From 6936e12da2dd99ba22e92537e27f1c821113799d Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 3 Aug 2017 17:15:39 +0200 Subject: [PATCH 001/686] Tau reco: Moving from PFJet to Jet, and from PFCandidate to Candidate --- .../TauReco/interface/JetPiZeroAssociation.h | 6 +- .../interface/PFJetChargedHadronAssociation.h | 6 +- .../interface/PFRecoTauChargedHadronPlugins.h | 6 +- .../interface/RecoTauCommonUtilities.h | 55 ++++++++++++------ .../RecoTau/interface/RecoTauQualityCuts.h | 36 ++++++------ .../interface/RecoTauVertexAssociator.h | 10 ++-- ...coTauChargedHadronFromPFCandidatePlugin.cc | 6 +- .../plugins/PFRecoTauChargedHadronProducer.cc | 20 +++++-- .../PFRecoTauDiscriminationByIsolation.cc | 6 +- .../RecoTau/plugins/RecoTauPhotonFilter.cc | 25 ++++---- .../RecoTauPiZeroCombinatoricPlugin.cc | 16 +++--- .../plugins/RecoTauPiZeroStripPlugin.cc | 20 +++---- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 3 +- .../RecoTau/src/RecoTauCommonUtilities.cc | 57 ++++++++++--------- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 50 ++++++++-------- .../RecoTau/src/RecoTauVertexAssociator.cc | 14 ++--- 16 files changed, 184 insertions(+), 152 deletions(-) diff --git a/DataFormats/TauReco/interface/JetPiZeroAssociation.h b/DataFormats/TauReco/interface/JetPiZeroAssociation.h index bf351a682b42b..697cb283e2cf1 100644 --- a/DataFormats/TauReco/interface/JetPiZeroAssociation.h +++ b/DataFormats/TauReco/interface/JetPiZeroAssociation.h @@ -3,12 +3,12 @@ #include "DataFormats/Common/interface/AssociationVector.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" namespace reco { // This base class improves the readability of the ROOT class name by hiding // the template crap - typedef edm::AssociationVector > > + typedef edm::AssociationVector > > JetPiZeroAssociationBase; class JetPiZeroAssociation : public JetPiZeroAssociationBase { @@ -17,7 +17,7 @@ namespace reco { JetPiZeroAssociationBase() { } - JetPiZeroAssociation(const reco::PFJetRefProd & ref) : + JetPiZeroAssociation(const JetRefBaseProd & ref) : JetPiZeroAssociationBase(ref) { } diff --git a/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h b/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h index 28a13e4f67aed..4a5f2f6acba2e 100644 --- a/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h +++ b/DataFormats/TauReco/interface/PFJetChargedHadronAssociation.h @@ -3,13 +3,13 @@ #include "DataFormats/Common/interface/AssociationVector.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" namespace reco { // This base class improves the readability of the ROOT class name by hiding // the template crap - typedef edm::AssociationVector > > PFJetChargedHadronAssociationBase; + typedef edm::AssociationVector > > PFJetChargedHadronAssociationBase; class PFJetChargedHadronAssociation : public PFJetChargedHadronAssociationBase { @@ -18,7 +18,7 @@ namespace reco : PFJetChargedHadronAssociationBase() {} - PFJetChargedHadronAssociation(const reco::PFJetRefProd& ref) + PFJetChargedHadronAssociation(const reco::JetRefBaseProd& ref) : PFJetChargedHadronAssociationBase(ref) {} diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h b/RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h index 06fc0543f22be..7b0ac9b2a1771 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h @@ -8,7 +8,7 @@ * * Base classes for plugins that construct and rank PFRecoTauChargedHadron * objects from a jet. The builder plugin has an abstract function - * that takes a PFJet and returns a list of reconstructed photons in + * that takes a Jet and returns a list of reconstructed photons in * the jet. * * The quality plugin has an abstract function that takes a reference @@ -27,7 +27,7 @@ namespace reco { // Forward declarations -class PFJet; +class Jet; class PFRecoTauChargedHadron; namespace tau { @@ -45,7 +45,7 @@ class PFRecoTauChargedHadronBuilderPlugin : public RecoTauEventHolderPlugin {} ~PFRecoTauChargedHadronBuilderPlugin() override {} /// Build a collection of chargedHadrons from objects in the input jet - virtual return_type operator()(const PFJet&) const = 0; + virtual return_type operator()(const Jet&) const = 0; /// Hook called at the beginning of the event. void beginEvent() override {} }; diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index 4edde8fbbb8cc..7d519bce30bc0 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -9,8 +9,8 @@ * */ -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include @@ -29,20 +29,20 @@ namespace reco { namespace tau { class SortPFCandsDescendingPt { public: - bool operator()(const PFCandidatePtr& a, const PFCandidatePtr& b) const { + bool operator()(const CandidatePtr& a, const CandidatePtr& b) const { return a->pt() > b->pt(); } }; -/// Filter a collection of objects that are convertible to PFCandidatePtrs +/// Filter a collection of objects that are convertible to CandidatePtrs /// by PFCandidate ID -template std::vector +template std::vector filterPFCandidates(const Iterator& begin, const Iterator& end, - int particleId, bool sort=true) { - std::vector output; + int pdgId, bool sort=true) { + std::vector output; for(Iterator iter = begin; iter != end; ++iter) { - reco::PFCandidatePtr ptr(*iter); - if (ptr->particleId() == particleId) + reco::CandidatePtr ptr(*iter); + if (std::abs(ptr->pdgId()) == pdgId) output.push_back(ptr); } if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt()); @@ -51,23 +51,23 @@ filterPFCandidates(const Iterator& begin, const Iterator& end, /// Extract pfCandidates of a given particle Id from a PFJet. If sort is true, /// candidates will be sorted by descending PT -std::vector pfCandidates(const PFJet& jet, - int particleId, bool sort=true); +std::vector pfCandidates(const Jet& jet, + int pdgId, bool sort=true); /// Extract pfCandidates of a that match a list of particle Ids from a PFJet -std::vector pfCandidates(const PFJet& jet, - const std::vector& particleIds, +std::vector pfCandidates(const Jet& jet, + const std::vector& pdgIds, bool sort=true); /// Extract all non-neutral candidates from a PFJet -std::vector pfChargedCands(const PFJet& jet, bool sort=true); +std::vector pfChargedCands(const Jet& jet, bool sort=true); /// Extract all pfGammas from a PFJet -std::vector pfGammas(const PFJet& jet, bool sort=true); +std::vector pfGammas(const Jet& jet, bool sort=true); /// Flatten a list of pi zeros into a list of there constituent PFCandidates -std::vector flattenPiZeros(const std::vector::const_iterator&, const std::vector::const_iterator&); -std::vector flattenPiZeros(const std::vector&); +std::vector flattenPiZeros(const std::vector::const_iterator&, const std::vector::const_iterator&); +std::vector flattenPiZeros(const std::vector&); /// Convert a BaseView (View) to a TRefVector template @@ -88,6 +88,7 @@ RefVectorType castView(const edm::Handle& view) { return output; } + /* *Given a range over a container of type C, return a new 'end' iterator such *that at max elements are taken. If there are less than N elements in the @@ -141,5 +142,25 @@ template InputIterator leadPFCand(InputIterator begin, } return max_cand; } + +std::vector convertPtrVector(const std::vector& cands) { + std::vector newSignalPFCands; + for (auto& cand : cands) { + const auto& newPtr = cand->masterClone().castTo >(); + newSignalPFCands.push_back(newPtr); + } + return newSignalPFCands; +} + +std::vector convertPtrVector(const std::vector& cands) { + std::vector newSignalCands; + for (auto& cand : cands) { + const auto& newPtr = cand->masterClone().castTo >(); + newSignalCands.push_back(newPtr); + } + return newSignalCands; +} + + }} // end namespace reco::tau #endif diff --git a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h index 71c40249fc3f5..f62a79b26449a 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h +++ b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h @@ -6,10 +6,10 @@ * * Author: Evan K. Friis * - * Constructs a number of independent requirements on PFCandidates by building + * Constructs a number of independent requirements on Candidates by building * binary predicate functions. These are held in a number of lists of - * functions. Each of these lists is mapped to a PFCandidate particle type - * (like hadron, gamma, etc). When a PFCandidate is passed to filter(), + * functions. Each of these lists is mapped to a Candidate particle type + * (like hadron, gamma, etc). When a Candidate is passed to filter(), * the correct list is looked up, and the result is the AND of all the predicate * functions. See the .cc files for the QCut functions. * @@ -23,8 +23,8 @@ #include #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -37,9 +37,9 @@ class RecoTauQualityCuts // Quality cut types typedef boost::function TrackQCutFunc; typedef std::vector TrackQCutFuncCollection; - typedef boost::function CandQCutFunc; + typedef boost::function CandQCutFunc; typedef std::vector CandQCutFuncCollection; - typedef std::map CandQCutFuncMap; + typedef std::map CandQCutFuncMap; explicit RecoTauQualityCuts(const edm::ParameterSet& qcuts); @@ -48,11 +48,11 @@ class RecoTauQualityCuts /// Update the leading track void setLeadTrack(const reco::TrackRef& leadTrack) const; - void setLeadTrack(const reco::PFCandidate& leadCand) const; + void setLeadTrack(const reco::Candidate& leadCand) const; /// Update the leading track (using reference) /// If null, this will set the lead track ref null. - void setLeadTrack(const reco::PFCandidateRef& leadCand) const; + void setLeadTrack(const reco::CandidateRef& leadCand) const; /// Filter a single Track bool filterTrack(const reco::TrackBaseRef& track) const; @@ -69,14 +69,14 @@ class RecoTauQualityCuts return output; } - /// Filter a single PFCandidate - bool filterCand(const reco::PFCandidate& cand) const; + /// Filter a single Candidate + bool filterCand(const reco::Candidate& cand) const; - /// Filter a PFCandidate held by a smart pointer or Ref - template - bool filterCandRef(const PFCandRefType& cand) const { return filterCand(*cand); } + /// Filter a Candidate held by a smart pointer or Ref + template + bool filterCandRef(const CandRefType& cand) const { return filterCand(*cand); } - /// Filter a ref vector of PFCandidates + /// Filter a ref vector of Candidates template Coll filterCandRefs(const Coll& refcoll, bool invert = false) const { @@ -89,9 +89,9 @@ class RecoTauQualityCuts private: template bool filterTrack_(const T& trackRef) const; - bool filterGammaCand(const reco::PFCandidate& cand) const; - bool filterNeutralHadronCand(const reco::PFCandidate& cand) const; - bool filterCandByType(const reco::PFCandidate& cand) const; + bool filterGammaCand(const reco::Candidate& cand) const; + bool filterNeutralHadronCand(const reco::Candidate& cand) const; + bool filterCandByType(const reco::Candidate& cand) const; // The current primary vertex mutable reco::VertexRef pv_; diff --git a/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h b/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h index c364edfd84809..b9f740e10b6a1 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h +++ b/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h @@ -25,7 +25,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" #include "DataFormats/Common/interface/AssociationMap.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" @@ -41,7 +41,7 @@ namespace edm { namespace reco { class PFTau; - class PFJet; + class Jet; } namespace reco { namespace tau { @@ -59,7 +59,7 @@ class RecoTauVertexAssociator { virtual ~RecoTauVertexAssociator(); /// Get the primary vertex associated to a given jet. /// Returns a null Ref if no vertex is found. - reco::VertexRef associatedVertex(const PFJet& jet) const; + reco::VertexRef associatedVertex(const Jet& jet) const; /// Convenience function to get the PV associated to the jet that /// seeded this tau (useJet=true, old behaviour) /// or leaging charged hadron if set (useJet=false). @@ -68,7 +68,7 @@ class RecoTauVertexAssociator { /// Load the vertices from the event. void setEvent(const edm::Event& evt); - reco::TrackBaseRef getLeadTrack(const PFJet& jet) const; + reco::TrackBaseRef getLeadTrack(const Jet& jet) const; private: edm::InputTag vertexTag_; @@ -84,7 +84,7 @@ class RecoTauVertexAssociator { int leadingTrkOrPFCandOption_; edm::EDGetTokenT vxToken_; // containers for holding vertices associated to jets - std::map* jetToVertexAssociation_; + std::map* jetToVertexAssociation_; edm::EventNumber_t lastEvent_; int verbosity_; }; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 03016fd1c70c8..6b0140e3e317d 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -21,7 +21,7 @@ #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" -#include "DataFormats/JetReco/interface/PFJet.h" +#include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Common/interface/RefToPtr.h" @@ -44,7 +44,7 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro explicit PFRecoTauChargedHadronFromPFCandidatePlugin(const edm::ParameterSet&, edm::ConsumesCollector &&iC); ~PFRecoTauChargedHadronFromPFCandidatePlugin() override; // Return type is auto_ptr - return_type operator()(const reco::PFJet&) const override; + return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; @@ -163,7 +163,7 @@ namespace } } -PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronFromPFCandidatePlugin::operator()(const reco::PFJet& jet) const +PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronFromPFCandidatePlugin::operator()(const reco::Jet& jet) const { if ( verbosity_ ) { edm::LogPrint("TauChHadronFromPF") << ":"; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 16d6685fa2207..a662c301384ad 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -73,7 +73,7 @@ class PFRecoTauChargedHadronProducer : public edm::stream::EDProducer<> // input jet collection edm::InputTag srcJets_; - edm::EDGetTokenT Jets_token; + edm::EDGetTokenT Jets_token; double minJetPt_; double maxJetAbsEta_; @@ -94,7 +94,7 @@ PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(const edm::Parame : moduleLabel_(cfg.getParameter("@module_label")) { srcJets_ = cfg.getParameter("jetSrc"); - Jets_token = consumes(srcJets_); + Jets_token = consumes(srcJets_); minJetPt_ = ( cfg.exists("minJetPt") ) ? cfg.getParameter("minJetPt") : -1.0; maxJetAbsEta_ = ( cfg.exists("maxJetAbsEta") ) ? cfg.getParameter("maxJetAbsEta") : 99.0; verbosity_ = ( cfg.exists("verbosity") ) ? @@ -147,11 +147,17 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe } // get a view of our jets via the base candidates - edm::Handle jets; + edm::Handle jets; evt.getByToken(Jets_token, jets); // convert the view to a RefVector of actual PFJets - reco::PFJetRefVector pfJets = reco::tau::castView(jets); + // reco::PFJetRefVector pfJets = reco::tau::castView(jets); + edm::RefToBaseVector pfJets; + // = reco::tau::castView>(jets); + size_t nElements = jets->size(); + for (size_t i = 0; i < nElements; ++i) { + pfJets.push_back(jets->refAt(i)); + } // make our association std::unique_ptr pfJetChargedHadronAssociations; @@ -160,13 +166,15 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe if ( !pfJets.empty() ) { edm::Handle pfJetCollectionHandle; evt.get(pfJets.id(), pfJetCollectionHandle); - pfJetChargedHadronAssociations = std::make_unique(reco::PFJetRefProd(pfJetCollectionHandle)); + pfJetChargedHadronAssociations = std::make_unique(reco::JetRefBaseProd(pfJetCollectionHandle)); } else { pfJetChargedHadronAssociations = std::make_unique(); } // loop over our jets - BOOST_FOREACH( const reco::PFJetRef& pfJet, pfJets ) { + // BOOST_FOREACH( const reco::JetBaseRef& pfJet, pfJets ) { + for (size_t i_j = 0; i_j < pfJets.size(); ++i_j) { + const auto& pfJet = pfJets.at(i_j); if(pfJet->pt() - minJetPt_ < 1e-5) continue; if(std::abs(pfJet->eta()) - maxJetAbsEta_ > -1e-5) continue; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 43c3b598b9bad..0b5bd4875b0f5 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -374,13 +374,13 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const if ( !(pv.isNonnull() && pfTau->leadPFChargedHadrCand().isNonnull()) ) return 0.; qcuts_->setPV(pv); - qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand()); + qcuts_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); if ( applyDeltaBeta_ || calculateWeights_) { pileupQcutsGeneralQCuts_->setPV(pv); - pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand()); + pileupQcutsGeneralQCuts_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); pileupQcutsPUTrackSelection_->setPV(pv); - pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand()); + pileupQcutsPUTrackSelection_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); } // Load the tracks if they are being used. diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc index 64f7a7c856816..c06c38b08cf1a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc @@ -54,6 +54,7 @@ bool RecoTauPhotonFilter::filter( const RecoTauPiZero* piZero, return piZero->pt()/total.pt() < minPtFractionSinglePhotons_; } + void RecoTauPhotonFilter::operator()(PFTau& tau) const { std::vector signalPiZeros; BOOST_FOREACH(const RecoTauPiZero& piZero, tau.signalPiZeroCandidates()) { @@ -103,38 +104,38 @@ void RecoTauPhotonFilter::operator()(PFTau& tau) const { tau.setisolationPiZeroCandidates(newIsolation); // Now we need to deal with the gamma candidates underlying moved pizeros. - std::vector pfcandsToMove = flattenPiZeros(toMove); + std::vector pfcandsToMove = flattenPiZeros(toMove); // Copy the keys to move std::set keysToMove; - BOOST_FOREACH(const PFCandidatePtr& ptr, pfcandsToMove) { + BOOST_FOREACH(const CandidatePtr& ptr, pfcandsToMove) { keysToMove.insert(ptr.key()); } - std::vector newSignalPFGammas; - std::vector newSignalPFCands; - std::vector newIsolationPFGammas = tau.isolationPFGammaCands(); - std::vector newIsolationPFCands = tau.isolationPFCands(); + std::vector newSignalPFGammas; + std::vector newSignalPFCands; + std::vector newIsolationPFGammas = convertPtrVector(tau.isolationPFGammaCands()); + std::vector newIsolationPFCands = convertPtrVector(tau.isolationPFCands()); // Move the necessary signal pizeros - what a mess! - BOOST_FOREACH(const PFCandidatePtr& ptr, tau.signalPFCands()) { + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFCands()) { if (keysToMove.count(ptr.key())) newIsolationPFCands.push_back(ptr); else newSignalPFCands.push_back(ptr); } - BOOST_FOREACH(const PFCandidatePtr& ptr, tau.signalPFGammaCands()) { + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFGammaCands()) { if (keysToMove.count(ptr.key())) newIsolationPFGammas.push_back(ptr); else newSignalPFGammas.push_back(ptr); } - tau.setsignalPFCands(newSignalPFCands); - tau.setsignalPFCands(newSignalPFGammas); - tau.setisolationPFGammaCands(newIsolationPFGammas); - tau.setisolationPFCands(newIsolationPFCands); + tau.setsignalPFCands(convertPtrVector(newSignalPFCands)); + tau.setsignalPFCands(convertPtrVector(newSignalPFGammas)); + tau.setisolationPFGammaCands(convertPtrVector(newIsolationPFGammas)); + tau.setisolationPFCands(convertPtrVector(newIsolationPFCands)); } } }} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc index 8aa6ca45d8ab5..93fcdf75147f9 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc @@ -13,8 +13,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" @@ -55,24 +55,24 @@ RecoTauPiZeroCombinatoricPlugin::return_type RecoTauPiZeroCombinatoricPlugin::operator()( const reco::PFJet& jet) const { // Get list of gamma candidates - typedef std::vector PFCandPtrs; - typedef PFCandPtrs::const_iterator PFCandIter; + typedef std::vector CandPtrs; + typedef CandPtrs::const_iterator CandIter; PiZeroVector output; - PFCandPtrs pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet)); + CandPtrs pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet)); // Check if we have anything to do... if (pfGammaCands.size() < choose_) return output.release(); // Define the valid range of gammas to use - PFCandIter start_iter = pfGammaCands.begin(); - PFCandIter end_iter = pfGammaCands.end(); + CandIter start_iter = pfGammaCands.begin(); + CandIter end_iter = pfGammaCands.end(); // Only take the desired number of piZeros end_iter = takeNElements(start_iter, end_iter, maxInputGammas_); // Build the combinatoric generator - typedef CombinatoricGenerator ComboGenerator; + typedef CombinatoricGenerator ComboGenerator; ComboGenerator generator(start_iter, end_iter, choose_); // Find all possible combinations diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc index 3fe6eac5f5880..6732488a33155 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc @@ -16,8 +16,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" @@ -96,24 +96,24 @@ void RecoTauPiZeroStripPlugin::beginEvent() { RecoTauPiZeroStripPlugin::return_type RecoTauPiZeroStripPlugin::operator()( const reco::PFJet& jet) const { // Get list of gamma candidates - typedef std::vector PFCandPtrs; - typedef PFCandPtrs::iterator PFCandIter; + typedef std::vector CandPtrs; + typedef CandPtrs::iterator CandIter; PiZeroVector output; // Get the candidates passing our quality cuts qcuts_.setPV(vertexAssociator_.associatedVertex(jet)); - PFCandPtrs candsVector = qcuts_.filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_.filterCandRefs(pfCandidates(jet, inputPdgIds_)); //PFCandPtrs candsVector = qcuts_.filterCandRefs(pfGammas(jet)); // Convert to stl::list to allow fast deletions - typedef std::list PFCandPtrList; - typedef std::list::iterator PFCandPtrListIter; - PFCandPtrList cands; + typedef std::list CandPtrList; + typedef std::list::iterator CandPtrListIter; + CandPtrList cands; cands.insert(cands.end(), candsVector.begin(), candsVector.end()); while (!cands.empty()) { // Seed this new strip, and delete it from future strips - PFCandidatePtr seed = cands.front(); + CandidatePtr seed = cands.front(); cands.pop_front(); // Add a new candidate to our collection using this seed @@ -122,7 +122,7 @@ RecoTauPiZeroStripPlugin::return_type RecoTauPiZeroStripPlugin::operator()( strip->addDaughter(seed); // Find all other objects in the strip - PFCandPtrListIter stripCand = cands.begin(); + CandPtrListIter stripCand = cands.begin(); while(stripCand != cands.end()) { if( fabs(strip->eta() - (*stripCand)->eta()) < etaAssociationDistance_ && fabs(deltaPhi(*strip, **stripCand)) < phiAssociationDistance_ ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index a5a55e3e7f551..ac208f951f3b1 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -134,7 +134,8 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) evt.getByToken(jet_token, jetView); // Convert to a vector of PFJetRefs - reco::PFJetRefVector jets = reco::tau::castView(jetView); + // reco::PFJetRefVector jets = reco::tau::castView(jetView); + edm::RefToBaseVector jets = reco::tau::castView>(jetView); // Get the jet region producer edm::Handle > jetRegionHandle; diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 1ffafeb4f086b..0dbe0c19a5813 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -1,69 +1,70 @@ #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/CandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/Candidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/JetReco/interface/PFJet.h" +#include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include -typedef std::vector PFCandPtrs; -typedef PFCandPtrs::iterator PFCandIter; +typedef std::vector CandPtrs; +typedef CandPtrs::iterator CandIter; namespace reco { namespace tau { -std::vector +std::vector flattenPiZeros(const std::vector::const_iterator& piZerosBegin, const std::vector::const_iterator& piZerosEnd) { - std::vector output; + std::vector output; for(std::vector::const_iterator piZero = piZerosBegin; piZero != piZerosEnd; ++piZero) { for(size_t iDaughter = 0; iDaughter < piZero->numberOfDaughters(); ++iDaughter) { - output.push_back(PFCandidatePtr(piZero->daughterPtr(iDaughter))); + output.push_back(CandidatePtr(piZero->daughterPtr(iDaughter))); } } return output; } -std::vector +std::vector flattenPiZeros(const std::vector& piZeros) { return flattenPiZeros(piZeros.begin(), piZeros.end()); } -std::vector pfCandidates(const reco::PFJet& jet, - int particleId, bool sort) { - PFCandPtrs pfCands = jet.getPFConstituents(); - PFCandPtrs selectedPFCands = filterPFCandidates( - pfCands.begin(), pfCands.end(), particleId, sort); +std::vector pfCandidates(const reco::Jet& jet, + int pdgId, bool sort) { + CandPtrs pfCands = jet.getPFConstituents(); + CandPtrs selectedPFCands = filterPFCandidates( + pfCands.begin(), pfCands.end(), pdgId, sort); return selectedPFCands; } -std::vector pfCandidates(const reco::PFJet& jet, - const std::vector& particleIds, bool sort) { - PFCandPtrs&& pfCands = jet.getPFConstituents(); - PFCandPtrs output; +std::vector pfCandidates(const reco::Jet& jet, + const std::vector& pdgIds, bool sort) { + CandPtrs&& pfCands = jet.getPFConstituents(); + CandPtrs output; // Get each desired candidate type, unsorted for now - for(std::vector::const_iterator particleId = particleIds.begin(); - particleId != particleIds.end(); ++particleId) { - PFCandPtrs&& selectedPFCands = filterPFCandidates(pfCands.begin(), pfCands.end(), *particleId, false); + for(std::vector::const_iterator pdgId = pdgIds.begin(); + pdgId != pdgIds.end(); ++pdgId) { + CandPtrs&& selectedPFCands = filterPFCandidates(pfCands.begin(), pfCands.end(), *pdgId, false); output.insert(output.end(), selectedPFCands.begin(), selectedPFCands.end()); } if (sort) std::sort(output.begin(), output.end(), SortPFCandsDescendingPt()); return output; } -std::vector pfGammas(const reco::PFJet& jet, bool sort) { - return pfCandidates(jet, reco::PFCandidate::gamma, sort); +std::vector pfGammas(const reco::Jet& jet, bool sort) { + return pfCandidates(jet, 22, sort); } -std::vector pfChargedCands(const reco::PFJet& jet, +std::vector pfChargedCands(const reco::Jet& jet, bool sort) { - PFCandPtrs&& pfCands = jet.getPFConstituents(); - PFCandPtrs output; - PFCandPtrs&& mus = filterPFCandidates(pfCands.begin(), pfCands.end(), reco::PFCandidate::mu, false); - PFCandPtrs&& es = filterPFCandidates(pfCands.begin(), pfCands.end(), reco::PFCandidate::e, false); - PFCandPtrs&& chs = filterPFCandidates(pfCands.begin(), pfCands.end(), reco::PFCandidate::h, false); + CandPtrs&& pfCands = jet.getPFConstituents(); + CandPtrs output; + CandPtrs&& mus = filterPFCandidates(pfCands.begin(), pfCands.end(), 13, false); + CandPtrs&& es = filterPFCandidates(pfCands.begin(), pfCands.end(), 11, false); + CandPtrs&& chs = filterPFCandidates(pfCands.begin(), pfCands.end(), 211, false); output.reserve(mus.size() + es.size() + chs.size()); output.insert(output.end(), mus.begin(), mus.end()); output.insert(output.end(), es.begin(), es.end()); diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index 4250b9b11e4e3..057f096f723fc 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -10,7 +10,7 @@ namespace reco { namespace tau { namespace { // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. - const reco::TrackBaseRef getTrackRef(const PFCandidate& cand) + const reco::TrackBaseRef getTrackRef(const Candidate& cand) { if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); else if ( cand.gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(cand.gsfTrackRef()); @@ -33,13 +33,13 @@ bool ptMin(const TrackBaseRef& track, double cut) return (track->pt() > cut); } -bool ptMin_cand(const PFCandidate& cand, double cut) +bool ptMin_cand(const Candidate& cand, double cut) { LogDebug("TauQCuts") << ": Pt = " << cand.pt() << ", cut = " << cut ; return (cand.pt() > cut); } -bool etMin_cand(const PFCandidate& cand, double cut) +bool etMin_cand(const Candidate& cand, double cut) { LogDebug("TauQCuts") << ": Et = " << cand.et() << ", cut = " << cut ; return (cand.et() > cut); @@ -52,7 +52,7 @@ bool trkPixelHits(const TrackBaseRef& track, int cut) return (track->hitPattern().numberOfValidPixelHits() >= cut); } -bool trkPixelHits_cand(const PFCandidate& cand, int cut) +bool trkPixelHits_cand(const Candidate& cand, int cut) { // For some reason, the number of hits is signed auto track = getTrackRef(cand); @@ -71,7 +71,7 @@ bool trkTrackerHits(const TrackBaseRef& track, int cut) return (track->hitPattern().numberOfValidHits() >= cut); } -bool trkTrackerHits_cand(const PFCandidate& cand, int cut) +bool trkTrackerHits_cand(const Candidate& cand, int cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { @@ -96,7 +96,7 @@ bool trkTransverseImpactParameter(const TrackBaseRef& track, const reco::VertexR return (std::fabs(track->dxy((*pv)->position())) <= cut); } -bool trkTransverseImpactParameter_cand(const PFCandidate& cand, const reco::VertexRef* pv, double cut) +bool trkTransverseImpactParameter_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { @@ -120,7 +120,7 @@ bool trkLongitudinalImpactParameter(const TrackBaseRef& track, const reco::Verte return (std::fabs(track->dz((*pv)->position())) <= cut); } -bool trkLongitudinalImpactParameter_cand(const PFCandidate& cand, const reco::VertexRef* pv, double cut) +bool trkLongitudinalImpactParameter_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { @@ -142,7 +142,7 @@ bool trkLongitudinalImpactParameterWrtTrack(const TrackBaseRef& track, const rec return (std::fabs(track->dz((*pv)->position()) - (*leadTrack)->dz((*pv)->position())) <= cut); } -bool trkLongitudinalImpactParameterWrtTrack_cand(const PFCandidate& cand, const reco::TrackBaseRef* leadTrack, const reco::VertexRef* pv, double cut) +bool trkLongitudinalImpactParameterWrtTrack_cand(const Candidate& cand, const reco::TrackBaseRef* leadTrack, const reco::VertexRef* pv, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) return trkLongitudinalImpactParameterWrtTrack(track, leadTrack, pv, cut); @@ -162,7 +162,7 @@ bool minTrackVertexWeight(const TrackBaseRef& track, const reco::VertexRef* pv, return ((*pv)->trackWeight(track) >= cut); } -bool minTrackVertexWeight_cand(const PFCandidate& cand, const reco::VertexRef* pv, double cut) +bool minTrackVertexWeight_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { @@ -179,7 +179,7 @@ bool trkChi2(const TrackBaseRef& track, double cut) return (track->normalizedChi2() <= cut); } -bool trkChi2_cand(const PFCandidate& cand, double cut) +bool trkChi2_cand(const Candidate& cand, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { @@ -200,7 +200,7 @@ bool AND(const TrackBaseRef& track, const RecoTauQualityCuts::TrackQCutFuncColle return true; } -bool AND_cand(const PFCandidate& cand, const RecoTauQualityCuts::CandQCutFuncCollection& cuts) +bool AND_cand(const Candidate& cand, const RecoTauQualityCuts::CandQCutFuncCollection& cuts) { BOOST_FOREACH( const RecoTauQualityCuts::CandQCutFunc& func, cuts ) { if ( !func(cand) ) return false; @@ -209,10 +209,10 @@ bool AND_cand(const PFCandidate& cand, const RecoTauQualityCuts::CandQCutFuncCol } // Get the set of Q cuts for a given type (i.e. gamma) -bool mapAndCutByType(const PFCandidate& cand, const RecoTauQualityCuts::CandQCutFuncMap& funcMap) +bool mapAndCutByType(const Candidate& cand, const RecoTauQualityCuts::CandQCutFuncMap& funcMap) { // Find the cuts that for this particle type - RecoTauQualityCuts::CandQCutFuncMap::const_iterator cuts = funcMap.find(cand.particleId()); + RecoTauQualityCuts::CandQCutFuncMap::const_iterator cuts = funcMap.find(std::abs(cand.pdgId())); // Return false if we dont' know how to deal with this particle type if ( cuts == funcMap.end() ) return false; return AND_cand(cand, cuts->second); // Otherwise AND all the cuts @@ -378,26 +378,26 @@ bool RecoTauQualityCuts::filterTrack_(const T& trackRef) const return true; } -bool RecoTauQualityCuts::filterGammaCand(const reco::PFCandidate& cand) const { +bool RecoTauQualityCuts::filterGammaCand(const reco::Candidate& cand) const { if(minGammaEt_ >= 0 && !(cand.et() > minGammaEt_)) return false; return true; } -bool RecoTauQualityCuts::filterNeutralHadronCand(const reco::PFCandidate& cand) const { +bool RecoTauQualityCuts::filterNeutralHadronCand(const reco::Candidate& cand) const { if(minNeutralHadronEt_ >= 0 && !(cand.et() > minNeutralHadronEt_)) return false; return true; } -bool RecoTauQualityCuts::filterCandByType(const reco::PFCandidate& cand) const { - switch(cand.particleId()) { - case PFCandidate::gamma: +bool RecoTauQualityCuts::filterCandByType(const reco::Candidate& cand) const { + switch(std::abs(cand.pdgId())) { + case 22: return filterGammaCand(cand); - case PFCandidate::h0: + case 130: return filterNeutralHadronCand(cand); // We use the same qcuts for muons/electrons and charged hadrons. - case PFCandidate::h: - case PFCandidate::e: - case PFCandidate::mu: + case 211: + case 11: + case 13: // no cuts ATM (track cuts applied in filterCand) return true; // Return false if we dont' know how to deal with this particle type @@ -407,7 +407,7 @@ bool RecoTauQualityCuts::filterCandByType(const reco::PFCandidate& cand) const { return false; } -bool RecoTauQualityCuts::filterCand(const reco::PFCandidate& cand) const +bool RecoTauQualityCuts::filterCand(const reco::Candidate& cand) const { auto trackRef = cand.trackRef(); bool result = true; @@ -430,12 +430,12 @@ void RecoTauQualityCuts::setLeadTrack(const reco::TrackRef& leadTrack) const leadTrack_ = reco::TrackBaseRef(leadTrack); } -void RecoTauQualityCuts::setLeadTrack(const reco::PFCandidate& leadCand) const +void RecoTauQualityCuts::setLeadTrack(const reco::Candidate& leadCand) const { leadTrack_ = getTrackRef(leadCand); } -void RecoTauQualityCuts::setLeadTrack(const reco::PFCandidateRef& leadCand) const +void RecoTauQualityCuts::setLeadTrack(const reco::CandidateRef& leadCand) const { if ( leadCand.isNonnull() ) { leadTrack_ = getTrackRef(*leadCand); diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 82568dca1ea59..14f5aa0fcecaf 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -17,7 +17,7 @@ namespace reco { namespace tau { // Get the highest pt track in a jet. // Get the KF track if it exists. Otherwise, see if it has a GSF track. -reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const PFJet& jet) const +reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const { std::vector chargedPFCands = pfChargedCands(jet, true); if ( verbosity_ >= 1 ) { @@ -229,7 +229,7 @@ void RecoTauVertexAssociator::setEvent(const edm::Event& evt) } edm::EventNumber_t currentEvent = evt.id().event(); if ( currentEvent != lastEvent_ || !jetToVertexAssociation_ ) { - if ( !jetToVertexAssociation_ ) jetToVertexAssociation_ = new std::map; + if ( !jetToVertexAssociation_ ) jetToVertexAssociation_ = new std::map; else jetToVertexAssociation_->clear(); lastEvent_ = currentEvent; } @@ -248,7 +248,7 @@ RecoTauVertexAssociator::associatedVertex(const PFTau& tau, bool useJet) const } } // MB: use vertex associated to a given jet if explicitely requested or in case of missing leading track - reco::PFJetRef jetRef = tau.jetRef(); + reco::JetRef jetRef = tau.jetRef(); // FIXME workaround for HLT which does not use updated data format if ( jetRef.isNull() ) jetRef = tau.pfTauTagInfoRef()->pfjetRef(); return associatedVertex(*jetRef); @@ -335,7 +335,7 @@ RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const } reco::VertexRef -RecoTauVertexAssociator::associatedVertex(const PFJet& jet) const +RecoTauVertexAssociator::associatedVertex(const Jet& jet) const { if ( verbosity_ >= 1 ) { std::cout << ":" << std::endl; @@ -348,10 +348,10 @@ RecoTauVertexAssociator::associatedVertex(const PFJet& jet) const } reco::VertexRef jetVertex = ( !selectedVertices_.empty() ) ? selectedVertices_[0] : reco::VertexRef(); - const PFJet* jetPtr = &jet; + const Jet* jetPtr = &jet; // check if jet-vertex association has been determined for this jet before - std::map::iterator vertexPtr = jetToVertexAssociation_->find(jetPtr); + std::map::iterator vertexPtr = jetToVertexAssociation_->find(jetPtr); if ( vertexPtr != jetToVertexAssociation_->end() ) { jetVertex = vertexPtr->second; } else { @@ -372,7 +372,7 @@ RecoTauVertexAssociator::associatedVertex(const PFJet& jet) const } } - jetToVertexAssociation_->insert(std::pair(jetPtr, jetVertex)); + jetToVertexAssociation_->insert(std::pair(jetPtr, jetVertex)); } if ( verbosity_ >= 1 ) { From 46aa930578c17b34d06a5cb399e2f6af9f625a9e Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 4 Aug 2017 16:31:18 +0200 Subject: [PATCH 002/686] Tau reco: Moving from PFJet to Jet, and from PFCandidate to Candidate, continued --- .../interface/PFRecoTauChargedHadron.h | 8 +- RecoTauTag/RecoTau/interface/ConeTools.h | 4 + .../RecoTau/interface/RecoTauBuilderPlugins.h | 2 +- .../interface/RecoTauCommonUtilities.h | 1 + .../RecoTau/interface/RecoTauCrossCleaning.h | 16 ++- ...coTauChargedHadronFromPFCandidatePlugin.cc | 98 +++++++++++-------- .../plugins/PFRecoTauChargedHadronProducer.cc | 27 ++--- .../plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 10 +- .../plugins/RecoTauBuilderConePlugin.cc | 76 +++++++------- .../RecoTau/src/RecoTauCommonUtilities.cc | 25 +++++ 10 files changed, 165 insertions(+), 102 deletions(-) diff --git a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h index 1b00b64f058e2..6853be31fb261 100644 --- a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h +++ b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h @@ -47,13 +47,13 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate ~PFRecoTauChargedHadron() override; /// reference to "charged" PFCandidate (either charged PFCandidate or PFNeutralHadron) - const PFCandidatePtr& getChargedPFCandidate() const; + const CandidatePtr& getChargedPFCandidate() const; /// reference to reco::Track const TrackPtr& getTrack() const; /// references to additional neutral PFCandidates - const std::vector& getNeutralPFCandidates() const; + const std::vector& getNeutralPFCandidates() const; /// position at ECAL entrance const math::XYZPointF& positionAtECALEntrance() const; @@ -75,9 +75,9 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate PFRecoTauChargedHadronAlgorithm algo_; - PFCandidatePtr chargedPFCandidate_; + CandidatePtr chargedPFCandidate_; TrackPtr track_; - std::vector neutralPFCandidates_; + std::vector neutralPFCandidates_; math::XYZPointF positionAtECALEntrance_; }; diff --git a/RecoTauTag/RecoTau/interface/ConeTools.h b/RecoTauTag/RecoTau/interface/ConeTools.h index 12fa9da09fe4c..b943d4db16ba5 100644 --- a/RecoTauTag/RecoTau/interface/ConeTools.h +++ b/RecoTauTag/RecoTau/interface/ConeTools.h @@ -49,6 +49,10 @@ typedef DeltaRPtrFilter PFCandPtrDRFilter; typedef boost::filter_iterator< PFCandPtrDRFilter, std::vector::const_iterator> PFCandPtrDRFilterIter; +typedef DeltaRPtrFilter CandPtrDRFilter; +typedef boost::filter_iterator< CandPtrDRFilter, + std::vector::const_iterator> CandPtrDRFilterIter; + typedef DeltaRFilter ChargedHadronDRFilter; typedef boost::filter_iterator< ChargedHadronDRFilter, std::vector::const_iterator> ChargedHadronDRFilterIter; diff --git a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h index 6388f996f632e..01b2f0e485ff3 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h +++ b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h @@ -76,7 +76,7 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin const reco::PFJetRef&, const std::vector&, const std::vector&, - const std::vector&) const = 0; + const std::vector&) const = 0; /// Hack to be able to convert Ptrs to Refs const edm::Handle& getPFCands() const { return pfCands_; }; diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index 7d519bce30bc0..bf46c9bcf35c0 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -161,6 +161,7 @@ std::vector convertPtrVector(const std::vector& ca return newSignalCands; } +math::XYZPoint atECALEntrance(const reco::Candidate* part); }} // end namespace reco::tau #endif diff --git a/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h b/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h index 3b91e34d5c5bc..6c8118a7c30c7 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h @@ -104,7 +104,7 @@ class FilterPFCandByParticleId { public: FilterPFCandByParticleId(int particleId): id_(particleId){}; - template + template bool operator()(const PFCandCompatiblePtrType& ptr) const { return ptr->particleId() == id_; } @@ -112,6 +112,20 @@ class FilterPFCandByParticleId { int id_; }; +// Predicate to filter CandPtrs by the abs(pdgId) +class FilterCandByAbsPdgId { + public: + FilterCandByAbsPdgId(int pdgId): + id_(pdgId){}; + template + bool operator()(const CandCompatiblePtrType& ptr) const { + CandidatePtr pfptr(ptr); + return std::abs(ptr->pdgId()) == id_; + } + private: + int id_; +}; + // Create the AND of two predicates template class PredicateAND { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 6b0140e3e317d..0847d57b65edd 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -49,7 +49,7 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro void beginEvent() override; private: - typedef std::vector PFCandPtrs; + typedef std::vector CandPtrs; RecoTauVertexAssociator vertexAssociator_; @@ -119,18 +119,18 @@ void PFRecoTauChargedHadronFromPFCandidatePlugin::beginEvent() namespace { - std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) - { - if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; - else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; - else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; - else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; - else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; - else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; - else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; - else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; - else assert(0); - } + // std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) + // { + // if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; + // else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; + // else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; + // else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; + // else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; + // else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; + // else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; + // else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; + // else assert(0); + // } bool isMatchedByBlockElement(const reco::PFCandidate& pfCandidate1, const reco::PFCandidate& pfCandidate2, int minMatches1, int minMatches2, int maxUnmatchedBlockElements1plus2) { @@ -174,68 +174,82 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - PFCandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); - for ( PFCandPtrs::iterator cand = candsVector.begin(); + for ( CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand ) { if ( verbosity_ ) { edm::LogPrint("TauChHadronFromPF") << "processing PFCandidate: Pt = " << (*cand)->pt() << ", eta = " << (*cand)->eta() << ", phi = " << (*cand)->phi() - << " (type = " << getPFCandidateType((*cand)->particleId()) << ", charge = " << (*cand)->charge() << ")" ; + << " (pdgId = " << (*cand)->pdgId() << ", charge = " << (*cand)->charge() << ")" ; } PFRecoTauChargedHadron::PFRecoTauChargedHadronAlgorithm algo = PFRecoTauChargedHadron::kUndefined; if ( std::abs((*cand)->charge()) > 0.5 ) algo = PFRecoTauChargedHadron::kChargedPFCandidate; else algo = PFRecoTauChargedHadron::kPFNeutralHadron; std::auto_ptr chargedHadron(new PFRecoTauChargedHadron(**cand, algo)); - if ( (*cand)->trackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr((*cand)->trackRef()); - else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->innerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr((*cand)->muonRef()->innerTrack()); - else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr((*cand)->muonRef()->globalTrack()); - else if ( (*cand)->muonRef().isNonnull() && (*cand)->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr((*cand)->muonRef()->outerTrack()); - else if ( (*cand)->gsfTrackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr((*cand)->gsfTrackRef()); + + // JAN - work on this. This must be adapted carefully to MiniAOD packed candidates + const reco::PFCandidate* pfCand = dynamic_cast(&**cand); + if (pfCand) { + if ( pfCand->trackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->trackRef()); + else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->innerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->innerTrack()); + else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->globalTrack()); + else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->outerTrack()); + else if ( pfCand->gsfTrackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->gsfTrackRef()); + + + } + chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand); chargedHadron->chargedPFCandidate_ = (*cand); chargedHadron->addDaughter(*cand); + - chargedHadron->positionAtECALEntrance_ = (*cand)->positionAtECALEntrance(); - - reco::PFCandidate::ParticleType chargedPFCandidateType = chargedHadron->chargedPFCandidate_->particleId(); + // reco::PFCandidate::ParticleType chargedPFCandidateType = chargedHadron->chargedPFCandidate_->particleId(); + int pdgId = std::abs(chargedHadron->chargedPFCandidate_->pdgId()); if ( chargedHadron->pt() > minMergeChargedHadronPt_ ) { - std::vector jetConstituents = jet.getPFConstituents(); - for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); + std::vector jetConstituents = jet.daughterPtrVector(); + for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); jetConstituent != jetConstituents.end(); ++jetConstituent ) { // CV: take care of not double-counting energy in case "charged" PFCandidate is in fact a PFNeutralHadron if ( (*jetConstituent) == chargedHadron->chargedPFCandidate_ ) continue; - reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId(); - if ( !(jetConstituentType == reco::PFCandidate::h0 || jetConstituentType == reco::PFCandidate::gamma) ) continue; + // reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId(); + int jetConstituentPdgId = std::abs((*jetConstituent)->pdgId()); + if ( !(jetConstituentPdgId == 130 || jetConstituentPdgId == 22) ) continue; - double dR = deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_); + double dR = deltaR(atECALEntrance(&**jetConstituent), atECALEntrance(&*chargedHadron)); double dRmerge = -1.; int minBlockElementMatches = 1000; int maxUnmatchedBlockElements = 0; double minMergeEt = 1.e+6; - if ( jetConstituentType == reco::PFCandidate::h0 ) { - if ( chargedPFCandidateType == reco::PFCandidate::h ) dRmerge = dRmergeNeutralHadronWrtChargedHadron_; - else if ( chargedPFCandidateType == reco::PFCandidate::h0 ) dRmerge = dRmergeNeutralHadronWrtNeutralHadron_; - else if ( chargedPFCandidateType == reco::PFCandidate::e ) dRmerge = dRmergeNeutralHadronWrtElectron_; + if ( jetConstituentPdgId == 130 ) { + if ( pdgId == 211 ) dRmerge = dRmergeNeutralHadronWrtChargedHadron_; + else if ( pdgId == 130 ) dRmerge = dRmergeNeutralHadronWrtNeutralHadron_; + else if ( pdgId == 11 ) dRmerge = dRmergeNeutralHadronWrtElectron_; else dRmerge = dRmergeNeutralHadronWrtOther_; minBlockElementMatches = minBlockElementMatchesNeutralHadron_; maxUnmatchedBlockElements = maxUnmatchedBlockElementsNeutralHadron_; minMergeEt = minMergeNeutralHadronEt_; - } else if ( jetConstituentType == reco::PFCandidate::gamma ) { - if ( chargedPFCandidateType == reco::PFCandidate::h ) dRmerge = dRmergePhotonWrtChargedHadron_; - else if ( chargedPFCandidateType == reco::PFCandidate::h0 ) dRmerge = dRmergePhotonWrtNeutralHadron_; - else if ( chargedPFCandidateType == reco::PFCandidate::e ) dRmerge = dRmergePhotonWrtElectron_; + } else if ( jetConstituentPdgId == 22 ) { + if ( pdgId == 211 ) dRmerge = dRmergePhotonWrtChargedHadron_; + else if ( pdgId == 130 ) dRmerge = dRmergePhotonWrtNeutralHadron_; + else if ( pdgId == 11 ) dRmerge = dRmergePhotonWrtElectron_; else dRmerge = dRmergePhotonWrtOther_; minBlockElementMatches = minBlockElementMatchesPhoton_; maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_; minMergeEt = minMergeGammaEt_; } - if ( (*jetConstituent)->et() > minMergeEt && - (dR < dRmerge || isMatchedByBlockElement(**jetConstituent, *chargedHadron->chargedPFCandidate_, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) ) { - chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); - chargedHadron->addDaughter(*jetConstituent); - } + // JAN - FIXME - block matching possible in miniAOD? probably not?? but is it important after all? + const reco::PFCandidate* pfCHCand = dynamic_cast(&*chargedHadron->chargedPFCandidate_); + const reco::PFCandidate* pfJetConstituent = dynamic_cast(&**jetConstituent); + if (pfCHCand && pfJetConstituent) { + if ( (*jetConstituent)->et() > minMergeEt && + (dR < dRmerge || isMatchedByBlockElement(*pfJetConstituent, *pfCHCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) ) { + chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); + chargedHadron->addDaughter(*jetConstituent); + } + } } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index a662c301384ad..1a080fab6e3ec 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -208,7 +208,7 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe // keep track of neutral PFCandidates, charged PFCandidates and tracks "used" by ChargedHadron candidates in the clean collection typedef std::pair etaPhiPair; std::list tracksInCleanCollection; - std::set neutralPFCandsInCleanCollection; + std::set neutralPFCandsInCleanCollection; while ( !uncleanedChargedHadrons.empty() ) { @@ -224,12 +224,14 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe const reco::Track* track = nullptr; if ( nextChargedHadron->getChargedPFCandidate().isNonnull() ) { - const reco::PFCandidatePtr& chargedPFCand = nextChargedHadron->getChargedPFCandidate(); - if ( chargedPFCand->trackRef().isNonnull() ) track = chargedPFCand->trackRef().get(); - else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->innerTrack().isNonnull() ) track = chargedPFCand->muonRef()->innerTrack().get(); - else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->globalTrack().isNonnull() ) track = chargedPFCand->muonRef()->globalTrack().get(); - else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->outerTrack().isNonnull() ) track = chargedPFCand->muonRef()->outerTrack().get(); - else if ( chargedPFCand->gsfTrackRef().isNonnull() ) track = chargedPFCand->gsfTrackRef().get(); + const reco::PFCandidate* chargedPFCand = dynamic_cast (&*nextChargedHadron->getChargedPFCandidate()); + if (chargedPFCand) { + if ( chargedPFCand->trackRef().isNonnull() ) track = chargedPFCand->trackRef().get(); + else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->innerTrack().isNonnull() ) track = chargedPFCand->muonRef()->innerTrack().get(); + else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->globalTrack().isNonnull() ) track = chargedPFCand->muonRef()->globalTrack().get(); + else if ( chargedPFCand->muonRef().isNonnull() && chargedPFCand->muonRef()->outerTrack().isNonnull() ) track = chargedPFCand->muonRef()->outerTrack().get(); + else if ( chargedPFCand->gsfTrackRef().isNonnull() ) track = chargedPFCand->gsfTrackRef().get(); + } } if ( nextChargedHadron->getTrack().isNonnull() && !track ) { track = nextChargedHadron->getTrack().get(); @@ -254,9 +256,12 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe // discard ChargedHadron candidates without track in case they are close to neutral PFCandidates "used" by ChargedHadron candidates in the clean collection bool isNeutralPFCand_overlap = false; if ( nextChargedHadron->algoIs(reco::PFRecoTauChargedHadron::kPFNeutralHadron) ) { - for ( std::set::const_iterator neutralPFCandInCleanCollection = neutralPFCandsInCleanCollection.begin(); + for ( std::set::const_iterator neutralPFCandInCleanCollection = neutralPFCandsInCleanCollection.begin(); neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end(); ++neutralPFCandInCleanCollection ) { - if ( (*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate() ) isNeutralPFCand_overlap = true; + // JAN - FIXME - this should be fine according to the documentation but need to double-check + // if ( neutralPFCandInCleanCollection->id() == nextChargedHadron->getChargedPFCandidate().id() ) + if ( (*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate() ) isNeutralPFCand_overlap = true; + } } if ( verbosity_ ) { @@ -265,7 +270,7 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe if ( isNeutralPFCand_overlap ) continue; // find neutral PFCandidates that are not "used" by any ChargedHadron in the clean collection - std::vector uniqueNeutralPFCands; + std::vector uniqueNeutralPFCands; std::set_difference(nextChargedHadron->getNeutralPFCandidates().begin(), nextChargedHadron->getNeutralPFCandidates().end(), neutralPFCandsInCleanCollection.begin(), @@ -281,7 +286,7 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe cleanedChargedHadrons.push_back(*nextChargedHadron); } else { // remove overlapping neutral PFCandidates, reevaluate ranking criterion and process ChargedHadron candidate again nextChargedHadron->neutralPFCandidates_.clear(); - BOOST_FOREACH( const reco::PFCandidatePtr& neutralPFCand, uniqueNeutralPFCands ) { + BOOST_FOREACH( const reco::CandidatePtr& neutralPFCand, uniqueNeutralPFCands ) { nextChargedHadron->neutralPFCandidates_.push_back(neutralPFCand); } // update ChargedHadron four-momentum diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 516463ed57416..405d7353fd983 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -187,13 +187,13 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const // Determine which neutral PFCandidates are close to PFChargedHadrons // and have been merged into ChargedHadrons - std::vector mergedNeutrals; + std::vector mergedNeutrals; reco::Candidate::LorentzVector mergedNeutralsSumP4; for ( std::vector::const_iterator chargedHadron = chargedHadrons.begin(); chargedHadron != chargedHadrons.end(); ++chargedHadron ) { if ( chargedHadron->algoIs(PFRecoTauChargedHadron::kTrack) ) { - const std::vector& neutralPFCands = chargedHadron->getNeutralPFCandidates(); - for ( std::vector::const_iterator neutralPFCand = neutralPFCands.begin(); + const std::vector& neutralPFCands = chargedHadron->getNeutralPFCandidates(); + for ( std::vector::const_iterator neutralPFCand = neutralPFCands.begin(); neutralPFCand != neutralPFCands.end(); ++neutralPFCand ) { mergedNeutrals.push_back(*neutralPFCand); mergedNeutralsSumP4 += (*neutralPFCand)->p4(); @@ -234,7 +234,7 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const // Determine energy sum of all PFNeutralHadrons interpreted as ChargedHadrons with missing track unsigned numChargedHadronNeutrals = 0; - std::vector chargedHadronNeutrals; + std::vector chargedHadronNeutrals; reco::Candidate::LorentzVector chargedHadronNeutralsSumP4; for ( std::vector::const_iterator chargedHadron = chargedHadrons.begin(); chargedHadron != chargedHadrons.end(); ++chargedHadron ) { @@ -266,7 +266,7 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const if ( chargedHadron.algoIs(PFRecoTauChargedHadron::kPFNeutralHadron) ) { PFRecoTauChargedHadron chargedHadron_modified = chargedHadron; chargedHadron_modified.neutralPFCandidates_.clear(); - const PFCandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate(); + const CandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate(); double chargedHadronPx_modified = scaleFactor*chargedPFCand->px(); double chargedHadronPy_modified = scaleFactor*chargedPFCand->py(); double chargedHadronPz_modified = scaleFactor*chargedPFCand->pz(); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc index 52cd91bdc93ba..f371e9c919190 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc @@ -39,7 +39,7 @@ class RecoTauBuilderConePlugin : public RecoTauBuilderPlugin { return_type operator()(const reco::PFJetRef& jet, const std::vector& chargedHadrons, const std::vector& piZeros, - const std::vector& regionalExtras) const override; + const std::vector& regionalExtras) const override; private: RecoTauQualityCuts qcuts_; @@ -107,10 +107,10 @@ namespace xclean { // define template specialization for cross-cleaning template<> - inline void CrossCleanPiZeros::initialize(const cone::PFCandPtrDRFilterIter& signalTracksBegin, const cone::PFCandPtrDRFilterIter& signalTracksEnd) + inline void CrossCleanPiZeros::initialize(const cone::CandPtrDRFilterIter& signalTracksBegin, const cone::CandPtrDRFilterIter& signalTracksEnd) { // Get the list of objects we need to clean - for ( cone::PFCandPtrDRFilterIter signalTrack = signalTracksBegin; signalTrack != signalTracksEnd; ++signalTrack ) { + for ( cone::CandPtrDRFilterIter signalTrack = signalTracksBegin; signalTrack != signalTracksEnd; ++signalTrack ) { toRemove_.insert(reco::CandidatePtr(*signalTrack)); } } @@ -118,7 +118,7 @@ namespace xclean template<> inline void CrossCleanPtrs::initialize(const PiZeroList::const_iterator& piZerosBegin, const PiZeroList::const_iterator& piZerosEnd) { - BOOST_FOREACH( const PFCandidatePtr &ptr, flattenPiZeros(piZerosBegin, piZerosEnd) ) { + BOOST_FOREACH( const CandidatePtr &ptr, flattenPiZeros(piZerosBegin, piZerosEnd) ) { toRemove_.insert(CandidatePtr(ptr)); } } @@ -188,7 +188,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( const reco::PFJetRef& jet, const std::vector& chargedHadrons, const std::vector& piZeros, - const std::vector& regionalExtras) const { + const std::vector& regionalExtras) const { //std::cout << ":" << std::endl; //std::cout << " jet: Pt = " << jet->pt() << ", eta = " << jet->eta() << ", phi = " << jet->phi() << std::endl; @@ -206,12 +206,12 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( // Setup our quality cuts to use the current vertex (supplied by base class) qcuts_.setPV(primaryVertex(jet)); - typedef std::vector PFCandPtrs; + typedef std::vector CandPtrs; // Get the PF Charged hadrons + quality cuts - PFCandPtrs pfchs; + CandPtrs pfchs; if (!usePFLeptonsAsChargedHadrons_) { - pfchs = qcuts_.filterCandRefs(pfCandidates(*jet, reco::PFCandidate::h)); + pfchs = qcuts_.filterCandRefs(pfCandidates(*jet, 211)); } else { // Check if we want to include electrons in muons in "charged hadron" // collection. This is the preferred behavior, as the PF lepton selections @@ -223,14 +223,14 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( std::sort(pfchs.begin(), pfchs.end(), SortPFCandsDescendingPt()); // Get the PF gammas - PFCandPtrs pfGammas = qcuts_.filterCandRefs( - pfCandidates(*jet, reco::PFCandidate::gamma)); + CandPtrs pfGammas = qcuts_.filterCandRefs( + pfCandidates(*jet, 22)); // Neutral hadrons - PFCandPtrs pfnhs = qcuts_.filterCandRefs( - pfCandidates(*jet, reco::PFCandidate::h0)); + CandPtrs pfnhs = qcuts_.filterCandRefs( + pfCandidates(*jet, 130)); // All the extra junk - PFCandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); + CandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); /*********************************************** ****** Lead Candidate Finding ********** @@ -238,13 +238,13 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( // Define our matching cone and filters double matchingCone = matchingCone_(*jet); - PFCandPtrDRFilter matchingConeFilter(jet->p4(), 0, matchingCone); + CandPtrDRFilter matchingConeFilter(jet->p4(), 0, matchingCone); // Find the maximum PFCharged hadron in the matching cone. The call to // PFCandidates always a sorted list, so we can just take the first if it // if it exists. - PFCandidatePtr leadPFCH; - PFCandPtrs::iterator leadPFCH_iter = + CandidatePtr leadPFCH; + CandPtrs::iterator leadPFCH_iter = std::find_if(pfchs.begin(), pfchs.end(), matchingConeFilter); if (leadPFCH_iter != pfchs.end()) { @@ -258,8 +258,8 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( } // Find the leading neutral candidate - PFCandidatePtr leadPFGamma; - PFCandPtrs::iterator leadPFGamma_iter = + CandidatePtr leadPFGamma; + CandPtrs::iterator leadPFGamma_iter = std::find_if(pfGammas.begin(), pfGammas.end(), matchingConeFilter); if (leadPFGamma_iter != pfGammas.end()) { @@ -268,7 +268,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( tau.setleadPFNeutralCand(leadPFGamma); } - PFCandidatePtr leadPFCand; + CandidatePtr leadPFCand; // Always use the leadPFCH if it is above our threshold if (leadPFCH.isNonnull() && leadPFCH->pt() > leadObjecPtThreshold_) { leadPFCand = leadPFCH; @@ -293,29 +293,29 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( // Define the signal and isolation cone sizes for this jet and build filters // to select elements in the given DeltaR regions - PFCandPtrDRFilter signalConePFCHFilter( + CandPtrDRFilter signalConePFCHFilter( coneAxis, -0.1, signalConeChargedHadrons_(*jet)); - PFCandPtrDRFilter signalConePFNHFilter( + CandPtrDRFilter signalConePFNHFilter( coneAxis, -0.1, signalConeNeutralHadrons_(*jet)); PiZeroDRFilter signalConePiZeroFilter( coneAxis, -0.1, signalConePiZeros_(*jet)); - PFCandPtrDRFilter isoConePFCHFilter( + CandPtrDRFilter isoConePFCHFilter( coneAxis, signalConeChargedHadrons_(*jet), isoConeChargedHadrons_(*jet)); - PFCandPtrDRFilter isoConePFGammaFilter( + CandPtrDRFilter isoConePFGammaFilter( coneAxis, signalConePiZeros_(*jet), isoConePiZeros_(*jet)); - PFCandPtrDRFilter isoConePFNHFilter( + CandPtrDRFilter isoConePFNHFilter( coneAxis, signalConeNeutralHadrons_(*jet), isoConeNeutralHadrons_(*jet)); PiZeroDRFilter isoConePiZeroFilter( coneAxis, signalConePiZeros_(*jet), isoConePiZeros_(*jet)); // Additionally make predicates to select the different PF object types // of the regional junk objects to add to the iso cone. - typedef xclean::PredicateAND RegionalJunkConeAndIdFilter; + typedef xclean::PredicateAND RegionalJunkConeAndIdFilter; - xclean::FilterPFCandByParticleId pfchCandSelector(reco::PFCandidate::h); - xclean::FilterPFCandByParticleId pfgammaCandSelector(reco::PFCandidate::gamma); - xclean::FilterPFCandByParticleId pfnhCandSelector(reco::PFCandidate::h0); + xclean::FilterCandByAbsPdgId pfchCandSelector(211); + xclean::FilterCandByAbsPdgId pfgammaCandSelector(22); + xclean::FilterCandByAbsPdgId pfnhCandSelector(130); // Predicate to select the regional junk in the iso cone by PF id RegionalJunkConeAndIdFilter pfChargedJunk( @@ -334,15 +334,15 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( ); // Build filter iterators select the signal charged stuff. - PFCandPtrDRFilterIter signalPFCHCands_begin( + CandPtrDRFilterIter signalPFCHCands_begin( signalConePFCHFilter, pfchs.begin(), pfchs.end()); - PFCandPtrDRFilterIter signalPFCHCands_end( + CandPtrDRFilterIter signalPFCHCands_end( signalConePFCHFilter, pfchs.end(), pfchs.end()); - PFCandPtrs signalPFCHs; + CandPtrs signalPFCHs; int numSignalPFCHs = 0; - PFCandPtrs isolationPFCHs; + CandPtrs isolationPFCHs; int numIsolationPFCHs = 0; - for ( PFCandPtrDRFilterIter iter = signalPFCHCands_begin; iter != signalPFCHCands_end; ++iter ) { + for ( CandPtrDRFilterIter iter = signalPFCHCands_begin; iter != signalPFCHCands_end; ++iter ) { if ( numSignalPFCHs < maxSignalConeChargedHadrons_ || maxSignalConeChargedHadrons_ == -1 ) { //std::cout << "adding signalPFCH #" << numSignalPFCHs << ": Pt = " << (*iter)->pt() << ", eta = " << (*iter)->eta() << ", phi = " << (*iter)->phi() << std::endl; signalPFCHs.push_back(*iter); @@ -354,11 +354,11 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( ++numIsolationPFCHs; } } - PFCandPtrs::const_iterator signalPFCHs_begin = signalPFCHs.begin(); - PFCandPtrs::const_iterator signalPFCHs_end = signalPFCHs.end(); + CandPtrs::const_iterator signalPFCHs_begin = signalPFCHs.begin(); + CandPtrs::const_iterator signalPFCHs_end = signalPFCHs.end(); // Cross clean pi zero content using signal cone charged hadron constituents. - xclean::CrossCleanPiZeros piZeroXCleaner( + xclean::CrossCleanPiZeros piZeroXCleaner( signalPFCHCands_begin, signalPFCHCands_end); std::vector cleanPiZeros = piZeroXCleaner(piZeros); @@ -379,8 +379,8 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( isolationPFCHs.push_back(*iter); ++numIsolationPFCHs; } - PFCandPtrs::const_iterator isolationPFCHs_begin = isolationPFCHs.begin(); - PFCandPtrs::const_iterator isolationPFCHs_end = isolationPFCHs.end(); + CandPtrs::const_iterator isolationPFCHs_begin = isolationPFCHs.begin(); + CandPtrs::const_iterator isolationPFCHs_end = isolationPFCHs.end(); // Build signal charged hadrons tau.addPFCands(RecoTauConstructor::kSignal, diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 0dbe0c19a5813..7985695248c9b 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -73,4 +73,29 @@ std::vector pfChargedCands(const reco::Jet& jet, return output; } +math::XYZPoint atECALEntrance(const reco::Candidate* part) { + const reco::PFCandidate* pfCand = dynamic_cast(part); + if (pfCand) + return pfCand->positionAtECALEntrance(); + + math::XYZPoint pos; + BaseParticlePropagator theParticle = + BaseParticlePropagator(RawParticle(math::XYZTLorentzVector(part->px(), + part->py(), + part->pz(), + part->energy()), + math::XYZTLorentzVector(part->vertex().x(), + part->vertex().y(), + part->vertex().z(), + 0.)), + 0.,0.,bField_); + theParticle.setCharge(part->charge()); + theParticle.propagateToEcalEntrance(false); + if(theParticle.getSuccess()!=0){ + pos = math::XYZPoint(theParticle.vertex()); + } + return pos; +} + + } } From da78114a9c457aa6886aad00c398ed74d2c28174 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 7 Aug 2017 16:43:35 +0200 Subject: [PATCH 003/686] Tau reco: Moving from PFJet to Jet, and from PFCandidate to Candidate, continued (2) --- .../RecoTau/interface/RecoTauBuilderPlugins.h | 8 ++-- .../interface/RecoTauCommonUtilities.h | 19 ++++++++ .../RecoTau/interface/RecoTauConstructor.h | 4 +- .../PFRecoTauChargedHadronFromTrackPlugin.cc | 3 +- .../PFRecoTauDiscriminationByNProngs.cc | 6 +-- .../RecoTauBuilderCombinatoricPlugin.cc | 46 +++++++++---------- .../plugins/RecoTauBuilderConePlugin.cc | 6 +-- .../RecoTau/plugins/RecoTauPiZeroProducer.cc | 12 ++--- .../plugins/RecoTauPiZeroStripPlugin3.cc | 41 ++++++++++------- .../plugins/RecoTauPiZeroTrivialPlugin.cc | 8 ++-- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 30 +++++++----- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 1 + 12 files changed, 109 insertions(+), 75 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h index 01b2f0e485ff3..338217402147f 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h +++ b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h @@ -37,7 +37,7 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" @@ -51,7 +51,7 @@ namespace reco { namespace tau { -/* Class that constructs PFTau(s) from a PFJet and its associated PiZeros */ +/* Class that constructs PFTau(s) from a Jet and its associated PiZeros */ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin { public: @@ -73,7 +73,7 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin /// reconstructed PiZeros and regional extras i.e. objects in a 0.8 cone /// about the jet virtual return_type operator()( - const reco::PFJetRef&, const + const reco::JetBaseRef&, const std::vector&, const std::vector&, const std::vector&) const = 0; @@ -82,7 +82,7 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin const edm::Handle& getPFCands() const { return pfCands_; }; /// Get primary vertex associated to this jet - reco::VertexRef primaryVertex(const reco::PFJetRef& jet) const { return vertexAssociator_.associatedVertex(*jet); } + reco::VertexRef primaryVertex(const reco::JetBaseRef& jet) const { return vertexAssociator_.associatedVertex(*jet); } /// Get primary vertex associated to this tau reco::VertexRef primaryVertex(const reco::PFTau& tau, bool useJet=false) const { return vertexAssociator_.associatedVertex(tau, useJet); } diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index bf46c9bcf35c0..767de5f019f86 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -89,6 +89,25 @@ RefVectorType castView(const edm::Handle& view) { } +/// Convert a BaseView (View) to a TRefToBaseVector +template +RefVectorType castViewToOtherBase(const edm::Handle& view) { + typedef typename RefVectorType::value_type OutputRef; + // Double check at compile time that the inheritance is okay. It can still + // fail at runtime if you pass it the wrong collection. + BOOST_STATIC_ASSERT( + (boost::is_base_of::value)); + RefVectorType output; + size_t nElements = view->size(); + // output.reserve(nElements); + // Cast each of our Refs + for (size_t i = 0; i < nElements; ++i) { + output.push_back(view->refAt(i).template castTo()); + } + return output; +} + /* *Given a range over a container of type C, return a new 'end' iterator such *that at max elements are taken. If there are less than N elements in the diff --git a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h index 9e138cbea84fa..6318acbfddfa3 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h +++ b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h @@ -27,7 +27,7 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" #include "DataFormats/TauReco/interface/PFTau.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" #include "CommonTools/Utils/interface/StringObjectFunction.h" @@ -52,7 +52,7 @@ class RecoTauConstructor { }; /// Constructor with PFCandidate Handle - RecoTauConstructor(const PFJetRef& jetRef, + RecoTauConstructor(const JetBaseRef& jetRef, const edm::Handle& pfCands, bool copyGammasFromPiZeros = false, const StringObjectFunction* signalConeSize = nullptr, diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index 4b3da9a67bb11..3980d7023df9b 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -50,6 +50,7 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild ~PFRecoTauChargedHadronFromTrackPlugin() override; // Return type is auto_ptr return_type operator()(const reco::PFJet&) const override; + return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; @@ -128,7 +129,7 @@ namespace } } -PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTrackPlugin::operator()(const reco::PFJet& jet) const +PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTrackPlugin::operator()(const reco::Jet& jet) const { if ( verbosity_ ) { edm::LogPrint("TauChHFromTrack") << ":" ; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc index ed0909cdb7741..d0c41eb9feab2 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc @@ -52,14 +52,14 @@ void PFRecoTauDiscriminationByNProngs::beginEvent(const Event& iEvent, const Eve double PFRecoTauDiscriminationByNProngs::discriminate(const PFTauRef& tau) const{ reco::VertexRef pv = vertexAssociator_->associatedVertex(*tau); - const PFCandidatePtr leadingTrack = tau->leadPFChargedHadrCand(); + const CandidatePtr leadingTrack = tau->leadPFChargedHadrCand(); uint np = 0; if(leadingTrack.isNonnull() && pv.isNonnull()){ qcuts_->setPV(pv); - qcuts_->setLeadTrack(tau->leadPFChargedHadrCand()); + qcuts_->setLeadTrack(*tau->leadPFChargedHadrCand()); - BOOST_FOREACH( const reco::PFCandidatePtr& cand, tau->signalPFChargedHadrCands() ) { + BOOST_FOREACH( const reco::CandidatePtr& cand, tau->signalPFChargedHadrCands() ) { if ( qcuts_->filterCandRef(cand) ) np++; } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc index 2a8e0b85960ff..9d7e7664ca9a4 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc @@ -32,10 +32,10 @@ class RecoTauBuilderCombinatoricPlugin : public RecoTauBuilderPlugin ~RecoTauBuilderCombinatoricPlugin() override {} return_type operator()( - const reco::PFJetRef&, + const reco::JetBaseRef&, const std::vector&, const std::vector&, - const std::vector&) const override; + const std::vector&) const override; private: RecoTauQualityCuts qcuts_; @@ -113,7 +113,7 @@ namespace xclean template<> inline void CrossCleanPtrs::initialize(const PiZeroList::const_iterator& piZerosBegin, const PiZeroList::const_iterator& piZerosEnd) { - BOOST_FOREACH( const PFCandidatePtr &ptr, flattenPiZeros(piZerosBegin, piZerosEnd) ) { + BOOST_FOREACH( const CandidatePtr &ptr, flattenPiZeros(piZerosBegin, piZerosEnd) ) { toRemove_.insert(CandidatePtr(ptr)); } } @@ -167,10 +167,10 @@ namespace RecoTauBuilderCombinatoricPlugin::return_type RecoTauBuilderCombinatoricPlugin::operator()( - const reco::PFJetRef& jet, + const reco::JetBaseRef& jet, const std::vector& chargedHadrons, const std::vector& piZeros, - const std::vector& regionalExtras) const + const std::vector& regionalExtras) const { if ( verbosity_ ) { std::cout << ":" << std::endl; @@ -185,7 +185,7 @@ RecoTauBuilderCombinatoricPlugin::operator()( // the base class. qcuts_.setPV( primaryVertex(jet) ); - typedef std::vector PFCandPtrs; + typedef std::vector CandPtrs; if ( verbosity_ ) { std::cout << "#chargedHadrons = " << chargedHadrons.size() << std::endl; @@ -206,13 +206,13 @@ RecoTauBuilderCombinatoricPlugin::operator()( } } - PFCandPtrs pfchs = qcuts_.filterCandRefs(pfChargedCands(*jet)); - PFCandPtrs pfnhs = qcuts_.filterCandRefs(pfCandidates(*jet, reco::PFCandidate::h0)); - PFCandPtrs pfgammas = qcuts_.filterCandRefs(pfCandidates(*jet, reco::PFCandidate::gamma)); + CandPtrs pfchs = qcuts_.filterCandRefs(pfChargedCands(*jet)); + CandPtrs pfnhs = qcuts_.filterCandRefs(pfCandidates(*jet, 130)); + CandPtrs pfgammas = qcuts_.filterCandRefs(pfCandidates(*jet, 22)); /// Apply quality cuts to the regional junk around the jet. Note that the /// particle contents of the junk is exclusive to the jet content. - PFCandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); + CandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); // Loop over the decay modes we want to build for ( std::vector::const_iterator decayMode = decayModesToBuild_.begin(); @@ -239,7 +239,7 @@ RecoTauBuilderCombinatoricPlugin::operator()( // Build our track combo generator ChargedHadronCombo trackCombos(chargedHadron_begin, chargedHadron_end, tracksToBuild); - PFCandPtrs::iterator pfch_end = pfchs.end(); + CandPtrs::iterator pfch_end = pfchs.end(); pfch_end = takeNElements(pfchs.begin(), pfch_end, decayMode->maxPFCHs_); //------------------------------------------------------- @@ -349,7 +349,7 @@ RecoTauBuilderCombinatoricPlugin::operator()( // Now build isolation collections // Load our isolation tools using namespace reco::tau::cone; - PFCandPtrDRFilter isolationConeFilter(tau.p4(), -0.1, isolationConeSize_); + CandPtrDRFilter isolationConeFilter(tau.p4(), -0.1, isolationConeSize_); // Cross cleaning predicate: Remove any PFCandidatePtrs that are contained within existing ChargedHadrons or PiZeros. // The predicate will return false for any object that overlaps with chargedHadrons or cleanPiZeros. @@ -357,29 +357,29 @@ RecoTauBuilderCombinatoricPlugin::operator()( typedef xclean::CrossCleanPtrs pfChargedHadronXCleanerType; pfChargedHadronXCleanerType pfChargedHadronXCleaner_comboChargedHadrons(trackCombo->combo_begin(), trackCombo->combo_end()); // And this cleaning filter predicate with our Iso cone filter - xclean::PredicateAND pfCandFilter_comboChargedHadrons(isolationConeFilter, pfChargedHadronXCleaner_comboChargedHadrons); + xclean::PredicateAND pfCandFilter_comboChargedHadrons(isolationConeFilter, pfChargedHadronXCleaner_comboChargedHadrons); // 2.) to select neutral PFCandidates within jet xclean::CrossCleanPtrs pfChargedHadronXCleaner_allChargedHadrons(chargedHadrons.begin(), chargedHadrons.end()); xclean::CrossCleanPtrs piZeroXCleaner(piZeros.begin(), piZeros.end()); typedef xclean::PredicateAND, xclean::CrossCleanPtrs > pfCandXCleanerType; pfCandXCleanerType pfCandXCleaner_allChargedHadrons(pfChargedHadronXCleaner_allChargedHadrons, piZeroXCleaner); // And this cleaning filter predicate with our Iso cone filter - xclean::PredicateAND pfCandFilter_allChargedHadrons(isolationConeFilter, pfCandXCleaner_allChargedHadrons); + xclean::PredicateAND pfCandFilter_allChargedHadrons(isolationConeFilter, pfCandXCleaner_allChargedHadrons); ChargedHadronDRFilter isolationConeFilterChargedHadron(tau.p4(), -0.1, isolationConeSize_); PiZeroDRFilter isolationConeFilterPiZero(tau.p4(), -0.1, isolationConeSize_); // Additionally make predicates to select the different PF object types // of the regional junk objects to add - typedef xclean::PredicateAND RegionalJunkConeAndIdFilter; - - xclean::FilterPFCandByParticleId - pfchCandSelector(reco::PFCandidate::h); - xclean::FilterPFCandByParticleId - pfgammaCandSelector(reco::PFCandidate::gamma); - xclean::FilterPFCandByParticleId - pfnhCandSelector(reco::PFCandidate::h0); + typedef xclean::PredicateAND RegionalJunkConeAndIdFilter; + + xclean::FilterCandByAbsPdgId + pfchCandSelector(211); + xclean::FilterCandByAbsPdgId + pfgammaCandSelector(22); + xclean::FilterCandByAbsPdgId + pfnhCandSelector(130); RegionalJunkConeAndIdFilter pfChargedJunk( pfchCandSelector, // select charged stuff from junk diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc index f371e9c919190..34b880a7bca07 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc @@ -36,7 +36,7 @@ class RecoTauBuilderConePlugin : public RecoTauBuilderPlugin { explicit RecoTauBuilderConePlugin(const edm::ParameterSet& pset,edm::ConsumesCollector &&iC); ~RecoTauBuilderConePlugin() override {} // Build a tau from a jet - return_type operator()(const reco::PFJetRef& jet, + return_type operator()(const reco::JetBaseRef& jet, const std::vector& chargedHadrons, const std::vector& piZeros, const std::vector& regionalExtras) const override; @@ -48,7 +48,7 @@ class RecoTauBuilderConePlugin : public RecoTauBuilderPlugin { double leadObjecPtThreshold_; /* String function to extract values from PFJets */ - typedef StringObjectFunction JetFunc; + typedef StringObjectFunction JetFunc; // Cone defintions JetFunc matchingCone_; @@ -185,7 +185,7 @@ void RecoTauBuilderConePlugin::setTauQuantities(reco::PFTau& aTau, } RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( - const reco::PFJetRef& jet, + const reco::JetBaseRef& jet, const std::vector& chargedHadrons, const std::vector& piZeros, const std::vector& regionalExtras) const { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index a7fdd0cc45e00..3fb5efbdf2bf6 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -67,7 +67,7 @@ class RecoTauPiZeroProducer : public edm::stream::EDProducer<> { outputSelector_; //consumes interface - edm::EDGetTokenT cand_token; + edm::EDGetTokenT cand_token; double minJetPt_; double maxJetAbsEta_; @@ -77,7 +77,7 @@ class RecoTauPiZeroProducer : public edm::stream::EDProducer<> { RecoTauPiZeroProducer::RecoTauPiZeroProducer(const edm::ParameterSet& pset) { - cand_token = consumes( pset.getParameter("jetSrc")); + cand_token = consumes( pset.getParameter("jetSrc")); minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter("minJetPt") : -1.0; maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter("maxJetAbsEta") : 99.0; @@ -129,7 +129,7 @@ RecoTauPiZeroProducer::RecoTauPiZeroProducer(const edm::ParameterSet& pset) void RecoTauPiZeroProducer::produce(edm::Event& evt, const edm::EventSetup& es) { // Get a view of our jets via the base candidates - edm::Handle jetView; + edm::Handle jetView; evt.getByToken(cand_token, jetView); // Give each of our plugins a chance at doing something with the edm::Event @@ -144,9 +144,9 @@ void RecoTauPiZeroProducer::produce(edm::Event& evt, const edm::EventSetup& es) std::unique_ptr association; if (!jetRefs.empty()) { - edm::Handle pfJetCollectionHandle; - evt.get(jetRefs.id(), pfJetCollectionHandle); - association = std::make_unique(reco::PFJetRefProd(pfJetCollectionHandle)); + // edm::Handle pfJetCollectionHandle; + // evt.get(jetRefs.id(), pfJetCollectionHandle); + association = std::make_unique(reco::JetRefBaseProd(jetView)); } else { association = std::make_unique(); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 91a92bcd0a360..b3ffb976ba611 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -64,8 +64,8 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin void beginEvent() override; private: - typedef std::vector PFCandPtrs; - void addCandsToStrip(RecoTauPiZero&, PFCandPtrs&, const std::vector&, std::set&, bool&) const; + typedef std::vector CandPtrs; + void addCandsToStrip(RecoTauPiZero&, CandPtrs&, const std::vector&, std::set&, bool&) const; RecoTauVertexAssociator vertexAssociator_; @@ -168,7 +168,7 @@ void RecoTauPiZeroStripPlugin3::beginEvent() vertexAssociator_.setEvent(*evt()); } -void RecoTauPiZeroStripPlugin3::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs& cands, const std::vector& candFlags, +void RecoTauPiZeroStripPlugin3::addCandsToStrip(RecoTauPiZero& strip, CandPtrs& cands, const std::vector& candFlags, std::set& candIdsCurrentStrip, bool& isCandAdded) const { if ( verbosity_ >= 1 ) { @@ -177,7 +177,7 @@ void RecoTauPiZeroStripPlugin3::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs size_t numCands = cands.size(); for ( size_t candId = 0; candId < numCands; ++candId ) { if ( (!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end() ) { // do not include same cand twice - reco::PFCandidatePtr cand = cands[candId]; + reco::CandidatePtr cand = cands[candId]; double etaAssociationDistance_value = etaAssociationDistance_->Eval(strip.pt()) + etaAssociationDistance_->Eval(cand->pt()); double phiAssociationDistance_value = phiAssociationDistance_->Eval(strip.pt()) + phiAssociationDistance_->Eval(cand->pt()); if ( fabs(strip.eta() - cand->eta()) < etaAssociationDistance_value && // check if cand is within eta-phi window centered on strip @@ -204,11 +204,18 @@ namespace } } - inline const reco::TrackBaseRef getTrack(const PFCandidate& cand) + // JAN - FIXME - this method is needed multiple times + + inline const reco::TrackBaseRef getTrack(const Candidate& cand) { - if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); - else if ( cand.gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(cand.gsfTrackRef()); - else return reco::TrackBaseRef(); + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); + else return reco::TrackBaseRef(); + } + // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); } } @@ -225,13 +232,13 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - PFCandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); // Convert to stl::list to allow fast deletions - PFCandPtrs seedCands; - PFCandPtrs addCands; + CandPtrs seedCands; + CandPtrs addCands; int idx = 0; - for ( PFCandPtrs::iterator cand = candsVector.begin(); + for ( CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand ) { if ( verbosity_ >= 1 ) { edm::LogPrint("RecoTauPiZeroStripPlugin3") << "PFGamma #" << idx << " (" << cand->id() << ":" << cand->key() << "): Et = " << (*cand)->et() << ", eta = " << (*cand)->eta() << ", phi = " << (*cand)->phi() ; @@ -239,17 +246,17 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con if ( (*cand)->et() > minGammaEtStripSeed_ ) { if ( verbosity_ >= 2 ) { edm::LogPrint("RecoTauPiZeroStripPlugin3") << "--> assigning seedCandId = " << seedCands.size() ; - const reco::TrackBaseRef candTrack = getTrack(*cand); + const reco::TrackBaseRef candTrack = getTrack(**cand); if ( candTrack.isNonnull() ) { edm::LogPrint("RecoTauPiZeroStripPlugin3") << "track: Pt = " << candTrack->pt() << " eta = " << candTrack->eta() << ", phi = " << candTrack->phi() << ", charge = " << candTrack->charge() ; edm::LogPrint("RecoTauPiZeroStripPlugin3") << " (dZ = " << candTrack->dz(vertexAssociator_.associatedVertex(jet)->position()) << ", dXY = " << candTrack->dxy(vertexAssociator_.associatedVertex(jet)->position()) << "," << " numHits = " << candTrack->hitPattern().numberOfValidTrackerHits() << ", numPxlHits = " << candTrack->hitPattern().numberOfValidPixelHits() << "," << " chi2 = " << candTrack->normalizedChi2() << ", dPt/Pt = " << (candTrack->ptError()/candTrack->pt()) << ")" ; } - edm::LogPrint("RecoTauPiZeroStripPlugin3") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," - << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; - edm::LogPrint("RecoTauPiZeroStripPlugin3") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," - << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; + // edm::LogPrint("RecoTauPiZeroStripPlugin3") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," + // << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; + // edm::LogPrint("RecoTauPiZeroStripPlugin3") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," + // << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; } seedCands.push_back(*cand); } else if ( (*cand)->et() > minGammaEtStripAdd_ ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc index 82b132fa1d331..82a53effb691a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc @@ -11,8 +11,8 @@ */ #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" @@ -39,11 +39,11 @@ RecoTauPiZeroTrivialPlugin::RecoTauPiZeroTrivialPlugin( RecoTauPiZeroBuilderPlugin::return_type RecoTauPiZeroTrivialPlugin::operator()( const reco::PFJet& jet) const { - std::vector pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet)); + std::vector pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet)); PiZeroVector output; output.reserve(pfGammaCands.size()); - BOOST_FOREACH(const PFCandidatePtr& gamma, pfGammaCands) { + BOOST_FOREACH(const CandidatePtr& gamma, pfGammaCands) { std::auto_ptr piZero(new RecoTauPiZero( 0, (*gamma).p4(), (*gamma).vertex(), 22, 1000, true, RecoTauPiZero::kTrivial)); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index ac208f951f3b1..2538281e5d516 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -37,7 +37,7 @@ #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/JetPiZeroAssociation.h" #include "DataFormats/TauReco/interface/PFTau.h" -#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/JetReco/interface/JetCollection.h" #include "DataFormats/Common/interface/Association.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" @@ -63,7 +63,7 @@ class RecoTauProducer : public edm::stream::EDProducer<> double minJetPt_; double maxJetAbsEta_; //token definition - edm::EDGetTokenT jet_token; + edm::EDGetTokenT jet_token; edm::EDGetTokenT > jetRegion_token; edm::EDGetTokenT chargedHadron_token; edm::EDGetTokenT piZero_token; @@ -88,7 +88,7 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter("minJetPt") : -1.0; maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter("maxJetAbsEta") : 99.0; //consumes definition - jet_token=consumes(jetSrc_); + jet_token=consumes(jetSrc_); jetRegion_token = consumes >(jetRegionSrc_); chargedHadron_token = consumes(chargedHadronSrc_); piZero_token = consumes(piZeroSrc_); @@ -130,12 +130,13 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) { // Get the jet input collection via a view of Candidates - edm::Handle jetView; + edm::Handle jetView; evt.getByToken(jet_token, jetView); // Convert to a vector of PFJetRefs // reco::PFJetRefVector jets = reco::tau::castView(jetView); - edm::RefToBaseVector jets = reco::tau::castView>(jetView); + // edm::RefVector> jets = reco::tau::castView>>(jetView); + // edm::RefToBaseVector jets = reco::tau::castViewToOtherBase>(jetView); // Get the jet region producer edm::Handle > jetRegionHandle; @@ -161,10 +162,13 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // Create output collection auto output = std::make_unique(); - output->reserve(jets.size()); + output->reserve(jetView->size()); // Loop over the jets and build the taus for each jet - BOOST_FOREACH( reco::PFJetRef jetRef, jets ) { + // BOOST_FOREACH( edm::Ref> jetRef, jets ) { + for (size_t i_j = 0; i_j < jetView->size(); ++i_j) { + const auto& jetRef = jetView->refAt(i_j); + // Get the jet with extra constituents from an area around the jet if(jetRef->pt() - minJetPt_ < 1e-5) continue; if(std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5) continue; @@ -174,13 +178,13 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) << "No jet region can be found for the current jet: " << jetRef.id(); } // Remove all the jet constituents from the jet extras - std::vector jetCands = jetRef->getPFConstituents(); - std::vector allRegionalCands = jetRegionRef->getPFConstituents(); + std::vector jetCands = jetRef->daughterPtrVector(); + std::vector allRegionalCands = jetRegionRef->daughterPtrVector(); // Sort both by ref key std::sort(jetCands.begin(), jetCands.end()); std::sort(allRegionalCands.begin(), allRegionalCands.end()); // Get the regional junk candidates not in the jet. - std::vector uniqueRegionalCands; + std::vector uniqueRegionalCands; // This can actually be less than zero, if the jet has really crazy soft // stuff really far away from the jet axis. @@ -204,8 +208,10 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) builder != builders_.end(); ++builder) { // Get a ptr_vector of taus from the builder reco::tau::RecoTauBuilderPlugin::output_type taus((*builder)(jetRef, chargedHadrons, piZeros, uniqueRegionalCands)); + // JAN - convert reco::Jet ref to PFJet ref (only in direct interaction with PFTau) + // Make sure all taus have their jetref set correctly - std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, jetRef)); + std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, jetRef.castTo())); // Copy without selection if ( !outputSelector_.get() ) { output->insert(output->end(), taus.begin(), taus.end()); @@ -225,7 +231,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // jet. if ( !nTausBuilt && buildNullTaus_ ) { reco::PFTau nullTau(std::numeric_limits::quiet_NaN(), jetRef->p4()); - nullTau.setjetRef(jetRef); + nullTau.setjetRef(jetRef.castTo()); output->push_back(nullTau); } } diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index 057f096f723fc..75bb3d755b9e1 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -10,6 +10,7 @@ namespace reco { namespace tau { namespace { // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. + // JAN FIXME - WE NEED TO SEE WHAT TO DO FOR MINIAOD const reco::TrackBaseRef getTrackRef(const Candidate& cand) { if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); From cc1f6409185bab1cc8ec7d8407f8d68ce130677d Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 10 Aug 2017 10:42:59 +0200 Subject: [PATCH 004/686] Tau reco: Moving from PFJet to Jet, and from PFCandidate to Candidate, continued (3) --- .../interface/PFRecoTauChargedHadron.h | 2 +- .../TauReco/src/PFRecoTauChargedHadron.cc | 35 ++++++++------- DataFormats/TauReco/src/classes_def_2.xml | 3 +- DataFormats/TauReco/src/classes_def_3.xml | 6 ++- .../interface/RecoTauCommonUtilities.h | 29 ++++-------- ...coTauChargedHadronFromPFCandidatePlugin.cc | 15 ++++++- .../PFRecoTauChargedHadronFromTrackPlugin.cc | 31 +++++++------ .../RecoTau/plugins/RecoTauPhotonFilter.cc | 8 ++-- .../plugins/RecoTauPiZeroStripPlugin2.cc | 45 +++++++++++-------- .../RecoTau/src/RecoTauCommonUtilities.cc | 40 ++++++++++++----- RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 41 +++++++++-------- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 27 +++++------ .../RecoTau/src/RecoTauVertexAssociator.cc | 38 +++++++++------- .../src/pfRecoTauChargedHadronAuxFunctions.cc | 10 ++--- 14 files changed, 185 insertions(+), 145 deletions(-) diff --git a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h index 6853be31fb261..1975b61cd8f48 100644 --- a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h +++ b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h @@ -2,7 +2,7 @@ #define DataFormats_TauReco_PFRecoTauChargedHadron_h #include "DataFormats/Candidate/interface/CompositePtrCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Math/interface/Point3D.h" diff --git a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc index 898a4aa582b6e..13f5e8b32dcbc 100644 --- a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc +++ b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc @@ -39,7 +39,7 @@ PFRecoTauChargedHadron::PFRecoTauChargedHadron(const Candidate& c, PFRecoTauChar PFRecoTauChargedHadron::~PFRecoTauChargedHadron() {} -const PFCandidatePtr& PFRecoTauChargedHadron::getChargedPFCandidate() const +const CandidatePtr& PFRecoTauChargedHadron::getChargedPFCandidate() const { return chargedPFCandidate_; } @@ -49,7 +49,7 @@ const PFRecoTauChargedHadron::TrackPtr& PFRecoTauChargedHadron::getTrack() const return track_; } -const std::vector& PFRecoTauChargedHadron::getNeutralPFCandidates() const +const std::vector& PFRecoTauChargedHadron::getNeutralPFCandidates() const { return neutralPFCandidates_; } @@ -71,18 +71,19 @@ bool PFRecoTauChargedHadron::algoIs(PFRecoTauChargedHadron::PFRecoTauChargedHadr namespace { - std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) - { - if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; - else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; - else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; - else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; - else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; - else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; - else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; - else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; - else assert(0); - } + // JAN - FIXME - can still use this to print out based on PDG ID + // std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) + // { + // if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; + // else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; + // else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; + // else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; + // else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; + // else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; + // else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; + // else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; + // else assert(0); + // } } void PFRecoTauChargedHadron::print(std::ostream& stream) const @@ -93,7 +94,7 @@ void PFRecoTauChargedHadron::print(std::ostream& stream) const if ( chargedPFCandidate_.isNonnull() ) { stream << " (" << chargedPFCandidate_.id() << ":" << chargedPFCandidate_.key() << "):" << " Pt = " << chargedPFCandidate_->pt() << ", eta = " << chargedPFCandidate_->eta() << ", phi = " << chargedPFCandidate_->phi() - << " (type = " << getPFCandidateType(chargedPFCandidate_->particleId()) << ")" << std::endl; + << " (pdgId = " << chargedPFCandidate_->pdgId() << ")" << std::endl; } else { stream << ": N/A" << std::endl; } @@ -107,11 +108,11 @@ void PFRecoTauChargedHadron::print(std::ostream& stream) const if ( !neutralPFCandidates_.empty() ) { stream << std::endl; int idx = 0; - for ( std::vector::const_iterator neutralPFCandidate = neutralPFCandidates_.begin(); + for ( std::vector::const_iterator neutralPFCandidate = neutralPFCandidates_.begin(); neutralPFCandidate != neutralPFCandidates_.end(); ++neutralPFCandidate ) { stream << " #" << idx << " (" << neutralPFCandidate->id() << ":" << neutralPFCandidate->key() << "):" << " Pt = " << (*neutralPFCandidate)->pt() << ", eta = " << (*neutralPFCandidate)->eta() << ", phi = " << (*neutralPFCandidate)->phi() - << " (type = " << getPFCandidateType((*neutralPFCandidate)->particleId()) << ")" << std::endl; + << " (pdgId = " << (*neutralPFCandidate)->pdgId() << ")" << std::endl; ++idx; } } else { diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index b578678c6b15d..d6348aa9221fb 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -283,7 +283,8 @@ isolationTauChargedHadronCandidates_.reset(); - + + diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index d09c7465ec4b6..684b0f0dbcffc 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -58,9 +58,10 @@ - + + @@ -75,9 +76,10 @@ - + + diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index 767de5f019f86..cf6af40db1526 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -9,13 +9,16 @@ * */ +#include +#include +#include + #include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" -#include -#include -#include // Boost helpers #include @@ -162,25 +165,11 @@ template InputIterator leadPFCand(InputIterator begin, return max_cand; } -std::vector convertPtrVector(const std::vector& cands) { - std::vector newSignalPFCands; - for (auto& cand : cands) { - const auto& newPtr = cand->masterClone().castTo >(); - newSignalPFCands.push_back(newPtr); - } - return newSignalPFCands; -} +std::vector convertPtrVectorToPF(const std::vector& cands); -std::vector convertPtrVector(const std::vector& cands) { - std::vector newSignalCands; - for (auto& cand : cands) { - const auto& newPtr = cand->masterClone().castTo >(); - newSignalCands.push_back(newPtr); - } - return newSignalCands; -} +std::vector convertPtrVector(const std::vector& cands); -math::XYZPoint atECALEntrance(const reco::Candidate* part); +math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField); }} // end namespace reco::tau #endif diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 0847d57b65edd..54925a2248b7a 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -25,11 +25,16 @@ #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Common/interface/RefToPtr.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" + #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" #include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" #include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" + #include namespace reco @@ -73,6 +78,8 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro double minMergeGammaEt_; double minMergeChargedHadronPt_; + double bField_; + int verbosity_; }; @@ -115,6 +122,10 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::~PFRecoTauChargedHadronFromPFCandid void PFRecoTauChargedHadronFromPFCandidatePlugin::beginEvent() { vertexAssociator_.setEvent(*evt()); + + edm::ESHandle pSetup; + evtSetup()->get().get(pSetup); + bField_ = pSetup->inTesla(GlobalPoint(0,0,0)).z(); } namespace @@ -199,7 +210,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF } - chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand); + chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand, bField_); chargedHadron->chargedPFCandidate_ = (*cand); chargedHadron->addDaughter(*cand); @@ -218,7 +229,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF int jetConstituentPdgId = std::abs((*jetConstituent)->pdgId()); if ( !(jetConstituentPdgId == 130 || jetConstituentPdgId == 22) ) continue; - double dR = deltaR(atECALEntrance(&**jetConstituent), atECALEntrance(&*chargedHadron)); + double dR = deltaR(atECALEntrance(&**jetConstituent, bField_), atECALEntrance(&*chargedHadron, bField_)); double dRmerge = -1.; int minBlockElementMatches = 1000; int maxUnmatchedBlockElements = 0; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index 3980d7023df9b..0d0e3c9e9b357 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -117,13 +117,13 @@ void PFRecoTauChargedHadronFromTrackPlugin::beginEvent() namespace { - struct PFCandidate_withDistance + struct Candidate_withDistance { - reco::PFCandidatePtr pfCandidate_; + reco::CandidatePtr pfCandidate_; double distance_; }; - bool isSmallerDistance(const PFCandidate_withDistance& cand1, const PFCandidate_withDistance& cand2) + bool isSmallerDistance(const Candidate_withDistance& cand1, const Candidate_withDistance& cand2) { return (cand1.distance_ < cand2.distance_); } @@ -210,22 +210,21 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra chargedHadron->positionAtECALEntrance_ = math::XYZPointF(0.,0.,0.); } - std::vector neutralJetConstituents_withDistance; - std::vector jetConstituents = jet.getPFConstituents(); - for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); - jetConstituent != jetConstituents.end(); ++jetConstituent ) { - reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId(); - if ( !(jetConstituentType == reco::PFCandidate::h0 || jetConstituentType == reco::PFCandidate::gamma) ) continue; - double dR = deltaR((*jetConstituent)->positionAtECALEntrance(), chargedHadron->positionAtECALEntrance_); + std::vector neutralJetConstituents_withDistance; + std::vector jetConstituents = jet.daughterPtrVector(); + for ( const auto& jetConstituent : jetConstituents ) { + int pdgId = jetConstituent->pdgId(); + if ( !(pdgId == 130 || pdgId == 22) ) continue; + double dR = deltaR(atECALEntrance(&*jetConstituent, magneticFieldStrength_.z()), chargedHadron->positionAtECALEntrance_); double dRmerge = -1.; - if ( jetConstituentType == reco::PFCandidate::h0 ) dRmerge = dRmergeNeutralHadron_; - else if ( jetConstituentType == reco::PFCandidate::gamma ) dRmerge = dRmergePhoton_; + if ( pdgId == 130 ) dRmerge = dRmergeNeutralHadron_; + else if ( pdgId == 22 ) dRmerge = dRmergePhoton_; if ( dR < dRmerge ) { - PFCandidate_withDistance jetConstituent_withDistance; - jetConstituent_withDistance.pfCandidate_ = (*jetConstituent); + Candidate_withDistance jetConstituent_withDistance; + jetConstituent_withDistance.pfCandidate_ = jetConstituent; jetConstituent_withDistance.distance_ = dR; neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance); - chargedHadron->addDaughter(*jetConstituent); + chargedHadron->addDaughter(jetConstituent); } } std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance); @@ -233,7 +232,7 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra const double caloResolutionCoeff = 1.0; // CV: approximate ECAL + HCAL calorimeter resolution for hadrons by 100%*sqrt(E) double resolutionTrackP = track->p()*(track->ptError()/track->pt()); double neutralEnSum = 0.; - for ( std::vector::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin(); + for ( std::vector::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin(); nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) { double nextNeutralEn = nextNeutral->pfCandidate_->energy(); double resolutionCaloEn = caloResolutionCoeff*sqrt(neutralEnSum + nextNeutralEn); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc index c06c38b08cf1a..89283e09b8bb9 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc @@ -132,10 +132,10 @@ void RecoTauPhotonFilter::operator()(PFTau& tau) const { newSignalPFGammas.push_back(ptr); } - tau.setsignalPFCands(convertPtrVector(newSignalPFCands)); - tau.setsignalPFCands(convertPtrVector(newSignalPFGammas)); - tau.setisolationPFGammaCands(convertPtrVector(newIsolationPFGammas)); - tau.setisolationPFCands(convertPtrVector(newIsolationPFCands)); + tau.setsignalPFCands(convertPtrVectorToPF(newSignalPFCands)); + tau.setsignalPFCands(convertPtrVectorToPF(newSignalPFGammas)); + tau.setisolationPFGammaCands(convertPtrVectorToPF(newIsolationPFGammas)); + tau.setisolationPFCands(convertPtrVectorToPF(newIsolationPFCands)); } } }} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index e45effacc81c9..287bce87d10f5 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -18,8 +18,8 @@ #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" @@ -61,8 +61,8 @@ class RecoTauPiZeroStripPlugin2 : public RecoTauPiZeroBuilderPlugin void beginEvent() override; private: - typedef std::vector PFCandPtrs; - void addCandsToStrip(RecoTauPiZero&, PFCandPtrs&, const std::vector&, std::set&, bool&) const; + typedef std::vector CandPtrs; + void addCandsToStrip(RecoTauPiZero&, CandPtrs&, const std::vector&, std::set&, bool&) const; RecoTauVertexAssociator vertexAssociator_; @@ -146,7 +146,7 @@ void RecoTauPiZeroStripPlugin2::beginEvent() vertexAssociator_.setEvent(*evt()); } -void RecoTauPiZeroStripPlugin2::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs& cands, const std::vector& candFlags, +void RecoTauPiZeroStripPlugin2::addCandsToStrip(RecoTauPiZero& strip, CandPtrs& cands, const std::vector& candFlags, std::set& candIdsCurrentStrip, bool& isCandAdded) const { if ( verbosity_ >= 1 ) { @@ -155,7 +155,7 @@ void RecoTauPiZeroStripPlugin2::addCandsToStrip(RecoTauPiZero& strip, PFCandPtrs size_t numCands = cands.size(); for ( size_t candId = 0; candId < numCands; ++candId ) { if ( (!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end() ) { // do not include same cand twice - reco::PFCandidatePtr cand = cands[candId]; + reco::CandidatePtr cand = cands[candId]; if ( fabs(strip.eta() - cand->eta()) < etaAssociationDistance_ && // check if cand is within eta-phi window centered on strip fabs(strip.phi() - cand->phi()) < phiAssociationDistance_ ) { if ( verbosity_ >= 2 ) { @@ -180,11 +180,18 @@ namespace } } - inline const reco::TrackBaseRef getTrack(const PFCandidate& cand) + // JAN - FIXME - this method is needed multiple times + + inline const reco::TrackBaseRef getTrack(const Candidate& cand) { - if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); - else if ( cand.gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(cand.gsfTrackRef()); - else return reco::TrackBaseRef(); + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); + else return reco::TrackBaseRef(); + } + // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); } } @@ -201,13 +208,13 @@ RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(con // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - PFCandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); // Convert to stl::list to allow fast deletions - PFCandPtrs seedCands; - PFCandPtrs addCands; + CandPtrs seedCands; + CandPtrs addCands; int idx = 0; - for ( PFCandPtrs::iterator cand = candsVector.begin(); + for ( CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand ) { if ( verbosity_ >= 1 ) { edm::LogPrint("RecoTauPiZeroStripPlugin2") << "PFGamma #" << idx << " (" << cand->id() << ":" << cand->key() << "): Et = " << (*cand)->et() << ", eta = " << (*cand)->eta() << ", phi = " << (*cand)->phi() ; @@ -215,17 +222,17 @@ RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(con if ( (*cand)->et() > minGammaEtStripSeed_ ) { if ( verbosity_ >= 2 ) { edm::LogPrint("RecoTauPiZeroStripPlugin2") << "--> assigning seedCandId = " << seedCands.size() ; - const reco::TrackBaseRef candTrack = getTrack(*cand); + const reco::TrackBaseRef candTrack = getTrack(**cand); if ( candTrack.isNonnull() ) { edm::LogPrint("RecoTauPiZeroStripPlugin2") << "track: Pt = " << candTrack->pt() << " eta = " << candTrack->eta() << ", phi = " << candTrack->phi() << ", charge = " << candTrack->charge() ; edm::LogPrint("RecoTauPiZeroStripPlugin2") << " (dZ = " << candTrack->dz(vertexAssociator_.associatedVertex(jet)->position()) << ", dXY = " << candTrack->dxy(vertexAssociator_.associatedVertex(jet)->position()) << "," << " numHits = " << candTrack->hitPattern().numberOfValidTrackerHits() << ", numPxlHits = " << candTrack->hitPattern().numberOfValidPixelHits() << "," << " chi2 = " << candTrack->normalizedChi2() << ", dPt/Pt = " << (candTrack->ptError()/candTrack->pt()) << ")" ; } - edm::LogPrint("RecoTauPiZeroStripPlugin2") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," - << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; - edm::LogPrint("RecoTauPiZeroStripPlugin2") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," - << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; + // edm::LogPrint("RecoTauPiZeroStripPlugin2") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," + // << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; + // edm::LogPrint("RecoTauPiZeroStripPlugin2") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," + // << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; } seedCands.push_back(*cand); } else if ( (*cand)->et() > minGammaEtStripAdd_ ) { diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 7985695248c9b..8fc0caf590b03 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -1,11 +1,13 @@ #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" -#include "DataFormats/ParticleFlowCandidate/interface/CandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" + #include typedef std::vector CandPtrs; @@ -34,7 +36,7 @@ flattenPiZeros(const std::vector& piZeros) { std::vector pfCandidates(const reco::Jet& jet, int pdgId, bool sort) { - CandPtrs pfCands = jet.getPFConstituents(); + CandPtrs pfCands = jet.daughterPtrVector(); CandPtrs selectedPFCands = filterPFCandidates( pfCands.begin(), pfCands.end(), pdgId, sort); return selectedPFCands; @@ -42,7 +44,7 @@ std::vector pfCandidates(const reco::Jet& jet, std::vector pfCandidates(const reco::Jet& jet, const std::vector& pdgIds, bool sort) { - CandPtrs&& pfCands = jet.getPFConstituents(); + const CandPtrs& pfCands = jet.daughterPtrVector(); CandPtrs output; // Get each desired candidate type, unsorted for now for(std::vector::const_iterator pdgId = pdgIds.begin(); @@ -60,7 +62,7 @@ std::vector pfGammas(const reco::Jet& jet, bool sort) { std::vector pfChargedCands(const reco::Jet& jet, bool sort) { - CandPtrs&& pfCands = jet.getPFConstituents(); + const CandPtrs& pfCands = jet.daughterPtrVector(); CandPtrs output; CandPtrs&& mus = filterPFCandidates(pfCands.begin(), pfCands.end(), 13, false); CandPtrs&& es = filterPFCandidates(pfCands.begin(), pfCands.end(), 11, false); @@ -73,12 +75,30 @@ std::vector pfChargedCands(const reco::Jet& jet, return output; } -math::XYZPoint atECALEntrance(const reco::Candidate* part) { - const reco::PFCandidate* pfCand = dynamic_cast(part); +std::vector convertPtrVectorToPF(const std::vector& cands) { + std::vector newSignalPFCands; + for (auto& cand : cands) { + const auto& newPtr = cand->masterClone().castTo >(); + newSignalPFCands.push_back(newPtr); + } + return std::move(newSignalPFCands); +} + +std::vector convertPtrVector(const std::vector& cands) { + std::vector newSignalCands; + for (auto& cand : cands) { + const auto& newPtr = cand->masterClone().castTo >(); + newSignalCands.push_back(newPtr); + } + return std::move(newSignalCands); +} + +math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField) { + const reco::PFCandidate* pfCand = dynamic_cast(part); if (pfCand) return pfCand->positionAtECALEntrance(); - math::XYZPoint pos; + math::XYZPointF pos; BaseParticlePropagator theParticle = BaseParticlePropagator(RawParticle(math::XYZTLorentzVector(part->px(), part->py(), @@ -88,11 +108,11 @@ math::XYZPoint atECALEntrance(const reco::Candidate* part) { part->vertex().y(), part->vertex().z(), 0.)), - 0.,0.,bField_); + 0.,0.,bField); theParticle.setCharge(part->charge()); theParticle.propagateToEcalEntrance(false); if(theParticle.getSuccess()!=0){ - pos = math::XYZPoint(theParticle.vertex()); + pos = math::XYZPointF(theParticle.vertex()); } return pos; } diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index 9a14f847b101c..cbe2733c760c8 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -12,7 +12,7 @@ namespace reco { namespace tau { -RecoTauConstructor::RecoTauConstructor(const PFJetRef& jet, const edm::Handle& pfCands, +RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle& pfCands, bool copyGammasFromPiZeros, const StringObjectFunction* signalConeSize, double minAbsPhotonSumPt_insideSignalCone, double minRelPhotonSumPt_insideSignalCone, @@ -55,7 +55,7 @@ RecoTauConstructor::RecoTauConstructor(const PFJetRef& jet, const edm::HandlesetjetRef(jet); + tau_->setjetRef(jet.castTo()); } void RecoTauConstructor::addPFCand(Region region, ParticleType type, const PFCandidateRef& ref, bool skipAddToP4) { @@ -111,17 +111,20 @@ void RecoTauConstructor::reserveTauChargedHadron(Region region, size_t size) namespace { - void checkOverlap(const PFCandidatePtr& neutral, const std::vector& pfGammas, bool& isUnique) + void checkOverlap(const CandidatePtr& neutral, const std::vector& pfGammas, bool& isUnique) { LogDebug("TauConstructorCheckOverlap") << " pfGammas: #entries = " << pfGammas.size(); for ( std::vector::const_iterator pfGamma = pfGammas.begin(); pfGamma != pfGammas.end(); ++pfGamma ) { LogDebug("TauConstructorCheckOverlap") << "pfGamma = " << pfGamma->id() << ":" << pfGamma->key(); - if ( (*pfGamma) == neutral ) isUnique = false; + // JAN - FIXME - double-check that id() equality is fine! + // lhs.refCore() == rhs.refCore() && lhs.key() == rhs.key() ??? + if ( (*pfGamma).refCore() == neutral.refCore() && (*pfGamma).key() == neutral.key() ) isUnique = false; } } - void checkOverlap(const PFCandidatePtr& neutral, const std::vector& piZeros, bool& isUnique) + + void checkOverlap(const CandidatePtr& neutral, const std::vector& piZeros, bool& isUnique) { LogDebug("TauConstructorCheckOverlap") << " piZeros: #entries = " << piZeros.size(); for ( std::vector::const_iterator piZero = piZeros.begin(); @@ -140,9 +143,9 @@ void RecoTauConstructor::addTauChargedHadron(Region region, const PFRecoTauCharg { LogDebug("TauConstructorAddChH") << " region = " << region << ": Pt = " << chargedHadron.pt() << ", eta = " << chargedHadron.eta() << ", phi = " << chargedHadron.phi(); // CV: need to make sure that PFGammas merged with ChargedHadrons are not part of PiZeros - const std::vector& neutrals = chargedHadron.getNeutralPFCandidates(); - std::vector neutrals_cleaned; - for ( std::vector::const_iterator neutral = neutrals.begin(); + const std::vector& neutrals = chargedHadron.getNeutralPFCandidates(); + std::vector neutrals_cleaned; + for ( std::vector::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral ) { LogDebug("TauConstructorAddChH") << "neutral = " << neutral->id() << ":" << neutral->key(); bool isUnique = true; @@ -164,25 +167,25 @@ void RecoTauConstructor::addTauChargedHadron(Region region, const PFRecoTauCharg tau_->signalTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned); p4_ += chargedHadron_cleaned.p4(); if ( chargedHadron_cleaned.getChargedPFCandidate().isNonnull() ) { - addPFCand(kSignal, kChargedHadron, chargedHadron_cleaned.getChargedPFCandidate(), true); + addPFCand(kSignal, kChargedHadron, convertToPtr(chargedHadron_cleaned.getChargedPFCandidate()), true); } - const std::vector& neutrals = chargedHadron_cleaned.getNeutralPFCandidates(); - for ( std::vector::const_iterator neutral = neutrals.begin(); + const std::vector& neutrals = chargedHadron_cleaned.getNeutralPFCandidates(); + for ( std::vector::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral ) { - if ( (*neutral)->particleId() == reco::PFCandidate::gamma ) addPFCand(kSignal, kGamma, *neutral, true); - else if ( (*neutral)->particleId() == reco::PFCandidate::h0 ) addPFCand(kSignal, kNeutralHadron, *neutral, true); + if ( std::abs((*neutral)->pdgId()) == 22 ) addPFCand(kSignal, kGamma, convertToPtr(*neutral), true); + else if ( std::abs((*neutral)->pdgId()) == 130 ) addPFCand(kSignal, kNeutralHadron, convertToPtr(*neutral), true); }; } else { tau_->isolationTauChargedHadronCandidatesRestricted().push_back(chargedHadron_cleaned); if ( chargedHadron_cleaned.getChargedPFCandidate().isNonnull() ) { - if ( chargedHadron_cleaned.getChargedPFCandidate()->particleId() == reco::PFCandidate::h ) addPFCand(kIsolation, kChargedHadron, chargedHadron_cleaned.getChargedPFCandidate()); - else if ( chargedHadron_cleaned.getChargedPFCandidate()->particleId() == reco::PFCandidate::h0 ) addPFCand(kIsolation, kNeutralHadron, chargedHadron_cleaned.getChargedPFCandidate()); + if ( std::abs(chargedHadron_cleaned.getChargedPFCandidate()->pdgId()) == 211 ) addPFCand(kIsolation, kChargedHadron, convertToPtr(chargedHadron_cleaned.getChargedPFCandidate())); + else if ( std::abs(chargedHadron_cleaned.getChargedPFCandidate()->pdgId()) == 130 ) addPFCand(kIsolation, kNeutralHadron, convertToPtr(chargedHadron_cleaned.getChargedPFCandidate())); } - const std::vector& neutrals = chargedHadron_cleaned.getNeutralPFCandidates(); - for ( std::vector::const_iterator neutral = neutrals.begin(); + const std::vector& neutrals = chargedHadron_cleaned.getNeutralPFCandidates(); + for ( std::vector::const_iterator neutral = neutrals.begin(); neutral != neutrals.end(); ++neutral ) { - if ( (*neutral)->particleId() == reco::PFCandidate::gamma ) addPFCand(kIsolation, kGamma, *neutral); - else if ( (*neutral)->particleId() == reco::PFCandidate::h0 ) addPFCand(kIsolation, kNeutralHadron, *neutral); + if ( std::abs((*neutral)->pdgId()) == 22 ) addPFCand(kIsolation, kGamma, convertToPtr(*neutral)); + else if ( std::abs((*neutral)->pdgId()) == 130 ) addPFCand(kIsolation, kNeutralHadron, convertToPtr(*neutral)); }; } } diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index 75bb3d755b9e1..17be726ebd74a 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -3,6 +3,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include @@ -12,10 +13,15 @@ namespace { // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. // JAN FIXME - WE NEED TO SEE WHAT TO DO FOR MINIAOD const reco::TrackBaseRef getTrackRef(const Candidate& cand) - { - if ( cand.trackRef().isNonnull() ) return reco::TrackBaseRef(cand.trackRef()); - else if ( cand.gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(cand.gsfTrackRef()); - else return reco::TrackBaseRef(); + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); + else return reco::TrackBaseRef(); + } + // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); } // Translate GsfTrackRef to TrackBaseRef @@ -410,17 +416,12 @@ bool RecoTauQualityCuts::filterCandByType(const reco::Candidate& cand) const { bool RecoTauQualityCuts::filterCand(const reco::Candidate& cand) const { - auto trackRef = cand.trackRef(); + auto trackRef = getTrackRef(cand); bool result = true; - if(trackRef.isNonnull()) { + + if(trackRef.isNonnull()) result = filterTrack_(trackRef); - } - else { - auto gsfTrackRef = cand.gsfTrackRef(); - if(gsfTrackRef.isNonnull()) { - result = filterTrack_(gsfTrackRef); - } - } + if(result) result = filterCandByType(cand); return result; diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 14f5aa0fcecaf..82dd76d2acd3e 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -15,11 +15,25 @@ namespace reco { namespace tau { +namespace { + inline const reco::TrackBaseRef getTrack(const Candidate& cand) + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); + else return reco::TrackBaseRef(); + } + // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); + } +} + // Get the highest pt track in a jet. // Get the KF track if it exists. Otherwise, see if it has a GSF track. reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const { - std::vector chargedPFCands = pfChargedCands(jet, true); + std::vector chargedPFCands = pfChargedCands(jet, true); if ( verbosity_ >= 1 ) { std::cout << ":" << std::endl; std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << std::endl; @@ -31,7 +45,7 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const return reco::TrackBaseRef(); } - std::vector selectedPFCands; + std::vector selectedPFCands; if ( vxTrkFiltering_ ) { selectedPFCands = qcuts_->filterCandRefs(chargedPFCands); } else { @@ -41,18 +55,15 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const std::cout << " num. selectedPFCands = " << selectedPFCands.size() << std::endl; } - PFCandidatePtr leadPFCand; + CandidatePtr leadPFCand; if ( !selectedPFCands.empty() ) { double leadTrackPt = 0.; if ( leadingTrkOrPFCandOption_ == kFirstTrack){ leadPFCand=selectedPFCands[0];} else { - for ( std::vector::const_iterator pfCand = selectedPFCands.begin(); + for ( std::vector::const_iterator pfCand = selectedPFCands.begin(); pfCand != selectedPFCands.end(); ++pfCand ) { - const reco::Track* track = nullptr; - if ( (*pfCand)->trackRef().isNonnull() ) track = (*pfCand)->trackRef().get(); - else if ( (*pfCand)->gsfTrackRef().isNonnull() ) track = (*pfCand)->gsfTrackRef().get(); - if ( !track ) continue; + const reco::TrackBaseRef& track = getTrack(**pfCand); double trackPt = 0.; if ( leadingTrkOrPFCandOption_ == kLeadTrack ) { //double trackPt = track->pt(); @@ -79,13 +90,8 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const if ( verbosity_ >= 1 ) { std::cout << "leadPFCand: Pt = " << leadPFCand->pt() << ", eta = " << leadPFCand->eta() << ", phi = " << leadPFCand->phi() << std::endl; } - - if ( leadPFCand->trackRef().isNonnull() ) { - return reco::TrackBaseRef(leadPFCand->trackRef()); - } else if ( leadPFCand->gsfTrackRef().isNonnull() ) { - return reco::TrackBaseRef(leadPFCand->gsfTrackRef()); - } - return reco::TrackBaseRef(); + const reco::TrackBaseRef& track = getTrack(*leadPFCand); + return track; } namespace { @@ -248,7 +254,7 @@ RecoTauVertexAssociator::associatedVertex(const PFTau& tau, bool useJet) const } } // MB: use vertex associated to a given jet if explicitely requested or in case of missing leading track - reco::JetRef jetRef = tau.jetRef(); + reco::PFJetRef jetRef = tau.jetRef(); // FIXME workaround for HLT which does not use updated data format if ( jetRef.isNull() ) jetRef = tau.pfTauTagInfoRef()->pfjetRef(); return associatedVertex(*jetRef); diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index 9f87a6bf9a597..f065888202a88 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -1,7 +1,7 @@ #include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include @@ -16,7 +16,7 @@ void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scal double SumNeutrals = 0.; if ( chargedHadron.algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate) || chargedHadron.algoIs(reco::PFRecoTauChargedHadron::kPFNeutralHadron) ) { - const reco::PFCandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate(); + const reco::CandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate(); assert(chargedPFCand.isNonnull()); chargedHadronP += chargedPFCand->p(); chargedHadronPx = chargedPFCand->px(); @@ -30,8 +30,8 @@ void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scal chargedHadronPy = track->py(); chargedHadronPz = track->pz(); } else assert(0); - const std::vector& neutralPFCands = chargedHadron.getNeutralPFCandidates(); - for ( std::vector::const_iterator neutralPFCand = neutralPFCands.begin(); + const std::vector& neutralPFCands = chargedHadron.getNeutralPFCandidates(); + for ( std::vector::const_iterator neutralPFCand = neutralPFCands.begin(); neutralPFCand != neutralPFCands.end(); ++neutralPFCand ) { SumNeutrals += (*neutralPFCand)->p(); } From c1c0e8cfc67a38b85fd410fd02eb2742d8120662 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 10 Aug 2017 14:01:44 +0200 Subject: [PATCH 005/686] Tau reco: Moving from PFJet to Jet, and from PFCandidate to Candidate, done (PFTau re-reconstruction the same) --- DataFormats/TauReco/src/classes_3.h | 7 ++++ DataFormats/TauReco/src/classes_def_3.xml | 6 ++++ .../interface/RecoTauCommonUtilities.h | 14 ++++++-- ...coTauChargedHadronFromPFCandidatePlugin.cc | 6 ++-- .../RecoTauBuilderCombinatoricPlugin.cc | 4 +-- .../plugins/RecoTauBuilderConePlugin.cc | 6 ++-- .../plugins/RecoTauPiZeroStripPlugin.cc | 6 ++-- .../plugins/RecoTauPiZeroStripPlugin2.cc | 6 ++-- .../plugins/RecoTauPiZeroStripPlugin3.cc | 6 ++-- .../RecoTau/src/RecoTauCommonUtilities.cc | 32 ++++++++++++++++++- 10 files changed, 73 insertions(+), 20 deletions(-) diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h index 8ce89b2174a99..7c8dcd5ee4165 100644 --- a/DataFormats/TauReco/src/classes_3.h +++ b/DataFormats/TauReco/src/classes_3.h @@ -31,6 +31,7 @@ #include "DataFormats/TauReco/interface/PFTau3ProngSummaryFwd.h" #include "DataFormats/TauReco/interface/PFTau3ProngSummaryAssociation.h" #include "DataFormats/JetReco/interface/PFJet.h" +#include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" @@ -82,6 +83,9 @@ namespace DataFormats_TauReco { std::pair > jetPiZeroAssoc_p; std::vector > > jetPiZeroAssoc_v; + std::pair > jetBasePiZeroAssoc_p; + std::vector > > jetBasePiZeroAssoc_v; + std::vector > jetPiZeroAssoc_v_v; reco::PFJetChargedHadronAssociationBase jetChHAssoc_b; @@ -94,6 +98,9 @@ namespace DataFormats_TauReco { std::pair > jetChHAssoc_p; std::vector > > jetChHAssoc_v; + std::pair > jetBaseChHAssoc_p; + std::vector > > jetBaseChHAssoc_v; + std::vector > jetChHAssoc_v_v; diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index 684b0f0dbcffc..891bf958e1cac 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -72,6 +72,9 @@ + + + @@ -90,6 +93,9 @@ + + + diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index cf6af40db1526..71f19836d911f 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -53,12 +53,22 @@ filterPFCandidates(const Iterator& begin, const Iterator& end, } /// Extract pfCandidates of a given particle Id from a PFJet. If sort is true, -/// candidates will be sorted by descending PT +/// candidates will be sorted by descending PT. Internall translates to pdgId std::vector pfCandidates(const Jet& jet, - int pdgId, bool sort=true); + int particleId, bool sort=true); /// Extract pfCandidates of a that match a list of particle Ids from a PFJet std::vector pfCandidates(const Jet& jet, + const std::vector& particleIds, + bool sort=true); + +/// Extract pfCandidates of a given PDG Id from a PFJet. If sort is true, +/// candidates will be sorted by descending PT +std::vector pfCandidatesByPdgId(const Jet& jet, + int pdgId, bool sort=true); + +/// Extract pfCandidates of a that match a list of PDG Ids from a PFJet +std::vector pfCandidatesByPdgId(const Jet& jet, const std::vector& pdgIds, bool sort=true); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 54925a2248b7a..8182aa9dc26ff 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -60,7 +60,7 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro RecoTauQualityCuts* qcuts_; - std::vector inputPdgIds_; // type of candidates to clusterize + std::vector inputParticleIds_; // type of candidates to clusterize double dRmergeNeutralHadronWrtChargedHadron_; double dRmergeNeutralHadronWrtNeutralHadron_; @@ -91,7 +91,7 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts"); qcuts_ = new RecoTauQualityCuts(qcuts_pset); - inputPdgIds_ = pset.getParameter >("chargedHadronCandidatesParticleIds"); + inputParticleIds_ = pset.getParameter >("chargedHadronCandidatesParticleIds"); dRmergeNeutralHadronWrtChargedHadron_ = pset.getParameter("dRmergeNeutralHadronWrtChargedHadron"); dRmergeNeutralHadronWrtNeutralHadron_ = pset.getParameter("dRmergeNeutralHadronWrtNeutralHadron"); @@ -185,7 +185,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputParticleIds_)); for ( CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc index 9d7e7664ca9a4..770be92764549 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc @@ -207,8 +207,8 @@ RecoTauBuilderCombinatoricPlugin::operator()( } CandPtrs pfchs = qcuts_.filterCandRefs(pfChargedCands(*jet)); - CandPtrs pfnhs = qcuts_.filterCandRefs(pfCandidates(*jet, 130)); - CandPtrs pfgammas = qcuts_.filterCandRefs(pfCandidates(*jet, 22)); + CandPtrs pfnhs = qcuts_.filterCandRefs(pfCandidatesByPdgId(*jet, 130)); + CandPtrs pfgammas = qcuts_.filterCandRefs(pfCandidatesByPdgId(*jet, 22)); /// Apply quality cuts to the regional junk around the jet. Note that the /// particle contents of the junk is exclusive to the jet content. diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc index 34b880a7bca07..e0523178e21c4 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc @@ -211,7 +211,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( // Get the PF Charged hadrons + quality cuts CandPtrs pfchs; if (!usePFLeptonsAsChargedHadrons_) { - pfchs = qcuts_.filterCandRefs(pfCandidates(*jet, 211)); + pfchs = qcuts_.filterCandRefs(pfCandidatesByPdgId(*jet, 211)); } else { // Check if we want to include electrons in muons in "charged hadron" // collection. This is the preferred behavior, as the PF lepton selections @@ -224,10 +224,10 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( // Get the PF gammas CandPtrs pfGammas = qcuts_.filterCandRefs( - pfCandidates(*jet, 22)); + pfCandidatesByPdgId(*jet, 22)); // Neutral hadrons CandPtrs pfnhs = qcuts_.filterCandRefs( - pfCandidates(*jet, 130)); + pfCandidatesByPdgId(*jet, 130)); // All the extra junk CandPtrs regionalJunk = qcuts_.filterCandRefs(regionalExtras); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc index 6732488a33155..c9d7217c382f5 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc @@ -56,7 +56,7 @@ class RecoTauPiZeroStripPlugin : public RecoTauPiZeroBuilderPlugin { RecoTauQualityCuts qcuts_; RecoTauVertexAssociator vertexAssociator_; - std::vector inputPdgIds_; //type of candidates to clusterize + std::vector inputParticleIds_; //type of candidates to clusterize double etaAssociationDistance_;//eta Clustering Association Distance double phiAssociationDistance_;//phi Clustering Association Distance @@ -74,7 +74,7 @@ RecoTauPiZeroStripPlugin::RecoTauPiZeroStripPlugin( qcuts_(pset.getParameterSet( "qualityCuts").getParameterSet("signalQualityCuts")), vertexAssociator_(pset.getParameter("qualityCuts"),std::move(iC)) { - inputPdgIds_ = pset.getParameter >( + inputParticleIds_ = pset.getParameter >( "stripCandidatesParticleIds"); etaAssociationDistance_ = pset.getParameter( "stripEtaAssociationDistance"); @@ -102,7 +102,7 @@ RecoTauPiZeroStripPlugin::return_type RecoTauPiZeroStripPlugin::operator()( // Get the candidates passing our quality cuts qcuts_.setPV(vertexAssociator_.associatedVertex(jet)); - CandPtrs candsVector = qcuts_.filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_.filterCandRefs(pfCandidates(jet, inputParticleIds_)); //PFCandPtrs candsVector = qcuts_.filterCandRefs(pfGammas(jet)); // Convert to stl::list to allow fast deletions diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index 287bce87d10f5..4fc353d1b1654 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -73,7 +73,7 @@ class RecoTauPiZeroStripPlugin2 : public RecoTauPiZeroBuilderPlugin double minStripEt_; - std::vector inputPdgIds_; // type of candidates to clusterize + std::vector inputParticleIds_; // type of candidates to clusterize double etaAssociationDistance_; // size of strip clustering window in eta direction double phiAssociationDistance_; // size of strip clustering window in phi direction @@ -118,7 +118,7 @@ RecoTauPiZeroStripPlugin2::RecoTauPiZeroStripPlugin2(const edm::ParameterSet& ps qcuts_pset.addParameter("minGammaEt", std::min(minGammaEtStripSeed_, minGammaEtStripAdd_)); qcuts_ = new RecoTauQualityCuts(qcuts_pset); - inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); + inputParticleIds_ = pset.getParameter >("stripCandidatesParticleIds"); etaAssociationDistance_ = pset.getParameter("stripEtaAssociationDistance"); phiAssociationDistance_ = pset.getParameter("stripPhiAssociationDistance"); @@ -208,7 +208,7 @@ RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(con // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputParticleIds_)); // Convert to stl::list to allow fast deletions CandPtrs seedCands; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index b3ffb976ba611..70ba450ab2e8c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -76,7 +76,7 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin double minStripEt_; - std::vector inputPdgIds_; // type of candidates to clusterize + std::vector inputParticleIds_; // type of candidates to clusterize std::unique_ptr etaAssociationDistance_; // size of strip clustering window in eta direction std::unique_ptr phiAssociationDistance_; // size of strip clustering window in phi direction @@ -140,7 +140,7 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps qcuts_.reset(new RecoTauQualityCuts(qcuts_pset)); - inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); + inputParticleIds_ = pset.getParameter >("stripCandidatesParticleIds"); const edm::ParameterSet& stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistance"); etaAssociationDistance_ = makeFunction("etaAssociationDistance", stripSize_eta_pset); const edm::ParameterSet& stripSize_phi_pset = pset.getParameterSet("stripPhiAssociationDistance"); @@ -232,7 +232,7 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con // Get the candidates passing our quality cuts qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputPdgIds_)); + CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputParticleIds_)); // Convert to stl::list to allow fast deletions CandPtrs seedCands; diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 8fc0caf590b03..186edf162e38c 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -15,6 +15,22 @@ typedef CandPtrs::iterator CandIter; namespace reco { namespace tau { +namespace { + // Re-implemented from PFCandidate.cc + int translateTypeToAbsPdgId(int type) { + switch( type ) { + case reco::PFCandidate::h: return 211; // pi+ + case reco::PFCandidate::e: return 11; + case reco::PFCandidate::mu: return 13; + case reco::PFCandidate::gamma: return 22; + case reco::PFCandidate::h0: return 130; // K_L0 + case reco::PFCandidate::h_HF: return 1; // dummy pdg code + case reco::PFCandidate::egamma_HF: return 2; // dummy pdg code + case reco::PFCandidate::X: + default: return 0; + } + } +} std::vector flattenPiZeros(const std::vector::const_iterator& piZerosBegin, const std::vector::const_iterator& piZerosEnd) { std::vector output; @@ -35,6 +51,20 @@ flattenPiZeros(const std::vector& piZeros) { } std::vector pfCandidates(const reco::Jet& jet, + int particleId, bool sort) { + return pfCandidatesByPdgId(jet, translateTypeToAbsPdgId(particleId), sort); +} + +std::vector pfCandidates(const Jet& jet, + const std::vector& particleIds, + bool sort) { + std::vector pdgIds; + for (auto particleId : particleIds) + pdgIds.push_back(translateTypeToAbsPdgId(particleId)); + return pfCandidatesByPdgId(jet, pdgIds, sort); +} + +std::vector pfCandidatesByPdgId(const reco::Jet& jet, int pdgId, bool sort) { CandPtrs pfCands = jet.daughterPtrVector(); CandPtrs selectedPFCands = filterPFCandidates( @@ -42,7 +72,7 @@ std::vector pfCandidates(const reco::Jet& jet, return selectedPFCands; } -std::vector pfCandidates(const reco::Jet& jet, +std::vector pfCandidatesByPdgId(const reco::Jet& jet, const std::vector& pdgIds, bool sort) { const CandPtrs& pfCands = jet.daughterPtrVector(); CandPtrs output; From 934eb5f3b7e0af80e7479f7972360d9e4e4cf9f2 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 31 Jan 2018 14:36:50 +0100 Subject: [PATCH 006/686] PFTau: Use Candidates instead of PFCandidates, and reference to base jet instead of PFJet --- DataFormats/TauReco/interface/PFTau.h | 78 +++++++++++------------ DataFormats/TauReco/src/PFTau.cc | 73 ++++++++++----------- DataFormats/TauReco/src/classes_def_2.xml | 4 +- DataFormats/TauReco/src/classes_def_3.xml | 4 +- 4 files changed, 77 insertions(+), 82 deletions(-) diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h index cd8c28fc87b53..e3210b7e889f9 100644 --- a/DataFormats/TauReco/interface/PFTau.h +++ b/DataFormats/TauReco/interface/PFTau.h @@ -13,9 +13,9 @@ #include "DataFormats/TauReco/interface/BaseTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" #include "DataFormats/TauReco/interface/PFTauTagInfo.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/JetReco/interface/JetCollection.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" #include "DataFormats/TauReco/interface/RecoTauPiZeroFwd.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" @@ -58,22 +58,22 @@ class PFTau : public BaseTau { ~PFTau() override {}; PFTau* clone() const override; - const PFJetRef& jetRef() const; - void setjetRef(const PFJetRef&); + const JetBaseRef& jetRef() const; + void setjetRef(const JetBaseRef&); // functions to access the PFTauTagInfoRef used by HLT const PFTauTagInfoRef& pfTauTagInfoRef() const; void setpfTauTagInfoRef(const PFTauTagInfoRef); PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const; - const PFCandidatePtr& leadPFChargedHadrCand() const; - const PFCandidatePtr& leadPFNeutralCand() const; + const CandidatePtr& leadPFChargedHadrCand() const; + const CandidatePtr& leadPFNeutralCand() const; //Can be either the charged or the neutral one - const PFCandidatePtr& leadPFCand() const; + const CandidatePtr& leadPFCand() const; - void setleadPFChargedHadrCand(const PFCandidatePtr&); - void setleadPFNeutralCand(const PFCandidatePtr&); - void setleadPFCand(const PFCandidatePtr&); + void setleadPFChargedHadrCand(const CandidatePtr&); + void setleadPFNeutralCand(const CandidatePtr&); + void setleadPFCand(const CandidatePtr&); /// Signed transverse impact parameter significance of the Track /// associated to the leading charged PFCandidate @@ -81,36 +81,36 @@ class PFTau : public BaseTau { void setleadPFChargedHadrCandsignedSipt(const float&); /// PFCandidates in signal region - const std::vector& signalPFCands() const; - void setsignalPFCands(const std::vector&); + const std::vector& signalPFCands() const; + void setsignalPFCands(const std::vector&); /// Charged hadrons in signal region - const std::vector& signalPFChargedHadrCands() const; - void setsignalPFChargedHadrCands(const std::vector&); + const std::vector& signalPFChargedHadrCands() const; + void setsignalPFChargedHadrCands(const std::vector&); /// Neutral hadrons in signal region - const std::vector& signalPFNeutrHadrCands() const; - void setsignalPFNeutrHadrCands(const std::vector&); + const std::vector& signalPFNeutrHadrCands() const; + void setsignalPFNeutrHadrCands(const std::vector&); /// Gamma candidates in signal region - const std::vector& signalPFGammaCands() const; - void setsignalPFGammaCands(const std::vector&); + const std::vector& signalPFGammaCands() const; + void setsignalPFGammaCands(const std::vector&); /// PFCandidates in isolation region - const std::vector& isolationPFCands() const; - void setisolationPFCands(const std::vector&); + const std::vector& isolationPFCands() const; + void setisolationPFCands(const std::vector&); /// Charged candidates in isolation region - const std::vector& isolationPFChargedHadrCands() const; - void setisolationPFChargedHadrCands(const std::vector&); + const std::vector& isolationPFChargedHadrCands() const; + void setisolationPFChargedHadrCands(const std::vector&); //// Neutral hadrons in isolation region - const std::vector& isolationPFNeutrHadrCands() const; - void setisolationPFNeutrHadrCands(const std::vector&); + const std::vector& isolationPFNeutrHadrCands() const; + void setisolationPFNeutrHadrCands(const std::vector&); /// Gamma candidates in isolation region - const std::vector& isolationPFGammaCands() const; - void setisolationPFGammaCands(const std::vector&); + const std::vector& isolationPFGammaCands() const; + void setisolationPFGammaCands(const std::vector&); /// Sum of charged hadron candidate PT in isolation cone; returns NaN /// if isolation region is undefined. @@ -244,24 +244,24 @@ class PFTau : public BaseTau { float signalConeSize_; - reco::PFJetRef jetRef_; + reco::JetBaseRef jetRef_; PFTauTagInfoRef PFTauTagInfoRef_; - reco::PFCandidatePtr leadPFChargedHadrCand_; - reco::PFCandidatePtr leadPFNeutralCand_; - reco::PFCandidatePtr leadPFCand_; + reco::CandidatePtr leadPFChargedHadrCand_; + reco::CandidatePtr leadPFNeutralCand_; + reco::CandidatePtr leadPFCand_; reco::TrackRef electronPreIDTrack_; // Signal candidates - std::vector selectedSignalPFCands_; - std::vector selectedSignalPFChargedHadrCands_; - std::vector selectedSignalPFNeutrHadrCands_; - std::vector selectedSignalPFGammaCands_; + std::vector selectedSignalPFCands_; + std::vector selectedSignalPFChargedHadrCands_; + std::vector selectedSignalPFNeutrHadrCands_; + std::vector selectedSignalPFGammaCands_; // Isolation candidates - std::vector selectedIsolationPFCands_; - std::vector selectedIsolationPFChargedHadrCands_; - std::vector selectedIsolationPFNeutrHadrCands_; - std::vector selectedIsolationPFGammaCands_; + std::vector selectedIsolationPFCands_; + std::vector selectedIsolationPFChargedHadrCands_; + std::vector selectedIsolationPFNeutrHadrCands_; + std::vector selectedIsolationPFGammaCands_; RecoTauPiZeroRefVector signalPiZeroCandidatesRefs_; RecoTauPiZeroRefVector isolationPiZeroCandidatesRefs_; diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index 2beeec970273e..3309a68536baa 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -55,8 +55,8 @@ PFTau::PFTau(Charge q, const LorentzVector& p4, const Point& vtx) PFTau* PFTau::clone() const { return new PFTau(*this); } // Constituent getters and setters -const PFJetRef& PFTau::jetRef() const { return jetRef_; } -void PFTau::setjetRef(const PFJetRef& x) { jetRef_ = x; } +const JetBaseRef& PFTau::jetRef() const { return jetRef_; } +void PFTau::setjetRef(const JetBaseRef& x) { jetRef_ = x; } const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const { return PFTauTagInfoRef_; @@ -64,34 +64,34 @@ const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const { void PFTau::setpfTauTagInfoRef(const PFTauTagInfoRef x) { PFTauTagInfoRef_ = x; } -const PFCandidatePtr& PFTau::leadPFChargedHadrCand() const { return leadPFChargedHadrCand_; } -const PFCandidatePtr& PFTau::leadPFNeutralCand() const { return leadPFNeutralCand_; } -const PFCandidatePtr& PFTau::leadPFCand() const { return leadPFCand_; } +const CandidatePtr& PFTau::leadPFChargedHadrCand() const { return leadPFChargedHadrCand_; } +const CandidatePtr& PFTau::leadPFNeutralCand() const { return leadPFNeutralCand_; } +const CandidatePtr& PFTau::leadPFCand() const { return leadPFCand_; } -void PFTau::setleadPFChargedHadrCand(const PFCandidatePtr& myLead) { leadPFChargedHadrCand_ = myLead;} -void PFTau::setleadPFNeutralCand(const PFCandidatePtr& myLead) { leadPFNeutralCand_ = myLead;} -void PFTau::setleadPFCand(const PFCandidatePtr& myLead) { leadPFCand_ = myLead;} +void PFTau::setleadPFChargedHadrCand(const CandidatePtr& myLead) { leadPFChargedHadrCand_ = myLead;} +void PFTau::setleadPFNeutralCand(const CandidatePtr& myLead) { leadPFNeutralCand_ = myLead;} +void PFTau::setleadPFCand(const CandidatePtr& myLead) { leadPFCand_ = myLead;} float PFTau::leadPFChargedHadrCandsignedSipt() const { return leadPFChargedHadrCandsignedSipt_; } void PFTau::setleadPFChargedHadrCandsignedSipt(const float& x){ leadPFChargedHadrCandsignedSipt_ = x; } -const std::vector& PFTau::signalPFCands() const { return selectedSignalPFCands_; } -void PFTau::setsignalPFCands(const std::vector& myParts) { selectedSignalPFCands_ = myParts; } -const std::vector& PFTau::signalPFChargedHadrCands() const { return selectedSignalPFChargedHadrCands_; } -void PFTau::setsignalPFChargedHadrCands(const std::vector& myParts) { selectedSignalPFChargedHadrCands_ = myParts; } -const std::vector& PFTau::signalPFNeutrHadrCands() const {return selectedSignalPFNeutrHadrCands_; } -void PFTau::setsignalPFNeutrHadrCands(const std::vector& myParts) { selectedSignalPFNeutrHadrCands_ = myParts; } -const std::vector& PFTau::signalPFGammaCands() const { return selectedSignalPFGammaCands_; } -void PFTau::setsignalPFGammaCands(const std::vector& myParts) { selectedSignalPFGammaCands_ = myParts; } - -const std::vector& PFTau::isolationPFCands() const { return selectedIsolationPFCands_; } -void PFTau::setisolationPFCands(const std::vector& myParts) { selectedIsolationPFCands_ = myParts;} -const std::vector& PFTau::isolationPFChargedHadrCands() const { return selectedIsolationPFChargedHadrCands_; } -void PFTau::setisolationPFChargedHadrCands(const std::vector& myParts) { selectedIsolationPFChargedHadrCands_ = myParts; } -const std::vector& PFTau::isolationPFNeutrHadrCands() const { return selectedIsolationPFNeutrHadrCands_; } -void PFTau::setisolationPFNeutrHadrCands(const std::vector& myParts) { selectedIsolationPFNeutrHadrCands_ = myParts; } -const std::vector& PFTau::isolationPFGammaCands() const { return selectedIsolationPFGammaCands_; } -void PFTau::setisolationPFGammaCands(const std::vector& myParts) { selectedIsolationPFGammaCands_ = myParts; } +const std::vector& PFTau::signalPFCands() const { return selectedSignalPFCands_; } +void PFTau::setsignalPFCands(const std::vector& myParts) { selectedSignalPFCands_ = myParts; } +const std::vector& PFTau::signalPFChargedHadrCands() const { return selectedSignalPFChargedHadrCands_; } +void PFTau::setsignalPFChargedHadrCands(const std::vector& myParts) { selectedSignalPFChargedHadrCands_ = myParts; } +const std::vector& PFTau::signalPFNeutrHadrCands() const {return selectedSignalPFNeutrHadrCands_; } +void PFTau::setsignalPFNeutrHadrCands(const std::vector& myParts) { selectedSignalPFNeutrHadrCands_ = myParts; } +const std::vector& PFTau::signalPFGammaCands() const { return selectedSignalPFGammaCands_; } +void PFTau::setsignalPFGammaCands(const std::vector& myParts) { selectedSignalPFGammaCands_ = myParts; } + +const std::vector& PFTau::isolationPFCands() const { return selectedIsolationPFCands_; } +void PFTau::setisolationPFCands(const std::vector& myParts) { selectedIsolationPFCands_ = myParts;} +const std::vector& PFTau::isolationPFChargedHadrCands() const { return selectedIsolationPFChargedHadrCands_; } +void PFTau::setisolationPFChargedHadrCands(const std::vector& myParts) { selectedIsolationPFChargedHadrCands_ = myParts; } +const std::vector& PFTau::isolationPFNeutrHadrCands() const { return selectedIsolationPFNeutrHadrCands_; } +void PFTau::setisolationPFNeutrHadrCands(const std::vector& myParts) { selectedIsolationPFNeutrHadrCands_ = myParts; } +const std::vector& PFTau::isolationPFGammaCands() const { return selectedIsolationPFGammaCands_; } +void PFTau::setisolationPFGammaCands(const std::vector& myParts) { selectedIsolationPFGammaCands_ = myParts; } namespace { @@ -248,9 +248,12 @@ void PFTau::setelectronPreIDDecision(const bool& x) {electronPreIDDecision_ = x; bool PFTau::hasMuonReference() const { // check if muon ref exists if( leadPFChargedHadrCand_.isNull() ) return false; else if( leadPFChargedHadrCand_.isNonnull() ){ - reco::MuonRef muonRef = leadPFChargedHadrCand_->muonRef(); - if( muonRef.isNull() ) return false; - else if( muonRef.isNonnull() ) return true; + const reco::PFCandidate* pf_cand = dynamic_cast(&*leadPFChargedHadrCand_); + if (pf_cand) { + reco::MuonRef muonRef = pf_cand->muonRef(); + if( muonRef.isNull() ) return false; + else if( muonRef.isNonnull() ) return true; + } } return false; } @@ -264,7 +267,7 @@ void PFTau::setMuonDecision(const bool& x) {muonDecision_ = x;} CandidatePtr PFTau::sourceCandidatePtr( size_type i ) const { if ( i!=0 ) return CandidatePtr(); - return refToPtr(jetRef()); + return jetRef().castTo(); } @@ -284,24 +287,16 @@ void PFTau::dump(std::ostream& out) const { out<<"# PF neutral hadr. cand's "<PFNeutrHadrCands().size()<PFGammaCands().size()<chargedHadronMultiplicity()<neutralHadronMultiplicity()<photonMultiplicity()<electronMultiplicity()< - - + + diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index 891bf958e1cac..caf8543e15a76 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -62,7 +62,7 @@ - + @@ -83,7 +83,7 @@ - + From 0bf3efa3fade748dcd6523698b2e70d9389b271b Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 31 Jan 2018 14:37:53 +0100 Subject: [PATCH 007/686] Adapt pat::Tau and related classes/producers to change from PFCandidate to Candidate and PFJet to BaseJet in PFTau --- DataFormats/PatCandidates/interface/Tau.h | 19 +-- .../PatCandidates/interface/TauPFSpecific.h | 24 +-- DataFormats/PatCandidates/src/Tau.cc | 92 +++++++----- .../PatCandidates/src/classes_def_objects.xml | 3 +- .../PatAlgos/plugins/PATTauProducer.cc | 137 +++++++++++++----- 5 files changed, 178 insertions(+), 97 deletions(-) diff --git a/DataFormats/PatCandidates/interface/Tau.h b/DataFormats/PatCandidates/interface/Tau.h index f473cce07430c..7c8724ecf6605 100644 --- a/DataFormats/PatCandidates/interface/Tau.h +++ b/DataFormats/PatCandidates/interface/Tau.h @@ -23,6 +23,7 @@ #include "DataFormats/PatCandidates/interface/Lepton.h" #include "DataFormats/JetReco/interface/GenJetCollection.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/PatCandidates/interface/TauPFSpecific.h" #include "DataFormats/PatCandidates/interface/TauCaloSpecific.h" @@ -160,7 +161,7 @@ namespace pat { const pat::tau::TauPFEssential & pfEssential() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const reco::PFJetRef & pfJetRef() const { return pfSpecific().pfJetRef_; } + const reco::JetBaseRef & pfJetRef() const { return pfSpecific().pfJetRef_; } /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau reco::PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const; @@ -178,16 +179,16 @@ namespace pat { const reco::PFCandidatePtr leadPFCand() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& signalPFCands() const; + const std::vector signalPFCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& signalPFChargedHadrCands() const; + const std::vector signalPFChargedHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& signalPFNeutrHadrCands() const; + const std::vector signalPFNeutrHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& signalPFGammaCands() const; + const std::vector signalPFGammaCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau const std::vector & signalTauChargedHadronCandidates() const; @@ -196,16 +197,16 @@ namespace pat { const std::vector & signalPiZeroCandidates() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& isolationPFCands() const; + const std::vector isolationPFCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& isolationPFChargedHadrCands() const; + const std::vector isolationPFChargedHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& isolationPFNeutrHadrCands() const; + const std::vector isolationPFNeutrHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector& isolationPFGammaCands() const; + const std::vector isolationPFGammaCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau const std::vector & isolationTauChargedHadronCandidates() const; diff --git a/DataFormats/PatCandidates/interface/TauPFSpecific.h b/DataFormats/PatCandidates/interface/TauPFSpecific.h index 87bf760d8082b..137c34216023d 100644 --- a/DataFormats/PatCandidates/interface/TauPFSpecific.h +++ b/DataFormats/PatCandidates/interface/TauPFSpecific.h @@ -24,21 +24,21 @@ struct TauPFSpecific { // constructor from PFTau TauPFSpecific(const reco::PFTau& tau); // datamembers - reco::PFJetRef pfJetRef_; - reco::PFCandidatePtr leadPFChargedHadrCand_; + reco::JetBaseRef pfJetRef_; + reco::CandidatePtr leadPFChargedHadrCand_; float leadPFChargedHadrCandsignedSipt_; - reco::PFCandidatePtr leadPFNeutralCand_; - reco::PFCandidatePtr leadPFCand_; - std::vector selectedSignalPFCands_; - std::vector selectedSignalPFChargedHadrCands_; - std::vector selectedSignalPFNeutrHadrCands_; - std::vector selectedSignalPFGammaCands_; + reco::CandidatePtr leadPFNeutralCand_; + reco::CandidatePtr leadPFCand_; + std::vector selectedSignalPFCands_; + std::vector selectedSignalPFChargedHadrCands_; + std::vector selectedSignalPFNeutrHadrCands_; + std::vector selectedSignalPFGammaCands_; std::vector signalTauChargedHadronCandidates_; std::vector signalPiZeroCandidates_; - std::vector selectedIsolationPFCands_; - std::vector selectedIsolationPFChargedHadrCands_; - std::vector selectedIsolationPFNeutrHadrCands_; - std::vector selectedIsolationPFGammaCands_; + std::vector selectedIsolationPFCands_; + std::vector selectedIsolationPFChargedHadrCands_; + std::vector selectedIsolationPFNeutrHadrCands_; + std::vector selectedIsolationPFGammaCands_; std::vector isolationTauChargedHadronCandidates_; std::vector isolationPiZeroCandidates_; float isolationPFChargedHadrCandsPtSum_; diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc index 012e6d30c2c95..3cf722ee9454e 100644 --- a/DataFormats/PatCandidates/src/Tau.cc +++ b/DataFormats/PatCandidates/src/Tau.cc @@ -326,7 +326,7 @@ void Tau::embedLeadPFCand() { } leadPFCand_.clear(); if (pfSpecific_[0].leadPFCand_.isNonnull() ) { - leadPFCand_.push_back(*pfSpecific_[0].leadPFCand_); //already set in C-tor + leadPFCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFCand_)); //already set in C-tor embeddedLeadPFCand_ = true; } } @@ -337,7 +337,7 @@ void Tau::embedLeadPFChargedHadrCand() { } leadPFChargedHadrCand_.clear(); if (pfSpecific_[0].leadPFChargedHadrCand_.isNonnull() ) { - leadPFChargedHadrCand_.push_back(*pfSpecific_[0].leadPFChargedHadrCand_); //already set in C-tor + leadPFChargedHadrCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFChargedHadrCand_)); //already set in C-tor embeddedLeadPFChargedHadrCand_ = true; } } @@ -348,7 +348,7 @@ void Tau::embedLeadPFNeutralCand() { } leadPFNeutralCand_.clear(); if (pfSpecific_[0].leadPFNeutralCand_.isNonnull() ) { - leadPFNeutralCand_.push_back(*pfSpecific_[0].leadPFNeutralCand_); //already set in C-tor + leadPFNeutralCand_.push_back(*static_cast(&*pfSpecific_[0].leadPFNeutralCand_)); //already set in C-tor embeddedLeadPFNeutralCand_ = true; } } @@ -357,9 +357,9 @@ void Tau::embedSignalPFCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFCands_.push_back(*candPtrs.at(i)); + signalPFCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedSignalPFCands_ = true; } @@ -367,9 +367,9 @@ void Tau::embedSignalPFChargedHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFChargedHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFChargedHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFChargedHadrCands_.push_back(*candPtrs.at(i)); + signalPFChargedHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedSignalPFChargedHadrCands_ = true; } @@ -377,9 +377,9 @@ void Tau::embedSignalPFNeutralHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFNeutrHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFNeutrHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFNeutralHadrCands_.push_back(*candPtrs.at(i)); + signalPFNeutralHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedSignalPFNeutralHadrCands_ = true; } @@ -387,9 +387,9 @@ void Tau::embedSignalPFGammaCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFGammaCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFGammaCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFGammaCands_.push_back(*candPtrs.at(i)); + signalPFGammaCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedSignalPFGammaCands_ = true; } @@ -398,9 +398,9 @@ void Tau::embedIsolationPFCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFCands_.push_back(*candPtrs.at(i)); + isolationPFCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedIsolationPFCands_ = true; } @@ -409,9 +409,9 @@ void Tau::embedIsolationPFChargedHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFChargedHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFChargedHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFChargedHadrCands_.push_back(*candPtrs.at(i)); + isolationPFChargedHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedIsolationPFChargedHadrCands_ = true; } @@ -419,9 +419,9 @@ void Tau::embedIsolationPFNeutralHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFNeutrHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFNeutrHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFNeutralHadrCands_.push_back(*candPtrs.at(i)); + isolationPFNeutralHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedIsolationPFNeutralHadrCands_ = true; } @@ -429,9 +429,9 @@ void Tau::embedIsolationPFGammaCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFGammaCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFGammaCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFGammaCands_.push_back(*candPtrs.at(i)); + isolationPFGammaCands_.push_back(*static_cast(&*candPtrs.at(i))); } embeddedIsolationPFGammaCands_ = true; } @@ -445,10 +445,26 @@ reco::PFRecoTauChargedHadronRef Tau::leadTauChargedHadronCandidate() const { } } +const reco::PFCandidatePtr convertToPFCandidatePtr(const reco::CandidatePtr& ptr) { + const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); + if (pf_cand) + return pf_cand->masterClone().castTo >(); + return reco::PFCandidatePtr(); +} + +std::vector convertPtrVector(const std::vector& cands) { + std::vector newSignalPFCands; + for (auto& cand : cands) { + const auto& newPtr = cand->masterClone().castTo >(); + newSignalPFCands.push_back(newPtr); + } + return newSignalPFCands; +} + const reco::PFCandidatePtr Tau::leadPFChargedHadrCand() const { if(!embeddedLeadPFChargedHadrCand_){ if(pfSpecific_.empty()) return reco::PFCandidatePtr(); - else return pfSpecific().leadPFChargedHadrCand_; + else return convertToPFCandidatePtr(pfSpecific().leadPFChargedHadrCand_); }else return reco::PFCandidatePtr(&leadPFChargedHadrCand_,0); } @@ -456,7 +472,7 @@ const reco::PFCandidatePtr Tau::leadPFChargedHadrCand() const { const reco::PFCandidatePtr Tau::leadPFNeutralCand() const { if(!embeddedLeadPFNeutralCand_){ if(pfSpecific_.empty()) return reco::PFCandidatePtr(); - else return pfSpecific().leadPFNeutralCand_; + else return convertToPFCandidatePtr(pfSpecific().leadPFNeutralCand_); }else return reco::PFCandidatePtr(&leadPFNeutralCand_,0); } @@ -464,12 +480,12 @@ const reco::PFCandidatePtr Tau::leadPFNeutralCand() const { const reco::PFCandidatePtr Tau::leadPFCand() const { if(!embeddedLeadPFCand_){ if(pfSpecific_.empty()) return reco::PFCandidatePtr(); - return pfSpecific().leadPFCand_; + return convertToPFCandidatePtr(pfSpecific().leadPFCand_); }else return reco::PFCandidatePtr(&leadPFCand_,0); } -const std::vector& Tau::signalPFCands() const { +const std::vector Tau::signalPFCands() const { if (embeddedSignalPFCands_) { if (!signalPFCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -487,11 +503,11 @@ const std::vector& Tau::signalPFCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFCandsTransientPtrs_; - } else return pfSpecific().selectedSignalPFCands_; + } else return convertPtrVector(pfSpecific().selectedSignalPFCands_); } } -const std::vector& Tau::signalPFChargedHadrCands() const { +const std::vector Tau::signalPFChargedHadrCands() const { if (embeddedSignalPFChargedHadrCands_) { if (!signalPFChargedHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -509,11 +525,11 @@ const std::vector& Tau::signalPFChargedHadrCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFChargedHadrCandsTransientPtrs_; - } else return pfSpecific().selectedSignalPFChargedHadrCands_; + } else return convertPtrVector(pfSpecific().selectedSignalPFChargedHadrCands_); } } -const std::vector& Tau::signalPFNeutrHadrCands() const { +const std::vector Tau::signalPFNeutrHadrCands() const { if (embeddedSignalPFNeutralHadrCands_) { if (!signalPFNeutralHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -531,11 +547,11 @@ const std::vector& Tau::signalPFNeutrHadrCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFNeutralHadrCandsTransientPtrs_; - } else return pfSpecific().selectedSignalPFNeutrHadrCands_; + } else return convertPtrVector(pfSpecific().selectedSignalPFNeutrHadrCands_); } } -const std::vector& Tau::signalPFGammaCands() const { +const std::vector Tau::signalPFGammaCands() const { if (embeddedSignalPFGammaCands_) { if (!signalPFGammaCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -553,7 +569,7 @@ const std::vector& Tau::signalPFGammaCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFGammaCandsTransientPtrs_; - } else return pfSpecific().selectedSignalPFGammaCands_; + } else return convertPtrVector(pfSpecific().selectedSignalPFGammaCands_); } } @@ -567,7 +583,7 @@ const std::vector & Tau::signalPiZeroCandidates() const { return pfSpecific().signalPiZeroCandidates_; } -const std::vector& Tau::isolationPFCands() const { +const std::vector Tau::isolationPFCands() const { if (embeddedIsolationPFCands_) { if (!isolationPFCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -585,11 +601,11 @@ const std::vector& Tau::isolationPFCands() const { std::unique_ptr > aPtrs{new std::vector{}}; isolationPFCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFCandsTransientPtrs_; - } else return pfSpecific().selectedIsolationPFCands_; + } else return convertPtrVector(pfSpecific().selectedIsolationPFCands_); } } -const std::vector& Tau::isolationPFChargedHadrCands() const { +const std::vector Tau::isolationPFChargedHadrCands() const { if (embeddedIsolationPFChargedHadrCands_) { if (!isolationPFChargedHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -607,11 +623,11 @@ const std::vector& Tau::isolationPFChargedHadrCands() cons std::unique_ptr > aPtrs{new std::vector{}}; isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFChargedHadrCandsTransientPtrs_; - } else return pfSpecific().selectedIsolationPFChargedHadrCands_; + } else return convertPtrVector(pfSpecific().selectedIsolationPFChargedHadrCands_); } } -const std::vector& Tau::isolationPFNeutrHadrCands() const { +const std::vector Tau::isolationPFNeutrHadrCands() const { if (embeddedIsolationPFNeutralHadrCands_) { if (!isolationPFNeutralHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -629,11 +645,11 @@ const std::vector& Tau::isolationPFNeutrHadrCands() const std::unique_ptr > aPtrs{new std::vector{}}; isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFNeutralHadrCandsTransientPtrs_; - } else return pfSpecific().selectedIsolationPFNeutrHadrCands_; + } else return convertPtrVector(pfSpecific().selectedIsolationPFNeutrHadrCands_); } } -const std::vector& Tau::isolationPFGammaCands() const { +const std::vector Tau::isolationPFGammaCands() const { if (embeddedIsolationPFGammaCands_) { if (!isolationPFGammaCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -651,7 +667,7 @@ const std::vector& Tau::isolationPFGammaCands() const { std::unique_ptr > aPtrs{new std::vector{}}; isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFGammaCandsTransientPtrs_; - } else return pfSpecific().selectedIsolationPFGammaCands_; + } else return convertPtrVector(pfSpecific().selectedIsolationPFGammaCands_); } } diff --git a/DataFormats/PatCandidates/src/classes_def_objects.xml b/DataFormats/PatCandidates/src/classes_def_objects.xml index 81aa08d7cbc1e..d798462c2adfc 100644 --- a/DataFormats/PatCandidates/src/classes_def_objects.xml +++ b/DataFormats/PatCandidates/src/classes_def_objects.xml @@ -156,7 +156,8 @@ - + + diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index 67179061f197a..da10a8638b5cb 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -18,6 +18,7 @@ #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterAssociation.h" #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameter.h" #include "DataFormats/PatCandidates/interface/TauPFSpecific.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" @@ -382,26 +383,46 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup float sumEnergy = 0.; float leadChargedCandPt = -99; float leadChargedCandEtaAtEcalEntrance = -99; - const std::vector& signalCands = pfTauRef->signalPFCands(); - for(std::vector::const_iterator it = signalCands.begin(); it != signalCands.end(); ++it) { - const reco::PFCandidatePtr& icand = *it; - ecalEnergy += icand->ecalEnergy(); - hcalEnergy += icand->hcalEnergy(); - sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy(); - sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy(); - sumEnergy += icand->energy(); - const reco::Track* track = nullptr; - if ( icand->trackRef().isNonnull() ) track = icand->trackRef().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->innerTrack().isNonnull() ) track = icand->muonRef()->innerTrack().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->globalTrack().isNonnull() ) track = icand->muonRef()->globalTrack().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->outerTrack().isNonnull() ) track = icand->muonRef()->outerTrack().get(); - else if ( icand->gsfTrackRef().isNonnull() ) track = icand->gsfTrackRef().get(); - if( track ) { - if( track->pt() > leadChargedCandPt ) { - leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta(); - leadChargedCandPt = track->pt(); - } - } + const std::vector& signalCands = pfTauRef->signalPFCands(); + for(const auto& it : signalCands) { + const reco::PFCandidate* icand = dynamic_cast(it.get()); + if (icand != nullptr) { + ecalEnergy += icand->ecalEnergy(); + hcalEnergy += icand->hcalEnergy(); + sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy(); + sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy(); + sumEnergy += icand->energy(); + const reco::Track* track = nullptr; + if ( icand->trackRef().isNonnull() ) track = icand->trackRef().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->innerTrack().isNonnull() ) track = icand->muonRef ()->innerTrack().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->globalTrack().isNonnull() ) track = icand->muonRef ()->globalTrack().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->outerTrack().isNonnull() ) track = icand->muonRef ()->outerTrack().get(); + else if ( icand->gsfTrackRef().isNonnull() ) track = icand->gsfTrackRef().get(); + if( track ) { + if( track->pt() > leadChargedCandPt ) { + leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta(); + leadChargedCandPt = track->pt(); + } + } + } + else{ + const pat::PackedCandidate* packedCandPtr = dynamic_cast(it.get()); + if(packedCandPtr != nullptr) { + //position at ECAL entrance can be recomputed, but individual ECAL and HCAL energies not + //ecalEnergy += packedCandPtr->ecalEnergy(); + //hcalEnergy += packedCandPtr->hcalEnergy(); + //sumPhiTimesEnergy += packedCandPtr->positionAtECALEntrance().phi()*packedCandPtr->energy(); + //sumEtaTimesEnergy += packedCandPtr->positionAtECALEntrance().eta()*packedCandPtr->energy(); + sumEnergy += packedCandPtr->energy(); + const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; + if( track != nullptr ) { + if( track->pt() > leadChargedCandPt ) { + //leadChargedCandEtaAtEcalEntrance = packedCandPtr->positionAtECALEntrance().eta(); + leadChargedCandPt = track->pt(); + } + } + } + } } aTauPFEssential.ecalEnergy_ = ecalEnergy; aTauPFEssential.hcalEnergy_ = hcalEnergy; @@ -421,26 +442,68 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup float emFraction = -1.; float myHCALenergy = 0.; float myECALenergy = 0.; - const reco::PFCandidatePtr& leadingPFCharged = pfTauRef->leadPFChargedHadrCand(); + const reco::CandidatePtr& leadingPFCharged = pfTauRef->leadPFChargedHadrCand(); if(leadingPFCharged.isNonnull()) { - ecalEnergyLeadChargedHadrCand = leadingPFCharged->ecalEnergy(); - hcalEnergyLeadChargedHadrCand = leadingPFCharged->hcalEnergy(); - reco::TrackRef trackRef = leadingPFCharged->trackRef(); - if( trackRef.isNonnull() ) { - leadingTrackNormChi2 = trackRef->normalizedChi2(); - for( std::vector::const_iterator tauIt = pfTauRef->isolationPFCands().begin(); tauIt!=pfTauRef->isolationPFCands().end(); ++tauIt ){ - myHCALenergy += (*tauIt)->hcalEnergy(); - myECALenergy += (*tauIt)->ecalEnergy(); - } - for( std::vector::const_iterator tauIt = pfTauRef->signalPFCands().begin(); tauIt!=pfTauRef->signalPFCands().end(); ++tauIt ){ - myHCALenergy += (*tauIt)->hcalEnergy(); - myECALenergy += (*tauIt)->ecalEnergy(); - } - if( myHCALenergy + myECALenergy != 0. ) { - emFraction = myECALenergy/( myHCALenergy + myECALenergy); - } + const reco::PFCandidate* pfCandPtr = dynamic_cast(leadingPFCharged.get()); + if(pfCandPtr != nullptr) { + ecalEnergyLeadChargedHadrCand = pfCandPtr->ecalEnergy(); + hcalEnergyLeadChargedHadrCand = pfCandPtr->hcalEnergy(); + reco::TrackRef trackRef = pfCandPtr->trackRef(); + if( trackRef.isNonnull() ) { + leadingTrackNormChi2 = trackRef->normalizedChi2(); + for(const auto& tauIt : pfTauRef->isolationPFCands()){ + const reco::PFCandidate* pfPtr = dynamic_cast(tauIt.get()); + if (pfPtr != nullptr) { + myHCALenergy += pfPtr->hcalEnergy(); + myECALenergy += pfPtr->ecalEnergy(); + } + } + for(const auto& tauIt : pfTauRef->signalPFCands()){ + const reco::PFCandidate* pfPtr = dynamic_cast(tauIt.get()); + if (pfPtr != nullptr) { + myHCALenergy += pfPtr->hcalEnergy(); + myECALenergy += pfPtr->ecalEnergy(); + } + } + if( myHCALenergy + myECALenergy != 0. ) { + emFraction = myECALenergy/( myHCALenergy + myECALenergy); + } + } } + else { + const pat::PackedCandidate* packedCandPtr = dynamic_cast(leadingPFCharged.get()); + if (packedCandPtr != nullptr) { + //individual ECAL and HCAL energies not available with packedCandPtridates + //ecalEnergyLeadChargedHadrCand = packedCandPtr->ecalEnergy(); + //hcalEnergyLeadChargedHadrCand = packedCandPtr->hcalEnergy(); + const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; + if (track != nullptr) { + leadingTrackNormChi2 = track->normalizedChi2(); + //individual ECAL and HCAL energies not available with packedCandidates + /* + for(const auto& tauIt : pfTauRef->isolationPFCands()){ + const pat::PackedCandidate* packedPtr = dynamic_cast(tauIt.get()); + if(packedPtr != nullptr) { + myHCALenergy += packedPtr->hcalEnergy(); + myECALenergy += packedPtr->ecalEnergy(); + } + } + for(const auto& tauIt : pfTauRef->signalPFCands()){ + const pat::PackedCandidate* packedPtr = dynamic_cast(tauIt.get()); + if(packedPtr != nullptr) { + myHCALenergy += packedPtr->hcalEnergy(); + myECALenergy += packedPtr->ecalEnergy(); + } + } + if( myHCALenergy + myECALenergy > 0. ) { + emFraction = myECALenergy/( myHCALenergy + myECALenergy); + } + */ + } + } + } } + aTauPFEssential.emFraction_ = emFraction; aTauPFEssential.leadingTrackNormChi2_ = leadingTrackNormChi2; aTauPFEssential.ecalEnergyLeadChargedHadrCand_ = ecalEnergyLeadChargedHadrCand; From fa7b9f0ff664f4e6538a9ec550f29761a802a50a Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 31 Jan 2018 14:38:51 +0100 Subject: [PATCH 008/686] Adapt first set of tau algorithms to changes in PFTau data format --- .../RecoTau/interface/AntiElectronIDCut2.h | 36 +++++++------ .../interface/PFRecoTauClusterVariables.h | 43 +++++++++------ ...ecoTauDiscriminationAgainstElectronMVA5.cc | 52 ++++++++++++------- .../PFRecoTauDiscriminationByDeltaE.cc | 2 +- ...uDiscriminationByFlightPathSignificance.cc | 25 +++++---- .../plugins/PFTauSecondaryVertexProducer.cc | 26 ++++++++-- RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc | 4 +- .../RecoTau/plugins/RecoTauPhotonFilter.cc | 12 ++--- 8 files changed, 127 insertions(+), 73 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h index 143e35eca6d1e..4cf9dcb3ce6a1 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h @@ -53,21 +53,24 @@ class AntiElectronIDCut2 { float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for (const auto& cand : signalPFCands) { + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if (pfcand->trackRef().isNonnull()) track = pfcand->trackRef().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull()) track = pfcand->muonRef()->innerTrack().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull()) track = pfcand->muonRef()->globalTrack().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull()) track = pfcand->muonRef()->outerTrack().get(); + else if (pfcand->gsfTrackRef().isNonnull()) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); + } } } + else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } float TauPt = thePFTau.pt(); @@ -76,14 +79,17 @@ class AntiElectronIDCut2 float TauLeadPFChargedHadrEoP = 0.; if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { //TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + const reco::PFCandidate* leadPFCHCand = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (leadPFCHCand != nullptr) + TauLeadPFChargedHadrEoP = leadPFCHCand->ecalEnergy()/leadPFCHCand->p(); + else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } std::vector GammasdEta; std::vector GammasdPhi; std::vector GammasPt; for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index 3c4ddb80e70c0..f9b5ebc0159c9 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -12,6 +12,7 @@ #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/PatCandidates/interface/Tau.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" class TauIdMVAAuxiliaries { public: @@ -22,29 +23,41 @@ class TauIdMVAAuxiliaries { /// return chi2 of the leading track ==> deprecated? <== float tau_leadTrackChi2(const reco::PFTau& tau) const { float LeadingTracknormalizedChi2 = 0; - const reco::PFCandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand() ; + const reco::CandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand(); if (leadingPFCharged.isNonnull()) { - reco::TrackRef tref = leadingPFCharged -> trackRef(); - if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2()); + const reco::PFCandidate* pfcand = dynamic_cast(leadingPFCharged.get()); + if (pfcand != nullptr) { + reco::TrackRef tref = pfcand->trackRef(); + if (tref.isNonnull()) { + LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2()); + } + } + else { + const pat::PackedCandidate* patcand = dynamic_cast(leadingPFCharged.get()); + if (patcand != nullptr && patcand->hasTrackDetails()) { + patcand->pseudoTrack().normalizedChi2(); + } } } return LeadingTracknormalizedChi2; } + /// return ratio of energy in ECAL over sum of energy in ECAL and HCAL float tau_Eratio(const reco::PFTau& tau) const { - std::vector constsignal = tau.signalPFCands(); - float EcalEnInSignalPFCands = 0; - float HcalEnInSignalPFCands = 0; - typedef std::vector ::iterator constituents_iterator; - for(constituents_iterator it=constsignal.begin(); it != constsignal.end(); ++it) { - reco::PFCandidatePtr & icand = *it; - EcalEnInSignalPFCands += icand -> ecalEnergy(); - HcalEnInSignalPFCands += icand -> hcalEnergy(); + const auto& constsignal = tau.signalPFCands(); + float EcalEnInSignalPFCands = 0.; + float HcalEnInSignalPFCands = 0.; + for (const auto& icand : constsignal) { + const reco::PFCandidate* pfcand = dynamic_cast(icand.get()); + if (pfcand != nullptr) { + EcalEnInSignalPFCands += pfcand->ecalEnergy(); + HcalEnInSignalPFCands += pfcand->hcalEnergy(); + } + // JAN - FIXME: not calculated for PackedCandidate } float total = EcalEnInSignalPFCands + HcalEnInSignalPFCands; - if(total==0){ - return -1; + if(total == 0.){ + return -1.; } return EcalEnInSignalPFCands/total; } @@ -207,7 +220,7 @@ class TauIdMVAAuxiliaries { private: /// return pf photon candidates that are associated to signal - const std::vector& getPFGammas(const reco::PFTau& tau, bool signal = true) const { + const std::vector& getPFGammas(const reco::PFTau& tau, bool signal = true) const { if (signal){ return tau.signalPFGammaCands(); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc index f4e453013c418..778ee7879a17f 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc @@ -96,11 +96,14 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& float tauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTauRef->signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy()); - sumEnergy += (*pfCandidate)->energy(); + const std::vector& signalPFCands = thePFTauRef->signalPFCands(); + for (const auto& cand : signalPFCands) { + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += (pfcand->positionAtECALEntrance().eta()*pfcand->energy()); + sumEnergy += pfcand->energy(); + } + else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergy > 0. ) { tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -108,20 +111,23 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& float leadChargedPFCandEtaAtEcalEntrance = -99.; float leadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > leadChargedPFCandPt ) { - leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - leadChargedPFCandPt = track->pt(); + for (const auto& cand : signalPFCands) { + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if (pfcand->trackRef().isNonnull()) track = pfcand->trackRef().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull()) track = pfcand->muonRef()->innerTrack().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull()) track = pfcand->muonRef()->globalTrack().get(); + else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull()) track = pfcand->muonRef()->outerTrack().get(); + else if (pfcand->gsfTrackRef().isNonnull()) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > leadChargedPFCandPt ) { + leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + leadChargedPFCandPt = track->pt(); + } } } + else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) { @@ -133,7 +139,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size(); - bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + bool hasGsfTrack = false; + const reco::PFCandidate* leadPFCH = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + if (leadPFCH != nullptr) { + hasGsfTrack = leadPFCH->gsfTrackRef().isNonnull(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { @@ -175,7 +185,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& if ( !isGsfElectronMatched ) { mvaValue = mva_->MVAValue(*thePFTauRef); size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size(); - bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + bool hasGsfTrack = false; + const reco::PFCandidate* leadPFCH = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + if (leadPFCH != nullptr) { + hasGsfTrack = leadPFCH->gsfTrackRef().isNonnull(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc index 5045b4b93d416..2c6520360403b 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc @@ -48,7 +48,7 @@ double PFRecoTauDiscriminationByDeltaE::discriminate(const PFTauRef& tau) const{ double PFRecoTauDiscriminationByDeltaE::DeltaE(const PFTauRef& tau) const { double tracksE = 0; - const std::vector& signalTracks = tau->signalPFChargedHadrCands(); + const std::vector& signalTracks = tau->signalPFChargedHadrCands(); for(size_t i = 0; i < signalTracks.size(); ++i){ TLorentzVector p4; p4.SetXYZM(signalTracks[i]->px(), diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc index d033c30d66b4d..fe027e618c05b 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc @@ -82,19 +82,22 @@ double PFRecoTauDiscriminationByFlightPathSignificance::threeProngFlightPathSig( } //Secondary vertex - const vector& pfSignalCandidates = tau->signalPFChargedHadrCands(); + const vector& pfSignalCandidates = tau->signalPFChargedHadrCands(); vector transientTracks; - vector::const_iterator iTrack; - for(iTrack = pfSignalCandidates.begin(); iTrack!= pfSignalCandidates.end(); iTrack++){ - const PFCandidate& pfCand = *(iTrack->get()); - if(pfCand.trackRef().isNonnull()){ - const TransientTrack transientTrack = transientTrackBuilder->build(pfCand.trackRef()); - transientTracks.push_back(transientTrack); - } - else if(pfCand.gsfTrackRef().isNonnull()){ - const TransientTrack transientTrack = transientTrackBuilder->build(pfCand.gsfTrackRef()); - transientTracks.push_back(transientTrack); + for(const auto& pfSignalCand : pfSignalCandidates){ + const PFCandidate* pfCand = dynamic_cast(pfSignalCand.get()); + if (pfCand) { + if(pfCand->trackRef().isNonnull()){ + const TransientTrack transientTrack = transientTrackBuilder->build(pfCand->trackRef()); + transientTracks.push_back(transientTrack); + } + else if(pfCand->gsfTrackRef().isNonnull()){ + const TransientTrack transientTrack = transientTrackBuilder->build(pfCand->gsfTrackRef()); + transientTracks.push_back(transientTrack); + } } + else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } if(transientTracks.size() > 1){ KalmanVertexFitter kvf(true); diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index 5148581f45c66..2ac90417f3b85 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -36,6 +36,7 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/Association.h" #include "DataFormats/Common/interface/AssociationVector.h" @@ -71,6 +72,21 @@ PFTauSecondaryVertexProducer::~PFTauSecondaryVertexProducer(){ } +namespace { + const reco::Track* getTrack(const reco::Candidate& cand) { + const reco::PFCandidate* pfCand = dynamic_cast(&cand); + if (pfCand != nullptr) { + if (pfCand->trackRef().isNonnull()) + return &*pfCand->trackRef(); + else if (pfCand->gsfTrackRef().isNonnull()) + return &*pfCand->gsfTrackRef(); + } + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if (pCand != nullptr && pCand->hasTrackDetails()) + return &pCand->pseudoTrack(); + return nullptr; + } +} void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,const edm::EventSetup& iSetup) const { // Obtain edm::ESHandle transTrackBuilder; @@ -94,10 +110,12 @@ void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,con // Get tracks form PFTau daugthers std::vector transTrk; TransientVertex transVtx; - const std::vector > cands = RefPFTau->signalPFChargedHadrCands(); - for (std::vector >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) { - if(iter->get()->trackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->trackRef())); - else if(iter->get()->gsfTrackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->gsfTrackRef())); + const std::vector > cands = RefPFTau->signalPFChargedHadrCands(); + for (const auto& cand : cands) { + if (cand.isNull()) continue; + const reco::Track* track = getTrack(*cand); + if (track != nullptr) + transTrk.push_back(transTrackBuilder->build(*track)); } /////////////////////////////////////////////////////////////////////////////////////////////// // Fit the secondary vertex diff --git a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc index a0047e51ad943..9198d470432f1 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc @@ -179,11 +179,11 @@ namespace const reco::RecoTauPiZero& piZero = signalPiZeroCandidates.at(iPiZero); std::cout << " piZero #" << iPiZero << ": Pt = " << piZero.pt() << ", eta = " << piZero.eta() << ", phi = " << piZero.phi() << ", mass = " << piZero.mass() << std::endl; } - const std::vector& isolationPFCands = tauRef_->isolationPFCands(); + const auto& isolationPFCands = tauRef_->isolationPFCands(); size_t numPFCands = isolationPFCands.size(); std::cout << "isolationPFCands = " << numPFCands << std::endl; for ( size_t iPFCand = 0; iPFCand < numPFCands; ++iPFCand ) { - const reco::PFCandidatePtr& pfCand = isolationPFCands.at(iPFCand); + const auto& pfCand = isolationPFCands.at(iPFCand); std::cout << " pfCand #" << iPFCand << " (" << pfCand.id() << ":" << pfCand.key() << "):" << " Pt = " << pfCand->pt() << ", eta = " << pfCand->eta() << ", phi = " << pfCand->phi() << std::endl; } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc index 89283e09b8bb9..d2c0b95b597a1 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc @@ -114,8 +114,8 @@ void RecoTauPhotonFilter::operator()(PFTau& tau) const { std::vector newSignalPFGammas; std::vector newSignalPFCands; - std::vector newIsolationPFGammas = convertPtrVector(tau.isolationPFGammaCands()); - std::vector newIsolationPFCands = convertPtrVector(tau.isolationPFCands()); + std::vector newIsolationPFGammas = tau.isolationPFGammaCands(); + std::vector newIsolationPFCands = tau.isolationPFCands(); // Move the necessary signal pizeros - what a mess! BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFCands()) { @@ -132,10 +132,10 @@ void RecoTauPhotonFilter::operator()(PFTau& tau) const { newSignalPFGammas.push_back(ptr); } - tau.setsignalPFCands(convertPtrVectorToPF(newSignalPFCands)); - tau.setsignalPFCands(convertPtrVectorToPF(newSignalPFGammas)); - tau.setisolationPFGammaCands(convertPtrVectorToPF(newIsolationPFGammas)); - tau.setisolationPFCands(convertPtrVectorToPF(newIsolationPFCands)); + tau.setsignalPFCands(newSignalPFCands); + tau.setsignalPFCands(newSignalPFGammas); + tau.setisolationPFGammaCands(newIsolationPFGammas); + tau.setisolationPFCands(newIsolationPFCands); } } }} // end namespace reco::tau From eb8795a874496b917e81f34ea364b479f720d6a6 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 20 Nov 2017 18:12:30 +0100 Subject: [PATCH 009/686] Add chargedHadronFromLostTrack builder and adapt related dataformats/modules/tools --- .../interface/PFRecoTauChargedHadron.h | 6 + .../TauReco/src/PFRecoTauChargedHadron.cc | 8 + DataFormats/TauReco/src/classes_def_2.xml | 2 +- .../RecoTau/interface/RecoTauQualityCuts.h | 3 + ...RecoTauChargedHadronFromLostTrackPlugin.cc | 278 ++++++++++++++++++ .../plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 137 ++++++--- .../src/pfRecoTauChargedHadronAuxFunctions.cc | 21 ++ 7 files changed, 408 insertions(+), 47 deletions(-) create mode 100644 RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc diff --git a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h index 1975b61cd8f48..90871a8abe182 100644 --- a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h +++ b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h @@ -10,6 +10,7 @@ namespace reco { namespace tau { class PFRecoTauChargedHadronFromPFCandidatePlugin; class PFRecoTauChargedHadronFromTrackPlugin; + class PFRecoTauChargedHadronFromLostTrackPlugin; class RecoTauConstructor; class PFRecoTauEnergyAlgorithmPlugin; }} @@ -52,6 +53,9 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate /// reference to reco::Track const TrackPtr& getTrack() const; + /// reference to "lostTrack Candidate" when chadron built with tracks stored as pat::PackedCandidates + const CandidatePtr& getLostTrackCandidate() const; + /// references to additional neutral PFCandidates const std::vector& getNeutralPFCandidates() const; @@ -69,6 +73,7 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate private: friend class tau::PFRecoTauChargedHadronFromPFCandidatePlugin; friend class tau::PFRecoTauChargedHadronFromTrackPlugin; + friend class tau::PFRecoTauChargedHadronFromLostTrackPlugin; friend class tau::RecoTauConstructor; friend class tau::PFRecoTauEnergyAlgorithmPlugin; friend class ::PFRecoTauChargedHadronProducer; @@ -76,6 +81,7 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate PFRecoTauChargedHadronAlgorithm algo_; CandidatePtr chargedPFCandidate_; + CandidatePtr lostTrackCandidate_; TrackPtr track_; std::vector neutralPFCandidates_; diff --git a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc index 13f5e8b32dcbc..efad92a86e34f 100644 --- a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc +++ b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc @@ -49,6 +49,11 @@ const PFRecoTauChargedHadron::TrackPtr& PFRecoTauChargedHadron::getTrack() const return track_; } +const CandidatePtr& PFRecoTauChargedHadron::getLostTrackCandidate() const +{ + return lostTrackCandidate_; +} + const std::vector& PFRecoTauChargedHadron::getNeutralPFCandidates() const { return neutralPFCandidates_; @@ -101,6 +106,9 @@ void PFRecoTauChargedHadron::print(std::ostream& stream) const stream << "reco::Track: "; if ( track_.isNonnull() ) { stream << "Pt = " << track_->pt() << " +/- " << track_->ptError() << ", eta = " << track_->eta() << ", phi = " << track_->phi() << std::endl; + } else if ( lostTrackCandidate_.isNonnull() ) { + stream << "(lostTrackCandidate: " << lostTrackCandidate_.id() << ":" << lostTrackCandidate_.key() << "):" + << " Pt = " << lostTrackCandidate_->pt() << ", eta = " << lostTrackCandidate_->eta() << ", phi = " << lostTrackCandidate_->phi() << std::endl; } else { stream << "N/A" << std::endl; } diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 2afdf88f0b622..215d418d87585 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -284,7 +284,7 @@ isolationTauChargedHadronCandidates_.reset(); - + diff --git a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h index f62a79b26449a..1583da7dc485e 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h +++ b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h @@ -57,6 +57,9 @@ class RecoTauQualityCuts /// Filter a single Track bool filterTrack(const reco::TrackBaseRef& track) const; bool filterTrack(const reco::TrackRef& track) const; + bool filterTrack(const reco::Track& track) const; + /// or a single charged candidate + bool filterChargedCand(const reco::Candidate& cand) const; /// Filter a collection of Tracks template diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc new file mode 100644 index 0000000000000..67ce49e758d4e --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc @@ -0,0 +1,278 @@ +/* + * PFRecoTauChargedHadronFromLostTrackPlugin + * + * Build PFRecoTauChargedHadron objects + * using lostTracks, i.e. pat::PackedCandidates built for tracks not used + * by PFlow algorithm as input + * + * Author: Michal Bluj, NCBJ, Poland + * based on PFRecoTauChargedHadronFromTrackPlugin by Christian Veelken + * + */ + +#include "RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" + +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" +#include "DataFormats/JetReco/interface/Jet.h" +#include "DataFormats/Common/interface/AssociationMap.h" +#include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/Math/interface/deltaR.h" + +#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "FastSimulation/Particle/interface/RawParticle.h" + +#include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" +#include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" +#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" +#include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" + +#include + +#include +#include + +namespace reco { namespace tau { + +class PFRecoTauChargedHadronFromLostTrackPlugin : public PFRecoTauChargedHadronBuilderPlugin +{ + public: + explicit PFRecoTauChargedHadronFromLostTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector && iC); + ~PFRecoTauChargedHadronFromLostTrackPlugin() override; + // Return type is auto_ptr + return_type operator()(const reco::Jet&) const override; + // Hook to update PV information + void beginEvent() override; + + private: + typedef std::vector CandPtrs; + + RecoTauVertexAssociator vertexAssociator_; + + RecoTauQualityCuts* qcuts_; + + edm::InputTag srcLostTracks_; + edm::EDGetTokenT lostTracks_token; + double dRcone_; + bool dRconeLimitedToJetArea_; + + double dRmergeNeutralHadron_; + double dRmergePhoton_; + + math::XYZVector magneticFieldStrength_; + + mutable int numWarnings_; + int maxWarnings_; + + int verbosity_; +}; + + PFRecoTauChargedHadronFromLostTrackPlugin::PFRecoTauChargedHadronFromLostTrackPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC) + : PFRecoTauChargedHadronBuilderPlugin(pset,std::move(iC)), + vertexAssociator_(pset.getParameter("qualityCuts"),std::move(iC)), + qcuts_(nullptr) +{ + edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts"); + qcuts_ = new RecoTauQualityCuts(qcuts_pset); + + srcLostTracks_ = pset.getParameter("srcLostTracks"); + lostTracks_token = iC.consumes(srcLostTracks_); + dRcone_ = pset.getParameter("dRcone"); + dRconeLimitedToJetArea_ = pset.getParameter("dRconeLimitedToJetArea"); + + dRmergeNeutralHadron_ = pset.getParameter("dRmergeNeutralHadron"); + dRmergePhoton_ = pset.getParameter("dRmergePhoton"); + + numWarnings_ = 0; + maxWarnings_ = 3; + + verbosity_ = ( pset.exists("verbosity") ) ? + pset.getParameter("verbosity") : 0; +} + +PFRecoTauChargedHadronFromLostTrackPlugin::~PFRecoTauChargedHadronFromLostTrackPlugin() +{ + delete qcuts_; +} + +// Update the primary vertex +void PFRecoTauChargedHadronFromLostTrackPlugin::beginEvent() +{ + vertexAssociator_.setEvent(*this->evt()); + + edm::ESHandle magneticField; + evtSetup()->get().get(magneticField); + magneticFieldStrength_ = magneticField->inTesla(GlobalPoint(0.,0.,0.)); +} + +namespace +{ + struct Candidate_withDistance + { + reco::CandidatePtr pfCandidate_; + double distance_; + }; + + bool isSmallerDistance(const Candidate_withDistance& cand1, const Candidate_withDistance& cand2) + { + return (cand1.distance_ < cand2.distance_); + } +} + +PFRecoTauChargedHadronFromLostTrackPlugin::return_type PFRecoTauChargedHadronFromLostTrackPlugin::operator()(const reco::Jet& jet) const +{ + if ( verbosity_ ) { + edm::LogPrint("TauChHFromLostTrack") << ":" ; + edm::LogPrint("TauChHFromLostTrack") << " pluginName = " << name() ; + } + + ChargedHadronVector output; + + const edm::Event& evt = (*this->evt()); + + edm::Handle lostTracks; + evt.getByToken(lostTracks_token, lostTracks); + + qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); + float jEta=jet.eta(); + float jPhi=jet.phi(); + size_t numTracks = lostTracks->size(); + for ( size_t iTrack = 0; iTrack < numTracks; ++iTrack ) { + // ignore lostTracks without detailed information + if ( !(*lostTracks)[iTrack].hasTrackDetails() ) continue; + const reco::Track *track = &(*lostTracks)[iTrack].pseudoTrack(); + + // consider tracks in vicinity of tau-jet candidate only + double dR = deltaR((*lostTracks)[iTrack].eta(), (*lostTracks)[iTrack].phi(), jEta,jPhi); + double dRmatch = dRcone_; + if ( dRconeLimitedToJetArea_ ) { + double jetArea = jet.jetArea(); + if ( jetArea > 0. ) { + dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi())); + } else { + if ( numWarnings_ < maxWarnings_ ) { + edm::LogInfo("PFRecoTauChargedHadronFromLostTrackPlugin::operator()") + << "Jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << " has area = " << jetArea << " !!" << std::endl; + ++numWarnings_; + } + dRmatch = 0.1; + } + } + if ( dR > dRmatch ) continue; + + // ignore tracks which fail quality cuts + if ( (*lostTracks)[iTrack].charge() == 0 || !qcuts_->filterChargedCand((*lostTracks)[iTrack]) ) continue; + + reco::Candidate::Charge trackCharge_int = 0; + if ( (*lostTracks)[iTrack].charge() > 0. ) trackCharge_int = +1; + else if ( (*lostTracks)[iTrack].charge() < 0. ) trackCharge_int = -1; + + const double chargedPionMass = 0.13957; // GeV + double chargedPionP = (*lostTracks)[iTrack].p(); + double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass); + reco::Candidate::LorentzVector chargedPionP4((*lostTracks)[iTrack].px(), (*lostTracks)[iTrack].py(),(*lostTracks)[iTrack].pz(), chargedPionEn); + + reco::Vertex::Point vtx(0.,0.,0.); + if ( vertexAssociator_.associatedVertex(jet).isNonnull() ) vtx = vertexAssociator_.associatedVertex(jet)->position(); + + std::auto_ptr chargedHadron(new PFRecoTauChargedHadron(trackCharge_int, chargedPionP4, vtx, 0, true, PFRecoTauChargedHadron::kTrack)); + // MB: Not possible to save track for a lostTrack(PackedCandidate)/miniAOD, + // need to get the track later using the pseudoTrack method (downstream) + //chargedHadron->track_ = edm::Ptr(tracks, iTrack); + chargedHadron->lostTrackCandidate_ = edm::Ptr(lostTracks,iTrack); + + // CV: Take code for propagating track to ECAL entrance + // from RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc + // to make sure propagation is done in the same way as for charged PFCandidates. + // + // The following replacements need to be made + // outerMomentum -> momentum + // outerPosition -> referencePoint + // in order to run on AOD input + // (outerMomentum and outerPosition require access to reco::TrackExtra objects, which are available in RECO only) + // + XYZTLorentzVector chargedPionPos((*lostTracks)[iTrack].vertex().x(), (*lostTracks)[iTrack].vertex().y(), (*lostTracks)[iTrack].vertex().z(), 0.); + BaseParticlePropagator trackPropagator(RawParticle(chargedPionP4, chargedPionPos), 0., 0., magneticFieldStrength_.z()); + trackPropagator.setCharge((*lostTracks)[iTrack].charge()); + trackPropagator.propagateToEcalEntrance(false); + if ( trackPropagator.getSuccess() != 0 ) { + chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex(); + } else { + if ( chargedPionP4.pt() > 2. ) { + edm::LogWarning("PFRecoTauChargedHadronFromLostTrackPlugin::operator()") + << "Failed to propagate track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() << " to ECAL entrance !!" << std::endl; + } + chargedHadron->positionAtECALEntrance_ = math::XYZPointF(0.,0.,0.); + } + + std::vector neutralJetConstituents_withDistance; + std::vector jetConstituents = jet.daughterPtrVector(); + for ( const auto& jetConstituent : jetConstituents ) { + int pdgId = jetConstituent->pdgId(); + if ( !(pdgId == 130 || pdgId == 22) ) continue; + double dR = deltaR(atECALEntrance(&*jetConstituent, magneticFieldStrength_.z()), chargedHadron->positionAtECALEntrance_); + double dRmerge = -1.; + if ( pdgId == 130 ) dRmerge = dRmergeNeutralHadron_; + else if ( pdgId == 22 ) dRmerge = dRmergePhoton_; + if ( dR < dRmerge ) { + Candidate_withDistance jetConstituent_withDistance; + jetConstituent_withDistance.pfCandidate_ = jetConstituent; + jetConstituent_withDistance.distance_ = dR; + neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance); + chargedHadron->addDaughter(jetConstituent); + } + } + std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance); + + const double caloResolutionCoeff = 1.0; // CV: approximate ECAL + HCAL calorimeter resolution for hadrons by 100%*sqrt(E) + double trackPtError = 0.06; // MB: Approximate avarage track PtError by 2.5% (barrel), 4% (transition), 6% (endcaps) lostTracks w/o detailed track information available (after TRK-11-001) + if( std::abs((*lostTracks)[iTrack].eta()) < 0.9 ) + trackPtError = 0.025; + else if( std::abs((*lostTracks)[iTrack].eta()) < 1.4 ) + trackPtError = 0.04; + if(track != nullptr) + trackPtError = track->ptError(); + double resolutionTrackP =(*lostTracks)[iTrack].p()*(trackPtError/(*lostTracks)[iTrack].pt()); + double neutralEnSum = 0.; + for ( std::vector::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin(); + nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) { + double nextNeutralEn = nextNeutral->pfCandidate_->energy(); + double resolutionCaloEn = caloResolutionCoeff*sqrt(neutralEnSum + nextNeutralEn); + double resolution = sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn); + if ( (neutralEnSum + nextNeutralEn) < ((*lostTracks)[iTrack].p() + 2.*resolution) ) { + chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_); + neutralEnSum += nextNeutralEn; + } else { + break; + } + } + + setChargedHadronP4(*chargedHadron); + + if ( verbosity_ ) { + edm::LogPrint("TauChHFromLostTrack") << *chargedHadron; + } + + output.push_back(chargedHadron); + } + + return output.release(); +} + +}} // end namespace reco::tau + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_EDM_PLUGIN(PFRecoTauChargedHadronBuilderPluginFactory, reco::tau::PFRecoTauChargedHadronFromLostTrackPlugin, "PFRecoTauChargedHadronFromLostTrackPlugin"); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 405d7353fd983..2903d50d8b570 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -17,6 +17,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/Common/interface/Ptr.h" @@ -39,7 +40,7 @@ class PFRecoTauEnergyAlgorithmPlugin : public RecoTauModifierPlugin explicit PFRecoTauEnergyAlgorithmPlugin(const edm::ParameterSet&, edm::ConsumesCollector &&iC); ~PFRecoTauEnergyAlgorithmPlugin() override; - void operator()(PFTau&) const override; + void operator()(reco::PFTau&) const override; void beginEvent() override; void endEvent() override; @@ -53,7 +54,7 @@ class PFRecoTauEnergyAlgorithmPlugin : public RecoTauModifierPlugin int verbosity_; }; - PFRecoTauEnergyAlgorithmPlugin::PFRecoTauEnergyAlgorithmPlugin(const edm::ParameterSet& cfg, edm::ConsumesCollector &&iC) +PFRecoTauEnergyAlgorithmPlugin::PFRecoTauEnergyAlgorithmPlugin(const edm::ParameterSet& cfg, edm::ConsumesCollector &&iC) : RecoTauModifierPlugin(cfg, std::move(iC)), dRaddNeutralHadron_(cfg.getParameter("dRaddNeutralHadron")), minNeutralHadronEt_(cfg.getParameter("minNeutralHadronEt")), @@ -78,7 +79,7 @@ namespace return trackPerr*trackPerr; } - void updateTauP4(PFTau& tau, double sf, const reco::Candidate::LorentzVector& addP4) + void updateTauP4(reco::PFTau& tau, double sf, const reco::Candidate::LorentzVector& addP4) { // preserve tau candidate mass when adding extra neutral energy double tauPx_modified = tau.px() + sf*addP4.px(); @@ -90,15 +91,46 @@ namespace tau.setP4(tauP4_modified); } - void killTau(PFTau& tau) + void killTau(reco::PFTau& tau) { reco::Candidate::LorentzVector tauP4_modified(0.,0.,0.,0.); tau.setP4(tauP4_modified); tau.setStatus(-1); } + + const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron) { + // Charged hadron made from track (reco::Track) - RECO/AOD only + if ( chargedHadron.getTrack().isNonnull()) { + return chargedHadron.getTrack().get(); + } + // Get track from chargedPackedCandidate - MINIAOD + const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); + if (chargedPFPCand) { + if (chargedPFPCand->hasTrackDetails()) + return &chargedPFPCand->pseudoTrack(); + } + // Get track from lostTrackPackedCandidate - MINIAOD for charged hadron made from lostTtrack (pat::PackedCandidate) + const pat::PackedCandidate* lostTrackPCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); + if (lostTrackPCand) { + if (lostTrackPCand->hasTrackDetails()) + return &lostTrackPCand->pseudoTrack(); + } + + return nullptr; + } +} + +template +bool isPtrEqual(const edm::Ptr& b, const edm::Ptr& d) { + return edm::Ptr(b) == d; } -void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const +template +bool isPtrEqual(const edm::Ptr& b, const edm::Ptr& d) { + return b == d; +} + +void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const { if ( verbosity_ ) { std::cout << ":" << std::endl; @@ -106,30 +138,29 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const } // Add high Pt PFNeutralHadrons and PFGammas that are not "used" by tau decay mode object - std::vector addNeutrals; + std::vector addNeutrals; reco::Candidate::LorentzVector addNeutralsSumP4; - std::vector jetConstituents = tau.jetRef()->getPFConstituents(); - for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); - jetConstituent != jetConstituents.end(); ++jetConstituent ) { - reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId(); - if ( !((jetConstituentType == reco::PFCandidate::h0 && (*jetConstituent)->et() > minNeutralHadronEt_) || - (jetConstituentType == reco::PFCandidate::gamma && (*jetConstituent)->et() > minGammaEt_ )) ) continue; + const auto& jetConstituents = tau.jetRef()->daughterPtrVector(); + for (const auto& jetConstituent : jetConstituents) { + + int jetConstituentPdgId = std::abs(jetConstituent->pdgId()); + if ( !((jetConstituentPdgId == 130 && jetConstituent->et() > minNeutralHadronEt_) || + (jetConstituentPdgId == 22 && jetConstituent->et() > minGammaEt_ )) ) continue; bool isSignalPFCand = false; - const std::vector& signalPFCands = tau.signalPFCands(); - for ( std::vector::const_iterator signalPFCand = signalPFCands.begin(); - signalPFCand != signalPFCands.end(); ++signalPFCand ) { - if ( (*jetConstituent) == (*signalPFCand) ) isSignalPFCand = true; + const auto& signalPFCands = tau.signalPFCands(); + for (const auto& signalPFCand : signalPFCands) { + if ( isPtrEqual(jetConstituent, signalPFCand) ) isSignalPFCand = true; } if ( isSignalPFCand ) continue; - double dR = deltaR((*jetConstituent)->p4(), tau.p4()); + double dR = deltaR(jetConstituent->p4(), tau.p4()); double dRadd = -1.; - if ( jetConstituentType == reco::PFCandidate::h0 ) dRadd = dRaddNeutralHadron_; - else if ( jetConstituentType == reco::PFCandidate::gamma ) dRadd = dRaddPhoton_; + if ( jetConstituentPdgId == 130 ) dRadd = dRaddNeutralHadron_; + else if ( jetConstituentPdgId == 22 ) dRadd = dRaddPhoton_; if ( dR < dRadd ) { - addNeutrals.push_back(*jetConstituent); - addNeutralsSumP4 += (*jetConstituent)->p4(); + addNeutrals.push_back(jetConstituent); + addNeutralsSumP4 += jetConstituent->p4(); } } if ( verbosity_ ) { @@ -144,9 +175,17 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const chargedHadron != chargedHadrons.end(); ++chargedHadron ) { if ( chargedHadron->algoIs(PFRecoTauChargedHadron::kTrack) ) { ++numNonPFCandTracks; - const edm::Ptr& chargedHadronTrack = chargedHadron->getTrack(); - nonPFCandTracksSumP += chargedHadronTrack->p(); - nonPFCandTracksSumPerr2 += getTrackPerr2(*chargedHadronTrack); + const reco::Track* chargedHadronTrack = getTrackFromChargedHadron(*chargedHadron); + if ( chargedHadronTrack != nullptr ) { + nonPFCandTracksSumP += chargedHadronTrack->p(); + nonPFCandTracksSumPerr2 += getTrackPerr2(*chargedHadronTrack); + } else { + edm::LogWarning("PFRecoTauEnergyAlgorithmPlugin::operator()") + << "PFRecoTauChargedHadron has no associated reco::Track !!" << std::endl; + if ( verbosity_ ) { + chargedHadron->print(); + } + } } } if ( verbosity_ ) { @@ -288,8 +327,8 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const for ( std::vector::const_iterator chargedHadron = chargedHadrons.begin(); chargedHadron != chargedHadrons.end(); ++chargedHadron ) { if ( chargedHadron->algoIs(PFRecoTauChargedHadron::kChargedPFCandidate) || chargedHadron->algoIs(PFRecoTauChargedHadron::kTrack) ) { - const edm::Ptr& chargedHadronTrack = chargedHadron->getTrack(); - if ( chargedHadronTrack.isNonnull() ) { + const reco::Track* chargedHadronTrack = getTrackFromChargedHadron(*chargedHadron); + if ( chargedHadronTrack != nullptr ) { allTracksSumP += chargedHadronTrack->p(); allTracksSumPerr2 += getTrackPerr2(*chargedHadronTrack); } else { @@ -305,20 +344,26 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const std::cout << "allTracksSumP = " << allTracksSumP << " +/- " << sqrt(allTracksSumPerr2) << std::endl; } double allNeutralsSumEn = 0.; - const std::vector& signalPFCands = tau.signalPFCands(); - for ( std::vector::const_iterator signalPFCand = signalPFCands.begin(); - signalPFCand != signalPFCands.end(); ++signalPFCand ) { + const auto& signalPFCands = tau.signalPFCands(); + for (const auto& signalPFCand : signalPFCands) { if ( verbosity_ ) { - std::cout << "PFCandidate #" << signalPFCand->id() << ":" << signalPFCand->key() << ":" - << " Pt = " << (*signalPFCand)->pt() << ", eta = " << (*signalPFCand)->eta() << ", phi = " << (*signalPFCand)->phi() << std::endl; - std::cout << "calorimeter energy:" - << " ECAL = " << (*signalPFCand)->ecalEnergy() << "," - << " HCAL = " << (*signalPFCand)->hcalEnergy() << "," - << " HO = " << (*signalPFCand)->hoEnergy() << std::endl; - } - if ( edm::isFinite((*signalPFCand)->ecalEnergy()) ) allNeutralsSumEn += (*signalPFCand)->ecalEnergy(); - if ( edm::isFinite((*signalPFCand)->hcalEnergy()) ) allNeutralsSumEn += (*signalPFCand)->hcalEnergy(); - if ( edm::isFinite((*signalPFCand)->hoEnergy()) ) allNeutralsSumEn += (*signalPFCand)->hoEnergy(); + std::cout << "PFCandidate #" << signalPFCand.id() << ":" << signalPFCand.key() << ":" + << " Pt = " << (signalPFCand)->pt() << ", eta = " << (signalPFCand)->eta() << ", phi = " << (signalPFCand)->phi() << std::endl; + } + const PFCandidate* pfCand = dynamic_cast(&*signalPFCand); + if (pfCand) { + if (verbosity_) { + std::cout << "calorimeter energy:" + << " ECAL = " << (pfCand)->ecalEnergy() << "," + << " HCAL = " << (pfCand)->hcalEnergy() << "," + << " HO = " << (pfCand)->hoEnergy() << std::endl; + } + // JAN - FIXME - this info is not readily available in miniAOD + // This means this sub-algo is currently broken + if ( edm::isFinite(pfCand->ecalEnergy()) ) allNeutralsSumEn += pfCand->ecalEnergy(); + if ( edm::isFinite(pfCand->hcalEnergy()) ) allNeutralsSumEn += pfCand->hcalEnergy(); + if ( edm::isFinite(pfCand->hoEnergy()) ) allNeutralsSumEn += pfCand->hoEnergy(); + } } allNeutralsSumEn += addNeutralsSumP4.energy(); if ( allNeutralsSumEn < 0. ) allNeutralsSumEn = 0.; @@ -342,11 +387,11 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const PFRecoTauChargedHadron chargedHadron_modified = chargedHadron; chargedHadron_modified.neutralPFCandidates_.clear(); reco::Candidate::LorentzVector chargedHadronP4_modified(0.,0.,0.,0.); - if ( (chargedHadron.getTrack()).isNonnull() ) { - const Track& chargedHadronTrack = *(chargedHadron.getTrack()); - double chargedHadronPx_modified = chargedHadronTrack.px(); - double chargedHadronPy_modified = chargedHadronTrack.py(); - double chargedHadronPz_modified = chargedHadronTrack.pz(); + const reco::Track* chTrack = getTrackFromChargedHadron(chargedHadron); + if ( chTrack != nullptr ) { + double chargedHadronPx_modified = chTrack->px(); + double chargedHadronPy_modified = chTrack->py(); + double chargedHadronPz_modified = chTrack->pz(); chargedHadronP4_modified = compChargedHadronP4fromPxPyPz(chargedHadronPx_modified, chargedHadronPy_modified, chargedHadronPz_modified); } else { edm::LogWarning("PFRecoTauEnergyAlgorithmPlugin::operator()") @@ -378,8 +423,8 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(PFTau& tau) const PFRecoTauChargedHadron chargedHadron_modified = chargedHadron; chargedHadron_modified.neutralPFCandidates_.clear(); reco::Candidate::LorentzVector chargedHadronP4_modified(0.,0.,0.,0.); - const edm::Ptr& chargedHadronTrack = chargedHadron.getTrack(); - if ( chargedHadronTrack.isNonnull() ) { + const reco::Track* chargedHadronTrack = getTrackFromChargedHadron(chargedHadron); + if ( chargedHadronTrack != nullptr ) { double trackP = chargedHadronTrack->p(); double trackPerr2 = getTrackPerr2(*chargedHadronTrack); if ( verbosity_ ) { diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index f065888202a88..9931126658e8d 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -7,6 +7,27 @@ namespace reco { namespace tau { +namespace { + const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron) { + // Charged hadron made from track (reco::Track) - RECO/AOD only + if ( chargedHadron.getTrack().isNonnull()) { + return chargedHadron.getTrack().get(); + } + // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist + const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); + if (chargedPFPCand != nullptr) { + if (chargedPFPCand->hasTrackDetails()) + return &chargedPFPCand->pseudoTrack(); + } + const pat::PackedCandidate* lostTrackCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); + if (lostTrackCand != nullptr) { + if (lostTrackCand->hasTrackDetails()) + return &lostTrackCand->pseudoTrack(); + } + return nullptr; + } +} + void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scaleFactor_neutralPFCands) { double chargedHadronP = 0.; From 9f728b2c524edb930208b731a1a21cd8e9d82e31 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 1 Feb 2018 17:34:48 +0100 Subject: [PATCH 010/686] Use Candidate instead of PFCandidate in PFTauTagInfo, following change in PFTau --- DataFormats/TauReco/interface/PFTauTagInfo.h | 28 ++++++++++---------- DataFormats/TauReco/src/PFTauTagInfo.cc | 26 +++++++++--------- DataFormats/TauReco/src/classes_def_1.xml | 3 ++- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/DataFormats/TauReco/interface/PFTauTagInfo.h b/DataFormats/TauReco/interface/PFTauTagInfo.h index 6b6df4c20603b..7f4e6f82b3912 100644 --- a/DataFormats/TauReco/interface/PFTauTagInfo.h +++ b/DataFormats/TauReco/interface/PFTauTagInfo.h @@ -11,7 +11,7 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/JetReco/interface/JetCollection.h" #include "DataFormats/TauReco/interface/PFTauTagInfoFwd.h" #include "DataFormats/TauReco/interface/BaseTauTagInfo.h" @@ -24,22 +24,22 @@ namespace reco{ virtual PFTauTagInfo* clone()const; //get the PFCandidates which compose the PF jet and were filtered by RecoTauTag/TauTagTools/ TauTagTools::filteredPFChargedHadrCands(.,...), filteredPFNeutrHadrCands(.), filteredPFGammaCands(.) functions through RecoTauTag/RecoTauTag/ PFRecoTauTagInfoProducer EDProducer - std::vector PFCands()const; - const std::vector& PFChargedHadrCands()const; - void setPFChargedHadrCands(const std::vector&); - const std::vector& PFNeutrHadrCands()const; - void setPFNeutrHadrCands(const std::vector&); - const std::vector& PFGammaCands()const; - void setPFGammaCands(const std::vector&); + std::vector PFCands()const; + const std::vector& PFChargedHadrCands()const; + void setPFChargedHadrCands(const std::vector&); + const std::vector& PFNeutrHadrCands()const; + void setPFNeutrHadrCands(const std::vector&); + const std::vector& PFGammaCands()const; + void setPFGammaCands(const std::vector&); //the reference to the PFJet - const PFJetRef& pfjetRef()const; - void setpfjetRef(const PFJetRef); + const JetBaseRef& pfjetRef()const; + void setpfjetRef(const JetBaseRef); private: - PFJetRef PFJetRef_; - std::vector PFChargedHadrCands_; - std::vector PFNeutrHadrCands_; - std::vector PFGammaCands_; + JetBaseRef PFJetRef_; + std::vector PFChargedHadrCands_; + std::vector PFNeutrHadrCands_; + std::vector PFGammaCands_; }; } #endif diff --git a/DataFormats/TauReco/src/PFTauTagInfo.cc b/DataFormats/TauReco/src/PFTauTagInfo.cc index 1ecda30e48a39..f3706e585d058 100644 --- a/DataFormats/TauReco/src/PFTauTagInfo.cc +++ b/DataFormats/TauReco/src/PFTauTagInfo.cc @@ -5,19 +5,19 @@ using namespace reco; PFTauTagInfo* PFTauTagInfo::clone()const{return new PFTauTagInfo(*this);} -std::vector PFTauTagInfo::PFCands()const{ - std::vector thePFCands; - for (std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); - for (std::vector::const_iterator iPFCand=PFNeutrHadrCands_.begin();iPFCand!=PFNeutrHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); - for (std::vector::const_iterator iPFCand=PFGammaCands_.begin();iPFCand!=PFGammaCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); +std::vector PFTauTagInfo::PFCands()const{ + std::vector thePFCands; + for (std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); + for (std::vector::const_iterator iPFCand=PFNeutrHadrCands_.begin();iPFCand!=PFNeutrHadrCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); + for (std::vector::const_iterator iPFCand=PFGammaCands_.begin();iPFCand!=PFGammaCands_.end();iPFCand++) thePFCands.push_back(*iPFCand); return thePFCands; } -const std::vector& PFTauTagInfo::PFChargedHadrCands() const {return PFChargedHadrCands_;} -void PFTauTagInfo::setPFChargedHadrCands(const std::vector& x){PFChargedHadrCands_=x;} -const std::vector& PFTauTagInfo::PFNeutrHadrCands() const {return PFNeutrHadrCands_;} -void PFTauTagInfo::setPFNeutrHadrCands(const std::vector& x){PFNeutrHadrCands_=x;} -const std::vector& PFTauTagInfo::PFGammaCands() const {return PFGammaCands_;} -void PFTauTagInfo::setPFGammaCands(const std::vector& x){PFGammaCands_=x;} +const std::vector& PFTauTagInfo::PFChargedHadrCands() const {return PFChargedHadrCands_;} +void PFTauTagInfo::setPFChargedHadrCands(const std::vector& x){PFChargedHadrCands_=x;} +const std::vector& PFTauTagInfo::PFNeutrHadrCands() const {return PFNeutrHadrCands_;} +void PFTauTagInfo::setPFNeutrHadrCands(const std::vector& x){PFNeutrHadrCands_=x;} +const std::vector& PFTauTagInfo::PFGammaCands() const {return PFGammaCands_;} +void PFTauTagInfo::setPFGammaCands(const std::vector& x){PFGammaCands_=x;} -const PFJetRef& PFTauTagInfo::pfjetRef()const{return PFJetRef_;} -void PFTauTagInfo::setpfjetRef(const PFJetRef x){PFJetRef_=x;} +const JetBaseRef& PFTauTagInfo::pfjetRef()const{return PFJetRef_;} +void PFTauTagInfo::setpfjetRef(const JetBaseRef x){PFJetRef_=x;} diff --git a/DataFormats/TauReco/src/classes_def_1.xml b/DataFormats/TauReco/src/classes_def_1.xml index 4a30f6c431e2e..6d7ff8ec6411d 100644 --- a/DataFormats/TauReco/src/classes_def_1.xml +++ b/DataFormats/TauReco/src/classes_def_1.xml @@ -29,7 +29,8 @@ - + + From c013bea430257c25305856d411abb2da2b942225 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 1 Feb 2018 17:36:01 +0100 Subject: [PATCH 011/686] Various adaptions in tau plugins for change in PFTau data format --- .../interface/PFRecoTauTagInfoAlgorithm.h | 2 +- .../interface/RecoTauBinnedIsolationPlugin.h | 4 +- .../interface/RecoTauIsolationMasking.h | 10 +-- .../PFRecoTauChargedHadronFromTrackPlugin.cc | 1 - .../PFRecoTauDiscriminationAgainstElectron.cc | 71 +++++++++-------- .../PFRecoTauDiscriminationAgainstMuon.cc | 79 +++++++++++-------- .../PFRecoTauDiscriminationAgainstMuonMVA.cc | 37 ++++++--- .../PFRecoTauDiscriminationByHPSSelection.cc | 28 +++++-- .../PFRecoTauDiscriminationByIsolation.cc | 46 +++++------ .../plugins/PFRecoTauTagInfoProducer.cc | 7 +- .../plugins/PFTauPrimaryVertexProducer.cc | 17 ++-- .../PFTauTransverseImpactParameters.cc | 24 ++++-- .../plugins/RecoTauBuilderConePlugin.cc | 4 +- .../plugins/RecoTauDiscriminationByFlight.cc | 17 ++-- .../plugins/RecoTauElectronRejectionPlugin.cc | 47 ++++++----- .../plugins/RecoTauEnergyRecoveryPlugin2.cc | 6 +- ...ecoTauImpactParameterSignificancePlugin.cc | 25 +++++- .../RecoTauIsolationDiscriminantPlugins.cc | 20 ++--- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 4 +- .../RecoTauTauTagInfoWorkaroundModifier.cc | 4 +- .../RecoTau/plugins/RecoTauTwoProngFilter.cc | 20 ++--- 21 files changed, 285 insertions(+), 188 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h b/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h index 72b093556fa19..587eeb6fb0c75 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauTagInfoAlgorithm.h @@ -17,7 +17,7 @@ class PFRecoTauTagInfoAlgorithm { PFRecoTauTagInfoAlgorithm(){} PFRecoTauTagInfoAlgorithm(const edm::ParameterSet&); ~PFRecoTauTagInfoAlgorithm(){} - reco::PFTauTagInfo buildPFTauTagInfo(const reco::PFJetRef&,const std::vector&,const reco::TrackRefVector&,const reco::Vertex&) const; + reco::PFTauTagInfo buildPFTauTagInfo(const reco::JetBaseRef&,const std::vector&,const reco::TrackRefVector&,const reco::Vertex&) const; private: double ChargedHadrCand_tkminPt_; int ChargedHadrCand_tkminPixelHitsn_; diff --git a/RecoTauTag/RecoTau/interface/RecoTauBinnedIsolationPlugin.h b/RecoTauTag/RecoTau/interface/RecoTauBinnedIsolationPlugin.h index 46550e0f4fad3..172ff31089610 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauBinnedIsolationPlugin.h +++ b/RecoTauTag/RecoTau/interface/RecoTauBinnedIsolationPlugin.h @@ -17,7 +17,7 @@ */ #include "RecoTauTag/RecoTau/interface/RecoTauDiscriminantPlugins.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" namespace reco { namespace tau { @@ -28,7 +28,7 @@ class RecoTauDiscriminationBinnedIsolation : public RecoTauDiscriminantPlugin { void beginEvent() override; std::vector operator()(const reco::PFTauRef& tau) const override; // Pure abstract function to extract objects to isolate with - virtual std::vector extractIsoObjects( + virtual std::vector extractIsoObjects( const reco::PFTauRef& tau) const = 0; private: diff --git a/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h b/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h index f2d78ed26b2be..86358e8cba1c8 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h +++ b/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h @@ -25,8 +25,8 @@ class RecoTauIsolationMasking { public: // Structure containing new, maksed isolation collections struct IsoMaskResult { - std::list gammas; - std::list h0s; + std::list gammas; + std::list h0s; }; RecoTauIsolationMasking(const edm::ParameterSet& pset); ~RecoTauIsolationMasking(); @@ -36,10 +36,10 @@ class RecoTauIsolationMasking { void setMaxSigmas(double maxSigmas) {maxSigmas_ = maxSigmas;} private: // Get the energy resoltuion of a gamma or h0 candidate - double resolution(const reco::PFCandidate& cand) const; + double resolution(const reco::Candidate& cand) const; // Check if the candidate is in the correct cone - bool inCone(const reco::PFCandidate& track, - const reco::PFCandidate& cand) const; + bool inCone(const reco::Candidate& track, + const reco::Candidate& cand) const; double ecalCone_; double hcalCone_; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index 0d0e3c9e9b357..e1c657147ab07 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -49,7 +49,6 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild explicit PFRecoTauChargedHadronFromTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector && iC); ~PFRecoTauChargedHadronFromTrackPlugin() override; // Return type is auto_ptr - return_type operator()(const reco::PFJet&) const override; return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc index 9062d88608105..a1ca09943dd58 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc @@ -115,16 +115,19 @@ double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& theP } else { // Check if track goes to Ecal crack - TrackRef myleadTk; - myleadTk=(*thePFTauRef).leadPFChargedHadrCand()->trackRef(); - math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance(); - if(myleadTk.isNonnull()) - { - if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) - { - return 0.; - } - } + const reco::PFCandidate* pflch = dynamic_cast((*thePFTauRef).leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + TrackRef myleadTk; + myleadTk = pflch->trackRef(); + math::XYZPointF myleadTkEcalPos = pflch->positionAtECALEntrance(); + if(myleadTk.isNonnull()) + { + if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) + { + return 0.; + } + } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } bool decision = false; @@ -199,29 +202,31 @@ double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& theP } } if (applyCut_bremCombined_) { - if (thePFTauRef->leadPFChargedHadrCand()->trackRef().isNull()) { - // No KF track found - return 0; - } - if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().empty()) { - if(thePFTauRef->leadPFChargedHadrCand()->hcalEnergy()/thePFTauRef->leadPFChargedHadrCand()->trackRef()->p()signalPFChargedHadrCands().size()==1 && !thePFTauRef->signalPFGammaCands().empty()) { - //calculate the brem ratio energy - float bremEnergy=0.; - float emEnergy=0.; - for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc) - { - PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc); - if(fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta()-cand->eta())energy(); - emEnergy+=cand->energy(); - } - if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass()((*thePFTauRef).leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + if (pflch->trackRef().isNull()) { + // No KF track found + return 0; + } + if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().empty()) { + if(pflch->hcalEnergy()/pflch->trackRef()->p()signalPFChargedHadrCands().size()==1 && !thePFTauRef->signalPFGammaCands().empty()) { + //calculate the brem ratio energy + float bremEnergy=0.; + float emEnergy=0.; + for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc) + { + CandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc); + if(fabs(pflch->trackRef()->eta()-cand->eta())energy(); + emEnergy+=cand->energy(); + } + if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass()hasMuonReference() ) { - - MuonRef muonref = thePFTauRef->leadPFChargedHadrCand()->muonRef(); - if ( discriminatorOption_ == "noSegMatch" ) { - if ( muonref ->numberOfMatches() > maxNumberOfMatches_ ) decision = false; - } else if (discriminatorOption_ == "twoDCut") { - double seg = muon::segmentCompatibility(*muonref); - double calo= muonref->caloCompatibility(); - double border = calo * a + seg * b +c; - if ( border > 0 ) decision = false; - } else if ( discriminatorOption_ == "merePresence" ) { - decision = false; - } else if (discriminatorOption_ == "combined" ) { // testing purpose only - unsigned int muType = 0; - if ( muonref->isGlobalMuon() ) muType = 1; - else if ( muonref->isCaloMuon() ) muType = 2; - else if ( muonref->isTrackerMuon() ) muType = 3; - double muonEnergyFraction = thePFTauRef->pfTauTagInfoRef()->pfjetRef()->chargedMuEnergyFraction(); - bool eta_veto = false; - bool phi_veto = false; - if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true; - if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true; - if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder - } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { - if(checkNumMatches_ && muonref ->numberOfMatches() > maxNumberOfMatches_) decision = false; - if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false; - } else if ( discriminatorOption_ == "HOP" ) { - decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system - } else { - throw edm::Exception(edm::errors::UnimplementedFeature) - << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n"; - } + const reco::PFCandidate* pfcand = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + if (pfcand != nullptr) { + MuonRef muonref = pfcand->muonRef(); + if ( discriminatorOption_ == "noSegMatch" ) { + if ( muonref ->numberOfMatches() > maxNumberOfMatches_ ) decision = false; + } else if (discriminatorOption_ == "twoDCut") { + double seg = muon::segmentCompatibility(*muonref); + double calo= muonref->caloCompatibility(); + double border = calo * a + seg * b +c; + if ( border > 0 ) decision = false; + } else if ( discriminatorOption_ == "merePresence" ) { + decision = false; + } else if (discriminatorOption_ == "combined" ) { // testing purpose only + unsigned int muType = 0; + if ( muonref->isGlobalMuon() ) muType = 1; + else if ( muonref->isCaloMuon() ) muType = 2; + else if ( muonref->isTrackerMuon() ) muType = 3; + float muonEnergyFraction = 0.; + const reco::PFJet* pfJetPtr = dynamic_cast(thePFTauRef->pfTauTagInfoRef()->pfjetRef().get()); + if (pfJetPtr) { + muonEnergyFraction = pfJetPtr->chargedMuEnergyFraction(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFJets, and this outdated algorithm was not updated to cope with PFTaus made from other Jets.\n"; + + bool eta_veto = false; + bool phi_veto = false; + if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true; + if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true; + if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder + } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { + if(checkNumMatches_ && muonref ->numberOfMatches() > maxNumberOfMatches_) decision = false; + if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false; + } else if ( discriminatorOption_ == "HOP" ) { + decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system + } else { + throw edm::Exception(edm::errors::UnimplementedFeature) + << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n"; + } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } // valid muon ref // Additional calo. muon cut: veto one prongs compatible with MIP signature if ( discriminatorOption_ == "HOP" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { if ( thePFTauRef->leadPFChargedHadrCand().isNonnull() ) { - double muonCaloEn = thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() + thePFTauRef->leadPFChargedHadrCand()->ecalEnergy(); - if ( thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_*thePFTauRef->leadPFChargedHadrCand()->p()) ) decision = false; - } + const reco::PFCandidate* pfcand = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + if (pfcand != nullptr) { + double muonCaloEn = pfcand->hcalEnergy() + pfcand->ecalEnergy(); + if ( thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_*pfcand->p()) ) decision = false; + } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } return (decision ? 1. : 0.); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc index 6d1edbe9e06ec..e1dcc99a98947 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc @@ -184,17 +184,28 @@ double PFRecoTauDiscriminationAgainstMuonMVA::discriminate(const PFTauRef& tau) mvaInput_[0] = TMath::Abs(tau->eta()); double tauCaloEnECAL = 0.; double tauCaloEnHCAL = 0.; - const std::vector& tauSignalPFCands = tau->signalPFCands(); - for ( std::vector::const_iterator tauSignalPFCand = tauSignalPFCands.begin(); + const std::vector& tauSignalPFCands = tau->signalPFCands(); + for ( std::vector::const_iterator tauSignalPFCand = tauSignalPFCands.begin(); tauSignalPFCand != tauSignalPFCands.end(); ++tauSignalPFCand ) { - tauCaloEnECAL += (*tauSignalPFCand)->ecalEnergy(); - tauCaloEnHCAL += (*tauSignalPFCand)->hcalEnergy(); + const reco::PFCandidate* pfcand = dynamic_cast(tauSignalPFCand->get()); + if (pfcand != nullptr) { + tauCaloEnECAL += pfcand->ecalEnergy(); + tauCaloEnHCAL += pfcand->hcalEnergy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } + + const reco::PFCandidate* pflch = nullptr; + if (tau->leadPFChargedHadrCand().isNonnull()) { + pflch = dynamic_cast(tau->leadPFChargedHadrCand().get()); + if (pflch == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + mvaInput_[1] = TMath::Sqrt(TMath::Max(0., tauCaloEnECAL)); mvaInput_[2] = TMath::Sqrt(TMath::Max(0., tauCaloEnHCAL)); mvaInput_[3] = tau->leadPFChargedHadrCand()->pt()/TMath::Max(1.,Double_t(tau->pt())); - mvaInput_[4] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->ecalEnergy())); - mvaInput_[5] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->hcalEnergy())); + mvaInput_[4] = TMath::Sqrt(TMath::Max(0., pflch->ecalEnergy())); + mvaInput_[5] = TMath::Sqrt(TMath::Max(0., pflch->hcalEnergy())); int numMatches = 0; std::vector numHitsDT(4); std::vector numHitsCSC(4); @@ -204,17 +215,17 @@ double PFRecoTauDiscriminationAgainstMuonMVA::discriminate(const PFTauRef& tau) numHitsCSC[iStation] = 0; numHitsRPC[iStation] = 0; } - if ( tau->leadPFChargedHadrCand().isNonnull() ) { - reco::MuonRef muonRef = tau->leadPFChargedHadrCand()->muonRef(); - if ( muonRef.isNonnull() ) { - numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration); - countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); - } + + reco::MuonRef muonRef = pflch->muonRef(); + if ( muonRef.isNonnull() ) { + numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration); + countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); } + size_t numMuons = muons_->size(); for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) { reco::MuonRef muon(muons_, idxMuon); - if ( tau->leadPFChargedHadrCand().isNonnull() && tau->leadPFChargedHadrCand()->muonRef().isNonnull() && muon == tau->leadPFChargedHadrCand()->muonRef() ) { + if (pflch->muonRef().isNonnull() && muon == pflch->muonRef()) { continue; } double dR = deltaR(muon->p4(), tau->p4()); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index 1f154feed8b91..2716ee3953fb6 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -8,6 +8,7 @@ #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" #include "DataFormats/TauReco/interface/PFRecoTauChargedHadronFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" namespace { // Apply a hypothesis on the mass of the strips. @@ -125,6 +126,23 @@ PFRecoTauDiscriminationByHPSSelection::~PFRecoTauDiscriminationByHPSSelection() } } +namespace { + inline const reco::Track* getTrack(const reco::Candidate& cand) + { + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); + else return nullptr; + } + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } +} + double PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) const { @@ -317,13 +335,9 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c if ( minPixelHits_ > 0 ) { int numPixelHits = 0; - const std::vector& chargedHadrCands = tau->signalPFChargedHadrCands(); - for ( std::vector::const_iterator chargedHadrCand = chargedHadrCands.begin(); - chargedHadrCand != chargedHadrCands.end(); ++chargedHadrCand ) { - const reco::Track* track = nullptr; - if ( (*chargedHadrCand)->trackRef().isNonnull() ) track = (*chargedHadrCand)->trackRef().get(); - else if ( (*chargedHadrCand)->gsfTrackRef().isNonnull() ) track = (*chargedHadrCand)->gsfTrackRef().get(); - if ( track ) { + for (const auto& chargedHadrCand : tau->signalPFChargedHadrCands()) { + const reco::Track* track = getTrack(*chargedHadrCand); + if (track != nullptr) { numPixelHits += track->hitPattern().numberOfValidPixelHits(); } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 0b5bd4875b0f5..f9bc1bf69da45 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -167,7 +167,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas puFactorizedIsoQCuts.second)); pfCandSrc_ = pset.getParameter("particleFlowSrc"); - pfCand_token = consumes(pfCandSrc_); + pfCand_token = consumes >(pfCandSrc_); vertexSrc_ = pset.getParameter("vertexSrc"); vertex_token = consumes(vertexSrc_); deltaBetaCollectionCone_ = pset.getParameter( @@ -201,7 +201,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; double discriminate(const PFTauRef& pfTau) const override; - inline double weightedSum(const std::vector& inColl_, double eta, double phi) const { + inline double weightedSum(const std::vector& inColl_, double eta, double phi) const { double out = 1.0; for (auto const & inObj_ : inColl_){ double sum = (inObj_->pt()*inObj_->pt())/(deltaR2(eta,phi,inObj_->eta(),inObj_->phi())); @@ -268,11 +268,11 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas // Delta Beta correction bool applyDeltaBeta_; edm::InputTag pfCandSrc_; - edm::EDGetTokenT pfCand_token; + edm::EDGetTokenT > pfCand_token; // Keep track of how many vertices are in the event edm::InputTag vertexSrc_; edm::EDGetTokenT vertex_token; - std::vector chargedPFCandidatesInEvent_; + std::vector chargedPFCandidatesInEvent_; // Size of cone used to collect PU tracks double deltaBetaCollectionCone_; std::auto_ptr deltaBetaFormula_; @@ -304,13 +304,13 @@ void PFRecoTauDiscriminationByIsolation::beginEvent(const edm::Event& event, con // candidates from the event so we can find the PU tracks. if ( applyDeltaBeta_ || calculateWeights_ ) { // Collect all the PF pile up tracks - edm::Handle pfCandidates; + edm::Handle > pfCandidates; event.getByToken(pfCand_token, pfCandidates); chargedPFCandidatesInEvent_.clear(); chargedPFCandidatesInEvent_.reserve(pfCandidates->size()); size_t numPFCandidates = pfCandidates->size(); for ( size_t i = 0; i < numPFCandidates; ++i ) { - reco::PFCandidatePtr pfCandidate(pfCandidates, i); + reco::CandidatePtr pfCandidate(pfCandidates, i); if ( pfCandidate->charge() != 0 ) { chargedPFCandidatesInEvent_.push_back(pfCandidate); } @@ -338,11 +338,11 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const LogDebug("discriminate") << *pfTau ; // collect the objects we are working with (ie tracks, tracks+gammas, etc) - std::vector isoCharged_; - std::vector isoNeutral_; - std::vector isoPU_; - PFCandidateCollection isoNeutralWeight_; - std::vector chPV_; + std::vector isoCharged_; + std::vector isoNeutral_; + std::vector isoPU_; + CandidateCollection isoNeutralWeight_; + std::vector chPV_; isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size()); isoNeutral_.reserve(pfTau->isolationPFGammaCands().size()); isoPU_.reserve(std::min(100UL, chargedPFCandidatesInEvent_.size())); @@ -401,8 +401,8 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const } } - typedef reco::tau::cone::DeltaRPtrFilter DRFilter; - typedef reco::tau::cone::DeltaRFilter DRFilter2; + typedef reco::tau::cone::DeltaRPtrFilter DRFilter; + typedef reco::tau::cone::DeltaRFilter DRFilter2; // If desired, get PU tracks. if ( applyDeltaBeta_ || calculateWeights_) { @@ -411,21 +411,21 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const std::cout << "Initial PFCands: " << chargedPFCandidatesInEvent_.size() << std::endl; } - std::vector allPU = + std::vector allPU = pileupQcutsPUTrackSelection_->filterCandRefs( chargedPFCandidatesInEvent_, true); - std::vector allNPU = + std::vector allNPU = pileupQcutsPUTrackSelection_->filterCandRefs( chargedPFCandidatesInEvent_); LogTrace("discriminate") << "After track cuts: " << allPU.size() ; // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc if ( !useAllPFCands_ ) { - std::vector cleanPU = + std::vector cleanPU = pileupQcutsGeneralQCuts_->filterCandRefs(allPU); - std::vector cleanNPU = + std::vector cleanNPU = pileupQcutsGeneralQCuts_->filterCandRefs(allNPU); LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size() ; @@ -459,7 +459,7 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const double sumNPU = 0.5*log(weightedSum(chPV_, eta, phi)); double sumPU = 0.5*log(weightedSum(isoPU_, eta, phi)); - PFCandidate neutral = (*isoObject); + LeafCandidate neutral(*isoObject); if ( (sumNPU + sumPU) > 0 ) neutral.setP4(((sumNPU)/(sumNPU + sumPU))*neutral.p4()); isoNeutralWeight_.push_back(neutral); @@ -470,9 +470,9 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const if ( customIsoCone_ >= 0. ) { DRFilter filter(pfTau->p4(), 0, customIsoCone_); DRFilter2 filter2(pfTau->p4(), 0, customIsoCone_); - std::vector isoCharged_filter; - std::vector isoNeutral_filter; - PFCandidateCollection isoNeutralWeight_filter; + std::vector isoCharged_filter; + std::vector isoNeutral_filter; + CandidateCollection isoNeutralWeight_filter; // Remove all the objects not in our iso cone for( auto const & isoObject : isoCharged_ ) { if ( filter(isoObject) ) isoCharged_filter.push_back(isoObject); @@ -578,8 +578,8 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const bool failsPhotonPtSumOutsideSignalConeCut = false; double photonSumPt_outsideSignalCone = 0.; if ( applyPhotonPtSumOutsideSignalConeCut_ || storeRawPhotonSumPt_outsideSignalCone_ ) { - const std::vector& signalPFGammas = pfTau->signalPFGammaCands(); - for ( std::vector::const_iterator signalPFGamma = signalPFGammas.begin(); + const std::vector& signalPFGammas = pfTau->signalPFGammaCands(); + for ( std::vector::const_iterator signalPFGamma = signalPFGammas.begin(); signalPFGamma != signalPFGammas.end(); ++signalPFGamma ) { double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalPFGamma)->eta(), (*signalPFGamma)->phi()); if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalPFGamma)->pt(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc index 2a4003f016153..4cd0349939cc7 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc @@ -74,9 +74,9 @@ void PFRecoTauTagInfoProducer::produce(edm::StreamID, edm::Event& iEvent, const // *** access the PFCandidateCollection in the event in order to retrieve the PFCandidateRefVector which constitutes each PFJet edm::Handle thePFCandidateCollection; iEvent.getByToken(PFCandidate_token,thePFCandidateCollection); - vector thePFCandsInTheEvent; + vector thePFCandsInTheEvent; for(unsigned int i_PFCand=0;i_PFCand!=thePFCandidateCollection->size();i_PFCand++) { - thePFCandsInTheEvent.push_back(PFCandidatePtr(thePFCandidateCollection,i_PFCand)); + thePFCandsInTheEvent.push_back(CandidatePtr(thePFCandidateCollection,i_PFCand)); } // *** // query a rec/sim PV @@ -98,7 +98,8 @@ else{ auto resultExt = std::make_unique(); for(JetTracksAssociationCollection::const_iterator iAssoc=thePFJetTracksAssociatorCollection->begin();iAssoc!=thePFJetTracksAssociatorCollection->end();iAssoc++){ - PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo((*iAssoc).first.castTo(),thePFCandsInTheEvent,(*iAssoc).second,thePV); + // PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo((*iAssoc).first.castTo(),thePFCandsInTheEvent,(*iAssoc).second,thePV); + PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo(JetBaseRef((*iAssoc).first),thePFCandsInTheEvent,(*iAssoc).second,thePV); resultExt->push_back(myPFTauTagInfo); } diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 194814472a899..1f54d12498def 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -195,16 +195,23 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ + // Use two signal track collections: One with Refs for taus made from PFCandidates, + // and one with pointers for taus made from PackedCandidates std::vector SignalTracks; + // std::vector SignalTrackPtrs; + // JAN - FIXME - THIS NEEDS TO BE CHANGED WITH MICHAL'S ADAPTIONS + for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < Tau->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ reco::PFTauRef RefPFTau(Tau, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// - // Get tracks from PFTau daugthers - const std::vector > cands = RefPFTau->signalPFChargedHadrCands(); - for (std::vector >::const_iterator iter = cands.begin(); iter!=cands.end(); iter++){ - if(iter->get()->trackRef().isNonnull()) SignalTracks.push_back(reco::TrackBaseRef(iter->get()->trackRef())); - else if(iter->get()->gsfTrackRef().isNonnull()){SignalTracks.push_back(reco::TrackBaseRef(((iter)->get()->gsfTrackRef())));} + // Get tracks from PFTau daughters + for (const auto& cand : RefPFTau->signalPFChargedHadrCands()){ + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + if (pfcand->trackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} + else if (pfcand->gsfTrackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} + } } } } diff --git a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc index d8dd74a45c8bd..46b2173bef8b9 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc @@ -36,6 +36,7 @@ #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameter.h" #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/Association.h" #include "DataFormats/Common/interface/AssociationVector.h" @@ -75,6 +76,23 @@ PFTauTransverseImpactParameters::~PFTauTransverseImpactParameters(){ } +namespace { + inline const reco::Track* getTrack(const Candidate& cand) + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr != nullptr) { + if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); + else return nullptr; + } + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand != nullptr && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } +} + void PFTauTransverseImpactParameters::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ // Obtain Collections edm::ESHandle transTrackBuilder; @@ -105,11 +123,7 @@ void PFTauTransverseImpactParameters::produce(edm::Event& iEvent,const edm::Even double ip3d(-999), ip3d_err(-999); reco::Vertex::Point ip3d_poca(0,0,0); if(RefPFTau->leadPFChargedHadrCand().isNonnull()){ - const reco::Track* track = nullptr; - if(RefPFTau->leadPFChargedHadrCand()->trackRef().isNonnull()) - track = RefPFTau->leadPFChargedHadrCand()->trackRef().get(); - else if(RefPFTau->leadPFChargedHadrCand()->gsfTrackRef().isNonnull()) - track = RefPFTau->leadPFChargedHadrCand()->gsfTrackRef().get(); + const reco::Track* track = getTrack(*RefPFTau->leadPFChargedHadrCand()); if(track != nullptr){ if(useFullCalculation_){ reco::TransientTrack transTrk=transTrackBuilder->build(*track); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc index e0523178e21c4..fcda8a2bcd264 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc @@ -135,8 +135,8 @@ void RecoTauBuilderConePlugin::setTauQuantities(reco::PFTau& aTau, // Set charge int charge = 0; int leadCharge = aTau.leadPFChargedHadrCand().isNonnull() ? aTau.leadPFChargedHadrCand()->charge() : 0; - const std::vector& pfChs = aTau.signalPFChargedHadrCands(); - for(const reco::PFCandidatePtr& pfCh : pfChs){ + const std::vector& pfChs = aTau.signalPFChargedHadrCands(); + for(const reco::CandidatePtr& pfCh : pfChs){ charge += pfCh->charge(); } charge = charge==0 ? leadCharge : charge; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc index d61db038fd992..6678bd38e2e23 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc @@ -54,16 +54,19 @@ double PFRecoTauDiscriminationByFlight::discriminate( const reco::PFTauRef& tau) const { KalmanVertexFitter kvf(true); - const std::vector& signalTracks = + const std::vector& signalTracks = tau->signalPFChargedHadrCands(); std::vector signalTransTracks; std::vector signalTrackPtrs; - BOOST_FOREACH(const reco::PFCandidatePtr& pftrack, signalTracks) { - if (pftrack->trackRef().isNonnull()) { - signalTransTracks.push_back( - builder_->build(pftrack->trackRef())); - signalTrackPtrs.push_back(pftrack->trackRef()); - } + BOOST_FOREACH(const reco::CandidatePtr& signalTrack, signalTracks) { + const reco::PFCandidate* pftrack = dynamic_cast(signalTrack.get()); + if (pftrack != nullptr) { + if (pftrack->trackRef().isNonnull()) { + signalTransTracks.push_back( + builder_->build(pftrack->trackRef())); + signalTrackPtrs.push_back(pftrack->trackRef()); + } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } reco::Vertex pv = (*vertices_)[0]; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc index 855dcd635a54a..1ed3cb13bb4c3 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc @@ -83,9 +83,9 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { typedef std::pair ElementInBlock; typedef std::vector< ElementInBlock > ElementsInBlocks; - PFCandidatePtr myleadPFChargedCand = tau.leadPFChargedHadrCand(); + CandidatePtr myleadChargedCand = tau.leadPFChargedHadrCand(); // Build list of PFCands in tau - std::vector myPFCands; + std::vector myPFCands; myPFCands.reserve(tau.isolationPFCands().size()+tau.signalPFCands().size()); std::copy(tau.isolationPFCands().begin(), tau.isolationPFCands().end(), @@ -94,7 +94,10 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { std::back_inserter(myPFCands)); //Use the electron rejection only in case there is a charged leading pion - if(myleadPFChargedCand.isNonnull()){ + if(myleadChargedCand.isNonnull()){ + const reco::PFCandidate* myleadPFChargedCand = dynamic_cast(myleadChargedCand.get()); + if (myleadPFChargedCand == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi(); math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance(); @@ -104,33 +107,37 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { //FROM AOD if(DataType_ == "AOD"){ // Corrected Cluster energies - for(int i=0;i<(int)myPFCands.size();i++){ - myHCALenergy += myPFCands[i]->hcalEnergy(); - myECALenergy += myPFCands[i]->ecalEnergy(); + for(const auto& cand : myPFCands){ + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + myHCALenergy += pfcand->hcalEnergy(); + myECALenergy += pfcand->ecalEnergy(); math::XYZPointF candPos; - if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2)//if charged hadron or electron - candPos = myPFCands[i]->positionAtECALEntrance(); + if (pfcand->particleId()==1 || pfcand->particleId()==2)//if charged hadron or electron + candPos = pfcand->positionAtECALEntrance(); else - candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz()); + candPos = math::XYZPointF(pfcand->px(),pfcand->py(),pfcand->pz()); double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,candPos); double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos); double deltaEta = std::abs(myElecTrkEcalPos.eta()-candPos.eta()); double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge(); - if (myPFCands[i]->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && + if (pfcand->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) { - myStripClusterE += myPFCands[i]->ecalEnergy(); + myStripClusterE += pfcand->ecalEnergy(); } if (deltaR<0.184) { - myHCALenergy3x3 += myPFCands[i]->hcalEnergy(); + myHCALenergy3x3 += pfcand->hcalEnergy(); } - if (myPFCands[i]->hcalEnergy()>myMaximumHCALPFClusterE) { - myMaximumHCALPFClusterE = myPFCands[i]->hcalEnergy(); + if (pfcand->hcalEnergy()>myMaximumHCALPFClusterE) { + myMaximumHCALPFClusterE = pfcand->hcalEnergy(); } - if ((myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { - myMaximumHCALPFClusterEt = (myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta()))); + if ((pfcand->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { + myMaximumHCALPFClusterEt = (pfcand->hcalEnergy()*fabs(sin(candPos.Theta()))); } } @@ -138,8 +145,12 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { // Against double counting of clusters std::vector hcalPosV; hcalPosV.clear(); std::vector ecalPosV; ecalPosV.clear(); - for(int i=0;i<(int)myPFCands.size();i++){ - const ElementsInBlocks& elts = myPFCands[i]->elementsInBlocks(); + for(const auto& cand : myPFCands){ + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + const ElementsInBlocks& elts = pfcand->elementsInBlocks(); for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) { const reco::PFBlock& block = *(it->first); unsigned indexOfElementInBlock = it->second; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauEnergyRecoveryPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauEnergyRecoveryPlugin2.cc index 97995f96e0045..c476cdfd05672 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauEnergyRecoveryPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauEnergyRecoveryPlugin2.cc @@ -1,4 +1,4 @@ -/* + /* * ============================================================================= * Filename: RecoTauEnergyRecoveryPlugin2.cc * @@ -63,8 +63,8 @@ void RecoTauEnergyRecoveryPlugin2::operator()(PFTau& tau) const { reco::Candidate::LorentzVector tauAltP4(0.,0.,0.,0.); - std::vector pfJetConstituents = tau.jetRef()->getPFConstituents(); - for ( std::vector::const_iterator pfJetConstituent = pfJetConstituents.begin(); + std::vector pfJetConstituents = tau.jetRef()->getJetConstituents(); + for ( std::vector::const_iterator pfJetConstituent = pfJetConstituents.begin(); pfJetConstituent != pfJetConstituents.end(); ++pfJetConstituent ) { double dR = deltaR((*pfJetConstituent)->p4(), tau.p4()); if ( dR < dRcone_ ) tauAltP4 += (*pfJetConstituent)->p4(); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc index 5c2e65843f56d..ef0d6aeed0684 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc @@ -14,6 +14,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -52,11 +53,31 @@ void RecoTauImpactParameterSignificancePlugin::beginEvent() { builder_= myTransientTrackBuilder.product(); } +namespace +{ + inline const reco::Track* getTrack(const Candidate& cand) + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if (pfCandPtr->trackRef().isNonnull()) + return pfCandPtr->trackRef().get(); + else + return nullptr; + } + + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } +} + void RecoTauImpactParameterSignificancePlugin::operator()(PFTau& tau) const { // Get the transient lead track if (tau.leadPFChargedHadrCand().isNonnull()) { - TrackRef leadTrack = tau.leadPFChargedHadrCand()->trackRef(); - if (leadTrack.isNonnull()) { + const reco::Track* leadTrack = getTrack(*tau.leadPFChargedHadrCand()); + if (leadTrack != nullptr) { const TransientTrack track = builder_->build(leadTrack); GlobalVector direction(tau.jetRef()->px(), tau.jetRef()->py(), tau.jetRef()->pz()); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc b/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc index 3bebb48251ef1..89eaa08f22f6f 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc @@ -10,7 +10,7 @@ class RecoTauDiscriminationBinnedIsolationImpl public: RecoTauDiscriminationBinnedIsolationImpl(const edm::ParameterSet& pset) :RecoTauDiscriminationBinnedIsolation(pset),extractor_(pset) {} - std::vector extractIsoObjects( + std::vector extractIsoObjects( const reco::PFTauRef& tau) const override { return extractor_(tau); } @@ -27,7 +27,7 @@ namespace { class TrackExtractor { public: TrackExtractor(const edm::ParameterSet& pset){}; - std::vector operator()(const reco::PFTauRef& tau) const { + std::vector operator()(const reco::PFTauRef& tau) const { return tau->isolationPFChargedHadrCands(); } }; @@ -35,7 +35,7 @@ class TrackExtractor { class ECALExtractor { public: ECALExtractor(const edm::ParameterSet& pset){}; - std::vector operator()(const reco::PFTauRef& tau) const { + std::vector operator()(const reco::PFTauRef& tau) const { return tau->isolationPFGammaCands(); } }; @@ -44,12 +44,12 @@ class MaskedECALExtractor { public: MaskedECALExtractor(const edm::ParameterSet& pset) :mask_(pset.getParameter("mask")){}; - std::vector operator()(const reco::PFTauRef& tau) const { - std::vector output; + std::vector operator()(const reco::PFTauRef& tau) const { + std::vector output; reco::tau::RecoTauIsolationMasking::IsoMaskResult result = mask_.mask(*tau); output.reserve(result.gammas.size()); - BOOST_FOREACH(const reco::PFCandidatePtr gamma, result.gammas) { + BOOST_FOREACH(const reco::CandidatePtr gamma, result.gammas) { output.push_back(gamma); } return output; @@ -61,7 +61,7 @@ class MaskedECALExtractor { class HCALExtractor { public: HCALExtractor(const edm::ParameterSet& pset){}; - std::vector operator()(const reco::PFTauRef& tau) const { + std::vector operator()(const reco::PFTauRef& tau) const { return tau->isolationPFNeutrHadrCands(); } }; @@ -70,12 +70,12 @@ class MaskedHCALExtractor { public: MaskedHCALExtractor(const edm::ParameterSet& pset) :mask_(pset.getParameter("mask")){}; - std::vector operator()(const reco::PFTauRef& tau) const { - std::vector output; + std::vector operator()(const reco::PFTauRef& tau) const { + std::vector output; reco::tau::RecoTauIsolationMasking::IsoMaskResult result = mask_.mask(*tau); output.reserve(result.h0s.size()); - BOOST_FOREACH(const reco::PFCandidatePtr h0, result.h0s) { + BOOST_FOREACH(const reco::CandidatePtr h0, result.h0s) { output.push_back(h0); } return output; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index 2538281e5d516..10a084e7858da 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -211,7 +211,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // JAN - convert reco::Jet ref to PFJet ref (only in direct interaction with PFTau) // Make sure all taus have their jetref set correctly - std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, jetRef.castTo())); + std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, reco::JetBaseRef(jetRef))); // Copy without selection if ( !outputSelector_.get() ) { output->insert(output->end(), taus.begin(), taus.end()); @@ -231,7 +231,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // jet. if ( !nTausBuilt && buildNullTaus_ ) { reco::PFTau nullTau(std::numeric_limits::quiet_NaN(), jetRef->p4()); - nullTau.setjetRef(jetRef.castTo()); + nullTau.setjetRef(reco::JetBaseRef(jetRef)); output->push_back(nullTau); } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauTauTagInfoWorkaroundModifier.cc b/RecoTauTag/RecoTau/plugins/RecoTauTauTagInfoWorkaroundModifier.cc index 3340ee7af150e..760cb8653bc54 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauTauTagInfoWorkaroundModifier.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauTauTagInfoWorkaroundModifier.cc @@ -43,11 +43,11 @@ void RecoTauTagInfoWorkaroundModifer::beginEvent() { void RecoTauTagInfoWorkaroundModifer::operator()(PFTau& tau) const { // Find the PFTauTagInfo that comes from the same PFJet - PFJetRef tauJetRef = tau.jetRef(); + JetBaseRef tauJetRef = tau.jetRef(); for(size_t iInfo = 0; iInfo < infos_->size(); ++iInfo) { // Get jet ref from tau tag info PFTauTagInfoRef infoRef = PFTauTagInfoRef(infos_, iInfo); - PFJetRef infoJetRef = infoRef->pfjetRef(); + JetBaseRef infoJetRef = infoRef->pfjetRef(); // Check if they come from the same jet if (infoJetRef == tauJetRef) { // This tau "comes" from this PFJetRef diff --git a/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc index b68a38fe44ef5..803b5e7a84961 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc @@ -18,10 +18,10 @@ namespace reco { namespace tau { namespace { // Delete an element from a ptr vector - std::vector deleteFrom(const PFCandidatePtr& ptr, const std::vector& collection) + std::vector deleteFrom(const CandidatePtr& ptr, const std::vector& collection) { - std::vector output; - for ( std::vector::const_iterator cand = collection.begin(); + std::vector output; + for ( std::vector::const_iterator cand = collection.begin(); cand != collection.end(); ++cand ) { if ( (*cand) != ptr) output.push_back(*cand); } @@ -44,7 +44,7 @@ class RecoTauTwoProngFilter : public RecoTauModifierPlugin { void RecoTauTwoProngFilter::operator()(PFTau& tau) const { if (tau.signalPFChargedHadrCands().size() == 2) { - const std::vector& signalCharged = tau.signalPFChargedHadrCands(); + const std::vector& signalCharged = tau.signalPFChargedHadrCands(); size_t indexOfHighestPt = (signalCharged[0]->pt() > signalCharged[1]->pt()) ? 0 : 1; size_t indexOfLowerPt = ( indexOfHighestPt ) ? 0 : 1; @@ -52,18 +52,18 @@ void RecoTauTwoProngFilter::operator()(PFTau& tau) const { signalCharged[indexOfHighestPt]->pt(); if (ratio < minPtFractionForSecondProng_) { - PFCandidatePtr keep = signalCharged[indexOfHighestPt]; - PFCandidatePtr filter = signalCharged[indexOfLowerPt]; + CandidatePtr keep = signalCharged[indexOfHighestPt]; + CandidatePtr filter = signalCharged[indexOfLowerPt]; // Make our new signal charged candidate collection - std::vector newSignalCharged; + std::vector newSignalCharged; newSignalCharged.push_back(keep); - std::vector newSignal = deleteFrom(filter, tau.signalPFCands()); + std::vector newSignal = deleteFrom(filter, tau.signalPFCands()); // Copy our filtered cand to isolation - std::vector newIsolationCharged = + std::vector newIsolationCharged = tau.isolationPFChargedHadrCands(); newIsolationCharged.push_back(filter); - std::vector newIsolation = tau.isolationPFCands(); + std::vector newIsolation = tau.isolationPFCands(); newIsolation.push_back(filter); // Update tau members From 47c179ecc009eee4862a205352f66f6a91ba18c2 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 10:04:37 +0100 Subject: [PATCH 012/686] Adapt rest of plugins and other code in RecoTauTag/RecoTau to changes in PFTau class --- .../RecoTau/interface/HPSPFRecoTauAlgorithm.h | 12 +- .../interface/PFRecoTauClusterVariables.h | 2 +- .../RecoTau/interface/RecoTauBuilderPlugins.h | 8 +- .../interface/RecoTauCommonUtilities.h | 6 +- .../RecoTau/interface/RecoTauConstructor.h | 20 +- .../interface/RecoTauDiscriminantFunctions.h | 2 +- .../RecoTau/interface/RecoTauQualityCuts.h | 6 +- .../interface/RecoTauVertexAssociator.h | 5 +- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 57 +++--- .../PFRecoTauDiscriminationAgainstMuon2.cc | 53 +++--- .../TauDiscriminationAgainstCaloMuon.cc | 7 +- RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc | 158 +++++++++------- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 127 ++++++++----- .../RecoTau/src/HPSPFRecoTauAlgorithm.cc | 162 +++++++++------- RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc | 84 +++++---- .../RecoTau/src/PFRecoTauTagInfoAlgorithm.cc | 6 +- .../src/RecoTauBinnedIsolationPlugin.cc | 8 +- RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 72 +++---- .../src/RecoTauDiscriminantFunctions.cc | 64 +++---- .../RecoTau/src/RecoTauIsolationMasking.cc | 49 ++--- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 178 +++++++++++++----- .../RecoTau/src/RecoTauVertexAssociator.cc | 126 +++++++++---- .../src/pfRecoTauChargedHadronAuxFunctions.cc | 5 +- 23 files changed, 749 insertions(+), 468 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/HPSPFRecoTauAlgorithm.h b/RecoTauTag/RecoTau/interface/HPSPFRecoTauAlgorithm.h index 68a1ecbf050ee..37ff5194b8375 100644 --- a/RecoTauTag/RecoTau/interface/HPSPFRecoTauAlgorithm.h +++ b/RecoTauTag/RecoTau/interface/HPSPFRecoTauAlgorithm.h @@ -42,10 +42,10 @@ class HPSPFRecoTauAlgorithm : public PFRecoTauAlgorithmBase //* Helper Methods *// //Creators of the Decay Modes - void buildOneProng(const reco::PFTauTagInfoRef&,const std::vector& ); - void buildOneProngStrip(const reco::PFTauTagInfoRef&,const std::vector>&,const std::vector&); - void buildOneProngTwoStrips(const reco::PFTauTagInfoRef&,const std::vector>&,const std::vector&); - void buildThreeProngs(const reco::PFTauTagInfoRef&,const std::vector&); + void buildOneProng(const reco::PFTauTagInfoRef&,const std::vector& ); + void buildOneProngStrip(const reco::PFTauTagInfoRef&,const std::vector>&,const std::vector&); + void buildOneProngTwoStrips(const reco::PFTauTagInfoRef&,const std::vector>&,const std::vector&); + void buildThreeProngs(const reco::PFTauTagInfoRef&,const std::vector&); //Narrowness selection bool isNarrowTau(const reco::PFTau&,double); @@ -60,9 +60,9 @@ class HPSPFRecoTauAlgorithm : public PFRecoTauAlgorithmBase void applyElectronRejection(reco::PFTau&,double); //Method to create a candidate from the merged EM Candidates vector; - math::XYZTLorentzVector createMergedLorentzVector(const std::vector&); + math::XYZTLorentzVector createMergedLorentzVector(const std::vector&); - void removeCandidateFromRefVector(const reco::PFCandidatePtr&,std::vector&); + void removeCandidateFromRefVector(const reco::CandidatePtr&,std::vector&); void applyMassConstraint(math::XYZTLorentzVector&,double ); bool refitThreeProng(reco::PFTau&); diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index f9b5ebc0159c9..b85942885c3c5 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -35,7 +35,7 @@ class TauIdMVAAuxiliaries { else { const pat::PackedCandidate* patcand = dynamic_cast(leadingPFCharged.get()); if (patcand != nullptr && patcand->hasTrackDetails()) { - patcand->pseudoTrack().normalizedChi2(); + LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); } } } diff --git a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h index 338217402147f..5c1b0bcaa6396 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h +++ b/RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h @@ -64,7 +64,7 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin vertexAssociator_(pset.getParameter("qualityCuts"),std::move(iC)) { pfCandSrc_ = pset.getParameter("pfCandSrc"); - pfCand_token = iC.consumes(pfCandSrc_); + pfCand_token = iC.consumes >(pfCandSrc_); }; ~RecoTauBuilderPlugin() override {} @@ -79,7 +79,7 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin const std::vector&) const = 0; /// Hack to be able to convert Ptrs to Refs - const edm::Handle& getPFCands() const { return pfCands_; }; + const edm::Handle >& getPFCands() const { return pfCands_; }; /// Get primary vertex associated to this jet reco::VertexRef primaryVertex(const reco::JetBaseRef& jet) const { return vertexAssociator_.associatedVertex(*jet); } @@ -93,9 +93,9 @@ class RecoTauBuilderPlugin : public RecoTauEventHolderPlugin private: edm::InputTag pfCandSrc_; // Handle to PFCandidates needed to build Refs - edm::Handle pfCands_; + edm::Handle > pfCands_; reco::tau::RecoTauVertexAssociator vertexAssociator_; - edm::EDGetTokenT pfCand_token; + edm::EDGetTokenT > pfCand_token; }; /* Class that updates a PFTau's members (i.e. electron variables) */ diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index 71f19836d911f..eefb599c9cda8 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -146,20 +146,20 @@ template template reco::Candidate::LorentzVector sumPFCandP4( InputIterator begin, InputIterator end) { - return sumPFVector(begin, end, &PFCandidate::p4, + return sumPFVector(begin, end, &Candidate::p4, reco::Candidate::LorentzVector()); } /// Sum the pT of a collection of PFCandidates template double sumPFCandPt(InputIterator begin, InputIterator end) { - return sumPFVector(begin, end, &PFCandidate::pt, 0.0); + return sumPFVector(begin, end, &Candidate::pt, 0.0); } /// Sum the charge of a collection of PFCandidates template int sumPFCandCharge(InputIterator begin, InputIterator end) { - return sumPFVector(begin, end, &PFCandidate::charge, 0); + return sumPFVector(begin, end, &Candidate::charge, 0); } template InputIterator leadPFCand(InputIterator begin, diff --git a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h index 6318acbfddfa3..1ee0a3208268a 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h +++ b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h @@ -53,7 +53,7 @@ class RecoTauConstructor { /// Constructor with PFCandidate Handle RecoTauConstructor(const JetBaseRef& jetRef, - const edm::Handle& pfCands, + const edm::Handle >& pfCands, bool copyGammasFromPiZeros = false, const StringObjectFunction* signalConeSize = nullptr, double minAbsPhotonSumPt_insideSignalCone = 2.5, double minRelPhotonSumPt_insideSignalCone = 0., @@ -81,8 +81,8 @@ class RecoTauConstructor { } /// Append a PFCandidateRef/Ptr to a given collection - void addPFCand(Region region, ParticleType type, const PFCandidateRef& ref, bool skipAddToP4 = false); - void addPFCand(Region region, ParticleType type, const PFCandidatePtr& ptr, bool skipAddToP4 = false); + // void addPFCand(Region region, ParticleType type, const CandidateRef& ref, bool skipAddToP4 = false); + void addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4 = false); /// Reserve a set amount of space for a given RefVector void reserve(Region region, ParticleType type, size_t size); @@ -132,8 +132,8 @@ class RecoTauConstructor { private: typedef std::pair CollectionKey; - typedef std::map*> CollectionMap; - typedef boost::shared_ptr > SortedListPtr; + typedef std::map*> CollectionMap; + typedef boost::shared_ptr > SortedListPtr; typedef std::map SortedCollectionMap; bool copyGammas_; @@ -145,18 +145,18 @@ class RecoTauConstructor { double minRelPhotonSumPt_outsideSignalCone_; // Retrieve collection associated to signal/iso and type - std::vector* getCollection(Region region, ParticleType type); + std::vector* getCollection(Region region, ParticleType type); SortedListPtr getSortedCollection(Region region, ParticleType type); // Sort all our collections by PT and copy them into the tau void sortAndCopyIntoTau(); // Helper functions for dealing with refs - PFCandidatePtr convertToPtr(const PFCandidatePtr& pfPtr) const; - PFCandidatePtr convertToPtr(const CandidatePtr& candPtr) const; - PFCandidatePtr convertToPtr(const PFCandidateRef& pfRef) const; + CandidatePtr convertToPtr(const PFCandidatePtr& pfPtr) const; + CandidatePtr convertToPtr(const CandidatePtr& candPtr) const; + // CandidatePtr convertToPtr(const PFCandidateRef& pfRef) const; - const edm::Handle& pfCands_; + const edm::Handle >& pfCands_; std::auto_ptr tau_; CollectionMap collections_; diff --git a/RecoTauTag/RecoTau/interface/RecoTauDiscriminantFunctions.h b/RecoTauTag/RecoTau/interface/RecoTauDiscriminantFunctions.h index b244ea140e593..5910713a81511 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauDiscriminantFunctions.h +++ b/RecoTauTag/RecoTau/interface/RecoTauDiscriminantFunctions.h @@ -26,7 +26,7 @@ typedef std::vector VDouble; /// For three prong events, take the track that has charge opposite to the /// composite charge. -PFCandidatePtr mainTrack(const PFTau& tau); +CandidatePtr mainTrack(const PFTau& tau); // HPStanc variables double JetPt(Tau tau); diff --git a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h index 1583da7dc485e..c733312711552 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h +++ b/RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h @@ -47,7 +47,7 @@ class RecoTauQualityCuts void setPV(const reco::VertexRef& vtx) const { pv_ = vtx; } /// Update the leading track - void setLeadTrack(const reco::TrackRef& leadTrack) const; + void setLeadTrack(const reco::Track& leadTrack) const; void setLeadTrack(const reco::Candidate& leadCand) const; /// Update the leading track (using reference) @@ -91,7 +91,7 @@ class RecoTauQualityCuts } private: - template bool filterTrack_(const T& trackRef) const; + bool filterTrack_(const reco::Track* track) const; bool filterGammaCand(const reco::Candidate& cand) const; bool filterNeutralHadronCand(const reco::Candidate& cand) const; bool filterCandByType(const reco::Candidate& cand) const; @@ -99,7 +99,7 @@ class RecoTauQualityCuts // The current primary vertex mutable reco::VertexRef pv_; // The current lead track references - mutable reco::TrackBaseRef leadTrack_; + mutable const reco::Track* leadTrack_; double minTrackPt_; double maxTrackChi2_; diff --git a/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h b/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h index b9f740e10b6a1..7eec4702f159e 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h +++ b/RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h @@ -65,10 +65,13 @@ class RecoTauVertexAssociator { /// or leaging charged hadron if set (useJet=false). reco::VertexRef associatedVertex(const PFTau& tau, bool useJet=false) const; reco::VertexRef associatedVertex(const TrackBaseRef& track) const; + reco::VertexRef associatedVertex(const Track* track) const; /// Load the vertices from the event. void setEvent(const edm::Event& evt); - reco::TrackBaseRef getLeadTrack(const Jet& jet) const; + const Track* getLeadTrack(const Jet&) const; + const TrackBaseRef getLeadTrackRef(const Jet&) const; + const CandidatePtr getLeadCand(const Jet&) const; private: edm::InputTag vertexTag_; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index cc3760b6f70c8..fee361ac8f432 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -97,11 +97,13 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float tauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTauRef->signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy()); - sumEnergy += (*pfCandidate)->energy(); + for (const auto& cand : thePFTauRef->signalPFCands()) { + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += (pfcand->positionAtECALEntrance().eta()*pfcand->energy()); + sumEnergy += pfcand->energy(); + } + else throw cms::Exception("Type Mismatch") << "FIXME.\n"; } if ( sumEnergy > 0. ) { tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -109,28 +111,30 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float leadChargedPFCandEtaAtEcalEntrance = -99.; float leadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > leadChargedPFCandPt ) { - leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - leadChargedPFCandPt = track->pt(); + for (const auto& cand : thePFTauRef->signalPFCands()) { + const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > leadChargedPFCandPt ) { + leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + leadChargedPFCandPt = track->pt(); + } } - } + } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; } if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) { int numSignalPFGammaCandsInSigCone = 0; - const std::vector& signalPFGammaCands = thePFTauRef->signalPFGammaCands(); + const std::vector& signalPFGammaCands = thePFTauRef->signalPFGammaCands(); - for ( std::vector::const_iterator pfGamma = signalPFGammaCands.begin(); + for ( std::vector::const_iterator pfGamma = signalPFGammaCands.begin(); pfGamma != signalPFGammaCands.end(); ++pfGamma ) { double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); @@ -150,7 +154,12 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); - bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + bool hasGsfTrack = false; + if (lpfch) { + hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); + } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; + if ( !hasGsfTrack ) hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); @@ -187,7 +196,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& if ( !isGsfElectronMatched ) { mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); - bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + bool hasGsfTrack = false; + if (lpfch) { + hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); + } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index 2484150158f30..c1650c2afc4fa 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -174,14 +174,17 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p numHitsRPC[iStation] = 0; } - const reco::PFCandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); + const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); if ( pfLeadChargedHadron.isNonnull() ) { - reco::MuonRef muonRef = pfLeadChargedHadron->muonRef(); - if ( muonRef.isNonnull() ) { - if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ; - countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); - countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); - } + const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); + if (pflch != nullptr) { + reco::MuonRef muonRef = pflch->muonRef(); + if ( muonRef.isNonnull() ) { + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ; + countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); + countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); + } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } if ( srcMuons_.label() != "" ) { @@ -193,9 +196,14 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p if ( verbosity_ ){ edm::LogPrint("PFTauAgainstMuon2") << " fails Pt cut --> skipping it." ;} continue; } - if ( pfLeadChargedHadron.isNonnull() && pfLeadChargedHadron->muonRef().isNonnull() && muon == pfLeadChargedHadron->muonRef() ) { - if ( verbosity_ ){ edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it." ;} - continue; + if ( pfLeadChargedHadron.isNonnull()) { + const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); + if (pflch != nullptr) { + reco::MuonRef muonRef = pflch->muonRef(); + if (muonRef.isNonnull() && muon == pflch->muonRef() ) + if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; } + continue; + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } double dR = deltaR(muon->p4(), pfTau->p4()); double dRmatch = dRmuonMatch_; @@ -248,18 +256,21 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p bool passesCaloMuonVeto = true; if ( pfLeadChargedHadron.isNonnull() ) { - double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy(); - if ( verbosity_ ) { - if ( pfLeadChargedHadron->trackRef().isNonnull() ) { - edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->trackRef()->p() ; - } else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) { - edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->gsfTrackRef()->p() ; + const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); + if (pflch != nullptr) { + double energyECALplusHCAL = pflch->ecalEnergy() + pflch->hcalEnergy(); + if ( verbosity_ ) { + if ( pflch->trackRef().isNonnull() ) { + edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pflch->trackRef()->p() ; + } else if ( pflch->gsfTrackRef().isNonnull() ) { + edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pflch->gsfTrackRef()->p() ; + } } - } - const reco::Track* leadTrack = nullptr; - if ( pfLeadChargedHadron->trackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->trackRef().get(); - else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->gsfTrackRef().get(); - if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false; + const reco::Track* leadTrack = nullptr; + if ( pflch->trackRef().isNonnull() ) leadTrack = pflch->trackRef().get(); + else if ( pflch->gsfTrackRef().isNonnull() ) leadTrack = pflch->gsfTrackRef().get(); + if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false; + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } double discriminatorValue = 0.; diff --git a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc index 9b91afde16e92..91a81cac3dbcf 100644 --- a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc +++ b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc @@ -74,12 +74,15 @@ class TauLeadTrackExtractor public: reco::TrackRef getLeadTrack(const reco::PFTau& tau) const { - return tau.leadPFChargedHadrCand()->trackRef(); + const reco::PFCandidate* pflch = dynamic_cast(tau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + return pflch->trackRef(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } double getTrackPtSum(const reco::PFTau& tau) const { double trackPtSum = 0.; - for ( std::vector::const_iterator signalTrack = tau.signalPFChargedHadrCands().begin(); + for ( std::vector::const_iterator signalTrack = tau.signalPFChargedHadrCands().begin(); signalTrack != tau.signalPFChargedHadrCands().end(); ++signalTrack ) { trackPtSum += (*signalTrack)->pt(); } diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc index 1eb55dfff3869..a52350fea5ad3 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc @@ -701,11 +701,14 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, Float_t TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); + sumEnergy += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -713,20 +716,23 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); + } } - } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } Float_t TauPt = thePFTau.pt(); @@ -734,9 +740,13 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size(); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + if ( pflch->p() > 0. ) { + TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); + TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); } Float_t TauVisMass = thePFTau.mass(); Float_t TauHadrMva = std::max(thePFTau.electronPreIDOutput(), float(-1.0)); @@ -744,7 +754,7 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, std::vector GammasdPhi; std::vector GammasPt; for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); @@ -755,30 +765,33 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, GammasPt.push_back(gamma->pt()); } Float_t TauKFNumHits = -99.; - if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) { - TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits(); + if ( (pflch->trackRef()).isNonnull() ) { + TauKFNumHits = pflch->trackRef()->numberOfValidHits(); } Float_t TauGSFNumHits = -99.; Float_t TauGSFChi2 = -99.; Float_t TauGSFTrackResol = -99.; Float_t TauGSFTracklnPt = -99.; Float_t TauGSFTrackEta = -99.; - if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) { - TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2(); - TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits(); - if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) { - TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt(); - TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*M_LN10; + if ( (pflch->gsfTrackRef()).isNonnull() ) { + TauGSFChi2 = pflch->gsfTrackRef()->normalizedChi2(); + TauGSFNumHits = pflch->gsfTrackRef()->numberOfValidHits(); + if ( pflch->gsfTrackRef()->pt() > 0. ) { + TauGSFTrackResol = pflch->gsfTrackRef()->ptError()/pflch->gsfTrackRef()->pt(); + TauGSFTracklnPt = log(pflch->gsfTrackRef()->pt())*M_LN10; } - TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta(); + TauGSFTrackEta = pflch->gsfTrackRef()->eta(); } Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); - sumEnergyPhi += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); + sumEnergyPhi += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergyPhi > 0. ) { TauPhi = sumPhiTimesEnergy/sumEnergyPhi; @@ -786,7 +799,7 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size(); - Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + Float_t TauHasGsf = pflch->gsfTrackRef().isNonnull(); Float_t ElecEta = theGsfEle.eta(); Float_t ElecPhi = theGsfEle.phi(); @@ -866,11 +879,14 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) Float_t TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); + sumEnergy += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -878,20 +894,23 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); + } } - } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } Float_t TauPt = thePFTau.pt(); @@ -899,9 +918,13 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size(); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + if ( pflch->p() > 0. ) { + TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); + TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); } Float_t TauVisMass = thePFTau.mass(); Float_t TauHadrMva = std::max(thePFTau.electronPreIDOutput(),float(-1.0)); @@ -909,7 +932,7 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) std::vector GammasdPhi; std::vector GammasPt; for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); @@ -920,30 +943,33 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) GammasPt.push_back(gamma->pt()); } Float_t TauKFNumHits = -99.; - if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) { - TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits(); + if ( (pflch->trackRef()).isNonnull() ) { + TauKFNumHits = pflch->trackRef()->numberOfValidHits(); } Float_t TauGSFNumHits = -99.; Float_t TauGSFChi2 = -99.; Float_t TauGSFTrackResol = -99.; Float_t TauGSFTracklnPt = -99.; Float_t TauGSFTrackEta = -99.; - if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) { - TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2(); - TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits(); - if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) { - TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt(); - TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*M_LN10; + if ( (pflch->gsfTrackRef()).isNonnull() ) { + TauGSFChi2 = pflch->gsfTrackRef()->normalizedChi2(); + TauGSFNumHits = pflch->gsfTrackRef()->numberOfValidHits(); + if ( pflch->gsfTrackRef()->pt() > 0. ) { + TauGSFTrackResol = pflch->gsfTrackRef()->ptError()/pflch->gsfTrackRef()->pt(); + TauGSFTracklnPt = log(pflch->gsfTrackRef()->pt())*M_LN10; } - TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta(); + TauGSFTrackEta = pflch->gsfTrackRef()->eta(); } Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); - sumEnergyPhi += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); + sumEnergyPhi += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergyPhi > 0. ) { TauPhi = sumPhiTimesEnergy/sumEnergyPhi; @@ -951,7 +977,7 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) Float_t TaudCrackPhi = dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ; Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance) ; Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size(); - Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + Float_t TauHasGsf = pflch->gsfTrackRef().isNonnull(); Float_t dummyElecEta = 9.9; diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index d44240810966b..1960dca4b682a 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -523,11 +523,14 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); + sumEnergy += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -535,20 +538,23 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); + } } - } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } Float_t TauPt = thePFTau.pt(); @@ -556,8 +562,11 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); + TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } std::vector GammasdEtaInSigCone; @@ -570,7 +579,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -602,7 +611,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::PFCandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); + reco::CandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -621,8 +630,11 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float sumEnergyPhi = 0.; if ( !usePhiAtEcalEntranceExtrapolation ){ for (auto const& pfc : signalPFCands){ - sumPhiTimesEnergy += pfc->positionAtECALEntrance().phi()*pfc->energy(); - sumEnergyPhi += pfc->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfc.get()); + if (pfcand != nullptr) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfc->energy(); + sumEnergyPhi += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } } else{ @@ -641,8 +653,12 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); - Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); - + Float_t TauHasGsf = false; + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + TauHasGsf = pflch->gsfTrackRef().isNonnull(); + } else { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } // === electron variables === Float_t ElecEta = theGsfEle.eta(); @@ -738,11 +754,14 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); + sumEnergy += pfcand->energy(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -750,20 +769,23 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { const reco::Track* track = nullptr; - if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); - else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); - else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); + } } - } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } Float_t TauPt = thePFTau.pt(); @@ -771,8 +793,11 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); + TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); + } else { throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } } std::vector GammasdEtaInSigCone; @@ -785,7 +810,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -817,7 +842,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc } for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::PFCandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); + reco::CandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); @@ -835,10 +860,13 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; if ( !usePhiAtEcalEntranceExtrapolation ){ - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); - sumEnergyPhi += (*pfCandidate)->energy(); + const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); + if (pfcand != nullptr) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); + sumEnergyPhi += pfcand->energy(); + } else { throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } } } else{ @@ -857,7 +885,12 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc } Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); - Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); + Float_t TauHasGsf = false; + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + TauHasGsf = pflch->gsfTrackRef().isNonnull(); + } else { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } // === electron variables === diff --git a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc index 58907c7e00614..47014e7c32c92 100644 --- a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc @@ -26,11 +26,11 @@ HPSPFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& tagInfo,const Vertex& v pfTaus_.clear(); //make the strips globally. - std::vector> strips = candidateMerger_->mergeCandidates(tagInfo->PFCands()); + std::vector> strips = candidateMerger_->mergeCandidates(tagInfo->PFCands()); //Sort the hadrons globally and once! - std::vector hadrons = tagInfo->PFChargedHadrCands(); + std::vector hadrons = tagInfo->PFChargedHadrCands(); if(hadrons.size()>1) TauTagTools::sortRefVectorByPt(hadrons); @@ -60,15 +60,21 @@ HPSPFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& tagInfo,const Vertex& v pfTau = getBestTauCandidate(pfTaus_); //Set the IP for the leading track - if(TransientTrackBuilder_!=nullptr &&pfTau.leadPFChargedHadrCand()->trackRef().isNonnull()) { - const TransientTrack leadTrack=TransientTrackBuilder_->build(pfTau.leadPFChargedHadrCand()->trackRef()); - if(pfTau.pfTauTagInfoRef().isNonnull()) - if(pfTau.pfTauTagInfoRef()->pfjetRef().isNonnull()) { - PFJetRef jet = pfTau.pfTauTagInfoRef()->pfjetRef(); - GlobalVector jetDir(jet->px(),jet->py(),jet->pz()); - if(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).first) - pfTau.setleadPFChargedHadrCandsignedSipt(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).second.significance()); + if(TransientTrackBuilder_!=nullptr) { + const reco::PFCandidate* pflch = dynamic_cast(pfTau.leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + if (pflch->trackRef().isNonnull()) { + const TransientTrack leadTrack=TransientTrackBuilder_->build(pflch->trackRef()); + if(pfTau.pfTauTagInfoRef().isNonnull()) { + if(pfTau.pfTauTagInfoRef()->pfjetRef().isNonnull()) { + JetBaseRef jet = pfTau.pfTauTagInfoRef()->pfjetRef(); + GlobalVector jetDir(jet->px(),jet->py(),jet->pz()); + if(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).first) + pfTau.setleadPFChargedHadrCandsignedSipt(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).second.significance()); + } + } } + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } } else { //null PFTau @@ -85,13 +91,13 @@ HPSPFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& tagInfo,const Vertex& v //Create one prong tau void -HPSPFRecoTauAlgorithm::buildOneProng(const reco::PFTauTagInfoRef& tagInfo,const std::vector& hadrons) +HPSPFRecoTauAlgorithm::buildOneProng(const reco::PFTauTagInfoRef& tagInfo,const std::vector& hadrons) { PFTauCollection taus; if(!hadrons.empty()) for(unsigned int h=0;h signal; + std::vector signal; signal.push_back(hadron); //Set The signal candidates of the PF Tau @@ -135,7 +141,7 @@ HPSPFRecoTauAlgorithm::buildOneProng(const reco::PFTauTagInfoRef& tagInfo,const //Build one Prong + Strip void -HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,const std::vector >& strips,const std::vector & hadrons) +HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,const std::vector >& strips,const std::vector & hadrons) { //Create output Collection @@ -147,12 +153,12 @@ HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,c //make taus like this only if there is at least one hadron+ 1 strip if(!hadrons.empty()&&!strips.empty()){ //Combinatorics between strips and clusters - for(std::vector>::const_iterator candVector=strips.begin();candVector!=strips.end();++candVector) - for(std::vector::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) { + for(std::vector>::const_iterator candVector=strips.begin();candVector!=strips.end();++candVector) + for(std::vector::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) { //First Cross cleaning ! If you asked to clusterize the candidates //with tracks too then you should not double count the track - std::vector emConstituents = *candVector; + std::vector emConstituents = *candVector; removeCandidateFromRefVector(*hadron,emConstituents); //Create a LorentzVector for the strip @@ -174,9 +180,9 @@ HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,c tau.setpfTauTagInfoRef(tagInfo); //Create the signal vectors - std::vector signal; - std::vector signalH; - std::vector signalG; + std::vector signal; + std::vector signalH; + std::vector signalG; //Store the hadron in the PFTau signalH.push_back(*hadron); @@ -192,7 +198,7 @@ HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,c ROOT::Math::VectorUtil::DeltaR(tau.p4(),strip)); if(!emConstituents.empty()) - for(std::vector::const_iterator j=emConstituents.begin();j!=emConstituents.end();++j) { + for(std::vector::const_iterator j=emConstituents.begin();j!=emConstituents.end();++j) { signal.push_back(*j); signalG.push_back(*j); } @@ -231,7 +237,7 @@ HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,c } void -HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagInfo,const std::vector >& strips,const std::vector& hadrons) +HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagInfo,const std::vector >& strips,const std::vector& hadrons) { @@ -242,13 +248,13 @@ HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagIn //Combinatorics between strips and clusters for(unsigned int Nstrip1=0;Nstrip1::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) { + for(std::vector::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) { //Create the strips and the vectors .Again cross clean the track if associated - std::vector emConstituents1 = strips[Nstrip1]; - std::vector emConstituents2 = strips[Nstrip2]; + std::vector emConstituents1 = strips[Nstrip1]; + std::vector emConstituents2 = strips[Nstrip2]; removeCandidateFromRefVector(*hadron,emConstituents1); removeCandidateFromRefVector(*hadron,emConstituents2); @@ -278,9 +284,9 @@ HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagIn //Create the signal vectors - std::vector signal; - std::vector signalH; - std::vector signalG; + std::vector signal; + std::vector signalH; + std::vector signalG; //Store the hadron in the PFTau signalH.push_back(*hadron); @@ -300,12 +306,12 @@ HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagIn } - for(std::vector::const_iterator j=emConstituents1.begin();j!=emConstituents1.end();++j) { + for(std::vector::const_iterator j=emConstituents1.begin();j!=emConstituents1.end();++j) { signal.push_back(*j); signalG.push_back(*j); } - for(std::vector::const_iterator j=emConstituents2.begin();j!=emConstituents2.end();++j) { + for(std::vector::const_iterator j=emConstituents2.begin();j!=emConstituents2.end();++j) { signal.push_back(*j); signalG.push_back(*j); } @@ -351,7 +357,7 @@ HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagIn void -HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,const std::vector& hadrons) +HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,const std::vector& hadrons) { PFTauCollection taus; //get Hadrons @@ -363,9 +369,16 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con for(unsigned int b=a+1;b(c_h1.get()); + const reco::PFCandidate* h2 = dynamic_cast(c_h2.get()); + const reco::PFCandidate* h3 = dynamic_cast(c_h3.get()); + if (h1 == nullptr || h2 == nullptr || h3 == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } //check charge Compatibility and lead track int charge=h1->charge()+h2->charge()+h3->charge(); @@ -381,10 +394,10 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con if(tau.pt()>tauThreshold_)//Threshold if(ROOT::Math::VectorUtil::DeltaR(tau.p4(),tagInfo->pfjetRef()->p4()) signal; - signal.push_back(h1); - signal.push_back(h2); - signal.push_back(h3); + std::vector signal; + signal.push_back(h1->masterClone().castTo >()); + signal.push_back(h2->masterClone().castTo >()); + signal.push_back(h3->masterClone().castTo >()); //calculate the tau cone by getting the maximum distance double tauCone = 10000.0; if(coneMetric_=="DR") @@ -403,8 +416,8 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con //Set The PFTau tau.setsignalPFChargedHadrCands(signal); tau.setsignalPFCands(signal); - tau.setleadPFChargedHadrCand(h1); - tau.setleadPFCand(h1); + tau.setleadPFChargedHadrCand(h1->masterClone().castTo >()); + tau.setleadPFCand(h1->masterClone().castTo >()); if(isNarrowTau(tau,tauCone)) { //calculate the isolation Deposits @@ -457,31 +470,31 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, if(tau.pfTauTagInfoRef().isNull()) return; - std::vector hadrons; - std::vector gammas; - std::vector neutral; + std::vector hadrons; + std::vector gammas; + std::vector neutral; //Remove candidates outside the cones if(useIsolationAnnulus_) { - const std::vector& pfChargedHadrCands = tau.pfTauTagInfoRef()->PFChargedHadrCands(); + const std::vector& pfChargedHadrCands = tau.pfTauTagInfoRef()->PFChargedHadrCands(); double tauEta=tau.eta(); double tauPhi=tau.phi(); - for ( std::vector::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin(); + for ( std::vector::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin(); pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi()); if ( dR > tauCone && dR < chargeIsolationCone_ ) hadrons.push_back(*pfChargedHadrCand); } - const std::vector& pfGammaCands = tau.pfTauTagInfoRef()->PFGammaCands(); - for ( std::vector::const_iterator pfGammaCand = pfGammaCands.begin(); + const std::vector& pfGammaCands = tau.pfTauTagInfoRef()->PFGammaCands(); + for ( std::vector::const_iterator pfGammaCand = pfGammaCands.begin(); pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi()); if ( dR > tauCone && dR < gammaIsolationCone_ ) gammas.push_back(*pfGammaCand); } - const std::vector& pfNeutralHadrCands = tau.pfTauTagInfoRef()->PFNeutrHadrCands(); - for ( std::vector::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin(); + const std::vector& pfNeutralHadrCands = tau.pfTauTagInfoRef()->PFNeutrHadrCands(); + for ( std::vector::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin(); pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi()); if ( dR > tauCone && dR < neutrHadrIsolationCone_ ) hadrons.push_back(*pfNeutralHadrCand); @@ -489,22 +502,22 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, } else { double tauEta=tau.eta(); double tauPhi=tau.phi(); - const std::vector& pfChargedHadrCands = tau.pfTauTagInfoRef()->PFChargedHadrCands(); - for ( std::vector::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin(); + const std::vector& pfChargedHadrCands = tau.pfTauTagInfoRef()->PFChargedHadrCands(); + for ( std::vector::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin(); pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi()); if ( dR < chargeIsolationCone_ ) hadrons.push_back(*pfChargedHadrCand); } - const std::vector& pfGammaCands = tau.pfTauTagInfoRef()->PFGammaCands(); - for ( std::vector::const_iterator pfGammaCand = pfGammaCands.begin(); + const std::vector& pfGammaCands = tau.pfTauTagInfoRef()->PFGammaCands(); + for ( std::vector::const_iterator pfGammaCand = pfGammaCands.begin(); pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi()); if ( dR < gammaIsolationCone_ ) gammas.push_back(*pfGammaCand); } - const std::vector& pfNeutralHadrCands = tau.pfTauTagInfoRef()->PFNeutrHadrCands(); - for ( std::vector::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin(); + const std::vector& pfNeutralHadrCands = tau.pfTauTagInfoRef()->PFNeutrHadrCands(); + for ( std::vector::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin(); pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) { double dR = reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi()); if ( dR < neutrHadrIsolationCone_ ) hadrons.push_back(*pfNeutralHadrCand); @@ -512,12 +525,12 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, } //remove the signal Constituents from the collections - for(std::vector::const_iterator i=tau.signalPFChargedHadrCands().begin();i!=tau.signalPFChargedHadrCands().end();++i) + for(std::vector::const_iterator i=tau.signalPFChargedHadrCands().begin();i!=tau.signalPFChargedHadrCands().end();++i) { removeCandidateFromRefVector(*i,hadrons); } - for(std::vector::const_iterator i=tau.signalPFGammaCands().begin();i!=tau.signalPFGammaCands().end();++i) + for(std::vector::const_iterator i=tau.signalPFGammaCands().begin();i!=tau.signalPFGammaCands().end();++i) { removeCandidateFromRefVector(*i,gammas); removeCandidateFromRefVector(*i,hadrons);//special case where we included a hadron if the strip! @@ -542,7 +555,7 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, tau.setisolationPFNeutrHadrCands(neutral); tau.setisolationPFGammaCands(gammas); - std::vector isoAll = hadrons; + std::vector isoAll = hadrons; for(unsigned int i=0;imuonRef(); + const reco::PFCandidate* leadCharged = dynamic_cast(tau.leadPFChargedHadrCand().get()); + if (leadCharged == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + MuonRef mu =leadCharged->muonRef(); if(mu.isNonnull()){ segComp=(float)(mu->matches().size()); if(mu->caloCompatibility()>caloComp) @@ -593,7 +610,11 @@ HPSPFRecoTauAlgorithm::applyElectronRejection(reco::PFTau& tau,double stripEnerg if(tau.leadPFChargedHadrCand().isNonnull()) { - PFCandidatePtr leadCharged = tau.leadPFChargedHadrCand(); + const reco::PFCandidate* leadCharged = dynamic_cast(tau.leadPFChargedHadrCand().get()); + if (leadCharged == nullptr) { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } + math::XYZVector caloDir(leadCharged->positionAtECALEntrance().x(), leadCharged->positionAtECALEntrance().y(), leadCharged->positionAtECALEntrance().z()); @@ -679,7 +700,7 @@ HPSPFRecoTauAlgorithm::configure(const edm::ParameterSet& p) math::XYZTLorentzVector -HPSPFRecoTauAlgorithm::createMergedLorentzVector(const std::vector& cands) +HPSPFRecoTauAlgorithm::createMergedLorentzVector(const std::vector& cands) { math::XYZTLorentzVector sum; for(unsigned int i=0;i& vec) +HPSPFRecoTauAlgorithm::removeCandidateFromRefVector(const reco::CandidatePtr& cand,std::vector& vec) { - std::vector newVec; + std::vector newVec; - std::vector::iterator it; + std::vector::iterator it; it = std::find(vec.begin(),vec.end(),cand); if(it!=vec.end()) vec.erase(it); @@ -714,11 +735,14 @@ HPSPFRecoTauAlgorithm::refitThreeProng(reco::PFTau& tau) { bool response=false; //Get Hadrons - std::vector hadrons = tau.signalPFChargedHadrCands(); - PFCandidatePtr h1 = hadrons[0]; - PFCandidatePtr h2 = hadrons[1]; - PFCandidatePtr h3 = hadrons[2]; - + std::vector hadrons = tau.signalPFChargedHadrCands(); + const reco::PFCandidate* h1 = dynamic_cast(hadrons[0].get()); + const reco::PFCandidate* h2 = dynamic_cast(hadrons[1].get()); + const reco::PFCandidate* h3 = dynamic_cast(hadrons[2].get()); + + if (h1 == nullptr || h2 == nullptr || h3 == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + //Make transient tracks std::vector transientTracks; transientTracks.push_back(TransientTrackBuilder_->build(h1->trackRef())); diff --git a/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc b/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc index 4921bab02081c..11df4d64fe024 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc @@ -94,21 +94,21 @@ PFRecoTauAlgorithm::PFRecoTauAlgorithm(const edm::ParameterSet& iConfig):PFRecoT PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, const Vertex& myPV) { - PFJetRef myPFJet=(*myPFTauTagInfoRef).pfjetRef(); // catch a ref to the initial PFJet + JetBaseRef myPFJet=(*myPFTauTagInfoRef).pfjetRef(); // catch a ref to the initial PFJet PFTau myPFTau(std::numeric_limits::quiet_NaN(),myPFJet->p4()); // create the PFTau myPFTau.setpfTauTagInfoRef(myPFTauTagInfoRef); - std::vector myPFCands=(*myPFTauTagInfoRef).PFCands(); + std::vector myPFCands=(*myPFTauTagInfoRef).PFCands(); PFTauElementsOperators myPFTauElementsOperators(myPFTau); double myMatchingConeSize=myPFTauElementsOperators.computeConeSize(myMatchingConeSizeTFormula,MatchingConeSize_min_,MatchingConeSize_max_); - PFCandidatePtr myleadPFChargedCand=myPFTauElementsOperators.leadPFChargedHadrCand(MatchingConeMetric_,myMatchingConeSize,PFTauAlgo_PFCand_minPt_); + CandidatePtr myleadPFChargedCand=myPFTauElementsOperators.leadPFChargedHadrCand(MatchingConeMetric_,myMatchingConeSize,PFTauAlgo_PFCand_minPt_); // These two quantities always taken from the signal cone - PFCandidatePtr myleadPFNeutralCand; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFNeutralCand; + CandidatePtr myleadPFCand; bool myleadPFCand_rectkavailable = false; double myleadPFCand_rectkDZ = 0.; @@ -116,7 +116,10 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // Determine the SIPT of the lead track if(myleadPFChargedCand.isNonnull()) { myPFTau.setleadPFChargedHadrCand(myleadPFChargedCand); - TrackRef myleadPFCand_rectk=(*myleadPFChargedCand).trackRef(); + const reco::PFCandidate* pflch = dynamic_cast(myleadPFChargedCand.get()); + if (pflch == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + TrackRef myleadPFCand_rectk=pflch->trackRef(); if(myleadPFCand_rectk.isNonnull()) { myleadPFCand_rectkavailable=true; myleadPFCand_rectkDZ=(*myleadPFCand_rectk).dz(myPV.position()); @@ -137,12 +140,12 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // Compute energy of the PFTau considering only inner constituents // (inner == pfcandidates inside a cone which is equal to the maximum value of the signal cone) // The axis is built about the lead charged hadron - std::vector myTmpPFCandsInSignalCone = + std::vector myTmpPFCandsInSignalCone = myPFTauElementsOperators.PFCandsInCone(tauAxis,TrackerSignalConeMetric_,TrackerSignalConeSize_max_,0.5); math::XYZTLorentzVector tmpLorentzVect(0.,0.,0.,0.); double jetOpeningAngle = 0.0; - for (std::vector::const_iterator iCand = myTmpPFCandsInSignalCone.begin(); + for (std::vector::const_iterator iCand = myTmpPFCandsInSignalCone.begin(); iCand != myTmpPFCandsInSignalCone.end(); iCand++) { //find the maximum opening angle of the jet (now a parameter in available TFormulas) @@ -173,7 +176,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c myHCALIsolConeSizeTFormula, HCALIsolConeSize_min_, HCALIsolConeSize_max_, transverseEnergy, energy, jetOpeningAngle); // Signal cone collections - std::vector mySignalPFChargedHadrCands, mySignalPFNeutrHadrCands, mySignalPFGammaCands, mySignalPFCands; + std::vector mySignalPFChargedHadrCands, mySignalPFNeutrHadrCands, mySignalPFGammaCands, mySignalPFCands; if (UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_ && myleadPFCand_rectkavailable) { mySignalPFChargedHadrCands=myPFTauElementsOperators.PFChargedHadrCandsInCone(tauAxis, @@ -240,7 +243,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c } // Declare isolation collections - std::vector myUnfilteredIsolPFChargedHadrCands, myIsolPFNeutrHadrCands, myIsolPFGammaCands, myIsolPFCands; + std::vector myUnfilteredIsolPFChargedHadrCands, myIsolPFNeutrHadrCands, myIsolPFGammaCands, myIsolPFCands; // Build unfiltered isolation collection if(UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_ && myleadPFCand_rectkavailable) { @@ -255,7 +258,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // Filter isolation annulus charge dhadrons with additional nHits quality cut // (note that other cuts [pt, chi2, are already cut on]) - std::vector myIsolPFChargedHadrCands; + std::vector myIsolPFChargedHadrCands; myIsolPFChargedHadrCands = TauTagTools::filteredPFChargedHadrCandsByNumTrkHits( myUnfilteredIsolPFChargedHadrCands, ChargedHadrCand_IsolAnnulus_minNhits_); @@ -282,13 +285,13 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c else rPhi = Rphi_; - std::pair,std::vector> elementsInOutEllipse = + std::pair,std::vector> elementsInOutEllipse = myPFTauElementsOperators.PFGammaCandsInOutEllipse(myIsolPFGammaCands, *myleadPFCand, rPhi, myECALSignalConeSize, MaxEtInEllipse_); - std::vector elementsInEllipse = elementsInOutEllipse.first; - std::vector elementsOutEllipse = elementsInOutEllipse.second; + std::vector elementsInEllipse = elementsInOutEllipse.first; + std::vector elementsOutEllipse = elementsInOutEllipse.second; //add the inside elements to signal PFCandidates and reset signal PFCands - for(std::vector::const_iterator inEllipseIt = elementsInEllipse.begin(); inEllipseIt != elementsInEllipse.end(); inEllipseIt++){ + for(std::vector::const_iterator inEllipseIt = elementsInEllipse.begin(); inEllipseIt != elementsInEllipse.end(); inEllipseIt++){ mySignalPFCands.push_back(*inEllipseIt); mySignalPFGammaCands.push_back(*inEllipseIt); } @@ -322,12 +325,12 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c //Making the alternateLorentzVector, i.e. direction with only signal components math::XYZTLorentzVector alternatLorentzVect(0.,0.,0.,0.); - for (std::vector::const_iterator iGammaCand = mySignalPFGammaCands.begin(); + for (std::vector::const_iterator iGammaCand = mySignalPFGammaCands.begin(); iGammaCand != mySignalPFGammaCands.end(); iGammaCand++) { alternatLorentzVect+=(**iGammaCand).p4(); } - for (std::vector::const_iterator iChargedHadrCand = mySignalPFChargedHadrCands.begin(); + for (std::vector::const_iterator iChargedHadrCand = mySignalPFChargedHadrCands.begin(); iChargedHadrCand != mySignalPFChargedHadrCands.end(); iChargedHadrCand++) { alternatLorentzVect+=(**iChargedHadrCand).p4(); } @@ -336,7 +339,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // Optionally add the neutral hadrons to the p4 if (putNeutralHadronsInP4_) { - for (std::vector::const_iterator iNeutralHadrCand = mySignalPFNeutrHadrCands.begin(); + for (std::vector::const_iterator iNeutralHadrCand = mySignalPFNeutrHadrCands.begin(); iNeutralHadrCand != mySignalPFNeutrHadrCands.end(); iNeutralHadrCand++) { alternatLorentzVect+=(**iNeutralHadrCand).p4(); } @@ -348,9 +351,9 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c } // set the leading, signal cone and isolation annulus Tracks (the initial list of Tracks was catched through a JetTracksAssociation - // object, not through the charged hadr. PFCandidates inside the PFJet ; + // object, not through the charged hadr. Candidates inside the PFJet ; // the motivation for considering these objects is the need for checking that a selection by the - // charged hadr. PFCandidates is equivalent to a selection by the rec. Tracks.) + // charged hadr. Candidates is equivalent to a selection by the rec. Tracks.) TrackRef myleadTk=myPFTauElementsOperators.leadTk(MatchingConeMetric_,myMatchingConeSize,LeadTrack_minPt_); myPFTau.setleadTrack(myleadTk); if(myleadTk.isNonnull()){ @@ -391,42 +394,48 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c //Use the electron rejection only in case there is a charged leading pion if(myleadPFChargedCand.isNonnull()){ - myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi(); + const reco::PFCandidate* pflch = dynamic_cast(myleadPFChargedCand.get()); + if (pflch == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + myElectronPreIDOutput = pflch->mva_e_pi(); - math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance(); - myElecTrk = myleadPFChargedCand->trackRef();//Electron candidate + math::XYZPointF myElecTrkEcalPos = pflch->positionAtECALEntrance(); + myElecTrk = pflch->trackRef();//Electron candidate if(myElecTrk.isNonnull()) { //FROM AOD if(DataType_ == "AOD"){ // Corrected Cluster energies for(int i=0;i<(int)myPFCands.size();i++){ - myHCALenergy += myPFCands[i]->hcalEnergy(); - myECALenergy += myPFCands[i]->ecalEnergy(); + const reco::PFCandidate* myPFCand = dynamic_cast(myPFCands[i].get()); + if (myPFCand == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + myHCALenergy += myPFCand->hcalEnergy(); + myECALenergy += myPFCand->ecalEnergy(); math::XYZPointF candPos; - if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2)//if charged hadron or electron - candPos = myPFCands[i]->positionAtECALEntrance(); + if (myPFCand->particleId()==1 || myPFCand->particleId()==2)//if charged hadron or electron + candPos = myPFCand->positionAtECALEntrance(); else - candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz()); + candPos = math::XYZPointF(myPFCand->px(),myPFCand->py(),myPFCand->pz()); double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,candPos); double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos); double deltaEta = std::abs(myElecTrkEcalPos.eta()-candPos.eta()); double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge(); - if (myPFCands[i]->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && + if (myPFCand->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) { - myStripClusterE += myPFCands[i]->ecalEnergy(); + myStripClusterE += myPFCand->ecalEnergy(); } if (deltaR<0.184) { - myHCALenergy3x3 += myPFCands[i]->hcalEnergy(); + myHCALenergy3x3 += myPFCand->hcalEnergy(); } - if (myPFCands[i]->hcalEnergy()>myMaximumHCALPFClusterE) { - myMaximumHCALPFClusterE = myPFCands[i]->hcalEnergy(); + if (myPFCand->hcalEnergy()>myMaximumHCALPFClusterE) { + myMaximumHCALPFClusterE = myPFCand->hcalEnergy(); } - if ((myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { - myMaximumHCALPFClusterEt = (myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta()))); + if ((myPFCand->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { + myMaximumHCALPFClusterEt = (myPFCand->hcalEnergy()*fabs(sin(candPos.Theta()))); } } @@ -435,7 +444,10 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c std::vector hcalPosV; hcalPosV.clear(); std::vector ecalPosV; ecalPosV.clear(); for(int i=0;i<(int)myPFCands.size();i++){ - const ElementsInBlocks& elts = myPFCands[i]->elementsInBlocks(); + const reco::PFCandidate* myPFCand = dynamic_cast(myPFCands[i].get()); + if (myPFCand == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + const ElementsInBlocks& elts = myPFCand->elementsInBlocks(); for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) { const reco::PFBlock& block = *(it->first); unsigned indexOfElementInBlock = it->second; diff --git a/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc b/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc index 3a93f26a67707..c38649b18bcd2 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauTagInfoAlgorithm.cc @@ -26,11 +26,11 @@ PFRecoTauTagInfoAlgorithm::PFRecoTauTagInfoAlgorithm(const edm::ParameterSet& pa tkPVmaxDZ_ = parameters.getParameter("tkPVmaxDZ"); } -PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const PFJetRef& thePFJet,const std::vector& thePFCandsInEvent, const TrackRefVector& theTracks,const Vertex& thePV) const { +PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const JetBaseRef& thePFJet,const std::vector& thePFCandsInEvent, const TrackRefVector& theTracks,const Vertex& thePV) const { PFTauTagInfo resultExtended; resultExtended.setpfjetRef(thePFJet); - std::vector thePFCands; + std::vector thePFCands; const float jetPhi = (*thePFJet).phi(); const float jetEta = (*thePFJet).eta(); auto dr2 = [jetPhi,jetEta](float phi, float eta) { return reco::deltaR2(jetEta,jetPhi,eta,phi);}; @@ -40,7 +40,7 @@ PFTauTagInfo PFRecoTauTagInfoAlgorithm::buildPFTauTagInfo(const PFJetRef& thePFJ } bool pvIsFake = (thePV.z() < -500.); - std::vector theFilteredPFChargedHadrCands; + std::vector theFilteredPFChargedHadrCands; if (UsePVconstraint_ && !pvIsFake) theFilteredPFChargedHadrCands=TauTagTools::filteredPFChargedHadrCands(thePFCands,ChargedHadrCand_tkminPt_,ChargedHadrCand_tkminPixelHitsn_,ChargedHadrCand_tkminTrackerHitsn_,ChargedHadrCand_tkmaxipt_,ChargedHadrCand_tkmaxChi2_,ChargedHadrCand_tkPVmaxDZ_, thePV, thePV.z()); else theFilteredPFChargedHadrCands=TauTagTools::filteredPFChargedHadrCands(thePFCands,ChargedHadrCand_tkminPt_,ChargedHadrCand_tkminPixelHitsn_,ChargedHadrCand_tkminTrackerHitsn_,ChargedHadrCand_tkmaxipt_,ChargedHadrCand_tkmaxChi2_, thePV); resultExtended.setPFChargedHadrCands(theFilteredPFChargedHadrCands); diff --git a/RecoTauTag/RecoTau/src/RecoTauBinnedIsolationPlugin.cc b/RecoTauTag/RecoTau/src/RecoTauBinnedIsolationPlugin.cc index 696d257e079ed..75462a552a3c5 100644 --- a/RecoTauTag/RecoTau/src/RecoTauBinnedIsolationPlugin.cc +++ b/RecoTauTag/RecoTau/src/RecoTauBinnedIsolationPlugin.cc @@ -1,7 +1,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauBinnedIsolationPlugin.h" #include -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -73,9 +73,9 @@ std::vector RecoTauDiscriminationBinnedIsolation::operator()( // Create our output spectrum std::vector output(bins->size(), 0.0); // Get the desired isolation objects - std::vector isoObjects = extractIsoObjects(tau); + std::vector isoObjects = extractIsoObjects(tau); // Loop over each and histogram their pt - BOOST_FOREACH(const reco::PFCandidatePtr& cand, isoObjects) { + BOOST_FOREACH(const reco::CandidatePtr& cand, isoObjects) { int highestBinLessThan = -1; for (size_t ibin = 0; ibin < bins->size(); ++ibin) { if (cand->pt() > bins->at(ibin)) { diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index cbe2733c760c8..3906f94a5da79 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -12,7 +12,7 @@ namespace reco { namespace tau { -RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle& pfCands, +RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle >& pfCands, bool copyGammasFromPiZeros, const StringObjectFunction* signalConeSize, double minAbsPhotonSumPt_insideSignalCone, double minRelPhotonSumPt_insideSignalCone, @@ -55,25 +55,25 @@ RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle< new SortedListPtr::element_type); } - tau_->setjetRef(jet.castTo()); + tau_->setjetRef(jet); } -void RecoTauConstructor::addPFCand(Region region, ParticleType type, const PFCandidateRef& ref, bool skipAddToP4) { - LogDebug("TauConstructorAddPFCand") << " region = " << region << ", type = " << type << ": Pt = " << ref->pt() << ", eta = " << ref->eta() << ", phi = " << ref->phi(); - if ( region == kSignal ) { - // Keep track of the four vector of the signal vector products added so far. - // If a photon add it if we are not using PiZeros to build the gammas - if ( ((type != kGamma) || !copyGammas_) && !skipAddToP4 ) { - LogDebug("TauConstructorAddPFCand") << "--> adding PFCand to tauP4." ; - p4_ += ref->p4(); - } - } - getSortedCollection(region, type)->push_back(edm::refToPtr(ref)); - // Add to global collection - getSortedCollection(region, kAll)->push_back(edm::refToPtr(ref)); -} - -void RecoTauConstructor::addPFCand(Region region, ParticleType type, const PFCandidatePtr& ptr, bool skipAddToP4) { +// void RecoTauConstructor::addPFCand(Region region, ParticleType type, const CandidateRef& ref, bool skipAddToP4) { +// LogDebug("TauConstructorAddPFCand") << " region = " << region << ", type = " << type << ": Pt = " << ref->pt() << ", eta = " << ref->eta() << ", phi = " << ref->phi(); +// if ( region == kSignal ) { +// // Keep track of the four vector of the signal vector products added so far. +// // If a photon add it if we are not using PiZeros to build the gammas +// if ( ((type != kGamma) || !copyGammas_) && !skipAddToP4 ) { +// LogDebug("TauConstructorAddPFCand") << "--> adding PFCand to tauP4." ; +// p4_ += ref->p4(); +// } +// } +// getSortedCollection(region, type)->push_back(edm::refToPtr(ref)); +// // Add to global collection +// getSortedCollection(region, kAll)->push_back(edm::refToPtr(ref)); +// } + +void RecoTauConstructor::addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4) { LogDebug("TauConstructorAddPFCand") << " region = " << region << ", type = " << type << ": Pt = " << ptr->pt() << ", eta = " << ptr->eta() << ", phi = " << ptr->phi(); if ( region == kSignal ) { // Keep track of the four vector of the signal vector products added so far. @@ -111,10 +111,10 @@ void RecoTauConstructor::reserveTauChargedHadron(Region region, size_t size) namespace { - void checkOverlap(const CandidatePtr& neutral, const std::vector& pfGammas, bool& isUnique) + void checkOverlap(const CandidatePtr& neutral, const std::vector& pfGammas, bool& isUnique) { LogDebug("TauConstructorCheckOverlap") << " pfGammas: #entries = " << pfGammas.size(); - for ( std::vector::const_iterator pfGamma = pfGammas.begin(); + for ( std::vector::const_iterator pfGamma = pfGammas.begin(); pfGamma != pfGammas.end(); ++pfGamma ) { LogDebug("TauConstructorCheckOverlap") << "pfGamma = " << pfGamma->id() << ":" << pfGamma->key(); // JAN - FIXME - double-check that id() equality is fine! @@ -225,7 +225,7 @@ void RecoTauConstructor::addPiZero(Region region, const RecoTauPiZero& piZero) } } -std::vector* +std::vector* RecoTauConstructor::getCollection(Region region, ParticleType type) { return collections_[std::make_pair(region, type)]; } @@ -236,8 +236,8 @@ RecoTauConstructor::getSortedCollection(Region region, ParticleType type) { } // Trivial converter needed for polymorphism -PFCandidatePtr RecoTauConstructor::convertToPtr( - const PFCandidatePtr& pfPtr) const { +CandidatePtr RecoTauConstructor::convertToPtr( + const CandidatePtr& pfPtr) const { return pfPtr; } @@ -254,20 +254,20 @@ void checkMatchedProductIds(const T1& t1, const T2& t2) { } } -PFCandidatePtr RecoTauConstructor::convertToPtr( - const PFCandidateRef& pfRef) const { - if(pfRef.isNonnull()) { - checkMatchedProductIds(pfRef, pfCands_); - return PFCandidatePtr(pfCands_, pfRef.key()); - } else return PFCandidatePtr(); -} +// PFCandidatePtr RecoTauConstructor::convertToPtr( +// const PFCandidateRef& pfRef) const { +// if(pfRef.isNonnull()) { +// checkMatchedProductIds(pfRef, pfCands_); +// return PFCandidatePtr(pfCands_, pfRef.key()); +// } else return PFCandidatePtr(); +// } // Convert from a CandidateRef to a Ptr -PFCandidatePtr RecoTauConstructor::convertToPtr( - const CandidatePtr& candPtr) const { +CandidatePtr RecoTauConstructor::convertToPtr( + const PFCandidatePtr& candPtr) const { if(candPtr.isNonnull()) { checkMatchedProductIds(candPtr, pfCands_); - return PFCandidatePtr(pfCands_, candPtr.key()); + return CandidatePtr(pfCands_, candPtr.key()); } else return PFCandidatePtr(); } @@ -301,9 +301,9 @@ void RecoTauConstructor::sortAndCopyIntoTau() { SortedListPtr sortedCollection = sortedCollections_[colkey.first]; std::sort(sortedCollection->begin(), sortedCollection->end(), - ptDescendingPtr); + ptDescendingPtr); // Copy into the real tau collection - for ( std::vector::const_iterator particle = sortedCollection->begin(); + for ( std::vector::const_iterator particle = sortedCollection->begin(); particle != sortedCollection->end(); ++particle ) { colkey.second->push_back(*particle); } @@ -422,7 +422,7 @@ std::auto_ptr RecoTauConstructor::get(bool setupLeadingObjects) getCollection(kSignal, kGamma)->end()) / tau_->pt()); if ( setupLeadingObjects ) { - typedef std::vector::const_iterator Iter; + typedef std::vector::const_iterator Iter; // Find the highest PT object in the signal cone Iter leadingCand = leadPFCand( getCollection(kSignal, kAll)->begin(), diff --git a/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc b/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc index 5aa3611916df3..6b88bd0e86090 100644 --- a/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc +++ b/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc @@ -2,8 +2,8 @@ #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Math/interface/angle.h" #include -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/TauReco/interface/RecoTauPiZero.h" #include @@ -12,7 +12,7 @@ namespace reco { namespace tau { namespace disc { // Helper functions namespace { -const PFCandidate& removeRef(const PFCandidatePtr& pfRef) { +const Candidate& removeRef(const CandidatePtr& pfRef) { return *pfRef; } @@ -46,7 +46,7 @@ class DeltaRToAxis { } // end helper functions -PFCandidatePtr mainTrack(Tau tau) { +CandidatePtr mainTrack(Tau tau) { if (tau.signalPFChargedHadrCands().size() == 3) { for (size_t itrk = 0; itrk < 3; ++itrk) { if (tau.signalPFChargedHadrCands()[itrk]->charge() * tau.charge() < 0) @@ -56,12 +56,12 @@ PFCandidatePtr mainTrack(Tau tau) { return tau.leadPFChargedHadrCand(); } -std::vector notMainTrack(Tau tau) +std::vector notMainTrack(Tau tau) { - const PFCandidatePtr& mainTrackPtr = mainTrack(tau); - std::vector output; + const CandidatePtr& mainTrackPtr = mainTrack(tau); + std::vector output; output.reserve(tau.signalPFChargedHadrCands().size() - 1); - BOOST_FOREACH(const PFCandidatePtr& ptr, tau.signalPFChargedHadrCands()) { + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFChargedHadrCands()) { if (ptr != mainTrackPtr) output.push_back(ptr); } @@ -115,7 +115,7 @@ double IsolationECALPtFraction(Tau tau) { double IsolationNeutralHadronPtFraction(Tau tau) { double sum = 0.0; - BOOST_FOREACH(PFCandidatePtr cand, tau.isolationPFNeutrHadrCands()) { + BOOST_FOREACH(CandidatePtr cand, tau.isolationPFNeutrHadrCands()) { sum += cand->pt(); } return sum/tau.jetRef()->pt(); @@ -129,7 +129,7 @@ double ScaledEtaJetCollimation(Tau tau) { double OpeningDeltaR(Tau tau) { double sumEt = 0; double weightedDeltaR = 0; - BOOST_FOREACH(const reco::PFCandidatePtr& cand, tau.signalPFCands()) { + BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalPFCands()) { double candEt = cand->et(); double candDeltaR = reco::deltaR(cand->p4(), tau.p4()); sumEt += candEt; @@ -141,7 +141,7 @@ double OpeningDeltaR(Tau tau) { double OpeningAngle3D(Tau tau) { double sumE = 0; double weightedAngle = 0; - BOOST_FOREACH(const reco::PFCandidatePtr& cand, tau.signalPFCands()) { + BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalPFCands()) { double candE = cand->energy(); double candAngle = angle(cand->p4(), tau.p4()); sumE += candE; @@ -152,7 +152,7 @@ double OpeningAngle3D(Tau tau) { double ScaledOpeningDeltaR(Tau tau) { double max = 0.0; - const std::vector& cands = tau.signalPFCands(); + const std::vector& cands = tau.signalPFCands(); for (size_t i = 0; i < cands.size()-1; ++i) { for (size_t j = i+1; j < cands.size(); ++j) { double deltaRVal = deltaR(cands[i]->p4(), cands[j]->p4()); @@ -185,13 +185,13 @@ double MainTrackPtFraction(Tau tau) { } VDouble Dalitz2(Tau tau) { - PFCandidatePtr theMainTrack = mainTrack(tau); - std::vector otherSignalTracks = notMainTrack(tau); + CandidatePtr theMainTrack = mainTrack(tau); + std::vector otherSignalTracks = notMainTrack(tau); const std::vector &pizeros = tau.signalPiZeroCandidates(); VDouble output; output.reserve(otherSignalTracks.size() + pizeros.size()); // Add combos with tracks - BOOST_FOREACH(PFCandidatePtr trk, otherSignalTracks) { + BOOST_FOREACH(CandidatePtr trk, otherSignalTracks) { reco::Candidate::LorentzVector p4 = theMainTrack->p4() + trk->p4(); output.push_back(p4.mass()); } @@ -205,7 +205,7 @@ VDouble Dalitz2(Tau tau) { double IsolationChargedSumHard(Tau tau) { VDouble isocands = extract(tau.isolationPFChargedHadrCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { if (pt > 1.0) @@ -216,7 +216,7 @@ double IsolationChargedSumHard(Tau tau) { double IsolationChargedSumSoft(Tau tau) { VDouble isocands = extract(tau.isolationPFChargedHadrCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { if (pt < 1.0) @@ -236,7 +236,7 @@ double IsolationChargedSumSoftRelative(Tau tau) { double IsolationECALSumHard(Tau tau) { VDouble isocands = extract(tau.isolationPFGammaCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { if (pt > 1.5) @@ -247,7 +247,7 @@ double IsolationECALSumHard(Tau tau) { double IsolationECALSumSoft(Tau tau) { VDouble isocands = extract(tau.isolationPFGammaCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { if (pt < 1.5) @@ -267,7 +267,7 @@ double IsolationECALSumSoftRelative(Tau tau) { double EMFraction(Tau tau) { //double result = tau.emFraction(); reco::Candidate::LorentzVector gammaP4; - BOOST_FOREACH(const reco::PFCandidatePtr& gamma, tau.signalPFGammaCands()) { + BOOST_FOREACH(const reco::CandidatePtr& gamma, tau.signalPFGammaCands()) { gammaP4 += gamma->p4(); } double result = gammaP4.pt()/tau.pt(); @@ -276,12 +276,12 @@ double EMFraction(Tau tau) { LogDebug("TauDiscFunctions") << "EM fraction = " << result << tau ; LogDebug("TauDiscFunctions") << "charged" ; - BOOST_FOREACH(const reco::PFCandidatePtr cand, tau.signalPFChargedHadrCands()) { - LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " type: " << cand->particleId() << " key: " << cand.key() ; + BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalPFChargedHadrCands()) { + LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " pdgId: " << cand->pdgId() << " key: " << cand.key() ; } LogDebug("TauDiscFunctions") << "gammas" ; - BOOST_FOREACH(const reco::PFCandidatePtr cand, tau.signalPFGammaCands()) { - LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " type: " << cand->particleId() << " key: " << cand.key() ; + BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalPFGammaCands()) { + LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " pdgId: " << cand->pdgId() << " key: " << cand.key() ; } } return result; @@ -301,17 +301,17 @@ double OutlierNCharged(Tau tau) { } double MainTrackPt(Tau tau) { - PFCandidatePtr trk = mainTrack(tau); + CandidatePtr trk = mainTrack(tau); return (!trk) ? 0.0 : trk->pt(); } double MainTrackEta(Tau tau) { - PFCandidatePtr trk = mainTrack(tau); + CandidatePtr trk = mainTrack(tau); return (!trk) ? 0.0 : trk->eta(); } double MainTrackAngle(Tau tau) { - PFCandidatePtr trk = mainTrack(tau); + CandidatePtr trk = mainTrack(tau); return (!trk) ? 0.0 : deltaR(trk->p4(), tau.p4()); } @@ -330,11 +330,11 @@ double NeutralOutlierSumPt(Tau tau) { // Quantities associated to tracks - that are not the main track VDouble TrackPt(Tau tau) { - return extract(notMainTrack(tau), std::mem_fun_ref(&PFCandidate::pt)); + return extract(notMainTrack(tau), std::mem_fun_ref(&Candidate::pt)); } VDouble TrackEta(Tau tau) { - return extract(notMainTrack(tau), std::mem_fun_ref(&PFCandidate::eta)); + return extract(notMainTrack(tau), std::mem_fun_ref(&Candidate::eta)); } VDouble TrackAngle(Tau tau) { @@ -356,7 +356,7 @@ VDouble PiZeroAngle(Tau tau) { // Isolation quantities VDouble OutlierPt(Tau tau) { - return extract(tau.isolationPFCands(), std::mem_fun_ref(&PFCandidate::pt)); + return extract(tau.isolationPFCands(), std::mem_fun_ref(&Candidate::pt)); } VDouble OutlierAngle(Tau tau) { @@ -365,7 +365,7 @@ VDouble OutlierAngle(Tau tau) { VDouble ChargedOutlierPt(Tau tau) { return extract(tau.isolationPFChargedHadrCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); } VDouble ChargedOutlierAngle(Tau tau) { @@ -374,7 +374,7 @@ VDouble ChargedOutlierAngle(Tau tau) { VDouble NeutralOutlierPt(Tau tau) { return extract(tau.isolationPFGammaCands(), - std::mem_fun_ref(&PFCandidate::pt)); + std::mem_fun_ref(&Candidate::pt)); } VDouble NeutralOutlierAngle(Tau tau) { diff --git a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc index d1e7176395a95..6857a9b0ca5bc 100644 --- a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc +++ b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc @@ -32,11 +32,11 @@ class PtSorter { // Check if an object is within DR of a track collection class MultiTrackDRFilter { public: - MultiTrackDRFilter(double deltaR, const std::vector& trks) + MultiTrackDRFilter(double deltaR, const std::vector& trks) :deltaR_(deltaR),tracks_(trks){} template bool operator()(const T& t) const { - BOOST_FOREACH(const reco::PFCandidatePtr& trk, tracks_) { + BOOST_FOREACH(const reco::CandidatePtr& trk, tracks_) { if (reco::deltaR(trk->p4(), t->p4()) < deltaR_) return true; } @@ -44,7 +44,7 @@ class MultiTrackDRFilter { } private: double deltaR_; - const std::vector& tracks_; + const std::vector& tracks_; }; double square(double x) { return x*x; } @@ -75,7 +75,7 @@ RecoTauIsolationMasking::IsoMaskResult RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { IsoMaskResult output; - typedef std::list PFCandList; + typedef std::list CandList; // Copy original iso collections. std::copy(tau.isolationPFGammaCands().begin(), tau.isolationPFGammaCands().end(), std::back_inserter(output.gammas)); @@ -83,12 +83,15 @@ RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { tau.isolationPFNeutrHadrCands().end(), std::back_inserter(output.h0s)); - std::vector courses; + std::vector courses; courses.push_back(&(output.h0s)); courses.push_back(&(output.gammas)); // Mask using each one of the tracks - BOOST_FOREACH(const reco::PFCandidatePtr& track, + BOOST_FOREACH(const reco::CandidatePtr& c_track, tau.signalPFChargedHadrCands()) { + const reco::PFCandidate* track = dynamic_cast(c_track.get()); + if (track == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; double trackerEnergy = track->energy(); double linkedEcalEnergy = track->ecalEnergy(); double linkedHcalEnergy = track->hcalEnergy(); @@ -108,14 +111,14 @@ RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { //DRSorter sorter(track->p4()); PtSorter sorter; - BOOST_FOREACH(PFCandList* course, courses) { + BOOST_FOREACH(CandList* course, courses) { // Sort by deltaR to the current track course->sort(sorter); - PFCandList::iterator toEatIter = course->begin(); + CandList::iterator toEatIter = course->begin(); // While there are still candidates to eat in this course and they are // within the cone. while (toEatIter != course->end()) { - const reco::PFCandidate& toEat = **toEatIter; + const reco::Candidate& toEat = **toEatIter; double toEatEnergy = toEat.energy(); double toEatErrorSq = square(resolution(toEat)); // Check if we can absorb this candidate into the track. @@ -143,35 +146,37 @@ RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { } double RecoTauIsolationMasking::resolution( - const reco::PFCandidate& cand) const { - if (cand.particleId() == reco::PFCandidate::h0) { + const reco::Candidate& cand) const { + if (cand.pdgId() == 130) { // NB for HCAL it returns relative energy return cand.energy()*resolutions_->getEnergyResolutionHad(cand.energy(), cand.eta(), cand.phi()); - } else if (cand.particleId() == reco::PFCandidate::gamma) { + } else if (cand.pdgId() == 22) { return resolutions_->getEnergyResolutionEm(cand.energy(), cand.eta()); - } else if (cand.particleId() == reco::PFCandidate::e) { + } else if (std::abs(cand.pdgId()) == 11) { // FIXME what is the electron resolution?? return 0.15; } else { edm::LogWarning("IsoMask::res (bad pf id)") - << "Unknown PF ID: " << cand.particleId(); + << "Unknown PF PDG ID: " << cand.pdgId(); } return -1; } -bool RecoTauIsolationMasking::inCone(const reco::PFCandidate& track, - const reco::PFCandidate& cand) const { - double openingDR = reco::deltaR(track.positionAtECALEntrance(), cand.p4()); - if (cand.particleId() == reco::PFCandidate::h0) { +bool RecoTauIsolationMasking::inCone(const reco::Candidate& track, + const reco::Candidate& cand) const { + const reco::PFCandidate* pf_track = dynamic_cast(&track); + if (pf_track == nullptr) + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + double openingDR = reco::deltaR(pf_track->positionAtECALEntrance(), cand.p4()); + if (cand.pdgId() == 130) { return (openingDR < hcalCone_); - } else if (cand.particleId() == reco::PFCandidate::gamma || - cand.particleId() == reco::PFCandidate::e) { + } else if (cand.pdgId() == 22 || + abs(cand.pdgId()) == 11) { return openingDR < ecalCone_; } else { edm::LogWarning("IsoMask::inCone (bad pf id)") - << "Unknown PF ID: " << cand.particleId() - << " " << reco::PFCandidate::e; + << "Unknown PF PDG ID: " << cand.pdgId(); } return -1; } diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index 17be726ebd74a..35b86f7f5405a 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -4,6 +4,7 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include @@ -12,16 +13,31 @@ namespace reco { namespace tau { namespace { // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. // JAN FIXME - WE NEED TO SEE WHAT TO DO FOR MINIAOD - const reco::TrackBaseRef getTrackRef(const Candidate& cand) + const reco::Track* getTrack(const Candidate& cand) { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); + else return nullptr; + } + + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } + + const reco::TrackBaseRef getTrackRef(const Candidate& cand) + { const PFCandidate* pfCandPtr = dynamic_cast(&cand); if (pfCandPtr) { if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); - else return reco::TrackBaseRef(); } - // JAN - FIXME: Add method for miniAOD PackedCandidate return reco::TrackBaseRef(); + } // Translate GsfTrackRef to TrackBaseRef @@ -52,7 +68,7 @@ bool etMin_cand(const Candidate& cand, double cut) return (cand.et() > cut); } -bool trkPixelHits(const TrackBaseRef& track, int cut) +bool trkPixelHits(const Track* track, int cut) { // For some reason, the number of hits is signed LogDebug("TauQCuts") << ": #Pxl hits = " << track->hitPattern().numberOfValidPixelHits() << ", cut = " << cut ; @@ -62,8 +78,8 @@ bool trkPixelHits(const TrackBaseRef& track, int cut) bool trkPixelHits_cand(const Candidate& cand, int cut) { // For some reason, the number of hits is signed - auto track = getTrackRef(cand); - if ( track.isNonnull() ) { + auto track = getTrack(cand); + if ( track ) { LogDebug("TauQCuts") << ": #Pxl hits = " << trkPixelHits(track, cut) << ", cut = " << cut ; return trkPixelHits(track, cut); } else { @@ -72,7 +88,7 @@ bool trkPixelHits_cand(const Candidate& cand, int cut) } } -bool trkTrackerHits(const TrackBaseRef& track, int cut) +bool trkTrackerHits(const Track* track, int cut) { LogDebug("TauQCuts") << ": #Trk hits = " << track->hitPattern().numberOfValidHits() << ", cut = " << cut ; return (track->hitPattern().numberOfValidHits() >= cut); @@ -80,8 +96,8 @@ bool trkTrackerHits(const TrackBaseRef& track, int cut) bool trkTrackerHits_cand(const Candidate& cand, int cut) { - auto track = getTrackRef(cand); - if ( track.isNonnull() ) { + auto track = getTrack(cand); + if ( track ) { LogDebug("TauQCuts") << ": #Trk hits = " << track->hitPattern().numberOfValidHits() << ", cut = " << cut ; return trkTrackerHits(track, cut); } else { @@ -90,7 +106,7 @@ bool trkTrackerHits_cand(const Candidate& cand, int cut) } } -bool trkTransverseImpactParameter(const TrackBaseRef& track, const reco::VertexRef* pv, double cut) +bool trkTransverseImpactParameter(const Track* track, const reco::VertexRef* pv, double cut) { if ( pv->isNull() ) { edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " << @@ -105,8 +121,8 @@ bool trkTransverseImpactParameter(const TrackBaseRef& track, const reco::VertexR bool trkTransverseImpactParameter_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { - auto track = getTrackRef(cand); - if ( track.isNonnull() ) { + auto track = getTrack(cand); + if ( track ) { return trkTransverseImpactParameter(track, pv, cut); } else { LogDebug("TauQCuts") << ": dXY = N/A, cut = " << cut ; @@ -114,7 +130,7 @@ bool trkTransverseImpactParameter_cand(const Candidate& cand, const reco::Vertex } } -bool trkLongitudinalImpactParameter(const TrackBaseRef& track, const reco::VertexRef* pv, double cut) +bool trkLongitudinalImpactParameter(const TrackBase* track, const reco::VertexRef* pv, double cut) { if ( pv->isNull() ) { edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " << @@ -129,8 +145,8 @@ bool trkLongitudinalImpactParameter(const TrackBaseRef& track, const reco::Verte bool trkLongitudinalImpactParameter_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { - auto track = getTrackRef(cand); - if ( track.isNonnull() ) { + auto track = getTrack(cand); + if ( track ) { return trkLongitudinalImpactParameter(track, pv, cut); } else { LogDebug("TauQCuts") << ": dZ = N/A, cut = " << cut ; @@ -139,20 +155,20 @@ bool trkLongitudinalImpactParameter_cand(const Candidate& cand, const reco::Vert } /// DZ cut, with respect to the current lead rack -bool trkLongitudinalImpactParameterWrtTrack(const TrackBaseRef& track, const reco::TrackBaseRef* leadTrack, const reco::VertexRef* pv, double cut) +bool trkLongitudinalImpactParameterWrtTrack(const Track* track, const Track* leadTrack, const reco::VertexRef* pv, double cut) { - if ( leadTrack->isNull()) { + if (!leadTrack) { edm::LogError("QCutsNoValidLeadTrack") << "Lead track Ref in " << "RecoTauQualityCuts is invalid. - trkLongitudinalImpactParameterWrtTrack"; return false; } - return (std::fabs(track->dz((*pv)->position()) - (*leadTrack)->dz((*pv)->position())) <= cut); + return (std::fabs(track->dz((*pv)->position()) - leadTrack->dz((*pv)->position())) <= cut); } -bool trkLongitudinalImpactParameterWrtTrack_cand(const Candidate& cand, const reco::TrackBaseRef* leadTrack, const reco::VertexRef* pv, double cut) +bool trkLongitudinalImpactParameterWrtTrack_cand(const Candidate& cand, const reco::Track* leadTrack, const reco::VertexRef* pv, double cut) { - auto track = getTrackRef(cand); - if ( track.isNonnull() ) return trkLongitudinalImpactParameterWrtTrack(track, leadTrack, pv, cut); + auto track = getTrack(cand); + if ( track ) return trkLongitudinalImpactParameterWrtTrack(track, leadTrack, pv, cut); else return false; } @@ -169,18 +185,41 @@ bool minTrackVertexWeight(const TrackBaseRef& track, const reco::VertexRef* pv, return ((*pv)->trackWeight(track) >= cut); } +bool minPackedCandVertexWeight(const pat::PackedCandidate& pCand, const reco::VertexRef* pv, double cut) { + + if ( pv->isNull() ) { + edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " << + "RecoTauQualityCuts is invalid. - minPackedCandVertexWeight"; + return false; + } + //there is some low granular information on track weight in the vertex available with packed cands + double weight = -9.9; + if( pCand.vertexRef().isNonnull() && pCand.vertexRef().key() == pv->key() ){ + int quality = pCand.pvAssociationQuality(); + if( quality == pat::PackedCandidate::UsedInFitTight ) weight = 0.6;//0.6 as proxy for weight above 0.5 + else if( quality == pat::PackedCandidate::UsedInFitLoose ) weight = 0.1;//0.6 as proxy for weight below 0.5 + } + LogDebug("TauQCuts") << " packedCand: Pt = " << pCand.pt() << ", eta = " << pCand.eta() << ", phi = " << pCand.phi() ; + LogDebug("TauQCuts") << " vertex: x = " << (*pv)->position().x() << ", y = " << (*pv)->position().y() << ", z = " << (*pv)->position().z() ; + LogDebug("TauQCuts") << "--> trackWeight from packedCand = " << weight << " (cut = " << cut << ")" ; + return (weight >= cut); +} + bool minTrackVertexWeight_cand(const Candidate& cand, const reco::VertexRef* pv, double cut) { auto track = getTrackRef(cand); if ( track.isNonnull() ) { return minTrackVertexWeight(track, pv, cut); - } else { - LogDebug("TauQCuts") << ": weight = N/A, cut = " << cut ; - return false; } + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if( pCand != nullptr && cand.charge() != 0) { + return minPackedCandVertexWeight(*pCand, pv, cut); + } + LogDebug("TauQCuts") << ": weight = N/A, cut = " << cut ; + return false; } -bool trkChi2(const TrackBaseRef& track, double cut) +bool trkChi2(const Track* track, double cut) { LogDebug("TauQCuts") << ": chi^2 = " << track->normalizedChi2() << ", cut = " << cut ; return (track->normalizedChi2() <= cut); @@ -188,8 +227,8 @@ bool trkChi2(const TrackBaseRef& track, double cut) bool trkChi2_cand(const Candidate& cand, double cut) { - auto track = getTrackRef(cand); - if ( track.isNonnull() ) { + auto track = getTrack(cand); + if ( track ) { LogDebug("TauQCuts") << ": chi^2 = " << track->normalizedChi2() << ", cut = " << cut ; return trkChi2(track, cut); } else { @@ -341,18 +380,27 @@ std::pair factorizePUQCuts(const edm::Para bool RecoTauQualityCuts::filterTrack(const reco::TrackBaseRef& track) const { - return filterTrack_(track); + if (!filterTrack_(track.get())) + return false; + if(minTrackVertexWeight_ >= 0. && !(pv_->trackWeight(convertRef(track)) >= minTrackVertexWeight_)) return false; + return true; } bool RecoTauQualityCuts::filterTrack(const reco::TrackRef& track) const { - return filterTrack_(track); + if (!filterTrack_(track.get())) + return false; + if(minTrackVertexWeight_ >= 0. && !(pv_->trackWeight(convertRef(track)) >= minTrackVertexWeight_)) return false; + return true; } -template -bool RecoTauQualityCuts::filterTrack_(const T& trackRef) const +bool RecoTauQualityCuts::filterTrack(const reco::Track& track) const +{ + return filterTrack_(&track); +} + +bool RecoTauQualityCuts::filterTrack_(const reco::Track* track) const { - const Track *track = trackRef.get(); if(minTrackPt_ >= 0 && !(track->pt() > minTrackPt_)) return false; if(maxTrackChi2_ >= 0 && !(track->normalizedChi2() <= maxTrackChi2_)) return false; if(checkHitPattern_) { @@ -371,7 +419,7 @@ bool RecoTauQualityCuts::filterTrack_(const T& trackRef) const return false; if(maxDeltaZ_ >= 0 && !(std::fabs(track->dz(pv_->position())) <= maxDeltaZ_)) return false; if(maxDeltaZToLeadTrack_ >= 0) { - if ( leadTrack_.isNull()) { + if ( !leadTrack_) { edm::LogError("QCutsNoValidLeadTrack") << "Lead track Ref in " << "RecoTauQualityCuts is invalid. - filterTrack"; return false; @@ -380,7 +428,50 @@ bool RecoTauQualityCuts::filterTrack_(const T& trackRef) const if(!(std::fabs(track->dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_)) return false; } - if(minTrackVertexWeight_ > -1.0 && !(pv_->trackWeight(convertRef(trackRef)) >= minTrackVertexWeight_)) return false; + + return true; +} + +bool RecoTauQualityCuts::filterChargedCand(const reco::Candidate& cand) const { + + if (cand.charge() == 0) + return true; + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if (pCand == nullptr) + return true; + + //Get track, it should be present for cands with pT(charged)>0.5GeV + //and check track quality critera other than vertex weight + auto track = getTrack(cand); + if (track != nullptr){ + if (!filterTrack(*track)) + return false; + } else {//Candidates without track (pT(charged)<0.5GeV): Can still check pT and calculate dxy and dz + if(minTrackPt_ >= 0 && !(pCand->pt() > minTrackPt_)) return false; + if(checkPV_ && pv_.isNull()) { + edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " << + "RecoTauQualityCuts is invalid. - filterChargedCand"; + return false; + } + + if(maxTransverseImpactParameter_ >= 0 && + !(std::fabs(pCand->dxy(pv_->position())) <= maxTransverseImpactParameter_)) + return false; + if(maxDeltaZ_ >= 0 && !(std::fabs(pCand->dz(pv_->position())) <= maxDeltaZ_)) return false; + if(maxDeltaZToLeadTrack_ >= 0) { + if ( leadTrack_ == nullptr) { + edm::LogError("QCutsNoValidLeadTrack") << "Lead track Ref in " << + "RecoTauQualityCuts is invalid. - filterChargedCand"; + return false; + } + + if(!(std::fabs(pCand->dz(pv_->position()) - leadTrack_->dz(pv_->position())) <= maxDeltaZToLeadTrack_)) + return false; + } + } + if(minTrackVertexWeight_ >= 0. && + !(qcuts::minPackedCandVertexWeight(*pCand, &pv_, minTrackVertexWeight_))) + return false; return true; } @@ -420,31 +511,34 @@ bool RecoTauQualityCuts::filterCand(const reco::Candidate& cand) const bool result = true; if(trackRef.isNonnull()) - result = filterTrack_(trackRef); - + result = filterTrack(trackRef); + else if(cand.charge() != 0){ + result = filterChargedCand(cand); + } if(result) result = filterCandByType(cand); + return result; } -void RecoTauQualityCuts::setLeadTrack(const reco::TrackRef& leadTrack) const +void RecoTauQualityCuts::setLeadTrack(const reco::Track& leadTrack) const { - leadTrack_ = reco::TrackBaseRef(leadTrack); + leadTrack_ = &leadTrack; } void RecoTauQualityCuts::setLeadTrack(const reco::Candidate& leadCand) const { - leadTrack_ = getTrackRef(leadCand); + leadTrack_ = getTrack(leadCand); } void RecoTauQualityCuts::setLeadTrack(const reco::CandidateRef& leadCand) const { if ( leadCand.isNonnull() ) { - leadTrack_ = getTrackRef(*leadCand); + leadTrack_ = getTrack(*leadCand); } else { // Set null - leadTrack_ = reco::TrackBaseRef(); + leadTrack_ = nullptr; } } -}} // end namespace reco::tau +}} // end namespace reco::tau \ No newline at end of file diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 82dd76d2acd3e..152069f0933f5 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -5,6 +5,7 @@ #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" @@ -16,22 +17,40 @@ namespace reco { namespace tau { namespace { - inline const reco::TrackBaseRef getTrack(const Candidate& cand) + inline const reco::Track* getTrack(const Candidate& cand) { const PFCandidate* pfCandPtr = dynamic_cast(&cand); - if (pfCandPtr) { + if (pfCandPtr != nullptr) { + if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); + else return nullptr; + } + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand != nullptr && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } + + inline const reco::TrackBaseRef getTrackRef(const Candidate& cand) + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr != nullptr) { if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); else return reco::TrackBaseRef(); } - // JAN - FIXME: Add method for miniAOD PackedCandidate + + // FIXME - JAN - should put an error message somewhere that we use an algo that + // is not supported for PackedCandidates + return reco::TrackBaseRef(); } } // Get the highest pt track in a jet. // Get the KF track if it exists. Otherwise, see if it has a GSF track. -reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const +const reco::CandidatePtr RecoTauVertexAssociator::getLeadCand(const Jet& jet) const { std::vector chargedPFCands = pfChargedCands(jet, true); if ( verbosity_ >= 1 ) { @@ -42,9 +61,9 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const } if ( chargedPFCands.empty() ) { - return reco::TrackBaseRef(); + return reco::CandidatePtr(nullptr, 0); } - + std::vector selectedPFCands; if ( vxTrkFiltering_ ) { selectedPFCands = qcuts_->filterCandRefs(chargedPFCands); @@ -54,24 +73,26 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const if ( verbosity_ >= 1 ) { std::cout << " num. selectedPFCands = " << selectedPFCands.size() << std::endl; } - + CandidatePtr leadPFCand; if ( !selectedPFCands.empty() ) { double leadTrackPt = 0.; if ( leadingTrkOrPFCandOption_ == kFirstTrack){ leadPFCand=selectedPFCands[0];} - else - { + else { for ( std::vector::const_iterator pfCand = selectedPFCands.begin(); - pfCand != selectedPFCands.end(); ++pfCand ) { - const reco::TrackBaseRef& track = getTrack(**pfCand); + pfCand != selectedPFCands.end(); ++pfCand ) { + const reco::Track* track = getTrack(**pfCand); + double actualTrackPt = 0.; + if ( track != nullptr ) + actualTrackPt = track->pt(); double trackPt = 0.; if ( leadingTrkOrPFCandOption_ == kLeadTrack ) { - //double trackPt = track->pt(); - trackPt = track->pt() - 2.*track->ptError(); + //double trackPt = track->pt(); + trackPt = actualTrackPt - 2.*track->ptError(); } else if ( leadingTrkOrPFCandOption_ == kLeadPFCand ) { trackPt = (*pfCand)->pt(); } else if ( leadingTrkOrPFCandOption_ == kMinLeadTrackOrPFCand ) { - trackPt = TMath::Min(track->pt(), (double)(*pfCand)->pt()); + trackPt = TMath::Min(actualTrackPt, (double)(*pfCand)->pt()); } else assert(0); if ( trackPt > leadTrackPt ) { leadPFCand = (*pfCand); @@ -84,23 +105,35 @@ reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const if ( recoverLeadingTrk_ ) { leadPFCand = chargedPFCands[0]; } else { - return reco::TrackBaseRef(); + return reco::CandidatePtr(nullptr, 0); } } if ( verbosity_ >= 1 ) { std::cout << "leadPFCand: Pt = " << leadPFCand->pt() << ", eta = " << leadPFCand->eta() << ", phi = " << leadPFCand->phi() << std::endl; } - const reco::TrackBaseRef& track = getTrack(*leadPFCand); + return leadPFCand; +} + +const reco::Track* RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const { + auto leadPFCand = getLeadCand(jet); + if(leadPFCand.isNull()) return nullptr; + const reco::Track* track = getTrack(*leadPFCand); return track; } +const reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrackRef(const Jet& jet) const { + auto leadPFCand = getLeadCand(jet); + if(leadPFCand.isNull()) return reco::TrackBaseRef(); + return getTrackRef(*leadPFCand); +} + namespace { // Define functors which extract the relevant information from a collection of // vertices. class DZtoTrack : public std::unary_function { public: - DZtoTrack(const reco::TrackBaseRef& trk) + DZtoTrack(const reco::Track* trk) : trk_(trk) {} double operator()(const reco::VertexRef& vtx) const @@ -111,7 +144,7 @@ namespace { return std::abs(trk_->dz(vtx->position())); } private: - const reco::TrackBaseRef trk_; + const reco::Track* trk_; }; class TrackWeightInVertex : public std::unary_function @@ -244,32 +277,30 @@ void RecoTauVertexAssociator::setEvent(const edm::Event& evt) reco::VertexRef RecoTauVertexAssociator::associatedVertex(const PFTau& tau, bool useJet) const { - if ( !useJet ) { if ( tau.leadPFChargedHadrCand().isNonnull() ) { - if ( tau.leadPFChargedHadrCand()->trackRef().isNonnull() ) - return associatedVertex( reco::TrackBaseRef( tau.leadPFChargedHadrCand()->trackRef() ) ); - else if ( tau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull() ) - return associatedVertex( reco::TrackBaseRef( tau.leadPFChargedHadrCand()->gsfTrackRef() ) ); + const reco::Track* track = getTrack(*tau.leadPFChargedHadrCand()); + if (track != nullptr) + return associatedVertex(track); } } // MB: use vertex associated to a given jet if explicitely requested or in case of missing leading track - reco::PFJetRef jetRef = tau.jetRef(); + reco::JetBaseRef jetRef = tau.jetRef(); // FIXME workaround for HLT which does not use updated data format if ( jetRef.isNull() ) jetRef = tau.pfTauTagInfoRef()->pfjetRef(); return associatedVertex(*jetRef); } reco::VertexRef -RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const +RecoTauVertexAssociator::associatedVertex(const Track* track) const { - reco::VertexRef trkVertex = ( !selectedVertices_.empty() ) ? selectedVertices_[0] : reco::VertexRef(); + // algos kHighestWeigtForLeadTrack and kCombined not supported if ( algo_ == kHighestPtInEvent ) { if ( !selectedVertices_.empty() ) trkVertex = selectedVertices_[0]; } else if ( algo_ == kClosestDeltaZ ) { - if ( track.isNonnull() ) { + if ( track ) { double closestDistance = 1.e+6; DZtoTrack dzComputer(track); // Find the vertex that has the lowest dZ to the track @@ -288,7 +319,23 @@ RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const ++idxVertex; } } - } else if ( algo_ == kHighestWeigtForLeadTrack || algo_ == kCombined ) { + } + + if ( verbosity_ >= 1 ) { + std::cout << "--> returning vertex: x = " << trkVertex->position().x() << ", y = " << trkVertex->position().y() << ", z = " << trkVertex->position().z() << std::endl; + } + + return trkVertex; +} + + +reco::VertexRef +RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const +{ + + reco::VertexRef trkVertex = ( !selectedVertices_.empty() ) ? selectedVertices_[0] : reco::VertexRef(); + + if ( algo_ == kHighestWeigtForLeadTrack || algo_ == kCombined ) { if ( track.isNonnull() ) { double largestWeight = -1.; // Find the vertex that has the highest association probability to the track @@ -313,7 +360,7 @@ RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const std::cout << "No vertex had positive weight! Trying dZ instead... " << std::endl; } double closestDistance = 1.e+6; - DZtoTrack dzComputer(track); + DZtoTrack dzComputer(track.get()); // Find the vertex that has the lowest dZ to the leading track int idxVertex = 0; for ( std::vector::const_iterator selectedVertex = selectedVertices_.begin(); @@ -343,7 +390,7 @@ RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const reco::VertexRef RecoTauVertexAssociator::associatedVertex(const Jet& jet) const { - if ( verbosity_ >= 1 ) { +if ( verbosity_ >= 1 ) { std::cout << ":" << std::endl; std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << std::endl; std::cout << " num. Vertices = " << selectedVertices_.size() << std::endl; @@ -364,16 +411,25 @@ RecoTauVertexAssociator::associatedVertex(const Jet& jet) const // no jet-vertex association exists for this jet yet, compute it! if ( algo_ == kHighestPtInEvent ) { if ( !selectedVertices_.empty() ) jetVertex = selectedVertices_[0]; - } else if ( algo_ == kClosestDeltaZ || - algo_ == kHighestWeigtForLeadTrack || - algo_ == kCombined ) { + } else if ( algo_ == kClosestDeltaZ ) { + // find "leading" (highest Pt) track in jet + const reco::Track* leadTrack = getLeadTrack(jet); + if ( verbosity_ ) { + if ( leadTrack != nullptr ) std::cout << "leadTrack: Pt = " << leadTrack->pt() << ", eta = " << leadTrack->eta() << ", phi = " << leadTrack->phi() << std::endl; + else std::cout << "leadTrack: N/A" << std::endl; + } + if ( leadTrack != nullptr ) { + jetVertex = associatedVertex(leadTrack); + } + } else if (algo_ == kHighestWeigtForLeadTrack || + algo_ == kCombined ) { // find "leading" (highest Pt) track in jet - reco::TrackBaseRef leadTrack = getLeadTrack(jet); + const reco::TrackBaseRef leadTrack = getLeadTrackRef(jet); if ( verbosity_ ) { if ( leadTrack.isNonnull() ) std::cout << "leadTrack: Pt = " << leadTrack->pt() << ", eta = " << leadTrack->eta() << ", phi = " << leadTrack->phi() << std::endl; else std::cout << "leadTrack: N/A" << std::endl; } - if ( leadTrack.isNonnull() ) { + if ( leadTrack.isNonnull()) { jetVertex = associatedVertex(leadTrack); } } diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index 9931126658e8d..75a63e96e0509 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -2,6 +2,7 @@ #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include @@ -44,8 +45,8 @@ void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scal chargedHadronPy = chargedPFCand->py(); chargedHadronPz = chargedPFCand->pz(); } else if ( chargedHadron.algoIs(reco::PFRecoTauChargedHadron::kTrack) ) { - const reco::PFRecoTauChargedHadron::TrackPtr& track = chargedHadron.getTrack(); - assert(track.isNonnull()); + const reco::Track* track = getTrackFromChargedHadron(chargedHadron); + assert(track != nullptr); chargedHadronP += track->p(); chargedHadronPx = track->px(); chargedHadronPy = track->py(); From 68e208e0ed25d199f8018289c51e1830063a6a65 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 10:05:22 +0100 Subject: [PATCH 013/686] Adapt all tau tag tools to changes in PFTau class --- .../interface/PFCandidateMergerBase.h | 2 +- .../interface/PFCandidateStripMerger.h | 4 +- .../interface/PFTauElementsOperators.h | 82 +++--- .../TauTagTools/interface/TauTagTools.h | 34 +-- .../plugins/RecoTauDifferenceAnalyzer.cc | 6 +- .../TauTagTools/plugins/RecoTauDumper.cc | 1 + .../plugins/RecoTauPiZeroFlattener.cc | 2 +- .../TauTagTools/src/PFCandidateStripMerger.cc | 14 +- .../TauTagTools/src/PFTauElementsOperators.cc | 276 +++++++++--------- RecoTauTag/TauTagTools/src/TauTagTools.cc | 97 +++--- 10 files changed, 267 insertions(+), 251 deletions(-) diff --git a/RecoTauTag/TauTagTools/interface/PFCandidateMergerBase.h b/RecoTauTag/TauTagTools/interface/PFCandidateMergerBase.h index 89d92941d79ac..022cedda54c33 100644 --- a/RecoTauTag/TauTagTools/interface/PFCandidateMergerBase.h +++ b/RecoTauTag/TauTagTools/interface/PFCandidateMergerBase.h @@ -13,7 +13,7 @@ class PFCandidateMergerBase virtual ~PFCandidateMergerBase()=0; - virtual std::vector > mergeCandidates(const std::vector&) =0; + virtual std::vector > mergeCandidates(const std::vector&) =0; }; diff --git a/RecoTauTag/TauTagTools/interface/PFCandidateStripMerger.h b/RecoTauTag/TauTagTools/interface/PFCandidateStripMerger.h index db011a32858a0..c25e7d352e44b 100644 --- a/RecoTauTag/TauTagTools/interface/PFCandidateStripMerger.h +++ b/RecoTauTag/TauTagTools/interface/PFCandidateStripMerger.h @@ -19,7 +19,7 @@ class PFCandidateStripMerger : public PFCandidateMergerBase PFCandidateStripMerger(const edm::ParameterSet&); ~PFCandidateStripMerger() override; - std::vector> mergeCandidates(const std::vector&) override; + std::vector> mergeCandidates(const std::vector&) override; private: @@ -29,7 +29,7 @@ class PFCandidateStripMerger : public PFCandidateMergerBase //Private Methods - bool candidateMatches(const reco::PFCandidatePtr&); + bool candidateMatches(const reco::CandidatePtr&); }; diff --git a/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h b/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h index eab44a7164879..b1b8554f8fa64 100644 --- a/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h +++ b/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h @@ -34,45 +34,45 @@ class PFTauElementsOperators : public TauElementsOperators { ~PFTauElementsOperators(){} void setAreaMetricrecoElementsmaxabsEta( double x); //return the leading PFCandidate in a given cone around the jet axis or a given direction - reco::PFCandidatePtr leadPFCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFChargedHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFChargedHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFNeutrHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFNeutrHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFGammaCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::PFCandidatePtr leadPFGammaCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFChargedHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFChargedHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFNeutrHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFNeutrHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFGammaCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadPFGammaCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; // return all PFCandidates in a cone of metric* "cone_metric" and size "conesize" around a direction "myVector" - std::vector PFCandsInCone(const std::vector& PFCands,const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; - std::vector PFCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; - std::vector PFChargedHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; - std::vector PFChargedHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const reco::Vertex &mPV)const; - std::vector PFNeutrHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; - std::vector PFGammaCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; + std::vector PFCandsInCone(const std::vector& PFCands,const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; + std::vector PFCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; + std::vector PFChargedHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; + std::vector PFChargedHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const reco::Vertex &mPV)const; + std::vector PFNeutrHadrCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; + std::vector PFGammaCandsInCone(const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; // return all PFCandidates in a annulus defined by inner(metric* "innercone_metric" and size "innercone_size") and outer(metric* "outercone_metric" and size "outercone_size") cones around a direction "myVector" - std::vector PFCandsInAnnulus(const std::vector& PFCands,const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; - std::vector PFCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; - std::vector PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; - std::vector PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const reco::Vertex &myPV)const; - std::vector PFNeutrHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; - std::vector PFGammaCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; + std::vector PFCandsInAnnulus(const std::vector& PFCands,const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; + std::vector PFCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; + std::vector PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; + std::vector PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const reco::Vertex &myPV)const; + std::vector PFNeutrHadrCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; + std::vector PFGammaCandsInAnnulus(const math::XYZVector& myVector,const std::string innercone_metric,const double innercone_size,const std::string outercone_metric,const double outercone_size,const double minPt)const; //Put function to get elements inside ellipse here ... EELL - std::pair,std::vector> PFGammaCandsInOutEllipse(const std::vector&, const reco::PFCandidate&, double rPhi, double rEta, double maxPt) const; + std::pair,std::vector> PFGammaCandsInOutEllipse(const std::vector&, const reco::Candidate&, double rPhi, double rEta, double maxPt) const; //EELL /// append elements of theInputCands that pass Pt requirement to the end of theOutputCands - void copyCandRefsFilteredByPt(const std::vector& theInputCands, std::vector& theOutputCands, const double minPt); + void copyCandRefsFilteredByPt(const std::vector& theInputCands, std::vector& theOutputCands, const double minPt); /// compute size of cone using the Inside-Out cone (Author Evan Friis, UC Davis) - void computeInsideOutContents(const std::vector& theChargedCands, const std::vector& theGammaCands, const math::XYZVector& leadTrackVector, + void computeInsideOutContents(const std::vector& theChargedCands, const std::vector& theGammaCands, const math::XYZVector& leadTrackVector, const TFormula& coneSizeFormula, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&), // determines grow function, and the metric to compare the opening angle to const double minChargedSize, const double maxChargedSize, const double minNeutralSize, const double maxNeutralSize, const double minChargedPt, const double minNeutralPt, const std::string& outlierCollectorConeMetric, const double outlierCollectorConeSize, - std::vector& signalChargedObjects, std::vector& outlierChargedObjects, - std::vector& signalGammaObjects, std::vector& outlierGammaObjects, bool useScanningAxis); //these last two quantities are the return values + std::vector& signalChargedObjects, std::vector& outlierChargedObjects, + std::vector& signalGammaObjects, std::vector& outlierGammaObjects, bool useScanningAxis); //these last two quantities are the return values // return 1 if no/low PFCandidates activity in an isolation annulus around a leading PFCandidate, 0 otherwise; // different possible metrics* for the matching, signal and isolation cones; @@ -101,28 +101,28 @@ class PFTauElementsOperators : public TauElementsOperators { double discriminatorByIsolPFGammaCandsEtSum(std::string matchingcone_metric,double matchingcone_size,std::string signalcone_metric,double signalcone_size,std::string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum=0); double discriminatorByIsolPFGammaCandsEtSum(const math::XYZVector& myVector,std::string matchingcone_metric,double matchingcone_size,std::string signalcone_metric,double signalcone_size,std::string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum=0); private: - reco::PFJetRef PFJetRef_; + reco::JetBaseRef PFJetRef_; double AreaMetric_recoElements_maxabsEta_; - std::vector PFCands_; - std::vector IsolPFCands_; - std::vector PFChargedHadrCands_; - std::vector IsolPFChargedHadrCands_; - std::vector PFNeutrHadrCands_; - std::vector IsolPFNeutrHadrCands_; - std::vector PFGammaCands_; - std::vector IsolPFGammaCands_; + std::vector PFCands_; + std::vector IsolPFCands_; + std::vector PFChargedHadrCands_; + std::vector IsolPFChargedHadrCands_; + std::vector PFNeutrHadrCands_; + std::vector IsolPFNeutrHadrCands_; + std::vector PFGammaCands_; + std::vector IsolPFGammaCands_; // template objects for DR and Angle metrics DeltaR metricDR_; Angle metricAngle_; double computeDeltaR(const math::XYZVector& vec1, const math::XYZVector& vec2); double computeAngle(const math::XYZVector& vec1, const math::XYZVector& vec2); - ElementsInCone,reco::PFCandidate> PFCandsinCone_DRmetric_; - ElementsInCone,reco::PFCandidate> PFCandsinCone_Anglemetric_; - ElementsInAnnulus,DeltaR,reco::PFCandidate> PFCandsinAnnulus_innerDRouterDRmetrics_; - ElementsInAnnulus,Angle,reco::PFCandidate> PFCandsinAnnulus_innerDRouterAnglemetrics_; - ElementsInAnnulus,Angle,reco::PFCandidate> PFCandsinAnnulus_innerAngleouterAnglemetrics_; - ElementsInAnnulus,DeltaR,reco::PFCandidate> PFCandsinAnnulus_innerAngleouterDRmetrics_; - ElementsInEllipse PFCandidatesInEllipse_; + ElementsInCone,reco::Candidate> PFCandsinCone_DRmetric_; + ElementsInCone,reco::Candidate> PFCandsinCone_Anglemetric_; + ElementsInAnnulus,DeltaR,reco::Candidate> PFCandsinAnnulus_innerDRouterDRmetrics_; + ElementsInAnnulus,Angle,reco::Candidate> PFCandsinAnnulus_innerDRouterAnglemetrics_; + ElementsInAnnulus,Angle,reco::Candidate> PFCandsinAnnulus_innerAngleouterAnglemetrics_; + ElementsInAnnulus,DeltaR,reco::Candidate> PFCandsinAnnulus_innerAngleouterDRmetrics_; + ElementsInEllipse PFCandidatesInEllipse_; }; #endif diff --git a/RecoTauTag/TauTagTools/interface/TauTagTools.h b/RecoTauTag/TauTagTools/interface/TauTagTools.h index 77d44d4deb93c..f4ff96eea726a 100644 --- a/RecoTauTag/TauTagTools/interface/TauTagTools.h +++ b/RecoTauTag/TauTagTools/interface/TauTagTools.h @@ -3,8 +3,8 @@ #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/ParticleFlowReco/interface/PFBlock.h" #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -27,11 +27,11 @@ namespace TauTagTools{ reco::TrackRefVector filteredTracks(const reco::TrackRefVector& theInitialTracks,double tkminPt,int tkminPixelHitsn,int tkminTrackerHitsn,double tkmaxipt,double tkmaxChi2, reco::Vertex pV); reco::TrackRefVector filteredTracks(const reco::TrackRefVector& theInitialTracks,double tkminPt,int tkminPixelHitsn,int tkminTrackerHitsn,double tkmaxipt,double tkmaxChi2,double tktorefpointmaxDZ,reco::Vertex pV,double refpoint_Z); - std::vector filteredPFChargedHadrCandsByNumTrkHits(const std::vector& theInitialPFCands, int ChargedHadrCand_tkminTrackerHitsn); - std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2, reco::Vertex pV); - std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2,double ChargedHadrCand_tktorefpointmaxDZ,reco::Vertex pV, double refpoint_Z); - std::vector filteredPFNeutrHadrCands(const std::vector& theInitialPFCands,double NeutrHadrCand_HcalclusMinEt); - std::vector filteredPFGammaCands(const std::vector& theInitialPFCands,double GammaCand_EcalclusMinEt); + std::vector filteredPFChargedHadrCandsByNumTrkHits(const std::vector& theInitialPFCands, int ChargedHadrCand_tkminTrackerHitsn); + std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2, reco::Vertex pV); + std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2,double ChargedHadrCand_tktorefpointmaxDZ,reco::Vertex pV, double refpoint_Z); + std::vector filteredPFNeutrHadrCands(const std::vector& theInitialPFCands,double NeutrHadrCand_HcalclusMinEt); + std::vector filteredPFGammaCands(const std::vector& theInitialPFCands,double GammaCand_EcalclusMinEt); math::XYZPoint propagTrackECALSurfContactPoint(const MagneticField*,reco::TrackRef); TFormula computeConeSizeTFormula(const std::string& ConeSizeFormula,const char* errorMessage); @@ -41,32 +41,32 @@ namespace TauTagTools{ double computeAngle(const math::XYZVector& vec1, const math::XYZVector& vec2); //MIKE: Sort a reference vector - void sortRefVectorByPt(std::vector&); + void sortRefVectorByPt(std::vector&); //binary predicate classes for sorting a list of indexes corresponding to PFPtrVectors...(as they can't use STL??) class sortRefsByOpeningDistance { public: - sortRefsByOpeningDistance(const math::XYZVector& theAxis, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&), const std::vector& myInputVector):myMetricFunction(ptrToMetricFunction),axis(theAxis),myVector(myInputVector){}; + sortRefsByOpeningDistance(const math::XYZVector& theAxis, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&), const std::vector& myInputVector):myMetricFunction(ptrToMetricFunction),axis(theAxis),myVector(myInputVector){}; bool operator()(uint32_t indexA, uint32_t indexB) { - const reco::PFCandidatePtr candA = myVector.at(indexA); - const reco::PFCandidatePtr candB = myVector.at(indexB); + const reco::CandidatePtr candA = myVector.at(indexA); + const reco::CandidatePtr candB = myVector.at(indexB); return (myMetricFunction(axis, candA->momentum()) < myMetricFunction(axis, candB->momentum())); } private: double (*myMetricFunction)(const math::XYZVector&, const math::XYZVector&); math::XYZVector axis; //axis about which candidates are sorted - const std::vector myVector; + const std::vector myVector; }; class filterChargedAndNeutralsByPt { public: - filterChargedAndNeutralsByPt(double minNeutralPt, double minChargedPt, const std::vector& myInputVector):minNeutralPt_(minNeutralPt),minChargedPt_(minChargedPt),myVector(myInputVector){}; + filterChargedAndNeutralsByPt(double minNeutralPt, double minChargedPt, const std::vector& myInputVector):minNeutralPt_(minNeutralPt),minChargedPt_(minChargedPt),myVector(myInputVector){}; bool operator()(uint32_t candIndex) { - const reco::PFCandidatePtr cand = myVector.at(candIndex); + const reco::CandidatePtr cand = myVector.at(candIndex); bool output = true; unsigned char charge = std::abs(cand->charge()); double thePt = cand->pt(); @@ -79,12 +79,12 @@ namespace TauTagTools{ private: double minNeutralPt_; double minChargedPt_; - const std::vector& myVector; + const std::vector& myVector; }; class refVectorPtSorter { public: - refVectorPtSorter(const std::vector& vec) + refVectorPtSorter(const std::vector& vec) { vec_ = vec; } @@ -102,7 +102,7 @@ namespace TauTagTools{ } private: - std::vector vec_; + std::vector vec_; }; diff --git a/RecoTauTag/TauTagTools/plugins/RecoTauDifferenceAnalyzer.cc b/RecoTauTag/TauTagTools/plugins/RecoTauDifferenceAnalyzer.cc index 58bc127931c84..6ba495a4a68a1 100644 --- a/RecoTauTag/TauTagTools/plugins/RecoTauDifferenceAnalyzer.cc +++ b/RecoTauTag/TauTagTools/plugins/RecoTauDifferenceAnalyzer.cc @@ -46,7 +46,7 @@ RecoTauDifferenceAnalyzer::RecoTauDifferenceAnalyzer( } namespace { - reco::PFJetRef getJetRef(const reco::PFTau& tau) { + reco::JetBaseRef getJetRef(const reco::PFTau& tau) { if (tau.jetRef().isNonnull()) return tau.jetRef(); else if (tau.pfTauTagInfoRef()->pfjetRef().isNonnull()) @@ -80,8 +80,8 @@ bool RecoTauDifferenceAnalyzer::filter( double bestDeltaR = -1; for (size_t iTau2 = 0; iTau2 < taus2->size(); ++iTau2) { reco::PFTauRef tau2(taus2, iTau2); - reco::PFJetRef jet1 = getJetRef(*tau1); - reco::PFJetRef jet2 = getJetRef(*tau2); + reco::JetBaseRef jet1 = getJetRef(*tau1); + reco::JetBaseRef jet2 = getJetRef(*tau2); double deltaRVal = deltaR(jet2->p4(), jet1->p4()); if (bestMatch.isNull() || deltaRVal < bestDeltaR) { bestMatch = tau2; diff --git a/RecoTauTag/TauTagTools/plugins/RecoTauDumper.cc b/RecoTauTag/TauTagTools/plugins/RecoTauDumper.cc index 2b1a3109bc932..67c1e82289320 100644 --- a/RecoTauTag/TauTagTools/plugins/RecoTauDumper.cc +++ b/RecoTauTag/TauTagTools/plugins/RecoTauDumper.cc @@ -18,6 +18,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/TauReco/interface/PFTau.h" +#include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/Candidate/interface/Candidate.h" // Methods to write the different types diff --git a/RecoTauTag/TauTagTools/plugins/RecoTauPiZeroFlattener.cc b/RecoTauTag/TauTagTools/plugins/RecoTauPiZeroFlattener.cc index 5c6fd7c848040..2a4d55278ef67 100644 --- a/RecoTauTag/TauTagTools/plugins/RecoTauPiZeroFlattener.cc +++ b/RecoTauTag/TauTagTools/plugins/RecoTauPiZeroFlattener.cc @@ -61,7 +61,7 @@ RecoTauPiZeroFlattener::produce(edm::Event& evt, const edm::EventSetup& es) { // Loop over the jets and append the pizeros for each jet to our output // collection. BOOST_FOREACH(reco::PFJetRef jetRef, jets) { - const std::vector& pizeros = (*piZeroAssoc)[jetRef]; + const std::vector& pizeros = (*piZeroAssoc)[reco::JetBaseRef(jetRef)]; output->reserve(output->size() + pizeros.size()); output->insert(output->end(), pizeros.begin(), pizeros.end()); } diff --git a/RecoTauTag/TauTagTools/src/PFCandidateStripMerger.cc b/RecoTauTag/TauTagTools/src/PFCandidateStripMerger.cc index 99dbea4e7a867..bdee5a8673ab1 100644 --- a/RecoTauTag/TauTagTools/src/PFCandidateStripMerger.cc +++ b/RecoTauTag/TauTagTools/src/PFCandidateStripMerger.cc @@ -22,7 +22,7 @@ PFCandidateStripMerger::~PFCandidateStripMerger() bool -PFCandidateStripMerger::candidateMatches(const reco::PFCandidatePtr& cand) +PFCandidateStripMerger::candidateMatches(const reco::CandidatePtr& cand) { bool matches = false; for(unsigned int i=0; i < inputPdgIds_.size(); ++i) { @@ -39,12 +39,12 @@ PFCandidateStripMerger::candidateMatches(const reco::PFCandidatePtr& cand) -vector> -PFCandidateStripMerger::mergeCandidates(const vector& candidates) +vector> +PFCandidateStripMerger::mergeCandidates(const vector& candidates) { //Copy the input getting the relevant candidates and sort by pt - vector cands; + vector cands; for(unsigned int i=0;i& candidates if(cands.size()>1) TauTagTools::sortRefVectorByPt(cands); - std::vector> strips; + std::vector> strips; //Repeat while there are still unclusterized gammas while(!cands.empty()) { //save the non associated candidates to a different collection - vector notAssociated; + vector notAssociated; //Create a cluster from the Seed Photon - vector strip; + vector strip; math::XYZTLorentzVector stripVector; strip.push_back(cands.at(0)); stripVector=cands.at(0)->p4(); diff --git a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc index dff1bfa8dd061..614e723fc9b13 100644 --- a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc +++ b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc @@ -17,12 +17,12 @@ using std::string; } void PFTauElementsOperators::setAreaMetricrecoElementsmaxabsEta( double x) {AreaMetric_recoElements_maxabsEta_=x;} -std::vector PFTauElementsOperators::PFCandsInCone(const std::vector& thePFCands,const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ - std::vector theFilteredPFCands; - for (std::vector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) { +std::vector PFTauElementsOperators::PFCandsInCone(const std::vector& thePFCands,const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ + std::vector theFilteredPFCands; + for (std::vector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) { if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand); } - std::vector theFilteredPFCandsInCone; + std::vector theFilteredPFCandsInCone; if (conemetric=="DR"){ theFilteredPFCandsInCone=PFCandsinCone_DRmetric_(myVector,metricDR_,conesize,theFilteredPFCands); }else if(conemetric=="angle"){ @@ -34,59 +34,62 @@ std::vector PFTauElementsOperators::PFCandsInCone(const st double coneangle=theFixedAreaCone(myVector.theta(),myVector.phi(),0,conesize,errorFlag); if (errorFlag!=0)return theFilteredPFCandsInCone; theFilteredPFCandsInCone=PFCandsinCone_Anglemetric_(myVector,metricAngle_,coneangle,theFilteredPFCands); - }else return std::vector(); + }else return std::vector(); return theFilteredPFCandsInCone; } -std::vector PFTauElementsOperators::PFCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ - std::vector theFilteredPFCandsInCone=PFCandsInCone(PFCands_,myVector,conemetric,conesize,minPt); +std::vector PFTauElementsOperators::PFCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ + std::vector theFilteredPFCandsInCone=PFCandsInCone(PFCands_,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; } -std::vector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ - std::vector theFilteredPFCandsInCone=PFCandsInCone(PFChargedHadrCands_,myVector,conemetric,conesize,minPt); +std::vector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ + std::vector theFilteredPFCandsInCone=PFCandsInCone(PFChargedHadrCands_,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; } -std::vector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ - std::vector filteredPFChargedHadrCands; - for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ - TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef(); - if (!PFChargedHadrCand_track)continue; - if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); +std::vector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ + std::vector filteredPFChargedHadrCands; + for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ + const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); + if (pfcand != nullptr) { + TrackRef PFChargedHadrCand_track = pfcand->trackRef(); + if (!PFChargedHadrCand_track)continue; + if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } - std::vector theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt); + std::vector theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; } -std::vector PFTauElementsOperators::PFNeutrHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ - std::vector theFilteredPFCandsInCone=PFCandsInCone(PFNeutrHadrCands_,myVector,conemetric,conesize,minPt); +std::vector PFTauElementsOperators::PFNeutrHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ + std::vector theFilteredPFCandsInCone=PFCandsInCone(PFNeutrHadrCands_,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; } - std::vector PFTauElementsOperators::PFGammaCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ - std::vector theFilteredPFCandsInCone=PFCandsInCone(PFGammaCands_,myVector,conemetric,conesize,minPt); + std::vector PFTauElementsOperators::PFGammaCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{ + std::vector theFilteredPFCandsInCone=PFCandsInCone(PFGammaCands_,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; } // Function to get elements inside ellipse here ... EELL -std::pair, std::vector> PFTauElementsOperators::PFGammaCandsInOutEllipse(const std::vector& PFGammaCands_, const PFCandidate& leadCand_, double rPhi, double rEta, double maxPt) const{ - std::pair,std::vector> myPFGammaCandsInEllipse = PFCandidatesInEllipse_(leadCand_, rPhi, rEta, PFGammaCands_); - std::vector thePFGammaCandsInEllipse = myPFGammaCandsInEllipse.first; - std::vector thePFGammaCandsOutEllipse = myPFGammaCandsInEllipse.second; - std::vector theFilteredPFGammaCandsInEllipse; - for(std::vector::const_iterator iPFGammaCand = thePFGammaCandsInEllipse.begin(); iPFGammaCand != thePFGammaCandsInEllipse.end(); ++iPFGammaCand){ +std::pair, std::vector> PFTauElementsOperators::PFGammaCandsInOutEllipse(const std::vector& PFGammaCands_, const Candidate& leadCand_, double rPhi, double rEta, double maxPt) const{ + std::pair,std::vector> myPFGammaCandsInEllipse = PFCandidatesInEllipse_(leadCand_, rPhi, rEta, PFGammaCands_); + std::vector thePFGammaCandsInEllipse = myPFGammaCandsInEllipse.first; + std::vector thePFGammaCandsOutEllipse = myPFGammaCandsInEllipse.second; + std::vector theFilteredPFGammaCandsInEllipse; + for(std::vector::const_iterator iPFGammaCand = thePFGammaCandsInEllipse.begin(); iPFGammaCand != thePFGammaCandsInEllipse.end(); ++iPFGammaCand){ if((**iPFGammaCand).pt() <= maxPt) theFilteredPFGammaCandsInEllipse.push_back(*iPFGammaCand); else thePFGammaCandsOutEllipse.push_back(*iPFGammaCand); } - std::pair, std::vector> theFilteredPFGammaCandsInOutEllipse(theFilteredPFGammaCandsInEllipse, thePFGammaCandsOutEllipse); + std::pair, std::vector> theFilteredPFGammaCandsInOutEllipse(theFilteredPFGammaCandsInEllipse, thePFGammaCandsOutEllipse); return theFilteredPFGammaCandsInOutEllipse; } // EELL - std::vector PFTauElementsOperators::PFCandsInAnnulus(const std::vector& thePFCands,const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ - std::vector theFilteredPFCands; - for (std::vector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) { + std::vector PFTauElementsOperators::PFCandsInAnnulus(const std::vector& thePFCands,const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ + std::vector theFilteredPFCands; + for (std::vector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) { if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand); } - std::vector theFilteredPFCandsInAnnulus; + std::vector theFilteredPFCandsInAnnulus; if (outercone_metric=="DR"){ if (innercone_metric=="DR"){ theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterDRmetrics_(myVector,metricDR_,innercone_size,metricDR_,outercone_size,theFilteredPFCands); @@ -99,7 +102,7 @@ std::pair, std::vector> double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag); if (errorFlag!=0)return theFilteredPFCandsInAnnulus; theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterDRmetrics_(myVector,metricAngle_,innercone_angle,metricDR_,outercone_size,theFilteredPFCands); - }else return std::vector(); + }else return std::vector(); }else if(outercone_metric=="angle"){ if (innercone_metric=="DR"){ theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterAnglemetrics_(myVector,metricDR_,innercone_size,metricAngle_,outercone_size,theFilteredPFCands); @@ -112,7 +115,7 @@ std::pair, std::vector> double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag); if (errorFlag!=0)return theFilteredPFCandsInAnnulus; theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_size,theFilteredPFCands); - }else return std::vector(); + }else return std::vector(); }else if(outercone_metric=="area"){ int errorFlag=0; FixedAreaIsolationCone theFixedAreaSignalCone; @@ -129,44 +132,47 @@ std::pair, std::vector> double outercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),innercone_angle,outercone_size,errorFlag); if (errorFlag!=0)return theFilteredPFCandsInAnnulus; theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_angle,theFilteredPFCands); - }else return std::vector(); + }else return std::vector(); } return theFilteredPFCandsInAnnulus; } - std::vector PFTauElementsOperators::PFCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ - std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); + std::vector PFTauElementsOperators::PFCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ + std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } - std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ - std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFChargedHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); + std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ + std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFChargedHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } -std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ - std::vector filteredPFChargedHadrCands; - for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ - TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef(); - if (!PFChargedHadrCand_track)continue; - if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); +std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ + std::vector filteredPFChargedHadrCands; + for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ + const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); + if (pfcand != nullptr) { + TrackRef PFChargedHadrCand_track = pfcand->trackRef(); + if (!PFChargedHadrCand_track)continue; + if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } - std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); + std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } - std::vector PFTauElementsOperators::PFNeutrHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ - std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFNeutrHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); + std::vector PFTauElementsOperators::PFNeutrHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ + std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFNeutrHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } - std::vector PFTauElementsOperators::PFGammaCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ - std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); + std::vector PFTauElementsOperators::PFGammaCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{ + std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } -PFCandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; +CandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); - const std::vector theFilteredPFCandsInCone=PFCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); + const std::vector theFilteredPFCandsInCone=PFCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (theFilteredPFCandsInCone.size()>0.){ - for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -175,12 +181,12 @@ PFCandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metr } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; - const std::vector theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); +CandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; + const std::vector theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (!theFilteredPFCandsInCone.empty()){ - for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -189,14 +195,14 @@ PFCandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVecto } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; +CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); - const std::vector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); + const std::vector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (theFilteredPFCandsInCone.size()>0.){ - for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -205,12 +211,12 @@ PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matchi } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; - const std::vector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); +CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; + const std::vector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (!theFilteredPFCandsInCone.empty()){ - for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -219,14 +225,14 @@ PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVect } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; +CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); - const std::vector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); + const std::vector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (theFilteredPFCandsInCone.size()>0.){ - for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -235,12 +241,12 @@ PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matching } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; - const std::vector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); +CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; + const std::vector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (!theFilteredPFCandsInCone.empty()){ - for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -249,14 +255,14 @@ PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; +CandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); - const std::vector theFilteredPFCandsInCone=PFGammaCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); + const std::vector theFilteredPFCandsInCone=PFGammaCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (theFilteredPFCandsInCone.size()>0.){ - for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -265,12 +271,12 @@ PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone } return myleadPFCand; } -PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ - PFCandidatePtr myleadPFCand; - const std::vector theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); +CandidatePtr PFTauElementsOperators::leadPFGammaCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ + CandidatePtr myleadPFCand; + const std::vector theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; if (!theFilteredPFCandsInCone.empty()){ - for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ + for(std::vector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){ if((*iPFCand)->pt()>pt_cut) { myleadPFCand=*iPFCand; pt_cut=(**iPFCand).pt(); @@ -281,9 +287,9 @@ PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const math::XYZVector& my } void -PFTauElementsOperators::copyCandRefsFilteredByPt(const std::vector& theInputCands, std::vector& theOutputCands, const double minPt) +PFTauElementsOperators::copyCandRefsFilteredByPt(const std::vector& theInputCands, std::vector& theOutputCands, const double minPt) { - for(std::vector::const_iterator iPFCand = theInputCands.begin(); + for(std::vector::const_iterator iPFCand = theInputCands.begin(); iPFCand != theInputCands.end(); ++iPFCand) { @@ -295,18 +301,18 @@ PFTauElementsOperators::copyCandRefsFilteredByPt(const std::vector& theChargedCands, const std::vector& theGammaCands, +PFTauElementsOperators::computeInsideOutContents(const std::vector& theChargedCands, const std::vector& theGammaCands, const math::XYZVector& leadTrackVector, const TFormula& coneSizeFormula, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&), const double minChargedSize, const double maxChargedSize, const double minNeutralSize, const double maxNeutralSize, const double minChargedPt, const double minNeutralPt, const string& outlierCollectorConeMetric, const double outlierCollectionMaxSize, - std::vector& signalChargedObjects, std::vector& outlierChargedObjects, - std::vector& signalGammaObjects, std::vector& outlierGammaObjects, bool useScanningAxis) + std::vector& signalChargedObjects, std::vector& outlierChargedObjects, + std::vector& signalGammaObjects, std::vector& outlierGammaObjects, bool useScanningAxis) { if (theChargedCands.empty() && theGammaCands.empty()) return; //copy the vector of PFCands filtering by Pt - std::vector filteredCands; + std::vector filteredCands; filteredCands.reserve(theChargedCands.size() + theGammaCands.size()); copyCandRefsFilteredByPt(theChargedCands, filteredCands, minChargedPt); @@ -327,7 +333,7 @@ PFTauElementsOperators::computeInsideOutContents(const std::vector sortedCands; + std::vector sortedCands; for(std::vector::const_iterator theSortedIndex = filteredCandIndexes.begin(); theSortedIndex != filteredCandIndexes.end(); ++theSortedIndex) @@ -336,7 +342,7 @@ PFTauElementsOperators::computeInsideOutContents(const std::vector::const_iterator signalObjectCandidate = sortedCands.begin(); + std::vector::const_iterator signalObjectCandidate = sortedCands.begin(); double totalEnergySoFar = (**signalObjectCandidate).energy(); double totalEtSoFar = (**signalObjectCandidate).et(); math::XYZVector axisVectorSoFar = leadTrackVector; @@ -387,7 +393,7 @@ PFTauElementsOperators::computeInsideOutContents(const std::vector::const_iterator iterCand = sortedCands.begin(); + for (std::vector::const_iterator iterCand = sortedCands.begin(); iterCand != signalObjectCandidate; ++iterCand) { @@ -435,7 +441,7 @@ PFTauElementsOperators::computeInsideOutContents(const std::vector::const_iterator iterCand = signalObjectCandidate; + for (std::vector::const_iterator iterCand = signalObjectCandidate; iterCand != sortedCands.end(); ++iterCand) { @@ -460,25 +466,25 @@ double PFTauElementsOperators::discriminatorByIsolPFCandsN(int IsolPFCands_maxN) } double PFTauElementsOperators::discriminatorByIsolPFCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){ double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - const std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + const std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){ double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - const std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + const std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1; return myDiscriminator; } @@ -489,25 +495,25 @@ double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(int IsolPF } double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){ double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){ double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1; return myDiscriminator; } @@ -518,25 +524,25 @@ double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(int IsolPFNe } double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){ double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){ double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1; return myDiscriminator; } @@ -547,165 +553,165 @@ double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(int IsolPFGammaC } double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){ double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){ double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(double IsolPFCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - for(std::vector::const_iterator iPFCand=IsolPFCands_.begin();iPFCand!=IsolPFCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + for(std::vector::const_iterator iPFCand=IsolPFCands_.begin();iPFCand!=IsolPFCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(double IsolPFChargedHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - for(std::vector::const_iterator iPFCand=IsolPFChargedHadrCands_.begin();iPFCand!=IsolPFChargedHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + for(std::vector::const_iterator iPFCand=IsolPFChargedHadrCands_.begin();iPFCand!=IsolPFChargedHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFChargedHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFChargedHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(double IsolPFNeutrHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - for(std::vector::const_iterator iPFCand=IsolPFNeutrHadrCands_.begin();iPFCand!=IsolPFNeutrHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + for(std::vector::const_iterator iPFCand=IsolPFNeutrHadrCands_.begin();iPFCand!=IsolPFNeutrHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFNeutrHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFNeutrHadrCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(double IsolPFGammaCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - for(std::vector::const_iterator iPFCand=IsolPFGammaCands_.begin();iPFCand!=IsolPFGammaCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + for(std::vector::const_iterator iPFCand=IsolPFGammaCands_.begin();iPFCand!=IsolPFGammaCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFGammaCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFGammaCands_maxEtSum){ double myIsolPFCandsEtSum=0.; double myDiscriminator=0; - PFCandidatePtr myleadPFCand; + CandidatePtr myleadPFCand; if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; - std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); - for(std::vector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); + std::vector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand); + for(std::vector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et(); if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1; return myDiscriminator; } diff --git a/RecoTauTag/TauTagTools/src/TauTagTools.cc b/RecoTauTag/TauTagTools/src/TauTagTools.cc index 2ceed32cb1dbf..80e8ee3163888 100644 --- a/RecoTauTag/TauTagTools/src/TauTagTools.cc +++ b/RecoTauTag/TauTagTools/src/TauTagTools.cc @@ -1,4 +1,5 @@ #include "RecoTauTag/TauTagTools/interface/TauTagTools.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" using namespace reco; using std::string; @@ -101,64 +102,72 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ return filteredTracks; } - std::vector filteredPFChargedHadrCandsByNumTrkHits(const std::vector& theInitialPFCands, int ChargedHadrCand_tkminTrackerHitsn){ - std::vector filteredPFChargedHadrCands; - for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ - if (PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::h || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::mu || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::e){ + std::vector filteredPFChargedHadrCandsByNumTrkHits(const std::vector& theInitialPFCands, int ChargedHadrCand_tkminTrackerHitsn){ + std::vector filteredPFChargedHadrCands; + for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ + if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - TrackRef PFChargedHadrCand_rectk = (**iPFCand).trackRef(); + const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); + if (pfcand != nullptr) { + TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); - if (!PFChargedHadrCand_rectk)continue; - if ( (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn ) - filteredPFChargedHadrCands.push_back(*iPFCand); + if (!PFChargedHadrCand_rectk)continue; + if ( (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn ) + filteredPFChargedHadrCands.push_back(*iPFCand); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } } return filteredPFChargedHadrCands; } - std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2, Vertex pv){ - std::vector filteredPFChargedHadrCands; - for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ - if (PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::h || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::mu || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::e){ + std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2, Vertex pv){ + std::vector filteredPFChargedHadrCands; + for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ + if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - TrackRef PFChargedHadrCand_rectk = (**iPFCand).trackRef(); + const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); + if (pfcand != nullptr) { + TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); - - if (!PFChargedHadrCand_rectk)continue; - if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && - (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && - fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && - (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn && - (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn) - filteredPFChargedHadrCands.push_back(*iPFCand); + if (!PFChargedHadrCand_rectk)continue; + if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && + (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && + fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && + (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn && + (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn) + filteredPFChargedHadrCands.push_back(*iPFCand); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } } return filteredPFChargedHadrCands; } - std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2,double ChargedHadrCand_tktorefpointmaxDZ,Vertex pv, double refpoint_Z){ + std::vector filteredPFChargedHadrCands(const std::vector& theInitialPFCands,double ChargedHadrCand_tkminPt,int ChargedHadrCand_tkminPixelHitsn,int ChargedHadrCand_tkminTrackerHitsn,double ChargedHadrCand_tkmaxipt,double ChargedHadrCand_tkmaxChi2,double ChargedHadrCand_tktorefpointmaxDZ,Vertex pv, double refpoint_Z){ if(pv.isFake()) ChargedHadrCand_tktorefpointmaxDZ = 30.; - std::vector filteredPFChargedHadrCands; - for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ - if (PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::h || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::mu || PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::e){ + std::vector filteredPFChargedHadrCands; + for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ + if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - TrackRef PFChargedHadrCand_rectk = (**iPFCand).trackRef(); - if (!PFChargedHadrCand_rectk)continue; - if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && - (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && - fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && - (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn && - (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn && - fabs((*PFChargedHadrCand_rectk).dz(pv.position()))<=ChargedHadrCand_tktorefpointmaxDZ) - filteredPFChargedHadrCands.push_back(*iPFCand); + const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); + if (pfcand != nullptr) { + TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); + if (!PFChargedHadrCand_rectk)continue; + if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && + (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && + fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && + (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn && + (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn && + fabs((*PFChargedHadrCand_rectk).dz(pv.position()))<=ChargedHadrCand_tktorefpointmaxDZ) + filteredPFChargedHadrCands.push_back(*iPFCand); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } } return filteredPFChargedHadrCands; } - std::vector filteredPFNeutrHadrCands(const std::vector& theInitialPFCands,double NeutrHadrCand_HcalclusMinEt){ - std::vector filteredPFNeutrHadrCands; - for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ - if (PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::h0){ + std::vector filteredPFNeutrHadrCands(const std::vector& theInitialPFCands,double NeutrHadrCand_HcalclusMinEt){ + std::vector filteredPFNeutrHadrCands; + for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ + if (std::abs((*iPFCand)->pdgId()) == 130){ // *** Whether the neutral hadron candidate will be selected or not depends on its rec. HCAL cluster properties. if ((**iPFCand).et()>=NeutrHadrCand_HcalclusMinEt){ filteredPFNeutrHadrCands.push_back(*iPFCand); @@ -168,10 +177,10 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ return filteredPFNeutrHadrCands; } - std::vector filteredPFGammaCands(const std::vector& theInitialPFCands,double GammaCand_EcalclusMinEt){ - std::vector filteredPFGammaCands; - for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ - if (PFCandidate::ParticleType((**iPFCand).particleId())==PFCandidate::gamma){ + std::vector filteredPFGammaCands(const std::vector& theInitialPFCands,double GammaCand_EcalclusMinEt){ + std::vector filteredPFGammaCands; + for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ + if (std::abs((*iPFCand)->pdgId()) == 22){ // *** Whether the gamma candidate will be selected or not depends on its rec. ECAL cluster properties. if ((**iPFCand).et()>=GammaCand_EcalclusMinEt){ filteredPFGammaCands.push_back(*iPFCand); @@ -239,7 +248,7 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ void - sortRefVectorByPt(std::vector& vec) + sortRefVectorByPt(std::vector& vec) { std::vector indices; @@ -251,7 +260,7 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ std::sort(indices.begin(),indices.end(),sorter); - std::vector sorted; + std::vector sorted; sorted.reserve(vec.size()); for(unsigned int i=0;i Date: Wed, 15 Nov 2017 13:51:47 +0100 Subject: [PATCH 014/686] correct parameter name --- RecoTauTag/Configuration/python/HPSPFTaus_cff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py index dfd139efb349b..578a747f6ea5f 100644 --- a/RecoTauTag/Configuration/python/HPSPFTaus_cff.py +++ b/RecoTauTag/Configuration/python/HPSPFTaus_cff.py @@ -584,7 +584,7 @@ hpsPFTauDiscriminationByIsolationMVArun2v1PWoldDMwLTraw = hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone( mvaName = cms.string("RecoTauTag_tauIdMVAPWoldDMwLTv1"), mvaOpt = cms.string("PWoldDMwLT"), - srcPUcorrPtSum = cms.InputTag('hpsPFTauNeutralIsoPtSumWeight'), + srcNeutralIsoPtSum = cms.InputTag('hpsPFTauNeutralIsoPtSumWeight'), verbosity = cms.int32(0) ) @@ -726,7 +726,7 @@ hpsPFTauDiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw = hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw.clone( mvaName = cms.string("RecoTauTag_tauIdMVAPWdR03oldDMwLTv1"), mvaOpt = cms.string("PWoldDMwLT"), - srcPUcorrPtSum = cms.InputTag('hpsPFTauNeutralIsoPtSumWeightdR03'), + srcNeutralIsoPtSum = cms.InputTag('hpsPFTauNeutralIsoPtSumWeightdR03'), verbosity = cms.int32(0) ) hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT = hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT.clone( From fa59a8859665747126e3408c601358bc1b8776f5 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 11:18:12 +0100 Subject: [PATCH 015/686] Add Michal's configuration files and simple anti-muon discriminator --- .../python/tools/adaptToRunAtMiniAOD.py | 326 ++++++++++++++++++ .../Configuration/test/tauFromMiniAOD.py | 117 +++++++ ...FRecoTauDiscriminationAgainstMuonSimple.cc | 311 +++++++++++++++++ 3 files changed, 754 insertions(+) create mode 100644 RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py create mode 100644 RecoTauTag/Configuration/test/tauFromMiniAOD.py create mode 100644 RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py new file mode 100644 index 0000000000000..e771a2e08a253 --- /dev/null +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -0,0 +1,326 @@ +import FWCore.ParameterSet.Config as cms + +###### +# Tools to adapt Tau sequences to run tau ReReco+PAT at MiniAOD samples +# M. Bluj, NCBJ Warsaw +# based on work of J. Steggemann, CERN +# Created: 9 Nov. 2017 +###### + +##### +def addTauReReco(process): + #PAT + process.load('PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff') + process.load('PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi') + process.selectedPatTaus.cut="pt > 18. && tauID(\'decayModeFindingNewDMs\')> 0.5" #Cut as in MiniAOD + #Tau RECO + process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") + #Task/Sequence for tau rereco + process.miniAODTausTask = cms.Task() + process.miniAODTausTask.add(process.PFTauTask) + #Add PAT Tau modules to miniAODTausTask + process.miniAODTausTask.add(process.makePatTausTask) + process.miniAODTausTask.add(process.selectedPatTaus) + process.miniAODTausSequence = cms.Sequence(process.miniAODTausTask) + #Path with tau rereco (Needed?) + process.TauReco = cms.Path(process.miniAODTausSequence) + +##### +def convertModuleToBaseTau(process, name): + module = getattr(process, name) + module.__dict__['_TypedParameterizable__type'] = module.type_().replace('RecoTau', 'RecoBaseTau') + #MBif hasattr(module, 'PFTauProducer'): + #MB module.PFBaseTauProducer = module.PFTauProducer + #MB # del module.PFTauProducer + if hasattr(module, 'particleFlowSrc'): + module.particleFlowSrc = cms.InputTag("packedPFCandidates", "", "") + if hasattr(module, 'vertexSrc'): + module.vertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') + if hasattr(module, 'qualityCuts') and hasattr(module.qualityCuts, 'primaryVertexSrc'): + module.qualityCuts.primaryVertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') + +##### +def adaptTauToMiniAODReReco(process, reclusterJets=True): + # TRYING TO MAKE THINGS MINIAOD COMPATIBLE, FROM THE START, TO THE END, 1 BY 1 + #print '[adaptTauToMiniAODReReco]: Start' + + jetCollection = 'slimmedJets' + # Add new jet collections if reclustering is demanded + if reclusterJets: + jetCollection = 'patAK4PFJets' + from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets + process.ak4PFJetsPAT = ak4PFJets.clone( + src=cms.InputTag("packedPFCandidates") + ) + # trivial PATJets + from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets + process.patAK4PFJets = _patJets.clone( + jetSource = cms.InputTag("ak4PFJetsPAT"), + addJetCorrFactors = cms.bool(False), + jetCorrFactorsSource = cms.VInputTag(), + addBTagInfo = cms.bool(False), + addDiscriminators = cms.bool(False), + discriminatorSources = cms.VInputTag(), + addAssociatedTracks = cms.bool(False), + addJetCharge = cms.bool(False), + addGenPartonMatch = cms.bool(False), + embedGenPartonMatch = cms.bool(False), + addGenJetMatch = cms.bool(False), + getJetMCFlavour = cms.bool(False), + addJetFlavourInfo = cms.bool(False), + ) + process.miniAODTausTask.add(process.ak4PFJetsPAT) + process.miniAODTausTask.add(process.patAK4PFJets) + + # so this adds all tracks to jet in some deltaR region. we don't have tracks so don't need it :D + # process.ak4PFJetTracksAssociatorAtVertex.jets = cms.InputTag(jetCollection) + + # Remove ak4PFJetTracksAssociatorAtVertex from recoTauCommonSequence + # Remove pfRecoTauTagInfoProducer from recoTauCommonSequence since it uses the jet-track association + # HOWEVER, may use https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookMiniAOD2017#Isolated_Tracks + # probably needs recovery of the two modules above + + + process.recoTauAK4PatJets08Region = cms.EDProducer("RecoTauPatJetRegionProducer", + deltaR = process.recoTauAK4PFJets08Region.deltaR, + maxJetAbsEta = process.recoTauAK4PFJets08Region.maxJetAbsEta, + minJetPt = process.recoTauAK4PFJets08Region.minJetPt, + pfCandAssocMapSrc = cms.InputTag(""), + pfCandSrc = cms.InputTag("packedPFCandidates"), + src = cms.InputTag(jetCollection) + ) + + process.recoTauPileUpVertices.src = cms.InputTag("offlineSlimmedPrimaryVertices") + # Redefine recoTauCommonTask + # with redefined region and PU vertices, and w/o track-to-vertex associator and tauTagInfo (the two latter are probably obsolete and not needed at all) + process.recoTauCommonTask = cms.Task( + process.recoTauAK4PatJets08Region, + process.recoTauPileUpVertices + ) + + # Adapt TauPiZeros producer + process.ak4PFJetsLegacyHPSPiZeros.builders[0].qualityCuts.primaryVertexSrc = cms.InputTag("offlineSlimmedPrimaryVertices") + process.ak4PFJetsLegacyHPSPiZeros.jetSrc = cms.InputTag(jetCollection) + + # Adapt TauChargedHadrons producer + for builder in process.ak4PFJetsRecoTauChargedHadrons.builders: + builder.qualityCuts.primaryVertexSrc = cms.InputTag("offlineSlimmedPrimaryVertices") + if builder.name.value() == 'tracks': #replace plugin based on generalTracks by one based on lostTracks + builder.name = 'lostTracks' + builder.plugin = 'PFRecoTauChargedHadronFromLostTrackPlugin' + builder.srcLostTracks = cms.InputTag("lostTracks") + del builder.srcTracks + process.ak4PFJetsRecoTauChargedHadrons.jetSrc = cms.InputTag(jetCollection) + + # Adapt combinatoricRecoTau producer + convertModuleToBaseTau(process, 'combinatoricRecoTaus') + process.combinatoricRecoTaus.jetRegionSrc = 'recoTauAK4PatJets08Region' + process.combinatoricRecoTaus.jetSrc = jetCollection + # Adapt builders + for builer in process.combinatoricRecoTaus.builders: + builer.plugin = builer.plugin.value().replace('RecoTau', 'RecoBaseTau') + for name,value in builer.parameters_().iteritems(): + if name == 'qualityCuts': + builer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' + elif name == 'pfCandSrc': + builer.pfCandSrc = 'packedPFCandidates' + # Adapt supported modifiers and remove unsupported ones + modifiersToRemove_ = cms.VPSet() + for mod in process.combinatoricRecoTaus.modifiers: + if mod.name.value() == 'elec_rej': + modifiersToRemove_.append(mod) + continue + elif mod.name.value() == 'TTIworkaround': + modifiersToRemove_.append(mod) + continue + mod.plugin = mod.plugin.value().replace('RecoTau', 'RecoBaseTau') + for name,value in mod.parameters_().iteritems(): + if name == 'qualityCuts': + mod.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' + for mod in modifiersToRemove_: + process.combinatoricRecoTaus.modifiers.remove(mod) + #print "\t\t Removing '%s' modifier from 'combinatoricRecoTaus'" %mod.name.value() + + # Adapt tau decay mode finding discrimiantor for the cleaning step + convertModuleToBaseTau(process, 'hpsSelectionDiscriminator') + + # Adapt clean tau producer + convertModuleToBaseTau(process, 'hpsPFTauProducerSansRefs') + # Adapt cleaners + for cleaner in process.hpsPFTauProducerSansRefs.cleaners: + cleaner.plugin = cleaner.plugin.value().replace('RecoTau', 'RecoBaseTau') + + # Adapt piZero unembedder + convertModuleToBaseTau(process, 'hpsPFTauProducer') + + # Adapt classic discriminants + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFindingNewDMs') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFindingOldDMs') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFinding') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseChargedIsolation') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseIsolation') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits') + + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03') + + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits') + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits') + + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone') + + # Adapt isolation sums + convertModuleToBaseTau(process, 'hpsPFTauChargedIsoPtSum') + convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSum') + convertModuleToBaseTau(process, 'hpsPFTauPUcorrPtSum') + convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumWeight') + convertModuleToBaseTau(process, 'hpsPFTauFootprintCorrection') + convertModuleToBaseTau(process, 'hpsPFTauPhotonPtSumOutsideSignalCone') + # Adapt isolation sums (R=0.3) + convertModuleToBaseTau(process, 'hpsPFTauChargedIsoPtSumdR03') + convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumdR03') + convertModuleToBaseTau(process, 'hpsPFTauPUcorrPtSumdR03') + convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumWeightdR03') + convertModuleToBaseTau(process, 'hpsPFTauFootprintCorrectiondR03') + convertModuleToBaseTau(process, 'hpsPFTauPhotonPtSumOutsideSignalConedR03') + + # Redefine tau PV producer + process.hpsPFTauPrimaryVertexProducer.__dict__['_TypedParameterizable__type'] = 'PFBaseTauPrimaryVertexProducer' + process.hpsPFTauPrimaryVertexProducer.PVTag = 'offlineSlimmedPrimaryVertices' + process.hpsPFTauPrimaryVertexProducer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' + process.hpsPFTauPrimaryVertexProducer.packedCandidatesTag = cms.InputTag("packedPFCandidates") + process.hpsPFTauPrimaryVertexProducer.lostCandidatesTag = cms.InputTag("lostTracks") + + # Redefine tau SV producer + process.hpsPFTauSecondaryVertexProducer = cms.EDProducer("PFBaseTauSecondaryVertexProducer", + PFTauTag = cms.InputTag("hpsPFTauProducer") + ) + # Redefine IP producer + process.hpsPFTauTransverseImpactParameters.__dict__['_TypedParameterizable__type'] = 'PFBaseTauTransverseImpactParameters' + + # Adapt MVAIso discriminants (DBoldDMwLT) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw') + for wp in ['VVLoose', 'VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBoldDMwLT'.format(wp)) + # Adapt MVAIso discriminants (DBnewDMwLT) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw') + for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBnewDMwLT'.format(wp)) + # Adapt MVAIso discriminants (PWoldDMwLT) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWoldDMwLTraw') + for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWoldDMwLT'.format(wp)) + # Adapt MVAIso discriminants (PWnewDMwLT) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWnewDMwLTraw') + for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWnewDMwLT'.format(wp)) + # Adapt MVAIso discriminants (DBoldDMwLT, R=0.3) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw') + for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBdR03oldDMwLT'.format(wp)) + # Adapt MVAIso discriminants (PWoldDMwLT, R=0.3) + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw') + for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: + convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWdR03oldDMwLT'.format(wp)) + + # Remove RecoTau producers which are not supported (yet?), i.e. against-e/mu discriminats + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMediumElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByLooseElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6rawElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6VLooseElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6LooseElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6MediumElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6TightElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6VTightElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByDeadECALElectronRejection) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByLooseMuonRejection3) + process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightMuonRejection3) + # add against-mu discriminants which are MiniAOD compatible + process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoBaseTauDiscriminationAgainstMuonSimple", + PFTauProducer = cms.InputTag("hpsPFTauProducer"), + Prediscriminants = process.hpsPFTauDiscriminationByLooseMuonRejection3.Prediscriminants, + HoPMin = cms.double(0.1), #use smaller value that with AOD as raw energy is used + doCaloMuonVeto = cms.bool(False), #do not use it until tuned + srcPatMuons = cms.InputTag("slimmedMuons"), + minPtMatchedMuon = process.hpsPFTauDiscriminationByLooseMuonRejection3.minPtMatchedMuon, + dRmuonMatch = process.hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatch, + dRmuonMatchLimitedToJetArea = process.hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatchLimitedToJetArea, + maskHitsCSC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsCSC, + maskHitsDT = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsDT, + maskHitsRPC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsRPC, + maxNumberOfHitsLast2Stations = process.hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfHitsLast2Stations, + maskMatchesCSC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesCSC, + maskMatchesDT = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesDT, + maskMatchesRPC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesRPC, + maxNumberOfMatches = process.hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfMatches, + maxNumberOfSTAMuons = cms.int32(-1), + maxNumberOfRPCMuons = cms.int32(-1), + verbosity = cms.int32(0) + ) + process.hpsPFTauDiscriminationByTightMuonRejectionSimple = process.hpsPFTauDiscriminationByLooseMuonRejectionSimple.clone( + maxNumberOfHitsLast2Stations = process.hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations + ) + process.miniAODTausTask.add(process.hpsPFTauDiscriminationByLooseMuonRejectionSimple) + process.miniAODTausTask.add(process.hpsPFTauDiscriminationByTightMuonRejectionSimple) + + ##### + # OK NOW COMES PATTY PAT + + # FIXME - check both if this is the OK collection... + process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") + process.tauMatch.matched = cms.InputTag("prunedGenParticles") + + + process.patTaus.__dict__['_TypedParameterizable__type'] = 'PATTauBaseProducer' + convertModuleToBaseTau(process, 'patTaus') + + # Remove unsupported tauIDs + for name, src in process.patTaus.tauIDSources.parameters_().iteritems(): + if name.find('againstElectron') > -1 or name.find('againstMuon') > -1: + delattr(process.patTaus.tauIDSources,name) + # Add MiniAOD specific ones + setattr(process.patTaus.tauIDSources,'againstMuonLooseSimple',cms.InputTag('hpsPFTauDiscriminationByLooseMuonRejectionSimple')) + setattr(process.patTaus.tauIDSources,'againstMuonTightSimple',cms.InputTag('hpsPFTauDiscriminationByTightMuonRejectionSimple')) + + #print '[adaptTauToMiniAODReReco]: Done!' + +##### +def setOutputModule(mode=0): + #mode = 0: store original MiniAOD and new selectedPatTaus + #mode = 1: store original MiniAOD, new selectedPatTaus, and all PFTau products as in AOD (except of unsuported ones) + + import Configuration.EventContent.EventContent_cff as evtContent + output = cms.OutputModule( + 'PoolOutputModule', + fileName=cms.untracked.string('miniAOD_TauReco.root'), + fastCloning=cms.untracked.bool(False), + dataset=cms.untracked.PSet( + dataTier=cms.untracked.string('MINIAODSIM'), + filterName=cms.untracked.string('') + ), + outputCommands = evtContent.MINIAODSIMEventContent.outputCommands, + SelectEvents=cms.untracked.PSet( + SelectEvents=cms.vstring('*',) + ) + ) + output.outputCommands.append('keep *_selectedPatTaus_*_*') + if mode==1: + for prod in evtContent.RecoTauTagAOD.outputCommands: + if prod.find('ElectronRejection') > -1: + continue + if prod.find('MuonRejection') > -1: + continue + output.outputCommands.append(prod) + output.outputCommands.append('keep *_hpsPFTauDiscriminationByLooseMuonRejectionSimple_*_*') + output.outputCommands.append('keep *_hpsPFTauDiscriminationByTightMuonRejectionSimple_*_*') + + return output + +##### diff --git a/RecoTauTag/Configuration/test/tauFromMiniAOD.py b/RecoTauTag/Configuration/test/tauFromMiniAOD.py new file mode 100644 index 0000000000000..a4c478e116b2b --- /dev/null +++ b/RecoTauTag/Configuration/test/tauFromMiniAOD.py @@ -0,0 +1,117 @@ +import FWCore.ParameterSet.Config as cms +###### +# Configuration to run tau ReReco+PAT at MiniAOD samples +# M. Bluj, NCBJ Warsaw +# based on work of J. Steggemann, CERN +# Created: 9 Nov. 2017 +###### + +###### +runSignal=True +#runSignal=False +maxEvents=1000 +#maxEvents=-1 + +# If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is +# built to seed taus (as at RECO), otherwise standard slimmedJets are used +reclusterJets=True +#reclusterJets=False + +#set true for upgrade studies +phase2=False +#phase2=True + +#Output mode +outMode = 0 #store original MiniAOD and new selectedPatTaus +#outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) + +print 'Running Tau reco&id with MiniAOD inputs:' +print '\t Run on signal:', runSignal +print '\t Recluster jets:', reclusterJets +print '\t Use Phase2 settings:', phase2 +print '\t Output mode:', outMode + +##### +from Configuration.StandardSequences.Eras import eras +era = eras.Run2_2017 +if phase2: + era = eras.Phase2_timing +process = cms.Process("TAURECO",era) +process.load("Configuration.StandardSequences.MagneticField_cff") # for CH reco +if not phase2: + process.load("Configuration.Geometry.GeometryRecoDB_cff") +else: + process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') + +##### +readFiles = cms.untracked.vstring() +secFiles = cms.untracked.vstring() +process.source = cms.Source ("PoolSource",fileNames = readFiles, secondaryFileNames = secFiles) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(maxEvents) +) +print '\t Max events:', process.maxEvents.input.value() + +if runSignal: + readFiles.extend( [ + 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/94FC956F-17E1-E711-B672-0025905A60A6.root', + 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', + ] ) +else: + readFiles.extend( [ + 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', + 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', + ] ) + +##### +import RecoTauTag.Configuration.tools.adaptToRunAtMiniAOD as tauAtMiniTools + +##### +tauAtMiniTools.addTauReReco(process) + +##### +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +if not phase2: + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' +else: + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +##### +#mode = 0: store original MiniAOD and new selectedPatTaus +#mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) +process.output = tauAtMiniTools.setOutputModule(mode=outMode) +if runSignal: + process.output.fileName='miniAOD_TauReco_ggH.root' + if reclusterJets: + process.output.fileName='miniAOD_TauReco_ak4PFJets_ggH.root' +else: + process.output.fileName='miniAOD_TauReco_QCD.root' + if reclusterJets: + process.output.fileName='miniAOD_TauReco_ak4PFJets_QCD.root' +process.out = cms.EndPath(process.output) + +##### +tauAtMiniTools.adaptTauToMiniAODReReco(process, reclusterJets) + +##### +process.load('FWCore.MessageService.MessageLogger_cfi') +if process.maxEvents.input.value()>10: + process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10 +if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0: + process.MessageLogger.cerr.FwkReport.reportEvery = 1000 + +##### +process.options = cms.untracked.PSet( +) +process.options.numberOfThreads=cms.untracked.uint32(4) +#process.options.numberOfThreads=cms.untracked.uint32(1) +process.options.numberOfStreams=cms.untracked.uint32(0) +print '\t No. of threads:', process.options.numberOfThreads.value(),', no. of streams:',process.options.numberOfStreams.value() + +process.options = cms.untracked.PSet( + process.options, + wantSummary = cms.untracked.bool(True) +) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc new file mode 100644 index 0000000000000..35045299251c9 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc @@ -0,0 +1,311 @@ +/** \class PFRecoTauDiscriminationAgainstMuonSimple + * + * Compute tau Id. discriminator against muons for MiniAOD. + * + * \author Michal Bluj, NCBJ Warsaw + * based on PFRecoTauDiscriminationAgainstMuon2 by Christian Veelken + * + * Note: it is not granted that information on muon track is/will be always + * accesible with MiniAOD, if not one can consider to veto muons which are + * not only Trk by also STA or RPC muons, i.e. have many (>=2) good muon segments + */ + +#include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" + +#include "FWCore/Utilities/interface/Exception.h" + +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/TrackReco/interface/HitPattern.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/Math/interface/deltaR.h" + +#include +#include +#include + +namespace { + +class PFRecoTauDiscriminationAgainstMuonSimple final : public PFTauDiscriminationProducerBase +{ + public: + explicit PFRecoTauDiscriminationAgainstMuonSimple(const edm::ParameterSet& cfg) + : PFTauDiscriminationProducerBase(cfg), + moduleLabel_(cfg.getParameter("@module_label")) + { + hop_ = cfg.getParameter("HoPMin"); + doCaloMuonVeto_ = cfg.getParameter("doCaloMuonVeto"); + srcPatMuons_ = cfg.getParameter("srcPatMuons"); + Muons_token = consumes(srcPatMuons_); + dRmuonMatch_ = cfg.getParameter("dRmuonMatch"); + dRmuonMatchLimitedToJetArea_ = cfg.getParameter("dRmuonMatchLimitedToJetArea"); + minPtMatchedMuon_ = cfg.getParameter("minPtMatchedMuon"); + maxNumberOfMatches_ = cfg.getParameter("maxNumberOfMatches"); + maxNumberOfHitsLast2Stations_ = cfg.getParameter("maxNumberOfHitsLast2Stations"); + typedef std::vector vint; + maskMatchesDT_ = cfg.getParameter("maskMatchesDT"); + maskMatchesCSC_ = cfg.getParameter("maskMatchesCSC"); + maskMatchesRPC_ = cfg.getParameter("maskMatchesRPC"); + maskHitsDT_ = cfg.getParameter("maskHitsDT"); + maskHitsCSC_ = cfg.getParameter("maskHitsCSC"); + maskHitsRPC_ = cfg.getParameter("maskHitsRPC"); + maxNumberOfSTAMuons_ = cfg.getParameter("maxNumberOfSTAMuons"); + maxNumberOfRPCMuons_ = cfg.getParameter("maxNumberOfRPCMuons"); + + numWarnings_ = 0; + maxWarnings_ = 3; + verbosity_ = cfg.exists("verbosity") ? cfg.getParameter("verbosity") : 0; + } + ~PFRecoTauDiscriminationAgainstMuonSimple() override {} + + void beginEvent(const edm::Event&, const edm::EventSetup&) override; + + double discriminate(const reco::PFTauRef&) const override; + + private: + std::string moduleLabel_; + int discriminatorOption_; + double hop_; + bool doCaloMuonVeto_; + edm::InputTag srcPatMuons_; + edm::Handle muons_; + edm::EDGetTokenT Muons_token; + double dRmuonMatch_; + bool dRmuonMatchLimitedToJetArea_; + double minPtMatchedMuon_; + int maxNumberOfMatches_; + std::vector maskMatchesDT_; + std::vector maskMatchesCSC_; + std::vector maskMatchesRPC_; + int maxNumberOfHitsLast2Stations_; + std::vector maskHitsDT_; + std::vector maskHitsCSC_; + std::vector maskHitsRPC_; + int maxNumberOfSTAMuons_, maxNumberOfRPCMuons_; + + mutable int numWarnings_; + int maxWarnings_; + int verbosity_; +}; + +void PFRecoTauDiscriminationAgainstMuonSimple::beginEvent(const edm::Event& evt, const edm::EventSetup& es) +{ + evt.getByToken(Muons_token, muons_); +} + +namespace +{ + /* MB: not used in current implementation, but keep it if needed in future + const reco::Track* getTrack(const reco::Candidate& cand) { + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if ( pCand != nullptr && pCand->hasTrackDetails() ) + return &pCand->pseudoTrack(); + return nullptr; + } + */ + void countHits(const pat::Muon& muon, std::vector& numHitsDT, std::vector& numHitsCSC, std::vector& numHitsRPC) + { + if ( muon.outerTrack().isNonnull() ) { + const reco::HitPattern &muonHitPattern = muon.outerTrack()->hitPattern(); + for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) { + uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit); + if ( hit == 0 ) break; + if ( muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid || muonHitPattern.getHitType(hit) == TrackingRecHit::bad) ) { + int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3 + if ( muonStation >= 0 && muonStation < 4 ) { + if ( muonHitPattern.muonDTHitFilter(hit) ) ++numHitsDT[muonStation]; + else if ( muonHitPattern.muonCSCHitFilter(hit) ) ++numHitsCSC[muonStation]; + else if ( muonHitPattern.muonRPCHitFilter(hit) ) ++numHitsRPC[muonStation]; + } + } + } + } + } + + void countMatches(const pat::Muon& muon, std::vector& numMatchesDT, std::vector& numMatchesCSC, std::vector& numMatchesRPC) + { + const std::vector& muonSegments = muon.matches(); + for ( std::vector::const_iterator muonSegment = muonSegments.begin(); + muonSegment != muonSegments.end(); ++muonSegment ) { + if ( muonSegment->segmentMatches.empty() ) continue; + int muonDetector = muonSegment->detector(); + int muonStation = muonSegment->station() - 1; + assert(muonStation >= 0 && muonStation <= 3); + if ( muonDetector == MuonSubdetId::DT ) ++numMatchesDT[muonStation]; + else if ( muonDetector == MuonSubdetId::CSC ) ++numMatchesCSC[muonStation]; + else if ( muonDetector == MuonSubdetId::RPC ) ++numMatchesRPC[muonStation]; + } + } + + std::string format_vint(const std::vector& vi) + { + std::ostringstream os; + os << "{ "; + unsigned numEntries = vi.size(); + for ( unsigned iEntry = 0; iEntry < numEntries; ++iEntry ) { + os << vi[iEntry]; + if ( iEntry < (numEntries - 1) ) os << ", "; + } + os << " }"; + return os.str(); + } + +} + +double PFRecoTauDiscriminationAgainstMuonSimple::discriminate(const reco::PFTauRef& pfTau) const +{ + if ( verbosity_ ) { + edm::LogPrint("PFTauAgainstMuonSimple") << ":" ; + edm::LogPrint("PFTauAgainstMuonSimple") << " moduleLabel = " << moduleLabel_ ; + edm::LogPrint("PFTauAgainstMuonSimple") << "tau #" << pfTau.key() << ": Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << ", decay mode = " << pfTau->decayMode() ; + } + + //if (pfTau->decayMode() >= 5) return true; //MB: accept all multi-prongs?? + + const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); + bool passesCaloMuonVeto = true; + if ( pfLeadChargedHadron.isNonnull() ) { + const pat::PackedCandidate* pCand = dynamic_cast(pfLeadChargedHadron.get()); + if ( pCand != nullptr ) { + double rawCaloEnergyFraction = pCand->rawCaloFraction(); + //if ( !(rawCaloEnergyFraction > 0.) ) rawCaloEnergyFraction = 99; //MB: hack against cases when rawCaloEnergyFraction is not stored; it makes performance of the H/P cut rather poor + if ( verbosity_ ) { + edm::LogPrint("PFTauAgainstMuonSimple") << "decayMode = " << pfTau->decayMode() << ", rawCaloEnergy(ECAL+HCAL)Fraction = " << rawCaloEnergyFraction << ", leadPFChargedHadronP = " << pCand->p() << ", leadPFChargedHadron pdgId = " << pCand->pdgId(); + } + if ( pfTau->decayMode() == 0 && rawCaloEnergyFraction < hop_ ) passesCaloMuonVeto = false; + } + } + if ( doCaloMuonVeto_ && !passesCaloMuonVeto ) { + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuonSimple") << "--> CaloMuonVeto failed, returning 0"; + return 0.; + } + + //iterate over muons to find ones to use for discrimination + std::vector muonsToCheck; + size_t numMuons = muons_->size(); + for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) { + bool matched = false; + const pat::MuonRef muon(muons_, idxMuon); + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuonSimple") << "muon #" << muon.key() << ": Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() ; + //firsty check if the muon corrsponds with the leading tau particle + for ( size_t iCand = 0; iCand < muon->numberOfSourceCandidatePtrs(); ++iCand) { + const reco::CandidatePtr& srcCand = muon->sourceCandidatePtr(iCand); + if (srcCand.isNonnull() && pfLeadChargedHadron.isNonnull() && + srcCand.id()==pfLeadChargedHadron.id() && + srcCand.key()==pfLeadChargedHadron.key() ) { + muonsToCheck.push_back(muon.get()); + matched = true; + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuonSimple") << " tau has muonRef." ; + break; + } + } + if (matched) continue; + //check dR matching + if ( !(muon->pt() > minPtMatchedMuon_) ) { + if ( verbosity_ ){ edm::LogPrint("PFTauAgainstMuonSimple") << " fails Pt cut --> skipping it." ;} + continue; + } + double dR = deltaR(muon->p4(), pfTau->p4()); + double dRmatch = dRmuonMatch_; + if ( dRmuonMatchLimitedToJetArea_ ) { + double jetArea = 0.; + if ( pfTau->jetRef().isNonnull() ) jetArea = pfTau->jetRef()->jetArea(); + if ( jetArea > 0. ) { + dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi())); + } else { + if ( numWarnings_ < maxWarnings_ ) { + edm::LogInfo("PFRecoTauDiscriminationAgainstMuonSimple::discriminate") + << "Jet associated to Tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << " has area = " << jetArea << " !!" ; + ++numWarnings_; + } + dRmatch = pfTau->signalConeSize(); + } + dRmatch = TMath::Max(dRmatch,pfTau->signalConeSize()); + if ( dR < dRmatch ) { + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuonSimple") << " overlaps with tau, dR = " << dR ; + muonsToCheck.push_back(muon.get()); + } + } + } + //now examine selected muons + bool pass = true; + std::vector numMatchesDT(4); + std::vector numMatchesCSC(4); + std::vector numMatchesRPC(4); + std::vector numHitsDT(4); + std::vector numHitsCSC(4); + std::vector numHitsRPC(4); + //MB: clear counters of matched segments and hits globally as in the AgainstMuon2 discriminant, but note that they will sum for all matched muons. However it is not likely that there is more than one matched muon. + for ( int iStation = 0; iStation < 4; ++iStation ) { + numMatchesDT[iStation] = 0; + numMatchesCSC[iStation] = 0; + numMatchesRPC[iStation] = 0; + numHitsDT[iStation] = 0; + numHitsCSC[iStation] = 0; + numHitsRPC[iStation] = 0; + } + int numSTAMuons=0, numRPCMuons=0; + if ( verbosity_ && !muonsToCheck.empty() ) edm::LogPrint("PFTauAgainstMuonSimple") << "Muons to check (" << muonsToCheck.size() << "):"; + size_t iMu = 0; + for (const auto &mu: muonsToCheck) { + if ( mu->isStandAloneMuon() ) numSTAMuons++; + if ( mu->muonID("RPCMuLoose") ) numRPCMuons++; + countMatches(*mu, numMatchesDT, numMatchesCSC, numMatchesRPC); + int numStationsWithMatches = 0; + for ( int iStation = 0; iStation < 4; ++iStation ) { + if ( numMatchesDT[iStation] > 0 && !maskMatchesDT_[iStation] ) ++numStationsWithMatches; + if ( numMatchesCSC[iStation] > 0 && !maskMatchesCSC_[iStation] ) ++numStationsWithMatches; + if ( numMatchesRPC[iStation] > 0 && !maskMatchesRPC_[iStation] ) ++numStationsWithMatches; + } + countHits(*mu, numHitsDT, numHitsCSC, numHitsRPC); + int numLast2StationsWithHits = 0; + for ( int iStation = 2; iStation < 4; ++iStation ) { + if ( numHitsDT[iStation] > 0 && !maskHitsDT_[iStation] ) ++numLast2StationsWithHits; + if ( numHitsCSC[iStation] > 0 && !maskHitsCSC_[iStation] ) ++numLast2StationsWithHits; + if ( numHitsRPC[iStation] > 0 && !maskHitsRPC_[iStation] ) ++numLast2StationsWithHits; + } + if ( verbosity_ ) + edm::LogPrint("PFTauAgainstMuonSimple") + << "\t" << iMu << ": Pt = " << mu->pt() << ", eta = " << mu->eta() << ", phi = " << mu->phi() + << "\n\t" + << " isSTA: "<isStandAloneMuon() + << ", isRPCLoose: "<muonID("RPCMuLoose") + << "\n\t numMatchesDT = " << format_vint(numMatchesDT) + << "\n\t numMatchesCSC = " << format_vint(numMatchesCSC) + << "\n\t numMatchesRPC = " << format_vint(numMatchesRPC) + << "\n\t --> numStationsWithMatches = " << numStationsWithMatches + << "\n\t numHitsDT = " << format_vint(numHitsDT) + << "\n\t numHitsCSC = " << format_vint(numHitsCSC) + << "\n\t numHitsRPC = " << format_vint(numHitsRPC) + << "\n\t --> numLast2StationsWithHits = " << numLast2StationsWithHits ; + if ( maxNumberOfMatches_ >= 0 && numStationsWithMatches > maxNumberOfMatches_ ) { + pass = false; + break; + } + if ( maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_ ) { + pass = false; + break; + } + if ( maxNumberOfSTAMuons_ >= 0 && numSTAMuons > maxNumberOfSTAMuons_ ) { + pass = false; + break; + } + if ( maxNumberOfRPCMuons_ >= 0 && numRPCMuons > maxNumberOfRPCMuons_ ) { + pass = false; + break; + } + iMu++; + } + + double discriminatorValue = pass ? 1.: 0.; + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuonSimple") << "--> returning discriminatorValue = " << discriminatorValue ; + + return discriminatorValue; +} + +} + +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonSimple); + From 250ff2d6f04c1c29dd1b3364cc6fc13ba82dd5e6 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 11:34:53 +0100 Subject: [PATCH 016/686] Add tau jet region producer based on PAT Jets --- .../plugins/RecoPatTauJetRegionProducer.cc | 210 ++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc diff --git a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc new file mode 100644 index 0000000000000..049597649c1b3 --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc @@ -0,0 +1,210 @@ +/* + * RecoTauPatJetRegionProducer + * + * Given a set of PFJets, make new jets with the same p4 but collect all the + * PFCandidates from a cone of a given size into the constituents. + * + * Author: Evan K. Friis, UC Davis + * + */ + +#include + +#include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/Common/interface/AssociationMap.h" + +#include "RecoTauTag/RecoTau/interface/ConeTools.h" +#include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include +#include + +class RecoTauPatJetRegionProducer : public edm::stream::EDProducer<> +{ + public: + typedef edm::Association PatJetMatchMap; + typedef edm::AssociationMap, std::vector, unsigned int> > JetToPackedCandidateAssociation; + explicit RecoTauPatJetRegionProducer(const edm::ParameterSet& pset); + ~RecoTauPatJetRegionProducer() override {} + + void produce(edm::Event& evt, const edm::EventSetup& es) override; + + private: + std::string moduleLabel_; + + edm::InputTag inputJets_; + edm::InputTag pfCandSrc_; + edm::InputTag pfCandAssocMapSrc_; + + edm::EDGetTokenT pf_token; + edm::EDGetTokenT Jets_token; + edm::EDGetTokenT pfCandAssocMap_token; + + double minJetPt_; + double maxJetAbsEta_; + double deltaR2_; + + int verbosity_; +}; + +RecoTauPatJetRegionProducer::RecoTauPatJetRegionProducer(const edm::ParameterSet& cfg) + : moduleLabel_(cfg.getParameter("@module_label")) +{ + inputJets_ = cfg.getParameter("src"); + pfCandSrc_ = cfg.getParameter("pfCandSrc"); + pfCandAssocMapSrc_ = cfg.getParameter("pfCandAssocMapSrc"); + + pf_token = consumes(pfCandSrc_); + Jets_token = consumes(inputJets_); + pfCandAssocMap_token = consumes(pfCandAssocMapSrc_); + + double deltaR = cfg.getParameter("deltaR"); + deltaR2_ = deltaR*deltaR; + minJetPt_ = ( cfg.exists("minJetPt") ) ? cfg.getParameter("minJetPt") : -1.0; + maxJetAbsEta_ = ( cfg.exists("maxJetAbsEta") ) ? cfg.getParameter("maxJetAbsEta") : 99.0; + + verbosity_ = ( cfg.exists("verbosity") ) ? + cfg.getParameter("verbosity") : 0; + + produces("jets"); + produces(); +} + +void RecoTauPatJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& es) +{ + if ( verbosity_ ) { + std::cout << ":" << std::endl; + std::cout << " inputJets = " << inputJets_ << std::endl; + std::cout << " pfCandSrc = " << pfCandSrc_ << std::endl; + std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl; + } + + edm::Handle pfCandsHandle; + evt.getByToken(pf_token, pfCandsHandle); + + // Build Ptrs for all the PFCandidates + typedef edm::Ptr PackedCandPtr; + std::vector pfCands; + pfCands.reserve(pfCandsHandle->size()); + for ( size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) { + pfCands.push_back(PackedCandPtr(pfCandsHandle, icand)); + } + + // Get the jets + edm::Handle jetView; + evt.getByToken(Jets_token, jetView); + // Convert to a vector of PFJetRefs + pat::JetRefVector jets = reco::tau::castView(jetView); + size_t nJets = jets.size(); + + // Get the association map matching jets to PFCandidates + // (needed for recinstruction of boosted taus) + edm::Handle jetToPFCandMap; + std::vector > fastJetToPFCandMap; + if ( pfCandAssocMapSrc_.label() != "" ) { + evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); + fastJetToPFCandMap.resize(nJets); + for ( size_t ijet = 0; ijet < nJets; ++ijet ) { + // Get a ref to jet + const pat::JetRef& jetRef = jets[ijet]; + const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef]; + for ( const auto& pfCandMappedToJet : pfCandsMappedToJet ) { + fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key()); + } + } + } + + // Get the original product, so we can match against it - otherwise the + // indices don't match up. + edm::ProductID originalId = jets.id(); + edm::Handle originalJets; + size_t nOriginalJets = 0; + // We have to make sure that we have some selected jets, otherwise we don't + // actually have a valid product ID to the original jets. + if ( nJets ) { + try { + evt.get(originalId, originalJets); + } catch(const cms::Exception &e) { + edm::LogError("MissingOriginalCollection") + << "Can't get the original jets that made: " << inputJets_ + << " that have product ID: " << originalId + << " from the event!!"; + throw e; + } + nOriginalJets = originalJets->size(); + } + + auto newJets = std::make_unique(); + + // Keep track of the indices of the current jet and the old (original) jet + // -1 indicates no match. + std::vector matchInfo(nOriginalJets, -1); + newJets->reserve(nJets); + size_t nNewJets = 0; + for ( size_t ijet = 0; ijet < nJets; ++ijet ) { + // Get a ref to jet + const pat::JetRef& jetRef = jets[ijet]; + if(jetRef->pt() - minJetPt_ < 1e-5) continue; + if(std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5) continue; + // Make an initial copy. + newJets->emplace_back(*jetRef); + pat::Jet& newJet = newJets->back(); + // Clear out all the constituents + newJet.clearDaughters(); + // Loop over all the PFCands + for ( const auto& pfCand : pfCands ) { + bool isMappedToJet = false; + if ( jetToPFCandMap.isValid() ) { + auto temp = jetToPFCandMap->find(jetRef); + if( temp == jetToPFCandMap->end() ) { + edm::LogWarning("WeirdCandidateMap") << "Candidate map for jet " << jetRef.key() << " is empty!"; + continue; + } + isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key()); + } else { + isMappedToJet = true; + } + if ( reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet ) newJet.addDaughter(pfCand); + } + if ( verbosity_ ) { + std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta() << ", phi = " << jetRef->eta() << "," + << " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl; + auto jetConstituents = newJet.daughterPtrVector(); + int idx = 0; + for ( const auto& jetConstituent : jetConstituents) { + std::cout << " constituent #" << idx << ": Pt = " << jetConstituent->pt() << ", eta = " << jetConstituent->eta() << ", phi = " << jetConstituent->phi() << std::endl; + ++idx; + } + } + // Match the index of the jet we just made to the index into the original + // collection. + //matchInfo[jetRef.key()] = ijet; + matchInfo[jetRef.key()] = nNewJets; + nNewJets++; + } + + // Put our new jets into the event + edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); + + // Create a matching between original jets -> extra collection + auto matching = std::make_unique(newJetsInEvent); + if ( nJets ) { + PatJetMatchMap::Filler filler(*matching); + filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); + filler.fill(); + } + evt.put(std::move(matching)); +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(RecoTauPatJetRegionProducer); + From b9f79af82b3a6e6b626d02040569f4c67b45c5b8 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 17:33:34 +0100 Subject: [PATCH 017/686] More adaptions due to changes in PFTau class --- DataFormats/TauReco/src/classes_3.h | 17 ++- DataFormats/TauReco/src/classes_def_3.xml | 14 ++ .../python/tools/adaptToRunAtMiniAOD.py | 125 ++++++++---------- .../RecoTau/interface/RecoTauCrossCleaning.h | 1 - .../RecoTau/interface/RecoTauPiZeroPlugins.h | 4 +- .../plugins/PFRecoTauChargedHadronProducer.cc | 4 +- .../PFRecoTauDiscriminationAgainstElectron.cc | 2 +- .../plugins/RecoPatTauJetRegionProducer.cc | 18 ++- .../plugins/RecoTauJetRegionProducer.cc | 15 ++- .../RecoTauPiZeroCombinatoricPlugin.cc | 4 +- .../RecoTau/plugins/RecoTauPiZeroProducer.cc | 15 +-- .../plugins/RecoTauPiZeroStripPlugin.cc | 4 +- .../plugins/RecoTauPiZeroStripPlugin2.cc | 4 +- .../plugins/RecoTauPiZeroStripPlugin3.cc | 4 +- .../plugins/RecoTauPiZeroTrivialPlugin.cc | 4 +- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 8 +- 16 files changed, 127 insertions(+), 116 deletions(-) diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h index 7c8dcd5ee4165..13ff430c7733c 100644 --- a/DataFormats/TauReco/src/classes_3.h +++ b/DataFormats/TauReco/src/classes_3.h @@ -34,6 +34,8 @@ #include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include #include @@ -242,8 +244,19 @@ namespace DataFormats_TauReco { /* edm::helpers::KeyVal >,edm::RefProd > > jetPFCandidateAssociation_kv; */ /* edm::helpers::KeyVal,reco::PFJet,edm::refhelper::FindUsingAdvance,reco::PFJet> >,edm::RefVector,reco::PFCandidate,edm::refhelper::FindUsingAdvance,reco::PFCandidate> > > jetPFCandidateAssociation_kv2; */ /* std::map,reco::PFJet,edm::refhelper::FindUsingAdvance,reco::PFJet> >,edm::RefVector,reco::PFCandidate,edm::refhelper::FindUsingAdvance,reco::PFCandidate> > > > jetPFCandidateAssociation_mkv; */ - - + // PAT Jet associations, needed for miniAOD-based reconstruction + // JAN - FIXME - this should possibly go into PatCandidates + edm::Association > patjet_assoc_vr; + edm::Wrapper > > patjet_assoc_vr_wrapper; + edm::RefProd > patjet_rp; + edm::AssociationMap,std::vector,unsigned int> >patjet_v_patpc_v_otm_am; + edm::Wrapper,std::vector,unsigned int> > > patjet_v_patpc_v_otm_am_w; + edm::helpers::KeyVal >,edm::RefProd > > patjet_v_patpc_v_kv; + + // Generic association + edm::AssociationMap,edm::View,unsigned int> > v_j_v_j_am; + edm::Wrapper,edm::View,unsigned int> > > v_j_v_j_am_w; + edm::helpers::KeyVal,edm::RefToBaseProd > v_j_v_j_kv; }; } diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index caf8543e15a76..9976659141548 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -237,5 +237,19 @@ + + + + + + + + + + + + + + diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index e771a2e08a253..c419a98ff8fd4 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -26,12 +26,8 @@ def addTauReReco(process): process.TauReco = cms.Path(process.miniAODTausSequence) ##### -def convertModuleToBaseTau(process, name): +def convertModuleToMiniAODInput(process, name): module = getattr(process, name) - module.__dict__['_TypedParameterizable__type'] = module.type_().replace('RecoTau', 'RecoBaseTau') - #MBif hasattr(module, 'PFTauProducer'): - #MB module.PFBaseTauProducer = module.PFTauProducer - #MB # del module.PFTauProducer if hasattr(module, 'particleFlowSrc'): module.particleFlowSrc = cms.InputTag("packedPFCandidates", "", "") if hasattr(module, 'vertexSrc'): @@ -113,17 +109,16 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.ak4PFJetsRecoTauChargedHadrons.jetSrc = cms.InputTag(jetCollection) # Adapt combinatoricRecoTau producer - convertModuleToBaseTau(process, 'combinatoricRecoTaus') + convertModuleToMiniAODInput(process, 'combinatoricRecoTaus') process.combinatoricRecoTaus.jetRegionSrc = 'recoTauAK4PatJets08Region' process.combinatoricRecoTaus.jetSrc = jetCollection # Adapt builders - for builer in process.combinatoricRecoTaus.builders: - builer.plugin = builer.plugin.value().replace('RecoTau', 'RecoBaseTau') - for name,value in builer.parameters_().iteritems(): + for builder in process.combinatoricRecoTaus.builders: + for name,value in builder.parameters_().iteritems(): if name == 'qualityCuts': - builer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' + builder.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' elif name == 'pfCandSrc': - builer.pfCandSrc = 'packedPFCandidates' + builder.pfCandSrc = 'packedPFCandidates' # Adapt supported modifiers and remove unsupported ones modifiersToRemove_ = cms.VPSet() for mod in process.combinatoricRecoTaus.modifiers: @@ -133,7 +128,6 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): elif mod.name.value() == 'TTIworkaround': modifiersToRemove_.append(mod) continue - mod.plugin = mod.plugin.value().replace('RecoTau', 'RecoBaseTau') for name,value in mod.parameters_().iteritems(): if name == 'qualityCuts': mod.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' @@ -142,92 +136,86 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): #print "\t\t Removing '%s' modifier from 'combinatoricRecoTaus'" %mod.name.value() # Adapt tau decay mode finding discrimiantor for the cleaning step - convertModuleToBaseTau(process, 'hpsSelectionDiscriminator') + convertModuleToMiniAODInput(process, 'hpsSelectionDiscriminator') # Adapt clean tau producer - convertModuleToBaseTau(process, 'hpsPFTauProducerSansRefs') - # Adapt cleaners - for cleaner in process.hpsPFTauProducerSansRefs.cleaners: - cleaner.plugin = cleaner.plugin.value().replace('RecoTau', 'RecoBaseTau') + convertModuleToMiniAODInput(process, 'hpsPFTauProducerSansRefs') # Adapt piZero unembedder - convertModuleToBaseTau(process, 'hpsPFTauProducer') + convertModuleToMiniAODInput(process, 'hpsPFTauProducer') # Adapt classic discriminants - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFindingNewDMs') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFindingOldDMs') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByDecayModeFinding') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseChargedIsolation') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseIsolation') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits') - - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03') - - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits') - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits') - - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFindingNewDMs') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFindingOldDMs') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFinding') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseChargedIsolation') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseIsolation') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits') + + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03') + + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits') + + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone') # Adapt isolation sums - convertModuleToBaseTau(process, 'hpsPFTauChargedIsoPtSum') - convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSum') - convertModuleToBaseTau(process, 'hpsPFTauPUcorrPtSum') - convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumWeight') - convertModuleToBaseTau(process, 'hpsPFTauFootprintCorrection') - convertModuleToBaseTau(process, 'hpsPFTauPhotonPtSumOutsideSignalCone') + convertModuleToMiniAODInput(process, 'hpsPFTauChargedIsoPtSum') + convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSum') + convertModuleToMiniAODInput(process, 'hpsPFTauPUcorrPtSum') + convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumWeight') + convertModuleToMiniAODInput(process, 'hpsPFTauFootprintCorrection') + convertModuleToMiniAODInput(process, 'hpsPFTauPhotonPtSumOutsideSignalCone') # Adapt isolation sums (R=0.3) - convertModuleToBaseTau(process, 'hpsPFTauChargedIsoPtSumdR03') - convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumdR03') - convertModuleToBaseTau(process, 'hpsPFTauPUcorrPtSumdR03') - convertModuleToBaseTau(process, 'hpsPFTauNeutralIsoPtSumWeightdR03') - convertModuleToBaseTau(process, 'hpsPFTauFootprintCorrectiondR03') - convertModuleToBaseTau(process, 'hpsPFTauPhotonPtSumOutsideSignalConedR03') + convertModuleToMiniAODInput(process, 'hpsPFTauChargedIsoPtSumdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauPUcorrPtSumdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumWeightdR03') + convertModuleToMiniAODInput(process, 'hpsPFTauFootprintCorrectiondR03') + convertModuleToMiniAODInput(process, 'hpsPFTauPhotonPtSumOutsideSignalConedR03') # Redefine tau PV producer - process.hpsPFTauPrimaryVertexProducer.__dict__['_TypedParameterizable__type'] = 'PFBaseTauPrimaryVertexProducer' process.hpsPFTauPrimaryVertexProducer.PVTag = 'offlineSlimmedPrimaryVertices' process.hpsPFTauPrimaryVertexProducer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' process.hpsPFTauPrimaryVertexProducer.packedCandidatesTag = cms.InputTag("packedPFCandidates") process.hpsPFTauPrimaryVertexProducer.lostCandidatesTag = cms.InputTag("lostTracks") # Redefine tau SV producer - process.hpsPFTauSecondaryVertexProducer = cms.EDProducer("PFBaseTauSecondaryVertexProducer", + process.hpsPFTauSecondaryVertexProducer = cms.EDProducer("PFTauSecondaryVertexProducer", PFTauTag = cms.InputTag("hpsPFTauProducer") ) - # Redefine IP producer - process.hpsPFTauTransverseImpactParameters.__dict__['_TypedParameterizable__type'] = 'PFBaseTauTransverseImpactParameters' # Adapt MVAIso discriminants (DBoldDMwLT) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw') for wp in ['VVLoose', 'VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBoldDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBoldDMwLT'.format(wp)) # Adapt MVAIso discriminants (DBnewDMwLT) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw') for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBnewDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBnewDMwLT'.format(wp)) # Adapt MVAIso discriminants (PWoldDMwLT) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWoldDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWoldDMwLTraw') for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWoldDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWoldDMwLT'.format(wp)) # Adapt MVAIso discriminants (PWnewDMwLT) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWnewDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWnewDMwLTraw') for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWnewDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWnewDMwLT'.format(wp)) # Adapt MVAIso discriminants (DBoldDMwLT, R=0.3) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw') for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBdR03oldDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBdR03oldDMwLT'.format(wp)) # Adapt MVAIso discriminants (PWoldDMwLT, R=0.3) - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw') + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw') for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToBaseTau(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWdR03oldDMwLT'.format(wp)) + convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWdR03oldDMwLT'.format(wp)) # Remove RecoTau producers which are not supported (yet?), i.e. against-e/mu discriminats process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightElectronRejection) @@ -243,7 +231,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByLooseMuonRejection3) process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightMuonRejection3) # add against-mu discriminants which are MiniAOD compatible - process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoBaseTauDiscriminationAgainstMuonSimple", + process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoTauDiscriminationAgainstMuonSimple", PFTauProducer = cms.InputTag("hpsPFTauProducer"), Prediscriminants = process.hpsPFTauDiscriminationByLooseMuonRejection3.Prediscriminants, HoPMin = cms.double(0.1), #use smaller value that with AOD as raw energy is used @@ -278,8 +266,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.tauMatch.matched = cms.InputTag("prunedGenParticles") - process.patTaus.__dict__['_TypedParameterizable__type'] = 'PATTauBaseProducer' - convertModuleToBaseTau(process, 'patTaus') + convertModuleToMiniAODInput(process, 'patTaus') # Remove unsupported tauIDs for name, src in process.patTaus.tauIDSources.parameters_().iteritems(): diff --git a/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h b/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h index 6c8118a7c30c7..c3369eeaee5a9 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCrossCleaning.h @@ -119,7 +119,6 @@ class FilterCandByAbsPdgId { id_(pdgId){}; template bool operator()(const CandCompatiblePtrType& ptr) const { - CandidatePtr pfptr(ptr); return std::abs(ptr->pdgId()) == id_; } private: diff --git a/RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h b/RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h index 057478dfc1854..ce946155d44b9 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h +++ b/RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h @@ -26,7 +26,7 @@ namespace reco { // Forward declarations -class PFJet; +class Jet; class RecoTauPiZero; namespace tau { @@ -41,7 +41,7 @@ class RecoTauPiZeroBuilderPlugin : public RecoTauEventHolderPlugin { RecoTauEventHolderPlugin(pset) {} ~RecoTauPiZeroBuilderPlugin() override {} /// Build a collection of piZeros from objects in the input jet - virtual return_type operator()(const PFJet&) const = 0; + virtual return_type operator()(const Jet&) const = 0; /// Hook called at the beginning of the event. void beginEvent() override {}; }; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 1a080fab6e3ec..4cf21efb80cd2 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -164,9 +164,7 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe if ( !pfJets.empty() ) { - edm::Handle pfJetCollectionHandle; - evt.get(pfJets.id(), pfJetCollectionHandle); - pfJetChargedHadronAssociations = std::make_unique(reco::JetRefBaseProd(pfJetCollectionHandle)); + pfJetChargedHadronAssociations = std::make_unique(reco::JetRefBaseProd(jets)); } else { pfJetChargedHadronAssociations = std::make_unique(); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc index a1ca09943dd58..e8f6aec074f42 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc @@ -119,7 +119,7 @@ double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& theP if (pflch != nullptr) { TrackRef myleadTk; myleadTk = pflch->trackRef(); - math::XYZPointF myleadTkEcalPos = pflch->positionAtECALEntrance(); + const math::XYZPointF& myleadTkEcalPos = pflch->positionAtECALEntrance(); if(myleadTk.isNonnull()) { if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) diff --git a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc index 049597649c1b3..9198442a978b8 100644 --- a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc @@ -22,6 +22,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/makeRefToBaseProdFrom.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -31,7 +32,8 @@ class RecoTauPatJetRegionProducer : public edm::stream::EDProducer<> { public: - typedef edm::Association PatJetMatchMap; + // typedef edm::Association PatJetMatchMap; + typedef edm::AssociationMap > PatJetMatchMap; typedef edm::AssociationMap, std::vector, unsigned int> > JetToPackedCandidateAssociation; explicit RecoTauPatJetRegionProducer(const edm::ParameterSet& pset); ~RecoTauPatJetRegionProducer() override {} @@ -194,13 +196,15 @@ void RecoTauPatJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup // Put our new jets into the event edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); - + // Create a matching between original jets -> extra collection - auto matching = std::make_unique(newJetsInEvent); - if ( nJets ) { - PatJetMatchMap::Filler filler(*matching); - filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); - filler.fill(); + auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); + for (size_t ijet = 0; ijet < nJets; ++ijet) { + // JAN - FIXME - this doesn't look very elegant... + matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); + // PFJetMatchMap::Filler filler(*matching); + // filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); + // filler.fill(); } evt.put(std::move(matching)); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index 67e31689a4716..6553d462c6886 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -32,7 +32,8 @@ class RecoTauJetRegionProducer : public edm::stream::EDProducer<> { public: - typedef edm::Association PFJetMatchMap; + // typedef edm::Association PFJetMatchMap; + typedef edm::AssociationMap > PFJetMatchMap; typedef edm::AssociationMap, std::vector, unsigned int> > JetToPFCandidateAssociation; explicit RecoTauJetRegionProducer(const edm::ParameterSet& pset); ~RecoTauJetRegionProducer() override {} @@ -197,11 +198,13 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); // Create a matching between original jets -> extra collection - auto matching = std::make_unique(newJetsInEvent); - if ( nJets ) { - PFJetMatchMap::Filler filler(*matching); - filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); - filler.fill(); + auto matching = std::make_unique(); + for (size_t ijet = 0; ijet < nJets; ++ijet) { + // JAN - FIXME - this doesn't look very elegant... + matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); + // PFJetMatchMap::Filler filler(*matching); + // filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); + // filler.fill(); } evt.put(std::move(matching)); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc index 93fcdf75147f9..5e3c3456a3f1a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc @@ -30,7 +30,7 @@ class RecoTauPiZeroCombinatoricPlugin : public RecoTauPiZeroBuilderPlugin { explicit RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC); ~RecoTauPiZeroCombinatoricPlugin() override {} // Return type is auto_ptr - return_type operator()(const reco::PFJet& jet) const override; + return_type operator()(const reco::Jet& jet) const override; private: RecoTauQualityCuts qcuts_; @@ -53,7 +53,7 @@ RecoTauPiZeroCombinatoricPlugin::RecoTauPiZeroCombinatoricPlugin( RecoTauPiZeroCombinatoricPlugin::return_type RecoTauPiZeroCombinatoricPlugin::operator()( - const reco::PFJet& jet) const { + const reco::Jet& jet) const { // Get list of gamma candidates typedef std::vector CandPtrs; typedef CandPtrs::const_iterator CandIter; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index 3fb5efbdf2bf6..f450569191a53 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -137,22 +137,15 @@ void RecoTauPiZeroProducer::produce(edm::Event& evt, const edm::EventSetup& es) builder.setup(evt, es); } - // Convert the view to a RefVector of actual PFJets - reco::PFJetRefVector jetRefs = - reco::tau::castView(jetView); // Make our association std::unique_ptr association; - if (!jetRefs.empty()) { - // edm::Handle pfJetCollectionHandle; - // evt.get(jetRefs.id(), pfJetCollectionHandle); - association = std::make_unique(reco::JetRefBaseProd(jetView)); - } else { - association = std::make_unique(); - } + association = std::make_unique(reco::JetRefBaseProd(jetView)); // Loop over our jets - BOOST_FOREACH(const reco::PFJetRef& jet, jetRefs) { + size_t nJets = jetView->size(); + for (size_t i = 0; i < nJets; ++i) { + const reco::JetBaseRef jet(jetView->refAt(i)); if(jet->pt() - minJetPt_ < 1e-5) continue; if(std::abs(jet->eta()) - maxJetAbsEta_ > -1e-5) continue; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc index c9d7217c382f5..f5f53c6e2db86 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin.cc @@ -48,7 +48,7 @@ class RecoTauPiZeroStripPlugin : public RecoTauPiZeroBuilderPlugin { explicit RecoTauPiZeroStripPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC); ~RecoTauPiZeroStripPlugin() override {} // Return type is auto_ptr - return_type operator()(const reco::PFJet& jet) const override; + return_type operator()(const reco::Jet& jet) const override; // Hook to update PV information void beginEvent() override; @@ -94,7 +94,7 @@ void RecoTauPiZeroStripPlugin::beginEvent() { } RecoTauPiZeroStripPlugin::return_type RecoTauPiZeroStripPlugin::operator()( - const reco::PFJet& jet) const { + const reco::Jet& jet) const { // Get list of gamma candidates typedef std::vector CandPtrs; typedef CandPtrs::iterator CandIter; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index 4fc353d1b1654..61618958c313c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -56,7 +56,7 @@ class RecoTauPiZeroStripPlugin2 : public RecoTauPiZeroBuilderPlugin explicit RecoTauPiZeroStripPlugin2(const edm::ParameterSet&, edm::ConsumesCollector &&iC); ~RecoTauPiZeroStripPlugin2() override; // Return type is auto_ptr - return_type operator()(const reco::PFJet&) const override; + return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; @@ -195,7 +195,7 @@ namespace } } -RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(const reco::PFJet& jet) const +RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(const reco::Jet& jet) const { if ( verbosity_ >= 1 ) { edm::LogPrint("RecoTauPiZeroStripPlugin2") << ":" ; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 70ba450ab2e8c..dd839594a0f45 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -59,7 +59,7 @@ class RecoTauPiZeroStripPlugin3 : public RecoTauPiZeroBuilderPlugin explicit RecoTauPiZeroStripPlugin3(const edm::ParameterSet&, edm::ConsumesCollector &&iC); ~RecoTauPiZeroStripPlugin3() override; // Return type is auto_ptr - return_type operator()(const reco::PFJet&) const override; + return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; @@ -219,7 +219,7 @@ namespace } } -RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(const reco::PFJet& jet) const +RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(const reco::Jet& jet) const { if ( verbosity_ >= 1 ) { edm::LogPrint("RecoTauPiZeroStripPlugin3") << ":" ; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc index 82a53effb691a..1e6d61d03107d 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroTrivialPlugin.cc @@ -27,7 +27,7 @@ class RecoTauPiZeroTrivialPlugin : public RecoTauPiZeroBuilderPlugin { public: explicit RecoTauPiZeroTrivialPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector &&iC); ~RecoTauPiZeroTrivialPlugin() override {} - return_type operator()(const reco::PFJet& jet) const override; + return_type operator()(const reco::Jet& jet) const override; private: RecoTauQualityCuts qcuts_; }; @@ -38,7 +38,7 @@ RecoTauPiZeroTrivialPlugin::RecoTauPiZeroTrivialPlugin( "qualityCuts").getParameterSet("signalQualityCuts")) {} RecoTauPiZeroBuilderPlugin::return_type RecoTauPiZeroTrivialPlugin::operator()( - const reco::PFJet& jet) const { + const reco::Jet& jet) const { std::vector pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet)); PiZeroVector output; output.reserve(pfGammaCands.size()); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index 10a084e7858da..eb8e8392800e7 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -64,7 +64,7 @@ class RecoTauProducer : public edm::stream::EDProducer<> double maxJetAbsEta_; //token definition edm::EDGetTokenT jet_token; - edm::EDGetTokenT > jetRegion_token; + edm::EDGetTokenT > > jetRegion_token; edm::EDGetTokenT chargedHadron_token; edm::EDGetTokenT piZero_token; @@ -89,7 +89,7 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter("maxJetAbsEta") : 99.0; //consumes definition jet_token=consumes(jetSrc_); - jetRegion_token = consumes >(jetRegionSrc_); + jetRegion_token = consumes > >(jetRegionSrc_); chargedHadron_token = consumes(chargedHadronSrc_); piZero_token = consumes(piZeroSrc_); @@ -139,7 +139,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // edm::RefToBaseVector jets = reco::tau::castViewToOtherBase>(jetView); // Get the jet region producer - edm::Handle > jetRegionHandle; + edm::Handle > > jetRegionHandle; evt.getByToken(jetRegion_token, jetRegionHandle); // Get the charged hadron input collection @@ -172,7 +172,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // Get the jet with extra constituents from an area around the jet if(jetRef->pt() - minJetPt_ < 1e-5) continue; if(std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5) continue; - reco::PFJetRef jetRegionRef = (*jetRegionHandle)[jetRef]; + reco::JetBaseRef jetRegionRef = (*jetRegionHandle)[jetRef]; if ( jetRegionRef.isNull() ) { throw cms::Exception("BadJetRegionRef") << "No jet region can be found for the current jet: " << jetRef.id(); From 5c5c3383f76c2f6a60d0b0a7f7028ddb7caf0dec Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 9 Feb 2018 17:44:21 +0100 Subject: [PATCH 018/686] More adaptions due to changes in PFTau class --- RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index 6553d462c6886..c8aa0d1eb0aac 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -23,6 +23,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/makeRefToBaseProdFrom.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -194,11 +195,11 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e nNewJets++; } - // Put our new jets into the event + // Put our new jets into the event edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); - + // Create a matching between original jets -> extra collection - auto matching = std::make_unique(); + auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); for (size_t ijet = 0; ijet < nJets; ++ijet) { // JAN - FIXME - this doesn't look very elegant... matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); From 785e783be3cb88ed44b6d59019e048a69139cd7f Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 12 Feb 2018 12:55:02 +0100 Subject: [PATCH 019/686] Adaptions for changes in PFTau data format --- Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc | 2 +- .../IsolationAlgos/plugins/PFTauExtractor.cc | 6 ++-- .../interface/PFMEtSignInterfaceBase.h | 20 ++++++++++-- .../src/PFTauElecRejectionBenchmark.cc | 27 ++++++++++------ .../src/HLTPFTauPairLeadTrackDzMatchFilter.cc | 25 ++++++++++++--- .../plugins/PFTau3ProngReco.cc | 32 ++++++++++++++----- .../RecoTau/interface/TauTagValidation.h | 2 +- Validation/RecoTau/src/TauTagValidation.cc | 4 +-- 8 files changed, 86 insertions(+), 32 deletions(-) diff --git a/Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc b/Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc index a9ccdfe78af24..848782d4dee1c 100644 --- a/Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWPFTauProxyBuilder.cc @@ -63,7 +63,7 @@ FWPFTauProxyBuilder::buildViewType( const FWEventItem* iItem, TEveElementList* p // prepare phi-list and theta range try { const reco::PFTauTagInfo *tauTagInfo = dynamic_cast( (*it).pfTauTagInfoRef().get() ); - const reco::PFJet *jet = dynamic_cast( tauTagInfo->pfjetRef().get() ); + const reco::Jet *jet = tauTagInfo->pfjetRef().get(); m_minTheta = 100; m_maxTheta = -100; std::vector phis; diff --git a/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc b/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc index 0bedd9fe57286..51e2e5019a327 100644 --- a/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc +++ b/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc @@ -4,8 +4,8 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/Math/interface/deltaR.h" @@ -65,7 +65,7 @@ reco::IsoDeposit PFTauExtractor::depositFromObject(const edm::Event& evt, const //--- check that the candidate is not associated to one of the tau decay products // within the signal cone of the PFTau bool isSignalCone = false; - for ( std::vector::const_iterator tauSignalConeConstituent = pfTau_matched->signalPFCands().begin(); + for ( std::vector::const_iterator tauSignalConeConstituent = pfTau_matched->signalPFCands().begin(); tauSignalConeConstituent != pfTau_matched->signalPFCands().end(); ++tauSignalConeConstituent ) { double dR = deltaR(candidate->momentum(), (*tauSignalConeConstituent)->momentum()); if ( dR <= dRvetoPFTauSignalConeConstituents_ ) isSignalCone = true; diff --git a/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h b/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h index abc835232923a..366848b7c8ce3 100755 --- a/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h +++ b/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h @@ -101,11 +101,27 @@ class PFMEtSignInterfaceBase if ( dynamic_cast(particle) != nullptr ) { const pat::Tau* pfTau = dynamic_cast(particle); //std::cout << "tau: pt = " << pt << ", eta = " << eta << ", phi = " << phi << std::endl; - return pfMEtResolution_->evalPFJet(pfTau->pfJetRef().get()); + const reco::PFJet* pfJet = dynamic_cast(pfTau->pfJetRef().get()); + if (pfJet != nullptr) + return pfMEtResolution_->evalPFJet(pfJet); + + const pat::Jet* patJet = dynamic_cast(pfTau->pfJetRef().get()); + if (patJet != nullptr) { + reco::PFJet pfJet(patJet->p4(), patJet->vertex(), patJet->pfSpecific(), patJet->getJetConstituents()); + return pfMEtResolution_->evalPFJet(&pfJet); + } + else throw cms::Exception("addPFMEtSignObjects") + << "Neither PAT jet nor PF Jet in tau object !!\n"; } else if ( dynamic_cast(particle) != nullptr ) { const reco::PFTau* pfTau = dynamic_cast(particle); //std::cout << "tau: pt = " << pt << ", eta = " << eta << ", phi = " << phi << std::endl; - return pfMEtResolution_->evalPFJet(pfTau->jetRef().get()); + const pat::Jet* patJet = dynamic_cast(pfTau->jetRef().get()); + if (patJet != nullptr) { + reco::PFJet pfJet(patJet->p4(), patJet->vertex(), patJet->pfSpecific(), patJet->getJetConstituents()); + return pfMEtResolution_->evalPFJet(&pfJet); + } + else throw cms::Exception("addPFMEtSignObjects") + << "Neither PAT jet nor PF Jet in tau object !!\n"; } else assert(0); } else if ( dynamic_cast(particle) != nullptr || dynamic_cast(particle) != nullptr ) { diff --git a/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc b/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc index e58afd09d181c..56d3a59e4de9a 100644 --- a/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc +++ b/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc @@ -44,6 +44,7 @@ void PFTauElecRejectionBenchmark::write() { } + void PFTauElecRejectionBenchmark::setup( string Filename, string benchmarkLabel, @@ -256,10 +257,13 @@ void PFTauElecRejectionBenchmark::process(edm::Handle mcevt, if ((*thePFTau).et() > minRecoPt_ && std::abs((*thePFTau).eta()) < maxRecoAbsEta_) { // Check if track goes to Ecal crack - TrackRef myleadTk; + reco::TrackRef myleadTk; if(thePFTau->leadPFChargedHadrCand().isNonnull()){ - myleadTk=thePFTau->leadPFChargedHadrCand()->trackRef(); - myleadTkEcalPos = thePFTau->leadPFChargedHadrCand()->positionAtECALEntrance(); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau->leadPFChargedHadrCand().get()); + if (pflch != nullptr) { + myleadTk=pflch->trackRef(); + myleadTkEcalPos = pflch->positionAtECALEntrance(); + } if(myleadTk.isNonnull()){ if (applyEcalCrackCut_ && isInEcalCrack(std::abs((double)myleadTkEcalPos.eta()))) { @@ -321,14 +325,17 @@ void PFTauElecRejectionBenchmark::process(edm::Handle mcevt, } // Loop over all PFCands for cluster plots - std::vector myPFCands=(*thePFTau).pfTauTagInfoRef()->PFCands(); + std::vector myPFCands=(*thePFTau).pfTauTagInfoRef()->PFCands(); for(int i=0;i<(int)myPFCands.size();i++){ - + const reco::PFCandidate* pfCand = dynamic_cast(myPFCands[i].get()); + if (pfCand == nullptr) + continue; + math::XYZPointF candPos; - if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2) // if charged hadron or electron - candPos = myPFCands[i]->positionAtECALEntrance(); + if (std::abs(pfCand->pdgId()) == 211 || std::abs(pfCand->pdgId()) == 11) // if charged hadron or electron + candPos = pfCand->positionAtECALEntrance(); else - candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz()); + candPos = math::XYZPointF(pfCand->px(),pfCand->py(),pfCand->pz()); //double deltaR = ROOT::Math::VectorUtil::DeltaR(myleadTkEcalPos,candPos); double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myleadTkEcalPos,candPos); @@ -336,9 +343,9 @@ void PFTauElecRejectionBenchmark::process(edm::Handle mcevt, double deltaPhiOverQ = deltaPhi/(double)myleadTk->charge(); hpfcand_deltaEta->Fill(deltaEta); - hpfcand_deltaEta_weightE->Fill(deltaEta*myPFCands[i]->ecalEnergy()); + hpfcand_deltaEta_weightE->Fill(deltaEta*pfCand->ecalEnergy()); hpfcand_deltaPhiOverQ->Fill(deltaPhiOverQ); - hpfcand_deltaPhiOverQ_weightE->Fill(deltaPhiOverQ*myPFCands[i]->ecalEnergy()); + hpfcand_deltaPhiOverQ_weightE->Fill(deltaPhiOverQ*pfCand->ecalEnergy()); } diff --git a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc index 9b748f28200ed..ca910692c6fb3 100644 --- a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc +++ b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc @@ -43,6 +43,15 @@ void HLTPFTauPairLeadTrackDzMatchFilter::fillDescriptions(edm::ConfigurationDesc descriptions.add("hltPFTauPairLeadTrackDzMatchFilter",desc); } +inline const reco::Track* getTrack(const reco::Candidate& cand) +{ + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr && pfCandPtr->trackRef().isNonnull()) { + return pfCandPtr->trackRef().get(); + } + return nullptr; +} + bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::EventSetup& es, trigger::TriggerFilterObjectWithRefs& filterproduct) const { using namespace std; @@ -64,23 +73,29 @@ bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::Ev size_t npairs = 0, nfail_dz = 0; if(n_taus > 1) for(size_t t1 = 0; t1 < n_taus; ++t1) { if( taus[t1].leadPFChargedHadrCand().isNull() || - taus[t1].leadPFChargedHadrCand()->trackRef().isNull() || - taus[t1].pt() < tauMinPt_ || + taus[t1].pt() < tauMinPt_ || std::abs(taus[t1].eta() ) > tauMaxEta_ ) continue; + const reco::Track* track1 = getTrack(*taus[t1].leadPFChargedHadrCand()); + if (track1 == nullptr) + continue; + float mindz = 99.f; for(size_t t2 = t1+1; t2 < n_taus; ++t2){ if( taus[t2].leadPFChargedHadrCand().isNull() || - taus[t2].leadPFChargedHadrCand()->trackRef().isNull() || taus[t2].pt() < tauMinPt_ || std::abs(taus[t2].eta() ) > tauMaxEta_ ) continue; + + const reco::Track* track2 = getTrack(*taus[t2].leadPFChargedHadrCand()); + if (track2 == nullptr) + continue; float dr2 = reco::deltaR2(taus[t1].eta(), taus[t1].phi(), taus[t2].eta(), taus[t2].phi() ); - float dz = ( taus[t1].leadPFChargedHadrCand()->trackRef()->vz() - - taus[t2].leadPFChargedHadrCand()->trackRef()->vz() ); + float dz = ( track1->vz() - + track2->vz() ); // skip pairs of taus that are close if ( dr2 < tauMinDR_*tauMinDR_ ) { diff --git a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc index 09563509c0e2c..62f8fb6b12230 100644 --- a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc +++ b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc @@ -36,6 +36,7 @@ #include "DataFormats/Common/interface/RefToBase.h" #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/Association.h" #include "DataFormats/Common/interface/AssociationVector.h" @@ -124,6 +125,23 @@ PFTau3ProngReco::~PFTau3ProngReco(){ } +namespace { + inline const reco::Track* getTrack(const reco::Candidate& cand) + { + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); + else return nullptr; + } + const pat::PackedCandidate* packedCand = dynamic_cast(&cand); + if (packedCand && packedCand->hasTrackDetails()) + return &packedCand->pseudoTrack(); + + return nullptr; + } +} + void PFTau3ProngReco::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ // Obtain Collections edm::ESHandle transTrackBuilder; @@ -209,16 +227,14 @@ void PFTau3ProngReco::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ // use Track Helix std::vector pions; GlobalPoint pvpoint(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z()); - const std::vector > cands = tau->signalPFChargedHadrCands(); - for (std::vector >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) { - if(iter->get()->trackRef().isNonnull()){ - reco::TransientTrack transTrk=transTrackBuilder->build(iter->get()->trackRef()); + const std::vector > cands = tau->signalPFChargedHadrCands(); + for (std::vector >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) { + const reco::Track* track = getTrack(**iter); + if (track != nullptr) { + reco::TransientTrack transTrk=transTrackBuilder->build(*track); pions.push_back(ParticleBuilder::createTrackParticle(transTrk,pvpoint,true,true)); } - else if(iter->get()->gsfTrackRef().isNonnull()){ - //reco::TransientTrack transTrk=transTrackBuilder->build(iter->get()->gsfTrackRef()); - //pions.push_back(ParticleBuilder::CreateTrackParticle(transTrk,pvpoint,true,true)); - } + } TVector3 pv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z()); Chi2VertexFitter chi2v(pions,pv); diff --git a/Validation/RecoTau/interface/TauTagValidation.h b/Validation/RecoTau/interface/TauTagValidation.h index 9806f4578697c..08c28a5474e7c 100644 --- a/Validation/RecoTau/interface/TauTagValidation.h +++ b/Validation/RecoTau/interface/TauTagValidation.h @@ -83,7 +83,7 @@ class TauTagValidation : public DQMEDAnalyzer{ /// label of the current module std::string moduleLabel_; ///sum the transversal momentum of all candidates - double getSumPt(const std::vector > & candidates); + double getSumPt(const std::vector > & candidates); ///get rid of redundant parts to shorten the label bool stripDiscriminatorLabel(const std::string& discriminatorLabel, std::string & newLabel); diff --git a/Validation/RecoTau/src/TauTagValidation.cc b/Validation/RecoTau/src/TauTagValidation.cc index c15ce82fbaa60..fb51eef095ac8 100644 --- a/Validation/RecoTau/src/TauTagValidation.cc +++ b/Validation/RecoTau/src/TauTagValidation.cc @@ -600,9 +600,9 @@ void TauTagValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& }//End of PFTau Collection If Loop } -double TauTagValidation::getSumPt(const std::vector > & candidates ){ +double TauTagValidation::getSumPt(const std::vector > & candidates ){ double sumPt = 0.; - for (std::vector >::const_iterator candidate = candidates.begin(); candidate!=candidates.end(); ++candidate) { + for (std::vector >::const_iterator candidate = candidates.begin(); candidate!=candidates.end(); ++candidate) { sumPt += (*candidate)->pt(); } return sumPt; From 8e10bcf464766f8c1035f7f1e28b9bf5238e4f6a Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 13 Feb 2018 14:17:49 +0100 Subject: [PATCH 020/686] Fix Ptr conversion, and remove unused method from common tau utilities --- DataFormats/PatCandidates/src/Tau.cc | 4 ++-- .../RecoTau/interface/RecoTauCommonUtilities.h | 4 ---- .../RecoTau/src/RecoTauCommonUtilities.cc | 18 ------------------ 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc index 3cf722ee9454e..dafe4e1d5f561 100644 --- a/DataFormats/PatCandidates/src/Tau.cc +++ b/DataFormats/PatCandidates/src/Tau.cc @@ -448,14 +448,14 @@ reco::PFRecoTauChargedHadronRef Tau::leadTauChargedHadronCandidate() const { const reco::PFCandidatePtr convertToPFCandidatePtr(const reco::CandidatePtr& ptr) { const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); if (pf_cand) - return pf_cand->masterClone().castTo >(); + return edm::Ptr(ptr); return reco::PFCandidatePtr(); } std::vector convertPtrVector(const std::vector& cands) { std::vector newSignalPFCands; for (auto& cand : cands) { - const auto& newPtr = cand->masterClone().castTo >(); + const auto& newPtr = edm::Ptr(cand); newSignalPFCands.push_back(newPtr); } return newSignalPFCands; diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index eefb599c9cda8..e8ae7619aeaf5 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -175,10 +175,6 @@ template InputIterator leadPFCand(InputIterator begin, return max_cand; } -std::vector convertPtrVectorToPF(const std::vector& cands); - -std::vector convertPtrVector(const std::vector& cands); - math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField); }} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 186edf162e38c..4e975ad0848ba 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -105,24 +105,6 @@ std::vector pfChargedCands(const reco::Jet& jet, return output; } -std::vector convertPtrVectorToPF(const std::vector& cands) { - std::vector newSignalPFCands; - for (auto& cand : cands) { - const auto& newPtr = cand->masterClone().castTo >(); - newSignalPFCands.push_back(newPtr); - } - return std::move(newSignalPFCands); -} - -std::vector convertPtrVector(const std::vector& cands) { - std::vector newSignalCands; - for (auto& cand : cands) { - const auto& newPtr = cand->masterClone().castTo >(); - newSignalCands.push_back(newPtr); - } - return std::move(newSignalCands); -} - math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField) { const reco::PFCandidate* pfCand = dynamic_cast(part); if (pfCand) From 5f1bf05a209625333ba3faa2a27f082bce220b13 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 13 Feb 2018 17:32:24 +0100 Subject: [PATCH 021/686] Directly construct taus with packed candidate collections filled, if taus are made from packed candidates --- DataFormats/PatCandidates/src/Tau.cc | 79 ++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc index dafe4e1d5f561..a75c85308f781 100644 --- a/DataFormats/PatCandidates/src/Tau.cc +++ b/DataFormats/PatCandidates/src/Tau.cc @@ -3,6 +3,7 @@ #include "DataFormats/PatCandidates/interface/Tau.h" #include "DataFormats/JetReco/interface/GenJet.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include #include @@ -49,7 +50,31 @@ Tau::Tau(const reco::BaseTau & aTau) : { const reco::PFTau * pfTau = dynamic_cast(&aTau); if (pfTau != nullptr){ - pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + // If PFTau is made from PackedCandidates, directly fill slimmed version + // without PFSpecific + const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); + if (pc != nullptr) { + for (const auto& ptr : pfTau->signalPFChargedHadrCands()) + signalChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) + signalNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFGammaCands()) + signalGammaCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) + isolationChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) + isolationNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFGammaCands()) + isolationGammaCandPtrs_.push_back(ptr); + } + else { + pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + } pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); } const reco::CaloTau * caloTau = dynamic_cast(&aTau); @@ -76,7 +101,31 @@ Tau::Tau(const edm::RefToBase & aTauRef) : { const reco::PFTau * pfTau = dynamic_cast(aTauRef.get()); if (pfTau != nullptr){ - pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + // If PFTau is made from PackedCandidates, directly fill slimmed version + // without PFSpecific + const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); + if (pc != nullptr) { + for (const auto& ptr : pfTau->signalPFChargedHadrCands()) + signalChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) + signalNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFGammaCands()) + signalGammaCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) + isolationChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) + isolationNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFGammaCands()) + isolationGammaCandPtrs_.push_back(ptr); + } + else { + pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + } pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); } const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get()); @@ -103,7 +152,31 @@ Tau::Tau(const edm::Ptr & aTauRef) : { const reco::PFTau * pfTau = dynamic_cast(aTauRef.get()); if (pfTau != nullptr){ - pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + // If PFTau is made from PackedCandidates, directly fill slimmed version + // without PFSpecific + const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); + if (pc != nullptr) { + for (const auto& ptr : pfTau->signalPFChargedHadrCands()) + signalChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) + signalNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->signalPFGammaCands()) + signalGammaCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) + isolationChargedHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) + isolationNeutralHadrCandPtrs_.push_back(ptr); + + for (const auto& ptr : pfTau->isolationPFGammaCands()) + isolationGammaCandPtrs_.push_back(ptr); + } + else { + pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); + } pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); } const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get()); From ae507088ea47ec8bf3074e39d4316146968cc8b5 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 15 Feb 2018 14:26:38 +0100 Subject: [PATCH 022/686] Make two-prong track pT cleaner plugin work properly for taus from MiniAOD input --- .../pfRecoTauChargedHadronAuxFunctions.h | 1 + .../plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 21 ----------- .../RecoTauSoftTwoProngTausCleanerPlugin.cc | 4 ++- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 3 +- .../src/pfRecoTauChargedHadronAuxFunctions.cc | 36 +++++++++---------- 5 files changed, 22 insertions(+), 43 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h b/RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h index 0a4e724d64c3b..1c858bbc02807 100644 --- a/RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h +++ b/RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h @@ -7,6 +7,7 @@ namespace reco { namespace tau { + const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron); void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scaleFactor_neutralPFCands = 1.0); reco::Candidate::LorentzVector compChargedHadronP4fromPxPyPz(double, double, double); reco::Candidate::LorentzVector compChargedHadronP4fromPThetaPhi(double, double, double); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 2903d50d8b570..4783d894f9fbf 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -97,27 +97,6 @@ namespace tau.setP4(tauP4_modified); tau.setStatus(-1); } - - const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron) { - // Charged hadron made from track (reco::Track) - RECO/AOD only - if ( chargedHadron.getTrack().isNonnull()) { - return chargedHadron.getTrack().get(); - } - // Get track from chargedPackedCandidate - MINIAOD - const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); - if (chargedPFPCand) { - if (chargedPFPCand->hasTrackDetails()) - return &chargedPFPCand->pseudoTrack(); - } - // Get track from lostTrackPackedCandidate - MINIAOD for charged hadron made from lostTtrack (pat::PackedCandidate) - const pat::PackedCandidate* lostTrackPCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); - if (lostTrackPCand) { - if (lostTrackPCand->hasTrackDetails()) - return &lostTrackPCand->pseudoTrack(); - } - - return nullptr; - } } template diff --git a/RecoTauTag/RecoTau/plugins/RecoTauSoftTwoProngTausCleanerPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauSoftTwoProngTausCleanerPlugin.cc index 6dcd50450b03c..467eab28ada2a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauSoftTwoProngTausCleanerPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauSoftTwoProngTausCleanerPlugin.cc @@ -8,6 +8,7 @@ #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" +#include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" namespace reco { namespace tau { @@ -35,7 +36,8 @@ double RecoTauSoftTwoProngTausCleanerPlugin::operator()(const reco::PFTauRef& ta if ( chargedHadrons.size() == 2 ) { for ( std::vector::const_iterator chargedHadron = chargedHadrons.begin(); chargedHadron != chargedHadrons.end(); ++chargedHadron ) { - if ( !(chargedHadron->getTrack().get() && chargedHadron->getTrack()->pt() > minTrackPt_) ) result += 1.e+3; + const reco::Track* track = getTrackFromChargedHadron(*chargedHadron); + if ( !(track != nullptr && track->pt() > minTrackPt_) ) result += 1.e+3; } } return result; diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index 35b86f7f5405a..b4f0cf841bc7b 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -11,12 +11,11 @@ namespace reco { namespace tau { namespace { - // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. - // JAN FIXME - WE NEED TO SEE WHAT TO DO FOR MINIAOD const reco::Track* getTrack(const Candidate& cand) { const PFCandidate* pfCandPtr = dynamic_cast(&cand); if (pfCandPtr) { + // Get the KF track if it exists. Otherwise, see if PFCandidate has a GSF track. if ( pfCandPtr->trackRef().isNonnull() ) return pfCandPtr->trackRef().get(); else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return pfCandPtr->gsfTrackRef().get(); else return nullptr; diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index 75a63e96e0509..bde272f3c096f 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -8,27 +8,25 @@ namespace reco { namespace tau { -namespace { - const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron) { - // Charged hadron made from track (reco::Track) - RECO/AOD only - if ( chargedHadron.getTrack().isNonnull()) { - return chargedHadron.getTrack().get(); - } - // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist - const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); - if (chargedPFPCand != nullptr) { - if (chargedPFPCand->hasTrackDetails()) - return &chargedPFPCand->pseudoTrack(); - } - const pat::PackedCandidate* lostTrackCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); - if (lostTrackCand != nullptr) { - if (lostTrackCand->hasTrackDetails()) - return &lostTrackCand->pseudoTrack(); - } - return nullptr; +const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& chargedHadron) { + // Charged hadron made from track (reco::Track) - RECO/AOD only + if ( chargedHadron.getTrack().isNonnull()) { + return chargedHadron.getTrack().get(); } + // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist + const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); + if (chargedPFPCand != nullptr) { + if (chargedPFPCand->hasTrackDetails()) + return &chargedPFPCand->pseudoTrack(); + } + const pat::PackedCandidate* lostTrackCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); + if (lostTrackCand != nullptr) { + if (lostTrackCand->hasTrackDetails()) + return &lostTrackCand->pseudoTrack(); + } + return nullptr; } - + void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scaleFactor_neutralPFCands) { double chargedHadronP = 0.; From ca859e0313a5a8f03bdf32cdcbc6bfab2a1b62ea Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 19 Feb 2018 14:35:40 +0100 Subject: [PATCH 023/686] Add ioread rules for changes in PFTau --- DataFormats/TauReco/src/classes_def_2.xml | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 215d418d87585..71aa67f0d2414 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -39,6 +39,79 @@ + + (onfile.leadPFChargedHadrCand_);]]> + + + + (onfile.leadPFNeutralCand_);]]> + + + + (onfile.leadPFCand_);]]> + + + + & cand : onfile.selectedSignalPFCands_) { + selectedSignalPFCands_.push_back(edm::Ptr(cand));} + ]]> + + + + (cand));]]> + + + + (cand));;]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + + + From 2065b6e858b90a78999365182d96e6aaee7d7ac3 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 21 Feb 2018 09:42:42 +0100 Subject: [PATCH 024/686] Add ioread rules for a few changes in data formats --- .../PatCandidates/src/classes_def_objects.xml | 73 +++++++++++++++++++ DataFormats/TauReco/src/classes_def_1.xml | 25 +++++++ DataFormats/TauReco/src/classes_def_2.xml | 12 +++ 3 files changed, 110 insertions(+) diff --git a/DataFormats/PatCandidates/src/classes_def_objects.xml b/DataFormats/PatCandidates/src/classes_def_objects.xml index d798462c2adfc..4d8079ffb86e6 100644 --- a/DataFormats/PatCandidates/src/classes_def_objects.xml +++ b/DataFormats/PatCandidates/src/classes_def_objects.xml @@ -166,6 +166,79 @@ + + (onfile.leadPFChargedHadrCand_);]]> + + + + (onfile.leadPFNeutralCand_);]]> + + + + (onfile.leadPFCand_);]]> + + + + & cand : onfile.selectedSignalPFCands_) { + selectedSignalPFCands_.push_back(edm::Ptr(cand));} + ]]> + + + + (cand));]]> + + + + (cand));;]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + + + diff --git a/DataFormats/TauReco/src/classes_def_1.xml b/DataFormats/TauReco/src/classes_def_1.xml index 6d7ff8ec6411d..c083708d42a9b 100644 --- a/DataFormats/TauReco/src/classes_def_1.xml +++ b/DataFormats/TauReco/src/classes_def_1.xml @@ -43,6 +43,31 @@ + + + + + + (cand));]]> + + + + (cand));]]> + + + + (cand));]]> + + + + (onfile.chargedPFCandidate_);]]> + + + + (cand));]]> + + + From 99a3384c25bd8c8c17f5a500fda0f58dec62b91f Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 27 Feb 2018 15:56:49 +0100 Subject: [PATCH 025/686] Cleanup following tau code review --- .../TauReco/src/PFRecoTauChargedHadron.cc | 17 --------------- DataFormats/TauReco/src/classes_3.h | 1 - .../interface/RecoTauCommonUtilities.h | 21 +------------------ ...coTauChargedHadronFromPFCandidatePlugin.cc | 13 ------------ .../plugins/PFRecoTauChargedHadronProducer.cc | 2 -- .../plugins/RecoPatTauJetRegionProducer.cc | 4 ---- .../plugins/RecoTauJetRegionProducer.cc | 4 ---- .../plugins/RecoTauPiZeroStripPlugin2.cc | 4 +--- .../plugins/RecoTauPiZeroStripPlugin3.cc | 7 ++++--- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 7 +------ RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 2 -- 11 files changed, 7 insertions(+), 75 deletions(-) diff --git a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc index efad92a86e34f..be50d24d05472 100644 --- a/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc +++ b/DataFormats/TauReco/src/PFRecoTauChargedHadron.cc @@ -74,23 +74,6 @@ bool PFRecoTauChargedHadron::algoIs(PFRecoTauChargedHadron::PFRecoTauChargedHadr return (algo_ == algo); } -namespace -{ - // JAN - FIXME - can still use this to print out based on PDG ID - // std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) - // { - // if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; - // else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; - // else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; - // else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; - // else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; - // else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; - // else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; - // else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; - // else assert(0); - // } -} - void PFRecoTauChargedHadron::print(std::ostream& stream) const { stream << " Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi() << " (mass = " << this->mass() << ")" << std::endl; diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h index 13ff430c7733c..a86b5e3ea52bf 100644 --- a/DataFormats/TauReco/src/classes_3.h +++ b/DataFormats/TauReco/src/classes_3.h @@ -246,7 +246,6 @@ namespace DataFormats_TauReco { /* std::map,reco::PFJet,edm::refhelper::FindUsingAdvance,reco::PFJet> >,edm::RefVector,reco::PFCandidate,edm::refhelper::FindUsingAdvance,reco::PFCandidate> > > > jetPFCandidateAssociation_mkv; */ // PAT Jet associations, needed for miniAOD-based reconstruction - // JAN - FIXME - this should possibly go into PatCandidates edm::Association > patjet_assoc_vr; edm::Wrapper > > patjet_assoc_vr_wrapper; edm::RefProd > patjet_rp; diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index e8ae7619aeaf5..f74a9daa5a347 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -53,7 +53,7 @@ filterPFCandidates(const Iterator& begin, const Iterator& end, } /// Extract pfCandidates of a given particle Id from a PFJet. If sort is true, -/// candidates will be sorted by descending PT. Internall translates to pdgId +/// candidates will be sorted by descending PT. Internally translates to pdgId std::vector pfCandidates(const Jet& jet, int particleId, bool sort=true); @@ -102,25 +102,6 @@ RefVectorType castView(const edm::Handle& view) { } -/// Convert a BaseView (View) to a TRefToBaseVector -template -RefVectorType castViewToOtherBase(const edm::Handle& view) { - typedef typename RefVectorType::value_type OutputRef; - // Double check at compile time that the inheritance is okay. It can still - // fail at runtime if you pass it the wrong collection. - BOOST_STATIC_ASSERT( - (boost::is_base_of::value)); - RefVectorType output; - size_t nElements = view->size(); - // output.reserve(nElements); - // Cast each of our Refs - for (size_t i = 0; i < nElements; ++i) { - output.push_back(view->refAt(i).template castTo()); - } - return output; -} - /* *Given a range over a container of type C, return a new 'end' iterator such *that at max elements are taken. If there are less than N elements in the diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 8182aa9dc26ff..1a9e51c093c36 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -130,19 +130,6 @@ void PFRecoTauChargedHadronFromPFCandidatePlugin::beginEvent() namespace { - // std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) - // { - // if ( pfCandidateType == reco::PFCandidate::X ) return "undefined"; - // else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron"; - // else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron"; - // else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon"; - // else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma"; - // else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron"; - // else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had"; - // else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em"; - // else assert(0); - // } - bool isMatchedByBlockElement(const reco::PFCandidate& pfCandidate1, const reco::PFCandidate& pfCandidate2, int minMatches1, int minMatches2, int maxUnmatchedBlockElements1plus2) { reco::PFCandidate::ElementsInBlocks blockElements1 = pfCandidate1.elementsInBlocks(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 4cf21efb80cd2..7c55ed24792b1 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -256,8 +256,6 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe if ( nextChargedHadron->algoIs(reco::PFRecoTauChargedHadron::kPFNeutralHadron) ) { for ( std::set::const_iterator neutralPFCandInCleanCollection = neutralPFCandsInCleanCollection.begin(); neutralPFCandInCleanCollection != neutralPFCandsInCleanCollection.end(); ++neutralPFCandInCleanCollection ) { - // JAN - FIXME - this should be fine according to the documentation but need to double-check - // if ( neutralPFCandInCleanCollection->id() == nextChargedHadron->getChargedPFCandidate().id() ) if ( (*neutralPFCandInCleanCollection) == nextChargedHadron->getChargedPFCandidate() ) isNeutralPFCand_overlap = true; } diff --git a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc index 9198442a978b8..42c89d5754ed0 100644 --- a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc @@ -200,11 +200,7 @@ void RecoTauPatJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup // Create a matching between original jets -> extra collection auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); for (size_t ijet = 0; ijet < nJets; ++ijet) { - // JAN - FIXME - this doesn't look very elegant... matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); - // PFJetMatchMap::Filler filler(*matching); - // filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); - // filler.fill(); } evt.put(std::move(matching)); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index c8aa0d1eb0aac..e57963cf3c376 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -201,11 +201,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e // Create a matching between original jets -> extra collection auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); for (size_t ijet = 0; ijet < nJets; ++ijet) { - // JAN - FIXME - this doesn't look very elegant... matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); - // PFJetMatchMap::Filler filler(*matching); - // filler.insert(originalJets, matchInfo.begin(), matchInfo.end()); - // filler.fill(); } evt.put(std::move(matching)); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index 61618958c313c..d723149254a7f 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -179,8 +179,6 @@ namespace candFlags[*candId] = true; } } - - // JAN - FIXME - this method is needed multiple times inline const reco::TrackBaseRef getTrack(const Candidate& cand) { @@ -190,7 +188,7 @@ namespace else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); else return reco::TrackBaseRef(); } - // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index dd839594a0f45..df6b52c4158b8 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -204,8 +204,9 @@ namespace } } - // JAN - FIXME - this method is needed multiple times - + // The following method has not been adapted to work with PackedCandidates, + // however, it is only used for printing/debugging and can be adapted when + // needed. inline const reco::TrackBaseRef getTrack(const Candidate& cand) { const PFCandidate* pfCandPtr = dynamic_cast(&cand); @@ -214,7 +215,7 @@ namespace else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); else return reco::TrackBaseRef(); } - // JAN - FIXME: Add method for miniAOD PackedCandidate + return reco::TrackBaseRef(); } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index eb8e8392800e7..73fa286faa78d 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -132,12 +132,7 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) // Get the jet input collection via a view of Candidates edm::Handle jetView; evt.getByToken(jet_token, jetView); - - // Convert to a vector of PFJetRefs - // reco::PFJetRefVector jets = reco::tau::castView(jetView); - // edm::RefVector> jets = reco::tau::castView>>(jetView); - // edm::RefToBaseVector jets = reco::tau::castViewToOtherBase>(jetView); - + // Get the jet region producer edm::Handle > > jetRegionHandle; evt.getByToken(jetRegion_token, jetRegionHandle); diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index 3906f94a5da79..40a97e5da4ff2 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -117,8 +117,6 @@ namespace for ( std::vector::const_iterator pfGamma = pfGammas.begin(); pfGamma != pfGammas.end(); ++pfGamma ) { LogDebug("TauConstructorCheckOverlap") << "pfGamma = " << pfGamma->id() << ":" << pfGamma->key(); - // JAN - FIXME - double-check that id() equality is fine! - // lhs.refCore() == rhs.refCore() && lhs.key() == rhs.key() ??? if ( (*pfGamma).refCore() == neutral.refCore() && (*pfGamma).key() == neutral.key() ) isUnique = false; } } From 5294f0eda4dfbc99ebdf3d98e9f847c69c0bbe31 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 28 Feb 2018 17:10:03 +0100 Subject: [PATCH 026/686] Add specific tau PV producer for taus produced from MiniAOD input (based on work by Michal Bluj), and adapt MiniAOD tau sequence accordingly --- RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py | 5 +++++ RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index c419a98ff8fd4..ee5916eac72bc 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -182,6 +182,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): convertModuleToMiniAODInput(process, 'hpsPFTauPhotonPtSumOutsideSignalConedR03') # Redefine tau PV producer + process.hpsPFTauPrimaryVertexProducer.__dict__['_TypedParameterizable__type'] = 'PFTauMiniAODPrimaryVertexProducer' process.hpsPFTauPrimaryVertexProducer.PVTag = 'offlineSlimmedPrimaryVertices' process.hpsPFTauPrimaryVertexProducer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' process.hpsPFTauPrimaryVertexProducer.packedCandidatesTag = cms.InputTag("packedPFCandidates") @@ -298,6 +299,10 @@ def setOutputModule(mode=0): ) ) output.outputCommands.append('keep *_selectedPatTaus_*_*') + output.outputCommands.append('keep *_combinatoricReco*_*_*') + output.outputCommands.append('keep *_ak4PFJetsRecoTauChargedHadrons_*_*') + output.outputCommands.append('keep *_ak4PFJetsLegacyHPSPiZeros_*_*') + output.outputCommands.append('keep *_patAK4PFJets_*_*') if mode==1: for prod in evtContent.RecoTauTagAOD.outputCommands: if prod.find('ElectronRejection') > -1: diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 1f54d12498def..62c4516d9b148 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -195,12 +195,7 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ - // Use two signal track collections: One with Refs for taus made from PFCandidates, - // and one with pointers for taus made from PackedCandidates std::vector SignalTracks; - // std::vector SignalTrackPtrs; - // JAN - FIXME - THIS NEEDS TO BE CHANGED WITH MICHAL'S ADAPTIONS - for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < Tau->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ reco::PFTauRef RefPFTau(Tau, jPFTau); From c9aab9642b012fb0e0b681c119df95046a5fb447 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 1 Mar 2018 11:32:21 +0100 Subject: [PATCH 027/686] Add specific tau PV producer for taus produced from MiniAOD input (based on work by Michal Bluj), and adapt MiniAOD tau sequence accordingly --- .../PFTauMiniAODPrimaryVertexProducer.cc | 334 ++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc new file mode 100644 index 0000000000000..e9d11146ff18e --- /dev/null +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -0,0 +1,334 @@ +/* class PFTauMiniAODPrimaryVertexProducer + * EDProducer of the + * authors: Ian M. Nugent + * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus. + * The idea of the fully reconstructing the tau using a kinematic fit comes from + * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This + * work was continued by Ian M. Nugent and Vladimir Cherepanov. + * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions. + */ + + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" +#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" +#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" + +#include "DataFormats/TauReco/interface/PFTau.h" +#include "DataFormats/TauReco/interface/PFTauFwd.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" +#include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/PatCandidates/interface/Electron.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Common/interface/AssociationVector.h" +#include "DataFormats/Common/interface/RefProd.h" + +#include "DataFormats/TauReco/interface/PFTauDiscriminator.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include +#include +#include + +#include + +using namespace reco; +using namespace edm; +using namespace std; + +class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> { + public: + enum Alg{useInputPV=0, useFontPV}; + + struct DiscCutPair{ + DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} + ~DiscCutPair(){delete cutFormula_;} + const reco::PFTauDiscriminator* discr_; + edm::EDGetTokenT inputToken_; + double cut_; + TFormula* cutFormula_; + }; + typedef std::vector DiscCutPairVec; + + explicit PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet& iConfig); + ~PFTauMiniAODPrimaryVertexProducer() override; + void produce(edm::Event&,const edm::EventSetup&) override; + + private: + edm::EDGetTokenT > PFTauToken_; + edm::EDGetTokenT > ElectronToken_; + edm::EDGetTokenT > MuonToken_; + edm::EDGetTokenT PVToken_; + edm::EDGetTokenT beamSpotToken_; + edm::EDGetTokenT > packedCandsToken_, lostCandsToken_; + int Algorithm_; + edm::ParameterSet qualityCutsPSet_; + bool useBeamSpot_; + bool useSelectedTaus_; + bool removeMuonTracks_; + bool removeElectronTracks_; + DiscCutPairVec discriminators_; + std::auto_ptr > cut_; + std::auto_ptr vertexAssociator_; +}; + +PFTauMiniAODPrimaryVertexProducer::PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet& iConfig): + PFTauToken_(consumes >(iConfig.getParameter("PFTauTag"))), + ElectronToken_(consumes >(iConfig.getParameter("ElectronTag"))), + MuonToken_(consumes >(iConfig.getParameter("MuonTag"))), + PVToken_(consumes(iConfig.getParameter("PVTag"))), + beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), + packedCandsToken_(consumes >(iConfig.getParameter("packedCandidatesTag"))), + lostCandsToken_(consumes >(iConfig.getParameter("lostCandidatesTag"))), + Algorithm_(iConfig.getParameter("Algorithm")), + qualityCutsPSet_(iConfig.getParameter("qualityCuts")), + useBeamSpot_(iConfig.getParameter("useBeamSpot")), + useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), + removeMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), + removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) +{ + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + std::vector discriminators =iConfig.getParameter >("discriminators"); + // Build each of our cuts + BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) { + DiscCutPair* newCut = new DiscCutPair(); + newCut->inputToken_ =consumes(pset.getParameter("discriminator")); + + if ( pset.existsAs("selectionCut") ) newCut->cutFormula_ = new TFormula("selectionCut", pset.getParameter("selectionCut").data()); + else newCut->cut_ = pset.getParameter("selectionCut"); + discriminators_.push_back(newCut); + } + // Build a string cut if desired + if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + produces > >(); + produces("PFTauPrimaryVertices"); + + vertexAssociator_.reset(new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); +} + +PFTauMiniAODPrimaryVertexProducer::~PFTauMiniAODPrimaryVertexProducer(){} + +namespace { + const reco::Track* getTrack(const reco::Candidate& cand) { + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if (pCand && pCand->hasTrackDetails()) + return &pCand->pseudoTrack(); + return nullptr; + } +} + +void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ + // Obtain Collections + edm::ESHandle transTrackBuilder; + iSetup.get().get("TransientTrackBuilder",transTrackBuilder); + + edm::Handle > Tau; + iEvent.getByToken(PFTauToken_,Tau); + + edm::Handle > Electron; + iEvent.getByToken(ElectronToken_,Electron); + + edm::Handle > Mu; + iEvent.getByToken(MuonToken_,Mu); + + edm::Handle PV; + iEvent.getByToken(PVToken_,PV); + + edm::Handle beamSpot; + iEvent.getByToken(beamSpotToken_,beamSpot); + + edm::Handle > packedCands; + iEvent.getByToken(packedCandsToken_, packedCands); + + edm::Handle > lostCands; + iEvent.getByToken(lostCandsToken_, lostCands); + + // Set Association Map + auto AVPFTauPV = std::make_unique>>(PFTauRefProd(Tau)); + auto VertexCollection_out = std::make_unique(); + reco::VertexRefProd VertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); + + // Load each discriminator + BOOST_FOREACH(DiscCutPair *disc, discriminators_) { + edm::Handle discr; + iEvent.getByToken(disc->inputToken_, discr); + disc->discr_ = &(*discr); + } + + // Set event for VerexAssociator if needed + if(useInputPV==Algorithm_) + vertexAssociator_->setEvent(iEvent); + + // For each Tau Run Algorithim + if(Tau.isValid()){ + for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) { + reco::PFTauRef tau(Tau, iPFTau); + reco::Vertex thePV; + size_t thePVkey = 0; + if(useInputPV==Algorithm_){ + reco::VertexRef thePVRef = vertexAssociator_->associatedVertex(*tau); + thePV = *thePVRef; + thePVkey = thePVRef.key(); + } + else if(useFontPV==Algorithm_){ + thePV=PV->front(); + thePVkey = 0; + } + /////////////////////// + // Check if it passed all the discrimiantors + bool passed(true); + BOOST_FOREACH(const DiscCutPair* disc, discriminators_) { + // Check this discriminator passes + bool passedDisc = true; + if ( disc->cutFormula_ )passedDisc = (disc->cutFormula_->Eval((*disc->discr_)[tau]) > 0.5); + else passedDisc = ((*disc->discr_)[tau] > disc->cut_); + if ( !passedDisc ){passed = false; break;} + } + if (passed && cut_.get()){passed = (*cut_)(*tau);} + if (passed){ + std::vector SignalTracks; + for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < Tau->size(); jPFTau++) { + if(useSelectedTaus_ || iPFTau==jPFTau){ + reco::PFTauRef RefPFTau(Tau, jPFTau); + /////////////////////////////////////////////////////////////////////////////////////////////// + // Get tracks from PFTau daugthers + const std::vector cands = RefPFTau->signalPFChargedHadrCands(); + for(std::vector::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter){ + if((*iter).isNull()) continue; + const reco::Track* track = getTrack(**iter); + if(track == nullptr) continue; + SignalTracks.push_back(track); + } + } + } + // Get Muon tracks + if(removeMuonTracks_){ + + if(Mu.isValid()) { + for(pat::MuonCollection::size_type iMuon = 0; iMuon< Mu->size(); iMuon++){ + pat::MuonRef RefMuon(Mu, iMuon); + if(RefMuon->track().isNonnull()) SignalTracks.push_back(RefMuon->track().get()); + } + } + } + // Get Electron Tracks + if(removeElectronTracks_){ + if(Electron.isValid()) { + for(pat::ElectronCollection::size_type iElectron = 0; iElectronsize(); iElectron++){ + pat::ElectronRef RefElectron(Electron, iElectron); + if(RefElectron->gsfTrack().isNonnull()) SignalTracks.push_back(RefElectron->gsfTrack().get()); + } + } + } + /////////////////////////////////////////////////////////////////////////////////////////////// + // Get Non-Tau tracks + std::vector nonTauTracks; + //PackedCandidates first... + if(packedCands.isValid()) { + //Find candidates/tracks associated to thePV + for(size_t iCand=0; iCandsize(); ++iCand){ + if((*packedCands)[iCand].vertexRef().isNull()) continue; + int quality = (*packedCands)[iCand].pvAssociationQuality(); + if((*packedCands)[iCand].vertexRef().key()!=thePVkey || + (quality!=pat::PackedCandidate::UsedInFitTight && + quality!=pat::PackedCandidate::UsedInFitLoose)) continue; + const reco::Track* track = getTrack((*packedCands)[iCand]); + if(track == nullptr) continue; + //Remove signal (tau) tracks + //MB: Only deltaR deltaPt overlap removal possible (?) + //MB: It should be fine as pat objects stores same track info with same presision + bool skipTrack = false; + for(size_t iSigTrk=0 ; iSigTrketa(),SignalTracks[iSigTrk]->phi(), + track->eta(),track->phi())<0.005*0.005 + && std::abs(SignalTracks[iSigTrk]->pt()/track->pt()-1.)<0.005 + ){ + skipTrack = true; + break; + } + } + if(skipTrack) continue; + nonTauTracks.push_back(track); + } + } + //then lostCandidates + if(lostCands.isValid()) { + //Find candidates/tracks associated to thePV + for(size_t iCand=0; iCandsize(); ++iCand){ + if((*lostCands)[iCand].vertexRef().isNull()) continue; + int quality = (*lostCands)[iCand].pvAssociationQuality(); + if((*lostCands)[iCand].vertexRef().key()!=thePVkey || + (quality!=pat::PackedCandidate::UsedInFitTight && + quality!=pat::PackedCandidate::UsedInFitLoose)) continue; + const reco::Track* track = getTrack((*lostCands)[iCand]); + if(track == nullptr) continue; + //Remove signal (tau) tracks + //MB: Only deltaR deltaPt overlap removal possible (?) + //MB: It should be fine as pat objects stores same track info with same presision + bool skipTrack = false; + for(size_t iSigTrk=0 ; iSigTrketa(),SignalTracks[iSigTrk]->phi(), + track->eta(),track->phi())<0.005*0.005 + && std::abs(SignalTracks[iSigTrk]->pt()/track->pt()-1.)<0.005 + ){ + skipTrack = true; + break; + } + } + if(skipTrack) continue; + nonTauTracks.push_back(track); + } + } + /////////////////////////////////////////////////////////////////////////////////////////////// + // Refit the vertex + TransientVertex transVtx; + std::vector transTracks; + for(size_t iTrk=0 ; iTrkbuild(*(nonTauTracks[iTrk]))); + } + bool FitOk(true); + if ( transTracks.size() >= 2 ) { + AdaptiveVertexFitter avf; + avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception + try { + if ( !useBeamSpot_ ){ + transVtx = avf.vertex(transTracks); + } else { + transVtx = avf.vertex(transTracks, *beamSpot); + } + } catch (...) { + FitOk = false; + } + } else FitOk = false; + if ( FitOk ) thePV = transVtx; + } + VertexRef VRef = reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()); + VertexCollection_out->push_back(thePV); + AVPFTauPV->setValue(iPFTau, VRef); + } + } + iEvent.put(std::move(VertexCollection_out),"PFTauPrimaryVertices"); + iEvent.put(std::move(AVPFTauPV)); +} + +DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); \ No newline at end of file From 9abe1a1eb4b5aaff1ed28f6c7f833db591aa06e5 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 1 Mar 2018 11:35:14 +0100 Subject: [PATCH 028/686] Add specific tau PV producer for taus produced from MiniAOD input (based on work by Michal Bluj), and adapt MiniAOD tau sequence accordingly --- .../python/tools/adaptToRunAtMiniAOD.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index ee5916eac72bc..7c50bca0df8c4 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -260,9 +260,8 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.miniAODTausTask.add(process.hpsPFTauDiscriminationByTightMuonRejectionSimple) ##### - # OK NOW COMES PATTY PAT + # PAT part in the following - # FIXME - check both if this is the OK collection... process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") process.tauMatch.matched = cms.InputTag("prunedGenParticles") @@ -282,7 +281,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): ##### def setOutputModule(mode=0): #mode = 0: store original MiniAOD and new selectedPatTaus - #mode = 1: store original MiniAOD, new selectedPatTaus, and all PFTau products as in AOD (except of unsuported ones) + #mode = 1: store original MiniAOD, new selectedPatTaus, and all PFTau products as in AOD (except of unsuported ones), plus a few additional collections (charged hadrons, pi zeros, combinatoric reco taus) import Configuration.EventContent.EventContent_cff as evtContent output = cms.OutputModule( @@ -299,10 +298,6 @@ def setOutputModule(mode=0): ) ) output.outputCommands.append('keep *_selectedPatTaus_*_*') - output.outputCommands.append('keep *_combinatoricReco*_*_*') - output.outputCommands.append('keep *_ak4PFJetsRecoTauChargedHadrons_*_*') - output.outputCommands.append('keep *_ak4PFJetsLegacyHPSPiZeros_*_*') - output.outputCommands.append('keep *_patAK4PFJets_*_*') if mode==1: for prod in evtContent.RecoTauTagAOD.outputCommands: if prod.find('ElectronRejection') > -1: @@ -312,6 +307,10 @@ def setOutputModule(mode=0): output.outputCommands.append(prod) output.outputCommands.append('keep *_hpsPFTauDiscriminationByLooseMuonRejectionSimple_*_*') output.outputCommands.append('keep *_hpsPFTauDiscriminationByTightMuonRejectionSimple_*_*') + output.outputCommands.append('keep *_combinatoricReco*_*_*') + output.outputCommands.append('keep *_ak4PFJetsRecoTauChargedHadrons_*_*') + output.outputCommands.append('keep *_ak4PFJetsLegacyHPSPiZeros_*_*') + output.outputCommands.append('keep *_patAK4PFJets_*_*') return output From f15e59d671e6f4533b40de84c628299249c6bef6 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 1 Mar 2018 18:03:39 +0100 Subject: [PATCH 029/686] Fill additional information also for taus built from MiniAOD input --- PhysicsTools/PatAlgos/plugins/PATTauProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index da10a8638b5cb..ffe0780965280 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -371,7 +371,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup } // extraction of variables needed to rerun MVA isolation and anti-electron discriminator on MiniAOD - if( aTau.isPFTau() ) { + if( !aTau.pfEssential_.empty() ) { edm::Handle pfTaus; iEvent.getByToken(pfTauToken_, pfTaus); reco::PFTauRef pfTauRef(pfTaus, idx); From c6437da931ec6bb70975c7e2ff35970a14b6527e Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 7 Mar 2018 00:19:46 +0100 Subject: [PATCH 030/686] added whitespace in template definition --- RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc index 47014e7c32c92..ae129d358d7f7 100644 --- a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc @@ -26,7 +26,7 @@ HPSPFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& tagInfo,const Vertex& v pfTaus_.clear(); //make the strips globally. - std::vector> strips = candidateMerger_->mergeCandidates(tagInfo->PFCands()); + std::vector > strips = candidateMerger_->mergeCandidates(tagInfo->PFCands()); //Sort the hadrons globally and once! From 907147bad784d39140521f3a37c5aa3ffe9eadf9 Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 7 Mar 2018 00:19:59 +0100 Subject: [PATCH 031/686] new test file --- RecoTauTag/Configuration/test/ZTT-validation.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/Configuration/test/ZTT-validation.txt b/RecoTauTag/Configuration/test/ZTT-validation.txt index 85f6d7773f55b..e2c47481b2f98 100644 --- a/RecoTauTag/Configuration/test/ZTT-validation.txt +++ b/RecoTauTag/Configuration/test/ZTT-validation.txt @@ -1,2 +1,3 @@ #/store/relval/CMSSW_9_2_2/RelValProdTTbar_13/AODSIM/91X_mcRun2_asymptotic_v3-v1/10000/EEB99F74-DA4D-E711-A41C-0025905A48F2.root -/store/relval/CMSSW_10_0_0_pre1/RelValTTbar_13/GEN-SIM-RECO/94X_mc2017_realistic_v10-v1/10000/5873841C-9DCB-E711-8E9F-0CC47A7C357A.root +#/store/relval/CMSSW_10_0_0_pre1/RelValTTbar_13/GEN-SIM-RECO/94X_mc2017_realistic_v10-v1/10000/5873841C-9DCB-E711-8E9F-0CC47A7C357A.root +/store/relval/CMSSW_10_1_0_pre1/RelValTTbar_13/GEN-SIM-RECO/PUpmx25ns_100X_upgrade2018_realistic_v10-v1/20000/2AA898A5-9713-E811-8471-0CC47A4D7636.root From 1379757c8877831204d25f7d07dbd1a75fef617a Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 7 Mar 2018 13:04:33 +0100 Subject: [PATCH 032/686] adding cfg as initial test file for tau reco based on miniAOD --- .../RecoTau/test/rerunTauRecoOnMiniAOD.py | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py new file mode 100644 index 0000000000000..4c8207829304d --- /dev/null +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -0,0 +1,119 @@ +import FWCore.ParameterSet.Config as cms +###### +# Configuration to run tau ReReco+PAT at MiniAOD samples +# M. Bluj, NCBJ Warsaw +# based on work of J. Steggemann, CERN +# Created: 9 Nov. 2017 +###### + +###### +runSignal=True +#runSignal=False +maxEvents=1000 +#maxEvents=-1 + +# If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is +# built to seed taus (as at RECO), otherwise standard slimmedJets are used +reclusterJets=True +#reclusterJets=False + +#set true for upgrade studies +phase2=False +#phase2=True + +#Output mode +outMode = 0 #store original MiniAOD and new selectedPatTaus +#outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) + +print 'Running Tau reco&id with MiniAOD inputs:' +print '\t Run on signal:', runSignal +print '\t Recluster jets:', reclusterJets +print '\t Use Phase2 settings:', phase2 +print '\t Output mode:', outMode + +##### +from Configuration.StandardSequences.Eras import eras +era = eras.Run2_2017 +if phase2: + era = eras.Phase2_timing +process = cms.Process("TAURECO",era) +process.load("Configuration.StandardSequences.MagneticField_cff") # for CH reco +if not phase2: + process.load("Configuration.Geometry.GeometryRecoDB_cff") +else: + process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') + +##### +readFiles = cms.untracked.vstring() +secFiles = cms.untracked.vstring() +process.source = cms.Source ("PoolSource",fileNames = readFiles, secondaryFileNames = secFiles) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(maxEvents) +) +print '\t Max events:', process.maxEvents.input.value() + +if runSignal: + readFiles.extend( [ + 'file:patMiniAOD_standard.root' + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/94FC956F-17E1-E711-B672-0025905A60A6.root', + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', + ] ) +else: + readFiles.extend( [ + 'file:patMiniAOD_standard.root' + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', + ] ) + +##### +import RecoTauTag.Configuration.tools.adaptToRunAtMiniAOD as tauAtMiniTools + +##### +tauAtMiniTools.addTauReReco(process) + +##### +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +if not phase2: + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' +else: + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +##### +#mode = 0: store original MiniAOD and new selectedPatTaus +#mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) +process.output = tauAtMiniTools.setOutputModule(mode=outMode) +if runSignal: + process.output.fileName='miniAOD_TauReco_ggH.root' + if reclusterJets: + process.output.fileName='miniAOD_TauReco_ak4PFJets_ggH.root' +else: + process.output.fileName='miniAOD_TauReco_QCD.root' + if reclusterJets: + process.output.fileName='miniAOD_TauReco_ak4PFJets_QCD.root' +process.out = cms.EndPath(process.output) + +##### +tauAtMiniTools.adaptTauToMiniAODReReco(process, reclusterJets) + +##### +process.load('FWCore.MessageService.MessageLogger_cfi') +if process.maxEvents.input.value()>10: + process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10 +if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0: + process.MessageLogger.cerr.FwkReport.reportEvery = 1000 + +##### +process.options = cms.untracked.PSet( +) +process.options.numberOfThreads=cms.untracked.uint32(4) +#process.options.numberOfThreads=cms.untracked.uint32(1) +process.options.numberOfStreams=cms.untracked.uint32(0) +print '\t No. of threads:', process.options.numberOfThreads.value(),', no. of streams:',process.options.numberOfStreams.value() + +process.options = cms.untracked.PSet( + process.options, + wantSummary = cms.untracked.bool(True) +) From b77fdcadb4ad1f83452e001730bf700b04e846a5 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 12 Mar 2018 15:22:02 +0100 Subject: [PATCH 033/686] Fix muon-tau overlap removal --- .../RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index c1650c2afc4fa..20ceac68ae576 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -200,9 +200,10 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); if (pflch != nullptr) { reco::MuonRef muonRef = pflch->muonRef(); - if (muonRef.isNonnull() && muon == pflch->muonRef() ) - if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; } - continue; + if (muonRef.isNonnull() && muon == pflch->muonRef() ) { + if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; } + continue; + } } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } double dR = deltaR(muon->p4(), pfTau->p4()); From 413e8fb8bfe9c553d103576f4e87a0c5d6552057 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 12 Mar 2018 15:34:53 +0100 Subject: [PATCH 034/686] Update/remove comments for tau reco at MiniAOD --- RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h | 2 +- .../PFRecoTauChargedHadronFromPFCandidatePlugin.cc | 8 +++----- .../RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 3 +-- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 1 - RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc | 5 ++--- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index b85942885c3c5..cd60de7d4ce5f 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -53,7 +53,7 @@ class TauIdMVAAuxiliaries { EcalEnInSignalPFCands += pfcand->ecalEnergy(); HcalEnInSignalPFCands += pfcand->hcalEnergy(); } - // JAN - FIXME: not calculated for PackedCandidate + // TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content } float total = EcalEnInSignalPFCands + HcalEnInSignalPFCands; if(total == 0.){ diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 1a9e51c093c36..cf71e592938b0 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -186,7 +186,6 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF else algo = PFRecoTauChargedHadron::kPFNeutralHadron; std::auto_ptr chargedHadron(new PFRecoTauChargedHadron(**cand, algo)); - // JAN - work on this. This must be adapted carefully to MiniAOD packed candidates const reco::PFCandidate* pfCand = dynamic_cast(&**cand); if (pfCand) { if ( pfCand->trackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->trackRef()); @@ -194,9 +193,8 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->globalTrack()); else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->outerTrack()); else if ( pfCand->gsfTrackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->gsfTrackRef()); - - - } + } // TauReco@MiniAOD: Tracks only available dynamically, so no possiblity to save ref here; checked by code downstream + chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand, bField_); chargedHadron->chargedPFCandidate_ = (*cand); chargedHadron->addDaughter(*cand); @@ -238,7 +236,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_; minMergeEt = minMergeGammaEt_; } - // JAN - FIXME - block matching possible in miniAOD? probably not?? but is it important after all? + // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact const reco::PFCandidate* pfCHCand = dynamic_cast(&*chargedHadron->chargedPFCandidate_); const reco::PFCandidate* pfJetConstituent = dynamic_cast(&**jetConstituent); if (pfCHCand && pfJetConstituent) { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 4783d894f9fbf..5ec9c6679d4b2 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -337,8 +337,7 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const << " HCAL = " << (pfCand)->hcalEnergy() << "," << " HO = " << (pfCand)->hoEnergy() << std::endl; } - // JAN - FIXME - this info is not readily available in miniAOD - // This means this sub-algo is currently broken + // TauReco@MiniAOD: This info is not yet available in miniAOD. if ( edm::isFinite(pfCand->ecalEnergy()) ) allNeutralsSumEn += pfCand->ecalEnergy(); if ( edm::isFinite(pfCand->hcalEnergy()) ) allNeutralsSumEn += pfCand->hcalEnergy(); if ( edm::isFinite(pfCand->hoEnergy()) ) allNeutralsSumEn += pfCand->hoEnergy(); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index 73fa286faa78d..693e6e287cc8c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -203,7 +203,6 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) builder != builders_.end(); ++builder) { // Get a ptr_vector of taus from the builder reco::tau::RecoTauBuilderPlugin::output_type taus((*builder)(jetRef, chargedHadrons, piZeros, uniqueRegionalCands)); - // JAN - convert reco::Jet ref to PFJet ref (only in direct interaction with PFTau) // Make sure all taus have their jetref set correctly std::for_each(taus.begin(), taus.end(), boost::bind(&reco::PFTau::setjetRef, _1, reco::JetBaseRef(jetRef))); diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 152069f0933f5..8177d2d0ea5ed 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -34,6 +34,8 @@ namespace { inline const reco::TrackBaseRef getTrackRef(const Candidate& cand) { + // TauReco@MiniAOD: This version does not work on top of MiniAOD, however, + // it is only used for non-default track-vertex associations const PFCandidate* pfCandPtr = dynamic_cast(&cand); if (pfCandPtr != nullptr) { if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); @@ -41,9 +43,6 @@ namespace { else return reco::TrackBaseRef(); } - // FIXME - JAN - should put an error message somewhere that we use an algo that - // is not supported for PackedCandidates - return reco::TrackBaseRef(); } } From 95d5cef4bfb9212344f0e271830c873d84445145 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 12 Mar 2018 15:44:17 +0100 Subject: [PATCH 035/686] Remove commented code, and update comments related to tau reco at MiniAOD --- .../PatAlgos/plugins/PATTauProducer.cc | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index ffe0780965280..7628094347860 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -408,16 +408,13 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup else{ const pat::PackedCandidate* packedCandPtr = dynamic_cast(it.get()); if(packedCandPtr != nullptr) { - //position at ECAL entrance can be recomputed, but individual ECAL and HCAL energies not - //ecalEnergy += packedCandPtr->ecalEnergy(); - //hcalEnergy += packedCandPtr->hcalEnergy(); - //sumPhiTimesEnergy += packedCandPtr->positionAtECALEntrance().phi()*packedCandPtr->energy(); - //sumEtaTimesEnergy += packedCandPtr->positionAtECALEntrance().eta()*packedCandPtr->energy(); + // TauReco@MiniAOD: individual ECAL and HCAL energies currently not available for PackedCandidates + // (see above implementation for PFCandidates). + // Should be added if available, as well as on-the-fly computation of position at ECAL entrance sumEnergy += packedCandPtr->energy(); const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; if( track != nullptr ) { if( track->pt() > leadChargedCandPt ) { - //leadChargedCandEtaAtEcalEntrance = packedCandPtr->positionAtECALEntrance().eta(); leadChargedCandPt = track->pt(); } } @@ -473,32 +470,10 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup else { const pat::PackedCandidate* packedCandPtr = dynamic_cast(leadingPFCharged.get()); if (packedCandPtr != nullptr) { - //individual ECAL and HCAL energies not available with packedCandPtridates - //ecalEnergyLeadChargedHadrCand = packedCandPtr->ecalEnergy(); - //hcalEnergyLeadChargedHadrCand = packedCandPtr->hcalEnergy(); + // TauReco@MiniAOD: Update code below if ecal/hcal energies are available. const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; if (track != nullptr) { leadingTrackNormChi2 = track->normalizedChi2(); - //individual ECAL and HCAL energies not available with packedCandidates - /* - for(const auto& tauIt : pfTauRef->isolationPFCands()){ - const pat::PackedCandidate* packedPtr = dynamic_cast(tauIt.get()); - if(packedPtr != nullptr) { - myHCALenergy += packedPtr->hcalEnergy(); - myECALenergy += packedPtr->ecalEnergy(); - } - } - for(const auto& tauIt : pfTauRef->signalPFCands()){ - const pat::PackedCandidate* packedPtr = dynamic_cast(tauIt.get()); - if(packedPtr != nullptr) { - myHCALenergy += packedPtr->hcalEnergy(); - myECALenergy += packedPtr->ecalEnergy(); - } - } - if( myHCALenergy + myECALenergy > 0. ) { - emFraction = myECALenergy/( myHCALenergy + myECALenergy); - } - */ } } } From 78e824d1c9403215e896b9b0322bee9410a0ea9b Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 13 Mar 2018 11:46:24 +0100 Subject: [PATCH 036/686] commiting to be able to swithc branches --- RecoTauTag/Configuration/test/ZTT-validation.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/Configuration/test/ZTT-validation.txt b/RecoTauTag/Configuration/test/ZTT-validation.txt index 85f6d7773f55b..e2c47481b2f98 100644 --- a/RecoTauTag/Configuration/test/ZTT-validation.txt +++ b/RecoTauTag/Configuration/test/ZTT-validation.txt @@ -1,2 +1,3 @@ #/store/relval/CMSSW_9_2_2/RelValProdTTbar_13/AODSIM/91X_mcRun2_asymptotic_v3-v1/10000/EEB99F74-DA4D-E711-A41C-0025905A48F2.root -/store/relval/CMSSW_10_0_0_pre1/RelValTTbar_13/GEN-SIM-RECO/94X_mc2017_realistic_v10-v1/10000/5873841C-9DCB-E711-8E9F-0CC47A7C357A.root +#/store/relval/CMSSW_10_0_0_pre1/RelValTTbar_13/GEN-SIM-RECO/94X_mc2017_realistic_v10-v1/10000/5873841C-9DCB-E711-8E9F-0CC47A7C357A.root +/store/relval/CMSSW_10_1_0_pre1/RelValTTbar_13/GEN-SIM-RECO/PUpmx25ns_100X_upgrade2018_realistic_v10-v1/20000/2AA898A5-9713-E811-8471-0CC47A4D7636.root From 8bba3d3bd9159178c6e27542aef7fb0daacba2f1 Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 13 Mar 2018 13:52:55 +0100 Subject: [PATCH 037/686] moved class definitions from TauReco to JetReco on request by duplicateReflexLibrarySearch.py --- DataFormats/JetReco/src/classes_3.h | 5 +++++ DataFormats/JetReco/src/classes_def_3.xml | 6 ++++++ DataFormats/TauReco/src/classes_3.h | 5 ----- DataFormats/TauReco/src/classes_def_3.xml | 7 ------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/DataFormats/JetReco/src/classes_3.h b/DataFormats/JetReco/src/classes_3.h index 633f49602ea9e..1ba3b27ec5ff3 100644 --- a/DataFormats/JetReco/src/classes_3.h +++ b/DataFormats/JetReco/src/classes_3.h @@ -125,6 +125,11 @@ namespace DataFormats_JetReco { edm::RefToBaseVector jrtbv; edm::Wrapper > jrtbv_w; edm::reftobase::BaseVectorHolder * bvhj_p; // pointer since it's pure virtual + + // Generic association (used e.g. in TauReco) + edm::AssociationMap,edm::View,unsigned int> > v_j_v_j_am; + edm::Wrapper,edm::View,unsigned int> > > v_j_v_j_am_w; + edm::helpers::KeyVal,edm::RefToBaseProd > v_j_v_j_kv; }; } #endif diff --git a/DataFormats/JetReco/src/classes_def_3.xml b/DataFormats/JetReco/src/classes_def_3.xml index 36f486ef67768..986e9b91b1d57 100644 --- a/DataFormats/JetReco/src/classes_def_3.xml +++ b/DataFormats/JetReco/src/classes_def_3.xml @@ -118,4 +118,10 @@ + + + + + + diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h index a86b5e3ea52bf..d7b0171fa0e09 100644 --- a/DataFormats/TauReco/src/classes_3.h +++ b/DataFormats/TauReco/src/classes_3.h @@ -252,10 +252,5 @@ namespace DataFormats_TauReco { edm::AssociationMap,std::vector,unsigned int> >patjet_v_patpc_v_otm_am; edm::Wrapper,std::vector,unsigned int> > > patjet_v_patpc_v_otm_am_w; edm::helpers::KeyVal >,edm::RefProd > > patjet_v_patpc_v_kv; - - // Generic association - edm::AssociationMap,edm::View,unsigned int> > v_j_v_j_am; - edm::Wrapper,edm::View,unsigned int> > > v_j_v_j_am_w; - edm::helpers::KeyVal,edm::RefToBaseProd > v_j_v_j_kv; }; } diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index 9976659141548..265458a0d468c 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -245,11 +245,4 @@ - - - - - - - From d0c7a056748a076af2892bd96e075614888c5dd9 Mon Sep 17 00:00:00 2001 From: Roger Date: Tue, 13 Mar 2018 15:07:56 +0100 Subject: [PATCH 038/686] code corrections by clang --- PhysicsTools/PatAlgos/plugins/PATTauProducer.cc | 2 +- RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc | 2 +- .../RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc | 4 ++-- RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc | 2 +- RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc | 2 +- RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc | 2 +- RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc | 2 +- RecoTauTag/RecoTau/plugins/RecoTauProducer.cc | 2 +- RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index 7628094347860..48bfd546b87c1 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -484,7 +484,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup aTauPFEssential.ecalEnergyLeadChargedHadrCand_ = ecalEnergyLeadChargedHadrCand; aTauPFEssential.hcalEnergyLeadChargedHadrCand_ = hcalEnergyLeadChargedHadrCand; // extraction of tau lifetime information - if( tauTransverseImpactParameterSrc_.label() != "" ) { + if( !tauTransverseImpactParameterSrc_.label().empty() ) { edm::Handle tauLifetimeInfos; iEvent.getByToken(tauTransverseImpactParameterToken_, tauLifetimeInfos); const reco::PFTauTransverseImpactParameter& tauLifetimeInfo = *(*tauLifetimeInfos)[pfTauRef]; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 7c55ed24792b1..826376ad1c67e 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -126,7 +126,7 @@ PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(const edm::Parame // check if we want to apply a final output selection if ( cfg.exists("outputSelection") ) { std::string selection = cfg.getParameter("outputSelection"); - if ( selection != "" ) { + if ( !selection.empty() ) { outputSelector_.reset(new StringCutObjectSelector(selection)); } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index 20ceac68ae576..fac5c70b4bfa7 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -96,7 +96,7 @@ class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProd void PFRecoTauDiscriminationAgainstMuon2::beginEvent(const edm::Event& evt, const edm::EventSetup& es) { - if ( srcMuons_.label() != "" ) { + if ( !srcMuons_.label().empty() ) { evt.getByToken(Muons_token, muons_); } } @@ -187,7 +187,7 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } - if ( srcMuons_.label() != "" ) { + if ( !srcMuons_.label().empty() ) { size_t numMuons = muons_->size(); for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) { reco::MuonRef muon(muons_, idxMuon); diff --git a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc index 42c89d5754ed0..30ec20c68cc7c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc @@ -112,7 +112,7 @@ void RecoTauPatJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup // (needed for recinstruction of boosted taus) edm::Handle jetToPFCandMap; std::vector > fastJetToPFCandMap; - if ( pfCandAssocMapSrc_.label() != "" ) { + if ( !pfCandAssocMapSrc_.label().empty() ) { evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); fastJetToPFCandMap.resize(nJets); for ( size_t ijet = 0; ijet < nJets; ++ijet ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc index 9198d470432f1..7df763fd335f2 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc @@ -95,7 +95,7 @@ RecoTauCleanerImpl::RecoTauCleanerImpl(const edm::ParameterSet& pset) // Check if we want to apply a final output selection if ( pset.exists("outputSelection") ) { std::string selection = pset.getParameter("outputSelection"); - if ( selection != "" ) { + if ( !selection.empty() ) { outputSelector_.reset(new StringCutObjectSelector(selection)); } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index e57963cf3c376..45b7605794ead 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -113,7 +113,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e // (needed for recinstruction of boosted taus) edm::Handle jetToPFCandMap; std::vector > fastJetToPFCandMap; - if ( pfCandAssocMapSrc_.label() != "" ) { + if ( !pfCandAssocMapSrc_.label().empty() ) { evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); fastJetToPFCandMap.resize(nJets); for ( size_t ijet = 0; ijet < nJets; ++ijet ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index f450569191a53..f0de72c6037c4 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -114,7 +114,7 @@ RecoTauPiZeroProducer::RecoTauPiZeroProducer(const edm::ParameterSet& pset) // Check if we want to apply a final output selection if (pset.exists("outputSelection")) { std::string selection = pset.getParameter("outputSelection"); - if (selection != "") { + if (!selection.empty()) { outputSelector_.reset( new StringCutObjectSelector(selection)); } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index 693e6e287cc8c..87f6f8220ef26 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -118,7 +118,7 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) // Check if we want to apply a final output selection if ( pset.exists("outputSelection") ) { std::string selection = pset.getParameter("outputSelection"); - if ( selection != "" ) { + if ( !selection.empty() ) { outputSelector_.reset(new StringCutObjectSelector(selection)); } } diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 8177d2d0ea5ed..9a9cb9c804f75 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -207,7 +207,7 @@ RecoTauVertexAssociator::RecoTauVertexAssociator(const edm::ParameterSet& pset, } if ( pset.exists("vertexSelection") ) { std::string vertexSelection = pset.getParameter("vertexSelection"); - if ( vertexSelection != "" ) { + if ( !vertexSelection.empty() ) { vertexSelector_ = new StringCutObjectSelector(vertexSelection); } } From 494f85534f54f4304d8091d50a9cc02b36243b7b Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 5 Apr 2018 17:02:49 +0200 Subject: [PATCH 039/686] Rename Candidate accessors in PFTau, add back PFCandidate accessors, and various downstream changes --- DataFormats/PatCandidates/interface/Tau.h | 2 + .../PatCandidates/interface/TauPFSpecific.h | 22 +-- DataFormats/PatCandidates/src/Tau.cc | 145 ++++---------- .../PatCandidates/src/classes_def_objects.xml | 74 +------ DataFormats/TauReco/interface/PFTau.h | 94 +++++---- DataFormats/TauReco/src/PFTau.cc | 183 +++++++++++++----- DataFormats/TauReco/src/classes_def_2.xml | 130 +++++++------ .../IsolationAlgos/plugins/PFTauExtractor.cc | 4 +- .../PatAlgos/plugins/PATTauProducer.cc | 28 ++- .../plugins/PFMETProducerMVA.cc | 8 +- .../src/PFTauElecRejectionBenchmark.cc | 10 +- .../src/HLTPFTauPairLeadTrackDzMatchFilter.cc | 27 +-- .../HLTProducers/src/L1HLTTauMatching.cc | 8 +- .../HLTProducers/src/L1THLTTauMatching.cc | 4 +- .../HLTProducers/src/PFTauToJetProducer.cc | 1 - .../plugins/PFTau3ProngReco.cc | 2 +- .../RecoTau/interface/AntiElectronIDCut2.h | 46 ++--- .../interface/PFRecoTauClusterVariables.h | 12 +- .../interface/RecoTauCommonUtilities.h | 2 +- .../RecoTau/interface/RecoTauConstructor.h | 12 +- .../PFRecoTauDiscriminationAgainstElectron.cc | 73 ++++--- ...PFRecoTauDiscriminationAgainstElectron2.cc | 4 +- ...ecoTauDiscriminationAgainstElectronMVA5.cc | 56 ++---- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 71 +++---- .../PFRecoTauDiscriminationAgainstMuon.cc | 85 ++++---- .../PFRecoTauDiscriminationAgainstMuon2.cc | 2 +- .../PFRecoTauDiscriminationAgainstMuonMVA.cc | 39 ++-- ...FRecoTauDiscriminationAgainstMuonSimple.cc | 2 +- .../PFRecoTauDiscriminationByCharge.cc | 2 +- .../PFRecoTauDiscriminationByDeltaE.cc | 2 +- ...uDiscriminationByFlightPathSignificance.cc | 22 +-- .../PFRecoTauDiscriminationByHPSSelection.cc | 2 +- .../PFRecoTauDiscriminationByInvMass.cc | 2 +- .../PFRecoTauDiscriminationByIsolation.cc | 36 ++-- ...coTauDiscriminationByLeadingObjectPtCut.cc | 20 +- .../PFRecoTauDiscriminationByMVAIsolation2.cc | 2 +- ...RecoTauDiscriminationByMVAIsolationRun2.cc | 2 +- .../PFRecoTauDiscriminationByNProngs.cc | 6 +- ...FRecoTauDiscriminationByTauPolarization.cc | 4 +- .../plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 20 +- .../PFTauMiniAODPrimaryVertexProducer.cc | 2 +- .../plugins/PFTauPrimaryVertexProducer.cc | 9 +- .../plugins/PFTauSecondaryVertexProducer.cc | 2 +- .../PFTauTransverseImpactParameters.cc | 4 +- .../plugins/RecoTauBuilderConePlugin.cc | 10 +- RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc | 14 +- .../plugins/RecoTauDecayModeCutMultiplexer.cc | 2 +- .../plugins/RecoTauDiscriminationByFlight.cc | 19 +- .../plugins/RecoTauElectronRejectionPlugin.cc | 49 ++--- ...ecoTauImpactParameterSignificancePlugin.cc | 4 +- .../RecoTauIsolationDiscriminantPlugins.cc | 6 +- .../RecoTau/plugins/RecoTauPhotonFilter.cc | 28 +-- .../RecoTau/plugins/RecoTauTwoProngFilter.cc | 18 +- .../TauDiscriminationAgainstCaloMuon.cc | 11 +- .../RecoTau/python/RecoTauCleanerPlugins.py | 12 +- .../python/RecoTauCombinatoricProducer_cfi.py | 2 +- RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc | 176 +++++++---------- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 161 +++++++-------- .../RecoTau/src/HPSPFRecoTauAlgorithm.cc | 110 +++++------ RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc | 36 ++-- RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 32 +-- .../src/RecoTauDiscriminantFunctions.cc | 56 +++--- .../RecoTau/src/RecoTauIsolationMasking.cc | 15 +- .../RecoTau/src/RecoTauVertexAssociator.cc | 30 +-- .../interface/PFTauElementsOperators.h | 16 +- .../plugins/RecoTauObjectEmbedderPlugin.cc | 2 +- .../TauTagTools/src/PFTauElementsOperators.cc | 88 ++++----- .../TauTagTools/test/training/trainMVA_cfg.py | 2 +- .../RecoTau/Tools/makeLayoutFileForGui.py | 2 +- Validation/RecoTau/src/TauTagValidation.cc | 104 +++++----- 70 files changed, 1054 insertions(+), 1234 deletions(-) diff --git a/DataFormats/PatCandidates/interface/Tau.h b/DataFormats/PatCandidates/interface/Tau.h index 7c8724ecf6605..d242e1a562058 100644 --- a/DataFormats/PatCandidates/interface/Tau.h +++ b/DataFormats/PatCandidates/interface/Tau.h @@ -453,6 +453,8 @@ namespace pat { private: + /// helper to avoid code duplication in constructors + void initFromBaseTau(const reco::BaseTau& aTau); // ---- for content embedding ---- bool embeddedIsolationTracks_; std::vector isolationTracks_; diff --git a/DataFormats/PatCandidates/interface/TauPFSpecific.h b/DataFormats/PatCandidates/interface/TauPFSpecific.h index 137c34216023d..6da4fe67653ba 100644 --- a/DataFormats/PatCandidates/interface/TauPFSpecific.h +++ b/DataFormats/PatCandidates/interface/TauPFSpecific.h @@ -6,7 +6,7 @@ /** \class pat::tau::PFSpecific TauPFSpecific.h "DataFormats/PatCandidates/interface/TauPFSpecific.h" - \brief Structure to hold information specific to a PFTau inside a pat::Tau + \brief Structure to hold information specific to a PFTau made from PFCandidates inside a pat::Tau \author Giovanni Petrucciani */ @@ -27,18 +27,18 @@ struct TauPFSpecific { reco::JetBaseRef pfJetRef_; reco::CandidatePtr leadPFChargedHadrCand_; float leadPFChargedHadrCandsignedSipt_; - reco::CandidatePtr leadPFNeutralCand_; - reco::CandidatePtr leadPFCand_; - std::vector selectedSignalPFCands_; - std::vector selectedSignalPFChargedHadrCands_; - std::vector selectedSignalPFNeutrHadrCands_; - std::vector selectedSignalPFGammaCands_; + reco::PFCandidatePtr leadPFNeutralCand_; + reco::PFCandidatePtr leadPFCand_; + std::vector selectedSignalPFCands_; + std::vector selectedSignalPFChargedHadrCands_; + std::vector selectedSignalPFNeutrHadrCands_; + std::vector selectedSignalPFGammaCands_; std::vector signalTauChargedHadronCandidates_; std::vector signalPiZeroCandidates_; - std::vector selectedIsolationPFCands_; - std::vector selectedIsolationPFChargedHadrCands_; - std::vector selectedIsolationPFNeutrHadrCands_; - std::vector selectedIsolationPFGammaCands_; + std::vector selectedIsolationPFCands_; + std::vector selectedIsolationPFChargedHadrCands_; + std::vector selectedIsolationPFNeutrHadrCands_; + std::vector selectedIsolationPFGammaCands_; std::vector isolationTauChargedHadronCandidates_; std::vector isolationPiZeroCandidates_; float isolationPFChargedHadrCandsPtSum_; diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc index a75c85308f781..430612d9dae1e 100644 --- a/DataFormats/PatCandidates/src/Tau.cc +++ b/DataFormats/PatCandidates/src/Tau.cc @@ -48,37 +48,7 @@ Tau::Tau(const reco::BaseTau & aTau) : ,embeddedIsolationPFNeutralHadrCands_(false) ,embeddedIsolationPFGammaCands_(false) { - const reco::PFTau * pfTau = dynamic_cast(&aTau); - if (pfTau != nullptr){ - // If PFTau is made from PackedCandidates, directly fill slimmed version - // without PFSpecific - const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); - if (pc != nullptr) { - for (const auto& ptr : pfTau->signalPFChargedHadrCands()) - signalChargedHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) - signalNeutralHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->signalPFGammaCands()) - signalGammaCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) - isolationChargedHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) - isolationNeutralHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFGammaCands()) - isolationGammaCandPtrs_.push_back(ptr); - } - else { - pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); - } - pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); - } - const reco::CaloTau * caloTau = dynamic_cast(&aTau); - if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau)); + initFromBaseTau(aTau); } /// constructor from ref to reco::BaseTau @@ -99,37 +69,7 @@ Tau::Tau(const edm::RefToBase & aTauRef) : ,embeddedIsolationPFNeutralHadrCands_(false) ,embeddedIsolationPFGammaCands_(false) { - const reco::PFTau * pfTau = dynamic_cast(aTauRef.get()); - if (pfTau != nullptr){ - // If PFTau is made from PackedCandidates, directly fill slimmed version - // without PFSpecific - const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); - if (pc != nullptr) { - for (const auto& ptr : pfTau->signalPFChargedHadrCands()) - signalChargedHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) - signalNeutralHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->signalPFGammaCands()) - signalGammaCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) - isolationChargedHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) - isolationNeutralHadrCandPtrs_.push_back(ptr); - - for (const auto& ptr : pfTau->isolationPFGammaCands()) - isolationGammaCandPtrs_.push_back(ptr); - } - else { - pfSpecific_.push_back(pat::tau::TauPFSpecific(*pfTau)); - } - pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); - } - const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get()); - if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau)); + initFromBaseTau(*aTauRef); } /// constructor from ref to reco::BaseTau @@ -150,28 +90,32 @@ Tau::Tau(const edm::Ptr & aTauRef) : ,embeddedIsolationPFNeutralHadrCands_(false) ,embeddedIsolationPFGammaCands_(false) { - const reco::PFTau * pfTau = dynamic_cast(aTauRef.get()); + initFromBaseTau(*aTauRef); +} + +void Tau::initFromBaseTau(const reco::BaseTau& aTau) { + const reco::PFTau * pfTau = dynamic_cast(&aTau); if (pfTau != nullptr){ // If PFTau is made from PackedCandidates, directly fill slimmed version // without PFSpecific - const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadPFChargedHadrCand().get()); + const pat::PackedCandidate* pc = dynamic_cast(pfTau->leadChargedHadrCand().get()); if (pc != nullptr) { - for (const auto& ptr : pfTau->signalPFChargedHadrCands()) + for (const auto& ptr : pfTau->signalChargedHadrCands()) signalChargedHadrCandPtrs_.push_back(ptr); - for (const auto& ptr : pfTau->signalPFNeutrHadrCands()) + for (const auto& ptr : pfTau->signalNeutrHadrCands()) signalNeutralHadrCandPtrs_.push_back(ptr); - for (const auto& ptr : pfTau->signalPFGammaCands()) + for (const auto& ptr : pfTau->signalGammaCands()) signalGammaCandPtrs_.push_back(ptr); - for (const auto& ptr : pfTau->isolationPFChargedHadrCands()) - isolationChargedHadrCandPtrs_.push_back(ptr); + for (const auto& ptr : pfTau->isolationChargedHadrCands()) + isolationChargedHadrCandPtrs_.push_back(ptr); - for (const auto& ptr : pfTau->isolationPFNeutrHadrCands()) + for (const auto& ptr : pfTau->isolationNeutrHadrCands()) isolationNeutralHadrCandPtrs_.push_back(ptr); - for (const auto& ptr : pfTau->isolationPFGammaCands()) + for (const auto& ptr : pfTau->isolationGammaCands()) isolationGammaCandPtrs_.push_back(ptr); } else { @@ -179,7 +123,7 @@ Tau::Tau(const edm::Ptr & aTauRef) : } pfEssential_.push_back(pat::tau::TauPFEssential(*pfTau)); } - const reco::CaloTau * caloTau = dynamic_cast(aTauRef.get()); + const reco::CaloTau * caloTau = dynamic_cast(&aTau); if (caloTau != nullptr) caloSpecific_.push_back(pat::tau::TauCaloSpecific(*caloTau)); } @@ -430,9 +374,9 @@ void Tau::embedSignalPFCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFCands_.push_back(*static_cast(&*candPtrs.at(i))); + signalPFCands_.push_back(candPtrs.at(i)); } embeddedSignalPFCands_ = true; } @@ -440,9 +384,9 @@ void Tau::embedSignalPFChargedHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFChargedHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFChargedHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFChargedHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); + signalPFChargedHadrCands_.push_back(candPtrs.at(i)); } embeddedSignalPFChargedHadrCands_ = true; } @@ -450,9 +394,9 @@ void Tau::embedSignalPFNeutralHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFNeutrHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFNeutrHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFNeutralHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); + signalPFNeutralHadrCands_.push_back(candPtrs.at(i)); } embeddedSignalPFNeutralHadrCands_ = true; } @@ -460,9 +404,9 @@ void Tau::embedSignalPFGammaCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedSignalPFGammaCands_; + std::vector candPtrs = pfSpecific_[0].selectedSignalPFGammaCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - signalPFGammaCands_.push_back(*static_cast(&*candPtrs.at(i))); + signalPFGammaCands_.push_back(candPtrs.at(i)); } embeddedSignalPFGammaCands_ = true; } @@ -471,9 +415,9 @@ void Tau::embedIsolationPFCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFCands_.push_back(*static_cast(&*candPtrs.at(i))); + isolationPFCands_.push_back(candPtrs.at(i)); } embeddedIsolationPFCands_ = true; } @@ -482,9 +426,9 @@ void Tau::embedIsolationPFChargedHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFChargedHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFChargedHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFChargedHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); + isolationPFChargedHadrCands_.push_back(candPtrs.at(i)); } embeddedIsolationPFChargedHadrCands_ = true; } @@ -492,9 +436,9 @@ void Tau::embedIsolationPFNeutralHadrCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFNeutrHadrCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFNeutrHadrCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFNeutralHadrCands_.push_back(*static_cast(&*candPtrs.at(i))); + isolationPFNeutralHadrCands_.push_back(candPtrs.at(i)); } embeddedIsolationPFNeutralHadrCands_ = true; } @@ -502,9 +446,9 @@ void Tau::embedIsolationPFGammaCands() { if (!isPFTau() ) {//additional check with warning in pat::tau producer return; } - std::vector candPtrs = pfSpecific_[0].selectedIsolationPFGammaCands_; + std::vector candPtrs = pfSpecific_[0].selectedIsolationPFGammaCands_; for (unsigned int i = 0; i < candPtrs.size(); i++) { - isolationPFGammaCands_.push_back(*static_cast(&*candPtrs.at(i))); + isolationPFGammaCands_.push_back(candPtrs.at(i)); } embeddedIsolationPFGammaCands_ = true; } @@ -525,15 +469,6 @@ const reco::PFCandidatePtr convertToPFCandidatePtr(const reco::CandidatePtr& ptr return reco::PFCandidatePtr(); } -std::vector convertPtrVector(const std::vector& cands) { - std::vector newSignalPFCands; - for (auto& cand : cands) { - const auto& newPtr = edm::Ptr(cand); - newSignalPFCands.push_back(newPtr); - } - return newSignalPFCands; -} - const reco::PFCandidatePtr Tau::leadPFChargedHadrCand() const { if(!embeddedLeadPFChargedHadrCand_){ if(pfSpecific_.empty()) return reco::PFCandidatePtr(); @@ -576,7 +511,7 @@ const std::vector Tau::signalPFCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedSignalPFCands_); + } else return pfSpecific().selectedSignalPFCands_; } } @@ -598,7 +533,7 @@ const std::vector Tau::signalPFChargedHadrCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFChargedHadrCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedSignalPFChargedHadrCands_); + } else return pfSpecific().selectedSignalPFChargedHadrCands_; } } @@ -620,7 +555,7 @@ const std::vector Tau::signalPFNeutrHadrCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFNeutralHadrCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedSignalPFNeutrHadrCands_); + } else return pfSpecific().selectedSignalPFNeutrHadrCands_; } } @@ -642,7 +577,7 @@ const std::vector Tau::signalPFGammaCands() const { std::unique_ptr > aPtrs{new std::vector{}}; signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); return *signalPFGammaCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedSignalPFGammaCands_); + } else return pfSpecific().selectedSignalPFGammaCands_; } } @@ -674,7 +609,7 @@ const std::vector Tau::isolationPFCands() const { std::unique_ptr > aPtrs{new std::vector{}}; isolationPFCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedIsolationPFCands_); + } else return pfSpecific().selectedIsolationPFCands_; } } @@ -696,7 +631,7 @@ const std::vector Tau::isolationPFChargedHadrCands() const std::unique_ptr > aPtrs{new std::vector{}}; isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFChargedHadrCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedIsolationPFChargedHadrCands_); + } else return pfSpecific().selectedIsolationPFChargedHadrCands_; } } @@ -718,7 +653,7 @@ const std::vector Tau::isolationPFNeutrHadrCands() const { std::unique_ptr > aPtrs{new std::vector{}}; isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFNeutralHadrCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedIsolationPFNeutrHadrCands_); + } else return pfSpecific().selectedIsolationPFNeutrHadrCands_; } } @@ -740,7 +675,7 @@ const std::vector Tau::isolationPFGammaCands() const { std::unique_ptr > aPtrs{new std::vector{}}; isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); return *isolationPFGammaCandsTransientPtrs_; - } else return convertPtrVector(pfSpecific().selectedIsolationPFGammaCands_); + } else return pfSpecific().selectedIsolationPFGammaCands_; } } diff --git a/DataFormats/PatCandidates/src/classes_def_objects.xml b/DataFormats/PatCandidates/src/classes_def_objects.xml index 3c30d4428903e..d6345f59b53bd 100644 --- a/DataFormats/PatCandidates/src/classes_def_objects.xml +++ b/DataFormats/PatCandidates/src/classes_def_objects.xml @@ -159,7 +159,7 @@ - + @@ -168,78 +168,6 @@ - - (onfile.leadPFChargedHadrCand_);]]> - - - - (onfile.leadPFNeutralCand_);]]> - - - - (onfile.leadPFCand_);]]> - - - - & cand : onfile.selectedSignalPFCands_) { - selectedSignalPFCands_.push_back(edm::Ptr(cand));} - ]]> - - - - (cand));]]> - - - - (cand));;]]> - - - - (cand));]]> - - - - (cand));]]> - - - - (cand));]]> - - - - (cand));]]> - - - - (cand));]]> - - - - - diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h index e3210b7e889f9..32803d600c92a 100644 --- a/DataFormats/TauReco/interface/PFTau.h +++ b/DataFormats/TauReco/interface/PFTau.h @@ -66,51 +66,64 @@ class PFTau : public BaseTau { void setpfTauTagInfoRef(const PFTauTagInfoRef); PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const; - const CandidatePtr& leadPFChargedHadrCand() const; - const CandidatePtr& leadPFNeutralCand() const; + const CandidatePtr& leadChargedHadrCand() const; + const CandidatePtr& leadNeutralCand() const; //Can be either the charged or the neutral one - const CandidatePtr& leadPFCand() const; + const CandidatePtr& leadCand() const; - void setleadPFChargedHadrCand(const CandidatePtr&); - void setleadPFNeutralCand(const CandidatePtr&); - void setleadPFCand(const CandidatePtr&); + void setleadChargedHadrCand(const CandidatePtr&); + void setleadNeutralCand(const CandidatePtr&); + void setleadCand(const CandidatePtr&); /// Signed transverse impact parameter significance of the Track /// associated to the leading charged PFCandidate float leadPFChargedHadrCandsignedSipt() const; void setleadPFChargedHadrCandsignedSipt(const float&); - /// PFCandidates in signal region - const std::vector& signalPFCands() const; - void setsignalPFCands(const std::vector&); + /// Candidates in signal region + const std::vector& signalCands() const; + void setsignalCands(const std::vector&); /// Charged hadrons in signal region - const std::vector& signalPFChargedHadrCands() const; - void setsignalPFChargedHadrCands(const std::vector&); + const std::vector& signalChargedHadrCands() const; + void setsignalChargedHadrCands(const std::vector&); /// Neutral hadrons in signal region - const std::vector& signalPFNeutrHadrCands() const; - void setsignalPFNeutrHadrCands(const std::vector&); + const std::vector& signalNeutrHadrCands() const; + void setsignalNeutrHadrCands(const std::vector&); /// Gamma candidates in signal region - const std::vector& signalPFGammaCands() const; - void setsignalPFGammaCands(const std::vector&); + const std::vector& signalGammaCands() const; + void setsignalGammaCands(const std::vector&); - /// PFCandidates in isolation region - const std::vector& isolationPFCands() const; - void setisolationPFCands(const std::vector&); + /// Candidates in isolation region + const std::vector& isolationCands() const; + void setisolationCands(const std::vector&); /// Charged candidates in isolation region - const std::vector& isolationPFChargedHadrCands() const; - void setisolationPFChargedHadrCands(const std::vector&); + const std::vector& isolationChargedHadrCands() const; + void setisolationChargedHadrCands(const std::vector&); //// Neutral hadrons in isolation region - const std::vector& isolationPFNeutrHadrCands() const; - void setisolationPFNeutrHadrCands(const std::vector&); + const std::vector& isolationNeutrHadrCands() const; + void setisolationNeutrHadrCands(const std::vector&); /// Gamma candidates in isolation region - const std::vector& isolationPFGammaCands() const; - void setisolationPFGammaCands(const std::vector&); + const std::vector& isolationGammaCands() const; + void setisolationGammaCands(const std::vector&); + + /// Getters for different PFCandidates for PFTaus made from PFCandidates + const PFCandidatePtr leadPFChargedHadrCand() const; + const PFCandidatePtr leadPFNeutralCand() const; + const PFCandidatePtr leadPFCand() const; + const std::vector& signalPFCands() const; + const std::vector& signalPFChargedHadrCands() const; + const std::vector& signalPFNeutrHadrCands() const; + const std::vector& signalPFGammaCands() const; + const std::vector& isolationPFCands() const; + const std::vector& isolationPFChargedHadrCands() const; + const std::vector& isolationPFNeutrHadrCands() const; + const std::vector& isolationPFGammaCands() const; /// Sum of charged hadron candidate PT in isolation cone; returns NaN /// if isolation region is undefined. @@ -246,22 +259,33 @@ class PFTau : public BaseTau { reco::JetBaseRef jetRef_; PFTauTagInfoRef PFTauTagInfoRef_; - reco::CandidatePtr leadPFChargedHadrCand_; - reco::CandidatePtr leadPFNeutralCand_; - reco::CandidatePtr leadPFCand_; + reco::CandidatePtr leadChargedHadrCand_; + reco::CandidatePtr leadNeutralCand_; + reco::CandidatePtr leadCand_; reco::TrackRef electronPreIDTrack_; // Signal candidates - std::vector selectedSignalPFCands_; - std::vector selectedSignalPFChargedHadrCands_; - std::vector selectedSignalPFNeutrHadrCands_; - std::vector selectedSignalPFGammaCands_; + std::vector selectedSignalCands_; + std::vector selectedSignalChargedHadrCands_; + std::vector selectedSignalNeutrHadrCands_; + std::vector selectedSignalGammaCands_; // Isolation candidates - std::vector selectedIsolationPFCands_; - std::vector selectedIsolationPFChargedHadrCands_; - std::vector selectedIsolationPFNeutrHadrCands_; - std::vector selectedIsolationPFGammaCands_; + std::vector selectedIsolationCands_; + std::vector selectedIsolationChargedHadrCands_; + std::vector selectedIsolationNeutrHadrCands_; + std::vector selectedIsolationGammaCands_; + + // Caches for PFCandidate-based accessors + edm::AtomicPtrCache > selectedTransientSignalPFCands_; + edm::AtomicPtrCache > selectedTransientSignalPFChargedHadrCands_; + edm::AtomicPtrCache > selectedTransientSignalPFNeutrHadrCands_; + edm::AtomicPtrCache > selectedTransientSignalPFGammaCands_; + + edm::AtomicPtrCache > selectedTransientIsolationPFCands_; + edm::AtomicPtrCache > selectedTransientIsolationPFChargedHadrCands_; + edm::AtomicPtrCache > selectedTransientIsolationPFNeutrHadrCands_; + edm::AtomicPtrCache > selectedTransientIsolationPFGammaCands_; RecoTauPiZeroRefVector signalPiZeroCandidatesRefs_; RecoTauPiZeroRefVector isolationPiZeroCandidatesRefs_; diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index 3309a68536baa..a31b89aa9ae10 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -64,34 +64,34 @@ const PFTauTagInfoRef& PFTau::pfTauTagInfoRef() const { void PFTau::setpfTauTagInfoRef(const PFTauTagInfoRef x) { PFTauTagInfoRef_ = x; } -const CandidatePtr& PFTau::leadPFChargedHadrCand() const { return leadPFChargedHadrCand_; } -const CandidatePtr& PFTau::leadPFNeutralCand() const { return leadPFNeutralCand_; } -const CandidatePtr& PFTau::leadPFCand() const { return leadPFCand_; } +const CandidatePtr& PFTau::leadChargedHadrCand() const { return leadChargedHadrCand_; } +const CandidatePtr& PFTau::leadNeutralCand() const { return leadNeutralCand_; } +const CandidatePtr& PFTau::leadCand() const { return leadCand_; } -void PFTau::setleadPFChargedHadrCand(const CandidatePtr& myLead) { leadPFChargedHadrCand_ = myLead;} -void PFTau::setleadPFNeutralCand(const CandidatePtr& myLead) { leadPFNeutralCand_ = myLead;} -void PFTau::setleadPFCand(const CandidatePtr& myLead) { leadPFCand_ = myLead;} +void PFTau::setleadChargedHadrCand(const CandidatePtr& myLead) { leadChargedHadrCand_ = myLead;} +void PFTau::setleadNeutralCand(const CandidatePtr& myLead) { leadNeutralCand_ = myLead;} +void PFTau::setleadCand(const CandidatePtr& myLead) { leadCand_ = myLead;} float PFTau::leadPFChargedHadrCandsignedSipt() const { return leadPFChargedHadrCandsignedSipt_; } void PFTau::setleadPFChargedHadrCandsignedSipt(const float& x){ leadPFChargedHadrCandsignedSipt_ = x; } -const std::vector& PFTau::signalPFCands() const { return selectedSignalPFCands_; } -void PFTau::setsignalPFCands(const std::vector& myParts) { selectedSignalPFCands_ = myParts; } -const std::vector& PFTau::signalPFChargedHadrCands() const { return selectedSignalPFChargedHadrCands_; } -void PFTau::setsignalPFChargedHadrCands(const std::vector& myParts) { selectedSignalPFChargedHadrCands_ = myParts; } -const std::vector& PFTau::signalPFNeutrHadrCands() const {return selectedSignalPFNeutrHadrCands_; } -void PFTau::setsignalPFNeutrHadrCands(const std::vector& myParts) { selectedSignalPFNeutrHadrCands_ = myParts; } -const std::vector& PFTau::signalPFGammaCands() const { return selectedSignalPFGammaCands_; } -void PFTau::setsignalPFGammaCands(const std::vector& myParts) { selectedSignalPFGammaCands_ = myParts; } - -const std::vector& PFTau::isolationPFCands() const { return selectedIsolationPFCands_; } -void PFTau::setisolationPFCands(const std::vector& myParts) { selectedIsolationPFCands_ = myParts;} -const std::vector& PFTau::isolationPFChargedHadrCands() const { return selectedIsolationPFChargedHadrCands_; } -void PFTau::setisolationPFChargedHadrCands(const std::vector& myParts) { selectedIsolationPFChargedHadrCands_ = myParts; } -const std::vector& PFTau::isolationPFNeutrHadrCands() const { return selectedIsolationPFNeutrHadrCands_; } -void PFTau::setisolationPFNeutrHadrCands(const std::vector& myParts) { selectedIsolationPFNeutrHadrCands_ = myParts; } -const std::vector& PFTau::isolationPFGammaCands() const { return selectedIsolationPFGammaCands_; } -void PFTau::setisolationPFGammaCands(const std::vector& myParts) { selectedIsolationPFGammaCands_ = myParts; } +const std::vector& PFTau::signalCands() const { return selectedSignalCands_; } +void PFTau::setsignalCands(const std::vector& myParts) { selectedSignalCands_ = myParts; } +const std::vector& PFTau::signalChargedHadrCands() const { return selectedSignalChargedHadrCands_; } +void PFTau::setsignalChargedHadrCands(const std::vector& myParts) { selectedSignalChargedHadrCands_ = myParts; } +const std::vector& PFTau::signalNeutrHadrCands() const {return selectedSignalNeutrHadrCands_; } +void PFTau::setsignalNeutrHadrCands(const std::vector& myParts) { selectedSignalNeutrHadrCands_ = myParts; } +const std::vector& PFTau::signalGammaCands() const { return selectedSignalGammaCands_; } +void PFTau::setsignalGammaCands(const std::vector& myParts) { selectedSignalGammaCands_ = myParts; } + +const std::vector& PFTau::isolationCands() const { return selectedIsolationCands_; } +void PFTau::setisolationCands(const std::vector& myParts) { selectedIsolationCands_ = myParts;} +const std::vector& PFTau::isolationChargedHadrCands() const { return selectedIsolationChargedHadrCands_; } +void PFTau::setisolationChargedHadrCands(const std::vector& myParts) { selectedIsolationChargedHadrCands_ = myParts; } +const std::vector& PFTau::isolationNeutrHadrCands() const { return selectedIsolationNeutrHadrCands_; } +void PFTau::setisolationNeutrHadrCands(const std::vector& myParts) { selectedIsolationNeutrHadrCands_ = myParts; } +const std::vector& PFTau::isolationGammaCands() const { return selectedIsolationGammaCands_; } +void PFTau::setisolationGammaCands(const std::vector& myParts) { selectedIsolationGammaCands_ = myParts; } namespace { @@ -121,8 +121,103 @@ namespace { oCache.reset(); oCache.set( std::make_unique(std::move(iFrom))); } + + reco::PFCandidatePtr convertToPFPtr(const reco::CandidatePtr& ptr) { + const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); + if (pf_cand) { + return edm::Ptr(ptr); + } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access a PFCandidate.\n"; + return reco::PFCandidatePtr(); + } + + std::unique_ptr > convertToPFPtrs(const std::vector& cands) { + std::unique_ptr > newSignalPFCands{new std::vector{}}; + bool isPF = false; + for (auto& cand : cands) { + // Check for first Candidate if it is a PFCandidate; if yes, skip for the rest + if (!isPF) { + const reco::PFCandidate* pf_cand = dynamic_cast(&*cand); + if (pf_cand != nullptr) { + isPF = true; + newSignalPFCands->reserve(cands.size()); + } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access PFCandidates.\n"; + } + const auto& newPtr = edm::Ptr(cand); + newSignalPFCands->push_back(newPtr); + } + return newSignalPFCands; + } +} + +const PFCandidatePtr PFTau::leadPFChargedHadrCand() const { + return convertToPFPtr(leadChargedHadrCand_); +} + +const PFCandidatePtr PFTau::leadPFNeutralCand() const { + return convertToPFPtr(leadNeutralCand_); } +const PFCandidatePtr PFTau::leadPFCand() const { + return convertToPFPtr(leadCand_); +} + +const std::vector& PFTau::signalPFCands() const { + if (!selectedTransientSignalPFCands_.isSet()) { + selectedTransientSignalPFCands_.set(std::move(convertToPFPtrs(selectedSignalCands_))); + } + return *selectedTransientSignalPFCands_; +} + +const std::vector& PFTau::signalPFChargedHadrCands() const { + if (!selectedTransientSignalPFChargedHadrCands_.isSet()) { + selectedTransientSignalPFChargedHadrCands_.set(std::move(convertToPFPtrs(selectedSignalChargedHadrCands_))); + } + return *selectedTransientSignalPFChargedHadrCands_; +} + +const std::vector& PFTau::signalPFNeutrHadrCands() const { + if (!selectedTransientSignalPFNeutrHadrCands_.isSet()) { + selectedTransientSignalPFNeutrHadrCands_.set(std::move(convertToPFPtrs(selectedSignalNeutrHadrCands_))); + } + return *selectedTransientSignalPFNeutrHadrCands_; +} + +const std::vector& PFTau::signalPFGammaCands() const { + if (!selectedTransientSignalPFGammaCands_.isSet()) { + selectedTransientSignalPFGammaCands_.set(std::move(convertToPFPtrs(selectedSignalGammaCands_))); + } + return *selectedTransientSignalPFGammaCands_; +} + +const std::vector& PFTau::isolationPFCands() const { + if (!selectedTransientIsolationPFCands_.isSet()) { + selectedTransientIsolationPFCands_.set(std::move(convertToPFPtrs(selectedIsolationCands_))); + } + return *selectedTransientIsolationPFCands_; +} + +const std::vector& PFTau::isolationPFChargedHadrCands() const { + if (!selectedTransientIsolationPFChargedHadrCands_.isSet()) { + selectedTransientIsolationPFChargedHadrCands_.set(std::move(convertToPFPtrs(selectedIsolationChargedHadrCands_))); + } + return *selectedTransientIsolationPFChargedHadrCands_; +} + +const std::vector& PFTau::isolationPFNeutrHadrCands() const { + if (!selectedTransientIsolationPFNeutrHadrCands_.isSet()) { + selectedTransientIsolationPFNeutrHadrCands_.set(std::move(convertToPFPtrs(selectedIsolationNeutrHadrCands_))); + } + return *selectedTransientIsolationPFNeutrHadrCands_; +} + +const std::vector& PFTau::isolationPFGammaCands() const { + if (!selectedTransientIsolationPFGammaCands_.isSet()) { + selectedTransientIsolationPFGammaCands_.set(std::move(convertToPFPtrs(selectedIsolationGammaCands_))); + } + return *selectedTransientIsolationPFGammaCands_; +} + + // PiZero and decay mode information const std::vector& PFTau::signalPiZeroCandidates() const { // Check if the signal pi zeros are already filled @@ -246,9 +341,9 @@ void PFTau::setelectronPreIDDecision(const bool& x) {electronPreIDDecision_ = x; // Muon variables bool PFTau::hasMuonReference() const { // check if muon ref exists - if( leadPFChargedHadrCand_.isNull() ) return false; - else if( leadPFChargedHadrCand_.isNonnull() ){ - const reco::PFCandidate* pf_cand = dynamic_cast(&*leadPFChargedHadrCand_); + if( leadChargedHadrCand_.isNull() ) return false; + else if( leadChargedHadrCand_.isNonnull() ){ + const reco::PFCandidate* pf_cand = dynamic_cast(&*leadChargedHadrCand_); if (pf_cand) { reco::MuonRef muonRef = pf_cand->muonRef(); if( muonRef.isNull() ) return false; @@ -290,20 +385,20 @@ void PFTau::dump(std::ostream& out) const { out<<"in detail :"< - + + + + + + + + + @@ -39,100 +47,100 @@ - - (onfile.leadPFChargedHadrCand_);]]> + + (onfile.leadPFChargedHadrCand_);]]> - - (onfile.leadPFNeutralCand_);]]> + + (onfile.leadPFNeutralCand_);]]> - - (onfile.leadPFCand_);]]> + + (onfile.leadPFCand_);]]> - + & cand : onfile.selectedSignalPFCands_) { - selectedSignalPFCands_.push_back(edm::Ptr(cand));} + selectedSignalCands_.push_back(edm::Ptr(cand));} ]]> - + (cand));]]> + selectedSignalChargedHadrCands_.push_back(edm::Ptr(cand));]]> - + (cand));;]]> + selectedSignalNeutrHadrCands_.push_back(edm::Ptr(cand));;]]> - + (cand));]]> + selectedSignalGammaCands_.push_back(edm::Ptr(cand));]]> - + (cand));]]> + selectedIsolationCands_.push_back(edm::Ptr(cand));]]> - + (cand));]]> + selectedIsolationChargedHadrCands_.push_back(edm::Ptr(cand));]]> - + (cand));]]> + selectedIsolationNeutrHadrCands_.push_back(edm::Ptr(cand));]]> - + (cand));]]> + selectedIsolationGammaCands_.push_back(edm::Ptr(cand));]]> - - + + - - + + - - + + @@ -140,12 +148,12 @@ for(auto const& ref : onfile.selectedSignalPFCands_) { @@ -153,12 +161,12 @@ for(auto const& ref : onfile.selectedSignalPFChargedHadrCands_) { @@ -166,12 +174,12 @@ for(auto const& ref : onfile.selectedSignalPFNeutrHadrCands_) { @@ -179,12 +187,12 @@ for(auto const& ref : onfile.selectedSignalPFGammaCands_) { @@ -192,12 +200,12 @@ for(auto const& ref : onfile.selectedIsolationPFCands_) { @@ -205,12 +213,12 @@ for(auto const& ref : onfile.selectedIsolationPFChargedHadrCands_) { @@ -218,12 +226,12 @@ for(auto const& ref : onfile.selectedIsolationPFNeutrHadrCands_) { diff --git a/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc b/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc index 51e2e5019a327..de60d23ec5b8e 100644 --- a/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc +++ b/PhysicsTools/IsolationAlgos/plugins/PFTauExtractor.cc @@ -65,8 +65,8 @@ reco::IsoDeposit PFTauExtractor::depositFromObject(const edm::Event& evt, const //--- check that the candidate is not associated to one of the tau decay products // within the signal cone of the PFTau bool isSignalCone = false; - for ( std::vector::const_iterator tauSignalConeConstituent = pfTau_matched->signalPFCands().begin(); - tauSignalConeConstituent != pfTau_matched->signalPFCands().end(); ++tauSignalConeConstituent ) { + for ( std::vector::const_iterator tauSignalConeConstituent = pfTau_matched->signalCands().begin(); + tauSignalConeConstituent != pfTau_matched->signalCands().end(); ++tauSignalConeConstituent ) { double dR = deltaR(candidate->momentum(), (*tauSignalConeConstituent)->momentum()); if ( dR <= dRvetoPFTauSignalConeConstituents_ ) isSignalCone = true; } diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index 48bfd546b87c1..a87d2e73cd003 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -383,7 +383,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup float sumEnergy = 0.; float leadChargedCandPt = -99; float leadChargedCandEtaAtEcalEntrance = -99; - const std::vector& signalCands = pfTauRef->signalPFCands(); + const std::vector& signalCands = pfTauRef->signalCands(); for(const auto& it : signalCands) { const reco::PFCandidate* icand = dynamic_cast(it.get()); if (icand != nullptr) { @@ -439,28 +439,22 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup float emFraction = -1.; float myHCALenergy = 0.; float myECALenergy = 0.; - const reco::CandidatePtr& leadingPFCharged = pfTauRef->leadPFChargedHadrCand(); - if(leadingPFCharged.isNonnull()) { + const reco::CandidatePtr& leadingPFCharged = pfTauRef->leadChargedHadrCand(); + if(leadingPFCharged.isNonnull()) { const reco::PFCandidate* pfCandPtr = dynamic_cast(leadingPFCharged.get()); - if(pfCandPtr != nullptr) { + if(pfCandPtr != nullptr) { // PFTau made from PFCandidates ecalEnergyLeadChargedHadrCand = pfCandPtr->ecalEnergy(); hcalEnergyLeadChargedHadrCand = pfCandPtr->hcalEnergy(); reco::TrackRef trackRef = pfCandPtr->trackRef(); if( trackRef.isNonnull() ) { leadingTrackNormChi2 = trackRef->normalizedChi2(); - for(const auto& tauIt : pfTauRef->isolationPFCands()){ - const reco::PFCandidate* pfPtr = dynamic_cast(tauIt.get()); - if (pfPtr != nullptr) { - myHCALenergy += pfPtr->hcalEnergy(); - myECALenergy += pfPtr->ecalEnergy(); - } + for(const auto& isoPFCand : pfTauRef->isolationPFCands()){ + myHCALenergy += isoPFCand->hcalEnergy(); + myECALenergy += isoPFCand->ecalEnergy(); } - for(const auto& tauIt : pfTauRef->signalPFCands()){ - const reco::PFCandidate* pfPtr = dynamic_cast(tauIt.get()); - if (pfPtr != nullptr) { - myHCALenergy += pfPtr->hcalEnergy(); - myECALenergy += pfPtr->ecalEnergy(); - } + for(const auto& signalPFCand : pfTauRef->signalPFCands()){ + myHCALenergy += signalPFCand->hcalEnergy(); + myECALenergy += signalPFCand->ecalEnergy(); } if( myHCALenergy + myECALenergy != 0. ) { emFraction = myECALenergy/( myHCALenergy + myECALenergy); @@ -473,7 +467,7 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup // TauReco@MiniAOD: Update code below if ecal/hcal energies are available. const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; if (track != nullptr) { - leadingTrackNormChi2 = track->normalizedChi2(); + leadingTrackNormChi2 = track->normalizedChi2(); } } } diff --git a/RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.cc b/RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.cc index e72eef26d84b9..8c8c930556739 100644 --- a/RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.cc +++ b/RecoMET/METPUSubtraction/plugins/PFMETProducerMVA.cc @@ -315,10 +315,10 @@ double PFMETProducerMVA::chargedEnFrac(const reco::Candidate *iCand, const reco::PFTau *lPFTau = nullptr; lPFTau = dynamic_cast(iCand); if(lPFTau != nullptr) { - for (UInt_t i0 = 0; i0 < lPFTau->signalPFCands().size(); i0++) { - lPtTot += (lPFTau->signalPFCands())[i0]->pt(); - if((lPFTau->signalPFCands())[i0]->charge() == 0) continue; - lPtCharged += (lPFTau->signalPFCands())[i0]->pt(); + for (UInt_t i0 = 0; i0 < lPFTau->signalCands().size(); i0++) { + lPtTot += (lPFTau->signalCands())[i0]->pt(); + if((lPFTau->signalCands())[i0]->charge() == 0) continue; + lPtCharged += (lPFTau->signalCands())[i0]->pt(); } } else { diff --git a/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc b/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc index 56d3a59e4de9a..3fdb782be4ed0 100644 --- a/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc +++ b/RecoParticleFlow/Benchmark/src/PFTauElecRejectionBenchmark.cc @@ -258,12 +258,10 @@ void PFTauElecRejectionBenchmark::process(edm::Handle mcevt, // Check if track goes to Ecal crack reco::TrackRef myleadTk; - if(thePFTau->leadPFChargedHadrCand().isNonnull()){ - const reco::PFCandidate* pflch = dynamic_cast(thePFTau->leadPFChargedHadrCand().get()); - if (pflch != nullptr) { - myleadTk=pflch->trackRef(); - myleadTkEcalPos = pflch->positionAtECALEntrance(); - } + const reco::PFCandidatePtr& pflch = thePFTau->leadPFChargedHadrCand(); + if(pflch.isNonnull()){ + myleadTk=pflch->trackRef(); + myleadTkEcalPos = pflch->positionAtECALEntrance(); if(myleadTk.isNonnull()){ if (applyEcalCrackCut_ && isInEcalCrack(std::abs((double)myleadTkEcalPos.eta()))) { diff --git a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc index ca910692c6fb3..b3b3a8fe81bf9 100644 --- a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc +++ b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc @@ -43,15 +43,6 @@ void HLTPFTauPairLeadTrackDzMatchFilter::fillDescriptions(edm::ConfigurationDesc descriptions.add("hltPFTauPairLeadTrackDzMatchFilter",desc); } -inline const reco::Track* getTrack(const reco::Candidate& cand) -{ - const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); - if (pfCandPtr && pfCandPtr->trackRef().isNonnull()) { - return pfCandPtr->trackRef().get(); - } - return nullptr; -} - bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::EventSetup& es, trigger::TriggerFilterObjectWithRefs& filterproduct) const { using namespace std; @@ -73,29 +64,23 @@ bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::Ev size_t npairs = 0, nfail_dz = 0; if(n_taus > 1) for(size_t t1 = 0; t1 < n_taus; ++t1) { if( taus[t1].leadPFChargedHadrCand().isNull() || - taus[t1].pt() < tauMinPt_ || + taus[t1].leadPFChargedHadrCand()->trackRef().isNull() || + taus[t1].pt() < tauMinPt_ || std::abs(taus[t1].eta() ) > tauMaxEta_ ) continue; - const reco::Track* track1 = getTrack(*taus[t1].leadPFChargedHadrCand()); - if (track1 == nullptr) - continue; - float mindz = 99.f; for(size_t t2 = t1+1; t2 < n_taus; ++t2){ if( taus[t2].leadPFChargedHadrCand().isNull() || + taus[t2].leadPFChargedHadrCand()->trackRef().isNull() || taus[t2].pt() < tauMinPt_ || std::abs(taus[t2].eta() ) > tauMaxEta_ ) continue; - - const reco::Track* track2 = getTrack(*taus[t2].leadPFChargedHadrCand()); - if (track2 == nullptr) - continue; float dr2 = reco::deltaR2(taus[t1].eta(), taus[t1].phi(), taus[t2].eta(), taus[t2].phi() ); - float dz = ( track1->vz() - - track2->vz() ); + float dz = ( taus[t1].leadPFChargedHadrCand()->trackRef()->vz() - + taus[t2].leadPFChargedHadrCand()->trackRef()->vz() ); // skip pairs of taus that are close if ( dr2 < tauMinDR_*tauMinDR_ ) { @@ -126,4 +111,4 @@ bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::Ev // return truth if at least one good pair found return npairs>0; -} +} \ No newline at end of file diff --git a/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc b/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc index 350c1696ca2cf..1105dc0243d7d 100644 --- a/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc +++ b/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc @@ -61,8 +61,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); if(deltaR < matchingR ) { // LeafCandidate myLC(myJet); - if(myJet.leadPFChargedHadrCand().isNonnull()){ - a = myJet.leadPFChargedHadrCand()->vertex(); + if(myJet.leadChargedHadrCand().isNonnull()){ + a = myJet.leadChargedHadrCand()->vertex(); } PFTau myPFTau(std::numeric_limits::quiet_NaN(), myJet.p4(), a); if(myJet.pt() > mEt_Min) { @@ -83,8 +83,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect()); if(deltaR < matchingR ) { // LeafCandidate myLC(myJet); - if(myJet.leadPFChargedHadrCand().isNonnull()){ - a = myJet.leadPFChargedHadrCand()->vertex(); + if(myJet.leadChargedHadrCand().isNonnull()){ + a = myJet.leadChargedHadrCand()->vertex(); } PFTau myPFTau(std::numeric_limits::quiet_NaN(), myJet.p4(),a); diff --git a/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc b/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc index 2511d2eb45abc..c5bab006e15f4 100644 --- a/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc +++ b/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc @@ -47,8 +47,8 @@ void L1THLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const ed const PFTau & myJet = (*tauJets)[iJet]; deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); if(deltaR < matchingR ) { - if(myJet.leadPFChargedHadrCand().isNonnull()){ - a = myJet.leadPFChargedHadrCand()->vertex(); + if(myJet.leadChargedHadrCand().isNonnull()){ + a = myJet.leadChargedHadrCand()->vertex(); } PFTau myPFTau(std::numeric_limits::quiet_NaN(), myJet.p4(), a); if(myJet.pt() > mEt_Min) { diff --git a/RecoTauTag/HLTProducers/src/PFTauToJetProducer.cc b/RecoTauTag/HLTProducers/src/PFTauToJetProducer.cc index b3a8904d03aae..d10b519f2dbb1 100644 --- a/RecoTauTag/HLTProducers/src/PFTauToJetProducer.cc +++ b/RecoTauTag/HLTProducers/src/PFTauToJetProducer.cc @@ -29,7 +29,6 @@ void PFTauToJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iES) iEvent.getByToken( tauSrc_, tauJets ); PFTauCollection::const_iterator i = tauJets->begin(); for(;i !=tauJets->end(); i++ ) { - // cout <<"Tau Tracks " << i->signalPFChargedHadrCands().size()<p4(),i->vertex(),specific); jet.setPdgId(15); jetCollectionTmp->push_back(jet); diff --git a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc index 62f8fb6b12230..f8e701bd5b319 100644 --- a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc +++ b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc @@ -227,7 +227,7 @@ void PFTau3ProngReco::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ // use Track Helix std::vector pions; GlobalPoint pvpoint(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z()); - const std::vector > cands = tau->signalPFChargedHadrCands(); + const std::vector > cands = tau->signalChargedHadrCands(); for (std::vector >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) { const reco::Track* track = getTrack(**iter); if (track != nullptr) { diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h index 4cf9dcb3ce6a1..dccf7ff8a63fc 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h @@ -53,24 +53,21 @@ class AntiElectronIDCut2 { float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for (const auto& cand : signalPFCands) { - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if (pfcand->trackRef().isNonnull()) track = pfcand->trackRef().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull()) track = pfcand->muonRef()->innerTrack().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull()) track = pfcand->muonRef()->globalTrack().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull()) track = pfcand->muonRef()->outerTrack().get(); - else if (pfcand->gsfTrackRef().isNonnull()) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); - } + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + pfCandidate != signalPFCands.end(); ++pfCandidate ) { + const reco::Track* track = nullptr; + if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); + else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); } } - else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } float TauPt = thePFTau.pt(); @@ -79,20 +76,17 @@ class AntiElectronIDCut2 float TauLeadPFChargedHadrEoP = 0.; if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { //TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); - const reco::PFCandidate* leadPFCHCand = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); - if (leadPFCHCand != nullptr) - TauLeadPFChargedHadrEoP = leadPFCHCand->ecalEnergy()/leadPFCHCand->p(); - else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); } std::vector GammasdEta; std::vector GammasdPhi; std::vector GammasPt; - for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { + reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEta.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhi.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEta.push_back(gamma->eta() - thePFTau.eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.phi()); @@ -185,4 +179,4 @@ class AntiElectronIDCut2 int verbosity_; }; -#endif +#endif \ No newline at end of file diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index cd60de7d4ce5f..5d5903439e8f2 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -23,7 +23,7 @@ class TauIdMVAAuxiliaries { /// return chi2 of the leading track ==> deprecated? <== float tau_leadTrackChi2(const reco::PFTau& tau) const { float LeadingTracknormalizedChi2 = 0; - const reco::CandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand(); + const reco::CandidatePtr& leadingPFCharged = tau.leadChargedHadrCand(); if (leadingPFCharged.isNonnull()) { const reco::PFCandidate* pfcand = dynamic_cast(leadingPFCharged.get()); if (pfcand != nullptr) { @@ -44,7 +44,7 @@ class TauIdMVAAuxiliaries { /// return ratio of energy in ECAL over sum of energy in ECAL and HCAL float tau_Eratio(const reco::PFTau& tau) const { - const auto& constsignal = tau.signalPFCands(); + const auto& constsignal = tau.signalCands(); float EcalEnInSignalPFCands = 0.; float HcalEnInSignalPFCands = 0.; for (const auto& icand : constsignal) { @@ -195,11 +195,11 @@ class TauIdMVAAuxiliaries { /// return total number of pf photon candidates with pT>500 MeV, which are associated to signal unsigned int tau_n_photons_total(const reco::PFTau& tau) const { unsigned int n_photons = 0; - for (auto& cand : tau.signalPFGammaCands()) { + for (auto& cand : tau.signalGammaCands()) { if ((float)cand->pt() > 0.5) ++n_photons; } - for (auto& cand : tau.isolationPFGammaCands()) { + for (auto& cand : tau.isolationGammaCands()) { if ((float)cand->pt() > 0.5) ++n_photons; } @@ -222,9 +222,9 @@ class TauIdMVAAuxiliaries { /// return pf photon candidates that are associated to signal const std::vector& getPFGammas(const reco::PFTau& tau, bool signal = true) const { if (signal){ - return tau.signalPFGammaCands(); + return tau.signalGammaCands(); } - return tau.isolationPFGammaCands(); + return tau.isolationGammaCands(); } reco::CandidatePtrVector getGammas(const pat::Tau& tau, bool signal = true) const { if(signal){ diff --git a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h index f74a9daa5a347..20d08c9ca1346 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h +++ b/RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h @@ -143,7 +143,7 @@ template int sumPFCandCharge(InputIterator begin, return sumPFVector(begin, end, &Candidate::charge, 0); } -template InputIterator leadPFCand(InputIterator begin, +template InputIterator leadCand(InputIterator begin, InputIterator end) { double max_pt = 0; InputIterator max_cand = begin; diff --git a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h index 1ee0a3208268a..e03a9bd228929 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h +++ b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h @@ -66,18 +66,18 @@ class RecoTauConstructor { */ /// Set leading PFChargedHadron candidate - template void setleadPFChargedHadrCand(const T& cand) { - tau_->setleadPFChargedHadrCand(convertToPtr(cand)); + template void setleadChargedHadrCand(const T& cand) { + tau_->setleadChargedHadrCand(convertToPtr(cand)); } /// Set leading PFGamma candidate - template void setleadPFNeutralCand(const T& cand) { - tau_->setleadPFNeutralCand(convertToPtr(cand)); + template void setleadNeutralCand(const T& cand) { + tau_->setleadNeutralCand(convertToPtr(cand)); } /// Set leading PF candidate - template void setleadPFCand(const T& cand) { - tau_->setleadPFCand(convertToPtr(cand)); + template void setleadCand(const T& cand) { + tau_->setleadCand(convertToPtr(cand)); } /// Append a PFCandidateRef/Ptr to a given collection diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc index e8f6aec074f42..f8e8dbbb7cf6a 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc @@ -115,19 +115,16 @@ double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& theP } else { // Check if track goes to Ecal crack - const reco::PFCandidate* pflch = dynamic_cast((*thePFTauRef).leadPFChargedHadrCand().get()); - if (pflch != nullptr) { - TrackRef myleadTk; - myleadTk = pflch->trackRef(); - const math::XYZPointF& myleadTkEcalPos = pflch->positionAtECALEntrance(); - if(myleadTk.isNonnull()) - { - if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) - { - return 0.; - } - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + TrackRef myleadTk; + myleadTk=(*thePFTauRef).leadPFChargedHadrCand()->trackRef(); + math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance(); + if(myleadTk.isNonnull()) + { + if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) + { + return 0.; + } + } } bool decision = false; @@ -202,31 +199,29 @@ double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& theP } } if (applyCut_bremCombined_) { - const reco::PFCandidate* pflch = dynamic_cast((*thePFTauRef).leadPFChargedHadrCand().get()); - if (pflch != nullptr) { - if (pflch->trackRef().isNull()) { - // No KF track found - return 0; - } - if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().empty()) { - if(pflch->hcalEnergy()/pflch->trackRef()->p()signalPFChargedHadrCands().size()==1 && !thePFTauRef->signalPFGammaCands().empty()) { - //calculate the brem ratio energy - float bremEnergy=0.; - float emEnergy=0.; - for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc) - { - CandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc); - if(fabs(pflch->trackRef()->eta()-cand->eta())energy(); - emEnergy+=cand->energy(); - } - if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass()leadPFChargedHadrCand()->trackRef().isNull()) { + // No KF track found + return 0; + } + if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().empty()) { + if(thePFTauRef->leadPFChargedHadrCand()->hcalEnergy()/thePFTauRef->leadPFChargedHadrCand()->trackRef()->p()signalPFChargedHadrCands().size()==1 && !thePFTauRef->signalPFGammaCands().empty()) { + //calculate the brem ratio energy + float bremEnergy=0.; + float emEnergy=0.; + for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc) + { + PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc); + if(fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta()-cand->eta())energy(); + emEnergy+=cand->energy(); + } + if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass():" << std::endl; std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi() << std::endl; std::cout << " discriminator value = " << discriminator << std::endl; - std::cout << " Prongs in tau: " << thePFTauRef->signalPFChargedHadrCands().size() << std::endl; + std::cout << " Prongs in tau: " << thePFTauRef->signalChargedHadrCands().size() << std::endl; } return discriminator; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc index 778ee7879a17f..00c2f1a014797 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc @@ -96,14 +96,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& float tauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTauRef->signalPFCands(); - for (const auto& cand : signalPFCands) { - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += (pfcand->positionAtECALEntrance().eta()*pfcand->energy()); - sumEnergy += pfcand->energy(); - } - else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + const std::vector& signalPFCands = thePFTauRef->signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + pfCandidate != signalPFCands.end(); ++pfCandidate ) { + sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy()); + sumEnergy += (*pfCandidate)->energy(); } if ( sumEnergy > 0. ) { tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -111,23 +108,20 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& float leadChargedPFCandEtaAtEcalEntrance = -99.; float leadChargedPFCandPt = -99.; - for (const auto& cand : signalPFCands) { - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if (pfcand->trackRef().isNonnull()) track = pfcand->trackRef().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull()) track = pfcand->muonRef()->innerTrack().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull()) track = pfcand->muonRef()->globalTrack().get(); - else if (pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull()) track = pfcand->muonRef()->outerTrack().get(); - else if (pfcand->gsfTrackRef().isNonnull()) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > leadChargedPFCandPt ) { - leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - leadChargedPFCandPt = track->pt(); - } + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + pfCandidate != signalPFCands.end(); ++pfCandidate ) { + const reco::Track* track = nullptr; + if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); + else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > leadChargedPFCandPt ) { + leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + leadChargedPFCandPt = track->pt(); } } - else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) { @@ -139,11 +133,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size(); - bool hasGsfTrack = false; - const reco::PFCandidate* leadPFCH = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); - if (leadPFCH != nullptr) { - hasGsfTrack = leadPFCH->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { @@ -185,11 +175,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& if ( !isGsfElectronMatched ) { mvaValue = mva_->MVAValue(*thePFTauRef); size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size(); - bool hasGsfTrack = false; - const reco::PFCandidate* leadPFCH = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); - if (leadPFCH != nullptr) { - hasGsfTrack = leadPFCH->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { @@ -228,7 +214,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate(const PFTauRef& edm::LogPrint("PFTauAgainstEleMVA5") << ":" ; edm::LogPrint("PFTauAgainstEleMVA5") << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi(); edm::LogPrint("PFTauAgainstEleMVA5") << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched; - edm::LogPrint("PFTauAgainstEleMVA5") << " #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size(); + edm::LogPrint("PFTauAgainstEleMVA5") << " #Prongs = " << thePFTauRef->signalChargedHadrCands().size(); edm::LogPrint("PFTauAgainstEleMVA5") << " MVA = " << mvaValue << ", category = " << category; } @@ -251,4 +237,4 @@ PFRecoTauDiscriminationAgainstElectronMVA5::isInEcalCrack(double eta) const return (absEta > 1.460 && absEta < 1.558); } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA5); +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA5); \ No newline at end of file diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index fee361ac8f432..98cb6cebdccf8 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -97,13 +97,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float tauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - for (const auto& cand : thePFTauRef->signalPFCands()) { - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += (pfcand->positionAtECALEntrance().eta()*pfcand->energy()); - sumEnergy += pfcand->energy(); - } - else throw cms::Exception("Type Mismatch") << "FIXME.\n"; + for (const auto& pfcand : thePFTauRef->signalPFCands()) { + sumEtaTimesEnergy += (pfcand->positionAtECALEntrance().eta()*pfcand->energy()); + sumEnergy += pfcand->energy(); } if ( sumEnergy > 0. ) { tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -111,38 +107,35 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& float leadChargedPFCandEtaAtEcalEntrance = -99.; float leadChargedPFCandPt = -99.; - for (const auto& cand : thePFTauRef->signalPFCands()) { - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); - else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > leadChargedPFCandPt ) { - leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - leadChargedPFCandPt = track->pt(); - } + for (const auto& pfcand : thePFTauRef->signalPFCands()) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > leadChargedPFCandPt ) { + leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + leadChargedPFCandPt = track->pt(); } } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; } - if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) { + if( (*thePFTauRef).leadChargedHadrCand().isNonnull()) { - int numSignalPFGammaCandsInSigCone = 0; - const std::vector& signalPFGammaCands = thePFTauRef->signalPFGammaCands(); + int numSignalGammaCandsInSigCone = 0; + const std::vector& signalGammaCands = thePFTauRef->signalGammaCands(); - for ( std::vector::const_iterator pfGamma = signalPFGammaCands.begin(); - pfGamma != signalPFGammaCands.end(); ++pfGamma ) { + for ( std::vector::const_iterator pfGamma = signalGammaCands.begin(); + pfGamma != signalGammaCands.end(); ++pfGamma ) { - double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); + double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { - numSignalPFGammaCandsInSigCone += 1; + numSignalGammaCandsInSigCone += 1; } } @@ -154,7 +147,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); - const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); bool hasGsfTrack = false; if (lpfch) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); @@ -173,17 +166,17 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& //// Veto taus that go to Ecal crack if ( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { // Barrel - if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) { + if ( numSignalGammaCandsInSigCone == 0 && hasGsfTrack ) { category = 5.; } - else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) { + else if ( numSignalGammaCandsInSigCone >= 1 && hasGsfTrack ) { category = 7.; } } else { // Endcap - if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) { + if ( numSignalGammaCandsInSigCone == 0 && hasGsfTrack ) { category = 13.; } - else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) { + else if ( numSignalGammaCandsInSigCone >= 1 && hasGsfTrack ) { category = 15.; } } @@ -196,7 +189,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& if ( !isGsfElectronMatched ) { mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); - const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); + const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); bool hasGsfTrack = false; if (lpfch) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); @@ -212,17 +205,17 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& //// Veto taus that go to Ecal crack if ( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { // Barrel - if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) { + if ( numSignalGammaCandsInSigCone == 0 && !hasGsfTrack ) { category = 0.; } - else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) { + else if ( numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack ) { category = 2.; } } else { // Endcap - if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) { + if ( numSignalGammaCandsInSigCone == 0 && !hasGsfTrack ) { category = 8.; } - else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) { + else if ( numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack ) { category = 10.; } } @@ -233,7 +226,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& edm::LogPrint("PFTauAgainstEleMVA6") << ":" ; edm::LogPrint("PFTauAgainstEleMVA6") << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi(); edm::LogPrint("PFTauAgainstEleMVA6") << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched; - edm::LogPrint("PFTauAgainstEleMVA6") << " #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size(); + edm::LogPrint("PFTauAgainstEleMVA6") << " #Prongs = " << thePFTauRef->signalChargedHadrCands().size(); edm::LogPrint("PFTauAgainstEleMVA6") << " MVA = " << mvaValue << ", category = " << category; } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc index 8303c0ad493e0..6291e22e2a423 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc @@ -11,9 +11,6 @@ #include "DataFormats/MuonReco/interface/MuonSelectors.h" #include "DataFormats/JetReco/interface/PFJet.h" -#include "DataFormats/MuonReco/interface/MuonSelectors.h" - - #include using namespace reco; @@ -52,58 +49,52 @@ double PFRecoTauDiscriminationAgainstMuon::discriminate(const PFTauRef& thePFTau bool decision = true; if ( thePFTauRef->hasMuonReference() ) { - const reco::PFCandidate* pfcand = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); - if (pfcand != nullptr) { - MuonRef muonref = pfcand->muonRef(); - if ( discriminatorOption_ == "noSegMatch" ) { - if ( muonref ->numberOfMatches() > maxNumberOfMatches_ ) decision = false; - } else if (discriminatorOption_ == "twoDCut") { - double seg = muon::segmentCompatibility(*muonref); - double calo= muonref->caloCompatibility(); - double border = calo * a + seg * b +c; - if ( border > 0 ) decision = false; - } else if ( discriminatorOption_ == "merePresence" ) { - decision = false; - } else if (discriminatorOption_ == "combined" ) { // testing purpose only - unsigned int muType = 0; - if ( muonref->isGlobalMuon() ) muType = 1; - else if ( muonref->isCaloMuon() ) muType = 2; - else if ( muonref->isTrackerMuon() ) muType = 3; - float muonEnergyFraction = 0.; - const reco::PFJet* pfJetPtr = dynamic_cast(thePFTauRef->pfTauTagInfoRef()->pfjetRef().get()); - if (pfJetPtr) { - muonEnergyFraction = pfJetPtr->chargedMuEnergyFraction(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFJets, and this outdated algorithm was not updated to cope with PFTaus made from other Jets.\n"; - bool eta_veto = false; - bool phi_veto = false; - if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true; - if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true; - if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder - } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { - if(checkNumMatches_ && muonref ->numberOfMatches() > maxNumberOfMatches_) decision = false; - if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false; - } else if ( discriminatorOption_ == "HOP" ) { - decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system - } else { - throw edm::Exception(edm::errors::UnimplementedFeature) - << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n"; - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + MuonRef muonref = thePFTauRef->leadPFChargedHadrCand()->muonRef(); + if ( discriminatorOption_ == "noSegMatch" ) { + if ( muonref ->numberOfMatches() > maxNumberOfMatches_ ) decision = false; + } else if (discriminatorOption_ == "twoDCut") { + double seg = muon::segmentCompatibility(*muonref); + double calo= muonref->caloCompatibility(); + double border = calo * a + seg * b +c; + if ( border > 0 ) decision = false; + } else if ( discriminatorOption_ == "merePresence" ) { + decision = false; + } else if (discriminatorOption_ == "combined" ) { // testing purpose only + unsigned int muType = 0; + if ( muonref->isGlobalMuon() ) muType = 1; + else if ( muonref->isCaloMuon() ) muType = 2; + else if ( muonref->isTrackerMuon() ) muType = 3; + float muonEnergyFraction = 0.; + const reco::PFJet* pfJetPtr = dynamic_cast(thePFTauRef->pfTauTagInfoRef()->pfjetRef().get()); + if (pfJetPtr) { + muonEnergyFraction = pfJetPtr->chargedMuEnergyFraction(); + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFJets, and this outdated algorithm was not updated to cope with PFTaus made from other Jets.\n"; + bool eta_veto = false; + bool phi_veto = false; + if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true; + if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true; + if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder + } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { + if(checkNumMatches_ && muonref ->numberOfMatches() > maxNumberOfMatches_) decision = false; + if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false; + } else if ( discriminatorOption_ == "HOP" ) { + decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system + } else { + throw edm::Exception(edm::errors::UnimplementedFeature) + << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n"; + } } // valid muon ref // Additional calo. muon cut: veto one prongs compatible with MIP signature if ( discriminatorOption_ == "HOP" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { if ( thePFTauRef->leadPFChargedHadrCand().isNonnull() ) { - const reco::PFCandidate* pfcand = dynamic_cast(thePFTauRef->leadPFChargedHadrCand().get()); - if (pfcand != nullptr) { - double muonCaloEn = pfcand->hcalEnergy() + pfcand->ecalEnergy(); - if ( thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_*pfcand->p()) ) decision = false; - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + double muonCaloEn = thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() + thePFTauRef->leadPFChargedHadrCand()->ecalEnergy(); + if ( thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_*thePFTauRef->leadPFChargedHadrCand()->p()) ) decision = false; + } } return (decision ? 1. : 0.); } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon); +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon); \ No newline at end of file diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index fac5c70b4bfa7..5c0ca08d7afca 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -174,7 +174,7 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p numHitsRPC[iStation] = 0; } - const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); + const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadChargedHadrCand(); if ( pfLeadChargedHadron.isNonnull() ) { const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); if (pflch != nullptr) { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc index e1dcc99a98947..0e4dcbac0d3ec 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc @@ -184,28 +184,17 @@ double PFRecoTauDiscriminationAgainstMuonMVA::discriminate(const PFTauRef& tau) mvaInput_[0] = TMath::Abs(tau->eta()); double tauCaloEnECAL = 0.; double tauCaloEnHCAL = 0.; - const std::vector& tauSignalPFCands = tau->signalPFCands(); - for ( std::vector::const_iterator tauSignalPFCand = tauSignalPFCands.begin(); + const std::vector& tauSignalPFCands = tau->signalPFCands(); + for ( std::vector::const_iterator tauSignalPFCand = tauSignalPFCands.begin(); tauSignalPFCand != tauSignalPFCands.end(); ++tauSignalPFCand ) { - const reco::PFCandidate* pfcand = dynamic_cast(tauSignalPFCand->get()); - if (pfcand != nullptr) { - tauCaloEnECAL += pfcand->ecalEnergy(); - tauCaloEnHCAL += pfcand->hcalEnergy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + tauCaloEnECAL += (*tauSignalPFCand)->ecalEnergy(); + tauCaloEnHCAL += (*tauSignalPFCand)->hcalEnergy(); } - - const reco::PFCandidate* pflch = nullptr; - if (tau->leadPFChargedHadrCand().isNonnull()) { - pflch = dynamic_cast(tau->leadPFChargedHadrCand().get()); - if (pflch == nullptr) - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - mvaInput_[1] = TMath::Sqrt(TMath::Max(0., tauCaloEnECAL)); mvaInput_[2] = TMath::Sqrt(TMath::Max(0., tauCaloEnHCAL)); mvaInput_[3] = tau->leadPFChargedHadrCand()->pt()/TMath::Max(1.,Double_t(tau->pt())); - mvaInput_[4] = TMath::Sqrt(TMath::Max(0., pflch->ecalEnergy())); - mvaInput_[5] = TMath::Sqrt(TMath::Max(0., pflch->hcalEnergy())); + mvaInput_[4] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->ecalEnergy())); + mvaInput_[5] = TMath::Sqrt(TMath::Max(0., tau->leadPFChargedHadrCand()->hcalEnergy())); int numMatches = 0; std::vector numHitsDT(4); std::vector numHitsCSC(4); @@ -215,17 +204,17 @@ double PFRecoTauDiscriminationAgainstMuonMVA::discriminate(const PFTauRef& tau) numHitsCSC[iStation] = 0; numHitsRPC[iStation] = 0; } - - reco::MuonRef muonRef = pflch->muonRef(); - if ( muonRef.isNonnull() ) { - numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration); - countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); + if ( tau->leadPFChargedHadrCand().isNonnull() ) { + reco::MuonRef muonRef = tau->leadPFChargedHadrCand()->muonRef(); + if ( muonRef.isNonnull() ) { + numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration); + countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); + } } - size_t numMuons = muons_->size(); for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) { reco::MuonRef muon(muons_, idxMuon); - if (pflch->muonRef().isNonnull() && muon == pflch->muonRef()) { + if ( tau->leadPFChargedHadrCand().isNonnull() && tau->leadPFChargedHadrCand()->muonRef().isNonnull() && muon == tau->leadPFChargedHadrCand()->muonRef() ) { continue; } double dR = deltaR(muon->p4(), tau->p4()); @@ -255,4 +244,4 @@ void PFRecoTauDiscriminationAgainstMuonMVA::endEvent(edm::Event& evt) } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonMVA); +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonMVA); \ No newline at end of file diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc index 35045299251c9..097af96972df9 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc @@ -164,7 +164,7 @@ double PFRecoTauDiscriminationAgainstMuonSimple::discriminate(const reco::PFTauR //if (pfTau->decayMode() >= 5) return true; //MB: accept all multi-prongs?? - const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); + const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadChargedHadrCand(); bool passesCaloMuonVeto = true; if ( pfLeadChargedHadron.isNonnull() ) { const pat::PackedCandidate* pCand = dynamic_cast(pfLeadChargedHadron.get()); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc index c444676d5a9be..df57a707873fe 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc @@ -26,7 +26,7 @@ class PFRecoTauDiscriminationByCharge : public PFTauDiscriminationProducerBase double PFRecoTauDiscriminationByCharge::discriminate(const PFTauRef& thePFTauRef) const { - uint16_t nSigTk = thePFTauRef->signalPFChargedHadrCands().size(); + uint16_t nSigTk = thePFTauRef->signalChargedHadrCands().size(); bool chargeok = (std::abs(thePFTauRef->charge()) == int(chargeReq_)); bool oneOrThreeProngOK = ( (nSigTk==1) || (nSigTk==3) || !oneOrThreeProng_ ); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc index 2c6520360403b..ed6f89a18e8c0 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc @@ -48,7 +48,7 @@ double PFRecoTauDiscriminationByDeltaE::discriminate(const PFTauRef& tau) const{ double PFRecoTauDiscriminationByDeltaE::DeltaE(const PFTauRef& tau) const { double tracksE = 0; - const std::vector& signalTracks = tau->signalPFChargedHadrCands(); + const std::vector& signalTracks = tau->signalChargedHadrCands(); for(size_t i = 0; i < signalTracks.size(); ++i){ TLorentzVector p4; p4.SetXYZM(signalTracks[i]->px(), diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc index fe027e618c05b..465e688c5ff08 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc @@ -82,22 +82,16 @@ double PFRecoTauDiscriminationByFlightPathSignificance::threeProngFlightPathSig( } //Secondary vertex - const vector& pfSignalCandidates = tau->signalPFChargedHadrCands(); vector transientTracks; - for(const auto& pfSignalCand : pfSignalCandidates){ - const PFCandidate* pfCand = dynamic_cast(pfSignalCand.get()); - if (pfCand) { - if(pfCand->trackRef().isNonnull()){ - const TransientTrack transientTrack = transientTrackBuilder->build(pfCand->trackRef()); - transientTracks.push_back(transientTrack); - } - else if(pfCand->gsfTrackRef().isNonnull()){ - const TransientTrack transientTrack = transientTrackBuilder->build(pfCand->gsfTrackRef()); - transientTracks.push_back(transientTrack); - } + for(const auto& pfSignalCand : tau->signalPFChargedHadrCands()){ + if(pfSignalCand->trackRef().isNonnull()){ + const TransientTrack transientTrack = transientTrackBuilder->build(pfSignalCand->trackRef()); + transientTracks.push_back(transientTrack); + } + else if(pfSignalCand->gsfTrackRef().isNonnull()){ + const TransientTrack transientTrack = transientTrackBuilder->build(pfSignalCand->gsfTrackRef()); + transientTracks.push_back(transientTrack); } - else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } if(transientTracks.size() > 1){ KalmanVertexFitter kvf(true); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index 2716ee3953fb6..09c672ac8ac41 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -335,7 +335,7 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c if ( minPixelHits_ > 0 ) { int numPixelHits = 0; - for (const auto& chargedHadrCand : tau->signalPFChargedHadrCands()) { + for (const auto& chargedHadrCand : tau->signalChargedHadrCands()) { const reco::Track* track = getTrack(*chargedHadrCand); if (track != nullptr) { numPixelHits += track->hitPattern().numberOfValidPixelHits(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc index 0ad4cde95cefb..6812293724bb2 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc @@ -55,7 +55,7 @@ double PFRecoTauDiscriminationByInvMass::discriminate(const reco::PFTauRef& tau) const { double mass = tau->mass(); if (cut_) { - unsigned int charged = tau->signalPFChargedHadrCands().size(); + unsigned int charged = tau->signalChargedHadrCands().size(); unsigned int pizeros = tau->signalPiZeroCandidates().size(); DecayModeCutMap::const_iterator specificCut = decayModeCuts_.find( std::make_pair(charged, pizeros)); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index f9bc1bf69da45..103f7f593c6ba 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -343,10 +343,10 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const std::vector isoPU_; CandidateCollection isoNeutralWeight_; std::vector chPV_; - isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size()); - isoNeutral_.reserve(pfTau->isolationPFGammaCands().size()); + isoCharged_.reserve(pfTau->isolationChargedHadrCands().size()); + isoNeutral_.reserve(pfTau->isolationGammaCands().size()); isoPU_.reserve(std::min(100UL, chargedPFCandidatesInEvent_.size())); - isoNeutralWeight_.reserve(pfTau->isolationPFGammaCands().size()); + isoNeutralWeight_.reserve(pfTau->isolationGammaCands().size()); chPV_.reserve(std::min(50UL, chargedPFCandidatesInEvent_.size())); @@ -360,32 +360,32 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const } else { LogTrace("discriminate") << "pv: N/A" ; } - if ( pfTau->leadPFChargedHadrCand().isNonnull() ) { + if ( pfTau->leadChargedHadrCand().isNonnull() ) { LogTrace("discriminate") << "leadPFChargedHadron:" - << " Pt = " << pfTau->leadPFChargedHadrCand()->pt() << "," - << " eta = " << pfTau->leadPFChargedHadrCand()->eta() << "," - << " phi = " << pfTau->leadPFChargedHadrCand()->phi() ; + << " Pt = " << pfTau->leadChargedHadrCand()->pt() << "," + << " eta = " << pfTau->leadChargedHadrCand()->eta() << "," + << " phi = " << pfTau->leadChargedHadrCand()->phi() ; } else { LogTrace("discriminate") << "leadPFChargedHadron: N/A" ; } } // CV: isolation is not well defined in case primary vertex or leading charged hadron do not exist - if ( !(pv.isNonnull() && pfTau->leadPFChargedHadrCand().isNonnull()) ) return 0.; + if ( !(pv.isNonnull() && pfTau->leadChargedHadrCand().isNonnull()) ) return 0.; qcuts_->setPV(pv); - qcuts_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); + qcuts_->setLeadTrack(*pfTau->leadChargedHadrCand()); if ( applyDeltaBeta_ || calculateWeights_) { pileupQcutsGeneralQCuts_->setPV(pv); - pileupQcutsGeneralQCuts_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); + pileupQcutsGeneralQCuts_->setLeadTrack(*pfTau->leadChargedHadrCand()); pileupQcutsPUTrackSelection_->setPV(pv); - pileupQcutsPUTrackSelection_->setLeadTrack(*pfTau->leadPFChargedHadrCand()); + pileupQcutsPUTrackSelection_->setLeadTrack(*pfTau->leadChargedHadrCand()); } // Load the tracks if they are being used. if ( includeTracks_ ) { - for( auto const & cand : pfTau->isolationPFChargedHadrCands() ) { + for( auto const & cand : pfTau->isolationChargedHadrCands() ) { if ( qcuts_->filterCandRef(cand) ) { LogTrace("discriminate") << "adding charged iso cand with pt " << cand->pt() ; isoCharged_.push_back(cand); @@ -393,7 +393,7 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const } } if ( includeGammas_ || calculateWeights_ ) { - for( auto const & cand : pfTau->isolationPFGammaCands() ) { + for( auto const & cand : pfTau->isolationGammaCands() ) { if ( qcuts_->filterCandRef(cand) ) { LogTrace("discriminate") << "adding neutral iso cand with pt " << cand->pt() ; isoNeutral_.push_back(cand); @@ -578,11 +578,11 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const bool failsPhotonPtSumOutsideSignalConeCut = false; double photonSumPt_outsideSignalCone = 0.; if ( applyPhotonPtSumOutsideSignalConeCut_ || storeRawPhotonSumPt_outsideSignalCone_ ) { - const std::vector& signalPFGammas = pfTau->signalPFGammaCands(); - for ( std::vector::const_iterator signalPFGamma = signalPFGammas.begin(); - signalPFGamma != signalPFGammas.end(); ++signalPFGamma ) { - double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalPFGamma)->eta(), (*signalPFGamma)->phi()); - if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalPFGamma)->pt(); + const std::vector& signalGammas = pfTau->signalGammaCands(); + for ( std::vector::const_iterator signalGamma = signalGammas.begin(); + signalGamma != signalGammas.end(); ++signalGamma ) { + double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalGamma)->eta(), (*signalGamma)->phi()); + if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalGamma)->pt(); } if ( photonSumPt_outsideSignalCone > maxAbsPhotonSumPt_outsideSignalCone_ || photonSumPt_outsideSignalCone > (maxRelPhotonSumPt_outsideSignalCone_*pfTau->pt()) ) { failsPhotonPtSumOutsideSignalConeCut = true; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc index 795fe580437b7..24b639ecea594 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc @@ -27,23 +27,23 @@ double PFRecoTauDiscriminationByLeadingObjectPtCut::discriminate(const PFTauRef& double leadObjectPt = -1.; if( chargedOnly_ ) { - // consider only charged hadrons. note that the leadPFChargedHadrCand is the highest pt + // consider only charged hadrons. note that the leadChargedHadrCand is the highest pt // charged signal cone object above the quality cut level (typically 0.5 GeV). - if( thePFTauRef->leadPFChargedHadrCand().isNonnull() ) + if( thePFTauRef->leadChargedHadrCand().isNonnull() ) { - leadObjectPt = thePFTauRef->leadPFChargedHadrCand()->pt(); + leadObjectPt = thePFTauRef->leadChargedHadrCand()->pt(); } } else { // If using the 'leading pion' option, require that: - // 1) at least one charged hadron exists above threshold (thePFTauRef->leadPFChargedHadrCand().isNonnull()) + // 1) at least one charged hadron exists above threshold (thePFTauRef->leadChargedHadrCand().isNonnull()) // 2) the lead PFCand exists. In the case that the highest pt charged hadron is above the PFRecoTauProducer threshold - // (typically 5 GeV), the leadPFCand and the leadPFChargedHadrCand are the same object. If the leadPFChargedHadrCand - // is below 5GeV, but there exists a neutral PF particle > 5 GeV, it is set to be the leadPFCand - if( thePFTauRef->leadPFCand().isNonnull() && thePFTauRef->leadPFChargedHadrCand().isNonnull() ) + // (typically 5 GeV), the leadCand and the leadChargedHadrCand are the same object. If the leadChargedHadrCand + // is below 5GeV, but there exists a neutral PF particle > 5 GeV, it is set to be the leadCand + if( thePFTauRef->leadCand().isNonnull() && thePFTauRef->leadChargedHadrCand().isNonnull() ) { - leadObjectPt = thePFTauRef->leadPFCand()->pt(); + leadObjectPt = thePFTauRef->leadCand()->pt(); } } @@ -66,11 +66,11 @@ void PFRecoTauDiscriminationByLeadingPionPtCut::produce(edm::Event& iEvent,const PFTau thePFTau=*thePFTauRef; double theleadTrackPtCutDiscriminator = 0.; // fill the AssociationVector object - if (!thePFTau.leadPFCand() || !thePFTau.leadPFChargedHadrCand()) + if (!thePFTau.leadCand() || !thePFTau.leadChargedHadrCand()) { theleadTrackPtCutDiscriminator=0.; } - else if(thePFTau.leadPFCand()->pt() > minPtLeadTrack_) theleadTrackPtCutDiscriminator=1.; + else if(thePFTau.leadCand()->pt() > minPtLeadTrack_) theleadTrackPtCutDiscriminator=1.; thePFTauDiscriminatorByLeadingPionPtCut->setValue(iPFTau,theleadTrackPtCutDiscriminator); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc index a9b40f0cdbe60..251dd89f1b709 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc @@ -177,7 +177,7 @@ double PFRecoTauDiscriminationByIsolationMVA2::discriminate(const PFTauRef& tau) category_output_->setValue(tauIndex_, category); // CV: computation of MVA value requires presence of leading charged hadron - if ( tau->leadPFChargedHadrCand().isNull() ) return 0.; + if ( tau->leadChargedHadrCand().isNull() ) return 0.; int tauDecayMode = tau->decayMode(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc index 37baac5f07318..41f0e2fa54ff7 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc @@ -195,7 +195,7 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t category_output_->setValue(tauIndex_, category); // CV: computation of MVA value requires presence of leading charged hadron - if ( tau->leadPFChargedHadrCand().isNull() ) return 0.; + if ( tau->leadChargedHadrCand().isNull() ) return 0.; int tauDecayMode = tau->decayMode(); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc index d0c41eb9feab2..cf4a8b4427c69 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc @@ -52,14 +52,14 @@ void PFRecoTauDiscriminationByNProngs::beginEvent(const Event& iEvent, const Eve double PFRecoTauDiscriminationByNProngs::discriminate(const PFTauRef& tau) const{ reco::VertexRef pv = vertexAssociator_->associatedVertex(*tau); - const CandidatePtr leadingTrack = tau->leadPFChargedHadrCand(); + const CandidatePtr leadingTrack = tau->leadChargedHadrCand(); uint np = 0; if(leadingTrack.isNonnull() && pv.isNonnull()){ qcuts_->setPV(pv); - qcuts_->setLeadTrack(*tau->leadPFChargedHadrCand()); + qcuts_->setLeadTrack(*tau->leadChargedHadrCand()); - BOOST_FOREACH( const reco::CandidatePtr& cand, tau->signalPFChargedHadrCands() ) { + BOOST_FOREACH( const reco::CandidatePtr& cand, tau->signalChargedHadrCands() ) { if ( qcuts_->filterCandRef(cand) ) np++; } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc index ddf6875d04638..21c23fd0b8d59 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc @@ -39,8 +39,8 @@ PFRecoTauDiscriminationByTauPolarization::discriminate(const PFTauRef& tau) cons // rtau for PFTau has to be calculated for leading PF charged hadronic candidate // calculating it from leadingTrack can (and will) give rtau > 1! if(tau.isNonnull() && tau->p() > 0 - && tau->leadPFChargedHadrCand().isNonnull()) { - rTau = tau->leadPFChargedHadrCand()->p()/tau->p(); + && tau->leadChargedHadrCand().isNonnull()) { + rTau = tau->leadChargedHadrCand()->p()/tau->p(); } if(booleanOutput) return ( rTau > rTauMin ? 1. : 0. ); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 5ec9c6679d4b2..a8e56fa9c09ae 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -126,12 +126,12 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const if ( !((jetConstituentPdgId == 130 && jetConstituent->et() > minNeutralHadronEt_) || (jetConstituentPdgId == 22 && jetConstituent->et() > minGammaEt_ )) ) continue; - bool isSignalPFCand = false; - const auto& signalPFCands = tau.signalPFCands(); - for (const auto& signalPFCand : signalPFCands) { - if ( isPtrEqual(jetConstituent, signalPFCand) ) isSignalPFCand = true; + bool isSignalCand = false; + const auto& signalCands = tau.signalCands(); + for (const auto& signalCand : signalCands) { + if ( isPtrEqual(jetConstituent, signalCand) ) isSignalCand = true; } - if ( isSignalPFCand ) continue; + if ( isSignalCand ) continue; double dR = deltaR(jetConstituent->p4(), tau.p4()); double dRadd = -1.; @@ -323,13 +323,13 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const std::cout << "allTracksSumP = " << allTracksSumP << " +/- " << sqrt(allTracksSumPerr2) << std::endl; } double allNeutralsSumEn = 0.; - const auto& signalPFCands = tau.signalPFCands(); - for (const auto& signalPFCand : signalPFCands) { + const auto& signalCands = tau.signalCands(); + for (const auto& signalCand : signalCands) { if ( verbosity_ ) { - std::cout << "PFCandidate #" << signalPFCand.id() << ":" << signalPFCand.key() << ":" - << " Pt = " << (signalPFCand)->pt() << ", eta = " << (signalPFCand)->eta() << ", phi = " << (signalPFCand)->phi() << std::endl; + std::cout << "Candidate #" << signalCand.id() << ":" << signalCand.key() << ":" + << " Pt = " << (signalCand)->pt() << ", eta = " << (signalCand)->eta() << ", phi = " << (signalCand)->phi() << std::endl; } - const PFCandidate* pfCand = dynamic_cast(&*signalPFCand); + const PFCandidate* pfCand = dynamic_cast(&*signalCand); if (pfCand) { if (verbosity_) { std::cout << "calorimeter energy:" diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index e9d11146ff18e..bbfaeec52f529 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -212,7 +212,7 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev reco::PFTauRef RefPFTau(Tau, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// // Get tracks from PFTau daugthers - const std::vector cands = RefPFTau->signalPFChargedHadrCands(); + const std::vector cands = RefPFTau->signalChargedHadrCands(); for(std::vector::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter){ if((*iter).isNull()) continue; const reco::Track* track = getTrack(**iter); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 62c4516d9b148..62971a8e4daa7 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -201,12 +201,9 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu reco::PFTauRef RefPFTau(Tau, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// // Get tracks from PFTau daughters - for (const auto& cand : RefPFTau->signalPFChargedHadrCands()){ - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand != nullptr) { - if (pfcand->trackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} - else if (pfcand->gsfTrackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} - } + for (const auto& pfcand : RefPFTau->signalPFChargedHadrCands()) { + if (pfcand->trackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} + else if (pfcand->gsfTrackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} } } } diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index 5024777fc30df..6efb2406a0e6a 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -110,7 +110,7 @@ void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,con // Get tracks form PFTau daugthers std::vector transTrk; TransientVertex transVtx; - const std::vector > cands = RefPFTau->signalPFChargedHadrCands(); + const std::vector > cands = RefPFTau->signalChargedHadrCands(); for (const auto& cand : cands) { if (cand.isNull()) continue; const reco::Track* track = getTrack(*cand); diff --git a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc index 46b2173bef8b9..22a75d732418d 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc @@ -122,8 +122,8 @@ void PFTauTransverseImpactParameters::produce(edm::Event& iEvent,const edm::Even reco::Vertex::Point poca(0,0,0); double ip3d(-999), ip3d_err(-999); reco::Vertex::Point ip3d_poca(0,0,0); - if(RefPFTau->leadPFChargedHadrCand().isNonnull()){ - const reco::Track* track = getTrack(*RefPFTau->leadPFChargedHadrCand()); + if(RefPFTau->leadChargedHadrCand().isNonnull()){ + const reco::Track* track = getTrack(*RefPFTau->leadChargedHadrCand()); if(track != nullptr){ if(useFullCalculation_){ reco::TransientTrack transTrk=transTrackBuilder->build(*track); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc index fcda8a2bcd264..424237130d5be 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderConePlugin.cc @@ -134,8 +134,8 @@ void RecoTauBuilderConePlugin::setTauQuantities(reco::PFTau& aTau, // Set charge int charge = 0; - int leadCharge = aTau.leadPFChargedHadrCand().isNonnull() ? aTau.leadPFChargedHadrCand()->charge() : 0; - const std::vector& pfChs = aTau.signalPFChargedHadrCands(); + int leadCharge = aTau.leadChargedHadrCand().isNonnull() ? aTau.leadChargedHadrCand()->charge() : 0; + const std::vector& pfChs = aTau.signalChargedHadrCands(); for(const reco::CandidatePtr& pfCh : pfChs){ charge += pfCh->charge(); } @@ -250,7 +250,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( if (leadPFCH_iter != pfchs.end()) { leadPFCH = *leadPFCH_iter; // Set leading candidate - tau.setleadPFChargedHadrCand(leadPFCH); + tau.setleadChargedHadrCand(leadPFCH); } else { // If there is no leading charged candidate at all, return nothing - the // producer class that owns the plugin will build a null tau if desired. @@ -265,7 +265,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( if (leadPFGamma_iter != pfGammas.end()) { leadPFGamma = *leadPFGamma_iter; // Set leading neutral candidate - tau.setleadPFNeutralCand(leadPFGamma); + tau.setleadNeutralCand(leadPFGamma); } CandidatePtr leadPFCand; @@ -281,7 +281,7 @@ RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()( leadPFCand = leadPFCH; } - tau.setleadPFCand(leadPFCand); + tau.setleadCand(leadPFCand); // Our cone axis is defined about the lead charged hadron reco::Candidate::LorentzVector coneAxis = leadPFCH->p4(); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc index 7df763fd335f2..261f01dafc54e 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc @@ -179,13 +179,13 @@ namespace const reco::RecoTauPiZero& piZero = signalPiZeroCandidates.at(iPiZero); std::cout << " piZero #" << iPiZero << ": Pt = " << piZero.pt() << ", eta = " << piZero.eta() << ", phi = " << piZero.phi() << ", mass = " << piZero.mass() << std::endl; } - const auto& isolationPFCands = tauRef_->isolationPFCands(); - size_t numPFCands = isolationPFCands.size(); - std::cout << "isolationPFCands = " << numPFCands << std::endl; - for ( size_t iPFCand = 0; iPFCand < numPFCands; ++iPFCand ) { - const auto& pfCand = isolationPFCands.at(iPFCand); - std::cout << " pfCand #" << iPFCand << " (" << pfCand.id() << ":" << pfCand.key() << "):" - << " Pt = " << pfCand->pt() << ", eta = " << pfCand->eta() << ", phi = " << pfCand->phi() << std::endl; + const auto& isolationCands = tauRef_->isolationCands(); + size_t numCands = isolationCands.size(); + std::cout << "isolationCands = " << numCands << std::endl; + for ( size_t iCand = 0; iCand < numCands; ++iCand ) { + const auto& cand = isolationCands.at(iCand); + std::cout << " pfCand #" << iCand << " (" << cand.id() << ":" << cand.key() << "):" + << " Pt = " << cand->pt() << ", eta = " << cand->eta() << ", phi = " << cand->phi() << std::endl; } std::cout << " ranks = " << format_vT(ranks_) << std::endl; std::cout << " tolerances = " << format_vT(tolerances_) << std::endl; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc b/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc index 6f1fc6885c967..ecfe77cdf3484 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc @@ -50,7 +50,7 @@ double RecoTauDecayModeCutMultiplexer::discriminate(const reco::PFTauRef& tau) const { double disc_result = (*handle_)[tau]; DecayModeCutMap::const_iterator cutIter = - decayModeCuts_.find(std::make_pair(tau->signalPFChargedHadrCands().size(), + decayModeCuts_.find(std::make_pair(tau->signalChargedHadrCands().size(), tau->signalPiZeroCandidates().size())); // Return null if it doesn't exist diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc index 6678bd38e2e23..5cfa01f01f553 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc @@ -54,19 +54,16 @@ double PFRecoTauDiscriminationByFlight::discriminate( const reco::PFTauRef& tau) const { KalmanVertexFitter kvf(true); - const std::vector& signalTracks = + const std::vector& signalTracks = tau->signalPFChargedHadrCands(); std::vector signalTransTracks; std::vector signalTrackPtrs; - BOOST_FOREACH(const reco::CandidatePtr& signalTrack, signalTracks) { - const reco::PFCandidate* pftrack = dynamic_cast(signalTrack.get()); - if (pftrack != nullptr) { - if (pftrack->trackRef().isNonnull()) { - signalTransTracks.push_back( - builder_->build(pftrack->trackRef())); - signalTrackPtrs.push_back(pftrack->trackRef()); - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + for (const auto& pftrack : signalTracks) { + if (pftrack->trackRef().isNonnull()) { + signalTransTracks.push_back( + builder_->build(pftrack->trackRef())); + signalTrackPtrs.push_back(pftrack->trackRef()); + } } reco::Vertex pv = (*vertices_)[0]; @@ -101,7 +98,7 @@ double PFRecoTauDiscriminationByFlight::discriminate( // The tau direction, to determine the sign of the IP. // In the case that it is a one prong, take the jet direction. // This may give better result due to out-of-cone stuff. - GlobalVector direction = (tau->signalPFCands().size() == 1 ? + GlobalVector direction = (tau->signalCands().size() == 1 ? GlobalVector( tau->jetRef()->px(), tau->jetRef()->py(), tau->jetRef()->pz()) : GlobalVector(tau->px(), tau->py(), tau->pz())); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc index 1ed3cb13bb4c3..1a2581459a1cd 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc @@ -83,9 +83,9 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { typedef std::pair ElementInBlock; typedef std::vector< ElementInBlock > ElementsInBlocks; - CandidatePtr myleadChargedCand = tau.leadPFChargedHadrCand(); + PFCandidatePtr myleadPFChargedCand = tau.leadPFChargedHadrCand(); // Build list of PFCands in tau - std::vector myPFCands; + std::vector myPFCands; myPFCands.reserve(tau.isolationPFCands().size()+tau.signalPFCands().size()); std::copy(tau.isolationPFCands().begin(), tau.isolationPFCands().end(), @@ -94,10 +94,7 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { std::back_inserter(myPFCands)); //Use the electron rejection only in case there is a charged leading pion - if(myleadChargedCand.isNonnull()){ - const reco::PFCandidate* myleadPFChargedCand = dynamic_cast(myleadChargedCand.get()); - if (myleadPFChargedCand == nullptr) - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + if(myleadPFChargedCand.isNonnull()){ myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi(); math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance(); @@ -107,37 +104,33 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { //FROM AOD if(DataType_ == "AOD"){ // Corrected Cluster energies - for(const auto& cand : myPFCands){ - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - myHCALenergy += pfcand->hcalEnergy(); - myECALenergy += pfcand->ecalEnergy(); + for(int i=0;i<(int)myPFCands.size();i++){ + myHCALenergy += myPFCands[i]->hcalEnergy(); + myECALenergy += myPFCands[i]->ecalEnergy(); math::XYZPointF candPos; - if (pfcand->particleId()==1 || pfcand->particleId()==2)//if charged hadron or electron - candPos = pfcand->positionAtECALEntrance(); + if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2)//if charged hadron or electron + candPos = myPFCands[i]->positionAtECALEntrance(); else - candPos = math::XYZPointF(pfcand->px(),pfcand->py(),pfcand->pz()); + candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz()); double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,candPos); double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos); double deltaEta = std::abs(myElecTrkEcalPos.eta()-candPos.eta()); double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge(); - if (pfcand->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && + if (myPFCands[i]->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) { - myStripClusterE += pfcand->ecalEnergy(); + myStripClusterE += myPFCands[i]->ecalEnergy(); } if (deltaR<0.184) { - myHCALenergy3x3 += pfcand->hcalEnergy(); + myHCALenergy3x3 += myPFCands[i]->hcalEnergy(); } - if (pfcand->hcalEnergy()>myMaximumHCALPFClusterE) { - myMaximumHCALPFClusterE = pfcand->hcalEnergy(); + if (myPFCands[i]->hcalEnergy()>myMaximumHCALPFClusterE) { + myMaximumHCALPFClusterE = myPFCands[i]->hcalEnergy(); } - if ((pfcand->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { - myMaximumHCALPFClusterEt = (pfcand->hcalEnergy()*fabs(sin(candPos.Theta()))); + if ((myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) { + myMaximumHCALPFClusterEt = (myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta()))); } } @@ -145,12 +138,8 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { // Against double counting of clusters std::vector hcalPosV; hcalPosV.clear(); std::vector ecalPosV; ecalPosV.clear(); - for(const auto& cand : myPFCands){ - const reco::PFCandidate* pfcand = dynamic_cast(cand.get()); - if (pfcand == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - const ElementsInBlocks& elts = pfcand->elementsInBlocks(); + for(int i=0;i<(int)myPFCands.size();i++){ + const ElementsInBlocks& elts = myPFCands[i]->elementsInBlocks(); for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) { const reco::PFBlock& block = *(it->first); unsigned indexOfElementInBlock = it->second; @@ -234,4 +223,4 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory, reco::tau::RecoTauElectronRejectionPlugin, - "RecoTauElectronRejectionPlugin"); + "RecoTauElectronRejectionPlugin"); \ No newline at end of file diff --git a/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc index ef0d6aeed0684..87f0656bf267d 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauImpactParameterSignificancePlugin.cc @@ -75,8 +75,8 @@ namespace void RecoTauImpactParameterSignificancePlugin::operator()(PFTau& tau) const { // Get the transient lead track - if (tau.leadPFChargedHadrCand().isNonnull()) { - const reco::Track* leadTrack = getTrack(*tau.leadPFChargedHadrCand()); + if (tau.leadChargedHadrCand().isNonnull()) { + const reco::Track* leadTrack = getTrack(*tau.leadChargedHadrCand()); if (leadTrack != nullptr) { const TransientTrack track = builder_->build(leadTrack); GlobalVector direction(tau.jetRef()->px(), tau.jetRef()->py(), diff --git a/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc b/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc index 89eaa08f22f6f..de55eaa95138a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauIsolationDiscriminantPlugins.cc @@ -28,7 +28,7 @@ class TrackExtractor { public: TrackExtractor(const edm::ParameterSet& pset){}; std::vector operator()(const reco::PFTauRef& tau) const { - return tau->isolationPFChargedHadrCands(); + return tau->isolationChargedHadrCands(); } }; @@ -36,7 +36,7 @@ class ECALExtractor { public: ECALExtractor(const edm::ParameterSet& pset){}; std::vector operator()(const reco::PFTauRef& tau) const { - return tau->isolationPFGammaCands(); + return tau->isolationGammaCands(); } }; @@ -62,7 +62,7 @@ class HCALExtractor { public: HCALExtractor(const edm::ParameterSet& pset){}; std::vector operator()(const reco::PFTauRef& tau) const { - return tau->isolationPFNeutrHadrCands(); + return tau->isolationNeutrHadrCands(); } }; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc index d2c0b95b597a1..f5f512d52eb52 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPhotonFilter.cc @@ -112,30 +112,30 @@ void RecoTauPhotonFilter::operator()(PFTau& tau) const { keysToMove.insert(ptr.key()); } - std::vector newSignalPFGammas; - std::vector newSignalPFCands; - std::vector newIsolationPFGammas = tau.isolationPFGammaCands(); - std::vector newIsolationPFCands = tau.isolationPFCands(); + std::vector newSignalGammas; + std::vector newSignalCands; + std::vector newIsolationGammas = tau.isolationGammaCands(); + std::vector newIsolationCands = tau.isolationCands(); // Move the necessary signal pizeros - what a mess! - BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFCands()) { + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalCands()) { if (keysToMove.count(ptr.key())) - newIsolationPFCands.push_back(ptr); + newIsolationCands.push_back(ptr); else - newSignalPFCands.push_back(ptr); + newSignalCands.push_back(ptr); } - BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFGammaCands()) { + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalGammaCands()) { if (keysToMove.count(ptr.key())) - newIsolationPFGammas.push_back(ptr); + newIsolationGammas.push_back(ptr); else - newSignalPFGammas.push_back(ptr); + newSignalGammas.push_back(ptr); } - tau.setsignalPFCands(newSignalPFCands); - tau.setsignalPFCands(newSignalPFGammas); - tau.setisolationPFGammaCands(newIsolationPFGammas); - tau.setisolationPFCands(newIsolationPFCands); + tau.setsignalCands(newSignalCands); + tau.setsignalCands(newSignalGammas); + tau.setisolationGammaCands(newIsolationGammas); + tau.setisolationCands(newIsolationCands); } } }} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc b/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc index 803b5e7a84961..f507e810759f3 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauTwoProngFilter.cc @@ -43,8 +43,8 @@ class RecoTauTwoProngFilter : public RecoTauModifierPlugin { } void RecoTauTwoProngFilter::operator()(PFTau& tau) const { - if (tau.signalPFChargedHadrCands().size() == 2) { - const std::vector& signalCharged = tau.signalPFChargedHadrCands(); + if (tau.signalChargedHadrCands().size() == 2) { + const std::vector& signalCharged = tau.signalChargedHadrCands(); size_t indexOfHighestPt = (signalCharged[0]->pt() > signalCharged[1]->pt()) ? 0 : 1; size_t indexOfLowerPt = ( indexOfHighestPt ) ? 0 : 1; @@ -57,13 +57,13 @@ void RecoTauTwoProngFilter::operator()(PFTau& tau) const { // Make our new signal charged candidate collection std::vector newSignalCharged; newSignalCharged.push_back(keep); - std::vector newSignal = deleteFrom(filter, tau.signalPFCands()); + std::vector newSignal = deleteFrom(filter, tau.signalCands()); // Copy our filtered cand to isolation std::vector newIsolationCharged = - tau.isolationPFChargedHadrCands(); + tau.isolationChargedHadrCands(); newIsolationCharged.push_back(filter); - std::vector newIsolation = tau.isolationPFCands(); + std::vector newIsolation = tau.isolationCands(); newIsolation.push_back(filter); // Update tau members @@ -72,10 +72,10 @@ void RecoTauTwoProngFilter::operator()(PFTau& tau) const { tau.isolationPFChargedHadrCandsPtSum() - filter->pt()); tau.setCharge(tau.charge() - filter->charge()); // Update tau constituents - tau.setsignalPFChargedHadrCands(newSignalCharged); - tau.setsignalPFCands(newSignal); - tau.setisolationPFChargedHadrCands(newIsolationCharged); - tau.setisolationPFCands(newIsolation); + tau.setsignalChargedHadrCands(newSignalCharged); + tau.setsignalCands(newSignal); + tau.setisolationChargedHadrCands(newIsolationCharged); + tau.setisolationCands(newIsolation); } } } diff --git a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc index 2d2f389d02a5e..86ad7d76b4ea6 100644 --- a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc +++ b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc @@ -74,16 +74,13 @@ class TauLeadTrackExtractor public: reco::TrackRef getLeadTrack(const reco::PFTau& tau) const { - const reco::PFCandidate* pflch = dynamic_cast(tau.leadPFChargedHadrCand().get()); - if (pflch != nullptr) { - return pflch->trackRef(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + return tau.leadPFChargedHadrCand()->trackRef(); } double getTrackPtSum(const reco::PFTau& tau) const { double trackPtSum = 0.; - for ( std::vector::const_iterator signalTrack = tau.signalPFChargedHadrCands().begin(); - signalTrack != tau.signalPFChargedHadrCands().end(); ++signalTrack ) { + for ( std::vector::const_iterator signalTrack = tau.signalChargedHadrCands().begin(); + signalTrack != tau.signalChargedHadrCands().end(); ++signalTrack ) { trackPtSum += (*signalTrack)->pt(); } return trackPtSum; @@ -311,4 +308,4 @@ typedef TauDiscriminationAgainstCaloMuon PFRecoTauDis typedef TauDiscriminationAgainstCaloMuon CaloRecoTauDiscriminationAgainstCaloMuon; DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstCaloMuon); -DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstCaloMuon); +DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstCaloMuon); \ No newline at end of file diff --git a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py index b2e191d225e06..028e4a47cbab7 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py @@ -20,7 +20,7 @@ name = cms.string("UnitCharge"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Only effects three prongs - selection = cms.string("signalPFChargedHadrCands().size() = 3"), + selection = cms.string("signalChargedHadrCands().size() = 3"), # As 1 is lower than 3, this will always prefer those with unit charge selectionPassFunction = cms.string("abs(charge())-1"), # If it is a one prong, consider it just as good as a @@ -66,7 +66,7 @@ name = cms.string("Pt"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Require that cones were built by ensuring the a leadCand exits - selection = cms.string("leadPFCand().isNonnull()"), + selection = cms.string("leadCand().isNonnull()"), selectionPassFunction = cms.string("-pt()"), # CV: negative sign means that we prefer candidates of high pT selectionFailValue = cms.double(1e3), tolerance = cms.double(1.e-2) # CV: consider candidates with almost equal pT to be of the same rank (to avoid sensitivity to rounding errors) @@ -81,7 +81,7 @@ name = cms.string("StripMultiplicity"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Require that cones were built by ensuring the a leadCand exits - selection = cms.string("leadPFCand().isNonnull()"), + selection = cms.string("leadCand().isNonnull()"), selectionPassFunction = cms.string("-signalPiZeroCandidates().size()"), selectionFailValue = cms.double(1e3) ) @@ -90,7 +90,7 @@ name = cms.string("CombinedIsolation"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Require that cones were built by ensuring the a leadCand exits - selection = cms.string("leadPFCand().isNonnull()"), + selection = cms.string("leadCand().isNonnull()"), selectionPassFunction = cms.string("isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()"), selectionFailValue = cms.double(1e3) ) @@ -99,7 +99,7 @@ name = cms.string("ChargeIsolation"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Require that cones were built by ensuring the a leadCand exits - selection = cms.string("leadPFCand().isNonnull()"), + selection = cms.string("leadCand().isNonnull()"), # Prefer lower isolation activity selectionPassFunction = cms.string("isolationPFChargedHadrCandsPtSum()"), selectionFailValue = cms.double(1e3) @@ -109,7 +109,7 @@ name = cms.string("GammaIsolation"), plugin = cms.string("RecoTauStringCleanerPlugin"), # Require that cones were built by ensuring the a leadCand exits - selection = cms.string("leadPFCand().isNonnull()"), + selection = cms.string("leadCand().isNonnull()"), # Prefer lower isolation activity selectionPassFunction = cms.string("isolationPFGammaCandsEtSum()"), selectionFailValue = cms.double(1e3) diff --git a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py index f599808795bd1..c0295e568987c 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py @@ -138,7 +138,7 @@ chargedHadronSrc = cms.InputTag('ak4PFJetsRecoTauChargedHadrons'), piZeroSrc = cms.InputTag("ak4PFJetsRecoTauPiZeros"), buildNullTaus = cms.bool(False), - outputSelection = cms.string("leadPFChargedHadrCand().isNonnull()"), # MB: always require that leading PFChargedHadron candidate exists + outputSelection = cms.string("leadChargedHadrCand().isNonnull()"), # MB: always require that leading PFChargedHadron candidate exists # Make maximum size from which to collect isolation cone objects, w.r.t to # the axis of the signal cone objects builders = cms.VPSet( diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc index 403e8a92cbe34..09ab19c4692ea 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc @@ -693,14 +693,11 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, Float_t TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); - sumEnergy += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); + sumEnergy += (*pfCandidate)->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -708,23 +705,20 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); - else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); - } + const reco::Track* track = nullptr; + if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); + else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } } Float_t TauPt = thePFTau.pt(); @@ -732,13 +726,9 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size(); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); - if (pflch == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - if ( pflch->p() > 0. ) { - TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); - TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); + if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { + TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); } Float_t TauVisMass = thePFTau.mass(); Float_t TauHadrMva = std::max(thePFTau.electronPreIDOutput(), float(-1.0)); @@ -746,10 +736,10 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, std::vector GammasdPhi; std::vector GammasPt; for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEta.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhi.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEta.push_back(gamma->eta() - thePFTau.eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.phi()); @@ -757,41 +747,38 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau, GammasPt.push_back(gamma->pt()); } Float_t TauKFNumHits = -99.; - if ( (pflch->trackRef()).isNonnull() ) { - TauKFNumHits = pflch->trackRef()->numberOfValidHits(); + if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) { + TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits(); } Float_t TauGSFNumHits = -99.; Float_t TauGSFChi2 = -99.; Float_t TauGSFTrackResol = -99.; Float_t TauGSFTracklnPt = -99.; Float_t TauGSFTrackEta = -99.; - if ( (pflch->gsfTrackRef()).isNonnull() ) { - TauGSFChi2 = pflch->gsfTrackRef()->normalizedChi2(); - TauGSFNumHits = pflch->gsfTrackRef()->numberOfValidHits(); - if ( pflch->gsfTrackRef()->pt() > 0. ) { - TauGSFTrackResol = pflch->gsfTrackRef()->ptError()/pflch->gsfTrackRef()->pt(); - TauGSFTracklnPt = log(pflch->gsfTrackRef()->pt())*M_LN10; + if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) { + TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2(); + TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits(); + if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) { + TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt(); + TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*M_LN10; } - TauGSFTrackEta = pflch->gsfTrackRef()->eta(); + TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta(); } Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); - sumEnergyPhi += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); + sumEnergyPhi += (*pfCandidate)->energy(); } if ( sumEnergyPhi > 0. ) { TauPhi = sumPhiTimesEnergy/sumEnergyPhi; } Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); - Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size(); - Float_t TauHasGsf = pflch->gsfTrackRef().isNonnull(); + Float_t TauSignalPFChargedCands = thePFTau.signalChargedHadrCands().size(); + Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); Float_t ElecEta = theGsfEle.eta(); Float_t ElecPhi = theGsfEle.phi(); @@ -871,14 +858,11 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) Float_t TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); - sumEnergy += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); + sumEnergy += (*pfCandidate)->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -886,23 +870,20 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); - else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); - } + const reco::Track* track = nullptr; + if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get(); + else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get(); + else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } } Float_t TauPt = thePFTau.pt(); @@ -910,13 +891,9 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size(); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); - if (pflch == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - if ( pflch->p() > 0. ) { - TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); - TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); + if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { + TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); } Float_t TauVisMass = thePFTau.mass(); Float_t TauHadrMva = std::max(thePFTau.electronPreIDOutput(),float(-1.0)); @@ -924,10 +901,10 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) std::vector GammasdPhi; std::vector GammasPt; for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEta.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhi.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEta.push_back(gamma->eta() - thePFTau.eta()); GammasdPhi.push_back(gamma->phi() - thePFTau.phi()); @@ -935,41 +912,38 @@ double AntiElectronIDMVA5::MVAValue(const reco::PFTau& thePFTau) GammasPt.push_back(gamma->pt()); } Float_t TauKFNumHits = -99.; - if ( (pflch->trackRef()).isNonnull() ) { - TauKFNumHits = pflch->trackRef()->numberOfValidHits(); + if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) { + TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits(); } Float_t TauGSFNumHits = -99.; Float_t TauGSFChi2 = -99.; Float_t TauGSFTrackResol = -99.; Float_t TauGSFTracklnPt = -99.; Float_t TauGSFTrackEta = -99.; - if ( (pflch->gsfTrackRef()).isNonnull() ) { - TauGSFChi2 = pflch->gsfTrackRef()->normalizedChi2(); - TauGSFNumHits = pflch->gsfTrackRef()->numberOfValidHits(); - if ( pflch->gsfTrackRef()->pt() > 0. ) { - TauGSFTrackResol = pflch->gsfTrackRef()->ptError()/pflch->gsfTrackRef()->pt(); - TauGSFTracklnPt = log(pflch->gsfTrackRef()->pt())*M_LN10; + if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) { + TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2(); + TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits(); + if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) { + TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt(); + TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*M_LN10; } - TauGSFTrackEta = pflch->gsfTrackRef()->eta(); + TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta(); } Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); + for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); - sumEnergyPhi += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy(); + sumEnergyPhi += (*pfCandidate)->energy(); } if ( sumEnergyPhi > 0. ) { TauPhi = sumPhiTimesEnergy/sumEnergyPhi; } Float_t TaudCrackPhi = dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ; Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance) ; - Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size(); - Float_t TauHasGsf = pflch->gsfTrackRef().isNonnull(); + Float_t TauSignalPFChargedCands = thePFTau.signalChargedHadrCands().size(); + Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); Float_t dummyElecEta = 9.9; @@ -1105,4 +1079,4 @@ double AntiElectronIDMVA5::dCrackEta(double eta) } return std::abs(retVal); -} +} \ No newline at end of file diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 1960dca4b682a..90af59f8ac183 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -523,14 +523,10 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*(*pfCandidate)->energy(); - sumEnergy += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for (const auto& pfcand : signalPFCands) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); + sumEnergy += pfcand->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -538,31 +534,27 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - const reco::Track* track = nullptr; - if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); - else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); - } + for (const auto& pfcand : signalPFCands) { + const reco::Track* track = nullptr; + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + } } Float_t TauPt = thePFTau.pt(); Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if ( thePFTau.leadChargedHadrCand()->p() > 0. ) { + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); if (pflch != nullptr) { TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); @@ -578,16 +570,16 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { + reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); + float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.eta()); @@ -598,9 +590,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } // pfGammas outside the tau signal cone else { - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.eta()); @@ -610,9 +602,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } } - for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { + reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); + float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -629,18 +621,15 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; if ( !usePhiAtEcalEntranceExtrapolation ){ - for (auto const& pfc : signalPFCands){ - const reco::PFCandidate* pfcand = dynamic_cast(pfc.get()); - if (pfcand != nullptr) { - sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfc->energy(); - sumEnergyPhi += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + for (auto const& pfcand : signalPFCands) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); + sumEnergyPhi += pfcand->energy(); } } else{ TauPhi= -99.; for (unsigned int o = 0; o < signalPFCands.size(); ++o ) { - reco::Candidate const* signalCand = signalPFCands[o].get(); + reco::PFCandidate const* signalCand = signalPFCands[o].get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) ) phi = aPos.Phi(); @@ -654,7 +643,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); Float_t TauHasGsf = false; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); if (pflch != nullptr) { TauHasGsf = pflch->gsfTrackRef().isNonnull(); } else { @@ -754,14 +743,10 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float TauEtaAtEcalEntrance = -99.; float sumEtaTimesEnergy = 0.; float sumEnergy = 0.; - const std::vector& signalPFCands = thePFTau.signalPFCands(); - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); - sumEnergy += pfcand->energy(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + const std::vector& signalPFCands = thePFTau.signalPFCands(); + for (const auto& pfcand : signalPFCands) { + sumEtaTimesEnergy += pfcand->positionAtECALEntrance().eta()*pfcand->energy(); + sumEnergy += pfcand->energy(); } if ( sumEnergy > 0. ) { TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy; @@ -769,31 +754,27 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float TauLeadChargedPFCandEtaAtEcalEntrance = -99.; float TauLeadChargedPFCandPt = -99.; - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { + for (const auto& pfcand : signalPFCands) { const reco::Track* track = nullptr; - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); - else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); - else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); - if ( track ) { - if ( track->pt() > TauLeadChargedPFCandPt ) { - TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); - TauLeadChargedPFCandPt = track->pt(); - } + if ( pfcand->trackRef().isNonnull() ) track = pfcand->trackRef().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->innerTrack().isNonnull() ) track = pfcand->muonRef()->innerTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->globalTrack().isNonnull() ) track = pfcand->muonRef()->globalTrack().get(); + else if ( pfcand->muonRef().isNonnull() && pfcand->muonRef()->outerTrack().isNonnull() ) track = pfcand->muonRef()->outerTrack().get(); + else if ( pfcand->gsfTrackRef().isNonnull() ) track = pfcand->gsfTrackRef().get(); + if ( track ) { + if ( track->pt() > TauLeadChargedPFCandPt ) { + TauLeadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); + TauLeadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + } } Float_t TauPt = thePFTau.pt(); Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + if ( thePFTau.leadChargedHadrCand()->p() > 0. ) { + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); if (pflch != nullptr) { TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); @@ -809,16 +790,16 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalPFGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { + reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); + float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.eta()); @@ -829,9 +810,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc } // pfGammas outside the tau signal cone else { - if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi()); + if ( thePFTau.leadChargedHadrCand().isNonnull() ) { + GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi()); } else { GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.eta()); @@ -841,9 +822,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc } } - for ( unsigned i = 0 ; i < thePFTau.signalPFChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalPFChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { + reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); + float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -860,19 +841,15 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; if ( !usePhiAtEcalEntranceExtrapolation ){ - for ( std::vector::const_iterator pfCandidate = signalPFCands.begin(); - pfCandidate != signalPFCands.end(); ++pfCandidate ) { - const reco::PFCandidate* pfcand = dynamic_cast(pfCandidate->get()); - if (pfcand != nullptr) { - sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); - sumEnergyPhi += pfcand->energy(); - } else { throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } + for (const auto& pfcand : signalPFCands) { + sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); + sumEnergyPhi += pfcand->energy(); } } else{ TauPhi= -99.; for (unsigned int o = 0; o < signalPFCands.size(); o++ ) { - reco::Candidate const* signalCand = signalPFCands[o].get(); + reco::PFCandidate const* signalCand = signalPFCands[o].get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -886,7 +863,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); Float_t TauHasGsf = false; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadPFChargedHadrCand().get()); + const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); if (pflch != nullptr) { TauHasGsf = pflch->gsfTrackRef().isNonnull(); } else { diff --git a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc index ae129d358d7f7..189f5d3869884 100644 --- a/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/HPSPFRecoTauAlgorithm.cc @@ -60,21 +60,15 @@ HPSPFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& tagInfo,const Vertex& v pfTau = getBestTauCandidate(pfTaus_); //Set the IP for the leading track - if(TransientTrackBuilder_!=nullptr) { - const reco::PFCandidate* pflch = dynamic_cast(pfTau.leadPFChargedHadrCand().get()); - if (pflch != nullptr) { - if (pflch->trackRef().isNonnull()) { - const TransientTrack leadTrack=TransientTrackBuilder_->build(pflch->trackRef()); - if(pfTau.pfTauTagInfoRef().isNonnull()) { - if(pfTau.pfTauTagInfoRef()->pfjetRef().isNonnull()) { - JetBaseRef jet = pfTau.pfTauTagInfoRef()->pfjetRef(); - GlobalVector jetDir(jet->px(),jet->py(),jet->pz()); - if(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).first) - pfTau.setleadPFChargedHadrCandsignedSipt(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).second.significance()); - } - } + if(TransientTrackBuilder_!=nullptr &&pfTau.leadPFChargedHadrCand()->trackRef().isNonnull()) { + const TransientTrack leadTrack=TransientTrackBuilder_->build(pfTau.leadPFChargedHadrCand()->trackRef()); + if(pfTau.pfTauTagInfoRef().isNonnull()) + if(pfTau.pfTauTagInfoRef()->pfjetRef().isNonnull()) { + JetBaseRef jet = pfTau.pfTauTagInfoRef()->pfjetRef(); + GlobalVector jetDir(jet->px(),jet->py(),jet->pz()); + if(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).first) + pfTau.setleadPFChargedHadrCandsignedSipt(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).second.significance()); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } } else { //null PFTau @@ -116,10 +110,10 @@ HPSPFRecoTauAlgorithm::buildOneProng(const reco::PFTauTagInfoRef& tagInfo,const signal.push_back(hadron); //Set The signal candidates of the PF Tau - tau.setsignalPFChargedHadrCands(signal); - tau.setsignalPFCands(signal); - tau.setleadPFChargedHadrCand(hadron); - tau.setleadPFCand(hadron); + tau.setsignalChargedHadrCands(signal); + tau.setsignalCands(signal); + tau.setleadChargedHadrCand(hadron); + tau.setleadCand(hadron); //Fill isolation variables associateIsolationCandidates(tau,0.0); @@ -204,17 +198,17 @@ HPSPFRecoTauAlgorithm::buildOneProngStrip(const reco::PFTauTagInfoRef& tagInfo,c } //Set the PFTau - tau.setsignalPFChargedHadrCands(signalH); - tau.setsignalPFGammaCands(signalG); - tau.setsignalPFCands(signal); - tau.setleadPFChargedHadrCand(*hadron); - tau.setleadPFNeutralCand(emConstituents[0]); + tau.setsignalChargedHadrCands(signalH); + tau.setsignalGammaCands(signalG); + tau.setsignalCands(signal); + tau.setleadChargedHadrCand(*hadron); + tau.setleadNeutralCand(emConstituents[0]); //Set the lead Candidate->Can be the hadron or the leading PFGamma(When we clear the Dataformat we will put the strip) if((*hadron)->pt()>emConstituents[0]->pt()) - tau.setleadPFCand(*hadron); + tau.setleadCand(*hadron); else - tau.setleadPFCand(emConstituents[0]); + tau.setleadCand(emConstituents[0]); //Apply the signal cone size formula if(isNarrowTau(tau,tauCone)) { @@ -317,16 +311,16 @@ HPSPFRecoTauAlgorithm::buildOneProngTwoStrips(const reco::PFTauTagInfoRef& tagIn } //Set the PFTau - tau.setsignalPFChargedHadrCands(signalH); - tau.setsignalPFGammaCands(signalG); - tau.setsignalPFCands(signal); - tau.setleadPFChargedHadrCand(*hadron); + tau.setsignalChargedHadrCands(signalH); + tau.setsignalGammaCands(signalG); + tau.setsignalCands(signal); + tau.setleadChargedHadrCand(*hadron); //Set the lead Candidate->Can be the hadron or the leading PFGamma(When we clear the Dataformat we will put the strip) if((*hadron)->pt()>emConstituents1[0]->pt()) - tau.setleadPFCand(*hadron); + tau.setleadCand(*hadron); else - tau.setleadPFCand(emConstituents1[0]); + tau.setleadCand(emConstituents1[0]); //Apply the cone size formula if(isNarrowTau(tau,tauCone)) { @@ -377,7 +371,7 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con const reco::PFCandidate* h2 = dynamic_cast(c_h2.get()); const reco::PFCandidate* h3 = dynamic_cast(c_h3.get()); if (h1 == nullptr || h2 == nullptr || h3 == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm as not updated to cope with PFTaus made from other Candidates.\n"; } //check charge Compatibility and lead track @@ -395,9 +389,9 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con if(ROOT::Math::VectorUtil::DeltaR(tau.p4(),tagInfo->pfjetRef()->p4()) signal; - signal.push_back(h1->masterClone().castTo >()); - signal.push_back(h2->masterClone().castTo >()); - signal.push_back(h3->masterClone().castTo >()); + signal.push_back(c_h1); + signal.push_back(c_h2); + signal.push_back(c_h3); //calculate the tau cone by getting the maximum distance double tauCone = 10000.0; if(coneMetric_=="DR") @@ -414,10 +408,10 @@ HPSPFRecoTauAlgorithm::buildThreeProngs(const reco::PFTauTagInfoRef& tagInfo,con } //Set The PFTau - tau.setsignalPFChargedHadrCands(signal); - tau.setsignalPFCands(signal); - tau.setleadPFChargedHadrCand(h1->masterClone().castTo >()); - tau.setleadPFCand(h1->masterClone().castTo >()); + tau.setsignalChargedHadrCands(signal); + tau.setsignalCands(signal); + tau.setleadChargedHadrCand(c_h1); + tau.setleadCand(c_h1); if(isNarrowTau(tau,tauCone)) { //calculate the isolation Deposits @@ -525,12 +519,12 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, } //remove the signal Constituents from the collections - for(std::vector::const_iterator i=tau.signalPFChargedHadrCands().begin();i!=tau.signalPFChargedHadrCands().end();++i) + for(std::vector::const_iterator i=tau.signalChargedHadrCands().begin();i!=tau.signalChargedHadrCands().end();++i) { removeCandidateFromRefVector(*i,hadrons); } - for(std::vector::const_iterator i=tau.signalPFGammaCands().begin();i!=tau.signalPFGammaCands().end();++i) + for(std::vector::const_iterator i=tau.signalGammaCands().begin();i!=tau.signalGammaCands().end();++i) { removeCandidateFromRefVector(*i,gammas); removeCandidateFromRefVector(*i,hadrons);//special case where we included a hadron if the strip! @@ -551,9 +545,9 @@ HPSPFRecoTauAlgorithm::associateIsolationCandidates(reco::PFTau& tau, tau.setisolationPFChargedHadrCandsPtSum(sumPT); tau.setisolationPFGammaCandsEtSum(sumET); - tau.setisolationPFChargedHadrCands(hadrons); - tau.setisolationPFNeutrHadrCands(neutral); - tau.setisolationPFGammaCands(gammas); + tau.setisolationChargedHadrCands(hadrons); + tau.setisolationNeutrHadrCands(neutral); + tau.setisolationGammaCands(gammas); std::vector isoAll = hadrons; for(unsigned int i=0;i(tau.leadPFChargedHadrCand().get()); - if (leadCharged == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - MuonRef mu =leadCharged->muonRef(); + MuonRef mu =tau.leadPFChargedHadrCand()->muonRef(); if(mu.isNonnull()){ segComp=(float)(mu->matches().size()); if(mu->caloCompatibility()>caloComp) @@ -610,11 +600,7 @@ HPSPFRecoTauAlgorithm::applyElectronRejection(reco::PFTau& tau,double stripEnerg if(tau.leadPFChargedHadrCand().isNonnull()) { - const reco::PFCandidate* leadCharged = dynamic_cast(tau.leadPFChargedHadrCand().get()); - if (leadCharged == nullptr) { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - } - + PFCandidatePtr leadCharged = tau.leadPFChargedHadrCand(); math::XYZVector caloDir(leadCharged->positionAtECALEntrance().x(), leadCharged->positionAtECALEntrance().y(), leadCharged->positionAtECALEntrance().z()); @@ -735,14 +721,11 @@ HPSPFRecoTauAlgorithm::refitThreeProng(reco::PFTau& tau) { bool response=false; //Get Hadrons - std::vector hadrons = tau.signalPFChargedHadrCands(); - const reco::PFCandidate* h1 = dynamic_cast(hadrons[0].get()); - const reco::PFCandidate* h2 = dynamic_cast(hadrons[1].get()); - const reco::PFCandidate* h3 = dynamic_cast(hadrons[2].get()); - - if (h1 == nullptr || h2 == nullptr || h3 == nullptr) - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - + std::vector hadrons = tau.signalPFChargedHadrCands(); + PFCandidatePtr h1 = hadrons[0]; + PFCandidatePtr h2 = hadrons[1]; + PFCandidatePtr h3 = hadrons[2]; + //Make transient tracks std::vector transientTracks; transientTracks.push_back(TransientTrackBuilder_->build(h1->trackRef())); @@ -795,4 +778,3 @@ HPSPFRecoTauAlgorithm::getBestTauCandidate(reco::PFTauCollection& taus) return *it; } - diff --git a/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc b/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc index 11df4d64fe024..e946872859a02 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauAlgorithm.cc @@ -104,7 +104,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c PFTauElementsOperators myPFTauElementsOperators(myPFTau); double myMatchingConeSize=myPFTauElementsOperators.computeConeSize(myMatchingConeSizeTFormula,MatchingConeSize_min_,MatchingConeSize_max_); - CandidatePtr myleadPFChargedCand=myPFTauElementsOperators.leadPFChargedHadrCand(MatchingConeMetric_,myMatchingConeSize,PFTauAlgo_PFCand_minPt_); + CandidatePtr myleadPFChargedCand=myPFTauElementsOperators.leadChargedHadrCand(MatchingConeMetric_,myMatchingConeSize,PFTauAlgo_PFCand_minPt_); // These two quantities always taken from the signal cone CandidatePtr myleadPFNeutralCand; @@ -115,7 +115,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // Determine the SIPT of the lead track if(myleadPFChargedCand.isNonnull()) { - myPFTau.setleadPFChargedHadrCand(myleadPFChargedCand); + myPFTau.setleadChargedHadrCand(myleadPFChargedCand); const reco::PFCandidate* pflch = dynamic_cast(myleadPFChargedCand.get()); if (pflch == nullptr) throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; @@ -189,19 +189,19 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c } // Set the Charged hadronics that live in the signal cones - myPFTau.setsignalPFChargedHadrCands(mySignalPFChargedHadrCands); + myPFTau.setsignalChargedHadrCands(mySignalPFChargedHadrCands); // Set the neurtral hadrons that live in the signal cone mySignalPFNeutrHadrCands=myPFTauElementsOperators.PFNeutrHadrCandsInCone(tauAxis, HCALSignalConeMetric_, myHCALSignalConeSize, PFTauAlgo_NeutrHadrCand_minPt_); - myPFTau.setsignalPFNeutrHadrCands(mySignalPFNeutrHadrCands); + myPFTau.setsignalNeutrHadrCands(mySignalPFNeutrHadrCands); // Compute the gammas that live in the signal cone mySignalPFGammaCands=myPFTauElementsOperators.PFGammaCandsInCone(tauAxis, ECALSignalConeMetric_,myECALSignalConeSize,PFTauAlgo_GammaCand_minPt_); - myPFTau.setsignalPFGammaCands(mySignalPFGammaCands); + myPFTau.setsignalGammaCands(mySignalPFGammaCands); // Add charged objects to signal cone, and calculate charge if(!mySignalPFChargedHadrCands.empty()) { @@ -227,9 +227,9 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c } mySignalPFCands.push_back(mySignalPFGammaCands[i]); } - myPFTau.setsignalPFCands(mySignalPFCands); + myPFTau.setsignalCands(mySignalPFCands); // Set leading gamma - myPFTau.setleadPFNeutralCand(myleadPFNeutralCand); + myPFTau.setleadNeutralCand(myleadPFNeutralCand); // Logic to determine lead PFCand. If the lead charged object // is above the threshold, take that. If the lead charged object is less @@ -237,9 +237,9 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c // take the gamma as the leadPFCand. Otherwise it is null. if(myleadPFChargedCand->pt() > LeadPFCand_minPt_) { - myPFTau.setleadPFCand(myleadPFChargedCand); + myPFTau.setleadCand(myleadPFChargedCand); } else if (maxSignalGammaPt > LeadPFCand_minPt_) { - myPFTau.setleadPFCand(myleadPFNeutralCand); + myPFTau.setleadCand(myleadPFNeutralCand); } // Declare isolation collections @@ -262,19 +262,19 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c myIsolPFChargedHadrCands = TauTagTools::filteredPFChargedHadrCandsByNumTrkHits( myUnfilteredIsolPFChargedHadrCands, ChargedHadrCand_IsolAnnulus_minNhits_); - myPFTau.setisolationPFChargedHadrCands(myIsolPFChargedHadrCands); + myPFTau.setisolationChargedHadrCands(myIsolPFChargedHadrCands); // Fill neutral hadrons myIsolPFNeutrHadrCands = myPFTauElementsOperators.PFNeutrHadrCandsInAnnulus( tauAxis, HCALSignalConeMetric_, myHCALSignalConeSize, HCALIsolConeMetric_, myHCALIsolConeSize, PFTauAlgo_NeutrHadrCand_minPt_); - myPFTau.setisolationPFNeutrHadrCands(myIsolPFNeutrHadrCands); + myPFTau.setisolationNeutrHadrCands(myIsolPFNeutrHadrCands); // Fill gamma candidates myIsolPFGammaCands = myPFTauElementsOperators.PFGammaCandsInAnnulus( tauAxis, ECALSignalConeMetric_, myECALSignalConeSize, ECALIsolConeMetric_, myECALIsolConeSize, PFTauAlgo_GammaCand_minPt_); - myPFTau.setisolationPFGammaCands(myIsolPFGammaCands); + myPFTau.setisolationGammaCands(myIsolPFGammaCands); //Incorporate converted gammas from isolation ellipse into signal ... ELLL //Get pair with in/out elements using the isoPFGammaCandidates set by default @@ -295,10 +295,10 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c mySignalPFCands.push_back(*inEllipseIt); mySignalPFGammaCands.push_back(*inEllipseIt); } - myPFTau.setsignalPFCands(mySignalPFCands); + myPFTau.setsignalCands(mySignalPFCands); //redefine isoPFGammaCandidates to be the outside elements myIsolPFGammaCands=elementsOutEllipse; - myPFTau.setisolationPFGammaCands(myIsolPFGammaCands); + myPFTau.setisolationGammaCands(myIsolPFGammaCands); } @@ -321,7 +321,7 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c myIsolPFCands.push_back(myIsolPFGammaCands[i]); } myPFTau.setisolationPFGammaCandsEtSum(myIsolPFGammaCands_Etsum); - myPFTau.setisolationPFCands(myIsolPFCands); + myPFTau.setisolationCands(myIsolPFCands); //Making the alternateLorentzVector, i.e. direction with only signal components math::XYZTLorentzVector alternatLorentzVect(0.,0.,0.,0.); @@ -351,9 +351,9 @@ PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, c } // set the leading, signal cone and isolation annulus Tracks (the initial list of Tracks was catched through a JetTracksAssociation - // object, not through the charged hadr. Candidates inside the PFJet ; + // object, not through the charged hadr. PFCandidates inside the PFJet ; // the motivation for considering these objects is the need for checking that a selection by the - // charged hadr. Candidates is equivalent to a selection by the rec. Tracks.) + // charged hadr. PFCandidates is equivalent to a selection by the rec. Tracks.) TrackRef myleadTk=myPFTauElementsOperators.leadTk(MatchingConeMetric_,myMatchingConeSize,LeadTrack_minPt_); myPFTau.setleadTrack(myleadTk); if(myleadTk.isNonnull()){ @@ -541,4 +541,4 @@ PFRecoTauAlgorithm::checkPos(const std::vector& CalPos,const mat } return flag; //return false; -} +} \ No newline at end of file diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index 40a97e5da4ff2..ba06e6349d532 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -30,22 +30,22 @@ RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle< copyGammas_ = copyGammasFromPiZeros; // Initialize our Accessors collections_[std::make_pair(kSignal, kChargedHadron)] = - &tau_->selectedSignalPFChargedHadrCands_; + &tau_->selectedSignalChargedHadrCands_; collections_[std::make_pair(kSignal, kGamma)] = - &tau_->selectedSignalPFGammaCands_; + &tau_->selectedSignalGammaCands_; collections_[std::make_pair(kSignal, kNeutralHadron)] = - &tau_->selectedSignalPFNeutrHadrCands_; + &tau_->selectedSignalNeutrHadrCands_; collections_[std::make_pair(kSignal, kAll)] = - &tau_->selectedSignalPFCands_; + &tau_->selectedSignalCands_; collections_[std::make_pair(kIsolation, kChargedHadron)] = - &tau_->selectedIsolationPFChargedHadrCands_; + &tau_->selectedIsolationChargedHadrCands_; collections_[std::make_pair(kIsolation, kGamma)] = - &tau_->selectedIsolationPFGammaCands_; + &tau_->selectedIsolationGammaCands_; collections_[std::make_pair(kIsolation, kNeutralHadron)] = - &tau_->selectedIsolationPFNeutrHadrCands_; + &tau_->selectedIsolationNeutrHadrCands_; collections_[std::make_pair(kIsolation, kAll)] = - &tau_->selectedIsolationPFCands_; + &tau_->selectedIsolationCands_; // Build our temporary sorted collections, since you can't use stl sorts on // RefVectors @@ -102,10 +102,10 @@ void RecoTauConstructor::reserveTauChargedHadron(Region region, size_t size) { if ( region == kSignal ) { tau_->signalTauChargedHadronCandidatesRestricted().reserve(size); - tau_->selectedSignalPFChargedHadrCands_.reserve(size); + tau_->selectedSignalChargedHadrCands_.reserve(size); } else { tau_->isolationTauChargedHadronCandidatesRestricted().reserve(size); - tau_->selectedIsolationPFChargedHadrCands_.reserve(size); + tau_->selectedIsolationChargedHadrCands_.reserve(size); } } @@ -422,28 +422,28 @@ std::auto_ptr RecoTauConstructor::get(bool setupLeadingObjects) if ( setupLeadingObjects ) { typedef std::vector::const_iterator Iter; // Find the highest PT object in the signal cone - Iter leadingCand = leadPFCand( + Iter leadingCand = leadCand( getCollection(kSignal, kAll)->begin(), getCollection(kSignal, kAll)->end()); if ( leadingCand != getCollection(kSignal, kAll)->end() ) - tau_->setleadPFCand(*leadingCand); + tau_->setleadCand(*leadingCand); // Hardest charged object in signal cone - Iter leadingChargedCand = leadPFCand( + Iter leadingChargedCand = leadCand( getCollection(kSignal, kChargedHadron)->begin(), getCollection(kSignal, kChargedHadron)->end()); if ( leadingChargedCand != getCollection(kSignal, kChargedHadron)->end() ) - tau_->setleadPFChargedHadrCand(*leadingChargedCand); + tau_->setleadChargedHadrCand(*leadingChargedCand); // Hardest gamma object in signal cone - Iter leadingGammaCand = leadPFCand( + Iter leadingGammaCand = leadCand( getCollection(kSignal, kGamma)->begin(), getCollection(kSignal, kGamma)->end()); if(leadingGammaCand != getCollection(kSignal, kGamma)->end()) - tau_->setleadPFNeutralCand(*leadingGammaCand); + tau_->setleadNeutralCand(*leadingGammaCand); } return tau_; } diff --git a/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc b/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc index 6b88bd0e86090..5899fd0623a01 100644 --- a/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc +++ b/RecoTauTag/RecoTau/src/RecoTauDiscriminantFunctions.cc @@ -47,21 +47,21 @@ class DeltaRToAxis { } // end helper functions CandidatePtr mainTrack(Tau tau) { - if (tau.signalPFChargedHadrCands().size() == 3) { + if (tau.signalChargedHadrCands().size() == 3) { for (size_t itrk = 0; itrk < 3; ++itrk) { - if (tau.signalPFChargedHadrCands()[itrk]->charge() * tau.charge() < 0) - return tau.signalPFChargedHadrCands()[itrk]; + if (tau.signalChargedHadrCands()[itrk]->charge() * tau.charge() < 0) + return tau.signalChargedHadrCands()[itrk]; } } - return tau.leadPFChargedHadrCand(); + return tau.leadChargedHadrCand(); } std::vector notMainTrack(Tau tau) { const CandidatePtr& mainTrackPtr = mainTrack(tau); std::vector output; - output.reserve(tau.signalPFChargedHadrCands().size() - 1); - BOOST_FOREACH(const CandidatePtr& ptr, tau.signalPFChargedHadrCands()) { + output.reserve(tau.signalChargedHadrCands().size() - 1); + BOOST_FOREACH(const CandidatePtr& ptr, tau.signalChargedHadrCands()) { if (ptr != mainTrackPtr) output.push_back(ptr); } @@ -115,7 +115,7 @@ double IsolationECALPtFraction(Tau tau) { double IsolationNeutralHadronPtFraction(Tau tau) { double sum = 0.0; - BOOST_FOREACH(CandidatePtr cand, tau.isolationPFNeutrHadrCands()) { + BOOST_FOREACH(CandidatePtr cand, tau.isolationNeutrHadrCands()) { sum += cand->pt(); } return sum/tau.jetRef()->pt(); @@ -129,7 +129,7 @@ double ScaledEtaJetCollimation(Tau tau) { double OpeningDeltaR(Tau tau) { double sumEt = 0; double weightedDeltaR = 0; - BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalPFCands()) { + BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalCands()) { double candEt = cand->et(); double candDeltaR = reco::deltaR(cand->p4(), tau.p4()); sumEt += candEt; @@ -141,7 +141,7 @@ double OpeningDeltaR(Tau tau) { double OpeningAngle3D(Tau tau) { double sumE = 0; double weightedAngle = 0; - BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalPFCands()) { + BOOST_FOREACH(const reco::CandidatePtr& cand, tau.signalCands()) { double candE = cand->energy(); double candAngle = angle(cand->p4(), tau.p4()); sumE += candE; @@ -152,7 +152,7 @@ double OpeningAngle3D(Tau tau) { double ScaledOpeningDeltaR(Tau tau) { double max = 0.0; - const std::vector& cands = tau.signalPFCands(); + const std::vector& cands = tau.signalCands(); for (size_t i = 0; i < cands.size()-1; ++i) { for (size_t j = i+1; j < cands.size(); ++j) { double deltaRVal = deltaR(cands[i]->p4(), cands[j]->p4()); @@ -174,10 +174,10 @@ double ScaledPhiJetCollimation(Tau tau) { } double IsolationChargedAveragePtFraction(Tau tau) { - size_t nIsoCharged = tau.isolationPFChargedHadrCands().size(); + size_t nIsoCharged = tau.isolationChargedHadrCands().size(); double averagePt = (nIsoCharged) ? tau.isolationPFChargedHadrCandsPtSum()/nIsoCharged : 0; - return averagePt/tau.leadPFChargedHadrCand()->pt(); + return averagePt/tau.leadChargedHadrCand()->pt(); } double MainTrackPtFraction(Tau tau) { @@ -204,7 +204,7 @@ VDouble Dalitz2(Tau tau) { } double IsolationChargedSumHard(Tau tau) { - VDouble isocands = extract(tau.isolationPFChargedHadrCands(), + VDouble isocands = extract(tau.isolationChargedHadrCands(), std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { @@ -215,7 +215,7 @@ double IsolationChargedSumHard(Tau tau) { } double IsolationChargedSumSoft(Tau tau) { - VDouble isocands = extract(tau.isolationPFChargedHadrCands(), + VDouble isocands = extract(tau.isolationChargedHadrCands(), std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { @@ -235,7 +235,7 @@ double IsolationChargedSumSoftRelative(Tau tau) { } double IsolationECALSumHard(Tau tau) { - VDouble isocands = extract(tau.isolationPFGammaCands(), + VDouble isocands = extract(tau.isolationGammaCands(), std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { @@ -246,7 +246,7 @@ double IsolationECALSumHard(Tau tau) { } double IsolationECALSumSoft(Tau tau) { - VDouble isocands = extract(tau.isolationPFGammaCands(), + VDouble isocands = extract(tau.isolationGammaCands(), std::mem_fun_ref(&Candidate::pt)); double output = 0.0; BOOST_FOREACH(double pt, isocands) { @@ -267,7 +267,7 @@ double IsolationECALSumSoftRelative(Tau tau) { double EMFraction(Tau tau) { //double result = tau.emFraction(); reco::Candidate::LorentzVector gammaP4; - BOOST_FOREACH(const reco::CandidatePtr& gamma, tau.signalPFGammaCands()) { + BOOST_FOREACH(const reco::CandidatePtr& gamma, tau.signalGammaCands()) { gammaP4 += gamma->p4(); } double result = gammaP4.pt()/tau.pt(); @@ -276,11 +276,11 @@ double EMFraction(Tau tau) { LogDebug("TauDiscFunctions") << "EM fraction = " << result << tau ; LogDebug("TauDiscFunctions") << "charged" ; - BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalPFChargedHadrCands()) { + BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalChargedHadrCands()) { LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " pdgId: " << cand->pdgId() << " key: " << cand.key() ; } LogDebug("TauDiscFunctions") << "gammas" ; - BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalPFGammaCands()) { + BOOST_FOREACH(const reco::CandidatePtr cand, tau.signalGammaCands()) { LogDebug("TauDiscFunctions") << " pt: " << cand->pt() << " pdgId: " << cand->pdgId() << " key: " << cand.key() ; } } @@ -292,12 +292,12 @@ double ImpactParameterSignificance(Tau tau) { } double OutlierN(Tau tau) { - return tau.isolationPFChargedHadrCands().size() + - tau.isolationPFGammaCands().size(); + return tau.isolationChargedHadrCands().size() + + tau.isolationGammaCands().size(); } double OutlierNCharged(Tau tau) { - return tau.isolationPFChargedHadrCands().size(); + return tau.isolationChargedHadrCands().size(); } double MainTrackPt(Tau tau) { @@ -356,29 +356,29 @@ VDouble PiZeroAngle(Tau tau) { // Isolation quantities VDouble OutlierPt(Tau tau) { - return extract(tau.isolationPFCands(), std::mem_fun_ref(&Candidate::pt)); + return extract(tau.isolationCands(), std::mem_fun_ref(&Candidate::pt)); } VDouble OutlierAngle(Tau tau) { - return extract(tau.isolationPFCands(), DeltaRToAxis(tau.p4())); + return extract(tau.isolationCands(), DeltaRToAxis(tau.p4())); } VDouble ChargedOutlierPt(Tau tau) { - return extract(tau.isolationPFChargedHadrCands(), + return extract(tau.isolationChargedHadrCands(), std::mem_fun_ref(&Candidate::pt)); } VDouble ChargedOutlierAngle(Tau tau) { - return extract(tau.isolationPFChargedHadrCands(), DeltaRToAxis(tau.p4())); + return extract(tau.isolationChargedHadrCands(), DeltaRToAxis(tau.p4())); } VDouble NeutralOutlierPt(Tau tau) { - return extract(tau.isolationPFGammaCands(), + return extract(tau.isolationGammaCands(), std::mem_fun_ref(&Candidate::pt)); } VDouble NeutralOutlierAngle(Tau tau) { - return extract(tau.isolationPFGammaCands(), DeltaRToAxis(tau.p4())); + return extract(tau.isolationGammaCands(), DeltaRToAxis(tau.p4())); } // Invariant mass of main track with other combinations diff --git a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc index 6857a9b0ca5bc..eb33d1d830599 100644 --- a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc +++ b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc @@ -77,21 +77,18 @@ RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { typedef std::list CandList; // Copy original iso collections. - std::copy(tau.isolationPFGammaCands().begin(), - tau.isolationPFGammaCands().end(), std::back_inserter(output.gammas)); - std::copy(tau.isolationPFNeutrHadrCands().begin(), - tau.isolationPFNeutrHadrCands().end(), + std::copy(tau.isolationGammaCands().begin(), + tau.isolationGammaCands().end(), std::back_inserter(output.gammas)); + std::copy(tau.isolationNeutrHadrCands().begin(), + tau.isolationNeutrHadrCands().end(), std::back_inserter(output.h0s)); std::vector courses; courses.push_back(&(output.h0s)); courses.push_back(&(output.gammas)); // Mask using each one of the tracks - BOOST_FOREACH(const reco::CandidatePtr& c_track, + BOOST_FOREACH(const reco::PFCandidatePtr& track, tau.signalPFChargedHadrCands()) { - const reco::PFCandidate* track = dynamic_cast(c_track.get()); - if (track == nullptr) - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; double trackerEnergy = track->energy(); double linkedEcalEnergy = track->ecalEnergy(); double linkedHcalEnergy = track->hcalEnergy(); @@ -139,7 +136,7 @@ RecoTauIsolationMasking::mask(const reco::PFTau& tau) const { // This removes upward fluctuating HCAL objects if (finalHcalCone_ > 0) { MultiTrackDRFilter hcalFinalFilter(finalHcalCone_, - tau.signalPFChargedHadrCands()); + tau.signalChargedHadrCands()); std::remove_if(output.h0s.begin(), output.h0s.end(), hcalFinalFilter); } return output; diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index 9a9cb9c804f75..6bc461bff41de 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -73,10 +73,10 @@ const reco::CandidatePtr RecoTauVertexAssociator::getLeadCand(const Jet& jet) co std::cout << " num. selectedPFCands = " << selectedPFCands.size() << std::endl; } - CandidatePtr leadPFCand; + CandidatePtr leadCand; if ( !selectedPFCands.empty() ) { double leadTrackPt = 0.; - if ( leadingTrkOrPFCandOption_ == kFirstTrack){ leadPFCand=selectedPFCands[0];} + if ( leadingTrkOrPFCandOption_ == kFirstTrack){ leadCand=selectedPFCands[0];} else { for ( std::vector::const_iterator pfCand = selectedPFCands.begin(); pfCand != selectedPFCands.end(); ++pfCand ) { @@ -94,36 +94,36 @@ const reco::CandidatePtr RecoTauVertexAssociator::getLeadCand(const Jet& jet) co trackPt = TMath::Min(actualTrackPt, (double)(*pfCand)->pt()); } else assert(0); if ( trackPt > leadTrackPt ) { - leadPFCand = (*pfCand); + leadCand = (*pfCand); leadTrackPt = trackPt; } } } } - if ( leadPFCand.isNull() ) { + if ( leadCand.isNull() ) { if ( recoverLeadingTrk_ ) { - leadPFCand = chargedPFCands[0]; + leadCand = chargedPFCands[0]; } else { return reco::CandidatePtr(nullptr, 0); } } if ( verbosity_ >= 1 ) { - std::cout << "leadPFCand: Pt = " << leadPFCand->pt() << ", eta = " << leadPFCand->eta() << ", phi = " << leadPFCand->phi() << std::endl; + std::cout << "leadCand: Pt = " << leadCand->pt() << ", eta = " << leadCand->eta() << ", phi = " << leadCand->phi() << std::endl; } - return leadPFCand; + return leadCand; } const reco::Track* RecoTauVertexAssociator::getLeadTrack(const Jet& jet) const { - auto leadPFCand = getLeadCand(jet); - if(leadPFCand.isNull()) return nullptr; - const reco::Track* track = getTrack(*leadPFCand); + auto leadCand = getLeadCand(jet); + if(leadCand.isNull()) return nullptr; + const reco::Track* track = getTrack(*leadCand); return track; } const reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrackRef(const Jet& jet) const { - auto leadPFCand = getLeadCand(jet); - if(leadPFCand.isNull()) return reco::TrackBaseRef(); - return getTrackRef(*leadPFCand); + auto leadCand = getLeadCand(jet); + if(leadCand.isNull()) return reco::TrackBaseRef(); + return getTrackRef(*leadCand); } namespace { @@ -277,8 +277,8 @@ reco::VertexRef RecoTauVertexAssociator::associatedVertex(const PFTau& tau, bool useJet) const { if ( !useJet ) { - if ( tau.leadPFChargedHadrCand().isNonnull() ) { - const reco::Track* track = getTrack(*tau.leadPFChargedHadrCand()); + if ( tau.leadChargedHadrCand().isNonnull() ) { + const reco::Track* track = getTrack(*tau.leadChargedHadrCand()); if (track != nullptr) return associatedVertex(track); } diff --git a/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h b/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h index b1b8554f8fa64..0c5aa2be20cee 100644 --- a/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h +++ b/RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h @@ -34,14 +34,14 @@ class PFTauElementsOperators : public TauElementsOperators { ~PFTauElementsOperators(){} void setAreaMetricrecoElementsmaxabsEta( double x); //return the leading PFCandidate in a given cone around the jet axis or a given direction - reco::CandidatePtr leadPFCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFChargedHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFChargedHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFNeutrHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFNeutrHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFGammaCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; - reco::CandidatePtr leadPFGammaCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadChargedHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadChargedHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadNeutrHadrCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadNeutrHadrCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadGammaCand(const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; + reco::CandidatePtr leadGammaCand(const math::XYZVector& myVector,const std::string matchingcone_metric,const double matchingcone_size,const double minPt)const; // return all PFCandidates in a cone of metric* "cone_metric" and size "conesize" around a direction "myVector" std::vector PFCandsInCone(const std::vector& PFCands,const math::XYZVector& myVector,const std::string conemetric,const double conesize,const double minPt)const; diff --git a/RecoTauTag/TauTagTools/plugins/RecoTauObjectEmbedderPlugin.cc b/RecoTauTag/TauTagTools/plugins/RecoTauObjectEmbedderPlugin.cc index 822ece3be55dd..20e0e0a54c49e 100644 --- a/RecoTauTag/TauTagTools/plugins/RecoTauObjectEmbedderPlugin.cc +++ b/RecoTauTag/TauTagTools/plugins/RecoTauObjectEmbedderPlugin.cc @@ -45,7 +45,7 @@ unsigned int nGammas(const GenJet& jet) { } unsigned int nCharged(const PFTau& tau) { - return tau.signalPFChargedHadrCands().size(); + return tau.signalChargedHadrCands().size(); } unsigned int nGammas(const PFTau& tau) { return tau.signalPiZeroCandidates().size(); diff --git a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc index 789ec8b8d6450..26cbb1b3161ed 100644 --- a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc +++ b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc @@ -9,10 +9,10 @@ using std::string; PFChargedHadrCands_=thePFTau.pfTauTagInfoRef()->PFChargedHadrCands(); PFNeutrHadrCands_=thePFTau.pfTauTagInfoRef()->PFNeutrHadrCands(); PFGammaCands_=thePFTau.pfTauTagInfoRef()->PFGammaCands(); - IsolPFCands_=thePFTau.isolationPFCands(); - IsolPFChargedHadrCands_=thePFTau.isolationPFChargedHadrCands(); - IsolPFNeutrHadrCands_=thePFTau.isolationPFNeutrHadrCands(); - IsolPFGammaCands_=thePFTau.isolationPFGammaCands(); + IsolPFCands_=thePFTau.isolationCands(); + IsolPFChargedHadrCands_=thePFTau.isolationChargedHadrCands(); + IsolPFNeutrHadrCands_=thePFTau.isolationNeutrHadrCands(); + IsolPFGammaCands_=thePFTau.isolationGammaCands(); Tracks_=thePFTau.pfTauTagInfoRef()->Tracks(); } void PFTauElementsOperators::setAreaMetricrecoElementsmaxabsEta( double x) {AreaMetric_recoElements_maxabsEta_=x;} @@ -165,7 +165,7 @@ std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnu std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; } -CandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); @@ -181,7 +181,7 @@ CandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metric } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; const std::vector theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; @@ -195,7 +195,7 @@ CandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVector, } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); @@ -211,7 +211,7 @@ CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matching } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadChargedHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; const std::vector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; @@ -225,7 +225,7 @@ CandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); @@ -241,7 +241,7 @@ CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingco } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadNeutrHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; const std::vector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; @@ -255,7 +255,7 @@ CandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector& } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; if (!PFJetRef_) return myleadPFCand; math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum(); @@ -271,7 +271,7 @@ CandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone_m } return myleadPFCand; } -CandidatePtr PFTauElementsOperators::leadPFGammaCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ +CandidatePtr PFTauElementsOperators::leadGammaCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{ CandidatePtr myleadPFCand; const std::vector theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt); double pt_cut=minPt; @@ -466,8 +466,8 @@ double PFTauElementsOperators::discriminatorByIsolPFCandsN(int IsolPFCands_maxN) double PFTauElementsOperators::discriminatorByIsolPFCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){ double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -478,8 +478,8 @@ double PFTauElementsOperators::discriminatorByIsolPFCandsN(string matchingcone_m double PFTauElementsOperators::discriminatorByIsolPFCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){ double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -495,8 +495,8 @@ double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(int IsolPF double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){ double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -507,8 +507,8 @@ double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(string mat double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){ double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -524,8 +524,8 @@ double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(int IsolPFNe double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){ double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -536,8 +536,8 @@ double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(string match double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){ double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -553,8 +553,8 @@ double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(int IsolPFGammaC double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){ double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -565,8 +565,8 @@ double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(string matchingc double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(const math::XYZVector& myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){ double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -585,8 +585,8 @@ double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(string matchingco double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -599,8 +599,8 @@ double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(const math::XYZVe double myIsolPFCandsEtSum=0.; double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -620,8 +620,8 @@ double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(string double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -634,8 +634,8 @@ double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(const double myIsolPFCandsEtSum=0.; double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -655,8 +655,8 @@ double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(string m double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -669,8 +669,8 @@ double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(const ma double myIsolPFCandsEtSum=0.; double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -690,8 +690,8 @@ double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(string match double myIsolPFCandsEtSum=0.; double myDiscriminator=0.; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; @@ -704,8 +704,8 @@ double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(const math:: double myIsolPFCandsEtSum=0.; double myDiscriminator=0; CandidatePtr myleadPFCand; - if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); - else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); + else myleadPFCand=leadCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); if(!myleadPFCand)return myDiscriminator; //if(signalcone_size>=isolcone_size) return 1.; math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ; diff --git a/RecoTauTag/TauTagTools/test/training/trainMVA_cfg.py b/RecoTauTag/TauTagTools/test/training/trainMVA_cfg.py index 4f7753e844a07..e8ca8e6e41aad 100644 --- a/RecoTauTag/TauTagTools/test/training/trainMVA_cfg.py +++ b/RecoTauTag/TauTagTools/test/training/trainMVA_cfg.py @@ -226,7 +226,7 @@ "PFTauViewRefSelector", src = cms.InputTag("signalRawTaus"), cut = cms.string( - 'leadPFChargedHadrCand().muonRef().isNull() &leadPFCand().pt() > 5.0'), + 'leadPFChargedHadrCand().muonRef().isNull() &leadCand().pt() > 5.0'), # We can skip events where no taus pass this requirement filter = cms.bool(True), ) diff --git a/Validation/RecoTau/Tools/makeLayoutFileForGui.py b/Validation/RecoTau/Tools/makeLayoutFileForGui.py index 5b1c719609c4c..bcf03b875526c 100644 --- a/Validation/RecoTau/Tools/makeLayoutFileForGui.py +++ b/Validation/RecoTau/Tools/makeLayoutFileForGui.py @@ -127,7 +127,7 @@ def sizeSumpt(locpath,dataType,var): return stdFill.substitute(locpath=locpath,rows=strow) variables = {'a%s':'pt','b%s':'pileup','c%s':'eta','d%s':'phi'} -sumVar = dict( list(zip(string.letters,[elem for elem in ['signalPFCands','isolationPFChargedHadrCands','isolationPFGammaCands','isolationPFNeutrHadrCands'] ])) ) +sumVar = dict( list(zip(string.letters,[elem for elem in ['signalCands','isolationChargedHadrCands','isolationGammaCands','isolationNeutrHadrCands'] ])) ) # diff --git a/Validation/RecoTau/src/TauTagValidation.cc b/Validation/RecoTau/src/TauTagValidation.cc index fb51eef095ac8..c2087d4553acd 100644 --- a/Validation/RecoTau/src/TauTagValidation.cc +++ b/Validation/RecoTau/src/TauTagValidation.cc @@ -251,27 +251,27 @@ void TauTagValidation::bookHistograms(DQMStore::IBooker & ibooker, edm::Run cons xaxisLabel = ";size"; yaxislabel = ";Frequency"; bins = 20; - plotName = plotType + "signalPFCands"; + plotName = plotType + "signalCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "signalPFChargedHadrCands"; + plotName = plotType + "signalChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "signalPFNeutrHadrCands"; + plotName = plotType + "signalNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFCands"; + plotName = plotType + "isolationCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFChargedHadrCands"; + plotName = plotType + "isolationChargedHadrCands"; bins = 10; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFNeutrHadrCands"; + plotName = plotType + "isolationNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFGammaCands"; + plotName = plotType + "isolationGammaCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); @@ -279,25 +279,25 @@ void TauTagValidation::bookHistograms(DQMStore::IBooker & ibooker, edm::Run cons xaxisLabel = ";p_{T}^{sum}/ GeV"; yaxislabel = ";Frequency"; bins = 20; - plotName = plotType + "signalPFCands"; + plotName = plotType + "signalCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "signalPFChargedHadrCands"; + plotName = plotType + "signalChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "signalPFNeutrHadrCands"; + plotName = plotType + "signalNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFCands"; + plotName = plotType + "isolationCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFChargedHadrCands"; + plotName = plotType + "isolationChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 10.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFNeutrHadrCands"; + plotName = plotType + "isolationNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 30.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); - plotName = plotType + "isolationPFGammaCands"; + plotName = plotType + "isolationGammaCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 20.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); @@ -526,53 +526,53 @@ void TauTagValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& } //fill: size and sumPt within tau isolation std::string plotType = "_Size_"; - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFChargedHadrCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFNeutrHadrCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFChargedHadrCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFNeutrHadrCands().size() ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" ); - if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFGammaCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalChargedHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalChargedHadrCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalNeutrHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalNeutrHadrCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationChargedHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationChargedHadrCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationNeutrHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationNeutrHadrCands().size() ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationGammaCands" ); + if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationGammaCands().size() ); plotType = "_SumPt_"; - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFChargedHadrCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFNeutrHadrCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFChargedHadrCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFNeutrHadrCands() ) ); - element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" ); - if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFGammaCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalChargedHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalChargedHadrCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalNeutrHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalNeutrHadrCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationChargedHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationChargedHadrCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationNeutrHadrCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationNeutrHadrCands() ) ); + element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationGammaCands" ); + if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationGammaCands() ) ); //deprecated if( TauProducer_.find("PFTau") != string::npos ){ if ( currentDiscriminatorLabel.find("LeadingTrackPtCut") != string::npos){ - nPFJet_LeadingChargedHadron_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size()); - nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFChargedHadrCands().size()); - nPFJet_LeadingChargedHadron_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size()); - nPFJet_LeadingChargedHadron_GammasIsolAnnulus_->Fill((*thePFTau).isolationPFGammaCands().size()); - nPFJet_LeadingChargedHadron_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size()); - nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size()); + nPFJet_LeadingChargedHadron_ChargedHadronsSignal_->Fill((*thePFTau).signalChargedHadrCands().size()); + nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_->Fill((*thePFTau).isolationChargedHadrCands().size()); + nPFJet_LeadingChargedHadron_GammasSignal_->Fill((*thePFTau).signalGammaCands().size()); + nPFJet_LeadingChargedHadron_GammasIsolAnnulus_->Fill((*thePFTau).isolationGammaCands().size()); + nPFJet_LeadingChargedHadron_NeutralHadronsSignal_->Fill((*thePFTau).signalNeutrHadrCands().size()); + nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationNeutrHadrCands().size()); } else if ( currentDiscriminatorLabel.find("ByIsolation") != string::npos ){ - nIsolated_NoChargedNoGammas_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size()); - nIsolated_NoChargedNoGammas_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size()); - nIsolated_NoChargedNoGammas_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size()); - nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size()); + nIsolated_NoChargedNoGammas_ChargedHadronsSignal_->Fill((*thePFTau).signalChargedHadrCands().size()); + nIsolated_NoChargedNoGammas_GammasSignal_->Fill((*thePFTau).signalGammaCands().size()); + nIsolated_NoChargedNoGammas_NeutralHadronsSignal_->Fill((*thePFTau).signalNeutrHadrCands().size()); + nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationNeutrHadrCands().size()); } } } From 51bdf5100027a0d1e1b88843e509d83159c1305a Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 6 Apr 2018 14:38:41 +0200 Subject: [PATCH 040/686] Address various code review comments --- DataFormats/PatCandidates/interface/Tau.h | 16 ++--- DataFormats/PatCandidates/src/Tau.cc | 64 ++++++++++++------- .../PatCandidates/src/classes_def_objects.xml | 10 +++ .../PatCandidates/src/classes_objects.h | 8 +++ DataFormats/TauReco/src/classes_3.h | 8 --- DataFormats/TauReco/src/classes_def_1.xml | 16 +++-- DataFormats/TauReco/src/classes_def_2.xml | 29 +++++---- DataFormats/TauReco/src/classes_def_3.xml | 8 --- .../PatAlgos/plugins/PATTauProducer.cc | 53 ++++++++------- .../interface/SignAlgoResolutions.h | 2 +- .../METAlgorithms/src/SignAlgoResolutions.cc | 2 +- .../interface/PFMEtSignInterfaceBase.h | 22 +------ .../plugins/PFTau3ProngReco.cc | 4 +- .../interface/PFRecoTauClusterVariables.h | 2 +- 14 files changed, 125 insertions(+), 119 deletions(-) diff --git a/DataFormats/PatCandidates/interface/Tau.h b/DataFormats/PatCandidates/interface/Tau.h index d242e1a562058..4bf85d03ebde2 100644 --- a/DataFormats/PatCandidates/interface/Tau.h +++ b/DataFormats/PatCandidates/interface/Tau.h @@ -179,16 +179,16 @@ namespace pat { const reco::PFCandidatePtr leadPFCand() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector signalPFCands() const; + const std::vector& signalPFCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector signalPFChargedHadrCands() const; + const std::vector& signalPFChargedHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector signalPFNeutrHadrCands() const; + const std::vector& signalPFNeutrHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector signalPFGammaCands() const; + const std::vector& signalPFGammaCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau const std::vector & signalTauChargedHadronCandidates() const; @@ -197,16 +197,16 @@ namespace pat { const std::vector & signalPiZeroCandidates() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector isolationPFCands() const; + const std::vector& isolationPFCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector isolationPFChargedHadrCands() const; + const std::vector& isolationPFChargedHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector isolationPFNeutrHadrCands() const; + const std::vector& isolationPFNeutrHadrCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau - const std::vector isolationPFGammaCands() const; + const std::vector& isolationPFGammaCands() const; /// Method copied from reco::PFTau. /// Throws an exception if this pat::Tau was not made from a reco::PFTau const std::vector & isolationTauChargedHadronCandidates() const; diff --git a/DataFormats/PatCandidates/src/Tau.cc b/DataFormats/PatCandidates/src/Tau.cc index 430612d9dae1e..f0fc3896bfa4b 100644 --- a/DataFormats/PatCandidates/src/Tau.cc +++ b/DataFormats/PatCandidates/src/Tau.cc @@ -493,7 +493,7 @@ const reco::PFCandidatePtr Tau::leadPFCand() const { return reco::PFCandidatePtr(&leadPFCand_,0); } -const std::vector Tau::signalPFCands() const { +const std::vector& Tau::signalPFCands() const { if (embeddedSignalPFCands_) { if (!signalPFCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -508,14 +508,16 @@ const std::vector Tau::signalPFCands() const { if(pfSpecific_.empty() || pfSpecific().selectedSignalPFCands_.empty() || !pfSpecific().selectedSignalPFCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - signalPFCandsTransientPtrs_.set(std::move(aPtrs)); + if (!signalPFCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + signalPFCandsTransientPtrs_.set(std::move(aPtrs)); + } return *signalPFCandsTransientPtrs_; } else return pfSpecific().selectedSignalPFCands_; } } -const std::vector Tau::signalPFChargedHadrCands() const { +const std::vector& Tau::signalPFChargedHadrCands() const { if (embeddedSignalPFChargedHadrCands_) { if (!signalPFChargedHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -530,14 +532,16 @@ const std::vector Tau::signalPFChargedHadrCands() const { if(pfSpecific_.empty() || pfSpecific().selectedSignalPFChargedHadrCands_.empty() || !pfSpecific().selectedSignalPFChargedHadrCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); + if (!signalPFChargedHadrCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + signalPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); + } return *signalPFChargedHadrCandsTransientPtrs_; } else return pfSpecific().selectedSignalPFChargedHadrCands_; } } -const std::vector Tau::signalPFNeutrHadrCands() const { +const std::vector& Tau::signalPFNeutrHadrCands() const { if (embeddedSignalPFNeutralHadrCands_) { if (!signalPFNeutralHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -552,14 +556,16 @@ const std::vector Tau::signalPFNeutrHadrCands() const { if(pfSpecific_.empty() || pfSpecific().selectedSignalPFNeutrHadrCands_.empty() || !pfSpecific().selectedSignalPFNeutrHadrCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); + if (!signalPFNeutralHadrCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + signalPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); + } return *signalPFNeutralHadrCandsTransientPtrs_; } else return pfSpecific().selectedSignalPFNeutrHadrCands_; } } -const std::vector Tau::signalPFGammaCands() const { +const std::vector& Tau::signalPFGammaCands() const { if (embeddedSignalPFGammaCands_) { if (!signalPFGammaCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -574,8 +580,10 @@ const std::vector Tau::signalPFGammaCands() const { if(pfSpecific_.empty() || pfSpecific().selectedSignalPFGammaCands_.empty() || !pfSpecific().selectedSignalPFGammaCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); + if (!signalPFGammaCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + signalPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); + } return *signalPFGammaCandsTransientPtrs_; } else return pfSpecific().selectedSignalPFGammaCands_; } @@ -591,7 +599,7 @@ const std::vector & Tau::signalPiZeroCandidates() const { return pfSpecific().signalPiZeroCandidates_; } -const std::vector Tau::isolationPFCands() const { +const std::vector& Tau::isolationPFCands() const { if (embeddedIsolationPFCands_) { if (!isolationPFCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -606,14 +614,16 @@ const std::vector Tau::isolationPFCands() const { if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFCands_.empty() || !pfSpecific().selectedIsolationPFCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - isolationPFCandsTransientPtrs_.set(std::move(aPtrs)); + if (!isolationPFCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + isolationPFCandsTransientPtrs_.set(std::move(aPtrs)); + } return *isolationPFCandsTransientPtrs_; } else return pfSpecific().selectedIsolationPFCands_; } } -const std::vector Tau::isolationPFChargedHadrCands() const { +const std::vector& Tau::isolationPFChargedHadrCands() const { if (embeddedIsolationPFChargedHadrCands_) { if (!isolationPFChargedHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -628,14 +638,16 @@ const std::vector Tau::isolationPFChargedHadrCands() const if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFChargedHadrCands_.empty() || !pfSpecific().selectedIsolationPFChargedHadrCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); + if (!isolationPFChargedHadrCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + isolationPFChargedHadrCandsTransientPtrs_.set(std::move(aPtrs)); + } return *isolationPFChargedHadrCandsTransientPtrs_; } else return pfSpecific().selectedIsolationPFChargedHadrCands_; } } -const std::vector Tau::isolationPFNeutrHadrCands() const { +const std::vector& Tau::isolationPFNeutrHadrCands() const { if (embeddedIsolationPFNeutralHadrCands_) { if (!isolationPFNeutralHadrCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{ new std::vector{}}; @@ -650,14 +662,16 @@ const std::vector Tau::isolationPFNeutrHadrCands() const { if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFNeutrHadrCands_.empty() || !pfSpecific().selectedIsolationPFNeutrHadrCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); + if (!isolationPFNeutralHadrCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + isolationPFNeutralHadrCandsTransientPtrs_.set(std::move(aPtrs)); + } return *isolationPFNeutralHadrCandsTransientPtrs_; } else return pfSpecific().selectedIsolationPFNeutrHadrCands_; } } -const std::vector Tau::isolationPFGammaCands() const { +const std::vector& Tau::isolationPFGammaCands() const { if (embeddedIsolationPFGammaCands_) { if (!isolationPFGammaCandsTransientPtrs_.isSet()) { std::unique_ptr > aPtrs{new std::vector{}}; @@ -672,8 +686,10 @@ const std::vector Tau::isolationPFGammaCands() const { if(pfSpecific_.empty() || pfSpecific().selectedIsolationPFGammaCands_.empty() || !pfSpecific().selectedIsolationPFGammaCands_.front().isAvailable()){ // this part of code is called when reading from patTuple or miniAOD // it returns empty collection in correct format so it can be substituted by reco::Candidates if available - std::unique_ptr > aPtrs{new std::vector{}}; - isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); + if (!isolationPFGammaCandsTransientPtrs_.isSet()) { + std::unique_ptr > aPtrs{new std::vector{}}; + isolationPFGammaCandsTransientPtrs_.set(std::move(aPtrs)); + } return *isolationPFGammaCandsTransientPtrs_; } else return pfSpecific().selectedIsolationPFGammaCands_; } diff --git a/DataFormats/PatCandidates/src/classes_def_objects.xml b/DataFormats/PatCandidates/src/classes_def_objects.xml index d6345f59b53bd..94ffbc435aff7 100644 --- a/DataFormats/PatCandidates/src/classes_def_objects.xml +++ b/DataFormats/PatCandidates/src/classes_def_objects.xml @@ -585,6 +585,16 @@ + + + + + + + + + + diff --git a/DataFormats/PatCandidates/src/classes_objects.h b/DataFormats/PatCandidates/src/classes_objects.h index 9eb0c512183a2..b81d329f6cd54 100644 --- a/DataFormats/PatCandidates/src/classes_objects.h +++ b/DataFormats/PatCandidates/src/classes_objects.h @@ -1,5 +1,6 @@ #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Common/interface/AssociationMap.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/PtrVector.h" #include "DataFormats/Common/interface/FwdPtr.h" @@ -200,6 +201,13 @@ namespace DataFormats_PatCandidates { edm::Wrapper< std::vector< edm::Ptr > > wvptr_jet; edm::Wrapper< std::vector< std::vector< edm::Ptr > > > wvvptr_jet; + edm::Association > patjet_assoc_vr; + edm::Wrapper > > patjet_assoc_vr_wrapper; + edm::RefProd > patjet_rp; + edm::AssociationMap,std::vector,unsigned int> > patjet_v_patpc_v_otm_am; + edm::Wrapper,std::vector,unsigned int> > > patjet_v_patpc_v_otm_am_w; + edm::helpers::KeyVal >,edm::RefProd > > patjet_v_patpc_v_kv; + pat::PATTauDiscriminatorBase pattdiscr_b; pat::PATTauDiscriminator pattdiscr_o; pat::PATTauDiscriminatorRef pattdiscr_r; diff --git a/DataFormats/TauReco/src/classes_3.h b/DataFormats/TauReco/src/classes_3.h index d7b0171fa0e09..91eadceeddd31 100644 --- a/DataFormats/TauReco/src/classes_3.h +++ b/DataFormats/TauReco/src/classes_3.h @@ -244,13 +244,5 @@ namespace DataFormats_TauReco { /* edm::helpers::KeyVal >,edm::RefProd > > jetPFCandidateAssociation_kv; */ /* edm::helpers::KeyVal,reco::PFJet,edm::refhelper::FindUsingAdvance,reco::PFJet> >,edm::RefVector,reco::PFCandidate,edm::refhelper::FindUsingAdvance,reco::PFCandidate> > > jetPFCandidateAssociation_kv2; */ /* std::map,reco::PFJet,edm::refhelper::FindUsingAdvance,reco::PFJet> >,edm::RefVector,reco::PFCandidate,edm::refhelper::FindUsingAdvance,reco::PFCandidate> > > > jetPFCandidateAssociation_mkv; */ - - // PAT Jet associations, needed for miniAOD-based reconstruction - edm::Association > patjet_assoc_vr; - edm::Wrapper > > patjet_assoc_vr_wrapper; - edm::RefProd > patjet_rp; - edm::AssociationMap,std::vector,unsigned int> >patjet_v_patpc_v_otm_am; - edm::Wrapper,std::vector,unsigned int> > > patjet_v_patpc_v_otm_am_w; - edm::helpers::KeyVal >,edm::RefProd > > patjet_v_patpc_v_kv; }; } diff --git a/DataFormats/TauReco/src/classes_def_1.xml b/DataFormats/TauReco/src/classes_def_1.xml index c083708d42a9b..809ca1e05c138 100644 --- a/DataFormats/TauReco/src/classes_def_1.xml +++ b/DataFormats/TauReco/src/classes_def_1.xml @@ -43,25 +43,33 @@ - + - + (cand));]]> - + (cand));]]> - + - - + + @@ -10,6 +10,7 @@ + @@ -47,19 +48,19 @@ - + (onfile.leadPFChargedHadrCand_);]]> - + (onfile.leadPFNeutralCand_);]]> - + (onfile.leadPFCand_);]]> - + & cand : onfile.selectedSignalPFCands_) { @@ -67,56 +68,56 @@ ]]> - + (cand));]]> - + (cand));;]]> - + (cand));]]> - + (cand));]]> - + (cand));]]> - + (cand));]]> - + (cand));]]> - + diff --git a/DataFormats/TauReco/src/classes_def_3.xml b/DataFormats/TauReco/src/classes_def_3.xml index 265458a0d468c..c6ba555d75946 100644 --- a/DataFormats/TauReco/src/classes_def_3.xml +++ b/DataFormats/TauReco/src/classes_def_3.xml @@ -237,12 +237,4 @@ - - - - - - - - diff --git a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc index a87d2e73cd003..f8bf1d9944969 100755 --- a/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTauProducer.cc @@ -387,39 +387,36 @@ void PATTauProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup for(const auto& it : signalCands) { const reco::PFCandidate* icand = dynamic_cast(it.get()); if (icand != nullptr) { - ecalEnergy += icand->ecalEnergy(); - hcalEnergy += icand->hcalEnergy(); + ecalEnergy += icand->ecalEnergy(); + hcalEnergy += icand->hcalEnergy(); sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy(); sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy(); - sumEnergy += icand->energy(); + sumEnergy += icand->energy(); const reco::Track* track = nullptr; - if ( icand->trackRef().isNonnull() ) track = icand->trackRef().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->innerTrack().isNonnull() ) track = icand->muonRef ()->innerTrack().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->globalTrack().isNonnull() ) track = icand->muonRef ()->globalTrack().get(); - else if ( icand->muonRef().isNonnull() && icand->muonRef()->outerTrack().isNonnull() ) track = icand->muonRef ()->outerTrack().get(); - else if ( icand->gsfTrackRef().isNonnull() ) track = icand->gsfTrackRef().get(); - if( track ) { - if( track->pt() > leadChargedCandPt ) { - leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta(); - leadChargedCandPt = track->pt(); - } - } - } - else{ - const pat::PackedCandidate* packedCandPtr = dynamic_cast(it.get()); - if(packedCandPtr != nullptr) { - // TauReco@MiniAOD: individual ECAL and HCAL energies currently not available for PackedCandidates - // (see above implementation for PFCandidates). - // Should be added if available, as well as on-the-fly computation of position at ECAL entrance - sumEnergy += packedCandPtr->energy(); - const reco::Track* track = packedCandPtr->hasTrackDetails() ? &packedCandPtr->pseudoTrack() : nullptr; - if( track != nullptr ) { - if( track->pt() > leadChargedCandPt ) { - leadChargedCandPt = track->pt(); - } + if ( icand->trackRef().isNonnull() ) track = icand->trackRef().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->innerTrack().isNonnull() ) track = icand->muonRef ()->innerTrack().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->globalTrack().isNonnull() ) track = icand->muonRef ()->globalTrack().get(); + else if ( icand->muonRef().isNonnull() && icand->muonRef()->outerTrack().isNonnull() ) track = icand->muonRef ()->outerTrack().get(); + else if ( icand->gsfTrackRef().isNonnull() ) track = icand->gsfTrackRef().get(); + if( track ) { + if( track->pt() > leadChargedCandPt ) { + leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta(); + leadChargedCandPt = track->pt(); } } - } + } + else { + // TauReco@MiniAOD: individual ECAL and HCAL energies currently not available for PackedCandidates + // (see above implementation for PFCandidates). + // Should be added if available, as well as on-the-fly computation of position at ECAL entrance + sumEnergy += it->energy(); + const reco::Track* track = it->bestTrack(); + if( track != nullptr ) { + if( track->pt() > leadChargedCandPt ) { + leadChargedCandPt = track->pt(); + } + } + } } aTauPFEssential.ecalEnergy_ = ecalEnergy; aTauPFEssential.hcalEnergy_ = hcalEnergy; diff --git a/RecoMET/METAlgorithms/interface/SignAlgoResolutions.h b/RecoMET/METAlgorithms/interface/SignAlgoResolutions.h index 037c51610c69b..9b3853253822f 100644 --- a/RecoMET/METAlgorithms/interface/SignAlgoResolutions.h +++ b/RecoMET/METAlgorithms/interface/SignAlgoResolutions.h @@ -50,7 +50,7 @@ namespace metsig { double eval(const resolutionType & type, const resolutionFunc & func, const double & et, const double & phi, const double & eta, const double &p) const; // for example getvalue(caloHF,ET,et,phi,eta,p); double eval(const resolutionType & type, const resolutionFunc & func, const double & et, const double & phi, const double & eta) const; // for example getvalue(caloHF,ET,et,phi,eta,p); metsig::SigInputObj evalPF(const reco::PFCandidate* candidate) const; - metsig::SigInputObj evalPFJet(const reco::PFJet *jet) const; + metsig::SigInputObj evalPFJet(const reco::Jet *jet) const; bool isFilled() const {return !functionmap_.empty();} private: diff --git a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc index 1778196a41c46..3cdf7c3240adb 100644 --- a/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc +++ b/RecoMET/METAlgorithms/src/SignAlgoResolutions.cc @@ -106,7 +106,7 @@ metsig::SigInputObj metsig::SignAlgoResolutions::evalPF(const reco::PFCandidate metsig::SigInputObj -metsig::SignAlgoResolutions::evalPFJet(const reco::PFJet *jet) const{ +metsig::SignAlgoResolutions::evalPFJet(const reco::Jet *jet) const{ double jpt = jet->pt(); double jphi = jet->phi(); diff --git a/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h b/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h index 366848b7c8ce3..39249d63155cd 100755 --- a/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h +++ b/RecoMET/METPUSubtraction/interface/PFMEtSignInterfaceBase.h @@ -100,28 +100,10 @@ class PFMEtSignInterfaceBase // (until PFTau specific resolutions are available) if ( dynamic_cast(particle) != nullptr ) { const pat::Tau* pfTau = dynamic_cast(particle); - //std::cout << "tau: pt = " << pt << ", eta = " << eta << ", phi = " << phi << std::endl; - const reco::PFJet* pfJet = dynamic_cast(pfTau->pfJetRef().get()); - if (pfJet != nullptr) - return pfMEtResolution_->evalPFJet(pfJet); - - const pat::Jet* patJet = dynamic_cast(pfTau->pfJetRef().get()); - if (patJet != nullptr) { - reco::PFJet pfJet(patJet->p4(), patJet->vertex(), patJet->pfSpecific(), patJet->getJetConstituents()); - return pfMEtResolution_->evalPFJet(&pfJet); - } - else throw cms::Exception("addPFMEtSignObjects") - << "Neither PAT jet nor PF Jet in tau object !!\n"; + return pfMEtResolution_->evalPFJet(pfTau->pfJetRef().get()); } else if ( dynamic_cast(particle) != nullptr ) { const reco::PFTau* pfTau = dynamic_cast(particle); - //std::cout << "tau: pt = " << pt << ", eta = " << eta << ", phi = " << phi << std::endl; - const pat::Jet* patJet = dynamic_cast(pfTau->jetRef().get()); - if (patJet != nullptr) { - reco::PFJet pfJet(patJet->p4(), patJet->vertex(), patJet->pfSpecific(), patJet->getJetConstituents()); - return pfMEtResolution_->evalPFJet(&pfJet); - } - else throw cms::Exception("addPFMEtSignObjects") - << "Neither PAT jet nor PF Jet in tau object !!\n"; + return pfMEtResolution_->evalPFJet(pfTau->jetRef().get()); } else assert(0); } else if ( dynamic_cast(particle) != nullptr || dynamic_cast(particle) != nullptr ) { diff --git a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc index f8e701bd5b319..cef37d4b8ab68 100644 --- a/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc +++ b/RecoTauTag/ImpactParameter/plugins/PFTau3ProngReco.cc @@ -135,8 +135,8 @@ namespace { else return nullptr; } const pat::PackedCandidate* packedCand = dynamic_cast(&cand); - if (packedCand && packedCand->hasTrackDetails()) - return &packedCand->pseudoTrack(); + if (packedCand != nullptr) + return packedCand->bestTrack(); return nullptr; } diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index 5d5903439e8f2..916189002f909 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -29,7 +29,7 @@ class TauIdMVAAuxiliaries { if (pfcand != nullptr) { reco::TrackRef tref = pfcand->trackRef(); if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2()); + LeadingTracknormalizedChi2 = tref->normalizedChi2(); } } else { From 5a25a5bc3d41cbad90780562bd7431267a86155b Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 10 Apr 2018 10:50:13 +0200 Subject: [PATCH 041/686] Address various code review comments --- .../Configuration/test/tauFromMiniAOD.py | 117 ---------- .../RecoTau/interface/RecoTauMuonTools.h | 19 ++ ...coTauChargedHadronFromPFCandidatePlugin.cc | 28 ++- .../plugins/PFRecoTauChargedHadronProducer.cc | 3 - ...ecoTauDiscriminationAgainstElectronMVA6.cc | 6 +- .../PFRecoTauDiscriminationAgainstMuon2.cc | 75 ++----- ...FRecoTauDiscriminationAgainstMuonSimple.cc | 67 +----- .../plugins/PFRecoTauTagInfoProducer.cc | 3 +- .../plugins/RecoPatTauJetRegionProducer.cc | 210 ------------------ .../plugins/RecoTauJetRegionProducer.cc | 81 ++++--- .../plugins/RecoTauPiZeroStripPlugin2.cc | 4 - .../plugins/RecoTauPiZeroStripPlugin3.cc | 4 - RecoTauTag/RecoTau/src/RecoTauConstructor.cc | 23 -- RecoTauTag/RecoTau/src/RecoTauMuonTools.cc | 53 +++++ RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 46 +++- .../src/pfRecoTauChargedHadronAuxFunctions.cc | 6 +- .../RecoTau/test/rerunTauRecoOnMiniAOD.py | 4 +- 17 files changed, 206 insertions(+), 543 deletions(-) delete mode 100644 RecoTauTag/Configuration/test/tauFromMiniAOD.py create mode 100644 RecoTauTag/RecoTau/interface/RecoTauMuonTools.h delete mode 100644 RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc create mode 100644 RecoTauTag/RecoTau/src/RecoTauMuonTools.cc diff --git a/RecoTauTag/Configuration/test/tauFromMiniAOD.py b/RecoTauTag/Configuration/test/tauFromMiniAOD.py deleted file mode 100644 index a4c478e116b2b..0000000000000 --- a/RecoTauTag/Configuration/test/tauFromMiniAOD.py +++ /dev/null @@ -1,117 +0,0 @@ -import FWCore.ParameterSet.Config as cms -###### -# Configuration to run tau ReReco+PAT at MiniAOD samples -# M. Bluj, NCBJ Warsaw -# based on work of J. Steggemann, CERN -# Created: 9 Nov. 2017 -###### - -###### -runSignal=True -#runSignal=False -maxEvents=1000 -#maxEvents=-1 - -# If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is -# built to seed taus (as at RECO), otherwise standard slimmedJets are used -reclusterJets=True -#reclusterJets=False - -#set true for upgrade studies -phase2=False -#phase2=True - -#Output mode -outMode = 0 #store original MiniAOD and new selectedPatTaus -#outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) - -print 'Running Tau reco&id with MiniAOD inputs:' -print '\t Run on signal:', runSignal -print '\t Recluster jets:', reclusterJets -print '\t Use Phase2 settings:', phase2 -print '\t Output mode:', outMode - -##### -from Configuration.StandardSequences.Eras import eras -era = eras.Run2_2017 -if phase2: - era = eras.Phase2_timing -process = cms.Process("TAURECO",era) -process.load("Configuration.StandardSequences.MagneticField_cff") # for CH reco -if not phase2: - process.load("Configuration.Geometry.GeometryRecoDB_cff") -else: - process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') - -##### -readFiles = cms.untracked.vstring() -secFiles = cms.untracked.vstring() -process.source = cms.Source ("PoolSource",fileNames = readFiles, secondaryFileNames = secFiles) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(maxEvents) -) -print '\t Max events:', process.maxEvents.input.value() - -if runSignal: - readFiles.extend( [ - 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/94FC956F-17E1-E711-B672-0025905A60A6.root', - 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', - ] ) -else: - readFiles.extend( [ - 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', - 'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', - ] ) - -##### -import RecoTauTag.Configuration.tools.adaptToRunAtMiniAOD as tauAtMiniTools - -##### -tauAtMiniTools.addTauReReco(process) - -##### -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -from Configuration.AlCa.GlobalTag import GlobalTag -if not phase2: - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' -else: - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -##### -#mode = 0: store original MiniAOD and new selectedPatTaus -#mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) -process.output = tauAtMiniTools.setOutputModule(mode=outMode) -if runSignal: - process.output.fileName='miniAOD_TauReco_ggH.root' - if reclusterJets: - process.output.fileName='miniAOD_TauReco_ak4PFJets_ggH.root' -else: - process.output.fileName='miniAOD_TauReco_QCD.root' - if reclusterJets: - process.output.fileName='miniAOD_TauReco_ak4PFJets_QCD.root' -process.out = cms.EndPath(process.output) - -##### -tauAtMiniTools.adaptTauToMiniAODReReco(process, reclusterJets) - -##### -process.load('FWCore.MessageService.MessageLogger_cfi') -if process.maxEvents.input.value()>10: - process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10 -if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0: - process.MessageLogger.cerr.FwkReport.reportEvery = 1000 - -##### -process.options = cms.untracked.PSet( -) -process.options.numberOfThreads=cms.untracked.uint32(4) -#process.options.numberOfThreads=cms.untracked.uint32(1) -process.options.numberOfStreams=cms.untracked.uint32(0) -print '\t No. of threads:', process.options.numberOfThreads.value(),', no. of streams:',process.options.numberOfStreams.value() - -process.options = cms.untracked.PSet( - process.options, - wantSummary = cms.untracked.bool(True) -) diff --git a/RecoTauTag/RecoTau/interface/RecoTauMuonTools.h b/RecoTauTag/RecoTau/interface/RecoTauMuonTools.h new file mode 100644 index 0000000000000..1c4d6246f5c18 --- /dev/null +++ b/RecoTauTag/RecoTau/interface/RecoTauMuonTools.h @@ -0,0 +1,19 @@ +#ifndef RecoTauTag_RecoTau_RecoTauMuonTools_h +#define RecoTauTag_RecoTau_RecoTauMuonTools_h + +/* + * RecoTauMuonTools - utilities for muon->tau discrimination. + + */ + +#include + +#include "DataFormats/PatCandidates/interface/Muon.h" + +namespace reco { namespace tau { + void countHits(const reco::Muon& muon, std::vector& numHitsDT, std::vector& numHitsCSC, std::vector& numHitsRPC); + void countMatches(const reco::Muon& muon, std::vector& numMatchesDT, std::vector& numMatchesCSC, std::vector& numMatchesRPC); + std::string format_vint(const std::vector& vi); +}} // end namespace reco::tau + +#endif diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index cf71e592938b0..5fe4b667b680d 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -236,16 +236,24 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_; minMergeEt = minMergeGammaEt_; } - // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact - const reco::PFCandidate* pfCHCand = dynamic_cast(&*chargedHadron->chargedPFCandidate_); - const reco::PFCandidate* pfJetConstituent = dynamic_cast(&**jetConstituent); - if (pfCHCand && pfJetConstituent) { - if ( (*jetConstituent)->et() > minMergeEt && - (dR < dRmerge || isMatchedByBlockElement(*pfJetConstituent, *pfCHCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) ) { - chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); - chargedHadron->addDaughter(*jetConstituent); - } - } + + if ((*jetConstituent)->et() > minMergeEt) { + if (dR < dRmerge) { + chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); + chargedHadron->addDaughter(*jetConstituent); + } + else { + // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact + const reco::PFCandidate* pfCHCand = dynamic_cast(&*chargedHadron->chargedPFCandidate_); + const reco::PFCandidate* pfJetConstituent = dynamic_cast(&**jetConstituent); + if (pfCHCand != nullptr && pfJetConstituent != nullptr) { + if (isMatchedByBlockElement(*pfJetConstituent, *pfCHCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) { + chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); + chargedHadron->addDaughter(*jetConstituent); + } + } + } + } } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 826376ad1c67e..40745a89e134e 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -151,9 +151,7 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe evt.getByToken(Jets_token, jets); // convert the view to a RefVector of actual PFJets - // reco::PFJetRefVector pfJets = reco::tau::castView(jets); edm::RefToBaseVector pfJets; - // = reco::tau::castView>(jets); size_t nElements = jets->size(); for (size_t i = 0; i < nElements; ++i) { pfJets.push_back(jets->refAt(i)); @@ -170,7 +168,6 @@ void PFRecoTauChargedHadronProducer::produce(edm::Event& evt, const edm::EventSe } // loop over our jets - // BOOST_FOREACH( const reco::JetBaseRef& pfJet, pfJets ) { for (size_t i_j = 0; i_j < pfJets.size(); ++i_j) { const auto& pfJet = pfJets.at(i_j); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 98cb6cebdccf8..9059ff9da67ac 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -119,7 +119,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); leadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; } if( (*thePFTauRef).leadChargedHadrCand().isNonnull()) { @@ -151,7 +151,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& bool hasGsfTrack = false; if (lpfch) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; if ( !hasGsfTrack ) hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); @@ -193,7 +193,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& bool hasGsfTrack = false; if (lpfch) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "FIXME.\n"; + } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index 5c0ca08d7afca..55fa3e0248961 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -21,10 +21,14 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/Math/interface/deltaR.h" +#include "RecoTauTag/RecoTau/interface/RecoTauMuonTools.h" + #include #include #include +using reco::tau::format_vint; + namespace { class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProducerBase @@ -101,56 +105,6 @@ void PFRecoTauDiscriminationAgainstMuon2::beginEvent(const edm::Event& evt, cons } } -namespace -{ - void countHits(const reco::Muon& muon, std::vector& numHitsDT, std::vector& numHitsCSC, std::vector& numHitsRPC) - { - if ( muon.outerTrack().isNonnull() ) { - const reco::HitPattern &muonHitPattern = muon.outerTrack()->hitPattern(); - for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) { - uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit); - if ( hit == 0 ) break; - if ( muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid || muonHitPattern.getHitType(hit) == TrackingRecHit::bad) ) { - int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3 - if ( muonStation >= 0 && muonStation < 4 ) { - if ( muonHitPattern.muonDTHitFilter(hit) ) ++numHitsDT[muonStation]; - else if ( muonHitPattern.muonCSCHitFilter(hit) ) ++numHitsCSC[muonStation]; - else if ( muonHitPattern.muonRPCHitFilter(hit) ) ++numHitsRPC[muonStation]; - } - } - } - } - } - - std::string format_vint(const std::vector& vi) - { - std::ostringstream os; - os << "{ "; - unsigned numEntries = vi.size(); - for ( unsigned iEntry = 0; iEntry < numEntries; ++iEntry ) { - os << vi[iEntry]; - if ( iEntry < (numEntries - 1) ) os << ", "; - } - os << " }"; - return os.str(); - } - - void countMatches(const reco::Muon& muon, std::vector& numMatchesDT, std::vector& numMatchesCSC, std::vector& numMatchesRPC) - { - const std::vector& muonSegments = muon.matches(); - for ( std::vector::const_iterator muonSegment = muonSegments.begin(); - muonSegment != muonSegments.end(); ++muonSegment ) { - if ( muonSegment->segmentMatches.empty() ) continue; - int muonDetector = muonSegment->detector(); - int muonStation = muonSegment->station() - 1; - assert(muonStation >= 0 && muonStation <= 3); - if ( muonDetector == MuonSubdetId::DT ) ++numMatchesDT[muonStation]; - else if ( muonDetector == MuonSubdetId::CSC ) ++numMatchesCSC[muonStation]; - else if ( muonDetector == MuonSubdetId::RPC ) ++numMatchesRPC[muonStation]; - } - } -} - double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& pfTau) const { if ( verbosity_ ) { @@ -181,8 +135,8 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p reco::MuonRef muonRef = pflch->muonRef(); if ( muonRef.isNonnull() ) { if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ; - countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); - countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); + reco::tau::countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); + reco::tau::countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); } } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } @@ -224,8 +178,8 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p } if ( dR < dRmatch ) { if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " overlaps with tau, dR = " << dR ; - countMatches(*muon, numMatchesDT, numMatchesCSC, numMatchesRPC); - countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC); + reco::tau::countMatches(*muon, numMatchesDT, numMatchesCSC, numMatchesRPC); + reco::tau::countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC); } } } @@ -268,10 +222,15 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p } } const reco::Track* leadTrack = nullptr; - if ( pflch->trackRef().isNonnull() ) leadTrack = pflch->trackRef().get(); - else if ( pflch->gsfTrackRef().isNonnull() ) leadTrack = pflch->gsfTrackRef().get(); - if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false; - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; + if ( pflch->trackRef().isNonnull() ) + leadTrack = pflch->trackRef().get(); + else if ( pflch->gsfTrackRef().isNonnull() ) + leadTrack = pflch->gsfTrackRef().get(); + if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) + passesCaloMuonVeto = false; + } else { + throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; + } } double discriminatorValue = 0.; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc index 097af96972df9..9acb3e06de95e 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonSimple.cc @@ -22,10 +22,14 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/Math/interface/deltaR.h" +#include "RecoTauTag/RecoTau/interface/RecoTauMuonTools.h" + #include #include #include +using reco::tau::format_vint; + namespace { class PFRecoTauDiscriminationAgainstMuonSimple final : public PFTauDiscriminationProducerBase @@ -95,65 +99,6 @@ void PFRecoTauDiscriminationAgainstMuonSimple::beginEvent(const edm::Event& evt, evt.getByToken(Muons_token, muons_); } -namespace -{ - /* MB: not used in current implementation, but keep it if needed in future - const reco::Track* getTrack(const reco::Candidate& cand) { - const pat::PackedCandidate* pCand = dynamic_cast(&cand); - if ( pCand != nullptr && pCand->hasTrackDetails() ) - return &pCand->pseudoTrack(); - return nullptr; - } - */ - void countHits(const pat::Muon& muon, std::vector& numHitsDT, std::vector& numHitsCSC, std::vector& numHitsRPC) - { - if ( muon.outerTrack().isNonnull() ) { - const reco::HitPattern &muonHitPattern = muon.outerTrack()->hitPattern(); - for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) { - uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit); - if ( hit == 0 ) break; - if ( muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid || muonHitPattern.getHitType(hit) == TrackingRecHit::bad) ) { - int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3 - if ( muonStation >= 0 && muonStation < 4 ) { - if ( muonHitPattern.muonDTHitFilter(hit) ) ++numHitsDT[muonStation]; - else if ( muonHitPattern.muonCSCHitFilter(hit) ) ++numHitsCSC[muonStation]; - else if ( muonHitPattern.muonRPCHitFilter(hit) ) ++numHitsRPC[muonStation]; - } - } - } - } - } - - void countMatches(const pat::Muon& muon, std::vector& numMatchesDT, std::vector& numMatchesCSC, std::vector& numMatchesRPC) - { - const std::vector& muonSegments = muon.matches(); - for ( std::vector::const_iterator muonSegment = muonSegments.begin(); - muonSegment != muonSegments.end(); ++muonSegment ) { - if ( muonSegment->segmentMatches.empty() ) continue; - int muonDetector = muonSegment->detector(); - int muonStation = muonSegment->station() - 1; - assert(muonStation >= 0 && muonStation <= 3); - if ( muonDetector == MuonSubdetId::DT ) ++numMatchesDT[muonStation]; - else if ( muonDetector == MuonSubdetId::CSC ) ++numMatchesCSC[muonStation]; - else if ( muonDetector == MuonSubdetId::RPC ) ++numMatchesRPC[muonStation]; - } - } - - std::string format_vint(const std::vector& vi) - { - std::ostringstream os; - os << "{ "; - unsigned numEntries = vi.size(); - for ( unsigned iEntry = 0; iEntry < numEntries; ++iEntry ) { - os << vi[iEntry]; - if ( iEntry < (numEntries - 1) ) os << ", "; - } - os << " }"; - return os.str(); - } - -} - double PFRecoTauDiscriminationAgainstMuonSimple::discriminate(const reco::PFTauRef& pfTau) const { if ( verbosity_ ) { @@ -252,14 +197,14 @@ double PFRecoTauDiscriminationAgainstMuonSimple::discriminate(const reco::PFTauR for (const auto &mu: muonsToCheck) { if ( mu->isStandAloneMuon() ) numSTAMuons++; if ( mu->muonID("RPCMuLoose") ) numRPCMuons++; - countMatches(*mu, numMatchesDT, numMatchesCSC, numMatchesRPC); + reco::tau::countMatches(*mu, numMatchesDT, numMatchesCSC, numMatchesRPC); int numStationsWithMatches = 0; for ( int iStation = 0; iStation < 4; ++iStation ) { if ( numMatchesDT[iStation] > 0 && !maskMatchesDT_[iStation] ) ++numStationsWithMatches; if ( numMatchesCSC[iStation] > 0 && !maskMatchesCSC_[iStation] ) ++numStationsWithMatches; if ( numMatchesRPC[iStation] > 0 && !maskMatchesRPC_[iStation] ) ++numStationsWithMatches; } - countHits(*mu, numHitsDT, numHitsCSC, numHitsRPC); + reco::tau::countHits(*mu, numHitsDT, numHitsCSC, numHitsRPC); int numLast2StationsWithHits = 0; for ( int iStation = 2; iStation < 4; ++iStation ) { if ( numHitsDT[iStation] > 0 && !maskHitsDT_[iStation] ) ++numLast2StationsWithHits; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc index 4cd0349939cc7..bf3a66c240749 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc @@ -98,8 +98,7 @@ else{ auto resultExt = std::make_unique(); for(JetTracksAssociationCollection::const_iterator iAssoc=thePFJetTracksAssociatorCollection->begin();iAssoc!=thePFJetTracksAssociatorCollection->end();iAssoc++){ - // PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo((*iAssoc).first.castTo(),thePFCandsInTheEvent,(*iAssoc).second,thePV); - PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo(JetBaseRef((*iAssoc).first),thePFCandsInTheEvent,(*iAssoc).second,thePV); + PFTauTagInfo myPFTauTagInfo=PFRecoTauTagInfoAlgo_->buildPFTauTagInfo(JetBaseRef((*iAssoc).first),thePFCandsInTheEvent,(*iAssoc).second,thePV); resultExt->push_back(myPFTauTagInfo); } diff --git a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc deleted file mode 100644 index 30ec20c68cc7c..0000000000000 --- a/RecoTauTag/RecoTau/plugins/RecoPatTauJetRegionProducer.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* - * RecoTauPatJetRegionProducer - * - * Given a set of PFJets, make new jets with the same p4 but collect all the - * PFCandidates from a cone of a given size into the constituents. - * - * Author: Evan K. Friis, UC Davis - * - */ - -#include - -#include "DataFormats/PatCandidates/interface/Jet.h" -#include "DataFormats/Common/interface/Association.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" -#include "DataFormats/Common/interface/AssociationMap.h" - -#include "RecoTauTag/RecoTau/interface/ConeTools.h" -#include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/makeRefToBaseProdFrom.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include -#include - -class RecoTauPatJetRegionProducer : public edm::stream::EDProducer<> -{ - public: - // typedef edm::Association PatJetMatchMap; - typedef edm::AssociationMap > PatJetMatchMap; - typedef edm::AssociationMap, std::vector, unsigned int> > JetToPackedCandidateAssociation; - explicit RecoTauPatJetRegionProducer(const edm::ParameterSet& pset); - ~RecoTauPatJetRegionProducer() override {} - - void produce(edm::Event& evt, const edm::EventSetup& es) override; - - private: - std::string moduleLabel_; - - edm::InputTag inputJets_; - edm::InputTag pfCandSrc_; - edm::InputTag pfCandAssocMapSrc_; - - edm::EDGetTokenT pf_token; - edm::EDGetTokenT Jets_token; - edm::EDGetTokenT pfCandAssocMap_token; - - double minJetPt_; - double maxJetAbsEta_; - double deltaR2_; - - int verbosity_; -}; - -RecoTauPatJetRegionProducer::RecoTauPatJetRegionProducer(const edm::ParameterSet& cfg) - : moduleLabel_(cfg.getParameter("@module_label")) -{ - inputJets_ = cfg.getParameter("src"); - pfCandSrc_ = cfg.getParameter("pfCandSrc"); - pfCandAssocMapSrc_ = cfg.getParameter("pfCandAssocMapSrc"); - - pf_token = consumes(pfCandSrc_); - Jets_token = consumes(inputJets_); - pfCandAssocMap_token = consumes(pfCandAssocMapSrc_); - - double deltaR = cfg.getParameter("deltaR"); - deltaR2_ = deltaR*deltaR; - minJetPt_ = ( cfg.exists("minJetPt") ) ? cfg.getParameter("minJetPt") : -1.0; - maxJetAbsEta_ = ( cfg.exists("maxJetAbsEta") ) ? cfg.getParameter("maxJetAbsEta") : 99.0; - - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; - - produces("jets"); - produces(); -} - -void RecoTauPatJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& es) -{ - if ( verbosity_ ) { - std::cout << ":" << std::endl; - std::cout << " inputJets = " << inputJets_ << std::endl; - std::cout << " pfCandSrc = " << pfCandSrc_ << std::endl; - std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl; - } - - edm::Handle pfCandsHandle; - evt.getByToken(pf_token, pfCandsHandle); - - // Build Ptrs for all the PFCandidates - typedef edm::Ptr PackedCandPtr; - std::vector pfCands; - pfCands.reserve(pfCandsHandle->size()); - for ( size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) { - pfCands.push_back(PackedCandPtr(pfCandsHandle, icand)); - } - - // Get the jets - edm::Handle jetView; - evt.getByToken(Jets_token, jetView); - // Convert to a vector of PFJetRefs - pat::JetRefVector jets = reco::tau::castView(jetView); - size_t nJets = jets.size(); - - // Get the association map matching jets to PFCandidates - // (needed for recinstruction of boosted taus) - edm::Handle jetToPFCandMap; - std::vector > fastJetToPFCandMap; - if ( !pfCandAssocMapSrc_.label().empty() ) { - evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); - fastJetToPFCandMap.resize(nJets); - for ( size_t ijet = 0; ijet < nJets; ++ijet ) { - // Get a ref to jet - const pat::JetRef& jetRef = jets[ijet]; - const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef]; - for ( const auto& pfCandMappedToJet : pfCandsMappedToJet ) { - fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key()); - } - } - } - - // Get the original product, so we can match against it - otherwise the - // indices don't match up. - edm::ProductID originalId = jets.id(); - edm::Handle originalJets; - size_t nOriginalJets = 0; - // We have to make sure that we have some selected jets, otherwise we don't - // actually have a valid product ID to the original jets. - if ( nJets ) { - try { - evt.get(originalId, originalJets); - } catch(const cms::Exception &e) { - edm::LogError("MissingOriginalCollection") - << "Can't get the original jets that made: " << inputJets_ - << " that have product ID: " << originalId - << " from the event!!"; - throw e; - } - nOriginalJets = originalJets->size(); - } - - auto newJets = std::make_unique(); - - // Keep track of the indices of the current jet and the old (original) jet - // -1 indicates no match. - std::vector matchInfo(nOriginalJets, -1); - newJets->reserve(nJets); - size_t nNewJets = 0; - for ( size_t ijet = 0; ijet < nJets; ++ijet ) { - // Get a ref to jet - const pat::JetRef& jetRef = jets[ijet]; - if(jetRef->pt() - minJetPt_ < 1e-5) continue; - if(std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5) continue; - // Make an initial copy. - newJets->emplace_back(*jetRef); - pat::Jet& newJet = newJets->back(); - // Clear out all the constituents - newJet.clearDaughters(); - // Loop over all the PFCands - for ( const auto& pfCand : pfCands ) { - bool isMappedToJet = false; - if ( jetToPFCandMap.isValid() ) { - auto temp = jetToPFCandMap->find(jetRef); - if( temp == jetToPFCandMap->end() ) { - edm::LogWarning("WeirdCandidateMap") << "Candidate map for jet " << jetRef.key() << " is empty!"; - continue; - } - isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key()); - } else { - isMappedToJet = true; - } - if ( reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet ) newJet.addDaughter(pfCand); - } - if ( verbosity_ ) { - std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta() << ", phi = " << jetRef->eta() << "," - << " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl; - auto jetConstituents = newJet.daughterPtrVector(); - int idx = 0; - for ( const auto& jetConstituent : jetConstituents) { - std::cout << " constituent #" << idx << ": Pt = " << jetConstituent->pt() << ", eta = " << jetConstituent->eta() << ", phi = " << jetConstituent->phi() << std::endl; - ++idx; - } - } - // Match the index of the jet we just made to the index into the original - // collection. - //matchInfo[jetRef.key()] = ijet; - matchInfo[jetRef.key()] = nNewJets; - nNewJets++; - } - - // Put our new jets into the event - edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); - - // Create a matching between original jets -> extra collection - auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); - for (size_t ijet = 0; ijet < nJets; ++ijet) { - matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); - } - evt.put(std::move(matching)); -} - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(RecoTauPatJetRegionProducer); - diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index 45b7605794ead..01d92d2318df6 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -1,8 +1,8 @@ /* * RecoTauJetRegionProducer * - * Given a set of PFJets, make new jets with the same p4 but collect all the - * PFCandidates from a cone of a given size into the constituents. + * Given a set of Jets, make new jets with the same p4 but collect all the + * particle-flow candidates from a cone of a given size into the constituents. * * Author: Evan K. Friis, UC Davis * @@ -11,9 +11,11 @@ #include #include "DataFormats/JetReco/interface/PFJet.h" +#include "DataFormats/PatCandidates/interface/Jet.h" #include "DataFormats/Common/interface/Association.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/AssociationMap.h" #include "RecoTauTag/RecoTau/interface/ConeTools.h" @@ -30,14 +32,14 @@ #include #include -class RecoTauJetRegionProducer : public edm::stream::EDProducer<> +template +class RecoTauGenericJetRegionProducer : public edm::stream::EDProducer<> { public: - // typedef edm::Association PFJetMatchMap; - typedef edm::AssociationMap > PFJetMatchMap; - typedef edm::AssociationMap, std::vector, unsigned int> > JetToPFCandidateAssociation; - explicit RecoTauJetRegionProducer(const edm::ParameterSet& pset); - ~RecoTauJetRegionProducer() override {} + typedef edm::AssociationMap > JetMatchMap; + typedef edm::AssociationMap, std::vector, unsigned int> > JetToCandidateAssociation; + explicit RecoTauGenericJetRegionProducer(const edm::ParameterSet& pset); + ~RecoTauGenericJetRegionProducer() override {} void produce(edm::Event& evt, const edm::EventSetup& es) override; @@ -48,9 +50,9 @@ class RecoTauJetRegionProducer : public edm::stream::EDProducer<> edm::InputTag pfCandSrc_; edm::InputTag pfCandAssocMapSrc_; - edm::EDGetTokenT pf_token; + edm::EDGetTokenT > pf_token; edm::EDGetTokenT Jets_token; - edm::EDGetTokenT pfCandAssocMap_token; + edm::EDGetTokenT pfCandAssocMap_token; double minJetPt_; double maxJetAbsEta_; @@ -59,16 +61,17 @@ class RecoTauJetRegionProducer : public edm::stream::EDProducer<> int verbosity_; }; -RecoTauJetRegionProducer::RecoTauJetRegionProducer(const edm::ParameterSet& cfg) +template +RecoTauGenericJetRegionProducer::RecoTauGenericJetRegionProducer(const edm::ParameterSet& cfg) : moduleLabel_(cfg.getParameter("@module_label")) { inputJets_ = cfg.getParameter("src"); pfCandSrc_ = cfg.getParameter("pfCandSrc"); pfCandAssocMapSrc_ = cfg.getParameter("pfCandAssocMapSrc"); - pf_token = consumes(pfCandSrc_); + pf_token = consumes >(pfCandSrc_); Jets_token = consumes(inputJets_); - pfCandAssocMap_token = consumes(pfCandAssocMapSrc_); + pfCandAssocMap_token = consumes(pfCandAssocMapSrc_); double deltaR = cfg.getParameter("deltaR"); deltaR2_ = deltaR*deltaR; @@ -78,11 +81,12 @@ RecoTauJetRegionProducer::RecoTauJetRegionProducer(const edm::ParameterSet& cfg) verbosity_ = ( cfg.exists("verbosity") ) ? cfg.getParameter("verbosity") : 0; - produces("jets"); - produces(); + produces >("jets"); + produces(); } -void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& es) +template +void RecoTauGenericJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& es) { if ( verbosity_ ) { std::cout << ":" << std::endl; @@ -91,34 +95,34 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl; } - edm::Handle pfCandsHandle; + edm::Handle > pfCandsHandle; evt.getByToken(pf_token, pfCandsHandle); // Build Ptrs for all the PFCandidates - typedef edm::Ptr PFCandPtr; - std::vector pfCands; + typedef edm::Ptr CandPtr; + std::vector pfCands; pfCands.reserve(pfCandsHandle->size()); for ( size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) { - pfCands.push_back(PFCandPtr(pfCandsHandle, icand)); + pfCands.push_back(CandPtr(pfCandsHandle, icand)); } // Get the jets edm::Handle jetView; evt.getByToken(Jets_token, jetView); - // Convert to a vector of PFJetRefs - reco::PFJetRefVector jets = reco::tau::castView(jetView); + // Convert to a vector of JetRefs + edm::RefVector > jets = reco::tau::castView > >(jetView); size_t nJets = jets.size(); - // Get the association map matching jets to PFCandidates + // Get the association map matching jets to Candidates // (needed for recinstruction of boosted taus) - edm::Handle jetToPFCandMap; + edm::Handle jetToPFCandMap; std::vector > fastJetToPFCandMap; if ( !pfCandAssocMapSrc_.label().empty() ) { evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); fastJetToPFCandMap.resize(nJets); for ( size_t ijet = 0; ijet < nJets; ++ijet ) { // Get a ref to jet - const reco::PFJetRef& jetRef = jets[ijet]; + const edm::Ref >& jetRef = jets[ijet]; const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef]; for ( const auto& pfCandMappedToJet : pfCandsMappedToJet ) { fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key()); @@ -129,7 +133,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e // Get the original product, so we can match against it - otherwise the // indices don't match up. edm::ProductID originalId = jets.id(); - edm::Handle originalJets; + edm::Handle > originalJets; size_t nOriginalJets = 0; // We have to make sure that we have some selected jets, otherwise we don't // actually have a valid product ID to the original jets. @@ -146,7 +150,7 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e nOriginalJets = originalJets->size(); } - auto newJets = std::make_unique(); + auto newJets = std::make_unique >(); // Keep track of the indices of the current jet and the old (original) jet // -1 indicates no match. @@ -155,12 +159,12 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e size_t nNewJets = 0; for ( size_t ijet = 0; ijet < nJets; ++ijet ) { // Get a ref to jet - const reco::PFJetRef& jetRef = jets[ijet]; + const edm::Ref >& jetRef = jets[ijet]; if(jetRef->pt() - minJetPt_ < 1e-5) continue; if(std::abs(jetRef->eta()) - maxJetAbsEta_ > -1e-5) continue; // Make an initial copy. newJets->emplace_back(*jetRef); - reco::PFJet& newJet = newJets->back(); + JetType& newJet = newJets->back(); // Clear out all the constituents newJet.clearDaughters(); // Loop over all the PFCands @@ -181,11 +185,11 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e if ( verbosity_ ) { std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta() << ", phi = " << jetRef->eta() << "," << " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl; - std::vector jetConstituents = newJet.getPFConstituents(); + auto jetConstituents = newJet.daughterPtrVector(); int idx = 0; - for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); - jetConstituent != jetConstituents.end(); ++jetConstituent ) { - std::cout << " constituent #" << idx << ": Pt = " << (*jetConstituent)->pt() << ", eta = " << (*jetConstituent)->eta() << ", phi = " << (*jetConstituent)->phi() << std::endl; + for ( const auto& jetConstituent : jetConstituents) { + std::cout << " constituent #" << idx << ": Pt = " << jetConstituent->pt() << ", eta = " << jetConstituent->eta() << ", phi = " << jetConstituent->phi() << std::endl; + ++idx; } } // Match the index of the jet we just made to the index into the original @@ -196,15 +200,20 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e } // Put our new jets into the event - edm::OrphanHandle newJetsInEvent = evt.put(std::move(newJets), "jets"); + edm::OrphanHandle > newJetsInEvent = evt.put(std::move(newJets), "jets"); // Create a matching between original jets -> extra collection - auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); + auto matching = (nJets !=0) ? std::make_unique(edm::makeRefToBaseProdFrom(edm::RefToBase(jets[0]), evt), newJetsInEvent) : std::make_unique(); for (size_t ijet = 0; ijet < nJets; ++ijet) { - matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref(newJetsInEvent, matchInfo[ijet]))); + matching->insert(edm::RefToBase(jets[ijet]), edm::RefToBase(edm::Ref >(newJetsInEvent, matchInfo[ijet]))); } evt.put(std::move(matching)); } +template class RecoTauGenericJetRegionProducer; +typedef RecoTauGenericJetRegionProducer RecoTauJetRegionProducer; +template class RecoTauGenericJetRegionProducer; +typedef RecoTauGenericJetRegionProducer RecoTauPatJetRegionProducer; #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauJetRegionProducer); +DEFINE_FWK_MODULE(RecoTauPatJetRegionProducer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index d723149254a7f..ff78047a91929 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -227,10 +227,6 @@ RecoTauPiZeroStripPlugin2::return_type RecoTauPiZeroStripPlugin2::operator()(con << " numHits = " << candTrack->hitPattern().numberOfValidTrackerHits() << ", numPxlHits = " << candTrack->hitPattern().numberOfValidPixelHits() << "," << " chi2 = " << candTrack->normalizedChi2() << ", dPt/Pt = " << (candTrack->ptError()/candTrack->pt()) << ")" ; } - // edm::LogPrint("RecoTauPiZeroStripPlugin2") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," - // << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; - // edm::LogPrint("RecoTauPiZeroStripPlugin2") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," - // << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; } seedCands.push_back(*cand); } else if ( (*cand)->et() > minGammaEtStripAdd_ ) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index df6b52c4158b8..2cbe658e59ef7 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -254,10 +254,6 @@ RecoTauPiZeroStripPlugin3::return_type RecoTauPiZeroStripPlugin3::operator()(con << " numHits = " << candTrack->hitPattern().numberOfValidTrackerHits() << ", numPxlHits = " << candTrack->hitPattern().numberOfValidPixelHits() << "," << " chi2 = " << candTrack->normalizedChi2() << ", dPt/Pt = " << (candTrack->ptError()/candTrack->pt()) << ")" ; } - // edm::LogPrint("RecoTauPiZeroStripPlugin3") << "ECAL Et: calibrated = " << (*cand)->ecalEnergy()*sin((*cand)->theta()) << "," - // << " raw = " << (*cand)->rawEcalEnergy()*sin((*cand)->theta()) ; - // edm::LogPrint("RecoTauPiZeroStripPlugin3") << "HCAL Et: calibrated = " << (*cand)->hcalEnergy()*sin((*cand)->theta()) << "," - // << " raw = " << (*cand)->rawHcalEnergy()*sin((*cand)->theta()) ; } seedCands.push_back(*cand); } else if ( (*cand)->et() > minGammaEtStripAdd_ ) { diff --git a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc index ba06e6349d532..fc83bfd568f50 100644 --- a/RecoTauTag/RecoTau/src/RecoTauConstructor.cc +++ b/RecoTauTag/RecoTau/src/RecoTauConstructor.cc @@ -58,21 +58,6 @@ RecoTauConstructor::RecoTauConstructor(const JetBaseRef& jet, const edm::Handle< tau_->setjetRef(jet); } -// void RecoTauConstructor::addPFCand(Region region, ParticleType type, const CandidateRef& ref, bool skipAddToP4) { -// LogDebug("TauConstructorAddPFCand") << " region = " << region << ", type = " << type << ": Pt = " << ref->pt() << ", eta = " << ref->eta() << ", phi = " << ref->phi(); -// if ( region == kSignal ) { -// // Keep track of the four vector of the signal vector products added so far. -// // If a photon add it if we are not using PiZeros to build the gammas -// if ( ((type != kGamma) || !copyGammas_) && !skipAddToP4 ) { -// LogDebug("TauConstructorAddPFCand") << "--> adding PFCand to tauP4." ; -// p4_ += ref->p4(); -// } -// } -// getSortedCollection(region, type)->push_back(edm::refToPtr(ref)); -// // Add to global collection -// getSortedCollection(region, kAll)->push_back(edm::refToPtr(ref)); -// } - void RecoTauConstructor::addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4) { LogDebug("TauConstructorAddPFCand") << " region = " << region << ", type = " << type << ": Pt = " << ptr->pt() << ", eta = " << ptr->eta() << ", phi = " << ptr->phi(); if ( region == kSignal ) { @@ -252,14 +237,6 @@ void checkMatchedProductIds(const T1& t1, const T2& t2) { } } -// PFCandidatePtr RecoTauConstructor::convertToPtr( -// const PFCandidateRef& pfRef) const { -// if(pfRef.isNonnull()) { -// checkMatchedProductIds(pfRef, pfCands_); -// return PFCandidatePtr(pfCands_, pfRef.key()); -// } else return PFCandidatePtr(); -// } - // Convert from a CandidateRef to a Ptr CandidatePtr RecoTauConstructor::convertToPtr( const PFCandidatePtr& candPtr) const { diff --git a/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc b/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc new file mode 100644 index 0000000000000..8a75d06eb2bec --- /dev/null +++ b/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc @@ -0,0 +1,53 @@ +#include "RecoTauTag/RecoTau/interface/RecoTauMuonTools.h" + +#include "DataFormats/TrackReco/interface/HitPattern.h" + +namespace reco { namespace tau { + void countHits(const reco::Muon& muon, std::vector& numHitsDT, std::vector& numHitsCSC, std::vector& numHitsRPC) + { + if ( muon.outerTrack().isNonnull() ) { + const reco::HitPattern &muonHitPattern = muon.outerTrack()->hitPattern(); + for (int iHit = 0; iHit < muonHitPattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); ++iHit) { + uint32_t hit = muonHitPattern.getHitPattern(reco::HitPattern::TRACK_HITS, iHit); + if ( hit == 0 ) break; + if ( muonHitPattern.muonHitFilter(hit) && (muonHitPattern.getHitType(hit) == TrackingRecHit::valid || muonHitPattern.getHitType(hit) == TrackingRecHit::bad) ) { + int muonStation = muonHitPattern.getMuonStation(hit) - 1; // CV: map into range 0..3 + if ( muonStation >= 0 && muonStation < 4 ) { + if ( muonHitPattern.muonDTHitFilter(hit) ) ++numHitsDT[muonStation]; + else if ( muonHitPattern.muonCSCHitFilter(hit) ) ++numHitsCSC[muonStation]; + else if ( muonHitPattern.muonRPCHitFilter(hit) ) ++numHitsRPC[muonStation]; + } + } + } + } + } + + std::string format_vint(const std::vector& vi) + { + std::ostringstream os; + os << "{ "; + unsigned numEntries = vi.size(); + for ( unsigned iEntry = 0; iEntry < numEntries; ++iEntry ) { + os << vi[iEntry]; + if ( iEntry < (numEntries - 1) ) os << ", "; + } + os << " }"; + return os.str(); + } + + void countMatches(const reco::Muon& muon, std::vector& numMatchesDT, std::vector& numMatchesCSC, std::vector& numMatchesRPC) + { + const std::vector& muonSegments = muon.matches(); + for ( std::vector::const_iterator muonSegment = muonSegments.begin(); + muonSegment != muonSegments.end(); ++muonSegment ) { + if ( muonSegment->segmentMatches.empty() ) continue; + int muonDetector = muonSegment->detector(); + int muonStation = muonSegment->station() - 1; + assert(muonStation >= 0 && muonStation <= 3); + if ( muonDetector == MuonSubdetId::DT ) ++numMatchesDT[muonStation]; + else if ( muonDetector == MuonSubdetId::CSC ) ++numMatchesCSC[muonStation]; + else if ( muonDetector == MuonSubdetId::RPC ) ++numMatchesRPC[muonStation]; + } + } + +}} // end namespace reco::tau \ No newline at end of file diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index b4f0cf841bc7b..bf98ccc851755 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -28,17 +28,26 @@ namespace { return nullptr; } - const reco::TrackBaseRef getTrackRef(const Candidate& cand) + const reco::TrackRef getTrackRef(const Candidate& cand) + { + const PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) + return pfCandPtr->trackRef(); + + return reco::TrackRef(); + } + + const reco::TrackBaseRef getGsfTrackRef(const Candidate& cand) { const PFCandidate* pfCandPtr = dynamic_cast(&cand); if (pfCandPtr) { - if ( pfCandPtr->trackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->trackRef()); - else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); + return reco::TrackBaseRef(pfCandPtr->gsfTrackRef()); } return reco::TrackBaseRef(); } + // Translate GsfTrackRef to TrackBaseRef template reco::TrackBaseRef convertRef(const T& ref) { @@ -184,6 +193,19 @@ bool minTrackVertexWeight(const TrackBaseRef& track, const reco::VertexRef* pv, return ((*pv)->trackWeight(track) >= cut); } +bool minTrackVertexWeight(const TrackRef& track, const reco::VertexRef* pv, double cut) +{ + if ( pv->isNull() ) { + edm::LogError("QCutsNoPrimaryVertex") << "Primary vertex Ref in " << + "RecoTauQualityCuts is invalid. - minTrackVertexWeight"; + return false; + } + LogDebug("TauQCuts") << " track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() ; + LogDebug("TauQCuts") << " vertex: x = " << (*pv)->position().x() << ", y = " << (*pv)->position().y() << ", z = " << (*pv)->position().z() ; + LogDebug("TauQCuts") << "--> trackWeight = " << (*pv)->trackWeight(track) << " (cut = " << cut << ")" ; + return ((*pv)->trackWeight(track) >= cut); +} + bool minPackedCandVertexWeight(const pat::PackedCandidate& pCand, const reco::VertexRef* pv, double cut) { if ( pv->isNull() ) { @@ -210,6 +232,11 @@ bool minTrackVertexWeight_cand(const Candidate& cand, const reco::VertexRef* pv, if ( track.isNonnull() ) { return minTrackVertexWeight(track, pv, cut); } + auto gsfTrack = getGsfTrackRef(cand); + if ( gsfTrack.isNonnull() ) { + return minTrackVertexWeight(gsfTrack, pv, cut); + } + const pat::PackedCandidate* pCand = dynamic_cast(&cand); if( pCand != nullptr && cand.charge() != 0) { return minPackedCandVertexWeight(*pCand, pv, cut); @@ -509,11 +536,18 @@ bool RecoTauQualityCuts::filterCand(const reco::Candidate& cand) const auto trackRef = getTrackRef(cand); bool result = true; - if(trackRef.isNonnull()) + if (trackRef.isNonnull()) { result = filterTrack(trackRef); - else if(cand.charge() != 0){ - result = filterChargedCand(cand); + } + else { + auto gsfTrackRef = getGsfTrackRef(cand); + if (gsfTrackRef.isNonnull()) + result = filterTrack(gsfTrackRef); + else if (cand.charge() != 0) { + result = filterChargedCand(cand); + } } + if(result) result = filterCandByType(cand); diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index bde272f3c096f..52fd770cff3ae 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -16,13 +16,11 @@ const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); if (chargedPFPCand != nullptr) { - if (chargedPFPCand->hasTrackDetails()) - return &chargedPFPCand->pseudoTrack(); + return chargedPFPCand->bestTrack(); } const pat::PackedCandidate* lostTrackCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); if (lostTrackCand != nullptr) { - if (lostTrackCand->hasTrackDetails()) - return &lostTrackCand->pseudoTrack(); + return lostTrackCand->bestTrack(); } return nullptr; } diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 4c8207829304d..60ae566f68889 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -55,8 +55,8 @@ if runSignal: readFiles.extend( [ - 'file:patMiniAOD_standard.root' - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/94FC956F-17E1-E711-B672-0025905A60A6.root', + # 'file:patMiniAOD_standard.root' + 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ] ) else: From 1b1fff752b41964d6fadb8ad3d0e85f5cef4edfb Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 10 Apr 2018 16:45:40 +0200 Subject: [PATCH 042/686] Remove leftover exception --- .../plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 9059ff9da67ac..15e641cec2348 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -119,7 +119,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& leadChargedPFCandEtaAtEcalEntrance = pfcand->positionAtECALEntrance().eta(); leadChargedPFCandPt = track->pt(); } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; + } } if( (*thePFTauRef).leadChargedHadrCand().isNonnull()) { @@ -149,7 +149,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); bool hasGsfTrack = false; - if (lpfch) { + if (lpfch != nullptr) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; @@ -191,7 +191,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); bool hasGsfTrack = false; - if (lpfch) { + if (lpfch != nullptr) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; From 1814e22964d40c3ad3e5fb9c0fcec4d93b2b98c4 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 10 Apr 2018 17:35:09 +0200 Subject: [PATCH 043/686] Only convert to edm::Ptr if candidate is present --- DataFormats/TauReco/src/PFTau.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index a31b89aa9ae10..e865af739e8c1 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -124,7 +124,7 @@ namespace { reco::PFCandidatePtr convertToPFPtr(const reco::CandidatePtr& ptr) { const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); - if (pf_cand) { + if (pf_cand != nullptr) { return edm::Ptr(ptr); } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access a PFCandidate.\n"; return reco::PFCandidatePtr(); @@ -150,15 +150,21 @@ namespace { } const PFCandidatePtr PFTau::leadPFChargedHadrCand() const { - return convertToPFPtr(leadChargedHadrCand_); + if (leadChargedHadrCand_.isNonnull()) + return convertToPFPtr(leadChargedHadrCand_); + return PFCandidatePtr(); } const PFCandidatePtr PFTau::leadPFNeutralCand() const { - return convertToPFPtr(leadNeutralCand_); + if (leadNeutralCand_.isNonnull()) + return convertToPFPtr(leadNeutralCand_); + return PFCandidatePtr(); } const PFCandidatePtr PFTau::leadPFCand() const { - return convertToPFPtr(leadCand_); + if (leadCand_.isNonnull()) + return convertToPFPtr(leadCand_); + return PFCandidatePtr(); } const std::vector& PFTau::signalPFCands() const { From ea83bd40a092522b3d56b650496b4073b69dceb5 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Wed, 11 Apr 2018 14:52:00 +0200 Subject: [PATCH 044/686] Address style comments: range loops, lower case for variables, duplicated code to a common method, etc. --- .../PFTauMiniAODPrimaryVertexProducer.cc | 219 +++++++++--------- .../plugins/PFTauPrimaryVertexProducer.cc | 137 +++++------ 2 files changed, 166 insertions(+), 190 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index bbfaeec52f529..ee34e9c426532 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -28,7 +28,8 @@ #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -36,7 +37,8 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "DataFormats/Common/interface/RefToBase.h" -#include "DataFormats/PatCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" #include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/Association.h" @@ -48,6 +50,7 @@ #include #include #include +#include "DataFormats/Math/interface/deltaR.h" #include @@ -57,7 +60,7 @@ using namespace std; class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> { public: - enum Alg{useInputPV=0, useFontPV}; + enum Alg{useInputPV=0, useFrontPV}; struct DiscCutPair{ DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} @@ -74,13 +77,18 @@ class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> void produce(edm::Event&,const edm::EventSetup&) override; private: - edm::EDGetTokenT > PFTauToken_; - edm::EDGetTokenT > ElectronToken_; - edm::EDGetTokenT > MuonToken_; - edm::EDGetTokenT PVToken_; + void nonTauTracksInPVFromPackedCands(const pat::PackedCandidateCollection&, + const size_t&, + const std::vector&, + std::vector &); + + edm::EDGetTokenT > pftauToken_; + edm::EDGetTokenT > electronToken_; + edm::EDGetTokenT > muonToken_; + edm::EDGetTokenT pvToken_; edm::EDGetTokenT beamSpotToken_; - edm::EDGetTokenT > packedCandsToken_, lostCandsToken_; - int Algorithm_; + edm::EDGetTokenT packedCandsToken_, lostCandsToken_; + int algorithm_; edm::ParameterSet qualityCutsPSet_; bool useBeamSpot_; bool useSelectedTaus_; @@ -92,14 +100,14 @@ class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> }; PFTauMiniAODPrimaryVertexProducer::PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet& iConfig): - PFTauToken_(consumes >(iConfig.getParameter("PFTauTag"))), - ElectronToken_(consumes >(iConfig.getParameter("ElectronTag"))), - MuonToken_(consumes >(iConfig.getParameter("MuonTag"))), - PVToken_(consumes(iConfig.getParameter("PVTag"))), + pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), + electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), + muonToken_(consumes >(iConfig.getParameter("MuonTag"))), + pvToken_(consumes(iConfig.getParameter("PVTag"))), beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), - packedCandsToken_(consumes >(iConfig.getParameter("packedCandidatesTag"))), - lostCandsToken_(consumes >(iConfig.getParameter("lostCandidatesTag"))), - Algorithm_(iConfig.getParameter("Algorithm")), + packedCandsToken_(consumes(iConfig.getParameter("packedCandidatesTag"))), + lostCandsToken_(consumes(iConfig.getParameter("lostCandidatesTag"))), + algorithm_(iConfig.getParameter("Algorithm")), qualityCutsPSet_(iConfig.getParameter("qualityCuts")), useBeamSpot_(iConfig.getParameter("useBeamSpot")), useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), @@ -142,31 +150,31 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev edm::ESHandle transTrackBuilder; iSetup.get().get("TransientTrackBuilder",transTrackBuilder); - edm::Handle > Tau; - iEvent.getByToken(PFTauToken_,Tau); + edm::Handle > pfTaus; + iEvent.getByToken(pftauToken_,pfTaus); - edm::Handle > Electron; - iEvent.getByToken(ElectronToken_,Electron); + edm::Handle > electrons; + iEvent.getByToken(electronToken_,electrons); - edm::Handle > Mu; - iEvent.getByToken(MuonToken_,Mu); + edm::Handle > muons; + iEvent.getByToken(muonToken_,muons); - edm::Handle PV; - iEvent.getByToken(PVToken_,PV); + edm::Handle vertices; + iEvent.getByToken(pvToken_,vertices); edm::Handle beamSpot; iEvent.getByToken(beamSpotToken_,beamSpot); - edm::Handle > packedCands; + edm::Handle packedCands; iEvent.getByToken(packedCandsToken_, packedCands); - edm::Handle > lostCands; + edm::Handle lostCands; iEvent.getByToken(lostCandsToken_, lostCands); // Set Association Map - auto AVPFTauPV = std::make_unique>>(PFTauRefProd(Tau)); - auto VertexCollection_out = std::make_unique(); - reco::VertexRefProd VertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); + auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); + auto vertexCollection_out = std::make_unique(); + reco::VertexRefProd vertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); // Load each discriminator BOOST_FOREACH(DiscCutPair *disc, discriminators_) { @@ -176,22 +184,22 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev } // Set event for VerexAssociator if needed - if(useInputPV==Algorithm_) + if(useInputPV==algorithm_) vertexAssociator_->setEvent(iEvent); // For each Tau Run Algorithim - if(Tau.isValid()){ - for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) { - reco::PFTauRef tau(Tau, iPFTau); + if(pfTaus.isValid()){ + for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { + reco::PFTauRef tau(pfTaus, iPFTau); reco::Vertex thePV; size_t thePVkey = 0; - if(useInputPV==Algorithm_){ + if(useInputPV==algorithm_){ reco::VertexRef thePVRef = vertexAssociator_->associatedVertex(*tau); thePV = *thePVRef; thePVkey = thePVRef.key(); } - else if(useFontPV==Algorithm_){ - thePV=PV->front(); + else if(useFrontPV==algorithm_){ + thePV=vertices->front(); thePVkey = 0; } /////////////////////// @@ -206,37 +214,34 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ - std::vector SignalTracks; - for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < Tau->size(); jPFTau++) { + std::vector signalTracks; + for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ - reco::PFTauRef RefPFTau(Tau, jPFTau); + reco::PFTauRef pfTauRef(pfTaus, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// - // Get tracks from PFTau daugthers - const std::vector cands = RefPFTau->signalChargedHadrCands(); - for(std::vector::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter){ - if((*iter).isNull()) continue; - const reco::Track* track = getTrack(**iter); + // Get tracks from PFTau daughters + for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { + if(pfcand.isNull()) continue; + const reco::Track* track = getTrack(*pfcand); if(track == nullptr) continue; - SignalTracks.push_back(track); + signalTracks.push_back(track); } } } // Get Muon tracks if(removeMuonTracks_){ - if(Mu.isValid()) { - for(pat::MuonCollection::size_type iMuon = 0; iMuon< Mu->size(); iMuon++){ - pat::MuonRef RefMuon(Mu, iMuon); - if(RefMuon->track().isNonnull()) SignalTracks.push_back(RefMuon->track().get()); + if(muons.isValid()) { + for(const auto& muon: *muons){ + if(muon.track().isNonnull()) signalTracks.push_back(muon.track().get()); } } } // Get Electron Tracks if(removeElectronTracks_){ - if(Electron.isValid()) { - for(pat::ElectronCollection::size_type iElectron = 0; iElectronsize(); iElectron++){ - pat::ElectronRef RefElectron(Electron, iElectron); - if(RefElectron->gsfTrack().isNonnull()) SignalTracks.push_back(RefElectron->gsfTrack().get()); + if(electrons.isValid()) { + for(const auto& electron: *electrons){ + if(electron.gsfTrack().isNonnull()) signalTracks.push_back(electron.gsfTrack().get()); } } } @@ -245,68 +250,20 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev std::vector nonTauTracks; //PackedCandidates first... if(packedCands.isValid()) { - //Find candidates/tracks associated to thePV - for(size_t iCand=0; iCandsize(); ++iCand){ - if((*packedCands)[iCand].vertexRef().isNull()) continue; - int quality = (*packedCands)[iCand].pvAssociationQuality(); - if((*packedCands)[iCand].vertexRef().key()!=thePVkey || - (quality!=pat::PackedCandidate::UsedInFitTight && - quality!=pat::PackedCandidate::UsedInFitLoose)) continue; - const reco::Track* track = getTrack((*packedCands)[iCand]); - if(track == nullptr) continue; - //Remove signal (tau) tracks - //MB: Only deltaR deltaPt overlap removal possible (?) - //MB: It should be fine as pat objects stores same track info with same presision - bool skipTrack = false; - for(size_t iSigTrk=0 ; iSigTrketa(),SignalTracks[iSigTrk]->phi(), - track->eta(),track->phi())<0.005*0.005 - && std::abs(SignalTracks[iSigTrk]->pt()/track->pt()-1.)<0.005 - ){ - skipTrack = true; - break; - } - } - if(skipTrack) continue; - nonTauTracks.push_back(track); - } + nonTauTracksInPVFromPackedCands(*packedCands,thePVkey,signalTracks,nonTauTracks); } //then lostCandidates if(lostCands.isValid()) { - //Find candidates/tracks associated to thePV - for(size_t iCand=0; iCandsize(); ++iCand){ - if((*lostCands)[iCand].vertexRef().isNull()) continue; - int quality = (*lostCands)[iCand].pvAssociationQuality(); - if((*lostCands)[iCand].vertexRef().key()!=thePVkey || - (quality!=pat::PackedCandidate::UsedInFitTight && - quality!=pat::PackedCandidate::UsedInFitLoose)) continue; - const reco::Track* track = getTrack((*lostCands)[iCand]); - if(track == nullptr) continue; - //Remove signal (tau) tracks - //MB: Only deltaR deltaPt overlap removal possible (?) - //MB: It should be fine as pat objects stores same track info with same presision - bool skipTrack = false; - for(size_t iSigTrk=0 ; iSigTrketa(),SignalTracks[iSigTrk]->phi(), - track->eta(),track->phi())<0.005*0.005 - && std::abs(SignalTracks[iSigTrk]->pt()/track->pt()-1.)<0.005 - ){ - skipTrack = true; - break; - } - } - if(skipTrack) continue; - nonTauTracks.push_back(track); - } + nonTauTracksInPVFromPackedCands(*lostCands,thePVkey,signalTracks,nonTauTracks); } /////////////////////////////////////////////////////////////////////////////////////////////// // Refit the vertex TransientVertex transVtx; std::vector transTracks; - for(size_t iTrk=0 ; iTrkbuild(*(nonTauTracks[iTrk]))); + for(const auto track: nonTauTracks){ + transTracks.push_back(transTrackBuilder->build(*track)); } - bool FitOk(true); + bool fitOK(true); if ( transTracks.size() >= 2 ) { AdaptiveVertexFitter avf; avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception @@ -317,18 +274,50 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev transVtx = avf.vertex(transTracks, *beamSpot); } } catch (...) { - FitOk = false; + fitOK = false; } - } else FitOk = false; - if ( FitOk ) thePV = transVtx; + } else fitOK = false; + if ( fitOK ) thePV = transVtx; + } + VertexRef vtxRef = reco::VertexRef(vertexRefProd_out, vertexCollection_out->size()); + vertexCollection_out->push_back(thePV); + avPFTauPV->setValue(iPFTau, vtxRef); + } + } + iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); + iEvent.put(std::move(avPFTauPV)); +} + +void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const pat::PackedCandidateCollection &cands, + const size_t &thePVkey, + const std::vector &tauTracks, + std::vector &nonTauTracks){ + + //Find candidates/tracks associated to thePVe + for(auto const& cand: cands){ + if(cand.vertexRef().isNull()) continue; + int quality = cand.pvAssociationQuality(); + if(cand.vertexRef().key()!=thePVkey || + (quality!=pat::PackedCandidate::UsedInFitTight && + quality!=pat::PackedCandidate::UsedInFitLoose)) continue; + const reco::Track* track = getTrack(cand); + if(track == nullptr) continue; + //Remove signal (tau) tracks + //MB: Only deltaR deltaPt overlap removal possible (?) + //MB: It should be fine as pat objects stores same track info with same presision + bool skipTrack = false; + for(auto const& tauTrack: tauTracks){ + if(deltaR2(tauTrack->eta(),tauTrack->phi(), + track->eta(),track->phi())<0.005*0.005 + && std::abs(tauTrack->pt()/track->pt()-1.)<0.005 + ){ + skipTrack = true; + break; } - VertexRef VRef = reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()); - VertexCollection_out->push_back(thePV); - AVPFTauPV->setValue(iPFTau, VRef); } + if(skipTrack) continue; + nonTauTracks.push_back(track); } - iEvent.put(std::move(VertexCollection_out),"PFTauPrimaryVertices"); - iEvent.put(std::move(AVPFTauPV)); } -DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); \ No newline at end of file +DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 62971a8e4daa7..bf911eb0ec56a 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -58,7 +58,7 @@ using namespace std; class PFTauPrimaryVertexProducer final : public edm::stream::EDProducer<> { public: - enum Alg{useInputPV=0, useFontPV}; + enum Alg{useInputPV=0, useFrontPV}; struct DiscCutPair{ DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} @@ -75,44 +75,34 @@ class PFTauPrimaryVertexProducer final : public edm::stream::EDProducer<> { void produce(edm::Event&,const edm::EventSetup&) override; private: - edm::InputTag PFTauTag_; - edm::EDGetTokenT >PFTauToken_; - edm::InputTag ElectronTag_; - edm::EDGetTokenT >ElectronToken_; - edm::InputTag MuonTag_; - edm::EDGetTokenT >MuonToken_; - edm::InputTag PVTag_; - edm::EDGetTokenT PVToken_; - edm::InputTag beamSpotTag_; + edm::EDGetTokenT > pftauToken_; + edm::EDGetTokenT > electronToken_; + edm::EDGetTokenT > muonToken_; + edm::EDGetTokenT pvToken_; edm::EDGetTokenT beamSpotToken_; - int Algorithm_; + int algorithm_; edm::ParameterSet qualityCutsPSet_; bool useBeamSpot_; bool useSelectedTaus_; - bool RemoveMuonTracks_; - bool RemoveElectronTracks_; + bool removeMuonTracks_; + bool removeElectronTracks_; DiscCutPairVec discriminators_; std::auto_ptr > cut_; std::auto_ptr vertexAssociator_; }; PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(const edm::ParameterSet& iConfig): - PFTauTag_(iConfig.getParameter("PFTauTag")), - PFTauToken_(consumes >(PFTauTag_)), - ElectronTag_(iConfig.getParameter("ElectronTag")), - ElectronToken_(consumes >(ElectronTag_)), - MuonTag_(iConfig.getParameter("MuonTag")), - MuonToken_(consumes >(MuonTag_)), - PVTag_(iConfig.getParameter("PVTag")), - PVToken_(consumes(PVTag_)), - beamSpotTag_(iConfig.getParameter("beamSpot")), - beamSpotToken_(consumes(beamSpotTag_)), - Algorithm_(iConfig.getParameter("Algorithm")), + pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), + electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), + muonToken_(consumes >(iConfig.getParameter("MuonTag"))), + pvToken_(consumes(iConfig.getParameter("PVTag"))), + beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), + algorithm_(iConfig.getParameter("Algorithm")), qualityCutsPSet_(iConfig.getParameter("qualityCuts")), useBeamSpot_(iConfig.getParameter("useBeamSpot")), useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), - RemoveMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), - RemoveElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) + removeMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), + removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector discriminators =iConfig.getParameter >("discriminators"); @@ -141,25 +131,25 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu edm::ESHandle transTrackBuilder; iSetup.get().get("TransientTrackBuilder",transTrackBuilder); - edm::Handle > Tau; - iEvent.getByToken(PFTauToken_,Tau); + edm::Handle > pfTaus; + iEvent.getByToken(pftauToken_,pfTaus); - edm::Handle > Electron; - iEvent.getByToken(ElectronToken_,Electron); + edm::Handle > electrons; + iEvent.getByToken(electronToken_,electrons); - edm::Handle > Mu; - iEvent.getByToken(MuonToken_,Mu); + edm::Handle > muons; + iEvent.getByToken(muonToken_,muons); - edm::Handle PV; - iEvent.getByToken(PVToken_,PV); + edm::Handle vertices; + iEvent.getByToken(pvToken_,vertices); edm::Handle beamSpot; iEvent.getByToken(beamSpotToken_,beamSpot); // Set Association Map - auto AVPFTauPV = std::make_unique>>(PFTauRefProd(Tau)); - auto VertexCollection_out = std::make_unique(); - reco::VertexRefProd VertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); + auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); + auto vertexCollection_out = std::make_unique(); + reco::VertexRefProd vertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); // Load each discriminator BOOST_FOREACH(DiscCutPair *disc, discriminators_) { @@ -169,19 +159,19 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu } // Set event for VerexAssociator if needed - if(useInputPV==Algorithm_) + if(useInputPV==algorithm_) vertexAssociator_->setEvent(iEvent); // For each Tau Run Algorithim - if(Tau.isValid()){ - for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) { - reco::PFTauRef tau(Tau, iPFTau); + if(pfTaus.isValid()){ + for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { + reco::PFTauRef tau(pfTaus, iPFTau); reco::Vertex thePV; - if(useInputPV==Algorithm_){ + if(useInputPV==algorithm_){ thePV =(*( vertexAssociator_->associatedVertex(*tau))); } - else if(useFontPV==Algorithm_){ - thePV=PV->front(); + else if(useFrontPV==algorithm_){ + thePV=vertices->front(); } /////////////////////// // Check if it passed all the discrimiantors @@ -195,34 +185,31 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ - std::vector SignalTracks; - for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < Tau->size(); jPFTau++) { + std::vector signalTracks; + for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ - reco::PFTauRef RefPFTau(Tau, jPFTau); + reco::PFTauRef pfTauRef(pfTaus, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// // Get tracks from PFTau daughters - for (const auto& pfcand : RefPFTau->signalPFChargedHadrCands()) { - if (pfcand->trackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} - else if (pfcand->gsfTrackRef().isNonnull()) {SignalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} + for(const auto& pfcand : pfTauRef->signalPFChargedHadrCands()) { + if (pfcand->trackRef().isNonnull()) {signalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} + else if (pfcand->gsfTrackRef().isNonnull()) {signalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} } } } // Get Muon tracks - if(RemoveMuonTracks_){ - - if(Mu.isValid()) { - for(reco::MuonCollection::size_type iMuon = 0; iMuon< Mu->size(); iMuon++){ - reco::MuonRef RefMuon(Mu, iMuon); - if(RefMuon->track().isNonnull()) SignalTracks.push_back(reco::TrackBaseRef(RefMuon->track())); + if(removeMuonTracks_){ + if(muons.isValid()) { + for(const auto& muon: *muons){ + if(muon.track().isNonnull()) signalTracks.push_back(reco::TrackBaseRef(muon.track())); } } } // Get Electron Tracks - if(RemoveElectronTracks_){ - if(Electron.isValid()) { - for(reco::ElectronCollection::size_type iElectron = 0; iElectronsize(); iElectron++){ - reco::ElectronRef RefElectron(Electron, iElectron); - if(RefElectron->track().isNonnull()) SignalTracks.push_back(reco::TrackBaseRef(RefElectron->track())); + if(removeElectronTracks_){ + if(electrons.isValid()) { + for(const auto& electron: *electrons){ + if(electron.track().isNonnull()) signalTracks.push_back(reco::TrackBaseRef(electron.track())); } } } @@ -231,21 +218,21 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu reco::TrackCollection nonTauTracks; for(std::vector::const_iterator vtxTrkRef=thePV.tracks_begin();vtxTrkRef transTracks; - for (reco::TrackCollection::iterator iter=nonTauTracks.begin(); iter!=nonTauTracks.end(); ++iter){ - transTracks.push_back(transTrackBuilder->build(*iter)); + for(const auto& track: nonTauTracks){ + transTracks.push_back(transTrackBuilder->build(track)); } - bool FitOk(true); + bool fitOK(true); if ( transTracks.size() >= 2 ) { AdaptiveVertexFitter avf; avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception @@ -256,18 +243,18 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu transVtx = avf.vertex(transTracks, *beamSpot); } } catch (...) { - FitOk = false; + fitOK = false; } - } else FitOk = false; - if ( FitOk ) thePV = transVtx; + } else fitOK = false; + if ( fitOK ) thePV = transVtx; } - VertexRef VRef = reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()); - VertexCollection_out->push_back(thePV); - AVPFTauPV->setValue(iPFTau, VRef); + VertexRef vtxRef = reco::VertexRef(vertexRefProd_out, vertexCollection_out->size()); + vertexCollection_out->push_back(thePV); + avPFTauPV->setValue(iPFTau, vtxRef); } } - iEvent.put(std::move(VertexCollection_out),"PFTauPrimaryVertices"); - iEvent.put(std::move(AVPFTauPV)); + iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); + iEvent.put(std::move(avPFTauPV)); } DEFINE_FWK_MODULE(PFTauPrimaryVertexProducer); From 7902388b08a55354b59d27d6d0b7b7652e2fce35 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 13 Apr 2018 09:34:00 +0200 Subject: [PATCH 045/686] PV produceres, PF and Mini, prepared to unification --- .../PFTauMiniAODPrimaryVertexProducer.cc | 110 ++++++++++-------- .../plugins/PFTauPrimaryVertexProducer.cc | 88 +++++++++----- 2 files changed, 124 insertions(+), 74 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index ee34e9c426532..048b80b9390e5 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -37,6 +37,7 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/Common/interface/RefToPtr.h" #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" #include "DataFormats/PatCandidates/interface/PackedCandidate.h" @@ -47,10 +48,10 @@ #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/Math/interface/deltaR.h" #include #include #include -#include "DataFormats/Math/interface/deltaR.h" #include @@ -77,9 +78,12 @@ class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> void produce(edm::Event&,const edm::EventSetup&) override; private: - void nonTauTracksInPVFromPackedCands(const pat::PackedCandidateCollection&, - const size_t&, - const std::vector&, + void nonTauTracksInPV(const reco::VertexRef&, + const std::vector >&, + std::vector&); + void nonTauTracksInPVFromPackedCands(const size_t&, + const pat::PackedCandidateCollection&, + const std::vector >&, std::vector &); edm::EDGetTokenT > pftauToken_; @@ -88,6 +92,7 @@ class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> edm::EDGetTokenT pvToken_; edm::EDGetTokenT beamSpotToken_; edm::EDGetTokenT packedCandsToken_, lostCandsToken_; + edm::Handle packedCands_, lostCands_; int algorithm_; edm::ParameterSet qualityCutsPSet_; bool useBeamSpot_; @@ -137,11 +142,19 @@ PFTauMiniAODPrimaryVertexProducer::PFTauMiniAODPrimaryVertexProducer(const edm:: PFTauMiniAODPrimaryVertexProducer::~PFTauMiniAODPrimaryVertexProducer(){} namespace { - const reco::Track* getTrack(const reco::Candidate& cand) { + edm::Ptr getTrack(const reco::Candidate& cand) { + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->gsfTrackRef()); + else return edm::Ptr(); + } const pat::PackedCandidate* pCand = dynamic_cast(&cand); - if (pCand && pCand->hasTrackDetails()) - return &pCand->pseudoTrack(); - return nullptr; + if (pCand && pCand->hasTrackDetails()) { + const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); + return edm::Ptr(trkPtr,0); + } + return edm::Ptr(); } } @@ -154,22 +167,20 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev iEvent.getByToken(pftauToken_,pfTaus); edm::Handle > electrons; - iEvent.getByToken(electronToken_,electrons); + if(removeElectronTracks_) iEvent.getByToken(electronToken_,electrons); edm::Handle > muons; - iEvent.getByToken(muonToken_,muons); + if(removeMuonTracks_) iEvent.getByToken(muonToken_,muons); edm::Handle vertices; iEvent.getByToken(pvToken_,vertices); edm::Handle beamSpot; - iEvent.getByToken(beamSpotToken_,beamSpot); + if(useBeamSpot_) iEvent.getByToken(beamSpotToken_,beamSpot); - edm::Handle packedCands; - iEvent.getByToken(packedCandsToken_, packedCands); + iEvent.getByToken(packedCandsToken_, packedCands_); - edm::Handle lostCands; - iEvent.getByToken(lostCandsToken_, lostCands); + iEvent.getByToken(lostCandsToken_, lostCands_); // Set Association Map auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); @@ -191,17 +202,14 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev if(pfTaus.isValid()){ for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { reco::PFTauRef tau(pfTaus, iPFTau); - reco::Vertex thePV; - size_t thePVkey = 0; + reco::VertexRef thePVRef; if(useInputPV==algorithm_){ - reco::VertexRef thePVRef = vertexAssociator_->associatedVertex(*tau); - thePV = *thePVRef; - thePVkey = thePVRef.key(); + thePVRef = vertexAssociator_->associatedVertex(*tau); } else if(useFrontPV==algorithm_){ - thePV=vertices->front(); - thePVkey = 0; + thePVRef = reco::VertexRef(vertices,0); } + reco::Vertex thePV = *thePVRef; /////////////////////// // Check if it passed all the discrimiantors bool passed(true); @@ -214,7 +222,7 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ - std::vector signalTracks; + std::vector > signalTracks; for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ reco::PFTauRef pfTauRef(pfTaus, jPFTau); @@ -222,18 +230,16 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev // Get tracks from PFTau daughters for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { if(pfcand.isNull()) continue; - const reco::Track* track = getTrack(*pfcand); - if(track == nullptr) continue; - signalTracks.push_back(track); + const edm::Ptr& trackPtr = getTrack(*pfcand); + if(trackPtr.isNonnull()) signalTracks.push_back(trackPtr); } } } // Get Muon tracks if(removeMuonTracks_){ - if(muons.isValid()) { for(const auto& muon: *muons){ - if(muon.track().isNonnull()) signalTracks.push_back(muon.track().get()); + if(muon.track().isNonnull()) signalTracks.push_back(edm::refToPtr(muon.track())); } } } @@ -241,21 +247,15 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev if(removeElectronTracks_){ if(electrons.isValid()) { for(const auto& electron: *electrons){ - if(electron.gsfTrack().isNonnull()) signalTracks.push_back(electron.gsfTrack().get()); + if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); } } } /////////////////////////////////////////////////////////////////////////////////////////////// // Get Non-Tau tracks std::vector nonTauTracks; - //PackedCandidates first... - if(packedCands.isValid()) { - nonTauTracksInPVFromPackedCands(*packedCands,thePVkey,signalTracks,nonTauTracks); - } - //then lostCandidates - if(lostCands.isValid()) { - nonTauTracksInPVFromPackedCands(*lostCands,thePVkey,signalTracks,nonTauTracks); - } + nonTauTracksInPV(thePVRef,signalTracks,nonTauTracks); + /////////////////////////////////////////////////////////////////////////////////////////////// // Refit the vertex TransientVertex transVtx; @@ -288,35 +288,49 @@ void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::Ev iEvent.put(std::move(avPFTauPV)); } -void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const pat::PackedCandidateCollection &cands, - const size_t &thePVkey, - const std::vector &tauTracks, +void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRef, + const std::vector > &tauTracks, + std::vector &nonTauTracks){ + + //Find non-tau tracks associated to thePV + //PackedCandidates first... + if(packedCands_.isValid()) { + nonTauTracksInPVFromPackedCands(thePVRef.key(),*packedCands_,tauTracks,nonTauTracks); + } + //then lostCandidates + if(lostCands_.isValid()) { + nonTauTracksInPVFromPackedCands(thePVRef.key(),*lostCands_,tauTracks,nonTauTracks); + } +} + +void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const size_t &thePVkey, + const pat::PackedCandidateCollection &cands, + const std::vector > &tauTracks, std::vector &nonTauTracks){ - //Find candidates/tracks associated to thePVe - for(auto const& cand: cands){ + //Find candidates/tracks associated to thePV + for(const auto& cand: cands){ if(cand.vertexRef().isNull()) continue; int quality = cand.pvAssociationQuality(); if(cand.vertexRef().key()!=thePVkey || (quality!=pat::PackedCandidate::UsedInFitTight && quality!=pat::PackedCandidate::UsedInFitLoose)) continue; - const reco::Track* track = getTrack(cand); + const reco::Track *track = cand.hasTrackDetails() ? &cand.pseudoTrack() : nullptr; if(track == nullptr) continue; //Remove signal (tau) tracks //MB: Only deltaR deltaPt overlap removal possible (?) //MB: It should be fine as pat objects stores same track info with same presision - bool skipTrack = false; - for(auto const& tauTrack: tauTracks){ + bool matched = false; + for(const auto& tauTrack: tauTracks){ if(deltaR2(tauTrack->eta(),tauTrack->phi(), track->eta(),track->phi())<0.005*0.005 && std::abs(tauTrack->pt()/track->pt()-1.)<0.005 ){ - skipTrack = true; + matched = true; break; } } - if(skipTrack) continue; - nonTauTracks.push_back(track); + if( !matched ) nonTauTracks.push_back(track); } } diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index bf911eb0ec56a..f871dc7e6a85f 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -37,8 +37,10 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/Common/interface/RefToPtr.h" #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/Common/interface/Association.h" #include "DataFormats/Common/interface/AssociationVector.h" @@ -46,6 +48,7 @@ #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/Math/interface/deltaR.h" #include #include #include @@ -75,6 +78,10 @@ class PFTauPrimaryVertexProducer final : public edm::stream::EDProducer<> { void produce(edm::Event&,const edm::EventSetup&) override; private: + void nonTauTracksInPV(const reco::VertexRef&, + const std::vector >&, + std::vector&); + edm::EDGetTokenT > pftauToken_; edm::EDGetTokenT > electronToken_; edm::EDGetTokenT > muonToken_; @@ -126,6 +133,23 @@ PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(const edm::ParameterSet& PFTauPrimaryVertexProducer::~PFTauPrimaryVertexProducer(){} +namespace { + edm::Ptr getTrack(const reco::Candidate& cand) { + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->gsfTrackRef()); + else return edm::Ptr(); + } + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if (pCand && pCand->hasTrackDetails()) { + const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); + return edm::Ptr(trkPtr,0); + } + return edm::Ptr(); + } +} + void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ // Obtain Collections edm::ESHandle transTrackBuilder; @@ -135,16 +159,16 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu iEvent.getByToken(pftauToken_,pfTaus); edm::Handle > electrons; - iEvent.getByToken(electronToken_,electrons); + if(removeElectronTracks_) iEvent.getByToken(electronToken_,electrons); edm::Handle > muons; - iEvent.getByToken(muonToken_,muons); + if(removeMuonTracks_) iEvent.getByToken(muonToken_,muons); edm::Handle vertices; iEvent.getByToken(pvToken_,vertices); edm::Handle beamSpot; - iEvent.getByToken(beamSpotToken_,beamSpot); + if(useBeamSpot_) iEvent.getByToken(beamSpotToken_,beamSpot); // Set Association Map auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); @@ -166,13 +190,14 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu if(pfTaus.isValid()){ for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { reco::PFTauRef tau(pfTaus, iPFTau); - reco::Vertex thePV; + reco::VertexRef thePVRef; if(useInputPV==algorithm_){ - thePV =(*( vertexAssociator_->associatedVertex(*tau))); + thePVRef = vertexAssociator_->associatedVertex(*tau); } else if(useFrontPV==algorithm_){ - thePV=vertices->front(); + thePVRef = reco::VertexRef(vertices,0); } + reco::Vertex thePV = *thePVRef; /////////////////////// // Check if it passed all the discrimiantors bool passed(true); @@ -185,23 +210,24 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu } if (passed && cut_.get()){passed = (*cut_)(*tau);} if (passed){ - std::vector signalTracks; + std::vector > signalTracks; for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { if(useSelectedTaus_ || iPFTau==jPFTau){ reco::PFTauRef pfTauRef(pfTaus, jPFTau); /////////////////////////////////////////////////////////////////////////////////////////////// // Get tracks from PFTau daughters - for(const auto& pfcand : pfTauRef->signalPFChargedHadrCands()) { - if (pfcand->trackRef().isNonnull()) {signalTracks.push_back(reco::TrackBaseRef(pfcand->trackRef()));} - else if (pfcand->gsfTrackRef().isNonnull()) {signalTracks.push_back(reco::TrackBaseRef((pfcand->gsfTrackRef())));} + for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { + if(pfcand.isNull()) continue; + const edm::Ptr& trackPtr = getTrack(*pfcand); + if(trackPtr.isNonnull()) signalTracks.push_back(trackPtr); } } } // Get Muon tracks if(removeMuonTracks_){ if(muons.isValid()) { - for(const auto& muon: *muons){ - if(muon.track().isNonnull()) signalTracks.push_back(reco::TrackBaseRef(muon.track())); + for(const auto& muon: *muons){ + if(muon.track().isNonnull()) signalTracks.push_back(edm::refToPtr(muon.track())); } } } @@ -209,28 +235,21 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu if(removeElectronTracks_){ if(electrons.isValid()) { for(const auto& electron: *electrons){ - if(electron.track().isNonnull()) signalTracks.push_back(reco::TrackBaseRef(electron.track())); + if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); } } } /////////////////////////////////////////////////////////////////////////////////////////////// // Get Non-Tau tracks - reco::TrackCollection nonTauTracks; - for(std::vector::const_iterator vtxTrkRef=thePV.tracks_begin();vtxTrkRef nonTauTracks; + nonTauTracksInPV(thePVRef,signalTracks,nonTauTracks); + /////////////////////////////////////////////////////////////////////////////////////////////// // Refit the vertex TransientVertex transVtx; std::vector transTracks; - for(const auto& track: nonTauTracks){ - transTracks.push_back(transTrackBuilder->build(track)); + for(const auto track: nonTauTracks){ + transTracks.push_back(transTrackBuilder->build(*track)); } bool fitOK(true); if ( transTracks.size() >= 2 ) { @@ -256,5 +275,22 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); iEvent.put(std::move(avPFTauPV)); } - + +void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRef, + const std::vector > &tauTracks, + std::vector &nonTauTracks){ + + //Find non-tau tracks associated to thePV + for(reco::Vertex::trackRef_iterator vtxTrkRef=thePVRef->tracks_begin();vtxTrkRef!=thePVRef->tracks_end();vtxTrkRef++){ + bool matched = false; + edm::Ptr vtxTrkPtr = edm::refToPtr((*vtxTrkRef).castTo > >()); + for(const auto& tauTrack: tauTracks){ + if( vtxTrkPtr == tauTrack ) { + matched = true; + } + } + if( !matched ) nonTauTracks.push_back((*vtxTrkRef).get()); + } +} + DEFINE_FWK_MODULE(PFTauPrimaryVertexProducer); From 83313a121a789351c13f291c18e759f61301c3f1 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 13 Apr 2018 17:04:55 +0200 Subject: [PATCH 046/686] Unify PVProducers on top of common Base --- .../PFTauPrimaryVertexProducerBase.h | 105 +++++++ .../PFTauMiniAODPrimaryVertexProducer.cc | 279 +----------------- .../plugins/PFTauPrimaryVertexProducer.cc | 272 +---------------- .../src/PFTauPrimaryVertexProducerBase.cc | 183 ++++++++++++ 4 files changed, 311 insertions(+), 528 deletions(-) create mode 100644 RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h create mode 100644 RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc diff --git a/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h new file mode 100644 index 0000000000000..59e465f62f146 --- /dev/null +++ b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h @@ -0,0 +1,105 @@ +#ifndef RecoTauTag_RecoTau_PFTauPrimaryVertexProducerBase_H_ +#define RecoTauTag_RecoTau_PFTauPrimaryVertexProducerBase_H_ + +/* class PFTauPrimaryVertexProducerBase + * EDProducer of the + * authors: Ian M. Nugent + * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus. + * The idea of the fully reconstructing the tau using a kinematic fit comes from + * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This + * work was continued by Ian M. Nugent and Vladimir Cherepanov. + * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions. + */ + + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" +#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" +#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" + +#include "DataFormats/TauReco/interface/PFTau.h" +#include "DataFormats/TauReco/interface/PFTauFwd.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" +#include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/Common/interface/RefToPtr.h" +#include "DataFormats/EgammaCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Common/interface/AssociationVector.h" +#include "DataFormats/Common/interface/RefProd.h" + +#include "DataFormats/TauReco/interface/PFTauDiscriminator.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/Math/interface/deltaR.h" +#include +#include +#include + +#include + +class PFTauPrimaryVertexProducerBase : public edm::stream::EDProducer<> { + public: + enum Alg{useInputPV=0, useFrontPV}; + + struct DiscCutPair{ + DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} + ~DiscCutPair(){delete cutFormula_;} + const reco::PFTauDiscriminator* discr_; + edm::EDGetTokenT inputToken_; + double cut_; + TFormula* cutFormula_; + }; + typedef std::vector DiscCutPairVec; + + explicit PFTauPrimaryVertexProducerBase(const edm::ParameterSet& iConfig); + ~PFTauPrimaryVertexProducerBase() override; + void produce(edm::Event&,const edm::EventSetup&) override; + + // called at the beginning of every event - override if necessary + virtual void beginEvent(const edm::Event&, const edm::EventSetup&) {} + + protected: + // abstract function implemented in derived classes + virtual void nonTauTracksInPV(const reco::VertexRef&, + const std::vector >&, + std::vector&) = 0; + + private: + edm::EDGetTokenT > pftauToken_; + edm::EDGetTokenT > electronToken_; + edm::EDGetTokenT > muonToken_; + edm::EDGetTokenT pvToken_; + edm::EDGetTokenT beamSpotToken_; + int algorithm_; + edm::ParameterSet qualityCutsPSet_; + bool useBeamSpot_; + bool useSelectedTaus_; + bool removeMuonTracks_; + bool removeElectronTracks_; + DiscCutPairVec discriminators_; + std::auto_ptr > cut_; + std::auto_ptr vertexAssociator_; +}; + +#endif diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index 048b80b9390e5..45d01fea40505 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -1,291 +1,42 @@ -/* class PFTauMiniAODPrimaryVertexProducer - * EDProducer of the - * authors: Ian M. Nugent - * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus. - * The idea of the fully reconstructing the tau using a kinematic fit comes from - * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This - * work was continued by Ian M. Nugent and Vladimir Cherepanov. - * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions. - */ +#include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" +/// MiniAOD implementation of the PFTauPrimaryVertexProducer plugin +class PFTauMiniAODPrimaryVertexProducer final : public PFTauPrimaryVertexProducerBase { -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" -#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" -#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" - -#include "DataFormats/TauReco/interface/PFTau.h" -#include "DataFormats/TauReco/interface/PFTauFwd.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/MuonReco/interface/Muon.h" -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" -#include "DataFormats/Common/interface/RefToBase.h" -#include "DataFormats/Common/interface/RefToPtr.h" -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" - -#include "DataFormats/Common/interface/Association.h" -#include "DataFormats/Common/interface/AssociationVector.h" -#include "DataFormats/Common/interface/RefProd.h" - -#include "DataFormats/TauReco/interface/PFTauDiscriminator.h" -#include "CommonTools/Utils/interface/StringCutObjectSelector.h" -#include "DataFormats/Math/interface/deltaR.h" -#include -#include -#include - -#include - -using namespace reco; -using namespace edm; -using namespace std; - -class PFTauMiniAODPrimaryVertexProducer final : public edm::stream::EDProducer<> { public: - enum Alg{useInputPV=0, useFrontPV}; - - struct DiscCutPair{ - DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} - ~DiscCutPair(){delete cutFormula_;} - const reco::PFTauDiscriminator* discr_; - edm::EDGetTokenT inputToken_; - double cut_; - TFormula* cutFormula_; - }; - typedef std::vector DiscCutPairVec; - explicit PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet& iConfig); ~PFTauMiniAODPrimaryVertexProducer() override; - void produce(edm::Event&,const edm::EventSetup&) override; - private: + void beginEvent(const edm::Event&, const edm::EventSetup&) override; + + protected: void nonTauTracksInPV(const reco::VertexRef&, const std::vector >&, - std::vector&); + std::vector&) override; + + private: void nonTauTracksInPVFromPackedCands(const size_t&, const pat::PackedCandidateCollection&, const std::vector >&, std::vector &); - edm::EDGetTokenT > pftauToken_; - edm::EDGetTokenT > electronToken_; - edm::EDGetTokenT > muonToken_; - edm::EDGetTokenT pvToken_; - edm::EDGetTokenT beamSpotToken_; edm::EDGetTokenT packedCandsToken_, lostCandsToken_; edm::Handle packedCands_, lostCands_; - int algorithm_; - edm::ParameterSet qualityCutsPSet_; - bool useBeamSpot_; - bool useSelectedTaus_; - bool removeMuonTracks_; - bool removeElectronTracks_; - DiscCutPairVec discriminators_; - std::auto_ptr > cut_; - std::auto_ptr vertexAssociator_; + }; PFTauMiniAODPrimaryVertexProducer::PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet& iConfig): - pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), - electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), - muonToken_(consumes >(iConfig.getParameter("MuonTag"))), - pvToken_(consumes(iConfig.getParameter("PVTag"))), - beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), + PFTauPrimaryVertexProducerBase::PFTauPrimaryVertexProducerBase(iConfig), packedCandsToken_(consumes(iConfig.getParameter("packedCandidatesTag"))), - lostCandsToken_(consumes(iConfig.getParameter("lostCandidatesTag"))), - algorithm_(iConfig.getParameter("Algorithm")), - qualityCutsPSet_(iConfig.getParameter("qualityCuts")), - useBeamSpot_(iConfig.getParameter("useBeamSpot")), - useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), - removeMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), - removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) -{ - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector discriminators =iConfig.getParameter >("discriminators"); - // Build each of our cuts - BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) { - DiscCutPair* newCut = new DiscCutPair(); - newCut->inputToken_ =consumes(pset.getParameter("discriminator")); - - if ( pset.existsAs("selectionCut") ) newCut->cutFormula_ = new TFormula("selectionCut", pset.getParameter("selectionCut").data()); - else newCut->cut_ = pset.getParameter("selectionCut"); - discriminators_.push_back(newCut); - } - // Build a string cut if desired - if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - produces > >(); - produces("PFTauPrimaryVertices"); - - vertexAssociator_.reset(new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); -} + lostCandsToken_(consumes(iConfig.getParameter("lostCandidatesTag"))) {} PFTauMiniAODPrimaryVertexProducer::~PFTauMiniAODPrimaryVertexProducer(){} -namespace { - edm::Ptr getTrack(const reco::Candidate& cand) { - const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); - if (pfCandPtr) { - if ( pfCandPtr->trackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->trackRef()); - else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->gsfTrackRef()); - else return edm::Ptr(); - } - const pat::PackedCandidate* pCand = dynamic_cast(&cand); - if (pCand && pCand->hasTrackDetails()) { - const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); - return edm::Ptr(trkPtr,0); - } - return edm::Ptr(); - } -} - -void PFTauMiniAODPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ - // Obtain Collections - edm::ESHandle transTrackBuilder; - iSetup.get().get("TransientTrackBuilder",transTrackBuilder); - - edm::Handle > pfTaus; - iEvent.getByToken(pftauToken_,pfTaus); - - edm::Handle > electrons; - if(removeElectronTracks_) iEvent.getByToken(electronToken_,electrons); - - edm::Handle > muons; - if(removeMuonTracks_) iEvent.getByToken(muonToken_,muons); - - edm::Handle vertices; - iEvent.getByToken(pvToken_,vertices); - - edm::Handle beamSpot; - if(useBeamSpot_) iEvent.getByToken(beamSpotToken_,beamSpot); +void PFTauMiniAODPrimaryVertexProducer::beginEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup){ + //Get candidate collections iEvent.getByToken(packedCandsToken_, packedCands_); - iEvent.getByToken(lostCandsToken_, lostCands_); - - // Set Association Map - auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); - auto vertexCollection_out = std::make_unique(); - reco::VertexRefProd vertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); - - // Load each discriminator - BOOST_FOREACH(DiscCutPair *disc, discriminators_) { - edm::Handle discr; - iEvent.getByToken(disc->inputToken_, discr); - disc->discr_ = &(*discr); - } - - // Set event for VerexAssociator if needed - if(useInputPV==algorithm_) - vertexAssociator_->setEvent(iEvent); - - // For each Tau Run Algorithim - if(pfTaus.isValid()){ - for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { - reco::PFTauRef tau(pfTaus, iPFTau); - reco::VertexRef thePVRef; - if(useInputPV==algorithm_){ - thePVRef = vertexAssociator_->associatedVertex(*tau); - } - else if(useFrontPV==algorithm_){ - thePVRef = reco::VertexRef(vertices,0); - } - reco::Vertex thePV = *thePVRef; - /////////////////////// - // Check if it passed all the discrimiantors - bool passed(true); - BOOST_FOREACH(const DiscCutPair* disc, discriminators_) { - // Check this discriminator passes - bool passedDisc = true; - if ( disc->cutFormula_ )passedDisc = (disc->cutFormula_->Eval((*disc->discr_)[tau]) > 0.5); - else passedDisc = ((*disc->discr_)[tau] > disc->cut_); - if ( !passedDisc ){passed = false; break;} - } - if (passed && cut_.get()){passed = (*cut_)(*tau);} - if (passed){ - std::vector > signalTracks; - for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { - if(useSelectedTaus_ || iPFTau==jPFTau){ - reco::PFTauRef pfTauRef(pfTaus, jPFTau); - /////////////////////////////////////////////////////////////////////////////////////////////// - // Get tracks from PFTau daughters - for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { - if(pfcand.isNull()) continue; - const edm::Ptr& trackPtr = getTrack(*pfcand); - if(trackPtr.isNonnull()) signalTracks.push_back(trackPtr); - } - } - } - // Get Muon tracks - if(removeMuonTracks_){ - if(muons.isValid()) { - for(const auto& muon: *muons){ - if(muon.track().isNonnull()) signalTracks.push_back(edm::refToPtr(muon.track())); - } - } - } - // Get Electron Tracks - if(removeElectronTracks_){ - if(electrons.isValid()) { - for(const auto& electron: *electrons){ - if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); - } - } - } - /////////////////////////////////////////////////////////////////////////////////////////////// - // Get Non-Tau tracks - std::vector nonTauTracks; - nonTauTracksInPV(thePVRef,signalTracks,nonTauTracks); - - /////////////////////////////////////////////////////////////////////////////////////////////// - // Refit the vertex - TransientVertex transVtx; - std::vector transTracks; - for(const auto track: nonTauTracks){ - transTracks.push_back(transTrackBuilder->build(*track)); - } - bool fitOK(true); - if ( transTracks.size() >= 2 ) { - AdaptiveVertexFitter avf; - avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception - try { - if ( !useBeamSpot_ ){ - transVtx = avf.vertex(transTracks); - } else { - transVtx = avf.vertex(transTracks, *beamSpot); - } - } catch (...) { - fitOK = false; - } - } else fitOK = false; - if ( fitOK ) thePV = transVtx; - } - VertexRef vtxRef = reco::VertexRef(vertexRefProd_out, vertexCollection_out->size()); - vertexCollection_out->push_back(thePV); - avPFTauPV->setValue(iPFTau, vtxRef); - } - } - iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); - iEvent.put(std::move(avPFTauPV)); } void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRef, @@ -333,5 +84,5 @@ void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const si if( !matched ) nonTauTracks.push_back(track); } } - + DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index f871dc7e6a85f..b352cfb883d16 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -1,281 +1,24 @@ -/* class PFTauPrimaryVertexProducer - * EDProducer of the - * authors: Ian M. Nugent - * This work is based on the impact parameter work by Rosamaria Venditti and reconstructing the 3 prong taus. - * The idea of the fully reconstructing the tau using a kinematic fit comes from - * Lars Perchalla and Philip Sauerland Theses under Achim Stahl supervision. This - * work was continued by Ian M. Nugent and Vladimir Cherepanov. - * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions. - */ +#include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" +/// RECO/AOD implementation of the PFTauPrimaryVertexProducer plugin +class PFTauPrimaryVertexProducer final : public PFTauPrimaryVertexProducerBase { -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" -#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" -#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" - -#include "DataFormats/TauReco/interface/PFTau.h" -#include "DataFormats/TauReco/interface/PFTauFwd.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/MuonReco/interface/Muon.h" -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" -#include "DataFormats/Common/interface/RefToBase.h" -#include "DataFormats/Common/interface/RefToPtr.h" -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" - -#include "DataFormats/Common/interface/Association.h" -#include "DataFormats/Common/interface/AssociationVector.h" -#include "DataFormats/Common/interface/RefProd.h" - -#include "DataFormats/TauReco/interface/PFTauDiscriminator.h" -#include "CommonTools/Utils/interface/StringCutObjectSelector.h" -#include "DataFormats/Math/interface/deltaR.h" -#include -#include -#include - -#include - -using namespace reco; -using namespace edm; -using namespace std; - -class PFTauPrimaryVertexProducer final : public edm::stream::EDProducer<> { public: - enum Alg{useInputPV=0, useFrontPV}; - - struct DiscCutPair{ - DiscCutPair():discr_(nullptr),cutFormula_(nullptr){} - ~DiscCutPair(){delete cutFormula_;} - const reco::PFTauDiscriminator* discr_; - edm::EDGetTokenT inputToken_; - double cut_; - TFormula* cutFormula_; - }; - typedef std::vector DiscCutPairVec; - explicit PFTauPrimaryVertexProducer(const edm::ParameterSet& iConfig); ~PFTauPrimaryVertexProducer() override; - void produce(edm::Event&,const edm::EventSetup&) override; - private: + protected: void nonTauTracksInPV(const reco::VertexRef&, const std::vector >&, - std::vector&); + std::vector&) override; - edm::EDGetTokenT > pftauToken_; - edm::EDGetTokenT > electronToken_; - edm::EDGetTokenT > muonToken_; - edm::EDGetTokenT pvToken_; - edm::EDGetTokenT beamSpotToken_; - int algorithm_; - edm::ParameterSet qualityCutsPSet_; - bool useBeamSpot_; - bool useSelectedTaus_; - bool removeMuonTracks_; - bool removeElectronTracks_; - DiscCutPairVec discriminators_; - std::auto_ptr > cut_; - std::auto_ptr vertexAssociator_; }; -PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(const edm::ParameterSet& iConfig): - pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), - electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), - muonToken_(consumes >(iConfig.getParameter("MuonTag"))), - pvToken_(consumes(iConfig.getParameter("PVTag"))), - beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), - algorithm_(iConfig.getParameter("Algorithm")), - qualityCutsPSet_(iConfig.getParameter("qualityCuts")), - useBeamSpot_(iConfig.getParameter("useBeamSpot")), - useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), - removeMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), - removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) -{ - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector discriminators =iConfig.getParameter >("discriminators"); - // Build each of our cuts - BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) { - DiscCutPair* newCut = new DiscCutPair(); - newCut->inputToken_ =consumes(pset.getParameter("discriminator")); - - if ( pset.existsAs("selectionCut") ) newCut->cutFormula_ = new TFormula("selectionCut", pset.getParameter("selectionCut").data()); - else newCut->cut_ = pset.getParameter("selectionCut"); - discriminators_.push_back(newCut); - } - // Build a string cut if desired - if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - produces > >(); - produces("PFTauPrimaryVertices"); - - vertexAssociator_.reset(new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); -} +PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(const edm::ParameterSet& iConfig): + PFTauPrimaryVertexProducerBase::PFTauPrimaryVertexProducerBase(iConfig) {} PFTauPrimaryVertexProducer::~PFTauPrimaryVertexProducer(){} -namespace { - edm::Ptr getTrack(const reco::Candidate& cand) { - const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); - if (pfCandPtr) { - if ( pfCandPtr->trackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->trackRef()); - else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->gsfTrackRef()); - else return edm::Ptr(); - } - const pat::PackedCandidate* pCand = dynamic_cast(&cand); - if (pCand && pCand->hasTrackDetails()) { - const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); - return edm::Ptr(trkPtr,0); - } - return edm::Ptr(); - } -} - -void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ - // Obtain Collections - edm::ESHandle transTrackBuilder; - iSetup.get().get("TransientTrackBuilder",transTrackBuilder); - - edm::Handle > pfTaus; - iEvent.getByToken(pftauToken_,pfTaus); - - edm::Handle > electrons; - if(removeElectronTracks_) iEvent.getByToken(electronToken_,electrons); - - edm::Handle > muons; - if(removeMuonTracks_) iEvent.getByToken(muonToken_,muons); - - edm::Handle vertices; - iEvent.getByToken(pvToken_,vertices); - - edm::Handle beamSpot; - if(useBeamSpot_) iEvent.getByToken(beamSpotToken_,beamSpot); - - // Set Association Map - auto avPFTauPV = std::make_unique>>(PFTauRefProd(pfTaus)); - auto vertexCollection_out = std::make_unique(); - reco::VertexRefProd vertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); - - // Load each discriminator - BOOST_FOREACH(DiscCutPair *disc, discriminators_) { - edm::Handle discr; - iEvent.getByToken(disc->inputToken_, discr); - disc->discr_ = &(*discr); - } - - // Set event for VerexAssociator if needed - if(useInputPV==algorithm_) - vertexAssociator_->setEvent(iEvent); - - // For each Tau Run Algorithim - if(pfTaus.isValid()){ - for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { - reco::PFTauRef tau(pfTaus, iPFTau); - reco::VertexRef thePVRef; - if(useInputPV==algorithm_){ - thePVRef = vertexAssociator_->associatedVertex(*tau); - } - else if(useFrontPV==algorithm_){ - thePVRef = reco::VertexRef(vertices,0); - } - reco::Vertex thePV = *thePVRef; - /////////////////////// - // Check if it passed all the discrimiantors - bool passed(true); - BOOST_FOREACH(const DiscCutPair* disc, discriminators_) { - // Check this discriminator passes - bool passedDisc = true; - if ( disc->cutFormula_ )passedDisc = (disc->cutFormula_->Eval((*disc->discr_)[tau]) > 0.5); - else passedDisc = ((*disc->discr_)[tau] > disc->cut_); - if ( !passedDisc ){passed = false; break;} - } - if (passed && cut_.get()){passed = (*cut_)(*tau);} - if (passed){ - std::vector > signalTracks; - for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { - if(useSelectedTaus_ || iPFTau==jPFTau){ - reco::PFTauRef pfTauRef(pfTaus, jPFTau); - /////////////////////////////////////////////////////////////////////////////////////////////// - // Get tracks from PFTau daughters - for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { - if(pfcand.isNull()) continue; - const edm::Ptr& trackPtr = getTrack(*pfcand); - if(trackPtr.isNonnull()) signalTracks.push_back(trackPtr); - } - } - } - // Get Muon tracks - if(removeMuonTracks_){ - if(muons.isValid()) { - for(const auto& muon: *muons){ - if(muon.track().isNonnull()) signalTracks.push_back(edm::refToPtr(muon.track())); - } - } - } - // Get Electron Tracks - if(removeElectronTracks_){ - if(electrons.isValid()) { - for(const auto& electron: *electrons){ - if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); - } - } - } - /////////////////////////////////////////////////////////////////////////////////////////////// - // Get Non-Tau tracks - std::vector nonTauTracks; - nonTauTracksInPV(thePVRef,signalTracks,nonTauTracks); - - /////////////////////////////////////////////////////////////////////////////////////////////// - // Refit the vertex - TransientVertex transVtx; - std::vector transTracks; - for(const auto track: nonTauTracks){ - transTracks.push_back(transTrackBuilder->build(*track)); - } - bool fitOK(true); - if ( transTracks.size() >= 2 ) { - AdaptiveVertexFitter avf; - avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception - try { - if ( !useBeamSpot_ ){ - transVtx = avf.vertex(transTracks); - } else { - transVtx = avf.vertex(transTracks, *beamSpot); - } - } catch (...) { - fitOK = false; - } - } else fitOK = false; - if ( fitOK ) thePV = transVtx; - } - VertexRef vtxRef = reco::VertexRef(vertexRefProd_out, vertexCollection_out->size()); - vertexCollection_out->push_back(thePV); - avPFTauPV->setValue(iPFTau, vtxRef); - } - } - iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); - iEvent.put(std::move(avPFTauPV)); -} - void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRef, const std::vector > &tauTracks, std::vector &nonTauTracks){ @@ -287,6 +30,7 @@ void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRe for(const auto& tauTrack: tauTracks){ if( vtxTrkPtr == tauTrack ) { matched = true; + break; } } if( !matched ) nonTauTracks.push_back((*vtxTrkRef).get()); diff --git a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc new file mode 100644 index 0000000000000..0ca1932c6d0f9 --- /dev/null +++ b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc @@ -0,0 +1,183 @@ +#include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" + +PFTauPrimaryVertexProducerBase::PFTauPrimaryVertexProducerBase(const edm::ParameterSet& iConfig): + pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), + electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), + muonToken_(consumes >(iConfig.getParameter("MuonTag"))), + pvToken_(consumes(iConfig.getParameter("PVTag"))), + beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), + algorithm_(iConfig.getParameter("Algorithm")), + qualityCutsPSet_(iConfig.getParameter("qualityCuts")), + useBeamSpot_(iConfig.getParameter("useBeamSpot")), + useSelectedTaus_(iConfig.getParameter("useSelectedTaus")), + removeMuonTracks_(iConfig.getParameter("RemoveMuonTracks")), + removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) +{ + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + std::vector discriminators =iConfig.getParameter >("discriminators"); + // Build each of our cuts + BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) { + DiscCutPair* newCut = new DiscCutPair(); + newCut->inputToken_ =consumes(pset.getParameter("discriminator")); + + if ( pset.existsAs("selectionCut") ) newCut->cutFormula_ = new TFormula("selectionCut", pset.getParameter("selectionCut").data()); + else newCut->cut_ = pset.getParameter("selectionCut"); + discriminators_.push_back(newCut); + } + // Build a string cut if desired + if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + produces > >(); + produces("PFTauPrimaryVertices"); + + vertexAssociator_.reset(new reco::tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); +} + +PFTauPrimaryVertexProducerBase::~PFTauPrimaryVertexProducerBase(){} + +namespace { + edm::Ptr getTrack(const reco::Candidate& cand) { + const reco::PFCandidate* pfCandPtr = dynamic_cast(&cand); + if (pfCandPtr) { + if ( pfCandPtr->trackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->trackRef()); + else if ( pfCandPtr->gsfTrackRef().isNonnull() ) return edm::refToPtr(pfCandPtr->gsfTrackRef()); + else return edm::Ptr(); + } + const pat::PackedCandidate* pCand = dynamic_cast(&cand); + if (pCand && pCand->hasTrackDetails()) { + const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); + return edm::Ptr(trkPtr,0); + } + return edm::Ptr(); + } +} + +void PFTauPrimaryVertexProducerBase::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){ + + beginEvent(iEvent, iSetup); + + // Obtain Collections + edm::ESHandle transTrackBuilder; + iSetup.get().get("TransientTrackBuilder",transTrackBuilder); + + edm::Handle > pfTaus; + iEvent.getByToken(pftauToken_,pfTaus); + + edm::Handle > electrons; + if(removeElectronTracks_) iEvent.getByToken(electronToken_,electrons); + + edm::Handle > muons; + if(removeMuonTracks_) iEvent.getByToken(muonToken_,muons); + + edm::Handle vertices; + iEvent.getByToken(pvToken_,vertices); + + edm::Handle beamSpot; + if(useBeamSpot_) iEvent.getByToken(beamSpotToken_,beamSpot); + + // Set Association Map + auto avPFTauPV = std::make_unique>>(reco::PFTauRefProd(pfTaus)); + auto vertexCollection_out = std::make_unique(); + reco::VertexRefProd vertexRefProd_out = iEvent.getRefBeforePut("PFTauPrimaryVertices"); + + // Load each discriminator + BOOST_FOREACH(DiscCutPair *disc, discriminators_) { + edm::Handle discr; + iEvent.getByToken(disc->inputToken_, discr); + disc->discr_ = &(*discr); + } + + // Set event for VerexAssociator if needed + if(useInputPV==algorithm_) + vertexAssociator_->setEvent(iEvent); + + // For each Tau Run Algorithim + if(pfTaus.isValid()){ + for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) { + reco::PFTauRef tau(pfTaus, iPFTau); + reco::VertexRef thePVRef; + if(useInputPV==algorithm_){ + thePVRef = vertexAssociator_->associatedVertex(*tau); + } + else if(useFrontPV==algorithm_){ + thePVRef = reco::VertexRef(vertices,0); + } + reco::Vertex thePV = *thePVRef; + /////////////////////// + // Check if it passed all the discrimiantors + bool passed(true); + BOOST_FOREACH(const DiscCutPair* disc, discriminators_) { + // Check this discriminator passes + bool passedDisc = true; + if ( disc->cutFormula_ )passedDisc = (disc->cutFormula_->Eval((*disc->discr_)[tau]) > 0.5); + else passedDisc = ((*disc->discr_)[tau] > disc->cut_); + if ( !passedDisc ){passed = false; break;} + } + if (passed && cut_.get()){passed = (*cut_)(*tau);} + if (passed){ + std::vector > signalTracks; + for(reco::PFTauCollection::size_type jPFTau = 0; jPFTau < pfTaus->size(); jPFTau++) { + if(useSelectedTaus_ || iPFTau==jPFTau){ + reco::PFTauRef pfTauRef(pfTaus, jPFTau); + /////////////////////////////////////////////////////////////////////////////////////////////// + // Get tracks from PFTau daughters + for(const auto& pfcand : pfTauRef->signalChargedHadrCands()) { + if(pfcand.isNull()) continue; + const edm::Ptr& trackPtr = getTrack(*pfcand); + if(trackPtr.isNonnull()) signalTracks.push_back(trackPtr); + } + } + } + // Get Muon tracks + if(removeMuonTracks_){ + if(muons.isValid()) { + for(const auto& muon: *muons){ + if(muon.track().isNonnull()) signalTracks.push_back(edm::refToPtr(muon.track())); + } + } + } + // Get Electron Tracks + if(removeElectronTracks_){ + if(electrons.isValid()) { + for(const auto& electron: *electrons){ + if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); + } + } + } + /////////////////////////////////////////////////////////////////////////////////////////////// + // Get Non-Tau tracks + std::vector nonTauTracks; + nonTauTracksInPV(thePVRef,signalTracks,nonTauTracks); + + /////////////////////////////////////////////////////////////////////////////////////////////// + // Refit the vertex + TransientVertex transVtx; + std::vector transTracks; + for(const auto track: nonTauTracks){ + transTracks.push_back(transTrackBuilder->build(*track)); + } + bool fitOK(true); + if ( transTracks.size() >= 2 ) { + AdaptiveVertexFitter avf; + avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception + try { + if ( !useBeamSpot_ ){ + transVtx = avf.vertex(transTracks); + } else { + transVtx = avf.vertex(transTracks, *beamSpot); + } + } catch (...) { + fitOK = false; + } + } else fitOK = false; + if ( fitOK ) thePV = transVtx; + } + reco::VertexRef vtxRef = reco::VertexRef(vertexRefProd_out, vertexCollection_out->size()); + vertexCollection_out->push_back(thePV); + avPFTauPV->setValue(iPFTau, vtxRef); + } + } + iEvent.put(std::move(vertexCollection_out),"PFTauPrimaryVertices"); + iEvent.put(std::move(avPFTauPV)); +} + From 126c0009cdd403a6bdbd1debe56c1122e4c55d76 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 13 Apr 2018 17:45:03 +0200 Subject: [PATCH 047/686] check both tracks and gsf-tracks in case of electrons --- RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc index 0ca1932c6d0f9..601347a601edf 100644 --- a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc +++ b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc @@ -141,6 +141,7 @@ void PFTauPrimaryVertexProducerBase::produce(edm::Event& iEvent,const edm::Event if(electrons.isValid()) { for(const auto& electron: *electrons){ if(electron.track().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.track())); + if(electron.gsfTrack().isNonnull()) signalTracks.push_back(edm::refToPtr(electron.gsfTrack())); } } } From 962fe3557fd6ee1ee7a3adf40182bb086eadefac Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 16 Apr 2018 11:01:28 +0200 Subject: [PATCH 048/686] Rationalize includes and implementation of other Jan's comments --- .../PFTauPrimaryVertexProducerBase.h | 33 +++---------------- .../PFTauMiniAODPrimaryVertexProducer.cc | 9 +++-- .../plugins/PFTauPrimaryVertexProducer.cc | 2 ++ .../src/PFTauPrimaryVertexProducerBase.cc | 22 +++++++++++-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h index 59e465f62f146..9a41d805201a2 100644 --- a/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h +++ b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h @@ -11,52 +11,29 @@ * Thanks goes to Christian Veelken and Evan Klose Friis for their help and suggestions. */ - #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" -#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" -#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" -#include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/EgammaCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" -#include "DataFormats/Common/interface/RefToBase.h" -#include "DataFormats/Common/interface/RefToPtr.h" -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" - -#include "DataFormats/Common/interface/Association.h" -#include "DataFormats/Common/interface/AssociationVector.h" -#include "DataFormats/Common/interface/RefProd.h" #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" -#include "DataFormats/Math/interface/deltaR.h" -#include -#include -#include +#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" -#include +#include class PFTauPrimaryVertexProducerBase : public edm::stream::EDProducer<> { public: diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index 45d01fea40505..cf36d45d724e1 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -1,4 +1,7 @@ #include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/Math/interface/deltaR.h" /// MiniAOD implementation of the PFTauPrimaryVertexProducer plugin class PFTauMiniAODPrimaryVertexProducer final : public PFTauPrimaryVertexProducerBase { @@ -66,15 +69,15 @@ void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const si if(cand.vertexRef().key()!=thePVkey || (quality!=pat::PackedCandidate::UsedInFitTight && quality!=pat::PackedCandidate::UsedInFitLoose)) continue; - const reco::Track *track = cand.hasTrackDetails() ? &cand.pseudoTrack() : nullptr; + const reco::Track *track = cand.bestTrack(); if(track == nullptr) continue; //Remove signal (tau) tracks //MB: Only deltaR deltaPt overlap removal possible (?) //MB: It should be fine as pat objects stores same track info with same presision bool matched = false; for(const auto& tauTrack: tauTracks){ - if(deltaR2(tauTrack->eta(),tauTrack->phi(), - track->eta(),track->phi())<0.005*0.005 + if(std::abs(tauTrack->eta()-track->eta())<0.005 + && deltaPhi(tauTrack->phi(),track->phi())<0.005 && std::abs(tauTrack->pt()/track->pt()-1.)<0.005 ){ matched = true; diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index b352cfb883d16..ec5321a632b76 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -1,4 +1,6 @@ #include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "DataFormats/Common/interface/RefToPtr.h" /// RECO/AOD implementation of the PFTauPrimaryVertexProducer plugin class PFTauPrimaryVertexProducer final : public PFTauPrimaryVertexProducerBase { diff --git a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc index 601347a601edf..591d74aa2e9a7 100644 --- a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc +++ b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc @@ -1,5 +1,23 @@ #include "RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" +#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" + +#include "DataFormats/Common/interface/AssociationVector.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/Common/interface/RefToPtr.h" + +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +#include +#include + PFTauPrimaryVertexProducerBase::PFTauPrimaryVertexProducerBase(const edm::ParameterSet& iConfig): pftauToken_(consumes >(iConfig.getParameter("PFTauTag"))), electronToken_(consumes >(iConfig.getParameter("ElectronTag"))), @@ -14,7 +32,7 @@ PFTauPrimaryVertexProducerBase::PFTauPrimaryVertexProducerBase(const edm::Parame removeElectronTracks_(iConfig.getParameter("RemoveElectronTracks")) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::vector discriminators =iConfig.getParameter >("discriminators"); + std::vector discriminators = iConfig.getParameter >("discriminators"); // Build each of our cuts BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) { DiscCutPair* newCut = new DiscCutPair(); @@ -45,7 +63,7 @@ namespace { } const pat::PackedCandidate* pCand = dynamic_cast(&cand); if (pCand && pCand->hasTrackDetails()) { - const reco::TrackBase* trkPtr = &pCand->pseudoTrack(); + const reco::TrackBase* trkPtr = pCand->bestTrack(); return edm::Ptr(trkPtr,0); } return edm::Ptr(); From 5c0ad96cde0494c6b0945d00a1e7478d53209abc Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 18 Apr 2018 12:49:21 +0200 Subject: [PATCH 049/686] Unify charged-hadron-from-track plugins, and minor review modifications --- .../interface/PFRecoTauChargedHadron.h | 8 +- ...RecoTauChargedHadronFromLostTrackPlugin.cc | 278 ------------------ .../PFRecoTauChargedHadronFromTrackPlugin.cc | 140 +++++++-- .../TauTagTools/src/PFTauElementsOperators.cc | 10 +- 4 files changed, 116 insertions(+), 320 deletions(-) delete mode 100644 RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc diff --git a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h index 90871a8abe182..833bc806a280e 100644 --- a/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h +++ b/DataFormats/TauReco/interface/PFRecoTauChargedHadron.h @@ -8,9 +8,9 @@ #include "DataFormats/Math/interface/Point3D.h" namespace reco { namespace tau { + template + class PFRecoTauChargedHadronFromGenericTrackPlugin; class PFRecoTauChargedHadronFromPFCandidatePlugin; - class PFRecoTauChargedHadronFromTrackPlugin; - class PFRecoTauChargedHadronFromLostTrackPlugin; class RecoTauConstructor; class PFRecoTauEnergyAlgorithmPlugin; }} @@ -72,8 +72,8 @@ class PFRecoTauChargedHadron : public CompositePtrCandidate private: friend class tau::PFRecoTauChargedHadronFromPFCandidatePlugin; - friend class tau::PFRecoTauChargedHadronFromTrackPlugin; - friend class tau::PFRecoTauChargedHadronFromLostTrackPlugin; + template + friend class tau::PFRecoTauChargedHadronFromGenericTrackPlugin; friend class tau::RecoTauConstructor; friend class tau::PFRecoTauEnergyAlgorithmPlugin; friend class ::PFRecoTauChargedHadronProducer; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc deleted file mode 100644 index 67ce49e758d4e..0000000000000 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromLostTrackPlugin.cc +++ /dev/null @@ -1,278 +0,0 @@ -/* - * PFRecoTauChargedHadronFromLostTrackPlugin - * - * Build PFRecoTauChargedHadron objects - * using lostTracks, i.e. pat::PackedCandidates built for tracks not used - * by PFlow algorithm as input - * - * Author: Michal Bluj, NCBJ, Poland - * based on PFRecoTauChargedHadronFromTrackPlugin by Christian Veelken - * - */ - -#include "RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h" -#include "DataFormats/JetReco/interface/Jet.h" -#include "DataFormats/Common/interface/AssociationMap.h" -#include "DataFormats/Common/interface/Ptr.h" -#include "DataFormats/Math/interface/deltaR.h" - -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" -#include "FastSimulation/Particle/interface/RawParticle.h" - -#include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" -#include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" -#include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" -#include "RecoTauTag/RecoTau/interface/pfRecoTauChargedHadronAuxFunctions.h" - -#include - -#include -#include - -namespace reco { namespace tau { - -class PFRecoTauChargedHadronFromLostTrackPlugin : public PFRecoTauChargedHadronBuilderPlugin -{ - public: - explicit PFRecoTauChargedHadronFromLostTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector && iC); - ~PFRecoTauChargedHadronFromLostTrackPlugin() override; - // Return type is auto_ptr - return_type operator()(const reco::Jet&) const override; - // Hook to update PV information - void beginEvent() override; - - private: - typedef std::vector CandPtrs; - - RecoTauVertexAssociator vertexAssociator_; - - RecoTauQualityCuts* qcuts_; - - edm::InputTag srcLostTracks_; - edm::EDGetTokenT lostTracks_token; - double dRcone_; - bool dRconeLimitedToJetArea_; - - double dRmergeNeutralHadron_; - double dRmergePhoton_; - - math::XYZVector magneticFieldStrength_; - - mutable int numWarnings_; - int maxWarnings_; - - int verbosity_; -}; - - PFRecoTauChargedHadronFromLostTrackPlugin::PFRecoTauChargedHadronFromLostTrackPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC) - : PFRecoTauChargedHadronBuilderPlugin(pset,std::move(iC)), - vertexAssociator_(pset.getParameter("qualityCuts"),std::move(iC)), - qcuts_(nullptr) -{ - edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts"); - qcuts_ = new RecoTauQualityCuts(qcuts_pset); - - srcLostTracks_ = pset.getParameter("srcLostTracks"); - lostTracks_token = iC.consumes(srcLostTracks_); - dRcone_ = pset.getParameter("dRcone"); - dRconeLimitedToJetArea_ = pset.getParameter("dRconeLimitedToJetArea"); - - dRmergeNeutralHadron_ = pset.getParameter("dRmergeNeutralHadron"); - dRmergePhoton_ = pset.getParameter("dRmergePhoton"); - - numWarnings_ = 0; - maxWarnings_ = 3; - - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; -} - -PFRecoTauChargedHadronFromLostTrackPlugin::~PFRecoTauChargedHadronFromLostTrackPlugin() -{ - delete qcuts_; -} - -// Update the primary vertex -void PFRecoTauChargedHadronFromLostTrackPlugin::beginEvent() -{ - vertexAssociator_.setEvent(*this->evt()); - - edm::ESHandle magneticField; - evtSetup()->get().get(magneticField); - magneticFieldStrength_ = magneticField->inTesla(GlobalPoint(0.,0.,0.)); -} - -namespace -{ - struct Candidate_withDistance - { - reco::CandidatePtr pfCandidate_; - double distance_; - }; - - bool isSmallerDistance(const Candidate_withDistance& cand1, const Candidate_withDistance& cand2) - { - return (cand1.distance_ < cand2.distance_); - } -} - -PFRecoTauChargedHadronFromLostTrackPlugin::return_type PFRecoTauChargedHadronFromLostTrackPlugin::operator()(const reco::Jet& jet) const -{ - if ( verbosity_ ) { - edm::LogPrint("TauChHFromLostTrack") << ":" ; - edm::LogPrint("TauChHFromLostTrack") << " pluginName = " << name() ; - } - - ChargedHadronVector output; - - const edm::Event& evt = (*this->evt()); - - edm::Handle lostTracks; - evt.getByToken(lostTracks_token, lostTracks); - - qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); - float jEta=jet.eta(); - float jPhi=jet.phi(); - size_t numTracks = lostTracks->size(); - for ( size_t iTrack = 0; iTrack < numTracks; ++iTrack ) { - // ignore lostTracks without detailed information - if ( !(*lostTracks)[iTrack].hasTrackDetails() ) continue; - const reco::Track *track = &(*lostTracks)[iTrack].pseudoTrack(); - - // consider tracks in vicinity of tau-jet candidate only - double dR = deltaR((*lostTracks)[iTrack].eta(), (*lostTracks)[iTrack].phi(), jEta,jPhi); - double dRmatch = dRcone_; - if ( dRconeLimitedToJetArea_ ) { - double jetArea = jet.jetArea(); - if ( jetArea > 0. ) { - dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi())); - } else { - if ( numWarnings_ < maxWarnings_ ) { - edm::LogInfo("PFRecoTauChargedHadronFromLostTrackPlugin::operator()") - << "Jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << " has area = " << jetArea << " !!" << std::endl; - ++numWarnings_; - } - dRmatch = 0.1; - } - } - if ( dR > dRmatch ) continue; - - // ignore tracks which fail quality cuts - if ( (*lostTracks)[iTrack].charge() == 0 || !qcuts_->filterChargedCand((*lostTracks)[iTrack]) ) continue; - - reco::Candidate::Charge trackCharge_int = 0; - if ( (*lostTracks)[iTrack].charge() > 0. ) trackCharge_int = +1; - else if ( (*lostTracks)[iTrack].charge() < 0. ) trackCharge_int = -1; - - const double chargedPionMass = 0.13957; // GeV - double chargedPionP = (*lostTracks)[iTrack].p(); - double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass); - reco::Candidate::LorentzVector chargedPionP4((*lostTracks)[iTrack].px(), (*lostTracks)[iTrack].py(),(*lostTracks)[iTrack].pz(), chargedPionEn); - - reco::Vertex::Point vtx(0.,0.,0.); - if ( vertexAssociator_.associatedVertex(jet).isNonnull() ) vtx = vertexAssociator_.associatedVertex(jet)->position(); - - std::auto_ptr chargedHadron(new PFRecoTauChargedHadron(trackCharge_int, chargedPionP4, vtx, 0, true, PFRecoTauChargedHadron::kTrack)); - // MB: Not possible to save track for a lostTrack(PackedCandidate)/miniAOD, - // need to get the track later using the pseudoTrack method (downstream) - //chargedHadron->track_ = edm::Ptr(tracks, iTrack); - chargedHadron->lostTrackCandidate_ = edm::Ptr(lostTracks,iTrack); - - // CV: Take code for propagating track to ECAL entrance - // from RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc - // to make sure propagation is done in the same way as for charged PFCandidates. - // - // The following replacements need to be made - // outerMomentum -> momentum - // outerPosition -> referencePoint - // in order to run on AOD input - // (outerMomentum and outerPosition require access to reco::TrackExtra objects, which are available in RECO only) - // - XYZTLorentzVector chargedPionPos((*lostTracks)[iTrack].vertex().x(), (*lostTracks)[iTrack].vertex().y(), (*lostTracks)[iTrack].vertex().z(), 0.); - BaseParticlePropagator trackPropagator(RawParticle(chargedPionP4, chargedPionPos), 0., 0., magneticFieldStrength_.z()); - trackPropagator.setCharge((*lostTracks)[iTrack].charge()); - trackPropagator.propagateToEcalEntrance(false); - if ( trackPropagator.getSuccess() != 0 ) { - chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex(); - } else { - if ( chargedPionP4.pt() > 2. ) { - edm::LogWarning("PFRecoTauChargedHadronFromLostTrackPlugin::operator()") - << "Failed to propagate track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() << " to ECAL entrance !!" << std::endl; - } - chargedHadron->positionAtECALEntrance_ = math::XYZPointF(0.,0.,0.); - } - - std::vector neutralJetConstituents_withDistance; - std::vector jetConstituents = jet.daughterPtrVector(); - for ( const auto& jetConstituent : jetConstituents ) { - int pdgId = jetConstituent->pdgId(); - if ( !(pdgId == 130 || pdgId == 22) ) continue; - double dR = deltaR(atECALEntrance(&*jetConstituent, magneticFieldStrength_.z()), chargedHadron->positionAtECALEntrance_); - double dRmerge = -1.; - if ( pdgId == 130 ) dRmerge = dRmergeNeutralHadron_; - else if ( pdgId == 22 ) dRmerge = dRmergePhoton_; - if ( dR < dRmerge ) { - Candidate_withDistance jetConstituent_withDistance; - jetConstituent_withDistance.pfCandidate_ = jetConstituent; - jetConstituent_withDistance.distance_ = dR; - neutralJetConstituents_withDistance.push_back(jetConstituent_withDistance); - chargedHadron->addDaughter(jetConstituent); - } - } - std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance); - - const double caloResolutionCoeff = 1.0; // CV: approximate ECAL + HCAL calorimeter resolution for hadrons by 100%*sqrt(E) - double trackPtError = 0.06; // MB: Approximate avarage track PtError by 2.5% (barrel), 4% (transition), 6% (endcaps) lostTracks w/o detailed track information available (after TRK-11-001) - if( std::abs((*lostTracks)[iTrack].eta()) < 0.9 ) - trackPtError = 0.025; - else if( std::abs((*lostTracks)[iTrack].eta()) < 1.4 ) - trackPtError = 0.04; - if(track != nullptr) - trackPtError = track->ptError(); - double resolutionTrackP =(*lostTracks)[iTrack].p()*(trackPtError/(*lostTracks)[iTrack].pt()); - double neutralEnSum = 0.; - for ( std::vector::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin(); - nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) { - double nextNeutralEn = nextNeutral->pfCandidate_->energy(); - double resolutionCaloEn = caloResolutionCoeff*sqrt(neutralEnSum + nextNeutralEn); - double resolution = sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn); - if ( (neutralEnSum + nextNeutralEn) < ((*lostTracks)[iTrack].p() + 2.*resolution) ) { - chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_); - neutralEnSum += nextNeutralEn; - } else { - break; - } - } - - setChargedHadronP4(*chargedHadron); - - if ( verbosity_ ) { - edm::LogPrint("TauChHFromLostTrack") << *chargedHadron; - } - - output.push_back(chargedHadron); - } - - return output.release(); -} - -}} // end namespace reco::tau - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_EDM_PLUGIN(PFRecoTauChargedHadronBuilderPluginFactory, reco::tau::PFRecoTauChargedHadronFromLostTrackPlugin, "PFRecoTauChargedHadronFromLostTrackPlugin"); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index 2b1e178321c4b..a3635d5593dd9 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -1,11 +1,13 @@ /* - * PFRecoTauChargedHadronFromTrackPlugin + * PFRecoTauChargedHadronFromGenericTrackPlugin * * Build PFRecoTauChargedHadron objects * using charged PFCandidates as input * * Author: Christian Veelken, LLR * + * inclusion of lost tracks based on + * PFRecoTauChargedHadronFromLostTrackPlugin by Michal Bluj, NCBJ, Poland */ #include "RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h" @@ -18,6 +20,7 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -40,28 +43,33 @@ #include #include +#include namespace reco { namespace tau { -class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuilderPlugin +template +class PFRecoTauChargedHadronFromGenericTrackPlugin : public PFRecoTauChargedHadronBuilderPlugin { public: - explicit PFRecoTauChargedHadronFromTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector && iC); - ~PFRecoTauChargedHadronFromTrackPlugin() override; + explicit PFRecoTauChargedHadronFromGenericTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector && iC); + ~PFRecoTauChargedHadronFromGenericTrackPlugin() override; // Return type is auto_ptr return_type operator()(const reco::Jet&) const override; // Hook to update PV information void beginEvent() override; private: - typedef std::vector PFCandPtrs; + bool filterTrack(const edm::Handle >&, size_t iTrack) const; + void setChargedHadronTrack(PFRecoTauChargedHadron& chargedHadron, const edm::Ptr& track) const; + double getTrackPtError(const TrackClass& track) const; + XYZTLorentzVector getTrackPos(const TrackClass& track) const; RecoTauVertexAssociator vertexAssociator_; RecoTauQualityCuts* qcuts_; edm::InputTag srcTracks_; - edm::EDGetTokenT Tracks_token; + edm::EDGetTokenT > Tracks_token; double dRcone_; bool dRconeLimitedToJetArea_; @@ -76,7 +84,8 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild int verbosity_; }; - PFRecoTauChargedHadronFromTrackPlugin::PFRecoTauChargedHadronFromTrackPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC) +template +PFRecoTauChargedHadronFromGenericTrackPlugin::PFRecoTauChargedHadronFromGenericTrackPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector && iC) : PFRecoTauChargedHadronBuilderPlugin(pset,std::move(iC)), vertexAssociator_(pset.getParameter("qualityCuts"),std::move(iC)), qcuts_(nullptr) @@ -85,7 +94,7 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild qcuts_ = new RecoTauQualityCuts(qcuts_pset); srcTracks_ = pset.getParameter("srcTracks"); - Tracks_token = iC.consumes(srcTracks_); + Tracks_token = iC.consumes >(srcTracks_); dRcone_ = pset.getParameter("dRcone"); dRconeLimitedToJetArea_ = pset.getParameter("dRconeLimitedToJetArea"); @@ -98,22 +107,82 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild verbosity_ = ( pset.exists("verbosity") ) ? pset.getParameter("verbosity") : 0; } - -PFRecoTauChargedHadronFromTrackPlugin::~PFRecoTauChargedHadronFromTrackPlugin() + +template +PFRecoTauChargedHadronFromGenericTrackPlugin::~PFRecoTauChargedHadronFromGenericTrackPlugin() { delete qcuts_; } // Update the primary vertex -void PFRecoTauChargedHadronFromTrackPlugin::beginEvent() +template +void PFRecoTauChargedHadronFromGenericTrackPlugin::beginEvent() { vertexAssociator_.setEvent(*this->evt()); edm::ESHandle magneticField; - evtSetup()->get().get(magneticField); + const edm::EventSetup* evtSetup(this->evtSetup()); + evtSetup->get().get(magneticField); magneticFieldStrength_ = magneticField->inTesla(GlobalPoint(0.,0.,0.)); } +template<> +bool PFRecoTauChargedHadronFromGenericTrackPlugin::filterTrack(const edm::Handle >& tracks, size_t iTrack) const { +// ignore tracks which fail quality cuts + reco::TrackRef trackRef(tracks, iTrack); + return qcuts_->filterTrack(trackRef); +} + +template<> +bool PFRecoTauChargedHadronFromGenericTrackPlugin::filterTrack(const edm::Handle >& tracks, size_t iTrack) const { +// ignore tracks which fail quality cuts + const pat::PackedCandidate& cand = (*tracks)[iTrack]; + if (cand.charge() == 0) + return false; + return qcuts_->filterChargedCand(cand); +} + +template<> +void PFRecoTauChargedHadronFromGenericTrackPlugin::setChargedHadronTrack(PFRecoTauChargedHadron& chargedHadron, const edm::Ptr& track) const { + chargedHadron.track_ = track; +} + +template<> +void PFRecoTauChargedHadronFromGenericTrackPlugin::setChargedHadronTrack(PFRecoTauChargedHadron& chargedHadron, const edm::Ptr& track) const { + chargedHadron.lostTrackCandidate_ = track; +} + +template<> +double PFRecoTauChargedHadronFromGenericTrackPlugin::getTrackPtError(const reco::Track& track) const { + return track.ptError(); +} + +template<> +double PFRecoTauChargedHadronFromGenericTrackPlugin::getTrackPtError(const pat::PackedCandidate& cand) const { + double trackPtError = 0.06; // MB: Approximate avarage track PtError by 2.5% (barrel), 4% (transition), 6% (endcaps) lostTracks w/o detailed track information available (after TRK-11-001) + const reco::Track* track(cand.bestTrack()); + if(track != nullptr) { + trackPtError = track->ptError(); + } else { + if( std::abs(cand.eta()) < 0.9 ) + trackPtError = 0.025; + else if( std::abs(cand.eta()) < 1.4 ) + trackPtError = 0.04; + } + return trackPtError; +} + +template<> +XYZTLorentzVector PFRecoTauChargedHadronFromGenericTrackPlugin::getTrackPos(const reco::Track& track) const { + return XYZTLorentzVector(track.referencePoint().x(), track.referencePoint().y(), track.referencePoint().z(), 0.); +} + +template<> +XYZTLorentzVector PFRecoTauChargedHadronFromGenericTrackPlugin::getTrackPos(const pat::PackedCandidate& track) const { + return XYZTLorentzVector(track.vertex().x(), track.vertex().y(), track.vertex().z(), 0.); +} + + namespace { struct Candidate_withDistance @@ -128,10 +197,11 @@ namespace } } -PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTrackPlugin::operator()(const reco::Jet& jet) const +template +typename PFRecoTauChargedHadronFromGenericTrackPlugin::return_type PFRecoTauChargedHadronFromGenericTrackPlugin::operator()(const reco::Jet& jet) const { if ( verbosity_ ) { - edm::LogPrint("TauChHFromTrack") << ":" ; + edm::LogPrint("TauChHFromTrack") << ":" ; edm::LogPrint("TauChHFromTrack") << " pluginName = " << name() ; } @@ -139,7 +209,7 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra const edm::Event& evt = (*this->evt()); - edm::Handle tracks; + edm::Handle > tracks; evt.getByToken(Tracks_token, tracks); qcuts_->setPV(vertexAssociator_.associatedVertex(jet)); @@ -147,18 +217,18 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra float jPhi=jet.phi(); size_t numTracks = tracks->size(); for ( size_t iTrack = 0; iTrack < numTracks; ++iTrack ) { - reco::TrackRef track(tracks, iTrack); + const TrackClass& track = (*tracks)[iTrack]; // consider tracks in vicinity of tau-jet candidate only - double dR = deltaR(track->eta(), track->phi(), jEta,jPhi); + double dR = deltaR(track.eta(), track.phi(), jEta,jPhi); double dRmatch = dRcone_; if ( dRconeLimitedToJetArea_ ) { double jetArea = jet.jetArea(); if ( jetArea > 0. ) { - dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi())); + dRmatch = std::min(dRmatch, sqrt(jetArea/M_PI)); } else { if ( numWarnings_ < maxWarnings_ ) { - edm::LogInfo("PFRecoTauChargedHadronFromTrackPlugin::operator()") + edm::LogInfo("PFRecoTauChargedHadronFromGenericTrackPlugin::operator()") << "Jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << " has area = " << jetArea << " !!" << std::endl; ++numWarnings_; } @@ -167,23 +237,23 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra } if ( dR > dRmatch ) continue; - // ignore tracks which fail quality cuts - if ( !qcuts_->filterTrack(track) ) continue; + if (!this->filterTrack(tracks, iTrack)) continue; reco::Candidate::Charge trackCharge_int = 0; - if ( track->charge() > 0. ) trackCharge_int = +1; - else if ( track->charge() < 0. ) trackCharge_int = -1; + if ( track.charge() > 0. ) trackCharge_int = +1; + else if ( track.charge() < 0. ) trackCharge_int = -1; const double chargedPionMass = 0.13957; // GeV - double chargedPionP = track->p(); + double chargedPionP = track.p(); double chargedPionEn = TMath::Sqrt(chargedPionP*chargedPionP + chargedPionMass*chargedPionMass); - reco::Candidate::LorentzVector chargedPionP4(track->px(), track->py(), track->pz(), chargedPionEn); + reco::Candidate::LorentzVector chargedPionP4(track.px(), track.py(), track.pz(), chargedPionEn); reco::Vertex::Point vtx(0.,0.,0.); if ( vertexAssociator_.associatedVertex(jet).isNonnull() ) vtx = vertexAssociator_.associatedVertex(jet)->position(); std::auto_ptr chargedHadron(new PFRecoTauChargedHadron(trackCharge_int, chargedPionP4, vtx, 0, true, PFRecoTauChargedHadron::kTrack)); - chargedHadron->track_ = edm::Ptr(tracks, iTrack); + + setChargedHadronTrack(*chargedHadron, edm::Ptr(tracks, iTrack)); // CV: Take code for propagating track to ECAL entrance // from RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc @@ -195,16 +265,16 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra // in order to run on AOD input // (outerMomentum and outerPosition require access to reco::TrackExtra objects, which are available in RECO only) // - XYZTLorentzVector chargedPionPos(track->referencePoint().x(), track->referencePoint().y(), track->referencePoint().z(), 0.); + XYZTLorentzVector chargedPionPos(getTrackPos(track)); BaseParticlePropagator trackPropagator(RawParticle(chargedPionP4, chargedPionPos), 0., 0., magneticFieldStrength_.z()); - trackPropagator.setCharge(track->charge()); + trackPropagator.setCharge(track.charge()); trackPropagator.propagateToEcalEntrance(false); if ( trackPropagator.getSuccess() != 0 ) { chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex(); } else { if ( chargedPionP4.pt() > 2. and std::abs(chargedPionP4.eta()) < 3. ) { - edm::LogWarning("PFRecoTauChargedHadronFromTrackPlugin::operator()") - << "Failed to propagate track: Pt = " << track->pt() << ", eta = " << track->eta() << ", phi = " << track->phi() << " to ECAL entrance !!" << std::endl; + edm::LogWarning("PFRecoTauChargedHadronFromGenericTrackPlugin::operator()") + << "Failed to propagate track: Pt = " << track.pt() << ", eta = " << track.eta() << ", phi = " << track.phi() << " to ECAL entrance !!" << std::endl; } chargedHadron->positionAtECALEntrance_ = math::XYZPointF(0.,0.,0.); } @@ -229,14 +299,14 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra std::sort(neutralJetConstituents_withDistance.begin(), neutralJetConstituents_withDistance.end(), isSmallerDistance); const double caloResolutionCoeff = 1.0; // CV: approximate ECAL + HCAL calorimeter resolution for hadrons by 100%*sqrt(E) - double resolutionTrackP = track->p()*(track->ptError()/track->pt()); + double resolutionTrackP = track.p()*(getTrackPtError(track)/track.pt()); double neutralEnSum = 0.; for ( std::vector::const_iterator nextNeutral = neutralJetConstituents_withDistance.begin(); nextNeutral != neutralJetConstituents_withDistance.end(); ++nextNeutral ) { double nextNeutralEn = nextNeutral->pfCandidate_->energy(); double resolutionCaloEn = caloResolutionCoeff*sqrt(neutralEnSum + nextNeutralEn); double resolution = sqrt(resolutionTrackP*resolutionTrackP + resolutionCaloEn*resolutionCaloEn); - if ( (neutralEnSum + nextNeutralEn) < (track->p() + 2.*resolution) ) { + if ( (neutralEnSum + nextNeutralEn) < (track.p() + 2.*resolution) ) { chargedHadron->neutralPFCandidates_.push_back(nextNeutral->pfCandidate_); neutralEnSum += nextNeutralEn; } else { @@ -256,8 +326,14 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra return output.release(); } +template class PFRecoTauChargedHadronFromGenericTrackPlugin; +typedef PFRecoTauChargedHadronFromGenericTrackPlugin PFRecoTauChargedHadronFromTrackPlugin; +template class PFRecoTauChargedHadronFromGenericTrackPlugin; +typedef PFRecoTauChargedHadronFromGenericTrackPlugin PFRecoTauChargedHadronFromLostTrackPlugin; + }} // end namespace reco::tau #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_EDM_PLUGIN(PFRecoTauChargedHadronBuilderPluginFactory, reco::tau::PFRecoTauChargedHadronFromTrackPlugin, "PFRecoTauChargedHadronFromTrackPlugin"); +DEFINE_EDM_PLUGIN(PFRecoTauChargedHadronBuilderPluginFactory, reco::tau::PFRecoTauChargedHadronFromLostTrackPlugin, "PFRecoTauChargedHadronFromLostTrackPlugin"); diff --git a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc index 26cbb1b3161ed..4a11d6085c4bc 100644 --- a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc +++ b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc @@ -48,12 +48,10 @@ std::vector PFTauElementsOperators::PFChargedHadrCandsInCone std::vector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ std::vector filteredPFChargedHadrCands; for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ - const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); - if (pfcand != nullptr) { - TrackRef PFChargedHadrCand_track = pfcand->trackRef(); - if (!PFChargedHadrCand_track)continue; - if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + const reco::Track* PFChargedHadrCand_track = (*iPFCand)->bestTrack(); + if (PFChargedHadrCand_track == nullptr) continue; + if (fabs(PFChargedHadrCand_track->dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); + } std::vector theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt); return theFilteredPFCandsInCone; From d1757214fa44314f1fa2ad583a5d48c8a7c4c7e8 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 18 Apr 2018 15:07:38 +0200 Subject: [PATCH 050/686] Only allow lost tracks that have a pseudoTrack(), since otherwise the p4 assignment fails --- .../RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index a3635d5593dd9..0927146cbad39 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -135,10 +135,13 @@ bool PFRecoTauChargedHadronFromGenericTrackPlugin::filterTrack(cons template<> bool PFRecoTauChargedHadronFromGenericTrackPlugin::filterTrack(const edm::Handle >& tracks, size_t iTrack) const { -// ignore tracks which fail quality cuts + // ignore tracks which fail quality cuts const pat::PackedCandidate& cand = (*tracks)[iTrack]; if (cand.charge() == 0) return false; + // ignore lost tracks without reconstructed track + if (!cand.hasTrackDetails()) + return false; return qcuts_->filterChargedCand(cand); } From 334ffa0c42e9504c347f25b23bf69f4a96056a2b Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 18 Apr 2018 15:08:25 +0200 Subject: [PATCH 051/686] Simplify setting up tau reco@MiniAOD sequence --- .../python/tools/adaptToRunAtMiniAOD.py | 176 ++++-------------- ...oTauDiscriminationAgainstMuonSimple_cfi.py | 29 +++ .../RecoTau/test/rerunTauRecoOnMiniAOD.py | 4 +- 3 files changed, 68 insertions(+), 141 deletions(-) create mode 100644 RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index 7c50bca0df8c4..53aa247a9447c 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -15,25 +15,25 @@ def addTauReReco(process): process.selectedPatTaus.cut="pt > 18. && tauID(\'decayModeFindingNewDMs\')> 0.5" #Cut as in MiniAOD #Tau RECO process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") - #Task/Sequence for tau rereco - process.miniAODTausTask = cms.Task() - process.miniAODTausTask.add(process.PFTauTask) - #Add PAT Tau modules to miniAODTausTask - process.miniAODTausTask.add(process.makePatTausTask) - process.miniAODTausTask.add(process.selectedPatTaus) + #Task/Sequence for tau rereco + process.miniAODTausTask = cms.Task( + process.PFTauTask, + process.makePatTausTask, + process.selectedPatTaus + ) process.miniAODTausSequence = cms.Sequence(process.miniAODTausTask) #Path with tau rereco (Needed?) - process.TauReco = cms.Path(process.miniAODTausSequence) + process.TauReco = cms.Path(process.miniAODTausSequence) ##### def convertModuleToMiniAODInput(process, name): - module = getattr(process, name) - if hasattr(module, 'particleFlowSrc'): - module.particleFlowSrc = cms.InputTag("packedPFCandidates", "", "") - if hasattr(module, 'vertexSrc'): - module.vertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') - if hasattr(module, 'qualityCuts') and hasattr(module.qualityCuts, 'primaryVertexSrc'): - module.qualityCuts.primaryVertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') + module = getattr(process, name) + if hasattr(module, 'particleFlowSrc'): + module.particleFlowSrc = cms.InputTag("packedPFCandidates", "", "") + if hasattr(module, 'vertexSrc'): + module.vertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') + if hasattr(module, 'qualityCuts') and hasattr(module.qualityCuts, 'primaryVertexSrc'): + module.qualityCuts.primaryVertexSrc = cms.InputTag('offlineSlimmedPrimaryVertices') ##### def adaptTauToMiniAODReReco(process, reclusterJets=True): @@ -43,14 +43,14 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): jetCollection = 'slimmedJets' # Add new jet collections if reclustering is demanded if reclusterJets: - jetCollection = 'patAK4PFJets' + jetCollection = 'patJetsPAT' from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets process.ak4PFJetsPAT = ak4PFJets.clone( src=cms.InputTag("packedPFCandidates") ) # trivial PATJets from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets - process.patAK4PFJets = _patJets.clone( + process.patJetsPAT = _patJets.clone( jetSource = cms.InputTag("ak4PFJetsPAT"), addJetCorrFactors = cms.bool(False), jetCorrFactorsSource = cms.VInputTag(), @@ -66,7 +66,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): addJetFlavourInfo = cms.bool(False), ) process.miniAODTausTask.add(process.ak4PFJetsPAT) - process.miniAODTausTask.add(process.patAK4PFJets) + process.miniAODTausTask.add(process.patJetsPAT) # so this adds all tracks to jet in some deltaR region. we don't have tracks so don't need it :D # process.ak4PFJetTracksAssociatorAtVertex.jets = cms.InputTag(jetCollection) @@ -76,8 +76,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): # HOWEVER, may use https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookMiniAOD2017#Isolated_Tracks # probably needs recovery of the two modules above - - process.recoTauAK4PatJets08Region = cms.EDProducer("RecoTauPatJetRegionProducer", + process.recoTauAK4Jets08RegionPAT = cms.EDProducer("RecoTauPatJetRegionProducer", deltaR = process.recoTauAK4PFJets08Region.deltaR, maxJetAbsEta = process.recoTauAK4PFJets08Region.maxJetAbsEta, minJetPt = process.recoTauAK4PFJets08Region.minJetPt, @@ -90,10 +89,14 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): # Redefine recoTauCommonTask # with redefined region and PU vertices, and w/o track-to-vertex associator and tauTagInfo (the two latter are probably obsolete and not needed at all) process.recoTauCommonTask = cms.Task( - process.recoTauAK4PatJets08Region, + process.recoTauAK4Jets08RegionPAT, process.recoTauPileUpVertices ) + for moduleName in process.TauReco.moduleNames(): + convertModuleToMiniAODInput(process, moduleName) + + # Adapt TauPiZeros producer process.ak4PFJetsLegacyHPSPiZeros.builders[0].qualityCuts.primaryVertexSrc = cms.InputTag("offlineSlimmedPrimaryVertices") process.ak4PFJetsLegacyHPSPiZeros.jetSrc = cms.InputTag(jetCollection) @@ -104,13 +107,11 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): if builder.name.value() == 'tracks': #replace plugin based on generalTracks by one based on lostTracks builder.name = 'lostTracks' builder.plugin = 'PFRecoTauChargedHadronFromLostTrackPlugin' - builder.srcLostTracks = cms.InputTag("lostTracks") - del builder.srcTracks + builder.srcTracks = cms.InputTag("lostTracks") process.ak4PFJetsRecoTauChargedHadrons.jetSrc = cms.InputTag(jetCollection) # Adapt combinatoricRecoTau producer - convertModuleToMiniAODInput(process, 'combinatoricRecoTaus') - process.combinatoricRecoTaus.jetRegionSrc = 'recoTauAK4PatJets08Region' + process.combinatoricRecoTaus.jetRegionSrc = 'recoTauAK4Jets08RegionPAT' process.combinatoricRecoTaus.jetSrc = jetCollection # Adapt builders for builder in process.combinatoricRecoTaus.builders: @@ -135,56 +136,9 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.combinatoricRecoTaus.modifiers.remove(mod) #print "\t\t Removing '%s' modifier from 'combinatoricRecoTaus'" %mod.name.value() - # Adapt tau decay mode finding discrimiantor for the cleaning step - convertModuleToMiniAODInput(process, 'hpsSelectionDiscriminator') - - # Adapt clean tau producer - convertModuleToMiniAODInput(process, 'hpsPFTauProducerSansRefs') - - # Adapt piZero unembedder - convertModuleToMiniAODInput(process, 'hpsPFTauProducer') - - # Adapt classic discriminants - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFindingNewDMs') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFindingOldDMs') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByDecayModeFinding') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseChargedIsolation') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseIsolation') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByRawCombinedIsolationDBSumPtCorr3Hits') - - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03') - - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits') - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByRawPileupWeightedIsolation3Hits') - - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByPhotonPtSumOutsideSignalCone') - - # Adapt isolation sums - convertModuleToMiniAODInput(process, 'hpsPFTauChargedIsoPtSum') - convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSum') - convertModuleToMiniAODInput(process, 'hpsPFTauPUcorrPtSum') - convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumWeight') - convertModuleToMiniAODInput(process, 'hpsPFTauFootprintCorrection') - convertModuleToMiniAODInput(process, 'hpsPFTauPhotonPtSumOutsideSignalCone') - # Adapt isolation sums (R=0.3) - convertModuleToMiniAODInput(process, 'hpsPFTauChargedIsoPtSumdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauPUcorrPtSumdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauNeutralIsoPtSumWeightdR03') - convertModuleToMiniAODInput(process, 'hpsPFTauFootprintCorrectiondR03') - convertModuleToMiniAODInput(process, 'hpsPFTauPhotonPtSumOutsideSignalConedR03') - # Redefine tau PV producer process.hpsPFTauPrimaryVertexProducer.__dict__['_TypedParameterizable__type'] = 'PFTauMiniAODPrimaryVertexProducer' process.hpsPFTauPrimaryVertexProducer.PVTag = 'offlineSlimmedPrimaryVertices' - process.hpsPFTauPrimaryVertexProducer.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' process.hpsPFTauPrimaryVertexProducer.packedCandidatesTag = cms.InputTag("packedPFCandidates") process.hpsPFTauPrimaryVertexProducer.lostCandidatesTag = cms.InputTag("lostTracks") @@ -192,70 +146,17 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.hpsPFTauSecondaryVertexProducer = cms.EDProducer("PFTauSecondaryVertexProducer", PFTauTag = cms.InputTag("hpsPFTauProducer") ) - - # Adapt MVAIso discriminants (DBoldDMwLT) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw') - for wp in ['VVLoose', 'VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBoldDMwLT'.format(wp)) - # Adapt MVAIso discriminants (DBnewDMwLT) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw') - for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBnewDMwLT'.format(wp)) - # Adapt MVAIso discriminants (PWoldDMwLT) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWoldDMwLTraw') - for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWoldDMwLT'.format(wp)) - # Adapt MVAIso discriminants (PWnewDMwLT) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWnewDMwLTraw') - for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWnewDMwLT'.format(wp)) - # Adapt MVAIso discriminants (DBoldDMwLT, R=0.3) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw') - for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1DBdR03oldDMwLT'.format(wp)) - # Adapt MVAIso discriminants (PWoldDMwLT, R=0.3) - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw') - for wp in ['VLoose', 'Loose', 'Medium', 'Tight', 'VTight', 'VVTight']: - convertModuleToMiniAODInput(process, 'hpsPFTauDiscriminationBy{}IsolationMVArun2v1PWdR03oldDMwLT'.format(wp)) - + # Remove RecoTau producers which are not supported (yet?), i.e. against-e/mu discriminats - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMediumElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByLooseElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6rawElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6VLooseElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6LooseElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6MediumElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6TightElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByMVA6VTightElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByDeadECALElectronRejection) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByLooseMuonRejection3) - process.miniAODTausTask.remove(process.hpsPFTauDiscriminationByTightMuonRejection3) - # add against-mu discriminants which are MiniAOD compatible - process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoTauDiscriminationAgainstMuonSimple", - PFTauProducer = cms.InputTag("hpsPFTauProducer"), - Prediscriminants = process.hpsPFTauDiscriminationByLooseMuonRejection3.Prediscriminants, - HoPMin = cms.double(0.1), #use smaller value that with AOD as raw energy is used - doCaloMuonVeto = cms.bool(False), #do not use it until tuned - srcPatMuons = cms.InputTag("slimmedMuons"), - minPtMatchedMuon = process.hpsPFTauDiscriminationByLooseMuonRejection3.minPtMatchedMuon, - dRmuonMatch = process.hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatch, - dRmuonMatchLimitedToJetArea = process.hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatchLimitedToJetArea, - maskHitsCSC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsCSC, - maskHitsDT = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsDT, - maskHitsRPC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsRPC, - maxNumberOfHitsLast2Stations = process.hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfHitsLast2Stations, - maskMatchesCSC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesCSC, - maskMatchesDT = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesDT, - maskMatchesRPC = process.hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesRPC, - maxNumberOfMatches = process.hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfMatches, - maxNumberOfSTAMuons = cms.int32(-1), - maxNumberOfRPCMuons = cms.int32(-1), - verbosity = cms.int32(0) - ) - process.hpsPFTauDiscriminationByTightMuonRejectionSimple = process.hpsPFTauDiscriminationByLooseMuonRejectionSimple.clone( - maxNumberOfHitsLast2Stations = process.hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations - ) + for moduleName in process.TauReco.moduleNames(): + if 'ElectronRejection' in moduleName or 'MuonRejection' in moduleName: + process.miniAODTausTask.remove(getattr(process, moduleName)) + + # Instead add against-mu discriminants which are MiniAOD compatible + from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonSimple_cfi import hpsPFTauDiscriminationByLooseMuonRejectionSimple, hpsPFTauDiscriminationByTightMuonRejectionSimple + + process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejectionSimple + process.hpsPFTauDiscriminationByTightMuonRejectionSimple = hpsPFTauDiscriminationByTightMuonRejectionSimple process.miniAODTausTask.add(process.hpsPFTauDiscriminationByLooseMuonRejectionSimple) process.miniAODTausTask.add(process.hpsPFTauDiscriminationByTightMuonRejectionSimple) @@ -265,9 +166,6 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles") process.tauMatch.matched = cms.InputTag("prunedGenParticles") - - convertModuleToMiniAODInput(process, 'patTaus') - # Remove unsupported tauIDs for name, src in process.patTaus.tauIDSources.parameters_().iteritems(): if name.find('againstElectron') > -1 or name.find('againstMuon') > -1: @@ -299,7 +197,7 @@ def setOutputModule(mode=0): ) output.outputCommands.append('keep *_selectedPatTaus_*_*') if mode==1: - for prod in evtContent.RecoTauTagAOD.outputCommands: + for prod in evtContent.RecoTauTagAOD.outputCommands: if prod.find('ElectronRejection') > -1: continue if prod.find('MuonRejection') > -1: @@ -310,7 +208,7 @@ def setOutputModule(mode=0): output.outputCommands.append('keep *_combinatoricReco*_*_*') output.outputCommands.append('keep *_ak4PFJetsRecoTauChargedHadrons_*_*') output.outputCommands.append('keep *_ak4PFJetsLegacyHPSPiZeros_*_*') - output.outputCommands.append('keep *_patAK4PFJets_*_*') + output.outputCommands.append('keep *_patJetsPAT_*_*') return output diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py new file mode 100644 index 0000000000000..0d6df96aed3f9 --- /dev/null +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py @@ -0,0 +1,29 @@ +import FWCore.ParameterSet.Config as cms + +from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByLooseMuonRejection3, hpsPFTauDiscriminationByTightMuonRejection3 + +hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoTauDiscriminationAgainstMuonSimple", + PFTauProducer = cms.InputTag("hpsPFTauProducer"), + Prediscriminants = hpsPFTauDiscriminationByLooseMuonRejection3.Prediscriminants, + HoPMin = cms.double(0.1), #use smaller value that with AOD as raw energy is used + doCaloMuonVeto = cms.bool(False), #do not use it until tuned + srcPatMuons = cms.InputTag("slimmedMuons"), + minPtMatchedMuon = hpsPFTauDiscriminationByLooseMuonRejection3.minPtMatchedMuon, + dRmuonMatch = hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatch, + dRmuonMatchLimitedToJetArea = hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatchLimitedToJetArea, + maskHitsCSC = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsCSC, + maskHitsDT = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsDT, + maskHitsRPC = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsRPC, + maxNumberOfHitsLast2Stations = hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfHitsLast2Stations, + maskMatchesCSC = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesCSC, + maskMatchesDT = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesDT, + maskMatchesRPC = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesRPC, + maxNumberOfMatches = hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfMatches, + maxNumberOfSTAMuons = cms.int32(-1), + maxNumberOfRPCMuons = cms.int32(-1), + verbosity = cms.int32(0) +) + +hpsPFTauDiscriminationByTightMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejectionSimple.clone( + maxNumberOfHitsLast2Stations = hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations +) diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 60ae566f68889..635914f9beca8 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -55,8 +55,8 @@ if runSignal: readFiles.extend( [ - # 'file:patMiniAOD_standard.root' - 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', + 'file:patMiniAOD_standard.root' + # 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ] ) else: From f77ae6c286b9559680f0468bb85500e232495653 Mon Sep 17 00:00:00 2001 From: Roger Date: Wed, 18 Apr 2018 16:20:57 +0200 Subject: [PATCH 052/686] adding runtest for tau reconstruction based on miniAOD input --- RecoTauTag/RecoTau/test/BuildFile.xml | 6 ++++++ RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py | 4 +++- RecoTauTag/RecoTau/test/runtestRecoTauTagRecoTau.cpp | 3 +++ RecoTauTag/RecoTau/test/runtests.sh | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 RecoTauTag/RecoTau/test/runtestRecoTauTagRecoTau.cpp create mode 100755 RecoTauTag/RecoTau/test/runtests.sh diff --git a/RecoTauTag/RecoTau/test/BuildFile.xml b/RecoTauTag/RecoTau/test/BuildFile.xml index 7b61d3bf3fb24..d77453efb4df5 100644 --- a/RecoTauTag/RecoTau/test/BuildFile.xml +++ b/RecoTauTag/RecoTau/test/BuildFile.xml @@ -16,3 +16,9 @@ + + + + + + diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 60ae566f68889..82bddd6922b68 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -56,7 +56,9 @@ if runSignal: readFiles.extend( [ # 'file:patMiniAOD_standard.root' - 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', + '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + #'/store/relval/CMSSW_10_1_0_pre1/RelValTTbar_13/MINIAODSIM/PU25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/10000/72D398B6-8613-E811-B900-0CC47A4D75EE.root' + #'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ] ) else: diff --git a/RecoTauTag/RecoTau/test/runtestRecoTauTagRecoTau.cpp b/RecoTauTag/RecoTau/test/runtestRecoTauTagRecoTau.cpp new file mode 100644 index 0000000000000..b2991bd18ae57 --- /dev/null +++ b/RecoTauTag/RecoTau/test/runtestRecoTauTagRecoTau.cpp @@ -0,0 +1,3 @@ +#include "FWCore/Utilities/interface/TestHelper.h" + +RUNTEST() diff --git a/RecoTauTag/RecoTau/test/runtests.sh b/RecoTauTag/RecoTau/test/runtests.sh new file mode 100755 index 0000000000000..8a0a2d274efe9 --- /dev/null +++ b/RecoTauTag/RecoTau/test/runtests.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +function die { echo $1: status $2 ; exit $2; } + +cmsRun ${LOCAL_TEST_DIR}/rerunTauRecoOnMiniAOD.py || die 'Failure using rerunTauRecoOnMiniAOD.py' $? + From c1f1fce96db5be9b030cb33b90f11124bb39a97d Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 18 Apr 2018 16:45:38 +0200 Subject: [PATCH 053/686] Allow also charged hadrons to be reconstructed from PackedCandidates from the lostTracks collection that do not have additional track information stored --- .../PFRecoTauChargedHadronFromTrackPlugin.cc | 4 +--- .../plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 6 ------ .../src/pfRecoTauChargedHadronAuxFunctions.cc | 18 +++++++++++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index 0927146cbad39..20c3c6d2cfec5 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -139,9 +139,7 @@ bool PFRecoTauChargedHadronFromGenericTrackPlugin::filterT const pat::PackedCandidate& cand = (*tracks)[iTrack]; if (cand.charge() == 0) return false; - // ignore lost tracks without reconstructed track - if (!cand.hasTrackDetails()) - return false; + return qcuts_->filterChargedCand(cand); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index a8e56fa9c09ae..3eeca80bec8e8 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -158,12 +158,6 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const if ( chargedHadronTrack != nullptr ) { nonPFCandTracksSumP += chargedHadronTrack->p(); nonPFCandTracksSumPerr2 += getTrackPerr2(*chargedHadronTrack); - } else { - edm::LogWarning("PFRecoTauEnergyAlgorithmPlugin::operator()") - << "PFRecoTauChargedHadron has no associated reco::Track !!" << std::endl; - if ( verbosity_ ) { - chargedHadron->print(); - } } } } diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index 52fd770cff3ae..52f2b73f0322e 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -42,11 +42,19 @@ void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scal chargedHadronPz = chargedPFCand->pz(); } else if ( chargedHadron.algoIs(reco::PFRecoTauChargedHadron::kTrack) ) { const reco::Track* track = getTrackFromChargedHadron(chargedHadron); - assert(track != nullptr); - chargedHadronP += track->p(); - chargedHadronPx = track->px(); - chargedHadronPy = track->py(); - chargedHadronPz = track->pz(); + if (track != nullptr) { + chargedHadronP += track->p(); + chargedHadronPx = track->px(); + chargedHadronPy = track->py(); + chargedHadronPz = track->pz(); + } else { // lost tracks from MiniAOD that don't have track information saved + const reco::CandidatePtr& lostTrack = chargedHadron.getLostTrackCandidate(); + assert(lostTrack.isNonnull()); + chargedHadronP += lostTrack->p(); + chargedHadronPx = lostTrack->px(); + chargedHadronPy = lostTrack->py(); + chargedHadronPz = lostTrack->pz(); + } } else assert(0); const std::vector& neutralPFCands = chargedHadron.getNeutralPFCandidates(); for ( std::vector::const_iterator neutralPFCand = neutralPFCands.begin(); From a73d590481ef389d69dc70740686986172e5ab8a Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 18 Apr 2018 17:14:53 +0200 Subject: [PATCH 054/686] After allowing lost tracks candidates without additional track information to be considered as tau charged hadrons, downgrade logger warnings about non-available tracks to info --- .../RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 3eeca80bec8e8..f2deebba0b27d 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -305,8 +305,8 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const allTracksSumP += chargedHadronTrack->p(); allTracksSumPerr2 += getTrackPerr2(*chargedHadronTrack); } else { - edm::LogWarning("PFRecoTauEnergyAlgorithmPlugin::operator()") - << "PFRecoTauChargedHadron has no associated reco::Track !!" << std::endl; + edm::LogInfo("PFRecoTauEnergyAlgorithmPlugin::operator()") + << "PFRecoTauChargedHadron has no associated reco::Track !!"; if ( verbosity_ ) { chargedHadron->print(); } @@ -427,8 +427,8 @@ void PFRecoTauEnergyAlgorithmPlugin::operator()(reco::PFTau& tau) const double chargedHadronPz_modified = scaleFactor*chargedHadronTrack->pz(); chargedHadronP4_modified = compChargedHadronP4fromPxPyPz(chargedHadronPx_modified, chargedHadronPy_modified, chargedHadronPz_modified); } else { - edm::LogWarning("PFRecoTauEnergyAlgorithmPlugin::operator()") - << "PFRecoTauChargedHadron has no associated reco::Track !!" << std::endl; + edm::LogInfo("PFRecoTauEnergyAlgorithmPlugin::operator()") + << "PFRecoTauChargedHadron has no associated reco::Track !!"; if ( verbosity_ ) { chargedHadron.print(); } From 01d1881501dc6361d2cab44b3724efc44a860562 Mon Sep 17 00:00:00 2001 From: Roger Date: Fri, 20 Apr 2018 21:15:40 +0200 Subject: [PATCH 055/686] input file had been overwritten unexpectedly during merge --- RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 0c4ddab6caa6e..e702cc489acc1 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -9,7 +9,7 @@ ###### runSignal=True #runSignal=False -maxEvents=1000 +maxEvents=100 #maxEvents=-1 # If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is @@ -55,13 +55,15 @@ if runSignal: readFiles.extend( [ - 'file:patMiniAOD_standard.root' - #'/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + #'file:patMiniAOD_standard.root' + '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + #'/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ] ) else: readFiles.extend( [ - 'file:patMiniAOD_standard.root' + #'file:patMiniAOD_standard.root' + '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', ] ) From 71ec9f0aa7d73018ea277bf4e6168777cc2d5106 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Mon, 30 Apr 2018 12:08:55 +0200 Subject: [PATCH 056/686] Address a number of code review comments --- .../RecoTau/interface/AntiElectronIDCut2.h | 2 +- .../interface/PFRecoTauClusterVariables.h | 18 +++--- ...TauChargedHadronFromGenericTrackPlugin.cc} | 14 ++--- ...coTauChargedHadronFromPFCandidatePlugin.cc | 30 ++++----- .../PFRecoTauDiscriminationAgainstElectron.cc | 2 +- ...ecoTauDiscriminationAgainstElectronMVA5.cc | 2 +- .../PFRecoTauDiscriminationAgainstMuon.cc | 2 +- .../PFRecoTauDiscriminationAgainstMuon2.cc | 61 ++++++++----------- .../PFRecoTauDiscriminationAgainstMuonMVA.cc | 2 +- ...coTauDiscriminationByLeadingObjectPtCut.cc | 29 --------- .../plugins/PFTauPrimaryVertexProducer.cc | 5 +- ....cc => RecoTauGenericJetRegionProducer.cc} | 3 +- .../TauDiscriminationAgainstCaloMuon.cc | 2 +- ...oTauDiscriminationAgainstMuonSimple_cfi.py | 35 +++++------ 14 files changed, 76 insertions(+), 131 deletions(-) rename RecoTauTag/RecoTau/plugins/{PFRecoTauChargedHadronFromTrackPlugin.cc => PFRecoTauChargedHadronFromGenericTrackPlugin.cc} (96%) rename RecoTauTag/RecoTau/plugins/{RecoTauJetRegionProducer.cc => RecoTauGenericJetRegionProducer.cc} (98%) diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h index dccf7ff8a63fc..5a48cbbd0e72b 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h @@ -179,4 +179,4 @@ class AntiElectronIDCut2 int verbosity_; }; -#endif \ No newline at end of file +#endif diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index 916189002f909..5360af55bb719 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -23,17 +23,17 @@ class TauIdMVAAuxiliaries { /// return chi2 of the leading track ==> deprecated? <== float tau_leadTrackChi2(const reco::PFTau& tau) const { float LeadingTracknormalizedChi2 = 0; - const reco::CandidatePtr& leadingPFCharged = tau.leadChargedHadrCand(); + const auto& leadingPFCharged = tau.leadPFChargedHadrCand(); if (leadingPFCharged.isNonnull()) { - const reco::PFCandidate* pfcand = dynamic_cast(leadingPFCharged.get()); - if (pfcand != nullptr) { - reco::TrackRef tref = pfcand->trackRef(); - if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = tref->normalizedChi2(); - } + reco::TrackRef tref = leadingPFCharged->trackRef(); + if (tref.isNonnull()) { + LeadingTracknormalizedChi2 = tref->normalizedChi2(); } - else { - const pat::PackedCandidate* patcand = dynamic_cast(leadingPFCharged.get()); + } + else { + const auto& leadingCharged = tau.leadChargedHadrCand(); + if (leadingCharged.isNonnull()) { + const pat::PackedCandidate* patcand = dynamic_cast(leadingCharged.get()); if (patcand != nullptr && patcand->hasTrackDetails()) { LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc similarity index 96% rename from RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc rename to RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc index 20c3c6d2cfec5..000ac0440301c 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc @@ -2,12 +2,15 @@ * PFRecoTauChargedHadronFromGenericTrackPlugin * * Build PFRecoTauChargedHadron objects - * using charged PFCandidates as input + * using tracks as input, from either collection of RECO/AOD reco::Tracks + * (PFRecoTauChargedHadronFromTrackPlugin) or from a collection of MINIAOD + * pat::PackedCandidates (PFRecoTauChargedHadronFromLostTrackPlugin), typically + * using the 'lostTracks' collection * * Author: Christian Veelken, LLR * - * inclusion of lost tracks based on - * PFRecoTauChargedHadronFromLostTrackPlugin by Michal Bluj, NCBJ, Poland + * inclusion of lost tracks based on original implementation + * by Michal Bluj, NCBJ, Poland */ #include "RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h" @@ -281,8 +284,7 @@ typename PFRecoTauChargedHadronFromGenericTrackPlugin::return_type P } std::vector neutralJetConstituents_withDistance; - std::vector jetConstituents = jet.daughterPtrVector(); - for ( const auto& jetConstituent : jetConstituents ) { + for ( const auto& jetConstituent : jet.daughterPtrVector() ) { int pdgId = jetConstituent->pdgId(); if ( !(pdgId == 130 || pdgId == 22) ) continue; double dR = deltaR(atECALEntrance(&*jetConstituent, magneticFieldStrength_.z()), chargedHadron->positionAtECALEntrance_); @@ -327,9 +329,7 @@ typename PFRecoTauChargedHadronFromGenericTrackPlugin::return_type P return output.release(); } -template class PFRecoTauChargedHadronFromGenericTrackPlugin; typedef PFRecoTauChargedHadronFromGenericTrackPlugin PFRecoTauChargedHadronFromTrackPlugin; -template class PFRecoTauChargedHadronFromGenericTrackPlugin; typedef PFRecoTauChargedHadronFromGenericTrackPlugin PFRecoTauChargedHadronFromLostTrackPlugin; }} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 5fe4b667b680d..7c95023e2e20f 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -199,22 +199,17 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF chargedHadron->chargedPFCandidate_ = (*cand); chargedHadron->addDaughter(*cand); - - // reco::PFCandidate::ParticleType chargedPFCandidateType = chargedHadron->chargedPFCandidate_->particleId(); int pdgId = std::abs(chargedHadron->chargedPFCandidate_->pdgId()); if ( chargedHadron->pt() > minMergeChargedHadronPt_ ) { - std::vector jetConstituents = jet.daughterPtrVector(); - for ( std::vector::const_iterator jetConstituent = jetConstituents.begin(); - jetConstituent != jetConstituents.end(); ++jetConstituent ) { + for (const auto& jetConstituent : jet.daughterPtrVector()) { // CV: take care of not double-counting energy in case "charged" PFCandidate is in fact a PFNeutralHadron - if ( (*jetConstituent) == chargedHadron->chargedPFCandidate_ ) continue; + if ( jetConstituent == chargedHadron->chargedPFCandidate_ ) continue; - // reco::PFCandidate::ParticleType jetConstituentType = (*jetConstituent)->particleId(); - int jetConstituentPdgId = std::abs((*jetConstituent)->pdgId()); + int jetConstituentPdgId = std::abs(jetConstituent->pdgId()); if ( !(jetConstituentPdgId == 130 || jetConstituentPdgId == 22) ) continue; - double dR = deltaR(atECALEntrance(&**jetConstituent, bField_), atECALEntrance(&*chargedHadron, bField_)); + double dR = deltaR(atECALEntrance(jetConstituent.get(), bField_), atECALEntrance(&*chargedHadron, bField_)); double dRmerge = -1.; int minBlockElementMatches = 1000; int maxUnmatchedBlockElements = 0; @@ -237,19 +232,18 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF minMergeEt = minMergeGammaEt_; } - if ((*jetConstituent)->et() > minMergeEt) { + if (jetConstituent->et() > minMergeEt) { if (dR < dRmerge) { - chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); - chargedHadron->addDaughter(*jetConstituent); + chargedHadron->neutralPFCandidates_.push_back(jetConstituent); + chargedHadron->addDaughter(jetConstituent); } else { // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact - const reco::PFCandidate* pfCHCand = dynamic_cast(&*chargedHadron->chargedPFCandidate_); - const reco::PFCandidate* pfJetConstituent = dynamic_cast(&**jetConstituent); - if (pfCHCand != nullptr && pfJetConstituent != nullptr) { - if (isMatchedByBlockElement(*pfJetConstituent, *pfCHCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) { - chargedHadron->neutralPFCandidates_.push_back(*jetConstituent); - chargedHadron->addDaughter(*jetConstituent); + const reco::PFCandidate* pfJetConstituent = dynamic_cast(jetConstituent.get()); + if (pfCand != nullptr && pfJetConstituent != nullptr) { + if (isMatchedByBlockElement(*pfJetConstituent, *pfCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) { + chargedHadron->neutralPFCandidates_.push_back(jetConstituent); + chargedHadron->addDaughter(jetConstituent); } } } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc index f8e8dbbb7cf6a..9062d88608105 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc @@ -242,4 +242,4 @@ PFRecoTauDiscriminationAgainstElectron::isInEcalCrack(double eta) const } } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron); \ No newline at end of file +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc index 00c2f1a014797..cc66700d8de4a 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc @@ -237,4 +237,4 @@ PFRecoTauDiscriminationAgainstElectronMVA5::isInEcalCrack(double eta) const return (absEta > 1.460 && absEta < 1.558); } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA5); \ No newline at end of file +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA5); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc index 6291e22e2a423..4fae057948084 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc @@ -97,4 +97,4 @@ double PFRecoTauDiscriminationAgainstMuon::discriminate(const PFTauRef& thePFTau return (decision ? 1. : 0.); } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon); \ No newline at end of file +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index 55fa3e0248961..c25cb5db1116e 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -128,17 +128,14 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p numHitsRPC[iStation] = 0; } - const reco::CandidatePtr& pfLeadChargedHadron = pfTau->leadChargedHadrCand(); + const reco::PFCandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand(); if ( pfLeadChargedHadron.isNonnull() ) { - const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); - if (pflch != nullptr) { - reco::MuonRef muonRef = pflch->muonRef(); - if ( muonRef.isNonnull() ) { - if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ; - reco::tau::countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); - reco::tau::countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; + reco::MuonRef muonRef = pfLeadChargedHadron->muonRef(); + if ( muonRef.isNonnull() ) { + if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ; + reco::tau::countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC); + reco::tau::countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC); + } } if ( !srcMuons_.label().empty() ) { @@ -151,14 +148,11 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p continue; } if ( pfLeadChargedHadron.isNonnull()) { - const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); - if (pflch != nullptr) { - reco::MuonRef muonRef = pflch->muonRef(); - if (muonRef.isNonnull() && muon == pflch->muonRef() ) { - if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; } - continue; - } - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; + reco::MuonRef muonRef = pfLeadChargedHadron->muonRef(); + if (muonRef.isNonnull() && muon == pfLeadChargedHadron->muonRef() ) { + if ( verbosity_ ) { edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it."; } + continue; + } } double dR = deltaR(muon->p4(), pfTau->p4()); double dRmatch = dRmuonMatch_; @@ -211,26 +205,21 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p bool passesCaloMuonVeto = true; if ( pfLeadChargedHadron.isNonnull() ) { - const reco::PFCandidate* pflch = dynamic_cast(pfLeadChargedHadron.get()); - if (pflch != nullptr) { - double energyECALplusHCAL = pflch->ecalEnergy() + pflch->hcalEnergy(); - if ( verbosity_ ) { - if ( pflch->trackRef().isNonnull() ) { - edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pflch->trackRef()->p() ; - } else if ( pflch->gsfTrackRef().isNonnull() ) { - edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pflch->gsfTrackRef()->p() ; - } + double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy(); + if ( verbosity_ ) { + if ( pfLeadChargedHadron->trackRef().isNonnull() ) { + edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->trackRef()->p() ; + } else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) { + edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->gsfTrackRef()->p() ; } - const reco::Track* leadTrack = nullptr; - if ( pflch->trackRef().isNonnull() ) - leadTrack = pflch->trackRef().get(); - else if ( pflch->gsfTrackRef().isNonnull() ) - leadTrack = pflch->gsfTrackRef().get(); - if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) - passesCaloMuonVeto = false; - } else { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstMuon2 only works with PFTaus made from PFCandidates. Please use PFRecoTauDiscriminationAgainstMuonSimple instead.\n"; } + const reco::Track* leadTrack = nullptr; + if ( pfLeadChargedHadron->trackRef().isNonnull() ) + leadTrack = pfLeadChargedHadron->trackRef().get(); + else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) + leadTrack = pfLeadChargedHadron->gsfTrackRef().get(); + if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) + passesCaloMuonVeto = false; } double discriminatorValue = 0.; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc index 0e4dcbac0d3ec..6d1edbe9e06ec 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc @@ -244,4 +244,4 @@ void PFRecoTauDiscriminationAgainstMuonMVA::endEvent(edm::Event& evt) } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonMVA); \ No newline at end of file +DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonMVA); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc index 24b639ecea594..452efa1f15f2d 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc @@ -51,32 +51,3 @@ double PFRecoTauDiscriminationByLeadingObjectPtCut::discriminate(const PFTauRef& } DEFINE_FWK_MODULE(PFRecoTauDiscriminationByLeadingObjectPtCut); - -/* -void PFRecoTauDiscriminationByLeadingPionPtCut::produce(edm::Event& iEvent,const edm::EventSetup& iEventSetup){ - edm::Handle thePFTauCollection; - iEvent.getByLabel(PFTauProducer_,thePFTauCollection); - - - auto thePFTauDiscriminatorByLeadingPionPtCut = std::make_unique(thePFTauCollection)); - - //loop over the PFTau candidates - for(size_t iPFTau=0;iPFTausize();++iPFTau) { - PFTauRef thePFTauRef(thePFTauCollection,iPFTau); - PFTau thePFTau=*thePFTauRef; - double theleadTrackPtCutDiscriminator = 0.; - // fill the AssociationVector object - if (!thePFTau.leadCand() || !thePFTau.leadChargedHadrCand()) - { - theleadTrackPtCutDiscriminator=0.; - } - else if(thePFTau.leadCand()->pt() > minPtLeadTrack_) theleadTrackPtCutDiscriminator=1.; - - thePFTauDiscriminatorByLeadingPionPtCut->setValue(iPFTau,theleadTrackPtCutDiscriminator); - } - - iEvent.put(std::move(thePFTauDiscriminatorByLeadingPionPtCut)); - -} - -*/ diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index ec5321a632b76..91550972e7400 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -28,9 +28,8 @@ void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRe //Find non-tau tracks associated to thePV for(reco::Vertex::trackRef_iterator vtxTrkRef=thePVRef->tracks_begin();vtxTrkRef!=thePVRef->tracks_end();vtxTrkRef++){ bool matched = false; - edm::Ptr vtxTrkPtr = edm::refToPtr((*vtxTrkRef).castTo > >()); - for(const auto& tauTrack: tauTracks){ - if( vtxTrkPtr == tauTrack ) { + for(const auto& tauTrack : tauTracks){ + if (tauTrack.id() == vtxTrkRef->id() && tauTrack.key() == vtxTrkRef->key()) { matched = true; break; } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc similarity index 98% rename from RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc rename to RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc index 01d92d2318df6..70cfd106bde90 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc @@ -209,9 +209,8 @@ void RecoTauGenericJetRegionProducer::produce(edm::Event& evt } evt.put(std::move(matching)); } -template class RecoTauGenericJetRegionProducer; + typedef RecoTauGenericJetRegionProducer RecoTauJetRegionProducer; -template class RecoTauGenericJetRegionProducer; typedef RecoTauGenericJetRegionProducer RecoTauPatJetRegionProducer; #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc index 86ad7d76b4ea6..98654730b7ace 100644 --- a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc +++ b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc @@ -308,4 +308,4 @@ typedef TauDiscriminationAgainstCaloMuon PFRecoTauDis typedef TauDiscriminationAgainstCaloMuon CaloRecoTauDiscriminationAgainstCaloMuon; DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstCaloMuon); -DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstCaloMuon); \ No newline at end of file +DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstCaloMuon); diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py index 0d6df96aed3f9..e4e34b505a1fa 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py @@ -2,27 +2,20 @@ from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByLooseMuonRejection3, hpsPFTauDiscriminationByTightMuonRejection3 -hpsPFTauDiscriminationByLooseMuonRejectionSimple = cms.EDProducer("PFRecoTauDiscriminationAgainstMuonSimple", - PFTauProducer = cms.InputTag("hpsPFTauProducer"), - Prediscriminants = hpsPFTauDiscriminationByLooseMuonRejection3.Prediscriminants, - HoPMin = cms.double(0.1), #use smaller value that with AOD as raw energy is used - doCaloMuonVeto = cms.bool(False), #do not use it until tuned - srcPatMuons = cms.InputTag("slimmedMuons"), - minPtMatchedMuon = hpsPFTauDiscriminationByLooseMuonRejection3.minPtMatchedMuon, - dRmuonMatch = hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatch, - dRmuonMatchLimitedToJetArea = hpsPFTauDiscriminationByLooseMuonRejection3.dRmuonMatchLimitedToJetArea, - maskHitsCSC = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsCSC, - maskHitsDT = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsDT, - maskHitsRPC = hpsPFTauDiscriminationByLooseMuonRejection3.maskHitsRPC, - maxNumberOfHitsLast2Stations = hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfHitsLast2Stations, - maskMatchesCSC = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesCSC, - maskMatchesDT = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesDT, - maskMatchesRPC = hpsPFTauDiscriminationByLooseMuonRejection3.maskMatchesRPC, - maxNumberOfMatches = hpsPFTauDiscriminationByLooseMuonRejection3.maxNumberOfMatches, - maxNumberOfSTAMuons = cms.int32(-1), - maxNumberOfRPCMuons = cms.int32(-1), - verbosity = cms.int32(0) -) +hpsPFTauDiscriminationByLooseMuonRejectionSimple2 = hpsPFTauDiscriminationByLooseMuonRejection3.clone( + PFTauProducer=cms.InputTag("hpsPFTauProducer"), + HoPMin=cms.double(0.1), #use smaller value than with AOD as raw energy is used + doCaloMuonVeto=cms.bool(False), #do not use it until tuned + srcPatMuons=cms.InputTag("slimmedMuons"), + maxNumberOfSTAMuons=cms.int32(-1), + maxNumberOfRPCMuons=cms.int32(-1) + ) + +hpsPFTauDiscriminationByLooseMuonRejectionSimple2.__dict__['_TypedParameterizable__type'] = "PFRecoTauDiscriminationAgainstMuonSimple" + +for attr in ['discriminatorOption', 'srcMuons']: + delattr(hpsPFTauDiscriminationByLooseMuonRejectionSimple2, attr) + hpsPFTauDiscriminationByTightMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejectionSimple.clone( maxNumberOfHitsLast2Stations = hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations From c7d6c563a9085bc0bed8ed522788987ddf0f7d6e Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 2 May 2018 10:46:34 +0200 Subject: [PATCH 057/686] Cache also single-PFCandidate returns, and address other review comments --- DataFormats/TauReco/interface/PFTau.h | 6 +++- DataFormats/TauReco/src/PFTau.cc | 32 ++++++++++--------- DataFormats/TauReco/src/classes_def_2.xml | 3 ++ .../python/tools/adaptToRunAtMiniAOD.py | 2 +- .../src/HLTPFTauPairLeadTrackDzMatchFilter.cc | 2 +- .../RecoTau/interface/RecoTauConstructor.h | 2 -- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 12 +++---- .../PFTauMiniAODPrimaryVertexProducer.cc | 2 +- .../plugins/RecoTauElectronRejectionPlugin.cc | 2 +- ...scriminationByAMuonRejectionSimple_cff.py} | 0 RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc | 2 +- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 32 +++++-------------- RecoTauTag/RecoTau/src/RecoTauMuonTools.cc | 2 +- RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc | 2 +- .../RecoTau/test/rerunTauRecoOnMiniAOD.py | 4 +-- .../TauTagTools/src/PFTauElementsOperators.cc | 6 ++-- RecoTauTag/TauTagTools/src/TauTagTools.cc | 9 ++---- 17 files changed, 53 insertions(+), 67 deletions(-) rename RecoTauTag/RecoTau/python/{PFRecoTauDiscriminationAgainstMuonSimple_cfi.py => hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py} (100%) diff --git a/DataFormats/TauReco/interface/PFTau.h b/DataFormats/TauReco/interface/PFTau.h index 32803d600c92a..65f0f8fb2f902 100644 --- a/DataFormats/TauReco/interface/PFTau.h +++ b/DataFormats/TauReco/interface/PFTau.h @@ -276,7 +276,11 @@ class PFTau : public BaseTau { std::vector selectedIsolationNeutrHadrCands_; std::vector selectedIsolationGammaCands_; - // Caches for PFCandidate-based accessors + // Transient caches for PFCandidate-based accessors + edm::AtomicPtrCache leadPFChargedHadrCand_; + edm::AtomicPtrCache leadPFNeutralCand_; + edm::AtomicPtrCache leadPFCand_; + edm::AtomicPtrCache > selectedTransientSignalPFCands_; edm::AtomicPtrCache > selectedTransientSignalPFChargedHadrCands_; edm::AtomicPtrCache > selectedTransientSignalPFNeutrHadrCands_; diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index e865af739e8c1..05e2e0fd60fa9 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -122,12 +122,14 @@ namespace { oCache.set( std::make_unique(std::move(iFrom))); } - reco::PFCandidatePtr convertToPFPtr(const reco::CandidatePtr& ptr) { - const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); - if (pf_cand != nullptr) { - return edm::Ptr(ptr); - } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access a PFCandidate.\n"; - return reco::PFCandidatePtr(); + std::unique_ptr convertToPFPtr(const reco::CandidatePtr& ptr) { + if (ptr.isNonnull()) { + const reco::PFCandidate* pf_cand = dynamic_cast(&*ptr); + if (pf_cand != nullptr) { + return std::unique_ptr(new reco::PFCandidatePtr(ptr)); + } else throw cms::Exception("Type Mismatch") << "This PFTau was not made from PFCandidates, but it is being tried to access a PFCandidate.\n"; + } + return std::unique_ptr(new reco::PFCandidatePtr()); } std::unique_ptr > convertToPFPtrs(const std::vector& cands) { @@ -150,21 +152,21 @@ namespace { } const PFCandidatePtr PFTau::leadPFChargedHadrCand() const { - if (leadChargedHadrCand_.isNonnull()) - return convertToPFPtr(leadChargedHadrCand_); - return PFCandidatePtr(); + if (!leadPFChargedHadrCand_.isSet()) + leadPFChargedHadrCand_.set(std::move(convertToPFPtr(leadChargedHadrCand_))); + return *leadPFChargedHadrCand_; } const PFCandidatePtr PFTau::leadPFNeutralCand() const { - if (leadNeutralCand_.isNonnull()) - return convertToPFPtr(leadNeutralCand_); - return PFCandidatePtr(); + if (!leadPFNeutralCand_.isSet()) + leadPFNeutralCand_.set(std::move(convertToPFPtr(leadNeutralCand_))); + return *leadPFNeutralCand_; } const PFCandidatePtr PFTau::leadPFCand() const { - if (leadCand_.isNonnull()) - return convertToPFPtr(leadCand_); - return PFCandidatePtr(); + if (!leadPFCand_.isSet()) + leadPFCand_.set(std::move(convertToPFPtr(leadCand_))); + return *leadPFCand_; } const std::vector& PFTau::signalPFCands() const { diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index f4c4c946db843..41e06684bc960 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -2,6 +2,9 @@ + + + diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index 53aa247a9447c..ef9bbde729194 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -153,7 +153,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.miniAODTausTask.remove(getattr(process, moduleName)) # Instead add against-mu discriminants which are MiniAOD compatible - from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonSimple_cfi import hpsPFTauDiscriminationByLooseMuonRejectionSimple, hpsPFTauDiscriminationByTightMuonRejectionSimple + from RecoTauTag.RecoTau.hpsPFTauDiscriminationByAMuonRejectionSimple_cff import hpsPFTauDiscriminationByLooseMuonRejectionSimple, hpsPFTauDiscriminationByTightMuonRejectionSimple process.hpsPFTauDiscriminationByLooseMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejectionSimple process.hpsPFTauDiscriminationByTightMuonRejectionSimple = hpsPFTauDiscriminationByTightMuonRejectionSimple diff --git a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc index b3b3a8fe81bf9..9b748f28200ed 100644 --- a/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc +++ b/RecoTauTag/HLTProducers/src/HLTPFTauPairLeadTrackDzMatchFilter.cc @@ -111,4 +111,4 @@ bool HLTPFTauPairLeadTrackDzMatchFilter::hltFilter(edm::Event& ev, const edm::Ev // return truth if at least one good pair found return npairs>0; -} \ No newline at end of file +} diff --git a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h index e03a9bd228929..87319ad1f56f5 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauConstructor.h +++ b/RecoTauTag/RecoTau/interface/RecoTauConstructor.h @@ -81,7 +81,6 @@ class RecoTauConstructor { } /// Append a PFCandidateRef/Ptr to a given collection - // void addPFCand(Region region, ParticleType type, const CandidateRef& ref, bool skipAddToP4 = false); void addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4 = false); /// Reserve a set amount of space for a given RefVector @@ -154,7 +153,6 @@ class RecoTauConstructor { // Helper functions for dealing with refs CandidatePtr convertToPtr(const PFCandidatePtr& pfPtr) const; CandidatePtr convertToPtr(const CandidatePtr& candPtr) const; - // CandidatePtr convertToPtr(const PFCandidateRef& pfRef) const; const edm::Handle >& pfCands_; std::auto_ptr tau_; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 15e641cec2348..d9a15163028e4 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -147,11 +147,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); - const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); + const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand(); bool hasGsfTrack = false; - if (lpfch != nullptr) { + if (lpfch.isNonnull()) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; + } if ( !hasGsfTrack ) hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); @@ -189,11 +189,11 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& if ( !isGsfElectronMatched ) { mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); - const reco::PFCandidate* lpfch = dynamic_cast(thePFTauRef->leadChargedHadrCand().get()); + const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand(); bool hasGsfTrack = false; - if (lpfch != nullptr) { + if (lpfch.isNonnull()) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and PFRecoTauDiscriminationAgainstElectronMVA6 only works with PFTaus made from PFCandidates."; + } //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index cf36d45d724e1..cee8fa267fdf6 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -77,7 +77,7 @@ void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const si bool matched = false; for(const auto& tauTrack: tauTracks){ if(std::abs(tauTrack->eta()-track->eta())<0.005 - && deltaPhi(tauTrack->phi(),track->phi())<0.005 + && std::abs(deltaPhi(tauTrack->phi(),track->phi()))<0.005 && std::abs(tauTrack->pt()/track->pt()-1.)<0.005 ){ matched = true; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc index 1a2581459a1cd..855dcd635a54a 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauElectronRejectionPlugin.cc @@ -223,4 +223,4 @@ void RecoTauElectronRejectionPlugin::operator()(PFTau& tau) const { #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory, reco::tau::RecoTauElectronRejectionPlugin, - "RecoTauElectronRejectionPlugin"); \ No newline at end of file + "RecoTauElectronRejectionPlugin"); diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py b/RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py similarity index 100% rename from RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonSimple_cfi.py rename to RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc index 09ab19c4692ea..16cd819603b08 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA5.cc @@ -1079,4 +1079,4 @@ double AntiElectronIDMVA5::dCrackEta(double eta) } return std::abs(retVal); -} \ No newline at end of file +} diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 90af59f8ac183..de3c8485341cb 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -553,12 +553,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadChargedHadrCand()->p() > 0. ) { - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); - if (pflch != nullptr) { - TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); - TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; + if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { + TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); } std::vector GammasdEtaInSigCone; @@ -642,12 +639,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); - Float_t TauHasGsf = false; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); - if (pflch != nullptr) { - TauHasGsf = pflch->gsfTrackRef().isNonnull(); - } else { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } + Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); // === electron variables === Float_t ElecEta = theGsfEle.eta(); @@ -773,12 +765,9 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.); Float_t TauLeadPFChargedHadrHoP = 0.; Float_t TauLeadPFChargedHadrEoP = 0.; - if ( thePFTau.leadChargedHadrCand()->p() > 0. ) { - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); - if (pflch != nullptr) { - TauLeadPFChargedHadrHoP = pflch->hcalEnergy()/pflch->p(); - TauLeadPFChargedHadrEoP = pflch->ecalEnergy()/pflch->p(); - } else { throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } + if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) { + TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); + TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p(); } std::vector GammasdEtaInSigCone; @@ -862,12 +851,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc } Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance); Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance); - Float_t TauHasGsf = false; - const reco::PFCandidate* pflch = dynamic_cast(thePFTau.leadChargedHadrCand().get()); - if (pflch != nullptr) { - TauHasGsf = pflch->gsfTrackRef().isNonnull(); - } else { - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this algorithm was not yet updated to cope with PFTaus made from other Candidates.\n"; } + Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull(); // === electron variables === diff --git a/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc b/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc index 8a75d06eb2bec..38aaceb4ba6ff 100644 --- a/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc +++ b/RecoTauTag/RecoTau/src/RecoTauMuonTools.cc @@ -50,4 +50,4 @@ namespace reco { namespace tau { } } -}} // end namespace reco::tau \ No newline at end of file +}} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc index bf98ccc851755..915de084c23b9 100644 --- a/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc +++ b/RecoTauTag/RecoTau/src/RecoTauQualityCuts.cc @@ -574,4 +574,4 @@ void RecoTauQualityCuts::setLeadTrack(const reco::CandidateRef& leadCand) const } } -}} // end namespace reco::tau \ No newline at end of file +}} // end namespace reco::tau diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 635914f9beca8..60ae566f68889 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -55,8 +55,8 @@ if runSignal: readFiles.extend( [ - 'file:patMiniAOD_standard.root' - # 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', + # 'file:patMiniAOD_standard.root' + 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ] ) else: diff --git a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc index 4a11d6085c4bc..de69230079d7b 100644 --- a/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc +++ b/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc @@ -145,10 +145,8 @@ std::pair, std::vector> PFTa std::vector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector& myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{ std::vector filteredPFChargedHadrCands; for(std::vector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){ - const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); - if (pfcand != nullptr) { - TrackRef PFChargedHadrCand_track = pfcand->trackRef(); - if (!PFChargedHadrCand_track)continue; + const reco::Track* PFChargedHadrCand_track = (*iPFCand)->bestTrack(); + if (PFChargedHadrCand_track != nullptr) { if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; } diff --git a/RecoTauTag/TauTagTools/src/TauTagTools.cc b/RecoTauTag/TauTagTools/src/TauTagTools.cc index 80e8ee3163888..a41de426342ff 100644 --- a/RecoTauTag/TauTagTools/src/TauTagTools.cc +++ b/RecoTauTag/TauTagTools/src/TauTagTools.cc @@ -107,14 +107,11 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); - if (pfcand != nullptr) { - TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); - - if (!PFChargedHadrCand_rectk)continue; + const reco::Track* PFChargedHadrCand_rectk = (*iPFCand)->bestTrack(); + if (PFChargedHadrCand_rectk != nullptr) { if ( (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn ) filteredPFChargedHadrCands.push_back(*iPFCand); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } } } return filteredPFChargedHadrCands; From 7289b39b5a86352d021746faf2dbb845463eb2e1 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 3 May 2018 11:17:12 +0200 Subject: [PATCH 058/686] Update configuration for tau reconstruction at MiniAOD, and revert to previous logic in tau MVA evaluation --- .../interface/PFRecoTauClusterVariables.h | 18 +-- ...RecoTauDiscriminationByMVAIsolationRun2.cc | 5 +- ...iscriminationByAMuonRejectionSimple_cff.py | 8 +- .../RecoTau/test/rerunTauRecoOnMiniAOD.py | 110 +++++++++--------- 4 files changed, 72 insertions(+), 69 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index 5360af55bb719..a0286df1abd62 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -23,17 +23,17 @@ class TauIdMVAAuxiliaries { /// return chi2 of the leading track ==> deprecated? <== float tau_leadTrackChi2(const reco::PFTau& tau) const { float LeadingTracknormalizedChi2 = 0; - const auto& leadingPFCharged = tau.leadPFChargedHadrCand(); + const reco::CandidatePtr& leadingPFCharged = tau.leadChargedHadrCand(); if (leadingPFCharged.isNonnull()) { - reco::TrackRef tref = leadingPFCharged->trackRef(); - if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = tref->normalizedChi2(); + const reco::PFCandidate* pfcand = dynamic_cast(leadingPFCharged.get()); + if (pfcand != nullptr) { + reco::TrackRef tref = pfcand->trackRef(); + if (tref.isNonnull()) { + LeadingTracknormalizedChi2 = tref->normalizedChi2(); + } } - } - else { - const auto& leadingCharged = tau.leadChargedHadrCand(); - if (leadingCharged.isNonnull()) { - const pat::PackedCandidate* patcand = dynamic_cast(leadingCharged.get()); + else { + const pat::PackedCandidate* patcand = dynamic_cast(leadingPFCharged.get()); if (patcand != nullptr && patcand->hasTrackDetails()) { LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); } diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc index 41f0e2fa54ff7..afdfe088b6195 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc @@ -224,7 +224,6 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t float ptWeightedDphiStrip = clusterVariables_.tau_pt_weighted_dphi_strip(*tau, tauDecayMode); float ptWeightedDrSignal = clusterVariables_.tau_pt_weighted_dr_signal(*tau, tauDecayMode); float ptWeightedDrIsolation = clusterVariables_.tau_pt_weighted_dr_iso(*tau, tauDecayMode); - float leadingTrackChi2 = clusterVariables_.tau_leadTrackChi2(*tau); float eRatio = clusterVariables_.tau_Eratio(*tau); // Difference between measured and maximally allowed Gottfried-Jackson angle @@ -275,7 +274,7 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t mvaInput_[9] = std::min(0.5f, ptWeightedDphiStrip); mvaInput_[10] = std::min(0.5f, ptWeightedDrSignal); mvaInput_[11] = std::min(0.5f, ptWeightedDrIsolation); - mvaInput_[12] = std::min(100.f, leadingTrackChi2); + mvaInput_[12] = std::min(100.f, clusterVariables_.tau_leadTrackChi2(*tau)); mvaInput_[13] = std::min(1.f, eRatio); mvaInput_[14] = std::copysign(+1.f, (float)tauLifetimeInfo.dxy()); mvaInput_[15] = std::sqrt(std::min(1.f, std::abs((float)tauLifetimeInfo.dxy()))); @@ -299,7 +298,7 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t mvaInput_[9] = std::min(0.5f, ptWeightedDphiStrip); mvaInput_[10] = std::min(0.5f, ptWeightedDrSignal); mvaInput_[11] = std::min(0.5f, ptWeightedDrIsolation); - mvaInput_[12] = std::min(100.f, leadingTrackChi2); + mvaInput_[12] = std::min(100.f, clusterVariables_.tau_leadTrackChi2(*tau)); mvaInput_[13] = std::min(1.f, eRatio); mvaInput_[14] = std::copysign(+1.f, (float)tauLifetimeInfo.dxy()); mvaInput_[15] = std::sqrt(std::min(1.f, std::abs((float)tauLifetimeInfo.dxy()))); diff --git a/RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py b/RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py index e4e34b505a1fa..2a984a5072de4 100644 --- a/RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py +++ b/RecoTauTag/RecoTau/python/hpsPFTauDiscriminationByAMuonRejectionSimple_cff.py @@ -2,7 +2,7 @@ from RecoTauTag.Configuration.HPSPFTaus_cff import hpsPFTauDiscriminationByLooseMuonRejection3, hpsPFTauDiscriminationByTightMuonRejection3 -hpsPFTauDiscriminationByLooseMuonRejectionSimple2 = hpsPFTauDiscriminationByLooseMuonRejection3.clone( +hpsPFTauDiscriminationByLooseMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejection3.clone( PFTauProducer=cms.InputTag("hpsPFTauProducer"), HoPMin=cms.double(0.1), #use smaller value than with AOD as raw energy is used doCaloMuonVeto=cms.bool(False), #do not use it until tuned @@ -11,12 +11,12 @@ maxNumberOfRPCMuons=cms.int32(-1) ) -hpsPFTauDiscriminationByLooseMuonRejectionSimple2.__dict__['_TypedParameterizable__type'] = "PFRecoTauDiscriminationAgainstMuonSimple" +hpsPFTauDiscriminationByLooseMuonRejectionSimple.__dict__['_TypedParameterizable__type'] = "PFRecoTauDiscriminationAgainstMuonSimple" for attr in ['discriminatorOption', 'srcMuons']: - delattr(hpsPFTauDiscriminationByLooseMuonRejectionSimple2, attr) + delattr(hpsPFTauDiscriminationByLooseMuonRejectionSimple, attr) hpsPFTauDiscriminationByTightMuonRejectionSimple = hpsPFTauDiscriminationByLooseMuonRejectionSimple.clone( - maxNumberOfHitsLast2Stations = hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations + maxNumberOfHitsLast2Stations=hpsPFTauDiscriminationByTightMuonRejection3.maxNumberOfHitsLast2Stations ) diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 60ae566f68889..b959201edfa98 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -7,64 +7,67 @@ ###### ###### -runSignal=True -#runSignal=False -maxEvents=1000 -#maxEvents=-1 +runSignal = True +# runSignal=False +maxEvents = 100 +# maxEvents=-1 -# If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is +# If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is # built to seed taus (as at RECO), otherwise standard slimmedJets are used -reclusterJets=True -#reclusterJets=False +reclusterJets = True +# reclusterJets = False -#set true for upgrade studies -phase2=False -#phase2=True +# set true for upgrade studies +phase2 = False +# phase2 = True -#Output mode -outMode = 0 #store original MiniAOD and new selectedPatTaus -#outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) +# Output mode +outMode = 0 # store original MiniAOD and new selectedPatTaus +# outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) print 'Running Tau reco&id with MiniAOD inputs:' print '\t Run on signal:', runSignal print '\t Recluster jets:', reclusterJets print '\t Use Phase2 settings:', phase2 print '\t Output mode:', outMode - + ##### from Configuration.StandardSequences.Eras import eras era = eras.Run2_2017 if phase2: - era = eras.Phase2_timing -process = cms.Process("TAURECO",era) -process.load("Configuration.StandardSequences.MagneticField_cff") # for CH reco + era = eras.Phase2_timing +process = cms.Process("TAURECO", era) +# for CH reco +process.load("Configuration.StandardSequences.MagneticField_cff") if not phase2: - process.load("Configuration.Geometry.GeometryRecoDB_cff") + process.load("Configuration.Geometry.GeometryRecoDB_cff") else: - process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') + process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') ##### readFiles = cms.untracked.vstring() -secFiles = cms.untracked.vstring() -process.source = cms.Source ("PoolSource",fileNames = readFiles, secondaryFileNames = secFiles) +secFiles = cms.untracked.vstring() +process.source = cms.Source( + "PoolSource", fileNames=readFiles, secondaryFileNames=secFiles) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(maxEvents) + input=cms.untracked.int32(maxEvents) ) print '\t Max events:', process.maxEvents.input.value() if runSignal: - readFiles.extend( [ - # 'file:patMiniAOD_standard.root' - 'root://cms-xrd-global.cern.ch////store/relval/CMSSW_10_1_0/RelValZTT_13/MINIAODSIM/101X_upgrade2018_realistic_v6_resub-v1/10000/AE5162C1-0A38-E811-9FCA-0CC47A4D7634.root', - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', - ] ) + readFiles.extend([ + #'file:patMiniAOD_standard.root' + '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', + ]) else: - readFiles.extend( [ - 'file:patMiniAOD_standard.root' - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', - ] ) + readFiles.extend([ + #'file:patMiniAOD_standard.root' + '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', + #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', + ]) ##### import RecoTauTag.Configuration.tools.adaptToRunAtMiniAOD as tauAtMiniTools @@ -76,23 +79,24 @@ process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag if not phase2: - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' else: - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + process.GlobalTag = GlobalTag( + process.GlobalTag, 'auto:phase2_realistic', '') ##### -#mode = 0: store original MiniAOD and new selectedPatTaus -#mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) +# mode = 0: store original MiniAOD and new selectedPatTaus +# mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) process.output = tauAtMiniTools.setOutputModule(mode=outMode) if runSignal: - process.output.fileName='miniAOD_TauReco_ggH.root' - if reclusterJets: - process.output.fileName='miniAOD_TauReco_ak4PFJets_ggH.root' + process.output.fileName = 'miniAOD_TauReco_ggH.root' + if reclusterJets: + process.output.fileName = 'miniAOD_TauReco_ak4PFJets_ggH.root' else: - process.output.fileName='miniAOD_TauReco_QCD.root' - if reclusterJets: - process.output.fileName='miniAOD_TauReco_ak4PFJets_QCD.root' + process.output.fileName = 'miniAOD_TauReco_QCD.root' + if reclusterJets: + process.output.fileName = 'miniAOD_TauReco_ak4PFJets_QCD.root' process.out = cms.EndPath(process.output) ##### @@ -100,20 +104,20 @@ ##### process.load('FWCore.MessageService.MessageLogger_cfi') -if process.maxEvents.input.value()>10: - process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10 -if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0: - process.MessageLogger.cerr.FwkReport.reportEvery = 1000 +if process.maxEvents.input.value() > 10: + process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10 +if process.maxEvents.input.value() > 10000 or process.maxEvents.input.value() < 0: + process.MessageLogger.cerr.FwkReport.reportEvery = 1000 ##### process.options = cms.untracked.PSet( ) -process.options.numberOfThreads=cms.untracked.uint32(4) -#process.options.numberOfThreads=cms.untracked.uint32(1) -process.options.numberOfStreams=cms.untracked.uint32(0) -print '\t No. of threads:', process.options.numberOfThreads.value(),', no. of streams:',process.options.numberOfStreams.value() +process.options.numberOfThreads = cms.untracked.uint32(4) +# process.options.numberOfThreads=cms.untracked.uint32(1) +process.options.numberOfStreams = cms.untracked.uint32(0) +print '\t No. of threads:', process.options.numberOfThreads.value(), ', no. of streams:', process.options.numberOfStreams.value() process.options = cms.untracked.PSet( - process.options, - wantSummary = cms.untracked.bool(True) + process.options, + wantSummary=cms.untracked.bool(True) ) From af45120e01f547fe039cb8febdef06860cac5c65 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 3 May 2018 14:25:48 +0200 Subject: [PATCH 059/686] Avoid casts to PFCandidate --- .../interface/RecoTauIsolationMasking.h | 2 +- .../RecoTau/src/RecoTauIsolationMasking.cc | 7 ++----- RecoTauTag/TauTagTools/src/TauTagTools.cc | 18 ++++++------------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h b/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h index 86358e8cba1c8..aafaaac1eb804 100644 --- a/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h +++ b/RecoTauTag/RecoTau/interface/RecoTauIsolationMasking.h @@ -38,7 +38,7 @@ class RecoTauIsolationMasking { // Get the energy resoltuion of a gamma or h0 candidate double resolution(const reco::Candidate& cand) const; // Check if the candidate is in the correct cone - bool inCone(const reco::Candidate& track, + bool inCone(const reco::PFCandidate& track, const reco::Candidate& cand) const; double ecalCone_; diff --git a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc index eb33d1d830599..c65bf64435dc3 100644 --- a/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc +++ b/RecoTauTag/RecoTau/src/RecoTauIsolationMasking.cc @@ -160,12 +160,9 @@ double RecoTauIsolationMasking::resolution( return -1; } -bool RecoTauIsolationMasking::inCone(const reco::Candidate& track, +bool RecoTauIsolationMasking::inCone(const reco::PFCandidate& track, const reco::Candidate& cand) const { - const reco::PFCandidate* pf_track = dynamic_cast(&track); - if (pf_track == nullptr) - throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; - double openingDR = reco::deltaR(pf_track->positionAtECALEntrance(), cand.p4()); + double openingDR = reco::deltaR(track.positionAtECALEntrance(), cand.p4()); if (cand.pdgId() == 130) { return (openingDR < hcalCone_); } else if (cand.pdgId() == 22 || diff --git a/RecoTauTag/TauTagTools/src/TauTagTools.cc b/RecoTauTag/TauTagTools/src/TauTagTools.cc index a41de426342ff..061902db99227 100644 --- a/RecoTauTag/TauTagTools/src/TauTagTools.cc +++ b/RecoTauTag/TauTagTools/src/TauTagTools.cc @@ -1,5 +1,4 @@ #include "RecoTauTag/TauTagTools/interface/TauTagTools.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" using namespace reco; using std::string; @@ -122,18 +121,15 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); - if (pfcand != nullptr) { - TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); - - if (!PFChargedHadrCand_rectk)continue; + const reco::Track* PFChargedHadrCand_rectk = (*iPFCand)->bestTrack(); + if (PFChargedHadrCand_rectk != nullptr) { if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && (*PFChargedHadrCand_rectk).numberOfValidHits()>=ChargedHadrCand_tkminTrackerHitsn && (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn) filteredPFChargedHadrCands.push_back(*iPFCand); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } } } return filteredPFChargedHadrCands; @@ -144,10 +140,8 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ for(std::vector::const_iterator iPFCand=theInitialPFCands.begin();iPFCand!=theInitialPFCands.end();iPFCand++){ if (std::abs((*iPFCand)->pdgId()) == 211 || std::abs((*iPFCand)->pdgId()) == 13 || std::abs((*iPFCand)->pdgId()) == 11){ // *** Whether the charged hadron candidate will be selected or not depends on its rec. tk properties. - const reco::PFCandidate* pfcand = dynamic_cast(iPFCand->get()); - if (pfcand != nullptr) { - TrackRef PFChargedHadrCand_rectk = pfcand->trackRef(); - if (!PFChargedHadrCand_rectk)continue; + const reco::Track* PFChargedHadrCand_rectk = (*iPFCand)->bestTrack(); + if (PFChargedHadrCand_rectk != nullptr) { if ((*PFChargedHadrCand_rectk).pt()>=ChargedHadrCand_tkminPt && (*PFChargedHadrCand_rectk).normalizedChi2()<=ChargedHadrCand_tkmaxChi2 && fabs((*PFChargedHadrCand_rectk).dxy(pv.position()))<=ChargedHadrCand_tkmaxipt && @@ -155,7 +149,7 @@ void replaceSubStr(string& s,const string& oldSubStr,const string& newSubStr){ (*PFChargedHadrCand_rectk).hitPattern().numberOfValidPixelHits()>=ChargedHadrCand_tkminPixelHitsn && fabs((*PFChargedHadrCand_rectk).dz(pv.position()))<=ChargedHadrCand_tktorefpointmaxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } } } return filteredPFChargedHadrCands; From cd2db40bcf3c2ecc93da282e30e3395824d0af56 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Thu, 3 May 2018 14:48:30 +0200 Subject: [PATCH 060/686] Remove PF from local variable name --- RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h index a0286df1abd62..32fc8b85315cb 100644 --- a/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h +++ b/RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h @@ -23,9 +23,9 @@ class TauIdMVAAuxiliaries { /// return chi2 of the leading track ==> deprecated? <== float tau_leadTrackChi2(const reco::PFTau& tau) const { float LeadingTracknormalizedChi2 = 0; - const reco::CandidatePtr& leadingPFCharged = tau.leadChargedHadrCand(); - if (leadingPFCharged.isNonnull()) { - const reco::PFCandidate* pfcand = dynamic_cast(leadingPFCharged.get()); + const reco::CandidatePtr& leadingCharged = tau.leadChargedHadrCand(); + if (leadingCharged.isNonnull()) { + const reco::PFCandidate* pfcand = dynamic_cast(leadingCharged.get()); if (pfcand != nullptr) { reco::TrackRef tref = pfcand->trackRef(); if (tref.isNonnull()) { @@ -33,7 +33,7 @@ class TauIdMVAAuxiliaries { } } else { - const pat::PackedCandidate* patcand = dynamic_cast(leadingPFCharged.get()); + const pat::PackedCandidate* patcand = dynamic_cast(leadingCharged.get()); if (patcand != nullptr && patcand->hasTrackDetails()) { LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); } From 562377426f381b56a151a57d2557af7bbf51d87e Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Fri, 11 May 2018 17:01:06 +0200 Subject: [PATCH 061/686] Add I/O directives for new transient data members, and update to more appropriate error message --- DataFormats/TauReco/src/classes_def_2.xml | 95 +++++++++++++++++++ .../TauTagTools/src/PFTauElementsOperators.cc | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 41e06684bc960..29d201be98fbd 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -241,9 +241,104 @@ for(auto const& ref : onfile.selectedIsolationPFGammaCands_) { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PFTauElementsOperators::PFChargedHadrCandsInAnnu const reco::Track* PFChargedHadrCand_track = (*iPFCand)->bestTrack(); if (PFChargedHadrCand_track != nullptr) { if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand); - } else throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n"; + } else throw cms::Exception("Missing information") << "No associated track information is saved in charged hadron candidate.\n"; } std::vector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt); return theFilteredPFCandsInAnnulus; From 0647e3e926b99fc672ac50de6f5af867a0730abc Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 7 Sep 2018 13:45:42 +0200 Subject: [PATCH 062/686] update to adjust with changes for tauRecoAtMini --- .../RecoTau/src/PFRecoTauClusterVariables.cc | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc index 25698bae7c227..97d0d31560b5c 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc @@ -1,7 +1,7 @@ #include "RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h" namespace { - struct PFTau_traits{ typedef reco::PFTau Tau_t; typedef const std::vector& Ret_t; }; + struct PFTau_traits{ typedef reco::PFTau Tau_t; typedef const std::vector& Ret_t; }; struct PATTau_traits{ typedef pat::Tau Tau_t; typedef reco::CandidatePtrVector Ret_t; }; template @@ -10,11 +10,11 @@ namespace { } /// return pf photon candidates that are associated to signal template<> - const std::vector& getGammas_T(const reco::PFTau& tau, bool signal) { + const std::vector& getGammas_T(const reco::PFTau& tau, bool signal) { if (signal){ - return tau.signalPFGammaCands(); + return tau.signalGammaCands(); } - return tau.isolationPFGammaCands(); + return tau.isolationGammaCands(); } template<> @@ -44,11 +44,20 @@ namespace reco { namespace tau { /// return chi2 of the leading track ==> deprecated? <== float lead_track_chi2(const reco::PFTau& tau) { float LeadingTracknormalizedChi2 = 0; - const reco::PFCandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand() ; - if (leadingPFCharged.isNonnull()) { - reco::TrackRef tref = leadingPFCharged -> trackRef(); - if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2()); + const reco::CandidatePtr& leadingCharged = tau.leadChargedHadrCand(); + if (leadingCharged.isNonnull()) { + const reco::PFCandidate* pfcand = dynamic_cast(leadingCharged.get()); + if (pfcand != nullptr) { + reco::TrackRef tref = pfcand->trackRef(); + if (tref.isNonnull()) { + LeadingTracknormalizedChi2 = tref->normalizedChi2(); + } + } + else { + const pat::PackedCandidate* patcand = dynamic_cast(leadingCharged.get()); + if (patcand != nullptr && patcand->hasTrackDetails()) { + LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); + } } } return LeadingTracknormalizedChi2; @@ -57,13 +66,17 @@ namespace reco { namespace tau { float eratio(const reco::PFTau& tau) { float ecal_en_in_signal_pf_cands = 0; float hcal_en_in_signal_pf_cands = 0; - for (const auto& signal_cand : tau.signalPFCands()) { - ecal_en_in_signal_pf_cands += signal_cand->ecalEnergy(); - hcal_en_in_signal_pf_cands += signal_cand->hcalEnergy(); + for (const auto& icand : tau.signalCands()) { + const reco::PFCandidate* pfcand = dynamic_cast(icand.get()); + if (pfcand != nullptr) { + ecal_en_in_signal_pf_cands += icand->ecalEnergy(); + hcal_en_in_signal_pf_cands += icand->hcalEnergy(); + } + // TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content } float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands; - if(total==0){ - return -1; + if(total == 0.){ + return -1.; } return ecal_en_in_signal_pf_cands/total; } @@ -71,8 +84,8 @@ namespace reco { namespace tau { float ecal_en_in_signal_cands = tau.ecalEnergy(); float hcal_en_in_signal_cands = tau.hcalEnergy(); float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands; - if(total == 0){ - return -1; + if(total == 0.){ + return -1.; } return ecal_en_in_signal_cands/total; } @@ -132,11 +145,11 @@ namespace reco { namespace tau { /// return total number of pf photon candidates with pT>500 MeV, which are associated to signal unsigned int n_photons_total(const reco::PFTau& tau) { unsigned int n_photons = 0; - for (auto& cand : tau.signalPFGammaCands()) { + for (auto& cand : tau.signalGammaCands()) { if (cand->pt() > 0.5) ++n_photons; } - for (auto& cand : tau.isolationPFGammaCands()) { + for (auto& cand : tau.isolationGammaCands()) { if (cand->pt() > 0.5) ++n_photons; } From dc3f2fcaf08384db439c47c3d6d943827bdf21ab Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 7 Sep 2018 13:45:42 +0200 Subject: [PATCH 063/686] adjust to changes for tauRecoAtMini --- .../RecoTau/src/PFRecoTauClusterVariables.cc | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc index 25698bae7c227..97d0d31560b5c 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc @@ -1,7 +1,7 @@ #include "RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h" namespace { - struct PFTau_traits{ typedef reco::PFTau Tau_t; typedef const std::vector& Ret_t; }; + struct PFTau_traits{ typedef reco::PFTau Tau_t; typedef const std::vector& Ret_t; }; struct PATTau_traits{ typedef pat::Tau Tau_t; typedef reco::CandidatePtrVector Ret_t; }; template @@ -10,11 +10,11 @@ namespace { } /// return pf photon candidates that are associated to signal template<> - const std::vector& getGammas_T(const reco::PFTau& tau, bool signal) { + const std::vector& getGammas_T(const reco::PFTau& tau, bool signal) { if (signal){ - return tau.signalPFGammaCands(); + return tau.signalGammaCands(); } - return tau.isolationPFGammaCands(); + return tau.isolationGammaCands(); } template<> @@ -44,11 +44,20 @@ namespace reco { namespace tau { /// return chi2 of the leading track ==> deprecated? <== float lead_track_chi2(const reco::PFTau& tau) { float LeadingTracknormalizedChi2 = 0; - const reco::PFCandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand() ; - if (leadingPFCharged.isNonnull()) { - reco::TrackRef tref = leadingPFCharged -> trackRef(); - if (tref.isNonnull()) { - LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2()); + const reco::CandidatePtr& leadingCharged = tau.leadChargedHadrCand(); + if (leadingCharged.isNonnull()) { + const reco::PFCandidate* pfcand = dynamic_cast(leadingCharged.get()); + if (pfcand != nullptr) { + reco::TrackRef tref = pfcand->trackRef(); + if (tref.isNonnull()) { + LeadingTracknormalizedChi2 = tref->normalizedChi2(); + } + } + else { + const pat::PackedCandidate* patcand = dynamic_cast(leadingCharged.get()); + if (patcand != nullptr && patcand->hasTrackDetails()) { + LeadingTracknormalizedChi2 = patcand->pseudoTrack().normalizedChi2(); + } } } return LeadingTracknormalizedChi2; @@ -57,13 +66,17 @@ namespace reco { namespace tau { float eratio(const reco::PFTau& tau) { float ecal_en_in_signal_pf_cands = 0; float hcal_en_in_signal_pf_cands = 0; - for (const auto& signal_cand : tau.signalPFCands()) { - ecal_en_in_signal_pf_cands += signal_cand->ecalEnergy(); - hcal_en_in_signal_pf_cands += signal_cand->hcalEnergy(); + for (const auto& icand : tau.signalCands()) { + const reco::PFCandidate* pfcand = dynamic_cast(icand.get()); + if (pfcand != nullptr) { + ecal_en_in_signal_pf_cands += icand->ecalEnergy(); + hcal_en_in_signal_pf_cands += icand->hcalEnergy(); + } + // TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content } float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands; - if(total==0){ - return -1; + if(total == 0.){ + return -1.; } return ecal_en_in_signal_pf_cands/total; } @@ -71,8 +84,8 @@ namespace reco { namespace tau { float ecal_en_in_signal_cands = tau.ecalEnergy(); float hcal_en_in_signal_cands = tau.hcalEnergy(); float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands; - if(total == 0){ - return -1; + if(total == 0.){ + return -1.; } return ecal_en_in_signal_cands/total; } @@ -132,11 +145,11 @@ namespace reco { namespace tau { /// return total number of pf photon candidates with pT>500 MeV, which are associated to signal unsigned int n_photons_total(const reco::PFTau& tau) { unsigned int n_photons = 0; - for (auto& cand : tau.signalPFGammaCands()) { + for (auto& cand : tau.signalGammaCands()) { if (cand->pt() > 0.5) ++n_photons; } - for (auto& cand : tau.isolationPFGammaCands()) { + for (auto& cand : tau.isolationGammaCands()) { if (cand->pt() > 0.5) ++n_photons; } From 767d2c48a5430a85fe0c22eb41ec4d07aa116c78 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 7 Sep 2018 14:12:25 +0200 Subject: [PATCH 064/686] small fix --- RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc index 97d0d31560b5c..af5e09d69e3b8 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc @@ -66,11 +66,11 @@ namespace reco { namespace tau { float eratio(const reco::PFTau& tau) { float ecal_en_in_signal_pf_cands = 0; float hcal_en_in_signal_pf_cands = 0; - for (const auto& icand : tau.signalCands()) { - const reco::PFCandidate* pfcand = dynamic_cast(icand.get()); - if (pfcand != nullptr) { - ecal_en_in_signal_pf_cands += icand->ecalEnergy(); - hcal_en_in_signal_pf_cands += icand->hcalEnergy(); + for (const auto& signal_cand : tau.signalCands()) { + const reco::PFCandidate* signal_pfcand = dynamic_cast(signal_cand.get()); + if (signal_pfcand != nullptr) { + ecal_en_in_signal_pf_cands += signal_pfcand->ecalEnergy(); + hcal_en_in_signal_pf_cands += signal_pfcand->hcalEnergy(); } // TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content } From ef7525d74d89c1bc650f4b057829844defb869b3 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 7 Sep 2018 14:49:06 +0200 Subject: [PATCH 065/686] update test configuration --- RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index 9bcedbf27ad30..efe4ae3ea1aeb 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -34,7 +34,7 @@ ##### from Configuration.StandardSequences.Eras import eras -era = eras.Run2_2017 +era = eras.Run2_2018 if phase2: era = eras.Phase2_timing process = cms.Process("TAURECO", era) @@ -59,7 +59,8 @@ if runSignal: readFiles.extend([ #'file:patMiniAOD_standard.root' - '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' + '/store/relval/CMSSW_10_3_0_pre2/RelValZTT_13/MINIAODSIM/PU25ns_103X_upgrade2018_realistic_v2-v1/20000/75AAA50B-3DD0-2B41-AB02-85428238CF7C.root' + #'/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', ]) else: @@ -81,7 +82,7 @@ from Configuration.AlCa.GlobalTag import GlobalTag if not phase2: process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - process.GlobalTag.globaltag = '94X_mc2017_realistic_v1' + process.GlobalTag.globaltag = '103X_upgrade2018_realistic_v2' else: process.GlobalTag = GlobalTag( process.GlobalTag, 'auto:phase2_realistic', '') From d2654d6182d4675879c70ad33c0a1a9cef9f4ee8 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 2 Oct 2018 13:59:06 +0200 Subject: [PATCH 066/686] correct indentation --- RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc index af5e09d69e3b8..a6d06e67e854f 100644 --- a/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc +++ b/RecoTauTag/RecoTau/src/PFRecoTauClusterVariables.cc @@ -69,8 +69,8 @@ namespace reco { namespace tau { for (const auto& signal_cand : tau.signalCands()) { const reco::PFCandidate* signal_pfcand = dynamic_cast(signal_cand.get()); if (signal_pfcand != nullptr) { - ecal_en_in_signal_pf_cands += signal_pfcand->ecalEnergy(); - hcal_en_in_signal_pf_cands += signal_pfcand->hcalEnergy(); + ecal_en_in_signal_pf_cands += signal_pfcand->ecalEnergy(); + hcal_en_in_signal_pf_cands += signal_pfcand->hcalEnergy(); } // TauReco@MiniAOD: recalculate for PackedCandidate if added to MiniAOD event content } From ac3ae41f421a3e36fa275d0feb6906a6b4f55992 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 13:43:58 +0200 Subject: [PATCH 067/686] use modern pointer --- .../PFRecoTauDiscriminationAgainstElectronMVA6.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index d9a15163028e4..615ccf6557593 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -29,10 +29,10 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro public: explicit PFRecoTauDiscriminationAgainstElectronMVA6(const edm::ParameterSet& cfg) : PFTauDiscriminationProducerBase(cfg), - mva_(nullptr), + mva_(), category_output_() { - mva_ = new AntiElectronIDMVA6(cfg); + mva_ = std::make_unique(cfg); usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); @@ -51,18 +51,13 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro void endEvent(edm::Event&) override; - ~PFRecoTauDiscriminationAgainstElectronMVA6() override - { - delete mva_; - } + ~PFRecoTauDiscriminationAgainstElectronMVA6() override {} private: bool isInEcalCrack(double) const; std::string moduleLabel_; - - AntiElectronIDMVA6* mva_; - float* mvaInput_; + std::unique_ptr mva_; edm::InputTag srcGsfElectrons_; edm::EDGetTokenT GsfElectrons_token; From bbb94f8603cc510189e6d1c2b5a8f63b37ab9e04 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 15:15:55 +0200 Subject: [PATCH 068/686] Constraints on input values against unphysical outliers --- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index de3c8485341cb..b080b93486463 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -393,10 +393,10 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, Var_woGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); Var_woGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); Var_woGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_woGwGSF_Barrel_[3] = std::log(ElecGSFTrackResol); + Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_woGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_woGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Barrel_[6] = std::log(ElecChi2NormKF); + Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_woGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Barrel_[9] = ElecDeltaEta; @@ -417,12 +417,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_woGwGSF_BL_->GetClassifier(Var_woGwGSF_Barrel_); } else { Var_woGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Endcap_[1] = std::log(ElecChi2NormGSF); + Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_woGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_woGwGSF_Endcap_[3] = std::log(ElecGSFTrackResol); + Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_woGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_woGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Endcap_[6] = std::log(ElecChi2NormKF); + Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_woGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Endcap_[9] = ElecDeltaEta; @@ -445,12 +445,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn > 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_wGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); + Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_wGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_wGwGSF_Barrel_[3] = std::log(ElecGSFTrackResol); + Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_wGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_wGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Barrel_[6] = std::log(ElecChi2NormKF); + Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_wGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Barrel_[9] = ElecDeltaEta; @@ -479,12 +479,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_wGwGSF_BL_->GetClassifier(Var_wGwGSF_Barrel_); } else { Var_wGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Endcap_[1] = std::log(ElecChi2NormGSF); + Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); Var_wGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_wGwGSF_Endcap_[3] = std::log(ElecGSFTrackResol); + Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); Var_wGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_wGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Endcap_[6] = std::log(ElecChi2NormKF); + Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); Var_wGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Endcap_[9] = ElecDeltaEta; From 5f183994ddd145133e6d2c46edd003c7e2d325ac Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 21 Sep 2018 16:14:41 +0200 Subject: [PATCH 069/686] usePhiAtEcalEntranceExtrapolation becomes an internal parameter of the AntiElectronMVA algo -- solve conflicts --- .../RecoTau/interface/AntiElectronIDMVA6.h | 12 +++++++----- .../PATTauDiscriminationAgainstElectronMVA6.cc | 6 ++---- ...RecoTauDiscriminationAgainstElectronMVA6.cc | 7 ++----- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 18 ++++++++++-------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h index cc2d246e9d619..afbaf54f57861 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h @@ -123,15 +123,15 @@ class AntiElectronIDMVA6 // this function can be called for all categories double MVAValue(const reco::PFTau& thePFTau, - const reco::GsfElectron& theGsfEle, bool usePhiAtEcalEntranceExtrapolation); + const reco::GsfElectron& theGsfEle); // this function can be called for category 1 only !! - double MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEcalEntranceExtrapolation); + double MVAValue(const reco::PFTau& thePFTau); // this function can be called for all categories double MVAValue(const pat::Tau& theTau, - const pat::Electron& theEle, bool usePhiAtEcalEntranceExtrapolation); + const pat::Electron& theEle); // this function can be called for category 1 only !! - double MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEntranceExtrapolation); + double MVAValue(const pat::Tau& theTau); // track extrapolation to ECAL entrance (used to re-calculate varibales that might not be available on miniAOD) bool atECalEntrance(const reco::Candidate* part, math::XYZPoint &pos); @@ -153,7 +153,9 @@ class AntiElectronIDMVA6 std::string mvaName_NoEleMatch_wGwoGSF_EC_; std::string mvaName_woGwGSF_EC_; std::string mvaName_wGwGSF_EC_; - + + bool usePhiAtEcalEntranceExtrapolation_; + Float_t* Var_NoEleMatch_woGwoGSF_Barrel_; Float_t* Var_NoEleMatch_wGwoGSF_Barrel_; Float_t* Var_woGwGSF_Barrel_; diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 4ad8e257209ae..8416a6e21ce21 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -31,7 +31,6 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu { mva_ = std::make_unique(cfg); - usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcElectrons = cfg.getParameter("srcElectrons"); electronToken = consumes(srcElectrons); verbosity_ = ( cfg.exists("verbosity") ) ? @@ -61,7 +60,6 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu edm::Handle taus_; std::unique_ptr category_output_; - bool usePhiAtEcalEntranceExtrapolation_; int verbosity_; }; @@ -104,7 +102,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4()); deltaRDummy = deltaREleTau; if( deltaREleTau < 0.3 ){ - double mva_match = mva_->MVAValue(*theTauRef, theElectron, usePhiAtEcalEntranceExtrapolation_); + double mva_match = mva_->MVAValue(*theTauRef, theElectron); bool hasGsfTrack = false; pat::PackedCandidate const* packedLeadTauCand = dynamic_cast(theTauRef->leadChargedHadrCand().get()); if( abs(packedLeadTauCand->pdgId()) == 11 ) @@ -142,7 +140,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa } // end of loop over electrons if ( !isGsfElectronMatched ) { - mvaValue = mva_->MVAValue(*theTauRef, usePhiAtEcalEntranceExtrapolation_); + mvaValue = mva_->MVAValue(*theTauRef); bool hasGsfTrack = false; pat::PackedCandidate const* packedLeadTauCand = dynamic_cast(theTauRef->leadChargedHadrCand().get()); if( abs(packedLeadTauCand->pdgId()) == 11 ) hasGsfTrack = true; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 615ccf6557593..e42a667e4d880 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -34,7 +34,6 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro { mva_ = std::make_unique(cfg); - usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); GsfElectrons_token = consumes(srcGsfElectrons_); @@ -65,7 +64,6 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro edm::Handle taus_; std::unique_ptr category_output_; - bool usePhiAtEcalEntranceExtrapolation_; int verbosity_; }; @@ -141,13 +139,12 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { - double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_); + double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand(); bool hasGsfTrack = false; if (lpfch.isNonnull()) { hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); } - if ( !hasGsfTrack ) hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); @@ -183,7 +180,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& } // end of loop over electrons if ( !isGsfElectronMatched ) { - mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_); + mvaValue = mva_->MVAValue(*thePFTauRef); const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand(); bool hasGsfTrack = false; if (lpfch.isNonnull()) { diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index b080b93486463..32daeb8bda92c 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -46,6 +46,8 @@ AntiElectronIDMVA6::AntiElectronIDMVA6(const edm::ParameterSet& cfg) mvaName_woGwGSF_EC_ = cfg.getParameter("mvaName_woGwGSF_EC"); mvaName_wGwGSF_EC_ = cfg.getParameter("mvaName_wGwGSF_EC"); + usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter("usePhiAtEcalEntranceExtrapolation"); + Var_NoEleMatch_woGwoGSF_Barrel_ = new Float_t[10]; Var_NoEleMatch_wGwoGSF_Barrel_ = new Float_t[18]; Var_woGwGSF_Barrel_ = new Float_t[24]; @@ -516,7 +518,7 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, } double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, - const reco::GsfElectron& theGsfEle, bool usePhiAtEcalEntranceExtrapolation) + const reco::GsfElectron& theGsfEle) { // === tau variables === @@ -617,7 +619,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - if ( !usePhiAtEcalEntranceExtrapolation ){ + if ( !usePhiAtEcalEntranceExtrapolation_ ){ for (auto const& pfcand : signalPFCands) { sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); sumEnergyPhi += pfcand->energy(); @@ -729,7 +731,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, ElecMvaInDeltaEta); } -double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) { // === tau variables === float TauEtaAtEcalEntrance = -99.; @@ -829,7 +831,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc Float_t TauPhi = thePFTau.phi(); float sumPhiTimesEnergy = 0.; float sumEnergyPhi = 0.; - if ( !usePhiAtEcalEntranceExtrapolation ){ + if ( !usePhiAtEcalEntranceExtrapolation_ ){ for (const auto& pfcand : signalPFCands) { sumPhiTimesEnergy += pfcand->positionAtECALEntrance().phi()*pfcand->energy(); sumEnergyPhi += pfcand->energy(); @@ -896,7 +898,7 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, bool usePhiAtEc 0.); } -double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& theEle, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& theEle) { // === tau variables === float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance(); @@ -978,7 +980,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size(); Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass(); Float_t TauPhi = -99.; - if ( usePhiAtEcalEntranceExtrapolation ) { + if ( usePhiAtEcalEntranceExtrapolation_ ) { float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); @@ -1092,7 +1094,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& ElecMvaInDeltaEta); } -double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEntranceExtrapolation) +double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) { // === tau variables === float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance(); @@ -1166,7 +1168,7 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, bool usePhiAtEcalEnt Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size(); Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass(); Float_t TauPhi = -99.; - if ( usePhiAtEcalEntranceExtrapolation ) { + if ( usePhiAtEcalEntranceExtrapolation_ ) { float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); From 40d2d3706323d0c0b20da8cc46f71d597b61cd96 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 28 Sep 2018 16:07:23 +0200 Subject: [PATCH 070/686] looser protection boundaries --- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 32daeb8bda92c..0767af334a4fd 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -393,12 +393,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn == 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_woGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Barrel_[1] = std::log(ElecChi2NormGSF); + Var_woGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_woGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_woGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_woGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_woGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Barrel_[9] = ElecDeltaEta; @@ -419,12 +419,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_woGwGSF_BL_->GetClassifier(Var_woGwGSF_Barrel_); } else { Var_woGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_woGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_woGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_woGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_woGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_woGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_woGwGSF_Endcap_[9] = ElecDeltaEta; @@ -447,12 +447,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, else if ( TauSignalPFGammaCandsIn > 0 && TauHasGsf > 0.5 ) { if ( std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { Var_wGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_wGwGSF_Barrel_[2] = ElecGSFNumHits; - Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_wGwGSF_Barrel_[4] = ElecGSFTracklnPt; Var_wGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_wGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Barrel_[9] = ElecDeltaEta; @@ -481,12 +481,12 @@ double AntiElectronIDMVA6::MVAValue(Float_t TauPt, mvaValue = mva_wGwGSF_BL_->GetClassifier(Var_wGwGSF_Barrel_); } else { Var_wGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin); - Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.1), ElecChi2NormGSF)); + Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF)); Var_wGwGSF_Endcap_[2] = ElecGSFNumHits; - Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.1), ElecGSFTrackResol)); + Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol)); Var_wGwGSF_Endcap_[4] = ElecGSFTracklnPt; Var_wGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum; - Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.1), ElecChi2NormKF)); + Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF)); Var_wGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.)); Var_wGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.)); Var_wGwGSF_Endcap_[9] = ElecDeltaEta; From 43c7f8817e5cd76cbce41c7e395b5c53b34d76cf Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Fri, 28 Sep 2018 16:47:27 +0200 Subject: [PATCH 071/686] fix name of input param --- .../python/PATTauDiscriminationAgainstElectronMVA6_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py index ba1d78326e0a5..2d8db274ceec3 100644 --- a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py +++ b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py @@ -4,7 +4,7 @@ patTauDiscriminationAgainstElectronMVA6 = cms.EDProducer("PATTauDiscriminationAgainstElectronMVA6", # tau collection to discriminate - PFTauProducer = cms.InputTag('slimmedTaus'), + PATTauProducer = cms.InputTag('slimmedTaus'), # Require leading pion ensures that: # 1) these is at least one track above threshold (0.5 GeV) in the signal cone From 234e4a9f66a7ee9aaf104fa9d0199b408eb3803e Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 4 Oct 2018 10:47:00 +0200 Subject: [PATCH 072/686] Range-based loops -- fix cherry-pick conflicts --- ...PATTauDiscriminationAgainstElectronMVA6.cc | 7 +- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 14 +-- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 113 +++++++++--------- 3 files changed, 64 insertions(+), 70 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 8416a6e21ce21..050d9abb814a9 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -87,8 +87,8 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa if( (*theTauRef).leadChargedHadrCand().isNonnull()) { int numSignalPFGammaCandsInSigCone = 0; const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands(); - for( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - double dR = deltaR((*gamma)->p4(), theTauRef->leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTauRef->pt()))); // gammas inside the tau signal cone if (dR < signalrad) { @@ -96,8 +96,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa } } // loop over the electrons - for( unsigned int ie = 0; ie < Electrons->size(); ++ie ){ - const pat::Electron& theElectron = Electrons->at(ie); + for ( const auto & theElectron : *Electrons ) { if ( theElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4()); deltaRDummy = deltaREleTau; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index e42a667e4d880..4b602e5d37828 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -120,10 +120,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& int numSignalGammaCandsInSigCone = 0; const std::vector& signalGammaCands = thePFTauRef->signalGammaCands(); - for ( std::vector::const_iterator pfGamma = signalGammaCands.begin(); - pfGamma != signalGammaCands.end(); ++pfGamma ) { + for ( const auto & pfGamma : signalPFGammaCands ) { - double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadChargedHadrCand()->p4()); + double dR = deltaR(pfGamma->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt()))); // pfGammas inside the tau signal cone @@ -133,10 +132,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& } // loop over the electrons - for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin(); - theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) { - if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... - double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); + for ( const auto & theGsfElectron : *gsfElectrons_ ) { + if ( theGsfElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... + double deltaREleTau = deltaR(theGsfElectron.p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); @@ -146,7 +144,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); } if ( !hasGsfTrack ) - hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); + hasGsfTrack = theGsfElectron.gsfTrack().isNonnull(); //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 0767af334a4fd..ad1630cc89a9d 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -569,9 +569,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -601,9 +600,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } } - for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -627,8 +625,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); ++o ) { - reco::PFCandidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) ) phi = aPos.Phi(); @@ -781,9 +779,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -813,9 +810,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } } - for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -839,8 +835,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); o++ ) { - reco::PFCandidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -926,53 +922,53 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiInSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please chaekc whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ){ - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -984,8 +980,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1122,45 +1118,45 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ) { - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ) { - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -1172,8 +1168,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1252,9 +1248,10 @@ namespace { std::array cPhi; // IN: define locations of the 18 phi-cracks cPhi[0] = 2.97025; - for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) - cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; - return cPhi; + for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) { + cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; + } + return cPhi; } const std::array cPhi = fill_cPhi(); From 75cd1cf6085dc19d9a070975a3261246bf8e3de2 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 4 Oct 2018 10:47:00 +0200 Subject: [PATCH 073/686] Range-based loops -- fix cherry-pick conflicts --- ...PATTauDiscriminationAgainstElectronMVA6.cc | 7 +- ...ecoTauDiscriminationAgainstElectronMVA6.cc | 14 +-- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 113 +++++++++--------- 3 files changed, 64 insertions(+), 70 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 8416a6e21ce21..050d9abb814a9 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -87,8 +87,8 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa if( (*theTauRef).leadChargedHadrCand().isNonnull()) { int numSignalPFGammaCandsInSigCone = 0; const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands(); - for( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - double dR = deltaR((*gamma)->p4(), theTauRef->leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTauRef->pt()))); // gammas inside the tau signal cone if (dR < signalrad) { @@ -96,8 +96,7 @@ double PATTauDiscriminationAgainstElectronMVA6::discriminate(const TauRef& theTa } } // loop over the electrons - for( unsigned int ie = 0; ie < Electrons->size(); ++ie ){ - const pat::Electron& theElectron = Electrons->at(ie); + for ( const auto & theElectron : *Electrons ) { if ( theElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4()); deltaRDummy = deltaREleTau; diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index e42a667e4d880..4b602e5d37828 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -120,10 +120,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& int numSignalGammaCandsInSigCone = 0; const std::vector& signalGammaCands = thePFTauRef->signalGammaCands(); - for ( std::vector::const_iterator pfGamma = signalGammaCands.begin(); - pfGamma != signalGammaCands.end(); ++pfGamma ) { + for ( const auto & pfGamma : signalPFGammaCands ) { - double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadChargedHadrCand()->p4()); + double dR = deltaR(pfGamma->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt()))); // pfGammas inside the tau signal cone @@ -133,10 +132,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& } // loop over the electrons - for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin(); - theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) { - if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... - double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4()); + for ( const auto & theGsfElectron : *gsfElectrons_ ) { + if ( theGsfElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account... + double deltaREleTau = deltaR(theGsfElectron.p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); @@ -146,7 +144,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& hasGsfTrack = lpfch->gsfTrackRef().isNonnull(); } if ( !hasGsfTrack ) - hasGsfTrack = theGsfElectron->gsfTrack().isNonnull(); + hasGsfTrack = theGsfElectron.gsfTrack().isNonnull(); //// Veto taus that go to Ecal crack if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) { diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index 0767af334a4fd..ad1630cc89a9d 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -569,9 +569,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -601,9 +600,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } } - for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -627,8 +625,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); ++o ) { - reco::PFCandidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) ) phi = aPos.Phi(); @@ -781,9 +779,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( unsigned i = 0 ; i < thePFTau.signalGammaCands().size(); ++i ) { - reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i); - float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -813,9 +810,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } } - for ( unsigned i = 0 ; i < thePFTau.signalChargedHadrCands().size(); ++i ) { - reco::CandidatePtr charged = thePFTau.signalChargedHadrCands().at(i); - float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -839,8 +835,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } else{ TauPhi= -99.; - for (unsigned int o = 0; o < signalPFCands.size(); o++ ) { - reco::PFCandidate const* signalCand = signalPFCands[o].get(); + for ( const auto & signalPFCand : signalPFCands ) { + reco::Candidate const* signalCand = signalPFCand.get(); float phi = thePFTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -926,53 +922,53 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){ - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiInSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); //A.-C. please check whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.leadChargedHadrCand()->phi())); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); //A.-C. please chaekc whether this change is safe against future trainings - //GammasdPhiOutSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.phi())); + //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi())); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ){ - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -984,8 +980,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1122,45 +1118,45 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands(); - for ( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ) { - float dR = deltaR((*gamma)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & gamma : signalGammaCands ) { + float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // pfGammas inside the tau signal cone if (dR < signalrad) { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaInSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiInSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtInSigCone.push_back((*gamma)->pt()); - pfGammaSum += (*gamma)->p4(); + GammasPtInSigCone.push_back(gamma->pt()); + pfGammaSum += gamma->p4(); } // pfGammas outside the tau signal cone else { if ( theTau.leadChargedHadrCand().isNonnull() ) { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.leadChargedHadrCand()->eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.leadChargedHadrCand()->phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi()); } else { - GammasdEtaOutSigCone.push_back((*gamma)->eta() - theTau.eta()); - GammasdPhiOutSigCone.push_back((*gamma)->phi() - theTau.phi()); + GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta()); + GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi()); } - GammasPtOutSigCone.push_back((*gamma)->pt()); + GammasPtOutSigCone.push_back(gamma->pt()); } } const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands(); - for ( reco::CandidatePtrVector::const_iterator charged = signalChargedCands.begin(); charged != signalChargedCands.end(); ++charged ) { - float dR = deltaR((*charged)->p4(), theTau.leadChargedHadrCand()->p4()); + for ( const auto & charged : signalChargedCands ) { + float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTau.pt()))); // charged particles inside the tau signal cone if (dR < signalrad) { - pfChargedSum += (*charged)->p4(); + pfChargedSum += charged->p4(); } } @@ -1172,8 +1168,8 @@ double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau) float sumPhiTimesEnergy = 0.; float sumEnergy = 0.; const reco::CandidatePtrVector signalCands = theTau.signalCands(); - for (unsigned int o = 0; o < signalCands.size(); o++ ) { - reco::Candidate const* signalCand = signalCands[o].get(); + for ( const auto & signalCandPtr : signalCands ) { + reco::Candidate const* signalCand = signalCandPtr.get(); float phi = theTau.phi(); math::XYZPoint aPos; if ( atECalEntrance(signalCand, aPos) == true ) phi = aPos.Phi(); @@ -1252,9 +1248,10 @@ namespace { std::array cPhi; // IN: define locations of the 18 phi-cracks cPhi[0] = 2.97025; - for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) - cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; - return cPhi; + for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) { + cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18; + } + return cPhi; } const std::array cPhi = fill_cPhi(); From f3d2173509bf9a0716c1c001800fac838618dd9d Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 16 Oct 2018 14:19:10 +0200 Subject: [PATCH 074/686] fixes: PFCands -> Cands --- ...PFRecoTauDiscriminationAgainstElectronMVA6.cc | 6 +++--- RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 4b602e5d37828..57985f7ad0b8c 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -120,9 +120,9 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& int numSignalGammaCandsInSigCone = 0; const std::vector& signalGammaCands = thePFTauRef->signalGammaCands(); - for ( const auto & pfGamma : signalPFGammaCands ) { + for ( const auto & pfGamma : signalGammaCands ) { - double dR = deltaR(pfGamma->p4(), thePFTauRef->leadPFChargedHadrCand()->p4()); + double dR = deltaR(pfGamma->p4(), thePFTauRef->leadChargedHadrCand()->p4()); double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt()))); // pfGammas inside the tau signal cone @@ -137,7 +137,7 @@ double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate(const PFTauRef& double deltaREleTau = deltaR(theGsfElectron.p4(), thePFTauRef->p4()); deltaRDummy = deltaREleTau; if ( deltaREleTau < 0.3 ) { - double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron); + double mva_match = mva_->MVAValue(*thePFTauRef, theGsfElectron); const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand(); bool hasGsfTrack = false; if (lpfch.isNonnull()) { diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index ad1630cc89a9d..5afa131d440f8 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -569,8 +569,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { - float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -600,8 +600,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, } } - for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { - float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone @@ -779,8 +779,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) reco::Candidate::LorentzVector pfGammaSum(0,0,0,0); reco::Candidate::LorentzVector pfChargedSum(0,0,0,0); - for ( const auto & gamma : thePFTau.signalPFGammaCands() ) { - float dR = deltaR(gamma->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( const auto & gamma : thePFTau.signalGammaCands() ) { + float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // pfGammas inside the tau signal cone @@ -810,8 +810,8 @@ double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) } } - for ( const auto & charged : thePFTau.signalPFChargedHadrCands() ) { - float dR = deltaR(charged->p4(), thePFTau.leadPFChargedHadrCand()->p4()); + for ( const auto & charged : thePFTau.signalChargedHadrCands() ) { + float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4()); float signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTau.pt()))); // charged particles inside the tau signal cone From 12b994cf15b4040771e18755f0f6b1c46c98fee6 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Wed, 17 Oct 2018 16:05:36 +0200 Subject: [PATCH 075/686] post merge fixes --- RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc index e0f7337f19947..dae7990818046 100644 --- a/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc +++ b/RecoTauTag/RecoTau/src/RecoTauVertexAssociator.cc @@ -129,7 +129,7 @@ const reco::TrackBaseRef RecoTauVertexAssociator::getLeadTrackRef(const Jet& jet namespace { // Define functors which extract the relevant information from a collection of // vertices. - double dzToTrack(const reco::VertexRef& vtx, const reco::TrackBaseRef& trk) + double dzToTrack(const reco::VertexRef& vtx, const reco::Track* trk) { if ( !trk || !vtx ) { return std::numeric_limits::infinity(); @@ -343,7 +343,7 @@ RecoTauVertexAssociator::associatedVertex(const TrackBaseRef& track) const int idxVertex = 0; for ( std::vector::const_iterator selectedVertex = selectedVertices_.begin(); selectedVertex != selectedVertices_.end(); ++selectedVertex ) { - double dZ = dzToTrack(*selectedVertex, track); + double dZ = dzToTrack(*selectedVertex, track.get()); if ( verbosity_ ) { std::cout << "vertex #" << idxVertex << ": x = " << (*selectedVertex)->position().x() << ", y = " << (*selectedVertex)->position().y() << ", z = " << (*selectedVertex)->position().z() << " --> dZ = " << dZ << std::endl; From f8c7d8345ff776bdef9af01481d66a07c5383a04 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 18 Oct 2018 11:20:12 +0200 Subject: [PATCH 076/686] Remove unnecessary catch(...) expressions --- .../RecoTau/plugins/PFTauSecondaryVertexProducer.cc | 6 +----- .../RecoTau/src/PFTauPrimaryVertexProducerBase.cc | 12 ++++-------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index 6efb2406a0e6a..15760f8ff2ad2 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -122,11 +122,7 @@ void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,con bool FitOk(true); KalmanVertexFitter kvf(true); if(transTrk.size() > 1) { - try{ - transVtx = kvf.vertex(transTrk); //KalmanVertexFitter - }catch(...){ - FitOk=false; - } + transVtx = kvf.vertex(transTrk); //KalmanVertexFitter } else { FitOk = false; } diff --git a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc index 1519d96701413..ace4e8933a9ee 100644 --- a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc +++ b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc @@ -178,14 +178,10 @@ void PFTauPrimaryVertexProducerBase::produce(edm::Event& iEvent,const edm::Event if ( transTracks.size() >= 2 ) { AdaptiveVertexFitter avf; avf.setWeightThreshold(0.1); //weight per track. allow almost every fit, else --> exception - try { - if ( !useBeamSpot_ ){ - transVtx = avf.vertex(transTracks); - } else { - transVtx = avf.vertex(transTracks, *beamSpot); - } - } catch (...) { - fitOK = false; + if ( !useBeamSpot_ ){ + transVtx = avf.vertex(transTracks); + } else { + transVtx = avf.vertex(transTracks, *beamSpot); } } else fitOK = false; if ( fitOK ) thePV = transVtx; From 2cd2c400170e076b7b9c1cd6b9a3810558ed9f44 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 18 Oct 2018 16:28:43 +0200 Subject: [PATCH 077/686] Remove incorrectly used std::move --- DataFormats/TauReco/src/PFTau.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DataFormats/TauReco/src/PFTau.cc b/DataFormats/TauReco/src/PFTau.cc index 05e2e0fd60fa9..ddb1551d416c7 100644 --- a/DataFormats/TauReco/src/PFTau.cc +++ b/DataFormats/TauReco/src/PFTau.cc @@ -153,74 +153,74 @@ namespace { const PFCandidatePtr PFTau::leadPFChargedHadrCand() const { if (!leadPFChargedHadrCand_.isSet()) - leadPFChargedHadrCand_.set(std::move(convertToPFPtr(leadChargedHadrCand_))); + leadPFChargedHadrCand_.set(convertToPFPtr(leadChargedHadrCand_)); return *leadPFChargedHadrCand_; } const PFCandidatePtr PFTau::leadPFNeutralCand() const { if (!leadPFNeutralCand_.isSet()) - leadPFNeutralCand_.set(std::move(convertToPFPtr(leadNeutralCand_))); + leadPFNeutralCand_.set(convertToPFPtr(leadNeutralCand_)); return *leadPFNeutralCand_; } const PFCandidatePtr PFTau::leadPFCand() const { if (!leadPFCand_.isSet()) - leadPFCand_.set(std::move(convertToPFPtr(leadCand_))); + leadPFCand_.set(convertToPFPtr(leadCand_)); return *leadPFCand_; } const std::vector& PFTau::signalPFCands() const { if (!selectedTransientSignalPFCands_.isSet()) { - selectedTransientSignalPFCands_.set(std::move(convertToPFPtrs(selectedSignalCands_))); + selectedTransientSignalPFCands_.set(convertToPFPtrs(selectedSignalCands_)); } return *selectedTransientSignalPFCands_; } const std::vector& PFTau::signalPFChargedHadrCands() const { if (!selectedTransientSignalPFChargedHadrCands_.isSet()) { - selectedTransientSignalPFChargedHadrCands_.set(std::move(convertToPFPtrs(selectedSignalChargedHadrCands_))); + selectedTransientSignalPFChargedHadrCands_.set(convertToPFPtrs(selectedSignalChargedHadrCands_)); } return *selectedTransientSignalPFChargedHadrCands_; } const std::vector& PFTau::signalPFNeutrHadrCands() const { if (!selectedTransientSignalPFNeutrHadrCands_.isSet()) { - selectedTransientSignalPFNeutrHadrCands_.set(std::move(convertToPFPtrs(selectedSignalNeutrHadrCands_))); + selectedTransientSignalPFNeutrHadrCands_.set(convertToPFPtrs(selectedSignalNeutrHadrCands_)); } return *selectedTransientSignalPFNeutrHadrCands_; } const std::vector& PFTau::signalPFGammaCands() const { if (!selectedTransientSignalPFGammaCands_.isSet()) { - selectedTransientSignalPFGammaCands_.set(std::move(convertToPFPtrs(selectedSignalGammaCands_))); + selectedTransientSignalPFGammaCands_.set(convertToPFPtrs(selectedSignalGammaCands_)); } return *selectedTransientSignalPFGammaCands_; } const std::vector& PFTau::isolationPFCands() const { if (!selectedTransientIsolationPFCands_.isSet()) { - selectedTransientIsolationPFCands_.set(std::move(convertToPFPtrs(selectedIsolationCands_))); + selectedTransientIsolationPFCands_.set(convertToPFPtrs(selectedIsolationCands_)); } return *selectedTransientIsolationPFCands_; } const std::vector& PFTau::isolationPFChargedHadrCands() const { if (!selectedTransientIsolationPFChargedHadrCands_.isSet()) { - selectedTransientIsolationPFChargedHadrCands_.set(std::move(convertToPFPtrs(selectedIsolationChargedHadrCands_))); + selectedTransientIsolationPFChargedHadrCands_.set(convertToPFPtrs(selectedIsolationChargedHadrCands_)); } return *selectedTransientIsolationPFChargedHadrCands_; } const std::vector& PFTau::isolationPFNeutrHadrCands() const { if (!selectedTransientIsolationPFNeutrHadrCands_.isSet()) { - selectedTransientIsolationPFNeutrHadrCands_.set(std::move(convertToPFPtrs(selectedIsolationNeutrHadrCands_))); + selectedTransientIsolationPFNeutrHadrCands_.set(convertToPFPtrs(selectedIsolationNeutrHadrCands_)); } return *selectedTransientIsolationPFNeutrHadrCands_; } const std::vector& PFTau::isolationPFGammaCands() const { if (!selectedTransientIsolationPFGammaCands_.isSet()) { - selectedTransientIsolationPFGammaCands_.set(std::move(convertToPFPtrs(selectedIsolationGammaCands_))); + selectedTransientIsolationPFGammaCands_.set(convertToPFPtrs(selectedIsolationGammaCands_)); } return *selectedTransientIsolationPFGammaCands_; } From 2cf812e7bb2af0d36cc3f764feb12d1c26901449 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Mon, 5 Nov 2018 11:44:33 +0100 Subject: [PATCH 078/686] Reset properly transient PFTau data via ioread rules --- DataFormats/TauReco/src/classes_def_2.xml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 29d201be98fbd..6382e837d312a 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -51,16 +51,22 @@ - - (onfile.leadPFChargedHadrCand_);]]> + + (onfile.leadPFChargedHadrCand_);]]> - - (onfile.leadPFNeutralCand_);]]> + + (onfile.leadPFNeutralCand_);]]> - - (onfile.leadPFCand_);]]> + + (onfile.leadPFCand_);]]> From a4e7896b96ce56386c608f214c017456b143e6a1 Mon Sep 17 00:00:00 2001 From: mbluj Date: Tue, 13 Nov 2018 10:02:43 +0100 Subject: [PATCH 079/686] Loop using tempory var for the size Addressing https://github.com/cms-sw/cmssw/pull/22594#discussion_r231996972 --- RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index e6382e198c58b..0754208339973 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -142,7 +142,8 @@ void RecoTauPiZeroProducer::produce(edm::Event& evt, const edm::EventSetup& es) association = std::make_unique(reco::JetRefBaseProd(jetView)); // Loop over our jets - for (size_t i = 0; i < jetView->size(); ++i) { + size_t nJets = jetView->size(); + for (size_t i = 0; i < nJets; ++i) { const reco::JetBaseRef jet(jetView->refAt(i)); if(jet->pt() - minJetPt_ < 1e-5) continue; From 8b8bd0ae26af8ac0a80cfde67b06041198fdfff2 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Tue, 5 Feb 2019 10:00:32 +0100 Subject: [PATCH 080/686] updated inputs for tests --- RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index efe4ae3ea1aeb..d49d22be832a6 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -59,16 +59,12 @@ if runSignal: readFiles.extend([ #'file:patMiniAOD_standard.root' - '/store/relval/CMSSW_10_3_0_pre2/RelValZTT_13/MINIAODSIM/PU25ns_103X_upgrade2018_realistic_v2-v1/20000/75AAA50B-3DD0-2B41-AB02-85428238CF7C.root' - #'/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValZTT_13/MINIAODSIM/PUpmx25ns_100X_mc2017_realistic_v1-v1/20000/B01F0774-17E1-E711-9826-0CC47A4D7654.root', + '/store/relval/CMSSW_10_5_0_pre1/RelValZTT_13/MINIAODSIM/PU25ns_103X_upgrade2018_realistic_v8-v1/20000/EA29017F-9967-3F41-BB8A-22C44A454235.root' ]) else: readFiles.extend([ #'file:patMiniAOD_standard.root' - '/store/relval/CMSSW_10_1_0_pre3/RelValZTT_13UP18/MINIAODSIM/PUpmx25ns_101X_upgrade2018_realistic_v3_cc7-v1/10000/2808A251-DE31-E811-BFBC-0242AC130002.root' - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/78318DC3-40E0-E711-BCFE-0CC47A4D763C.root', - #'root://cms-xrd-global.cern.ch///store/relval/CMSSW_10_0_0_pre2/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PUpmx25ns_100X_mcRun2_asymptotic_v2_FastSim-v1/20000/E6F528C8-40E0-E711-9F06-0CC47A4C8E56.root', + '/store/relval/CMSSW_10_5_0_pre1/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PU25ns_103X_mcRun2_asymptotic_v3-v1/20000/A5CBC261-E3AB-C842-896F-E6AFB38DD22F.root' ]) ##### @@ -81,8 +77,7 @@ process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag if not phase2: - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') - process.GlobalTag.globaltag = '103X_upgrade2018_realistic_v2' + process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '') else: process.GlobalTag = GlobalTag( process.GlobalTag, 'auto:phase2_realistic', '') From 816d49e2d32feae41e273870f085947aff395116 Mon Sep 17 00:00:00 2001 From: Giacomo Govi Date: Wed, 6 Feb 2019 17:00:36 +0100 Subject: [PATCH 081/686] Added support for plots from two tags --- CondCore/CondDB/interface/Session.h | 5 +- CondCore/CondDB/interface/Types.h | 1 + CondCore/CondDB/src/Session.cc | 8 ++ .../Utilities/interface/PayloadInspector.h | 38 ++++++--- .../interface/PayloadInspectorModule.h | 2 + .../plugins/BasicP_PayloadInspector.cc | 85 +++++++++++++++++++ .../plugins/Module_PayloadInspector.cc | 2 + CondCore/Utilities/src/PayloadInspector.cc | 73 +++++++++++++++- 8 files changed, 198 insertions(+), 16 deletions(-) diff --git a/CondCore/CondDB/interface/Session.h b/CondCore/CondDB/interface/Session.h index 6f095f0708215..7a2d628296c62 100644 --- a/CondCore/CondDB/interface/Session.h +++ b/CondCore/CondDB/interface/Session.h @@ -100,7 +100,10 @@ namespace cond { // bool existsIov( const std::string& tag ); - + + // + bool getTagInfo( const std::string& tag, cond::Tag_t& info ); + // retrieves an IOV range. Peforms a query at every call. bool getIovRange( const std::string& tag, cond::Time_t begin, cond::Time_t end, diff --git a/CondCore/CondDB/interface/Types.h b/CondCore/CondDB/interface/Types.h index f8ab4edf42da4..1ba0afd9428b5 100644 --- a/CondCore/CondDB/interface/Types.h +++ b/CondCore/CondDB/interface/Types.h @@ -63,6 +63,7 @@ namespace cond { std::string tag; std::string payloadType; TimeType timeType; + SynchronizationType synchronizationType; Time_t endOfValidity; Time_t lastValidatedTime; }; diff --git a/CondCore/CondDB/src/Session.cc b/CondCore/CondDB/src/Session.cc index e33a412c11d52..109ce12d287e5 100644 --- a/CondCore/CondDB/src/Session.cc +++ b/CondCore/CondDB/src/Session.cc @@ -98,6 +98,14 @@ namespace cond { m_session->openIovDb(); return m_session->iovSchema().tagTable().select( tag ); } + + bool Session::getTagInfo( const std::string& tag, + cond::Tag_t& info ){ + m_session->openIovDb(); + std::string description; + return m_session->iovSchema().tagTable().select( tag, info.timeType, info.payloadType, info.synchronizationType, + info.endOfValidity, description, info.lastValidatedTime ); + } IOVProxy Session::iovProxy(){ m_session->openIovDb(); diff --git a/CondCore/Utilities/interface/PayloadInspector.h b/CondCore/Utilities/interface/PayloadInspector.h index e910c4127262b..da48898c84b15 100644 --- a/CondCore/Utilities/interface/PayloadInspector.h +++ b/CondCore/Utilities/interface/PayloadInspector.h @@ -31,6 +31,7 @@ namespace cond { std::string get( const std::string& key ) const; std::map m; bool singleIov = false; + bool twoTags = false; }; static const char* const JSON_FORMAT_VERSION = "1.0"; @@ -147,12 +148,18 @@ namespace cond { // required in the browser bool isSingleIov() const; + // required in the browser + bool isTwoTags() const; + // returns the json file with the plot data std::string data() const; // triggers the processing producing the plot bool process( const std::string& connectionString, const std::string& tag, const std::string& timeType, cond::Time_t begin, cond::Time_t end ); + //bool process( const std::string& connectionString, const std::string& tag, cond::Time_t begin, cond::Time_t end ); + bool processTwoTags( const std::string& connectionString, const std::string& tag0, const std::string& tag1, cond::Time_t time0, cond::Time_t time1 ); + // not exposed in python: // called internally in process() virtual void init(); @@ -164,13 +171,17 @@ namespace cond { // to be set in order to limit the iov selection ( and processing ) to 1 iov void setSingleIov( bool flag ); + void setTwoTags( bool flag ); + // access to the fetch function of the configured reader, to be used in the processData implementations template std::shared_ptr fetchPayload( const cond::Hash& payloadHash ){ return m_dbSession.fetchPayload( payloadHash ); } + cond::Tag_t getTagInfo( const std::string& tag ); + // access to the timeType of the tag in process - cond::TimeType tagTimeType() const; + //cond::TimeType tagTimeType() const; // access to the underlying db session cond::persistency::Session dbSession(); @@ -178,11 +189,13 @@ namespace cond { protected: PlotAnnotations m_plotAnnotations; + std::string m_tag0 = ""; + std::string m_tag1 = ""; private: cond::persistency::Session m_dbSession; - cond::TimeType m_tagTimeType; + //cond::TimeType m_tagTimeType; std::string m_data = ""; }; @@ -279,9 +292,11 @@ namespace cond { } ~RunHistoryPlot() override = default; bool fill( const std::vector >& iovs ) override { + // for the lumi iovs we need to count the number of lumisections in every runs std::map runs; - if( Base::tagTimeType()==cond::lumiid ){ + cond::Tag_t tagInfo = Base::getTagInfo( Base::m_tag0 ); + if( tagInfo.timeType==cond::lumiid ){ for( auto iov : iovs ) { unsigned int run = std::get<0>(iov) >> 32; auto it = runs.find( run ); @@ -298,7 +313,7 @@ namespace cond { for( auto iov : iovs ) { unsigned long long since = std::get<0>(iov); // for the lumi iovs we squeeze the lumi section available in the constant run 'slot' of witdth=1 - if( Base::tagTimeType()==cond::lumiid ){ + if( tagInfo.timeType==cond::lumiid ){ unsigned int run = since >> 32; unsigned int lumi = since & 0xFFFFFFFF; if( run != currentRun ) { @@ -319,7 +334,7 @@ namespace cond { } else { ind++; // for the timestamp based iovs, it does not really make much sense to use this plot... - if( Base::tagTimeType()==cond::timestamp ){ + if( tagInfo.timeType==cond::timestamp ){ boost::posix_time::ptime t = cond::time::to_boost( since ); label = boost::posix_time::to_simple_string( t ); } else { @@ -349,10 +364,11 @@ namespace cond { ~TimeHistoryPlot() override = default; bool fill( const std::vector >& iovs ) override { cond::persistency::RunInfoProxy runInfo; - if( Base::tagTimeType()==cond::lumiid || Base::tagTimeType()==cond::runnumber){ + cond::Tag_t tagInfo = Base::getTagInfo( Base::m_tag0 ); + if( tagInfo.timeType==cond::lumiid || tagInfo.timeType==cond::runnumber){ cond::Time_t min = std::get<0>(iovs.front()); cond::Time_t max = std::get<0>( iovs.back() ); - if( Base::tagTimeType()==cond::lumiid ){ + if( tagInfo.timeType==cond::lumiid ){ min = min >> 32; max = max >> 32; } @@ -362,9 +378,9 @@ namespace cond { cond::Time_t since = std::get<0>(iov); boost::posix_time::ptime time; std::string label(""); - if( Base::tagTimeType()==cond::lumiid || Base::tagTimeType()==cond::runnumber){ + if( tagInfo.timeType==cond::lumiid || tagInfo.timeType==cond::runnumber){ unsigned int nlumi = since & 0xFFFFFFFF; - if( Base::tagTimeType()==cond::lumiid ) since = since >> 32; + if( tagInfo.timeType==cond::lumiid ) since = since >> 32; label = std::to_string(since ); auto it = runInfo.find( since ); if ( it == runInfo.end() ){ @@ -373,11 +389,11 @@ namespace cond { } time = (*it).start; // add the lumi sections... - if( Base::tagTimeType()==cond::lumiid ){ + if( tagInfo.timeType==cond::lumiid ){ time += boost::posix_time::seconds( cond::time::SECONDS_PER_LUMI*nlumi ); label += (" : "+std::to_string(nlumi ) ); } - } else if ( Base::tagTimeType()==cond::timestamp ){ + } else if ( tagInfo.timeType==cond::timestamp ){ time = cond::time::to_boost( since ); label = boost::posix_time::to_simple_string( time ); } diff --git a/CondCore/Utilities/interface/PayloadInspectorModule.h b/CondCore/Utilities/interface/PayloadInspectorModule.h index 106ec5062ff48..d5b38371ecf8e 100644 --- a/CondCore/Utilities/interface/PayloadInspectorModule.h +++ b/CondCore/Utilities/interface/PayloadInspectorModule.h @@ -11,8 +11,10 @@ #define PAYLOAD_INSPECTOR_CLASS( CLASS_NAME ) \ boost::python::class_< CLASS_NAME, boost::python::bases >( STRINGIZE(PPCAT(plot_,CLASS_NAME)), boost::python::init<>()) \ .def("process",&cond::payloadInspector::PlotBase::process ) \ + .def("processTwoTags",&cond::payloadInspector::PlotBase::processTwoTags ) \ .def("payloadType",&cond::payloadInspector::PlotBase::payloadType ) \ .def("title",&cond::payloadInspector::PlotBase::title ) \ .def("isSingleIov",&cond::payloadInspector::PlotBase::isSingleIov ) \ + .def("isTwoTags",&cond::payloadInspector::PlotBase::isTwoTags ) \ .def("data",&cond::payloadInspector::PlotBase::data ) \ ; diff --git a/CondCore/Utilities/plugins/BasicP_PayloadInspector.cc b/CondCore/Utilities/plugins/BasicP_PayloadInspector.cc index 187c71c34a631..20b1ba3409403 100644 --- a/CondCore/Utilities/plugins/BasicP_PayloadInspector.cc +++ b/CondCore/Utilities/plugins/BasicP_PayloadInspector.cc @@ -177,6 +177,90 @@ namespace { } }; + class BasicPayload_data7 : public cond::payloadInspector::PlotImage { + public: + BasicPayload_data7() : cond::payloadInspector::PlotImage( "Example delivery picture" ){ + setTwoTags( true ); + } + + bool fill( const std::vector >& iovs ) override{ + auto iov0 = iovs.front(); + auto iov1 = iovs.back(); + std::shared_ptr payload0 = fetchPayload( std::get<1>(iov0) ); + std::shared_ptr payload1 = fetchPayload( std::get<1>(iov1) ); + + double xmax(100.),ymax(100.); + + TH2D h2D("h2D","Example",100,0.,xmax,100,0.,ymax); + + if( payload0.get() && payload1.get() ){ + if(payload0->m_vec.size()==10000 && payload1->m_vec.size()==10000 ){ + for( size_t i=0;i<100;i++ ) + for( size_t j=0;j<100;j++ ) { + auto diff = abs(payload0->m_vec[i*100+j] - payload1->m_vec[i*100+j]); + h2D.Fill(i,j,diff); + } + h2D.SetStats(false); + } + } + + TCanvas c("c","",20,20,900,500); + c.cd(); + c.SetLogz(); + h2D.SetNdivisions(18, "X"); + h2D.GetXaxis()->SetTickLength(0.00); + h2D.GetYaxis()->SetTickLength(0.00); + h2D.GetXaxis()->SetTitle("iphi"); + h2D.GetYaxis()->SetTitle("ieta"); + h2D.Draw("col"); + + //======= drawing lines ======== + ///// this is quite specific to the line style they need + + TLine l; + l.SetLineStyle(2); + l.DrawLine(0., ymax/2., xmax, ymax/2.); + for(int m = 0; m < int(xmax); m+=10) { + l.DrawLine(m, 0., m, 100.); + } + + c.RedrawAxis(); + + //========== writing text in the canvas============== + //// This is again quite specific part. I just tried to emulate what is there in DQM for EB. + + TLatex Tl; + TLatex Tll; + Tl.SetTextAlign(23); + Tl.SetTextSize(0.04); + + Tll.SetTextAlign(23); + Tll.SetTextSize(0.04); + + int j = 0; + for(int i = 1; i <=10; i++){ + std::string s = "+" + std::to_string(i); + char const *pchar = s.c_str(); + j+=10; + Tl.DrawLatex(j-5,int(ymax)/1.33,pchar); + } + + int z = 0; + for(int g = -10; g <0; g++){ + std::string ss = std::to_string(g); + char const *pchar1 = ss.c_str(); + z+= 10; + Tll.DrawLatex(z-5,int(ymax)/4,pchar1); + } + //========================= + + std::string fileName(m_imageFileName); + c.SaveAs(fileName.c_str()); + + return true; + } + }; + } PAYLOAD_INSPECTOR_MODULE( BasicPayload ){ @@ -187,4 +271,5 @@ PAYLOAD_INSPECTOR_MODULE( BasicPayload ){ PAYLOAD_INSPECTOR_CLASS( BasicPayload_data4 ); PAYLOAD_INSPECTOR_CLASS( BasicPayload_data5 ); PAYLOAD_INSPECTOR_CLASS( BasicPayload_data6 ); + PAYLOAD_INSPECTOR_CLASS( BasicPayload_data7 ); } diff --git a/CondCore/Utilities/plugins/Module_PayloadInspector.cc b/CondCore/Utilities/plugins/Module_PayloadInspector.cc index 3e96ed0262d2f..6accbfaac2ef5 100644 --- a/CondCore/Utilities/plugins/Module_PayloadInspector.cc +++ b/CondCore/Utilities/plugins/Module_PayloadInspector.cc @@ -6,9 +6,11 @@ BOOST_PYTHON_MODULE( pluginModule_PayloadInspector ) { .def_readonly("label", &cond::payloadInspector::ModuleVersion::label ); boost::python::class_< cond::payloadInspector::PlotBase > ( "PlotBase" ) .def("process",&cond::payloadInspector::PlotBase::process ) + .def("processTwoTags",&cond::payloadInspector::PlotBase::processTwoTags ) .def("payloadType",&cond::payloadInspector::PlotBase::payloadType ) .def("type",&cond::payloadInspector::PlotBase::type ) .def("title",&cond::payloadInspector::PlotBase::title ) .def("isSingleIov",&cond::payloadInspector::PlotBase::isSingleIov ) + .def("isTwoTags",&cond::payloadInspector::PlotBase::isTwoTags ) .def("data",&cond::payloadInspector::PlotBase::data ); } diff --git a/CondCore/Utilities/src/PayloadInspector.cc b/CondCore/Utilities/src/PayloadInspector.cc index e5f843d35f2e5..ac3d9ad9fe0f2 100644 --- a/CondCore/Utilities/src/PayloadInspector.cc +++ b/CondCore/Utilities/src/PayloadInspector.cc @@ -41,11 +41,15 @@ namespace cond { return m_plotAnnotations.singleIov; } + bool PlotBase::isTwoTags() const { + return m_plotAnnotations.twoTags; + } + std::string PlotBase::data() const { return m_data; } - bool PlotBase::process( const std::string& connectionString, const std::string& tag, const std::string& timeType, cond::Time_t begin, cond::Time_t end ){ + bool PlotBase::process( const std::string& connectionString, const std::string& tag, const std::string&, cond::Time_t begin, cond::Time_t end ){ init(); std::vector psets; @@ -55,7 +59,8 @@ namespace cond { static const edm::ServiceToken services(edm::ServiceRegistry::createSet(psets)); static const edm::ServiceRegistry::Operate operate(services); - m_tagTimeType = cond::time::timeTypeFromName(timeType); + m_tag0 = tag; + //m_tagTimeType = cond::time::timeTypeFromName(timeType); cond::persistency::ConnectionPool connection; m_dbSession = connection.createSession( connectionString ); m_dbSession.transaction().start(); @@ -67,6 +72,55 @@ namespace cond { return true; } + /** + bool PlotBase::process( const std::string& connectionString, const std::string& tag, cond::Time_t begin, cond::Time_t end ){ + init(); + + std::vector psets; + edm::ParameterSet pSet; + pSet.addParameter("@service_type",std::string("SiteLocalConfigService")); + psets.push_back(pSet); + static const edm::ServiceToken services(edm::ServiceRegistry::createSet(psets)); + static const edm::ServiceRegistry::Operate operate(services); + + m_tag0 = tag; + cond::persistency::ConnectionPool connection; + m_dbSession = connection.createSession( connectionString ); + m_dbSession.transaction().start(); + std::vector > iovs; + m_dbSession.getIovRange( tag, begin, end, iovs ); + m_data = processData( iovs ); + m_dbSession.transaction().commit(); + // fixme... + return true; + } + **/ + + bool PlotBase::processTwoTags( const std::string& connectionString, const std::string& tag0, const std::string& tag1, cond::Time_t time0, cond::Time_t time1 ){ + init(); + + std::vector psets; + edm::ParameterSet pSet; + pSet.addParameter("@service_type",std::string("SiteLocalConfigService")); + psets.push_back(pSet); + static const edm::ServiceToken services(edm::ServiceRegistry::createSet(psets)); + static const edm::ServiceRegistry::Operate operate(services); + + m_tag0 = tag0; + m_tag1 = tag1; + cond::persistency::ConnectionPool connection; + m_dbSession = connection.createSession( connectionString ); + m_dbSession.transaction().start(); + std::vector > iovs; + m_dbSession.getIovRange( tag0, time0, time0, iovs ); + m_dbSession.getIovRange( tag1, time1, time1, iovs ); + m_data = processData( iovs ); + m_dbSession.transaction().commit(); + // fixme... + return true; + } + + void PlotBase::init(){ } @@ -78,8 +132,19 @@ namespace cond { m_plotAnnotations.singleIov = flag; } - cond::TimeType PlotBase::tagTimeType() const { - return m_tagTimeType; + void PlotBase::setTwoTags( bool flag ){ + m_plotAnnotations.twoTags = flag; + if(flag) m_plotAnnotations.singleIov = flag; + } + + //cond::TimeType PlotBase::tagTimeType() const { + // return m_tagTimeType; + //} + + cond::Tag_t PlotBase::getTagInfo( const std::string& tag ){ + cond::Tag_t info; + m_dbSession.getTagInfo( tag, info ); + return info; } cond::persistency::Session PlotBase::dbSession(){ From d39be48e56363727b69a5c453e6239249e54835a Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 11 Feb 2019 15:45:30 +0100 Subject: [PATCH 082/686] GEM vfatv3 improved dataformat for HW classes backward compatible with v2 Removed struct dictionary from classes.h files --- DQM/GEM/plugins/GEMDQMStatusDigi.cc | 300 ++++----------- DQM/GEM/test/test.py | 6 +- DataFormats/GEMDigi/src/classes.h | 88 ----- DataFormats/GEMDigi/src/classes_def.xml | 24 -- EventFilter/GEMRawToDigi/BuildFile.xml | 3 +- .../GEMRawToDigi/interface/AMC13Event.h | 129 ++++--- EventFilter/GEMRawToDigi/interface/AMCdata.h | 356 ++++++------------ EventFilter/GEMRawToDigi/interface/GEBdata.h | 188 ++++----- .../interface/GEMAMC13EventCollection.h | 9 + .../interface/GEMAMCdataCollection.h | 9 + .../interface/GEMGEBdataCollection.h | 10 + .../interface/GEMVfatStatusDigi.h | 28 ++ .../interface/GEMVfatStatusDigiCollection.h | 10 + EventFilter/GEMRawToDigi/interface/VFATdata.h | 294 ++++++--------- .../GEMRawToDigi/plugins/BuildFile.xml | 1 + .../plugins/GEMDigiToRawModule.cc | 286 +++++++------- .../GEMRawToDigi/plugins/GEMDigiToRawModule.h | 12 +- .../plugins/GEMRawToDigiModule.cc | 225 ++++++----- .../GEMRawToDigi/plugins/GEMRawToDigiModule.h | 19 +- EventFilter/GEMRawToDigi/src/AMC13Event.cc | 130 ++----- EventFilter/GEMRawToDigi/src/AMCdata.cc | 31 ++ .../GEMRawToDigi/src/GEMVfatStatusDigi.cc | 11 + EventFilter/GEMRawToDigi/src/VFATdata.cc | 103 +++++ EventFilter/GEMRawToDigi/src/classes.h | 14 + EventFilter/GEMRawToDigi/src/classes_def.xml | 53 +++ .../GEMRawToDigi/test/unpackData-GEM.py | 26 +- 26 files changed, 1013 insertions(+), 1352 deletions(-) create mode 100644 EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h create mode 100644 EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h create mode 100644 EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h create mode 100644 EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h create mode 100644 EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h create mode 100644 EventFilter/GEMRawToDigi/src/AMCdata.cc create mode 100644 EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc create mode 100644 EventFilter/GEMRawToDigi/src/VFATdata.cc create mode 100644 EventFilter/GEMRawToDigi/src/classes.h create mode 100644 EventFilter/GEMRawToDigi/src/classes_def.xml diff --git a/DQM/GEM/plugins/GEMDQMStatusDigi.cc b/DQM/GEM/plugins/GEMDQMStatusDigi.cc index ce4a19750d539..9b66460835215 100644 --- a/DQM/GEM/plugins/GEMDQMStatusDigi.cc +++ b/DQM/GEM/plugins/GEMDQMStatusDigi.cc @@ -12,9 +12,9 @@ #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" #include @@ -42,53 +42,23 @@ class GEMDQMStatusDigi: public DQMEDAnalyzer edm::EDGetToken tagGEB_; edm::EDGetToken tagAMC_; - int AMCBinN(uint16_t BID_); - int GEBBinN(uint16_t BID_); - - MonitorElement *h1B1010All_; - MonitorElement *h1B1100All_; - MonitorElement *h1B1110All_; - - MonitorElement *h1FlagAll_; - MonitorElement *h1CRCAll_; - - MonitorElement *h1InputID_; - MonitorElement *h1Vwh_; - MonitorElement *h1Vwt_; - - MonitorElement *h1GEBError_; - MonitorElement *h1GEBWarning_; - - MonitorElement *h2B1010All_; - MonitorElement *h2B1100All_; - MonitorElement *h2B1110All_; - - MonitorElement *h2FlagAll_; - MonitorElement *h2CRCAll_; - - MonitorElement *h2InputID_; - MonitorElement *h2Vwh_; - MonitorElement *h2Vwt_; - - MonitorElement *h2GEBError_; - MonitorElement *h2GEBWarning_; - - MonitorElement *GEMDAV_; - MonitorElement *Tstate_; - MonitorElement *GDcount_; - MonitorElement *ChamT_; - MonitorElement *OOSG_; + MonitorElement *h1_vfat_quality_; + MonitorElement *h1_vfat_flag_; + MonitorElement *h2_vfat_quality_; + MonitorElement *h2_vfat_flag_; - MonitorElement *GEMDAV2D_; - MonitorElement *Tstate2D_; - MonitorElement *GDcount2D_; - MonitorElement *ChamT2D_; - MonitorElement *OOSG2D_; + MonitorElement *h1_geb_inputStatus_; + MonitorElement *h1_geb_vfatWordCnt_; + MonitorElement *h1_geb_zeroSupWordsCnt_; + MonitorElement *h1_geb_stuckData_; + MonitorElement *h1_geb_inFIFOund_; - std::unordered_map mlAMCID_; - std::unordered_map mlGEBID_; + MonitorElement *h1_amc_ttsState_; + MonitorElement *h1_amc_davCnt_; + MonitorElement *h1_amc_buffState_; + MonitorElement *h1_amc_oosGlib_; + MonitorElement *h1_amc_chTimeOut_; - }; using namespace std; @@ -98,8 +68,8 @@ GEMDQMStatusDigi::GEMDQMStatusDigi(const edm::ParameterSet& cfg) { tagVFAT_ = consumes(cfg.getParameter("VFATInputLabel")); - tagGEB_ = consumes(cfg.getParameter("GEBInputLabel")); - tagAMC_ = consumes(cfg.getParameter("AMCInputLabel")); + tagGEB_ = consumes(cfg.getParameter("GEBInputLabel")); + tagAMC_ = consumes(cfg.getParameter("AMCInputLabel")); } @@ -112,218 +82,78 @@ void GEMDQMStatusDigi::fillDescriptions(edm::ConfigurationDescriptions & descrip descriptions.add("GEMDQMStatusDigi", desc); } -int GEMDQMStatusDigi::AMCBinN(uint16_t BID_) { - - if(mlAMCID_.find(BID_) == mlAMCID_.end()){ - int addIdx = mlAMCID_.size(); - mlAMCID_[BID_] = addIdx; - - int nNumAMC = (int)mlAMCID_.size(); - string strLabel = "BID: "+to_string(BID_); - const char* tmpLabel = strLabel.data(); - ( (TH2F *)GEMDAV2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC); - ( (TH2F *)GEMDAV2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)Tstate2D_->getTH2F() )->SetBins(15, 0, 15, nNumAMC, 0, nNumAMC); - ( (TH2F *)Tstate2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)GDcount2D_->getTH2F() )->SetBins(32, 0, 32, nNumAMC, 0, nNumAMC); - ( (TH2F *)GDcount2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)ChamT2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC); - ( (TH2F *)ChamT2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)OOSG2D_->getTH2F() )->SetBins(1, 0, 1, nNumAMC, 0, nNumAMC); - ( (TH2F *)OOSG2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - } - - return mlAMCID_[BID_]; -} - -int GEMDQMStatusDigi::GEBBinN(uint16_t BID_){ - if(mlGEBID_.find(BID_) == mlGEBID_.end()){ - int addIdx = mlGEBID_.size(); - mlGEBID_[BID_] = addIdx; - - int nNumGEB = (int)mlGEBID_.size(); - string strLabel = "BID: "+to_string(BID_); - const char* tmpLabel = strLabel.data(); - ( (TH2F *)h2B1010All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1010All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2B1100All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1100All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2B1110All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1110All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2FlagAll_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2FlagAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2CRCAll_->getTH2F() )->SetBins(0xffff, -32768, 32768, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2CRCAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2InputID_->getTH2F() )->SetBins(31, 0x0 , 0b11111, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2InputID_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2Vwh_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2Vwh_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2Vwt_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2Vwt_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2GEBError_->getTH2F() )->SetBins(5, 0, 5, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2GEBError_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2GEBWarning_->getTH2F() )->SetBins(10, 0, 10, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2GEBWarning_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - } - return mlGEBID_[BID_]; -} - -//---------------------------------------------------------------------------------------------------- - - void GEMDQMStatusDigi::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const & iSetup) { ibooker.cd(); ibooker.setCurrentFolder("GEM/StatusDigi"); - h1B1010All_ = ibooker.book1D("vfatErrors_all_b1010", "Control Bit 1010", 15, 0x0 , 0xf); - h1B1100All_ = ibooker.book1D("vfatErrors_all_b1100", "Control Bit 1100", 15, 0x0 , 0xf); - h1B1110All_ = ibooker.book1D("vfatErrors_all_b1110", "Control Bit 1110", 15, 0x0 , 0xf); - h2B1010All_ = ibooker.book2D("vfatErrors_all_b1010_PerGEB", "Control Bit 1010", 15, 0x0 , 0xf, 1, 0, 1); - h2B1100All_ = ibooker.book2D("vfatErrors_all_b1100_PerGEB", "Control Bit 1100", 15, 0x0 , 0xf, 1, 0, 1); - h2B1110All_ = ibooker.book2D("vfatErrors_all_b1110_PerGEB", "Control Bit 1110", 15, 0x0 , 0xf, 1, 0, 1); - - h1FlagAll_ = ibooker.book1D("vfatErrors_all_flag", "Control Flags", 15, 0x0 , 0xf); - h1CRCAll_ = ibooker.book1D("vfatErrors_all_CRC", "CRC Mismatches", 0xffff, -32768, 32768); - h2FlagAll_ = ibooker.book2D("vfatErrors_all_flag_PerGEB", "Control Flags", 15, 0x0 , 0xf, 1, 0, 1); - h2CRCAll_ = ibooker.book2D("vfatErrors_all_CRC_PerGEB", "CRC Mismatches", 0xffff, -32768, 32768, 1, 0, 1); - - h1InputID_ = ibooker.book1D("GEB_InputID", "GEB GLIB input ID", 31, 0x0 , 0b11111); - h1Vwh_ = ibooker.book1D("VFAT_Vwh", "VFAT word count", 4095, 0x0 , 0xfff); - h1Vwt_ = ibooker.book1D("VFAT_Vwt", "VFAT word count", 4095, 0x0 , 0xfff); - h2InputID_ = ibooker.book2D("GEB_InputID_PerGEB", "GEB GLIB input ID", 31, 0x0 , 0b11111, 1, 0, 1); - h2Vwh_ = ibooker.book2D("VFAT_Vwh_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1); - h2Vwt_ = ibooker.book2D("VFAT_Vwt_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1); - - h1GEBError_ = ibooker.book1D("GEB_Errors", "GEB Critical Errors", 5, 0, 5); - h2GEBError_ = ibooker.book2D("GEB_Errors_PerGEB", "GEB Critical Errors", 5, 0, 5, 1, 0, 1); - TH1F *histErr1D = h1GEBError_->getTH1F(); - TH2F *histErr2D = h2GEBError_->getTH2F(); - const char *error_flags[5] = {"Event Size Overflow", "L1AFIFO Full", "InFIFO Full", "Evt FIFO Full","InFIFO Underflow"}; - for (int i = 1; i< histErr1D->GetNbinsX()+1; i++) {histErr1D->GetXaxis()->SetBinLabel(i, error_flags[i-1]); histErr2D->GetXaxis()->SetBinLabel(i, error_flags[i-1]);} - h1GEBWarning_ = ibooker.book1D("GEB_Warnings", "GEB Warnings", 10, 0, 10); - h2GEBWarning_ = ibooker.book2D("GEB_Warnings_PerGEB", "GEB Warnings", 10, 0, 10, 1, 0, 1); - TH1F *histWar1D = h1GEBWarning_->getTH1F(); - TH2F *histWar2D = h2GEBWarning_->getTH2F(); - const char *warning_flags[10] = {"BX AMC-OH Mismatch", "BX AMC-VFAT Mismatch", "OOS AMC OH", "OOS AMC VFAT","No VFAT Marker","Event Size Warn", "L1AFIFO Near Full", "InFIFO Near Full", "EvtFIFO Near Full", "Stuck Data"}; - for (int i = 1; iGetNbinsX()+1; i++) {histWar1D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]); histWar2D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]);} - - GEMDAV_ = ibooker.book1D("GEMDAV", "GEM DAV list", 24, 0, 24); - Tstate_ = ibooker.book1D("Tstate", "TTS state", 15, 0, 15); - GDcount_ = ibooker.book1D("GDcount", "GEM DAV count", 32, 0, 32); - ChamT_ = ibooker.book1D("ChamT", "Chamber Timeout", 24, 0, 24); - OOSG_ = ibooker.book1D("OOSG", "OOS GLIB", 1, 0, 1); - - GEMDAV2D_ = ibooker.book2D("GEMDAV_PerAMC", "GEM DAV list", 24, 0, 24, 1, 0, 1); - Tstate2D_ = ibooker.book2D("Tstate_PerAMC", "TTS state", 15, 0, 15, 1, 0, 1); - GDcount2D_ = ibooker.book2D("GDcount_PerAMC", "GEM DAV count", 32, 0, 32, 1, 0, 1); - ChamT2D_ = ibooker.book2D("ChamT_PerAMC", "Chamber Timeout", 24, 0, 24, 1, 0, 1); - OOSG2D_ = ibooker.book2D("OOSG_PerAMC", "OOS GLIB", 1, 0, 1, 1, 0, 1); + h1_vfat_quality_ = ibooker.book1D("vfat quality", "quality", 6, 0, 6); + h1_vfat_flag_ = ibooker.book1D("vfat flag", "flag", 5, 0, 5); + + h2_vfat_quality_ = ibooker.book2D("vfat quality per geb", "quality", 6, 0 , 6, 36, 0, 36); + h2_vfat_flag_ = ibooker.book2D("vfat flag per geb", "flag", 5, 0, 5, 36, 0, 36); + + h1_geb_inputStatus_ = ibooker.book1D("geb input status", "inputStatus", 10, 0, 10); + h1_geb_vfatWordCnt_ = ibooker.book1D("geb no. vfats", "nvfats", 25, 0, 25); + h1_geb_zeroSupWordsCnt_ = ibooker.book1D("geb zeroSupWordsCnt", "zeroSupWordsCnt", 10, 0, 10); + h1_geb_stuckData_ = ibooker.book1D("geb stuckData", "stuckData", 10, 0, 10); + h1_geb_inFIFOund_ = ibooker.book1D("geb inFIFOund", "inFIFOund", 10, 0, 10); + + h1_amc_ttsState_ = ibooker.book1D("amc ttsState", "ttsState", 10, 0, 10); + h1_amc_davCnt_ = ibooker.book1D("amc davCnt", "davCnt", 10, 0, 10); + h1_amc_buffState_ = ibooker.book1D("amc buffState", "buffState", 10, 0, 10); + h1_amc_oosGlib_ = ibooker.book1D("amc oosGlib", "oosGlib", 10, 0, 10); + h1_amc_chTimeOut_ = ibooker.book1D("amc chTimeOut", "chTimeOut", 10, 0, 10); } void GEMDQMStatusDigi::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) { edm::Handle gemVFAT; - edm::Handle gemGEB; - edm::Handle gemAMC; - event.getByToken( this->tagVFAT_, gemVFAT); - event.getByToken( this->tagGEB_, gemGEB); - event.getByToken( this->tagAMC_, gemAMC); + edm::Handle gemGEB; + edm::Handle gemAMC; + event.getByToken( tagVFAT_, gemVFAT); + event.getByToken( tagGEB_, gemGEB); + event.getByToken( tagAMC_, gemAMC); for (GEMVfatStatusDigiCollection::DigiRangeIterator vfatIt = gemVFAT->begin(); vfatIt != gemVFAT->end(); ++vfatIt){ + GEMDetId gemid = (*vfatIt).first; + float nIdx = gemid.chamber() + (gemid.layer()-1)/2.0; const GEMVfatStatusDigiCollection::Range& range = (*vfatIt).second; - uint16_t tmpID = (*vfatIt).first; - int nIdx = GEBBinN(tmpID); - for ( auto vfatError = range.first; vfatError != range.second; ++vfatError ) { + for ( auto vfatStat = range.first; vfatStat != range.second; ++vfatStat ) { - h1B1010All_->Fill(vfatError->getB1010()); - h1B1100All_->Fill(vfatError->getB1100()); - h1B1110All_->Fill(vfatError->getB1110()); - h1FlagAll_->Fill(vfatError->getFlag()); - h1CRCAll_->Fill(vfatError->getCrc()); - - h2B1010All_->Fill(vfatError->getB1010(), nIdx); - h2B1100All_->Fill(vfatError->getB1100(), nIdx); - h2B1110All_->Fill(vfatError->getB1110(), nIdx); - h2FlagAll_->Fill(vfatError->getFlag(), nIdx); - h2CRCAll_->Fill(vfatError->getCrc(), nIdx); - } + h1_vfat_quality_->Fill(vfatStat->quality()); + h1_vfat_flag_->Fill(vfatStat->flag()); + h2_vfat_quality_->Fill(vfatStat->quality(), nIdx); + h2_vfat_flag_->Fill(vfatStat->flag(), nIdx); } + } - for (GEMGEBStatusDigiCollection::DigiRangeIterator gebIt = gemGEB->begin(); gebIt != gemGEB->end(); ++gebIt){ - const GEMGEBStatusDigiCollection::Range& range = (*gebIt).second; + for (GEMGEBdataCollection::DigiRangeIterator gebIt = gemGEB->begin(); gebIt != gemGEB->end(); ++gebIt){ + const GEMGEBdataCollection::Range& range = (*gebIt).second; for ( auto GEBStatus = range.first; GEBStatus != range.second; ++GEBStatus ) { - uint16_t tmpID = (*gebIt).first; - h1InputID_->Fill(tmpID); - h1Vwh_->Fill(GEBStatus->getVwh()); - h1Vwt_->Fill(GEBStatus->getVwt()); - int nIdx = GEBBinN(tmpID); - h2InputID_->Fill(tmpID, nIdx); - h2Vwh_->Fill(GEBStatus->getVwh(), nIdx); - h2Vwt_->Fill(GEBStatus->getVwt(), nIdx); - - for ( int bin = 0 ; bin < cBit_ ; bin++ ) { - if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) { - h1GEBWarning_->Fill(bin); - h2GEBWarning_->Fill(bin, nIdx); - } - } - for ( int bin = cBit_ ; bin < eBit_ ; bin++ ) { - if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) { - h1GEBError_->Fill(bin - 9); - h2GEBError_->Fill(bin - 9, nIdx); - } - } + h1_geb_inputStatus_->Fill(GEBStatus->inputStatus()); + h1_geb_vfatWordCnt_->Fill(GEBStatus->vfatWordCnt()/3); + h1_geb_zeroSupWordsCnt_->Fill(GEBStatus->zeroSupWordsCnt()); + h1_geb_stuckData_->Fill(GEBStatus->stuckData()); + h1_geb_inFIFOund_->Fill(GEBStatus->inFIFOund()); - if ( ( GEBStatus->getInFu() & 0x1 ) != 0 ) { - h1GEBError_->Fill(9); - h2GEBError_->Fill(9, nIdx); - } - if ( ( GEBStatus->getStuckd() & 0x1 ) != 0 ) { - h1GEBWarning_->Fill(9); - h2GEBWarning_->Fill(9, nIdx); - } } } - for (GEMAMCStatusDigiCollection::DigiRangeIterator amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt){ - const GEMAMCStatusDigiCollection::Range& range = (*amcIt).second; + for (GEMAMCdataCollection::DigiRangeIterator amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt){ + const GEMAMCdataCollection::Range& range = (*amcIt).second; for ( auto amc = range.first; amc != range.second; ++amc ) { - uint16_t tmpID = (*amcIt).first; - int nIdxAMC = AMCBinN(tmpID); - uint8_t binFired = 0; - for (int bin = 0; bin < nVfat_; bin++){ - binFired = ((amc->GEMDAV() >> bin) & 0x1); - if (binFired) {GEMDAV_->Fill(bin); GEMDAV2D_->Fill(bin, nIdxAMC);} - binFired = ((amc->ChamT() >> bin) & 0x1); - if (binFired) {ChamT_->Fill(bin); ChamT2D_->Fill(bin, nIdxAMC);} - } - - Tstate_->Fill(amc->Tstate()); - GDcount_->Fill(amc->GDcount()); - OOSG_->Fill(amc->OOSG()); - - Tstate2D_->Fill(amc->Tstate(), nIdxAMC); - GDcount2D_->Fill(amc->GDcount(), nIdxAMC); - OOSG2D_->Fill(amc->OOSG(), nIdxAMC); + + h1_amc_ttsState_->Fill(amc->ttsState()); + h1_amc_davCnt_->Fill(amc->davCnt()); + h1_amc_buffState_->Fill(amc->buffState()); + h1_amc_oosGlib_->Fill(amc->oosGlib()); + h1_amc_chTimeOut_->Fill(amc->chTimeOut()); } } + } DEFINE_FWK_MODULE(GEMDQMStatusDigi); diff --git a/DQM/GEM/test/test.py b/DQM/GEM/test/test.py index e6486e9d23ece..75104f7e73482 100644 --- a/DQM/GEM/test/test.py +++ b/DQM/GEM/test/test.py @@ -46,13 +46,13 @@ ############## DB file ################# from CondCore.CondDB.CondDB_cfi import * CondDB.DBParameters.authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb') -CondDB.connect = cms.string('sqlite_fip:DQM/GEM/data/GEMELMap.db') +CondDB.connect = cms.string('sqlite_fip:DQM/GEM/data/GEMeMap.db') process.GEMCabling = cms.ESSource("PoolDBESSource", CondDB, toGet = cms.VPSet(cms.PSet( - record = cms.string('GEMELMapRcd'), - tag = cms.string('GEMELMap_v2') + record = cms.string('GEMeMapRcd'), + tag = cms.string('GEMeMap_v2') )), ) #################################### diff --git a/DataFormats/GEMDigi/src/classes.h b/DataFormats/GEMDigi/src/classes.h index 030ce821d8c1b..f4b398d4bc43d 100644 --- a/DataFormats/GEMDigi/src/classes.h +++ b/DataFormats/GEMDigi/src/classes.h @@ -25,94 +25,6 @@ #include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" #include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" - -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" - -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" - #include "DataFormats/Common/interface/Wrapper.h" #include -namespace DataFormats_GEMDigi { - struct dictionary { - - GEMDigi g; - std::vector vg; - std::vector > vvg; - GEMDigiCollection gcol; - edm::Wrapper wg; - - - GEMVfatStatusDigi gvs; - std::vector vgvs; - std::vector > vvgvs; - GEMVfatStatusDigiCollection gvscol; - edm::Wrapper wgvs; - - GEMGEBStatusDigi ggs; - std::vector vggs; - std::vector > vvggs; - GEMGEBStatusDigiCollection ggscol; - edm::Wrapper wggs; - - GEMAMCStatusDigi gas; - std::vector vgas; - std::vector > vvgas; - GEMAMCStatusDigiCollection gascol; - edm::Wrapper wgas; - - GEMPadDigi gc; - std::vector vgc; - std::vector > vvgc; - GEMPadDigiCollection gccol; - edm::Wrapper wgc; - - GEMPadDigiCluster gcc; - std::vector vgcc; - std::vector > vvgcc; - GEMPadDigiClusterCollection gcccol; - edm::Wrapper wgcc; - - GEMCoPadDigi gcp; - std::vector vgcp; - std::vector > vvgcp; - GEMCoPadDigiCollection gcpcol; - edm::Wrapper wgcp; - - ME0DigiPreReco m; - std::vector vm; - std::vector > vvm; - ME0DigiPreRecoCollection mcol; - edm::Wrapper wm; - ME0DigiPreRecoMap mmap; - edm::Wrapper wmmap; - - ME0Digi mm; - std::vector vmm; - std::vector > vvmm; - ME0DigiCollection mmcol; - edm::Wrapper wmm; - - ME0PadDigi mp; - std::vector vmp; - std::vector > vvmp; - ME0PadDigiCollection mpcol; - edm::Wrapper wmp; - - ME0PadDigiCluster mpc; - std::vector vmpc; - std::vector > vvmpc; - ME0PadDigiClusterCollection mpccol; - edm::Wrapper wmpc; - - ME0TriggerDigi ml; - std::vector vml; - std::vector > vvml; - ME0TriggerDigiCollection mlcol; - edm::Wrapper wml; - }; -} diff --git a/DataFormats/GEMDigi/src/classes_def.xml b/DataFormats/GEMDigi/src/classes_def.xml index 5b7e0ea51cb61..5af830422ffec 100644 --- a/DataFormats/GEMDigi/src/classes_def.xml +++ b/DataFormats/GEMDigi/src/classes_def.xml @@ -9,30 +9,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/EventFilter/GEMRawToDigi/BuildFile.xml b/EventFilter/GEMRawToDigi/BuildFile.xml index adb5e7ade841f..bb98fdbe7708a 100644 --- a/EventFilter/GEMRawToDigi/BuildFile.xml +++ b/EventFilter/GEMRawToDigi/BuildFile.xml @@ -2,7 +2,6 @@ - @@ -12,5 +11,5 @@ - + diff --git a/EventFilter/GEMRawToDigi/interface/AMC13Event.h b/EventFilter/GEMRawToDigi/interface/AMC13Event.h index 0a2d3467e1482..c387ffd160743 100644 --- a/EventFilter/GEMRawToDigi/interface/AMC13Event.h +++ b/EventFilter/GEMRawToDigi/interface/AMC13Event.h @@ -4,71 +4,100 @@ #include "AMCdata.h" namespace gem { + + union CDFHeader { + uint64_t word; + struct { + uint64_t fov : 8; // not used + uint64_t sourceId : 12; // FED number assigned by CDAQ + uint64_t bxId : 12; // Bunch crossing 0...3563 + uint64_t lv1Id : 24; // Level 1 ID (hardware event number) + uint64_t eventType : 4; // Event Type (1 for normal, 2 for calibration) + uint64_t cb5 : 4; // 0x5 + }; + }; + union AMC13Header { + uint64_t word; + struct { + uint64_t cb0 : 4; // 0x0 + uint64_t orbitN : 32; // Orbit Number + uint64_t reserved0 : 16; // reserved + uint64_t nAMC : 4; // Number of AMCs following (0 to 12) + uint64_t calType : 4; // Calibration event type + uint64_t uFov : 4; // Format version: 0x1 + }; + }; + union AMC13Trailer { + uint64_t word; + struct { + uint64_t bxIdT : 12; // bx id + uint64_t lv1IdT : 8; // level 1 id + uint64_t blkN : 8; // block number + uint64_t crc32 : 36; // Overall CRC (first 34 bits) + }; + }; + union CDFTrailer { + uint64_t word; + struct { + uint64_t tts : 8; // tts (first 4 bits) + uint64_t evtStat : 4; // event status + uint64_t crcCDF : 20; // CDF crc (first 16 bits) + uint64_t evtLength : 24; // event length + uint64_t cbA : 8; // 0xA (first 4 bits) + }; + }; + class AMC13Event { + public: - AMC13Event(){} - ~AMC13Event(){m_amcHeaders.clear(); m_amcs.clear();} + AMC13Event() {} + ~AMC13Event() {amcHeaders_.clear(); amcs_.clear();} - int nAMC() const {return unsigned(m_nAMC);} - int bx_id() const {return unsigned(m_BX_id);} - int lv1_id() const {return unsigned(m_LV1_id);} - int source_id() const {return unsigned(m_Source_id);} - //const std::vector * amcs() const {return &m_amcs;} + void setCDFHeader(uint64_t word) { cdfh_ = word;} + void setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id); + uint64_t getCDFHeader() const { return cdfh_;} - uint64_t getCDFHeader() const; - void setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id); - void setCDFHeader(uint64_t word); + void setAMC13Header(uint64_t word) { amc13h_ = word;} + void setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN); + uint64_t getAMC13Header() const { return amc13h_;} - uint64_t getAMC13header() const; - void setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0); - void setAMC13header(uint64_t word); + void setAMC13Trailer(uint64_t word) { amc13t_ = word;} + void setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT); + uint64_t getAMC13Trailer() const { return amc13t_;} + + void setCDFTrailer(uint64_t word) { cdft_ = word;} + void setCDFTrailer(uint32_t EvtLength); + uint64_t getCDFTrailer() const { return cdft_;} + + uint16_t bxId() const {return CDFHeader{cdfh_}.bxId;} + uint32_t lv1Id() const {return CDFHeader{cdfh_}.lv1Id;} + uint16_t sourceId() const {return CDFHeader{cdfh_}.sourceId;} + + uint8_t nAMC() const {return AMC13Header{amc13h_}.nAMC;} - const std::vector * getAMCheaders() const {return &m_amcHeaders;} + const std::vector * getAMCheaders() const {return &amcHeaders_;} void addAMCheader(uint64_t word); void addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID); - const std::vector * getAMCpayloads() const {return &m_amcs;} - void addAMCpayload(const AMCdata& a){m_amcs.push_back(a);} - - uint64_t getAMC13trailer() const; - void setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT); - void setAMC13trailer(uint64_t word); - - uint64_t getCDFTrailer() const; - void setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf); - void setCDFTrailer(uint64_t word); + const std::vector * getAMCpayloads() const {return &amcs_;} + void addAMCpayload(const AMCdata& a) {amcs_.push_back(a);} private: - // CDF Header - uint8_t m_cb5; // control bit, should be 0x5 bits 60-63 - uint8_t m_Evt_ty; - uint32_t m_LV1_id; - uint16_t m_BX_id; - uint16_t m_Source_id; - // AMC13 header - uint8_t m_CalTyp; - uint8_t m_nAMC; - uint32_t m_OrN; - uint8_t m_cb0; // control bit, should be 0b0000 + uint64_t cdfh_; + uint64_t amc13h_; + uint64_t amc13t_; + uint64_t cdft_; + // AMC headers - std::vector m_amcHeaders; - /* std::vector m_AMC_size; */ - /* std::vector m_Blk_No; */ - /* std::vector m_AMC_No; */ - /* std::vector m_BoardID; */ + std::vector amcHeaders_; // AMCs payload - std::vector m_amcs; - //AMC13 trailer - uint32_t m_CRC_amc13; - uint8_t m_Blk_NoT; - uint8_t m_LV1_idT; - uint16_t m_BX_idT; - //CDF trailer - uint8_t m_cbA; // control bit, should be 0xA bits 60-63 - uint32_t m_EvtLength; - uint16_t m_CRC_cdf; + std::vector amcs_; + /* CDFHeader cdfh_; */ + /* AMC13Header amc13h_; */ + /* AMC13Trailer amc13t_; */ + /* CDFTrailer cdft_; */ }; } #endif diff --git a/EventFilter/GEMRawToDigi/interface/AMCdata.h b/EventFilter/GEMRawToDigi/interface/AMCdata.h index 73d7f403f8d46..6b6cecbc97fe7 100644 --- a/EventFilter/GEMRawToDigi/interface/AMCdata.h +++ b/EventFilter/GEMRawToDigi/interface/AMCdata.h @@ -1,259 +1,135 @@ #ifndef EventFilter_GEMRawToDigi_AMCdata_h #define EventFilter_GEMRawToDigi_AMCdata_h -#include #include "GEBdata.h" -//!A class for AMC data -/** - The number after the ":" indicates how many bits a certain item consists of. -*/ +#include + namespace gem { + + union AMCheader1 { + uint64_t word; + struct { + uint64_t dataLength : 20; // Overall size of this FED event fragment + uint64_t bxID : 12; // Bunch crossing ID + uint64_t l1AID : 24; // L1A number – basically this is like event number, but it’s reset by resync + uint64_t AMCnum : 4; // Slot number of the AMC + uint64_t reserved : 4; // not used + }; + }; + union AMCheader2 { + uint64_t word; + struct { + uint64_t boardID : 16; // 8bit long GLIB serial number + uint64_t orbitNum : 16; + uint64_t param3 : 8; + uint64_t param2 : 8; + uint64_t param1 : 8; + uint64_t runType : 4; // run types like physics, cosmics, threshold scan, latency scan, etc.. + uint64_t formatVer : 4; // Current format version = 0x0 + }; + }; + union AMCTrailer { + uint64_t word; + struct { + uint64_t dataLengthT: 20; // Overall size of this FED event fragment + uint64_t l1AIDT : 12; // 8bit long GLIB serial number (first 8 bits) + uint64_t crc : 32; + }; + }; + union EventHeader { + uint64_t word; + struct { + uint64_t ttsState : 11; // GLIB TTS state at the moment when this event was built. + uint64_t davCnt : 5; // Number of chamber blocks + uint64_t buffState : 24; // buffer error + uint64_t davList : 24; // Bitmask indicating which inputs/chambers have data + }; + }; + union EventTrailer { + uint64_t word; + struct { + uint64_t oosGlib : 40; // GLIB is outâ€ofâ€sync (critical): L1A ID is different for different chambers in this event (1 bit) + uint64_t chTimeOut : 24; // GLIB did not receive data from a particular input for this L1A + }; + }; + class AMCdata { - public: - //!Constructor for the class - AMCdata(){}; - AMCdata(const uint8_t AMCnum_, - const uint32_t L1A_, - const uint16_t BX_, - const uint32_t Dlength_, - const uint8_t FV_, - const uint8_t Rtype_, - const uint8_t Param1_, - const uint8_t Param2_, - const uint8_t Param3_, - const uint16_t Onum_, - const uint16_t BID_, - const uint32_t GEMDAV_, - const uint64_t Bstatus_, - const uint8_t GDcount_, - const uint8_t Tstate_, - const uint32_t ChamT_, - const uint8_t OOSG_) : - m_AMCnum(AMCnum_), - m_L1A(L1A_), - m_BX(BX_), - m_Dlength(Dlength_), - m_FV(FV_), - m_Rtype(Rtype_), - m_Param1(Param1_), - m_Param2(Param2_), - m_Param3(Param3_), - m_Onum(Onum_), - m_BID(BID_), - m_GEMDAV(GEMDAV_), - m_Bstatus(Bstatus_), - m_GDcount(GDcount_), - m_Tstate(Tstate_), - m_ChamT(ChamT_), - m_OOSG(OOSG_){} - //!Destructor for the class - ~AMCdata(){gebd.clear();} - - //!Reads the word for AMC Header - //Fills the AMC number, L1A ID, BX ID, and Data Length - void setAMCheader1(uint64_t word) - { - m_AMCnum = 0x0f & (word >> 56); /*!> 32); /*!> 20); /*!(m_AMCnum & 0x0f) << 56) | - (static_cast(m_L1A & 0x00ffffff) << 32) | - (static_cast(m_BX & 0x0fff) << 20) | - (static_cast(m_Dlength & 0x000fffff)); - } - //!Reads the word for the AMC Header 2 - // Fills the Format Version, Run Type, Run Param 1, Run Param 2, Run Param 3, Orbit Number, and Board ID - void setAMCheader2(uint64_t word) - { - m_FV = 0x0f & (word >> 60); /*!> 56); /*!> 48; /*!> 40; /*!> 32; /*!> 16; /*!(m_FV & 0x0f) << 60) | - (static_cast(m_Rtype & 0x0f) << 56) | - (static_cast(m_Param1) << 48) | - (static_cast(m_Param2) << 40) | - (static_cast(m_Param3) << 32) | - (static_cast(m_Onum) << 16) | - (static_cast(m_BID)); - } + public: + AMCdata() {}; + ~AMCdata() {gebd_.clear();} + + void setAMCheader1(uint64_t word) { amch1_ = word;} + void setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum); + uint64_t getAMCheader1() const { return amch1_;} + + void setAMCheader2(uint64_t word) { amch2_ = word;} + void setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType); + uint64_t getAMCheader2() const { return amch2_;} + + void setAMCTrailer(uint64_t word) { amct_ = word;} + uint64_t getAMCTrailer() const { return amct_;} + + void setGEMeventHeader(uint64_t word) { eh_ = word;} + void setGEMeventHeader(uint8_t davCnt, uint32_t davList); + uint64_t getGEMeventHeader() const { return eh_;} + + void setGEMeventTrailer(uint64_t word) { et_ = word;} + uint64_t getGEMeventTrailer() const { return et_;} + + uint32_t dataLength() const {return AMCheader1{amch1_}.dataLength;} + uint16_t bx() const {return AMCheader1{amch1_}.bxID;} + uint32_t l1A() const {return AMCheader1{amch1_}.l1AID;} + uint8_t amcNum() const {return AMCheader1{amch1_}.AMCnum;} + + uint16_t boardId() const {return AMCheader2{amch2_}.boardID;} + uint16_t orbitNum() const {return AMCheader2{amch2_}.orbitNum;} + uint8_t param3() const {return AMCheader2{amch2_}.param3;} + uint8_t param2() const {return AMCheader2{amch2_}.param2;} + uint8_t param1() const {return AMCheader2{amch2_}.param1;} + uint8_t runType() const {return AMCheader2{amch2_}.runType;} + uint8_t formatVer() const {return AMCheader2{amch2_}.formatVer;} - //!Reads the word for the GEM Event Header - // Fills the GEM DAV list, Buffer Status, GEM DAV count, and TTS state. - void setGEMeventHeader(uint64_t word) - { - m_GEMDAV = 0x00ffffff & (word >> 40); /*!> 16); /*!> 11); /*!(m_GEMDAV & 0x00ffffff) << 40) | - (static_cast(m_Bstatus & 0x00ffffff) << 16) | - (static_cast(m_GDcount & 0b00011111) << 11) | - (static_cast(m_Tstate & 0b00000111)); - } - - //!Reads the word for the GEM Event Trailer - // Fills the Chamber Timeout and OOS GLIB. - void setGEMeventTrailer(uint64_t word) - { - m_ChamT = 0x00ffffff & (word >> 40); /*!> 39); /*!(m_ChamT & 0x00ffffff) << 40) | - (static_cast(m_OOSG & 0b00000001) << 39); - } - - //!Reads the word for the AMC Trailer - void setAMCTrailer(uint64_t word) - { - m_CRC = word >> 32; - m_L1AT = word >> 24; - m_DlengthT = 0x000fffff & word; - } - uint64_t getAMCTrailer() const - { - return - (static_cast(m_CRC) << 32) | - (static_cast(m_L1AT) << 24) | - (static_cast(m_DlengthT & 0x000fffff)); - } + uint16_t ttsState() const {return EventHeader{eh_}.ttsState;} + uint8_t davCnt() const {return EventHeader{eh_}.davCnt;} + uint32_t buffState() const {return EventHeader{eh_}.buffState;} + uint32_t davList() const {return EventHeader{eh_}.davList;} - uint8_t amcNum() const {return m_AMCnum;} /// * gebs() const {return &gebd;} + const std::vector * gebs() const {return &gebd_;} private: - std::vector gebd; /// gebd_; /// #include "VFATdata.h" -//!A class for GEB data -/** - The number after the ":" indicates how many bits a certain item consists of. -*/ +#include + namespace gem { + // Input status 1 bit for each + // BX mismatch GLIB OH / BX mismatch GLIB VFAT / OOS GLIB OH / OOS GLIB VFAT / No VFAT marker + // Event size warn / L1AFIFO near full / InFIFO near full / EvtFIFO near full / Event size overflow + // L1AFIFO full / InFIFO full / EvtFIFO full + union GEBchamberHeader { + uint64_t word; + struct { + uint64_t inputStatus : 23; // Input status (critical) only first 13 bits used + uint64_t vfatWordCnt : 12; // Size of VFAT payload in 64bit words expected to send to AMC13 + uint64_t inputID : 5 ; // GLIB input ID (starting at 0) + uint64_t zeroSupWordsCnt : 24; // Bitmask indicating if certain VFAT blocks have been zero suppressed + }; + }; + union GEBchamberTrailer { + uint64_t word; + struct { + uint64_t ecOH : 20; // OH event counter + uint64_t bcOH : 14; // OH bunch crossing + uint64_t stuckData : 1; // Input status (warning): There was data in InFIFO or EvtFIFO when L1A FIFO was empty + uint64_t inFIFOund : 1; // Input status (critical): Input FIFO underflow occurred while sending this event + uint64_t vfatWordCntT : 12; // Size of VFAT payload in 64bit words sent to AMC13 + uint64_t ohcrc : 16; // CRC of OH data (currently not available – filled with 0) + }; + }; + class GEBdata { public: - GEBdata(){}; - ~GEBdata(){m_vfatd.clear();} + + GEBdata() {}; + ~GEBdata() {vfatd_.clear();} - // need to include all the flags - //!Reads the word for the GEM Chamber Header. Puts the thirteen flags in a vector. - /** - Fills the Zero Suppression, GLIB Input ID, VFAT word count, and Thirteen Flags. - */ - void setChamberHeader(uint64_t word) - { - m_ZeroSupWordsCnt = 0x0fff & (word >> 40); /*!Zero suppressed words counter*/ - m_InputID = 0b00011111 & (word >> 35); /*!> 23); /*!> i)); - } - } - uint64_t getChamberHeader() const + //!Read chamberHeader from the block. + void setChamberHeader(uint64_t word) { ch_ = word;} + void setChamberHeader(uint16_t vfatWordCnt, uint8_t inputID) { - return - (static_cast(m_ZeroSupWordsCnt & 0x0fff) << 40) | - (static_cast(m_InputID & 0b00011111) << 35) | - (static_cast(m_Vwh & 0x0fff) << 23) | - (static_cast(m_ErrorC & 0b0001111111111111)); + GEBchamberHeader u; + u.vfatWordCnt = vfatWordCnt; + u.inputID = inputID; + ch_ = u.word; } + uint64_t getChamberHeader() const { return ch_;} - //return specific flags - //!Returns one of thirteen flags from GEM chamber header. - /** - Argument must be between 0 and 12. The flags corresponding to a given argument are shown. - 12->EvtFIFO full 11->InFIFO full 10->L1AFIFO full 9->Even size overflow 8->EvtFIFO near full 5->InFIFO near full - 6->L1AFIFO near full 5->Event size warn 4->No VFAT marker 3->OOS GLIB VFAT 2->OOS GLIB OH - 1->BX mismatch GLIB VFAT 0->BX mismatch GLIB OH - */ - uint8_t getGEBflag(int c) const + //!Read chamberTrailer from the block. + void setChamberTrailer(uint64_t word) { ct_ = word;} + void setChamberTrailer(uint32_t ecOH, uint16_t bcOH, uint16_t vfatWordCntT) { - return m_GEBflags.at(c); - } - std::vector getGEBflag() const - { - return m_GEBflags; - } - // need to include all the flags - //!Reads the word for GEM Chamber Trailer - /** - Fills the OH CRC, VFAT word count, InFIFO underflow, Stuck data, OH BC and OH EC. - */ - void setChamberTrailer(uint64_t word) - { - m_OHCRC = word >> 48; /*!> 36); /*!> 35); /*!> 34); /*!> 20); /*!OH BC*/ - m_OHEC = 0x000fffff & (word); /*!OH EC*/ - } - uint64_t getChamberTrailer() const - { - return - (static_cast(m_OHCRC) << 48) | - (static_cast(m_Vwt & 0x0fff) << 36) | - (static_cast(m_InFu & 0x0f) << 35) | - (static_cast(m_Stuckd & 0x01) << 34) | - (static_cast(m_OHBC & 0x0fff) << 20) | - (static_cast(m_OHEC & 0x000fffff)); + GEBchamberTrailer u; + u.ecOH = ecOH; + u.bcOH = bcOH; + u.vfatWordCntT = vfatWordCntT; + ct_ = u.word; } + uint64_t getChamberTrailer() const { return ct_;} - void setVwh(uint16_t n){m_Vwh = n;} /// * vFATs() const {return &m_vfatd;} + const std::vector * vFATs() const {return &vfatd_;} static const int sizeGebID = 5; private: - std::vector m_vfatd; /// m_GEBflags; /// vfatd_; }; } #endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h b/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h new file mode 100644 index 0000000000000..ea2b1eb1453fd --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h @@ -0,0 +1,9 @@ +#ifndef DataFormats_GEMDigi_GEMAMC13EventCollection_h +#define DataFormats_GEMDigi_GEMAMC13EventCollection_h + +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" + +typedef MuonDigiCollection GEMAMC13EventCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h b/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h new file mode 100644 index 0000000000000..6c34d3e5d92ba --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h @@ -0,0 +1,9 @@ +#ifndef DataFormats_GEMDigi_GEMAMCdataCollection_h +#define DataFormats_GEMDigi_GEMAMCdataCollection_h + +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" + +typedef MuonDigiCollection GEMAMCdataCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h b/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h new file mode 100644 index 0000000000000..ba9b3cd8ef7a9 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h @@ -0,0 +1,10 @@ +#ifndef DataFormats_GEMDigi_GEMGEBdataCollection_h +#define DataFormats_GEMDigi_GEMGEBdataCollection_h + +#include "EventFilter/GEMRawToDigi/interface/GEBdata.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" + +typedef MuonDigiCollection GEMGEBdataCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h new file mode 100644 index 0000000000000..7e39f98208839 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h @@ -0,0 +1,28 @@ +#ifndef DataFormats_GEMDigi_GEMVfatStatusDigi_H +#define DataFormats_GEMDigi_GEMVfatStatusDigi_H + +#include +#include "EventFilter/GEMRawToDigi/interface/VFATdata.h" + +class GEMVfatStatusDigi { + + public: + GEMVfatStatusDigi(gem::VFATdata &vfat); + GEMVfatStatusDigi(){} + + uint8_t quality() const { return quality_; } + uint8_t flag() const { return flag_; } + int phi() const { return phi_; } + uint16_t bc() const { return bc_; } + uint8_t ec() const { return ec_; } + + private: + + uint8_t quality_; /// quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110 + uint8_t flag_; /// Control Flags: 4 bits, Hamming Error/AFULL/SEUlogic/SUEI2C + int phi_; /// vfat local phi postion in chamber + uint16_t bc_; + uint8_t ec_; + +}; +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h new file mode 100644 index 0000000000000..36e50dc814745 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h @@ -0,0 +1,10 @@ +#ifndef DataFormats_GEMDigi_GEMVfatStatusDigiCollection_h +#define DataFormats_GEMDigi_GEMVfatStatusDigiCollection_h + +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" + +typedef MuonDigiCollection GEMVfatStatusDigiCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/VFATdata.h b/EventFilter/GEMRawToDigi/interface/VFATdata.h index b947ba3f04a8f..339e82485cbf5 100644 --- a/EventFilter/GEMRawToDigi/interface/VFATdata.h +++ b/EventFilter/GEMRawToDigi/interface/VFATdata.h @@ -1,215 +1,133 @@ #ifndef EventFilter_GEMRawToDigi_VFATdata_h #define EventFilter_GEMRawToDigi_VFATdata_h -#include +#include namespace gem { - class VFATdata + /// VFAT data structure - 3 words of 64 bits each + union VFATfirst { + uint64_t word; + // v3 dataformat + struct { + uint64_t msData1 : 16; ///checkCRC(); - } + public: + + VFATdata(); + // this constructor only used for packing sim digis + VFATdata(const int vfatVer, + const uint16_t BC, + const uint8_t EC, + const uint16_t chipID, + const uint64_t lsDatas, + const uint64_t msDatas); + ~VFATdata() {} //!Read first word from the block. - void read_fw(uint64_t word) - { - m_b1010 = 0x0f & (word >> 60); - m_BC = 0x0fff & (word >> 48); - m_b1100 = 0x0f & (word >> 44); - m_EC = word >> 36; - m_Flag = 0x0f & (word >> 32); - m_b1110 = 0x0f & (word >> 28); - m_ChipID = 0x0fff & (word >> 16); - m_msData = 0xffff000000000000 & (word << 48); - } - uint64_t get_fw() const - { - return - (static_cast(m_b1010 & 0x0f) << 60) | - (static_cast(m_BC & 0x0fff) << 48) | - (static_cast(m_b1100 & 0x0f) << 44) | - (static_cast(m_EC) << 36) | - (static_cast(m_Flag & 0x0f) << 32) | - (static_cast(m_b1110 & 0x0f) << 28) | - (static_cast(m_ChipID & 0x0fff) << 16) | - (static_cast(m_msData & 0xffff000000000000) >> 48); - } + void read_fw(uint64_t word) { fw_ = word;} + uint64_t get_fw() const { return fw_;} //!Read second word from the block. - void read_sw(uint64_t word) - { - m_msData = m_msData | (0x0000ffffffffffff & word >> 16); - m_lsData = 0xffff000000000000 & (word << 48); + void read_sw(uint64_t word) { sw_ = word;} + uint64_t get_sw() const { return sw_;} + + //!Read third word from the block. + void read_tw(uint64_t word) { tw_ = word;} + uint64_t get_tw() const { return tw_;} + + // local phi in chamber + void setPhi(int i) {phiPos_ = i;} + int phi() const {return phiPos_;} + + uint64_t lsData() const { + return uint64_t(VFATsecond{sw_}.lsData1) << 48 | VFATthird{tw_}.lsData2; } - uint64_t get_sw() const - { - return - (static_cast(m_msData & 0x0000ffffffffffff) << 16) | - (static_cast(m_lsData & 0xffff000000000000) >> 48); + uint64_t msData() const { + return uint64_t(VFATfirst{fw_}.msData1) << 48 | VFATsecond{sw_}.msData2; } - //!Read third word from the block. - void read_tw(uint64_t word) - { - m_lsData = m_lsData | (0x0000ffffffffffff & word >> 16); - m_crc = word; + uint16_t bc() const { + if (ver_==2) return VFATfirst{fw_}.bcV2; + return VFATfirst{fw_}.bc; } - // make write_word function - uint64_t get_tw() const - { - return - (static_cast(m_lsData & 0x0000ffffffffffff) << 16) | - (static_cast(m_crc)); + uint8_t ec() const { + if (ver_==2) return VFATfirst{fw_}.ecV2; + return VFATfirst{fw_}.ec; } - - uint8_t b1010 () const { return m_b1010; } - uint16_t bc () const { return m_BC; } - uint8_t b1100 () const { return m_b1100; } - uint8_t ec () const { return m_EC; } - uint8_t flag () const { return m_Flag; } - uint8_t b1110 () const { return m_b1110; } - uint16_t chipID () const { return m_ChipID; } - uint64_t lsData () const { return m_lsData; } - uint64_t msData () const { return m_msData; } - uint16_t crc () const { return m_crc; } - uint16_t crc_calc () const { return m_crc_calc; } - int slotNumber () const { return m_SlotNumber; } - bool isBlockGood() const { return m_isBlockGood;} - - uint16_t crc_cal(uint16_t crc_in, uint16_t dato) - { - uint16_t v = 0x0001; - uint16_t mask = 0x0001; - uint16_t d=0x0000; - uint16_t crc_temp = crc_in; - unsigned char datalen = 16; - for (int i=0; i>1 ^ 0x8408; - else crc_temp = crc_temp>>1; - v<<=1; - } - return(crc_temp); + uint16_t vfatId() const { + if (ver_==2) return VFATfirst{fw_}.chipID; + return VFATfirst{fw_}.pos; } - - uint16_t checkCRC() - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & m_b1010)<<12) | m_BC; - vfatBlockWords[10] = ((0x000f & m_b1100)<<12) | ((0x00ff & m_EC) <<4) | (0x000f & m_Flag); - vfatBlockWords[9] = ((0x000f & m_b1110)<<12) | m_ChipID; - vfatBlockWords[8] = (0xffff000000000000 & m_msData) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & m_msData) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & m_msData) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & m_msData); - vfatBlockWords[4] = (0xffff000000000000 & m_lsData) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & m_lsData) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & m_lsData) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & m_lsData); - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } - - uint16_t checkCRC(uint8_t b1010, uint16_t BC, uint8_t b1100, - uint8_t EC, uint8_t Flag, uint8_t b1110, - uint16_t ChipID, uint64_t msData, uint64_t lsData) - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & b1010)<<12) | BC; - vfatBlockWords[10] = ((0x000f & b1100)<<12) | ((0x00ff & EC) <<4) | (0x000f & Flag); - vfatBlockWords[9] = ((0x000f & b1110)<<12) | ChipID; - vfatBlockWords[8] = (0xffff000000000000 & msData) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & msData) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & msData) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & msData); - vfatBlockWords[4] = (0xffff000000000000 & lsData) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & lsData) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & lsData) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & lsData); + void setVersion(int i) {ver_ = i;} + int version() const {return ver_;} - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } - - uint16_t checkCRC(const VFATdata * vfatData) - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & vfatData->b1010())<<12) | vfatData->bc(); - vfatBlockWords[10] = ((0x000f & vfatData->b1100())<<12) | ((0x00ff & vfatData->ec()) <<4) | (0x000f & vfatData->flag()); - vfatBlockWords[9] = ((0x000f & vfatData->b1110())<<12) | vfatData->chipID(); - vfatBlockWords[8] = (0xffff000000000000 & vfatData->msData()) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & vfatData->msData()) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & vfatData->msData()) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & vfatData->msData()); - vfatBlockWords[4] = (0xffff000000000000 & vfatData->lsData()) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & vfatData->lsData()) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & vfatData->lsData()) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & vfatData->lsData()); + /// quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110 + uint8_t quality(); - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } + /// v3 + uint8_t header () const {return VFATfirst{fw_}.header; } + uint8_t crcCheck () const {return VFATfirst{fw_}.crcCheck; } + uint8_t position () const {return VFATfirst{fw_}.pos; } + /// v2 + uint8_t b1010 () const { return VFATfirst{fw_}.b1010; } + uint8_t b1100 () const { return VFATfirst{fw_}.b1100; } + uint8_t b1110 () const { return VFATfirst{fw_}.b1110; } + uint8_t flag () const { return VFATfirst{fw_}.flag; } + uint16_t chipID () const { return VFATfirst{fw_}.chipID; } + uint16_t crc () const { return VFATthird{tw_}.crc; } + + uint16_t crc_cal(uint16_t crc_in, uint16_t dato); + uint16_t checkCRC(); + static const int nChannels = 128; static const int sizeChipID = 12; - private: + private: + int ver_; /// vfat version + int phiPos_; /// phi position of vfat in chamber - uint8_t m_b1010; ///<1010:4 Control bits, shoud be 1010 - uint16_t m_BC; /// + diff --git a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc index 552cd64d26406..2e8c654e98096 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc @@ -37,19 +37,19 @@ void GEMDigiToRawModule::fillDescriptions(edm::ConfigurationDescriptions & descr descriptions.add("gemPackerDefault", desc); } -std::shared_ptr GEMDigiToRawModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const +std::shared_ptr GEMDigiToRawModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); - if (useDBEMap_){ - edm::ESHandle gemEMapRcd; - iSetup.get().get(gemEMapRcd); - auto gemEMap = std::make_unique(*(gemEMapRcd.product())); + auto gemORmap = std::make_shared(); + if (useDBEMap_) { + edm::ESHandle gemEMapRcd; + iSetup.get().get(gemEMapRcd); + auto gemEMap = std::make_unique(*(gemEMapRcd.product())); gemEMap->convert(*gemORmap); gemEMap.reset(); } else { // no EMap in DB, using dummy - auto gemEMap = std::make_unique(); + auto gemEMap = std::make_unique(); gemEMap->convertDummy(*gemORmap); gemEMap.reset(); } @@ -60,193 +60,167 @@ void GEMDigiToRawModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::Ev { auto fedRawDataCol = std::make_unique(); - // Take digis from the event edm::Handle gemDigis; iEvent.getByToken( digi_token, gemDigis ); - + if (!gemDigis.isValid()) { + iEvent.put(std::move(fedRawDataCol)); + return; + } + auto gemROMap = runCache(iEvent.getRun().index()); std::vector> amc13Events; - // currently only one FEDRaw - amc13Events.reserve(1); - { - auto amc13Event = std::make_unique(); - - uint16_t amcId = 0, gebId = 0; - std::unique_ptr amcData; - std::unique_ptr gebData; + amc13Events.reserve(FEDNumbering::MAXGEMFEDID-FEDNumbering::MINGEMFEDID+1); - const std::map *roMapED = gemROMap->getRoMap(); - for (auto ro=roMapED->begin(); ro!=roMapED->end(); ++ro){ - GEMROmap::eCoord ec = ro->first; - GEMROmap::dCoord dc = ro->second; + for (unsigned int fedId=FEDNumbering::MINGEMFEDID; fedId<=FEDNumbering::MAXGEMFEDID; ++fedId) { + std::unique_ptr amc13Event = std::make_unique(); - if (amcId != ec.amcId || !amcData){ - amcId = ec.amcId; - amcData = std::make_unique(); - amcData->setBID(amcId); - amcData->setBX(GEMELMap::amcBX_); - } - - if (gebId != ec.gebId || !gebData){ - gebId = ec.gebId; - gebData = std::make_unique(); - gebData->setInputID(gebId); - } - - uint16_t vfatId = ec.vfatId; - GEMDetId gemId = dc.gemDetId; + for (uint8_t amcNum=0; amcNum < GEMeMap::maxAMCs_; ++amcNum) { + std::unique_ptr amcData = std::make_unique(); - for (uint16_t bc = 0; bc < 2*GEMELMap::amcBX_; ++bc){ - bool hasDigi = false; + for (uint8_t gebId=0; gebId < GEMeMap::maxGEBs_; ++gebId) { + std::unique_ptr gebData = std::make_unique(); + GEMROMapping::chamEC geb_ec{fedId, amcNum, gebId}; + + if (!gemROMap->isValidChamber(geb_ec)) continue; + GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec); - uint8_t b1010 =0xA; ///<1010:4 Control bits, shoud be 1010 - uint16_t BC =bc; ///get(gemId); - for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt){ + auto vfats = gemROMap->getVfats(geb_dc.detId); + for (auto vfat_ec : vfats) { - const GEMDigi & digi = (*digiIt); - if (digi.bx() != bc-GEMELMap::amcBX_) continue; - - int maxVFat = GEMELMap::maxVFatGE11_; - if (gemId.station() == 2) maxVFat = GEMELMap::maxVFatGE21_; + GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec); + GEMDetId gemId = vfat_dc.detId; + uint16_t vfatId = vfat_ec.vfatAdd; - int localStrip = digi.strip() - ((dc.iPhi-1)%maxVFat)*GEMELMap::maxChan_; - // skip strips not in current vFat - if (localStrip < 1 || localStrip > GEMELMap::maxChan_) continue; + for (uint16_t bc = 0; bc < 2*GEMeMap::amcBX_; ++bc) { + bool hasDigi = false; - hasDigi = true; + uint64_t lsData = 0; ///get(gemId); + for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt) { - GEMROmap::stripNum stMap = {dc.vfatType, localStrip}; - GEMROmap::channelNum chMap = gemROMap->hitPosition(stMap); + const GEMDigi & digi = (*digiIt); + if (digi.bx() != bc-GEMeMap::amcBX_) continue; - int chan = chMap.chNum; - uint64_t oneBit = 0x1; - if (chan < 64) lsData = lsData | (oneBit << chan); - else msData = msData | (oneBit << (chan-64)); + int localStrip = digi.strip() - vfat_dc.localPhi*GEMeMap::maxChan_; + + // skip strips not in current vFat + if (localStrip < 0 || localStrip > GEMeMap::maxChan_ -1) continue; - LogDebug("GEMDigiToRawModule") <<" vfatId "<hitPos(stMap); - } + if (chMap.chNum < 64) lsData |= 1UL << chMap.chNum; + else msData |= 1UL << (chMap.chNum-64); + + LogDebug("GEMDigiToRawModule") + << " fed: " << fedId + << " amc:" << int(amcNum) + << " geb:" << int(gebId) + << " vfat:"<< vfat_dc.localPhi + << ",type: "<< vfat_dc.vfatType + << " id:"<< gemId + << " ch:"<< chMap.chNum + << " st:"<< digi.strip() + << " bx:"<< digi.bx(); + + } - if (!hasDigi) continue; - // only make vfat with hits - auto vfatData = std::make_unique(b1010, BC, b1100, EC, Flag, b1110, vfatId, lsData, msData, - crc, crc_calc, SlotNumber, isBlockGood); - gebData->addVFAT(*vfatData); - } + if (!hasDigi) continue; + // only make vfat with hits + auto vfatData = std::make_unique(geb_dc.vfatVer, bc, 0, vfatId, lsData, msData); + gebData->addVFAT(*vfatData); + } + + } // end of vfats in GEB + + if (!gebData->vFATs()->empty()) { + gebData->setChamberHeader(gebData->vFATs()->size()*3, gebId); + gebData->setChamberTrailer(0, 0, gebData->vFATs()->size()*3); + amcData->addGEB(*gebData); + } + + } // end of GEB loop + + if (!amcData->gebs()->empty()) { + amcData->setAMCheader1(0, GEMeMap::amcBX_, 0, amcNum); + amcData->setAMCheader2(amcNum, 0, 1); + amcData->setGEMeventHeader(amcData->gebs()->size(), 0); + amc13Event->addAMCpayload(*amcData); + } - bool saveGeb = false; - bool saveAMC = false; - auto nx = std::next(ro); - // last vfat, save - if (nx == roMapED->end()){ - saveGeb = true; - saveAMC = true; - } - else { - // check if next vfat is in new geb or amc - GEMROmap::eCoord ecNext = nx->first; - if (ecNext.gebId != gebId) saveGeb = true; - if (ecNext.amcId != amcId) saveAMC = true; + } // end of AMC loop + + if (!amc13Event->getAMCpayloads()->empty()) { + // CDFHeader + uint32_t LV1_id = iEvent.id().event(); + uint16_t BX_id = iEvent.bunchCrossing(); + amc13Event->setCDFHeader(event_type_, LV1_id, BX_id, fedId); + + // AMC13header + uint8_t CalTyp = 1; + uint8_t nAMC = amc13Event->getAMCpayloads()->size(); + uint32_t OrN = 2; + amc13Event->setAMC13Header(CalTyp, nAMC, OrN); + + for (unsigned short i = 0; i < amc13Event->nAMC(); ++i) { + uint32_t AMC_size = 0; + uint8_t Blk_No = 0; + uint8_t AMC_No = 0; + uint16_t BoardID = 0; + amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID); } - - if (!gebData->vFATs()->empty() && saveGeb){ - gebData->setVwh(gebData->vFATs()->size()*3); - amcData->addGEB(*gebData); - } - if (!amcData->gebs()->empty() && saveAMC){ - amcData->setGDcount(amcData->gebs()->size()); - amc13Event->addAMCpayload(*amcData); - } - } - - // CDFHeader - uint8_t cb5 = 0x5;// control bit, should be 0x5 bits 60-63 - uint8_t Evt_ty = event_type_; - uint32_t LV1_id = iEvent.id().event(); - uint16_t BX_id = iEvent.bunchCrossing(); - uint16_t Source_id = FEDNumbering::MINGEMFEDID; - amc13Event->setCDFHeader(cb5, Evt_ty, LV1_id, BX_id, Source_id); - - // AMC13header - uint8_t CalTyp = 1; - uint8_t nAMC = amc13Event->getAMCpayloads()->size(); // currently only one AMC13Event - uint32_t OrN = 2; - uint8_t cb0 = 0b0000;// control bit, should be 0b0000 - amc13Event->setAMC13header(CalTyp, nAMC, OrN, cb0); - - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i){ - uint32_t AMC_size = 0; - uint8_t Blk_No = 0; - uint8_t AMC_No = 0; - uint16_t BoardID = 0; - amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID); - } - //AMC13 trailer - uint32_t CRC_amc13 = 0; - uint8_t Blk_NoT = 0; - uint8_t LV1_idT = 0; - uint16_t BX_idT = BX_id; - amc13Event->setAMC13trailer(CRC_amc13, Blk_NoT, LV1_idT, BX_idT); - //CDF trailer - uint8_t cbA = 0xA; // control bit, should be 0xA bits 60-63 - uint32_t EvtLength = 0; - uint16_t CRC_cdf = 0; - amc13Event->setCDFTrailer(cbA, EvtLength, CRC_cdf); - amc13Events.emplace_back(std::move(amc13Event)); - }// finished making amc13Event data + //AMC13 trailer + uint8_t Blk_NoT = 0; + uint8_t LV1_idT = 0; + uint16_t BX_idT = BX_id; + amc13Event->setAMC13Trailer(Blk_NoT, LV1_idT, BX_idT); + //CDF trailer + uint32_t EvtLength = 0; + amc13Event->setCDFTrailer(EvtLength); + amc13Events.emplace_back(std::move(amc13Event)); + }// finished making amc13Event data + + } // end of FED loop // read out amc13Events into fedRawData - for (const auto & amc13e : amc13Events){ + for (const auto & amc13e : amc13Events) { std::vector words; words.emplace_back(amc13e->getCDFHeader()); - words.emplace_back(amc13e->getAMC13header()); - + words.emplace_back(amc13e->getAMC13Header()); + for (const auto & w: *amc13e->getAMCheaders()) - words.emplace_back(w); + words.emplace_back(w); - for (const auto & amc : *amc13e->getAMCpayloads()){ + for (const auto & amc : *amc13e->getAMCpayloads()) { words.emplace_back(amc.getAMCheader1()); words.emplace_back(amc.getAMCheader2()); words.emplace_back(amc.getGEMeventHeader()); - - for (const auto & geb: *amc.gebs()){ - words.emplace_back(geb.getChamberHeader()); - - for (const auto & vfat: *geb.vFATs()){ - words.emplace_back(vfat.get_fw()); - words.emplace_back(vfat.get_sw()); - words.emplace_back(vfat.get_tw()); - } + + for (const auto & geb: *amc.gebs()) { + words.emplace_back(geb.getChamberHeader()); + + for (const auto & vfat: *geb.vFATs()) { + words.emplace_back(vfat.get_fw()); + words.emplace_back(vfat.get_sw()); + words.emplace_back(vfat.get_tw()); + } - words.emplace_back(geb.getChamberTrailer()); + words.emplace_back(geb.getChamberTrailer()); } words.emplace_back(amc.getGEMeventTrailer()); words.emplace_back(amc.getAMCTrailer()); } - words.emplace_back(amc13e->getAMC13trailer()); + words.emplace_back(amc13e->getAMC13Trailer()); words.emplace_back(amc13e->getCDFTrailer()); - FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->source_id()); + FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->sourceId()); int dataSize = (words.size()) * sizeof(uint64_t); fedRawData.resize(dataSize); diff --git a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h index 1e14b8e5b4015..db558ff99c8b6 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h +++ b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h @@ -16,21 +16,21 @@ #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" -#include "CondFormats/DataRecord/interface/GEMELMapRcd.h" -#include "CondFormats/GEMObjects/interface/GEMELMap.h" -#include "CondFormats/GEMObjects/interface/GEMROmap.h" +#include "CondFormats/DataRecord/interface/GEMeMapRcd.h" +#include "CondFormats/GEMObjects/interface/GEMeMap.h" +#include "CondFormats/GEMObjects/interface/GEMROMapping.h" namespace edm { class ConfigurationDescriptions; } -class GEMDigiToRawModule : public edm::global::EDProducer > { +class GEMDigiToRawModule : public edm::global::EDProducer > { public: /// Constructor GEMDigiToRawModule(const edm::ParameterSet & pset); // global::EDProducer - std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; + std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {}; @@ -41,7 +41,7 @@ class GEMDigiToRawModule : public edm::global::EDProducer digi_token; - bool useDBEMap_; + bool useDBEMap_; }; DEFINE_FWK_MODULE(GEMDigiToRawModule); #endif diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc index 0f2ebfb1762b8..5eb619f360800 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc @@ -22,10 +22,11 @@ GEMRawToDigiModule::GEMRawToDigiModule(const edm::ParameterSet & pset) : unPackStatusDigis_(pset.getParameter("unPackStatusDigis")) { produces(); - if (unPackStatusDigis_){ + if (unPackStatusDigis_) { produces("vfatStatus"); - produces("GEBStatus"); - produces("AMCStatus"); + produces("gebStatus"); + produces("AMCdata"); + produces("AMC13Event"); } } @@ -38,19 +39,19 @@ void GEMRawToDigiModule::fillDescriptions(edm::ConfigurationDescriptions & descr descriptions.add("muonGEMDigisDefault", desc); } -std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const +std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); - if (useDBEMap_){ - edm::ESHandle gemEMapRcd; - iSetup.get().get(gemEMapRcd); - auto gemEMap = std::make_unique(*(gemEMapRcd.product())); + auto gemORmap = std::make_shared(); + if (useDBEMap_) { + edm::ESHandle gemEMapRcd; + iSetup.get().get(gemEMapRcd); + auto gemEMap = std::make_unique(*(gemEMapRcd.product())); gemEMap->convert(*gemORmap); gemEMap.reset(); } else { // no EMap in DB, using dummy - auto gemEMap = std::make_unique(); + auto gemEMap = std::make_unique(); gemEMap->convertDummy(*gemORmap); gemEMap.reset(); } @@ -60,21 +61,23 @@ std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, ed void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::EventSetup const&) const { auto outGEMDigis = std::make_unique(); - auto outVfatStatus = std::make_unique(); - auto outGEBStatus = std::make_unique(); - auto outAMCStatus = std::make_unique(); + auto outVFATStatus = std::make_unique(); + auto outGEBStatus = std::make_unique(); + auto outAMCdata = std::make_unique(); + auto outAMC13Event = std::make_unique(); - // Take raw from the event + // Take raw from the event edm::Handle fed_buffers; iEvent.getByToken( fed_token, fed_buffers ); auto gemROMap = runCache(iEvent.getRun().index()); - for (unsigned int id=FEDNumbering::MINGEMFEDID; id<=FEDNumbering::MAXGEMFEDID; ++id){ - const FEDRawData& fedData = fed_buffers->FEDData(id); + for (unsigned int fedId=FEDNumbering::MINGEMFEDID; fedId<=FEDNumbering::MAXGEMFEDID; ++fedId) { + const FEDRawData& fedData = fed_buffers->FEDData(fedId); int nWords = fedData.size()/sizeof(uint64_t); LogDebug("GEMRawToDigiModule") <<" words " << nWords; + if (nWords<5) continue; const unsigned char * data = fedData.data(); @@ -83,150 +86,138 @@ void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::Ev const uint64_t* word = reinterpret_cast(data); amc13Event->setCDFHeader(*word); - amc13Event->setAMC13header(*(++word)); - + amc13Event->setAMC13Header(*(++word)); + // Readout out AMC headers - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i) + for (uint8_t i = 0; i < amc13Event->nAMC(); ++i) amc13Event->addAMCheader(*(++word)); // Readout out AMC payloads - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i){ + for (uint8_t i = 0; i < amc13Event->nAMC(); ++i) { auto amcData = std::make_unique(); amcData->setAMCheader1(*(++word)); amcData->setAMCheader2(*(++word)); amcData->setGEMeventHeader(*(++word)); - uint16_t amcId = amcData->boardId(); uint16_t amcBx = amcData->bx(); + uint8_t amcNum = amcData->amcNum(); // Fill GEB - for (unsigned short j = 0; j < amcData->gdCount(); ++j){ + for (uint8_t j = 0; j < amcData->davCnt(); ++j) { auto gebData = std::make_unique(); gebData->setChamberHeader(*(++word)); - unsigned int m_nvb = gebData->vwh() / 3; // number of VFAT2 blocks - uint16_t gebId = gebData->inputID(); - GEMDetId gemId(-1,1,1,1,1,0); // temp ID - for (unsigned short k = 0; k < m_nvb; k++){ + uint8_t gebId = gebData->inputID(); + GEMROMapping::chamEC geb_ec = {fedId, amcNum, gebId}; + GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec); + GEMDetId gemChId = geb_dc.detId; + + for (uint16_t k = 0; k < gebData->vfatWordCnt()/3; k++) { auto vfatData = std::make_unique(); vfatData->read_fw(*(++word)); vfatData->read_sw(*(++word)); vfatData->read_tw(*(++word)); - gebData->addVFAT(*vfatData); - - uint16_t bc=vfatData->bc(); - uint8_t b1010=vfatData->b1010(); - uint8_t b1100=vfatData->b1100(); - uint8_t b1110=vfatData->b1110(); - uint16_t vfatId=vfatData->chipID(); - uint16_t crc = vfatData->crc(); - uint16_t crc_check = vfatData->checkCRC(); - bool Quality = (b1010==10) && (b1100==12) && (b1110==14) && (crc==crc_check); - - if (crc!=crc_check) edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :"<isValidChipID(ec)){ - edm::LogWarning("GEMRawToDigiModule") << "InValid ChipID :"<setVersion(geb_dc.vfatVer); + uint16_t vfatId = vfatData->vfatId(); + GEMROMapping::vfatEC vfat_ec = {vfatId, gemChId}; + + // check if ChipID exists. + if (!gemROMap->isValidChipID(vfat_ec)) { + edm::LogWarning("GEMRawToDigiModule") << "InValid: amcNum "<< int(amcNum) + << " gebId "<< int(gebId) + << " vfatId "<< int(vfatId) + << " vfat Pos "<< int(vfatData->position()); continue; } - + // check vfat data + if (vfatData->quality()) { + edm::LogWarning("GEMRawToDigiModule") << "Quality "<< vfatData->quality() + << " b1010 "<< int(vfatData->b1010()) + << " b1100 "<< int(vfatData->b1100()) + << " b1110 "<< int(vfatData->b1110()); + if (vfatData->crc() != vfatData->checkCRC() ) { + edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :" + <crc()<<" "<checkCRC(); + } + } + + GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec); + + vfatData->setPhi(vfat_dc.localPhi); + GEMDetId gemId = vfat_dc.detId; + uint16_t bc=vfatData->bc(); + // strip bx = vfat bx - amc bx + int bx = bc-amcBx; + for (int chan = 0; chan < VFATdata::nChannels; ++chan) { uint8_t chan0xf = 0; if (chan < 64) chan0xf = ((vfatData->lsData() >> chan) & 0x1); else chan0xf = ((vfatData->msData() >> (chan-64)) & 0x1); // no hits - if(chan0xf==0) continue; - GEMROmap::dCoord dc = gemROMap->hitPosition(ec); - // strip bx = vfat bx - amc bx - int bx = bc-amcBx; - gemId = dc.gemDetId; - - GEMROmap::channelNum chMap = {dc.vfatType, chan}; - GEMROmap::stripNum stMap = gemROMap->hitPosition(chMap); - - int maxVFat = GEMELMap::maxVFatGE11_; - if (gemId.station() == 2) maxVFat = GEMELMap::maxVFatGE21_; - int stripId = stMap.stNum + (dc.iPhi-1)%maxVFat*GEMELMap::maxChan_; + if (chan0xf==0) continue; + + GEMROMapping::channelNum chMap = {vfat_dc.vfatType, chan}; + GEMROMapping::stripNum stMap = gemROMap->hitPos(chMap); + int stripId = stMap.stNum + vfatData->phi()*GEMeMap::maxChan_; + GEMDigi digi(stripId,bx); - LogDebug("GEMRawToDigiModule") <<" vfatId "<insertDigi(gemId,digi); + LogDebug("GEMRawToDigiModule") + << " fed: " << fedId + << " amc:" << int(amcNum) + << " geb:" << int(gebId) + << " vfat:"<< vfat_dc.localPhi + << ",type: "<< vfat_dc.vfatType + << " id:"<< gemId + << " ch:"<< chMap.chNum + << " st:"<< digi.strip() + << " bx:"<< digi.bx(); + + outGEMDigis.get()->insertDigi(gemId,digi); + + }// end of channel loop + + if (unPackStatusDigis_) { + outVFATStatus.get()->insertDigi(gemId, GEMVfatStatusDigi(*vfatData)); } - if (unPackStatusDigis_){ - GEMVfatStatusDigi vfatStatus(vfatData->lsData(), vfatData->msData(), - crc, vfatData->crc_calc(), - b1010, b1100, b1110, vfatData->flag(), - vfatData->isBlockGood()); - outVfatStatus.get()->insertDigi(gebData->inputID(),vfatStatus); - } - - } + } // end of vfat loop gebData->setChamberTrailer(*(++word)); - if (unPackStatusDigis_){ - GEMGEBStatusDigi gebStatus(gebData->zeroSupWordsCnt(), - gebData->vwh(), - gebData->errorC(), - gebData->ohCRC(), - gebData->vwt(), - gebData->inFu(), - gebData->inputID(), - gebData->stuckd(), - gebData->getGEBflag()); - outGEBStatus.get()->insertDigi(gebData->inputID(),gebStatus); + + if (unPackStatusDigis_) { + outGEBStatus.get()->insertDigi(gemChId.chamberId(), (*gebData)); } - - amcData->addGEB(*gebData); - } + + } // end of geb loop amcData->setGEMeventTrailer(*(++word)); amcData->setAMCTrailer(*(++word)); - - if (unPackStatusDigis_){ - GEMAMCStatusDigi amcStatus(amcData->amcNum(), - amcData->l1A(), - amcData->bx(), - amcData->dlength(), - amcData->fv(), - amcData->runType(), - amcData->param1(), - amcData->param2(), - amcData->param3(), - amcData->orbitNum(), - amcData->boardId(), - amcData->gemDAV(), - amcData->bStatus(), - amcData->gdCount(), - amcData->ttsState(), - amcData->chamberTimeOut(), - amcData->oosGLIB()); - outAMCStatus.get()->insertDigi(amcData->boardId(), amcStatus); + + if (unPackStatusDigis_) { + outAMCdata.get()->insertDigi(amcData->boardId(), (*amcData)); } - amc13Event->addAMCpayload(*amcData); - } + } // end of amc loop - amc13Event->setAMC13trailer(*(++word)); + amc13Event->setAMC13Trailer(*(++word)); amc13Event->setCDFTrailer(*(++word)); - } + + if (unPackStatusDigis_) { + outAMC13Event.get()->insertDigi(amc13Event->bxId(), AMC13Event(*amc13Event)); + } + + } // end of amc13Event iEvent.put(std::move(outGEMDigis)); - if (unPackStatusDigis_){ - iEvent.put(std::move(outVfatStatus), "vfatStatus"); - iEvent.put(std::move(outGEBStatus), "GEBStatus"); - iEvent.put(std::move(outAMCStatus), "AMCStatus"); + + if (unPackStatusDigis_) { + iEvent.put(std::move(outVFATStatus), "vfatStatus"); + iEvent.put(std::move(outGEBStatus), "gebStatus"); + iEvent.put(std::move(outAMCdata), "AMCdata"); + iEvent.put(std::move(outAMC13Event), "AMC13Event"); } + } diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h index 9952fb91d7a2d..82b2bc37ad687 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h @@ -15,13 +15,14 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" - -#include "CondFormats/DataRecord/interface/GEMELMapRcd.h" -#include "CondFormats/GEMObjects/interface/GEMELMap.h" -#include "CondFormats/GEMObjects/interface/GEMROmap.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h" + +#include "CondFormats/DataRecord/interface/GEMeMapRcd.h" +#include "CondFormats/GEMObjects/interface/GEMeMap.h" +#include "CondFormats/GEMObjects/interface/GEMROMapping.h" #include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" #include "EventFilter/GEMRawToDigi/interface/VFATdata.h" @@ -29,13 +30,13 @@ namespace edm { class ConfigurationDescriptions; } -class GEMRawToDigiModule : public edm::global::EDProducer > { +class GEMRawToDigiModule : public edm::global::EDProducer > { public: /// Constructor GEMRawToDigiModule(const edm::ParameterSet & pset); // global::EDProducer - std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; + std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {}; diff --git a/EventFilter/GEMRawToDigi/src/AMC13Event.cc b/EventFilter/GEMRawToDigi/src/AMC13Event.cc index 52d2b0b817a8a..c9d780af9e2e2 100644 --- a/EventFilter/GEMRawToDigi/src/AMC13Event.cc +++ b/EventFilter/GEMRawToDigi/src/AMC13Event.cc @@ -3,70 +3,47 @@ using namespace gem; -uint64_t AMC13Event::getCDFHeader() const +void AMC13Event::setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id) { - // CDF Header word - // 63 - 60 | 59 - 56 | 55 - 32 | 31 - 20 | 19 - 8 | - // cb5 | Evt_ty | LV1_id | BX_id | Source_id | - return (static_cast(m_cb5 & 0x0f) << 60) | - (static_cast(m_Evt_ty & 0x0f) << 56) | - (static_cast(m_LV1_id & 0x00ffffff) << 32) | - (static_cast(m_BX_id & 0x0fff) << 20) | - (static_cast(m_Source_id & 0x0fff) << 8); + CDFHeader u; + u.cb5 = 0x5; + u.eventType = Evt_ty; + u.lv1Id = LV1_id; + u.bxId = BX_id; + u.sourceId = Source_id; + cdfh_ = u.word; } -void AMC13Event::setCDFHeader(uint64_t word) +void AMC13Event::setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN) { - m_cb5 = 0x0f & (word >> 60); - m_Evt_ty = 0x0f & (word >> 56); - m_LV1_id = 0x00ffffff & (word >> 32); - m_BX_id = 0x0fff & (word >> 20); - m_Source_id = 0x0fff & (word >> 8); + AMC13Header u; + u.cb0 = 0x0; + u.calType = CalTyp; + u.nAMC = nAMC; + u.orbitN = OrN; + amc13h_ = u.word; } -void AMC13Event::setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id) +void AMC13Event::setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT) { - m_cb5 = cb5; - m_Evt_ty = Evt_ty; - m_LV1_id = LV1_id; - m_BX_id = BX_id; - m_Source_id = Source_id; + AMC13Trailer u; + u.blkN = Blk_NoT; + u.lv1IdT = LV1_idT; + u.bxIdT = BX_idT; + amc13t_ = u.word; } -uint64_t AMC13Event::getAMC13header() const +void AMC13Event::setCDFTrailer(uint32_t EvtLength) { - // AMC13 Header word - // 63 - 60 | 59 - 56 | 55 - 52 | 51 - 36 | 35 - 4 | 4 - 0 | - // uFOV | CalTyp | nAMC | Reserved| OrN | cb0 | - return (static_cast(m_CalTyp & 0x0f) << 56) | - (static_cast(m_nAMC & 0x0f) << 52) | - (static_cast(m_OrN) << 4) | - (static_cast(m_cb0 & 0x0f)); -} - -void AMC13Event::setAMC13header(uint64_t word) -{ - m_CalTyp = 0x0f & (word >> 56); - m_nAMC = 0x0f & (word >> 52); - m_OrN = word >> 4; - m_cb0 = 0x0f & word; -} - -void AMC13Event::setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0) -{ - m_CalTyp = CalTyp; - m_nAMC = nAMC; - m_OrN = OrN; - m_cb0 = cb0; + CDFTrailer u; + u.cbA = 0xA; + u.evtLength = EvtLength; + cdft_ = u.word; } void AMC13Event::addAMCheader(uint64_t word) { - // m_AMC_size.push_back(0x00ffffff&(word>>32)); - // m_Blk_No.push_back(0xff&(word>>20)); - // m_AMC_No.push_back(0x0f&(word>>16)); - // m_BoardID.push_back(0xffff&word); - m_amcHeaders.push_back(word); + amcHeaders_.push_back(word); } void AMC13Event::addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID) @@ -79,56 +56,5 @@ void AMC13Event::addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, (static_cast(Blk_No & 0xff) << 20) | (static_cast(AMC_No & 0x0f) << 16) | (static_cast(BoardID & 0xffff)); - m_amcHeaders.push_back(word); -} - -uint64_t AMC13Event::getAMC13trailer() const -{ - // AMC13 trailer word - // 63 - 32 | 27 - 20 | 19 - 12 | 11 - 0 | - // CRC_amc13 | Blk_No | LV1_idT | BX_idT | - return (static_cast(m_CRC_amc13) << 32) | - (static_cast(m_Blk_NoT & 0xff) << 20) | - (static_cast(m_LV1_idT & 0xff) << 12) | - (static_cast(m_BX_idT & 0x0fff)); -} - -void AMC13Event::setAMC13trailer(uint64_t word) -{ - m_CRC_amc13 = word >> 32; - m_Blk_NoT = 0xff & (word >> 20); - m_LV1_idT = 0xff & (word >> 12); - m_BX_idT = 0x0fff & word; -} - -void AMC13Event::setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT) -{ - m_CRC_amc13 = CRC_amc13; - m_Blk_NoT = Blk_NoT; - m_LV1_idT = LV1_idT; - m_BX_idT = BX_idT; -} - -uint64_t AMC13Event::getCDFTrailer() const -{ - // CDF trailer word - // 63 - 60 | 55 - 32 | 31 - 16 | - // cbA | EvtLength | CRC_cdf | - return (static_cast(m_cbA & 0x0f) << 60) | - (static_cast(m_EvtLength & 0x00ffffff) << 32) | - (static_cast(m_CRC_cdf & 0xffff) << 16); -} - -void AMC13Event::setCDFTrailer(uint64_t word) -{ - m_cbA = 0x0f & (word >> 60); - m_EvtLength = 0x00ffffff & (word >> 32); - m_CRC_cdf = 0xffff & (word >> 16); -} - -void AMC13Event::setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf) -{ - m_cbA = cbA; - m_EvtLength = EvtLength; - m_CRC_cdf = CRC_cdf; + amcHeaders_.push_back(word); } diff --git a/EventFilter/GEMRawToDigi/src/AMCdata.cc b/EventFilter/GEMRawToDigi/src/AMCdata.cc new file mode 100644 index 0000000000000..459ba26f6c4e7 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/AMCdata.cc @@ -0,0 +1,31 @@ +#include +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" + +using namespace gem; + +void AMCdata::setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum) +{ + AMCheader1 u; + u.dataLength = dataLength; + u.bxID = bxID; + u.l1AID = l1AID; + u.AMCnum = AMCnum; + amch1_ = u.word; +} + +void AMCdata::setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType) +{ + AMCheader2 u; + u.boardID = boardID; + u.orbitNum = orbitNum; + u.runType = runType; + amch2_ = u.word; +} + +void AMCdata::setGEMeventHeader(uint8_t davCnt, uint32_t davList) +{ + EventHeader u; + u.davCnt = davCnt; + u.davList = davList; + eh_ = u.word; +} diff --git a/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc new file mode 100644 index 0000000000000..f530ce2be7ecf --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc @@ -0,0 +1,11 @@ +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include + +GEMVfatStatusDigi::GEMVfatStatusDigi(gem::VFATdata &vfat) +{ + quality_ = vfat.quality(); + flag_ = vfat.flag(); + phi_ = vfat.phi(); + ec_ = vfat.ec(); + bc_ = vfat.bc(); +}; diff --git a/EventFilter/GEMRawToDigi/src/VFATdata.cc b/EventFilter/GEMRawToDigi/src/VFATdata.cc new file mode 100644 index 0000000000000..6eabc354f31bf --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/VFATdata.cc @@ -0,0 +1,103 @@ +#include "EventFilter/GEMRawToDigi/interface/VFATdata.h" + +using namespace gem; + +VFATdata::VFATdata() { + ver_ = 1; +} + +VFATdata::VFATdata(const int vfatVer, + const uint16_t BC, + const uint8_t EC, + const uint16_t chipID, + const uint64_t lsDatas, + const uint64_t msDatas) +{ + // this constructor only used for packing sim digis + VFATfirst fw; + VFATsecond sw; + VFATthird tw; + + fw.word = 0; + sw.word = 0; + tw.word = 0; + fw.header = 0x1E; + + if (vfatVer == 3) { + fw.bc = BC; + fw.ec = EC; + fw.pos = chipID; + } + else { + fw.chipID = chipID; + fw.b1110 = 14; + fw.b1100 = 12; + fw.b1010 = 10; + fw.ecV2 = EC; + fw.bcV2 = BC; + } + + sw.lsData1 = lsDatas >> 48; + tw.lsData2 = lsDatas & 0x0000ffffffffffff; + + fw.msData1 = msDatas >> 48; + sw.msData2 = msDatas & 0x0000ffffffffffff; + ver_ = vfatVer; + + tw.crc = checkCRC();// crc check not yet implemented for v3 + + fw_ = fw.word; + sw_ = sw.word; + tw_ = tw.word; +} + +uint8_t VFATdata::quality() { + uint8_t q = 0; + if (ver_ == 2) { + if (VFATthird{tw_}.crc != checkCRC()) q |= 1UL << 1; + if (VFATfirst{fw_}.b1010 != 10) q |= 1UL << 2; + if (VFATfirst{fw_}.b1100 != 12) q |= 1UL << 3; + if (VFATfirst{fw_}.b1110 != 14) q |= 1UL << 4; + } + // quality test not yet implemented in v3 + return q; +} + +uint16_t VFATdata::crc_cal(uint16_t crc_in, uint16_t dato) +{ + uint16_t v = 0x0001; + uint16_t mask = 0x0001; + uint16_t d=0x0000; + uint16_t crc_temp = crc_in; + unsigned char datalen = 16; + for (int i=0; i>1 ^ 0x8408; + else crc_temp = crc_temp>>1; + v<<=1; + } + return crc_temp; +} + +uint16_t VFATdata::checkCRC() +{ + uint16_t vfatBlockWords[12]; + vfatBlockWords[11] = ((0x000f & VFATfirst{fw_}.b1010)<<12) | bc(); + vfatBlockWords[10] = ((0x000f & VFATfirst{fw_}.b1100)<<12) | ((0x00ff & ec()) <<4) | (0x000f & VFATfirst{fw_}.flag); + vfatBlockWords[9] = ((0x000f & VFATfirst{fw_}.b1110)<<12) | VFATfirst{fw_}.chipID; + vfatBlockWords[8] = (0xffff000000000000 & msData()) >> 48; + vfatBlockWords[7] = (0x0000ffff00000000 & msData()) >> 32; + vfatBlockWords[6] = (0x00000000ffff0000 & msData()) >> 16; + vfatBlockWords[5] = (0x000000000000ffff & msData()); + vfatBlockWords[4] = (0xffff000000000000 & lsData()) >> 48; + vfatBlockWords[3] = (0x0000ffff00000000 & lsData()) >> 32; + vfatBlockWords[2] = (0x00000000ffff0000 & lsData()) >> 16; + vfatBlockWords[1] = (0x000000000000ffff & lsData()); + + uint16_t crc_fin = 0xffff; + for (int i = 11; i >= 1; i--) { + crc_fin = crc_cal(crc_fin, vfatBlockWords[i]); + } + return crc_fin; +} diff --git a/EventFilter/GEMRawToDigi/src/classes.h b/EventFilter/GEMRawToDigi/src/classes.h new file mode 100644 index 0000000000000..747f4509e1804 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/classes.h @@ -0,0 +1,14 @@ +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/GEBdata.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h" + +#include "DataFormats/Common/interface/Wrapper.h" +#include diff --git a/EventFilter/GEMRawToDigi/src/classes_def.xml b/EventFilter/GEMRawToDigi/src/classes_def.xml new file mode 100644 index 0000000000000..cd8951aee8bad --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/classes_def.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EventFilter/GEMRawToDigi/test/unpackData-GEM.py b/EventFilter/GEMRawToDigi/test/unpackData-GEM.py index 1219c78b15c26..c4e7e38e218cc 100644 --- a/EventFilter/GEMRawToDigi/test/unpackData-GEM.py +++ b/EventFilter/GEMRawToDigi/test/unpackData-GEM.py @@ -93,10 +93,9 @@ # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') -#process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -#process.load('Configuration.Geometry.GeometryDB_cff') -process.load('Configuration.Geometry.GeometryExtended2017Reco_cff') -process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') process.load('Configuration.StandardSequences.SimL1Emulator_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') @@ -147,8 +146,16 @@ # Other statements from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2017_realistic', '') -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:startup', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') + +process.GlobalTag.toGet = cms.VPSet( + cms.PSet( + #connect = cms.string('sqlite_fip:EventFilter/GEMRawToDigi/test/GEMeMap.db'), + connect = cms.string('sqlite_file:./GEMeMap.db'), + record = cms.string('GEMeMapRcd'), + tag = cms.string('GEMeMap_v4') + )) + # validation event filter process.load('EventFilter.L1TRawToDigi.validationEventFilter_cfi') @@ -161,13 +168,13 @@ process.dumpRaw = cms.EDAnalyzer( "DumpFEDRawDataProduct", token = cms.untracked.InputTag("rawDataCollector"), - feds = cms.untracked.vint32 ( 1467 ), + feds = cms.untracked.vint32 ( 1467,1468 ), dumpPayload = cms.untracked.bool ( options.dumpRaw ) ) # raw to digi process.load('EventFilter.GEMRawToDigi.muonGEMDigis_cfi') -process.load('EventFilter.GEMRawToDigi.GEMSQLiteCabling_cfi') +#process.load('EventFilter.GEMRawToDigi.GEMSQLiteCabling_cfi') process.muonGEMDigis.InputLabel = cms.InputTag('rawDataCollector') process.muonGEMDigis.useDBEMap = True @@ -210,9 +217,6 @@ process.output = cms.OutputModule( "PoolOutputModule", outputCommands = cms.untracked.vstring("keep *"), - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('path') - ), fileName = cms.untracked.string('gem_EDM.root') ) From 3923fdc6cffce8fe40edea4689a5acfe7c1668b6 Mon Sep 17 00:00:00 2001 From: Giacomo Govi Date: Thu, 14 Feb 2019 10:25:16 +0100 Subject: [PATCH 083/686] getPayloadData.py script adapted for the two tags support --- CondCore/Utilities/scripts/getPayloadData.py | 104 ++++++++++++++++--- 1 file changed, 89 insertions(+), 15 deletions(-) diff --git a/CondCore/Utilities/scripts/getPayloadData.py b/CondCore/Utilities/scripts/getPayloadData.py index c0d7f48f95669..c8f420e6b9054 100755 --- a/CondCore/Utilities/scripts/getPayloadData.py +++ b/CondCore/Utilities/scripts/getPayloadData.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -from __future__ import print_function import shutil import glob import json @@ -82,14 +81,9 @@ def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs): plot = getattr(plugin_obj, plot_name)() output('plot object: ', plot) - if db == "Prod": - db_name = 'frontier://FrontierProd/CMS_CONDITIONS' - elif db == 'Prep' : - db_name = 'frontier://FrontierPrep/CMS_CONDITIONS' - else: - db_name = db + db_name = 'oracle://cms_orcon_adg/CMS_CONDITIONS' if db == 'Prod' else 'oracle://cms_orcoff_prep/CMS_CONDITIONS' output('full DB name: ', db_name) - + success = plot.process(db_name, tag, time_type, int(iovs['start_iov']), int(iovs['end_iov'])) output('plot processed data successfully: ', success) @@ -97,6 +91,46 @@ def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs): return False + result = plot.data() + output('deserialized data: ', result) + return result +@supress_output +def deserialize_twoiovs(db, plugin_name, plot_name, tag,tagtwo,iovs,iovstwo): + ''' Deserializes given iovs data and returns plot coordinates ''' + #print "Starting to deserialize iovs:" + #print 'First Iovs',iovs + #print 'Two Iovs', iovstwo + output('Starting to deserialize iovs: ', '') + output('db: ', db) + output('plugin name: ', plugin_name) + output('plot name: ', plot_name) + output('tag name: ', tag) + output('tagtwo name: ', tagtwo) + #output('tag time type: ', time_type) + output('iovs: ', iovs) + output('iovstwo: ', iovstwo) + + plugin_base = import_module('pluginModule_PayloadInspector') + output('PI plugin base: ', plugin_base) + + plugin_obj = import_module(plugin_name) + output('PI plugin object: ', plugin_obj) + + # get plot method and execute it with given iovs + plot = getattr(plugin_obj, plot_name)() + output('plot object: ', plot) + + db_name = 'oracle://cms_orcon_adg/CMS_CONDITIONS' if db == 'Prod' else 'oracle://cms_orcoff_prep/CMS_CONDITIONS' + output('full DB name: ', db_name) + + + success = plot.processTwoTags(db_name, tag,tagtwo,int(iovs['start_iov']), int(iovstwo['end_iov'])) + #print "All good",success + output('plot processed data successfully: ', success) + if not success: + return False + + result = plot.data() output('deserialized data: ', result) return result @@ -169,15 +203,17 @@ def discover(): output(' - plot type: ', plot_type) single_iov = plot_method.isSingleIov() output(' - is single iov: ', single_iov) - result.setdefault(payload_type, []).append({'plot': plot, 'plugin_name': plugin_name, 'title': plot_title, 'plot_type': plot_type, 'single_iov': single_iov}) + two_tags = plot_method.isTwoTags() + output(' - is Two Tags: ', two_tags) + result.setdefault(payload_type, []).append({'plot': plot, 'plugin_name': plugin_name, 'title': plot_title, 'plot_type': plot_type, 'single_iov': single_iov, 'two_tags': two_tags}) output('currently discovered info: ', result) output('*** final output:', '') return json.dumps(result) def output(description, param): if args.verbose: - print('') - print(description, param) + print '' + print description, param if __name__ == '__main__': @@ -213,9 +249,11 @@ def output(description, param): parser = ArgumentParser(description=description, formatter_class=RawTextHelpFormatter) parser.add_argument("-d", "--discover", help="discovers object types and plots \nfor a given cmssw release", action="store_true") parser.add_argument("-i", "--iovs", help="deserializes given iovs data encoded in base64 and returns plot coordinates also encoded in base64") + parser.add_argument("-i2", "--iovstwo", help="deserializes given iovs data encoded in base64 and returns plot coordinates also encoded in base64") parser.add_argument("-o", "--plugin", help="Payload Inspector plugin name needed for iovs deserialization") parser.add_argument("-p", "--plot", help="plot name needed for iovs deserialization") parser.add_argument("-t", "--tag", help="tag name needed for iovs deserialization") + parser.add_argument("-t2", "--tagtwo", help="tag name needed for iovs deserialization") parser.add_argument("-tt", "--time_type", help="tag time type name needed for iovs deserialization") parser.add_argument("-b", "--db", help="db (Prod or Prep) needed for iovs deserialization") parser.add_argument("-test", "--test", help="add this flag if you want to test the deserialization function and want to see a readable output", action="store_true") @@ -235,9 +273,44 @@ def output(description, param): os.write( 1, discover() ) # Return a plot if iovs are provided - if args.iovs: + #print '* getiovs: ',args.iovs + #print '* getiovstwo: ',args.iovstwo + if args.iovstwo: # Run plugin with arguments + #print 'We are here' + a=json.loads(args.iovs) + #print 'A',a + b=json.loads(args.iovstwo) + #print 'B',b + result = deserialize_twoiovs(args.db, args.plugin, args.plot, args.tag,args.tagtwo,a,b) + # If test -> output the result as formatted json + if args.test: + os.write( 1, json.dumps( json.loads( result ), indent=4 )) + #print 'Result:',result + if args.image_plot: + try: + filename = json.loads( result )['file'] + #print 'File name',filename + except ValueError, e: + os.write( 2, 'Value error when getting image name: %s\n' % str( e )) + except KeyError, e: + os.write( 2, 'Key error when getting image name: %s\n' % str( e )) + + if not filename or not os.path.isfile( filename ): + os.write( 2, 'Error: Generated image file (%s) not found\n' % filename ) + + try: + with open( filename, 'r' ) as f: + shutil.copyfileobj( f, sys.stdout ) + except IOError, e: + os.write( 2, 'IO error when streaming image: %s' % str( e )) + finally: + os.remove( filename ) + + + # Else -> output result json string with base 64 encoding + elif args.iovs: result = deserialize_iovs(args.db, args.plugin, args.plot, args.tag, args.time_type, json.loads(args.iovs)) # If test -> output the result as formatted json @@ -251,9 +324,10 @@ def output(description, param): try: filename = json.loads( result )['file'] - except ValueError as e: + #print 'File name',filename + except ValueError, e: os.write( 2, 'Value error when getting image name: %s\n' % str( e )) - except KeyError as e: + except KeyError, e: os.write( 2, 'Key error when getting image name: %s\n' % str( e )) if not filename or not os.path.isfile( filename ): @@ -262,7 +336,7 @@ def output(description, param): try: with open( filename, 'r' ) as f: shutil.copyfileobj( f, sys.stdout ) - except IOError as e: + except IOError, e: os.write( 2, 'IO error when streaming image: %s' % str( e )) finally: os.remove( filename ) From 36711a7a58de5898ba9e605dbe4acaf2d966c849 Mon Sep 17 00:00:00 2001 From: Patricia Date: Fri, 15 Feb 2019 22:06:08 +0100 Subject: [PATCH 084/686] removing two fragments from override --- Configuration/PyReleaseValidation/python/relval_steps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 7a9bfb20e8e28..2294c4acce980 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1438,7 +1438,7 @@ def lhegensim2017(fragment,howMuch): # sometimes v1 won't be used - override it here - the dictionary key is gen fragment + '_' + geometry -overrideFragments={'QQH1352T_13UP18INPUT':'2'} +#overrideFragments={'QQH1352T_13UP18INPUT':'2'} import re for key in overrideFragments: @@ -2905,7 +2905,7 @@ def gen2018HiMix(fragment,howMuch): defaultDataSets[key+'PU']=defaultDataSets[key] # sometimes v1 won't be used - override it here - the dictionary key is gen fragment + '_' + geometry -versionOverrides={'BuMixing_BMuonFilter_forSTEAM_13TeV_TuneCUETP8M1_2017':'2','SingleElectronPt10_pythia8_2017':'2','HSCPstop_M_200_TuneCUETP8M1_13TeV_pythia8_2017':'2','RSGravitonToGammaGamma_kMpl01_M_3000_TuneCUETP8M1_13TeV_pythia8_2017':'2','WprimeToENu_M-2000_TuneCUETP8M1_13TeV-pythia8_2017':'2','DisplacedSUSY_stopToBottom_M_300_1000mm_TuneCUETP8M1_13TeV_pythia8_2017':'2','TenE_E_0_200_pythia8_2017':'2','TenE_E_0_200_pythia8_2017PU':'2','QQH1352T_13TeV_TuneCUETP8M1_2018':'2', 'TenTau_E_15_500_pythia8_2018':'2','PhotonJet_Pt_10_13TeV_TuneCUETP8M1_2018':'2','QCD_Pt_600_800_13TeV_TuneCUETP8M1_2018':'2','Wjet_Pt_80_120_13TeV_TuneCUETP8M1_2018':'2'} +versionOverrides={'BuMixing_BMuonFilter_forSTEAM_13TeV_TuneCUETP8M1_2017':'2','SingleElectronPt10_pythia8_2017':'2','HSCPstop_M_200_TuneCUETP8M1_13TeV_pythia8_2017':'2','RSGravitonToGammaGamma_kMpl01_M_3000_TuneCUETP8M1_13TeV_pythia8_2017':'2','WprimeToENu_M-2000_TuneCUETP8M1_13TeV-pythia8_2017':'2','DisplacedSUSY_stopToBottom_M_300_1000mm_TuneCUETP8M1_13TeV_pythia8_2017':'2','TenE_E_0_200_pythia8_2017':'2','TenE_E_0_200_pythia8_2017PU':'2', 'TenTau_E_15_500_pythia8_2018':'2','PhotonJet_Pt_10_13TeV_TuneCUETP8M1_2018':'2','Wjet_Pt_80_120_13TeV_TuneCUETP8M1_2018':'2'} baseDataSetReleaseBetter={} for gen in upgradeFragments: From b13d1179ca6a4152d6e144e0e0d5d61157ece70e Mon Sep 17 00:00:00 2001 From: Patricia Date: Fri, 15 Feb 2019 22:22:06 +0100 Subject: [PATCH 085/686] removing three fragments from override --- Configuration/PyReleaseValidation/python/relval_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 2294c4acce980..3b15a9d592820 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2905,7 +2905,7 @@ def gen2018HiMix(fragment,howMuch): defaultDataSets[key+'PU']=defaultDataSets[key] # sometimes v1 won't be used - override it here - the dictionary key is gen fragment + '_' + geometry -versionOverrides={'BuMixing_BMuonFilter_forSTEAM_13TeV_TuneCUETP8M1_2017':'2','SingleElectronPt10_pythia8_2017':'2','HSCPstop_M_200_TuneCUETP8M1_13TeV_pythia8_2017':'2','RSGravitonToGammaGamma_kMpl01_M_3000_TuneCUETP8M1_13TeV_pythia8_2017':'2','WprimeToENu_M-2000_TuneCUETP8M1_13TeV-pythia8_2017':'2','DisplacedSUSY_stopToBottom_M_300_1000mm_TuneCUETP8M1_13TeV_pythia8_2017':'2','TenE_E_0_200_pythia8_2017':'2','TenE_E_0_200_pythia8_2017PU':'2', 'TenTau_E_15_500_pythia8_2018':'2','PhotonJet_Pt_10_13TeV_TuneCUETP8M1_2018':'2','Wjet_Pt_80_120_13TeV_TuneCUETP8M1_2018':'2'} +versionOverrides={'BuMixing_BMuonFilter_forSTEAM_13TeV_TuneCUETP8M1_2017':'2','HSCPstop_M_200_TuneCUETP8M1_13TeV_pythia8_2017':'2','RSGravitonToGammaGamma_kMpl01_M_3000_TuneCUETP8M1_13TeV_pythia8_2017':'2','WprimeToENu_M-2000_TuneCUETP8M1_13TeV-pythia8_2017':'2','DisplacedSUSY_stopToBottom_M_300_1000mm_TuneCUETP8M1_13TeV_pythia8_2017':'2','TenE_E_0_200_pythia8_2017':'2','TenE_E_0_200_pythia8_2017PU':'2', 'TenTau_E_15_500_pythia8_2018':'2','PhotonJet_Pt_10_13TeV_TuneCUETP8M1_2018':'2','Wjet_Pt_80_120_13TeV_TuneCUETP8M1_2018':'2'} baseDataSetReleaseBetter={} for gen in upgradeFragments: From 49cdcfeacc956086d1c314c3227cc71d8585b676 Mon Sep 17 00:00:00 2001 From: Patricia Date: Fri, 15 Feb 2019 23:31:05 +0100 Subject: [PATCH 086/686] fix overrideFragments --- Configuration/PyReleaseValidation/python/relval_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 3b15a9d592820..b07f9ce021b0f 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1438,7 +1438,7 @@ def lhegensim2017(fragment,howMuch): # sometimes v1 won't be used - override it here - the dictionary key is gen fragment + '_' + geometry -#overrideFragments={'QQH1352T_13UP18INPUT':'2'} +overrideFragments={ } import re for key in overrideFragments: From d4d862431063a5b2a6fc1771f606be2a596ddde0 Mon Sep 17 00:00:00 2001 From: Patricia Date: Fri, 15 Feb 2019 23:33:04 +0100 Subject: [PATCH 087/686] fix overrideFragments --- Configuration/PyReleaseValidation/python/relval_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index b07f9ce021b0f..b21c21955a96c 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1438,7 +1438,7 @@ def lhegensim2017(fragment,howMuch): # sometimes v1 won't be used - override it here - the dictionary key is gen fragment + '_' + geometry -overrideFragments={ } +overrideFragments={} import re for key in overrideFragments: From cc13f077fabfedb19865d8e8b7f7bf8fcc4db827 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 27 Feb 2019 18:34:10 -0600 Subject: [PATCH 088/686] Fix cases where none of the clusters match to SimTrakcs Otherwise equal_range() will throw an exception if accessing the mapping with such a cluster as the ProductID of these (key) clusters has not been recorded. --- .../interface/ClusterTPAssociation.h | 12 ++++++++---- .../plugins/ClusterTPAssociationProducer.cc | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h b/SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h index e4fcde1f03f70..067ebe371cfd8 100644 --- a/SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h +++ b/SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h @@ -31,12 +31,16 @@ class ClusterTPAssociation { explicit ClusterTPAssociation(const edm::HandleBase& mappedHandle): ClusterTPAssociation(mappedHandle.id()) {} explicit ClusterTPAssociation(const edm::ProductID& mappedProductId): mappedProductId_(mappedProductId) {} - void emplace_back(const OmniClusterRef& cluster, const TrackingParticleRef& tp) { - checkMappedProductID(tp); - auto foundKeyID = std::find(std::begin(keyProductIDs_), std::end(keyProductIDs_), cluster.id()); + void addKeyID(edm::ProductID id) { + auto foundKeyID = std::find(std::begin(keyProductIDs_), std::end(keyProductIDs_), id); if(foundKeyID == std::end(keyProductIDs_)) { - keyProductIDs_.emplace_back(cluster.id()); + keyProductIDs_.emplace_back(id); } + } + + void emplace_back(const OmniClusterRef& cluster, const TrackingParticleRef& tp) { + checkMappedProductID(tp); + checkKeyProductID(cluster.id()); map_.emplace_back(cluster, tp); } void sortAndUnique() { diff --git a/SimTracker/TrackerHitAssociation/plugins/ClusterTPAssociationProducer.cc b/SimTracker/TrackerHitAssociation/plugins/ClusterTPAssociationProducer.cc index 648c0b6c6268b..de0d5f9e44f93 100644 --- a/SimTracker/TrackerHitAssociation/plugins/ClusterTPAssociationProducer.cc +++ b/SimTracker/TrackerHitAssociation/plugins/ClusterTPAssociationProducer.cc @@ -134,6 +134,7 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co if ( foundPixelClusters ) { // Pixel Clusters + clusterTPList->addKeyID(pixelClusters.id()); for (edmNew::DetSetVector::const_iterator iter = pixelClusters->begin(); iter != pixelClusters->end(); ++iter) { uint32_t detid = iter->id(); @@ -168,6 +169,7 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co if ( foundStripClusters ) { // Strip Clusters + clusterTPList->addKeyID(stripClusters.id()); for (edmNew::DetSetVector::const_iterator iter = stripClusters->begin(false), eter = stripClusters->end(false); iter != eter; ++iter) { if (!(*iter).isValid()) continue; @@ -202,8 +204,8 @@ void ClusterTPAssociationProducer::produce(edm::StreamID, edm::Event& iEvent, co } if ( foundPhase2OTClusters ) { - // Phase2 Clusters + clusterTPList->addKeyID(phase2OTClusters.id()); if(phase2OTClusters.isValid()){ for (edmNew::DetSetVector::const_iterator iter = phase2OTClusters->begin(false), eter = phase2OTClusters->end(false); iter != eter; ++iter) { From deb98dc79aea1e3b2a4132abba13ea569f77318b Mon Sep 17 00:00:00 2001 From: Wagner Carvalho Date: Thu, 22 Nov 2018 19:16:51 +0100 Subject: [PATCH 089/686] Add beam parameters conditions data code for CTPPS --- CondCore/CTPPSPlugins/src/plugin.cc | 3 + CondFormats/CTPPSReadoutObjects/BuildFile.xml | 1 + .../interface/CTPPSBeamParameters.h | 129 +++++++++++++++++ .../src/CTPPSBeamParameters.cc | 137 ++++++++++++++++++ .../src/T_EventSetup_CTPPSBeamParameters.cc | 4 + .../CTPPSReadoutObjects/src/classes_def.xml | 26 ++++ CondFormats/CTPPSReadoutObjects/src/headers.h | 1 + .../CTPPSReadoutObjects/test/BuildFile.xml | 3 + .../test/testSerializationBeamParameters.cc | 9 ++ .../interface/CTPPSBeamParametersRcd.h | 25 ++++ .../DataRecord/src/CTPPSBeamParametersRcd.cc | 15 ++ 11 files changed, 353 insertions(+) create mode 100644 CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h create mode 100644 CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc create mode 100644 CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc create mode 100644 CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc create mode 100644 CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h create mode 100644 CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index dbe9d8628602f..2fe0ac1625e95 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -1,4 +1,6 @@ #include "CondCore/ESSources/interface/registration_macros.h" +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h" #include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h" @@ -12,6 +14,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h" +REGISTER_PLUGIN(CTPPSBeamParametersRcd,CTPPSBeamParameters); REGISTER_PLUGIN(CTPPSPixelDAQMappingRcd,CTPPSPixelDAQMapping); REGISTER_PLUGIN(CTPPSPixelAnalysisMaskRcd,CTPPSPixelAnalysisMask); REGISTER_PLUGIN(CTPPSPixelGainCalibrationsRcd,CTPPSPixelGainCalibrations); diff --git a/CondFormats/CTPPSReadoutObjects/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/BuildFile.xml index 9abcabe352d4b..e22273fdbdb4c 100644 --- a/CondFormats/CTPPSReadoutObjects/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/BuildFile.xml @@ -1,6 +1,7 @@ + diff --git a/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h b/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h new file mode 100644 index 0000000000000..13e6dfe53b47c --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h @@ -0,0 +1,129 @@ +#ifndef CondFormats_CTPPSReadoutObjects_CTPPSBeamParameters_h +#define CondFormats_CTPPSReadoutObjects_CTPPSBeamParameters_h +// -*- C++ -*- +// +// Package: CTPPSReadoutObjects +// Class: CTPPSBeamParameters +// +/**\class CTPPSBeamParameters CTPPSBeamParameters.h CondFormats/CTPPSRedoutObjects/src/CTPPSBeamParameters.cc + + Description: Beam parameters for proton reconstruction + + Implementation: + +*/ +// Original Author: Wagner Carvalho +// Created: 20 Nov 2018 +// + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +class CTPPSBeamParameters { + + public: + + // Constructor + CTPPSBeamParameters() ; + // Destructor + ~CTPPSBeamParameters() ; + + // Getters + + double getBeamMom45() const ; + double getBeamMom56() const ; + + double getBetaStarX45() const ; + double getBetaStarY45() const ; + double getBetaStarX56() const ; + double getBetaStarY56() const ; + + double getBeamDivergenceX45() const ; + double getBeamDivergenceY45() const ; + double getBeamDivergenceX56() const ; + double getBeamDivergenceY56() const ; + + double getHalfXangleX45() const ; + double getHalfXangleY45() const ; + double getHalfXangleX56() const ; + double getHalfXangleY56() const ; + + double getVtxOffsetX45() const ; + double getVtxOffsetY45() const ; + double getVtxOffsetZ45() const ; + double getVtxOffsetX56() const ; + double getVtxOffsetY56() const ; + double getVtxOffsetZ56() const ; + + double getVtxStddevX() const ; + double getVtxStddevY() const ; + double getVtxStddevZ() const ; + + // Setters + + void setBeamMom45( double mom ) ; + void setBeamMom56( double mom ) ; + + void setBetaStarX45( double beta ) ; + void setBetaStarY45( double beta ) ; + void setBetaStarX56( double beta ) ; + void setBetaStarY56( double beta ) ; + + void setBeamDivergenceX45( double div ) ; + void setBeamDivergenceY45( double div ) ; + void setBeamDivergenceX56( double div ) ; + void setBeamDivergenceY56( double div ) ; + + void setHalfXangleX45( double angle ) ; + void setHalfXangleY45( double angle ) ; + void setHalfXangleX56( double angle ) ; + void setHalfXangleY56( double angle ) ; + + void setVtxOffsetX45( double offset ) ; + void setVtxOffsetY45( double offset ) ; + void setVtxOffsetZ45( double offset ) ; + void setVtxOffsetX56( double offset ) ; + void setVtxOffsetY56( double offset ) ; + void setVtxOffsetZ56( double offset ) ; + + void setVtxStddevX( double stddev ) ; + void setVtxStddevY( double stddev ) ; + void setVtxStddevZ( double stddev ) ; + + void printInfo(std::stringstream & s) ; + + + private: + + // LHC sector 45 corresponds to beam 2, sector 56 to beam 1 + double beam_momentum_45_ ; // GeV + double beam_momentum_56_ ; // GeV + + double beta_star_x_45_ , beta_star_x_56_; // cm + double beta_star_y_45_ , beta_star_y_56_; + + double beam_divergence_x_45_ , beam_divergence_x_56_ ; // rad + double beam_divergence_y_45_ , beam_divergence_y_56_ ; + + double half_crossing_angle_x_45_ , half_crossing_angle_x_56_ ; // rad + double half_crossing_angle_y_45_ , half_crossing_angle_y_56_ ; + + // splitting between 45 and 56 may effectively account for magnet misalignment + double vtx_offset_x_45_ , vtx_offset_x_56_ ; // cm + double vtx_offset_y_45_ , vtx_offset_y_56_ ; // cm + double vtx_offset_z_45_ , vtx_offset_z_56_ ; // cm + + // the following variables might possibly be in another CMS record already, + // but we might want to keep them for completeness/independence + double vtx_stddev_x_ ; // cm + double vtx_stddev_y_ ; // cm + double vtx_stddev_z_ ; // cm + + + COND_SERIALIZABLE; + +}; + +std::ostream & operator<<( std::ostream &, CTPPSBeamParameters ); + +#endif \ No newline at end of file diff --git a/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc new file mode 100644 index 0000000000000..2b0d122c9e9f6 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc @@ -0,0 +1,137 @@ +// -*- C++ -*- +// +// Package: CTPPSReadoutObjects +// Class: CTPPSBeamParameters +// +/**\class CTPPSBeamParameters CTPPSBeamParameters.h CondFormats/CTPPSRedoutObjects/src/CTPPSBeamParameters.cc + + Description: Beam parameters for proton reconstruction + + Implementation: + +*/ +// Original Author: Wagner Carvalho +// Created: 20 Nov 2018 +// + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include + + // Constructors + + CTPPSBeamParameters::CTPPSBeamParameters() : + beam_momentum_45_ (0.) , beam_momentum_56_ (0.) , + beta_star_x_45_ (0.) , beta_star_x_56_ (0.) , + beta_star_y_45_ (0.) , beta_star_y_56_ (0.) , + beam_divergence_x_45_ (0.) , beam_divergence_x_56_ (0.) , + beam_divergence_y_45_ (0.) , beam_divergence_y_56_ (0.) , + half_crossing_angle_x_45_ (0.) , half_crossing_angle_x_56_ (0.) , + half_crossing_angle_y_45_ (0.) , half_crossing_angle_y_56_ (0.) , + vtx_offset_x_45_ (0.) , vtx_offset_x_56_ (0.) , + vtx_offset_y_45_ (0.) , vtx_offset_y_56_ (0.) , + vtx_offset_z_45_ (0.) , vtx_offset_z_56_ (0.) , + vtx_stddev_x_ (0.) , vtx_stddev_y_ (0.) , vtx_stddev_z_ (0.) + {} + + // Destructor + CTPPSBeamParameters::~CTPPSBeamParameters() {} + + // Getters + + double CTPPSBeamParameters::getBeamMom45() const {return beam_momentum_45_;} + double CTPPSBeamParameters::getBeamMom56() const {return beam_momentum_56_;} + + double CTPPSBeamParameters::getBetaStarX45() const {return beta_star_x_45_;} + double CTPPSBeamParameters::getBetaStarY45() const {return beta_star_y_45_;} + double CTPPSBeamParameters::getBetaStarX56() const {return beta_star_x_56_;} + double CTPPSBeamParameters::getBetaStarY56() const {return beta_star_y_56_;} + + double CTPPSBeamParameters::getBeamDivergenceX45() const {return beam_divergence_x_45_;} + double CTPPSBeamParameters::getBeamDivergenceY45() const {return beam_divergence_y_45_;} + double CTPPSBeamParameters::getBeamDivergenceX56() const {return beam_divergence_x_56_;} + double CTPPSBeamParameters::getBeamDivergenceY56() const {return beam_divergence_y_56_;} + + double CTPPSBeamParameters::getHalfXangleX45() const {return half_crossing_angle_x_45_;} + double CTPPSBeamParameters::getHalfXangleY45() const {return half_crossing_angle_y_45_;} + double CTPPSBeamParameters::getHalfXangleX56() const {return half_crossing_angle_x_56_;} + double CTPPSBeamParameters::getHalfXangleY56() const {return half_crossing_angle_y_56_;} + + double CTPPSBeamParameters::getVtxOffsetX45() const {return vtx_offset_x_45_;} + double CTPPSBeamParameters::getVtxOffsetY45() const {return vtx_offset_y_45_;} + double CTPPSBeamParameters::getVtxOffsetZ45() const {return vtx_offset_z_45_;} + double CTPPSBeamParameters::getVtxOffsetX56() const {return vtx_offset_x_56_;} + double CTPPSBeamParameters::getVtxOffsetY56() const {return vtx_offset_y_56_;} + double CTPPSBeamParameters::getVtxOffsetZ56() const {return vtx_offset_z_56_;} + + double CTPPSBeamParameters::getVtxStddevX() const {return vtx_stddev_x_;} + double CTPPSBeamParameters::getVtxStddevY() const {return vtx_stddev_y_;} + double CTPPSBeamParameters::getVtxStddevZ() const {return vtx_stddev_z_;} + + // Setters + + void CTPPSBeamParameters::setBeamMom45( double mom ) {beam_momentum_45_ = mom;} + void CTPPSBeamParameters::setBeamMom56( double mom ) {beam_momentum_56_ = mom;} + + void CTPPSBeamParameters::setBetaStarX45( double beta ) {beta_star_x_45_ = beta;} + void CTPPSBeamParameters::setBetaStarY45( double beta ) {beta_star_y_45_ = beta;} + void CTPPSBeamParameters::setBetaStarX56( double beta ) {beta_star_x_56_ = beta;} + void CTPPSBeamParameters::setBetaStarY56( double beta ) {beta_star_y_56_ = beta;} + + void CTPPSBeamParameters::setBeamDivergenceX45( double div ) {beam_divergence_x_45_ = div;} + void CTPPSBeamParameters::setBeamDivergenceY45( double div ) {beam_divergence_y_45_ = div;} + void CTPPSBeamParameters::setBeamDivergenceX56( double div ) {beam_divergence_x_56_ = div;} + void CTPPSBeamParameters::setBeamDivergenceY56( double div ) {beam_divergence_y_56_ = div;} + + void CTPPSBeamParameters::setHalfXangleX45( double angle ) {half_crossing_angle_x_45_ = angle;} + void CTPPSBeamParameters::setHalfXangleY45( double angle ) {half_crossing_angle_y_45_ = angle;} + void CTPPSBeamParameters::setHalfXangleX56( double angle ) {half_crossing_angle_x_56_ = angle;} + void CTPPSBeamParameters::setHalfXangleY56( double angle ) {half_crossing_angle_y_56_ = angle;} + + void CTPPSBeamParameters::setVtxOffsetX45( double offset ) {vtx_offset_x_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetY45( double offset ) {vtx_offset_y_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetZ45( double offset ) {vtx_offset_z_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetX56( double offset ) {vtx_offset_x_56_ = offset;} + void CTPPSBeamParameters::setVtxOffsetY56( double offset ) {vtx_offset_y_56_ = offset;} + void CTPPSBeamParameters::setVtxOffsetZ56( double offset ) {vtx_offset_z_56_ = offset;} + + void CTPPSBeamParameters::setVtxStddevX( double stddev ) {vtx_stddev_x_ = stddev;} + void CTPPSBeamParameters::setVtxStddevY( double stddev ) {vtx_stddev_y_ = stddev;} + void CTPPSBeamParameters::setVtxStddevZ( double stddev ) {vtx_stddev_z_ = stddev;} + + + void CTPPSBeamParameters::printInfo(std::stringstream & s) + { + s << "\n Beam parameters : \n" + << "\n beam_momentum_45 = " << beam_momentum_45_ << " GeV" + << "\n beam_momentum_56 = " << beam_momentum_56_ << " GeV" + << "\n beta_star_x_45 = " << beta_star_x_45_ << " cm" + << "\n beta_star_y_45 = " << beta_star_y_45_ << " cm" + << "\n beta_star_x_56 = " << beta_star_x_56_ << " cm" + << "\n beta_star_y_56 = " << beta_star_y_56_ << " cm" + << "\n beam_divergence_x_45 = " << beam_divergence_x_45_ << " rad" + << "\n beam_divergence_y_45 = " << beam_divergence_y_45_ << " rad" + << "\n beam_divergence_x_56 = " << beam_divergence_x_56_ << " rad" + << "\n beam_divergence_y_56 = " << beam_divergence_y_56_ << " rad" + << "\n half_crossing_angle_x_45 = " << half_crossing_angle_x_45_ << " rad" + << "\n half_crossing_angle_y_45 = " << half_crossing_angle_y_45_ << " rad" + << "\n half_crossing_angle_x_56 = " << half_crossing_angle_x_56_ << " rad" + << "\n half_crossing_angle_y_56 = " << half_crossing_angle_y_56_ << " rad" + << "\n vtx_offset_x_45 = " << vtx_offset_x_45_ << " cm" + << "\n vtx_offset_y_45 = " << vtx_offset_y_45_ << " cm" + << "\n vtx_offset_z_45 = " << vtx_offset_z_45_ << " cm" + << "\n vtx_offset_x_56 = " << vtx_offset_x_56_ << " cm" + << "\n vtx_offset_y_56 = " << vtx_offset_y_56_ << " cm" + << "\n vtx_offset_z_56 = " << vtx_offset_z_56_ << " cm" + << "\n vtx_stddev_x = " << vtx_stddev_x_ << " cm" + << "\n vtx_stddev_y = " << vtx_stddev_y_ << " cm" + << "\n vtx_stddev_z = " << vtx_stddev_z_ << " cm" + << std::endl ; + + } + +std::ostream & operator<<( std::ostream & os, CTPPSBeamParameters info ) { + std::stringstream ss; + info.printInfo( ss ); + os << ss.str(); + return os; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc new file mode 100644 index 0000000000000..07fac4921dd76 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(CTPPSBeamParameters); diff --git a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml index 77ac92b1126e8..a0b0bf9e470b3 100644 --- a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml +++ b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml @@ -1,4 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CondFormats/CTPPSReadoutObjects/src/headers.h b/CondFormats/CTPPSReadoutObjects/src/headers.h index 733a7e89b1135..24dabc52c51df 100644 --- a/CondFormats/CTPPSReadoutObjects/src/headers.h +++ b/CondFormats/CTPPSReadoutObjects/src/headers.h @@ -1,3 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelGainCalibrations.h" diff --git a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml index d798a922007da..68a568ffc7138 100644 --- a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml @@ -4,4 +4,7 @@ + + + diff --git a/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc new file mode 100644 index 0000000000000..b9b3ec427bf76 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc @@ -0,0 +1,9 @@ +#include "CondFormats/Serialization/interface/Test.h" +#include "CondFormats/CTPPSReadoutObjects/src/headers.h" + +int main() +{ + testSerialization() ; + + return 0 ; +} diff --git a/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h b/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h new file mode 100644 index 0000000000000..3739d19fbc29e --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h @@ -0,0 +1,25 @@ +#ifndef CTPPSBeamParametersRcd_CTPPSBeamParametersRcd_h +#define CTPPSBeamParametersRcd_CTPPSBeamParametersRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : CTPPSBeamParametersRcd +// +/**\class CTPPSBeamParametersRcd CTPPSBeamParametersRcd.h CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h + + Description: Record for beam parameters for CTPPS + + Usage: + + +*/ +// +// Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 16:12:53 GMT +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class CTPPSBeamParametersRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc b/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc new file mode 100644 index 0000000000000..65c374bbe8e72 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : CTPPSBeamParametersRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 16:12:53 GMT + +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSBeamParametersRcd); From e8f6a433d6be38870c17ead94e3fe804cd8c966d Mon Sep 17 00:00:00 2001 From: Wagner Carvalho Date: Mon, 10 Dec 2018 14:58:11 +0100 Subject: [PATCH 090/686] Add PPS beam parameters conditions data ESSource and test code --- .../plugins/CTPPSBeamParametersESSource.cc | 211 ++++++++++++++++++ .../test/test_BeamParametersESSource.py | 76 +++++++ CondTools/CTPPS/BuildFile.xml | 2 + .../retrieve-ctpps-beam-parameters_cfg.py | 44 ++++ .../test/write-ctpps-beam-parameters_cfg.py | 41 ++++ 5 files changed, 374 insertions(+) create mode 100644 CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc create mode 100644 CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py create mode 100644 CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py create mode 100644 CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc new file mode 100644 index 0000000000000..3a8e4be5bd6e0 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc @@ -0,0 +1,211 @@ +/**************************************************************************** + * + * CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc + * + * Description : - Loads CTPPSBeamParameters from the CTPPSBeamParametersESSource_cfi.py + * config file. + * - Currently, one single set of beam parameters is provided. Just to be + * ready in time for 10_4_0 and allow simple tests. + * - To be further developed to provide multiple sets of parameters + * - Needed while CTPPSBeamParameters is not available in database + * + * + * Author: + * Wagner Carvalho wcarvalh@cern.ch + * + ****************************************************************************/ + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ModuleFactory.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +using namespace std; + +/** + * \brief Loads CTPPSBeamParameters from a config file. + **/ + +class CTPPSBeamParametersESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ +public: + + CTPPSBeamParametersESSource(const edm::ParameterSet &); + ~CTPPSBeamParametersESSource() override; + + std::unique_ptr produce(const CTPPSBeamParametersRcd &); + +private: + + bool setBeamPars; + + void initializeBeamParameters(); // Initialize beam parameters (BP) to zero + void setBeamParameters(const edm::ParameterSet &); // Set BP to their values from config + CTPPSBeamParameters* fillBeamParameters(); // Fill CTPPSBeamParameters object with BP + + // Beam parameters + double beamMom45, beamMom56, betaStarX45, betaStarX56, betaStarY45, betaStarY56, + beamDivX45, beamDivX56, beamDivY45, beamDivY56, halfXangleX45, halfXangleX56, + halfXangleY45, halfXangleY56, vtxOffsetX45, vtxOffsetX56, vtxOffsetY45, vtxOffsetY56, + vtxOffsetZ45, vtxOffsetZ56, vtxStddevX, vtxStddevY, vtxStddevZ ; + +protected: + +/// sets infinite validity of this data + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +CTPPSBeamParametersESSource::CTPPSBeamParametersESSource(const edm::ParameterSet& conf) : + setBeamPars(conf.getUntrackedParameter("setBeamPars","False")) + +{ + + initializeBeamParameters(); + if(setBeamPars) setBeamParameters(conf); + + setWhatProduced(this); + findingRecord(); + +} + +//---------------------------------------------------------------------------------------------------- + +CTPPSBeamParametersESSource::~CTPPSBeamParametersESSource() +{ +} + +//---------------------------------------------------------------------------------------------------- + +std::unique_ptr CTPPSBeamParametersESSource::produce( const CTPPSBeamParametersRcd & ) +{ + + CTPPSBeamParameters *bp; + bp = new CTPPSBeamParameters(); + + // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object + if(setBeamPars) bp = fillBeamParameters(); + + edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp << "\n" ; + + return std::unique_ptr(bp); + +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamParametersESSource::initializeBeamParameters() +{ + beamMom45 = beamMom56 = betaStarX45 = betaStarX56 = betaStarY45 = betaStarY56 = + beamDivX45 = beamDivX56 = beamDivY45 = beamDivY56 = halfXangleX45 = halfXangleX56 = + halfXangleY45 = halfXangleY56 = vtxOffsetX45 = vtxOffsetX56 = vtxOffsetY45 = vtxOffsetY56 = + vtxOffsetZ45 = vtxOffsetZ56 = vtxStddevX = vtxStddevY = vtxStddevZ = 0.0 ; +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamParametersESSource::setBeamParameters(const edm::ParameterSet& conf) +{ + beamMom45 = conf.getParameter("beamMom45"); + beamMom56 = conf.getParameter("beamMom56"); + betaStarX45 = conf.getParameter("betaStarX45"); + betaStarX56 = conf.getParameter("betaStarX56"); + betaStarY45 = conf.getParameter("betaStarY45"); + betaStarY56 = conf.getParameter("betaStarY56"); + beamDivX45 = conf.getParameter("beamDivX45"); + beamDivX56 = conf.getParameter("beamDivX56"); + beamDivY45 = conf.getParameter("beamDivY45"); + beamDivY56 = conf.getParameter("beamDivY56"); + halfXangleX45 = conf.getParameter("halfXangleX45"); + halfXangleX56 = conf.getParameter("halfXangleX56"); + halfXangleY45 = conf.getParameter("halfXangleY45"); + halfXangleY56 = conf.getParameter("halfXangleY56"); + vtxOffsetX45 = conf.getParameter("vtxOffsetX45"); + vtxOffsetY45 = conf.getParameter("vtxOffsetY45"); + vtxOffsetZ45 = conf.getParameter("vtxOffsetZ45"); + vtxOffsetX56 = conf.getParameter("vtxOffsetX56"); + vtxOffsetY56 = conf.getParameter("vtxOffsetY56"); + vtxOffsetZ56 = conf.getParameter("vtxOffsetZ56"); + vtxStddevX = conf.getParameter("vtxStddevX"); + vtxStddevY = conf.getParameter("vtxStddevY"); + vtxStddevZ = conf.getParameter("vtxStddevZ"); +} + +//---------------------------------------------------------------------------------------------------- + +CTPPSBeamParameters* CTPPSBeamParametersESSource::fillBeamParameters() +{ + CTPPSBeamParameters* p = new CTPPSBeamParameters(); + + p->setBeamMom45( beamMom45 ); + p->setBeamMom56( beamMom56 ); + + p->setBetaStarX45( betaStarX45 ); + p->setBetaStarY45( betaStarY45 ); + p->setBetaStarX56( betaStarX56 ); + p->setBetaStarY56( betaStarY56 ); + + p->setBeamDivergenceX45( beamDivX45 ); + p->setBeamDivergenceY45( beamDivY45 ); + p->setBeamDivergenceX56( beamDivX56 ); + p->setBeamDivergenceY56( beamDivY56 ); + + p->setHalfXangleX45( halfXangleX45 ); + p->setHalfXangleY45( halfXangleY45 ); + p->setHalfXangleX56( halfXangleX56 ); + p->setHalfXangleY56( halfXangleY56 ); + + p->setVtxOffsetX45( vtxOffsetX45 ); + p->setVtxOffsetY45( vtxOffsetY45 ); + p->setVtxOffsetZ45( vtxOffsetZ45 ); + p->setVtxOffsetX56( vtxOffsetX56 ); + p->setVtxOffsetY56( vtxOffsetY56 ); + p->setVtxOffsetZ56( vtxOffsetZ56 ); + + p->setVtxStddevX( vtxStddevX ); + p->setVtxStddevY( vtxStddevY ); + p->setVtxStddevZ( vtxStddevZ ); + + // edm::LogInfo("CTPPSBeamParametersESSource::fillBeamParameters") << "\n" ; + + return p ; +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamParametersESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +{ + /* + LogVerbatim("CTPPSBeamParametersESSource") + << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")"; + + LogVerbatim("CTPPSBeamParametersESSource") + << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event(); + */ + + edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() ); + oValidity = infinity; + +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSBeamParametersESSource); diff --git a/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py b/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py new file mode 100644 index 0000000000000..d31be1e81c0eb --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py @@ -0,0 +1,76 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ) +) + +# raw data source +#process.source = cms.Source("EmptySource", +#) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + # timetype = cms.string('lumiid'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# Load beam parameters +process.load("CondFormats.CTPPSReadoutObjects.CTPPSBeamParametersESSource_cfi") +# process.CTPPSBeamParametersESSource.verbosity = cms.untracked.uint32(2) + +# Test retrieving the ESSource data +process.get = cms.EDAnalyzer("RetrieveCTPPSBeamParameters", + verbose = cms.untracked.bool(True) +) + +# ======================== Test writing to DB ========================================== + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# Output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + # timetype = cms.untracked.string('timestamp'), + # timetype = cms.untracked.string('lumiid'), + toPut = cms.VPSet( + cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string('CTPPSBeamParameters_v1') + ) + ) +) + +process.write = cms.EDAnalyzer("WriteCTPPSBeamParameters", + record = cms.string('CTPPSBeamParametersRcd'), + loggingOn= cms.untracked.bool(True), + SinceAppendMode=cms.bool(True), + Source=cms.PSet( + IOVRun=cms.untracked.uint32(1) + ) +) + +# =============================================================================== + + +process.path = cms.Path( + process.get*process.write +) diff --git a/CondTools/CTPPS/BuildFile.xml b/CondTools/CTPPS/BuildFile.xml index 606b514ecbc6c..e219cd905d12b 100644 --- a/CondTools/CTPPS/BuildFile.xml +++ b/CondTools/CTPPS/BuildFile.xml @@ -3,6 +3,8 @@ + + diff --git a/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py new file mode 100644 index 0000000000000..e2dd7033472ec --- /dev/null +++ b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py @@ -0,0 +1,44 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("retrieveCTPPSBeamParametersTest") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# input database (in this case the local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' +# WORK_DIR = "/afs/cern.ch/work/w/wcarvalh/ctpps/db/CMSSW_10_4_0_pre2/src" +# process.CondDB.connect = 'sqlite_file:/afs/cern.ch/work/w/wcarvalh/ctpps/db/CMSSW_10_2_0_pre3/src/CondTools/CTPPS/test_output.db' + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string("CTPPSBeamParameters_v1") + )), +) + +process.get = cms.EDAnalyzer("RetrieveCTPPSBeamParameters", + verbose = cms.untracked.bool(True) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(3), + lastValue = cms.uint64(3), + interval = cms.uint64(1) + #timetype = cms.string('timestamp'), + #firstValue = cms.uint64(6542600000000000000), + #lastValue = cms.uint64(6542700000000000000), + #interval = cms.uint64(100000000000000) + # timetype = cms.string('lumiid'), +) + +process.path = cms.Path(process.get) diff --git a/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py b/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py new file mode 100644 index 0000000000000..0702975bcda39 --- /dev/null +++ b/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py @@ -0,0 +1,41 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("writeCTPPSBeamParameters") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + # timetype = cms.string('lumiid'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + # timetype = cms.untracked.string('runnumber'), + # timetype = cms.untracked.string('timestamp'), + timetype = cms.untracked.string('lumiid'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string('CTPPSBeamParameters_v1') + )) +) + +process.parameters_maker = cms.EDAnalyzer("WriteCTPPSBeamParameters", + record = cms.string('CTPPSBeamParametersRcd'), + loggingOn= cms.untracked.bool(True), + SinceAppendMode=cms.bool(True), + Source=cms.PSet( + IOVRun=cms.untracked.uint32(1) + ) +) + +process.path = cms.Path(process.parameters_maker) From 0a522f83201683864a549179bee17fb23e55c61c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 3 Dec 2018 19:35:46 +0100 Subject: [PATCH 091/686] Added LHCOpticalFunctionsSet class. --- .../interface/LHCOpticalFunctionsSet.h | 66 +++++++ .../src/LHCOpticalFunctionsSet.cc | 167 ++++++++++++++++++ .../T_EventSetup_LHCOpticalFunctionsSet.cc | 4 + 3 files changed, 237 insertions(+) create mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h create mode 100644 CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc create mode 100644 CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h new file mode 100644 index 0000000000000..418e7a5b396cc --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -0,0 +1,66 @@ +#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h +#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h + +// Original Author: Jan KaÅ¡par + +#include "CondFormats/Serialization/interface/Serializable.h" + +#include +#include +#include + +#include "TSpline.h" + +class LHCOpticalFunctionsSet +{ + public: + LHCOpticalFunctionsSet() {} + + /// fills m_*_values fields from a ROOT file + LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName); + + ~LHCOpticalFunctionsSet(); + + /// builds splines from m_*_values fields + void InitializeSplines(); + + /// proton kinematics description + struct Kinematics + { + double x, th_x, y, th_y, xi; + }; + + /// transports proton according to the splines + void Transport(const Kinematics &input, Kinematics &output) const; + + /// interpolates optical functions from (xangle1, of1) and (xangle2, of2) to xangle + LHCOpticalFunctionsSet* Interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, + double xangle2, const LHCOpticalFunctionsSet &of2, double xangle); + + private: + std::vector m_xi_values; + + std::vector m_x_D_values; + std::vector m_L_x_values; + std::vector m_v_x_values; + std::vector m_E_14_values; + + std::vector m_y_D_values; + std::vector m_L_y_values; + std::vector m_v_y_values; + std::vector m_E_32_values; + + std::shared_ptr m_s_x_D_vs_xi; + std::shared_ptr m_s_L_x_vs_xi; + std::shared_ptr m_s_v_x_vs_xi; + std::shared_ptr m_s_E_14_vs_xi; + + std::shared_ptr m_s_y_D_vs_xi; + std::shared_ptr m_s_L_y_vs_xi; + std::shared_ptr m_s_v_y_vs_xi; + std::shared_ptr m_s_E_32_vs_xi; + + COND_SERIALIZABLE; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..ce0b5da95d27f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -0,0 +1,167 @@ +// Original Author: Jan KaÅ¡par + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include "FWCore/Utilities/interface/Exception.h" + +#include "TFile.h" +#include "TGraph.h" + +//---------------------------------------------------------------------------------------------------- + +LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName) +{ + TFile *f_in = TFile::Open(fileName.c_str()); + if (f_in == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; + + TGraph *g_x_D = (TGraph *) f_in->Get((directoryName + "/g_x_D_vs_xi").c_str()); + if (g_x_D == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_x_D_vs_xi from file " << fileName << "."; + + TGraph *g_L_x = (TGraph *) f_in->Get((directoryName + "/g_L_x_vs_xi").c_str()); + if (g_L_x == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_L_x_vs_xi from file " << fileName << "."; + + TGraph *g_v_x = (TGraph *) f_in->Get((directoryName + "/g_v_x_vs_xi").c_str()); + if (g_v_x == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_v_x_vs_xi from file " << fileName << "."; + + TGraph *g_E_14 = (TGraph *) f_in->Get((directoryName + "/g_E_14_vs_xi").c_str()); + if (g_E_14 == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_E_14_vs_xi from file " << fileName << "."; + + TGraph *g_y_D = (TGraph *) f_in->Get((directoryName + "/g_y_D_vs_xi").c_str()); + if (g_y_D == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_y_D_vs_xi from file " << fileName << "."; + + TGraph *g_L_y = (TGraph *) f_in->Get((directoryName + "/g_L_y_vs_xi").c_str()); + if (g_L_y == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_L_y_vs_xi from file " << fileName << "."; + + TGraph *g_v_y = (TGraph *) f_in->Get((directoryName + "/g_v_y_vs_xi").c_str()); + if (g_v_y == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_v_y_vs_xi from file " << fileName << "."; + + TGraph *g_E_32 = (TGraph *) f_in->Get((directoryName + "/g_E_32_vs_xi").c_str()); + if (g_E_32 == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_E_32_vs_xi from file " << fileName << "."; + + const unsigned int n = g_x_D->GetN(); + + m_xi_values.resize(n); + m_x_D_values.resize(n); + m_L_x_values.resize(n); + m_v_x_values.resize(n); + m_E_14_values.resize(n); + + m_y_D_values.resize(n); + m_L_y_values.resize(n); + m_v_y_values.resize(n); + m_E_32_values.resize(n); + + for (unsigned int i = 0; i < n; ++i) + { + const double xi = g_x_D->GetX()[i]; + m_xi_values[i] = xi; + + m_x_D_values[i] = g_x_D->Eval(xi); + m_L_x_values[i] = g_L_x->Eval(xi); + m_v_x_values[i] = g_v_x->Eval(xi); + m_E_14_values[i] = g_E_14->Eval(xi); + + m_y_D_values[i] = g_y_D->Eval(xi); + m_L_y_values[i] = g_L_y->Eval(xi); + m_v_y_values[i] = g_v_y->Eval(xi); + m_E_32_values[i] = g_E_32->Eval(xi); + } + + delete f_in; +} + +//---------------------------------------------------------------------------------------------------- + +void LHCOpticalFunctionsSet::InitializeSplines() +{ + const unsigned int n = m_xi_values.size(); + + m_s_x_D_vs_xi = std::make_shared("", m_xi_values.data(), m_x_D_values.data(), n); + m_s_L_x_vs_xi = std::make_shared("", m_xi_values.data(), m_L_x_values.data(), n); + m_s_v_x_vs_xi = std::make_shared("", m_xi_values.data(), m_v_x_values.data(), n); + m_s_E_14_vs_xi = std::make_shared("", m_xi_values.data(), m_E_14_values.data(), n); + + m_s_y_D_vs_xi = std::make_shared("", m_xi_values.data(), m_y_D_values.data(), n); + m_s_L_y_vs_xi = std::make_shared("", m_xi_values.data(), m_L_y_values.data(), n); + m_s_v_y_vs_xi = std::make_shared("", m_xi_values.data(), m_v_y_values.data(), n); + m_s_E_32_vs_xi = std::make_shared("", m_xi_values.data(), m_E_32_values.data(), n); +} + +//---------------------------------------------------------------------------------------------------- + +void LHCOpticalFunctionsSet::Transport(const LHCOpticalFunctionsSet::Kinematics &input, LHCOpticalFunctionsSet::Kinematics &output) const +{ + output.x = m_s_x_D_vs_xi->Eval(input.xi) + m_s_v_x_vs_xi->Eval(input.xi) * input.x + + m_s_L_x_vs_xi->Eval(input.xi) * input.th_x + m_s_E_14_vs_xi->Eval(input.xi) * input.th_y; + + output.th_x = 0.; + + output.y = m_s_y_D_vs_xi->Eval(input.xi) + m_s_v_y_vs_xi->Eval(input.xi) * input.y + + m_s_L_y_vs_xi->Eval(input.xi) * input.th_y + m_s_E_32_vs_xi->Eval(input.xi) * input.th_x; + + output.th_y = 0.; + + output.xi = input.xi; +} + +//---------------------------------------------------------------------------------------------------- + +LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::Interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, + double xangle2, const LHCOpticalFunctionsSet &of2, double xangle) +{ + LHCOpticalFunctionsSet *output = new LHCOpticalFunctionsSet(); + + const unsigned int n = of1.m_xi_values.size(); + + output->m_xi_values.resize(n); + output->m_x_D_values.resize(n); + output->m_L_x_values.resize(n); + output->m_v_x_values.resize(n); + output->m_E_14_values.resize(n); + output->m_y_D_values.resize(n); + output->m_L_y_values.resize(n); + output->m_v_y_values.resize(n); + output->m_E_32_values.resize(n); + + for (unsigned int i = 0; i < n; ++i) + { + double xi = of1.m_xi_values[i]; + + output->m_xi_values[i] = xi; + + double x_D_1 = of1.m_s_x_D_vs_xi->Eval(xi), x_D_2 = of2.m_s_x_D_vs_xi->Eval(xi); + output->m_x_D_values[i] = x_D_2 + (x_D_2 - x_D_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double L_x_1 = of1.m_s_L_x_vs_xi->Eval(xi), L_x_2 = of2.m_s_L_x_vs_xi->Eval(xi); + output->m_L_x_values[i] = L_x_2 + (L_x_2 - L_x_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double v_x_1 = of1.m_s_v_x_vs_xi->Eval(xi), v_x_2 = of2.m_s_v_x_vs_xi->Eval(xi); + output->m_v_x_values[i] = v_x_2 + (v_x_2 - v_x_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double E_14_1 = of1.m_s_E_14_vs_xi->Eval(xi), E_14_2 = of2.m_s_E_14_vs_xi->Eval(xi); + output->m_E_14_values[i] = E_14_2 + (E_14_2 - E_14_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double y_D_1 = of1.m_s_y_D_vs_xi->Eval(xi), y_D_2 = of2.m_s_y_D_vs_xi->Eval(xi); + output->m_y_D_values[i] = y_D_2 + (y_D_2 - y_D_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double L_y_1 = of1.m_s_L_y_vs_xi->Eval(xi), L_y_2 = of2.m_s_L_y_vs_xi->Eval(xi); + output->m_L_y_values[i] = L_y_2 + (L_y_2 - L_y_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double v_y_1 = of1.m_s_v_y_vs_xi->Eval(xi), v_y_2 = of2.m_s_v_y_vs_xi->Eval(xi); + output->m_v_y_values[i] = v_y_2 + (v_y_2 - v_y_1) / (xangle2 - xangle1) * (xangle - xangle2); + + double E_32_1 = of1.m_s_E_32_vs_xi->Eval(xi), E_32_2 = of2.m_s_E_32_vs_xi->Eval(xi); + output->m_E_32_values[i] = E_32_2 + (E_32_2 - E_32_1) / (xangle2 - xangle1) * (xangle - xangle2); + } + + return output; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..25799a9eda263 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCOpticalFunctionsSet); From 61b90207930218d3990730bf7145620cd69e2228 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 5 Dec 2018 09:09:04 +0100 Subject: [PATCH 092/686] Added ROOT as dependence. --- CondFormats/CTPPSReadoutObjects/BuildFile.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CondFormats/CTPPSReadoutObjects/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/BuildFile.xml index e22273fdbdb4c..247e1e31a67fe 100644 --- a/CondFormats/CTPPSReadoutObjects/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/BuildFile.xml @@ -6,6 +6,8 @@ + + From 540395416114b082fecf0ed7206699273c159d94 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 5 Dec 2018 20:37:49 +0100 Subject: [PATCH 093/686] Added also angular optica functions. --- .../interface/LHCOpticalFunctionsSet.h | 49 +++-- .../src/LHCOpticalFunctionsSet.cc | 185 ++++++++---------- 2 files changed, 103 insertions(+), 131 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index 418e7a5b396cc..b707b66293367 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -11,54 +11,53 @@ #include "TSpline.h" +/** + \brief Set of optical functions corresponding to one scoring plane along LHC. +**/ class LHCOpticalFunctionsSet { public: LHCOpticalFunctionsSet() {} /// fills m_*_values fields from a ROOT file - LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName); + LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, const double &z); - ~LHCOpticalFunctionsSet(); + ~LHCOpticalFunctionsSet() {} + + /// returns the position of the scoring plane (LHC/TOTEM convention) + double getScoringPlaneZ() const { return m_z; } /// builds splines from m_*_values fields - void InitializeSplines(); + void initializeSplines(); /// proton kinematics description struct Kinematics { - double x, th_x, y, th_y, xi; + double x; // physics vertex position (beam offset subtracted), m + double th_x; // physics scattering angle (crossing angle subtracted), rad + double y; // physics vertex position, m + double th_y; // physics scattering angle, rad + double xi; // relative momentum loss (positive for diffractive protons) }; /// transports proton according to the splines - void Transport(const Kinematics &input, Kinematics &output) const; + void transport(const Kinematics &input, Kinematics &output, bool calculateAngles = false) const; /// interpolates optical functions from (xangle1, of1) and (xangle2, of2) to xangle - LHCOpticalFunctionsSet* Interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, + static LHCOpticalFunctionsSet* interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, double xangle2, const LHCOpticalFunctionsSet &of2, double xangle); private: + /// position of the scoring plane, in LHC/TOTEM convention, m + double m_z; + std::vector m_xi_values; - std::vector m_x_D_values; - std::vector m_L_x_values; - std::vector m_v_x_values; - std::vector m_E_14_values; - - std::vector m_y_D_values; - std::vector m_L_y_values; - std::vector m_v_y_values; - std::vector m_E_32_values; - - std::shared_ptr m_s_x_D_vs_xi; - std::shared_ptr m_s_L_x_vs_xi; - std::shared_ptr m_s_v_x_vs_xi; - std::shared_ptr m_s_E_14_vs_xi; - - std::shared_ptr m_s_y_D_vs_xi; - std::shared_ptr m_s_L_y_vs_xi; - std::shared_ptr m_s_v_y_vs_xi; - std::shared_ptr m_s_E_32_vs_xi; + enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd }; + + std::array, 16> m_fcn_values; + + std::array, 16> m_splines; COND_SERIALIZABLE; }; diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index ce0b5da95d27f..a4ec42f50a61c 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -9,71 +9,56 @@ //---------------------------------------------------------------------------------------------------- -LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName) +LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, const double &z) : + m_z(z) { TFile *f_in = TFile::Open(fileName.c_str()); if (f_in == NULL) throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; - TGraph *g_x_D = (TGraph *) f_in->Get((directoryName + "/g_x_D_vs_xi").c_str()); - if (g_x_D == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_x_D_vs_xi from file " << fileName << "."; - - TGraph *g_L_x = (TGraph *) f_in->Get((directoryName + "/g_L_x_vs_xi").c_str()); - if (g_L_x == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_L_x_vs_xi from file " << fileName << "."; - - TGraph *g_v_x = (TGraph *) f_in->Get((directoryName + "/g_v_x_vs_xi").c_str()); - if (g_v_x == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_v_x_vs_xi from file " << fileName << "."; - - TGraph *g_E_14 = (TGraph *) f_in->Get((directoryName + "/g_E_14_vs_xi").c_str()); - if (g_E_14 == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_E_14_vs_xi from file " << fileName << "."; - - TGraph *g_y_D = (TGraph *) f_in->Get((directoryName + "/g_y_D_vs_xi").c_str()); - if (g_y_D == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_y_D_vs_xi from file " << fileName << "."; - - TGraph *g_L_y = (TGraph *) f_in->Get((directoryName + "/g_L_y_vs_xi").c_str()); - if (g_L_y == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_L_y_vs_xi from file " << fileName << "."; - - TGraph *g_v_y = (TGraph *) f_in->Get((directoryName + "/g_v_y_vs_xi").c_str()); - if (g_v_y == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_v_y_vs_xi from file " << fileName << "."; - - TGraph *g_E_32 = (TGraph *) f_in->Get((directoryName + "/g_E_32_vs_xi").c_str()); - if (g_E_32 == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << directoryName << "/g_E_32_vs_xi from file " << fileName << "."; + std::vector graphs(m_fcn_values.size()); + for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) + { + std::string tag; + if (fi == evx) tag = "v_x"; + if (fi == eLx) tag = "L_x"; + if (fi == e14) tag = "E_14"; + if (fi == exd) tag = "x_D"; + if (fi == evpx) tag = "vp_x"; + if (fi == eLpx) tag = "Lp_x"; + if (fi == e24) tag = "E_24"; + if (fi == expd) tag = "xp_D"; + if (fi == e32) tag = "E_32"; + if (fi == evy) tag = "v_y"; + if (fi == eLy) tag = "L_y"; + if (fi == eyd) tag = "y_D"; + if (fi == e42) tag = "E_42"; + if (fi == evpy) tag = "vp_y"; + if (fi == eLpy) tag = "Lp_y"; + if (fi == eypd) tag = "yp_D"; + + std::string objPath = directoryName + "/g_" + tag + "_vs_xi"; + TGraph *g = (TGraph *) f_in->Get(objPath.c_str()); + if (g == NULL) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << objPath << " from file " << fileName << "."; + + graphs[fi] = g; + } - const unsigned int n = g_x_D->GetN(); + const unsigned int n = graphs[0]->GetN(); m_xi_values.resize(n); - m_x_D_values.resize(n); - m_L_x_values.resize(n); - m_v_x_values.resize(n); - m_E_14_values.resize(n); - m_y_D_values.resize(n); - m_L_y_values.resize(n); - m_v_y_values.resize(n); - m_E_32_values.resize(n); + for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) + m_fcn_values[fi].resize(n); - for (unsigned int i = 0; i < n; ++i) + for (unsigned int pi = 0; pi < n; ++pi) { - const double xi = g_x_D->GetX()[i]; - m_xi_values[i] = xi; - - m_x_D_values[i] = g_x_D->Eval(xi); - m_L_x_values[i] = g_L_x->Eval(xi); - m_v_x_values[i] = g_v_x->Eval(xi); - m_E_14_values[i] = g_E_14->Eval(xi); - - m_y_D_values[i] = g_y_D->Eval(xi); - m_L_y_values[i] = g_L_y->Eval(xi); - m_v_y_values[i] = g_v_y->Eval(xi); - m_E_32_values[i] = g_E_32->Eval(xi); + const double xi = graphs[0]->GetX()[pi]; + m_xi_values[pi] = xi; + + for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) + m_fcn_values[fi][pi] = graphs[fi]->Eval(xi); } delete f_in; @@ -81,86 +66,74 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons //---------------------------------------------------------------------------------------------------- -void LHCOpticalFunctionsSet::InitializeSplines() +void LHCOpticalFunctionsSet::initializeSplines() { const unsigned int n = m_xi_values.size(); - m_s_x_D_vs_xi = std::make_shared("", m_xi_values.data(), m_x_D_values.data(), n); - m_s_L_x_vs_xi = std::make_shared("", m_xi_values.data(), m_L_x_values.data(), n); - m_s_v_x_vs_xi = std::make_shared("", m_xi_values.data(), m_v_x_values.data(), n); - m_s_E_14_vs_xi = std::make_shared("", m_xi_values.data(), m_E_14_values.data(), n); - - m_s_y_D_vs_xi = std::make_shared("", m_xi_values.data(), m_y_D_values.data(), n); - m_s_L_y_vs_xi = std::make_shared("", m_xi_values.data(), m_L_y_values.data(), n); - m_s_v_y_vs_xi = std::make_shared("", m_xi_values.data(), m_v_y_values.data(), n); - m_s_E_32_vs_xi = std::make_shared("", m_xi_values.data(), m_E_32_values.data(), n); + for (unsigned int i = 0; i < m_fcn_values.size(); ++i) + m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), n); } //---------------------------------------------------------------------------------------------------- -void LHCOpticalFunctionsSet::Transport(const LHCOpticalFunctionsSet::Kinematics &input, LHCOpticalFunctionsSet::Kinematics &output) const +void LHCOpticalFunctionsSet::transport(const LHCOpticalFunctionsSet::Kinematics &input, + LHCOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const { - output.x = m_s_x_D_vs_xi->Eval(input.xi) + m_s_v_x_vs_xi->Eval(input.xi) * input.x - + m_s_L_x_vs_xi->Eval(input.xi) * input.th_x + m_s_E_14_vs_xi->Eval(input.xi) * input.th_y; + const double &xi = input.xi; + + output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x + + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; - output.th_x = 0.; + output.th_x = (!calculateAngles) ? 0. : m_splines[expd]->Eval(xi) + m_splines[evpx]->Eval(xi) * input.x + + m_splines[eLpx]->Eval(xi) * input.th_x + m_splines[e24]->Eval(xi) * input.th_y; - output.y = m_s_y_D_vs_xi->Eval(input.xi) + m_s_v_y_vs_xi->Eval(input.xi) * input.y - + m_s_L_y_vs_xi->Eval(input.xi) * input.th_y + m_s_E_32_vs_xi->Eval(input.xi) * input.th_x; + output.y = m_splines[eyd]->Eval(xi) + m_splines[evy]->Eval(xi) * input.y + + m_splines[eLy]->Eval(xi) * input.th_y + m_splines[e32]->Eval(xi) * input.th_x; - output.th_y = 0.; + output.th_y = (!calculateAngles) ? 0. : m_splines[eypd]->Eval(xi) + m_splines[evpy]->Eval(xi) * input.y + + m_splines[eLpy]->Eval(xi) * input.th_y + m_splines[e42]->Eval(xi) * input.th_x; output.xi = input.xi; } //---------------------------------------------------------------------------------------------------- -LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::Interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, +LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, double xangle2, const LHCOpticalFunctionsSet &of2, double xangle) { - LHCOpticalFunctionsSet *output = new LHCOpticalFunctionsSet(); - - const unsigned int n = of1.m_xi_values.size(); - - output->m_xi_values.resize(n); - output->m_x_D_values.resize(n); - output->m_L_x_values.resize(n); - output->m_v_x_values.resize(n); - output->m_E_14_values.resize(n); - output->m_y_D_values.resize(n); - output->m_L_y_values.resize(n); - output->m_v_y_values.resize(n); - output->m_E_32_values.resize(n); - - for (unsigned int i = 0; i < n; ++i) + // check whether interpolation can be done + if (abs(xangle1 - xangle2) < 1e-6) { - double xi = of1.m_xi_values[i]; - - output->m_xi_values[i] = xi; + if (abs(xangle - xangle1) < 1e-6) + return new LHCOpticalFunctionsSet(of1); + else + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot interpolate from angles " << xangle1 << + " and " << xangle2 << " to angle " << xangle << "."; + } - double x_D_1 = of1.m_s_x_D_vs_xi->Eval(xi), x_D_2 = of2.m_s_x_D_vs_xi->Eval(xi); - output->m_x_D_values[i] = x_D_2 + (x_D_2 - x_D_1) / (xangle2 - xangle1) * (xangle - xangle2); + // do interpolation + LHCOpticalFunctionsSet *output = new LHCOpticalFunctionsSet(); - double L_x_1 = of1.m_s_L_x_vs_xi->Eval(xi), L_x_2 = of2.m_s_L_x_vs_xi->Eval(xi); - output->m_L_x_values[i] = L_x_2 + (L_x_2 - L_x_1) / (xangle2 - xangle1) * (xangle - xangle2); + output->m_z = of1.m_z; - double v_x_1 = of1.m_s_v_x_vs_xi->Eval(xi), v_x_2 = of2.m_s_v_x_vs_xi->Eval(xi); - output->m_v_x_values[i] = v_x_2 + (v_x_2 - v_x_1) / (xangle2 - xangle1) * (xangle - xangle2); + const unsigned int n = of1.m_xi_values.size(); - double E_14_1 = of1.m_s_E_14_vs_xi->Eval(xi), E_14_2 = of2.m_s_E_14_vs_xi->Eval(xi); - output->m_E_14_values[i] = E_14_2 + (E_14_2 - E_14_1) / (xangle2 - xangle1) * (xangle - xangle2); + output->m_xi_values.resize(n); - double y_D_1 = of1.m_s_y_D_vs_xi->Eval(xi), y_D_2 = of2.m_s_y_D_vs_xi->Eval(xi); - output->m_y_D_values[i] = y_D_2 + (y_D_2 - y_D_1) / (xangle2 - xangle1) * (xangle - xangle2); + for (unsigned int fi = 0; fi < of1.m_fcn_values.size(); ++fi) + { + output->m_fcn_values[fi].resize(n); - double L_y_1 = of1.m_s_L_y_vs_xi->Eval(xi), L_y_2 = of2.m_s_L_y_vs_xi->Eval(xi); - output->m_L_y_values[i] = L_y_2 + (L_y_2 - L_y_1) / (xangle2 - xangle1) * (xangle - xangle2); + for (unsigned int pi = 0; pi < n; ++pi) + { + double xi = of1.m_xi_values[pi]; - double v_y_1 = of1.m_s_v_y_vs_xi->Eval(xi), v_y_2 = of2.m_s_v_y_vs_xi->Eval(xi); - output->m_v_y_values[i] = v_y_2 + (v_y_2 - v_y_1) / (xangle2 - xangle1) * (xangle - xangle2); + output->m_xi_values[pi] = xi; - double E_32_1 = of1.m_s_E_32_vs_xi->Eval(xi), E_32_2 = of2.m_s_E_32_vs_xi->Eval(xi); - output->m_E_32_values[i] = E_32_2 + (E_32_2 - E_32_1) / (xangle2 - xangle1) * (xangle - xangle2); + double v1 = of1.m_splines[fi]->Eval(xi); + double v2 = of2.m_splines[fi]->Eval(xi); + output->m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (xangle - xangle1); + } } return output; From 7b8bd481b15326ab31b56ba0922fc4e100198791 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 5 Dec 2018 20:39:18 +0100 Subject: [PATCH 094/686] Added ES record and source for optical functions. --- .../interface/LHCOpticalFunctionsCollection.h | 48 +++++++++ .../plugins/CTPPSOpticalFunctionsESSource.cc | 101 ++++++++++++++++++ .../ctppsOpticalFunctionsESSource_cfi.py | 16 +++ .../src/LHCOpticalFunctionsCollection.cc | 21 ++++ ...ventSetup_LHCOpticalFunctionsCollection.cc | 4 + .../DataRecord/interface/CTPPSOpticsRcd.h | 10 ++ CondFormats/DataRecord/src/CTPPSOpticsRcd.cc | 6 ++ 7 files changed, 206 insertions(+) create mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h create mode 100644 CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc create mode 100644 CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py create mode 100644 CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc create mode 100644 CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc create mode 100644 CondFormats/DataRecord/interface/CTPPSOpticsRcd.h create mode 100644 CondFormats/DataRecord/src/CTPPSOpticsRcd.cc diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h new file mode 100644 index 0000000000000..b2a537fcda6ad --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h @@ -0,0 +1,48 @@ +#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsCollection_h +#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsCollection_h + +// Original Author: Jan KaÅ¡par + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include + +class CTPPSOpticalFunctionsESSource; + +/** + \brief Collection of optical functions for two crossing angle values and various scoring planes. +**/ +class LHCOpticalFunctionsCollection +{ + public: + using mapType = std::unordered_map; + + LHCOpticalFunctionsCollection() {} + + ~LHCOpticalFunctionsCollection() {} + + /// (half-)crossing-angle values in urad + double getXangle1() const { return m_xangle1; } + double getXangle2() const { return m_xangle2; } + + const mapType& getFunctions1() const { return m_functions1; } + const mapType& getFunctions2() const { return m_functions2; } + + void interpolateFunctions(double xangle, mapType &output) const; + + void setXangle1(double v) { m_xangle1 = v; } + void setXangle2(double v) { m_xangle2 = v; } + + private: + friend CTPPSOpticalFunctionsESSource; + + double m_xangle1, m_xangle2; + + /// map: RP id --> optical functions + mapType m_functions1, m_functions2; + + COND_SERIALIZABLE; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc new file mode 100644 index 0000000000000..0ad1a8bc4afa5 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc @@ -0,0 +1,101 @@ +// Original Author: Jan KaÅ¡par + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" + +//---------------------------------------------------------------------------------------------------- + +/** + * \brief Loads optical functions from ROOT files. + **/ +class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ + public: + CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); + + ~CTPPSOpticalFunctionsESSource() {}; + + edm::ESProducts> produce(const CTPPSOpticsRcd &); + + private: + double m_xangle1, m_xangle2; + std::string m_fileName1, m_fileName2; + + struct RPInfo + { + std::string dirName; + double scoringPlaneZ; + }; + + std::unordered_map m_rpInfo; + + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) : + m_xangle1(conf.getParameter("xangle1")), + m_xangle2(conf.getParameter("xangle2")), + m_fileName1(conf.getParameter("fileName1").fullPath()), + m_fileName2(conf.getParameter("fileName2").fullPath()) +{ + for (const auto &pset : conf.getParameter>("scoringPlanes")) + { + const unsigned int rpId = pset.getParameter("rpId"); + const std::string dirName = pset.getParameter("dirName"); + const double z = pset.getParameter("z"); + const RPInfo entry = {dirName, z}; + m_rpInfo.emplace(rpId, entry); + } + + setWhatProduced(this); + findingRecord(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +{ + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); +} + +//---------------------------------------------------------------------------------------------------- + +edm::ESProducts< std::unique_ptr > + CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) +{ + // fill the output + auto output = std::make_unique(); + + output->m_xangle1 = m_xangle1; + output->m_xangle2 = m_xangle2; + + for (const auto &p : m_rpInfo) + { + LHCOpticalFunctionsSet fcn1(m_fileName1, p.second.dirName, p.second.scoringPlaneZ); + fcn1.initializeSplines(); + output->m_functions1.emplace(p.first, std::move(fcn1)); + + LHCOpticalFunctionsSet fcn2(m_fileName2, p.second.dirName, p.second.scoringPlaneZ); + fcn2.initializeSplines(); + output->m_functions2.emplace(p.first, std::move(fcn2)); + } + + // commit the output + return edm::es::products(std::move(output)); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSOpticalFunctionsESSource); diff --git a/CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py new file mode 100644 index 0000000000000..861621823c198 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -0,0 +1,16 @@ +import FWCore.ParameterSet.Config as cms + +ctppsOpticalFunctionsESSource = cms.ESSource("CTPPSOpticalFunctionsESSource", + xangle1 = cms.double(185), + fileName1 = cms.FileInPath("CondFormats/CTPPSReadoutObjects/data/year_2016/optical_functions.root"), + + xangle2 = cms.double(185), + fileName2 = cms.FileInPath("CondFormats/CTPPSReadoutObjects/data/year_2016/optical_functions.root"), + + scoringPlanes = cms.VPSet( + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-203.826) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-212.551) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+203.826) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+212.551) ), # RP 103 + ) +) diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc new file mode 100644 index 0000000000000..cbc7c5d2e2230 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc @@ -0,0 +1,21 @@ +// Original Author: Jan KaÅ¡par + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" + +#include "FWCore/Utilities/interface/Exception.h" + +//---------------------------------------------------------------------------------------------------- + +void LHCOpticalFunctionsCollection::interpolateFunctions(double xangle, mapType &output) const +{ + for (const auto p1 : m_functions1) + { + const auto it2 = m_functions2.find(p1.first); + if (it2 == m_functions2.end()) + throw cms::Exception("LHCOpticalFunctionsCollection") << "Mismatch between m_functions1 and m_functions2."; + + LHCOpticalFunctionsSet *fs = LHCOpticalFunctionsSet::interpolate(m_xangle1, p1.second, m_xangle2, it2->second, xangle); + + output.emplace(p1.first, *fs); + } +} diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc new file mode 100644 index 0000000000000..676a4e4935605 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCOpticalFunctionsCollection); diff --git a/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h new file mode 100644 index 0000000000000..0af45405f1379 --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h @@ -0,0 +1,10 @@ +#ifndef CTPPSOpticsRcd_CTPPSOpticsRcd_h +#define CTPPSOpticsRcd_CTPPSOpticsRcd_h + +// Author: Jan KaÅ¡par + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class CTPPSOpticsRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc b/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc new file mode 100644 index 0000000000000..6c39a25e99604 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc @@ -0,0 +1,6 @@ +// Author: Jan KaÅ¡par + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSOpticsRcd); From 55bf0cafa1994fe97199f0a2f63dfb8195ca5cc6 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 5 Dec 2018 20:40:01 +0100 Subject: [PATCH 095/686] Added random xi-theta gun. --- .../interface/RandomXiThetaGunProducer.h | 49 +++++++ .../src/RandomXiThetaGunProducer.cc | 125 ++++++++++++++++++ IOMC/ParticleGuns/src/SealModule.cc | 3 + 3 files changed, 177 insertions(+) create mode 100644 IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h create mode 100644 IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc diff --git a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h new file mode 100644 index 0000000000000..a2791f75f7ce1 --- /dev/null +++ b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * + ****************************************************************************/ + +#ifndef RandomXiThetaGunProducer_H +#define RandomXiThetaGunProducer_H + +#include "FWCore/Framework/interface/one/EDProducer.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Random/RandGauss.h" + +namespace edm { + +class RandomXiThetaGunProducer : public one::EDProducer<> +{ + + public: + RandomXiThetaGunProducer(const ParameterSet &); + + virtual ~RandomXiThetaGunProducer(); + + private: + virtual void produce(Event & e, const EventSetup& es) override; + + void GenerateParticle(double z_sign, double mass, unsigned int barcode, CLHEP::HepRandomEngine* engine, HepMC::GenVertex *vtx) const; + + unsigned int verbosity; + + unsigned int particleId; + + double energy; + double xi_min, xi_max; + double theta_x_mean, theta_x_sigma; + double theta_y_mean, theta_y_sigma; + + unsigned int nParticlesSector45; + unsigned int nParticlesSector56; +}; + +} + +#endif diff --git a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc new file mode 100644 index 0000000000000..634a25b53a31d --- /dev/null +++ b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc @@ -0,0 +1,125 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * + ****************************************************************************/ + +#include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "HepPDT/ParticleDataTable.hh" +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +using namespace edm; +using namespace std; + +//---------------------------------------------------------------------------------------------------- + +RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet& pset) : + verbosity(pset.getUntrackedParameter("verbosity", 0)), + + particleId(pset.getParameter("particleId")), + + energy(pset.getParameter("energy")), + xi_min(pset.getParameter("xi_min")), + xi_max(pset.getParameter("xi_max")), + theta_x_mean(pset.getParameter("theta_x_mean")), + theta_x_sigma(pset.getParameter("theta_x_sigma")), + theta_y_mean(pset.getParameter("theta_y_mean")), + theta_y_sigma(pset.getParameter("theta_y_sigma")), + + nParticlesSector45(pset.getParameter("nParticlesSector45")), + nParticlesSector56(pset.getParameter("nParticlesSector56")) +{ + produces("unsmeared"); +} + +//---------------------------------------------------------------------------------------------------- + +void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) +{ + if (verbosity) + printf("===================== %u:%llu =====================\n", e.id().run(), e.id().event()); + + // get conditions + edm::Service rng; + CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); + + ESHandle pdgTable; + es.getData(pdgTable); + + // prepare HepMC event + HepMC::GenEvent *fEvt = new HepMC::GenEvent(); + fEvt->set_event_number(e.id().event()); + + HepMC::GenVertex *vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0., 0.)); + fEvt->add_vertex(vtx); + + const HepPDT::ParticleData *pData = pdgTable->particle(HepPDT::ParticleID(particleId)); + double mass = pData->mass().value(); + + // generate particles + unsigned int barcode = 0; + + for (unsigned int i = 0; i < nParticlesSector45; i++) + { + barcode++; + GenerateParticle(+1., mass, barcode, engine, vtx); + } + + for (unsigned int i = 0; i < nParticlesSector56; i++) + { + barcode++; + GenerateParticle(-1., mass, barcode, engine, vtx); + } + + // save output + std::unique_ptr output(new HepMCProduct()) ; + output->addHepMCData(fEvt); + e.put(std::move(output), "unsmeared"); +} + +//---------------------------------------------------------------------------------------------------- + +void RandomXiThetaGunProducer::GenerateParticle(double z_sign, double mass, unsigned int barcode, + CLHEP::HepRandomEngine* engine, HepMC::GenVertex *vtx) const +{ + const double xi = CLHEP::RandFlat::shoot(engine, xi_min, xi_max); + const double theta_x = CLHEP::RandGauss::shoot(engine, theta_x_mean, theta_x_sigma); + const double theta_y = CLHEP::RandGauss::shoot(engine, theta_y_mean, theta_y_sigma); + + if (verbosity) + printf("xi = %.4f, theta_x = %E, theta_y = %E, z_sign = %.0f\n", xi, theta_x, theta_y, z_sign); + + const double cos_theta = sqrt(1. - theta_x*theta_x - theta_y*theta_y); + + const double p_nom = sqrt(energy*energy - mass*mass); + const double p = p_nom * (1. - xi); + const double e = sqrt(p*p + mass*mass); + + HepMC::FourVector momentum( + p * theta_x, + p * theta_y, + z_sign * p * cos_theta, + e + ); + + HepMC::GenParticle* particle = new HepMC::GenParticle(momentum, particleId, 1); + particle->suggest_barcode(barcode); + vtx->add_particle_out(particle); +} + +//---------------------------------------------------------------------------------------------------- + +RandomXiThetaGunProducer::~RandomXiThetaGunProducer() +{ +} diff --git a/IOMC/ParticleGuns/src/SealModule.cc b/IOMC/ParticleGuns/src/SealModule.cc index 57de81937405e..d30aa6a576746 100644 --- a/IOMC/ParticleGuns/src/SealModule.cc +++ b/IOMC/ParticleGuns/src/SealModule.cc @@ -19,6 +19,7 @@ #include "IOMC/ParticleGuns/interface/RandomtXiGunProducer.h" #include "IOMC/ParticleGuns/interface/FlatRandomPtAndDxyGunProducer.h" #include "IOMC/ParticleGuns/interface/RandomMultiParticlePGunProducer.h" +#include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" // particle gun prototypes @@ -58,3 +59,5 @@ using edm::FlatRandomPtAndDxyGunProducer; DEFINE_FWK_MODULE(FlatRandomPtAndDxyGunProducer); using edm::RandomMultiParticlePGunProducer; DEFINE_FWK_MODULE(RandomMultiParticlePGunProducer); +using edm::RandomXiThetaGunProducer; +DEFINE_FWK_MODULE(RandomXiThetaGunProducer); From f44031f8082a93685b68fdd6e554ef9c7396908b Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 5 Dec 2018 20:40:33 +0100 Subject: [PATCH 096/686] Added direct simulation. --- Validation/CTPPS/plugins/BuildFile.xml | 13 + .../plugins/CTPPSDirectProtonSimulation.cc | 469 ++++++++++++++++++ .../test/year_2016/RP_Dist_Beam_Cent.xml | 42 ++ 3 files changed, 524 insertions(+) create mode 100644 Validation/CTPPS/plugins/BuildFile.xml create mode 100644 Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc create mode 100644 Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml diff --git a/Validation/CTPPS/plugins/BuildFile.xml b/Validation/CTPPS/plugins/BuildFile.xml new file mode 100644 index 0000000000000..2057039a3d671 --- /dev/null +++ b/Validation/CTPPS/plugins/BuildFile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc new file mode 100644 index 0000000000000..803f551ff03cd --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -0,0 +1,469 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h" + +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" + +#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" +#include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h" +#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" + +#include + +#include "TMath.h" +#include "TMatrixD.h" +#include "TVectorD.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> +{ + public: + explicit CTPPSDirectProtonSimulation( const edm::ParameterSet& ); + ~CTPPSDirectProtonSimulation() {} + + static void fillDescriptions( edm::ConfigurationDescriptions& descriptions ); + + private: + virtual void produce( edm::Event&, const edm::EventSetup& ) override; + + void processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, + const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + std::vector &out_tracks, + edm::DetSetVector& out_strip_hits, + edm::DetSetVector &out_pixel_hits, + edm::DetSetVector &out_diamond_hits) const; + + static bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2 = true) + { + float tmpXlocalCoordinate = xLocalCoordinate + (79*0.1 + 0.2); + float tmpYlocalCoordinate = yLocalCoordinate + (0.15*51 + 0.3*2 + 0.15*25); + + if(tmpXlocalCoordinate<0) return false; + if(tmpYlocalCoordinate<0) return false; + int xModuleSize = 0.1*79 + 0.2*2 + 0.1*79; // mm - 100 um pitch direction + int yModuleSize; // mm - 150 um pitch direction + if (is3x2) yModuleSize = 0.15*51 + 0.3*2 + 0.15*50 + 0.3*2 + 0.15*51; + else yModuleSize = 0.15*51 + 0.3*2 + 0.15*51; + if(tmpXlocalCoordinate>xModuleSize) return false; + if(tmpYlocalCoordinate>yModuleSize) return false; + return true; + } + + // ------------ config file parameters ------------ + + /// input tag + edm::EDGetTokenT hepMCToken_; + + /// flags what output to be produced + bool produceScoringPlaneHits_; + bool produceRecHits_; + + /// simulation parameters + bool checkApertures_; + + bool useEmpiricalApertures_; + double empiricalAperture45_xi0_, empiricalAperture45_a_; + double empiricalAperture56_xi0_, empiricalAperture56_a_; + + bool produceHitsRelativeToBeam_; + bool roundToPitch_; + bool checkIsHit_; + + double pitchStrips_; ///< strip pitch in mm + double insensitiveMarginStrips_; ///< size of insensitive margin at sensor's edge facing the beam, in mm + + double pitchPixelsHor_; + double pitchPixelsVer_; + + unsigned int verbosity_; + + // ------------ internal parameters ------------ + + std::unordered_map opticalFunctions; + + /// internal variable: v position of strip 0, in mm + double stripZeroPosition_; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSDirectProtonSimulation::CTPPSDirectProtonSimulation( const edm::ParameterSet& iConfig ) : + hepMCToken_( consumes( iConfig.getParameter( "hepMCTag" ) ) ), + + produceScoringPlaneHits_( iConfig.getParameter( "produceScoringPlaneHits" ) ), + produceRecHits_( iConfig.getParameter( "produceRecHits" ) ), + + useEmpiricalApertures_( iConfig.getParameter( "useEmpiricalApertures" ) ), + empiricalAperture45_xi0_( iConfig.getParameter( "empiricalAperture45_xi0" ) ), + empiricalAperture45_a_( iConfig.getParameter( "empiricalAperture45_a" ) ), + empiricalAperture56_xi0_( iConfig.getParameter( "empiricalAperture56_xi0" ) ), + empiricalAperture56_a_( iConfig.getParameter( "empiricalAperture56_a" ) ), + + produceHitsRelativeToBeam_( iConfig.getParameter( "produceHitsRelativeToBeam" ) ), + roundToPitch_( iConfig.getParameter( "roundToPitch" ) ), + checkIsHit_( iConfig.getParameter( "checkIsHit" ) ), + + pitchStrips_( iConfig.getParameter( "pitchStrips" ) ), + insensitiveMarginStrips_( iConfig.getParameter( "insensitiveMarginStrips" ) ), + + pitchPixelsHor_( iConfig.getParameter( "pitchPixelsHor" ) ), + pitchPixelsVer_( iConfig.getParameter( "pitchPixelsVer" ) ), + + verbosity_( iConfig.getUntrackedParameter( "verbosity", 0 ) ) +{ + if (produceScoringPlaneHits_) + produces>(); + + if (produceRecHits_) + { + produces>(); + produces>(); + produces>(); + } + + // v position of strip 0 + stripZeroPosition_ = RPTopology::last_strip_to_border_dist_ + (RPTopology::no_of_strips_-1)*RPTopology::pitch_ - RPTopology::y_width_/2.; +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) +{ + // get input + edm::Handle hepmc_prod; + iEvent.getByToken(hepMCToken_, hepmc_prod); + + // get conditions + edm::ESHandle opticalFunctionCollection; + iSetup.get().get(opticalFunctionCollection); + + edm::ESHandle geometry; + iSetup.get().get(geometry); + + // make static beam parameter object + // TODO: replace with proper EventSetup mechanism + CTPPSBeamParameters beamParameters; + beamParameters.setBeamMom45(6500.); + beamParameters.setBeamMom56(6500.); + beamParameters.setHalfXangleX45(185.); + beamParameters.setHalfXangleX56(185.); + + // prepare optical functions + // TODO: proper condition (with ES watcher) + if (true) + { + opticalFunctions.clear(); + + // TODO: solve 45/56 asymmetry, also nominal/determined mismatch + opticalFunctionCollection->interpolateFunctions(beamParameters.getHalfXangleX45(), opticalFunctions); + + for (auto &p : opticalFunctions) + p.second.initializeSplines(); + } + + // prepare outputs + std::unique_ptr> pStripRecHits(new edm::DetSetVector()); + std::unique_ptr> pDiamondRecHits(new edm::DetSetVector()); + std::unique_ptr> pPixelRecHits(new edm::DetSetVector()); + + std::unique_ptr> pTracks(new std::vector()); + + // loop over event vertices + auto evt = new HepMC::GenEvent( *hepmc_prod->GetEvent() ); + for ( auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx ) + { + auto vtx = *( it_vtx ); + + // loop over outgoing particles + for ( auto it_part = vtx->particles_out_const_begin(); it_part != vtx->particles_out_const_end(); ++it_part ) + { + auto part = *( it_part ); + + // accept only stable protons + if ( part->pdg_id() != 2212 ) + continue; + + if ( part->status() != 1 && part->status() < 83 ) + continue; + + processProton(vtx, part, *geometry, beamParameters, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); + } + } + + if (produceScoringPlaneHits_) + iEvent.put(std::move(pTracks)); + + if (produceRecHits_) + { + iEvent.put(std::move(pStripRecHits)); + iEvent.put(std::move(pPixelRecHits)); + iEvent.put(std::move(pDiamondRecHits)); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, + const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + std::vector &out_tracks, edm::DetSetVector& out_strip_hits, + edm::DetSetVector &out_pixel_hits, edm::DetSetVector &out_diamond_hits) const +{ + /// xi is positive for diffractive protons, thus proton momentum p = (1-xi) * p_nom + /// horizontal component of proton momentum: p_x = th_x * (1-xi) * p_nom + + // vectors in CMS convention + const HepMC::FourVector vtx_cms = in_vtx->position(); // in mm + const HepMC::FourVector mom_cms = in_trk->momentum(); + + // transformation to LHC/TOTEM convention + HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t()); + HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t()); + + // determine the LHC arm and related parameters + unsigned int arm = 3; + double z_sign; + double beamMomentum = 0.; + double xangle = 0.; + double empiricalAperture_xi0, empiricalAperture_a; + + if (mom_lhc.z() < 0) // sector 45 + { + arm = 0; + z_sign = -1; + beamMomentum = beamParameters.getBeamMom45(); + xangle = beamParameters.getHalfXangleX45(); + empiricalAperture_xi0 = empiricalAperture45_xi0_; + empiricalAperture_a = empiricalAperture45_a_; + } else { // sector 56 + arm = 1; + z_sign = +1; + beamMomentum = beamParameters.getBeamMom56(); + xangle = beamParameters.getHalfXangleX56(); + empiricalAperture_xi0 = empiricalAperture56_xi0_; + empiricalAperture_a = empiricalAperture56_a_; + } + + // calculate kinematics for optics parametrisation + const double p = mom_lhc.rho(); + const double xi = 1. - p / beamMomentum; + const double th_x_phys = mom_lhc.x() / p; + const double th_y_phys = mom_lhc.y() / p; + const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle); + const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z()); + + if (verbosity_) + { + printf("simu: xi=%.4f, th_x=%.3E, %.3E, vtx_lhc_eff_x=%.3E, vtx_lhc_eff_y=%.3E\n", + xi, th_x_phys, th_y_phys, vtx_lhc_eff_x, vtx_lhc_eff_y); + } + + // check empirical aperture + if (useEmpiricalApertures_) + { + const double xi_th = empiricalAperture_xi0 + th_x_phys * empiricalAperture_a; + if (xi > xi_th) + return; + } + + // transport the proton into each pot/scoring plane + for (const auto &ofp : opticalFunctions) + { + CTPPSDetId rpId(ofp.first); + const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (verbosity_) + printf(" RP %u\n", rpDecId); + + // first check the arm + if (rpId.arm() != arm) + continue; + + // transport proton + LHCOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x * 1E-3, th_x_phys, vtx_lhc_eff_y * 1E-3, th_y_phys, xi }; // conversions: mm -> m + LHCOpticalFunctionsSet::Kinematics k_out; + ofp.second.transport(k_in, k_out, true); + + double b_x = k_out.x * 1E3, b_y = k_out.y * 1E3; // conversions: m -> mm + double a_x = k_out.th_x, a_y = k_out.th_y; + + // if needed, subtract beam position and angle + if (produceHitsRelativeToBeam_) + { + // determine beam position + LHCOpticalFunctionsSet::Kinematics k_be_in = { 0., 0., 0., 0., 0. }; + LHCOpticalFunctionsSet::Kinematics k_be_out; + ofp.second.transport(k_be_in, k_be_out, true); + + a_x -= k_be_out.th_x; a_y -= k_be_out.th_y; + b_x -= k_be_out.x * 1E3; b_y -= k_be_out.y * 1E3; + } + + const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E3; // conversion: m --> mm + + if (verbosity_) + { + printf(" proton transported: a_x = %.3E rad, a_y = %.3E rad, b_x = %.3f mm, b_y = %.3f mm, z = %.3f mm\n", + a_x, a_y, b_x, b_y, z_scoringPlane); + } + + // save scoring plane hit + if (produceScoringPlaneHits_) + out_tracks.emplace_back(rpId, b_x, 0., b_y, 0.); + + // stop if rec hits are not to be produced + if (!produceRecHits_) + continue; + + // loop over all sensors in the RP + for (const auto& detIdInt : geometry.getSensorsInRP(rpId)) + { + CTPPSDetId detId(detIdInt); + + // determine the track impact point (in global coordinates) + // !! this assumes that local axes (1, 0, 0) and (0, 1, 0) describe the sensor surface + CLHEP::Hep3Vector gl_o = geometry.localToGlobal(detId, CLHEP::Hep3Vector(0, 0, 0)); + CLHEP::Hep3Vector gl_a1 = geometry.localToGlobal(detId, CLHEP::Hep3Vector(1, 0, 0)) - gl_o; + CLHEP::Hep3Vector gl_a2 = geometry.localToGlobal(detId, CLHEP::Hep3Vector(0, 1, 0)) - gl_o; + + TMatrixD A(3, 3); + TVectorD B(3); + A(0, 0) = a_x; A(0, 1) = -gl_a1.x(); A(0, 2) = -gl_a2.x(); B(0) = gl_o.x() - b_x; + A(1, 0) = a_y; A(1, 1) = -gl_a1.y(); A(1, 2) = -gl_a2.y(); B(1) = gl_o.y() - b_y; + A(2, 0) = z_sign; A(2, 1) = -gl_a1.z(); A(2, 2) = -gl_a2.z(); B(2) = gl_o.z() - z_scoringPlane; + TMatrixD Ai(3, 3); + Ai = A.Invert(); + TVectorD P(3); + P = Ai * B; + + double ze = P(0); + CLHEP::Hep3Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign*ze + z_scoringPlane); + + // hit in local coordinates + CLHEP::Hep3Vector h_loc = geometry.globalToLocal(detId, h_glo); + + if (verbosity_) + { + printf("\n"); + printf(" de z = %f mm, p1 = %f mm, p2 = %f mm\n", P(0), P(1), P(2)); + printf(" h_glo: x = %f mm, y = %f mm, z = %f mm\n", h_glo.x(), h_glo.y(), h_glo.z()); + printf(" h_loc: c1 = %f mm, c2 = %f mm, c3 = %f mm\n", h_loc.x(), h_loc.y(), h_loc.z()); + } + + // strips + if (detId.subdetId() == CTPPSDetId::sdTrackingStrip) + { + double u = h_loc.x(); + double v = h_loc.y(); + + if (verbosity_ > 5) + printf(" u=%+8.4f, v=%+8.4f", u, v); + + // is it within detector? + if (checkIsHit_ && !RPTopology::IsHit(u, v, insensitiveMarginStrips_)) + { + if (verbosity_ > 5) + printf(" | no hit\n"); + continue; + } + + // round the measurement + if (roundToPitch_) + { + double m = stripZeroPosition_ - v; + signed int strip = (int) floor(m / pitchStrips_ + 0.5); + + v = stripZeroPosition_ - pitchStrips_ * strip; + + if (verbosity_ > 5) + printf(" | strip=%+4i", strip); + } + + double sigma = pitchStrips_ / sqrt(12.); + + if (verbosity_ > 5) + printf(" | m=%+8.4f, sigma=%+8.4f\n", v, sigma); + + edm::DetSet &hits = out_strip_hits.find_or_insert(detId); + hits.push_back(TotemRPRecHit(v, sigma)); + } + + // diamonds + if (detId.subdetId() == CTPPSDetId::sdTimingDiamond) + { + throw cms::Exception("CTPPSDirectProtonSimulation") << "Diamonds are not yet supported."; + } + + // pixels + if (detId.subdetId() == CTPPSDetId::sdTrackingPixel) + { + if (verbosity_) + { + CTPPSPixelDetId pixelDetId(detIdInt); + printf(" pixel plane %u: local hit x = %.3f mm, y = %.3f mm, z = %.1E mm\n", pixelDetId.plane(), h_loc.x(), h_loc.y(), h_loc.z()); + } + + if (checkIsHit_ && !isPixelHit(h_loc.x(), h_loc.y())) + continue; + + if (roundToPitch_) + { + h_loc.setX( pitchPixelsHor_ * floor(h_loc.x()/pitchPixelsHor_ + 0.5) ); + h_loc.setY( pitchPixelsVer_ * floor(h_loc.y()/pitchPixelsVer_ + 0.5) ); + } + + if (verbosity_ > 5) + printf(" hit accepted: m1 = %.3f mm, m2 = %.3f mm\n", h_loc.x(), h_loc.y()); + + const double sigmaHor = pitchPixelsHor_ / sqrt(12.); + const double sigmaVer = pitchPixelsVer_ / sqrt(12.); + + const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z()); + const LocalError le(sigmaHor, 0., sigmaVer); + + edm::DetSet &hits = out_pixel_hits.find_or_insert(detId); + hits.push_back(CTPPSPixelRecHit(lp, le)); + } + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) +{ + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault( desc ); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSDirectProtonSimulation ); diff --git a/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml b/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml new file mode 100644 index 0000000000000..f7a9a2f083eca --- /dev/null +++ b/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 29b0c965dbfac92706de022370ccab96b47df6ec Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 5 Dec 2018 22:59:22 +0100 Subject: [PATCH 097/686] Added the proton track and extra information --- DataFormats/ProtonReco/BuildFile.xml | 5 +++ .../ProtonReco/interface/ProtonTrack.h | 44 +++++++++++++++++++ DataFormats/ProtonReco/src/ProtonTrack.cc | 23 ++++++++++ DataFormats/ProtonReco/src/classes.h | 33 ++++++++++++++ DataFormats/ProtonReco/src/classes_def.xml | 23 ++++++++++ 5 files changed, 128 insertions(+) create mode 100644 DataFormats/ProtonReco/BuildFile.xml create mode 100644 DataFormats/ProtonReco/interface/ProtonTrack.h create mode 100644 DataFormats/ProtonReco/src/ProtonTrack.cc create mode 100644 DataFormats/ProtonReco/src/classes.h create mode 100644 DataFormats/ProtonReco/src/classes_def.xml diff --git a/DataFormats/ProtonReco/BuildFile.xml b/DataFormats/ProtonReco/BuildFile.xml new file mode 100644 index 0000000000000..061af954fdd84 --- /dev/null +++ b/DataFormats/ProtonReco/BuildFile.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h new file mode 100644 index 0000000000000..1085bccba226c --- /dev/null +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -0,0 +1,44 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#ifndef DataFormats_ProtonReco_ProtonTrack_h +#define DataFormats_ProtonReco_ProtonTrack_h + +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" +#include + +namespace reco +{ + class ProtonTrack : public Track + { + public: + /// Default constructor + ProtonTrack(); + /// Constructor from refit parameters, fitted vertex and direction, and longitudinal fractional momentum loss + ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& dir, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); + + /// Indices to the covariance matrix + enum struct Index : unsigned short { xi, th_x, th_y, vtx_y, num_indices }; + + /// Longitudinal fractional momentum loss + float xi() const { return xi_; } + /// Absolute uncertainty on longitudinal fractional momentum loss + float xiError() const { return error( (int)Index::xi ); } + + void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } + const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } + + private: + float xi_; ///< Longitudinal fractional momentum loss + ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track + }; +} + +#endif diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc new file mode 100644 index 0000000000000..7ce252fae322d --- /dev/null +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -0,0 +1,23 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include + +using namespace reco; + +ProtonTrack::ProtonTrack() : + xi_( 0. ) +{} + +ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& dir, float xi, const CovarianceMatrix& cov ) : + Track( chi2, ndof, vtx, dir, +1, cov ), xi_( xi ) +{} + diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h new file mode 100644 index 0000000000000..dbaffeb696661 --- /dev/null +++ b/DataFormats/ProtonReco/src/classes.h @@ -0,0 +1,33 @@ +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" + +#include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/Common/interface/View.h" +#include "DataFormats/Common/interface/Wrapper.h" + +#include +#include + +namespace DataFormats_ProtonReco +{ + struct dictionary + { + reco::ProtonTrack pt; + std::vector vec_pt; + edm::Wrapper > wrp_vec_pt; + edm::RefProd > rp_vec_pt; + edm::Ref,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > ref_vec_pt; + edm::RefVector,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > rv_vec_pt; + + reco::ProtonTrackExtra pte; + std::vector vec_pte; + edm::Wrapper > wrp_vec_pte; + edm::RefProd > rp_vec_pte; + edm::Ref,reco::ProtonTrackExtra,edm::refhelper::FindUsingAdvance,reco::ProtonTrackExtra> > ref_vec_pte; + edm::RefVector,reco::ProtonTrackExtra,edm::refhelper::FindUsingAdvance,reco::ProtonTrackExtra> > rv_vec_pte; + + std::set set_uint; + }; +} diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml new file mode 100644 index 0000000000000..438d3558741af --- /dev/null +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + From bbfa57bfd1bd8cf756d1c6c5acafdd0c2d4a7675 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:03:20 +0100 Subject: [PATCH 098/686] All 2016-test files moved to one package. --- .../python/year_2016/ctppsOpticalFunctionsESSource_cfi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename {CondFormats/CTPPSReadoutObjects => Validation/CTPPS}/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py (70%) diff --git a/CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py similarity index 70% rename from CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py rename to Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index 861621823c198..d16a84d45eccc 100644 --- a/CondFormats/CTPPSReadoutObjects/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -1,11 +1,11 @@ import FWCore.ParameterSet.Config as cms ctppsOpticalFunctionsESSource = cms.ESSource("CTPPSOpticalFunctionsESSource", - xangle1 = cms.double(185), - fileName1 = cms.FileInPath("CondFormats/CTPPSReadoutObjects/data/year_2016/optical_functions.root"), + xangle1 = cms.double(185), + fileName1 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), - xangle2 = cms.double(185), - fileName2 = cms.FileInPath("CondFormats/CTPPSReadoutObjects/data/year_2016/optical_functions.root"), + xangle2 = cms.double(185), + fileName2 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), scoringPlanes = cms.VPSet( cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-203.826) ), # RP 002 From 0831ea23218f7aaaf21b2a7e250eb866417b18a7 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:03:46 +0100 Subject: [PATCH 099/686] Added more public getters. --- .../interface/LHCOpticalFunctionsSet.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index b707b66293367..f2d602aa574b1 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -17,6 +17,9 @@ class LHCOpticalFunctionsSet { public: + /// indeces for m_fcn_values and m_splines data members + enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd }; + LHCOpticalFunctionsSet() {} /// fills m_*_values fields from a ROOT file @@ -26,6 +29,12 @@ class LHCOpticalFunctionsSet /// returns the position of the scoring plane (LHC/TOTEM convention) double getScoringPlaneZ() const { return m_z; } + + const std::vector& getXiValues() const { return m_xi_values; } + + const std::array, 16>& getFcnValues() const { return m_fcn_values; } + + const std::array, 16>& getSplines() const { return m_splines; } /// builds splines from m_*_values fields void initializeSplines(); @@ -53,8 +62,6 @@ class LHCOpticalFunctionsSet std::vector m_xi_values; - enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd }; - std::array, 16> m_fcn_values; std::array, 16> m_splines; From c9b020e00b5503ebc365eaa9327313bb1eda48e6 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:04:24 +0100 Subject: [PATCH 100/686] Added TODO notes. --- DataFormats/ProtonReco/interface/ProtonTrack.h | 15 +++++++++++++-- DataFormats/ProtonReco/src/ProtonTrack.cc | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 1085bccba226c..8ec200764b503 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -21,22 +21,33 @@ namespace reco public: /// Default constructor ProtonTrack(); - /// Constructor from refit parameters, fitted vertex and direction, and longitudinal fractional momentum loss - ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& dir, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); + + /// Constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss + ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); /// Indices to the covariance matrix + // TODO: what is num_indeces, where used ?? + // TODO: add (formally) also vtx_x ?? the base class defines dimension = 5 enum struct Index : unsigned short { xi, th_x, th_y, vtx_y, num_indices }; /// Longitudinal fractional momentum loss float xi() const { return xi_; } + /// Absolute uncertainty on longitudinal fractional momentum loss + // TODO: rename error -> uncertainty ? float xiError() const { return error( (int)Index::xi ); } void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } + // TODO: add getters for theta*_x and theta*_y, ... + // TODO: add getter for t + + // TODO: add convenience getters for the extra data (as done in reco::Track) ?? + private: float xi_; ///< Longitudinal fractional momentum loss + ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track }; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index 7ce252fae322d..bba9a48391d3c 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -17,7 +17,7 @@ ProtonTrack::ProtonTrack() : xi_( 0. ) {} -ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& dir, float xi, const CovarianceMatrix& cov ) : - Track( chi2, ndof, vtx, dir, +1, cov ), xi_( xi ) +ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov ) : + Track( chi2, ndof, vtx, momentum, +1, cov ), xi_( xi ) {} From 0b5e81f608d9307b3aaf2ca736d9566b9b8ca5ec Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:05:24 +0100 Subject: [PATCH 101/686] Added simple ES source for LHCInfo. --- Validation/CTPPS/plugins/BuildFile.xml | 3 + .../CTPPS/plugins/CTPPSLHCInfoESSource.cc | 68 +++++++++++++++++++ .../year_2016/ctppsLHCInfoESSource_cfi.py | 6 ++ 3 files changed, 77 insertions(+) create mode 100644 Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc create mode 100644 Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py diff --git a/Validation/CTPPS/plugins/BuildFile.xml b/Validation/CTPPS/plugins/BuildFile.xml index 2057039a3d671..7634b7d030415 100644 --- a/Validation/CTPPS/plugins/BuildFile.xml +++ b/Validation/CTPPS/plugins/BuildFile.xml @@ -1,12 +1,15 @@ + + + diff --git a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc new file mode 100644 index 0000000000000..977f9e62d9068 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc @@ -0,0 +1,68 @@ +// Original Author: Jan KaÅ¡par + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +//---------------------------------------------------------------------------------------------------- + +/** + * \brief Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). + **/ +class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ + public: + CTPPSLHCInfoESSource(const edm::ParameterSet &); + + ~CTPPSLHCInfoESSource() {}; + + edm::ESProducts> produce(const LHCInfoRcd &); + + private: + double m_beamEnergy; + double m_xangle; + + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : + m_beamEnergy(conf.getParameter("beamEnergy")), + m_xangle(conf.getParameter("xangle")) +{ + setWhatProduced(this); + findingRecord(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +{ + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); +} + +//---------------------------------------------------------------------------------------------------- + +edm::ESProducts> CTPPSLHCInfoESSource::produce(const LHCInfoRcd &) +{ + auto output = std::make_unique(); + + output->setEnergy(m_beamEnergy); + output->setCrossingAngle(m_xangle); + + return edm::es::products(std::move(output)); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSLHCInfoESSource); diff --git a/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py new file mode 100644 index 0000000000000..da4dfc3d864fe --- /dev/null +++ b/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", + beamEnergy = cms.double(6500), # GeV + xangle = cms.double(185) # murad +) From 6443387dc837e19ac5756878ca96a0f7287e85c1 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:07:49 +0100 Subject: [PATCH 102/686] Adde proton reconstruction package. --- RecoCTPPS/ProtonReconstruction/BuildFile.xml | 13 + .../interface/ProtonReconstructionAlgorithm.h | 83 ++++ .../plugins/BuildFile.xml | 8 + .../plugins/CTPPSProtonReconstruction.cc | 200 ++++++++++ .../src/ProtonReconstructionAlgorithm.cc | 373 ++++++++++++++++++ 5 files changed, 677 insertions(+) create mode 100644 RecoCTPPS/ProtonReconstruction/BuildFile.xml create mode 100644 RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h create mode 100644 RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml create mode 100644 RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc create mode 100644 RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc diff --git a/RecoCTPPS/ProtonReconstruction/BuildFile.xml b/RecoCTPPS/ProtonReconstruction/BuildFile.xml new file mode 100644 index 0000000000000..cd2759054145a --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/BuildFile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h new file mode 100644 index 0000000000000..af361a3f78965 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + ****************************************************************************/ + +#ifndef RecoCTPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h +#define RecoCTPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include "TSpline.h" +#include "Fit/Fitter.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class ProtonReconstructionAlgorithm +{ + public: + ProtonReconstructionAlgorithm(bool fit_vtx_y, unsigned int verbosity); + + ~ProtonReconstructionAlgorithm() {} + + /// runs proton reconstruction using single-RP strategy + void reconstructFromSingleRP(const std::vector &input, + std::vector &output, const LHCInfo &lhcInfo) const; + + /// runs proton reconstruction using multiple-RP strategy + void reconstructFromMultiRP(const std::vector &input, + std::vector &output, const LHCInfo &lhcInfo) const; + + void init(const std::unordered_map &opticalFunctions); + + void release(); + + private: + unsigned int verbosity_; + + bool fitVtxY_; + + bool initialized_; + + /// optics data associated with 1 RP + struct RPOpticsData + { + const LHCOpticalFunctionsSet *optics; + std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; + double x0, y0; // beam position, m + double ch0, ch1; // linear approximation (intercept and slope) of x(xi) + double la0, la1; // linear approximation (intercept and slope) of L_x(xi) + }; + + /// map: RP id --> optics data + std::map m_rp_optics_; + + /// class for calculation of chi^2 + class ChiSquareCalculator + { + public: + ChiSquareCalculator() {} + + double operator() (const double *parameters) const; + + const std::vector *tracks_; + const std::map *m_rp_optics_; + }; + + /// fitter object + std::unique_ptr fitter_; + + /// object to calculate chi^2 + std::unique_ptr chiSquareCalculator_; +}; + +#endif diff --git a/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml b/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml new file mode 100644 index 0000000000000..2573f06b47d48 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc new file mode 100644 index 0000000000000..9029bad9c9ae0 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -0,0 +1,200 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstruction : public edm::stream::EDProducer<> +{ + public: + explicit CTPPSProtonReconstruction(const edm::ParameterSet&); + ~CTPPSProtonReconstruction() {} + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + edm::EDGetTokenT< std::vector > tracksToken_; + + unsigned int verbosity_; + + bool doSingleRPReconstruction_; + bool doMultiRPReconstruction_; + + ProtonReconstructionAlgorithm algorithm_; + + edm::ESWatcher lhcInfoWatcher_; + float currentCrossingAngle_; + + std::unordered_map opticalFunctions_; + + const std::string singleRPLabel = "singleRP"; + const std::string multiRPLabel = "multiRP"; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iConfig) : + tracksToken_(consumes< std::vector >(iConfig.getParameter("tagLocalTrackLite"))), + verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), + doMultiRPReconstruction_(iConfig.getParameter("doMultiRPReconstruction")), + algorithm_(iConfig.getParameter("fitVtxY"), verbosity_), + currentCrossingAngle_(-1.) +{ + if (doSingleRPReconstruction_) + produces>(singleRPLabel); + + if (doMultiRPReconstruction_) + produces>(multiRPLabel); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& descriptions) +{ + ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSetup) +{ + if (verbosity_) + printf("\n---------- %u:%llu ----------\n", event.id().run(), event.id().event()); + + // get conditions + edm::ESHandle hLHCInfo; + eventSetup.get().get(hLHCInfo); + + edm::ESHandle hOpticalFunctionCollection; + eventSetup.get().get(hOpticalFunctionCollection); + + // re-initialise algorithm upon crossing-angle change + if (lhcInfoWatcher_.check(eventSetup)) + { + const LHCInfo* pLHCInfo = hLHCInfo.product(); + if (pLHCInfo->crossingAngle() != currentCrossingAngle_) + { + currentCrossingAngle_ = pLHCInfo->crossingAngle(); + + if (currentCrossingAngle_ == 0.) + { + LogWarning("CTPPSProtonReconstruction") << "Invalid crossing angle, reconstruction disabled."; + algorithm_.release(); + } + + if (verbosity_) + printf("CTPPSProtonReconstruction::produce >> Setting crossing angle %.1f\n", currentCrossingAngle_); + + // interpolate optical functions + opticalFunctions_.clear(); + hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); + for (auto &p : opticalFunctions_) + p.second.initializeSplines(); + + // reinitialise algorithm + algorithm_.init(opticalFunctions_); + } + } + + // get input + Handle> hTracks; + event.getByToken(tracksToken_, hTracks); + + // keep only tracks from tracker RPs, split them by LHC sector + vector tracks_45, tracks_56; + map nTracksPerRP; + for (const auto &tr : *hTracks) + { + CTPPSDetId rpId(tr.getRPId()); + if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) + continue; + + if (verbosity_) + { + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + printf("%u (%u): x=%.3f, y=%.3f mm\n", tr.getRPId(), decRPId, tr.getX(), tr.getY()); + } + + if (rpId.arm() == 0) + tracks_45.push_back(&tr); + if (rpId.arm() == 1) + tracks_56.push_back(&tr); + + nTracksPerRP[tr.getRPId()]++; + } + + // for the moment: check whether there is no more than 1 track in each arm + bool singleTrack_45 = true, singleTrack_56 = true; + for (const auto &p : nTracksPerRP) + { + if (p.second > 1) + { + CTPPSDetId rpId(p.first); + if (rpId.arm() == 0) + singleTrack_45 = false; + if (rpId.arm() == 1) + singleTrack_56 = false; + } + } + + // single-RP reconstruction + if (doSingleRPReconstruction_) + { + unique_ptr> output(new vector); + + algorithm_.reconstructFromSingleRP(tracks_45, *output, *hLHCInfo); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *hLHCInfo); + + event.put(move(output), singleRPLabel); + } + + // multi-RP reconstruction + if (doMultiRPReconstruction_) + { + unique_ptr> output(new vector); + + if (singleTrack_45) + algorithm_.reconstructFromMultiRP(tracks_45, *output, *hLHCInfo); + if (singleTrack_56) + algorithm_.reconstructFromMultiRP(tracks_56, *output, *hLHCInfo); + + event.put(move(output), multiRPLabel); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstruction); diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc new file mode 100644 index 0000000000000..c7aac2b4b91ad --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -0,0 +1,373 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" + +#include "TF1.h" + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, unsigned int verbosity) : + verbosity_(verbosity), + fitVtxY_(fit_vtx_y), + initialized_(false), + fitter_(std::make_unique()), + chiSquareCalculator_(std::make_unique()) +{ + // initialise fitter + double pStart[] = { 0, 0, 0, 0 }; + fitter_->SetFCN(4, *chiSquareCalculator_, pStart, 0, true); +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::init(const std::unordered_map &opticalFunctions) +{ + // reset cache + release(); + + // prepare helper objects + unique_ptr ff(new TF1("ff", "[0] + [1]*x")); + + // build optics data for each object + for (const auto &p : opticalFunctions) + { + const LHCOpticalFunctionsSet &ofs = p.second; + + // make record + RPOpticsData rpod; + rpod.optics = &p.second; + rpod.s_xi_vs_x_d = make_shared("", + (double *) ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data(), + (double *) ofs.getXiValues().data(), ofs.getXiValues().size()); + rpod.s_y_d_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eyd]; + rpod.s_v_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::evy]; + rpod.s_L_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eLy]; + + // calculate auxiliary data + LHCOpticalFunctionsSet::Kinematics k_in = { 0., 0., 0., 0., 0. }; + LHCOpticalFunctionsSet::Kinematics k_out; + rpod.optics->transport(k_in, k_out); + rpod.x0 = k_out.x; + rpod.y0 = k_out.y; + + unique_ptr g_x_d_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), + ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data()); + ff->SetParameters(0., 0.); + g_x_d_vs_xi->Fit(ff.get(), "Q"); + g_x_d_vs_xi->Fit(ff.get(), "Q"); + g_x_d_vs_xi->Fit(ff.get(), "Q"); + rpod.ch0 = ff->GetParameter(0) - rpod.x0; + rpod.ch1 = ff->GetParameter(1); + + unique_ptr g_L_x_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), + ofs.getFcnValues()[LHCOpticalFunctionsSet::eLx].data()); + ff->SetParameters(0., 0.); + g_L_x_vs_xi->Fit(ff.get(), "Q"); + g_L_x_vs_xi->Fit(ff.get(), "Q"); + g_L_x_vs_xi->Fit(ff.get(), "Q"); + rpod.la0 = ff->GetParameter(0); + rpod.la1 = ff->GetParameter(1); + + // insert record + const CTPPSDetId rpId(p.first); + m_rp_optics_.emplace(rpId, std::move(rpod)); + } + + // update settings + initialized_ = true; +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::release() +{ + initialized_ = false; + + m_rp_optics_.clear(); +} + +//---------------------------------------------------------------------------------------------------- + +double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const double* parameters) const +{ + // extract proton parameters + const LHCOpticalFunctionsSet::Kinematics k_in = { 0., parameters[1], parameters[3], parameters[2], parameters[0] }; + + // calculate chi^2 by looping over hits + double S2 = 0.; + + for (const auto &track : *tracks_) + { + const CTPPSDetId rpId(track->getRPId()); + + // transport proton to the RP + auto oit = m_rp_optics_->find(rpId); + LHCOpticalFunctionsSet::Kinematics k_out; + oit->second.optics->transport(k_in, k_out); + + // proton position wrt. beam + const double& x = k_out.x - oit->second.x0; + const double& y = k_out.y - oit->second.y0; + + // make sure that uncertainties are reasonable + double x_unc = track->getXUnc(); + if (x_unc < 1E-3) + x_unc = 40E-3; + + double y_unc = track->getYUnc(); + if (y_unc < 1E-3) + y_unc = 40E-3; + + // calculate chi^2 contributions, convert track data mm --> m + const double x_diff_norm = (x - track->getX()*1E-3) / (x_unc*1E-3); + const double y_diff_norm = (y - track->getY()*1E-3) / (y_unc*1E-3); + + // increase chi^2 + S2 += x_diff_norm*x_diff_norm + y_diff_norm*y_diff_norm; + } + + return S2; +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const vector &tracks, + vector &out, const LHCInfo &lhcInfo) const +{ + if (!initialized_) + return; + + // need at least two tracks + if (tracks.size() < 2) + return; + + // make sure optics is available for all tracks + for (const auto &it : tracks) + { + auto oit = m_rp_optics_.find(it->getRPId()); + if (oit == m_rp_optics_.end()) + throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << + it->getRPId() << ", i.e. " << CTPPSDetId(it->getRPId()) << "."; + } + + // initial estimate of xi and th_x + double xi_init = 0., th_x_init = 0.; + + const bool use_improved_estimate = true; + if (use_improved_estimate) + { + double x_N = 0., x_F = 0.; + const RPOpticsData *i_N = NULL, *i_F = NULL; + unsigned int idx = 0; + for (const auto &track : tracks) + { + auto oit = m_rp_optics_.find(track->getRPId()); + + if (idx == 0) { x_N = track->getX() * 1E-3; i_N = &oit->second; } + if (idx == 1) { x_F = track->getX() * 1E-3; i_F = &oit->second; } + if (idx == 2) break; + + idx++; + } + + const double a = i_F->ch1*i_N->la1 - i_N->ch1*i_F->la1; + const double b = i_F->ch0*i_N->la1 - i_N->ch0*i_F->la1 + i_F->ch1*i_N->la0 - i_N->ch1*i_F->la0 + x_N*i_F->la1 - x_F*i_N->la1; + const double c = x_N*i_F->la0 - x_F*i_N->la0 + i_F->ch0*i_N->la0 - i_N->ch0*i_F->la0; + const double D = b*b - 4.*a*c; + + xi_init = (-b + sqrt(D)) / 2. / a; + th_x_init = (x_N - i_N->ch0 - i_N->ch1 * xi_init) / (i_N->la0 + i_N->la1 * xi_init); + } else { + double S_xi0 = 0., S_1 = 0.; + for (const auto &track : tracks) + { + auto oit = m_rp_optics_.find(track->getRPId()); + double xi = oit->second.s_xi_vs_x_d->Eval(track->getX() * 1E-3 + oit->second.x0); // conversion: mm --> m + + S_1 += 1.; + S_xi0 += xi; + } + + xi_init = S_xi0 / S_1; + } + + // initial estimate of th_y and vtx_y + double y[2], v_y[2], L_y[2]; + unsigned int y_idx = 0; + for (const auto &track : tracks) + { + if (y_idx >= 2) + continue; + + auto oit = m_rp_optics_.find(track->getRPId()); + + y[y_idx] = track->getY()*1E-3 - oit->second.s_y_d_vs_xi->Eval(xi_init); // track y: mm --> m + v_y[y_idx] = oit->second.s_v_y_vs_xi->Eval(xi_init); + L_y[y_idx] = oit->second.s_L_y_vs_xi->Eval(xi_init); + + y_idx++; + } + + double vtx_y_init = 0.; + double th_y_init = 0.; + + if (fitVtxY_) + { + const double det_y = v_y[0] * L_y[1] - L_y[0] * v_y[1]; + vtx_y_init = (L_y[1] * y[0] - L_y[0] * y[1]) / det_y; + th_y_init = (v_y[0] * y[1] - v_y[1] * y[0]) / det_y; + } else { + vtx_y_init = 0.; + th_y_init = (y[1]/L_y[1] + y[0]/L_y[0]) / 2.; + } + + if (verbosity_) + { + unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); + printf("* ProtonReconstructionAlgorithm::reconstructFromMultiRP(%u)\n", armId); + printf(" initial estimate: xi_init = %f, th_x_init = %E, th_y_init = %E, vtx_y_init = %E\n", xi_init, th_x_init, th_y_init, vtx_y_init); + } + + // minimisation + fitter_->Config().ParSettings(0).Set("xi", xi_init, 0.005); + fitter_->Config().ParSettings(1).Set("th_x", th_x_init, 2E-6); + fitter_->Config().ParSettings(2).Set("th_y", th_y_init, 2E-6); + fitter_->Config().ParSettings(3).Set("vtx_y", vtx_y_init, 10E-6); + + if (!fitVtxY_) + fitter_->Config().ParSettings(3).Fix(); + + chiSquareCalculator_->tracks_ = &tracks; + chiSquareCalculator_->m_rp_optics_ = &m_rp_optics_; + + fitter_->FitFCN(); + fitter_->FitFCN(); // second minimisation in case the first one had troubles + + // extract proton parameters + const ROOT::Fit::FitResult& result = fitter_->Result(); + const double *params = result.GetParams(); + + if (verbosity_) + edm::LogInfo("ProtonReconstructionAlgorithm") + << "at reconstructed level: " + << "xi=" << params[0] << ", " + << "theta_x=" << params[1] << ", " + << "theta_y=" << params[2] << ", " + << "vertex_y=" << params[3] << "\n"; + + if (verbosity_) + printf(" fit: xi = %f, th_x = %E, th_y = %E, vtx_y = %E, chiSq = %.0f\n", params[0], params[1], params[2], params[3], result.Chi2()); + + // save reco candidate + reco::ProtonTrack pt; + // TODO + /* + pt.method = reco::ProtonTrack::rmMultiRP; + pt.halfCrossingAngleSector45 = halfCrossingAngleSector45_; + pt.halfCrossingAngleSector56 = halfCrossingAngleSector56_; + + pt.fitChiSq = result.Chi2(); + pt.fitNDF = 2.*tracks.size() - ((fitVtxY_) ? 4. : 3.); + pt.lhcSector = (CTPPSDetId(tracks[0]->getRPId()).arm() == 0) ? reco::ProtonTrack::sector45 : reco::ProtonTrack::sector56; + + pt.setVertex(Local3DPoint(0., params[3]*1E3, 0.)); // vertext in mm + + const double p_nom = 6500.; // GeV + const double p = p_nom * (1. - params[0]); + const double th_x = params[1]; + const double th_y = params[2]; + const double cos_th = sqrt(1. - th_x*th_x - th_y*th_y); + const double sign_z_lhc = (pt.lhcSector == reco::ProtonTrack::sector45) ? -1. : +1.; + + pt.setXi(params[0]); + + pt.setDirection(Local3DVector( + - p * th_x, // the signs reflect change LHC --> CMS convention + + p * th_y, + - sign_z_lhc * p * cos_th + )); + + for (const auto &track : tracks) + pt.contributingRPIds.insert(track->getRPId()); + + const double max_chi_sq = 2.; + + const bool valid = result.IsValid() && pt.fitChiSq < max_chi_sq; + pt.setValid(valid); + + if (verbosity && !valid) + printf("WARNING: invalid proton-reconstruction fit (result.IsValid = %u, fitChiSq = %.2E).\n", result.IsValid(), pt.fitChiSq); + */ + + out.push_back(move(pt)); +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const vector &tracks, + vector &out, const LHCInfo &lhcInfo) const +{ + if (!initialized_) + return; + + // make sure optics is available for all tracks + for (const auto &it : tracks) + { + auto oit = m_rp_optics_.find(it->getRPId()); + if (oit == m_rp_optics_.end()) + throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << it->getRPId() + << ", i.e. " << CTPPSDetId(it->getRPId()) << "."; + } + + // rough estimate of xi and th_y from each track + for (const auto &track : tracks) + { + CTPPSDetId rpId(track->getRPId()); + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (verbosity_) + printf("* reconstructFromSingleRP(%u)\n", decRPId); + + auto oit = m_rp_optics_.find(track->getRPId()); + const double xi = oit->second.s_xi_vs_x_d->Eval(track->getX() * 1E-3 + oit->second.x0); // conversions mm --> m + const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); + const double th_y = track->getY() * 1E-3 / L_y; + + if (verbosity_) + printf(" xi = %f, th_y = %E\n", xi, th_y); + + using ex = reco::ProtonTrackExtra; + + // save proton candidate + auto lhcSector = (CTPPSDetId(track->getRPId()).arm() == 0) ? ex::LHCSector::sector45 : ex::LHCSector::sector56; + ex::RPList rpList; + rpList.insert(track->getRPId()); + reco::ProtonTrackExtra ptExtra(true, ex::ReconstructionMethod::singleRP, lhcSector, rpList); + + const double sign_z_lhc = (lhcSector == ex::LHCSector::sector45) ? -1. : +1.; + const reco::Track::Point vtx(0., 0., 0.); + const reco::Track::Vector direction(0., th_y, - sign_z_lhc); + const double p = lhcInfo.energy() * (1. - xi); + reco::ProtonTrack pt(0., 0, vtx, p * direction, xi); // TODO: covariance matrix + + // TODO: fix this + //pt.setProtonTrackExtra(ptExtra); + + out.push_back(move(pt)); + } +} From a09cc1c26b3e7483f1295c47036cbb0423459fa0 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 7 Dec 2018 22:08:40 +0100 Subject: [PATCH 103/686] Proton reconstruction added to the standard PPS sequence. --- RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index c93527b436767..e8e81f2ac17ed 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -3,9 +3,12 @@ from RecoCTPPS.TotemRPLocal.totemRPLocalReconstruction_cff import * from RecoCTPPS.TotemRPLocal.ctppsDiamondLocalReconstruction_cff import * from RecoCTPPS.TotemRPLocal.totemTimingLocalReconstruction_cff import * -from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer from RecoCTPPS.PixelLocal.ctppsPixelLocalReconstruction_cff import * +from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer + +from RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi import * + from CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring("Alignment/CTPPS/data/RPixGeometryCorrections.xml") @@ -14,5 +17,6 @@ ctppsDiamondLocalReconstruction * totemTimingLocalReconstruction * ctppsPixelLocalReconstruction * - ctppsLocalTrackLiteProducer + ctppsLocalTrackLiteProducer * + ctppsProtonReconstruction ) From 572b48d0992cc5d48e9e5d7708a87728fa8b88f7 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:41:58 +0100 Subject: [PATCH 104/686] Added getter methods, vector of refs to lite local tracks, etc. --- DataFormats/ProtonReco/BuildFile.xml | 1 + .../ProtonReco/interface/ProtonTrack.h | 55 ++++++++++++++----- DataFormats/ProtonReco/src/ProtonTrack.cc | 18 +++++- DataFormats/ProtonReco/src/classes_def.xml | 4 +- 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/DataFormats/ProtonReco/BuildFile.xml b/DataFormats/ProtonReco/BuildFile.xml index 061af954fdd84..a54f5cfdd9083 100644 --- a/DataFormats/ProtonReco/BuildFile.xml +++ b/DataFormats/ProtonReco/BuildFile.xml @@ -1,5 +1,6 @@ + diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 8ec200764b503..593bcab21022d 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -1,18 +1,15 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software. * Authors: * Jan KaÅ¡par * Laurent Forthomme - * ****************************************************************************/ #ifndef DataFormats_ProtonReco_ProtonTrack_h #define DataFormats_ProtonReco_ProtonTrack_h #include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" #include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" -#include namespace reco { @@ -26,27 +23,55 @@ namespace reco ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); /// Indices to the covariance matrix - // TODO: what is num_indeces, where used ?? - // TODO: add (formally) also vtx_x ?? the base class defines dimension = 5 - enum struct Index : unsigned short { xi, th_x, th_y, vtx_y, num_indices }; + enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices }; /// Longitudinal fractional momentum loss float xi() const { return xi_; } - /// Absolute uncertainty on longitudinal fractional momentum loss - // TODO: rename error -> uncertainty ? + /// vertical scattering angle, in rad + float thetaX() const { return px() / p(); } + + /// horizontal scattering angle, in rad + float thetaY() const { return py() / p(); } + + // vertex position can be obtained via TrackBase::vx() and vy() functions + + static float calculateT(double beam_mom, double proton_mom, double theta); + + /// four-momentum transfer squared, in GeV^2 + float t() const; + float xiError() const { return error( (int)Index::xi ); } - void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } - const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } + float thetaXError() const { return error( (int)Index::th_x ); } + + float thetaYError() const { return error( (int)Index::th_y ); } - // TODO: add getters for theta*_x and theta*_y, ... - // TODO: add getter for t + float vertexXError() const { return error( (int)Index::vtx_x ); } - // TODO: add convenience getters for the extra data (as done in reco::Track) ?? + float vertexYError() const { return error( (int)Index::vtx_y ); } + + /// LHC sector + enum class LHCSector { invalid = -1, sector45, sector56 }; + LHCSector lhcSector() const + { + if (pz() < 0.) return LHCSector::sector56; + if (pz() > 0.) return LHCSector::sector45; + return LHCSector::invalid; + } + + // convenience getters for the extra information + bool validFit() const { return pt_extra_->validFit(); } + + ProtonTrackExtra::ReconstructionMethod method() const { return pt_extra_->method(); } + + const ProtonTrackExtra::CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return pt_extra_->contributingLocalTracks(); } + + void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } + const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } private: - float xi_; ///< Longitudinal fractional momentum loss + float xi_; ///< fractional momentum loss (positive for diffractive protons) ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track }; diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index bba9a48391d3c..acbab7f2d5f35 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -1,10 +1,7 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software. * Authors: * Jan KaÅ¡par * Laurent Forthomme - * ****************************************************************************/ #include "DataFormats/ProtonReco/interface/ProtonTrack.h" @@ -21,3 +18,18 @@ ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vect Track( chi2, ndof, vtx, momentum, +1, cov ), xi_( xi ) {} +float ProtonTrack::calculateT(double beam_mom, double proton_mom, double theta) +{ + const double m = 0.938; // GeV + + const double t0 = 2.*m*m + 2.*beam_mom*proton_mom - 2.*sqrt( (m*m + beam_mom*beam_mom) * (m*m + proton_mom*proton_mom) ); + const double S = sin(theta/2.); + return t0 - 4. * beam_mom * proton_mom * S*S; +} + +float ProtonTrack::t() const +{ + const double beam_mom = p() / (1.-xi()); + const double theta = sqrt(thetaX()*thetaX() + thetaY()*thetaY()); + return calculateT(beam_mom, p(), theta); +} diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index 438d3558741af..9e7b65051cae6 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -9,8 +9,7 @@ - - + @@ -19,5 +18,4 @@ - From aae8914e80569381bef2deca0830bbf3062316d1 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:42:57 +0100 Subject: [PATCH 105/686] Proton track (and extra) entirely filled. --- .../interface/ProtonReconstructionAlgorithm.h | 15 ++- .../plugins/CTPPSProtonReconstruction.cc | 38 ++++-- .../src/ProtonReconstructionAlgorithm.cc | 125 ++++++++++-------- 3 files changed, 112 insertions(+), 66 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index af361a3f78965..a3979972eb480 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -11,6 +11,7 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" @@ -30,12 +31,16 @@ class ProtonReconstructionAlgorithm ~ProtonReconstructionAlgorithm() {} /// runs proton reconstruction using single-RP strategy - void reconstructFromSingleRP(const std::vector &input, - std::vector &output, const LHCInfo &lhcInfo) const; + void reconstructFromSingleRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, + std::vector &output, + std::vector &outputExtra, + const LHCInfo &lhcInfo) const; /// runs proton reconstruction using multiple-RP strategy - void reconstructFromMultiRP(const std::vector &input, - std::vector &output, const LHCInfo &lhcInfo) const; + void reconstructFromMultiRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, + std::vector &output, + std::vector &outputExtra, + const LHCInfo &lhcInfo) const; void init(const std::unordered_map &opticalFunctions); @@ -69,7 +74,7 @@ class ProtonReconstructionAlgorithm double operator() (const double *parameters) const; - const std::vector *tracks_; + const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector *tracks_; const std::map *m_rp_optics_; }; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 9029bad9c9ae0..d84fa1d624ddf 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -72,16 +72,25 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC currentCrossingAngle_(-1.) { if (doSingleRPReconstruction_) + { produces>(singleRPLabel); + produces>(singleRPLabel); + } if (doMultiRPReconstruction_) + { produces>(multiRPLabel); + produces>(multiRPLabel); + } } //---------------------------------------------------------------------------------------------------- void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& descriptions) { + // TODO: fill in + // TODO: then remove the static cfi file + ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); @@ -134,10 +143,11 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector - vector tracks_45, tracks_56; + reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; map nTracksPerRP; - for (const auto &tr : *hTracks) + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { + const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; CTPPSDetId rpId(tr.getRPId()); if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) continue; @@ -149,9 +159,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } if (rpId.arm() == 0) - tracks_45.push_back(&tr); + tracks_45.emplace_back(hTracks, idx); if (rpId.arm() == 1) - tracks_56.push_back(&tr); + tracks_56.emplace_back(hTracks, idx); nTracksPerRP[tr.getRPId()]++; } @@ -174,10 +184,16 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (doSingleRPReconstruction_) { unique_ptr> output(new vector); + unique_ptr> outputExtra(new vector); + + algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *hLHCInfo); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *hLHCInfo); + auto ohExtra = event.put(move(outputExtra), singleRPLabel); + for (unsigned int i = 0; i < output->size(); ++i) + (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); + event.put(move(output), singleRPLabel); } @@ -185,11 +201,17 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (doMultiRPReconstruction_) { unique_ptr> output(new vector); + unique_ptr> outputExtra(new vector); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo); + + auto ohExtra = event.put(move(outputExtra), multiRPLabel); + + for (unsigned int i = 0; i < output->size(); ++i) + (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); event.put(move(output), multiRPLabel); } diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index c7aac2b4b91ad..625d86eea2789 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -1,10 +1,7 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software. * Authors: * Jan KaÅ¡par * Laurent Forthomme - * ****************************************************************************/ #include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" @@ -146,8 +143,11 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const vector &tracks, - vector &out, const LHCInfo &lhcInfo) const +void ProtonReconstructionAlgorithm::reconstructFromMultiRP( + const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, + std::vector &output, + std::vector &outputExtra, + const LHCInfo &lhcInfo) const { if (!initialized_) return; @@ -236,9 +236,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const vectorgetRPId()).arm(); + if (verbosity_) { - unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); printf("* ProtonReconstructionAlgorithm::reconstructFromMultiRP(%u)\n", armId); printf(" initial estimate: xi_init = %f, th_x_init = %E, th_y_init = %E, vtx_y_init = %E\n", xi_init, th_x_init, th_y_init, vtx_y_init); } @@ -274,53 +275,59 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const vectorgetRPId()).arm() == 0) ? reco::ProtonTrack::sector45 : reco::ProtonTrack::sector56; + using EX = reco::ProtonTrackExtra; + using PT = reco::ProtonTrack; - pt.setVertex(Local3DPoint(0., params[3]*1E3, 0.)); // vertext in mm + reco::ProtonTrackExtra ptExtra(result.IsValid(), EX::ReconstructionMethod::multiRP, tracks); - const double p_nom = 6500.; // GeV - const double p = p_nom * (1. - params[0]); + const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention + const reco::Track::Point vertex(0., params[3]*1E2, 0.); // vertex in cm + const double xi = params[0]; const double th_x = params[1]; const double th_y = params[2]; const double cos_th = sqrt(1. - th_x*th_x - th_y*th_y); - const double sign_z_lhc = (pt.lhcSector == reco::ProtonTrack::sector45) ? -1. : +1.; - - pt.setXi(params[0]); - - pt.setDirection(Local3DVector( + const double p = lhcInfo.energy() * (1. - xi); + const reco::Track::Vector momentum( - p * th_x, // the signs reflect change LHC --> CMS convention + p * th_y, - - sign_z_lhc * p * cos_th - )); - - for (const auto &track : tracks) - pt.contributingRPIds.insert(track->getRPId()); + sign_z * p * cos_th + ); + signed int ndf = 2.*tracks.size() - ((fitVtxY_) ? 4. : 3.); + + map index_map = { + {(unsigned int) reco::ProtonTrack::Index::xi, 0}, + {(unsigned int) reco::ProtonTrack::Index::th_x, 1}, + {(unsigned int) reco::ProtonTrack::Index::th_y, 2}, + {(unsigned int) reco::ProtonTrack::Index::vtx_y, ((fitVtxY_) ? 3 : -1)}, + {(unsigned int) reco::ProtonTrack::Index::vtx_x, -1}, + }; + + reco::TrackBase::CovarianceMatrix cm; + for (unsigned int i = 0; i < (unsigned int) reco::ProtonTrack::Index::num_indices; ++i) + { + signed int fit_i = index_map[i]; - const double max_chi_sq = 2.; + for (unsigned int j = 0; j < (unsigned int) reco::ProtonTrack::Index::num_indices; ++j) + { + signed int fit_j = index_map[j]; - const bool valid = result.IsValid() && pt.fitChiSq < max_chi_sq; - pt.setValid(valid); + cm(i, j) = (fit_i >= 0 && fit_j >= 0) ? result.CovMatrix(fit_i, fit_j) : 0.; + } + } - if (verbosity && !valid) - printf("WARNING: invalid proton-reconstruction fit (result.IsValid = %u, fitChiSq = %.2E).\n", result.IsValid(), pt.fitChiSq); - */ + reco::ProtonTrack pt(result.Chi2(), ndf, vertex, momentum, xi, cm); - out.push_back(move(pt)); + output.push_back(move(pt)); + outputExtra.push_back(move(ptExtra)); } //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const vector &tracks, - vector &out, const LHCInfo &lhcInfo) const +void ProtonReconstructionAlgorithm::reconstructFromSingleRP( + const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, + std::vector &output, + std::vector &outputExtra, + const LHCInfo &lhcInfo) const { if (!initialized_) return; @@ -344,30 +351,42 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const vectorgetRPId()); - const double xi = oit->second.s_xi_vs_x_d->Eval(track->getX() * 1E-3 + oit->second.x0); // conversions mm --> m + const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m + const double xi = oit->second.s_xi_vs_x_d->Eval(x_full); const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); const double th_y = track->getY() * 1E-3 / L_y; + const double ep_x = 1E-6; + const double dxi_dx = (oit->second.s_xi_vs_x_d->Eval(x_full + ep_x) - xi) / ep_x; + const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-3; + + const double ep_xi = 1E-4; + const double dL_y_dxi = ( oit->second.s_L_y_vs_xi->Eval(xi + ep_xi) - L_y ) / ep_xi; + const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); + if (verbosity_) - printf(" xi = %f, th_y = %E\n", xi, th_y); + printf(" xi = %f +- %f, th_y = %E +- %E\n", xi, xi_unc, th_y, th_y_unc); - using ex = reco::ProtonTrackExtra; + using EX = reco::ProtonTrackExtra; + using PT = reco::ProtonTrack; // save proton candidate - auto lhcSector = (CTPPSDetId(track->getRPId()).arm() == 0) ? ex::LHCSector::sector45 : ex::LHCSector::sector56; - ex::RPList rpList; - rpList.insert(track->getRPId()); - reco::ProtonTrackExtra ptExtra(true, ex::ReconstructionMethod::singleRP, lhcSector, rpList); - - const double sign_z_lhc = (lhcSector == ex::LHCSector::sector45) ? -1. : +1.; - const reco::Track::Point vtx(0., 0., 0.); - const reco::Track::Vector direction(0., th_y, - sign_z_lhc); + const bool valid = true; + reco::ProtonTrackExtra ptExtra(valid, EX::ReconstructionMethod::singleRP, { track }); + + const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention + const reco::Track::Point vertex(0., 0., 0.); + const double cos_th = sqrt(1. - th_y*th_y); const double p = lhcInfo.energy() * (1. - xi); - reco::ProtonTrack pt(0., 0, vtx, p * direction, xi); // TODO: covariance matrix + const reco::Track::Vector momentum(0., p * th_y, sign_z * p * cos_th); + + reco::TrackBase::CovarianceMatrix cm; + cm((int)PT::Index::xi, (int)PT::Index::xi) = xi_unc * xi_unc; + cm((int)PT::Index::th_y, (int)PT::Index::th_y) = th_y_unc * th_y_unc; - // TODO: fix this - //pt.setProtonTrackExtra(ptExtra); + reco::ProtonTrack pt(0., 0, vertex, momentum, xi, cm); - out.push_back(move(pt)); + output.push_back(move(pt)); + outputExtra.push_back(move(ptExtra)); } } From 1d18b0139eafa73d8d2a7b6b888c0dc8d5b7eeed Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:44:27 +0100 Subject: [PATCH 106/686] Added beam-divergence and vertex generator. --- IOMC/EventVertexGenerators/BuildFile.xml | 1 + .../src/BeamDivergenceVtxGenerator.cc | 111 ++++++++++++++++++ IOMC/EventVertexGenerators/src/module.cc | 2 + 3 files changed, 114 insertions(+) create mode 100644 IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc diff --git a/IOMC/EventVertexGenerators/BuildFile.xml b/IOMC/EventVertexGenerators/BuildFile.xml index f82b4ec179900..86b4a6e9eef6e 100644 --- a/IOMC/EventVertexGenerators/BuildFile.xml +++ b/IOMC/EventVertexGenerators/BuildFile.xml @@ -10,4 +10,5 @@ + diff --git a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc new file mode 100644 index 0000000000000..524f3a1b52cad --- /dev/null +++ b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc @@ -0,0 +1,111 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + ****************************************************************************/ + +#include "IOMC/EventVertexGenerators/interface/BeamDivergenceVtxGenerator.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +BeamDivergenceVtxGenerator::BeamDivergenceVtxGenerator(const edm::ParameterSet& iConfig) : + sourceToken_( consumes( iConfig.getParameter( "src" ) ) ), + + simulateVertex_ ( iConfig.getParameter( "simulateVertex" ) ), + simulateBeamDivergence_ ( iConfig.getParameter( "simulateBeamDivergence" ) ) +{ + edm::Service rng; + if ( !rng.isAvailable() ) + { + throw cms::Exception("Configuration") + << "The BeamDivergenceVtxGenerator requires the RandomNumberGeneratorService\n" + "which is not present in the configuration file. \n" + "You must add the service\n" + "in the configuration file or remove the modules that require it."; + } + + produces(); +} + +//---------------------------------------------------------------------------------------------------- + +void BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get random engine + edm::Service rng; + CLHEP::HepRandomEngine* rnd = &(rng->getEngine(iEvent.streamID())); + + // get conditions + edm::ESHandle hBeamParameters; + iSetup.get().get(hBeamParameters); + + // get input + edm::Handle hepUnsmearedMCEvt; + iEvent.getByToken(sourceToken_, hepUnsmearedMCEvt); + + // prepare output + HepMC::GenEvent* genevt = new HepMC::GenEvent(*hepUnsmearedMCEvt->GetEvent()); + std::unique_ptr pEvent(new edm::HepMCProduct(genevt)); + + // apply vertex smearing + if (simulateVertex_) + { + // NB: the separtion between effective offsets in LHC sectors 45 and 56 cannot be applied, thus the values for 45 are used + const double vtx_x = hBeamParameters->getVtxOffsetX45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevX(); + const double vtx_y = hBeamParameters->getVtxOffsetY45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevY(); + const double vtx_z = hBeamParameters->getVtxOffsetZ45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevZ(); + + HepMC::FourVector shift(vtx_x*1E1, vtx_y*1E1, vtx_z*1E1, 0.); // conversions: cm to mm + pEvent->applyVtxGen(&shift); + } + + // apply beam divergence + if (simulateBeamDivergence_) + { + const double bd_x_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX45(); + const double bd_x_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX56(); + + const double bd_y_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY45(); + const double bd_y_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY56(); + + for (HepMC::GenEvent::particle_iterator part = genevt->particles_begin(); part != genevt->particles_end(); ++part) + { + const HepMC::FourVector mom = (*part)->momentum(); + + // TODO: this is an oversimplified implemetation + // the TOTEM smearing module should be taken as reference + + double th_x = mom.x() / mom.z(); + double th_y = mom.y() / mom.z(); + + if (mom.z() > 0.) + { + th_x += bd_x_45; + th_y += bd_y_45; + } else { + th_x += bd_x_56; + th_y += bd_y_56; + } + + // calculate consistent p_z component + const double sign = (mom.z() > 0.) ? 1. : -1.; + const double p_z = sign * mom.rho() / sqrt(1. + th_x*th_x + th_y*th_y); + + // set smeared momentum + (*part)->set_momentum(HepMC::FourVector(p_z * th_x, p_z * th_y, p_z, mom.e())); + } + } + + // save output + iEvent.put(std::move(pEvent)); +} diff --git a/IOMC/EventVertexGenerators/src/module.cc b/IOMC/EventVertexGenerators/src/module.cc index 3ec6e2d985d45..8b388f0be1138 100644 --- a/IOMC/EventVertexGenerators/src/module.cc +++ b/IOMC/EventVertexGenerators/src/module.cc @@ -9,6 +9,7 @@ #include "IOMC/EventVertexGenerators/interface/BetafuncEvtVtxGenerator.h" #include "IOMC/EventVertexGenerators/interface/GaussianZBeamSpotFilter.h" #include "IOMC/EventVertexGenerators/interface/HLLHCEvtVtxGenerator.h" +#include "IOMC/EventVertexGenerators/interface/BeamDivergenceVtxGenerator.h" #include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -24,3 +25,4 @@ DEFINE_FWK_MODULE(BeamProfileVtxGenerator) ; DEFINE_FWK_MODULE(BetafuncEvtVtxGenerator) ; DEFINE_FWK_MODULE(GaussianZBeamSpotFilter); DEFINE_FWK_MODULE(HLLHCEvtVtxGenerator); +DEFINE_FWK_MODULE(BeamDivergenceVtxGenerator); From c0a746e218dccd48c374ff3344d4f2cdc5bd127a Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:45:05 +0100 Subject: [PATCH 107/686] Uses correct ES data. --- .../plugins/CTPPSDirectProtonSimulation.cc | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index 803f551ff03cd..885bf3a62e6d0 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -7,11 +7,13 @@ * ****************************************************************************/ + #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -26,10 +28,14 @@ #include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + #include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" #include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h" @@ -107,7 +113,9 @@ class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> // ------------ internal parameters ------------ - std::unordered_map opticalFunctions; + edm::ESWatcher lhcInfoWatcher_; + + std::unordered_map opticalFunctions_; /// internal variable: v position of strip 0, in mm double stripZeroPosition_; @@ -162,30 +170,26 @@ void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventS iEvent.getByToken(hepMCToken_, hepmc_prod); // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(hLHCInfo); + + edm::ESHandle hBeamParameters; + iSetup.get().get(hBeamParameters); + edm::ESHandle opticalFunctionCollection; iSetup.get().get(opticalFunctionCollection); edm::ESHandle geometry; iSetup.get().get(geometry); - // make static beam parameter object - // TODO: replace with proper EventSetup mechanism - CTPPSBeamParameters beamParameters; - beamParameters.setBeamMom45(6500.); - beamParameters.setBeamMom56(6500.); - beamParameters.setHalfXangleX45(185.); - beamParameters.setHalfXangleX56(185.); - // prepare optical functions - // TODO: proper condition (with ES watcher) - if (true) + if (lhcInfoWatcher_.check(iSetup)) { - opticalFunctions.clear(); + opticalFunctions_.clear(); - // TODO: solve 45/56 asymmetry, also nominal/determined mismatch - opticalFunctionCollection->interpolateFunctions(beamParameters.getHalfXangleX45(), opticalFunctions); + opticalFunctionCollection->interpolateFunctions(hLHCInfo->crossingAngle(), opticalFunctions_); - for (auto &p : opticalFunctions) + for (auto &p : opticalFunctions_) p.second.initializeSplines(); } @@ -214,7 +218,7 @@ void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventS if ( part->status() != 1 && part->status() < 83 ) continue; - processProton(vtx, part, *geometry, beamParameters, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); + processProton(vtx, part, *geometry, *hBeamParameters, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); } } @@ -294,7 +298,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, } // transport the proton into each pot/scoring plane - for (const auto &ofp : opticalFunctions) + for (const auto &ofp : opticalFunctions_) { CTPPSDetId rpId(ofp.first); const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); From 415634147bd512e5fda863ee65d6263dbab42706 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:45:59 +0100 Subject: [PATCH 108/686] Added validation modules. --- .../CTPPS/plugins/CTPPSAcceptancePlotter.cc | 358 +++++++++++ .../plugins/CTPPSBeamSmearingValidator.cc | 173 ++++++ .../CTPPSDirectProtonSimulationValidator.cc | 149 +++++ .../plugins/CTPPSHepMCDistributionPlotter.cc | 125 ++++ .../CTPPSProtonReconstructionPlotter.cc | 557 ++++++++++++++++++ ...ProtonReconstructionSimulationValidator.cc | 371 ++++++++++++ .../CTPPSProtonReconstructionValidator.cc | 191 ++++++ .../plugins/CTPPSTrackDistributionPlotter.cc | 173 ++++++ 8 files changed, 2097 insertions(+) create mode 100644 Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc create mode 100644 Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc create mode 100644 Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc create mode 100644 Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc create mode 100644 Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc create mode 100644 Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc create mode 100644 Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc create mode 100644 Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc new file mode 100644 index 0000000000000..49d1a505649d0 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -0,0 +1,358 @@ +/**************************************************************************** + * + * This is a part of CTPPS validation software + * Authors: + * Jan KaÅ¡par + * + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" + +#include +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSAcceptancePlotter( const edm::ParameterSet& ); + ~CTPPSAcceptancePlotter(); + + private: + virtual void beginJob() override; + + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + edm::EDGetTokenT tokenHepMC; + edm::EDGetTokenT< std::vector > tokenTracks; + + unsigned int rpId_45_N, rpId_45_F, rpId_56_N, rpId_56_F; + + std::string outputFile; + + struct SingleArmPlots + { + TH1D *h_xi_all = NULL, *h_xi_acc = NULL; + + void Init() + { + h_xi_all = new TH1D("", ";#xi", 100, 0., 0.25); + h_xi_acc = new TH1D("", ";#xi", 100, 0., 0.25); + } + + void Fill(double xi, bool acc) + { + if (h_xi_all == NULL) + Init(); + + h_xi_all->Fill(xi); + if (acc) + h_xi_acc->Fill(xi); + } + + void Write() const + { + h_xi_all->Write("h_xi_all"); + h_xi_acc->Write("h_xi_acc"); + + TH1D *h_xi_rat = new TH1D(*h_xi_acc); + h_xi_rat->Divide(h_xi_all); + h_xi_rat->Write("h_xi_rat"); + } + }; + + std::vector> singleArmConfigurations; + std::map, SingleArmPlots> singleArmPlots; + + struct DoubleArmPlots + { + TH1D *h_m_all = NULL, *h_m_acc = NULL; + TH2D *h2_xi_45_vs_xi_56_all, *h2_xi_45_vs_xi_56_acc; + TH2D *h2_y_vs_m_all, *h2_y_vs_m_acc; + + void Init() + { + h_m_all = new TH1D("", ";m (GeV)", 100, 0., 2500.); + h_m_acc = new TH1D("", ";m (GeV)", 100, 0., 2500.); + + h2_xi_45_vs_xi_56_all = new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25); + h2_xi_45_vs_xi_56_acc = new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25); + + h2_y_vs_m_all = new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5); + h2_y_vs_m_acc = new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5); + } + + void Fill(double xi_45, double xi_56, bool acc) + { + if (h_m_all == NULL) + Init(); + + const double p_nom = 6500.; + const double m = 2. * p_nom * sqrt(xi_45 * xi_56); + const double y = log(xi_45 / xi_56) / 2.; + + h_m_all->Fill(m); + h2_xi_45_vs_xi_56_all->Fill(xi_56, xi_45); + h2_y_vs_m_all->Fill(m, y); + + if (acc) + { + h_m_acc->Fill(m); + h2_xi_45_vs_xi_56_acc->Fill(xi_56, xi_45); + h2_y_vs_m_acc->Fill(m, y); + } + } + + void Write() const + { + h_m_all->Write("h_m_all"); + h_m_acc->Write("h_m_acc"); + + TH1D *h_m_rat = new TH1D(*h_m_acc); + h_m_rat->Divide(h_m_all); + h_m_rat->Write("h_m_rat"); + + + h2_xi_45_vs_xi_56_all->Write("h2_xi_45_vs_xi_56_all"); + h2_xi_45_vs_xi_56_acc->Write("h2_xi_45_vs_xi_56_acc"); + + TH2D *h2_xi_45_vs_xi_56_rat = new TH2D(*h2_xi_45_vs_xi_56_acc); + h2_xi_45_vs_xi_56_rat->Divide(h2_xi_45_vs_xi_56_all); + h2_xi_45_vs_xi_56_rat->Write("h2_xi_45_vs_xi_56_rat"); + + + h2_y_vs_m_all->Write("h2_y_vs_m_all"); + h2_y_vs_m_acc->Write("h2_y_vs_m_acc"); + + TH2D *h2_y_vs_m_rat = new TH2D(*h2_y_vs_m_acc); + h2_y_vs_m_rat->Divide(h2_y_vs_m_all); + h2_y_vs_m_rat->Write("h2_y_vs_m_rat"); + } + }; + + std::vector> doubleArmConfigurations; + std::map, DoubleArmPlots> doubleArmPlots; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSAcceptancePlotter::CTPPSAcceptancePlotter(const edm::ParameterSet& iConfig) : + tokenHepMC( consumes(iConfig.getParameter("tagHepMC")) ), + tokenTracks( consumes< std::vector >( iConfig.getParameter( "tagTracks" ) ) ), + + rpId_45_N(iConfig.getParameter("rpId_45_N")), + rpId_45_F(iConfig.getParameter("rpId_45_F")), + rpId_56_N(iConfig.getParameter("rpId_56_N")), + rpId_56_F(iConfig.getParameter("rpId_56_F")), + + outputFile(iConfig.getParameter("outputFile")) +{ + singleArmConfigurations = { + { rpId_45_N }, + { rpId_45_F }, + { rpId_56_N }, + { rpId_56_F }, + { rpId_45_N, rpId_45_F }, + { rpId_56_N, rpId_56_F }, + }; + + doubleArmConfigurations = { + { rpId_45_N, rpId_56_N }, + { rpId_45_F, rpId_56_F }, + { rpId_45_N, rpId_45_F, rpId_56_N, rpId_56_F }, + }; +} + +//---------------------------------------------------------------------------------------------------- + +CTPPSAcceptancePlotter::~CTPPSAcceptancePlotter() +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventSetup&) +{ + //printf("------------------------ run=%u, event=%llu -----------------------\n", iEvent.id().run(), iEvent.id().event()); + + // get input + edm::Handle hHepMC; + iEvent.getByToken(tokenHepMC, hHepMC); + HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent(); + + edm::Handle< std::vector > hTracks; + iEvent.getByToken(tokenTracks, hTracks); + + // extract protons + bool proton_45_set = false; + bool proton_56_set = false; + FourVector mom_45, mom_56; + + for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) + { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + + if (mom.e() < 4500.) + continue; + + // TODO + //printf(" status = %u, mom = %E, %E, %E\n", part->status(), mom.x(), mom.y(), mom.z()); + + if (mom.z() > 0) + { + // 45 + if (proton_45_set) + { + printf("ERROR: multiple protons in sector 45 found.\n"); + return; + } + + proton_45_set = true; + mom_45 = mom; + } else { + // 56 + if (proton_56_set) + { + printf("ERROR: multiple protons in sector 56 found.\n"); + return; + } + + proton_56_set = true; + mom_56 = mom; + } + } + + // stop if protons missing + if (!proton_45_set || !proton_56_set) + return; + + // calculate xi's + const double p_nom = 6500.; + const double xi_45 = (p_nom - mom_45.e()) / p_nom; + const double xi_56 = (p_nom - mom_56.e()) / p_nom; + + // process tracks + map trackPresent; + for (const auto& trk : *hTracks) + { + CTPPSDetId rpId(trk.getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + trackPresent[rpDecId] = true; + } + + // update plots + for (const auto rpIds : singleArmConfigurations) + { + bool acc = true; + signed int arm = -1; + for (const auto rpId : rpIds) + { + acc &= trackPresent[rpId]; + arm = rpId / 100; + } + + if (arm < 0) + continue; + + const double xi = (arm == 0) ? xi_45 : xi_56; + + singleArmPlots[rpIds].Fill(xi, acc); + } + + for (const auto rpIds : doubleArmConfigurations) + { + bool acc = true; + for (const auto rpId : rpIds) + acc &= trackPresent[rpId]; + + doubleArmPlots[rpIds].Fill(xi_45, xi_56, acc); + } +} + + +//---------------------------------------------------------------------------------------------------- + +void CTPPSAcceptancePlotter::beginJob() +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSAcceptancePlotter::endJob() +{ + TFile *f_out = TFile::Open(outputFile.c_str(), "recreate"); + + for (const auto &p : singleArmPlots) + { + string dirName; + for (const auto &rpId : p.first) + { + if (dirName.size() > 0) + dirName += ","; + char buf[100]; + sprintf(buf, "%u", rpId); + dirName += buf; + } + + gDirectory = f_out->mkdir(dirName.c_str()); + p.second.Write(); + } + + for (const auto &p : doubleArmPlots) + { + string dirName; + for (const auto &rpId : p.first) + { + if (dirName.size() > 0) + dirName += ","; + char buf[100]; + sprintf(buf, "%u", rpId); + dirName += buf; + } + + gDirectory = f_out->mkdir(dirName.c_str()); + p.second.Write(); + } + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSAcceptancePlotter); diff --git a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc new file mode 100644 index 0000000000000..067b8679e7909 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc @@ -0,0 +1,173 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "TFile.h" +#include "TH1D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSBeamSmearingValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSBeamSmearingValidator( const edm::ParameterSet& ); + + ~CTPPSBeamSmearingValidator() {} + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + edm::EDGetTokenT tokenBeforeSmearing_; + edm::EDGetTokenT tokenAfterSmearing_; + + std::string outputFile_; + + TH1D *h_de_vtx_x_, *h_de_vtx_y_, *h_de_vtx_z_; + + struct SectorPlots + { + TH1D *h_de_th_x = NULL; + TH1D *h_de_th_y = NULL; + TH1D *h_de_p = NULL; + + void init() + { + h_de_th_x = new TH1D("", ";#Delta#theta_{x} (rad)", 100, 0., 0.); + h_de_th_y = new TH1D("", ";#Delta#theta_{y} (rad)", 100, 0., 0.); + h_de_p = new TH1D("", ";#Deltap (GeV)", 100, 0., 0.); + } + + void write() const + { + h_de_th_x->Write("h_de_th_x"); + h_de_th_y->Write("h_de_th_y"); + h_de_p->Write("h_de_p"); + } + }; + + std::map sectorPlots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSBeamSmearingValidator::CTPPSBeamSmearingValidator(const edm::ParameterSet& iConfig) : + tokenBeforeSmearing_( consumes(iConfig.getParameter("tagBeforeSmearing")) ), + tokenAfterSmearing_( consumes(iConfig.getParameter("tagAfterSmearing")) ), + outputFile_(iConfig.getParameter("outputFile")) +{ + h_de_vtx_x_ = new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.); + h_de_vtx_y_ = new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.); + h_de_vtx_z_ = new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.); + + sectorPlots_[0].init(); + sectorPlots_[1].init(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::EventSetup&) +{ + // get input + edm::Handle hBeforeSmearing; + iEvent.getByToken(tokenBeforeSmearing_, hBeforeSmearing); + HepMC::GenEvent *orig = (HepMC::GenEvent *) hBeforeSmearing->GetEvent(); + + edm::Handle hAfterSmearing; + iEvent.getByToken(tokenAfterSmearing_, hAfterSmearing); + HepMC::GenEvent *smear = (HepMC::GenEvent *) hAfterSmearing->GetEvent(); + + // vertices + GenEvent::vertex_const_iterator vold, vnew; + for (vold = orig->vertices_begin(), vnew = smear->vertices_begin(); + vold != orig->vertices_end() && vnew != smear->vertices_end(); ++vold, ++vnew) + { + const FourVector &vo = (*vold)->position(); + const FourVector &vn = (*vnew)->position(); + + // HepMC gives vertex in mm + h_de_vtx_x_->Fill(vn.x() - vo.x()); + h_de_vtx_y_->Fill(vn.y() - vo.y()); + h_de_vtx_z_->Fill(vn.z() - vo.z()); + } + + // particles + GenEvent::particle_const_iterator pold, pnew; + for (pold = orig->particles_begin(), pnew = smear->particles_begin(); + pold != orig->particles_end() && pnew != smear->particles_end(); ++pold, ++pnew) + { + FourVector o = (*pold)->momentum(), n = (*pnew)->momentum(); + + // determine direction region + signed int idx = -1; + const double thetaLim = 0.01; // rad + double th = o.theta(); + + if (th < thetaLim) + idx = 0; + if (th > (M_PI - thetaLim)) + idx = 1; + + if (idx < 0) + continue; + + /* + cout << "particle\n\told: [" << o.x() << ", " << o.y() << ", " << o.z() << ", " << o.t() + << "]\n\tnew: [" << n.x() << ", " << n.y() << ", " << n.z() << ", " << n.t() + << "]\n\tregion: " << idx << endl; + */ + + // fill histograms + auto &sp = sectorPlots_[idx]; + + double othx = o.x() / o.rho(), othy = o.y() / o.rho(); + double nthx = n.x() / n.rho(), nthy = n.y() / n.rho(); + + sp.h_de_p->Fill(n.rho() - o.rho()); + + sp.h_de_th_x->Fill(nthx - othx); + sp.h_de_th_y->Fill(nthy - othy); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamSmearingValidator::endJob() +{ + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + h_de_vtx_x_->Write(); + h_de_vtx_y_->Write(); + h_de_vtx_z_->Write(); + + gDirectory = f_out->mkdir("sector 45"); + sectorPlots_[0].write(); + + gDirectory = f_out->mkdir("sector 56"); + sectorPlots_[1].write(); + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSBeamSmearingValidator); diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc new file mode 100644 index 0000000000000..3072ec327e8ef --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc @@ -0,0 +1,149 @@ +/**************************************************************************** + * + * This is a part of CTPPS validation software + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& ); + ~CTPPSDirectProtonSimulationValidator(); + + private: + virtual void beginJob() override; + + virtual void analyze( const edm::Event&, const edm::EventSetup& ) override; + + virtual void endJob() override; + + edm::EDGetTokenT< std::vector > simuTracksToken_; + edm::EDGetTokenT< std::vector > recoTracksToken_; + + std::string outputFile; + + struct RPPlots + { + TH2D *h2_xr_vs_xs=NULL, *h2_yr_vs_ys=NULL; + TH1D *h_de_x, *h_de_y; + + void init() + { + h2_xr_vs_xs = new TH2D("", "", 100, -10., +10., 100, -10, +10.); + h2_yr_vs_ys = new TH2D("", "", 100, -10., +10., 100, -10, +10.); + h_de_x = new TH1D("", "", 100, -0., +0.); + h_de_y = new TH1D("", "", 100, -0., +0.); + } + + void fill(double simu_x, double simu_y, double reco_x, double reco_y) + { + if (h2_xr_vs_xs == NULL) + init(); + + h2_xr_vs_xs->Fill(simu_x, reco_x); + h2_yr_vs_ys->Fill(simu_y, reco_y); + + h_de_x->Fill(reco_x - simu_x); + h_de_y->Fill(reco_y - simu_y); + } + + void write() const + { + h2_xr_vs_xs->Write("h2_xr_vs_xs"); + h2_yr_vs_ys->Write("h2_yr_vs_ys"); + h_de_x->Write("h_de_x"); + h_de_y->Write("h_de_y"); + } + }; + + std::map rpPlots; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSDirectProtonSimulationValidator::CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& iConfig ) : + simuTracksToken_( consumes< std::vector >( iConfig.getParameter( "simuTracksTag" ) ) ), + recoTracksToken_( consumes< std::vector >( iConfig.getParameter( "recoTracksTag" ) ) ), + outputFile( iConfig.getParameter("outputFile") ) +{ +} + +//---------------------------------------------------------------------------------------------------- + +CTPPSDirectProtonSimulationValidator::~CTPPSDirectProtonSimulationValidator() +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulationValidator::analyze( const edm::Event& iEvent, const edm::EventSetup& ) +{ + // get input + edm::Handle< std::vector > simuTracks; + iEvent.getByToken( simuTracksToken_, simuTracks ); + + edm::Handle< std::vector > recoTracks; + iEvent.getByToken( recoTracksToken_, recoTracks ); + + // process tracks + for (const auto& simuTrack : *simuTracks) + { + + for (const auto& recoTrack : *recoTracks) + { + if (simuTrack.getRPId() == recoTrack.getRPId()) + { + CTPPSDetId rpId(simuTrack.getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + rpPlots[rpDecId].fill(simuTrack.getX(), simuTrack.getY(), recoTrack.getX(), recoTrack.getY()); + } + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulationValidator::beginJob() +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulationValidator::endJob() +{ + TFile *f_out = TFile::Open(outputFile.c_str(), "recreate"); + + for (const auto it : rpPlots) + { + gDirectory = f_out->mkdir(Form("RP %u", it.first)); + it.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSDirectProtonSimulationValidator ); diff --git a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc new file mode 100644 index 0000000000000..e7834f59c6237 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc @@ -0,0 +1,125 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "TFile.h" +#include "TH1D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSHepMCDistributionPlotter(const edm::ParameterSet&); + + ~CTPPSHepMCDistributionPlotter() {} + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + edm::EDGetTokenT tokenHepMC_; + + std::string outputFile_; + + TH1D *h_xi_; + TH1D *h_th_x_; + TH1D *h_th_y_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::ParameterSet& iConfig) : + tokenHepMC_( consumes(iConfig.getParameter("tagHepMC")) ), + outputFile_(iConfig.getParameter("outputFile")) +{ + h_xi_ = new TH1D("h_xi", ";#xi", 100, 0., 0.30); + h_th_x_ = new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6); + h_th_y_ = new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSHepMCDistributionPlotter::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(hLHCInfo); + + // get input + edm::Handle hHepMC; + iEvent.getByToken(tokenHepMC_, hHepMC); + HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent(); + + // extract protons + for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) + { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + const double p_nom = hLHCInfo->energy(); + + if (mom.rho() / p_nom < 0.7) + continue; + + const double xi_simu = (p_nom - mom.e()) / p_nom; + const double th_x_simu = mom.x() / mom.rho(); + const double th_y_simu = mom.y() / mom.rho(); + + h_xi_->Fill(xi_simu); + h_th_x_->Fill(th_x_simu); + h_th_y_->Fill(th_y_simu); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSHepMCDistributionPlotter::endJob() +{ + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + h_xi_->Write(); + h_th_x_->Write(); + h_th_y_->Write(); + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSHepMCDistributionPlotter); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc new file mode 100644 index 0000000000000..cb90bc9e65a90 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -0,0 +1,557 @@ +/**************************************************************************** +* +* Authors: +* Jan KaÅ¡par (jan.kaspar@gmail.com) +* +****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "TFile.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionPlotter(const edm::ParameterSet&); + ~CTPPSProtonReconstructionPlotter() {} + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + edm::EDGetTokenT> tokenTracks_; + edm::EDGetTokenT> tokenRecoProtonsSingleRP_; + edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + + unsigned int rpId_45_N_, rpId_45_F_; + unsigned int rpId_56_N_, rpId_56_F_; + + std::string outputFile_; + + signed int maxNonEmptyEvents_; + + static void profileToRMSGraph(TProfile *p, TGraphErrors *g) + { + for (int bi = 1; bi <= p->GetNbinsX(); ++bi) + { + double c = p->GetBinCenter(bi); + + double N = p->GetBinEntries(bi); + double Sy = p->GetBinContent(bi) * N; + double Syy = p->GetSumw2()->At(bi); + + double si_sq = Syy/N - Sy*Sy/N/N; + double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; + double si_unc_sq = si_sq / 2. / N; // Gaussian approximation + double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; + + int idx = g->GetN(); + g->SetPoint(idx, c, si); + g->SetPointError(idx, 0., si_unc); + } + } + + struct SingleRPPlots + { + TH1D *h_xi = NULL; + + TH2D *h2_th_y_vs_xi = NULL; + TProfile *p_th_y_vs_xi = NULL; + + void init() + { + h_xi = new TH1D("", ";#xi", 100, 0., 0.25); + + h2_th_y_vs_xi = new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); + p_th_y_vs_xi = new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25); + } + + void fill(const reco::ProtonTrack &p) + { + if (!h_xi) + init(); + + if (p.validFit()) + { + h_xi->Fill(p.xi()); + + const double th_y = p.thetaY(); + h2_th_y_vs_xi->Fill(p.xi(), th_y); + p_th_y_vs_xi->Fill(p.xi(), th_y); + } + } + + void write() const + { + h_xi->Write("h_xi"); + + h2_th_y_vs_xi->Write("h2_th_y_vs_xi"); + p_th_y_vs_xi->Write("p_th_y_vs_xi"); + } + }; + + std::map singleRPPlots_; + + struct MultiRPPlots + { + TH1D *h_xi=NULL, *h_th_x=NULL, *h_th_y=NULL, *h_vtx_y=NULL, *h_t=NULL, *h_chi_sq=NULL, *h_chi_sq_norm=NULL; + TH1D *h_t_xi_range1=NULL, *h_t_xi_range2=NULL, *h_t_xi_range3=NULL; + TH2D *h2_th_x_vs_xi = NULL, *h2_th_y_vs_xi = NULL, *h2_vtx_y_vs_xi = NULL, *h2_t_vs_xi; + TProfile *p_th_x_vs_xi = NULL, *p_th_y_vs_xi = NULL, *p_vtx_y_vs_xi = NULL; + + void init() + { + std::vector v_t_bin_edges; + for (double t = 0; t <= 5.; ) + { + v_t_bin_edges.push_back(t); + const double de_t = 0.05 + 0.09 * t + 0.02 * t*t; + t += de_t; + } + + double *t_bin_edges = new double[v_t_bin_edges.size()]; + for (unsigned int i = 0; i < v_t_bin_edges.size(); ++i) + t_bin_edges[i] = v_t_bin_edges[i]; + + h_chi_sq = new TH1D("", ";#chi^{2}", 100, 0., 0.); + h_chi_sq_norm = new TH1D("", ";#chi^{2}/ndf", 100, 0., 5.); + + h_xi = new TH1D("", ";#xi", 100, 0., 0.25); + + h_th_x = new TH1D("", ";#theta_{x} (rad)", 100, -500E-6, +500E-6); + h_th_y = new TH1D("", ";#theta_{y} (rad)", 100, -500E-6, +500E-6); + + h_vtx_y = new TH1D("", ";vtx_{y} (cm)", 100, -2., +2.); + + h_t = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); + h_t_xi_range1 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); + h_t_xi_range2 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); + h_t_xi_range3 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); + + h2_th_x_vs_xi = new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); + h2_th_y_vs_xi = new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); + h2_vtx_y_vs_xi = new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25, 100, -500E-3, +500E-3); + h2_t_vs_xi = new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.25, v_t_bin_edges.size() - 1, t_bin_edges); + + p_th_x_vs_xi = new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25); + p_th_y_vs_xi = new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25); + p_vtx_y_vs_xi = new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25); + + delete[] t_bin_edges; + } + + void fill(const reco::ProtonTrack &p) + { + if (!h_xi) + init(); + + if (p.validFit()) + { + const double th_x = p.thetaX(); + const double th_y = p.thetaY(); + const double mt = - p.t(); + + h_chi_sq->Fill(p.chi2()); + if (p.ndof() > 0) + h_chi_sq_norm->Fill(p.normalizedChi2()); + + h_xi->Fill(p.xi()); + + h_th_x->Fill(th_x); + h_th_y->Fill(th_y); + + h_vtx_y->Fill(p.vertex().y()); + + h_t->Fill(mt); + if (p.xi() > 0.04 && p.xi() < 0.07) h_t_xi_range1->Fill(mt); + if (p.xi() > 0.07 && p.xi() < 0.10) h_t_xi_range2->Fill(mt); + if (p.xi() > 0.10 && p.xi() < 0.13) h_t_xi_range3->Fill(mt); + + h2_th_x_vs_xi->Fill(p.xi(), th_x); + h2_th_y_vs_xi->Fill(p.xi(), th_y); + h2_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); + h2_t_vs_xi->Fill(p.xi(), mt); + + p_th_x_vs_xi->Fill(p.xi(), th_x); + p_th_y_vs_xi->Fill(p.xi(), th_y); + p_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); + } + } + + void write() const + { + h_chi_sq->Write("h_chi_sq"); + h_chi_sq_norm->Write("h_chi_sq_norm"); + + h_xi->Write("h_xi"); + + h_th_x->Write("h_th_x"); + h2_th_x_vs_xi->Write("h2_th_x_vs_xi"); + p_th_x_vs_xi->Write("p_th_x_vs_xi"); + TGraphErrors *g_th_x_RMS_vs_xi = new TGraphErrors(); + profileToRMSGraph(p_th_x_vs_xi, g_th_x_RMS_vs_xi); + g_th_x_RMS_vs_xi->Write("g_th_x_RMS_vs_xi"); + + h_th_y->Write("h_th_y"); + h2_th_y_vs_xi->Write("h2_th_y_vs_xi"); + p_th_y_vs_xi->Write("p_th_y_vs_xi"); + TGraphErrors *g_th_y_RMS_vs_xi = new TGraphErrors(); + profileToRMSGraph(p_th_y_vs_xi, g_th_y_RMS_vs_xi); + g_th_y_RMS_vs_xi->Write("g_th_y_RMS_vs_xi"); + + h_vtx_y->Write("h_vtx_y"); + h2_vtx_y_vs_xi->Write("h2_vtx_y_vs_xi"); + p_vtx_y_vs_xi->Write("p_vtx_y_vs_xi"); + TGraphErrors *g_vtx_y_RMS_vs_xi = new TGraphErrors(); + profileToRMSGraph(p_vtx_y_vs_xi, g_vtx_y_RMS_vs_xi); + g_vtx_y_RMS_vs_xi->Write("g_vtx_y_RMS_vs_xi"); + + h_t->Write("h_t"); + h_t_xi_range1->Write("h_t_xi_range1"); + h_t_xi_range2->Write("h_t_xi_range2"); + h_t_xi_range3->Write("h_t_xi_range3"); + + h2_t_vs_xi->Write("h2_t_vs_xi"); + } + }; + + std::map multiRPPlots_; + + struct SingleMultiCorrelationPlots + { + TH2D *h2_xi_mu_vs_xi_si = NULL; + TH1D *h_xi_diff_mu_si = NULL; + TH1D *h_xi_diff_si_mu = NULL; + + TH2D *h2_xi_diff_si_mu_vs_xi_mu = NULL; + TProfile *p_xi_diff_si_mu_vs_xi_mu = NULL; + + TH2D *h2_th_y_mu_vs_th_y_si = NULL; + + void init() + { + h2_xi_mu_vs_xi_si = new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.25, 100, 0., 0.25); + h_xi_diff_mu_si = new TH1D("", ";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1); + h_xi_diff_si_mu = new TH1D("", ";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1); + + h2_xi_diff_si_mu_vs_xi_mu = new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25, 100, -0.10, 0.10); + p_xi_diff_si_mu_vs_xi_mu = new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25); + + h2_th_y_mu_vs_th_y_si = new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6); + } + + void fill(const reco::ProtonTrack &p_single, const reco::ProtonTrack &p_multi) + { + if (!h2_xi_mu_vs_xi_si) + init(); + + if (p_single.validFit() && p_multi.validFit()) + { + h2_xi_mu_vs_xi_si->Fill(p_single.xi(), p_multi.xi()); + h_xi_diff_mu_si->Fill(p_multi.xi() - p_single.xi()); + h_xi_diff_si_mu->Fill(p_single.xi() - p_multi.xi()); + + h2_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.xi(), p_single.xi() - p_multi.xi()); + p_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.xi(), p_single.xi() - p_multi.xi()); + + const double th_y_si = p_single.thetaY(); + const double th_y_mu = p_multi.thetaY(); + + h2_th_y_mu_vs_th_y_si->Fill(th_y_si, th_y_mu); + } + } + + void write() const + { + h2_xi_mu_vs_xi_si->Write("h2_xi_mu_vs_xi_si"); + h_xi_diff_mu_si->Write("h_xi_diff_mu_si"); + h_xi_diff_si_mu->Write("h_xi_diff_si_mu"); + + h2_xi_diff_si_mu_vs_xi_mu->Write("h2_xi_diff_si_mu_vs_xi_mu"); + p_xi_diff_si_mu_vs_xi_mu->Write("p_xi_diff_si_mu_vs_xi_mu"); + + h2_th_y_mu_vs_th_y_si->Write("h2_th_y_mu_vs_th_y_si"); + } + }; + + std::map singleMultiCorrelationPlots_; + + struct ArmCorrelationPlots + { + TH1D *h_xi_si_diffNF = NULL; + TProfile *p_xi_si_diffNF_vs_xi_mu = NULL; + + TH1D *h_th_y_si_diffNF = NULL; + TProfile *p_th_y_si_diffNF_vs_xi_mu = NULL; + + void init() + { + h_xi_si_diffNF = new TH1D("", ";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02); + p_xi_si_diffNF_vs_xi_mu = new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.25); + + h_th_y_si_diffNF = new TH1D("", ";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6); + p_th_y_si_diffNF_vs_xi_mu = new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25); + } + + void fill(const reco::ProtonTrack &p_s_N, const reco::ProtonTrack &p_s_F, const reco::ProtonTrack &p_m) + { + if (!h_xi_si_diffNF) + init(); + + if (p_s_N.validFit() && p_s_F.validFit() && p_m.validFit()) + { + const double th_y_s_N = p_s_N.thetaY(); + const double th_y_s_F = p_s_F.thetaY(); + + h_xi_si_diffNF->Fill(p_s_F.xi() - p_s_N.xi()); + p_xi_si_diffNF_vs_xi_mu->Fill(p_m.xi(), p_s_F.xi() - p_s_N.xi()); + + h_th_y_si_diffNF->Fill(th_y_s_F - th_y_s_N); + p_th_y_si_diffNF_vs_xi_mu->Fill(p_m.xi(), th_y_s_F - th_y_s_N); + } + } + + void write() const + { + h_xi_si_diffNF->Write("h_xi_si_diffNF"); + p_xi_si_diffNF_vs_xi_mu->Write("p_xi_si_diffNF_vs_xi_mu"); + + h_th_y_si_diffNF->Write("h_th_y_si_diffNF"); + p_th_y_si_diffNF_vs_xi_mu->Write("p_th_y_si_diffNF_vs_xi_mu"); + } + }; + + std::map armCorrelationPlots_; + + TProfile *p_x_L_diffNF_vs_x_L_N_, *p_x_R_diffNF_vs_x_R_N_; + TProfile *p_y_L_diffNF_vs_y_L_N_, *p_y_R_diffNF_vs_y_R_N_; + + signed int n_non_empty_events_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionPlotter::CTPPSProtonReconstructionPlotter(const edm::ParameterSet &ps) : + tokenTracks_(consumes< std::vector>(ps.getParameter("tagTracks"))), + tokenRecoProtonsSingleRP_(consumes>(ps.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_(consumes>(ps.getParameter("tagRecoProtonsMultiRP"))), + + rpId_45_N_(ps.getParameter("rpId_45_N")), + rpId_45_F_(ps.getParameter("rpId_45_F")), + rpId_56_N_(ps.getParameter("rpId_56_N")), + rpId_56_F_(ps.getParameter("rpId_56_F")), + + outputFile_(ps.getParameter("outputFile")), + maxNonEmptyEvents_(ps.getUntrackedParameter("maxNonEmptyEvents", -1)), + + n_non_empty_events_(0) +{ + p_x_L_diffNF_vs_x_L_N_ = new TProfile("p_x_L_diffNF_vs_x_L_N", ";x_{LN};x_{LF} - x_{LN}", 100, 0., +20.); + p_x_R_diffNF_vs_x_R_N_ = new TProfile("p_x_R_diffNF_vs_x_R_N", ";x_{RN};x_{RF} - x_{RN}", 100, 0., +20.); + + p_y_L_diffNF_vs_y_L_N_ = new TProfile("p_y_L_diffNF_vs_y_L_N", ";y_{LN};y_{LF} - y_{LN}", 100, -20., +20.); + p_y_R_diffNF_vs_y_R_N_ = new TProfile("p_y_R_diffNF_vs_y_R_N", ";y_{RN};y_{RF} - y_{RN}", 100, -20., +20.); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const edm::EventSetup&) +{ + // get input + edm::Handle< std::vector > hTracks; + event.getByToken(tokenTracks_, hTracks); + + Handle> hRecoProtonsSingleRP; + event.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + Handle> hRecoProtonsMultiRP; + event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + + if (hRecoProtonsSingleRP->size() > 0) + n_non_empty_events_++; + + if (maxNonEmptyEvents_ > 0 && n_non_empty_events_ > maxNonEmptyEvents_) + throw cms::Exception("CTPPSProtonReconstructionPlotter") << "Number of non empty events reached maximum."; + + // track plots + const CTPPSLocalTrackLite *tr_L_N = NULL; + const CTPPSLocalTrackLite *tr_L_F = NULL; + const CTPPSLocalTrackLite *tr_R_N = NULL; + const CTPPSLocalTrackLite *tr_R_F = NULL; + + for (const auto &tr : *hTracks) + { + CTPPSDetId rpId(tr.getRPId()); + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (decRPId == rpId_45_N_) tr_L_N = &tr; + if (decRPId == rpId_45_F_) tr_L_F = &tr; + if (decRPId == rpId_56_N_) tr_R_N = &tr; + if (decRPId == rpId_56_F_) tr_R_F = &tr; + } + + if (tr_L_N && tr_L_F) + { + p_x_L_diffNF_vs_x_L_N_->Fill(tr_L_N->getX(), tr_L_F->getX() - tr_L_N->getX()); + p_y_L_diffNF_vs_y_L_N_->Fill(tr_L_N->getY(), tr_L_F->getY() - tr_L_N->getY()); + } + + if (tr_R_N && tr_R_F) + { + p_x_R_diffNF_vs_x_R_N_->Fill(tr_R_N->getX(), tr_R_F->getX() - tr_R_N->getX()); + p_y_R_diffNF_vs_y_R_N_->Fill(tr_R_N->getY(), tr_R_F->getY() - tr_R_N->getY()); + } + + // make single-RP-reco plots + for (const auto &proton : *hRecoProtonsSingleRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + singleRPPlots_[decRPId].fill(proton); + } + + // make multi-RP-reco plots + for (const auto &proton : *hRecoProtonsMultiRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + unsigned int armId = rpId.arm(); + multiRPPlots_[armId].fill(proton); + } + + // make correlation plots + for (const auto &proton_s : *hRecoProtonsSingleRP) + { + for (const auto &proton_m : *hRecoProtonsMultiRP) + { + // only compare object from the same arm + CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->getRPId()); + CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->getRPId()); + + if (rpId_s.arm() != rpId_m.arm()) + continue; + + // build index + const unsigned int idx = rpId_s.arm()*1000 + rpId_s.station()*100 + rpId_s.rp()*10 + rpId_m.arm(); + + // fill plots + singleMultiCorrelationPlots_[idx].fill(proton_s, proton_m); + } + } + + // arm correlation plots + const reco::ProtonTrack *p_arm0_s_N = NULL, *p_arm0_s_F = NULL, *p_arm0_m = NULL; + const reco::ProtonTrack *p_arm1_s_N = NULL, *p_arm1_s_F = NULL, *p_arm1_m = NULL; + + for (const auto &proton : *hRecoProtonsSingleRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (rpDecId == rpId_45_N_) p_arm0_s_N = &proton; + if (rpDecId == rpId_45_F_) p_arm0_s_F = &proton; + + if (rpDecId == rpId_56_N_) p_arm1_s_N = &proton; + if (rpDecId == rpId_56_F_) p_arm1_s_F = &proton; + } + + for (const auto & proton : *hRecoProtonsMultiRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + const unsigned int arm = rpId.arm(); + + if (arm == 0) p_arm0_m = &proton; + if (arm == 1) p_arm1_m = &proton; + } + + if (p_arm0_s_N && p_arm0_s_F && p_arm0_m) + armCorrelationPlots_[0].fill(*p_arm0_s_N, *p_arm0_s_F, *p_arm0_m); + + if (p_arm1_s_N && p_arm1_s_F && p_arm1_m) + armCorrelationPlots_[1].fill(*p_arm1_s_N, *p_arm1_s_F, *p_arm1_m); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionPlotter::endJob() +{ + printf(">> CTPPSProtonReconstructionPlotter: n_non_empty_events = %u\n", n_non_empty_events_); + + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + p_x_L_diffNF_vs_x_L_N_->Write(); + p_x_R_diffNF_vs_x_R_N_->Write(); + + p_y_L_diffNF_vs_y_L_N_->Write(); + p_y_R_diffNF_vs_y_R_N_->Write(); + + TDirectory *d_singleRPPlots = f_out->mkdir("singleRPPlots"); + for (const auto it : singleRPPlots_) + { + char buf[100]; + sprintf(buf, "rp%u", it.first); + gDirectory = d_singleRPPlots->mkdir(buf); + it.second.write(); + } + + TDirectory *d_multiRPPlots = f_out->mkdir("multiRPPlots"); + for (const auto it : multiRPPlots_) + { + char buf[100]; + sprintf(buf, "arm%u", it.first); + gDirectory = d_multiRPPlots->mkdir(buf); + it.second.write(); + } + + TDirectory *d_singleMultiCorrelationPlots = f_out->mkdir("singleMultiCorrelationPlots"); + for (const auto it : singleMultiCorrelationPlots_) + { + unsigned int si_rp = it.first / 10; + unsigned int mu_arm = it.first % 10; + + char buf[100]; + sprintf(buf, "si_rp%u_mu_arm%u", si_rp, mu_arm); + gDirectory = d_singleMultiCorrelationPlots->mkdir(buf); + it.second.write(); + } + + TDirectory *d_armCorrelationPlots = f_out->mkdir("armCorrelationPlots"); + for (const auto it : armCorrelationPlots_) + { + unsigned int arm = it.first; + + char buf[100]; + sprintf(buf, "arm%u", arm); + gDirectory = d_armCorrelationPlots->mkdir(buf); + it.second.write(); + } + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionPlotter); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc new file mode 100644 index 0000000000000..d1be1502dabf7 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -0,0 +1,371 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TGraphErrors.h" + +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet&); + + ~CTPPSProtonReconstructionSimulationValidator() {} + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ProtonTrack &rec_pr, + const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo); + + edm::EDGetTokenT tokenHepMCBeforeSmearing_; + edm::EDGetTokenT tokenHepMCAfterSmearing_; + + edm::EDGetTokenT> tokenRecoProtonsSingleRP_; + edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + + std::string outputFile_; + + struct PlotGroup + { + TH1D *h_de_xi = NULL; + TProfile *p_de_xi_vs_xi_simu; + TH2D *h_xi_reco_vs_xi_simu; + + TH1D *h_de_th_x = NULL; + TProfile *p_de_th_x_vs_xi_simu; + + TH1D *h_de_th_y = NULL; + TProfile *p_de_th_y_vs_xi_simu; + + TH1D *h_de_vtx_y = NULL; + TProfile *p_de_vtx_y_vs_xi_simu; + + TH1D *h_de_t = NULL; + TProfile *p_de_t_vs_xi_simu; + TProfile *p_de_t_vs_t_simu; + + void init() + { + h_de_xi = new TH1D("", ";#xi_{reco} - #xi_{simu}", 100, 0., 0.); + p_de_xi_vs_xi_simu = new TProfile("", ";#xi_{simu};#xi_{reco} - #xi_{simu}", 19, 0.015, 0.205); + h_xi_reco_vs_xi_simu = new TH2D("", ";#xi_{simu};#xi_{reco}", 100, 0., 0.30, 100, 0., 0.30); + + h_de_th_x = new TH1D("", ";#theta_{x,reco} - #theta_{x,simu}", 100, 0., 0.); + p_de_th_x_vs_xi_simu = new TProfile("", ";#xi_{simu};#theta_{x,reco} - #theta_{x,simu}", 19, 0.015, 0.205); + + h_de_th_y = new TH1D("", ";#theta_{y,reco} - #theta_{y,simu}", 100, 0., 0.); + p_de_th_y_vs_xi_simu = new TProfile("", ";#xi_{simu};#theta_{y,reco} - #theta_{y,simu}", 19, 0.015, 0.205); + + h_de_vtx_y = new TH1D("", ";vtx_{y,reco} - vtx_{y,simu} (mm)", 100, 0., 0.); + p_de_vtx_y_vs_xi_simu = new TProfile("", ";#xi_{simu};vtx_{y,reco} - vtx_{y,simu} (mm)", 19, 0.015, 0.205); + + h_de_t = new TH1D("", ";t_{reco} - t_{simu}", 100, -1., +1.); + p_de_t_vs_xi_simu = new TProfile("", ";xi_{simu};t_{reco} - t_{simu}", 19, 0.015, 0.205); + p_de_t_vs_t_simu = new TProfile("", ";t_{simu};t_{reco} - t_{simu}", 20, 0., 5.); + } + + static TGraphErrors* profileToRMSGraph(TProfile *p, const std::string &name = "") + { + TGraphErrors *g = new TGraphErrors(); + g->SetName(name.c_str()); + + for (int bi = 1; bi <= p->GetNbinsX(); ++bi) + { + double c = p->GetBinCenter(bi); + double w = p->GetBinWidth(bi); + + double N = p->GetBinEntries(bi); + double Sy = p->GetBinContent(bi) * N; + double Syy = p->GetSumw2()->At(bi); + + double si_sq = Syy/N - Sy*Sy/N/N; + double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; + double si_unc_sq = si_sq / 2. / N; // Gaussian approximation + double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; + + int idx = g->GetN(); + g->SetPoint(idx, c, si); + g->SetPointError(idx, w/2., si_unc); + } + + return g; + } + + void write() const + { + h_xi_reco_vs_xi_simu->Write("h_xi_reco_vs_xi_simu"); + h_de_xi->Write("h_de_xi"); + p_de_xi_vs_xi_simu->Write("p_de_xi_vs_xi_simu"); + profileToRMSGraph(p_de_xi_vs_xi_simu, "g_rms_de_xi_vs_xi_simu")->Write(); + + h_de_th_x->Write("h_de_th_x"); + p_de_th_x_vs_xi_simu->Write("p_de_th_x_vs_xi_simu"); + profileToRMSGraph(p_de_th_x_vs_xi_simu, "g_rms_de_th_x_vs_xi_simu")->Write(); + + h_de_th_y->Write("h_de_th_y"); + p_de_th_y_vs_xi_simu->Write("p_de_th_y_vs_xi_simu"); + profileToRMSGraph(p_de_th_y_vs_xi_simu, "g_rms_de_th_y_vs_xi_simu")->Write(); + + h_de_vtx_y->Write("h_de_vtx_y"); + p_de_vtx_y_vs_xi_simu->Write("p_de_vtx_y_vs_xi_simu"); + profileToRMSGraph(p_de_vtx_y_vs_xi_simu, "g_rms_de_vtx_y_vs_xi_simu")->Write(); + + h_de_t->Write("h_de_t"); + p_de_t_vs_xi_simu->Write("p_de_t_vs_xi_simu"); + profileToRMSGraph(p_de_t_vs_xi_simu, "g_rms_de_t_vs_xi_simu")->Write(); + p_de_t_vs_t_simu->Write("p_de_t_vs_t_simu"); + profileToRMSGraph(p_de_t_vs_t_simu, "g_rms_de_t_vs_t_simu")->Write(); + } + }; + + std::map> plots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionSimulationValidator::CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet& iConfig) : + tokenHepMCBeforeSmearing_( consumes(iConfig.getParameter("tagHepMCBeforeSmearing")) ), + tokenHepMCAfterSmearing_( consumes(iConfig.getParameter("tagHepMCAfterSmearing")) ), + tokenRecoProtonsSingleRP_(consumes>(iConfig.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_(consumes>(iConfig.getParameter("tagRecoProtonsMultiRP"))), + outputFile_(iConfig.getParameter("outputFile")) +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(hLHCInfo); + + // get input + edm::Handle hHepMCBeforeSmearing; + iEvent.getByToken(tokenHepMCBeforeSmearing_, hHepMCBeforeSmearing); + HepMC::GenEvent *hepMCEventBeforeSmearing = (HepMC::GenEvent *) hHepMCBeforeSmearing->GetEvent(); + + edm::Handle hHepMCAfterSmearing; + iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing); + HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *) hHepMCAfterSmearing->GetEvent(); + + Handle> hRecoProtonsSingleRP; + iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + Handle> hRecoProtonsMultiRP; + iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + + // extract vertex position + bool vertex_set = false; + FourVector vtx; + for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) + { + if (vertex_set) + { + printf("ERROR: multiple vertices found.\n"); + return; + } + + vertex_set = true; + vtx = (*it)->position(); + } + + // extract forward protons + bool proton_45_set = false; + bool proton_56_set = false; + FourVector mom_45, mom_56; + + for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) + { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + + if (mom.e() < 4500.) + continue; + + if (mom.z() > 0) + { + // 45 + if (proton_45_set) + { + printf("ERROR: multiple protons in sector 45 found.\n"); + return; + } + + proton_45_set = true; + mom_45 = mom; + } else { + // 56 + if (proton_56_set) + { + printf("ERROR: multiple protons in sector 56 found.\n"); + return; + } + + proton_56_set = true; + mom_56 = mom; + } + } + + // do comparison + for (const auto &handle : { hRecoProtonsSingleRP, hRecoProtonsMultiRP } ) + { + for (const auto &rec_pr : *handle) + { + if (! rec_pr.validFit()) + continue; + + unsigned int idx; + + bool mom_set = false; + FourVector mom; + + if (rec_pr.lhcSector() == reco::ProtonTrack::LHCSector::sector45) + { + idx = 0; + mom_set = proton_45_set; + mom = mom_45; + } else { + idx = 1; + mom_set = proton_56_set; + mom = mom_56; + } + + if (! mom_set) + continue; + + unsigned int meth_idx = 1234; + + if (rec_pr.method() == reco::ProtonTrackExtra::ReconstructionMethod::singleRP) + { + meth_idx = 0; + + CTPPSDetId rpId((*rec_pr.contributingLocalTracks().begin())->getRPId()); + idx = 100*rpId.arm() + 10*rpId.station() + rpId.rp(); + } + + if (rec_pr.method() == reco::ProtonTrackExtra::ReconstructionMethod::multiRP) + { + meth_idx = 1; + } + + fillPlots(meth_idx, idx, rec_pr, vtx, mom, *hLHCInfo); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_idx, unsigned int idx, + const reco::ProtonTrack &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo) +{ + const double p_nom = lhcInfo.energy(); + const double xi_simu = (p_nom - mom.rho()) / p_nom; + const double th_x_simu = mom.x() / mom.rho(); + const double th_y_simu = mom.y() / mom.rho(); + const double vtx_y_simu = vtx.y(); + const double th_simu = sqrt(th_x_simu*th_x_simu + th_y_simu*th_y_simu); + const double t_simu = - reco::ProtonTrack::calculateT(p_nom, mom.rho(), th_simu); + + const double xi_reco = rec_pr.xi(); + const double th_x_reco = rec_pr.thetaX(); + const double th_y_reco = rec_pr.thetaY(); + const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm + const double t_reco = - rec_pr.t(); + + auto &p = plots_[meth_idx][idx]; + if (p.h_de_xi == NULL) + p.init(); + + p.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco); + p.h_de_xi->Fill(xi_reco - xi_simu); + p.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu); + + p.h_de_th_x->Fill(th_x_reco - th_x_simu); + p.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu); + + p.h_de_th_y->Fill(th_y_reco - th_y_simu); + p.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu); + + p.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu); + p.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu); + + p.h_de_t->Fill(t_reco - t_simu); + p.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu); + p.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::endJob() +{ + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + for (const auto &mit : plots_) + { + string method = (mit.first == 0) ? "single rp" : "multi rp"; + TDirectory *d_method = f_out->mkdir(method.c_str()); + + for (const auto &eit : mit.second) + { + char buf[20]; + sprintf(buf, "%i", eit.first); + + TDirectory *d_element = d_method->mkdir(buf); + + gDirectory = d_element; + eit.second.write(); + } + } + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionSimulationValidator); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc new file mode 100644 index 0000000000000..a457eb3179e7b --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -0,0 +1,191 @@ +/**************************************************************************** + * Authors: + * Jan KaÅ¡par + ****************************************************************************/ + + +// TODO: clean +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" + +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TGraphErrors.h" + +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionValidator(const edm::ParameterSet&); + + ~CTPPSProtonReconstructionValidator() {} + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + + virtual void endJob() override; + + edm::EDGetTokenT> tokenRecoProtons_; + + double chiSqCut_; + + std::string outputFile_; + + edm::ESWatcher lhcInfoWatcher_; + float currentCrossingAngle_; + + std::unordered_map opticalFunctions_; + + struct RPPlots + { + TH1D *h_de_x = NULL, *h_de_y; + + void init() + { + h_de_x = new TH1D("", ";#Deltax (mm)", 100, -2E-3, +2E-3); + h_de_y = new TH1D("", ";#Deltay (mm)", 100, -2E-3, +2E-3); + } + + void fill(double de_x, double de_y) + { + if (h_de_x == NULL) + init(); + + h_de_x->Fill(de_x); + h_de_y->Fill(de_y); + } + + void write() const + { + h_de_x->Write("h_de_x"); + h_de_y->Write("h_de_y"); + } + }; + + std::map rp_plots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator(const edm::ParameterSet& iConfig) : + tokenRecoProtons_( consumes>(iConfig.getParameter("tagRecoProtons")) ), + chiSqCut_( iConfig.getParameter("chiSqCut") ), + outputFile_(iConfig.getParameter("outputFile")) +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(hLHCInfo); + + edm::ESHandle hOpticalFunctionCollection; + iSetup.get().get(hOpticalFunctionCollection); + + // interpolate optical functions, if needed + if (lhcInfoWatcher_.check(iSetup)) + { + const LHCInfo* pLHCInfo = hLHCInfo.product(); + if (pLHCInfo->crossingAngle() != currentCrossingAngle_) + { + currentCrossingAngle_ = pLHCInfo->crossingAngle(); + + opticalFunctions_.clear(); + hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); + for (auto &p : opticalFunctions_) + p.second.initializeSplines(); + } + } + + // stop if conditions invalid + if (currentCrossingAngle_ <= 0.) + return; + + // get input + Handle> hRecoProtons; + iEvent.getByToken(tokenRecoProtons_, hRecoProtons); + + // process tracks + for (const auto &pr : *hRecoProtons) + { + if (! pr.validFit()) + continue; + + if (pr.chi2() > chiSqCut_) + continue; + + for (const auto &tr : pr.contributingLocalTracks()) + { + CTPPSDetId rpId(tr->getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + auto it = opticalFunctions_.find(rpId); + + LHCOpticalFunctionsSet::Kinematics k_in_beam = { 0., 0., 0., 0., 0. }; + LHCOpticalFunctionsSet::Kinematics k_out_beam; + it->second.transport(k_in_beam, k_out_beam); + + LHCOpticalFunctionsSet::Kinematics k_in = { pr.vx() * 1E-2, -pr.thetaX(), pr.vy() * 1E-2, pr.thetaY(), pr.xi() }; // conversions: cm --> m, CMS --> LHC convention + LHCOpticalFunctionsSet::Kinematics k_out; + it->second.transport(k_in, k_out); + + const double de_x = (k_out.x - k_out_beam.x) * 1E3 - tr->getX(); // conversions: m --> mm + const double de_y = (k_out.y - k_out_beam.y) * 1E3 - tr->getY(); // conversions: m --> mm + + rp_plots_[rpDecId].fill(de_x, de_y); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionValidator::endJob() +{ + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + for (const auto &p : rp_plots_) + { + char buf[100]; + sprintf(buf, "%u", p.first); + gDirectory = f_out->mkdir(buf); + p.second.write(); + } + + delete f_out; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionValidator); diff --git a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc new file mode 100644 index 0000000000000..e01d18d000eb1 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc @@ -0,0 +1,173 @@ +/**************************************************************************** + * + * This is a part of CTPPS validation software + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "TFile.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TProfile2D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSTrackDistributionPlotter(const edm::ParameterSet&); + + ~CTPPSTrackDistributionPlotter() {} + + private: + virtual void analyze( const edm::Event&, const edm::EventSetup& ) override; + + virtual void endJob() override; + + edm::EDGetTokenT< std::vector > tracksToken_; + + std::string outputFile_; + + struct RPPlots + { + TH2D *h2_y_vs_x; + TProfile *p_y_vs_x; + TH1D *h_x; + + void init() + { + h2_y_vs_x = new TH2D("", "", 300, -10., +70., 300, -30, +30.); + p_y_vs_x = new TProfile("", "", 300, -10., +70.); + h_x = new TH1D("", "", 600, -10., +70.); + } + + void fill(double x, double y) + { + if (h2_y_vs_x == NULL) + init(); + + h2_y_vs_x->Fill(x, y); + p_y_vs_x->Fill(x, y); + h_x->Fill(x); + } + + void write() const + { + h2_y_vs_x->Write("h2_y_vs_x"); + p_y_vs_x->Write("p_y_vs_x"); + h_x->Write("h_x"); + } + }; + + std::map rpPlots; + + + struct ArmPlots + { + TProfile2D *p2_de_x_vs_x_y; + TProfile2D *p2_de_y_vs_x_y; + + void init() + { + p2_de_x_vs_x_y = new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.); + p2_de_y_vs_x_y = new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.); + } + + void fill(double x_N, double y_N, double x_F, double y_F) + { + if (p2_de_x_vs_x_y == NULL) + init(); + + p2_de_x_vs_x_y->Fill(x_N, y_N, x_F - x_N); + p2_de_y_vs_x_y->Fill(x_N, y_N, y_F - y_N); + } + + void write() const + { + p2_de_x_vs_x_y->Write("p2_de_x_vs_x_y"); + p2_de_y_vs_x_y->Write("p2_de_y_vs_x_y"); + } + }; + + std::map armPlots; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSTrackDistributionPlotter::CTPPSTrackDistributionPlotter( const edm::ParameterSet& iConfig ) : + tracksToken_( consumes< std::vector >( iConfig.getParameter( "tagTracks" ) ) ), + outputFile_( iConfig.getParameter("outputFile") ) +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSTrackDistributionPlotter::analyze( const edm::Event& iEvent, const edm::EventSetup& ) +{ + // get input + edm::Handle< std::vector > tracks; + iEvent.getByToken( tracksToken_, tracks ); + + // process tracks + for (const auto& trk : *tracks) + { + CTPPSDetId rpId(trk.getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + rpPlots[rpDecId].fill(trk.getX(), trk.getY()); + } + + for (const auto& t1 : *tracks) + { + CTPPSDetId rpId1(t1.getRPId()); + + for (const auto& t2 : *tracks) + { + CTPPSDetId rpId2(t2.getRPId()); + + if (rpId1.arm() != rpId2.arm()) + continue; + + if (rpId1.station() == 0 && rpId2.station() == 2) + armPlots[rpId1.arm()].fill(t1.getX(), t1.getY(), t2.getX(), t2.getY()); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSTrackDistributionPlotter::endJob() +{ + TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + + for (const auto it : rpPlots) + { + gDirectory = f_out->mkdir(Form("RP %u", it.first)); + it.second.write(); + } + + for (const auto it : armPlots) + { + gDirectory = f_out->mkdir(Form("arm %u", it.first)); + it.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSTrackDistributionPlotter ); From 60ae4d17f2b4b9e688f2fdb5cb5d1dbc574dd5d3 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 10 Dec 2018 20:49:05 +0100 Subject: [PATCH 109/686] Added validation configs. --- .../ctppsBeamParametersESSource_cfi.py | 40 +++++++ .../year_2016/randomXiThetaGunProducer_cfi.py | 17 +++ .../python/year_2016/simulation_levels_cff.py | 56 +++++++++ .../test_beam_smearing_cfg.py | 59 ++++++++++ .../test_acceptance_cfg.py | 98 ++++++++++++++++ .../test_smearing_effects_cfg.py | 109 ++++++++++++++++++ .../test_xy_pattern_cfg.py | 91 +++++++++++++++ .../test_proton_gun_cfg.py | 48 ++++++++ .../test_reconstruction_cfg.py | 82 +++++++++++++ .../misalignment/alignment_template.xml | 13 +++ .../misalignment/run_multiple | 60 ++++++++++ .../misalignment/template_cfg.py | 100 ++++++++++++++++ .../resolution/run_multiple | 55 +++++++++ .../resolution/template_cfg.py | 95 +++++++++++++++ 14 files changed, 923 insertions(+) create mode 100644 Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py create mode 100644 Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py create mode 100644 Validation/CTPPS/python/year_2016/simulation_levels_cff.py create mode 100644 Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py create mode 100644 Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml create mode 100755 Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple create mode 100644 Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py create mode 100755 Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple create mode 100644 Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py diff --git a/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py new file mode 100644 index 0000000000000..87bb24a1ff962 --- /dev/null +++ b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py @@ -0,0 +1,40 @@ +import FWCore.ParameterSet.Config as cms + +ctppsBeamParametersESSource = cms.ESSource("CTPPSBeamParametersESSource", + setBeamPars = cms.untracked.bool(True), + + # beam momentum (GeV) + beamMom45 = cms.double(6500.), + beamMom56 = cms.double(6500.), + + # beta* (cm) + betaStarX45 = cms.double(0.), + betaStarX56 = cms.double(0.), + betaStarY45 = cms.double(0.), + betaStarY56 = cms.double(0.), + + # beam divergence (rad) + beamDivX45 = cms.double(20E-6), + beamDivX56 = cms.double(20E-6), + beamDivY45 = cms.double(20E-6), + beamDivY56 = cms.double(20E-6), + + # half crossing angle (rad) + halfXangleX45 = cms.double(179.394E-6), + halfXangleX56 = cms.double(191.541E-6), + halfXangleY45 = cms.double(0.), + halfXangleY56 = cms.double(0.), + + # vertex offset (cm) + vtxOffsetX45 = cms.double(0.), + vtxOffsetX56 = cms.double(0.), + vtxOffsetY45 = cms.double(0.), + vtxOffsetY56 = cms.double(0.), + vtxOffsetZ45 = cms.double(0.), + vtxOffsetZ56 = cms.double(0.), + + # vertex sigma (cm) + vtxStddevX = cms.double(10E-4), + vtxStddevY = cms.double(10E-4), + vtxStddevZ = cms.double(5) +) diff --git a/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py b/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py new file mode 100644 index 0000000000000..a7c10f034b0a9 --- /dev/null +++ b/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py @@ -0,0 +1,17 @@ +import FWCore.ParameterSet.Config as cms + +generator = cms.EDProducer("RandomXiThetaGunProducer", + particleId = cms.uint32(2212), + + energy = cms.double(6500), # nominal beam energy, GeV + + xi_min = cms.double(0.), + xi_max = cms.double(0.20), + theta_x_mean = cms.double(0), + theta_x_sigma = cms.double(50E-6), # in rad + theta_y_mean = cms.double(0), + theta_y_sigma = cms.double(50E-6), + + nParticlesSector45 = cms.uint32(1), + nParticlesSector56 = cms.uint32(1), +) diff --git a/Validation/CTPPS/python/year_2016/simulation_levels_cff.py b/Validation/CTPPS/python/year_2016/simulation_levels_cff.py new file mode 100644 index 0000000000000..53ebfdfb08e9f --- /dev/null +++ b/Validation/CTPPS/python/year_2016/simulation_levels_cff.py @@ -0,0 +1,56 @@ +import FWCore.ParameterSet.Config as cms + +# supply beam parameters +from Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi import * + +# particle generator +from Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi import * + +# direct simulation +from Validation.CTPPS.ctppsDirectProtonSimulation_cfi import * +ctppsDirectProtonSimulation.verbosity = 0 +ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +ctppsDirectProtonSimulation.useEmpiricalApertures = False +ctppsDirectProtonSimulation.roundToPitch = True +ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +ctppsDirectProtonSimulation.produceScoringPlaneHits = False +ctppsDirectProtonSimulation.produceRecHits = True + +#---------------------------------------------------------------------------------------------------- + +def SetLevel1(): + ctppsBeamParametersESSource.vtxStddevX = 0E-4 + ctppsBeamParametersESSource.vtxStddevZ = 0 + + ctppsBeamParametersESSource.beamDivX45 = 0E-6 + ctppsBeamParametersESSource.beamDivX56 = 0E-6 + ctppsBeamParametersESSource.beamDivY45 = 0E-6 + ctppsBeamParametersESSource.beamDivY56 = 0E-6 + + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel2(): + ctppsBeamParametersESSource.beamDivX45 = 0E-6 + ctppsBeamParametersESSource.beamDivX56 = 0E-6 + ctppsBeamParametersESSource.beamDivY45 = 0E-6 + ctppsBeamParametersESSource.beamDivY56 = 0E-6 + + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel3(): + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel4(): + pass + +def SetLowTheta(): + process.generator.theta_x_sigma = 0E-6 + process.generator.theta_y_sigma = 0E-6 + + +def SetLargeTheta(): + pass diff --git a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py new file mode 100644 index 0000000000000..ce12faf88ddad --- /dev/null +++ b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py @@ -0,0 +1,59 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestBeamSmearing', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# beam-smearing validation +process.ctppsBeamSmearingValidator = cms.EDAnalyzer("CTPPSBeamSmearingValidator", + tagBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + outputFile = cms.string("test_beam_smearing.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsBeamSmearingValidator +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py new file mode 100644 index 0000000000000..4bccd59e26d28 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -0,0 +1,98 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestAcceptance', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') +process.ctppsDirectProtonSimulation.verbosity = 0 +process.ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +process.ctppsDirectProtonSimulation.useEmpiricalApertures = False +process.ctppsDirectProtonSimulation.roundToPitch = True +process.ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +process.ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +process.ctppsDirectProtonSimulation.produceScoringPlaneHits = False +process.ctppsDirectProtonSimulation.produceRecHits = True + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# acceptance plotter +process.ctppsAcceptancePlotter = cms.EDAnalyzer("CTPPSAcceptancePlotter", + tagHepMC = cms.InputTag("generator", "unsmeared"), + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + + rpId_45_F = cms.uint32(3), + rpId_45_N = cms.uint32(2), + rpId_56_N = cms.uint32(102), + rpId_56_F = cms.uint32(103), + + outputFile = cms.string("test_acceptance.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsAcceptancePlotter +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py new file mode 100644 index 0000000000000..d3f32be1ce9b7 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -0,0 +1,109 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestAcceptance', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') + +process.ctppsDirectProtonSimulationSm = process.ctppsDirectProtonSimulation.clone( + verbosity = 0, + hepMCTag = cms.InputTag('beamDivergenceVtxGenerator'), + useEmpiricalApertures = False, + roundToPitch = True, + pitchStrips = 66E-3 * 12 / 19, # effective value to reproduce real RP resolution + produceHitsRelativeToBeam = True, + produceScoringPlaneHits = True, + produceRecHits = True, +) + +process.ctppsDirectProtonSimulationNoSm = process.ctppsDirectProtonSimulationSm.clone( + hepMCTag = cms.InputTag("generator", "unsmeared"), + produceScoringPlaneHits = True, + produceRecHits = False, +) + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulationSm') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# plotters +process.ctppsDirectProtonSimulationValidatorBeamSm = cms.EDAnalyzer("CTPPSDirectProtonSimulationValidator", + simuTracksTag = cms.InputTag("ctppsDirectProtonSimulationNoSm"), + recoTracksTag = cms.InputTag("ctppsDirectProtonSimulationSm"), + outputFile = cms.string("test_smearing_effects_beam.root") +) + +process.ctppsDirectProtonSimulationValidatorSensorSm = cms.EDAnalyzer("CTPPSDirectProtonSimulationValidator", + simuTracksTag = cms.InputTag("ctppsDirectProtonSimulationSm"), + recoTracksTag = cms.InputTag("ctppsLocalTrackLiteProducer"), + outputFile = cms.string("test_smearing_effects_sensor.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulationNoSm + * process.ctppsDirectProtonSimulationSm + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsDirectProtonSimulationValidatorBeamSm + * process.ctppsDirectProtonSimulationValidatorSensorSm +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py new file mode 100644 index 0000000000000..f9bfb87500a3a --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -0,0 +1,91 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSFastSimulation', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') +process.ctppsDirectProtonSimulation.verbosity = 0 +process.ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +process.ctppsDirectProtonSimulation.useEmpiricalApertures = False +process.ctppsDirectProtonSimulation.roundToPitch = True +process.ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +process.ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +process.ctppsDirectProtonSimulation.produceScoringPlaneHits = False +process.ctppsDirectProtonSimulation.produceRecHits = True + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# distribution plotter +process.ctppsTrackDistributionPlotter = cms.EDAnalyzer("CTPPSTrackDistributionPlotter", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + outputFile = cms.string("test_xy_pattern.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsTrackDistributionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py new file mode 100644 index 0000000000000..c30a283d6d49d --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py @@ -0,0 +1,48 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSFastSimulation', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# provide LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), +) + +# plotter +process.ctppsHepMCDistributionPlotter = cms.EDAnalyzer("CTPPSHepMCDistributionPlotter", + tagHepMC = cms.InputTag("generator", "unsmeared"), + + outputFile = cms.string("test_proton_gun.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.ctppsHepMCDistributionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py new file mode 100644 index 0000000000000..560cff87def33 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -0,0 +1,82 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("CTPPSTestProtonReconstruction", eras.ctpps_2016) + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# data source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + # more at: https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod%2Fglobal&input=file+dataset%3D%2FBTagCSV%2FRun2016C-07Aug17-v1%2FAOD + "/store/data/Run2016C/BTagCSV/AOD/07Aug17-v1/110000/0026FCD2-369A-E711-920C-0025905A607E.root" + ) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# load LHCInfo +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# load optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# load reconstruction sequences +process.load("RecoCTPPS.Configuration.recoCTPPS_sequences_cff") + +process.ctppsLocalTrackLiteProducer.includeStrips = True +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +process.ctppsProtonReconstruction.verbosity = 0 + +# load geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") # 2017 is OK here + +# load alignment corrections +process.ctppsIncludeAlignmentsFromXML.RealFiles += cms.vstring("Validation/CTPPS/test/year_2016/alignment_export_2018_12_07.1.xml") + +# reconstruction validator +process.ctppsProtonReconstructionValidator = cms.EDAnalyzer("CTPPSProtonReconstructionValidator", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + tagRecoProtons = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + + chiSqCut = cms.double(2.), + + outputFile = cms.string("test_recontruction_validation.root") +) + +# reconstruction plotter +process.ctppsProtonReconstructionPlotter = cms.EDAnalyzer("CTPPSProtonReconstructionPlotter", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + + rpId_45_F = cms.uint32(3), + rpId_45_N = cms.uint32(2), + rpId_56_N = cms.uint32(102), + rpId_56_F = cms.uint32(103), + + outputFile = cms.string("test_reconstruction_plots.root") +) + +# processing sequence +process.p = cms.Path( + process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + + * process.ctppsLocalTrackLiteProducer + * process.ctppsProtonReconstruction + + * process.ctppsProtonReconstructionValidator + * process.ctppsProtonReconstructionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml new file mode 100644 index 0000000000000..f2eaf3e5fe243 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple new file mode 100755 index 0000000000000..a47b825e61a0d --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple @@ -0,0 +1,60 @@ +#!/bin/bash + +function RunOne() +{ + local tag="$1" + local de_x_N="$2" + local de_x_F="$3" + local de_y_N="$4" + local de_y_F="$5" + + local cfgFile="${tag}_cfg.py" + local logFile="${tag}.log" + local aligFile="${tag}.xml" + + cat "alignment_template.xml" | sed "\ + s|\$de_x_N|$de_x_N|; \ + s|\$de_x_F|$de_x_F|; \ + s|\$de_y_N|$de_y_N|; \ + s|\$de_y_F|$de_y_F|; \ + " > "$dir/$aligFile" + + cp "template_cfg.py" "$dir/$cfgFile" + + ( + echo "process.maxEvents.input = $events" + + echo "process.ctppsIncludeAlignmentsFromXML.MisalignedFiles += cms.vstring(\"Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/$dir/$aligFile\")" + echo "process.ctppsProtonReconstructionSimulationValidator.outputFile = \"${tag}_validation.root\"" + ) >> "$dir/$cfgFile" + + cd "$dir" + + cmsRun "$cfgFile" &> "$logFile" & + + cd - &> /dev/null +} + + +#---------------------------------------------------------------------------------------------------- + +function Run() +{ + events="$1" + dir="$2" + + rm -rf "$dir" + mkdir "$dir" + + RunOne "none" "0" "0" "0" "0" + RunOne "x_sym" "+150" "+150" "0" "0" + RunOne "x_asym" "-10" "+10" "0" "0" + RunOne "y_sym" "0" "0" "+100" "+100" + RunOne "y_asym" "0" "0" "-10" "+10" +} + +#---------------------------------------------------------------------------------------------------- + +#Run "100" "1E2" + +Run "10000" "1E4" diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py new file mode 100644 index 0000000000000..a8abc286fb988 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -0,0 +1,100 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSProtonReconstructionTest', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +process.load("Geometry.VeryForwardGeometryBuilder.ctppsIncludeAlignmentsFromXML_cfi") + +# beam-smearing settings +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# simulation-level settings +from Validation.CTPPS.year_2016.simulation_levels_cff import * + +process.ctppsBeamParametersESSource = ctppsBeamParametersESSource +process.generator = generator +process.ctppsDirectProtonSimulation = ctppsDirectProtonSimulation + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# proton reconstruction +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi") +process.ctppsProtonReconstruction.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtonReconstruction.fitVtxY = False + +# reconstruction validation +process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", + tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + + outputFile = cms.string("") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsProtonReconstruction + + * process.ctppsProtonReconstructionSimulationValidator +) + +#---------- + +SetLargeTheta() +SetLevel4() + diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple new file mode 100755 index 0000000000000..92740468946af --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple @@ -0,0 +1,55 @@ +#!/bin/bash + +function RunOne() +{ + local thSize="$1" + local level="$2" + + local tag="th_${thSize}_level_${level}" + + local cfgFile="${tag}_cfg.py" + local logFile="${tag}.log" + + cp "template_cfg.py" "$dir/$cfgFile" + + ( + echo "process.maxEvents.input = $events" + echo "Set${thSize}Theta()" + echo "SetLevel${level}()" + echo "process.ctppsProtonReconstructionSimulationValidator.outputFile = \"${tag}_validation.root\"" + ) >> "$dir/$cfgFile" + + cd "$dir" + + cmsRun "$cfgFile" &> "$logFile" & + + cd - &> /dev/null +} + + +#---------------------------------------------------------------------------------------------------- + +function Run() +{ + events="$1" + dir="$2" + + rm -rf "$dir" + mkdir "$dir" + + #RunOne "Low" "1" + #RunOne "Low" "2" + #RunOne "Low" "3" + #RunOne "Low" "4" + + RunOne "Large" "1" + RunOne "Large" "2" + RunOne "Large" "3" + RunOne "Large" "4" +} + +#---------------------------------------------------------------------------------------------------- + +#Run "100" "1E2" + +Run "10000" "1E4" diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py new file mode 100644 index 0000000000000..2de1f1cb2ca9d --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -0,0 +1,95 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSProtonReconstructionTest', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info +process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") + +# supply optics +process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing settings +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# simulation-level settings +from Validation.CTPPS.year_2016.simulation_levels_cff import * + +process.ctppsBeamParametersESSource = ctppsBeamParametersESSource +process.generator = generator +process.ctppsDirectProtonSimulation = ctppsDirectProtonSimulation + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# proton reconstruction +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi") +process.ctppsProtonReconstruction.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtonReconstruction.fitVtxY = False + +# reconstruction validation +process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", + tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + + outputFile = cms.string("") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsProtonReconstruction + + * process.ctppsProtonReconstructionSimulationValidator +) + +#---------- + From f9fe5b8a9b2e8f1b3bae07f89e2caee93b06855d Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 11 Dec 2018 11:03:03 +0100 Subject: [PATCH 110/686] TODO's addressed. --- Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc | 3 --- .../CTPPS/plugins/CTPPSProtonReconstructionValidator.cc | 7 ------- 2 files changed, 10 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc index 49d1a505649d0..cdc958ed1179f 100644 --- a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -231,9 +231,6 @@ void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventS if (mom.e() < 4500.) continue; - // TODO - //printf(" status = %u, mom = %E, %E, %E\n", part->status(), mom.x(), mom.y(), mom.z()); - if (mom.z() > 0) { // 45 diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index a457eb3179e7b..26497822c1753 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -3,8 +3,6 @@ * Jan KaÅ¡par ****************************************************************************/ - -// TODO: clean #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -16,8 +14,6 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" -#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" - #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" @@ -28,9 +24,6 @@ #include "TFile.h" #include "TH1D.h" -#include "TH2D.h" -#include "TProfile.h" -#include "TGraphErrors.h" #include #include From fceda2210183bbd777a29fc4927f0d70b03325c9 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 11 Dec 2018 11:15:35 +0100 Subject: [PATCH 111/686] Supplied fillDescriptions method, removed static _cfi.py file. --- .../plugins/CTPPSProtonReconstruction.cc | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index d84fa1d624ddf..a8cdc45e6b5bb 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -88,12 +88,24 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& descriptions) { - // TODO: fill in - // TODO: then remove the static cfi file - ParameterSetDescription desc; - desc.setUnknown(); - descriptions.addDefault(desc); + + desc.addUntracked("verbosity", 0) + ->setComment("verbosity level"); + + desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) + ->setComment("specification of the input lite-track collection"); + + desc.add("doSingleRPReconstruction", true) + ->setComment("flag whether to apply single-RP reconstruction strategy"); + + desc.add("doMultiRPReconstruction", true) + ->setComment("flag whether to apply multi-RP reconstruction strategy"); + + desc.add("fitVtxY", true) + ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); + + descriptions.add("ctppsProtonReconstruction", desc); } //---------------------------------------------------------------------------------------------------- From 10ecf130accac24e1f21a340b87d5602030aaf87 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 11 Dec 2018 12:29:16 +0100 Subject: [PATCH 112/686] printf replaced with LogInfo and LogError. --- .../interface/RandomXiThetaGunProducer.h | 3 -- .../src/RandomXiThetaGunProducer.cc | 9 +--- .../interface/ProtonReconstructionAlgorithm.h | 4 +- .../plugins/CTPPSProtonReconstruction.cc | 26 ++++++---- .../src/ProtonReconstructionAlgorithm.cc | 29 +++++------ .../CTPPS/plugins/CTPPSAcceptancePlotter.cc | 10 +--- .../plugins/CTPPSDirectProtonSimulation.cc | 51 +++++++++++-------- .../CTPPSProtonReconstructionPlotter.cc | 4 +- ...ProtonReconstructionSimulationValidator.cc | 6 +-- 9 files changed, 72 insertions(+), 70 deletions(-) diff --git a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h index a2791f75f7ce1..67ef56a7930c3 100644 --- a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h +++ b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h @@ -1,9 +1,6 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software. * Authors: * Jan KaÅ¡par - * ****************************************************************************/ #ifndef RandomXiThetaGunProducer_H diff --git a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc index 634a25b53a31d..a88197806acad 100644 --- a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc +++ b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc @@ -1,9 +1,6 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software. * Authors: * Jan KaÅ¡par - * ****************************************************************************/ #include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" @@ -47,9 +44,6 @@ RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet& pset void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) { - if (verbosity) - printf("===================== %u:%llu =====================\n", e.id().run(), e.id().event()); - // get conditions edm::Service rng; CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); @@ -98,7 +92,8 @@ void RandomXiThetaGunProducer::GenerateParticle(double z_sign, double mass, unsi const double theta_y = CLHEP::RandGauss::shoot(engine, theta_y_mean, theta_y_sigma); if (verbosity) - printf("xi = %.4f, theta_x = %E, theta_y = %E, z_sign = %.0f\n", xi, theta_x, theta_y, z_sign); + LogInfo("RandomXiThetaGunProducer") << "xi = " << xi << ", theta_x = " << theta_x + << ", theta_y" << theta_y << ", z_sign = " << z_sign; const double cos_theta = sqrt(1. - theta_x*theta_x - theta_y*theta_y); diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index a3979972eb480..6a78e94c1e337 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -34,13 +34,13 @@ class ProtonReconstructionAlgorithm void reconstructFromSingleRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const; + const LHCInfo &lhcInfo, std::stringstream &ssLog) const; /// runs proton reconstruction using multiple-RP strategy void reconstructFromMultiRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const; + const LHCInfo &lhcInfo, std::stringstream &ssLog) const; void init(const std::unordered_map &opticalFunctions); diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index a8cdc45e6b5bb..89dceab0b8b90 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -112,9 +112,6 @@ void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& desc void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSetup) { - if (verbosity_) - printf("\n---------- %u:%llu ----------\n", event.id().run(), event.id().event()); - // get conditions edm::ESHandle hLHCInfo; eventSetup.get().get(hLHCInfo); @@ -137,7 +134,7 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } if (verbosity_) - printf("CTPPSProtonReconstruction::produce >> Setting crossing angle %.1f\n", currentCrossingAngle_); + edm::LogInfo("CTPPSProtonReconstruction") << "Setting crossing angle " << currentCrossingAngle_; // interpolate optical functions opticalFunctions_.clear(); @@ -150,6 +147,12 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } } + // prepare log + std::stringstream ssLog; + + if (verbosity_) + ssLog << "input tracks:" << std::endl; + // get input Handle> hTracks; event.getByToken(tracksToken_, hTracks); @@ -167,7 +170,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (verbosity_) { unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - printf("%u (%u): x=%.3f, y=%.3f mm\n", tr.getRPId(), decRPId, tr.getX(), tr.getY()); + ssLog << " " << tr.getRPId() << " (" << decRPId << "): " + << "x = " << tr.getX() << " +- " << tr.getXUnc() << " mm" + << ", y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; } if (rpId.arm() == 0) @@ -198,8 +203,8 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet unique_ptr> output(new vector); unique_ptr> outputExtra(new vector); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); auto ohExtra = event.put(move(outputExtra), singleRPLabel); @@ -216,9 +221,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet unique_ptr> outputExtra(new vector); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); auto ohExtra = event.put(move(outputExtra), multiRPLabel); @@ -227,6 +232,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet event.put(move(output), multiRPLabel); } + + if (verbosity_) + edm::LogInfo("CTPPSProtonReconstruction") << ssLog.str(); } //---------------------------------------------------------------------------------------------------- diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 625d86eea2789..94b439a7f40b6 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -147,7 +147,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const + const LHCInfo &lhcInfo, std::stringstream &ssLog) const { if (!initialized_) return; @@ -240,8 +240,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( if (verbosity_) { - printf("* ProtonReconstructionAlgorithm::reconstructFromMultiRP(%u)\n", armId); - printf(" initial estimate: xi_init = %f, th_x_init = %E, th_y_init = %E, vtx_y_init = %E\n", xi_init, th_x_init, th_y_init, vtx_y_init); + ssLog << std::endl + << "ProtonReconstructionAlgorithm::reconstructFromMultiRP(" << armId << ")" << std::endl + << " initial estimate: xi_init = " << xi_init << ", th_x_init = " << th_x_init + << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "" << std::endl; } // minimisation @@ -264,15 +266,12 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const double *params = result.GetParams(); if (verbosity_) - edm::LogInfo("ProtonReconstructionAlgorithm") - << "at reconstructed level: " - << "xi=" << params[0] << ", " - << "theta_x=" << params[1] << ", " - << "theta_y=" << params[2] << ", " - << "vertex_y=" << params[3] << "\n"; - - if (verbosity_) - printf(" fit: xi = %f, th_x = %E, th_y = %E, vtx_y = %E, chiSq = %.0f\n", params[0], params[1], params[2], params[3], result.Chi2()); + ssLog << " fit: " + << "xi=" << params[0] << " +- " << result.Error(0) + << ", th_x=" << params[1] << " +-" << result.Error(1) + << ", th_y=" << params[2] << " +-" << result.Error(2) + << ", vtx_y=" << params[3] << " +-" << result.Error(3) + << ", chiSq = " << result.Chi2() << std::endl; // save reco candidate using EX = reco::ProtonTrackExtra; @@ -327,7 +326,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const + const LHCInfo &lhcInfo, std::stringstream &ssLog) const { if (!initialized_) return; @@ -348,7 +347,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); if (verbosity_) - printf("* reconstructFromSingleRP(%u)\n", decRPId); + ssLog << std::endl << "reconstructFromSingleRP(" << decRPId << ")" << endl; auto oit = m_rp_optics_.find(track->getRPId()); const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m @@ -365,7 +364,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); if (verbosity_) - printf(" xi = %f +- %f, th_y = %E +- %E\n", xi, xi_unc, th_y, th_y_unc); + ssLog << " xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "" << endl; using EX = reco::ProtonTrackExtra; using PT = reco::ProtonTrack; diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc index cdc958ed1179f..93677e85917dc 100644 --- a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -1,12 +1,8 @@ /**************************************************************************** - * - * This is a part of CTPPS validation software * Authors: * Jan KaÅ¡par - * ****************************************************************************/ - #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" @@ -197,8 +193,6 @@ CTPPSAcceptancePlotter::~CTPPSAcceptancePlotter() void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventSetup&) { - //printf("------------------------ run=%u, event=%llu -----------------------\n", iEvent.id().run(), iEvent.id().event()); - // get input edm::Handle hHepMC; iEvent.getByToken(tokenHepMC, hHepMC); @@ -236,7 +230,7 @@ void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventS // 45 if (proton_45_set) { - printf("ERROR: multiple protons in sector 45 found.\n"); + LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 45."; return; } @@ -246,7 +240,7 @@ void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventS // 56 if (proton_56_set) { - printf("ERROR: multiple protons in sector 56 found.\n"); + LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 56."; return; } diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index 885bf3a62e6d0..bea2ea917d515 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -1,10 +1,7 @@ /**************************************************************************** - * - * This is a part of CTPPS offline software * Authors: * Jan KaÅ¡par * Laurent Forthomme - * ****************************************************************************/ @@ -242,6 +239,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, { /// xi is positive for diffractive protons, thus proton momentum p = (1-xi) * p_nom /// horizontal component of proton momentum: p_x = th_x * (1-xi) * p_nom + + std::stringstream ssLog; // vectors in CMS convention const HepMC::FourVector vtx_cms = in_vtx->position(); // in mm @@ -285,8 +284,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (verbosity_) { - printf("simu: xi=%.4f, th_x=%.3E, %.3E, vtx_lhc_eff_x=%.3E, vtx_lhc_eff_y=%.3E\n", - xi, th_x_phys, th_y_phys, vtx_lhc_eff_x, vtx_lhc_eff_y); + ssLog << "simu: xi = " << xi << ", th_x_phys = " << th_x_phys << ", th_y_phys = " << th_y_phys + << ", vtx_lhc_eff_x = " << vtx_lhc_eff_x << ", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl; } // check empirical aperture @@ -294,7 +293,15 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, { const double xi_th = empiricalAperture_xi0 + th_x_phys * empiricalAperture_a; if (xi > xi_th) + { + if (verbosity_) + { + ssLog << "stop because of empirical appertures"; + edm::LogInfo("CTPPSDirectProtonSimulation") << ssLog.str(); + } + return; + } } // transport the proton into each pot/scoring plane @@ -302,14 +309,14 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, { CTPPSDetId rpId(ofp.first); const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - - if (verbosity_) - printf(" RP %u\n", rpDecId); // first check the arm if (rpId.arm() != arm) continue; + if (verbosity_) + ssLog << " RP " << rpDecId << std::endl; + // transport proton LHCOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x * 1E-3, th_x_phys, vtx_lhc_eff_y * 1E-3, th_y_phys, xi }; // conversions: mm -> m LHCOpticalFunctionsSet::Kinematics k_out; @@ -334,8 +341,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (verbosity_) { - printf(" proton transported: a_x = %.3E rad, a_y = %.3E rad, b_x = %.3f mm, b_y = %.3f mm, z = %.3f mm\n", - a_x, a_y, b_x, b_y, z_scoringPlane); + ssLog << " proton transported: a_x = " << a_x << " rad, a_y = " << a_y << " rad, b_x = " << b_x << + " mm, b_y = " << b_y << " mm, z = " << z_scoringPlane << " mm" << std::endl; } // save scoring plane hit @@ -375,10 +382,10 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (verbosity_) { - printf("\n"); - printf(" de z = %f mm, p1 = %f mm, p2 = %f mm\n", P(0), P(1), P(2)); - printf(" h_glo: x = %f mm, y = %f mm, z = %f mm\n", h_glo.x(), h_glo.y(), h_glo.z()); - printf(" h_loc: c1 = %f mm, c2 = %f mm, c3 = %f mm\n", h_loc.x(), h_loc.y(), h_loc.z()); + ssLog << std::endl + << " de z = " << P(0) << " mm, p1 = " << P(1) << " mm, p2 = " << P(2) << " mm" << std::endl + << " h_glo: x = " << h_glo.x() << " mm, y = " << h_glo.y() << " mm, z = " << h_glo.z() << " mm" << std::endl + << " h_loc: c1 = " << h_loc.x() << " mm, c2 = " << h_loc.y() << " mm, c3 = " << h_loc.z() << " mm" << std::endl; } // strips @@ -388,13 +395,13 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, double v = h_loc.y(); if (verbosity_ > 5) - printf(" u=%+8.4f, v=%+8.4f", u, v); + ssLog << " u=" << u << ", v=" << v; // is it within detector? if (checkIsHit_ && !RPTopology::IsHit(u, v, insensitiveMarginStrips_)) { if (verbosity_ > 5) - printf(" | no hit\n"); + ssLog << " | no hit" << std::endl; continue; } @@ -407,13 +414,13 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, v = stripZeroPosition_ - pitchStrips_ * strip; if (verbosity_ > 5) - printf(" | strip=%+4i", strip); + ssLog << " | strip=" << strip; } double sigma = pitchStrips_ / sqrt(12.); if (verbosity_ > 5) - printf(" | m=%+8.4f, sigma=%+8.4f\n", v, sigma); + ssLog << " | m=" << v << ", sigma=" << sigma << std::endl; edm::DetSet &hits = out_strip_hits.find_or_insert(detId); hits.push_back(TotemRPRecHit(v, sigma)); @@ -431,7 +438,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (verbosity_) { CTPPSPixelDetId pixelDetId(detIdInt); - printf(" pixel plane %u: local hit x = %.3f mm, y = %.3f mm, z = %.1E mm\n", pixelDetId.plane(), h_loc.x(), h_loc.y(), h_loc.z()); + ssLog << " pixel plane " << pixelDetId.plane() << ": local hit x = " << h_loc.x() + << " mm, y = " << h_loc.y() << " mm, z = " << h_loc.z() << " mm" << std::endl; } if (checkIsHit_ && !isPixelHit(h_loc.x(), h_loc.y())) @@ -444,7 +452,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, } if (verbosity_ > 5) - printf(" hit accepted: m1 = %.3f mm, m2 = %.3f mm\n", h_loc.x(), h_loc.y()); + ssLog << " hit accepted: m1 = " << h_loc.x() << " mm, m2 = " << h_loc.y() << " mm" << std::endl; const double sigmaHor = pitchPixelsHor_ / sqrt(12.); const double sigmaVer = pitchPixelsVer_ / sqrt(12.); @@ -457,6 +465,9 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, } } } + + if (verbosity_) + edm::LogInfo("CTPPSDirectProtonSimulation") << ssLog.str(); } //---------------------------------------------------------------------------------------------------- diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc index cb90bc9e65a90..7ba36bec3c4c9 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -1,8 +1,6 @@ /**************************************************************************** -* * Authors: * Jan KaÅ¡par (jan.kaspar@gmail.com) -* ****************************************************************************/ #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -498,7 +496,7 @@ void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const ed void CTPPSProtonReconstructionPlotter::endJob() { - printf(">> CTPPSProtonReconstructionPlotter: n_non_empty_events = %u\n", n_non_empty_events_); + LogInfo("CTPPSProtonReconstructionPlotter") << "n_non_empty_events = " << n_non_empty_events_; TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index d1be1502dabf7..94c8fd223cebd 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -196,7 +196,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv { if (vertex_set) { - printf("ERROR: multiple vertices found.\n"); + LogError("CTPPSProtonReconstructionSimulationValidator") << "Multiple vertices found."; return; } @@ -233,7 +233,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv // 45 if (proton_45_set) { - printf("ERROR: multiple protons in sector 45 found.\n"); + LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 45."; return; } @@ -243,7 +243,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv // 56 if (proton_56_set) { - printf("ERROR: multiple protons in sector 56 found.\n"); + LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 56."; return; } From 9e0571b92a4e09bcb3fbfc0a74582b7294c99a56 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 11 Dec 2018 15:39:18 +0100 Subject: [PATCH 113/686] doNothing mechanism replaced by the use of includeXYZ flags. --- .../plugins/CTPPSLocalTrackLiteProducer.cc | 17 +++++++++++------ .../python/ctppsLocalTrackLiteProducer_cff.py | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 0bdbb2fe0c893..386a18629d7fc 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -189,19 +189,24 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d { edm::ParameterSetDescription desc; - desc.add("includeStrips", true)->setComment("whether tracks from Si strips should be included"); + // By default: module enabled (doNothing=false), but all includeXYZ flags set to false. + // The includeXYZ are switched on when the "ctpps_2016" era is declared in python config, see: + // RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py + + desc.add("includeStrips", false)->setComment("whether tracks from Si strips should be included"); desc.add( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) ) ->setComment( "input TOTEM strips' local tracks collection to retrieve" ); - desc.add("includeDiamonds", true)->setComment("whether tracks from diamonds strips should be included"); + desc.add("includeDiamonds", false)->setComment("whether tracks from diamonds strips should be included"); desc.add( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) ) ->setComment( "input diamond detectors' local tracks collection to retrieve" ); - desc.add("includePixels", true)->setComment("whether tracks from pixels should be included"); - desc.add( "tagPixelTrack" , edm::InputTag( "ctppsPixelLocalTracks" ) ) + desc.add("includePixels", false)->setComment("whether tracks from pixels should be included"); + desc.add( "tagPixelTrack", edm::InputTag( "ctppsPixelLocalTracks" ) ) ->setComment( "input pixel detectors' local tracks collection to retrieve" ); - desc.add( "doNothing", true ) // disable the module by default - ->setComment( "disable the module" ); + + desc.add("doNothing", false) + ->setComment("disable the module"); desc.add("pixelTrackTxMin",-10.0); desc.add("pixelTrackTxMax", 10.0); diff --git a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py index ace76c2c803dc..6379d3c2b155d 100644 --- a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py +++ b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py @@ -8,7 +8,9 @@ from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 ctpps_2016.toModify( ctppsLocalTrackLiteProducer, - doNothing = cms.bool(False) + includeStrips = cms.bool(True), + includeDiamonds = cms.bool(True), + includePixels = cms.bool(True) ) from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy From 13f8def1807117d21df3784ea35d5b77d3d494f9 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 11 Dec 2018 15:41:03 +0100 Subject: [PATCH 114/686] (Example) condition sources added to main PPS reco config (to support proton reconstruction). --- .../python/recoCTPPS_sequences_cff.py | 8 +++++++ .../test_reconstruction_cfg.py | 22 +++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index e8e81f2ac17ed..c66b73f6957d1 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -9,8 +9,16 @@ from RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi import * +# TODO: load these data from DB from CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring("Alignment/CTPPS/data/RPixGeometryCorrections.xml") +ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles += cms.vstring("Validation/CTPPS/test/year_2016/alignment_export_2018_12_07.1.xml") + +# TODO: load these data from DB +from Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi import * + +# TODO: load these data from DB +from Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi import * recoCTPPSdets = cms.Sequence( totemRPLocalReconstruction * diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index 560cff87def33..41067afbbdbcb 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -17,6 +17,10 @@ fileNames = cms.untracked.vstring( # more at: https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod%2Fglobal&input=file+dataset%3D%2FBTagCSV%2FRun2016C-07Aug17-v1%2FAOD "/store/data/Run2016C/BTagCSV/AOD/07Aug17-v1/110000/0026FCD2-369A-E711-920C-0025905A607E.root" + ), + inputCommands = cms.untracked.vstring( + "keep *", + "drop CTPPSLocalTrackLites_*_*_*" ) ) @@ -24,16 +28,8 @@ input = cms.untracked.int32(-1) ) -# load LHCInfo -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# load optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - # load reconstruction sequences process.load("RecoCTPPS.Configuration.recoCTPPS_sequences_cff") - -process.ctppsLocalTrackLiteProducer.includeStrips = True process.ctppsLocalTrackLiteProducer.includeDiamonds = False process.ctppsLocalTrackLiteProducer.includePixels = False @@ -42,9 +38,6 @@ # load geometry process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") # 2017 is OK here -# load alignment corrections -process.ctppsIncludeAlignmentsFromXML.RealFiles += cms.vstring("Validation/CTPPS/test/year_2016/alignment_export_2018_12_07.1.xml") - # reconstruction validator process.ctppsProtonReconstructionValidator = cms.EDAnalyzer("CTPPSProtonReconstructionValidator", tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), @@ -71,9 +64,10 @@ # processing sequence process.p = cms.Path( - process.totemRPUVPatternFinder - * process.totemRPLocalTrackFitter - + process.totemRPLocalReconstruction + * process.ctppsDiamondLocalReconstruction + #* process.totemTimingLocalReconstruction + #* process.ctppsPixelLocalReconstruction * process.ctppsLocalTrackLiteProducer * process.ctppsProtonReconstruction From f12ceff8403306cae8a66a6edfa102834bf39224 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 12 Dec 2018 14:12:12 +0100 Subject: [PATCH 115/686] ProtonReconstruction excluded from processing in FastSim. --- Configuration/StandardSequences/python/Reconstruction_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/StandardSequences/python/Reconstruction_cff.py b/Configuration/StandardSequences/python/Reconstruction_cff.py index 4d4edf170e296..8f14bbe6f36ad 100644 --- a/Configuration/StandardSequences/python/Reconstruction_cff.py +++ b/Configuration/StandardSequences/python/Reconstruction_cff.py @@ -90,7 +90,7 @@ ########################################### _fastSim_localreco = localreco.copyAndExclude([ castorreco, - totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction,ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction, + totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction,ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtonReconstruction, trackerlocalreco ]) fastSim.toReplaceWith(localreco, _fastSim_localreco) From 0bbcdf7983d33e22aa5013f169526e0f7e5b8d03 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 11:47:35 +0100 Subject: [PATCH 116/686] Cleanup of the CondFormats/CTPPSReadoutObjects sub-package --- .../interface/LHCOpticalFunctionsSet.h | 27 +- .../plugins/CTPPSBeamParametersESSource.cc | 273 ++++++++++-------- .../plugins/CTPPSOpticalFunctionsESSource.cc | 38 ++- .../src/LHCOpticalFunctionsSet.cc | 77 +++-- .../ctppsOpticalFunctionsESSource_cfi.py | 21 +- 5 files changed, 236 insertions(+), 200 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index f2d602aa574b1..1590cd12c866f 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -11,31 +11,24 @@ #include "TSpline.h" -/** - \brief Set of optical functions corresponding to one scoring plane along LHC. -**/ +/// Set of optical functions corresponding to one scoring plane along LHC. class LHCOpticalFunctionsSet { public: - /// indeces for m_fcn_values and m_splines data members + /// indices for m_fcn_values and m_splines data members enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd }; - LHCOpticalFunctionsSet() {} - + LHCOpticalFunctionsSet() = default; /// fills m_*_values fields from a ROOT file - LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, const double &z); - - ~LHCOpticalFunctionsSet() {} + LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, double z); + ~LHCOpticalFunctionsSet() = default; /// returns the position of the scoring plane (LHC/TOTEM convention) double getScoringPlaneZ() const { return m_z; } - const std::vector& getXiValues() const { return m_xi_values; } - const std::array, 16>& getFcnValues() const { return m_fcn_values; } - const std::array, 16>& getSplines() const { return m_splines; } - + /// builds splines from m_*_values fields void initializeSplines(); @@ -48,7 +41,7 @@ class LHCOpticalFunctionsSet double th_y; // physics scattering angle, rad double xi; // relative momentum loss (positive for diffractive protons) }; - + /// transports proton according to the splines void transport(const Kinematics &input, Kinematics &output, bool calculateAngles = false) const; @@ -59,14 +52,12 @@ class LHCOpticalFunctionsSet private: /// position of the scoring plane, in LHC/TOTEM convention, m double m_z; - std::vector m_xi_values; - std::array, 16> m_fcn_values; - std::array, 16> m_splines; - + COND_SERIALIZABLE; }; #endif + diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc index 3a8e4be5bd6e0..bf6dc7d15de08 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc @@ -2,11 +2,11 @@ * * CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc * - * Description : - Loads CTPPSBeamParameters from the CTPPSBeamParametersESSource_cfi.py - * config file. - * - Currently, one single set of beam parameters is provided. Just to be + * Description : - Loads CTPPSBeamParameters from the CTPPSBeamParametersESSource_cfi.py + * config file. + * - Currently, one single set of beam parameters is provided. Just to be * ready in time for 10_4_0 and allow simple tests. - * - To be further developed to provide multiple sets of parameters + * - To be further developed to provide multiple sets of parameters * - Needed while CTPPSBeamParameters is not available in database * * @@ -43,24 +43,30 @@ class CTPPSBeamParametersESSource: public edm::ESProducer, public edm::EventSetu { public: - CTPPSBeamParametersESSource(const edm::ParameterSet &); - ~CTPPSBeamParametersESSource() override; + CTPPSBeamParametersESSource(const edm::ParameterSet&); + ~CTPPSBeamParametersESSource() override = default; - std::unique_ptr produce(const CTPPSBeamParametersRcd &); + std::unique_ptr produce(const CTPPSBeamParametersRcd&); + static void fillDescriptions(edm::ConfigurationDescriptions&); private: - - bool setBeamPars; - - void initializeBeamParameters(); // Initialize beam parameters (BP) to zero - void setBeamParameters(const edm::ParameterSet &); // Set BP to their values from config - CTPPSBeamParameters* fillBeamParameters(); // Fill CTPPSBeamParameters object with BP - - // Beam parameters - double beamMom45, beamMom56, betaStarX45, betaStarX56, betaStarY45, betaStarY56, - beamDivX45, beamDivX56, beamDivY45, beamDivY56, halfXangleX45, halfXangleX56, - halfXangleY45, halfXangleY56, vtxOffsetX45, vtxOffsetX56, vtxOffsetY45, vtxOffsetY56, - vtxOffsetZ45, vtxOffsetZ56, vtxStddevX, vtxStddevY, vtxStddevZ ; + + bool setBeamPars_; + + /// Set BP to their values from config + void setBeamParameters(const edm::ParameterSet &); + /// Fill CTPPSBeamParameters object with BP + std::unique_ptr fillBeamParameters(); + + // Beam parameters + double beamMom45_, beamMom56_; + double betaStarX45_, betaStarY45_, betaStarX56_, betaStarY56_; + double beamDivX45_, beamDivY45_, beamDivX56_, beamDivY56_; + double halfXangleX45_, halfXangleY45_; + double halfXangleX56_, halfXangleY56_; + double vtxOffsetX45_, vtxOffsetY45_, vtxOffsetZ45_; + double vtxOffsetX56_, vtxOffsetY56_, vtxOffsetZ56_; + double vtxStddevX_, vtxStddevY_, vtxStddevZ_; protected: @@ -70,142 +76,163 @@ class CTPPSBeamParametersESSource: public edm::ESProducer, public edm::EventSetu //---------------------------------------------------------------------------------------------------- -using namespace std; -using namespace edm; - -CTPPSBeamParametersESSource::CTPPSBeamParametersESSource(const edm::ParameterSet& conf) : - setBeamPars(conf.getUntrackedParameter("setBeamPars","False")) - +CTPPSBeamParametersESSource::CTPPSBeamParametersESSource(const edm::ParameterSet& iConfig) : + setBeamPars_( iConfig.getParameter( "setBeamPars" ) ), + beamMom45_( 0. ), beamMom56_( 0. ), + betaStarX45_( 0. ), betaStarY45_( 0. ), betaStarX56_( 0. ), betaStarY56_( 0. ), + beamDivX45_( 0. ), beamDivY45_( 0. ), beamDivX56_( 0. ), beamDivY56_( 0. ), + halfXangleX45_( 0. ), halfXangleY45_( 0. ), + halfXangleX56_( 0. ), halfXangleY56_( 0. ), + vtxOffsetX45_( 0. ), vtxOffsetY45_( 0. ), vtxOffsetZ45_( 0. ), + vtxOffsetX56_( 0. ), vtxOffsetY56_( 0. ), vtxOffsetZ56_( 0. ), + vtxStddevX_( 0. ), vtxStddevY_( 0. ), vtxStddevZ_( 0. ) { + if ( setBeamPars_ ) + setBeamParameters( iConfig ); - initializeBeamParameters(); - if(setBeamPars) setBeamParameters(conf); - setWhatProduced(this); findingRecord(); - -} - -//---------------------------------------------------------------------------------------------------- - -CTPPSBeamParametersESSource::~CTPPSBeamParametersESSource() -{ } //---------------------------------------------------------------------------------------------------- -std::unique_ptr CTPPSBeamParametersESSource::produce( const CTPPSBeamParametersRcd & ) +std::unique_ptr +CTPPSBeamParametersESSource::produce( const CTPPSBeamParametersRcd & ) { - - CTPPSBeamParameters *bp; - bp = new CTPPSBeamParameters(); - // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object - if(setBeamPars) bp = fillBeamParameters(); - - edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp << "\n" ; + auto bp = ( setBeamPars_ ) + ? fillBeamParameters() + : std::make_unique(); - return std::unique_ptr(bp); - + edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp; + + return std::move( bp ); } //---------------------------------------------------------------------------------------------------- -void CTPPSBeamParametersESSource::initializeBeamParameters() +void +CTPPSBeamParametersESSource::setBeamParameters( const edm::ParameterSet& iConfig ) { - beamMom45 = beamMom56 = betaStarX45 = betaStarX56 = betaStarY45 = betaStarY56 = - beamDivX45 = beamDivX56 = beamDivY45 = beamDivY56 = halfXangleX45 = halfXangleX56 = - halfXangleY45 = halfXangleY56 = vtxOffsetX45 = vtxOffsetX56 = vtxOffsetY45 = vtxOffsetY56 = - vtxOffsetZ45 = vtxOffsetZ56 = vtxStddevX = vtxStddevY = vtxStddevZ = 0.0 ; + beamMom45_ = iConfig.getParameter( "beamMom45" ); + beamMom56_ = iConfig.getParameter( "beamMom56" ); + betaStarX45_ = iConfig.getParameter( "betaStarX45" ); + betaStarX56_ = iConfig.getParameter( "betaStarX56" ); + betaStarY45_ = iConfig.getParameter( "betaStarY45" ); + betaStarY56_ = iConfig.getParameter( "betaStarY56" ); + beamDivX45_ = iConfig.getParameter( "beamDivX45" ); + beamDivX56_ = iConfig.getParameter( "beamDivX56" ); + beamDivY45_ = iConfig.getParameter( "beamDivY45" ); + beamDivY56_ = iConfig.getParameter( "beamDivY56" ); + halfXangleX45_ = iConfig.getParameter( "halfXangleX45" ); + halfXangleX56_ = iConfig.getParameter( "halfXangleX56" ); + halfXangleY45_ = iConfig.getParameter( "halfXangleY45" ); + halfXangleY56_ = iConfig.getParameter( "halfXangleY56" ); + vtxOffsetX45_ = iConfig.getParameter( "vtxOffsetX45" ); + vtxOffsetY45_ = iConfig.getParameter( "vtxOffsetY45" ); + vtxOffsetZ45_ = iConfig.getParameter( "vtxOffsetZ45" ); + vtxOffsetX56_ = iConfig.getParameter( "vtxOffsetX56" ); + vtxOffsetY56_ = iConfig.getParameter( "vtxOffsetY56" ); + vtxOffsetZ56_ = iConfig.getParameter( "vtxOffsetZ56" ); + vtxStddevX_ = iConfig.getParameter( "vtxStddevX" ); + vtxStddevY_ = iConfig.getParameter( "vtxStddevY" ); + vtxStddevZ_ = iConfig.getParameter( "vtxStddevZ" ); } //---------------------------------------------------------------------------------------------------- -void CTPPSBeamParametersESSource::setBeamParameters(const edm::ParameterSet& conf) +std::unique_ptr +CTPPSBeamParametersESSource::fillBeamParameters() { - beamMom45 = conf.getParameter("beamMom45"); - beamMom56 = conf.getParameter("beamMom56"); - betaStarX45 = conf.getParameter("betaStarX45"); - betaStarX56 = conf.getParameter("betaStarX56"); - betaStarY45 = conf.getParameter("betaStarY45"); - betaStarY56 = conf.getParameter("betaStarY56"); - beamDivX45 = conf.getParameter("beamDivX45"); - beamDivX56 = conf.getParameter("beamDivX56"); - beamDivY45 = conf.getParameter("beamDivY45"); - beamDivY56 = conf.getParameter("beamDivY56"); - halfXangleX45 = conf.getParameter("halfXangleX45"); - halfXangleX56 = conf.getParameter("halfXangleX56"); - halfXangleY45 = conf.getParameter("halfXangleY45"); - halfXangleY56 = conf.getParameter("halfXangleY56"); - vtxOffsetX45 = conf.getParameter("vtxOffsetX45"); - vtxOffsetY45 = conf.getParameter("vtxOffsetY45"); - vtxOffsetZ45 = conf.getParameter("vtxOffsetZ45"); - vtxOffsetX56 = conf.getParameter("vtxOffsetX56"); - vtxOffsetY56 = conf.getParameter("vtxOffsetY56"); - vtxOffsetZ56 = conf.getParameter("vtxOffsetZ56"); - vtxStddevX = conf.getParameter("vtxStddevX"); - vtxStddevY = conf.getParameter("vtxStddevY"); - vtxStddevZ = conf.getParameter("vtxStddevZ"); + auto p = std::make_unique(); + + p->setBeamMom45( beamMom45_ ); + p->setBeamMom56( beamMom56_ ); + + p->setBetaStarX45( betaStarX45_ ); + p->setBetaStarY45( betaStarY45_ ); + p->setBetaStarX56( betaStarX56_ ); + p->setBetaStarY56( betaStarY56_ ); + + p->setBeamDivergenceX45( beamDivX45_ ); + p->setBeamDivergenceY45( beamDivY45_ ); + p->setBeamDivergenceX56( beamDivX56_ ); + p->setBeamDivergenceY56( beamDivY56_ ); + + p->setHalfXangleX45( halfXangleX45_ ); + p->setHalfXangleY45( halfXangleY45_ ); + p->setHalfXangleX56( halfXangleX56_ ); + p->setHalfXangleY56( halfXangleY56_ ); + + p->setVtxOffsetX45( vtxOffsetX45_ ); + p->setVtxOffsetY45( vtxOffsetY45_ ); + p->setVtxOffsetZ45( vtxOffsetZ45_ ); + p->setVtxOffsetX56( vtxOffsetX56_ ); + p->setVtxOffsetY56( vtxOffsetY56_ ); + p->setVtxOffsetZ56( vtxOffsetZ56_ ); + + p->setVtxStddevX( vtxStddevX_ ); + p->setVtxStddevY( vtxStddevY_ ); + p->setVtxStddevZ( vtxStddevZ_ ); + + return p; } //---------------------------------------------------------------------------------------------------- -CTPPSBeamParameters* CTPPSBeamParametersESSource::fillBeamParameters() +void +CTPPSBeamParametersESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity ) { - CTPPSBeamParameters* p = new CTPPSBeamParameters(); - - p->setBeamMom45( beamMom45 ); - p->setBeamMom56( beamMom56 ); - - p->setBetaStarX45( betaStarX45 ); - p->setBetaStarY45( betaStarY45 ); - p->setBetaStarX56( betaStarX56 ); - p->setBetaStarY56( betaStarY56 ); - - p->setBeamDivergenceX45( beamDivX45 ); - p->setBeamDivergenceY45( beamDivY45 ); - p->setBeamDivergenceX56( beamDivX56 ); - p->setBeamDivergenceY56( beamDivY56 ); - - p->setHalfXangleX45( halfXangleX45 ); - p->setHalfXangleY45( halfXangleY45 ); - p->setHalfXangleX56( halfXangleX56 ); - p->setHalfXangleY56( halfXangleY56 ); - - p->setVtxOffsetX45( vtxOffsetX45 ); - p->setVtxOffsetY45( vtxOffsetY45 ); - p->setVtxOffsetZ45( vtxOffsetZ45 ); - p->setVtxOffsetX56( vtxOffsetX56 ); - p->setVtxOffsetY56( vtxOffsetY56 ); - p->setVtxOffsetZ56( vtxOffsetZ56 ); - - p->setVtxStddevX( vtxStddevX ); - p->setVtxStddevY( vtxStddevY ); - p->setVtxStddevZ( vtxStddevZ ); - - // edm::LogInfo("CTPPSBeamParametersESSource::fillBeamParameters") << "\n" ; - - return p ; + LogDebug("CTPPSBeamParametersESSource") + << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n" + << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event(); + + edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() ); + oValidity = infinity; } //---------------------------------------------------------------------------------------------------- -void CTPPSBeamParametersESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, - const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +void +CTPPSBeamParametersESSource::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) { - /* - LogVerbatim("CTPPSBeamParametersESSource") - << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")"; - - LogVerbatim("CTPPSBeamParametersESSource") - << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event(); - */ - - edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() ); - oValidity = infinity; - + edm::ParameterSetDescription desc; + desc.add( "setBeamPars", true ); + // beam momentum (GeV) + desc.add( "beamMom45", 6500. ); + desc.add( "beamMom56", 6500. ); + // beta* (cm) + desc.add( "betaStarX45", 30. ); + desc.add( "betaStarY45", 30. ); + desc.add( "betaStarX56", 30. ); + desc.add( "betaStarY56", 30. ); + // beam divergence (rad) + desc.add( "beamDivX45", 0.1 ); + desc.add( "beamDivY45", 0.1 ); + desc.add( "beamDivX56", 0.1 ); + desc.add( "beamDivY56", 0.1 ); + // half crossing angle (rad) + desc.add( "halfXangleX45", 80.e-6 ); + desc.add( "halfXangleY45", 80.e-6 ); + desc.add( "halfXangleX56", 80.e-6 ); + desc.add( "halfXangleY56", 80.e-6 ); + // vertex offset (cm) + desc.add( "vtxOffsetX45", 1.e-2 ); + desc.add( "vtxOffsetY45", 1.e-2 ); + desc.add( "vtxOffsetZ45", 1.e-2 ); + desc.add( "vtxOffsetX56", 1.e-2 ); + desc.add( "vtxOffsetY56", 1.e-2 ); + desc.add( "vtxOffsetZ56", 1.e-2 ); + // vertex sigma (cm) + desc.add( "vtxStddevX", 2.e-2 ); + desc.add( "vtxStddevY", 2.e-2 ); + desc.add( "vtxStddevZ", 2.e-2 ); + + descriptions.add( "ctppsBeamParametersESSource", desc ); } //---------------------------------------------------------------------------------------------------- -DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSBeamParametersESSource); +DEFINE_FWK_EVENTSETUP_SOURCE( CTPPSBeamParametersESSource ); + diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc index 0ad1a8bc4afa5..6c42cdd81d71b 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc @@ -20,12 +20,14 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe { public: CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); - - ~CTPPSOpticalFunctionsESSource() {}; + ~CTPPSOpticalFunctionsESSource() = default; edm::ESProducts> produce(const CTPPSOpticsRcd &); + static void fillDescriptions(edm::ConfigurationDescriptions&); private: + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + double m_xangle1, m_xangle2; std::string m_fileName1, m_fileName2; @@ -34,10 +36,7 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe std::string dirName; double scoringPlaneZ; }; - std::unordered_map m_rpInfo; - - void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; }; //---------------------------------------------------------------------------------------------------- @@ -65,15 +64,15 @@ CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::Paramete //---------------------------------------------------------------------------------------------------- void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, - const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); } //---------------------------------------------------------------------------------------------------- -edm::ESProducts< std::unique_ptr > - CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) +edm::ESProducts > +CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) { // fill the output auto output = std::make_unique(); @@ -98,4 +97,27 @@ edm::ESProducts< std::unique_ptr > //---------------------------------------------------------------------------------------------------- +void +CTPPSOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + desc.add("xangle1", 185.)->setComment("half crossing angle for sector 45"); + desc.add("fileName1", edm::FileInPath())->setComment("optical functions input file for sector 45"); + desc.add("xangle2", 185.)->setComment("half crossing angle for sector 56"); + desc.add("fileName2", edm::FileInPath())->setComment("optical functions input file for sector 56"); + + //--- information about scoring planes + edm::ParameterSetDescription sp_desc; + sp_desc.add("rpId")->setComment("associated detector DetId"); + sp_desc.add("dirName")->setComment("associated path to the optical functions file"); + sp_desc.add("z")->setComment("longitudinal position at scoring plane/detector"); + std::vector sp; + desc.addVPSet("scoringPlanes", sp_desc, sp)->setComment("list of sensitive planes/detectors stations"); + + descriptions.add("ctppsOpticalFunctionsESSource", desc); +} + +//---------------------------------------------------------------------------------------------------- + DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSOpticalFunctionsESSource); + diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index a4ec42f50a61c..853ed19f3c85e 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -9,51 +9,51 @@ //---------------------------------------------------------------------------------------------------- -LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, const double &z) : +LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, double z) : m_z(z) { TFile *f_in = TFile::Open(fileName.c_str()); if (f_in == NULL) throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; - std::vector graphs(m_fcn_values.size()); - for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) - { + std::vector graphs(m_fcn_values.size()); + for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) { std::string tag; if (fi == evx) tag = "v_x"; - if (fi == eLx) tag = "L_x"; - if (fi == e14) tag = "E_14"; - if (fi == exd) tag = "x_D"; - if (fi == evpx) tag = "vp_x"; - if (fi == eLpx) tag = "Lp_x"; - if (fi == e24) tag = "E_24"; - if (fi == expd) tag = "xp_D"; - if (fi == e32) tag = "E_32"; - if (fi == evy) tag = "v_y"; - if (fi == eLy) tag = "L_y"; - if (fi == eyd) tag = "y_D"; - if (fi == e42) tag = "E_42"; - if (fi == evpy) tag = "vp_y"; - if (fi == eLpy) tag = "Lp_y"; - if (fi == eypd) tag = "yp_D"; + else if (fi == eLx) tag = "L_x"; + else if (fi == e14) tag = "E_14"; + else if (fi == exd) tag = "x_D"; + else if (fi == evpx) tag = "vp_x"; + else if (fi == eLpx) tag = "Lp_x"; + else if (fi == e24) tag = "E_24"; + else if (fi == expd) tag = "xp_D"; + else if (fi == e32) tag = "E_32"; + else if (fi == evy) tag = "v_y"; + else if (fi == eLy) tag = "L_y"; + else if (fi == eyd) tag = "y_D"; + else if (fi == e42) tag = "E_42"; + else if (fi == evpy) tag = "vp_y"; + else if (fi == eLpy) tag = "Lp_y"; + else if (fi == eypd) tag = "yp_D"; + else + throw cms::Exception("LHCOpticalFunctionsSet") << "Invalid tag for optical functions: \"" << fi << "\""; std::string objPath = directoryName + "/g_" + tag + "_vs_xi"; - TGraph *g = (TGraph *) f_in->Get(objPath.c_str()); - if (g == NULL) - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << objPath << " from file " << fileName << "."; + auto gr_obj = dynamic_cast( f_in->Get(objPath.c_str()) ); + if (!gr_obj) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << objPath << " from file " << fileName << "."; - graphs[fi] = g; + graphs[fi] = gr_obj; } - const unsigned int n = graphs[0]->GetN(); + const unsigned int num_xi_vals = graphs[0]->GetN(); - m_xi_values.resize(n); + m_xi_values.resize(num_xi_vals); for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) - m_fcn_values[fi].resize(n); + m_fcn_values[fi].resize(num_xi_vals); - for (unsigned int pi = 0; pi < n; ++pi) - { + for (unsigned int pi = 0; pi < num_xi_vals; ++pi) { const double xi = graphs[0]->GetX()[pi]; m_xi_values[pi] = xi; @@ -68,10 +68,10 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons void LHCOpticalFunctionsSet::initializeSplines() { - const unsigned int n = m_xi_values.size(); + const unsigned int num_xi_vals = m_xi_values.size(); for (unsigned int i = 0; i < m_fcn_values.size(); ++i) - m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), n); + m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), num_xi_vals); } //---------------------------------------------------------------------------------------------------- @@ -79,7 +79,7 @@ void LHCOpticalFunctionsSet::initializeSplines() void LHCOpticalFunctionsSet::transport(const LHCOpticalFunctionsSet::Kinematics &input, LHCOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const { - const double &xi = input.xi; + const double& xi = input.xi; output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; @@ -102,8 +102,7 @@ LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::interpolate(double xangle1, cons double xangle2, const LHCOpticalFunctionsSet &of2, double xangle) { // check whether interpolation can be done - if (abs(xangle1 - xangle2) < 1e-6) - { + if (abs(xangle1 - xangle2) < 1e-6) { if (abs(xangle - xangle1) < 1e-6) return new LHCOpticalFunctionsSet(of1); else @@ -116,16 +115,14 @@ LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::interpolate(double xangle1, cons output->m_z = of1.m_z; - const unsigned int n = of1.m_xi_values.size(); + const size_t num_xi_vals = of1.m_xi_values.size(); - output->m_xi_values.resize(n); + output->m_xi_values.resize(num_xi_vals); - for (unsigned int fi = 0; fi < of1.m_fcn_values.size(); ++fi) - { - output->m_fcn_values[fi].resize(n); + for (size_t fi = 0; fi < of1.m_fcn_values.size(); ++fi) { + output->m_fcn_values[fi].resize(num_xi_vals); - for (unsigned int pi = 0; pi < n; ++pi) - { + for (size_t pi = 0; pi < num_xi_vals; ++pi) { double xi = of1.m_xi_values[pi]; output->m_xi_values[pi] = xi; diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index d16a84d45eccc..624f5b6be80a9 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -1,16 +1,15 @@ import FWCore.ParameterSet.Config as cms +from CondFormats.CTPPSReadoutObjects.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _tmp -ctppsOpticalFunctionsESSource = cms.ESSource("CTPPSOpticalFunctionsESSource", - xangle1 = cms.double(185), - fileName1 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), - - xangle2 = cms.double(185), - fileName2 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), - +ctppsOpticalFunctionsESSource = _tmp.clone( + xangle1 = cms.double(185), + fileName1 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), + xangle2 = cms.double(185), + fileName2 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), scoringPlanes = cms.VPSet( - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-203.826) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-212.551) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+203.826) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+212.551) ), # RP 103 + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-203.826) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-212.551) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+203.826) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+212.551) ), # RP 103 ) ) From 818a1868e4eeece121eddf59a157e27782c9eea7 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 16:27:37 +0100 Subject: [PATCH 117/686] Beam divergence vertex generator cleanup --- .../src/BeamDivergenceVtxGenerator.cc | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc index 524f3a1b52cad..853eb69080e38 100644 --- a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc +++ b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc @@ -7,7 +7,8 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" - +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" @@ -19,27 +20,25 @@ //---------------------------------------------------------------------------------------------------- BeamDivergenceVtxGenerator::BeamDivergenceVtxGenerator(const edm::ParameterSet& iConfig) : - sourceToken_( consumes( iConfig.getParameter( "src" ) ) ), - - simulateVertex_ ( iConfig.getParameter( "simulateVertex" ) ), - simulateBeamDivergence_ ( iConfig.getParameter( "simulateBeamDivergence" ) ) + sourceToken_(consumes( iConfig.getParameter("src"))), + simulateVertex_ (iConfig.getParameter("simulateVertex")), + simulateBeamDivergence_(iConfig.getParameter("simulateBeamDivergence")) { edm::Service rng; - if ( !rng.isAvailable() ) - { + if (!rng.isAvailable()) throw cms::Exception("Configuration") << "The BeamDivergenceVtxGenerator requires the RandomNumberGeneratorService\n" - "which is not present in the configuration file. \n" + "which is not present in the configuration file. \n" "You must add the service\n" "in the configuration file or remove the modules that require it."; - } produces(); } //---------------------------------------------------------------------------------------------------- -void BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSetup &iSetup) +void +BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSetup &iSetup) { // get random engine edm::Service rng; @@ -58,8 +57,7 @@ void BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSet std::unique_ptr pEvent(new edm::HepMCProduct(genevt)); // apply vertex smearing - if (simulateVertex_) - { + if (simulateVertex_) { // NB: the separtion between effective offsets in LHC sectors 45 and 56 cannot be applied, thus the values for 45 are used const double vtx_x = hBeamParameters->getVtxOffsetX45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevX(); const double vtx_y = hBeamParameters->getVtxOffsetY45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevY(); @@ -70,16 +68,14 @@ void BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSet } // apply beam divergence - if (simulateBeamDivergence_) - { + if (simulateBeamDivergence_) { const double bd_x_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX45(); const double bd_x_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX56(); const double bd_y_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY45(); const double bd_y_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY56(); - for (HepMC::GenEvent::particle_iterator part = genevt->particles_begin(); part != genevt->particles_end(); ++part) - { + for (HepMC::GenEvent::particle_iterator part = genevt->particles_begin(); part != genevt->particles_end(); ++part) { const HepMC::FourVector mom = (*part)->momentum(); // TODO: this is an oversimplified implemetation @@ -109,3 +105,16 @@ void BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSet // save output iEvent.put(std::move(pEvent)); } + +void +BeamDivergenceVtxGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("generator", "unsmeared")) + ->setComment("input collection where to retrieve outgoing particles kinematics to be smeared"); + desc.add("simulateBeamDivergence", true)->setComment("account for the beam angular divergence?"); + desc.add("simulateVertex", true)->setComment("account for the vertex transverse smearing?"); + + descriptions.add("beamDivergenceVtxGenerator", desc); +} + From 03dc70f0c98462b1a787410492f5f57bbce9bc0c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 16:42:14 +0100 Subject: [PATCH 118/686] Cleanup of Xi/Theta gun --- .../interface/RandomXiThetaGunProducer.h | 29 ++++---- .../src/RandomXiThetaGunProducer.cc | 72 ++++++++----------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h index 67ef56a7930c3..b94b2c29b7216 100644 --- a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h +++ b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h @@ -13,32 +13,31 @@ #include "CLHEP/Random/RandFlat.h" #include "CLHEP/Random/RandGauss.h" +namespace CLHEP { class HepRandomEngine; } namespace edm { class RandomXiThetaGunProducer : public one::EDProducer<> { - public: - RandomXiThetaGunProducer(const ParameterSet &); - - virtual ~RandomXiThetaGunProducer(); + RandomXiThetaGunProducer(const ParameterSet&); + ~RandomXiThetaGunProducer() override = default; private: - virtual void produce(Event & e, const EventSetup& es) override; - - void GenerateParticle(double z_sign, double mass, unsigned int barcode, CLHEP::HepRandomEngine* engine, HepMC::GenVertex *vtx) const; + virtual void produce(Event&, const EventSetup&) override; + void generateParticle(double z_sign, double mass, unsigned int barcode, HepMC::GenVertex *vtx) const; - unsigned int verbosity; + unsigned int verbosity_; + unsigned int particleId_; - unsigned int particleId; + double energy_; + double xi_min_, xi_max_; + double theta_x_mean_, theta_x_sigma_; + double theta_y_mean_, theta_y_sigma_; - double energy; - double xi_min, xi_max; - double theta_x_mean, theta_x_sigma; - double theta_y_mean, theta_y_sigma; + unsigned int nParticlesSector45_; + unsigned int nParticlesSector56_; - unsigned int nParticlesSector45; - unsigned int nParticlesSector56; + CLHEP::HepRandomEngine* engine_; }; } diff --git a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc index a88197806acad..2db3f41fce5e1 100644 --- a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc +++ b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc @@ -21,32 +21,30 @@ using namespace std; //---------------------------------------------------------------------------------------------------- -RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet& pset) : - verbosity(pset.getUntrackedParameter("verbosity", 0)), - - particleId(pset.getParameter("particleId")), - - energy(pset.getParameter("energy")), - xi_min(pset.getParameter("xi_min")), - xi_max(pset.getParameter("xi_max")), - theta_x_mean(pset.getParameter("theta_x_mean")), - theta_x_sigma(pset.getParameter("theta_x_sigma")), - theta_y_mean(pset.getParameter("theta_y_mean")), - theta_y_sigma(pset.getParameter("theta_y_sigma")), - - nParticlesSector45(pset.getParameter("nParticlesSector45")), - nParticlesSector56(pset.getParameter("nParticlesSector56")) +RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet& iConfig) : + verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), + particleId_ (iConfig.getParameter("particleId")), + energy_ (iConfig.getParameter("energy")), + xi_min_ (iConfig.getParameter("xi_min")), + xi_max_ (iConfig.getParameter("xi_max")), + theta_x_mean_ (iConfig.getParameter("theta_x_mean")), + theta_x_sigma_ (iConfig.getParameter("theta_x_sigma")), + theta_y_mean_ (iConfig.getParameter("theta_y_mean")), + theta_y_sigma_ (iConfig.getParameter("theta_y_sigma")), + nParticlesSector45_(iConfig.getParameter("nParticlesSector45")), + nParticlesSector56_(iConfig.getParameter("nParticlesSector56")), + engine_(nullptr) { produces("unsmeared"); } //---------------------------------------------------------------------------------------------------- -void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) +void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) { // get conditions edm::Service rng; - CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); + engine_ = &rng->getEngine(e.streamID()); ESHandle pdgTable; es.getData(pdgTable); @@ -54,27 +52,21 @@ void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) // prepare HepMC event HepMC::GenEvent *fEvt = new HepMC::GenEvent(); fEvt->set_event_number(e.id().event()); - + HepMC::GenVertex *vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0., 0.)); fEvt->add_vertex(vtx); - const HepPDT::ParticleData *pData = pdgTable->particle(HepPDT::ParticleID(particleId)); + const HepPDT::ParticleData *pData = pdgTable->particle(HepPDT::ParticleID(particleId_)); double mass = pData->mass().value(); // generate particles unsigned int barcode = 0; - for (unsigned int i = 0; i < nParticlesSector45; i++) - { - barcode++; - GenerateParticle(+1., mass, barcode, engine, vtx); - } + for (unsigned int i = 0; i < nParticlesSector45_; ++i) + generateParticle(+1., mass, ++barcode, vtx); - for (unsigned int i = 0; i < nParticlesSector56; i++) - { - barcode++; - GenerateParticle(-1., mass, barcode, engine, vtx); - } + for (unsigned int i = 0; i < nParticlesSector56_; ++i) + generateParticle(-1., mass, ++barcode, vtx); // save output std::unique_ptr output(new HepMCProduct()) ; @@ -84,20 +76,20 @@ void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) //---------------------------------------------------------------------------------------------------- -void RandomXiThetaGunProducer::GenerateParticle(double z_sign, double mass, unsigned int barcode, - CLHEP::HepRandomEngine* engine, HepMC::GenVertex *vtx) const +void RandomXiThetaGunProducer::generateParticle(double z_sign, double mass, unsigned int barcode, + HepMC::GenVertex *vtx) const { - const double xi = CLHEP::RandFlat::shoot(engine, xi_min, xi_max); - const double theta_x = CLHEP::RandGauss::shoot(engine, theta_x_mean, theta_x_sigma); - const double theta_y = CLHEP::RandGauss::shoot(engine, theta_y_mean, theta_y_sigma); + const double xi = CLHEP::RandFlat::shoot(engine_, xi_min_, xi_max_); + const double theta_x = CLHEP::RandGauss::shoot(engine_, theta_x_mean_, theta_x_sigma_); + const double theta_y = CLHEP::RandGauss::shoot(engine_, theta_y_mean_, theta_y_sigma_); - if (verbosity) + if (verbosity_) LogInfo("RandomXiThetaGunProducer") << "xi = " << xi << ", theta_x = " << theta_x << ", theta_y" << theta_y << ", z_sign = " << z_sign; const double cos_theta = sqrt(1. - theta_x*theta_x - theta_y*theta_y); - const double p_nom = sqrt(energy*energy - mass*mass); + const double p_nom = sqrt(energy_*energy_ - mass*mass); const double p = p_nom * (1. - xi); const double e = sqrt(p*p + mass*mass); @@ -108,13 +100,7 @@ void RandomXiThetaGunProducer::GenerateParticle(double z_sign, double mass, unsi e ); - HepMC::GenParticle* particle = new HepMC::GenParticle(momentum, particleId, 1); + HepMC::GenParticle* particle = new HepMC::GenParticle(momentum, particleId_, 1); particle->suggest_barcode(barcode); vtx->add_particle_out(particle); } - -//---------------------------------------------------------------------------------------------------- - -RandomXiThetaGunProducer::~RandomXiThetaGunProducer() -{ -} From f5ef947f2eb95be200c3c3535d1bfeafec664960 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 17:17:58 +0100 Subject: [PATCH 119/686] Cleanup of the proton reco + algorithm --- .../interface/ProtonReconstructionAlgorithm.h | 34 +++--- .../plugins/CTPPSProtonReconstruction.cc | 103 +++++++----------- .../src/ProtonReconstructionAlgorithm.cc | 31 +++--- 3 files changed, 72 insertions(+), 96 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index 6a78e94c1e337..b1cab3b8157f0 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -27,30 +27,26 @@ class ProtonReconstructionAlgorithm { public: ProtonReconstructionAlgorithm(bool fit_vtx_y, unsigned int verbosity); + ~ProtonReconstructionAlgorithm() = default; - ~ProtonReconstructionAlgorithm() {} + void init(const std::unordered_map &opticalFunctions); + void release(); - /// runs proton reconstruction using single-RP strategy + /// run proton reconstruction using single-RP strategy void reconstructFromSingleRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo, std::stringstream &ssLog) const; + const LHCInfo &lhcInfo) const; - /// runs proton reconstruction using multiple-RP strategy + /// run proton reconstruction using multiple-RP strategy void reconstructFromMultiRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo, std::stringstream &ssLog) const; - - void init(const std::unordered_map &opticalFunctions); - - void release(); + const LHCInfo &lhcInfo) const; private: unsigned int verbosity_; - bool fitVtxY_; - bool initialized_; /// optics data associated with 1 RP @@ -58,9 +54,12 @@ class ProtonReconstructionAlgorithm { const LHCOpticalFunctionsSet *optics; std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; - double x0, y0; // beam position, m - double ch0, ch1; // linear approximation (intercept and slope) of x(xi) - double la0, la1; // linear approximation (intercept and slope) of L_x(xi) + double x0; ///< beam horizontal position, m + double y0; ///< beam vertical position, m + double ch0; ///< intercept for linear approximation of \f$x(\xi)\f$ + double ch1; ///< slope for linear approximation of \f$x(\xi)\f$ + double la0; ///< intercept for linear approximation of \f$L_x(\xi)\f$ + double la1; ///< slope for linear approximation of \f$L_x(\xi)\f$ }; /// map: RP id --> optics data @@ -70,12 +69,12 @@ class ProtonReconstructionAlgorithm class ChiSquareCalculator { public: - ChiSquareCalculator() {} + ChiSquareCalculator() = default; double operator() (const double *parameters) const; - const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector *tracks_; - const std::map *m_rp_optics_; + const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector* tracks; + const std::map* m_rp_optics; }; /// fitter object @@ -86,3 +85,4 @@ class ProtonReconstructionAlgorithm }; #endif + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 89dceab0b8b90..2789ac291f01b 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -14,7 +14,9 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + +#include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" +#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" #include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" @@ -30,14 +32,14 @@ class CTPPSProtonReconstruction : public edm::stream::EDProducer<> { public: explicit CTPPSProtonReconstruction(const edm::ParameterSet&); - ~CTPPSProtonReconstruction() {} + ~CTPPSProtonReconstruction() = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: virtual void produce(edm::Event&, const edm::EventSetup&) override; - edm::EDGetTokenT< std::vector > tracksToken_; + edm::EDGetTokenT > tracksToken_; unsigned int verbosity_; @@ -51,8 +53,8 @@ class CTPPSProtonReconstruction : public edm::stream::EDProducer<> std::unordered_map opticalFunctions_; - const std::string singleRPLabel = "singleRP"; - const std::string multiRPLabel = "multiRP"; + const std::string singleRPLabel_ = "singleRP"; + const std::string multiRPLabel_ = "multiRP"; }; //---------------------------------------------------------------------------------------------------- @@ -64,23 +66,21 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iConfig) : - tracksToken_(consumes< std::vector >(iConfig.getParameter("tagLocalTrackLite"))), - verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), + verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), - doMultiRPReconstruction_(iConfig.getParameter("doMultiRPReconstruction")), - algorithm_(iConfig.getParameter("fitVtxY"), verbosity_), + doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), + algorithm_ (iConfig.getParameter("fitVtxY"), verbosity_), currentCrossingAngle_(-1.) { - if (doSingleRPReconstruction_) - { - produces>(singleRPLabel); - produces>(singleRPLabel); + if (doSingleRPReconstruction_) { + produces(singleRPLabel_); + produces(singleRPLabel_); } - if (doMultiRPReconstruction_) - { - produces>(multiRPLabel); - produces>(multiRPLabel); + if (doMultiRPReconstruction_) { + produces(multiRPLabel_); + produces(multiRPLabel_); } } @@ -89,19 +89,13 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& descriptions) { ParameterSetDescription desc; - - desc.addUntracked("verbosity", 0) - ->setComment("verbosity level"); - + desc.addUntracked("verbosity", 0)->setComment("verbosity level"); desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) ->setComment("specification of the input lite-track collection"); - desc.add("doSingleRPReconstruction", true) ->setComment("flag whether to apply single-RP reconstruction strategy"); - desc.add("doMultiRPReconstruction", true) ->setComment("flag whether to apply multi-RP reconstruction strategy"); - desc.add("fitVtxY", true) ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); @@ -147,33 +141,24 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } } - // prepare log - std::stringstream ssLog; - - if (verbosity_) - ssLog << "input tracks:" << std::endl; - // get input - Handle> hTracks; + Handle > hTracks; event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; map nTracksPerRP; - for (unsigned int idx = 0; idx < hTracks->size(); ++idx) - { + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; CTPPSDetId rpId(tr.getRPId()); if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) continue; if (verbosity_) - { - unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - ssLog << " " << tr.getRPId() << " (" << decRPId << "): " + LogDebug("CTPPSProtonReconstruction") + << " " << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " << "x = " << tr.getX() << " +- " << tr.getXUnc() << " mm" << ", y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; - } if (rpId.arm() == 0) tracks_45.emplace_back(hTracks, idx); @@ -185,58 +170,52 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet // for the moment: check whether there is no more than 1 track in each arm bool singleTrack_45 = true, singleTrack_56 = true; - for (const auto &p : nTracksPerRP) - { - if (p.second > 1) - { + for_each(nTracksPerRP.begin(), nTracksPerRP.end(), [&singleTrack_45,&singleTrack_56](const auto& p) { + if (p.second > 1) { CTPPSDetId rpId(p.first); if (rpId.arm() == 0) singleTrack_45 = false; if (rpId.arm() == 1) singleTrack_56 = false; } - } + }); // single-RP reconstruction - if (doSingleRPReconstruction_) - { - unique_ptr> output(new vector); - unique_ptr> outputExtra(new vector); + if (doSingleRPReconstruction_) { + unique_ptr output(new reco::ProtonTrackCollection); + unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo); - auto ohExtra = event.put(move(outputExtra), singleRPLabel); + auto ohExtra = event.put(move(outputExtra), singleRPLabel_); for (unsigned int i = 0; i < output->size(); ++i) (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); - - event.put(move(output), singleRPLabel); + + event.put(move(output), singleRPLabel_); } // multi-RP reconstruction - if (doMultiRPReconstruction_) - { - unique_ptr> output(new vector); - unique_ptr> outputExtra(new vector); + if (doMultiRPReconstruction_) { + unique_ptr output(new reco::ProtonTrackCollection); + unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo); - auto ohExtra = event.put(move(outputExtra), multiRPLabel); + auto ohExtra = event.put(move(outputExtra), multiRPLabel_); for (unsigned int i = 0; i < output->size(); ++i) (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); - event.put(move(output), multiRPLabel); + event.put(move(output), multiRPLabel_); } - - if (verbosity_) - edm::LogInfo("CTPPSProtonReconstruction") << ssLog.str(); } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSProtonReconstruction); + diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 94b439a7f40b6..7cee64a1afc5e 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -22,8 +22,7 @@ ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, uns verbosity_(verbosity), fitVtxY_(fit_vtx_y), initialized_(false), - fitter_(std::make_unique()), - chiSquareCalculator_(std::make_unique()) + fitter_(new ROOT::Fit::Fitter), chiSquareCalculator_(new ChiSquareCalculator) { // initialise fitter double pStart[] = { 0, 0, 0, 0 }; @@ -108,12 +107,11 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou // calculate chi^2 by looping over hits double S2 = 0.; - for (const auto &track : *tracks_) - { + for (const auto &track : *tracks) { const CTPPSDetId rpId(track->getRPId()); // transport proton to the RP - auto oit = m_rp_optics_->find(rpId); + auto oit = m_rp_optics->find(rpId); LHCOpticalFunctionsSet::Kinematics k_out; oit->second.optics->transport(k_in, k_out); @@ -147,7 +145,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo, std::stringstream &ssLog) const + const LHCInfo &lhcInfo) const { if (!initialized_) return; @@ -239,12 +237,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); if (verbosity_) - { - ssLog << std::endl + LogDebug("ProtonReconstructionAlgorithm") << "ProtonReconstructionAlgorithm::reconstructFromMultiRP(" << armId << ")" << std::endl << " initial estimate: xi_init = " << xi_init << ", th_x_init = " << th_x_init - << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "" << std::endl; - } + << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "."; // minimisation fitter_->Config().ParSettings(0).Set("xi", xi_init, 0.005); @@ -255,8 +251,8 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( if (!fitVtxY_) fitter_->Config().ParSettings(3).Fix(); - chiSquareCalculator_->tracks_ = &tracks; - chiSquareCalculator_->m_rp_optics_ = &m_rp_optics_; + chiSquareCalculator_->tracks = &tracks; + chiSquareCalculator_->m_rp_optics = &m_rp_optics_; fitter_->FitFCN(); fitter_->FitFCN(); // second minimisation in case the first one had troubles @@ -266,12 +262,12 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const double *params = result.GetParams(); if (verbosity_) - ssLog << " fit: " + LogDebug("ProtonReconstructionAlgorithm") << " fit: " << "xi=" << params[0] << " +- " << result.Error(0) << ", th_x=" << params[1] << " +-" << result.Error(1) << ", th_y=" << params[2] << " +-" << result.Error(2) << ", vtx_y=" << params[3] << " +-" << result.Error(3) - << ", chiSq = " << result.Chi2() << std::endl; + << ", chiSq = " << result.Chi2(); // save reco candidate using EX = reco::ProtonTrackExtra; @@ -326,7 +322,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo, std::stringstream &ssLog) const + const LHCInfo &lhcInfo) const { if (!initialized_) return; @@ -347,7 +343,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); if (verbosity_) - ssLog << std::endl << "reconstructFromSingleRP(" << decRPId << ")" << endl; + LogDebug("ProtonReconstructionAlgorithm") << "reconstructFromSingleRP(" << decRPId << ")"; auto oit = m_rp_optics_.find(track->getRPId()); const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m @@ -364,7 +360,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); if (verbosity_) - ssLog << " xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "" << endl; + LogDebug("ProtonReconstructionAlgorithm") << " xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; using EX = reco::ProtonTrackExtra; using PT = reco::ProtonTrack; @@ -389,3 +385,4 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( outputExtra.push_back(move(ptExtra)); } } + From eec1981d04c051659f967a9a8571bc71dff6aa18 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 17:25:21 +0100 Subject: [PATCH 120/686] standard descriptions filled for direct proton simulation validation tool --- .../plugins/CTPPSDirectProtonSimulation.cc | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index bea2ea917d515..f64198bdaf57b 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -241,7 +241,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, /// horizontal component of proton momentum: p_x = th_x * (1-xi) * p_nom std::stringstream ssLog; - + // vectors in CMS convention const HepMC::FourVector vtx_cms = in_vtx->position(); // in mm const HepMC::FourVector mom_cms = in_trk->momentum(); @@ -303,7 +303,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, return; } } - + // transport the proton into each pot/scoring plane for (const auto &ofp : opticalFunctions_) { @@ -403,7 +403,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (verbosity_ > 5) ssLog << " | no hit" << std::endl; continue; - } + } // round the measurement if (roundToPitch_) @@ -462,7 +462,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, edm::DetSet &hits = out_pixel_hits.find_or_insert(detId); hits.push_back(CTPPSPixelRecHit(lp, le)); - } + } } } @@ -475,8 +475,24 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, void CTPPSDirectProtonSimulation::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) { edm::ParameterSetDescription desc; - desc.setUnknown(); - descriptions.addDefault( desc ); + desc.add("verbosity", 0); + desc.add("hepMCTag", edm::InputTag("generator", "unsmeared")); + desc.add("produceScoringPlaneHits", true); + desc.add("produceRecHits", true); + desc.add("useEmpiricalApertures", false); + desc.add("empiricalAperture45_xi0", 0.); + desc.add("empiricalAperture45_a", 0.); + desc.add("empiricalAperture56_xi0", 0.); + desc.add("empiricalAperture56_a", 0.); + desc.add("produceHitsRelativeToBeam", false); + desc.add("roundToPitch", true); + desc.add("checkIsHit", true); + desc.add("pitchStrips", 66.e-3); // in mm + desc.add("insensitiveMarginStrips", 34.e-3); // in mm + desc.add("pitchPixelsHor", 100.e-3)->setComment("x in local coordinates, in mm"); + desc.add("pitchPixelsVer", 150.e-3)->setComment("y in local coordinates, in mm"); + + descriptions.add("ctppsDirectProtonSimulation", desc); } //---------------------------------------------------------------------------------------------------- From 9286b8adbb0abd2f22a82a2e9b2db04ba4e30f56 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 17:40:40 +0100 Subject: [PATCH 121/686] Cleanup of new condtools for CTPPS --- .../plugins/RetrieveCTPPSBeamParameters.cc | 61 +++++++++++++++ .../CTPPS/plugins/WriteCTPPSBeamParameters.cc | 76 +++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc create mode 100644 CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc diff --git a/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc new file mode 100644 index 0000000000000..5d5dae5335993 --- /dev/null +++ b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc @@ -0,0 +1,61 @@ +// -*- C++ -*- +// +// Class: RetrieveCTPPSBeamParameters +// +// Description: Test analyzer for reading CTPPS beam parameters condition data +// +// Simple analyzer that retrieves CTTPSBeamParameters record from a sql +// database file, as a test of offline conditions implementation. +// +// Original Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 17:35:07 GMT +// +//================================================================================== + +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +class RetrieveCTPPSBeamParameters : public edm::one::EDAnalyzer<> +{ + public: + explicit RetrieveCTPPSBeamParameters(const edm::ParameterSet&); + ~RetrieveCTPPSBeamParameters() = default; + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + std::string label_; +}; + +//--------------------------------------------------------------------------------------- + +RetrieveCTPPSBeamParameters::RetrieveCTPPSBeamParameters(const edm::ParameterSet& iConfig) +{} + +void RetrieveCTPPSBeamParameters::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle pSetup; + iSetup.get().get(label_, pSetup); + + const CTPPSBeamParameters* pInfo = pSetup.product(); + + edm::LogInfo("CTPPSBeamParameters") << "\n" << *pInfo << "\n" ; +} + +DEFINE_FWK_MODULE(RetrieveCTPPSBeamParameters); + diff --git a/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc new file mode 100644 index 0000000000000..81aaa397b0dfd --- /dev/null +++ b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc @@ -0,0 +1,76 @@ +// -*- C++ -*- +// +// Class: WriteCTPPSBeamParameters +// +// Description: Test analyzer for CTPPS beam parameters condition data +// +// Simple analyzer that writes one CTTPSBeamParameters record into a sql +// database file, as a test of offline conditions implementation. +// Another analyzer is then used to retrieve these conditions. +// +// Original Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 17:35:07 GMT +// +//================================================================================== + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Event.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +class WriteCTPPSBeamParameters : public edm::one::EDAnalyzer<> +{ + public: + WriteCTPPSBeamParameters(const edm::ParameterSet&) {} + ~WriteCTPPSBeamParameters() = default; + + private: + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; +}; + +//--------------------------------------------------------------------------------------- + +void WriteCTPPSBeamParameters::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle bp ; + iSetup.get().get(bp) ; + + // Pointer for the conditions data object + const CTPPSBeamParameters *p = bp.product() ; + + // Using "lumiid" as IOV + const edm::LuminosityBlock &iLBlock = iEvent.getLuminosityBlock() ; + edm::LuminosityBlockID lu(iLBlock.run(), iLBlock.id().luminosityBlock()) ; + cond::Time_t ilumi = (cond::Time_t)(lu.value()) ; + // cond::Time_t itime = (cond::Time_t)(iEvent.time().value()) ; // use this for timestamp + + edm::LogInfo("WriteCTPPSBeamParameters::analyze") << "cond::Time_t ilumi = " << ilumi + << " = " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( ilumi ) ) << "\n" ; + + // Write to database or sqlite file + edm::Service poolDbService; + if( poolDbService.isAvailable() ) + poolDbService->writeOne( p, ilumi, "CTPPSBeamParametersRcd" ); + // poolDbService->writeOne( p, poolDbService->currentTime(), "CTPPSBeamParametersRcd" ); + else + throw std::runtime_error("PoolDBService required."); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(WriteCTPPSBeamParameters); + From d4bf00d542343ebfb8d6f8ac81f385244f69fcb6 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 21:11:13 +0100 Subject: [PATCH 122/686] Reverted back some cleanups --- .../plugins/CTPPSBeamParametersESSource.cc | 2 +- .../interface/ProtonReconstructionAlgorithm.h | 4 +-- .../plugins/CTPPSProtonReconstruction.cc | 28 ++++++++++++------- .../src/ProtonReconstructionAlgorithm.cc | 12 ++++---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc index bf6dc7d15de08..5ad5f7df52c84 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc @@ -184,7 +184,7 @@ void CTPPSBeamParametersESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& key, const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity ) { - LogDebug("CTPPSBeamParametersESSource") + edm::LogInfo("CTPPSBeamParametersESSource") << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n" << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event(); diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index b1cab3b8157f0..b813cebf7912c 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -36,13 +36,13 @@ class ProtonReconstructionAlgorithm void reconstructFromSingleRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const; + const LHCInfo &lhcInfo, std::ostream& os) const; /// run proton reconstruction using multiple-RP strategy void reconstructFromMultiRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const; + const LHCInfo &lhcInfo, std::ostream& os) const; private: unsigned int verbosity_; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 2789ac291f01b..2698eb9f2d49b 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -141,6 +141,11 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } } + // prepare log + std::ostringstream ssLog; + if (verbosity_) + ssLog << "input tracks:"; + // get input Handle > hTracks; event.getByToken(tracksToken_, hTracks); @@ -155,10 +160,10 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet continue; if (verbosity_) - LogDebug("CTPPSProtonReconstruction") + ssLog << "\n" << " " << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " << "x = " << tr.getX() << " +- " << tr.getXUnc() << " mm" - << ", y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; + << ", y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; if (rpId.arm() == 0) tracks_45.emplace_back(hTracks, idx); @@ -170,23 +175,23 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet // for the moment: check whether there is no more than 1 track in each arm bool singleTrack_45 = true, singleTrack_56 = true; - for_each(nTracksPerRP.begin(), nTracksPerRP.end(), [&singleTrack_45,&singleTrack_56](const auto& p) { - if (p.second > 1) { - CTPPSDetId rpId(p.first); + for (const auto& detid_num : nTracksPerRP) { + if (detid_num.second > 1) { + CTPPSDetId rpId(detid_num.first); if (rpId.arm() == 0) singleTrack_45 = false; if (rpId.arm() == 1) singleTrack_56 = false; } - }); + } // single-RP reconstruction if (doSingleRPReconstruction_) { unique_ptr output(new reco::ProtonTrackCollection); unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); auto ohExtra = event.put(move(outputExtra), singleRPLabel_); @@ -202,9 +207,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); auto ohExtra = event.put(move(outputExtra), multiRPLabel_); @@ -213,6 +218,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet event.put(move(output), multiRPLabel_); } + + if (verbosity_) + edm::LogInfo("CTPPSProtonReconstruction") << ssLog.str(); } //---------------------------------------------------------------------------------------------------- diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 7cee64a1afc5e..2de50d361520a 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -145,7 +145,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const + const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) return; @@ -237,7 +237,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); if (verbosity_) - LogDebug("ProtonReconstructionAlgorithm") + os << "\n" << "ProtonReconstructionAlgorithm::reconstructFromMultiRP(" << armId << ")" << std::endl << " initial estimate: xi_init = " << xi_init << ", th_x_init = " << th_x_init << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "."; @@ -262,7 +262,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const double *params = result.GetParams(); if (verbosity_) - LogDebug("ProtonReconstructionAlgorithm") << " fit: " + os << "\n" << "xi=" << params[0] << " +- " << result.Error(0) << ", th_x=" << params[1] << " +-" << result.Error(1) << ", th_y=" << params[2] << " +-" << result.Error(2) @@ -322,7 +322,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, std::vector &outputExtra, - const LHCInfo &lhcInfo) const + const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) return; @@ -343,7 +343,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); if (verbosity_) - LogDebug("ProtonReconstructionAlgorithm") << "reconstructFromSingleRP(" << decRPId << ")"; + os << "\nreconstructFromSingleRP(" << decRPId << ")"; auto oit = m_rp_optics_.find(track->getRPId()); const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m @@ -360,7 +360,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); if (verbosity_) - LogDebug("ProtonReconstructionAlgorithm") << " xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; + os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; using EX = reco::ProtonTrackExtra; using PT = reco::ProtonTrack; From 8ffd9687f3c06a88d8a415f9daca6444ce4ff3c6 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 12 Dec 2018 21:21:39 +0100 Subject: [PATCH 123/686] Homogenised proton track indentation + doxygen documentation --- .../ProtonReco/interface/ProtonTrack.h | 25 ++++++++----------- DataFormats/ProtonReco/src/ProtonTrack.cc | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 593bcab21022d..b0a693f18b2c7 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -18,53 +18,49 @@ namespace reco public: /// Default constructor ProtonTrack(); - /// Constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); /// Indices to the covariance matrix enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices }; - /// Longitudinal fractional momentum loss + /// longitudinal fractional momentum loss float xi() const { return xi_; } - /// vertical scattering angle, in rad float thetaX() const { return px() / p(); } - /// horizontal scattering angle, in rad float thetaY() const { return py() / p(); } // vertex position can be obtained via TrackBase::vx() and vy() functions - static float calculateT(double beam_mom, double proton_mom, double theta); + /// compute the squared four-momentum transfer from incident and scattered momenta, and angular information + static float calculateT( double beam_mom, double proton_mom, double theta ); /// four-momentum transfer squared, in GeV^2 float t() const; - + /// uncertainty on longitudinal fractional momentum loss float xiError() const { return error( (int)Index::xi ); } - + /// uncertainty on fitted momentum horizontal angle opening float thetaXError() const { return error( (int)Index::th_x ); } - + /// uncertainty on fitted momentum vertical angle opening float thetaYError() const { return error( (int)Index::th_y ); } - + /// uncertainty on fitted vertex horizontal position float vertexXError() const { return error( (int)Index::vtx_x ); } - + /// uncertainty on fitted vertex vertical position float vertexYError() const { return error( (int)Index::vtx_y ); } /// LHC sector enum class LHCSector { invalid = -1, sector45, sector56 }; LHCSector lhcSector() const { - if (pz() < 0.) return LHCSector::sector56; - if (pz() > 0.) return LHCSector::sector45; + if ( pz() < 0. ) return LHCSector::sector56; + if ( pz() > 0. ) return LHCSector::sector45; return LHCSector::invalid; } // convenience getters for the extra information bool validFit() const { return pt_extra_->validFit(); } - ProtonTrackExtra::ReconstructionMethod method() const { return pt_extra_->method(); } - const ProtonTrackExtra::CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return pt_extra_->contributingLocalTracks(); } void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } @@ -72,7 +68,6 @@ namespace reco private: float xi_; ///< fractional momentum loss (positive for diffractive protons) - ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track }; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index acbab7f2d5f35..ef238d557fc51 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -18,9 +18,10 @@ ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vect Track( chi2, ndof, vtx, momentum, +1, cov ), xi_( xi ) {} -float ProtonTrack::calculateT(double beam_mom, double proton_mom, double theta) +float ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) { const double m = 0.938; // GeV + //FIXME necessarily hardcoded? may be moved to a static const(expr) value? or method argument? const double t0 = 2.*m*m + 2.*beam_mom*proton_mom - 2.*sqrt( (m*m + beam_mom*beam_mom) * (m*m + proton_mom*proton_mom) ); const double S = sin(theta/2.); From 3fbaeee3366be291279aec40856295f1e58df83b Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 13 Dec 2018 13:07:49 +0100 Subject: [PATCH 124/686] Added mass_ and massSquared_ static members. --- DataFormats/ProtonReco/interface/ProtonTrack.h | 17 ++++++++++++----- DataFormats/ProtonReco/src/ProtonTrack.cc | 5 +---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index b0a693f18b2c7..fdd8a65e71b28 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -33,11 +33,6 @@ namespace reco // vertex position can be obtained via TrackBase::vx() and vy() functions - /// compute the squared four-momentum transfer from incident and scattered momenta, and angular information - static float calculateT( double beam_mom, double proton_mom, double theta ); - - /// four-momentum transfer squared, in GeV^2 - float t() const; /// uncertainty on longitudinal fractional momentum loss float xiError() const { return error( (int)Index::xi ); } /// uncertainty on fitted momentum horizontal angle opening @@ -49,6 +44,15 @@ namespace reco /// uncertainty on fitted vertex vertical position float vertexYError() const { return error( (int)Index::vtx_y ); } + /// proton mass in GeV + static float mass() { return mass_; } + + /// compute the squared four-momentum transfer from incident and scattered momenta, and angular information + static float calculateT( double beam_mom, double proton_mom, double theta ); + + /// four-momentum transfer squared, in GeV^2 + float t() const; + /// LHC sector enum class LHCSector { invalid = -1, sector45, sector56 }; LHCSector lhcSector() const @@ -69,6 +73,9 @@ namespace reco private: float xi_; ///< fractional momentum loss (positive for diffractive protons) ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track + + static constexpr float mass_ = 0.938272046; ///< proton mass, GeV + static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 }; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index ef238d557fc51..f0e8ed071a95c 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -20,10 +20,7 @@ ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vect float ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) { - const double m = 0.938; // GeV - //FIXME necessarily hardcoded? may be moved to a static const(expr) value? or method argument? - - const double t0 = 2.*m*m + 2.*beam_mom*proton_mom - 2.*sqrt( (m*m + beam_mom*beam_mom) * (m*m + proton_mom*proton_mom) ); + const double t0 = 2.*massSquared_ + 2.*beam_mom*proton_mom - 2.*sqrt( (massSquared_ + beam_mom*beam_mom) * (massSquared_ + proton_mom*proton_mom) ); const double S = sin(theta/2.); return t0 - 4. * beam_mom * proton_mom * S*S; } From 1e379e17602f4e137226bf8dd51bc0f493c2d7bb Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 13 Dec 2018 18:11:32 +0100 Subject: [PATCH 125/686] Applied patch suggested by code-checks. --- .../plugins/CTPPSOpticalFunctionsESSource.cc | 2 +- .../src/LHCOpticalFunctionsSet.cc | 2 +- .../plugins/RetrieveCTPPSBeamParameters.cc | 6 +-- .../CTPPS/plugins/WriteCTPPSBeamParameters.cc | 6 +-- .../interface/RandomXiThetaGunProducer.h | 2 +- .../plugins/CTPPSProtonReconstruction.cc | 4 +- .../src/ProtonReconstructionAlgorithm.cc | 2 +- .../CTPPS/plugins/CTPPSAcceptancePlotter.cc | 20 +++---- .../plugins/CTPPSBeamSmearingValidator.cc | 12 ++--- .../plugins/CTPPSDirectProtonSimulation.cc | 8 +-- .../CTPPSDirectProtonSimulationValidator.cc | 12 ++--- .../plugins/CTPPSHepMCDistributionPlotter.cc | 6 +-- .../CTPPS/plugins/CTPPSLHCInfoESSource.cc | 2 +- .../CTPPSProtonReconstructionPlotter.cc | 54 +++++++++---------- ...ProtonReconstructionSimulationValidator.cc | 18 +++---- .../CTPPSProtonReconstructionValidator.cc | 10 ++-- .../plugins/CTPPSTrackDistributionPlotter.cc | 10 ++-- 17 files changed, 88 insertions(+), 88 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc index 6c42cdd81d71b..770b40fdc66ee 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc @@ -20,7 +20,7 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe { public: CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); - ~CTPPSOpticalFunctionsESSource() = default; + ~CTPPSOpticalFunctionsESSource() override = default; edm::ESProducts> produce(const CTPPSOpticsRcd &); static void fillDescriptions(edm::ConfigurationDescriptions&); diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index 853ed19f3c85e..29de973cb4e2c 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -13,7 +13,7 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons m_z(z) { TFile *f_in = TFile::Open(fileName.c_str()); - if (f_in == NULL) + if (f_in == nullptr) throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; std::vector graphs(m_fcn_values.size()); diff --git a/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc index 5d5dae5335993..63df5295455cf 100644 --- a/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc +++ b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc @@ -29,16 +29,16 @@ #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" -#include +#include class RetrieveCTPPSBeamParameters : public edm::one::EDAnalyzer<> { public: explicit RetrieveCTPPSBeamParameters(const edm::ParameterSet&); - ~RetrieveCTPPSBeamParameters() = default; + ~RetrieveCTPPSBeamParameters() override = default; private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; std::string label_; }; diff --git a/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc index 81aaa397b0dfd..4341e6285639b 100644 --- a/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc +++ b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc @@ -31,16 +31,16 @@ #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" -#include +#include class WriteCTPPSBeamParameters : public edm::one::EDAnalyzer<> { public: WriteCTPPSBeamParameters(const edm::ParameterSet&) {} - ~WriteCTPPSBeamParameters() = default; + ~WriteCTPPSBeamParameters() override = default; private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; }; //--------------------------------------------------------------------------------------- diff --git a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h index b94b2c29b7216..4e67c7632cf7e 100644 --- a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h +++ b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h @@ -23,7 +23,7 @@ class RandomXiThetaGunProducer : public one::EDProducer<> ~RandomXiThetaGunProducer() override = default; private: - virtual void produce(Event&, const EventSetup&) override; + void produce(Event&, const EventSetup&) override; void generateParticle(double z_sign, double mass, unsigned int barcode, HepMC::GenVertex *vtx) const; unsigned int verbosity_; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 2698eb9f2d49b..e64ca3e686ff7 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -32,12 +32,12 @@ class CTPPSProtonReconstruction : public edm::stream::EDProducer<> { public: explicit CTPPSProtonReconstruction(const edm::ParameterSet&); - ~CTPPSProtonReconstruction() = default; + ~CTPPSProtonReconstruction() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - virtual void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; edm::EDGetTokenT > tracksToken_; diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 2de50d361520a..799ffc799af57 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -170,7 +170,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( if (use_improved_estimate) { double x_N = 0., x_F = 0.; - const RPOpticsData *i_N = NULL, *i_F = NULL; + const RPOpticsData *i_N = nullptr, *i_F = nullptr; unsigned int idx = 0; for (const auto &track : tracks) { diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc index 93677e85917dc..d2798f2d8ab81 100644 --- a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -28,14 +28,14 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> { public: explicit CTPPSAcceptancePlotter( const edm::ParameterSet& ); - ~CTPPSAcceptancePlotter(); + ~CTPPSAcceptancePlotter() override; private: - virtual void beginJob() override; + void beginJob() override; - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT tokenHepMC; edm::EDGetTokenT< std::vector > tokenTracks; @@ -46,7 +46,7 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> struct SingleArmPlots { - TH1D *h_xi_all = NULL, *h_xi_acc = NULL; + TH1D *h_xi_all = nullptr, *h_xi_acc = nullptr; void Init() { @@ -56,7 +56,7 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> void Fill(double xi, bool acc) { - if (h_xi_all == NULL) + if (h_xi_all == nullptr) Init(); h_xi_all->Fill(xi); @@ -80,7 +80,7 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> struct DoubleArmPlots { - TH1D *h_m_all = NULL, *h_m_acc = NULL; + TH1D *h_m_all = nullptr, *h_m_acc = nullptr; TH2D *h2_xi_45_vs_xi_56_all, *h2_xi_45_vs_xi_56_acc; TH2D *h2_y_vs_m_all, *h2_y_vs_m_acc; @@ -98,7 +98,7 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> void Fill(double xi_45, double xi_56, bool acc) { - if (h_m_all == NULL) + if (h_m_all == nullptr) Init(); const double p_nom = 6500.; @@ -314,7 +314,7 @@ void CTPPSAcceptancePlotter::endJob() string dirName; for (const auto &rpId : p.first) { - if (dirName.size() > 0) + if (!dirName.empty()) dirName += ","; char buf[100]; sprintf(buf, "%u", rpId); @@ -330,7 +330,7 @@ void CTPPSAcceptancePlotter::endJob() string dirName; for (const auto &rpId : p.first) { - if (dirName.size() > 0) + if (!dirName.empty()) dirName += ","; char buf[100]; sprintf(buf, "%u", rpId); diff --git a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc index 067b8679e7909..ee3d9d0919947 100644 --- a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc @@ -24,12 +24,12 @@ class CTPPSBeamSmearingValidator : public edm::one::EDAnalyzer<> public: explicit CTPPSBeamSmearingValidator( const edm::ParameterSet& ); - ~CTPPSBeamSmearingValidator() {} + ~CTPPSBeamSmearingValidator() override {} private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT tokenBeforeSmearing_; edm::EDGetTokenT tokenAfterSmearing_; @@ -40,9 +40,9 @@ class CTPPSBeamSmearingValidator : public edm::one::EDAnalyzer<> struct SectorPlots { - TH1D *h_de_th_x = NULL; - TH1D *h_de_th_y = NULL; - TH1D *h_de_p = NULL; + TH1D *h_de_th_x = nullptr; + TH1D *h_de_th_y = nullptr; + TH1D *h_de_p = nullptr; void init() { diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index f64198bdaf57b..b791b01810673 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -50,12 +50,12 @@ class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> { public: explicit CTPPSDirectProtonSimulation( const edm::ParameterSet& ); - ~CTPPSDirectProtonSimulation() {} + ~CTPPSDirectProtonSimulation() override {} static void fillDescriptions( edm::ConfigurationDescriptions& descriptions ); private: - virtual void produce( edm::Event&, const edm::EventSetup& ) override; + void produce( edm::Event&, const edm::EventSetup& ) override; void processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, @@ -243,8 +243,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, std::stringstream ssLog; // vectors in CMS convention - const HepMC::FourVector vtx_cms = in_vtx->position(); // in mm - const HepMC::FourVector mom_cms = in_trk->momentum(); + const HepMC::FourVector& vtx_cms = in_vtx->position(); // in mm + const HepMC::FourVector& mom_cms = in_trk->momentum(); // transformation to LHC/TOTEM convention HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t()); diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc index 3072ec327e8ef..68913826099e7 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc @@ -31,14 +31,14 @@ class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> { public: explicit CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& ); - ~CTPPSDirectProtonSimulationValidator(); + ~CTPPSDirectProtonSimulationValidator() override; private: - virtual void beginJob() override; + void beginJob() override; - virtual void analyze( const edm::Event&, const edm::EventSetup& ) override; + void analyze( const edm::Event&, const edm::EventSetup& ) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT< std::vector > simuTracksToken_; edm::EDGetTokenT< std::vector > recoTracksToken_; @@ -47,7 +47,7 @@ class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> struct RPPlots { - TH2D *h2_xr_vs_xs=NULL, *h2_yr_vs_ys=NULL; + TH2D *h2_xr_vs_xs=nullptr, *h2_yr_vs_ys=nullptr; TH1D *h_de_x, *h_de_y; void init() @@ -60,7 +60,7 @@ class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> void fill(double simu_x, double simu_y, double reco_x, double reco_y) { - if (h2_xr_vs_xs == NULL) + if (h2_xr_vs_xs == nullptr) init(); h2_xr_vs_xs->Fill(simu_x, reco_x); diff --git a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc index e7834f59c6237..e975cb137b672 100644 --- a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc @@ -30,12 +30,12 @@ class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> public: explicit CTPPSHepMCDistributionPlotter(const edm::ParameterSet&); - ~CTPPSHepMCDistributionPlotter() {} + ~CTPPSHepMCDistributionPlotter() override {} private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT tokenHepMC_; diff --git a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc index 977f9e62d9068..cff9c9adfe63e 100644 --- a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc +++ b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc @@ -21,7 +21,7 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord public: CTPPSLHCInfoESSource(const edm::ParameterSet &); - ~CTPPSLHCInfoESSource() {}; + ~CTPPSLHCInfoESSource() override {}; edm::ESProducts> produce(const LHCInfoRcd &); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc index 7ba36bec3c4c9..8f16309adfa2e 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -29,12 +29,12 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> { public: explicit CTPPSProtonReconstructionPlotter(const edm::ParameterSet&); - ~CTPPSProtonReconstructionPlotter() {} + ~CTPPSProtonReconstructionPlotter() override {} private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT> tokenTracks_; edm::EDGetTokenT> tokenRecoProtonsSingleRP_; @@ -70,10 +70,10 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct SingleRPPlots { - TH1D *h_xi = NULL; + TH1D *h_xi = nullptr; - TH2D *h2_th_y_vs_xi = NULL; - TProfile *p_th_y_vs_xi = NULL; + TH2D *h2_th_y_vs_xi = nullptr; + TProfile *p_th_y_vs_xi = nullptr; void init() { @@ -111,10 +111,10 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct MultiRPPlots { - TH1D *h_xi=NULL, *h_th_x=NULL, *h_th_y=NULL, *h_vtx_y=NULL, *h_t=NULL, *h_chi_sq=NULL, *h_chi_sq_norm=NULL; - TH1D *h_t_xi_range1=NULL, *h_t_xi_range2=NULL, *h_t_xi_range3=NULL; - TH2D *h2_th_x_vs_xi = NULL, *h2_th_y_vs_xi = NULL, *h2_vtx_y_vs_xi = NULL, *h2_t_vs_xi; - TProfile *p_th_x_vs_xi = NULL, *p_th_y_vs_xi = NULL, *p_vtx_y_vs_xi = NULL; + TH1D *h_xi=nullptr, *h_th_x=nullptr, *h_th_y=nullptr, *h_vtx_y=nullptr, *h_t=nullptr, *h_chi_sq=nullptr, *h_chi_sq_norm=nullptr; + TH1D *h_t_xi_range1=nullptr, *h_t_xi_range2=nullptr, *h_t_xi_range3=nullptr; + TH2D *h2_th_x_vs_xi = nullptr, *h2_th_y_vs_xi = nullptr, *h2_vtx_y_vs_xi = nullptr, *h2_t_vs_xi; + TProfile *p_th_x_vs_xi = nullptr, *p_th_y_vs_xi = nullptr, *p_vtx_y_vs_xi = nullptr; void init() { @@ -236,14 +236,14 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct SingleMultiCorrelationPlots { - TH2D *h2_xi_mu_vs_xi_si = NULL; - TH1D *h_xi_diff_mu_si = NULL; - TH1D *h_xi_diff_si_mu = NULL; + TH2D *h2_xi_mu_vs_xi_si = nullptr; + TH1D *h_xi_diff_mu_si = nullptr; + TH1D *h_xi_diff_si_mu = nullptr; - TH2D *h2_xi_diff_si_mu_vs_xi_mu = NULL; - TProfile *p_xi_diff_si_mu_vs_xi_mu = NULL; + TH2D *h2_xi_diff_si_mu_vs_xi_mu = nullptr; + TProfile *p_xi_diff_si_mu_vs_xi_mu = nullptr; - TH2D *h2_th_y_mu_vs_th_y_si = NULL; + TH2D *h2_th_y_mu_vs_th_y_si = nullptr; void init() { @@ -295,11 +295,11 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct ArmCorrelationPlots { - TH1D *h_xi_si_diffNF = NULL; - TProfile *p_xi_si_diffNF_vs_xi_mu = NULL; + TH1D *h_xi_si_diffNF = nullptr; + TProfile *p_xi_si_diffNF_vs_xi_mu = nullptr; - TH1D *h_th_y_si_diffNF = NULL; - TProfile *p_th_y_si_diffNF_vs_xi_mu = NULL; + TH1D *h_th_y_si_diffNF = nullptr; + TProfile *p_th_y_si_diffNF_vs_xi_mu = nullptr; void init() { @@ -389,17 +389,17 @@ void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const ed Handle> hRecoProtonsMultiRP; event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); - if (hRecoProtonsSingleRP->size() > 0) + if (!hRecoProtonsSingleRP->empty()) n_non_empty_events_++; if (maxNonEmptyEvents_ > 0 && n_non_empty_events_ > maxNonEmptyEvents_) throw cms::Exception("CTPPSProtonReconstructionPlotter") << "Number of non empty events reached maximum."; // track plots - const CTPPSLocalTrackLite *tr_L_N = NULL; - const CTPPSLocalTrackLite *tr_L_F = NULL; - const CTPPSLocalTrackLite *tr_R_N = NULL; - const CTPPSLocalTrackLite *tr_R_F = NULL; + const CTPPSLocalTrackLite *tr_L_N = nullptr; + const CTPPSLocalTrackLite *tr_L_F = nullptr; + const CTPPSLocalTrackLite *tr_R_N = nullptr; + const CTPPSLocalTrackLite *tr_R_F = nullptr; for (const auto &tr : *hTracks) { @@ -461,8 +461,8 @@ void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const ed } // arm correlation plots - const reco::ProtonTrack *p_arm0_s_N = NULL, *p_arm0_s_F = NULL, *p_arm0_m = NULL; - const reco::ProtonTrack *p_arm1_s_N = NULL, *p_arm1_s_F = NULL, *p_arm1_m = NULL; + const reco::ProtonTrack *p_arm0_s_N = nullptr, *p_arm0_s_F = nullptr, *p_arm0_m = nullptr; + const reco::ProtonTrack *p_arm1_s_N = nullptr, *p_arm1_s_F = nullptr, *p_arm1_m = nullptr; for (const auto &proton : *hRecoProtonsSingleRP) { diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index 94c8fd223cebd..d392f3ddc384e 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -35,12 +35,12 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer public: explicit CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet&); - ~CTPPSProtonReconstructionSimulationValidator() {} + ~CTPPSProtonReconstructionSimulationValidator() override {} private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ProtonTrack &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo); @@ -55,20 +55,20 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer struct PlotGroup { - TH1D *h_de_xi = NULL; + TH1D *h_de_xi = nullptr; TProfile *p_de_xi_vs_xi_simu; TH2D *h_xi_reco_vs_xi_simu; - TH1D *h_de_th_x = NULL; + TH1D *h_de_th_x = nullptr; TProfile *p_de_th_x_vs_xi_simu; - TH1D *h_de_th_y = NULL; + TH1D *h_de_th_y = nullptr; TProfile *p_de_th_y_vs_xi_simu; - TH1D *h_de_vtx_y = NULL; + TH1D *h_de_vtx_y = nullptr; TProfile *p_de_vtx_y_vs_xi_simu; - TH1D *h_de_t = NULL; + TH1D *h_de_t = nullptr; TProfile *p_de_t_vs_xi_simu; TProfile *p_de_t_vs_t_simu; @@ -319,7 +319,7 @@ void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_i const double t_reco = - rec_pr.t(); auto &p = plots_[meth_idx][idx]; - if (p.h_de_xi == NULL) + if (p.h_de_xi == nullptr) p.init(); p.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 26497822c1753..657e025c70ae5 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -35,12 +35,12 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> public: explicit CTPPSProtonReconstructionValidator(const edm::ParameterSet&); - ~CTPPSProtonReconstructionValidator() {} + ~CTPPSProtonReconstructionValidator() override {} private: - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT> tokenRecoProtons_; @@ -55,7 +55,7 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> struct RPPlots { - TH1D *h_de_x = NULL, *h_de_y; + TH1D *h_de_x = nullptr, *h_de_y; void init() { @@ -65,7 +65,7 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> void fill(double de_x, double de_y) { - if (h_de_x == NULL) + if (h_de_x == nullptr) init(); h_de_x->Fill(de_x); diff --git a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc index e01d18d000eb1..0e858e036e30a 100644 --- a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc @@ -33,12 +33,12 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> public: explicit CTPPSTrackDistributionPlotter(const edm::ParameterSet&); - ~CTPPSTrackDistributionPlotter() {} + ~CTPPSTrackDistributionPlotter() override {} private: - virtual void analyze( const edm::Event&, const edm::EventSetup& ) override; + void analyze( const edm::Event&, const edm::EventSetup& ) override; - virtual void endJob() override; + void endJob() override; edm::EDGetTokenT< std::vector > tracksToken_; @@ -59,7 +59,7 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> void fill(double x, double y) { - if (h2_y_vs_x == NULL) + if (h2_y_vs_x == nullptr) init(); h2_y_vs_x->Fill(x, y); @@ -91,7 +91,7 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> void fill(double x_N, double y_N, double x_F, double y_F) { - if (p2_de_x_vs_x_y == NULL) + if (p2_de_x_vs_x_y == nullptr) init(); p2_de_x_vs_x_y->Fill(x_N, y_N, x_F - x_N); From ac99e9c826611e9b47d7fddd35ea6e51ca3bd43e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 14 Dec 2018 13:50:56 +0100 Subject: [PATCH 126/686] Clang warnings addressed. --- .../plugins/CTPPSBeamParametersESSource.cc | 2 +- CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc index 5ad5f7df52c84..adb4f868049b2 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc @@ -106,7 +106,7 @@ CTPPSBeamParametersESSource::produce( const CTPPSBeamParametersRcd & ) edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp; - return std::move( bp ); + return bp; } //---------------------------------------------------------------------------------------------------- diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index 29de973cb4e2c..135a5b09be8f4 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -102,8 +102,8 @@ LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::interpolate(double xangle1, cons double xangle2, const LHCOpticalFunctionsSet &of2, double xangle) { // check whether interpolation can be done - if (abs(xangle1 - xangle2) < 1e-6) { - if (abs(xangle - xangle1) < 1e-6) + if (std::abs(xangle1 - xangle2) < 1e-6) { + if (std::abs(xangle - xangle1) < 1e-6) return new LHCOpticalFunctionsSet(of1); else throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot interpolate from angles " << xangle1 << From d1fc3ea8e2d2d65f1807289d36714c64f558e959 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 19 Dec 2018 13:48:11 +0100 Subject: [PATCH 127/686] Applied suggestions for thread safety. --- .../interface/LHCOpticalFunctionsSet.h | 4 ++-- RecoCTPPS/ProtonReconstruction/BuildFile.xml | 15 ++++++++------- .../interface/ProtonReconstructionAlgorithm.h | 2 +- .../src/ProtonReconstructionAlgorithm.cc | 17 ++++++++++------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index 1590cd12c866f..9e30366a2afa2 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -27,7 +27,7 @@ class LHCOpticalFunctionsSet double getScoringPlaneZ() const { return m_z; } const std::vector& getXiValues() const { return m_xi_values; } const std::array, 16>& getFcnValues() const { return m_fcn_values; } - const std::array, 16>& getSplines() const { return m_splines; } + const std::array, 16>& getSplines() const { return m_splines; } /// builds splines from m_*_values fields void initializeSplines(); @@ -54,7 +54,7 @@ class LHCOpticalFunctionsSet double m_z; std::vector m_xi_values; std::array, 16> m_fcn_values; - std::array, 16> m_splines; + std::array, 16> m_splines; COND_SERIALIZABLE; }; diff --git a/RecoCTPPS/ProtonReconstruction/BuildFile.xml b/RecoCTPPS/ProtonReconstruction/BuildFile.xml index cd2759054145a..a87f2226bea56 100644 --- a/RecoCTPPS/ProtonReconstruction/BuildFile.xml +++ b/RecoCTPPS/ProtonReconstruction/BuildFile.xml @@ -1,12 +1,13 @@ - - - + + - - - + - + + + + + diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index b813cebf7912c..49d23fe668ce6 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -53,7 +53,7 @@ class ProtonReconstructionAlgorithm struct RPOpticsData { const LHCOpticalFunctionsSet *optics; - std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; + std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; double x0; ///< beam horizontal position, m double y0; ///< beam vertical position, m double ch0; ///< intercept for linear approximation of \f$x(\xi)\f$ diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 799ffc799af57..984687ed183b7 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -12,6 +12,7 @@ #include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" #include "TF1.h" +#include "TMinuitMinimizer.h" using namespace std; using namespace edm; @@ -24,6 +25,9 @@ ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, uns initialized_(false), fitter_(new ROOT::Fit::Fitter), chiSquareCalculator_(new ChiSquareCalculator) { + // needed for thread safety + TMinuitMinimizer::UseStaticMinuit(false); + // initialise fitter double pStart[] = { 0, 0, 0, 0 }; fitter_->SetFCN(4, *chiSquareCalculator_, pStart, 0, true); @@ -36,8 +40,8 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map ff(new TF1("ff", "[0] + [1]*x")); + // prepare helper objects (special flag needed for thread safety) + unique_ptr ff(new TF1("ff", "[0] + [1]*x", 0., 1., TF1::EAddToList::kNo)); // build optics data for each object for (const auto &p : opticalFunctions) @@ -48,7 +52,7 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map("", - (double *) ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data(), + (double *) ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data(), // const cast away necessary due to the ROOT interface (double *) ofs.getXiValues().data(), ofs.getXiValues().size()); rpod.s_y_d_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eyd]; rpod.s_v_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::evy]; @@ -61,12 +65,13 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map g_x_d_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data()); ff->SetParameters(0., 0.); g_x_d_vs_xi->Fit(ff.get(), "Q"); - g_x_d_vs_xi->Fit(ff.get(), "Q"); - g_x_d_vs_xi->Fit(ff.get(), "Q"); rpod.ch0 = ff->GetParameter(0) - rpod.x0; rpod.ch1 = ff->GetParameter(1); @@ -74,8 +79,6 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_mapSetParameters(0., 0.); g_L_x_vs_xi->Fit(ff.get(), "Q"); - g_L_x_vs_xi->Fit(ff.get(), "Q"); - g_L_x_vs_xi->Fit(ff.get(), "Q"); rpod.la0 = ff->GetParameter(0); rpod.la1 = ff->GetParameter(1); From 56810d72b730d958c5e8032fc16829969724bfc2 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 19 Dec 2018 13:48:44 +0100 Subject: [PATCH 128/686] Added getters for time of proton arrival at RPs. --- DataFormats/ProtonReco/interface/ProtonTrack.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index fdd8a65e71b28..c39ee68ea583b 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -53,6 +53,10 @@ namespace reco /// four-momentum transfer squared, in GeV^2 float t() const; + /// conveniece getters for time of proton arrival at RPs + float time() const { return t0(); } + float timeError() const { return t0Error(); } + /// LHC sector enum class LHCSector { invalid = -1, sector45, sector56 }; LHCSector lhcSector() const From 3d9d7765b476eebd64eedaad04e6ac6bfb8b2b0d Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 19 Dec 2018 13:49:06 +0100 Subject: [PATCH 129/686] Reconstructed protons added to standard event content. --- RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py index fdbcbbd05b857..5a1f48851f184 100644 --- a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py @@ -34,7 +34,9 @@ 'keep CTPPSPixelLocalTrackedmDetSetVector_ctppsPixelLocalTracks_*_*', # CTPPS common - 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*' + 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', + 'keep recoProtonTracks_ctppsProtonReconstruction_*_*', + 'keep recoProtonTrackExtras_ctppsProtonReconstruction_*_*' ) ) From 839023131ee958e3aeefa23ce2d6f4d8e7a8efc4 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 19 Dec 2018 13:49:35 +0100 Subject: [PATCH 130/686] Added validity interval. --- .../CTPPS/plugins/CTPPSLHCInfoESSource.cc | 40 +++++++++++++++++-- .../year_2016/ctppsLHCInfoESSource_cfi.py | 1 + 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc index cff9c9adfe63e..9a4d47a00ef69 100644 --- a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc +++ b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc @@ -26,9 +26,12 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord edm::ESProducts> produce(const LHCInfoRcd &); private: + edm::EventRange m_validityRange; double m_beamEnergy; double m_xangle; + bool m_insideValidityRange; + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; }; @@ -36,8 +39,10 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord //---------------------------------------------------------------------------------------------------- CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : + m_validityRange(conf.getParameter("validityRange")), m_beamEnergy(conf.getParameter("beamEnergy")), - m_xangle(conf.getParameter("xangle")) + m_xangle(conf.getParameter("xangle")), + m_insideValidityRange(false) { setWhatProduced(this); findingRecord(); @@ -48,7 +53,28 @@ CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { - oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); + if (edm::contains(m_validityRange, iosv.eventID())) + { + m_insideValidityRange = true; + oValidity = edm::ValidityInterval(edm::IOVSyncValue(m_validityRange.startEventID()), edm::IOVSyncValue(m_validityRange.endEventID())); + } else { + m_insideValidityRange = false; + + if (iosv.eventID() < m_validityRange.startEventID()) + { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID endEvent = (lb > 1) ? edm::EventID(run, lb-1, 0) : edm::EventID(run-1, edm::EventID::maxLuminosityBlockNumber(), 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(endEvent)); + } else { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber()-1) ? edm::EventID(run, lb+1, 0) : edm::EventID(run+1, 0, 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); + } + } } //---------------------------------------------------------------------------------------------------- @@ -57,8 +83,14 @@ edm::ESProducts> CTPPSLHCInfoESSource::produce(const LH { auto output = std::make_unique(); - output->setEnergy(m_beamEnergy); - output->setCrossingAngle(m_xangle); + if (m_insideValidityRange) + { + output->setEnergy(m_beamEnergy); + output->setCrossingAngle(m_xangle); + } else { + output->setEnergy(0.); + output->setCrossingAngle(0.); + } return edm::es::products(std::move(output)); } diff --git a/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py index da4dfc3d864fe..cc9fe235d3e14 100644 --- a/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", + validityRange = cms.EventRange("270293:min - 290872:max"), beamEnergy = cms.double(6500), # GeV xangle = cms.double(185) # murad ) From 70d60f0e96e9b219c57b398e010349323c0c626e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 19 Dec 2018 13:50:11 +0100 Subject: [PATCH 131/686] Fixed handling of unspecified xangle. --- .../plugins/CTPPSProtonReconstruction.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index e64ca3e686ff7..813bb3fdeab21 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -125,19 +125,19 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet { LogWarning("CTPPSProtonReconstruction") << "Invalid crossing angle, reconstruction disabled."; algorithm_.release(); + } else { + if (verbosity_) + edm::LogInfo("CTPPSProtonReconstruction") << "Setting crossing angle " << currentCrossingAngle_; + + // interpolate optical functions + opticalFunctions_.clear(); + hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); + for (auto &p : opticalFunctions_) + p.second.initializeSplines(); + + // reinitialise algorithm + algorithm_.init(opticalFunctions_); } - - if (verbosity_) - edm::LogInfo("CTPPSProtonReconstruction") << "Setting crossing angle " << currentCrossingAngle_; - - // interpolate optical functions - opticalFunctions_.clear(); - hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); - for (auto &p : opticalFunctions_) - p.second.initializeSplines(); - - // reinitialise algorithm - algorithm_.init(opticalFunctions_); } } From cb029b6ac1aec6c7bf37dce312deb0dd837801a7 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 12:21:19 +0100 Subject: [PATCH 132/686] Stripped out any dependency on reco::Track for the reco::ProtonTrack object --- .../ProtonReco/interface/ProtonTrack.h | 83 +++++++++++++++---- DataFormats/ProtonReco/src/ProtonTrack.cc | 12 +-- DataFormats/ProtonReco/src/classes_def.xml | 2 +- .../src/ProtonReconstructionAlgorithm.cc | 12 +-- 4 files changed, 83 insertions(+), 26 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index c39ee68ea583b..63d37f61b9919 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -7,22 +7,53 @@ #ifndef DataFormats_ProtonReco_ProtonTrack_h #define DataFormats_ProtonReco_ProtonTrack_h -#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/Math/interface/Error.h" +#include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/Math/interface/Vector3D.h" + #include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" #include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" namespace reco { - class ProtonTrack : public Track + class ProtonTrack { + public: + /// parameter dimension + enum { dimension = 5 }; + /// indices to the covariance matrix + enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension }; + /// dimension-parameter covariance matrix + typedef math::Error::type CovarianceMatrix; + /// spatial vector + typedef math::XYZVector Vector; + /// point in the space + typedef math::XYZPoint Point; + public: /// Default constructor ProtonTrack(); /// Constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); - /// Indices to the covariance matrix - enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices }; + const Point& vertex() const { return vertex_; } + float vx() const { return vertex_.x(); } + float vy() const { return vertex_.y(); } + float vz() const { return vertex_.z(); } + const Vector& momentum() const { return momentum_; } + float p() const { return momentum_.R(); } + float px() const { return momentum_.x(); } + float py() const { return momentum_.y(); } + float pz() const { return momentum_.z(); } + + /// chi-squared of the fit + float chi2() const { return chi2_; } + /// number of degrees of freedom for the track fit + unsigned int ndof() const { return ndof_; } + /// chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero) + float normalizedChi2() const { + return ( ndof_ != 0 ) ? chi2_ / ndof_ : chi2_ * 1.e6; + } /// longitudinal fractional momentum loss float xi() const { return xi_; } @@ -34,15 +65,15 @@ namespace reco // vertex position can be obtained via TrackBase::vx() and vy() functions /// uncertainty on longitudinal fractional momentum loss - float xiError() const { return error( (int)Index::xi ); } + float xiError() const { return error( Index::xi ); } /// uncertainty on fitted momentum horizontal angle opening - float thetaXError() const { return error( (int)Index::th_x ); } + float thetaXError() const { return error( Index::th_x ); } /// uncertainty on fitted momentum vertical angle opening - float thetaYError() const { return error( (int)Index::th_y ); } + float thetaYError() const { return error( Index::th_y ); } /// uncertainty on fitted vertex horizontal position - float vertexXError() const { return error( (int)Index::vtx_x ); } + float vertexXError() const { return error( Index::vtx_x ); } /// uncertainty on fitted vertex vertical position - float vertexYError() const { return error( (int)Index::vtx_y ); } + float vertexYError() const { return error( Index::vtx_y ); } /// proton mass in GeV static float mass() { return mass_; } @@ -54,8 +85,8 @@ namespace reco float t() const; /// conveniece getters for time of proton arrival at RPs - float time() const { return t0(); } - float timeError() const { return t0Error(); } + float time() const { return t_; } + float timeError() const { return t_err_; } /// LHC sector enum class LHCSector { invalid = -1, sector45, sector56 }; @@ -75,11 +106,35 @@ namespace reco const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } private: - float xi_; ///< fractional momentum loss (positive for diffractive protons) - ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track - static constexpr float mass_ = 0.938272046; ///< proton mass, GeV static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 + + /*inline size_t covIndex( Index i, Index j ) const { + const size_t a = ( i <= j ? i : j ), b = ( i <= j ? j : i ); + return b * 0.5*( b + 1 ) + a; + }*/ + double error( Index i ) const { + return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) ); + } + + /// reconstructed vertex position at z/s = 0 + Point vertex_; + /// reconstructed momentum vector + Vector momentum_; + /// reconstructed time at forward detectors + float t_; + /// uncertainty on reconstructed time at forward detectors + float t_err_; + /// fractional momentum loss (positive for diffractive protons) + float xi_; + /// 5x5 covariance matrix + CovarianceMatrix covariance_; + /// chi-squared + float chi2_; + /// number of degrees of freedom + unsigned int ndof_; + ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track + }; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index f0e8ed071a95c..50a30f716cd20 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -11,16 +11,18 @@ using namespace reco; ProtonTrack::ProtonTrack() : - xi_( 0. ) + t_( 0. ), t_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ) {} ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov ) : - Track( chi2, ndof, vtx, momentum, +1, cov ), xi_( xi ) + vertex_( vtx ), momentum_( momentum ), + t_( 0. ), t_err_( 0. ), xi_( xi ), + covariance_( cov ), chi2_( chi2 ), ndof_( ndof ) {} float ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) { - const double t0 = 2.*massSquared_ + 2.*beam_mom*proton_mom - 2.*sqrt( (massSquared_ + beam_mom*beam_mom) * (massSquared_ + proton_mom*proton_mom) ); + const double t0 = 2.*( massSquared_+beam_mom*proton_mom-sqrt( ( massSquared_+beam_mom*beam_mom ) * ( massSquared_+proton_mom*proton_mom ) ) ); const double S = sin(theta/2.); return t0 - 4. * beam_mom * proton_mom * S*S; } @@ -28,6 +30,6 @@ float ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta float ProtonTrack::t() const { const double beam_mom = p() / (1.-xi()); - const double theta = sqrt(thetaX()*thetaX() + thetaY()*thetaY()); - return calculateT(beam_mom, p(), theta); + const double theta = std::hypot( thetaX(), thetaY() ); + return calculateT( beam_mom, p(), theta ); } diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index 9e7b65051cae6..fddaf82813ba4 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,6 +1,6 @@ - + diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 984687ed183b7..c3e033a17d35b 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -279,13 +279,13 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( reco::ProtonTrackExtra ptExtra(result.IsValid(), EX::ReconstructionMethod::multiRP, tracks); const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention - const reco::Track::Point vertex(0., params[3]*1E2, 0.); // vertex in cm + const reco::ProtonTrack::Point vertex(0., params[3]*1E2, 0.); // vertex in cm const double xi = params[0]; const double th_x = params[1]; const double th_y = params[2]; const double cos_th = sqrt(1. - th_x*th_x - th_y*th_y); const double p = lhcInfo.energy() * (1. - xi); - const reco::Track::Vector momentum( + const reco::ProtonTrack::Vector momentum( - p * th_x, // the signs reflect change LHC --> CMS convention + p * th_y, sign_z * p * cos_th @@ -300,7 +300,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( {(unsigned int) reco::ProtonTrack::Index::vtx_x, -1}, }; - reco::TrackBase::CovarianceMatrix cm; + reco::ProtonTrack::CovarianceMatrix cm; for (unsigned int i = 0; i < (unsigned int) reco::ProtonTrack::Index::num_indices; ++i) { signed int fit_i = index_map[i]; @@ -373,12 +373,12 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( reco::ProtonTrackExtra ptExtra(valid, EX::ReconstructionMethod::singleRP, { track }); const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention - const reco::Track::Point vertex(0., 0., 0.); + const reco::ProtonTrack::Point vertex(0., 0., 0.); const double cos_th = sqrt(1. - th_y*th_y); const double p = lhcInfo.energy() * (1. - xi); - const reco::Track::Vector momentum(0., p * th_y, sign_z * p * cos_th); + const reco::ProtonTrack::Vector momentum(0., p * th_y, sign_z * p * cos_th); - reco::TrackBase::CovarianceMatrix cm; + reco::ProtonTrack::CovarianceMatrix cm; cm((int)PT::Index::xi, (int)PT::Index::xi) = xi_unc * xi_unc; cm((int)PT::Index::th_y, (int)PT::Index::th_y) = th_y_unc * th_y_unc; From e9a0357ea2ca2a8c335b753075710a39f55dd52d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 12:41:17 +0100 Subject: [PATCH 133/686] Moved all proton track extra attributes to standard proton track object --- .../ProtonReco/interface/ProtonTrack.h | 38 ++++++++++++------- DataFormats/ProtonReco/src/ProtonTrack.cc | 12 ++++-- DataFormats/ProtonReco/src/classes.h | 11 ------ DataFormats/ProtonReco/src/classes_def.xml | 13 +------ .../python/RecoCTPPS_EventContent_cff.py | 1 - .../interface/ProtonReconstructionAlgorithm.h | 9 ++--- .../plugins/CTPPSProtonReconstruction.cc | 31 ++++----------- .../src/ProtonReconstructionAlgorithm.cc | 22 +++++------ ...ProtonReconstructionSimulationValidator.cc | 8 ++-- 9 files changed, 57 insertions(+), 88 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 63d37f61b9919..9430248f45415 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -10,9 +10,8 @@ #include "DataFormats/Math/interface/Error.h" #include "DataFormats/Math/interface/Point3D.h" #include "DataFormats/Math/interface/Vector3D.h" - -#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" namespace reco { @@ -30,6 +29,11 @@ namespace reco /// point in the space typedef math::XYZPoint Point; + using CTPPSLocalTrackLiteRefVector = std::vector > >; + + /// Type of reconstruction for this track + enum class ReconstructionMethod { invalid = -1, singleRP, multiRP }; + public: /// Default constructor ProtonTrack(); @@ -88,6 +92,21 @@ namespace reco float time() const { return t_; } float timeError() const { return t_err_; } + /// Set the flag for the fit validity + void setValidFit( bool valid = true ) { valid_fit_ = valid; } + /// Flag for the fit validity + bool validFit() const { return valid_fit_; } + + /// Set the reconstruction method for this track + void setMethod( const ReconstructionMethod& method ) { method_ = method; } + /// Reconstruction method for this track + ReconstructionMethod method() const { return method_; } + + /// Store the list of RP tracks that contributed to this global track + void setContributingLocalTracks( const CTPPSLocalTrackLiteRefVector &v ) { contributing_local_tracks_ = v; } + /// List of RP tracks that contributed to this global track + const CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return contributing_local_tracks_; } + /// LHC sector enum class LHCSector { invalid = -1, sector45, sector56 }; LHCSector lhcSector() const @@ -97,14 +116,6 @@ namespace reco return LHCSector::invalid; } - // convenience getters for the extra information - bool validFit() const { return pt_extra_->validFit(); } - ProtonTrackExtra::ReconstructionMethod method() const { return pt_extra_->method(); } - const ProtonTrackExtra::CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return pt_extra_->contributingLocalTracks(); } - - void setProtonTrackExtra( const ProtonTrackExtraRef& ref ) { pt_extra_ = ref; } - const ProtonTrackExtraRef& protonTrackExtra() const { return pt_extra_; } - private: static constexpr float mass_ = 0.938272046; ///< proton mass, GeV static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 @@ -133,8 +144,9 @@ namespace reco float chi2_; /// number of degrees of freedom unsigned int ndof_; - ProtonTrackExtraRef pt_extra_; ///< Additional information on proton track - + bool valid_fit_; + ReconstructionMethod method_; + CTPPSLocalTrackLiteRefVector contributing_local_tracks_; }; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index 50a30f716cd20..d9b1be301acb3 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -11,23 +11,27 @@ using namespace reco; ProtonTrack::ProtonTrack() : - t_( 0. ), t_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ) + t_( 0. ), t_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ), + valid_fit_( false ), method_( ReconstructionMethod::invalid ) {} ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov ) : vertex_( vtx ), momentum_( momentum ), t_( 0. ), t_err_( 0. ), xi_( xi ), - covariance_( cov ), chi2_( chi2 ), ndof_( ndof ) + covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), + valid_fit_( false ), method_( ReconstructionMethod::invalid ) {} -float ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) +float +ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) { const double t0 = 2.*( massSquared_+beam_mom*proton_mom-sqrt( ( massSquared_+beam_mom*beam_mom ) * ( massSquared_+proton_mom*proton_mom ) ) ); const double S = sin(theta/2.); return t0 - 4. * beam_mom * proton_mom * S*S; } -float ProtonTrack::t() const +float +ProtonTrack::t() const { const double beam_mom = p() / (1.-xi()); const double theta = std::hypot( thetaX(), thetaY() ); diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h index dbaffeb696661..d8ed79f25456a 100644 --- a/DataFormats/ProtonReco/src/classes.h +++ b/DataFormats/ProtonReco/src/classes.h @@ -1,7 +1,5 @@ #include "DataFormats/ProtonReco/interface/ProtonTrack.h" #include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/View.h" @@ -20,14 +18,5 @@ namespace DataFormats_ProtonReco edm::RefProd > rp_vec_pt; edm::Ref,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > ref_vec_pt; edm::RefVector,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > rv_vec_pt; - - reco::ProtonTrackExtra pte; - std::vector vec_pte; - edm::Wrapper > wrp_vec_pte; - edm::RefProd > rp_vec_pte; - edm::Ref,reco::ProtonTrackExtra,edm::refhelper::FindUsingAdvance,reco::ProtonTrackExtra> > ref_vec_pte; - edm::RefVector,reco::ProtonTrackExtra,edm::refhelper::FindUsingAdvance,reco::ProtonTrackExtra> > rv_vec_pte; - - std::set set_uint; }; } diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index fddaf82813ba4..cc922d624c53d 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,21 +1,10 @@ - + - - - - - - - - - - - diff --git a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py index 5a1f48851f184..37ff1b2dcb9a6 100644 --- a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py @@ -36,7 +36,6 @@ # CTPPS common 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', 'keep recoProtonTracks_ctppsProtonReconstruction_*_*', - 'keep recoProtonTrackExtras_ctppsProtonReconstruction_*_*' ) ) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index 49d23fe668ce6..9c93ad61af43a 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -11,7 +11,6 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/ProtonReco/interface/ProtonTrack.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" @@ -33,15 +32,13 @@ class ProtonReconstructionAlgorithm void release(); /// run proton reconstruction using single-RP strategy - void reconstructFromSingleRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, + void reconstructFromSingleRP(const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &input, std::vector &output, - std::vector &outputExtra, const LHCInfo &lhcInfo, std::ostream& os) const; /// run proton reconstruction using multiple-RP strategy - void reconstructFromMultiRP(const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &input, + void reconstructFromMultiRP(const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &input, std::vector &output, - std::vector &outputExtra, const LHCInfo &lhcInfo, std::ostream& os) const; private: @@ -73,7 +70,7 @@ class ProtonReconstructionAlgorithm double operator() (const double *parameters) const; - const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector* tracks; + const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector* tracks; const std::map* m_rp_optics; }; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 813bb3fdeab21..9e09efd342638 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -16,7 +16,6 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtraFwd.h" #include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" @@ -73,15 +72,11 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC algorithm_ (iConfig.getParameter("fitVtxY"), verbosity_), currentCrossingAngle_(-1.) { - if (doSingleRPReconstruction_) { + if (doSingleRPReconstruction_) produces(singleRPLabel_); - produces(singleRPLabel_); - } - if (doMultiRPReconstruction_) { + if (doMultiRPReconstruction_) produces(multiRPLabel_); - produces(multiRPLabel_); - } } //---------------------------------------------------------------------------------------------------- @@ -151,7 +146,7 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector - reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + reco::ProtonTrack::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; @@ -188,15 +183,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet // single-RP reconstruction if (doSingleRPReconstruction_) { unique_ptr output(new reco::ProtonTrackCollection); - unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); - - auto ohExtra = event.put(move(outputExtra), singleRPLabel_); - - for (unsigned int i = 0; i < output->size(); ++i) - (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); + algorithm_.reconstructFromSingleRP(tracks_45, *output, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *hLHCInfo, ssLog); event.put(move(output), singleRPLabel_); } @@ -204,17 +193,11 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet // multi-RP reconstruction if (doMultiRPReconstruction_) { unique_ptr output(new reco::ProtonTrackCollection); - unique_ptr outputExtra(new reco::ProtonTrackExtraCollection); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *hLHCInfo, ssLog); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); - - auto ohExtra = event.put(move(outputExtra), multiRPLabel_); - - for (unsigned int i = 0; i < output->size(); ++i) - (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *hLHCInfo, ssLog); event.put(move(output), multiRPLabel_); } diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index c3e033a17d35b..ebc57804f7927 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -9,7 +9,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackExtra.h" +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" #include "TF1.h" #include "TMinuitMinimizer.h" @@ -145,9 +145,8 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou //---------------------------------------------------------------------------------------------------- void ProtonReconstructionAlgorithm::reconstructFromMultiRP( - const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, + const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, - std::vector &outputExtra, const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) @@ -273,11 +272,8 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( << ", chiSq = " << result.Chi2(); // save reco candidate - using EX = reco::ProtonTrackExtra; using PT = reco::ProtonTrack; - reco::ProtonTrackExtra ptExtra(result.IsValid(), EX::ReconstructionMethod::multiRP, tracks); - const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention const reco::ProtonTrack::Point vertex(0., params[3]*1E2, 0.); // vertex in cm const double xi = params[0]; @@ -314,17 +310,18 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( } reco::ProtonTrack pt(result.Chi2(), ndf, vertex, momentum, xi, cm); + pt.setValidFit(result.IsValid()); + pt.setMethod(PT::ReconstructionMethod::multiRP); + pt.setContributingLocalTracks(tracks); output.push_back(move(pt)); - outputExtra.push_back(move(ptExtra)); } //---------------------------------------------------------------------------------------------------- void ProtonReconstructionAlgorithm::reconstructFromSingleRP( - const reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector &tracks, + const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &tracks, std::vector &output, - std::vector &outputExtra, const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) @@ -365,12 +362,9 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( if (verbosity_) os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; - using EX = reco::ProtonTrackExtra; using PT = reco::ProtonTrack; // save proton candidate - const bool valid = true; - reco::ProtonTrackExtra ptExtra(valid, EX::ReconstructionMethod::singleRP, { track }); const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention const reco::ProtonTrack::Point vertex(0., 0., 0.); @@ -383,9 +377,11 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( cm((int)PT::Index::th_y, (int)PT::Index::th_y) = th_y_unc * th_y_unc; reco::ProtonTrack pt(0., 0, vertex, momentum, xi, cm); + pt.setValidFit(true); + pt.setMethod(PT::ReconstructionMethod::singleRP); + pt.setContributingLocalTracks({ track }); output.push_back(move(pt)); - outputExtra.push_back(move(ptExtra)); } } diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index d392f3ddc384e..5bfb1bd4ba71b 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -281,7 +281,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv unsigned int meth_idx = 1234; - if (rec_pr.method() == reco::ProtonTrackExtra::ReconstructionMethod::singleRP) + if (rec_pr.method() == reco::ProtonTrack::ReconstructionMethod::singleRP) { meth_idx = 0; @@ -289,7 +289,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv idx = 100*rpId.arm() + 10*rpId.station() + rpId.rp(); } - if (rec_pr.method() == reco::ProtonTrackExtra::ReconstructionMethod::multiRP) + if (rec_pr.method() == reco::ProtonTrack::ReconstructionMethod::multiRP) { meth_idx = 1; } @@ -355,9 +355,9 @@ void CTPPSProtonReconstructionSimulationValidator::endJob() { char buf[20]; sprintf(buf, "%i", eit.first); - + TDirectory *d_element = d_method->mkdir(buf); - + gDirectory = d_element; eit.second.write(); } From ce3de647aa7e7b84416526218056229718b6950c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 12:46:52 +0100 Subject: [PATCH 134/686] Improved doxygen documentation --- DataFormats/ProtonReco/interface/ProtonTrack.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 9430248f45415..d3c0f3de7db5d 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -40,14 +40,23 @@ namespace reco /// Constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); + /// fitted vertex position const Point& vertex() const { return vertex_; } + /// fitted vertex horizontal position float vx() const { return vertex_.x(); } + /// fitted vertex vertical position float vy() const { return vertex_.y(); } + /// vertex longitudinal position (conventionally set to 0) float vz() const { return vertex_.z(); } + /// fitted track direction const Vector& momentum() const { return momentum_; } + /// scalar norm of fitted track momentum float p() const { return momentum_.R(); } + /// fitted track momentum horizontal component float px() const { return momentum_.x(); } + /// fitted track momentum vertical component float py() const { return momentum_.y(); } + /// fitted track momentum longitudinal component float pz() const { return momentum_.z(); } /// chi-squared of the fit From 810b8fbc65195a79f0b05d3db9f98115057322b8 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 12:48:15 +0100 Subject: [PATCH 135/686] Slight change in vertex coordinates error access methods to match coordinates access methods --- DataFormats/ProtonReco/interface/ProtonTrack.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index d3c0f3de7db5d..2fbd24cc75f8e 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -84,9 +84,9 @@ namespace reco /// uncertainty on fitted momentum vertical angle opening float thetaYError() const { return error( Index::th_y ); } /// uncertainty on fitted vertex horizontal position - float vertexXError() const { return error( Index::vtx_x ); } + float vxError() const { return error( Index::vtx_x ); } /// uncertainty on fitted vertex vertical position - float vertexYError() const { return error( Index::vtx_y ); } + float vyError() const { return error( Index::vtx_y ); } /// proton mass in GeV static float mass() { return mass_; } From 9a6c01370ccdec888f035419e13332d2ecb20c2a Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 14:55:48 +0100 Subject: [PATCH 136/686] Added pt retrieval method on ProtonTrack --- DataFormats/ProtonReco/interface/ProtonTrack.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 2fbd24cc75f8e..2c42165a05183 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -51,7 +51,9 @@ namespace reco /// fitted track direction const Vector& momentum() const { return momentum_; } /// scalar norm of fitted track momentum - float p() const { return momentum_.R(); } + float p() const { return momentum_.r(); } + /// scalar fitted track transverse momentum + float pt() const { return momentum_.rho(); } /// fitted track momentum horizontal component float px() const { return momentum_.x(); } /// fitted track momentum vertical component @@ -97,8 +99,9 @@ namespace reco /// four-momentum transfer squared, in GeV^2 float t() const; - /// conveniece getters for time of proton arrival at RPs + /// time of proton arrival at forward stations float time() const { return t_; } + /// uncertainty on time of proton arrival at forward stations float timeError() const { return t_err_; } /// Set the flag for the fit validity From 033f022598acd3ca2bf8cbd0e0f42278c88af25f Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 14:58:28 +0100 Subject: [PATCH 137/686] Finalised the doxygen documentation for ProtonTrack --- .../ProtonReco/interface/ProtonTrack.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 2c42165a05183..966f18bb552ab 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -31,13 +31,13 @@ namespace reco using CTPPSLocalTrackLiteRefVector = std::vector > >; - /// Type of reconstruction for this track + /// type of reconstruction applied for this track enum class ReconstructionMethod { invalid = -1, singleRP, multiRP }; public: - /// Default constructor + /// default constructor ProtonTrack(); - /// Constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss + /// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); /// fitted vertex position @@ -104,19 +104,19 @@ namespace reco /// uncertainty on time of proton arrival at forward stations float timeError() const { return t_err_; } - /// Set the flag for the fit validity + /// set the flag for the fit validity void setValidFit( bool valid = true ) { valid_fit_ = valid; } - /// Flag for the fit validity + /// flag for the fit validity bool validFit() const { return valid_fit_; } - /// Set the reconstruction method for this track + /// set the reconstruction method for this track void setMethod( const ReconstructionMethod& method ) { method_ = method; } - /// Reconstruction method for this track + /// reconstruction method for this track ReconstructionMethod method() const { return method_; } - /// Store the list of RP tracks that contributed to this global track + /// store the list of RP tracks that contributed to this global track void setContributingLocalTracks( const CTPPSLocalTrackLiteRefVector &v ) { contributing_local_tracks_ = v; } - /// List of RP tracks that contributed to this global track + /// list of RP tracks that contributed to this global track const CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return contributing_local_tracks_; } /// LHC sector @@ -132,10 +132,7 @@ namespace reco static constexpr float mass_ = 0.938272046; ///< proton mass, GeV static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 - /*inline size_t covIndex( Index i, Index j ) const { - const size_t a = ( i <= j ? i : j ), b = ( i <= j ? j : i ); - return b * 0.5*( b + 1 ) + a; - }*/ + /// return the uncertainty on a given component double error( Index i ) const { return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) ); } @@ -156,8 +153,11 @@ namespace reco float chi2_; /// number of degrees of freedom unsigned int ndof_; + /// fit validity flag bool valid_fit_; + /// type of reconstruction applied ReconstructionMethod method_; + /// collection of references to tracks contributing to this object definition CTPPSLocalTrackLiteRefVector contributing_local_tracks_; }; } From ba0a0be725711c53fb5cadd6a9d72a2c47858ffc Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 15:48:22 +0100 Subject: [PATCH 138/686] Eliminated uncessary BeamDivergenceVtxGenerator.h. --- .../src/BeamDivergenceVtxGenerator.cc | 32 +++++++++++++++++-- IOMC/EventVertexGenerators/src/module.cc | 2 -- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc index 853eb69080e38..8506da2b0e306 100644 --- a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc +++ b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc @@ -3,15 +3,19 @@ * Jan KaÅ¡par ****************************************************************************/ -#include "IOMC/EventVertexGenerators/interface/BeamDivergenceVtxGenerator.h" - +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" @@ -19,6 +23,25 @@ //---------------------------------------------------------------------------------------------------- +class BeamDivergenceVtxGenerator : public edm::stream::EDProducer<> +{ + public: + explicit BeamDivergenceVtxGenerator(const edm::ParameterSet&); + ~BeamDivergenceVtxGenerator() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + + void produce(edm::Event&, const edm::EventSetup&) override; + + private: + edm::EDGetTokenT sourceToken_; + + bool simulateVertex_; + bool simulateBeamDivergence_; +}; + +//---------------------------------------------------------------------------------------------------- + BeamDivergenceVtxGenerator::BeamDivergenceVtxGenerator(const edm::ParameterSet& iConfig) : sourceToken_(consumes( iConfig.getParameter("src"))), simulateVertex_ (iConfig.getParameter("simulateVertex")), @@ -106,6 +129,8 @@ BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSetup &i iEvent.put(std::move(pEvent)); } +//---------------------------------------------------------------------------------------------------- + void BeamDivergenceVtxGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -118,3 +143,6 @@ BeamDivergenceVtxGenerator::fillDescriptions(edm::ConfigurationDescriptions& des descriptions.add("beamDivergenceVtxGenerator", desc); } +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(BeamDivergenceVtxGenerator); diff --git a/IOMC/EventVertexGenerators/src/module.cc b/IOMC/EventVertexGenerators/src/module.cc index 8b388f0be1138..3ec6e2d985d45 100644 --- a/IOMC/EventVertexGenerators/src/module.cc +++ b/IOMC/EventVertexGenerators/src/module.cc @@ -9,7 +9,6 @@ #include "IOMC/EventVertexGenerators/interface/BetafuncEvtVtxGenerator.h" #include "IOMC/EventVertexGenerators/interface/GaussianZBeamSpotFilter.h" #include "IOMC/EventVertexGenerators/interface/HLLHCEvtVtxGenerator.h" -#include "IOMC/EventVertexGenerators/interface/BeamDivergenceVtxGenerator.h" #include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -25,4 +24,3 @@ DEFINE_FWK_MODULE(BeamProfileVtxGenerator) ; DEFINE_FWK_MODULE(BetafuncEvtVtxGenerator) ; DEFINE_FWK_MODULE(GaussianZBeamSpotFilter); DEFINE_FWK_MODULE(HLLHCEvtVtxGenerator); -DEFINE_FWK_MODULE(BeamDivergenceVtxGenerator); From c09985b578c6b2aff660dc02d702d5a594d36681 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 15:50:03 +0100 Subject: [PATCH 139/686] Several small review comments addressed. --- .../src/LHCOpticalFunctionsCollection.cc | 2 +- .../src/LHCOpticalFunctionsSet.cc | 2 +- .../retrieve-ctpps-beam-parameters_cfg.py | 2 - .../python/Reconstruction_cff.py | 3 +- .../src/ProtonReconstructionAlgorithm.cc | 70 ++++++++----------- 5 files changed, 32 insertions(+), 47 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc index cbc7c5d2e2230..2b867bb3e0ab4 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc @@ -8,7 +8,7 @@ void LHCOpticalFunctionsCollection::interpolateFunctions(double xangle, mapType &output) const { - for (const auto p1 : m_functions1) + for (const auto &p1 : m_functions1) { const auto it2 = m_functions2.find(p1.first); if (it2 == m_functions2.end()) diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index 135a5b09be8f4..2ad20fdbada18 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -79,7 +79,7 @@ void LHCOpticalFunctionsSet::initializeSplines() void LHCOpticalFunctionsSet::transport(const LHCOpticalFunctionsSet::Kinematics &input, LHCOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const { - const double& xi = input.xi; + const double xi = input.xi; output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; diff --git a/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py index e2dd7033472ec..510ea1e3840bb 100644 --- a/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py +++ b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py @@ -7,8 +7,6 @@ # input database (in this case the local sqlite file) process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' -# WORK_DIR = "/afs/cern.ch/work/w/wcarvalh/ctpps/db/CMSSW_10_4_0_pre2/src" -# process.CondDB.connect = 'sqlite_file:/afs/cern.ch/work/w/wcarvalh/ctpps/db/CMSSW_10_2_0_pre3/src/CondTools/CTPPS/test_output.db' process.MessageLogger = cms.Service("MessageLogger", cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), diff --git a/Configuration/StandardSequences/python/Reconstruction_cff.py b/Configuration/StandardSequences/python/Reconstruction_cff.py index 8f14bbe6f36ad..d718772c4909f 100644 --- a/Configuration/StandardSequences/python/Reconstruction_cff.py +++ b/Configuration/StandardSequences/python/Reconstruction_cff.py @@ -90,7 +90,8 @@ ########################################### _fastSim_localreco = localreco.copyAndExclude([ castorreco, - totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction,ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtonReconstruction, + totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction, + ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtonReconstruction, trackerlocalreco ]) fastSim.toReplaceWith(localreco, _fastSim_localreco) diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index ebc57804f7927..fdb5fe81df2b9 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -51,13 +51,14 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map("", - (double *) ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data(), // const cast away necessary due to the ROOT interface - (double *) ofs.getXiValues().data(), ofs.getXiValues().size()); rpod.s_y_d_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eyd]; rpod.s_v_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::evy]; rpod.s_L_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eLy]; + vector xiValues = ofs.getXiValues(); // local copy made since the TSpline constructor needs non-const parameters + vector xDValues = ofs.getFcnValues()[LHCOpticalFunctionsSet::exd]; + rpod.s_xi_vs_x_d = make_shared("", xDValues.data(), xiValues.data(), xiValues.size()); + // calculate auxiliary data LHCOpticalFunctionsSet::Kinematics k_in = { 0., 0., 0., 0., 0. }; LHCOpticalFunctionsSet::Kinematics k_out; @@ -71,14 +72,14 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map g_x_d_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data()); ff->SetParameters(0., 0.); - g_x_d_vs_xi->Fit(ff.get(), "Q"); + g_x_d_vs_xi->Fit(ff.get(), "Q SERIAL"); rpod.ch0 = ff->GetParameter(0) - rpod.x0; rpod.ch1 = ff->GetParameter(1); unique_ptr g_L_x_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), ofs.getFcnValues()[LHCOpticalFunctionsSet::eLx].data()); ff->SetParameters(0., 0.); - g_L_x_vs_xi->Fit(ff.get(), "Q"); + g_L_x_vs_xi->Fit(ff.get(), "Q SERIAL"); rpod.la0 = ff->GetParameter(0); rpod.la1 = ff->GetParameter(1); @@ -108,7 +109,7 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou const LHCOpticalFunctionsSet::Kinematics k_in = { 0., parameters[1], parameters[3], parameters[2], parameters[0] }; // calculate chi^2 by looping over hits - double S2 = 0.; + double s2 = 0.; for (const auto &track : *tracks) { const CTPPSDetId rpId(track->getRPId()); @@ -119,27 +120,18 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou oit->second.optics->transport(k_in, k_out); // proton position wrt. beam - const double& x = k_out.x - oit->second.x0; - const double& y = k_out.y - oit->second.y0; - - // make sure that uncertainties are reasonable - double x_unc = track->getXUnc(); - if (x_unc < 1E-3) - x_unc = 40E-3; - - double y_unc = track->getYUnc(); - if (y_unc < 1E-3) - y_unc = 40E-3; + const double x = k_out.x - oit->second.x0; + const double y = k_out.y - oit->second.y0; // calculate chi^2 contributions, convert track data mm --> m - const double x_diff_norm = (x - track->getX()*1E-3) / (x_unc*1E-3); - const double y_diff_norm = (y - track->getY()*1E-3) / (y_unc*1E-3); + const double x_diff_norm = (x - track->getX()*1E-3) / (track->getXUnc()*1E-3); + const double y_diff_norm = (y - track->getY()*1E-3) / (track->getYUnc()*1E-3); // increase chi^2 - S2 += x_diff_norm*x_diff_norm + y_diff_norm*y_diff_norm; + s2 += x_diff_norm*x_diff_norm + y_diff_norm*y_diff_norm; } - return S2; + return s2; } //---------------------------------------------------------------------------------------------------- @@ -171,39 +163,31 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( const bool use_improved_estimate = true; if (use_improved_estimate) { - double x_N = 0., x_F = 0.; - const RPOpticsData *i_N = nullptr, *i_F = nullptr; - unsigned int idx = 0; - for (const auto &track : tracks) - { - auto oit = m_rp_optics_.find(track->getRPId()); - - if (idx == 0) { x_N = track->getX() * 1E-3; i_N = &oit->second; } - if (idx == 1) { x_F = track->getX() * 1E-3; i_F = &oit->second; } - if (idx == 2) break; + double x_N = tracks[0]->getX()*1E-3, // conversion: mm --> m + x_F = tracks[1]->getX()*1E-3; - idx++; - } + const RPOpticsData &i_N = m_rp_optics_.find(tracks[0]->getRPId())->second, + &i_F = m_rp_optics_.find(tracks[1]->getRPId())->second; - const double a = i_F->ch1*i_N->la1 - i_N->ch1*i_F->la1; - const double b = i_F->ch0*i_N->la1 - i_N->ch0*i_F->la1 + i_F->ch1*i_N->la0 - i_N->ch1*i_F->la0 + x_N*i_F->la1 - x_F*i_N->la1; - const double c = x_N*i_F->la0 - x_F*i_N->la0 + i_F->ch0*i_N->la0 - i_N->ch0*i_F->la0; + const double a = i_F.ch1*i_N.la1 - i_N.ch1*i_F.la1; + const double b = i_F.ch0*i_N.la1 - i_N.ch0*i_F.la1 + i_F.ch1*i_N.la0 - i_N.ch1*i_F.la0 + x_N*i_F.la1 - x_F*i_N.la1; + const double c = x_N*i_F.la0 - x_F*i_N.la0 + i_F.ch0*i_N.la0 - i_N.ch0*i_F.la0; const double D = b*b - 4.*a*c; xi_init = (-b + sqrt(D)) / 2. / a; - th_x_init = (x_N - i_N->ch0 - i_N->ch1 * xi_init) / (i_N->la0 + i_N->la1 * xi_init); + th_x_init = (x_N - i_N.ch0 - i_N.ch1 * xi_init) / (i_N.la0 + i_N.la1 * xi_init); } else { - double S_xi0 = 0., S_1 = 0.; + double s_xi0 = 0., s_1 = 0.; for (const auto &track : tracks) { auto oit = m_rp_optics_.find(track->getRPId()); double xi = oit->second.s_xi_vs_x_d->Eval(track->getX() * 1E-3 + oit->second.x0); // conversion: mm --> m - S_1 += 1.; - S_xi0 += xi; + s_1 += 1.; + s_xi0 += xi; } - xi_init = S_xi0 / S_1; + xi_init = s_xi0 / s_1; } // initial estimate of th_y and vtx_y @@ -340,10 +324,12 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( for (const auto &track : tracks) { CTPPSDetId rpId(track->getRPId()); - unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); if (verbosity_) + { + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); os << "\nreconstructFromSingleRP(" << decRPId << ")"; + } auto oit = m_rp_optics_.find(track->getRPId()); const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m From 7b4f7527a08d941370d027477ffbe0ced803d83a Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 15:58:01 +0100 Subject: [PATCH 140/686] useImprovedInitialEstimate made config parameter. --- .../interface/ProtonReconstructionAlgorithm.h | 3 ++- .../plugins/CTPPSProtonReconstruction.cc | 4 +++- .../src/ProtonReconstructionAlgorithm.cc | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index 9c93ad61af43a..48cee4c896896 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -25,7 +25,7 @@ class ProtonReconstructionAlgorithm { public: - ProtonReconstructionAlgorithm(bool fit_vtx_y, unsigned int verbosity); + ProtonReconstructionAlgorithm(bool fit_vtx_y, bool improved_estimate, unsigned int verbosity); ~ProtonReconstructionAlgorithm() = default; void init(const std::unordered_map &opticalFunctions); @@ -44,6 +44,7 @@ class ProtonReconstructionAlgorithm private: unsigned int verbosity_; bool fitVtxY_; + bool useImprovedInitialEstimate_; bool initialized_; /// optics data associated with 1 RP diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 9e09efd342638..7f386e7ed0c68 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -69,7 +69,7 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), - algorithm_ (iConfig.getParameter("fitVtxY"), verbosity_), + algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), currentCrossingAngle_(-1.) { if (doSingleRPReconstruction_) @@ -93,6 +93,8 @@ void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& desc ->setComment("flag whether to apply multi-RP reconstruction strategy"); desc.add("fitVtxY", true) ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); + desc.add("useImprovedInitialEstimate", true) + ->setComment("for multi-RP reconstruction, flag whether a quadratic estimate of the initial point should be used"); descriptions.add("ctppsProtonReconstruction", desc); } diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index fdb5fe81df2b9..a05f7e5e7e18f 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -19,9 +19,10 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- -ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, unsigned int verbosity) : +ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, bool improved_estimate, unsigned int verbosity) : verbosity_(verbosity), fitVtxY_(fit_vtx_y), + useImprovedInitialEstimate_(improved_estimate), initialized_(false), fitter_(new ROOT::Fit::Fitter), chiSquareCalculator_(new ChiSquareCalculator) { @@ -160,8 +161,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( // initial estimate of xi and th_x double xi_init = 0., th_x_init = 0.; - const bool use_improved_estimate = true; - if (use_improved_estimate) + if (useImprovedInitialEstimate_) { double x_N = tracks[0]->getX()*1E-3, // conversion: mm --> m x_F = tracks[1]->getX()*1E-3; From b0d874c7d8040f9099da78b7bb8dad50b7c7447e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:09:51 +0100 Subject: [PATCH 141/686] Output labels made config parameters. --- .../plugins/CTPPSProtonReconstruction.cc | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc index 7f386e7ed0c68..6aceafc01c77c 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc @@ -45,15 +45,15 @@ class CTPPSProtonReconstruction : public edm::stream::EDProducer<> bool doSingleRPReconstruction_; bool doMultiRPReconstruction_; + std::string singleRPReconstructionLabel_; + std::string multiRPReconstructionLabel_; + ProtonReconstructionAlgorithm algorithm_; edm::ESWatcher lhcInfoWatcher_; float currentCrossingAngle_; std::unordered_map opticalFunctions_; - - const std::string singleRPLabel_ = "singleRP"; - const std::string multiRPLabel_ = "multiRP"; }; //---------------------------------------------------------------------------------------------------- @@ -69,14 +69,20 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), + singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), + multiRPReconstructionLabel_(iConfig.getParameter("multiRPReconstructionLabel")), algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), currentCrossingAngle_(-1.) { - if (doSingleRPReconstruction_) - produces(singleRPLabel_); + if (doSingleRPReconstruction_) { + produces(singleRPReconstructionLabel_); + produces(singleRPReconstructionLabel_); + } - if (doMultiRPReconstruction_) - produces(multiRPLabel_); + if (doMultiRPReconstruction_) { + produces(multiRPReconstructionLabel_); + produces(multiRPReconstructionLabel_); + } } //---------------------------------------------------------------------------------------------------- @@ -87,10 +93,17 @@ void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& desc desc.addUntracked("verbosity", 0)->setComment("verbosity level"); desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) ->setComment("specification of the input lite-track collection"); + desc.add("doSingleRPReconstruction", true) ->setComment("flag whether to apply single-RP reconstruction strategy"); + desc.add("singleRPReconstructionLabel", "singleRP") + ->setComment("output label for single-RP reconstruction products"); + desc.add("doMultiRPReconstruction", true) ->setComment("flag whether to apply multi-RP reconstruction strategy"); + desc.add("multiRPReconstructionLabel", "multiRP") + ->setComment("output label for multi-RP reconstruction products"); + desc.add("fitVtxY", true) ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); desc.add("useImprovedInitialEstimate", true) @@ -148,8 +161,8 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector - reco::ProtonTrack::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; - map nTracksPerRP; + reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; CTPPSDetId rpId(tr.getRPId()); @@ -167,14 +180,14 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (rpId.arm() == 1) tracks_56.emplace_back(hTracks, idx); - nTracksPerRP[tr.getRPId()]++; + nTracksPerRP[rpId]++; } // for the moment: check whether there is no more than 1 track in each arm bool singleTrack_45 = true, singleTrack_56 = true; for (const auto& detid_num : nTracksPerRP) { if (detid_num.second > 1) { - CTPPSDetId rpId(detid_num.first); + const CTPPSDetId &rpId = detid_num.first; if (rpId.arm() == 0) singleTrack_45 = false; if (rpId.arm() == 1) @@ -186,10 +199,15 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (doSingleRPReconstruction_) { unique_ptr output(new reco::ProtonTrackCollection); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); + + auto ohExtra = event.put(move(outputExtra), singleRPReconstructionLabel_); - event.put(move(output), singleRPLabel_); + for (unsigned int i = 0; i < output->size(); ++i) + (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); + + event.put(move(output), singleRPReconstructionLabel_); } // multi-RP reconstruction @@ -197,11 +215,16 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet unique_ptr output(new reco::ProtonTrackCollection); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); + + auto ohExtra = event.put(move(outputExtra), multiRPReconstructionLabel_); + + for (unsigned int i = 0; i < output->size(); ++i) + (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); - event.put(move(output), multiRPLabel_); + event.put(move(output), multiRPReconstructionLabel_); } if (verbosity_) From 5f71f1b7d7a9939c53fe1838671b406b5fde126b Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:13:54 +0100 Subject: [PATCH 142/686] Unnecessary type specifications removed. --- .../TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py index 6379d3c2b155d..892ef77aae739 100644 --- a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py +++ b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py @@ -8,9 +8,9 @@ from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 ctpps_2016.toModify( ctppsLocalTrackLiteProducer, - includeStrips = cms.bool(True), - includeDiamonds = cms.bool(True), - includePixels = cms.bool(True) + includeStrips = True, + includeDiamonds = True, + includePixels = True ) from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy From ff58719b6b5f776fb0d12d921ace5693d3412c75 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:45:28 +0100 Subject: [PATCH 143/686] (Un)tracked mismatched fixed. --- Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index b791b01810673..0d4b35ec769cb 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -475,7 +475,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, void CTPPSDirectProtonSimulation::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) { edm::ParameterSetDescription desc; - desc.add("verbosity", 0); + desc.addUntracked("verbosity", 0); desc.add("hepMCTag", edm::InputTag("generator", "unsmeared")); desc.add("produceScoringPlaneHits", true); desc.add("produceRecHits", true); From 0a06cc2523a3beb513562b3e03d9e7459a903f1a Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:46:09 +0100 Subject: [PATCH 144/686] (Un)tracked mismatch fixed. --- .../CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py index 87bb24a1ff962..be79a60d09582 100644 --- a/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms ctppsBeamParametersESSource = cms.ESSource("CTPPSBeamParametersESSource", - setBeamPars = cms.untracked.bool(True), + setBeamPars = cms.bool(True), # beam momentum (GeV) beamMom45 = cms.double(6500.), From 1e1c6eb7b6aa788a295d159ba965cc0ca528826c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:46:28 +0100 Subject: [PATCH 145/686] CTPPSProtonReconstruction renamed to CTPPSProtonProducer, ctppsProtonReconstruction renamed to ctppsProtons. --- .../python/Reconstruction_cff.py | 2 +- .../python/RecoCTPPS_EventContent_cff.py | 3 ++- .../python/recoCTPPS_sequences_cff.py | 4 +-- ...construction.cc => CTPPSProtonProducer.cc} | 27 +++++++++---------- .../test_reconstruction_cfg.py | 10 +++---- .../misalignment/template_cfg.py | 12 ++++----- .../resolution/template_cfg.py | 12 ++++----- 7 files changed, 35 insertions(+), 35 deletions(-) rename RecoCTPPS/ProtonReconstruction/plugins/{CTPPSProtonReconstruction.cc => CTPPSProtonProducer.cc} (89%) diff --git a/Configuration/StandardSequences/python/Reconstruction_cff.py b/Configuration/StandardSequences/python/Reconstruction_cff.py index d718772c4909f..13f475ceb8b7f 100644 --- a/Configuration/StandardSequences/python/Reconstruction_cff.py +++ b/Configuration/StandardSequences/python/Reconstruction_cff.py @@ -91,7 +91,7 @@ _fastSim_localreco = localreco.copyAndExclude([ castorreco, totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction, - ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtonReconstruction, + ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtons, trackerlocalreco ]) fastSim.toReplaceWith(localreco, _fastSim_localreco) diff --git a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py index 37ff1b2dcb9a6..185c131dcf5b8 100644 --- a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py @@ -35,7 +35,8 @@ # CTPPS common 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', - 'keep recoProtonTracks_ctppsProtonReconstruction_*_*', + 'keep recoProtonTracks_ctppsProtons_*_*', + 'keep recoProtonTrackExtras_ctppsProtons_*_*' ) ) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index c66b73f6957d1..40f32793df165 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -7,7 +7,7 @@ from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer -from RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi import * +from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * # TODO: load these data from DB from CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * @@ -26,5 +26,5 @@ totemTimingLocalReconstruction * ctppsPixelLocalReconstruction * ctppsLocalTrackLiteProducer * - ctppsProtonReconstruction + ctppsProtons ) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc similarity index 89% rename from RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc rename to RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 6aceafc01c77c..d3c442cfc683b 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonReconstruction.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -27,11 +27,11 @@ //---------------------------------------------------------------------------------------------------- -class CTPPSProtonReconstruction : public edm::stream::EDProducer<> +class CTPPSProtonProducer : public edm::stream::EDProducer<> { public: - explicit CTPPSProtonReconstruction(const edm::ParameterSet&); - ~CTPPSProtonReconstruction() override = default; + explicit CTPPSProtonProducer(const edm::ParameterSet&); + ~CTPPSProtonProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); @@ -64,7 +64,7 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- -CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iConfig) : +CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), @@ -87,7 +87,7 @@ CTPPSProtonReconstruction::CTPPSProtonReconstruction(const edm::ParameterSet& iC //---------------------------------------------------------------------------------------------------- -void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& descriptions) +void CTPPSProtonProducer::fillDescriptions(ConfigurationDescriptions& descriptions) { ParameterSetDescription desc; desc.addUntracked("verbosity", 0)->setComment("verbosity level"); @@ -96,12 +96,12 @@ void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& desc desc.add("doSingleRPReconstruction", true) ->setComment("flag whether to apply single-RP reconstruction strategy"); - desc.add("singleRPReconstructionLabel", "singleRP") + desc.add("singleRPReconstructionLabel", "singleRP") ->setComment("output label for single-RP reconstruction products"); desc.add("doMultiRPReconstruction", true) ->setComment("flag whether to apply multi-RP reconstruction strategy"); - desc.add("multiRPReconstructionLabel", "multiRP") + desc.add("multiRPReconstructionLabel", "multiRP") ->setComment("output label for multi-RP reconstruction products"); desc.add("fitVtxY", true) @@ -109,12 +109,12 @@ void CTPPSProtonReconstruction::fillDescriptions(ConfigurationDescriptions& desc desc.add("useImprovedInitialEstimate", true) ->setComment("for multi-RP reconstruction, flag whether a quadratic estimate of the initial point should be used"); - descriptions.add("ctppsProtonReconstruction", desc); + descriptions.add("ctppsProtons", desc); } //---------------------------------------------------------------------------------------------------- -void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSetup) +void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) { // get conditions edm::ESHandle hLHCInfo; @@ -133,11 +133,11 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet if (currentCrossingAngle_ == 0.) { - LogWarning("CTPPSProtonReconstruction") << "Invalid crossing angle, reconstruction disabled."; + LogWarning("CTPPSProtonProducer") << "Invalid crossing angle, reconstruction disabled."; algorithm_.release(); } else { if (verbosity_) - edm::LogInfo("CTPPSProtonReconstruction") << "Setting crossing angle " << currentCrossingAngle_; + edm::LogInfo("CTPPSProtonProducer") << "Setting crossing angle " << currentCrossingAngle_; // interpolate optical functions opticalFunctions_.clear(); @@ -228,10 +228,9 @@ void CTPPSProtonReconstruction::produce(Event& event, const EventSetup &eventSet } if (verbosity_) - edm::LogInfo("CTPPSProtonReconstruction") << ssLog.str(); + edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); } //---------------------------------------------------------------------------------------------------- -DEFINE_FWK_MODULE(CTPPSProtonReconstruction); - +DEFINE_FWK_MODULE(CTPPSProtonProducer); diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index 41067afbbdbcb..89026e57d13ca 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -33,7 +33,7 @@ process.ctppsLocalTrackLiteProducer.includeDiamonds = False process.ctppsLocalTrackLiteProducer.includePixels = False -process.ctppsProtonReconstruction.verbosity = 0 +process.ctppsProtons.verbosity = 0 # load geometry process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") # 2017 is OK here @@ -41,7 +41,7 @@ # reconstruction validator process.ctppsProtonReconstructionValidator = cms.EDAnalyzer("CTPPSProtonReconstructionValidator", tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), - tagRecoProtons = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + tagRecoProtons = cms.InputTag("ctppsProtons", "multiRP"), chiSqCut = cms.double(2.), @@ -51,8 +51,8 @@ # reconstruction plotter process.ctppsProtonReconstructionPlotter = cms.EDAnalyzer("CTPPSProtonReconstructionPlotter", tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), - tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), - tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), rpId_45_F = cms.uint32(3), rpId_45_N = cms.uint32(2), @@ -69,7 +69,7 @@ #* process.totemTimingLocalReconstruction #* process.ctppsPixelLocalReconstruction * process.ctppsLocalTrackLiteProducer - * process.ctppsProtonReconstruction + * process.ctppsProtons * process.ctppsProtonReconstructionValidator * process.ctppsProtonReconstructionPlotter diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index a8abc286fb988..f61cf6d59c281 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -64,16 +64,16 @@ process.ctppsLocalTrackLiteProducer.includePixels = False # proton reconstruction -process.load("RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi") -process.ctppsProtonReconstruction.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -#process.ctppsProtonReconstruction.fitVtxY = False +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") +process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtons.fitVtxY = False # reconstruction validation process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), - tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), - tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), outputFile = cms.string("") ) @@ -88,7 +88,7 @@ * process.totemRPLocalTrackFitter * process.ctppsLocalTrackLiteProducer - * process.ctppsProtonReconstruction + * process.ctppsProtons * process.ctppsProtonReconstructionSimulationValidator ) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index 2de1f1cb2ca9d..bd53d563e4c34 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -62,16 +62,16 @@ process.ctppsLocalTrackLiteProducer.includePixels = False # proton reconstruction -process.load("RecoCTPPS.ProtonReconstruction.ctppsProtonReconstruction_cfi") -process.ctppsProtonReconstruction.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -#process.ctppsProtonReconstruction.fitVtxY = False +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") +process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtons.fitVtxY = False # reconstruction validation process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), - tagRecoProtonsSingleRP = cms.InputTag("ctppsProtonReconstruction", "singleRP"), - tagRecoProtonsMultiRP = cms.InputTag("ctppsProtonReconstruction", "multiRP"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), outputFile = cms.string("") ) @@ -86,7 +86,7 @@ * process.totemRPLocalTrackFitter * process.ctppsLocalTrackLiteProducer - * process.ctppsProtonReconstruction + * process.ctppsProtons * process.ctppsProtonReconstructionSimulationValidator ) From ed9b9f48926f9c32396b4cd2334a12b965cf3910 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 16:52:38 +0100 Subject: [PATCH 146/686] Run number set to match with 2016 range. --- .../proton_reconstruction_MC/misalignment/template_cfg.py | 4 +++- .../proton_reconstruction_MC/resolution/template_cfg.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index f61cf6d59c281..c5ccd91228daf 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index bd53d563e4c34..aead8625071a5 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) From 6deab78b9333a4ea9c3b437aa1d9ddd7753d20b2 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 10 Jan 2019 17:17:09 +0100 Subject: [PATCH 147/686] Fit avoids using TF1 and TGraph. --- .../interface/ProtonReconstructionAlgorithm.h | 2 + .../src/ProtonReconstructionAlgorithm.cc | 41 ++++++++++--------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index 48cee4c896896..f0f4044572c4f 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -80,6 +80,8 @@ class ProtonReconstructionAlgorithm /// object to calculate chi^2 std::unique_ptr chiSquareCalculator_; + + static void doLinearFit(const std::vector &vx, const std::vector &vy, double &b, double &a); }; #endif diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index a05f7e5e7e18f..25252cee63fc9 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -11,7 +11,6 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/ProtonReco/interface/ProtonTrack.h" -#include "TF1.h" #include "TMinuitMinimizer.h" using namespace std; @@ -41,9 +40,6 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map ff(new TF1("ff", "[0] + [1]*x", 0., 1., TF1::EAddToList::kNo)); - // build optics data for each object for (const auto &p : opticalFunctions) { @@ -67,22 +63,10 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map g_x_d_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), - ofs.getFcnValues()[LHCOpticalFunctionsSet::exd].data()); - ff->SetParameters(0., 0.); - g_x_d_vs_xi->Fit(ff.get(), "Q SERIAL"); - rpod.ch0 = ff->GetParameter(0) - rpod.x0; - rpod.ch1 = ff->GetParameter(1); + doLinearFit(ofs.getXiValues(), ofs.getFcnValues()[LHCOpticalFunctionsSet::exd], rpod.ch0, rpod.ch1); + rpod.ch0 -= rpod.x0; - unique_ptr g_L_x_vs_xi = make_unique(ofs.getXiValues().size(), ofs.getXiValues().data(), - ofs.getFcnValues()[LHCOpticalFunctionsSet::eLx].data()); - ff->SetParameters(0., 0.); - g_L_x_vs_xi->Fit(ff.get(), "Q SERIAL"); - rpod.la0 = ff->GetParameter(0); - rpod.la1 = ff->GetParameter(1); + doLinearFit(ofs.getXiValues(), ofs.getFcnValues()[LHCOpticalFunctionsSet::eLx], rpod.la0, rpod.la1); // insert record const CTPPSDetId rpId(p.first); @@ -95,6 +79,25 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map &vx, const std::vector &vy, double &b, double &a) +{ + double s_1=0., s_x=0., s_xx=0., s_y=0., s_xy=0.; + for (unsigned int i = 0; i < vx.size(); ++i) + { + s_1 += 1.; + s_x += vx[i]; + s_xx += vx[i] * vx[i]; + s_y += vy[i]; + s_xy += vx[i] * vy[i]; + } + + const double d = s_xx * s_1 - s_x * s_x; + a = ( s_1 * s_xy - s_x * s_y) / d; + b = (-s_x * s_xy + s_xx * s_y) / d; +} + +//---------------------------------------------------------------------------------------------------- + void ProtonReconstructionAlgorithm::release() { initialized_ = false; From 033972d4f01f5d174b166299fb2b1523e762b88f Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 11 Jan 2019 12:19:54 +0100 Subject: [PATCH 148/686] Run number corresponds to 2016 period. --- .../beam_smearing_validation/test_beam_smearing_cfg.py | 4 +++- .../direct_simulation_validation/test_acceptance_cfg.py | 4 +++- .../direct_simulation_validation/test_smearing_effects_cfg.py | 4 +++- .../direct_simulation_validation/test_xy_pattern_cfg.py | 4 +++- .../year_2016/proton_gun_validation/test_proton_gun_cfg.py | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py index ce12faf88ddad..dc550044ba4d1 100644 --- a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py +++ b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py index 4bccd59e26d28..47faa3cb1de61 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py index d3f32be1ce9b7..e69bc04ef736d 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py index f9bfb87500a3a..09a4450b63d5e 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000) diff --git a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py index c30a283d6d49d..eb93f6ac40c79 100644 --- a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py @@ -13,7 +13,9 @@ ) # number of events -process.source = cms.Source("EmptySource") +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000) From eda61ed8cb3b76fcab6b79d098b5f3329c18d6e5 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 11 Jan 2019 12:25:32 +0100 Subject: [PATCH 149/686] Use cm as length unit for optical functions. --- .../interface/LHCOpticalFunctionsSet.h | 11 +++++----- .../plugins/CTPPSOpticalFunctionsESSource.cc | 2 +- .../interface/ProtonReconstructionAlgorithm.h | 4 ++-- .../src/ProtonReconstructionAlgorithm.cc | 22 +++++++++---------- .../plugins/CTPPSDirectProtonSimulation.cc | 8 +++---- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index 9e30366a2afa2..e019d3b2741f9 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -25,6 +25,7 @@ class LHCOpticalFunctionsSet /// returns the position of the scoring plane (LHC/TOTEM convention) double getScoringPlaneZ() const { return m_z; } + const std::vector& getXiValues() const { return m_xi_values; } const std::array, 16>& getFcnValues() const { return m_fcn_values; } const std::array, 16>& getSplines() const { return m_splines; } @@ -35,9 +36,9 @@ class LHCOpticalFunctionsSet /// proton kinematics description struct Kinematics { - double x; // physics vertex position (beam offset subtracted), m + double x; // physics vertex position (beam offset subtracted), cm double th_x; // physics scattering angle (crossing angle subtracted), rad - double y; // physics vertex position, m + double y; // physics vertex position, cm double th_y; // physics scattering angle, rad double xi; // relative momentum loss (positive for diffractive protons) }; @@ -50,14 +51,14 @@ class LHCOpticalFunctionsSet double xangle2, const LHCOpticalFunctionsSet &of2, double xangle); private: - /// position of the scoring plane, in LHC/TOTEM convention, m + /// position of the scoring plane, in LHC/TOTEM convention, cm double m_z; + std::vector m_xi_values; - std::array, 16> m_fcn_values; + std::array, 16> m_fcn_values; ///< length unit cm std::array, 16> m_splines; COND_SERIALIZABLE; }; #endif - diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc index 770b40fdc66ee..f0bdeb8144539 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc @@ -53,7 +53,7 @@ CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::Paramete const unsigned int rpId = pset.getParameter("rpId"); const std::string dirName = pset.getParameter("dirName"); const double z = pset.getParameter("z"); - const RPInfo entry = {dirName, z}; + const RPInfo entry = {dirName, z * 1E2}; // conversion: m -> cm m_rpInfo.emplace(rpId, entry); } diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index f0f4044572c4f..b4ca619e84618 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -52,8 +52,8 @@ class ProtonReconstructionAlgorithm { const LHCOpticalFunctionsSet *optics; std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; - double x0; ///< beam horizontal position, m - double y0; ///< beam vertical position, m + double x0; ///< beam horizontal position, cm + double y0; ///< beam vertical position, cm double ch0; ///< intercept for linear approximation of \f$x(\xi)\f$ double ch1; ///< slope for linear approximation of \f$x(\xi)\f$ double la0; ///< intercept for linear approximation of \f$L_x(\xi)\f$ diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 25252cee63fc9..66e286fef85a2 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -127,9 +127,9 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou const double x = k_out.x - oit->second.x0; const double y = k_out.y - oit->second.y0; - // calculate chi^2 contributions, convert track data mm --> m - const double x_diff_norm = (x - track->getX()*1E-3) / (track->getXUnc()*1E-3); - const double y_diff_norm = (y - track->getY()*1E-3) / (track->getYUnc()*1E-3); + // calculate chi^2 contributions, convert track data mm --> cm + const double x_diff_norm = (x - track->getX()*1E-1) / (track->getXUnc()*1E-1); + const double y_diff_norm = (y - track->getY()*1E-1) / (track->getYUnc()*1E-1); // increase chi^2 s2 += x_diff_norm*x_diff_norm + y_diff_norm*y_diff_norm; @@ -166,8 +166,8 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( if (useImprovedInitialEstimate_) { - double x_N = tracks[0]->getX()*1E-3, // conversion: mm --> m - x_F = tracks[1]->getX()*1E-3; + double x_N = tracks[0]->getX()*1E-1, // conversion: mm --> cm + x_F = tracks[1]->getX()*1E-1; const RPOpticsData &i_N = m_rp_optics_.find(tracks[0]->getRPId())->second, &i_F = m_rp_optics_.find(tracks[1]->getRPId())->second; @@ -184,7 +184,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( for (const auto &track : tracks) { auto oit = m_rp_optics_.find(track->getRPId()); - double xi = oit->second.s_xi_vs_x_d->Eval(track->getX() * 1E-3 + oit->second.x0); // conversion: mm --> m + double xi = oit->second.s_xi_vs_x_d->Eval(track->getX()*1E-1 + oit->second.x0); // conversion: mm --> cm s_1 += 1.; s_xi0 += xi; @@ -203,7 +203,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( auto oit = m_rp_optics_.find(track->getRPId()); - y[y_idx] = track->getY()*1E-3 - oit->second.s_y_d_vs_xi->Eval(xi_init); // track y: mm --> m + y[y_idx] = track->getY()*1E-1 - oit->second.s_y_d_vs_xi->Eval(xi_init); // track y: mm --> cm v_y[y_idx] = oit->second.s_v_y_vs_xi->Eval(xi_init); L_y[y_idx] = oit->second.s_L_y_vs_xi->Eval(xi_init); @@ -262,7 +262,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( using PT = reco::ProtonTrack; const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention - const reco::ProtonTrack::Point vertex(0., params[3]*1E2, 0.); // vertex in cm + const reco::Track::Point vertex(0., params[3], 0.); const double xi = params[0]; const double th_x = params[1]; const double th_y = params[2]; @@ -335,14 +335,14 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( } auto oit = m_rp_optics_.find(track->getRPId()); - const double x_full = track->getX() * 1E-3 + oit->second.x0; // conversions mm --> m + const double x_full = track->getX()*1E-1 + oit->second.x0; // conversion mm --> cm const double xi = oit->second.s_xi_vs_x_d->Eval(x_full); const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); - const double th_y = track->getY() * 1E-3 / L_y; + const double th_y = track->getY()*1E-1 / L_y; // conversion mm --> cm const double ep_x = 1E-6; const double dxi_dx = (oit->second.s_xi_vs_x_d->Eval(x_full + ep_x) - xi) / ep_x; - const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-3; + const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-1; // conversion mm --> cm const double ep_xi = 1E-4; const double dL_y_dxi = ( oit->second.s_L_y_vs_xi->Eval(xi + ep_xi) - L_y ) / ep_xi; diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index 0d4b35ec769cb..8f9db559841d0 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -318,11 +318,11 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, ssLog << " RP " << rpDecId << std::endl; // transport proton - LHCOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x * 1E-3, th_x_phys, vtx_lhc_eff_y * 1E-3, th_y_phys, xi }; // conversions: mm -> m + LHCOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x*1E-1, th_x_phys, vtx_lhc_eff_y*1E-1, th_y_phys, xi }; // conversions: mm -> cm LHCOpticalFunctionsSet::Kinematics k_out; ofp.second.transport(k_in, k_out, true); - double b_x = k_out.x * 1E3, b_y = k_out.y * 1E3; // conversions: m -> mm + double b_x = k_out.x * 1E1, b_y = k_out.y * 1E1; // conversions: cm -> mm double a_x = k_out.th_x, a_y = k_out.th_y; // if needed, subtract beam position and angle @@ -334,10 +334,10 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, ofp.second.transport(k_be_in, k_be_out, true); a_x -= k_be_out.th_x; a_y -= k_be_out.th_y; - b_x -= k_be_out.x * 1E3; b_y -= k_be_out.y * 1E3; + b_x -= k_be_out.x * 1E1; b_y -= k_be_out.y * 1E1; // conversions: cm -> mm } - const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E3; // conversion: m --> mm + const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1; // conversion: cm --> mm if (verbosity_) { From 4a04553136d8c24ee6445732a0a0d617b5631412 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 11 Jan 2019 12:44:27 +0100 Subject: [PATCH 150/686] ctppsProtons in miniAOD. --- PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 204a0adcdc255..088e86299af8d 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -512,8 +512,10 @@ def miniAOD_customizeData(process): from PhysicsTools.PatAlgos.tools.coreTools import runOnData runOnData( process, outputModules = [] ) process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff") + process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") task = getPatAlgosToolsTask(process) task.add(process.ctppsLocalTrackLiteProducer) + task.add(process.ctppsProtons) def miniAOD_customizeAllData(process): miniAOD_customizeCommon(process) From 5dae6efbad1300acb12ce4cff0d2df218a0bc893 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 14 Jan 2019 16:28:44 +0100 Subject: [PATCH 151/686] Replaced setters calls by a modified ProtonTrack constructor --- DataFormats/ProtonReco/interface/ProtonTrack.h | 4 +++- DataFormats/ProtonReco/src/ProtonTrack.cc | 6 ++++-- .../src/ProtonReconstructionAlgorithm.cc | 7 ++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ProtonTrack.h index 966f18bb552ab..2603b8717ef35 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ProtonTrack.h @@ -38,7 +38,9 @@ namespace reco /// default constructor ProtonTrack(); /// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss - ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov = CovarianceMatrix() ); + ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ); /// fitted vertex position const Point& vertex() const { return vertex_; } diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ProtonTrack.cc index d9b1be301acb3..48bcd64e24171 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ProtonTrack.cc @@ -15,11 +15,13 @@ ProtonTrack::ProtonTrack() : valid_fit_( false ), method_( ReconstructionMethod::invalid ) {} -ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov ) : +ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : vertex_( vtx ), momentum_( momentum ), t_( 0. ), t_err_( 0. ), xi_( xi ), covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), - valid_fit_( false ), method_( ReconstructionMethod::invalid ) + valid_fit_( valid ), method_( method ), contributing_local_tracks_( local_tracks ) {} float diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 66e286fef85a2..0e75f8d12a2fd 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -296,10 +296,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( } } - reco::ProtonTrack pt(result.Chi2(), ndf, vertex, momentum, xi, cm); - pt.setValidFit(result.IsValid()); - pt.setMethod(PT::ReconstructionMethod::multiRP); - pt.setContributingLocalTracks(tracks); + reco::ProtonTrack pt(result.Chi2(), ndf, vertex, momentum, xi, cm, PT::ReconstructionMethod::multiRP, tracks, result.IsValid()); output.push_back(move(pt)); } @@ -365,7 +362,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( cm((int)PT::Index::xi, (int)PT::Index::xi) = xi_unc * xi_unc; cm((int)PT::Index::th_y, (int)PT::Index::th_y) = th_y_unc * th_y_unc; - reco::ProtonTrack pt(0., 0, vertex, momentum, xi, cm); + reco::ProtonTrack pt(0., 0, vertex, momentum, xi, cm, PT::ReconstructionMethod::singleRP, { track }, true); pt.setValidFit(true); pt.setMethod(PT::ReconstructionMethod::singleRP); pt.setContributingLocalTracks({ track }); From 762c0992bd5d573bbb8aac8d619a24b464b823a4 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 15 Jan 2019 14:10:13 +0100 Subject: [PATCH 152/686] Renaming of ProtonTrack to ForwardProton --- .../{ProtonTrack.h => ForwardProton.h} | 14 ++++---- .../ProtonReco/interface/ForwardProtonFwd.h | 33 +++++++++++++++++++ .../src/{ProtonTrack.cc => ForwardProton.cc} | 14 ++++---- DataFormats/ProtonReco/src/classes.h | 16 ++++----- DataFormats/ProtonReco/src/classes_def.xml | 12 +++---- 5 files changed, 61 insertions(+), 28 deletions(-) rename DataFormats/ProtonReco/interface/{ProtonTrack.h => ForwardProton.h} (94%) create mode 100644 DataFormats/ProtonReco/interface/ForwardProtonFwd.h rename DataFormats/ProtonReco/src/{ProtonTrack.cc => ForwardProton.cc} (67%) diff --git a/DataFormats/ProtonReco/interface/ProtonTrack.h b/DataFormats/ProtonReco/interface/ForwardProton.h similarity index 94% rename from DataFormats/ProtonReco/interface/ProtonTrack.h rename to DataFormats/ProtonReco/interface/ForwardProton.h index 2603b8717ef35..2af2847346922 100644 --- a/DataFormats/ProtonReco/interface/ProtonTrack.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -4,8 +4,8 @@ * Laurent Forthomme ****************************************************************************/ -#ifndef DataFormats_ProtonReco_ProtonTrack_h -#define DataFormats_ProtonReco_ProtonTrack_h +#ifndef DataFormats_ProtonReco_ForwardProton_h +#define DataFormats_ProtonReco_ForwardProton_h #include "DataFormats/Math/interface/Error.h" #include "DataFormats/Math/interface/Point3D.h" @@ -15,7 +15,7 @@ namespace reco { - class ProtonTrack + class ForwardProton { public: /// parameter dimension @@ -36,11 +36,11 @@ namespace reco public: /// default constructor - ProtonTrack(); + ForwardProton(); /// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss - ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, - const CovarianceMatrix& cov, ReconstructionMethod method, - const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ); + ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ); /// fitted vertex position const Point& vertex() const { return vertex_; } diff --git a/DataFormats/ProtonReco/interface/ForwardProtonFwd.h b/DataFormats/ProtonReco/interface/ForwardProtonFwd.h new file mode 100644 index 0000000000000..0b09890de88eb --- /dev/null +++ b/DataFormats/ProtonReco/interface/ForwardProtonFwd.h @@ -0,0 +1,33 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#ifndef DataFormats_ProtonReco_ForwardProtonFwd_h +#define DataFormats_ProtonReco_ForwardProtonFwd_h + +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/Common/interface/RefVector.h" + +#include + +namespace reco +{ + class ForwardProton; + /// Collection of ForwardProton objects + typedef std::vector ForwardProtonCollection; + /// Persistent reference to a ForwardProton + typedef edm::Ref ForwardProtonRef; + /// Reference to a ForwardProton collection + typedef edm::RefProd ForwardProtonRefProd; + /// Vector of references to ForwardProton in the same collection + typedef edm::RefVector ForwardProtonRefVector; +} + +#endif + diff --git a/DataFormats/ProtonReco/src/ProtonTrack.cc b/DataFormats/ProtonReco/src/ForwardProton.cc similarity index 67% rename from DataFormats/ProtonReco/src/ProtonTrack.cc rename to DataFormats/ProtonReco/src/ForwardProton.cc index 48bcd64e24171..335fa024825d5 100644 --- a/DataFormats/ProtonReco/src/ProtonTrack.cc +++ b/DataFormats/ProtonReco/src/ForwardProton.cc @@ -4,20 +4,20 @@ * Laurent Forthomme ****************************************************************************/ -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include using namespace reco; -ProtonTrack::ProtonTrack() : +ForwardProton::ForwardProton() : t_( 0. ), t_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ), valid_fit_( false ), method_( ReconstructionMethod::invalid ) {} -ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, - const CovarianceMatrix& cov, ReconstructionMethod method, - const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : +ForwardProton::ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : vertex_( vtx ), momentum_( momentum ), t_( 0. ), t_err_( 0. ), xi_( xi ), covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), @@ -25,7 +25,7 @@ ProtonTrack::ProtonTrack( double chi2, double ndof, const Point& vtx, const Vect {} float -ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) +ForwardProton::calculateT( double beam_mom, double proton_mom, double theta ) { const double t0 = 2.*( massSquared_+beam_mom*proton_mom-sqrt( ( massSquared_+beam_mom*beam_mom ) * ( massSquared_+proton_mom*proton_mom ) ) ); const double S = sin(theta/2.); @@ -33,7 +33,7 @@ ProtonTrack::calculateT( double beam_mom, double proton_mom, double theta ) } float -ProtonTrack::t() const +ForwardProton::t() const { const double beam_mom = p() / (1.-xi()); const double theta = std::hypot( thetaX(), thetaY() ); diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h index d8ed79f25456a..75aeab9e4e8b3 100644 --- a/DataFormats/ProtonReco/src/classes.h +++ b/DataFormats/ProtonReco/src/classes.h @@ -1,5 +1,5 @@ -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/View.h" @@ -12,11 +12,11 @@ namespace DataFormats_ProtonReco { struct dictionary { - reco::ProtonTrack pt; - std::vector vec_pt; - edm::Wrapper > wrp_vec_pt; - edm::RefProd > rp_vec_pt; - edm::Ref,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > ref_vec_pt; - edm::RefVector,reco::ProtonTrack,edm::refhelper::FindUsingAdvance,reco::ProtonTrack> > rv_vec_pt; + reco::ForwardProton fp; + std::vector vec_fp; + edm::Wrapper > wrp_vec_fp; + edm::RefProd > rp_vec_fp; + edm::Ref,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > ref_vec_fp; + edm::RefVector,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > rv_vec_fp; }; } diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index cc922d624c53d..ce9aaace3bdb9 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,10 +1,10 @@ - + - - - - - + + + + + From d795d55e01fc2a5bfb0d7acd256ea9acd84c3263 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 15 Jan 2019 14:49:53 +0100 Subject: [PATCH 153/686] Adapted RecoCTPPS to the naming change --- .../python/RecoCTPPS_EventContent_cff.py | 3 +- .../interface/ProtonReconstructionAlgorithm.h | 12 ++--- .../plugins/CTPPSProtonProducer.cc | 21 ++++---- .../src/ProtonReconstructionAlgorithm.cc | 50 +++++++++---------- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py index 185c131dcf5b8..df8837853ad52 100644 --- a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py @@ -35,8 +35,7 @@ # CTPPS common 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', - 'keep recoProtonTracks_ctppsProtons_*_*', - 'keep recoProtonTrackExtras_ctppsProtons_*_*' + 'keep recoForwardProtons_ctppsProtons_*_*', ) ) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index b4ca619e84618..ec4061f734a70 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -10,7 +10,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" @@ -32,13 +32,13 @@ class ProtonReconstructionAlgorithm void release(); /// run proton reconstruction using single-RP strategy - void reconstructFromSingleRP(const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &input, - std::vector &output, + void reconstructFromSingleRP(const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &input, + std::vector &output, const LHCInfo &lhcInfo, std::ostream& os) const; /// run proton reconstruction using multiple-RP strategy - void reconstructFromMultiRP(const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &input, - std::vector &output, + void reconstructFromMultiRP(const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &input, + std::vector &output, const LHCInfo &lhcInfo, std::ostream& os) const; private: @@ -71,7 +71,7 @@ class ProtonReconstructionAlgorithm double operator() (const double *parameters) const; - const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector* tracks; + const reco::ForwardProton::CTPPSLocalTrackLiteRefVector* tracks; const std::map* m_rp_optics; }; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index d3c442cfc683b..df4ec7cdb3122 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -15,7 +15,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "DataFormats/ProtonReco/interface/ProtonTrackFwd.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" @@ -74,15 +74,11 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), currentCrossingAngle_(-1.) { - if (doSingleRPReconstruction_) { - produces(singleRPReconstructionLabel_); - produces(singleRPReconstructionLabel_); - } + if (doSingleRPReconstruction_) + produces(singleRPReconstructionLabel_); - if (doMultiRPReconstruction_) { - produces(multiRPReconstructionLabel_); - produces(multiRPReconstructionLabel_); - } + if (doMultiRPReconstruction_) + produces(multiRPReconstructionLabel_); } //---------------------------------------------------------------------------------------------------- @@ -161,7 +157,7 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector - reco::ProtonTrackExtra::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + reco::ForwardProton::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; @@ -197,7 +193,7 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) // single-RP reconstruction if (doSingleRPReconstruction_) { - unique_ptr output(new reco::ProtonTrackCollection); + unique_ptr output(new reco::ForwardProtonCollection); algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); @@ -212,7 +208,7 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) // multi-RP reconstruction if (doMultiRPReconstruction_) { - unique_ptr output(new reco::ProtonTrackCollection); + unique_ptr output(new reco::ForwardProtonCollection); if (singleTrack_45) algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); @@ -234,3 +230,4 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSProtonProducer); + diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 0e75f8d12a2fd..d1c725e79634f 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -9,7 +9,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "TMinuitMinimizer.h" @@ -141,8 +141,8 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou //---------------------------------------------------------------------------------------------------- void ProtonReconstructionAlgorithm::reconstructFromMultiRP( - const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &tracks, - std::vector &output, + const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &tracks, + std::vector &output, const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) @@ -259,16 +259,16 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( << ", chiSq = " << result.Chi2(); // save reco candidate - using PT = reco::ProtonTrack; + using FP = reco::ForwardProton; const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention - const reco::Track::Point vertex(0., params[3], 0.); + const FP::Point vertex(0., params[3], 0.); const double xi = params[0]; const double th_x = params[1]; const double th_y = params[2]; const double cos_th = sqrt(1. - th_x*th_x - th_y*th_y); const double p = lhcInfo.energy() * (1. - xi); - const reco::ProtonTrack::Vector momentum( + const FP::Vector momentum( - p * th_x, // the signs reflect change LHC --> CMS convention + p * th_y, sign_z * p * cos_th @@ -276,19 +276,19 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( signed int ndf = 2.*tracks.size() - ((fitVtxY_) ? 4. : 3.); map index_map = { - {(unsigned int) reco::ProtonTrack::Index::xi, 0}, - {(unsigned int) reco::ProtonTrack::Index::th_x, 1}, - {(unsigned int) reco::ProtonTrack::Index::th_y, 2}, - {(unsigned int) reco::ProtonTrack::Index::vtx_y, ((fitVtxY_) ? 3 : -1)}, - {(unsigned int) reco::ProtonTrack::Index::vtx_x, -1}, + {(unsigned int) FP::Index::xi, 0}, + {(unsigned int) FP::Index::th_x, 1}, + {(unsigned int) FP::Index::th_y, 2}, + {(unsigned int) FP::Index::vtx_y, ((fitVtxY_) ? 3 : -1)}, + {(unsigned int) FP::Index::vtx_x, -1}, }; - reco::ProtonTrack::CovarianceMatrix cm; - for (unsigned int i = 0; i < (unsigned int) reco::ProtonTrack::Index::num_indices; ++i) + FP::CovarianceMatrix cm; + for (unsigned int i = 0; i < (unsigned int) FP::Index::num_indices; ++i) { signed int fit_i = index_map[i]; - for (unsigned int j = 0; j < (unsigned int) reco::ProtonTrack::Index::num_indices; ++j) + for (unsigned int j = 0; j < (unsigned int) FP::Index::num_indices; ++j) { signed int fit_j = index_map[j]; @@ -296,7 +296,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( } } - reco::ProtonTrack pt(result.Chi2(), ndf, vertex, momentum, xi, cm, PT::ReconstructionMethod::multiRP, tracks, result.IsValid()); + reco::ForwardProton pt(result.Chi2(), ndf, vertex, momentum, xi, cm, FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); output.push_back(move(pt)); } @@ -304,8 +304,8 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( //---------------------------------------------------------------------------------------------------- void ProtonReconstructionAlgorithm::reconstructFromSingleRP( - const reco::ProtonTrack::CTPPSLocalTrackLiteRefVector &tracks, - std::vector &output, + const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &tracks, + std::vector &output, const LHCInfo &lhcInfo, std::ostream& os) const { if (!initialized_) @@ -348,23 +348,23 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( if (verbosity_) os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; - using PT = reco::ProtonTrack; + using PT = reco::ForwardProton; // save proton candidate const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention - const reco::ProtonTrack::Point vertex(0., 0., 0.); + const FP::Point vertex(0., 0., 0.); const double cos_th = sqrt(1. - th_y*th_y); const double p = lhcInfo.energy() * (1. - xi); - const reco::ProtonTrack::Vector momentum(0., p * th_y, sign_z * p * cos_th); + const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); - reco::ProtonTrack::CovarianceMatrix cm; - cm((int)PT::Index::xi, (int)PT::Index::xi) = xi_unc * xi_unc; - cm((int)PT::Index::th_y, (int)PT::Index::th_y) = th_y_unc * th_y_unc; + FP::CovarianceMatrix cm; + cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; + cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; - reco::ProtonTrack pt(0., 0, vertex, momentum, xi, cm, PT::ReconstructionMethod::singleRP, { track }, true); + reco::ForwardProton pt(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, { track }, true); pt.setValidFit(true); - pt.setMethod(PT::ReconstructionMethod::singleRP); + pt.setMethod(FP::ReconstructionMethod::singleRP); pt.setContributingLocalTracks({ track }); output.push_back(move(pt)); From 8980b2b28c6e6233b8187bcf9c334eaf5b6ea0bf Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 15 Jan 2019 15:31:44 +0100 Subject: [PATCH 154/686] Small fixes --- DataFormats/ProtonReco/src/classes_def.xml | 2 +- .../src/ProtonReconstructionAlgorithm.cc | 2 +- .../CTPPSProtonReconstructionPlotter.cc | 26 +++++++++---------- ...ProtonReconstructionSimulationValidator.cc | 26 +++++++++---------- .../CTPPSProtonReconstructionValidator.cc | 8 +++--- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index ce9aaace3bdb9..c36921ee0503f 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,6 +1,6 @@ - + diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index d1c725e79634f..b219f164ebc39 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -348,7 +348,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( if (verbosity_) os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; - using PT = reco::ForwardProton; + using FP = reco::ForwardProton; // save proton candidate diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc index 8f16309adfa2e..ce377e343309b 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -15,7 +15,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "TFile.h" #include "TGraphErrors.h" @@ -37,8 +37,8 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> void endJob() override; edm::EDGetTokenT> tokenTracks_; - edm::EDGetTokenT> tokenRecoProtonsSingleRP_; - edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + edm::EDGetTokenT> tokenRecoProtonsSingleRP_; + edm::EDGetTokenT> tokenRecoProtonsMultiRP_; unsigned int rpId_45_N_, rpId_45_F_; unsigned int rpId_56_N_, rpId_56_F_; @@ -83,7 +83,7 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> p_th_y_vs_xi = new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25); } - void fill(const reco::ProtonTrack &p) + void fill(const reco::ForwardProton &p) { if (!h_xi) init(); @@ -157,7 +157,7 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> delete[] t_bin_edges; } - void fill(const reco::ProtonTrack &p) + void fill(const reco::ForwardProton &p) { if (!h_xi) init(); @@ -257,7 +257,7 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> h2_th_y_mu_vs_th_y_si = new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6); } - void fill(const reco::ProtonTrack &p_single, const reco::ProtonTrack &p_multi) + void fill(const reco::ForwardProton &p_single, const reco::ForwardProton &p_multi) { if (!h2_xi_mu_vs_xi_si) init(); @@ -310,7 +310,7 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> p_th_y_si_diffNF_vs_xi_mu = new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25); } - void fill(const reco::ProtonTrack &p_s_N, const reco::ProtonTrack &p_s_F, const reco::ProtonTrack &p_m) + void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m) { if (!h_xi_si_diffNF) init(); @@ -355,8 +355,8 @@ using namespace edm; CTPPSProtonReconstructionPlotter::CTPPSProtonReconstructionPlotter(const edm::ParameterSet &ps) : tokenTracks_(consumes< std::vector>(ps.getParameter("tagTracks"))), - tokenRecoProtonsSingleRP_(consumes>(ps.getParameter("tagRecoProtonsSingleRP"))), - tokenRecoProtonsMultiRP_(consumes>(ps.getParameter("tagRecoProtonsMultiRP"))), + tokenRecoProtonsSingleRP_(consumes>(ps.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_(consumes>(ps.getParameter("tagRecoProtonsMultiRP"))), rpId_45_N_(ps.getParameter("rpId_45_N")), rpId_45_F_(ps.getParameter("rpId_45_F")), @@ -383,10 +383,10 @@ void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const ed edm::Handle< std::vector > hTracks; event.getByToken(tokenTracks_, hTracks); - Handle> hRecoProtonsSingleRP; + Handle> hRecoProtonsSingleRP; event.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); - Handle> hRecoProtonsMultiRP; + Handle> hRecoProtonsMultiRP; event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); if (!hRecoProtonsSingleRP->empty()) @@ -461,8 +461,8 @@ void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const ed } // arm correlation plots - const reco::ProtonTrack *p_arm0_s_N = nullptr, *p_arm0_s_F = nullptr, *p_arm0_m = nullptr; - const reco::ProtonTrack *p_arm1_s_N = nullptr, *p_arm1_s_F = nullptr, *p_arm1_m = nullptr; + const reco::ForwardProton *p_arm0_s_N = nullptr, *p_arm0_s_F = nullptr, *p_arm0_m = nullptr; + const reco::ForwardProton *p_arm1_s_N = nullptr, *p_arm1_s_F = nullptr, *p_arm1_m = nullptr; for (const auto &proton : *hRecoProtonsSingleRP) { diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index 5bfb1bd4ba71b..e217ac93cf5f4 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -17,7 +17,7 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "TFile.h" #include "TH1D.h" @@ -42,14 +42,14 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer void endJob() override; - void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ProtonTrack &rec_pr, + void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ForwardProton &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo); edm::EDGetTokenT tokenHepMCBeforeSmearing_; edm::EDGetTokenT tokenHepMCAfterSmearing_; - edm::EDGetTokenT> tokenRecoProtonsSingleRP_; - edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + edm::EDGetTokenT> tokenRecoProtonsSingleRP_; + edm::EDGetTokenT> tokenRecoProtonsMultiRP_; std::string outputFile_; @@ -160,8 +160,8 @@ using namespace HepMC; CTPPSProtonReconstructionSimulationValidator::CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet& iConfig) : tokenHepMCBeforeSmearing_( consumes(iConfig.getParameter("tagHepMCBeforeSmearing")) ), tokenHepMCAfterSmearing_( consumes(iConfig.getParameter("tagHepMCAfterSmearing")) ), - tokenRecoProtonsSingleRP_(consumes>(iConfig.getParameter("tagRecoProtonsSingleRP"))), - tokenRecoProtonsMultiRP_(consumes>(iConfig.getParameter("tagRecoProtonsMultiRP"))), + tokenRecoProtonsSingleRP_(consumes>(iConfig.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_(consumes>(iConfig.getParameter("tagRecoProtonsMultiRP"))), outputFile_(iConfig.getParameter("outputFile")) { } @@ -183,10 +183,10 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing); HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *) hHepMCAfterSmearing->GetEvent(); - Handle> hRecoProtonsSingleRP; + Handle> hRecoProtonsSingleRP; iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); - Handle> hRecoProtonsMultiRP; + Handle> hRecoProtonsMultiRP; iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); // extract vertex position @@ -265,7 +265,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv bool mom_set = false; FourVector mom; - if (rec_pr.lhcSector() == reco::ProtonTrack::LHCSector::sector45) + if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector45) { idx = 0; mom_set = proton_45_set; @@ -281,7 +281,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv unsigned int meth_idx = 1234; - if (rec_pr.method() == reco::ProtonTrack::ReconstructionMethod::singleRP) + if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::singleRP) { meth_idx = 0; @@ -289,7 +289,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv idx = 100*rpId.arm() + 10*rpId.station() + rpId.rp(); } - if (rec_pr.method() == reco::ProtonTrack::ReconstructionMethod::multiRP) + if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::multiRP) { meth_idx = 1; } @@ -302,7 +302,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv //---------------------------------------------------------------------------------------------------- void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_idx, unsigned int idx, - const reco::ProtonTrack &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo) + const reco::ForwardProton &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo) { const double p_nom = lhcInfo.energy(); const double xi_simu = (p_nom - mom.rho()) / p_nom; @@ -310,7 +310,7 @@ void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_i const double th_y_simu = mom.y() / mom.rho(); const double vtx_y_simu = vtx.y(); const double th_simu = sqrt(th_x_simu*th_x_simu + th_y_simu*th_y_simu); - const double t_simu = - reco::ProtonTrack::calculateT(p_nom, mom.rho(), th_simu); + const double t_simu = - reco::ForwardProton::calculateT(p_nom, mom.rho(), th_simu); const double xi_reco = rec_pr.xi(); const double th_x_reco = rec_pr.thetaX(); diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 657e025c70ae5..8385655660a17 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -20,7 +20,7 @@ #include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" -#include "DataFormats/ProtonReco/interface/ProtonTrack.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "TFile.h" #include "TH1D.h" @@ -42,7 +42,7 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> void endJob() override; - edm::EDGetTokenT> tokenRecoProtons_; + edm::EDGetTokenT> tokenRecoProtons_; double chiSqCut_; @@ -90,7 +90,7 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator(const edm::ParameterSet& iConfig) : - tokenRecoProtons_( consumes>(iConfig.getParameter("tagRecoProtons")) ), + tokenRecoProtons_( consumes>(iConfig.getParameter("tagRecoProtons")) ), chiSqCut_( iConfig.getParameter("chiSqCut") ), outputFile_(iConfig.getParameter("outputFile")) { @@ -127,7 +127,7 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const return; // get input - Handle> hRecoProtons; + Handle> hRecoProtons; iEvent.getByToken(tokenRecoProtons_, hRecoProtons); // process tracks From 6312e7b5f9d280d517ea44e31d1565ef98535f67 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 15 Jan 2019 16:23:40 +0100 Subject: [PATCH 155/686] Using single precision floats instead of doubles for vertex/momentum/covariance tracks attributes --- DataFormats/ProtonReco/interface/ForwardProton.h | 8 +++++--- DataFormats/ProtonReco/src/classes_def.xml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h index 2af2847346922..5af7add41ee7d 100644 --- a/DataFormats/ProtonReco/interface/ForwardProton.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -10,7 +10,9 @@ #include "DataFormats/Math/interface/Error.h" #include "DataFormats/Math/interface/Point3D.h" #include "DataFormats/Math/interface/Vector3D.h" + #include "DataFormats/Common/interface/Ref.h" + #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" namespace reco @@ -23,11 +25,11 @@ namespace reco /// indices to the covariance matrix enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension }; /// dimension-parameter covariance matrix - typedef math::Error::type CovarianceMatrix; + typedef math::ErrorF::type CovarianceMatrix; /// spatial vector - typedef math::XYZVector Vector; + typedef math::XYZVectorF Vector; /// point in the space - typedef math::XYZPoint Point; + typedef math::XYZPointF Point; using CTPPSLocalTrackLiteRefVector = std::vector > >; diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index c36921ee0503f..5c966aedd86da 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,6 +1,6 @@ - + From 09bfe9453606c51084f1a1e60fceb815eea05c8c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 16 Jan 2019 12:30:06 +0100 Subject: [PATCH 156/686] Avoiding copies in proton collections filling --- .../src/ProtonReconstructionAlgorithm.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index b219f164ebc39..3f83c2ba69f68 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -296,9 +296,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( } } - reco::ForwardProton pt(result.Chi2(), ndf, vertex, momentum, xi, cm, FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); - - output.push_back(move(pt)); + output.emplace_back(result.Chi2(), ndf, vertex, momentum, xi, cm, FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); } //---------------------------------------------------------------------------------------------------- @@ -326,10 +324,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( CTPPSDetId rpId(track->getRPId()); if (verbosity_) - { - unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - os << "\nreconstructFromSingleRP(" << decRPId << ")"; - } + os << "\nreconstructFromSingleRP(" << rpId.arm()*100 + rpId.station()*10 + rpId.rp() << ")"; auto oit = m_rp_optics_.find(track->getRPId()); const double x_full = track->getX()*1E-1 + oit->second.x0; // conversion mm --> cm @@ -362,12 +357,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; - reco::ForwardProton pt(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, { track }, true); - pt.setValidFit(true); - pt.setMethod(FP::ReconstructionMethod::singleRP); - pt.setContributingLocalTracks({ track }); - - output.push_back(move(pt)); + output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, FP::CTPPSLocalTrackLiteRefVector{ track }, true); } } From 675ecfad5842ce7134bf92c053dc963a1f4ca133 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 16 Jan 2019 14:28:28 +0100 Subject: [PATCH 157/686] =?UTF-8?q?std::vector=20>=20=E2=86=92?= =?UTF-8?q?=20edm::RefVector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProtonReco/interface/ForwardProton.h | 4 +-- DataFormats/ProtonReco/src/classes_def.xml | 2 +- .../plugins/CTPPSProtonProducer.cc | 33 ++++++++++--------- .../src/ProtonReconstructionAlgorithm.cc | 4 ++- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h index 5af7add41ee7d..7eca0ae043fdb 100644 --- a/DataFormats/ProtonReco/interface/ForwardProton.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -11,7 +11,7 @@ #include "DataFormats/Math/interface/Point3D.h" #include "DataFormats/Math/interface/Vector3D.h" -#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" @@ -31,7 +31,7 @@ namespace reco /// point in the space typedef math::XYZPointF Point; - using CTPPSLocalTrackLiteRefVector = std::vector > >; + using CTPPSLocalTrackLiteRefVector = edm::RefVector >; /// type of reconstruction applied for this track enum class ReconstructionMethod { invalid = -1, singleRP, multiRP }; diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index 5c966aedd86da..f33397e5523bd 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,6 +1,6 @@ - + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index df4ec7cdb3122..44cb5aadeb5af 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -65,13 +65,13 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : - tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), - verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), - doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), - doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), + tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), + verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), + doSingleRPReconstruction_ (iConfig.getParameter("doSingleRPReconstruction")), + doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), - multiRPReconstructionLabel_(iConfig.getParameter("multiRPReconstructionLabel")), - algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), + multiRPReconstructionLabel_ (iConfig.getParameter("multiRPReconstructionLabel")), + algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), currentCrossingAngle_(-1.) { if (doSingleRPReconstruction_) @@ -153,28 +153,29 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) ssLog << "input tracks:"; // get input - Handle > hTracks; + Handle > hTracks; event.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector reco::ForwardProton::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { - const CTPPSLocalTrackLite &tr = (*hTracks)[idx]; - CTPPSDetId rpId(tr.getRPId()); + const auto& tr = hTracks->at(idx); + const CTPPSDetId rpId(tr.getRPId()); if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) continue; if (verbosity_) - ssLog << "\n" - << " " << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " - << "x = " << tr.getX() << " +- " << tr.getXUnc() << " mm" - << ", y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; + ssLog << "\n\t" + << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " + << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " + << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; + Ref > r_track(hTracks, idx); if (rpId.arm() == 0) - tracks_45.emplace_back(hTracks, idx); + tracks_45.push_back(r_track); if (rpId.arm() == 1) - tracks_56.emplace_back(hTracks, idx); + tracks_56.push_back(r_track); nTracksPerRP[rpId]++; } @@ -183,7 +184,7 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) bool singleTrack_45 = true, singleTrack_56 = true; for (const auto& detid_num : nTracksPerRP) { if (detid_num.second > 1) { - const CTPPSDetId &rpId = detid_num.first; + const CTPPSDetId& rpId = detid_num.first; if (rpId.arm() == 0) singleTrack_45 = false; if (rpId.arm() == 1) diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 3f83c2ba69f68..6c5bdc5255355 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -357,7 +357,9 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; - output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, FP::CTPPSLocalTrackLiteRefVector{ track }, true); + FP::CTPPSLocalTrackLiteRefVector trk; + trk.push_back( track ); + output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, trk, true); } } From b10c16fdebb607a15df094a1b4e3c357863ab6b5 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 16 Jan 2019 14:37:13 +0100 Subject: [PATCH 158/686] CMS coding rules --- .../interface/CTPPSLocalTrackLiteFwd.h | 30 +++++++++ .../plugins/CTPPSProtonProducer.cc | 66 +++++++------------ 2 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h diff --git a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h new file mode 100644 index 0000000000000..c0e3008c4e28c --- /dev/null +++ b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan KaÅ¡par + * Laurent Forthomme + * + ****************************************************************************/ + +#ifndef DataFormats_CTPPSReco_CTPPSLocalTrackLiteFwd_h +#define DataFormats_CTPPSReco_CTPPSLocalTrackLiteFwd_h + +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/Common/interface/RefVector.h" + +#include + +class CTPPSLocalTrackLite; +/// Collection of CTPPSLocalTrackLite objects +typedef std::vector CTPPSLocalTrackLiteCollection; +/// Persistent reference to a CTPPSLocalTrackLite +typedef edm::Ref CTPPSLocalTrackLiteRef; +/// Reference to a CTPPSLocalTrackLite collection +typedef edm::RefProd CTPPSLocalTrackLiteRefProd; +/// Vector of references to CTPPSLocalTrackLite in the same collection +typedef edm::RefVector CTPPSLocalTrackLiteRefVector; + +#endif + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 44cb5aadeb5af..35ea754597692 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -56,16 +56,10 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> std::unordered_map opticalFunctions_; }; -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - //---------------------------------------------------------------------------------------------------- CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : - tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), + tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_ (iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), @@ -83,9 +77,9 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : //---------------------------------------------------------------------------------------------------- -void CTPPSProtonProducer::fillDescriptions(ConfigurationDescriptions& descriptions) +void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - ParameterSetDescription desc; + edm::ParameterSetDescription desc; desc.addUntracked("verbosity", 0)->setComment("verbosity level"); desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) ->setComment("specification of the input lite-track collection"); @@ -110,28 +104,26 @@ void CTPPSProtonProducer::fillDescriptions(ConfigurationDescriptions& descriptio //---------------------------------------------------------------------------------------------------- -void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) +void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // get conditions edm::ESHandle hLHCInfo; - eventSetup.get().get(hLHCInfo); + iSetup.get().get(hLHCInfo); edm::ESHandle hOpticalFunctionCollection; - eventSetup.get().get(hOpticalFunctionCollection); + iSetup.get().get(hOpticalFunctionCollection); // re-initialise algorithm upon crossing-angle change - if (lhcInfoWatcher_.check(eventSetup)) - { + if (lhcInfoWatcher_.check(iSetup)) { const LHCInfo* pLHCInfo = hLHCInfo.product(); - if (pLHCInfo->crossingAngle() != currentCrossingAngle_) - { + if (pLHCInfo->crossingAngle() != currentCrossingAngle_) { currentCrossingAngle_ = pLHCInfo->crossingAngle(); - if (currentCrossingAngle_ == 0.) - { - LogWarning("CTPPSProtonProducer") << "Invalid crossing angle, reconstruction disabled."; + if (currentCrossingAngle_ == 0.) { + edm::LogWarning("CTPPSProtonProducer") << "Invalid crossing angle, reconstruction disabled."; algorithm_.release(); - } else { + } + else { if (verbosity_) edm::LogInfo("CTPPSProtonProducer") << "Setting crossing angle " << currentCrossingAngle_; @@ -153,12 +145,12 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) ssLog << "input tracks:"; // get input - Handle > hTracks; - event.getByToken(tracksToken_, hTracks); + edm::Handle > hTracks; + iEvent.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector reco::ForwardProton::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; - map nTracksPerRP; + std::map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const auto& tr = hTracks->at(idx); const CTPPSDetId rpId(tr.getRPId()); @@ -171,7 +163,7 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; - Ref > r_track(hTracks, idx); + edm::Ref > r_track(hTracks, idx); if (rpId.arm() == 0) tracks_45.push_back(r_track); if (rpId.arm() == 1) @@ -194,34 +186,24 @@ void CTPPSProtonProducer::produce(Event& event, const EventSetup &eventSetup) // single-RP reconstruction if (doSingleRPReconstruction_) { - unique_ptr output(new reco::ForwardProtonCollection); + std::unique_ptr pOut(new reco::ForwardProtonCollection); - algorithm_.reconstructFromSingleRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_45, *pOut, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *pOut, *hLHCInfo, ssLog); - auto ohExtra = event.put(move(outputExtra), singleRPReconstructionLabel_); - - for (unsigned int i = 0; i < output->size(); ++i) - (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); - - event.put(move(output), singleRPReconstructionLabel_); + iEvent.put(std::move(pOut), singleRPReconstructionLabel_); } // multi-RP reconstruction if (doMultiRPReconstruction_) { - unique_ptr output(new reco::ForwardProtonCollection); + std::unique_ptr pOut(new reco::ForwardProtonCollection); if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *output, *outputExtra, *hLHCInfo, ssLog); + algorithm_.reconstructFromMultiRP(tracks_45, *pOut, *hLHCInfo, ssLog); if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *output, *outputExtra, *hLHCInfo, ssLog); - - auto ohExtra = event.put(move(outputExtra), multiRPReconstructionLabel_); - - for (unsigned int i = 0; i < output->size(); ++i) - (*output)[i].setProtonTrackExtra(reco::ProtonTrackExtraRef(ohExtra, i)); + algorithm_.reconstructFromMultiRP(tracks_56, *pOut, *hLHCInfo, ssLog); - event.put(move(output), multiRPReconstructionLabel_); + iEvent.put(std::move(pOut), multiRPReconstructionLabel_); } if (verbosity_) From 91496dacc2ffc0c22bb1de6baf5ecf8d6b575811 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 16 Jan 2019 15:28:24 +0100 Subject: [PATCH 159/686] Using the new Fwd definition of CTPPSLocalTrackLite --- DataFormats/CTPPSReco/src/classes_def.xml | 2 + .../ProtonReco/interface/ForwardProton.h | 5 +- .../interface/ProtonReconstructionAlgorithm.h | 18 +++---- .../plugins/CTPPSProtonProducer.cc | 12 +++-- .../src/ProtonReconstructionAlgorithm.cc | 50 ++++++++----------- ...ProtonReconstructionSimulationValidator.cc | 1 + .../CTPPSProtonReconstructionValidator.cc | 7 +-- 7 files changed, 45 insertions(+), 50 deletions(-) diff --git a/DataFormats/CTPPSReco/src/classes_def.xml b/DataFormats/CTPPSReco/src/classes_def.xml index 5d9ca355a143b..983a6d26e5756 100644 --- a/DataFormats/CTPPSReco/src/classes_def.xml +++ b/DataFormats/CTPPSReco/src/classes_def.xml @@ -170,4 +170,6 @@ + + diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h index 7eca0ae043fdb..2f2306403f2d7 100644 --- a/DataFormats/ProtonReco/interface/ForwardProton.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -13,7 +13,7 @@ #include "DataFormats/Common/interface/RefVector.h" -#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" namespace reco { @@ -30,9 +30,6 @@ namespace reco typedef math::XYZVectorF Vector; /// point in the space typedef math::XYZPointF Point; - - using CTPPSLocalTrackLiteRefVector = edm::RefVector >; - /// type of reconstruction applied for this track enum class ReconstructionMethod { invalid = -1, singleRP, multiRP }; diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index ec4061f734a70..bdc35b8caebac 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -9,8 +9,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" @@ -32,14 +32,14 @@ class ProtonReconstructionAlgorithm void release(); /// run proton reconstruction using single-RP strategy - void reconstructFromSingleRP(const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &input, - std::vector &output, - const LHCInfo &lhcInfo, std::ostream& os) const; + void reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& input, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const; /// run proton reconstruction using multiple-RP strategy - void reconstructFromMultiRP(const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &input, - std::vector &output, - const LHCInfo &lhcInfo, std::ostream& os) const; + void reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& input, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const; private: unsigned int verbosity_; @@ -71,7 +71,7 @@ class ProtonReconstructionAlgorithm double operator() (const double *parameters) const; - const reco::ForwardProton::CTPPSLocalTrackLiteRefVector* tracks; + const CTPPSLocalTrackLiteRefVector* tracks; const std::map* m_rp_optics; }; diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 35ea754597692..535708ed3a9aa 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -14,7 +14,9 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" @@ -38,7 +40,7 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> private: void produce(edm::Event&, const edm::EventSetup&) override; - edm::EDGetTokenT > tracksToken_; + edm::EDGetTokenT tracksToken_; unsigned int verbosity_; @@ -59,7 +61,7 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> //---------------------------------------------------------------------------------------------------- CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : - tracksToken_(consumes >(iConfig.getParameter("tagLocalTrackLite"))), + tracksToken_(consumes(iConfig.getParameter("tagLocalTrackLite"))), verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_ (iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), @@ -145,11 +147,11 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe ssLog << "input tracks:"; // get input - edm::Handle > hTracks; + edm::Handle hTracks; iEvent.getByToken(tracksToken_, hTracks); // keep only tracks from tracker RPs, split them by LHC sector - reco::ForwardProton::CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; std::map nTracksPerRP; for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { const auto& tr = hTracks->at(idx); @@ -163,7 +165,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; - edm::Ref > r_track(hTracks, idx); + CTPPSLocalTrackLiteRef r_track(hTracks, idx); if (rpId.arm() == 0) tracks_45.push_back(r_track); if (rpId.arm() == 1) diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 6c5bdc5255355..9111e3107008f 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -9,6 +9,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "TMinuitMinimizer.h" @@ -140,10 +141,9 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromMultiRP( - const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &tracks, - std::vector &output, - const LHCInfo &lhcInfo, std::ostream& os) const +void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& tracks, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const { if (!initialized_) return; @@ -153,8 +153,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( return; // make sure optics is available for all tracks - for (const auto &it : tracks) - { + for (const auto &it : tracks) { auto oit = m_rp_optics_.find(it->getRPId()); if (oit == m_rp_optics_.end()) throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << @@ -164,8 +163,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( // initial estimate of xi and th_x double xi_init = 0., th_x_init = 0.; - if (useImprovedInitialEstimate_) - { + if (useImprovedInitialEstimate_) { double x_N = tracks[0]->getX()*1E-1, // conversion: mm --> cm x_F = tracks[1]->getX()*1E-1; @@ -179,10 +177,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( xi_init = (-b + sqrt(D)) / 2. / a; th_x_init = (x_N - i_N.ch0 - i_N.ch1 * xi_init) / (i_N.la0 + i_N.la1 * xi_init); - } else { + } + else { double s_xi0 = 0., s_1 = 0.; - for (const auto &track : tracks) - { + for (const auto &track : tracks) { auto oit = m_rp_optics_.find(track->getRPId()); double xi = oit->second.s_xi_vs_x_d->Eval(track->getX()*1E-1 + oit->second.x0); // conversion: mm --> cm @@ -196,8 +194,7 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( // initial estimate of th_y and vtx_y double y[2], v_y[2], L_y[2]; unsigned int y_idx = 0; - for (const auto &track : tracks) - { + for (const auto &track : tracks) { if (y_idx >= 2) continue; @@ -213,12 +210,12 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( double vtx_y_init = 0.; double th_y_init = 0.; - if (fitVtxY_) - { + if (fitVtxY_) { const double det_y = v_y[0] * L_y[1] - L_y[0] * v_y[1]; vtx_y_init = (L_y[1] * y[0] - L_y[0] * y[1]) / det_y; th_y_init = (v_y[0] * y[1] - v_y[1] * y[0]) / det_y; - } else { + } + else { vtx_y_init = 0.; th_y_init = (y[1]/L_y[1] + y[0]/L_y[0]) / 2.; } @@ -284,12 +281,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( }; FP::CovarianceMatrix cm; - for (unsigned int i = 0; i < (unsigned int) FP::Index::num_indices; ++i) - { + for (unsigned int i = 0; i < (unsigned int) FP::Index::num_indices; ++i) { signed int fit_i = index_map[i]; - for (unsigned int j = 0; j < (unsigned int) FP::Index::num_indices; ++j) - { + for (unsigned int j = 0; j < (unsigned int) FP::Index::num_indices; ++j) { signed int fit_j = index_map[j]; cm(i, j) = (fit_i >= 0 && fit_j >= 0) ? result.CovMatrix(fit_i, fit_j) : 0.; @@ -301,17 +296,15 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP( //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromSingleRP( - const reco::ForwardProton::CTPPSLocalTrackLiteRefVector &tracks, - std::vector &output, - const LHCInfo &lhcInfo, std::ostream& os) const +void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& tracks, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const { if (!initialized_) return; // make sure optics is available for all tracks - for (const auto &it : tracks) - { + for (const auto &it : tracks) { auto oit = m_rp_optics_.find(it->getRPId()); if (oit == m_rp_optics_.end()) throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << it->getRPId() @@ -319,8 +312,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( } // rough estimate of xi and th_y from each track - for (const auto &track : tracks) - { + for (const auto &track : tracks) { CTPPSDetId rpId(track->getRPId()); if (verbosity_) @@ -357,7 +349,7 @@ void ProtonReconstructionAlgorithm::reconstructFromSingleRP( cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; - FP::CTPPSLocalTrackLiteRefVector trk; + CTPPSLocalTrackLiteRefVector trk; trk.push_back( track ); output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, trk, true); } diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index e217ac93cf5f4..9ad43c0acbd20 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -18,6 +18,7 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "TFile.h" #include "TH1D.h" diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 8385655660a17..556bcb8310f16 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -21,6 +21,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "TFile.h" #include "TH1D.h" @@ -120,7 +121,7 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const for (auto &p : opticalFunctions_) p.second.initializeSplines(); } - } + } // stop if conditions invalid if (currentCrossingAngle_ <= 0.) @@ -147,11 +148,11 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const auto it = opticalFunctions_.find(rpId); LHCOpticalFunctionsSet::Kinematics k_in_beam = { 0., 0., 0., 0., 0. }; - LHCOpticalFunctionsSet::Kinematics k_out_beam; + LHCOpticalFunctionsSet::Kinematics k_out_beam; it->second.transport(k_in_beam, k_out_beam); LHCOpticalFunctionsSet::Kinematics k_in = { pr.vx() * 1E-2, -pr.thetaX(), pr.vy() * 1E-2, pr.thetaY(), pr.xi() }; // conversions: cm --> m, CMS --> LHC convention - LHCOpticalFunctionsSet::Kinematics k_out; + LHCOpticalFunctionsSet::Kinematics k_out; it->second.transport(k_in, k_out); const double de_x = (k_out.x - k_out_beam.x) * 1E3 - tr->getX(); // conversions: m --> mm From c07d952394b8ba74d7362ce259f2bdc506beb37d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 16 Jan 2019 16:12:16 +0100 Subject: [PATCH 160/686] Added required streamers for edm::RefVector --- DataFormats/CTPPSReco/src/classes.h | 2 ++ DataFormats/CTPPSReco/src/classes_def.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/DataFormats/CTPPSReco/src/classes.h b/DataFormats/CTPPSReco/src/classes.h index b2860d0ac8478..733e00574a143 100644 --- a/DataFormats/CTPPSReco/src/classes.h +++ b/DataFormats/CTPPSReco/src/classes.h @@ -1,5 +1,7 @@ #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/PtrVector.h" +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/DetSet.h" #include "DataFormats/Common/interface/DetSetVector.h" diff --git a/DataFormats/CTPPSReco/src/classes_def.xml b/DataFormats/CTPPSReco/src/classes_def.xml index 983a6d26e5756..6029635ec5234 100644 --- a/DataFormats/CTPPSReco/src/classes_def.xml +++ b/DataFormats/CTPPSReco/src/classes_def.xml @@ -172,4 +172,6 @@ + + From 719987dcd723d4e6c55c9b65f493d5a6112663f5 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Feb 2019 11:24:36 +0100 Subject: [PATCH 161/686] Implemented several suggestions for ProtonReco class. --- .../ProtonReco/interface/ForwardProton.h | 20 +++++++++---------- DataFormats/ProtonReco/src/ForwardProton.cc | 4 ++-- DataFormats/ProtonReco/src/classes_def.xml | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h index 2f2306403f2d7..f438c519ea245 100644 --- a/DataFormats/ProtonReco/interface/ForwardProton.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -23,7 +23,7 @@ namespace reco /// parameter dimension enum { dimension = 5 }; /// indices to the covariance matrix - enum struct Index : unsigned short { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension }; + enum struct Index { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension }; /// dimension-parameter covariance matrix typedef math::ErrorF::type CovarianceMatrix; /// spatial vector @@ -80,6 +80,11 @@ namespace reco // vertex position can be obtained via TrackBase::vx() and vy() functions + /// return the uncertainty on a given component + double error( Index i ) const { + return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) ); + } + /// uncertainty on longitudinal fractional momentum loss float xiError() const { return error( Index::xi ); } /// uncertainty on fitted momentum horizontal angle opening @@ -101,9 +106,9 @@ namespace reco float t() const; /// time of proton arrival at forward stations - float time() const { return t_; } + float time() const { return time_; } /// uncertainty on time of proton arrival at forward stations - float timeError() const { return t_err_; } + float timeError() const { return time_err_; } /// set the flag for the fit validity void setValidFit( bool valid = true ) { valid_fit_ = valid; } @@ -133,19 +138,14 @@ namespace reco static constexpr float mass_ = 0.938272046; ///< proton mass, GeV static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 - /// return the uncertainty on a given component - double error( Index i ) const { - return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) ); - } - /// reconstructed vertex position at z/s = 0 Point vertex_; /// reconstructed momentum vector Vector momentum_; /// reconstructed time at forward detectors - float t_; + float time_; /// uncertainty on reconstructed time at forward detectors - float t_err_; + float time_err_; /// fractional momentum loss (positive for diffractive protons) float xi_; /// 5x5 covariance matrix diff --git a/DataFormats/ProtonReco/src/ForwardProton.cc b/DataFormats/ProtonReco/src/ForwardProton.cc index 335fa024825d5..1a650733cbd8a 100644 --- a/DataFormats/ProtonReco/src/ForwardProton.cc +++ b/DataFormats/ProtonReco/src/ForwardProton.cc @@ -11,7 +11,7 @@ using namespace reco; ForwardProton::ForwardProton() : - t_( 0. ), t_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ), + time_( 0. ), time_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ), valid_fit_( false ), method_( ReconstructionMethod::invalid ) {} @@ -19,7 +19,7 @@ ForwardProton::ForwardProton( double chi2, double ndof, const Point& vtx, const const CovarianceMatrix& cov, ReconstructionMethod method, const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : vertex_( vtx ), momentum_( momentum ), - t_( 0. ), t_err_( 0. ), xi_( xi ), + time_( 0. ), time_err_( 0. ), xi_( xi ), covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), valid_fit_( valid ), method_( method ), contributing_local_tracks_( local_tracks ) {} diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml index f33397e5523bd..0e88cf81de42e 100644 --- a/DataFormats/ProtonReco/src/classes_def.xml +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -1,6 +1,6 @@ - + From bf33694a6184aa13828056454a7cb1c387d320ba Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Feb 2019 11:27:47 +0100 Subject: [PATCH 162/686] Scoring-plane positions given in cm. --- .../plugins/CTPPSOpticalFunctionsESSource.cc | 2 +- .../year_2016/ctppsOpticalFunctionsESSource_cfi.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc index f0bdeb8144539..770b40fdc66ee 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc @@ -53,7 +53,7 @@ CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::Paramete const unsigned int rpId = pset.getParameter("rpId"); const std::string dirName = pset.getParameter("dirName"); const double z = pset.getParameter("z"); - const RPInfo entry = {dirName, z * 1E2}; // conversion: m -> cm + const RPInfo entry = {dirName, z}; m_rpInfo.emplace(rpId, entry); } diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index 624f5b6be80a9..efa1a91e52c52 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -7,9 +7,10 @@ xangle2 = cms.double(185), fileName2 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), scoringPlanes = cms.VPSet( - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-203.826) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-212.551) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+203.826) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+212.551) ), # RP 103 + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 ) ) From faad06a284c396b5f490ec294fc4a5d0d331350d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 6 Feb 2019 12:59:51 +0100 Subject: [PATCH 163/686] Moved the .root optical functions container to cms-data repository --- .../python/year_2016/ctppsOpticalFunctionsESSource_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index efa1a91e52c52..8229d3d0eec2a 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -3,9 +3,9 @@ ctppsOpticalFunctionsESSource = _tmp.clone( xangle1 = cms.double(185), - fileName1 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), xangle2 = cms.double(185), - fileName2 = cms.FileInPath("Validation/CTPPS/test/year_2016/optical_functions.root"), + fileName1 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), + fileName2 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), scoringPlanes = cms.VPSet( # z in cm cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 From 9870d1a2f6fd1adefe15cfb33790288d981647e4 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 12 Feb 2019 08:55:00 +0100 Subject: [PATCH 164/686] Matched light local tracks constructor to new signature --- Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index 8f9db559841d0..141073e8e79b5 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -347,7 +347,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, // save scoring plane hit if (produceScoringPlaneHits_) - out_tracks.emplace_back(rpId, b_x, 0., b_y, 0.); + out_tracks.emplace_back(rpId.rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0., CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.); // stop if rec hits are not to be produced if (!produceRecHits_) From bf0a1f1353b4671bb49b42cd2296df6b78dd6d8b Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 12 Feb 2019 09:17:57 +0100 Subject: [PATCH 165/686] Corrected units for reconstruction validator --- .../plugins/CTPPSProtonReconstructionValidator.cc | 13 ++++++------- .../test_reconstruction_cfg.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 556bcb8310f16..7182f0f476de4 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -60,8 +60,8 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> void init() { - h_de_x = new TH1D("", ";#Deltax (mm)", 100, -2E-3, +2E-3); - h_de_y = new TH1D("", ";#Deltay (mm)", 100, -2E-3, +2E-3); + h_de_x = new TH1D("", ";#Deltax (mm)", 100, -2., +2.); + h_de_y = new TH1D("", ";#Deltay (mm)", 100, -2., +2.); } void fill(double de_x, double de_y) @@ -155,8 +155,8 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const LHCOpticalFunctionsSet::Kinematics k_out; it->second.transport(k_in, k_out); - const double de_x = (k_out.x - k_out_beam.x) * 1E3 - tr->getX(); // conversions: m --> mm - const double de_y = (k_out.y - k_out_beam.y) * 1E3 - tr->getY(); // conversions: m --> mm + const double de_x = (k_out.x - k_out_beam.x) * 10. - tr->getX(); // conversions: cm --> mm + const double de_y = (k_out.y - k_out_beam.y) * 10. - tr->getY(); // conversions: cm --> mm rp_plots_[rpDecId].fill(de_x, de_y); } @@ -171,9 +171,7 @@ void CTPPSProtonReconstructionValidator::endJob() for (const auto &p : rp_plots_) { - char buf[100]; - sprintf(buf, "%u", p.first); - gDirectory = f_out->mkdir(buf); + gDirectory = f_out->mkdir(Form("%u", p.first)); p.second.write(); } @@ -183,3 +181,4 @@ void CTPPSProtonReconstructionValidator::endJob() //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSProtonReconstructionValidator); + diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index 89026e57d13ca..6992c9ebfe7ac 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -31,7 +31,7 @@ # load reconstruction sequences process.load("RecoCTPPS.Configuration.recoCTPPS_sequences_cff") process.ctppsLocalTrackLiteProducer.includeDiamonds = False -process.ctppsLocalTrackLiteProducer.includePixels = False +process.ctppsLocalTrackLiteProducer.includePixels = False process.ctppsProtons.verbosity = 0 @@ -45,7 +45,7 @@ chiSqCut = cms.double(2.), - outputFile = cms.string("test_recontruction_validation.root") + outputFile = cms.string("test_reconstruction_validation.root") ) # reconstruction plotter From 3d933d714253c6d905d155c8b4b19ba360780a7a Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 12 Feb 2019 15:19:39 +0100 Subject: [PATCH 166/686] Smart pointers used whenever possible in validation package --- .../CTPPS/plugins/CTPPSAcceptancePlotter.cc | 185 +++++------ .../plugins/CTPPSBeamSmearingValidator.cc | 47 ++- .../CTPPSDirectProtonSimulationValidator.cc | 82 ++--- .../plugins/CTPPSHepMCDistributionPlotter.cc | 24 +- .../CTPPS/plugins/CTPPSLHCInfoESSource.cc | 8 +- .../CTPPSProtonReconstructionPlotter.cc | 297 ++++++++---------- ...ProtonReconstructionSimulationValidator.cc | 203 ++++++------ .../CTPPSProtonReconstructionValidator.cc | 47 +-- .../plugins/CTPPSTrackDistributionPlotter.cc | 63 ++-- 9 files changed, 383 insertions(+), 573 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc index d2798f2d8ab81..ccd78ea2b6082 100644 --- a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -13,6 +13,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" #include "TFile.h" #include "TH1D.h" @@ -28,49 +29,41 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> { public: explicit CTPPSAcceptancePlotter( const edm::ParameterSet& ); - ~CTPPSAcceptancePlotter() override; private: - void beginJob() override; - + void beginJob() override {} void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override; - edm::EDGetTokenT tokenHepMC; - edm::EDGetTokenT< std::vector > tokenTracks; + edm::EDGetTokenT tokenHepMC_; + edm::EDGetTokenT tokenTracks_; - unsigned int rpId_45_N, rpId_45_F, rpId_56_N, rpId_56_F; + unsigned int rpId_45_N_, rpId_45_F_, rpId_56_N_, rpId_56_F_; - std::string outputFile; + std::string outputFile_; struct SingleArmPlots { - TH1D *h_xi_all = nullptr, *h_xi_acc = nullptr; - - void Init() - { - h_xi_all = new TH1D("", ";#xi", 100, 0., 0.25); - h_xi_acc = new TH1D("", ";#xi", 100, 0., 0.25); - } + std::unique_ptr h_xi_all, h_xi_acc; + SingleArmPlots() : + h_xi_all(new TH1D("", ";#xi", 100, 0., 0.25)), + h_xi_acc(new TH1D("", ";#xi", 100, 0., 0.25)) + {} - void Fill(double xi, bool acc) + void fill(double xi, bool acc) { - if (h_xi_all == nullptr) - Init(); - - h_xi_all->Fill(xi); + h_xi_all->Fill(xi); if (acc) - h_xi_acc->Fill(xi); + h_xi_acc->Fill(xi); } - void Write() const + void write() const { h_xi_all->Write("h_xi_all"); h_xi_acc->Write("h_xi_acc"); - TH1D *h_xi_rat = new TH1D(*h_xi_acc); - h_xi_rat->Divide(h_xi_all); + auto h_xi_rat = std::make_unique(*h_xi_acc); + h_xi_rat->Divide(h_xi_all.get()); h_xi_rat->Write("h_xi_rat"); } }; @@ -80,27 +73,21 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> struct DoubleArmPlots { - TH1D *h_m_all = nullptr, *h_m_acc = nullptr; - TH2D *h2_xi_45_vs_xi_56_all, *h2_xi_45_vs_xi_56_acc; - TH2D *h2_y_vs_m_all, *h2_y_vs_m_acc; - - void Init() - { - h_m_all = new TH1D("", ";m (GeV)", 100, 0., 2500.); - h_m_acc = new TH1D("", ";m (GeV)", 100, 0., 2500.); - - h2_xi_45_vs_xi_56_all = new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25); - h2_xi_45_vs_xi_56_acc = new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25); - - h2_y_vs_m_all = new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5); - h2_y_vs_m_acc = new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5); - } - - void Fill(double xi_45, double xi_56, bool acc) + std::unique_ptr h_m_all, h_m_acc; + std::unique_ptr h2_xi_45_vs_xi_56_all, h2_xi_45_vs_xi_56_acc; + std::unique_ptr h2_y_vs_m_all, h2_y_vs_m_acc; + + DoubleArmPlots() : + h_m_all(new TH1D("", ";m (GeV)", 100, 0., 2500.)), + h_m_acc(new TH1D("", ";m (GeV)", 100, 0., 2500.)), + h2_xi_45_vs_xi_56_all(new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)), + h2_xi_45_vs_xi_56_acc(new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)), + h2_y_vs_m_all(new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)), + h2_y_vs_m_acc(new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)) + {} + + void fill(double xi_45, double xi_56, bool acc) { - if (h_m_all == nullptr) - Init(); - const double p_nom = 6500.; const double m = 2. * p_nom * sqrt(xi_45 * xi_56); const double y = log(xi_45 / xi_56) / 2.; @@ -108,38 +95,35 @@ class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> h_m_all->Fill(m); h2_xi_45_vs_xi_56_all->Fill(xi_56, xi_45); h2_y_vs_m_all->Fill(m, y); - - if (acc) - { - h_m_acc->Fill(m); + + if (acc) { + h_m_acc->Fill(m); h2_xi_45_vs_xi_56_acc->Fill(xi_56, xi_45); h2_y_vs_m_acc->Fill(m, y); } } - void Write() const + void write() const { h_m_all->Write("h_m_all"); h_m_acc->Write("h_m_acc"); - TH1D *h_m_rat = new TH1D(*h_m_acc); - h_m_rat->Divide(h_m_all); + auto h_m_rat = std::make_unique(*h_m_acc); + h_m_rat->Divide(h_m_all.get()); h_m_rat->Write("h_m_rat"); - h2_xi_45_vs_xi_56_all->Write("h2_xi_45_vs_xi_56_all"); h2_xi_45_vs_xi_56_acc->Write("h2_xi_45_vs_xi_56_acc"); - TH2D *h2_xi_45_vs_xi_56_rat = new TH2D(*h2_xi_45_vs_xi_56_acc); - h2_xi_45_vs_xi_56_rat->Divide(h2_xi_45_vs_xi_56_all); + auto h2_xi_45_vs_xi_56_rat = std::make_unique(*h2_xi_45_vs_xi_56_acc); + h2_xi_45_vs_xi_56_rat->Divide(h2_xi_45_vs_xi_56_all.get()); h2_xi_45_vs_xi_56_rat->Write("h2_xi_45_vs_xi_56_rat"); - h2_y_vs_m_all->Write("h2_y_vs_m_all"); h2_y_vs_m_acc->Write("h2_y_vs_m_acc"); - TH2D *h2_y_vs_m_rat = new TH2D(*h2_y_vs_m_acc); - h2_y_vs_m_rat->Divide(h2_y_vs_m_all); + auto h2_y_vs_m_rat = std::make_unique(*h2_y_vs_m_acc); + h2_y_vs_m_rat->Divide(h2_y_vs_m_all.get()); h2_y_vs_m_rat->Write("h2_y_vs_m_rat"); } }; @@ -157,49 +141,41 @@ using namespace HepMC; //---------------------------------------------------------------------------------------------------- CTPPSAcceptancePlotter::CTPPSAcceptancePlotter(const edm::ParameterSet& iConfig) : - tokenHepMC( consumes(iConfig.getParameter("tagHepMC")) ), - tokenTracks( consumes< std::vector >( iConfig.getParameter( "tagTracks" ) ) ), - - rpId_45_N(iConfig.getParameter("rpId_45_N")), - rpId_45_F(iConfig.getParameter("rpId_45_F")), - rpId_56_N(iConfig.getParameter("rpId_56_N")), - rpId_56_F(iConfig.getParameter("rpId_56_F")), - - outputFile(iConfig.getParameter("outputFile")) + tokenHepMC_ (consumes(iConfig.getParameter("tagHepMC"))), + tokenTracks_(consumes(iConfig.getParameter("tagTracks"))), + rpId_45_N_ (iConfig.getParameter("rpId_45_N")), + rpId_45_F_ (iConfig.getParameter("rpId_45_F")), + rpId_56_N_ (iConfig.getParameter("rpId_56_N")), + rpId_56_F_ (iConfig.getParameter("rpId_56_F")), + outputFile_(iConfig.getParameter("outputFile")) { singleArmConfigurations = { - { rpId_45_N }, - { rpId_45_F }, - { rpId_56_N }, - { rpId_56_F }, - { rpId_45_N, rpId_45_F }, - { rpId_56_N, rpId_56_F }, + { rpId_45_N_ }, + { rpId_45_F_ }, + { rpId_56_N_ }, + { rpId_56_F_ }, + { rpId_45_N_, rpId_45_F_ }, + { rpId_56_N_, rpId_56_F_ }, }; doubleArmConfigurations = { - { rpId_45_N, rpId_56_N }, - { rpId_45_F, rpId_56_F }, - { rpId_45_N, rpId_45_F, rpId_56_N, rpId_56_F }, + { rpId_45_N_, rpId_56_N_ }, + { rpId_45_F_, rpId_56_F_ }, + { rpId_45_N_, rpId_45_F_, rpId_56_N_, rpId_56_F_ }, }; } //---------------------------------------------------------------------------------------------------- -CTPPSAcceptancePlotter::~CTPPSAcceptancePlotter() -{ -} - -//---------------------------------------------------------------------------------------------------- - void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventSetup&) { // get input edm::Handle hHepMC; - iEvent.getByToken(tokenHepMC, hHepMC); + iEvent.getByToken(tokenHepMC_, hHepMC); HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent(); - edm::Handle< std::vector > hTracks; - iEvent.getByToken(tokenTracks, hTracks); + edm::Handle hTracks; + iEvent.getByToken(tokenTracks_, hTracks); // extract protons bool proton_45_set = false; @@ -282,8 +258,8 @@ void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventS continue; const double xi = (arm == 0) ? xi_45 : xi_56; - - singleArmPlots[rpIds].Fill(xi, acc); + + singleArmPlots[rpIds].fill(xi, acc); } for (const auto rpIds : doubleArmConfigurations) @@ -292,58 +268,43 @@ void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventS for (const auto rpId : rpIds) acc &= trackPresent[rpId]; - doubleArmPlots[rpIds].Fill(xi_45, xi_56, acc); + doubleArmPlots[rpIds].fill(xi_45, xi_56, acc); } } -//---------------------------------------------------------------------------------------------------- - -void CTPPSAcceptancePlotter::beginJob() -{ -} - //---------------------------------------------------------------------------------------------------- void CTPPSAcceptancePlotter::endJob() { - TFile *f_out = TFile::Open(outputFile.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); - for (const auto &p : singleArmPlots) - { + for (const auto &p : singleArmPlots) { string dirName; - for (const auto &rpId : p.first) - { + for (const auto &rpId : p.first) { if (!dirName.empty()) dirName += ","; - char buf[100]; - sprintf(buf, "%u", rpId); - dirName += buf; + dirName += Form("%u", rpId); } gDirectory = f_out->mkdir(dirName.c_str()); - p.second.Write(); + p.second.write(); } - for (const auto &p : doubleArmPlots) - { + for (const auto &p : doubleArmPlots) { string dirName; - for (const auto &rpId : p.first) - { + for (const auto &rpId : p.first) { if (!dirName.empty()) dirName += ","; - char buf[100]; - sprintf(buf, "%u", rpId); - dirName += buf; + dirName += Form("%u", rpId); } gDirectory = f_out->mkdir(dirName.c_str()); - p.second.Write(); + p.second.write(); } - - delete f_out; } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSAcceptancePlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc index ee3d9d0919947..896872d3cb337 100644 --- a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc @@ -36,20 +36,16 @@ class CTPPSBeamSmearingValidator : public edm::one::EDAnalyzer<> std::string outputFile_; - TH1D *h_de_vtx_x_, *h_de_vtx_y_, *h_de_vtx_z_; + std::unique_ptr h_de_vtx_x_, h_de_vtx_y_, h_de_vtx_z_; struct SectorPlots { - TH1D *h_de_th_x = nullptr; - TH1D *h_de_th_y = nullptr; - TH1D *h_de_p = nullptr; + std::unique_ptr h_de_th_x, h_de_th_y, h_de_p; - void init() - { - h_de_th_x = new TH1D("", ";#Delta#theta_{x} (rad)", 100, 0., 0.); - h_de_th_y = new TH1D("", ";#Delta#theta_{y} (rad)", 100, 0., 0.); - h_de_p = new TH1D("", ";#Deltap (GeV)", 100, 0., 0.); - } + SectorPlots() : + h_de_th_x(new TH1D("", ";#Delta#theta_{x} (rad)", 100, 0., 0.)), + h_de_th_y(new TH1D("", ";#Delta#theta_{y} (rad)", 100, 0., 0.)), + h_de_p(new TH1D("", ";#Deltap (GeV)", 100, 0., 0.)) {} void write() const { @@ -73,15 +69,11 @@ using namespace HepMC; CTPPSBeamSmearingValidator::CTPPSBeamSmearingValidator(const edm::ParameterSet& iConfig) : tokenBeforeSmearing_( consumes(iConfig.getParameter("tagBeforeSmearing")) ), tokenAfterSmearing_( consumes(iConfig.getParameter("tagAfterSmearing")) ), - outputFile_(iConfig.getParameter("outputFile")) -{ - h_de_vtx_x_ = new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.); - h_de_vtx_y_ = new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.); - h_de_vtx_z_ = new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.); - - sectorPlots_[0].init(); - sectorPlots_[1].init(); -} + outputFile_(iConfig.getParameter("outputFile")), + h_de_vtx_x_(new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.)), + h_de_vtx_y_(new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.)), + h_de_vtx_z_(new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.)) +{} //---------------------------------------------------------------------------------------------------- @@ -98,11 +90,11 @@ void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::Ev // vertices GenEvent::vertex_const_iterator vold, vnew; - for (vold = orig->vertices_begin(), vnew = smear->vertices_begin(); + for (vold = orig->vertices_begin(), vnew = smear->vertices_begin(); vold != orig->vertices_end() && vnew != smear->vertices_end(); ++vold, ++vnew) { - const FourVector &vo = (*vold)->position(); - const FourVector &vn = (*vnew)->position(); + const FourVector &vo = (*vold)->position(); + const FourVector &vn = (*vnew)->position(); // HepMC gives vertex in mm h_de_vtx_x_->Fill(vn.x() - vo.x()); @@ -116,7 +108,7 @@ void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::Ev pold != orig->particles_end() && pnew != smear->particles_end(); ++pold, ++pnew) { FourVector o = (*pold)->momentum(), n = (*pnew)->momentum(); - + // determine direction region signed int idx = -1; const double thetaLim = 0.01; // rad @@ -129,7 +121,7 @@ void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::Ev if (idx < 0) continue; - + /* cout << "particle\n\told: [" << o.x() << ", " << o.y() << ", " << o.z() << ", " << o.t() << "]\n\tnew: [" << n.x() << ", " << n.y() << ", " << n.z() << ", " << n.t() @@ -153,21 +145,20 @@ void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::Ev void CTPPSBeamSmearingValidator::endJob() { - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); h_de_vtx_x_->Write(); h_de_vtx_y_->Write(); h_de_vtx_z_->Write(); - + gDirectory = f_out->mkdir("sector 45"); sectorPlots_[0].write(); gDirectory = f_out->mkdir("sector 56"); sectorPlots_[1].write(); - - delete f_out; } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSBeamSmearingValidator); + diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc index 68913826099e7..b1b859ad7139e 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc @@ -18,6 +18,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" #include "TFile.h" #include "TH1D.h" @@ -31,38 +32,31 @@ class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> { public: explicit CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& ); - ~CTPPSDirectProtonSimulationValidator() override; private: - void beginJob() override; - + void beginJob() override {} void analyze( const edm::Event&, const edm::EventSetup& ) override; - void endJob() override; - edm::EDGetTokenT< std::vector > simuTracksToken_; - edm::EDGetTokenT< std::vector > recoTracksToken_; + edm::EDGetTokenT simuTracksToken_; + edm::EDGetTokenT recoTracksToken_; - std::string outputFile; + std::string outputFile_; struct RPPlots { - TH2D *h2_xr_vs_xs=nullptr, *h2_yr_vs_ys=nullptr; - TH1D *h_de_x, *h_de_y; + std::unique_ptr h2_xr_vs_xs, h2_yr_vs_ys; + std::unique_ptr h_de_x, h_de_y; - void init() - { - h2_xr_vs_xs = new TH2D("", "", 100, -10., +10., 100, -10, +10.); - h2_yr_vs_ys = new TH2D("", "", 100, -10., +10., 100, -10, +10.); - h_de_x = new TH1D("", "", 100, -0., +0.); - h_de_y = new TH1D("", "", 100, -0., +0.); - } + RPPlots() : + h2_xr_vs_xs( new TH2D("", "", 100, -10., +10., 100, -10, +10.) ), + h2_yr_vs_ys( new TH2D("", "", 100, -10., +10., 100, -10, +10.) ), + h_de_x( new TH1D("", "", 100, -0., +0.) ), + h_de_y( new TH1D("", "", 100, -0., +0.) ) + {} void fill(double simu_x, double simu_y, double reco_x, double reco_y) { - if (h2_xr_vs_xs == nullptr) - init(); - h2_xr_vs_xs->Fill(simu_x, reco_x); h2_yr_vs_ys->Fill(simu_y, reco_y); @@ -79,47 +73,35 @@ class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> } }; - std::map rpPlots; + std::map rpPlots_; }; //---------------------------------------------------------------------------------------------------- CTPPSDirectProtonSimulationValidator::CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& iConfig ) : - simuTracksToken_( consumes< std::vector >( iConfig.getParameter( "simuTracksTag" ) ) ), - recoTracksToken_( consumes< std::vector >( iConfig.getParameter( "recoTracksTag" ) ) ), - outputFile( iConfig.getParameter("outputFile") ) -{ -} - -//---------------------------------------------------------------------------------------------------- - -CTPPSDirectProtonSimulationValidator::~CTPPSDirectProtonSimulationValidator() -{ -} + simuTracksToken_( consumes( iConfig.getParameter( "simuTracksTag" ) ) ), + recoTracksToken_( consumes( iConfig.getParameter( "recoTracksTag" ) ) ), + outputFile_( iConfig.getParameter("outputFile") ) +{} //---------------------------------------------------------------------------------------------------- void CTPPSDirectProtonSimulationValidator::analyze( const edm::Event& iEvent, const edm::EventSetup& ) { // get input - edm::Handle< std::vector > simuTracks; + edm::Handle simuTracks; iEvent.getByToken( simuTracksToken_, simuTracks ); - edm::Handle< std::vector > recoTracks; + edm::Handle recoTracks; iEvent.getByToken( recoTracksToken_, recoTracks ); // process tracks - for (const auto& simuTrack : *simuTracks) - { - - for (const auto& recoTrack : *recoTracks) - { - if (simuTrack.getRPId() == recoTrack.getRPId()) - { - CTPPSDetId rpId(simuTrack.getRPId()); + for (const auto& simuTrack : *simuTracks) { + const CTPPSDetId rpId(simuTrack.getRPId()); + for (const auto& recoTrack : *recoTracks) { + if (simuTrack.getRPId() == recoTrack.getRPId()) { unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - - rpPlots[rpDecId].fill(simuTrack.getX(), simuTrack.getY(), recoTrack.getX(), recoTrack.getY()); + rpPlots_[rpDecId].fill(simuTrack.getX(), simuTrack.getY(), recoTrack.getX(), recoTrack.getY()); } } } @@ -127,18 +109,11 @@ void CTPPSDirectProtonSimulationValidator::analyze( const edm::Event& iEvent, co //---------------------------------------------------------------------------------------------------- -void CTPPSDirectProtonSimulationValidator::beginJob() -{ -} - -//---------------------------------------------------------------------------------------------------- - void CTPPSDirectProtonSimulationValidator::endJob() { - TFile *f_out = TFile::Open(outputFile.c_str(), "recreate"); - - for (const auto it : rpPlots) - { + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& it : rpPlots_) { gDirectory = f_out->mkdir(Form("RP %u", it.first)); it.second.write(); } @@ -147,3 +122,4 @@ void CTPPSDirectProtonSimulationValidator::endJob() //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE( CTPPSDirectProtonSimulationValidator ); + diff --git a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc index e975cb137b672..4a8c48b630c96 100644 --- a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc @@ -30,20 +30,14 @@ class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> public: explicit CTPPSHepMCDistributionPlotter(const edm::ParameterSet&); - ~CTPPSHepMCDistributionPlotter() override {} - private: void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override; edm::EDGetTokenT tokenHepMC_; - std::string outputFile_; - TH1D *h_xi_; - TH1D *h_th_x_; - TH1D *h_th_y_; + std::unique_ptr h_xi_, h_th_x_, h_th_y_; }; //---------------------------------------------------------------------------------------------------- @@ -56,12 +50,11 @@ using namespace HepMC; CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::ParameterSet& iConfig) : tokenHepMC_( consumes(iConfig.getParameter("tagHepMC")) ), - outputFile_(iConfig.getParameter("outputFile")) -{ - h_xi_ = new TH1D("h_xi", ";#xi", 100, 0., 0.30); - h_th_x_ = new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6); - h_th_y_ = new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6); -} + outputFile_(iConfig.getParameter("outputFile")), + h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)), + h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)), + h_th_y_(new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6)) +{} //---------------------------------------------------------------------------------------------------- @@ -111,15 +104,14 @@ void CTPPSHepMCDistributionPlotter::analyze(const edm::Event& iEvent, const edm: void CTPPSHepMCDistributionPlotter::endJob() { - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); h_xi_->Write(); h_th_x_->Write(); h_th_y_->Write(); - - delete f_out; } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSHepMCDistributionPlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc index 9a4d47a00ef69..67e53488ba02b 100644 --- a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc +++ b/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc @@ -20,19 +20,16 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord { public: CTPPSLHCInfoESSource(const edm::ParameterSet &); - - ~CTPPSLHCInfoESSource() override {}; - edm::ESProducts> produce(const LHCInfoRcd &); private: + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + edm::EventRange m_validityRange; double m_beamEnergy; double m_xangle; bool m_insideValidityRange; - - void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; }; //---------------------------------------------------------------------------------------------------- @@ -98,3 +95,4 @@ edm::ESProducts> CTPPSLHCInfoESSource::produce(const LH //---------------------------------------------------------------------------------------------------- DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSLHCInfoESSource); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc index ce377e343309b..a66c7ff5ac0d6 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -16,6 +16,7 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "TFile.h" #include "TGraphErrors.h" @@ -36,9 +37,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> void endJob() override; - edm::EDGetTokenT> tokenTracks_; - edm::EDGetTokenT> tokenRecoProtonsSingleRP_; - edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + edm::EDGetTokenT tokenTracks_; + edm::EDGetTokenT tokenRecoProtonsSingleRP_; + edm::EDGetTokenT tokenRecoProtonsMultiRP_; unsigned int rpId_45_N_, rpId_45_F_; unsigned int rpId_56_N_, rpId_56_F_; @@ -70,26 +71,19 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct SingleRPPlots { - TH1D *h_xi = nullptr; + std::unique_ptr h_xi; + std::unique_ptr h2_th_y_vs_xi; + std::unique_ptr p_th_y_vs_xi; - TH2D *h2_th_y_vs_xi = nullptr; - TProfile *p_th_y_vs_xi = nullptr; - - void init() - { - h_xi = new TH1D("", ";#xi", 100, 0., 0.25); - - h2_th_y_vs_xi = new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); - p_th_y_vs_xi = new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25); - } + SingleRPPlots() : + h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)) + {} void fill(const reco::ForwardProton &p) { - if (!h_xi) - init(); - - if (p.validFit()) - { + if (p.validFit()) { h_xi->Fill(p.xi()); const double th_y = p.thetaY(); @@ -111,88 +105,71 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct MultiRPPlots { - TH1D *h_xi=nullptr, *h_th_x=nullptr, *h_th_y=nullptr, *h_vtx_y=nullptr, *h_t=nullptr, *h_chi_sq=nullptr, *h_chi_sq_norm=nullptr; - TH1D *h_t_xi_range1=nullptr, *h_t_xi_range2=nullptr, *h_t_xi_range3=nullptr; - TH2D *h2_th_x_vs_xi = nullptr, *h2_th_y_vs_xi = nullptr, *h2_vtx_y_vs_xi = nullptr, *h2_t_vs_xi; - TProfile *p_th_x_vs_xi = nullptr, *p_th_y_vs_xi = nullptr, *p_vtx_y_vs_xi = nullptr; - - void init() + std::unique_ptr h_xi, h_th_x, h_th_y, h_vtx_y, h_t, h_chi_sq, h_chi_sq_norm; + std::unique_ptr h_t_xi_range1, h_t_xi_range2, h_t_xi_range3; + std::unique_ptr h2_th_x_vs_xi, h2_th_y_vs_xi, h2_vtx_y_vs_xi, h2_t_vs_xi; + std::unique_ptr p_th_x_vs_xi, p_th_y_vs_xi, p_vtx_y_vs_xi; + + MultiRPPlots() : + h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), + h_th_x(new TH1D("", ";#theta_{x} (rad)", 100, -500E-6, +500E-6)), + h_th_y(new TH1D("", ";#theta_{y} (rad)", 100, -500E-6, +500E-6)), + h_vtx_y(new TH1D("", ";vtx_{y} (cm)", 100, -2., +2.)), + h_chi_sq(new TH1D("", ";#chi^{2}", 100, 0., 0.)), + h_chi_sq_norm(new TH1D("", ";#chi^{2}/ndf", 100, 0., 5.)), + h2_th_x_vs_xi(new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + h2_vtx_y_vs_xi(new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25, 100, -500E-3, +500E-3)), + p_th_x_vs_xi(new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)), + p_vtx_y_vs_xi(new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25)) { std::vector v_t_bin_edges; - for (double t = 0; t <= 5.; ) - { + for (double t = 0; t <= 5.; ) { v_t_bin_edges.push_back(t); const double de_t = 0.05 + 0.09 * t + 0.02 * t*t; t += de_t; } - - double *t_bin_edges = new double[v_t_bin_edges.size()]; - for (unsigned int i = 0; i < v_t_bin_edges.size(); ++i) - t_bin_edges[i] = v_t_bin_edges[i]; - - h_chi_sq = new TH1D("", ";#chi^{2}", 100, 0., 0.); - h_chi_sq_norm = new TH1D("", ";#chi^{2}/ndf", 100, 0., 5.); - - h_xi = new TH1D("", ";#xi", 100, 0., 0.25); - - h_th_x = new TH1D("", ";#theta_{x} (rad)", 100, -500E-6, +500E-6); - h_th_y = new TH1D("", ";#theta_{y} (rad)", 100, -500E-6, +500E-6); - - h_vtx_y = new TH1D("", ";vtx_{y} (cm)", 100, -2., +2.); - - h_t = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); - h_t_xi_range1 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); - h_t_xi_range2 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); - h_t_xi_range3 = new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, t_bin_edges); - - h2_th_x_vs_xi = new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); - h2_th_y_vs_xi = new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6); - h2_vtx_y_vs_xi = new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25, 100, -500E-3, +500E-3); - h2_t_vs_xi = new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.25, v_t_bin_edges.size() - 1, t_bin_edges); - - p_th_x_vs_xi = new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25); - p_th_y_vs_xi = new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25); - p_vtx_y_vs_xi = new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25); - - delete[] t_bin_edges; + h_t.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range1.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range2.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range3.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h2_t_vs_xi.reset(new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.25, v_t_bin_edges.size() - 1, v_t_bin_edges.data())); } void fill(const reco::ForwardProton &p) { - if (!h_xi) - init(); + if (!p.validFit()) + return; - if (p.validFit()) - { - const double th_x = p.thetaX(); - const double th_y = p.thetaY(); - const double mt = - p.t(); + const double th_x = p.thetaX(); + const double th_y = p.thetaY(); + const double mt = - p.t(); - h_chi_sq->Fill(p.chi2()); - if (p.ndof() > 0) - h_chi_sq_norm->Fill(p.normalizedChi2()); + h_chi_sq->Fill(p.chi2()); + if (p.ndof() > 0) + h_chi_sq_norm->Fill(p.normalizedChi2()); - h_xi->Fill(p.xi()); + h_xi->Fill(p.xi()); - h_th_x->Fill(th_x); - h_th_y->Fill(th_y); + h_th_x->Fill(th_x); + h_th_y->Fill(th_y); - h_vtx_y->Fill(p.vertex().y()); + h_vtx_y->Fill(p.vertex().y()); - h_t->Fill(mt); - if (p.xi() > 0.04 && p.xi() < 0.07) h_t_xi_range1->Fill(mt); - if (p.xi() > 0.07 && p.xi() < 0.10) h_t_xi_range2->Fill(mt); - if (p.xi() > 0.10 && p.xi() < 0.13) h_t_xi_range3->Fill(mt); + h_t->Fill(mt); + if (p.xi() > 0.04 && p.xi() < 0.07) h_t_xi_range1->Fill(mt); + if (p.xi() > 0.07 && p.xi() < 0.10) h_t_xi_range2->Fill(mt); + if (p.xi() > 0.10 && p.xi() < 0.13) h_t_xi_range3->Fill(mt); - h2_th_x_vs_xi->Fill(p.xi(), th_x); - h2_th_y_vs_xi->Fill(p.xi(), th_y); - h2_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); - h2_t_vs_xi->Fill(p.xi(), mt); + h2_th_x_vs_xi->Fill(p.xi(), th_x); + h2_th_y_vs_xi->Fill(p.xi(), th_y); + h2_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); + h2_t_vs_xi->Fill(p.xi(), mt); - p_th_x_vs_xi->Fill(p.xi(), th_x); - p_th_y_vs_xi->Fill(p.xi(), th_y); - p_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); - } + p_th_x_vs_xi->Fill(p.xi(), th_x); + p_th_y_vs_xi->Fill(p.xi(), th_y); + p_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); } void write() const @@ -205,22 +182,22 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> h_th_x->Write("h_th_x"); h2_th_x_vs_xi->Write("h2_th_x_vs_xi"); p_th_x_vs_xi->Write("p_th_x_vs_xi"); - TGraphErrors *g_th_x_RMS_vs_xi = new TGraphErrors(); - profileToRMSGraph(p_th_x_vs_xi, g_th_x_RMS_vs_xi); + auto g_th_x_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_th_x_vs_xi.get(), g_th_x_RMS_vs_xi.get()); g_th_x_RMS_vs_xi->Write("g_th_x_RMS_vs_xi"); h_th_y->Write("h_th_y"); h2_th_y_vs_xi->Write("h2_th_y_vs_xi"); p_th_y_vs_xi->Write("p_th_y_vs_xi"); - TGraphErrors *g_th_y_RMS_vs_xi = new TGraphErrors(); - profileToRMSGraph(p_th_y_vs_xi, g_th_y_RMS_vs_xi); + auto g_th_y_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_th_y_vs_xi.get(), g_th_y_RMS_vs_xi.get()); g_th_y_RMS_vs_xi->Write("g_th_y_RMS_vs_xi"); h_vtx_y->Write("h_vtx_y"); h2_vtx_y_vs_xi->Write("h2_vtx_y_vs_xi"); p_vtx_y_vs_xi->Write("p_vtx_y_vs_xi"); - TGraphErrors *g_vtx_y_RMS_vs_xi = new TGraphErrors(); - profileToRMSGraph(p_vtx_y_vs_xi, g_vtx_y_RMS_vs_xi); + auto g_vtx_y_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_vtx_y_vs_xi.get(), g_vtx_y_RMS_vs_xi.get()); g_vtx_y_RMS_vs_xi->Write("g_vtx_y_RMS_vs_xi"); h_t->Write("h_t"); @@ -236,34 +213,26 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct SingleMultiCorrelationPlots { - TH2D *h2_xi_mu_vs_xi_si = nullptr; - TH1D *h_xi_diff_mu_si = nullptr; - TH1D *h_xi_diff_si_mu = nullptr; + std::unique_ptr h2_xi_mu_vs_xi_si; + std::unique_ptr h_xi_diff_mu_si, h_xi_diff_si_mu; - TH2D *h2_xi_diff_si_mu_vs_xi_mu = nullptr; - TProfile *p_xi_diff_si_mu_vs_xi_mu = nullptr; + std::unique_ptr h2_xi_diff_si_mu_vs_xi_mu; + std::unique_ptr p_xi_diff_si_mu_vs_xi_mu; - TH2D *h2_th_y_mu_vs_th_y_si = nullptr; + std::unique_ptr h2_th_y_mu_vs_th_y_si; - void init() - { - h2_xi_mu_vs_xi_si = new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.25, 100, 0., 0.25); - h_xi_diff_mu_si = new TH1D("", ";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1); - h_xi_diff_si_mu = new TH1D("", ";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1); - - h2_xi_diff_si_mu_vs_xi_mu = new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25, 100, -0.10, 0.10); - p_xi_diff_si_mu_vs_xi_mu = new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25); - - h2_th_y_mu_vs_th_y_si = new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6); - } + SingleMultiCorrelationPlots() : + h2_xi_mu_vs_xi_si(new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.25, 100, 0., 0.25)), + h_xi_diff_mu_si(new TH1D("", ";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1)), + h_xi_diff_si_mu(new TH1D("", ";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1)), + h2_xi_diff_si_mu_vs_xi_mu(new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25, 100, -0.10, 0.10)), + p_xi_diff_si_mu_vs_xi_mu(new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25)), + h2_th_y_mu_vs_th_y_si(new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6)) + {} void fill(const reco::ForwardProton &p_single, const reco::ForwardProton &p_multi) { - if (!h2_xi_mu_vs_xi_si) - init(); - - if (p_single.validFit() && p_multi.validFit()) - { + if (p_single.validFit() && p_multi.validFit()) { h2_xi_mu_vs_xi_si->Fill(p_single.xi(), p_multi.xi()); h_xi_diff_mu_si->Fill(p_multi.xi() - p_single.xi()); h_xi_diff_si_mu->Fill(p_single.xi() - p_multi.xi()); @@ -295,37 +264,32 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct ArmCorrelationPlots { - TH1D *h_xi_si_diffNF = nullptr; - TProfile *p_xi_si_diffNF_vs_xi_mu = nullptr; - - TH1D *h_th_y_si_diffNF = nullptr; - TProfile *p_th_y_si_diffNF_vs_xi_mu = nullptr; + std::unique_ptr h_xi_si_diffNF; + std::unique_ptr p_xi_si_diffNF_vs_xi_mu; - void init() - { - h_xi_si_diffNF = new TH1D("", ";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02); - p_xi_si_diffNF_vs_xi_mu = new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.25); + std::unique_ptr h_th_y_si_diffNF; + std::unique_ptr p_th_y_si_diffNF_vs_xi_mu; - h_th_y_si_diffNF = new TH1D("", ";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6); - p_th_y_si_diffNF_vs_xi_mu = new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25); - } + ArmCorrelationPlots() : + h_xi_si_diffNF(new TH1D("", ";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02)), + p_xi_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.25)), + h_th_y_si_diffNF(new TH1D("", ";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6)), + p_th_y_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25)) + {} void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m) { - if (!h_xi_si_diffNF) - init(); + if (!p_s_N.validFit() || !p_s_F.validFit() || !p_m.validFit()) + return; - if (p_s_N.validFit() && p_s_F.validFit() && p_m.validFit()) - { - const double th_y_s_N = p_s_N.thetaY(); - const double th_y_s_F = p_s_F.thetaY(); + const double th_y_s_N = p_s_N.thetaY(); + const double th_y_s_F = p_s_F.thetaY(); - h_xi_si_diffNF->Fill(p_s_F.xi() - p_s_N.xi()); - p_xi_si_diffNF_vs_xi_mu->Fill(p_m.xi(), p_s_F.xi() - p_s_N.xi()); + h_xi_si_diffNF->Fill(p_s_F.xi() - p_s_N.xi()); + p_xi_si_diffNF_vs_xi_mu->Fill(p_m.xi(), p_s_F.xi() - p_s_N.xi()); - h_th_y_si_diffNF->Fill(th_y_s_F - th_y_s_N); - p_th_y_si_diffNF_vs_xi_mu->Fill(p_m.xi(), th_y_s_F - th_y_s_N); - } + h_th_y_si_diffNF->Fill(th_y_s_F - th_y_s_N); + p_th_y_si_diffNF_vs_xi_mu->Fill(p_m.xi(), th_y_s_F - th_y_s_N); } void write() const @@ -340,8 +304,8 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> std::map armCorrelationPlots_; - TProfile *p_x_L_diffNF_vs_x_L_N_, *p_x_R_diffNF_vs_x_R_N_; - TProfile *p_y_L_diffNF_vs_y_L_N_, *p_y_R_diffNF_vs_y_R_N_; + std::unique_ptr p_x_L_diffNF_vs_x_L_N_, p_x_R_diffNF_vs_x_R_N_; + std::unique_ptr p_y_L_diffNF_vs_y_L_N_, p_y_R_diffNF_vs_y_R_N_; signed int n_non_empty_events_; }; @@ -354,9 +318,9 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- CTPPSProtonReconstructionPlotter::CTPPSProtonReconstructionPlotter(const edm::ParameterSet &ps) : - tokenTracks_(consumes< std::vector>(ps.getParameter("tagTracks"))), - tokenRecoProtonsSingleRP_(consumes>(ps.getParameter("tagRecoProtonsSingleRP"))), - tokenRecoProtonsMultiRP_(consumes>(ps.getParameter("tagRecoProtonsMultiRP"))), + tokenTracks_ (consumes(ps.getParameter("tagTracks"))), + tokenRecoProtonsSingleRP_(consumes(ps.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_ (consumes(ps.getParameter("tagRecoProtonsMultiRP"))), rpId_45_N_(ps.getParameter("rpId_45_N")), rpId_45_F_(ps.getParameter("rpId_45_F")), @@ -366,27 +330,27 @@ CTPPSProtonReconstructionPlotter::CTPPSProtonReconstructionPlotter(const edm::Pa outputFile_(ps.getParameter("outputFile")), maxNonEmptyEvents_(ps.getUntrackedParameter("maxNonEmptyEvents", -1)), - n_non_empty_events_(0) -{ - p_x_L_diffNF_vs_x_L_N_ = new TProfile("p_x_L_diffNF_vs_x_L_N", ";x_{LN};x_{LF} - x_{LN}", 100, 0., +20.); - p_x_R_diffNF_vs_x_R_N_ = new TProfile("p_x_R_diffNF_vs_x_R_N", ";x_{RN};x_{RF} - x_{RN}", 100, 0., +20.); + p_x_L_diffNF_vs_x_L_N_(new TProfile("p_x_L_diffNF_vs_x_L_N", ";x_{LN};x_{LF} - x_{LN}", 100, 0., +20.)), + p_x_R_diffNF_vs_x_R_N_(new TProfile("p_x_R_diffNF_vs_x_R_N", ";x_{RN};x_{RF} - x_{RN}", 100, 0., +20.)), - p_y_L_diffNF_vs_y_L_N_ = new TProfile("p_y_L_diffNF_vs_y_L_N", ";y_{LN};y_{LF} - y_{LN}", 100, -20., +20.); - p_y_R_diffNF_vs_y_R_N_ = new TProfile("p_y_R_diffNF_vs_y_R_N", ";y_{RN};y_{RF} - y_{RN}", 100, -20., +20.); -} + p_y_L_diffNF_vs_y_L_N_(new TProfile("p_y_L_diffNF_vs_y_L_N", ";y_{LN};y_{LF} - y_{LN}", 100, -20., +20.)), + p_y_R_diffNF_vs_y_R_N_(new TProfile("p_y_R_diffNF_vs_y_R_N", ";y_{RN};y_{RF} - y_{RN}", 100, -20., +20.)), + + n_non_empty_events_(0) +{} //---------------------------------------------------------------------------------------------------- void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const edm::EventSetup&) { // get input - edm::Handle< std::vector > hTracks; + edm::Handle hTracks; event.getByToken(tokenTracks_, hTracks); - Handle> hRecoProtonsSingleRP; + Handle hRecoProtonsSingleRP; event.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); - Handle> hRecoProtonsMultiRP; + Handle hRecoProtonsMultiRP; event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); if (!hRecoProtonsSingleRP->empty()) @@ -498,7 +462,7 @@ void CTPPSProtonReconstructionPlotter::endJob() { LogInfo("CTPPSProtonReconstructionPlotter") << "n_non_empty_events = " << n_non_empty_events_; - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); p_x_L_diffNF_vs_x_L_N_->Write(); p_x_R_diffNF_vs_x_R_N_->Write(); @@ -507,49 +471,34 @@ void CTPPSProtonReconstructionPlotter::endJob() p_y_R_diffNF_vs_y_R_N_->Write(); TDirectory *d_singleRPPlots = f_out->mkdir("singleRPPlots"); - for (const auto it : singleRPPlots_) - { - char buf[100]; - sprintf(buf, "rp%u", it.first); - gDirectory = d_singleRPPlots->mkdir(buf); + for (const auto& it : singleRPPlots_) { + gDirectory = d_singleRPPlots->mkdir(Form("rp%u", it.first)); it.second.write(); } TDirectory *d_multiRPPlots = f_out->mkdir("multiRPPlots"); - for (const auto it : multiRPPlots_) - { - char buf[100]; - sprintf(buf, "arm%u", it.first); - gDirectory = d_multiRPPlots->mkdir(buf); + for (const auto& it : multiRPPlots_) { + gDirectory = d_multiRPPlots->mkdir(Form("arm%u", it.first)); it.second.write(); } TDirectory *d_singleMultiCorrelationPlots = f_out->mkdir("singleMultiCorrelationPlots"); - for (const auto it : singleMultiCorrelationPlots_) - { + for (const auto& it : singleMultiCorrelationPlots_) { unsigned int si_rp = it.first / 10; unsigned int mu_arm = it.first % 10; - char buf[100]; - sprintf(buf, "si_rp%u_mu_arm%u", si_rp, mu_arm); - gDirectory = d_singleMultiCorrelationPlots->mkdir(buf); + gDirectory = d_singleMultiCorrelationPlots->mkdir(Form("si_rp%u_mu_arm%u", si_rp, mu_arm)); it.second.write(); } TDirectory *d_armCorrelationPlots = f_out->mkdir("armCorrelationPlots"); - for (const auto it : armCorrelationPlots_) - { - unsigned int arm = it.first; - - char buf[100]; - sprintf(buf, "arm%u", arm); - gDirectory = d_armCorrelationPlots->mkdir(buf); + for (const auto& it : armCorrelationPlots_) { + gDirectory = d_armCorrelationPlots->mkdir(Form("arm%u", it.first)); it.second.write(); } - - delete f_out; } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSProtonReconstructionPlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index 9ad43c0acbd20..d9f90a3223c49 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -18,6 +18,7 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "TFile.h" @@ -36,11 +37,8 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer public: explicit CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet&); - ~CTPPSProtonReconstructionSimulationValidator() override {} - private: void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override; void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ForwardProton &rec_pr, @@ -49,75 +47,72 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer edm::EDGetTokenT tokenHepMCBeforeSmearing_; edm::EDGetTokenT tokenHepMCAfterSmearing_; - edm::EDGetTokenT> tokenRecoProtonsSingleRP_; - edm::EDGetTokenT> tokenRecoProtonsMultiRP_; + edm::EDGetTokenT tokenRecoProtonsSingleRP_; + edm::EDGetTokenT tokenRecoProtonsMultiRP_; std::string outputFile_; struct PlotGroup { - TH1D *h_de_xi = nullptr; - TProfile *p_de_xi_vs_xi_simu; - TH2D *h_xi_reco_vs_xi_simu; + std::unique_ptr h_de_xi; + std::unique_ptr p_de_xi_vs_xi_simu; + std::unique_ptr h_xi_reco_vs_xi_simu; - TH1D *h_de_th_x = nullptr; - TProfile *p_de_th_x_vs_xi_simu; + std::unique_ptr h_de_th_x; + std::unique_ptr p_de_th_x_vs_xi_simu; - TH1D *h_de_th_y = nullptr; - TProfile *p_de_th_y_vs_xi_simu; + std::unique_ptr h_de_th_y; + std::unique_ptr p_de_th_y_vs_xi_simu; - TH1D *h_de_vtx_y = nullptr; - TProfile *p_de_vtx_y_vs_xi_simu; + std::unique_ptr h_de_vtx_y; + std::unique_ptr p_de_vtx_y_vs_xi_simu; - TH1D *h_de_t = nullptr; - TProfile *p_de_t_vs_xi_simu; - TProfile *p_de_t_vs_t_simu; + std::unique_ptr h_de_t; + std::unique_ptr p_de_t_vs_xi_simu, p_de_t_vs_t_simu; - void init() - { - h_de_xi = new TH1D("", ";#xi_{reco} - #xi_{simu}", 100, 0., 0.); - p_de_xi_vs_xi_simu = new TProfile("", ";#xi_{simu};#xi_{reco} - #xi_{simu}", 19, 0.015, 0.205); - h_xi_reco_vs_xi_simu = new TH2D("", ";#xi_{simu};#xi_{reco}", 100, 0., 0.30, 100, 0., 0.30); + PlotGroup() : + h_de_xi(new TH1D("", ";#xi_{reco} - #xi_{simu}", 100, 0., 0.)), + p_de_xi_vs_xi_simu(new TProfile("", ";#xi_{simu};#xi_{reco} - #xi_{simu}", 19, 0.015, 0.205)), + h_xi_reco_vs_xi_simu(new TH2D("", ";#xi_{simu};#xi_{reco}", 100, 0., 0.30, 100, 0., 0.30)), - h_de_th_x = new TH1D("", ";#theta_{x,reco} - #theta_{x,simu}", 100, 0., 0.); - p_de_th_x_vs_xi_simu = new TProfile("", ";#xi_{simu};#theta_{x,reco} - #theta_{x,simu}", 19, 0.015, 0.205); + h_de_th_x(new TH1D("", ";#theta_{x,reco} - #theta_{x,simu}", 100, 0., 0.)), + p_de_th_x_vs_xi_simu(new TProfile("", ";#xi_{simu};#theta_{x,reco} - #theta_{x,simu}", 19, 0.015, 0.205)), - h_de_th_y = new TH1D("", ";#theta_{y,reco} - #theta_{y,simu}", 100, 0., 0.); - p_de_th_y_vs_xi_simu = new TProfile("", ";#xi_{simu};#theta_{y,reco} - #theta_{y,simu}", 19, 0.015, 0.205); + h_de_th_y(new TH1D("", ";#theta_{y,reco} - #theta_{y,simu}", 100, 0., 0.)), + p_de_th_y_vs_xi_simu(new TProfile("", ";#xi_{simu};#theta_{y,reco} - #theta_{y,simu}", 19, 0.015, 0.205)), - h_de_vtx_y = new TH1D("", ";vtx_{y,reco} - vtx_{y,simu} (mm)", 100, 0., 0.); - p_de_vtx_y_vs_xi_simu = new TProfile("", ";#xi_{simu};vtx_{y,reco} - vtx_{y,simu} (mm)", 19, 0.015, 0.205); + h_de_vtx_y(new TH1D("", ";vtx_{y,reco} - vtx_{y,simu} (mm)", 100, 0., 0.)), + p_de_vtx_y_vs_xi_simu(new TProfile("", ";#xi_{simu};vtx_{y,reco} - vtx_{y,simu} (mm)", 19, 0.015, 0.205)), - h_de_t = new TH1D("", ";t_{reco} - t_{simu}", 100, -1., +1.); - p_de_t_vs_xi_simu = new TProfile("", ";xi_{simu};t_{reco} - t_{simu}", 19, 0.015, 0.205); - p_de_t_vs_t_simu = new TProfile("", ";t_{simu};t_{reco} - t_{simu}", 20, 0., 5.); - } + h_de_t(new TH1D("", ";t_{reco} - t_{simu}", 100, -1., +1.)), + p_de_t_vs_xi_simu(new TProfile("", ";xi_{simu};t_{reco} - t_{simu}", 19, 0.015, 0.205)), + p_de_t_vs_t_simu(new TProfile("", ";t_{simu};t_{reco} - t_{simu}", 20, 0., 5.)) + {} - static TGraphErrors* profileToRMSGraph(TProfile *p, const std::string &name = "") + static TGraphErrors profileToRMSGraph(TProfile *p, const char* name = "") { - TGraphErrors *g = new TGraphErrors(); - g->SetName(name.c_str()); + TGraphErrors gr_err; + gr_err.SetName(name); - for (int bi = 1; bi <= p->GetNbinsX(); ++bi) - { - double c = p->GetBinCenter(bi); - double w = p->GetBinWidth(bi); + for (int bi = 1; bi <= p->GetNbinsX(); ++bi) { + double c = p->GetBinCenter(bi); + double w = p->GetBinWidth(bi); - double N = p->GetBinEntries(bi); - double Sy = p->GetBinContent(bi) * N; - double Syy = p->GetSumw2()->At(bi); + double N = p->GetBinEntries(bi); + double Sy = p->GetBinContent(bi) * N; + double Syy = p->GetSumw2()->At(bi); - double si_sq = Syy/N - Sy*Sy/N/N; - double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; - double si_unc_sq = si_sq / 2. / N; // Gaussian approximation - double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; + double si_sq = Syy/N - Sy*Sy/N/N; + double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; + double si_unc_sq = si_sq / 2. / N; // Gaussian approximation + double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; - int idx = g->GetN(); - g->SetPoint(idx, c, si); - g->SetPointError(idx, w/2., si_unc); - } + int idx = gr_err.GetN(); + gr_err.SetPoint(idx, c, si); + gr_err.SetPointError(idx, w/2., si_unc); + } - return g; + return gr_err; } void write() const @@ -125,25 +120,25 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer h_xi_reco_vs_xi_simu->Write("h_xi_reco_vs_xi_simu"); h_de_xi->Write("h_de_xi"); p_de_xi_vs_xi_simu->Write("p_de_xi_vs_xi_simu"); - profileToRMSGraph(p_de_xi_vs_xi_simu, "g_rms_de_xi_vs_xi_simu")->Write(); + profileToRMSGraph(p_de_xi_vs_xi_simu.get(), "g_rms_de_xi_vs_xi_simu").Write(); h_de_th_x->Write("h_de_th_x"); p_de_th_x_vs_xi_simu->Write("p_de_th_x_vs_xi_simu"); - profileToRMSGraph(p_de_th_x_vs_xi_simu, "g_rms_de_th_x_vs_xi_simu")->Write(); + profileToRMSGraph(p_de_th_x_vs_xi_simu.get(), "g_rms_de_th_x_vs_xi_simu").Write(); h_de_th_y->Write("h_de_th_y"); p_de_th_y_vs_xi_simu->Write("p_de_th_y_vs_xi_simu"); - profileToRMSGraph(p_de_th_y_vs_xi_simu, "g_rms_de_th_y_vs_xi_simu")->Write(); + profileToRMSGraph(p_de_th_y_vs_xi_simu.get(), "g_rms_de_th_y_vs_xi_simu").Write(); h_de_vtx_y->Write("h_de_vtx_y"); p_de_vtx_y_vs_xi_simu->Write("p_de_vtx_y_vs_xi_simu"); - profileToRMSGraph(p_de_vtx_y_vs_xi_simu, "g_rms_de_vtx_y_vs_xi_simu")->Write(); + profileToRMSGraph(p_de_vtx_y_vs_xi_simu.get(), "g_rms_de_vtx_y_vs_xi_simu").Write(); h_de_t->Write("h_de_t"); p_de_t_vs_xi_simu->Write("p_de_t_vs_xi_simu"); - profileToRMSGraph(p_de_t_vs_xi_simu, "g_rms_de_t_vs_xi_simu")->Write(); + profileToRMSGraph(p_de_t_vs_xi_simu.get(), "g_rms_de_t_vs_xi_simu").Write(); p_de_t_vs_t_simu->Write("p_de_t_vs_t_simu"); - profileToRMSGraph(p_de_t_vs_t_simu, "g_rms_de_t_vs_t_simu")->Write(); + profileToRMSGraph(p_de_t_vs_t_simu.get(), "g_rms_de_t_vs_t_simu").Write(); } }; @@ -159,13 +154,12 @@ using namespace HepMC; //---------------------------------------------------------------------------------------------------- CTPPSProtonReconstructionSimulationValidator::CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet& iConfig) : - tokenHepMCBeforeSmearing_( consumes(iConfig.getParameter("tagHepMCBeforeSmearing")) ), - tokenHepMCAfterSmearing_( consumes(iConfig.getParameter("tagHepMCAfterSmearing")) ), - tokenRecoProtonsSingleRP_(consumes>(iConfig.getParameter("tagRecoProtonsSingleRP"))), - tokenRecoProtonsMultiRP_(consumes>(iConfig.getParameter("tagRecoProtonsMultiRP"))), + tokenHepMCBeforeSmearing_(consumes(iConfig.getParameter("tagHepMCBeforeSmearing"))), + tokenHepMCAfterSmearing_ (consumes(iConfig.getParameter("tagHepMCAfterSmearing"))), + tokenRecoProtonsSingleRP_(consumes(iConfig.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_ (consumes(iConfig.getParameter("tagRecoProtonsMultiRP"))), outputFile_(iConfig.getParameter("outputFile")) -{ -} +{} //---------------------------------------------------------------------------------------------------- @@ -184,19 +178,17 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing); HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *) hHepMCAfterSmearing->GetEvent(); - Handle> hRecoProtonsSingleRP; + Handle hRecoProtonsSingleRP; iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); - Handle> hRecoProtonsMultiRP; + Handle hRecoProtonsMultiRP; iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); // extract vertex position bool vertex_set = false; FourVector vtx; - for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) - { - if (vertex_set) - { + for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) { + if (vertex_set) { LogError("CTPPSProtonReconstructionSimulationValidator") << "Multiple vertices found."; return; } @@ -210,8 +202,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv bool proton_56_set = false; FourVector mom_45, mom_56; - for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) - { + for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) { const auto &part = *it; // accept only stable non-beam protons @@ -229,11 +220,9 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv if (mom.e() < 4500.) continue; - if (mom.z() > 0) - { + if (mom.z() > 0) { // 45 - if (proton_45_set) - { + if (proton_45_set) { LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 45."; return; } @@ -242,8 +231,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv mom_45 = mom; } else { // 56 - if (proton_56_set) - { + if (proton_56_set) { LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 56."; return; } @@ -254,10 +242,8 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv } // do comparison - for (const auto &handle : { hRecoProtonsSingleRP, hRecoProtonsMultiRP } ) - { - for (const auto &rec_pr : *handle) - { + for (const auto& handle : { hRecoProtonsSingleRP, hRecoProtonsMultiRP } ) { + for (const auto& rec_pr : *handle) { if (! rec_pr.validFit()) continue; @@ -282,8 +268,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv unsigned int meth_idx = 1234; - if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::singleRP) - { + if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::singleRP) { meth_idx = 0; CTPPSDetId rpId((*rec_pr.contributingLocalTracks().begin())->getRPId()); @@ -291,9 +276,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv } if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::multiRP) - { meth_idx = 1; - } fillPlots(meth_idx, idx, rec_pr, vtx, mom, *hLHCInfo); } @@ -319,54 +302,44 @@ void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_i const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm const double t_reco = - rec_pr.t(); - auto &p = plots_[meth_idx][idx]; - if (p.h_de_xi == nullptr) - p.init(); + auto& plt = plots_[meth_idx][idx]; - p.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco); - p.h_de_xi->Fill(xi_reco - xi_simu); - p.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu); + plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco); + plt.h_de_xi->Fill(xi_reco - xi_simu); + plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu); - p.h_de_th_x->Fill(th_x_reco - th_x_simu); - p.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu); + plt.h_de_th_x->Fill(th_x_reco - th_x_simu); + plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu); - p.h_de_th_y->Fill(th_y_reco - th_y_simu); - p.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu); + plt.h_de_th_y->Fill(th_y_reco - th_y_simu); + plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu); - p.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu); - p.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu); + plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu); + plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu); - p.h_de_t->Fill(t_reco - t_simu); - p.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu); - p.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu); + plt.h_de_t->Fill(t_reco - t_simu); + plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu); + plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu); } //---------------------------------------------------------------------------------------------------- void CTPPSProtonReconstructionSimulationValidator::endJob() { - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); - for (const auto &mit : plots_) - { - string method = (mit.first == 0) ? "single rp" : "multi rp"; - TDirectory *d_method = f_out->mkdir(method.c_str()); + for (const auto& mit : plots_) { + const char* method = (mit.first == 0) ? "single rp" : "multi rp"; + TDirectory *d_method = f_out->mkdir(method); - for (const auto &eit : mit.second) - { - char buf[20]; - sprintf(buf, "%i", eit.first); - - TDirectory *d_element = d_method->mkdir(buf); - - gDirectory = d_element; + for (const auto& eit : mit.second) { + gDirectory = d_method->mkdir(Form("%i", eit.first)); eit.second.write(); } } - - delete f_out; } //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSProtonReconstructionSimulationValidator); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 7182f0f476de4..3e5da63144319 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -21,6 +21,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" #include "TFile.h" @@ -36,45 +37,31 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> public: explicit CTPPSProtonReconstructionValidator(const edm::ParameterSet&); - ~CTPPSProtonReconstructionValidator() override {} - private: void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override; - edm::EDGetTokenT> tokenRecoProtons_; - + edm::EDGetTokenT tokenRecoProtons_; double chiSqCut_; - std::string outputFile_; - edm::ESWatcher lhcInfoWatcher_; float currentCrossingAngle_; - std::unordered_map opticalFunctions_; struct RPPlots { - TH1D *h_de_x = nullptr, *h_de_y; - - void init() - { - h_de_x = new TH1D("", ";#Deltax (mm)", 100, -2., +2.); - h_de_y = new TH1D("", ";#Deltay (mm)", 100, -2., +2.); - } - - void fill(double de_x, double de_y) - { - if (h_de_x == nullptr) - init(); + std::unique_ptr h_de_x, h_de_y; + RPPlots() : + h_de_x(new TH1D("", ";#Deltax (mm)", 100, -2., +2.)), + h_de_y(new TH1D("", ";#Deltay (mm)", 100, -2., +2.)) + {} + void fill(double de_x, double de_y) { h_de_x->Fill(de_x); h_de_y->Fill(de_y); } - void write() const - { + void write() const { h_de_x->Write("h_de_x"); h_de_y->Write("h_de_y"); } @@ -91,11 +78,10 @@ using namespace edm; //---------------------------------------------------------------------------------------------------- CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator(const edm::ParameterSet& iConfig) : - tokenRecoProtons_( consumes>(iConfig.getParameter("tagRecoProtons")) ), - chiSqCut_( iConfig.getParameter("chiSqCut") ), + tokenRecoProtons_(consumes(iConfig.getParameter("tagRecoProtons"))), + chiSqCut_ (iConfig.getParameter("chiSqCut")), outputFile_(iConfig.getParameter("outputFile")) -{ -} +{} //---------------------------------------------------------------------------------------------------- @@ -128,7 +114,7 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const return; // get input - Handle> hRecoProtons; + Handle hRecoProtons; iEvent.getByToken(tokenRecoProtons_, hRecoProtons); // process tracks @@ -167,15 +153,12 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const void CTPPSProtonReconstructionValidator::endJob() { - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); - for (const auto &p : rp_plots_) - { + for (const auto& p : rp_plots_) { gDirectory = f_out->mkdir(Form("%u", p.first)); p.second.write(); } - - delete f_out; } //---------------------------------------------------------------------------------------------------- diff --git a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc index 0e858e036e30a..15d49f8e1a544 100644 --- a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc @@ -18,6 +18,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" #include "TFile.h" #include "TH2D.h" @@ -37,31 +38,26 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> private: void analyze( const edm::Event&, const edm::EventSetup& ) override; - void endJob() override; - edm::EDGetTokenT< std::vector > tracksToken_; + edm::EDGetTokenT tracksToken_; std::string outputFile_; struct RPPlots { - TH2D *h2_y_vs_x; - TProfile *p_y_vs_x; - TH1D *h_x; + std::unique_ptr h2_y_vs_x; + std::unique_ptr p_y_vs_x; + std::unique_ptr h_x; - void init() - { - h2_y_vs_x = new TH2D("", "", 300, -10., +70., 300, -30, +30.); - p_y_vs_x = new TProfile("", "", 300, -10., +70.); - h_x = new TH1D("", "", 600, -10., +70.); - } + RPPlots() : + h2_y_vs_x(new TH2D("", "", 300, -10., +70., 300, -30, +30.)), + p_y_vs_x(new TProfile("", "", 300, -10., +70.)), + h_x(new TH1D("", "", 600, -10., +70.)) + {} void fill(double x, double y) { - if (h2_y_vs_x == nullptr) - init(); - h2_y_vs_x->Fill(x, y); p_y_vs_x->Fill(x, y); h_x->Fill(x); @@ -80,20 +76,15 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> struct ArmPlots { - TProfile2D *p2_de_x_vs_x_y; - TProfile2D *p2_de_y_vs_x_y; + std::unique_ptr p2_de_x_vs_x_y, p2_de_y_vs_x_y; - void init() - { - p2_de_x_vs_x_y = new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.); - p2_de_y_vs_x_y = new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.); - } + ArmPlots() : + p2_de_x_vs_x_y(new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.)), + p2_de_y_vs_x_y(new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.)) + {} void fill(double x_N, double y_N, double x_F, double y_F) { - if (p2_de_x_vs_x_y == nullptr) - init(); - p2_de_x_vs_x_y->Fill(x_N, y_N, x_F - x_N); p2_de_y_vs_x_y->Fill(x_N, y_N, y_F - y_N); } @@ -111,7 +102,7 @@ class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> //---------------------------------------------------------------------------------------------------- CTPPSTrackDistributionPlotter::CTPPSTrackDistributionPlotter( const edm::ParameterSet& iConfig ) : - tracksToken_( consumes< std::vector >( iConfig.getParameter( "tagTracks" ) ) ), + tracksToken_( consumes( iConfig.getParameter( "tagTracks" ) ) ), outputFile_( iConfig.getParameter("outputFile") ) { } @@ -121,23 +112,20 @@ CTPPSTrackDistributionPlotter::CTPPSTrackDistributionPlotter( const edm::Paramet void CTPPSTrackDistributionPlotter::analyze( const edm::Event& iEvent, const edm::EventSetup& ) { // get input - edm::Handle< std::vector > tracks; + edm::Handle tracks; iEvent.getByToken( tracksToken_, tracks ); // process tracks - for (const auto& trk : *tracks) - { + for (const auto& trk : *tracks) { CTPPSDetId rpId(trk.getRPId()); unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); rpPlots[rpDecId].fill(trk.getX(), trk.getY()); } - for (const auto& t1 : *tracks) - { + for (const auto& t1 : *tracks) { CTPPSDetId rpId1(t1.getRPId()); - for (const auto& t2 : *tracks) - { + for (const auto& t2 : *tracks) { CTPPSDetId rpId2(t2.getRPId()); if (rpId1.arm() != rpId2.arm()) @@ -153,16 +141,14 @@ void CTPPSTrackDistributionPlotter::analyze( const edm::Event& iEvent, const edm void CTPPSTrackDistributionPlotter::endJob() { - TFile *f_out = TFile::Open(outputFile_.c_str(), "recreate"); - - for (const auto it : rpPlots) - { + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& it : rpPlots) { gDirectory = f_out->mkdir(Form("RP %u", it.first)); it.second.write(); } - for (const auto it : armPlots) - { + for (const auto& it : armPlots) { gDirectory = f_out->mkdir(Form("arm %u", it.first)); it.second.write(); } @@ -171,3 +157,4 @@ void CTPPSTrackDistributionPlotter::endJob() //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE( CTPPSTrackDistributionPlotter ); + From 6db0b1b66ae6a3e5f9861ee49c3f702ee8ef85d9 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 08:54:18 +0100 Subject: [PATCH 167/686] Alignment constants loaded from preparation DB. --- .../python/recoCTPPS_sequences_cff.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index 40f32793df165..749963c8cea61 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -9,10 +9,19 @@ from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * -# TODO: load these data from DB -from CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * -ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring("Alignment/CTPPS/data/RPixGeometryCorrections.xml") -ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles += cms.vstring("Validation/CTPPS/test/year_2016/alignment_export_2018_12_07.1.xml") +# TODO: get this from standard DB and GT +from CondCore.CondDB.CondDB_cfi import * +CondDB.connect = 'frontier://FrontierPrep/CMS_CONDITIONS' +PoolDBESSource = cms.ESSource("PoolDBESSource", + CondDB, + DumpStat = cms.untracked.bool(False), + toGet = cms.VPSet( + cms.PSet( + record = cms.string("RPRealAlignmentRecord"), + tag = cms.string("CTPPSRPAlignmentCorrections_real_test") + ) + ) +) # TODO: load these data from DB from Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi import * From d3fd800850e3297bfb4588e9e3e6798d684842bd Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 12 Feb 2019 13:17:15 +0100 Subject: [PATCH 168/686] Unit added in comment. --- DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h index 823edeaf3f932..cf72f9664bfca 100644 --- a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h +++ b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h @@ -152,9 +152,8 @@ class CTPPSLocalTrackLite /// number of points used for fit unsigned short numberOfPointsUsedForFit; - /// time information and uncertainty + /// time information and uncertainty, ns float time, time_unc; - }; #endif From 513ba331da4fdef275ffb98a0d41e9832e19b01c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 12 Feb 2019 16:04:48 +0100 Subject: [PATCH 169/686] All inputs are checked to be valid. --- DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc index d9ddbe08eaf4b..4adf728397fd5 100644 --- a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc @@ -491,16 +491,22 @@ CTPPSDiamondDQMSource::analyze( const edm::Event& event, const edm::EventSetup& // check validity bool valid = true; valid &= diamondVFATStatus.isValid(); + valid &= pixelTracks.isValid(); valid &= diamondDigis.isValid(); valid &= fedInfo.isValid(); + valid &= diamondRecHits.isValid(); + valid &= diamondLocalTracks.isValid(); if ( !valid ) { if ( verbosity_ ) { edm::LogProblem("CTPPSDiamondDQMSource") << "ERROR in CTPPSDiamondDQMSource::analyze > some of the required inputs are not valid. Skipping this event.\n" << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n" + << " pixelTracks.isValid = " << pixelTracks.isValid() << "\n" << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n" - << " fedInfo.isValid = " << fedInfo.isValid(); + << " fedInfo.isValid = " << fedInfo.isValid() << "\n" + << " diamondRecHits.isValid = " << diamondRecHits.isValid() << "\n" + << " diamondLocalTracks.isValid = " << diamondLocalTracks.isValid(); } return; From 4e70fbdb9c10522e4edebc1dcad7d7c244e71e78 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 12 Feb 2019 16:06:30 +0100 Subject: [PATCH 170/686] Added plots for SW tests and RelVals (lite tracks and proton reco). --- DQM/CTPPS/plugins/BuildFile.xml | 3 +- DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc | 216 +++++++++++++----- DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py | 3 +- .../test/all_ctpps_dqm_test_from_aod_cfg.py | 16 +- 4 files changed, 170 insertions(+), 68 deletions(-) diff --git a/DQM/CTPPS/plugins/BuildFile.xml b/DQM/CTPPS/plugins/BuildFile.xml index fbcd2d5b145f3..7b4aefff06d87 100644 --- a/DQM/CTPPS/plugins/BuildFile.xml +++ b/DQM/CTPPS/plugins/BuildFile.xml @@ -7,11 +7,12 @@ + - + diff --git a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc index aad61d485e686..528522d6d0248 100644 --- a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc @@ -20,6 +20,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "DataFormats/OnlineMetaData/interface/CTPPSRecord.h" #include @@ -29,25 +30,30 @@ class CTPPSCommonDQMSource: public one::DQMEDAnalyzer>> { public: - CTPPSCommonDQMSource(const edm::ParameterSet& ps); - ~CTPPSCommonDQMSource() override; protected: - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override; std::shared_ptr> globalBeginLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) const override; void globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) override; + void analyzeCTPPSRecord(edm::Event const& event, edm::EventSetup const& eventSetup); + private: const unsigned int verbosity; constexpr static int MAX_LUMIS = 6000; constexpr static int MAX_VBINS = 18; - const edm::EDGetTokenT< std::vector > tokenLocalTrackLite; const edm::EDGetTokenT ctppsRecordToken; + const edm::EDGetTokenT< std::vector > tokenLocalTrackLite; + const edm::EDGetTokenT> tokenRecoProtons; + + int currentLS; + int endLS; + + std::vector rpstate; /// plots related to the whole system struct GlobalPlots @@ -69,6 +75,22 @@ class CTPPSCommonDQMSource: public one::DQMEDAnalyzer trackingRPPlots; + + struct TimingRPPlots + { + MonitorElement *h_x, *h_time; + }; + + std::map timingRPPlots; + ArmPlots(){} ArmPlots(DQMStore::IBooker &ibooker, int _id); @@ -95,6 +117,13 @@ void CTPPSCommonDQMSource::GlobalPlots::Init(DQMStore::IBooker &ibooker) events_per_bx = ibooker.book1D("events per BX", "rp;Event.BX", 4002, -1.5, 4000. + 0.5); events_per_bx_short = ibooker.book1D("events per BX (short)", "rp;Event.BX", 102, -1.5, 100. + 0.5); + /* + RP State (HV & LV & Insertion): + 0 -> not used + 1 -> bad + 2 -> warning + 3 -> ok + */ RPState = ibooker.book2D("rpstate per LS","RP State per Lumisection;Luminosity Section;",MAX_LUMIS, 0, MAX_LUMIS, MAX_VBINS, 0., MAX_VBINS); { TH2F* hist = RPState->getTH2F(); @@ -183,6 +212,40 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : xa->SetBinLabel( 5, "220, far, hor"); ya->SetBinLabel( 5, "220, far, hor"); xa->SetBinLabel( 6, "220, far, top"); ya->SetBinLabel( 6, "220, far, top"); xa->SetBinLabel( 7, "220, far, bot"); ya->SetBinLabel( 7, "220, far, bot"); + + h_proton_xi = ibooker.book1D("proton xi", title+";xi", 100, 0., 0.3); + h_proton_t = ibooker.book1D("proton t", title+";|t| GeV^{2}", 100, 0., 5.); + h_proton_time = ibooker.book1D("proton time", title+";time (ns)", 100, -25., 50.); + + for (const unsigned int &rpDecId : { 2, 3, 23 }) + { + unsigned int st = rpDecId / 10, rp = rpDecId % 10, rpFullDecId = id * 100 + rpDecId; + CTPPSDetId rpId(CTPPSDetId::sdTrackingStrip, id, st, rp); + string stName, rpName; + rpId.stationName(stName, CTPPSDetId::nShort); + rpId.rpName(rpName, CTPPSDetId::nShort); + rpName = stName + "_" + rpName; + + trackingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track y histogram", title+"/"+rpName+";track y (mm)", 200, -20., +20.) + }; + } + + for (const unsigned int &rpDecId : { 22 }) + { + unsigned int st = rpDecId / 10, rp = rpDecId % 10, rpFullDecId = id * 100 + rpDecId; + CTPPSDetId rpId(CTPPSDetId::sdTrackingStrip, id, st, rp); + string stName, rpName; + rpId.stationName(stName, CTPPSDetId::nShort); + rpId.rpName(rpName, CTPPSDetId::nShort); + rpName = stName + "_" + rpName; + + timingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track time histogram", title+"/"+rpName+";track time (ns)", 100, -25., +50.) + }; + } } //---------------------------------------------------------------------------------------------------- @@ -190,10 +253,13 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : CTPPSCommonDQMSource::CTPPSCommonDQMSource(const edm::ParameterSet& ps) : verbosity(ps.getUntrackedParameter("verbosity", 0)), - tokenLocalTrackLite{consumes< vector >(ps.getParameter("tagLocalTrackLite"))}, - ctppsRecordToken {consumes(ps.getUntrackedParameter("ctppsmetadata"))} + ctppsRecordToken(consumes(ps.getUntrackedParameter("ctppsmetadata"))), + tokenLocalTrackLite(consumes< vector >(ps.getParameter("tagLocalTrackLite"))), + tokenRecoProtons(consumes>(ps.getParameter("tagRecoProtons"))) { - + currentLS = 0; + endLS = 0; + rpstate.clear(); } //---------------------------------------------------------------------------------------------------- @@ -218,63 +284,49 @@ void CTPPSCommonDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run c //---------------------------------------------------------------------------------------------------- -void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) +void CTPPSCommonDQMSource::analyzeCTPPSRecord(edm::Event const& event, edm::EventSetup const& eventSetup) { + Handle hCTPPSRecord; + event.getByToken(ctppsRecordToken, hCTPPSRecord); - // get CTPPS Event Record - Handle rp; - event.getByToken(ctppsRecordToken, rp); - - /* - RP State (HV & LV & Insertion): - 0 -> not used - 1 -> bad - 2 -> warning - 3 -> ok - - CTPPSRecord Order: - RP name: RP_45_210_FR_BT - RP name: RP_45_210_FR_HR - RP name: RP_45_210_FR_TP - RP name: RP_45_220_C1 - RP name: RP_45_220_FR_BT - RP name: RP_45_220_FR_HR - RP name: RP_45_220_FR_TP - RP name: RP_45_220_NR_BT - RP name: RP_45_220_NR_TP - RP name: RP_56_210_FR_BT - RP name: RP_56_210_FR_HR - RP name: RP_56_210_FR_TP - RP name: RP_56_220_C1 - RP name: RP_56_220_FR_BT - RP name: RP_56_220_FR_HR - RP name: RP_56_220_FR_TP - RP name: RP_56_220_NR_BT - RP name: RP_56_220_NR_TP - */ + if (!hCTPPSRecord.isValid()) + return; auto& rpstate = *luminosityBlockCache(event.getLuminosityBlock().index()); - if(rpstate.empty()){ + if (rpstate.empty()) + { rpstate.reserve(CTPPSRecord::RomanPot::Last); - for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) { - rpstate.push_back(rp->status(i)); - } + for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) + rpstate.push_back(hCTPPSRecord->status(i)); } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) +{ + analyzeCTPPSRecord(event, eventSetup); // get event data - Handle< vector > tracks; - event.getByToken(tokenLocalTrackLite, tracks); + Handle< vector > hTracks; + event.getByToken(tokenLocalTrackLite, hTracks); + + Handle> hRecoProtons; + event.getByToken(tokenRecoProtons, hRecoProtons); // check validity bool valid = true; - valid &= tracks.isValid(); + valid &= hTracks.isValid(); + valid &= hRecoProtons.isValid(); if (!valid) { if (verbosity) { LogProblem("CTPPSCommonDQMSource") - << " trackLites.isValid = " << tracks.isValid(); + << "ERROR in CTPPSCommonDQMSource::analyze > some of the required inputs are not valid. Skipping this event.\n" + << " hTracks.isValid = " << hTracks.isValid() << "\n" + << " hRecoProtons.isValid = " << hRecoProtons.isValid(); } return; @@ -285,7 +337,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons set s_rp_idx_global_hor, s_rp_idx_global_vert; map> ms_rp_idx_arm; - for (auto &tr : *tracks) + for (auto &tr : *hTracks) { const CTPPSDetId rpId(tr.getRPId()); const unsigned int arm = rpId.arm(); @@ -300,7 +352,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons if (stRPNum == 16) idx = 2; if (idx >= 0) - s_rp_idx_global_hor.insert(3*arm + idx); + s_rp_idx_global_hor.insert(3*arm + idx); } { @@ -311,7 +363,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons if (stRPNum == 25) idx = 3; if (idx >= 0) - s_rp_idx_global_vert.insert(4*arm + idx); + s_rp_idx_global_vert.insert(4*arm + idx); } { @@ -327,7 +379,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons const signed int hor = ((rpNum == 2) || (rpNum == 3) || (rpNum == 6)) ? 1 : 0; if (idx >= 0) - ms_rp_idx_arm[arm].insert(idx * 10 + hor); + ms_rp_idx_arm[arm].insert(idx * 10 + hor); } } @@ -350,7 +402,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons map> mTop, mHor, mBot; - for (auto &tr : *tracks) + for (auto &tr : *hTracks) { CTPPSDetId rpId(tr.getRPId()); const unsigned int rpNum = rpId.rp(); @@ -362,6 +414,49 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons mHor[armIdx].insert(rpId); if (rpNum == 1 || rpNum == 5) mBot[armIdx].insert(rpId); + + auto &ap = armPlots[rpId.arm()]; + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + // fill in reference tracking-RP plots + { + auto it = ap.trackingRPPlots.find(rpDecId); + if (it != ap.trackingRPPlots.end()) + { + it->second.h_x->Fill(tr.getX()); + it->second.h_y->Fill(tr.getY()); + } + } + + // fill in reference timing-RP plots + { + auto it = ap.timingRPPlots.find(rpDecId); + if (it != ap.timingRPPlots.end()) + { + it->second.h_x->Fill(tr.getX()); + it->second.h_time->Fill(tr.getTime()); + } + } + } + + for (auto &p : *hRecoProtons) + { + if (!p.validFit()) + continue; + + signed int armIndex = -1; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector45) + armIndex = 0; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector56) + armIndex = 1; + if (armIndex < 0) + continue; + + auto &plots = armPlots[armIndex]; + + plots.h_proton_xi->Fill(p.xi()); + plots.h_proton_t->Fill(fabs(p.t())); + plots.h_proton_time->Fill(p.time()); } for (auto &p : armPlots) @@ -380,10 +475,10 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons { for (const auto &idx2 : ap.second) { - plots.h_trackCorr->Fill(idx1/10, idx2/10); + plots.h_trackCorr->Fill(idx1/10, idx2/10); - if ((idx1 % 10) != (idx2 % 10)) - plots.h_trackCorr_overlap->Fill(idx1/10, idx2/10); + if ((idx1 % 10) != (idx2 % 10)) + plots.h_trackCorr_overlap->Fill(idx1/10, idx2/10); } } } @@ -391,20 +486,21 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons } //---------------------------------------------------------------------------------------------------- -std::shared_ptr> CTPPSCommonDQMSource::globalBeginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& ) const { +std::shared_ptr> CTPPSCommonDQMSource::globalBeginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& ) const +{ return std::make_shared>(); } //---------------------------------------------------------------------------------------------------- -void CTPPSCommonDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) { - +void CTPPSCommonDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) +{ auto const& rpstate = *luminosityBlockCache(iLumi.index()); auto currentLS = iLumi.id().luminosityBlock(); - for(std::vector::size_type i=0; i::size_type i=0; isetBinContent(currentLS, i+1, rpstate[i]); - } } + //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSCommonDQMSource); diff --git a/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py b/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py index 71ed040b976ad..1e93a8d0182d0 100644 --- a/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py +++ b/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py @@ -3,7 +3,8 @@ from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer ctppsCommonDQMSource = DQMEDAnalyzer('CTPPSCommonDQMSource', - tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer'), ctppsmetadata = cms.untracked.InputTag("onlineMetaDataDigis"), + tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer'), + tagRecoProtons = cms.InputTag("ctppsProtons", "multiRP"), verbosity = cms.untracked.uint32(0), ) diff --git a/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py b/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py index ff3ae6b8dfa19..e11ff031bd276 100644 --- a/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py +++ b/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py @@ -6,8 +6,8 @@ # minimum of logs process.MessageLogger = cms.Service("MessageLogger", statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( threshold = cms.untracked.string('WARNING') ) ) @@ -26,7 +26,7 @@ process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') # raw data source process.source = cms.Source("PoolSource", @@ -40,14 +40,18 @@ input = cms.untracked.int32(-1) ) -# geometry definition -process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi") +# geometry definition and reco modules +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") # CTPPS DQM modules process.load("DQM.CTPPS.ctppsDQM_cff") process.path = cms.Path( - process.ctppsDQMElastic + process.ctppsPixelLocalReconstruction + * process.ctppsLocalTrackLiteProducer + * process.ctppsProtons + + * process.ctppsDQMElastic ) process.end_path = cms.EndPath( From fac755be33564f4f68bb0bfea435a0e6e9b9913f Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 10:05:16 +0100 Subject: [PATCH 171/686] ESProducers from CondFormats/CTPPSReadoutObjects and Validation/CTPPS moved to CalibPPS/ESProducers. --- .../ESProducers}/plugins/BuildFile.xml | 3 +-- .../ESProducers}/plugins/CTPPSAlignmentInfo.cc | 0 .../ESProducers}/plugins/CTPPSBeamParametersESSource.cc | 0 .../ESProducers}/plugins/CTPPSOpticalFunctionsESSource.cc | 0 .../ESProducers}/plugins/CTPPSPixelDAQMappingESSourceXML.cc | 0 .../plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc | 0 .../ESProducers}/plugins/PPSTimingCalibrationESSource.cc | 0 .../ESProducers}/plugins/PrintTotemDAQMapping.cc | 0 .../ESProducers}/plugins/TotemDAQMappingESSourceXML.cc | 0 .../python/CTPPSPixelDAQMappingESSourceXML_cfi.py | 0 .../python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py | 0 .../ESProducers}/python/totemDAQMappingESSourceXML_cfi.py | 0 CalibPPS/ESProducers/test/BuildFile.xml | 3 +++ .../ESProducers}/test/alignment_xml_io_test.cc | 0 .../ESProducers}/test/print_alignment_info_DB_cfg.py | 0 .../ESProducers}/test/print_alignment_info_XML_cfg.py | 2 +- .../ESProducers}/test/test_totemDAQMappingESSourceXML_cfg.py | 2 +- CondFormats/CTPPSReadoutObjects/test/BuildFile.xml | 5 +---- .../python/year_2016/ctppsOpticalFunctionsESSource_cfi.py | 2 +- 19 files changed, 8 insertions(+), 9 deletions(-) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/BuildFile.xml (71%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/CTPPSAlignmentInfo.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/CTPPSBeamParametersESSource.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/CTPPSOpticalFunctionsESSource.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/CTPPSPixelDAQMappingESSourceXML.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/PPSTimingCalibrationESSource.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/PrintTotemDAQMapping.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/plugins/TotemDAQMappingESSourceXML.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/python/CTPPSPixelDAQMappingESSourceXML_cfi.py (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/python/totemDAQMappingESSourceXML_cfi.py (100%) create mode 100644 CalibPPS/ESProducers/test/BuildFile.xml rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/test/alignment_xml_io_test.cc (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/test/print_alignment_info_DB_cfg.py (100%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/test/print_alignment_info_XML_cfg.py (92%) rename {CondFormats/CTPPSReadoutObjects => CalibPPS/ESProducers}/test/test_totemDAQMappingESSourceXML_cfg.py (92%) diff --git a/CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml b/CalibPPS/ESProducers/plugins/BuildFile.xml similarity index 71% rename from CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml rename to CalibPPS/ESProducers/plugins/BuildFile.xml index 9996ffa1f52d8..ab143e048dd66 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml +++ b/CalibPPS/ESProducers/plugins/BuildFile.xml @@ -1,9 +1,8 @@ - + - diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSAlignmentInfo.cc b/CalibPPS/ESProducers/plugins/CTPPSAlignmentInfo.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSAlignmentInfo.cc rename to CalibPPS/ESProducers/plugins/CTPPSAlignmentInfo.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSBeamParametersESSource.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc rename to CalibPPS/ESProducers/plugins/CTPPSBeamParametersESSource.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSOpticalFunctionsESSource.cc rename to CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSPixelDAQMappingESSourceXML.cc b/CalibPPS/ESProducers/plugins/CTPPSPixelDAQMappingESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSPixelDAQMappingESSourceXML.cc rename to CalibPPS/ESProducers/plugins/CTPPSPixelDAQMappingESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc b/CalibPPS/ESProducers/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc rename to CalibPPS/ESProducers/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/PPSTimingCalibrationESSource.cc b/CalibPPS/ESProducers/plugins/PPSTimingCalibrationESSource.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/PPSTimingCalibrationESSource.cc rename to CalibPPS/ESProducers/plugins/PPSTimingCalibrationESSource.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/PrintTotemDAQMapping.cc b/CalibPPS/ESProducers/plugins/PrintTotemDAQMapping.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/PrintTotemDAQMapping.cc rename to CalibPPS/ESProducers/plugins/PrintTotemDAQMapping.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc b/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc rename to CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/python/CTPPSPixelDAQMappingESSourceXML_cfi.py b/CalibPPS/ESProducers/python/CTPPSPixelDAQMappingESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/CTPPSPixelDAQMappingESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/CTPPSPixelDAQMappingESSourceXML_cfi.py diff --git a/CondFormats/CTPPSReadoutObjects/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py b/CalibPPS/ESProducers/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py diff --git a/CondFormats/CTPPSReadoutObjects/python/totemDAQMappingESSourceXML_cfi.py b/CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/totemDAQMappingESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py diff --git a/CalibPPS/ESProducers/test/BuildFile.xml b/CalibPPS/ESProducers/test/BuildFile.xml new file mode 100644 index 0000000000000..b42ccdba69631 --- /dev/null +++ b/CalibPPS/ESProducers/test/BuildFile.xml @@ -0,0 +1,3 @@ + + + diff --git a/CondFormats/CTPPSReadoutObjects/test/alignment_xml_io_test.cc b/CalibPPS/ESProducers/test/alignment_xml_io_test.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/test/alignment_xml_io_test.cc rename to CalibPPS/ESProducers/test/alignment_xml_io_test.cc diff --git a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_DB_cfg.py b/CalibPPS/ESProducers/test/print_alignment_info_DB_cfg.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/test/print_alignment_info_DB_cfg.py rename to CalibPPS/ESProducers/test/print_alignment_info_DB_cfg.py diff --git a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py b/CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py similarity index 92% rename from CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py rename to CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py index 5b3648db23537..064ab1ff60f2b 100644 --- a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py +++ b/CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py @@ -11,7 +11,7 @@ ) # load alignment corrections -process.load("CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") +process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") process.ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") process.ctppsRPAlignmentCorrectionsDataESSourceXML.MeasuredFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") process.ctppsRPAlignmentCorrectionsDataESSourceXML.MisalignedFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") diff --git a/CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py b/CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py similarity index 92% rename from CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py rename to CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py index b7b818ac446fa..f86b3ad208a02 100644 --- a/CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py +++ b/CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py @@ -20,7 +20,7 @@ ) # load a mapping -process.load("CondFormats.CTPPSReadoutObjects.totemDAQMappingESSourceXML_cfi") +process.load("CalibPPS.ESProducers.totemDAQMappingESSourceXML_cfi") process.totemDAQMappingESSourceXML.subSystem = "TrackingStrip" process.totemDAQMappingESSourceXML.configuration = cms.VPSet( cms.PSet( diff --git a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml index 68a568ffc7138..f925e58a4f741 100644 --- a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml @@ -1,10 +1,7 @@ - - - + - diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index 8229d3d0eec2a..ea29aec63d5ed 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -from CondFormats.CTPPSReadoutObjects.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _tmp +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _tmp ctppsOpticalFunctionsESSource = _tmp.clone( xangle1 = cms.double(185), From 7cbc273cef4dfcf800d0fb6d2c76e3ba1cf19b93 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 10:06:12 +0100 Subject: [PATCH 172/686] Eliminate dependence of RecoCTPPS on Validation. --- .../python/recoCTPPS_sequences_cff.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index 749963c8cea61..d0e7683fe51d2 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -24,10 +24,30 @@ ) # TODO: load these data from DB -from Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi import * +# NB: this example only works for 2016 data +ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", + validityRange = cms.EventRange("270293:min - 290872:max"), + beamEnergy = cms.double(6500), # GeV + xangle = cms.double(185) # murad +) # TODO: load these data from DB -from Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi import * +# NB: this example only works for 2016 data +import FWCore.ParameterSet.Config as cms +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp +ctppsOpticalFunctionsESSource = _optics_tmp.clone( + xangle1 = cms.double(185), + xangle2 = cms.double(185), + fileName1 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), + fileName2 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), + scoringPlanes = cms.VPSet( + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + ) +) recoCTPPSdets = cms.Sequence( totemRPLocalReconstruction * From e50e63bb04921989b371fd98b3f8ad2d3b142c30 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 15:55:27 +0100 Subject: [PATCH 173/686] Updated CondFormats related to optical functions. --- .../LHCInterpolatedOpticalFunctionsSet.h | 46 ++++++++++ ...nterpolatedOpticalFunctionsSetCollection.h | 14 +++ .../interface/LHCOpticalFunctionsCollection.h | 48 ----------- .../interface/LHCOpticalFunctionsSet.h | 38 ++------- .../LHCOpticalFunctionsSetCollection.h | 22 +++++ .../src/LHCInterpolatedOpticalFunctionsSet.cc | 36 ++++++++ .../src/LHCOpticalFunctionsCollection.cc | 21 ----- .../src/LHCOpticalFunctionsSet.cc | 85 ++----------------- ...etup_LHCInterpolatedOpticalFunctionsSet.cc | 4 + ...terpolatedOpticalFunctionsSetCollection.cc | 4 + ...Setup_LHCOpticalFunctionsSetCollection.cc} | 4 +- CondFormats/CTPPSReadoutObjects/src/classes.h | 30 ++++--- .../CTPPSReadoutObjects/src/classes_def.xml | 5 ++ CondFormats/CTPPSReadoutObjects/src/headers.h | 4 + .../DataRecord/interface/CTPPSOpticsRcd.h | 6 +- 15 files changed, 174 insertions(+), 193 deletions(-) create mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h create mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h delete mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h create mode 100644 CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h create mode 100644 CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc delete mode 100644 CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc create mode 100644 CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc create mode 100644 CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc rename CondFormats/CTPPSReadoutObjects/src/{T_EventSetup_LHCOpticalFunctionsCollection.cc => T_EventSetup_LHCOpticalFunctionsSetCollection.cc} (59%) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h new file mode 100644 index 0000000000000..3cea0a4727f5e --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h @@ -0,0 +1,46 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSet_h +#define CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSet_h + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include "TSpline.h" + +class CTPPSInterpolatedOpticalFunctionsESSource; + +/// Set of optical functions corresponding to one scoring plane along LHC, including splines for interpolation performance. +class LHCInterpolatedOpticalFunctionsSet : public LHCOpticalFunctionsSet +{ + public: + LHCInterpolatedOpticalFunctionsSet() = default; + + LHCInterpolatedOpticalFunctionsSet(const LHCOpticalFunctionsSet &src) : LHCOpticalFunctionsSet(src) {} + + ~LHCInterpolatedOpticalFunctionsSet() = default; + + const std::vector>& getSplines() const { return m_splines; } + + /// builds splines from m_*_values fields + void initializeSplines(); + + /// proton kinematics description + struct Kinematics + { + double x; // physics vertex position (beam offset subtracted), cm + double th_x; // physics scattering angle (crossing angle subtracted), rad + double y; // physics vertex position, cm + double th_y; // physics scattering angle, rad + double xi; // relative momentum loss (positive for diffractive protons) + }; + + /// transports proton according to the splines + void transport(const Kinematics &input, Kinematics &output, bool calculateAngles = false) const; + + protected: + friend CTPPSInterpolatedOpticalFunctionsESSource; + + std::vector> m_splines; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h new file mode 100644 index 0000000000000..fff9cac3fc38f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h @@ -0,0 +1,14 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSetCollection_h +#define CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSetCollection_h + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" + +#include + +class LHCInterpolatedOpticalFunctionsSetCollection : public std::unordered_map +{ +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h deleted file mode 100644 index b2a537fcda6ad..0000000000000 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsCollection_h -#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsCollection_h - -// Original Author: Jan Kašpar - -#include "CondFormats/Serialization/interface/Serializable.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" - -#include - -class CTPPSOpticalFunctionsESSource; - -/** - \brief Collection of optical functions for two crossing angle values and various scoring planes. -**/ -class LHCOpticalFunctionsCollection -{ - public: - using mapType = std::unordered_map; - - LHCOpticalFunctionsCollection() {} - - ~LHCOpticalFunctionsCollection() {} - - /// (half-)crossing-angle values in urad - double getXangle1() const { return m_xangle1; } - double getXangle2() const { return m_xangle2; } - - const mapType& getFunctions1() const { return m_functions1; } - const mapType& getFunctions2() const { return m_functions2; } - - void interpolateFunctions(double xangle, mapType &output) const; - - void setXangle1(double v) { m_xangle1 = v; } - void setXangle2(double v) { m_xangle2 = v; } - - private: - friend CTPPSOpticalFunctionsESSource; - - double m_xangle1, m_xangle2; - - /// map: RP id --> optical functions - mapType m_functions1, m_functions2; - - COND_SERIALIZABLE; -}; - -#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h index e019d3b2741f9..1b45ae179910c 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -1,62 +1,40 @@ +// Original Author: Jan Kašpar + #ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h #define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h -// Original Author: Jan Kašpar - #include "CondFormats/Serialization/interface/Serializable.h" #include #include #include -#include "TSpline.h" - /// Set of optical functions corresponding to one scoring plane along LHC. class LHCOpticalFunctionsSet { public: /// indices for m_fcn_values and m_splines data members - enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd }; + enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd, nFunctions }; LHCOpticalFunctionsSet() = default; + /// fills m_*_values fields from a ROOT file LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, double z); + ~LHCOpticalFunctionsSet() = default; /// returns the position of the scoring plane (LHC/TOTEM convention) double getScoringPlaneZ() const { return m_z; } const std::vector& getXiValues() const { return m_xi_values; } - const std::array, 16>& getFcnValues() const { return m_fcn_values; } - const std::array, 16>& getSplines() const { return m_splines; } - - /// builds splines from m_*_values fields - void initializeSplines(); - - /// proton kinematics description - struct Kinematics - { - double x; // physics vertex position (beam offset subtracted), cm - double th_x; // physics scattering angle (crossing angle subtracted), rad - double y; // physics vertex position, cm - double th_y; // physics scattering angle, rad - double xi; // relative momentum loss (positive for diffractive protons) - }; - - /// transports proton according to the splines - void transport(const Kinematics &input, Kinematics &output, bool calculateAngles = false) const; - - /// interpolates optical functions from (xangle1, of1) and (xangle2, of2) to xangle - static LHCOpticalFunctionsSet* interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, - double xangle2, const LHCOpticalFunctionsSet &of2, double xangle); + const std::vector>& getFcnValues() const { return m_fcn_values; } - private: + protected: /// position of the scoring plane, in LHC/TOTEM convention, cm double m_z; std::vector m_xi_values; - std::array, 16> m_fcn_values; ///< length unit cm - std::array, 16> m_splines; + std::vector> m_fcn_values; ///< length unit cm COND_SERIALIZABLE; }; diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h new file mode 100644 index 0000000000000..d7529cdbb85bc --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h @@ -0,0 +1,22 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSetCollection_h +#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSetCollection_h + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include +#include + +/** + \brief Collection of optical functions for two crossing angle values and various scoring planes. + * map: crossing angle --> (map: RP id --> optical functions) +**/ +class LHCOpticalFunctionsSetCollection : public std::map> +{ + private: + COND_SERIALIZABLE; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..0730ad0c7f81f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc @@ -0,0 +1,36 @@ +// Original Author: Jan Kašpar + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" + +//---------------------------------------------------------------------------------------------------- + +void LHCInterpolatedOpticalFunctionsSet::initializeSplines() +{ + const unsigned int num_xi_vals = m_xi_values.size(); + + m_splines.resize(m_fcn_values.size()); + for (unsigned int i = 0; i < m_fcn_values.size(); ++i) + m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), num_xi_vals); +} + +//---------------------------------------------------------------------------------------------------- + +void LHCInterpolatedOpticalFunctionsSet::transport(const LHCInterpolatedOpticalFunctionsSet::Kinematics &input, + LHCInterpolatedOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const +{ + const double xi = input.xi; + + output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x + + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; + + output.th_x = (!calculateAngles) ? 0. : m_splines[expd]->Eval(xi) + m_splines[evpx]->Eval(xi) * input.x + + m_splines[eLpx]->Eval(xi) * input.th_x + m_splines[e24]->Eval(xi) * input.th_y; + + output.y = m_splines[eyd]->Eval(xi) + m_splines[evy]->Eval(xi) * input.y + + m_splines[eLy]->Eval(xi) * input.th_y + m_splines[e32]->Eval(xi) * input.th_x; + + output.th_y = (!calculateAngles) ? 0. : m_splines[eypd]->Eval(xi) + m_splines[evpy]->Eval(xi) * input.y + + m_splines[eLpy]->Eval(xi) * input.th_y + m_splines[e42]->Eval(xi) * input.th_x; + + output.xi = input.xi; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc deleted file mode 100644 index 2b867bb3e0ab4..0000000000000 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsCollection.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Original Author: Jan Kašpar - -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" - -#include "FWCore/Utilities/interface/Exception.h" - -//---------------------------------------------------------------------------------------------------- - -void LHCOpticalFunctionsCollection::interpolateFunctions(double xangle, mapType &output) const -{ - for (const auto &p1 : m_functions1) - { - const auto it2 = m_functions2.find(p1.first); - if (it2 == m_functions2.end()) - throw cms::Exception("LHCOpticalFunctionsCollection") << "Mismatch between m_functions1 and m_functions2."; - - LHCOpticalFunctionsSet *fs = LHCOpticalFunctionsSet::interpolate(m_xangle1, p1.second, m_xangle2, it2->second, xangle); - - output.emplace(p1.first, *fs); - } -} diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc index 2ad20fdbada18..7d29c319a4ed6 100644 --- a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -16,8 +16,9 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons if (f_in == nullptr) throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; - std::vector graphs(m_fcn_values.size()); - for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) { + std::vector graphs(nFunctions); + for (unsigned int fi = 0; fi < nFunctions; ++fi) + { std::string tag; if (fi == evx) tag = "v_x"; else if (fi == eLx) tag = "L_x"; @@ -47,13 +48,15 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons } const unsigned int num_xi_vals = graphs[0]->GetN(); - m_xi_values.resize(num_xi_vals); - for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) + m_fcn_values.resize(nFunctions); + + for (unsigned int fi = 0; fi < nFunctions; ++fi) m_fcn_values[fi].resize(num_xi_vals); - for (unsigned int pi = 0; pi < num_xi_vals; ++pi) { + for (unsigned int pi = 0; pi < num_xi_vals; ++pi) + { const double xi = graphs[0]->GetX()[pi]; m_xi_values[pi] = xi; @@ -63,75 +66,3 @@ LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, cons delete f_in; } - -//---------------------------------------------------------------------------------------------------- - -void LHCOpticalFunctionsSet::initializeSplines() -{ - const unsigned int num_xi_vals = m_xi_values.size(); - - for (unsigned int i = 0; i < m_fcn_values.size(); ++i) - m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), num_xi_vals); -} - -//---------------------------------------------------------------------------------------------------- - -void LHCOpticalFunctionsSet::transport(const LHCOpticalFunctionsSet::Kinematics &input, - LHCOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const -{ - const double xi = input.xi; - - output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x - + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; - - output.th_x = (!calculateAngles) ? 0. : m_splines[expd]->Eval(xi) + m_splines[evpx]->Eval(xi) * input.x - + m_splines[eLpx]->Eval(xi) * input.th_x + m_splines[e24]->Eval(xi) * input.th_y; - - output.y = m_splines[eyd]->Eval(xi) + m_splines[evy]->Eval(xi) * input.y - + m_splines[eLy]->Eval(xi) * input.th_y + m_splines[e32]->Eval(xi) * input.th_x; - - output.th_y = (!calculateAngles) ? 0. : m_splines[eypd]->Eval(xi) + m_splines[evpy]->Eval(xi) * input.y - + m_splines[eLpy]->Eval(xi) * input.th_y + m_splines[e42]->Eval(xi) * input.th_x; - - output.xi = input.xi; -} - -//---------------------------------------------------------------------------------------------------- - -LHCOpticalFunctionsSet* LHCOpticalFunctionsSet::interpolate(double xangle1, const LHCOpticalFunctionsSet &of1, - double xangle2, const LHCOpticalFunctionsSet &of2, double xangle) -{ - // check whether interpolation can be done - if (std::abs(xangle1 - xangle2) < 1e-6) { - if (std::abs(xangle - xangle1) < 1e-6) - return new LHCOpticalFunctionsSet(of1); - else - throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot interpolate from angles " << xangle1 << - " and " << xangle2 << " to angle " << xangle << "."; - } - - // do interpolation - LHCOpticalFunctionsSet *output = new LHCOpticalFunctionsSet(); - - output->m_z = of1.m_z; - - const size_t num_xi_vals = of1.m_xi_values.size(); - - output->m_xi_values.resize(num_xi_vals); - - for (size_t fi = 0; fi < of1.m_fcn_values.size(); ++fi) { - output->m_fcn_values[fi].resize(num_xi_vals); - - for (size_t pi = 0; pi < num_xi_vals; ++pi) { - double xi = of1.m_xi_values[pi]; - - output->m_xi_values[pi] = xi; - - double v1 = of1.m_splines[fi]->Eval(xi); - double v2 = of2.m_splines[fi]->Eval(xi); - output->m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (xangle - xangle1); - } - } - - return output; -} diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..1a2798e54ba97 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInterpolatedOpticalFunctionsSet); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc new file mode 100644 index 0000000000000..bf10004105613 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInterpolatedOpticalFunctionsSetCollection); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc similarity index 59% rename from CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc rename to CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc index 676a4e4935605..ce0e1a898f353 100644 --- a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsCollection.cc +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc @@ -1,4 +1,4 @@ -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" #include "FWCore/Utilities/interface/typelookup.h" -TYPELOOKUP_DATA_REG(LHCOpticalFunctionsCollection); +TYPELOOKUP_DATA_REG(LHCOpticalFunctionsSetCollection); diff --git a/CondFormats/CTPPSReadoutObjects/src/classes.h b/CondFormats/CTPPSReadoutObjects/src/classes.h index b7ca13560a193..89a64917e3daa 100644 --- a/CondFormats/CTPPSReadoutObjects/src/classes.h +++ b/CondFormats/CTPPSReadoutObjects/src/classes.h @@ -1,18 +1,24 @@ #include "CondFormats/CTPPSReadoutObjects/src/headers.h" namespace CondFormats_CTPPSPixelObjects { - struct dictionary { - std::map ROCMapping; - std::map analysisMask; - std::vector< CTPPSPixelGainCalibration::DetRegistry >::iterator p3; - std::vector< CTPPSPixelGainCalibration::DetRegistry >::const_iterator p4; - std::map mycalibmap; - std::map mapType; - //--- timing calibration parameters - std::map > tc_tm; - std::map > tc_pm; - std::pair > tc_v_tm; - std::pair > tc_v_pm; + struct dictionary { + std::map ROCMapping; + std::map analysisMask; + std::vector< CTPPSPixelGainCalibration::DetRegistry >::iterator p3; + std::vector< CTPPSPixelGainCalibration::DetRegistry >::const_iterator p4; + std::map mycalibmap; + std::map mapType; + + //--- timing calibration parameters + std::map > tc_tm; + std::map > tc_pm; + std::pair > tc_v_tm; + std::pair > tc_v_pm; + + LHCOpticalFunctionsSet lhc_ofs; + LHCOpticalFunctionsSetCollection lhc_ofsc; + LHCInterpolatedOpticalFunctionsSet lhc_iofs; + LHCInterpolatedOpticalFunctionsSetCollection lhc_iofsc; }; } diff --git a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml index a0b0bf9e470b3..522f9de2cd61d 100644 --- a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml +++ b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml @@ -61,5 +61,10 @@ + + + + + diff --git a/CondFormats/CTPPSReadoutObjects/src/headers.h b/CondFormats/CTPPSReadoutObjects/src/headers.h index 24dabc52c51df..2b74cd572dc5f 100644 --- a/CondFormats/CTPPSReadoutObjects/src/headers.h +++ b/CondFormats/CTPPSReadoutObjects/src/headers.h @@ -6,3 +6,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSRPAlignmentCorrectionsDataSequence.h" #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" diff --git a/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h index 0af45405f1379..a91e7fbb021f8 100644 --- a/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h +++ b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h @@ -1,8 +1,8 @@ -#ifndef CTPPSOpticsRcd_CTPPSOpticsRcd_h -#define CTPPSOpticsRcd_CTPPSOpticsRcd_h - // Author: Jan Kašpar +#ifndef CondFormats_DataRecord_CTPPSOpticsRcd_h +#define CondFormats_DataRecord_CTPPSOpticsRcd_h + #include "FWCore/Framework/interface/EventSetupRecordImplementation.h" class CTPPSOpticsRcd : public edm::eventsetup::EventSetupRecordImplementation {}; From b662745cd8e484f647d88c7ade3cad73f7741f1c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 15:56:21 +0100 Subject: [PATCH 174/686] Updated Cond records related to optical functions. --- .../interface/CTPPSInterpolatedOpticsRcd.h | 17 +++++++++++++++++ .../src/CTPPSInterpolatedOpticsRcd.cc | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h create mode 100644 CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc diff --git a/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h b/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h new file mode 100644 index 0000000000000..b83de7df2140f --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h @@ -0,0 +1,17 @@ +// Author: Jan Kašpar + +#ifndef CondFormats_DataRecord_CTPPSInterpolatedOpticsRcd_h +#define CondFormats_DataRecord_CTPPSInterpolatedOpticsRcd_h + +#include "FWCore/Framework/interface/DependentRecordImplementation.h" + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "boost/mpl/vector.hpp" + +class CTPPSInterpolatedOpticsRcd : public edm::eventsetup::DependentRecordImplementation> +{ +}; + +#endif diff --git a/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc b/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc new file mode 100644 index 0000000000000..1baa6a2a3f466 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc @@ -0,0 +1,6 @@ +// Author: Jan Kašpar + +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSInterpolatedOpticsRcd); From 2f223caaae3c25d68e5f3934bd16f89529cbe6d5 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 15:57:14 +0100 Subject: [PATCH 175/686] Updated ESProducers related to optical functions. --- CalibPPS/ESProducers/plugins/BuildFile.xml | 1 + ...PPSInterpolatedOpticalFunctionsESSource.cc | 172 ++++++++++++++++++ .../plugins/CTPPSOpticalFunctionsESSource.cc | 59 +++--- 3 files changed, 206 insertions(+), 26 deletions(-) create mode 100644 CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc diff --git a/CalibPPS/ESProducers/plugins/BuildFile.xml b/CalibPPS/ESProducers/plugins/BuildFile.xml index ab143e048dd66..4518b0b24e320 100644 --- a/CalibPPS/ESProducers/plugins/BuildFile.xml +++ b/CalibPPS/ESProducers/plugins/BuildFile.xml @@ -5,4 +5,5 @@ + diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc new file mode 100644 index 0000000000000..f76d90356a9e6 --- /dev/null +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -0,0 +1,172 @@ +// authors: Jan Kaspar (jan.kaspar@gmail.com) + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + + +class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer +{ + public: + CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet&); + ~CTPPSInterpolatedOpticalFunctionsESSource() override {} + + std::shared_ptr produce(const CTPPSInterpolatedOpticsRcd&); + + private: + float currentCrossingAngle_; + bool currentDataValid_; + std::shared_ptr currentData_; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet& iConfig) : + currentCrossingAngle_(-1.), + currentDataValid_(false) +{ + setWhatProduced(this, &CTPPSInterpolatedOpticalFunctionsESSource::produce); +} + +//---------------------------------------------------------------------------------------------------- + +std::shared_ptr CTPPSInterpolatedOpticalFunctionsESSource::produce(const CTPPSInterpolatedOpticsRcd& iRecord) +{ + // get the input data + edm::ESHandle hOFColl; + iRecord.getRecord().get(hOFColl); + + edm::ESHandle hLHCInfo; + iRecord.getRecord().get(hLHCInfo); + + // process + if (!currentDataValid_ || hLHCInfo->crossingAngle() != currentCrossingAngle_) + { + currentCrossingAngle_ = hLHCInfo->crossingAngle(); + + if (currentCrossingAngle_ == 0.) + { + edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; + + currentDataValid_ = false; + currentData_ = std::make_shared(); + } else { + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Crossing angle has changed to " << currentCrossingAngle_ << "."; + + if (hOFColl->size() == 1) + { + // case with single-xangle input + const auto &it = hOFColl->begin(); + if (fabs(currentCrossingAngle_ - it->first) < 1e-6) + { + currentData_ = std::make_shared(); + for (const auto &rp_p : it->second) + { + const auto rpId = rp_p.first; + LHCInterpolatedOpticalFunctionsSet iof(rp_p.second); + iof.initializeSplines(); + currentData_->emplace(rpId, std::move(iof)); + } + } else { + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Cannot interpolate: input given only for xangle " + << it->first << " while interpolation requested for " << currentCrossingAngle_ << "."; + } + } else { + // case with multi-xangle input + + // find the closest xangle points for interpolation + auto it1 = hOFColl->begin(); + auto it2 = std::next(it1); + + if (currentCrossingAngle_ > it1->first) + { + for (; it1 != hOFColl->end(); ++it1) + { + it2 = std::next(it1); + + if (it2 == hOFColl->end()) + { + it2 = it1; + it1 = std::prev(it1); + break; + } + + if (it1->first <= currentCrossingAngle_ && currentCrossingAngle_ < it2->first) + break; + } + } + + const auto &xangle1 = it1->first; + const auto &xangle2 = it2->first; + + const auto &ofs1 = it1->second; + const auto &ofs2 = it2->second; + + // do the interpoaltion RP by RP + currentData_ = std::make_shared(); + for (const auto &rp_p : ofs1) + { + const auto rpId = rp_p.first; + const auto &rp_it2 = ofs2.find(rpId); + if (rp_it2 == ofs2.end()) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Mismatch between ofs1 and ofs2."; + + const auto &of1 = rp_p.second; + const auto &of2 = rp_it2->second; + + LHCInterpolatedOpticalFunctionsSet iof; + iof.m_z = of1.getScoringPlaneZ(); + + const size_t num_xi_vals = of1.getXiValues().size(); + + iof.m_xi_values.resize(num_xi_vals); + + for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) + { + iof.m_fcn_values[fi].resize(num_xi_vals); + + for (size_t pi = 0; pi < num_xi_vals; ++pi) + { + double xi = of1.getXiValues()[pi]; + double xi_control = of2.getXiValues()[pi]; + + if (fabs(xi - xi_control) > 1e-6) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Xi mismatch between ofs1 and ofs2."; + + iof.m_xi_values[pi] = xi; + + double v1 = of1.getFcnValues()[fi][pi]; + double v2 = of2.getFcnValues()[fi][pi]; + iof.m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (currentCrossingAngle_ - xangle1); + } + } + + iof.initializeSplines(); + + currentData_->emplace(rpId, std::move(iof)); + } + } + + currentDataValid_ = true; + } + } + + return currentData_; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_MODULE(CTPPSInterpolatedOpticalFunctionsESSource); diff --git a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc index 770b40fdc66ee..dca4eadfea0ad 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc @@ -8,7 +8,7 @@ #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" #include "FWCore/Framework/interface/ESProducts.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" #include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" //---------------------------------------------------------------------------------------------------- @@ -22,14 +22,18 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); ~CTPPSOpticalFunctionsESSource() override = default; - edm::ESProducts> produce(const CTPPSOpticsRcd &); + edm::ESProducts> produce(const CTPPSOpticsRcd &); static void fillDescriptions(edm::ConfigurationDescriptions&); private: void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; - double m_xangle1, m_xangle2; - std::string m_fileName1, m_fileName2; + struct FileInfo + { + double xangle; + std::string fileName; + }; + std::vector m_fileInfo; struct RPInfo { @@ -42,12 +46,15 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- -CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) : - m_xangle1(conf.getParameter("xangle1")), - m_xangle2(conf.getParameter("xangle2")), - m_fileName1(conf.getParameter("fileName1").fullPath()), - m_fileName2(conf.getParameter("fileName2").fullPath()) +CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) { + for (const auto &pset : conf.getParameter>("opticalFunctions")) + { + const double &xangle = pset.getParameter("xangle"); + const std::string &fileName = pset.getParameter("fileName").fullPath(); + m_fileInfo.push_back({xangle, fileName}); + } + for (const auto &pset : conf.getParameter>("scoringPlanes")) { const unsigned int rpId = pset.getParameter("rpId"); @@ -71,24 +78,23 @@ void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventS //---------------------------------------------------------------------------------------------------- -edm::ESProducts > +edm::ESProducts > CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) { // fill the output - auto output = std::make_unique(); + auto output = std::make_unique(); - output->m_xangle1 = m_xangle1; - output->m_xangle2 = m_xangle2; - - for (const auto &p : m_rpInfo) + for (const auto &fi : m_fileInfo) { - LHCOpticalFunctionsSet fcn1(m_fileName1, p.second.dirName, p.second.scoringPlaneZ); - fcn1.initializeSplines(); - output->m_functions1.emplace(p.first, std::move(fcn1)); + std::unordered_map xa_data; + + for (const auto &rpi : m_rpInfo) + { + LHCOpticalFunctionsSet fcn(fi.fileName, rpi.second.dirName, rpi.second.scoringPlaneZ); + xa_data.emplace(rpi.first, std::move(fcn)); + } - LHCOpticalFunctionsSet fcn2(m_fileName2, p.second.dirName, p.second.scoringPlaneZ); - fcn2.initializeSplines(); - output->m_functions2.emplace(p.first, std::move(fcn2)); + output->emplace(fi.xangle, xa_data); } // commit the output @@ -101,12 +107,13 @@ void CTPPSOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("xangle1", 185.)->setComment("half crossing angle for sector 45"); - desc.add("fileName1", edm::FileInPath())->setComment("optical functions input file for sector 45"); - desc.add("xangle2", 185.)->setComment("half crossing angle for sector 56"); - desc.add("fileName2", edm::FileInPath())->setComment("optical functions input file for sector 56"); - //--- information about scoring planes + edm::ParameterSetDescription of_desc; + of_desc.add("xangle")->setComment("half crossing angle value in urad"); + of_desc.add("fileName")->setComment("ROOT file with optical functions"); + std::vector of; + desc.addVPSet("opticalFunctions", of_desc, of)->setComment("list of optical functions at different crossing angles"); + edm::ParameterSetDescription sp_desc; sp_desc.add("rpId")->setComment("associated detector DetId"); sp_desc.add("dirName")->setComment("associated path to the optical functions file"); From e8f7757c12663357fe42b6e6fb119469cb1e4249 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 15:58:08 +0100 Subject: [PATCH 176/686] Updated EDProducers and analyzers related to optical functions. --- .../interface/ProtonReconstructionAlgorithm.h | 7 +-- .../plugins/CTPPSProtonProducer.cc | 42 ++++++------------ .../src/ProtonReconstructionAlgorithm.cc | 12 ++--- .../plugins/CTPPSDirectProtonSimulation.cc | 43 +++++------------- .../CTPPSProtonReconstructionValidator.cc | 44 +++++-------------- 5 files changed, 45 insertions(+), 103 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index bdc35b8caebac..558f8060e91a2 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -13,7 +13,8 @@ #include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" #include "TSpline.h" #include "Fit/Fitter.h" @@ -28,7 +29,7 @@ class ProtonReconstructionAlgorithm ProtonReconstructionAlgorithm(bool fit_vtx_y, bool improved_estimate, unsigned int verbosity); ~ProtonReconstructionAlgorithm() = default; - void init(const std::unordered_map &opticalFunctions); + void init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions); void release(); /// run proton reconstruction using single-RP strategy @@ -50,7 +51,7 @@ class ProtonReconstructionAlgorithm /// optics data associated with 1 RP struct RPOpticsData { - const LHCOpticalFunctionsSet *optics; + const LHCInterpolatedOpticalFunctionsSet *optics; std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; double x0; ///< beam horizontal position, cm double y0; ///< beam vertical position, cm diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 535708ed3a9aa..2f0055646e4e6 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -24,8 +24,8 @@ #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" -#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" //---------------------------------------------------------------------------------------------------- @@ -52,10 +52,7 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> ProtonReconstructionAlgorithm algorithm_; - edm::ESWatcher lhcInfoWatcher_; float currentCrossingAngle_; - - std::unordered_map opticalFunctions_; }; //---------------------------------------------------------------------------------------------------- @@ -112,32 +109,19 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe edm::ESHandle hLHCInfo; iSetup.get().get(hLHCInfo); - edm::ESHandle hOpticalFunctionCollection; - iSetup.get().get(hOpticalFunctionCollection); + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); // re-initialise algorithm upon crossing-angle change - if (lhcInfoWatcher_.check(iSetup)) { - const LHCInfo* pLHCInfo = hLHCInfo.product(); - if (pLHCInfo->crossingAngle() != currentCrossingAngle_) { - currentCrossingAngle_ = pLHCInfo->crossingAngle(); - - if (currentCrossingAngle_ == 0.) { - edm::LogWarning("CTPPSProtonProducer") << "Invalid crossing angle, reconstruction disabled."; - algorithm_.release(); - } - else { - if (verbosity_) - edm::LogInfo("CTPPSProtonProducer") << "Setting crossing angle " << currentCrossingAngle_; - - // interpolate optical functions - opticalFunctions_.clear(); - hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); - for (auto &p : opticalFunctions_) - p.second.initializeSplines(); - - // reinitialise algorithm - algorithm_.init(opticalFunctions_); - } + if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { + currentCrossingAngle_ = hLHCInfo->crossingAngle(); + + if (hOpticalFunctions->size() == 0) { + edm::LogWarning("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; + algorithm_.release(); + } + else { + algorithm_.init(*hOpticalFunctions); } } diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 9111e3107008f..607b02664bde8 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -36,7 +36,7 @@ ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, boo //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::init(const std::unordered_map &opticalFunctions) +void ProtonReconstructionAlgorithm::init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions) { // reset cache release(); @@ -44,7 +44,7 @@ void ProtonReconstructionAlgorithm::init(const std::unordered_map("", xDValues.data(), xiValues.data(), xiValues.size()); // calculate auxiliary data - LHCOpticalFunctionsSet::Kinematics k_in = { 0., 0., 0., 0., 0. }; - LHCOpticalFunctionsSet::Kinematics k_out; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; rpod.optics->transport(k_in, k_out); rpod.x0 = k_out.x; rpod.y0 = k_out.y; @@ -111,7 +111,7 @@ void ProtonReconstructionAlgorithm::release() double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const double* parameters) const { // extract proton parameters - const LHCOpticalFunctionsSet::Kinematics k_in = { 0., parameters[1], parameters[3], parameters[2], parameters[0] }; + const LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { 0., parameters[1], parameters[3], parameters[2], parameters[0] }; // calculate chi^2 by looping over hits double s2 = 0.; @@ -121,7 +121,7 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou // transport proton to the RP auto oit = m_rp_optics->find(rpId); - LHCOpticalFunctionsSet::Kinematics k_out; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; oit->second.optics->transport(k_in, k_out); // proton position wrt. beam diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index 141073e8e79b5..d96d515054499 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -25,11 +25,8 @@ #include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" -#include "CondFormats/RunInfo/interface/LHCInfo.h" -#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" - -#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" @@ -59,6 +56,7 @@ class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> void processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, std::vector &out_tracks, edm::DetSetVector& out_strip_hits, edm::DetSetVector &out_pixel_hits, @@ -110,10 +108,6 @@ class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> // ------------ internal parameters ------------ - edm::ESWatcher lhcInfoWatcher_; - - std::unordered_map opticalFunctions_; - /// internal variable: v position of strip 0, in mm double stripZeroPosition_; }; @@ -167,29 +161,15 @@ void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventS iEvent.getByToken(hepMCToken_, hepmc_prod); // get conditions - edm::ESHandle hLHCInfo; - iSetup.get().get(hLHCInfo); - edm::ESHandle hBeamParameters; iSetup.get().get(hBeamParameters); - edm::ESHandle opticalFunctionCollection; - iSetup.get().get(opticalFunctionCollection); + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); edm::ESHandle geometry; iSetup.get().get(geometry); - // prepare optical functions - if (lhcInfoWatcher_.check(iSetup)) - { - opticalFunctions_.clear(); - - opticalFunctionCollection->interpolateFunctions(hLHCInfo->crossingAngle(), opticalFunctions_); - - for (auto &p : opticalFunctions_) - p.second.initializeSplines(); - } - // prepare outputs std::unique_ptr> pStripRecHits(new edm::DetSetVector()); std::unique_ptr> pDiamondRecHits(new edm::DetSetVector()); @@ -215,7 +195,7 @@ void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventS if ( part->status() != 1 && part->status() < 83 ) continue; - processProton(vtx, part, *geometry, *hBeamParameters, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); + processProton(vtx, part, *geometry, *hBeamParameters, *hOpticalFunctions, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); } } @@ -234,6 +214,7 @@ void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventS void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, std::vector &out_tracks, edm::DetSetVector& out_strip_hits, edm::DetSetVector &out_pixel_hits, edm::DetSetVector &out_diamond_hits) const { @@ -305,7 +286,7 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, } // transport the proton into each pot/scoring plane - for (const auto &ofp : opticalFunctions_) + for (const auto &ofp : opticalFunctions) { CTPPSDetId rpId(ofp.first); const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); @@ -318,8 +299,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, ssLog << " RP " << rpDecId << std::endl; // transport proton - LHCOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x*1E-1, th_x_phys, vtx_lhc_eff_y*1E-1, th_y_phys, xi }; // conversions: mm -> cm - LHCOpticalFunctionsSet::Kinematics k_out; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x*1E-1, th_x_phys, vtx_lhc_eff_y*1E-1, th_y_phys, xi }; // conversions: mm -> cm + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; ofp.second.transport(k_in, k_out, true); double b_x = k_out.x * 1E1, b_y = k_out.y * 1E1; // conversions: cm -> mm @@ -329,8 +310,8 @@ void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, if (produceHitsRelativeToBeam_) { // determine beam position - LHCOpticalFunctionsSet::Kinematics k_be_in = { 0., 0., 0., 0., 0. }; - LHCOpticalFunctionsSet::Kinematics k_be_out; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_in = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_out; ofp.second.transport(k_be_in, k_be_out, true); a_x -= k_be_out.th_x; a_y -= k_be_out.th_y; diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 3e5da63144319..531588664a3bc 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -14,11 +14,8 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" -#include "CondFormats/RunInfo/interface/LHCInfo.h" -#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" - -#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" -#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" #include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" @@ -44,9 +41,6 @@ class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> edm::EDGetTokenT tokenRecoProtons_; double chiSqCut_; std::string outputFile_; - edm::ESWatcher lhcInfoWatcher_; - float currentCrossingAngle_; - std::unordered_map opticalFunctions_; struct RPPlots { @@ -88,29 +82,11 @@ CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator(const edm void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup) { // get conditions - edm::ESHandle hLHCInfo; - iSetup.get().get(hLHCInfo); - - edm::ESHandle hOpticalFunctionCollection; - iSetup.get().get(hOpticalFunctionCollection); - - // interpolate optical functions, if needed - if (lhcInfoWatcher_.check(iSetup)) - { - const LHCInfo* pLHCInfo = hLHCInfo.product(); - if (pLHCInfo->crossingAngle() != currentCrossingAngle_) - { - currentCrossingAngle_ = pLHCInfo->crossingAngle(); - - opticalFunctions_.clear(); - hOpticalFunctionCollection->interpolateFunctions(currentCrossingAngle_, opticalFunctions_); - for (auto &p : opticalFunctions_) - p.second.initializeSplines(); - } - } + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); // stop if conditions invalid - if (currentCrossingAngle_ <= 0.) + if (hOpticalFunctions->size() == 0) return; // get input @@ -131,14 +107,14 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const CTPPSDetId rpId(tr->getRPId()); unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); - auto it = opticalFunctions_.find(rpId); + auto it = hOpticalFunctions->find(rpId); - LHCOpticalFunctionsSet::Kinematics k_in_beam = { 0., 0., 0., 0., 0. }; - LHCOpticalFunctionsSet::Kinematics k_out_beam; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in_beam = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out_beam; it->second.transport(k_in_beam, k_out_beam); - LHCOpticalFunctionsSet::Kinematics k_in = { pr.vx() * 1E-2, -pr.thetaX(), pr.vy() * 1E-2, pr.thetaY(), pr.xi() }; // conversions: cm --> m, CMS --> LHC convention - LHCOpticalFunctionsSet::Kinematics k_out; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { -pr.vx(), -pr.thetaX(), pr.vy(), pr.thetaY(), pr.xi() }; // conversions: CMS --> LHC convention + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; it->second.transport(k_in, k_out); const double de_x = (k_out.x - k_out_beam.x) * 10. - tr->getX(); // conversions: cm --> mm From a88e210f6be2888303dcbed3e8d114790ca1b7c0 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 16:05:05 +0100 Subject: [PATCH 177/686] Updated configuration related to optical functions. --- .../Configuration/python/recoCTPPS_sequences_cff.py | 10 ++++++---- .../year_2016/ctppsOpticalFunctionsESSource_cfi.py | 12 ++++++------ .../misalignment/template_cfg.py | 2 ++ .../resolution/template_cfg.py | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index d0e7683fe51d2..2ef601ffa56e2 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -36,10 +36,10 @@ import FWCore.ParameterSet.Config as cms from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp ctppsOpticalFunctionsESSource = _optics_tmp.clone( - xangle1 = cms.double(185), - xangle2 = cms.double(185), - fileName1 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), - fileName2 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root") ) + ), + scoringPlanes = cms.VPSet( # z in cm cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 @@ -49,6 +49,8 @@ ) ) +ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + recoCTPPSdets = cms.Sequence( totemRPLocalReconstruction * ctppsDiamondLocalReconstruction * diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index ea29aec63d5ed..d6a224afa52bf 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -1,11 +1,11 @@ import FWCore.ParameterSet.Config as cms -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _tmp +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp + +ctppsOpticalFunctionsESSource = _optics_tmp.clone( + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root") ) + ), -ctppsOpticalFunctionsESSource = _tmp.clone( - xangle1 = cms.double(185), - xangle2 = cms.double(185), - fileName1 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), - fileName2 = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root"), scoringPlanes = cms.VPSet( # z in cm cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index c5ccd91228daf..a80d09bd27eb7 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -30,6 +30,8 @@ # supply optics process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index aead8625071a5..0639bedc7a32f 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -30,6 +30,8 @@ # supply optics process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), From d8372f5ee8a8b9d02128b878dde9fb371f627e90 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Feb 2019 16:28:37 +0100 Subject: [PATCH 178/686] Applied patch from code-checks. --- RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc | 2 +- Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 2f0055646e4e6..f5ec077f98b0e 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -116,7 +116,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { currentCrossingAngle_ = hLHCInfo->crossingAngle(); - if (hOpticalFunctions->size() == 0) { + if (hOpticalFunctions->empty()) { edm::LogWarning("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; algorithm_.release(); } diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc index 531588664a3bc..437c5527edb6e 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -86,7 +86,7 @@ void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const iSetup.get().get(hOpticalFunctions); // stop if conditions invalid - if (hOpticalFunctions->size() == 0) + if (hOpticalFunctions->empty()) return; // get input From 8846bbfe40d7e0011085d6bb07b10efd8b1db570 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 13 Feb 2019 18:28:20 +0100 Subject: [PATCH 179/686] Updated the optics file path according to https://github.com/cms-data/CalibPPS-ESProducers/pull/1 --- RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py | 2 +- .../CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py index 2ef601ffa56e2..cd78ae2495153 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py @@ -37,7 +37,7 @@ from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp ctppsOpticalFunctionsESSource = _optics_tmp.clone( opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root") ) + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) ), scoringPlanes = cms.VPSet( diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index d6a224afa52bf..99e7508c85b02 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -3,7 +3,7 @@ ctppsOpticalFunctionsESSource = _optics_tmp.clone( opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("RecoCTPPS/TotemRPLocal/data/optical_functions_2016.root") ) + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) ), scoringPlanes = cms.VPSet( From adf2afb1af910e6f01ef4d7e577a18d230eb60d3 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 21 Feb 2019 12:23:18 +0100 Subject: [PATCH 180/686] CTPPSLHCInfoESSource.cc moved to CalibPPS/ESProducers. --- .../ESProducers}/plugins/CTPPSLHCInfoESSource.cc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Validation/CTPPS => CalibPPS/ESProducers}/plugins/CTPPSLHCInfoESSource.cc (100%) diff --git a/Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc similarity index 100% rename from Validation/CTPPS/plugins/CTPPSLHCInfoESSource.cc rename to CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc From 57ab854382d5b390778f95480d95f92ea864c0bf Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 21 Feb 2019 12:25:38 +0100 Subject: [PATCH 181/686] Removed obsolete configs. --- .../Configuration/python/recoCTPPS_DB_cff.py | 7 --- .../Configuration/python/recoCTPPS_DD_cff.py | 9 --- .../Configuration/python/recoCTPPS_cff.py | 59 +++++++++++++++++- .../python/recoCTPPS_sequences_cff.py | 61 ------------------- 4 files changed, 57 insertions(+), 79 deletions(-) delete mode 100644 RecoCTPPS/Configuration/python/recoCTPPS_DB_cff.py delete mode 100644 RecoCTPPS/Configuration/python/recoCTPPS_DD_cff.py delete mode 100644 RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_DB_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_DB_cff.py deleted file mode 100644 index fb4d9527823d4..0000000000000 --- a/RecoCTPPS/Configuration/python/recoCTPPS_DB_cff.py +++ /dev/null @@ -1,7 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * - -from RecoCTPPS.Configuration.recoCTPPS_sequences_cff import * - -recoCTPPS = cms.Sequence(recoCTPPSdets) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_DD_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_DD_cff.py deleted file mode 100644 index 377da6b249d39..0000000000000 --- a/RecoCTPPS/Configuration/python/recoCTPPS_DD_cff.py +++ /dev/null @@ -1,9 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Geometry.VeryForwardGeometry.geometryRPFromDD_2018_cfi import * -#from Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi import * - -from RecoCTPPS.Configuration.recoCTPPS_sequences_cff import * - -recoCTPPS = cms.Sequence(recoCTPPSdets) - diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index fb4d9527823d4..bfe31f466fcf0 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -1,7 +1,62 @@ import FWCore.ParameterSet.Config as cms +from RecoCTPPS.TotemRPLocal.totemRPLocalReconstruction_cff import * +from RecoCTPPS.TotemRPLocal.ctppsDiamondLocalReconstruction_cff import * +from RecoCTPPS.TotemRPLocal.totemTimingLocalReconstruction_cff import * +from RecoCTPPS.PixelLocal.ctppsPixelLocalReconstruction_cff import * + +from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer +from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * + from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * -from RecoCTPPS.Configuration.recoCTPPS_sequences_cff import * +# TODO: get this from standard DB and GT +from CondCore.CondDB.CondDB_cfi import * +CondDB.connect = 'frontier://FrontierPrep/CMS_CONDITIONS' +ctppsAlignmentPoolDBESSource = cms.ESSource("PoolDBESSource", + CondDB, + DumpStat = cms.untracked.bool(False), + toGet = cms.VPSet( + cms.PSet( + record = cms.string("RPRealAlignmentRecord"), + tag = cms.string("CTPPSRPAlignmentCorrections_real_test") + ) + ) +) + +# TODO: load these data from DB +# NB: this example only works for 2016 data +ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", + validityRange = cms.EventRange("270293:min - 290872:max"), + beamEnergy = cms.double(6500), # GeV + xangle = cms.double(185) # murad +) + +# TODO: load these data from DB +# NB: this example only works for 2016 data +import FWCore.ParameterSet.Config as cms +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp +ctppsOpticalFunctionsESSource = _optics_tmp.clone( + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) + ), + + scoringPlanes = cms.VPSet( + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + ) +) + +ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") -recoCTPPS = cms.Sequence(recoCTPPSdets) +recoCTPPS = cms.Sequence( + totemRPLocalReconstruction * + ctppsDiamondLocalReconstruction * + totemTimingLocalReconstruction * + ctppsPixelLocalReconstruction * + ctppsLocalTrackLiteProducer * + ctppsProtons +) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py deleted file mode 100644 index cd78ae2495153..0000000000000 --- a/RecoCTPPS/Configuration/python/recoCTPPS_sequences_cff.py +++ /dev/null @@ -1,61 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from RecoCTPPS.TotemRPLocal.totemRPLocalReconstruction_cff import * -from RecoCTPPS.TotemRPLocal.ctppsDiamondLocalReconstruction_cff import * -from RecoCTPPS.TotemRPLocal.totemTimingLocalReconstruction_cff import * -from RecoCTPPS.PixelLocal.ctppsPixelLocalReconstruction_cff import * - -from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer - -from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * - -# TODO: get this from standard DB and GT -from CondCore.CondDB.CondDB_cfi import * -CondDB.connect = 'frontier://FrontierPrep/CMS_CONDITIONS' -PoolDBESSource = cms.ESSource("PoolDBESSource", - CondDB, - DumpStat = cms.untracked.bool(False), - toGet = cms.VPSet( - cms.PSet( - record = cms.string("RPRealAlignmentRecord"), - tag = cms.string("CTPPSRPAlignmentCorrections_real_test") - ) - ) -) - -# TODO: load these data from DB -# NB: this example only works for 2016 data -ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", - validityRange = cms.EventRange("270293:min - 290872:max"), - beamEnergy = cms.double(6500), # GeV - xangle = cms.double(185) # murad -) - -# TODO: load these data from DB -# NB: this example only works for 2016 data -import FWCore.ParameterSet.Config as cms -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp -ctppsOpticalFunctionsESSource = _optics_tmp.clone( - opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) - ), - - scoringPlanes = cms.VPSet( - # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 - ) -) - -ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") - -recoCTPPSdets = cms.Sequence( - totemRPLocalReconstruction * - ctppsDiamondLocalReconstruction * - totemTimingLocalReconstruction * - ctppsPixelLocalReconstruction * - ctppsLocalTrackLiteProducer * - ctppsProtons -) From d5fb6f14c47dc45fd359782557c66ac13861ac1c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 21 Feb 2019 12:26:33 +0100 Subject: [PATCH 182/686] Added ESPrefer statements. --- RecoCTPPS/Configuration/python/recoCTPPS_cff.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index bfe31f466fcf0..f66acfaa366fa 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -24,6 +24,9 @@ ) ) +# TODO: remove this line once alignment is loaded using global tag +es_prefer_ctppsAlignment = cms.ESPrefer("PoolDBESSource", "ctppsAlignmentPoolDBESSource") + # TODO: load these data from DB # NB: this example only works for 2016 data ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", @@ -32,6 +35,9 @@ xangle = cms.double(185) # murad ) +# TODO: remove this line once LHCInfo is loaded from DB +es_prefer_LHCInfo = cms.ESPrefer("CTPPSLHCInfoESSource", "ctppsLHCInfoESSource") + # TODO: load these data from DB # NB: this example only works for 2016 data import FWCore.ParameterSet.Config as cms From 4e2440115ddb0a869fab76c133065f5eda5f7b62 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 21 Feb 2019 13:08:34 +0100 Subject: [PATCH 183/686] Test configs updated. --- .../test_acceptance_cfg.py | 2 ++ .../test_smearing_effects_cfg.py | 2 ++ .../test_xy_pattern_cfg.py | 2 ++ .../test_reconstruction_cfg.py | 10 ++++++---- .../proton_reconstruction_MC/misalignment/run_multiple | 2 +- .../misalignment/template_cfg.py | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py index 47faa3cb1de61..853fc15c9c68f 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -30,6 +30,8 @@ # supply optics process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py index e69bc04ef736d..b08e8da1c01bc 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -30,6 +30,8 @@ # supply optics process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py index 09a4450b63d5e..5aff6bd7f647a 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -30,6 +30,8 @@ # supply optics process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") + # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index 6992c9ebfe7ac..bc011305742b7 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -3,6 +3,11 @@ process = cms.Process("CTPPSTestProtonReconstruction", eras.ctpps_2016) +# declare global tag +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") + # minimum of logs process.MessageLogger = cms.Service("MessageLogger", statistics = cms.untracked.vstring(), @@ -29,15 +34,12 @@ ) # load reconstruction sequences -process.load("RecoCTPPS.Configuration.recoCTPPS_sequences_cff") +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") process.ctppsLocalTrackLiteProducer.includeDiamonds = False process.ctppsLocalTrackLiteProducer.includePixels = False process.ctppsProtons.verbosity = 0 -# load geometry -process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") # 2017 is OK here - # reconstruction validator process.ctppsProtonReconstructionValidator = cms.EDAnalyzer("CTPPSProtonReconstructionValidator", tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple index a47b825e61a0d..914825a93d227 100755 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple @@ -24,7 +24,7 @@ function RunOne() ( echo "process.maxEvents.input = $events" - echo "process.ctppsIncludeAlignmentsFromXML.MisalignedFiles += cms.vstring(\"Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/$dir/$aligFile\")" + echo "process.ctppsRPAlignmentCorrectionsDataESSourceXML.MisalignedFiles += cms.vstring(\"Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/$dir/$aligFile\")" echo "process.ctppsProtonReconstructionSimulationValidator.outputFile = \"${tag}_validation.root\"" ) >> "$dir/$cfgFile" diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index a80d09bd27eb7..a302902af2f84 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -44,7 +44,7 @@ del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") -process.load("Geometry.VeryForwardGeometryBuilder.ctppsIncludeAlignmentsFromXML_cfi") +process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") # beam-smearing settings process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") From 33fbc3ea879c65797b3cb3a88424a8e31215fd88 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 22 Feb 2019 16:32:49 +0100 Subject: [PATCH 184/686] IOV for optical functions can be specified. --- .../plugins/CTPPSOpticalFunctionsESSource.cc | 53 +++++++++++++++---- .../Configuration/python/recoCTPPS_cff.py | 22 ++++---- .../ctppsOpticalFunctionsESSource_cfi.py | 2 + 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc index dca4eadfea0ad..cf1d7f4c28cc8 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc @@ -28,6 +28,9 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe private: void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + edm::EventRange m_validityRange; + bool m_insideValidityRange; + struct FileInfo { double xangle; @@ -46,7 +49,9 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- -CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) +CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) : + m_validityRange(conf.getParameter("validityRange")), + m_insideValidityRange(false) { for (const auto &pset : conf.getParameter>("opticalFunctions")) { @@ -71,9 +76,30 @@ CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::Paramete //---------------------------------------------------------------------------------------------------- void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, - const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { - oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); + if (edm::contains(m_validityRange, iosv.eventID())) + { + m_insideValidityRange = true; + oValidity = edm::ValidityInterval(edm::IOVSyncValue(m_validityRange.startEventID()), edm::IOVSyncValue(m_validityRange.endEventID())); + } else { + m_insideValidityRange = false; + + if (iosv.eventID() < m_validityRange.startEventID()) + { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID endEvent = (lb > 1) ? edm::EventID(run, lb-1, 0) : edm::EventID(run-1, edm::EventID::maxLuminosityBlockNumber(), 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(endEvent)); + } else { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber()-1) ? edm::EventID(run, lb+1, 0) : edm::EventID(run+1, 0, 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); + } + } } //---------------------------------------------------------------------------------------------------- @@ -84,17 +110,20 @@ CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) // fill the output auto output = std::make_unique(); - for (const auto &fi : m_fileInfo) + if (m_insideValidityRange) { - std::unordered_map xa_data; - - for (const auto &rpi : m_rpInfo) + for (const auto &fi : m_fileInfo) { - LHCOpticalFunctionsSet fcn(fi.fileName, rpi.second.dirName, rpi.second.scoringPlaneZ); - xa_data.emplace(rpi.first, std::move(fcn)); - } + std::unordered_map xa_data; - output->emplace(fi.xangle, xa_data); + for (const auto &rpi : m_rpInfo) + { + LHCOpticalFunctionsSet fcn(fi.fileName, rpi.second.dirName, rpi.second.scoringPlaneZ); + xa_data.emplace(rpi.first, std::move(fcn)); + } + + output->emplace(fi.xangle, xa_data); + } } // commit the output @@ -108,6 +137,8 @@ CTPPSOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions& { edm::ParameterSetDescription desc; + desc.add("validityRange", edm::EventRange())->setComment("interval of validity"); + edm::ParameterSetDescription of_desc; of_desc.add("xangle")->setComment("half crossing angle value in urad"); of_desc.add("fileName")->setComment("ROOT file with optical functions"); diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index f66acfaa366fa..adfbbb2aa737e 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -43,17 +43,19 @@ import FWCore.ParameterSet.Config as cms from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp ctppsOpticalFunctionsESSource = _optics_tmp.clone( - opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) - ), + validityRange = cms.EventRange("270293:min - 290872:max"), - scoringPlanes = cms.VPSet( - # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 - ) + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) + ), + + scoringPlanes = cms.VPSet( + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + ) ) ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py index 99e7508c85b02..95de8246f09f6 100644 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py @@ -2,6 +2,8 @@ from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp ctppsOpticalFunctionsESSource = _optics_tmp.clone( + validityRange = cms.EventRange("270293:min - 290872:max"), + opticalFunctions = cms.VPSet( cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) ), From 82678758602ccfee744d25353f9c1a589898197c Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 22 Feb 2019 16:33:28 +0100 Subject: [PATCH 185/686] IOV temporarily hard-coded with both event-id and time specifications. --- CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc index 67e53488ba02b..610530bcf9656 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc @@ -50,6 +50,14 @@ CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { + // TODO: the IOV specified in config is temporarily replaced with a hardcoded one + m_insideValidityRange = true; + + edm::IOVSyncValue beg(edm::EventID(270293, 0, 0), edm::Timestamp(1461016800ULL << 32)); + edm::IOVSyncValue end(edm::EventID(290872, 0, 0), edm::Timestamp(1483138800ULL << 32)); + oValidity = edm::ValidityInterval(beg, end); + + /* if (edm::contains(m_validityRange, iosv.eventID())) { m_insideValidityRange = true; @@ -72,6 +80,7 @@ void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecor oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); } } + */ } //---------------------------------------------------------------------------------------------------- From 023b7a10ca489b796d456721d85f753da45bf304 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 27 Feb 2019 12:20:36 +0100 Subject: [PATCH 186/686] Bug fix: no input case covered. --- ...PPSInterpolatedOpticalFunctionsESSource.cc | 183 ++++++++++-------- 1 file changed, 100 insertions(+), 83 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc index f76d90356a9e6..abefeafe3bc79 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -52,115 +52,132 @@ std::shared_ptr CTPPSInterpolatedO edm::ESHandle hLHCInfo; iRecord.getRecord().get(hLHCInfo); - // process - if (!currentDataValid_ || hLHCInfo->crossingAngle() != currentCrossingAngle_) + // is there anything to do? + if (currentDataValid_ && hLHCInfo->crossingAngle() == currentCrossingAngle_) + return currentData_; + + // is crossing angle reasonable (LHCInfo is correctly filled in DB)? + if (currentCrossingAngle_ == 0.) + { + edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; + + currentDataValid_ = false; + currentData_ = std::make_shared(); + + return currentData_; + } + + // set new crossing angle + currentCrossingAngle_ = hLHCInfo->crossingAngle(); + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Crossing angle has changed to " << currentCrossingAngle_ << "."; + + // is input optics available ? + if (hOFColl->empty()) { - currentCrossingAngle_ = hLHCInfo->crossingAngle(); + edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "No input optics available, no optical functions produced."; + + currentDataValid_ = false; + currentData_ = std::make_shared(); - if (currentCrossingAngle_ == 0.) + return currentData_; + } + + // regular case with single-xangle input + if (hOFColl->size() == 1) + { + const auto &it = hOFColl->begin(); + + // does the input xangle correspond to the actual one? + if (fabs(currentCrossingAngle_ - it->first) > 1e-6) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Cannot interpolate: input given only for xangle " + << it->first << " while interpolation requested for " << currentCrossingAngle_ << "."; + + currentData_ = std::make_shared(); + for (const auto &rp_p : it->second) { - edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; + const auto rpId = rp_p.first; + LHCInterpolatedOpticalFunctionsSet iof(rp_p.second); + iof.initializeSplines(); + currentData_->emplace(rpId, std::move(iof)); + } - currentDataValid_ = false; - currentData_ = std::make_shared(); - } else { - edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Crossing angle has changed to " << currentCrossingAngle_ << "."; + currentDataValid_ = true; + } - if (hOFColl->size() == 1) - { - // case with single-xangle input - const auto &it = hOFColl->begin(); - if (fabs(currentCrossingAngle_ - it->first) < 1e-6) - { - currentData_ = std::make_shared(); - for (const auto &rp_p : it->second) - { - const auto rpId = rp_p.first; - LHCInterpolatedOpticalFunctionsSet iof(rp_p.second); - iof.initializeSplines(); - currentData_->emplace(rpId, std::move(iof)); - } - } else { - throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Cannot interpolate: input given only for xangle " - << it->first << " while interpolation requested for " << currentCrossingAngle_ << "."; - } - } else { - // case with multi-xangle input + // regular case with multi-xangle input + if (hOFColl->size() > 1) + { + // find the closest xangle points for interpolation + auto it1 = hOFColl->begin(); + auto it2 = std::next(it1); - // find the closest xangle points for interpolation - auto it1 = hOFColl->begin(); - auto it2 = std::next(it1); + if (currentCrossingAngle_ > it1->first) + { + for (; it1 != hOFColl->end(); ++it1) + { + it2 = std::next(it1); - if (currentCrossingAngle_ > it1->first) + if (it2 == hOFColl->end()) { - for (; it1 != hOFColl->end(); ++it1) - { - it2 = std::next(it1); - - if (it2 == hOFColl->end()) - { - it2 = it1; - it1 = std::prev(it1); - break; - } - - if (it1->first <= currentCrossingAngle_ && currentCrossingAngle_ < it2->first) - break; - } + it2 = it1; + it1 = std::prev(it1); + break; } - const auto &xangle1 = it1->first; - const auto &xangle2 = it2->first; - - const auto &ofs1 = it1->second; - const auto &ofs2 = it2->second; + if (it1->first <= currentCrossingAngle_ && currentCrossingAngle_ < it2->first) + break; + } + } - // do the interpoaltion RP by RP - currentData_ = std::make_shared(); - for (const auto &rp_p : ofs1) - { - const auto rpId = rp_p.first; - const auto &rp_it2 = ofs2.find(rpId); - if (rp_it2 == ofs2.end()) - throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Mismatch between ofs1 and ofs2."; + const auto &xangle1 = it1->first; + const auto &xangle2 = it2->first; - const auto &of1 = rp_p.second; - const auto &of2 = rp_it2->second; + const auto &ofs1 = it1->second; + const auto &ofs2 = it2->second; - LHCInterpolatedOpticalFunctionsSet iof; - iof.m_z = of1.getScoringPlaneZ(); + // do the interpoaltion RP by RP + currentData_ = std::make_shared(); + for (const auto &rp_p : ofs1) + { + const auto rpId = rp_p.first; + const auto &rp_it2 = ofs2.find(rpId); + if (rp_it2 == ofs2.end()) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Mismatch between ofs1 and ofs2."; - const size_t num_xi_vals = of1.getXiValues().size(); + const auto &of1 = rp_p.second; + const auto &of2 = rp_it2->second; - iof.m_xi_values.resize(num_xi_vals); + LHCInterpolatedOpticalFunctionsSet iof; + iof.m_z = of1.getScoringPlaneZ(); - for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) - { - iof.m_fcn_values[fi].resize(num_xi_vals); + const size_t num_xi_vals = of1.getXiValues().size(); - for (size_t pi = 0; pi < num_xi_vals; ++pi) - { - double xi = of1.getXiValues()[pi]; - double xi_control = of2.getXiValues()[pi]; + iof.m_xi_values.resize(num_xi_vals); - if (fabs(xi - xi_control) > 1e-6) - throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Xi mismatch between ofs1 and ofs2."; + for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) + { + iof.m_fcn_values[fi].resize(num_xi_vals); - iof.m_xi_values[pi] = xi; + for (size_t pi = 0; pi < num_xi_vals; ++pi) + { + double xi = of1.getXiValues()[pi]; + double xi_control = of2.getXiValues()[pi]; - double v1 = of1.getFcnValues()[fi][pi]; - double v2 = of2.getFcnValues()[fi][pi]; - iof.m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (currentCrossingAngle_ - xangle1); - } - } + if (fabs(xi - xi_control) > 1e-6) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Xi mismatch between ofs1 and ofs2."; - iof.initializeSplines(); + iof.m_xi_values[pi] = xi; - currentData_->emplace(rpId, std::move(iof)); + double v1 = of1.getFcnValues()[fi][pi]; + double v2 = of2.getFcnValues()[fi][pi]; + iof.m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (currentCrossingAngle_ - xangle1); } } + iof.initializeSplines(); + currentDataValid_ = true; + currentData_->emplace(rpId, std::move(iof)); } } From 7fb7099dea324ef1c2860fa92183481ad9b0842a Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 27 Feb 2019 15:19:40 +0100 Subject: [PATCH 187/686] No access to track data when optics is not valid. --- .../ProtonReconstruction/plugins/CTPPSProtonProducer.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index f5ec077f98b0e..ed202f556a254 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -52,6 +52,7 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> ProtonReconstructionAlgorithm algorithm_; + bool opticsValid_; float currentCrossingAngle_; }; @@ -65,6 +66,7 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), multiRPReconstructionLabel_ (iConfig.getParameter("multiRPReconstructionLabel")), algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), + opticsValid_(false), currentCrossingAngle_(-1.) { if (doSingleRPReconstruction_) @@ -119,12 +121,18 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe if (hOpticalFunctions->empty()) { edm::LogWarning("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; algorithm_.release(); + opticsValid_ = false; } else { algorithm_.init(*hOpticalFunctions); + opticsValid_ = true; } } + // stop if conditions invalid + if (!opticsValid_) + return; + // prepare log std::ostringstream ssLog; if (verbosity_) From 37590de11d1276f3a653b0004d2a7a28377679a7 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Mar 2019 14:32:37 +0100 Subject: [PATCH 188/686] Produce as many plots as possible, irrespective of missing other input. --- DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc | 99 ++++++++++++++--------- 1 file changed, 61 insertions(+), 38 deletions(-) diff --git a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc index 528522d6d0248..ae22feee3adc2 100644 --- a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc @@ -40,6 +40,8 @@ class CTPPSCommonDQMSource: public one::DQMEDAnalyzer hCTPPSRecord; event.getByToken(ctppsRecordToken, hCTPPSRecord); if (!hCTPPSRecord.isValid()) + { + if (verbosity) + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeCTPPSRecord > input not available."; + return; + } auto& rpstate = *luminosityBlockCache(event.getLuminosityBlock().index()); if (rpstate.empty()) @@ -303,31 +319,17 @@ void CTPPSCommonDQMSource::analyzeCTPPSRecord(edm::Event const& event, edm::Even //---------------------------------------------------------------------------------------------------- -void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) +void CTPPSCommonDQMSource::analyzeTracks(edm::Event const& event, edm::EventSetup const& eventSetup) { - analyzeCTPPSRecord(event, eventSetup); - // get event data Handle< vector > hTracks; event.getByToken(tokenLocalTrackLite, hTracks); - Handle> hRecoProtons; - event.getByToken(tokenRecoProtons, hRecoProtons); - // check validity - bool valid = true; - valid &= hTracks.isValid(); - valid &= hRecoProtons.isValid(); - - if (!valid) + if (!hTracks.isValid()) { if (verbosity) - { - LogProblem("CTPPSCommonDQMSource") - << "ERROR in CTPPSCommonDQMSource::analyze > some of the required inputs are not valid. Skipping this event.\n" - << " hTracks.isValid = " << hTracks.isValid() << "\n" - << " hRecoProtons.isValid = " << hRecoProtons.isValid(); - } + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeTracks > input not available."; return; } @@ -439,26 +441,6 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons } } - for (auto &p : *hRecoProtons) - { - if (!p.validFit()) - continue; - - signed int armIndex = -1; - if (p.lhcSector() == reco::ForwardProton::LHCSector::sector45) - armIndex = 0; - if (p.lhcSector() == reco::ForwardProton::LHCSector::sector56) - armIndex = 1; - if (armIndex < 0) - continue; - - auto &plots = armPlots[armIndex]; - - plots.h_proton_xi->Fill(p.xi()); - plots.h_proton_t->Fill(fabs(p.t())); - plots.h_proton_time->Fill(p.time()); - } - for (auto &p : armPlots) { p.second.h_numRPWithTrack_top->Fill(mTop[p.first].size()); @@ -466,7 +448,9 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons p.second.h_numRPWithTrack_bot->Fill(mBot[p.first].size()); } - // track RP correlation + //------------------------------ + // Correlation plots + for (const auto &ap : ms_rp_idx_arm) { auto &plots = armPlots[ap.first]; @@ -482,8 +466,47 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons } } } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSCommonDQMSource::analyzeProtons(edm::Event const& event, edm::EventSetup const& eventSetup) +{ + // get event data + Handle> hRecoProtons; + event.getByToken(tokenRecoProtons, hRecoProtons); + + // check validity + if (!hRecoProtons.isValid()) + { + if (verbosity) + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeProtons > input not available."; + + return; + } + + // loop over protons + for (auto &p : *hRecoProtons) + { + if (!p.validFit()) + continue; + signed int armIndex = -1; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector45) + armIndex = 0; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector56) + armIndex = 1; + if (armIndex < 0) + continue; + + auto &plots = armPlots[armIndex]; + + plots.h_proton_xi->Fill(p.xi()); + plots.h_proton_t->Fill(fabs(p.t())); + plots.h_proton_time->Fill(p.time()); + } } + //---------------------------------------------------------------------------------------------------- std::shared_ptr> CTPPSCommonDQMSource::globalBeginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& ) const From d4ebd5e84cc4c3e7d366ad5fe0d688d7e7bc0e29 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Mar 2019 15:14:30 +0100 Subject: [PATCH 189/686] Re-added horizontal RPs in 210 station - for 2016 and 2017 reprocessing. --- DQM/CTPPS/plugins/TotemRPDQMSource.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/DQM/CTPPS/plugins/TotemRPDQMSource.cc b/DQM/CTPPS/plugins/TotemRPDQMSource.cc index be3e06f058aae..62a42b8ad6397 100644 --- a/DQM/CTPPS/plugins/TotemRPDQMSource.cc +++ b/DQM/CTPPS/plugins/TotemRPDQMSource.cc @@ -198,21 +198,20 @@ void TotemRPDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const // loop over arms for (unsigned int arm : {0, 1}) { - // loop over stations - for (unsigned int st : {0, 2}) + // loop over RPs + for (unsigned int st_rp : {2, 3, 4, 5, 24, 25}) { - // loop over RPs - for (unsigned int rp : {4, 5}) - { - TotemRPDetId rpId(arm, st, rp); - potPlots[rpId] = PotPlots(ibooker, rpId); + const unsigned int st = st_rp / 10; + const unsigned int rp = st_rp % 10; - // loop over planes - for (unsigned int pl = 0; pl < 10; ++pl) - { - TotemRPDetId plId(arm, st, rp, pl); - planePlots[plId] = PlanePlots(ibooker, plId); - } + TotemRPDetId rpId(arm, st, rp); + potPlots[rpId] = PotPlots(ibooker, rpId); + + // loop over planes + for (unsigned int pl = 0; pl < 10; ++pl) + { + TotemRPDetId plId(arm, st, rp, pl); + planePlots[plId] = PlanePlots(ibooker, plId); } } } From ce7c668ea1d584f7167de2125ee08fc11a819cc1 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Mar 2019 15:15:40 +0100 Subject: [PATCH 190/686] Fixed id of timing RP, duplicate code removed. --- DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc | 33 +++++++++-------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc index ae22feee3adc2..807323b605b03 100644 --- a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc @@ -219,7 +219,7 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : h_proton_t = ibooker.book1D("proton t", title+";|t| GeV^{2}", 100, 0., 5.); h_proton_time = ibooker.book1D("proton time", title+";time (ns)", 100, -25., 50.); - for (const unsigned int &rpDecId : { 2, 3, 23 }) + for (const unsigned int &rpDecId : { 2, 3, 16, 23 }) { unsigned int st = rpDecId / 10, rp = rpDecId % 10, rpFullDecId = id * 100 + rpDecId; CTPPSDetId rpId(CTPPSDetId::sdTrackingStrip, id, st, rp); @@ -228,25 +228,18 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : rpId.rpName(rpName, CTPPSDetId::nShort); rpName = stName + "_" + rpName; - trackingRPPlots[rpFullDecId] = { - ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), - ibooker.book1D(rpName + " - track y histogram", title+"/"+rpName+";track y (mm)", 200, -20., +20.) - }; - } - - for (const unsigned int &rpDecId : { 22 }) - { - unsigned int st = rpDecId / 10, rp = rpDecId % 10, rpFullDecId = id * 100 + rpDecId; - CTPPSDetId rpId(CTPPSDetId::sdTrackingStrip, id, st, rp); - string stName, rpName; - rpId.stationName(stName, CTPPSDetId::nShort); - rpId.rpName(rpName, CTPPSDetId::nShort); - rpName = stName + "_" + rpName; - - timingRPPlots[rpFullDecId] = { - ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), - ibooker.book1D(rpName + " - track time histogram", title+"/"+rpName+";track time (ns)", 100, -25., +50.) - }; + if (rp == 6) + { + timingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track time histogram", title+"/"+rpName+";track time (ns)", 100, -25., +50.) + }; + } else { + trackingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track y histogram", title+"/"+rpName+";track y (mm)", 200, -20., +20.) + }; + } } } From b2bbe839134894eee0fd6cc52113a2e54dec25f7 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 1 Mar 2019 16:27:56 +0100 Subject: [PATCH 191/686] Test candidate datasets for RelVals. --- .../test/all_ctpps_dqm_test_from_raw_cfg.py | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py b/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py index 52bd28b6734c3..b8e07878ee2ed 100644 --- a/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py +++ b/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py @@ -22,19 +22,29 @@ # raw data source process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - # run 274199, fill 4961, 29 May 2016 (before TS2) - #'/store/data/Run2016B/DoubleEG/RAW/v2/000/274/199/00000/04985451-9B26-E611-BEB9-02163E013859.root', - #'root://eostotem.cern.ch//eos/totem/user/j/jkaspar/04C8034A-9626-E611-9B6E-02163E011F93.root' + # reference for 2016, pre-TS2 (fill 5029) + #"/store/data/Run2016B/ZeroBias/RAW/v2/000/275/371/00000/FA67145B-8836-E611-8560-02163E012627.root", + #"/store/data/Run2016B/ZeroBias/RAW/v2/000/275/371/00000/EAD70032-8836-E611-8C11-02163E014154.root", + "/store/data/Run2016B/DoubleEG/RAW/v2/000/275/371/00000/FE9F0F13-9436-E611-8F39-02163E012B47.root", # temporarily use a staged file from a different stream - # run 283877, fill 5442, 23 Oct 2016 (after TS2) - #'/store/data/Run2016H/HLTPhysics/RAW/v1/000/283/877/00000/F28F8896-999B-E611-93D8-02163E013706.root', + # referece for 2016, post-TS2 (fill 5424) + #"/store/data/Run2016H/ZeroBias/RAW/v1/000/283/453/00000/463B84C2-C098-E611-8BC4-FA163E3201B4.root", + #"/store/data/Run2016H/ZeroBias/RAW/v1/000/283/453/00000/3204EE5B-C298-E611-BC39-02163E01448F.root", + "/store/data/Run2016H/SingleMuon/RAW/v1/000/283/453/00000/FE53CBFE-CB98-E611-A106-FA163E04425A.root", # temporarily use a staged file from a different stream - # test file for 2017 mapping (vertical RPs only) - #'root://eostotem.cern.ch//eos/totem/data/ctpps/run290874.root' + # referece for 2017, pre-TS2 (fill 6089) + "/store/data/Run2017C/ZeroBias/RAW/v1/000/301/283/00000/8ED63519-2282-E711-9073-02163E01A3C6.root", + #"/store/data/Run2017C/ZeroBias/RAW/v1/000/301/283/00000/D4508469-2282-E711-82A9-02163E01A31A.root", - # 900GeV test, 8 May 2018 - '/store/data/Run2018A/Totem1/RAW/v1/000/315/956/00000/B2AB3BFA-8D53-E811-ACFA-FA163E63AE40.root' + # referece for 2017, post-TS2 (fill 6300) + "/store/data/Run2017F/ZeroBias/RAW/v1/000/305/081/00000/001D08EE-C4B1-E711-B92D-02163E013864.root", + #"/store/data/Run2017F/ZeroBias/RAW/v1/000/305/081/00000/44B0284D-C3B1-E711-BECF-02163E014357.root", + + # referece for 2018 (fill 7006) + "/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/601A721D-AD95-E811-B21A-FA163E28A50A.root", + #"/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/EE97DF44-AD95-E811-A444-02163E019FF7.root", ), + inputCommands = cms.untracked.vstring( 'drop *', 'keep FEDRawDataCollection_*_*_*' @@ -42,7 +52,7 @@ ) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(8000) + input = cms.untracked.int32(-1) ) # global tag - conditions for P5 cluster @@ -52,7 +62,7 @@ process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") # local RP reconstruction chain with standard settings -process.load("RecoCTPPS.Configuration.recoCTPPS_DD_cff") +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") # CTPPS DQM modules process.load("DQM.CTPPS.ctppsDQM_cff") From c23ea5618c4492947c1c76e9a85860c5907f5612 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 5 Mar 2019 00:45:20 +0900 Subject: [PATCH 192/686] remove commented out code --- .../GEMRawToDigi/interface/AMC13Event.h | 12 ++++-------- EventFilter/GEMRawToDigi/interface/AMCdata.h | 18 ------------------ EventFilter/GEMRawToDigi/interface/GEBdata.h | 9 ++------- EventFilter/GEMRawToDigi/interface/VFATdata.h | 9 +++------ .../GEMRawToDigi/plugins/GEMDigiToRawModule.cc | 8 ++++---- .../GEMRawToDigi/plugins/GEMRawToDigiModule.cc | 8 ++++---- .../GEMRawToDigi/src/GEMVfatStatusDigi.cc | 10 +++++----- 7 files changed, 22 insertions(+), 52 deletions(-) diff --git a/EventFilter/GEMRawToDigi/interface/AMC13Event.h b/EventFilter/GEMRawToDigi/interface/AMC13Event.h index c387ffd160743..124ba132a0296 100644 --- a/EventFilter/GEMRawToDigi/interface/AMC13Event.h +++ b/EventFilter/GEMRawToDigi/interface/AMC13Event.h @@ -84,20 +84,16 @@ namespace gem { void addAMCpayload(const AMCdata& a) {amcs_.push_back(a);} private: - uint64_t cdfh_; - uint64_t amc13h_; - uint64_t amc13t_; - uint64_t cdft_; + uint64_t cdfh_; // CDFHeader + uint64_t amc13h_; // AMC13Header + uint64_t amc13t_; // AMC13Trailer + uint64_t cdft_; // CDFTrailer // AMC headers std::vector amcHeaders_; // AMCs payload std::vector amcs_; - /* CDFHeader cdfh_; */ - /* AMC13Header amc13h_; */ - /* AMC13Trailer amc13t_; */ - /* CDFTrailer cdft_; */ }; } #endif diff --git a/EventFilter/GEMRawToDigi/interface/AMCdata.h b/EventFilter/GEMRawToDigi/interface/AMCdata.h index 6b6cecbc97fe7..6cf23d224995f 100644 --- a/EventFilter/GEMRawToDigi/interface/AMCdata.h +++ b/EventFilter/GEMRawToDigi/interface/AMCdata.h @@ -97,19 +97,6 @@ namespace gem { uint8_t oosGlib() const {return EventTrailer{et_}.oosGlib;} uint32_t chTimeOut() const {return EventTrailer{et_}.chTimeOut;} - - - /* void setdataLength(uint64_t n) {amch1_.dataLength = n;} */ - /* void setbx(uint64_t n) {amch1_.bxID = n;} */ - /* void setl1A(uint64_t n) {amch1_.l1AID = n;} */ - /* void setamcNum(uint64_t n) {amch1_.AMCnum = n;} */ - - /* void setboardId(uint64_t n) {amch2_.boardID = n;} */ - /* void setorbitNum(uint64_t n) {amch2_.orbitNum = n;} */ - /* void setrunType(uint64_t n) {amch2_.runType = n;} */ - - /* void setdavCnt(uint64_t n) {eh_.davCnt = n;} */ - /* void setdavList(uint64_t n) {eh_.davList = n;} */ //!Adds GEB data to vector void addGEB(GEBdata g) {gebd_.push_back(g);} @@ -117,11 +104,6 @@ namespace gem { const std::vector * gebs() const {return &gebd_;} private: - /* AMCheader1 amch1_; */ - /* AMCheader2 amch2_; */ - /* AMCTrailer amct_; */ - /* EventHeader eh_; */ - /* EventTrailer et_; */ uint64_t amch1_; uint64_t amch2_; diff --git a/EventFilter/GEMRawToDigi/interface/GEBdata.h b/EventFilter/GEMRawToDigi/interface/GEBdata.h index f57ea2e824e12..6dc8fd0d82ce2 100644 --- a/EventFilter/GEMRawToDigi/interface/GEBdata.h +++ b/EventFilter/GEMRawToDigi/interface/GEBdata.h @@ -71,9 +71,6 @@ namespace gem { uint16_t vfatWordCntT() const {return GEBchamberTrailer{ct_}.vfatWordCntT;} uint16_t ohcrc() const {return GEBchamberTrailer{ct_}.ohcrc;} - /* void setVfatWordCnt(uint16_t n) {ch_.vfatWordCnt = n; ct_.vfatWordCntT = n;} */ - /* void setInputID(uint8_t n) {ch_.inputID = n;} */ - //!Adds VFAT data to the vector void addVFAT(VFATdata v) {vfatd_.push_back(v);} //!Returns the vector of FVAT data @@ -82,10 +79,8 @@ namespace gem { static const int sizeGebID = 5; private: - /* GEBchamberHeader ch_; */ - /* GEBchamberTrailer ct_; */ - uint64_t ch_; - uint64_t ct_; + uint64_t ch_; // GEBchamberHeader + uint64_t ct_; // GEBchamberTrailer std::vector vfatd_; }; diff --git a/EventFilter/GEMRawToDigi/interface/VFATdata.h b/EventFilter/GEMRawToDigi/interface/VFATdata.h index 339e82485cbf5..3662468ee6f12 100644 --- a/EventFilter/GEMRawToDigi/interface/VFATdata.h +++ b/EventFilter/GEMRawToDigi/interface/VFATdata.h @@ -122,12 +122,9 @@ namespace gem { int ver_; /// vfat version int phiPos_; /// phi position of vfat in chamber - /* VFATfirst fw_; */ - /* VFATsecond sw_; */ - /* VFATthird tw_; */ - uint64_t fw_; - uint64_t sw_; - uint64_t tw_; + uint64_t fw_; // VFAT first word + uint64_t sw_; // VFAT second word + uint64_t tw_; // VFAT third word }; } #endif diff --git a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc index 2e8c654e98096..c48cf85eb36dc 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc @@ -39,21 +39,21 @@ void GEMDigiToRawModule::fillDescriptions(edm::ConfigurationDescriptions & descr std::shared_ptr GEMDigiToRawModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); + auto gemROmap = std::make_shared(); if (useDBEMap_) { edm::ESHandle gemEMapRcd; iSetup.get().get(gemEMapRcd); auto gemEMap = std::make_unique(*(gemEMapRcd.product())); - gemEMap->convert(*gemORmap); + gemEMap->convert(*gemROmap); gemEMap.reset(); } else { // no EMap in DB, using dummy auto gemEMap = std::make_unique(); - gemEMap->convertDummy(*gemORmap); + gemEMap->convertDummy(*gemROmap); gemEMap.reset(); } - return gemORmap; + return gemROmap; } void GEMDigiToRawModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::EventSetup const&) const diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc index 5eb619f360800..9bbf7ace01c02 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc @@ -41,21 +41,21 @@ void GEMRawToDigiModule::fillDescriptions(edm::ConfigurationDescriptions & descr std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); + auto gemROmap = std::make_shared(); if (useDBEMap_) { edm::ESHandle gemEMapRcd; iSetup.get().get(gemEMapRcd); auto gemEMap = std::make_unique(*(gemEMapRcd.product())); - gemEMap->convert(*gemORmap); + gemEMap->convert(*gemROmap); gemEMap.reset(); } else { // no EMap in DB, using dummy auto gemEMap = std::make_unique(); - gemEMap->convertDummy(*gemORmap); + gemEMap->convertDummy(*gemROmap); gemEMap.reset(); } - return gemORmap; + return gemROmap; } void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::EventSetup const&) const diff --git a/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc index f530ce2be7ecf..b2cedacc205d4 100644 --- a/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc +++ b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc @@ -3,9 +3,9 @@ GEMVfatStatusDigi::GEMVfatStatusDigi(gem::VFATdata &vfat) { - quality_ = vfat.quality(); - flag_ = vfat.flag(); - phi_ = vfat.phi(); - ec_ = vfat.ec(); - bc_ = vfat.bc(); + quality_ = vfat.quality(); + flag_ = vfat.flag(); + phi_ = vfat.phi(); + ec_ = vfat.ec(); + bc_ = vfat.bc(); }; From 411a1a39022051bb0089a363e56c521a0770ea03 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 28 Feb 2019 16:18:44 +0100 Subject: [PATCH 193/686] update heavy Ion data promptlike GT; add GEM emap for MC GTs; use autoCond GT instead of hardcoded prompt GT for heavy Ion data relval --- Configuration/AlCa/python/autoCond.py | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 2d1855f0ba053..4714e35641d88 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -33,7 +33,7 @@ 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v5', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v6', - 'run2_data_promptlike_hi' : '103X_dataRun2_PromptLike_HI_v2', + 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v1', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v6', # GlobalTag for Run2 HLT: it points to the online GT @@ -44,31 +44,31 @@ # GlobalTag for Run2 HLT for HI: it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v7', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v3', + 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v4', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '105X_mc2017_realistic_v4', + 'phase1_2017_realistic' : '105X_mc2017_realistic_v5', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v4', + 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v5', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v5', + 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v6', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '105X_upgrade2018_design_v2', + 'phase1_2018_design' : '105X_upgrade2018_design_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v2', + 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '103X_upgrade2018_realistic_HI_v12', + 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v3', + 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v4', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v3', + 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v4', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v3', + 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v4', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '105X_postLS2_design_v1', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '105X_postLS2_design_v2', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '105X_postLS2_realistic_v3', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '105X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_v2' + 'phase2_realistic' : '105X_upgrade2023_realistic_3' } aliases = { From 841ba372232c65c4606286918562bc7347e08d58 Mon Sep 17 00:00:00 2001 From: tocheng Date: Fri, 1 Mar 2019 22:53:03 +0100 Subject: [PATCH 194/686] update 2016/2018 ECAL MC conditions for UL --- Configuration/AlCa/python/autoCond.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 4714e35641d88..d8983fc488d39 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -16,9 +16,9 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 'run2_design' : '105X_mcRun2_design_v1', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '105X_mcRun2_asymptotic_v1', + 'run2_mc' : '105X_mcRun2_asymptotic_v2', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v1', + 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v2', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 'run2_mc_hi' : '103X_mcRun2_HeavyIon_v3', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 @@ -54,15 +54,15 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) 'phase1_2018_design' : '105X_upgrade2018_design_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v3', + 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v4', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v1', + 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v4', + 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v5', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v4', + 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v5', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v4', + 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v5', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 'phase1_2019_design' : '105X_postLS2_design_v2', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 From b48e379bf77d518f0cf9c7458a8f88e09671eb34 Mon Sep 17 00:00:00 2001 From: tocheng Date: Fri, 1 Mar 2019 23:00:04 +0100 Subject: [PATCH 195/686] Fix typo in GT name --- Configuration/AlCa/python/autoCond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index d8983fc488d39..f11ec8190bea0 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -68,7 +68,7 @@ # GlobalTag for MC production with realistic conditions for Phase1 2019 'phase1_2019_realistic' : '105X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_3' + 'phase2_realistic' : '105X_upgrade2023_realistic_v3' } aliases = { From 1222eb57ed8749d7c616dbffb68b352aca2a8dd5 Mon Sep 17 00:00:00 2001 From: tocheng Date: Sat, 2 Mar 2019 00:12:12 +0100 Subject: [PATCH 196/686] Add new MC GEM emap to 2017 cosmic deco mode GT --- Configuration/AlCa/python/autoCond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index f11ec8190bea0..b1fe03ca9786e 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -48,7 +48,7 @@ # GlobalTag for MC production with realistic conditions for Phase1 2017 detector 'phase1_2017_realistic' : '105X_mc2017_realistic_v5', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v5', + 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v6', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v6', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) From 06175939444740d993c0f6085dcb1fb72bc58d28 Mon Sep 17 00:00:00 2001 From: tocheng Date: Sun, 3 Mar 2019 02:34:02 +0100 Subject: [PATCH 197/686] update PF calibration in offline and MC GTs --- Configuration/AlCa/python/autoCond.py | 60 +++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index b1fe03ca9786e..d965cb2881845 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -2,38 +2,38 @@ ### NEW KEYS ### # GlobalTag for MC production with perfectly aligned and calibrated detector for Run1 - 'run1_design' : '103X_mcRun1_design_v1', + 'run1_design' : '105X_mcRun1_design_v1', # GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1 - 'run1_mc' : '103X_mcRun1_realistic_v1', + 'run1_mc' : '105X_mcRun1_realistic_v1', # GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_hi' : '103X_mcRun1_HeavyIon_v1', + 'run1_mc_hi' : '105X_mcRun1_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_pa' : '103X_mcRun1_pA_v1', + 'run1_mc_pa' : '105X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '103X_mcRun2_startup_v3', + 'run2_mc_50ns' : '105X_mcRun2_startup_v1', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '103X_mcRun2_asymptotic_l1stage1_v1', + 'run2_mc_l1stage1' : '105X_mcRun2_asymptotic_l1stage1_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '105X_mcRun2_design_v1', + 'run2_design' : '105X_mcRun2_design_v2', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '105X_mcRun2_asymptotic_v2', + 'run2_mc' : '105X_mcRun2_asymptotic_v3', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v2', + 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v3', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '103X_mcRun2_HeavyIon_v3', + 'run2_mc_hi' : '105X_mcRun2_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '103X_mcRun2_pA_v3', + 'run2_mc_pa' : '105X_mcRun2_pA_v1', # GlobalTag for Run1 data reprocessing - 'run1_data' : '105X_dataRun2_v6', + 'run1_data' : '105X_dataRun2_v7', # GlobalTag for Run2 data reprocessing - 'run2_data' : '105X_dataRun2_v6', + 'run2_data' : '105X_dataRun2_v7', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '105X_dataRun2_relval_v6', + 'run2_data_relval' : '105X_dataRun2_relval_v7', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v5', + 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v6', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v6', - 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v1', + 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v7', + 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v2', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v6', # GlobalTag for Run2 HLT: it points to the online GT @@ -44,31 +44,31 @@ # GlobalTag for Run2 HLT for HI: it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v7', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v4', + 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v5', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '105X_mc2017_realistic_v5', + 'phase1_2017_realistic' : '105X_mc2017_realistic_v6', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v6', + 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v7', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v6', + 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v7', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '105X_upgrade2018_design_v3', + 'phase1_2018_design' : '105X_upgrade2018_design_v4', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v4', + 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v5', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v2', + 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v5', + 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v6', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v5', + 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v6', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v5', + 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v6', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '105X_postLS2_design_v2', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '105X_postLS2_design_v3', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '105X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '105X_postLS2_realistic_v5', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_v3' + 'phase2_realistic' : '105X_upgrade2023_realistic_v4' } aliases = { From 469d5e1e472d578148383e5874a78104a50b30a6 Mon Sep 17 00:00:00 2001 From: tocheng Date: Tue, 5 Mar 2019 17:13:27 +0100 Subject: [PATCH 198/686] Revert "update PF calibration in offline and MC GTs" This reverts commit f689a3021224fed7ea611533dca6fe0064d4c03d. --- Configuration/AlCa/python/autoCond.py | 60 +++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index d965cb2881845..b1fe03ca9786e 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -2,38 +2,38 @@ ### NEW KEYS ### # GlobalTag for MC production with perfectly aligned and calibrated detector for Run1 - 'run1_design' : '105X_mcRun1_design_v1', + 'run1_design' : '103X_mcRun1_design_v1', # GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1 - 'run1_mc' : '105X_mcRun1_realistic_v1', + 'run1_mc' : '103X_mcRun1_realistic_v1', # GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_hi' : '105X_mcRun1_HeavyIon_v1', + 'run1_mc_hi' : '103X_mcRun1_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_pa' : '105X_mcRun1_pA_v1', + 'run1_mc_pa' : '103X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '105X_mcRun2_startup_v1', + 'run2_mc_50ns' : '103X_mcRun2_startup_v3', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '105X_mcRun2_asymptotic_l1stage1_v1', + 'run2_mc_l1stage1' : '103X_mcRun2_asymptotic_l1stage1_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '105X_mcRun2_design_v2', + 'run2_design' : '105X_mcRun2_design_v1', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '105X_mcRun2_asymptotic_v3', + 'run2_mc' : '105X_mcRun2_asymptotic_v2', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v3', + 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v2', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '105X_mcRun2_HeavyIon_v1', + 'run2_mc_hi' : '103X_mcRun2_HeavyIon_v3', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '105X_mcRun2_pA_v1', + 'run2_mc_pa' : '103X_mcRun2_pA_v3', # GlobalTag for Run1 data reprocessing - 'run1_data' : '105X_dataRun2_v7', + 'run1_data' : '105X_dataRun2_v6', # GlobalTag for Run2 data reprocessing - 'run2_data' : '105X_dataRun2_v7', + 'run2_data' : '105X_dataRun2_v6', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '105X_dataRun2_relval_v7', + 'run2_data_relval' : '105X_dataRun2_relval_v6', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v6', + 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v5', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v7', - 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v2', + 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v6', + 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v1', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v6', # GlobalTag for Run2 HLT: it points to the online GT @@ -44,31 +44,31 @@ # GlobalTag for Run2 HLT for HI: it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v7', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v5', + 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v4', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '105X_mc2017_realistic_v6', + 'phase1_2017_realistic' : '105X_mc2017_realistic_v5', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v7', + 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v6', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v7', + 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v6', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '105X_upgrade2018_design_v4', + 'phase1_2018_design' : '105X_upgrade2018_design_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v5', + 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v4', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v3', + 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v6', + 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v5', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v6', + 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v5', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v6', + 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v5', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '105X_postLS2_design_v3', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '105X_postLS2_design_v2', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '105X_postLS2_realistic_v5', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '105X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_v4' + 'phase2_realistic' : '105X_upgrade2023_realistic_v3' } aliases = { From 0662a2391cbdf65226cb1e777c11e5635839515e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 11:54:21 +0100 Subject: [PATCH 199/686] Test config uses GT with alignment, alignment specification removed from main reco config. --- RecoCTPPS/Configuration/python/recoCTPPS_cff.py | 17 ----------------- .../test_reconstruction_cfg.py | 3 ++- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index adfbbb2aa737e..0d81fbdfa21f6 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -10,23 +10,6 @@ from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * -# TODO: get this from standard DB and GT -from CondCore.CondDB.CondDB_cfi import * -CondDB.connect = 'frontier://FrontierPrep/CMS_CONDITIONS' -ctppsAlignmentPoolDBESSource = cms.ESSource("PoolDBESSource", - CondDB, - DumpStat = cms.untracked.bool(False), - toGet = cms.VPSet( - cms.PSet( - record = cms.string("RPRealAlignmentRecord"), - tag = cms.string("CTPPSRPAlignmentCorrections_real_test") - ) - ) -) - -# TODO: remove this line once alignment is loaded using global tag -es_prefer_ctppsAlignment = cms.ESPrefer("PoolDBESSource", "ctppsAlignmentPoolDBESSource") - # TODO: load these data from DB # NB: this example only works for 2016 data ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index bc011305742b7..d0030fe982eed 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -6,7 +6,8 @@ # declare global tag process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") +process.GlobalTag = GlobalTag(process.GlobalTag, "105X_dataRun2_relval_v2") +#process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") # minimum of logs process.MessageLogger = cms.Service("MessageLogger", From c7f1a2d7579b990c04f26464419923edccec5067 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 12:44:05 +0100 Subject: [PATCH 200/686] Added labels to LHCInfo data. --- ...PPSInterpolatedOpticalFunctionsESSource.cc | 5 ++++- .../plugins/CTPPSLHCInfoESSource.cc | 5 ++++- .../plugins/CTPPSProtonProducer.cc | 21 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc index abefeafe3bc79..f3c7b98b97bea 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -26,6 +26,8 @@ class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer std::shared_ptr produce(const CTPPSInterpolatedOpticsRcd&); private: + std::string lhcInfoLabel_; + float currentCrossingAngle_; bool currentDataValid_; std::shared_ptr currentData_; @@ -35,6 +37,7 @@ class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer //---------------------------------------------------------------------------------------------------- CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet& iConfig) : + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), currentCrossingAngle_(-1.), currentDataValid_(false) { @@ -50,7 +53,7 @@ std::shared_ptr CTPPSInterpolatedO iRecord.getRecord().get(hOFColl); edm::ESHandle hLHCInfo; - iRecord.getRecord().get(hLHCInfo); + iRecord.getRecord().get(lhcInfoLabel_, hLHCInfo); // is there anything to do? if (currentDataValid_ && hLHCInfo->crossingAngle() == currentCrossingAngle_) diff --git a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc index 610530bcf9656..4898db7933e78 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc @@ -25,6 +25,8 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord private: void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + std::string m_label; + edm::EventRange m_validityRange; double m_beamEnergy; double m_xangle; @@ -36,12 +38,13 @@ class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecord //---------------------------------------------------------------------------------------------------- CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : + m_label(conf.getParameter("label")), m_validityRange(conf.getParameter("validityRange")), m_beamEnergy(conf.getParameter("beamEnergy")), m_xangle(conf.getParameter("xangle")), m_insideValidityRange(false) { - setWhatProduced(this); + setWhatProduced(this, m_label); findingRecord(); } diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index ed202f556a254..62485373948a3 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -42,6 +42,8 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> edm::EDGetTokenT tracksToken_; + std::string lhcInfoLabel_; + unsigned int verbosity_; bool doSingleRPReconstruction_; @@ -59,7 +61,8 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> //---------------------------------------------------------------------------------------------------- CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : - tracksToken_(consumes(iConfig.getParameter("tagLocalTrackLite"))), + tracksToken_ (consumes(iConfig.getParameter("tagLocalTrackLite"))), + lhcInfoLabel_ (iConfig.getParameter("lhcInfoLabel")), verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), doSingleRPReconstruction_ (iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), @@ -81,22 +84,30 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.addUntracked("verbosity", 0)->setComment("verbosity level"); + desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) ->setComment("specification of the input lite-track collection"); + desc.add("lhcInfoLabel", "") + ->setComment("label of the LHCInfo record"); + + desc.addUntracked("verbosity", 0)->setComment("verbosity level"); + desc.add("doSingleRPReconstruction", true) ->setComment("flag whether to apply single-RP reconstruction strategy"); - desc.add("singleRPReconstructionLabel", "singleRP") - ->setComment("output label for single-RP reconstruction products"); desc.add("doMultiRPReconstruction", true) ->setComment("flag whether to apply multi-RP reconstruction strategy"); + + desc.add("singleRPReconstructionLabel", "singleRP") + ->setComment("output label for single-RP reconstruction products"); + desc.add("multiRPReconstructionLabel", "multiRP") ->setComment("output label for multi-RP reconstruction products"); desc.add("fitVtxY", true) ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); + desc.add("useImprovedInitialEstimate", true) ->setComment("for multi-RP reconstruction, flag whether a quadratic estimate of the initial point should be used"); @@ -109,7 +120,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe { // get conditions edm::ESHandle hLHCInfo; - iSetup.get().get(hLHCInfo); + iSetup.get().get(lhcInfoLabel_, hLHCInfo); edm::ESHandle hOpticalFunctions; iSetup.get().get(hOpticalFunctions); From 0706711cfe2e1a014a033cfb6c0bf82cfdd36769 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 12:45:22 +0100 Subject: [PATCH 201/686] LHCInfo and optics source specs moved from main reco config to dedicated cff files. --- .../ESProducers/python/ctppsLHCInfo_cff.py | 9 +++++ .../python/ctppsOpticalFunctions_cff.py | 22 +++++++++++ .../Configuration/python/recoCTPPS_cff.py | 37 +++---------------- 3 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py create mode 100644 CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py diff --git a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py new file mode 100644 index 0000000000000..85e0ad4219243 --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py @@ -0,0 +1,9 @@ +import FWCore.ParameterSet.Config as cms + +# minimal LHCInfo for 2016 data +ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", + label = cms.string("ctpps_minimal"), + validityRange = cms.EventRange("270293:min - 290872:max"), + beamEnergy = cms.double(6500), # GeV + xangle = cms.double(185) # murad +) diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py new file mode 100644 index 0000000000000..374bd412f344d --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp + +# optical functions for 2016 data +ctppsOpticalFunctionsESSource = _optics_tmp.clone( + validityRange = cms.EventRange("270293:min - 290872:max"), + + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) + ), + + scoringPlanes = cms.VPSet( + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + ) +) + +ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index 0d81fbdfa21f6..38977f4972041 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -10,38 +10,13 @@ from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * -# TODO: load these data from DB -# NB: this example only works for 2016 data -ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", - validityRange = cms.EventRange("270293:min - 290872:max"), - beamEnergy = cms.double(6500), # GeV - xangle = cms.double(185) # murad -) - -# TODO: remove this line once LHCInfo is loaded from DB -es_prefer_LHCInfo = cms.ESPrefer("CTPPSLHCInfoESSource", "ctppsLHCInfoESSource") - -# TODO: load these data from DB -# NB: this example only works for 2016 data -import FWCore.ParameterSet.Config as cms -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp -ctppsOpticalFunctionsESSource = _optics_tmp.clone( - validityRange = cms.EventRange("270293:min - 290872:max"), - - opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) - ), - - scoringPlanes = cms.VPSet( - # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 - ) -) +# TODO: remove these lines once LHCInfo available in DB +from CalibPPS.ESProducers.ctppsLHCInfo_cff import * +ctppsProtons.lhcInfoLabel = ctppsLHCInfoESSource.label -ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# TODO: remove these lines once optical functions available in DB +from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * +ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ctppsLHCInfoESSource.label recoCTPPS = cms.Sequence( totemRPLocalReconstruction * From d76782a469f4a5deec9e2569d548909de07cd5fb Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 13:13:12 +0100 Subject: [PATCH 202/686] getSplines() renamed to splines(). --- .../interface/LHCInterpolatedOpticalFunctionsSet.h | 2 +- .../src/ProtonReconstructionAlgorithm.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h index 3cea0a4727f5e..ad2682c7dc09a 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h @@ -19,7 +19,7 @@ class LHCInterpolatedOpticalFunctionsSet : public LHCOpticalFunctionsSet ~LHCInterpolatedOpticalFunctionsSet() = default; - const std::vector>& getSplines() const { return m_splines; } + const std::vector>& splines() const { return m_splines; } /// builds splines from m_*_values fields void initializeSplines(); diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 607b02664bde8..a923bd072e658 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -49,9 +49,9 @@ void ProtonReconstructionAlgorithm::init(const LHCInterpolatedOpticalFunctionsSe // make record RPOpticsData rpod; rpod.optics = &p.second; - rpod.s_y_d_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eyd]; - rpod.s_v_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::evy]; - rpod.s_L_y_vs_xi = ofs.getSplines()[LHCOpticalFunctionsSet::eLy]; + rpod.s_y_d_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::eyd]; + rpod.s_v_y_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::evy]; + rpod.s_L_y_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::eLy]; vector xiValues = ofs.getXiValues(); // local copy made since the TSpline constructor needs non-const parameters vector xDValues = ofs.getFcnValues()[LHCOpticalFunctionsSet::exd]; From 6ce9e4868cb3376e0d978453dc5d5bc7caa320df Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 13:13:43 +0100 Subject: [PATCH 203/686] Namespace and struct blocks removed. --- DataFormats/ProtonReco/src/classes.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h index 75aeab9e4e8b3..945075c65f138 100644 --- a/DataFormats/ProtonReco/src/classes.h +++ b/DataFormats/ProtonReco/src/classes.h @@ -8,15 +8,9 @@ #include #include -namespace DataFormats_ProtonReco -{ - struct dictionary - { - reco::ForwardProton fp; - std::vector vec_fp; - edm::Wrapper > wrp_vec_fp; - edm::RefProd > rp_vec_fp; - edm::Ref,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > ref_vec_fp; - edm::RefVector,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > rv_vec_fp; - }; -} +reco::ForwardProton fp; +std::vector vec_fp; +edm::Wrapper > wrp_vec_fp; +edm::RefProd > rp_vec_fp; +edm::Ref,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > ref_vec_fp; +edm::RefVector,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > rv_vec_fp; From ee420c84fd88055b3f56836684a32b8c1c9ecd43 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 13:16:18 +0100 Subject: [PATCH 204/686] Always produces output. --- .../plugins/CTPPSProtonProducer.cc | 130 +++++++++--------- 1 file changed, 67 insertions(+), 63 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 62485373948a3..d93ecfd518bb1 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -140,79 +140,83 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } } - // stop if conditions invalid - if (!opticsValid_) - return; - - // prepare log - std::ostringstream ssLog; - if (verbosity_) - ssLog << "input tracks:"; - - // get input - edm::Handle hTracks; - iEvent.getByToken(tracksToken_, hTracks); - - // keep only tracks from tracker RPs, split them by LHC sector - CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; - std::map nTracksPerRP; - for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { - const auto& tr = hTracks->at(idx); - const CTPPSDetId rpId(tr.getRPId()); - if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) - continue; - + // book output + std::unique_ptr pOutSingleRP(new reco::ForwardProtonCollection); + std::unique_ptr pOutMultiRP(new reco::ForwardProtonCollection); + + // do reconstruction only if optics is valid + if (opticsValid_) + { + // prepare log + std::ostringstream ssLog; if (verbosity_) - ssLog << "\n\t" - << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " - << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " - << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; - - CTPPSLocalTrackLiteRef r_track(hTracks, idx); - if (rpId.arm() == 0) - tracks_45.push_back(r_track); - if (rpId.arm() == 1) - tracks_56.push_back(r_track); - - nTracksPerRP[rpId]++; - } - - // for the moment: check whether there is no more than 1 track in each arm - bool singleTrack_45 = true, singleTrack_56 = true; - for (const auto& detid_num : nTracksPerRP) { - if (detid_num.second > 1) { - const CTPPSDetId& rpId = detid_num.first; + ssLog << "input tracks:"; + + // get input + edm::Handle hTracks; + iEvent.getByToken(tracksToken_, hTracks); + + // keep only tracks from tracker RPs, split them by LHC sector + CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + std::map nTracksPerRP; + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { + const auto& tr = hTracks->at(idx); + const CTPPSDetId rpId(tr.getRPId()); + if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) + continue; + + if (verbosity_) + ssLog << "\n\t" + << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " + << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " + << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; + + CTPPSLocalTrackLiteRef r_track(hTracks, idx); if (rpId.arm() == 0) - singleTrack_45 = false; + tracks_45.push_back(r_track); if (rpId.arm() == 1) - singleTrack_56 = false; - } - } - - // single-RP reconstruction - if (doSingleRPReconstruction_) { - std::unique_ptr pOut(new reco::ForwardProtonCollection); + tracks_56.push_back(r_track); - algorithm_.reconstructFromSingleRP(tracks_45, *pOut, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *pOut, *hLHCInfo, ssLog); + nTracksPerRP[rpId]++; + } - iEvent.put(std::move(pOut), singleRPReconstructionLabel_); - } + // for the moment: check whether there is no more than 1 track in each arm + bool singleTrack_45 = true, singleTrack_56 = true; + for (const auto& detid_num : nTracksPerRP) { + if (detid_num.second > 1) { + const CTPPSDetId& rpId = detid_num.first; + if (rpId.arm() == 0) + singleTrack_45 = false; + if (rpId.arm() == 1) + singleTrack_56 = false; + } + } - // multi-RP reconstruction - if (doMultiRPReconstruction_) { - std::unique_ptr pOut(new reco::ForwardProtonCollection); + // single-RP reconstruction + if (doSingleRPReconstruction_) { + algorithm_.reconstructFromSingleRP(tracks_45, *pOutSingleRP, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *pOutSingleRP, *hLHCInfo, ssLog); + } - if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *pOut, *hLHCInfo, ssLog); - if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *pOut, *hLHCInfo, ssLog); + // multi-RP reconstruction + if (doMultiRPReconstruction_) { + if (singleTrack_45) + algorithm_.reconstructFromMultiRP(tracks_45, *pOutMultiRP, *hLHCInfo, ssLog); + if (singleTrack_56) + algorithm_.reconstructFromMultiRP(tracks_56, *pOutMultiRP, *hLHCInfo, ssLog); + } - iEvent.put(std::move(pOut), multiRPReconstructionLabel_); + // dump log + if (verbosity_) + edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); } - if (verbosity_) - edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); + // save output + if (doSingleRPReconstruction_) + iEvent.put(std::move(pOutSingleRP), singleRPReconstructionLabel_); + + if (doMultiRPReconstruction_) + iEvent.put(std::move(pOutMultiRP), multiRPReconstructionLabel_); } //---------------------------------------------------------------------------------------------------- From ed8c9e93b4d41952c4b26c989ec5f63e2c20212e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 13:35:24 +0100 Subject: [PATCH 205/686] Added fillDescriptions method. --- .../CTPPSInterpolatedOpticalFunctionsESSource.cc | 14 ++++++++++++++ .../python/ctppsOpticalFunctions_cff.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc index f3c7b98b97bea..7906635ea73de 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -23,6 +23,8 @@ class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet&); ~CTPPSInterpolatedOpticalFunctionsESSource() override {} + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + std::shared_ptr produce(const CTPPSInterpolatedOpticsRcd&); private: @@ -46,6 +48,18 @@ CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSo //---------------------------------------------------------------------------------------------------- +void CTPPSInterpolatedOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions &descriptions) +{ + edm::ParameterSetDescription desc; + + desc.add("lhcInfoLabel", "") + ->setComment("label of the LHCInfo record"); + + descriptions.add("ctppsInterpolatedOpticalFunctionsESSource", desc); +} + +//---------------------------------------------------------------------------------------------------- + std::shared_ptr CTPPSInterpolatedOpticalFunctionsESSource::produce(const CTPPSInterpolatedOpticsRcd& iRecord) { // get the input data diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py index 374bd412f344d..ed22d982e6338 100644 --- a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -19,4 +19,4 @@ ) ) -ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import * From 7507214bbce85951d9358c491dcf44e2dff8724b Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 14:16:25 +0100 Subject: [PATCH 206/686] Added labels to LHCInfo data. --- Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc | 4 +++- .../plugins/CTPPSProtonReconstructionSimulationValidator.cc | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc index 4a8c48b630c96..b487eb17c19a8 100644 --- a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc @@ -35,6 +35,7 @@ class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> void endJob() override; edm::EDGetTokenT tokenHepMC_; + std::string lhcInfoLabel_; std::string outputFile_; std::unique_ptr h_xi_, h_th_x_, h_th_y_; @@ -50,6 +51,7 @@ using namespace HepMC; CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::ParameterSet& iConfig) : tokenHepMC_( consumes(iConfig.getParameter("tagHepMC")) ), + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), outputFile_(iConfig.getParameter("outputFile")), h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)), h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)), @@ -62,7 +64,7 @@ void CTPPSHepMCDistributionPlotter::analyze(const edm::Event& iEvent, const edm: { // get conditions edm::ESHandle hLHCInfo; - iSetup.get().get(hLHCInfo); + iSetup.get().get(lhcInfoLabel_, hLHCInfo); // get input edm::Handle hHepMC; diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc index d9f90a3223c49..a522e7be15a34 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -50,6 +50,8 @@ class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer edm::EDGetTokenT tokenRecoProtonsSingleRP_; edm::EDGetTokenT tokenRecoProtonsMultiRP_; + std::string lhcInfoLabel_; + std::string outputFile_; struct PlotGroup @@ -158,6 +160,7 @@ CTPPSProtonReconstructionSimulationValidator::CTPPSProtonReconstructionSimulatio tokenHepMCAfterSmearing_ (consumes(iConfig.getParameter("tagHepMCAfterSmearing"))), tokenRecoProtonsSingleRP_(consumes(iConfig.getParameter("tagRecoProtonsSingleRP"))), tokenRecoProtonsMultiRP_ (consumes(iConfig.getParameter("tagRecoProtonsMultiRP"))), + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), outputFile_(iConfig.getParameter("outputFile")) {} @@ -167,7 +170,7 @@ void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEv { // get conditions edm::ESHandle hLHCInfo; - iSetup.get().get(hLHCInfo); + iSetup.get().get(lhcInfoLabel_, hLHCInfo); // get input edm::Handle hHepMCBeforeSmearing; From 8a1a2897674e46a214a782d3180a6090778a3bef Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 14:16:41 +0100 Subject: [PATCH 207/686] Removed duplicate configs. --- .../year_2016/ctppsLHCInfoESSource_cfi.py | 7 ------- .../ctppsOpticalFunctionsESSource_cfi.py | 18 ------------------ 2 files changed, 25 deletions(-) delete mode 100644 Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py delete mode 100644 Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py diff --git a/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py deleted file mode 100644 index cc9fe235d3e14..0000000000000 --- a/Validation/CTPPS/python/year_2016/ctppsLHCInfoESSource_cfi.py +++ /dev/null @@ -1,7 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", - validityRange = cms.EventRange("270293:min - 290872:max"), - beamEnergy = cms.double(6500), # GeV - xangle = cms.double(185) # murad -) diff --git a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py deleted file mode 100644 index 95de8246f09f6..0000000000000 --- a/Validation/CTPPS/python/year_2016/ctppsOpticalFunctionsESSource_cfi.py +++ /dev/null @@ -1,18 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp - -ctppsOpticalFunctionsESSource = _optics_tmp.clone( - validityRange = cms.EventRange("270293:min - 290872:max"), - - opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) - ), - - scoringPlanes = cms.VPSet( - # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 - ) -) From c44096b8b5d36f07fe83c1e330bc33f70652a055 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 13 Mar 2019 14:18:07 +0100 Subject: [PATCH 208/686] Use cff files from CalibPPS/ESProducers. --- .../test_beam_smearing_cfg.py | 10 +++++----- .../test_acceptance_cfg.py | 12 +++++------- .../test_smearing_effects_cfg.py | 12 +++++------- .../test_xy_pattern_cfg.py | 12 +++++------- .../proton_gun_validation/test_proton_gun_cfg.py | 5 +++-- .../misalignment/template_cfg.py | 15 ++++++++------- .../resolution/template_cfg.py | 15 ++++++++------- 7 files changed, 39 insertions(+), 42 deletions(-) diff --git a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py index dc550044ba4d1..42994126c1997 100644 --- a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py +++ b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py @@ -24,11 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py index 853fc15c9c68f..158102a73093a 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -24,13 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - -process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py index b08e8da1c01bc..dd31027ca7bb8 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -24,13 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - -process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py index 5aff6bd7f647a..4813a08dcde17 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -24,13 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - -process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py index eb93f6ac40c79..35791f20c7489 100644 --- a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py @@ -25,7 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # provide LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") # particle generator process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") @@ -39,7 +40,7 @@ # plotter process.ctppsHepMCDistributionPlotter = cms.EDAnalyzer("CTPPSHepMCDistributionPlotter", tagHepMC = cms.InputTag("generator", "unsmeared"), - + lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB outputFile = cms.string("test_proton_gun.root") ) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index a302902af2f84..cf4f85452edcc 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -24,13 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - -process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", @@ -70,6 +68,7 @@ # proton reconstruction process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation @@ -79,6 +78,8 @@ tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), + lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB + outputFile = cms.string("") ) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index 0639bedc7a32f..28200e9a17dcd 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -24,13 +24,11 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info -process.load("Validation.CTPPS.year_2016.ctppsLHCInfoESSource_cfi") - -# supply optics -process.load("Validation.CTPPS.year_2016.ctppsOpticalFunctionsESSource_cfi") - -process.ctppsInterpolatedOpticalFunctionsESSource = cms.ESProducer("CTPPSInterpolatedOpticalFunctionsESSource") +# supply LHC info and optics +# TODO: remove these lines once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") +process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", @@ -68,6 +66,7 @@ # proton reconstruction process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation @@ -77,6 +76,8 @@ tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), + lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB + outputFile = cms.string("") ) From c420bb215d4584d2aee7a2ee87ad7680d7f87715 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 14 Mar 2019 20:04:20 +0100 Subject: [PATCH 209/686] Removed funny charcters inserted by GitHub resolve tool. --- IOMC/ParticleGuns/src/SealModule.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOMC/ParticleGuns/src/SealModule.cc b/IOMC/ParticleGuns/src/SealModule.cc index 7ac668e80afe7..140c401a7e717 100644 --- a/IOMC/ParticleGuns/src/SealModule.cc +++ b/IOMC/ParticleGuns/src/SealModule.cc @@ -58,7 +58,7 @@ using edm::FlatRandomPtAndDxyGunProducer; DEFINE_FWK_MODULE(FlatRandomPtAndDxyGunProducer); using edm::RandomMultiParticlePGunProducer; DEFINE_FWK_MODULE(RandomMultiParticlePGunProducer); -using edm::CloseByParticleGunProducer;  +using edm::CloseByParticleGunProducer; DEFINE_FWK_MODULE(CloseByParticleGunProducer); using edm::RandomXiThetaGunProducer; DEFINE_FWK_MODULE(RandomXiThetaGunProducer); From b6b9e21a5d57cfb1eb187c69fbeac7542bb040e4 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Fri, 4 May 2018 14:47:41 +0200 Subject: [PATCH 210/686] Workflow: Use new unpacker Since 2017 a new unpacker for the digis is used. If the option "run-on-RAW" is used the digis need to be unpacked from the raw data. Now the correct new unpacker is loaded when using this option. (cherry picked from commit 3fa9140ff22681fe0dadcc1c025f420b3d59b9e7) --- .../DTCalibration/python/dt_offlineAnalysis_common_cff.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CalibMuon/DTCalibration/python/dt_offlineAnalysis_common_cff.py b/CalibMuon/DTCalibration/python/dt_offlineAnalysis_common_cff.py index df05a52c18b3a..9e26b169c877f 100644 --- a/CalibMuon/DTCalibration/python/dt_offlineAnalysis_common_cff.py +++ b/CalibMuon/DTCalibration/python/dt_offlineAnalysis_common_cff.py @@ -7,7 +7,8 @@ from RecoLocalMuon.Configuration.RecoLocalMuon_cff import * -from EventFilter.DTRawToDigi.dtunpacker_cfi import * +import EventFilter.DTRawToDigi.dturosunpacker_cfi +muonDTDigis = EventFilter.DTRawToDigi.dturosunpacker_cfi.dturosunpacker.clone() dtCalibOfflineReco = cms.Sequence(dt1DRecHits + dt2DSegments + dt4DSegments) dtCalibOfflineRecoRAW = cms.Sequence(muonDTDigis + dt1DRecHits + dt2DSegments + dt4DSegments) From 06b72e8f4191070ccb346dd130b9051e7bc9bab9 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Fri, 4 May 2018 14:49:21 +0200 Subject: [PATCH 211/686] General: Print less messages about the number of analyzed events Bevor every analyzed event was printed in the cerr. Now it prints less often with increasing time between two messages. (cherry picked from commit f21547b126e4c0069f645ed5cd2f70278e3aa18d) --- CalibMuon/DTCalibration/python/messageLoggerDebug_cff.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CalibMuon/DTCalibration/python/messageLoggerDebug_cff.py b/CalibMuon/DTCalibration/python/messageLoggerDebug_cff.py index 23b66376b8f77..058e5dc842961 100644 --- a/CalibMuon/DTCalibration/python/messageLoggerDebug_cff.py +++ b/CalibMuon/DTCalibration/python/messageLoggerDebug_cff.py @@ -5,6 +5,10 @@ MessageLogger.destinations = cms.untracked.vstring('cerr') MessageLogger.categories.append('Calibration') MessageLogger.cerr = cms.untracked.PSet( + FwkReport = cms.untracked.PSet( + limit = cms.untracked.int32(100), + reportEvery = cms.untracked.int32(1000) + ), threshold = cms.untracked.string('DEBUG'), noLineBreaks = cms.untracked.bool(False), DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), From 02f9e3227b3ed08056d8882b2e3746634894310d Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Fri, 4 May 2018 14:53:17 +0200 Subject: [PATCH 212/686] DTResidualCalibration: Less verbose logging Moved a lot of messages to debug level (like booking histos). Results in much less output. (cherry picked from commit e1bc42d63006ab26b1a3b35c32f7b5e042a8ed13) --- .../plugins/DTResidualCalibration.cc | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc index c1b1f65d8b655..420a66d246c34 100644 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc @@ -38,7 +38,7 @@ DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset): rootBaseDir_(pset.getUntrackedParameter("rootBaseDir","DT/Residuals")), detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis",false)) { - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Constructor called."; + LogDebug("Calibration") << "[DTResidualCalibration] Constructor called."; consumes< DTRecSegment4DCollection >(edm::InputTag(segment4DLabel_)); std::string rootFileName = pset.getUntrackedParameter("rootFileName","residuals.root"); rootFile_ = new TFile(rootFileName.c_str(), "RECREATE"); @@ -174,7 +174,7 @@ float DTResidualCalibration::segmentToWireDistance(const DTRecHit1D& recHit1D, c void DTResidualCalibration::endJob(){ - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Writing histos to file."; + LogDebug("Calibration") << "[DTResidualCalibration] Writing histos to file."; rootFile_->cd(); rootFile_->Write(); rootFile_->Close(); @@ -197,7 +197,7 @@ void DTResidualCalibration::bookHistos(DTSuperLayerId slId) { TH1AddDirectorySentry addDir; rootFile_->cd(); - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for SL: " << slId; + LogDebug("Calibration") << "[DTResidualCalibration] Booking histos for SL: " << slId; // Compose the chamber name // Define the step @@ -214,16 +214,16 @@ void DTResidualCalibration::bookHistos(DTSuperLayerId slId) { "_Sec" + sectorStr + "_SL" + std::to_string(slId.superlayer()); - edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; + LogDebug("Calibration") << "Accessing " << rootBaseDir_; TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); + LogDebug("Calibration") << "Accessing " << ("Wheel" + wheelStr); TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); + LogDebug("Calibration") << "Accessing " << ("Station" + stationStr); TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); + LogDebug("Calibration") << "Accessing " << ("Sector" + sectorStr); TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); @@ -246,7 +246,7 @@ void DTResidualCalibration::bookHistos(DTLayerId layerId) { TH1AddDirectorySentry addDir; rootFile_->cd(); - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for layer: " << layerId; + LogDebug("Calibration") << "[DTResidualCalibration] Booking histos for layer: " << layerId; // Compose the chamber name std::string wheelStr = std::to_string(layerId.wheel()); @@ -265,19 +265,19 @@ void DTResidualCalibration::bookHistos(DTLayerId layerId) { "_SL" + superLayerStr + "_Layer" + layerStr; - edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; + LogDebug("Calibration") << "Accessing " << rootBaseDir_; TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); + LogDebug("Calibration") << "Accessing " << ("Wheel" + wheelStr); TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); + LogDebug("Calibration") << "Accessing " << ("Station" + stationStr); TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); + LogDebug("Calibration") << "Accessing " << ("Sector" + sectorStr); TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("SL" + superLayerStr); + LogDebug("Calibration") << "Accessing " << ("SL" + superLayerStr); TDirectory* superLayerDir = sectorDir->GetDirectory(("SL" + superLayerStr).c_str()); if(!superLayerDir) superLayerDir = sectorDir->mkdir(("SL" + superLayerStr).c_str()); From b670c9eb067cba1c0ea90bf8e0c083ca76afd165 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Fri, 4 May 2018 15:37:23 +0200 Subject: [PATCH 213/686] T0 Calibration rework and integration in workflow I re-worked the T0 calibration. The first working version (lot of commented code which will be removed) is included in this commit. It is also now integrated in the DTWorkflow. You can run is using: dtCalibration T0Wire all all --label LABEL --trial TRIAL --run=RUN --globaltag=GLOBALTAG --datasetpath=/MiniDaq/ERA/RAW (cherry picked from commit c6c6739f899c53daef39ba8a4a5bd368158bc154) --- .../plugins/DTT0CalibrationNew.cc | 815 ++++++++++++++++++ .../plugins/DTT0CalibrationNew.h | 131 +++ CalibMuon/DTCalibration/plugins/SealModule.cc | 2 + .../python/Workflow/DTCalibrationWorker.py | 3 +- .../python/dtT0WireCalibrationNew_cfg.py | 129 +++ 5 files changed, 1079 insertions(+), 1 deletion(-) create mode 100644 CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc create mode 100644 CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h create mode 100644 CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc new file mode 100644 index 0000000000000..cb91e51baf821 --- /dev/null +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc @@ -0,0 +1,815 @@ +/* + * See header file for a description of this class. + * + * $Date: 2012/05/11 17:17:17 $ + * $Revision: 1.6 $ + * \author S. Bolognesi - INFN Torino + * 06/08/2008 Mofified by Antonio.Vilela.Pereira@cern.ch + */ + +#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" +#include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" + +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "CondFormats/DTObjects/interface/DTT0.h" + +#include +#include + +#include "TKey.h" +#include "TF1.h" + +#include + +using namespace std; +using namespace edm; + +// Constructor +DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : + debug(pset.getUntrackedParameter("debug")), + digiToken(consumes(pset.getUntrackedParameter("digiLabel"))), + theFile(pset.getUntrackedParameter("rootFileName", "DTT0PerLayer.root").c_str(), "RECREATE"), + nevents(0), + eventsForLayerT0(pset.getParameter("eventsForLayerT0")), + eventsForWireT0(pset.getParameter("eventsForWireT0")), + tpPeakWidth(pset.getParameter("tpPeakWidth")), + tpPeakWidthPerLayer(pset.getParameter("tpPeakWidthPerLayer")), + rejectDigiFromPeak(pset.getParameter("rejectDigiFromPeak")), + hLayerPeaks("hLayerPeaks", "", 3000, 0, 3000), + spectrum(20) + +{ + // Get the debug parameter for verbose output + if(debug) + cout << "[DTT0CalibrationNew]Constructor called!" << endl; + + theCalibWheel = pset.getUntrackedParameter("calibWheel", "All"); //FIXME amke a vector of integer instead of a string + if(theCalibWheel != "All") { + stringstream linestr; + int selWheel; + linestr << theCalibWheel; + linestr >> selWheel; + cout << "[DTT0CalibrationNewPerLayer] chosen wheel " << selWheel << endl; + } + + // Sector/s to calibrate + theCalibSector = pset.getUntrackedParameter("calibSector", "All"); //FIXME amke a vector of integer instead of a string + if(theCalibSector != "All") { + stringstream linestr; + int selSector; + linestr << theCalibSector; + linestr >> selSector; + cout << "[DTT0CalibrationNewPerLayer] chosen sector " << selSector << endl; + } + + vector defaultCell; + const auto& cellsWithHistos = pset.getUntrackedParameter >("cellsWithHisto", defaultCell); + for(const auto& cell : cellsWithHistos){ + stringstream linestr; + int wheel, sector, station, sl, layer, wire; + linestr << cell; + linestr >> wheel >> sector >> station >> sl >> layer >> wire; + wireIdWithHistos.push_back(DTWireId(wheel, station, sector, sl, layer, wire)); + } +} + +// Destructor +DTT0CalibrationNew::~DTT0CalibrationNew(){ + if(debug) + cout << "[DTT0CalibrationNew]Destructor called!" << endl; + + theFile.Close(); +} + +/// Perform the real analysis +void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { + nevents++; + + // Get the digis from the event + Handle digis; + event.getByToken(digiToken, digis); + + // Get the DT Geometry + if (nevents == 1) + eventSetup.get().get(dtGeom); + + //const auto begin = *(digis->begin()); + //const auto end = *(digis->end()); + //std::cout << __LINE__ << " " << &(begin) << " " << &(end) << " " << sizeof(begin) << " " << typeid(begin).name() << std::endl; + //std::cout << __LINE__ << " " << &(*begin) << " " << &(*end) << std::endl; + //std::cout << __LINE__ << " " << &(*(digis->begin())) << " " << &(*(digis->end())) << std::endl; + //for (; begin != end; begin++) + // std::cout << __LINE__ << std::endl; + // Iterate through all digi collections ordered by LayerId + for (const auto& digis_per_layer : *digis) + { + //std::cout << __LINE__ << std::endl; + // Get the iterators over the digis associated with this LayerId + const DTDigiCollection::Range& digiRange = digis_per_layer.second; + + // Get the layerId + const DTLayerId layerId = digis_per_layer.first; + //const DTChamberId chamberId = layerId.superlayerId().chamberId(); + + if((theCalibWheel != "All") && (layerId.superlayerId().chamberId().wheel() != selWheel)) + continue; + if((theCalibSector != "All") && (layerId.superlayerId().chamberId().sector() != selSector)) + continue; + + // Loop over all digis in the given layer + for (DTDigiCollection::const_iterator digi = digiRange.first; + digi != digiRange.second; + ++digi) + { + const double t0 = digi->countsTDC(); + const DTWireId wireIdtmp(layerId, (*digi).wire()); + all_wires.insert(wireIdtmp.wire()); + + // Use first bunch of events to fill t0 per layer + if(nevents <= eventsForLayerT0){ + // If it doesn't exist, book it + if(not theHistoLayerMap.count(layerId)){ + theHistoLayerMap[layerId] = TH1I(getHistoName(layerId).c_str(), + "T0 from pulses by layer (TDC counts, 1 TDC count = 0.781 ns)", + 3000, + 0, + 3000 + ); + if(debug) + cout << " New T0 per Layer Histo: " << theHistoLayerMap[layerId].GetName() << endl; + } + theHistoLayerMap[layerId].Fill(t0); + } + + // Use all the remaining events to compute t0 per wire + if(nevents>eventsForLayerT0){ + // Get the wireId + const DTWireId wireId(layerId, (*digi).wire()); + if(debug) { + cout << " Wire: " << wireId << endl + << " time (TDC counts): " << (*digi).countsTDC()<< endl; + } + + //Fill the histos per wire for the chosen cells + //if (std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) != layerIdWithWireHistos.end() or + std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) + { + //If it doesn't exist, book it + if(theHistoWireMap.count(wireId) == 0){ + theHistoWireMap[wireId] = TH1I(getHistoName(wireId).c_str(), + "T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)", + 7000, + 0, + 7000 + ); + if(debug) + cout << " New T0 per wire Histo: " << theHistoWireMap[wireId].GetName() << endl; + } + theHistoWireMap[wireId].Fill(t0); + } + + //Select per layer + if(fabs(theTPPeakMap[layerId] - t0) > rejectDigiFromPeak){ + if(debug) + cout<<"digi skipped because t0 too far from peak " << theTPPeakMap[layerId] << endl; + continue; + } + + //Find to ref. per chamber + /* + if (not theCountT0ByChamber[chamberId]) + { + theSumT0ByChamber[chamberId] = 0; + theCountT0ByChamber[chamberId] = 0; + theMeanT0ByChamber[chamberId] = 0; + theSigmaT0ByChamber[chamberId] = 0; + } + theCountT0ByChamber[chamberId]++; + theSumT0ByChamber[chamberId] = theSumT0ByChamber[chamberId] + t0; + theSigmaT0ByChamber[chamberId] += (theSumT0ByChamber[chamberId] - 1) * pow(t0 -theMeanT0ByChamber[chamberId], 2) / theSumT0ByChamber[chamberId]; + theMeanT0ByChamber[chamberId] += (t0 - theMeanT0ByChamber[chamberId]) / theCountT0ByChamber[chamberId]; + */ + + //Use second bunch of events to compute a t0 reference per wire + if(nevents <= (eventsForLayerT0 + eventsForWireT0)){ + if(!nDigiPerWire_ref[wireId]){ + mK_ref[wireId] = 0; + } + nDigiPerWire_ref[wireId] = nDigiPerWire_ref[wireId] + 1; + mK_ref[wireId] = mK_ref[wireId] + (t0-mK_ref[wireId])/nDigiPerWire_ref[wireId]; + } + //Use last all the remaining events to compute the mean and sigma t0 per wire + else if(nevents > (eventsForLayerT0 + eventsForWireT0)){ + if(abs(t0-mK_ref[wireId]) > tpPeakWidth) + continue; + if(!nDigiPerWire[wireId]){ + theAbsoluteT0PerWire[wireId] = 0; + qK[wireId] = 0; + mK[wireId] = 0; + } + nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1; + theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0; + //theSigmaT0PerWire[wireId] = theSigmaT0PerWire[wireId] + (t0*t0); + qK[wireId] = qK[wireId] + ((nDigiPerWire[wireId]-1)*(t0-mK[wireId])*(t0-mK[wireId])/nDigiPerWire[wireId]); + mK[wireId] = mK[wireId] + (t0-mK[wireId])/nDigiPerWire[wireId]; + } + }//end if(nevents>1000) + }//end loop on digi + }//end loop on layer + + //Use the t0 per layer histos to have an indication about the t0 position + if(nevents == eventsForLayerT0){ + for(const auto& lHisto : theHistoLayerMap) + { + const auto& layerId = lHisto.first; + const auto& hist = lHisto.second; + if(debug) + cout << "Reading histogram " << hist.GetName() << " with mean " << hist.GetMean() << " and RMS " << hist.GetRMS() << endl; + + //Find peaks + int npeaks = spectrum.Search(&hist, (tpPeakWidthPerLayer / 2.), "", 0.3); + + double *peaks = spectrum.GetPositionX(); + //Put in a std::vector + vector peakMeans(peaks, peaks + npeaks); + //Sort the peaks in ascending order + sort(peakMeans.begin(), peakMeans.end()); + + if (peakMeans.empty()) + { + theTPPeakMap[layerId] = hist.GetMaximumBin(); + std::cout << "No peaks found by peakfinder in layer " << layerId << ". Taking maximum bin at " << theTPPeakMap[layerId] << ". Please check!" << std::endl; + layerIdWithWireHistos.push_back(layerId); + } + else if (fabs(hist.GetXaxis()->FindBin(peakMeans.front()) - hist.GetXaxis()->FindBin(peakMeans.back())) < rejectDigiFromPeak) + { + theTPPeakMap[layerId] = peakMeans[peakMeans.size() / 2]; + } + else + { + bool peak_set = false; + for (const auto& peak : peakMeans) + { + // Skip if at low edge + if (peak - tpPeakWidthPerLayer <= 0) + continue; + // Get integral of peak + double sum = 0; + for (int ibin=peak - tpPeakWidthPerLayer; ibin 5) + { + std::cout << "Found more than 5 peaks in layer " << layerId << ". Please check!" << std::endl; + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) + layerIdWithWireHistos.push_back(layerId); + } + // Check for noise + int nspikes = 0; + for (int ibin=0; ibin hist.GetMaximum() * 0.001) + nspikes++; + } + if (nspikes > 50) + { + std::cout << "Found a lot of (>50) small spikes in layer " << layerId << ". Please check if all wires are functioning as expected!" << std::endl; + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) + layerIdWithWireHistos.push_back(layerId); + } + //if (peakMeans.empty()) + // std::cout << "PEAK IN LAYER (EMPTY) " << layerId << " " << theTPPeakMap[layerId] << std::endl; + //else if (peakMeans.size() > 5) + // std::cout << "PEAK IN LAYER (>5) " << layerId << " " << theTPPeakMap[layerId] << std::endl; + //else if (peakMeans.back() > 1000) + // std::cout << "PEAK IN LAYER (TO HIGH) " << layerId << " " << theTPPeakMap[layerId] << std::endl; + + hLayerPeaks.Fill(theTPPeakMap[layerId]); + + } + } +} + +void DTT0CalibrationNew::endJob() { + + std::cout << "WIRES" << std::endl; + for (auto& wire : all_wires) + std::cout << wire << std::endl; + std::cout << "Analyzed " << nevents << " events" << std::endl; + + DTT0* t0sWRTChamber = new DTT0(); + + if(debug) + cout << "[DTT0CalibrationNewPerLayer]Writing histos to file!" << endl; + + theFile.cd(); + //hT0SectorHisto->Write(); + hLayerPeaks.Write(); + for(const auto& wHisto : theHistoWireMap){ + wHisto.second.Write(); + } + for(const auto& lHisto : theHistoLayerMap ) { + lHisto.second.Write(); + } + + if(debug) + cout << "[DTT0CalibrationNew] Compute and store t0 and sigma per wire" << endl; + + // Calculate uncertainties per wire (counting experiment) + for (auto& wiret0 : theAbsoluteT0PerWire) + { + auto& wireId = wiret0.first; + if (nDigiPerWire[wireId] > 1 ) + theSigmaT0PerWire[wireId] = qK[wireId] / (nDigiPerWire[wireId] - 1); + else + theSigmaT0PerWire[wireId] = 999.; // Only one measurement: uncertainty -> infinity + // syst uncert + //theSigmaT0PerWire[wireId] += pow(0.5, 2)); + // Every time the same measurement. Use Laplace estimator as estimation how propable it is to measure another value due to limited size of sample + if (theSigmaT0PerWire[wireId] == 0) + { + std::cout << "NOERROR " << wireId << " " << nDigiPerWire[wireId] << " " << pow(1. / (nDigiPerWire[wireId] + 1), 2) << std::endl; + theSigmaT0PerWire[wireId] += pow(1. / (nDigiPerWire[wireId] + 1), 2); + } + std::cout << "START " << wireId << " " << wiret0.second / nDigiPerWire[wireId] << " " << sqrt(theSigmaT0PerWire[wireId]) << " " << nDigiPerWire[wireId] << std::endl; + } + + // function to calculate weighted means + /*auto weighted_mean_function = [] (const std::list& values, const std::list& sigmas) + { + auto value_iterator = values.begin(); + auto sigma_iterator = sigmas.begin(); + double weighted_mean = 0; + double weighted_sigma = 0; + assert(values.size() == sigmas.size()); + for (; value_iterator != values.end(); value_iterator++, sigma_iterator++) + { + double weight = 1. / pow(*sigma_iterator, 2); + weighted_mean += (*value_iterator * weight); + weighted_sigma += weight; + } + weighted_mean /= weighted_sigma; + weighted_sigma = 1. / sqrt(weighted_sigma); + return std::make_pair(weighted_mean, weighted_sigma); + };*/ + + // function to calculate unweighted means + auto unweighted_mean_function = [] (const std::list& values, const std::list& sigmas) + { + double mean = 0; + for (auto& value : values) + { + mean += value; + } + mean /= values.size(); + + double uncertainty = 0; + for (auto& value : values) + { + uncertainty += pow(value - mean, 2); + } + uncertainty /= values.size(); + uncertainty = sqrt(uncertainty); + return std::make_pair(mean, uncertainty); + }; + + // correct for odd-even effect in each super layer + std::map > weighted_mean_sigma_even; + std::map > weighted_mean_sigma_odd; + for (const auto& superlayer : dtGeom->superLayers()) + { + const auto superlayer_id = superlayer->id(); + std::list values_even; + std::list sigmas_even; + std::list values_odd; + std::list sigmas_odd; + + for (const auto& wiret0 : theAbsoluteT0PerWire) + { + const auto& wireId = wiret0.first; + if (wireId.layerId().superlayerId() == superlayer_id) + { + const auto& t0 = wiret0.second / nDigiPerWire[wireId]; + if (wireId.layerId().layer() % 2) + { + values_odd.push_back(t0); + sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + else + { + values_even.push_back(t0); + sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + } + } + // get mean and uncertainty + weighted_mean_sigma_even.emplace(superlayer_id, unweighted_mean_function(values_even, sigmas_even)); + weighted_mean_sigma_odd.emplace(superlayer_id, unweighted_mean_function(values_odd, sigmas_odd)); + std::cout << "EVEN " << superlayer_id << " " << weighted_mean_sigma_even[superlayer_id].first << " +- " << weighted_mean_sigma_even[superlayer_id].second << std::endl; + std::cout << "ODD " << superlayer_id << " " << weighted_mean_sigma_odd[superlayer_id].first << " +- " << weighted_mean_sigma_odd[superlayer_id].second << std::endl; + } + + // filter outliers + for (const auto& superlayer : dtGeom->superLayers()) + { + const auto superlayer_id = superlayer->id(); + std::list values_even; + std::list sigmas_even; + std::list values_odd; + std::list sigmas_odd; + + for (const auto& wiret0 : theAbsoluteT0PerWire) + { + const auto& wireId = wiret0.first; + if (wireId.layerId().superlayerId() == superlayer_id) + { + const auto& t0 = wiret0.second / nDigiPerWire[wireId]; + if (wireId.layerId().layer() % 2 and abs(t0 - weighted_mean_sigma_odd[superlayer_id].first) < 2*weighted_mean_sigma_odd[superlayer_id].second) + { + values_odd.push_back(t0); + sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + else + { + if (abs(t0 - weighted_mean_sigma_even[superlayer_id].first) < 2*weighted_mean_sigma_even[superlayer_id].second) + { + values_even.push_back(t0); + sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + } + } + } + // get mean and uncertainty + weighted_mean_sigma_even[superlayer_id] = unweighted_mean_function(values_even, sigmas_even); + weighted_mean_sigma_odd[superlayer_id] = unweighted_mean_function(values_odd, sigmas_odd); + } + + // apply correction + for (auto& wiret0 : theAbsoluteT0PerWire) + { + const auto& wire_id = wiret0.first; + const auto& superlayer_id = wiret0.first.layerId().superlayerId(); + const auto& layer = wiret0.first.layerId().layer(); + auto& t0 = wiret0.second; + t0 /= nDigiPerWire[wire_id]; + if (not layer % 2) + continue; + // t0 is reference. Changing it changes the map + t0 += weighted_mean_sigma_even[superlayer_id].first - weighted_mean_sigma_odd[superlayer_id].first; + theSigmaT0PerWire[wire_id] += pow(weighted_mean_sigma_odd[superlayer_id].second, 2) + pow(weighted_mean_sigma_even[superlayer_id].second, 2); + std::cout << "ODD-EVEN-CORRECTED " << wire_id << " " << t0 << " " << sqrt(theSigmaT0PerWire[wire_id]) << std::endl; + } + + // get chamber mean + std::map > values_per_chamber; + std::map > sigmas_per_chamber; + for (const auto& wire_t0 : theAbsoluteT0PerWire) + { + const auto& wire_id = wire_t0.first; + const auto& chamber_id = wire_id.chamberId(); + const auto& t0 = wire_t0.second; + values_per_chamber[chamber_id].push_back(t0); + sigmas_per_chamber[chamber_id].push_back(sqrt(theSigmaT0PerWire[wire_id])); + } + + std::map > weighted_mean_per_chamber; + for (const auto& chamber_mean : values_per_chamber) + { + const auto& chamber_id = chamber_mean.first; + const auto& means = chamber_mean.second; + const auto& sigmas = sigmas_per_chamber[chamber_id]; + weighted_mean_per_chamber.emplace(chamber_id, unweighted_mean_function(means, sigmas)); + std::cout << "CHAMBER MEAN " << chamber_id << " " << weighted_mean_per_chamber[chamber_id].first << " +- " << weighted_mean_per_chamber[chamber_id].second << std::endl; + } + + // calculate relative values + for (const auto& wire_t0 : theAbsoluteT0PerWire) + { + const auto& wire_id = wire_t0.first; + const auto& chamber_id = wire_id.chamberId(); + const auto& t0 = wire_t0.second; + theRelativeT0PerWire.emplace(wire_id, t0 - weighted_mean_per_chamber[chamber_id].first); + //theSigmaT0PerWire[wire_id] += pow(weighted_mean_per_chamber[chamber_id].second, 2); + cout << "[DTT0CalibrationNew] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " + << " sigma "<< sqrt(theSigmaT0PerWire[wire_id]) <set(wire_id, + t0, + sqrt(theSigmaT0PerWire[wire_id]), + DTTimeUnits::counts + ); + } + + ///Write the t0 map into DB + if(debug) + cout << "[DTT0CalibrationNew]Writing values in DB!" << endl; + // FIXME: to be read from cfg? + string t0Record = "DTT0Rcd"; + // Write the t0 map to DB + DTCalibDBUtils::writeToDB(t0Record, t0sWRTChamber); + delete t0sWRTChamber; + + /* + for(map::const_iterator wiret0 = theAbsoluteT0PerWire.begin(); + wiret0 != theAbsoluteT0PerWire.end(); + ++wiret0){ + DTChamberId chamberId = wiret0->first.chamberId(); + double t0 = wiret0->second/nDigiPerWire[wiret0->first]; + //double t0 = mK[wiret0->first]; + if (nDigiPerWire[wiret0->first] > 1 ) + theSigmaT0PerWire[wiret0->first] = sqrt(qK[wiret0->first]/(nDigiPerWire[wiret0->first] - 1)); + else + theSigmaT0PerWire[wiret0->first] = 999.; // Only one measurement: uncertainty -> infinity + values[chamberId].push_back(t0); + theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(0.5, 2)); + sigmas[chamberId].push_back(theSigmaT0PerWire[wiret0->first]); + } + + for (auto chamberId_iterator=values.begin(); chamberId_iterator != values.end(); chamberId_iterator++) + { + const auto& chamberId = chamberId_iterator->first; + double weight = 0; + auto value_iterator = values[chamberId].begin(); + auto sigma_iterator = sigmas[chamberId].begin(); + double tmp = 0; + theSigmaT0ByChamber[chamberId] = 0; + if (values[chamberId].size() != sigmas[chamberId].size()) + std::cout << "FUCK MY LIFE" << std::endl; + for (; value_iterator != values[chamberId].end(); value_iterator++, sigma_iterator++) + { + weight = 1. / pow(*sigma_iterator, 2); + theRefT0ByChamber[chamberId] += (*value_iterator * weight); + theSigmaT0ByChamber[chamberId] += weight; + tmp += *value_iterator; + std::cout << *value_iterator << " " << *sigma_iterator << std::endl; + } + //std::cout << tmp << " " << values[chamberId].size() << " " << sigmas[chamberId].size() << " " << theCountT0ByChamber[chamberId] << " " << theSumT0ByChamber[chamberId] << std::endl; + theRefT0ByChamber[chamberId] /= theSigmaT0ByChamber[chamberId]; + theSigmaT0ByChamber[chamberId] = 1. / sqrt(theSigmaT0ByChamber[chamberId]); + std::cout << "PER CHAMBER " << chamberId << " " << theCountT0ByChamber[chamberId] << " " << theRefT0ByChamber[chamberId] << " " << theSigmaT0ByChamber[chamberId] << " " << tmp / values[chamberId].size() << std::endl; + } + + for(map::const_iterator wiret0 = theAbsoluteT0PerWire.begin(); + wiret0 != theAbsoluteT0PerWire.end(); + ++wiret0){ + if(nDigiPerWire[(*wiret0).first]){ + double t0 = (*wiret0).second/nDigiPerWire[(*wiret0).first]; + DTChamberId chamberId = ((*wiret0).first).chamberId(); + //theRelativeT0PerWire[(*wiret0).first] = t0 - hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()); + theRelativeT0PerWire[(*wiret0).first] = t0 - theRefT0ByChamber[chamberId]; + cout<<"Wire "<<(*wiret0).first<<" has t0 "< 1 ) + // theSigmaT0PerWire[(*wiret0).first] = sqrt(qK[(*wiret0).first]/(nDigiPerWire[(*wiret0).first] - 1)); + //else + // theSigmaT0PerWire[(*wiret0).first] = 999.; // Only one measurement: uncertainty -> infinity + // Systematic uncertainty: Channel Width + theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(theSigmaT0ByChamber[chamberId], 2)); + //theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(0.5, 2)); + cout<<" sigma "< superLayers = dtGeom->superLayers(); + // Loop over all SLs + double oddLayersFinalMean=0; + double evenLayersFinalMean=0; + for(vector::const_iterator sl = superLayers.begin(); + sl != superLayers.end(); sl++) { + + + //Compute mean for odd and even superlayers + double oddLayersMean=0; + double evenLayersMean=0; + double oddLayersDen=0; + double evenLayersDen=0; + for(map::const_iterator wiret0 = theRelativeT0PerWire.begin(); + wiret0 != theRelativeT0PerWire.end(); + ++wiret0){ + if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ + if(debug) + cout<<"[DTT0CalibrationNew] Superlayer "<<(*sl)->id() + <<"layer " <<(*wiret0).first.layerId().layer()<<" with "<<(*wiret0).second<::const_iterator wiret0 = theRelativeT0PerWire.begin(); + wiret0 != theRelativeT0PerWire.end(); + ++wiret0){ + if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ + if(((*wiret0).first.layerId().layer()) % 2){ + oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean); + } + else{ + evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean); + } + } + } + oddLayersSigma = oddLayersSigma/oddLayersDen; + evenLayersSigma = evenLayersSigma/evenLayersDen; + oddLayersSigma = sqrt(oddLayersSigma); + evenLayersSigma = sqrt(evenLayersSigma); + + if(debug && evenLayersMean) + cout<<"[DTT0CalibrationNew] Relative T0 sigma for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); + wiret0 != theRelativeT0PerWire.end(); + ++wiret0){ + if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ + if(((*wiret0).first.layerId().layer()) % 2){ + if(abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma)) + { + oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second; + oddLayersDen++; + } + } + else{ + if(abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma)) + { + evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second; + evenLayersDen++; + } + } + } + } + oddLayersFinalMean = oddLayersFinalMean/oddLayersDen; + evenLayersFinalMean = evenLayersFinalMean/evenLayersDen; + } + for(vector::const_iterator sl = superLayers.begin(); + sl != superLayers.end(); sl++) { + if(debug && oddLayersFinalMean) + cout<<"[DTT0CalibrationNew] Final relative T0 mean for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); + wiret0 != theRelativeT0PerWire.end(); + ++wiret0){ + if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ + double t0=-999; + if(((*wiret0).first.layerId().layer()) % 2) + t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean); + else + t0 = (*wiret0).second; + + //cout<<"[DTT0CalibrationNew] Wire "<<(*wiret0).first<<" has t0 "<set((*wiret0).first, t0, theSigmaT0PerWire[(*wiret0).first],DTTimeUnits::counts); + } + } + } + + ///Change t0 absolute reference -> from sector peak to chamber average + if(debug) + cout << "[DTT0CalibrationNew]Computing relative t0 wrt to chamber average" << endl; + //Compute the reference for each chamber + map sumT0ByChamber; + map countT0ByChamber; + for(DTT0::const_iterator tzero = t0s->begin(); + tzero != t0s->end(); ++tzero) { + // @@@ NEW DTT0 FORMAT + // DTChamberId chamberId((*tzero).first.wheelId, + // (*tzero).first.stationId, + // (*tzero).first.sectorId); + // sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + (*tzero).second.t0mean; + int channelId = tzero->channelId; + if ( channelId == 0 ) continue; + DTWireId wireId(channelId); + DTChamberId chamberId(wireId.chamberId()); + //sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + tzero->t0mean; + // @@@ better DTT0 usage + float t0mean_f; + float t0rms_f; + t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); + sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f; + // @@@ NEW DTT0 END + countT0ByChamber[chamberId]++; + } + //Change reference for each wire and store the new t0s in the new map + for(DTT0::const_iterator tzero = t0s->begin(); + tzero != t0s->end(); ++tzero) { + // @@@ NEW DTT0 FORMAT + // DTChamberId chamberId((*tzero).first.wheelId, + // (*tzero).first.stationId, + // (*tzero).first.sectorId); + // double t0mean = ((*tzero).second.t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); + // double t0rms = (*tzero).second.t0rms; + // DTWireId wireId((*tzero).first.wheelId, + // (*tzero).first.stationId, + // (*tzero).first.sectorId, + // (*tzero).first.slId, + // (*tzero).first.layerId, + // (*tzero).first.cellId); + int channelId = tzero->channelId; + if ( channelId == 0 ) continue; + DTWireId wireId( channelId ); + DTChamberId chamberId(wireId.chamberId()); + //double t0mean = (tzero->t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); + //double t0rms = tzero->t0rms; + // @@@ better DTT0 usage + float t0mean_f; + float t0rms_f; + t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); + double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); + double t0rms = t0rms_f; + cout<<"[DTT0CalibrationNew] Wire "<set(wireId, + t0mean, + t0rms, + DTTimeUnits::counts); + if(debug){ + //cout<<"Chamber "<t0mean<<" to "<> histoName; + return histoName; +} + +string DTT0CalibrationNew::getHistoName(const DTLayerId& lId) const { + string histoName; + stringstream theStream; + theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector() + << "_SL" << lId.superlayer() << "_L" << lId.layer() <<"_hT0Histo"; + theStream >> histoName; + return histoName; +} + diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h new file mode 100644 index 0000000000000..1c999a2979d94 --- /dev/null +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h @@ -0,0 +1,131 @@ +#ifndef CalibMuon_DTT0CalibrationNew_H +#define CalibMuon_DTT0CalibrationNew_H + +/** \class DTT0CalibrationNew + * Analyzer class computes the mean and RMS of t0 from pulses. + * Those values are written in the DB with cell granularity. The + * mean value for each channel is normalized to a reference time common to all the sector. + * The t0 of wires in odd layers are corrected for the relative difference between + * odd and even layers + * + * \author S. Bolognesi - INFN Torino + */ + +//#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include +#include +#include + +#include "TFile.h" +#include "TH1I.h" +#include "TH1D.h" +#include "TSpectrum.h" + +//class TFile; +//class TH1I; +//class TH1D; +//class TSpectrum; +class DTT0; + +class DTT0CalibrationNew : public edm::one::EDAnalyzer<> { +public: + /// Constructor + DTT0CalibrationNew(const edm::ParameterSet& pset); + + /// Destructor + virtual ~DTT0CalibrationNew(); + + // Operations + + /// Fill the maps with t0 (by channel) + void analyze(const edm::Event & event, const edm::EventSetup& eventSetup); + + /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity + void endJob(); + + +protected: + +private: + // TODO: REMOVE ME + std::set all_wires; + DTLayerId theLayer; + // Generate the histo name + std::string getHistoName(const DTWireId& wId) const; + std::string getHistoName(const DTLayerId& lId) const; + + // Debug flag + bool debug; + + // The label used to retrieve digis from the event + edm::EDGetTokenT digiToken; + + // The root file which contain the histos per layer + TFile theFile; + + //The event counter + unsigned int nevents; + //Number of events to be used for the t0 per layer histos + unsigned int eventsForLayerT0; + //Number of events to be used for the t0 reference per wire + unsigned int eventsForWireT0; + + //Acceptance of t0 w.r.t. reference peak + double tpPeakWidth; + + //Acceptance of t0 w.r.t. reference peak + double tpPeakWidthPerLayer; + + //Digi's will be rejected if too far from TP peak + unsigned int rejectDigiFromPeak; + + //The wheels,sector to be calibrated (default All) + std::string theCalibWheel; + int selWheel; + std::string theCalibSector; + int selSector; + + // Map of the histos and graph by layer + std::map theHistoLayerMap; + // TODO: REMOVE OR DOCUMENT + TH1D hLayerPeaks; + + TSpectrum spectrum; + + //Layer with histos for each wire + std::vector wireIdWithHistos; + std::vector layerIdWithWireHistos; + + //Maps with t0, sigma, number of digi per wire + std::map theAbsoluteT0PerWire; + std::map theRelativeT0PerWire; + std::map theSigmaT0PerWire; + std::map nDigiPerWire; + std::map nDigiPerWire_ref; + std::map mK; + std::map mK_ref; + std::map qK; + //Map with histo per wire for the chosen layer + std::map theHistoWireMap; + //Map with mean and RMS of t0 per layer + std::map theT0LayerMap; + std::map theSigmaT0LayerMap; + std::map theTPPeakMap; + //Ref. t0 per chamber + std::map theSumT0ByChamber; + std::map theCountT0ByChamber; + std::map theSigmaT0ByChamber; + std::map theMeanT0ByChamber; + std::map theRefT0ByChamber; + + //DTGeometry used to loop on the SL in the endJob + edm::ESHandle dtGeom; +}; +#endif + diff --git a/CalibMuon/DTCalibration/plugins/SealModule.cc b/CalibMuon/DTCalibration/plugins/SealModule.cc index 03fdafbf75848..82261521d5639 100644 --- a/CalibMuon/DTCalibration/plugins/SealModule.cc +++ b/CalibMuon/DTCalibration/plugins/SealModule.cc @@ -11,6 +11,7 @@ #include "CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h" #include "CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h" #include "CalibMuon/DTCalibration/plugins/DTT0Calibration.h" +#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" #include "CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h" #include "CalibMuon/DTCalibration/plugins/DTT0Correction.h" #include "CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h" @@ -50,6 +51,7 @@ DEFINE_FWK_MODULE(DTTTrigCorrection); DEFINE_FWK_MODULE(DTTTrigCorrectionFirst); DEFINE_FWK_MODULE(DTT0CalibrationRMS); DEFINE_FWK_MODULE(DTT0Calibration); +DEFINE_FWK_MODULE(DTT0CalibrationNew); DEFINE_FWK_MODULE(DTTPDeadWriter); DEFINE_FWK_MODULE(DTT0Correction); DEFINE_FWK_MODULE(DTVDriftCalibration); diff --git a/CalibMuon/DTCalibration/python/Workflow/DTCalibrationWorker.py b/CalibMuon/DTCalibration/python/Workflow/DTCalibrationWorker.py index aa3c31298522d..511c86090217b 100755 --- a/CalibMuon/DTCalibration/python/Workflow/DTCalibrationWorker.py +++ b/CalibMuon/DTCalibration/python/Workflow/DTCalibrationWorker.py @@ -5,6 +5,7 @@ from DTWorkflow import DTWorkflow from DTTtrigWorkflow import DTttrigWorkflow from DTVdriftWorkflow import DTvdriftWorkflow +from DTT0WireWorkflow import DTT0WireWorkflow import logging # setup logging log = logging.getLogger(__name__) @@ -15,7 +16,7 @@ class DTCalibrationWorker(object): workflows. Additional workflow classes should use the naming scheme DT${WORKFLOWNAME}Workflow and implement a classmethod function add_parser_options. """ - available_workflows = ["ttrig","vdrift"] + available_workflows = ["ttrig","vdrift","T0Wire"] def __init__(self, options): self.options = options if not self.has_crab3_env: diff --git a/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py b/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py new file mode 100644 index 0000000000000..d475ab09496a8 --- /dev/null +++ b/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py @@ -0,0 +1,129 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("PROD") + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.MessageLogger.debugModules = cms.untracked.vstring('*') +process.MessageLogger.destinations = cms.untracked.vstring('cerr') +process.MessageLogger.categories.append('resolution') +process.MessageLogger.cerr = cms.untracked.PSet( + FwkReport = cms.untracked.PSet( + limit = cms.untracked.int32(100), + reportEvery = cms.untracked.int32(1000) + ), + threshold = cms.untracked.string('DEBUG'), + noLineBreaks = cms.untracked.bool(False), + DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), + INFO = cms.untracked.PSet(limit = cms.untracked.int32(0)), + resolution = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +) + +process.load("Configuration.StandardSequences.GeometryDB_cff") +process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") +process.GlobalTag.globaltag = "" + +process.load("CondCore.CondDB.CondDB_cfi") + +process.load("DQMServices.Core.DQM_cfg") + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + '/store/data/Commissioning2018/MiniDaq/RAW/v1/000/312/774/00000/CCADE144-9431-E811-9641-FA163E220C5C.root' +# '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/540/AA9053D9-F306-E211-80A4-001D09F248F8.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/204/148CF2AC-CAD0-E111-A056-001D09F291D2.root', +### '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/132/D0E088D3-D7DC-E111-92D2-00237DDC5C24.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/198/510/0C50021A-F4C8-E111-B861-001D09F2512C.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/206/EC54DD2C-D3D0-E111-9019-5404A63886CE.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/131/E024E67D-D6DC-E111-A404-0025901D6288.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/201/074/92295641-C3E7-E111-899B-0025901D629C.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/133/ACB373F1-D9DC-E111-B891-003048F024FE.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/276/2CF5C87C-E303-E211-A314-001D09F28F25.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/535/1EEFEF95-F506-E211-A872-001D09F2906A.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/665/1C75364F-0EE3-E111-8021-BCAEC5329705.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/716/8A0AC842-A3E3-E111-A669-001D09F291D7.root' + ) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + +# process.load("CalibMuon.DTCalibration.dt_offlineAnalysis_common_cff") + +import EventFilter.DTRawToDigi.dturosunpacker_cfi +process.dtunpacker = EventFilter.DTRawToDigi.dturosunpacker_cfi.dturosunpacker.clone() + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('DTT0Rcd'), + tag = cms.string('t0') + )) +) +process.PoolDBOutputService.connect = cms.string('sqlite_file:t0.db') + +process.eventInfoProvider = cms.EDFilter("EventCoordinatesSource", + eventInfoFolder = cms.untracked.string('EventInfo/') +) + + +# test pulse monitoring +process.load("DQM.DTMonitorModule.dtDigiTask_TP_cfi") +process.load("DQM.DTMonitorClient.dtOccupancyTest_TP_cfi") +process.dtTPmonitor.readDB = False +process.dtTPmonitor.defaultTtrig = 600 +process.dtTPmonitor.defaultTmax = 100 +process.dtTPmonitor.inTimeHitsLowerBound = 0 +process.dtTPmonitor.inTimeHitsUpperBound = 0 +#file = open("tpDead.txt") +wiresToDebug = cms.untracked.vstring() +#for line in file: +# corrWire = line.split()[:6] +# #switch station/sector +# corrWire[1:3] = corrWire[2:0:-1] +# wire = ' '.join(corrWire) +# #print wire +# wiresToDebug.append(wire) +#file.close() + +process.dtT0WireCalibration = cms.EDAnalyzer("DTT0CalibrationNew", + correctByChamberMean = cms.bool(False), + # Cells for which you want the histos (default = None) + cellsWithHisto = wiresToDebug, + # Label to retrieve DT digis from the event + digiLabel = cms.untracked.string('dtunpacker'), + calibSector = cms.untracked.string('All'), + # Chose the wheel, sector (default = All) + calibWheel = cms.untracked.string('All'), + # Number of events to be used for the t0 per layer histos + eventsForWireT0 = cms.uint32(25000), #25000 + # Name of the ROOT file which will contain the test pulse times per layer + rootFileName = cms.untracked.string('DTTestPulses.root'), + debug = cms.untracked.bool(False), + rejectDigiFromPeak = cms.uint32(50), + # Acceptance for TP peak width + tpPeakWidth = cms.double(15.0), + # Number of events to be used for the t0 per layer histos + eventsForLayerT0 = cms.uint32(5000), #5000 + timeBoxWidth = cms.uint32(300), + tpPeakWidthPerLayer = cms.double(2.0) +) + +process.output = cms.OutputModule("PoolOutputModule", + outputCommands = cms.untracked.vstring('drop *', + 'keep *_MEtoEDMConverter_*_*'), + fileName = cms.untracked.string('DQM.root') +) + +process.load("DQMServices.Components.MEtoEDMConverter_cff") +#process.DQM.collectorHost = '' + +process.p = cms.Path(process.dtunpacker* + process.dtTPmonitor+process.dtTPmonitorTest+ + process.dtT0WireCalibration+ + process.MEtoEDMConverter) +process.outpath = cms.EndPath(process.output) From b7162e5845a875a4104816dffb5fe9a35e775407 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Fri, 4 May 2018 15:42:09 +0200 Subject: [PATCH 214/686] Workflow: Fix for crab submission crab submit --wait seems not to wait any more. Therefore I wait a little bit longer using sleep in order to not crash when checking the status. (cherry picked from commit a9433c2be4b35c0a239bd207eb6b5164709d92ab) --- CalibMuon/DTCalibration/python/Workflow/CrabHelper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py index 66da220102dff..3aca474730712 100644 --- a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py +++ b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py @@ -30,8 +30,9 @@ def submit_crab_task(self): #submit crab job log.info("Submitting crab job") self.crab.submit(full_crab_config_filename) - log.info("crab job submitted. Waiting 30 seconds before first status call") - time.sleep( 30 ) + log.info("crab job submitted. Waiting 120 seconds before first status call") + time.sleep( 120 ) + task = self.crabFunctions.CrabTask(crab_config = full_crab_config_filename) task.update() success_states = ( 'QUEUED', 'SUBMITTED', "COMPLETED", "FINISHED") From c4f8014204c361acb7155b675964a9a6ba0b81fe Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Tue, 8 May 2018 13:02:35 +0200 Subject: [PATCH 215/686] Workflow: Fix syntax error in vdrift workflow (cherry picked from commit 312ef957422c52e1bde470a52be61f898628384e) --- CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py b/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py index b94c7bea1c042..92bb834415a6a 100644 --- a/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py +++ b/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py @@ -29,8 +29,8 @@ def prepare_workflow(self): fill_function = getattr(self, function_name) except AttributeError: errmsg = "Class `{}` does not implement `{}`" - raise NotImplementedError( errmsg.format(my_cls.__class__.__name__, - method_name)) + raise NotImplementedError( errmsg.format(self.__class__.__name__, + function_name)) log.debug("Preparing workflow with function %s" % function_name) # call chosen function fill_function() From 669d7eedb37bc0543b9b3587051421c0491879b4 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Tue, 8 May 2018 13:03:09 +0200 Subject: [PATCH 216/686] VDrift: Add consume to MeanTimer A consumes needeed to be added in order to run in CMSSW10. (cherry picked from commit dcff4bc2188bd5ab75af6de84860dadb1a513c03) --- CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc | 5 ++--- CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc index 22abf52c60774..fd545224da7b9 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc @@ -19,7 +19,6 @@ #include "CalibMuon/DTDigiSync/interface/DTTTrigSyncFactory.h" #include "CalibMuon/DTDigiSync/interface/DTTTrigBaseSync.h" -#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" #include "CondFormats/DTObjects/interface/DTMtime.h" #include "CondFormats/DataRecord/interface/DTStatusFlagRcd.h" @@ -53,7 +52,7 @@ DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset): { // The name of the 4D rec hits collection - theRecHits4DLabel = pset.getParameter("recHits4DLabel"); + theRecHits4DToken = (consumes(pset.getParameter("recHits4DLabel"))); // The root file which will contain the histos string rootFileName = pset.getUntrackedParameter("rootFileName"); @@ -131,7 +130,7 @@ void DTVDriftCalibration::analyze(const Event & event, const EventSetup& eventSe // Get the rechit collection from the event Handle all4DSegments; - event.getByLabel(theRecHits4DLabel, all4DSegments); + event.getByToken(theRecHits4DToken, all4DSegments); // Get the map of noisy channels /*ESHandle statusMap; diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h index 2f9e2a1153d21..3ac8530bac561 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h @@ -11,6 +11,7 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" #include "CalibMuon/DTCalibration/interface/vDriftHistos.h" #include "CalibMuon/DTCalibration/interface/DTTMax.h" @@ -88,7 +89,7 @@ class DTVDriftCalibration : public edm::EDAnalyzer { TMaxGranularity theGranularity; // The label used to retrieve 4D segments from the event - edm::InputTag theRecHits4DLabel; + edm::EDGetTokenT theRecHits4DToken; // Debug flag bool debug; From 683f740fb691b7cde61f9a5636c163c990a09754 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Tue, 8 May 2018 13:03:50 +0200 Subject: [PATCH 217/686] Vdrift Mean Timer Added to Workflow The Mean Timer can now be submitted using the workflow tool. As I do not fully understand the vdrift meantimer code I did not check if everything works correctly (e.g. importing ttrig dbs). (cherry picked from commit bb54b38b45e7dd2ac6b3cb16ac246a3864188c03) --- .../python/Workflow/DTVdriftWorkflow.py | 133 +++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py b/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py index 92bb834415a6a..237380374b2f7 100644 --- a/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py +++ b/CalibMuon/DTCalibration/python/Workflow/DTVdriftWorkflow.py @@ -14,9 +14,11 @@ def __init__(self, options): super( DTvdriftWorkflow, self ).__init__( options ) self.outpath_command_tag = "VdriftCalibration" - output_file_dict ={ "segment" : "DTVDriftHistos.root", + output_file_dict = { "segment" : "DTVDriftHistos.root", + "meantimer" : "DTTMaxHistos.root", } - self.outpath_workflow_mode_dict = { "segment" : "Segments" + self.outpath_workflow_mode_dict = { "segment" : "Segments", + "meantimer" : "MeanTimer", } self.output_file = output_file_dict[self.options.workflow_mode] self.output_files = [self.output_file] @@ -109,6 +111,83 @@ def prepare_segment_all(self): # main implementation of all self.all_commands=["submit", "check", "write", "dump"] + #################################################################### + # Mean Timer # + #################################################################### + def prepare_meantimer_submit(self): + self.pset_name = 'dtVDriftMeanTimerCalibration_cfg.py' + self.pset_template = 'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_cfg' + if self.options.datasettype == "Cosmics": + self.pset_template = 'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_cosmics_cfg' + + self.process = tools.loadCmsProcess(self.pset_template) + self.process.GlobalTag.globaltag = self.options.globaltag + self.process.dtVDriftMeanTimerCalibration.rootFileName = self.output_file + + if self.options.inputCalibDB: + err = "Option inputCalibDB not available for meantimer." + err += "Maybe you want to use option inputTtrigDB" + raise ValueError(err) + self.prepare_common_submit() + if self.options.inputTtrigDB: + label = '' + if self.options.datasettype == "Cosmics": + label = 'cosmics' + connect = os.path.basename(self.options.inputTtrigDB) + self.addPoolDBESSource( process = self.process, + moduleName = 'tTrigDB', + record = 'DTTtrigRcd', + tag = 'ttrig', + connect = str("sqlite_file:%s" % connect), + label = label + ) + self.input_files.append( os.path.abspath(self.options.inputTtrigDB) ) + self.write_pset_file() + + def prepare_meantimer_check(self): + self.load_options_command("submit") + + def prepare_meantimer_write(self): + self.pset_name = 'dtVDriftMeanTimerWriter_cfg.py' + self.pset_template = 'CalibMuon.DTCalibration.dtVDriftMeanTimerWriter_cfg' + tag = self.prepare_common_write() + merged_file = os.path.join(self.result_path, self.output_file) + self.process = tools.loadCmsProcess(self.pset_template) + + if self.options.inputVDriftDB: + self.add_local_vdrift_db(self) + vdrift_db = "vDrift_meantimer" + tag + ".db" + vdrift_db = os.path.join(self.result_path, vdrift_db) + self.process.dtVDriftMeanTimerWriter.vDriftAlgoConfig.rootFileName = "file:///" + merged_file + self.process.PoolDBOutputService.connect = 'sqlite_file:%s' % vdrift_db + self.process.source.firstRun = cms.untracked.uint32(self.options.run) + self.process.GlobalTag.globaltag = cms.string(str(self.options.globaltag)) + self.write_pset_file() + + def prepare_meantimer_dump(self): + self.pset_name = 'dumpDBToFile_vdrift_cfg.py' + self.pset_template = 'CalibMuon.DTCalibration.dumpDBToFile_vdrift_cfg' + if self.options.input_dumpDB: + try: + test = self.result_path + self.load_options_command("write") + except: + pass + dbpath = os.path.abspath(self.options.input_dumpDB) + else: + crabtask = self.crabFunctions.CrabTask(crab_config = self.crab_config_filepath, + initUpdate = False) + tag = crabtask.crabConfig.Data.outputDatasetTag + dbpath = os.path.abspath( os.path.join(self.result_path, + "vDrift_meantimer" + tag + ".db")) + self.prepare_common_dump(dbpath) + self.write_pset_file() + + def prepare_meantimer_all(self): + # individual prepare functions for all tasks will be called in + # main implementation of all + self.all_commands=["submit", "check", "write", "dump"] + #################################################################### # CLI creation # #################################################################### @@ -127,6 +206,9 @@ def add_parser_options(cls, subparser_container): vdrift_segment_subparser = vdrift_subparsers.add_parser( "segment", #parents=[mutual_parent_parser, common_parent_parser], help = "" ) + vdrift_meantimer_subparser = vdrift_subparsers.add_parser( "meantimer", + #parents=[mutual_parent_parser, common_parent_parser], + help = "" ) ################################################################ # Sub parser options for workflow mode segment # ################################################################ @@ -174,3 +256,50 @@ def add_parser_options(cls, subparser_container): help = "Perform all steps: submit, check, write, dump in this order") vdrift_segment_all_parser.add_argument("--inputTtrigDB", help="Local alternative calib ttrig db") + ################################################################ + # Sub parser options for workflow mode meantimer # + ################################################################ + vdrift_meantimer_subparsers = vdrift_meantimer_subparser.add_subparsers( dest="command", + help="Possible commands for meantimers") + vdrift_meantimer_submit_parser = vdrift_meantimer_subparsers.add_parser( + "submit", + parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(), + super(DTvdriftWorkflow,cls).get_submission_options_parser(), + super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(), + super(DTvdriftWorkflow,cls).get_input_db_options_parser()], + help = "Submit job to the GRID via crab3") + vdrift_meantimer_submit_parser.add_argument("--inputTtrigDB", + help="Local alternative calib ttrig db") + + vdrift_meantimer_check_parser = vdrift_meantimer_subparsers.add_parser( + "check", + parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(), + super(DTvdriftWorkflow,cls).get_check_options_parser()], + help = "Check status of submitted jobs") + + vdrift_meantimer_write_parser = vdrift_meantimer_subparsers.add_parser( + "write", + parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(), + super(DTvdriftWorkflow,cls).get_write_options_parser() + ], + help = "Write result from root output to text file") + + vdrift_meantimer_dump_parser = vdrift_meantimer_subparsers.add_parser( + "dump", + parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(), + super(DTvdriftWorkflow,cls).get_dump_options_parser()], + help = "Dump database to text file") + + vdrift_meantimer_all_parser = vdrift_meantimer_subparsers.add_parser( + "all", + parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(), + super(DTvdriftWorkflow,cls).get_submission_options_parser(), + super(DTvdriftWorkflow,cls).get_check_options_parser(), + super(DTvdriftWorkflow,cls).get_input_db_options_parser(), + super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(), + super(DTvdriftWorkflow,cls).get_write_options_parser(), + super(DTvdriftWorkflow,cls).get_dump_options_parser() + ], + help = "Perform all steps: submit, check, write, dump in this order") + vdrift_meantimer_all_parser.add_argument("--inputTtrigDB", + help="Local alternative calib ttrig db") From 24ecc068c223900daae5051b98927a24358eb1f3 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Wed, 6 Jun 2018 09:26:07 +0200 Subject: [PATCH 218/686] Workflow: Commit of T0 Workflow (previously forgotten) One may want to rebase this commit. (cherry picked from commit ce787b667fc1af16f269c94e2b368f4265b97fc1) --- .../python/Workflow/DTT0WireWorkflow.py | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py diff --git a/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py b/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py new file mode 100644 index 0000000000000..d446e33e082cd --- /dev/null +++ b/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py @@ -0,0 +1,93 @@ +import os +import logging + +import tools +import FWCore.ParameterSet.Config as cms +from DTWorkflow import DTWorkflow + +log = logging.getLogger(__name__) + +class DTT0WireWorkflow(DTWorkflow): + """ This class creates and performce / submits vdrift workflow jobs""" + def __init__(self, options): + # call parent constructor + super(DTT0WireWorkflow, self).__init__(options) + + self.outpath_command_tag = "T0WireCalibration" + self.outpath_workflow_mode_dict = {"all" : "All"} + self.output_file = 'DTTestPulses.root' + self.output_files = ['t0.db', self.output_file, 'DQM.root'] + + def prepare_workflow(self): + """ Generalized function to prepare workflow dependent on workflow mode""" + function_name = "prepare_" + self.options.workflow_mode + "_" + self.options.command + + try: + fill_function = getattr(self, function_name) + except AttributeError: + errmsg = "Class `{}` does not implement `{}`" + raise NotImplementedError(errmsg.format(my_cls.__class__.__name__, + method_name)) + log.debug("Preparing workflow with function %s" % function_name) + # call chosen function + fill_function() + + def prepare_all_submit(self): + self.pset_name = 'dtT0WireCalibrationNew_cfg.py' + self.pset_template = 'CalibMuon.DTCalibration.dtT0WireCalibrationNew_cfg' + + self.process = tools.loadCmsProcess(self.pset_template) + self.process.GlobalTag.globaltag = self.options.globaltag + self.process.dtT0WireCalibration.rootFileName = self.output_file + + self.prepare_common_submit() + self.write_pset_file() + + def prepare_all_all(self): + # individual prepare functions for all tasks will be called in + # main implementation of all + self.all_commands=["submit"] + + def submit(self): + # Overload to run locally + self.runCMSSWtask() + + #################################################################### + # CLI creation # + #################################################################### + @classmethod + def add_parser_options(cls, subparser_container): + vdrift_parser = subparser_container.add_parser( "T0Wire", + #parents=[mutual_parent_parser, common_parent_parser], + help = "" ) # What does ttrig + + ################################################################ + # Sub parser options for workflow modes # + ################################################################ + vdrift_subparsers = vdrift_parser.add_subparsers( dest="workflow_mode", + help="Possible workflow modes",) + ## Add all workflow modes for ttrig + vdrift_segment_subparser = vdrift_subparsers.add_parser( "all", + #parents=[mutual_parent_parser, common_parent_parser], + help = "" ) + ################################################################ + # Sub parser options for workflow mode segment # + ################################################################ + vdrift_segment_subparsers = vdrift_segment_subparser.add_subparsers( dest="command", + help="Possible commands for all") + vdrift_segment_submit_parser = vdrift_segment_subparsers.add_parser( + "submit", + parents=[super(DTT0WireWorkflow,cls).get_common_options_parser(), + super(DTT0WireWorkflow,cls).get_submission_options_parser(), + super(DTT0WireWorkflow,cls).get_local_input_db_options_parser(), + super(DTT0WireWorkflow,cls).get_input_db_options_parser()], + help = "Run job locally as GRID submission is not supported for T0 Calibration") + + vdrift_segment_all_parser = vdrift_segment_subparsers.add_parser( + "all", + parents=[super(DTT0WireWorkflow,cls).get_common_options_parser(), + super(DTT0WireWorkflow,cls).get_submission_options_parser(), + super(DTT0WireWorkflow,cls).get_input_db_options_parser(), + super(DTT0WireWorkflow,cls).get_local_input_db_options_parser(), + ], + help = "Perform all steps: submit, check in this order") From d48cc731e97cfbc1b51234823b5ea7c6bebb7c87 Mon Sep 17 00:00:00 2001 From: Saranya Ghosh Date: Fri, 27 Jul 2018 05:22:09 +0200 Subject: [PATCH 219/686] Consolidated updates for DT Calibration (cherry picked from commit 8db25b77d07516f4da4024934df52539559a2966) --- .../interface/DTSegmentSelector.h | 16 +- .../plugins/DTResidualCalibration.cc | 44 +-- .../plugins/DTResidualCalibration.cc.old | 317 +++++++++++++++ .../plugins/DTResidualCalibration.h | 10 +- .../plugins/DTTTrigOffsetCalibration.cc | 6 +- .../plugins/DTTTrigOffsetCalibration.h | 2 +- .../plugins/DTVDriftCalibration.cc | 15 +- .../plugins/DTVDriftCalibration.h | 2 +- .../plugins/DTVDriftSegmentCalibration.cc | 6 +- .../plugins/DTVDriftSegmentCalibration.h | 2 +- .../python/Workflow/CLIHelper.py | 2 + .../python/Workflow/CrabHelper.py | 3 + .../python/Workflow/DTTtrigWorkflow.py | 7 +- .../python/Workflow/addPoolDBESSource.py | 18 + .../python/dtCalibValidationFromMuons_cfg.py | 42 ++ .../python/dtCalibValidationFromMuons_cfi.py | 23 ++ .../python/dtResidualCalibration_cfi.py | 13 +- .../python/dtSegmentSelection_cfi.py | 1 + .../scripts/allPlotsResiduals.py | 89 +++++ .../DTCalibration/src/DTSegmentSelector.cc | 56 ++- .../interface/DTCalibValidationFromMuons.h | 117 ++++++ DQM/DTMonitorModule/plugins/plugins.cc | 9 + .../src/DTCalibValidationFromMuons.cc | 374 ++++++++++++++++++ 23 files changed, 1100 insertions(+), 74 deletions(-) create mode 100644 CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old create mode 100644 CalibMuon/DTCalibration/python/Workflow/addPoolDBESSource.py create mode 100644 CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfg.py create mode 100644 CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfi.py create mode 100755 CalibMuon/DTCalibration/scripts/allPlotsResiduals.py create mode 100644 DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h create mode 100644 DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc diff --git a/CalibMuon/DTCalibration/interface/DTSegmentSelector.h b/CalibMuon/DTCalibration/interface/DTSegmentSelector.h index 4149d879d3609..7ff808a0fb2fd 100644 --- a/CalibMuon/DTCalibration/interface/DTSegmentSelector.h +++ b/CalibMuon/DTCalibration/interface/DTSegmentSelector.h @@ -5,10 +5,15 @@ * \author A. Vilela Pereira */ +#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" #include @@ -18,20 +23,15 @@ class DTStatusFlag; class DTSegmentSelector { public: - DTSegmentSelector(edm::ParameterSet const& pset): - checkNoisyChannels_(pset.getParameter("checkNoisyChannels")), - minHitsPhi_(pset.getParameter("minHitsPhi")), - minHitsZ_(pset.getParameter("minHitsZ")), - maxChi2_(pset.getParameter("maxChi2")), - maxAnglePhi_(pset.getParameter("maxAnglePhi")), - maxAngleZ_(pset.getParameter("maxAngleZ")) { - } + DTSegmentSelector(edm::ParameterSet const& pset, edm::ConsumesCollector& iC); ~DTSegmentSelector() {} bool operator() (DTRecSegment4D const&, edm::Event const&, edm::EventSetup const&); private: bool checkNoisySegment(edm::ESHandle const&, std::vector const&); + edm::InputTag muonTags_; + edm::EDGetTokenT muonToken_; bool checkNoisyChannels_; int minHitsPhi_; int minHitsZ_; diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc index 420a66d246c34..481e65bcc70cb 100644 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc @@ -32,12 +32,14 @@ #include DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset): - select_(pset), histRange_(pset.getParameter("histogramRange")), segment4DLabel_(pset.getParameter("segment4DLabel")), rootBaseDir_(pset.getUntrackedParameter("rootBaseDir","DT/Residuals")), detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis",false)) { + edm::ConsumesCollector collector(consumesCollector()); + select_ = new DTSegmentSelector(pset,collector); + LogDebug("Calibration") << "[DTResidualCalibration] Constructor called."; consumes< DTRecSegment4DCollection >(edm::InputTag(segment4DLabel_)); std::string rootFileName = pset.getUntrackedParameter("rootFileName","residuals.root"); @@ -50,6 +52,7 @@ DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset): } DTResidualCalibration::~DTResidualCalibration() { + delete select_; edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Destructor called."; edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Analyzed events: " << nevent; edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Good segments: " << segmok; @@ -86,6 +89,7 @@ void DTResidualCalibration::beginRun(const edm::Run& run, const edm::EventSetup& } void DTResidualCalibration::analyze(const edm::Event& event, const edm::EventSetup& setup) { + rootFile_->cd(); ++nevent; @@ -108,7 +112,7 @@ void DTResidualCalibration::analyze(const edm::Event& event, const edm::EventSet LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); - if( !select_(*segment, event, setup) ) { segmbad++; continue; } + if( !(*select_)(*segment, event, setup) ) { segmbad++; continue; } segmok++; // Get all 1D RecHits at step 3 within the 4D segment @@ -179,8 +183,8 @@ void DTResidualCalibration::endJob(){ rootFile_->Write(); rootFile_->Close(); - /*std::map >::const_iterator itSlHistos = histoMapTH1F_.begin(); - std::map >::const_iterator itSlHistos_end = histoMapTH1F_.end(); + /*std::map::const_iterator itSlHistos = histoMapTH1F_.begin(); + std::map::const_iterator itSlHistos_end = histoMapTH1F_.end(); for(; itSlHistos != itSlHistos_end; ++itSlHistos){ std::vector::const_iterator itHistTH1F = (*itSlHistos).second.begin(); std::vector::const_iterator itHistTH1F_end = (*itSlHistos).second.end(); @@ -230,14 +234,12 @@ void DTResidualCalibration::bookHistos(DTSuperLayerId slId) { sectorDir->cd(); // Create the monitor elements - std::vector histosTH1F; - histosTH1F.push_back(new TH1F(("hResDist"+slHistoName).c_str(), + TH1F* histosTH1F = new TH1F(("hResDist"+slHistoName).c_str(), "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", - 200, -histRange_, histRange_)); - std::vector histosTH2F; - histosTH2F.push_back(new TH2F(("hResDistVsDist"+slHistoName).c_str(), + 200, -histRange_, histRange_); + TH2F* histosTH2F = new TH2F(("hResDistVsDist"+slHistoName).c_str(), "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", - 100, 0, 2.5, 200, -histRange_, histRange_)); + 100, 0, 2.5, 200, -histRange_, histRange_); histoMapTH1F_[slId] = histosTH1F; histoMapTH2F_[slId] = histosTH2F; } @@ -283,14 +285,12 @@ void DTResidualCalibration::bookHistos(DTLayerId layerId) { superLayerDir->cd(); // Create histograms - std::vector histosTH1F; - histosTH1F.push_back(new TH1F(("hResDist"+layerHistoName).c_str(), + TH1F* histosTH1F = new TH1F(("hResDist"+layerHistoName).c_str(), "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", - 200, -histRange_, histRange_)); - std::vector histosTH2F; - histosTH2F.push_back(new TH2F(("hResDistVsDist"+layerHistoName).c_str(), + 200, -histRange_, histRange_); + TH2F* histosTH2F = new TH2F(("hResDistVsDist"+layerHistoName).c_str(), "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", - 100, 0, 2.5, 200, -histRange_, histRange_)); + 100, 0, 2.5, 200, -histRange_, histRange_); histoMapPerLayerTH1F_[layerId] = histosTH1F; histoMapPerLayerTH2F_[layerId] = histosTH2F; } @@ -299,19 +299,15 @@ void DTResidualCalibration::bookHistos(DTLayerId layerId) { void DTResidualCalibration::fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance) { - std::vector const& histosTH1F = histoMapTH1F_[slId]; - std::vector const& histosTH2F = histoMapTH2F_[slId]; - histosTH1F[0]->Fill(residualOnDistance); - histosTH2F[0]->Fill(distance, residualOnDistance); + histoMapTH1F_[slId]->Fill(residualOnDistance); + histoMapTH2F_[slId]->Fill(distance, residualOnDistance); } // Fill a set of histograms for a given layer void DTResidualCalibration::fillHistos(DTLayerId layerId, float distance, float residualOnDistance) { - std::vector const& histosTH1F = histoMapPerLayerTH1F_[layerId]; - std::vector const& histosTH2F = histoMapPerLayerTH2F_[layerId]; - histosTH1F[0]->Fill(residualOnDistance); - histosTH2F[0]->Fill(distance, residualOnDistance); + histoMapPerLayerTH1F_[layerId]->Fill(residualOnDistance); + histoMapPerLayerTH2F_[layerId]->Fill(distance, residualOnDistance); } diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old new file mode 100644 index 0000000000000..c1b1f65d8b655 --- /dev/null +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old @@ -0,0 +1,317 @@ + +/* + * See header file for a description of this class. + * + */ + +#include "DTResidualCalibration.h" + +// Framework +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +//Geometry +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +//RecHit +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" + +#include "CommonTools/Utils/interface/TH1AddDirectorySentry.h" +#include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h" +#include "CalibMuon/DTCalibration/interface/DTRecHitSegmentResidual.h" + +#include "TFile.h" +#include "TH1F.h" +#include "TH2F.h" + +#include + +DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset): + select_(pset), + histRange_(pset.getParameter("histogramRange")), + segment4DLabel_(pset.getParameter("segment4DLabel")), + rootBaseDir_(pset.getUntrackedParameter("rootBaseDir","DT/Residuals")), + detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis",false)) { + + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Constructor called."; + consumes< DTRecSegment4DCollection >(edm::InputTag(segment4DLabel_)); + std::string rootFileName = pset.getUntrackedParameter("rootFileName","residuals.root"); + rootFile_ = new TFile(rootFileName.c_str(), "RECREATE"); + rootFile_->cd(); + + segmok=0; + segmbad=0; + nevent=0; +} + +DTResidualCalibration::~DTResidualCalibration() { + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Destructor called."; + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Analyzed events: " << nevent; + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Good segments: " << segmok; + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Bad segments: " << segmbad; +} + +void DTResidualCalibration::beginJob() { + TH1::SetDefaultSumw2(true); +} + +void DTResidualCalibration::beginRun(const edm::Run& run, const edm::EventSetup& setup) { + + // get the geometry + edm::ESHandle dtGeomH; + setup.get().get(dtGeomH); + dtGeom_ = dtGeomH.product(); + + // Loop over all the chambers + if(histoMapTH1F_.empty()) { + for (auto ch_it : dtGeom_->chambers()) { + // Loop over the SLs + for (auto sl_it : ch_it->superLayers()) { + DTSuperLayerId slId = (sl_it)->id(); + bookHistos(slId); + if(detailedAnalysis_) { + for (auto layer_it : (sl_it)->layers()) { + DTLayerId layerId = (layer_it)->id(); + bookHistos(layerId); + } + } + } + } + } +} + +void DTResidualCalibration::analyze(const edm::Event& event, const edm::EventSetup& setup) { + rootFile_->cd(); + ++nevent; + + // Get the 4D rechits from the event + edm::Handle segments4D; + event.getByLabel(segment4DLabel_, segments4D); + + // Loop over segments by chamber + DTRecSegment4DCollection::id_iterator chamberIdIt; + for(chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt){ + + const DTChamber* chamber = dtGeom_->chamber(*chamberIdIt); + + // Get the range for the corresponding ChamberId + DTRecSegment4DCollection::range range = segments4D->get((*chamberIdIt)); + // Loop over the rechits of this DetUnit + for(DTRecSegment4DCollection::const_iterator segment = range.first; + segment != range.second; ++segment){ + + LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() + << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); + + if( !select_(*segment, event, setup) ) { segmbad++; continue; } + segmok++; + + // Get all 1D RecHits at step 3 within the 4D segment + std::vector recHits1D_S3; + + if( (*segment).hasPhi() ){ + const DTChamberRecSegment2D* phiSeg = (*segment).phiSegment(); + const std::vector& phiRecHits = phiSeg->specificRecHits(); + std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3)); + } + + if( (*segment).hasZed() ){ + const DTSLRecSegment2D* zSeg = (*segment).zSegment(); + const std::vector& zRecHits = zSeg->specificRecHits(); + std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3)); + } + + // Loop over 1D RecHit inside 4D segment + for(std::vector::const_iterator recHit1D = recHits1D_S3.begin(); + recHit1D != recHits1D_S3.end(); ++recHit1D) { + const DTWireId wireId = recHit1D->wireId(); + + float segmDistance = segmentToWireDistance(*recHit1D,*segment); + if(segmDistance > 2.1) LogTrace("Calibration") << "WARNING: segment-wire distance: " << segmDistance; + else LogTrace("Calibration") << "segment-wire distance: " << segmDistance; + + float residualOnDistance = DTRecHitSegmentResidual().compute(dtGeom_,*recHit1D,*segment); + LogTrace("Calibration") << "Wire Id " << wireId << " residual on distance: " << residualOnDistance; + + fillHistos(wireId.superlayerId(), segmDistance, residualOnDistance); + if(detailedAnalysis_) fillHistos(wireId.layerId(), segmDistance, residualOnDistance); + } + } + } +} + +float DTResidualCalibration::segmentToWireDistance(const DTRecHit1D& recHit1D, const DTRecSegment4D& segment){ + + // Get the layer and the wire position + const DTWireId wireId = recHit1D.wireId(); + const DTLayer* layer = dtGeom_->layer(wireId); + float wireX = layer->specificTopology().wirePosition(wireId.wire()); + + // Extrapolate the segment to the z of the wire + // Get wire position in chamber RF + // (y and z must be those of the hit to be coherent in the transf. of RF in case of rotations of the layer alignment) + LocalPoint wirePosInLay(wireX,recHit1D.localPosition().y(),recHit1D.localPosition().z()); + GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay); + const DTChamber* chamber = dtGeom_->chamber(wireId.layerId().chamberId()); + LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob); + + // Segment position at Wire z in chamber local frame + LocalPoint segPosAtZWire = segment.localPosition() + segment.localDirection()*wirePosInChamber.z()/cos(segment.localDirection().theta()); + + // Compute the distance of the segment from the wire + int sl = wireId.superlayer(); + float segmDistance = -1; + if(sl == 1 || sl == 3) segmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x()); + else if(sl == 2) segmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y()); + + return segmDistance; +} + +void DTResidualCalibration::endJob(){ + + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Writing histos to file."; + rootFile_->cd(); + rootFile_->Write(); + rootFile_->Close(); + + /*std::map >::const_iterator itSlHistos = histoMapTH1F_.begin(); + std::map >::const_iterator itSlHistos_end = histoMapTH1F_.end(); + for(; itSlHistos != itSlHistos_end; ++itSlHistos){ + std::vector::const_iterator itHistTH1F = (*itSlHistos).second.begin(); + std::vector::const_iterator itHistTH1F_end = (*itSlHistos).second.end(); + for(; itHistTH1F != itHistTH1F_end; ++itHistTH1F) (*itHistTH1F)->Write(); + + std::vector::const_iterator itHistTH2F = histoMapTH2F_[(*itSlHistos).first].begin(); + std::vector::const_iterator itHistTH2F_end = histoMapTH2F_[(*itSlHistos).first].end(); + for(; itHistTH2F != itHistTH2F_end; ++itHistTH2F) (*itHistTH2F)->Write(); + }*/ + +} + +void DTResidualCalibration::bookHistos(DTSuperLayerId slId) { + TH1AddDirectorySentry addDir; + rootFile_->cd(); + + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for SL: " << slId; + + // Compose the chamber name + // Define the step + int step = 3; + + std::string wheelStr = std::to_string(slId.wheel()); + std::string stationStr = std::to_string(slId.station()); + std::string sectorStr = std::to_string(slId.sector()); + + std::string slHistoName = + "_STEP" + std::to_string(step) + + "_W" + wheelStr + + "_St" + stationStr + + "_Sec" + sectorStr + + "_SL" + std::to_string(slId.superlayer()); + + edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; + TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); + if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); + TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); + if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); + TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); + if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); + TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); + if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); + + sectorDir->cd(); + + // Create the monitor elements + std::vector histosTH1F; + histosTH1F.push_back(new TH1F(("hResDist"+slHistoName).c_str(), + "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", + 200, -histRange_, histRange_)); + std::vector histosTH2F; + histosTH2F.push_back(new TH2F(("hResDistVsDist"+slHistoName).c_str(), + "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", + 100, 0, 2.5, 200, -histRange_, histRange_)); + histoMapTH1F_[slId] = histosTH1F; + histoMapTH2F_[slId] = histosTH2F; +} + +void DTResidualCalibration::bookHistos(DTLayerId layerId) { + TH1AddDirectorySentry addDir; + rootFile_->cd(); + + edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for layer: " << layerId; + + // Compose the chamber name + std::string wheelStr = std::to_string(layerId.wheel()); + std::string stationStr = std::to_string(layerId.station()); + std::string sectorStr = std::to_string(layerId.sector()); + std::string superLayerStr = std::to_string(layerId.superlayer()); + std::string layerStr = std::to_string(layerId.layer()); + // Define the step + int step = 3; + + std::string layerHistoName = + "_STEP" + std::to_string(step) + + "_W" + wheelStr + + "_St" + stationStr + + "_Sec" + sectorStr + + "_SL" + superLayerStr + + "_Layer" + layerStr; + + edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; + TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); + if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); + TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); + if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); + TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); + if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); + TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); + if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); + edm::LogVerbatim("Calibration") << "Accessing " << ("SL" + superLayerStr); + TDirectory* superLayerDir = sectorDir->GetDirectory(("SL" + superLayerStr).c_str()); + if(!superLayerDir) superLayerDir = sectorDir->mkdir(("SL" + superLayerStr).c_str()); + + superLayerDir->cd(); + // Create histograms + std::vector histosTH1F; + histosTH1F.push_back(new TH1F(("hResDist"+layerHistoName).c_str(), + "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", + 200, -histRange_, histRange_)); + std::vector histosTH2F; + histosTH2F.push_back(new TH2F(("hResDistVsDist"+layerHistoName).c_str(), + "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", + 100, 0, 2.5, 200, -histRange_, histRange_)); + histoMapPerLayerTH1F_[layerId] = histosTH1F; + histoMapPerLayerTH2F_[layerId] = histosTH2F; +} + +// Fill a set of histograms for a given SL +void DTResidualCalibration::fillHistos(DTSuperLayerId slId, + float distance, + float residualOnDistance) { + std::vector const& histosTH1F = histoMapTH1F_[slId]; + std::vector const& histosTH2F = histoMapTH2F_[slId]; + histosTH1F[0]->Fill(residualOnDistance); + histosTH2F[0]->Fill(distance, residualOnDistance); +} + +// Fill a set of histograms for a given layer +void DTResidualCalibration::fillHistos(DTLayerId layerId, + float distance, + float residualOnDistance) { + std::vector const& histosTH1F = histoMapPerLayerTH1F_[layerId]; + std::vector const& histosTH2F = histoMapPerLayerTH2F_[layerId]; + histosTH1F[0]->Fill(residualOnDistance); + histosTH2F[0]->Fill(distance, residualOnDistance); +} + diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h index 3230c6b0e7bce..636c39ad30434 100644 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.h @@ -52,7 +52,7 @@ class DTResidualCalibration: public edm::EDAnalyzer{ void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance); void fillHistos(DTLayerId slId, float distance, float residualOnDistance); - DTSegmentSelector select_; + DTSegmentSelector *select_; double histRange_; edm::InputTag segment4DLabel_; std::string rootBaseDir_; @@ -62,10 +62,10 @@ class DTResidualCalibration: public edm::EDAnalyzer{ // Geometry const DTGeometry* dtGeom_; // Histograms per super-layer - std::map > histoMapTH1F_; - std::map > histoMapTH2F_; + std::map histoMapTH1F_; + std::map histoMapTH2F_; // Histograms per layer - std::map > histoMapPerLayerTH1F_; - std::map > histoMapPerLayerTH2F_; + std::map histoMapPerLayerTH1F_; + std::map histoMapPerLayerTH2F_; }; #endif diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc index ba9989696dd7f..f7f7dac88c8cc 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.cc @@ -35,7 +35,6 @@ using namespace std; using namespace edm; DTTTrigOffsetCalibration::DTTTrigOffsetCalibration(const ParameterSet& pset): - select_(pset), theRecHits4DLabel_(pset.getParameter("recHits4DLabel")), doTTrigCorrection_(pset.getUntrackedParameter("doT0SegCorrection", false)), theCalibChamber_(pset.getUntrackedParameter("calibChamber", "All")), @@ -43,6 +42,9 @@ DTTTrigOffsetCalibration::DTTTrigOffsetCalibration(const ParameterSet& pset): LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Constructor called!"; + edm::ConsumesCollector collector(consumesCollector()); + select_ = new DTSegmentSelector(pset,collector); + // the root file which will contain the histos string rootFileName = pset.getUntrackedParameter("rootFileName","DTT0SegHistos.root"); rootFile_ = new TFile(rootFileName.c_str(), "RECREATE"); @@ -110,7 +112,7 @@ void DTTTrigOffsetCalibration::analyze(const Event & event, const EventSetup& ev LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); - if( !select_(*segment, event, eventSetup) ) continue; + if( !(*select_)(*segment, event, eventSetup) ) continue; // Fill t0-seg values if( (*segment).hasPhi() ) { diff --git a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h index 41fea61ada548..2698a3206bdce 100644 --- a/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTTTrigOffsetCalibration.h @@ -39,7 +39,7 @@ class DTTTrigOffsetCalibration : public edm::EDAnalyzer { typedef std::map > ChamberHistosMap; void bookHistos(DTChamberId); - DTSegmentSelector select_; + DTSegmentSelector *select_; edm::InputTag theRecHits4DLabel_; bool doTTrigCorrection_; diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc index fd545224da7b9..3f32cc973c88c 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc @@ -44,12 +44,10 @@ using namespace edm; using namespace dttmaxenums; -DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset): - select_(pset), - // Get the synchronizer - theSync{DTTTrigSyncFactory::get()->create(pset.getParameter("tTrigMode"), - pset.getParameter("tTrigModeConfig"))} -{ +DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset) { + + edm::ConsumesCollector collector(consumesCollector()); + select_ = std::make_unique(pset,collector); // The name of the 4D rec hits collection theRecHits4DToken = (consumes(pset.getParameter("recHits4DLabel"))); @@ -79,6 +77,9 @@ DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset): // the txt file which will contain the calibrated constants theVDriftOutputFile = pset.getUntrackedParameter("vDriftFileName"); + // Get the synchronizer + theSync{DTTTrigSyncFactory::get()->create(pset.getParameter("tTrigMode"), + pset.getParameter("tTrigModeConfig"))} // get parameter set for DTCalibrationMap constructor theCalibFilePar = pset.getUntrackedParameter("calibFileConfig"); @@ -170,7 +171,7 @@ void DTVDriftCalibration::analyze(const Event & event, const EventSetup& eventSe LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); - if( !select_(*segment, event, eventSetup) ) continue; + if( !((*select_)(*segment, event, eventSetup)) ) continue; LocalPoint phiSeg2DPosInCham; LocalVector phiSeg2DDirInCham; diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h index 3ac8530bac561..17246c543dc07 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h @@ -49,7 +49,7 @@ class DTVDriftCalibration : public edm::EDAnalyzer { private: - DTSegmentSelector select_; + DTSegmentSelector *select_; // The class containing TMax information typedef DTTMax::TMax TMax; diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc index 828bcfa548ca0..17c6c37a5d330 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.cc @@ -32,12 +32,14 @@ using namespace std; using namespace edm; DTVDriftSegmentCalibration::DTVDriftSegmentCalibration(const ParameterSet& pset): - select_(pset), theRecHits4DLabel_(pset.getParameter("recHits4DLabel")), //writeVDriftDB_(pset.getUntrackedParameter("writeVDriftDB", false)), theCalibChamber_(pset.getUntrackedParameter("calibChamber", "All")) { LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Constructor called!"; + + edm::ConsumesCollector collector(consumesCollector()); + select_ = new DTSegmentSelector(pset,collector); consumes< DTRecSegment4DCollection >(edm::InputTag(theRecHits4DLabel_)); // the root file which will contain the histos string rootFileName = pset.getUntrackedParameter("rootFileName","DTVDriftHistos.root"); @@ -101,7 +103,7 @@ void DTVDriftSegmentCalibration::analyze(const Event & event, const EventSetup& LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); - if( !select_(*segment, event, eventSetup) ) continue; + if( !(*select_)(*segment, event, eventSetup) ) continue; // Fill v-drift values if( (*segment).hasPhi() ) { diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h index 561e8a73f42c8..1a82b9611ad22 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftSegmentCalibration.h @@ -36,7 +36,7 @@ class DTVDriftSegmentCalibration : public edm::EDAnalyzer { typedef std::map > ChamberHistosMapTH2F; void bookHistos(DTChamberId); - DTSegmentSelector select_; + DTSegmentSelector *select_; edm::InputTag theRecHits4DLabel_; //bool writeVDriftDB_; diff --git a/CalibMuon/DTCalibration/python/Workflow/CLIHelper.py b/CalibMuon/DTCalibration/python/Workflow/CLIHelper.py index 4b6cdd0a82de0..8542a593c11dc 100644 --- a/CalibMuon/DTCalibration/python/Workflow/CLIHelper.py +++ b/CalibMuon/DTCalibration/python/Workflow/CLIHelper.py @@ -85,6 +85,8 @@ def get_submission_options_parser(cls): help="dataset name to process") submission_opts_group.add_argument("--run-on-RAW", action = "store_true", help="Flag if run on RAW dataset") + submission_opts_group.add_argument("--fromMuons", action = "store_true", + help="Segment selection using muon-segment matching") submission_opts_group.add_argument("--globaltag", help="global tag identifier (with the '::All' string, if necessary)") submission_opts_group.add_argument("--histoRange", default = 0.4, diff --git a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py index 3aca474730712..b34a0bcd32302 100644 --- a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py +++ b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py @@ -35,6 +35,9 @@ def submit_crab_task(self): task = self.crabFunctions.CrabTask(crab_config = full_crab_config_filename) task.update() + if task.state =="UNKNOWN": + time.sleep( 30 ) + task.update() success_states = ( 'QUEUED', 'SUBMITTED', "COMPLETED", "FINISHED") if task.state in success_states: log.info("Job in state %s" % task.state ) diff --git a/CalibMuon/DTCalibration/python/Workflow/DTTtrigWorkflow.py b/CalibMuon/DTCalibration/python/Workflow/DTTtrigWorkflow.py index 9b4a56cb293a1..b43cc7aa21db2 100644 --- a/CalibMuon/DTCalibration/python/Workflow/DTTtrigWorkflow.py +++ b/CalibMuon/DTCalibration/python/Workflow/DTTtrigWorkflow.py @@ -152,6 +152,8 @@ def prepare_residuals_submit(self): self.process.GlobalTag.globaltag = cms.string(str(self.options.globaltag)) self.process.dtResidualCalibration.rootFileName = self.output_file self.prepare_common_submit() + if self.options.fromMuons: + self.process.dtResidualCalibration.Muons = cms.InputTag("muons") if self.options.histoRange: self.process.dtResidualCalibration.histogramRange = cms.double(float(self.options.histoRange)) if self.options.inputCalibDB: @@ -222,10 +224,13 @@ def prepare_validation_submit(self): self.pset_template = 'CalibMuon.DTCalibration.dtCalibValidation_cfg' if self.options.datasettype == "Cosmics": self.pset_template = 'CalibMuon.DTCalibration.dtCalibValidation_cosmics_cfg' + if self.options.fromMuons: + self.pset_template = 'CalibMuon.DTCalibration.dtCalibValidationFromMuons_cfg' self.process = tools.loadCmsProcess(self.pset_template) self.process.GlobalTag.globaltag = cms.string(str(self.options.globaltag)) self.prepare_common_submit() - self.add_local_calib_db() + if self.options.inputCalibDB: + self.add_local_calib_db() self.write_pset_file() def prepare_validation_check(self): diff --git a/CalibMuon/DTCalibration/python/Workflow/addPoolDBESSource.py b/CalibMuon/DTCalibration/python/Workflow/addPoolDBESSource.py new file mode 100644 index 0000000000000..dfe346cc818ef --- /dev/null +++ b/CalibMuon/DTCalibration/python/Workflow/addPoolDBESSource.py @@ -0,0 +1,18 @@ +import FWCore.ParameterSet.Config as cms + +def addPoolDBESSource(process,moduleName,record,tag,label='',connect='sqlite_file:'): + from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup + calibDB = cms.ESSource("PoolDBESSource", + CondDBSetup, + timetype = cms.string('runnumber'), + toGet = cms.VPSet(cms.PSet( + record = cms.string(record), + tag = cms.string(tag), + label = cms.untracked.string(label) + )), + connect = cms.string(connect), + authenticationMethod = cms.untracked.uint32(0)) + #if authPath: calibDB.DBParameters.authenticationPath = authPath + if connect.find('oracle:') != -1: calibDB.DBParameters.authenticationPath = '/afs/cern.ch/cms/DB/conddb' + setattr(process,moduleName,calibDB) + setattr(process,"es_prefer_" + moduleName,cms.ESPrefer('PoolDBESSource',moduleName)) diff --git a/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfg.py b/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfg.py new file mode 100644 index 0000000000000..5b172833f528d --- /dev/null +++ b/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfg.py @@ -0,0 +1,42 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("Validation") + +process.load("FWCore.MessageService.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = 'INFO' + +process.load("CalibMuon.DTCalibration.dt_offlineAnalysis_common_cff") +process.load("DQMServices.Core.DQM_cfg") + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring() +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + +process.load("CalibMuon.DTCalibration.dtCalibValidationFromMuons_cfi") +process.load("CalibMuon.DTCalibration.ALCARECODtCalibHLTDQM_cfi") +#process.ALCARECODtCalibHLTDQM.directory = "DT/HLTSummary" + +process.output = cms.OutputModule("PoolOutputModule", + outputCommands = cms.untracked.vstring('drop *', + 'keep *_MEtoEDMConverter_*_Validation'), + fileName = cms.untracked.string('DQM.root') +) + +process.load("DQMServices.Components.MEtoEDMConverter_cff") + +""" +process.dtValidSequence = cms.Sequence(process.muonDTDigis* + process.dt1DRecHits*process.dt2DSegments*process.dt4DSegments+ + process.dtCalibValidation+process.ALCARECODtCalibHLTDQM) +""" +process.dtValidSequence = cms.Sequence(process.dt1DRecHits*process.dt2DSegments*process.dt4DSegments+ + process.dtCalibValidation)#+process.ALCARECODtCalibHLTDQM) +process.analysis_step = cms.Path(process.dtValidSequence*process.MEtoEDMConverter) +process.out_step = cms.EndPath(process.output) +#process.DQM.collectorHost = '' diff --git a/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfi.py b/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfi.py new file mode 100644 index 0000000000000..0c241dd2f8eba --- /dev/null +++ b/CalibMuon/DTCalibration/python/dtCalibValidationFromMuons_cfi.py @@ -0,0 +1,23 @@ +import FWCore.ParameterSet.Config as cms + +from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer +from RecoMuon.TrackingTools.MuonSegmentMatcher_cff import * + +dtCalibValidation = DQMEDAnalyzer("DTCalibValidationFromMuons", + MuonSegmentMatcher, + OutputFileName = cms.string('residuals.root'), + # Write the histos on file + OutputMEsInRootFile = cms.bool(False), + debug = cms.untracked.bool(False), + # Detailed analysis + detailedAnalysis = cms.untracked.bool(False), + # Muon collection used for matching + muonLabel = cms.untracked.string('muons'), + # Lable to retrieve RecHits from the event + recHits1DLabel = cms.untracked.string('dt1DRecHits'), + # Lable to retrieve 2D segments from the event + segment2DLabel = cms.untracked.string('dt2DSegments'), + # Lable to retrieve 4D segments from the event + segment4DLabel = cms.untracked.string('dt4DSegments') +) + diff --git a/CalibMuon/DTCalibration/python/dtResidualCalibration_cfi.py b/CalibMuon/DTCalibration/python/dtResidualCalibration_cfi.py index e5efa6d5340e1..7572fb02b46d5 100644 --- a/CalibMuon/DTCalibration/python/dtResidualCalibration_cfi.py +++ b/CalibMuon/DTCalibration/python/dtResidualCalibration_cfi.py @@ -1,19 +1,10 @@ import FWCore.ParameterSet.Config as cms -dtSegmentSelectionResiduals = cms.PSet( - checkNoisyChannels = cms.bool(False), - minHitsPhi = cms.int32(7), - #minHitsPhi = cms.int32(5), - minHitsZ = cms.int32(4), - #minHitsZ = cms.int32(3), - maxChi2 = cms.double(1000.0), - maxAnglePhi = cms.double(25.), - maxAngleZ = cms.double(999.) -) +from CalibMuon.DTCalibration.dtSegmentSelection_cfi import dtSegmentSelection dtResidualCalibration = cms.EDAnalyzer("DTResidualCalibration", # Segment selection - dtSegmentSelectionResiduals, + dtSegmentSelection, histogramRange = cms.double(0.4), segment4DLabel = cms.InputTag('dt4DSegments'), rootBaseDir = cms.untracked.string('DTResiduals'), diff --git a/CalibMuon/DTCalibration/python/dtSegmentSelection_cfi.py b/CalibMuon/DTCalibration/python/dtSegmentSelection_cfi.py index 09cafcd1374e7..29d88a495b2b7 100644 --- a/CalibMuon/DTCalibration/python/dtSegmentSelection_cfi.py +++ b/CalibMuon/DTCalibration/python/dtSegmentSelection_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms dtSegmentSelection = cms.PSet( + Muons= cms.InputTag(''), checkNoisyChannels = cms.bool(False), minHitsPhi = cms.int32(7), minHitsZ = cms.int32(4), diff --git a/CalibMuon/DTCalibration/scripts/allPlotsResiduals.py b/CalibMuon/DTCalibration/scripts/allPlotsResiduals.py new file mode 100755 index 0000000000000..2a77fee299009 --- /dev/null +++ b/CalibMuon/DTCalibration/scripts/allPlotsResiduals.py @@ -0,0 +1,89 @@ +#! /usr/bin/env python +from __future__ import print_function +import ROOT +import optparse +import re +import os + +def main(): + parser = optparse.OptionParser() + (options, args) = parser.parse_args() + ROOT.gROOT.SetBatch(True) + for filename in args: + if "vDrift_segment_" in filename: + #name="DQM" + m=re.search("vDrift_segment_(\d*)",filename) + run=m.group(1) + + #path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation" + + f = open('dtVDriftAnalyzer_cfg.py','w') + print("from CalibMuon.DTCalibration.Workflow.addPoolDBESSource import addPoolDBESSource", file=f) + print("from CalibMuon.DTCalibration.dtVDriftAnalyzer_cfg import process", file=f) + print("addPoolDBESSource(process = process, moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift', connect = 'sqlite_file:"+filename+"')", file=f) + print("process.dtVDriftAnalyzer.rootFileName = 'dtVDriftAnalyzer_dtVDriftCalibration"+run+".root'", file=f) + f.close() + os.system("cmsRun dtVDriftAnalyzer_cfg.py") + name="vdrift" + runvdrift(name, run, "dtVDriftAnalyzer_dtVDriftCalibration"+run+".root") + + if "vDrift_meantimer_" in filename: + #name="DQM" + m=re.search("vDrift_meantimer_(\d*)",filename) + run=m.group(1) + + #path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation" + + f = open('dtVDriftAnalyzer_cfg.py','w') + print("from CalibMuon.DTCalibration.Workflow.addPoolDBESSource import addPoolDBESSource", file=f) + print("from CalibMuon.DTCalibration.dtVDriftAnalyzer_cfg import process", file=f) + print("addPoolDBESSource(process = process, moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift', connect = 'sqlite_file:"+filename+"')", file=f) + print("process.dtVDriftAnalyzer.rootFileName = 'dtVDriftAnalyzer_dtVDriftCalibration"+run+".root'", file=f) + f.close() + os.system("cmsRun dtVDriftAnalyzer_cfg.py") + name="vdrift" + runvdrift(name, run, "dtVDriftAnalyzer_dtVDriftCalibration"+run+".root") + + elif "DQM" in filename: + name="DQM" + m=re.search("R000(\d*)__",filename) + run=m.group(1) + path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation" + runttrig(name, filename, path, run) + elif "TestPulses" in filename: + name="T0" + runt0(name,filename,123456) + else: + name="DTRV" + m=re.search("DTResidualValidation_(\d*)\.root",filename) + run=m.group(1) + path="DTResiduals" + runttrig(name, filename, path, run) + +def runttrig(name, filename, path, run): + from CalibMuon.DTCalibration.PlottingTools.plotResiduals import * + for SL in [1,2,3]: + mean,sigma = plot(filename, SL,dir=path) + mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf") + mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root") + sigma[0].Print(name+run+"-SL"+str(SL)+"-sigma.pdf") + sigma[0].SaveAs(name+run+"-SL"+str(SL)+"-sigma.root") +def runvdrift(name, run, filename): + from CalibMuon.DTCalibration.PlottingTools.plotVDriftFromHistos import * + for SL in [1,2,3]: + mean = plot(filename, SL) + mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf") + mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root") + #sigma[0].Print(name+run+"-SL"+str(SL)+"-sigma.pdf") + + #plot("DTResidualValidation_210614.root", 1,dir="DTResiduals") + #plot("DQM_V0001_R000210634__StreamExpress__HIRun2013-DtCalib-Express-v1-dtTtrigCalibrationFromResiduals-NEW-usedb-rev1__ALCARECO.root", 1,dir="DQMData/Run 210634/DT/Run summary/DTCalibValidation") +def runt0(name,filename,run): + from CalibMuon.DTCalibration.PlottingTools.plotT0FromHistos import * + for SL in [1,2,3]: + mean = plot(filename, SL ,run) + mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf") + mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root") + +if __name__=="__main__": + main() diff --git a/CalibMuon/DTCalibration/src/DTSegmentSelector.cc b/CalibMuon/DTCalibration/src/DTSegmentSelector.cc index 2a644bd196b14..df2094257f884 100644 --- a/CalibMuon/DTCalibration/src/DTSegmentSelector.cc +++ b/CalibMuon/DTCalibration/src/DTSegmentSelector.cc @@ -13,15 +13,55 @@ #include "CondFormats/DataRecord/interface/DTStatusFlagRcd.h" #include "CondFormats/DTObjects/interface/DTStatusFlag.h" +DTSegmentSelector::DTSegmentSelector(edm::ParameterSet const& pset, edm::ConsumesCollector& iC): + muonTags_(pset.getParameter("Muons")), + checkNoisyChannels_(pset.getParameter("checkNoisyChannels")), + minHitsPhi_(pset.getParameter("minHitsPhi")), + minHitsZ_(pset.getParameter("minHitsZ")), + maxChi2_(pset.getParameter("maxChi2")), + maxAnglePhi_(pset.getParameter("maxAnglePhi")), + maxAngleZ_(pset.getParameter("maxAngleZ")) +{ + muonToken_ = iC.consumes(muonTags_); +} + + bool DTSegmentSelector::operator() (DTRecSegment4D const& segment, edm::Event const& event, edm::EventSetup const& setup){ bool result = true; - /* - // Get the DT Geometry - ESHandle dtGeom; - eventSetup.get().get(dtGeom); - */ + /* get the muon collection if one is specified + (not specifying a muon collection switches off muon matching */ + if (muonTags_.label()!="") { + edm::Handle muonH; + event.getByToken(muonToken_,muonH); + const std::vector* muons = muonH.product(); + //std::cout << " Muon collection size: " << muons->size() << std::endl; + if (!muons->size()) return false; + + DTChamberId segId(segment.rawId()); + + bool matched = false; + for (auto &imuon : *muons) + for (const auto &ch : imuon.matches()) { + DetId chId(ch.id.rawId()); + if (chId!=segId) continue; + if ( imuon.pt()<15 || !imuon.isGlobalMuon()) continue; + + int nsegs=ch.segmentMatches.size(); + if (!nsegs) continue; + + LocalPoint posHit = segment.localPosition(); + float dx = (posHit.x() ? posHit.x()-ch.x : 0 ); + float dy = (posHit.y() ? posHit.y()-ch.y : 0 ); + float dr = sqrt(dx*dx+dy*dy); + if (dr<5) matched=true; + } + + if (!matched) result=false; + } + + edm::ESHandle statusMap; if(checkNoisyChannels_) setup.get().get(statusMap); @@ -31,8 +71,6 @@ bool DTSegmentSelector::operator() (DTRecSegment4D const& segment, edm::Event co bool segmentNoisyPhi = false; if( segment.hasPhi() ){ const DTChamberRecSegment2D* phiSeg = segment.phiSegment(); // phiSeg lives in the chamber RF - //LocalPoint phiSeg2DPosInCham = phiSeg->localPosition(); - //LocalVector phiSeg2DDirInCham = phiSeg->localDirection(); std::vector phiRecHits = phiSeg->specificRecHits(); nPhiHits = phiRecHits.size(); if(checkNoisyChannels_) segmentNoisyPhi = checkNoisySegment(statusMap,phiRecHits); @@ -43,9 +81,6 @@ bool DTSegmentSelector::operator() (DTRecSegment4D const& segment, edm::Event co bool segmentNoisyZ = false; if( segment.hasZed() ){ const DTSLRecSegment2D* zSeg = segment.zSegment(); // zSeg lives in the SL RF - //const DTSuperLayer* sl = chamber->superLayer(zSeg->superLayerId()); - //LocalPoint zSeg2DPosInCham = chamber->toLocal(sl->toGlobal((*zSeg).localPosition())); - //LocalVector zSeg2DDirInCham = chamber->toLocal(sl->toGlobal((*zSeg).localDirection())); std::vector zRecHits = zSeg->specificRecHits(); nZHits = zRecHits.size(); if(checkNoisyChannels_) segmentNoisyZ = checkNoisySegment(statusMap,zRecHits); @@ -88,7 +123,6 @@ bool DTSegmentSelector::checkNoisySegment(edm::ESHandle const& sta std::vector::const_iterator dtHit = dtHits.begin(); std::vector::const_iterator dtHits_end = dtHits.end(); for(; dtHit != dtHits_end; ++dtHit){ - //DTRecHit1D const* dtHit1D = dynamic_cast(*recHit); DTWireId wireId = dtHit->wireId(); // Check for noisy channels to skip them bool isNoisy = false, isFEMasked = false, isTDCMasked = false, isTrigMask = false, diff --git a/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h b/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h new file mode 100644 index 0000000000000..a1b0ba87d47b4 --- /dev/null +++ b/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h @@ -0,0 +1,117 @@ + +#ifndef DTCalibValidationFromMuons_H +#define DTCalibValidationFromMuons_H + +/** \class DTCalibValidationFromMuons + * Analysis on DT residuals to validate the kFactor + * + * + * \author G. Mila - INFN Torino + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include + +#include +#include +#include + +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" + +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "RecoMuon/TrackingTools/interface/MuonSegmentMatcher.h" + + +#include + +#include +#include +#include + + +// To remove into CMSSW versions before 20X +class DQMStore; +// To add into CMSSW versions before 20X +//class DaqMonitorBEInterface; + +class MonitorElement; +class DTGeometry; +class DTChamber; + +// FR class DTCalibValidationFromMuons: public edm::EDAnalyzer{ +class DTCalibValidationFromMuons: public DQMEDAnalyzer{ + + public: + /// Constructor + DTCalibValidationFromMuons(const edm::ParameterSet& pset); + + /// Destructor + ~DTCalibValidationFromMuons() override; + + /// BeginRun + void dqmBeginRun(const edm::Run& r, const edm::EventSetup& c) override; + + // Operations + void analyze(const edm::Event& event, const edm::EventSetup& setup) override; + + + protected: + void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; + + + private: + + // Switch for verbosity + //bool debug; + edm::ParameterSet parameters; + int wrongSegment; + int rightSegment; + int nevent; + // the geometry + edm::ESHandle dtGeom; + + // Label of 4D segments in the event + edm::EDGetTokenT segment4DToken_; + + // Label of muons in the event + edm::EDGetTokenT muonToken_; + + // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair + float recHitDistFromWire(const DTRecHit1DPair& hitPair, const DTLayer* layer); + // Compute the distance from wire (cm) of a hits in a DTRecHit1D + float recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer); + // Compute the position with respect to the wire (cm) of a hits in a DTRecHit1DPair + float recHitPosition(const DTRecHit1DPair& hitPair, const DTLayer* layer, const DTChamber* chamber, float segmPos, int sl); + // Compute the position with respect to the wire (cm) of a hits in a DTRecHit1D + float recHitPosition(const DTRecHit1D& recHit, const DTLayer* layer, const DTChamber* chamber, float segmPos, int sl); + + // Does the real job + void compute(const DTGeometry *dtGeom, const DTRecSegment4D& segment); + + // Book a set of histograms for a give chamber + void bookHistos(DTSuperLayerId slId, int step); + // Fill a set of histograms for a give chamber + void fillHistos(DTSuperLayerId slId, + float distance, + float residualOnDistance, + float position, + float residualOnPosition, + int step); + + std::map, std::vector > histosPerSL; + +}; +#endif + + +/* Local Variables: */ +/* show-trailing-whitespace: t */ +/* truncate-lines: t */ +/* End: */ diff --git a/DQM/DTMonitorModule/plugins/plugins.cc b/DQM/DTMonitorModule/plugins/plugins.cc index b040c492fb29b..4f7500353adfe 100644 --- a/DQM/DTMonitorModule/plugins/plugins.cc +++ b/DQM/DTMonitorModule/plugins/plugins.cc @@ -30,6 +30,9 @@ DEFINE_FWK_MODULE(DTNoiseTask); #include "DQM/DTMonitorModule/interface/DTCalibValidation.h" DEFINE_FWK_MODULE(DTCalibValidation); +#include "DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h" +DEFINE_FWK_MODULE(DTCalibValidationFromMuons); + #include DEFINE_FWK_MODULE(DTTriggerEfficiencyTask); @@ -48,5 +51,11 @@ DEFINE_FWK_MODULE(DTScalerInfoTask); #include DEFINE_FWK_MODULE(DTDCSByLumiTask); + #include DEFINE_FWK_MODULE(DTDataIntegrityTask); + +// Local Variables: +// show-trailing-whitespace: t +// truncate-lines: t +// End: diff --git a/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc b/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc new file mode 100644 index 0000000000000..234c886648aa5 --- /dev/null +++ b/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc @@ -0,0 +1,374 @@ + +/* + * See header file for a description of this class. + * + * \author G. Mila - INFN Torino + */ + +#include "DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h" + +// Framework +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "DQMServices/Core/interface/MonitorElement.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +//Geometry +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +//RecHit +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +#include "DataFormats/MuonReco/interface/MuonSelectors.h" + + +#include + +using namespace edm; +using namespace std; + + +DTCalibValidationFromMuons::DTCalibValidationFromMuons(const ParameterSet& pset) { + + parameters = pset; + + // the name of the 4D segments + segment4DToken_ = consumes( + edm::InputTag(parameters.getUntrackedParameter("segment4DLabel"))); + // muon collection for matching 4D segments to muons + muonToken_ = consumes( + edm::InputTag(parameters.getUntrackedParameter("muonLabel"))); + // the counter of segments not used to compute residuals + wrongSegment = 0; + // the counter of segments used to compute residuals + rightSegment = 0; + + nevent=0; + +} + + +DTCalibValidationFromMuons::~DTCalibValidationFromMuons(){ + + //FR the following was previously in the endJob + + LogVerbatim("DTCalibValidationFromMuons") << "Segments used to compute residuals: " << rightSegment; + LogVerbatim("DTCalibValidationFromMuons") << "Segments not used to compute residuals: " << wrongSegment; + +} + +void DTCalibValidationFromMuons::dqmBeginRun(const edm::Run& run, const edm::EventSetup& setup) { + + // get the geometry + setup.get().get(dtGeom); +} + + +void DTCalibValidationFromMuons::analyze(const edm::Event& event, const edm::EventSetup& setup) { + + ++nevent; + LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Analyze #Run: " << event.id().run() + << " #Event: " << nevent; + + // RecHit mapping at Step 3 --------------------------------- + LogTrace("DTCalibValidationFromMuons") << " -- DTRecHit S3: begin analysis:"; + // Get the 4D rechits from the event + Handle muonH; + event.getByToken(muonToken_, muonH); + const vector* muons = muonH.product(); + + // Get the 4D rechits from the event + Handle segment4Ds; + event.getByToken(segment4DToken_, segment4Ds); + + vector selectedSegment4Ds; + + for (auto &imuon : *muons) { + for (const auto &ch : imuon.matches()) { + DetId chId(ch.id.rawId()); + if ( chId.det() != DetId::Muon ) continue; + if ( chId.subdetId() != MuonSubdetId::DT ) continue; + if ( imuon.pt()<15 ) continue; + if ( !imuon.isGlobalMuon() ) continue; + + int nsegs=ch.segmentMatches.size(); + if (!nsegs) continue; + + // get the DT segments that were used to construct the muon + DTChamberId matchId = ch.id(); + DTRecSegment4DCollection::range segs= segment4Ds->get(matchId); + for (DTRecSegment4DCollection::const_iterator segment = segs.first; segment!=segs.second; ++segment) { + LocalPoint posHit = segment->localPosition(); + float dx = (posHit.x() ? posHit.x()-ch.x : 0 ); + float dy = (posHit.y() ? posHit.y()-ch.y : 0 ); + float dr = sqrt(dx*dx+dy*dy); + if (dr<5) selectedSegment4Ds.push_back(&(*segment)); + } + } + + } + + // Loop over all 4D segments + for (auto segment : selectedSegment4Ds ) { + LogTrace("DTCalibValidationFromMuons") << "Anlysis on recHit at step 3"; + compute(dtGeom.product(), *segment); + } + +} + + +// Compute the distance from wire (cm) of a hits in a DTRecHit1DPair +float +DTCalibValidationFromMuons::recHitDistFromWire(const DTRecHit1DPair& hitPair, const DTLayer* layer) { + return fabs(hitPair.localPosition(DTEnums::Left).x() - + hitPair.localPosition(DTEnums::Right).x())/2.; +} + + +// Compute the distance from wire (cm) of a hits in a DTRecHit1D +float +DTCalibValidationFromMuons::recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer) { + return fabs(recHit.localPosition().x() - layer->specificTopology().wirePosition(recHit.wireId().wire())); + +} + +// Compute the position (cm) of a hits in a DTRecHit1DPair +float +DTCalibValidationFromMuons::recHitPosition(const DTRecHit1DPair& hitPair, const DTLayer* layer, const DTChamber* chamber, float segmentPos, int sl) { + + // Get the layer and the wire position + GlobalPoint hitPosGlob_right = layer->toGlobal(hitPair.localPosition(DTEnums::Right)); + LocalPoint hitPosInChamber_right = chamber->toLocal(hitPosGlob_right); + GlobalPoint hitPosGlob_left = layer->toGlobal(hitPair.localPosition(DTEnums::Left)); + LocalPoint hitPosInChamber_left = chamber->toLocal(hitPosGlob_left); + + float recHitPos=-1; + if(sl != 2){ + if(fabs(hitPosInChamber_left.x()-segmentPos)toGlobal(recHit.localPosition()); + LocalPoint recHitPosInChamber = chamber->toLocal(recHitPosGlob); + + float recHitPos = -1; + if(sl != 2) + recHitPos = recHitPosInChamber.x(); + else + recHitPos = recHitPosInChamber.y(); + + return recHitPos; + +} + +// Compute the residuals +void DTCalibValidationFromMuons::compute(const DTGeometry *dtGeom, const DTRecSegment4D& segment) { + + bool computeResidual = true; + + // Get all 1D RecHits at step 3 within the 4D segment + vector recHits1D_S3; + + // Get 1D RecHits at Step 3 and select only events with + // >=7 hits in phi and 4 hits in theta (if any) + const DTChamberRecSegment2D* phiSeg = segment.phiSegment(); + if(phiSeg){ + vector phiRecHits = phiSeg->specificRecHits(); + if(phiRecHits.size() < 7) { + LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Phi segments has: " << phiRecHits.size() + << " hits, skipping"; // FIXME: info output + computeResidual = false; + } + copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3)); + } + if(!phiSeg){ + LogTrace("DTCalibValidationFromMuons") << " [DTCalibValidationFromMuons] 4D segment has no phi segment! "; + computeResidual = false; + } + + if(segment.dimension() == 4) { + const DTSLRecSegment2D* zSeg = segment.zSegment(); + if(zSeg){ + vector zRecHits = zSeg->specificRecHits(); + if(zRecHits.size() != 4) { + LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Theta segments has: " << zRecHits.size() + << " hits, skipping"; // FIXME: info output + computeResidual = false; + } + copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3)); + } + if(!zSeg){ + LogTrace("DTCalibValidationFromMuons") << " [DTCalibValidationFromMuons] 4D segment has not the z segment! "; + computeResidual = false; + } + } + + if(!computeResidual) ++wrongSegment; + + if(computeResidual) { + ++rightSegment; + + // Loop over 1D RecHit inside 4D segment + for(vector::const_iterator recHit1D = recHits1D_S3.begin(); + recHit1D != recHits1D_S3.end(); + ++recHit1D) { + const DTWireId wireId = (*recHit1D).wireId(); + + // Get the layer and the wire position + const DTLayer* layer = dtGeom->layer(wireId); + float wireX = layer->specificTopology().wirePosition(wireId.wire()); + + // Extrapolate the segment to the z of the wire + // Get wire position in chamber RF + // (y and z must be those of the hit to be coherent in the transf. of RF in case of rotations of the layer alignment) + LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z()); + GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay); + const DTChamber* chamber = dtGeom->chamber((*recHit1D).wireId().layerId().chamberId()); + LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob); + + // Segment position at Wire z in chamber local frame + LocalPoint segPosAtZWire = segment.localPosition() + + segment.localDirection()*wirePosInChamber.z()/cos(segment.localDirection().theta()); + + // Compute the distance of the segment from the wire + int sl = wireId.superlayer(); + float SegmDistance = -1; + if(sl == 1 || sl == 3) { + // RPhi SL + SegmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x()); + LogTrace("DTCalibValidationFromMuons") << "SegmDistance: " << SegmDistance; + } else if(sl == 2) { + // RZ SL + SegmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y()); + LogTrace("DTCalibValidationFromMuons") << "SegmDistance: " << SegmDistance; + } + + if(SegmDistance > 2.1) + LogTrace("DTCalibValidationFromMuons") << " Warning: dist segment-wire: " << SegmDistance; + + // Compute the distance of the recHit from the wire + float recHitWireDist = recHitDistFromWire(*recHit1D, layer); + LogTrace("DTCalibValidationFromMuons") << "recHitWireDist: " << recHitWireDist; + + // Compute the residuals + float residualOnDistance = recHitWireDist - SegmDistance; + LogTrace("DTCalibValidationFromMuons") << "WireId: " << wireId << " ResidualOnDistance: " << residualOnDistance; + float residualOnPosition = -1; + float recHitPos = -1; + if(sl == 1 || sl == 3) { + recHitPos = recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.x(), sl); + residualOnPosition = recHitPos - segPosAtZWire.x(); + } else { + recHitPos = recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.y(), sl); + residualOnPosition = recHitPos - segPosAtZWire.y(); + } + LogTrace("DTCalibValidationFromMuons") << "WireId: " << wireId << " ResidualOnPosition: " << residualOnPosition; + + // Fill the histos + if(sl == 1 || sl == 3) + fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.x() - segPosAtZWire.x()), residualOnPosition, 3); + else + fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.y() - segPosAtZWire.y()), residualOnPosition, 3); + } + } +} + + +void DTCalibValidationFromMuons::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & iSetup) { + + //FR substitute the DQMStore instance by ibooker + ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons"); + + DTSuperLayerId slId; + + // Loop over all the chambers + vector::const_iterator ch_it = dtGeom->chambers().begin(); + vector::const_iterator ch_end = dtGeom->chambers().end(); + for (; ch_it != ch_end; ++ch_it) { + vector::const_iterator sl_it = (*ch_it)->superLayers().begin(); + vector::const_iterator sl_end = (*ch_it)->superLayers().end(); + // Loop over the SLs + for(; sl_it != sl_end; ++sl_it) { + slId = (*sl_it)->id(); + + // TODO! fix this is a leftover + int firstStep=3; + // Loop over the 3 steps + for(int step = firstStep; step <= 3; ++step) { + + LogTrace("DTCalibValidationFromMuons") << " Booking histos for SL: " << slId; + + // Compose the chamber name + stringstream wheel; wheel << slId.wheel(); + stringstream station; station << slId.station(); + stringstream sector; sector << slId.sector(); + stringstream superLayer; superLayer << slId.superlayer(); + // Define the step + stringstream Step; Step << step; + + string slHistoName = + "_STEP" + Step.str() + + "_W" + wheel.str() + + "_St" + station.str() + + "_Sec" + sector.str() + + "_SL" + superLayer.str(); + + ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons/Wheel" + wheel.str() + + "/Station" + station.str() + + "/Sector" + sector.str()); + // Create the monitor elements + vector histos; + // Note the order matters + histos.push_back(ibooker.book1D("hResDist"+slHistoName, + "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", + 200, -0.4, 0.4)); + histos.push_back(ibooker.book2D("hResDistVsDist"+slHistoName, + "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)", + 100, 0, 2.5, 200, -0.4, 0.4)); + + histosPerSL[make_pair(slId, step)] = histos; + } + } + } +} + + +// Fill a set of histograms for a given SL +void DTCalibValidationFromMuons::fillHistos(DTSuperLayerId slId, + float distance, + float residualOnDistance, + float position, + float residualOnPosition, + int step) { + // FIXME: optimization of the number of searches + vector histos = histosPerSL[make_pair(slId,step)]; + histos[0]->Fill(residualOnDistance); + histos[1]->Fill(distance, residualOnDistance); +} + + +// Local Variables: +// show-trailing-whitespace: t +// truncate-lines: t +// End: From 8de9e1a2655a68790ca3691721f0c8c4678f6254 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Wed, 26 Sep 2018 15:47:37 +0200 Subject: [PATCH 220/686] Cleanup of T0 code - Remove debug output - Rename some variables - Remove old files from config (cherry picked from commit aa8e565d37f6b359347c3429725626b7c34161cc) --- .../plugins/DTT0CalibrationNew.cc | 340 +----------------- .../plugins/DTT0CalibrationNew.h | 6 +- .../python/dtT0WireCalibration_cfg.py | 13 +- 3 files changed, 16 insertions(+), 343 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc index cb91e51baf821..ff5cc7a8fb5d5 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc @@ -99,13 +99,6 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup if (nevents == 1) eventSetup.get().get(dtGeom); - //const auto begin = *(digis->begin()); - //const auto end = *(digis->end()); - //std::cout << __LINE__ << " " << &(begin) << " " << &(end) << " " << sizeof(begin) << " " << typeid(begin).name() << std::endl; - //std::cout << __LINE__ << " " << &(*begin) << " " << &(*end) << std::endl; - //std::cout << __LINE__ << " " << &(*(digis->begin())) << " " << &(*(digis->end())) << std::endl; - //for (; begin != end; begin++) - // std::cout << __LINE__ << std::endl; // Iterate through all digi collections ordered by LayerId for (const auto& digis_per_layer : *digis) { @@ -129,7 +122,6 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup { const double t0 = digi->countsTDC(); const DTWireId wireIdtmp(layerId, (*digi).wire()); - all_wires.insert(wireIdtmp.wire()); // Use first bunch of events to fill t0 per layer if(nevents <= eventsForLayerT0){ @@ -157,7 +149,6 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup } //Fill the histos per wire for the chosen cells - //if (std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) != layerIdWithWireHistos.end() or std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) { @@ -182,21 +173,6 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup continue; } - //Find to ref. per chamber - /* - if (not theCountT0ByChamber[chamberId]) - { - theSumT0ByChamber[chamberId] = 0; - theCountT0ByChamber[chamberId] = 0; - theMeanT0ByChamber[chamberId] = 0; - theSigmaT0ByChamber[chamberId] = 0; - } - theCountT0ByChamber[chamberId]++; - theSumT0ByChamber[chamberId] = theSumT0ByChamber[chamberId] + t0; - theSigmaT0ByChamber[chamberId] += (theSumT0ByChamber[chamberId] - 1) * pow(t0 -theMeanT0ByChamber[chamberId], 2) / theSumT0ByChamber[chamberId]; - theMeanT0ByChamber[chamberId] += (t0 - theMeanT0ByChamber[chamberId]) / theCountT0ByChamber[chamberId]; - */ - //Use second bunch of events to compute a t0 reference per wire if(nevents <= (eventsForLayerT0 + eventsForWireT0)){ if(!nDigiPerWire_ref[wireId]){ @@ -216,7 +192,6 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup } nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1; theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0; - //theSigmaT0PerWire[wireId] = theSigmaT0PerWire[wireId] + (t0*t0); qK[wireId] = qK[wireId] + ((nDigiPerWire[wireId]-1)*(t0-mK[wireId])*(t0-mK[wireId])/nDigiPerWire[wireId]); mK[wireId] = mK[wireId] + (t0-mK[wireId])/nDigiPerWire[wireId]; } @@ -306,24 +281,13 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) layerIdWithWireHistos.push_back(layerId); } - //if (peakMeans.empty()) - // std::cout << "PEAK IN LAYER (EMPTY) " << layerId << " " << theTPPeakMap[layerId] << std::endl; - //else if (peakMeans.size() > 5) - // std::cout << "PEAK IN LAYER (>5) " << layerId << " " << theTPPeakMap[layerId] << std::endl; - //else if (peakMeans.back() > 1000) - // std::cout << "PEAK IN LAYER (TO HIGH) " << layerId << " " << theTPPeakMap[layerId] << std::endl; - hLayerPeaks.Fill(theTPPeakMap[layerId]); - } } } void DTT0CalibrationNew::endJob() { - std::cout << "WIRES" << std::endl; - for (auto& wire : all_wires) - std::cout << wire << std::endl; std::cout << "Analyzed " << nevents << " events" << std::endl; DTT0* t0sWRTChamber = new DTT0(); @@ -357,31 +321,10 @@ void DTT0CalibrationNew::endJob() { // Every time the same measurement. Use Laplace estimator as estimation how propable it is to measure another value due to limited size of sample if (theSigmaT0PerWire[wireId] == 0) { - std::cout << "NOERROR " << wireId << " " << nDigiPerWire[wireId] << " " << pow(1. / (nDigiPerWire[wireId] + 1), 2) << std::endl; theSigmaT0PerWire[wireId] += pow(1. / (nDigiPerWire[wireId] + 1), 2); } - std::cout << "START " << wireId << " " << wiret0.second / nDigiPerWire[wireId] << " " << sqrt(theSigmaT0PerWire[wireId]) << " " << nDigiPerWire[wireId] << std::endl; } - // function to calculate weighted means - /*auto weighted_mean_function = [] (const std::list& values, const std::list& sigmas) - { - auto value_iterator = values.begin(); - auto sigma_iterator = sigmas.begin(); - double weighted_mean = 0; - double weighted_sigma = 0; - assert(values.size() == sigmas.size()); - for (; value_iterator != values.end(); value_iterator++, sigma_iterator++) - { - double weight = 1. / pow(*sigma_iterator, 2); - weighted_mean += (*value_iterator * weight); - weighted_sigma += weight; - } - weighted_mean /= weighted_sigma; - weighted_sigma = 1. / sqrt(weighted_sigma); - return std::make_pair(weighted_mean, weighted_sigma); - };*/ - // function to calculate unweighted means auto unweighted_mean_function = [] (const std::list& values, const std::list& sigmas) { @@ -403,8 +346,8 @@ void DTT0CalibrationNew::endJob() { }; // correct for odd-even effect in each super layer - std::map > weighted_mean_sigma_even; - std::map > weighted_mean_sigma_odd; + std::map > mean_sigma_even; + std::map > mean_sigma_odd; for (const auto& superlayer : dtGeom->superLayers()) { const auto superlayer_id = superlayer->id(); @@ -432,10 +375,8 @@ void DTT0CalibrationNew::endJob() { } } // get mean and uncertainty - weighted_mean_sigma_even.emplace(superlayer_id, unweighted_mean_function(values_even, sigmas_even)); - weighted_mean_sigma_odd.emplace(superlayer_id, unweighted_mean_function(values_odd, sigmas_odd)); - std::cout << "EVEN " << superlayer_id << " " << weighted_mean_sigma_even[superlayer_id].first << " +- " << weighted_mean_sigma_even[superlayer_id].second << std::endl; - std::cout << "ODD " << superlayer_id << " " << weighted_mean_sigma_odd[superlayer_id].first << " +- " << weighted_mean_sigma_odd[superlayer_id].second << std::endl; + mean_sigma_even.emplace(superlayer_id, unweighted_mean_function(values_even, sigmas_even)); + mean_sigma_odd.emplace(superlayer_id, unweighted_mean_function(values_odd, sigmas_odd)); } // filter outliers @@ -453,14 +394,14 @@ void DTT0CalibrationNew::endJob() { if (wireId.layerId().superlayerId() == superlayer_id) { const auto& t0 = wiret0.second / nDigiPerWire[wireId]; - if (wireId.layerId().layer() % 2 and abs(t0 - weighted_mean_sigma_odd[superlayer_id].first) < 2*weighted_mean_sigma_odd[superlayer_id].second) + if (wireId.layerId().layer() % 2 and abs(t0 - mean_sigma_odd[superlayer_id].first) < 2 * mean_sigma_odd[superlayer_id].second) { values_odd.push_back(t0); sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); } else { - if (abs(t0 - weighted_mean_sigma_even[superlayer_id].first) < 2*weighted_mean_sigma_even[superlayer_id].second) + if (abs(t0 - mean_sigma_even[superlayer_id].first) < 2 * mean_sigma_even[superlayer_id].second) { values_even.push_back(t0); sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); @@ -469,8 +410,8 @@ void DTT0CalibrationNew::endJob() { } } // get mean and uncertainty - weighted_mean_sigma_even[superlayer_id] = unweighted_mean_function(values_even, sigmas_even); - weighted_mean_sigma_odd[superlayer_id] = unweighted_mean_function(values_odd, sigmas_odd); + mean_sigma_even[superlayer_id] = unweighted_mean_function(values_even, sigmas_even); + mean_sigma_odd[superlayer_id] = unweighted_mean_function(values_odd, sigmas_odd); } // apply correction @@ -484,9 +425,8 @@ void DTT0CalibrationNew::endJob() { if (not layer % 2) continue; // t0 is reference. Changing it changes the map - t0 += weighted_mean_sigma_even[superlayer_id].first - weighted_mean_sigma_odd[superlayer_id].first; - theSigmaT0PerWire[wire_id] += pow(weighted_mean_sigma_odd[superlayer_id].second, 2) + pow(weighted_mean_sigma_even[superlayer_id].second, 2); - std::cout << "ODD-EVEN-CORRECTED " << wire_id << " " << t0 << " " << sqrt(theSigmaT0PerWire[wire_id]) << std::endl; + t0 += mean_sigma_even[superlayer_id].first - mean_sigma_odd[superlayer_id].first; + theSigmaT0PerWire[wire_id] += pow(mean_sigma_odd[superlayer_id].second, 2) + pow(mean_sigma_even[superlayer_id].second, 2); } // get chamber mean @@ -501,14 +441,13 @@ void DTT0CalibrationNew::endJob() { sigmas_per_chamber[chamber_id].push_back(sqrt(theSigmaT0PerWire[wire_id])); } - std::map > weighted_mean_per_chamber; + std::map > mean_per_chamber; for (const auto& chamber_mean : values_per_chamber) { const auto& chamber_id = chamber_mean.first; const auto& means = chamber_mean.second; const auto& sigmas = sigmas_per_chamber[chamber_id]; - weighted_mean_per_chamber.emplace(chamber_id, unweighted_mean_function(means, sigmas)); - std::cout << "CHAMBER MEAN " << chamber_id << " " << weighted_mean_per_chamber[chamber_id].first << " +- " << weighted_mean_per_chamber[chamber_id].second << std::endl; + mean_per_chamber.emplace(chamber_id, unweighted_mean_function(means, sigmas)); } // calculate relative values @@ -517,8 +456,7 @@ void DTT0CalibrationNew::endJob() { const auto& wire_id = wire_t0.first; const auto& chamber_id = wire_id.chamberId(); const auto& t0 = wire_t0.second; - theRelativeT0PerWire.emplace(wire_id, t0 - weighted_mean_per_chamber[chamber_id].first); - //theSigmaT0PerWire[wire_id] += pow(weighted_mean_per_chamber[chamber_id].second, 2); + theRelativeT0PerWire.emplace(wire_id, t0 - mean_per_chamber[chamber_id].first); cout << "[DTT0CalibrationNew] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " << " sigma "<< sqrt(theSigmaT0PerWire[wire_id]) <::const_iterator wiret0 = theAbsoluteT0PerWire.begin(); - wiret0 != theAbsoluteT0PerWire.end(); - ++wiret0){ - DTChamberId chamberId = wiret0->first.chamberId(); - double t0 = wiret0->second/nDigiPerWire[wiret0->first]; - //double t0 = mK[wiret0->first]; - if (nDigiPerWire[wiret0->first] > 1 ) - theSigmaT0PerWire[wiret0->first] = sqrt(qK[wiret0->first]/(nDigiPerWire[wiret0->first] - 1)); - else - theSigmaT0PerWire[wiret0->first] = 999.; // Only one measurement: uncertainty -> infinity - values[chamberId].push_back(t0); - theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(0.5, 2)); - sigmas[chamberId].push_back(theSigmaT0PerWire[wiret0->first]); - } - - for (auto chamberId_iterator=values.begin(); chamberId_iterator != values.end(); chamberId_iterator++) - { - const auto& chamberId = chamberId_iterator->first; - double weight = 0; - auto value_iterator = values[chamberId].begin(); - auto sigma_iterator = sigmas[chamberId].begin(); - double tmp = 0; - theSigmaT0ByChamber[chamberId] = 0; - if (values[chamberId].size() != sigmas[chamberId].size()) - std::cout << "FUCK MY LIFE" << std::endl; - for (; value_iterator != values[chamberId].end(); value_iterator++, sigma_iterator++) - { - weight = 1. / pow(*sigma_iterator, 2); - theRefT0ByChamber[chamberId] += (*value_iterator * weight); - theSigmaT0ByChamber[chamberId] += weight; - tmp += *value_iterator; - std::cout << *value_iterator << " " << *sigma_iterator << std::endl; - } - //std::cout << tmp << " " << values[chamberId].size() << " " << sigmas[chamberId].size() << " " << theCountT0ByChamber[chamberId] << " " << theSumT0ByChamber[chamberId] << std::endl; - theRefT0ByChamber[chamberId] /= theSigmaT0ByChamber[chamberId]; - theSigmaT0ByChamber[chamberId] = 1. / sqrt(theSigmaT0ByChamber[chamberId]); - std::cout << "PER CHAMBER " << chamberId << " " << theCountT0ByChamber[chamberId] << " " << theRefT0ByChamber[chamberId] << " " << theSigmaT0ByChamber[chamberId] << " " << tmp / values[chamberId].size() << std::endl; - } - - for(map::const_iterator wiret0 = theAbsoluteT0PerWire.begin(); - wiret0 != theAbsoluteT0PerWire.end(); - ++wiret0){ - if(nDigiPerWire[(*wiret0).first]){ - double t0 = (*wiret0).second/nDigiPerWire[(*wiret0).first]; - DTChamberId chamberId = ((*wiret0).first).chamberId(); - //theRelativeT0PerWire[(*wiret0).first] = t0 - hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()); - theRelativeT0PerWire[(*wiret0).first] = t0 - theRefT0ByChamber[chamberId]; - cout<<"Wire "<<(*wiret0).first<<" has t0 "< 1 ) - // theSigmaT0PerWire[(*wiret0).first] = sqrt(qK[(*wiret0).first]/(nDigiPerWire[(*wiret0).first] - 1)); - //else - // theSigmaT0PerWire[(*wiret0).first] = 999.; // Only one measurement: uncertainty -> infinity - // Systematic uncertainty: Channel Width - theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(theSigmaT0ByChamber[chamberId], 2)); - //theSigmaT0PerWire[(*wiret0).first] = sqrt(pow(theSigmaT0PerWire[(*wiret0).first], 2) + pow(0.5, 2)); - cout<<" sigma "< superLayers = dtGeom->superLayers(); - // Loop over all SLs - double oddLayersFinalMean=0; - double evenLayersFinalMean=0; - for(vector::const_iterator sl = superLayers.begin(); - sl != superLayers.end(); sl++) { - - - //Compute mean for odd and even superlayers - double oddLayersMean=0; - double evenLayersMean=0; - double oddLayersDen=0; - double evenLayersDen=0; - for(map::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(debug) - cout<<"[DTT0CalibrationNew] Superlayer "<<(*sl)->id() - <<"layer " <<(*wiret0).first.layerId().layer()<<" with "<<(*wiret0).second<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(((*wiret0).first.layerId().layer()) % 2){ - oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean); - } - else{ - evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean); - } - } - } - oddLayersSigma = oddLayersSigma/oddLayersDen; - evenLayersSigma = evenLayersSigma/evenLayersDen; - oddLayersSigma = sqrt(oddLayersSigma); - evenLayersSigma = sqrt(evenLayersSigma); - - if(debug && evenLayersMean) - cout<<"[DTT0CalibrationNew] Relative T0 sigma for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(((*wiret0).first.layerId().layer()) % 2){ - if(abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma)) - { - oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second; - oddLayersDen++; - } - } - else{ - if(abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma)) - { - evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second; - evenLayersDen++; - } - } - } - } - oddLayersFinalMean = oddLayersFinalMean/oddLayersDen; - evenLayersFinalMean = evenLayersFinalMean/evenLayersDen; - } - for(vector::const_iterator sl = superLayers.begin(); - sl != superLayers.end(); sl++) { - if(debug && oddLayersFinalMean) - cout<<"[DTT0CalibrationNew] Final relative T0 mean for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - double t0=-999; - if(((*wiret0).first.layerId().layer()) % 2) - t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean); - else - t0 = (*wiret0).second; - - //cout<<"[DTT0CalibrationNew] Wire "<<(*wiret0).first<<" has t0 "<set((*wiret0).first, t0, theSigmaT0PerWire[(*wiret0).first],DTTimeUnits::counts); - } - } - } - - ///Change t0 absolute reference -> from sector peak to chamber average - if(debug) - cout << "[DTT0CalibrationNew]Computing relative t0 wrt to chamber average" << endl; - //Compute the reference for each chamber - map sumT0ByChamber; - map countT0ByChamber; - for(DTT0::const_iterator tzero = t0s->begin(); - tzero != t0s->end(); ++tzero) { - // @@@ NEW DTT0 FORMAT - // DTChamberId chamberId((*tzero).first.wheelId, - // (*tzero).first.stationId, - // (*tzero).first.sectorId); - // sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + (*tzero).second.t0mean; - int channelId = tzero->channelId; - if ( channelId == 0 ) continue; - DTWireId wireId(channelId); - DTChamberId chamberId(wireId.chamberId()); - //sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + tzero->t0mean; - // @@@ better DTT0 usage - float t0mean_f; - float t0rms_f; - t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); - sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f; - // @@@ NEW DTT0 END - countT0ByChamber[chamberId]++; - } - //Change reference for each wire and store the new t0s in the new map - for(DTT0::const_iterator tzero = t0s->begin(); - tzero != t0s->end(); ++tzero) { - // @@@ NEW DTT0 FORMAT - // DTChamberId chamberId((*tzero).first.wheelId, - // (*tzero).first.stationId, - // (*tzero).first.sectorId); - // double t0mean = ((*tzero).second.t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); - // double t0rms = (*tzero).second.t0rms; - // DTWireId wireId((*tzero).first.wheelId, - // (*tzero).first.stationId, - // (*tzero).first.sectorId, - // (*tzero).first.slId, - // (*tzero).first.layerId, - // (*tzero).first.cellId); - int channelId = tzero->channelId; - if ( channelId == 0 ) continue; - DTWireId wireId( channelId ); - DTChamberId chamberId(wireId.chamberId()); - //double t0mean = (tzero->t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); - //double t0rms = tzero->t0rms; - // @@@ better DTT0 usage - float t0mean_f; - float t0rms_f; - t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); - double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); - double t0rms = t0rms_f; - cout<<"[DTT0CalibrationNew] Wire "<set(wireId, - t0mean, - t0rms, - DTTimeUnits::counts); - if(debug){ - //cout<<"Chamber "<t0mean<<" to "<> histoName; return histoName; } - diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h index 1c999a2979d94..a7476147aca81 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h +++ b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h @@ -53,9 +53,6 @@ class DTT0CalibrationNew : public edm::one::EDAnalyzer<> { protected: private: - // TODO: REMOVE ME - std::set all_wires; - DTLayerId theLayer; // Generate the histo name std::string getHistoName(const DTWireId& wId) const; std::string getHistoName(const DTLayerId& lId) const; @@ -93,7 +90,8 @@ class DTT0CalibrationNew : public edm::one::EDAnalyzer<> { // Map of the histos and graph by layer std::map theHistoLayerMap; - // TODO: REMOVE OR DOCUMENT + + // Histogram containing position of all peaks TH1D hLayerPeaks; TSpectrum spectrum; diff --git a/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py b/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py index c911f7a58060e..82bfe52542c35 100644 --- a/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py +++ b/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py @@ -25,18 +25,7 @@ process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( -# '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/540/AA9053D9-F306-E211-80A4-001D09F248F8.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/199/204/148CF2AC-CAD0-E111-A056-001D09F291D2.root', -### '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/132/D0E088D3-D7DC-E111-92D2-00237DDC5C24.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/198/510/0C50021A-F4C8-E111-B861-001D09F2512C.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/199/206/EC54DD2C-D3D0-E111-9019-5404A63886CE.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/131/E024E67D-D6DC-E111-A404-0025901D6288.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/201/074/92295641-C3E7-E111-899B-0025901D629C.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/133/ACB373F1-D9DC-E111-B891-003048F024FE.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/276/2CF5C87C-E303-E211-A314-001D09F28F25.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/535/1EEFEF95-F506-E211-A872-001D09F2906A.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/665/1C75364F-0EE3-E111-8021-BCAEC5329705.root', - '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/716/8A0AC842-A3E3-E111-A669-001D09F291D7.root' + '/store/data/Commissioning2018/MiniDaq/RAW/v1/000/312/774/00000/CCADE144-9431-E811-9641-FA163E220C5C.root' ) ) From 3213a907d3bba503df5903d7a72011f2da165ab6 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Wed, 26 Sep 2018 15:52:32 +0200 Subject: [PATCH 221/686] Renamed DTT0CalibrationNew to DTT0Calibration The history is kept. (cherry picked from commit 69ccb111ee0193740ae63aeee96f0df647951cf3) --- .../DTCalibration/plugins/DTT0Calibration.cc | 1043 +++++++---------- .../DTCalibration/plugins/DTT0Calibration.h | 65 +- .../plugins/DTT0CalibrationNew.cc | 501 -------- .../plugins/DTT0CalibrationNew.h | 129 -- 4 files changed, 489 insertions(+), 1249 deletions(-) delete mode 100644 CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc delete mode 100644 CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc index d99e00353a2e0..ff5cc7a8fb5d5 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc @@ -1,8 +1,13 @@ /* * See header file for a description of this class. + * + * $Date: 2012/05/11 17:17:17 $ + * $Revision: 1.6 $ + * \author S. Bolognesi - INFN Torino + * 06/08/2008 Mofified by Antonio.Vilela.Pereira@cern.ch */ -#include "CalibMuon/DTCalibration/plugins/DTT0Calibration.h" +#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h" #include "FWCore/Framework/interface/Event.h" @@ -17,616 +22,480 @@ #include #include -#include "TH1I.h" -#include "TFile.h" #include "TKey.h" -#include "TSpectrum.h" #include "TF1.h" +#include + using namespace std; using namespace edm; -// using namespace cond; // Constructor -DTT0Calibration::DTT0Calibration(const edm::ParameterSet& pset) { - // Get the debug parameter for verbose output - debug = pset.getUntrackedParameter("debug"); - if(debug) - cout << "[DTT0Calibration]Constructor called!" << endl; - - // Get the label to retrieve digis from the event - digiLabel = pset.getUntrackedParameter("digiLabel"); - - dbLabel = pset.getUntrackedParameter("dbLabel", ""); - - // The root file which contain the histos per layer - string rootFileName = pset.getUntrackedParameter("rootFileName","DTT0PerLayer.root"); - theFile = new TFile(rootFileName.c_str(), "RECREATE"); - - theCalibWheel = pset.getUntrackedParameter("calibWheel", "All"); //FIXME amke a vector of integer instead of a string - if(theCalibWheel != "All") { - stringstream linestr; - int selWheel; - linestr << theCalibWheel; - linestr >> selWheel; - cout << "[DTT0CalibrationPerLayer] chosen wheel " << selWheel << endl; - } - - // Sector/s to calibrate - theCalibSector = pset.getUntrackedParameter("calibSector", "All"); //FIXME amke a vector of integer instead of a string - if(theCalibSector != "All") { - stringstream linestr; - int selSector; - linestr << theCalibSector; - linestr >> selSector; - cout << "[DTT0CalibrationPerLayer] chosen sector " << selSector << endl; - } - - vector defaultCell; - defaultCell.push_back("None"); - cellsWithHistos = pset.getUntrackedParameter >("cellsWithHisto", defaultCell); - for(vector::const_iterator cell = cellsWithHistos.begin(); cell != cellsWithHistos.end(); ++cell){ - if((*cell) != "None"){ +DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : + debug(pset.getUntrackedParameter("debug")), + digiToken(consumes(pset.getUntrackedParameter("digiLabel"))), + theFile(pset.getUntrackedParameter("rootFileName", "DTT0PerLayer.root").c_str(), "RECREATE"), + nevents(0), + eventsForLayerT0(pset.getParameter("eventsForLayerT0")), + eventsForWireT0(pset.getParameter("eventsForWireT0")), + tpPeakWidth(pset.getParameter("tpPeakWidth")), + tpPeakWidthPerLayer(pset.getParameter("tpPeakWidthPerLayer")), + rejectDigiFromPeak(pset.getParameter("rejectDigiFromPeak")), + hLayerPeaks("hLayerPeaks", "", 3000, 0, 3000), + spectrum(20) + +{ + // Get the debug parameter for verbose output + if(debug) + cout << "[DTT0CalibrationNew]Constructor called!" << endl; + + theCalibWheel = pset.getUntrackedParameter("calibWheel", "All"); //FIXME amke a vector of integer instead of a string + if(theCalibWheel != "All") { + stringstream linestr; + int selWheel; + linestr << theCalibWheel; + linestr >> selWheel; + cout << "[DTT0CalibrationNewPerLayer] chosen wheel " << selWheel << endl; + } + + // Sector/s to calibrate + theCalibSector = pset.getUntrackedParameter("calibSector", "All"); //FIXME amke a vector of integer instead of a string + if(theCalibSector != "All") { stringstream linestr; - int wheel,sector,station,sl,layer,wire; - linestr << (*cell); + int selSector; + linestr << theCalibSector; + linestr >> selSector; + cout << "[DTT0CalibrationNewPerLayer] chosen sector " << selSector << endl; + } + + vector defaultCell; + const auto& cellsWithHistos = pset.getUntrackedParameter >("cellsWithHisto", defaultCell); + for(const auto& cell : cellsWithHistos){ + stringstream linestr; + int wheel, sector, station, sl, layer, wire; + linestr << cell; linestr >> wheel >> sector >> station >> sl >> layer >> wire; - wireIdWithHistos.push_back(DTWireId(wheel,station,sector,sl,layer,wire)); - } - } - - hT0SectorHisto=nullptr; - - nevents=0; - eventsForLayerT0 = pset.getParameter("eventsForLayerT0"); - eventsForWireT0 = pset.getParameter("eventsForWireT0"); - tpPeakWidth = pset.getParameter("tpPeakWidth"); - tpPeakWidthPerLayer = pset.getParameter("tpPeakWidthPerLayer"); - timeBoxWidth = pset.getParameter("timeBoxWidth"); - rejectDigiFromPeak = pset.getParameter("rejectDigiFromPeak"); - - spectrum = new TSpectrum(5); - retryForLayerT0 = 0; + wireIdWithHistos.push_back(DTWireId(wheel, station, sector, sl, layer, wire)); + } } // Destructor -DTT0Calibration::~DTT0Calibration(){ - if(debug) - cout << "[DTT0Calibration]Destructor called!" << endl; +DTT0CalibrationNew::~DTT0CalibrationNew(){ + if(debug) + cout << "[DTT0CalibrationNew]Destructor called!" << endl; - delete spectrum; - theFile->Close(); + theFile.Close(); } - /// Perform the real analysis -void DTT0Calibration::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { - if(debug || event.id().event() % 500==0) - cout << "--- [DTT0Calibration] Analysing Event: #Run: " << event.id().run() - << " #Event: " << event.id().event() << endl; - nevents++; - - // Get the digis from the event - Handle digis; - event.getByLabel(digiLabel, digis); - - // Get the DT Geometry - eventSetup.get().get(dtGeom); - - // Get ttrig DB - edm::ESHandle tTrigMap; - eventSetup.get().get(dbLabel,tTrigMap); - - // Iterate through all digi collections ordered by LayerId - DTDigiCollection::DigiRangeIterator dtLayerIt; - for (dtLayerIt = digis->begin(); - dtLayerIt != digis->end(); - ++dtLayerIt){ - // Get the iterators over the digis associated with this LayerId - const DTDigiCollection::Range& digiRange = (*dtLayerIt).second; - - // Get the layerId - const DTLayerId layerId = (*dtLayerIt).first; //FIXME: check to be in the right sector - const DTChamberId chamberId = layerId.superlayerId().chamberId(); - - if((theCalibWheel != "All") && (layerId.superlayerId().chamberId().wheel() != selWheel)) - continue; - if((theCalibSector != "All") && (layerId.superlayerId().chamberId().sector() != selSector)) - continue; - - //if(debug) { - // cout << "Layer " << layerId<<" with "<get(layerId.superlayerId(), tTrig, tTrigRMS, kFactor, DTTimeUnits::counts ); - if(debug&&(nevents <= 1)){ - cout << " Superlayer: " << layerId.superlayerId() << endl - << " tTrig,tTrigRMS= " << tTrig << ", " << tTrigRMS << endl; - } - - // Loop over all digis in the given layer - for (DTDigiCollection::const_iterator digi = digiRange.first; - digi != digiRange.second; - ++digi) { - double t0 = (*digi).countsTDC(); - - //Use first bunch of events to fill t0 per layer - if(nevents < eventsForLayerT0){ - //Get the per-layer histo from the map - TH1I *hT0LayerHisto = theHistoLayerMap[layerId]; - //If it doesn't exist, book it - if(hT0LayerHisto == nullptr){ - theFile->cd(); - float hT0Min = tTrig - 2*tTrigRMS; - float hT0Max = hT0Min + timeBoxWidth; - hT0LayerHisto = new TH1I(getHistoName(layerId).c_str(), - "T0 from pulses by layer (TDC counts, 1 TDC count = 0.781 ns)", - timeBoxWidth,hT0Min,hT0Max); - if(debug) - cout << " New T0 per Layer Histo: " << hT0LayerHisto->GetName() << endl; - theHistoLayerMap[layerId] = hT0LayerHisto; - } - - //Fill the histos - theFile->cd(); - if(hT0LayerHisto != nullptr) { - // if(debug) - // cout<<"Filling histo "<GetName()<<" with digi "<Fill(t0); - } - } - - //Use all the remaining events to compute t0 per wire - if(nevents>eventsForLayerT0){ - // Get the wireId - const DTWireId wireId(layerId, (*digi).wire()); - if(debug) { - cout << " Wire: " << wireId << endl - << " time (TDC counts): " << (*digi).countsTDC()<< endl; - } - - //Fill the histos per wire for the chosen cells - vector::iterator it = find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId); - if (it!=wireIdWithHistos.end()){ - //Get the per-wire histo from the map - TH1I *hT0WireHisto = theHistoWireMap[wireId]; - //If it doesn't exist, book it - if(hT0WireHisto == nullptr){ - theFile->cd(); - hT0WireHisto = new TH1I(getHistoName(wireId).c_str(),"T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)",7000,0,7000); - //hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin())-100, - //hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin())+100); - if(debug) - cout << " New T0 per wire Histo: " << hT0WireHisto->GetName() << endl; - theHistoWireMap[wireId] = hT0WireHisto; - } - //Fill the histos - theFile->cd(); - if(hT0WireHisto != nullptr) { - //if(debug) - // cout<<"Filling histo "<GetName()<<" with digi "<Fill(t0); - } - } - - //Check the tzero has reasonable value - //float hT0Min = tTrig - 2*tTrigRMS; - //float hT0Max = hT0Min + timeBoxWidth; - /*if(abs(hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()) - t0) > rejectDigiFromPeak){ - if(debug) - cout<<"digi skipped because t0 per sector "<GetBinCenter(hT0SectorHisto->GetMaximumBin())< hT0Max)){ - if(debug) - cout<<"digi skipped because t0 outside of interval (" << hT0Min << "," << hT0Max << ")" < rejectDigiFromPeak){ - if(debug) - cout<<"digi skipped because t0 too far from peak " << theTPPeakMap[layerId] << endl; - continue; - } - - //Find to ref. per chamber - theSumT0ByChamber[chamberId] = theSumT0ByChamber[chamberId] + t0; - theCountT0ByChamber[chamberId]++; - - //Use second bunch of events to compute a t0 reference per wire - if(nevents< (eventsForLayerT0 + eventsForWireT0)){ - if(!nDigiPerWire_ref[wireId]){ - mK_ref[wireId] = 0; - } - nDigiPerWire_ref[wireId] = nDigiPerWire_ref[wireId] + 1; - mK_ref[wireId] = mK_ref[wireId] + (t0-mK_ref[wireId])/nDigiPerWire_ref[wireId]; - } - //Use last all the remaining events to compute the mean and sigma t0 per wire - else if(nevents>(eventsForLayerT0 + eventsForWireT0)){ - if(abs(t0-mK_ref[wireId]) > tpPeakWidth) - continue; - if(!nDigiPerWire[wireId]){ - theAbsoluteT0PerWire[wireId] = 0; - qK[wireId] = 0; - mK[wireId] = 0; - } - nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1; - theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0; - //theSigmaT0PerWire[wireId] = theSigmaT0PerWire[wireId] + (t0*t0); - qK[wireId] = qK[wireId] + ((nDigiPerWire[wireId]-1)*(t0-mK[wireId])*(t0-mK[wireId])/nDigiPerWire[wireId]); - mK[wireId] = mK[wireId] + (t0-mK[wireId])/nDigiPerWire[wireId]; - } - }//end if(nevents>1000) - }//end loop on digi - }//end loop on layer - - //Use the t0 per layer histos to have an indication about the t0 position - if(nevents == eventsForLayerT0){ - bool increaseEvtsForLayerT0 = false; - for(map::const_iterator lHisto = theHistoLayerMap.begin(); - lHisto != theHistoLayerMap.end(); - ++lHisto){ - if(debug) - cout<<"Reading histogram "<<(*lHisto).second->GetName()<<" with mean "<<(*lHisto).second->GetMean()<<" and RMS "<<(*lHisto).second->GetRMS() << endl; - - //Find peaks - //int npeaks = spectrum->Search((*lHisto).second,0.5,"goff"); - //int npeaks = spectrum->Search((*lHisto).second,(tpPeakWidthPerLayer/2.),"goff",0.3); - int npeaks = spectrum->Search((*lHisto).second,(tpPeakWidthPerLayer/2.),"",0.3); - - double *peaks = spectrum->GetPositionX(); - //Put in a std::vector - vector peakMeans(peaks,peaks + npeaks); - //Sort the peaks in ascending order - sort(peakMeans.begin(),peakMeans.end()); - - //Find best peak -- preliminary criteria: find peak closest to center of time box - float tTrig,tTrigRMS, kFactor; - tTrigMap->get((*lHisto).first.superlayerId(), tTrig, tTrigRMS, kFactor, DTTimeUnits::counts ); - - double timeBoxCenter = (2*tTrig + (float)timeBoxWidth)/2.; - double hMin = (*lHisto).second->GetXaxis()->GetXmin(); - double hMax = (*lHisto).second->GetXaxis()->GetXmax(); - vector::const_iterator tpPeak = peakMeans.end(); - for(vector::const_iterator it = peakMeans.begin(); it != peakMeans.end(); ++it){ - double mean = *it; - - int bin = (*lHisto).second->GetXaxis()->FindBin(mean); - double yp = (*lHisto).second->GetBinContent(bin); - if(debug) cout << "Peak : (" << mean << "," << yp << ")" << endl; - - //Find RMS - double previous_peak = (it == peakMeans.begin())?hMin:*(it - 1); - double next_peak = (it == (peakMeans.end()-1))?hMax:*(it + 1); - - double rangemin = mean - (mean - previous_peak)/8.; - double rangemax = mean + (next_peak - mean)/8.; - int binmin = (*lHisto).second->GetXaxis()->FindBin(rangemin); - int binmax = (*lHisto).second->GetXaxis()->FindBin(rangemax); - (*lHisto).second->GetXaxis()->SetRange(binmin,binmax); - //RMS estimate - double rms_seed = (*lHisto).second->GetRMS(); - - /*rangemin = mean - 2*rms_seed; - rangemax = mean + 2*rms_seed; - if(debug) cout << "Seed for RMS, Fit min, Fit max: " << rms_seed << ", " << rangemin << ", " << rangemax << endl; - //Fit to gaussian - string funcname("fitFcn_"); - funcname += (*lHisto).second->GetName(); - if(debug) cout << "Fitting function " << funcname << endl; - TF1* func = new TF1(funcname.c_str(),"gaus",rangemin,rangemax); - func->SetParameters(yp,mean,rms_seed); - (*lHisto).second->Fit(func,"Q","",rangemin,rangemax); - float fitconst = func->GetParameter(0); - float fitmean = func->GetParameter(1); - float fitrms = func->GetParameter(2); - float chisquare = func->GetChisquare()/func->GetNDF(); - if(debug) cout << "Gaussian fit constant,mean,RMS,chi2= " << fitconst << ", " << fitmean << ", " << fitrms << ", " << chisquare << endl;*/ - - //Reject peaks with RMS larger than specified - //if(fitrms > tpPeakWidth) continue; - if(rms_seed > tpPeakWidthPerLayer) continue; - - if(fabs(mean - timeBoxCenter) < fabs(*tpPeak - timeBoxCenter)) tpPeak = it; - } - //Didn't find peak - /*if(tpPeak == peakMeans.end()){ - if(retryForLayerT0 < 2){ - increaseEvtsForLayerT0 = true; - retryForLayerT0++; - break; - } - }*/ - - double selPeak = (tpPeak != peakMeans.end())?*tpPeak:(*lHisto).second->GetBinCenter((*lHisto).second->GetMaximumBin()); - if(debug) cout << "Peak selected at " << selPeak << endl; - - theTPPeakMap[(*lHisto).first] = selPeak; - - //Take the mean as a first t0 estimation - /*if((*lHisto).second->GetRMS() < tpPeakWidth){ - if(hT0SectorHisto == 0){ - hT0SectorHisto = new TH1D("hT0AllLayerOfSector","T0 from pulses per layer in sector", - //20, (*lHisto).second->GetMean()-100, (*lHisto).second->GetMean()+100); - 700, 0, 7000); - //300,3300,3600); - } - if(debug) - cout<<" accepted"<GetXaxis()->SetRangeUser(3300,3600); - hT0SectorHisto->Fill((*lHisto).second->GetMean()); - //hT0SectorHisto->Fill(aux_histo->GetMean()); +/// Perform the real analysis +void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { + nevents++; + + // Get the digis from the event + Handle digis; + event.getByToken(digiToken, digis); + + // Get the DT Geometry + if (nevents == 1) + eventSetup.get().get(dtGeom); + + // Iterate through all digi collections ordered by LayerId + for (const auto& digis_per_layer : *digis) + { + //std::cout << __LINE__ << std::endl; + // Get the iterators over the digis associated with this LayerId + const DTDigiCollection::Range& digiRange = digis_per_layer.second; + + // Get the layerId + const DTLayerId layerId = digis_per_layer.first; + //const DTChamberId chamberId = layerId.superlayerId().chamberId(); + + if((theCalibWheel != "All") && (layerId.superlayerId().chamberId().wheel() != selWheel)) + continue; + if((theCalibSector != "All") && (layerId.superlayerId().chamberId().sector() != selSector)) + continue; + + // Loop over all digis in the given layer + for (DTDigiCollection::const_iterator digi = digiRange.first; + digi != digiRange.second; + ++digi) + { + const double t0 = digi->countsTDC(); + const DTWireId wireIdtmp(layerId, (*digi).wire()); + + // Use first bunch of events to fill t0 per layer + if(nevents <= eventsForLayerT0){ + // If it doesn't exist, book it + if(not theHistoLayerMap.count(layerId)){ + theHistoLayerMap[layerId] = TH1I(getHistoName(layerId).c_str(), + "T0 from pulses by layer (TDC counts, 1 TDC count = 0.781 ns)", + 3000, + 0, + 3000 + ); + if(debug) + cout << " New T0 per Layer Histo: " << theHistoLayerMap[layerId].GetName() << endl; + } + theHistoLayerMap[layerId].Fill(t0); + } + + // Use all the remaining events to compute t0 per wire + if(nevents>eventsForLayerT0){ + // Get the wireId + const DTWireId wireId(layerId, (*digi).wire()); + if(debug) { + cout << " Wire: " << wireId << endl + << " time (TDC counts): " << (*digi).countsTDC()<< endl; + } + + //Fill the histos per wire for the chosen cells + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) != layerIdWithWireHistos.end() or + std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) + { + //If it doesn't exist, book it + if(theHistoWireMap.count(wireId) == 0){ + theHistoWireMap[wireId] = TH1I(getHistoName(wireId).c_str(), + "T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)", + 7000, + 0, + 7000 + ); + if(debug) + cout << " New T0 per wire Histo: " << theHistoWireMap[wireId].GetName() << endl; + } + theHistoWireMap[wireId].Fill(t0); + } + + //Select per layer + if(fabs(theTPPeakMap[layerId] - t0) > rejectDigiFromPeak){ + if(debug) + cout<<"digi skipped because t0 too far from peak " << theTPPeakMap[layerId] << endl; + continue; + } + + //Use second bunch of events to compute a t0 reference per wire + if(nevents <= (eventsForLayerT0 + eventsForWireT0)){ + if(!nDigiPerWire_ref[wireId]){ + mK_ref[wireId] = 0; + } + nDigiPerWire_ref[wireId] = nDigiPerWire_ref[wireId] + 1; + mK_ref[wireId] = mK_ref[wireId] + (t0-mK_ref[wireId])/nDigiPerWire_ref[wireId]; + } + //Use last all the remaining events to compute the mean and sigma t0 per wire + else if(nevents > (eventsForLayerT0 + eventsForWireT0)){ + if(abs(t0-mK_ref[wireId]) > tpPeakWidth) + continue; + if(!nDigiPerWire[wireId]){ + theAbsoluteT0PerWire[wireId] = 0; + qK[wireId] = 0; + mK[wireId] = 0; + } + nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1; + theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0; + qK[wireId] = qK[wireId] + ((nDigiPerWire[wireId]-1)*(t0-mK[wireId])*(t0-mK[wireId])/nDigiPerWire[wireId]); + mK[wireId] = mK[wireId] + (t0-mK[wireId])/nDigiPerWire[wireId]; + } + }//end if(nevents>1000) + }//end loop on digi + }//end loop on layer + + //Use the t0 per layer histos to have an indication about the t0 position + if(nevents == eventsForLayerT0){ + for(const auto& lHisto : theHistoLayerMap) + { + const auto& layerId = lHisto.first; + const auto& hist = lHisto.second; + if(debug) + cout << "Reading histogram " << hist.GetName() << " with mean " << hist.GetMean() << " and RMS " << hist.GetRMS() << endl; + + //Find peaks + int npeaks = spectrum.Search(&hist, (tpPeakWidthPerLayer / 2.), "", 0.3); + + double *peaks = spectrum.GetPositionX(); + //Put in a std::vector + vector peakMeans(peaks, peaks + npeaks); + //Sort the peaks in ascending order + sort(peakMeans.begin(), peakMeans.end()); + + if (peakMeans.empty()) + { + theTPPeakMap[layerId] = hist.GetMaximumBin(); + std::cout << "No peaks found by peakfinder in layer " << layerId << ". Taking maximum bin at " << theTPPeakMap[layerId] << ". Please check!" << std::endl; + layerIdWithWireHistos.push_back(layerId); + } + else if (fabs(hist.GetXaxis()->FindBin(peakMeans.front()) - hist.GetXaxis()->FindBin(peakMeans.back())) < rejectDigiFromPeak) + { + theTPPeakMap[layerId] = peakMeans[peakMeans.size() / 2]; + } + else + { + bool peak_set = false; + for (const auto& peak : peakMeans) + { + // Skip if at low edge + if (peak - tpPeakWidthPerLayer <= 0) + continue; + // Get integral of peak + double sum = 0; + for (int ibin=peak - tpPeakWidthPerLayer; ibin 5) + { + std::cout << "Found more than 5 peaks in layer " << layerId << ". Please check!" << std::endl; + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) + layerIdWithWireHistos.push_back(layerId); + } + // Check for noise + int nspikes = 0; + for (int ibin=0; ibin hist.GetMaximum() * 0.001) + nspikes++; + } + if (nspikes > 50) + { + std::cout << "Found a lot of (>50) small spikes in layer " << layerId << ". Please check if all wires are functioning as expected!" << std::endl; + if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) + layerIdWithWireHistos.push_back(layerId); + } + hLayerPeaks.Fill(theTPPeakMap[layerId]); } - //Take the mean of noise + 400ns as a first t0 estimation - //if((*lHisto).second->GetRMS()>10.0 && ((*lHisto).second->GetRMS()<15.0)){ - //double t0_estim = (*lHisto).second->GetMean() + 400; - //if(hT0SectorHisto == 0){ - // hT0SectorHisto = new TH1D("hT0AllLayerOfSector","T0 from pulses per layer in sector", - // //20, t0_estim-100, t0_estim+100); - // 700, 0, 7000); - //} - //if(debug) - // cout<<" accepted + 400ns"<Fill((*lHisto).second->GetMean() + 400); - //} - if(debug) - cout<GetName()] = (*lHisto).second->GetMean(); - theSigmaT0LayerMap[(*lHisto).second->GetName()] = (*lHisto).second->GetRMS();*/ - } - /*if(!hT0SectorHisto){ - cout<<"[DTT0Calibration]: All the t0 per layer are still uncorrect: trying with greater number of events"<GetBinCenter(hT0SectorHisto->GetMaximumBin())<cd(); - //hT0SectorHisto->Write(); - for(map::const_iterator wHisto = theHistoWireMap.begin(); - wHisto != theHistoWireMap.end(); - ++wHisto) { - (*wHisto).second->Write(); - } - for(map::const_iterator lHisto = theHistoLayerMap.begin(); - lHisto != theHistoLayerMap.end(); - ++lHisto) { - (*lHisto).second->Write(); - } - - if(debug) - cout << "[DTT0Calibration] Compute and store t0 and sigma per wire" << endl; - - for(map::const_iterator chamber = theSumT0ByChamber.begin(); - chamber != theSumT0ByChamber.end(); - ++chamber) theRefT0ByChamber[(*chamber).first] = theSumT0ByChamber[(*chamber).first]/((double)theCountT0ByChamber[(*chamber).first]); - - for(map::const_iterator wiret0 = theAbsoluteT0PerWire.begin(); - wiret0 != theAbsoluteT0PerWire.end(); - ++wiret0){ - if(nDigiPerWire[(*wiret0).first]){ - double t0 = (*wiret0).second/nDigiPerWire[(*wiret0).first]; - DTChamberId chamberId = ((*wiret0).first).chamberId(); - //theRelativeT0PerWire[(*wiret0).first] = t0 - hT0SectorHisto->GetBinCenter(hT0SectorHisto->GetMaximumBin()); - theRelativeT0PerWire[(*wiret0).first] = t0 - theRefT0ByChamber[chamberId]; - cout<<"Wire "<<(*wiret0).first<<" has t0 "< superLayers = dtGeom->superLayers(); - // Loop over all SLs - for(vector::const_iterator sl = superLayers.begin(); - sl != superLayers.end(); sl++) { - - - //Compute mean for odd and even superlayers - double oddLayersMean=0; - double evenLayersMean=0; - double oddLayersDen=0; - double evenLayersDen=0; - for(map::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(debug) - cout<<"[DTT0Calibration] Superlayer "<<(*sl)->id() - <<"layer " <<(*wiret0).first.layerId().layer()<<" with "<<(*wiret0).second<Write(); + hLayerPeaks.Write(); + for(const auto& wHisto : theHistoWireMap){ + wHisto.second.Write(); + } + for(const auto& lHisto : theHistoLayerMap ) { + lHisto.second.Write(); + } + + if(debug) + cout << "[DTT0CalibrationNew] Compute and store t0 and sigma per wire" << endl; + + // Calculate uncertainties per wire (counting experiment) + for (auto& wiret0 : theAbsoluteT0PerWire) + { + auto& wireId = wiret0.first; + if (nDigiPerWire[wireId] > 1 ) + theSigmaT0PerWire[wireId] = qK[wireId] / (nDigiPerWire[wireId] - 1); + else + theSigmaT0PerWire[wireId] = 999.; // Only one measurement: uncertainty -> infinity + // syst uncert + //theSigmaT0PerWire[wireId] += pow(0.5, 2)); + // Every time the same measurement. Use Laplace estimator as estimation how propable it is to measure another value due to limited size of sample + if (theSigmaT0PerWire[wireId] == 0) + { + theSigmaT0PerWire[wireId] += pow(1. / (nDigiPerWire[wireId] + 1), 2); + } + } + + // function to calculate unweighted means + auto unweighted_mean_function = [] (const std::list& values, const std::list& sigmas) + { + double mean = 0; + for (auto& value : values) + { + mean += value; } - } - oddLayersMean = oddLayersMean/oddLayersDen; - evenLayersMean = evenLayersMean/evenLayersDen; - if(debug && oddLayersMean) - cout<<"[DTT0Calibration] Relative T0 mean for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(((*wiret0).first.layerId().layer()) % 2){ - oddLayersSigma = oddLayersSigma + ((*wiret0).second - oddLayersMean) * ((*wiret0).second - oddLayersMean); - } - else{ - evenLayersSigma = evenLayersSigma + ((*wiret0).second - evenLayersMean) * ((*wiret0).second - evenLayersMean); - } + mean /= values.size(); + + double uncertainty = 0; + for (auto& value : values) + { + uncertainty += pow(value - mean, 2); } - } - oddLayersSigma = oddLayersSigma/oddLayersDen; - evenLayersSigma = evenLayersSigma/evenLayersDen; - oddLayersSigma = sqrt(oddLayersSigma); - evenLayersSigma = sqrt(evenLayersSigma); - - if(debug && oddLayersMean) - cout<<"[DTT0Calibration] Relative T0 sigma for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - if(((*wiret0).first.layerId().layer()) % 2){ - if(abs((*wiret0).second - oddLayersMean) < (2*oddLayersSigma)) - oddLayersFinalMean = oddLayersFinalMean + (*wiret0).second; - } - else{ - if(abs((*wiret0).second - evenLayersMean) < (2*evenLayersSigma)) - evenLayersFinalMean = evenLayersFinalMean + (*wiret0).second; - } + uncertainty /= values.size(); + uncertainty = sqrt(uncertainty); + return std::make_pair(mean, uncertainty); + }; + + // correct for odd-even effect in each super layer + std::map > mean_sigma_even; + std::map > mean_sigma_odd; + for (const auto& superlayer : dtGeom->superLayers()) + { + const auto superlayer_id = superlayer->id(); + std::list values_even; + std::list sigmas_even; + std::list values_odd; + std::list sigmas_odd; + + for (const auto& wiret0 : theAbsoluteT0PerWire) + { + const auto& wireId = wiret0.first; + if (wireId.layerId().superlayerId() == superlayer_id) + { + const auto& t0 = wiret0.second / nDigiPerWire[wireId]; + if (wireId.layerId().layer() % 2) + { + values_odd.push_back(t0); + sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + else + { + values_even.push_back(t0); + sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + } } - } - oddLayersFinalMean = oddLayersFinalMean/oddLayersDen; - evenLayersFinalMean = evenLayersFinalMean/evenLayersDen; - if(debug && oddLayersMean) - cout<<"[DTT0Calibration] Final relative T0 mean for odd layers "<::const_iterator wiret0 = theRelativeT0PerWire.begin(); - wiret0 != theRelativeT0PerWire.end(); - ++wiret0){ - if((*wiret0).first.layerId().superlayerId() == (*sl)->id()){ - double t0=-999; - if(((*wiret0).first.layerId().layer()) % 2) - t0 = (*wiret0).second + (evenLayersFinalMean - oddLayersFinalMean); - else - t0 = (*wiret0).second; - - cout<<"[DTT0Calibration] Wire "<<(*wiret0).first<<" has t0 "<<(*wiret0).second<<" (relative, after even-odd layer corrections) " - <<" sigma "<set((*wiret0).first, t0, theSigmaT0PerWire[(*wiret0).first],DTTimeUnits::counts); + // get mean and uncertainty + mean_sigma_even.emplace(superlayer_id, unweighted_mean_function(values_even, sigmas_even)); + mean_sigma_odd.emplace(superlayer_id, unweighted_mean_function(values_odd, sigmas_odd)); + } + + // filter outliers + for (const auto& superlayer : dtGeom->superLayers()) + { + const auto superlayer_id = superlayer->id(); + std::list values_even; + std::list sigmas_even; + std::list values_odd; + std::list sigmas_odd; + + for (const auto& wiret0 : theAbsoluteT0PerWire) + { + const auto& wireId = wiret0.first; + if (wireId.layerId().superlayerId() == superlayer_id) + { + const auto& t0 = wiret0.second / nDigiPerWire[wireId]; + if (wireId.layerId().layer() % 2 and abs(t0 - mean_sigma_odd[superlayer_id].first) < 2 * mean_sigma_odd[superlayer_id].second) + { + values_odd.push_back(t0); + sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + else + { + if (abs(t0 - mean_sigma_even[superlayer_id].first) < 2 * mean_sigma_even[superlayer_id].second) + { + values_even.push_back(t0); + sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); + } + } + } } - } - } - - ///Change t0 absolute reference -> from sector peak to chamber average - if(debug) - cout << "[DTT0Calibration]Computing relative t0 wrt to chamber average" << endl; - //Compute the reference for each chamber - map sumT0ByChamber; - map countT0ByChamber; - for(DTT0::const_iterator tzero = t0s->begin(); - tzero != t0s->end(); ++tzero) { -// @@@ NEW DTT0 FORMAT -// DTChamberId chamberId((*tzero).first.wheelId, -// (*tzero).first.stationId, -// (*tzero).first.sectorId); -// sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + (*tzero).second.t0mean; - int channelId = tzero->channelId; - if ( channelId == 0 ) continue; - DTWireId wireId(channelId); - DTChamberId chamberId(wireId.chamberId()); - //sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + tzero->t0mean; -// @@@ better DTT0 usage - float t0mean_f; - float t0rms_f; - t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); - sumT0ByChamber[chamberId] = sumT0ByChamber[chamberId] + t0mean_f; -// @@@ NEW DTT0 END - countT0ByChamber[chamberId]++; - } - - //Change reference for each wire and store the new t0s in the new map - for(DTT0::const_iterator tzero = t0s->begin(); - tzero != t0s->end(); ++tzero) { -// @@@ NEW DTT0 FORMAT -// DTChamberId chamberId((*tzero).first.wheelId, -// (*tzero).first.stationId, -// (*tzero).first.sectorId); -// double t0mean = ((*tzero).second.t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); -// double t0rms = (*tzero).second.t0rms; -// DTWireId wireId((*tzero).first.wheelId, -// (*tzero).first.stationId, -// (*tzero).first.sectorId, -// (*tzero).first.slId, -// (*tzero).first.layerId, -// (*tzero).first.cellId); - int channelId = tzero->channelId; - if ( channelId == 0 ) continue; - DTWireId wireId( channelId ); - DTChamberId chamberId(wireId.chamberId()); - //double t0mean = (tzero->t0mean) - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); - //double t0rms = tzero->t0rms; -// @@@ better DTT0 usage - float t0mean_f; - float t0rms_f; - t0s->get(wireId,t0mean_f,t0rms_f,DTTimeUnits::counts); - double t0mean = t0mean_f - (sumT0ByChamber[chamberId]/countT0ByChamber[chamberId]); - double t0rms = t0rms_f; -// @@@ NEW DTT0 END - t0sWRTChamber->set(wireId, - t0mean, - t0rms, - DTTimeUnits::counts); - if(debug){ - //cout<<"Chamber "<t0mean<<" to "< > values_per_chamber; + std::map > sigmas_per_chamber; + for (const auto& wire_t0 : theAbsoluteT0PerWire) + { + const auto& wire_id = wire_t0.first; + const auto& chamber_id = wire_id.chamberId(); + const auto& t0 = wire_t0.second; + values_per_chamber[chamber_id].push_back(t0); + sigmas_per_chamber[chamber_id].push_back(sqrt(theSigmaT0PerWire[wire_id])); + } + + std::map > mean_per_chamber; + for (const auto& chamber_mean : values_per_chamber) + { + const auto& chamber_id = chamber_mean.first; + const auto& means = chamber_mean.second; + const auto& sigmas = sigmas_per_chamber[chamber_id]; + mean_per_chamber.emplace(chamber_id, unweighted_mean_function(means, sigmas)); + } + + // calculate relative values + for (const auto& wire_t0 : theAbsoluteT0PerWire) + { + const auto& wire_id = wire_t0.first; + const auto& chamber_id = wire_id.chamberId(); + const auto& t0 = wire_t0.second; + theRelativeT0PerWire.emplace(wire_id, t0 - mean_per_chamber[chamber_id].first); + cout << "[DTT0CalibrationNew] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " + << " sigma "<< sqrt(theSigmaT0PerWire[wire_id]) <set(wire_id, + t0, + sqrt(theSigmaT0PerWire[wire_id]), + DTTimeUnits::counts + ); + } + + ///Write the t0 map into DB + if(debug) + cout << "[DTT0CalibrationNew]Writing values in DB!" << endl; + // FIXME: to be read from cfg? + string t0Record = "DTT0Rcd"; + // Write the t0 map to DB + DTCalibDBUtils::writeToDB(t0Record, t0sWRTChamber); + delete t0sWRTChamber; } -string DTT0Calibration::getHistoName(const DTWireId& wId) const { - string histoName; - stringstream theStream; - theStream << "Ch_" << wId.wheel() << "_" << wId.station() << "_" << wId.sector() - << "_SL" << wId.superlayer() << "_L" << wId.layer() << "_W"<< wId.wire() <<"_hT0Histo"; - theStream >> histoName; - return histoName; +string DTT0CalibrationNew::getHistoName(const DTWireId& wId) const { + string histoName; + stringstream theStream; + theStream << "Ch_" << wId.wheel() << "_" << wId.station() << "_" << wId.sector() + << "_SL" << wId.superlayer() << "_L" << wId.layer() << "_W"<< wId.wire() <<"_hT0Histo"; + theStream >> histoName; + return histoName; } -string DTT0Calibration::getHistoName(const DTLayerId& lId) const { - string histoName; - stringstream theStream; - theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector() - << "_SL" << lId.superlayer() << "_L" << lId.layer() <<"_hT0Histo"; - theStream >> histoName; - return histoName; +string DTT0CalibrationNew::getHistoName(const DTLayerId& lId) const { + string histoName; + stringstream theStream; + theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector() + << "_SL" << lId.superlayer() << "_L" << lId.layer() <<"_hT0Histo"; + theStream >> histoName; + return histoName; } - diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h index 47df1e90e3ea7..a7476147aca81 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h @@ -1,46 +1,53 @@ -#ifndef CalibMuon_DTT0Calibration_H -#define CalibMuon_DTT0Calibration_H +#ifndef CalibMuon_DTT0CalibrationNew_H +#define CalibMuon_DTT0CalibrationNew_H -/** \class DTT0Calibration +/** \class DTT0CalibrationNew * Analyzer class computes the mean and RMS of t0 from pulses. * Those values are written in the DB with cell granularity. The * mean value for each channel is normalized to a reference time common to all the sector. - * The t0 of wires in odd layers are corrected for the relative difference between - * odd and even layers + * The t0 of wires in odd layers are corrected for the relative difference between + * odd and even layers * * \author S. Bolognesi - INFN Torino */ -#include "FWCore/Framework/interface/EDAnalyzer.h" +//#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" #include "FWCore/Framework/interface/ESHandle.h" #include #include #include -class TFile; -class TH1I; -class TH1D; -class TSpectrum; +#include "TFile.h" +#include "TH1I.h" +#include "TH1D.h" +#include "TSpectrum.h" + +//class TFile; +//class TH1I; +//class TH1D; +//class TSpectrum; class DTT0; -class DTT0Calibration : public edm::EDAnalyzer { +class DTT0CalibrationNew : public edm::one::EDAnalyzer<> { public: /// Constructor - DTT0Calibration(const edm::ParameterSet& pset); + DTT0CalibrationNew(const edm::ParameterSet& pset); /// Destructor - ~DTT0Calibration() override; + virtual ~DTT0CalibrationNew(); // Operations /// Fill the maps with t0 (by channel) - void analyze(const edm::Event & event, const edm::EventSetup& eventSetup) override; + void analyze(const edm::Event & event, const edm::EventSetup& eventSetup); /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity - void endJob() override; + void endJob(); protected: @@ -54,14 +61,10 @@ class DTT0Calibration : public edm::EDAnalyzer { bool debug; // The label used to retrieve digis from the event - std::string digiLabel; - - std::string dbLabel; + edm::EDGetTokenT digiToken; // The root file which contain the histos per layer - TFile *theFile; - // The root file which will contain the histos per wire (for the given layer) - TFile *theOutputFile; + TFile theFile; //The event counter unsigned int nevents; @@ -76,14 +79,9 @@ class DTT0Calibration : public edm::EDAnalyzer { //Acceptance of t0 w.r.t. reference peak double tpPeakWidthPerLayer; - //Size of timeBox - unsigned int timeBoxWidth; - //Digi's will be rejected if too far from TP peak unsigned int rejectDigiFromPeak; - unsigned int retryForLayerT0; - //The wheels,sector to be calibrated (default All) std::string theCalibWheel; int selWheel; @@ -91,15 +89,16 @@ class DTT0Calibration : public edm::EDAnalyzer { int selSector; // Map of the histos and graph by layer - std::map theHistoLayerMap; - //Histo with t0 mean per layer for all the sector - TH1D* hT0SectorHisto; + std::map theHistoLayerMap; + + // Histogram containing position of all peaks + TH1D hLayerPeaks; - TSpectrum* spectrum; + TSpectrum spectrum; //Layer with histos for each wire std::vector wireIdWithHistos; - std::vector cellsWithHistos; + std::vector layerIdWithWireHistos; //Maps with t0, sigma, number of digi per wire std::map theAbsoluteT0PerWire; @@ -111,7 +110,7 @@ class DTT0Calibration : public edm::EDAnalyzer { std::map mK_ref; std::map qK; //Map with histo per wire for the chosen layer - std::map theHistoWireMap; + std::map theHistoWireMap; //Map with mean and RMS of t0 per layer std::map theT0LayerMap; std::map theSigmaT0LayerMap; @@ -119,6 +118,8 @@ class DTT0Calibration : public edm::EDAnalyzer { //Ref. t0 per chamber std::map theSumT0ByChamber; std::map theCountT0ByChamber; + std::map theSigmaT0ByChamber; + std::map theMeanT0ByChamber; std::map theRefT0ByChamber; //DTGeometry used to loop on the SL in the endJob diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc deleted file mode 100644 index ff5cc7a8fb5d5..0000000000000 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.cc +++ /dev/null @@ -1,501 +0,0 @@ -/* - * See header file for a description of this class. - * - * $Date: 2012/05/11 17:17:17 $ - * $Revision: 1.6 $ - * \author S. Bolognesi - INFN Torino - * 06/08/2008 Mofified by Antonio.Vilela.Pereira@cern.ch - */ - -#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" -#include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/Records/interface/MuonNumberingRecord.h" - -#include "DataFormats/DTDigi/interface/DTDigiCollection.h" -#include "CondFormats/DTObjects/interface/DTT0.h" - -#include -#include - -#include "TKey.h" -#include "TF1.h" - -#include - -using namespace std; -using namespace edm; - -// Constructor -DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : - debug(pset.getUntrackedParameter("debug")), - digiToken(consumes(pset.getUntrackedParameter("digiLabel"))), - theFile(pset.getUntrackedParameter("rootFileName", "DTT0PerLayer.root").c_str(), "RECREATE"), - nevents(0), - eventsForLayerT0(pset.getParameter("eventsForLayerT0")), - eventsForWireT0(pset.getParameter("eventsForWireT0")), - tpPeakWidth(pset.getParameter("tpPeakWidth")), - tpPeakWidthPerLayer(pset.getParameter("tpPeakWidthPerLayer")), - rejectDigiFromPeak(pset.getParameter("rejectDigiFromPeak")), - hLayerPeaks("hLayerPeaks", "", 3000, 0, 3000), - spectrum(20) - -{ - // Get the debug parameter for verbose output - if(debug) - cout << "[DTT0CalibrationNew]Constructor called!" << endl; - - theCalibWheel = pset.getUntrackedParameter("calibWheel", "All"); //FIXME amke a vector of integer instead of a string - if(theCalibWheel != "All") { - stringstream linestr; - int selWheel; - linestr << theCalibWheel; - linestr >> selWheel; - cout << "[DTT0CalibrationNewPerLayer] chosen wheel " << selWheel << endl; - } - - // Sector/s to calibrate - theCalibSector = pset.getUntrackedParameter("calibSector", "All"); //FIXME amke a vector of integer instead of a string - if(theCalibSector != "All") { - stringstream linestr; - int selSector; - linestr << theCalibSector; - linestr >> selSector; - cout << "[DTT0CalibrationNewPerLayer] chosen sector " << selSector << endl; - } - - vector defaultCell; - const auto& cellsWithHistos = pset.getUntrackedParameter >("cellsWithHisto", defaultCell); - for(const auto& cell : cellsWithHistos){ - stringstream linestr; - int wheel, sector, station, sl, layer, wire; - linestr << cell; - linestr >> wheel >> sector >> station >> sl >> layer >> wire; - wireIdWithHistos.push_back(DTWireId(wheel, station, sector, sl, layer, wire)); - } -} - -// Destructor -DTT0CalibrationNew::~DTT0CalibrationNew(){ - if(debug) - cout << "[DTT0CalibrationNew]Destructor called!" << endl; - - theFile.Close(); -} - -/// Perform the real analysis -void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { - nevents++; - - // Get the digis from the event - Handle digis; - event.getByToken(digiToken, digis); - - // Get the DT Geometry - if (nevents == 1) - eventSetup.get().get(dtGeom); - - // Iterate through all digi collections ordered by LayerId - for (const auto& digis_per_layer : *digis) - { - //std::cout << __LINE__ << std::endl; - // Get the iterators over the digis associated with this LayerId - const DTDigiCollection::Range& digiRange = digis_per_layer.second; - - // Get the layerId - const DTLayerId layerId = digis_per_layer.first; - //const DTChamberId chamberId = layerId.superlayerId().chamberId(); - - if((theCalibWheel != "All") && (layerId.superlayerId().chamberId().wheel() != selWheel)) - continue; - if((theCalibSector != "All") && (layerId.superlayerId().chamberId().sector() != selSector)) - continue; - - // Loop over all digis in the given layer - for (DTDigiCollection::const_iterator digi = digiRange.first; - digi != digiRange.second; - ++digi) - { - const double t0 = digi->countsTDC(); - const DTWireId wireIdtmp(layerId, (*digi).wire()); - - // Use first bunch of events to fill t0 per layer - if(nevents <= eventsForLayerT0){ - // If it doesn't exist, book it - if(not theHistoLayerMap.count(layerId)){ - theHistoLayerMap[layerId] = TH1I(getHistoName(layerId).c_str(), - "T0 from pulses by layer (TDC counts, 1 TDC count = 0.781 ns)", - 3000, - 0, - 3000 - ); - if(debug) - cout << " New T0 per Layer Histo: " << theHistoLayerMap[layerId].GetName() << endl; - } - theHistoLayerMap[layerId].Fill(t0); - } - - // Use all the remaining events to compute t0 per wire - if(nevents>eventsForLayerT0){ - // Get the wireId - const DTWireId wireId(layerId, (*digi).wire()); - if(debug) { - cout << " Wire: " << wireId << endl - << " time (TDC counts): " << (*digi).countsTDC()<< endl; - } - - //Fill the histos per wire for the chosen cells - if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) != layerIdWithWireHistos.end() or - std::find(wireIdWithHistos.begin(),wireIdWithHistos.end(),wireId) != wireIdWithHistos.end()) - { - //If it doesn't exist, book it - if(theHistoWireMap.count(wireId) == 0){ - theHistoWireMap[wireId] = TH1I(getHistoName(wireId).c_str(), - "T0 from pulses by wire (TDC counts, 1 TDC count = 0.781 ns)", - 7000, - 0, - 7000 - ); - if(debug) - cout << " New T0 per wire Histo: " << theHistoWireMap[wireId].GetName() << endl; - } - theHistoWireMap[wireId].Fill(t0); - } - - //Select per layer - if(fabs(theTPPeakMap[layerId] - t0) > rejectDigiFromPeak){ - if(debug) - cout<<"digi skipped because t0 too far from peak " << theTPPeakMap[layerId] << endl; - continue; - } - - //Use second bunch of events to compute a t0 reference per wire - if(nevents <= (eventsForLayerT0 + eventsForWireT0)){ - if(!nDigiPerWire_ref[wireId]){ - mK_ref[wireId] = 0; - } - nDigiPerWire_ref[wireId] = nDigiPerWire_ref[wireId] + 1; - mK_ref[wireId] = mK_ref[wireId] + (t0-mK_ref[wireId])/nDigiPerWire_ref[wireId]; - } - //Use last all the remaining events to compute the mean and sigma t0 per wire - else if(nevents > (eventsForLayerT0 + eventsForWireT0)){ - if(abs(t0-mK_ref[wireId]) > tpPeakWidth) - continue; - if(!nDigiPerWire[wireId]){ - theAbsoluteT0PerWire[wireId] = 0; - qK[wireId] = 0; - mK[wireId] = 0; - } - nDigiPerWire[wireId] = nDigiPerWire[wireId] + 1; - theAbsoluteT0PerWire[wireId] = theAbsoluteT0PerWire[wireId] + t0; - qK[wireId] = qK[wireId] + ((nDigiPerWire[wireId]-1)*(t0-mK[wireId])*(t0-mK[wireId])/nDigiPerWire[wireId]); - mK[wireId] = mK[wireId] + (t0-mK[wireId])/nDigiPerWire[wireId]; - } - }//end if(nevents>1000) - }//end loop on digi - }//end loop on layer - - //Use the t0 per layer histos to have an indication about the t0 position - if(nevents == eventsForLayerT0){ - for(const auto& lHisto : theHistoLayerMap) - { - const auto& layerId = lHisto.first; - const auto& hist = lHisto.second; - if(debug) - cout << "Reading histogram " << hist.GetName() << " with mean " << hist.GetMean() << " and RMS " << hist.GetRMS() << endl; - - //Find peaks - int npeaks = spectrum.Search(&hist, (tpPeakWidthPerLayer / 2.), "", 0.3); - - double *peaks = spectrum.GetPositionX(); - //Put in a std::vector - vector peakMeans(peaks, peaks + npeaks); - //Sort the peaks in ascending order - sort(peakMeans.begin(), peakMeans.end()); - - if (peakMeans.empty()) - { - theTPPeakMap[layerId] = hist.GetMaximumBin(); - std::cout << "No peaks found by peakfinder in layer " << layerId << ". Taking maximum bin at " << theTPPeakMap[layerId] << ". Please check!" << std::endl; - layerIdWithWireHistos.push_back(layerId); - } - else if (fabs(hist.GetXaxis()->FindBin(peakMeans.front()) - hist.GetXaxis()->FindBin(peakMeans.back())) < rejectDigiFromPeak) - { - theTPPeakMap[layerId] = peakMeans[peakMeans.size() / 2]; - } - else - { - bool peak_set = false; - for (const auto& peak : peakMeans) - { - // Skip if at low edge - if (peak - tpPeakWidthPerLayer <= 0) - continue; - // Get integral of peak - double sum = 0; - for (int ibin=peak - tpPeakWidthPerLayer; ibin 5) - { - std::cout << "Found more than 5 peaks in layer " << layerId << ". Please check!" << std::endl; - if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) - layerIdWithWireHistos.push_back(layerId); - } - // Check for noise - int nspikes = 0; - for (int ibin=0; ibin hist.GetMaximum() * 0.001) - nspikes++; - } - if (nspikes > 50) - { - std::cout << "Found a lot of (>50) small spikes in layer " << layerId << ". Please check if all wires are functioning as expected!" << std::endl; - if (std::find(layerIdWithWireHistos.begin(), layerIdWithWireHistos.end(), layerId) == layerIdWithWireHistos.end()) - layerIdWithWireHistos.push_back(layerId); - } - hLayerPeaks.Fill(theTPPeakMap[layerId]); - } - } -} - -void DTT0CalibrationNew::endJob() { - - std::cout << "Analyzed " << nevents << " events" << std::endl; - - DTT0* t0sWRTChamber = new DTT0(); - - if(debug) - cout << "[DTT0CalibrationNewPerLayer]Writing histos to file!" << endl; - - theFile.cd(); - //hT0SectorHisto->Write(); - hLayerPeaks.Write(); - for(const auto& wHisto : theHistoWireMap){ - wHisto.second.Write(); - } - for(const auto& lHisto : theHistoLayerMap ) { - lHisto.second.Write(); - } - - if(debug) - cout << "[DTT0CalibrationNew] Compute and store t0 and sigma per wire" << endl; - - // Calculate uncertainties per wire (counting experiment) - for (auto& wiret0 : theAbsoluteT0PerWire) - { - auto& wireId = wiret0.first; - if (nDigiPerWire[wireId] > 1 ) - theSigmaT0PerWire[wireId] = qK[wireId] / (nDigiPerWire[wireId] - 1); - else - theSigmaT0PerWire[wireId] = 999.; // Only one measurement: uncertainty -> infinity - // syst uncert - //theSigmaT0PerWire[wireId] += pow(0.5, 2)); - // Every time the same measurement. Use Laplace estimator as estimation how propable it is to measure another value due to limited size of sample - if (theSigmaT0PerWire[wireId] == 0) - { - theSigmaT0PerWire[wireId] += pow(1. / (nDigiPerWire[wireId] + 1), 2); - } - } - - // function to calculate unweighted means - auto unweighted_mean_function = [] (const std::list& values, const std::list& sigmas) - { - double mean = 0; - for (auto& value : values) - { - mean += value; - } - mean /= values.size(); - - double uncertainty = 0; - for (auto& value : values) - { - uncertainty += pow(value - mean, 2); - } - uncertainty /= values.size(); - uncertainty = sqrt(uncertainty); - return std::make_pair(mean, uncertainty); - }; - - // correct for odd-even effect in each super layer - std::map > mean_sigma_even; - std::map > mean_sigma_odd; - for (const auto& superlayer : dtGeom->superLayers()) - { - const auto superlayer_id = superlayer->id(); - std::list values_even; - std::list sigmas_even; - std::list values_odd; - std::list sigmas_odd; - - for (const auto& wiret0 : theAbsoluteT0PerWire) - { - const auto& wireId = wiret0.first; - if (wireId.layerId().superlayerId() == superlayer_id) - { - const auto& t0 = wiret0.second / nDigiPerWire[wireId]; - if (wireId.layerId().layer() % 2) - { - values_odd.push_back(t0); - sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); - } - else - { - values_even.push_back(t0); - sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); - } - } - } - // get mean and uncertainty - mean_sigma_even.emplace(superlayer_id, unweighted_mean_function(values_even, sigmas_even)); - mean_sigma_odd.emplace(superlayer_id, unweighted_mean_function(values_odd, sigmas_odd)); - } - - // filter outliers - for (const auto& superlayer : dtGeom->superLayers()) - { - const auto superlayer_id = superlayer->id(); - std::list values_even; - std::list sigmas_even; - std::list values_odd; - std::list sigmas_odd; - - for (const auto& wiret0 : theAbsoluteT0PerWire) - { - const auto& wireId = wiret0.first; - if (wireId.layerId().superlayerId() == superlayer_id) - { - const auto& t0 = wiret0.second / nDigiPerWire[wireId]; - if (wireId.layerId().layer() % 2 and abs(t0 - mean_sigma_odd[superlayer_id].first) < 2 * mean_sigma_odd[superlayer_id].second) - { - values_odd.push_back(t0); - sigmas_odd.push_back(sqrt(theSigmaT0PerWire[wireId])); - } - else - { - if (abs(t0 - mean_sigma_even[superlayer_id].first) < 2 * mean_sigma_even[superlayer_id].second) - { - values_even.push_back(t0); - sigmas_even.push_back(sqrt(theSigmaT0PerWire[wireId])); - } - } - } - } - // get mean and uncertainty - mean_sigma_even[superlayer_id] = unweighted_mean_function(values_even, sigmas_even); - mean_sigma_odd[superlayer_id] = unweighted_mean_function(values_odd, sigmas_odd); - } - - // apply correction - for (auto& wiret0 : theAbsoluteT0PerWire) - { - const auto& wire_id = wiret0.first; - const auto& superlayer_id = wiret0.first.layerId().superlayerId(); - const auto& layer = wiret0.first.layerId().layer(); - auto& t0 = wiret0.second; - t0 /= nDigiPerWire[wire_id]; - if (not layer % 2) - continue; - // t0 is reference. Changing it changes the map - t0 += mean_sigma_even[superlayer_id].first - mean_sigma_odd[superlayer_id].first; - theSigmaT0PerWire[wire_id] += pow(mean_sigma_odd[superlayer_id].second, 2) + pow(mean_sigma_even[superlayer_id].second, 2); - } - - // get chamber mean - std::map > values_per_chamber; - std::map > sigmas_per_chamber; - for (const auto& wire_t0 : theAbsoluteT0PerWire) - { - const auto& wire_id = wire_t0.first; - const auto& chamber_id = wire_id.chamberId(); - const auto& t0 = wire_t0.second; - values_per_chamber[chamber_id].push_back(t0); - sigmas_per_chamber[chamber_id].push_back(sqrt(theSigmaT0PerWire[wire_id])); - } - - std::map > mean_per_chamber; - for (const auto& chamber_mean : values_per_chamber) - { - const auto& chamber_id = chamber_mean.first; - const auto& means = chamber_mean.second; - const auto& sigmas = sigmas_per_chamber[chamber_id]; - mean_per_chamber.emplace(chamber_id, unweighted_mean_function(means, sigmas)); - } - - // calculate relative values - for (const auto& wire_t0 : theAbsoluteT0PerWire) - { - const auto& wire_id = wire_t0.first; - const auto& chamber_id = wire_id.chamberId(); - const auto& t0 = wire_t0.second; - theRelativeT0PerWire.emplace(wire_id, t0 - mean_per_chamber[chamber_id].first); - cout << "[DTT0CalibrationNew] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " - << " sigma "<< sqrt(theSigmaT0PerWire[wire_id]) <set(wire_id, - t0, - sqrt(theSigmaT0PerWire[wire_id]), - DTTimeUnits::counts - ); - } - - ///Write the t0 map into DB - if(debug) - cout << "[DTT0CalibrationNew]Writing values in DB!" << endl; - // FIXME: to be read from cfg? - string t0Record = "DTT0Rcd"; - // Write the t0 map to DB - DTCalibDBUtils::writeToDB(t0Record, t0sWRTChamber); - delete t0sWRTChamber; -} - -string DTT0CalibrationNew::getHistoName(const DTWireId& wId) const { - string histoName; - stringstream theStream; - theStream << "Ch_" << wId.wheel() << "_" << wId.station() << "_" << wId.sector() - << "_SL" << wId.superlayer() << "_L" << wId.layer() << "_W"<< wId.wire() <<"_hT0Histo"; - theStream >> histoName; - return histoName; -} - -string DTT0CalibrationNew::getHistoName(const DTLayerId& lId) const { - string histoName; - stringstream theStream; - theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector() - << "_SL" << lId.superlayer() << "_L" << lId.layer() <<"_hT0Histo"; - theStream >> histoName; - return histoName; -} diff --git a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h b/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h deleted file mode 100644 index a7476147aca81..0000000000000 --- a/CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef CalibMuon_DTT0CalibrationNew_H -#define CalibMuon_DTT0CalibrationNew_H - -/** \class DTT0CalibrationNew - * Analyzer class computes the mean and RMS of t0 from pulses. - * Those values are written in the DB with cell granularity. The - * mean value for each channel is normalized to a reference time common to all the sector. - * The t0 of wires in odd layers are corrected for the relative difference between - * odd and even layers - * - * \author S. Bolognesi - INFN Torino - */ - -//#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DataFormats/MuonDetId/interface/DTWireId.h" -#include "DataFormats/DTDigi/interface/DTDigiCollection.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include -#include -#include - -#include "TFile.h" -#include "TH1I.h" -#include "TH1D.h" -#include "TSpectrum.h" - -//class TFile; -//class TH1I; -//class TH1D; -//class TSpectrum; -class DTT0; - -class DTT0CalibrationNew : public edm::one::EDAnalyzer<> { -public: - /// Constructor - DTT0CalibrationNew(const edm::ParameterSet& pset); - - /// Destructor - virtual ~DTT0CalibrationNew(); - - // Operations - - /// Fill the maps with t0 (by channel) - void analyze(const edm::Event & event, const edm::EventSetup& eventSetup); - - /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity - void endJob(); - - -protected: - -private: - // Generate the histo name - std::string getHistoName(const DTWireId& wId) const; - std::string getHistoName(const DTLayerId& lId) const; - - // Debug flag - bool debug; - - // The label used to retrieve digis from the event - edm::EDGetTokenT digiToken; - - // The root file which contain the histos per layer - TFile theFile; - - //The event counter - unsigned int nevents; - //Number of events to be used for the t0 per layer histos - unsigned int eventsForLayerT0; - //Number of events to be used for the t0 reference per wire - unsigned int eventsForWireT0; - - //Acceptance of t0 w.r.t. reference peak - double tpPeakWidth; - - //Acceptance of t0 w.r.t. reference peak - double tpPeakWidthPerLayer; - - //Digi's will be rejected if too far from TP peak - unsigned int rejectDigiFromPeak; - - //The wheels,sector to be calibrated (default All) - std::string theCalibWheel; - int selWheel; - std::string theCalibSector; - int selSector; - - // Map of the histos and graph by layer - std::map theHistoLayerMap; - - // Histogram containing position of all peaks - TH1D hLayerPeaks; - - TSpectrum spectrum; - - //Layer with histos for each wire - std::vector wireIdWithHistos; - std::vector layerIdWithWireHistos; - - //Maps with t0, sigma, number of digi per wire - std::map theAbsoluteT0PerWire; - std::map theRelativeT0PerWire; - std::map theSigmaT0PerWire; - std::map nDigiPerWire; - std::map nDigiPerWire_ref; - std::map mK; - std::map mK_ref; - std::map qK; - //Map with histo per wire for the chosen layer - std::map theHistoWireMap; - //Map with mean and RMS of t0 per layer - std::map theT0LayerMap; - std::map theSigmaT0LayerMap; - std::map theTPPeakMap; - //Ref. t0 per chamber - std::map theSumT0ByChamber; - std::map theCountT0ByChamber; - std::map theSigmaT0ByChamber; - std::map theMeanT0ByChamber; - std::map theRefT0ByChamber; - - //DTGeometry used to loop on the SL in the endJob - edm::ESHandle dtGeom; -}; -#endif - From d51bbcd1da017e7b6c0eb2247a3eb3af6fb17b5a Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Wed, 26 Sep 2018 15:53:00 +0200 Subject: [PATCH 222/686] Workflow: Minor fix in exception This exception was not definied before. (cherry picked from commit 2080235d6534b8896dc7cec209aa3be5689d3ef5) --- CalibMuon/DTCalibration/python/Workflow/CrabHelper.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py index b34a0bcd32302..2507119932be6 100644 --- a/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py +++ b/CalibMuon/DTCalibration/python/Workflow/CrabHelper.py @@ -237,3 +237,7 @@ def crab_taskname(self): taskname+= self.options.workflow_mode + "_" taskname += "run_" + str(self.options.run) + "_v" + str(self.options.trial) return taskname + +## Exception for the VOMS proxy +class ProxyError(Exception): + pass From 10cdd01f4c8fd0edbdb58c30a97fa0436dcc5bf0 Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Mon, 3 Dec 2018 15:01:14 +0100 Subject: [PATCH 223/686] T0: Fixed rename of files I forgot to change class name, log files and header name imports from DTT0CalibrationNew to DTT0Calibration. (cherry picked from commit 0b76d7d1a6e91bfd9ca55e7ea46f1e722173791e) --- .../DTCalibration/plugins/DTT0Calibration.cc | 30 +++++++++---------- .../DTCalibration/plugins/DTT0Calibration.h | 12 ++++---- CalibMuon/DTCalibration/plugins/SealModule.cc | 2 -- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc index ff5cc7a8fb5d5..3152daeb053df 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc @@ -7,7 +7,7 @@ * 06/08/2008 Mofified by Antonio.Vilela.Pereira@cern.ch */ -#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" +#include "CalibMuon/DTCalibration/plugins/DTT0Calibration.h" #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h" #include "FWCore/Framework/interface/Event.h" @@ -31,7 +31,7 @@ using namespace std; using namespace edm; // Constructor -DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : +DTT0Calibration::DTT0Calibration(const edm::ParameterSet& pset) : debug(pset.getUntrackedParameter("debug")), digiToken(consumes(pset.getUntrackedParameter("digiLabel"))), theFile(pset.getUntrackedParameter("rootFileName", "DTT0PerLayer.root").c_str(), "RECREATE"), @@ -47,7 +47,7 @@ DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : { // Get the debug parameter for verbose output if(debug) - cout << "[DTT0CalibrationNew]Constructor called!" << endl; + cout << "[DTT0Calibration]Constructor called!" << endl; theCalibWheel = pset.getUntrackedParameter("calibWheel", "All"); //FIXME amke a vector of integer instead of a string if(theCalibWheel != "All") { @@ -55,7 +55,7 @@ DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : int selWheel; linestr << theCalibWheel; linestr >> selWheel; - cout << "[DTT0CalibrationNewPerLayer] chosen wheel " << selWheel << endl; + cout << "[DTT0CalibrationPerLayer] chosen wheel " << selWheel << endl; } // Sector/s to calibrate @@ -65,7 +65,7 @@ DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : int selSector; linestr << theCalibSector; linestr >> selSector; - cout << "[DTT0CalibrationNewPerLayer] chosen sector " << selSector << endl; + cout << "[DTT0CalibrationPerLayer] chosen sector " << selSector << endl; } vector defaultCell; @@ -80,15 +80,15 @@ DTT0CalibrationNew::DTT0CalibrationNew(const edm::ParameterSet& pset) : } // Destructor -DTT0CalibrationNew::~DTT0CalibrationNew(){ +DTT0Calibration::~DTT0Calibration(){ if(debug) - cout << "[DTT0CalibrationNew]Destructor called!" << endl; + cout << "[DTT0Calibration]Destructor called!" << endl; theFile.Close(); } /// Perform the real analysis -void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { +void DTT0Calibration::analyze(const edm::Event & event, const edm::EventSetup& eventSetup) { nevents++; // Get the digis from the event @@ -286,14 +286,14 @@ void DTT0CalibrationNew::analyze(const edm::Event & event, const edm::EventSetup } } -void DTT0CalibrationNew::endJob() { +void DTT0Calibration::endJob() { std::cout << "Analyzed " << nevents << " events" << std::endl; DTT0* t0sWRTChamber = new DTT0(); if(debug) - cout << "[DTT0CalibrationNewPerLayer]Writing histos to file!" << endl; + cout << "[DTT0CalibrationPerLayer]Writing histos to file!" << endl; theFile.cd(); //hT0SectorHisto->Write(); @@ -306,7 +306,7 @@ void DTT0CalibrationNew::endJob() { } if(debug) - cout << "[DTT0CalibrationNew] Compute and store t0 and sigma per wire" << endl; + cout << "[DTT0Calibration] Compute and store t0 and sigma per wire" << endl; // Calculate uncertainties per wire (counting experiment) for (auto& wiret0 : theAbsoluteT0PerWire) @@ -457,7 +457,7 @@ void DTT0CalibrationNew::endJob() { const auto& chamber_id = wire_id.chamberId(); const auto& t0 = wire_t0.second; theRelativeT0PerWire.emplace(wire_id, t0 - mean_per_chamber[chamber_id].first); - cout << "[DTT0CalibrationNew] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " + cout << "[DTT0Calibration] Wire " << wire_id << " has t0 "<< theRelativeT0PerWire[wire_id] << " (relative, after even-odd layer corrections) " << " sigma "<< sqrt(theSigmaT0PerWire[wire_id]) < { +class DTT0Calibration : public edm::one::EDAnalyzer<> { public: /// Constructor - DTT0CalibrationNew(const edm::ParameterSet& pset); + DTT0Calibration(const edm::ParameterSet& pset); /// Destructor - virtual ~DTT0CalibrationNew(); + virtual ~DTT0Calibration(); // Operations diff --git a/CalibMuon/DTCalibration/plugins/SealModule.cc b/CalibMuon/DTCalibration/plugins/SealModule.cc index 82261521d5639..03fdafbf75848 100644 --- a/CalibMuon/DTCalibration/plugins/SealModule.cc +++ b/CalibMuon/DTCalibration/plugins/SealModule.cc @@ -11,7 +11,6 @@ #include "CalibMuon/DTCalibration/plugins/DTTTrigCorrectionFirst.h" #include "CalibMuon/DTCalibration/plugins/DTT0CalibrationRMS.h" #include "CalibMuon/DTCalibration/plugins/DTT0Calibration.h" -#include "CalibMuon/DTCalibration/plugins/DTT0CalibrationNew.h" #include "CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h" #include "CalibMuon/DTCalibration/plugins/DTT0Correction.h" #include "CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h" @@ -51,7 +50,6 @@ DEFINE_FWK_MODULE(DTTTrigCorrection); DEFINE_FWK_MODULE(DTTTrigCorrectionFirst); DEFINE_FWK_MODULE(DTT0CalibrationRMS); DEFINE_FWK_MODULE(DTT0Calibration); -DEFINE_FWK_MODULE(DTT0CalibrationNew); DEFINE_FWK_MODULE(DTTPDeadWriter); DEFINE_FWK_MODULE(DTT0Correction); DEFINE_FWK_MODULE(DTVDriftCalibration); From 1be794b6c8bdf65dc5ec70a3d2f42152845c01ca Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Wed, 20 Feb 2019 16:44:17 +0100 Subject: [PATCH 224/686] T0: More cleanup of T0 code Changed dtT0CalibrationNew to dtT0Calibration. (cherry picked from commit afe5dbecfea02c0745c8a45bd0b8925fe3b0fb0b) --- .../python/Workflow/DTT0WireWorkflow.py | 4 +- .../python/dtT0WireCalibrationNew_cfg.py | 129 ------------------ .../python/dtT0WireCalibration_cfg.py | 60 ++++---- 3 files changed, 32 insertions(+), 161 deletions(-) delete mode 100644 CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py diff --git a/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py b/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py index d446e33e082cd..7ab769e575705 100644 --- a/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py +++ b/CalibMuon/DTCalibration/python/Workflow/DTT0WireWorkflow.py @@ -33,8 +33,8 @@ def prepare_workflow(self): fill_function() def prepare_all_submit(self): - self.pset_name = 'dtT0WireCalibrationNew_cfg.py' - self.pset_template = 'CalibMuon.DTCalibration.dtT0WireCalibrationNew_cfg' + self.pset_name = 'dtT0WireCalibration_cfg.py' + self.pset_template = 'CalibMuon.DTCalibration.dtT0WireCalibration_cfg' self.process = tools.loadCmsProcess(self.pset_template) self.process.GlobalTag.globaltag = self.options.globaltag diff --git a/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py b/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py deleted file mode 100644 index d475ab09496a8..0000000000000 --- a/CalibMuon/DTCalibration/python/dtT0WireCalibrationNew_cfg.py +++ /dev/null @@ -1,129 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("PROD") - -process.load("FWCore.MessageService.MessageLogger_cfi") -process.MessageLogger.debugModules = cms.untracked.vstring('*') -process.MessageLogger.destinations = cms.untracked.vstring('cerr') -process.MessageLogger.categories.append('resolution') -process.MessageLogger.cerr = cms.untracked.PSet( - FwkReport = cms.untracked.PSet( - limit = cms.untracked.int32(100), - reportEvery = cms.untracked.int32(1000) - ), - threshold = cms.untracked.string('DEBUG'), - noLineBreaks = cms.untracked.bool(False), - DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), - INFO = cms.untracked.PSet(limit = cms.untracked.int32(0)), - resolution = cms.untracked.PSet(limit = cms.untracked.int32(-1)) -) - -process.load("Configuration.StandardSequences.GeometryDB_cff") -process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff") -process.GlobalTag.globaltag = "" - -process.load("CondCore.CondDB.CondDB_cfi") - -process.load("DQMServices.Core.DQM_cfg") - -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( - '/store/data/Commissioning2018/MiniDaq/RAW/v1/000/312/774/00000/CCADE144-9431-E811-9641-FA163E220C5C.root' -# '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/540/AA9053D9-F306-E211-80A4-001D09F248F8.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/204/148CF2AC-CAD0-E111-A056-001D09F291D2.root', -### '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/132/D0E088D3-D7DC-E111-92D2-00237DDC5C24.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/198/510/0C50021A-F4C8-E111-B861-001D09F2512C.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/206/EC54DD2C-D3D0-E111-9019-5404A63886CE.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/131/E024E67D-D6DC-E111-A404-0025901D6288.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/201/074/92295641-C3E7-E111-899B-0025901D629C.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/133/ACB373F1-D9DC-E111-B891-003048F024FE.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/276/2CF5C87C-E303-E211-A314-001D09F28F25.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/535/1EEFEF95-F506-E211-A872-001D09F2906A.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/665/1C75364F-0EE3-E111-8021-BCAEC5329705.root', - #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/716/8A0AC842-A3E3-E111-A669-001D09F291D7.root' - ) -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) - -process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) - -# process.load("CalibMuon.DTCalibration.dt_offlineAnalysis_common_cff") - -import EventFilter.DTRawToDigi.dturosunpacker_cfi -process.dtunpacker = EventFilter.DTRawToDigi.dturosunpacker_cfi.dturosunpacker.clone() - -process.PoolDBOutputService = cms.Service("PoolDBOutputService", - process.CondDB, - timetype = cms.untracked.string('runnumber'), - toPut = cms.VPSet(cms.PSet( - record = cms.string('DTT0Rcd'), - tag = cms.string('t0') - )) -) -process.PoolDBOutputService.connect = cms.string('sqlite_file:t0.db') - -process.eventInfoProvider = cms.EDFilter("EventCoordinatesSource", - eventInfoFolder = cms.untracked.string('EventInfo/') -) - - -# test pulse monitoring -process.load("DQM.DTMonitorModule.dtDigiTask_TP_cfi") -process.load("DQM.DTMonitorClient.dtOccupancyTest_TP_cfi") -process.dtTPmonitor.readDB = False -process.dtTPmonitor.defaultTtrig = 600 -process.dtTPmonitor.defaultTmax = 100 -process.dtTPmonitor.inTimeHitsLowerBound = 0 -process.dtTPmonitor.inTimeHitsUpperBound = 0 -#file = open("tpDead.txt") -wiresToDebug = cms.untracked.vstring() -#for line in file: -# corrWire = line.split()[:6] -# #switch station/sector -# corrWire[1:3] = corrWire[2:0:-1] -# wire = ' '.join(corrWire) -# #print wire -# wiresToDebug.append(wire) -#file.close() - -process.dtT0WireCalibration = cms.EDAnalyzer("DTT0CalibrationNew", - correctByChamberMean = cms.bool(False), - # Cells for which you want the histos (default = None) - cellsWithHisto = wiresToDebug, - # Label to retrieve DT digis from the event - digiLabel = cms.untracked.string('dtunpacker'), - calibSector = cms.untracked.string('All'), - # Chose the wheel, sector (default = All) - calibWheel = cms.untracked.string('All'), - # Number of events to be used for the t0 per layer histos - eventsForWireT0 = cms.uint32(25000), #25000 - # Name of the ROOT file which will contain the test pulse times per layer - rootFileName = cms.untracked.string('DTTestPulses.root'), - debug = cms.untracked.bool(False), - rejectDigiFromPeak = cms.uint32(50), - # Acceptance for TP peak width - tpPeakWidth = cms.double(15.0), - # Number of events to be used for the t0 per layer histos - eventsForLayerT0 = cms.uint32(5000), #5000 - timeBoxWidth = cms.uint32(300), - tpPeakWidthPerLayer = cms.double(2.0) -) - -process.output = cms.OutputModule("PoolOutputModule", - outputCommands = cms.untracked.vstring('drop *', - 'keep *_MEtoEDMConverter_*_*'), - fileName = cms.untracked.string('DQM.root') -) - -process.load("DQMServices.Components.MEtoEDMConverter_cff") -#process.DQM.collectorHost = '' - -process.p = cms.Path(process.dtunpacker* - process.dtTPmonitor+process.dtTPmonitorTest+ - process.dtT0WireCalibration+ - process.MEtoEDMConverter) -process.outpath = cms.EndPath(process.output) diff --git a/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py b/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py index 82bfe52542c35..f73c9e65fda97 100644 --- a/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py +++ b/CalibMuon/DTCalibration/python/dtT0WireCalibration_cfg.py @@ -7,6 +7,10 @@ process.MessageLogger.destinations = cms.untracked.vstring('cerr') process.MessageLogger.categories.append('resolution') process.MessageLogger.cerr = cms.untracked.PSet( + FwkReport = cms.untracked.PSet( + limit = cms.untracked.int32(100), + reportEvery = cms.untracked.int32(1000) + ), threshold = cms.untracked.string('DEBUG'), noLineBreaks = cms.untracked.bool(False), DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0)), @@ -26,6 +30,18 @@ process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( '/store/data/Commissioning2018/MiniDaq/RAW/v1/000/312/774/00000/CCADE144-9431-E811-9641-FA163E220C5C.root' +# '/store/data/Run2012C/MiniDaq/RAW/v1/000/203/540/AA9053D9-F306-E211-80A4-001D09F248F8.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/204/148CF2AC-CAD0-E111-A056-001D09F291D2.root', +### '/store/data/Run2012C/MiniDaq/RAW/v1/000/200/132/D0E088D3-D7DC-E111-92D2-00237DDC5C24.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/198/510/0C50021A-F4C8-E111-B861-001D09F2512C.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/199/206/EC54DD2C-D3D0-E111-9019-5404A63886CE.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/131/E024E67D-D6DC-E111-A404-0025901D6288.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/201/074/92295641-C3E7-E111-899B-0025901D629C.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/133/ACB373F1-D9DC-E111-B891-003048F024FE.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/276/2CF5C87C-E303-E211-A314-001D09F28F25.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/203/535/1EEFEF95-F506-E211-A872-001D09F2906A.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/665/1C75364F-0EE3-E111-8021-BCAEC5329705.root', + #'/store/data/Run2012C/MiniDaq/RAW/v1/000/200/716/8A0AC842-A3E3-E111-A669-001D09F291D7.root' ) ) @@ -37,26 +53,8 @@ # process.load("CalibMuon.DTCalibration.dt_offlineAnalysis_common_cff") -process.dtunpacker = cms.EDProducer("DTUnpackingModule", - dataType = cms.string('DDU'), - inputLabel = cms.InputTag('rawDataCollector'), - fedbyType = cms.bool(False), - useStandardFEDid = cms.bool(True), - dqmOnly = cms.bool(False), - readOutParameters = cms.PSet( - debug = cms.untracked.bool(False), - rosParameters = cms.PSet( - writeSC = cms.untracked.bool(True), - readingDDU = cms.untracked.bool(True), - performDataIntegrityMonitor = cms.untracked.bool(False), - readDDUIDfromDDU = cms.untracked.bool(True), - debug = cms.untracked.bool(False), - localDAQ = cms.untracked.bool(False) - ), - localDAQ = cms.untracked.bool(False), - performDataIntegrityMonitor = cms.untracked.bool(False) - ) -) +import EventFilter.DTRawToDigi.dturosunpacker_cfi +process.dtunpacker = EventFilter.DTRawToDigi.dturosunpacker_cfi.dturosunpacker.clone() process.PoolDBOutputService = cms.Service("PoolDBOutputService", process.CondDB, @@ -81,16 +79,16 @@ process.dtTPmonitor.defaultTmax = 100 process.dtTPmonitor.inTimeHitsLowerBound = 0 process.dtTPmonitor.inTimeHitsUpperBound = 0 -file = open("tpDead.txt") +#file = open("tpDead.txt") wiresToDebug = cms.untracked.vstring() -for line in file: - corrWire = line.split()[:6] - #switch station/sector - corrWire[1:3] = corrWire[2:0:-1] - wire = ' '.join(corrWire) - #print wire - wiresToDebug.append(wire) -file.close() +#for line in file: +# corrWire = line.split()[:6] +# #switch station/sector +# corrWire[1:3] = corrWire[2:0:-1] +# wire = ' '.join(corrWire) +# #print wire +# wiresToDebug.append(wire) +#file.close() process.dtT0WireCalibration = cms.EDAnalyzer("DTT0Calibration", correctByChamberMean = cms.bool(False), @@ -110,7 +108,9 @@ # Acceptance for TP peak width tpPeakWidth = cms.double(15.0), # Number of events to be used for the t0 per layer histos - eventsForLayerT0 = cms.uint32(5000) #5000 + eventsForLayerT0 = cms.uint32(5000), #5000 + timeBoxWidth = cms.uint32(300), + tpPeakWidthPerLayer = cms.double(2.0) ) process.output = cms.OutputModule("PoolOutputModule", From e8b3e2cedaf9d635619f9659f08f271f0eb423cd Mon Sep 17 00:00:00 2001 From: Jonas Roemer Date: Mon, 4 Mar 2019 13:49:18 +0100 Subject: [PATCH 225/686] DTVDriftCalibration fixes to smart pointers Bug fixing of smart pointers. Could be rebased behind the cherry pick merge commit. (cherry picked from commit 90afc1fb190fd220329da159b12ee2d3c9363190) --- CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc | 10 ++++++---- CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc index 3f32cc973c88c..3ba9b48e15fe7 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.cc @@ -44,7 +44,12 @@ using namespace edm; using namespace dttmaxenums; -DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset) { +DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset) : + // Get the synchronizer + theSync{DTTTrigSyncFactory::get()->create(pset.getParameter("tTrigMode"), + pset.getParameter("tTrigModeConfig"))} + +{ edm::ConsumesCollector collector(consumesCollector()); select_ = std::make_unique(pset,collector); @@ -77,9 +82,6 @@ DTVDriftCalibration::DTVDriftCalibration(const ParameterSet& pset) { // the txt file which will contain the calibrated constants theVDriftOutputFile = pset.getUntrackedParameter("vDriftFileName"); - // Get the synchronizer - theSync{DTTTrigSyncFactory::get()->create(pset.getParameter("tTrigMode"), - pset.getParameter("tTrigModeConfig"))} // get parameter set for DTCalibrationMap constructor theCalibFilePar = pset.getUntrackedParameter("calibFileConfig"); diff --git a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h index 17246c543dc07..59e869990fcf1 100644 --- a/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h +++ b/CalibMuon/DTCalibration/plugins/DTVDriftCalibration.h @@ -49,7 +49,7 @@ class DTVDriftCalibration : public edm::EDAnalyzer { private: - DTSegmentSelector *select_; + std::unique_ptr select_; // The class containing TMax information typedef DTTMax::TMax TMax; From 68931d0f50b5d59b442682d8f1ee574f84d7fde0 Mon Sep 17 00:00:00 2001 From: Saranya Ghosh Date: Sat, 16 Mar 2019 13:57:08 +0100 Subject: [PATCH 226/686] Minor code syntax changes suggested by the cms command scram build code-checks --- CalibMuon/DTCalibration/plugins/DTT0Calibration.cc | 2 +- CalibMuon/DTCalibration/plugins/DTT0Calibration.h | 6 +++--- CalibMuon/DTCalibration/src/DTSegmentSelector.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc index 3152daeb053df..4de1a3de85924 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.cc @@ -25,7 +25,7 @@ #include "TKey.h" #include "TF1.h" -#include +#include using namespace std; using namespace edm; diff --git a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h index 003256bf5678d..a05fc62d32e2e 100644 --- a/CalibMuon/DTCalibration/plugins/DTT0Calibration.h +++ b/CalibMuon/DTCalibration/plugins/DTT0Calibration.h @@ -39,15 +39,15 @@ class DTT0Calibration : public edm::one::EDAnalyzer<> { DTT0Calibration(const edm::ParameterSet& pset); /// Destructor - virtual ~DTT0Calibration(); + ~DTT0Calibration() override; // Operations /// Fill the maps with t0 (by channel) - void analyze(const edm::Event & event, const edm::EventSetup& eventSetup); + void analyze(const edm::Event & event, const edm::EventSetup& eventSetup) override; /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity - void endJob(); + void endJob() override; protected: diff --git a/CalibMuon/DTCalibration/src/DTSegmentSelector.cc b/CalibMuon/DTCalibration/src/DTSegmentSelector.cc index df2094257f884..7f503e2630496 100644 --- a/CalibMuon/DTCalibration/src/DTSegmentSelector.cc +++ b/CalibMuon/DTCalibration/src/DTSegmentSelector.cc @@ -32,12 +32,12 @@ bool DTSegmentSelector::operator() (DTRecSegment4D const& segment, edm::Event co /* get the muon collection if one is specified (not specifying a muon collection switches off muon matching */ - if (muonTags_.label()!="") { + if (!muonTags_.label().empty()) { edm::Handle muonH; event.getByToken(muonToken_,muonH); const std::vector* muons = muonH.product(); //std::cout << " Muon collection size: " << muons->size() << std::endl; - if (!muons->size()) return false; + if (muons->empty()) return false; DTChamberId segId(segment.rawId()); From e77b48024253ba6cbb3ef6ac4569f4f94b0634eb Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Sun, 17 Mar 2019 13:03:27 +0100 Subject: [PATCH 227/686] classes.h contains headers only. --- DataFormats/ProtonReco/src/classes.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h index 945075c65f138..df9677e71ddf4 100644 --- a/DataFormats/ProtonReco/src/classes.h +++ b/DataFormats/ProtonReco/src/classes.h @@ -7,10 +7,3 @@ #include #include - -reco::ForwardProton fp; -std::vector vec_fp; -edm::Wrapper > wrp_vec_fp; -edm::RefProd > rp_vec_fp; -edm::Ref,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > ref_vec_fp; -edm::RefVector,reco::ForwardProton,edm::refhelper::FindUsingAdvance,reco::ForwardProton> > rv_vec_fp; From 763708dc7253a51ef943bf01ca69ab6657299d2a Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Sun, 17 Mar 2019 13:05:57 +0100 Subject: [PATCH 228/686] Auto GT used. --- .../proton_reconstruction_LHC_data/test_reconstruction_cfg.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index d0030fe982eed..bc011305742b7 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -6,8 +6,7 @@ # declare global tag process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, "105X_dataRun2_relval_v2") -#process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") +process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") # minimum of logs process.MessageLogger = cms.Service("MessageLogger", From c1ae6617852d4e19166ab966b0913a8af6c6b92e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Sun, 17 Mar 2019 13:52:06 +0100 Subject: [PATCH 229/686] Common replacement pattern moved to a common cff.py file. --- CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py | 6 ++++-- CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py | 6 +++++- RecoCTPPS/Configuration/python/recoCTPPS_cff.py | 8 ++------ .../beam_smearing_validation/test_beam_smearing_cfg.py | 4 +--- .../direct_simulation_validation/test_acceptance_cfg.py | 4 +--- .../test_smearing_effects_cfg.py | 4 +--- .../direct_simulation_validation/test_xy_pattern_cfg.py | 4 +--- .../proton_gun_validation/test_proton_gun_cfg.py | 2 +- .../proton_reconstruction_MC/misalignment/template_cfg.py | 8 +++----- .../proton_reconstruction_MC/resolution/template_cfg.py | 8 +++----- 10 files changed, 22 insertions(+), 32 deletions(-) diff --git a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py index 85e0ad4219243..f7ecf58fd6561 100644 --- a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py +++ b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py @@ -1,8 +1,10 @@ import FWCore.ParameterSet.Config as cms +ctppsLHCInfoLabel = cms.string("ctpps_minimal") + # minimal LHCInfo for 2016 data -ctppsLHCInfoESSource = cms.ESSource("CTPPSLHCInfoESSource", - label = cms.string("ctpps_minimal"), +ctppsLHCInfoESSource_2016 = cms.ESSource("CTPPSLHCInfoESSource", + label = ctppsLHCInfoLabel, validityRange = cms.EventRange("270293:min - 290872:max"), beamEnergy = cms.double(6500), # GeV xangle = cms.double(185) # murad diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py index ed22d982e6338..5a6068db262c4 100644 --- a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -1,9 +1,11 @@ import FWCore.ParameterSet.Config as cms +from CalibPPS.ESProducers.ctppsLHCInfo_cff import * + from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp # optical functions for 2016 data -ctppsOpticalFunctionsESSource = _optics_tmp.clone( +ctppsOpticalFunctionsESSource_2016 = _optics_tmp.clone( validityRange = cms.EventRange("270293:min - 290872:max"), opticalFunctions = cms.VPSet( @@ -19,4 +21,6 @@ ) ) +# optics interpolation between crossing angles from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import * +ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ctppsLHCInfoLabel diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index 38977f4972041..43bb3129f6f06 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -10,13 +10,9 @@ from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * -# TODO: remove these lines once LHCInfo available in DB -from CalibPPS.ESProducers.ctppsLHCInfo_cff import * -ctppsProtons.lhcInfoLabel = ctppsLHCInfoESSource.label - -# TODO: remove these lines once optical functions available in DB +# TODO: remove these lines once optical functions and LHCInfo are available in DB from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * -ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ctppsLHCInfoESSource.label +ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel recoCTPPS = cms.Sequence( totemRPLocalReconstruction * diff --git a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py index 42994126c1997..3b7d651922bd3 100644 --- a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py +++ b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py index 158102a73093a..3f3de6e596435 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py index dd31027ca7bb8..318e0360450ca 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py index 4813a08dcde17..56deec1684b90 100644 --- a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # supply beam parameters process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") diff --git a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py index 35791f20c7489..53f998bd52e0e 100644 --- a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py @@ -40,7 +40,7 @@ # plotter process.ctppsHepMCDistributionPlotter = cms.EDAnalyzer("CTPPSHepMCDistributionPlotter", tagHepMC = cms.InputTag("generator", "unsmeared"), - lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB outputFile = cms.string("test_proton_gun.root") ) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index cf4f85452edcc..b2b009e72fd93 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", @@ -68,7 +66,7 @@ # proton reconstruction process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource.label # TODO: remove this line once data loaded from DB +process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation @@ -78,7 +76,7 @@ tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), - lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB outputFile = cms.string("") ) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index 28200e9a17dcd..8e57872fab3f2 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -25,10 +25,8 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") # supply LHC info and optics -# TODO: remove these lines once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") +# TODO: remove this line once data are available in CondDB process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") -process.ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = process.ctppsLHCInfoESSource.label # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", @@ -66,7 +64,7 @@ # proton reconstruction process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource.label # TODO: remove this line once data loaded from DB +process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation @@ -76,7 +74,7 @@ tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), - lhcInfoLabel = process.ctppsLHCInfoESSource.label, # TODO: replace with "" once data loaded from DB + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB outputFile = cms.string("") ) From 2ec68ac89a3f0b6d3cab717c89f22d8a396693b0 Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Sun, 17 Mar 2019 15:13:31 +0000 Subject: [PATCH 230/686] swapping order of cuts to avoid expensive dxy/dz calc --- .../plugins/PhotonIDValueMapProducer.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc index cb15aa1fc8d41..e264bb06f1a33 100644 --- a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc +++ b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc @@ -397,11 +397,20 @@ float PhotonIDValueMapProducer::computeWorstPFChargedIsolation(const reco::Photo math::XYZVector phoWrtVtx(photon.superCluster()->x() - vtx->x(), photon.superCluster()->y() - vtx->y(), photon.superCluster()->z() - vtx->z()); + const float phoWrtVtxPhi = phoWrtVtx.phi(); + const float phoWrtVtxEta = phoWrtVtx.eta(); + float sum = 0; // Loop over the PFCandidates for (auto const& aCCand : chargedCands) { - float dxy = -999; + auto iCand = aCCand.candidate; + float dR2 = deltaR2(phoWrtVtxEta, phoWrtVtxPhi, iCand->eta(), iCand->phi()); + if (dR2 > coneSizeDR * coneSizeDR || + (options & DR_VETO && dR2 < dRveto * dRveto)) + continue; + + float dxy = -999; float dz = -999; if (options & PV_CONSTRAINT) getImpactParameters(aCCand, pv, dxy, dz); @@ -411,11 +420,6 @@ float PhotonIDValueMapProducer::computeWorstPFChargedIsolation(const reco::Photo if (fabs(dxy) > dxyMax || fabs(dz) > dzMax) continue; - auto iCand = aCCand.candidate; - float dR2 = deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi()); - if (dR2 > coneSizeDR * coneSizeDR || - (options & DR_VETO && dR2 < dRveto * dRveto)) - continue; sum += iCand->pt(); } From 2cd0414ee2241ec37bcb61a8e5f72bb1d2008f39 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 19 Mar 2019 04:27:04 +0900 Subject: [PATCH 231/686] fix crc issue --- .../plugins/GEMRawToDigiModule.cc | 2 +- EventFilter/GEMRawToDigi/src/VFATdata.cc | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc index 9bbf7ace01c02..f4403ff71ef44 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc @@ -131,7 +131,7 @@ void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::Ev } // check vfat data if (vfatData->quality()) { - edm::LogWarning("GEMRawToDigiModule") << "Quality "<< vfatData->quality() + edm::LogWarning("GEMRawToDigiModule") << "Quality "<< int(vfatData->quality()) << " b1010 "<< int(vfatData->b1010()) << " b1100 "<< int(vfatData->b1100()) << " b1110 "<< int(vfatData->b1110()); diff --git a/EventFilter/GEMRawToDigi/src/VFATdata.cc b/EventFilter/GEMRawToDigi/src/VFATdata.cc index 6eabc354f31bf..3a50da4a86c18 100644 --- a/EventFilter/GEMRawToDigi/src/VFATdata.cc +++ b/EventFilter/GEMRawToDigi/src/VFATdata.cc @@ -1,5 +1,5 @@ #include "EventFilter/GEMRawToDigi/interface/VFATdata.h" - +#include using namespace gem; VFATdata::VFATdata() { @@ -44,20 +44,23 @@ VFATdata::VFATdata(const int vfatVer, sw.msData2 = msDatas & 0x0000ffffffffffff; ver_ = vfatVer; - tw.crc = checkCRC();// crc check not yet implemented for v3 - fw_ = fw.word; sw_ = sw.word; tw_ = tw.word; + // checkCRC only works after words are set + // checkCRC not yet implemented for v3 + tw.crc = checkCRC(); + // once crc is found, save new third word + tw_ = tw.word; } uint8_t VFATdata::quality() { uint8_t q = 0; if (ver_ == 2) { - if (VFATthird{tw_}.crc != checkCRC()) q |= 1UL << 1; - if (VFATfirst{fw_}.b1010 != 10) q |= 1UL << 2; - if (VFATfirst{fw_}.b1100 != 12) q |= 1UL << 3; - if (VFATfirst{fw_}.b1110 != 14) q |= 1UL << 4; + if (VFATthird{tw_}.crc != checkCRC()) q = 1; + if (VFATfirst{fw_}.b1010 != 10) q |= 1UL << 1; + if (VFATfirst{fw_}.b1100 != 12) q |= 1UL << 2; + if (VFATfirst{fw_}.b1110 != 14) q |= 1UL << 3; } // quality test not yet implemented in v3 return q; @@ -83,8 +86,8 @@ uint16_t VFATdata::crc_cal(uint16_t crc_in, uint16_t dato) uint16_t VFATdata::checkCRC() { uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & VFATfirst{fw_}.b1010)<<12) | bc(); - vfatBlockWords[10] = ((0x000f & VFATfirst{fw_}.b1100)<<12) | ((0x00ff & ec()) <<4) | (0x000f & VFATfirst{fw_}.flag); + vfatBlockWords[11] = ((0x000f & VFATfirst{fw_}.b1010)<<12) | VFATfirst{fw_}.bcV2; + vfatBlockWords[10] = ((0x000f & VFATfirst{fw_}.b1100)<<12) | ((0x00ff & VFATfirst{fw_}.ecV2) <<4) | (0x000f & VFATfirst{fw_}.flag); vfatBlockWords[9] = ((0x000f & VFATfirst{fw_}.b1110)<<12) | VFATfirst{fw_}.chipID; vfatBlockWords[8] = (0xffff000000000000 & msData()) >> 48; vfatBlockWords[7] = (0x0000ffff00000000 & msData()) >> 32; @@ -94,7 +97,7 @@ uint16_t VFATdata::checkCRC() vfatBlockWords[3] = (0x0000ffff00000000 & lsData()) >> 32; vfatBlockWords[2] = (0x00000000ffff0000 & lsData()) >> 16; vfatBlockWords[1] = (0x000000000000ffff & lsData()); - + uint16_t crc_fin = 0xffff; for (int i = 11; i >= 1; i--) { crc_fin = crc_cal(crc_fin, vfatBlockWords[i]); From 35a2daaedd84d18ed7001068d746bfcb3a84ea81 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 20 Mar 2019 14:30:17 +0100 Subject: [PATCH 232/686] LogWarning replaced with LogInfo. --- .../plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc | 4 ++-- RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc index 7906635ea73de..d4db89148683a 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -76,7 +76,7 @@ std::shared_ptr CTPPSInterpolatedO // is crossing angle reasonable (LHCInfo is correctly filled in DB)? if (currentCrossingAngle_ == 0.) { - edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; currentDataValid_ = false; currentData_ = std::make_shared(); @@ -91,7 +91,7 @@ std::shared_ptr CTPPSInterpolatedO // is input optics available ? if (hOFColl->empty()) { - edm::LogWarning("CTPPSInterpolatedOpticalFunctionsESSource") << "No input optics available, no optical functions produced."; + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "No input optics available, no optical functions produced."; currentDataValid_ = false; currentData_ = std::make_shared(); diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index d93ecfd518bb1..d53e20e6a613e 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -130,7 +130,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe currentCrossingAngle_ = hLHCInfo->crossingAngle(); if (hOpticalFunctions->empty()) { - edm::LogWarning("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; + edm::LogInfo("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; algorithm_.release(); opticsValid_ = false; } From 46d7c8ea1d9f37298fa1df3c26c07f9eab67b0ee Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 20 Mar 2019 15:24:30 +0100 Subject: [PATCH 233/686] PPS protons added to miniAOD. --- PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py index 84d755f7f5322..2041663047cb1 100644 --- a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py @@ -78,6 +78,7 @@ 'keep LumiScalerss_scalersRawToDigi_*_*', # CTPPS 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', + 'keep recoForwardProtons_ctppsProtons_*_*', # displacedStandAlone muon collection for EXO 'keep recoTracks_displacedStandAloneMuons__*', ) From 0298770b8ccf4a5c3756beb4fb0ee49ee6e3354d Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 20 Mar 2019 15:25:48 +0100 Subject: [PATCH 234/686] Reverted back to using alignment from local XML file. --- RecoCTPPS/Configuration/python/recoCTPPS_cff.py | 3 ++- .../proton_reconstruction_LHC_data/test_reconstruction_cfg.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index 43bb3129f6f06..fb1519a62eb77 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -10,7 +10,8 @@ from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * -# TODO: remove these lines once optical functions and LHCInfo are available in DB +# TODO: remove these lines once conditions data are available in DB +from CalibPPS.ESProducers.ctppsAlignment_cff import * from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index bc011305742b7..3ed71f5688a01 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -8,6 +8,10 @@ from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") +# TODO: these lines can be useful before all necessary data available in DB with an auto GT +#process.GlobalTag = GlobalTag(process.GlobalTag, "105X_dataRun2_relval_v2") +#process.alignmentEsPrefer = cms.ESPrefer("PoolDBESSource", "GlobalTag") + # minimum of logs process.MessageLogger = cms.Service("MessageLogger", statistics = cms.untracked.vstring(), From 512a0f7d244c66387f880989e5f2488b470c08ac Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 20 Mar 2019 17:53:03 +0100 Subject: [PATCH 235/686] Added cff file with alignment settings for PPS. --- CalibPPS/ESProducers/python/ctppsAlignment_cff.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CalibPPS/ESProducers/python/ctppsAlignment_cff.py diff --git a/CalibPPS/ESProducers/python/ctppsAlignment_cff.py b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py new file mode 100644 index 0000000000000..fc2aed2fb1a3d --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +from CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * +ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring( + "Alignment/CTPPS/data/RPixGeometryCorrections.xml" +) From a30489fac8b9a91107c1f5f38cca173d5f84e0dc Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 20 Mar 2019 18:36:23 +0100 Subject: [PATCH 236/686] Interface for external Pyquen #4790 --- .../PyquenInterface/BuildFile.xml | 1 + .../PyquenInterface/interface/PyquenWrapper.h | 5 + .../python/pyquenPythiaDefault_cff.py | 4 +- .../PyquenInterface/src/HepEvt.F | 10 - .../PyquenInterface/src/PyquenHadronizer.cc | 9 +- .../PyquenInterface/src/hepevt.inc | 6 - .../PyquenInterface/src/pyquen.F | 1515 ----------------- .../PyquenInterface/test/PyquenAnalyzer.cc | 4 +- .../PyquenInterface/test/PyquenAnalyzer.h | 10 + .../PyquenInterface/test/testPyquen.py | 4 +- 10 files changed, 32 insertions(+), 1536 deletions(-) delete mode 100644 GeneratorInterface/PyquenInterface/src/HepEvt.F delete mode 100644 GeneratorInterface/PyquenInterface/src/hepevt.inc delete mode 100644 GeneratorInterface/PyquenInterface/src/pyquen.F diff --git a/GeneratorInterface/PyquenInterface/BuildFile.xml b/GeneratorInterface/PyquenInterface/BuildFile.xml index 47d0404b37037..b2c955bb01f22 100644 --- a/GeneratorInterface/PyquenInterface/BuildFile.xml +++ b/GeneratorInterface/PyquenInterface/BuildFile.xml @@ -8,6 +8,7 @@ + diff --git a/GeneratorInterface/PyquenInterface/interface/PyquenWrapper.h b/GeneratorInterface/PyquenInterface/interface/PyquenWrapper.h index 2ba06c297a999..1f40188e83ef6 100644 --- a/GeneratorInterface/PyquenInterface/interface/PyquenWrapper.h +++ b/GeneratorInterface/PyquenInterface/interface/PyquenWrapper.h @@ -16,6 +16,11 @@ extern "C" { } #define PYQUEN pyquen_ +extern "C" { + void pyqver_(int& ,int& ,int& ,int&); +} +#define PYQVER pyqver_ + extern "C" { extern struct{ double bgen; diff --git a/GeneratorInterface/PyquenInterface/python/pyquenPythiaDefault_cff.py b/GeneratorInterface/PyquenInterface/python/pyquenPythiaDefault_cff.py index 3841d229f0a5e..78de12a2be837 100644 --- a/GeneratorInterface/PyquenInterface/python/pyquenPythiaDefault_cff.py +++ b/GeneratorInterface/PyquenInterface/python/pyquenPythiaDefault_cff.py @@ -28,7 +28,9 @@ 'MSTJ(22)=2' ), - ppJets = cms.vstring('MSEL=1 ! QCD hight pT processes'), + ppJets = cms.vstring('MSEL=1 ! QCD hight pT processes', + 'MSTP(122)=0' # ! no printout of Pythia initialization information hereinafter + ), pythiaJets = cms.vstring('MSUB(11)=1', # q+q->q+q 'MSUB(12)=1', # q+qbar->q+qbar 'MSUB(13)=1', # q+qbar->g+g diff --git a/GeneratorInterface/PyquenInterface/src/HepEvt.F b/GeneratorInterface/PyquenInterface/src/HepEvt.F deleted file mode 100644 index eb70f5dec0270..0000000000000 --- a/GeneratorInterface/PyquenInterface/src/HepEvt.F +++ /dev/null @@ -1,10 +0,0 @@ - - - subroutine ihepevt - - -#include "SimDataFormats/GeneratorProducts/data/stdhep.inc" -#include "SimDataFormats/GeneratorProducts/data/hepev4.inc" - - return - end diff --git a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc index ed752bceadb80..1ee7bc7fc66fa 100644 --- a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc +++ b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc @@ -78,6 +78,10 @@ filterType_(pset.getUntrackedParameter("filterType","None")) } selector_ = HiGenEvtSelectorFactory::get(filterType_,pset); + HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); + int cm=1; + PYQVER(cm,cm,cm,cm); + } @@ -183,7 +187,10 @@ bool PyquenHadronizer::generatePartonsAndHadronize() if(embedding_) rotateEvtPlane(evt,evtPlane_); add_heavy_ion_rec(evt); - + + HepMC::HEPEVT_Wrapper::check_hepevt_consistency(); + //std::cout<<"Entries number: "< /pythic/,/plpar1/,/parimp/,/pyqpar/,/plfpar/ - dimension ijoik(2),ijoin(1000),ijoin0(1000),nis(500),nss(500), - > nas(500),nus(500) - -* set initial event paramters - AW=A ! atomic weight - RA=1.15d0*AW**0.333333d0 ! nucleus radius in fm - RA3=3.d0*RA - mvisc=0 ! flag of QGP viscosity (off here) - TC=0.2d0 ! crutical temperature - - if(nfu.ne.0.and.nfu.ne.1.and.nfu.ne.2.and.nfu.ne.3) nfu=0 - nf=nfu ! number of active flavours in QGP - if(tau0u.lt.0.01d0.or.tau0u.gt.10.d0) tau0u=0.1d0 - tau0=tau0u ! proper time of QGP formation - if(T0u.lt.0.2d0.or.T0u.gt.2.d0) T0u=1.d0 - T0=T0u*(AW/207.d0)**0.166667d0 ! initial QGP temperatute at b=0 - if(ienglu.ne.0.and.ienglu.ne.1.and.ienglu.ne.2) ienglu=0 ! e-loss type - if(ianglu.ne.0.and.ianglu.ne.1.and.ianglu.ne.2) ianglu=0 ! angular spec. -* - pi=3.14159d0 - -* avoid stopping run if pythia does not conserve energy due to collisional loss - mstu(21)=1 - -* creation of arrays for tabulation of beam/target nuclear thickness function - Z2=4.d0*RA - Z1=-1.d0*Z2 - H=0.01d0*(Z2-Z1) - do ib=1,110 - BC=RA3*(ib-1)/109.d0 - CALL SIMPA(Z1,Z2,H,0.005d0,1.d-8,prhoaa,Z,RES,AIH,AIABS) - PBAB(ib)=BC - PTAB(ib)=AW*RES - end do - -* calculation of beam/target nuclear overlap function at b=0 -* if ifb=1: creation of arrays for tabulation of nuclear overlap function - npb=1 - if (ifb.eq.1) npb=110 - Z1=0.d0 - Z2=6.28318d0 - H=0.01d0*(Z2-Z1) - do ib=1,npb - bp=PBAB(ib) - CALL SIMPA(Z1,Z2,H,0.05d0,1.d-8,PFUNC1,X,RES,AIH,AIABS) - PTAAB(ib)=RES - end do - -* generate impact parameter of A-A collision with jet production - if(ifb.eq.0) then - if(bfix.lt.0.d0) then - write(6,*) 'Impact parameter less than zero!' - bfix=0.d0 - end if - if (bfix.gt.RA3) then - write(6,*) 'Impact parameter larger than three nuclear radius!' - bfix=RA3 - end if - b1=bfix - else - 112 call bipsear(fmax1,xmin1) - fmax=fmax1 - xmin=xmin1 - 11 bb1=xmin*pyr(0) - ff1=fmax*pyr(0) - fb=funbip(bb1) - if(ff1.gt.fb) goto 11 - b1=bb1 - if(bb1.gt.bmax) goto 112 - if(bb1.lt.bmin) goto 112 - end if - bgen=b1 - -* generate single event with partonic energy loss - nrg=0 - ehard=ckin(3) - call plinit(ehard) - call plevnt(ehard) - -* reset all in-vacuum radiated guark 4-momenta and codes to zero - do i=1,1000 - do j=1,5 - pqua(i,j)=0.d0 - kqua(i,j)=0 - end do - end do - nrq=0 - -* generate final state shower in vacuum if it was excluded before - nrgm=nrg ! fix number of in-medium emitted gluons - ip1=0 - ip2=0 - ip01=0 - ip02=0 - ip001=0 - ip002=0 - if(mstj(41).ne.0) goto 5 - mstj(41)=1 - nn=n - kfh1=0 - kfh2=0 - - do i=9,nn - if(k(i,3).eq.7) then - ip1=i ! first hard parton (line ip1) - kfh1=k(i,1) ! status code of first hard parton - qmax1=pyp(i,10) ! transverse momentum of first hard parton - end if - if(k(i,3).eq.8) then - ip2=i ! second hard parton (line ip2) - kfh2=k(i,1) ! status code of second hard parton - qmax2=pyp(i,10) ! transverse momentum of second hard parton - end if - end do - - n1=n - call pyshow(ip1,0,qmax1) ! vacuum showering for first hard parton - if(n.eq.n1) ip1=0 - n2=n - call pyshow(ip2,0,qmax2) ! vacuum showering for second hard parton - if(n.eq.n2) ip2=0 - mstj(41)=0 - if(n.eq.nn) goto 5 - -* find two leading partons after showering - do i=nn+1,n - if(k(i,3).eq.ip1) ip001=i ! first daughter of first hard parton - if(k(i,3).eq.ip2) ip002=i ! first daughter of second hard parton - end do - ptle1=0.d0 - ptle2=0.d0 - do i=nn+1,n - if (k(i,1).eq.14) goto 3 - if(i.ge.ip002.and.ip002.gt.0) then - ptl02=pyp(i,10) - if(ptl02.gt.ptle2.and.k(i,2).eq.k(ip2,2)) then - ip02=i ! leading parton in second shower (line ip02) - ptle2=ptl02 ! pt of the leading parton - end if - elseif(ip001.gt.0) then - ptl01=pyp(i,10) - if(ptl01.gt.ptle1.and.k(i,2).eq.k(ip1,2)) then - ip01=i ! leading parton in first shower (line ip01) - ptle1=ptl01 ! pt of the leading parton - end if - end if - 3 continue - end do - -* replace two hard partons by two leading partons in original event record - if(ip1.gt.0) then - do j=1,5 - v(ip1,j)=v(ip01,j) - p(ip1,j)=p(ip01,j) - end do - k(ip1,1)=kfh1 -* fix first/last daughter for moving entry - do jgl=1,n - if(k(jgl,4).eq.ip01) k(jgl,4)=ip1 - if(k(jgl,5).eq.ip01) k(jgl,5)=ip1 - end do -* - end if - if(ip2.gt.0) then - do j=1,5 - v(ip2,j)=v(ip02,j) - p(ip2,j)=p(ip02,j) - end do - k(ip2,1)=kfh2 -* fix first/last daughter for moving entry - do jgl=1,n - if(k(jgl,4).eq.ip02) k(jgl,4)=ip2 - if(k(jgl,5).eq.ip02) k(jgl,5)=ip2 - end do -* - end if - -* add final showering gluons to the list of in-medium emitted gluons, -* fill the list of emitted quarks by final showering quark pairs, -* and remove showering gluons and quarks from the event record - do i=nn+1,n - if(k(i,1).eq.14.or.i.eq.ip01.or.i.eq.ip02) goto 12 - if(k(i,2).ne.21) then ! filling 'plquar' arrays for quarks - nrq=nrq+1 - do j=1,5 - kqua(nrq,j)=k(i,j) - pqua(nrq,j)=p(i,j) - end do - kqua(nrq,1)=2 - goto 12 - end if - if(i.ge.ip002.and.ip002.gt.0) then - ish=ip2 - else - ish=ip1 - end if - nrg=nrg+1 - nur=nrg - 7 ishm=kglu(nur-1,6) - if(ish.ge.ishm.or.nur.le.2) goto 6 ! adding gluons in 'plglur' arrays - do j=1,6 - kglu(nur,j)=kglu(nur-1,j) - end do - do j=1,4 - glur(nur,j)=glur(nur-1,j) - end do - nur=nur-1 - goto 7 - 6 kglu(nur,1)=2 ! status code - kglu(nur,2)=k(i,2) ! particle identificator - kglu(nur,3)=k(ish,3) ! parent line number - kglu(nur,4)=0 ! special colour info - kglu(nur,5)=0 ! special colour info - kglu(nur,6)=ish ! associated parton number - glur(nur,1)=p(i,4) ! energy - glur(nur,2)=pyp(i,10) ! pt - glur(nur,3)=pyp(i,15) ! phi - glur(nur,4)=pyp(i,19) ! eta - 12 continue -* remove partons from event list - do j=1,5 - v(i,j)=0.d0 - k(i,j)=0 - p(i,j)=0.d0 - end do - end do - n=nn - - 5 continue - -* stop generate event if there are no additional gluons - if(nrg.lt.1) goto 1 - -* define number of stirngs (ns) and number of entries in strings before -* in-medium radiation (nis(ns)) - ns=0 - nes=0 - i0=0 - i1=0 - do i=1,500 - nis(i)=0 - nas(i)=0 - nss(i)=0 - nus(i)=0 - end do - do i=9,n - ks=k(i,1) - ksp=k(i-1,1) - if(ks.eq.2) then - nis(ns+1)=nis(ns+1)+1 - elseif(ks.eq.1.and.nis(ns+1).gt.0) then - nis(ns+1)=nis(ns+1)+1 - nes=nes+nis(ns+1) ! nes - total number of entries - nss(ns+1)=nes - ns=ns+1 - elseif(ks.ne.2.and.ksp.ne.2.and.ns.gt.0) then - i1=i1+1 ! last i1 lines not included in strings - end if - end do - i0=n-nes-i1 ! first i0 lines not included in strings - do i=1,ns - nss(i)=nss(i)+i0 - end do - -* move fragmented particles in bottom of event list - i=i0+1 - 2 ks=k(i,1) - ksp=k(i-1,1) - if(ks.ne.2.and.ksp.ne.2) then - n=n+1 - do j=1,5 - v(n,j)=v(i,j) - k(n,j)=k(i,j) - p(n,j)=p(i,j) - end do -* fix first/last daughter for moving entry - do jgl=1,n - if(k(jgl,4).eq.i) k(jgl,4)=n - if(k(jgl,5).eq.i) k(jgl,5)=n - end do -* - do in=i+1,n - do j=1,5 - v(in-1,j)=v(in,j) - k(in-1,j)=k(in,j) - p(in-1,j)=p(in,j) - end do -* fix first/last daughter for moving entry - do jgl=1,n - if(k(jgl,4).eq.in) k(jgl,4)=in-1 - if(k(jgl,5).eq.in) k(jgl,5)=in-1 - end do -* - end do - do ip=1,nrg - ku=kglu(ip,6) - if(ku.gt.i) kglu(ip,6)=ku-1 - end do - n=n-1 - else - i=i+1 - end if - if(i.le.n-i1) goto 2 - -* define number of additional entries in strings, nas(ns) - do i=1,nrg - kas=kglu(i,6) - if(kas.le.nss(1)) then - nas(1)=nas(1)+1 - else - do j=2,ns - if(kas.le.nss(j).and.kas.gt.nss(j-1)) - > nas(j)=nas(j)+1 - end do - end if - end do - do j=1,ns - do i=1,j - nus(j)=nus(j)+nas(i) - end do - end do - -* add emitted gluons in event list - nu=n - n=n+nrg - do i=nu,nu-i1,-1 - is=i+nrg - do j=1,5 - v(is,j)=v(i,j) - k(is,j)=k(i,j) - p(is,j)=p(i,j) - end do -* fix first/last daughter for moving entries - do jgl=1,n - if(k(jgl,4).eq.i) k(jgl,4)=is - if(k(jgl,5).eq.i) k(jgl,5)=is - end do -* - end do - - do ia=ns-1,1,-1 - do i=nss(ia+1)-1,nss(ia),-1 - is=i+nus(ia) - do j=1,5 - v(is,j)=v(i,j) - k(is,j)=k(i,j) - p(is,j)=p(i,j) - end do -* fix first/last daughter for moving entries - do jgl=1,n - if(k(jgl,4).eq.i) k(jgl,4)=is - if(k(jgl,5).eq.i) k(jgl,5)=is - end do -* - end do - end do - - do i=1,nrg - if(i.le.nus(1)) then - ia=nss(1)-1+i - else - do in=2,ns - if(i.le.nus(in).and.i.gt.nus(in-1)) - > ia=nss(in)-1+i - end do - end if - eg=glur(i,1) - ptg=glur(i,2) - phig=glur(i,3) - etag=glur(i,4) - do j=1,5 - v(ia,j)=0.d0 - k(ia,j)=kglu(i,j) - end do - p(ia,1)=ptg*dcos(phig) - p(ia,2)=ptg*dsin(phig) - p(ia,3)=dsqrt(abs(eg*eg-ptg*ptg)) - if(etag.lt.0.d0) p(ia,3)=-1.d0*p(ia,3) - p(ia,4)=dsqrt(ptg*ptg+p(ia,3)**2) - p(ia,5)=0.d0 - end do - -* rearrange partons to form strings in event list - do ij=1,1000 - ijoin(ij)=0 - ijoin0(ij)=0 - end do - do i=1,ns - njoin=nis(i)+nas(i) - if(i.eq.1) then - do j=1,njoin - ijoin(j)=i0+j - end do - else - do j=1,njoin - ijoin(j)=nss(i-1)+nus(i-1)+j - end do - end if - -* re-oder additional gluons by z-coordinate along the string - if(nas(i).gt.0) then - ja=njoin-nas(i) - jo1=ijoin(1) - jon=ijoin(njoin) - etasum=0.d0 - detaj=pyp(jo1,19)-pyp(jon,19) - do j=ja,njoin-1 - jnum=0 - etaj=pyp(jo1+j-1,19) - etasum=etasum+etaj - do jj=ja,njoin-1 - etajj=pyp(jo1+jj-1,19) - if(detaj.lt.0) then - if(etajj.lt.etaj.and.j.ne.jj) jnum=jnum+1 - else - if(etajj.gt.etaj.and.j.ne.jj) jnum=jnum+1 - end if - if(etajj.eq.etaj.and.j.lt.jj) jnum=jnum+1 - end do - ijoin(ja+jnum)=jo1+j-1 - end do - detas1=abs(pyp(jo1,19)-etasum) - detasn=abs(pyp(jon,19)-etasum) - if(detasn.gt.detas1) then - do j=1,njoin - ijoin0(j)=ijoin(j) - end do - do j=2,nas(i)+1 - ijoin(j)=ijoin0(ja+j-2) - end do - do j=nas(i)+2,njoin-1 - ijoin(j)=ijoin0(j-nas(i)) - end do - end if - end if - -* form strings - call pyjoin(njoin,ijoin) - - end do - -* add in-vacuum emitted quark pairs - if(nrq.lt.2) goto 1 - do i=1,nrq,2 - n=n+2 - do j=1,5 - v(n-1,j)=0.d0 - k(n-1,j)=kqua(i,j) - p(n-1,j)=pqua(i,j) - end do - in=i+1 - 4 ktest=k(n-1,2)+kqua(in,2) - if(ktest.eq.0.or.in.eq.nrq) goto 8 - in=in+1 - goto 4 - 8 do j=1,5 - v(n,j)=0.d0 - k(n,j)=kqua(in,j) - p(n,j)=pqua(in,j) - end do - if(in.gt.i+1) then - do j=1,5 - kqua(in,j)=kqua(i+1,j) - pqua(in,j)=pqua(i+1,j) - end do - end if - end do - - do ij=1,2 - ijoik(ij)=0 - end do - do i=1,nrq-1,2 - k(n+1-i,1)=1 - ijoik(1)=n-i - ijoik(2)=n+1-i - call pyjoin(2,ijoik) - end do - - 1 continue - - return - end - -********************************* PLINIT *************************** - SUBROUTINE PLINIT(ET) -* set time-dependence of plasma parameters - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external plvisc - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /plevol/ taup(5000),temp(5000),denp(5000),enep(5000) - save /plevol/,/plpar1/,/plpar2/ -* - et=et - pi=3.14159d0 - pi2=pi*pi - -* set number degrees of freedom in QGP - hgd=3.d0 - rg=(16.d0+10.5d0*nf)/hgd - rgn=(16.d0+9.d0*nf)/hgd - -* set 'fiction' sigma for parton rescattering in QGP - sigqq=4.2d0 - sigpl=2.25d0*2.25d0*sigqq*(16.d0+4.d0*nf)/(16.d0+9.d0*nf) - -* set intial plasma temperature, density and energy density in perfect -* (if mvisc=0) or viscous (mvisc=1,2) QGP with PLVISC subroitine - hst=0.15d0 - if(T0.gt.1.5d0.or.mvisc.eq.2) hst=0.25d0 - if(T0.gt.1.5d0.and.mvisc.ne.0) hst=0.9d0 - T01=T0*5.06d0 - TC1=TC*5.06d0 - pln0=(16.d0+9.d0*nf)*1.2d0*(T01**3)/pi2 - ened0=pi2*(16.d0+10.5d0*nf)*(T01**4)/30.d0 - hh=hst*tau0 - tau=tau0 ! proper time - T=T01 ! temperature - den=pln0 ! number density - ened=ened0 ! energy density - -* create array of parameters to configurate QGP time evolution - DO I=1,5000 - taup(i)=tau ! proper time - temp(i)=T/5.06d0 ! temperature - denp(i)=den ! number density - enep(i)=ened/5.06d0 ! energy density - ened1=0.5d0*hh*(1.3333d0*plvisc(T)/(tau*tau)-1.3333d0 - > *ened/tau)+ened - T1=(30.d0*ened1/((16.d0+10.5d0*nf)*pi2))**0.25d0 - tau1=tau+0.5d0*hh - ened=hh*(1.3333d0*plvisc(T1)/(tau1*tau1)-1.3333d0 - > *ened1/tau1)+ened - TPR=T - T=(30.d0*ened/((16.d0+10.5d0*nf)*pi2))**0.25d0 - den=(16.d0+9.d0*nf)*1.2d0*(T**3)/pi2 - tau=tau+hh - if(TPR.gt.TC1.and.T.le.TC1) taupl=tau-0.5d0*hh ! QGP lifetime taupl - END DO - tauh=taupl*rg ! mixed phase lifetime - - return - end -******************************** END PLINIT ************************** - -******************************* PLEVNT ****************************** - SUBROUTINE PLEVNT(ET) -* generate hard parton production vertex and passing with rescattering, -* collisional and radiative energy loss of each parton through plasma - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - IMPLICIT INTEGER(I-N) -c INTEGER PYK,PYCHGE,PYCOMP - external plthik, pln, plt, pls, gauss, gluang - external pyp,pyr,pyk - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /thikpa/ fmax,xmin - common /pyjets/ n,npad,k(4000,5),p(4000,5),v(4000,5) - common /pyqpar/ T0u,tau0u,nfu,ienglu,ianglu - common /plglur/ glur(1000,4),kglu(1000,6),nrg,nrgm - common /factor/ cfac, kf - common /pleave/ taul, temlev - common /parimp/ b1, psib1, rb1, rb2, noquen - common /plen/ epartc, um - common /plos/ elr,rsk - common /numje1/ nuj1, nuj2 - save/pyjets/,/plglur/,/plpar1/,/plpar2/,/thikpa/,/factor/, - < /pleave/,/parimp/,/plen/,/plos/,/numje1/ -* - pi=3.14159d0 - et=et -* find minimum of nuclear thikness function with subroutine plsear - psib1=pi*(2.d0*pyr(0)-1.d0) - call plsear (fmax1,xmin1) - fmax=fmax1 - xmin=xmin1 - -* generate vertex of jet production - iv=0 - 1 rr1=xmin*pyr(0) - ff1=fmax*pyr(0) - f=plthik(rr1) - iv=iv+1 - if(ff1.gt.f.and.iv.le.100000) goto 1 - r0=rr1 - rb1=dsqrt(abs(r0*r0+b1*b1/4.d0+r0*b1*dcos(psib1))) - rb2=dsqrt(abs(r0*r0+b1*b1/4.d0-r0*b1*dcos(psib1))) - rb1=max(rb1,1.d-4) - rb2=max(rb2,1.d-4) -* no quenching if noquen=1 or jet production vertex is out of effective dense zone - if(noquen.eq.1.or.rb1.gt.RA.or.rb2.gt.RA) goto 7 - -* find maximum of angular spectrum of radiated gluons with subroutine gluang - temin=0.5d0*pi - temax=0.5d0*(1.d0+dsqrt(5.d0))*0.0863d0 - ftemax=gluang(temax) - -* reset all radiated gluon 4-momenta and codes to zero ------------------- - do i=1,1000 - do j=1,4 - glur(i,j)=0.d0 - kglu(i,j)=0 - end do - kglu(i,5)=0 - kglu(i,6)=0 - end do - nrg=0 - -* generate changing 4-momentum of partons due to rescattering and energy loss -* (for partons with |eta|<3.5 and pt>3 GeV/c) - nuj1=9 ! minimum line number of rescattered parton - nuj2=n ! maximum line number of rescattered parton - do 2 ip=nuj1,nuj2 ! cycle on travelling partons - irasf=0 - iraz=0 - ks=k(ip,1) ! parton status code - kf=k(ip,2) ! parton identificator - ka=abs(kf) - ko=k(ip,3) ! origin (parent line number) - epart=abs(pyp(ip,10)) ! parton transverse momentum - etar=pyp(ip,19) ! parton pseudorapidity - if(ko.gt.6.and.epart.ge.3.d0.and.abs(etar). - > le.7.d0) then - if(ka.eq.21.or.ka.eq.1.or.ka.eq.2.or.ka.eq.3. - > or.ka.eq.4.or.ka.eq.5.or.ka.eq.6.or.ka.eq.7. - > or.ka.eq.8) then - if(ks.eq.2.or.ks.eq.1) then - phir=pyp(ip,15) ! parton azimuthal angle - tetr=pyp(ip,13) ! parton polar angle - yrr=pyp(ip,17) ! parton rapidity - stetr=dsin(tetr) ! parton sin(theta) - if(abs(stetr).le.1.d-05) then - if(stetr.ge.0.d0) then - stetr=1.d-05 - else - stetr=-1.d-05 - end if - end if - phir1=-1.d0*phir - tetr1=-1.d0*tetr - -* set colour factor - if(kf.eq.21) then - cfac=1.d0 ! for gluon - else - cfac=0.44444444d0 ! for quark - end if - -* boost from laboratory system to system of hard parton - ipar=ip - bet0=(r0*dcos(psib1)+0.5d0*b1)/rb1 - if(bet0.le.-1.d0) bet0=-0.99999d0 - if(bet0.ge.1.d0) bet0=0.99999d0 - bet=dacos(bet0) - if(psib1.lt.0.d0) bet=-1.d0*bet - phip=phir-bet - if(phip.gt.pi) phip=phip-2.d0*pi - if(phip.lt.-1.d0*pi) phip=phip+2.d0*pi - call pyrobo(ip,ip,0.d0,phir1,0.d0,0.d0,0.d0) - call pyrobo(ip,ip,tetr1,0.d0,0.d0,0.d0,0.d0) - -* calculate proper time of parton leaving the effective dense zone - aphin=(r0*r0-b1*b1/4.d0)/(rb1*rb2) - if(aphin.le.-1.d0) aphin=-0.99999d0 - if(aphin.ge.1.d0) aphin=0.99999d0 - phin=dacos(aphin) - if(psib1.le.0.d0) phin=-1.d0*phin - phid=phip-phin - if(phid.gt.pi) phid=phid-2.d0*pi - if(phid.lt.-1.d0*pi) phid=phid+2.d0*pi - taul1=abs(dsqrt(abs(RA*RA-(rb1*dsin(phip))**2))-rb1*dcos(phip)) - taul2=abs(dsqrt(abs(RA*RA-(rb2*dsin(phid))**2))-rb2*dcos(phid)) - taul=min(taul1,taul2) ! escape time taul - temlev=plt(taul,rb1,rb2,yrr) ! QGP temperature at taul - if(taul.le.tau0) goto 100 ! escape from QGP if taul8 -* and fill arrays of radiated gluons in common block plglur - if(nrg.le.1000) then - if(abs(elr).gt.0.1d0.and.ip.gt.8) then -* generate the angle of emitted gluon - if(ianglu.eq.0) then - 6 te1=temin*pyr(0) - fte1=ftemax*pyr(0) - fte2=gluang(te1) - if(fte1.gt.fte2) goto 6 - tgl=te1 - elseif (ianglu.eq.1) then - tgl=((0.5d0*pi*epartc)**pyr(0))/epartc - else - tgl=0.d0 - end if - pgl=pi*(2.d0*pyr(0)-1.d0) -* in comoving system - pxgl=abs(elr)*stetr*(dcos(phir)*dcos(tgl)- - > dsin(phir)*dsin(tgl)*dsin(pgl)) - pygl=abs(elr)*stetr*(dsin(phir)*dcos(tgl)+ - > dcos(phir)*dsin(tgl)*dsin(pgl)) - pzgl=-1.d0*abs(elr)*stetr*dsin(tgl)*dcos(pgl) - ptgl=dsqrt(abs(pxgl*pxgl+pygl*pygl)) - psgl=dsqrt(abs(ptgl*ptgl+pzgl*pzgl)) -* recalculate in lab system - dyg=0.5d0*dlog(max(1.d-9,(psgl+pzgl)/(psgl-pzgl))) - pzgl=ptgl*dsinh(yrr+dyg) - psgl=dsqrt(abs(ptgl*ptgl+pzgl*pzgl)) -* - dpgl=pygl/pxgl - glur1=abs(elr) ! energy - glur3=datan(dpgl) ! phi - if(pxgl.lt.0.d0) then - if(pygl.ge.0.d0) then - glur3=glur3+pi - else - glur3=glur3-pi - end if - end if - glur4=0.5d0*dlog(max(1.d-9,(psgl+pzgl)/(psgl-pzgl))) ! eta - glur2=glur1/dcosh(glur4) ! pt - -* put in event list radiated gluons with pt > 0.2 GeV only - if(glur2.ge.0.2d0) then - nrg=nrg+1 -* set gluon 4-momentum - glur(nrg,1)=glur1 ! energy - glur(nrg,2)=glur2 ! pt - glur(nrg,3)=glur3 ! phi - glur(nrg,4)=glur4 ! eta -* set gluon codes - kglu(nrg,1)=2 ! status code - kglu(nrg,2)=21 ! particle identificator - kglu(nrg,3)=k(ipar,3) ! parent line number - kglu(nrg,4)=0 ! special colour info - kglu(nrg,5)=0 ! special colour info - kglu(nrg,6)=ipar ! associated parton number - end if - end if - else - write(6,*) 'Warning! Number of emitted gluons is too large!' - end if - -* set parton "thermalization" if pt dlog(max(1.d-10,pyr(0)))) - if(ep0.le.p(ip,5).or.ep0.ge.100.d0) goto 5 - pp0=dsqrt(abs(ep0**2-p(ip,5)**2)) - probt=pp0/ep0 - if(pyr(0).gt.probt) goto 5 - ctp0=2.d0*pyr(0)-1.d0 - stp0=dsqrt(abs(1.d0-ctp0**2)) - php0=pi*(2.d0*pyr(0)-1.d0) - p(ip,1)=pp0*stp0*dcos(php0) - p(ip,2)=pp0*stp0*dsin(php0) - p(ip,3)=sigp*pp0*ctp0 - p(ip,4)=dsqrt(p(ip,1)**2+p(ip,2)**2+p(ip,3)**2+p(ip,5)**2) - -* boost to laboratory system - 100 call pyrobo(ip,ip,tetr,phir,0.d0,0.d0,0.d0) - end if - end if - end if - 2 continue - 7 continue - - return - end -******************************* END PLEVNT ************************* - -******************************* PLJETR ***************************** - SUBROUTINE PLJETR(tau,y,x,ip,epart) -* transform parton 4-momentum due to scattering in plasma at time = tau - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - IMPLICIT INTEGER(I-N) -c INTEGER PYK,PYCHGE,PYCOMP - external plfun1, pls - external pyp,pyr - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /pyjets/ n,npad,k(4000,5),p(4000,5),v(4000,5) - common /pyqpar/ T0u,tau0u,nfu,ienglu,ianglu - common /pljdat/ ej, z, ygl, alfs, um, epa - common /pleave/ taul, temlev - common /radcal/ aa, bb - common /factor/ cfac, kf - common /plos/ elr,rsk - save /pyjets/,/plpar1/,/plpar2/,/pyqpar/,/pljdat/,/pleave/,/plos/, - < /factor/,/radcal/ -* - pi=3.14159d0 - spi=dsqrt(pi) - tauu=x ! redenote temerature tauu=x - i=ip ! redenote parton number i=ip - iter=0 - iraz=0 - epart=epart - tau=tau - -* boost to system of comoving plasma constituent - phir=pyp(i,15) ! parton phi - tetr=pyp(i,13) ! parton theta - phir1=-1.d0*phir - tetr1=-1.d0*tetr - call pyrobo(i,i,0.d0,phir1,0.d0,0.d0,0.d0) - call pyrobo(i,i,tetr1,0.d0,0.d0,0.d0,0.d0) - pp=pyp(i,8) ! parton total momentum - ppl=abs(p(i,3)) ! parton pz - um=p(i,5) ! parton mass - epa=p(i,4) ! parton energy - ppt=pyp(i,10) ! parton pt - pphi=pyp(i,15) ! parton phi - - if(ppl.lt.3.d0) goto 222 ! no energy loss if pz<3 GeV/c - -* generation hard parton-plasma scattering with momentum transfer rsk - 221 ep0=-1.*tauu*(dlog(max(1.d-10,pyr(0)))+dlog(max(1.d-10, - > pyr(0)))+dlog(max(1.d-10,pyr(0)))) ! energy of 'thermal' parton - iter=iter+1 - if(ep0.lt.1.d-10.and.iter.le.100000) goto 221 - scm=2.*ep0*epa+um*um+ep0*ep0 - qm2=(scm-((um+ep0)**2))*(scm-((um-ep0)**2))/scm - bub=4.d0*tauu/TC - alf=6.d0*pi/((33.d0-2.d0*nf)*dlog(max(bub,1.d-10))) - z=abs(pi*4.d0*tauu*tauu*alf*(1.+nf/6.d0)) - bubs=dsqrt(z)/TC - alfs=6.d0*pi/((33.d0-2.d0*nf)*dlog(max(bubs,1.d-10))) - phmin2=z - phmax2=max(phmin2,qm2) - fqmax2=1.d0/(dlog(max(phmin2/(TC*TC),1.d-10)))**2 - 12 rn1=pyr(0) - tp=1.d0/(rn1/phmax2+(1.d0-rn1)/phmin2) - ftp=1.d0/(dlog(max(tp/(TC*TC),1.d-10)))**2 - fprob=ftp/fqmax2 - rn2=pyr(0) - if(fprob.lt.rn2) goto 12 - rsk=dsqrt(abs(tp)) - if(rsk.gt.ppl) rsk=ppl - -* calculate radiative energy loss per given scattering with subroutine plfun1 - ygl=y*cfac ! mean gluon free path in GeV^{-1} - elp=ygl*z ! mimimum radiated energy in LPM regime - ej=ppl - bb=ej ! maximum radiated energy - bbi=max(dsqrt(z),1.000001d0*elp) - aa=min(bb,bbi) ! minimum radiated energy - hh=0.00001d0*(bb-aa) - REPS=0.01d0 - AEPS=1.d-8 - CALL SIMPA(aa,bb,hh,REPS,AEPS,plfun1,om,resun,AIH,AIABS) -* ! integral over omega for radiative loss - call radsear(ermax1,eomin1) - ermax=ermax1 - eomin=eomin1 - 11 resu=eomin*pyr(0)+aa - fres=ermax*pyr(0) - fres1=plfun1(resu) - iraz=iraz+1 - if(fres.gt.fres1.and.iraz.lt.100000) goto 11 - elr=resu*resun ! energy of radiated gluon - -* to chancel radiative energy loss (optional case) - if(ienglu.eq.2) elr=0.d0 -* to chancel collisional energy loss (optional case) - if(ienglu.eq.1) rsk=0.d0 - -* determine the direction of parton moving - if(p(i,3).ge.0.d0) then - sigp=1.d0 - else - sigp=-1.d0 - end if - -* calculate new 4-momentum of hard parton - phirs=2.d0*pi*pyr(0) - epan=epa-rsk*rsk/(2.d0*ep0)-abs(elr) - if(epan.lt.0.1d0) then - epan=epan+abs(elr) - elr=0.d0 - if(epan.lt.0.1d0) then - rsk=0.d0 - epan=epa - end if - end if - pptn=dsqrt(abs(rsk*rsk+(rsk**4)*(1.d0-epa*epa/(ppl*ppl))/ - > (4.d0*ep0*ep0)-(rsk**4)*epa/(2.d0*ep0*ppl*ppl)-(rsk**4)/ - > (4.d0*ppl*ppl))) - ppln=dsqrt(abs(epan*epan-pptn*pptn-p(i,5)**2)) - p(i,1)=pptn*dcos(phirs) ! px - p(i,2)=pptn*dsin(phirs) ! py - p(i,3)=sigp*ppln ! pz - p(i,4)=dsqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2) ! E -* boost to system of hard parton - 222 call pyrobo(i,i,tetr,phir,0.d0,0.d0,0.d0) - - return - end -******************************* END PLJETR ************************** - -******************************** PLSEAR *************************** - SUBROUTINE PLSEAR (fmax,xmin) -* find maximum and 'sufficient minimum' of jet production vertex distribution -* xm, fm are outputs. - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external plthik - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - save /plpar1/ - xmin=3.d0*RA - fmax=0.d0 - do 10 j=1,1000 - x=xmin*(j-1)/999.d0 - f=plthik(x) - if(f.gt.fmax) then - fmax=f - end if - 10 continue - return - end -****************************** END PLSEAR ************************** - -******************************** RADSEAR *************************** - SUBROUTINE RADSEAR (fmax,xmin) -* find maximum and 'sufficient minimum' of radiative energy loss distribution -* xm, fm are outputs. - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external plfun1 - common /radcal/ aa, bb - save /radcal/ - xmin=bb-aa - fmax=0.d0 - do j=1,1000 - x=aa+xmin*(j-1)/999.d0 - f=plfun1(x) - if(f.gt.fmax) then - fmax=f - end if - end do - return - end -****************************** END RADSEAR ************************** - -********************************* BIPSEAR *************************** - SUBROUTINE BIPSEAR (fmax,xmin) -* find maximum and 'sufficient minimum' of jet production cross section -* as a function of impact paramater (xm, fm are outputs) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external funbip - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - save /plpar1/ - xmin=3.d0*RA - fmax=0.d0 - do j=1,1000 - x=xmin*(j-1)/999.d0 - f=funbip(x) - if(f.gt.fmax) then - fmax=f - end if - end do - return - end -****************************** END RADSEAR ************************** - -**************************** SIMPA ********************************** - SUBROUTINE SIMPA (A1,B1,H1,REPS1,AEPS1,FUNCT,X, - 1 AI,AIH,AIABS) -* calculate intergal of function FUNCT(X) on the interval from A1 to B1 - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - IMPLICIT INTEGER(I-N) - DIMENSION F(7), P(5) - H=dSIGN ( H1, B1-A1 ) - S=dSIGN (1.d0, H ) - A=A1 - B=B1 - AI=0.0d0 - AIH=0.0d0 - AIABS=0.0d0 - P(2)=4.d0 - P(4)=4.d0 - P(3)=2.d0 - P(5)=1.d0 - IF(B-A)1,2,1 - 1 REPS=ABS(REPS1) - AEPS=ABS(AEPS1) - DO 3 K=1,7 - 3 F(K)=10.d16 - X=A - C=0.d0 - F(1)=FUNCT(X)/3.d0 - 4 X0=X - IF( (X0+4.d0*H-B)*S)5,5,6 - 6 H=(B-X0)/4.d0 - IF ( H ) 7,2,7 - 7 DO 8 K=2,7 - 8 F(K)=10.d16 - C=1.d0 - 5 DI2=F (1) - DI3=ABS( F(1) ) - DO 9 K=2,5 - X=X+H - IF((X-B)*S)23,24,24 - 24 X=B - 23 IF(F(K)-10.d16)10,11,10 - 11 F(K)=FUNCT(X)/3.d0 - 10 DI2=DI2+P(K)*F(K) - 9 DI3=DI3+P(K)*ABS(F(K)) - DI1=(F(1)+4.*F(3)+F(5))*2.d0*H - DI2=DI2*H - DI3=DI3*H - IF (REPS) 12,13,12 - 13 IF (AEPS) 12,14,12 - 12 EPS=ABS((AIABS+DI3)*REPS) - IF(EPS-AEPS)15,16,16 - 15 EPS=AEPS - 16 DELTA=ABS(DI2-DI1) - IF(DELTA-EPS)20,21,21 - 20 IF(DELTA-EPS/8.d0)17,14,14 - 17 H=2.d0*H - F(1)=F(5) - F(2)=F(6) - F(3)=F(7) - DO 19 K=4,7 - 19 F(K)=10.d16 - GO TO 18 - 14 F(1)=F(5) - F(3)=F(6) - F(5)=F(7) - F(2)=10.d16 - F(4)=10.d16 - F(6)=10.d16 - F(7)=10.d16 - 18 DI1=DI2+(DI2-DI1)/15.d0 - AI=AI+DI1 - AIH=AIH+DI2 - AIABS=AIABS+DI3 - GO TO 22 - 21 H=H/2.d0 - F(7)=F(5) - F(6)=F(4) - F(5)=F(3) - F(3)=F(2) - F(2)=10.d16 - F(4)=10.d16 - X=X0 - C=0. - GO TO 5 - 22 IF(C)2,4,2 - 2 RETURN - END -************************* END SIMPA ******************************* - -**************************** SIMPB ********************************** - SUBROUTINE SIMPB (A1,B1,H1,REPS1,AEPS1,FUNCT,X, - 1 AI,AIH,AIABS) -* calculate intergal of function FUNCT(X) on the interval from A1 to B1 - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - IMPLICIT INTEGER(I-N) - DIMENSION F(7), P(5) - H=dSIGN ( H1, B1-A1 ) - S=dSIGN (1.d0, H ) - A=A1 - B=B1 - AI=0.0d0 - AIH=0.0d0 - AIABS=0.0d0 - P(2)=4.d0 - P(4)=4.d0 - P(3)=2.d0 - P(5)=1.d0 - IF(B-A)1,2,1 - 1 REPS=ABS(REPS1) - AEPS=ABS(AEPS1) - DO 3 K=1,7 - 3 F(K)=10.d16 - X=A - C=0.d0 - F(1)=FUNCT(X)/3.d0 - 4 X0=X - IF( (X0+4.d0*H-B)*S)5,5,6 - 6 H=(B-X0)/4.d0 - IF ( H ) 7,2,7 - 7 DO 8 K=2,7 - 8 F(K)=10.d16 - C=1.d0 - 5 DI2=F (1) - DI3=ABS( F(1) ) - DO 9 K=2,5 - X=X+H - IF((X-B)*S)23,24,24 - 24 X=B - 23 IF(F(K)-10.d16)10,11,10 - 11 F(K)=FUNCT(X)/3.d0 - 10 DI2=DI2+P(K)*F(K) - 9 DI3=DI3+P(K)*ABS(F(K)) - DI1=(F(1)+4.*F(3)+F(5))*2.d0*H - DI2=DI2*H - DI3=DI3*H - IF (REPS) 12,13,12 - 13 IF (AEPS) 12,14,12 - 12 EPS=ABS((AIABS+DI3)*REPS) - IF(EPS-AEPS)15,16,16 - 15 EPS=AEPS - 16 DELTA=ABS(DI2-DI1) - IF(DELTA-EPS)20,21,21 - 20 IF(DELTA-EPS/8.d0)17,14,14 - 17 H=2.d0*H - F(1)=F(5) - F(2)=F(6) - F(3)=F(7) - DO 19 K=4,7 - 19 F(K)=10.d16 - GO TO 18 - 14 F(1)=F(5) - F(3)=F(6) - F(5)=F(7) - F(2)=10.d16 - F(4)=10.d16 - F(6)=10.d16 - F(7)=10.d16 - 18 DI1=DI2+(DI2-DI1)/15.d0 - AI=AI+DI1 - AIH=AIH+DI2 - AIABS=AIABS+DI3 - GO TO 22 - 21 H=H/2.d0 - F(7)=F(5) - F(6)=F(4) - F(5)=F(3) - F(3)=F(2) - F(2)=10.d16 - F(4)=10.d16 - X=X0 - C=0. - GO TO 5 - 22 IF(C)2,4,2 - 2 RETURN - END -************************* END SIMPB ******************************* - -************************* PARINV ********************************** - SUBROUTINE PARINV(X,A,F,N,R) -* gives interpolation of function F(X) with arrays A(N) and F(N) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - IMPLICIT INTEGER(I-N) - DIMENSION A(N),F(N) - IF(X.LT.A(1))GO TO 11 - IF(X.GT.A(N))GO TO 4 - K1=1 - K2=N - 2 K3=K2-K1 - IF(K3.LE.1)GO TO 6 - K3=K1+K3/2 - IF(A(K3)-X) 7,8,9 - 7 K1=K3 - GOTO2 - 9 K2=K3 - GOTO2 - 8 R=F(K3) - RETURN - 3 B1=A(K1) - B2=A(K1+1) - B3=A(K1+2) - B4=F(K1) - B5=F(K1+1) - B6=F(K1+2) - R=B4*((X-B2)*(X-B3))/((B1-B2)*(B1-B3))+B5*((X-B1)*(X-B3))/ - 1 ((B2-B1)*(B2-B3))+B6*((X-B1)*(X-B2))/((B3-B1)*(B3-B2)) - RETURN - 6 IF(K2.NE.N)GO TO 3 - K1=N-2 - GOTO3 - 4 C=ABS(X-A(N)) - IF(C.LT.0.1d-7) GO TO 5 - K1=N-2 - 13 CONTINUE -C13 PRINT 41,X -C41 FORMAT(25H X IS OUT OF THE INTERVAL,3H X=,F15.9) - GO TO 3 - 5 R=F(N) - RETURN - 11 C=ABS(X-A(1)) - IF(C.LT.0.1d-7) GO TO 12 - K1=1 - GOTO 13 - 12 R=F(1) - RETURN - END -C************************** END PARINV ************************************* - -* quark-quark scattering differential cross section - double precision FUNCTION PLSIGH(Z) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - save /plpar1/ - pi=3.14159d0 - beta=(33.d0-2.d0*nf)/(12.d0*pi) - alfs=1.d0/(beta*dlog(max(1.d-10,z/(TC*TC)))) - PLSIGH=8.d0*pi*alfs*alfs/(9.d0*z*z) - return - end - -* differential radiated gluon spectrum in BDMS model - double precision FUNCTION PLFUN1(or) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /pljdat/ ej, z, ygl, alfs, um, epa - common /pleave/ taul, temlev - common /factor/ cfac, kf - save /plpar1/,/pljdat/,/pleave/,/factor/ - pi=3.14159d0 - x=min((1.d0-ygl*z/or),or/ej) - if(x.le.0.d0) x=0.d0 - if(x.ge.1.d0) x=0.9999d0 - if(kf.eq.21) then - if(x.ge.0.5d0) x=1.d0-x - spinf=0.5d0*(1.+(1.d0-x)**4+x**4)/(1.d0-x) - else - spinf=1.d0-x+0.5d0*x*x - end if - ak=ygl*z/(or*(1.d0-x)) - al=taul*5.06d0 - uu=0.5d0*al*dsqrt(abs(0.5d0*(1.d0-x+cfac*x*x)*ak* - > dlog(max(16.d0/ak,1.d-10))))/ygl -* if quark production outside the QGP then -* arg=(((dsin(uu)*cosh(uu))**2)+((dcos(uu)*sinh(uu))**2))/(2.d0*uu*uu); -* here quark production inside the QGP - arg=((dcos(uu)*cosh(uu))**2)+((dsin(uu)*sinh(uu))**2) - gl1=(ygl/(cfac*z))**0.3333333d0 - gl2=(um/epa)**1.333333d0 - dc=1.d0/((1.d0+((gl1*gl2*or)**1.5d0))**2) ! massive parton -c dc=1.d0 !massless parton - plfun1=dc*3.d0*alfs*ygl*dlog(max(arg,1.d-20))*spinf/(pi*al*or) - return - end - -* angular distribution of emitted gluons - double precision function gluang(x) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - s=0.0863d0 - gluang=x*dexp(-1.d0*(x-s)*(x-s)/(2.d0*s*s)) - return - end - -* temperature-dependence of parton-plasma integral cross section - double precision FUNCTION PLS(X) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external plsigh - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /plen/ epartc, um - save /plpar1/,/plpar2/,/plen/ - t=X - pi=3.14159d0 - bub=4.d0*t/TC - alf=6.d0*pi/((33.d0-2.d0*nf)*dlog(max(bub,1.d-10))) - ZZ0=4.d0*t*t*pi*alf*(1.d0+nf/6.d0) - scm=4.d0*t*epartc+um*um+4.d0*t*t - ZZ1=max((scm-((um+2.d0*t)**2))*(scm-((um-2.d0*t)**2))/scm,ZZ0) - HH1=0.01d0*ZZ1 - REPS=0.01d0 - AEPS=1.d-8 - CALL SIMPA(ZZ0,ZZ1,HH1,REPS,AEPS,plsigh,ZZ,RESS,AIH,AIABS) - PLS=0.39d0*2.25d0*2.25d0*RESS*(16.d0+4.d0*nf)/(16.d0+9.d0*nf) - return - end - -* temperature-dependence of QGP viscosity (if mvisc=1,2) - double precision FUNCTION PLVISC(X) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - save /plpar1/ - pi=3.14159d0 - T=X - TC1=5.06d0*TC - if(X.le.TC1) T=TC1 - if(mvisc.eq.0) then - c=0.d0 - elseif(mvisc.eq.1) then - a=3.4d0*(1.d0+0.12d0*(2.d0*nf+1.d0)) - b=15.d0*(1.d0+0.06d0*nf) - c=4.d0*pi*pi*(10.5d0*nf/a+16.d0/b)/675.d0 - else - c=(1.7d0*nf+1.d0)*0.342d0/(1.d0+nf/6.d0) - end if - bub=4.d0*T/TC1 - alf=6.d0*pi/((33.d0-2.d0*nf)*dlog(max(bub,1.d-10))) - alf1=1.d0/alf - PLVISC=c*(T**3)/(alf*alf*dlog(max(1.d-10,alf1))) - return - end - -* space-time dependence of QGP number density - double precision FUNCTION PLN(X,r1,r2,y) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external pythik - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /plevol/ taup(5000),temp(5000),denp(5000),enep(5000) - common /pythic/ PBAB(110),PTAB(110),PTAAB(110) - save /plpar1/,/plpar2/,/plevol/,/pythic/ - pi=3.14159d0 - t=X - if(t.lt.taupl) then - call parinv(t,taup,denp,5000,res) - else - res=1.2d0*(16.d0+9.d0*nf)*((5.06d0*TC)**3)/(pi*pi) - end if - res=res*(pythik(r1)*pythik(r2)*pi*RA*RA/PTAAB(1))**0.75d0 - res=res*dexp(-1.d0*y*y/24.5d0) - PLN=max(1.d-8,res) - return - end - -* space-time dependence of QGP temperature - double precision FUNCTION PLT(X,r1,r2,y) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /plpar2/ pln0,taupl,tauh,sigpl,sigh,sigplh,sigqqh,rg,rgn - common /plevol/ taup(5000),temp(5000),denp(5000),enep(5000) - common /pythic/ PBAB(110),PTAB(110),PTAAB(110) - save /plpar1/,/plpar2/,/plevol/,/pythic/ - pi=3.14159d0 - t=X - if(t.lt.taupl) then - call parinv(t,taup,temp,5000,res) - else - res=TC - end if - res=res*(pythik(r1)*pythik(r2)*pi*RA*RA/PTAAB(1))**0.25d0 - res=res*(dexp(-1.d0*y*y/24.5d0))**0.333333d0 - PLT=max(1.d-8,res) - return - end - -* impact parameter dependence of jet production cross section - double precision function funbip(x) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external ftaa - common /pyint7/ sigt(0:6,0:6,0:5) - save /pyint7/ - br=x - sigin=sigt(0,0,0)-sigt(0,0,1) - taa=ftaa(br) - funbip=taa*br*(1.d0-dexp(-0.1d0*taa*sigin)) - return - end - -* distribution over jet production vertex position - double precision FUNCTION plthik(X) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external pythik - common /parimp/ b1, psib1, rb1, rb2, noquen - save /parimp/ - bu=X - r12=dsqrt(abs(bu*bu+b1*b1/4.d0+bu*b1*dcos(psib1))) - r22=dsqrt(abs(bu*bu+b1*b1/4.d0-bu*b1*dcos(psib1))) - PLTHIK=bu*pythik(r12)*pythik(r22) - return - end - -* nuclear overlap function at impact parameter b - double precision function ftaa(r) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /pythic/ PBAB(110),PTAB(110),PTAAB(110) - save /pythic/ - call parinv(r,PBAB,PTAAB,110,RES) - ftaa=RES - return - end -* - double precision function PFUNC1(x) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external PFUNC2 - common /pynup1/ bp,xx - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - save /plpar1/ - xx=x - EPS=0.05d0 - A=0.d0 - B=3.d0*RA - H=0.01d0*(B-A) - CALL SIMPB(A,B,H,EPS,1.d-8,PFUNC2,Y,RES,AIH,AIABS) - PFUNC1=RES - return - end -* - double precision function PFUNC2(y) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - external pythik - common /pynup1/ bp,x - r1=sqrt(abs(y*y+bp*bp/4.+y*bp*cos(x))) - r2=sqrt(abs(y*y+bp*bp/4.-y*bp*cos(x))) - PFUNC2=y*pythik(r1)*pythik(r2) - return - end - -* nuclear thickness function - double precision function pythik(r) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /pythic/ PBAB(110),PTAB(110),PTAAB(110) - save /pythic/ - call parinv(r,PBAB,PTAB,110,RES) - pythik=RES - return - end - -* Wood-Saxon nucleon distrubution - double precision function prhoaa(z) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - common /plpar1/ tau0,T0,TC,sigqq,AW,RA,mvisc,nf - common /pygeom/ BC - save /plpar1/,/pygeom/ - pi=3.14159d0 - df=0.54d0 - r=sqrt(bc*bc+z*z) - rho0=3.d0/(4.d0*pi*RA**3)/(1.d0+(pi*df/RA)**2) - prhoaa=rho0/(1.d0+exp((r-RA)/df)) - return - end - -* function to generate gauss distribution - double precision function gauss(x0,sig) - IMPLICIT DOUBLE PRECISION(A-H, O-Z) - 41 u1=pyr(0) - u2=pyr(0) - v1=2.d0*u1-1.d0 - v2=2.d0*u2-1.d0 - s=v1**2+v2**2 - if(s.gt.1) go to 41 - gauss=v1*dsqrt(-2.d0*dlog(s)/s)*sig+x0 - return - end -************************************************************************** diff --git a/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.cc b/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.cc index 613c06a71fbca..32f3a8496bef1 100644 --- a/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.cc +++ b/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.cc @@ -34,6 +34,7 @@ PyquenAnalyzer::PyquenAnalyzer(const ParameterSet& pset) : phdNdEta(0), phdNdY(0), phdNdPt(0),phdNdPhi(0) { // constructor +srcT_ = mayConsume(edm::InputTag("generator","unsmeared")); } @@ -62,7 +63,8 @@ void PyquenAnalyzer::analyze( const Event& e, const EventSetup& ) // find initial (unsmeared, unfiltered,...) HepMCProduct // by its label - PyquenSource, that is - e.getByLabel( "source", EvtHandle ) ; + //e.getByLabel( "source", EvtHandle ) ; + e.getByToken(srcT_,EvtHandle); // EvtHandle->GetEvent()->print(); diff --git a/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.h b/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.h index 2265f76d28d33..f1a9dee8dd0bc 100644 --- a/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.h +++ b/GeneratorInterface/PyquenInterface/test/PyquenAnalyzer.h @@ -4,6 +4,13 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + + // forward declarations class TFile; class TH1D; @@ -19,6 +26,9 @@ class PyquenAnalyzer : public edm::EDAnalyzer virtual void beginJob(); virtual void endJob(); + edm::EDGetTokenT srcT_; + + private: TH1D* phdNdEta; // histogram for dN/deta diff --git a/GeneratorInterface/PyquenInterface/test/testPyquen.py b/GeneratorInterface/PyquenInterface/test/testPyquen.py index 41a30408bcbac..5ed87135c34f9 100644 --- a/GeneratorInterface/PyquenInterface/test/testPyquen.py +++ b/GeneratorInterface/PyquenInterface/test/testPyquen.py @@ -8,7 +8,7 @@ process.source = cms.Source("EmptySource") -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(100) ) process.SimpleMemoryCheck = cms.Service('SimpleMemoryCheck', @@ -16,7 +16,7 @@ oncePerEventMode = cms.untracked.bool(False) ) -process.ana = cms.EDAnalyzer('HydjetAnalyzer' +process.ana = cms.EDAnalyzer('PyquenAnalyzer' ) process.TFileService = cms.Service('TFileService', From feacdeb7e0f96affa13dbce4ff6ea3cd2778d8f2 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 21 Mar 2019 11:19:24 +0100 Subject: [PATCH 237/686] Avoid passing around parameters too often --- .../PFProducer/interface/PFAlgo.h | 33 +--- .../PFProducer/interface/PFEGammaFilters.h | 80 ++++------ .../PFProducer/plugins/PFProducer.cc | 67 +------- .../PFProducer/plugins/PFProducer.h | 3 +- RecoParticleFlow/PFProducer/src/PFAlgo.cc | 82 ++-------- .../PFProducer/src/PFEGammaFilters.cc | 143 +++++++++--------- 6 files changed, 129 insertions(+), 279 deletions(-) diff --git a/RecoParticleFlow/PFProducer/interface/PFAlgo.h b/RecoParticleFlow/PFProducer/interface/PFAlgo.h index a269d2a0a7a18..88d272e4debf8 100644 --- a/RecoParticleFlow/PFProducer/interface/PFAlgo.h +++ b/RecoParticleFlow/PFProducer/interface/PFAlgo.h @@ -60,7 +60,7 @@ class PFAlgo { void setAlgo( int algo ) {algo_ = algo;} void setPFMuonAlgo(PFMuonAlgo* algo) {pfmu_ =algo;} void setMuonHandle(const edm::Handle&); - void setDebug( bool debug ) {debug_ = debug; connector_.setDebug(debug_); if (pfegamma_) pfegamma_->setDebug(debug); } + void setDebug( bool debug ) {debug_ = debug; connector_.setDebug(debug_); } void setParameters(double nSigmaECAL, double nSigmaHCAL, @@ -113,27 +113,7 @@ class PFAlgo { double sumPtTrackIsoForPhoton, double sumPtTrackIsoSlopeForPhoton); - void setEGammaParameters(bool use_EGammaFilters, - std::string ele_iso_path_mvaWeightFile, - double ele_iso_pt, - double ele_iso_mva_barrel, - double ele_iso_mva_endcap, - double ele_iso_combIso_barrel, - double ele_iso_combIso_endcap, - double ele_noniso_mva, - unsigned int ele_missinghits, - double ele_ecalDrivenHademPreselCut, - double ele_maxElePtForOnlyMVAPresel, - bool useProtectionsForJetMET, - const edm::ParameterSet& ele_protectionsForJetMET, - const edm::ParameterSet& ele_protectionsForBadHcal, - double ph_MinEt, - double ph_combIso, - double ph_HoE, - double ph_sietaieta_eb, - double ph_sietaieta_ee, - const edm::ParameterSet& ph_protectionsForJetMET, - const edm::ParameterSet& ph_protectionsForBadHcal); + void setEGammaParameters(bool use_EGammaFilters, bool useProtectionsForJetMET); void setEGammaCollections(const edm::View & pfEgammaCandidates, @@ -179,11 +159,11 @@ class PFAlgo { /// reconstruct particles (full framework case) /// will keep track of the block handle to build persistent references, - /// and call reconstructParticles( const reco::PFBlockCollection& blocks ) - void reconstructParticles( const reco::PFBlockHandle& blockHandle ); + /// and call reconstructParticles( const reco::PFBlockCollection& blocks, PFEGammaFilters const* pfegamma ) + void reconstructParticles( const reco::PFBlockHandle& blockHandle, PFEGammaFilters const* pfegamma ); /// reconstruct particles - void reconstructParticles( const reco::PFBlockCollection& blocks ); + void reconstructParticles( const reco::PFBlockCollection& blocks, PFEGammaFilters const* pfegamma ); /// Check HF Cleaning void checkCleaning( const reco::PFRecHitCollection& cleanedHF ); @@ -245,7 +225,7 @@ class PFAlgo { /// algorithms void processBlock( const reco::PFBlockRef& blockref, std::list& hcalBlockRefs, - std::list& ecalBlockRefs ); + std::list& ecalBlockRefs, PFEGammaFilters const* pfegamma ); /// Reconstruct a charged particle from a track /// Returns the index of the newly created candidate in pfCandidates_ @@ -358,7 +338,6 @@ class PFAlgo { /// Variables for NEW EGAMMA selection bool useEGammaFilters_; - PFEGammaFilters *pfegamma_; bool useProtectionsForJetMET_; const edm::View * pfEgammaCandidates_; const edm::ValueMap * valueMapGedElectrons_; diff --git a/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h b/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h index fe367f92e23da..23b73717b228d 100644 --- a/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h +++ b/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h @@ -17,71 +17,46 @@ class PFEGammaFilters { public: - PFEGammaFilters(float ph_Et, - float ph_combIso, - float ph_loose_hoe, - float ph_sietaieta_eb, - float ph_sietaieta_ee, - const edm::ParameterSet& ph_protectionsForJetMET, - const edm::ParameterSet& ph_protectionsForBadHcal, - float ele_iso_pt, - float ele_iso_mva_eb, - float ele_iso_mva_ee, - float ele_iso_combIso_eb, - float ele_iso_combIso_ee, - float ele_noniso_mva, - unsigned int ele_missinghits, - float ele_ecalDrivenHademPreselCut, - float ele_maxElePtForOnlyMVAPresel, - const std::string& ele_iso_path_mvaWeightFile, - const edm::ParameterSet& ele_protectionsForJetMET, - const edm::ParameterSet& ele_protectionsForBadHcal - ); + PFEGammaFilters(const edm::ParameterSet& iConfig); - ~PFEGammaFilters(){}; - - bool passPhotonSelection(const reco::Photon &); + bool passPhotonSelection(const reco::Photon &) const; bool passElectronSelection(const reco::GsfElectron &, const reco::PFCandidate &, - const int & ); - bool isElectron(const reco::GsfElectron & ); + const int & ) const; + bool isElectron(const reco::GsfElectron & ) const; bool isElectronSafeForJetMET(const reco::GsfElectron &, const reco::PFCandidate &, const reco::Vertex &, - bool& lockTracks); + bool& lockTracks) const; bool isPhotonSafeForJetMET(const reco::Photon &, - const reco::PFCandidate &); - - void setDebug( bool debug ) { debug_ = debug; } + const reco::PFCandidate &) const; private: - bool passGsfElePreSelWithOnlyConeHadem(const reco::GsfElectron &); + bool passGsfElePreSelWithOnlyConeHadem(const reco::GsfElectron &) const; // Photon selections - float ph_Et_; - float ph_combIso_; - float ph_loose_hoe_; - float ph_sietaieta_eb_; - float ph_sietaieta_ee_; - //std::vector ph_protectionsForJetMET_; //replacement below - float pho_sumPtTrackIso, pho_sumPtTrackIsoSlope; + const float ph_Et_; + const float ph_combIso_; + const float ph_loose_hoe_; + const float ph_sietaieta_eb_; + const float ph_sietaieta_ee_; + const float pho_sumPtTrackIso, pho_sumPtTrackIsoSlope; // Electron selections - float ele_iso_pt_; - float ele_iso_mva_eb_; - float ele_iso_mva_ee_; - float ele_iso_combIso_eb_; - float ele_iso_combIso_ee_; - float ele_noniso_mva_; - unsigned int ele_missinghits_; - float ele_ecalDrivenHademPreselCut_; - float ele_maxElePtForOnlyMVAPresel_; - //std::vector ele_protectionsForJetMET_; // replacement below - float ele_maxNtracks, ele_maxHcalE, ele_maxTrackPOverEele, ele_maxE, + const float ele_iso_pt_; + const float ele_iso_mva_eb_; + const float ele_iso_mva_ee_; + const float ele_iso_combIso_eb_; + const float ele_iso_combIso_ee_; + const float ele_noniso_mva_; + const unsigned int ele_missinghits_; + const float ele_ecalDrivenHademPreselCut_; + const float ele_maxElePtForOnlyMVAPresel_; + const float ele_maxNtracks, ele_maxHcalE, ele_maxTrackPOverEele, ele_maxE, ele_maxEleHcalEOverEcalE, ele_maxEcalEOverPRes, ele_maxEeleOverPoutRes, ele_maxHcalEOverP, ele_maxHcalEOverEcalE, ele_maxEcalEOverP_1, ele_maxEcalEOverP_2, ele_maxEeleOverPout, ele_maxDPhiIN; @@ -91,15 +66,14 @@ class PFEGammaFilters { std::array badHcal_eInvPInv_; std::array badHcal_dEta_; std::array badHcal_dPhi_; - bool badHcal_eleEnable_; - static void readEBEEParams_(const edm::ParameterSet &pset, const std::string &name, std::array & out) ; + const bool badHcal_eleEnable_; // dead hcal selections (photons) - float badHcal_phoTrkSolidConeIso_offs_, badHcal_phoTrkSolidConeIso_slope_; - bool badHcal_phoEnable_; + const float badHcal_phoTrkSolidConeIso_offs_, badHcal_phoTrkSolidConeIso_slope_; + const bool badHcal_phoEnable_; // Event variables - bool debug_; + const bool debug_ = false; }; #endif diff --git a/RecoParticleFlow/PFProducer/plugins/PFProducer.cc b/RecoParticleFlow/PFProducer/plugins/PFProducer.cc index 5c8c2daab3e7b..8cd9cb185d742 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFProducer.cc +++ b/RecoParticleFlow/PFProducer/plugins/PFProducer.cc @@ -190,47 +190,12 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig) // Reading new EGamma selection cuts bool useProtectionsForJetMET(false); - double ele_iso_pt(0.0), ele_iso_mva_barrel(0.0), ele_iso_mva_endcap(0.0), - ele_iso_combIso_barrel(0.0), ele_iso_combIso_endcap(0.0), - ele_noniso_mva(0.0); - unsigned int ele_missinghits(0); - double ele_ecalDrivenHademPreselCut(0.0); - double ele_maxElePtForOnlyMVAPresel(0.0); - double ph_MinEt(0.0), ph_combIso(0.0), ph_HoE(0.0), - ph_sietaieta_eb(0.0),ph_sietaieta_ee(0.0); - string ele_iso_mvaWeightFile(""), ele_iso_path_mvaWeightFile(""); - edm::ParameterSet ele_protectionsForJetMET,ele_protectionsForBadHcal,ph_protectionsForJetMET,ph_protectionsForBadHcal; // Reading new EGamma ubiased collections and value maps if(use_EGammaFilters_) { - ele_iso_mvaWeightFile = iConfig.getParameter("isolatedElectronID_mvaWeightFile"); - ele_iso_path_mvaWeightFile = edm::FileInPath ( ele_iso_mvaWeightFile.c_str() ).fullPath(); inputTagPFEGammaCandidates_ = consumes >((iConfig.getParameter("PFEGammaCandidates"))); inputTagValueMapGedElectrons_ = consumes>(iConfig.getParameter("GedElectronValueMap")); inputTagValueMapGedPhotons_ = consumes >(iConfig.getParameter("GedPhotonValueMap")); - ele_iso_pt = iConfig.getParameter("electron_iso_pt"); - ele_iso_mva_barrel = iConfig.getParameter("electron_iso_mva_barrel"); - ele_iso_mva_endcap = iConfig.getParameter("electron_iso_mva_endcap"); - ele_iso_combIso_barrel = iConfig.getParameter("electron_iso_combIso_barrel"); - ele_iso_combIso_endcap = iConfig.getParameter("electron_iso_combIso_endcap"); - ele_noniso_mva = iConfig.getParameter("electron_noniso_mvaCut"); - ele_missinghits = iConfig.getParameter("electron_missinghits"); - ele_ecalDrivenHademPreselCut = iConfig.getParameter("electron_ecalDrivenHademPreselCut"); - ele_maxElePtForOnlyMVAPresel = iConfig.getParameter("electron_maxElePtForOnlyMVAPresel"); - ph_MinEt = iConfig.getParameter("photon_MinEt"); - ph_combIso = iConfig.getParameter("photon_combIso"); - ph_HoE = iConfig.getParameter("photon_HoE"); - ph_sietaieta_eb = iConfig.getParameter("photon_SigmaiEtaiEta_barrel"); - ph_sietaieta_ee = iConfig.getParameter("photon_SigmaiEtaiEta_endcap"); - useProtectionsForJetMET = - iConfig.getParameter("useProtectionsForJetMET"); - ele_protectionsForJetMET = - iConfig.getParameter("electron_protectionsForJetMET"); - ele_protectionsForBadHcal = - iConfig.getParameter("electron_protectionsForBadHcal"); - ph_protectionsForJetMET = - iConfig.getParameter("photon_protectionsForJetMET"); - ph_protectionsForBadHcal = - iConfig.getParameter("photon_protectionsForBadHcal"); + useProtectionsForJetMET = iConfig.getParameter("useProtectionsForJetMET"); } //Secondary tracks and displaced vertices parameters @@ -315,27 +280,10 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig) // NEW EGamma Filters - pfAlgo_->setEGammaParameters(use_EGammaFilters_, - ele_iso_path_mvaWeightFile, - ele_iso_pt, - ele_iso_mva_barrel, - ele_iso_mva_endcap, - ele_iso_combIso_barrel, - ele_iso_combIso_endcap, - ele_noniso_mva, - ele_missinghits, - ele_ecalDrivenHademPreselCut, - ele_maxElePtForOnlyMVAPresel, - useProtectionsForJetMET, - ele_protectionsForJetMET, - ele_protectionsForBadHcal, - ph_MinEt, - ph_combIso, - ph_HoE, - ph_sietaieta_eb, - ph_sietaieta_ee, - ph_protectionsForJetMET, - ph_protectionsForBadHcal); + pfAlgo_->setEGammaParameters(use_EGammaFilters_, useProtectionsForJetMET); + + if(use_EGammaFilters_) pfegamma_ = std::make_unique(iConfig); + //Secondary tracks and displaced vertices parameters @@ -403,9 +351,6 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig) } - -PFProducer::~PFProducer() {} - void PFProducer::beginRun(const edm::Run & run, const edm::EventSetup & es) @@ -514,7 +459,7 @@ PFProducer::produce(Event& iEvent, const EventSetup& iSetup) LogDebug("PFProducer")<<"particle flow is starting"<reconstructParticles( blocks ); + pfAlgo_->reconstructParticles( blocks, pfegamma_.get() ); if(verbose_) { ostringstream str; diff --git a/RecoParticleFlow/PFProducer/plugins/PFProducer.h b/RecoParticleFlow/PFProducer/plugins/PFProducer.h index 6aad6adb23a9b..5a9261fca0755 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFProducer.h +++ b/RecoParticleFlow/PFProducer/plugins/PFProducer.h @@ -25,6 +25,7 @@ #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h" class PFAlgo; class PFEnergyCalibrationHF; @@ -42,7 +43,6 @@ This producer makes use of PFAlgo, the particle flow algorithm. class PFProducer : public edm::stream::EDProducer<> { public: explicit PFProducer(const edm::ParameterSet&); - ~PFProducer() override; void produce(edm::Event&, const edm::EventSetup&) override; void beginRun(const edm::Run &, const edm::EventSetup &) override; @@ -65,6 +65,7 @@ class PFProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT > inputTagPFEGammaCandidates_; bool use_EGammaFilters_; + std::unique_ptr pfegamma_ = nullptr; //Use of HO clusters and links in PF Reconstruction diff --git a/RecoParticleFlow/PFProducer/src/PFAlgo.cc b/RecoParticleFlow/PFProducer/src/PFAlgo.cc index e11070fa7560f..2d97c6711a2fa 100644 --- a/RecoParticleFlow/PFProducer/src/PFAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFAlgo.cc @@ -56,14 +56,12 @@ PFAlgo::PFAlgo() debug_(false), pfele_(nullptr), pfpho_(nullptr), - pfegamma_(nullptr), useVertices_(false) {} PFAlgo::~PFAlgo() { if (usePFElectrons_) delete pfele_; if (usePFPhotons_) delete pfpho_; - if (useEGammaFilters_) delete pfegamma_; } @@ -201,68 +199,14 @@ PFAlgo::setPFPhotonParameters(bool usePFPhotons, return; } -void PFAlgo::setEGammaParameters(bool use_EGammaFilters, - std::string ele_iso_path_mvaWeightFile, - double ele_iso_pt, - double ele_iso_mva_barrel, - double ele_iso_mva_endcap, - double ele_iso_combIso_barrel, - double ele_iso_combIso_endcap, - double ele_noniso_mva, - unsigned int ele_missinghits, - double ele_ecalDrivenHademPreselCut, - double ele_maxElePtForOnlyMVAPresel, - bool useProtectionsForJetMET, - const edm::ParameterSet& ele_protectionsForJetMET, - const edm::ParameterSet& ele_protectionsForBadHcal, - double ph_MinEt, - double ph_combIso, - double ph_HoE, - double ph_sietaieta_eb, - double ph_sietaieta_ee, - const edm::ParameterSet& ph_protectionsForJetMET, - const edm::ParameterSet& ph_protectionsForBadHcal - ) +void PFAlgo::setEGammaParameters(bool use_EGammaFilters, bool useProtectionsForJetMET) { useEGammaFilters_ = use_EGammaFilters; if(!useEGammaFilters_ ) return; - FILE * fileEGamma_ele_iso_ID = fopen(ele_iso_path_mvaWeightFile.c_str(), "r"); - if (fileEGamma_ele_iso_ID) { - fclose(fileEGamma_ele_iso_ID); - } - else { - string err = "PFAlgo: cannot open weight file '"; - err += ele_iso_path_mvaWeightFile; - err += "'"; - throw invalid_argument( err ); - } - // ele_iso_mvaID_ = new ElectronMVAEstimator(ele_iso_path_mvaWeightFile_); useProtectionsForJetMET_ = useProtectionsForJetMET; - - pfegamma_ = new PFEGammaFilters(ph_MinEt, - ph_combIso, - ph_HoE, - ph_sietaieta_eb, - ph_sietaieta_ee, - ph_protectionsForJetMET, - ph_protectionsForBadHcal, - ele_iso_pt, - ele_iso_mva_barrel, - ele_iso_mva_endcap, - ele_iso_combIso_barrel, - ele_iso_combIso_endcap, - ele_noniso_mva, - ele_missinghits, - ele_ecalDrivenHademPreselCut, - ele_maxElePtForOnlyMVAPresel, - ele_iso_path_mvaWeightFile, - ele_protectionsForJetMET, - ele_protectionsForBadHcal); - - return; } void PFAlgo::setEGammaCollections(const edm::View & pfEgammaCandidates, const edm::ValueMap & valueMapGedElectrons, @@ -405,13 +349,13 @@ PFAlgo::setPFVertexParameters(bool useVertex, reco::VertexCollection const& pri } } -void PFAlgo::reconstructParticles( const reco::PFBlockHandle& blockHandle ) { +void PFAlgo::reconstructParticles( const reco::PFBlockHandle& blockHandle, PFEGammaFilters const* pfegamma ) { blockHandle_ = blockHandle; - reconstructParticles( *blockHandle_ ); + reconstructParticles( *blockHandle_, pfegamma ); } -void PFAlgo::reconstructParticles( const reco::PFBlockCollection& blocks ) { +void PFAlgo::reconstructParticles( const reco::PFBlockCollection& blocks, PFEGammaFilters const* pfegamma ) { // reset output collection if(pfCandidates_.get() ) @@ -495,7 +439,7 @@ void PFAlgo::reconstructParticles( const reco::PFBlockCollection& blocks ) { unsigned nblcks = 0; for(auto const& other : otherBlockRefs) { if ( debug_ ) std::cout << "Block number " << nblcks++ << std::endl; - processBlock( other, hcalBlockRefs, ecalBlockRefs ); + processBlock( other, hcalBlockRefs, ecalBlockRefs, pfegamma ); } std::list< reco::PFBlockRef > empty; @@ -504,14 +448,14 @@ void PFAlgo::reconstructParticles( const reco::PFBlockCollection& blocks ) { // process remaining single hcal blocks for(auto const& hcal : hcalBlockRefs) { if ( debug_ ) std::cout << "HCAL block number " << hblcks++ << std::endl; - processBlock( hcal, empty, empty ); + processBlock( hcal, empty, empty, pfegamma ); } unsigned eblcks = 0; // process remaining single ecal blocks for(auto const& ecal : ecalBlockRefs) { if ( debug_ ) std::cout << "ECAL block number " << eblcks++ << std::endl; - processBlock( ecal, empty, empty ); + processBlock( ecal, empty, empty, pfegamma ); } // Post HF Cleaning @@ -528,7 +472,7 @@ void PFAlgo::reconstructParticles( const reco::PFBlockCollection& blocks ) { void PFAlgo::processBlock( const reco::PFBlockRef& blockref, std::list& hcalBlockRefs, - std::list& ecalBlockRefs ) { + std::list& ecalBlockRefs, PFEGammaFilters const* pfegamma ) { // debug_ = false; assert(!blockref.isNull() ); @@ -645,8 +589,8 @@ void PFAlgo::processBlock( const reco::PFBlockRef& blockref, reco::GsfElectronRef gedEleRef = (*valueMapGedElectrons_)[pfEgmRef]; if(gedEleRef.isNonnull()) { - isGoodElectron = pfegamma_->passElectronSelection(*gedEleRef,*pfEgmRef,nVtx_); - isPrimaryElectron = pfegamma_->isElectron(*gedEleRef); + isGoodElectron = pfegamma->passElectronSelection(*gedEleRef,*pfEgmRef,nVtx_); + isPrimaryElectron = pfegamma->isElectron(*gedEleRef); if(egmLocalDebug){ if(isGoodElectron) cout << "** Good Electron, pt " << gedEleRef->pt() @@ -666,7 +610,7 @@ void PFAlgo::processBlock( const reco::PFBlockRef& blockref, reco::PhotonRef gedPhoRef = (*valueMapGedPhotons_)[pfEgmRef]; if(gedPhoRef.isNonnull()) { - isGoodPhoton = pfegamma_->passPhotonSelection(*gedPhoRef); + isGoodPhoton = pfegamma->passPhotonSelection(*gedPhoRef); if(egmLocalDebug) { if(isGoodPhoton) cout << "** Good Photon, pt " << gedPhoRef->pt() @@ -692,7 +636,7 @@ void PFAlgo::processBlock( const reco::PFBlockRef& blockref, bool isSafe = true; if( useProtectionsForJetMET_) { lockTracks = true; - isSafe = pfegamma_->isElectronSafeForJetMET(*gedEleRef,myPFElectron,primaryVertex_,lockTracks); + isSafe = pfegamma->isElectronSafeForJetMET(*gedEleRef,myPFElectron,primaryVertex_,lockTracks); } if(isSafe) { @@ -745,7 +689,7 @@ void PFAlgo::processBlock( const reco::PFBlockRef& blockref, reco::PFCandidate myPFPhoton = *pfEgmRef; bool isSafe = true; if( useProtectionsForJetMET_) { - isSafe = pfegamma_->isPhotonSafeForJetMET(*gedPhoRef,myPFPhoton); + isSafe = pfegamma->isPhotonSafeForJetMET(*gedPhoRef,myPFPhoton); } diff --git a/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc b/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc index 6b7e94f71f9d3..d0eafcef718a1 100644 --- a/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc +++ b/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc @@ -10,76 +10,83 @@ using namespace std; using namespace reco; -PFEGammaFilters::PFEGammaFilters(float ph_Et, - float ph_combIso, - float ph_loose_hoe, - float ph_sietaieta_eb, - float ph_sietaieta_ee, - const edm::ParameterSet& ph_protectionsForJetMET, - const edm::ParameterSet& ph_protectionsForBadHcal, - float ele_iso_pt, - float ele_iso_mva_eb, - float ele_iso_mva_ee, - float ele_iso_combIso_eb, - float ele_iso_combIso_ee, - float ele_noniso_mva, - unsigned int ele_missinghits, - float ele_ecalDrivenHademPreselCut, - float ele_maxElePtForOnlyMVAPresel, - const string& ele_iso_path_mvaWeightFile, - const edm::ParameterSet& ele_protectionsForJetMET, - const edm::ParameterSet& ele_protectionsForBadHcal - ): - ph_Et_(ph_Et), - ph_combIso_(ph_combIso), - ph_loose_hoe_(ph_loose_hoe), - ph_sietaieta_eb_(ph_sietaieta_eb), - ph_sietaieta_ee_(ph_sietaieta_ee), - pho_sumPtTrackIso(ph_protectionsForJetMET.getParameter("sumPtTrackIso")), - pho_sumPtTrackIsoSlope(ph_protectionsForJetMET.getParameter("sumPtTrackIsoSlope")), - ele_iso_pt_(ele_iso_pt), - ele_iso_mva_eb_(ele_iso_mva_eb), - ele_iso_mva_ee_(ele_iso_mva_ee), - ele_iso_combIso_eb_(ele_iso_combIso_eb), - ele_iso_combIso_ee_(ele_iso_combIso_ee), - ele_noniso_mva_(ele_noniso_mva), - ele_missinghits_(ele_missinghits), - ele_ecalDrivenHademPreselCut_(ele_ecalDrivenHademPreselCut), - ele_maxElePtForOnlyMVAPresel_(ele_maxElePtForOnlyMVAPresel), - ele_maxNtracks(ele_protectionsForJetMET.getParameter("maxNtracks")), - ele_maxHcalE(ele_protectionsForJetMET.getParameter("maxHcalE")), - ele_maxTrackPOverEele(ele_protectionsForJetMET.getParameter("maxTrackPOverEele")), - ele_maxE(ele_protectionsForJetMET.getParameter("maxE")), - ele_maxEleHcalEOverEcalE(ele_protectionsForJetMET.getParameter("maxEleHcalEOverEcalE")), - ele_maxEcalEOverPRes(ele_protectionsForJetMET.getParameter("maxEcalEOverPRes")), - ele_maxEeleOverPoutRes(ele_protectionsForJetMET.getParameter("maxEeleOverPoutRes")), - ele_maxHcalEOverP(ele_protectionsForJetMET.getParameter("maxHcalEOverP")), - ele_maxHcalEOverEcalE(ele_protectionsForJetMET.getParameter("maxHcalEOverEcalE")), - ele_maxEcalEOverP_1(ele_protectionsForJetMET.getParameter("maxEcalEOverP_1")), - ele_maxEcalEOverP_2(ele_protectionsForJetMET.getParameter("maxEcalEOverP_2")), - ele_maxEeleOverPout(ele_protectionsForJetMET.getParameter("maxEeleOverPout")), - ele_maxDPhiIN(ele_protectionsForJetMET.getParameter("maxDPhiIN")), - badHcal_eleEnable_(ele_protectionsForBadHcal.getParameter("enableProtections")), - badHcal_phoTrkSolidConeIso_offs_(ph_protectionsForBadHcal.getParameter("solidConeTrkIsoOffset")), - badHcal_phoTrkSolidConeIso_slope_(ph_protectionsForBadHcal.getParameter("solidConeTrkIsoSlope")), - badHcal_phoEnable_(ph_protectionsForBadHcal.getParameter("enableProtections")), - debug_(false) -{ - readEBEEParams_(ele_protectionsForBadHcal, "full5x5_sigmaIetaIeta", badHcal_full5x5_sigmaIetaIeta_); - readEBEEParams_(ele_protectionsForBadHcal, "eInvPInv", badHcal_eInvPInv_); - readEBEEParams_(ele_protectionsForBadHcal, "dEta", badHcal_dEta_); - readEBEEParams_(ele_protectionsForBadHcal, "dPhi", badHcal_dPhi_); -} +namespace { -void PFEGammaFilters::readEBEEParams_(const edm::ParameterSet &pset, const std::string &name, std::array & out) { + void readEBEEParams_( const edm::ParameterSet &pset, + const std::string &name, + std::array & out) + { const auto & vals = pset.getParameter>(name); - if (vals.size() != 2) throw cms::Exception("Configuration") << "Parameter " << name << " does not contain exactly 2 values (EB, EE)\n"; + if (vals.size() != 2) throw cms::Exception("Configuration") << "Parameter " + << name << " does not contain exactly 2 values (EB, EE)\n"; out[0] = vals[0]; out[1] = vals[1]; + } + + auto eleJetMetProt(const edm::ParameterSet& cfg) { + return cfg.getParameter("electron_protectionsForJetMET"); + } + + auto phJetMetProt(const edm::ParameterSet& cfg) { + return cfg.getParameter("photon_protectionsForJetMET"); + } + + auto eleHcalProt(const edm::ParameterSet& cfg) { + return cfg.getParameter("electron_protectionsForBadHcal"); + } + + auto phHcalProt(const edm::ParameterSet& cfg) { + return cfg.getParameter("photon_protectionsForBadHcal"); + } + } -bool PFEGammaFilters::passPhotonSelection(const reco::Photon & photon) { +PFEGammaFilters::PFEGammaFilters(const edm::ParameterSet& cfg) : + ph_Et_(cfg.getParameter("photon_MinEt")), + ph_combIso_(cfg.getParameter("photon_combIso")), + ph_loose_hoe_(cfg.getParameter("photon_HoE")), + ph_sietaieta_eb_(cfg.getParameter("photon_SigmaiEtaiEta_barrel")), + ph_sietaieta_ee_(cfg.getParameter("photon_SigmaiEtaiEta_endcap")), + pho_sumPtTrackIso(phJetMetProt(cfg).getParameter("sumPtTrackIso")), + pho_sumPtTrackIsoSlope(phJetMetProt(cfg).getParameter("sumPtTrackIsoSlope")), + ele_iso_pt_(cfg.getParameter("electron_iso_pt")), + ele_iso_mva_eb_(cfg.getParameter("electron_iso_mva_barrel")), + ele_iso_mva_ee_(cfg.getParameter("electron_iso_mva_endcap")), + ele_iso_combIso_eb_(cfg.getParameter("electron_iso_combIso_barrel")), + ele_iso_combIso_ee_(cfg.getParameter("electron_iso_combIso_endcap")), + ele_noniso_mva_(cfg.getParameter("electron_noniso_mvaCut")), + ele_missinghits_(cfg.getParameter("electron_missinghits")), + ele_ecalDrivenHademPreselCut_(cfg.getParameter("electron_ecalDrivenHademPreselCut")), + ele_maxElePtForOnlyMVAPresel_(cfg.getParameter("electron_maxElePtForOnlyMVAPresel")), + ele_maxNtracks(eleJetMetProt(cfg).getParameter("maxNtracks")), + ele_maxHcalE(eleJetMetProt(cfg).getParameter("maxHcalE")), + ele_maxTrackPOverEele(eleJetMetProt(cfg).getParameter("maxTrackPOverEele")), + ele_maxE(eleJetMetProt(cfg).getParameter("maxE")), + ele_maxEleHcalEOverEcalE(eleJetMetProt(cfg).getParameter("maxEleHcalEOverEcalE")), + ele_maxEcalEOverPRes(eleJetMetProt(cfg).getParameter("maxEcalEOverPRes")), + ele_maxEeleOverPoutRes(eleJetMetProt(cfg).getParameter("maxEeleOverPoutRes")), + ele_maxHcalEOverP(eleJetMetProt(cfg).getParameter("maxHcalEOverP")), + ele_maxHcalEOverEcalE(eleJetMetProt(cfg).getParameter("maxHcalEOverEcalE")), + ele_maxEcalEOverP_1(eleJetMetProt(cfg).getParameter("maxEcalEOverP_1")), + ele_maxEcalEOverP_2(eleJetMetProt(cfg).getParameter("maxEcalEOverP_2")), + ele_maxEeleOverPout(eleJetMetProt(cfg).getParameter("maxEeleOverPout")), + ele_maxDPhiIN(eleJetMetProt(cfg).getParameter("maxDPhiIN")), + badHcal_eleEnable_(eleHcalProt(cfg).getParameter("enableProtections")), + badHcal_phoTrkSolidConeIso_offs_(phHcalProt(cfg).getParameter("solidConeTrkIsoOffset")), + badHcal_phoTrkSolidConeIso_slope_(phHcalProt(cfg).getParameter("solidConeTrkIsoSlope")), + badHcal_phoEnable_(phHcalProt(cfg).getParameter("enableProtections")), + debug_(cfg.getUntrackedParameter("debug",false)) +{ + auto const& eleProtectionsForBadHcal = cfg.getParameter("electron_protectionsForBadHcal"); + readEBEEParams_(eleProtectionsForBadHcal, "full5x5_sigmaIetaIeta", badHcal_full5x5_sigmaIetaIeta_); + readEBEEParams_(eleProtectionsForBadHcal, "eInvPInv", badHcal_eInvPInv_); + readEBEEParams_(eleProtectionsForBadHcal, "dEta", badHcal_dEta_); + readEBEEParams_(eleProtectionsForBadHcal, "dPhi", badHcal_dPhi_); +} + + +bool PFEGammaFilters::passPhotonSelection(const reco::Photon & photon) const { // First simple selection, same as the Run1 to be improved in CMSSW_710 @@ -122,7 +129,7 @@ bool PFEGammaFilters::passPhotonSelection(const reco::Photon & photon) { bool PFEGammaFilters::passElectronSelection(const reco::GsfElectron & electron, const reco::PFCandidate & pfcand, - const int & nVtx) { + const int & nVtx) const { // First simple selection, same as the Run1 to be improved in CMSSW_710 bool validHoverE = electron.hcalOverEcalValid(); @@ -179,7 +186,7 @@ bool PFEGammaFilters::passElectronSelection(const reco::GsfElectron & electron, } -bool PFEGammaFilters::isElectron(const reco::GsfElectron & electron) { +bool PFEGammaFilters::isElectron(const reco::GsfElectron & electron) const { unsigned int nmisshits = electron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); if(nmisshits > ele_missinghits_) @@ -192,7 +199,7 @@ bool PFEGammaFilters::isElectron(const reco::GsfElectron & electron) { bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron, const reco::PFCandidate & pfcand, const reco::Vertex & primaryVertex, - bool& lockTracks) { + bool& lockTracks) const { bool debugSafeForJetMET = false; bool isSafeForJetMET = true; @@ -362,7 +369,7 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron return isSafeForJetMET; } -bool PFEGammaFilters::isPhotonSafeForJetMET(const reco::Photon & photon, const reco::PFCandidate & pfcand) { +bool PFEGammaFilters::isPhotonSafeForJetMET(const reco::Photon & photon, const reco::PFCandidate & pfcand) const { bool isSafeForJetMET = true; bool debugSafeForJetMET = false; @@ -429,7 +436,7 @@ bool PFEGammaFilters::isPhotonSafeForJetMET(const reco::Photon & photon, const r //However CMS is scared of making any change to the PF content and therefore //we have to explicitly reject them here //has to be insync here with GsfElectronAlgo::isPreselected -bool PFEGammaFilters::passGsfElePreSelWithOnlyConeHadem(const reco::GsfElectron & ele) +bool PFEGammaFilters::passGsfElePreSelWithOnlyConeHadem(const reco::GsfElectron & ele) const { bool passCutBased=ele.passingCutBasedPreselection(); if(ele.hadronicOverEm()>ele_ecalDrivenHademPreselCut_) passCutBased = false; From 37db9fbfc451393950a88e81198f76a676c879f4 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 21 Mar 2019 17:20:42 +0100 Subject: [PATCH 238/686] Merge development code to a usual Geometry structure --- .../DDCMS/interface/MuonNumbering.h | 23 ----- .../DDCMS/interface/MuonSubDetector.h | 24 ----- .../DDCMS/plugins/BuildFile.xml | 30 +++---- .../DDCMS/src/ES_DDDetector.cc | 9 -- .../DDCMS/test/DDFilteredView.cppunit.cc | 2 +- .../interface/DTGeometryBuilder.h | 3 + .../interface/DTNumberingScheme.h | 32 ------- .../plugins/DTGeometryESProducer.cc | 14 ++- .../RecoGeometry/src/DTGeometryBuilder.cc | 39 +++----- .../RecoGeometry/src/DTNumberingScheme.cc | 81 ----------------- .../interface/DD4hep_DTNumberingScheme.h | 55 ++++++++++++ .../interface/DD4hep_MuonNumbering.h | 51 +++++++++++ Geometry/MuonNumbering/plugins/BuildFile.xml | 9 +- .../plugins/DDTestMuonNumbering.cc | 8 +- .../plugins/MuonNumberingESProducer.cc | 8 +- .../src/DD4hep_DTNumberingScheme.cc | 88 +++++++++++++++++++ .../MuonNumbering/src/DD4hep_MuonNumbering.cc | 15 +++- .../Records}/interface/DDSpecParRegistryRcd.h | 2 +- .../Records}/interface/DDVectorRegistryRcd.h | 2 +- .../interface/DetectorDescriptionRcd.h | 0 .../Records}/interface/MuonGeometryRcd.h | 6 +- .../Records}/interface/MuonNumberingRcd.h | 4 +- Geometry/Records/src/DDSpecParRegistryRcd.cc | 4 + Geometry/Records/src/DDVectorRegistryRcd.cc | 4 + .../Records/src/DetectorDescriptionRcd.cc | 4 + Geometry/Records/src/ES_MuonDDDConstants.cc | 4 - Geometry/Records/src/MuonGeometryRcd.cc | 4 + Geometry/Records/src/MuonNumberingRcd.cc | 4 + 28 files changed, 284 insertions(+), 245 deletions(-) delete mode 100644 DetectorDescription/DDCMS/interface/MuonNumbering.h delete mode 100644 DetectorDescription/DDCMS/interface/MuonSubDetector.h delete mode 100644 DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h delete mode 100644 DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc create mode 100644 Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h create mode 100644 Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h rename {DetectorDescription/DDCMS => Geometry/MuonNumbering}/plugins/DDTestMuonNumbering.cc (84%) rename {DetectorDescription/DDCMS => Geometry/MuonNumbering}/plugins/MuonNumberingESProducer.cc (87%) create mode 100644 Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc rename DetectorDescription/DDCMS/src/MuonNumbering.cc => Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc (82%) rename {DetectorDescription/DDCMS => Geometry/Records}/interface/DDSpecParRegistryRcd.h (83%) rename {DetectorDescription/DDCMS => Geometry/Records}/interface/DDVectorRegistryRcd.h (83%) rename {DetectorDescription/DDCMS => Geometry/Records}/interface/DetectorDescriptionRcd.h (100%) rename {DetectorDescription/DDCMS => Geometry/Records}/interface/MuonGeometryRcd.h (80%) rename {DetectorDescription/DDCMS => Geometry/Records}/interface/MuonNumberingRcd.h (72%) create mode 100644 Geometry/Records/src/DDSpecParRegistryRcd.cc create mode 100644 Geometry/Records/src/DDVectorRegistryRcd.cc create mode 100644 Geometry/Records/src/DetectorDescriptionRcd.cc delete mode 100644 Geometry/Records/src/ES_MuonDDDConstants.cc create mode 100644 Geometry/Records/src/MuonGeometryRcd.cc create mode 100644 Geometry/Records/src/MuonNumberingRcd.cc diff --git a/DetectorDescription/DDCMS/interface/MuonNumbering.h b/DetectorDescription/DDCMS/interface/MuonNumbering.h deleted file mode 100644 index c86f6bfd898ed..0000000000000 --- a/DetectorDescription/DDCMS/interface/MuonNumbering.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef DETECTOR_DESCRIPTION_MUON_NUMBERING_H -#define DETECTOR_DESCRIPTION_MUON_NUMBERING_H - -#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" -#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" -#include -#include - -class MuonBaseNumber; - -namespace cms { - - using MuonConstants = std::unordered_map; - - struct MuonNumbering { - const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const; - const int get(const char*) const; - - MuonConstants values; - }; -} - -#endif diff --git a/DetectorDescription/DDCMS/interface/MuonSubDetector.h b/DetectorDescription/DDCMS/interface/MuonSubDetector.h deleted file mode 100644 index 08349bf96f0c4..0000000000000 --- a/DetectorDescription/DDCMS/interface/MuonSubDetector.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DETECTOR_DESCRIPTION_MUON_SUB_DETECTOR_H -#define DETECTOR_DESCRIPTION_MUON_SUB_DETECTOR_H - -#include -#include - -namespace cms { - struct MuonSubDetector { - - enum class SubDetector { - barrel = 1, endcap = 2, - rpc = 3, gem = 4, me0 = 5, nodef }; - - const std::map subDetMap { - { barrel, "MuonDTHits" }, - { endcap, "MuonCSCHits"}, - { rpc,"MuonRPCHits" }, - { gem, "MuonGEMHits" }, - { me0, "MuonME0Hits" }, - { nodef, "" }}; - }; -} - -#endif diff --git a/DetectorDescription/DDCMS/plugins/BuildFile.xml b/DetectorDescription/DDCMS/plugins/BuildFile.xml index 2451d3df8c692..e930c7ad68926 100644 --- a/DetectorDescription/DDCMS/plugins/BuildFile.xml +++ b/DetectorDescription/DDCMS/plugins/BuildFile.xml @@ -4,28 +4,28 @@ - + + - + + - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/DetectorDescription/DDCMS/src/ES_DDDetector.cc b/DetectorDescription/DDCMS/src/ES_DDDetector.cc index bcdd99879f1f4..a1b66effb29dd 100644 --- a/DetectorDescription/DDCMS/src/ES_DDDetector.cc +++ b/DetectorDescription/DDCMS/src/ES_DDDetector.cc @@ -3,10 +3,6 @@ #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" #include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" #include "FWCore/Framework/interface/data_default_record_trait.h" @@ -15,10 +11,5 @@ using namespace cms; TYPELOOKUP_DATA_REG(DDDetector); TYPELOOKUP_DATA_REG(DDSpecParRegistry); TYPELOOKUP_DATA_REG(DDVectorRegistry); -TYPELOOKUP_DATA_REG(MuonNumbering); -EVENTSETUP_RECORD_REG(DetectorDescriptionRcd); EVENTSETUP_DATA_DEFAULT_RECORD(DDDetector, DetectorDescriptionRcd); -EVENTSETUP_RECORD_REG(DDSpecParRegistryRcd); -EVENTSETUP_RECORD_REG(DDVectorRegistryRcd); -EVENTSETUP_RECORD_REG(MuonNumberingRcd); diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc index b4ea649e29b26..d04b4006c3dde 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc @@ -39,6 +39,6 @@ void testDDFilteredView::setUp() { void testDDFilteredView::checkFilteredView() { -unique_ptr det = make_unique("DUMMY", fileName_); + unique_ptr det = make_unique("DUMMY", fileName_); DDFilteredView fview(det.get(), det->description()->worldVolume()); } diff --git a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h index b82d354a97541..1f17cc77a77dc 100644 --- a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h +++ b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h @@ -4,6 +4,7 @@ #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h" #include "DataFormats/GeometrySurface/interface/Plane.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" namespace dd4hep { class Detector; @@ -55,6 +56,8 @@ namespace cms { RCPPlane plane(const DDFilteredView&, Bounds* bounds) const; + + std::unique_ptr dtnum_ = nullptr; }; } diff --git a/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h b/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h deleted file mode 100644 index 0b0454e3f29b5..0000000000000 --- a/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GEOMETRY_RECO_GEOMETRY_DT_NUMBERING_SCHEME_H -#define GEOMETRY_RECO_GEOMETRY_DT_NUMBERING_SCHEME_H - -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" - -namespace cms { - struct DTNumberingScheme { - DTNumberingScheme(MuonConstants&); - int baseNumberToUnitNumber(const MuonBaseNumber&); - int getDetId(const MuonBaseNumber&) const; - - void initMe(MuonConstants&); - // Decode MuonBaseNumber to id: no checking - void decode(const MuonBaseNumber& num, - int& wire_id, - int& layer_id, - int& superlayer_id, - int& sector_id, - int& station_id, - int& wheel_id - ) const; - - int theRegionLevel; - int theWheelLevel; - int theStationLevel; - int theSuperLayerLevel; - int theLayerLevel; - int theWireLevel; - }; -} - -#endif diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc b/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc index 8f5868aa21bd1..b1dc5fa99822d 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc +++ b/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc @@ -36,12 +36,12 @@ #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/ReusableObjectHolder.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h" @@ -195,7 +195,3 @@ DTGeometryESProducer::setupDBGeometry( const DTRecoGeometryRcd& record, } DEFINE_FWK_EVENTSETUP_MODULE(DTGeometryESProducer); - -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" -EVENTSETUP_RECORD_REG(MuonGeometryRcd); diff --git a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc b/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc index c3417d3797001..c76d7ed3f1320 100644 --- a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc +++ b/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc @@ -29,27 +29,20 @@ #include "DataFormats/GeometrySurface/interface/Bounds.h" #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h" +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" #include "DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h" #include "DD4hep/Detector.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/VolumeProcessor.h" -#include "TGeoManager.h" -#include "TClass.h" #include -#include -#include #include #include -#include using namespace edm; using namespace std; @@ -109,10 +102,7 @@ DTGeometryBuilder::plane(const DDFilteredView& fview, DTChamber* DTGeometryBuilder::buildChamber(const DDFilteredView& fview, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTChamberId detId(rawid); auto const& par = fview.extractParameters(); // par[0] r-phi dimension - different in different chambers @@ -130,10 +120,7 @@ DTSuperLayer* DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview, DTChamber* chamber, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTSuperLayerId slId(rawid); auto const& par = fview.extractParameters(); @@ -156,10 +143,7 @@ DTLayer* DTGeometryBuilder::buildLayer(DDFilteredView& fview, DTSuperLayer* sl, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTLayerId layId(rawid); auto const& par = fview.extractParameters(); @@ -195,12 +179,11 @@ DTGeometryBuilder::buildLayer(DDFilteredView& fview, void DTGeometryBuilder::build(DTGeometry& geom, - const cms::DDDetector* det, + const DDDetector* det, const MuonNumbering& num, const DDSpecParRefs& refs) { - - dd4hep::DetElement world = det->description()->world(); - DDFilteredView fview(det, world.volume()); + DDFilteredView fview(det, det->description()->worldVolume()); fview.mergedSpecifics(refs); + dtnum_ = make_unique(num.values()); buildGeometry(fview, geom, num); } diff --git a/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc b/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc deleted file mode 100644 index 26cde8315550d..0000000000000 --- a/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include "DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DataFormats/MuonDetId/interface/DTWireId.h" -#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" - -using namespace cms; - -DTNumberingScheme::DTNumberingScheme(MuonConstants& muonConstants) { - initMe(muonConstants); -} - -void -DTNumberingScheme::initMe(MuonConstants& muonConstants) { - int levelPart = muonConstants["level"]; - theRegionLevel = muonConstants["mb_region"]/levelPart; - theWheelLevel = muonConstants["mb_wheel"]/levelPart; - theStationLevel = muonConstants["mb_station"]/levelPart; - theSuperLayerLevel = muonConstants["mb_superlayer"]/levelPart; - theLayerLevel = muonConstants["mb_layer"]/levelPart; - theWireLevel = muonConstants["mb_wire"]/levelPart; -} - -int -DTNumberingScheme::getDetId(const MuonBaseNumber& num) const { - - int wire_id=0; - int layer_id=0; - int superlayer_id=0; - int sector_id=0; - int station_id=0; - int wheel_id=0; - - //decode significant barrel levels - decode(num, - wire_id, - layer_id, - superlayer_id, - sector_id, - station_id, - wheel_id); - - DTWireId id(wheel_id,station_id,sector_id,superlayer_id,layer_id,wire_id); - - return id.rawId(); -} - -void -DTNumberingScheme::decode(const MuonBaseNumber& num, - int& wire_id, - int& layer_id, - int& superlayer_id, - int& sector_id, - int& station_id, - int& wheel_id) const { - for (int level=1;level<=num.getLevels();level++) { - - //decode - if (level==theWheelLevel) { - const int copyno=num.getBaseNo(level); - wheel_id=copyno-2; - - } else if (level==theStationLevel) { - const int station_tag = num.getSuperNo(level); - const int copyno = num.getBaseNo(level); - station_id=station_tag; - sector_id=copyno+1; - - } else if (level==theSuperLayerLevel) { - const int copyno = num.getBaseNo(level); - superlayer_id = copyno + 1; - - } else if (level==theLayerLevel) { - const int copyno = num.getBaseNo(level); - layer_id=copyno+1; - - } else if (level==theWireLevel) { - const int copyno = num.getBaseNo(level); - wire_id = copyno+1; - } - } -} diff --git a/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h b/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h new file mode 100644 index 0000000000000..fbef879b0b07e --- /dev/null +++ b/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h @@ -0,0 +1,55 @@ +#ifndef GEOMETRY_MUON_NUMBERING_DT_NUMBERING_SCHEME_H +#define GEOMETRY_MUON_NUMBERING_DT_NUMBERING_SCHEME_H + +// -*- C++ -*- +// +// Package: Geometry/MuonNumbering +// Class: DTNumberingScheme +// +/**\class DTNumberingScheme + + Description: DTNumberingScheme converts the MuonBaseNumber + to a unit id for Muon Barrel + + Implementation: + DTNumberingScheme decode and getDetId are ported from + an original DTNumberingScheme class +*/ +// +// Original Author: Ianna Osborne +// Created: Thu, 21 Mar 2019 15:18:08 CET +// +// + +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" + +namespace cms { + class DTNumberingScheme { + public: + DTNumberingScheme(const MuonConstants&); + int baseNumberToUnitNumber(const MuonBaseNumber&); + int getDetId(const MuonBaseNumber&) const; + + private: + void initMe(const MuonConstants&); + const int get(const char*, const MuonConstants&) const; + // Decode MuonBaseNumber to id: no checking + void decode(const MuonBaseNumber& num, + int& wire_id, + int& layer_id, + int& superlayer_id, + int& sector_id, + int& station_id, + int& wheel_id + ) const; + + int theRegionLevel; + int theWheelLevel; + int theStationLevel; + int theSuperLayerLevel; + int theLayerLevel; + int theWireLevel; + }; +} + +#endif diff --git a/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h b/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h new file mode 100644 index 0000000000000..3839d1f38ea25 --- /dev/null +++ b/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h @@ -0,0 +1,51 @@ +#ifndef GEOMETRY_MUON_NUMBERING_MUON_NUMBERING_H +#define GEOMETRY_MUON_NUMBERING_MUON_NUMBERING_H + +// -*- C++ -*- +// +// Package: Geometry/MuonNumbering +// Class: MuonNumbering +// +/**\class MuonNumbering + + Description: MuonNumbering class to handle the conversion + to MuonBaseNumber from the ExpandedNodes history + + Implementation: + in the xml muon constant section one has to define + level, super and base constants (eg. 1000,100,1) and + the start value of the copy numbers (0 or 1) + +*/ +// +// Original Author: Ianna Osborne +// Created: Thu, 21 Mar 2019 15:32:36 CET +// + +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" + +#include +#include + +class MuonBaseNumber; + +namespace cms { + + using MuonConstants = std::unordered_map; + + class MuonNumbering { + public: + const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const; + const int get(const char*) const; + void put(std::string_view, int); + const MuonConstants& values() const { + return values_; + } + + private: + MuonConstants values_; + }; +} + +#endif diff --git a/Geometry/MuonNumbering/plugins/BuildFile.xml b/Geometry/MuonNumbering/plugins/BuildFile.xml index 3fbca5e759073..7159fea9f7c7e 100644 --- a/Geometry/MuonNumbering/plugins/BuildFile.xml +++ b/Geometry/MuonNumbering/plugins/BuildFile.xml @@ -4,7 +4,14 @@ - + + + + + + + + diff --git a/DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc similarity index 84% rename from DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc rename to Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc index 143df9132a03a..a42bcfbc54794 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc +++ b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc @@ -3,8 +3,8 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include @@ -28,9 +28,9 @@ DDTestMuonNumbering::analyze(const Event&, const EventSetup& iEventSetup) ESTransientHandle numbering; iEventSetup.get().get(numbering); - LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values.size(); + LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values().size(); LogVerbatim("Geometry").log([&numbering](auto& log) { - for(const auto& i: numbering->values) { + for(const auto& i: numbering->values()) { log << " " << i.first << " = " << i.second; log << '\n'; } diff --git a/DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc similarity index 87% rename from DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc rename to Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc index beb9b8933a795..ef065de6c94e9 100644 --- a/DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc +++ b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc @@ -23,9 +23,9 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" using namespace std; @@ -71,7 +71,7 @@ MuonNumberingESProducer::produce(const MuonNumberingRcd& iRecord) if(l.first == "OnlyForMuonNumbering") { for(const auto& k : it->second.numpars) { for(const auto& ik : k.second) { - product->values.emplace(k.first, static_cast(ik)); + product->put(k.first, static_cast(ik));//values.emplace(k.first, static_cast(ik)); } } } diff --git a/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc new file mode 100644 index 0000000000000..e16ca48728266 --- /dev/null +++ b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc @@ -0,0 +1,88 @@ +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" + +using namespace cms; + +DTNumberingScheme::DTNumberingScheme(const MuonConstants& muonConstants) { + initMe(muonConstants); +} + +void +DTNumberingScheme::initMe(const MuonConstants& muonConstants) { + int levelPart = get("level", muonConstants); + theRegionLevel = get("mb_region", muonConstants)/levelPart; + theWheelLevel = get("mb_wheel", muonConstants)/levelPart; + theStationLevel = get("mb_station", muonConstants)/levelPart; + theSuperLayerLevel = get("mb_superlayer", muonConstants)/levelPart; + theLayerLevel = get("mb_layer", muonConstants)/levelPart; + theWireLevel = get("mb_wire", muonConstants)/levelPart; +} + +int +DTNumberingScheme::getDetId(const MuonBaseNumber& num) const { + + int wire_id(0); + int layer_id(0); + int superlayer_id(0); + int sector_id(0); + int station_id(0); + int wheel_id(0); + + //decode significant barrel levels + decode(num, + wire_id, + layer_id, + superlayer_id, + sector_id, + station_id, + wheel_id); + + DTWireId id(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id); + + return id.rawId(); +} + +void +DTNumberingScheme::decode(const MuonBaseNumber& num, + int& wire_id, + int& layer_id, + int& superlayer_id, + int& sector_id, + int& station_id, + int& wheel_id) const { + for(int level = 1; level <= num.getLevels(); ++level) { + + //decode + if(level == theWheelLevel) { + const int copyno = num.getBaseNo(level); + wheel_id = copyno-2; + + } else if (level == theStationLevel) { + const int station_tag = num.getSuperNo(level); + const int copyno = num.getBaseNo(level); + station_id = station_tag; + sector_id = copyno + 1; + } else if(level == theSuperLayerLevel) { + const int copyno = num.getBaseNo(level); + superlayer_id = copyno + 1; + } else if (level == theLayerLevel) { + const int copyno = num.getBaseNo(level); + layer_id = copyno+1; + } else if(level == theWireLevel) { + const int copyno = num.getBaseNo(level); + wire_id = copyno + 1; + } + } +} + +const int +DTNumberingScheme::get(const char* key, + const MuonConstants& muonConstants) const { + int result(0); + auto const& it = muonConstants.find(key); + if(it != end(muonConstants)) + result = it->second; + return result; +} diff --git a/DetectorDescription/DDCMS/src/MuonNumbering.cc b/Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc similarity index 82% rename from DetectorDescription/DDCMS/src/MuonNumbering.cc rename to Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc index bdbbc39d9a4a0..cba1f8ddbf064 100644 --- a/DetectorDescription/DDCMS/src/MuonNumbering.cc +++ b/Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc @@ -1,4 +1,4 @@ -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -51,8 +51,17 @@ MuonNumbering::geoHistoryToBaseNumber(const cms::ExpandedNodes &nodes) const { const int MuonNumbering::get(const char* key) const { int result(0); - auto const& it = values.find(key); - if(it != end(values)) + auto const& it = values_.find(key); + if(it != end(values_)) result = it->second; return result; } + +void +MuonNumbering::put(string_view str, int num) { + values_.emplace(str, num); +} + +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(MuonNumbering); diff --git a/DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h b/Geometry/Records/interface/DDSpecParRegistryRcd.h similarity index 83% rename from DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h rename to Geometry/Records/interface/DDSpecParRegistryRcd.h index 5ad4630dfe045..a15fe98073c61 100644 --- a/DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h +++ b/Geometry/Records/interface/DDSpecParRegistryRcd.h @@ -2,7 +2,7 @@ #define GEOMETRY_RECORDS_DD_SPECPAR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "boost/mpl/vector.hpp" class DDSpecParRegistryRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h b/Geometry/Records/interface/DDVectorRegistryRcd.h similarity index 83% rename from DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h rename to Geometry/Records/interface/DDVectorRegistryRcd.h index e5b8cca57da2f..70cdf499ccb55 100644 --- a/DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h +++ b/Geometry/Records/interface/DDVectorRegistryRcd.h @@ -2,7 +2,7 @@ #define GEOMETRY_RECORDS_DD_VECTOR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "boost/mpl/vector.hpp" class DDVectorRegistryRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h b/Geometry/Records/interface/DetectorDescriptionRcd.h similarity index 100% rename from DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h rename to Geometry/Records/interface/DetectorDescriptionRcd.h diff --git a/DetectorDescription/DDCMS/interface/MuonGeometryRcd.h b/Geometry/Records/interface/MuonGeometryRcd.h similarity index 80% rename from DetectorDescription/DDCMS/interface/MuonGeometryRcd.h rename to Geometry/Records/interface/MuonGeometryRcd.h index 63d6ef086cc77..2596cabfe9b42 100644 --- a/DetectorDescription/DDCMS/interface/MuonGeometryRcd.h +++ b/Geometry/Records/interface/MuonGeometryRcd.h @@ -2,9 +2,9 @@ #define GEOMETRY_RECORDS_MUON_GEOMETRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" #include "Geometry/Records/interface/DTRecoGeometryRcd.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" diff --git a/DetectorDescription/DDCMS/interface/MuonNumberingRcd.h b/Geometry/Records/interface/MuonNumberingRcd.h similarity index 72% rename from DetectorDescription/DDCMS/interface/MuonNumberingRcd.h rename to Geometry/Records/interface/MuonNumberingRcd.h index 1e2f66738182d..7725b038cb943 100644 --- a/DetectorDescription/DDCMS/interface/MuonNumberingRcd.h +++ b/Geometry/Records/interface/MuonNumberingRcd.h @@ -2,8 +2,8 @@ #define GEOMETRY_RECORDS_MUON_NUMBERING_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "boost/mpl/vector.hpp" class MuonNumberingRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/Geometry/Records/src/DDSpecParRegistryRcd.cc b/Geometry/Records/src/DDSpecParRegistryRcd.cc new file mode 100644 index 0000000000000..ce2c0b433e08d --- /dev/null +++ b/Geometry/Records/src/DDSpecParRegistryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DDSpecParRegistryRcd); diff --git a/Geometry/Records/src/DDVectorRegistryRcd.cc b/Geometry/Records/src/DDVectorRegistryRcd.cc new file mode 100644 index 0000000000000..404c6b7d92226 --- /dev/null +++ b/Geometry/Records/src/DDVectorRegistryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DDVectorRegistryRcd); diff --git a/Geometry/Records/src/DetectorDescriptionRcd.cc b/Geometry/Records/src/DetectorDescriptionRcd.cc new file mode 100644 index 0000000000000..62fb1f2506ab0 --- /dev/null +++ b/Geometry/Records/src/DetectorDescriptionRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DetectorDescriptionRcd); diff --git a/Geometry/Records/src/ES_MuonDDDConstants.cc b/Geometry/Records/src/ES_MuonDDDConstants.cc deleted file mode 100644 index bf3f000614352..0000000000000 --- a/Geometry/Records/src/ES_MuonDDDConstants.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" -#include "FWCore/Utilities/interface/typelookup.h" - -TYPELOOKUP_DATA_REG(MuonDDDConstants); diff --git a/Geometry/Records/src/MuonGeometryRcd.cc b/Geometry/Records/src/MuonGeometryRcd.cc new file mode 100644 index 0000000000000..ce708b1216097 --- /dev/null +++ b/Geometry/Records/src/MuonGeometryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(MuonGeometryRcd); diff --git a/Geometry/Records/src/MuonNumberingRcd.cc b/Geometry/Records/src/MuonNumberingRcd.cc new file mode 100644 index 0000000000000..32a182a28d6ed --- /dev/null +++ b/Geometry/Records/src/MuonNumberingRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(MuonNumberingRcd); From 6c370d4d406ff4ed2c4cabd5ff3d896a4ff0eb1d Mon Sep 17 00:00:00 2001 From: Bibhuprasad Mahakud Date: Fri, 22 Mar 2019 04:52:20 +0100 Subject: [PATCH 239/686] first commit --- DataFormats/MuonReco/interface/Muon.h | 5 +- .../PatAlgos/plugins/PATMuonProducer.cc | 98 ++++++++++++++++++- .../PatAlgos/plugins/PATMuonProducer.h | 9 ++ .../producersLayer1/muonProducer_cfi.py | 1 + .../PatAlgos/python/slimming/miniAOD_tools.py | 7 +- 5 files changed, 114 insertions(+), 6 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index ea148da96a4e5..efea9c6477b3d 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -216,7 +216,10 @@ namespace reco { InTimeMuon = 1UL<<23, PFIsoVeryVeryTight = 1UL<<24, // reliso<0.05 MultiIsoLoose = 1UL<<25, // miniIso with ptRatio and ptRel - MultiIsoMedium = 1UL<<26 // miniIso with ptRatio and ptRel + MultiIsoMedium = 1UL<<26, // miniIso with ptRatio and ptRel + PuppiIsoLoose = 1UL<<27, + PuppiIsoMedium = 1UL<<28, + PuppiIsoTight = 1UL<<29 }; bool passed( unsigned int selection ) const { return (selectors_ & selection)==selection; } diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc index 7494279fb299e..37a2f0054bc00 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc @@ -154,11 +154,13 @@ PATMuonProducer::PATMuonProducer(const edm::ParameterSet & iConfig, PATMuonHeavy //for mini-isolation calculation computeMiniIso_ = iConfig.getParameter("computeMiniIso"); + computePuppiCombinedIso_ = iConfig.getParameter("computePuppiCombinedIso"); + miniIsoParams_ = iConfig.getParameter >("miniIsoParams"); if(computeMiniIso_ && miniIsoParams_.size() != 9){ throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n"; } - if(computeMiniIso_) + if(computeMiniIso_ || computePuppiCombinedIso_) pcToken_ = consumes(iConfig.getParameter("pfCandsForMiniIso")); // standard selectors @@ -302,7 +304,7 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu edm::Handle pc; - if(computeMiniIso_) + if(computeMiniIso_ || computePuppiCombinedIso_) iEvent.getByToken(pcToken_, pc); // get the ESHandle for the transient track builder, @@ -650,12 +652,24 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu double miniIsoValue = -1; if (computeMiniIso_){ // MiniIsolation working points + miniIsoValue = getRelMiniIsoPUCorrected(muon,*rho); + muon.setSelector(reco::Muon::MiniIsoLoose, miniIsoValue<0.40); muon.setSelector(reco::Muon::MiniIsoMedium, miniIsoValue<0.20); muon.setSelector(reco::Muon::MiniIsoTight, miniIsoValue<0.10); muon.setSelector(reco::Muon::MiniIsoVeryTight, miniIsoValue<0.05); } + + double puppiCombinedIsolationPAT = -1; + if(computePuppiCombinedIso_){ + + puppiCombinedIsolationPAT=puppiCombinedIsolation(muon, pc.product()); + muon.setSelector(reco::Muon::PuppiIsoLoose, puppiCombinedIsolationPAT<0.27); + muon.setSelector(reco::Muon::PuppiIsoMedium, puppiCombinedIsolationPAT<0.22); + muon.setSelector(reco::Muon::PuppiIsoTight, puppiCombinedIsolationPAT<0.12); + } + float jetPtRatio = 0.0; float jetPtRel = 0.0; float mva = 0.0; @@ -681,6 +695,8 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu // multi-isolation if (computeMiniIso_){ + + muon.setSelector(reco::Muon::MultiIsoLoose, miniIsoValue<0.40 && (muon.jetPtRatio() > 0.80 || muon.jetPtRel() > 7.2) ); muon.setSelector(reco::Muon::MultiIsoMedium, miniIsoValue<0.16 && (muon.jetPtRatio() > 0.76 || muon.jetPtRel() > 7.2) ); } @@ -815,6 +831,82 @@ double PATMuonProducer::getRelMiniIsoPUCorrected(const pat::Muon& muon, float rh return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.p4(), drcut, rho); } + +double PATMuonProducer::puppiCombinedIsolation(const pat::Muon& muon, const pat::PackedCandidateCollection *pc) +{ + double dR_threshold = 0.4; + double dR2_threshold = dR_threshold * dR_threshold; + double mix_fraction = 0.5; + enum particleType{ + CH = 0, + NH = 1, + PH = 2, + OTHER = 100000 + }; + double val_PuppiWithLep = 0.0; + double val_PuppiWithoutLep = 0.0; + + for(const auto & cand : *pc){//pat::pat::PackedCandidate loop start + + const particleType pType = + isChargedHadron( cand.pdgId() ) ? CH : + isNeutralHadron( cand.pdgId() ) ? NH : + isPhoton( cand.pdgId() ) ? PH : OTHER; + if( pType == OTHER ){ + if( cand.pdgId() != 1 && cand.pdgId() != 2 + && abs( cand.pdgId() ) != 11 + && abs( cand.pdgId() ) != 13){ + LogTrace("PATMuonProducer") <<"candidate with PDGID = " << cand.pdgId() << " is not CH/NH/PH/e/mu or 1/2 (and this is removed from isolation calculation)" << std::endl; + } + continue; + } + double d_eta = std::abs( cand.eta() - muon.eta() ); + if( d_eta > dR_threshold ) continue; + + double d_phi = std::abs(reco::deltaPhi(cand.phi(),muon.phi())); + if( d_phi > dR_threshold ) continue ; + + double dR2=reco::deltaR2(cand, muon); + if( dR2 > dR2_threshold ) continue; + if( pType == CH && dR2 < 0.0001*0.0001 ) continue; + if( pType == NH && dR2 < 0.01 *0.01 ) continue; + if( pType == PH && dR2 < 0.01 *0.01 ) continue; + val_PuppiWithLep += cand.pt() * cand.puppiWeight(); + val_PuppiWithoutLep += cand.pt() * cand.puppiWeightNoLep(); + + }//pat::pat::PackedCandidate loop end + + double reliso_Puppi_withLep = val_PuppiWithLep/muon.pt(); + double reliso_Puppi_withoutlep = val_PuppiWithoutLep/muon.pt(); + double reliso_Puppi_combined = mix_fraction * reliso_Puppi_withLep + ( 1.0 - mix_fraction) * reliso_Puppi_withoutlep; + return reliso_Puppi_combined; +} + +bool PATMuonProducer::isNeutralHadron( long pdgid ){ + const long id = abs( pdgid ); + if( id == 111 ) return true ; + if( id == 130 ) return true ; + if( id == 310 ) return true ; + if( id == 2112 ) return true ; + return false; + +} + +bool PATMuonProducer::isChargedHadron( long pdgid ){ + const long id = abs( pdgid ); + if( id == 211 ) return true ; + if( id == 321 ) return true ; + if( id == 999211 ) return true ; + if( id == 2212 ) return true ; + return false; +} + +bool PATMuonProducer::isPhoton( long pdgid ){ + const long id = abs( pdgid ); + if( id == 22 ) return true ; + return false; +} + // ParameterSet description for module void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) { @@ -857,6 +949,8 @@ void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions & descript // mini-iso iDesc.add("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation"); + iDesc.add("computePuppiCombinedIso",false)->setComment("whether or not to compute and store puppi combined isolation"); + iDesc.add("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))->setComment("collection to use to compute mini-iso"); iDesc.add >("miniIsoParams", std::vector())->setComment("mini-iso parameters to use for muons"); diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h index 1a2918b225c60..5a0fb40832069 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h @@ -101,6 +101,14 @@ namespace pat { void setMuonMiniIso(pat::Muon& aMuon, const pat::PackedCandidateCollection *pc); double getRelMiniIsoPUCorrected(const pat::Muon& muon, float rho); + double puppiCombinedIsolation(const pat::Muon& muon, const pat::PackedCandidateCollection *pc); + bool isNeutralHadron( long pdgid ); + bool isChargedHadron( long pdgid ); + bool isPhoton( long pdgid ); + + + + // embed various impact parameters with errors // embed high level selection void embedHighLevel( pat::Muon & aMuon, @@ -130,6 +138,7 @@ namespace pat { // for mini-iso calculation edm::EDGetTokenT pcToken_; bool computeMiniIso_; + bool computePuppiCombinedIso_; std::vector miniIsoParams_; double relMiniIsoPUCorrected_; diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py index cff50fb7c31a6..7fa0add40d8f2 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py @@ -102,6 +102,7 @@ pfCandsForMiniIso = cms.InputTag("packedPFCandidates"), miniIsoParams = cms.vdouble(0.05, 0.2, 10.0, 0.5, 0.0001, 0.01, 0.01, 0.01, 0.0), + computePuppiCombinedIso = cms.bool(False), # Standard Muon Selectors and Jet-related observables # Depends on MiniIsolation, so only works in miniaod # Don't forget to set flags properly in miniAOD_tools.py diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 204a0adcdc255..83701c89d400b 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -25,12 +25,13 @@ def miniAOD_customizeCommon(process): process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") - process.patMuons.computeMiniIso = cms.bool(True) - process.patMuons.computeMuonMVA = cms.bool(True) - process.patMuons.computeSoftMuonMVA = cms.bool(True) + process.patMuons.computeMiniIso = True + process.patMuons.computeMuonMVA = True + process.patMuons.computeSoftMuonMVA = True process.patMuons.addTriggerMatching = True + process.patMuons.computePuppiCombinedIso = True # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core From cd3c1fd41a2087c9ad5d20585c8771c11515353d Mon Sep 17 00:00:00 2001 From: wouf Date: Fri, 22 Mar 2019 13:47:26 +0300 Subject: [PATCH 240/686] Update PyquenHadronizer.cc Sorry, I found a minor bug --- GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc index 1ee7bc7fc66fa..c57d4c6905bc7 100644 --- a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc +++ b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc @@ -78,9 +78,9 @@ filterType_(pset.getUntrackedParameter("filterType","None")) } selector_ = HiGenEvtSelectorFactory::get(filterType_,pset); - HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); - int cm=1; - PYQVER(cm,cm,cm,cm); + HepMC::HEPEVT_Wrapper::set_max_number_entries(10000); + int cm=1, va, vb, vc; + PYQVER(cm,va,vb,vc); } From 17143b80c42bac578bcc5d11bcb7eb6050f94555 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 22 Mar 2019 12:05:35 +0100 Subject: [PATCH 241/686] Conditions settings for proton reco factorised to ctppsProtons_cff. --- RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py diff --git a/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py new file mode 100644 index 0000000000000..dd1f03a267ca1 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * + +# TODO: remove these lines once conditions data are available in DB +from CalibPPS.ESProducers.ctppsAlignment_cff import * +from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * +ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel From 391444df39ea3f3d8427557ef2b2b3861760372e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 22 Mar 2019 12:08:26 +0100 Subject: [PATCH 242/686] Use ctppsProtons_cff. --- PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py | 2 +- RecoCTPPS/Configuration/python/recoCTPPS_cff.py | 8 ++------ .../proton_reconstruction_MC/misalignment/template_cfg.py | 7 +------ .../proton_reconstruction_MC/resolution/template_cfg.py | 7 +------ 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 088e86299af8d..c5a048fc66d49 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -512,7 +512,7 @@ def miniAOD_customizeData(process): from PhysicsTools.PatAlgos.tools.coreTools import runOnData runOnData( process, outputModules = [] ) process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff") - process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") + process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") task = getPatAlgosToolsTask(process) task.add(process.ctppsLocalTrackLiteProducer) task.add(process.ctppsProtons) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py index fb1519a62eb77..735a13129458d 100644 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py @@ -6,14 +6,10 @@ from RecoCTPPS.PixelLocal.ctppsPixelLocalReconstruction_cff import * from RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff import ctppsLocalTrackLiteProducer -from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * -from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * +from RecoCTPPS.ProtonReconstruction.ctppsProtons_cff import * -# TODO: remove these lines once conditions data are available in DB -from CalibPPS.ESProducers.ctppsAlignment_cff import * -from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * -ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel +from Geometry.VeryForwardGeometry.geometryRPFromDB_cfi import * recoCTPPS = cms.Sequence( totemRPLocalReconstruction * diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py index b2b009e72fd93..5a8940d93e4ae 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -24,10 +24,6 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info and optics -# TODO: remove this line once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") - # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), @@ -64,9 +60,8 @@ process.ctppsLocalTrackLiteProducer.includePixels = False # proton reconstruction -process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py index 8e57872fab3f2..5071bff810342 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -24,10 +24,6 @@ # particle-data table process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -# supply LHC info and optics -# TODO: remove this line once data are available in CondDB -process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") - # random seeds process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), @@ -62,9 +58,8 @@ process.ctppsLocalTrackLiteProducer.includePixels = False # proton reconstruction -process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi") +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') -process.ctppsProtons.lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label # TODO: remove this line once data loaded from DB #process.ctppsProtons.fitVtxY = False # reconstruction validation From 0f502096131dccb7af3ca4ff8986cd37ecf2ce70 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 15:02:53 +0100 Subject: [PATCH 243/686] Added new parameter for OOT index selection --- .../plugins/CTPPSLocalTrackLiteProducer.cc | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 0bdbb2fe0c893..e3947eca416ed 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -49,12 +49,14 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> /// if true, this module will do nothing /// needed for consistency with CTPPS-less workflows bool doNothing_; + unsigned int timeSlice_; }; //---------------------------------------------------------------------------------------------------- CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSet& iConfig ) : - doNothing_( iConfig.getParameter( "doNothing" ) ) + doNothing_( iConfig.getParameter( "doNothing" ) ), + timeSlice_( iConfig.getParameter( "timeSlice" ) ) { if ( doNothing_ ) return; @@ -65,7 +67,7 @@ CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSe diamondTrackToken_ = consumes< edm::DetSetVector >( iConfig.getParameter("tagDiamondTrack") ); includePixels_ = iConfig.getParameter("includePixels"); - auto tagPixelTrack = iConfig.getParameter("tagPixelTrack"); + auto tagPixelTrack = iConfig.getParameter("tagPixelTrack"); if (not tagPixelTrack.label().empty()){ pixelTrackToken_ = consumes< edm::DetSetVector > (tagPixelTrack); } @@ -78,7 +80,7 @@ CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSe } //---------------------------------------------------------------------------------------------------- - + void CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& ) { @@ -87,7 +89,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& // prepare output std::unique_ptr< std::vector > pOut( new std::vector() ); - + //----- TOTEM strips // get input from Si strips @@ -112,7 +114,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& float roundedTySigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getTySigma()); float roundedChiSquaredOverNDF = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getChiSquaredOverNDF()); - pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, roundedTx, roundedTxSigma, roundedTy, roundedTySigma, + pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, roundedTx, roundedTxSigma, roundedTy, roundedTySigma, roundedChiSquaredOverNDF, CTPPSpixelLocalTrackReconstructionInfo::invalid, trk.getNumberOfPointsUsedForFit(),0,0 ); } } @@ -138,7 +140,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& float roundedT = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getT()); float roundedTSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getTSigma()); - pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, 0., 0., 0., 0., 0., + pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, 0., 0., 0., 0., 0., CTPPSpixelLocalTrackReconstructionInfo::invalid, trk.getNumOfPlanes(), roundedT, roundedTSigma); } } @@ -170,7 +172,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& float roundedTySigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getTySigma()); float roundedChiSquaredOverNDF = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getChiSquaredOverNDF()); - pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, roundedTx, roundedTxSigma, roundedTy, roundedTySigma, + pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, roundedTx, roundedTxSigma, roundedTy, roundedTySigma, roundedChiSquaredOverNDF, trk.getRecoInfo(), trk.getNumberOfPointsUsedForFit(),0.,0. ); } } @@ -184,7 +186,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& //---------------------------------------------------------------------------------------------------- -void +void CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& descr ) { edm::ParameterSetDescription desc; @@ -202,6 +204,8 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "input pixel detectors' local tracks collection to retrieve" ); desc.add( "doNothing", true ) // disable the module by default ->setComment( "disable the module" ); + desc.add( "timeSlice", 0 ) + ->setComment( "time slice to select for timing detectors" ); desc.add("pixelTrackTxMin",-10.0); desc.add("pixelTrackTxMax", 10.0); @@ -214,3 +218,4 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE( CTPPSLocalTrackLiteProducer ); + From 98e3c8ef94cc77a106ef3df472874685268d271e Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 15:03:17 +0100 Subject: [PATCH 244/686] Added OOT index selector in diamond tracks info recaster --- RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index e3947eca416ed..21f33af18715f 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -133,6 +133,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& const unsigned int rpId = rpv.detId(); for ( const auto& trk : rpv ) { if ( !trk.isValid() ) continue; + if ( trk.getOOTIndex() != timeSlice_ ) continue; float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getX0()); float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getX0Sigma()); float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0()); From 139e56be64785830f9283fe601e907c25868c94f Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 15:05:55 +0100 Subject: [PATCH 245/686] Using a signed selector to match getOOTIndex signature --- .../TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 21f33af18715f..bbcf10079e1df 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -49,14 +49,14 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> /// if true, this module will do nothing /// needed for consistency with CTPPS-less workflows bool doNothing_; - unsigned int timeSlice_; + int timeSlice_; }; //---------------------------------------------------------------------------------------------------- CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSet& iConfig ) : doNothing_( iConfig.getParameter( "doNothing" ) ), - timeSlice_( iConfig.getParameter( "timeSlice" ) ) + timeSlice_( iConfig.getParameter( "timeSlice" ) ) { if ( doNothing_ ) return; @@ -205,7 +205,7 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "input pixel detectors' local tracks collection to retrieve" ); desc.add( "doNothing", true ) // disable the module by default ->setComment( "disable the module" ); - desc.add( "timeSlice", 0 ) + desc.add( "timeSlice", 0 ) ->setComment( "time slice to select for timing detectors" ); desc.add("pixelTrackTxMin",-10.0); From 1847306aa71a91df24db72d54d35a982f5a6c431 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 22 Mar 2019 17:16:36 +0100 Subject: [PATCH 246/686] Add DT geometry validation --- .../DDCMS/interface/DDDetector.h | 6 +- DetectorDescription/DDCMS/src/DDDetector.cc | 9 +- .../RecoGeometry/BuildFile.xml | 13 - .../RecoGeometry/plugins/BuildFile.xml | 18 - .../DTGeometryBuilder/plugins/BuildFile.xml | 20 +- .../plugins/dd4hep}/DTGeometryBuilder.cc | 4 +- .../plugins/dd4hep}/DTGeometryBuilder.h | 0 .../plugins/dd4hep}/DTGeometryESProducer.cc | 2 +- .../plugins/dd4hep}/DTGeometryTest.cc | 2 +- .../plugins/dd4hep/DTGeometryValidate.cc | 364 ++++++++++++++++++ .../test/python/testDTGeometry.py | 0 .../test/python/testDTGeometryAndDump.py | 14 +- .../test/python/validateDTGeometry_cfg.py | 45 +++ 13 files changed, 453 insertions(+), 44 deletions(-) delete mode 100644 DetectorDescription/RecoGeometry/BuildFile.xml delete mode 100644 DetectorDescription/RecoGeometry/plugins/BuildFile.xml rename {DetectorDescription/RecoGeometry/src => Geometry/DTGeometryBuilder/plugins/dd4hep}/DTGeometryBuilder.cc (97%) rename {DetectorDescription/RecoGeometry/interface => Geometry/DTGeometryBuilder/plugins/dd4hep}/DTGeometryBuilder.h (100%) rename {DetectorDescription/RecoGeometry/plugins => Geometry/DTGeometryBuilder/plugins/dd4hep}/DTGeometryESProducer.cc (98%) rename {DetectorDescription/RecoGeometry/plugins => Geometry/DTGeometryBuilder/plugins/dd4hep}/DTGeometryTest.cc (98%) create mode 100644 Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc rename {DetectorDescription/RecoGeometry => Geometry/DTGeometryBuilder}/test/python/testDTGeometry.py (100%) rename {DetectorDescription/RecoGeometry => Geometry/DTGeometryBuilder}/test/python/testDTGeometryAndDump.py (81%) create mode 100644 Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py diff --git a/DetectorDescription/DDCMS/interface/DDDetector.h b/DetectorDescription/DDCMS/interface/DDDetector.h index 8c57817fde3ce..f4a95a4dae3a7 100644 --- a/DetectorDescription/DDCMS/interface/DDDetector.h +++ b/DetectorDescription/DDCMS/interface/DDDetector.h @@ -6,13 +6,15 @@ namespace dd4hep { class Detector; + class Volume; } namespace cms { class DDDetector { public: using Detector = dd4hep::Detector; - + using Volume = dd4hep::Volume; + explicit DDDetector(const std::string&, const std::string&); DDDetector() = delete; @@ -34,6 +36,8 @@ namespace cms { DDSpecParRegistry const& specpars() const { return m_specpars; } + + Volume worldVolume() const; private: diff --git a/DetectorDescription/DDCMS/src/DDDetector.cc b/DetectorDescription/DDCMS/src/DDDetector.cc index ba1a6f9bff54d..ca4e13e3a3415 100644 --- a/DetectorDescription/DDCMS/src/DDDetector.cc +++ b/DetectorDescription/DDCMS/src/DDDetector.cc @@ -1,5 +1,6 @@ #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DD4hep/Detector.h" +#include +#include #include @@ -28,3 +29,9 @@ DDDetector::process(const string& fileName) const char* files[] = { fileName.c_str(), nullptr }; m_description->apply( name.c_str(), 2, (char**)files ); } + +dd4hep::Volume +DDDetector::worldVolume() const { + assert(m_description); + return m_description->worldVolume(); +} diff --git a/DetectorDescription/RecoGeometry/BuildFile.xml b/DetectorDescription/RecoGeometry/BuildFile.xml deleted file mode 100644 index 9dc587ccec4b1..0000000000000 --- a/DetectorDescription/RecoGeometry/BuildFile.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/DetectorDescription/RecoGeometry/plugins/BuildFile.xml b/DetectorDescription/RecoGeometry/plugins/BuildFile.xml deleted file mode 100644 index c71643d4a52ae..0000000000000 --- a/DetectorDescription/RecoGeometry/plugins/BuildFile.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml index b185dc473bf8b..d3dcfbb72a873 100644 --- a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml +++ b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml @@ -2,15 +2,29 @@ - - - + + + + + + + + + + + + + + + + + diff --git a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc similarity index 97% rename from DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc index c76d7ed3f1320..ff3b0447d44d2 100644 --- a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc @@ -37,7 +37,7 @@ #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" -#include "DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h" +#include "DTGeometryBuilder.h" #include "DD4hep/Detector.h" #include @@ -182,7 +182,7 @@ DTGeometryBuilder::build(DTGeometry& geom, const DDDetector* det, const MuonNumbering& num, const DDSpecParRefs& refs) { - DDFilteredView fview(det, det->description()->worldVolume()); + DDFilteredView fview(det, det->worldVolume()); fview.mergedSpecifics(refs); dtnum_ = make_unique(num.values()); buildGeometry(fview, geom, num); diff --git a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h similarity index 100% rename from DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc similarity index 98% rename from DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc index b1dc5fa99822d..72579341f126f 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc @@ -46,7 +46,7 @@ #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h" +#include "DTGeometryBuilder.h" #include #include diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc similarity index 98% rename from DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc index fb1d21590ed75..dd353c831b7d9 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc @@ -4,7 +4,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" #include #include diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc new file mode 100644 index 0000000000000..2dce7997fd93c --- /dev/null +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc @@ -0,0 +1,364 @@ +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/DTGeometry/interface/DTLayer.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" + +#include "Fireworks/Core/interface/FWGeometry.h" + +#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include +#include + +#include +#include +#include +#include +#include + +using namespace std; + +template +typename enable_if::is_integer, bool>::type + almost_equal(T x, T y, int ulp) +{ + // the machine epsilon has to be scaled to the magnitude of the values used + // and multiplied by the desired precision in ULPs (units in the last place) + return abs(x-y) <= numeric_limits::epsilon() * abs(x+y) * ulp + // unless the result is subnormal + || abs(x-y) < numeric_limits::min(); +} + +using namespace edm; + +class DTGeometryValidate : public one::EDAnalyzer<> +{ +public: + explicit DTGeometryValidate(const ParameterSet&); + ~DTGeometryValidate() override {} + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + void validateDTChamberGeometry(); + void validateDTLayerGeometry(); + + void compareTransform(const GlobalPoint&, const TGeoMatrix*); + + void compareShape(const GeomDet*, const float*); + + double getDistance(const GlobalPoint&, const GlobalPoint&); + double getDiff(const double, const double); + + void makeHistograms(const char*); + void makeHistogram(const string&, vector&); + + string infileName_; + string outfileName_; + + edm::ESHandle dtGeometry_; + + FWGeometry fwGeometry_; + + TFile* outFile_; + + vector globalDistances_; + vector topWidths_; + vector bottomWidths_; + vector lengths_; + vector thicknesses_; + + void clearData() { + globalDistances_.clear(); + topWidths_.clear(); + bottomWidths_.clear(); + lengths_.clear(); + thicknesses_.clear(); + } + + int tolerance_ = 2; +}; + + +DTGeometryValidate::DTGeometryValidate(const edm::ParameterSet& iConfig) + : infileName_(iConfig.getUntrackedParameter("infileName")), + outfileName_(iConfig.getUntrackedParameter("outfileName")) +{ + fwGeometry_.loadMap(infileName_.c_str()); + outFile_ = new TFile(outfileName_.c_str(), "RECREATE"); +} + +void +DTGeometryValidate::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) +{ + eventSetup.get().get(dtGeometry_); + + if(dtGeometry_.isValid()) { + LogVerbatim("DTGeometry") << "Validating DT chamber geometry"; + validateDTChamberGeometry(); + + LogVerbatim("DTGeometry") <<"Validating DT layer geometry"; + validateDTLayerGeometry(); + } + else + LogVerbatim("DTGeometry") << "Invalid DT geometry"; +} + +void +DTGeometryValidate::validateDTChamberGeometry() { + + clearData(); + + for(auto const& it : dtGeometry_->chambers()) { + DTChamberId chId = it->id(); + GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0)); + + const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId()); + + if(!matrix) { + LogVerbatim("DTGeometry") << "Failed to get matrix of DT chamber with detid: " + << chId.rawId(); + continue; + } + + compareTransform(gp, matrix); + + auto const& shape = fwGeometry_.getShapePars(chId.rawId()); + + if(!shape) { + LogVerbatim("DTGeometry") << "Failed to get shape of DT chamber with detid: " + << chId.rawId(); + continue; + } + + compareShape(it, shape); + } + + makeHistograms("DT Chamber"); +} + +void +DTGeometryValidate::validateDTLayerGeometry() { + + clearData(); + + vector wire_positions(172000, 0.); + + for(auto const& it : dtGeometry_->layers()) { + DTLayerId layerId = it->id(); + GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0)); + + const TGeoMatrix* matrix = fwGeometry_.getMatrix(layerId.rawId()); + + if (!matrix) { + LogVerbatim("DTGeometry") << "Failed to get matrix of DT layer with detid: " + << layerId.rawId(); + continue; + } + + compareTransform(gp, matrix); + + auto const& shape = fwGeometry_.getShapePars(layerId.rawId()); + + if(!shape) { + LogVerbatim("DTGeometry") << "Failed to get shape of DT layer with detid: " + << layerId.rawId(); + continue; + } + + compareShape(it, shape); + + auto const& parameters = fwGeometry_.getParameters(layerId.rawId()); + + if(parameters == nullptr) { + LogVerbatim("DTGeometry") << "Parameters empty for DT layer with detid: " + << layerId.rawId(); + continue; + } + + double width = it->surface().bounds().width(); + assert(width == parameters[6]); + + double thickness = it->surface().bounds().thickness(); + assert(thickness == parameters[7]); + + double length = it->surface().bounds().length(); + assert(length == parameters[8]); + + int firstChannel = it->specificTopology().firstChannel(); + assert(firstChannel == parameters[3]); + + int lastChannel = it->specificTopology().lastChannel(); + int nChannels = parameters[5]; + assert(nChannels == (lastChannel-firstChannel)+1); + + for(int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) { + double localX1 = it->specificTopology().wirePosition(wireN); + double localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0]; + wire_positions.push_back(getDiff(localX1, localX2)); + } + } + + makeHistogram("DT Layer Wire localX", wire_positions); + makeHistograms("DT Layer"); +} + +void +DTGeometryValidate::compareTransform(const GlobalPoint& gp, + const TGeoMatrix* matrix) +{ + double local[3] = { 0.0, 0.0, 0.0 }; + double global[3]; + + matrix->LocalToMaster(local, global); + + double distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp); + globalDistances_.push_back(distance); +} + +void +DTGeometryValidate::compareShape(const GeomDet* det, const float* shape) +{ + float shapeTopWidth; + float shapeBottomWidth; + float shapeLength; + float shapeThickness; + + if(shape[0] == 1) { + shapeTopWidth = shape[2]; + shapeBottomWidth = shape[1]; + shapeLength = shape[4]; + shapeThickness = shape[3]; + } + else if(shape[0] == 2) { + shapeTopWidth = shape[1]; + shapeBottomWidth = shape[1]; + shapeLength = shape[2]; + shapeThickness = shape[3]; + } + else { + LogVerbatim("DTGeometry") << "Failed to get box or trapezoid from shape"; + return; + } + + float topWidth, bottomWidth; + float length, thickness; + + const Bounds* bounds = &(det->surface().bounds()); + + if(const TrapezoidalPlaneBounds* tpbs = dynamic_cast(bounds)) + { + array const & ps = tpbs->parameters(); + + assert(ps.size() == 4); + + bottomWidth = ps[0]; + topWidth = ps[1]; + thickness = ps[2]; + length = ps[3]; + } + else if((dynamic_cast(bounds))) { + length = det->surface().bounds().length()*0.5; + topWidth = det->surface().bounds().width()*0.5; + bottomWidth = topWidth; + thickness = det->surface().bounds().thickness()*0.5; + } + else { + LogVerbatim("DTGeometry") << "Failed to get bounds"; + return; + } + topWidths_.push_back(fabs(shapeTopWidth - topWidth)); + bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth)); + lengths_.push_back(fabs(shapeLength - length)); + thicknesses_.push_back(fabs(shapeThickness - thickness)); + + return; +} + +double +DTGeometryValidate::getDistance(const GlobalPoint& p1, const GlobalPoint& p2) +{ + return sqrt((p1.x()-p2.x())*(p1.x()-p2.x())+ + (p1.y()-p2.y())*(p1.y()-p2.y())+ + (p1.z()-p2.z())*(p1.z()-p2.z())); +} + + +double +DTGeometryValidate::getDiff(const double val1, const double val2) { + if(almost_equal(val1, val2, tolerance_)) + return double(0.0); + else + return (val1 - val2); +} + +void +DTGeometryValidate::makeHistograms(const char* detector) +{ + outFile_->cd(); + + string d(detector); + + string gdn = d+": distance between points in global coordinates"; + makeHistogram(gdn, globalDistances_); + + string twn = d + ": absolute difference between top widths (along X)"; + makeHistogram(twn, topWidths_); + + string bwn = d + ": absolute difference between bottom widths (along X)"; + makeHistogram(bwn, bottomWidths_); + + string ln = d + ": absolute difference between lengths (along Y)"; + makeHistogram(ln, lengths_); + + string tn = d + ": absolute difference between thicknesses (along Z)"; + makeHistogram(tn, thicknesses_); +} + +void +DTGeometryValidate::makeHistogram(const string& name, vector& data) +{ + if(data.empty()) + return; + + vector::iterator it; + + it = min_element(data.begin(), data.end()); + double minE = *it; + + it = max_element(data.begin(), data.end()); + double maxE = *it; + + vector::iterator itEnd = data.end(); + + TH1D hist(name.c_str(), name.c_str(), 100, minE*(1+0.10), maxE*(1+0.10)); + + for( it = data.begin(); it != itEnd; ++it ) + hist.Fill(*it); + + hist.GetXaxis()->SetTitle("[cm]"); + hist.Write(); +} + +void +DTGeometryValidate::beginJob() { + outFile_->cd(); +} + +void +DTGeometryValidate::endJob() { + LogVerbatim("DTGeometry") << "Done."; + LogVerbatim("DTGeometry") << "Results written to "<< outfileName_; + outFile_->Close(); +} + +DEFINE_FWK_MODULE(DTGeometryValidate); diff --git a/DetectorDescription/RecoGeometry/test/python/testDTGeometry.py b/Geometry/DTGeometryBuilder/test/python/testDTGeometry.py similarity index 100% rename from DetectorDescription/RecoGeometry/test/python/testDTGeometry.py rename to Geometry/DTGeometryBuilder/test/python/testDTGeometry.py diff --git a/DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py similarity index 81% rename from DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py rename to Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py index c33b0a8393d1d..8ae48c14f5bf8 100644 --- a/DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py +++ b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py @@ -1,6 +1,12 @@ import FWCore.ParameterSet.Config as cms process = cms.Process("DTGeometryTest") +process.add_(cms.Service("InitRootHandlers", ResetRootErrHandler = cms.untracked.bool(False))) +##process.add_(cms.ESProducer("FWTGeoRecoGeometryESProducer", +## Tracker = cms.untracked.bool(False), +## Muon = cms.untracked.bool(True), +## Calo = cms.untracked.bool(False), +## Timing = cms.untracked.bool(False))) process.source = cms.Source("EmptySource") process.maxEvents = cms.untracked.PSet( @@ -67,10 +73,10 @@ ) process.FWTGeoRecoGeometryESProducer = cms.ESProducer("FWTGeoRecoGeometryESProducer", - Tracker = cms.untracked.bool(False), - Muon = cms.untracked.bool(True), - Calo = cms.untracked.bool(False), - Timing = cms.untracked.bool(False)) + Tracker = cms.untracked.bool(False), + Muon = cms.untracked.bool(True), + Calo = cms.untracked.bool(False), + Timing = cms.untracked.bool(False)) process.dump = cms.EDAnalyzer("DumpFWRecoGeometry", level = cms.untracked.int32(1), diff --git a/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py new file mode 100644 index 0000000000000..d023af7948461 --- /dev/null +++ b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py @@ -0,0 +1,45 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('VALID') + +process.source = cms.Source('EmptySource') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml'), + appendToDataLabel = cms.string('MUON') + ) + +process.DTGeometryESProducer = cms.ESProducer("DTGeometryESProducer", + DDDetector = cms.ESInputTag('MUON'), + appendToDataLabel = cms.string(''), + applyAlignment = cms.bool(False), + alignmentsLabel = cms.string(''), + attribute = cms.string('MuStructure'), + value = cms.string('MuonBarrelDT'), + fromDDD = cms.bool(True) + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MUON') + ) + +process.MuonNumberingESProducer = cms.ESProducer("MuonNumberingESProducer", + label = cms.string('MUON'), + key = cms.string('MuonCommonNumbering') + ) + +# +# Note: Please, download the geometry file from a location +# specified by Fireworks/Geometry/data/download.url +# +# For example: wget http://cmsdoc.cern.ch/cms/data/CMSSW/Fireworks/Geometry/data/v4/cmsGeom10.root +# +process.valid = cms.EDAnalyzer("DTGeometryValidate", + infileName = cms.untracked.string('cmsGeom10.root'), + outfileName = cms.untracked.string('validateDTGeometry.root') + ) + +process.p = cms.Path(process.valid) From 94b6c1b01446b7e51258ed89411dd154ed724310 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 22 Mar 2019 17:28:36 +0100 Subject: [PATCH 247/686] Use emplace_back --- .../DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc index 2dce7997fd93c..bef88c52f56c5 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc @@ -151,7 +151,7 @@ DTGeometryValidate::validateDTLayerGeometry() { clearData(); - vector wire_positions(172000, 0.); + vector wire_positions; for(auto const& it : dtGeometry_->layers()) { DTLayerId layerId = it->id(); @@ -204,7 +204,7 @@ DTGeometryValidate::validateDTLayerGeometry() { for(int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) { double localX1 = it->specificTopology().wirePosition(wireN); double localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0]; - wire_positions.push_back(getDiff(localX1, localX2)); + wire_positions.emplace_back(getDiff(localX1, localX2)); } } From 417adf327f7cbb118e2af62f94f90b3ea9b138bc Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 22 Mar 2019 17:52:23 +0100 Subject: [PATCH 248/686] Correct include --- DetectorDescription/DDCMS/src/ES_DDDetector.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DetectorDescription/DDCMS/src/ES_DDDetector.cc b/DetectorDescription/DDCMS/src/ES_DDDetector.cc index a1b66effb29dd..368276b9605e5 100644 --- a/DetectorDescription/DDCMS/src/ES_DDDetector.cc +++ b/DetectorDescription/DDCMS/src/ES_DDDetector.cc @@ -1,9 +1,8 @@ #include "FWCore/Utilities/interface/typelookup.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "FWCore/Framework/interface/data_default_record_trait.h" using namespace cms; From ecf03186c7996bcfb951c44d5aaa2c02163893f2 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 22 Mar 2019 18:07:32 +0100 Subject: [PATCH 249/686] Correct includes --- DetectorDescription/DDCMS/plugins/DDCMSDetector.cc | 4 ++-- DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc | 2 +- .../DDCMS/plugins/DDSpecParRegistryESProducer.cc | 4 ++-- DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc | 2 +- DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc | 2 +- DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc | 4 ++-- .../DDCMS/plugins/DDVectorRegistryESProducer.cc | 4 ++-- .../DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc | 3 ++- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc index 0c3ba5d23609a..b5d5f9689dfd6 100644 --- a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc +++ b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc @@ -5,9 +5,9 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc index d2f4e5bac4a0f..403d083b264e8 100644 --- a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc @@ -24,7 +24,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc index f9f35d581c4c1..52a9b69a17256 100644 --- a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc @@ -24,9 +24,9 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc index 93b5e0cf81e84..44c4c2db261ad 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc index 15de51ddb9ec0..c57c49e0fda94 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc index dc6bbc78ebd68..6e530d5e324b6 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc @@ -3,9 +3,9 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include "DetectorDescription/DDCMS/interface/DDVolumeProcessor.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc index 1e04dff6dd48d..dcbe927e379ca 100644 --- a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc @@ -25,9 +25,9 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc index ff3b0447d44d2..fa000cdf74660 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc @@ -182,7 +182,8 @@ DTGeometryBuilder::build(DTGeometry& geom, const DDDetector* det, const MuonNumbering& num, const DDSpecParRefs& refs) { - DDFilteredView fview(det, det->worldVolume()); + Volume top = det->worldVolume(); + DDFilteredView fview(det, top); fview.mergedSpecifics(refs); dtnum_ = make_unique(num.values()); buildGeometry(fview, geom, num); From f8e334019ba39c0dc0bbaaa39d7792561b79fd59 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 22 Mar 2019 19:57:48 +0100 Subject: [PATCH 250/686] Enable test beam setup to dump geometry for cmsShow --- .../data/TB181/Oct181/hgcal.xml | 10 +++- .../plugins/DDHGCalTBModuleX.cc | 57 ++++++++++--------- .../plugins/DDHGCalTBModuleX.h | 3 + 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml index 27b660ac9fed0..14fc0964acb48 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml @@ -70,7 +70,11 @@ - + + + + + @@ -147,11 +151,11 @@ - + - + diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc index 7601a72aaf778..b7daab63abd6d 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc @@ -3,12 +3,10 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/GeantUnits.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDLogicalPart.h" -#include "DetectorDescription/Core/interface/DDSolid.h" -#include "DetectorDescription/Core/interface/DDMaterial.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDutils.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h" //#define EDM_ML_DEBUG @@ -113,7 +111,8 @@ void DDHGCalTBModuleX::initialize(const DDNumericArguments & nArgs, idNameSpace_ = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: NameSpace " - << idNameSpace_; + << idNameSpace_ << " Parent Name " + << parent().name().name(); #endif } @@ -147,7 +146,7 @@ void DDHGCalTBModuleX::constructBlocks(const DDLogicalPart& parent, double zi(zMinBlock_); for (unsigned int i=0; i 0) { positionSensitive(zz, copy, layerSense_[ly], rMax_, maxModule_[ly], - ignoreCenter, module, cpv); + ignoreCenter, name, matter, module, cpv); } ++copyNumber_[ii]; zi = zo; @@ -261,7 +260,9 @@ void DDHGCalTBModuleX::constructLayers(int block, int firstLayer, void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, double rout, int ncrMax, - bool ignoreCenter, + bool ignoreCenter, + const std::string& nameIn, + const DDMaterial& matter, const DDLogicalPart& glog, DDCompactView& cpv) { double ww = (waferW_+waferGap_); @@ -272,10 +273,12 @@ void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, int nrow = (int)(rout/(ww*tan30deg_)) + 1; #ifdef EDM_ML_DEBUG int incm(0), inrm(0); - edm::LogVerbatim("HGCalGeom") << glog.ddname() << " rout " << rout << " Row " - << nrow << " column " << ncol << " ncrMax " - << ncrMax << " Z " << zpos << " copy " - << copyIn << " Center " << ignoreCenter; + edm::LogVerbatim("HGCalGeom") << glog.ddname() << " Copy " << copyIn + << " Type " << type << " rout " << rout + << " Row " << nrow << " column " << ncol + << " ncrMax " << ncrMax << " Z " << zpos + << " Center " << ignoreCenter << " name " + << nameIn << " matter " << matter.name(); int kount(0); #endif if (ncrMax >= 0) { @@ -310,13 +313,16 @@ void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, if (nr < 0) copy += 100000; DDName name, nameX; if (type == 1) { - nameX = DDName(DDSplit(covers_[type-1]).first, - DDSplit(covers_[type-1]).second); - cpv.position(nameX, glog.ddname(), copyIn, tran, rotation); + nameX = DDName(DDSplit(covers_[0]).first, + DDSplit(covers_[0]).second); + std::string name0 = nameIn + "M" + std::to_string(copy); + DDLogicalPart glog1 = DDLogicalPart(DDName(name0, idNameSpace_), + matter, nameX); + cpv.position(glog1.ddname(),glog.ddname(),copyIn,tran,rotation); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << nameX - << " number " << copyIn - << " positioned in " + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " + << glog1.ddname() << " number " + << copyIn << " positioned in " << glog.ddname() << " at " << tran << " with " << rotation; #endif @@ -324,12 +330,12 @@ void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, DDName(DDSplit(wafer_[0]).first, DDSplit(wafer_[0]).second) : DDName(DDSplit(wafer_[1]).first, DDSplit(wafer_[1]).second); DDTranslation tran1; - cpv.position(name, nameX, copy, tran1, rotation); + cpv.position(name, glog1.ddname(), copy, tran1, rotation); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name << " number " << copy << " positioned in " - << nameX << " at " << tran1 + << glog1.ddname() << " at " << tran1 << " with " << rotation; #endif if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); @@ -337,14 +343,13 @@ void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, name = DDName(DDSplit(covers_[type-1]).first, DDSplit(covers_[type-1]).second); copy += copyIn*1000000; - nameX = glog.ddname(); cpv.position(name, glog.ddname(), copy, tran, rotation); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name - << " number " << copy - << " positioned in " - << nameX << " at " << tran - << " with " << rotation; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name + << " number " << copy + << " positioned in " + << glog.ddname() << " at " << tran + << " with " << rotation; #endif } #ifdef EDM_ML_DEBUG diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h index ae96246d8dc8a..178e4f6adadb9 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h @@ -5,6 +5,8 @@ #include #include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDMaterial.h" #include class DDHGCalTBModuleX : public DDAlgorithm { @@ -29,6 +31,7 @@ class DDHGCalTBModuleX : public DDAlgorithm { const DDLogicalPart&, DDCompactView&); void positionSensitive(double zpos, int copyIn, int type, double rmax, int ncrMax, bool ignoreCenter, + const std::string&, const DDMaterial&, const DDLogicalPart&, DDCompactView& cpv); private: From 9d1413c0d0ab460d33b87a4f2b58344b9de1d13c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 22 Mar 2019 20:03:39 +0100 Subject: [PATCH 251/686] Add the changes to hgcalHE --- Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml index 42c2db4aed907..a29744a1cf83c 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml @@ -49,7 +49,7 @@ HEPCB, HEKapton, HECuWShield, HECuShield, HEPCBShield, HEFeAbsorber, - HECuHeatShield, HESensitive, HEFeBox, + HECuHeatShield, HESiliconSensitive, HEFeBox, HEAirGap1, HEAirGap2, HEAirGap3, HEAirGap4, HEAirGap5, HEAirGap6, HEAirGap7, HEAirGap8, HEAirGap9, @@ -60,7 +60,7 @@ HEAirGap20, HEAirGap21, HEPCB, HEKapton, HECuWShield, HECuShield, HEPCBShield, HEFeAbsorber, - HECuHeatShield, HESensitive, HEFeBox, + HECuHeatShield, HESiliconSensitive, HEFeBox, HEAirGap1, HEAirGap2, HEAirGap3, HEAirGap4, HEAirGap5, HEAirGap6, HEAirGap7, HEAirGap8, HEAirGap9, From e99fc64be39a549b742eba3ccd4961914e9319b0 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 22 Mar 2019 22:33:10 +0100 Subject: [PATCH 252/686] Correct includes --- DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc | 2 +- DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc | 2 +- DetectorDescription/DDCMS/plugins/DDTestVectors.cc | 2 +- Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc b/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc index fcb95e4385880..0c4a6674acb93 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include diff --git a/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc b/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc index c23d329491680..adae6f80da360 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include diff --git a/DetectorDescription/DDCMS/plugins/DDTestVectors.cc b/DetectorDescription/DDCMS/plugins/DDTestVectors.cc index 3537511210be7..e8dcdd00fa220 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestVectors.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestVectors.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h index 1f17cc77a77dc..b059baa913a4c 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h @@ -19,7 +19,7 @@ namespace cms { class DDDetector; class DDFilteredView; - struct MuonNumbering; + class MuonNumbering; struct DDSpecPar; class DTGeometryBuilder { From 61a19b6d791f9074ad66d63ab7abba6ffdbd4454 Mon Sep 17 00:00:00 2001 From: Bibhuprasad Mahakud Date: Sat, 23 Mar 2019 05:17:41 +0100 Subject: [PATCH 253/686] function definitions organized --- .../PatAlgos/plugins/PATMuonProducer.cc | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc index 37a2f0054bc00..6a61e358e5653 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc @@ -883,28 +883,15 @@ double PATMuonProducer::puppiCombinedIsolation(const pat::Muon& muon, const pat: } bool PATMuonProducer::isNeutralHadron( long pdgid ){ - const long id = abs( pdgid ); - if( id == 111 ) return true ; - if( id == 130 ) return true ; - if( id == 310 ) return true ; - if( id == 2112 ) return true ; - return false; - + return std::abs(pdgid) == 130; } bool PATMuonProducer::isChargedHadron( long pdgid ){ - const long id = abs( pdgid ); - if( id == 211 ) return true ; - if( id == 321 ) return true ; - if( id == 999211 ) return true ; - if( id == 2212 ) return true ; - return false; + return std::abs(pdgid) == 211; } bool PATMuonProducer::isPhoton( long pdgid ){ - const long id = abs( pdgid ); - if( id == 22 ) return true ; - return false; + return pdgid==22; } // ParameterSet description for module From 0f9d47addcb83783a7a4a405ca17f0be813ff2ee Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sun, 24 Mar 2019 23:23:51 +0100 Subject: [PATCH 254/686] Protect against bad inputs in EnergyUncertaintyElectronSpecific ASAN reported out of bounds reads in calls to member functions. We now report if an input value would result in bad array reads. In addition, moved the arrays from the stack to a compile time created memory location. --- .../src/EnergyUncertaintyElectronSpecific.cc | 879 +++++++++--------- 1 file changed, 451 insertions(+), 428 deletions(-) diff --git a/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc b/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc index 5cf205eb2f2a1..5b005cb5975cb 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc @@ -27,136 +27,123 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde double et = energy/cosh(eta); - const int nBinsEta=5; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.4, 0.8, 1.5, 2.0, 2.5}; - - const int nBinsBrem=6; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.0, 1.1, 1.2, 1.3, 1.5, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - - par0[0][0]=0.00567891; - par1[0][0]=0.238685; - par2[0][0]=2.12035; - - par0[0][1]=0.0065673; - par1[0][1]=0.193642; - par2[0][1]=3.41493; - - par0[0][2]=0.00574742; - par1[0][2]=0.249171; - par2[0][2]=1.7401; - - par0[0][3]=0.00542964; - par1[0][3]=0.259997; - par2[0][3]=1.46234; - - par0[0][4]=0.00523293; - par1[0][4]=0.310505; - par2[0][4]=0.233226; - - par0[0][5]=0.00547518; - par1[0][5]=0.390506; - par2[0][5]=-2.78168; - - par0[1][0]=0.00552517; - par1[1][0]=0.288736; - par2[1][0]=1.30552; - - par0[1][1]=0.00611188; - par1[1][1]=0.312303; - par2[1][1]=0.137905; - - par0[1][2]=0.0062729; - par1[1][2]=0.294717; - par2[1][2]=0.653793; - - par0[1][3]=0.00574846; - par1[1][3]=0.294491; - par2[1][3]=0.790746; - - par0[1][4]=0.00447373; - par1[1][4]=0.379178; - par2[1][4]=-1.42584; - - par0[1][5]=0.00595789; - par1[1][5]=0.38164; - par2[1][5]=-2.34653; - - par0[2][0]=0.00356679; - par1[2][0]=0.456456; - par2[2][0]=0.610716; - - par0[2][1]=0.00503827; - par1[2][1]=0.394912; - par2[2][1]=0.778879; - - par0[2][2]=0.00328016; - par1[2][2]=0.541713; - par2[2][2]=-1.58577; - - par0[2][3]=0.00592303; - par1[2][3]=0.401744; - par2[2][3]=1.45098; - - par0[2][4]=0.00512479; - par1[2][4]=0.483151; - par2[2][4]=-0.0985911; - - par0[2][5]=0.00484166; - par1[2][5]=0.657995; - par2[2][5]=-3.47167; - - par0[3][0]=0.0109195; - par1[3][0]=1.13803; - par2[3][0]=-3.48281; - - par0[3][1]=0.0102361; - par1[3][1]=1.39866; - par2[3][1]=-6.4736; - - par0[3][2]=0.0101576; - par1[3][2]=1.51353; - par2[3][2]=-8.03308; - - par0[3][3]=0.0120683; - par1[3][3]=1.48587; - par2[3][3]=-7.55974; - - par0[3][4]=0.0155326; - par1[3][4]=1.49732; - par2[3][4]=-7.98843; - - par0[3][5]=0.0225035; - par1[3][5]=1.82363; - par2[3][5]=-10.1027; - - par0[4][0]=0.0109632; - par1[4][0]=0.458212; - par2[4][0]=0.995183; - - par0[4][1]=0.0103342; - par1[4][1]=0.628761; - par2[4][1]=-2.42889; - - par0[4][2]=0.0103486; - par1[4][2]=0.659144; - par2[4][2]=-2.14073; - - par0[4][3]=0.00862762; - par1[4][3]=0.929563; - par2[4][3]=-6.27768; - - par0[4][4]=0.0111448; - par1[4][4]=1.06724; - par2[4][4]=-7.68512; - - par0[4][5]=0.0146648; - par1[4][5]=1.6427; - par2[4][5]=-13.3504; - + constexpr int nBinsEta=5; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.4, 0.8, 1.5, 2.0, 2.5}; + + constexpr int nBinsBrem=6; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.0, 1.1, 1.2, 1.3, 1.5, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem] = { + {0.00567891, + 0.0065673, + 0.00574742, + 0.00542964, + 0.00523293, + 0.00547518}, + + {0.00552517, + 0.00611188, + 0.0062729, + 0.00574846, + 0.00447373, + 0.00595789}, + + {0.00356679, + 0.00503827, + 0.00328016, + 0.00592303, + 0.00512479, + 0.00484166}, + + {0.0109195, + 0.0102361, + 0.0101576, + 0.0120683, + 0.0155326, + 0.0225035}, + + {0.0109632, + 0.0103342, + 0.0103486, + 0.00862762, + 0.0111448, + 0.0146648}}; + + static_assert(par0[0][0] == 0.00567891f); + static_assert(par0[0][1] == 0.0065673f); + static_assert(par0[1][3] == 0.00574846f); + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.238685, + 0.193642, + 0.249171, + 0.259997, + 0.310505, + 0.390506}, + + {0.288736, + 0.312303, + 0.294717, + 0.294491, + 0.379178, + 0.38164}, + + {0.456456, + 0.394912, + 0.541713, + 0.401744, + 0.483151, + 0.657995}, + + {1.13803, + 1.39866, + 1.51353, + 1.48587, + 1.49732, + 1.82363}, + + {0.458212, + 0.628761, + 0.659144, + 0.929563, + 1.06724, + 1.6427}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {2.12035, + 3.41493, + 1.7401, + 1.46234, + 0.233226, + -2.78168}, + + {1.30552, + 0.137905, + 0.653793, + 0.790746, + -1.42584, + -2.34653}, + + {0.610716, + 0.778879, + -1.58577, + 1.45098, + -0.0985911, + -3.47167}, + { + -3.48281, + -6.4736, + -8.03308, + -7.55974, + -7.98843, + -10.1027}, + + {0.995183, + -2.42889, + -2.14073, + -6.27768, + -7.68512, + -13.3504}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -176,6 +163,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]); @@ -188,38 +185,35 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbrem(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.5, 2.0, 2.5}; + const double et = energy/cosh(eta); - const int nBinsBrem=1; - const Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.5, 2.0, 2.5}; - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; + constexpr int nBinsBrem=1; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; - par0[0][0]=0.00593389; - par1[0][0]=0.178275; - par2[0][0]=-7.28273; - par3[0][0]=13.2632; + constexpr float par0[nBinsEta][nBinsBrem] = + {{0.00593389}, {0.00266954}, + {0.00500623}, {0.00841038} }; - par0[1][0]=0.00266954; - par1[1][0]=0.811415; - par2[1][0]=-1.66063; - par3[1][0]=1.03555; + constexpr float par1[nBinsEta][nBinsBrem] = + {{0.178275}, + {0.811415}, + {2.34018}, + {1.06851}}; - par0[2][0]=0.00500623; - par1[2][0]=2.34018; - par2[2][0]=-11.0129; - par3[2][0]=-0.200323; + constexpr float par2[nBinsEta][nBinsBrem] = + {{-7.28273}, + {-1.66063}, + {-11.0129}, + {-4.1259}}; - par0[3][0]=0.00841038; - par1[3][0]=1.06851; - par2[3][0]=-4.1259; - par3[3][0]=-0.0646195; + constexpr float par3[nBinsEta][nBinsBrem] = + {{13.2632}, + {1.03555}, + {-0.200323}, + {-0.0646195}}; Int_t iEtaSl = -1; @@ -240,6 +234,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbr if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -251,39 +255,37 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbr } double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtrack(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.7, 1.3, 1.8, 2.5}; + const double et = energy/cosh(eta); - const int nBinsBrem=1; - const Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.7, 1.3, 1.8, 2.5}; - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; + constexpr int nBinsBrem=1; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; - par0[0][0]=0.00601311; - par1[0][0]=0.390988; - par2[0][0]=-4.11919; - par3[0][0]=4.61671; + constexpr float par0[nBinsEta][nBinsBrem] = + {{0.00601311}, + {0.0059814}, + {0.00953032}, + {0.00728618}}; - par0[1][0]=0.0059814; - par1[1][0]=1.02668; - par2[1][0]=-2.87477; - par3[1][0]=0.163447; + constexpr float par1[nBinsEta][nBinsBrem] = + {{ 0.390988}, + {1.02668}, + {2.27491}, + {2.08268}}; - par0[2][0]=0.00953032; - par1[2][0]=2.27491; - par2[2][0]=-7.61675; - par3[2][0]=-0.335786; - - par0[3][0]=0.00728618; - par1[3][0]=2.08268; - par2[3][0]=-8.66756; - par3[3][0]=-1.27831; + constexpr float par2[nBinsEta][nBinsBrem] = + {{-4.11919}, + {-2.87477}, + {-7.61675}, + {-8.66756}}; + constexpr float par3[nBinsEta][nBinsBrem]= + {{4.61671}, + {0.163447}, + {-0.335786}, + {-1.27831}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -303,6 +305,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtr if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -315,119 +327,113 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtr double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showering(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.2, 1.7, 2.5}; - - const int nBinsBrem=5; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.8, 2.2, 3.0, 4.0, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; - - par0[0][0]=0.0049351; - par1[0][0]=0.579925; - par2[0][0]=-9.33987; - par3[0][0]=1.62129; - - par0[0][1]=0.00566155; - par1[0][1]=0.496137; - par2[0][1]=-5.52543; - par3[0][1]=1.19101; - - par0[0][2]=0.0051397; - par1[0][2]=0.551947; - par2[0][2]=-7.30079; - par3[0][2]=1.89701; - - par0[0][3]=0.00468481; - par1[0][3]=0.63011; - par2[0][3]=-6.7722; - par3[0][3]=1.81614; - - par0[0][4]=0.00444475; - par1[0][4]=0.684261; - par2[0][4]=-4.67614; - par3[0][4]=1.64415; - - par0[1][0]=0.00201762; - par1[1][0]=0.914762; - par2[1][0]=-4.48042; - par3[1][0]=-1.50473; - - par0[1][1]=0.00431475; - par1[1][1]=0.824483; - par2[1][1]=-5.02885; - par3[1][1]=-0.153502; - - par0[1][2]=0.00501004; - par1[1][2]=0.888521; - par2[1][2]=-4.77311; - par3[1][2]=-0.355145; - - par0[1][3]=0.00632666; - par1[1][3]=0.960241; - par2[1][3]=-3.36742; - par3[1][3]=-1.16499; - - par0[1][4]=0.00636704; - par1[1][4]=1.25728; - par2[1][4]=-5.53561; - par3[1][4]=-0.864123; - - par0[2][0]=-0.00729396; - par1[2][0]=3.24295; - par2[2][0]=-17.1458; - par3[2][0]=-4.69711; - - par0[2][1]=0.00539783; - par1[2][1]=1.72935; - par2[2][1]=-5.92807; - par3[2][1]=-2.18733; - - par0[2][2]=0.00608149; - par1[2][2]=1.80606; - par2[2][2]=-6.67563; - par3[2][2]=-0.922401; - - par0[2][3]=0.00465335; - par1[2][3]=2.13562; - par2[2][3]=-10.1105; - par3[2][3]=-0.230781; - - par0[2][4]=0.00642685; - par1[2][4]=2.07592; - par2[2][4]=-7.50257; - par3[2][4]=-2.91515; - - par0[3][0]=0.0149449; - par1[3][0]=1.00448; - par2[3][0]=-2.09368; - par3[3][0]=0.455037; - - par0[3][1]=0.0216691; - par1[3][1]=1.18393; - par2[3][1]=-4.56674; - par3[3][1]=-0.601872; - - par0[3][2]=0.0255957; - par1[3][2]=0.00775295; - par2[3][2]=-44.2722; - par3[3][2]=241.516; - - par0[3][3]=0.0206101; - par1[3][3]=2.59246; - par2[3][3]=-13.1702; - par3[3][3]=-2.35024; - - par0[3][4]=0.0180508; - par1[3][4]=3.1099; - par2[3][4]=-13.6208; - par3[3][4]=-2.11069; - + const double et = energy/cosh(eta); + + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.2, 1.7, 2.5}; + + constexpr int nBinsBrem=5; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.8, 2.2, 3.0, 4.0, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem]= { + {0.0049351, + 0.00566155, + 0.0051397, + 0.00468481, + 0.00444475}, + + {0.00201762, + 0.00431475, + 0.00501004, + 0.00632666, + 0.00636704}, + + {-0.00729396, + 0.00539783, + 0.00608149, + 0.00465335, + 0.00642685}, + + {0.0149449, + 0.0216691, + 0.0255957, + 0.0206101, + 0.0180508} }; + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.579925, + 0.496137, + 0.551947, + 0.63011, + 0.684261}, + + {0.914762, + 0.824483, + 0.888521, + 0.960241, + 1.25728}, + + {3.24295, + 1.72935, + 1.80606, + 2.13562, + 2.07592}, + + {1.00448, + 1.18393, + 0.00775295, + 2.59246, + 3.1099}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {-9.33987, + -5.52543, + -7.30079, + -6.7722, + -4.67614}, + + {-4.48042, + -5.02885, + -4.77311, + -3.36742, + -5.53561}, + + {-17.1458, + -5.92807, + -6.67563, + -10.1105, + -7.50257}, + + {-2.09368, + -4.56674, + -44.2722, + -13.1702, + -13.6208}}; + + constexpr float par3[nBinsEta][nBinsBrem] = { + {1.62129, + 1.19101, + 1.89701, + 1.81614, + 1.64415}, + + {-1.50473, + -0.153502, + -0.355145, + -1.16499, + -0.864123}, + + {-4.69711, + -2.18733, + -0.922401, + -0.230781, + -2.91515}, + + {0.455037, + -0.601872, + 241.516, + -2.35024, + -2.11069}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -447,6 +453,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showe if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -459,138 +475,135 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showe double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_cracks(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=5; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.42, 0.78, 1.2, 1.52, 1.65}; - - const int nBinsBrem=6; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.2, 1.5, 2.1, 3., 4, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - - par0[0][0]=0.0139815; - par1[0][0]=0.569273; - par2[0][0]=-4.31243; - - par0[0][1]=0.00550839; - par1[0][1]=0.674654; - par2[0][1]=-3.071; - - par0[0][2]=0.0108292; - par1[0][2]=0.523128; - par2[0][2]=-2.56702; - - par0[0][3]=0.00596201; - par1[0][3]=1.02501; - par2[0][3]=-7.74555; - - par0[0][4]=-0.00498136; - par1[0][4]=1.75645; - par2[0][4]=-21.3726; - - par0[0][5]=0.000621696; - par1[0][5]=0.955191; - par2[0][5]=-6.2189; - - par0[1][0]=0.00467498; - par1[1][0]=0.697951; - par2[1][0]=-6.56009; - - par0[1][1]=0.00808463; - par1[1][1]=0.580628; - par2[1][1]=-3.66067; - - par0[1][2]=0.00546665; - par1[1][2]=0.814515; - par2[1][2]=-7.8275; - - par0[1][3]=0.00506318; - par1[1][3]=0.819975; - par2[1][3]=-6.01641; - - par0[1][4]=0.00608425; - par1[1][4]=0.829616; - par2[1][4]=-7.85456; - - par0[1][5]=-4.45641e-06; - par1[1][5]=1.18952; - par2[1][5]=-8.27071; - - par0[2][0]=0.00971734; - par1[2][0]=3.79446; - par2[2][0]=-49.9996; - - par0[2][1]=0.00063951; - par1[2][1]=2.47472; - par2[2][1]=-25.0724; - - par0[2][2]=-0.0121618; - par1[2][2]=5.12931; - par2[2][2]=-49.985; - - par0[2][3]=-0.00604365; - par1[2][3]=3.42497; - par2[2][3]=-28.1932; - - par0[2][4]=0.00492161; - par1[2][4]=1.84123; - par2[2][4]=-10.6485; - - par0[2][5]=-0.00143907; - par1[2][5]=2.3773; - par2[2][5]=-15.4014; - - par0[3][0]=-0.0844907; - par1[3][0]=19.9999; - par2[3][0]=-39.9444; - - par0[3][1]=-0.0592498; - par1[3][1]=10.4079; - par2[3][1]=-25.1133; - - par0[3][2]=-0.0828631; - par1[3][2]=16.6273; - par2[3][2]=-49.9999; - - par0[3][3]=-0.0740798; - par1[3][3]=15.9316; - par2[3][3]=-50; - - par0[3][4]=-0.0698045; - par1[3][4]=15.4883; - par2[3][4]=-49.9998; - - par0[3][5]=-0.0699518; - par1[3][5]=14.7306; - par2[3][5]=-49.9998; - - par0[4][0]=-0.0999971; - par1[4][0]=15.9122; - par2[4][0]=-30.1268; - - par0[4][1]=-0.0999996; - par1[4][1]=18.5882; - par2[4][1]=-42.6113; - - par0[4][2]=-0.0989356; - par1[4][2]=19.9996; - par2[4][2]=-46.6999; - - par0[4][3]=-0.0999965; - par1[4][3]=19.9999; - par2[4][3]=-47.074; - - par0[4][4]=-0.0833049; - par1[4][4]=18.2281; - par2[4][4]=-49.9995; - - par0[4][5]=-0.020072; - par1[4][5]=8.1587; - par2[4][5]=-25.2897; - + const double et = energy/cosh(eta); + + constexpr int nBinsEta=5; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.42, 0.78, 1.2, 1.52, 1.65}; + + constexpr int nBinsBrem=6; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.2, 1.5, 2.1, 3., 4, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem] = { + {0.0139815, + 0.00550839, + 0.0108292, + 0.00596201, + -0.00498136, + 0.000621696}, + + {0.00467498, + 0.00808463, + 0.00546665, + 0.00506318, + 0.00608425, + -4.45641e-06}, + + {0.00971734, + 0.00063951, + -0.0121618, + -0.00604365, + 0.00492161, + -0.00143907}, + + {-0.0844907, + -0.0592498, + -0.0828631, + -0.0740798, + -0.0698045, + -0.0699518}, + + {-0.0999971, + -0.0999996, + -0.0989356, + -0.0999965, + -0.0833049, + -0.020072}}; + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.569273, + 0.674654, + 0.523128, + 1.02501, + 1.75645, + 0.955191}, + + {0.697951, + 0.580628, + 0.814515, + 0.819975, + 0.829616, + 1.18952}, + + {3.79446, + 2.47472, + 5.12931, + 3.42497, + 1.84123, + 2.3773}, + + {19.9999, + 10.4079, + 16.6273, + 15.9316, + 15.4883, + 14.7306}, + + {15.9122, + 18.5882, + 19.9996, + 19.9999, + 18.2281, + 8.1587}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {-4.31243, + -3.071, + -2.56702, + -7.74555, + -21.3726, + -6.2189}, + + {-6.56009, + -3.66067, + -7.8275, + -6.01641, + -7.85456, + -8.27071}, + + {-49.9996, + -25.0724, + -49.985, + -28.1932, + -10.6485, + -15.4014}, + + {-39.9444, + -25.1133, + -49.9999, + -50, + -49.9998, + -49.9998}, + + {-30.1268, + -42.6113, + -46.6999, + -47.074, + -49.9995, + -25.2897}}; + + + static_assert(par0[0][3]==0.00596201f); + static_assert(par1[0][3]==1.02501f); + static_assert(par2[0][3]==-7.74555f); + + + static_assert(par0[2][4]==0.00492161f); + static_assert(par1[2][4]==1.84123f); + static_assert(par2[2][4]==-10.6485f); + + static_assert(par0[4][3]==-0.0999965f); + static_assert(par1[4][3]==19.9999f); + static_assert(par2[4][3]==-47.074f); Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -610,6 +623,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_crack if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]); From c57248c0f05339049e4382cf364c632bd296644c Mon Sep 17 00:00:00 2001 From: Saranya Ghosh Date: Mon, 25 Mar 2019 14:35:16 +0100 Subject: [PATCH 255/686] removed explicit declaration of the instance of class DQMStore --- DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h b/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h index a1b0ba87d47b4..1f57f84359bc7 100644 --- a/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h +++ b/DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h @@ -36,8 +36,8 @@ #include -// To remove into CMSSW versions before 20X -class DQMStore; +// To remove into CMSSW versions before 20X; removed in CMSSW 10_5_X onwards +//class DQMStore; // To add into CMSSW versions before 20X //class DaqMonitorBEInterface; From f0993db26304beb2d4873fa912e56ddca7f41aa7 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 16:07:48 +0100 Subject: [PATCH 256/686] Replacing the selection by OOT index by a selection by absolute, corrected time --- .../plugins/CTPPSLocalTrackLiteProducer.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index bbcf10079e1df..6ec7465d9e38a 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -49,14 +49,14 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> /// if true, this module will do nothing /// needed for consistency with CTPPS-less workflows bool doNothing_; - int timeSlice_; + std::vector trackTimeSel_; }; //---------------------------------------------------------------------------------------------------- CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSet& iConfig ) : - doNothing_( iConfig.getParameter( "doNothing" ) ), - timeSlice_( iConfig.getParameter( "timeSlice" ) ) + doNothing_ ( iConfig.getParameter( "doNothing" ) ), + trackTimeSel_( iConfig.getParameter >( "trackTimeSelection" ) ) { if ( doNothing_ ) return; @@ -133,7 +133,7 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& const unsigned int rpId = rpv.detId(); for ( const auto& trk : rpv ) { if ( !trk.isValid() ) continue; - if ( trk.getOOTIndex() != timeSlice_ ) continue; + if ( trk.getT() < trackTimeSel_.at( 0 ) || trk.getT() > trackTimeSel_.at( 1 ) ) continue; float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getX0()); float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getX0Sigma()); float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0()); @@ -205,8 +205,8 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "input pixel detectors' local tracks collection to retrieve" ); desc.add( "doNothing", true ) // disable the module by default ->setComment( "disable the module" ); - desc.add( "timeSlice", 0 ) - ->setComment( "time slice to select for timing detectors" ); + desc.add >( "trackTimeSelection", { 0., 1. } ) + ->setComment( "time slice to select for timing detectors [ns]" ); desc.add("pixelTrackTxMin",-10.0); desc.add("pixelTrackTxMax", 10.0); From 0b958d672ab5d68dbe52028478b9eb53682a3f90 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 16:15:21 +0100 Subject: [PATCH 257/686] Ensuring the validity of the timing range --- RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 6ec7465d9e38a..1ed69b529641a 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -65,6 +65,9 @@ CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSe includeDiamonds_ = iConfig.getParameter("includeDiamonds"); diamondTrackToken_ = consumes< edm::DetSetVector >( iConfig.getParameter("tagDiamondTrack") ); + if ( trackTimeSel_.size() != 2 ) + throw cms::Exception("CTPPSLocalTrackLiteProducer") + << "Invalid track timing selection! should be vector{lower time, upper time}."; includePixels_ = iConfig.getParameter("includePixels"); auto tagPixelTrack = iConfig.getParameter("tagPixelTrack"); From 44a9a6c73748387eb0e7fec1edc586b56b8f94d8 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 16:45:42 +0100 Subject: [PATCH 258/686] Cut applied on absolute time, instead of timeslice-relative time --- .../TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 1ed69b529641a..9c2a6927a5771 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -36,6 +36,8 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> static void fillDescriptions( edm::ConfigurationDescriptions& ); private: + /// HPTDC time slice width, in ns + static constexpr float HPTDC_TIME_SLICE_WIDTH = 25.; bool includeStrips_; edm::EDGetTokenT< edm::DetSetVector > siStripTrackToken_; @@ -136,12 +138,13 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& const unsigned int rpId = rpv.detId(); for ( const auto& trk : rpv ) { if ( !trk.isValid() ) continue; - if ( trk.getT() < trackTimeSel_.at( 0 ) || trk.getT() > trackTimeSel_.at( 1 ) ) continue; + const float abs_time = trk.getT()+trk.getOOTIndex()*HPTDC_TIME_SLICE_WIDTH; + if ( abs_time < trackTimeSel_.at( 0 ) || abs_time > trackTimeSel_.at( 1 ) ) continue; float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getX0()); float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getX0Sigma()); float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0()); float roundedY0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getY0Sigma()); - float roundedT = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getT()); + float roundedT = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(abs_time); float roundedTSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getTSigma()); pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, 0., 0., 0., 0., 0., From c76e317850e2d51f314e19b067eddd3dc7bdf488 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 16:46:55 +0100 Subject: [PATCH 259/686] Arbitrarily large lower and upper bounds for tracks timing selection, to be tuned after time calibration PR is merged --- RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 9c2a6927a5771..09936a72b74d4 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -211,7 +211,7 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "input pixel detectors' local tracks collection to retrieve" ); desc.add( "doNothing", true ) // disable the module by default ->setComment( "disable the module" ); - desc.add >( "trackTimeSelection", { 0., 1. } ) + desc.add >( "trackTimeSelection", { -1000., 1000. } ) ->setComment( "time slice to select for timing detectors [ns]" ); desc.add("pixelTrackTxMin",-10.0); From 8a3f6f556371d4dae0121611dba46598808ca9ab Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Mon, 25 Mar 2019 17:13:12 +0100 Subject: [PATCH 260/686] Fix script --- .../test/python/testDTGeometryAndDump.py | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py index 8ae48c14f5bf8..77f5c3c22b230 100644 --- a/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py +++ b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py @@ -2,12 +2,6 @@ process = cms.Process("DTGeometryTest") process.add_(cms.Service("InitRootHandlers", ResetRootErrHandler = cms.untracked.bool(False))) -##process.add_(cms.ESProducer("FWTGeoRecoGeometryESProducer", -## Tracker = cms.untracked.bool(False), -## Muon = cms.untracked.bool(True), -## Calo = cms.untracked.bool(False), -## Timing = cms.untracked.bool(False))) - process.source = cms.Source("EmptySource") process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) @@ -15,13 +9,13 @@ process.MessageLogger = cms.Service( "MessageLogger", - statistics = cms.untracked.vstring('cout', 'dtGeometry'), + statistics = cms.untracked.vstring('cout', 'dumpGeometry'), categories = cms.untracked.vstring('Geometry'), cout = cms.untracked.PSet( threshold = cms.untracked.string('WARNING'), noLineBreaks = cms.untracked.bool(True) ), - dtGeometry = cms.untracked.PSet( + dumpGeometry = cms.untracked.PSet( INFO = cms.untracked.PSet( limit = cms.untracked.int32(0) ), @@ -41,7 +35,7 @@ ) ), destinations = cms.untracked.vstring('cout', - 'dtGeometry') + 'dumpGeometry') ) process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", @@ -72,16 +66,8 @@ DDDetector = cms.ESInputTag('MUON') ) -process.FWTGeoRecoGeometryESProducer = cms.ESProducer("FWTGeoRecoGeometryESProducer", - Tracker = cms.untracked.bool(False), - Muon = cms.untracked.bool(True), - Calo = cms.untracked.bool(False), - Timing = cms.untracked.bool(False)) - -process.dump = cms.EDAnalyzer("DumpFWRecoGeometry", - level = cms.untracked.int32(1), - tagInfo = cms.untracked.string('DT'), - outputFileName = cms.untracked.string('cmsRecoGeom') +process.dump = cms.EDAnalyzer("DDTestDumpGeometry", + DDDetector = cms.ESInputTag('MUON') ) process.p = cms.Path(process.test+process.dump) From 2121bbe27ec92874e5143498cf710e317e5654ac Mon Sep 17 00:00:00 2001 From: mondalspandan Date: Mon, 25 Mar 2019 22:56:03 +0100 Subject: [PATCH 261/686] BTagCalibration: Added protection against -ve eta values for SFs calculated on abs(eta) --- CondTools/BTau/src/BTagCalibrationReader.cc | 5 +++++ CondTools/BTau/test/BTagCalibrationStandalone.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CondTools/BTau/src/BTagCalibrationReader.cc b/CondTools/BTau/src/BTagCalibrationReader.cc index a34ac7e3cdb52..09dcbc2fd4f45 100644 --- a/CondTools/BTau/src/BTagCalibrationReader.cc +++ b/CondTools/BTau/src/BTagCalibrationReader.cc @@ -163,6 +163,11 @@ double BTagCalibrationReader::BTagCalibrationReaderImpl::eval_auto_bounds( bool eta_is_out_of_bounds = false; if (sf_bounds_eta.first < 0) sf_bounds_eta.first = -sf_bounds_eta.second; + + if (useAbsEta_[jf] && eta < 0) { + eta = -eta; + } + if (eta <= sf_bounds_eta.first || eta > sf_bounds_eta.second ) { eta_is_out_of_bounds = true; } diff --git a/CondTools/BTau/test/BTagCalibrationStandalone.cpp b/CondTools/BTau/test/BTagCalibrationStandalone.cpp index eb596a103b61e..4b123b6d86070 100644 --- a/CondTools/BTau/test/BTagCalibrationStandalone.cpp +++ b/CondTools/BTau/test/BTagCalibrationStandalone.cpp @@ -528,7 +528,12 @@ double BTagCalibrationReader::BTagCalibrationReaderImpl::eval_auto_bounds( auto sf_bounds_eta = min_max_eta(jf, discr); bool eta_is_out_of_bounds = false; - if (sf_bounds_eta.first < 0) sf_bounds_eta.first = -sf_bounds_eta.second; + if (sf_bounds_eta.first < 0) sf_bounds_eta.first = -sf_bounds_eta.second; + + if (useAbsEta_[jf] && eta < 0) { + eta = -eta; + } + if (eta <= sf_bounds_eta.first || eta > sf_bounds_eta.second ) { eta_is_out_of_bounds = true; } From 2ba4cf0ff5d26c7964ac281780952024b633b4c4 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 26 Mar 2019 08:16:51 +0100 Subject: [PATCH 262/686] Replaced vector of double selection by two doubles --- .../plugins/CTPPSLocalTrackLiteProducer.cc | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index 09936a72b74d4..db8cb234ba809 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -51,14 +51,13 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> /// if true, this module will do nothing /// needed for consistency with CTPPS-less workflows bool doNothing_; - std::vector trackTimeSel_; + double timingTrackTMin_, timingTrackTMax_; }; //---------------------------------------------------------------------------------------------------- CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSet& iConfig ) : - doNothing_ ( iConfig.getParameter( "doNothing" ) ), - trackTimeSel_( iConfig.getParameter >( "trackTimeSelection" ) ) + doNothing_ ( iConfig.getParameter( "doNothing" ) ) { if ( doNothing_ ) return; @@ -67,9 +66,9 @@ CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSe includeDiamonds_ = iConfig.getParameter("includeDiamonds"); diamondTrackToken_ = consumes< edm::DetSetVector >( iConfig.getParameter("tagDiamondTrack") ); - if ( trackTimeSel_.size() != 2 ) - throw cms::Exception("CTPPSLocalTrackLiteProducer") - << "Invalid track timing selection! should be vector{lower time, upper time}."; + + timingTrackTMin_ = iConfig.getParameter( "timingTrackTMin" ); + timingTrackTMax_ = iConfig.getParameter( "timingTrackTMax" ); includePixels_ = iConfig.getParameter("includePixels"); auto tagPixelTrack = iConfig.getParameter("tagPixelTrack"); @@ -138,8 +137,10 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& const unsigned int rpId = rpv.detId(); for ( const auto& trk : rpv ) { if ( !trk.isValid() ) continue; + const float abs_time = trk.getT()+trk.getOOTIndex()*HPTDC_TIME_SLICE_WIDTH; - if ( abs_time < trackTimeSel_.at( 0 ) || abs_time > trackTimeSel_.at( 1 ) ) continue; + if ( abs_time < timingTrackTMin_ || abs_time > timingTrackTMax_ ) continue; + float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getX0()); float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.getX0Sigma()); float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0()); @@ -211,8 +212,10 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "input pixel detectors' local tracks collection to retrieve" ); desc.add( "doNothing", true ) // disable the module by default ->setComment( "disable the module" ); - desc.add >( "trackTimeSelection", { -1000., 1000. } ) - ->setComment( "time slice to select for timing detectors [ns]" ); + desc.add( "timingTrackTMin", -1000. ) + ->setComment( "minimal track time selection for timing detectors [ns]" ); + desc.add( "timingTrackTMax", +1000. ) + ->setComment( "maximal track time selection for timing detectors [ns]" ); desc.add("pixelTrackTxMin",-10.0); desc.add("pixelTrackTxMax", 10.0); From 54a96fed277cb95f22f1addfcd517b1729112cd8 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 26 Mar 2019 08:18:28 +0100 Subject: [PATCH 263/686] Cleanup of emplace_back procedure for diamond information --- .../TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index db8cb234ba809..d1a6dd452f237 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -148,8 +148,13 @@ CTPPSLocalTrackLiteProducer::produce( edm::Event& iEvent, const edm::EventSetup& float roundedT = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(abs_time); float roundedTSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getTSigma()); - pOut->emplace_back( rpId, roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, 0., 0., 0., 0., 0., - CTPPSpixelLocalTrackReconstructionInfo::invalid, trk.getNumOfPlanes(), roundedT, roundedTSigma); + pOut->emplace_back( + rpId, // detector info + roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma, // spatial info + 0., 0., 0., 0., 0., // angular info + CTPPSpixelLocalTrackReconstructionInfo::invalid, trk.getNumOfPlanes(), // reconstruction info + roundedT, roundedTSigma // timing info + ); } } } From 521521e94d8f7998925c041f293a7711dcb3c83b Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 26 Mar 2019 08:21:41 +0100 Subject: [PATCH 264/686] Cleanup --- RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index d1a6dd452f237..dcca2caef325d 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -57,7 +57,7 @@ class CTPPSLocalTrackLiteProducer : public edm::stream::EDProducer<> //---------------------------------------------------------------------------------------------------- CTPPSLocalTrackLiteProducer::CTPPSLocalTrackLiteProducer( const edm::ParameterSet& iConfig ) : - doNothing_ ( iConfig.getParameter( "doNothing" ) ) + doNothing_( iConfig.getParameter( "doNothing" ) ) { if ( doNothing_ ) return; From f3faa4fb641f83a575e156389810fe3db7245545 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 22 Mar 2019 19:56:23 +0100 Subject: [PATCH 265/686] More efficient PFEGammaFilters constructor --- .../PFProducer/interface/PFEGammaFilters.h | 29 +++-- .../PFProducer/src/PFEGammaFilters.cc | 110 ++++++++---------- 2 files changed, 69 insertions(+), 70 deletions(-) diff --git a/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h b/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h index 23b73717b228d..927da0c971137 100644 --- a/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h +++ b/RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h @@ -44,7 +44,8 @@ class PFEGammaFilters { const float ph_loose_hoe_; const float ph_sietaieta_eb_; const float ph_sietaieta_ee_; - const float pho_sumPtTrackIso, pho_sumPtTrackIsoSlope; + float pho_sumPtTrackIso_; + float pho_sumPtTrackIsoSlope_; // Electron selections const float ele_iso_pt_; @@ -56,24 +57,32 @@ class PFEGammaFilters { const unsigned int ele_missinghits_; const float ele_ecalDrivenHademPreselCut_; const float ele_maxElePtForOnlyMVAPresel_; - const float ele_maxNtracks, ele_maxHcalE, ele_maxTrackPOverEele, ele_maxE, - ele_maxEleHcalEOverEcalE, ele_maxEcalEOverPRes, ele_maxEeleOverPoutRes, - ele_maxHcalEOverP, ele_maxHcalEOverEcalE, ele_maxEcalEOverP_1, - ele_maxEcalEOverP_2, ele_maxEeleOverPout, ele_maxDPhiIN; + float ele_maxNtracks_; + float ele_maxHcalE_; + float ele_maxTrackPOverEele_; + float ele_maxE_; + float ele_maxEleHcalEOverEcalE_; + float ele_maxEcalEOverPRes_; + float ele_maxEeleOverPoutRes_; + float ele_maxHcalEOverP_; + float ele_maxHcalEOverEcalE_; + float ele_maxEcalEOverP_1_; + float ele_maxEcalEOverP_2_; + float ele_maxEeleOverPout_; + float ele_maxDPhiIN_; // dead hcal selections (electrons) std::array badHcal_full5x5_sigmaIetaIeta_; std::array badHcal_eInvPInv_; std::array badHcal_dEta_; std::array badHcal_dPhi_; - const bool badHcal_eleEnable_; + bool badHcal_eleEnable_; // dead hcal selections (photons) - const float badHcal_phoTrkSolidConeIso_offs_, badHcal_phoTrkSolidConeIso_slope_; - const bool badHcal_phoEnable_; + float badHcal_phoTrkSolidConeIso_offs_; + float badHcal_phoTrkSolidConeIso_slope_; + bool badHcal_phoEnable_; - // Event variables - const bool debug_ = false; }; #endif diff --git a/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc b/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc index d0eafcef718a1..454055028199b 100644 --- a/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc +++ b/RecoParticleFlow/PFProducer/src/PFEGammaFilters.cc @@ -23,22 +23,6 @@ namespace { out[1] = vals[1]; } - auto eleJetMetProt(const edm::ParameterSet& cfg) { - return cfg.getParameter("electron_protectionsForJetMET"); - } - - auto phJetMetProt(const edm::ParameterSet& cfg) { - return cfg.getParameter("photon_protectionsForJetMET"); - } - - auto eleHcalProt(const edm::ParameterSet& cfg) { - return cfg.getParameter("electron_protectionsForBadHcal"); - } - - auto phHcalProt(const edm::ParameterSet& cfg) { - return cfg.getParameter("photon_protectionsForBadHcal"); - } - } @@ -48,8 +32,6 @@ PFEGammaFilters::PFEGammaFilters(const edm::ParameterSet& cfg) : ph_loose_hoe_(cfg.getParameter("photon_HoE")), ph_sietaieta_eb_(cfg.getParameter("photon_SigmaiEtaiEta_barrel")), ph_sietaieta_ee_(cfg.getParameter("photon_SigmaiEtaiEta_endcap")), - pho_sumPtTrackIso(phJetMetProt(cfg).getParameter("sumPtTrackIso")), - pho_sumPtTrackIsoSlope(phJetMetProt(cfg).getParameter("sumPtTrackIsoSlope")), ele_iso_pt_(cfg.getParameter("electron_iso_pt")), ele_iso_mva_eb_(cfg.getParameter("electron_iso_mva_barrel")), ele_iso_mva_ee_(cfg.getParameter("electron_iso_mva_endcap")), @@ -58,31 +40,39 @@ PFEGammaFilters::PFEGammaFilters(const edm::ParameterSet& cfg) : ele_noniso_mva_(cfg.getParameter("electron_noniso_mvaCut")), ele_missinghits_(cfg.getParameter("electron_missinghits")), ele_ecalDrivenHademPreselCut_(cfg.getParameter("electron_ecalDrivenHademPreselCut")), - ele_maxElePtForOnlyMVAPresel_(cfg.getParameter("electron_maxElePtForOnlyMVAPresel")), - ele_maxNtracks(eleJetMetProt(cfg).getParameter("maxNtracks")), - ele_maxHcalE(eleJetMetProt(cfg).getParameter("maxHcalE")), - ele_maxTrackPOverEele(eleJetMetProt(cfg).getParameter("maxTrackPOverEele")), - ele_maxE(eleJetMetProt(cfg).getParameter("maxE")), - ele_maxEleHcalEOverEcalE(eleJetMetProt(cfg).getParameter("maxEleHcalEOverEcalE")), - ele_maxEcalEOverPRes(eleJetMetProt(cfg).getParameter("maxEcalEOverPRes")), - ele_maxEeleOverPoutRes(eleJetMetProt(cfg).getParameter("maxEeleOverPoutRes")), - ele_maxHcalEOverP(eleJetMetProt(cfg).getParameter("maxHcalEOverP")), - ele_maxHcalEOverEcalE(eleJetMetProt(cfg).getParameter("maxHcalEOverEcalE")), - ele_maxEcalEOverP_1(eleJetMetProt(cfg).getParameter("maxEcalEOverP_1")), - ele_maxEcalEOverP_2(eleJetMetProt(cfg).getParameter("maxEcalEOverP_2")), - ele_maxEeleOverPout(eleJetMetProt(cfg).getParameter("maxEeleOverPout")), - ele_maxDPhiIN(eleJetMetProt(cfg).getParameter("maxDPhiIN")), - badHcal_eleEnable_(eleHcalProt(cfg).getParameter("enableProtections")), - badHcal_phoTrkSolidConeIso_offs_(phHcalProt(cfg).getParameter("solidConeTrkIsoOffset")), - badHcal_phoTrkSolidConeIso_slope_(phHcalProt(cfg).getParameter("solidConeTrkIsoSlope")), - badHcal_phoEnable_(phHcalProt(cfg).getParameter("enableProtections")), - debug_(cfg.getUntrackedParameter("debug",false)) + ele_maxElePtForOnlyMVAPresel_(cfg.getParameter("electron_maxElePtForOnlyMVAPresel")) { auto const& eleProtectionsForBadHcal = cfg.getParameter("electron_protectionsForBadHcal"); + auto const& eleProtectionsForJetMET = cfg.getParameter("electron_protectionsForJetMET"); + auto const& phoProtectionsForBadHcal = cfg.getParameter("photon_protectionsForBadHcal"); + auto const& phoProtectionsForJetMET = cfg.getParameter("photon_protectionsForJetMET"); + + pho_sumPtTrackIso_ = phoProtectionsForJetMET.getParameter("sumPtTrackIso"); + pho_sumPtTrackIsoSlope_ = phoProtectionsForJetMET.getParameter("sumPtTrackIsoSlope"); + + ele_maxNtracks_ = eleProtectionsForJetMET.getParameter("maxNtracks"); + ele_maxHcalE_ = eleProtectionsForJetMET.getParameter("maxHcalE"); + ele_maxTrackPOverEele_ = eleProtectionsForJetMET.getParameter("maxTrackPOverEele"); + ele_maxE_ = eleProtectionsForJetMET.getParameter("maxE"); + ele_maxEleHcalEOverEcalE_ = eleProtectionsForJetMET.getParameter("maxEleHcalEOverEcalE"); + ele_maxEcalEOverPRes_ = eleProtectionsForJetMET.getParameter("maxEcalEOverPRes"); + ele_maxEeleOverPoutRes_ = eleProtectionsForJetMET.getParameter("maxEeleOverPoutRes"); + ele_maxHcalEOverP_ = eleProtectionsForJetMET.getParameter("maxHcalEOverP"); + ele_maxHcalEOverEcalE_ = eleProtectionsForJetMET.getParameter("maxHcalEOverEcalE"); + ele_maxEcalEOverP_1_ = eleProtectionsForJetMET.getParameter("maxEcalEOverP_1"); + ele_maxEcalEOverP_2_ = eleProtectionsForJetMET.getParameter("maxEcalEOverP_2"); + ele_maxEeleOverPout_ = eleProtectionsForJetMET.getParameter("maxEeleOverPout"); + ele_maxDPhiIN_ = eleProtectionsForJetMET.getParameter("maxDPhiIN"); + readEBEEParams_(eleProtectionsForBadHcal, "full5x5_sigmaIetaIeta", badHcal_full5x5_sigmaIetaIeta_); readEBEEParams_(eleProtectionsForBadHcal, "eInvPInv", badHcal_eInvPInv_); readEBEEParams_(eleProtectionsForBadHcal, "dEta", badHcal_dEta_); readEBEEParams_(eleProtectionsForBadHcal, "dPhi", badHcal_dPhi_); + + badHcal_eleEnable_ = eleProtectionsForBadHcal.getParameter("enableProtections"); + badHcal_phoTrkSolidConeIso_offs_ = phoProtectionsForBadHcal.getParameter("solidConeTrkIsoOffset"); + badHcal_phoTrkSolidConeIso_slope_ = phoProtectionsForBadHcal.getParameter("solidConeTrkIsoSlope"); + badHcal_phoEnable_ = phoProtectionsForBadHcal.getParameter("enableProtections"); } @@ -204,19 +194,19 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron bool debugSafeForJetMET = false; bool isSafeForJetMET = true; -// cout << " ele_maxNtracks " << ele_maxNtracks << endl -// << " ele_maxHcalE " << ele_maxHcalE << endl -// << " ele_maxTrackPOverEele " << ele_maxTrackPOverEele << endl -// << " ele_maxE " << ele_maxE << endl -// << " ele_maxEleHcalEOverEcalE "<< ele_maxEleHcalEOverEcalE << endl -// << " ele_maxEcalEOverPRes " << ele_maxEcalEOverPRes << endl -// << " ele_maxEeleOverPoutRes " << ele_maxEeleOverPoutRes << endl -// << " ele_maxHcalEOverP " << ele_maxHcalEOverP << endl -// << " ele_maxHcalEOverEcalE " << ele_maxHcalEOverEcalE << endl -// << " ele_maxEcalEOverP_1 " << ele_maxEcalEOverP_1 << endl -// << " ele_maxEcalEOverP_2 " << ele_maxEcalEOverP_2 << endl -// << " ele_maxEeleOverPout " << ele_maxEeleOverPout << endl -// << " ele_maxDPhiIN " << ele_maxDPhiIN << endl; +// cout << " ele_maxNtracks_ " << ele_maxNtracks_ << endl +// << " ele_maxHcalE_ " << ele_maxHcalE_ << endl +// << " ele_maxTrackPOverEele_ " << ele_maxTrackPOverEele_ << endl +// << " ele_maxE_ " << ele_maxE_ << endl +// << " ele_maxEleHcalEOverEcalE_ "<< ele_maxEleHcalEOverEcalE_ << endl +// << " ele_maxEcalEOverPRes_ " << ele_maxEcalEOverPRes_ << endl +// << " ele_maxEeleOverPoutRes_ " << ele_maxEeleOverPoutRes_ << endl +// << " ele_maxHcalEOverP_ " << ele_maxHcalEOverP_ << endl +// << " ele_maxHcalEOverEcalE_ " << ele_maxHcalEOverEcalE_ << endl +// << " ele_maxEcalEOverP_1_ " << ele_maxEcalEOverP_1_ << endl +// << " ele_maxEcalEOverP_2_ " << ele_maxEcalEOverP_2_ << endl +// << " ele_maxEeleOverPout_ " << ele_maxEeleOverPout_ << endl +// << " ele_maxDPhiIN_ " << ele_maxDPhiIN_ << endl; // loop on the extra-tracks associated to the electron PFCandidateEGammaExtraRef pfcandextra = pfcand.egammaExtraRef(); @@ -308,8 +298,8 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron } } if( iextratrack > 0) { - if(iextratrack > ele_maxNtracks || Ene_hcalgsf > ele_maxHcalE || (SumExtraKfP/Ene_ecalgsf) > ele_maxTrackPOverEele - || (ETtotal > ele_maxE && iextratrack > 1 && (Ene_hcalgsf/Ene_ecalgsf) > ele_maxEleHcalEOverEcalE) ) { + if(iextratrack > ele_maxNtracks_ || Ene_hcalgsf > ele_maxHcalE_ || (SumExtraKfP/Ene_ecalgsf) > ele_maxTrackPOverEele_ + || (ETtotal > ele_maxE_ && iextratrack > 1 && (Ene_hcalgsf/Ene_ecalgsf) > ele_maxEleHcalEOverEcalE_) ) { if(debugSafeForJetMET) cout << " *****This electron candidate is discarded: Non isolated # tracks " << iextratrack << " HOverHE " << HOverHE @@ -323,9 +313,9 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron isSafeForJetMET = false; } // the electron is retained and the kf tracks are not locked - if( (fabs(1.-EtotPinMode) < ele_maxEcalEOverPRes && (fabs(electron.eta()) < 1.0 || fabs(electron.eta()) > 2.0)) || + if( (fabs(1.-EtotPinMode) < ele_maxEcalEOverPRes_ && (fabs(electron.eta()) < 1.0 || fabs(electron.eta()) > 2.0)) || ((EtotPinMode < 1.1 && EtotPinMode > 0.6) && (fabs(electron.eta()) >= 1.0 && fabs(electron.eta()) <= 2.0))) { - if( fabs(1.-EGsfPoutMode) < ele_maxEeleOverPoutRes && + if( fabs(1.-EGsfPoutMode) < ele_maxEeleOverPoutRes_ && (itrackHcalLinked == iextratrack)) { lockTracks = false; @@ -340,7 +330,7 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron } } - if (HOverPin > ele_maxHcalEOverP && HOverHE > ele_maxHcalEOverEcalE && EtotPinMode < ele_maxEcalEOverP_1) { + if (HOverPin > ele_maxHcalEOverP_ && HOverHE > ele_maxHcalEOverEcalE_ && EtotPinMode < ele_maxEcalEOverP_1_) { if(debugSafeForJetMET) cout << " *****This electron candidate is discarded HCAL ENERGY " << " HOverPin " << HOverPin << " HOverHE " << HOverHE << " EtotPinMode" << EtotPinMode << endl; @@ -350,7 +340,7 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron // Reject Crazy E/p values... to be understood in the future how to train a // BDT in order to avoid to select this bad electron candidates. - if( EtotPinMode < ele_maxEcalEOverP_2 && EGsfPoutMode < ele_maxEeleOverPout ) { + if( EtotPinMode < ele_maxEcalEOverP_2_ && EGsfPoutMode < ele_maxEeleOverPout_ ) { if(debugSafeForJetMET) cout << " *****This electron candidate is discarded Low ETOTPIN " << " EtotPinMode " << EtotPinMode << " EGsfPoutMode " << EGsfPoutMode << endl; @@ -358,7 +348,7 @@ bool PFEGammaFilters::isElectronSafeForJetMET(const reco::GsfElectron & electron } // For not-preselected Gsf Tracks ET > 50 GeV, apply dphi preselection - if(ETtotal > ele_maxE && fabs(dphi_normalsc) > ele_maxDPhiIN ) { + if(ETtotal > ele_maxE_ && fabs(dphi_normalsc) > ele_maxDPhiIN_ ) { if(debugSafeForJetMET) cout << " *****This electron candidate is discarded Large ANGLE " << " ETtotal " << ETtotal << " EGsfPoutMode " << dphi_normalsc << endl; @@ -374,8 +364,8 @@ bool PFEGammaFilters::isPhotonSafeForJetMET(const reco::Photon & photon, const r bool isSafeForJetMET = true; bool debugSafeForJetMET = false; -// cout << " pho_sumPtTrackIsoForPhoton " << pho_sumPtTrackIso -// << " pho_sumPtTrackIsoSlopeForPhoton " << pho_sumPtTrackIsoSlope << endl; +// cout << " pho_sumPtTrackIso_ForPhoton " << pho_sumPtTrackIso_ +// << " pho_sumPtTrackIsoSlope_ForPhoton " << pho_sumPtTrackIsoSlope_ << endl; float sum_track_pt = 0.; @@ -422,7 +412,7 @@ bool PFEGammaFilters::isPhotonSafeForJetMET(const reco::Photon & photon, const r if(debugSafeForJetMET) cout << " PFEGammaFilters::isPhotonSafeForJetMET: SumPt " << sum_track_pt << endl; - if(sum_track_pt>(pho_sumPtTrackIso + pho_sumPtTrackIsoSlope * photon.pt())) { + if(sum_track_pt>(pho_sumPtTrackIso_ + pho_sumPtTrackIsoSlope_ * photon.pt())) { isSafeForJetMET = false; if(debugSafeForJetMET) cout << "************************************!!!! PFEGammaFilters::isPhotonSafeForJetMET: Photon Discaded !!! " << endl; From abbd45d3b872e2c5fd5c440fced754d06dfe988c Mon Sep 17 00:00:00 2001 From: Saranya Ghosh Date: Tue, 26 Mar 2019 11:20:48 +0100 Subject: [PATCH 266/686] Corrected formatting using clang-format for file DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc --- .../src/DTCalibValidationFromMuons.cc | 391 ++++++++++-------- 1 file changed, 215 insertions(+), 176 deletions(-) diff --git a/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc b/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc index 234c886648aa5..c96e2cba20a2e 100644 --- a/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc +++ b/DQM/DTMonitorModule/src/DTCalibValidationFromMuons.cc @@ -8,37 +8,36 @@ #include "DQM/DTMonitorModule/interface/DTCalibValidationFromMuons.h" // Framework -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/ServiceRegistry/interface/Service.h" #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/MonitorElement.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ServiceRegistry/interface/Service.h" -//Geometry +// Geometry #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" -//RecHit -#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +// RecHit #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" #include "DataFormats/MuonReco/interface/MuonSelectors.h" - #include using namespace edm; using namespace std; - -DTCalibValidationFromMuons::DTCalibValidationFromMuons(const ParameterSet& pset) { +DTCalibValidationFromMuons::DTCalibValidationFromMuons( + const ParameterSet &pset) { parameters = pset; // the name of the 4D segments - segment4DToken_ = consumes( - edm::InputTag(parameters.getUntrackedParameter("segment4DLabel"))); + segment4DToken_ = consumes(edm::InputTag( + parameters.getUntrackedParameter("segment4DLabel"))); // muon collection for matching 4D segments to muons muonToken_ = consumes( edm::InputTag(parameters.getUntrackedParameter("muonLabel"))); @@ -47,114 +46,124 @@ DTCalibValidationFromMuons::DTCalibValidationFromMuons(const ParameterSet& pset) // the counter of segments used to compute residuals rightSegment = 0; - nevent=0; - + nevent = 0; } +DTCalibValidationFromMuons::~DTCalibValidationFromMuons() { -DTCalibValidationFromMuons::~DTCalibValidationFromMuons(){ - - //FR the following was previously in the endJob - - LogVerbatim("DTCalibValidationFromMuons") << "Segments used to compute residuals: " << rightSegment; - LogVerbatim("DTCalibValidationFromMuons") << "Segments not used to compute residuals: " << wrongSegment; + // FR the following was previously in the endJob + LogVerbatim("DTCalibValidationFromMuons") + << "Segments used to compute residuals: " << rightSegment; + LogVerbatim("DTCalibValidationFromMuons") + << "Segments not used to compute residuals: " << wrongSegment; } -void DTCalibValidationFromMuons::dqmBeginRun(const edm::Run& run, const edm::EventSetup& setup) { +void DTCalibValidationFromMuons::dqmBeginRun(const edm::Run &run, + const edm::EventSetup &setup) { - // get the geometry + // get the geometry setup.get().get(dtGeom); } - -void DTCalibValidationFromMuons::analyze(const edm::Event& event, const edm::EventSetup& setup) { +void DTCalibValidationFromMuons::analyze(const edm::Event &event, + const edm::EventSetup &setup) { ++nevent; - LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Analyze #Run: " << event.id().run() - << " #Event: " << nevent; + LogTrace("DTCalibValidationFromMuons") + << "[DTCalibValidationFromMuons] Analyze #Run: " << event.id().run() + << " #Event: " << nevent; // RecHit mapping at Step 3 --------------------------------- LogTrace("DTCalibValidationFromMuons") << " -- DTRecHit S3: begin analysis:"; // Get the 4D rechits from the event Handle muonH; event.getByToken(muonToken_, muonH); - const vector* muons = muonH.product(); + const vector *muons = muonH.product(); // Get the 4D rechits from the event Handle segment4Ds; event.getByToken(segment4DToken_, segment4Ds); - vector selectedSegment4Ds; + vector selectedSegment4Ds; for (auto &imuon : *muons) { for (const auto &ch : imuon.matches()) { - DetId chId(ch.id.rawId()); - if ( chId.det() != DetId::Muon ) continue; - if ( chId.subdetId() != MuonSubdetId::DT ) continue; - if ( imuon.pt()<15 ) continue; - if ( !imuon.isGlobalMuon() ) continue; - - int nsegs=ch.segmentMatches.size(); - if (!nsegs) continue; - - // get the DT segments that were used to construct the muon - DTChamberId matchId = ch.id(); - DTRecSegment4DCollection::range segs= segment4Ds->get(matchId); - for (DTRecSegment4DCollection::const_iterator segment = segs.first; segment!=segs.second; ++segment) { - LocalPoint posHit = segment->localPosition(); - float dx = (posHit.x() ? posHit.x()-ch.x : 0 ); - float dy = (posHit.y() ? posHit.y()-ch.y : 0 ); - float dr = sqrt(dx*dx+dy*dy); - if (dr<5) selectedSegment4Ds.push_back(&(*segment)); - } + DetId chId(ch.id.rawId()); + if (chId.det() != DetId::Muon) + continue; + if (chId.subdetId() != MuonSubdetId::DT) + continue; + if (imuon.pt() < 15) + continue; + if (!imuon.isGlobalMuon()) + continue; + + int nsegs = ch.segmentMatches.size(); + if (!nsegs) + continue; + + // get the DT segments that were used to construct the muon + DTChamberId matchId = ch.id(); + DTRecSegment4DCollection::range segs = segment4Ds->get(matchId); + for (DTRecSegment4DCollection::const_iterator segment = segs.first; + segment != segs.second; ++segment) { + LocalPoint posHit = segment->localPosition(); + float dx = (posHit.x() ? posHit.x() - ch.x : 0); + float dy = (posHit.y() ? posHit.y() - ch.y : 0); + float dr = sqrt(dx * dx + dy * dy); + if (dr < 5) + selectedSegment4Ds.push_back(&(*segment)); + } } - } // Loop over all 4D segments - for (auto segment : selectedSegment4Ds ) { + for (auto segment : selectedSegment4Ds) { LogTrace("DTCalibValidationFromMuons") << "Anlysis on recHit at step 3"; compute(dtGeom.product(), *segment); } - } - // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair -float -DTCalibValidationFromMuons::recHitDistFromWire(const DTRecHit1DPair& hitPair, const DTLayer* layer) { +float DTCalibValidationFromMuons::recHitDistFromWire( + const DTRecHit1DPair &hitPair, const DTLayer *layer) { return fabs(hitPair.localPosition(DTEnums::Left).x() - - hitPair.localPosition(DTEnums::Right).x())/2.; + hitPair.localPosition(DTEnums::Right).x()) / + 2.; } - // Compute the distance from wire (cm) of a hits in a DTRecHit1D -float -DTCalibValidationFromMuons::recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer) { - return fabs(recHit.localPosition().x() - layer->specificTopology().wirePosition(recHit.wireId().wire())); - +float DTCalibValidationFromMuons::recHitDistFromWire(const DTRecHit1D &recHit, + const DTLayer *layer) { + return fabs(recHit.localPosition().x() - + layer->specificTopology().wirePosition(recHit.wireId().wire())); } // Compute the position (cm) of a hits in a DTRecHit1DPair -float -DTCalibValidationFromMuons::recHitPosition(const DTRecHit1DPair& hitPair, const DTLayer* layer, const DTChamber* chamber, float segmentPos, int sl) { +float DTCalibValidationFromMuons::recHitPosition(const DTRecHit1DPair &hitPair, + const DTLayer *layer, + const DTChamber *chamber, + float segmentPos, int sl) { // Get the layer and the wire position - GlobalPoint hitPosGlob_right = layer->toGlobal(hitPair.localPosition(DTEnums::Right)); + GlobalPoint hitPosGlob_right = + layer->toGlobal(hitPair.localPosition(DTEnums::Right)); LocalPoint hitPosInChamber_right = chamber->toLocal(hitPosGlob_right); - GlobalPoint hitPosGlob_left = layer->toGlobal(hitPair.localPosition(DTEnums::Left)); + GlobalPoint hitPosGlob_left = + layer->toGlobal(hitPair.localPosition(DTEnums::Left)); LocalPoint hitPosInChamber_left = chamber->toLocal(hitPosGlob_left); - float recHitPos=-1; - if(sl != 2){ - if(fabs(hitPosInChamber_left.x()-segmentPos)toGlobal(recHit.localPosition()); LocalPoint recHitPosInChamber = chamber->toLocal(recHitPosGlob); float recHitPos = -1; - if(sl != 2) + if (sl != 2) recHitPos = recHitPosInChamber.x(); else recHitPos = recHitPosInChamber.y(); return recHitPos; - } // Compute the residuals -void DTCalibValidationFromMuons::compute(const DTGeometry *dtGeom, const DTRecSegment4D& segment) { +void DTCalibValidationFromMuons::compute(const DTGeometry *dtGeom, + const DTRecSegment4D &segment) { bool computeResidual = true; @@ -192,182 +202,211 @@ void DTCalibValidationFromMuons::compute(const DTGeometry *dtGeom, const DTRecSe // Get 1D RecHits at Step 3 and select only events with // >=7 hits in phi and 4 hits in theta (if any) - const DTChamberRecSegment2D* phiSeg = segment.phiSegment(); - if(phiSeg){ + const DTChamberRecSegment2D *phiSeg = segment.phiSegment(); + if (phiSeg) { vector phiRecHits = phiSeg->specificRecHits(); - if(phiRecHits.size() < 7) { - LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Phi segments has: " << phiRecHits.size() - << " hits, skipping"; // FIXME: info output + if (phiRecHits.size() < 7) { + LogTrace("DTCalibValidationFromMuons") + << "[DTCalibValidationFromMuons] Phi segments has: " + << phiRecHits.size() << " hits, skipping"; // FIXME: info output computeResidual = false; } copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3)); } - if(!phiSeg){ - LogTrace("DTCalibValidationFromMuons") << " [DTCalibValidationFromMuons] 4D segment has no phi segment! "; + if (!phiSeg) { + LogTrace("DTCalibValidationFromMuons") + << " [DTCalibValidationFromMuons] 4D segment has no phi segment! "; computeResidual = false; } - if(segment.dimension() == 4) { - const DTSLRecSegment2D* zSeg = segment.zSegment(); - if(zSeg){ + if (segment.dimension() == 4) { + const DTSLRecSegment2D *zSeg = segment.zSegment(); + if (zSeg) { vector zRecHits = zSeg->specificRecHits(); - if(zRecHits.size() != 4) { - LogTrace("DTCalibValidationFromMuons") << "[DTCalibValidationFromMuons] Theta segments has: " << zRecHits.size() - << " hits, skipping"; // FIXME: info output - computeResidual = false; + if (zRecHits.size() != 4) { + LogTrace("DTCalibValidationFromMuons") + << "[DTCalibValidationFromMuons] Theta segments has: " + << zRecHits.size() << " hits, skipping"; // FIXME: info output + computeResidual = false; } copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3)); } - if(!zSeg){ - LogTrace("DTCalibValidationFromMuons") << " [DTCalibValidationFromMuons] 4D segment has not the z segment! "; + if (!zSeg) { + LogTrace("DTCalibValidationFromMuons") + << " [DTCalibValidationFromMuons] 4D segment has not the z segment! "; computeResidual = false; } } - if(!computeResidual) ++wrongSegment; + if (!computeResidual) + ++wrongSegment; - if(computeResidual) { + if (computeResidual) { ++rightSegment; // Loop over 1D RecHit inside 4D segment - for(vector::const_iterator recHit1D = recHits1D_S3.begin(); - recHit1D != recHits1D_S3.end(); - ++recHit1D) { + for (vector::const_iterator recHit1D = recHits1D_S3.begin(); + recHit1D != recHits1D_S3.end(); ++recHit1D) { const DTWireId wireId = (*recHit1D).wireId(); // Get the layer and the wire position - const DTLayer* layer = dtGeom->layer(wireId); + const DTLayer *layer = dtGeom->layer(wireId); float wireX = layer->specificTopology().wirePosition(wireId.wire()); // Extrapolate the segment to the z of the wire // Get wire position in chamber RF - // (y and z must be those of the hit to be coherent in the transf. of RF in case of rotations of the layer alignment) - LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z()); + // (y and z must be those of the hit to be coherent in the transf. of RF + // in case of rotations of the layer alignment) + LocalPoint wirePosInLay(wireX, (*recHit1D).localPosition().y(), + (*recHit1D).localPosition().z()); GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay); - const DTChamber* chamber = dtGeom->chamber((*recHit1D).wireId().layerId().chamberId()); + const DTChamber *chamber = + dtGeom->chamber((*recHit1D).wireId().layerId().chamberId()); LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob); // Segment position at Wire z in chamber local frame - LocalPoint segPosAtZWire = segment.localPosition() - + segment.localDirection()*wirePosInChamber.z()/cos(segment.localDirection().theta()); + LocalPoint segPosAtZWire = + segment.localPosition() + segment.localDirection() * + wirePosInChamber.z() / + cos(segment.localDirection().theta()); // Compute the distance of the segment from the wire int sl = wireId.superlayer(); float SegmDistance = -1; - if(sl == 1 || sl == 3) { - // RPhi SL - SegmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x()); - LogTrace("DTCalibValidationFromMuons") << "SegmDistance: " << SegmDistance; - } else if(sl == 2) { - // RZ SL - SegmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y()); - LogTrace("DTCalibValidationFromMuons") << "SegmDistance: " << SegmDistance; + if (sl == 1 || sl == 3) { + // RPhi SL + SegmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x()); + LogTrace("DTCalibValidationFromMuons") + << "SegmDistance: " << SegmDistance; + } else if (sl == 2) { + // RZ SL + SegmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y()); + LogTrace("DTCalibValidationFromMuons") + << "SegmDistance: " << SegmDistance; } - - if(SegmDistance > 2.1) - LogTrace("DTCalibValidationFromMuons") << " Warning: dist segment-wire: " << SegmDistance; + + if (SegmDistance > 2.1) + LogTrace("DTCalibValidationFromMuons") + << " Warning: dist segment-wire: " << SegmDistance; // Compute the distance of the recHit from the wire - float recHitWireDist = recHitDistFromWire(*recHit1D, layer); - LogTrace("DTCalibValidationFromMuons") << "recHitWireDist: " << recHitWireDist; - + float recHitWireDist = recHitDistFromWire(*recHit1D, layer); + LogTrace("DTCalibValidationFromMuons") + << "recHitWireDist: " << recHitWireDist; + // Compute the residuals float residualOnDistance = recHitWireDist - SegmDistance; - LogTrace("DTCalibValidationFromMuons") << "WireId: " << wireId << " ResidualOnDistance: " << residualOnDistance; + LogTrace("DTCalibValidationFromMuons") + << "WireId: " << wireId + << " ResidualOnDistance: " << residualOnDistance; float residualOnPosition = -1; float recHitPos = -1; - if(sl == 1 || sl == 3) { - recHitPos = recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.x(), sl); + if (sl == 1 || sl == 3) { + recHitPos = + recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.x(), sl); residualOnPosition = recHitPos - segPosAtZWire.x(); } else { - recHitPos = recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.y(), sl); + recHitPos = + recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.y(), sl); residualOnPosition = recHitPos - segPosAtZWire.y(); } - LogTrace("DTCalibValidationFromMuons") << "WireId: " << wireId << " ResidualOnPosition: " << residualOnPosition; + LogTrace("DTCalibValidationFromMuons") + << "WireId: " << wireId + << " ResidualOnPosition: " << residualOnPosition; // Fill the histos - if(sl == 1 || sl == 3) - fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.x() - segPosAtZWire.x()), residualOnPosition, 3); + if (sl == 1 || sl == 3) + fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, + (wirePosInChamber.x() - segPosAtZWire.x()), + residualOnPosition, 3); else - fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.y() - segPosAtZWire.y()), residualOnPosition, 3); + fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, + (wirePosInChamber.y() - segPosAtZWire.y()), + residualOnPosition, 3); } } } +void DTCalibValidationFromMuons::bookHistograms(DQMStore::IBooker &ibooker, + edm::Run const &iRun, + edm::EventSetup const &iSetup) { -void DTCalibValidationFromMuons::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & iSetup) { - - //FR substitute the DQMStore instance by ibooker - ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons"); + // FR substitute the DQMStore instance by ibooker + ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons"); DTSuperLayerId slId; // Loop over all the chambers - vector::const_iterator ch_it = dtGeom->chambers().begin(); - vector::const_iterator ch_end = dtGeom->chambers().end(); + vector::const_iterator ch_it = dtGeom->chambers().begin(); + vector::const_iterator ch_end = dtGeom->chambers().end(); for (; ch_it != ch_end; ++ch_it) { - vector::const_iterator sl_it = (*ch_it)->superLayers().begin(); - vector::const_iterator sl_end = (*ch_it)->superLayers().end(); + vector::const_iterator sl_it = + (*ch_it)->superLayers().begin(); + vector::const_iterator sl_end = + (*ch_it)->superLayers().end(); // Loop over the SLs - for(; sl_it != sl_end; ++sl_it) { + for (; sl_it != sl_end; ++sl_it) { slId = (*sl_it)->id(); // TODO! fix this is a leftover - int firstStep=3; + int firstStep = 3; // Loop over the 3 steps - for(int step = firstStep; step <= 3; ++step) { - - LogTrace("DTCalibValidationFromMuons") << " Booking histos for SL: " << slId; - - // Compose the chamber name - stringstream wheel; wheel << slId.wheel(); - stringstream station; station << slId.station(); - stringstream sector; sector << slId.sector(); - stringstream superLayer; superLayer << slId.superlayer(); - // Define the step - stringstream Step; Step << step; - - string slHistoName = - "_STEP" + Step.str() + - "_W" + wheel.str() + - "_St" + station.str() + - "_Sec" + sector.str() + - "_SL" + superLayer.str(); - - ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons/Wheel" + wheel.str() + - "/Station" + station.str() + - "/Sector" + sector.str()); - // Create the monitor elements - vector histos; - // Note the order matters - histos.push_back(ibooker.book1D("hResDist"+slHistoName, - "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", - 200, -0.4, 0.4)); - histos.push_back(ibooker.book2D("hResDistVsDist"+slHistoName, - "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)", - 100, 0, 2.5, 200, -0.4, 0.4)); - - histosPerSL[make_pair(slId, step)] = histos; + for (int step = firstStep; step <= 3; ++step) { + + LogTrace("DTCalibValidationFromMuons") + << " Booking histos for SL: " << slId; + + // Compose the chamber name + stringstream wheel; + wheel << slId.wheel(); + stringstream station; + station << slId.station(); + stringstream sector; + sector << slId.sector(); + stringstream superLayer; + superLayer << slId.superlayer(); + // Define the step + stringstream Step; + Step << step; + + string slHistoName = "_STEP" + Step.str() + "_W" + wheel.str() + "_St" + + station.str() + "_Sec" + sector.str() + "_SL" + + superLayer.str(); + + ibooker.setCurrentFolder("DT/DTCalibValidationFromMuons/Wheel" + + wheel.str() + "/Station" + station.str() + + "/Sector" + sector.str()); + // Create the monitor elements + vector histos; + // Note the order matters + histos.push_back(ibooker.book1D( + "hResDist" + slHistoName, + "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", + 200, -0.4, 0.4)); + histos.push_back( + ibooker.book2D("hResDistVsDist" + slHistoName, + "Residuals on the distance (cm) from wire (rec_hit " + "- segm_extr) vs distance (cm)", + 100, 0, 2.5, 200, -0.4, 0.4)); + + histosPerSL[make_pair(slId, step)] = histos; } } } } - // Fill a set of histograms for a given SL -void DTCalibValidationFromMuons::fillHistos(DTSuperLayerId slId, - float distance, - float residualOnDistance, - float position, - float residualOnPosition, - int step) { +void DTCalibValidationFromMuons::fillHistos(DTSuperLayerId slId, float distance, + float residualOnDistance, + float position, + float residualOnPosition, + int step) { // FIXME: optimization of the number of searches - vector histos = histosPerSL[make_pair(slId,step)]; + vector histos = histosPerSL[make_pair(slId, step)]; histos[0]->Fill(residualOnDistance); histos[1]->Fill(distance, residualOnDistance); } - // Local Variables: // show-trailing-whitespace: t // truncate-lines: t From af55ca37094290154079ecd9fbe25326e39e3663 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 26 Mar 2019 11:31:09 +0100 Subject: [PATCH 267/686] Update PFTau I/O rules to circumvent issue when restoring edm::Ptr --- DataFormats/TauReco/src/classes_def_2.xml | 169 +++++----------------- 1 file changed, 39 insertions(+), 130 deletions(-) diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 6382e837d312a..282646c1173db 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -51,79 +51,68 @@ - - (onfile.leadPFChargedHadrCand_);]]> - - - - (onfile.leadPFNeutralCand_);]]> - - - - (onfile.leadPFCand_);]]> - - - - leadPFChargedHadrCand_; edm::Ptr leadPFNeutralCand_; edm::Ptr leadPFCand_; std::vector selectedSignalPFCands_; std::vector > selectedSignalPFChargedHadrCands_; std::vector > selectedSignalPFNeutrHadrCands_; std::vector > selectedSignalPFGammaCands_; std::vector > selectedIsolationPFCands_; std::vector > selectedIsolationPFChargedHadrCands_; std::vector > selectedIsolationPFNeutrHadrCands_; std::vector > selectedIsolationPFGammaCands_; edm::RefVector > isolationTauChargedHadronCandidatesRefs_; reco::JetBaseRef jetRef_;" targetClass="reco::PFTau" target="leadChargedHadrCand_,leadNeutralCand_,leadCand_,selectedSignalCands_,selectedSignalChargedHadrCands_,selectedSignalNeutrHadrCands_,selectedSignalGammaCands_,selectedIsolationCands_,selectedIsolationChargedHadrCands_,selectedIsolationNeutrHadrCands_,selectedIsolationGammaCands_,leadPFChargedHadrCand_,leadPFNeutralCand_,leadPFCand_"> + & cand : onfile.selectedSignalPFCands_) { selectedSignalCands_.push_back(edm::Ptr(cand));} - ]]> - - - (cand));]]> - + selectedSignalChargedHadrCands_.push_back(edm::Ptr(cand)); - - (cand));;]]> - + selectedSignalNeutrHadrCands_.push_back(edm::Ptr(cand));; - - (cand));]]> - + selectedSignalGammaCands_.push_back(edm::Ptr(cand)); - - (cand));]]> - + selectedIsolationCands_.push_back(edm::Ptr(cand)); - - (cand));]]> - + selectedIsolationChargedHadrCands_.push_back(edm::Ptr(cand)); - - (cand));]]> - + selectedIsolationNeutrHadrCands_.push_back(edm::Ptr(cand)); - - (cand));]]> + selectedIsolationGammaCands_.push_back(edm::Ptr(cand)); + + if (selectedSignalChargedHadrCands_.size() > 0) { + leadChargedHadrCand_ = selectedSignalChargedHadrCands_[0]; + } else { + leadChargedHadrCand_ = edm::Ptr(); + } + if (selectedSignalGammaCands_.size() > 0) { + leadNeutralCand_ = selectedSignalGammaCands_[0]; + } else { + leadNeutralCand_ = edm::Ptr(); + } + if (selectedSignalCands_.size() > 0) { + leadCand_ = selectedSignalCands_[0]; + } else { + leadCand_ = edm::Ptr(); + } + + leadPFChargedHadrCand_.reset(); + leadPFNeutralCand_.reset(); + leadPFCand_.reset(); + ]]> @@ -250,98 +239,18 @@ for(auto const& ref : onfile.selectedIsolationPFGammaCands_) { +target="leadPFChargedHadrCand_,leadPFNeutralCand_,leadPFCand_,selectedTransientSignalPFCands_,selectedTransientSignalPFChargedHadrCands_,selectedTransientSignalPFNeutrHadrCands_,selectedTransientSignalPFGammaCands_,selectedTransientIsolationPFCands_,selectedTransientIsolationPFChargedHadrCands_,selectedTransientIsolationPFNeutrHadrCands_,selectedTransientIsolationPFGammaCands_"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From d6704854c634cf36f827ffe2648fff7433172e7c Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 15 Mar 2019 08:07:09 +0100 Subject: [PATCH 268/686] Framework for implementing HFStripFilter in CMSSW --- .../METReco/interface/HcalPhase1FlagLabels.h | 3 +- RecoLocalCalo/HcalRecAlgos/BuildFile.xml | 1 + .../HcalRecAlgos/interface/HFStripFilter.h | 45 ++++++++++ .../python/hcalRecAlgoESProd_cfi.py | 13 +-- .../HcalRecAlgos/src/HFStripFilter.cc | 85 +++++++++++++++++++ .../src/HcalSeverityLevelComputer.cc | 1 + .../python/HFPhase1Reconstructor_cfi.py | 19 +++++ .../src/HFPhase1Reconstructor.cc | 19 ++++- 8 files changed, 179 insertions(+), 7 deletions(-) create mode 100644 RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h create mode 100644 RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc diff --git a/DataFormats/METReco/interface/HcalPhase1FlagLabels.h b/DataFormats/METReco/interface/HcalPhase1FlagLabels.h index e86070281bb5a..fce43ec76ce32 100644 --- a/DataFormats/METReco/interface/HcalPhase1FlagLabels.h +++ b/DataFormats/METReco/interface/HcalPhase1FlagLabels.h @@ -20,7 +20,8 @@ namespace HcalPhase1FlagLabels /* 0 */ HFLongShort = HcalCaloFlagLabels::HFLongShort, /* 3 */ HFS8S1Ratio = HcalCaloFlagLabels::HFS8S1Ratio, /* 4 */ HFPET = HcalCaloFlagLabels::HFPET, - /* 5 */ HFSignalAsymmetry = 5 + /* 5 */ HFSignalAsymmetry = 5, + /* 6 */ HFAnomalousHit = 6 }; enum CommonFlag { diff --git a/RecoLocalCalo/HcalRecAlgos/BuildFile.xml b/RecoLocalCalo/HcalRecAlgos/BuildFile.xml index b3b67a7ae8fe4..8a8c538fc654e 100644 --- a/RecoLocalCalo/HcalRecAlgos/BuildFile.xml +++ b/RecoLocalCalo/HcalRecAlgos/BuildFile.xml @@ -11,6 +11,7 @@ + diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h new file mode 100644 index 0000000000000..98be4c520175f --- /dev/null +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -0,0 +1,45 @@ +#ifndef RecoLocalCalo_HcalRecAlgos_HFStripFilter_h_ +#define RecoLocalCalo_HcalRecAlgos_HFStripFilter_h_ + +#include + +#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + +class HFStripFilter +{ +public: + // Construct this object with all necessary parameters + HFStripFilter(double energyMax1, double energyMax2, + double stripThreshold, double maxThreshold, + double timeMax, double maxStripTime, + double wedgeCut, int gap, + int lstrips, int verboseLevel); + + // Destructor + ~HFStripFilter(); + + // The actual rechit tagging is performed by the following function + void runFilter(HFRecHitCollection& rec) const; + + // Parser function to create this object from a parameter set + static std::unique_ptr parseParameterSet( + const edm::ParameterSet& ps); + + // Standard parameter values + static edm::ParameterSetDescription fillDescription(); + +private: + double energyMax1_; + double energyMax2_; + double stripThreshold_; + double maxThreshold_; + double timeMax_; + double maxStripTime_; + double wedgeCut_; + int gap_; + int lstrips_; + int verboseLevel_; +}; + +#endif // RecoLocalCalo_HcalRecAlgos_HFStripFilter_h_ diff --git a/RecoLocalCalo/HcalRecAlgos/python/hcalRecAlgoESProd_cfi.py b/RecoLocalCalo/HcalRecAlgos/python/hcalRecAlgoESProd_cfi.py index 9d61def437f7a..1e65f81ea33ea 100644 --- a/RecoLocalCalo/HcalRecAlgos/python/hcalRecAlgoESProd_cfi.py +++ b/RecoLocalCalo/HcalRecAlgos/python/hcalRecAlgoESProd_cfi.py @@ -31,7 +31,10 @@ run2_HCAL_2017.toModify(hcalRecAlgos, phase = cms.uint32(1), SeverityLevels = { - 2 : dict( RecHitFlags = cms.vstring('HBHEIsolatedNoise') ), + 2 : dict( RecHitFlags = cms.vstring('HBHEIsolatedNoise', + 'HFAnomalousHit' + ) + ), 3 : dict( RecHitFlags = cms.vstring('HBHEHpdHitMultiplicity', 'HBHEFlatNoise', 'HBHESpikeNoise', @@ -40,10 +43,10 @@ 'HBHEOOTPU' ) ), - 4: dict( RecHitFlags = cms.vstring('HFLongShort', - 'HFS8S1Ratio', - 'HFPET', - 'HFSignalAsymmetry' + 4 : dict( RecHitFlags = cms.vstring('HFLongShort', + 'HFS8S1Ratio', + 'HFPET', + 'HFSignalAsymmetry' ) ), }, diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc new file mode 100644 index 0000000000000..aadac7af21c4c --- /dev/null +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -0,0 +1,85 @@ +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h" + +#include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" + + +HFStripFilter::HFStripFilter(const double energyMax1, const double energyMax2, + const double stripThreshold, const double maxThreshold, + const double timeMax, const double maxStripTime, + const double wedgeCut, const int gap, + const int lstrips, const int verboseLevel) + : energyMax1_(energyMax1), + energyMax2_(energyMax2), + stripThreshold_(stripThreshold), + maxThreshold_(maxThreshold), + timeMax_(timeMax), + maxStripTime_(maxStripTime), + wedgeCut_(wedgeCut), + gap_(gap), + lstrips_(lstrips), + verboseLevel_(verboseLevel) +{ + // For the description of CMSSW message logging, see + // https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideMessageLogger + if (verboseLevel_ >= 20) + edm::LogInfo("HFStripFilter") << "constructor called"; +} + +HFStripFilter::~HFStripFilter() +{ + if (verboseLevel_ >= 20) + edm::LogInfo("HFStripFilter") << "destructor called"; +} + +void HFStripFilter::runFilter(HFRecHitCollection& rec) const +{ + if (verboseLevel_ >= 20) + edm::LogInfo("HFStripFilter") << "runFilter called"; + + // Cycle over the rechit collection + for (HFRecHitCollection::iterator it = rec.begin(); it != rec.end(); ++it) + { + // Figure out which rechits need to be tagged + + // To tag a rechit with the anomalous hit flag, do the following + it->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); + } +} + +std::unique_ptr HFStripFilter::parseParameterSet( + const edm::ParameterSet& ps) +{ + return std::make_unique( + ps.getParameter("energyMax1"), + ps.getParameter("energyMax2"), + ps.getParameter("stripThreshold"), + ps.getParameter("maxThreshold"), + ps.getParameter("timeMax"), + ps.getParameter("maxStripTime"), + ps.getParameter("wedgeCut"), + ps.getParameter("gap"), + ps.getParameter("lstrips"), + ps.getParameter("verboseLevel") + ); +} + +edm::ParameterSetDescription HFStripFilter::fillDescription() +{ + edm::ParameterSetDescription desc; + + desc.add("energyMax1", -10.0); + desc.add("energyMax2", -10.0); + desc.add("stripThreshold", 40.0); + desc.add("maxThreshold", 100.0); + desc.add("timeMax", 6.0); + desc.add("maxStripTime", 10.0); + desc.add("wedgeCut", 0.05); + desc.add("gap", 2); + desc.add("lstrips", 2); + desc.add("verboseLevel", 0); + + return desc; +} diff --git a/RecoLocalCalo/HcalRecAlgos/src/HcalSeverityLevelComputer.cc b/RecoLocalCalo/HcalRecAlgos/src/HcalSeverityLevelComputer.cc index 98675bf27c182..6d3687c9c6531 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HcalSeverityLevelComputer.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HcalSeverityLevelComputer.cc @@ -52,6 +52,7 @@ bool HcalSeverityLevelComputer::getRecHitFlag(HcalSeverityDefinition& mydef, else if (mybit == "HFS8S1Ratio") setBit(HcalPhase1FlagLabels::HFS8S1Ratio, mydef.HFFlagMask); else if (mybit == "HFPET") setBit(HcalPhase1FlagLabels::HFPET, mydef.HFFlagMask); else if (mybit == "HFSignalAsymmetry") setBit(HcalPhase1FlagLabels::HFSignalAsymmetry, mydef.HFFlagMask); + else if (mybit == "HFAnomalousHit") setBit(HcalPhase1FlagLabels::HFAnomalousHit, mydef.HFFlagMask); // Common subdetector bits ++++++++++++++++++++++ else if (mybit == "TimingFromTDC") setAllRHMasks(HcalPhase1FlagLabels::TimingFromTDC, mydef); diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index 996d368a8f4bd..dfa2c33a4f5a8 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -74,6 +74,10 @@ # Turn on/off the noise cleanup algorithms setNoiseFlags = cms.bool(True), + # Run HFStripFilter in the noise cleanup sequence? This switch + # is meaningful only if "setNoiseFlags" is set to True. + runHFStripFilter = cms.bool(True), + # Parameters for the S9S1 test. # # optimumSlopes are slopes for each of the |ieta| values @@ -190,5 +194,20 @@ short_R_29 = cms.vdouble([0.8]), long_R_29 = cms.vdouble([0.8]), # should move from 0.98 to 0.8? HcalAcceptSeverityLevel = cms.int32(9), # allow hits with severity up to AND INCLUDING 9 + ), + + # Parameters for HFStripFilter. + # Please add some descriptions of their meaning. + HFStripFilter = cms.PSet( + energyMax1 = cms.double(-10.0), + energyMax2 = cms.double(-10.0), + stripThreshold = cms.double(40.0), + maxThreshold = cms.double(100.0), + timeMax = cms.double(6.0), + maxStripTime = cms.double(10.0), + wedgeCut = cms.double(0.05), + gap = cms.int32(2), + lstrips = cms.int32(2), + verboseLevel = cms.int32(20) ) ) diff --git a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc index 8afc2ee32a881..89b532703344a 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc @@ -40,6 +40,7 @@ // Noise cleanup algos #include "RecoLocalCalo/HcalRecAlgos/interface/HcalHF_PETalgorithm.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HcalHF_S9S1algorithm.h" +#include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" // Parser for Phase 1 HF reco algorithms #include "RecoLocalCalo/HcalRecAlgos/interface/parseHFPhase1AlgoDescription.h" @@ -65,6 +66,7 @@ class HFPhase1Reconstructor : public edm::stream::EDProducer<> // Configuration parameters std::string algoConfigClass_; bool setNoiseFlags_; + bool runHFStripFilter_; bool useChannelQualityFromDB_; bool checkChannelQualityForDepth3and4_; @@ -77,6 +79,7 @@ class HFPhase1Reconstructor : public edm::stream::EDProducer<> std::unique_ptr hfS9S1_; std::unique_ptr hfS8S1_; std::unique_ptr hfPET_; + std::unique_ptr hfStripFilter_; }; // @@ -85,6 +88,7 @@ class HFPhase1Reconstructor : public edm::stream::EDProducer<> HFPhase1Reconstructor::HFPhase1Reconstructor(const edm::ParameterSet& conf) : algoConfigClass_(conf.getParameter("algoConfigClass")), setNoiseFlags_(conf.getParameter("setNoiseFlags")), + runHFStripFilter_(conf.getParameter("runHFStripFilter")), useChannelQualityFromDB_(conf.getParameter("useChannelQualityFromDB")), checkChannelQualityForDepth3and4_(conf.getParameter("checkChannelQualityForDepth3and4")), reco_(parseHFPhase1AlgoDescription(conf.getParameter("algorithm"))) @@ -131,6 +135,13 @@ HFPhase1Reconstructor::HFPhase1Reconstructor(const edm::ParameterSet& conf) psPET.getParameter("HcalAcceptSeverityLevel"), psPET.getParameter >("short_R_29"), psPET.getParameter >("long_R_29") ); + + // Configure HFStripFilter + if (runHFStripFilter_) + { + const edm::ParameterSet& psStripFilter = conf.getParameter("HFStripFilter"); + hfStripFilter_ = HFStripFilter::parseParameterSet(psStripFilter); + } } // Describe consumed data @@ -266,7 +277,7 @@ HFPhase1Reconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup) hfS8S1_->HFSetFlagFromS9S1(*i, *rec, myqual, mySeverity); } - // Set 3: Set S9S1 flag (long fibers) + // Step 3: Set S9S1 flag (long fibers) for (HFRecHitCollection::iterator i = rec->begin(); i != rec->end(); ++i) { int depth=i->id().depth(); @@ -275,6 +286,10 @@ HFPhase1Reconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup) if (depth==1 && abs(ieta)!=29 ) hfS9S1_->HFSetFlagFromS9S1(*i, *rec, myqual, mySeverity); } + + // Step 4: Run HFStripFilter if requested + if (runHFStripFilter_) + hfStripFilter_->runFilter(*rec); } // Add the output collection to the event record @@ -295,9 +310,11 @@ HFPhase1Reconstructor::fillDescriptions(edm::ConfigurationDescriptions& descript desc.add("inputLabel"); desc.add("algoConfigClass"); desc.add("setNoiseFlags"); + desc.add("runHFStripFilter", false); desc.add("useChannelQualityFromDB"); desc.add("checkChannelQualityForDepth3and4"); desc.add("algorithm", fillDescriptionForParseHFPhase1AlgoDescription()); + desc.add("HFStripFilter", HFStripFilter::fillDescription()); add_param_set(S9S1stat); add_param_set(S8S1stat); From af6f1e5b50714389ed6d072010c61800a6f2e122 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 15 Mar 2019 10:19:06 +0100 Subject: [PATCH 269/686] changing the "runFilter" signature --- RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h | 7 ++++++- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 8 +++++--- .../HcalRecProducers/src/HFPhase1Reconstructor.cc | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h index 98be4c520175f..091fb6a648dfd 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -6,6 +6,9 @@ #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +class HcalChannelQuality; +class HcalSeverityLevelComputer; + class HFStripFilter { public: @@ -20,7 +23,9 @@ class HFStripFilter ~HFStripFilter(); // The actual rechit tagging is performed by the following function - void runFilter(HFRecHitCollection& rec) const; + void runFilter(HFRecHitCollection& rec, + const HcalChannelQuality* myqual, + const HcalSeverityLevelComputer* mySeverity) const; // Parser function to create this object from a parameter set static std::unique_ptr parseParameterSet( diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index aadac7af21c4c..68c7e56cdfc8a 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -1,11 +1,11 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - #include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h" +#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" +#include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" - HFStripFilter::HFStripFilter(const double energyMax1, const double energyMax2, const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, @@ -34,7 +34,9 @@ HFStripFilter::~HFStripFilter() edm::LogInfo("HFStripFilter") << "destructor called"; } -void HFStripFilter::runFilter(HFRecHitCollection& rec) const +void HFStripFilter::runFilter(HFRecHitCollection& rec, + const HcalChannelQuality* myqual, + const HcalSeverityLevelComputer* mySeverity) const { if (verboseLevel_ >= 20) edm::LogInfo("HFStripFilter") << "runFilter called"; diff --git a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc index 89b532703344a..b537363492a9c 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc @@ -289,7 +289,7 @@ HFPhase1Reconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup) // Step 4: Run HFStripFilter if requested if (runHFStripFilter_) - hfStripFilter_->runFilter(*rec); + hfStripFilter_->runFilter(*rec, myqual, mySeverity); } // Add the output collection to the event record From 36efcf07809c30115ed6305f8066b0c4d27a81d4 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 15 Mar 2019 10:35:19 +0100 Subject: [PATCH 270/686] added a parameter --- .../HcalRecAlgos/interface/HFStripFilter.h | 9 ++++----- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 17 +++++++---------- .../python/HFPhase1Reconstructor_cfi.py | 3 +-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h index 091fb6a648dfd..df8bfa5054de9 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -13,11 +13,11 @@ class HFStripFilter { public: // Construct this object with all necessary parameters - HFStripFilter(double energyMax1, double energyMax2, - double stripThreshold, double maxThreshold, + HFStripFilter(double stripThreshold, double maxThreshold, double timeMax, double maxStripTime, double wedgeCut, int gap, - int lstrips, int verboseLevel); + int lstrips, int acceptSeverityLevel, + int verboseLevel); // Destructor ~HFStripFilter(); @@ -35,8 +35,6 @@ class HFStripFilter static edm::ParameterSetDescription fillDescription(); private: - double energyMax1_; - double energyMax2_; double stripThreshold_; double maxThreshold_; double timeMax_; @@ -44,6 +42,7 @@ class HFStripFilter double wedgeCut_; int gap_; int lstrips_; + int acceptSeverityLevel_; int verboseLevel_; }; diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 68c7e56cdfc8a..5d5a5be84752d 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -6,20 +6,19 @@ #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" -HFStripFilter::HFStripFilter(const double energyMax1, const double energyMax2, - const double stripThreshold, const double maxThreshold, +HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, const double wedgeCut, const int gap, - const int lstrips, const int verboseLevel) - : energyMax1_(energyMax1), - energyMax2_(energyMax2), - stripThreshold_(stripThreshold), + const int lstrips, const int acceptSeverityLevel, + const int verboseLevel) + : stripThreshold_(stripThreshold), maxThreshold_(maxThreshold), timeMax_(timeMax), maxStripTime_(maxStripTime), wedgeCut_(wedgeCut), gap_(gap), lstrips_(lstrips), + acceptSeverityLevel_(acceptSeverityLevel), verboseLevel_(verboseLevel) { // For the description of CMSSW message logging, see @@ -55,8 +54,6 @@ std::unique_ptr HFStripFilter::parseParameterSet( const edm::ParameterSet& ps) { return std::make_unique( - ps.getParameter("energyMax1"), - ps.getParameter("energyMax2"), ps.getParameter("stripThreshold"), ps.getParameter("maxThreshold"), ps.getParameter("timeMax"), @@ -64,6 +61,7 @@ std::unique_ptr HFStripFilter::parseParameterSet( ps.getParameter("wedgeCut"), ps.getParameter("gap"), ps.getParameter("lstrips"), + ps.getParameter("acceptSeverityLevel"), ps.getParameter("verboseLevel") ); } @@ -72,8 +70,6 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() { edm::ParameterSetDescription desc; - desc.add("energyMax1", -10.0); - desc.add("energyMax2", -10.0); desc.add("stripThreshold", 40.0); desc.add("maxThreshold", 100.0); desc.add("timeMax", 6.0); @@ -81,6 +77,7 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() desc.add("wedgeCut", 0.05); desc.add("gap", 2); desc.add("lstrips", 2); + desc.add("acceptSeverityLevel", 9); desc.add("verboseLevel", 0); return desc; diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index dfa2c33a4f5a8..71ba402a9c195 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -199,8 +199,6 @@ # Parameters for HFStripFilter. # Please add some descriptions of their meaning. HFStripFilter = cms.PSet( - energyMax1 = cms.double(-10.0), - energyMax2 = cms.double(-10.0), stripThreshold = cms.double(40.0), maxThreshold = cms.double(100.0), timeMax = cms.double(6.0), @@ -208,6 +206,7 @@ wedgeCut = cms.double(0.05), gap = cms.int32(2), lstrips = cms.int32(2), + acceptSeverityLevel = cms.int32(9), verboseLevel = cms.int32(20) ) ) From 75c1f6b37eddaa710988cf58ab5fdc360ce3ee4e Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Fri, 22 Mar 2019 17:35:17 +0100 Subject: [PATCH 271/686] New method runFilter --- .../HcalRecAlgos/src/HFStripFilter.cc | 311 +++++++++++++++++- 1 file changed, 304 insertions(+), 7 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 5d5a5be84752d..c0b947c6296df 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -6,6 +6,8 @@ #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" +#include + HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, const double wedgeCut, const int gap, @@ -33,23 +35,318 @@ HFStripFilter::~HFStripFilter() edm::LogInfo("HFStripFilter") << "destructor called"; } + void HFStripFilter::runFilter(HFRecHitCollection& rec, const HcalChannelQuality* myqual, const HcalSeverityLevelComputer* mySeverity) const { - if (verboseLevel_ >= 20) - edm::LogInfo("HFStripFilter") << "runFilter called"; + if (verboseLevel_ >= 20) + edm::LogInfo("HFStripFilter") << "runFilter called"; + + std::vector d1strip; + std::vector d2strip; + std::vector::const_iterator it1; + + HFRecHit d1max; + HFRecHit d2max; + + d1max.setEnergy(-10); + // find d1 and d2 seed hits with max energy and time < timeMax_ + for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + { + if ((*it).time() > timeMax_ || (*it).time() < 0 || (*it).energy() < stripThreshold_) continue; + // find HF hit with maximum signal in depth = 1 + if ((*it).id().depth() == 1) { + if ((*it).energy() > d1max.energy() && abs((*it).id().ieta()) < 35) { + d1max = (*it); + } + } + } + + if (d1max.energy() > 0) d1strip.push_back(d1max); + + int signStripIeta = 0; + int stripIphiMax = 0; + int stripIetaMax = 0; + + if (d1max.energy() > 0) { + signStripIeta = d1max.id().ieta()/fabs(d1max.id().ieta()); + stripIphiMax = d1max.id().iphi(); + stripIetaMax = d1max.id().ieta(); + } - // Cycle over the rechit collection - for (HFRecHitCollection::iterator it = rec.begin(); it != rec.end(); ++it) + d2max.setEnergy(-10); + for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) { - // Figure out which rechits need to be tagged + if ((*it).time() > timeMax_ || (*it).time() < 0 || (*it).energy() < stripThreshold_) continue; + // find HFhit with maximum signal in depth = 2 + if ((*it).id().depth() == 2 && (*it).energy() > d2max.energy() && abs((*it).id().ieta()) < 35) { + if (d1max.energy() > 0) { + int signIeta = (*it).id().ieta()/fabs((*it).id().ieta()); + if ((*it).id().iphi() == stripIphiMax && signIeta == signStripIeta) { + d2max = (*it); + } + } else { + d2max = (*it); + } + } + } + + if (d2max.energy() > 0) d2strip.push_back(d2max); + + // check if possible seed hits have energies not too small + if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; + + if (stripIphiMax == 0 && d2max.energy() > 0) { + signStripIeta = d2max.id().ieta()/fabs(d2max.id().ieta()); + stripIphiMax = d2max.id().iphi(); + stripIetaMax = d2max.id().ieta(); + } + + if (verboseLevel_ >= 30) { + std::stringstream ss; + if (d1max.energy() > 0) { + ss << " MaxHit in Depth 1: ieta = " << d1max.id().ieta() << " iphi = " << stripIphiMax + << " energy = " << d1max.energy() << " time = " << d1max.time() << std::endl; } + if (d2max.energy() > 0) { + ss << " MaxHit in Depth 2: ieta = " << d2max.id().ieta() << " iphi = " << d2max.id().iphi() + << " energy = " << d2max.energy() << " time = " << d2max.time() << std::endl; } + ss << " stripThreshold_ = " << stripThreshold_ << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } - // To tag a rechit with the anomalous hit flag, do the following - it->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); + // prepare the strips: all hits along given ieta in one wedge (d1strip and d2strip) + //--------------------------------------------------------------------------------- + for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + { + if ((*it).energy() < stripThreshold_) continue; + int signIeta = (*it).id().ieta()/fabs((*it).id().ieta()); + + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " HF hit: ieta = " << (*it).id().ieta() << "\t iphi = " << (*it).id().iphi() + << "\t depth = " << (*it).id().depth() << "\t time = " << (*it).time() << "\t energy = " + << (*it).energy() << "\t flags = " << (*it).flags() << std::endl; + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + + // collect hits with the same iphi but different ieta into strips + if ((*it).id().iphi() == stripIphiMax && signIeta == signStripIeta + && (*it).time() < maxStripTime_) { + if ((*it).id().depth() == 1) { + // check if hit = (*it) is already in d1strip + bool pass = false; + if (d1strip.size() == 0) { + if (abs((*it).id().iphi() - stripIetaMax) <= gap_) { + d1strip.push_back((*it)); + pass = true; + } + } else { + for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { + if ((*it).id().ieta() == (*it1).id().ieta() && (*it).energy() == (*it1).energy()) { + pass = true; + break; + } + } + } + if (pass) continue; + // add hit = (*it) to d1strip if distance to the closest hit in d1strip <= gap_ + for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { + // check distance along Ieta to the closest hit + if (abs((*it1).id().ieta() - (*it).id().ieta()) <= gap_) { + d1strip.push_back((*it)); + break; + } + } + } + else if ((*it).id().depth() == 2) { + // check if hit = (*it) is already in d2strip + bool pass= false; + if (d2strip.size() == 0) { + if (abs((*it).id().ieta() - stripIetaMax) <= gap_) { + d2strip.push_back((*it)); + pass = true; + } + } else { + for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { + if ((*it).id().ieta() == (*it1).id().ieta() && (*it).energy() == (*it1).energy()) { + pass = true; + break; + } + } + } + if (pass) continue; + + // add hit = (*it) to d2strip if distance to the closest hit in d1strip <= gap_ + for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { + // check distance along Ieta to the closest hit + if (abs((*it1).id().ieta() - (*it).id().ieta()) <= gap_) { + d2strip.push_back((*it)); + break; + } + } + } + } } + + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " Lstrip1 = " << (int)d1strip.size() << " (iphi = " << stripIphiMax + << ") Lstrip2 = " << (int)d2strip.size() << std::endl << " Strip1: "; + for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { + ss << (*it1).energy() << " (" << (*it1).id().ieta() << ") "; } + ss << std::endl << " Strip2: "; + for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { + ss << (*it1).energy() << " (" << (*it1).id().ieta() << ") "; } + ss << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + + // check if one of strips in depth1 or depth2 >= lstrips_ + if ((int)d1strip.size() < lstrips_ && (int)d2strip.size() < lstrips_) return; + + // define range of strips in ieta + int ietaMin1 = 1000; // for d1strip + int ietaMax1 = -1000; + for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin1) ietaMin1 = (*it1).id().ieta(); + if ((*it1).id().ieta() > ietaMax1) ietaMax1 = (*it1).id().ieta(); + } + int ietaMin2 = 1000; // for d2strip + int ietaMax2 = -1000; + for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin2) ietaMin2 = (*it1).id().ieta(); + if ((*it1).id().ieta() > ietaMax2) ietaMax2 = (*it1).id().ieta(); + } + + // define ietamin and ietamax - common area for d1strip and d2strip + int ietaMin = ietaMin1; + int ietaMax = ietaMax1; + + if (ietaMin2 >= ietaMin1 && ietaMin2 <= ietaMax1) { + if (ietaMax2 > ietaMax1) ietaMax = ietaMax2; + } else if (ietaMin2 <= ietaMin1 && ietaMax2 >= ietaMin1) { + if (ietaMin2 < ietaMin1) ietaMin = ietaMin2; + if (ietaMax2 > ietaMax1) ietaMax = ietaMax2; + } + + // calculate the total energy in strips + double eStrip = 0; + for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; + eStrip += (*it1).energy(); + } + for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; + eStrip += (*it1).energy(); + } + + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " ietaMin1 = " << ietaMin1 << " ietaMax1 = " << ietaMax1 << std::endl + << " ietaMin2 = " << ietaMin2 << " ietaMax2 = " << ietaMax2 << std::endl + << " Common strip: ietaMin = " << ietaMin << " ietaMax = " << ietaMax << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + + int phiseg = 2; // 10 degrees segmentation for most of HF (1 iphi unit = 5 degrees) + if (abs(d1strip[0].id().ieta()) > 39) phiseg = 4; // 20 degrees segmentation for |ieta| > 39 + + // Check if seed hit has neighbours with (iphi +/- phiseg) and the same ieta + int iphi1 = d1strip[0].id().iphi() - phiseg; + while (iphi1 < 0) iphi1 += 72; + int iphi2 = d1strip[0].id().iphi() + phiseg; + while (iphi2 > 72) iphi2 -= 72; + + // energies in the neighboring wedges + double energyIphi1 = 0; + double energyIphi2 = 0; + for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + { + if ((*it).energy() < stripThreshold_) continue; + if ((*it).id().ieta() < ietaMin || (*it).id().ieta() > ietaMax) continue; + if ((*it).id().iphi() == iphi1) energyIphi1 += (*it).energy(); // iphi1 + else if ((*it).id().iphi() == iphi2) energyIphi2 += (*it).energy(); // iphi2 + } + + double ratio1 = eStrip > 0 ? energyIphi1/eStrip : 0; + double ratio2 = eStrip > 0 ? energyIphi2/eStrip : 0; + + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " iphi = " << d1strip[0].id().iphi() << " iphi1 = " << iphi1 << " iphi2 = " + << iphi2 << std::endl + << " Estrip = " << eStrip << " EnergyIphi1 = " << energyIphi1 + << " Ratio = " << ratio1 << std::endl + << " " << " EnergyIphi2 = " << energyIphi2 + << " Ratio = " << ratio2 << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + + // check if our wedge does not have substantial leak into adjacent wedges + if (ratio1 < wedgeCut_ && ratio2 < wedgeCut_) { // noise event with strips (d1 and/or d2) + + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " stripPass = false" << std::endl + << " mark hits in strips now " << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + + // Figure out which rechits need to be tagged (d1.strip) + for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; + HFRecHitCollection::iterator hit = rec.find((*it1).id()); + if (hit != rec.end()) { + // tag a rechit with the anomalous hit flag + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " d1strip: marked hit = " << (*hit) << std::endl; + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + hit->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); + } + } + // Figure out which rechits need to be tagged (d2.strip) + for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { + if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; + HFRecHitCollection::iterator hit = rec.find((*it1).id()); + if (hit != rec.end()) { + // tag a rechit with the anomalous hit flag + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " d2strip: marked hit = " << (*hit) << std::endl; + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + hit->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); + } + } + } + else { + if (verboseLevel_ >= 30) { + std::stringstream ss; + ss << " stripPass = true" << std::endl; + + //edm::LogInfo("HFStripFilter") << ss.str(); + std::cout << ss.str(); + } + } } + std::unique_ptr HFStripFilter::parseParameterSet( const edm::ParameterSet& ps) { From 0e7c885515d1d2deeab7af947a4e24f782770487 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Fri, 22 Mar 2019 18:14:06 +0100 Subject: [PATCH 272/686] Removed unused parameters --- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index c0b947c6296df..2d78093c3f82b 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -2,7 +2,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h" #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" -#include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" @@ -11,8 +10,7 @@ HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, const double wedgeCut, const int gap, - const int lstrips, const int acceptSeverityLevel, - const int verboseLevel) + const int lstrips, const int verboseLevel) : stripThreshold_(stripThreshold), maxThreshold_(maxThreshold), timeMax_(timeMax), @@ -20,7 +18,6 @@ HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThresh wedgeCut_(wedgeCut), gap_(gap), lstrips_(lstrips), - acceptSeverityLevel_(acceptSeverityLevel), verboseLevel_(verboseLevel) { // For the description of CMSSW message logging, see @@ -36,9 +33,7 @@ HFStripFilter::~HFStripFilter() } -void HFStripFilter::runFilter(HFRecHitCollection& rec, - const HcalChannelQuality* myqual, - const HcalSeverityLevelComputer* mySeverity) const +void HFStripFilter::runFilter(HFRecHitCollection& rec) const { if (verboseLevel_ >= 20) edm::LogInfo("HFStripFilter") << "runFilter called"; @@ -358,7 +353,6 @@ std::unique_ptr HFStripFilter::parseParameterSet( ps.getParameter("wedgeCut"), ps.getParameter("gap"), ps.getParameter("lstrips"), - ps.getParameter("acceptSeverityLevel"), ps.getParameter("verboseLevel") ); } @@ -374,7 +368,6 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() desc.add("wedgeCut", 0.05); desc.add("gap", 2); desc.add("lstrips", 2); - desc.add("acceptSeverityLevel", 9); desc.add("verboseLevel", 0); return desc; From a0d7fcd3d14f0d608a320470949ab3a5c507996e Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Fri, 22 Mar 2019 18:14:23 +0100 Subject: [PATCH 273/686] Removed unused parameters --- RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h index df8bfa5054de9..0cd2da211e6f8 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -6,9 +6,6 @@ #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -class HcalChannelQuality; -class HcalSeverityLevelComputer; - class HFStripFilter { public: @@ -16,16 +13,13 @@ class HFStripFilter HFStripFilter(double stripThreshold, double maxThreshold, double timeMax, double maxStripTime, double wedgeCut, int gap, - int lstrips, int acceptSeverityLevel, - int verboseLevel); + int lstrips, int verboseLevel); // Destructor ~HFStripFilter(); // The actual rechit tagging is performed by the following function - void runFilter(HFRecHitCollection& rec, - const HcalChannelQuality* myqual, - const HcalSeverityLevelComputer* mySeverity) const; + void runFilter(HFRecHitCollection& rec) const; // Parser function to create this object from a parameter set static std::unique_ptr parseParameterSet( @@ -42,7 +36,6 @@ class HFStripFilter double wedgeCut_; int gap_; int lstrips_; - int acceptSeverityLevel_; int verboseLevel_; }; From dff5e80df1426c3e499ed731002743feeae75ac5 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Fri, 22 Mar 2019 18:16:06 +0100 Subject: [PATCH 274/686] HFStripFilter: Removed unused parameters --- .../HcalRecProducers/python/HFPhase1Reconstructor_cfi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index 71ba402a9c195..e97f8899ce925 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -206,7 +206,6 @@ wedgeCut = cms.double(0.05), gap = cms.int32(2), lstrips = cms.int32(2), - acceptSeverityLevel = cms.int32(9), verboseLevel = cms.int32(20) ) ) From b25c575c3038cf0140ae4433c76e13e04da70715 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Fri, 22 Mar 2019 18:16:48 +0100 Subject: [PATCH 275/686] HFStripFilter: Removed unused parameters --- RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc index b537363492a9c..89b532703344a 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc @@ -289,7 +289,7 @@ HFPhase1Reconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup) // Step 4: Run HFStripFilter if requested if (runHFStripFilter_) - hfStripFilter_->runFilter(*rec, myqual, mySeverity); + hfStripFilter_->runFilter(*rec); } // Add the output collection to the event record From 7d049a35be3d86d507906a3e06a39fb33411ab49 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Sat, 23 Mar 2019 14:33:06 +0100 Subject: [PATCH 276/686] Modified debuggung printout --- .../HcalRecAlgos/src/HFStripFilter.cc | 46 +++++-------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 2d78093c3f82b..4707640c5a5cf 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -5,7 +5,6 @@ #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" -#include HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, @@ -98,8 +97,8 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const stripIetaMax = d2max.id().ieta(); } + std::stringstream ss; if (verboseLevel_ >= 30) { - std::stringstream ss; if (d1max.energy() > 0) { ss << " MaxHit in Depth 1: ieta = " << d1max.id().ieta() << " iphi = " << stripIphiMax << " energy = " << d1max.energy() << " time = " << d1max.time() << std::endl; } @@ -107,9 +106,6 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const ss << " MaxHit in Depth 2: ieta = " << d2max.id().ieta() << " iphi = " << d2max.id().iphi() << " energy = " << d2max.energy() << " time = " << d2max.time() << std::endl; } ss << " stripThreshold_ = " << stripThreshold_ << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } // prepare the strips: all hits along given ieta in one wedge (d1strip and d2strip) @@ -120,12 +116,9 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const int signIeta = (*it).id().ieta()/fabs((*it).id().ieta()); if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " HF hit: ieta = " << (*it).id().ieta() << "\t iphi = " << (*it).id().iphi() << "\t depth = " << (*it).id().depth() << "\t time = " << (*it).time() << "\t energy = " << (*it).energy() << "\t flags = " << (*it).flags() << std::endl; - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } // collect hits with the same iphi but different ieta into strips @@ -188,7 +181,6 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const } if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " Lstrip1 = " << (int)d1strip.size() << " (iphi = " << stripIphiMax << ") Lstrip2 = " << (int)d2strip.size() << std::endl << " Strip1: "; for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { @@ -197,13 +189,15 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { ss << (*it1).energy() << " (" << (*it1).id().ieta() << ") "; } ss << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } // check if one of strips in depth1 or depth2 >= lstrips_ - if ((int)d1strip.size() < lstrips_ && (int)d2strip.size() < lstrips_) return; + if ((int)d1strip.size() < lstrips_ && (int)d2strip.size() < lstrips_) { + if (verboseLevel_ >= 30) { + LogDebug("HFSFilter") << ss.str(); + } + return; + } // define range of strips in ieta int ietaMin1 = 1000; // for d1strip @@ -242,13 +236,9 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const } if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " ietaMin1 = " << ietaMin1 << " ietaMax1 = " << ietaMax1 << std::endl << " ietaMin2 = " << ietaMin2 << " ietaMax2 = " << ietaMax2 << std::endl << " Common strip: ietaMin = " << ietaMin << " ietaMax = " << ietaMax << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } int phiseg = 2; // 10 degrees segmentation for most of HF (1 iphi unit = 5 degrees) @@ -275,28 +265,20 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const double ratio2 = eStrip > 0 ? energyIphi2/eStrip : 0; if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " iphi = " << d1strip[0].id().iphi() << " iphi1 = " << iphi1 << " iphi2 = " << iphi2 << std::endl << " Estrip = " << eStrip << " EnergyIphi1 = " << energyIphi1 << " Ratio = " << ratio1 << std::endl << " " << " EnergyIphi2 = " << energyIphi2 << " Ratio = " << ratio2 << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } // check if our wedge does not have substantial leak into adjacent wedges if (ratio1 < wedgeCut_ && ratio2 < wedgeCut_) { // noise event with strips (d1 and/or d2) if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " stripPass = false" << std::endl << " mark hits in strips now " << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } // Figure out which rechits need to be tagged (d1.strip) @@ -306,10 +288,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (hit != rec.end()) { // tag a rechit with the anomalous hit flag if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " d1strip: marked hit = " << (*hit) << std::endl; - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } hit->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); } @@ -321,22 +300,19 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (hit != rec.end()) { // tag a rechit with the anomalous hit flag if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " d2strip: marked hit = " << (*hit) << std::endl; - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); } hit->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); } } + if (verboseLevel_ >= 30) { + LogDebug("HFSFilter") << ss.str(); + } } else { if (verboseLevel_ >= 30) { - std::stringstream ss; ss << " stripPass = true" << std::endl; - - //edm::LogInfo("HFStripFilter") << ss.str(); - std::cout << ss.str(); + LogDebug("HFSFilter") << ss.str(); } } } From 1dd98d339b8fefc610d874023e2946c0bb68a13e Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Tue, 26 Mar 2019 12:53:12 +0100 Subject: [PATCH 277/686] changed (.size() == 0) to (.empty()) to check vector size --- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 4707640c5a5cf..2ccc251440e56 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -127,7 +127,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if ((*it).id().depth() == 1) { // check if hit = (*it) is already in d1strip bool pass = false; - if (d1strip.size() == 0) { + if (d1strip.empty()) { if (abs((*it).id().iphi() - stripIetaMax) <= gap_) { d1strip.push_back((*it)); pass = true; @@ -153,7 +153,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const else if ((*it).id().depth() == 2) { // check if hit = (*it) is already in d2strip bool pass= false; - if (d2strip.size() == 0) { + if (d2strip.empty()) { if (abs((*it).id().ieta() - stripIetaMax) <= gap_) { d2strip.push_back((*it)); pass = true; From 08520c053b9cc0c595b06d877907e296ff9a0b80 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Tue, 26 Mar 2019 14:35:52 +0100 Subject: [PATCH 278/686] changed fabs to abs for some cases --- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 2ccc251440e56..e6707e816afdd 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -64,7 +64,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const int stripIetaMax = 0; if (d1max.energy() > 0) { - signStripIeta = d1max.id().ieta()/fabs(d1max.id().ieta()); + signStripIeta = d1max.id().ieta()/abs(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); } @@ -76,7 +76,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // find HFhit with maximum signal in depth = 2 if ((*it).id().depth() == 2 && (*it).energy() > d2max.energy() && abs((*it).id().ieta()) < 35) { if (d1max.energy() > 0) { - int signIeta = (*it).id().ieta()/fabs((*it).id().ieta()); + int signIeta = (*it).id().ieta()/abs((*it).id().ieta()); if ((*it).id().iphi() == stripIphiMax && signIeta == signStripIeta) { d2max = (*it); } @@ -92,7 +92,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; if (stripIphiMax == 0 && d2max.energy() > 0) { - signStripIeta = d2max.id().ieta()/fabs(d2max.id().ieta()); + signStripIeta = d2max.id().ieta()/abs(d2max.id().ieta()); stripIphiMax = d2max.id().iphi(); stripIetaMax = d2max.id().ieta(); } @@ -113,7 +113,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) { if ((*it).energy() < stripThreshold_) continue; - int signIeta = (*it).id().ieta()/fabs((*it).id().ieta()); + int signIeta = (*it).id().ieta()/abs((*it).id().ieta()); if (verboseLevel_ >= 30) { ss << " HF hit: ieta = " << (*it).id().ieta() << "\t iphi = " << (*it).id().iphi() From 7d98c7cfd74d254cd0315b45c31bd75f68874eff Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 26 Mar 2019 15:03:08 +0100 Subject: [PATCH 279/686] Update some of the code for material budget calculation and re-arrange --- SimG4CMS/HGCalTestBeam/interface/AHCalSD.h | 33 ---- .../HGCalTestBeam/interface/HGCalTB16SD01.h | 44 ----- SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h | 47 ----- SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc | 74 ++++++-- .../{src => plugins}/HGCalTB16SD01.cc | 73 +++++--- .../HGCalTestBeam/plugins/HGCalTBAnalyzer.cc | 164 ++++++++++-------- .../plugins/HGCalTBCheckGunPosition.cc | 17 +- .../{src => plugins}/HGCalTBMB.cc | 85 ++++++--- SimG4CMS/HGCalTestBeam/plugins/module.cc | 15 -- .../HGCalTestBeam/python/hgcalTBMBCERN_cfi.py | 38 ++-- .../test/HGCalTBGenSimCERNMB_cfg.py | 47 ++--- 11 files changed, 321 insertions(+), 316 deletions(-) delete mode 100644 SimG4CMS/HGCalTestBeam/interface/AHCalSD.h delete mode 100644 SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h delete mode 100644 SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h rename SimG4CMS/HGCalTestBeam/{src => plugins}/HGCalTB16SD01.cc (59%) rename SimG4CMS/HGCalTestBeam/{src => plugins}/HGCalTBMB.cc (63%) delete mode 100644 SimG4CMS/HGCalTestBeam/plugins/module.cc diff --git a/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h b/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h deleted file mode 100644 index 720da79515bb5..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SimG4CMS_AHCalSD_h -#define SimG4CMS_AHCalSD_h - -#include "SimG4CMS/Calo/interface/CaloSD.h" - -#include -#include - -class G4Step; - -class AHCalSD : public CaloSD { - -public: - - AHCalSD(const std::string& , const DDCompactView &, const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); - ~AHCalSD() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - bool unpackIndex(const uint32_t & idx, int & row, - int& col, int& depth); -protected: - - double getEnergyDeposit(const G4Step*) override; - bool filterHit(CaloG4Hit*, double) override; - -private: - - bool useBirk; - double birk1, birk2, birk3, betaThr; - double eminHit; -}; - -#endif // AHCalSD_h diff --git a/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h b/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h deleted file mode 100644 index c24786d20e713..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SimG4CMS_HGCalTB16SD01_h -#define SimG4CMS_HGCalTB16SD01_h -/////////////////////////////////////////////////////////////////////////////// -// File: HGCalTB16SD01.h -// Description: Stores hits of Beam counters for Fermilab TB16 in appropriate -// containers -/////////////////////////////////////////////////////////////////////////////// - -#include "SimG4CMS/Calo/interface/CaloSD.h" - -#include - -class DDCompactView; -class G4Step; -class G4Material; - -class HGCalTB16SD01 : public CaloSD { - -public: - - HGCalTB16SD01(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, edm::ParameterSet const &, - const SimTrackManager*); - ~HGCalTB16SD01() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - static uint32_t packIndex(int det, int lay, int x, int y); - static void unpackIndex(const uint32_t & idx, int& det, int& lay, - int& x, int& y); - -protected: - - double getEnergyDeposit(const G4Step*) override; - -private: - void initialize(const G4StepPoint* point); - - std::string matName_; - bool useBirk_; - double birk1_, birk2_, birk3_; - bool initialize_; - G4Material* matScin_; -}; - -#endif // HGCalTB16SD01_h diff --git a/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h b/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h deleted file mode 100644 index bb53bd0ea830d..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef SimG4CMS_HGCalTestBeam_HGCalTBMB_h -#define SimG4CMS_HGCalTestBeam_HGCalTBMB_h - -#include "SimG4Core/Watcher/interface/SimWatcher.h" -#include "SimG4Core/Notification/interface/Observer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -class BeginOfTrack; -class G4Step; -class EndOfTrack; -class G4VTouchable; - -#include -#include -#include - -class HGCalTBMB : public SimWatcher, - public Observer, - public Observer, - public Observer { - -public: - - HGCalTBMB(const edm::ParameterSet&); - ~HGCalTBMB() override; - -private: - - HGCalTBMB(const HGCalTBMB&) = delete; // stop default - const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... - - void update(const BeginOfTrack*) override; - void update(const G4Step*) override; - void update(const EndOfTrack*) override; - - bool stopAfter(const G4Step*); - int findVolume(const G4VTouchable* touch, bool stop) const; - - std::vector listNames_; - std::string stopName_; - double stopZ_; - unsigned int nList_; - std::vector radLen_, intLen_, stepLen_; - std::vector me100_, me200_, me300_; -}; - -#endif diff --git a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc index 81265db76feb9..be9a434143a4e 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc @@ -1,6 +1,7 @@ -#include "SimG4CMS/HGCalTestBeam/interface/AHCalSD.h" +#include "SimG4CMS/Calo/interface/CaloSD.h" #include "SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h" #include "SimG4Core/Notification/interface/TrackInformation.h" + #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" @@ -15,8 +16,34 @@ #include "G4PhysicalConstants.hh" #include +#include +#include + //#define EDM_ML_DEBUG +class AHCalSD : public CaloSD { + +public: + + AHCalSD(const std::string& , const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, const SimTrackManager*); + ~AHCalSD() override = default; + uint32_t setDetUnitId(const G4Step* step) override; + bool unpackIndex(const uint32_t & idx, int & row, + int& col, int& depth); +protected: + + double getEnergyDeposit(const G4Step*) override; + bool filterHit(CaloG4Hit*, double) override; + +private: + + bool useBirk; + double birk1, birk2, birk3, betaThr; + double eminHit; +}; + AHCalSD::AHCalSD(const std::string& name, const DDCompactView & cpv, const SensitiveDetectorCatalog & clg, edm::ParameterSet const & p, const SimTrackManager* manager) : @@ -31,11 +58,11 @@ AHCalSD::AHCalSD(const std::string& name, const DDCompactView & cpv, birk3 = m_HC.getParameter("BirkC3"); eminHit = m_HC.getParameter("EminHit")*CLHEP::MeV; - edm::LogInfo("HcalSim") << "AHCalSD:: Use of Birks law is set to " - << useBirk << " with three constants kB = " - << birk1 << ", C1 = " << birk2 << ", C2 = " << birk3 - << "\nAHCalSD:: Threshold for storing hits: " - << eminHit << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD:: Use of Birks law is set to " + << useBirk << " with three constants kB = " + << birk1 << ", C1 = " << birk2 << ", C2 = " + << birk3 << "\nAHCalSD:: Threshold for storing" + << " hits: " << eminHit; } double AHCalSD::getEnergyDeposit(const G4Step* aStep) { @@ -48,8 +75,8 @@ double AHCalSD::getEnergyDeposit(const G4Step* aStep) { #endif if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3); #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: weight " << weight0 << " " << weight - << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " + << weight; #endif double edep = weight*destep; return edep; @@ -69,15 +96,15 @@ uint32_t AHCalSD::setDetUnitId(const G4Step * aStep) { int row = (jnrow == 0) ? inrow : -inrow; uint32_t index = AHCalDetId(row,col,depth).rawId(); #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: det = " << HcalOther - << " depth = " << depth << " row = " << row - << " column = " << col << " packed index = 0x" - << std::hex << index << std::dec << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: det = " << HcalOther + << " depth = " << depth << " row = " << row + << " column = " << col << " packed index = 0x" + << std::hex << index << std::dec; bool flag = unpackIndex(index, row, col, depth); - edm::LogInfo("HcalSim") << "Results from unpacker for 0x" << std::hex - << index << std::dec << " Flag " << flag << " Row " - << row << " Col " << col << " Depth " << depth - << std::endl; + edm::LogVerbatim("HcalSim") << "Results from unpacker for 0x" << std::hex + << index << std::dec << " Flag " << flag + << " Row " << row << " Col " << col << " Depth " + << depth; #endif return index; } @@ -94,9 +121,10 @@ bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) { depth = AHCalDetId(idx).depth(); } #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: packed index = 0x" << std::hex << idx - << std::dec << " Row " << row << " Column " << col - << " Depth " << depth << " OK " << rcode << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: packed index = 0x" << std::hex + << idx << std::dec << " Row " << row + << " Column " << col << " Depth " << depth + << " OK " << rcode; #endif return rcode; } @@ -104,3 +132,11 @@ bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) { bool AHCalSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit)); } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +typedef AHCalSD AHcalSensitiveDetector; +DEFINE_SENSITIVEDETECTOR(AHcalSensitiveDetector); + diff --git a/SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc similarity index 59% rename from SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc rename to SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc index e40e90299e058..ba7a95bc74311 100644 --- a/SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc @@ -1,9 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// -// File: HGCalTB16SD01.cc -// Description: Sensitive Detector class for beam counters in TB06 setup -/////////////////////////////////////////////////////////////////////////////// - -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h" +#include "SimG4CMS/Calo/interface/CaloSD.h" #include "SimG4Core/Notification/interface/TrackInformation.h" #include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" @@ -19,9 +14,39 @@ #include "G4LogicalVolumeStore.hh" #include "CLHEP/Units/GlobalSystemOfUnits.h" +#include + //#define EDM_ML_DEBUG -HGCalTB16SD01::HGCalTB16SD01(const std::string& name, const DDCompactView & cpv, +class HGCalTB16SD01 : public CaloSD { + +public: + + HGCalTB16SD01(const std::string& , const DDCompactView &, + const SensitiveDetectorCatalog &, edm::ParameterSet const &, + const SimTrackManager*); + ~HGCalTB16SD01() override = default; + uint32_t setDetUnitId(const G4Step* step) override; + static uint32_t packIndex(int det, int lay, int x, int y); + static void unpackIndex(const uint32_t & idx, int& det, int& lay, + int& x, int& y); + +protected: + + double getEnergyDeposit(const G4Step*) override; + +private: + void initialize(const G4StepPoint* point); + + std::string matName_; + bool useBirk_; + double birk1_, birk2_, birk3_; + bool initialize_; + G4Material* matScin_; +}; + +HGCalTB16SD01::HGCalTB16SD01(const std::string& name, + const DDCompactView & cpv, const SensitiveDetectorCatalog & clg, edm::ParameterSet const & p, const SimTrackManager* manager) : @@ -36,10 +61,10 @@ HGCalTB16SD01::HGCalTB16SD01(const std::string& name, const DDCompactView & cpv, birk3_ = m_HC.getParameter("BirkC3"); matScin_ = nullptr; - edm::LogInfo("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " - << useBirk_ << " for " << matName_ - << " with three constants kB = " << birk1_ - << ", C1 = " << birk2_ << ", C2 = " << birk3_; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " + << useBirk_ << " for " << matName_ + << " with three constants kB = " << birk1_ + << ", C1 = " << birk2_ << ", C2 = " << birk3_; } double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) { @@ -53,10 +78,10 @@ double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) { weight *= getAttenuation(aStep, birk1_, birk2_, birk3_); } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Detector " - << point->GetTouchable()->GetVolume()->GetName() << " with " - << point->GetMaterial()->GetName() << " weight " << weight - << ":" << wt2 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " + << point->GetTouchable()->GetVolume()->GetName() + << " with " << point->GetMaterial()->GetName() + << " weight " << weight << ":" << wt2; #endif return weight*destep; } @@ -86,9 +111,10 @@ uint32_t HGCalTB16SD01::packIndex(int det, int lay, int x, int y) { idx += (ixx&511); //bits 0-8 #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Detector " << det << " Layer " << lay << " x " - << x << " " << ix << " " << ixx << " y " << y << " " << iy << " " - << iyy << " ID " << std::hex << idx << std::dec << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << det << " Layer " + << lay << " x " << x << " " << ix << " " << ixx + << " y " << y << " " << iy << " " << iyy << " ID " + << std::hex << idx << std::dec; #endif return idx; } @@ -109,7 +135,14 @@ void HGCalTB16SD01::initialize(const G4StepPoint* point) { initialize_ = false; } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Material pointer for " << matName_ - << " is initialized to : " << matScin_ << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Material pointer for " + << matName_ << " is initialized to : " <("DoPassive",false); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ << " Digis = " - << doDigis_ << ":" << sampleIndex_ << " RecHits = " << doRecHits_ - << " useDets " << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" - << ifBeam_ << " zFront " << zFrontEE_ << ":" << zFrontFH_ << ":" - << zFrontBH_ << " IdBeam " << idBeams_.size() << ":"; - for (auto id : idBeams_) std::cout << " " << id; - std::cout << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ + << " Digis = " << doDigis_ << ":" << sampleIndex_ + << " RecHits = " << doRecHits_ << " useDets " + << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" + << ifBeam_ << " zFront " << zFrontEE_ << ":" + << zFrontFH_ << ":" << zFrontBH_ << " IdBeam " + << idBeams_.size() << ":"; + for (unsigned int k=0; k(tmp0); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0; #endif std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); tok_hitsEE_ = consumes(edm::InputTag("g4SimHits",tmp1)); @@ -174,8 +177,9 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { tok_hitrEE_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifEE_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorEE_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorEE_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcFH"); @@ -186,8 +190,9 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { tok_hitrFH_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifFH_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorFH_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorFH_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcBH"); @@ -212,16 +217,17 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { #ifdef EDM_ML_DEBUG if (ifBH_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorBH_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorBH_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcBeam"); tok_hitsBeam_= consumes(edm::InputTag("g4SimHits",tmp1)); #ifdef EDM_ML_DEBUG if (ifBeam_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorBeam_ - << " with tags " << tmp1 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " + << detectorBeam_ << " with tags " << tmp1; } #endif } @@ -418,8 +424,9 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer::" << detectorEE_ << " defined with " - << hgcons_[0]->layers(false) << " layers" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorEE_ + << " defined with " << hgcons_[0]->layers(false) + << " layers"; #endif } else { hgcons_[0] = nullptr; @@ -450,8 +457,9 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer::" << detectorFH_ << " defined with " - << hgcons_[1]->layers(false) << " layers" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorFH_ + << " defined with " << hgcons_[1]->layers(false) + << " layers"; #endif } else { hgcons_[1] = nullptr; @@ -496,9 +504,10 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, p != myGenEvent->particles_end(); ++p, ++k) { if (k == 0) hBeam_->Fill((*p)->momentum().rho()); #ifdef EDM_ML_DEBUG - std::cout << "Particle[" << k << "] with p " << (*p)->momentum().rho() - << " theta " << (*p)->momentum().theta() << " phi " - << (*p)->momentum().phi() << std::endl; + edm::LogVerbatim("HGCSim") << "Particle[" << k << "] with p " + << (*p)->momentum().rho() << " theta " + << (*p)->momentum().theta() << " phi " + << (*p)->momentum().phi(); #endif } } @@ -527,8 +536,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorEE_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorEE_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -536,8 +546,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(0, caloHits, zFrontEE_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorEE_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorEE_ << " !!!"; #endif } } @@ -547,8 +557,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorFH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorFH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -556,8 +567,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(1, caloHits, zFrontFH_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorFH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorFH_ << " !!!"; #endif } } @@ -567,8 +578,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsBH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorBH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -576,8 +588,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(2, caloHits, zFrontBH_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorBH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorBH_ << " !!!"; #endif } } @@ -586,8 +598,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsBeam_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorBeam_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBeam_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -595,8 +608,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(3, caloHits, 0.0); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorBeam_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorBeam_ << " !!!"; #endif } } @@ -642,8 +655,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_digiEE_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCDigiCintainer for " << detectorEE_ << " with " - << theDigiContainers->size() << " element(s)" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCDigiCintainer for " << detectorEE_ + << " with " << theDigiContainers->size() + << " element(s)"; #endif for (auto it : *theDigiContainers) { HGCalDetId detId = (it.id()); @@ -658,8 +672,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_digiFH_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCDigiContainer for " << detectorFH_ << " with " - << theDigiContainers->size() << " element(s)" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCDigiContainer for " << detectorFH_ + << " with " << theDigiContainers->size() + << " element(s)"; #endif for (auto it : *theDigiContainers) { HGCalDetId detId = (it.id()); @@ -678,14 +693,15 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitrEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection for " << detectorEE_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorEE_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif analyzeRecHits(0, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection does not exist for " << detectorEE_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorEE_ << " !!!"; #endif } } @@ -693,14 +709,15 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitrFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection for " << detectorFH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorFH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif analyzeRecHits(1, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection does not exist for " << detectorFH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorFH_ << " !!!"; #endif }//else }//if (ifFH_) @@ -742,10 +759,11 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, idx = sector*1000+cell; } #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside << ":" - << layer << ":" << sector << ":" << subsector << ":" << cell - << ":" << depth << " Energy " << energy << " Time " << time - << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Hit[" << i << "] Id " << subdet + << ":" << zside << ":" << layer << ":" + << sector << ":" << subsector << ":" << cell + << ":" << depth << " Energy " << energy + << " Time " << time; #endif if (map_hits.count(id) != 0) { map_hits[id] += energy; @@ -794,8 +812,8 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, if (type < 2) zp = hgcons_[type]->waferZ(layer+1,false); else if (type == 2) zp = AHCalDetId((itr.second).first).getZ(); #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer+1 << " Z " << zp << ":" << zp-zFront - << " E " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " Z " << zp + << ":" << zp-zFront << " E " << energy; #endif if (type < 3) { hSimHitLng_[type]->Fill(zp-zFront,energy); @@ -830,7 +848,7 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, int layer = itr.first - 1; double energy = itr.second; #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer+1 << " " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " " << energy; #endif hSimHitLng1_[type]->Fill(layer+1,energy); if (type == 0) { @@ -894,11 +912,12 @@ void HGCalTBAnalyzer::analyzeSimTracks(edm::Handle const int vertIndex(-1); for (auto simTrkItr : *SimTk) { #ifdef EDM_ML_DEBUG - std::cout << "Track " << simTrkItr.trackId() << " Vertex " - << simTrkItr.vertIndex() << " Type " << simTrkItr.type() - << " Charge " << simTrkItr.charge() << " momentum " - << simTrkItr.momentum() << " " << simTrkItr.momentum().P() - << std::endl; + edm::LogVerbatim("HGCSim") << "Track " << simTrkItr.trackId() << " Vertex " + << simTrkItr.vertIndex() << " Type " + << simTrkItr.type() << " Charge " + << simTrkItr.charge() << " momentum " + << simTrkItr.momentum() << " " + << simTrkItr.momentum().P(); #endif if (vertIndex == -1) { vertIndex = simTrkItr.vertIndex(); @@ -909,8 +928,8 @@ void HGCalTBAnalyzer::analyzeSimTracks(edm::Handle const edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); for (int iv=0; ivposition() << std::endl; + edm::LogVerbatim("HGCSim") << "Vertex " << vertIndex << " position " + << simVtxItr->position(); #endif xBeam_ = simVtxItr->position().X(); yBeam_ = simVtxItr->position().Y(); @@ -954,8 +973,9 @@ void HGCalTBAnalyzer::analyzeRecHits (int type, map_hitCell[cell] = std::pair(detId,energy); } #ifdef EDM_ML_DEBUG - std::cout << "RecHit: " << layer << " " << global.x() << " " << global.y() - << " " << global.z() << " " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "RecHit: " << layer << " " << global.x() + << " " << global.y() << " " << global.z() + << " " << energy; #endif } @@ -964,8 +984,8 @@ void HGCalTBAnalyzer::analyzeRecHits (int type, double energy = itr.second; double zp = hgcons_[type]->waferZ(layer,true); #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer << " " << zp << " " << energy - << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer << " " << zp + << " " << energy; #endif hRecHitLng_[type]->Fill(zp,energy); hRecHitLng1_[type]->Fill(layer,energy); @@ -987,9 +1007,9 @@ void HGCalTBAnalyzer::analyzePassiveHits (edm::Handlec unsigned int id = v.id(); #ifdef EDM_ML_DEBUG double time = v.time(); - std::cout << "HGCalTBAnalyzer::analyzePassiveHits:Energy:Time:Name:Id : " - << energy << ":" << time << ":" << name << ":" << id - << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::analyzePassiveHits:Energy:" + << "Time:Name:Id : " << energy << ":" << time + << ":" << name << ":" << id; #endif if (subdet==1) { diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc index 96152541b763d..86ea0f57a0b8c 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc @@ -24,6 +24,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -32,6 +33,7 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include +//#define EDM_ML_DEBUG // // class declaration @@ -99,7 +101,7 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, iEvent.getByToken(hepMCproductLabel_, hepmc); #ifdef DebugLog if (verbosity_) - std::cout << "isHandle valid: " << isHandle valid << std::endl; + edm::LogVerbatim("HGCSim") << "isHandle valid: " << isHandle valid; #endif double x(0), y(0); @@ -108,7 +110,7 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, #ifdef DebugLog if (verbosity_) - std::cout << "vertex " << Evt->vertices_size() << std::endl; + edm::LogVerbatim("HGCSim") << "vertex " << Evt->vertices_size(); #endif for (HepMC::GenEvent::vertex_const_iterator p = Evt->vertices_begin(); p != Evt->vertices_end(); ++p) { @@ -117,10 +119,10 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, #ifdef DebugLog z = (*p)->position().z()/10.; // in cm if (verbosity_) - std::cout << " x: " << (*p)->position().x() << ":" << x - << " y: " << (*p)->position().y() << ":" << y - << " z: " << (*p)->position().z() << ":" << z - << std::endl; + edm::LogVerbatim("HGCSim") << " x: " << (*p)->position().x() << ":" + << x << " y: " << (*p)->position().y() + <<":" << y << " z: " << (*p)->position().z() + << ":" << z; #endif } }//if (genEventInfoHandle.isValid()) @@ -144,7 +146,8 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, } #ifdef DebugLog - if (verbosity_) std::cout << "Selection Flag " << flag << std::endl; + if (verbosity_) + edm::LogVerbatim("HGCSim") << "Selection Flag " << flag; #endif return flag; } diff --git a/SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc similarity index 63% rename from SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc rename to SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc index 6ee86621525e3..1cbf82d0ccec5 100644 --- a/SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc @@ -1,10 +1,11 @@ -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h" - -#include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/Exception.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "SimG4Core/Watcher/interface/SimWatcher.h" +#include "SimG4Core/Notification/interface/Observer.h" #include "SimG4Core/Notification/interface/BeginOfTrack.h" #include "SimG4Core/Notification/interface/EndOfTrack.h" @@ -12,10 +13,44 @@ #include "G4Step.hh" #include "G4Track.hh" +#include + #include +#include +#include //#define EDM_ML_DEBUG +class HGCalTBMB : public SimWatcher, + public Observer, + public Observer, + public Observer { + +public: + + HGCalTBMB(const edm::ParameterSet&); + ~HGCalTBMB() override; + +private: + + HGCalTBMB(const HGCalTBMB&) = delete; // stop default + const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... + + void update(const BeginOfTrack*) override; + void update(const G4Step*) override; + void update(const EndOfTrack*) override; + + bool stopAfter(const G4Step*); + int findVolume(const G4VTouchable* touch, bool stop) const; + + std::vector listNames_; + std::string stopName_; + double stopZ_; + unsigned int nList_; + std::vector radLen_, intLen_, stepLen_; + std::vector me100_, me200_, me300_; +}; + HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { edm::ParameterSet m_p = p.getParameter("HGCalTBMB"); @@ -23,11 +58,12 @@ HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { stopName_ = m_p.getParameter("StopName"); stopZ_ = m_p.getParameter("MaximumZ"); nList_ = listNames_.size(); - edm::LogInfo("HGCSim") << "HGCalTBMB initialized for " << nList_ <<" volumes\n"; + edm::LogVerbatim("HGCSim") << "HGCalTBMB initialized for " << nList_ + << " volumes"; for (unsigned int k=0; k tfile; if ( !tfile.isAvailable() ) @@ -53,12 +89,11 @@ HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { hist->Sumw2(true); me300_.push_back(hist); } - edm::LogInfo("HGCSim") << "HGCalTBMB: Booking user histos done ==="; + edm::LogVerbatim("HGCSim") << "HGCalTBMB: Booking user histos done ==="; } HGCalTBMB::~HGCalTBMB() { } - void HGCalTBMB::update(const BeginOfTrack* trk) { radLen_ = std::vector(nList_+1,0); @@ -70,9 +105,10 @@ void HGCalTBMB::update(const BeginOfTrack* trk) { const G4ThreeVector& mom = aTrack->GetMomentum() ; double theEnergy = aTrack->GetTotalEnergy(); int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding()); - std::cout << "MaterialBudgetHcalHistos: Track " << aTrack->GetTrackID() - << " Code " << theID << " Energy " <GetTrackID() << " Code " << theID + << " Energy " << theEnergy/CLHEP::GeV + << " GeV; Momentum " << mom ; #endif } @@ -95,10 +131,10 @@ void HGCalTBMB::update(const G4Step* aStep) { radLen_[nList_] += (step/radl); intLen_[nList_] += (step/intl); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBMB::Step in " - << touch->GetVolume(0)->GetLogicalVolume()->GetName() - << " Index " << indx <<" Step " << step << " RadL " << step/radl - << " IntL " << step/intl << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBMB::Step in " + << touch->GetVolume(0)->GetLogicalVolume()->GetName() + << " Index " << indx <<" Step " << step + << " RadL " << step/radl << " IntL " << step/intl; #endif if (stopAfter(aStep)) { @@ -116,9 +152,9 @@ void HGCalTBMB::update(const EndOfTrack* trk) { #ifdef EDM_ML_DEBUG std::string name("Total"); if (ii < nList_) name = listNames_[ii]; - std::cout << "HGCalTBMB::Volume[" << ii << "]: " << name << " == Step " - << stepLen_[ii] << " RadL " << radLen_[ii] << " IntL " - << intLen_[ii] << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBMB::Volume[" << ii << "]: " << name + << " == Step " << stepLen_[ii] << " RadL " + << radLen_[ii] << " IntL " << intLen_[ii]; #endif } } @@ -134,8 +170,9 @@ bool HGCalTBMB::stopAfter(const G4Step* aStep) { if ((findVolume(touch,true) == 0) || (zz > stopZ_)) flag = true; #ifdef EDM_ML_DEBUG - std::cout << " HGCalTBMB::Name " << touch->GetVolume(0)->GetName() << " z " - << zz << " Flag" << flag << std::endl; + edm::LogVerbatim("HGCSim") << " HGCalTBMB::Name " + << touch->GetVolume(0)->GetName() << " z " + << zz << " Flag" << flag; #endif return flag; } @@ -160,3 +197,9 @@ int HGCalTBMB::findVolume(const G4VTouchable* touch, bool stop) const { return ivol; } +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" + +DEFINE_SIMWATCHER (HGCalTBMB); + diff --git a/SimG4CMS/HGCalTestBeam/plugins/module.cc b/SimG4CMS/HGCalTestBeam/plugins/module.cc deleted file mode 100644 index 9c0b6e7b10061..0000000000000 --- a/SimG4CMS/HGCalTestBeam/plugins/module.cc +++ /dev/null @@ -1,15 +0,0 @@ -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h" -#include "SimG4CMS/HGCalTestBeam/interface/AHCalSD.h" -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h" -#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" -#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -typedef HGCalTB16SD01 HGCalTB1601SensitiveDetector; -DEFINE_SENSITIVEDETECTOR(HGCalTB1601SensitiveDetector); -typedef AHCalSD AHcalSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(AHcalSensitiveDetector); - -DEFINE_SIMWATCHER (HGCalTBMB); - diff --git a/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py b/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py index 35efb3b970e68..77bd2dbe76808 100644 --- a/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py +++ b/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py @@ -2,20 +2,24 @@ from SimG4Core.Configuration.SimG4Core_cff import * g4SimHits.Watchers = cms.VPSet(cms.PSet( - HGCalTBMB = cms.PSet( - DetectorNames = cms.vstring( - 'HGCalBeamWChamb', - 'HGCalBeamS1', - 'HGCalBeamS2', - 'HGCalBeamS3', - 'HGCalBeamS4', - 'HGCalBeamHaloCounter', - 'HGCalBeamCK3', - 'HGCalBeamMuonCounter', - ), - MaximumZ = cms.double(9500.), - StopName = cms.string("HGCal"), - ), - type = cms.string('HGCalTBMB') - ) - ) + HGCalTBMB = cms.PSet( + DetectorNames = cms.vstring( + 'HGCalBeamWChamb', + 'HGCalBeamS1', + 'HGCalBeamS2', + 'HGCalBeamS3', + 'HGCalBeamS4', + 'HGCalBeamHaloCounter', + 'HGCalBeamCK3', + 'HGCalBeamMuonCounter', + 'HGCalEE', + 'HGCalHE', + 'HGCalAH' + ), + #MaximumZ = cms.double(9500.), + MaximumZ = cms.double(950000.), + #StopName = cms.string("HGCal"), + StopName = cms.string("Junk"), + ), + type = cms.string('HGCalTBMB') +)) diff --git a/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py b/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py index 0b528af0ef2fd..057be620eda00 100644 --- a/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py +++ b/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py @@ -1,18 +1,21 @@ import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras -process = cms.Process('SIM') +process = cms.Process('SIM',eras.Phase2) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('SimG4CMS.HGCalTestBeam.HGCalTB161Module8XML_cfi') +process.load('SimG4CMS.HGCalTestBeam.HGCalTB181Oct1XML_cfi') +#process.load('SimG4CMS.HGCalTestBeam.HGCalTB161Module8XML_cfi') process.load('Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi') process.load('Geometry.HGCalCommonData.hgcalParametersInitialization_cfi') process.load('Configuration.StandardSequences.MagneticField_0T_cff') process.load('Configuration.StandardSequences.Generator_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') +#process.load('IOMC.EventVertexGenerators.VtxSmearedGauss_cfi') process.load('GeneratorInterface.Core.genFilterSummary_cff') process.load('Configuration.StandardSequences.SimIdeal_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') @@ -25,24 +28,15 @@ input = cms.untracked.int32(100) ) -process.MessageLogger = cms.Service("MessageLogger", - cout = cms.untracked.PSet( - default = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HGCSim = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - ), - categories = cms.untracked.vstring('HGCSim'), - destinations = cms.untracked.vstring('cout','cerr') -) +if 'MessageLogger' in process.__dict__: + process.MessageLogger.categories.append('HGCalGeom') + process.MessageLogger.categories.append('HGCSim') + # Input source process.source = cms.Source("EmptySource") process.options = cms.untracked.PSet( - ) # Production Info @@ -81,18 +75,23 @@ process.generator = cms.EDProducer("FlatRandomEThetaGunProducer", AddAntiParticle = cms.bool(False), PGunParameters = cms.PSet( - MinE = cms.double(9.99), - MaxE = cms.double(10.01), + MinE = cms.double(99.99), + MaxE = cms.double(100.01), MinTheta = cms.double(0.0), MaxTheta = cms.double(0.0), MinPhi = cms.double(-3.14159265359), MaxPhi = cms.double(3.14159265359), - PartID = cms.vint32(14) +# MinTheta = cms.double(.011837), +# MaxTheta = cms.double(.011837), +# MinPhi = cms.double(3.649887), +# MaxPhi = cms.double(3.649887), + PartID = cms.vint32(13) ), Verbosity = cms.untracked.int32(0), firstRun = cms.untracked.uint32(1), psethack = cms.string('single muon E 100') ) + process.VtxSmeared.MinZ = -800.0 process.VtxSmeared.MaxZ = -800.0 process.VtxSmeared.MinX = 0 @@ -102,7 +101,6 @@ process.HGCalTBAnalyzer.DoDigis = False process.HGCalTBAnalyzer.DoRecHits = False - # Path and EndPath definitions process.generation_step = cms.Path(process.pgen) process.simulation_step = cms.Path(process.psim) @@ -112,7 +110,14 @@ process.RAWSIMoutput_step = cms.EndPath(process.RAWSIMoutput) # Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.analysis_step,process.endjob_step,process.RAWSIMoutput_step) +process.schedule = cms.Schedule( + process.generation_step, + process.genfiltersummary_step, + process.simulation_step, + process.analysis_step, + process.endjob_step, + process.RAWSIMoutput_step +) # filter all path with the production filter sequence for path in process.paths: From cabf5ced80835f843c9d030e18ecb97ac5ebf04e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 26 Mar 2019 15:34:06 +0100 Subject: [PATCH 280/686] Remove extrusions --- Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml | 2 ++ Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml | 2 ++ Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc | 7 ++++--- Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml index dd7bc92537f2a..2842f8188d1ad 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml @@ -8,6 +8,7 @@ + @@ -128,6 +129,7 @@ + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml index a29744a1cf83c..3bc53cfe108f4 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml @@ -8,6 +8,7 @@ + @@ -192,6 +193,7 @@ + diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc index b7daab63abd6d..aa828ddf87842 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc @@ -99,6 +99,7 @@ void DDHGCalTBModuleX::initialize(const DDNumericArguments & nArgs, absorbW_ = nArgs["absorberW"]; absorbH_ = nArgs["absorberH"]; rMax_ = nArgs["rMax"]; + rMaxB_ = nArgs["rMaxB"]; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: zStart " << zMinBlock_ << " rFineCoarse " << rMaxFine_ @@ -106,7 +107,7 @@ void DDHGCalTBModuleX::initialize(const DDNumericArguments & nArgs, << " gap among wafers " << waferGap_ << " absorber width " << absorbW_ <<" absorber height " << absorbH_ - << " rMax " << rMax_; + << " rMax " << rMax_ << ":" << rMaxB_; #endif idNameSpace_ = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG @@ -150,12 +151,12 @@ void DDHGCalTBModuleX::constructBlocks(const DDLogicalPart& parent, #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: Block " << i << ":" << name << " z " << zi << ":" << zo - << " R " << rMax_ << " T " << blockThick_[i]; + << " R " << rMaxB_ << " T " < copies_; //List of copy #'s From 1ec760d6c986b5bcb0cc73ca6d23bfc2cd272b35 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 26 Mar 2019 15:20:21 +0100 Subject: [PATCH 281/686] Ban DQMReferenceHistogramRootFileEventSetupAnalyzer from prod sequences. The references that it loads seem to be deeply outdated, and it is a highly dangerous legacy module. --- .../python/DQMOfflineCosmics_SecondStep_cff.py | 7 +++---- .../python/DQMOfflineHeavyIons_SecondStep_cff.py | 7 +++---- .../python/DQMOffline_SecondStep_cff.py | 15 +++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/DQMOffline/Configuration/python/DQMOfflineCosmics_SecondStep_cff.py b/DQMOffline/Configuration/python/DQMOfflineCosmics_SecondStep_cff.py index 76905228d02b8..7a0c60113aac4 100644 --- a/DQMOffline/Configuration/python/DQMOfflineCosmics_SecondStep_cff.py +++ b/DQMOffline/Configuration/python/DQMOfflineCosmics_SecondStep_cff.py @@ -1,6 +1,5 @@ import FWCore.ParameterSet.Config as cms -from CondTools.DQM.DQMReferenceHistogramRootFileEventSetupAnalyzer_cfi import * from DQMServices.Components.DQMMessageLoggerClient_cff import * from DQMServices.Components.DQMDcsInfoClient_cfi import * from DQMServices.Components.DQMFastTimerServiceClient_cfi import * @@ -27,7 +26,7 @@ dqmFEDIntegrityClient ) -DQMOfflineCosmics_SecondStepDPG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineCosmics_SecondStepDPG = cms.Sequence( DQMOfflineCosmics_SecondStep_PreDPG * DQMMessageLoggerClientSeq ) @@ -49,12 +48,12 @@ SusyPostProcessorSequence ) DQMOfflineCosmics_SecondStep_PrePOG.remove(fsqClient) -DQMOfflineCosmics_SecondStepPOG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineCosmics_SecondStepPOG = cms.Sequence( DQMOfflineCosmics_SecondStep_PrePOG * DQMMessageLoggerClientSeq * dqmFastTimerServiceClient) -DQMOfflineCosmics_SecondStep = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineCosmics_SecondStep = cms.Sequence( DQMOfflineCosmics_SecondStep_PreDPG * DQMOfflineCosmics_SecondStep_PrePOG * DQMMessageLoggerClientSeq ) diff --git a/DQMOffline/Configuration/python/DQMOfflineHeavyIons_SecondStep_cff.py b/DQMOffline/Configuration/python/DQMOfflineHeavyIons_SecondStep_cff.py index 78dc0fe31bc0b..f2880f4d7ac2d 100644 --- a/DQMOffline/Configuration/python/DQMOfflineHeavyIons_SecondStep_cff.py +++ b/DQMOffline/Configuration/python/DQMOfflineHeavyIons_SecondStep_cff.py @@ -1,6 +1,5 @@ import FWCore.ParameterSet.Config as cms -from CondTools.DQM.DQMReferenceHistogramRootFileEventSetupAnalyzer_cfi import * from DQMServices.Components.DQMMessageLoggerClient_cff import * from DQMServices.Components.DQMDcsInfoClient_cfi import * from DQMServices.Components.DQMFastTimerServiceClient_cfi import * @@ -27,7 +26,7 @@ es_dqm_client_offline * dqmFEDIntegrityClient ) -DQMOfflineHeavyIons_SecondStepDPG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineHeavyIons_SecondStepDPG = cms.Sequence( DQMOfflineHeavyIons_SecondStep_PreDPG * DQMMessageLoggerClientSeq ) @@ -46,12 +45,12 @@ * hiTrackingDqmClientHeavyIons ) -DQMOfflineHeavyIons_SecondStepPOG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineHeavyIons_SecondStepPOG = cms.Sequence( DQMOfflineHeavyIons_SecondStep_PrePOG * DQMMessageLoggerClientSeq * dqmFastTimerServiceClient) -DQMOfflineHeavyIons_SecondStep = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOfflineHeavyIons_SecondStep = cms.Sequence( DQMOfflineHeavyIons_SecondStep_PreDPG * DQMOfflineHeavyIons_SecondStep_PrePOG * DQMMessageLoggerClientSeq ) diff --git a/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py b/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py index 25b759bc27589..868d73cf795cf 100644 --- a/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py +++ b/DQMOffline/Configuration/python/DQMOffline_SecondStep_cff.py @@ -1,6 +1,5 @@ import FWCore.ParameterSet.Config as cms -from CondTools.DQM.DQMReferenceHistogramRootFileEventSetupAnalyzer_cfi import * from DQMServices.Components.DQMMessageLoggerClient_cff import * from DQMServices.Components.DQMDcsInfoClient_cfi import * from DQMServices.Components.DQMFastTimerServiceClient_cfi import * @@ -33,7 +32,7 @@ dqmFEDIntegrityClient * l1TriggerDqmOfflineClient ) -DQMOffline_SecondStepDPG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOffline_SecondStepDPG = cms.Sequence( DQMOffline_SecondStep_PreDPG * DQMMessageLoggerClientSeq ) @@ -59,14 +58,14 @@ runTauEff) from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel -DQMOffline_SecondStepPOG = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOffline_SecondStepPOG = cms.Sequence( DQMOffline_SecondStep_PrePOG * DQMMessageLoggerClientSeq ) HLTMonitoringClient = cms.Sequence(trackingMonitorClientHLT * trackingForDisplacedJetMonitorClientHLT) HLTMonitoringClientPA= cms.Sequence(trackingMonitorClientHLT * PAtrackingMonitorClientHLT) -DQMOffline_SecondStep = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOffline_SecondStep = cms.Sequence( DQMOffline_SecondStep_PreDPG * DQMOffline_SecondStep_PrePOG * HLTMonitoringClient * @@ -82,11 +81,11 @@ DQMOffline_SecondStep_PrePOGMC = cms.Sequence( bTagCollectorSequenceDATA ) -DQMOffline_SecondStepPOGMC = cms.Sequence( dqmRefHistoRootFileGetter * +DQMOffline_SecondStepPOGMC = cms.Sequence( DQMOffline_SecondStep_PrePOGMC * DQMMessageLoggerClientSeq ) -DQMHarvestCommon = cms.Sequence( dqmRefHistoRootFileGetter * +DQMHarvestCommon = cms.Sequence( DQMMessageLoggerClientSeq * dqmDcsInfoClient * SiStripOfflineDQMClient * @@ -99,7 +98,7 @@ runTauEff * dqmFastTimerServiceClient ) -DQMHarvestCommonSiStripZeroBias = cms.Sequence(dqmRefHistoRootFileGetter * +DQMHarvestCommonSiStripZeroBias = cms.Sequence( DQMMessageLoggerClientSeq * dqmDcsInfoClient * SiStripOfflineDQMClient * @@ -119,7 +118,7 @@ DQMHarvestPixelTracking = cms.Sequence( pixelTrackingEffFromHitPattern ) -DQMHarvestOuterTracker = cms.Sequence( dqmRefHistoRootFileGetter * +DQMHarvestOuterTracker = cms.Sequence( dqmDcsInfoClient * OuterTrackerClient * dqmFEDIntegrityClient * From d140276db594d2dc742c2172e1bd158d1da76fac Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Tue, 26 Mar 2019 15:31:07 +0100 Subject: [PATCH 282/686] Adapt tau primary vertex finding to changes in fillDescriptions, and other updates related to merging central developments --- .../PFTauPrimaryVertexProducerBase.h | 3 + ...oTauChargedHadronFromGenericTrackPlugin.cc | 2 +- .../PFTauMiniAODPrimaryVertexProducer.cc | 10 +++ .../plugins/PFTauPrimaryVertexProducer.cc | 3 +- .../RecoTauGenericJetRegionProducer.cc | 24 ++++++- .../src/PFTauPrimaryVertexProducerBase.cc | 72 +++++++++++++++++++ .../RecoTau/src/RecoTauCommonUtilities.cc | 10 +-- 7 files changed, 114 insertions(+), 10 deletions(-) diff --git a/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h index f39e4747d607c..0dc07b74028f0 100644 --- a/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h +++ b/RecoTauTag/RecoTau/interface/PFTauPrimaryVertexProducerBase.h @@ -16,6 +16,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" @@ -53,6 +54,8 @@ class PFTauPrimaryVertexProducerBase : public edm::stream::EDProducer<> { ~PFTauPrimaryVertexProducerBase() override; void produce(edm::Event&,const edm::EventSetup&) override; + static edm::ParameterSetDescription getDescriptionsBase(); + // called at the beginning of every event - override if necessary virtual void beginEvent(const edm::Event&, const edm::EventSetup&) {} diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc index 9a0202a6c148f..3b4d34a9478e6 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromGenericTrackPlugin.cc @@ -270,7 +270,7 @@ typename PFRecoTauChargedHadronFromGenericTrackPlugin::return_type P // XYZTLorentzVector chargedPionPos(getTrackPos(track)); RawParticle p(chargedPionP4, chargedPionPos); - p.setCharge(track->charge()); + p.setCharge(track.charge()); BaseParticlePropagator trackPropagator(p, 0., 0., magneticFieldStrength_.z()); trackPropagator.propagateToEcalEntrance(false); if ( trackPropagator.getSuccess() != 0 ) { diff --git a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc index cee8fa267fdf6..5f59ed2dc7f77 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc @@ -11,6 +11,7 @@ class PFTauMiniAODPrimaryVertexProducer final : public PFTauPrimaryVertexProduce ~PFTauMiniAODPrimaryVertexProducer() override; void beginEvent(const edm::Event&, const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); protected: void nonTauTracksInPV(const reco::VertexRef&, @@ -88,4 +89,13 @@ void PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands(const si } } +void +PFTauMiniAODPrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + auto desc = PFTauPrimaryVertexProducerBase::getDescriptionsBase(); + desc.add("lostCandidatesTag", edm::InputTag("lostTracks")); + desc.add("packedCandidatesTag", edm::InputTag("packedPFCandidates")); + + descriptions.add("PFTauMiniAODPrimaryVertexProducer", desc); +} + DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 06ba41ed1fb50..64e808a9c0cdc 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -42,7 +42,8 @@ void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRe void PFTauPrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - PFTauPrimaryVertexProducerBase::fillDescriptionsBase(descriptions, "PFTauPrimaryVertexProducer"); + auto desc = PFTauPrimaryVertexProducerBase::getDescriptionsBase(); + descriptions.add("PFTauPrimaryVertexProducer", desc); } DEFINE_FWK_MODULE(PFTauPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc index 46fb7cab330f4..458d1e17ffe86 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauGenericJetRegionProducer.cc @@ -47,6 +47,7 @@ class RecoTauGenericJetRegionProducer : public edm::stream::EDProducer<> void produce(edm::Event& evt, const edm::EventSetup& es) override; static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + static void fillDescriptionsBase(edm::ConfigurationDescriptions & descriptions, const std::string& name); private: std::string moduleLabel_; @@ -214,9 +215,10 @@ void RecoTauGenericJetRegionProducer::produce(edm::Event& evt evt.put(std::move(matching)); } +template void -RecoTauJetRegionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // RecoTauJetRegionProducer +RecoTauGenericJetRegionProducer::fillDescriptionsBase(edm::ConfigurationDescriptions& descriptions, const std::string& name) { + // RecoTauGenericJetRegionProducer edm::ParameterSetDescription desc; desc.add("src", edm::InputTag("ak4PFJets")); desc.add("deltaR", 0.8); @@ -225,7 +227,23 @@ RecoTauJetRegionProducer::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("maxJetAbsEta", 2.5); desc.add("minJetPt", 14.0); desc.add("pfCandSrc", edm::InputTag("particleFlow")); - descriptions.add("RecoTauJetRegionProducer", desc); + descriptions.add(name, desc); +} + + +template<> +void +RecoTauGenericJetRegionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // RecoTauGenericJetRegionProducer + RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauJetRegionProducer"); + +} + +template<> +void +RecoTauGenericJetRegionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // RecoTauGenericJetRegionProducer + RecoTauGenericJetRegionProducer::fillDescriptionsBase(descriptions, "RecoTauPatJetRegionProducer"); } typedef RecoTauGenericJetRegionProducer RecoTauJetRegionProducer; diff --git a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc index ace4e8933a9ee..eedf548ce3252 100644 --- a/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc +++ b/RecoTauTag/RecoTau/src/PFTauPrimaryVertexProducerBase.cc @@ -195,3 +195,75 @@ void PFTauPrimaryVertexProducerBase::produce(edm::Event& iEvent,const edm::Event iEvent.put(std::move(avPFTauPV)); } +edm::ParameterSetDescription PFTauPrimaryVertexProducerBase::getDescriptionsBase() { + // PFTauPrimaryVertexProducerBase + edm::ParameterSetDescription desc; + + { + edm::ParameterSetDescription vpsd1; + vpsd1.add("discriminator"); + vpsd1.add("selectionCut"); + desc.addVPSet("discriminators", vpsd1); + } + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + } + + desc.add("cut", "pt > 18.0 & abs(eta)<2.3"); + desc.add("Algorithm", 0); + desc.add("RemoveElectronTracks", false); + desc.add("RemoveMuonTracks", false); + desc.add("useBeamSpot", true); + desc.add("useSelectedTaus", false); + desc.add("beamSpot", edm::InputTag("offlineBeamSpot")); + desc.add("ElectronTag", edm::InputTag("MyElectrons")); + desc.add("PFTauTag", edm::InputTag("hpsPFTauProducer")); + desc.add("MuonTag", edm::InputTag("MyMuons")); + desc.add("PVTag", edm::InputTag("offlinePrimaryVertices")); + + return desc; +} diff --git a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc index 4e975ad0848ba..671bc413353e0 100644 --- a/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc +++ b/RecoTauTag/RecoTau/src/RecoTauCommonUtilities.cc @@ -6,7 +6,7 @@ #include "DataFormats/JetReco/interface/Jet.h" #include "DataFormats/VertexReco/interface/Vertex.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include @@ -119,12 +119,12 @@ math::XYZPointF atECALEntrance(const reco::Candidate* part, double bField) { math::XYZTLorentzVector(part->vertex().x(), part->vertex().y(), part->vertex().z(), - 0.)), - 0.,0.,bField); - theParticle.setCharge(part->charge()); + 0.)), + part->charge(), + 0.,0.,bField); theParticle.propagateToEcalEntrance(false); if(theParticle.getSuccess()!=0){ - pos = math::XYZPointF(theParticle.vertex()); + pos = math::XYZPointF(theParticle.particle().vertex()); } return pos; } From 9cd1a1523ae436dd3308f013abcd0551adb753fc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Fri, 15 Feb 2019 12:14:55 +0100 Subject: [PATCH 283/686] create L1THGCalUtilities and move ntuples --- L1Trigger/L1THGCal/plugins/BuildFile.xml | 15 --- .../test/testHGCalL1T_RelValV9_cfg.py | 22 +++-- .../L1THGCal/test/testHGCalL1T_RelVal_cfg.py | 21 +++-- L1Trigger/L1THGCalUtilities/BuildFile.xml | 9 ++ .../interface/HGCalTriggerNtupleBase.h | 4 +- .../L1THGCalUtilities/plugins/BuildFile.xml | 17 ++++ .../ntuples/HGCalTriggerNtupleEvent.cc | 2 +- .../plugins/ntuples/HGCalTriggerNtupleGen.cc | 2 +- .../ntuples/HGCalTriggerNtupleGenJet.cc | 2 +- .../ntuples/HGCalTriggerNtupleGenTau.cc | 2 +- .../ntuples/HGCalTriggerNtupleHGCClusters.cc | 2 +- .../ntuples/HGCalTriggerNtupleHGCDigis.cc | 2 +- .../HGCalTriggerNtupleHGCMulticlusters.cc | 2 +- .../ntuples/HGCalTriggerNtupleHGCPanels.cc | 2 +- .../HGCalTriggerNtupleHGCTriggerCells.cc | 2 +- .../ntuples/HGCalTriggerNtupleManager.cc | 2 +- .../ntuples/HGCalTriggerNtupleTowers.cc | 2 +- .../python/customNtuples.py | 0 .../python/hgcalTriggerNtuples_cff.py | 4 +- .../python/hgcalTriggerNtuples_cfi.py | 2 +- .../src/HGCalTriggerNtupleBase.cc | 2 +- .../test/testHGCalL1T_RelValV9_cfg.py | 91 +++++++++++++++++++ .../test/testHGCalL1T_RelVal_cfg.py | 85 +++++++++++++++++ 23 files changed, 244 insertions(+), 50 deletions(-) create mode 100644 L1Trigger/L1THGCalUtilities/BuildFile.xml rename L1Trigger/{L1THGCal => L1THGCalUtilities}/interface/HGCalTriggerNtupleBase.h (85%) create mode 100644 L1Trigger/L1THGCalUtilities/plugins/BuildFile.xml rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleEvent.cc (93%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleGen.cc (99%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleGenJet.cc (96%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleGenTau.cc (99%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc (98%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc (99%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc (98%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc (98%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc (99%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleManager.cc (96%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/plugins/ntuples/HGCalTriggerNtupleTowers.cc (97%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/python/customNtuples.py (100%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/python/hgcalTriggerNtuples_cff.py (66%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/python/hgcalTriggerNtuples_cfi.py (97%) rename L1Trigger/{L1THGCal => L1THGCalUtilities}/src/HGCalTriggerNtupleBase.cc (60%) create mode 100644 L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py create mode 100644 L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py diff --git a/L1Trigger/L1THGCal/plugins/BuildFile.xml b/L1Trigger/L1THGCal/plugins/BuildFile.xml index 9961a5d0a3bbd..028150e8acb3c 100644 --- a/L1Trigger/L1THGCal/plugins/BuildFile.xml +++ b/L1Trigger/L1THGCal/plugins/BuildFile.xml @@ -29,18 +29,3 @@ - - - - - - - - - - - - - - - diff --git a/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py b/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py index 921f8d4f75e2f..2d63cf527397e 100644 --- a/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py +++ b/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py @@ -56,11 +56,16 @@ name = cms.untracked.string('Applications') ) -# Output definition -process.TFileService = cms.Service( - "TFileService", - fileName = cms.string("ntuple.root") - ) +process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = cms.untracked.vstring( + 'keep *_hgcalBackEndLayer2Producer_*_*', + 'keep *_hgcalTowerProducer_*_*', + ), + fileName = cms.untracked.string('file:test.root') +) + # Other statements from Configuration.AlCa.GlobalTag import GlobalTag @@ -77,12 +82,11 @@ #process = custom_3dclustering_histoMax(process) -# load ntuplizer -process.load('L1Trigger.L1THGCal.hgcalTriggerNtuples_cff') -process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) +process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput) # Schedule definition -process.schedule = cms.Schedule(process.hgcl1tpg_step, process.ntuple_step) +process.schedule = cms.Schedule(process.hgcl1tpg_step, process.FEVTDEBUGoutput_step) + # Add early deletion of temporary data products to reduce peak memory need from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete diff --git a/L1Trigger/L1THGCal/test/testHGCalL1T_RelVal_cfg.py b/L1Trigger/L1THGCal/test/testHGCalL1T_RelVal_cfg.py index da476d5067508..6a0ea6591eee2 100644 --- a/L1Trigger/L1THGCal/test/testHGCalL1T_RelVal_cfg.py +++ b/L1Trigger/L1THGCal/test/testHGCalL1T_RelVal_cfg.py @@ -54,11 +54,15 @@ name = cms.untracked.string('Applications') ) -# Output definition -process.TFileService = cms.Service( - "TFileService", - fileName = cms.string("ntuple.root") - ) +process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = cms.untracked.vstring( + 'keep *_hgcalBackEndLayer2Producer_*_*', + 'keep *_hgcalTowerProducer_*_*', + ), + fileName = cms.untracked.string('file:test.root') +) # Other statements from Configuration.AlCa.GlobalTag import GlobalTag @@ -71,12 +75,11 @@ # from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_ZoltanSplit_V7 # process = custom_geometry_ZoltanSplit_V7(process) -# load ntuplizer -process.load('L1Trigger.L1THGCal.hgcalTriggerNtuples_cff') -process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) + +process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput) # Schedule definition -process.schedule = cms.Schedule(process.hgcl1tpg_step, process.ntuple_step) +process.schedule = cms.Schedule(process.hgcl1tpg_step, process.FEVTDEBUGoutput_step) # Add early deletion of temporary data products to reduce peak memory need from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete diff --git a/L1Trigger/L1THGCalUtilities/BuildFile.xml b/L1Trigger/L1THGCalUtilities/BuildFile.xml new file mode 100644 index 0000000000000..737f97aead76e --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h similarity index 85% rename from L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h rename to L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h index 3b661154c0c38..0b9d678bbdf1b 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h +++ b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h @@ -1,5 +1,5 @@ -#ifndef __L1Trigger_L1THGCal_HGCalTriggerNtupleBase_h__ -#define __L1Trigger_L1THGCal_HGCalTriggerNtupleBase_h__ +#ifndef __L1Trigger_L1THGCalUtilities_HGCalTriggerNtupleBase_h__ +#define __L1Trigger_L1THGCalUtilities_HGCalTriggerNtupleBase_h__ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" diff --git a/L1Trigger/L1THGCalUtilities/plugins/BuildFile.xml b/L1Trigger/L1THGCalUtilities/plugins/BuildFile.xml new file mode 100644 index 0000000000000..b8f17605165d6 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/plugins/BuildFile.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleEvent.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc similarity index 93% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleEvent.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc index aa94870fd1f28..a2bcbc042323f 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleEvent.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase { diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc similarity index 99% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc index fc9be6adecca4..2a2914e64704c 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc @@ -4,7 +4,7 @@ #include "DataFormats/HcalDetId/interface/HcalDetId.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "MagneticField/Engine/interface/MagneticField.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenJet.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc similarity index 96% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenJet.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc index ba0e3ade042d0..3a2915caae244 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenJet.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc @@ -2,7 +2,7 @@ #include "DataFormats/JetReco/interface/GenJet.h" #include "DataFormats/JetReco/interface/GenJetCollection.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenTau.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc similarity index 99% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenTau.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc index eb15b1a32d6bd..927f0019f4d23 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenTau.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc @@ -1,7 +1,7 @@ #include #include "DataFormats/Math/interface/LorentzVector.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "DataFormats/Math/interface/LorentzVector.h" typedef math::XYZTLorentzVector LorentzVector; diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc similarity index 98% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc index 9e688cd18c433..ddfc840807b1a 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc @@ -4,7 +4,7 @@ #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc similarity index 99% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc index 29c10d2d1ff65..7300a61f42bee 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc @@ -2,7 +2,7 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "FWCore/Framework/interface/ESHandle.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc similarity index 98% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc index 4b647db46cdbc..8c01b9624c0bf 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc @@ -1,7 +1,7 @@ #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc similarity index 98% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc index 7ed8e316158e4..92976057f49b9 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc @@ -3,7 +3,7 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc similarity index 99% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc index e599031d74e47..623726317ac51 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc @@ -8,7 +8,7 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleManager.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc similarity index 96% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleManager.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc index f9bbdda7fa263..9bfc16fa5e265 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleManager.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc @@ -6,7 +6,7 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" class HGCalTriggerNtupleManager : public edm::EDAnalyzer { diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleTowers.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc similarity index 97% rename from L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleTowers.cc rename to L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc index 761983d3a57b5..605093aa99da2 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleTowers.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc @@ -1,7 +1,7 @@ #include "DataFormats/L1THGCal/interface/HGCalTower.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" diff --git a/L1Trigger/L1THGCal/python/customNtuples.py b/L1Trigger/L1THGCalUtilities/python/customNtuples.py similarity index 100% rename from L1Trigger/L1THGCal/python/customNtuples.py rename to L1Trigger/L1THGCalUtilities/python/customNtuples.py diff --git a/L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cff.py b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cff.py similarity index 66% rename from L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cff.py rename to L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cff.py index 486cc1656b297..4c21948a576f2 100644 --- a/L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cff.py +++ b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cff.py @@ -1,11 +1,11 @@ import FWCore.ParameterSet.Config as cms -from L1Trigger.L1THGCal.hgcalTriggerNtuples_cfi import * +from L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cfi import * hgcalTriggerNtuples = cms.Sequence(hgcalTriggerNtuplizer) from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 -from L1Trigger.L1THGCal.customNtuples import custom_ntuples_V9 +from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_V9 modifyHgcalTriggerNtuplesWithV9Geometry_ = phase2_hgcalV9.makeProcessModifier(custom_ntuples_V9) diff --git a/L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cfi.py b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py similarity index 97% rename from L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cfi.py rename to L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py index 5866aafdda998..ff02a0e7b3e7f 100644 --- a/L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cfi.py +++ b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py @@ -4,7 +4,7 @@ import SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi as digiparam import RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHit_cfi as recoparam import RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi as recocalibparam -from . import hgcalLayersCalibrationCoefficients_cfi as layercalibparam +import L1Trigger.L1THGCal.hgcalLayersCalibrationCoefficients_cfi as layercalibparam fcPerMip = recoparam.HGCalUncalibRecHit.HGCEEConfig.fCPerMIP diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerNtupleBase.cc b/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc similarity index 60% rename from L1Trigger/L1THGCal/src/HGCalTriggerNtupleBase.cc rename to L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc index ec6d7970289d2..c866ee2bdfe25 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerNtupleBase.cc +++ b/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h" +#include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" EDM_REGISTER_PLUGINFACTORY(HGCalTriggerNtupleFactory, "HGCalTriggerNtupleFactory"); diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py new file mode 100644 index 0000000000000..f186b5f0b3b0d --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py @@ -0,0 +1,91 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('DIGI',eras.Phase2C4) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D35Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D35_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(50) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_10_4_0_pre2/RelValSinglePiFlatPt_0p7to10_pythia8_cfi/GEN-SIM-DIGI-RAW/103X_upgrade2023_realistic_v2_2023D35noPU-v1/10000/CE7F0A8C-F917-F14D-9BC4-CD46CFA8B7FD.root'), + inputCommands=cms.untracked.vstring( + 'keep *', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT', + 'drop l1tEMTFHit2016s_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016s_simEmtfDigis__HLT', + 'drop FTLClusteredmNewDetSetVector_mtdClusters_FTLBarrel_RECO', + 'drop FTLClusteredmNewDetSetVector_mtdClusters_FTLEndcap_RECO', + 'drop MTDTrackingRecHitedmNewDetSetVector_mtdTrackingRecHits__RECO', + 'drop BTLDetIdBTLSampleFTLDataFrameTsSorted_mix_FTLBarrel_HLT', + 'drop ETLDetIdETLSampleFTLDataFrameTsSorted_mix_FTLEndcap_HLT', + ) + ) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string('$Revision: 1.20 $'), + annotation = cms.untracked.string('SingleElectronPt10_cfi nevts:10'), + name = cms.untracked.string('Applications') +) + +# Output definition +process.TFileService = cms.Service( + "TFileService", + fileName = cms.string("ntuple.root") + ) + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# load HGCAL TPG simulation +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') +process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) +# To test V9Imp2 +from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 +process = custom_geometry_V9(process, implementation=2) +from L1Trigger.L1THGCal.customClustering import custom_2dclustering_dummy, custom_3dclustering_histoMax +process = custom_2dclustering_dummy(process) +process = custom_3dclustering_histoMax(process) + + +# load ntuplizer +process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') +process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) + +# Schedule definition +process.schedule = cms.Schedule(process.hgcl1tpg_step, process.ntuple_step) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion + diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py new file mode 100644 index 0000000000000..7dbed169884b4 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py @@ -0,0 +1,85 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras +from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim + +# For old samples use the digi converter +#process = cms.Process('DIGI',eras.Phase2,convertHGCalDigisSim) +process = cms.Process('DIGI',eras.Phase2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D17_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(50) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_10_4_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/103X_upgrade2023_realistic_v2_2023D21noPU-v1/20000/F4344045-AEDE-4240-B7B1-27D2CF96C34E.root'), + inputCommands=cms.untracked.vstring( + 'keep *', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT', + 'drop l1tEMTFHit2016s_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016s_simEmtfDigis__HLT', + ) + ) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string('$Revision: 1.20 $'), + annotation = cms.untracked.string('SingleElectronPt10_cfi nevts:10'), + name = cms.untracked.string('Applications') +) + +# Output definition +process.TFileService = cms.Service( + "TFileService", + fileName = cms.string("ntuple.root") + ) + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# load HGCAL TPG simulation +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') +process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) +# Change to V7 trigger geometry for older samples +# from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_ZoltanSplit_V7 +# process = custom_geometry_ZoltanSplit_V7(process) + +# load ntuplizer +process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') +process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) + +# Schedule definition +process.schedule = cms.Schedule(process.hgcl1tpg_step, process.ntuple_step) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion + From 93f0b0f2190034f560bd5f3ace3dad1494e1bfb9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Tue, 19 Feb 2019 12:17:01 +0100 Subject: [PATCH 284/686] Clean V9 test config files --- L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py | 3 --- .../L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py b/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py index 2d63cf527397e..7d5f1e209ba26 100644 --- a/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py +++ b/L1Trigger/L1THGCal/test/testHGCalL1T_RelValV9_cfg.py @@ -77,9 +77,6 @@ # To test V9Imp2 #from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 #process = custom_geometry_V9(process, implementation=2) -#from L1Trigger.L1THGCal.customClustering import custom_2dclustering_dummy, custom_3dclustering_histoMax -#process = custom_2dclustering_dummy(process) -#process = custom_3dclustering_histoMax(process) process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput) diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py index f186b5f0b3b0d..086c13a665caa 100644 --- a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelValV9_cfg.py @@ -70,11 +70,8 @@ process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) # To test V9Imp2 -from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 -process = custom_geometry_V9(process, implementation=2) -from L1Trigger.L1THGCal.customClustering import custom_2dclustering_dummy, custom_3dclustering_histoMax -process = custom_2dclustering_dummy(process) -process = custom_3dclustering_histoMax(process) +#from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 +#process = custom_geometry_V9(process, implementation=2) # load ntuplizer From 2b073df7318d1e86bf9622f2287ab2a09fc4cd53 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Fri, 22 Feb 2019 15:08:49 +0100 Subject: [PATCH 285/686] fix dEdx weights and use them instead of calibs for V9 geometry case --- .../hgcalLayersCalibrationCoefficients_cfi.py | 66 ++++--------------- .../python/hgcalTriggerPrimitives_cff.py | 2 + 2 files changed, 14 insertions(+), 54 deletions(-) diff --git a/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py b/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py index ebd349289ec37..ec5002153e25b 100644 --- a/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py @@ -55,7 +55,7 @@ 0.326339 ) -TrgLayer_weights = cms.vdouble(0.0, +TrgLayer_weights = cms.vdouble(0.0, 0.0183664, 0., 0.0305622, @@ -110,56 +110,14 @@ 0.328053 ) -TrgLayer_dEdX_weights = cms.vdouble(0.0, # there is no layer zero - 8.603+8.0675, # Mev - 0., - 8.0675*2, - 0., - 8.0675*2, - 0., - 8.0675*2., - 0., - 8.0675+8.9515, - 0., - 10.135*2, - 0., - 10.135*2., - 0., - 10.135*2., - 0., - 10.135*2., - 0., - 10.135+11.682, - 0., - 13.654*2., - 0., - 13.654*2., - 0., - 13.654*2., - 0., - 13.654+38.2005, - 0., - 55.0265, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 49.871, - 62.005, - 83.1675, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 92.196, - 46.098) +from RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi import dEdX + +TrgLayer_dEdX_weights = cms.vdouble() +for lid, lw in enumerate(dEdX.weights): + if lid > 29: + TrgLayer_dEdX_weights.append(lw) + else: + if (lid % 2) == 1: + TrgLayer_dEdX_weights.append(lw+dEdX.weights[lid-1]) + else: + TrgLayer_dEdX_weights.append(0) diff --git a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py b/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py index cad730b75b5d4..8277117951feb 100644 --- a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py +++ b/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py @@ -13,7 +13,9 @@ from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 +from L1Trigger.L1THGCal.customCalibration import custom_cluster_calibration_global modifyHgcalTriggerPrimitivesWithV9Geometry_ = phase2_hgcalV9.makeProcessModifier(custom_geometry_V9) +modifyHgcalTriggerPrimitivesCalibWithV9Geometry_ = phase2_hgcalV9.makeProcessModifier(lambda process : custom_cluster_calibration_global(process, factor=1)) from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim # can't declare a producer version of simHGCalUnsuppressedDigis in the normal flow of things, From 5bfd56699ae8d88dafa645d1a7b502360b1eac37 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 11 Feb 2019 12:15:48 +0100 Subject: [PATCH 286/686] More 3D cluster tunable parameters and selector modules --- DataFormats/L1THGCal/src/HGCalTriggerCell.cc | 2 +- .../backend/HGCalMulticlusteringHistoImpl.h | 6 ++ L1Trigger/L1THGCal/python/customClustering.py | 14 +++ .../backend/HGCalMulticlusteringHistoImpl.cc | 6 +- .../L1THGCalUtilities/plugins/BuildFile.xml | 8 ++ .../selectors/HGC3DClusterSimpleSelector.cc | 52 +++++++++ .../selectors/HGC3DClusterTVMASelector.cc | 100 ++++++++++++++++++ 7 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc create mode 100644 L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc diff --git a/DataFormats/L1THGCal/src/HGCalTriggerCell.cc b/DataFormats/L1THGCal/src/HGCalTriggerCell.cc index 599fb76c07bf2..74a3d0036703d 100644 --- a/DataFormats/L1THGCal/src/HGCalTriggerCell.cc +++ b/DataFormats/L1THGCal/src/HGCalTriggerCell.cc @@ -10,7 +10,7 @@ HGCalTriggerCell( const LorentzVector& p4, int qual, uint32_t detid): L1Candidate(p4, pt, eta, phi, qual), - detid_(detid) + detid_(detid), position_(), mipPt_(0) { } diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h index 6d9b8715c3a54..24f04229e58ec 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h @@ -22,6 +22,11 @@ class HGCalMulticlusteringHistoImpl{ { triggerTools_.eventSetup(es); shape_.eventSetup(es); + if (!dr_byLayer_.empty() && (dr_byLayer_.size()-1) != triggerTools_.lastLayerBH()) { + throw cms::Exception("Configuration") << + "The per-layer dR values go up to " << (dr_byLayer_.size()-1) << + ", while layers go up to " << triggerTools_.lastLayerBH() << "\n"; + } } float dR( const l1t::HGCalCluster & clu, @@ -63,6 +68,7 @@ class HGCalMulticlusteringHistoImpl{ const HGCalTriggerGeometryBase&); double dr_; + std::vector dr_byLayer_; double ptC3dThreshold_; MulticlusterType multiclusteringAlgoType_; std::string multiclusterAlgoType_; diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index 75b711b10589d..e80e72709df7c 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -80,15 +80,29 @@ def custom_3dclustering_histoMax(process, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, + seed_threshold = 0, ): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.dR_multicluster = cms.double(distance) parameters_c3d.nBins_R_histo_multicluster = cms.uint32(nBins_R) parameters_c3d.nBins_Phi_histo_multicluster = cms.uint32(nBins_Phi) parameters_c3d.binSumsHisto = binSumsHisto + parameters_c3d.threshold_histo_multicluster = seed_threshold parameters_c3d.type_multicluster = cms.string('HistoMaxC3d') return process +def custom_3dclustering_histoMax_variableDr(process, + distances = ([0] + [0.010]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + [0.040]*6 + [0.050]*6 + [0.050]*12), + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + seed_threshold = 0, + ): + process = custom_3dclustering_histoMax(process, 0, nBins_R, nBins_Phi, binSumsHisto, seed_threshold) + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster_byLayer = cms.vdouble(distances) + return process + def custom_3dclustering_histoInterpolatedMax(process, distance = 0.01, diff --git a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc index 308f124fe390e..07adbeb746b7b 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc @@ -5,6 +5,7 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::ParameterSet& conf ) : dr_(conf.getParameter("dR_multicluster")), + dr_byLayer_(conf.existsAs>("dR_multicluster_byLayer") ? conf.getParameter>("dR_multicluster_byLayer") : std::vector()), ptC3dThreshold_(conf.getParameter("minPt_multicluster")), multiclusterAlgoType_(conf.getParameter("type_multicluster")), nBinsRHisto_(conf.getParameter("nBins_R_histo_multicluster")), @@ -189,7 +190,8 @@ std::vector HGCalMulticlusteringHistoImpl::computeMaxSeeds( const H for(int bin_phi = 0; bin_phi0; + bool isMax = MIPT_seed > histoThreshold_; + if (!isMax) continue; float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; @@ -337,7 +339,7 @@ std::vector HGCalMulticlusteringHistoImpl::clusterSeedMu int z_side = triggerTools_.zside(clu->detId()); - double minDist = dr_; + double minDist = dr_byLayer_.empty() ? dr_ : dr_byLayer_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment int targetSeed = -1; for( unsigned int iseed=0; iseed + + + + + + + + diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc new file mode 100644 index 0000000000000..8651bc1630925 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc @@ -0,0 +1,52 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" + +namespace l1t { + class HGC3DClusterSimpleSelector : public edm::stream::EDProducer<> { + public: + explicit HGC3DClusterSimpleSelector(const edm::ParameterSet&) ; + ~HGC3DClusterSimpleSelector() {} + + private: + edm::EDGetTokenT src_; + StringCutObjectSelector cut_; + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + }; // class +} // namespace + +l1t::HGC3DClusterSimpleSelector::HGC3DClusterSimpleSelector(const edm::ParameterSet & iConfig) : + src_(consumes(iConfig.getParameter("src"))), + cut_(iConfig.getParameter("cut")) +{ + produces(); +} + + +void +l1t::HGC3DClusterSimpleSelector::produce(edm::Event & iEvent, const edm::EventSetup &) +{ + std::unique_ptr out(new l1t::HGCalMulticlusterBxCollection()); + + edm::Handle multiclusters; + iEvent.getByToken(src_, multiclusters); + + for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) { + for(auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { + const auto & c = *it; + if (cut_(c)) { + out->push_back(bx, c); + } + } + } + + iEvent.put(std::move(out)); +} +using l1t::HGC3DClusterSimpleSelector; +DEFINE_FWK_MODULE(HGC3DClusterSimpleSelector); diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc new file mode 100644 index 0000000000000..1fd8a1c173a71 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc @@ -0,0 +1,100 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "CommonTools/Utils/interface/StringObjectFunction.h" +#include "CommonTools/MVAUtils/interface/TMVAZipReader.h" + +#include "TMVA/Factory.h" +#include "TMVA/Reader.h" + +namespace l1t { + class HGC3DClusterTMVASelector : public edm::stream::EDProducer<> { + public: + explicit HGC3DClusterTMVASelector(const edm::ParameterSet&) ; + ~HGC3DClusterTMVASelector() {} + + private: + class Var { + public: + Var(const std::string & name, const std::string & expr) : + name_(name), expr_(expr) {} + void declare(TMVA::Reader & r) { r.AddVariable(name_, &val_); } + void fill(const l1t::HGCalMulticluster & c) { val_ = expr_(c); } + private: + std::string name_; + StringObjectFunction expr_; + float val_; + }; + + edm::EDGetTokenT src_; + StringCutObjectSelector preselection_; + std::vector variables_; + std::string method_, weightsFile_; + std::unique_ptr reader_; + StringObjectFunction wp_; + + + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + }; // class +} // namespace + +l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector(const edm::ParameterSet & iConfig) : + src_(consumes(iConfig.getParameter("src"))), + preselection_(iConfig.getParameter("preselection")), + method_(iConfig.getParameter("method")), + weightsFile_(iConfig.getParameter("weightsFile")), + reader_(new TMVA::Reader()), + wp_(iConfig.getParameter("wp")) +{ + // first create all the variables + for (const auto & psvar : iConfig.getParameter>("variables")) { + variables_.emplace_back(psvar.getParameter("name"), psvar.getParameter("value")); + } + // then declare them + for (auto & var : variables_) var.declare(*reader_); + // then read the weights + if (weightsFile_[0] != '/' && weightsFile_[0] != '.') { + weightsFile_ = edm::FileInPath(weightsFile_).fullPath(); + } + reco::details::loadTMVAWeights(&*reader_, method_, weightsFile_); + // finally, declare outputs + produces(); + produces("fail"); +} + + +void +l1t::HGC3DClusterTMVASelector::produce(edm::Event & iEvent, const edm::EventSetup &) +{ + std::unique_ptr out(new l1t::HGCalMulticlusterBxCollection()); + std::unique_ptr fail(new l1t::HGCalMulticlusterBxCollection()); + + edm::Handle multiclusters; + iEvent.getByToken(src_, multiclusters); + + for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) { + for(auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { + const auto & c = *it; + if (preselection_(c)) { + for (auto & var : variables_) var.fill(c); + float mvaOut = reader_->EvaluateMVA(method_); + if (mvaOut > wp_(c)) { + out->push_back(bx, c); + } else { + fail->push_back(bx, c); + } + } + } + } + + iEvent.put(std::move(out)); + iEvent.put(std::move(fail), "fail"); +} +using l1t::HGC3DClusterTMVASelector; +DEFINE_FWK_MODULE(HGC3DClusterTMVASelector); From a0ae813a813920064ce4ecbe48a8bc4aad9e676f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Sat, 23 Feb 2019 17:19:53 +0100 Subject: [PATCH 287/686] Switch default clustering to HistoMax --- L1Trigger/L1THGCal/python/customClustering.py | 7 ++++++- .../L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py | 9 ++------- .../L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py | 11 +++++------ .../python/hgcalTriggerNtuples_cfi.py | 1 - .../L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py | 3 --- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index e80e72709df7c..03df1645d98cd 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -91,8 +91,13 @@ def custom_3dclustering_histoMax(process, parameters_c3d.type_multicluster = cms.string('HistoMaxC3d') return process + +dr_layerbylayer = ([0] + # no layer 0 + [0.010]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + # EM + [0.040]*6 + [0.050]*6 + # FH + [0.050]*12) # BH def custom_3dclustering_histoMax_variableDr(process, - distances = ([0] + [0.010]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + [0.040]*6 + [0.050]*6 + [0.050]*12), + distances = dr_layerbylayer, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py index d418790c84368..38dce63e5f3ce 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer1Producer_cfi.py @@ -6,13 +6,8 @@ import RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi as recocalibparam from . import hgcalLayersCalibrationCoefficients_cfi as layercalibparam -C2d_parValues = cms.PSet( clusterType = cms.string('dRNNC2d'), # clustering type: dRC2d--> Geometric-dR clustering; NNC2d-->Nearest Neighbors clustering - seeding_threshold_silicon = cms.double(5), # MipT - seeding_threshold_scintillator = cms.double(5), # MipT - clustering_threshold_silicon = cms.double(2), # MipT - clustering_threshold_scintillator = cms.double(2), # MipT - dR_cluster = cms.double(6.), # in cm - calibSF_cluster=cms.double(0.), +C2d_parValues = cms.PSet( clusterType = cms.string('dummyC2d'), + calibSF_cluster=cms.double(1.), layerWeights = layercalibparam.TrgLayer_weights, applyLayerCalibration = cms.bool(True) ) diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index 2b710c15217e5..93e05495f57e4 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -5,17 +5,16 @@ import RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi as recocalibparam from L1Trigger.L1THGCal.egammaIdentification import egamma_identification_drnn_cone -from L1Trigger.L1THGCal.customClustering import binSums +from L1Trigger.L1THGCal.customClustering import binSums, dr_layerbylayer -C3d_parValues = cms.PSet( type_multicluster = cms.string('dRC3d'), - dR_multicluster = cms.double(0.01), +C3d_parValues = cms.PSet( type_multicluster = cms.string('HistoMaxC3d'), + dR_multicluster = cms.double(0.), + dR_multicluster_byLayer = cms.vdouble(dr_layerbylayer), minPt_multicluster = cms.double(0.5), # minimum pt of the multicluster (GeV) - dist_dbscan_multicluster=cms.double(0.), - minN_dbscan_multicluster=cms.uint32(0), nBins_R_histo_multicluster = cms.uint32(36), nBins_Phi_histo_multicluster = cms.uint32(216), binSumsHisto = binSums, - threshold_histo_multicluster = cms.double(20.), + threshold_histo_multicluster = cms.double(0.), EGIdentification=egamma_identification_drnn_cone.clone(), neighbour_weights=cms.vdouble( 0 , 0.25, 0 , 0.25 , 0 , 0.25, diff --git a/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py index ff02a0e7b3e7f..ab5a171886534 100644 --- a/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py +++ b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py @@ -101,7 +101,6 @@ ntuple_gentau, ntuple_digis, ntuple_triggercells, - ntuple_clusters, ntuple_multicluster, ntuple_tower ) diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py index 7dbed169884b4..00a808e58fca8 100644 --- a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_RelVal_cfg.py @@ -67,9 +67,6 @@ # load HGCAL TPG simulation process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) -# Change to V7 trigger geometry for older samples -# from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_ZoltanSplit_V7 -# process = custom_geometry_ZoltanSplit_V7(process) # load ntuplizer process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') From e6626b872661202ef0973f73d8f8b193c3573838 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Tue, 19 Feb 2019 09:38:42 +0100 Subject: [PATCH 288/686] Add multi-algo config utilities --- .../python/hgcalTriggerPrimitives_cff.py | 14 +- .../L1THGCalUtilities/python/clustering2d.py | 51 +++++++ .../L1THGCalUtilities/python/clustering3d.py | 106 +++++++++++++++ .../L1THGCalUtilities/python/concentrator.py | 44 ++++++ .../L1THGCalUtilities/python/customNtuples.py | 31 +++++ .../python/hgcalTriggerChains.py | 79 +++++++++++ .../python/hgcalTriggerNtuples_cfi.py | 8 +- L1Trigger/L1THGCalUtilities/python/vfe.py | 13 ++ .../test/testHGCalL1T_multialgo_cfg.py | 127 ++++++++++++++++++ 9 files changed, 462 insertions(+), 11 deletions(-) create mode 100644 L1Trigger/L1THGCalUtilities/python/clustering2d.py create mode 100644 L1Trigger/L1THGCalUtilities/python/clustering3d.py create mode 100644 L1Trigger/L1THGCalUtilities/python/concentrator.py create mode 100644 L1Trigger/L1THGCalUtilities/python/hgcalTriggerChains.py create mode 100644 L1Trigger/L1THGCalUtilities/python/vfe.py create mode 100644 L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_cfg.py diff --git a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py b/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py index 8277117951feb..bf6347c9c4f2f 100644 --- a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py +++ b/L1Trigger/L1THGCal/python/hgcalTriggerPrimitives_cff.py @@ -1,15 +1,15 @@ import FWCore.ParameterSet.Config as cms from L1Trigger.L1THGCal.hgcalTriggerGeometryESProducer_cfi import * -from L1Trigger.L1THGCal.hgcalVFEProducer_cfi import * -from L1Trigger.L1THGCal.hgcalConcentratorProducer_cfi import * -from L1Trigger.L1THGCal.hgcalBackEndLayer1Producer_cfi import * -from L1Trigger.L1THGCal.hgcalBackEndLayer2Producer_cfi import * -from L1Trigger.L1THGCal.hgcalTowerMapProducer_cfi import * -from L1Trigger.L1THGCal.hgcalTowerProducer_cfi import * +from L1Trigger.L1THGCal.hgcalVFE_cff import * +from L1Trigger.L1THGCal.hgcalConcentrator_cff import * +from L1Trigger.L1THGCal.hgcalBackEndLayer1_cff import * +from L1Trigger.L1THGCal.hgcalBackEndLayer2_cff import * +from L1Trigger.L1THGCal.hgcalTowerMap_cff import * +from L1Trigger.L1THGCal.hgcalTower_cff import * -hgcalTriggerPrimitives = cms.Sequence(hgcalVFEProducer*hgcalConcentratorProducer*hgcalBackEndLayer1Producer*hgcalBackEndLayer2Producer*hgcalTowerMapProducer*hgcalTowerProducer) +hgcalTriggerPrimitives = cms.Sequence(hgcalVFE*hgcalConcentrator*hgcalBackEndLayer1*hgcalBackEndLayer2*hgcalTowerMap*hgcalTower) from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V9 diff --git a/L1Trigger/L1THGCalUtilities/python/clustering2d.py b/L1Trigger/L1THGCalUtilities/python/clustering2d.py new file mode 100644 index 0000000000000..c03050115a24f --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/clustering2d.py @@ -0,0 +1,51 @@ +import FWCore.ParameterSet.Config as cms + + +def create_distance(process, inputs, + distance=6.,# cm + seed_threshold=5.,# MipT + cluster_threshold=2.# MipT + ): + producer = process.hgcalBackEndLayer1Producer.clone() + producer.ProcessorParameters.C2d_parameters.seeding_threshold_silicon = cms.double(seed_threshold) + producer.ProcessorParameters.C2d_parameters.seeding_threshold_scintillator = cms.double(seed_threshold) + producer.ProcessorParameters.C2d_parameters.clustering_threshold_silicon = cms.double(cluster_threshold) + producer.ProcessorParameters.C2d_parameters.clustering_threshold_scintillator = cms.double(cluster_threshold) + producer.ProcessorParameters.C2d_parameters.dR_cluster = cms.double(distance) + producer.ProcessorParameters.C2d_parameters.clusterType = cms.string('dRC2d') + producer.InputTriggerCells = cms.InputTag('{}:HGCalConcentratorProcessorSelection'.format(inputs)) + return producer + +def create_topological(process, inputs, + seed_threshold=5.,# MipT + cluster_threshold=2.# MipT + ): + producer = process.hgcalBackEndLayer1Producer.clone() + producer.ProcessorParameters.C2d_parameters.seeding_threshold_silicon = cms.double(seed_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.seeding_threshold_scintillator = cms.double(seed_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.clustering_threshold_silicon = cms.double(cluster_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.clustering_threshold_scintillator = cms.double(cluster_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.clusterType = cms.string('NNC2d') + producer.InputTriggerCells = cms.InputTag('{}:HGCalConcentratorProcessorSelection'.format(inputs)) + return producer + +def create_constrainedtopological(process, inputs, + distance=6.,# cm + seed_threshold=5.,# MipT + cluster_threshold=2.# MipT + ): + producer = process.hgcalBackEndLayer1Producer.clone() + producer.ProcessorParameters.C2d_parameters.seeding_threshold_silicon = cms.double(seed_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.seeding_threshold_scintillator = cms.double(seed_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.clustering_threshold_silicon = cms.double(cluster_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.clustering_threshold_scintillator = cms.double(cluster_threshold) # MipT + producer.ProcessorParameters.C2d_parameters.dR_cluster = cms.double(distance) # cm + producer.ProcessorParameters.C2d_parameters.clusterType = cms.string('dRNNC2d') + producer.InputTriggerCells = cms.InputTag('{}:HGCalConcentratorProcessorSelection'.format(inputs)) + return producer + +def create_dummy(process, inputs): + producer = process.hgcalBackEndLayer1Producer.clone() + producer.ProcessorParameters.C2d_parameters.clusterType = cms.string('dummyC2d') + producer.InputTriggerCells = cms.InputTag('{}:HGCalConcentratorProcessorSelection'.format(inputs)) + return producer diff --git a/L1Trigger/L1THGCalUtilities/python/clustering3d.py b/L1Trigger/L1THGCalUtilities/python/clustering3d.py new file mode 100644 index 0000000000000..214021d070a96 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/clustering3d.py @@ -0,0 +1,106 @@ +import FWCore.ParameterSet.Config as cms + +from L1Trigger.L1THGCal.customClustering import binSums, dr_layerbylayer + + +def create_distance(process, inputs, + distance=0.01 + ): + producer = process.hgcalBackEndLayer2Producer.clone() + producer.ProcessorParameters.C3d_parameters.dR_multicluster = cms.double(distance) + producer.ProcessorParameters.C3d_parameters.dist_dbscan_multicluster=cms.double(0.) + producer.ProcessorParameters.C3d_parameters.minN_dbscan_multicluster=cms.uint32(0) + producer.ProcessorParameters.C3d_parameters.type_multicluster = cms.string('dRC3d') + producer.InputCluster = cms.InputTag('{}:HGCalBackendLayer1Processor2DClustering'.format(inputs)) + return producer + + +def create_dbscan(process, inputs, + distance=0.005, + min_points=3 + ): + producer = process.hgcalBackEndLayer2Producer.clone() + producer.ProcessorParameters.C3d_parameters.dR_multicluster = cms.double(0.) + producer.ProcessorParameters.C3d_parameters.dist_dbscan_multicluster = cms.double(distance) + producer.ProcessorParameters.C3d_parameters.minN_dbscan_multicluster = cms.uint32(min_points) + producer.ProcessorParameters.C3d_parameters.type_multicluster = cms.string('DBSCANC3d') + producer.InputCluster = cms.InputTag('{}:HGCalBackendLayer1Processor2DClustering'.format(inputs)) + return producer + + +def create_histoMax(process, inputs, + distance = 0.03, + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + seed_threshold = 0, + ): + producer = process.hgcalBackEndLayer2Producer.clone() + producer.ProcessorParameters.C3d_parameters.dR_multicluster = cms.double(distance) + producer.ProcessorParameters.C3d_parameters.nBins_R_histo_multicluster = cms.uint32(nBins_R) + producer.ProcessorParameters.C3d_parameters.nBins_Phi_histo_multicluster = cms.uint32(nBins_Phi) + producer.ProcessorParameters.C3d_parameters.binSumsHisto = binSumsHisto + producer.ProcessorParameters.C3d_parameters.threshold_histo_multicluster = seed_threshold + producer.ProcessorParameters.C3d_parameters.type_multicluster = cms.string('HistoMaxC3d') + producer.InputCluster = cms.InputTag('{}:HGCalBackendLayer1Processor2DClustering'.format(inputs)) + return producer + + +def create_histoMax_variableDr(process, inputs, + distances = dr_layerbylayer, + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + seed_threshold = 0, + ): + producer = create_histoMax(process, inputs, 0, nBins_R, nBins_Phi, binSumsHisto, seed_threshold) + producer.ProcessorParameters.C3d_parameters.dR_multicluster_byLayer = cms.vdouble(distances) + return producer + + +def create_histoInterpolatedMax(process, inputs, + distance = 0.03, + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + ): + producer = create_histoMax( process, inputs, distance, nBins_R, nBins_Phi, binSumsHisto ) + producer.ProcessorParameters.C3d_parameters.type_multicluster = cms.string('HistoInterpolatedMaxC3d') + return producer + +def create_histoInterpolatedMax1stOrder(process, inputs): + producer = create_histoInterpolatedMax( process, inputs ) + producer.ProcessorParameters.C3d_parameters.neighbour_weights=cms.vdouble( 0 , 0.25, 0 , + 0.25 , 0 , 0.25, + 0 , 0.25, 0 + ) + return producer + + + +def create_histoInterpolatedMax2ndOrder(process, inputs): + producer = create_histoInterpolatedMax( process,inputs ) + producer.ProcessorParameters.C3d_parameters.neighbour_weights=cms.vdouble( -0.25, 0.5, -0.25, + 0.5 , 0 , 0.5 , + -0.25, 0.5, -0.25 + ) + return producer + + + +def create_histoThreshold(process, inputs, + threshold = 20., + distance = 0.03, + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + ): + producer = process.hgcalBackEndLayer2Producer.clone() + producer.ProcessorParameters.C3d_parameters.threshold_histo_multicluster = cms.double(threshold) + producer.ProcessorParameters.C3d_parameters.dR_multicluster = cms.double(distance) + producer.ProcessorParameters.C3d_parameters.nBins_R_histo_multicluster = cms.uint32(nBins_R) + producer.ProcessorParameters.C3d_parameters.nBins_Phi_histo_multicluster = cms.uint32(nBins_Phi) + producer.ProcessorParameters.C3d_parameters.binSumsHisto = binSumsHisto + producer.ProcessorParameters.C3d_parameters.type_multicluster = cms.string('HistoThresholdC3d') + producer.InputCluster = cms.InputTag('{}:HGCalBackendLayer1Processor2DClustering'.format(inputs)) + return producer diff --git a/L1Trigger/L1THGCalUtilities/python/concentrator.py b/L1Trigger/L1THGCalUtilities/python/concentrator.py new file mode 100644 index 0000000000000..f44388cebeefd --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/concentrator.py @@ -0,0 +1,44 @@ +import FWCore.ParameterSet.Config as cms +import SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi as digiparam + +def create_supertriggercell(process, inputs): + producer = process.hgcalConcentratorProducer.clone() + producer.ProcessorParameters.Method = cms.string('superTriggerCellSelect') + producer.InputTriggerCells = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + producer.InputTriggerSums = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + return producer + + +def create_threshold(process, inputs, + threshold=2. # in mipT + ): + adcSaturationBH_MIP = digiparam.hgchebackDigitizer.digiCfg.feCfg.adcSaturation_fC + adcNbitsBH = digiparam.hgchebackDigitizer.digiCfg.feCfg.adcNbits + producer = process.hgcalConcentratorProducer.clone() + producer.ProcessorParameters.Method = cms.string('thresholdSelect') + producer.ProcessorParameters.linLSB = cms.double(100./1024.) + producer.ProcessorParameters.adcsaturationBH = adcSaturationBH_MIP + producer.ProcessorParameters.adcnBitsBH = adcNbitsBH + producer.ProcessorParameters.TCThreshold_fC = cms.double(0.) + producer.ProcessorParameters.TCThresholdBH_MIP = cms.double(0.) + producer.ProcessorParameters.triggercell_threshold_silicon = cms.double(threshold) # MipT + producer.ProcessorParameters.triggercell_threshold_scintillator = cms.double(threshold) # MipT + producer.InputTriggerCells = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + producer.InputTriggerSums = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + return producer + + +def create_bestchoice(process, inputs, + triggercells=12 + ): + adcSaturationBH_MIP = digiparam.hgchebackDigitizer.digiCfg.feCfg.adcSaturation_fC + adcNbitsBH = digiparam.hgchebackDigitizer.digiCfg.feCfg.adcNbits + producer = process.hgcalConcentratorProducer.clone() + producer.ProcessorParameters.Method = cms.string('bestChoiceSelect') + producer.ProcessorParameters.NData = cms.uint32(triggercells) + producer.ProcessorParameters.linLSB = cms.double(100./1024.) + producer.ProcessorParameters.adcsaturationBH = adcSaturationBH_MIP + producer.ProcessorParameters.adcnBitsBH = adcNbitsBH + producer.InputTriggerCells = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + producer.InputTriggerSums = cms.InputTag('{}:HGCalVFEProcessorSums'.format(inputs)) + return producer diff --git a/L1Trigger/L1THGCalUtilities/python/customNtuples.py b/L1Trigger/L1THGCalUtilities/python/customNtuples.py index 8ada2eb9e7c5e..21de15da5b5f3 100644 --- a/L1Trigger/L1THGCalUtilities/python/customNtuples.py +++ b/L1Trigger/L1THGCalUtilities/python/customNtuples.py @@ -7,3 +7,34 @@ def custom_ntuples_V9(process): ntuple.NtupleName=='HGCalTriggerNtupleHGCTriggerCells': ntuple.bhSimHits = cms.InputTag('g4SimHits:HGCHitsHEback') return process + + + +def create_ntuple(process, inputs, + ntuple_list=[ + 'event', + 'gen', 'genjet', 'gentau', + 'digis', + 'triggercells', + 'clusters', 'multiclusters' + ] + ): + vpset = [] + for ntuple in ntuple_list: + pset = getattr(process, 'ntuple_'+ntuple).clone() + if ntuple=='triggercells': + pset.TriggerCells = cms.InputTag('{}:HGCalConcentratorProcessorSelection'.format(inputs[0])) + pset.Multiclusters = cms.InputTag('{}:HGCalBackendLayer2Processor3DClustering'.format(inputs[2])) + elif ntuple=='clusters': + pset.Clusters = cms.InputTag('{}:HGCalBackendLayer1Processor2DClustering'.format(inputs[1])) + pset.Multiclusters = cms.InputTag('{}:HGCalBackendLayer2Processor3DClustering'.format(inputs[2])) + elif ntuple=='multiclusters': + pset.Multiclusters = cms.InputTag('{}:HGCalBackendLayer2Processor3DClustering'.format(inputs[2])) + vpset.append(pset) + ntuplizer = process.hgcalTriggerNtuplizer.clone() + ntuplizer.Ntuples = cms.VPSet(vpset) + return ntuplizer + + + + diff --git a/L1Trigger/L1THGCalUtilities/python/hgcalTriggerChains.py b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerChains.py new file mode 100644 index 0000000000000..432ae33aef58d --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerChains.py @@ -0,0 +1,79 @@ +import FWCore.ParameterSet.Config as cms + +class HGCalTriggerChains: + def __init__(self): + self.vfe = {} + self.concentrator = {} + self.backend1 = {} + self.backend2 = {} + self.ntuple = {} + self.chain = [] + + def register_vfe(self, name, generator): + self.vfe[name] = generator + + def register_concentrator(self, name, generator): + self.concentrator[name] = generator + + def register_backend1(self, name, generator): + self.backend1[name] = generator + + def register_backend2(self, name, generator): + self.backend2[name] = generator + + def register_ntuple(self, name, generator): + self.ntuple[name] = generator + + def register_chain(self, vfe, concentrator, backend1, backend2, ntuple=''): + if not vfe in self.vfe: + raise KeyError('{} not registered as VFE producer'.format(vfe)) + if not concentrator in self.concentrator: + raise KeyError('{} not registered as concentrator producer'.format(concentrator)) + if not backend1 in self.backend1: + raise KeyError('{} not registered as backend1 producer'.format(backend1)) + if not backend2 in self.backend2: + raise KeyError('{} not registered as backend2 producer'.format(backend2)) + if ntuple!='' and not ntuple in self.ntuple: + raise KeyError('{} not registered as ntuplizer'.format(ntuple)) + self.chain.append( (vfe, concentrator, backend1, backend2, ntuple) ) + + + def create_sequences(self, process): + tmp = cms.SequencePlaceholder("tmp") + vfe_sequence = cms.Sequence(tmp) + concentrator_sequence = cms.Sequence(tmp) + backend1_sequence = cms.Sequence(tmp) + backend2_sequence = cms.Sequence(tmp) + ntuple_sequence = cms.Sequence(tmp) + for vfe,concentrator,backend1,backend2,ntuple in self.chain: + concentrator_name = '{0}{1}'.format(vfe, concentrator) + backend1_name = '{0}{1}{2}'.format(vfe, concentrator, backend1) + backend2_name = '{0}{1}{2}{3}'.format(vfe, concentrator, backend1, backend2) + ntuple_name = '{0}{1}{2}{3}{4}'.format(vfe, concentrator, backend1, backend2, ntuple) + ntuple_inputs = [concentrator_name, backend1_name, backend2_name] + if not hasattr(process, vfe): + setattr(process, vfe, self.vfe[vfe](process)) + vfe_sequence *= getattr(process, vfe) + if not hasattr(process, concentrator_name): + setattr(process, concentrator_name, self.concentrator[concentrator](process, vfe)) + concentrator_sequence *= getattr(process, concentrator_name) + if not hasattr(process, backend1_name): + setattr(process, backend1_name, self.backend1[backend1](process, concentrator_name)) + backend1_sequence *= getattr(process, backend1_name) + if not hasattr(process, backend2_name): + setattr(process, backend2_name, self.backend2[backend2](process, backend1_name)) + backend2_sequence *= getattr(process, backend2_name) + if ntuple!='' and not hasattr(process, ntuple_name): + setattr(process, ntuple_name, self.ntuple[ntuple](process, ntuple_inputs)) + ntuple_sequence *= getattr(process, ntuple_name) + vfe_sequence.remove(tmp) + concentrator_sequence.remove(tmp) + backend1_sequence.remove(tmp) + backend2_sequence.remove(tmp) + ntuple_sequence.remove(tmp) + process.globalReplace('hgcalVFE', vfe_sequence) + process.globalReplace('hgcalConcentrator', concentrator_sequence) + process.globalReplace('hgcalBackEndLayer1', backend1_sequence) + process.globalReplace('hgcalBackEndLayer2', backend2_sequence) + process.globalReplace('hgcalTriggerNtuples', ntuple_sequence) + return process diff --git a/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py index ab5a171886534..9b03570e3ed85 100644 --- a/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py +++ b/L1Trigger/L1THGCalUtilities/python/hgcalTriggerNtuples_cfi.py @@ -76,7 +76,7 @@ ) from L1Trigger.L1THGCal.egammaIdentification import egamma_identification_drnn_cone -ntuple_multicluster = cms.PSet( +ntuple_multiclusters = cms.PSet( NtupleName = cms.string('HGCalTriggerNtupleHGCMulticlusters'), Multiclusters = cms.InputTag('hgcalBackEndLayer2Producer:HGCalBackendLayer2Processor3DClustering'), EGIdentification = egamma_identification_drnn_cone.clone() @@ -87,7 +87,7 @@ TriggerCells = cms.InputTag('hgcalConcentratorProducer:HGCalConcentratorProcessorSelection') ) -ntuple_tower = cms.PSet( +ntuple_towers = cms.PSet( NtupleName = cms.string('HGCalTriggerNtupleHGCTowers'), Towers = cms.InputTag('hgcalTowerProducer:HGCalTowerProcessor') ) @@ -101,7 +101,7 @@ ntuple_gentau, ntuple_digis, ntuple_triggercells, - ntuple_multicluster, - ntuple_tower + ntuple_multiclusters, + ntuple_towers ) ) diff --git a/L1Trigger/L1THGCalUtilities/python/vfe.py b/L1Trigger/L1THGCalUtilities/python/vfe.py new file mode 100644 index 0000000000000..6c3913b3c4eb1 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/vfe.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + + +def create_compression(process, + exponent=4, + mantissa=4, + rounding=True + ): + producer = process.hgcalVFEProducer.clone() + producer.ProcessorParameters.exponentBits = cms.uint32(exponent) + producer.ProcessorParameters.mantissaBits = cms.uint32(mantissa) + producer.ProcessorParameters.rounding = cms.bool(rounding) + return producer diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_cfg.py new file mode 100644 index 0000000000000..42ab1b5672792 --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_cfg.py @@ -0,0 +1,127 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras +from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim + +# For old samples use the digi converter +#process = cms.Process('DIGI',eras.Phase2,convertHGCalDigisSim) +process = cms.Process('DIGI',eras.Phase2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D17_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(50) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/relval/CMSSW_10_4_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/103X_upgrade2023_realistic_v2_2023D21noPU-v1/20000/F4344045-AEDE-4240-B7B1-27D2CF96C34E.root'), + inputCommands=cms.untracked.vstring( + 'keep *', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT', + 'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT', + 'drop l1tEMTFHit2016s_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT', + 'drop l1tEMTFTrack2016s_simEmtfDigis__HLT', + ) + ) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string('$Revision: 1.20 $'), + annotation = cms.untracked.string('SingleElectronPt10_cfi nevts:10'), + name = cms.untracked.string('Applications') +) + +# Output definition +process.TFileService = cms.Service( + "TFileService", + fileName = cms.string("ntuple.root") + ) + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +# load HGCAL TPG simulation +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') +process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') +from L1Trigger.L1THGCalUtilities.hgcalTriggerChains import HGCalTriggerChains +import L1Trigger.L1THGCalUtilities.vfe as vfe +import L1Trigger.L1THGCalUtilities.concentrator as concentrator +import L1Trigger.L1THGCalUtilities.clustering2d as clustering2d +import L1Trigger.L1THGCalUtilities.clustering3d as clustering3d +import L1Trigger.L1THGCalUtilities.customNtuples as ntuple + + +chains = HGCalTriggerChains() +# Register algorithms +## VFE +chains.register_vfe("Floatingpoint8", lambda p : vfe.create_compression(p, 4, 4, True)) +## ECON +chains.register_concentrator("Supertriggercell", concentrator.create_supertriggercell) +chains.register_concentrator("Threshold", concentrator.create_threshold) +## BE1 +chains.register_backend1("Ref2d", clustering2d.create_constrainedtopological) +chains.register_backend1("Dummy", clustering2d.create_dummy) +## BE2 +chains.register_backend2("Ref3d", clustering3d.create_distance) +chains.register_backend2("Histomax", clustering3d.create_histoMax) +chains.register_backend2("Histomaxvardrth0", lambda p,i : clustering3d.create_histoMax_variableDr(p,i,seed_threshold=0.)) +chains.register_backend2("Histomaxvardrth10", lambda p,i : clustering3d.create_histoMax_variableDr(p,i,seed_threshold=10.)) +chains.register_backend2("Histomaxvardrth20", lambda p,i : clustering3d.create_histoMax_variableDr(p,i,seed_threshold=20.)) +# Register ntuples +# Store gen info only in the reference ntuple +ntuple_list_ref = ['event', 'gen', 'multiclusters'] +ntuple_list = ['event', 'multiclusters'] +chains.register_ntuple("Genclustersntuple", lambda p,i : ntuple.create_ntuple(p,i, ntuple_list_ref)) +chains.register_ntuple("Clustersntuple", lambda p,i : ntuple.create_ntuple(p,i, ntuple_list)) + +# Register trigger chains +## Reference chain +chains.register_chain('Floatingpoint8', "Threshold", 'Ref2d', 'Ref3d', 'Genclustersntuple') +concentrator_algos = ['Supertriggercell', 'Threshold'] +backend_algos = ['Histomax', 'Histomaxvardrth0', 'Histomaxvardrth10', 'Histomaxvardrth20'] +## Make cross product fo ECON and BE algos +import itertools +for cc,be in itertools.product(concentrator_algos,backend_algos): + chains.register_chain('Floatingpoint8', cc, 'Dummy', be, 'Clustersntuple') + +process = chains.create_sequences(process) + +# Remove towers from sequence +process.hgcalTriggerPrimitives.remove(process.hgcalTowerMap) +process.hgcalTriggerPrimitives.remove(process.hgcalTower) + +process.hgcl1tpg_step = cms.Path(process.hgcalTriggerPrimitives) +process.ntuple_step = cms.Path(process.hgcalTriggerNtuples) + +# Schedule definition +process.schedule = cms.Schedule(process.hgcl1tpg_step, process.ntuple_step) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion + From a3346fdd9a856b2dfb281514bd433bfcc7dee8c2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Wed, 27 Feb 2019 17:08:11 +0100 Subject: [PATCH 289/686] Update default clustering parameters --- L1Trigger/L1THGCal/python/customClustering.py | 12 ++++++------ .../python/hgcalBackEndLayer2Producer_cfi.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index 03df1645d98cd..bb4cba994136f 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -76,11 +76,11 @@ def custom_3dclustering_dbscan(process, def custom_3dclustering_histoMax(process, - distance = 0.01, + distance = 0.03, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, - seed_threshold = 0, + seed_threshold = 10, ): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.dR_multicluster = cms.double(distance) @@ -93,7 +93,7 @@ def custom_3dclustering_histoMax(process, dr_layerbylayer = ([0] + # no layer 0 - [0.010]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + # EM + [0.015]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + # EM [0.040]*6 + [0.050]*6 + # FH [0.050]*12) # BH def custom_3dclustering_histoMax_variableDr(process, @@ -101,7 +101,7 @@ def custom_3dclustering_histoMax_variableDr(process, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, - seed_threshold = 0, + seed_threshold = 10, ): process = custom_3dclustering_histoMax(process, 0, nBins_R, nBins_Phi, binSumsHisto, seed_threshold) parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters @@ -110,7 +110,7 @@ def custom_3dclustering_histoMax_variableDr(process, def custom_3dclustering_histoInterpolatedMax(process, - distance = 0.01, + distance = 0.03, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, @@ -146,7 +146,7 @@ def custom_3dclustering_histoInterpolatedMax2ndOrder(process): def custom_3dclustering_histoThreshold(process, threshold = 20., - distance = 0.01, + distance = 0.03, nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index 93e05495f57e4..8bb0774951627 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -14,7 +14,7 @@ nBins_R_histo_multicluster = cms.uint32(36), nBins_Phi_histo_multicluster = cms.uint32(216), binSumsHisto = binSums, - threshold_histo_multicluster = cms.double(0.), + threshold_histo_multicluster = cms.double(10.), EGIdentification=egamma_identification_drnn_cone.clone(), neighbour_weights=cms.vdouble( 0 , 0.25, 0 , 0.25 , 0 , 0.25, From 2a1bb3912fc2008080e164cdc0c819ee9f7fee22 Mon Sep 17 00:00:00 2001 From: Samuel Webb Date: Tue, 20 Nov 2018 16:35:18 +0100 Subject: [PATCH 290/686] Update clustering and STC algos --- .../L1THGCal/interface/HGCalClusterT.h | 18 +- .../L1THGCal/interface/HGCalMulticluster.h | 2 +- DataFormats/L1THGCal/src/HGCalMulticluster.cc | 4 +- DataFormats/L1THGCal/src/classes_def.xml | 13 +- .../backend/HGCalMulticlusteringHistoImpl.h | 48 ++- .../HGCalConcentratorSuperTriggerCellImpl.h | 13 +- .../HGCalConcentratorProcessorSelection.cc | 1 + L1Trigger/L1THGCal/python/customClustering.py | 81 ++++- .../python/customTriggerCellSelect.py | 10 +- .../python/hgcalBackEndLayer2Producer_cfi.py | 4 +- .../backend/HGCalMulticlusteringHistoImpl.cc | 293 ++++++++++++++---- .../HGCalConcentratorSuperTriggerCellImpl.cc | 28 +- 12 files changed, 412 insertions(+), 103 deletions(-) diff --git a/DataFormats/L1THGCal/interface/HGCalClusterT.h b/DataFormats/L1THGCal/interface/HGCalClusterT.h index 21497483d7590..fffdf5d6bfa4e 100644 --- a/DataFormats/L1THGCal/interface/HGCalClusterT.h +++ b/DataFormats/L1THGCal/interface/HGCalClusterT.h @@ -37,17 +37,20 @@ namespace l1t centre_(0, 0, 0), centreProj_(0., 0., 0.), mipPt_(0), - seedMipPt_(0){} + seedMipPt_(0), + sumPt_(0){} - HGCalClusterT( const edm::Ptr& c ): + + HGCalClusterT( const edm::Ptr& c, float fraction=1. ): valid_(true), detId_( c->detId() ), centre_(0., 0., 0.), centreProj_(0., 0., 0.), mipPt_(0.), - seedMipPt_(0.) + seedMipPt_(0.), + sumPt_(0.) { - addConstituent(c); + addConstituent(c, true, fraction); } ~HGCalClusterT() override {}; @@ -105,11 +108,10 @@ namespace l1t double mipPt() const { return mipPt_; } double seedMipPt() const { return seedMipPt_; } uint32_t detId() const { return detId_.rawId(); } - void setPt(double pt) { setP4( math::PtEtaPhiMLorentzVector(pt, eta(), phi(), mass() ) ); } - + double sumPt() const { return sumPt_; } /* distance in 'cm' */ double distance( const l1t::HGCalTriggerCell &tc ) const { return ( tc.position() - centre_ ).mag(); } @@ -203,6 +205,7 @@ namespace l1t double mipPt_; double seedMipPt_; + double sumPt_; //shower shape @@ -226,6 +229,7 @@ namespace l1t void updateP4AndPosition(const edm::Ptr& c, bool updateCentre=true, float fraction=1.) { double cMipt = c->mipPt()*fraction; + double cPt = c->pt()*fraction; /* update cluster positions (IF requested) */ if( updateCentre ){ Basic3DVector constituentCentre( c->position() ); @@ -246,7 +250,7 @@ namespace l1t /* update cluster energies */ mipPt_ += cMipt; - + sumPt_ += cPt; int updatedPt = hwPt() + (int)(c->hwPt()*fraction); setHwPt( updatedPt ); diff --git a/DataFormats/L1THGCal/interface/HGCalMulticluster.h b/DataFormats/L1THGCal/interface/HGCalMulticluster.h index f8e4e4f062555..5f4c59bfa1ffa 100644 --- a/DataFormats/L1THGCal/interface/HGCalMulticluster.h +++ b/DataFormats/L1THGCal/interface/HGCalMulticluster.h @@ -19,7 +19,7 @@ namespace l1t { int phi=0 ); - HGCalMulticluster( const edm::Ptr &tc ); + HGCalMulticluster( const edm::Ptr &tc, float fraction=1); ~HGCalMulticluster() override; diff --git a/DataFormats/L1THGCal/src/HGCalMulticluster.cc b/DataFormats/L1THGCal/src/HGCalMulticluster.cc index d5b7bbc98f4bb..57e4c38a52a51 100644 --- a/DataFormats/L1THGCal/src/HGCalMulticluster.cc +++ b/DataFormats/L1THGCal/src/HGCalMulticluster.cc @@ -13,8 +13,8 @@ HGCalMulticluster::HGCalMulticluster( const LorentzVector p4, } -HGCalMulticluster::HGCalMulticluster( const edm::Ptr &clusterSeed ) - : HGCalClusterT(clusterSeed), +HGCalMulticluster::HGCalMulticluster( const edm::Ptr &clusterSeed, float fraction ) + : HGCalClusterT(clusterSeed, fraction), hOverE_(-99), hOverEValid_(false) { diff --git a/DataFormats/L1THGCal/src/classes_def.xml b/DataFormats/L1THGCal/src/classes_def.xml index 5de052d7f893a..659c0682c681d 100644 --- a/DataFormats/L1THGCal/src/classes_def.xml +++ b/DataFormats/L1THGCal/src/classes_def.xml @@ -30,8 +30,9 @@ - - + + + @@ -43,9 +44,11 @@ - - - + + + + + diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h index 24f04229e58ec..25355327d1d74 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h @@ -22,56 +22,72 @@ class HGCalMulticlusteringHistoImpl{ { triggerTools_.eventSetup(es); shape_.eventSetup(es); - if (!dr_byLayer_.empty() && (dr_byLayer_.size()-1) != triggerTools_.lastLayerBH()) { + if ( (!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size()-1) != triggerTools_.lastLayerBH()) + || (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size()-1) != triggerTools_.lastLayerBH()) + ) { throw cms::Exception("Configuration") << - "The per-layer dR values go up to " << (dr_byLayer_.size()-1) << - ", while layers go up to " << triggerTools_.lastLayerBH() << "\n"; + "The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size()-1) << + "(A) and " << (dr_byLayer_coefficientB_.size()-1) << "(B), while layers go up to " << triggerTools_.lastLayerBH() << "\n"; } } float dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed ) const; + const GlobalPoint & seed ) const; void clusterizeHisto( const std::vector> & clustersPtr, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); + l1t::HGCalMulticlusterBxCollection & multiclusters, + const HGCalTriggerGeometryBase & triggerGeometry + ); private: enum MulticlusterType{ HistoMaxC3d, + HistoSecondaryMaxC3d, HistoThresholdC3d, HistoInterpolatedMaxC3d }; + enum ClusterAssociationStrategy{ + NearestNeighbour, + EnergySplit + }; + typedef std::map,float> Histogram; Histogram fillHistoClusters( const std::vector> & clustersPtrs ); Histogram fillSmoothPhiHistoClusters( const Histogram & histoClusters, - const vector & binSums ); + const vector & binSums ); Histogram fillSmoothRPhiHistoClusters( const Histogram & histoClusters ); - std::vector computeMaxSeeds( const Histogram & histoClusters ); - - std::vector computeInterpolatedMaxSeeds( const Histogram & histoClusters ); + std::vector > computeMaxSeeds( const Histogram & histoClusters ); - std::vector computeThresholdSeeds( const Histogram & histoClusters ); + std::vector > computeSecondaryMaxSeeds( const Histogram & histoClusters ); + + std::vector > computeInterpolatedMaxSeeds( const Histogram & histoClusters ); + + std::vector > computeThresholdSeeds( const Histogram & histoClusters ); std::vector clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector & seeds); + const std::vector > & seeds); + void finalizeClusters(std::vector&, l1t::HGCalMulticlusterBxCollection&, const HGCalTriggerGeometryBase&); double dr_; - std::vector dr_byLayer_; + std::vector dr_byLayer_coefficientA_; + std::vector dr_byLayer_coefficientB_; double ptC3dThreshold_; - MulticlusterType multiclusteringAlgoType_; + std::string multiclusterAlgoType_; + std::string cluster_association_input_; + MulticlusterType multiclusteringAlgoType_; + ClusterAssociationStrategy cluster_association_strategy_; + unsigned nBinsRHisto_ = 36; unsigned nBinsPhiHisto_ = 216; std::vector binsSumsHisto_; @@ -86,6 +102,8 @@ class HGCalMulticlusteringHistoImpl{ static constexpr double kROverZMin_ = 0.09; static constexpr double kROverZMax_ = 0.52; + static constexpr double kMidRadius_ = 2.3; + }; #endif diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h index efb586e7a5224..ed2d522358d42 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h @@ -18,20 +18,29 @@ class HGCalConcentratorSuperTriggerCellImpl HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf); void superTriggerCellSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); + void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} private: int getSuperTriggerCellId(int detid) const ; - static const int kSplit_ = 0x3a; + static const int kSplit12_ = 0x3a; + static const int kSplit3_ = 0x30; static const int kWafer_offset_ = 6; + static const int kSTCsize16_ = 16; + static const int kSTCsize4_ = 4; + static const int kNLayers_ = 3; + + HGCalTriggerTools triggerTools_; + std::vector stcSize_; + class SuperTriggerCell { private: float sumPt_, sumMipPt_; int sumHwPt_, maxHwPt_; unsigned maxId_; - + public: SuperTriggerCell(){ sumPt_=0, sumMipPt_=0, sumHwPt_=0, maxHwPt_=0, maxId_=0 ;} void add(const l1t::HGCalTriggerCell &c) { diff --git a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc index 5fa5569d91b94..32ea6af2667f7 100644 --- a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc +++ b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc @@ -41,6 +41,7 @@ void HGCalConcentratorProcessorSelection::run(const edm::HandlegetModuleFromTriggerCell(trigCell.detId()); tc_modules[module].push_back(trigCell); } + if ( concentratorSTCImpl_) concentratorSTCImpl_->eventSetup(es); for( const auto& module_trigcell : tc_modules ) { std::vector trigCellVecOutput; diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index bb4cba994136f..404da22b8421b 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -91,11 +91,33 @@ def custom_3dclustering_histoMax(process, parameters_c3d.type_multicluster = cms.string('HistoMaxC3d') return process +def custom_3dclustering_histoSecondaryMax(process, + distance = 0.03, + threshold = 5., + nBins_R = 36, + nBins_Phi = 216, + binSumsHisto = binSums, + ): + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster = cms.double(distance) + parameters_c3d.nBins_R_histo_multicluster = cms.uint32(nBins_R) + parameters_c3d.nBins_Phi_histo_multicluster = cms.uint32(nBins_Phi) + parameters_c3d.binSumsHisto = binSumsHisto + parameters_c3d.threshold_histo_multicluster = cms.double(threshold) + parameters_c3d.type_multicluster = cms.string('HistoSecondaryMaxC3d') + return process dr_layerbylayer = ([0] + # no layer 0 [0.015]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + # EM [0.040]*6 + [0.050]*6 + # FH [0.050]*12) # BH + + +dr_layerbylayer_Bcoefficient = ([0] + # no layer 0 + [0.020]*7 + [0.020]*7 + [0.02]*7 + [0.020]*7 + # EM + [0.020]*6 + [0.020]*6 + # FH + [0.020]*12) # BH + def custom_3dclustering_histoMax_variableDr(process, distances = dr_layerbylayer, nBins_R = 36, @@ -109,37 +131,39 @@ def custom_3dclustering_histoMax_variableDr(process, return process + def custom_3dclustering_histoInterpolatedMax(process, distance = 0.03, + seed_threshold = 5., nBins_R = 36, nBins_Phi = 216, binSumsHisto = binSums, ): - process = custom_3dclustering_histoMax( process, distance, nBins_R, nBins_Phi, binSumsHisto ) + process = custom_3dclustering_histoMax( process, distance, nBins_R, nBins_Phi, binSumsHisto, seed_threshold ) parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.type_multicluster = cms.string('HistoInterpolatedMaxC3d') return process -def custom_3dclustering_histoInterpolatedMax1stOrder(process): +def custom_3dclustering_histoInterpolatedMax1stOrder(process, distance = 0.03, seed_threshold = 5. ): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.neighbour_weights=cms.vdouble( 0 , 0.25, 0 , 0.25 , 0 , 0.25, 0 , 0.25, 0 ) - process = custom_3dclustering_histoInterpolatedMax( process ) + process = custom_3dclustering_histoInterpolatedMax( process, distance, seed_threshold ) return process -def custom_3dclustering_histoInterpolatedMax2ndOrder(process): +def custom_3dclustering_histoInterpolatedMax2ndOrder(process, distance = 0.03, seed_threshold = 5.): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.neighbour_weights=cms.vdouble( -0.25, 0.5, -0.25, 0.5 , 0 , 0.5 , -0.25, 0.5, -0.25 ) - process = custom_3dclustering_histoInterpolatedMax( process ) + process = custom_3dclustering_histoInterpolatedMax( process, distance, seed_threshold ) return process @@ -159,3 +183,50 @@ def custom_3dclustering_histoThreshold(process, parameters_c3d.binSumsHisto = binSumsHisto parameters_c3d.type_multicluster = cms.string('HistoThresholdC3d') return process + +def custom_3dclustering_clusteringRadiusLayerbyLayerVariableEta(process, distance_coefficientA = dr_layerbylayer, distance_coefficientB = dr_layerbylayer_Bcoefficient): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster_byLayer_coefficientA = distance_coefficientA + parameters_c3d.dR_multicluster_byLayer_coefficientB = distance_coefficientB + + return process + + +def custom_3dclustering_clusteringRadiusLayerbyLayerFixedEta(process, distance_coefficientA = dr_layerbylayer): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster_byLayer_coefficientA = distance_coefficientA + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*53 ) + + return process + +def custom_3dclustering_clusteringRadiusNoLayerDependenceFixedEta(process, distance_coefficientA = 0.03): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*53 ) + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*53 ) + + return process + +def custom_3dclustering_clusteringRadiusNoLayerDependenceVariableEta(process, distance_coefficientA = 0.03, distance_coefficientB = 0.02): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*53 ) + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [distance_coefficientB]*53 ) + + return process + + +def custom_3dclustering_nearestNeighbourAssociation(process): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.cluster_association = cms.string('NearestNeighbour') + + return process + +def custom_3dclustering_EnergySplitAssociation(process): + + parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters + parameters_c3d.cluster_association = cms.string('EnergySplit') + return process diff --git a/L1Trigger/L1THGCal/python/customTriggerCellSelect.py b/L1Trigger/L1THGCal/python/customTriggerCellSelect.py index d6a66d04663ea..7473ef1b7d4ce 100644 --- a/L1Trigger/L1THGCal/python/customTriggerCellSelect.py +++ b/L1Trigger/L1THGCal/python/customTriggerCellSelect.py @@ -1,8 +1,14 @@ import FWCore.ParameterSet.Config as cms import SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi as digiparam -def custom_triggercellselect_supertriggercell(process): - process.hgcalConcentratorProducer.ProcessorParameters.Method = cms.string('superTriggerCellSelect') +def custom_triggercellselect_supertriggercell(process, + stcSize = cms.vuint32(4,4,4) + ): + + parameters = process.hgcalConcentratorProducer.ProcessorParameters + parameters.Method = cms.string('superTriggerCellSelect') + parameters.stcSize = stcSize + return process diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index 8bb0774951627..1caca9a077339 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -9,12 +9,14 @@ C3d_parValues = cms.PSet( type_multicluster = cms.string('HistoMaxC3d'), dR_multicluster = cms.double(0.), - dR_multicluster_byLayer = cms.vdouble(dr_layerbylayer), + dR_multicluster_byLayer_coefficientA = cms.vdouble(dr_layerbylayer), + dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*53 ), minPt_multicluster = cms.double(0.5), # minimum pt of the multicluster (GeV) nBins_R_histo_multicluster = cms.uint32(36), nBins_Phi_histo_multicluster = cms.uint32(216), binSumsHisto = binSums, threshold_histo_multicluster = cms.double(10.), + cluster_association = cms.string("NearestNeighbour"), EGIdentification=egamma_identification_drnn_cone.clone(), neighbour_weights=cms.vdouble( 0 , 0.25, 0 , 0.25 , 0 , 0.25, diff --git a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc index 07adbeb746b7b..ee3dc3b5bf542 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc @@ -5,9 +5,11 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::ParameterSet& conf ) : dr_(conf.getParameter("dR_multicluster")), - dr_byLayer_(conf.existsAs>("dR_multicluster_byLayer") ? conf.getParameter>("dR_multicluster_byLayer") : std::vector()), + dr_byLayer_coefficientA_(conf.existsAs>("dR_multicluster_byLayer_coefficientA") ? conf.getParameter>("dR_multicluster_byLayer_coefficientA") : std::vector()), + dr_byLayer_coefficientB_(conf.existsAs>("dR_multicluster_byLayer_coefficientB") ? conf.getParameter>("dR_multicluster_byLayer_coefficientB") : std::vector()), ptC3dThreshold_(conf.getParameter("minPt_multicluster")), multiclusterAlgoType_(conf.getParameter("type_multicluster")), + cluster_association_input_(conf.getParameter("cluster_association")), nBinsRHisto_(conf.getParameter("nBins_R_histo_multicluster")), nBinsPhiHisto_(conf.getParameter("nBins_Phi_histo_multicluster")), binsSumsHisto_(conf.getParameter< std::vector >("binSumsHisto")), @@ -17,13 +19,24 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::Paramet if(multiclusterAlgoType_=="HistoMaxC3d"){ multiclusteringAlgoType_ = HistoMaxC3d; + }else if(multiclusterAlgoType_=="HistoSecondaryMaxC3d"){ + multiclusteringAlgoType_ = HistoSecondaryMaxC3d; }else if(multiclusterAlgoType_=="HistoThresholdC3d"){ multiclusteringAlgoType_ = HistoThresholdC3d; }else if(multiclusterAlgoType_=="HistoInterpolatedMaxC3d"){ multiclusteringAlgoType_ = HistoInterpolatedMaxC3d; }else { throw cms::Exception("HGCTriggerParameterError") - << "Unknown Multiclustering type '" << multiclusterAlgoType_; + << "Unknown Multiclustering type '" << multiclusterAlgoType_; + } + + if(cluster_association_input_=="NearestNeighbour"){ + cluster_association_strategy_ = NearestNeighbour; + }else if(cluster_association_input_=="EnergySplit"){ + cluster_association_strategy_ = EnergySplit; + }else { + throw cms::Exception("HGCTriggerParameterError") + << "Unknown cluster association strategy'" << cluster_association_strategy_; } edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR: " << dr_ @@ -47,10 +60,8 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::Paramet - - float HGCalMulticlusteringHistoImpl::dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed) const + const GlobalPoint & seed) const { Basic3DVector seed_3dv( seed ); @@ -61,8 +72,6 @@ float HGCalMulticlusteringHistoImpl::dR( const l1t::HGCalCluster & clu, - - HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillHistoClusters( const std::vector> & clustersPtrs ){ @@ -101,7 +110,7 @@ HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillHist HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoothPhiHistoClusters( const Histogram & histoClusters, - const vector & binSums ){ + const vector & binSums ){ Histogram histoSumPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi @@ -178,10 +187,9 @@ HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoo +std::vector > HGCalMulticlusteringHistoImpl::computeMaxSeeds( const Histogram & histoClusters ){ -std::vector HGCalMulticlusteringHistoImpl::computeMaxSeeds( const Histogram & histoClusters ){ - - std::vector seedPositions; + std::vector > seedPositionsEnergy; for(int z_side : {-1,1}){ @@ -217,33 +225,31 @@ std::vector HGCalMulticlusteringHistoImpl::computeMaxSeeds( const H isMax &= MIPT_seed>MIPT_SW; isMax &= MIPT_seed>MIPT_NW; - - if(isMax){ - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; float x_seed = ROverZ_seed*cos(phi_seed); float y_seed = ROverZ_seed*sin(phi_seed); - seedPositions.emplace_back(x_seed,y_seed,z_side); - } + seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed); + } } } } - return seedPositions; + return seedPositionsEnergy; } -std::vector HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSeeds( const Histogram & histoClusters ){ - - std::vector seedPositions; +std::vector > HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSeeds( const Histogram & histoClusters ){ + + std::vector > seedPositionsEnergy; + for(int z_side : {-1,1}){ for(int bin_R = 0; bin_R HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSe for(int bin_phi = 0; bin_phi0; - float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; @@ -273,14 +277,14 @@ std::vector HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSe + neighbour_weights_.at(3) * MIPT_W + neighbour_weights_.at(5) * MIPT_E + neighbour_weights_.at(6) * MIPT_SW + neighbour_weights_.at(7) * MIPT_S + neighbour_weights_.at(8) * MIPT_SE; - isMax &= MIPT_seed>=MIPT_pred; + bool isMax = MIPT_seed>=(MIPT_pred+histoThreshold_); if(isMax){ - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - seedPositions.emplace_back(x_seed,y_seed,z_side); + float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; + float x_seed = ROverZ_seed*cos(phi_seed); + float y_seed = ROverZ_seed*sin(phi_seed); + seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed); } } @@ -289,14 +293,15 @@ std::vector HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSe } - return seedPositions; + return seedPositionsEnergy; } -std::vector HGCalMulticlusteringHistoImpl::computeThresholdSeeds( const Histogram & histoClusters ){ +std::vector > HGCalMulticlusteringHistoImpl::computeThresholdSeeds( const Histogram & histoClusters ){ - std::vector seedPositions; + + std::vector > seedPositionsEnergy; for(int z_side : {-1,1}){ @@ -312,7 +317,7 @@ std::vector HGCalMulticlusteringHistoImpl::computeThresholdSeeds( c float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; float x_seed = ROverZ_seed*cos(phi_seed); float y_seed = ROverZ_seed*sin(phi_seed); - seedPositions.emplace_back(x_seed,y_seed,z_side); + seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed) ; } } @@ -321,47 +326,217 @@ std::vector HGCalMulticlusteringHistoImpl::computeThresholdSeeds( c } - return seedPositions; + return seedPositionsEnergy; } -std::vector HGCalMulticlusteringHistoImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector & seeds){ +std::vector > HGCalMulticlusteringHistoImpl::computeSecondaryMaxSeeds( const Histogram & histoClusters ){ + + std::vector > seedPositionsEnergy; + + std::map, bool> primarySeedPositions; + std::map, bool> secondarySeedPositions; + std::map, bool> vetoPositions; + + //Search for primary seeds + for(int z_side : {-1,1}){ + + for(int bin_R = 0; bin_R histoThreshold_; + + if (!isMax) continue; + + float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; + float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if( binLeft<0 ) binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); + float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); + float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; + float MIPT_NE = bin_R>0 ?histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; + float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; + float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; + + isMax &= MIPT_seed>=MIPT_S; + isMax &= MIPT_seed>MIPT_N; + isMax &= MIPT_seed>=MIPT_E; + isMax &= MIPT_seed>=MIPT_SE; + isMax &= MIPT_seed>=MIPT_NE; + isMax &= MIPT_seed>MIPT_W; + isMax &= MIPT_seed>MIPT_SW; + isMax &= MIPT_seed>MIPT_NW; + + if(isMax){ + + + float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; + float x_seed = ROverZ_seed*cos(phi_seed); + float y_seed = ROverZ_seed*sin(phi_seed); + + seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed ); + primarySeedPositions[std::make_tuple(bin_R,bin_phi,z_side)] = true; + + vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] = true; + vetoPositions[std::make_tuple(bin_R,binRight,z_side)] = true; + if ( bin_R>0 ) { + vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] = true; + vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] = true; + vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] = true; + } + if ( bin_R<(int(nBinsRHisto_)-1) ) { + vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] = true; + vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] = true; + vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] = true; + } + + } + + } + } + + } + + + //Search for secondary seeds + + for(int z_side : {-1,1}){ + + for(int bin_R = 0; bin_R histoThreshold_; + + float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; + float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if( binLeft<0 ) binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); + float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); + float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; + float MIPT_NE = bin_R>0 ?histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; + float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; + float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; + + + if ( !vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] ) isMax &= MIPT_seed>=MIPT_S; + if ( !vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] ) isMax &= MIPT_seed>MIPT_N; + if ( !vetoPositions[std::make_tuple(bin_R,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_E; + if ( !vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_SE; + if ( !vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_NE; + if ( !vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_W; + if ( !vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_SW; + if ( !vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_NW; + + if(isMax){ + float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; + float x_seed = ROverZ_seed*cos(phi_seed); + float y_seed = ROverZ_seed*sin(phi_seed); + seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed ); + secondarySeedPositions[std::make_tuple(bin_R,bin_phi,z_side)] = true; + } + + } + + } + + } + + return seedPositionsEnergy; + +} + + + +std::vector HGCalMulticlusteringHistoImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, + const std::vector > & seeds){ std::map mapSeedMulticluster; std::vector multiclustersTmp; for(auto & clu : clustersPtrs){ - int z_side = triggerTools_.zside(clu->detId()); - double minDist = dr_byLayer_.empty() ? dr_ : dr_byLayer_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment - int targetSeed = -1; - for( unsigned int iseed=0; iseeddetId())); // use at() to get the assert, for the moment + double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment + + double minDist = radiusCoefficientA + radiusCoefficientB*(kMidRadius_ - std::abs(clu->eta()) ) ; - if( z_side*seeds[iseed].z()<0) continue; + std::vector > targetSeedsEnergy; + + for( unsigned int iseed=0; iseeddR(*clu, seeds[iseed]); + GlobalPoint seedPosition = seeds[iseed].first; + double seedEnergy = seeds[iseed].second; - if(ddR(*clu, seeds[iseed].first); - } + if ( d < minDist ){ + if ( cluster_association_strategy_ == EnergySplit ){ + targetSeedsEnergy.emplace_back( iseed, seedEnergy ); + } + if ( cluster_association_strategy_ == NearestNeighbour ){ - if(targetSeed<0) continue; + minDist = d; - if(mapSeedMulticluster[targetSeed].size()==0) mapSeedMulticluster[targetSeed] = l1t::HGCalMulticluster(clu); - else mapSeedMulticluster[targetSeed].addConstituent(clu); + if ( targetSeedsEnergy.empty() ) { + targetSeedsEnergy.emplace_back( iseed, seedEnergy ); + } + else { + targetSeedsEnergy.at(0).first = iseed ; + targetSeedsEnergy.at(0).second = seedEnergy; + } + } + + } + + } + + if(targetSeedsEnergy.empty()) continue; + //Loop over target seeds and divide up the clusters energy + double totalTargetSeedEnergy = 0; + for (auto energy: targetSeedsEnergy){ + totalTargetSeedEnergy+=energy.second; + } + + for (auto energy: targetSeedsEnergy){ + double seedWeight = 1; + if ( cluster_association_strategy_ == EnergySplit) seedWeight = energy.second/totalTargetSeedEnergy; + if( mapSeedMulticluster[energy.first].size()==0) { + mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight) ; + } + mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); + + } + } + for(auto mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); return multiclustersTmp; @@ -372,8 +547,8 @@ std::vector HGCalMulticlusteringHistoImpl::clusterSeedMu void HGCalMulticlusteringHistoImpl::clusterizeHisto( const std::vector> & clustersPtrs, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry) + l1t::HGCalMulticlusterBxCollection & multiclusters, + const HGCalTriggerGeometryBase & triggerGeometry) { /* put clusters into an r/z x phi histogram */ @@ -386,13 +561,13 @@ void HGCalMulticlusteringHistoImpl::clusterizeHisto( const std::vector seedPositions; - if (multiclusteringAlgoType_ == HistoMaxC3d) seedPositions = computeMaxSeeds(smoothRPhiHistoCluster); - else if(multiclusteringAlgoType_ == HistoThresholdC3d) seedPositions = computeThresholdSeeds(smoothRPhiHistoCluster); - else if(multiclusteringAlgoType_ == HistoInterpolatedMaxC3d) seedPositions = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); + std::vector > seedPositionsEnergy; + if (multiclusteringAlgoType_ == HistoMaxC3d) seedPositionsEnergy = computeMaxSeeds(smoothRPhiHistoCluster); + else if(multiclusteringAlgoType_ == HistoThresholdC3d) seedPositionsEnergy = computeThresholdSeeds(smoothRPhiHistoCluster); + else if(multiclusteringAlgoType_ == HistoInterpolatedMaxC3d) seedPositionsEnergy = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); + else if(multiclusteringAlgoType_ == HistoSecondaryMaxC3d) seedPositionsEnergy = computeSecondaryMaxSeeds(smoothRPhiHistoCluster); /* clusterize clusters around seeds */ - std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs,seedPositions); - + std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs,seedPositionsEnergy); /* making the collection of multiclusters */ finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); @@ -412,9 +587,7 @@ finalizeClusters(std::vector& multiclusters_in, for(auto& multicluster : multiclusters_in) { // compute the eta, phi from its barycenter // + pT as scalar sum of pT of constituents - double sumPt=0.; - const std::unordered_map>& clusters = multicluster.constituents(); - for(const auto& id_cluster : clusters) sumPt += id_cluster.second->pt(); + double sumPt=multicluster.sumPt(); math::PtEtaPhiMLorentzVector multiclusterP4( sumPt, multicluster.centre().eta(), diff --git a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc index beb52a1c73742..c2f37684c7e1f 100644 --- a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc +++ b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc @@ -3,7 +3,22 @@ #include HGCalConcentratorSuperTriggerCellImpl:: -HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf){} +HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) + : stcSize_(conf.getParameter< std::vector >("stcSize")) +{ + + if ( stcSize_.size() != kNLayers_ ){ + throw cms::Exception("HGCTriggerParameterError") + << "Inconsistent size of super trigger cell size vector" << stcSize_.size() ; + } + for(auto stc : stcSize_) { + if ( stc!=kSTCsize4_ && stc!=kSTCsize16_ ){ + throw cms::Exception("HGCTriggerParameterError") + << "Super Trigger Cell should be of size 4 or 16" ; + } + } + +} int @@ -13,9 +28,16 @@ HGCalConcentratorSuperTriggerCellImpl::getSuperTriggerCellId(int detid) const { if(TC_id.subdetId()==HGCHEB) { return TC_id.cell(); //scintillator } else { + int TC_wafer = TC_id.wafer(); - int TC_12th = ( TC_id.cell() & kSplit_ ); - return TC_wafer< Date: Mon, 4 Mar 2019 18:02:04 +0100 Subject: [PATCH 291/686] Changed variable name in custom clustering --- L1Trigger/L1THGCal/python/customClustering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index 404da22b8421b..5c22ea3cfd6d0 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -127,7 +127,7 @@ def custom_3dclustering_histoMax_variableDr(process, ): process = custom_3dclustering_histoMax(process, 0, nBins_R, nBins_Phi, binSumsHisto, seed_threshold) parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters - parameters_c3d.dR_multicluster_byLayer = cms.vdouble(distances) + parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble(distances) return process From 6c5217a949c0263921dec4b5212b9533a630f767 Mon Sep 17 00:00:00 2001 From: Samuel Webb Date: Fri, 8 Mar 2019 18:09:07 +0100 Subject: [PATCH 292/686] Separate seeding and clustering --- ...HistoImpl.h => HGCalHistoClusteringImpl.h} | 50 +--- .../interface/backend/HGCalHistoSeedingImpl.h | 76 +++++++ ...HGCalBackendLayer2Processor3DClustering.cc | 18 +- .../src/backend/HGCalHistoClusteringImpl.cc | 179 +++++++++++++++ ...gHistoImpl.cc => HGCalHistoSeedingImpl.cc} | 215 +++--------------- 5 files changed, 303 insertions(+), 235 deletions(-) rename L1Trigger/L1THGCal/interface/backend/{HGCalMulticlusteringHistoImpl.h => HGCalHistoClusteringImpl.h} (60%) create mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h create mode 100644 L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc rename L1Trigger/L1THGCal/src/backend/{HGCalMulticlusteringHistoImpl.cc => HGCalHistoSeedingImpl.cc} (64%) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h similarity index 60% rename from L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h rename to L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h index 25355327d1d74..a31b691e5dd62 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h @@ -1,5 +1,5 @@ -#ifndef __L1Trigger_L1THGCal_HGCalMulticlusteringHistoImpl_h__ -#define __L1Trigger_L1THGCal_HGCalMulticlusteringHistoImpl_h__ +#ifndef __L1Trigger_L1THGCal_HGCalHistoClusteringImpl_h__ +#define __L1Trigger_L1THGCal_HGCalHistoClusteringImpl_h__ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1THGCal/interface/HGCalCluster.h" @@ -12,11 +12,11 @@ #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" -class HGCalMulticlusteringHistoImpl{ +class HGCalHistoClusteringImpl{ public: - HGCalMulticlusteringHistoImpl( const edm::ParameterSet &conf); + HGCalHistoClusteringImpl( const edm::ParameterSet &conf); void eventSetup(const edm::EventSetup& es) { @@ -35,45 +35,21 @@ class HGCalMulticlusteringHistoImpl{ const GlobalPoint & seed ) const; void clusterizeHisto( const std::vector> & clustersPtr, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry + const std::vector > & seedPositionsEnergy, + const HGCalTriggerGeometryBase & triggerGeometry, + l1t::HGCalMulticlusterBxCollection & multiclusters ); private: - enum MulticlusterType{ - HistoMaxC3d, - HistoSecondaryMaxC3d, - HistoThresholdC3d, - HistoInterpolatedMaxC3d - }; - enum ClusterAssociationStrategy{ NearestNeighbour, EnergySplit }; - typedef std::map,float> Histogram; - - Histogram fillHistoClusters( const std::vector> & clustersPtrs ); - - Histogram fillSmoothPhiHistoClusters( const Histogram & histoClusters, - const vector & binSums ); - - Histogram fillSmoothRPhiHistoClusters( const Histogram & histoClusters ); - - std::vector > computeMaxSeeds( const Histogram & histoClusters ); - - std::vector > computeSecondaryMaxSeeds( const Histogram & histoClusters ); - - std::vector > computeInterpolatedMaxSeeds( const Histogram & histoClusters ); - - std::vector > computeThresholdSeeds( const Histogram & histoClusters ); - std::vector clusterSeedMulticluster(const std::vector> & clustersPtrs, const std::vector > & seeds); - void finalizeClusters(std::vector&, l1t::HGCalMulticlusterBxCollection&, const HGCalTriggerGeometryBase&); @@ -83,25 +59,13 @@ class HGCalMulticlusteringHistoImpl{ std::vector dr_byLayer_coefficientB_; double ptC3dThreshold_; - std::string multiclusterAlgoType_; std::string cluster_association_input_; - MulticlusterType multiclusteringAlgoType_; ClusterAssociationStrategy cluster_association_strategy_; - unsigned nBinsRHisto_ = 36; - unsigned nBinsPhiHisto_ = 216; - std::vector binsSumsHisto_; - double histoThreshold_ = 20.; - std::vector neighbour_weights_; - HGCalShowerShape shape_; HGCalTriggerTools triggerTools_; std::unique_ptr id_; - static constexpr unsigned neighbour_weights_size_ = 9; - static constexpr double kROverZMin_ = 0.09; - static constexpr double kROverZMax_ = 0.52; - static constexpr double kMidRadius_ = 2.3; }; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h new file mode 100644 index 0000000000000..9fbc0583903d9 --- /dev/null +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h @@ -0,0 +1,76 @@ +#ifndef __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__ +#define __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__ + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/L1THGCal/interface/HGCalCluster.h" +#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h" +#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" + + +class HGCalHistoSeedingImpl{ + +public: + + HGCalHistoSeedingImpl( const edm::ParameterSet &conf); + + void eventSetup(const edm::EventSetup& es) + { + triggerTools_.eventSetup(es); + } + + float dR( const l1t::HGCalCluster & clu, + const GlobalPoint & seed ) const; + + void findHistoSeeds( const std::vector> & clustersPtr, + std::vector > & seedPositionsEnergy); + + +private: + enum SeedingType{ + HistoMaxC3d, + HistoSecondaryMaxC3d, + HistoThresholdC3d, + HistoInterpolatedMaxC3d + }; + + typedef std::map,float> Histogram; + + Histogram fillHistoClusters( const std::vector> & clustersPtrs ); + + Histogram fillSmoothPhiHistoClusters( const Histogram & histoClusters, + const vector & binSums ); + + Histogram fillSmoothRPhiHistoClusters( const Histogram & histoClusters ); + + std::vector > computeMaxSeeds( const Histogram & histoClusters ); + + std::vector > computeSecondaryMaxSeeds( const Histogram & histoClusters ); + + std::vector > computeInterpolatedMaxSeeds( const Histogram & histoClusters ); + + std::vector > computeThresholdSeeds( const Histogram & histoClusters ); + + + std::string seedingAlgoType_; + SeedingType seedingType_; + + unsigned nBinsRHisto_ = 36; + unsigned nBinsPhiHisto_ = 216; + std::vector binsSumsHisto_; + double histoThreshold_ = 20.; + std::vector neighbour_weights_; + + HGCalTriggerTools triggerTools_; + + static constexpr unsigned neighbour_weights_size_ = 9; + static constexpr double kROverZMin_ = 0.09; + static constexpr double kROverZMax_ = 0.52; + +}; + +#endif diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc index d1aecb1b41ad8..c0676d3995f69 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc @@ -6,7 +6,8 @@ #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h" class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2ProcessorBase { @@ -23,7 +24,8 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process multiclustering_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); }else if(typeMulticluster.find("Histo")!=std::string::npos){ multiclusteringAlgoType_ = HistoC3d; - multiclusteringHisto_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); + multiclusteringHistoSeeding_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); + multiclusteringHistoClustering_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); }else { throw cms::Exception("HGCTriggerParameterError") << "Unknown Multiclustering type '" << typeMulticluster << "'"; @@ -36,7 +38,8 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process { es.get().get("", triggerGeometry_); if(multiclustering_) multiclustering_->eventSetup(es); - if(multiclusteringHisto_) multiclusteringHisto_->eventSetup(es); + if(multiclusteringHistoSeeding_) multiclusteringHistoSeeding_->eventSetup(es); + if(multiclusteringHistoClustering_) multiclusteringHistoClustering_->eventSetup(es); /* create a persistent vector of pointers to the trigger-cells */ std::vector> clustersPtrs; @@ -45,6 +48,9 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process clustersPtrs.push_back(ptr); } + /* create a vector of seed positions and their energy*/ + std::vector > seedPositionsEnergy; + /* call to multiclustering and compute shower shape*/ switch(multiclusteringAlgoType_){ case dRC3d : @@ -54,7 +60,8 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process multiclustering_->clusterizeDBSCAN( clustersPtrs, collCluster3D, *triggerGeometry_); break; case HistoC3d : - multiclusteringHisto_->clusterizeHisto( clustersPtrs, collCluster3D, *triggerGeometry_); + multiclusteringHistoSeeding_->findHistoSeeds( clustersPtrs, seedPositionsEnergy); + multiclusteringHistoClustering_->clusterizeHisto( clustersPtrs, seedPositionsEnergy, *triggerGeometry_, collCluster3D ); break; default: // Should not happen, clustering type checked in constructor @@ -73,7 +80,8 @@ class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2Process /* algorithms instances */ std::unique_ptr multiclustering_; - std::unique_ptr multiclusteringHisto_; + std::unique_ptr multiclusteringHistoSeeding_; + std::unique_ptr multiclusteringHistoClustering_; /* algorithm type */ MulticlusterType multiclusteringAlgoType_; diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc new file mode 100644 index 0000000000000..dc6b9e6a7f13e --- /dev/null +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc @@ -0,0 +1,179 @@ +#include "L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Math/interface/deltaPhi.h" + +HGCalHistoClusteringImpl::HGCalHistoClusteringImpl( const edm::ParameterSet& conf ) : + dr_(conf.getParameter("dR_multicluster")), + dr_byLayer_coefficientA_(conf.existsAs>("dR_multicluster_byLayer_coefficientA") ? conf.getParameter>("dR_multicluster_byLayer_coefficientA") : std::vector()), + dr_byLayer_coefficientB_(conf.existsAs>("dR_multicluster_byLayer_coefficientB") ? conf.getParameter>("dR_multicluster_byLayer_coefficientB") : std::vector()), + ptC3dThreshold_(conf.getParameter("minPt_multicluster")), + cluster_association_input_(conf.getParameter("cluster_association")) +{ + + if(cluster_association_input_=="NearestNeighbour"){ + cluster_association_strategy_ = NearestNeighbour; + }else if(cluster_association_input_=="EnergySplit"){ + cluster_association_strategy_ = EnergySplit; + }else { + throw cms::Exception("HGCTriggerParameterError") + << "Unknown cluster association strategy'" << cluster_association_strategy_; + } + + edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR: " << dr_ + <<"\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_ ; + + id_.reset( HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") ); + id_->initialize(conf.getParameter("EGIdentification")); + +} + + + +float HGCalHistoClusteringImpl::dR( const l1t::HGCalCluster & clu, + const GlobalPoint & seed) const +{ + + Basic3DVector seed_3dv( seed ); + GlobalPoint seed_proj( seed_3dv / seed.z() ); + return (seed_proj - clu.centreProj() ).mag(); + +} + + + +std::vector HGCalHistoClusteringImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, + const std::vector > & seeds){ + + std::map mapSeedMulticluster; + std::vector multiclustersTmp; + + for(auto & clu : clustersPtrs){ + + int z_side = triggerTools_.zside(clu->detId()); + + + double radiusCoefficientA = dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment + double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment + + double minDist = radiusCoefficientA + radiusCoefficientB*(kMidRadius_ - std::abs(clu->eta()) ) ; + + std::vector > targetSeedsEnergy; + + for( unsigned int iseed=0; iseeddR(*clu, seeds[iseed].first); + + if ( d < minDist ){ + if ( cluster_association_strategy_ == EnergySplit ){ + targetSeedsEnergy.emplace_back( iseed, seedEnergy ); + } + if ( cluster_association_strategy_ == NearestNeighbour ){ + + minDist = d; + + if ( targetSeedsEnergy.empty() ) { + targetSeedsEnergy.emplace_back( iseed, seedEnergy ); + } + else { + targetSeedsEnergy.at(0).first = iseed ; + targetSeedsEnergy.at(0).second = seedEnergy; + } + } + + } + + } + + if(targetSeedsEnergy.empty()) continue; + //Loop over target seeds and divide up the clusters energy + double totalTargetSeedEnergy = 0; + for (auto energy: targetSeedsEnergy){ + totalTargetSeedEnergy+=energy.second; + } + + for (auto energy: targetSeedsEnergy){ + + double seedWeight = 1; + if ( cluster_association_strategy_ == EnergySplit) seedWeight = energy.second/totalTargetSeedEnergy; + if( mapSeedMulticluster[energy.first].size()==0) { + mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight) ; + } + mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); + + } + + } + + + for(auto mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); + + return multiclustersTmp; + +} + + + + +void HGCalHistoClusteringImpl::clusterizeHisto( const std::vector> & clustersPtrs, + const std::vector > & seedPositionsEnergy, + const HGCalTriggerGeometryBase & triggerGeometry, + l1t::HGCalMulticlusterBxCollection & multiclusters) +{ + + + /* clusterize clusters around seeds */ + std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs,seedPositionsEnergy); + /* making the collection of multiclusters */ + finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); + +} + + + + + +void +HGCalHistoClusteringImpl:: +finalizeClusters(std::vector& multiclusters_in, + l1t::HGCalMulticlusterBxCollection& multiclusters_out, + const HGCalTriggerGeometryBase& triggerGeometry) { + for(auto& multicluster : multiclusters_in) { + // compute the eta, phi from its barycenter + // + pT as scalar sum of pT of constituents + double sumPt=multicluster.sumPt(); + + math::PtEtaPhiMLorentzVector multiclusterP4( sumPt, + multicluster.centre().eta(), + multicluster.centre().phi(), + 0. ); + multicluster.setP4( multiclusterP4 ); + + if( multicluster.pt() > ptC3dThreshold_ ){ + //compute shower shapes + multicluster.showerLength(shape_.showerLength(multicluster)); + multicluster.coreShowerLength(shape_.coreShowerLength(multicluster, triggerGeometry)); + multicluster.firstLayer(shape_.firstLayer(multicluster)); + multicluster.maxLayer(shape_.maxLayer(multicluster)); + multicluster.sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multicluster)); + multicluster.sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multicluster)); + multicluster.sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multicluster)); + multicluster.sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multicluster)); + multicluster.sigmaZZ(shape_.sigmaZZ(multicluster)); + multicluster.sigmaRRTot(shape_.sigmaRRTot(multicluster)); + multicluster.sigmaRRMax(shape_.sigmaRRMax(multicluster)); + multicluster.sigmaRRMean(shape_.sigmaRRMean(multicluster)); + multicluster.eMax(shape_.eMax(multicluster)); + // fill quality flag + multicluster.setHwQual(id_->decision(multicluster)); + // fill H/E + multicluster.saveHOverE(); + + multiclusters_out.push_back( 0, multicluster); + } + } +} diff --git a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc similarity index 64% rename from L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc rename to L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index ee3dc3b5bf542..2adb818e37cf3 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringHistoImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -1,15 +1,10 @@ -#include "L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringHistoImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h" #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Math/interface/deltaPhi.h" -HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::ParameterSet& conf ) : - dr_(conf.getParameter("dR_multicluster")), - dr_byLayer_coefficientA_(conf.existsAs>("dR_multicluster_byLayer_coefficientA") ? conf.getParameter>("dR_multicluster_byLayer_coefficientA") : std::vector()), - dr_byLayer_coefficientB_(conf.existsAs>("dR_multicluster_byLayer_coefficientB") ? conf.getParameter>("dR_multicluster_byLayer_coefficientB") : std::vector()), - ptC3dThreshold_(conf.getParameter("minPt_multicluster")), - multiclusterAlgoType_(conf.getParameter("type_multicluster")), - cluster_association_input_(conf.getParameter("cluster_association")), +HGCalHistoSeedingImpl::HGCalHistoSeedingImpl( const edm::ParameterSet& conf ) : + seedingAlgoType_(conf.getParameter("type_multicluster")), nBinsRHisto_(conf.getParameter("nBins_R_histo_multicluster")), nBinsPhiHisto_(conf.getParameter("nBins_Phi_histo_multicluster")), binsSumsHisto_(conf.getParameter< std::vector >("binSumsHisto")), @@ -17,38 +12,27 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::Paramet neighbour_weights_(conf.getParameter< std::vector >("neighbour_weights")) { - if(multiclusterAlgoType_=="HistoMaxC3d"){ - multiclusteringAlgoType_ = HistoMaxC3d; - }else if(multiclusterAlgoType_=="HistoSecondaryMaxC3d"){ - multiclusteringAlgoType_ = HistoSecondaryMaxC3d; - }else if(multiclusterAlgoType_=="HistoThresholdC3d"){ - multiclusteringAlgoType_ = HistoThresholdC3d; - }else if(multiclusterAlgoType_=="HistoInterpolatedMaxC3d"){ - multiclusteringAlgoType_ = HistoInterpolatedMaxC3d; + if(seedingAlgoType_=="HistoMaxC3d"){ + seedingType_ = HistoMaxC3d; + }else if(seedingAlgoType_=="HistoSecondaryMaxC3d"){ + seedingType_ = HistoSecondaryMaxC3d; + }else if(seedingAlgoType_=="HistoThresholdC3d"){ + seedingType_ = HistoThresholdC3d; + }else if(seedingAlgoType_=="HistoInterpolatedMaxC3d"){ + seedingType_ = HistoInterpolatedMaxC3d; }else { throw cms::Exception("HGCTriggerParameterError") - << "Unknown Multiclustering type '" << multiclusterAlgoType_; + << "Unknown Multiclustering type '" << seedingAlgoType_; } - if(cluster_association_input_=="NearestNeighbour"){ - cluster_association_strategy_ = NearestNeighbour; - }else if(cluster_association_input_=="EnergySplit"){ - cluster_association_strategy_ = EnergySplit; - }else { - throw cms::Exception("HGCTriggerParameterError") - << "Unknown cluster association strategy'" << cluster_association_strategy_; - } - - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR: " << dr_ - <<"\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_ - <<"\nMulticluster number of R-bins for the histo algorithm: " << nBinsRHisto_ + edm::LogInfo("HGCalMulticlusterParameters") <<"\nMulticluster number of R-bins for the histo algorithm: " << nBinsRHisto_ <<"\nMulticluster number of Phi-bins for the histo algorithm: " << nBinsPhiHisto_ <<"\nMulticluster MIPT threshold for histo threshold algorithm: " << histoThreshold_ - <<"\nMulticluster type of multiclustering algortihm: " << multiclusterAlgoType_; + <<"\nMulticluster type of multiclustering algortihm: " << seedingAlgoType_; id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; id_->initialize(conf.getParameter("EGIdentification")); - if(multiclusterAlgoType_.find("Histo")!=std::string::npos && nBinsRHisto_!=binsSumsHisto_.size()){ + if(seedingAlgoType_.find("Histo")!=std::string::npos && nBinsRHisto_!=binsSumsHisto_.size()){ throw cms::Exception("Inconsistent bin size") << "Inconsistent nBins_R_histo_multicluster ( " << nBinsRHisto_ << " ) and binSumsHisto ( " << binsSumsHisto_.size() << " ) size in HGCalMulticlustering\n"; } @@ -59,20 +43,7 @@ HGCalMulticlusteringHistoImpl::HGCalMulticlusteringHistoImpl( const edm::Paramet } - -float HGCalMulticlusteringHistoImpl::dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed) const -{ - - Basic3DVector seed_3dv( seed ); - GlobalPoint seed_proj( seed_3dv / seed.z() ); - return (seed_proj - clu.centreProj() ).mag(); - -} - - - -HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillHistoClusters( const std::vector> & clustersPtrs ){ +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillHistoClusters( const std::vector> & clustersPtrs ){ Histogram histoClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi @@ -109,7 +80,7 @@ HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillHist -HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoothPhiHistoClusters( const Histogram & histoClusters, +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoClusters( const Histogram & histoClusters, const vector & binSums ){ Histogram histoSumPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi @@ -156,7 +127,7 @@ HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoo -HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoothRPhiHistoClusters( const Histogram & histoClusters ){ +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothRPhiHistoClusters( const Histogram & histoClusters ){ Histogram histoSumRPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi @@ -187,7 +158,7 @@ HGCalMulticlusteringHistoImpl::Histogram HGCalMulticlusteringHistoImpl::fillSmoo -std::vector > HGCalMulticlusteringHistoImpl::computeMaxSeeds( const Histogram & histoClusters ){ +std::vector > HGCalHistoSeedingImpl::computeMaxSeeds( const Histogram & histoClusters ){ std::vector > seedPositionsEnergy; @@ -245,7 +216,7 @@ std::vector > HGCalMulticlusteringHistoImpl::com } -std::vector > HGCalMulticlusteringHistoImpl::computeInterpolatedMaxSeeds( const Histogram & histoClusters ){ +std::vector > HGCalHistoSeedingImpl::computeInterpolatedMaxSeeds( const Histogram & histoClusters ){ std::vector > seedPositionsEnergy; @@ -298,7 +269,7 @@ std::vector > HGCalMulticlusteringHistoImpl::com } -std::vector > HGCalMulticlusteringHistoImpl::computeThresholdSeeds( const Histogram & histoClusters ){ +std::vector > HGCalHistoSeedingImpl::computeThresholdSeeds( const Histogram & histoClusters ){ std::vector > seedPositionsEnergy; @@ -332,7 +303,7 @@ std::vector > HGCalMulticlusteringHistoImpl::com -std::vector > HGCalMulticlusteringHistoImpl::computeSecondaryMaxSeeds( const Histogram & histoClusters ){ +std::vector > HGCalHistoSeedingImpl::computeSecondaryMaxSeeds( const Histogram & histoClusters ){ std::vector > seedPositionsEnergy; @@ -468,87 +439,8 @@ std::vector > HGCalMulticlusteringHistoImpl::com } - -std::vector HGCalMulticlusteringHistoImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector > & seeds){ - - std::map mapSeedMulticluster; - std::vector multiclustersTmp; - - for(auto & clu : clustersPtrs){ - - int z_side = triggerTools_.zside(clu->detId()); - - - double radiusCoefficientA = dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment - double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment - - double minDist = radiusCoefficientA + radiusCoefficientB*(kMidRadius_ - std::abs(clu->eta()) ) ; - - std::vector > targetSeedsEnergy; - - for( unsigned int iseed=0; iseeddR(*clu, seeds[iseed].first); - - if ( d < minDist ){ - if ( cluster_association_strategy_ == EnergySplit ){ - targetSeedsEnergy.emplace_back( iseed, seedEnergy ); - } - if ( cluster_association_strategy_ == NearestNeighbour ){ - - minDist = d; - - if ( targetSeedsEnergy.empty() ) { - targetSeedsEnergy.emplace_back( iseed, seedEnergy ); - } - else { - targetSeedsEnergy.at(0).first = iseed ; - targetSeedsEnergy.at(0).second = seedEnergy; - } - } - - } - - } - - if(targetSeedsEnergy.empty()) continue; - //Loop over target seeds and divide up the clusters energy - double totalTargetSeedEnergy = 0; - for (auto energy: targetSeedsEnergy){ - totalTargetSeedEnergy+=energy.second; - } - - for (auto energy: targetSeedsEnergy){ - - double seedWeight = 1; - if ( cluster_association_strategy_ == EnergySplit) seedWeight = energy.second/totalTargetSeedEnergy; - if( mapSeedMulticluster[energy.first].size()==0) { - mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight) ; - } - mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); - - } - - } - - - for(auto mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); - - return multiclustersTmp; - -} - - - - -void HGCalMulticlusteringHistoImpl::clusterizeHisto( const std::vector> & clustersPtrs, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry) +void HGCalHistoSeedingImpl::findHistoSeeds( const std::vector> & clustersPtrs, + std::vector > & seedPositionsEnergy) { /* put clusters into an r/z x phi histogram */ @@ -561,61 +453,10 @@ void HGCalMulticlusteringHistoImpl::clusterizeHisto( const std::vector > seedPositionsEnergy; - if (multiclusteringAlgoType_ == HistoMaxC3d) seedPositionsEnergy = computeMaxSeeds(smoothRPhiHistoCluster); - else if(multiclusteringAlgoType_ == HistoThresholdC3d) seedPositionsEnergy = computeThresholdSeeds(smoothRPhiHistoCluster); - else if(multiclusteringAlgoType_ == HistoInterpolatedMaxC3d) seedPositionsEnergy = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); - else if(multiclusteringAlgoType_ == HistoSecondaryMaxC3d) seedPositionsEnergy = computeSecondaryMaxSeeds(smoothRPhiHistoCluster); - /* clusterize clusters around seeds */ - std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs,seedPositionsEnergy); - /* making the collection of multiclusters */ - finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); + if (seedingType_ == HistoMaxC3d) seedPositionsEnergy = computeMaxSeeds(smoothRPhiHistoCluster); + else if(seedingType_ == HistoThresholdC3d) seedPositionsEnergy = computeThresholdSeeds(smoothRPhiHistoCluster); + else if(seedingType_ == HistoInterpolatedMaxC3d) seedPositionsEnergy = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); + else if(seedingType_ == HistoSecondaryMaxC3d) seedPositionsEnergy = computeSecondaryMaxSeeds(smoothRPhiHistoCluster); } - - - - - - -void -HGCalMulticlusteringHistoImpl:: -finalizeClusters(std::vector& multiclusters_in, - l1t::HGCalMulticlusterBxCollection& multiclusters_out, - const HGCalTriggerGeometryBase& triggerGeometry) { - for(auto& multicluster : multiclusters_in) { - // compute the eta, phi from its barycenter - // + pT as scalar sum of pT of constituents - double sumPt=multicluster.sumPt(); - - math::PtEtaPhiMLorentzVector multiclusterP4( sumPt, - multicluster.centre().eta(), - multicluster.centre().phi(), - 0. ); - multicluster.setP4( multiclusterP4 ); - - if( multicluster.pt() > ptC3dThreshold_ ){ - //compute shower shapes - multicluster.showerLength(shape_.showerLength(multicluster)); - multicluster.coreShowerLength(shape_.coreShowerLength(multicluster, triggerGeometry)); - multicluster.firstLayer(shape_.firstLayer(multicluster)); - multicluster.maxLayer(shape_.maxLayer(multicluster)); - multicluster.sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multicluster)); - multicluster.sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multicluster)); - multicluster.sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multicluster)); - multicluster.sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multicluster)); - multicluster.sigmaZZ(shape_.sigmaZZ(multicluster)); - multicluster.sigmaRRTot(shape_.sigmaRRTot(multicluster)); - multicluster.sigmaRRMax(shape_.sigmaRRMax(multicluster)); - multicluster.sigmaRRMean(shape_.sigmaRRMean(multicluster)); - multicluster.eMax(shape_.eMax(multicluster)); - // fill quality flag - multicluster.setHwQual(id_->decision(multicluster)); - // fill H/E - multicluster.saveHOverE(); - - multiclusters_out.push_back( 0, multicluster); - } - } -} From 9816858a94126dc962394b406e9d60285c98bb93 Mon Sep 17 00:00:00 2001 From: Samuel Webb Date: Thu, 21 Mar 2019 11:38:52 +0100 Subject: [PATCH 293/686] Enable the use of super trigger cells in the V9 geometry --- .../HGCalConcentratorSuperTriggerCellImpl.h | 15 ++-- .../python/hgcalConcentratorProducer_cfi.py | 2 +- .../HGCalConcentratorSuperTriggerCellImpl.cc | 89 ++++++++++++++++--- .../L1THGCalUtilities/python/concentrator.py | 7 +- 4 files changed, 91 insertions(+), 22 deletions(-) diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h index ed2d522358d42..9eec77e92233c 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h @@ -6,9 +6,12 @@ #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h" +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetIdToROC.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" + + #include #include @@ -23,15 +26,15 @@ class HGCalConcentratorSuperTriggerCellImpl private: int getSuperTriggerCellId(int detid) const ; - static const int kSplit12_ = 0x3a; - static const int kSplit3_ = 0x30; + static std::map kSplit_; static const int kWafer_offset_ = 6; - - static const int kSTCsize16_ = 16; - static const int kSTCsize4_ = 4; + static const int kSTCsizeCoarse_ = 16; + static const int kSTCsizeFine_ = 4; static const int kNLayers_ = 3; + static const int kSplit_v9_ = 0x36; HGCalTriggerTools triggerTools_; + HGCSiliconDetIdToROC detIdToROC_; std::vector stcSize_; class SuperTriggerCell { @@ -40,7 +43,7 @@ class HGCalConcentratorSuperTriggerCellImpl float sumPt_, sumMipPt_; int sumHwPt_, maxHwPt_; unsigned maxId_; - + public: SuperTriggerCell(){ sumPt_=0, sumMipPt_=0, sumHwPt_=0, maxHwPt_=0, maxId_=0 ;} void add(const l1t::HGCalTriggerCell &c) { diff --git a/L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py b/L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py index 7c52c58537730..d6e19f843078f 100644 --- a/L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalConcentratorProducer_cfi.py @@ -15,7 +15,7 @@ TCThreshold_fC = cms.double(0.), TCThresholdBH_MIP = cms.double(0.), triggercell_threshold_silicon = cms.double(2.), # MipT - triggercell_threshold_scintillator = cms.double(2.) # MipT + triggercell_threshold_scintillator = cms.double(2.), # MipT ) hgcalConcentratorProducer = cms.EDProducer( diff --git a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc index c2f37684c7e1f..f2464e9afce5c 100644 --- a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc +++ b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc @@ -1,4 +1,5 @@ #include "L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h" +#include "DataFormats/ForwardDetId/interface/HGCalTriggerDetId.h" #include @@ -12,7 +13,7 @@ HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) << "Inconsistent size of super trigger cell size vector" << stcSize_.size() ; } for(auto stc : stcSize_) { - if ( stc!=kSTCsize4_ && stc!=kSTCsize16_ ){ + if ( stc!=kSTCsizeFine_ && stc!=kSTCsizeCoarse_ ){ throw cms::Exception("HGCTriggerParameterError") << "Super Trigger Cell should be of size 4 or 16" ; } @@ -20,24 +21,86 @@ HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) } +std::map +HGCalConcentratorSuperTriggerCellImpl::kSplit_ = { + {4, 0x3a}, + {16, 0x30} +}; int HGCalConcentratorSuperTriggerCellImpl::getSuperTriggerCellId(int detid) const { - // FIXME: won't work in the V9 geometry - HGCalDetId TC_id(detid); - if(TC_id.subdetId()==HGCHEB) { - return TC_id.cell(); //scintillator - } else { - int TC_wafer = TC_id.wafer(); - int TC_12th = ( TC_id.cell() & kSplit12_ ); - int TC_3rd = ( TC_id.cell() & kSplit3_ ); - int thickness = triggerTools_.thicknessIndex(detid,true); - int TC_split = TC_12th; - if (stcSize_.at(thickness) == kSTCsize16_) TC_split = TC_3rd; + DetId TC_id( detid ); + if ( TC_id.det() == DetId::Forward ){//V8 - return TC_wafer< Date: Tue, 26 Mar 2019 21:00:13 +0100 Subject: [PATCH 294/686] Configurable parameters changed to Untracked, iterators changed to auto& it --- .../HcalRecAlgos/src/HFStripFilter.cc | 168 +++++++++--------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index e6707e816afdd..5a0d6fa40dcf4 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -39,20 +39,19 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const std::vector d1strip; std::vector d2strip; - std::vector::const_iterator it1; HFRecHit d1max; HFRecHit d2max; d1max.setEnergy(-10); // find d1 and d2 seed hits with max energy and time < timeMax_ - for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + for (auto& it : rec) { - if ((*it).time() > timeMax_ || (*it).time() < 0 || (*it).energy() < stripThreshold_) continue; + if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; // find HF hit with maximum signal in depth = 1 - if ((*it).id().depth() == 1) { - if ((*it).energy() > d1max.energy() && abs((*it).id().ieta()) < 35) { - d1max = (*it); + if (it.id().depth() == 1) { + if (it.energy() > d1max.energy() && std::abs(it.id().ieta()) < 35) { + d1max = it; } } } @@ -64,24 +63,24 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const int stripIetaMax = 0; if (d1max.energy() > 0) { - signStripIeta = d1max.id().ieta()/abs(d1max.id().ieta()); + signStripIeta = d1max.id().ieta()/std::abs(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); } d2max.setEnergy(-10); - for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + for (auto& it : rec) { - if ((*it).time() > timeMax_ || (*it).time() < 0 || (*it).energy() < stripThreshold_) continue; + if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; // find HFhit with maximum signal in depth = 2 - if ((*it).id().depth() == 2 && (*it).energy() > d2max.energy() && abs((*it).id().ieta()) < 35) { + if (it.id().depth() == 2 && it.energy() > d2max.energy() && std::abs(it.id().ieta()) < 35) { if (d1max.energy() > 0) { - int signIeta = (*it).id().ieta()/abs((*it).id().ieta()); - if ((*it).id().iphi() == stripIphiMax && signIeta == signStripIeta) { - d2max = (*it); + int signIeta = it.id().ieta()/std::abs(it.id().ieta()); + if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta) { + d2max = it; } } else { - d2max = (*it); + d2max = it; } } } @@ -92,7 +91,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; if (stripIphiMax == 0 && d2max.energy() > 0) { - signStripIeta = d2max.id().ieta()/abs(d2max.id().ieta()); + signStripIeta = d2max.id().ieta()/std::abs(d2max.id().ieta()); stripIphiMax = d2max.id().iphi(); stripIetaMax = d2max.id().ieta(); } @@ -110,31 +109,31 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // prepare the strips: all hits along given ieta in one wedge (d1strip and d2strip) //--------------------------------------------------------------------------------- - for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + for (auto& it : rec) { - if ((*it).energy() < stripThreshold_) continue; - int signIeta = (*it).id().ieta()/abs((*it).id().ieta()); + if (it.energy() < stripThreshold_) continue; + int signIeta = it.id().ieta()/std::abs(it.id().ieta()); if (verboseLevel_ >= 30) { - ss << " HF hit: ieta = " << (*it).id().ieta() << "\t iphi = " << (*it).id().iphi() - << "\t depth = " << (*it).id().depth() << "\t time = " << (*it).time() << "\t energy = " - << (*it).energy() << "\t flags = " << (*it).flags() << std::endl; + ss << " HF hit: ieta = " << it.id().ieta() << "\t iphi = " << it.id().iphi() + << "\t depth = " << it.id().depth() << "\t time = " << it.time() << "\t energy = " + << it.energy() << "\t flags = " << it.flags() << std::endl; } // collect hits with the same iphi but different ieta into strips - if ((*it).id().iphi() == stripIphiMax && signIeta == signStripIeta - && (*it).time() < maxStripTime_) { - if ((*it).id().depth() == 1) { + if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta && + it.time() < maxStripTime_) { + if (it.id().depth() == 1) { // check if hit = (*it) is already in d1strip bool pass = false; if (d1strip.empty()) { - if (abs((*it).id().iphi() - stripIetaMax) <= gap_) { - d1strip.push_back((*it)); + if (std::abs(it.id().iphi() - stripIetaMax) <= gap_) { + d1strip.push_back(it); pass = true; } } else { - for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { - if ((*it).id().ieta() == (*it1).id().ieta() && (*it).energy() == (*it1).energy()) { + for (auto& it1 : d1strip) { + if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { pass = true; break; } @@ -142,25 +141,25 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const } if (pass) continue; // add hit = (*it) to d1strip if distance to the closest hit in d1strip <= gap_ - for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { + for (auto& it1 : d1strip) { // check distance along Ieta to the closest hit - if (abs((*it1).id().ieta() - (*it).id().ieta()) <= gap_) { - d1strip.push_back((*it)); + if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { + d1strip.push_back(it); break; } } } - else if ((*it).id().depth() == 2) { + else if (it.id().depth() == 2) { // check if hit = (*it) is already in d2strip bool pass= false; if (d2strip.empty()) { - if (abs((*it).id().ieta() - stripIetaMax) <= gap_) { - d2strip.push_back((*it)); + if (std::abs(it.id().ieta() - stripIetaMax) <= gap_) { + d2strip.push_back(it); pass = true; } } else { - for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { - if ((*it).id().ieta() == (*it1).id().ieta() && (*it).energy() == (*it1).energy()) { + for (auto& it1 : d2strip) { + if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { pass = true; break; } @@ -169,10 +168,10 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (pass) continue; // add hit = (*it) to d2strip if distance to the closest hit in d1strip <= gap_ - for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { + for (auto& it1 : d2strip) { // check distance along Ieta to the closest hit - if (abs((*it1).id().ieta() - (*it).id().ieta()) <= gap_) { - d2strip.push_back((*it)); + if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { + d2strip.push_back(it); break; } } @@ -183,11 +182,11 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (verboseLevel_ >= 30) { ss << " Lstrip1 = " << (int)d1strip.size() << " (iphi = " << stripIphiMax << ") Lstrip2 = " << (int)d2strip.size() << std::endl << " Strip1: "; - for (it1 = d1strip.begin(); it1 < d1strip.end(); it1++) { - ss << (*it1).energy() << " (" << (*it1).id().ieta() << ") "; } + for (auto& it1 : d1strip) { + ss << it1.energy() << " (" << it1.id().ieta() << ") "; } ss << std::endl << " Strip2: "; - for (it1 = d2strip.begin(); it1 < d2strip.end(); it1++) { - ss << (*it1).energy() << " (" << (*it1).id().ieta() << ") "; } + for (auto& it1 : d2strip) { + ss << it1.energy() << " (" << it1.id().ieta() << ") "; } ss << std::endl; } @@ -202,15 +201,15 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // define range of strips in ieta int ietaMin1 = 1000; // for d1strip int ietaMax1 = -1000; - for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin1) ietaMin1 = (*it1).id().ieta(); - if ((*it1).id().ieta() > ietaMax1) ietaMax1 = (*it1).id().ieta(); + for (auto& it1 : d1strip) { + if (it1.id().ieta() < ietaMin1) ietaMin1 = it1.id().ieta(); + if (it1.id().ieta() > ietaMax1) ietaMax1 = it1.id().ieta(); } int ietaMin2 = 1000; // for d2strip int ietaMax2 = -1000; - for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin2) ietaMin2 = (*it1).id().ieta(); - if ((*it1).id().ieta() > ietaMax2) ietaMax2 = (*it1).id().ieta(); + for (auto& it1 : d2strip) { + if (it1.id().ieta() < ietaMin2) ietaMin2 = it1.id().ieta(); + if (it1.id().ieta() > ietaMax2) ietaMax2 = it1.id().ieta(); } // define ietamin and ietamax - common area for d1strip and d2strip @@ -226,13 +225,13 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // calculate the total energy in strips double eStrip = 0; - for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; - eStrip += (*it1).energy(); + for (auto& it1 : d1strip) { + if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; + eStrip += it1.energy(); } - for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; - eStrip += (*it1).energy(); + for (auto& it1 : d2strip) { + if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; + eStrip += it1.energy(); } if (verboseLevel_ >= 30) { @@ -242,7 +241,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const } int phiseg = 2; // 10 degrees segmentation for most of HF (1 iphi unit = 5 degrees) - if (abs(d1strip[0].id().ieta()) > 39) phiseg = 4; // 20 degrees segmentation for |ieta| > 39 + if (std::abs(d1strip[0].id().ieta()) > 39) phiseg = 4; // 20 degrees segmentation for |ieta| > 39 // Check if seed hit has neighbours with (iphi +/- phiseg) and the same ieta int iphi1 = d1strip[0].id().iphi() - phiseg; @@ -253,12 +252,12 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // energies in the neighboring wedges double energyIphi1 = 0; double energyIphi2 = 0; - for (HFRecHitCollection::const_iterator it = rec.begin(); it != rec.end(); ++it) + for (auto& it : rec) { - if ((*it).energy() < stripThreshold_) continue; - if ((*it).id().ieta() < ietaMin || (*it).id().ieta() > ietaMax) continue; - if ((*it).id().iphi() == iphi1) energyIphi1 += (*it).energy(); // iphi1 - else if ((*it).id().iphi() == iphi2) energyIphi2 += (*it).energy(); // iphi2 + if (it.energy() < stripThreshold_) continue; + if (it.id().ieta() < ietaMin || it.id().ieta() > ietaMax) continue; + if (it.id().iphi() == iphi1) energyIphi1 += it.energy(); // iphi1 + else if (it.id().iphi() == iphi2) energyIphi2 += it.energy(); // iphi2 } double ratio1 = eStrip > 0 ? energyIphi1/eStrip : 0; @@ -280,11 +279,11 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const ss << " stripPass = false" << std::endl << " mark hits in strips now " << std::endl; } - + // Figure out which rechits need to be tagged (d1.strip) - for (it1 = d1strip.begin(); it1 < d1strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; - HFRecHitCollection::iterator hit = rec.find((*it1).id()); + for (auto& it1 : d1strip) { + if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; + HFRecHitCollection::iterator hit = rec.find(it1.id()); if (hit != rec.end()) { // tag a rechit with the anomalous hit flag if (verboseLevel_ >= 30) { @@ -293,10 +292,11 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const hit->setFlagField(1U, HcalPhase1FlagLabels::HFAnomalousHit); } } + // Figure out which rechits need to be tagged (d2.strip) - for (it1 = d2strip.begin(); it1 < d2strip.end(); ++it1) { - if ((*it1).id().ieta() < ietaMin || (*it1).id().ieta() > ietaMax) continue; - HFRecHitCollection::iterator hit = rec.find((*it1).id()); + for (auto& it1 : d2strip) { + if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; + HFRecHitCollection::iterator hit = rec.find(it1.id()); if (hit != rec.end()) { // tag a rechit with the anomalous hit flag if (verboseLevel_ >= 30) { @@ -322,14 +322,14 @@ std::unique_ptr HFStripFilter::parseParameterSet( const edm::ParameterSet& ps) { return std::make_unique( - ps.getParameter("stripThreshold"), - ps.getParameter("maxThreshold"), - ps.getParameter("timeMax"), - ps.getParameter("maxStripTime"), - ps.getParameter("wedgeCut"), - ps.getParameter("gap"), - ps.getParameter("lstrips"), - ps.getParameter("verboseLevel") + ps.getUntrackedParameter("stripThreshold"), + ps.getUntrackedParameter("maxThreshold"), + ps.getUntrackedParameter("timeMax"), + ps.getUntrackedParameter("maxStripTime"), + ps.getUntrackedParameter("wedgeCut"), + ps.getUntrackedParameter("gap"), + ps.getUntrackedParameter("lstrips"), + ps.getUntrackedParameter("verboseLevel") ); } @@ -337,14 +337,14 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() { edm::ParameterSetDescription desc; - desc.add("stripThreshold", 40.0); - desc.add("maxThreshold", 100.0); - desc.add("timeMax", 6.0); - desc.add("maxStripTime", 10.0); - desc.add("wedgeCut", 0.05); - desc.add("gap", 2); - desc.add("lstrips", 2); - desc.add("verboseLevel", 0); + desc.addUntracked("stripThreshold", 40.0); + desc.addUntracked("maxThreshold", 100.0); + desc.addUntracked("timeMax", 6.0); + desc.addUntracked("maxStripTime", 10.0); + desc.addUntracked("wedgeCut", 0.05); + desc.addUntracked("gap", 2); + desc.addUntracked("lstrips", 2); + desc.addUntracked("verboseLevel", 0); return desc; } From b3f15d4e5dead81802bbfaf26cdac5e10f0c4dbc Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Tue, 26 Mar 2019 21:00:59 +0100 Subject: [PATCH 295/686] Configurable parameters changed to Untracked --- .../python/HFPhase1Reconstructor_cfi.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index e97f8899ce925..3b4c374bf4373 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -199,13 +199,13 @@ # Parameters for HFStripFilter. # Please add some descriptions of their meaning. HFStripFilter = cms.PSet( - stripThreshold = cms.double(40.0), - maxThreshold = cms.double(100.0), - timeMax = cms.double(6.0), - maxStripTime = cms.double(10.0), - wedgeCut = cms.double(0.05), - gap = cms.int32(2), - lstrips = cms.int32(2), - verboseLevel = cms.int32(20) + stripThreshold = cms.untracked.double(40.0), + maxThreshold = cms.untracked.double(100.0), + timeMax = cms.untracked.double(6.0), + maxStripTime = cms.untracked.double(10.0), + wedgeCut = cms.untracked.double(0.05), + gap = cms.untracked.int32(2), + lstrips = cms.untracked.int32(2), + verboseLevel = cms.untracked.int32(20) ) ) From 584e20215130a0eeb9d4094836bc30a4456079ef Mon Sep 17 00:00:00 2001 From: jingyu zhang Date: Tue, 26 Mar 2019 16:38:15 -0500 Subject: [PATCH 296/686] add tot plots to HGCal Validation + some minor fixes --- .../plugins/HGCalDigiValidation.cc | 101 +++++++++++------- .../plugins/HGCalRecHitValidation.cc | 2 +- 2 files changed, 66 insertions(+), 37 deletions(-) diff --git a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc index 8e67733b87247..b4cec5f42b9a2 100644 --- a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc @@ -59,9 +59,11 @@ class HGCalDigiValidation : public DQMEDAnalyzer { digiInfo() { x = y = z = charge = 0.0; layer = adc = 0; + mode = threshold = false; } double x, y, z, charge; int layer, adc; + bool mode, threshold; //tot mode and zero supression }; explicit HGCalDigiValidation(const edm::ParameterSet&); @@ -78,7 +80,7 @@ class HGCalDigiValidation : public DQMEDAnalyzer { void fillOccupancyMap(std::map& OccupancyMap, int layer); template void digiValidation(const T1& detId, const T2* geom, int layer, - uint16_t adc, double charge); + uint16_t adc, double charge, bool mode, bool threshold); // ----------member data --------------------------- std::string nameDetector_; @@ -90,9 +92,11 @@ class HGCalDigiValidation : public DQMEDAnalyzer { std::map OccupancyMap_plus_; std::map OccupancyMap_minus_; - std::vector charge_; + //std::vector charge_; + std::vector TOA_; std::vector DigiOccupancy_XY_; std::vector ADC_; + std::vector TOT_; std::vector DigiOccupancy_Plus_; std::vector DigiOccupancy_Minus_; MonitorElement* MeanDigiOccupancy_Plus_; @@ -132,7 +136,7 @@ void HGCalDigiValidation::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("ifNose",false); desc.add("ifHCAL",false); desc.addUntracked("Verbosity",0); - desc.addUntracked("SampleIndx",0); + desc.addUntracked("SampleIndx",2); descriptions.add("hgcalDigiValidationEEDefault",desc); } @@ -188,8 +192,11 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom0, layer, adc, charge); + //double charge = adc*gain; + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom0, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -215,8 +222,11 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom0, layer, adc, charge); + //double charge = adc*gain; + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom0, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -239,8 +249,11 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom1, layer, adc, charge); + //double charge = adc*gain; + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom1, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -271,11 +284,13 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, HcalCoderDb coder(*channelCoder, *shape); CaloSamples tool; coder.adc2fC(df, tool); - int layer = detId.depth(); - uint16_t adc = (df)[SampleIndx_].adc(); - int capid = (df)[SampleIndx_].capid(); - double charge = (tool[SampleIndx_] - calibrations.pedestal(capid)); - digiValidation(detId, geom1, layer, adc, charge); + int layer = detId.depth(); + uint16_t adc = (df)[SampleIndx_].adc(); + int capid = (df)[SampleIndx_].capid(); + double charge = (tool[SampleIndx_] - calibrations.pedestal(capid)); + bool totmode = false; + bool zerothreshold = false; + digiValidation(detId, geom1, layer, adc, charge, totmode, zerothreshold); } } fillDigiInfo(); @@ -287,44 +302,46 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, edm::LogWarning("HGCalValidation") << "invalid detector name !! " << nameDetector_; } - if (verbosity_>0) - edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event() - << " with " << ntot << " total and " - << nused << " used digis"; + edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event() + << " with " << ntot << " total and " + << nused << " used digis"; } template void HGCalDigiValidation::digiValidation(const T1& detId, const T2* geom, int layer, uint16_t adc, - double charge) { + double charge, bool mode, bool threshold) { if (verbosity_>1) edm::LogVerbatim("HGCalValidation") << std::hex << detId.rawId() - << std::dec; + << std::dec + << " " << detId.rawId(); DetId id1 = DetId(detId.rawId()); const GlobalPoint& global1 = geom->getPosition(id1); if (verbosity_>1) - edm::LogVerbatim("HGCalValidation") << " adc = " << adc - << " charge = " << charge; + edm::LogVerbatim("HGCalValidation") << " adc = " << adc + << " toa = " << charge; digiInfo hinfo; - hinfo.x = global1.x(); - hinfo.y = global1.y(); - hinfo.z = global1.z(); - hinfo.adc = adc; - hinfo.charge = charge; - hinfo.layer = layer-firstLayer_; + hinfo.x = global1.x(); + hinfo.y = global1.y(); + hinfo.z = global1.z(); + hinfo.adc = adc; + hinfo.charge = charge; + hinfo.layer = layer-firstLayer_; + hinfo.mode = mode; + hinfo.threshold = threshold; if (verbosity_>1) edm::LogVerbatim("HGCalValidation") << "gx = " << hinfo.x << " gy = " << hinfo.y << " gz = " << hinfo.z; - - fillDigiInfo(hinfo); if (global1.eta() > 0) fillOccupancyMap(OccupancyMap_plus_, hinfo.layer); else fillOccupancyMap(OccupancyMap_minus_, hinfo.layer); + + fillDigiInfo(hinfo); } @@ -336,9 +353,16 @@ void HGCalDigiValidation::fillOccupancyMap(std::map& OccupancyMap, void HGCalDigiValidation::fillDigiInfo(digiInfo& hinfo) { int ilayer = hinfo.layer; - charge_.at(ilayer)->Fill(hinfo.charge); - DigiOccupancy_XY_.at(ilayer)->Fill(hinfo.x, hinfo.y); - ADC_.at(ilayer)->Fill(hinfo.adc); + TOA_.at(ilayer)->Fill(hinfo.charge); + + if (hinfo.mode) { + TOT_.at(ilayer)->Fill(hinfo.adc); + } + + if (!hinfo.mode && hinfo.threshold) { + ADC_.at(ilayer)->Fill(hinfo.adc); + DigiOccupancy_XY_.at(ilayer)->Fill(hinfo.x, hinfo.y); + } } void HGCalDigiValidation::fillDigiInfo() { @@ -386,11 +410,16 @@ void HGCalDigiValidation::bookHistograms(DQMStore::IBooker& iB, std::ostringstream histoname; for (int il = 0; il < layers_; ++il) { int ilayer = firstLayer_ + il; - histoname.str(""); histoname << "charge_"<< "layer_" << ilayer; - charge_.push_back(iB.book1D(histoname.str().c_str(),"charge_",100,-25,25)); + //histoname.str(""); histoname << "charge_"<< "layer_" << ilayer; + //charge_.push_back(iB.book1D(histoname.str().c_str(),"charge_",100,-25,25)); + histoname.str(""); histoname << "TOA_"<< "layer_" << ilayer; + TOA_.push_back(iB.book1D(histoname.str().c_str(),"toa_",1024,0,1024)); histoname.str(""); histoname << "ADC_" << "layer_" << ilayer; - ADC_.push_back(iB.book1D(histoname.str().c_str(), "DigiOccupancy",200,0,1000)); + ADC_.push_back(iB.book1D(histoname.str().c_str(), "ADCDigiOccupancy",1024,0,1024)); + + histoname.str(""); histoname << "TOT_" << "layer_" << ilayer; + TOT_.push_back(iB.book1D(histoname.str().c_str(), "TOTDigiOccupancy",4096,0,4096)); histoname.str(""); histoname << "DigiOccupancy_XY_" << "layer_" << ilayer; DigiOccupancy_XY_.push_back(iB.book2D(histoname.str().c_str(), "DigiOccupancy", 50, -500, 500, 50, -500, 500)); diff --git a/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc b/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc index a2f7d2affd0ea..0b26e00e8649e 100644 --- a/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc @@ -324,7 +324,7 @@ void HGCalRecHitValidation::bookHistograms(DQMStore::IBooker& iB, EtaPhi_Minus_.push_back(iB.book2D(histoname.str().c_str(), "Occupancy", 31, -3.0, -1.45, 72, -CLHEP::pi, CLHEP::pi)); histoname.str(""); histoname << "energy_layer_" << ilayer; - energy_.push_back(iB.book1D(histoname.str().c_str(),"energy_",100,0,0.002)); + energy_.push_back(iB.book1D(histoname.str().c_str(),"energy_",500,0,1)); }//loop over layers ends here histoname.str(""); histoname << "SUMOfRecHitOccupancy_Plus"; From 3d072b10477b14f30ebabe7322ea88d566130326 Mon Sep 17 00:00:00 2001 From: jingyu zhang Date: Tue, 26 Mar 2019 16:47:11 -0500 Subject: [PATCH 297/686] add some comments --- .../HGCalValidation/plugins/HGCalDigiValidation.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc index b4cec5f42b9a2..450f05dfc4c05 100644 --- a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc @@ -136,7 +136,7 @@ void HGCalDigiValidation::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("ifNose",false); desc.add("ifHCAL",false); desc.addUntracked("Verbosity",0); - desc.addUntracked("SampleIndx",2); + desc.addUntracked("SampleIndx",2); // central bx descriptions.add("hgcalDigiValidationEEDefault",desc); } @@ -302,9 +302,10 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, edm::LogWarning("HGCalValidation") << "invalid detector name !! " << nameDetector_; } - edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event() - << " with " << ntot << " total and " - << nused << " used digis"; + if (verbosity_>0) + edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event() + << " with " << ntot << " total and " + << nused << " used digis"; } template @@ -353,6 +354,7 @@ void HGCalDigiValidation::fillOccupancyMap(std::map& OccupancyMap, void HGCalDigiValidation::fillDigiInfo(digiInfo& hinfo) { int ilayer = hinfo.layer; + //charge_.at(ilayer)->Fill(hinfo.charge); TOA_.at(ilayer)->Fill(hinfo.charge); if (hinfo.mode) { From d74a10b59197c2f39a9559fc3258dba2388e4735 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Wed, 27 Mar 2019 09:15:07 +0100 Subject: [PATCH 298/686] Set some configurable parameters back to tracked type --- .../HcalRecAlgos/src/HFStripFilter.cc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 5a0d6fa40dcf4..65c5ffd96977c 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -322,13 +322,13 @@ std::unique_ptr HFStripFilter::parseParameterSet( const edm::ParameterSet& ps) { return std::make_unique( - ps.getUntrackedParameter("stripThreshold"), - ps.getUntrackedParameter("maxThreshold"), - ps.getUntrackedParameter("timeMax"), - ps.getUntrackedParameter("maxStripTime"), - ps.getUntrackedParameter("wedgeCut"), - ps.getUntrackedParameter("gap"), - ps.getUntrackedParameter("lstrips"), + ps.getParameter("stripThreshold"), + ps.getParameter("maxThreshold"), + ps.getParameter("timeMax"), + ps.getParameter("maxStripTime"), + ps.getParameter("wedgeCut"), + ps.getParameter("gap"), + ps.getParameter("lstrips"), ps.getUntrackedParameter("verboseLevel") ); } @@ -337,13 +337,13 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() { edm::ParameterSetDescription desc; - desc.addUntracked("stripThreshold", 40.0); - desc.addUntracked("maxThreshold", 100.0); - desc.addUntracked("timeMax", 6.0); - desc.addUntracked("maxStripTime", 10.0); - desc.addUntracked("wedgeCut", 0.05); - desc.addUntracked("gap", 2); - desc.addUntracked("lstrips", 2); + desc.add("stripThreshold", 40.0); + desc.add("maxThreshold", 100.0); + desc.add("timeMax", 6.0); + desc.add("maxStripTime", 10.0); + desc.add("wedgeCut", 0.05); + desc.add("gap", 2); + desc.add("lstrips", 2); desc.addUntracked("verboseLevel", 0); return desc; From d9d3909fbb32187ee58521da3ade4a1febeb8de8 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Wed, 27 Mar 2019 09:17:59 +0100 Subject: [PATCH 299/686] Set some configurable parameters back to tracked type --- .../python/HFPhase1Reconstructor_cfi.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index 3b4c374bf4373..b2c8c3fe19cbc 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -199,13 +199,13 @@ # Parameters for HFStripFilter. # Please add some descriptions of their meaning. HFStripFilter = cms.PSet( - stripThreshold = cms.untracked.double(40.0), - maxThreshold = cms.untracked.double(100.0), - timeMax = cms.untracked.double(6.0), - maxStripTime = cms.untracked.double(10.0), - wedgeCut = cms.untracked.double(0.05), - gap = cms.untracked.int32(2), - lstrips = cms.untracked.int32(2), + stripThreshold = cms.double(40.0), + maxThreshold = cms.double(100.0), + timeMax = cms.double(6.0), + maxStripTime = cms.double(10.0), + wedgeCut = cms.double(0.05), + gap = cms.int32(2), + lstrips = cms.int32(2), verboseLevel = cms.untracked.int32(20) ) ) From 8874a40a51f728f93e5666eb4d5cacaf9fe6232c Mon Sep 17 00:00:00 2001 From: wouf Date: Wed, 27 Mar 2019 11:55:50 +0300 Subject: [PATCH 300/686] Update PyquenHadronizer.cc --- GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc index c57d4c6905bc7..aac5f49ccfece 100644 --- a/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc +++ b/GeneratorInterface/PyquenInterface/src/PyquenHadronizer.cc @@ -78,7 +78,6 @@ filterType_(pset.getUntrackedParameter("filterType","None")) } selector_ = HiGenEvtSelectorFactory::get(filterType_,pset); - HepMC::HEPEVT_Wrapper::set_max_number_entries(10000); int cm=1, va, vb, vc; PYQVER(cm,va,vb,vc); From c5cae0d21626cf85be6f5806bed8e58394d27fc3 Mon Sep 17 00:00:00 2001 From: Saranya Ghosh Date: Wed, 27 Mar 2019 10:26:03 +0100 Subject: [PATCH 301/686] Removing redundant or older versions of unused files --- .../plugins/DTResidualCalibration.cc.old | 317 ------- .../DTCalibration/scripts/dtCalibrationOld | 857 ------------------ 2 files changed, 1174 deletions(-) delete mode 100644 CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old delete mode 100755 CalibMuon/DTCalibration/scripts/dtCalibrationOld diff --git a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old b/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old deleted file mode 100644 index c1b1f65d8b655..0000000000000 --- a/CalibMuon/DTCalibration/plugins/DTResidualCalibration.cc.old +++ /dev/null @@ -1,317 +0,0 @@ - -/* - * See header file for a description of this class. - * - */ - -#include "DTResidualCalibration.h" - -// Framework -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -//Geometry -#include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" - -//RecHit -#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" -#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h" - -#include "CommonTools/Utils/interface/TH1AddDirectorySentry.h" -#include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h" -#include "CalibMuon/DTCalibration/interface/DTRecHitSegmentResidual.h" - -#include "TFile.h" -#include "TH1F.h" -#include "TH2F.h" - -#include - -DTResidualCalibration::DTResidualCalibration(const edm::ParameterSet& pset): - select_(pset), - histRange_(pset.getParameter("histogramRange")), - segment4DLabel_(pset.getParameter("segment4DLabel")), - rootBaseDir_(pset.getUntrackedParameter("rootBaseDir","DT/Residuals")), - detailedAnalysis_(pset.getUntrackedParameter("detailedAnalysis",false)) { - - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Constructor called."; - consumes< DTRecSegment4DCollection >(edm::InputTag(segment4DLabel_)); - std::string rootFileName = pset.getUntrackedParameter("rootFileName","residuals.root"); - rootFile_ = new TFile(rootFileName.c_str(), "RECREATE"); - rootFile_->cd(); - - segmok=0; - segmbad=0; - nevent=0; -} - -DTResidualCalibration::~DTResidualCalibration() { - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Destructor called."; - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Analyzed events: " << nevent; - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Good segments: " << segmok; - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Bad segments: " << segmbad; -} - -void DTResidualCalibration::beginJob() { - TH1::SetDefaultSumw2(true); -} - -void DTResidualCalibration::beginRun(const edm::Run& run, const edm::EventSetup& setup) { - - // get the geometry - edm::ESHandle dtGeomH; - setup.get().get(dtGeomH); - dtGeom_ = dtGeomH.product(); - - // Loop over all the chambers - if(histoMapTH1F_.empty()) { - for (auto ch_it : dtGeom_->chambers()) { - // Loop over the SLs - for (auto sl_it : ch_it->superLayers()) { - DTSuperLayerId slId = (sl_it)->id(); - bookHistos(slId); - if(detailedAnalysis_) { - for (auto layer_it : (sl_it)->layers()) { - DTLayerId layerId = (layer_it)->id(); - bookHistos(layerId); - } - } - } - } - } -} - -void DTResidualCalibration::analyze(const edm::Event& event, const edm::EventSetup& setup) { - rootFile_->cd(); - ++nevent; - - // Get the 4D rechits from the event - edm::Handle segments4D; - event.getByLabel(segment4DLabel_, segments4D); - - // Loop over segments by chamber - DTRecSegment4DCollection::id_iterator chamberIdIt; - for(chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt){ - - const DTChamber* chamber = dtGeom_->chamber(*chamberIdIt); - - // Get the range for the corresponding ChamberId - DTRecSegment4DCollection::range range = segments4D->get((*chamberIdIt)); - // Loop over the rechits of this DetUnit - for(DTRecSegment4DCollection::const_iterator segment = range.first; - segment != range.second; ++segment){ - - LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition() - << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition()); - - if( !select_(*segment, event, setup) ) { segmbad++; continue; } - segmok++; - - // Get all 1D RecHits at step 3 within the 4D segment - std::vector recHits1D_S3; - - if( (*segment).hasPhi() ){ - const DTChamberRecSegment2D* phiSeg = (*segment).phiSegment(); - const std::vector& phiRecHits = phiSeg->specificRecHits(); - std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3)); - } - - if( (*segment).hasZed() ){ - const DTSLRecSegment2D* zSeg = (*segment).zSegment(); - const std::vector& zRecHits = zSeg->specificRecHits(); - std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3)); - } - - // Loop over 1D RecHit inside 4D segment - for(std::vector::const_iterator recHit1D = recHits1D_S3.begin(); - recHit1D != recHits1D_S3.end(); ++recHit1D) { - const DTWireId wireId = recHit1D->wireId(); - - float segmDistance = segmentToWireDistance(*recHit1D,*segment); - if(segmDistance > 2.1) LogTrace("Calibration") << "WARNING: segment-wire distance: " << segmDistance; - else LogTrace("Calibration") << "segment-wire distance: " << segmDistance; - - float residualOnDistance = DTRecHitSegmentResidual().compute(dtGeom_,*recHit1D,*segment); - LogTrace("Calibration") << "Wire Id " << wireId << " residual on distance: " << residualOnDistance; - - fillHistos(wireId.superlayerId(), segmDistance, residualOnDistance); - if(detailedAnalysis_) fillHistos(wireId.layerId(), segmDistance, residualOnDistance); - } - } - } -} - -float DTResidualCalibration::segmentToWireDistance(const DTRecHit1D& recHit1D, const DTRecSegment4D& segment){ - - // Get the layer and the wire position - const DTWireId wireId = recHit1D.wireId(); - const DTLayer* layer = dtGeom_->layer(wireId); - float wireX = layer->specificTopology().wirePosition(wireId.wire()); - - // Extrapolate the segment to the z of the wire - // Get wire position in chamber RF - // (y and z must be those of the hit to be coherent in the transf. of RF in case of rotations of the layer alignment) - LocalPoint wirePosInLay(wireX,recHit1D.localPosition().y(),recHit1D.localPosition().z()); - GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay); - const DTChamber* chamber = dtGeom_->chamber(wireId.layerId().chamberId()); - LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob); - - // Segment position at Wire z in chamber local frame - LocalPoint segPosAtZWire = segment.localPosition() + segment.localDirection()*wirePosInChamber.z()/cos(segment.localDirection().theta()); - - // Compute the distance of the segment from the wire - int sl = wireId.superlayer(); - float segmDistance = -1; - if(sl == 1 || sl == 3) segmDistance = fabs(wirePosInChamber.x() - segPosAtZWire.x()); - else if(sl == 2) segmDistance = fabs(segPosAtZWire.y() - wirePosInChamber.y()); - - return segmDistance; -} - -void DTResidualCalibration::endJob(){ - - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Writing histos to file."; - rootFile_->cd(); - rootFile_->Write(); - rootFile_->Close(); - - /*std::map >::const_iterator itSlHistos = histoMapTH1F_.begin(); - std::map >::const_iterator itSlHistos_end = histoMapTH1F_.end(); - for(; itSlHistos != itSlHistos_end; ++itSlHistos){ - std::vector::const_iterator itHistTH1F = (*itSlHistos).second.begin(); - std::vector::const_iterator itHistTH1F_end = (*itSlHistos).second.end(); - for(; itHistTH1F != itHistTH1F_end; ++itHistTH1F) (*itHistTH1F)->Write(); - - std::vector::const_iterator itHistTH2F = histoMapTH2F_[(*itSlHistos).first].begin(); - std::vector::const_iterator itHistTH2F_end = histoMapTH2F_[(*itSlHistos).first].end(); - for(; itHistTH2F != itHistTH2F_end; ++itHistTH2F) (*itHistTH2F)->Write(); - }*/ - -} - -void DTResidualCalibration::bookHistos(DTSuperLayerId slId) { - TH1AddDirectorySentry addDir; - rootFile_->cd(); - - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for SL: " << slId; - - // Compose the chamber name - // Define the step - int step = 3; - - std::string wheelStr = std::to_string(slId.wheel()); - std::string stationStr = std::to_string(slId.station()); - std::string sectorStr = std::to_string(slId.sector()); - - std::string slHistoName = - "_STEP" + std::to_string(step) + - "_W" + wheelStr + - "_St" + stationStr + - "_Sec" + sectorStr + - "_SL" + std::to_string(slId.superlayer()); - - edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; - TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); - if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); - TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); - if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); - TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); - if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); - TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); - if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); - - sectorDir->cd(); - - // Create the monitor elements - std::vector histosTH1F; - histosTH1F.push_back(new TH1F(("hResDist"+slHistoName).c_str(), - "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", - 200, -histRange_, histRange_)); - std::vector histosTH2F; - histosTH2F.push_back(new TH2F(("hResDistVsDist"+slHistoName).c_str(), - "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", - 100, 0, 2.5, 200, -histRange_, histRange_)); - histoMapTH1F_[slId] = histosTH1F; - histoMapTH2F_[slId] = histosTH2F; -} - -void DTResidualCalibration::bookHistos(DTLayerId layerId) { - TH1AddDirectorySentry addDir; - rootFile_->cd(); - - edm::LogVerbatim("Calibration") << "[DTResidualCalibration] Booking histos for layer: " << layerId; - - // Compose the chamber name - std::string wheelStr = std::to_string(layerId.wheel()); - std::string stationStr = std::to_string(layerId.station()); - std::string sectorStr = std::to_string(layerId.sector()); - std::string superLayerStr = std::to_string(layerId.superlayer()); - std::string layerStr = std::to_string(layerId.layer()); - // Define the step - int step = 3; - - std::string layerHistoName = - "_STEP" + std::to_string(step) + - "_W" + wheelStr + - "_St" + stationStr + - "_Sec" + sectorStr + - "_SL" + superLayerStr + - "_Layer" + layerStr; - - edm::LogVerbatim("Calibration") << "Accessing " << rootBaseDir_; - TDirectory* baseDir = rootFile_->GetDirectory(rootBaseDir_.c_str()); - if(!baseDir) baseDir = rootFile_->mkdir(rootBaseDir_.c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Wheel" + wheelStr); - TDirectory* wheelDir = baseDir->GetDirectory(("Wheel" + wheelStr).c_str()); - if(!wheelDir) wheelDir = baseDir->mkdir(("Wheel" + wheelStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Station" + stationStr); - TDirectory* stationDir = wheelDir->GetDirectory(("Station" + stationStr).c_str()); - if(!stationDir) stationDir = wheelDir->mkdir(("Station" + stationStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("Sector" + sectorStr); - TDirectory* sectorDir = stationDir->GetDirectory(("Sector" + sectorStr).c_str()); - if(!sectorDir) sectorDir = stationDir->mkdir(("Sector" + sectorStr).c_str()); - edm::LogVerbatim("Calibration") << "Accessing " << ("SL" + superLayerStr); - TDirectory* superLayerDir = sectorDir->GetDirectory(("SL" + superLayerStr).c_str()); - if(!superLayerDir) superLayerDir = sectorDir->mkdir(("SL" + superLayerStr).c_str()); - - superLayerDir->cd(); - // Create histograms - std::vector histosTH1F; - histosTH1F.push_back(new TH1F(("hResDist"+layerHistoName).c_str(), - "Residuals on the distance from wire (rec_hit - segm_extr) (cm)", - 200, -histRange_, histRange_)); - std::vector histosTH2F; - histosTH2F.push_back(new TH2F(("hResDistVsDist"+layerHistoName).c_str(), - "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)", - 100, 0, 2.5, 200, -histRange_, histRange_)); - histoMapPerLayerTH1F_[layerId] = histosTH1F; - histoMapPerLayerTH2F_[layerId] = histosTH2F; -} - -// Fill a set of histograms for a given SL -void DTResidualCalibration::fillHistos(DTSuperLayerId slId, - float distance, - float residualOnDistance) { - std::vector const& histosTH1F = histoMapTH1F_[slId]; - std::vector const& histosTH2F = histoMapTH2F_[slId]; - histosTH1F[0]->Fill(residualOnDistance); - histosTH2F[0]->Fill(distance, residualOnDistance); -} - -// Fill a set of histograms for a given layer -void DTResidualCalibration::fillHistos(DTLayerId layerId, - float distance, - float residualOnDistance) { - std::vector const& histosTH1F = histoMapPerLayerTH1F_[layerId]; - std::vector const& histosTH2F = histoMapPerLayerTH2F_[layerId]; - histosTH1F[0]->Fill(residualOnDistance); - histosTH2F[0]->Fill(distance, residualOnDistance); -} - diff --git a/CalibMuon/DTCalibration/scripts/dtCalibrationOld b/CalibMuon/DTCalibration/scripts/dtCalibrationOld deleted file mode 100755 index fcebefb3d3c02..0000000000000 --- a/CalibMuon/DTCalibration/scripts/dtCalibrationOld +++ /dev/null @@ -1,857 +0,0 @@ -#! /usr/bin/env python - -from CalibMuon.DTCalibration.Workflow.DTTTrigProd import DTTTrigProd -from CalibMuon.DTCalibration.Workflow.DTTTrigTimeBoxesWriter import DTTTrigTimeBoxesWriter -from CalibMuon.DTCalibration.Workflow.DTResidualCalibration import DTResidualCalibration -from CalibMuon.DTCalibration.Workflow.DTTTrigResidualCorr import DTTTrigResidualCorr -from CalibMuon.DTCalibration.Workflow.DTTTrigValid import DTTTrigValid -from CalibMuon.DTCalibration.Workflow.DTValidSummary import DTValidSummary -from CalibMuon.DTCalibration.Workflow.DTVDriftSegmentCalibration import DTVDriftSegmentCalibration -from CalibMuon.DTCalibration.Workflow.DTVDriftSegmentWriter import DTVDriftSegmentWriter -from CalibMuon.DTCalibration.Workflow.DTVDriftMeanTimerCalibration import DTVDriftMeanTimerCalibration -from CalibMuon.DTCalibration.Workflow.DTVDriftMeanTimerWriter import DTVDriftMeanTimerWriter -from CalibMuon.DTCalibration.Workflow.DTNoiseCalibration import DTNoiseCalibration -from CalibMuon.DTCalibration.Workflow.DTDQMValidation import DTDQMValidation -from CalibMuon.DTCalibration.Workflow.DTDQMMerge import DTDQMMerge -from CalibMuon.DTCalibration.Workflow.DTDQMHarvesting import DTDQMHarvesting -from CalibMuon.DTCalibration.Workflow.DTDqm import DTDqm -from CalibMuon.DTCalibration.Workflow.CrabWatch import CrabWatch -from CalibMuon.DTCalibration.Workflow.tools import listFilesInCastor,haddInCastor,listFilesLocal,haddLocal,copyFilesFromCastor,copyFilesLocal,parseInput,getDatasetStr -import sys,os,time,optparse - -def dqmOutputDir(type,dirLabel,config): - dqm_output_dir = '' - if config.stageOutLocal: - from crab_util import findLastWorkDir - cwd = os.getcwd() - crab_task_dir = config.base_dir + '/' + dirLabel - os.chdir(crab_task_dir) - crabdir = findLastWorkDir('crab_0_') - if not crabdir: raise RuntimeError,'Could not find CRAB dir in %s' % crab_task_dir - os.chdir(cwd) - dqm_output_dir = crabdir + "/res" - elif config.stageOutCAF: - datasetstr = getDatasetStr(config.datasetpath) - dqm_output_dir = config.castorpath + '/DTCalibration/' + datasetstr + '/Run' + str(run) + '/' + type + '/' + dirLabel + '/' + 'v' + str(trial) - - return dqm_output_dir - -def runTtrigProd(run,runselection,trial,config,runStep=True): - - print "Processing tTrig production" - #config.runselection = runselection - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigCalibration/' + 'TimeBoxes' + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/TimeBoxes' - dtTtrigProd = DTTTrigProd(run,task_dir,config) - dtTtrigProd.writeCfg() - - if runStep: - project_prod = dtTtrigProd.run() - - print "Sent calibration jobs with project",project_prod - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabProd = CrabWatch(project_prod) - crabProd.setThreshold(config.jobsFinishedThreshold) - crabProd.start() - crabProd.join() - - result_file = config.result_dir + '/DTTimeBoxes_%s.root'%run - if config.stageOutLocal: - output_dir = project_prod + "/res" - haddLocal(output_dir,result_file) - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - haddInCastor(castor_dir,result_file,'DTTimeBoxes','rfio://castorcms/','?svcClass=cmscafuser') - - return project_prod - - return None - -def runTtrigWriter(run,config,runStep=True): - - print "Processing tTrig correction" - dtTtrigWriter = DTTTrigTimeBoxesWriter(run,config.run_dir,config.result_dir,config) - dtTtrigWriter.writeCfg() - - if runStep: - dtTtrigWriter.run() - - print "Finished processing:" - for pset in dtTtrigWriter.configs: print "--->",pset - -def runResidualCalib(run,runselection,trial,input_db,label,result_file,config,runStep=True): - - print "Processing tTrig calibration" - #config.runselection = runselection - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigCalibration/' + label + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/' + label - dtResidualCalib = DTResidualCalibration(run=run, - dir=task_dir, - input_db=input_db, - config=config) - dtResidualCalib.writeCfg() - - if runStep: - project_residualCalib = dtResidualCalib.run() - - print "Sent calibration jobs with project",project_residualCalib - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabResidualCalib = CrabWatch(project_residualCalib) - crabResidualCalib.setThreshold(config.jobsFinishedThreshold) - crabResidualCalib.start() - crabResidualCalib.join() - - if config.stageOutLocal: - output_dir = project_residualCalib + "/res" - haddLocal(output_dir,result_file,'residuals') - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - haddInCastor(castor_dir,result_file,'residuals','rfio://castorcms/','?svcClass=cmscafuser') - - return project_residualCalib - - return None - -def runTtrigResidualCorr(run,input_db,root_file,config,runStep=True): - - print "Processing tTrig residual correction" - dtTtrigResidualCorr = DTTTrigResidualCorr(run=run, - dir=config.run_dir, - input_db=input_db, - residuals=root_file, - result_dir=config.result_dir, - config=config) - dtTtrigResidualCorr.writeCfg() - - if runStep: - dtTtrigResidualCorr.run() - - print "Finished processing:" - for pset in dtTtrigResidualCorr.configs: print "--->",pset - -#def runTtrigValid(run,runselection,trial,input_db,label,result_file,config,runStep=True): -def runTtrigValid(run,runselection,trial,input_db,label,config,runStep=True): - - print "Processing tTrig validation" - #config.runselection = runselection - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigValidation/' + label + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/' + label - dtTtrigValid = DTTTrigValid(run=run, - dir=task_dir, - input_db=input_db, - config=config) - dtTtrigValid.writeCfg() - - if runStep: - project_valid = dtTtrigValid.run() - - print "Sent validation jobs with project",project_valid - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabValid = CrabWatch(project_valid) - crabValid.setThreshold(config.jobsFinishedThreshold) - crabValid.start() - crabValid.join() - - """ - if config.stageOutLocal: - output_dir = project_valid + "/res" - haddLocal(output_dir,result_file,'residuals') - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - haddInCastor(castor_dir,result_file,'residuals','rfio://castorcms/','?svcClass=cmscafuser') - """ - - return project_valid - - return None - -def runTtrigValidSummary(run,input_file,output_file,config,runStep=True): - - print "Processing Validation Summary" - dtTtrigValidSummary = DTValidSummary(run,config.run_dir,input_file,output_file,config) - dtTtrigValidSummary.writeCfg() - - if runStep: - dtTtrigValidSummary.run() - - print "...Validation Summary finished" - -def runVDriftSegmentCalib(run,runselection,trial,label,result_file,config,runStep=True): - - print "Processing vDrift calibration" - #config.runselection = runselection - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/VDriftCalibration/' + label + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/' + label - dtVDriftSegment = DTVDriftSegmentCalibration(run=run, - dir=task_dir, - config=config) - dtVDriftSegment.writeCfg() - - if runStep: - project_segment = dtVDriftSegment.run() - - print "Sent validation jobs with project",project_segment - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabVDriftSegment = CrabWatch(project_segment) - crabVDriftSegment.setThreshold(config.jobsFinishedThreshold) - crabVDriftSegment.start() - crabVDriftSegment.join() - - if config.stageOutLocal: - output_dir = project_segment + "/res" - haddLocal(output_dir,result_file,'DTVDriftHistos') - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - haddInCastor(castor_dir,result_file,'DTVDriftHistos','rfio://castorcms/','?svcClass=cmscafuser') - - return project_segment - - return None - -def runVDriftSegmentWriter(run,root_file,config,runStep=True): - - print "Processing vDrift writer" - dtVDriftSegmentWriter = DTVDriftSegmentWriter(run=run, - dir=config.run_dir, - input_file=root_file, - output_dir=config.result_dir, - config=config) - dtVDriftSegmentWriter.writeCfg() - - if runStep: - dtVDriftSegmentWriter.run() - - print "Finished processing:" - for pset in dtVDriftSegmentWriter.configs: print "--->",pset - -def runVDriftMeanTimerCalib(run,runselection,trial,label,result_file,config,runStep=True): - - print "Processing vDrift calibration" - #config.runselection = runselection - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/VDriftCalibration/' + label + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/' + label - dtVDriftMeanTimer = DTVDriftMeanTimerCalibration(run=run, - dir=task_dir, - config=config) - dtVDriftMeanTimer.writeCfg() - - if runStep: - project_meantimer = dtVDriftMeanTimer.run() - - print "Sent validation jobs with project",project_meantimer - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabVDriftMeanTimer = CrabWatch(project_meantimer) - crabVDriftMeanTimer.setThreshold(config.jobsFinishedThreshold) - crabVDriftMeanTimer.start() - crabVDriftMeanTimer.join() - - if config.stageOutLocal: - output_dir = project_meantimer + "/res" - haddLocal(output_dir,result_file,'DTTMaxHistos') - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - haddInCastor(castor_dir,result_file,'DTTMaxHistos','rfio://castorcms/','?svcClass=cmscafuser') - - return project_meantimer - - return None - -def runVDriftMeanTimerWriter(run,root_file,config,runStep=True): - - print "Processing vDrift writer" - dtVDriftMeanTimerWriter = DTVDriftMeanTimerWriter(run=run, - dir=config.run_dir, - input_file=root_file, - output_dir=config.result_dir, - config=config) - dtVDriftMeanTimerWriter.writeCfg() - - if runStep: - dtVDriftMeanTimerWriter.run() - - print "Finished processing:" - for pset in dtVDriftMeanTimerWriter.configs: print "--->",pset - -def runDQMClient(run,output_dir,config,runStep=True): - - print "Processing DQM Merge" - - if runStep: - dqm_files = [] - if config.stageOutLocal: - dqm_files = listFilesLocal(output_dir,'DQM') - dqm_files = ['file:%s' % item for item in dqm_files] - dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - dtDqmFinal.run() - elif config.stageOutCAF: - dqm_files = listFilesInCastor(output_dir,'DQM','') - dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files] - dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - dtDqmFinal.run() - - print "...DQM Merge finished" - else: - dqm_files = [] - dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - -def runDQMHarvesting(run,output_dir,config,runStep=True): - - print "Processing DQM harvesting" - - if runStep: - dqm_files = [] - if config.stageOutLocal: - dqm_files = listFilesLocal(output_dir,'DQM') - dqm_files = ['file:%s' % item for item in dqm_files] - dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - dtDqmFinal.run() - elif config.stageOutCAF: - dqm_files = listFilesInCastor(output_dir,'DQM','') - dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files] - dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - dtDqmFinal.run() - - print "...DQM harvesting finished" - else: - dqm_files = [] - dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config) - dtDqmFinal.writeCfg() - -def runDQMMerge(run,output_dir,config,runStep=True): - - print "Processing DQM merge" - - if runStep: - dqm_files = [] - if config.stageOutLocal: - dqm_files = listFilesLocal(output_dir,'DQM') - dqm_files = ['file:%s' % item for item in dqm_files] - dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config) - dtDQMMerge.writeCfg() - dtDQMMerge.run() - elif config.stageOutCAF: - dqm_files = listFilesInCastor(output_dir,'DQM','') - dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files] - dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config) - dtDQMMerge.writeCfg() - dtDQMMerge.run() - - print "...DQM merge finished" - else: - dqm_files = [] - dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config) - dtDQMMerge.writeCfg() - -############################################################ -# tTrig workflow -############################################################ -def runTtrigWorkflow(mode,run,config,execute=True): - trial = config.trial - runselection = config.runselection - ttrig_input_db = None - if hasattr(config,'inputTTrigDB') and config.inputTTrigDB: ttrig_input_db = os.path.abspath(config.inputTTrigDB) - result_dir = config.result_dir - if mode == 'timeboxes': - timeBoxes = os.path.abspath(result_dir + '/' + 'DTTimeBoxes_' + run + '.root') - ttrig_timeboxes_db = os.path.abspath(result_dir + '/' + 'ttrig_timeboxes_' + run + '.db') - residualsFirst = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root') - ttrig_residuals_db = os.path.abspath(result_dir + '/' + 'ttrig_residuals_' + run + '.db') - residualsResidCorr = os.path.abspath(result_dir + '/' + 'DTResidualValidation_ResidCorr_' + run + '.root') - summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root') - - if not execute: - print "Writing configuration files.." - runTtrigProd(run,runselection,trial,config,False) - runTtrigWriter(run,config,False) - runResidualCalib(run,runselection,trial,ttrig_timeboxes_db,'Residuals',residualsFirst,config,False) - runTtrigResidualCorr(run,ttrig_timeboxes_db,residualsFirst,config,False) - runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config,False) - #runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config,False) - runDQMClient(run,'',config,False) - - sys.exit(0) - - # Produce time-boxes - if not os.path.exists(timeBoxes): runTtrigProd(run,runselection,trial,config) - if not os.path.exists(timeBoxes): raise RuntimeError,'Could not produce %s' % timeBoxes - - # Write tTrig DB - if not os.path.exists(ttrig_timeboxes_db): runTtrigWriter(run,config) - if not os.path.exists(ttrig_timeboxes_db): raise RuntimeError,'Could not produce %s' % ttrig_timeboxes_db - - # Produce residuals - if not os.path.exists(residualsFirst): - runResidualCalib(run,runselection,trial,ttrig_timeboxes_db,'Residuals',residualsFirst,config) - if not os.path.exists(residualsFirst): raise RuntimeError,'Could not produce %s' % residualsFirst - - # Correction from residuals and write tTrig DB - if not os.path.exists(ttrig_residuals_db): runTtrigResidualCorr(run,ttrig_timeboxes_db,residualsFirst,config) - if not os.path.exists(ttrig_residuals_db): raise RuntimeError,'Could not produce %s' % ttrig_residuals_db - - # Validation - runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config) - - """ - # Summary of validation - if not os.path.exists(summaryResiduals): runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config) - if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals - """ - # Produce DQM output - dqm_output_dir = dqmOutputDir('TTrigValidation','ResidualsResidCorr',config) - runDQMClient(run,dqm_output_dir,config) - - elif input.workflowMode == 'residuals': - residualsFirst = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root') - ttrig_residuals_db = os.path.abspath(result_dir + '/' + 'ttrig_residuals_' + run + '.db') - residualsResidCorr = os.path.abspath(result_dir + '/' + 'DTResidualValidation_ResidCorr_' + run + '.root') - summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root') - - if not execute: - print "Writing configuration files.." - if ttrig_input_db: - runResidualCalib(run,runselection,trial,ttrig_input_db,'Residuals',residualsFirst,config,False) - runTtrigResidualCorr(run,ttrig_input_db,residualsFirst,config,False) - else: - runResidualCalib(run,runselection,trial,None,'Residuals',residualsFirst,config,False) - runTtrigResidualCorr(run,None,residualsFirst,config,False) - - runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config,False) - #runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config,False) - runDQMClient(run,'',config,False) - - sys.exit(0) - - # Produce residuals - if not os.path.exists(residualsFirst): - if ttrig_input_db: - runResidualCalib(run,runselection,trial,ttrig_input_db,'Residuals',residualsFirst,config) - else: - runResidualCalib(run,runselection,trial,None,'Residuals',residualsFirst,config) - if not os.path.exists(residualsFirst): raise RuntimeError,'Could not produce %s' % residualsFirst - - # Correction from residuals and write tTrig DB - if not os.path.exists(ttrig_residuals_db): - if ttrig_input_db: runTtrigResidualCorr(run,ttrig_input_db,residualsFirst,config) - else: runTtrigResidualCorr(run,None,residualsFirst,config) - if not os.path.exists(ttrig_residuals_db): raise RuntimeError,'Could not produce %s' % ttrig_residuals_db - - # Validation - runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config) - - """ - # Summary of validation - if not os.path.exists(summaryResiduals): - runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config) - if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals - """ - # Produce DQM output - dqm_output_dir = dqmOutputDir('TTrigValidation','ResidualsResidCorr',config) - runDQMClient(run,dqm_output_dir,config) - - elif input.workflowMode == 'validation': - residualsValid = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root') - summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root') - - if not execute: - print "Writing configuration files.." - if ttrig_input_db: - runTtrigValid(run,runselection,trial,ttrig_input_db,'Residuals',config,False) - else: - runTtrigValid(run,runselection,trial,None,'Residuals',config,False) - - #runTtrigValidSummary(run,residualsValid,summaryResiduals,config,False) - runDQMClient(run,'',config,False) - - sys.exit(0) - - # Validation - if ttrig_input_db: - runTtrigValid(run,runselection,trial,ttrig_input_db,'Residuals',config) - else: - runTtrigValid(run,runselection,trial,None,'Residuals',config) - - """ - # Summary of validation - if not os.path.exists(summaryResiduals): - runTtrigValidSummary(run,residualsValid,summaryResiduals,config) - if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals - """ - - # Produce DQM output - dqm_output_dir = dqmOutputDir('TTrigValidation','Residuals',config) - runDQMClient(run,dqm_output_dir,config) - - return 0 - -############################################################ -# vDrift workflow -############################################################ -def runVDriftWorkflow(mode,run,config,execute=True): - trial = config.trial - runselection = config.runselection - result_dir = config.result_dir - if mode == 'segment': - vDriftHistos = os.path.abspath(result_dir + '/' + 'DTVDriftHistos_' + run + '.root') - vDrift_segment_db = os.path.abspath(result_dir + '/' + 'vDrift_segment_' + run + '.db') - - if not execute: - print "Writing configuration files.." - runVDriftSegmentCalib(run,runselection,trial,'VDriftHistos',vDriftHistos,config,False) - runVDriftSegmentWriter(run,vDriftHistos,config,False) - - sys.exit(0) - - # Produce vDrift histos - if not os.path.exists(vDriftHistos): - runVDriftSegmentCalib(run,runselection,trial,'VDriftHistos',vDriftHistos,config) - if not os.path.exists(vDriftHistos): raise RuntimeError,'Could not produce %s' % vDriftHistos - - # Write vDrift DB - if not os.path.exists(vDrift_segment_db): runVDriftSegmentWriter(run,vDriftHistos,config) - if not os.path.exists(vDrift_segment_db): raise RuntimeError,'Could not produce %s' % vDrift_segment_db - - elif mode == 'meantimer': - vDriftTMaxHistos = os.path.abspath(result_dir + '/' + 'DTTMaxHistos_' + run + '.root') - vDrift_meantimer_db = os.path.abspath(result_dir + '/' + 'vDrift_meantimer_' + run + '.db') - - if not execute: - print "Writing configuration files.." - runVDriftMeanTimerCalib(run,runselection,trial,'VDriftTMaxHistos',vDriftTMaxHistos,config,False) - runVDriftMeanTimerWriter(run,vDriftTMaxHistos,config,False) - - sys.exit(0) - - # Produce t_max histos - if not os.path.exists(vDriftTMaxHistos): - runVDriftMeanTimerCalib(run,runselection,trial,'VDriftTMaxHistos',vDriftTMaxHistos,config) - if not os.path.exists(vDriftTMaxHistos): raise RuntimeError,'Could not produce %s' % vDriftTMaxHistos - - # Write vDrift DB - if not os.path.exists(vDrift_meantimer_db): runVDriftMeanTimerWriter(run,vDriftTMaxHistos,config) - if not os.path.exists(vDrift_meantimer_db): raise RuntimeError,'Could not produce %s' % vDrift_meantimer_db - - return 0 - -############################################################ -# noise workflow -############################################################ -def runNoiseWorkflow(mode,run,config,execute=True): - print "Processing noise calibration" - - trial = config.trial - runselection = config.runselection - result_dir = config.result_dir - result_file = os.path.abspath(result_dir + '/' + 'dtNoiseCalib_' + run + '.root') - noise_db = os.path.abspath(result_dir + '/' + 'noise_' + run + '.db') - noise_txt = os.path.abspath(result_dir + '/' + 'noise_' + run + '.txt') - - datasetstr = getDatasetStr(config.datasetpath) - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/NoiseCalibration/' + label + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/NoiseCalib' - dtNoiseCalibration = DTNoiseCalibration(run=run, - dir=task_dir, - config=config) - if not execute: - dtNoiseCalibration.writeCfg() - sys.exit(0) - else: - dtNoiseCalibration.writeCfg() - project_noise = dtNoiseCalibration.run() - - print "Sent calibration jobs with project",project_noise - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabNoiseCalibration = CrabWatch(project_noise) - crabNoiseCalibration.setThreshold(config.jobsFinishedThreshold) - crabNoiseCalibration.start() - crabNoiseCalibration.join() - - if config.stageOutLocal: - crab_output_dir = project_noise + "/res" - retcode = copyFilesLocal(crab_output_dir,result_dir,'dtNoiseCalib') - retcode = copyFilesLocal(crab_output_dir,result_dir,'noise') - elif config.stageOutCAF: - castor_dir = config.castorpath + "/" + config.userdircaf - retcode = copyFilesFromCastor(castor_dir,result_dir,'dtNoiseCalib') - retcode = copyFilesFromCastor(castor_dir,result_dir,'noise') - - return 0 - -############################################################ -# t0 workflow -############################################################ -def runT0Workflow(mode,run,config,execute=True): - - return 0 - -############################################################ -# Validation workflow -############################################################ -def runValidationWorkflow(mode,run,config,execute=True): - print "Processing DQM validation" - trial = config.trial - runselection = config.runselection - result_dir = config.result_dir - datasetstr = getDatasetStr(config.datasetpath) - dirLabel = 'DQM' - config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/DQMValidation/' + dirLabel + '/' + 'v' + str(trial) - - task_dir = config.base_dir + '/' + dirLabel - dtDQMValid = DTDQMValidation(run=run, - dir=task_dir, - config=config) - if not execute: - dtDQMValid.writeCfg() - runDQMMerge(run,'',config,False) - runDQMHarvesting(run,'',config,False) - - sys.exit(0) - else: - dtDQMValid.writeCfg() - project_valid = dtDQMValid.run() - - print "Sent validation jobs with project",project_valid - print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold - - crabValid = CrabWatch(project_valid) - crabValid.setThreshold(config.jobsFinishedThreshold) - crabValid.start() - crabValid.join() - - # Produce DQM output - dqm_output_dir = dqmOutputDir('DQMValidation',dirLabel,config) - runDQMMerge(run,dqm_output_dir,config) - # Run harvesting from merged DQM file - dqm_merge_dir = os.path.abspath(result_dir) - runDQMHarvesting(run,dqm_merge_dir,config) - - return 0 - - -if __name__ == '__main__': - - parser = optparse.OptionParser(usage="usage: %prog arg1 arg2 [options]") - parser.add_option("-r","--run", dest="run", help="set reference run number (typically first or last run in list)") - parser.add_option("--runselection", dest="runselection", help="run list or range") - parser.add_option("--label", dest="label", default="dtCalibration", help="label used in the naming of workflow output") - parser.add_option("--trial", dest="trial", type="int", help="trial number used in the naming of output directories") - parser.add_option("--datasetpath", dest="datasetpath", help="dataset name to process") - parser.add_option("--globaltag", dest="globaltag", help="global tag identifier (without the '::All' string)") - parser.add_option("--preselection", dest="preselection", help="configuration fragment and sequence name, separated by a ':', defining a pre-selection filter") - parser.add_option("--inputVDriftDB", dest="inputVDriftDB", help="uses local SQLITE vDrift DB (instead of using the one in the GT)") - parser.add_option("--inputTTrigDB", dest="inputTTrigDB", help="uses local SQLITE tTrig DB (instead of using the one in the GT)") - parser.add_option("--runOnCosmics", action="store_true", dest="runOnCosmics", default=False, help="set this option to run on Cosmics") - parser.add_option("--runOnRAW", action="store_true", dest="runOnRAW", default=False, help="set this option to run on RAW") - #parser.add_option("--templatepath", dest="templatepath", help="path to dir with template cfg files") - parser.add_option("--no_exec", action="store_true", dest="no_exec", default=False, help="script will not execute") - - # Option group - options for residuals mode - #group_residuals = optparse.OptionGroup(parser,"Options for 'residuals' mode") - #group_residuals.add_option("--inputDB", dest="inputDB", help="sets initial DB (instead of using the one in the GT)") - #parser.add_option_group(group_residuals) - - # Option group - additional options - group_additional = optparse.OptionGroup(parser,"Additional options") - group_additional.add_option("--email", dest="email", help="user email") - group_additional.add_option("--castorpath", dest="castorpath", default=('/castor/cern.ch/cms/store/caf/user/%s' % os.environ['USER']), help="path to user area at CAF (default /castor/cern.ch/cms/store/caf/user/username)") - group_additional.add_option("--useCRABServer", action="store_true", dest="useserver", default=False, help="will use CRAB server to submit jobs (default = False)") - group_additional.add_option("--queueAtCAF", dest="queueAtCAF", default='cmscaf1nh', help="") - group_additional.add_option("--jobsFinishedThreshold", dest="jobsFinishedThreshold", type="float", default=100, help="percentage above or equal to which CRAB tasks will be considered completed") - - group_additional.add_option("--runOnGrid", action="store_true", dest="runOnGrid", default=False, help="workflow will be run on the Grid (instead of the CAF)") - group_additional.add_option("--stageOutLocal", action="store_true", dest="stageOutLocal", default=False, help="output will be copied locally (if running on the Grid this will be the default)") - - # Split by lumi options - group_additional.add_option("--splitByLumi", action="store_true", dest="splitByLumi", default=False, help="will split CRAB jobs by lumi section") - group_additional.add_option("--totalnumberlumis", dest="totalnumberlumis", type="int", default=-1, help="total number of lumis to be analyzed") - group_additional.add_option("--lumisperjob", dest="lumisperjob", type="int", default=150, help="number of lumis per job") - group_additional.add_option("--lumimask", dest="lumimask", help="lumi mask JSON file") - parser.add_option_group(group_additional) - - (input, args) = parser.parse_args() - - allowedTypes = ('ttrig','vdrift','noise','t0','validation') - input.workflowType = 'ttrig' - if len(args) > 0: - if args[0] not in allowedTypes: parser.error('option "%s" not allowed' % args[0]) - input.workflowType = args[0] - - allowedTTrigModes = ('timeboxes','residuals','validation') - allowedVDriftModes = ('segment','meantimer') - input.workflowMode = None - if input.workflowType == 'ttrig': input.workflowMode = 'residuals' - elif input.workflowType == 'vdrift': input.workflowMode = 'segment' - if len(args) > 1: - if input.workflowType == 'ttrig' and args[1] not in allowedTTrigModes: - parser.error('option "%s" not allowed' % args[1]) - if input.workflowType == 'vdrift' and args[1] not in allowedVDriftModes: - parser.error('option "%s" not allowed' % args[1]) - input.workflowMode = args[1] - - requiredFields = ('run','datasetpath','globaltag') - for item in requiredFields: - if not getattr(input,item): - parser.error('field "%s" needs to be set' % item) - - run = input.run - runselection = None - if hasattr(input,'runselection') and input.runselection: runselection = input.runselection - else: runselection = run - - trial = None - if hasattr(input,'trial') and input.trial: trial = input.trial - else: trial = 1 - - label = None - if hasattr(input,'label') and input.label: label = input.label - else: label = 'dtCalibration' - - if hasattr(input,'lumimask') and input.lumimask: - if not os.path.exists(input.lumimask): parser.error('File "%s" does not exist' % input.lumimask) - - ############################################################################### - class config: pass - - config.trial = trial - config.label = label - config.datasetpath = input.datasetpath - config.runselection = runselection - if hasattr(input,'inputVDriftDB') and input.inputVDriftDB: config.inputVDriftDB = os.path.abspath(input.inputVDriftDB) - if hasattr(input,'inputTTrigDB') and input.inputTTrigDB: config.inputTTrigDB = os.path.abspath(input.inputTTrigDB) - - config.runOnRAW = False - if hasattr(input,'runOnRAW') and input.runOnRAW: config.runOnRAW = input.runOnRAW - config.runOnCosmics = False - if hasattr(input,'runOnCosmics') and input.runOnCosmics: config.runOnCosmics = input.runOnCosmics - - config.globaltag = input.globaltag + '::All' - config.digilabel = 'muonDTDigis' - config.preselection = input.preselection - - if not input.runOnGrid: - config.scheduler = 'CAF' - if input.stageOutLocal: - config.stageOutCAF = False - config.stageOutLocal = True - else: - config.stageOutCAF = True - config.stageOutLocal = False - else: - config.runOnGrid = True - config.scheduler = 'glite' - config.stageOutCAF = False - config.stageOutLocal = True - - config.useserver = input.useserver - config.queueAtCAF = input.queueAtCAF - #config.totalnumberevents = 1000000 - #config.eventsperjob = 50000 - if hasattr(input,'splitByLumi') and input.splitByLumi: - config.splitByLumi = True - config.totalnumberlumis = input.totalnumberlumis - config.lumisperjob = input.lumisperjob - if hasattr(input,'lumimask') and input.lumimask: config.lumimask = os.path.abspath(input.lumimask) - else: - config.splitByLumi = False - - if hasattr(input,'email') and input.email: config.email = input.email - - if config.stageOutCAF: - """ - castorPath = '' - if not input.castorpath: castorPath = '/castor/cern.ch/cms/store/caf/user/' + os.environ['USER'] - else: castorPath = input.castorpath - """ - if not input.castorpath: parser.error('field "%s" needs to be set' % 'castorpath') - print "Writing files at",input.castorpath - config.castor_prefix = input.castorpath - config.castorpath = input.castorpath - - #config.template_path = input.templatepath - #config.templatepath = input.templatepath - config.jobsFinishedThreshold = input.jobsFinishedThreshold - - base_label = '' - if input.workflowType == 'ttrig': base_label = 'Ttrig' - elif input.workflowType == 'vdrift': base_label = 'VDrift' - elif input.workflowType == 'noise': base_label = 'Noise' - elif input.workflowType == 't0': base_label = 'T0' - elif input.workflowType == 'validation': base_label = 'Valid' - - #base_dir = 'Run%s/Ttrig' % run - base_dir = 'Run%s/%s' % (run,base_label) - if not os.path.exists(base_dir): os.makedirs(base_dir) - config.base_dir = base_dir - - run_dir = base_dir + '/Exec' - if not os.path.exists(run_dir): os.makedirs(run_dir) - config.run_dir = run_dir - - result_dir = base_dir + '/Results' - if not os.path.exists(result_dir): os.makedirs(result_dir) - config.result_dir = result_dir - - log_dir = base_dir + '/Log' - if not os.path.exists(log_dir): os.makedirs(log_dir) - config.log_dir = log_dir - - """ - prod_dir = 'Run%s/Ttrig/Production' % run - if not os.path.exists(prod_dir): os.makedirs(prod_dir) - config.prod_dir = prod_dir - valid_dir = 'Run%s/Ttrig/Validation' % run - if not os.path.exists(valid_dir): os.makedirs(valid_dir) - config.valid_dir = valid_dir - """ - #logFileName = os.path.abspath('%s/Run_%s_v%s.log' % (log_dir,run,trial)) - #logOut = open(logFileName,'w',1) - - ############################################################################### - start = time.time() - print "DT Calibration starting for Run",run - print "Using runs",runselection - print "Running at",run_dir - print "Results at",result_dir - #print "Log files at",logFileName - - #stdout_original = sys.stdout - #sys.stdout = logOut - - from CalibMuon.DTCalibration.Workflow.crabWrap import initCrabEnvironment - initCrabEnvironment() - - execute = True - if input.no_exec: execute = False - - if input.workflowType == 'ttrig': runTtrigWorkflow(input.workflowMode,run,config,execute) - elif input.workflowType == 'vdrift': runVDriftWorkflow(input.workflowMode,run,config,execute) - elif input.workflowType == 'noise': runNoiseWorkflow('',run,config,execute) - elif input.workflowType == 't0': runT0Workflow('',run,config,execute) - elif input.workflowType == 'validation': runValidationWorkflow('',run,config,execute) - - #sys.stdout = stdout_original - - stop = time.time() - print "DT Calibration finished.. results in",result_dir - print "Time elapsed was %.1f seconds"%(stop-start) From fe596f1d0297ffc4eca97a34918a12911739569c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Wed, 27 Mar 2019 11:51:07 +0100 Subject: [PATCH 302/686] Fixes --- .../L1THGCal/interface/backend/HGCalHistoClusteringImpl.h | 4 ++-- L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc | 2 +- L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc | 2 -- .../plugins/selectors/HGC3DClusterSimpleSelector.cc | 4 ++-- .../plugins/selectors/HGC3DClusterTVMASelector.cc | 4 ++-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h index a31b691e5dd62..26c02c390eeb0 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h @@ -22,8 +22,8 @@ class HGCalHistoClusteringImpl{ { triggerTools_.eventSetup(es); shape_.eventSetup(es); - if ( (!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size()-1) != triggerTools_.lastLayerBH()) - || (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size()-1) != triggerTools_.lastLayerBH()) + if ( (!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size()-1) < triggerTools_.lastLayerBH()) + || (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size()-1) < triggerTools_.lastLayerBH()) ) { throw cms::Exception("Configuration") << "The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size()-1) << diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc index dc6b9e6a7f13e..2e7024a7b3f28 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc @@ -23,7 +23,7 @@ HGCalHistoClusteringImpl::HGCalHistoClusteringImpl( const edm::ParameterSet& con edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR: " << dr_ <<"\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_ ; - id_.reset( HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") ); + id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; id_->initialize(conf.getParameter("EGIdentification")); } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 2adb818e37cf3..d303f9dc8e431 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -30,8 +30,6 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl( const edm::ParameterSet& conf ) : <<"\nMulticluster MIPT threshold for histo threshold algorithm: " << histoThreshold_ <<"\nMulticluster type of multiclustering algortihm: " << seedingAlgoType_; - id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; - id_->initialize(conf.getParameter("EGIdentification")); if(seedingAlgoType_.find("Histo")!=std::string::npos && nBinsRHisto_!=binsSumsHisto_.size()){ throw cms::Exception("Inconsistent bin size") << "Inconsistent nBins_R_histo_multicluster ( " << nBinsRHisto_ << " ) and binSumsHisto ( " << binsSumsHisto_.size() << " ) size in HGCalMulticlustering\n"; } diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc index 8651bc1630925..d35223d3be7b8 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc @@ -11,12 +11,12 @@ namespace l1t { class HGC3DClusterSimpleSelector : public edm::stream::EDProducer<> { public: explicit HGC3DClusterSimpleSelector(const edm::ParameterSet&) ; - ~HGC3DClusterSimpleSelector() {} + ~HGC3DClusterSimpleSelector() override {} private: edm::EDGetTokenT src_; StringCutObjectSelector cut_; - virtual void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; }; // class } // namespace diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc index 1fd8a1c173a71..d8020af7129f7 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc @@ -16,7 +16,7 @@ namespace l1t { class HGC3DClusterTMVASelector : public edm::stream::EDProducer<> { public: explicit HGC3DClusterTMVASelector(const edm::ParameterSet&) ; - ~HGC3DClusterTMVASelector() {} + ~HGC3DClusterTMVASelector() override {} private: class Var { @@ -39,7 +39,7 @@ namespace l1t { StringObjectFunction wp_; - virtual void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; }; // class } // namespace From 5ee9da9bf898c74c3dd4085e5f67556cc1053009 Mon Sep 17 00:00:00 2001 From: maria Date: Wed, 27 Mar 2019 12:32:41 +0100 Subject: [PATCH 303/686] fixes for Mahi arrival Time --- RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc index 25ee87b95b463..20c57604372e1 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc @@ -282,7 +282,7 @@ void MahiFit::updatePulseShape(double itQ, FullSampleVector &pulseShape, FullSam //with previous SOI=TS4 case assumed by psfPtr_->getPulseShape() int delta = 4 - nnlsWork_. tsOffset; - auto invDt = 0.25 / nnlsWork_.dt; + auto invDt = 0.5 / nnlsWork_.dt; for (unsigned int iTS=0; iTStimeLimit_) ? timeLimit_ : ((t<-timeLimit_) ? -timeLimit_ : t); From 37f74e5a0ff023704ad30b72f30ba20fb0d929f0 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Wed, 27 Mar 2019 12:58:32 +0100 Subject: [PATCH 304/686] Use Root API to retrieve copy numbers --- .../DDCMS/interface/DDFilteredView.h | 2 +- DetectorDescription/DDCMS/interface/Filter.h | 3 -- .../DDCMS/src/DDFilteredView.cc | 36 ++++++++----------- DetectorDescription/DDCMS/src/DDNamespace.cc | 1 - DetectorDescription/DDCMS/src/Filter.cc | 26 ++------------ 5 files changed, 19 insertions(+), 49 deletions(-) diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index b6772e49c5034..ca9df905851a2 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -97,7 +97,7 @@ namespace cms { private: bool accept(std::string_view); - bool addPath(std::string_view, Node* const); + bool addPath(Node* const); bool addNode(Node* const); ExpandedNodes nodes_; diff --git a/DetectorDescription/DDCMS/interface/Filter.h b/DetectorDescription/DDCMS/interface/Filter.h index f07c720d4d269..296530da606ac 100644 --- a/DetectorDescription/DDCMS/interface/Filter.h +++ b/DetectorDescription/DDCMS/interface/Filter.h @@ -35,9 +35,6 @@ namespace cms { bool isRegex(std::string_view); bool compareEqual(std::string_view, std::string_view); std::string_view realTopName(std::string_view input); - std::string_view noCopyNo(std::string_view input); - int copyNo(std::string_view input); - std::string_view noNamespace(std::string_view input); std::vector split(std::string_view, const char*); } } diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index ad31b44f8872e..794413ddca3a5 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -67,11 +67,8 @@ DDFilteredView::firstChild() { it_.back().SetType(0); Node *node = nullptr; while((node = it_.back().Next())) { - if(accept(noNamespace(node->GetVolume()->GetName()))) { - TString path; - it_.back().GetPath(path); - addPath(path, node); - + if(accept(node->GetVolume()->GetName())) { + addPath(node); return true; } } @@ -88,7 +85,7 @@ DDFilteredView::firstSibling() { else return false; do { - if(accepted(currentFilter_->keys, noNamespace(node_->GetVolume()->GetName()))) { + if(accepted(currentFilter_->keys, node_->GetVolume()->GetName())) { addNode(node_); return true; } @@ -102,7 +99,7 @@ DDFilteredView::nextSibling() { it_.back().SetType(1); unCheckNode(); do { - if(accepted(currentFilter_->keys, noNamespace(node_->GetVolume()->GetName()))) { + if(accepted(currentFilter_->keys, node_->GetVolume()->GetName())) { addNode(node_); return true; } @@ -116,7 +113,7 @@ DDFilteredView::sibling() { it_.back().SetType(1); Node *node = nullptr; while((node = it_.back().Next())) { - if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) { addNode(node); return true; } @@ -129,7 +126,7 @@ DDFilteredView::siblingNoCheck() { it_.back().SetType(1); Node *node = nullptr; while((node = it_.back().Next())) { - if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) { node_ = node; return true; } @@ -142,7 +139,7 @@ DDFilteredView::checkChild() { it_.back().SetType(1); Node *node = nullptr; while((node = it_.back().Next())) { - if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + if(accepted(currentFilter_->keys, node->GetVolume()->GetName())) { return true; } } @@ -217,29 +214,26 @@ DDFilteredView::extractParameters() const { } bool -DDFilteredView::addPath(string_view path, Node* const node) { +DDFilteredView::addPath(Node* const node) { assert(registry_); node_ = node; nodes_.tags.clear(); nodes_.offsets.clear(); nodes_.copyNos.clear(); - bool result(false); - auto v = split(path, "/"); - transform(v.begin(), v.end(), v.begin(), - [&](string_view s) -> string_view { return noNamespace(s); }); - - for(auto const& rv : v) { + + int level = it_.back().GetLevel(); + for(int nit = level; nit > 0; --nit) { for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) { auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) { - return (compareEqual(noCopyNo(rv), *begin(split(realTopName(j), "/"))) && + return (compareEqual(it_.back().GetNode(nit)->GetVolume()->GetName(), *begin(split(realTopName(j), "/"))) && (i.second.hasValue("CopyNoTag") || i.second.hasValue("CopyNoOffset"))); }); if(k != end(i.second.paths)) { nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag")); nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); - nodes_.copyNos.emplace_back(copyNo(rv)); + nodes_.copyNos.emplace_back(it_.back().GetNode(nit)->GetNumber()); result = true; } }); @@ -254,14 +248,14 @@ DDFilteredView::addNode(Node* const node) { bool result(false); for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) { auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) { - return (compareEqual(noCopyNo(noNamespace(node_->GetName())), *begin(split(realTopName(j), "/"))) && + return (compareEqual(node_->GetVolume()->GetName(), *begin(split(realTopName(j), "/"))) && (i.second.hasValue("CopyNoTag") || i.second.hasValue("CopyNoOffset"))); }); if(k != end(i.second.paths)) { nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag")); nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); - nodes_.copyNos.emplace_back(copyNo(node_->GetName())); + nodes_.copyNos.emplace_back(node_->GetNumber()); result = true; } }); diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc index 4ac5a96df1a20..e3397dbfa4896 100644 --- a/DetectorDescription/DDCMS/src/DDNamespace.cc +++ b/DetectorDescription/DDCMS/src/DDNamespace.cc @@ -181,7 +181,6 @@ DDNamespace::addVolume( dd4hep::Volume vol ) const string n = prepend(vol.name()); dd4hep::Solid s = vol.solid(); dd4hep::Material m = vol.material(); - vol->SetName(n.c_str()); m_context->volumes[n] = vol; dd4hep::printout( m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s", diff --git a/DetectorDescription/DDCMS/src/Filter.cc b/DetectorDescription/DDCMS/src/Filter.cc index f237c066a5d43..16c133eb9250a 100644 --- a/DetectorDescription/DDCMS/src/Filter.cc +++ b/DetectorDescription/DDCMS/src/Filter.cc @@ -12,6 +12,8 @@ namespace cms { if(!isRegex(name)) { return (name == node); } else { + if(name.front() != node.front()) + return false; regex pattern({name.data(), name.size()}); return regex_match(begin(node), end(node), pattern); } @@ -34,7 +36,7 @@ namespace cms { bool isRegex(string_view input) { return ((contains(input, "*") != -1) || - (contains(input, ".") != -1)); + (contains(input, ".") != -1)); } string_view realTopName(string_view input) { @@ -44,28 +46,6 @@ namespace cms { return v; } - string_view noCopyNo(string_view input) { - string_view v = input; - auto last = v.find_last_of("_"); - v.remove_suffix(v.size() - min(last, v.size())); - return v; - } - - int copyNo(string_view input) { - string_view v = input; - auto last = v.find_last_of("_"); - v.remove_prefix(min(last+1, v.size())); - - return stoi({v.data(), v.size()}); - } - - string_view noNamespace(string_view input) { - string_view v = input; - auto first = v.find_first_of(":"); - v.remove_prefix(min(first+1, v.size())); - return v; - } - vector split(string_view str, const char* delims) { vector ret; From 692e548b20520e841ae6581c1f13be67797a6f2e Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 27 Mar 2019 13:55:18 +0100 Subject: [PATCH 305/686] Re-add quality cuts to pi0 plugin to allow it to be easily overwritten (and to be able to see the defaults in the standard configuration) --- RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index 40f475cb2a4dd..8cb36c8e50b2c 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -75,6 +75,7 @@ modStrips2 = cms.PSet( name = cms.string("s"), plugin = cms.string('RecoTauPiZeroStripPlugin3'), + qualityCuts = PFTauQualityCuts, applyElecTrackQcuts = cms.bool(False), # Clusterize photons and electrons (PF numbering) stripCandidatesParticleIds = cms.vint32(2, 4), From bc65d127699e6154186c3b94df8b73ba21b74440 Mon Sep 17 00:00:00 2001 From: maria Date: Wed, 27 Mar 2019 15:09:23 +0100 Subject: [PATCH 306/686] add option to deactivate computation of arrivalTime for HLT --- RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h | 3 ++- RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc | 7 +++++-- .../HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc | 4 +++- RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc | 4 +++- .../HcalRecProducers/python/HBHEMahiParameters_cfi.py | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h b/RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h index a7c583e3ee17f..1405a500d1e47 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h @@ -103,7 +103,7 @@ class MahiFit void setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch, bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor, - double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, + bool iCalculateArrivalTime, double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, const std::vector &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS, double iDeltaChiSqThresh, double iNnlsThresh); @@ -165,6 +165,7 @@ class MahiFit HcalTimeSlew::BiasSetting slewFlavor_; float tsDelay1GeV_=0.f; + bool calculateArrivalTime_; float meanTime_; float timeSigmaHPD_; float timeSigmaSiPM_; diff --git a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc index 20c57604372e1..53632d49affc7 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc @@ -8,7 +8,7 @@ MahiFit::MahiFit() : void MahiFit::setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch, bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor, - double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, + bool iCalculateArrivalTime, double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, const std::vector &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS, double iDeltaChiSqThresh, double iNnlsThresh) { @@ -20,6 +20,7 @@ void MahiFit::setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwi applyTimeSlew_ = iApplyTimeSlew; slewFlavor_ = slewFlavor; + calculateArrivalTime_ = iCalculateArrivalTime; meanTime_ = iMeanTime; timeSigmaHPD_ = iTimeSigmaHPD; timeSigmaSiPM_ = iTimeSigmaSiPM; @@ -197,7 +198,9 @@ void MahiFit::doFit(std::array &correctedOutput, int nbx) const { if (foundintime) { correctedOutput.at(0) = nnlsWork_.ampVec.coeff(ipulseintime); //charge if (correctedOutput.at(0)!=0) { - float arrivalTime = calculateArrivalTime(); + // fixME store the timeslew + float arrivalTime = 0.; + if(calculateArrivalTime_) arrivalTime = calculateArrivalTime(); correctedOutput.at(1) = arrivalTime; //time } else correctedOutput.at(1) = -9999;//time diff --git a/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc b/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc index 0c43cd2e974c2..e810c4417ad4b 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc @@ -20,6 +20,7 @@ parseHBHEMahiDescription(const edm::ParameterSet& conf) const bool iApplyTimeSlew = conf.getParameter ("applyTimeSlew"); + const bool iCalculateArrivalTime = conf.getParameter ("calculateArrivalTime"); const double iMeanTime = conf.getParameter ("meanTime"); const double iTimeSigmaHPD = conf.getParameter ("timeSigmaHPD"); const double iTimeSigmaSiPM = conf.getParameter ("timeSigmaSiPM"); @@ -33,7 +34,7 @@ parseHBHEMahiDescription(const edm::ParameterSet& conf) std::unique_ptr corr = std::make_unique(); corr->setParameters(iDynamicPed, iTS4Thresh, chiSqSwitch, iApplyTimeSlew, HcalTimeSlew::Medium, - iMeanTime, iTimeSigmaHPD, iTimeSigmaSiPM, + iCalculateArrivalTime, iMeanTime, iTimeSigmaHPD, iTimeSigmaSiPM, iActiveBXs, iNMaxItersMin, iNMaxItersNNLS, iDeltaChiSqThresh, iNnlsThresh); @@ -149,6 +150,7 @@ edm::ParameterSetDescription fillDescriptionForParseHBHEPhase1Algo() desc.add("tdcTimeShift", 0.0); desc.add("correctForPhaseContainment", true); desc.add("applyLegacyHBMCorrection", true); + desc.add("calculateArrivalTime", true); return desc; } diff --git a/RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc b/RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc index 13e9a9662ea42..9e767a0780239 100644 --- a/RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc +++ b/RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc @@ -98,6 +98,7 @@ class MahiDebugger : public edm::one::EDAnalyzer { HcalTimeSlew::BiasSetting slewFlavor_; double tsDelay1GeV_=0; + bool calculateArrivalTime_; float meanTime_; float timeSigmaHPD_; float timeSigmaSiPM_; @@ -180,6 +181,7 @@ MahiDebugger::MahiDebugger(const edm::ParameterSet& iConfig) ts4Thresh_(iConfig.getParameter ("ts4Thresh")), chiSqSwitch_(iConfig.getParameter ("chiSqSwitch")), applyTimeSlew_(iConfig.getParameter ("applyTimeSlew")), + calculateArrivalTime_(iConfig.getParameter ("calculateArrivalTime")), meanTime_(iConfig.getParameter ("meanTime")), timeSigmaHPD_(iConfig.getParameter ("timeSigmaHPD")), timeSigmaSiPM_(iConfig.getParameter ("timeSigmaSiPM")), @@ -195,7 +197,7 @@ MahiDebugger::MahiDebugger(const edm::ParameterSet& iConfig) mahi_ = std::make_unique(); mahi_ -> setParameters(dynamicPed_, ts4Thresh_, chiSqSwitch_, applyTimeSlew_, HcalTimeSlew::Medium, - meanTime_, timeSigmaHPD_, timeSigmaSiPM_, + calculateArrivalTime_, meanTime_, timeSigmaHPD_, timeSigmaSiPM_, activeBXs_, nMaxItersMin_, nMaxItersNNLS_, deltaChiSqThresh_, nnlsThresh_); diff --git a/RecoLocalCalo/HcalRecProducers/python/HBHEMahiParameters_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HBHEMahiParameters_cfi.py index 30bb23811f11f..653576d5ac565 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HBHEMahiParameters_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HBHEMahiParameters_cfi.py @@ -3,6 +3,7 @@ # Configuration parameters for Mahi mahiParameters = cms.PSet( + calculateArrivalTime = cms.bool(True), dynamicPed = cms.bool(False), ts4Thresh = cms.double(0.0), chiSqSwitch = cms.double(15.0), From 00032858d9a9286ca29abb5bda36b83fd9b24b6c Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 27 Mar 2019 15:56:18 +0100 Subject: [PATCH 307/686] A few renaming and cleaning --- .../Configuration/python/RecoPFTauTag_cff.py | 2 +- .../RecoTau/plugins/PFRecoTauProducer.cc | 2 +- .../RecoTau/plugins/RecoTauPiZeroProducer.cc | 134 +----------------- .../RecoTau/python/PFRecoTauProducer_cfi.py | 4 + ...er_cfi.py => RecoTauPiZeroProducer_cff.py} | 21 ++- .../skimming/buildBackgroundDataSet_cfg.py | 2 +- .../skimming/buildSignalDataSet_cfg.py | 2 +- 7 files changed, 20 insertions(+), 147 deletions(-) create mode 100644 RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py rename RecoTauTag/RecoTau/python/{RecoTauPiZeroProducer_cfi.py => RecoTauPiZeroProducer_cff.py} (70%) diff --git a/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py b/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py index c6efb918c36ab..12d05e0cc2d93 100644 --- a/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py +++ b/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py @@ -29,7 +29,7 @@ e.toModify(recoTauAK4PFJets08Region, minJetPt = 999999.0) # Reconstruct the pi zeros in our pre-selected jets. -from RecoTauTag.RecoTau.RecoTauPiZeroProducer_cfi import ak4PFJetsLegacyHPSPiZeros +from RecoTauTag.RecoTau.RecoTauPiZeroProducer_cff import ak4PFJetsLegacyHPSPiZeros ak4PFJetsLegacyHPSPiZeros = ak4PFJetsLegacyHPSPiZeros.clone() ak4PFJetsLegacyHPSPiZeros.jetSrc = PFRecoTauPFJetInputs.inputJetCollection diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc index a511f262e733a..08ca2948228dc 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc @@ -189,7 +189,7 @@ PFRecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions desc.add("smearedPVsigmaZ", 0.005); desc.add("MatchingConeSize_max", 0.6); desc.add("HCALIsolConeSize_min", 0.0); - descriptions.add("pfRecoTauProducer", desc); + descriptions.add("pfRecoTauProducerDef", desc); } DEFINE_FWK_MODULE(PFRecoTauProducer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index 65d49a7e81d39..e0430de94e79d 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -318,135 +318,6 @@ RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descript pset_builders.addParameter("plugin",""); pset_builders.addParameter("verbosity",0); - { - // ak4PFJetsLegacyTaNCPiZeros - edm::ParameterSetDescription desc; - desc.add("massHypothesis", 0.136); - desc.addVPSet("ranking", desc_ranking, vpsd_ranking); - desc.add("verbosity", 0); - desc.add("maxJetAbsEta", 2.5); - desc.add("outputSelection", "pt > 1.5"); - desc.add("minJetPt", 14.0); - desc.add("jetSrc", edm::InputTag("ak4PFJets")); - - { - edm::ParameterSetDescription desc_builders; - desc_builders.setAllowAnything(); - desc_builders.add("qualityCuts", desc_qualityCuts); - desc_builders.add("name", "1"); - desc_builders.add("plugin", "RecoTauPiZeroTrivialPlugin"); - desc_builders.add("verbosity", 0); - - desc_builders.addOptional("makeCombinatoricStrips"); - desc_builders.addOptional("maxStripBuildIterations"); - desc_builders.addOptional("minGammaEtStripAdd"); - desc_builders.addOptional("minGammaEtStripSeed"); - desc_builders.addOptional("minStripEt"); - desc_builders.addOptional>("stripCandidatesParticleIds"); - desc_builders.addOptional("updateStripAfterEachDaughter"); - desc_builders.addOptional("applyElecTrackQcuts"); - - std::vector vpsd_builders; - vpsd_builders.push_back(pset_builders); - desc.addVPSet("builders", desc_builders, vpsd_builders); - } - - descriptions.add("ak4PFJetsLegacyTaNCPiZerosDefault", desc); - } - - { - // ak4PFJetsRecoTauGreedyPiZeros - edm::ParameterSetDescription desc; - desc.add("massHypothesis", 0.136); - desc.addVPSet("ranking", desc_ranking, vpsd_ranking); - desc.add("verbosity", 0); - desc.add("maxJetAbsEta", 2.5); - desc.add("outputSelection", "pt > 1.5"); - desc.add("minJetPt", 14.0); - desc.add("jetSrc", edm::InputTag("ak4PFJets")); - { - edm::ParameterSetDescription desc_builders; - desc_builders.setAllowAnything(); - desc_builders.add("qualityCuts", desc_qualityCuts); - desc_builders.add("maxInputStrips", 5); - desc_builders.add("name", "cs"); - desc_builders.add("plugin", "RecoTauPiZeroStripPlugin"); - desc_builders.add("stripMassWhenCombining", 0.0); - desc_builders.add("stripPhiAssociationDistance", 0.2); - desc_builders.add("stripEtaAssociationDistance", 0.05); - desc_builders.add("verbosity", 0); - - desc_builders.addOptional("makeCombinatoricStrips"); - desc_builders.addOptional("maxStripBuildIterations"); - desc_builders.addOptional("minGammaEtStripAdd"); - desc_builders.addOptional("minGammaEtStripSeed"); - desc_builders.addOptional("minStripEt"); - desc_builders.addOptional>("stripCandidatesParticleIds"); - desc_builders.addOptional("updateStripAfterEachDaughter"); - desc_builders.addOptional("applyElecTrackQcuts"); - - std::vector vpsd_builders; - vpsd_builders.push_back(pset_builders); - desc.addVPSet("builders", desc_builders, vpsd_builders); - } - descriptions.add("ak4PFJetsRecoTauGreedyPiZerosDefault", desc); - } - - { - // ak4PFJetsRecoTauPiZeros - edm::ParameterSetDescription desc; - desc.add("massHypothesis", 0.136); - desc.addVPSet("ranking", desc_ranking, vpsd_ranking); - desc.add("verbosity", 0); - desc.add("maxJetAbsEta", 2.5); - desc.add("outputSelection", "pt > 1.5"); - desc.add("minJetPt", 14.0); - desc.add("jetSrc", edm::InputTag("ak4PFJets")); - { - edm::ParameterSetDescription desc_builders; - desc_builders.setAllowAnything(); - desc_builders.add("qualityCuts", desc_qualityCuts); - desc_builders.add("name", "2"); - desc_builders.add("plugin", "RecoTauPiZeroCombinatoricPlugin"); - desc_builders.add("maxMass", -1.0); - desc_builders.add("minMass", 0.0); - desc_builders.add("choose", 2); - desc_builders.addOptional("maxInputGammas"); - desc_builders.add("verbosity", 0); - - desc_builders.addOptional("makeCombinatoricStrips"); - desc_builders.addOptional("maxStripBuildIterations"); - desc_builders.addOptional("minGammaEtStripAdd"); - desc_builders.addOptional("minGammaEtStripSeed"); - desc_builders.addOptional("minStripEt"); - desc_builders.addOptional>("stripCandidatesParticleIds"); - desc_builders.addOptional("updateStripAfterEachDaughter"); - desc_builders.addOptional("applyElecTrackQcuts"); - { - edm::ParameterSetDescription psd0; - psd0.addOptional("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); - psd0.addOptional("par1", 0.707716); - psd0.addOptional("par0", 0.352476); - desc_builders.addOptional("stripPhiAssociationDistanceFunc", psd0); - } - { - edm::ParameterSetDescription psd0; - psd0.addOptional("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); - psd0.addOptional("par1", 0.658701); - psd0.addOptional("par0", 0.197077); - desc_builders.addOptional("stripEtaAssociationDistanceFunc", psd0); - } - - // vpsd_builders.addOptional("stripPhiAssociationDistanceFunc"); - // vpsd_builders.addOptional("stripEtaAssociationDistanceFunc"); - std::vector vpsd_builders; - vpsd_builders.push_back(pset_builders); - desc.addVPSet("builders", desc_builders, vpsd_builders); - } - - descriptions.add("ak4PFJetsRecoTauPiZerosDefault", desc); - } - { // ak4PFJetsLegacyHPSPiZeros edm::ParameterSetDescription desc; @@ -498,9 +369,8 @@ RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descript desc.addVPSet("builders", desc_builders, vpsd_builders); } - descriptions.add("ak4PFJetsLegacyHPSPiZerosDefault", desc); - descriptions.add("ak4PFJetsLegacyHPSPiZerosBoostedDefault", desc); // this one is generated in configs with a strange procedure - descriptions.add("pfJetsLegacyHPSPiZerosDefault", desc); + descriptions.add("recoTauPiZeroProducer", desc); + // descriptions.add("ak4PFJetsLegacyHPSPiZerosBoostedDefault", desc); // this one is generated in configs with a strange procedure // RecoTauTag/Configuration/python/boostedHPSPFTaus_cfi.py // process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted", addToTask = True) } diff --git a/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py new file mode 100644 index 0000000000000..f7ee2c5dd1e70 --- /dev/null +++ b/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py @@ -0,0 +1,4 @@ +from RecoTauTag.RecoTau.PFRecoTauProducerDef_cfi import PFRecoTauProducerDef + +pfRecoTauProducer = PFRecoTauProducerDef.clone() + diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py similarity index 70% rename from RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py rename to RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py index b4c8752295d7a..ebf1a9b362ed1 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py @@ -3,11 +3,12 @@ import RecoTauTag.RecoTau.RecoTauPiZeroBuilderPlugins_cfi as builders import RecoTauTag.RecoTau.RecoTauPiZeroQualityPlugins_cfi as ranking from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs +from RecoTauTag.RecoTau.RecoTauPiZeroProducer_cfi import RecoTauPiZeroProducer + from Configuration.Eras.Modifier_phase2_common_cff import phase2_common -from RecoTauTag.RecoTau.ak4PFJetsLegacyHPSPiZerosDefault_cfi import ak4PFJetsLegacyHPSPiZerosDefault -ak4PFJetsLegacyHPSPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( +ak4PFJetsLegacyHPSPiZeros = RecoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -23,9 +24,8 @@ phase2_common.toModify(ak4PFJetsLegacyHPSPiZeros, builders = cms.VPSet(builders.modStrips) ) -from RecoTauTag.RecoTau.ak4PFJetsRecoTauGreedyPiZerosDefault_cfi import ak4PFJetsRecoTauGreedyPiZerosDefault -#ak4PFJetsRecoTauGreedyPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( -ak4PFJetsRecoTauGreedyPiZeros = ak4PFJetsRecoTauGreedyPiZerosDefault.clone( + +ak4PFJetsRecoTauGreedyPiZeros = RecoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -39,9 +39,8 @@ ), ) -from RecoTauTag.RecoTau.ak4PFJetsRecoTauPiZerosDefault_cfi import ak4PFJetsRecoTauPiZerosDefault -#ak4PFJetsRecoTauPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( -ak4PFJetsRecoTauPiZeros = ak4PFJetsRecoTauPiZerosDefault.clone( + +ak4PFJetsRecoTauPiZeros = RecoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -60,12 +59,12 @@ ), ) -from RecoTauTag.RecoTau.ak4PFJetsLegacyTaNCPiZerosDefault_cfi import ak4PFJetsLegacyTaNCPiZerosDefault -# ak4PFJetsLegacyTaNCPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( -ak4PFJetsLegacyTaNCPiZeros = ak4PFJetsLegacyTaNCPiZerosDefault.clone( + +ak4PFJetsLegacyTaNCPiZeros = RecoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, + massHypothesis = cms.double(0.136), outputSelection = cms.string('pt > 1.5'), builders = cms.VPSet( builders.allSinglePhotons, diff --git a/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py b/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py index aa5d29f41da52..8e2250d8d4ad7 100644 --- a/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py +++ b/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py @@ -309,7 +309,7 @@ ) # Build pizeros for our final jet collection -import RecoTauTag.RecoTau.RecoTauPiZeroProducer_cfi as PiZeroProd +import RecoTauTag.RecoTau.RecoTauPiZeroProducer_cff as PiZeroProd process.backgroundJetsRecoTauPiZeros = PiZeroProd.ak5PFJetsRecoTauPiZeros.clone( jetSrc = cms.InputTag("preselectedBackgroundJets") ) diff --git a/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py b/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py index 73b6e09051df5..d29f0aacc3285 100644 --- a/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py +++ b/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py @@ -199,7 +199,7 @@ ) # Produce and save PiZeros for the signal jets -import RecoTauTag.RecoTau.RecoTauPiZeroProducer_cfi as PiZeroProd +import RecoTauTag.RecoTau.RecoTauPiZeroProducer_cff as PiZeroProd process.signalJetsRecoTauPiZeros = PiZeroProd.ak5PFJetsRecoTauPiZeros.clone( jetSrc = cms.InputTag("preselectedSignalJets") ) From a8eb779a2e6a6860fb8cf5e50f7ca0be40044f7a Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 27 Mar 2019 16:08:22 +0100 Subject: [PATCH 308/686] fix file and config name --- RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py index ebf1a9b362ed1..c8fb8efa9f192 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py @@ -3,12 +3,12 @@ import RecoTauTag.RecoTau.RecoTauPiZeroBuilderPlugins_cfi as builders import RecoTauTag.RecoTau.RecoTauPiZeroQualityPlugins_cfi as ranking from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs -from RecoTauTag.RecoTau.RecoTauPiZeroProducer_cfi import RecoTauPiZeroProducer +from RecoTauTag.RecoTau.recoTauPiZeroProducer_cfi import recoTauPiZeroProducer from Configuration.Eras.Modifier_phase2_common_cff import phase2_common -ak4PFJetsLegacyHPSPiZeros = RecoTauPiZeroProducer.clone( +ak4PFJetsLegacyHPSPiZeros = recoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -25,7 +25,7 @@ builders = cms.VPSet(builders.modStrips) ) -ak4PFJetsRecoTauGreedyPiZeros = RecoTauPiZeroProducer.clone( +ak4PFJetsRecoTauGreedyPiZeros = recoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -40,7 +40,7 @@ ) -ak4PFJetsRecoTauPiZeros = RecoTauPiZeroProducer.clone( +ak4PFJetsRecoTauPiZeros = recoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -60,7 +60,7 @@ ) -ak4PFJetsLegacyTaNCPiZeros = RecoTauPiZeroProducer.clone( +ak4PFJetsLegacyTaNCPiZeros = recoTauPiZeroProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, From 3105c175fc7392fb813d2ba4ec1453fa4a4c3868 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 27 Mar 2019 16:21:42 +0100 Subject: [PATCH 309/686] Fix default file name --- RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc index 08ca2948228dc..a637379cef27f 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc @@ -189,7 +189,7 @@ PFRecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions desc.add("smearedPVsigmaZ", 0.005); desc.add("MatchingConeSize_max", 0.6); desc.add("HCALIsolConeSize_min", 0.0); - descriptions.add("pfRecoTauProducerDef", desc); + descriptions.add("PFRecoTauProducerDef", desc); } DEFINE_FWK_MODULE(PFRecoTauProducer); From 70096f5cc8562012e3aa8138144e662b1e621404 Mon Sep 17 00:00:00 2001 From: jingyu zhang Date: Wed, 27 Mar 2019 11:05:51 -0500 Subject: [PATCH 310/686] remove commented-out lines --- Validation/HGCalValidation/plugins/HGCalDigiValidation.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc index 450f05dfc4c05..a8a1b4344079f 100644 --- a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc @@ -92,7 +92,6 @@ class HGCalDigiValidation : public DQMEDAnalyzer { std::map OccupancyMap_plus_; std::map OccupancyMap_minus_; - //std::vector charge_; std::vector TOA_; std::vector DigiOccupancy_XY_; std::vector ADC_; @@ -192,7 +191,6 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - //double charge = adc*gain; double charge = gain; bool totmode = hgcSample.mode(); bool zerothreshold = hgcSample.threshold(); @@ -222,7 +220,6 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - //double charge = adc*gain; double charge = gain; bool totmode = hgcSample.mode(); bool zerothreshold = hgcSample.threshold(); @@ -249,7 +246,6 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - //double charge = adc*gain; double charge = gain; bool totmode = hgcSample.mode(); bool zerothreshold = hgcSample.threshold(); @@ -354,7 +350,6 @@ void HGCalDigiValidation::fillOccupancyMap(std::map& OccupancyMap, void HGCalDigiValidation::fillDigiInfo(digiInfo& hinfo) { int ilayer = hinfo.layer; - //charge_.at(ilayer)->Fill(hinfo.charge); TOA_.at(ilayer)->Fill(hinfo.charge); if (hinfo.mode) { @@ -412,8 +407,6 @@ void HGCalDigiValidation::bookHistograms(DQMStore::IBooker& iB, std::ostringstream histoname; for (int il = 0; il < layers_; ++il) { int ilayer = firstLayer_ + il; - //histoname.str(""); histoname << "charge_"<< "layer_" << ilayer; - //charge_.push_back(iB.book1D(histoname.str().c_str(),"charge_",100,-25,25)); histoname.str(""); histoname << "TOA_"<< "layer_" << ilayer; TOA_.push_back(iB.book1D(histoname.str().c_str(),"toa_",1024,0,1024)); From b0eb2bf98543bdd59c474bbef51e065dbe54d17c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Mar 2019 19:06:13 +0100 Subject: [PATCH 311/686] Changes to DDHCalAngular by removing explicit reference to CLHEP --- Geometry/HcalAlgo/plugins/DDHCalAngular.cc | 87 +++++++++++++--------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc index 7f8eccf7ca707..6baf5a990da96 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc @@ -7,13 +7,19 @@ #include #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "Geometry/HcalAlgo/plugins/DDHCalAngular.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units; +using namespace geant_units::operators; DDHCalAngular::DDHCalAngular() { - LogDebug("HCalGeom") << "DDHCalAngular test: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating an instance"; +#endif } DDHCalAngular::~DDHCalAngular() {} @@ -32,37 +38,44 @@ void DDHCalAngular::initialize(const DDNumericArguments & nArgs, n = int (nArgs["n"]); startCopyNo = int (nArgs["startCopyNo"]); incrCopyNo = int (nArgs["incrCopyNo"]); - LogDebug("HCalGeom") << "DDHCalAngular debug: Parameters for positioning-- " - << n << " copies in " << rangeAngle/CLHEP::deg - << " from " << startAngle/CLHEP::deg << "\tShifts " - << shiftX << ", " << shiftY - << " along x, y axes; \tZoffest " << zoffset - << "\tStart and inremental copy nos " << startCopyNo - << ", " << incrCopyNo; - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parameters for positioning " + << "-- " << n << " copies in " + << convertRadToDeg(rangeAngle) << " from " + << convertRadToDeg(startAngle) << "\tShifts " + << shiftX << ", " << shiftY + << " along x, y axes; \tZoffest " << zoffset + << "\tStart and inremental copy nos " + << startCopyNo << ", " << incrCopyNo; +#endif rotns = sArgs["RotNameSpace"]; idNameSpace = DDCurrentNamespace::ns(); childName = sArgs["ChildName"]; +#ifdef EDM_ML_DEBUG DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalAngular debug: Parent " << parentName - << "\tChild " << childName << "\tNameSpace " - << idNameSpace << "\tRotation Namespace " << rotns; + edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parent " << parentName + << "\tChild " << childName << "\tNameSpace " + << idNameSpace << "\tRotation Namespace " + << rotns; +#endif } void DDHCalAngular::execute(DDCompactView& cpv) { double dphi = rangeAngle/n; - double phi = startAngle; + double phix = startAngle; int copyNo = startCopyNo; + double theta = 90._deg; for (int ii=0; ii 0) iphi = int(phideg+0.1); - else iphi = int(phideg-0.1); - if (iphi >= 360) iphi -= 360; - phideg = iphi; + double phideg = convertRadToDeg(phix); + int iphi = std::lround(phideg); + if (iphi >= 360) { + iphi -= 360; + phideg = iphi; + phix = convertDegToRad(phideg); + } + double phiy = phix + 90._deg; DDRotation rotation; std::string rotstr("NULL"); @@ -72,26 +85,30 @@ void DDHCalAngular::execute(DDCompactView& cpv) { rotstr = rotstr + std::to_string(phideg); rotation = DDRotation(DDName(rotstr, rotns)); if (!rotation) { - LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation " - << DDName(rotstr, idNameSpace) << "\t90, " - << phideg << ", 90, " << (phideg+90) << ", 0, 0"; - rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg, - phideg*CLHEP::deg, 90*CLHEP::deg, - (90+phideg)*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating a rotation " + << DDName(rotstr, idNameSpace) << "\t90, " + << phideg << ", 90, " << (phideg+90) + << ", 0, 0"; +#endif + rotation = DDrot(DDName(rotstr, rotns), theta, phix, theta, phiy, 0,0); } } - double xpos = shiftX*cos(phi) - shiftY*sin(phi); - double ypos = shiftX*sin(phi) + shiftY*cos(phi); + double xpos = shiftX*cos(phix) - shiftY*sin(phix); + double ypos = shiftX*sin(phix) + shiftY*cos(phix); DDTranslation tran(xpos, ypos, zoffset); DDName parentName = parent().name(); - cpv.position(DDName(childName,idNameSpace), parentName, copyNo, tran, rotation); - LogDebug("HCalGeom") << "DDHCalAngular test: " - << DDName(childName, idNameSpace) << " number " - << copyNo << " positioned in " << parentName << " at " - << tran << " with " << rotation; - phi += dphi; + cpv.position(DDName(childName,idNameSpace),parentName,copyNo,tran,rotation); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalAngular: " + << DDName(childName, idNameSpace) + << " number " << copyNo << " positioned in " + << parentName << " at " << tran << " with " + << rotation; +#endif + phix += dphi; copyNo += incrCopyNo; } } From eac0f7da769c11793ab4facab8ebf49030a726d8 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 27 Mar 2019 20:30:51 +0100 Subject: [PATCH 312/686] remove setAllowAnything --- .../RecoTau/plugins/RecoTauPiZeroProducer.cc | 77 +++++++++---------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index e0430de94e79d..a8b7c35aa4b41 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -319,7 +319,7 @@ RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descript pset_builders.addParameter("verbosity",0); { - // ak4PFJetsLegacyHPSPiZeros + // Tailored on ak4PFJetsLegacyHPSPiZeros edm::ParameterSetDescription desc; desc.add("massHypothesis", 0.136); desc.addVPSet("ranking", desc_ranking, vpsd_ranking); @@ -328,51 +328,46 @@ RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descript desc.add("outputSelection", "pt > 0"); desc.add("minJetPt", 14.0); desc.add("jetSrc", edm::InputTag("ak4PFJets")); + edm::ParameterSetDescription desc_builders; - desc_builders.setAllowAnything(); { - // both of the following uncommented version need to be accepted. - { - edm::ParameterSetDescription psd0; - psd0.add("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); - psd0.add("par1", 0.707716); - psd0.add("par0", 0.352476); - desc_builders.addOptional("stripPhiAssociationDistanceFunc", psd0); - } - { - edm::ParameterSetDescription psd0; - psd0.add("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); - psd0.add("par1", 0.658701); - psd0.add("par0", 0.197077); - desc_builders.addOptional("stripEtaAssociationDistanceFunc", psd0); - } - desc_builders.addOptional("stripEtaAssociationDistance", 0.05); - desc_builders.addOptional("stripPhiAssociationDistance", 0.2); - - desc_builders.add("qualityCuts", desc_qualityCuts); - - desc_builders.add("name"); - desc_builders.add("plugin"); - desc_builders.add("verbosity", 0); - - desc_builders.addOptional("makeCombinatoricStrips"); - desc_builders.addOptional("maxStripBuildIterations"); - desc_builders.addOptional("minGammaEtStripAdd"); - desc_builders.addOptional("minGammaEtStripSeed"); - desc_builders.addOptional("minStripEt"); - desc_builders.addOptional>("stripCandidatesParticleIds"); - desc_builders.addOptional("updateStripAfterEachDaughter"); - desc_builders.addOptional("applyElecTrackQcuts"); - - std::vector vpsd_builders; - vpsd_builders.push_back(pset_builders); - desc.addVPSet("builders", desc_builders, vpsd_builders); + edm::ParameterSetDescription psd0; + psd0.add("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.add("par1", 0.707716); + psd0.add("par0", 0.352476); + desc_builders.addOptional("stripPhiAssociationDistanceFunc", psd0); } + { + edm::ParameterSetDescription psd0; + psd0.add("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.add("par1", 0.658701); + psd0.add("par0", 0.197077); + desc_builders.addOptional("stripEtaAssociationDistanceFunc", psd0); + } + desc_builders.addOptional("stripEtaAssociationDistance", 0.05); + desc_builders.addOptional("stripPhiAssociationDistance", 0.2); + + desc_builders.add("qualityCuts", desc_qualityCuts); + + desc_builders.add("name"); + desc_builders.add("plugin"); + desc_builders.add("verbosity", 0); + + desc_builders.addOptional("makeCombinatoricStrips"); + desc_builders.addOptional("maxStripBuildIterations"); + desc_builders.addOptional("minGammaEtStripAdd"); + desc_builders.addOptional("minGammaEtStripSeed"); + desc_builders.addOptional("minStripEt"); + desc_builders.addOptional>("stripCandidatesParticleIds"); + desc_builders.addOptional("updateStripAfterEachDaughter"); + desc_builders.addOptional("applyElecTrackQcuts"); + + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + desc.addVPSet("builders", desc_builders, vpsd_builders); descriptions.add("recoTauPiZeroProducer", desc); - // descriptions.add("ak4PFJetsLegacyHPSPiZerosBoostedDefault", desc); // this one is generated in configs with a strange procedure - // RecoTauTag/Configuration/python/boostedHPSPFTaus_cfi.py - // process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted", addToTask = True) + } } From 1bf4bb286e9245013996a44f837bdc009977aa13 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 21 Mar 2019 18:38:04 +0100 Subject: [PATCH 313/686] add necessary changes to handle dump import and fetch novel TrackerDetToDTCELinkCablingMap and DTCELinkId CondFormats --- CondCore/Utilities/BuildFile.xml | 1 + CondCore/Utilities/plugins/Module_2XML.cc | 2 ++ CondCore/Utilities/src/CondDBFetch.cc | 2 ++ CondCore/Utilities/src/CondDBImport.cc | 2 ++ CondCore/Utilities/src/CondFormats.h | 3 ++- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CondCore/Utilities/BuildFile.xml b/CondCore/Utilities/BuildFile.xml index b23be7ad383ab..f985782ccc5c5 100644 --- a/CondCore/Utilities/BuildFile.xml +++ b/CondCore/Utilities/BuildFile.xml @@ -33,6 +33,7 @@ + diff --git a/CondCore/Utilities/plugins/Module_2XML.cc b/CondCore/Utilities/plugins/Module_2XML.cc index 65de9516a9a5c..7f4dbfd0600aa 100644 --- a/CondCore/Utilities/plugins/Module_2XML.cc +++ b/CondCore/Utilities/plugins/Module_2XML.cc @@ -260,6 +260,8 @@ PAYLOAD_2XML_MODULE( pluginUtilities_payload2xml ){ PAYLOAD_2XML_CLASS( SiStripNoises ); PAYLOAD_2XML_CLASS( SiStripPedestals ); PAYLOAD_2XML_CLASS( SiStripThreshold ); + PAYLOAD_2XML_CLASS( DTCELinkId ); + PAYLOAD_2XML_CLASS( TrackerDetToDTCELinkCablingMap ); //PAYLOAD_2XML_CLASS( StorableDoubleMap ); PAYLOAD_2XML_CLASS( TrackProbabilityCalibration ); PAYLOAD_2XML_CLASS( cond::BaseKeyed ); diff --git a/CondCore/Utilities/src/CondDBFetch.cc b/CondCore/Utilities/src/CondDBFetch.cc index d3520496247d5..7c160d972cf6a 100644 --- a/CondCore/Utilities/src/CondDBFetch.cc +++ b/CondCore/Utilities/src/CondDBFetch.cc @@ -292,6 +292,8 @@ namespace cond { FETCH_PAYLOAD_CASE( SiStripNoises ) FETCH_PAYLOAD_CASE( SiStripPedestals ) FETCH_PAYLOAD_CASE( SiStripThreshold ) + FETCH_PAYLOAD_CASE( DTCELinkId ) + FETCH_PAYLOAD_CASE( TrackerDetToDTCELinkCablingMap ) FETCH_PAYLOAD_CASE( TrackProbabilityCalibration ) FETCH_PAYLOAD_CASE( cond::BaseKeyed ) FETCH_PAYLOAD_CASE( ESCondObjectContainer ) diff --git a/CondCore/Utilities/src/CondDBImport.cc b/CondCore/Utilities/src/CondDBImport.cc index 1be5546d1fb8b..ea3e6980cb853 100644 --- a/CondCore/Utilities/src/CondDBImport.cc +++ b/CondCore/Utilities/src/CondDBImport.cc @@ -313,6 +313,8 @@ namespace cond { IMPORT_PAYLOAD_CASE( SiStripNoises ) IMPORT_PAYLOAD_CASE( SiStripPedestals ) IMPORT_PAYLOAD_CASE( SiStripThreshold ) + IMPORT_PAYLOAD_CASE( DTCELinkId ) + IMPORT_PAYLOAD_CASE( TrackerDetToDTCELinkCablingMap ) IMPORT_PAYLOAD_CASE( TrackProbabilityCalibration ) IMPORT_PAYLOAD_CASE( cond::BaseKeyed ) IMPORT_PAYLOAD_CASE( ESCondObjectContainer ) diff --git a/CondCore/Utilities/src/CondFormats.h b/CondCore/Utilities/src/CondFormats.h index 3809277da5e18..7c7c3d7814b6d 100644 --- a/CondCore/Utilities/src/CondFormats.h +++ b/CondCore/Utilities/src/CondFormats.h @@ -261,7 +261,8 @@ #include "CondFormats/BTauObjects/interface/TrackProbabilityCalibration.h" #include "CondFormats/MFObjects/interface/MagFieldConfig.h" #include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" - +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" #include "CondFormats/Common/interface/BaseKeyed.h" #include "CondFormats/External/interface/DetID.h" From 593b6b67348491254de0a0febe7d644e9180c926 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 7 Mar 2019 15:29:46 +0100 Subject: [PATCH 314/686] Introduce HGCalClusteringAlgoBase to easily swap algorithms --- .../interface/HGCalClusteringAlgoBase.h | 59 +++++++++++++++++++ .../interface/HGCalImagingAlgo.h | 58 ++++++------------ .../plugins/HGCalLayerClusterProducer.cc | 2 +- 3 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h new file mode 100644 index 0000000000000..8d0ec1d16030a --- /dev/null +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h @@ -0,0 +1,59 @@ +#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalClusteringAlgoBase_h +#define RecoLocalCalo_HGCalRecAlgos_HGCalClusteringAlgoBase_h + +#include "FWCore/Framework/interface/EventSetup.h" + +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/EgammaReco/interface/BasicCluster.h" + +#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" + +// C/C++ headers +#include + +class HGCalClusteringAlgoBase +{ + +public: + +enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; + + HGCalClusteringAlgoBase(VerbosityLevel v, + reco::CaloCluster::AlgoId algo) + : verbosity_(v), algoId_(algo) {}; + virtual ~HGCalClusteringAlgoBase() {} + + virtual void populate(const HGCRecHitCollection &hits) = 0; + virtual void makeClusters() = 0; + virtual std::vector getClusters(bool) = 0; + virtual void reset() = 0; + + inline void getEventSetup(const edm::EventSetup& es){ + rhtools_.getEventSetup(es); + } + inline void setVerbosity(VerbosityLevel the_verbosity) { + verbosity_ = the_verbosity; + } + + //max number of layers + static const unsigned int maxlayer = 52; + // last layer per subdetector + static const unsigned int lastLayerEE = 28; + static const unsigned int lastLayerFH = 40; + +protected: + // The verbosity level + VerbosityLevel verbosity_; + + // The vector of clusters + std::vector clusters_v_; + + hgcal::RecHitTools rhtools_; + + // The algo id + reco::CaloCluster::AlgoId algoId_; + +}; + +#endif diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h index 0d0db119a986d..8c2ec6aa8cd99 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h @@ -1,6 +1,8 @@ #ifndef RecoLocalCalo_HGCalRecAlgos_HGCalImagingAlgo_h #define RecoLocalCalo_HGCalRecAlgos_HGCalImagingAlgo_h +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" + #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" #include "Geometry/CaloTopology/interface/HGCalTopology.h" #include "DataFormats/DetId/interface/DetId.h" @@ -56,19 +58,16 @@ size_t max_index(const std::vector &v) { return (*maxidx); } -class HGCalImagingAlgo +class HGCalImagingAlgo : public HGCalClusteringAlgoBase { - - public: -enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; - HGCalImagingAlgo() : thresholdW0_(), positionDeltaRho_c_(), - vecDeltas_(), kappa_(1.), ecut_(0.), - sigma2_(1.0), - algoId_(reco::CaloCluster::undefined), - verbosity_(pERROR),initialized_(false){ + HGCalImagingAlgo() : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined), + thresholdW0_(), positionDeltaRho_c_(), + vecDeltas_(), kappa_(1.), ecut_(0.), + sigma2_(1.0), + initialized_(false) { } HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& positionDeltaRho_c_in, @@ -82,12 +81,12 @@ enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; const std::vector& nonAgedNoises_in, double noiseMip_in, VerbosityLevel the_verbosity = pERROR) : + HGCalClusteringAlgoBase(the_verbosity, algoId_in), thresholdW0_(thresholdW0_in), positionDeltaRho_c_(positionDeltaRho_c_in), vecDeltas_(vecDeltas_in), kappa_(kappa_in), ecut_(ecut_in), sigma2_(1.0), - algoId_(algoId_in), dependSensor_(dependSensor_in), dEdXweights_(dEdXweights_in), thicknessCorrection_(thicknessCorrection_in), @@ -95,7 +94,6 @@ enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; fcPerEle_(fcPerEle_in), nonAgedNoises_(nonAgedNoises_in), noiseMip_(noiseMip_in), - verbosity_(the_verbosity), initialized_(false), points_(2*(maxlayer+1)), minpos_(2*(maxlayer+1),{ @@ -117,12 +115,12 @@ HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& nonAgedNoises_in, double noiseMip_in, VerbosityLevel the_verbosity = pERROR) : + HGCalClusteringAlgoBase(the_verbosity, algoId_in), thresholdW0_(thresholdW0_in), positionDeltaRho_c_(positionDeltaRho_c_in), vecDeltas_(vecDeltas_in), kappa_(kappa_in), ecut_(ecut_in), sigma2_(std::pow(showerSigma,2.0)), - algoId_(algoId_in), dependSensor_(dependSensor_in), dEdXweights_(dEdXweights_in), thicknessCorrection_(thicknessCorrection_in), @@ -130,7 +128,6 @@ HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& thresholdW0_in, const std::vector getClusters(bool); -// needed to switch between EE and HE with the same algorithm object (to get a single cluster collection) -void getEventSetup(const edm::EventSetup& es){ - rhtools_.getEventSetup(es); -} +virtual std::vector getClusters(bool) override; + // use this if you want to reuse the same cluster object but don't want to accumulate clusters (hardly useful?) -void reset(){ +virtual void reset() override { clusters_v_.clear(); layerClustersPerLayer_.clear(); for( auto& it: points_) @@ -182,14 +172,7 @@ void computeThreshold(); /// point in the space typedef math::XYZPoint Point; -//max number of layers -static const unsigned int maxlayer = 52; - - private: -// last layer per subdetector -static const unsigned int lastLayerEE = 28; -static const unsigned int lastLayerFH = 40; // To compute the cluster position std::vector thresholdW0_; @@ -227,9 +210,6 @@ double noiseMip_; std::vector > thresholds_; std::vector > sigmaNoise_; -// The verbosity level -VerbosityLevel verbosity_; - // initialization bool bool initialized_; @@ -320,7 +300,7 @@ math::XYZPoint calculatePosition(std::vector &) const; //For keeping the density information void setDensity(const std::vector &nd); - + // attempt to find subclusters within a given set of hexels std::vector findLocalMaximaInCluster(const std::vector&); math::XYZPoint calculatePositionWithFraction(const std::vector&, const std::vector&); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index aeb155b8029c1..5938c252be615 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -46,7 +46,7 @@ class HGCalLayerClusterProducer : public edm::stream::EDProducer<> { reco::CaloCluster::AlgoId algoId; - std::unique_ptr algo; + std::unique_ptr algo; bool doSharing; std::string detector; From dcbe55a8fda8bed24bf2a8a46cfabcdc732cdf1e Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 7 Mar 2019 16:26:18 +0100 Subject: [PATCH 315/686] Initial commit for CLUE algorithm --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 285 +++++++++ .../HGCalRecAlgos/src/HGCalCLUEAlgo.cc | 583 ++++++++++++++++++ 2 files changed, 868 insertions(+) create mode 100644 RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h create mode 100644 RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h new file mode 100644 index 0000000000000..cf52d1c68efc3 --- /dev/null +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -0,0 +1,285 @@ +#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalCLUEAlgo_h +#define RecoLocalCalo_HGCalRecAlgos_HGCalCLUEAlgo_h + +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" + +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/CaloGeometry/interface/TruncatedPyramid.h" +#include "Geometry/CaloTopology/interface/HGCalTopology.h" +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" + +#include "DataFormats/EgammaReco/interface/BasicCluster.h" +#include "DataFormats/Math/interface/Point3D.h" + +#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" + +// C/C++ headers +#include +#include +#include +#include + +#include "KDTreeLinkerAlgoT.h" + +template +std::vector sorted_indices(const std::vector &v) { + // initialize original index locations + std::vector idx(v.size()); + std::iota(std::begin(idx), std::end(idx), 0); + + // sort indices based on comparing values in v + std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] > v[i2]; }); + + return idx; +} + +template +size_t max_index(const std::vector &v) { + // initialize original index locations + std::vector idx(v.size(), 0); + std::iota(std::begin(idx), std::end(idx), 0); + + // take the max index based on comparing values in v + auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { + return v[i1].data.rho < v[i2].data.rho; + }); + + return (*maxidx); +} + +class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { + public: + HGCalCLUEAlgo() + : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined), + thresholdW0_(), + positionDeltaRho_c_(), + vecDeltas_(), + kappa_(1.), + ecut_(0.), + sigma2_(1.0), + initialized_(false) {} + + HGCalCLUEAlgo(const std::vector &thresholdW0_in, + const std::vector &positionDeltaRho_c_in, + const std::vector &vecDeltas_in, double kappa_in, double ecut_in, + reco::CaloCluster::AlgoId algoId_in, bool dependSensor_in, + const std::vector &dEdXweights_in, + const std::vector &thicknessCorrection_in, + const std::vector &fcPerMip_in, double fcPerEle_in, + const std::vector &nonAgedNoises_in, double noiseMip_in, + VerbosityLevel the_verbosity = pERROR) + : HGCalClusteringAlgoBase(the_verbosity, algoId_in), + thresholdW0_(thresholdW0_in), + positionDeltaRho_c_(positionDeltaRho_c_in), + vecDeltas_(vecDeltas_in), + kappa_(kappa_in), + ecut_(ecut_in), + sigma2_(1.0), + dependSensor_(dependSensor_in), + dEdXweights_(dEdXweights_in), + thicknessCorrection_(thicknessCorrection_in), + fcPerMip_(fcPerMip_in), + fcPerEle_(fcPerEle_in), + nonAgedNoises_(nonAgedNoises_in), + noiseMip_(noiseMip_in), + initialized_(false), + points_(2 * (maxlayer + 1)), + minpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}), + maxpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}) {} + + HGCalCLUEAlgo(const std::vector &thresholdW0_in, + const std::vector &positionDeltaRho_c_in, + const std::vector &vecDeltas_in, double kappa_in, double ecut_in, + double showerSigma, reco::CaloCluster::AlgoId algoId_in, bool dependSensor_in, + const std::vector &dEdXweights_in, + const std::vector &thicknessCorrection_in, + const std::vector &fcPerMip_in, double fcPerEle_in, + const std::vector &nonAgedNoises_in, double noiseMip_in, + VerbosityLevel the_verbosity = pERROR) + : HGCalClusteringAlgoBase(the_verbosity, algoId_in), + thresholdW0_(thresholdW0_in), + positionDeltaRho_c_(positionDeltaRho_c_in), + vecDeltas_(vecDeltas_in), + kappa_(kappa_in), + ecut_(ecut_in), + sigma2_(std::pow(showerSigma, 2.0)), + dependSensor_(dependSensor_in), + dEdXweights_(dEdXweights_in), + thicknessCorrection_(thicknessCorrection_in), + fcPerMip_(fcPerMip_in), + fcPerEle_(fcPerEle_in), + nonAgedNoises_(nonAgedNoises_in), + noiseMip_(noiseMip_in), + initialized_(false), + points_(2 * (maxlayer + 1)), + minpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}), + maxpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}) {} + + virtual ~HGCalCLUEAlgo() {} + + virtual void populate(const HGCRecHitCollection &hits) override; + // this is the method that will start the clusterisation (it is possible to invoke this method + // more than once - but make sure it is with different hit collections (or else use reset) + + virtual void makeClusters() override; + + // this is the method to get the cluster collection out + virtual std::vector getClusters(bool) override; + + // use this if you want to reuse the same cluster object but don't want to accumulate clusters + // (hardly useful?) + virtual void reset() override { + clusters_v_.clear(); + layerClustersPerLayer_.clear(); + for (auto &it : points_) { + it.clear(); + std::vector().swap(it); + } + for (unsigned int i = 0; i < minpos_.size(); i++) { + minpos_[i][0] = 0.; + minpos_[i][1] = 0.; + maxpos_[i][0] = 0.; + maxpos_[i][1] = 0.; + } + } + void computeThreshold(); + + /// point in the space + typedef math::XYZPoint Point; + + private: + // To compute the cluster position + std::vector thresholdW0_; + std::vector positionDeltaRho_c_; + + // The two parameters used to identify clusters + std::vector vecDeltas_; + double kappa_; + + // The hit energy cutoff + double ecut_; + + // for energy sharing + double sigma2_; // transverse shower size + + // various parameters used for calculating the noise levels for a given sensor (and whether to use + // them) + bool dependSensor_; + std::vector dEdXweights_; + std::vector thicknessCorrection_; + std::vector fcPerMip_; + double fcPerEle_; + std::vector nonAgedNoises_; + double noiseMip_; + std::vector > thresholds_; + std::vector > v_sigmaNoise_; + + // initialization bool + bool initialized_; + + struct Hexel { + double x; + double y; + double z; + bool isHalfCell; + double weight; + double fraction; + DetId detid; + double rho; + double delta; + int nearestHigher; + int clusterIndex; + float sigmaNoise; + float thickness; + const hgcal::RecHitTools *tools; + + Hexel(const HGCRecHit &hit, DetId id_in, bool isHalf, float sigmaNoise_in, float thickness_in, + const hgcal::RecHitTools *tools_in) + : isHalfCell(isHalf), + weight(0.), + fraction(1.0), + detid(id_in), + rho(0.), + delta(0.), + nearestHigher(-1), + clusterIndex(-1), + sigmaNoise(sigmaNoise_in), + thickness(thickness_in), + tools(tools_in) { + const GlobalPoint position(tools->getPosition(detid)); + weight = hit.energy(); + x = position.x(); + y = position.y(); + z = position.z(); + } + Hexel() + : x(0.), + y(0.), + z(0.), + isHalfCell(false), + weight(0.), + fraction(1.0), + detid(), + rho(0.), + delta(0.), + nearestHigher(-1), + clusterIndex(-1), + sigmaNoise(0.), + thickness(0.), + tools(nullptr) {} + bool operator>(const Hexel &rhs) const { return (rho > rhs.rho); } + }; + + typedef KDTreeLinkerAlgo KDTree; + typedef KDTreeNodeInfoT KDNode; + + std::vector > > layerClustersPerLayer_; + + std::vector sort_by_delta(const std::vector &v) const { + std::vector idx(v.size()); + std::iota(std::begin(idx), std::end(idx), 0); + sort(idx.begin(), idx.end(), + [&v](size_t i1, size_t i2) { return v[i1].data.delta > v[i2].data.delta; }); + return idx; + } + + std::vector > points_; // a vector of vectors of hexels, one for each layer + //@@EM todo: the number of layers should be obtained programmatically - the range is 1-n instead + //of 0-n-1... + + std::vector > minpos_; + std::vector > maxpos_; + + // these functions should be in a helper class. + inline double distance2(const Hexel &pt1, const Hexel &pt2) const { // distance squared + const double dx = pt1.x - pt2.x; + const double dy = pt1.y - pt2.y; + return (dx * dx + dy * dy); + } // distance squaredq + inline double distance(const Hexel &pt1, + const Hexel &pt2) const { // 2-d distance on the layer (x-y) + return std::sqrt(distance2(pt1, pt2)); + } + double calculateLocalDensity(std::vector &, KDTree &, + const unsigned int) const; // return max density + double calculateDistanceToHigher(std::vector &) const; + int findAndAssignClusters(std::vector &, KDTree &, double, KDTreeBox &, + const unsigned int, std::vector > &) const; + math::XYZPoint calculatePosition(std::vector &) const; + + // attempt to find subclusters within a given set of hexels + std::vector findLocalMaximaInCluster(const std::vector &); + math::XYZPoint calculatePositionWithFraction(const std::vector &, + const std::vector &); + double calculateEnergyWithFraction(const std::vector &, const std::vector &); + // outputs + void shareEnergy(const std::vector &, const std::vector &, + std::vector > &); +}; + +#endif diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc new file mode 100644 index 0000000000000..8ca7126192ef4 --- /dev/null +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc @@ -0,0 +1,583 @@ +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h" + +// Geometry +#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" +#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" + +#include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h" +// +#include "DataFormats/CaloRecHit/interface/CaloID.h" +#include "tbb/task_arena.h" +#include "tbb/tbb.h" + +void HGCalCLUEAlgo::populate(const HGCRecHitCollection &hits) { + // loop over all hits and create the Hexel structure, skip energies below ecut + + if (dependSensor_) { + // for each layer and wafer calculate the thresholds (sigmaNoise and energy) + // once + computeThreshold(); + } + + std::vector firstHit(2 * (maxlayer + 1), true); + for (unsigned int i = 0; i < hits.size(); ++i) { + const HGCRecHit &hgrh = hits[i]; + DetId detid = hgrh.detid(); + unsigned int layer = rhtools_.getLayerWithOffset(detid); + float thickness = 0.f; + // set sigmaNoise default value 1 to use kappa value directly in case of + // sensor-independent thresholds + float sigmaNoise = 1.f; + if (dependSensor_) { + thickness = rhtools_.getSiThickness(detid); + int thickness_index = rhtools_.getSiThickIndex(detid); + if (thickness_index == -1) thickness_index = 3; + double storedThreshold = thresholds_[layer - 1][thickness_index]; + sigmaNoise = v_sigmaNoise_[layer - 1][thickness_index]; + + if (hgrh.energy() < storedThreshold) + continue; // this sets the ZS threshold at ecut times the sigma noise + // for the sensor + } + if (!dependSensor_ && hgrh.energy() < ecut_) continue; + + // map layers from positive endcap (z) to layer + maxlayer+1 to prevent + // mixing up hits from different sides + layer += int(rhtools_.zside(detid) > 0) * (maxlayer + 1); + + // determine whether this is a half-hexagon + bool isHalf = rhtools_.isHalfCell(detid); + const GlobalPoint position(rhtools_.getPosition(detid)); + + // here's were the KDNode is passed its dims arguments - note that these are + // *copied* from the Hexel + points_[layer].emplace_back(Hexel(hgrh, detid, isHalf, sigmaNoise, thickness, &rhtools_), + position.x(), position.y()); + + // for each layer, store the minimum and maximum x and y coordinates for the + // KDTreeBox boundaries + if (firstHit[layer]) { + minpos_[layer][0] = position.x(); + minpos_[layer][1] = position.y(); + maxpos_[layer][0] = position.x(); + maxpos_[layer][1] = position.y(); + firstHit[layer] = false; + } else { + minpos_[layer][0] = std::min((float)position.x(), minpos_[layer][0]); + minpos_[layer][1] = std::min((float)position.y(), minpos_[layer][1]); + maxpos_[layer][0] = std::max((float)position.x(), maxpos_[layer][0]); + maxpos_[layer][1] = std::max((float)position.y(), maxpos_[layer][1]); + } + + } // end loop hits +} +// Create a vector of Hexels associated to one cluster from a collection of +// HGCalRecHits - this can be used directly to make the final cluster list - +// this method can be invoked multiple times for the same event with different +// input (reset should be called between events) +void HGCalCLUEAlgo::makeClusters() { + layerClustersPerLayer_.resize(2 * maxlayer + 2); + // assign all hits in each layer to a cluster core + tbb::this_task_arena::isolate([&] { + tbb::parallel_for(size_t(0), size_t(2 * maxlayer + 2), [&](size_t i) { + KDTreeBox bounds(minpos_[i][0], maxpos_[i][0], minpos_[i][1], maxpos_[i][1]); + KDTree hit_kdtree; + hit_kdtree.build(points_[i], bounds); + + unsigned int actualLayer = i > maxlayer + ? (i - (maxlayer + 1)) + : i; // maps back from index used for KD trees to actual layer + + double maxdensity = calculateLocalDensity(points_[i], hit_kdtree, + actualLayer); // also stores rho (energy + // density) for each point (node) + // calculate distance to nearest point with higher density storing + // distance (delta) and point's index + calculateDistanceToHigher(points_[i]); + findAndAssignClusters(points_[i], hit_kdtree, maxdensity, bounds, actualLayer, + layerClustersPerLayer_[i]); + }); + }); +} + +std::vector HGCalCLUEAlgo::getClusters(bool doSharing) { + reco::CaloID caloID = reco::CaloID::DET_HGCAL_ENDCAP; + std::vector> thisCluster; + for (auto &clsOnLayer : layerClustersPerLayer_) { + for (unsigned int i = 0; i < clsOnLayer.size(); ++i) { + double energy = 0; + Point position; + + // Will save the maximum density hit of the cluster + size_t rsmax = max_index(clsOnLayer[i]); + + if (doSharing) { + std::vector seeds = findLocalMaximaInCluster(clsOnLayer[i]); + // sharing found seeds.size() sub-cluster seeds in cluster i + + std::vector> fractions; + // first pass can have noise it in + shareEnergy(clsOnLayer[i], seeds, fractions); + + // reset and run second pass after vetoing seeds + // that result in trivial clusters (less than 2 effective cells) + + for (unsigned isub = 0; isub < fractions.size(); ++isub) { + double effective_hits = 0.0; + double energy = calculateEnergyWithFraction(clsOnLayer[i], fractions[isub]); + Point position = calculatePositionWithFraction(clsOnLayer[i], fractions[isub]); + + for (unsigned ihit = 0; ihit < fractions[isub].size(); ++ihit) { + const double fraction = fractions[isub][ihit]; + if (fraction > 1e-7) { + effective_hits += fraction; + thisCluster.emplace_back(clsOnLayer[i][ihit].data.detid, fraction); + } + } + + if (verbosity_ < pINFO) { + std::cout << "\t******** NEW CLUSTER (SHARING) ********" << std::endl; + std::cout << "\tEff. No. of cells = " << effective_hits << std::endl; + std::cout << "\t Energy = " << energy << std::endl; + std::cout << "\t Phi = " << position.phi() << std::endl; + std::cout << "\t Eta = " << position.eta() << std::endl; + std::cout << "\t*****************************" << std::endl; + } + clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); + if (!clusters_v_.empty()) { + clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); + } + thisCluster.clear(); + } + } else { + position = calculatePosition(clsOnLayer[i]); // energy-weighted position + // std::vector< KDNode >::iterator it; + for (auto &it : clsOnLayer[i]) { + energy += it.data.weight; + thisCluster.emplace_back(it.data.detid, 1.f); + } + if (verbosity_ < pINFO) { + std::cout << "******** NEW CLUSTER (HGCIA) ********" << std::endl; + std::cout << "Index " << i << std::endl; + std::cout << "No. of cells = " << clsOnLayer[i].size() << std::endl; + std::cout << " Energy = " << energy << std::endl; + std::cout << " Phi = " << position.phi() << std::endl; + std::cout << " Eta = " << position.eta() << std::endl; + std::cout << "*****************************" << std::endl; + } + clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); + if (!clusters_v_.empty()) { + clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); + } + thisCluster.clear(); + } + } + } + return clusters_v_; +} + +math::XYZPoint HGCalCLUEAlgo::calculatePosition(std::vector &v) const { + float total_weight = 0.f; + float x = 0.f; + float y = 0.f; + + unsigned int v_size = v.size(); + unsigned int maxEnergyIndex = 0; + float maxEnergyValue = 0; + + // loop over hits in cluster candidate + // determining the maximum energy hit + for (unsigned int i = 0; i < v_size; i++) { + if (v[i].data.weight > maxEnergyValue) { + maxEnergyValue = v[i].data.weight; + maxEnergyIndex = i; + } + } + + // Si cell or Scintillator. Used to set approach and parameters + int thick = rhtools_.getSiThickIndex(v[maxEnergyIndex].data.detid); + + // for hits within positionDeltaRho_c_ from maximum energy hit + // build up weight for energy-weighted position + // and save corresponding hits indices + std::vector innerIndices; + for (unsigned int i = 0; i < v_size; i++) { + if (thick == -1 || distance2(v[i].data, v[maxEnergyIndex].data) < positionDeltaRho_c_[thick]) { + innerIndices.push_back(i); + + float rhEnergy = v[i].data.weight; + total_weight += rhEnergy; + // just fill x, y for scintillator + // for Si it is overwritten later anyway + if (thick == -1) { + x += v[i].data.x * rhEnergy; + y += v[i].data.y * rhEnergy; + } + } + } + // just loop on reduced vector of interesting indices + // to compute log weighting + if (thick != -1 && total_weight != 0.) { // Silicon case + float total_weight_log = 0.f; + float x_log = 0.f; + float y_log = 0.f; + for (auto idx : innerIndices) { + float rhEnergy = v[idx].data.weight; + if (rhEnergy == 0.) continue; + float Wi = std::max(thresholdW0_[thick] + log(rhEnergy / total_weight), 0.); + x_log += v[idx].data.x * Wi; + y_log += v[idx].data.y * Wi; + total_weight_log += Wi; + } + total_weight = total_weight_log; + x = x_log; + y = y_log; + } + + if (total_weight != 0.) { + auto inv_tot_weight = 1. / total_weight; + return math::XYZPoint(x * inv_tot_weight, y * inv_tot_weight, v[maxEnergyIndex].data.z); + } + return math::XYZPoint(0, 0, 0); +} + +double HGCalCLUEAlgo::calculateLocalDensity(std::vector &nd, KDTree &lp, + const unsigned int layer) const { + double maxdensity = 0.; + float delta_c; // maximum search distance (critical distance) for local + // density calculation + if (layer <= lastLayerEE) + delta_c = vecDeltas_[0]; + else if (layer <= lastLayerFH) + delta_c = vecDeltas_[1]; + else + delta_c = vecDeltas_[2]; + + // for each node calculate local density rho and store it + for (unsigned int i = 0; i < nd.size(); ++i) { + // speec up search by looking within +/- delta_c window only + KDTreeBox search_box(nd[i].dims[0] - delta_c, nd[i].dims[0] + delta_c, nd[i].dims[1] - delta_c, + nd[i].dims[1] + delta_c); + std::vector found; + lp.search(search_box, found); + const unsigned int found_size = found.size(); + for (unsigned int j = 0; j < found_size; j++) { + if (distance(nd[i].data, found[j].data) < delta_c) { + nd[i].data.rho += found[j].data.weight; + maxdensity = std::max(maxdensity, nd[i].data.rho); + } + } // end loop found + } // end loop nodes + return maxdensity; +} + +double HGCalCLUEAlgo::calculateDistanceToHigher(std::vector &nd) const { + // sort vector of Hexels by decreasing local density + std::vector rs = sorted_indices(nd); + + double maxdensity = 0.0; + int nearestHigher = -1; + + if (!rs.empty()) + maxdensity = nd[rs[0]].data.rho; + else + return maxdensity; // there are no hits + double dist2 = 0.; + // start by setting delta for the highest density hit to + // the most distant hit - this is a convention + + for (auto &j : nd) { + double tmp = distance2(nd[rs[0]].data, j.data); + if (tmp > dist2) dist2 = tmp; + } + nd[rs[0]].data.delta = std::sqrt(dist2); + nd[rs[0]].data.nearestHigher = nearestHigher; + + // now we save the largest distance as a starting point + const double max_dist2 = dist2; + const unsigned int nd_size = nd.size(); + + for (unsigned int oi = 1; oi < nd_size; ++oi) { // start from second-highest density + dist2 = max_dist2; + unsigned int i = rs[oi]; + // we only need to check up to oi since hits + // are ordered by decreasing density + // and all points coming BEFORE oi are guaranteed to have higher rho + // and the ones AFTER to have lower rho + for (unsigned int oj = 0; oj < oi; ++oj) { + unsigned int j = rs[oj]; + double tmp = distance2(nd[i].data, nd[j].data); + if (tmp <= dist2) { // this "<=" instead of "<" addresses the (rare) case + // when there are only two hits + dist2 = tmp; + nearestHigher = j; + } + } + nd[i].data.delta = std::sqrt(dist2); + nd[i].data.nearestHigher = nearestHigher; // this uses the original unsorted hitlist + } + return maxdensity; +} +int HGCalCLUEAlgo::findAndAssignClusters(std::vector &nd, KDTree &lp, double maxdensity, + KDTreeBox &bounds, const unsigned int layer, + std::vector> &clustersOnLayer) const { + // this is called once per layer and endcap... + // so when filling the cluster temporary vector of Hexels we resize each time + // by the number of clusters found. This is always equal to the number of + // cluster centers... + + unsigned int nClustersOnLayer = 0; + float delta_c; // critical distance + if (layer <= lastLayerEE) + delta_c = vecDeltas_[0]; + else if (layer <= lastLayerFH) + delta_c = vecDeltas_[1]; + else + delta_c = vecDeltas_[2]; + + std::vector rs = sorted_indices(nd); // indices sorted by decreasing rho + std::vector ds = sort_by_delta(nd); // sort in decreasing distance to higher + + const unsigned int nd_size = nd.size(); + for (unsigned int i = 0; i < nd_size; ++i) { + if (nd[ds[i]].data.delta < delta_c) break; // no more cluster centers to be looked at + if (dependSensor_) { + float rho_c = kappa_ * nd[ds[i]].data.sigmaNoise; + if (nd[ds[i]].data.rho < rho_c) continue; // set equal to kappa times noise threshold + + } else if (nd[ds[i]].data.rho * kappa_ < maxdensity) + continue; + + nd[ds[i]].data.clusterIndex = nClustersOnLayer; + if (verbosity_ < pINFO) { + std::cout << "Adding new cluster with index " << nClustersOnLayer << std::endl; + std::cout << "Cluster center is hit " << ds[i] << std::endl; + } + nClustersOnLayer++; + } + + // at this point nClustersOnLayer is equal to the number of cluster centers - + // if it is zero we are done + if (nClustersOnLayer == 0) return nClustersOnLayer; + + // assign remaining points to clusters, using the nearestHigher set from + // previous step (always set except + // for top density hit that is skipped...) + for (unsigned int oi = 1; oi < nd_size; ++oi) { + unsigned int i = rs[oi]; + int ci = nd[i].data.clusterIndex; + if (ci == -1 && nd[i].data.delta < 2. * delta_c) { + nd[i].data.clusterIndex = nd[nd[i].data.nearestHigher].data.clusterIndex; + } + } + + // make room in the temporary cluster vector for the additional clusterIndex + // clusters + // from this layer + if (verbosity_ < pINFO) { + std::cout << "resizing cluster vector by " << nClustersOnLayer << std::endl; + } + clustersOnLayer.resize(nClustersOnLayer); + + // Fill the cluster vector + for (unsigned int i = 0; i < nd_size; ++i) { + int ci = nd[i].data.clusterIndex; + if (ci != -1) { + clustersOnLayer[ci].push_back(nd[i]); + if (verbosity_ < pINFO) { + std::cout << "Pushing hit " << i << " into cluster with index " << ci << std::endl; + } + } + } + + // prepare the offset for the next layer if there is one + if (verbosity_ < pINFO) { + std::cout << "moving cluster offset by " << nClustersOnLayer << std::endl; + } + return nClustersOnLayer; +} + +// find local maxima within delta_c, marking the indices in the cluster +std::vector HGCalCLUEAlgo::findLocalMaximaInCluster(const std::vector &cluster) { + std::vector result; + std::vector seed(cluster.size(), true); + float delta_c = 2.; + + for (unsigned i = 0; i < cluster.size(); ++i) { + for (unsigned j = 0; j < cluster.size(); ++j) { + if (i != j and distance(cluster[i].data, cluster[j].data) < delta_c) { + if (cluster[i].data.weight < cluster[j].data.weight) { + seed[i] = false; + break; + } + } + } + } + + for (unsigned i = 0; i < cluster.size(); ++i) { + if (seed[i] && cluster[i].data.weight > 5e-4) { + // seed at i with energy cluster[i].weight + result.push_back(i); + } + } + + // Found result.size() sub-clusters in input cluster of length cluster.size() + + return result; +} + +math::XYZPoint HGCalCLUEAlgo::calculatePositionWithFraction(const std::vector &hits, + const std::vector &fractions) { + double norm(0.0), x(0.0), y(0.0), z(0.0); + for (unsigned i = 0; i < hits.size(); ++i) { + const double weight = fractions[i] * hits[i].data.weight; + norm += weight; + x += weight * hits[i].data.x; + y += weight * hits[i].data.y; + z += weight * hits[i].data.z; + } + math::XYZPoint result(x, y, z); + result /= norm; + return result; +} + +double HGCalCLUEAlgo::calculateEnergyWithFraction(const std::vector &hits, + const std::vector &fractions) { + double result = 0.0; + for (unsigned i = 0; i < hits.size(); ++i) { + result += fractions[i] * hits[i].data.weight; + } + return result; +} + +void HGCalCLUEAlgo::shareEnergy(const std::vector &incluster, + const std::vector &seeds, + std::vector> &outclusters) { + std::vector isaseed(incluster.size(), false); + outclusters.clear(); + outclusters.resize(seeds.size()); + std::vector centroids(seeds.size()); + std::vector energies(seeds.size()); + + if (seeds.size() == 1) { // short circuit the case of a lone cluster + outclusters[0].clear(); + outclusters[0].resize(incluster.size(), 1.0); + return; + } + + // saving seeds + + // create quick seed lookup + for (unsigned i = 0; i < seeds.size(); ++i) { + isaseed[seeds[i]] = true; + } + + // initialize clusters to be shared + // centroids start off at seed positions + // seeds always have fraction 1.0, to stabilize fit + // initializing fit + for (unsigned i = 0; i < seeds.size(); ++i) { + outclusters[i].resize(incluster.size(), 0.0); + for (unsigned j = 0; j < incluster.size(); ++j) { + if (j == seeds[i]) { + outclusters[i][j] = 1.0; + centroids[i] = + math::XYZPoint(incluster[j].data.x, incluster[j].data.y, incluster[j].data.z); + energies[i] = incluster[j].data.weight; + } + } + } + + // run the fit while we are less than max iterations, and clusters are still + // moving + const double minFracTot = 1e-20; + unsigned iter = 0; + const unsigned iterMax = 50; + double diff = std::numeric_limits::max(); + const double stoppingTolerance = 1e-8; + const auto numberOfSeeds = seeds.size(); + auto toleranceScaling = numberOfSeeds > 2 ? (numberOfSeeds - 1) * (numberOfSeeds - 1) : 1; + std::vector prevCentroids; + std::vector frac(numberOfSeeds), dist2(numberOfSeeds); + while (iter++ < iterMax && diff > stoppingTolerance * toleranceScaling) { + for (unsigned i = 0; i < incluster.size(); ++i) { + const Hexel &ihit = incluster[i].data; + double fracTot(0.0); + for (unsigned j = 0; j < numberOfSeeds; ++j) { + double fraction = 0.0; + double d2 = + (std::pow(ihit.x - centroids[j].x(), 2.0) + std::pow(ihit.y - centroids[j].y(), 2.0) + + std::pow(ihit.z - centroids[j].z(), 2.0)) / + sigma2_; + dist2[j] = d2; + // now we set the fractions up based on hit type + if (i == seeds[j]) { // this cluster's seed + fraction = 1.0; + } else if (isaseed[i]) { + fraction = 0.0; + } else { + fraction = energies[j] * std::exp(-0.5 * d2); + } + fracTot += fraction; + frac[j] = fraction; + } + // now that we have calculated all fractions for all hits + // assign the new fractions + for (unsigned j = 0; j < numberOfSeeds; ++j) { + if (fracTot > minFracTot || (i == seeds[j] && fracTot > 0.0)) { + outclusters[j][i] = frac[j] / fracTot; + } else { + outclusters[j][i] = 0.0; + } + } + } + + // save previous centroids + prevCentroids = std::move(centroids); + // finally update the position of the centroids from the last iteration + centroids.resize(numberOfSeeds); + double diff2 = 0.0; + for (unsigned i = 0; i < numberOfSeeds; ++i) { + centroids[i] = calculatePositionWithFraction(incluster, outclusters[i]); + energies[i] = calculateEnergyWithFraction(incluster, outclusters[i]); + // calculate convergence parameters + const double delta2 = (prevCentroids[i] - centroids[i]).perp2(); + diff2 = std::max(delta2, diff2); + } + // update convergance parameter outside loop + diff = std::sqrt(diff2); + } +} + +void HGCalCLUEAlgo::computeThreshold() { + // To support the TDR geometry and also the post-TDR one (v9 onwards), we + // need to change the logic of the vectors containing signal to noise and + // thresholds. The first 3 indices will keep on addressing the different + // thicknesses of the Silicon detectors, while the last one, number 3 (the + // fourth) will address the Scintillators. This change will support both + // geometries at the same time. + + if (initialized_) return; // only need to calculate thresholds once + + initialized_ = true; + + std::vector dummy; + const unsigned maxNumberOfThickIndices = 3; + dummy.resize(maxNumberOfThickIndices + 1, 0); // +1 to accomodate for the Scintillators + thresholds_.resize(maxlayer, dummy); + v_sigmaNoise_.resize(maxlayer, dummy); + + for (unsigned ilayer = 1; ilayer <= maxlayer; ++ilayer) { + for (unsigned ithick = 0; ithick < maxNumberOfThickIndices; ++ithick) { + float sigmaNoise = 0.001f * fcPerEle_ * nonAgedNoises_[ithick] * dEdXweights_[ilayer] / + (fcPerMip_[ithick] * thicknessCorrection_[ithick]); + thresholds_[ilayer - 1][ithick] = sigmaNoise * ecut_; + v_sigmaNoise_[ilayer - 1][ithick] = sigmaNoise; + } + float scintillators_sigmaNoise = 0.001f * noiseMip_ * dEdXweights_[ilayer]; + thresholds_[ilayer - 1][maxNumberOfThickIndices] = ecut_ * scintillators_sigmaNoise; + v_sigmaNoise_[ilayer - 1][maxNumberOfThickIndices] = scintillators_sigmaNoise; + } +} From 129dc755f18fda1de6c5ffd6a63a42b7c63ffcf6 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 7 Mar 2019 17:14:48 +0100 Subject: [PATCH 316/686] Remove sharing concept from CLUE --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 2 - .../HGCalRecAlgos/src/HGCalCLUEAlgo.cc | 182 ++---------------- 2 files changed, 20 insertions(+), 164 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h index cf52d1c68efc3..b4537f419e51e 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -278,8 +278,6 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { const std::vector &); double calculateEnergyWithFraction(const std::vector &, const std::vector &); // outputs - void shareEnergy(const std::vector &, const std::vector &, - std::vector > &); }; #endif diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc index 8ca7126192ef4..6c51fa4ad8d7f 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc @@ -70,7 +70,6 @@ void HGCalCLUEAlgo::populate(const HGCRecHitCollection &hits) { maxpos_[layer][0] = std::max((float)position.x(), maxpos_[layer][0]); maxpos_[layer][1] = std::max((float)position.y(), maxpos_[layer][1]); } - } // end loop hits } // Create a vector of Hexels associated to one cluster from a collection of @@ -102,77 +101,35 @@ void HGCalCLUEAlgo::makeClusters() { }); } -std::vector HGCalCLUEAlgo::getClusters(bool doSharing) { +std::vector HGCalCLUEAlgo::getClusters(bool) { reco::CaloID caloID = reco::CaloID::DET_HGCAL_ENDCAP; std::vector> thisCluster; for (auto &clsOnLayer : layerClustersPerLayer_) { for (unsigned int i = 0; i < clsOnLayer.size(); ++i) { double energy = 0; Point position; - // Will save the maximum density hit of the cluster size_t rsmax = max_index(clsOnLayer[i]); - - if (doSharing) { - std::vector seeds = findLocalMaximaInCluster(clsOnLayer[i]); - // sharing found seeds.size() sub-cluster seeds in cluster i - - std::vector> fractions; - // first pass can have noise it in - shareEnergy(clsOnLayer[i], seeds, fractions); - - // reset and run second pass after vetoing seeds - // that result in trivial clusters (less than 2 effective cells) - - for (unsigned isub = 0; isub < fractions.size(); ++isub) { - double effective_hits = 0.0; - double energy = calculateEnergyWithFraction(clsOnLayer[i], fractions[isub]); - Point position = calculatePositionWithFraction(clsOnLayer[i], fractions[isub]); - - for (unsigned ihit = 0; ihit < fractions[isub].size(); ++ihit) { - const double fraction = fractions[isub][ihit]; - if (fraction > 1e-7) { - effective_hits += fraction; - thisCluster.emplace_back(clsOnLayer[i][ihit].data.detid, fraction); - } - } - - if (verbosity_ < pINFO) { - std::cout << "\t******** NEW CLUSTER (SHARING) ********" << std::endl; - std::cout << "\tEff. No. of cells = " << effective_hits << std::endl; - std::cout << "\t Energy = " << energy << std::endl; - std::cout << "\t Phi = " << position.phi() << std::endl; - std::cout << "\t Eta = " << position.eta() << std::endl; - std::cout << "\t*****************************" << std::endl; - } - clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); - if (!clusters_v_.empty()) { - clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); - } - thisCluster.clear(); - } - } else { - position = calculatePosition(clsOnLayer[i]); // energy-weighted position - // std::vector< KDNode >::iterator it; - for (auto &it : clsOnLayer[i]) { - energy += it.data.weight; - thisCluster.emplace_back(it.data.detid, 1.f); - } - if (verbosity_ < pINFO) { - std::cout << "******** NEW CLUSTER (HGCIA) ********" << std::endl; - std::cout << "Index " << i << std::endl; - std::cout << "No. of cells = " << clsOnLayer[i].size() << std::endl; - std::cout << " Energy = " << energy << std::endl; - std::cout << " Phi = " << position.phi() << std::endl; - std::cout << " Eta = " << position.eta() << std::endl; - std::cout << "*****************************" << std::endl; - } - clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); - if (!clusters_v_.empty()) { - clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); - } - thisCluster.clear(); + position = calculatePosition(clsOnLayer[i]); // energy-weighted position + for (auto &it : clsOnLayer[i]) { + energy += it.data.weight; + thisCluster.emplace_back(it.data.detid, 1.f); } + if (verbosity_ < pINFO) { + LogDebug("HGCalCLUEAlgo") + << "******** NEW CLUSTER (HGCIA) ********" + << "Index " << i + << "No. of cells = " << clsOnLayer[i].size() + << " Energy = " << energy + << " Phi = " << position.phi() + << " Eta = " << position.eta() + << "*****************************" << std::endl; + } + clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); + if (!clusters_v_.empty()) { + clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); + } + thisCluster.clear(); } } return clusters_v_; @@ -452,105 +409,6 @@ double HGCalCLUEAlgo::calculateEnergyWithFraction(const std::vector &hit return result; } -void HGCalCLUEAlgo::shareEnergy(const std::vector &incluster, - const std::vector &seeds, - std::vector> &outclusters) { - std::vector isaseed(incluster.size(), false); - outclusters.clear(); - outclusters.resize(seeds.size()); - std::vector centroids(seeds.size()); - std::vector energies(seeds.size()); - - if (seeds.size() == 1) { // short circuit the case of a lone cluster - outclusters[0].clear(); - outclusters[0].resize(incluster.size(), 1.0); - return; - } - - // saving seeds - - // create quick seed lookup - for (unsigned i = 0; i < seeds.size(); ++i) { - isaseed[seeds[i]] = true; - } - - // initialize clusters to be shared - // centroids start off at seed positions - // seeds always have fraction 1.0, to stabilize fit - // initializing fit - for (unsigned i = 0; i < seeds.size(); ++i) { - outclusters[i].resize(incluster.size(), 0.0); - for (unsigned j = 0; j < incluster.size(); ++j) { - if (j == seeds[i]) { - outclusters[i][j] = 1.0; - centroids[i] = - math::XYZPoint(incluster[j].data.x, incluster[j].data.y, incluster[j].data.z); - energies[i] = incluster[j].data.weight; - } - } - } - - // run the fit while we are less than max iterations, and clusters are still - // moving - const double minFracTot = 1e-20; - unsigned iter = 0; - const unsigned iterMax = 50; - double diff = std::numeric_limits::max(); - const double stoppingTolerance = 1e-8; - const auto numberOfSeeds = seeds.size(); - auto toleranceScaling = numberOfSeeds > 2 ? (numberOfSeeds - 1) * (numberOfSeeds - 1) : 1; - std::vector prevCentroids; - std::vector frac(numberOfSeeds), dist2(numberOfSeeds); - while (iter++ < iterMax && diff > stoppingTolerance * toleranceScaling) { - for (unsigned i = 0; i < incluster.size(); ++i) { - const Hexel &ihit = incluster[i].data; - double fracTot(0.0); - for (unsigned j = 0; j < numberOfSeeds; ++j) { - double fraction = 0.0; - double d2 = - (std::pow(ihit.x - centroids[j].x(), 2.0) + std::pow(ihit.y - centroids[j].y(), 2.0) + - std::pow(ihit.z - centroids[j].z(), 2.0)) / - sigma2_; - dist2[j] = d2; - // now we set the fractions up based on hit type - if (i == seeds[j]) { // this cluster's seed - fraction = 1.0; - } else if (isaseed[i]) { - fraction = 0.0; - } else { - fraction = energies[j] * std::exp(-0.5 * d2); - } - fracTot += fraction; - frac[j] = fraction; - } - // now that we have calculated all fractions for all hits - // assign the new fractions - for (unsigned j = 0; j < numberOfSeeds; ++j) { - if (fracTot > minFracTot || (i == seeds[j] && fracTot > 0.0)) { - outclusters[j][i] = frac[j] / fracTot; - } else { - outclusters[j][i] = 0.0; - } - } - } - - // save previous centroids - prevCentroids = std::move(centroids); - // finally update the position of the centroids from the last iteration - centroids.resize(numberOfSeeds); - double diff2 = 0.0; - for (unsigned i = 0; i < numberOfSeeds; ++i) { - centroids[i] = calculatePositionWithFraction(incluster, outclusters[i]); - energies[i] = calculateEnergyWithFraction(incluster, outclusters[i]); - // calculate convergence parameters - const double delta2 = (prevCentroids[i] - centroids[i]).perp2(); - diff2 = std::max(delta2, diff2); - } - // update convergance parameter outside loop - diff = std::sqrt(diff2); - } -} - void HGCalCLUEAlgo::computeThreshold() { // To support the TDR geometry and also the post-TDR one (v9 onwards), we // need to change the logic of the vectors containing signal to noise and From 01416e509f78196fb4fa20ebc98b619e960a04e9 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 7 Mar 2019 17:24:18 +0100 Subject: [PATCH 317/686] Remove cout --- RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc index 6c51fa4ad8d7f..d11971801fbc5 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc @@ -309,8 +309,9 @@ int HGCalCLUEAlgo::findAndAssignClusters(std::vector &nd, KDTree &lp, do nd[ds[i]].data.clusterIndex = nClustersOnLayer; if (verbosity_ < pINFO) { - std::cout << "Adding new cluster with index " << nClustersOnLayer << std::endl; - std::cout << "Cluster center is hit " << ds[i] << std::endl; + LogDebug("HGCalCLUEAlgo") + << "Adding new cluster with index " << nClustersOnLayer + << "Cluster center is hit " << ds[i] << std::endl; } nClustersOnLayer++; } @@ -334,7 +335,8 @@ int HGCalCLUEAlgo::findAndAssignClusters(std::vector &nd, KDTree &lp, do // clusters // from this layer if (verbosity_ < pINFO) { - std::cout << "resizing cluster vector by " << nClustersOnLayer << std::endl; + LogDebug("HGCalCLUEAlgo") + << "resizing cluster vector by " << nClustersOnLayer << std::endl; } clustersOnLayer.resize(nClustersOnLayer); @@ -344,14 +346,15 @@ int HGCalCLUEAlgo::findAndAssignClusters(std::vector &nd, KDTree &lp, do if (ci != -1) { clustersOnLayer[ci].push_back(nd[i]); if (verbosity_ < pINFO) { - std::cout << "Pushing hit " << i << " into cluster with index " << ci << std::endl; + LogDebug("HGCalCLUEAlgo") + << "Pushing hit " << i << " into cluster with index " << ci << std::endl; } } } // prepare the offset for the next layer if there is one if (verbosity_ < pINFO) { - std::cout << "moving cluster offset by " << nClustersOnLayer << std::endl; + LogDebug("HGCalCLUEAlgo") << "moving cluster offset by " << nClustersOnLayer << std::endl; } return nClustersOnLayer; } From 495f24ab12c82364ddf2ab4b94737c7150c6eb9a Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 7 Mar 2019 18:02:37 +0100 Subject: [PATCH 318/686] Remove unused options and code --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 40 -------------- .../HGCalRecAlgos/src/HGCalCLUEAlgo.cc | 54 +------------------ 2 files changed, 1 insertion(+), 93 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h index b4537f419e51e..1b1bfa4041c04 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -61,7 +61,6 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { vecDeltas_(), kappa_(1.), ecut_(0.), - sigma2_(1.0), initialized_(false) {} HGCalCLUEAlgo(const std::vector &thresholdW0_in, @@ -79,35 +78,6 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { vecDeltas_(vecDeltas_in), kappa_(kappa_in), ecut_(ecut_in), - sigma2_(1.0), - dependSensor_(dependSensor_in), - dEdXweights_(dEdXweights_in), - thicknessCorrection_(thicknessCorrection_in), - fcPerMip_(fcPerMip_in), - fcPerEle_(fcPerEle_in), - nonAgedNoises_(nonAgedNoises_in), - noiseMip_(noiseMip_in), - initialized_(false), - points_(2 * (maxlayer + 1)), - minpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}), - maxpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}) {} - - HGCalCLUEAlgo(const std::vector &thresholdW0_in, - const std::vector &positionDeltaRho_c_in, - const std::vector &vecDeltas_in, double kappa_in, double ecut_in, - double showerSigma, reco::CaloCluster::AlgoId algoId_in, bool dependSensor_in, - const std::vector &dEdXweights_in, - const std::vector &thicknessCorrection_in, - const std::vector &fcPerMip_in, double fcPerEle_in, - const std::vector &nonAgedNoises_in, double noiseMip_in, - VerbosityLevel the_verbosity = pERROR) - : HGCalClusteringAlgoBase(the_verbosity, algoId_in), - thresholdW0_(thresholdW0_in), - positionDeltaRho_c_(positionDeltaRho_c_in), - vecDeltas_(vecDeltas_in), - kappa_(kappa_in), - ecut_(ecut_in), - sigma2_(std::pow(showerSigma, 2.0)), dependSensor_(dependSensor_in), dEdXweights_(dEdXweights_in), thicknessCorrection_(thicknessCorrection_in), @@ -164,9 +134,6 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { // The hit energy cutoff double ecut_; - // for energy sharing - double sigma2_; // transverse shower size - // various parameters used for calculating the noise levels for a given sensor (and whether to use // them) bool dependSensor_; @@ -271,13 +238,6 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { int findAndAssignClusters(std::vector &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector > &) const; math::XYZPoint calculatePosition(std::vector &) const; - - // attempt to find subclusters within a given set of hexels - std::vector findLocalMaximaInCluster(const std::vector &); - math::XYZPoint calculatePositionWithFraction(const std::vector &, - const std::vector &); - double calculateEnergyWithFraction(const std::vector &, const std::vector &); - // outputs }; #endif diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc index d11971801fbc5..d9b88bec02577 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc @@ -72,6 +72,7 @@ void HGCalCLUEAlgo::populate(const HGCRecHitCollection &hits) { } } // end loop hits } + // Create a vector of Hexels associated to one cluster from a collection of // HGCalRecHits - this can be used directly to make the final cluster list - // this method can be invoked multiple times for the same event with different @@ -359,59 +360,6 @@ int HGCalCLUEAlgo::findAndAssignClusters(std::vector &nd, KDTree &lp, do return nClustersOnLayer; } -// find local maxima within delta_c, marking the indices in the cluster -std::vector HGCalCLUEAlgo::findLocalMaximaInCluster(const std::vector &cluster) { - std::vector result; - std::vector seed(cluster.size(), true); - float delta_c = 2.; - - for (unsigned i = 0; i < cluster.size(); ++i) { - for (unsigned j = 0; j < cluster.size(); ++j) { - if (i != j and distance(cluster[i].data, cluster[j].data) < delta_c) { - if (cluster[i].data.weight < cluster[j].data.weight) { - seed[i] = false; - break; - } - } - } - } - - for (unsigned i = 0; i < cluster.size(); ++i) { - if (seed[i] && cluster[i].data.weight > 5e-4) { - // seed at i with energy cluster[i].weight - result.push_back(i); - } - } - - // Found result.size() sub-clusters in input cluster of length cluster.size() - - return result; -} - -math::XYZPoint HGCalCLUEAlgo::calculatePositionWithFraction(const std::vector &hits, - const std::vector &fractions) { - double norm(0.0), x(0.0), y(0.0), z(0.0); - for (unsigned i = 0; i < hits.size(); ++i) { - const double weight = fractions[i] * hits[i].data.weight; - norm += weight; - x += weight * hits[i].data.x; - y += weight * hits[i].data.y; - z += weight * hits[i].data.z; - } - math::XYZPoint result(x, y, z); - result /= norm; - return result; -} - -double HGCalCLUEAlgo::calculateEnergyWithFraction(const std::vector &hits, - const std::vector &fractions) { - double result = 0.0; - for (unsigned i = 0; i < hits.size(); ++i) { - result += fractions[i] * hits[i].data.weight; - } - return result; -} - void HGCalCLUEAlgo::computeThreshold() { // To support the TDR geometry and also the post-TDR one (v9 onwards), we // need to change the logic of the vectors containing signal to noise and From 81dc974079b29c1631a820fd6e7faadfd3042e6e Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 09:49:30 +0100 Subject: [PATCH 319/686] Move LayerClustersAlgo to be Plugins --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 36 +++++------------- .../interface/HGCalClusteringAlgoBase.h | 30 +++++++++++++++ .../interface/HGCalImagingAlgo.h | 37 +++++-------------- .../interface/HGCalLayerClusterAlgoFactory.h | 12 ++++++ .../HGCalRecAlgos/src/HGCalImagingAlgo.cc | 5 ++- .../src/HGCalLayerClusterPluginFactory.cc | 10 +++++ .../plugins/HGCalLayerClusterProducer.cc | 3 ++ 7 files changed, 77 insertions(+), 56 deletions(-) create mode 100644 RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h create mode 100644 RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h index 1b1bfa4041c04..f6c583a03c33e 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -3,6 +3,8 @@ #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" @@ -19,39 +21,12 @@ #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" // C/C++ headers -#include #include #include #include #include "KDTreeLinkerAlgoT.h" -template -std::vector sorted_indices(const std::vector &v) { - // initialize original index locations - std::vector idx(v.size()); - std::iota(std::begin(idx), std::end(idx), 0); - - // sort indices based on comparing values in v - std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] > v[i2]; }); - - return idx; -} - -template -size_t max_index(const std::vector &v) { - // initialize original index locations - std::vector idx(v.size(), 0); - std::iota(std::begin(idx), std::end(idx), 0); - - // take the max index based on comparing values in v - auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { - return v[i1].data.rho < v[i2].data.rho; - }); - - return (*maxidx); -} - class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { public: HGCalCLUEAlgo() @@ -63,6 +38,9 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { ecut_(0.), initialized_(false) {} + HGCalCLUEAlgo(const edm::ParameterSet&) + : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined) {} + HGCalCLUEAlgo(const std::vector &thresholdW0_in, const std::vector &positionDeltaRho_c_in, const std::vector &vecDeltas_in, double kappa_in, double ecut_in, @@ -119,6 +97,10 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { } void computeThreshold(); + static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { + iDesc.add("value",5); + } + /// point in the space typedef math::XYZPoint Point; diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h index 8d0ec1d16030a..9138c347c2a53 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h @@ -11,6 +11,36 @@ // C/C++ headers #include +#include + +template +std::vector sorted_indices(const std::vector &v) { + + // initialize original index locations + std::vector idx(v.size()); + std::iota (std::begin(idx), std::end(idx), 0); + + // sort indices based on comparing values in v + std::sort(idx.begin(), idx.end(), + [&v](size_t i1, size_t i2) { + return v[i1] > v[i2]; + }); + + return idx; +} + +template +size_t max_index(const std::vector &v) { + + // initialize original index locations + std::vector idx(v.size(),0); + std::iota (std::begin(idx), std::end(idx), 0); + + // take the max index based on comparing values in v + auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1].data.rho < v[i2].data.rho;}); + + return (*maxidx); +} class HGCalClusteringAlgoBase { diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h index 8c2ec6aa8cd99..479f689715b72 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h @@ -3,6 +3,8 @@ #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" #include "Geometry/CaloTopology/interface/HGCalTopology.h" #include "DataFormats/DetId/interface/DetId.h" @@ -29,34 +31,6 @@ //Density collection typedef std::map< DetId, float > Density; -template -std::vector sorted_indices(const std::vector &v) { - - // initialize original index locations - std::vector idx(v.size()); - std::iota (std::begin(idx), std::end(idx), 0); - - // sort indices based on comparing values in v - std::sort(idx.begin(), idx.end(), - [&v](size_t i1, size_t i2) { - return v[i1] > v[i2]; - }); - - return idx; -} - -template -size_t max_index(const std::vector &v) { - - // initialize original index locations - std::vector idx(v.size(),0); - std::iota (std::begin(idx), std::end(idx), 0); - - // take the max index based on comparing values in v - auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1].data.rho < v[i2].data.rho;}); - - return (*maxidx); -} class HGCalImagingAlgo : public HGCalClusteringAlgoBase { @@ -70,6 +44,9 @@ class HGCalImagingAlgo : public HGCalClusteringAlgoBase initialized_(false) { } + HGCalImagingAlgo(const edm::ParameterSet&) + : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined) {} + HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& positionDeltaRho_c_in, const std::vector& vecDeltas_in, double kappa_in, double ecut_in, reco::CaloCluster::AlgoId algoId_in, @@ -169,6 +146,10 @@ void computeThreshold(); //getDensity Density getDensity(); +static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { + iDesc.add("value",5); +} + /// point in the space typedef math::XYZPoint Point; diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h new file mode 100644 index 0000000000000..7ae6f3407f064 --- /dev/null +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h @@ -0,0 +1,12 @@ +#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalLayerClusterAlgoFactory_H +#define RecoLocalCalo_HGCalRecAlgos_HGCalLayerClusterAlgoFactory_H + + +#include "FWCore/PluginManager/interface/PluginFactory.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" + +typedef edmplugin::PluginFactory< HGCalClusteringAlgoBase * (const edm::ParameterSet&) > HGCalLayerClusterAlgoFactory; + +#endif + diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc index 18198771ef1f7..cbbab742d641a 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc @@ -117,7 +117,7 @@ std::vector HGCalImagingAlgo::getClusters(bool doSharing) { for (unsigned int i = 0; i < clsOnLayer.size(); ++i) { double energy = 0; Point position; - + //Will save the maximum density hit of the cluster size_t rsmax = max_index(clsOnLayer[i]); @@ -332,6 +332,9 @@ HGCalImagingAlgo::calculateDistanceToHigher(std::vector &nd) const { // and the ones AFTER to have lower rho for (unsigned int oj = 0; oj < oi; ++oj) { unsigned int j = rs[oj]; + // Limit the search box + if ((nd[i].data.x - nd[j].data.x)*(nd[i].data.x - nd[j].data.x) > dist2) continue; + if ((nd[i].data.y - nd[j].data.y)*(nd[i].data.y - nd[j].data.y) > dist2) continue; double tmp = distance2(nd[i].data, nd[j].data); if (tmp <= dist2) { // this "<=" instead of "<" addresses the (rare) case // when there are only two hits diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc new file mode 100644 index 0000000000000..aa1a8fe6a8106 --- /dev/null +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc @@ -0,0 +1,10 @@ +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h" +#include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h" +#include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h" + +EDM_REGISTER_VALIDATED_PLUGINFACTORY(HGCalLayerClusterAlgoFactory, "HGCalLayerClusterAlgoFactory"); +DEFINE_EDM_VALIDATED_PLUGIN(HGCalLayerClusterAlgoFactory, HGCalImagingAlgo, "Imaging"); +DEFINE_EDM_VALIDATED_PLUGIN(HGCalLayerClusterAlgoFactory, HGCalCLUEAlgo, "CLUE"); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index 5938c252be615..6382106b363f0 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -119,6 +119,9 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps void HGCalLayerClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { // hgcalLayerClusters edm::ParameterSetDescription desc; +// edm::ParameterSetDescription pluginDesc; +// pluginDesc.addNode(edm::PluginDescription(“typeâ€, true)); + desc.add("detector", "all"); desc.add("doSharing", false); desc.add>("thresholdW0", { From e9dfb57d5d1c7e93c1baf9915f05e447af73ea24 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 11:05:31 +0100 Subject: [PATCH 320/686] Move parameters to the plugin --- .../interface/HGCalImagingAlgo.h | 38 ++++++++++- .../plugins/HGCalLayerClusterProducer.cc | 68 ++++++------------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h index 479f689715b72..b8f4c210209e1 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h @@ -147,7 +147,43 @@ void computeThreshold(); Density getDensity(); static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { - iDesc.add("value",5); + iDesc.add("value",5); + iDesc.add("detector", "all"); + iDesc.add("doSharing", false); + iDesc.add>("thresholdW0", { + 2.9, + 2.9, + 2.9 + }); + iDesc.add>("positionDeltaRho_c", { + 1.3, + 1.3, + 1.3 + }); + iDesc.add>("deltac", { + 2.0, + 2.0, + 5.0, + }); + iDesc.add("dependSensor", true); + iDesc.add("ecut", 3.0); + iDesc.add("kappa", 9.0); + iDesc.add("timeClname", "timeLayerCluster"); + iDesc.add("timeOffset",0.0); + iDesc.addUntracked("verbosity", 3); + iDesc.add("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits")); + iDesc.add("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits")); + iDesc.add("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits")); + iDesc.add>("dEdXweights",{}); + iDesc.add>("thicknessCorrection",{}); + iDesc.add>("fcPerMip",{}); + iDesc.add("fcPerEle",0.0); + edm::ParameterSetDescription descNestedNoises; + descNestedNoises.add >("values", {}); + iDesc.add("noises", descNestedNoises); + edm::ParameterSetDescription descNestedNoiseMIP; + descNestedNoiseMIP.add("value", 0 ); + iDesc.add("noiseMip", descNestedNoiseMIP); } /// point in the space diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index 6382106b363f0..e1400c3e80a23 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -7,9 +7,11 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/PluginDescription.h" #include "RecoParticleFlow/PFClusterProducer/interface/RecHitTopologicalCleanerBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h" @@ -17,16 +19,16 @@ #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h" +#include "RecoParticleFlow/PFClusterProducer/plugins/SimMappers/ComputeClusterTime.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalDepthPreClusterer.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "RecoParticleFlow/PFClusterProducer/plugins/SimMappers/ComputeClusterTime.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -96,14 +98,17 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps } - if(doSharing){ - double showerSigma = ps.getParameter("showerSigma"); - algo = std::make_unique(thresholdW0, positionDeltaRho_c, - vecDeltas, kappa, ecut, showerSigma, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); - }else{ - algo = std::make_unique(thresholdW0, positionDeltaRho_c, - vecDeltas, kappa, ecut, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); - } + auto pluginPSet = ps.getParameter("plugin"); + algo.reset(HGCalLayerClusterAlgoFactory::get()->create(pluginPSet.getParameter("type"), pluginPSet)); + +// if(doSharing){ +// double showerSigma = ps.getParameter("showerSigma"); +// algo = std::make_unique(thresholdW0, positionDeltaRho_c, +// vecDeltas, kappa, ecut, showerSigma, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); +// }else{ +// algo = std::make_unique(thresholdW0, positionDeltaRho_c, +// vecDeltas, kappa, ecut, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); +// } produces >(); @@ -119,45 +124,10 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps void HGCalLayerClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { // hgcalLayerClusters edm::ParameterSetDescription desc; -// edm::ParameterSetDescription pluginDesc; -// pluginDesc.addNode(edm::PluginDescription(“typeâ€, true)); - - desc.add("detector", "all"); - desc.add("doSharing", false); - desc.add>("thresholdW0", { - 2.9, - 2.9, - 2.9 - }); - desc.add>("positionDeltaRho_c", { - 1.3, - 1.3, - 1.3 - }); - desc.add>("deltac", { - 2.0, - 2.0, - 5.0, - }); - desc.add("dependSensor", true); - desc.add("ecut", 3.0); - desc.add("kappa", 9.0); - desc.add("timeClname", "timeLayerCluster"); - desc.add("timeOffset",0.0); - desc.addUntracked("verbosity", 3); - desc.add("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits")); - desc.add("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits")); - desc.add("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits")); - desc.add>("dEdXweights",{}); - desc.add>("thicknessCorrection",{}); - desc.add>("fcPerMip",{}); - desc.add("fcPerEle",0.0); - edm::ParameterSetDescription descNestedNoises; - descNestedNoises.add >("values", {}); - desc.add("noises", descNestedNoises); - edm::ParameterSetDescription descNestedNoiseMIP; - descNestedNoiseMIP.add("value", 0 ); - desc.add("noiseMip", descNestedNoiseMIP); + edm::ParameterSetDescription pluginDesc; + pluginDesc.addNode(edm::PluginDescription("type", "Imaging", true)); + + desc.add("plugin", pluginDesc); descriptions.add("hgcalLayerClusters", desc); } From ab07dfe8f6978b45c72df59cbc24b3220843b7b7 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 12:19:20 +0100 Subject: [PATCH 321/686] Move parameters to plugin algo --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 59 ++++------ .../interface/HGCalClusteringAlgoBase.h | 1 + .../interface/HGCalImagingAlgo.h | 107 ++++-------------- .../plugins/HGCalLayerClusterProducer.cc | 38 ++----- 4 files changed, 52 insertions(+), 153 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h index f6c583a03c33e..e643316b3126c 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -29,44 +29,27 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { public: - HGCalCLUEAlgo() - : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined), - thresholdW0_(), - positionDeltaRho_c_(), - vecDeltas_(), - kappa_(1.), - ecut_(0.), - initialized_(false) {} - - HGCalCLUEAlgo(const edm::ParameterSet&) - : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined) {} - - HGCalCLUEAlgo(const std::vector &thresholdW0_in, - const std::vector &positionDeltaRho_c_in, - const std::vector &vecDeltas_in, double kappa_in, double ecut_in, - reco::CaloCluster::AlgoId algoId_in, bool dependSensor_in, - const std::vector &dEdXweights_in, - const std::vector &thicknessCorrection_in, - const std::vector &fcPerMip_in, double fcPerEle_in, - const std::vector &nonAgedNoises_in, double noiseMip_in, - VerbosityLevel the_verbosity = pERROR) - : HGCalClusteringAlgoBase(the_verbosity, algoId_in), - thresholdW0_(thresholdW0_in), - positionDeltaRho_c_(positionDeltaRho_c_in), - vecDeltas_(vecDeltas_in), - kappa_(kappa_in), - ecut_(ecut_in), - dependSensor_(dependSensor_in), - dEdXweights_(dEdXweights_in), - thicknessCorrection_(thicknessCorrection_in), - fcPerMip_(fcPerMip_in), - fcPerEle_(fcPerEle_in), - nonAgedNoises_(nonAgedNoises_in), - noiseMip_(noiseMip_in), - initialized_(false), - points_(2 * (maxlayer + 1)), - minpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}), - maxpos_(2 * (maxlayer + 1), {{0.0f, 0.0f}}) {} + + HGCalCLUEAlgo(const edm::ParameterSet& ps) + : HGCalClusteringAlgoBase( + (HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter("verbosity",3), + reco::CaloCluster::undefined), + thresholdW0_(ps.getParameter >("thresholdW0")), + positionDeltaRho_c_(ps.getParameter >("positionDeltaRho_c")), + vecDeltas_(ps.getParameter >("deltac")), + kappa_(ps.getParameter("kappa")), + ecut_(ps.getParameter("ecut")), + dependSensor_(ps.getParameter("dependSensor")), + dEdXweights_(ps.getParameter >("dEdXweights")), + thicknessCorrection_(ps.getParameter >("thicknessCorrection")), + fcPerMip_(ps.getParameter >("fcPerMip")), + fcPerEle_(ps.getParameter("fcPerEle")), + nonAgedNoises_(ps.getParameter("noises").getParameter >("values")), + noiseMip_(ps.getParameter("noiseMip").getParameter("value")), + initialized_(false), + points_(2*(maxlayer+1)), + minpos_(2*(maxlayer+1),{ {0.0f,0.0f} }), + maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) {} virtual ~HGCalCLUEAlgo() {} diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h index 9138c347c2a53..50e472023f77e 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h @@ -65,6 +65,7 @@ enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; inline void setVerbosity(VerbosityLevel the_verbosity) { verbosity_ = the_verbosity; } + inline void setAlgoId(reco::CaloCluster::AlgoId algo) {algoId_ = algo;} //max number of layers static const unsigned int maxlayer = 52; diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h index b8f4c210209e1..e61015af6f094 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h @@ -24,7 +24,6 @@ #include #include #include -#include #include "KDTreeLinkerAlgoT.h" @@ -36,83 +35,27 @@ class HGCalImagingAlgo : public HGCalClusteringAlgoBase { public: - - HGCalImagingAlgo() : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined), - thresholdW0_(), positionDeltaRho_c_(), - vecDeltas_(), kappa_(1.), ecut_(0.), - sigma2_(1.0), - initialized_(false) { -} - - HGCalImagingAlgo(const edm::ParameterSet&) - : HGCalClusteringAlgoBase(pERROR, reco::CaloCluster::undefined) {} - - HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& positionDeltaRho_c_in, - const std::vector& vecDeltas_in, double kappa_in, double ecut_in, - reco::CaloCluster::AlgoId algoId_in, - bool dependSensor_in, - const std::vector& dEdXweights_in, - const std::vector& thicknessCorrection_in, - const std::vector& fcPerMip_in, - double fcPerEle_in, - const std::vector& nonAgedNoises_in, - double noiseMip_in, - VerbosityLevel the_verbosity = pERROR) : - HGCalClusteringAlgoBase(the_verbosity, algoId_in), - thresholdW0_(thresholdW0_in), - positionDeltaRho_c_(positionDeltaRho_c_in), - vecDeltas_(vecDeltas_in), kappa_(kappa_in), - ecut_(ecut_in), - sigma2_(1.0), - dependSensor_(dependSensor_in), - dEdXweights_(dEdXweights_in), - thicknessCorrection_(thicknessCorrection_in), - fcPerMip_(fcPerMip_in), - fcPerEle_(fcPerEle_in), - nonAgedNoises_(nonAgedNoises_in), - noiseMip_(noiseMip_in), - initialized_(false), - points_(2*(maxlayer+1)), - minpos_(2*(maxlayer+1),{ - {0.0f,0.0f} - }), - maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) -{ -} - -HGCalImagingAlgo(const std::vector& thresholdW0_in, const std::vector& positionDeltaRho_c_in, - const std::vector& vecDeltas_in, double kappa_in, double ecut_in, - double showerSigma, - reco::CaloCluster::AlgoId algoId_in, - bool dependSensor_in, - const std::vector& dEdXweights_in, - const std::vector& thicknessCorrection_in, - const std::vector& fcPerMip_in, - double fcPerEle_in, - const std::vector& nonAgedNoises_in, - double noiseMip_in, - VerbosityLevel the_verbosity = pERROR) : - HGCalClusteringAlgoBase(the_verbosity, algoId_in), - thresholdW0_(thresholdW0_in), - positionDeltaRho_c_(positionDeltaRho_c_in), - vecDeltas_(vecDeltas_in), kappa_(kappa_in), - ecut_(ecut_in), - sigma2_(std::pow(showerSigma,2.0)), - dependSensor_(dependSensor_in), - dEdXweights_(dEdXweights_in), - thicknessCorrection_(thicknessCorrection_in), - fcPerMip_(fcPerMip_in), - fcPerEle_(fcPerEle_in), - nonAgedNoises_(nonAgedNoises_in), - noiseMip_(noiseMip_in), - initialized_(false), - points_(2*(maxlayer+1)), - minpos_(2*(maxlayer+1),{ - {0.0f,0.0f} - }), - maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) -{ -} + HGCalImagingAlgo(const edm::ParameterSet& ps) + : HGCalClusteringAlgoBase( + (HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter("verbosity",3), + reco::CaloCluster::undefined), + thresholdW0_(ps.getParameter >("thresholdW0")), + positionDeltaRho_c_(ps.getParameter >("positionDeltaRho_c")), + vecDeltas_(ps.getParameter >("deltac")), + kappa_(ps.getParameter("kappa")), + ecut_(ps.getParameter("ecut")), + sigma2_(1.0), + dependSensor_(ps.getParameter("dependSensor")), + dEdXweights_(ps.getParameter >("dEdXweights")), + thicknessCorrection_(ps.getParameter >("thicknessCorrection")), + fcPerMip_(ps.getParameter >("fcPerMip")), + fcPerEle_(ps.getParameter("fcPerEle")), + nonAgedNoises_(ps.getParameter("noises").getParameter >("values")), + noiseMip_(ps.getParameter("noiseMip").getParameter("value")), + initialized_(false), + points_(2*(maxlayer+1)), + minpos_(2*(maxlayer+1),{ {0.0f,0.0f} }), + maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) {} virtual ~HGCalImagingAlgo() {} @@ -147,9 +90,6 @@ void computeThreshold(); Density getDensity(); static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { - iDesc.add("value",5); - iDesc.add("detector", "all"); - iDesc.add("doSharing", false); iDesc.add>("thresholdW0", { 2.9, 2.9, @@ -168,12 +108,7 @@ static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add("dependSensor", true); iDesc.add("ecut", 3.0); iDesc.add("kappa", 9.0); - iDesc.add("timeClname", "timeLayerCluster"); - iDesc.add("timeOffset",0.0); iDesc.addUntracked("verbosity", 3); - iDesc.add("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits")); - iDesc.add("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits")); - iDesc.add("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits")); iDesc.add>("dEdXweights",{}); iDesc.add>("thicknessCorrection",{}); iDesc.add>("fcPerMip",{}); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index e1400c3e80a23..18bc587ec9ec8 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -54,8 +54,6 @@ class HGCalLayerClusterProducer : public edm::stream::EDProducer<> { std::string timeClname; double timeOffset; - - HGCalImagingAlgo::VerbosityLevel verbosity; }; DEFINE_FWK_MODULE(HGCalLayerClusterProducer); @@ -65,21 +63,7 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps doSharing(ps.getParameter("doSharing")), detector(ps.getParameter("detector")), // one of EE, FH, BH or "all" timeClname(ps.getParameter("timeClname")), - timeOffset(ps.getParameter("timeOffset")), - verbosity((HGCalImagingAlgo::VerbosityLevel)ps.getUntrackedParameter("verbosity",3)){ - double ecut = ps.getParameter("ecut"); - std::vector thresholdW0 = ps.getParameter >("thresholdW0"); - std::vector positionDeltaRho_c = ps.getParameter >("positionDeltaRho_c"); - std::vector vecDeltas = ps.getParameter >("deltac"); - double kappa = ps.getParameter("kappa"); - std::vector dEdXweights = ps.getParameter >("dEdXweights"); - std::vector thicknessCorrection = ps.getParameter >("thicknessCorrection"); - std::vector fcPerMip = ps.getParameter >("fcPerMip"); - double fcPerEle = ps.getParameter("fcPerEle"); - std::vector nonAgedNoises = ps.getParameter("noises").getParameter >("values"); - double noiseMip = ps.getParameter("noiseMip").getParameter("value"); - bool dependSensor = ps.getParameter("dependSensor"); - + timeOffset(ps.getParameter("timeOffset")) { if(detector=="all") { hits_ee_token = consumes(ps.getParameter("HGCEEInput")); @@ -100,16 +84,7 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps auto pluginPSet = ps.getParameter("plugin"); algo.reset(HGCalLayerClusterAlgoFactory::get()->create(pluginPSet.getParameter("type"), pluginPSet)); - -// if(doSharing){ -// double showerSigma = ps.getParameter("showerSigma"); -// algo = std::make_unique(thresholdW0, positionDeltaRho_c, -// vecDeltas, kappa, ecut, showerSigma, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); -// }else{ -// algo = std::make_unique(thresholdW0, positionDeltaRho_c, -// vecDeltas, kappa, ecut, algoId, dependSensor, dEdXweights, thicknessCorrection, fcPerMip, fcPerEle, nonAgedNoises, noiseMip, verbosity); -// } - + algo->setAlgoId(algoId); produces >(); produces >("sharing"); @@ -128,11 +103,16 @@ void HGCalLayerClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& pluginDesc.addNode(edm::PluginDescription("type", "Imaging", true)); desc.add("plugin", pluginDesc); + desc.add("detector", "all"); + desc.add("doSharing", false); + desc.add("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits")); + desc.add("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits")); + desc.add("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits")); + desc.add("timeClname", "timeLayerCluster"); + desc.add("timeOffset", 0.0); descriptions.add("hgcalLayerClusters", desc); - } - void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) { From ca92a6def12bf24070571ac8cc304bb00b13c7b6 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 12:24:28 +0100 Subject: [PATCH 322/686] Update PSet for CLUE algorithm --- .../HGCalRecAlgos/interface/HGCalCLUEAlgo.h | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h index e643316b3126c..9121c3ee0a6d1 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h @@ -81,7 +81,35 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { void computeThreshold(); static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { - iDesc.add("value",5); + iDesc.add>("thresholdW0", { + 2.9, + 2.9, + 2.9 + }); + iDesc.add>("positionDeltaRho_c", { + 1.3, + 1.3, + 1.3 + }); + iDesc.add>("deltac", { + 1.3, + 1.3, + 5.0, + }); + iDesc.add("dependSensor", true); + iDesc.add("ecut", 3.0); + iDesc.add("kappa", 9.0); + iDesc.addUntracked("verbosity", 3); + iDesc.add>("dEdXweights",{}); + iDesc.add>("thicknessCorrection",{}); + iDesc.add>("fcPerMip",{}); + iDesc.add("fcPerEle",0.0); + edm::ParameterSetDescription descNestedNoises; + descNestedNoises.add >("values", {}); + iDesc.add("noises", descNestedNoises); + edm::ParameterSetDescription descNestedNoiseMIP; + descNestedNoiseMIP.add("value", 0 ); + iDesc.add("noiseMip", descNestedNoiseMIP); } /// point in the space From b87c7aacef53c7812afbf81506e35356121ebeb1 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 14:06:02 +0100 Subject: [PATCH 323/686] Finally, move plugins in the correct folder --- RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc | 9 ++++++--- .../interface/HGCalCLUEAlgo.h | 8 ++++---- .../interface/HGCalClusteringAlgoBase.h | 4 ++-- .../interface/HGCalImagingAlgo.h | 8 ++++---- .../interface/HGCalLayerClusterAlgoFactory.h | 6 +++--- .../plugins}/HGCalCLUEAlgo.cc | 2 +- .../plugins}/HGCalImagingAlgo.cc | 2 +- .../plugins}/HGCalLayerClusterPluginFactory.cc | 8 ++++---- .../plugins/HGCalLayerClusterProducer.cc | 3 +-- .../python/hgcalLayerClusters_cff.py | 12 ++++++------ 10 files changed, 32 insertions(+), 30 deletions(-) rename RecoLocalCalo/{HGCalRecAlgos => HGCalRecProducers}/interface/HGCalCLUEAlgo.h (96%) rename RecoLocalCalo/{HGCalRecAlgos => HGCalRecProducers}/interface/HGCalClusteringAlgoBase.h (94%) rename RecoLocalCalo/{HGCalRecAlgos => HGCalRecProducers}/interface/HGCalImagingAlgo.h (97%) rename RecoLocalCalo/{HGCalRecAlgos => HGCalRecProducers}/interface/HGCalLayerClusterAlgoFactory.h (52%) rename RecoLocalCalo/{HGCalRecAlgos/src => HGCalRecProducers/plugins}/HGCalCLUEAlgo.cc (99%) rename RecoLocalCalo/{HGCalRecAlgos/src => HGCalRecProducers/plugins}/HGCalImagingAlgo.cc (99%) rename RecoLocalCalo/{HGCalRecAlgos/src => HGCalRecProducers/plugins}/HGCalLayerClusterPluginFactory.cc (57%) diff --git a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc index 7adc246ae6f31..b7206c6989dca 100644 --- a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc +++ b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc @@ -1,3 +1,4 @@ + #include "RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h" #include "DataFormats/HGCRecHit/interface/HGCRecHit.h" @@ -5,9 +6,11 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + // To retrieve HGCalImagingAlgo::maxlayer // Also available as HGCal3DClustering::lastLayerBH and HGCalDepthPreClusterer::lastLayerBH -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include #include @@ -257,7 +260,7 @@ LongDeps EGammaPCAHelper::energyPerLayer(float radius, bool withHalo) { if (debug_) checkIteration(); std::set layers; float radius2 = radius*radius; - std::vector energyPerLayer(HGCalImagingAlgo::maxlayer+1, 0.f); + std::vector energyPerLayer(HGCalClusteringAlgoBase::maxlayer+1, 0.f); math::XYZVector mainAxis(axis_); mainAxis.unit(); math::XYZVector phiAxis(barycenter_.x(), barycenter_.y(), 0); @@ -299,7 +302,7 @@ void EGammaPCAHelper::printHits(float radius) const { float EGammaPCAHelper::findZFirstLayer(const LongDeps & ld) const { unsigned int firstLayer = 0; - for(unsigned il=1;il<=HGCalImagingAlgo::maxlayer;++il) { + for(unsigned il=1;il<=HGCalClusteringAlgoBase::maxlayer;++il) { if (ld.energyPerLayer()[il] > 0.) { firstLayer = il; break; diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h similarity index 96% rename from RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h rename to RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h index 9121c3ee0a6d1..7f94f32ba54f6 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h @@ -1,7 +1,7 @@ -#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalCLUEAlgo_h -#define RecoLocalCalo_HGCalRecAlgos_HGCalCLUEAlgo_h +#ifndef RecoLocalCalo_HGCalRecProducers_HGCalCLUEAlgo_h +#define RecoLocalCalo_HGCalRecProducers_HGCalCLUEAlgo_h -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" @@ -19,13 +19,13 @@ #include "DataFormats/Math/interface/Point3D.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/KDTreeLinkerAlgoT.h" // C/C++ headers #include #include #include -#include "KDTreeLinkerAlgoT.h" class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { public: diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h similarity index 94% rename from RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h rename to RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h index 50e472023f77e..38ae3297f70b5 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h @@ -1,5 +1,5 @@ -#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalClusteringAlgoBase_h -#define RecoLocalCalo_HGCalRecAlgos_HGCalClusteringAlgoBase_h +#ifndef RecoLocalCalo_HGCalRecProducers_HGCalClusteringAlgoBase_h +#define RecoLocalCalo_HGCalRecProducers_HGCalClusteringAlgoBase_h #include "FWCore/Framework/interface/EventSetup.h" diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h similarity index 97% rename from RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h rename to RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h index e61015af6f094..83c30dd2083e8 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h @@ -1,7 +1,7 @@ -#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalImagingAlgo_h -#define RecoLocalCalo_HGCalRecAlgos_HGCalImagingAlgo_h +#ifndef RecoLocalCalo_HGCalRecProducers_HGCalImagingAlgo_h +#define RecoLocalCalo_HGCalRecProducers_HGCalImagingAlgo_h -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" @@ -19,13 +19,13 @@ #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/KDTreeLinkerAlgoT.h" // C/C++ headers #include #include #include -#include "KDTreeLinkerAlgoT.h" //Density collection typedef std::map< DetId, float > Density; diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerClusterAlgoFactory.h similarity index 52% rename from RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h rename to RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerClusterAlgoFactory.h index 7ae6f3407f064..e68ac1f3abd18 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerClusterAlgoFactory.h @@ -1,10 +1,10 @@ -#ifndef RecoLocalCalo_HGCalRecAlgos_HGCalLayerClusterAlgoFactory_H -#define RecoLocalCalo_HGCalRecAlgos_HGCalLayerClusterAlgoFactory_H +#ifndef RecoLocalCalo_HGCalRecProducers_HGCalLayerClusterAlgoFactory_H +#define RecoLocalCalo_HGCalRecProducers_HGCalLayerClusterAlgoFactory_H #include "FWCore/PluginManager/interface/PluginFactory.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" typedef edmplugin::PluginFactory< HGCalClusteringAlgoBase * (const edm::ParameterSet&) > HGCalLayerClusterAlgoFactory; diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc similarity index 99% rename from RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc rename to RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index d9b88bec02577..d0378a5c8ec90 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -1,4 +1,4 @@ -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h" // Geometry #include "DataFormats/HcalDetId/interface/HcalSubdetector.h" diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc similarity index 99% rename from RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc rename to RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc index cbbab742d641a..d5fb1b1aae975 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc @@ -1,4 +1,4 @@ -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h" // Geometry #include "DataFormats/HcalDetId/interface/HcalSubdetector.h" diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterPluginFactory.cc similarity index 57% rename from RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc rename to RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterPluginFactory.cc index aa1a8fe6a8106..390a3c07292f4 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalLayerClusterPluginFactory.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterPluginFactory.cc @@ -1,7 +1,7 @@ -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalClusteringAlgoBase.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalCLUEAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerClusterAlgoFactory.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h" #include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h" #include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h" diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index 18bc587ec9ec8..c5e12b82c9438 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -21,9 +21,8 @@ #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h" #include "RecoParticleFlow/PFClusterProducer/plugins/SimMappers/ComputeClusterTime.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalLayerClusterAlgoFactory.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalDepthPreClusterer.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalLayerClusterAlgoFactory.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" diff --git a/RecoLocalCalo/HGCalRecProducers/python/hgcalLayerClusters_cff.py b/RecoLocalCalo/HGCalRecProducers/python/hgcalLayerClusters_cff.py index ce52fcd32178d..75b2e04cb5f58 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/hgcalLayerClusters_cff.py +++ b/RecoLocalCalo/HGCalRecProducers/python/hgcalLayerClusters_cff.py @@ -10,10 +10,10 @@ hgcalLayerClusters = hgcalLayerClusters_.clone() -hgcalLayerClusters.dEdXweights = cms.vdouble(dEdX.weights) -hgcalLayerClusters.fcPerMip = cms.vdouble(HGCalUncalibRecHit.HGCEEConfig.fCPerMIP) -hgcalLayerClusters.thicknessCorrection = cms.vdouble(HGCalRecHit.thicknessCorrection) -hgcalLayerClusters.fcPerEle = cms.double(fC_per_ele) hgcalLayerClusters.timeOffset = hgceeDigitizer.tofDelay -hgcalLayerClusters.noises = cms.PSet(refToPSet_ = cms.string('HGCAL_noises')) -hgcalLayerClusters.noiseMip = hgchebackDigitizer.digiCfg.noise_MIP +hgcalLayerClusters.plugin.dEdXweights = cms.vdouble(dEdX.weights) +hgcalLayerClusters.plugin.fcPerMip = cms.vdouble(HGCalUncalibRecHit.HGCEEConfig.fCPerMIP) +hgcalLayerClusters.plugin.thicknessCorrection = cms.vdouble(HGCalRecHit.thicknessCorrection) +hgcalLayerClusters.plugin.fcPerEle = cms.double(fC_per_ele) +hgcalLayerClusters.plugin.noises = cms.PSet(refToPSet_ = cms.string('HGCAL_noises')) +hgcalLayerClusters.plugin.noiseMip = hgchebackDigitizer.digiCfg.noise_MIP From 26c73ec7ced01db2473135d0a2bdd3bf07498644 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 14:45:21 +0100 Subject: [PATCH 324/686] Use 1/0.5 kernel function --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index d0378a5c8ec90..4270cfa18cd30 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -223,7 +223,7 @@ double HGCalCLUEAlgo::calculateLocalDensity(std::vector &nd, KDTree &lp, const unsigned int found_size = found.size(); for (unsigned int j = 0; j < found_size; j++) { if (distance(nd[i].data, found[j].data) < delta_c) { - nd[i].data.rho += found[j].data.weight; + nd[i].data.rho += (nd[i].data.detid == found[j].data.detid ? 1. : 0.5) * found[j].data.weight; maxdensity = std::max(maxdensity, nd[i].data.rho); } } // end loop found From 7cd6286d309fd2922b331b5767555f3bdbf65b35 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 14:45:37 +0100 Subject: [PATCH 325/686] Make CLUE algo default --- .../HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index c5e12b82c9438..6e46a6e0671d3 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -99,7 +99,7 @@ void HGCalLayerClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& // hgcalLayerClusters edm::ParameterSetDescription desc; edm::ParameterSetDescription pluginDesc; - pluginDesc.addNode(edm::PluginDescription("type", "Imaging", true)); + pluginDesc.addNode(edm::PluginDescription("type", "CLUE", true)); desc.add("plugin", pluginDesc); desc.add("detector", "all"); From bb906b33dce0ba29cde67a8a189bc73636aaef18 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 14 Mar 2019 15:18:40 +0100 Subject: [PATCH 326/686] Code-checks --- .../HGCalRecProducers/interface/HGCalCLUEAlgo.h | 10 +++++----- .../HGCalRecProducers/interface/HGCalImagingAlgo.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h index 7f94f32ba54f6..01fe9e1bdb493 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h @@ -51,20 +51,20 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { minpos_(2*(maxlayer+1),{ {0.0f,0.0f} }), maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) {} - virtual ~HGCalCLUEAlgo() {} + ~HGCalCLUEAlgo() override {} - virtual void populate(const HGCRecHitCollection &hits) override; + void populate(const HGCRecHitCollection &hits) override; // this is the method that will start the clusterisation (it is possible to invoke this method // more than once - but make sure it is with different hit collections (or else use reset) - virtual void makeClusters() override; + void makeClusters() override; // this is the method to get the cluster collection out - virtual std::vector getClusters(bool) override; + std::vector getClusters(bool) override; // use this if you want to reuse the same cluster object but don't want to accumulate clusters // (hardly useful?) - virtual void reset() override { + void reset() override { clusters_v_.clear(); layerClustersPerLayer_.clear(); for (auto &it : points_) { diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h index 83c30dd2083e8..a5ab118984a6c 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h @@ -57,20 +57,20 @@ class HGCalImagingAlgo : public HGCalClusteringAlgoBase minpos_(2*(maxlayer+1),{ {0.0f,0.0f} }), maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) {} -virtual ~HGCalImagingAlgo() {} +~HGCalImagingAlgo() override {} -virtual void populate(const HGCRecHitCollection &hits) override; +void populate(const HGCRecHitCollection &hits) override; // this is the method that will start the clusterisation (it is possible to invoke this method more than once - but make sure it is with // different hit collections (or else use reset) -virtual void makeClusters() override; +void makeClusters() override; // this is the method to get the cluster collection out -virtual std::vector getClusters(bool) override; +std::vector getClusters(bool) override; // use this if you want to reuse the same cluster object but don't want to accumulate clusters (hardly useful?) -virtual void reset() override { +void reset() override { clusters_v_.clear(); layerClustersPerLayer_.clear(); for( auto& it: points_) From 3bd3f8a241c8767b754ed97d68a64e556b434324 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Fri, 15 Mar 2019 10:54:46 +0100 Subject: [PATCH 327/686] Fix errors after rebase on top of 26099 --- .../HGCalRecAlgos/interface/HGCal3DClustering.h | 4 ++-- .../HGCalRecProducers/interface/HGCalCLUEAlgo.h | 8 ++++++++ .../interface/HGCalClusteringAlgoBase.h | 7 +++++++ .../interface/HGCalImagingAlgo.h | 12 ++---------- .../HGCalRecProducers/plugins/HGCalCLUEAlgo.cc | 16 ++++++++++++++++ .../plugins/HGCalImagingAlgo.cc | 4 +++- .../plugins/HGCalLayerClusterProducer.cc | 3 ++- .../plugins/HGCalMultiClusterProducer.cc | 6 +++--- .../HGCalValidation/interface/HGCalValidator.h | 2 +- .../interface/HGVHistoProducerAlgo.h | 10 ++++++---- 10 files changed, 50 insertions(+), 22 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h index 5918deb41754c..d33dda94b3f7e 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h @@ -11,7 +11,7 @@ #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/ClusterTools.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include "KDTreeLinkerAlgoT.h" @@ -65,7 +65,7 @@ class HGCal3DClustering void layerIntersection(std::array &to, const std::array &from) const; //max number of layers - static const unsigned int maxlayer = HGCalImagingAlgo::maxlayer; + static const unsigned int maxlayer = HGCalClusteringAlgoBase::maxlayer; std::vector radii; uint32_t minClusters; diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h index 01fe9e1bdb493..bd86d56bc8df6 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h @@ -26,6 +26,7 @@ #include #include +using Density=hgcal_clustering::Density; class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { public: @@ -78,6 +79,9 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { maxpos_[i][1] = 0.; } } + + Density getDensity() override; + void computeThreshold(); static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { @@ -127,6 +131,9 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { // The hit energy cutoff double ecut_; + // For keeping the density per hit + Density density_; + // various parameters used for calculating the noise levels for a given sensor (and whether to use // them) bool dependSensor_; @@ -231,6 +238,7 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { int findAndAssignClusters(std::vector &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector > &) const; math::XYZPoint calculatePosition(std::vector &) const; + void setDensity(const std::vector &nd); }; #endif diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h index 38ae3297f70b5..d54d0b7665fe3 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h @@ -13,6 +13,7 @@ #include #include +namespace hgcal_clustering { template std::vector sorted_indices(const std::vector &v) { @@ -42,6 +43,11 @@ size_t max_index(const std::vector &v) { return (*maxidx); } +//Density collection +typedef std::map< DetId, float > Density; + +}; + class HGCalClusteringAlgoBase { @@ -58,6 +64,7 @@ enum VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }; virtual void makeClusters() = 0; virtual std::vector getClusters(bool) = 0; virtual void reset() = 0; + virtual hgcal_clustering::Density getDensity() = 0; inline void getEventSetup(const edm::EventSetup& es){ rhtools_.getEventSetup(es); diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h index a5ab118984a6c..604f47108e14f 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h @@ -26,10 +26,7 @@ #include #include - -//Density collection -typedef std::map< DetId, float > Density; - +using Density = hgcal_clustering::Density; class HGCalImagingAlgo : public HGCalClusteringAlgoBase { @@ -87,7 +84,7 @@ void reset() override { void computeThreshold(); //getDensity - Density getDensity(); + Density getDensity() override; static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add>("thresholdW0", { @@ -143,11 +140,6 @@ double sigma2_; // transverse shower size // The vector of clusters std::vector clusters_v_; -hgcal::RecHitTools rhtools_; - -// The algo id -reco::CaloCluster::AlgoId algoId_; - // For keeping the density per hit Density density_; diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index 4270cfa18cd30..c15db97f245de 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -12,6 +12,8 @@ #include "tbb/task_arena.h" #include "tbb/tbb.h" +using namespace hgcal_clustering; + void HGCalCLUEAlgo::populate(const HGCRecHitCollection &hits) { // loop over all hits and create the Hexel structure, skip energies below ecut @@ -93,6 +95,8 @@ void HGCalCLUEAlgo::makeClusters() { double maxdensity = calculateLocalDensity(points_[i], hit_kdtree, actualLayer); // also stores rho (energy // density) for each point (node) + //Now that we have the density per point we can store it + setDensity(points_[i]); // calculate distance to nearest point with higher density storing // distance (delta) and point's index calculateDistanceToHigher(points_[i]); @@ -390,3 +394,15 @@ void HGCalCLUEAlgo::computeThreshold() { v_sigmaNoise_[ilayer - 1][maxNumberOfThickIndices] = scintillators_sigmaNoise; } } + +void HGCalCLUEAlgo::setDensity(const std::vector &nd){ + + // for each node store the computer local density + for (auto &i : nd){ + density_[ i.data.detid ] = i.data.rho ; + } +} + +Density HGCalCLUEAlgo::getDensity() { + return density_; +} diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc index d5fb1b1aae975..c05e2ff678a9d 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc @@ -12,6 +12,8 @@ #include "tbb/task_arena.h" #include "tbb/tbb.h" +using namespace hgcal_clustering; + void HGCalImagingAlgo::populate(const HGCRecHitCollection &hits) { // loop over all hits and create the Hexel structure, skip energies below ecut @@ -687,7 +689,7 @@ void HGCalImagingAlgo::setDensity(const std::vector &nd){ } // end loop nodes } -//Density +//Density Density HGCalImagingAlgo::getDensity(){ return density_; } diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index 6e46a6e0671d3..7c4d8114724ec 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -30,6 +30,7 @@ #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" #include "DataFormats/Common/interface/ValueMap.h" +using Density = hgcal_clustering::Density; class HGCalLayerClusterProducer : public edm::stream::EDProducer<> { public: @@ -174,7 +175,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, auto clusterHandle = evt.put(std::move(clusters)); auto clusterHandleSharing = evt.put(std::move(clusters_sharing),"sharing"); - //Keep the density + //Keep the density *density = algo->getDensity(); evt.put(std::move(density)); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalMultiClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalMultiClusterProducer.cc index 3469b7e41fc1f..2b93a489831fe 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalMultiClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalMultiClusterProducer.cc @@ -18,9 +18,9 @@ #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalDepthPreClusterer.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include "FWCore/Framework/interface/ESHandle.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" @@ -44,14 +44,14 @@ class HGCalMultiClusterProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT > clusters_sharing_token; std::unique_ptr multicluster_algo; bool doSharing; - HGCalImagingAlgo::VerbosityLevel verbosity; + HGCalClusteringAlgoBase::VerbosityLevel verbosity; }; DEFINE_FWK_MODULE(HGCalMultiClusterProducer); HGCalMultiClusterProducer::HGCalMultiClusterProducer(const edm::ParameterSet &ps) : doSharing(ps.getParameter("doSharing")), - verbosity((HGCalImagingAlgo::VerbosityLevel)ps.getUntrackedParameter("verbosity",3)){ + verbosity((HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter("verbosity",3)){ std::vector multicluster_radii = ps.getParameter >("multiclusterRadii"); double minClusters = ps.getParameter("minClusters"); clusters_token = consumes >(ps.getParameter("HGCLayerClusters")); diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index 5fc34b8b5c8d2..f2caf9af0080a 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -24,7 +24,7 @@ #include "Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h" #include "Validation/HGCalValidation/interface/CaloParticleSelector.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" class PileupSummaryInfo; diff --git a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h index d2cc1bd448108..8260255fb8518 100644 --- a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h +++ b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h @@ -21,7 +21,7 @@ #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" #include "SimDataFormats/Vertex/interface/SimVertex.h" -#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" +#include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h" #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/ConcurrentMonitorElement.h" @@ -81,7 +81,7 @@ struct HGVHistoProducerAlgoHistograms { std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer; std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer_eneweighted; std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer; - std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer_eneweighted; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer_eneweighted; std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcell_perthickperlayer; std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer; @@ -93,6 +93,8 @@ struct HGVHistoProducerAlgoHistograms { }; +using Density = hgcal_clustering::Density; + class HGVHistoProducerAlgo { public: HGVHistoProducerAlgo(const edm::ParameterSet& pset) ; @@ -103,7 +105,7 @@ class HGVHistoProducerAlgo { void bookInfo(DQMStore::ConcurrentBooker& ibook, Histograms& histograms); void bookCaloParticleHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,int pdgid); - void bookClusterHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,unsigned layers, + void bookClusterHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,unsigned layers, std::vector thicknesses, std::string pathtomatbudfile); void layerClusters_to_CaloParticles(const Histograms& histograms, const reco::CaloClusterCollection &clusters, @@ -180,7 +182,7 @@ class HGVHistoProducerAlgo { double minDisSeedToMaxperthickperlayer_, maxDisSeedToMaxperthickperlayer_; int nintDisSeedToMaxperthickperlayer_; double minClEneperthickperlayer_, maxClEneperthickperlayer_; int nintClEneperthickperlayer_; double minCellsEneDensperthick_, maxCellsEneDensperthick_; int nintCellsEneDensperthick_; - + }; #endif From ddb656d9e397f4c36f5cacbb25f6d4dbe790cf44 Mon Sep 17 00:00:00 2001 From: Marco Rovere Date: Thu, 28 Mar 2019 11:41:42 +0100 Subject: [PATCH 328/686] Review Comments --- .../interface/HGCalCLUEAlgo.h | 2 +- .../plugins/HGCalCLUEAlgo.cc | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h index bd86d56bc8df6..2c4cb8535b1ae 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalCLUEAlgo.h @@ -237,7 +237,7 @@ class HGCalCLUEAlgo : public HGCalClusteringAlgoBase { double calculateDistanceToHigher(std::vector &) const; int findAndAssignClusters(std::vector &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector > &) const; - math::XYZPoint calculatePosition(std::vector &) const; + math::XYZPoint calculatePosition(const std::vector &) const; void setDensity(const std::vector &nd); }; diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index c15db97f245de..0cf1f9d011d93 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -109,22 +109,23 @@ void HGCalCLUEAlgo::makeClusters() { std::vector HGCalCLUEAlgo::getClusters(bool) { reco::CaloID caloID = reco::CaloID::DET_HGCAL_ENDCAP; std::vector> thisCluster; - for (auto &clsOnLayer : layerClustersPerLayer_) { - for (unsigned int i = 0; i < clsOnLayer.size(); ++i) { + for (const auto &clsOnLayer : layerClustersPerLayer_) { + int index = 0; + for (const auto &cl : clsOnLayer) { double energy = 0; Point position; // Will save the maximum density hit of the cluster - size_t rsmax = max_index(clsOnLayer[i]); - position = calculatePosition(clsOnLayer[i]); // energy-weighted position - for (auto &it : clsOnLayer[i]) { + size_t rsmax = max_index(cl); + position = calculatePosition(cl); // energy-weighted position + for (const auto &it : cl) { energy += it.data.weight; thisCluster.emplace_back(it.data.detid, 1.f); } if (verbosity_ < pINFO) { LogDebug("HGCalCLUEAlgo") << "******** NEW CLUSTER (HGCIA) ********" - << "Index " << i - << "No. of cells = " << clsOnLayer[i].size() + << "Index " << index + << "No. of cells = " << cl.size() << " Energy = " << energy << " Phi = " << position.phi() << " Eta = " << position.eta() @@ -132,15 +133,16 @@ std::vector HGCalCLUEAlgo::getClusters(bool) { } clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); if (!clusters_v_.empty()) { - clusters_v_.back().setSeed(clsOnLayer[i][rsmax].data.detid); + clusters_v_.back().setSeed(cl[rsmax].data.detid); } thisCluster.clear(); + index++; } } return clusters_v_; } -math::XYZPoint HGCalCLUEAlgo::calculatePosition(std::vector &v) const { +math::XYZPoint HGCalCLUEAlgo::calculatePosition(const std::vector &v) const { float total_weight = 0.f; float x = 0.f; float y = 0.f; @@ -188,7 +190,7 @@ math::XYZPoint HGCalCLUEAlgo::calculatePosition(std::vector &v) const { for (auto idx : innerIndices) { float rhEnergy = v[idx].data.weight; if (rhEnergy == 0.) continue; - float Wi = std::max(thresholdW0_[thick] + log(rhEnergy / total_weight), 0.); + float Wi = std::max(thresholdW0_[thick] + std::log(rhEnergy / total_weight), 0.); x_log += v[idx].data.x * Wi; y_log += v[idx].data.y * Wi; total_weight_log += Wi; @@ -237,7 +239,7 @@ double HGCalCLUEAlgo::calculateLocalDensity(std::vector &nd, KDTree &lp, double HGCalCLUEAlgo::calculateDistanceToHigher(std::vector &nd) const { // sort vector of Hexels by decreasing local density - std::vector rs = sorted_indices(nd); + std::vector &&rs = sorted_indices(nd); double maxdensity = 0.0; int nearestHigher = -1; @@ -250,7 +252,7 @@ double HGCalCLUEAlgo::calculateDistanceToHigher(std::vector &nd) const { // start by setting delta for the highest density hit to // the most distant hit - this is a convention - for (auto &j : nd) { + for (const auto &j : nd) { double tmp = distance2(nd[rs[0]].data, j.data); if (tmp > dist2) dist2 = tmp; } From b311771989da77e14b060ae36f50ccf04b11b8d6 Mon Sep 17 00:00:00 2001 From: zhen Date: Thu, 28 Mar 2019 11:53:38 +0100 Subject: [PATCH 329/686] update job splitting for 2018 HI data workflows --- Configuration/PyReleaseValidation/python/MatrixInjector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Configuration/PyReleaseValidation/python/MatrixInjector.py b/Configuration/PyReleaseValidation/python/MatrixInjector.py index 926be20262460..943b5cd35cade 100644 --- a/Configuration/PyReleaseValidation/python/MatrixInjector.py +++ b/Configuration/PyReleaseValidation/python/MatrixInjector.py @@ -256,6 +256,7 @@ def prepare(self,mReader, directories, mode='init'): wmsplit['HYBRIDRepackHI2015VR']=1 wmsplit['HYBRIDZSHI2015']=1 wmsplit['RECOHID15']=1 + wmsplit['RECOHID18']=1 #import pprint #pprint.pprint(wmsplit) From 781745baa723ede9e05cfef96da96fd57b260c7f Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Mar 2019 15:03:44 +0100 Subject: [PATCH 330/686] Re-add quality cuts to pi0 plugin --- .../python/RecoTauPiZeroBuilderPlugins_cfi.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index 40f475cb2a4dd..55e9a49a34020 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -39,17 +39,15 @@ stripCandidatesParticleIds = cms.vint32(2, 4), stripEtaAssociationDistance = cms.double(0.05), stripPhiAssociationDistance = cms.double(0.2), - makeCombinatoricStrips = cms.bool(False) + makeCombinatoricStrips = cms.bool(False), + verbosity = cms.int32(0) ) -comboStrips = cms.PSet( +comboStrips = strips.clone( name = cms.string("cs"), plugin = cms.string("RecoTauPiZeroStripPlugin"), - qualityCuts = PFTauQualityCuts, # Clusterize photons and electrons (PF numbering) stripCandidatesParticleIds = cms.vint32(2, 4), - stripEtaAssociationDistance = cms.double(0.05), - stripPhiAssociationDistance = cms.double(0.2), makeCombinatoricStrips = cms.bool(True), maxInputStrips = cms.int32(5), stripMassWhenCombining = cms.double(0.0), # assume photon like @@ -65,15 +63,13 @@ minStripEt = cms.double(1.0), updateStripAfterEachDaughter = cms.bool(False), maxStripBuildIterations = cms.int32(-1), - verbosity = cms.int32(0) ) # Produce a "strips" of photons # with no track quality cuts applied to PFElectrons # and eta x phi size of strip increasing for low pT photons -modStrips2 = cms.PSet( - name = cms.string("s"), +modStrips2 = strips.clone( plugin = cms.string('RecoTauPiZeroStripPlugin3'), applyElecTrackQcuts = cms.bool(False), # Clusterize photons and electrons (PF numbering) @@ -96,5 +92,4 @@ # chosen to contain 95% of photons from tau decays updateStripAfterEachDaughter = cms.bool(False), maxStripBuildIterations = cms.int32(-1), - verbosity = cms.int32(0) ) From f40a17de36ebf6dc4a7983ee6f9952f93909c44b Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Mar 2019 15:11:05 +0100 Subject: [PATCH 331/686] Get rid of duplicate code --- RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index 55e9a49a34020..81059abc4f87f 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -46,8 +46,6 @@ comboStrips = strips.clone( name = cms.string("cs"), plugin = cms.string("RecoTauPiZeroStripPlugin"), - # Clusterize photons and electrons (PF numbering) - stripCandidatesParticleIds = cms.vint32(2, 4), makeCombinatoricStrips = cms.bool(True), maxInputStrips = cms.int32(5), stripMassWhenCombining = cms.double(0.0), # assume photon like @@ -72,8 +70,6 @@ modStrips2 = strips.clone( plugin = cms.string('RecoTauPiZeroStripPlugin3'), applyElecTrackQcuts = cms.bool(False), - # Clusterize photons and electrons (PF numbering) - stripCandidatesParticleIds = cms.vint32(2, 4), stripEtaAssociationDistanceFunc = cms.PSet( function = cms.string("TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"), par0 = cms.double(1.97077e-01), From d4e42eeb1771b40bb9479e48de73be3b978e83d2 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Mar 2019 16:15:39 +0100 Subject: [PATCH 332/686] Further clean modules here --- RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py index c8fb8efa9f192..603a61e653f09 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cff.py @@ -13,8 +13,6 @@ minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, builders = cms.VPSet( - #builders.strips - #builders.modStrips builders.modStrips2 ), ranking = cms.VPSet( @@ -29,7 +27,6 @@ jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, - massHypothesis = cms.double(0.136), outputSelection = cms.string('pt > 1.5'), builders = cms.VPSet( builders.comboStrips @@ -44,12 +41,9 @@ jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, - massHypothesis = cms.double(0.136), outputSelection = cms.string('pt > 1.5'), builders = cms.VPSet( builders.combinatoricPhotonPairs, - #builders.strips - #builders.modStrips builders.modStrips2 ), ranking = cms.VPSet( @@ -64,7 +58,6 @@ jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, - massHypothesis = cms.double(0.136), outputSelection = cms.string('pt > 1.5'), builders = cms.VPSet( builders.allSinglePhotons, From 441e90e3b5f2e2c38b36cff25876f688a9a2fd2a Mon Sep 17 00:00:00 2001 From: tonydp03 Date: Sun, 24 Mar 2019 12:34:35 +0100 Subject: [PATCH 333/686] Modified snippet for CloseByParticleGunProducer --- .../CloseByParticle_Photon_ERZRanges.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py diff --git a/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py b/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py new file mode 100644 index 0000000000000..ec8728f605fc2 --- /dev/null +++ b/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py @@ -0,0 +1,24 @@ +import FWCore.ParameterSet.Config as cms + +generator = cms.EDProducer("CloseByParticleGunProducer", + PGunParameters = cms.PSet(PartID = cms.vint32(22), + EnMin = cms.double(25.), + EnMax = cms.double(200.), + RMin = cms.double(60), + RMax = cms.double(120), + ZMin = cms.double(320), + ZMax = cms.double(650), + Delta = cms.double(2.5), + Pointing = cms.bool(True), + MaxEta = cms.double(2.7), + MinEta = cms.double(1.7), + MaxPhi = cms.double(3.14159265359/6.), + MinPhi = cms.double(-3.14159265359/6.), + + ), + Verbosity = cms.untracked.int32(10), + + psethack = cms.string('single gamma random energy'), + AddAntiParticle = cms.bool(False), + firstRun = cms.untracked.uint32(1) +) From 21e22f3ba7bda2ebd3e97ffe3421c295974cb135 Mon Sep 17 00:00:00 2001 From: tonydp03 Date: Thu, 28 Mar 2019 10:32:48 +0100 Subject: [PATCH 334/686] Adding smearing in energy, z, and R --- .../interface/CloseByParticleGunProducer.h | 3 ++- IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h index f5e8755a40201..0a89b4cf4efd2 100644 --- a/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h +++ b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h @@ -20,7 +20,8 @@ namespace edm protected : // data members - double fEn,fR,fZ,fDelta; + double fEnMin,fEnMax,fRMin,fRMax,fZMin,fZMax,fDelta; + bool fPointing = false; std::vector fPartIDs; }; diff --git a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc index 1de060edcf189..98caa9383b8bf 100644 --- a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc +++ b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc @@ -29,9 +29,12 @@ CloseByParticleGunProducer::CloseByParticleGunProducer(const ParameterSet& pset) ParameterSet pgun_params = pset.getParameter("PGunParameters") ; - fEn = pgun_params.getParameter("En"); - fR = pgun_params.getParameter("R"); - fZ = pgun_params.getParameter("Z"); + fEnMax = pgun_params.getParameter("EnMax"); + fEnMin = pgun_params.getParameter("EnMin"); + fRMax = pgun_params.getParameter("RMax"); + fRMin = pgun_params.getParameter("RMin"); + fZMax = pgun_params.getParameter("ZMax"); + fZMin = pgun_params.getParameter("ZMin"); fDelta = pgun_params.getParameter("Delta"); fPartIDs = pgun_params.getParameter< vector >("PartID"); fPointing = pgun_params.getParameter("Pointing"); @@ -60,6 +63,10 @@ void CloseByParticleGunProducer::produce(Event &e, const EventSetup& es) // int barcode = 1 ; double phi = CLHEP::RandFlat::shoot(engine, -3.14159265358979323846, 3.14159265358979323846); + double fR = CLHEP::RandFlat::shoot(engine,fRMin,fRMax); + double fZ = CLHEP::RandFlat::shoot(engine,fZMin,fZMax); + double fEn = CLHEP::RandFlat::shoot(engine,fEnMin,fEnMax); + for (unsigned int ip=0; ip Date: Thu, 28 Mar 2019 10:41:43 +0100 Subject: [PATCH 335/686] Rename the snippet --- ...hoton_ERZRanges.py => CloseByParticle_Photon_ERZRanges_cfi.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Configuration/Generator/python/{CloseByParticle_Photon_ERZRanges.py => CloseByParticle_Photon_ERZRanges_cfi.py} (100%) diff --git a/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py b/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py similarity index 100% rename from Configuration/Generator/python/CloseByParticle_Photon_ERZRanges.py rename to Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py From ef6bad37d074d985243d30986735df5c5b8bb6b6 Mon Sep 17 00:00:00 2001 From: tonydp03 Date: Thu, 28 Mar 2019 16:42:06 +0100 Subject: [PATCH 336/686] Added the possibility to produce particles in a given window within R and Phi ranges --- .../CloseByParticle_Photon_ERZRanges_cfi.py | 1 + .../src/PassThroughEvtVtxGenerator.cc | 2 +- .../interface/CloseByParticleGunProducer.h | 3 ++- .../src/CloseByParticleGunProducer.cc | 16 +++++++++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py b/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py index ec8728f605fc2..b1ffef164cd27 100644 --- a/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py +++ b/Configuration/Generator/python/CloseByParticle_Photon_ERZRanges_cfi.py @@ -10,6 +10,7 @@ ZMax = cms.double(650), Delta = cms.double(2.5), Pointing = cms.bool(True), + Overlapping = cms.bool(False), MaxEta = cms.double(2.7), MinEta = cms.double(1.7), MaxPhi = cms.double(3.14159265359/6.), diff --git a/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc b/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc index 28ccec7edd7e2..eb0403ac67aa8 100644 --- a/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc +++ b/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc @@ -46,7 +46,7 @@ PassThroughEvtVtxGenerator::~PassThroughEvtVtxGenerator() } HepMC::FourVector PassThroughEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine*) const { - return HepMC::FourVector(0.,0.,0.); + return HepMC::FourVector(0.,0.,0.,0); } void PassThroughEvtVtxGenerator::produce( Event& evt, const EventSetup& ) diff --git a/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h index 0a89b4cf4efd2..a9ec81edaba7e 100644 --- a/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h +++ b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h @@ -20,9 +20,10 @@ namespace edm protected : // data members - double fEnMin,fEnMax,fRMin,fRMax,fZMin,fZMax,fDelta; + double fEnMin,fEnMax,fRMin,fRMax,fZMin,fZMax,fDelta,fPhiMin,fPhiMax; bool fPointing = false; + bool fOverlapping = false; std::vector fPartIDs; }; } diff --git a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc index 98caa9383b8bf..8821dc0c9ea36 100644 --- a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc +++ b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc @@ -36,8 +36,11 @@ CloseByParticleGunProducer::CloseByParticleGunProducer(const ParameterSet& pset) fZMax = pgun_params.getParameter("ZMax"); fZMin = pgun_params.getParameter("ZMin"); fDelta = pgun_params.getParameter("Delta"); + fPhiMin = pgun_params.getParameter("MinPhi"); + fPhiMax = pgun_params.getParameter("MaxPhi"); fPartIDs = pgun_params.getParameter< vector >("PartID"); fPointing = pgun_params.getParameter("Pointing"); + fOverlapping = pgun_params.getParameter("Overlapping"); produces("unsmeared"); produces(); @@ -62,14 +65,21 @@ void CloseByParticleGunProducer::produce(Event &e, const EventSetup& es) // loop over particles // int barcode = 1 ; - double phi = CLHEP::RandFlat::shoot(engine, -3.14159265358979323846, 3.14159265358979323846); + double phi = CLHEP::RandFlat::shoot(engine, fPhiMin, fPhiMax); double fR = CLHEP::RandFlat::shoot(engine,fRMin,fRMax); double fZ = CLHEP::RandFlat::shoot(engine,fZMin,fZMax); double fEn = CLHEP::RandFlat::shoot(engine,fEnMin,fEnMax); - for (unsigned int ip=0; ipparticle(HepPDT::ParticleID(abs(PartID))) ; double mass = PData->mass().value() ; From 4364583bb3830f9b9ef5a5b6dd8864ee5fd68c41 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Mar 2019 17:16:15 +0100 Subject: [PATCH 337/686] Add the qualituCuts PSet also in the fillDescriptions generated config --- RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index a8b7c35aa4b41..50233b027c3a3 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -313,9 +313,10 @@ RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descript desc_qualityCuts.add("recoverLeadingTrk", false); edm::ParameterSet pset_builders; - //pset_builders.addParameter("qualityCuts"); pset_builders.addParameter("name",""); pset_builders.addParameter("plugin",""); + edm::ParameterSet qualityCuts; + pset_builders.addParameter("qualityCuts",qualityCuts); pset_builders.addParameter("verbosity",0); { From 6956ad75fc95e798001e89cfd94cbc2772c512cf Mon Sep 17 00:00:00 2001 From: "W. David Dagenhart" Date: Thu, 28 Mar 2019 20:24:40 +0100 Subject: [PATCH 338/686] Fix race condition in EventProcessor First note that that vast majority of the time, the correct code path wins the data race and there is no problem, almost always. That is why we have rarely seen failures related to this. The condition is related to the deletion of the LuminosityBlockProcessingStatus. If we want to call endRun after exiting processLumis, then this status object must have already been destroyed because it holds a shared_ptr to the RunResources object that prevents endRun from running. If it isn't destroyed then endRun may get called at some random time much later which causes all kinds of problems. Seg faults would be likely. --- FWCore/Framework/interface/EventProcessor.h | 3 +- FWCore/Framework/src/EventProcessor.cc | 61 ++++++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 0c49a29739069..5b93c0ce00ce9 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -52,6 +52,7 @@ namespace edm { class ProcessDesc; class SubProcess; class WaitingTaskHolder; + class LuminosityBlockPrincipal; class LuminosityBlockProcessingStatus; class IOVSyncValue; @@ -231,7 +232,7 @@ namespace edm { int readAndMergeLumi(LuminosityBlockProcessingStatus&); void writeRunAsync(WaitingTaskHolder, ProcessHistoryID const& phid, RunNumber_t run, MergeableRunProductMetadata const*); void deleteRunFromCache(ProcessHistoryID const& phid, RunNumber_t run); - void writeLumiAsync(WaitingTaskHolder, std::shared_ptr ); + void writeLumiAsync(WaitingTaskHolder, LuminosityBlockPrincipal& lumiPrincipal); void deleteLumiFromCache(LuminosityBlockProcessingStatus&); bool shouldWeStop() const; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 522351b973539..7706983d4d8f2 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1087,14 +1087,21 @@ namespace edm { std::shared_ptr const& iRunResource, edm::WaitingTaskHolder iHolder) { if(iHolder.taskHasFailed()) { return; } + // We must be careful with the status object here and in code this function calls. IF we want + // endRun to be called, then the status object must be destroyed before the things waiting on + // iHolder are allowed to proceed. Otherwise, there will be race condition (possibly causing + // endRun to be called much later than it should be, because it is holding iRunResource). auto status= std::make_shared(this, preallocations_.numberOfStreams(), iRunResource) ; - auto lumiWork = [this, iHolder, status](edm::LimitedTaskQueue::Resumer iResumer) mutable { - if(iHolder.taskHasFailed()) { return; } + auto lumiWork = [this, iHolder, status = std::move(status)](edm::LimitedTaskQueue::Resumer iResumer) mutable { + if (iHolder.taskHasFailed()) { + status.reset(); + return; + } status->setResumer(std::move(iResumer)); - - sourceResourcesAcquirer_.serialQueueChain().push([this,iHolder,status]() mutable { + + sourceResourcesAcquirer_.serialQueueChain().push([this, iHolder, status = std::move(status)]() mutable { //make the services available ServiceRegistry::Operate operate(serviceToken_); @@ -1119,8 +1126,9 @@ namespace edm { //Task to start the stream beginLumis auto beginStreamsTask= make_waiting_task(tbb::task::allocate_root() - ,[this, holder = iHolder, status, ts] (std::exception_ptr const* iPtr) mutable { + ,[this, holder = iHolder, status = std::move(status), ts] (std::exception_ptr const* iPtr) mutable { if (iPtr) { + status.reset(); holder.doneWaiting(*iPtr); } else { @@ -1132,6 +1140,7 @@ namespace edm { ServiceRegistry::Operate operate(serviceToken_); looper_->doBeginLuminosityBlock(*(status->lumiPrincipal()), es, &processContext_); }catch(...) { + status.reset(); holder.doneWaiting(std::current_exception()); return; } @@ -1139,7 +1148,7 @@ namespace edm { typedef OccurrenceTraits Traits; for(unsigned int i=0; i(WaitingTaskHolder{eventTask}, *schedule_,i,*lp,ts,es, serviceToken_,subProcesses_); + status.reset(); }); } + status.reset(); } - }); - + }); // beginStreamTask + //task to start the global begin lumi WaitingTaskHolder beginStreamsHolder{beginStreamsTask}; auto const& es = esp_->eventSetup(); @@ -1171,17 +1182,18 @@ namespace edm { typedef OccurrenceTraits Traits; beginGlobalTransitionAsync(beginStreamsHolder, *schedule_, - *(status->lumiPrincipal()), + lumiPrincipal, ts, es, serviceToken_, subProcesses_); } } catch(...) { + status.reset(); iHolder.doneWaiting(std::current_exception()); } - }); - }; + }); // task in sourceResourcesAcquirer + }; // end lumiWork //Safe to do check now since can not have multiple beginLumis at same time in this part of the code // because we do not attempt to read from the source again until we try to get the first event in a lumi @@ -1275,17 +1287,24 @@ namespace edm { items.second.doneWaiting(ptr); }); - auto writeT = edm::make_waiting_task(tbb::task::allocate_root(), [this,status =iLumiStatus, task = WaitingTaskHolder(t)] (std::exception_ptr const* iExcept) mutable { + auto& lp = *(iLumiStatus->lumiPrincipal()); + bool cleaningUpAfterException = iLumiStatus->cleaningUpAfterException(); + + auto writeT = edm::make_waiting_task(tbb::task::allocate_root(), [this,status = std::move(iLumiStatus), task = WaitingTaskHolder(t)] (std::exception_ptr const* iExcept) mutable { if(iExcept) { + status.reset(); task.doneWaiting(*iExcept); } else { //Only call writeLumi if beginLumi succeeded if(status->didGlobalBeginSucceed()) { - writeLumiAsync(std::move(task),status); + LuminosityBlockPrincipal& lumiPrincipal = *(status->lumiPrincipal()); + status.reset(); + writeLumiAsync(std::move(task), lumiPrincipal); + } else { + status.reset(); } } }); - auto& lp = *(iLumiStatus->lumiPrincipal()); IOVSyncValue ts(EventID(lp.run(), lp.luminosityBlock(), EventID::maxEventNumber()), lp.beginTime()); @@ -1301,7 +1320,7 @@ namespace edm { es, serviceToken_, subProcesses_, - iLumiStatus->cleaningUpAfterException()); + cleaningUpAfterException); } void EventProcessor::streamEndLumiAsync(edm::WaitingTaskHolder iTask, @@ -1345,6 +1364,7 @@ namespace edm { serviceToken_, subProcesses_,cleaningUpAfterException); } + iLumiStatus.reset(); } @@ -1458,23 +1478,22 @@ namespace edm { FDEBUG(1) << "\tdeleteRunFromCache " << run << "\n"; } - void EventProcessor::writeLumiAsync(WaitingTaskHolder task, std::shared_ptr iStatus) { - auto subsT = edm::make_waiting_task(tbb::task::allocate_root(), [this,task, iStatus](std::exception_ptr const* iExcept) mutable { + void EventProcessor::writeLumiAsync(WaitingTaskHolder task, LuminosityBlockPrincipal& lumiPrincipal) { + auto subsT = edm::make_waiting_task(tbb::task::allocate_root(), [this, task, &lumiPrincipal](std::exception_ptr const* iExcept) mutable { if(iExcept) { task.doneWaiting(*iExcept); } else { ServiceRegistry::Operate op(serviceToken_); for(auto&s : subProcesses_) { - s.writeLumiAsync(task,*(iStatus->lumiPrincipal())); + s.writeLumiAsync(task, lumiPrincipal); } } }); ServiceRegistry::Operate op(serviceToken_); - std::shared_ptr const& lumiPrincipal = iStatus->lumiPrincipal(); - lumiPrincipal->runPrincipal().mergeableRunProductMetadata()->writeLumi(lumiPrincipal->luminosityBlock()); + lumiPrincipal.runPrincipal().mergeableRunProductMetadata()->writeLumi(lumiPrincipal.luminosityBlock()); - schedule_->writeLumiAsync(WaitingTaskHolder{subsT}, *lumiPrincipal, &processContext_, actReg_.get()); + schedule_->writeLumiAsync(WaitingTaskHolder{subsT}, lumiPrincipal, &processContext_, actReg_.get()); } void EventProcessor::deleteLumiFromCache(LuminosityBlockProcessingStatus& iStatus) { From 5f5d4c7a5fdd788b071428f63e2d0fbbc9768cc4 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Mar 2019 21:18:00 +0100 Subject: [PATCH 339/686] Make changes to do geometry validation of V10 --- .../python/hgcGeomCheck_cff.py | 12 ++++ .../HGCalValidation/test/HGCGeometryCheck.cc | 64 +++++++++++-------- .../test/runHGCGeomCheck_cfg.py | 35 ++++++---- .../test/runHGCalDigiStudy_cfg.py | 14 ++-- .../test/runHGCalRecHitStudy_cfg.py | 15 +++-- .../test/runHGCalSimHitStudy_cfg.py | 18 +++--- .../test/testHGCalSimWatcherV8_cfg.py | 17 ++--- .../test/testHGCalSimWatcherV9_cfg.py | 4 +- 8 files changed, 107 insertions(+), 72 deletions(-) create mode 100644 Validation/HGCalValidation/python/hgcGeomCheck_cff.py diff --git a/Validation/HGCalValidation/python/hgcGeomCheck_cff.py b/Validation/HGCalValidation/python/hgcGeomCheck_cff.py new file mode 100644 index 0000000000000..67479811a15ba --- /dev/null +++ b/Validation/HGCalValidation/python/hgcGeomCheck_cff.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + +from Validation.HGCalValidation.hgcGeomCheck_cfi import * + +from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 + +phase2_hgcalV9.toModify(hgcGeomCheck, + geometrySource = cms.untracked.vstring( + 'HGCalEESensitive', + 'HGCalHESiliconSensitive', + 'HGCalHEScintillatorSensitive'), +) diff --git a/Validation/HGCalValidation/test/HGCGeometryCheck.cc b/Validation/HGCalValidation/test/HGCGeometryCheck.cc index e01219ac4d114..50f7294a7722b 100644 --- a/Validation/HGCalValidation/test/HGCGeometryCheck.cc +++ b/Validation/HGCalValidation/test/HGCGeometryCheck.cc @@ -31,6 +31,8 @@ #include +//#define EDM_ML_DEBUG + class HGCGeometryCheck : public edm::one::EDAnalyzer { public: @@ -70,12 +72,13 @@ HGCGeometryCheck::HGCGeometryCheck(const edm::ParameterSet &cfg) : hcons_(0) { g4Token_ = consumes(cfg.getParameter("g4Source")); geometrySource_ = cfg.getUntrackedParameter< std::vector >("geometrySource"); - edm::LogVerbatim("HGCalValidation") << "HGCGeometryCheck:: use information from " - << cfg.getParameter("g4Source") << " and " - << geometrySource_.size() << " geometry records:"; + edm::LogVerbatim("HGCalValid") << "HGCGeometryCheck:: use information from " + << cfg.getParameter("g4Source") + << " and " + << geometrySource_.size() + << " geometry records:"; for (unsigned int k=0; k hgcGeom; iSetup.get().get(geometrySource_[i],hgcGeom); if (hgcGeom.isValid()) { hgcGeometry_.push_back(hgcGeom.product()); + edm::LogVerbatim("HGCalValid") << "Initialize geometry for " + << geometrySource_[i]; } else { edm::LogWarning("HGCalValid") << "Cannot initiate HGCalGeometry for " - << geometrySource_[i] << std::endl; + << geometrySource_[i]; } } } @@ -137,12 +144,13 @@ void HGCGeometryCheck::beginRun(const edm::Run&, const edm::EventSetup& iSetup) void HGCGeometryCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - edm::LogVerbatim("HGCalValidation") << "HGCGeometryCheck::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "HGCGeometryCheck::Run " + << iEvent.id().run() << " Event " + << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " + << iEvent.bunchCrossing(); +#endif //Accessing G4 information edm::Handle infoLayer; iEvent.getByToken(g4Token_,infoLayer); @@ -186,12 +194,14 @@ void HGCGeometryCheck::analyze(const edm::Event &iEvent, } double zp = hgcGeometry_[dtype]->waferZ(layer,true); //cm if (zside < 0) zp = -zp; - edm::LogVerbatim("HGCalValidation") << "Info[" << i - << "] Detector Information " - << hitDet[i] << ":" << subdet - << ":" << zside << ":" << layer - << " Z " << zp << ":" << zz - << " R " << rr; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "Info[" << i + << "] Detector Information " + << hitDet[i] << ":" << subdet + << ":" << zside << ":" << layer + << " Z " << zp << ":" << zz + << " R " << rr; +#endif if (dtype == 0) { heedzVsZ->Fill(zp, (zz-zp)); heezVsLayer->Fill(layer,zz); @@ -213,13 +223,15 @@ void HGCGeometryCheck::analyze(const edm::Event &iEvent, HcalCellType::HcalCell cell = hcons_->cell(subdet, zside, lay, eta, phi); double zp = cell.rz/10; //mm --> cm if (zside == 0) zp = -zp; - edm::LogVerbatim("HGCalValidation") << "Info[" << i - << "] Detector Information " - << hitDet[i] << ":" << subdet - << ":" << zside << ":" << depth - << ":" << eta << ":" << phi << ":" - << lay << " z " << zp << ":" - << zz << " R " << rr; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "Info[" << i + << "] Detector Information " + << hitDet[i] << ":" << subdet + << ":" << zside << ":" << depth + << ":" << eta << ":" << phi << ":" + << lay << " z " << zp << ":" + << zz << " R " << rr; +#endif hebdzVsZ->Fill(zp, (zz-zp)); hebzVsLayer->Fill(lay,zz); hebrVsLayer->Fill(lay,rr); diff --git a/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py b/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py index 7c33adc279f46..556654d3d63aa 100644 --- a/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py +++ b/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py @@ -1,34 +1,41 @@ - import FWCore.ParameterSet.Config as cms - -process = cms.Process("HGCGeomAnalysis") +from Configuration.StandardSequences.Eras import eras + +#process = cms.Process("HGCGeomAnalysis",eras.Phase2) +#process.load('Configuration.Geometry.GeometryExtended2023D21Reco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D21_cff') +#process = cms.Process("HGCGeomAnalysis",eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +process = cms.Process("HGCGeomAnalysis",eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') process.load('Configuration.StandardSequences.Services_cff') process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') - -##v7 Geometry, with hex cells -process.load('Configuration.Geometry.GeometryExtended2023D3Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2023D3_cff') -process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -##Global Tag used for production in -## /uscms_data/d3/mhaytmyr/CMSSW_8_0_0_pre4/src/RecoLocalCalo/HGCalRecProducers/test/testHGCalRecoLocal_cfg.py -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HGCalValid') + process.MessageLogger.categories.append('HGCalGeom') process.MessageLogger.cerr.FwkReport.reportEvery = 100 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - 'file:testHGCalSimWatcher.root', + 'file:testHGCalSimWatcherV10.root', ) ) -process.load('Validation.HGCalValidation.hgcGeomCheck_cfi') +process.load('Validation.HGCalValidation.hgcGeomCheck_cff') process.TFileService = cms.Service("TFileService", - fileName = cms.string('hgcGeomCheck.root'), + fileName = cms.string('hgcGeomCheckV10.root'), closeFileFast = cms.untracked.bool(True) ) diff --git a/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py index f4cf8db7cdaa9..0ee11d07d4f7a 100644 --- a/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py @@ -1,11 +1,15 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('PROD',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') + +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -process.load('Configuration.Geometry.GeometryExtended2023D28_cff') -process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') process.load("Configuration.StandardSequences.MagneticField_cff") process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.StandardSequences.RawToDigi_cff') @@ -14,8 +18,8 @@ from Configuration.AlCa.autoCond import autoCond process.GlobalTag.globaltag = autoCond['phase2_realistic'] -if hasattr(process,'MessageLogger'): - process.MessageLogger.categories.append('HGCalValidation') +#if hasattr(process,'MessageLogger'): +# process.MessageLogger.categories.append('HGCalValidation') process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( diff --git a/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py index df908aa72cf5d..16ba54e018a08 100644 --- a/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py @@ -2,14 +2,19 @@ import FWCore.Utilities.FileUtils as FileUtils from Configuration.StandardSequences.Eras import eras -process = cms.Process('HGCGeomAnalysis',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') + +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag @@ -34,7 +39,7 @@ process.hgcalRecHitStudyBH.Verbosity = 0 process.TFileService = cms.Service("TFileService", - fileName = cms.string('rechitStudy.root'), + fileName = cms.string('hgcRecHit.root'), closeFileFast = cms.untracked.bool(True) ) diff --git a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py index 46d4ac61900df..17ae86564f9d5 100644 --- a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py @@ -1,14 +1,14 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('PROD',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') + +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") -process.load('Configuration.Geometry.GeometryExtended2023D28_cff') -#process.load("Geometry.HGCalCommonData.testHGCV9XML_cfi") -#process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi") -#process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi") process.load("Configuration.StandardSequences.MagneticField_cff") process.load("Configuration.EventContent.EventContent_cff") process.load('Configuration.StandardSequences.Generator_cff') @@ -19,10 +19,10 @@ from Configuration.AlCa.autoCond import autoCond process.GlobalTag.globaltag = autoCond['phase2_realistic'] -if hasattr(process,'MessageLogger'): - process.MessageLogger.categories.append('HGCalGeom') - process.MessageLogger.categories.append('HGCSim') - process.MessageLogger.categories.append('HGCalValidation') +#if hasattr(process,'MessageLogger'): +# process.MessageLogger.categories.append('HGCalGeom') +# process.MessageLogger.categories.append('HGCSim') +# process.MessageLogger.categories.append('HGCalValidation') process.load("IOMC.RandomEngine.IOMC_cff") process.RandomNumberGeneratorService.generator.initialSeed = 456789 diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py index 3932b9296037b..bfc390bf4b3df 100644 --- a/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py @@ -32,6 +32,10 @@ ) process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') + # Input source process.source = cms.Source("EmptySource") @@ -54,7 +58,7 @@ outputCommands = cms.untracked.vstring( 'keep *_*hbhe*_*_*', 'keep *_g4SimHits_*_*', - 'keep *_mix_*_*', +# 'keep *_mix_*_*', 'keep *_*HGC*_*_*', ), fileName = cms.untracked.string('file:testHGCalSimWatcherV8.root'), @@ -67,17 +71,6 @@ ) ) -process.MessageLogger = cms.Service("MessageLogger", - cout = cms.untracked.PSet( - default = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), -# ValidHGCal = cms.untracked.PSet(limit = cms.untracked.int32(0)), - ), -# categories = cms.untracked.vstring('ValidHGCal'), - destinations = cms.untracked.vstring('cout','cerr') -) - # Additional output definition process.g4SimHits.Watchers = cms.VPSet(cms.PSet( SimG4HGCalValidation = cms.PSet( diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py index 42f7879b96ea4..5e188284284e3 100644 --- a/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py @@ -33,8 +33,10 @@ input = cms.untracked.int32(1000) ) +process.MessageLogger.cerr.FwkReport.reportEvery = 5 if hasattr(process,'MessageLogger'): process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') # Input source process.source = cms.Source("EmptySource") @@ -58,7 +60,7 @@ outputCommands = cms.untracked.vstring( 'keep *_*hbhe*_*_*', 'keep *_g4SimHits_*_*', - 'keep *_mix_*_*', +# 'keep *_mix_*_*', 'keep *_*HGC*_*_*', ), fileName = cms.untracked.string('file:testHGCalSimWatcherV9.root'), From 4a07d66bbc137f64fa3d1bf7a96cb92e9f86dd41 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 28 Mar 2019 21:24:23 +0100 Subject: [PATCH 340/686] One missed file --- .../test/testHGCalSimWatcherV10_cfg.py | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py new file mode 100644 index 0000000000000..252c238725504 --- /dev/null +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py @@ -0,0 +1,153 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('testHGCalRecoLocal',eras.Phase2C4_timing_layer_bar) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('HLTrigger.Configuration.HLT_Fake2_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.RecoSim_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000) +) + +process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string(''), + annotation = cms.untracked.string(''), + name = cms.untracked.string('Applications') +) + + +# Output definition +process.output = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = cms.untracked.vstring( + 'keep *_*hbhe*_*_*', + 'keep *_g4SimHits_*_*', +# 'keep *_mix_*_*', + 'keep *_*HGC*_*_*', + ), + fileName = cms.untracked.string('file:testHGCalSimWatcherV10.root'), + dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW-RECO') + ), + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ) +) + +# Additional output definition +process.g4SimHits.Watchers = cms.VPSet(cms.PSet( + SimG4HGCalValidation = cms.PSet( + Names = cms.vstring( + 'HGCalEESensitive', + 'HGCalHESensitive', + 'HGCalHESiliconSensitive', + 'HGCalHEScintillatorSensitive', + ), + Types = cms.vint32(0,0,0,0), + DetTypes = cms.vint32(0,1,1,2), + LabelLayerInfo = cms.string("HGCalInfoLayer"), + Verbosity = cms.untracked.int32(0), + ), + type = cms.string('SimG4HGCalValidation') +)) + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + PGunParameters = cms.PSet( + MaxPt = cms.double(20.0), + MinPt = cms.double(20.0), + #PartID = cms.vint32(11), #--->electron + PartID = cms.vint32(13), #--->muon + #PartID = cms.vint32(211), #--->pion + MaxEta = cms.double(3.0), + MaxPhi = cms.double(3.14159265359), + MinEta = cms.double(1.2), + MinPhi = cms.double(-3.14159265359) + ), + Verbosity = cms.untracked.int32(0), + psethack = cms.string('single muon pt 35'), + AddAntiParticle = cms.bool(False), + firstRun = cms.untracked.uint32(1) +) + + +#Modified to produce hgceedigis +process.mix.digitizers = cms.PSet(process.theDigitizersValid) + +process.ProductionFilterSequence = cms.Sequence(process.generator) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.digitisation_step = cms.Path(process.pdigi_valid) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.digi2raw_step = cms.Path(process.DigiToRaw) +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.reconstruction_step = cms.Path(process.localreco) +process.recosim_step = cms.Path(process.recosim) +process.out_step = cms.EndPath(process.output) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step, + process.simulation_step, + process.digitisation_step, + process.L1simulation_step, + process.L1TrackTrigger_step, + process.digi2raw_step, +# process.HLTSchedule, + process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.recosim_step, + process.out_step + ) + +# filter all path with the production filter sequence +for path in process.paths: + if getattr(process,path)._seq is not None: getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq From 9fb12800abac8f28194e72be3f193ba94678fa40 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Mar 2019 23:53:15 +0100 Subject: [PATCH 341/686] lowercase for the module instance name --- RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc | 2 +- RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc index a637379cef27f..08ca2948228dc 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc @@ -189,7 +189,7 @@ PFRecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions desc.add("smearedPVsigmaZ", 0.005); desc.add("MatchingConeSize_max", 0.6); desc.add("HCALIsolConeSize_min", 0.0); - descriptions.add("PFRecoTauProducerDef", desc); + descriptions.add("pfRecoTauProducerDef", desc); } DEFINE_FWK_MODULE(PFRecoTauProducer); diff --git a/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py index f7ee2c5dd1e70..cb23b23ea5f84 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py @@ -1,4 +1,4 @@ -from RecoTauTag.RecoTau.PFRecoTauProducerDef_cfi import PFRecoTauProducerDef +from RecoTauTag.RecoTau.pfRecoTauProducerDef_cfi import pfRecoTauProducerDef -pfRecoTauProducer = PFRecoTauProducerDef.clone() +pfRecoTauProducer = pfRecoTauProducerDef.clone() From 396bb44215af7632c458163575c65ca13dab4dee Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 29 Mar 2019 09:00:37 +0100 Subject: [PATCH 342/686] moved back to AbritrationType --- DataFormats/MuonReco/interface/Muon.h | 21 ++++++---- DataFormats/MuonReco/src/Muon.cc | 55 +++++++++++++++------------ 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index ea148da96a4e5..2eb22cd5d13a0 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -238,7 +238,8 @@ namespace reco { /// number of chambers CSC or DT matches only (MuonChamberMatches include RPC rolls) int numberOfChambersCSCorDT() const; /// get number of chambers with matched segments - int numberOfMatches( unsigned int type = SegmentAndTrackArbitration ) const; + //int numberOfMatches( unsigned int type = SegmentAndTrackArbitration ) const; + int numberOfMatches( ArbitrationType type = SegmentAndTrackArbitration ) const; /// get number of stations with matched segments /// just adds the bits returned by stationMask int numberOfMatchedStations( ArbitrationType type = SegmentAndTrackArbitration ) const; @@ -248,7 +249,8 @@ namespace reco { /// get bit map of stations with matched segments /// bits 0-1-2-3 = DT stations 1-2-3-4 /// bits 4-5-6-7 = CSC stations 1-2-3-4 - unsigned int stationMask( unsigned int type = SegmentAndTrackArbitration ) const; + /* unsigned int stationMask( unsigned int type = SegmentAndTrackArbitration ) const; */ + unsigned int stationMask( ArbitrationType type = SegmentAndTrackArbitration ) const; /// get bit map of stations with tracks within /// given distance (in cm) of chamber edges /// bit assignments are same as above @@ -269,8 +271,10 @@ namespace reco { static const unsigned int GEMMuon = 1<<7; static const unsigned int ME0Muon = 1<<8; - void setType( unsigned int type ) { type_ = type; } - unsigned int type() const { return type_; } + void setType( unsigned int type ) { type_ = type; } + unsigned int type() const { return type_; } + + // override of method in base class reco::Candidate bool isMuon() const override { return true; } bool isGlobalMuon() const override { return type_ & GlobalMuon; } @@ -328,7 +332,7 @@ namespace reco { /// muon type mask unsigned int type_; - + //PF muon p4 reco::Candidate::LorentzVector pfP4_; @@ -337,13 +341,16 @@ namespace reco { /// get vector of muon chambers for given station and detector const std::vector chambers( int station, int muonSubdetId ) const; /// get pointers to best segment and corresponding chamber in vector of chambers + /* std::pair pair( const std::vector &, */ + /* unsigned int type = SegmentAndTrackArbitration ) const; */ std::pair pair( const std::vector &, - unsigned int type = SegmentAndTrackArbitration ) const; + ArbitrationType type = SegmentAndTrackArbitration ) const; /// selector bitmap unsigned int selectors_; public: /// get number of segments - int numberOfSegments( int station, int muonSubdetId, unsigned int type = SegmentAndTrackArbitration ) const; + /* int numberOfSegments( int station, int muonSubdetId, unsigned int type = SegmentAndTrackArbitration ) const; */ + int numberOfSegments( int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration ) const; /// get deltas between (best) segment and track /// If no chamber or no segment returns 999999 float dX ( int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration ) const; diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index cf79d5329b506..9a36cc445ec24 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -60,7 +60,8 @@ int Muon::numberOfChambersCSCorDT() const return total; } -int Muon::numberOfMatches( unsigned int type ) const +//int Muon::numberOfMatches( unsigned int type ) const +int Muon::numberOfMatches( ArbitrationType type ) const { int matches(0); for( std::vector::const_iterator chamberMatch = muMatches_.begin(); @@ -109,11 +110,11 @@ int Muon::numberOfMatches( unsigned int type ) const matches++; break; } - if(type > 1<<7) - if(segmentMatch->isMask(type)) { - matches++; - break; - } + // if(type > 1<<7) + // if(segmentMatch->isMask(type)) { + // matches++; + // break; + // } } } @@ -152,7 +153,8 @@ unsigned int Muon::expectedNnumberOfMatchedStations( float minDistanceFromEdge ) return n; } -unsigned int Muon::stationMask( unsigned int type ) const +// unsigned int Muon::stationMask( unsigned int type ) const +unsigned int Muon::stationMask( ArbitrationType type ) const { unsigned int totMask(0); unsigned int curMask(0); @@ -218,14 +220,14 @@ unsigned int Muon::stationMask( unsigned int type ) const totMask += curMask; break; } - if(type > 1<<7) - if(segmentMatch->isMask(type)) { - curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) ); - // do not double count - if(!(totMask & curMask)) - totMask += curMask; - break; - } + // if(type > 1<<7) + // if(segmentMatch->isMask(type)) { + // curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) ); + // // do not double count + // if(!(totMask & curMask)) + // totMask += curMask; + // break; + // } } } @@ -347,7 +349,8 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const return totMask; } -int Muon::numberOfSegments( int station, int muonSubdetId, unsigned int type ) const +// int Muon::numberOfSegments( int station, int muonSubdetId, unsigned int type ) const +int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const { int segments(0); for( std::vector::const_iterator chamberMatch = muMatches_.begin(); @@ -382,11 +385,11 @@ int Muon::numberOfSegments( int station, int muonSubdetId, unsigned int type ) c segments++; break; } - if(type > 1<<7) - if(segmentMatch->isMask(type)) { - segments++; - break; - } + // if(type > 1<<7) + // if(segmentMatch->isMask(type)) { + // segments++; + // break; + // } } } @@ -403,8 +406,10 @@ const std::vector Muon::chambers( int station, int muon return chambers; } +// std::pair Muon::pair( const std::vector &chambers, +// unsigned int type ) const std::pair Muon::pair( const std::vector &chambers, - unsigned int type ) const + ArbitrationType type ) const { MuonChamberMatch* m = nullptr; MuonSegmentMatch* s = nullptr; @@ -433,9 +438,9 @@ std::pair Muon::pair( const std segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) && segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) return std::make_pair(*chamberMatch, &(*segmentMatch)); - if(type > 1<<7) - if(segmentMatch->isMask(type)) - return std::make_pair(*chamberMatch, &(*segmentMatch)); + // if(type > 1<<7) + // if(segmentMatch->isMask(type)) + // return std::make_pair(*chamberMatch, &(*segmentMatch)); } } From e78cf0d6f38809349b816923f4600b82803e3dd7 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 27 Mar 2019 14:10:12 +0100 Subject: [PATCH 343/686] switch on simulation of the pixel bad components on the FED channel basis --- SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index a54b8f6fa2a29..9eaa7bbe3b2dc 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -36,7 +36,7 @@ def _modifyPixelDigitizerForPhase1Pixel( digitizer ) : digitizer.ElectronsPerVcal_Offset = cms.double(-60) # L2-4: -60 +- 130 digitizer.ElectronsPerVcal_L1_Offset = cms.double(-670) # L1: -670 +- 220 digitizer.UseReweighting = cms.bool(True) - + digitizer.KillBadFEDChannels = cms.bool(True) SiPixelSimBlock = cms.PSet( SiPixelQualityLabel = cms.string(''), From 5ffe308def88e2dbb0829a06b81a4006e790f7d2 Mon Sep 17 00:00:00 2001 From: tocheng Date: Fri, 29 Mar 2019 00:06:38 +0100 Subject: [PATCH 344/686] Update phase-1 MC GT to activate Simulation of the Pixel Bad Components on the FED channel basis --- Configuration/AlCa/python/autoCond.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 37da2b1479bd3..b9be61d1aff8e 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -44,29 +44,29 @@ # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v6', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v1', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '105X_mc2017_realistic_v7', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v8', + 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v8', + 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '105X_upgrade2018_design_v5', + 'phase1_2018_design' : '106X_upgrade2018_design_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v6', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v4', + 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v6', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v7', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v7', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '105X_postLS2_design_v4', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v1', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '105X_postLS2_realistic_v6', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v1', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 'phase2_realistic' : '105X_upgrade2023_realistic_v5' } From c96ac74e7149f9e0686d6a9e63889a149069901d Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 29 Mar 2019 09:33:11 +0100 Subject: [PATCH 345/686] Applied Nicola's patch for 2018 geometry. --- .../CTPPS_Diamond_Plane3.xml | 42 +++++++++---------- .../CTPPS_Diamond_Plane4.xml | 42 +++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml b/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml index 80fc0713d5443..c4a1f4333f13c 100644 --- a/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml +++ b/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane3.xml @@ -108,76 +108,76 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -185,38 +185,38 @@ - + - + - + - + - + - + @@ -225,19 +225,19 @@ - + - + - + diff --git a/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml b/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml index 16bda92ee4243..df4c25791ecbf 100644 --- a/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml +++ b/Geometry/VeryForwardData/data/CTPPS_Diamond_2018/CTPPS_Diamond_Planes/CTPPS_Diamond_Plane4.xml @@ -108,76 +108,76 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -185,38 +185,38 @@ - + - + - + - + - + - + @@ -225,19 +225,19 @@ - + - + - + From 4157aa61509557eca4f987d3189b41ee8ad53f1e Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Fri, 29 Mar 2019 09:34:49 +0100 Subject: [PATCH 346/686] Applied Nicola's patch for 2017 geometry. --- .../data/CTPPS_UFSD_Planes/CTPPS_UFSD_Plane4.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Geometry/VeryForwardData/data/CTPPS_UFSD_Planes/CTPPS_UFSD_Plane4.xml b/Geometry/VeryForwardData/data/CTPPS_UFSD_Planes/CTPPS_UFSD_Plane4.xml index 8d34b8d65b906..3b3b2eb99ee61 100644 --- a/Geometry/VeryForwardData/data/CTPPS_UFSD_Planes/CTPPS_UFSD_Plane4.xml +++ b/Geometry/VeryForwardData/data/CTPPS_UFSD_Planes/CTPPS_UFSD_Plane4.xml @@ -222,38 +222,38 @@ - + - + - + - + - + - + From 1b8389550192097ca6479174e2073198a89e1ef8 Mon Sep 17 00:00:00 2001 From: Giacomo Govi Date: Fri, 29 Mar 2019 10:19:11 +0100 Subject: [PATCH 347/686] Default db access reverted to frontier --- CondCore/Utilities/scripts/getPayloadData.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CondCore/Utilities/scripts/getPayloadData.py b/CondCore/Utilities/scripts/getPayloadData.py index c8f420e6b9054..ee7c7792a6a4d 100755 --- a/CondCore/Utilities/scripts/getPayloadData.py +++ b/CondCore/Utilities/scripts/getPayloadData.py @@ -1,6 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function import shutil import glob import json @@ -81,7 +82,13 @@ def deserialize_iovs(db, plugin_name, plot_name, tag, time_type, iovs): plot = getattr(plugin_obj, plot_name)() output('plot object: ', plot) - db_name = 'oracle://cms_orcon_adg/CMS_CONDITIONS' if db == 'Prod' else 'oracle://cms_orcoff_prep/CMS_CONDITIONS' + if db == "Prod": + db_name = 'frontier://FrontierProd/CMS_CONDITIONS' + elif db == 'Prep' : + db_name = 'frontier://FrontierPrep/CMS_CONDITIONS' + else: + db_name = db + output('full DB name: ', db_name) From c8f01c32a473c936a23ab30c8543869412ae2c6c Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 29 Mar 2019 11:21:27 +0100 Subject: [PATCH 348/686] Move the validation plugin --- .../DDCMS/data/cms-2015-muon-geometry.xml | 5 +- .../python/testDDSpecParsFilterG4ProdCuts.py | 56 ++++++++++++ DetectorDescription/DDCMS/test/runTest.sh | 15 +++- .../DTGeometryBuilder/plugins/BuildFile.xml | 3 +- .../{dd4hep => }/DTGeometryValidate.cc | 86 ++++++++----------- .../test/python/validateDTGeometry_cfg.py | 3 +- .../src/DD4hep_DTNumberingScheme.cc | 2 + 7 files changed, 111 insertions(+), 59 deletions(-) create mode 100644 DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py rename Geometry/DTGeometryBuilder/plugins/{dd4hep => }/DTGeometryValidate.cc (85%) diff --git a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml index 3edc29e248829..706aa7c43e7f5 100644 --- a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml +++ b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml @@ -1,7 +1,7 @@ - + @@ -58,6 +58,7 @@ + diff --git a/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py b/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py new file mode 100644 index 0000000000000..fd262b0847fc5 --- /dev/null +++ b/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py @@ -0,0 +1,56 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DDG4ProdCutsTest") + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.MessageLogger = cms.Service( + "MessageLogger", + statistics = cms.untracked.vstring('cout', 'g4prodcuts'), + categories = cms.untracked.vstring('Geometry'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING'), + noLineBreaks = cms.untracked.bool(True) + ), + g4prodcuts = cms.untracked.PSet( + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + threshold = cms.untracked.string('INFO'), + Geometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ) + ), + destinations = cms.untracked.vstring('cout', + 'g4prodcuts') +) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml'), + appendToDataLabel = cms.string('MUON') + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MUON') + ) + +process.test = cms.EDAnalyzer("DDTestSpecParsFilter", + DDDetector = cms.ESInputTag('MUON'), + attribute = cms.untracked.string('CMSCutsRegion'), + value = cms.untracked.string('Muon') + ) + +process.p = cms.Path(process.test) diff --git a/DetectorDescription/DDCMS/test/runTest.sh b/DetectorDescription/DDCMS/test/runTest.sh index e00361c1626c5..85dacf0547add 100755 --- a/DetectorDescription/DDCMS/test/runTest.sh +++ b/DetectorDescription/DDCMS/test/runTest.sh @@ -5,7 +5,7 @@ function die { echo $1: status $2 ; exit $2; } F1=${LOCAL_TEST_DIR}/python/dump.py F2=${LOCAL_TEST_DIR}/python/dumpDDShapes.py F3=${LOCAL_TEST_DIR}/python/dumpMFGeometry.py -F4=${LOCAL_TEST_DIR}/python/testDDAngularAlgorithm.py +F4=${LOCAL_TEST_DIR}/python/dumpMuonGeometry.py F5=${LOCAL_TEST_DIR}/python/testDDAngularAlgorithm.py F6=${LOCAL_TEST_DIR}/python/testDDDetectorESProducer.py F7=${LOCAL_TEST_DIR}/python/testDDPseudoTrapShapes.py @@ -16,7 +16,10 @@ F11=${LOCAL_TEST_DIR}/python/testMuonGeometry.py F12=${LOCAL_TEST_DIR}/python/testShapes.py F13=${LOCAL_TEST_DIR}/python/testNavigateGeometry.py F14=${LOCAL_TEST_DIR}/python/testTGeoIterator.py - +F15=${LOCAL_TEST_DIR}/python/testDDSpecParsFilterG4ProdCuts.py +F16=${LOCAL_TEST_DIR}/python/testDDSpecParsFilter.py +F17=${LOCAL_TEST_DIR}/python/testMuonNumbering.py + echo " testing DetectorDescription/DDCMS" export tmpdir=${LOCAL_TMP_DIR:-/tmp} @@ -28,7 +31,7 @@ echo "===== Test \"cmsRun dumpDDShapes.py\" ====" (cmsRun $F2) || die "Failure using cmsRun $F2" $? echo "===== Test \"cmsRun dumpMFGeometry.py\" ====" (cmsRun $F3) || die "Failure using cmsRun $F3" $? -echo "===== Test \"cmsRun testDDAngularAlgorithm.py\" ====" +echo "===== Test \"cmsRun dumpMuonGeometry.py\" ====" (cmsRun $F4) || die "Failure using cmsRun $F4" $? echo "===== Test \"cmsRun testDDAngularAlgorithm.py\" ====" (cmsRun $F5) || die "Failure using cmsRun $F5" $? @@ -50,3 +53,9 @@ echo "===== Test \"cmsRun testNavigateGeometry.py\" ====" (cmsRun $F13) || die "Failure using cmsRun $F13" $? echo "===== Test \"cmsRun testTGeoIterator.py\" ====" (cmsRun $F14) || die "Failure using cmsRun $F14" $? +echo "===== Test \"cmsRun testDDSpecParsFilterG4ProdCuts.py\" ====" +(cmsRun $F15) || die "Failure using cmsRun $F15" $? +echo "===== Test \"cmsRun testDDSpecParsFilter.py\" ====" +(cmsRun $F16) || die "Failure using cmsRun $F16" $? +echo "===== Test \"cmsRun testMuonNumbering.py\" ====" +(cmsRun $F17) || die "Failure using cmsRun $F17" $? diff --git a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml index d3dcfbb72a873..628ce793afa35 100644 --- a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml +++ b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml @@ -13,14 +13,13 @@ - + - diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc similarity index 85% rename from Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc rename to Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc index bef88c52f56c5..7d1d158f034e4 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryValidate.cc +++ b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc @@ -53,29 +53,13 @@ class DTGeometryValidate : public one::EDAnalyzer<> void validateDTLayerGeometry(); void compareTransform(const GlobalPoint&, const TGeoMatrix*); - void compareShape(const GeomDet*, const float*); - double getDistance(const GlobalPoint&, const GlobalPoint&); - double getDiff(const double, const double); + float getDistance(const GlobalPoint&, const GlobalPoint&); + float getDiff(const float, const float); void makeHistograms(const char*); - void makeHistogram(const string&, vector&); - - string infileName_; - string outfileName_; - - edm::ESHandle dtGeometry_; - - FWGeometry fwGeometry_; - - TFile* outFile_; - - vector globalDistances_; - vector topWidths_; - vector bottomWidths_; - vector lengths_; - vector thicknesses_; + void makeHistogram(const string&, vector&); void clearData() { globalDistances_.clear(); @@ -84,14 +68,25 @@ class DTGeometryValidate : public one::EDAnalyzer<> lengths_.clear(); thicknesses_.clear(); } - - int tolerance_ = 2; + + edm::ESHandle dtGeometry_; + FWGeometry fwGeometry_; + TFile* outFile_; + vector globalDistances_; + vector topWidths_; + vector bottomWidths_; + vector lengths_; + vector thicknesses_; + string infileName_; + string outfileName_; + int tolerance_; }; DTGeometryValidate::DTGeometryValidate(const edm::ParameterSet& iConfig) - : infileName_(iConfig.getUntrackedParameter("infileName")), - outfileName_(iConfig.getUntrackedParameter("outfileName")) + : infileName_(iConfig.getUntrackedParameter("infileName", "cmsGeom10.root")), + outfileName_(iConfig.getUntrackedParameter("outfileName", "validateDTGeometry.root")), + tolerance_(iConfig.getUntrackedParameter("tolerance", 6)) { fwGeometry_.loadMap(infileName_.c_str()); outFile_ = new TFile(outfileName_.c_str(), "RECREATE"); @@ -151,7 +146,7 @@ DTGeometryValidate::validateDTLayerGeometry() { clearData(); - vector wire_positions; + vector wire_positions; for(auto const& it : dtGeometry_->layers()) { DTLayerId layerId = it->id(); @@ -185,13 +180,13 @@ DTGeometryValidate::validateDTLayerGeometry() { continue; } - double width = it->surface().bounds().width(); + float width = it->surface().bounds().width(); assert(width == parameters[6]); - double thickness = it->surface().bounds().thickness(); + float thickness = it->surface().bounds().thickness(); assert(thickness == parameters[7]); - double length = it->surface().bounds().length(); + float length = it->surface().bounds().length(); assert(length == parameters[8]); int firstChannel = it->specificTopology().firstChannel(); @@ -202,8 +197,8 @@ DTGeometryValidate::validateDTLayerGeometry() { assert(nChannels == (lastChannel-firstChannel)+1); for(int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) { - double localX1 = it->specificTopology().wirePosition(wireN); - double localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0]; + float localX1 = it->specificTopology().wirePosition(wireN); + float localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0]; wire_positions.emplace_back(getDiff(localX1, localX2)); } } @@ -212,7 +207,7 @@ DTGeometryValidate::validateDTLayerGeometry() { makeHistograms("DT Layer"); } -void +void DTGeometryValidate::compareTransform(const GlobalPoint& gp, const TGeoMatrix* matrix) { @@ -221,7 +216,7 @@ DTGeometryValidate::compareTransform(const GlobalPoint& gp, matrix->LocalToMaster(local, global); - double distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp); + float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp); globalDistances_.push_back(distance); } @@ -280,11 +275,9 @@ DTGeometryValidate::compareShape(const GeomDet* det, const float* shape) bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth)); lengths_.push_back(fabs(shapeLength - length)); thicknesses_.push_back(fabs(shapeThickness - thickness)); - - return; } -double +float DTGeometryValidate::getDistance(const GlobalPoint& p1, const GlobalPoint& p2) { return sqrt((p1.x()-p2.x())*(p1.x()-p2.x())+ @@ -292,11 +285,10 @@ DTGeometryValidate::getDistance(const GlobalPoint& p1, const GlobalPoint& p2) (p1.z()-p2.z())*(p1.z()-p2.z())); } - -double -DTGeometryValidate::getDiff(const double val1, const double val2) { +float +DTGeometryValidate::getDiff(const float val1, const float val2) { if(almost_equal(val1, val2, tolerance_)) - return double(0.0); + return 0.0f; else return (val1 - val2); } @@ -325,26 +317,18 @@ DTGeometryValidate::makeHistograms(const char* detector) } void -DTGeometryValidate::makeHistogram(const string& name, vector& data) +DTGeometryValidate::makeHistogram(const string& name, vector& data) { if(data.empty()) return; - vector::iterator it; + const auto [minE, maxE] = minmax_element(begin(data), end(data)); - it = min_element(data.begin(), data.end()); - double minE = *it; - - it = max_element(data.begin(), data.end()); - double maxE = *it; + TH1D hist(name.c_str(), name.c_str(), 100, *minE*(1+0.10), *maxE*(1+0.10)); - vector::iterator itEnd = data.end(); - - TH1D hist(name.c_str(), name.c_str(), 100, minE*(1+0.10), maxE*(1+0.10)); + for(auto const& it : data) + hist.Fill(it); - for( it = data.begin(); it != itEnd; ++it ) - hist.Fill(*it); - hist.GetXaxis()->SetTitle("[cm]"); hist.Write(); } diff --git a/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py index d023af7948461..3da0f0b96a1ab 100644 --- a/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py +++ b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py @@ -39,7 +39,8 @@ # process.valid = cms.EDAnalyzer("DTGeometryValidate", infileName = cms.untracked.string('cmsGeom10.root'), - outfileName = cms.untracked.string('validateDTGeometry.root') + outfileName = cms.untracked.string('validateDTGeometry.root'), + tolerance = cms.untracked.int32(7) ) process.p = cms.Path(process.valid) diff --git a/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc index e16ca48728266..512f0b1262c52 100644 --- a/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc +++ b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc @@ -2,6 +2,7 @@ #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include "DataFormats/MuonDetId/interface/DTWireId.h" #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" +#include using namespace cms; @@ -12,6 +13,7 @@ DTNumberingScheme::DTNumberingScheme(const MuonConstants& muonConstants) { void DTNumberingScheme::initMe(const MuonConstants& muonConstants) { int levelPart = get("level", muonConstants); + assert(levelPart != 0); theRegionLevel = get("mb_region", muonConstants)/levelPart; theWheelLevel = get("mb_wheel", muonConstants)/levelPart; theStationLevel = get("mb_station", muonConstants)/levelPart; From 0719e7fbb22f3d78ba1eb388277c62595a181196 Mon Sep 17 00:00:00 2001 From: Huilin Qu Date: Thu, 28 Mar 2019 20:34:43 +0100 Subject: [PATCH 349/686] Update DeepBoostedJet tagger to V02. --- .../plugins/DeepBoostedJetTagsProducer.cc | 8 +- .../pfDeepBoostedJetPreprocessParams_cfi.py | 190 ++++++------ RecoBTag/MXNet/python/pfDeepBoostedJet_cff.py | 11 +- ...latedDeepBoostedJetPreprocessParams_cfi.py | 279 ++++++++++++++++++ 4 files changed, 384 insertions(+), 104 deletions(-) create mode 100644 RecoBTag/MXNet/python/pfMassDecorrelatedDeepBoostedJetPreprocessParams_cfi.py diff --git a/RecoBTag/MXNet/plugins/DeepBoostedJetTagsProducer.cc b/RecoBTag/MXNet/plugins/DeepBoostedJetTagsProducer.cc index f8c8773e37314..90b9b576c5ca9 100644 --- a/RecoBTag/MXNet/plugins/DeepBoostedJetTagsProducer.cc +++ b/RecoBTag/MXNet/plugins/DeepBoostedJetTagsProducer.cc @@ -31,8 +31,8 @@ struct MXBlockCache { struct PreprocessParams { struct VarInfo { VarInfo() {} - VarInfo(float median, float upper) : - center(median), norm_factor(upper==median ? 1 : 1./(upper-median)) {} + VarInfo(float median, float norm_factor) : + center(median), norm_factor(norm_factor) {} float center = 0; float norm_factor = 1; }; @@ -107,8 +107,8 @@ DeepBoostedJetTagsProducer::DeepBoostedJetTagsProducer(const edm::ParameterSet& for (const auto &var_name : prep_params.var_names){ const auto &var_pset = var_info_pset.getParameterSet(var_name); double median = var_pset.getParameter("median"); - double upper = var_pset.getParameter("upper"); - prep_params.var_info_map[var_name] = PreprocessParams::VarInfo(median, upper); + double norm_factor = var_pset.getParameter("norm_factor"); + prep_params.var_info_map[var_name] = PreprocessParams::VarInfo(median, norm_factor); } // create data storage with a fixed size vector initilized w/ 0 diff --git a/RecoBTag/MXNet/python/pfDeepBoostedJetPreprocessParams_cfi.py b/RecoBTag/MXNet/python/pfDeepBoostedJetPreprocessParams_cfi.py index cb709a2794a95..3c48f0b7fadc1 100644 --- a/RecoBTag/MXNet/python/pfDeepBoostedJetPreprocessParams_cfi.py +++ b/RecoBTag/MXNet/python/pfDeepBoostedJetPreprocessParams_cfi.py @@ -10,171 +10,171 @@ var_infos = cms.PSet( pfcand_VTX_ass = cms.PSet( median = cms.double(7.0), - upper = cms.double(7.0) + norm_factor = cms.double(1.0) ), pfcand_abseta = cms.PSet( - median = cms.double(0.599505603313), - upper = cms.double(1.21494185925) + median = cms.double(0.632648706436), + norm_factor = cms.double(1.59032225958) ), pfcand_btagEtaRel = cms.PSet( - median = cms.double(0.0), - upper = cms.double(3.23048327446) + median = cms.double(1.19703966379), + norm_factor = cms.double(0.521026991705) ), pfcand_btagJetDistVal = cms.PSet( - median = cms.double(0.0), - upper = cms.double(0.0) + median = cms.double(-0.000215483247302), + norm_factor = cms.double(161.385119349) ), pfcand_btagPParRatio = cms.PSet( - median = cms.double(0.0), - upper = cms.double(0.997295975685) + median = cms.double(0.839023888111), + norm_factor = cms.double(1.19186117841) ), pfcand_btagPtRatio = cms.PSet( - median = cms.double(0.0), - upper = cms.double(0.174372568727) + median = cms.double(0.0173742230982), + norm_factor = cms.double(4.25351138308) ), pfcand_btagSip2dSig = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.565274050236) + norm_factor = cms.double(1.41174531059) ), pfcand_btagSip2dVal = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.00165283482056) + norm_factor = cms.double(495.583709284) ), pfcand_btagSip3dSig = cms.PSet( median = cms.double(0.0), - upper = cms.double(1.03450630188) + norm_factor = cms.double(0.831133090749) ), pfcand_btagSip3dVal = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.00417172765359) + norm_factor = cms.double(233.664322627) ), pfcand_charge = cms.PSet( median = cms.double(0.0), - upper = cms.double(1.0) + norm_factor = cms.double(1.0) ), pfcand_deltaR = cms.PSet( - median = cms.double(0.22575956583), - upper = cms.double(0.488191870451) + median = cms.double(0.252654820681), + norm_factor = cms.double(3.50836328292) ), pfcand_detadeta = cms.PSet( - median = cms.double(0.0), - upper = cms.double(5.08303287461e-07) + median = cms.double(1.15567200254e-08), + norm_factor = cms.double(1644010.14927) ), pfcand_dlambdadz = cms.PSet( - median = cms.double(0.0), - upper = cms.double(0.0) + median = cms.double(-1.2810873784e-07), + norm_factor = cms.double(268715.13012) ), pfcand_dphidphi = cms.PSet( - median = cms.double(0.0), - upper = cms.double(7.63271316373e-07) + median = cms.double(1.130510352e-08), + norm_factor = cms.double(796482.476472) ), pfcand_dphidxy = cms.PSet( - median = cms.double(0.0), - upper = cms.double(0.0) + median = cms.double(-9.61654578191e-08), + norm_factor = cms.double(204149.346943) ), pfcand_dptdpt = cms.PSet( - median = cms.double(0.0), - upper = cms.double(6.11870564171e-06) + median = cms.double(4.11880840545e-08), + norm_factor = cms.double(66429.1000843) ), pfcand_drminsv = cms.PSet( - median = cms.double(0.177426457405), - upper = cms.double(0.555181086063) + median = cms.double(0.192182734609), + norm_factor = cms.double(2.38205282141) ), pfcand_drsubjet1 = cms.PSet( - median = cms.double(0.231124095619), - upper = cms.double(0.549522156715) + median = cms.double(0.258241385221), + norm_factor = cms.double(2.92607580997) ), pfcand_drsubjet2 = cms.PSet( - median = cms.double(0.263272643089), - upper = cms.double(0.605471189022) + median = cms.double(0.305164307356), + norm_factor = cms.double(2.88195895791) ), pfcand_dxy = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.00254638679326) + norm_factor = cms.double(415.415835966) ), pfcand_dxydxy = cms.PSet( - median = cms.double(0.0), - upper = cms.double(2.14965821215e-05) + median = cms.double(9.32332170578e-07), + norm_factor = cms.double(45949.2394216) ), pfcand_dxydz = cms.PSet( median = cms.double(0.0), - upper = cms.double(1.31130221348e-07) + norm_factor = cms.double(10598589.4298) ), pfcand_dxysig = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.496566288471) + norm_factor = cms.double(1.54565964258) ), pfcand_dz = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.00448730448261) + norm_factor = cms.double(264.770519024) ), pfcand_dzdz = cms.PSet( - median = cms.double(0.0), - upper = cms.double(3.40332044289e-05) + median = cms.double(1.58729170607e-06), + norm_factor = cms.double(36545.958354) ), pfcand_dzsig = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.596591930389) + norm_factor = cms.double(1.23840120847) ), pfcand_erel_log = cms.PSet( - median = cms.double(-5.38983869553), - upper = cms.double(-3.53490426064) + median = cms.double(-5.38221979141), + norm_factor = cms.double(0.556499386531) ), pfcand_etarel = cms.PSet( - median = cms.double(-0.0054658302106), - upper = cms.double(0.174858552814) + median = cms.double(-0.00711047858931), + norm_factor = cms.double(4.2642743837) ), pfcand_hcalFrac = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.0) + norm_factor = cms.double(1.0) ), pfcand_isChargedHad = cms.PSet( median = cms.double(1.0), - upper = cms.double(1.0) + norm_factor = cms.double(1.0) ), pfcand_isEl = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.0) + norm_factor = cms.double(1.0) ), pfcand_isGamma = cms.PSet( median = cms.double(0.0), - upper = cms.double(1.0) + norm_factor = cms.double(1.0) ), pfcand_isMu = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.0) + norm_factor = cms.double(1.0) ), pfcand_isNeutralHad = cms.PSet( median = cms.double(0.0), - upper = cms.double(0.0) + norm_factor = cms.double(1.0) ), pfcand_lostInnerHits = cms.PSet( median = cms.double(-1.0), - upper = cms.double(-1.0) + norm_factor = cms.double(1.0) ), pfcand_normchi2 = cms.PSet( - median = cms.double(999.0), - upper = cms.double(999.0) + median = cms.double(2.0), + norm_factor = cms.double(0.00100300902708) ), pfcand_phirel = cms.PSet( - median = cms.double(-5.10289683007e-05), - upper = cms.double(0.215602903366) + median = cms.double(-1.71389010575e-05), + norm_factor = cms.double(4.22784626632) ), pfcand_pt_log = cms.PSet( - median = cms.double(1.09469842911), - upper = cms.double(3.02194809914) + median = cms.double(1.03476798534), + norm_factor = cms.double(0.542224410728) ), pfcand_ptrel_log = cms.PSet( - median = cms.double(-5.38205528259), - upper = cms.double(-3.52304198265) + median = cms.double(-5.37407469749), + norm_factor = cms.double(0.554677114485) ), pfcand_puppiw = cms.PSet( median = cms.double(1.0), - upper = cms.double(1.0) + norm_factor = cms.double(255.000015199) ), pfcand_quality = cms.PSet( - median = cms.double(0.0), - upper = cms.double(5.0) + median = cms.double(5.0), + norm_factor = cms.double(0.2) ) ), var_length = cms.uint32(100), @@ -227,64 +227,64 @@ input_shape = cms.vuint32(1, 15, 7, 1), var_infos = cms.PSet( sv_abseta = cms.PSet( - median = cms.double(0.579698801041), - upper = cms.double(1.2257443285) + median = cms.double(0.616221785545), + norm_factor = cms.double(1.49676942133) ), sv_costhetasvpv = cms.PSet( - median = cms.double(0.999744534492), - upper = cms.double(0.999992311001) + median = cms.double(0.999747157097), + norm_factor = cms.double(174.907183727) ), sv_d3d = cms.PSet( - median = cms.double(0.496477723122), - upper = cms.double(4.83165483475) + median = cms.double(0.5242870152), + norm_factor = cms.double(0.255813267634) ), sv_d3dsig = cms.PSet( - median = cms.double(6.50515079498), - upper = cms.double(36.9069334412) + median = cms.double(9.12465429306), + norm_factor = cms.double(0.0238374692882) ), sv_deltaR = cms.PSet( - median = cms.double(0.105607174337), - upper = cms.double(0.323846782446) + median = cms.double(0.140969499946), + norm_factor = cms.double(4.30546783192) ), sv_dxy = cms.PSet( - median = cms.double(0.369336694479), - upper = cms.double(3.97735537529) + median = cms.double(0.387232214212), + norm_factor = cms.double(0.360931771841) ), sv_dxysig = cms.PSet( - median = cms.double(6.49603271484), - upper = cms.double(36.8943783569) + median = cms.double(9.11130714417), + norm_factor = cms.double(0.0238327380073) ), sv_erel_log = cms.PSet( - median = cms.double(-2.77275466919), - upper = cms.double(-1.7486346817) + median = cms.double(-2.82667005062), + norm_factor = cms.double(0.704463981589) ), sv_etarel = cms.PSet( - median = cms.double(-0.00318800867535), - upper = cms.double(0.0951088288426) + median = cms.double(-0.0037129354896), + norm_factor = cms.double(6.99426943996) ), sv_mass = cms.PSet( - median = cms.double(1.36728298664), - upper = cms.double(4.75960615158) + median = cms.double(1.34319722652), + norm_factor = cms.double(0.368495534421) ), sv_normchi2 = cms.PSet( - median = cms.double(0.796081960201), - upper = cms.double(2.15187430382) + median = cms.double(0.819934427738), + norm_factor = cms.double(0.725797320076) ), sv_ntracks = cms.PSet( median = cms.double(3.0), - upper = cms.double(5.0) + norm_factor = cms.double(0.5) ), sv_phirel = cms.PSet( - median = cms.double(0.000510219600983), - upper = cms.double(0.110185634494) + median = cms.double(0.000521215377375), + norm_factor = cms.double(7.16761972364) ), sv_pt_log = cms.PSet( - median = cms.double(3.77797603607), - upper = cms.double(4.90166530609) + median = cms.double(3.64881515503), + norm_factor = cms.double(0.725050067872) ), sv_ptrel_log = cms.PSet( - median = cms.double(-2.7622461319), - upper = cms.double(-1.73727185726) + median = cms.double(-2.81496477127), + norm_factor = cms.double(0.701236308041) ) ), var_length = cms.uint32(7), @@ -306,4 +306,4 @@ 'sv_costhetasvpv' ) ) -) +) \ No newline at end of file diff --git a/RecoBTag/MXNet/python/pfDeepBoostedJet_cff.py b/RecoBTag/MXNet/python/pfDeepBoostedJet_cff.py index f8915d164f9d3..8bcf98eed49c8 100644 --- a/RecoBTag/MXNet/python/pfDeepBoostedJet_cff.py +++ b/RecoBTag/MXNet/python/pfDeepBoostedJet_cff.py @@ -3,22 +3,23 @@ from RecoBTag.FeatureTools.pfDeepBoostedJetTagInfos_cfi import pfDeepBoostedJetTagInfos from RecoBTag.MXNet.pfDeepBoostedJetTags_cfi import pfDeepBoostedJetTags as _pfDeepBoostedJetTags from RecoBTag.MXNet.pfDeepBoostedJetPreprocessParams_cfi import pfDeepBoostedJetPreprocessParams +from RecoBTag.MXNet.pfMassDecorrelatedDeepBoostedJetPreprocessParams_cfi import pfMassDecorrelatedDeepBoostedJetPreprocessParams from RecoBTag.MXNet.pfDeepBoostedDiscriminatorsJetTags_cfi import pfDeepBoostedDiscriminatorsJetTags from RecoBTag.MXNet.pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags_cfi import pfMassDecorrelatedDeepBoostedDiscriminatorsJetTags # nominal DeepAK8 pfDeepBoostedJetTags = _pfDeepBoostedJetTags.clone( preprocessParams = pfDeepBoostedJetPreprocessParams, - model_path = 'RecoBTag/Combined/data/DeepBoostedJet/V01/full/resnet-symbol.json', - param_path = 'RecoBTag/Combined/data/DeepBoostedJet/V01/full/resnet-0000.params', + model_path = 'RecoBTag/Combined/data/DeepBoostedJet/V02/full/resnet-symbol.json', + param_path = 'RecoBTag/Combined/data/DeepBoostedJet/V02/full/resnet-0000.params', debugMode = False, # debug ) # mass-decorrelated DeepAK8 pfMassDecorrelatedDeepBoostedJetTags = _pfDeepBoostedJetTags.clone( - preprocessParams = pfDeepBoostedJetPreprocessParams, - model_path = 'RecoBTag/Combined/data/DeepBoostedJet/V01/decorrelated/resnet-symbol.json', - param_path = 'RecoBTag/Combined/data/DeepBoostedJet/V01/decorrelated/resnet-0000.params', + preprocessParams = pfMassDecorrelatedDeepBoostedJetPreprocessParams, + model_path = 'RecoBTag/Combined/data/DeepBoostedJet/V02/decorrelated/resnet-symbol.json', + param_path = 'RecoBTag/Combined/data/DeepBoostedJet/V02/decorrelated/resnet-0000.params', debugMode = False, # debug ) diff --git a/RecoBTag/MXNet/python/pfMassDecorrelatedDeepBoostedJetPreprocessParams_cfi.py b/RecoBTag/MXNet/python/pfMassDecorrelatedDeepBoostedJetPreprocessParams_cfi.py new file mode 100644 index 0000000000000..f94ee430e407b --- /dev/null +++ b/RecoBTag/MXNet/python/pfMassDecorrelatedDeepBoostedJetPreprocessParams_cfi.py @@ -0,0 +1,279 @@ +import FWCore.ParameterSet.Config as cms + +pfMassDecorrelatedDeepBoostedJetPreprocessParams = cms.PSet( + input_names = cms.vstring( + 'pfcand', + 'sv' + ), + pfcand = cms.PSet( + input_shape = cms.vuint32(1, 36, 100, 1), + var_infos = cms.PSet( + pfcand_VTX_ass = cms.PSet( + median = cms.double(7.0), + norm_factor = cms.double(1.0) + ), + pfcand_abseta = cms.PSet( + median = cms.double(0.632648706436), + norm_factor = cms.double(1.59032225958) + ), + pfcand_btagEtaRel = cms.PSet( + median = cms.double(1.19703966379), + norm_factor = cms.double(0.521026991705) + ), + pfcand_btagJetDistVal = cms.PSet( + median = cms.double(-0.000215483247302), + norm_factor = cms.double(161.385119349) + ), + pfcand_btagPParRatio = cms.PSet( + median = cms.double(0.839023888111), + norm_factor = cms.double(1.19186117841) + ), + pfcand_btagPtRatio = cms.PSet( + median = cms.double(0.0173742230982), + norm_factor = cms.double(4.25351138308) + ), + pfcand_btagSip2dSig = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(1.41174531059) + ), + pfcand_btagSip2dVal = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(495.583709284) + ), + pfcand_btagSip3dSig = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(0.831133090749) + ), + pfcand_btagSip3dVal = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(233.664322627) + ), + pfcand_charge = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(1.0) + ), + pfcand_deltaR = cms.PSet( + median = cms.double(0.252654820681), + norm_factor = cms.double(3.50836328292) + ), + pfcand_detadeta = cms.PSet( + median = cms.double(1.15567200254e-08), + norm_factor = cms.double(1644010.14927) + ), + pfcand_dlambdadz = cms.PSet( + median = cms.double(-1.2810873784e-07), + norm_factor = cms.double(268715.13012) + ), + pfcand_dphidphi = cms.PSet( + median = cms.double(1.130510352e-08), + norm_factor = cms.double(796482.476472) + ), + pfcand_dphidxy = cms.PSet( + median = cms.double(-9.61654578191e-08), + norm_factor = cms.double(204149.346943) + ), + pfcand_dptdpt = cms.PSet( + median = cms.double(4.11880840545e-08), + norm_factor = cms.double(66429.1000843) + ), + pfcand_drminsv = cms.PSet( + median = cms.double(0.192182734609), + norm_factor = cms.double(2.38205282141) + ), + pfcand_drsubjet1 = cms.PSet( + median = cms.double(0.258241385221), + norm_factor = cms.double(2.92607580997) + ), + pfcand_drsubjet2 = cms.PSet( + median = cms.double(0.305164307356), + norm_factor = cms.double(2.88195895791) + ), + pfcand_dxy = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(415.415835966) + ), + pfcand_dxydxy = cms.PSet( + median = cms.double(9.32332170578e-07), + norm_factor = cms.double(45949.2394216) + ), + pfcand_dxydz = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(10598589.4298) + ), + pfcand_dxysig = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(1.54565964258) + ), + pfcand_dz = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(264.770519024) + ), + pfcand_dzdz = cms.PSet( + median = cms.double(1.58729170607e-06), + norm_factor = cms.double(36545.958354) + ), + pfcand_dzsig = cms.PSet( + median = cms.double(0.0), + norm_factor = cms.double(1.23840120847) + ), + pfcand_erel_log = cms.PSet( + median = cms.double(-5.38221979141), + norm_factor = cms.double(0.556499386531) + ), + pfcand_etarel = cms.PSet( + median = cms.double(-0.00711047858931), + norm_factor = cms.double(4.2642743837) + ), + pfcand_lostInnerHits = cms.PSet( + median = cms.double(-1.0), + norm_factor = cms.double(1.0) + ), + pfcand_normchi2 = cms.PSet( + median = cms.double(2.0), + norm_factor = cms.double(0.00100300902708) + ), + pfcand_phirel = cms.PSet( + median = cms.double(-1.71389010575e-05), + norm_factor = cms.double(4.22784626632) + ), + pfcand_pt_log = cms.PSet( + median = cms.double(1.03476798534), + norm_factor = cms.double(0.542224410728) + ), + pfcand_ptrel_log = cms.PSet( + median = cms.double(-5.37407469749), + norm_factor = cms.double(0.554677114485) + ), + pfcand_puppiw = cms.PSet( + median = cms.double(1.0), + norm_factor = cms.double(255.000015199) + ), + pfcand_quality = cms.PSet( + median = cms.double(5.0), + norm_factor = cms.double(0.2) + ) + ), + var_length = cms.uint32(100), + var_names = cms.vstring( + 'pfcand_pt_log', + 'pfcand_ptrel_log', + 'pfcand_erel_log', + 'pfcand_phirel', + 'pfcand_etarel', + 'pfcand_deltaR', + 'pfcand_abseta', + 'pfcand_puppiw', + 'pfcand_drminsv', + 'pfcand_drsubjet1', + 'pfcand_drsubjet2', + 'pfcand_charge', + 'pfcand_VTX_ass', + 'pfcand_lostInnerHits', + 'pfcand_normchi2', + 'pfcand_quality', + 'pfcand_dz', + 'pfcand_dzsig', + 'pfcand_dxy', + 'pfcand_dxysig', + 'pfcand_dptdpt', + 'pfcand_detadeta', + 'pfcand_dphidphi', + 'pfcand_dxydxy', + 'pfcand_dzdz', + 'pfcand_dxydz', + 'pfcand_dphidxy', + 'pfcand_dlambdadz', + 'pfcand_btagEtaRel', + 'pfcand_btagPtRatio', + 'pfcand_btagPParRatio', + 'pfcand_btagSip2dVal', + 'pfcand_btagSip2dSig', + 'pfcand_btagSip3dVal', + 'pfcand_btagSip3dSig', + 'pfcand_btagJetDistVal' + ) + ), + sv = cms.PSet( + input_shape = cms.vuint32(1, 15, 7, 1), + var_infos = cms.PSet( + sv_abseta = cms.PSet( + median = cms.double(0.616221785545), + norm_factor = cms.double(1.49676942133) + ), + sv_costhetasvpv = cms.PSet( + median = cms.double(0.999747157097), + norm_factor = cms.double(174.907183727) + ), + sv_d3d = cms.PSet( + median = cms.double(0.5242870152), + norm_factor = cms.double(0.255813267634) + ), + sv_d3dsig = cms.PSet( + median = cms.double(9.12465429306), + norm_factor = cms.double(0.0238374692882) + ), + sv_deltaR = cms.PSet( + median = cms.double(0.140969499946), + norm_factor = cms.double(4.30546783192) + ), + sv_dxy = cms.PSet( + median = cms.double(0.387232214212), + norm_factor = cms.double(0.360931771841) + ), + sv_dxysig = cms.PSet( + median = cms.double(9.11130714417), + norm_factor = cms.double(0.0238327380073) + ), + sv_erel_log = cms.PSet( + median = cms.double(-2.82667005062), + norm_factor = cms.double(0.704463981589) + ), + sv_etarel = cms.PSet( + median = cms.double(-0.0037129354896), + norm_factor = cms.double(6.99426943996) + ), + sv_mass = cms.PSet( + median = cms.double(1.34319722652), + norm_factor = cms.double(0.368495534421) + ), + sv_normchi2 = cms.PSet( + median = cms.double(0.819934427738), + norm_factor = cms.double(0.725797320076) + ), + sv_ntracks = cms.PSet( + median = cms.double(3.0), + norm_factor = cms.double(0.5) + ), + sv_phirel = cms.PSet( + median = cms.double(0.000521215377375), + norm_factor = cms.double(7.16761972364) + ), + sv_pt_log = cms.PSet( + median = cms.double(3.64881515503), + norm_factor = cms.double(0.725050067872) + ), + sv_ptrel_log = cms.PSet( + median = cms.double(-2.81496477127), + norm_factor = cms.double(0.701236308041) + ) + ), + var_length = cms.uint32(7), + var_names = cms.vstring( + 'sv_pt_log', + 'sv_ptrel_log', + 'sv_erel_log', + 'sv_phirel', + 'sv_etarel', + 'sv_deltaR', + 'sv_abseta', + 'sv_mass', + 'sv_ntracks', + 'sv_normchi2', + 'sv_dxy', + 'sv_dxysig', + 'sv_d3d', + 'sv_d3dsig', + 'sv_costhetasvpv' + ) + ) +) \ No newline at end of file From 908922850ceac9fb50ade6806fe02d7a33a668ac Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 29 Mar 2019 13:46:41 +0100 Subject: [PATCH 350/686] Moved back to ArbitrationType --- DataFormats/MuonReco/interface/Muon.h | 5 ----- DataFormats/MuonReco/src/Muon.cc | 26 -------------------------- 2 files changed, 31 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index 2eb22cd5d13a0..4d92856f8b843 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -238,7 +238,6 @@ namespace reco { /// number of chambers CSC or DT matches only (MuonChamberMatches include RPC rolls) int numberOfChambersCSCorDT() const; /// get number of chambers with matched segments - //int numberOfMatches( unsigned int type = SegmentAndTrackArbitration ) const; int numberOfMatches( ArbitrationType type = SegmentAndTrackArbitration ) const; /// get number of stations with matched segments /// just adds the bits returned by stationMask @@ -249,7 +248,6 @@ namespace reco { /// get bit map of stations with matched segments /// bits 0-1-2-3 = DT stations 1-2-3-4 /// bits 4-5-6-7 = CSC stations 1-2-3-4 - /* unsigned int stationMask( unsigned int type = SegmentAndTrackArbitration ) const; */ unsigned int stationMask( ArbitrationType type = SegmentAndTrackArbitration ) const; /// get bit map of stations with tracks within /// given distance (in cm) of chamber edges @@ -341,15 +339,12 @@ namespace reco { /// get vector of muon chambers for given station and detector const std::vector chambers( int station, int muonSubdetId ) const; /// get pointers to best segment and corresponding chamber in vector of chambers - /* std::pair pair( const std::vector &, */ - /* unsigned int type = SegmentAndTrackArbitration ) const; */ std::pair pair( const std::vector &, ArbitrationType type = SegmentAndTrackArbitration ) const; /// selector bitmap unsigned int selectors_; public: /// get number of segments - /* int numberOfSegments( int station, int muonSubdetId, unsigned int type = SegmentAndTrackArbitration ) const; */ int numberOfSegments( int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration ) const; /// get deltas between (best) segment and track /// If no chamber or no segment returns 999999 diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index 9a36cc445ec24..c6103c6b86fb6 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -60,7 +60,6 @@ int Muon::numberOfChambersCSCorDT() const return total; } -//int Muon::numberOfMatches( unsigned int type ) const int Muon::numberOfMatches( ArbitrationType type ) const { int matches(0); @@ -110,11 +109,6 @@ int Muon::numberOfMatches( ArbitrationType type ) const matches++; break; } - // if(type > 1<<7) - // if(segmentMatch->isMask(type)) { - // matches++; - // break; - // } } } @@ -153,7 +147,6 @@ unsigned int Muon::expectedNnumberOfMatchedStations( float minDistanceFromEdge ) return n; } -// unsigned int Muon::stationMask( unsigned int type ) const unsigned int Muon::stationMask( ArbitrationType type ) const { unsigned int totMask(0); @@ -220,14 +213,6 @@ unsigned int Muon::stationMask( ArbitrationType type ) const totMask += curMask; break; } - // if(type > 1<<7) - // if(segmentMatch->isMask(type)) { - // curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) ); - // // do not double count - // if(!(totMask & curMask)) - // totMask += curMask; - // break; - // } } } @@ -349,7 +334,6 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const return totMask; } -// int Muon::numberOfSegments( int station, int muonSubdetId, unsigned int type ) const int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const { int segments(0); @@ -385,11 +369,6 @@ int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type segments++; break; } - // if(type > 1<<7) - // if(segmentMatch->isMask(type)) { - // segments++; - // break; - // } } } @@ -406,8 +385,6 @@ const std::vector Muon::chambers( int station, int muon return chambers; } -// std::pair Muon::pair( const std::vector &chambers, -// unsigned int type ) const std::pair Muon::pair( const std::vector &chambers, ArbitrationType type ) const { @@ -438,9 +415,6 @@ std::pair Muon::pair( const std segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) && segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) return std::make_pair(*chamberMatch, &(*segmentMatch)); - // if(type > 1<<7) - // if(segmentMatch->isMask(type)) - // return std::make_pair(*chamberMatch, &(*segmentMatch)); } } From 18619a85b994fffc76f1bb9a0bcc129249c5cd1e Mon Sep 17 00:00:00 2001 From: tonydp03 Date: Fri, 29 Mar 2019 15:02:09 +0100 Subject: [PATCH 351/686] Moving Energy smearing to particles in the same event --- IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc index 8821dc0c9ea36..442364a42cf73 100644 --- a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc +++ b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc @@ -68,7 +68,6 @@ void CloseByParticleGunProducer::produce(Event &e, const EventSetup& es) double phi = CLHEP::RandFlat::shoot(engine, fPhiMin, fPhiMax); double fR = CLHEP::RandFlat::shoot(engine,fRMin,fRMax); double fZ = CLHEP::RandFlat::shoot(engine,fZMin,fZMax); - double fEn = CLHEP::RandFlat::shoot(engine,fEnMin,fEnMax); for (unsigned int ip=0; ipparticle(HepPDT::ParticleID(abs(PartID))) ; double mass = PData->mass().value() ; From 24d6eb58570e751bab0c0b8ccfdabc789ba0594a Mon Sep 17 00:00:00 2001 From: Georgios Karathanasis Date: Fri, 29 Mar 2019 16:59:14 +0100 Subject: [PATCH 352/686] Pythia filter to focus on the probe side of B decays (backport) --- .../GenFilters/interface/PythiaProbeFilter.h | 73 +++++++ .../GenFilters/src/PythiaProbeFilter.cc | 181 ++++++++++++++++++ .../GenFilters/src/SealModule.cc | 2 + 3 files changed, 256 insertions(+) create mode 100644 GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h create mode 100644 GeneratorInterface/GenFilters/src/PythiaProbeFilter.cc diff --git a/GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h b/GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h new file mode 100644 index 0000000000000..5a5a1e40d6d60 --- /dev/null +++ b/GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h @@ -0,0 +1,73 @@ +#ifndef PYTHIAPROBEFILTER_h +#define PYTHIAPROBEFILTER_h +// -*- C++ -*- +// +// Package: PythiaProbeFilter +// Class: PythiaProbeFilter +// +/**\class PythiaProbeFilter PythiaProbeFilter.cc + + Description: Filter to exclude selected particles from passing pT,eta cuts etc. Usefull when we are interested in a decay that its daughters should not pass any cuts, but another particle of the same flavour should e.g B+B- production with B+->K+mumu forcing (probe side) and we want mu to come from B- (tag side) + + Implementation: + +*/ +// +// Original Author: Georgios Karathanasis +// Created: Mar 14 2019 +// +// + + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDFilter.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Pythia8/Pythia.h" + +// +// class decleration +// +namespace edm { + class HepMCProduct; +} + +class PythiaProbeFilter : public edm::global::EDFilter<> { + public: + explicit PythiaProbeFilter(const edm::ParameterSet&); + ~PythiaProbeFilter() override; + + + bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + bool AlreadyExcludedCheck(std::vector excludedList, unsigned int current_part) const; + private: + // ----------memeber function---------------------- + + // ----------member data --------------------------- + + const edm::EDGetTokenT token_; + std::vector exclsisIDs; + std::vector exclauntIDs; + const int particleID; + const int MomID; + const int GrandMomID; + const bool chargeconju; + const int nsisters; + const int naunts; + const double minptcut; + const double maxptcut; + const double minetacut; + const double maxetacut; + const bool countQEDCorPhotons; + bool identicalParticle; + std::unique_ptr fLookupGen; // this instance is for accessing particleData information +}; +#endif diff --git a/GeneratorInterface/GenFilters/src/PythiaProbeFilter.cc b/GeneratorInterface/GenFilters/src/PythiaProbeFilter.cc new file mode 100644 index 0000000000000..fa117877fc9b3 --- /dev/null +++ b/GeneratorInterface/GenFilters/src/PythiaProbeFilter.cc @@ -0,0 +1,181 @@ + +#include "GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h" + + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include + +using namespace edm; +using namespace std; +using namespace Pythia8; + + +PythiaProbeFilter::PythiaProbeFilter(const edm::ParameterSet& iConfig) : +token_(consumes(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))), +particleID(iConfig.getUntrackedParameter("ParticleID", 0)), +MomID(iConfig.getUntrackedParameter("MomID", 0)), +GrandMomID(iConfig.getUntrackedParameter("GrandMomID", 0)), +chargeconju(iConfig.getUntrackedParameter("ChargeConjugation", true)), +nsisters(iConfig.getUntrackedParameter("NumberOfSisters", 0)), +naunts(iConfig.getUntrackedParameter("NumberOfAunts", 0)), +minptcut(iConfig.getUntrackedParameter("MinPt", 0.)), +maxptcut(iConfig.getUntrackedParameter("MaxPt", 14000.)), +minetacut(iConfig.getUntrackedParameter("MinEta", -10.)), +maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.)), +countQEDCorPhotons(iConfig.getUntrackedParameter("countQEDCorPhotons", false)) +{ + //now do what ever initialization is needed + vector defID; + defID.push_back(0); + exclsisIDs = iConfig.getUntrackedParameter< vector >("SisterIDs",defID); + exclauntIDs = iConfig.getUntrackedParameter< vector >("AuntIDs",defID); + identicalParticle=false; + for( unsigned int ilist=0; ilist< exclsisIDs.size(); ++ilist) { + if (fabs(exclsisIDs[ilist])==fabs(particleID)) + identicalParticle=true; + } + // create pythia8 instance to access particle data + edm::LogInfo("PythiaProbeFilter::PythiaProbeFilter") << "Creating pythia8 instance for particle properties" << endl; + if(!fLookupGen.get()) fLookupGen.reset(new Pythia()); +} + + +PythiaProbeFilter::~PythiaProbeFilter() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + +bool PythiaProbeFilter::AlreadyExcludedCheck(std::vector excludedList, unsigned int current_part) const +{ + bool result=false; + for (unsigned int checkNow: excludedList ){ + if (current_part!=checkNow) continue; + result=true; break; + } + return result; +} +// +// member functions +// +// ------------ method called to produce the data ------------ +bool PythiaProbeFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const +{ + using namespace edm; + bool accepted = false; + Handle evt; + iEvent.getByToken(token_, evt); + + const HepMC::GenEvent * myGenEvent = evt->GetEvent(); + + //access particles + for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) { + //select tag particle + if (fabs((*p)->pdg_id()) == fabs(particleID)) + if( (*p)->pdg_id() != particleID && !chargeconju ) continue; + + if( fabs((*p)->pdg_id()) != fabs(particleID) && chargeconju ) continue; + //kinematic properties of tag + if ((*p)->momentum().perp()< minptcut || (*p)->momentum().perp()>maxptcut ) + continue; + if ((*p)->momentum().eta()< minetacut || (*p)->momentum().eta()>maxetacut ) continue; + //remove probe side particles + bool excludeTagParticle=false; + if (naunts==0){ + if ( (*p)->production_vertex()) { + for ( HepMC::GenVertex::particle_iterator anc=(*p)->production_vertex()->particles_begin(HepMC::parents); anc != (*p)->production_vertex()->particles_end(HepMC::parents); ++anc ) { + if (fabs((*anc)->pdg_id())!=fabs(MomID) && chargeconju) continue; + else if ((*anc)->pdg_id()!=MomID && !chargeconju) continue; + int nsis=0; int exclsis=0; std::vector checklistSis; + if ((*anc)->end_vertex()){ + for ( HepMC::GenVertex::particle_iterator sis=(*anc)->end_vertex()->particles_begin(HepMC::children); sis != (*anc)->end_vertex()->particles_end(HepMC::children); ++sis ) { + //identify the tag particle in the decay + if ((*p)->pdg_id()==(*sis)->pdg_id() && (identicalParticle || !chargeconju)) continue; + if (fabs((*p)->pdg_id())==fabs((*sis)->pdg_id()) && !identicalParticle && chargeconju) continue; + //remove QED photons + if ((*sis)->pdg_id()==22 && !countQEDCorPhotons) continue; + nsis++; + //check if this sis is excluded already + for( unsigned int ilist=0; ilist< exclsisIDs.size(); ++ilist) { + if(AlreadyExcludedCheck(checklistSis,ilist)){ + continue;} + if (fabs(exclsisIDs[ilist])==fabs((*sis)->pdg_id()) && chargeconju){ + exclsis++; checklistSis.push_back(ilist); + } + if (exclsisIDs[ilist]==(*sis)->pdg_id() && !chargeconju){ + exclsis++; checklistSis.push_back(ilist); + } + } + } + } + if (nsis==exclsis && nsis==nsisters) { + excludeTagParticle=true; break;} + } + } + } + else if (naunts>0){ + //now take into account that we have up 2 generations in the decay + if ( (*p)->production_vertex() ) { + for ( HepMC::GenVertex::particle_iterator anc=(*p)->production_vertex()->particles_begin(HepMC::parents); anc != (*p)->production_vertex()->particles_end(HepMC::parents); ++anc ) { + if (fabs((*anc)->pdg_id())!=fabs(MomID) && chargeconju) continue; + else if ((*anc)->pdg_id()!=MomID && !chargeconju) continue; + int nsis=0; int exclsis=0; std::vector checklistSis; + int naunt=0; int exclaunt=0; std::vector checklistAunt; + if ((*anc)->end_vertex()){ + for ( HepMC::GenVertex::particle_iterator sis=(*anc)->end_vertex()->particles_begin(HepMC::children); sis != (*anc)->end_vertex()->particles_end(HepMC::children); ++sis ) { + //identify the particle under study in the decay + if ((*p)->pdg_id()==(*sis)->pdg_id() && (identicalParticle || !chargeconju)) continue; + if (fabs((*p)->pdg_id())==fabs((*sis)->pdg_id()) && !identicalParticle && chargeconju) continue; + //remove QED photons + if ((*sis)->pdg_id()==22 && !countQEDCorPhotons) continue; + nsis++; + for( unsigned int ilist=0; ilist< exclsisIDs.size(); ++ilist) { + if(AlreadyExcludedCheck(checklistSis,ilist)) continue; + if (fabs(exclsisIDs[ilist])==fabs((*sis)->pdg_id()) && chargeconju){ + exclsis++; checklistSis.push_back(ilist);} + if (exclsisIDs[ilist]==(*sis)->pdg_id() && !chargeconju){ + exclsis++; checklistSis.push_back(ilist); } + } + } + } + //check sisters + if (nsis!=exclsis || nsis!=nsisters) break; + if ( (*anc)->production_vertex() ) { + for ( HepMC::GenVertex::particle_iterator granc=(*anc)->production_vertex()->particles_begin(HepMC::parents); granc != (*anc)->production_vertex()->particles_end(HepMC::parents); ++granc ) { + if (fabs((*granc)->pdg_id())!=fabs(GrandMomID) && chargeconju) + continue; + else if ((*granc)->pdg_id()!=GrandMomID && !chargeconju) + continue; + for ( HepMC::GenVertex::particle_iterator aunt=(*granc)->end_vertex()->particles_begin(HepMC::children); aunt != (*granc)->end_vertex()->particles_end(HepMC::children); ++aunt ) { + if ((*aunt)->pdg_id()==(*anc)->pdg_id()) continue; + if ((*aunt)->pdg_id()==22 && !countQEDCorPhotons) continue; + naunt++; + for( unsigned int ilist=0; ilist< exclauntIDs.size(); ++ilist) { + if(AlreadyExcludedCheck(checklistAunt,ilist)) continue; + if (fabs(exclauntIDs[ilist])==fabs((*aunt)->pdg_id()) && chargeconju){ + exclaunt++; checklistAunt.push_back(ilist); } + if (exclauntIDs[ilist]==(*aunt)->pdg_id() && !chargeconju){ + exclaunt++; checklistAunt.push_back(ilist); } + } + } + } + } + //check aunts + if (naunt==exclaunt && naunt==naunts) { + excludeTagParticle=true; break;} + } + } + } + if (excludeTagParticle) continue; + accepted = true; + break; + } + + if (accepted){ + return true; } + else { + return false;} + +} diff --git a/GeneratorInterface/GenFilters/src/SealModule.cc b/GeneratorInterface/GenFilters/src/SealModule.cc index 3427fd4b70488..4f8de2f447a48 100644 --- a/GeneratorInterface/GenFilters/src/SealModule.cc +++ b/GeneratorInterface/GenFilters/src/SealModule.cc @@ -4,6 +4,7 @@ #include "GeneratorInterface/GenFilters/interface/PythiaFilterHT.h" #include "GeneratorInterface/GenFilters/interface/PythiaFilterMultiMother.h" #include "GeneratorInterface/GenFilters/interface/PythiaDauFilter.h" +#include "GeneratorInterface/GenFilters/interface/PythiaProbeFilter.h" #include "GeneratorInterface/GenFilters/interface/PythiaFilterGammaJet.h" #include "GeneratorInterface/GenFilters/interface/PythiaFilterGammaGamma.h" #include "GeneratorInterface/GenFilters/interface/PythiaFilterZJet.h" @@ -56,6 +57,7 @@ DEFINE_FWK_MODULE(PythiaFilterHT); DEFINE_FWK_MODULE(PythiaFilterMultiMother); DEFINE_FWK_MODULE(PythiaDauFilter); + DEFINE_FWK_MODULE(PythiaProbeFilter); DEFINE_FWK_MODULE(PythiaFilterGammaJet); DEFINE_FWK_MODULE(PythiaFilterGammaGamma); DEFINE_FWK_MODULE(PythiaFilterZJet); From e644c6caaa21bbfb74db0e7cd620215a94ca315a Mon Sep 17 00:00:00 2001 From: "W. David Dagenhart" Date: Fri, 29 Mar 2019 18:05:19 +0100 Subject: [PATCH 353/686] Simplify globalEndLumiAsync Simply the function globalEndLumiAsync so it is more clear to someone reading or maintaining the code who owns the lumi status object. The status object is now moved into the first task instead of copied. It is no longer moved into the second task, which never really needed the shared_ptr in the first place. I also edited the comments a bit and renamed a few things to make this part of the code more clear. This commit should not change behavior in any way. --- FWCore/Framework/src/EventProcessor.cc | 43 +++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 7706983d4d8f2..cc4e83c78b253 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -1239,15 +1239,23 @@ namespace edm { }) ); } - void EventProcessor::globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus) { - //Need to be sure iTask is always destroyed after iLumiStatus since iLumiStatus can cause endRun to start. - auto t = edm::make_waiting_task(tbb::task::allocate_root(), [ items = std::make_pair(iLumiStatus,std::move(iTask)), this] (std::exception_ptr const* iPtr) mutable { + void EventProcessor::globalEndLumiAsync(edm::WaitingTaskHolder iTask, + std::shared_ptr iLumiStatus) { + + // Get some needed info out of the status object before moving + // it into finalTaskForThisLumi. + auto& lp = *(iLumiStatus->lumiPrincipal()); + bool didGlobalBeginSucceed = iLumiStatus->didGlobalBeginSucceed(); + bool cleaningUpAfterException = iLumiStatus->cleaningUpAfterException(); + + auto finalTaskForThisLumi = edm::make_waiting_task( + tbb::task::allocate_root(), + [status = std::move(iLumiStatus), iTask = std::move(iTask), this] (std::exception_ptr const* iPtr) mutable { + std::exception_ptr ptr; - //use an easier to remember variable name - auto status = std::move(items.first); if(iPtr) { ptr = *iPtr; - WaitingTaskHolder tmp(items.second); + WaitingTaskHolder tmp(iTask); //set the exception early to prevent a beginLumi from running // we use a copy to keep t from resetting on doneWaiting call. tmp.doneWaiting(ptr); @@ -1283,25 +1291,24 @@ namespace edm { ptr = std::current_exception(); } } - //have to wait until reset is called since that could call endRun - items.second.doneWaiting(ptr); + + // This call to doneWaiting must be after the call to status.reset(). + // Otherwise there will be a data race which could result in + // endRun being delayed until it is too late to successfully call + // it. + iTask.doneWaiting(ptr); }); - auto& lp = *(iLumiStatus->lumiPrincipal()); - bool cleaningUpAfterException = iLumiStatus->cleaningUpAfterException(); - - auto writeT = edm::make_waiting_task(tbb::task::allocate_root(), [this,status = std::move(iLumiStatus), task = WaitingTaskHolder(t)] (std::exception_ptr const* iExcept) mutable { + auto writeT = edm::make_waiting_task( + tbb::task::allocate_root(), + [this, didGlobalBeginSucceed, &lumiPrincipal = lp, task = WaitingTaskHolder(finalTaskForThisLumi)] (std::exception_ptr const* iExcept) mutable { + if(iExcept) { - status.reset(); task.doneWaiting(*iExcept); } else { //Only call writeLumi if beginLumi succeeded - if(status->didGlobalBeginSucceed()) { - LuminosityBlockPrincipal& lumiPrincipal = *(status->lumiPrincipal()); - status.reset(); + if(didGlobalBeginSucceed) { writeLumiAsync(std::move(task), lumiPrincipal); - } else { - status.reset(); } } }); From d9188c216f4cd5986287b9940c256bd68186d948 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 30 Mar 2019 00:17:33 +0100 Subject: [PATCH 354/686] Add specifics for HGCal V10 geometry --- Configuration/Eras/python/Era_Phase2C8_cff.py | 7 +++++++ Configuration/Eras/python/Era_Phase2C8_timing_cff.py | 7 +++++++ .../Eras/python/Era_Phase2C8_timing_layer_bar_cff.py | 8 ++++++++ Configuration/Eras/python/Modifier_phase2_hgcalV10_cff.py | 6 ++++++ Configuration/StandardSequences/python/Eras.py | 5 ++++- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Configuration/Eras/python/Era_Phase2C8_cff.py create mode 100644 Configuration/Eras/python/Era_Phase2C8_timing_cff.py create mode 100644 Configuration/Eras/python/Era_Phase2C8_timing_layer_bar_cff.py create mode 100644 Configuration/Eras/python/Modifier_phase2_hgcalV10_cff.py diff --git a/Configuration/Eras/python/Era_Phase2C8_cff.py b/Configuration/Eras/python/Era_Phase2C8_cff.py new file mode 100644 index 0000000000000..3274c863157ae --- /dev/null +++ b/Configuration/Eras/python/Era_Phase2C8_cff.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C4_cff import Phase2C4 +from Configuration.Eras.Modifier_phase2_hgcalV10_cff import phase2_hgcalV10 + +Phase2C8 = cms.ModifierChain(Phase2C4, phase2_hgcalV10) + diff --git a/Configuration/Eras/python/Era_Phase2C8_timing_cff.py b/Configuration/Eras/python/Era_Phase2C8_timing_cff.py new file mode 100644 index 0000000000000..1eae0f72d44c3 --- /dev/null +++ b/Configuration/Eras/python/Era_Phase2C8_timing_cff.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C8_cff import Phase2C8 +from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing + +Phase2C8_timing = cms.ModifierChain(Phase2C8, phase2_timing) + diff --git a/Configuration/Eras/python/Era_Phase2C8_timing_layer_bar_cff.py b/Configuration/Eras/python/Era_Phase2C8_timing_layer_bar_cff.py new file mode 100644 index 0000000000000..d36c9c071bd1b --- /dev/null +++ b/Configuration/Eras/python/Era_Phase2C8_timing_layer_bar_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C8_timing_cff import Phase2C8_timing +from Configuration.Eras.Modifier_phase2_timing_layer_cff import phase2_timing_layer +from Configuration.Eras.Modifier_phase2_timing_layer_bar_cff import phase2_timing_layer_bar + +Phase2C8_timing_layer_bar = cms.ModifierChain(Phase2C8_timing, phase2_timing_layer, phase2_timing_layer_bar) + diff --git a/Configuration/Eras/python/Modifier_phase2_hgcalV10_cff.py b/Configuration/Eras/python/Modifier_phase2_hgcalV10_cff.py new file mode 100644 index 0000000000000..bf6e4affd9b43 --- /dev/null +++ b/Configuration/Eras/python/Modifier_phase2_hgcalV10_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier is for HGCal V10 geometry-specific changes for sim, reco, etc. + +phase2_hgcalV10 = cms.Modifier() + diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index fde246b53c80e..2224a5510b8b7 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -42,6 +42,9 @@ def __init__(self): 'Phase2C6', 'Phase2C6_timing', 'Phase2C4_timing_layer_bar', + 'Phase2C8', + 'Phase2C8_timing', + 'Phase2C8_timing_layer_bar', ] internalUseMods = ['run2_common', 'run2_25ns_specific', @@ -54,7 +57,7 @@ def __init__(self): 'phase1Pixel', 'run3_GEM', 'run2_GEM_2017', 'run2_CSC_2018', 'phase2_common', 'phase2_tracker', - 'phase2_hgcal', 'phase2_muon', 'phase2_timing', 'phase2_hgcalV9', 'phase2_hfnose', + 'phase2_hgcal', 'phase2_muon', 'phase2_timing', 'phase2_hgcalV9', 'phase2_hfnose', 'phase2_hgcalV10', 'phase2_timing_layer','phase2_timing_layer_tile','phase2_timing_layer_bar','phase2_hcal', 'trackingLowPU', 'trackingPhase1', 'ctpps_2016', 'trackingPhase2PU140','highBetaStar_2018', 'tracker_apv_vfp30_2016', 'pf_badHcalMitigation', 'run2_miniAOD_80XLegacy','run2_miniAOD_94XFall17', 'run2_nanoAOD_92X', From 7cf60726904f14dc98c1a9c20c854bdb68f5cb55 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 14 Mar 2019 17:20:15 +0100 Subject: [PATCH 355/686] Proper constructor for PFMuonAlgo --- .../PFProducer/interface/PFMuonAlgo.h | 78 +++----- .../importers/GeneralTracksImporter.cc | 3 +- .../GeneralTracksImporterWithVeto.cc | 3 +- RecoParticleFlow/PFProducer/src/PFAlgo.cc | 3 +- RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc | 170 +++++------------- 5 files changed, 68 insertions(+), 189 deletions(-) diff --git a/RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h b/RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h index 8db964bdd7332..0b2d9e192a808 100644 --- a/RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h +++ b/RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h @@ -17,55 +17,28 @@ class PFMuonAlgo { public: /// constructor - PFMuonAlgo(); - - void setParameters(const edm::ParameterSet&); - - - - /// destructor - virtual ~PFMuonAlgo() {;} + PFMuonAlgo(edm::ParameterSet const&); ////STATIC MUON ID METHODS - static bool isMuon( const reco::PFBlockElement& elt ); - static bool isLooseMuon( const reco::PFBlockElement& elt ); - static bool isGlobalTightMuon( const reco::PFBlockElement& elt ); - static bool isGlobalLooseMuon( const reco::PFBlockElement& elt ); - static bool isTrackerTightMuon( const reco::PFBlockElement& elt ); - static bool isTrackerLooseMuon( const reco::PFBlockElement& elt ); - static bool isIsolatedMuon( const reco::PFBlockElement& elt ); - static bool isMuon( const reco::MuonRef& muonRef ); - static bool isLooseMuon( const reco::MuonRef& muonRef ); - static bool isGlobalTightMuon( const reco::MuonRef& muonRef ); - static bool isGlobalLooseMuon( const reco::MuonRef& muonRef ); - - - static bool isTrackerTightMuon( const reco::MuonRef& muonRef ); - static bool isTrackerLooseMuon( const reco::MuonRef& muonRef ); - static bool isIsolatedMuon( const reco::MuonRef& muonRef ); - static bool isTightMuonPOG(const reco::MuonRef& muonRef); - static void printMuonProperties( const reco::MuonRef& muonRef ); - - ////POST CLEANING AND MOMEMNTUM ASSIGNMENT bool hasValidTrack(const reco::MuonRef& muonRef,bool loose =false); @@ -156,32 +129,31 @@ class PFMuonAlgo { //Configurables - double maxDPtOPt_; - int minTrackerHits_; - int minPixelHits_; - reco::TrackBase::TrackQuality trackQuality_; - - double errorCompScale_; - double eventFractionCleaning_; - double sumetPU_; - double dzPV_; - bool postCleaning_; - double minPostCleaningPt_; - double eventFactorCosmics_; - double metSigForCleaning_; - double metSigForRejection_; - double metFactorCleaning_; - double eventFractionRejection_; - double metFactorRejection_; - double metFactorHighEta_; - double ptFactorHighEta_; - double metFactorFake_; - double minPunchThroughMomentum_; - double minPunchThroughEnergy_; - double punchThroughFactor_; - double punchThroughMETFactor_; - double cosmicRejDistance_; + const double maxDPtOPt_; + const int minTrackerHits_; + const int minPixelHits_; + const reco::TrackBase::TrackQuality trackQuality_; + const double errorCompScale_; + const double eventFractionCleaning_; + const double dzPV_; + const bool postCleaning_; + const double minPostCleaningPt_; + const double eventFactorCosmics_; + const double metSigForCleaning_; + const double metSigForRejection_; + const double metFactorCleaning_; + const double eventFractionRejection_; + const double metFactorRejection_; + const double metFactorHighEta_; + const double ptFactorHighEta_; + const double metFactorFake_; + const double minPunchThroughMomentum_; + const double minPunchThroughEnergy_; + const double punchThroughFactor_; + const double punchThroughMETFactor_; + const double cosmicRejDistance_; + double sumetPU_; double sumet_; double METX_; double METY_; diff --git a/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporter.cc b/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporter.cc index 4dcb4bc8c9bd1..a269c69607c87 100644 --- a/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporter.cc +++ b/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporter.cc @@ -22,8 +22,7 @@ class GeneralTracksImporter : public BlockElementImporterBase { cleanBadConvBrems_(conf.existsAs("cleanBadConvertedBrems") ? conf.getParameter("cleanBadConvertedBrems") : false), debug_(conf.getUntrackedParameter("debug",false)) { - pfmu_ = std::unique_ptr(new PFMuonAlgo()); - pfmu_->setParameters(conf); + pfmu_ = std::unique_ptr(new PFMuonAlgo(conf)); } diff --git a/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporterWithVeto.cc b/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporterWithVeto.cc index 81bdd3d855af4..17b23326aa0d7 100644 --- a/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporterWithVeto.cc +++ b/RecoParticleFlow/PFProducer/plugins/importers/GeneralTracksImporterWithVeto.cc @@ -23,8 +23,7 @@ class GeneralTracksImporterWithVeto : public BlockElementImporterBase { cleanBadConvBrems_(conf.existsAs("cleanBadConvertedBrems") ? conf.getParameter("cleanBadConvertedBrems") : false), debug_(conf.getUntrackedParameter("debug",false)) { - pfmu_ = std::unique_ptr(new PFMuonAlgo()); - pfmu_->setParameters(conf); + pfmu_ = std::unique_ptr(new PFMuonAlgo(conf)); } diff --git a/RecoParticleFlow/PFProducer/src/PFAlgo.cc b/RecoParticleFlow/PFProducer/src/PFAlgo.cc index 2d97c6711a2fa..2f4ba4d8e1a72 100644 --- a/RecoParticleFlow/PFProducer/src/PFAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFAlgo.cc @@ -234,8 +234,7 @@ void PFAlgo::setPFPhotonRegWeights( void PFAlgo::setPFMuonAndFakeParameters(const edm::ParameterSet& pset) { - pfmu_ = new PFMuonAlgo(); - pfmu_->setParameters(pset); + pfmu_ = new PFMuonAlgo(pset); // Muon parameters muonHCAL_= pset.getParameter >("muon_HCAL"); diff --git a/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc b/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc index 6728c9e4c5cb4..479f9efe65e16 100644 --- a/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc @@ -14,138 +14,49 @@ using namespace std; using namespace reco; using namespace boost; -PFMuonAlgo::PFMuonAlgo() { - pfCosmicsMuonCleanedCandidates_ = std::make_unique(); - pfCleanedTrackerAndGlobalMuonCandidates_= std::make_unique(); - pfFakeMuonCleanedCandidates_= std::make_unique(); - pfPunchThroughMuonCleanedCandidates_= std::make_unique(); - pfPunchThroughHadronCleanedCandidates_= std::make_unique(); - pfAddedMuonCandidates_ = std::make_unique(); - -} - - - -void PFMuonAlgo::setParameters(const edm::ParameterSet& iConfig ) -{ - - if(iConfig.exists("maxDPtOPt")) - maxDPtOPt_ = iConfig.getParameter("maxDPtOPt"); - else - maxDPtOPt_=1.0; - - if(iConfig.exists("minTrackerHits")) - minTrackerHits_ = iConfig.getParameter("minTrackerHits"); - else - minTrackerHits_ = 8; - - if(iConfig.exists("minPixelHits")) - minPixelHits_ = iConfig.getParameter("minPixelHits"); - else - minPixelHits_ = 1; - - if(iConfig.exists("trackQuality")) - trackQuality_ = reco::TrackBase::qualityByName(iConfig.getParameter("trackQuality")); - else - trackQuality_ = reco::TrackBase::qualityByName("highPurity"); +namespace { - if(iConfig.exists("ptErrorScale")) - errorCompScale_ = iConfig.getParameter("ptErrorScale"); - else - errorCompScale_ = 4.; - - if(iConfig.exists("eventFractionForCleaning")) - eventFractionCleaning_ = iConfig.getParameter("eventFractionForCleaning"); - else - eventFractionCleaning_ = 0.75; - - if(iConfig.exists("dzPV")) - dzPV_ = iConfig.getParameter("dzPV"); - else - dzPV_ = 0.2; - - if(iConfig.exists("postMuonCleaning")) - postCleaning_ = iConfig.getParameter("postMuonCleaning"); - else - postCleaning_ = false; //Disable by default (for HLT) - - if(iConfig.exists("minPtForPostCleaning")) - minPostCleaningPt_ = iConfig.getParameter("minPtForPostCleaning"); - else - minPostCleaningPt_ = 20.; - - if(iConfig.exists("eventFactorForCosmics")) - eventFactorCosmics_ = iConfig.getParameter("eventFactorForCosmics"); - else - eventFactorCosmics_ = 10.; - - - if(iConfig.exists("metSignificanceForCleaning")) - metSigForCleaning_ = iConfig.getParameter("metSignificanceForCleaning"); - else - metSigForCleaning_ = 3.; - - if(iConfig.exists("metSignificanceForRejection")) - metSigForRejection_ = iConfig.getParameter("metSignificanceForRejection"); - else - metSigForRejection_ = 4.; - - if(iConfig.exists("metFactorForCleaning")) - metFactorCleaning_ = iConfig.getParameter("metFactorForCleaning"); - else - metFactorCleaning_ = 4.; - - if(iConfig.exists("eventFractionForRejection")) - eventFractionRejection_ = iConfig.getParameter("eventFractionForRejection"); - else - eventFractionRejection_ = 0.75; - - if(iConfig.exists("metFactorForRejection")) - metFactorRejection_ = iConfig.getParameter("metFactorForRejection"); - else - metFactorRejection_ =4.; - - if(iConfig.exists("metFactorForHighEta")) - metFactorHighEta_ = iConfig.getParameter("metFactorForHighEta"); - else - metFactorHighEta_=4; - - if(iConfig.exists("ptFactorForHighEta")) - ptFactorHighEta_ = iConfig.getParameter("ptFactorForHighEta"); - else - ptFactorHighEta_ = 2.; - - if(iConfig.exists("metFactorForFakes")) - metFactorFake_ = iConfig.getParameter("metFactorForFakes"); - else - metFactorFake_ = 4.; - - if(iConfig.exists("minMomentumForPunchThrough")) - minPunchThroughMomentum_ = iConfig.getParameter("minMomentumForPunchThrough"); - else - minPunchThroughMomentum_=100.; - - if(iConfig.exists("minEnergyForPunchThrough")) - minPunchThroughEnergy_ = iConfig.getParameter("minEnergyForPunchThrough"); - else - minPunchThroughEnergy_ = 100.; - - if(iConfig.exists("punchThroughFactor")) - punchThroughFactor_ = iConfig.getParameter("punchThroughFactor"); - else - punchThroughFactor_ = 3.; - - if(iConfig.exists("punchThroughMETFactor")) - punchThroughMETFactor_ = iConfig.getParameter("punchThroughMETFactor"); - else - punchThroughMETFactor_ = 4.; + template + T getParameter(edm::ParameterSet const& pset, std::string && name, T && defaultValue) { + return pset.exists(name) ? pset.getParameter(name) : defaultValue; + } - if(iConfig.exists("cosmicRejectionDistance")) - cosmicRejDistance_ = iConfig.getParameter("cosmicRejectionDistance"); - else - cosmicRejDistance_ = 1.0; } +PFMuonAlgo::PFMuonAlgo(const edm::ParameterSet& iConfig) + + : pfCosmicsMuonCleanedCandidates_(std::make_unique()) + , pfCleanedTrackerAndGlobalMuonCandidates_(std::make_unique()) + , pfFakeMuonCleanedCandidates_(std::make_unique()) + , pfPunchThroughMuonCleanedCandidates_(std::make_unique()) + , pfPunchThroughHadronCleanedCandidates_(std::make_unique()) + , pfAddedMuonCandidates_(std::make_unique()) + + , maxDPtOPt_(getParameter(iConfig, "maxDPtOPt", 1.0)) + , minTrackerHits_(getParameter(iConfig, "minTrackerHits", 8)) + , minPixelHits_(getParameter(iConfig, "minPixelHits", 1)) + , trackQuality_(reco::TrackBase::qualityByName(getParameter(iConfig, "trackQuality", "highPurity"))) + , errorCompScale_(getParameter(iConfig, "ptErrorScale", 4.0)) + , eventFractionCleaning_(getParameter(iConfig, "eventFractionForCleaning", 0.75)) + , dzPV_(getParameter(iConfig, "dzPV", 0.2)) + , postCleaning_(getParameter(iConfig, "postMuonCleaning", false)) // disable by default (for HLT) + , minPostCleaningPt_(getParameter(iConfig, "minPtForPostCleaning", 20.)) + , eventFactorCosmics_(getParameter(iConfig, "eventFactorForCosmics", 10.)) + , metSigForCleaning_(getParameter(iConfig, "metSignificanceForCleaning", 3.)) + , metSigForRejection_(getParameter(iConfig, "metSignificanceForRejection", 4.)) + , metFactorCleaning_(getParameter(iConfig, "metFactorForCleaning", 4.)) + , eventFractionRejection_(getParameter(iConfig, "eventFractionForRejection", 0.75)) + , metFactorRejection_(getParameter(iConfig, "metFactorForRejection", 4.)) + , metFactorHighEta_(getParameter(iConfig, "metFactorForHighEta", 4.)) + , ptFactorHighEta_(getParameter(iConfig, "ptFactorForHighEta", 2.)) + , metFactorFake_(getParameter(iConfig, "metFactorForFakes", 4.)) + , minPunchThroughMomentum_(getParameter(iConfig, "minMomentumForPunchThrough", 100.)) + , minPunchThroughEnergy_(getParameter(iConfig, "minEnergyForPunchThrough", 100.)) + , punchThroughFactor_(getParameter(iConfig, "punchThroughFactor", 3.)) + , punchThroughMETFactor_(getParameter(iConfig, "punchThroughMETFactor", 4.)) + , cosmicRejDistance_(getParameter(iConfig, "cosmicRejectionDistance", 1.)) +{} + @@ -154,8 +65,7 @@ void PFMuonAlgo::setParameters(const edm::ParameterSet& iConfig ) bool PFMuonAlgo::isMuon( const reco::PFBlockElement& elt ) { - const reco::PFBlockElementTrack* eltTrack - = dynamic_cast(&elt); + const auto* eltTrack = dynamic_cast(&elt); assert ( eltTrack ); reco::MuonRef muonRef = eltTrack->muonRef(); From 6bd47d6b1b35adac098b48e65df4a4f3f4386f79 Mon Sep 17 00:00:00 2001 From: chayanit Date: Sun, 31 Mar 2019 09:01:54 +0200 Subject: [PATCH 356/686] hadronizer for HToGG Minlo NNLOPS pLHE relval --- ...gEmissionVeto_2p_HToGG_M125_LHE_py8_cff.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Configuration/Generator/python/Hadronizer_TuneCUETP8M1_13TeV_powhegEmissionVeto_2p_HToGG_M125_LHE_py8_cff.py diff --git a/Configuration/Generator/python/Hadronizer_TuneCUETP8M1_13TeV_powhegEmissionVeto_2p_HToGG_M125_LHE_py8_cff.py b/Configuration/Generator/python/Hadronizer_TuneCUETP8M1_13TeV_powhegEmissionVeto_2p_HToGG_M125_LHE_py8_cff.py new file mode 100644 index 0000000000000..f2e8345e7538c --- /dev/null +++ b/Configuration/Generator/python/Hadronizer_TuneCUETP8M1_13TeV_powhegEmissionVeto_2p_HToGG_M125_LHE_py8_cff.py @@ -0,0 +1,32 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.Generator.Pythia8CommonSettings_cfi import * +from Configuration.Generator.Pythia8CUEP8M1Settings_cfi import * +from Configuration.Generator.Pythia8PowhegEmissionVetoSettings_cfi import * + +generator = cms.EDFilter("Pythia8HadronizerFilter", + maxEventsToPrint = cms.untracked.int32(1), + pythiaPylistVerbosity = cms.untracked.int32(1), + filterEfficiency = cms.untracked.double(1.0), + pythiaHepMCVerbosity = cms.untracked.bool(False), + comEnergy = cms.double(13000.), + PythiaParameters = cms.PSet( + pythia8CommonSettingsBlock, + pythia8CUEP8M1SettingsBlock, + pythia8PowhegEmissionVetoSettingsBlock, + processParameters = cms.vstring( + 'POWHEG:nFinal = 2', ## Number of final state particles + ## (BEFORE THE DECAYS) in the LHE + ## other than emitted extra parton + '25:m0 = 125.0', + '25:onMode = off', + '25:onIfMatch = 22 22', + ), + parameterSets = cms.vstring('pythia8CommonSettings', + 'pythia8CUEP8M1Settings', + 'pythia8PowhegEmissionVetoSettings', + 'processParameters' + ) + ) + ) + +ProductionFilterSequence = cms.Sequence(generator) From 4164586ea477b15dc9ad2efe13c4ea45681ab343 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Sun, 31 Mar 2019 12:52:29 +0200 Subject: [PATCH 357/686] Changed definition of ieta sign with signbit(). Changed definition of validity iphi = iphi +/- phiseg to using methods from HcalTopology. --- .../HcalRecAlgos/interface/HFStripFilter.h | 7 +-- .../HcalRecAlgos/src/HFStripFilter.cc | 54 +++++++++++-------- .../python/HFPhase1Reconstructor_cfi.py | 3 +- .../src/HFPhase1Reconstructor.cc | 2 +- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h index 0cd2da211e6f8..cfd483d71826d 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -12,14 +12,14 @@ class HFStripFilter // Construct this object with all necessary parameters HFStripFilter(double stripThreshold, double maxThreshold, double timeMax, double maxStripTime, - double wedgeCut, int gap, - int lstrips, int verboseLevel); + double wedgeCut, int seedHitIetaMax, + int gap, int lstrips, int verboseLevel); // Destructor ~HFStripFilter(); // The actual rechit tagging is performed by the following function - void runFilter(HFRecHitCollection& rec) const; + void runFilter(HFRecHitCollection& rec, const HcalChannelQuality* myqual) const; // Parser function to create this object from a parameter set static std::unique_ptr parseParameterSet( @@ -34,6 +34,7 @@ class HFStripFilter double timeMax_; double maxStripTime_; double wedgeCut_; + int seedHitIetaMax_; int gap_; int lstrips_; int verboseLevel_; diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 65c5ffd96977c..a7951670f08a9 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -4,17 +4,20 @@ #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" +#include "Geometry/CaloTopology/interface/HcalTopology.h" +#include HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, - const double wedgeCut, const int gap, - const int lstrips, const int verboseLevel) + const double wedgeCut, const int seedHitIetaMax, + const int gap, const int lstrips, const int verboseLevel) : stripThreshold_(stripThreshold), maxThreshold_(maxThreshold), timeMax_(timeMax), maxStripTime_(maxStripTime), wedgeCut_(wedgeCut), + seedHitIetaMax_(seedHitIetaMax), gap_(gap), lstrips_(lstrips), verboseLevel_(verboseLevel) @@ -32,7 +35,8 @@ HFStripFilter::~HFStripFilter() } -void HFStripFilter::runFilter(HFRecHitCollection& rec) const +void HFStripFilter::runFilter(HFRecHitCollection& rec, + const HcalChannelQuality* myqual) const { if (verboseLevel_ >= 20) edm::LogInfo("HFStripFilter") << "runFilter called"; @@ -50,7 +54,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; // find HF hit with maximum signal in depth = 1 if (it.id().depth() == 1) { - if (it.energy() > d1max.energy() && std::abs(it.id().ieta()) < 35) { + if (it.energy() > d1max.energy() && std::abs(it.id().ieta()) < seedHitIetaMax_) { d1max = it; } } @@ -63,7 +67,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const int stripIetaMax = 0; if (d1max.energy() > 0) { - signStripIeta = d1max.id().ieta()/std::abs(d1max.id().ieta()); + signStripIeta = signbit(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); } @@ -73,9 +77,10 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const { if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; // find HFhit with maximum signal in depth = 2 - if (it.id().depth() == 2 && it.energy() > d2max.energy() && std::abs(it.id().ieta()) < 35) { + if (it.id().depth() == 2 && it.energy() > d2max.energy() && std::abs(it.id().ieta()) + < seedHitIetaMax_) { if (d1max.energy() > 0) { - int signIeta = it.id().ieta()/std::abs(it.id().ieta()); + int signIeta = signbit(it.id().ieta()); if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta) { d2max = it; } @@ -90,8 +95,8 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const // check if possible seed hits have energies not too small if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; - if (stripIphiMax == 0 && d2max.energy() > 0) { - signStripIeta = d2max.id().ieta()/std::abs(d2max.id().ieta()); + if (d1max.energy() <= 0 && d2max.energy() > 0) { + signStripIeta = signbit(d2max.id().ieta()); stripIphiMax = d2max.id().iphi(); stripIetaMax = d2max.id().ieta(); } @@ -112,7 +117,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const for (auto& it : rec) { if (it.energy() < stripThreshold_) continue; - int signIeta = it.id().ieta()/std::abs(it.id().ieta()); + int signIeta = signbit(it.id().ieta()); if (verboseLevel_ >= 30) { ss << " HF hit: ieta = " << it.id().ieta() << "\t iphi = " << it.id().iphi() @@ -124,7 +129,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta && it.time() < maxStripTime_) { if (it.id().depth() == 1) { - // check if hit = (*it) is already in d1strip + // check if hit = it is already in d1strip bool pass = false; if (d1strip.empty()) { if (std::abs(it.id().iphi() - stripIetaMax) <= gap_) { @@ -150,7 +155,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const } } else if (it.id().depth() == 2) { - // check if hit = (*it) is already in d2strip + // check if hit = it is already in d2strip bool pass= false; if (d2strip.empty()) { if (std::abs(it.id().ieta() - stripIetaMax) <= gap_) { @@ -240,24 +245,25 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec) const << " Common strip: ietaMin = " << ietaMin << " ietaMax = " << ietaMax << std::endl; } - int phiseg = 2; // 10 degrees segmentation for most of HF (1 iphi unit = 5 degrees) - if (std::abs(d1strip[0].id().ieta()) > 39) phiseg = 4; // 20 degrees segmentation for |ieta| > 39 - - // Check if seed hit has neighbours with (iphi +/- phiseg) and the same ieta - int iphi1 = d1strip[0].id().iphi() - phiseg; - while (iphi1 < 0) iphi1 += 72; - int iphi2 = d1strip[0].id().iphi() + phiseg; - while (iphi2 > 72) iphi2 -= 72; - // energies in the neighboring wedges double energyIphi1 = 0; double energyIphi2 = 0; + int iphi1 = 0, iphi2 = 0; + + // get information about the neighboring wedges from HcalTopology + HcalDetId neighbour; + for (auto& it : rec) { if (it.energy() < stripThreshold_) continue; if (it.id().ieta() < ietaMin || it.id().ieta() > ietaMax) continue; - if (it.id().iphi() == iphi1) energyIphi1 += it.energy(); // iphi1 - else if (it.id().iphi() == iphi2) energyIphi2 += it.energy(); // iphi2 + HcalDetId id(HcalForward, it.id().ieta(), d1strip[0].id().iphi(), d1strip[0].id().depth()); + bool neigh = myqual->topo()->decIPhi(id, neighbour); + iphi1 = (neigh) ? neighbour.iphi() : 0; + neigh = myqual->topo()->incIPhi(id, neighbour); + iphi2 = (neigh) ? neighbour.iphi() : 0; + if (it.id().iphi() == iphi1) energyIphi1 += it.energy(); // Energy iphi1 + else if (it.id().iphi() == iphi2) energyIphi2 += it.energy(); // Energy iphi2 } double ratio1 = eStrip > 0 ? energyIphi1/eStrip : 0; @@ -327,6 +333,7 @@ std::unique_ptr HFStripFilter::parseParameterSet( ps.getParameter("timeMax"), ps.getParameter("maxStripTime"), ps.getParameter("wedgeCut"), + ps.getParameter("seedHitIetaMax"), ps.getParameter("gap"), ps.getParameter("lstrips"), ps.getUntrackedParameter("verboseLevel") @@ -342,6 +349,7 @@ edm::ParameterSetDescription HFStripFilter::fillDescription() desc.add("timeMax", 6.0); desc.add("maxStripTime", 10.0); desc.add("wedgeCut", 0.05); + desc.add("seedHitIetaMax", 35); desc.add("gap", 2); desc.add("lstrips", 2); desc.addUntracked("verboseLevel", 0); diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index b2c8c3fe19cbc..82928ae519aa2 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -204,8 +204,9 @@ timeMax = cms.double(6.0), maxStripTime = cms.double(10.0), wedgeCut = cms.double(0.05), + seedHitIetaMax = cms.int32(35), gap = cms.int32(2), lstrips = cms.int32(2), - verboseLevel = cms.untracked.int32(20) + verboseLevel = cms.untracked.int32(10) ) ) diff --git a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc index 89b532703344a..ebfc6968a3f29 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HFPhase1Reconstructor.cc @@ -289,7 +289,7 @@ HFPhase1Reconstructor::produce(edm::Event& e, const edm::EventSetup& eventSetup) // Step 4: Run HFStripFilter if requested if (runHFStripFilter_) - hfStripFilter_->runFilter(*rec); + hfStripFilter_->runFilter(*rec, myqual); } // Add the output collection to the event record From da4bbb5f7146643dc115181d4a66d6c735b52a33 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Sun, 31 Mar 2019 15:18:14 +0200 Subject: [PATCH 358/686] replaced by --- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index a7951670f08a9..7385195f8ed68 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -6,7 +6,7 @@ #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" -#include +#include HFStripFilter::HFStripFilter(const double stripThreshold, const double maxThreshold, const double timeMax, const double maxStripTime, @@ -67,7 +67,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, int stripIetaMax = 0; if (d1max.energy() > 0) { - signStripIeta = signbit(d1max.id().ieta()); + signStripIeta = std::signbit(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); } @@ -80,7 +80,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, if (it.id().depth() == 2 && it.energy() > d2max.energy() && std::abs(it.id().ieta()) < seedHitIetaMax_) { if (d1max.energy() > 0) { - int signIeta = signbit(it.id().ieta()); + int signIeta = std::signbit(it.id().ieta()); if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta) { d2max = it; } @@ -96,7 +96,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; if (d1max.energy() <= 0 && d2max.energy() > 0) { - signStripIeta = signbit(d2max.id().ieta()); + signStripIeta = std::signbit(d2max.id().ieta()); stripIphiMax = d2max.id().iphi(); stripIetaMax = d2max.id().ieta(); } @@ -117,7 +117,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, for (auto& it : rec) { if (it.energy() < stripThreshold_) continue; - int signIeta = signbit(it.id().ieta()); + int signIeta = std::signbit(it.id().ieta()); if (verboseLevel_ >= 30) { ss << " HF hit: ieta = " << it.id().ieta() << "\t iphi = " << it.id().iphi() From ce9f4a8a5d2d3df392014682fecd8fbaaaaf7294 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Sun, 31 Mar 2019 17:53:28 +0200 Subject: [PATCH 359/686] additional protection for the possible case if d1strip has no hits --- RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 7385195f8ed68..db53d74b79362 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -65,11 +65,13 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, int signStripIeta = 0; int stripIphiMax = 0; int stripIetaMax = 0; + int stripDepthMax = 0; if (d1max.energy() > 0) { signStripIeta = std::signbit(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); + stripDepthMax = d1max.id().depth(); } d2max.setEnergy(-10); @@ -99,6 +101,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, signStripIeta = std::signbit(d2max.id().ieta()); stripIphiMax = d2max.id().iphi(); stripIetaMax = d2max.id().ieta(); + stripDepthMax = d2max.id().depth(); } std::stringstream ss; @@ -107,7 +110,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, ss << " MaxHit in Depth 1: ieta = " << d1max.id().ieta() << " iphi = " << stripIphiMax << " energy = " << d1max.energy() << " time = " << d1max.time() << std::endl; } if (d2max.energy() > 0) { - ss << " MaxHit in Depth 2: ieta = " << d2max.id().ieta() << " iphi = " << d2max.id().iphi() + ss << " MaxHit in Depth 2: ieta = " << d2max.id().ieta() << " iphi = " << stripIphiMax << " energy = " << d2max.energy() << " time = " << d2max.time() << std::endl; } ss << " stripThreshold_ = " << stripThreshold_ << std::endl; } @@ -257,7 +260,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, { if (it.energy() < stripThreshold_) continue; if (it.id().ieta() < ietaMin || it.id().ieta() > ietaMax) continue; - HcalDetId id(HcalForward, it.id().ieta(), d1strip[0].id().iphi(), d1strip[0].id().depth()); + HcalDetId id(HcalForward, it.id().ieta(), stripIphiMax, stripDepthMax); bool neigh = myqual->topo()->decIPhi(id, neighbour); iphi1 = (neigh) ? neighbour.iphi() : 0; neigh = myqual->topo()->incIPhi(id, neighbour); @@ -270,7 +273,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, double ratio2 = eStrip > 0 ? energyIphi2/eStrip : 0; if (verboseLevel_ >= 30) { - ss << " iphi = " << d1strip[0].id().iphi() << " iphi1 = " << iphi1 << " iphi2 = " + ss << " iphi = " << stripIphiMax << " iphi1 = " << iphi1 << " iphi2 = " << iphi2 << std::endl << " Estrip = " << eStrip << " EnergyIphi1 = " << energyIphi1 << " Ratio = " << ratio1 << std::endl From c3302ac67546d249604fe0aabe23152bfbaf13c7 Mon Sep 17 00:00:00 2001 From: tocheng Date: Sat, 23 Mar 2019 17:38:24 +0100 Subject: [PATCH 360/686] Add RPalignment to data GTs --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index b9be61d1aff8e..e50d6ce0a5c61 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '105X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '105X_dataRun2_v8', + 'run1_data' : '106X_dataRun2_v1', # GlobalTag for Run2 data reprocessing - 'run2_data' : '105X_dataRun2_v8', + 'run2_data' : '106X_dataRun2_v1', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '105X_dataRun2_relval_v8', + 'run2_data_relval' : '106X_dataRun2_relval_v1', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '105X_dataRun2_PromptLike_HEfail_v7', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '105X_dataRun2_PromptLike_v8', - 'run2_data_promptlike_hi' : '105X_dataRun2_PromptLike_HI_v3', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v1', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v1', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v8', # GlobalTag for Run2 HLT: it points to the online GT From 20088375561f68e1849e6461ab65f35ec521cead Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Mon, 1 Apr 2019 13:22:11 +0200 Subject: [PATCH 361/686] By default, PPS alignment now loaded from DB using auto GT. --- CalibPPS/ESProducers/python/ctppsAlignment_cff.py | 10 ++++++---- .../ProtonReconstruction/python/ctppsProtons_cff.py | 1 - .../test_reconstruction_cfg.py | 4 ---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CalibPPS/ESProducers/python/ctppsAlignment_cff.py b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py index fc2aed2fb1a3d..45c3a72dbffeb 100644 --- a/CalibPPS/ESProducers/python/ctppsAlignment_cff.py +++ b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py @@ -1,6 +1,8 @@ import FWCore.ParameterSet.Config as cms -from CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * -ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring( - "Alignment/CTPPS/data/RPixGeometryCorrections.xml" -) +# by default, alignment is now loaded from CondDB using a GT + +#from CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * +#ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring( +# "Alignment/CTPPS/data/RPixGeometryCorrections.xml" +#) diff --git a/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py index dd1f03a267ca1..71f3a14b9e0b9 100644 --- a/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py +++ b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py @@ -3,6 +3,5 @@ from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * # TODO: remove these lines once conditions data are available in DB -from CalibPPS.ESProducers.ctppsAlignment_cff import * from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py index 3ed71f5688a01..bc011305742b7 100644 --- a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -8,10 +8,6 @@ from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") -# TODO: these lines can be useful before all necessary data available in DB with an auto GT -#process.GlobalTag = GlobalTag(process.GlobalTag, "105X_dataRun2_relval_v2") -#process.alignmentEsPrefer = cms.ESPrefer("PoolDBESSource", "GlobalTag") - # minimum of logs process.MessageLogger = cms.Service("MessageLogger", statistics = cms.untracked.vstring(), From 3b23fa591e90728ae53e4f5ebd19d7152de7b0dd Mon Sep 17 00:00:00 2001 From: David Date: Mon, 1 Apr 2019 13:50:35 +0200 Subject: [PATCH 362/686] speed up --- FWCore/ParameterSet/python/Mixins.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/FWCore/ParameterSet/python/Mixins.py b/FWCore/ParameterSet/python/Mixins.py index ab4205d6b1cdc..db0eacc0e4d6a 100644 --- a/FWCore/ParameterSet/python/Mixins.py +++ b/FWCore/ParameterSet/python/Mixins.py @@ -656,9 +656,8 @@ def _itemsFromStrings(strings,converter): return (converter(x).value() for x in strings) def saveOrigin(obj, level): - frame = inspect.stack()[level+1] - if isinstance(frame,tuple): frame=frame[0] #python3 changes this to a tuple where the first thing is the frame - fInfo=inspect.getframeinfo(frame) + import sys + fInfo = inspect.getframeinfo(sys._getframe(level+1)) obj._filename = fInfo.filename obj._lineNumber =fInfo.lineno From 029075516ffae2f0b0ae5dd2a6b5158f066a6ae2 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 1 Apr 2019 15:39:57 +0200 Subject: [PATCH 363/686] Adapt ETL numbering scheme to new forward volume hierarchy (scenario D41, HGCal v10) --- Geometry/MTDCommonData/src/ETLNumberingScheme.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Geometry/MTDCommonData/src/ETLNumberingScheme.cc b/Geometry/MTDCommonData/src/ETLNumberingScheme.cc index 7cd0fbd3c08a9..430dfb9606618 100644 --- a/Geometry/MTDCommonData/src/ETLNumberingScheme.cc +++ b/Geometry/MTDCommonData/src/ETLNumberingScheme.cc @@ -43,7 +43,12 @@ uint32_t ETLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const { std::string baseName = ringName.substr(ringName.find(":")+1); const int ringCopy ( ::atoi( baseName.c_str() + 4 ) ); - const uint32_t sideCopy ( baseNumber.getCopyNumber( 7 ) ) ; + // Side choice: up to scenario D38 is given by level 7 (HGCal v9) + int nSide(7); + const std::string& sideName ( baseNumber.getLevelName( nSide ) ) ; + // Side choice: from scenario D41 is given by level 8 (HGCal v10) + if ( sideName == "caloBase:CALOECTSFront" ) { nSide = 8 ;} + const uint32_t sideCopy ( baseNumber.getCopyNumber( nSide ) ) ; const uint32_t zside ( sideCopy == 1 ? 1 : 0 ) ; #ifdef EDM_ML_DEBUG From 5f8492d19a5b54261fbbcf2ec0a5e22a4d7fee24 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 1 Apr 2019 08:55:52 -0500 Subject: [PATCH 364/686] Properly handle a polymorphic exception in DTCCablingMapProducer Fixes a gcc 8 compiler warning. --- CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc index 01626758f70eb..9cb4e8d11b82d 100644 --- a/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc +++ b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc @@ -213,7 +213,7 @@ void DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV(std::vector= 0) { From a9c581026efbeba77a5478b737438606ebb7fab6 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 1 Apr 2019 10:13:16 -0500 Subject: [PATCH 365/686] Make sure all member variables are initialized in RPCEMapSourceHandler -Initialize RPCEMap::febItem::theChamber to -1. This fixes a gcc 8.3 compiler warning. -Moved stack variables to have scope only within the loops they are used. --- CondTools/RPC/src/RPCEMapSourceHandler.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CondTools/RPC/src/RPCEMapSourceHandler.cc b/CondTools/RPC/src/RPCEMapSourceHandler.cc index fbc84a9e62f20..746b9ed11ee39 100644 --- a/CondTools/RPC/src/RPCEMapSourceHandler.cc +++ b/CondTools/RPC/src/RPCEMapSourceHandler.cc @@ -222,10 +222,8 @@ void popcon::RPCEMapSourceHandler::readEMap1() for (int i=0; i<3; i++) if (char2==char2Val[i]) n2=i; for (int i=0; i<9; i++) if (char4==char4Val[i]) n3=i; thisLB.theCode=n3+num3*10+n2*100+n1*1000+wheel*10000+sector*100000; - FEBStruct tmpFEB; std::vector theFEB; // get FEBs - RPCEMap::febItem thisFeb; coral::IQuery* query6 = schema.newQuery(); query6->addToTableList("FEBLOCATION"); query6->addToTableList("FEBCONNECTOR"); @@ -244,6 +242,7 @@ void popcon::RPCEMapSourceHandler::readEMap1() coral::ICursor& cursor6 = query6->execute(); int nfebs=0; while (cursor6.next()) { + FEBStruct tmpFEB; nfebs++; const coral::AttributeList& row = cursor6.currentRow(); tmpFEB.febId=row["FEBLOCATIONID"].data(); @@ -258,6 +257,7 @@ void popcon::RPCEMapSourceHandler::readEMap1() } delete query6; for(unsigned int iFEB=0; iFEBsetCondition( condition, conditionData ); coral::ICursor& cursor7 = query7->execute(); + thisFeb.theChamber = -1; while (cursor7.next()) { const coral::AttributeList& row = cursor7.currentRow(); char diskOrWheel=row["DISKORWHEEL"].data()+3; From 0e4953745fdc7339c36c8ff3d1833a694aff1e17 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Mon, 1 Apr 2019 17:10:33 +0200 Subject: [PATCH 366/686] Make Modifier.isChosen() private --- .../StandardSequences/python/Eras.py | 2 +- FWCore/ParameterSet/python/Config.py | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index fde246b53c80e..05121459254e8 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -86,7 +86,7 @@ def inspectModifier(self,m,details): def inspectEra(self,e,details): print('\nEra:',e) - print(' isChosen:',getattr(self,e).isChosen()) + print(' isChosen:',getattr(self,e)._isChosen()) if details: print(' Modifiers:') nmod=0 for value in getattr(self,e).__dict__['_ModifierChain__chain']: diff --git a/FWCore/ParameterSet/python/Config.py b/FWCore/ParameterSet/python/Config.py index 17dfafed31d5e..06b8d518d1272 100644 --- a/FWCore/ParameterSet/python/Config.py +++ b/FWCore/ParameterSet/python/Config.py @@ -284,7 +284,7 @@ def vpsets_(self): def isUsingModifier(self,mod): """returns True if the Modifier is in used by this Process""" - if mod.isChosen(): + if mod._isChosen(): for m in self.__modifiers: if m._isOrContains(mod): return True @@ -1316,12 +1316,12 @@ def __init__(self, lhs, rhs=None): self._rhs = rhs def toModify(self,obj, func=None,**kw): Modifier._toModifyCheck(obj,func,**kw) - if not self.isChosen(): + if not self._isChosen(): return Modifier._toModify(obj,func,**kw) def toReplaceWith(self,toObj,fromObj): Modifier._toReplaceWithCheck(toObj,fromObj) - if not self.isChosen(): + if not self._isChosen(): return Modifier._toReplaceWith(toObj,fromObj) def makeProcessModifier(self,func): @@ -1340,22 +1340,22 @@ class _AndModifier(_BoolModifierBase): """A modifier which only applies if multiple Modifiers are chosen""" def __init__(self, lhs, rhs): super(_AndModifier,self).__init__(lhs, rhs) - def isChosen(self): - return self._lhs.isChosen() and self._rhs.isChosen() + def _isChosen(self): + return self._lhs._isChosen() and self._rhs._isChosen() class _InvertModifier(_BoolModifierBase): """A modifier which only applies if a Modifier is not chosen""" def __init__(self, lhs): super(_InvertModifier,self).__init__(lhs) - def isChosen(self): - return not self._lhs.isChosen() + def _isChosen(self): + return not self._lhs._isChosen() class _OrModifier(_BoolModifierBase): """A modifier which only applies if at least one of multiple Modifiers is chosen""" def __init__(self, lhs, rhs): super(_OrModifier,self).__init__(lhs, rhs) - def isChosen(self): - return self._lhs.isChosen() or self._rhs.isChosen() + def _isChosen(self): + return self._lhs._isChosen() or self._rhs._isChosen() class Modifier(object): @@ -1394,7 +1394,7 @@ def toModify(self,obj, func=None,**kw): mod.toModify(foo, fred = dict(pebbles = 3, friend = "barney)) ) """ Modifier._toModifyCheck(obj,func,**kw) - if not self.isChosen(): + if not self._isChosen(): return Modifier._toModify(obj,func,**kw) @staticmethod @@ -1412,7 +1412,7 @@ def toReplaceWith(self,toObj,fromObj): """If the Modifier is chosen the internals of toObj will be associated with the internals of fromObj """ Modifier._toReplaceWithCheck(toObj,fromObj) - if not self.isChosen(): + if not self._isChosen(): return Modifier._toReplaceWith(toObj,fromObj) @staticmethod @@ -1437,7 +1437,7 @@ def _toReplaceWith(toObj,fromObj): def _setChosen(self): """Should only be called by cms.Process instances""" self.__chosen = True - def isChosen(self): + def _isChosen(self): return self.__chosen def __and__(self, other): return _AndModifier(self,other) @@ -1465,7 +1465,7 @@ def _setChosen(self): self.__chosen = True for m in self.__chain: m._setChosen() - def isChosen(self): + def _isChosen(self): return self.__chosen def copyAndExclude(self, toExclude): """Creates a new ModifierChain which is a copy of @@ -1509,7 +1509,7 @@ def __init__(self, modifier, func): self.__func = func self.__seenProcesses = set() def apply(self,process): - if self.__modifier.isChosen(): + if self.__modifier._isChosen(): if process not in self.__seenProcesses: self.__func(process) self.__seenProcesses.add(process) From 9fdae9a04fe068dfa9e24bc0e01701620b446b19 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 1 Apr 2019 10:23:19 -0500 Subject: [PATCH 367/686] Make sure isPixel is always initialized in TestAssociator This fixes a compiler warning from the ASAN build. --- SimTracker/TrackerHitAssociation/test/TestAssociator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/TrackerHitAssociation/test/TestAssociator.cc b/SimTracker/TrackerHitAssociation/test/TestAssociator.cc index 79956427c47f5..e73931562924e 100644 --- a/SimTracker/TrackerHitAssociation/test/TestAssociator.cc +++ b/SimTracker/TrackerHitAssociation/test/TestAssociator.cc @@ -97,7 +97,7 @@ void TestAssociator::printRechitSimhit(const edm::Handle - - diff --git a/DetectorDescription/DDCMS/plugins/DDTECModuleAlgo.cc b/DetectorDescription/DDCMS/plugins/DDTECModuleAlgo.cc index f7edcc499283a..548c256a6a772 100644 --- a/DetectorDescription/DDCMS/plugins/DDTECModuleAlgo.cc +++ b/DetectorDescription/DDCMS/plugins/DDTECModuleAlgo.cc @@ -213,7 +213,7 @@ static long algorithm(Detector& /* description */, if (isStereo) tag = "Stereo"; //usefull constants const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight; - string idName = ns.prepend(ns.objName(mother.name())); + string idName = ns.prepend(ns.realName(mother.name())); LogDebug("TECGeom") << "idName: " << idName << " parent " << mother.name() << " namespace " << ns.name(); Solid solid; diff --git a/DetectorDescription/DDCMS/plugins/DDTECPhiAltAlgo.cc b/DetectorDescription/DDCMS/plugins/DDTECPhiAltAlgo.cc index eb2737dc238d4..37ba2588ef834 100644 --- a/DetectorDescription/DDCMS/plugins/DDTECPhiAltAlgo.cc +++ b/DetectorDescription/DDCMS/plugins/DDTECPhiAltAlgo.cc @@ -35,7 +35,7 @@ static long algorithm(Detector& /* description */, LogDebug("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name(); - + if (number > 0) { double theta = 90._deg; int copyNo = startCopyNo; diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc index e3397dbfa4896..50f15fed9c24c 100644 --- a/DetectorDescription/DDCMS/src/DDNamespace.cc +++ b/DetectorDescription/DDCMS/src/DDNamespace.cc @@ -181,6 +181,7 @@ DDNamespace::addVolume( dd4hep::Volume vol ) const string n = prepend(vol.name()); dd4hep::Solid s = vol.solid(); dd4hep::Material m = vol.material(); + //vol->SetName(n.c_str()); m_context->volumes[n] = vol; dd4hep::printout( m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s", @@ -215,7 +216,7 @@ DDNamespace::addSolidNS( const string& name, dd4hep::Solid solid ) const dd4hep::printout( m_context->debug_shapes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add shape of type %s : %s", solid->IsA()->GetName(), name.c_str()); - m_context->shapes.emplace( name, solid.setName( name )); + m_context->shapes.emplace( name, solid.setName(name)); return solid; } From 892acbdd4a5a41181918e52fec2b0dba867d1e0e Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Mon, 1 Apr 2019 18:11:31 +0200 Subject: [PATCH 369/686] Added std anemspace to avoid cxxmodule Ib errors --- DataFormats/FEDRawData/interface/DaqData.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DataFormats/FEDRawData/interface/DaqData.h b/DataFormats/FEDRawData/interface/DaqData.h index ef9060976c9f6..feac014678e90 100644 --- a/DataFormats/FEDRawData/interface/DaqData.h +++ b/DataFormats/FEDRawData/interface/DaqData.h @@ -49,6 +49,7 @@ #include #include #include +#include template class DaqData { @@ -112,8 +113,8 @@ class DaqData { catch (std::string s){ - cout<<"DaqData - Exception caught: " << s < >::const_iterator it = data_.find(indobj); if (it != data_.end()) return ((*it).second)[indfield]; else { - cout<<"DaqData - Strange: object should exist but was not found "< Date: Mon, 1 Apr 2019 18:13:54 +0200 Subject: [PATCH 370/686] cleanup dependency: DataFormats/Provenance does not depend on FWCore/MessageLogger --- DataFormats/Provenance/BuildFile.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/DataFormats/Provenance/BuildFile.xml b/DataFormats/Provenance/BuildFile.xml index 24d14d0b64ec4..4ea6baf58db1c 100644 --- a/DataFormats/Provenance/BuildFile.xml +++ b/DataFormats/Provenance/BuildFile.xml @@ -2,7 +2,6 @@ - From 4da34670355d74cacf70a5b69720ce71ce025440 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 1 Apr 2019 22:58:59 +0200 Subject: [PATCH 371/686] Modify the hit analyzer code to make tree or a set of histos --- .../HGCalValidation/test/HGCGeometryCheck.cc | 12 +- .../HGCalValidation/test/HGCHitValidation.cc | 324 +++++++++++------- .../test/runHGCalSimHitStudy_cfg.py | 3 +- 3 files changed, 213 insertions(+), 126 deletions(-) diff --git a/Validation/HGCalValidation/test/HGCGeometryCheck.cc b/Validation/HGCalValidation/test/HGCGeometryCheck.cc index 50f7294a7722b..25fddf1141946 100644 --- a/Validation/HGCalValidation/test/HGCGeometryCheck.cc +++ b/Validation/HGCalValidation/test/HGCGeometryCheck.cc @@ -97,13 +97,13 @@ void HGCGeometryCheck::beginJob() { edm::Service fs; //initiating histograms - heedzVsZ = fs->make("heedzVsZ","", 800,315,355,100,-1,1); - hefdzVsZ = fs->make("hefdzVsZ","",1200,350,410,100,-1,1); - hebdzVsZ = fs->make("hebdzVsZ","", 320,400,560,100,-5,5); + heedzVsZ = fs->make("heedzVsZ","",1400,315,385,100,-1,1); + hefdzVsZ = fs->make("hefdzVsZ","",2000,350,550,100,-1,1); + hebdzVsZ = fs->make("hebdzVsZ","", 360,380,560,100,-5,5); - heezVsLayer = fs->make("heezVsLayer","",100,0,100, 800,315,355); - hefzVsLayer = fs->make("hefzVsLayer","", 40,0, 40,1200,350,410); - hebzVsLayer = fs->make("hebzVsLayer","", 50,0, 25, 320,400,560); + heezVsLayer = fs->make("heezVsLayer","",100,0,100,1400,315,385); + hefzVsLayer = fs->make("hefzVsLayer","", 40,0, 40,2000,350,550); + hebzVsLayer = fs->make("hebzVsLayer","", 50,0, 25, 360,380,560); heerVsLayer = fs->make("heerVsLayer","",100,0,100,600,0,300); hefrVsLayer = fs->make("hefrVsLayer","", 40,0, 40,600,0,300); diff --git a/Validation/HGCalValidation/test/HGCHitValidation.cc b/Validation/HGCalValidation/test/HGCHitValidation.cc index 29f4f9f024cb6..eab0135fe2034 100644 --- a/Validation/HGCalValidation/test/HGCHitValidation.cc +++ b/Validation/HGCalValidation/test/HGCHitValidation.cc @@ -91,7 +91,7 @@ class HGCHitValidation : public edm::one::EDAnalyzer> const& simHits, - int idet, std::map&); + int idet,TH1F*,std::map&); template void analyzeHGCalRecHit(T1 const & theHits, std::map const& hitRefs); @@ -105,7 +105,7 @@ class HGCHitValidation : public edm::one::EDAnalyzer geometrySource_; std::vector ietaExcludeBH_; - bool ifHCAL_, ifHcalG_; + bool ifHCAL_, ifHcalG_, makeTree_; edm::InputTag eeSimHitSource, fhSimHitSource, bhSimHitSource; edm::EDGetTokenT> eeSimHitToken_; @@ -116,19 +116,31 @@ class HGCHitValidation : public edm::one::EDAnalyzer bhRecHitTokeng_; edm::EDGetTokenT bhRecHitTokenh_; - TTree* hgcHits; - std::vector *heeRecX, *heeRecY, *heeRecZ, *heeRecEnergy; - std::vector *hefRecX, *hefRecY, *hefRecZ, *hefRecEnergy; - std::vector *hebRecX, *hebRecY, *hebRecZ, *hebRecEnergy; - std::vector *heeSimX, *heeSimY, *heeSimZ, *heeSimEnergy; - std::vector *hefSimX, *hefSimY, *hefSimZ, *hefSimEnergy; - std::vector *hebSimX, *hebSimY, *hebSimZ, *hebSimEnergy; - std::vector *hebSimEta, *hebRecEta, *hebSimPhi, *hebRecPhi; - std::vector *heeDetID, *hefDetID, *hebDetID; + TTree *hgcHits_; + std::vector *heeRecX_, *heeRecY_, *heeRecZ_, *heeRecEnergy_; + std::vector *hefRecX_, *hefRecY_, *hefRecZ_, *hefRecEnergy_; + std::vector *hebRecX_, *hebRecY_, *hebRecZ_, *hebRecEnergy_; + std::vector *heeSimX_, *heeSimY_, *heeSimZ_, *heeSimEnergy_; + std::vector *hefSimX_, *hefSimY_, *hefSimZ_, *hefSimEnergy_; + std::vector *hebSimX_, *hebSimY_, *hebSimZ_, *hebSimEnergy_; + std::vector *hebSimEta_, *hebRecEta_, *hebSimPhi_, *hebRecPhi_; + std::vector *heeDetID_, *hefDetID_, *hebDetID_; + + TH2F *heedzVsZ_, *heedyVsY_, *heedxVsX_; + TH2F *hefdzVsZ_, *hefdyVsY_, *hefdxVsX_; + TH2F *hebdzVsZ_, *hebdPhiVsPhi_, *hebdEtaVsEta_; + TH2F *heeRecVsSimZ_, *heeRecVsSimY_, *heeRecVsSimX_; + TH2F *hefRecVsSimZ_, *hefRecVsSimY_, *hefRecVsSimX_; + TH2F *hebRecVsSimZ_, *hebRecVsSimY_, *hebRecVsSimX_; + TH2F *heeEnSimRec_, *hefEnSimRec_, *hebEnSimRec_; + TH1F *hebEnRec_, *hebEnSim_, *hefEnRec_; + TH1F *hefEnSim_, *heeEnRec_, *heeEnSim_; }; -HGCHitValidation::HGCHitValidation( const edm::ParameterSet &cfg ) : ifHcalG_(false) { +HGCHitValidation::HGCHitValidation( const edm::ParameterSet &cfg ) : + hcCons_(nullptr), hcConr_(nullptr), hcGeometry_(nullptr), + ifHcalG_(false) { usesResource(TFileService::kSharedResource); @@ -146,21 +158,32 @@ HGCHitValidation::HGCHitValidation( const edm::ParameterSet &cfg ) : ifHcalG_(fa bhRecHitSource = cfg.getParameter("bhRecHitSource"); eeRecHitToken_ = consumes(eeRecHitSource); fhRecHitToken_ = consumes(fhRecHitSource); - ietaExcludeBH_ = cfg.getParameter >("ietaExcludeBH"); + ietaExcludeBH_ = cfg.getParameter >("ietaExcludeBH"); ifHCAL_ = cfg.getParameter("ifHCAL"); if (ifHCAL_) bhRecHitTokenh_ = consumes(bhRecHitSource); else bhRecHitTokeng_ = consumes(bhRecHitSource); - hgcHits = 0; - heeRecX = heeRecY = heeRecZ = heeRecEnergy = 0; - hefRecX = hefRecY = hefRecZ = hefRecEnergy = 0; - hebRecX = hebRecY = hebRecZ = hebRecEnergy = 0; - heeSimX = heeSimY = heeSimZ = heeSimEnergy = 0; - hefSimX = hefSimY = hefSimZ = hefSimEnergy = 0; - hebSimX = hebSimY = hebSimZ = hebSimEnergy = 0; - hebSimEta= hebRecEta= hebSimPhi= hebRecPhi = 0; - heeDetID = hefDetID = hebDetID = 0; - - edm::LogVerbatim("HGCalValid") << "Use " << geometrySource_.size() + makeTree_ = cfg.getUntrackedParameter("makeTree",true); + hgcHits_ = nullptr; + heeRecX_ = heeRecY_ = heeRecZ_ = heeRecEnergy_ = nullptr; + hefRecX_ = hefRecY_ = hefRecZ_ = hefRecEnergy_ = nullptr; + hebRecX_ = hebRecY_ = hebRecZ_ = hebRecEnergy_ = nullptr; + heeSimX_ = heeSimY_ = heeSimZ_ = heeSimEnergy_ = nullptr; + hefSimX_ = hefSimY_ = hefSimZ_ = hefSimEnergy_ = nullptr; + hebSimX_ = hebSimY_ = hebSimZ_ = hebSimEnergy_ = nullptr; + hebSimEta_ = hebRecEta_ = hebSimPhi_ = hebRecPhi_ = nullptr; + heeDetID_ = hefDetID_ = hebDetID_ = nullptr; + heedzVsZ_ = heedyVsY_ = heedxVsX_ = nullptr; + hefdzVsZ_ = hefdyVsY_ = hefdxVsX_ = nullptr; + hebdzVsZ_ = hebdPhiVsPhi_= hebdEtaVsEta_= nullptr; + heeRecVsSimZ_= heeRecVsSimY_= heeRecVsSimX_= nullptr; + hefRecVsSimZ_= hefRecVsSimY_= hefRecVsSimX_= nullptr; + hebRecVsSimZ_= hebRecVsSimY_= hebRecVsSimX_= nullptr; + heeEnSimRec_ = hefEnSimRec_ = hebEnSimRec_ = nullptr; + hebEnRec_ = hebEnSim_ = hefEnRec_ = nullptr; + hefEnSim_ = heeEnRec_ = heeEnSim_ = nullptr; + + edm::LogVerbatim("HGCalValid") << "MakeTree Flag set to " << makeTree_ + << " and use " << geometrySource_.size() << " Geometry sources and HCAL flag " << ifHCAL_; for (auto const& s : geometrySource_) @@ -182,6 +205,7 @@ void HGCHitValidation::fillDescriptions(edm::ConfigurationDescriptions& descript "Hcal"}; std::vector etas; edm::ParameterSetDescription desc; + desc.addUntracked("makeTree",true); desc.addUntracked>("geometrySource",names); desc.add("eeSimHitSource",edm::InputTag("g4SimHits","HGCHitsEE")); desc.add("fhSimHitSource",edm::InputTag("g4SimHits","HGCHitsHEfront")); @@ -198,40 +222,70 @@ void HGCHitValidation::beginJob() { //initiating fileservice edm::Service fs; - hgcHits = fs->make < TTree > ("hgcHits","Hit Collection"); - hgcHits->Branch("heeRecX", &heeRecX); - hgcHits->Branch("heeRecY", &heeRecY); - hgcHits->Branch("heeRecZ", &heeRecZ); - hgcHits->Branch("heeRecEnergy", &heeRecEnergy); - hgcHits->Branch("hefRecX", &hefRecX); - hgcHits->Branch("hefRecY", &hefRecY); - hgcHits->Branch("hefRecZ", &hefRecZ); - hgcHits->Branch("hefRecEnergy", &hefRecEnergy); - hgcHits->Branch("hebRecX", &hebRecX); - hgcHits->Branch("hebRecY", &hebRecY); - hgcHits->Branch("hebRecZ", &hebRecZ); - hgcHits->Branch("hebRecEta", &hebRecEta); - hgcHits->Branch("hebRecPhi", &hebRecPhi); - hgcHits->Branch("hebRecEnergy", &hebRecEnergy); - - hgcHits->Branch("heeSimX", &heeSimX); - hgcHits->Branch("heeSimY", &heeSimY); - hgcHits->Branch("heeSimZ", &heeSimZ); - hgcHits->Branch("heeSimEnergy", &heeSimEnergy); - hgcHits->Branch("hefSimX", &hefSimX); - hgcHits->Branch("hefSimY", &hefSimY); - hgcHits->Branch("hefSimZ", &hefSimZ); - hgcHits->Branch("hefSimEnergy", &hefSimEnergy); - hgcHits->Branch("hebSimX", &hebSimX); - hgcHits->Branch("hebSimY", &hebSimY); - hgcHits->Branch("hebSimZ", &hebSimZ); - hgcHits->Branch("hebSimEta", &hebSimEta); - hgcHits->Branch("hebSimPhi", &hebSimPhi); - hgcHits->Branch("hebSimEnergy", &hebSimEnergy); - - hgcHits->Branch("heeDetID", &heeDetID); - hgcHits->Branch("hefDetID", &hefDetID); - hgcHits->Branch("hebDetID", &hebDetID); + if (makeTree_) { + hgcHits_ = fs->make < TTree > ("hgcHits","Hit Collection"); + hgcHits_->Branch("heeRecX", &heeRecX_); + hgcHits_->Branch("heeRecY", &heeRecY_); + hgcHits_->Branch("heeRecZ", &heeRecZ_); + hgcHits_->Branch("heeRecEnergy", &heeRecEnergy_); + hgcHits_->Branch("hefRecX", &hefRecX_); + hgcHits_->Branch("hefRecY", &hefRecY_); + hgcHits_->Branch("hefRecZ", &hefRecZ_); + hgcHits_->Branch("hefRecEnergy", &hefRecEnergy_); + hgcHits_->Branch("hebRecX", &hebRecX_); + hgcHits_->Branch("hebRecY", &hebRecY_); + hgcHits_->Branch("hebRecZ", &hebRecZ_); + hgcHits_->Branch("hebRecEta", &hebRecEta_); + hgcHits_->Branch("hebRecPhi", &hebRecPhi_); + hgcHits_->Branch("hebRecEnergy", &hebRecEnergy_); + + hgcHits_->Branch("heeSimX", &heeSimX_); + hgcHits_->Branch("heeSimY", &heeSimY_); + hgcHits_->Branch("heeSimZ", &heeSimZ_); + hgcHits_->Branch("heeSimEnergy", &heeSimEnergy_); + hgcHits_->Branch("hefSimX", &hefSimX_); + hgcHits_->Branch("hefSimY", &hefSimY_); + hgcHits_->Branch("hefSimZ", &hefSimZ_); + hgcHits_->Branch("hefSimEnergy", &hefSimEnergy_); + hgcHits_->Branch("hebSimX", &hebSimX_); + hgcHits_->Branch("hebSimY", &hebSimY_); + hgcHits_->Branch("hebSimZ", &hebSimZ_); + hgcHits_->Branch("hebSimEta", &hebSimEta_); + hgcHits_->Branch("hebSimPhi", &hebSimPhi_); + hgcHits_->Branch("hebSimEnergy", &hebSimEnergy_); + + hgcHits_->Branch("heeDetID", &heeDetID_); + hgcHits_->Branch("hefDetID", &hefDetID_); + hgcHits_->Branch("hebDetID", &hebDetID_); + } else { + heedzVsZ_ = fs->make("heedzVsZ","",7200,-360,360,100,-0.1,0.1); + heedyVsY_ = fs->make("heedyVsY","",400,-200,200,100,-0.02,0.02); + heedxVsX_ = fs->make("heedxVsX","",400,-200,200,100,-0.02,0.02); + heeRecVsSimZ_ = fs->make("heeRecVsSimZ","",7200,-360,360,7200,-360,360); + heeRecVsSimY_ = fs->make("heeRecVsSimY","",400,-200,200,400,-200,200); + heeRecVsSimX_ = fs->make("heeRecVsSimX","",400,-200,200,400,-200,200); + hefdzVsZ_ = fs->make("hefdzVsZ","",8200,-410,410,100,-0.1,0.1); + hefdyVsY_ = fs->make("hefdyVsY","",400,-200,200,100,-0.02,0.02); + hefdxVsX_ = fs->make("hefdxVsX","",400,-200,200,100,-0.02,0.02); + hefRecVsSimZ_ = fs->make("hefRecVsSimZ","",8200,-410,410,8200,-410,410); + hefRecVsSimY_ = fs->make("hefRecVsSimY","",400,-200,200,400,-200,200); + hefRecVsSimX_ = fs->make("hefRecVsSimX","",400,-200,200,400,-200,200); + hebdzVsZ_ = fs->make("hebdzVsZ","",1080,-540,540,100,-1.0,1.0); + hebdPhiVsPhi_ = fs->make("hebdPhiVsPhi","",M_PI*100,-0.5,M_PI+0.5,200,-0.2,0.2); + hebdEtaVsEta_ = fs->make("hebdEtaVsEta","",1000,-5,5,200,-0.1,0.1); + hebRecVsSimZ_ = fs->make("hebRecVsSimZ","",1080,-540,540,1080,-540,540); + hebRecVsSimY_ = fs->make("hebRecVsSimY","",400,-200,200,400,-200,200); + hebRecVsSimX_ = fs->make("hebRecVsSimX","",400,-200,200,400,-200,200); + heeEnRec_ = fs->make("heeEnRec","",1000,0,10); + heeEnSim_ = fs->make("heeEnSim","",1000,0,0.01); + heeEnSimRec_ = fs->make("heeEnSimRec","",200,0,0.002,200,0,0.2); + hefEnRec_ = fs->make("hefEnRec","",1000,0,10); + hefEnSim_ = fs->make("hefEnSim","",1000,0,0.01); + hefEnSimRec_ = fs->make("hefEnSimRec","",200,0,0.001,200,0,0.5); + hebEnRec_ = fs->make("hebEnRec","",1000,0,15); + hebEnSim_ = fs->make("hebEnSim","",1000,0,0.01); + hebEnSimRec_ = fs->make("hebEnSimRec","",200,0,0.02,200,0,4); + } } void HGCHitValidation::beginRun(edm::Run const& iRun, @@ -301,7 +355,7 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup iEvent.getByToken(eeSimHitToken_, eeSimHits); if (eeSimHits.isValid()) { - analyzeHGCalSimHit(eeSimHits, 0, eeHitRefs); + analyzeHGCalSimHit(eeSimHits, 0, heeEnSim_, eeHitRefs); for (std::map::iterator itr=eeHitRefs.begin(); itr != eeHitRefs.end(); ++itr) { int idx = std::distance(eeHitRefs.begin(),itr); @@ -320,7 +374,7 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup edm::Handle> fhSimHits; iEvent.getByToken(fhSimHitToken_, fhSimHits); if (fhSimHits.isValid()) { - analyzeHGCalSimHit(fhSimHits, 1, fhHitRefs); + analyzeHGCalSimHit(fhSimHits, 1, hefEnSim_, fhHitRefs); for (std::map::iterator itr=fhHitRefs.begin(); itr != fhHitRefs.end(); ++itr) { int idx = std::distance(fhHitRefs.begin(),itr); @@ -358,6 +412,7 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup float energySum(0); if (bhHitRefs.count(id.rawId()) != 0) energySum = std::get<0>(bhHitRefs[id.rawId()]); energySum += energy; + if (!makeTree_) hebEnSim_->Fill(energy); if (std::find(ietaExcludeBH_.begin(),ietaExcludeBH_.end(),idx.eta) == ietaExcludeBH_.end()) { bhHitRefs[id.rawId()] = std::make_tuple(energySum,cell.eta,cell.phi,zp); @@ -369,7 +424,7 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup } } } else { - analyzeHGCalSimHit(bhSimHits, 2, bhHitRefs); + analyzeHGCalSimHit(bhSimHits, 2, hebEnSim_, bhHitRefs); } for (std::map::iterator itr=bhHitRefs.begin(); itr != bhHitRefs.end(); ++itr) { @@ -391,22 +446,30 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup if (eeRecHit.isValid()) { const HGCeeRecHitCollection* theHits = (eeRecHit.product()); for (auto it = theHits->begin(); it != theHits->end(); ++it) { - double energy = it->energy(); + double energy = it->energy(); + if (!makeTree_) heeEnRec_->Fill(energy); std::map::const_iterator itr = eeHitRefs.find(it->id().rawId()); if (itr != eeHitRefs.end()) { GlobalPoint xyz = hgcGeometry_[0]->getPosition(it->id()); - - heeRecX->push_back(xyz.x()); - heeRecY->push_back(xyz.y()); - heeRecZ->push_back(xyz.z()); - heeRecEnergy->push_back(energy); - - heeSimX->push_back(std::get<1>(itr->second)); - heeSimY->push_back(std::get<2>(itr->second)); - heeSimZ->push_back(std::get<3>(itr->second)); - heeSimEnergy->push_back(std::get<0>(itr->second)); - - heeDetID->push_back(itr->first); + if (makeTree_) { + heeRecX_->push_back(xyz.x()); + heeRecY_->push_back(xyz.y()); + heeRecZ_->push_back(xyz.z()); + heeRecEnergy_->push_back(energy); + heeSimX_->push_back(std::get<1>(itr->second)); + heeSimY_->push_back(std::get<2>(itr->second)); + heeSimZ_->push_back(std::get<3>(itr->second)); + heeSimEnergy_->push_back(std::get<0>(itr->second)); + heeDetID_->push_back(itr->first); + } else { + heeRecVsSimX_->Fill(std::get<1>(itr->second),xyz.x()); + heeRecVsSimY_->Fill(std::get<2>(itr->second),xyz.y()); + heeRecVsSimZ_->Fill(std::get<3>(itr->second),xyz.z()); + heedxVsX_->Fill(std::get<1>(itr->second),(xyz.x()-std::get<1>(itr->second))); + heedyVsY_->Fill(std::get<2>(itr->second),(xyz.y()-std::get<2>(itr->second))); + heedzVsZ_->Fill(std::get<3>(itr->second),(xyz.z()-std::get<3>(itr->second))); + heeEnSimRec_->Fill(std::get<0>(itr->second),energy); + } edm::LogVerbatim("HGCalValid") << "EEHit: " << std::hex << it->id().rawId() << std::dec << " Sim (" << std::get<0>(itr->second) @@ -429,21 +492,29 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup const HGChefRecHitCollection* theHits = (fhRecHit.product()); for (auto it = theHits->begin(); it!=theHits->end(); ++it) { double energy = it->energy(); + if (!makeTree_) hefEnRec_->Fill(energy); std::map::const_iterator itr = fhHitRefs.find(it->id().rawId()); if (itr != fhHitRefs.end()) { GlobalPoint xyz = hgcGeometry_[1]->getPosition(it->id()); - - hefRecX->push_back(xyz.x()); - hefRecY->push_back(xyz.y()); - hefRecZ->push_back(xyz.z()); - hefRecEnergy->push_back(energy); - - hefSimX->push_back(std::get<1>(itr->second)); - hefSimY->push_back(std::get<2>(itr->second)); - hefSimZ->push_back(std::get<3>(itr->second)); - hefSimEnergy->push_back(std::get<0>(itr->second)); - - hefDetID->push_back(itr->first); + if (makeTree_) { + hefRecX_->push_back(xyz.x()); + hefRecY_->push_back(xyz.y()); + hefRecZ_->push_back(xyz.z()); + hefRecEnergy_->push_back(energy); + hefSimX_->push_back(std::get<1>(itr->second)); + hefSimY_->push_back(std::get<2>(itr->second)); + hefSimZ_->push_back(std::get<3>(itr->second)); + hefSimEnergy_->push_back(std::get<0>(itr->second)); + hefDetID_->push_back(itr->first); + } else { + hefRecVsSimX_->Fill(std::get<1>(itr->second),xyz.x()); + hefRecVsSimY_->Fill(std::get<2>(itr->second),xyz.y()); + hefRecVsSimZ_->Fill(std::get<3>(itr->second),xyz.z()); + hefdxVsX_->Fill(std::get<1>(itr->second),(xyz.x()-std::get<1>(itr->second))); + hefdyVsY_->Fill(std::get<2>(itr->second),(xyz.y()-std::get<2>(itr->second))); + hefdzVsZ_->Fill(std::get<3>(itr->second),(xyz.z()-std::get<3>(itr->second))); + hefEnSimRec_->Fill(std::get<0>(itr->second),energy); + } edm::LogVerbatim("HGCalValid") << "FHHit: " << std::hex << it->id().rawId() << std::dec << " Sim (" << std::get<0>(itr->second) @@ -480,26 +551,32 @@ void HGCHitValidation::analyze( const edm::Event &iEvent, const edm::EventSetup } } - hgcHits->Fill(); - - heeRecX->clear(); heeRecY->clear(); heeRecZ->clear(); heeRecEnergy->clear(); - hefRecX->clear(); hefRecY->clear(); hefRecZ->clear(); hefRecEnergy->clear(); - hebRecX->clear(); hebRecY->clear(); hebRecZ->clear(); hebRecEnergy->clear(); - heeSimX->clear(); heeSimY->clear(); heeSimZ->clear(); heeSimEnergy->clear(); - hefSimX->clear(); hefSimY->clear(); hefSimZ->clear(); hefSimEnergy->clear(); - hebSimX->clear(); hebSimY->clear(); hebSimZ->clear(); hebSimEnergy->clear(); - hebSimEta->clear(); hebRecEta->clear(); - hebSimPhi->clear(); hebRecPhi->clear(); - heeDetID->clear(); hefDetID->clear(); hebDetID->clear(); + if (makeTree_) { + hgcHits_->Fill(); + + heeRecX_->clear(); heeRecY_->clear(); heeRecZ_->clear(); + hefRecX_->clear(); hefRecY_->clear(); hefRecZ_->clear(); + hebRecX_->clear(); hebRecY_->clear(); hebRecZ_->clear(); + heeRecEnergy_->clear(); hefRecEnergy_->clear(); hebRecEnergy_->clear(); + heeSimX_->clear(); heeSimY_->clear(); heeSimZ_->clear(); + hefSimX_->clear(); hefSimY_->clear(); hefSimZ_->clear(); + hebSimX_->clear(); hebSimY_->clear(); hebSimZ_->clear(); + heeSimEnergy_->clear(); hefSimEnergy_->clear(); hebSimEnergy_->clear(); + hebSimEta_->clear(); hebRecEta_->clear(); + hebSimPhi_->clear(); hebRecPhi_->clear(); + heeDetID_->clear(); hefDetID_->clear(); hebDetID_->clear(); + } } void HGCHitValidation::endJob() { - hgcHits->GetDirectory()->cd(); - hgcHits->Write(); + if (makeTree_) { + hgcHits_->GetDirectory()->cd(); + hgcHits_->Write(); + } } void HGCHitValidation::analyzeHGCalSimHit(edm::Handle> const& simHits, - int idet, + int idet, TH1F *hist, std::map& hitRefs) { const HGCalTopology &hTopo=hgcGeometry_[idet]->topology(); @@ -553,10 +630,12 @@ void HGCHitValidation::analyzeHGCalSimHit(edm::Handle> con if (zside < 0) zp = -zp; float xp = (zside<0) ? -xy.first/10 : xy.first/10; float yp = xy.second/10.0; + float energy = simHit.energy(); - float energySum(simHit.energy()); + float energySum(energy); if (hitRefs.count(id) != 0) energySum += std::get<0>(hitRefs[id]); hitRefs[id] = std::make_tuple(energySum,xp,yp,zp); + if (hist != nullptr) hist->Fill(energy); edm::LogVerbatim("HGCalValid") << "Position (" << xp << ", " << yp << ", " << zp << ") " << " Energy " << simHit.energy() << ":" << energySum; @@ -573,7 +652,8 @@ void HGCHitValidation::analyzeHGCalRecHit(T1 const & theHits, bool ok = (ifHCAL_) ? (id.subdetId() == (int)(HcalEndcap)) : true; if (ok) { double energy = it->energy(); - GlobalPoint xyz = (hcGeometry_ ? + if (!makeTree_) hebEnRec_->Fill(energy); + GlobalPoint xyz = (ifHcalG_ ? (hcGeometry_->getGeometry(id)->getPosition()) : (hgcGeometry_[2]->getPosition(id))); @@ -584,23 +664,29 @@ void HGCHitValidation::analyzeHGCalRecHit(T1 const & theHits, double pT = std::get<3>(itr->second) / fac; double xp = pT * cos(std::get<2>(itr->second)); double yp = pT * sin(std::get<2>(itr->second)); - - hebRecX->push_back(xyz.x()); - hebRecY->push_back(xyz.y()); - hebRecZ->push_back(xyz.z()); - hebRecEnergy->push_back(energy); - - hebSimX->push_back(xp); - hebSimY->push_back(yp); - hebSimZ->push_back(std::get<3>(itr->second)); - hebSimEnergy->push_back(std::get<0>(itr->second)); - - hebSimEta->push_back(std::get<1>(itr->second)); - hebRecEta->push_back(xyz.eta()); - hebSimPhi->push_back(std::get<2>(itr->second)); - hebRecPhi->push_back(ang3); - - hebDetID->push_back(itr->first); + if (makeTree_) { + hebRecX_->push_back(xyz.x()); + hebRecY_->push_back(xyz.y()); + hebRecZ_->push_back(xyz.z()); + hebRecEnergy_->push_back(energy); + hebSimX_->push_back(xp); + hebSimY_->push_back(yp); + hebSimZ_->push_back(std::get<3>(itr->second)); + hebSimEnergy_->push_back(std::get<0>(itr->second)); + hebSimEta_->push_back(std::get<1>(itr->second)); + hebRecEta_->push_back(xyz.eta()); + hebSimPhi_->push_back(std::get<2>(itr->second)); + hebRecPhi_->push_back(ang3); + hebDetID_->push_back(itr->first); + } else { + hebRecVsSimX_->Fill(xp,xyz.x()); + hebRecVsSimY_->Fill(yp,xyz.y()); + hebRecVsSimZ_->Fill(std::get<3>(itr->second),xyz.z()); + hebdEtaVsEta_->Fill(std::get<1>(itr->second),(xyz.eta()-std::get<1>(itr->second))); + hebdPhiVsPhi_->Fill(std::get<2>(itr->second),(ang3-std::get<2>(itr->second))); + hebdzVsZ_->Fill(std::get<3>(itr->second),(xyz.z()-std::get<3>(itr->second))); + hebEnSimRec_->Fill(std::get<0>(itr->second),energy); + } edm::LogVerbatim("HGCalValid") << "BHHit: " << std::hex << id.rawId() << std::dec << " Sim (" << std::get<0>(itr->second) << ", " diff --git a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py index 17ae86564f9d5..76fdd298bbc3f 100644 --- a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py @@ -32,7 +32,7 @@ process.Timing = cms.Service("Timing") process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(5000) + input = cms.untracked.int32(10000) ) process.source = cms.Source("EmptySource", @@ -72,6 +72,7 @@ process.g4SimHits.Physics.type = 'SimG4Core/Physics/FTFP_BERT_EMM' process.g4SimHits.Physics.DefaultCutValue = 0.1 process.hgcalSimHitStudy.verbosity = 0 +process.hgcalSimHitStudy.nBinZ = 3000 # Schedule definition process.schedule = cms.Schedule(process.generation_step, From 13cfe0994c4ef5349a780597ebed10f4a3bef08c Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 2 Apr 2019 09:16:27 +0200 Subject: [PATCH 372/686] Fix namespace in a test config --- .../DDCMS/test/python/testDDDetectorESProducer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DetectorDescription/DDCMS/test/python/testDDDetectorESProducer.py b/DetectorDescription/DDCMS/test/python/testDDDetectorESProducer.py index 2d1479d820653..b11634b7c9534 100644 --- a/DetectorDescription/DDCMS/test/python/testDDDetectorESProducer.py +++ b/DetectorDescription/DDCMS/test/python/testDDDetectorESProducer.py @@ -50,7 +50,7 @@ process.test = cms.EDAnalyzer("DDTestNavigateGeometry", DDDetector = cms.ESInputTag('MUON'), detElementPath = cms.string(''), - placedVolumePath = cms.string('/world_volume_1/cms:OCMS_1/cms:CMSE_1/muonBase:MUON_1') + placedVolumePath = cms.string('/world_volume_1/OCMS_1/CMSE_1/MUON_1') ) process.p = cms.Path(process.test) From eb84411222b0f2e2ba7e4e963855ffda97de0da5 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 10:52:59 +0100 Subject: [PATCH 373/686] Passing geometry to rechits producer by reference --- .../interface/CTPPSDiamondRecHitProducerAlgorithm.h | 2 +- .../TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc | 6 +----- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 6 ++++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h index 3674df62f9bc3..581a40132358d 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h @@ -25,7 +25,7 @@ class CTPPSDiamondRecHitProducerAlgorithm public: CTPPSDiamondRecHitProducerAlgorithm( const edm::ParameterSet& conf ); - void build( const CTPPSGeometry*, const edm::DetSetVector&, edm::DetSetVector& ); + void build( const CTPPSGeometry&, const edm::DetSetVector&, edm::DetSetVector& ); private: /// Conversion constant between HPTDC time slice and absolute time (in ns) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc index e223b77b46c17..e64329f5c465c 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc @@ -34,7 +34,6 @@ class CTPPSDiamondRecHitProducer : public edm::stream::EDProducer<> { public: explicit CTPPSDiamondRecHitProducer( const edm::ParameterSet& ); - ~CTPPSDiamondRecHitProducer() override; static void fillDescriptions( edm::ConfigurationDescriptions& ); @@ -56,9 +55,6 @@ CTPPSDiamondRecHitProducer::CTPPSDiamondRecHitProducer( const edm::ParameterSet& produces >(); } -CTPPSDiamondRecHitProducer::~CTPPSDiamondRecHitProducer() -{} - void CTPPSDiamondRecHitProducer::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) { @@ -73,7 +69,7 @@ CTPPSDiamondRecHitProducer::produce( edm::Event& iEvent, const edm::EventSetup& iSetup.get().get( geometry ); // produce the rechits collection - algo_.build( geometry.product(), *( digis ), *( pOut ) ); + algo_.build( *geometry, *digis, *pOut ); iEvent.put( std::move( pOut ) ); } diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index ca328cd6111a3..826e848f205e5 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -15,7 +15,9 @@ CTPPSDiamondRecHitProducerAlgorithm::CTPPSDiamondRecHitProducerAlgorithm( const {} void -CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry* geom, const edm::DetSetVector& input, edm::DetSetVector& output ) +CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, + const edm::DetSetVector& input, + edm::DetSetVector& output ) { for ( const auto& vec : input ) { const CTPPSDiamondDetId detid( vec.detId() ); @@ -23,7 +25,7 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry* geom, const edm if ( detid.channel() > 20 ) continue; // VFAT-like information, to be ignored // retrieve the geometry element associated to this DetID - const DetGeomDesc* det = geom->getSensor( detid ); + const DetGeomDesc* det = geom.getSensor( detid ); const float x_pos = det->translation().x(), y_pos = det->translation().y(); From fdf601662c02ad7af4018bffa593e67cc74889b3 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 10:56:33 +0100 Subject: [PATCH 374/686] Only fill output rechits collection if digis are found --- .../plugins/CTPPSDiamondRecHitProducer.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc index e64329f5c465c..0b19f474ca914 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc @@ -58,18 +58,20 @@ CTPPSDiamondRecHitProducer::CTPPSDiamondRecHitProducer( const edm::ParameterSet& void CTPPSDiamondRecHitProducer::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) { - std::unique_ptr > pOut( new edm::DetSetVector ); + auto pOut = std::make_unique >(); // get the digi collection edm::Handle > digis; iEvent.getByToken( digiToken_, digis ); - // get the geometry - edm::ESHandle geometry; - iSetup.get().get( geometry ); + if ( !digis->empty() ) { + // get the geometry + edm::ESHandle geometry; + iSetup.get().get( geometry ); - // produce the rechits collection - algo_.build( *geometry, *digis, *pOut ); + // produce the rechits collection + algo_.build( *geometry, *digis, *pOut ); + } iEvent.put( std::move( pOut ) ); } From 7fc94da01ccd9dec34f536522b988fe1f5869d95 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 11:04:16 +0100 Subject: [PATCH 375/686] Can now feed calibration parameters to the algorithm --- .../interface/CTPPSDiamondRecHitProducerAlgorithm.h | 4 ++++ .../plugins/CTPPSDiamondRecHitProducer.cc | 11 +++++++++-- .../src/CTPPSDiamondRecHitProducerAlgorithm.cc | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h index 581a40132358d..394cd9dda2ed3 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h @@ -20,16 +20,20 @@ #include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" +#include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" + class CTPPSDiamondRecHitProducerAlgorithm { public: CTPPSDiamondRecHitProducerAlgorithm( const edm::ParameterSet& conf ); + void setCalibration( const PPSTimingCalibration& ); void build( const CTPPSGeometry&, const edm::DetSetVector&, edm::DetSetVector& ); private: /// Conversion constant between HPTDC time slice and absolute time (in ns) double ts_to_ns_; + PPSTimingCalibration calib_; }; #endif diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc index 0b19f474ca914..c048074753e8b 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc @@ -14,6 +14,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" @@ -29,6 +30,7 @@ #include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" +#include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h" class CTPPSDiamondRecHitProducer : public edm::stream::EDProducer<> { @@ -42,8 +44,8 @@ class CTPPSDiamondRecHitProducer : public edm::stream::EDProducer<> edm::EDGetTokenT > digiToken_; - /// A watcher to detect geometry changes. - //edm::ESWatcher geometryWatcher_; + /// A watcher to detect timing calibration changes. + edm::ESWatcher calibWatcher_; CTPPSDiamondRecHitProducerAlgorithm algo_; }; @@ -65,6 +67,11 @@ CTPPSDiamondRecHitProducer::produce( edm::Event& iEvent, const edm::EventSetup& iEvent.getByToken( digiToken_, digis ); if ( !digis->empty() ) { + if ( calibWatcher_.check( iSetup ) ) { + edm::ESHandle hTimingCalib; + iSetup.get().get( hTimingCalib ); + algo_.setCalibration( *hTimingCalib ); + } // get the geometry edm::ESHandle geometry; iSetup.get().get( geometry ); diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 826e848f205e5..991622ac6f141 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -14,6 +14,12 @@ CTPPSDiamondRecHitProducerAlgorithm::CTPPSDiamondRecHitProducerAlgorithm( const ts_to_ns_( iConfig.getParameter( "timeSliceNs" ) ) {} +void +CTPPSDiamondRecHitProducerAlgorithm::setCalibration( const PPSTimingCalibration& calib ) +{ + calib_ = calib; +} + void CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, const edm::DetSetVector& input, @@ -58,3 +64,4 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, } } } + From 1237f96b41daeb8a6f11cb2ea56d456f4aaa5f7c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 11:38:02 +0100 Subject: [PATCH 376/686] First matches to the algorithm, calibration retrieval from db in test --- .../CTPPSDiamondRecHitProducerAlgorithm.h | 4 ++ .../CTPPSDiamondRecHitProducerAlgorithm.cc | 47 +++++++++++++------ .../TotemRPLocal/test/diamonds_reco_cfg.py | 20 +++++++- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h index 394cd9dda2ed3..9cc0c9cc6e01e 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h @@ -10,6 +10,7 @@ #define RecoCTPPS_TotemRPLocal_CTPPSDiamondRecHitProducerAlgorithm #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CommonTools/Utils/interface/FormulaEvaluator.h" #include "DataFormats/Common/interface/DetSetVector.h" @@ -31,9 +32,12 @@ class CTPPSDiamondRecHitProducerAlgorithm void build( const CTPPSGeometry&, const edm::DetSetVector&, edm::DetSetVector& ); private: + static constexpr unsigned short MAX_CHANNEL = 20; /// Conversion constant between HPTDC time slice and absolute time (in ns) double ts_to_ns_; PPSTimingCalibration calib_; + std::unique_ptr calib_fct_; }; #endif + diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 991622ac6f141..b4babd950032c 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -18,6 +18,7 @@ void CTPPSDiamondRecHitProducerAlgorithm::setCalibration( const PPSTimingCalibration& calib ) { calib_ = calib; + calib_fct_.reset( new reco::FormulaEvaluator( calib_.formula() ) ); } void @@ -28,7 +29,8 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, for ( const auto& vec : input ) { const CTPPSDiamondDetId detid( vec.detId() ); - if ( detid.channel() > 20 ) continue; // VFAT-like information, to be ignored + if ( detid.channel() > MAX_CHANNEL ) // VFAT-like information, to be ignored + continue; // retrieve the geometry element associated to this DetID const DetGeomDesc* det = geom.getSensor( detid ); @@ -42,25 +44,42 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, y_width = 2.0 * det->params().at( 1 ), z_width = 2.0 * det->params().at( 2 ); + // retrieve the timing calibration part for this channel + const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); + const auto& ch_params = calib_.parameters( sector, station, plane, channel ); + const double ch_t_offset = calib_.timeOffset( sector, station, plane, channel ); + const double ch_t_precis = calib_.timePrecision( sector, station, plane, channel ); + edm::DetSet& rec_hits = output.find_or_insert( detid ); for ( const auto& digi : vec ) { - if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() == 0 ) continue; + if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() == 0 ) + continue; const int t = digi.getLeadingEdge(); const int t0 = t % 1024; - const int time_slice = ( t != 0 ) ? t / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; - - int tot = 0; - if ( t != 0 && digi.getTrailingEdge() != 0 ) tot = ( (int)digi.getTrailingEdge() ) - t; - - rec_hits.push_back( CTPPSDiamondRecHit( x_pos, x_width, y_pos, y_width, z_pos, z_width, // spatial information - ( t0 * ts_to_ns_ ), - ( tot * ts_to_ns_), - 0., // time precision - time_slice, - digi.getHPTDCErrorFlags(), - digi.getMultipleHit() ) ); + const int time_slice = ( t != 0 ) + ? t / 1024 + : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; + + const int tot = ( t != 0 && digi.getTrailingEdge() != 0 ) + ? ( (int)digi.getTrailingEdge() ) - t + : 0; + + rec_hits.push_back( CTPPSDiamondRecHit( + // spatial information + x_pos, x_width, + y_pos, y_width, + z_pos, z_width, + // timing information + ( t0 * ts_to_ns_ ) + ch_t_offset, + ( tot * ts_to_ns_), + ch_t_precis, + time_slice, + // readout information + digi.getHPTDCErrorFlags(), + digi.getMultipleHit() + ) ); } } } diff --git a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py index da783586b1441..181d791df60c5 100644 --- a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py +++ b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py @@ -20,7 +20,8 @@ #) process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring( - '/store/data/Run2017E/ZeroBias/RAW/v1/000/304/447/00000/001C958C-7FA9-E711-858F-02163E011A5F.root', +# '/store/data/Run2017E/ZeroBias/RAW/v1/000/304/447/00000/001C958C-7FA9-E711-858F-02163E011A5F.root', + '/store/data/Commissioning2018/ZeroBias/RAW/v1/000/314/816/00000/FCDB2DE6-4845-E811-91A1-FA163E6CD0D3.root', ), ) @@ -28,6 +29,21 @@ input = cms.untracked.int32(1000) ) +# load calibrations from database +process.load('CondCore.CondDB.CondDB_cfi') +process.CondDB.connect = 'sqlite_file:ppsDiamondTiming_calibration.sqlite' # SQLite input + +process.PoolDBESSource = cms.ESSource('PoolDBESSource', + process.CondDB, + DumpStats = cms.untracked.bool(True), + toGet = cms.VPSet( + cms.PSet( + record = cms.string('PPSTimingCalibrationRcd'), + tag = cms.string('PPSDiamondTimingCalibration') + ) + ) +) + # raw-to-digi conversion process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") @@ -35,7 +51,7 @@ process.load("RecoCTPPS.Configuration.recoCTPPS_cff") # rechits production -process.load('Geometry.VeryForwardGeometry.geometryRP_cfi') +process.load('Geometry.VeryForwardGeometry.geometryRPFromDD_2018_cfi') process.load('RecoCTPPS.TotemRPLocal.ctppsDiamondRecHits_cfi') # local tracks fitter From 7d20854c3fc5a01d5c1486f181512d3f91d52703 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 16:26:47 +0100 Subject: [PATCH 377/686] Implementation of timing calibration corrections --- .../CTPPSDiamondRecHitProducerAlgorithm.cc | 26 ++++++++++++------- .../TotemRPLocal/test/diamonds_reco_cfg.py | 3 ++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index b4babd950032c..802fe0b616a48 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -7,6 +7,7 @@ ****************************************************************************/ #include "RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h" +#include // isnan //---------------------------------------------------------------------------------------------------- @@ -45,7 +46,8 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, z_width = 2.0 * det->params().at( 2 ); // retrieve the timing calibration part for this channel - const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); + //const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); + const int sector = detid.arm(), station = 0, plane = detid.plane(), channel = detid.channel(); const auto& ch_params = calib_.parameters( sector, station, plane, channel ); const double ch_t_offset = calib_.timeOffset( sector, station, plane, channel ); const double ch_t_precis = calib_.timePrecision( sector, station, plane, channel ); @@ -56,15 +58,19 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() == 0 ) continue; - const int t = digi.getLeadingEdge(); - const int t0 = t % 1024; - const int time_slice = ( t != 0 ) - ? t / 1024 + const int t_lead = digi.getLeadingEdge(), t_trail = digi.getTrailingEdge(); + const int time_slice = ( t_lead != 0 ) + ? t_lead / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; - const int tot = ( t != 0 && digi.getTrailingEdge() != 0 ) - ? ( (int)digi.getTrailingEdge() ) - t - : 0; + const double tot = ( t_lead != 0 && t_trail != 0 ) + ? ( t_trail-t_lead )*ts_to_ns_ + : 0.; + + const double t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); + const double t0 = ( t_lead % 1024 )*ts_to_ns_ + + ch_t_offset + + ( !std::isnan( t_mean ) ? t_mean : 0. ); rec_hits.push_back( CTPPSDiamondRecHit( // spatial information @@ -72,8 +78,8 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, y_pos, y_width, z_pos, z_width, // timing information - ( t0 * ts_to_ns_ ) + ch_t_offset, - ( tot * ts_to_ns_), + t0, + tot, ch_t_precis, time_slice, // readout information diff --git a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py index 181d791df60c5..bdc6a1a52a295 100644 --- a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py +++ b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py @@ -26,8 +26,9 @@ ) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000) + input = cms.untracked.int32(-1) ) +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32( 1000 ) # load calibrations from database process.load('CondCore.CondDB.CondDB_cfi') From d8b1bd51be53a89a3fd86da5e59c149d6777c88e Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 4 Mar 2019 16:49:11 +0100 Subject: [PATCH 378/686] Include chain cleanup --- RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc index c048074753e8b..c9397ece79570 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc @@ -29,7 +29,6 @@ #include "RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h" #include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" -#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h" class CTPPSDiamondRecHitProducer : public edm::stream::EDProducer<> From 7baa19f111b513834f1aaf66755989e6afd24924 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 5 Mar 2019 14:13:05 +0100 Subject: [PATCH 379/686] Fixed sign convention --- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 2 +- RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 802fe0b616a48..75558fca47d46 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -70,7 +70,7 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, const double t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); const double t0 = ( t_lead % 1024 )*ts_to_ns_ + ch_t_offset - + ( !std::isnan( t_mean ) ? t_mean : 0. ); + - ( !std::isnan( t_mean ) ? t_mean : 0. ); rec_hits.push_back( CTPPSDiamondRecHit( // spatial information diff --git a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py index bdc6a1a52a295..5eb8779522318 100644 --- a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py +++ b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py @@ -21,7 +21,8 @@ process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring( # '/store/data/Run2017E/ZeroBias/RAW/v1/000/304/447/00000/001C958C-7FA9-E711-858F-02163E011A5F.root', - '/store/data/Commissioning2018/ZeroBias/RAW/v1/000/314/816/00000/FCDB2DE6-4845-E811-91A1-FA163E6CD0D3.root', +# '/store/data/Commissioning2018/ZeroBias/RAW/v1/000/314/816/00000/FCDB2DE6-4845-E811-91A1-FA163E6CD0D3.root', + '/store/data/Run2018C/DoubleMuon/RAW/v1/000/319/525/00000/CE9C5CAC-AD85-E811-852B-FA163E26680F.root', ), ) From b1c0f0b38ecb5ee383cd48ecaeddf15dce08b8da Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 18 Mar 2019 16:16:15 +0100 Subject: [PATCH 380/686] Using emplace_back instead of push_back + copy --- .../src/CTPPSDiamondRecHitProducerAlgorithm.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 75558fca47d46..a71d91384698b 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -72,20 +72,15 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, + ch_t_offset - ( !std::isnan( t_mean ) ? t_mean : 0. ); - rec_hits.push_back( CTPPSDiamondRecHit( + rec_hits.emplace_back( // spatial information - x_pos, x_width, - y_pos, y_width, - z_pos, z_width, + x_pos, x_width, y_pos, y_width, z_pos, z_width, // timing information - t0, - tot, - ch_t_precis, - time_slice, + t0, tot, ch_t_precis, time_slice, // readout information digi.getHPTDCErrorFlags(), digi.getMultipleHit() - ) ); + ); } } } From dd029d728a7f005de777ab45d4c0ae7e1b87f246 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 18 Mar 2019 16:24:10 +0100 Subject: [PATCH 381/686] Cleanup; not computing tot corrections if invalid tot --- .../CTPPSDiamondRecHitProducerAlgorithm.cc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index a71d91384698b..b2e259289b6c7 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -55,22 +55,22 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, edm::DetSet& rec_hits = output.find_or_insert( detid ); for ( const auto& digi : vec ) { - if ( digi.getLeadingEdge() == 0 && digi.getTrailingEdge() == 0 ) + const int t_lead = digi.getLeadingEdge(), t_trail = digi.getTrailingEdge(); + if ( t_lead == 0 && t_trail == 0 ) continue; - const int t_lead = digi.getLeadingEdge(), t_trail = digi.getTrailingEdge(); const int time_slice = ( t_lead != 0 ) ? t_lead / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; - const double tot = ( t_lead != 0 && t_trail != 0 ) - ? ( t_trail-t_lead )*ts_to_ns_ - : 0.; - - const double t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); - const double t0 = ( t_lead % 1024 )*ts_to_ns_ - + ch_t_offset - - ( !std::isnan( t_mean ) ? t_mean : 0. ); + double tot = -1., t_mean = 0.; + if ( t_lead != 0 && t_trail != 0 ) { + tot = ( t_trail-t_lead )*ts_to_ns_; + t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); + if ( std::isnan( t_mean ) ) + t_mean = 0.; + } + const double t0 = ( t_lead % 1024 )*ts_to_ns_+ ch_t_offset-t_mean; rec_hits.emplace_back( // spatial information From 35fe3f2bd1c903bbb05fd07ffbfe49444f08fb2d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 10:07:59 +0100 Subject: [PATCH 382/686] Ensure calibration function is defined before applying its correction --- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index b2e259289b6c7..49d7ee2147763 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -1,6 +1,6 @@ /**************************************************************************** * -* This is a part of CTPPS offline software. +* This is a part of PPS offline software. * Authors: * Laurent Forthomme (laurent.forthomme@cern.ch) * @@ -46,7 +46,6 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, z_width = 2.0 * det->params().at( 2 ); // retrieve the timing calibration part for this channel - //const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); const int sector = detid.arm(), station = 0, plane = detid.plane(), channel = detid.channel(); const auto& ch_params = calib_.parameters( sector, station, plane, channel ); const double ch_t_offset = calib_.timeOffset( sector, station, plane, channel ); @@ -64,7 +63,7 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; double tot = -1., t_mean = 0.; - if ( t_lead != 0 && t_trail != 0 ) { + if ( calib_fct_ && t_lead != 0 && t_trail != 0 ) { tot = ( t_trail-t_lead )*ts_to_ns_; t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); if ( std::isnan( t_mean ) ) From cfbd761437f48a1269f1bcac2ef10836cff67f2f Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 12:00:08 +0100 Subject: [PATCH 383/686] Adding timing to diamond tracks --- .../interface/CTPPSDiamondTrackRecognition.h | 1 + .../plugins/CTPPSDiamondLocalTrackFitter.cc | 2 +- .../src/CTPPSDiamondTrackRecognition.cc | 24 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h index 6a6ee2fa27868..2a4f156d46aab 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h @@ -36,6 +36,7 @@ class CTPPSDiamondTrackRecognition : public CTPPSTimingTrackRecognition mhMap_; + double tolerance_; }; #endif diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc index 54c1f1ba9e4dd..f4a68a22c2444 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc @@ -55,7 +55,7 @@ CTPPSDiamondLocalTrackFitter::~CTPPSDiamondLocalTrackFitter() void CTPPSDiamondLocalTrackFitter::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) { - std::unique_ptr > pOut( new edm::DetSetVector ); + auto pOut = std::make_unique >(); edm::Handle > recHits; iEvent.getByToken( recHitsToken_, recHits ); diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index 03246908d7933..b6c813dd25c59 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -13,7 +13,8 @@ //---------------------------------------------------------------------------------------------------- CTPPSDiamondTrackRecognition::CTPPSDiamondTrackRecognition( const edm::ParameterSet& iConfig ) : - CTPPSTimingTrackRecognition( iConfig ) + CTPPSTimingTrackRecognition( iConfig ), + tolerance_( iConfig.getParameter( "tolerance" ) ) {} //---------------------------------------------------------------------------------------------------- @@ -76,6 +77,27 @@ CTPPSDiamondTrackRecognition::produceTracks( edm::DetSet ? mhMap_[oot] : 0; CTPPSDiamondLocalTrack newTrack( position, positionSigma, 0.f, 0.f, oot, multipleHits ); + + // find contributing hits + std::vector componentHits; + for ( const auto& hit : hits ) + if ( newTrack.containsHit( hit, tolerance_ ) ) + componentHits.emplace_back( hit ); + // compute timing information + float meanNumerator = 0.f, meanDenominator = 0.f; + bool validHits = false; + for ( const auto& hit : componentHits ) { + if ( hit.getTPrecision() == 0. ) + continue; + validHits = true; // at least one valid hit to account for + const float weight = 1.f / ( hit.getTPrecision() * hit.getTPrecision() ); + meanNumerator += weight * hit.getT(); + meanDenominator += weight; + } + const float meanTime = validHits ? ( meanNumerator / meanDenominator ) : 0.f; + const float timeSigma = validHits ? ( std::sqrt( 1.f / meanDenominator ) ) : 0.f; + newTrack.setT( meanTime ); + newTrack.setTSigma( timeSigma ); newTrack.setValid( true ); tracks.push_back( newTrack ); From 7ef371561e8b5cf33274d773f62221363753ae2b Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 12:09:37 +0100 Subject: [PATCH 384/686] Simplification through typedefs --- .../TotemRPLocal/interface/CTPPSTimingTrackRecognition.h | 5 +++-- RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc | 7 ++++--- RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index 12a5a6c7e0778..386837c22c15c 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -60,6 +60,7 @@ class CTPPSTimingTrackRecognition const float sigma_; reco::FormulaEvaluator pixelEfficiencyFunction_; + typedef std::vector TrackVector; typedef std::vector HitVector; typedef std::unordered_map HitVectorMap; @@ -92,7 +93,7 @@ class CTPPSTimingTrackRecognition float (*getHitRangeWidth)(const HIT_TYPE&), void (*setTrackCenter)(TRACK_TYPE&, float), void (*setTrackSigma)(TRACK_TYPE&, float), - std::vector& result); + TrackVector& result); /** Retrieve the bounds of a 3D range in which all hits from given collection are contained. * \param[in] hits hits collection to retrieve the range from @@ -112,7 +113,7 @@ void CTPPSTimingTrackRecognition::producePartialTracks( float (*getHitRangeWidth)(const HIT_TYPE&), void (*setTrackCenter)(TRACK_TYPE&, float), void (*setTrackSigma)(TRACK_TYPE&, float), - std::vector& result) { + TrackVector& result) { int numberOfTracks = 0; const float invResolution = 1./resolution_; const float profileRangeMargin = sigma_ * 3.; diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index b6c813dd25c59..fa659884c0018 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -49,14 +49,15 @@ CTPPSDiamondTrackRecognition::produceTracks( edm::DetSet auto setXSigma = []( CTPPSDiamondLocalTrack& track, float sigma ){ track.setPositionSigma( math::XYZPoint( sigma, 0., 0. ) ); }; for ( const auto& hitBatch: hitVectorMap_ ) { + // separate the tracking for each bunch crossing const auto& oot = hitBatch.first; const auto& hits = hitBatch.second; auto hitRange = getHitSpatialRange( hits ); - std::vector xPartTracks; + TrackVector xPartTracks; - // Produces tracks in x dimension + // produce tracks in x dimension param.rangeBegin = hitRange.xBegin; param.rangeEnd = hitRange.xEnd; producePartialTracks( hits, param, getX, getXWidth, setX, setXSigma, xPartTracks ); @@ -79,7 +80,7 @@ CTPPSDiamondTrackRecognition::produceTracks( edm::DetSet CTPPSDiamondLocalTrack newTrack( position, positionSigma, 0.f, 0.f, oot, multipleHits ); // find contributing hits - std::vector componentHits; + HitVector componentHits; for ( const auto& hit : hits ) if ( newTrack.containsHit( hit, tolerance_ ) ) componentHits.emplace_back( hit ); diff --git a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc index 5aefdf8d79643..96e3af34bea6a 100644 --- a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc @@ -47,7 +47,7 @@ TotemTimingTrackRecognition::produceTracks( edm::DetSet& const auto& hits = hitBatch.second; const auto& hitRange = getHitSpatialRange( hits ); - std::vector xPartTracks, yPartTracks; + TrackVector xPartTracks, yPartTracks; param.rangeBegin = hitRange.xBegin; param.rangeEnd = hitRange.xEnd; @@ -69,7 +69,7 @@ TotemTimingTrackRecognition::produceTracks( edm::DetSet& TotemTimingLocalTrack newTrack( position, positionSigma, 0., 0. ); - std::vector componentHits; + HitVector componentHits; for ( const auto& hit : hits ) if ( newTrack.containsHit( hit, tolerance_ ) ) componentHits.emplace_back( hit ); From ac01fdc6af02fabf660037d74758595ebafa4c58 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 13:57:18 +0100 Subject: [PATCH 385/686] Slight cleanup --- .../interface/CTPPSTimingTrackRecognition.h | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index 386837c22c15c..5eb13a0cbba50 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -135,8 +135,7 @@ void CTPPSTimingTrackRecognition::producePartialTracks( bool underThreshold = true; float rangeMaximum = -1.0f; bool trackRangeFound = false; - int trackRangeBegin = 0; - int trackRangeEnd; + int trackRangeBegin = 0, trackRangeEnd = 0; // Searches for tracks in the hit profile for (unsigned int i = 0; i < hitProfile.size(); i++) { @@ -192,30 +191,26 @@ CTPPSTimingTrackRecognition::getHitSpatialRange(const HitV SpatialRange result; for (const auto& hit : hits) { - const float xBegin = hit.getX() - 0.5f*hit.getXWidth(); - const float yBegin = hit.getY() - 0.5f*hit.getYWidth(); - const float zBegin = hit.getZ() - 0.5f*hit.getZWidth(); - const float xEnd = hit.getX() + 0.5f*hit.getXWidth(); - const float yEnd = hit.getY() + 0.5f*hit.getYWidth(); - const float zEnd = hit.getZ() + 0.5f*hit.getZWidth(); + const float xBegin = hit.getX() - 0.5f*hit.getXWidth(), xEnd = hit.getX() + 0.5f*hit.getXWidth(); + const float yBegin = hit.getY() - 0.5f*hit.getYWidth(), yEnd = hit.getY() + 0.5f*hit.getYWidth(); + const float zBegin = hit.getZ() - 0.5f*hit.getZWidth(), zEnd = hit.getZ() + 0.5f*hit.getZWidth(); if (!initialized) { result.xBegin = xBegin; - result.yBegin = yBegin; - result.zBegin = zBegin; result.xEnd = xEnd; + result.yBegin = yBegin; result.yEnd = yEnd; + result.zBegin = zBegin; result.zEnd = zEnd; initialized = true; continue; } - if (xBegin < result.xBegin) result.xBegin = xBegin; - if (yBegin < result.yBegin) result.yBegin = yBegin; - if (zBegin < result.zBegin) result.zBegin = zBegin; - - if (xEnd > result.xEnd) result.xEnd = xEnd; - if (yEnd > result.yEnd) result.yEnd = yEnd; - if (zEnd > result.zEnd) result.zEnd = zEnd; + result.xBegin = std::min(result.xBegin, xBegin); + result.xEnd = std::max(result.xEnd, xEnd); + result.yBegin = std::min(result.yBegin, yBegin); + result.yEnd = std::max(result.yEnd, yEnd); + result.zBegin = std::min(result.zBegin, zBegin); + result.zEnd = std::max(result.zEnd, zEnd); } return result; From 86ecedeed2af9198898ea80ac2046ec55ee67d5c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 22 Mar 2019 14:22:20 +0100 Subject: [PATCH 386/686] Tolerance for tracks<>hits association now a parent algorithm attribute --- .../interface/CTPPSDiamondTrackRecognition.h | 1 - .../interface/CTPPSTimingTrackRecognition.h | 2 ++ .../interface/TotemTimingTrackRecognition.h | 3 --- .../plugins/CTPPSDiamondLocalTrackFitter.cc | 2 ++ .../plugins/TotemTimingLocalTrackFitter.cc | 25 +++++++++++-------- .../src/CTPPSDiamondTrackRecognition.cc | 3 +-- .../src/TotemTimingTrackRecognition.cc | 3 +-- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h index 2a4f156d46aab..6a6ee2fa27868 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h @@ -36,7 +36,6 @@ class CTPPSDiamondTrackRecognition : public CTPPSTimingTrackRecognition mhMap_; - double tolerance_; }; #endif diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index 5eb13a0cbba50..c151e9c20db84 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -35,6 +35,7 @@ class CTPPSTimingTrackRecognition thresholdFromMaximum_ (iConfig.getParameter("thresholdFromMaximum")), resolution_ (iConfig.getParameter("resolution")), sigma_ (iConfig.getParameter("sigma")), + tolerance_ (iConfig.getParameter("tolerance")), pixelEfficiencyFunction_(iConfig.getParameter("pixelEfficiencyFunction")) { if (pixelEfficiencyFunction_.numberOfParameters() != 3) throw cms::Exception("CTPPSTimingTrackRecognition") @@ -58,6 +59,7 @@ class CTPPSTimingTrackRecognition const float thresholdFromMaximum_; const float resolution_; const float sigma_; + const float tolerance_; reco::FormulaEvaluator pixelEfficiencyFunction_; typedef std::vector TrackVector; diff --git a/RecoCTPPS/TotemRPLocal/interface/TotemTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/TotemTimingTrackRecognition.h index cdd1ae36f740a..d775728132079 100644 --- a/RecoCTPPS/TotemRPLocal/interface/TotemTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/TotemTimingTrackRecognition.h @@ -31,9 +31,6 @@ class TotemTimingTrackRecognition : public CTPPSTimingTrackRecognition& tracks ) override; - - private: - float tolerance_; }; #endif diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc index f4a68a22c2444..c5cce5fdcb0c2 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc @@ -116,6 +116,8 @@ CTPPSDiamondLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& ->setComment( "starting horizontal coordinate of rechits for the track recognition" ); trackingAlgoParams.add( "stopAtX", 19.5 /* mm */ ) ->setComment( "ending horizontal coordinate of rechits for the track recognition" ); + trackingAlgoParams.add( "tolerance", 0.1 /* mm */) + ->setComment( "tolerance used for checking if the track contains certain hit" ); trackingAlgoParams.add( "pixelEfficiencyFunction", "(x>[0]-0.5*[1])*(x<[0]+0.5*[1])+0*[2]" ) ->setComment( "efficiency function for single pixel\n" diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc index d7b5259580316..ab11f0ef3d3f2 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc @@ -51,7 +51,7 @@ TotemTimingLocalTrackFitter::TotemTimingLocalTrackFitter( const edm::ParameterSe for ( unsigned short armNo = 0; armNo < 2; armNo++ ) for ( unsigned short rpNo = 0; rpNo < 2; rpNo++ ) { TotemTimingDetId id( armNo, 1, rpNo, 0, 0 ); - TotemTimingTrackRecognition trk_algo( iConfig ); + TotemTimingTrackRecognition trk_algo( iConfig.getParameter( "trackingAlgorithmParams" ) ); trk_algo_map_.insert( std::make_pair( id, trk_algo ) ); } } @@ -59,7 +59,7 @@ TotemTimingLocalTrackFitter::TotemTimingLocalTrackFitter( const edm::ParameterSe void TotemTimingLocalTrackFitter::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) { - std::unique_ptr > pOut( new edm::DetSetVector ); + auto pOut = std::make_unique >(); edm::Handle > recHits; iEvent.getByToken( recHitsToken_, recHits ); @@ -114,20 +114,21 @@ TotemTimingLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& d desc.add( "verbosity", 0 ) ->setComment( "general verbosity of this module" ); - desc.add( "threshold", 1.5 ) + edm::ParameterSetDescription trackingAlgoParams; + trackingAlgoParams.add( "threshold", 1.5 ) ->setComment( "minimal number of rechits to be observed before launching the track recognition algorithm" ); - desc.add( "thresholdFromMaximum", 0.5 ) + trackingAlgoParams.add( "thresholdFromMaximum", 0.5 ) ->setComment( "threshold relative to hit profile function local maximum for determining the width of the track" ); - desc.add( "resolution", 0.01 /* mm */ ) + trackingAlgoParams.add( "resolution", 0.01 /* mm */ ) ->setComment( "spatial resolution on the horizontal coordinate (in mm)" ); - desc.add( "sigma", 0. ) + trackingAlgoParams.add( "sigma", 0. ) ->setComment( "pixel efficiency function parameter determining the smoothness of the step" ); - desc.add( "tolerance", 0.1 /* mm */) + trackingAlgoParams.add( "tolerance", 0.1 /* mm */) ->setComment( "tolerance used for checking if the track contains certain hit" ); - desc.add( "maxPlaneActiveChannels", 2 ) + trackingAlgoParams.add( "maxPlaneActiveChannels", 2 ) ->setComment( "threshold for discriminating noisy planes" ); - desc.add( "pixelEfficiencyFunction", "(x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]" ) + trackingAlgoParams.add( "pixelEfficiencyFunction", "(x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]" ) ->setComment( "efficiency function for single pixel\n" "can be defined as:\n" " * Precise: (TMath::Erf((x-[0]+0.5*([1]-0.05))/([2]/4)+2)+1)*TMath::Erfc((x-[0]-0.5*([1]-0.05))/([2]/4)-2)/4\n" @@ -139,10 +140,12 @@ TotemTimingLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& d " [1]: width of pad\n" " [2]: sigma: distance between efficiency ~100 -> 0 outside width" ); - desc.add( "yPosition", 0.0 ) + trackingAlgoParams.add( "yPosition", 0.0 ) ->setComment( "vertical offset of the outcoming track centre" ); - desc.add( "yWidth", 0.0 ) + trackingAlgoParams.add( "yWidth", 0.0 ) ->setComment( "vertical track width" ); + desc.add( "trackingAlgorithmParams", trackingAlgoParams ) + ->setComment( "list of parameters associated to the track recognition algorithm" ); descr.add( "totemTimingLocalTracks", desc ); } diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index fa659884c0018..27ed7550b9bdf 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -13,8 +13,7 @@ //---------------------------------------------------------------------------------------------------- CTPPSDiamondTrackRecognition::CTPPSDiamondTrackRecognition( const edm::ParameterSet& iConfig ) : - CTPPSTimingTrackRecognition( iConfig ), - tolerance_( iConfig.getParameter( "tolerance" ) ) + CTPPSTimingTrackRecognition( iConfig ) {} //---------------------------------------------------------------------------------------------------- diff --git a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc index 96e3af34bea6a..b32a5ec99a985 100644 --- a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc @@ -13,8 +13,7 @@ //---------------------------------------------------------------------------------------------------- TotemTimingTrackRecognition::TotemTimingTrackRecognition( const edm::ParameterSet& iConfig ) : - CTPPSTimingTrackRecognition( iConfig ), - tolerance_( iConfig.getParameter( "tolerance" ) ) + CTPPSTimingTrackRecognition( iConfig ) {} //---------------------------------------------------------------------------------------------------- From 1c67d40f0d3fd2fad6ad7d9634f0619eaa5f2e28 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 16:33:57 +0100 Subject: [PATCH 387/686] Simplification of tests through common enum definition --- .../CTPPSDiamondRecHitProducerAlgorithm.h | 2 +- .../plugins/CTPPSDiamondLocalTrackFitter.cc | 2 +- .../plugins/CTPPSDiamondRecHitProducer.cc | 2 +- .../PPSTimingCalibrationModeEnum_cff.py | 5 +++ .../TotemRPLocal/test/diamonds_reco_cfg.py | 36 +++++++++++-------- .../TotemRPLocal/test/totemTiming_reco_cfg.py | 13 +++---- 6 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 RecoCTPPS/TotemRPLocal/python/PPSTimingCalibrationModeEnum_cff.py diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h index 9cc0c9cc6e01e..fc0f4e93ae207 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h @@ -1,6 +1,6 @@ /**************************************************************************** * -* This is a part of CTPPS offline software. +* This is a part of PPS offline software. * Authors: * Laurent Forthomme (laurent.forthomme@cern.ch) * diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc index c5cce5fdcb0c2..9865c54f11a62 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc @@ -1,6 +1,6 @@ /**************************************************************************** * - * This is a part of CTPPS offline software. + * This is a part of PPS offline software. * Authors: * Laurent Forthomme (laurent.forthomme@cern.ch) * Nicola Minafra (nicola.minafra@cern.ch) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc index c9397ece79570..bb1e599e4c73d 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondRecHitProducer.cc @@ -1,6 +1,6 @@ /**************************************************************************** * - * This is a part of CTPPS offline software. + * This is a part of PPS offline software. * Authors: * Laurent Forthomme (laurent.forthomme@cern.ch) * Nicola Minafra (nicola.minafra@cern.ch) diff --git a/RecoCTPPS/TotemRPLocal/python/PPSTimingCalibrationModeEnum_cff.py b/RecoCTPPS/TotemRPLocal/python/PPSTimingCalibrationModeEnum_cff.py new file mode 100644 index 0000000000000..53acc0e3390a5 --- /dev/null +++ b/RecoCTPPS/TotemRPLocal/python/PPSTimingCalibrationModeEnum_cff.py @@ -0,0 +1,5 @@ +class PPSTimingCalibrationModeEnum: + CondDB = 0 + JSON = 1 + SQLite = 2 + diff --git a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py index 5eb8779522318..2947dd573ff5f 100644 --- a/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py +++ b/RecoCTPPS/TotemRPLocal/test/diamonds_reco_cfg.py @@ -2,6 +2,9 @@ process = cms.Process('CTPPS') +from RecoCTPPS.TotemRPLocal.PPSTimingCalibrationModeEnum_cff import PPSTimingCalibrationModeEnum +calibrationMode = PPSTimingCalibrationModeEnum.CondDB + # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') @@ -11,6 +14,24 @@ from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '') +if calibrationMode == PPSTimingCalibrationModeEnum.JSON: + process.load('CondFormats.CTPPSReadoutObjects.ppsTimingCalibrationESSource_cfi') + process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoCTPPS/TotemRPLocal/data/timing_offsets_ufsd_2018.dec18.cal.json') +elif calibrationMode == PPSTimingCalibrationModeEnum.SQLite: + # load calibrations from database + process.load('CondCore.CondDB.CondDB_cfi') + process.CondDB.connect = 'sqlite_file:ppsDiamondTiming_calibration.sqlite' # SQLite input + process.PoolDBESSource = cms.ESSource('PoolDBESSource', + process.CondDB, + DumpStats = cms.untracked.bool(True), + toGet = cms.VPSet( + cms.PSet( + record = cms.string('PPSTimingCalibrationRcd'), + tag = cms.string('PPSDiamondTimingCalibration') + ) + ) + ) + # raw data source #process.source = cms.Source("NewEventStreamFileReader", # fileNames = cms.untracked.vstring( @@ -31,21 +52,6 @@ ) process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32( 1000 ) -# load calibrations from database -process.load('CondCore.CondDB.CondDB_cfi') -process.CondDB.connect = 'sqlite_file:ppsDiamondTiming_calibration.sqlite' # SQLite input - -process.PoolDBESSource = cms.ESSource('PoolDBESSource', - process.CondDB, - DumpStats = cms.untracked.bool(True), - toGet = cms.VPSet( - cms.PSet( - record = cms.string('PPSTimingCalibrationRcd'), - tag = cms.string('PPSDiamondTimingCalibration') - ) - ) -) - # raw-to-digi conversion process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") diff --git a/RecoCTPPS/TotemRPLocal/test/totemTiming_reco_cfg.py b/RecoCTPPS/TotemRPLocal/test/totemTiming_reco_cfg.py index 8f6291a5c0847..2bda9f851a438 100644 --- a/RecoCTPPS/TotemRPLocal/test/totemTiming_reco_cfg.py +++ b/RecoCTPPS/TotemRPLocal/test/totemTiming_reco_cfg.py @@ -1,12 +1,9 @@ import FWCore.ParameterSet.Config as cms -class CalibrationMode: - CondDB = 0 - JSON = 1 - SQLite = 2 - process = cms.Process('CTPPS') -calibrationMode = CalibrationMode.CondDB + +from RecoCTPPS.TotemRPLocal.PPSTimingCalibrationModeEnum_cff import PPSTimingCalibrationModeEnum +calibrationMode = PPSTimingCalibrationModeEnum.CondDB # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') @@ -17,10 +14,10 @@ class CalibrationMode: from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') -if calibrationMode == CalibrationMode.JSON: +if calibrationMode == PPSTimingCalibrationModeEnum.JSON: process.load('CondFormats.CTPPSReadoutObjects.ppsTimingCalibrationESSource_cfi') process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoCTPPS/TotemRPLocal/data/timing_offsets_ufsd_2018.dec18.cal.json') -elif calibrationMode == CalibrationMode.SQLite: +elif calibrationMode == PPSTimingCalibrationModeEnum.SQLite: # load calibrations from database process.load('CondCore.CondDB.CondDB_cfi') process.CondDB.connect = 'sqlite_file:totemTiming_calibration.sqlite' # SQLite input From 9edab1776db14cff1bc8dc6d92b582e668262041 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 17:34:12 +0100 Subject: [PATCH 388/686] New helper method to compute time+uncertainty from associated hits collection --- .../interface/CTPPSTimingTrackRecognition.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index c151e9c20db84..e1ee3bc5a286b 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -101,6 +101,8 @@ class CTPPSTimingTrackRecognition * \param[in] hits hits collection to retrieve the range from */ SpatialRange getHitSpatialRange(const HitVector& hits); + /// Evaluate the time + associated uncertainty for a given track + bool timeEval(const HitVector& hits, float& meanTime, float& timeSigma); }; /**************************************************************************** @@ -218,5 +220,24 @@ CTPPSTimingTrackRecognition::getHitSpatialRange(const HitV return result; } +template inline +bool +CTPPSTimingTrackRecognition::timeEval(const HitVector& hits, float& mean_time, float& time_sigma) +{ + float mean_num = 0.f, mean_denom = 0.f; + bool valid_hits = false; + for (const auto& hit : hits) { + if (hit.getTPrecision() <= 0.) + continue; + valid_hits = true; // at least one valid hit to account for + const float weight = 1.f / ( hit.getTPrecision() * hit.getTPrecision() ); + mean_num += weight * hit.getT(); + mean_denom += weight; + } + mean_time = valid_hits ? (mean_num/mean_denom) : 0.f; + time_sigma = valid_hits ? std::sqrt(1.f/mean_denom) : 0.f; + return valid_hits; +} + #endif From 9c3e4817e2f0b7347a31f3acfc92490bf6d2fc11 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Mon, 25 Mar 2019 17:41:33 +0100 Subject: [PATCH 389/686] Common method to avoid stupid copy/paste --- .../interface/CTPPSTimingTrackRecognition.h | 7 ++++- .../src/CTPPSDiamondTrackRecognition.cc | 20 ++++--------- .../src/TotemTimingTrackRecognition.cc | 28 ++++--------------- 3 files changed, 16 insertions(+), 39 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index e1ee3bc5a286b..9aac58ee69406 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -101,7 +101,12 @@ class CTPPSTimingTrackRecognition * \param[in] hits hits collection to retrieve the range from */ SpatialRange getHitSpatialRange(const HitVector& hits); - /// Evaluate the time + associated uncertainty for a given track + /** Evaluate the time + associated uncertainty for a given track + * \note General remarks: + * - track's time = weighted mean of all hit times with time precision as weight, + * - track's time sigma = uncertainty of the weighted mean + * - hit is ignored if the time precision is equal to 0 + */ bool timeEval(const HitVector& hits, float& meanTime, float& timeSigma); }; diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index 27ed7550b9bdf..ad70f96eac0c8 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -84,21 +84,11 @@ CTPPSDiamondTrackRecognition::produceTracks( edm::DetSet if ( newTrack.containsHit( hit, tolerance_ ) ) componentHits.emplace_back( hit ); // compute timing information - float meanNumerator = 0.f, meanDenominator = 0.f; - bool validHits = false; - for ( const auto& hit : componentHits ) { - if ( hit.getTPrecision() == 0. ) - continue; - validHits = true; // at least one valid hit to account for - const float weight = 1.f / ( hit.getTPrecision() * hit.getTPrecision() ); - meanNumerator += weight * hit.getT(); - meanDenominator += weight; - } - const float meanTime = validHits ? ( meanNumerator / meanDenominator ) : 0.f; - const float timeSigma = validHits ? ( std::sqrt( 1.f / meanDenominator ) ) : 0.f; - newTrack.setT( meanTime ); - newTrack.setTSigma( timeSigma ); - newTrack.setValid( true ); + float mean_time = 0.f, time_sigma = 0.f; + bool valid_hits = timeEval( componentHits, mean_time, time_sigma ); + newTrack.setValid( valid_hits ); + newTrack.setT( mean_time ); + newTrack.setTSigma( time_sigma ); tracks.push_back( newTrack ); } diff --git a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc index b32a5ec99a985..a7cc16485a99d 100644 --- a/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/TotemTimingTrackRecognition.cc @@ -72,32 +72,14 @@ TotemTimingTrackRecognition::produceTracks( edm::DetSet& for ( const auto& hit : hits ) if ( newTrack.containsHit( hit, tolerance_ ) ) componentHits.emplace_back( hit ); - if ( componentHits.size() < validHitsNumber ) continue; - // Calculating time - // track's time = weighted mean of all hit times with time precision as weight - // track's time sigma = uncertainty of the weighted mean - // hit is ignored if the time precision is equal to 0 - - float meanNumerator = 0.f, meanDenominator = 0.f; - bool validHits = false; - for ( const auto& hit : componentHits ) { - if ( hit.getTPrecision() == 0. ) - continue; - - validHits = true; // at least one valid hit to account for - const float weight = 1.f / ( hit.getTPrecision() * hit.getTPrecision() ); - meanNumerator += weight * hit.getT(); - meanDenominator += weight; - } - - const float meanTime = validHits ? ( meanNumerator / meanDenominator ) : 0.f; - const float timeSigma = validHits ? ( std::sqrt( 1.f / meanDenominator ) ) : 0.f; - newTrack.setValid( validHits ); - newTrack.setT( meanTime ); - newTrack.setTSigma( timeSigma ); + float mean_time = 0.f, time_sigma = 0.f; + bool valid_hits = timeEval( componentHits, mean_time, time_sigma ); + newTrack.setValid( valid_hits ); + newTrack.setT( mean_time ); + newTrack.setTSigma( time_sigma ); // in a next iteration, we will be setting validity / numHits / numPlanes tracks.push_back( newTrack ); } From d82d5e86e1c1f55d4a721dd6b32da6a4589b152d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 27 Mar 2019 12:47:31 +0100 Subject: [PATCH 390/686] Flag added to exclude single-edged hits --- .../TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h | 1 + .../TotemRPLocal/interface/CTPPSTimingTrackRecognition.h | 6 +++--- .../TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc | 2 ++ RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h index 6a6ee2fa27868..db0470845f417 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondTrackRecognition.h @@ -36,6 +36,7 @@ class CTPPSDiamondTrackRecognition : public CTPPSTimingTrackRecognition mhMap_; + bool excludeSingleEdgeHits_; }; #endif diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index 9aac58ee69406..c5e8cc5f4e803 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -234,10 +234,10 @@ CTPPSTimingTrackRecognition::timeEval(const HitVector& hit for (const auto& hit : hits) { if (hit.getTPrecision() <= 0.) continue; - valid_hits = true; // at least one valid hit to account for - const float weight = 1.f / ( hit.getTPrecision() * hit.getTPrecision() ); - mean_num += weight * hit.getT(); + const float weight = std::pow(hit.getTPrecision(), -2); + mean_num += weight*hit.getT(); mean_denom += weight; + valid_hits = true; // at least one valid hit to account for } mean_time = valid_hits ? (mean_num/mean_denom) : 0.f; time_sigma = valid_hits ? std::sqrt(1.f/mean_denom) : 0.f; diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc index 9865c54f11a62..27efb3192b2b6 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc @@ -135,6 +135,8 @@ CTPPSDiamondLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& ->setComment( "vertical offset of the outcoming track centre" ); trackingAlgoParams.add( "yWidth", 0.0 ) ->setComment( "vertical track width" ); + trackingAlgoParams.add( "excludeSingleEdgeHits", true ) + ->setComment( "exclude rechits with missing leading/trailing edge" ); desc.add( "trackingAlgorithmParams", trackingAlgoParams ) ->setComment( "list of parameters associated to the track recognition algorithm" ); diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index ad70f96eac0c8..afe69233adc69 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -13,7 +13,8 @@ //---------------------------------------------------------------------------------------------------- CTPPSDiamondTrackRecognition::CTPPSDiamondTrackRecognition( const edm::ParameterSet& iConfig ) : - CTPPSTimingTrackRecognition( iConfig ) + CTPPSTimingTrackRecognition( iConfig ), + excludeSingleEdgeHits_( iConfig.getParameter( "excludeSingleEdgeHits" ) ) {} //---------------------------------------------------------------------------------------------------- @@ -81,7 +82,7 @@ CTPPSDiamondTrackRecognition::produceTracks( edm::DetSet // find contributing hits HitVector componentHits; for ( const auto& hit : hits ) - if ( newTrack.containsHit( hit, tolerance_ ) ) + if ( newTrack.containsHit( hit, tolerance_ ) && ( !excludeSingleEdgeHits_ || hit.getToT() > 0. ) ) componentHits.emplace_back( hit ); // compute timing information float mean_time = 0.f, time_sigma = 0.f; From 2cdcbb4d10c19cb4e723fb64012780f78759c756 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 27 Mar 2019 12:51:11 +0100 Subject: [PATCH 391/686] Also exclude single-edged rechits from track building part --- RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc index afe69233adc69..361974f3227b0 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondTrackRecognition.cc @@ -31,6 +31,8 @@ CTPPSDiamondTrackRecognition::clear() void CTPPSDiamondTrackRecognition::addHit( const CTPPSDiamondRecHit& recHit ) { + if ( excludeSingleEdgeHits_ && recHit.getToT() <= 0. ) + return; // store hit parameters hitVectorMap_[recHit.getOOTIndex()].emplace_back( recHit ); } From ad30255799d87033696d3b826bdf8a8e3624d577 Mon Sep 17 00:00:00 2001 From: tocheng Date: Tue, 2 Apr 2019 10:53:26 +0200 Subject: [PATCH 392/686] Fix GEM eMap and PF calibration in 2017 ideal simulation GT --- Configuration/AlCa/python/autoCond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index b9be61d1aff8e..1fda27c3569bb 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -44,7 +44,7 @@ # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v1', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v2', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector 'phase1_2017_realistic' : '106X_mc2017_realistic_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode From 4236f94a1bf2e5b7d406dfbf21c3d896061230ec Mon Sep 17 00:00:00 2001 From: Martin Grunewald Date: Tue, 2 Apr 2019 11:17:57 +0200 Subject: [PATCH 393/686] Migration to 10_6 for Tau changes --- .../Configuration/python/HLT_FULL_cff.py | 1403 +++++++++-------- .../Configuration/python/HLT_Fake1_cff.py | 6 +- .../Configuration/python/HLT_Fake2_cff.py | 6 +- .../Configuration/python/HLT_Fake_cff.py | 6 +- .../Configuration/python/HLT_GRun_cff.py | 1401 ++++++++-------- .../Configuration/python/HLT_HIon_cff.py | 8 +- .../Configuration/python/HLT_PIon_cff.py | 6 +- .../Configuration/python/HLT_PRef_cff.py | 7 +- .../python/HLTrigger_Datasets_GRun_cff.py | 2 +- .../python/HLTrigger_Datasets_HIon_cff.py | 2 +- .../python/HLTrigger_Datasets_PIon_cff.py | 2 +- .../python/HLTrigger_Datasets_PRef_cff.py | 2 +- HLTrigger/Configuration/tables/makeSubTables | 4 +- .../Configuration/test/OnLine_HLT_FULL.py | 1403 +++++++++-------- .../Configuration/test/OnLine_HLT_Fake.py | 6 +- .../Configuration/test/OnLine_HLT_Fake1.py | 6 +- .../Configuration/test/OnLine_HLT_Fake2.py | 6 +- .../Configuration/test/OnLine_HLT_GRun.py | 1401 ++++++++-------- .../Configuration/test/OnLine_HLT_HIon.py | 8 +- .../Configuration/test/OnLine_HLT_PIon.py | 6 +- .../Configuration/test/OnLine_HLT_PRef.py | 7 +- HLTrigger/Configuration/test/getFrozenHLT.sh | 6 +- HLTrigger/Configuration/test/getHLT.sh | 4 +- 23 files changed, 3009 insertions(+), 2699 deletions(-) diff --git a/HLTrigger/Configuration/python/HLT_FULL_cff.py b/HLTrigger/Configuration/python/HLT_FULL_cff.py index d3941ea905fde..30c767fe1a965 100644 --- a/HLTrigger/Configuration/python/HLT_FULL_cff.py +++ b/HLTrigger/Configuration/python/HLT_FULL_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/HLT --type FULL +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/HLT --type FULL -# /dev/CMSSW_10_5_0/HLT/V3 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/HLT/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/HLT/V3') + tableName = cms.string('/dev/CMSSW_10_6_0/HLT/V2') ) fragment.transferSystem = cms.PSet( @@ -11466,6 +11466,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -12813,6 +12814,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -17444,6 +17446,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -20224,6 +20227,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -24467,6 +24471,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -32338,6 +32343,7 @@ src = cms.InputTag( "hltAK4PFJetsForTaus" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowForTaus" ) @@ -32351,6 +32357,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -32413,6 +32420,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -32451,20 +32459,8 @@ ) fragment.hltPFTausSansRef = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadrons" ), @@ -32514,16 +32510,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( True ) + buildNullTaus = cms.bool( True ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) fragment.hltPFTaus = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRef" ) ) fragment.hltPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -32567,7 +32576,9 @@ MinDphi = cms.double( 0.0 ) ) fragment.hltPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32610,25 +32621,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32638,26 +32633,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32700,25 +32713,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32728,23 +32725,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32876,6 +32889,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -32975,24 +32989,8 @@ ) fragment.hltHpsCombinatoricRecoTaus = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutrals" ), @@ -33084,10 +33082,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) fragment.hltHpsSelectionDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -33185,6 +33201,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauProducerSansRefs = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -33216,14 +33235,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ) + ) ) fragment.hltHpsPFTauProducer = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefs" ) ) fragment.hltHpsPFTauDiscriminationByDecayModeFindingNewDMs = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -33321,10 +33340,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltHpsSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -33348,7 +33367,9 @@ MinPt = cms.double( 0.0 ) ) fragment.hltHpsPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.9 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33391,25 +33412,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33419,26 +33424,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33481,25 +33504,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33509,23 +33516,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -33633,7 +33656,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33676,25 +33701,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33704,26 +33713,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33766,25 +33793,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33794,23 +33805,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -33894,7 +33921,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33937,25 +33966,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33965,26 +33978,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34027,25 +34058,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34055,23 +34070,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -34155,7 +34186,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34198,25 +34231,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34226,23 +34243,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationTightOOSCPhotons = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -35468,20 +35501,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltPFTaus" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) fragment.hltSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -35592,20 +35625,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) fragment.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -37857,6 +37890,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -38230,6 +38264,7 @@ src = cms.InputTag( "hltAK4PFJetsReg" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowReg" ) @@ -38243,6 +38278,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -38305,6 +38341,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -38343,20 +38380,8 @@ ) fragment.hltPFTausSansRefReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadronsReg" ), @@ -38406,16 +38431,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) fragment.hltPFTausReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRefReg" ) ) fragment.hltPFTauTrackDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38451,10 +38489,10 @@ MinPt = cms.double( 35.0 ) ) fragment.hltPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) fragment.hltSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38478,7 +38516,9 @@ MinPt = cms.double( 35.0 ) ) fragment.hltPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38521,25 +38561,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38549,26 +38573,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38611,25 +38653,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38639,23 +38665,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -38727,7 +38769,9 @@ offset = cms.uint32( 0 ) ) fragment.hltPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38770,25 +38814,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38798,23 +38826,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -38886,7 +38930,9 @@ offset = cms.uint32( 0 ) ) fragment.hltPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38929,25 +38975,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38957,26 +38987,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39019,25 +39067,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39047,23 +39079,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -39218,6 +39266,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -39317,24 +39366,8 @@ ) fragment.hltHpsCombinatoricRecoTausReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutralsReg" ), @@ -39426,10 +39459,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) fragment.hltHpsSelectionDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -39527,6 +39578,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauProducerSansRefsReg = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -39558,14 +39612,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ) + ) ) fragment.hltHpsPFTauProducerReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefsReg" ) ) fragment.hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -39663,10 +39717,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauTrackFindingDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltHpsSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -39702,10 +39756,10 @@ MinPt = cms.double( 35.0 ) ) fragment.hltHpsPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) fragment.hltHpsSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -39729,7 +39783,9 @@ MinPt = cms.double( 35.0 ) ) fragment.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39772,25 +39828,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39800,26 +39840,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39862,25 +39920,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39890,23 +39932,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -39978,7 +40036,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40021,25 +40081,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40049,70 +40093,22 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - maximumSumPtCut = cms.double( 2.0 ), - qualityCuts = cms.PSet( - vertexTrackFiltering = cms.bool( False ), - isolationQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.5 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 100.0 ), - maxTransverseImpactParameter = cms.double( 0.1 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), - recoverLeadingTrk = cms.bool( False ), - signalQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ), - minNeutralHadronEt = cms.double( 1.0 ) - ), - vxAssocQualityCuts = cms.PSet( - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - pvFindingAlgo = cms.string( "closestInDeltaZ" ) - ), - minTauPtForNoIso = cms.double( -99.0 ), - vertexSrc = cms.InputTag( "NotUsed" ), - applySumPtCut = cms.bool( False ), - rhoConeSize = cms.double( 0.5 ), - ApplyDiscriminationByTrackerIsolation = cms.bool( True ), - rhoUEOffsetCorrection = cms.double( 1.0 ), - rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -40129,52 +40125,12 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) - ), - deltaBetaFactor = cms.string( "0.38" ), - applyFootprintCorrection = cms.bool( False ), - UseAllPFCandsForWeights = cms.bool( False ), - relativeSumPtCut = cms.double( 0.05 ), - Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - applyOccupancyCut = cms.bool( False ), - applyDeltaBetaCorrection = cms.bool( False ), - WeightECALIsolation = cms.double( 1.0 ), - applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), - ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), - maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), - ApplyDiscriminationByECALIsolation = cms.bool( False ), - isoConeSizeForDeltaBeta = cms.double( 0.3 ), - storeRawSumPt = cms.bool( False ), - verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), - relativeSumPtOffset = cms.double( 60.0 ), - customOuterCone = cms.double( -1.0 ), - particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", - PassValue = cms.double( 1.0 ), - Prediscriminants = cms.PSet( - BooleanOperator = cms.string( "or" ), - discr1 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) - ), - discr2 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) - ) - ), - FailValue = cms.double( 0.0 ), - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) + ) ) -fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", +fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40217,8 +40173,34 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), + deltaBetaFactor = cms.string( "0.38" ), + applyFootprintCorrection = cms.bool( False ), + UseAllPFCandsForWeights = cms.bool( False ), + relativeSumPtCut = cms.double( 0.05 ), + Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), + applyOccupancyCut = cms.bool( False ), + applyDeltaBetaCorrection = cms.bool( False ), + WeightECALIsolation = cms.double( 1.0 ), + applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maximumOccupancy = cms.uint32( 0 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), + ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), + maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), + ApplyDiscriminationByECALIsolation = cms.bool( False ), + isoConeSizeForDeltaBeta = cms.double( 0.3 ), + storeRawSumPt = cms.bool( False ), + verbosity = cms.int32( 0 ), + storeRawFootprintCorrection = cms.bool( False ), + relativeSumPtOffset = cms.double( 60.0 ), + customOuterCone = cms.double( -1.0 ), + particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -40235,7 +40217,73 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) + ) +) +fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", + PassValue = cms.double( 1.0 ), + Prediscriminants = cms.PSet( + BooleanOperator = cms.string( "or" ), + discr1 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) + ), + discr2 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) + ) ), + FailValue = cms.double( 0.0 ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) +) +fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), + maximumSumPtCut = cms.double( 2.0 ), + qualityCuts = cms.PSet( + vertexTrackFiltering = cms.bool( False ), + isolationQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.5 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 100.0 ), + maxTransverseImpactParameter = cms.double( 0.1 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), + recoverLeadingTrk = cms.bool( False ), + signalQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ), + minNeutralHadronEt = cms.double( 1.0 ) + ), + vxAssocQualityCuts = cms.PSet( + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + pvFindingAlgo = cms.string( "closestInDeltaZ" ) + ), + minTauPtForNoIso = cms.double( -99.0 ), + vertexSrc = cms.InputTag( "NotUsed" ), + applySumPtCut = cms.bool( False ), + rhoConeSize = cms.double( 0.5 ), + ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), + rhoUEOffsetCorrection = cms.double( 1.0 ), + rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40245,23 +40293,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -47320,6 +47384,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -54947,13 +55012,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtag" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtag" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -61989,7 +62054,9 @@ MinDphi = cms.double( 0.0 ) ) fragment.hltPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -62032,25 +62099,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -62060,26 +62111,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -62122,25 +62191,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -62150,23 +62203,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -74440,6 +74509,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -74801,6 +74871,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -91062,10 +91133,10 @@ MinPt = cms.double( 50.0 ) ) fragment.hltPFTauTrackPt30Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 30.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 30.0 ) ) fragment.hltPFTau1Prong = cms.EDProducer( "PFRecoTauDiscriminationByNProngs", MinN = cms.uint32( 1 ), @@ -91351,7 +91422,9 @@ MinPt = cms.double( 180.0 ) ) fragment.hltPFTauMediumHighPtRelaxedIsoAbsoluteIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -91393,25 +91466,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -91421,26 +91478,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumHighPtRelaxedIsoRelativeIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -91482,25 +91557,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -91510,23 +91569,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 200.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumHighPtRelaxedIsoAbsOrRelIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -91545,10 +91620,10 @@ PFTauProducer = cms.InputTag( "hltPFTaus" ) ) fragment.hltPFTauTrackPt50Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 50.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 50.0 ) ) fragment.hltSelectedPFTausTrackPt50AbsOrRelMediumHighPtRelaxedIsoIsolation = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -95895,13 +95970,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -96118,13 +96193,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForDBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForDBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -101043,6 +101118,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -102625,6 +102701,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/python/HLT_Fake1_cff.py b/HLTrigger/Configuration/python/HLT_Fake1_cff.py index aeac52c1db856..79e71fc756cbc 100644 --- a/HLTrigger/Configuration/python/HLT_Fake1_cff.py +++ b/HLTrigger/Configuration/python/HLT_Fake1_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/Fake1 --type Fake1 +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/Fake1 --type Fake1 -# /dev/CMSSW_10_5_0/Fake1/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake1/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake1/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake1/V2') ) fragment.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/python/HLT_Fake2_cff.py b/HLTrigger/Configuration/python/HLT_Fake2_cff.py index b757d8db33a62..54e2643ca92d5 100644 --- a/HLTrigger/Configuration/python/HLT_Fake2_cff.py +++ b/HLTrigger/Configuration/python/HLT_Fake2_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/Fake2 --type Fake2 +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/Fake2 --type Fake2 -# /dev/CMSSW_10_5_0/Fake2/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake2/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake2/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake2/V2') ) fragment.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/python/HLT_Fake_cff.py b/HLTrigger/Configuration/python/HLT_Fake_cff.py index cd91e3a5b47b4..c59e61f97450d 100644 --- a/HLTrigger/Configuration/python/HLT_Fake_cff.py +++ b/HLTrigger/Configuration/python/HLT_Fake_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/Fake --type Fake +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/Fake --type Fake -# /dev/CMSSW_10_5_0/Fake/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake/V2') ) fragment.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/python/HLT_GRun_cff.py b/HLTrigger/Configuration/python/HLT_GRun_cff.py index b7033942db8bc..5289ae773ec38 100644 --- a/HLTrigger/Configuration/python/HLT_GRun_cff.py +++ b/HLTrigger/Configuration/python/HLT_GRun_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/GRun --type GRun +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/GRun --type GRun -# /dev/CMSSW_10_5_0/GRun/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/GRun/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/GRun/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/GRun/V1') ) fragment.transferSystem = cms.PSet( @@ -10146,6 +10146,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -11493,6 +11494,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -16076,6 +16078,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -18856,6 +18859,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -23099,6 +23103,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -30970,6 +30975,7 @@ src = cms.InputTag( "hltAK4PFJetsForTaus" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowForTaus" ) @@ -30983,6 +30989,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -31045,6 +31052,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -31083,20 +31091,8 @@ ) fragment.hltPFTausSansRef = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadrons" ), @@ -31146,16 +31142,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( True ) + buildNullTaus = cms.bool( True ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) fragment.hltPFTaus = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRef" ) ) fragment.hltPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -31199,7 +31208,9 @@ MinDphi = cms.double( 0.0 ) ) fragment.hltPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -31242,25 +31253,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -31270,26 +31265,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -31332,25 +31345,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -31360,23 +31357,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -31508,6 +31521,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -31607,24 +31621,8 @@ ) fragment.hltHpsCombinatoricRecoTaus = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutrals" ), @@ -31716,10 +31714,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) fragment.hltHpsSelectionDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -31817,6 +31833,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauProducerSansRefs = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -31848,14 +31867,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ) + ) ) fragment.hltHpsPFTauProducer = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefs" ) ) fragment.hltHpsPFTauDiscriminationByDecayModeFindingNewDMs = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -31953,10 +31972,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltHpsSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -31980,7 +31999,9 @@ MinPt = cms.double( 0.0 ) ) fragment.hltHpsPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.9 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32023,25 +32044,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32051,26 +32056,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32113,25 +32136,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32141,23 +32148,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32265,7 +32288,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32308,25 +32333,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32336,26 +32345,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32398,25 +32425,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32426,23 +32437,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32526,7 +32553,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32569,25 +32598,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32597,26 +32610,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32659,25 +32690,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32687,23 +32702,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32787,7 +32818,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32830,25 +32863,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32858,23 +32875,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationTightOOSCPhotons = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -34076,20 +34109,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltPFTaus" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) fragment.hltSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -34200,20 +34233,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) fragment.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -36465,6 +36498,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -36838,6 +36872,7 @@ src = cms.InputTag( "hltAK4PFJetsReg" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowReg" ) @@ -36851,6 +36886,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -36913,6 +36949,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -36951,20 +36988,8 @@ ) fragment.hltPFTausSansRefReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadronsReg" ), @@ -37014,16 +37039,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) fragment.hltPFTausReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRefReg" ) ) fragment.hltPFTauTrackDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -37059,10 +37097,10 @@ MinPt = cms.double( 35.0 ) ) fragment.hltPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) fragment.hltSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -37086,7 +37124,9 @@ MinPt = cms.double( 35.0 ) ) fragment.hltPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37129,25 +37169,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37157,26 +37181,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37219,25 +37261,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37247,23 +37273,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -37335,7 +37377,9 @@ offset = cms.uint32( 0 ) ) fragment.hltPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37378,25 +37422,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37406,23 +37434,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -37494,7 +37538,9 @@ offset = cms.uint32( 0 ) ) fragment.hltPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37537,25 +37583,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37565,26 +37595,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37627,25 +37675,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37655,23 +37687,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -37826,6 +37874,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -37925,24 +37974,8 @@ ) fragment.hltHpsCombinatoricRecoTausReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutralsReg" ), @@ -38034,10 +38067,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) fragment.hltHpsSelectionDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -38135,6 +38186,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauProducerSansRefsReg = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -38166,14 +38220,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ) + ) ) fragment.hltHpsPFTauProducerReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefsReg" ) ) fragment.hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -38271,10 +38325,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) fragment.hltHpsPFTauTrackFindingDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) fragment.hltHpsSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38310,10 +38364,10 @@ MinPt = cms.double( 35.0 ) ) fragment.hltHpsPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) fragment.hltHpsSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38337,7 +38391,9 @@ MinPt = cms.double( 35.0 ) ) fragment.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38380,25 +38436,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38408,26 +38448,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38470,25 +38528,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38498,23 +38540,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -38586,7 +38644,9 @@ offset = cms.uint32( 0 ) ) fragment.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38629,25 +38689,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38657,70 +38701,22 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - maximumSumPtCut = cms.double( 2.0 ), - qualityCuts = cms.PSet( - vertexTrackFiltering = cms.bool( False ), - isolationQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.5 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 100.0 ), - maxTransverseImpactParameter = cms.double( 0.1 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), - recoverLeadingTrk = cms.bool( False ), - signalQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ), - minNeutralHadronEt = cms.double( 1.0 ) - ), - vxAssocQualityCuts = cms.PSet( - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - pvFindingAlgo = cms.string( "closestInDeltaZ" ) - ), - minTauPtForNoIso = cms.double( -99.0 ), - vertexSrc = cms.InputTag( "NotUsed" ), - applySumPtCut = cms.bool( False ), - rhoConeSize = cms.double( 0.5 ), - ApplyDiscriminationByTrackerIsolation = cms.bool( True ), - rhoUEOffsetCorrection = cms.double( 1.0 ), - rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -38737,52 +38733,12 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) - ), - deltaBetaFactor = cms.string( "0.38" ), - applyFootprintCorrection = cms.bool( False ), - UseAllPFCandsForWeights = cms.bool( False ), - relativeSumPtCut = cms.double( 0.05 ), - Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - applyOccupancyCut = cms.bool( False ), - applyDeltaBetaCorrection = cms.bool( False ), - WeightECALIsolation = cms.double( 1.0 ), - applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), - ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), - maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), - ApplyDiscriminationByECALIsolation = cms.bool( False ), - isoConeSizeForDeltaBeta = cms.double( 0.3 ), - storeRawSumPt = cms.bool( False ), - verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), - relativeSumPtOffset = cms.double( 60.0 ), - customOuterCone = cms.double( -1.0 ), - particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", - PassValue = cms.double( 1.0 ), - Prediscriminants = cms.PSet( - BooleanOperator = cms.string( "or" ), - discr1 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) - ), - discr2 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) - ) - ), - FailValue = cms.double( 0.0 ), - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) + ) ) -fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", +fragment.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38825,8 +38781,34 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), + deltaBetaFactor = cms.string( "0.38" ), + applyFootprintCorrection = cms.bool( False ), + UseAllPFCandsForWeights = cms.bool( False ), + relativeSumPtCut = cms.double( 0.05 ), + Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), + applyOccupancyCut = cms.bool( False ), + applyDeltaBetaCorrection = cms.bool( False ), + WeightECALIsolation = cms.double( 1.0 ), + applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maximumOccupancy = cms.uint32( 0 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), + ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), + maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), + ApplyDiscriminationByECALIsolation = cms.bool( False ), + isoConeSizeForDeltaBeta = cms.double( 0.3 ), + storeRawSumPt = cms.bool( False ), + verbosity = cms.int32( 0 ), + storeRawFootprintCorrection = cms.bool( False ), + relativeSumPtOffset = cms.double( 60.0 ), + customOuterCone = cms.double( -1.0 ), + particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -38843,7 +38825,73 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) + ) +) +fragment.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", + PassValue = cms.double( 1.0 ), + Prediscriminants = cms.PSet( + BooleanOperator = cms.string( "or" ), + discr1 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) + ), + discr2 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) + ) ), + FailValue = cms.double( 0.0 ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) +) +fragment.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), + maximumSumPtCut = cms.double( 2.0 ), + qualityCuts = cms.PSet( + vertexTrackFiltering = cms.bool( False ), + isolationQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.5 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 100.0 ), + maxTransverseImpactParameter = cms.double( 0.1 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), + recoverLeadingTrk = cms.bool( False ), + signalQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ), + minNeutralHadronEt = cms.double( 1.0 ) + ), + vxAssocQualityCuts = cms.PSet( + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + pvFindingAlgo = cms.string( "closestInDeltaZ" ) + ), + minTauPtForNoIso = cms.double( -99.0 ), + vertexSrc = cms.InputTag( "NotUsed" ), + applySumPtCut = cms.bool( False ), + rhoConeSize = cms.double( 0.5 ), + ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), + rhoUEOffsetCorrection = cms.double( 1.0 ), + rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38853,23 +38901,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltHpsPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -45508,6 +45572,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -53146,13 +53211,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtag" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtag" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -59778,7 +59843,9 @@ MinDphi = cms.double( 0.0 ) ) fragment.hltPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -59821,25 +59888,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -59849,26 +59900,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -59911,25 +59980,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -59939,23 +59992,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -72175,6 +72244,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -72536,6 +72606,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -81588,10 +81659,10 @@ MinPt = cms.double( 50.0 ) ) fragment.hltPFTauTrackPt30Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 30.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 30.0 ) ) fragment.hltPFTau1Prong = cms.EDProducer( "PFRecoTauDiscriminationByNProngs", MinN = cms.uint32( 1 ), @@ -81877,7 +81948,9 @@ MinPt = cms.double( 180.0 ) ) fragment.hltPFTauMediumHighPtRelaxedIsoAbsoluteIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -81919,25 +81992,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -81947,26 +82004,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumHighPtRelaxedIsoRelativeIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -82008,25 +82083,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -82036,23 +82095,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 200.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) fragment.hltPFTauMediumHighPtRelaxedIsoAbsOrRelIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -82071,10 +82146,10 @@ PFTauProducer = cms.InputTag( "hltPFTaus" ) ) fragment.hltPFTauTrackPt50Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 50.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 50.0 ) ) fragment.hltSelectedPFTausTrackPt50AbsOrRelMediumHighPtRelaxedIsoIsolation = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -86406,13 +86481,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -86629,13 +86704,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForDBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForDBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), diff --git a/HLTrigger/Configuration/python/HLT_HIon_cff.py b/HLTrigger/Configuration/python/HLT_HIon_cff.py index a0a58ed0b246e..e217068eb994f 100644 --- a/HLTrigger/Configuration/python/HLT_HIon_cff.py +++ b/HLTrigger/Configuration/python/HLT_HIon_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/HIon --type HIon +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/HIon --type HIon -# /dev/CMSSW_10_5_0/HIon/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/HIon/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/HIon/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/HIon/V1') ) fragment.transferSystem = cms.PSet( @@ -9838,6 +9838,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -11431,6 +11432,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/python/HLT_PIon_cff.py b/HLTrigger/Configuration/python/HLT_PIon_cff.py index bdb66df615cb1..a2f18c65b9376 100644 --- a/HLTrigger/Configuration/python/HLT_PIon_cff.py +++ b/HLTrigger/Configuration/python/HLT_PIon_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/PIon --type PIon +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/PIon --type PIon -# /dev/CMSSW_10_5_0/PIon/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/PIon/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/PIon/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/PIon/V1') ) fragment.transferSystem = cms.PSet( diff --git a/HLTrigger/Configuration/python/HLT_PRef_cff.py b/HLTrigger/Configuration/python/HLT_PRef_cff.py index c2858e3f4a394..68a5cc6949cc1 100644 --- a/HLTrigger/Configuration/python/HLT_PRef_cff.py +++ b/HLTrigger/Configuration/python/HLT_PRef_cff.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --cff --data /dev/CMSSW_10_5_0/PRef --type PRef +# hltGetConfiguration --cff --data /dev/CMSSW_10_6_0/PRef --type PRef -# /dev/CMSSW_10_5_0/PRef/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/PRef/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms fragment = cms.ProcessFragment( "HLT" ) fragment.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/PRef/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/PRef/V1') ) fragment.transferSystem = cms.PSet( @@ -8582,6 +8582,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/python/HLTrigger_Datasets_GRun_cff.py b/HLTrigger/Configuration/python/HLTrigger_Datasets_GRun_cff.py index c90f55f09722d..4b9fd49e4826a 100644 --- a/HLTrigger/Configuration/python/HLTrigger_Datasets_GRun_cff.py +++ b/HLTrigger/Configuration/python/HLTrigger_Datasets_GRun_cff.py @@ -1,4 +1,4 @@ -# /dev/CMSSW_10_5_0/GRun +# /dev/CMSSW_10_6_0/GRun import FWCore.ParameterSet.Config as cms diff --git a/HLTrigger/Configuration/python/HLTrigger_Datasets_HIon_cff.py b/HLTrigger/Configuration/python/HLTrigger_Datasets_HIon_cff.py index 21fbe2bc4a5b3..865114e8448b5 100644 --- a/HLTrigger/Configuration/python/HLTrigger_Datasets_HIon_cff.py +++ b/HLTrigger/Configuration/python/HLTrigger_Datasets_HIon_cff.py @@ -1,4 +1,4 @@ -# /dev/CMSSW_10_5_0/HIon +# /dev/CMSSW_10_6_0/HIon import FWCore.ParameterSet.Config as cms diff --git a/HLTrigger/Configuration/python/HLTrigger_Datasets_PIon_cff.py b/HLTrigger/Configuration/python/HLTrigger_Datasets_PIon_cff.py index 03c676ca2a72f..c9fb33e378176 100644 --- a/HLTrigger/Configuration/python/HLTrigger_Datasets_PIon_cff.py +++ b/HLTrigger/Configuration/python/HLTrigger_Datasets_PIon_cff.py @@ -1,4 +1,4 @@ -# /dev/CMSSW_10_5_0/PIon +# /dev/CMSSW_10_6_0/PIon import FWCore.ParameterSet.Config as cms diff --git a/HLTrigger/Configuration/python/HLTrigger_Datasets_PRef_cff.py b/HLTrigger/Configuration/python/HLTrigger_Datasets_PRef_cff.py index 77f632bf3c34c..c874ac66e9c7b 100644 --- a/HLTrigger/Configuration/python/HLTrigger_Datasets_PRef_cff.py +++ b/HLTrigger/Configuration/python/HLTrigger_Datasets_PRef_cff.py @@ -1,4 +1,4 @@ -# /dev/CMSSW_10_5_0/PRef +# /dev/CMSSW_10_6_0/PRef import FWCore.ParameterSet.Config as cms diff --git a/HLTrigger/Configuration/tables/makeSubTables b/HLTrigger/Configuration/tables/makeSubTables index 1cf5ff6b0e233..bcc7db252e9a8 100755 --- a/HLTrigger/Configuration/tables/makeSubTables +++ b/HLTrigger/Configuration/tables/makeSubTables @@ -3,8 +3,8 @@ # generate HLT tables from master table in ConfDB # -MASTER="/dev/CMSSW_10_5_0/HLT" # no version, take the latest one -TARGET="/dev/CMSSW_10_5_0/TABLE" # directory where to store the sub-tables +MASTER="/dev/CMSSW_10_6_0/HLT" # no version, take the latest one +TARGET="/dev/CMSSW_10_6_0/TABLE" # directory where to store the sub-tables TABLES="GRun HIon PIon PRef" # which sub-tables to create source subtables.sh diff --git a/HLTrigger/Configuration/test/OnLine_HLT_FULL.py b/HLTrigger/Configuration/test/OnLine_HLT_FULL.py index 98e88b62a83e7..199310ba6f300 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_FULL.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_FULL.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/HLT --type FULL --unprescale --process HLTFULL --globaltag auto:run2_hlt_FULL --input file:RelVal_Raw_FULL_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/HLT --type FULL --unprescale --process HLTFULL --globaltag auto:run2_hlt_FULL --input file:RelVal_Raw_FULL_DATA.root -# /dev/CMSSW_10_5_0/HLT/V3 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/HLT/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTFULL" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/HLT/V3') + tableName = cms.string('/dev/CMSSW_10_6_0/HLT/V2') ) process.transferSystem = cms.PSet( @@ -11766,6 +11766,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -13113,6 +13114,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -17744,6 +17746,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -20524,6 +20527,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -24767,6 +24771,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -32638,6 +32643,7 @@ src = cms.InputTag( "hltAK4PFJetsForTaus" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowForTaus" ) @@ -32651,6 +32657,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -32713,6 +32720,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -32751,20 +32759,8 @@ ) process.hltPFTausSansRef = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadrons" ), @@ -32814,16 +32810,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( True ) + buildNullTaus = cms.bool( True ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) process.hltPFTaus = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRef" ) ) process.hltPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -32867,7 +32876,9 @@ MinDphi = cms.double( 0.0 ) ) process.hltPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32910,25 +32921,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32938,26 +32933,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33000,25 +33013,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33028,23 +33025,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -33176,6 +33189,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -33275,24 +33289,8 @@ ) process.hltHpsCombinatoricRecoTaus = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutrals" ), @@ -33384,10 +33382,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) process.hltHpsSelectionDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -33485,6 +33501,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauProducerSansRefs = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -33516,14 +33535,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ) + ) ) process.hltHpsPFTauProducer = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefs" ) ) process.hltHpsPFTauDiscriminationByDecayModeFindingNewDMs = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -33621,10 +33640,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltHpsSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -33648,7 +33667,9 @@ MinPt = cms.double( 0.0 ) ) process.hltHpsPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.9 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33691,25 +33712,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33719,26 +33724,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33781,25 +33804,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33809,23 +33816,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -33933,7 +33956,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33976,25 +34001,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34004,26 +34013,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34066,25 +34093,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34094,23 +34105,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -34194,7 +34221,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34237,25 +34266,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34265,26 +34278,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34327,25 +34358,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34355,23 +34370,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -34455,7 +34486,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -34498,25 +34531,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -34526,23 +34543,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationTightOOSCPhotons = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -35768,20 +35801,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltPFTaus" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) process.hltSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -35892,20 +35925,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) process.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -38157,6 +38190,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -38530,6 +38564,7 @@ src = cms.InputTag( "hltAK4PFJetsReg" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowReg" ) @@ -38543,6 +38578,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -38605,6 +38641,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -38643,20 +38680,8 @@ ) process.hltPFTausSansRefReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadronsReg" ), @@ -38706,16 +38731,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) process.hltPFTausReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRefReg" ) ) process.hltPFTauTrackDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38751,10 +38789,10 @@ MinPt = cms.double( 35.0 ) ) process.hltPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) process.hltSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38778,7 +38816,9 @@ MinPt = cms.double( 35.0 ) ) process.hltPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38821,25 +38861,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38849,26 +38873,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38911,25 +38953,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38939,23 +38965,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -39027,7 +39069,9 @@ offset = cms.uint32( 0 ) ) process.hltPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39070,25 +39114,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39098,23 +39126,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -39186,7 +39230,9 @@ offset = cms.uint32( 0 ) ) process.hltPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39229,25 +39275,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39257,26 +39287,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39319,25 +39367,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39347,23 +39379,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -39518,6 +39566,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -39617,24 +39666,8 @@ ) process.hltHpsCombinatoricRecoTausReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutralsReg" ), @@ -39726,10 +39759,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) process.hltHpsSelectionDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -39827,6 +39878,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauProducerSansRefsReg = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -39858,14 +39912,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ) + ) ) process.hltHpsPFTauProducerReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefsReg" ) ) process.hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -39963,10 +40017,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauTrackFindingDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltHpsSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -40002,10 +40056,10 @@ MinPt = cms.double( 35.0 ) ) process.hltHpsPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) process.hltHpsSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -40029,7 +40083,9 @@ MinPt = cms.double( 35.0 ) ) process.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40072,25 +40128,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40100,26 +40140,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40162,25 +40220,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40190,23 +40232,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -40278,7 +40336,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40321,25 +40381,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40349,70 +40393,22 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - maximumSumPtCut = cms.double( 2.0 ), - qualityCuts = cms.PSet( - vertexTrackFiltering = cms.bool( False ), - isolationQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.5 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 100.0 ), - maxTransverseImpactParameter = cms.double( 0.1 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), - recoverLeadingTrk = cms.bool( False ), - signalQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ), - minNeutralHadronEt = cms.double( 1.0 ) - ), - vxAssocQualityCuts = cms.PSet( - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - pvFindingAlgo = cms.string( "closestInDeltaZ" ) - ), - minTauPtForNoIso = cms.double( -99.0 ), - vertexSrc = cms.InputTag( "NotUsed" ), - applySumPtCut = cms.bool( False ), - rhoConeSize = cms.double( 0.5 ), - ApplyDiscriminationByTrackerIsolation = cms.bool( True ), - rhoUEOffsetCorrection = cms.double( 1.0 ), - rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -40429,52 +40425,12 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) - ), - deltaBetaFactor = cms.string( "0.38" ), - applyFootprintCorrection = cms.bool( False ), - UseAllPFCandsForWeights = cms.bool( False ), - relativeSumPtCut = cms.double( 0.05 ), - Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - applyOccupancyCut = cms.bool( False ), - applyDeltaBetaCorrection = cms.bool( False ), - WeightECALIsolation = cms.double( 1.0 ), - applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), - ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), - maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), - ApplyDiscriminationByECALIsolation = cms.bool( False ), - isoConeSizeForDeltaBeta = cms.double( 0.3 ), - storeRawSumPt = cms.bool( False ), - verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), - relativeSumPtOffset = cms.double( 60.0 ), - customOuterCone = cms.double( -1.0 ), - particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", - PassValue = cms.double( 1.0 ), - Prediscriminants = cms.PSet( - BooleanOperator = cms.string( "or" ), - discr1 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) - ), - discr2 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) - ) - ), - FailValue = cms.double( 0.0 ), - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) + ) ) -process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", +process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -40517,8 +40473,34 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), + deltaBetaFactor = cms.string( "0.38" ), + applyFootprintCorrection = cms.bool( False ), + UseAllPFCandsForWeights = cms.bool( False ), + relativeSumPtCut = cms.double( 0.05 ), + Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), + applyOccupancyCut = cms.bool( False ), + applyDeltaBetaCorrection = cms.bool( False ), + WeightECALIsolation = cms.double( 1.0 ), + applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maximumOccupancy = cms.uint32( 0 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), + ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), + maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), + ApplyDiscriminationByECALIsolation = cms.bool( False ), + isoConeSizeForDeltaBeta = cms.double( 0.3 ), + storeRawSumPt = cms.bool( False ), + verbosity = cms.int32( 0 ), + storeRawFootprintCorrection = cms.bool( False ), + relativeSumPtOffset = cms.double( 60.0 ), + customOuterCone = cms.double( -1.0 ), + particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -40535,7 +40517,73 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) + ) +) +process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", + PassValue = cms.double( 1.0 ), + Prediscriminants = cms.PSet( + BooleanOperator = cms.string( "or" ), + discr1 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) + ), + discr2 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) + ) ), + FailValue = cms.double( 0.0 ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) +) +process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), + maximumSumPtCut = cms.double( 2.0 ), + qualityCuts = cms.PSet( + vertexTrackFiltering = cms.bool( False ), + isolationQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.5 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 100.0 ), + maxTransverseImpactParameter = cms.double( 0.1 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), + recoverLeadingTrk = cms.bool( False ), + signalQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ), + minNeutralHadronEt = cms.double( 1.0 ) + ), + vxAssocQualityCuts = cms.PSet( + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + pvFindingAlgo = cms.string( "closestInDeltaZ" ) + ), + minTauPtForNoIso = cms.double( -99.0 ), + vertexSrc = cms.InputTag( "NotUsed" ), + applySumPtCut = cms.bool( False ), + rhoConeSize = cms.double( 0.5 ), + ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), + rhoUEOffsetCorrection = cms.double( 1.0 ), + rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -40545,23 +40593,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -47620,6 +47684,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -55247,13 +55312,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtag" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtag" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -62289,7 +62354,9 @@ MinDphi = cms.double( 0.0 ) ) process.hltPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -62332,25 +62399,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -62360,26 +62411,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -62422,25 +62491,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -62450,23 +62503,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -74740,6 +74809,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -75101,6 +75171,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -91362,10 +91433,10 @@ MinPt = cms.double( 50.0 ) ) process.hltPFTauTrackPt30Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 30.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 30.0 ) ) process.hltPFTau1Prong = cms.EDProducer( "PFRecoTauDiscriminationByNProngs", MinN = cms.uint32( 1 ), @@ -91651,7 +91722,9 @@ MinPt = cms.double( 180.0 ) ) process.hltPFTauMediumHighPtRelaxedIsoAbsoluteIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -91693,25 +91766,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -91721,26 +91778,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumHighPtRelaxedIsoRelativeIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -91782,25 +91857,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -91810,23 +91869,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 200.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumHighPtRelaxedIsoAbsOrRelIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -91845,10 +91920,10 @@ PFTauProducer = cms.InputTag( "hltPFTaus" ) ) process.hltPFTauTrackPt50Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 50.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 50.0 ) ) process.hltSelectedPFTausTrackPt50AbsOrRelMediumHighPtRelaxedIsoIsolation = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -96195,13 +96270,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -96418,13 +96493,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForDBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForDBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -101343,6 +101418,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -102925,6 +103001,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/test/OnLine_HLT_Fake.py b/HLTrigger/Configuration/test/OnLine_HLT_Fake.py index 0a296ebd7ab48..99e9c98ad77c2 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_Fake.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_Fake.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/Fake --type Fake --unprescale --process HLTFake --globaltag auto:run1_hlt_Fake --input file:RelVal_Raw_Fake_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/Fake --type Fake --unprescale --process HLTFake --globaltag auto:run1_hlt_Fake --input file:RelVal_Raw_Fake_DATA.root -# /dev/CMSSW_10_5_0/Fake/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTFake" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake/V2') ) process.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/test/OnLine_HLT_Fake1.py b/HLTrigger/Configuration/test/OnLine_HLT_Fake1.py index 48fa3d41a0281..8be9c723f7af6 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_Fake1.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_Fake1.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/Fake1 --type Fake1 --unprescale --process HLTFake1 --globaltag auto:run2_hlt_Fake1 --input file:RelVal_Raw_Fake1_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/Fake1 --type Fake1 --unprescale --process HLTFake1 --globaltag auto:run2_hlt_Fake1 --input file:RelVal_Raw_Fake1_DATA.root -# /dev/CMSSW_10_5_0/Fake1/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake1/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTFake1" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake1/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake1/V2') ) process.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/test/OnLine_HLT_Fake2.py b/HLTrigger/Configuration/test/OnLine_HLT_Fake2.py index 994a259db46e6..2530fa78c030a 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_Fake2.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_Fake2.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/Fake2 --type Fake2 --unprescale --process HLTFake2 --globaltag auto:run2_hlt_Fake2 --input file:RelVal_Raw_Fake2_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/Fake2 --type Fake2 --unprescale --process HLTFake2 --globaltag auto:run2_hlt_Fake2 --input file:RelVal_Raw_Fake2_DATA.root -# /dev/CMSSW_10_5_0/Fake2/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/Fake2/V2 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTFake2" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/Fake2/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/Fake2/V2') ) process.streams = cms.PSet( A = cms.vstring( 'InitialPD' ) ) diff --git a/HLTrigger/Configuration/test/OnLine_HLT_GRun.py b/HLTrigger/Configuration/test/OnLine_HLT_GRun.py index 8ee1dcdfdb4ca..42514c93df016 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_GRun.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_GRun.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/GRun --type GRun --unprescale --process HLTGRun --globaltag auto:run2_hlt_GRun --input file:RelVal_Raw_GRun_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/GRun --type GRun --unprescale --process HLTGRun --globaltag auto:run2_hlt_GRun --input file:RelVal_Raw_GRun_DATA.root -# /dev/CMSSW_10_5_0/GRun/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/GRun/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTGRun" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/GRun/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/GRun/V1') ) process.transferSystem = cms.PSet( @@ -10446,6 +10446,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -11793,6 +11794,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -16376,6 +16378,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -19156,6 +19159,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -23399,6 +23403,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -31270,6 +31275,7 @@ src = cms.InputTag( "hltAK4PFJetsForTaus" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowForTaus" ) @@ -31283,6 +31289,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -31345,6 +31352,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -31383,20 +31391,8 @@ ) process.hltPFTausSansRef = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadrons" ), @@ -31446,16 +31442,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( True ) + buildNullTaus = cms.bool( True ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) process.hltPFTaus = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRef" ) ) process.hltPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -31499,7 +31508,9 @@ MinDphi = cms.double( 0.0 ) ) process.hltPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -31542,25 +31553,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -31570,26 +31565,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -31632,25 +31645,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -31660,23 +31657,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -31808,6 +31821,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -31907,24 +31921,8 @@ ) process.hltHpsCombinatoricRecoTaus = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZeros" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08Region" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutrals" ), @@ -32016,10 +32014,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) process.hltHpsSelectionDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -32117,6 +32133,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauProducerSansRefs = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -32148,14 +32167,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTaus" ) + ) ) process.hltHpsPFTauProducer = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefs" ) ) process.hltHpsPFTauDiscriminationByDecayModeFindingNewDMs = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -32253,10 +32272,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauTrackFindingDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltHpsSelectedPFTausTrackFinding = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -32280,7 +32299,9 @@ MinPt = cms.double( 0.0 ) ) process.hltHpsPFTauLooseAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.9 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32323,25 +32344,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32351,26 +32356,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauLooseRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32413,25 +32436,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32441,23 +32448,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 50.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauLooseAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32565,7 +32588,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32608,25 +32633,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32636,26 +32645,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32698,25 +32725,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32726,23 +32737,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -32826,7 +32853,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32869,25 +32898,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32897,26 +32910,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -32959,25 +32990,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -32987,23 +33002,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -33087,7 +33118,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -33130,25 +33163,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -33158,23 +33175,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationTightOOSCPhotons = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -34376,20 +34409,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltPFTaus" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) process.hltSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -34500,20 +34533,20 @@ maskHitsRPC = cms.vint32( 0, 0, 0, 0 ), maxNumberOfHitsLast2Stations = cms.int32( -1 ), maskMatchesRPC = cms.vint32( 0, 0, 0, 0 ), - maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), - maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), + discriminatorOption = cms.string( "custom" ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducer" ), verbosity = cms.int32( 0 ), - maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), minPtMatchedMuon = cms.double( 5.0 ), dRmuonMatchLimitedToJetArea = cms.bool( False ), + dRmuonMatch = cms.double( 0.3 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - maskHitsDT = cms.vint32( 0, 0, 0, 0 ), + maskHitsCSC = cms.vint32( 0, 0, 0, 0 ), HoPMin = cms.double( -1.0 ), maxNumberOfMatches = cms.int32( 1 ), - discriminatorOption = cms.string( "custom" ), - dRmuonMatch = cms.double( 0.3 ), + maskHitsDT = cms.vint32( 0, 0, 0, 0 ), srcMuons = cms.InputTag( "" ), + maskMatchesDT = cms.vint32( 0, 0, 0, 0 ), + maskMatchesCSC = cms.vint32( 1, 0, 0, 0 ), doCaloMuonVeto = cms.bool( False ) ) process.hltHpsSelectedPFTausTrackFindingLooseChargedIsolationAgainstMuon = cms.EDFilter( "PFTauSelector", @@ -36765,6 +36798,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -37138,6 +37172,7 @@ src = cms.InputTag( "hltAK4PFJetsReg" ), deltaR = cms.double( 0.8 ), pfCandAssocMapSrc = cms.InputTag( "" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), minJetPt = cms.double( -1.0 ), pfCandSrc = cms.InputTag( "hltParticleFlowReg" ) @@ -37151,6 +37186,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -37213,6 +37249,7 @@ selectionPassFunction = cms.string( "abs(mass() - 0.13579)" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0" ), minJetPt = cms.double( -1.0 ), @@ -37251,20 +37288,8 @@ ) process.hltPFTausSansRefReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - name = cms.string( "shrinkingConeElectronRej" ), - DataType = cms.string( "AOD" ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "" ), chargedHadronSrc = cms.InputTag( "hltTauPFJetsRecoTauChargedHadronsReg" ), @@ -37314,16 +37339,29 @@ signalConeNeutralHadrons = cms.string( "0.1" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + name = cms.string( "shrinkingConeElectronRej" ), + DataType = cms.string( "AOD" ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ) + ) + ) ) process.hltPFTausReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltPFTausSansRefReg" ) ) process.hltPFTauTrackDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -37359,10 +37397,10 @@ MinPt = cms.double( 35.0 ) ) process.hltPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) process.hltSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -37386,7 +37424,9 @@ MinPt = cms.double( 35.0 ) ) process.hltPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37429,25 +37469,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37457,26 +37481,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37519,25 +37561,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37547,23 +37573,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -37635,7 +37677,9 @@ offset = cms.uint32( 0 ) ) process.hltPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37678,25 +37722,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37706,23 +37734,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -37794,7 +37838,9 @@ offset = cms.uint32( 0 ) ) process.hltPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37837,25 +37883,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37865,26 +37895,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTausReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -37927,25 +37975,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -37955,23 +37987,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -38126,6 +38174,7 @@ selectionPassFunction = cms.string( "-pt" ) ) ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 99.0 ), outputSelection = cms.string( "pt > 0.5" ), minJetPt = cms.double( -1.0 ), @@ -38225,24 +38274,8 @@ ) process.hltHpsCombinatoricRecoTausReg = cms.EDProducer( "RecoTauProducer", piZeroSrc = cms.InputTag( "hltPFTauPiZerosReg" ), - modifiers = cms.VPSet( - cms.PSet( DataType = cms.string( "AOD" ), - EcalStripSumE_deltaEta = cms.double( 0.03 ), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), - EcalStripSumE_minClusEnergy = cms.double( 0.1 ), - ElectronPreIDProducer = cms.InputTag( "elecpreid" ), - maximumForElectrionPreIDOutput = cms.double( -0.1 ), - name = cms.string( "elec_rej" ), - plugin = cms.string( "RecoTauElectronRejectionPlugin" ), - ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) - ), - cms.PSet( name = cms.string( "tau_mass" ), - plugin = cms.string( "PFRecoTauMassPlugin" ), - verbosity = cms.int32( 0 ) - ) - ), jetRegionSrc = cms.InputTag( "hltTauPFJets08RegionReg" ), + verbosity = cms.int32( 0 ), maxJetAbsEta = cms.double( 2.5 ), outputSelection = cms.string( "leadPFChargedHadrCand().isNonnull()" ), chargedHadronSrc = cms.InputTag( "hltHpsTauPFJetsRecoTauChargedHadronsWithNeutralsReg" ), @@ -38334,10 +38367,28 @@ signalConeSize = cms.string( "max(min(0.1, 3.0/pt()), 0.05)" ) ) ), - buildNullTaus = cms.bool( False ) + buildNullTaus = cms.bool( False ), + modifiers = cms.VPSet( + cms.PSet( DataType = cms.string( "AOD" ), + EcalStripSumE_deltaEta = cms.double( 0.03 ), + EcalStripSumE_deltaPhiOverQ_maxValue = cms.double( 0.5 ), + EcalStripSumE_deltaPhiOverQ_minValue = cms.double( -0.1 ), + EcalStripSumE_minClusEnergy = cms.double( 0.1 ), + ElectronPreIDProducer = cms.InputTag( "elecpreid" ), + maximumForElectrionPreIDOutput = cms.double( -0.1 ), + name = cms.string( "elec_rej" ), + plugin = cms.string( "RecoTauElectronRejectionPlugin" ), + ElecPreIDLeadTkMatch_maxDR = cms.double( 0.01 ) + ), + cms.PSet( name = cms.string( "tau_mass" ), + plugin = cms.string( "PFRecoTauMassPlugin" ), + verbosity = cms.int32( 0 ) + ) + ) ) process.hltHpsSelectionDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 0.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -38435,6 +38486,9 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauProducerSansRefsReg = cms.EDProducer( "RecoTauCleaner", + outputSelection = cms.string( "" ), + src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ), + verbosity = cms.int32( 0 ), cleaners = cms.VPSet( cms.PSet( name = cms.string( "HPS_Select" ), plugin = cms.string( "RecoTauDiscriminantCleanerPlugin" ), @@ -38466,14 +38520,14 @@ selectionFailValue = cms.double( 1000.0 ), selectionPassFunction = cms.string( "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()" ) ) - ), - src = cms.InputTag( "hltHpsCombinatoricRecoTausReg" ) + ) ) process.hltHpsPFTauProducerReg = cms.EDProducer( "RecoTauPiZeroUnembedder", src = cms.InputTag( "hltHpsPFTauProducerSansRefsReg" ) ) process.hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg = cms.EDProducer( "PFRecoTauDiscriminationByHPSSelection", PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + verbosity = cms.int32( 0 ), minTauPt = cms.double( 18.0 ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), matchingCone = cms.double( 0.5 ), @@ -38571,10 +38625,10 @@ requireTauChargedHadronsToBeChargedPFCands = cms.bool( False ) ) process.hltHpsPFTauTrackFindingDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 0.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 0.0 ) ) process.hltHpsSelectedPFTausTrackFindingReg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38610,10 +38664,10 @@ MinPt = cms.double( 35.0 ) ) process.hltHpsPFTauTrackPt1DiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 1.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 1.0 ) ) process.hltHpsSelectedPFTausTrackPt1Reg = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -38637,7 +38691,9 @@ MinPt = cms.double( 35.0 ) ) process.hltHpsPFTauTightAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.2 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38680,25 +38736,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38708,26 +38748,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38770,25 +38828,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38798,23 +38840,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 70.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauTightAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -38886,7 +38944,9 @@ offset = cms.uint32( 0 ) ) process.hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.7 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -38929,25 +38989,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.357 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 0.0 ), rhoProducer = cms.InputTag( "NotUsed" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -38957,70 +39001,22 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 0.33333 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), - maximumSumPtCut = cms.double( 2.0 ), - qualityCuts = cms.PSet( - vertexTrackFiltering = cms.bool( False ), - isolationQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.5 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 100.0 ), - maxTransverseImpactParameter = cms.double( 0.1 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), - recoverLeadingTrk = cms.bool( False ), - signalQualityCuts = cms.PSet( - maxDeltaZ = cms.double( 0.2 ), - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ), - minNeutralHadronEt = cms.double( 1.0 ) - ), - vxAssocQualityCuts = cms.PSet( - minTrackPt = cms.double( 0.0 ), - minGammaEt = cms.double( 0.5 ), - minTrackHits = cms.uint32( 3 ), - minTrackPixelHits = cms.uint32( 0 ), - maxTrackChi2 = cms.double( 1000.0 ), - maxTransverseImpactParameter = cms.double( 0.2 ), - useTracksInsteadOfPFHadrons = cms.bool( False ) - ), - pvFindingAlgo = cms.string( "closestInDeltaZ" ) - ), - minTauPtForNoIso = cms.double( -99.0 ), - vertexSrc = cms.InputTag( "NotUsed" ), - applySumPtCut = cms.bool( False ), - rhoConeSize = cms.double( 0.5 ), - ApplyDiscriminationByTrackerIsolation = cms.bool( True ), - rhoUEOffsetCorrection = cms.double( 1.0 ), - rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -39037,52 +39033,12 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) - ), - deltaBetaFactor = cms.string( "0.38" ), - applyFootprintCorrection = cms.bool( False ), - UseAllPFCandsForWeights = cms.bool( False ), - relativeSumPtCut = cms.double( 0.05 ), - Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), - applyOccupancyCut = cms.bool( False ), - applyDeltaBetaCorrection = cms.bool( False ), - WeightECALIsolation = cms.double( 1.0 ), - applyRelativeSumPtCut = cms.bool( True ), - applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), - maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), - ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), - maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), - maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), - ApplyDiscriminationByECALIsolation = cms.bool( False ), - isoConeSizeForDeltaBeta = cms.double( 0.3 ), - storeRawSumPt = cms.bool( False ), - verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), - relativeSumPtOffset = cms.double( 60.0 ), - customOuterCone = cms.double( -1.0 ), - particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) -) -process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", - PassValue = cms.double( 1.0 ), - Prediscriminants = cms.PSet( - BooleanOperator = cms.string( "or" ), - discr1 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) - ), - discr2 = cms.PSet( - cut = cms.double( 0.5 ), - Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) - ) - ), - FailValue = cms.double( 0.0 ), - PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) + ) ) -process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", +process.hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -39125,8 +39081,34 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), + deltaBetaFactor = cms.string( "0.38" ), + applyFootprintCorrection = cms.bool( False ), + UseAllPFCandsForWeights = cms.bool( False ), + relativeSumPtCut = cms.double( 0.05 ), + Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), + applyOccupancyCut = cms.bool( False ), + applyDeltaBetaCorrection = cms.bool( False ), + WeightECALIsolation = cms.double( 1.0 ), + applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), + applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), + maximumOccupancy = cms.uint32( 0 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), + ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), + maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), + maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), + ApplyDiscriminationByECALIsolation = cms.bool( False ), + isoConeSizeForDeltaBeta = cms.double( 0.3 ), + storeRawSumPt = cms.bool( False ), + verbosity = cms.int32( 0 ), + storeRawFootprintCorrection = cms.bool( False ), + relativeSumPtOffset = cms.double( 60.0 ), + customOuterCone = cms.double( -1.0 ), + particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), footprintCorrections = cms.VPSet( cms.PSet( offset = cms.string( "0.0" ), selection = cms.string( "decayMode() = 0" ) @@ -39143,7 +39125,73 @@ cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), selection = cms.string( "decayMode() = 10" ) ) + ) +) +process.hltHpsPFTauMediumAbsOrRelChargedIsolationDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", + PassValue = cms.double( 1.0 ), + Prediscriminants = cms.PSet( + BooleanOperator = cms.string( "or" ), + discr1 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumAbsoluteChargedIsolationDiscriminatorReg" ) + ), + discr2 = cms.PSet( + cut = cms.double( 0.5 ), + Producer = cms.InputTag( "hltHpsPFTauMediumRelativeChargedIsolationDiscriminatorReg" ) + ) ), + FailValue = cms.double( 0.0 ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ) +) +process.hltHpsPFTauTightOutOfSignalConePhotonsDiscriminatorReg = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), + PFTauProducer = cms.InputTag( "hltHpsPFTauProducerReg" ), + storeRawOccupancy = cms.bool( False ), + maximumSumPtCut = cms.double( 2.0 ), + qualityCuts = cms.PSet( + vertexTrackFiltering = cms.bool( False ), + isolationQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.5 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 100.0 ), + maxTransverseImpactParameter = cms.double( 0.1 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + primaryVertexSrc = cms.InputTag( "hltPixelVertices" ), + recoverLeadingTrk = cms.bool( False ), + signalQualityCuts = cms.PSet( + maxDeltaZ = cms.double( 0.2 ), + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ), + minNeutralHadronEt = cms.double( 1.0 ) + ), + vxAssocQualityCuts = cms.PSet( + minTrackPt = cms.double( 0.0 ), + minGammaEt = cms.double( 0.5 ), + minTrackHits = cms.uint32( 3 ), + minTrackPixelHits = cms.uint32( 0 ), + maxTrackChi2 = cms.double( 1000.0 ), + maxTransverseImpactParameter = cms.double( 0.2 ), + useTracksInsteadOfPFHadrons = cms.bool( False ) + ), + pvFindingAlgo = cms.string( "closestInDeltaZ" ) + ), + minTauPtForNoIso = cms.double( -99.0 ), + vertexSrc = cms.InputTag( "NotUsed" ), + applySumPtCut = cms.bool( False ), + rhoConeSize = cms.double( 0.5 ), + ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), + rhoUEOffsetCorrection = cms.double( 1.0 ), + rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -39153,23 +39201,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( True ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowReg" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltHpsPFTauMediumChargedIsolationAndTightOOSCPhotonsDiscriminatorReg = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -45808,6 +45872,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -53446,13 +53511,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtag" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtag" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -60078,7 +60143,9 @@ MinDphi = cms.double( 0.0 ) ) process.hltPFTauMediumAbsoluteChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -60121,25 +60188,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAllCaloForMuons" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -60149,26 +60200,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumRelativeChargedIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 3.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -60211,25 +60280,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -60239,23 +60292,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 60.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumAbsOrRelChargedIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -72475,6 +72544,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -72836,6 +72906,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAntiKT4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), @@ -81888,10 +81959,10 @@ MinPt = cms.double( 50.0 ) ) process.hltPFTauTrackPt30Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 30.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 30.0 ) ) process.hltPFTau1Prong = cms.EDProducer( "PFRecoTauDiscriminationByNProngs", MinN = cms.uint32( 1 ), @@ -82177,7 +82248,9 @@ MinPt = cms.double( 180.0 ) ) process.hltPFTauMediumHighPtRelaxedIsoAbsoluteIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.3 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -82219,25 +82292,9 @@ applySumPtCut = cms.bool( True ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -82247,26 +82304,44 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( False ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 0.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumHighPtRelaxedIsoRelativeIsolationDiscriminator = cms.EDProducer( "PFRecoTauDiscriminationByIsolation", + applyRhoCorrection = cms.bool( False ), PFTauProducer = cms.InputTag( "hltPFTaus" ), + storeRawOccupancy = cms.bool( False ), maximumSumPtCut = cms.double( 2.0 ), qualityCuts = cms.PSet( vertexTrackFiltering = cms.bool( False ), @@ -82308,25 +82383,9 @@ applySumPtCut = cms.bool( False ), rhoConeSize = cms.double( 0.5 ), ApplyDiscriminationByTrackerIsolation = cms.bool( True ), + storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ), rhoUEOffsetCorrection = cms.double( 1.0 ), rhoProducer = cms.InputTag( "hltFixedGridRhoFastjetAll" ), - footprintCorrections = cms.VPSet( - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 0" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) - ), - cms.PSet( offset = cms.string( "2.7" ), - selection = cms.string( "decayMode() = 5" ) - ), - cms.PSet( offset = cms.string( "0.0" ), - selection = cms.string( "decayMode() = 6" ) - ), - cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), - selection = cms.string( "decayMode() = 10" ) - ) - ), deltaBetaFactor = cms.string( "0.38" ), applyFootprintCorrection = cms.bool( False ), UseAllPFCandsForWeights = cms.bool( False ), @@ -82336,23 +82395,39 @@ applyDeltaBetaCorrection = cms.bool( False ), WeightECALIsolation = cms.double( 1.0 ), applyRelativeSumPtCut = cms.bool( True ), + storeRawPUsumPt = cms.bool( False ), applyPhotonPtSumOutsideSignalConeCut = cms.bool( False ), maximumOccupancy = cms.uint32( 0 ), - deltaBetaPUTrackPtCutOverride = cms.double( 0.5 ), + deltaBetaPUTrackPtCutOverride = cms.bool( True ), ApplyDiscriminationByWeightedECALIsolation = cms.bool( False ), maxAbsPhotonSumPt_outsideSignalCone = cms.double( 1.0E9 ), maxRelPhotonSumPt_outsideSignalCone = cms.double( 0.1 ), + deltaBetaPUTrackPtCutOverride_val = cms.double( 0.5 ), ApplyDiscriminationByECALIsolation = cms.bool( False ), isoConeSizeForDeltaBeta = cms.double( 0.3 ), storeRawSumPt = cms.bool( False ), verbosity = cms.int32( 0 ), - applyRhoCorrection = cms.bool( False ), + storeRawFootprintCorrection = cms.bool( False ), relativeSumPtOffset = cms.double( 200.0 ), customOuterCone = cms.double( -1.0 ), particleFlowSrc = cms.InputTag( "hltParticleFlowForTaus" ), - storeRawPUsumPt = cms.bool( False ), - storeRawFootprintCorrection = cms.bool( False ), - storeRawPhotonSumPt_outsideSignalCone = cms.bool( False ) + footprintCorrections = cms.VPSet( + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 0" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 1 || decayMode() = 2" ) + ), + cms.PSet( offset = cms.string( "2.7" ), + selection = cms.string( "decayMode() = 5" ) + ), + cms.PSet( offset = cms.string( "0.0" ), + selection = cms.string( "decayMode() = 6" ) + ), + cms.PSet( offset = cms.string( "max(2.0, 0.22*pt() - 2.0)" ), + selection = cms.string( "decayMode() = 10" ) + ) + ) ) process.hltPFTauMediumHighPtRelaxedIsoAbsOrRelIsolationDiscriminator = cms.EDProducer( "PFTauDiscriminatorLogicalAndProducer", PassValue = cms.double( 1.0 ), @@ -82371,10 +82446,10 @@ PFTauProducer = cms.InputTag( "hltPFTaus" ) ) process.hltPFTauTrackPt50Discriminator = cms.EDProducer( "PFRecoTauDiscriminationByLeadingObjectPtCut", - MinPtLeadingObject = cms.double( 50.0 ), + UseOnlyChargedHadrons = cms.bool( True ), Prediscriminants = cms.PSet( BooleanOperator = cms.string( "and" ) ), PFTauProducer = cms.InputTag( "hltPFTaus" ), - UseOnlyChargedHadrons = cms.bool( True ) + MinPtLeadingObject = cms.double( 50.0 ) ) process.hltSelectedPFTausTrackPt50AbsOrRelMediumHighPtRelaxedIsoIsolation = cms.EDFilter( "PFTauSelector", discriminators = cms.VPSet( @@ -86706,13 +86781,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), @@ -86929,13 +87004,13 @@ minimumTransverseMomentum = cms.double( 1.0 ), primaryVertex = cms.InputTag( "hltVerticesPFFilter" ), maximumLongitudinalImpactParameter = cms.double( 17.0 ), - jets = cms.InputTag( "hltPFJetForDBtagAK8" ), + computeGhostTrack = cms.bool( True ), maxDeltaR = cms.double( 0.4 ), candidates = cms.InputTag( "hltParticleFlow" ), jetDirectionUsingGhostTrack = cms.bool( False ), minimumNumberOfPixelHits = cms.int32( 2 ), jetDirectionUsingTracks = cms.bool( False ), - computeGhostTrack = cms.bool( True ), + jets = cms.InputTag( "hltPFJetForDBtagAK8" ), useTrackQuality = cms.bool( False ), ghostTrackPriorDeltaR = cms.double( 0.03 ), maximumChiSquared = cms.double( 5.0 ), diff --git a/HLTrigger/Configuration/test/OnLine_HLT_HIon.py b/HLTrigger/Configuration/test/OnLine_HLT_HIon.py index e5f2d399b280a..9daaf41ac14d3 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_HIon.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_HIon.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/HIon --type HIon --unprescale --process HLTHIon --globaltag auto:run2_hlt_HIon --input file:RelVal_Raw_HIon_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/HIon --type HIon --unprescale --process HLTHIon --globaltag auto:run2_hlt_HIon --input file:RelVal_Raw_HIon_DATA.root -# /dev/CMSSW_10_5_0/HIon/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/HIon/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTHIon" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/HIon/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/HIon/V1') ) process.transferSystem = cms.PSet( @@ -10138,6 +10138,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), @@ -11731,6 +11732,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "hltHoreco" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "hltAK4CaloJetsPFEt5" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/test/OnLine_HLT_PIon.py b/HLTrigger/Configuration/test/OnLine_HLT_PIon.py index eeb3cca4a0905..89c6045b77554 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_PIon.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_PIon.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/PIon --type PIon --unprescale --process HLTPIon --globaltag auto:run2_hlt_PIon --input file:RelVal_Raw_PIon_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/PIon --type PIon --unprescale --process HLTPIon --globaltag auto:run2_hlt_PIon --input file:RelVal_Raw_PIon_DATA.root -# /dev/CMSSW_10_5_0/PIon/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/PIon/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTPIon" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/PIon/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/PIon/V1') ) process.transferSystem = cms.PSet( diff --git a/HLTrigger/Configuration/test/OnLine_HLT_PRef.py b/HLTrigger/Configuration/test/OnLine_HLT_PRef.py index 3bb6e72d0d9be..6e68d9e704417 100644 --- a/HLTrigger/Configuration/test/OnLine_HLT_PRef.py +++ b/HLTrigger/Configuration/test/OnLine_HLT_PRef.py @@ -1,13 +1,13 @@ -# hltGetConfiguration --full --data /dev/CMSSW_10_5_0/PRef --type PRef --unprescale --process HLTPRef --globaltag auto:run2_hlt_PRef --input file:RelVal_Raw_PRef_DATA.root +# hltGetConfiguration --full --data /dev/CMSSW_10_6_0/PRef --type PRef --unprescale --process HLTPRef --globaltag auto:run2_hlt_PRef --input file:RelVal_Raw_PRef_DATA.root -# /dev/CMSSW_10_5_0/PRef/V2 (CMSSW_10_5_0_pre2) +# /dev/CMSSW_10_6_0/PRef/V1 (CMSSW_10_6_0_pre3_HLT1) import FWCore.ParameterSet.Config as cms process = cms.Process( "HLTPRef" ) process.HLTConfigVersion = cms.PSet( - tableName = cms.string('/dev/CMSSW_10_5_0/PRef/V2') + tableName = cms.string('/dev/CMSSW_10_6_0/PRef/V1') ) process.transferSystem = cms.PSet( @@ -8882,6 +8882,7 @@ dRHcalPreselection = cms.double( 0.2 ), HORecHitCollectionLabel = cms.InputTag( "Notused" ) ), + storeCrossedHcalRecHits = cms.bool( False ), JetExtractorPSet = cms.PSet( JetCollectionLabel = cms.InputTag( "Notused" ), DR_Veto = cms.double( 0.1 ), diff --git a/HLTrigger/Configuration/test/getFrozenHLT.sh b/HLTrigger/Configuration/test/getFrozenHLT.sh index 61820ebc02e85..b7035eaa0490c 100755 --- a/HLTrigger/Configuration/test/getFrozenHLT.sh +++ b/HLTrigger/Configuration/test/getFrozenHLT.sh @@ -2,9 +2,9 @@ # ConfDB configurations to use TABLES="Fake Fake1 Fake2" -HLT_Fake="/dev/CMSSW_10_5_0/Fake" -HLT_Fake1="/dev/CMSSW_10_5_0/Fake1" -HLT_Fake2="/dev/CMSSW_10_5_0/Fake2" +HLT_Fake="/dev/CMSSW_10_6_0/Fake" +HLT_Fake1="/dev/CMSSW_10_6_0/Fake1" +HLT_Fake2="/dev/CMSSW_10_6_0/Fake2" # print extra messages ? VERBOSE=false diff --git a/HLTrigger/Configuration/test/getHLT.sh b/HLTrigger/Configuration/test/getHLT.sh index 46f2909db2cc0..cb1cc8c2669ce 100755 --- a/HLTrigger/Configuration/test/getHLT.sh +++ b/HLTrigger/Configuration/test/getHLT.sh @@ -1,8 +1,8 @@ #! /bin/bash # ConfDB configurations to use -MASTER="/dev/CMSSW_10_5_0/HLT" # no explicit version, take the most recent -TARGET="/dev/CMSSW_10_5_0/\$TABLE" # no explicit version, take the most recent +MASTER="/dev/CMSSW_10_6_0/HLT" # no explicit version, take the most recent +TARGET="/dev/CMSSW_10_6_0/\$TABLE" # no explicit version, take the most recent TABLES="GRun HIon PIon PRef" # $TABLE in the above variable will be expanded to these TABLES From 849e0c257351a85b681e713a6caa580da237712b Mon Sep 17 00:00:00 2001 From: Martin Grunewald Date: Tue, 2 Apr 2019 11:33:48 +0200 Subject: [PATCH 394/686] Migration to 10_6 for Tau changes --- HLTrigger/Configuration/python/customizeHLTforCMSSW.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 4eaa9872360ca..4f429b96d56d9 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -48,20 +48,10 @@ def customiseFor2017DtUnpacking(process): return process -# type of parameter changed -def customiseFor24501(process): - for producer in producers_by_type(process, "PFRecoTauDiscriminationByIsolation"): - if hasattr(producer, "deltaBetaPUTrackPtCutOverride") and not isinstance(producer.deltaBetaPUTrackPtCutOverride, cms.bool): - producer.deltaBetaPUTrackPtCutOverride_val = producer.deltaBetaPUTrackPtCutOverride - producer.deltaBetaPUTrackPtCutOverride = cms.bool(True) - return process - - # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): # add call to action function in proper order: newest last! # process = customiseFor12718(process) - process = customiseFor24501(process) return process From 93398557b7e2c12c77db56af144fbe1c897385f0 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 2 Apr 2019 12:07:30 +0200 Subject: [PATCH 395/686] Timing calibrations tests moved to CalibPPS package --- .../ESProducers}/test/ppsTimingCalibrationAnalyzer_cfg.py | 0 .../ESProducers}/test/ppsTimingCalibrationWriter_cfg.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {CondTools/CTPPS => CalibPPS/ESProducers}/test/ppsTimingCalibrationAnalyzer_cfg.py (100%) rename {CondTools/CTPPS => CalibPPS/ESProducers}/test/ppsTimingCalibrationWriter_cfg.py (93%) diff --git a/CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py b/CalibPPS/ESProducers/test/ppsTimingCalibrationAnalyzer_cfg.py similarity index 100% rename from CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py rename to CalibPPS/ESProducers/test/ppsTimingCalibrationAnalyzer_cfg.py diff --git a/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py b/CalibPPS/ESProducers/test/ppsTimingCalibrationWriter_cfg.py similarity index 93% rename from CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py rename to CalibPPS/ESProducers/test/ppsTimingCalibrationWriter_cfg.py index 8ba510be79a3d..0eb07d507857e 100644 --- a/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py +++ b/CalibPPS/ESProducers/test/ppsTimingCalibrationWriter_cfg.py @@ -12,7 +12,7 @@ from CondFormats.CTPPSReadoutObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum # load calibrations from JSON file -process.load('CondFormats.CTPPSReadoutObjects.ppsTimingCalibrationESSource_cfi') +process.load('CalibPPS.ESProducers.ppsTimingCalibrationESSource_cfi') process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoCTPPS/TotemRPLocal/data/timing_calibration_diamond_2018_mar19.ex.json') process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND From 376d5cb5604b73101f6793e0a434a9637d04a857 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 2 Apr 2019 07:07:05 -0500 Subject: [PATCH 396/686] Fix thread safety issue in FEDNumbering Removed the thread unsafe initialization of static member data. Change to initialize the data either at compile time (via the use of constexpr) or at shared library load time. --- .../FEDRawData/interface/FEDNumbering.h | 15 +- DataFormats/FEDRawData/src/FEDNumbering.cc | 485 ++++++++++++------ DataFormats/FEDRawData/test/BuildFile.xml | 2 +- .../FEDRawData/test/FEDNumbering_t.cpp | 265 ++++++++++ 4 files changed, 601 insertions(+), 166 deletions(-) create mode 100644 DataFormats/FEDRawData/test/FEDNumbering_t.cpp diff --git a/DataFormats/FEDRawData/interface/FEDNumbering.h b/DataFormats/FEDRawData/interface/FEDNumbering.h index eb057c3251ec8..eef85d3f2359f 100644 --- a/DataFormats/FEDRawData/interface/FEDNumbering.h +++ b/DataFormats/FEDRawData/interface/FEDNumbering.h @@ -12,7 +12,7 @@ * \author G. Bruno - CERN, EP Division */ -#include +#include #include class FEDNumbering { @@ -20,11 +20,9 @@ class FEDNumbering { public: - virtual ~FEDNumbering(){}; - - static int lastFEDId(); - - static void init(); + static constexpr int lastFEDId() { + return MAXFEDID; + } static bool inRange(int); static bool inRangeNoGT(int); @@ -137,11 +135,6 @@ class FEDNumbering { MINDAQvFEDFEDID = 2815, MAXDAQvFEDFEDID = 4095 }; - private: - static std::vector from_; - static bool *in_; - static bool init_; - }; #endif // FEDNumbering_H diff --git a/DataFormats/FEDRawData/src/FEDNumbering.cc b/DataFormats/FEDRawData/src/FEDNumbering.cc index 91c56270ead80..c3097bb706f9f 100644 --- a/DataFormats/FEDRawData/src/FEDNumbering.cc +++ b/DataFormats/FEDRawData/src/FEDNumbering.cc @@ -3,180 +3,357 @@ * \author G. Bruno - CERN, EP Division */ #include "DataFormats/FEDRawData/interface/FEDNumbering.h" - +#include using namespace std; +namespace { -bool FEDNumbering::init_ = true; -bool *FEDNumbering::in_ = new bool[MAXFEDID+1]; + constexpr std::array initIn() { + std::array in ={{false}}; + + int i = 0; + for(i=0; i< FEDNumbering::lastFEDId(); i++) + in[i] = false; + for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) + { + in[i] = true; + } + for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) + { + in[i] = true; + } + return in; + } + + constexpr std::array initFromIndex() { + std::array fromIndex= {{0}}; + int i = 0; + int index = 0; + for(i=0; i< FEDNumbering::lastFEDId(); i++) + fromIndex[i] = index; //empty + ++index; + for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) + { + fromIndex[i] = index; //"SiPixel"; + } + ++index; + for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) + { + fromIndex[i] = index; //"SiStrip"; + } + ++index; + for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) + { + fromIndex[i] = index; //"PreShower"; + } + ++index; + for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) + { + fromIndex[i] = index; //"Ecal"; + } + ++index; + for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) + { + fromIndex[i] = index; //"Castor"; + } + ++index; + for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) + { + fromIndex[i] = index; //"Hcal"; + } + ++index; + for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) + { + fromIndex[i] = index; //"LumiScalers"; + } + ++index; + for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) + { + fromIndex[i] = index; //"CSC"; + } + ++index; + for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) + { + fromIndex[i] = index; //"CSCTF"; + } + ++index; + for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) + { + fromIndex[i] = index; //"DT"; + } + ++index; + for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) + { + fromIndex[i] = index; //"DTTF"; + } + ++index; + for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) + { + fromIndex[i] = index; //"RPC"; + } + ++index; + for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) + { + fromIndex[i] = index; //"TriggerGTP"; + } + ++index; + for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) + { + fromIndex[i] = index; //"TriggerEGTP"; + } + ++index; + for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) + { + fromIndex[i] = index; //"TriggerGCT"; + } + ++index; + for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) + { + fromIndex[i] = index; //"TriggerLTC"; + } + ++index; + for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) + { + fromIndex[i] = index; //"TriggerLTCmtcc"; + } + ++index; + for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) + { + fromIndex[i] = index; //"CSCDDU"; + } + ++index; + for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) + { + fromIndex[i] = index; //"CSCContingency"; + } + ++index; + for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) + { + fromIndex[i] = index; //"CSCTFSP"; + } + ++index; + for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) + { + fromIndex[i] = index; //"DAQ"; + } + //++index; same name so no need for new index + for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) + { + fromIndex[i] = index; //"DAQ"; + } + ++index; + for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) + { + fromIndex[i] = index; //"TCDS"; + } + ++index; + for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) + { + fromIndex[i] = index; //"Hcal"; + } + ++index; + for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) + { + fromIndex[i] = index; //"SiPixel"; + } + ++index; + for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) + { + fromIndex[i] = index; //"DTUROS"; + } + ++index; + for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) + { + fromIndex[i] = index; //"L1T"; + } + return fromIndex; + } + + + std::array initFromString() { + std::array fromString; + int index = 0; + fromString[index] = ""; + ++index; + fromString[index] = "SiPixel"; + ++index; + fromString[index] = "SiStrip"; + ++index; + fromString[index] = "PreShower"; + ++index; + fromString[index] = "Ecal"; + ++index; + fromString[index] = "Castor"; + ++index; + fromString[index] = "Hcal"; + ++index; + fromString[index] = "LumiScalers"; + ++index; + fromString[index] = "CSC"; + ++index; + fromString[index] = "CSCTF"; + ++index; + fromString[index] = "DT"; + ++index; + fromString[index] = "DTTF"; + ++index; + fromString[index] = "RPC"; + ++index; + fromString[index] = "TriggerGTP"; + ++index; + fromString[index] = "TriggerEGTP"; + ++index; + fromString[index] = "TriggerGCT"; + ++index; + fromString[index] = "TriggerLTC"; + ++index; + fromString[index] = "TriggerLTCmtcc"; + ++index; + fromString[index] = "CSCDDU"; + ++index; + fromString[index] = "CSCContingency"; + ++index; + fromString[index] = "CSCTFSP"; + ++index; + fromString[index] = "DAQ"; + ++index; + fromString[index] = "TCDS"; + ++index; + fromString[index] = "Hcal"; + ++index; + fromString[index] = "SiPixel"; + ++index; + fromString[index] = "DTUROS"; + ++index; + fromString[index] = "L1T"; + + assert(index+1 == fromString.size()); + return fromString; + } + + constexpr std::array in_ = initIn(); + + constexpr std::array fromIndex_ = initFromIndex(); + + const std::array fromString_ = initFromString(); -vector FEDNumbering::from_(MAXFEDID+1,""); -int FEDNumbering::lastFEDId(){ - return MAXFEDID; -} -void FEDNumbering::init() -{ - int i = 0; - for(i=0; i< lastFEDId(); i++) - in_[i] = false; - for(i=MINSiPixelFEDID; i<=MAXSiPixelFEDID; i++) - { - in_[i] = true; - from_[i] = "SiPixel"; - } - for(i=MINSiStripFEDID; i<=MAXSiStripFEDID; i++) - { - in_[i] = true; - from_[i] = "SiStrip"; - } - for(i=MINPreShowerFEDID; i<=MAXPreShowerFEDID; i++) - { - in_[i] = true; - from_[i] = "PreShower"; - } - for(i=MINECALFEDID; i<=MAXECALFEDID; i++) - { - in_[i] = true; - from_[i] = "Ecal"; - } - for(i=MINCASTORFEDID; i<=MAXCASTORFEDID; i++) - { - in_[i] = true; - from_[i] = "Castor"; - } - for(i=MINHCALFEDID; i<=MAXHCALFEDID; i++) - { - in_[i] = true; - from_[i] = "Hcal"; - } - for(i=MINLUMISCALERSFEDID; i<=MAXLUMISCALERSFEDID; i++) - { - in_[i] = true; - from_[i] = "LumiScalers"; - } - for(i=MINCSCFEDID; i<=MAXCSCFEDID; i++) - { - in_[i] = true; - from_[i] = "CSC"; - } - for(i=MINCSCTFFEDID; i<=MAXCSCTFFEDID; i++) - { - in_[i] = true; - from_[i] = "CSCTF"; - } - for(i=MINDTFEDID; i<=MAXDTFEDID; i++) - { - in_[i] = true; - from_[i] = "DT"; - } - for(i=MINDTTFFEDID; i<=MAXDTTFFEDID; i++) - { - in_[i] = true; - from_[i] = "DTTF"; - } - for(i=MINRPCFEDID; i<=MAXRPCFEDID; i++) - { - in_[i] = true; - from_[i] = "RPC"; - } - for(i=MINTriggerGTPFEDID; i<=MAXTriggerGTPFEDID; i++) - { - in_[i] = true; - from_[i] = "TriggerGTP"; - } - for(i=MINTriggerEGTPFEDID; i<=MAXTriggerEGTPFEDID; i++) - { - in_[i] = true; - from_[i] = "TriggerEGTP"; - } - for(i=MINTriggerGCTFEDID; i<=MAXTriggerGCTFEDID; i++) - { - in_[i] = true; - from_[i] = "TriggerGCT"; - } - for(i=MINTriggerLTCFEDID; i<=MAXTriggerLTCFEDID; i++) - { - in_[i] = true; - from_[i] = "TriggerLTC"; - } - for(i=MINTriggerLTCmtccFEDID; i<=MAXTriggerLTCmtccFEDID; i++) - { - in_[i] = true; - from_[i] = "TriggerLTCmtcc"; - } - for(i=MINCSCDDUFEDID; i<=MAXCSCDDUFEDID; i++) - { - in_[i] = true; - from_[i] = "CSCDDU"; - } - for(i=MINCSCContingencyFEDID; i<=MAXCSCContingencyFEDID; i++) - { - in_[i] = true; - from_[i] = "CSCContingency"; - } - for(i=MINCSCTFSPFEDID; i<=MAXCSCTFSPFEDID; i++) - { - in_[i] = true; - from_[i] = "CSCTFSP"; - } - for(i=MINDAQeFEDFEDID; i<=MAXDAQeFEDFEDID; i++) - { - in_[i] = true; - from_[i] = "DAQ"; - } - for(i=MINDAQmFEDFEDID; i<=MAXDAQmFEDFEDID; i++) - { - in_[i] = true; - from_[i] = "DAQ"; - } - for(i=MINTCDSuTCAFEDID; i<=MAXTCDSuTCAFEDID; i++) - { - in_[i] = true; - from_[i] = "TCDS"; - } - for(i=MINHCALuTCAFEDID; i<=MAXHCALuTCAFEDID; i++) - { - in_[i] = true; - from_[i] = "Hcal"; - } - for(i=MINSiPixeluTCAFEDID; i<=MAXSiPixeluTCAFEDID; i++) - { - in_[i] = true; - from_[i] = "SiPixel"; - } - for(i=MINDTUROSFEDID; i<=MAXDTUROSFEDID; i++) - { - in_[i] = true; - from_[i] = "DTUROS"; - } - for(i=MINTriggerUpgradeFEDID; i<=MAXTriggerUpgradeFEDID; i++) - { - in_[i] = true; - from_[i] = "L1T"; - } - - - init_ = false; } bool FEDNumbering::inRange(int i) { - if(init_) init(); return in_[i]; } bool FEDNumbering::inRangeNoGT(int i) { - if(init_) init(); if((i>=MINTriggerGTPFEDID && i<=MAXTriggerGTPFEDID) || (i>=MINTriggerEGTPFEDID && i<=MAXTriggerEGTPFEDID)) return false; return in_[i]; } string const &FEDNumbering::fromDet(int i) { - if(init_) init(); - return from_[i]; + return fromString_[fromIndex_[i]]; } diff --git a/DataFormats/FEDRawData/test/BuildFile.xml b/DataFormats/FEDRawData/test/BuildFile.xml index 8797d30df4803..ed993bf42ad73 100644 --- a/DataFormats/FEDRawData/test/BuildFile.xml +++ b/DataFormats/FEDRawData/test/BuildFile.xml @@ -1,5 +1,5 @@ - + diff --git a/DataFormats/FEDRawData/test/FEDNumbering_t.cpp b/DataFormats/FEDRawData/test/FEDNumbering_t.cpp new file mode 100644 index 0000000000000..c215d4795d26b --- /dev/null +++ b/DataFormats/FEDRawData/test/FEDNumbering_t.cpp @@ -0,0 +1,265 @@ +/** + \file + test file for FEDRawData library + + \author Stefano ARGIRO + \date 28 Jun 2005 +*/ + +#include +#include "DataFormats/FEDRawData/interface/FEDNumbering.h" + +class testFEDNumbering: public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testFEDNumbering); + + CPPUNIT_TEST(test_inRange); + CPPUNIT_TEST(test_fromDet); + + CPPUNIT_TEST_SUITE_END(); + +public: + + + void setUp(){} + void tearDown(){} + void test_inRange(); + void test_fromDet(); + +}; + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(testFEDNumbering); + + +void testFEDNumbering::test_inRange(){ + int i = 0; + for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MAXSiPixelFEDID+1; i<=FEDNumbering::MINSiStripFEDID-1; i++) + { + CPPUNIT_ASSERT(not FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } + for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::inRange(i)); + } +} + +void testFEDNumbering::test_fromDet(){ + int i = 0; + for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiPixel"); + } + for(i=FEDNumbering::MAXSiPixelFEDID+1; i<=FEDNumbering::MINSiStripFEDID-1; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i).empty()); + } + for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiStrip"); + } + for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="PreShower"); + } + for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Ecal"); + } + for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Castor"); + } + for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Hcal"); + } + for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="LumiScalers"); + } + for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSC"); + } + for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCTF"); + } + for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DT"); + } + for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DTTF"); + } + for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="RPC"); + } + for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerGTP"); + } + for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerEGTP"); + } + for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerGCT"); + } + for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerLTC"); + } + for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerLTCmtcc"); + } + for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCDDU"); + } + for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCContingency"); + } + for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCTFSP"); + } + for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DAQ"); + } + for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DAQ"); + } + for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TCDS"); + } + for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Hcal"); + } + for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiPixel"); + } + for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DTUROS"); + } + for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) + { + CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="L1T"); + } +} From 9cc8e3ed471cfc2cf2d1d6528bb3803a07c1b1b6 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 2 Apr 2019 14:50:01 +0200 Subject: [PATCH 397/686] const timeEval method --- .../TotemRPLocal/interface/CTPPSTimingTrackRecognition.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index c5e8cc5f4e803..1ddb3c48cbc81 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -107,7 +107,7 @@ class CTPPSTimingTrackRecognition * - track's time sigma = uncertainty of the weighted mean * - hit is ignored if the time precision is equal to 0 */ - bool timeEval(const HitVector& hits, float& meanTime, float& timeSigma); + bool timeEval(const HitVector& hits, float& meanTime, float& timeSigma) const; }; /**************************************************************************** @@ -227,7 +227,7 @@ CTPPSTimingTrackRecognition::getHitSpatialRange(const HitV template inline bool -CTPPSTimingTrackRecognition::timeEval(const HitVector& hits, float& mean_time, float& time_sigma) +CTPPSTimingTrackRecognition::timeEval(const HitVector& hits, float& mean_time, float& time_sigma) const { float mean_num = 0.f, mean_denom = 0.f; bool valid_hits = false; From b37b99704134d4a20c2e847a45b7fee4933a2600 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 2 Apr 2019 07:57:30 -0500 Subject: [PATCH 398/686] Fix const declaration of static used in OAQuality Switched to using constexpr functions. This was caught by the clang static analyzer. --- CondFormats/OptAlignObjects/interface/OAQuality.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CondFormats/OptAlignObjects/interface/OAQuality.h b/CondFormats/OptAlignObjects/interface/OAQuality.h index aa01f0f8c03c3..b6ff903de7104 100644 --- a/CondFormats/OptAlignObjects/interface/OAQuality.h +++ b/CondFormats/OptAlignObjects/interface/OAQuality.h @@ -5,9 +5,9 @@ enum OAQuality { oa_fixed, oa_calibrated, oa_unknown }; struct OAQualityTranslator { - static const char * name(OAQuality oaq) + constexpr static const char * const name(OAQuality oaq) { - static const char* c[] = { + constexpr const char * const c[] = { "fixed", "calibrated", "unknown" @@ -15,7 +15,7 @@ struct OAQualityTranslator { return c[oaq]; } - static const OAQuality index( const int& ind ) { + static constexpr const OAQuality index(int ind ) { switch (ind) { case 0: return oa_fixed; From 815d40aaa9070b12a835b2a6dfb21a0eef70c08b Mon Sep 17 00:00:00 2001 From: Alessandro Rossi Date: Tue, 2 Apr 2019 15:32:22 +0200 Subject: [PATCH 399/686] Added plots to monitor pixel clusterrepair algorithm --- .../plugins/SiPixelPhase1RecHits.cc | 6 +- .../python/SiPixelPhase1RecHits_cfi.py | 96 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc index cd4d297642ef7..7fd9fb44eaea2 100644 --- a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc +++ b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc @@ -32,7 +32,9 @@ class SiPixelPhase1RecHits final : public SiPixelPhase1Base { ERROR_X, ERROR_Y, POS, - CLUSTER_PROB + CLUSTER_PROB, + NONEDGE, + NOTHERBAD }; public: @@ -142,6 +144,8 @@ void SiPixelPhase1RecHits::analyze(const edm::Event& iEvent, const edm::EventSet float lerr_y = sqrt(lerr.yy()); histo[NRECHITS].fill(id, &iEvent, col, row); //in general a inclusive counter of missing/valid/inactive hits + if(prechit->isOnEdge()) histo[NONEDGE].fill(id, &iEvent, col, row); + if(prechit->hasBadPixels()) histo[NOTHERBAD].fill(id, &iEvent, col, row); if (isHitValid){ histo[CLUST_X].fill(sizeX, id, &iEvent, col, row); diff --git a/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py b/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py index f7f108f68a198..9248b2387795a 100644 --- a/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py +++ b/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py @@ -108,6 +108,100 @@ ) ) +SiPixelPhase1RecHitsOnEdge = DefaultHistoTrack.clone( + name = "onedge", + title = "OnEdge", + range_min = 0, range_max = 30, range_nbins = 30, + xlabel = "onedge", + dimensions = 0, + specs = VPSet( + + StandardSpecificationTrend_Num, + StandardSpecificationOccupancy, + Specification().groupBy("PXBarrel/PXLayer/Event") + .reduce("COUNT") + .groupBy("PXBarrel/PXLayer/LumiBlock") + .reduce("MEAN") + .groupBy("PXBarrel/PXLayer","EXTEND_X") + .save(), + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward/PXDisk/LumiBlock") + .reduce("MEAN") + .groupBy("PXForward/PXDisk","EXTEND_X") + .save(), + Specification().groupBy("PXBarrel/PXLayer/Event") + .reduce("COUNT") + .groupBy("PXBarrel/PXLayer/") + .save(nbins=100, xmin=0, xmax=1000), + Specification().groupBy("PXBarrel/Event") + .reduce("COUNT") + .groupBy("PXBarrel") + .save(nbins=100, xmin=0, xmax=1000), + + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward/PXDisk/") + .save(nbins=100, xmin=0, xmax=1000), + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward") + .save(nbins=100, xmin=0, xmax=1000), + + Specification().groupBy("PXAll/Event") + .reduce("COUNT") + .groupBy("PXAll") + .save(nbins=100, xmin=0, xmax=1000) + + ) +) + +SiPixelPhase1RecHitsOtherBad = DefaultHistoTrack.clone( + name = "otherbad", + title = "OtherBad", + range_min = 0, range_max = 30, range_nbins = 30, + xlabel = "otherbad", + dimensions = 0, + specs = VPSet( + + StandardSpecificationTrend_Num, + StandardSpecificationOccupancy, + Specification().groupBy("PXBarrel/PXLayer/Event") + .reduce("COUNT") + .groupBy("PXBarrel/PXLayer/LumiBlock") + .reduce("MEAN") + .groupBy("PXBarrel/PXLayer","EXTEND_X") + .save(), + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward/PXDisk/LumiBlock") + .reduce("MEAN") + .groupBy("PXForward/PXDisk","EXTEND_X") + .save(), + Specification().groupBy("PXBarrel/PXLayer/Event") + .reduce("COUNT") + .groupBy("PXBarrel/PXLayer/") + .save(nbins=100, xmin=0, xmax=1000), + Specification().groupBy("PXBarrel/Event") + .reduce("COUNT") + .groupBy("PXBarrel") + .save(nbins=100, xmin=0, xmax=1000), + + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward/PXDisk/") + .save(nbins=100, xmin=0, xmax=1000), + Specification().groupBy("PXForward/PXDisk/Event") + .reduce("COUNT") + .groupBy("PXForward") + .save(nbins=100, xmin=0, xmax=1000), + + Specification().groupBy("PXAll/Event") + .reduce("COUNT") + .groupBy("PXAll") + .save(nbins=100, xmin=0, xmax=1000) + ) +) SiPixelPhase1RecHitsConf = cms.VPSet( SiPixelPhase1RecHitsNRecHits, @@ -117,6 +211,8 @@ SiPixelPhase1RecHitsErrorY, SiPixelPhase1RecHitsPosition, SiPixelPhase1RecHitsProb, + SiPixelPhase1RecHitsOnEdge, + SiPixelPhase1RecHitsOtherBad, ) from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer From f2b4655ff9c0578117282b51373f36caae2c88e5 Mon Sep 17 00:00:00 2001 From: Samuel Webb Date: Tue, 2 Apr 2019 15:10:27 +0200 Subject: [PATCH 400/686] Respond to comments from Kevin --- .../backend/HGCalHistoClusteringImpl.h | 6 +-- .../HGCalConcentratorSuperTriggerCellImpl.h | 7 +++ .../src/backend/HGCalHistoClusteringImpl.cc | 26 ++++++---- .../src/backend/HGCalHistoSeedingImpl.cc | 50 ++++++++++--------- .../HGCalConcentratorSuperTriggerCellImpl.cc | 13 ++--- 5 files changed, 58 insertions(+), 44 deletions(-) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h index 26c02c390eeb0..4481d05661a61 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h @@ -38,7 +38,7 @@ class HGCalHistoClusteringImpl{ const std::vector > & seedPositionsEnergy, const HGCalTriggerGeometryBase & triggerGeometry, l1t::HGCalMulticlusterBxCollection & multiclusters - ); + ) const; private: @@ -48,11 +48,11 @@ class HGCalHistoClusteringImpl{ }; std::vector clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector > & seeds); + const std::vector > & seeds) const; void finalizeClusters(std::vector&, l1t::HGCalMulticlusterBxCollection&, - const HGCalTriggerGeometryBase&); + const HGCalTriggerGeometryBase&) const; double dr_; std::vector dr_byLayer_coefficientA_; diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h index 9eec77e92233c..f12504dc447de 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h @@ -30,9 +30,16 @@ class HGCalConcentratorSuperTriggerCellImpl static const int kWafer_offset_ = 6; static const int kSTCsizeCoarse_ = 16; static const int kSTCsizeFine_ = 4; + static const int kSplit_v8_Coarse_ = 0x30; + static const int kSplit_v8_Fine_ = 0x3a; static const int kNLayers_ = 3; static const int kSplit_v9_ = 0x36; + static const int kRocShift_ = 6; + static const int kRotate4_ = 4; + static const int kUShift_ = 3; + + HGCalTriggerTools triggerTools_; HGCSiliconDetIdToROC detIdToROC_; std::vector stcSize_; diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc index 2e7024a7b3f28..b35d2232eec6c 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc @@ -43,18 +43,19 @@ float HGCalHistoClusteringImpl::dR( const l1t::HGCalCluster & clu, std::vector HGCalHistoClusteringImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector > & seeds){ + const std::vector > & seeds) const +{ std::map mapSeedMulticluster; std::vector multiclustersTmp; - for(auto & clu : clustersPtrs){ + for(const auto& clu : clustersPtrs){ int z_side = triggerTools_.zside(clu->detId()); - double radiusCoefficientA = dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment - double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_.at(triggerTools_.layerWithOffset(clu->detId())); // use at() to get the assert, for the moment + double radiusCoefficientA = dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_[triggerTools_.layerWithOffset(clu->detId())]; + double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_[triggerTools_.layerWithOffset(clu->detId())]; double minDist = radiusCoefficientA + radiusCoefficientB*(kMidRadius_ - std::abs(clu->eta()) ) ; @@ -72,7 +73,7 @@ std::vector HGCalHistoClusteringImpl::clusterSeedMulticl if ( cluster_association_strategy_ == EnergySplit ){ targetSeedsEnergy.emplace_back( iseed, seedEnergy ); } - if ( cluster_association_strategy_ == NearestNeighbour ){ + else if ( cluster_association_strategy_ == NearestNeighbour ){ minDist = d; @@ -92,25 +93,27 @@ std::vector HGCalHistoClusteringImpl::clusterSeedMulticl if(targetSeedsEnergy.empty()) continue; //Loop over target seeds and divide up the clusters energy double totalTargetSeedEnergy = 0; - for (auto energy: targetSeedsEnergy){ + for (const auto& energy: targetSeedsEnergy){ totalTargetSeedEnergy+=energy.second; } - for (auto energy: targetSeedsEnergy){ + for (const auto& energy: targetSeedsEnergy){ double seedWeight = 1; if ( cluster_association_strategy_ == EnergySplit) seedWeight = energy.second/totalTargetSeedEnergy; if( mapSeedMulticluster[energy.first].size()==0) { mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight) ; } - mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); + else{ + mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); + } } } - for(auto mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); + for(const auto& mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); return multiclustersTmp; @@ -122,7 +125,7 @@ std::vector HGCalHistoClusteringImpl::clusterSeedMulticl void HGCalHistoClusteringImpl::clusterizeHisto( const std::vector> & clustersPtrs, const std::vector > & seedPositionsEnergy, const HGCalTriggerGeometryBase & triggerGeometry, - l1t::HGCalMulticlusterBxCollection & multiclusters) + l1t::HGCalMulticlusterBxCollection & multiclusters) const { @@ -141,7 +144,8 @@ void HGCalHistoClusteringImpl:: finalizeClusters(std::vector& multiclusters_in, l1t::HGCalMulticlusterBxCollection& multiclusters_out, - const HGCalTriggerGeometryBase& triggerGeometry) { + const HGCalTriggerGeometryBase& triggerGeometry) const +{ for(auto& multicluster : multiclusters_in) { // compute the eta, phi from its barycenter // + pT as scalar sum of pT of constituents diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index d303f9dc8e431..ef36f350fb132 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -185,14 +185,14 @@ std::vector > HGCalHistoSeedingImpl::computeMaxS float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - isMax &= MIPT_seed>=MIPT_S; - isMax &= MIPT_seed>MIPT_N; - isMax &= MIPT_seed>=MIPT_E; - isMax &= MIPT_seed>=MIPT_SE; - isMax &= MIPT_seed>=MIPT_NE; - isMax &= MIPT_seed>MIPT_W; - isMax &= MIPT_seed>MIPT_SW; - isMax &= MIPT_seed>MIPT_NW; + isMax &= MIPT_seed>=MIPT_S + && MIPT_seed>MIPT_N + && MIPT_seed>=MIPT_E + && MIPT_seed>=MIPT_SE + && MIPT_seed>=MIPT_NE + && MIPT_seed>MIPT_W + && MIPT_seed>MIPT_SW + && MIPT_seed>MIPT_NW; if(isMax){ @@ -336,14 +336,14 @@ std::vector > HGCalHistoSeedingImpl::computeSeco float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - isMax &= MIPT_seed>=MIPT_S; - isMax &= MIPT_seed>MIPT_N; - isMax &= MIPT_seed>=MIPT_E; - isMax &= MIPT_seed>=MIPT_SE; - isMax &= MIPT_seed>=MIPT_NE; - isMax &= MIPT_seed>MIPT_W; - isMax &= MIPT_seed>MIPT_SW; - isMax &= MIPT_seed>MIPT_NW; + isMax &= MIPT_seed>=MIPT_S + && MIPT_seed>MIPT_N + && MIPT_seed>=MIPT_E + && MIPT_seed>=MIPT_SE + && MIPT_seed>=MIPT_NE + && MIPT_seed>MIPT_W + && MIPT_seed>MIPT_SW + && MIPT_seed>MIPT_NW; if(isMax){ @@ -408,14 +408,16 @@ std::vector > HGCalHistoSeedingImpl::computeSeco float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - if ( !vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] ) isMax &= MIPT_seed>=MIPT_S; - if ( !vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] ) isMax &= MIPT_seed>MIPT_N; - if ( !vetoPositions[std::make_tuple(bin_R,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_E; - if ( !vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_SE; - if ( !vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] ) isMax &= MIPT_seed>=MIPT_NE; - if ( !vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_W; - if ( !vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_SW; - if ( !vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] ) isMax &= MIPT_seed>MIPT_NW; + isMax &= ( vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] or MIPT_seed>=MIPT_S ) + && ( vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] or MIPT_seed>MIPT_N ) + && ( vetoPositions[std::make_tuple(bin_R,binRight,z_side)] or MIPT_seed>=MIPT_E ) + && ( vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] or MIPT_seed>=MIPT_SE ) + && ( vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] or MIPT_seed>=MIPT_NE ) + && ( vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] or MIPT_seed>MIPT_W ) + && ( vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] or MIPT_seed>MIPT_SW ) + && ( vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] or MIPT_seed>MIPT_NW ); + + if(isMax){ float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; diff --git a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc index f2464e9afce5c..c5f7e107f7225 100644 --- a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc +++ b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc @@ -15,7 +15,8 @@ HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) for(auto stc : stcSize_) { if ( stc!=kSTCsizeFine_ && stc!=kSTCsizeCoarse_ ){ throw cms::Exception("HGCTriggerParameterError") - << "Super Trigger Cell should be of size 4 or 16" ; + << "Super Trigger Cell should be of size "<< + kSTCsizeFine_ << " or " << kSTCsizeCoarse_; } } @@ -23,8 +24,8 @@ HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) std::map HGCalConcentratorSuperTriggerCellImpl::kSplit_ = { - {4, 0x3a}, - {16, 0x30} + {kSTCsizeFine_, kSplit_v8_Fine_}, + {kSTCsizeCoarse_, kSplit_v8_Coarse_} }; int @@ -80,12 +81,12 @@ HGCalConcentratorSuperTriggerCellImpl::getSuperTriggerCellId(int detid) const { } else if ( rocnum == 3 ){ - Uprime = TC_idV9.triggerCellU()-4; - Vprime = TC_idV9.triggerCellV()-4; + Uprime = TC_idV9.triggerCellU()-kRotate4_; + Vprime = TC_idV9.triggerCellV()-kRotate4_; } - TC_12th = (rocnum << 6) | ( (Uprime << 3 | Vprime) & kSplit_v9_ ); + TC_12th = (rocnum << kRocShift_) | ( (Uprime << kUShift_ | Vprime) & kSplit_v9_ ); int TC_split = TC_12th; if (stcSize_.at(thickness) == kSTCsizeCoarse_){ From f318255ee3e10a84200227045a1c289e1f806266 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 2 Apr 2019 08:45:38 -0500 Subject: [PATCH 401/686] Added missing include of vector --- .../SiStripRawToDigi/interface/SiStripFEDBufferComponents.h | 1 + 1 file changed, 1 insertion(+) diff --git a/EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferComponents.h b/EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferComponents.h index 3929841cf59fc..53b7d8b3167dd 100644 --- a/EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferComponents.h +++ b/EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferComponents.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h" #include "FWCore/Utilities/interface/Exception.h" From 63025b44b061fb6557589c202aef82bc05bf7c6b Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 2 Apr 2019 15:48:12 +0200 Subject: [PATCH 402/686] Also compute the ToT if no calibration function is present --- .../src/CTPPSDiamondRecHitProducerAlgorithm.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 49d7ee2147763..b851b6e5dedd9 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -63,12 +63,15 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; double tot = -1., t_mean = 0.; - if ( calib_fct_ && t_lead != 0 && t_trail != 0 ) { + if ( t_lead != 0 && t_trail != 0 ) { tot = ( t_trail-t_lead )*ts_to_ns_; - t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); - if ( std::isnan( t_mean ) ) - t_mean = 0.; + if ( calib_fct_ ) { + t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); + if ( std::isnan( t_mean ) ) + t_mean = 0.; + } } + // calibrated time of arrival const double t0 = ( t_lead % 1024 )*ts_to_ns_+ ch_t_offset-t_mean; rec_hits.emplace_back( From b8941792ddbb246e5b88b1fbb9ae1f57f8c4c8fc Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Tue, 2 Apr 2019 15:01:27 +0200 Subject: [PATCH 403/686] Applying new material for PCB with correct density --- Validation/Geometry/data/hgcalMaterials.l0 | 4 +- Validation/Geometry/data/hgcalMaterials.x0 | 4 +- .../Geometry/interface/MaterialBudgetData.h | 36 +++---- .../Geometry/python/plot_hgcal_utils.py | 6 +- .../Geometry/src/MaterialBudgetCategorizer.cc | 10 +- Validation/Geometry/src/MaterialBudgetData.cc | 26 ++--- .../Geometry/src/MaterialBudgetHGCalHistos.cc | 100 +++++++++--------- 7 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Validation/Geometry/data/hgcalMaterials.l0 b/Validation/Geometry/data/hgcalMaterials.l0 index ec289c418f4b5..7dea3e186f367 100644 --- a/Validation/Geometry/data/hgcalMaterials.l0 +++ b/Validation/Geometry/data/hgcalMaterials.l0 @@ -1,4 +1,4 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-M_NEMA_FR4_plate-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 @@ -6,7 +6,7 @@ Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -M_NEMA*FR4*plate 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/data/hgcalMaterials.x0 b/Validation/Geometry/data/hgcalMaterials.x0 index ec289c418f4b5..ab0995ffe777c 100644 --- a/Validation/Geometry/data/hgcalMaterials.x0 +++ b/Validation/Geometry/data/hgcalMaterials.x0 @@ -1,4 +1,4 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-M_NEMA_FR4_plate-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 @@ -6,7 +6,7 @@ Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -M_NEMA*FR4*plate 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/interface/MaterialBudgetData.h b/Validation/Geometry/interface/MaterialBudgetData.h index e78e10ca42872..9b94b87505bd9 100644 --- a/Validation/Geometry/interface/MaterialBudgetData.h +++ b/Validation/Geometry/interface/MaterialBudgetData.h @@ -56,8 +56,8 @@ class MaterialBudgetData { return theH_ScintillatorFractionMB; } float getLeadFractionMB() const { return theLeadFractionMB; } - float getM_NEMA_FR4_plateFractionMB() const { - return theM_NEMA_FR4_plateFractionMB; } + float getHGC_G10_FR4FractionMB() const { + return theHGC_G10_FR4FractionMB; } float getSiliconFractionMB() const { return theSiliconFractionMB; } float getStainlessSteelFractionMB() const { @@ -86,8 +86,8 @@ class MaterialBudgetData { return theH_ScintillatorMB; } float getLeadMB() const { return theLeadMB; } - float getM_NEMA_FR4_plateMB() const { - return theM_NEMA_FR4_plateMB; } + float getHGC_G10_FR4MB() const { + return theHGC_G10_FR4MB; } float getSiliconMB() const { return theSiliconMB; } float getStainlessSteelMB() const { @@ -115,8 +115,8 @@ class MaterialBudgetData { return theH_ScintillatorFractionIL; } float getLeadFractionIL() const { return theLeadFractionIL; } - float getM_NEMA_FR4_plateFractionIL() const { - return theM_NEMA_FR4_plateFractionIL; } + float getHGC_G10_FR4FractionIL() const { + return theHGC_G10_FR4FractionIL; } float getSiliconFractionIL() const { return theSiliconFractionIL; } float getStainlessSteelFractionIL() const { @@ -145,8 +145,8 @@ class MaterialBudgetData { return theH_ScintillatorIL; } float getLeadIL() const { return theLeadIL; } - float getM_NEMA_FR4_plateIL() const { - return theM_NEMA_FR4_plateIL; } + float getHGC_G10_FR4IL() const { + return theHGC_G10_FR4IL; } float getSiliconIL() const { return theSiliconIL; } float getStainlessSteelIL() const { @@ -207,8 +207,8 @@ class MaterialBudgetData { return theH_ScintillatorDmb[is]; } float getLeadDmb( int is ) const { return theLeadDmb[is]; } - float getM_NEMA_FR4_plateDmb( int is ) const { - return theM_NEMA_FR4_plateDmb[is]; } + float getHGC_G10_FR4Dmb( int is ) const { + return theHGC_G10_FR4Dmb[is]; } float getSiliconDmb( int is ) const { return theSiliconDmb[is]; } float getStainlessSteelDmb( int is ) const { @@ -240,8 +240,8 @@ class MaterialBudgetData { return theH_ScintillatorDil[is]; } float getLeadDil( int is ) const { return theLeadDil[is]; } - float getM_NEMA_FR4_plateDil( int is ) const { - return theM_NEMA_FR4_plateDil[is]; } + float getHGC_G10_FR4Dil( int is ) const { + return theHGC_G10_FR4Dil[is]; } float getSiliconDil( int is ) const { return theSiliconDil[is]; } float getStainlessSteelDil( int is ) const { @@ -425,14 +425,14 @@ class MaterialBudgetData { float theCopperFractionMB; float theH_ScintillatorFractionMB; float theLeadFractionMB; - float theM_NEMA_FR4_plateFractionMB; + float theHGC_G10_FR4FractionMB; float theSiliconFractionMB; float theStainlessSteelFractionMB; float theWCuFractionMB; float theCopperMB; float theH_ScintillatorMB; float theLeadMB; - float theM_NEMA_FR4_plateMB; + float theHGC_G10_FR4MB; float theSiliconMB; float theStainlessSteelMB; float theWCuMB; @@ -449,14 +449,14 @@ class MaterialBudgetData { float theCopperFractionIL; float theH_ScintillatorFractionIL; float theLeadFractionIL; - float theM_NEMA_FR4_plateFractionIL; + float theHGC_G10_FR4FractionIL; float theSiliconFractionIL; float theStainlessSteelFractionIL; float theWCuFractionIL; float theCopperIL; float theH_ScintillatorIL; float theLeadIL; - float theM_NEMA_FR4_plateIL; + float theHGC_G10_FR4IL; float theSiliconIL; float theStainlessSteelIL; float theWCuIL; @@ -481,7 +481,7 @@ class MaterialBudgetData { std::array theCopperDmb; std::array theH_ScintillatorDmb; std::array theLeadDmb; - std::array theM_NEMA_FR4_plateDmb; + std::array theHGC_G10_FR4Dmb; std::array theSiliconDmb; std::array theStainlessSteelDmb; std::array theWCuDmb; @@ -497,7 +497,7 @@ class MaterialBudgetData { std::array theCopperDil; std::array theH_ScintillatorDil; std::array theLeadDil; - std::array theM_NEMA_FR4_plateDil; + std::array theHGC_G10_FR4Dil; std::array theSiliconDil; std::array theStainlessSteelDil; std::array theWCuDil; diff --git a/Validation/Geometry/python/plot_hgcal_utils.py b/Validation/Geometry/python/plot_hgcal_utils.py index fa9f92a94670f..5c34a1e14f95c 100644 --- a/Validation/Geometry/python/plot_hgcal_utils.py +++ b/Validation/Geometry/python/plot_hgcal_utils.py @@ -84,7 +84,7 @@ hist_label_to_num['COP'] = [100, 2, 'Copper'] # Index first, color second, legend label third hist_label_to_num['SCI'] = [200, 3, 'Scintillator'] hist_label_to_num['CAB'] = [300, 4, 'Cables'] -hist_label_to_num['MNE'] = [400, 5, 'M_NEMA_FR4 plate'] +hist_label_to_num['MNE'] = [400, 5, 'HGC_G10-FR4'] hist_label_to_num['SIL'] = [500, 6, 'Silicon'] hist_label_to_num['OTH'] = [600, 7, 'Other'] hist_label_to_num['AIR'] = [700, 8, 'Air'] @@ -199,7 +199,7 @@ def acustompalette(): dEdx['H_Scintillator'] = 0.91512109*dEdx['C'] + 0.084878906*dEdx['H'] dEdx['Silicon'] = 0.3876 #http://cmslxr.fnal.gov/source/Geometry/CMSCommonData/data/materials.xml#2730 -dEdx['M_NEMA_FR4_plate'] = 0.18077359*dEdx['Silicon'] + 0.4056325*dEdx['0'] + 0.27804208*dEdx['C'] + 0.068442752*dEdx['H'] + 0.067109079*dEdx['Br'] +dEdx['HGC_G10-FR4'] = 0.18077359*dEdx['Silicon'] + 0.4056325*dEdx['0'] + 0.27804208*dEdx['C'] + 0.068442752*dEdx['H'] + 0.067109079*dEdx['Br'] dEdx['Other'] = 0. #http://cmslxr.fnal.gov/source/Geometry/CMSCommonData/data/materials.xml#0290 dEdx['Air'] = 0. @@ -218,7 +218,7 @@ def acustompalette(): MatXo['Copper'] = 14.3559 MatXo['H_Scintillator'] = 425.393 MatXo['Cables'] = 66.722 -MatXo['M_NEMA_FR4_plate'] = 175.056 +MatXo['HGC_G10-FR4'] = 175.056 MatXo['Silicon'] = 93.6762 MatXo['Other'] = 0. MatXo['Air'] = 301522. diff --git a/Validation/Geometry/src/MaterialBudgetCategorizer.cc b/Validation/Geometry/src/MaterialBudgetCategorizer.cc index bbadc21dbb19c..583a45b68b6bb 100644 --- a/Validation/Geometry/src/MaterialBudgetCategorizer.cc +++ b/Validation/Geometry/src/MaterialBudgetCategorizer.cc @@ -88,13 +88,13 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil cms::Exception("LogicError") <<" File not found " << theMaterialFileName; // fill everything as "other" - float Air,Cables,Copper,H_Scintillator,Lead,M_NEMA_FR4_plate,Silicon,StainlessSteel,WCu, oth; - Air=Cables=Copper=H_Scintillator=Lead=M_NEMA_FR4_plate=Silicon=StainlessSteel=WCu=0.; + float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu, oth; + Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=0.; std::string materialName; while(theMaterialFile) { theMaterialFile >> materialName; - theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> M_NEMA_FR4_plate >> Silicon >> StainlessSteel >> WCu; + theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu; // Skip comments if (materialName[0] == '#') continue; @@ -107,7 +107,7 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil theMap[materialName].push_back(Copper ); // Copper theMap[materialName].push_back(H_Scintillator ); // H_Scintillator theMap[materialName].push_back(Lead ); // Lead - theMap[materialName].push_back(M_NEMA_FR4_plate); // M_NEMA_FR4_plate + theMap[materialName].push_back(HGC_G10_FR4); // HGC_G10_FR4 theMap[materialName].push_back(Silicon ); // Silicon theMap[materialName].push_back(StainlessSteel ); // StainlessSteel theMap[materialName].push_back(WCu ); // WCu @@ -120,7 +120,7 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil << "\tCopper " << Copper << std::endl << "\tH_Scintillator " << H_Scintillator << std::endl << "\tLead " << Lead << std::endl - << "\tM_NEMA_FR4_plate " << M_NEMA_FR4_plate << std::endl + << "\tHGC_G10_FR4 " << HGC_G10_FR4 << std::endl << "\tSilicon " << Silicon << std::endl << "\tStainlessSteel " << StainlessSteel << std::endl << "\tWCu " << WCu << std::endl diff --git a/Validation/Geometry/src/MaterialBudgetData.cc b/Validation/Geometry/src/MaterialBudgetData.cc index 6cd73cf3b7453..39ec433f46c13 100644 --- a/Validation/Geometry/src/MaterialBudgetData.cc +++ b/Validation/Geometry/src/MaterialBudgetData.cc @@ -57,7 +57,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperMB = 0.f; theH_ScintillatorMB = 0.f; theLeadMB = 0.f; - theM_NEMA_FR4_plateMB = 0.f; + theHGC_G10_FR4MB = 0.f; theSiliconMB = 0.f; theStainlessSteelMB = 0.f; theWCuMB = 0.f; @@ -74,7 +74,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperIL = 0.f; theH_ScintillatorIL = 0.f; theLeadIL = 0.f; - theM_NEMA_FR4_plateIL = 0.f; + theHGC_G10_FR4IL = 0.f; theSiliconIL = 0.f; theStainlessSteelIL = 0.f; theWCuIL = 0.f; @@ -90,7 +90,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperFractionMB = 0.f; theH_ScintillatorFractionMB = 0.f; theLeadFractionMB = 0.f; - theM_NEMA_FR4_plateFractionMB = 0.f; + theHGC_G10_FR4FractionMB = 0.f; theSiliconFractionMB = 0.f; theStainlessSteelFractionMB = 0.f; theWCuFractionMB = 0.f; @@ -106,7 +106,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperFractionIL = 0.f; theH_ScintillatorFractionIL = 0.f; theLeadFractionIL = 0.f; - theM_NEMA_FR4_plateFractionIL = 0.f; + theHGC_G10_FR4FractionIL = 0.f; theSiliconFractionIL = 0.f; theStainlessSteelFractionIL = 0.f; theWCuFractionIL = 0.f; @@ -159,8 +159,8 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " Eta " << theEta << " Phi " << thePhi << " TotaLMB" << theTotalMB << " theCopperMB " << theCopperMB << " theH_ScintillatorMB " << theH_ScintillatorMB - << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theM_NEMA_FR4_plateMB " - << theM_NEMA_FR4_plateMB << " theSiliconMB " << theSiliconMB + << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theHGC_G10_FR4MB " + << theHGC_G10_FR4MB << " theSiliconMB " << theSiliconMB << " theAirMB " << theAirMB << " theStainlessSteelMB " << theStainlessSteelMB << " theWCuMB " << theWCuMB; @@ -170,7 +170,7 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " TotalIL " << theTotalIL << " theCopperIL " << theCopperIL << " theH_ScintillatorIL " << theH_ScintillatorIL << " CAB " << theCablesIL << " theLeadIL " << theLeadIL - << " theM_NEMA_FR4_plateIL " << theM_NEMA_FR4_plateIL + << " theHGC_G10_FR4IL " << theHGC_G10_FR4IL << " theSiliconIL " << theSiliconIL << " Air " << theAirIL << " theStainlessSteelIL " << theStainlessSteelIL << " theWCuIL " << theWCuIL << std::endl; @@ -283,7 +283,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[2]; theH_ScintillatorFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[3]; theLeadFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[4]; - theM_NEMA_FR4_plateFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[5]; + theHGC_G10_FR4FractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[5]; theSiliconFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[6]; theStainlessSteelFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[7]; theWCuFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[8]; @@ -299,7 +299,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[2]; theH_ScintillatorFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[3]; theLeadFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[4]; - theM_NEMA_FR4_plateFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[5]; + theHGC_G10_FR4FractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[5]; theSiliconFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[6]; theStainlessSteelFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[7]; theWCuFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[8]; @@ -348,7 +348,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperDmb[theStepN] = (dmb * theCopperFractionMB); theH_ScintillatorDmb[theStepN] = (dmb * theH_ScintillatorFractionMB); theLeadDmb[theStepN] = (dmb * theLeadFractionMB); - theM_NEMA_FR4_plateDmb[theStepN] = (dmb * theM_NEMA_FR4_plateFractionMB); + theHGC_G10_FR4Dmb[theStepN] = (dmb * theHGC_G10_FR4FractionMB); theSiliconDmb[theStepN] = (dmb * theSiliconFractionMB); theStainlessSteelDmb[theStepN] = (dmb * theStainlessSteelFractionMB); theWCuDmb[theStepN] = (dmb * theWCuFractionMB); @@ -364,7 +364,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperDil[theStepN] = (dil * theCopperFractionIL); theH_ScintillatorDil[theStepN] = (dil * theH_ScintillatorFractionIL); theLeadDil[theStepN] = (dil * theLeadFractionIL); - theM_NEMA_FR4_plateDil[theStepN] = (dil * theM_NEMA_FR4_plateFractionIL); + theHGC_G10_FR4Dil[theStepN] = (dil * theHGC_G10_FR4FractionIL); theSiliconDil[theStepN] = (dil * theSiliconFractionIL); theStainlessSteelDil[theStepN] = (dil * theStainlessSteelFractionIL); theWCuDil[theStepN] = (dil * theWCuFractionIL); @@ -546,7 +546,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperMB += (dmb * theCopperFractionMB); theH_ScintillatorMB += (dmb * theH_ScintillatorFractionMB); theLeadMB += (dmb * theLeadFractionMB); - theM_NEMA_FR4_plateMB += (dmb * theM_NEMA_FR4_plateFractionMB); + theHGC_G10_FR4MB += (dmb * theHGC_G10_FR4FractionMB); theSiliconMB += (dmb * theSiliconFractionMB); theStainlessSteelMB += (dmb * theStainlessSteelFractionMB); theWCuMB += (dmb * theWCuFractionMB); @@ -562,7 +562,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperIL += (dil * theCopperFractionIL); theH_ScintillatorIL += (dil * theH_ScintillatorFractionIL); theLeadIL += (dil * theLeadFractionIL); - theM_NEMA_FR4_plateIL += (dil * theM_NEMA_FR4_plateFractionIL); + theHGC_G10_FR4IL += (dil * theHGC_G10_FR4FractionIL); theSiliconIL += (dil * theSiliconFractionIL); theStainlessSteelIL += (dil * theStainlessSteelFractionIL); theWCuIL += (dil * theWCuFractionIL); diff --git a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc index fc6903b3856ba..004713992fca0 100644 --- a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc +++ b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc @@ -82,16 +82,16 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("370", "MB prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("372", "MB ortho prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - // M_NEMA_FR4_plate - hmgr->addHistoProf1( new TProfile("410", "MB prof Eta [M_NEMA_FR4_plate];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("420", "MB prof Phi [M_NEMA_FR4_plate];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("430", "MB prof Eta Phi [M_NEMA_FR4_plate];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("440", "MB prof R [M_NEMA_FR4_plate];R [mm];x/X_{0}", 300, 0., 3000. ) ); - hmgr->addHistoProf2( new TProfile2D("450", "MB prof sum R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("452", "MB ortho prof sum R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHisto2( new TH2F("460", "MB prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("470", "MB prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("472", "MB ortho prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // HGC_G10_FR4 + hmgr->addHistoProf1( new TProfile("410", "MB prof Eta [HGC_G10_FR4];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("420", "MB prof Phi [HGC_G10_FR4];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("430", "MB prof Eta Phi [HGC_G10_FR4];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("440", "MB prof R [HGC_G10_FR4];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("450", "MB prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("452", "MB ortho prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("460", "MB prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("470", "MB prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("472", "MB ortho prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Silicon hmgr->addHistoProf1( new TProfile("510", "MB prof Eta [Silicon];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); @@ -207,16 +207,16 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10370", "IL prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10372", "IL ortho prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - // M_NEMA_FR4_plate - hmgr->addHistoProf1( new TProfile("10410", "IL prof Eta [M_NEMA_FR4_plate];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10420", "IL prof Phi [M_NEMA_FR4_plate];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10430", "IL prof Eta Phi [M_NEMA_FR4_plate];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10440", "IL prof R [M_NEMA_FR4_plate];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); - hmgr->addHistoProf2( new TProfile2D("10450", "IL prof sum R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("10452", "IL ortho prof sum R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHisto2( new TH2F("10460", "IL prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("10470", "IL prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); - hmgr->addHistoProf2( new TProfile2D("10472", "IL ortho prof local R z [M_NEMA_FR4_plate];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // HGC_G10_FR4 + hmgr->addHistoProf1( new TProfile("10410", "IL prof Eta [HGC_G10_FR4];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("10420", "IL prof Phi [HGC_G10_FR4];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("10430", "IL prof Eta Phi [HGC_G10_FR4];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("10440", "IL prof R [HGC_G10_FR4];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("10450", "IL prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("10452", "IL ortho prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("10460", "IL prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("10470", "IL prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("10472", "IL ortho prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Silicon hmgr->addHistoProf1( new TProfile("10510", "IL prof Eta [Silicon];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); @@ -336,10 +336,10 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(320)->Fill(theData->getPhi(),theData->getCablesMB()); hmgr->getHistoProf2(330)->Fill(theData->getEta(),theData->getPhi(),theData->getCablesMB()); - // M_NEMA_FR4_plate - hmgr->getHistoProf1(410)->Fill(theData->getEta(),theData->getM_NEMA_FR4_plateMB()); - hmgr->getHistoProf1(420)->Fill(theData->getPhi(),theData->getM_NEMA_FR4_plateMB()); - hmgr->getHistoProf2(430)->Fill(theData->getEta(),theData->getPhi(),theData->getM_NEMA_FR4_plateMB()); + // HGC_G10_FR4 + hmgr->getHistoProf1(410)->Fill(theData->getEta(),theData->getHGC_G10_FR4MB()); + hmgr->getHistoProf1(420)->Fill(theData->getPhi(),theData->getHGC_G10_FR4MB()); + hmgr->getHistoProf2(430)->Fill(theData->getEta(),theData->getPhi(),theData->getHGC_G10_FR4MB()); // Silicon hmgr->getHistoProf1(510)->Fill(theData->getEta(),theData->getSiliconMB()); @@ -379,7 +379,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalMB_COP = 0.0; float theTotalMB_SCI = 0.0; float theTotalMB_CAB = 0.0; - float theTotalMB_MNE = 0.0; + float theTotalMB_HGF = 0.0; float theTotalMB_NIM = 0.0; float theTotalMB_OTH = 0.0; float theTotalMB_AIR = 0.0; @@ -391,7 +391,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalMB_COP += theData->getCopperDmb(iStep); theTotalMB_SCI += theData->getH_ScintillatorDmb(iStep); theTotalMB_CAB += theData->getCablesDmb(iStep); - theTotalMB_MNE += theData->getM_NEMA_FR4_plateDmb(iStep); + theTotalMB_HGF += theData->getHGC_G10_FR4Dmb(iStep); theTotalMB_NIM += theData->getSiliconDmb(iStep); theTotalMB_OTH += theData->getOtherDmb(iStep); theTotalMB_AIR += theData->getAirDmb(iStep); @@ -402,7 +402,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iCop = 0; int iSci = 0; int iCab = 0; - int iMne = 0; + int iHgf = 0; int iSil = 0; int iOth = 0; int iAir = 0; @@ -412,7 +412,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getCopperDmb(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDmb(iStep)>0. ) { iSci = 1; } if( theData->getCablesDmb(iStep)>0. ) { iCab = 1; } - if( theData->getM_NEMA_FR4_plateDmb(iStep)>0. ) { iMne = 1; } + if( theData->getHGC_G10_FR4Dmb(iStep)>0. ) { iHgf = 1; } if( theData->getSiliconDmb(iStep)>0. ) { iSil = 1; } if( theData->getOtherDmb(iStep)>0. ) { iOth = 1; } if( theData->getAirDmb(iStep)>0. ) { iAir = 1; } @@ -503,13 +503,13 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(370)->Fill(z,polarRadius,iCab*fillValue); hmgr->getHistoProf2(372)->Fill(z,polarRadius, iCab * fillValue * costhetacorrection ); - // M_NEMA_FR4_plate - hmgr->getHistoProf1(440)->Fill(polarRadius,theTotalMB_MNE); - hmgr->getHistoProf2(450)->Fill(z,polarRadius,theTotalMB_MNE); - hmgr->getHistoProf2(452)->Fill(z,polarRadius,theTotalMB_MNE * costhetacorrection ); - hmgr->getHisto2(460)->Fill(z,polarRadius,iMne*fillValue); - hmgr->getHistoProf2(470)->Fill(z,polarRadius,iMne*fillValue); - hmgr->getHistoProf2(472)->Fill(z,polarRadius, iMne * fillValue * costhetacorrection ); + // HGC_G10_FR4 + hmgr->getHistoProf1(440)->Fill(polarRadius,theTotalMB_HGF); + hmgr->getHistoProf2(450)->Fill(z,polarRadius,theTotalMB_HGF); + hmgr->getHistoProf2(452)->Fill(z,polarRadius,theTotalMB_HGF * costhetacorrection ); + hmgr->getHisto2(460)->Fill(z,polarRadius,iHgf*fillValue); + hmgr->getHistoProf2(470)->Fill(z,polarRadius,iHgf*fillValue); + hmgr->getHistoProf2(472)->Fill(z,polarRadius, iHgf * fillValue * costhetacorrection ); // Silicon hmgr->getHistoProf1(540)->Fill(polarRadius,theTotalMB_NIM); @@ -583,10 +583,10 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(10320)->Fill(theData->getPhi(),theData->getCablesIL()); hmgr->getHistoProf2(10330)->Fill(theData->getEta(),theData->getPhi(),theData->getCablesIL()); - // M_NEMA_FR4_plate - hmgr->getHistoProf1(10410)->Fill(theData->getEta(),theData->getM_NEMA_FR4_plateIL()); - hmgr->getHistoProf1(10420)->Fill(theData->getPhi(),theData->getM_NEMA_FR4_plateIL()); - hmgr->getHistoProf2(10430)->Fill(theData->getEta(),theData->getPhi(),theData->getM_NEMA_FR4_plateIL()); + // HGC_G10_FR4 + hmgr->getHistoProf1(10410)->Fill(theData->getEta(),theData->getHGC_G10_FR4IL()); + hmgr->getHistoProf1(10420)->Fill(theData->getPhi(),theData->getHGC_G10_FR4IL()); + hmgr->getHistoProf2(10430)->Fill(theData->getEta(),theData->getPhi(),theData->getHGC_G10_FR4IL()); // Silicon hmgr->getHistoProf1(10510)->Fill(theData->getEta(),theData->getSiliconIL()); @@ -623,7 +623,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalIL_COP = 0.0; float theTotalIL_SCI = 0.0; float theTotalIL_CAB = 0.0; - float theTotalIL_MNE = 0.0; + float theTotalIL_HGF = 0.0; float theTotalIL_NIM = 0.0; float theTotalIL_OTH = 0.0; float theTotalIL_AIR = 0.0; @@ -635,7 +635,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalIL_COP += theData->getCopperDil(iStep); theTotalIL_SCI += theData->getH_ScintillatorDil(iStep); theTotalIL_CAB += theData->getCablesDil(iStep); - theTotalIL_MNE += theData->getM_NEMA_FR4_plateDil(iStep); + theTotalIL_HGF += theData->getHGC_G10_FR4Dil(iStep); theTotalIL_NIM += theData->getSiliconDil(iStep); theTotalIL_OTH += theData->getOtherDil(iStep); theTotalIL_AIR += theData->getAirDil(iStep); @@ -646,7 +646,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iCop = 0; int iSci = 0; int iCab = 0; - int iMne = 0; + int iHgf = 0; int iSil = 0; int iOth = 0; int iAir = 0; @@ -657,7 +657,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getCopperDil(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDil(iStep)>0. ) { iSci = 1; } if( theData->getCablesDil(iStep)>0. ) { iCab = 1; } - if( theData->getM_NEMA_FR4_plateDil(iStep)>0. ) { iMne = 1; } + if( theData->getHGC_G10_FR4Dil(iStep)>0. ) { iHgf = 1; } if( theData->getSiliconDil(iStep)>0. ) { iSil = 1; } if( theData->getOtherDil(iStep)>0. ) { iOth = 1; } if( theData->getAirDil(iStep)>0. ) { iAir = 1; } @@ -746,13 +746,13 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(10370)->Fill(z,polarRadius,iCab*fillValue); hmgr->getHistoProf2(10372)->Fill(z,polarRadius, iCab * fillValue * costhetacorrection ); - // M_NEMA_FR4_plate - hmgr->getHistoProf1(10440)->Fill(polarRadius,theTotalIL_MNE); - hmgr->getHistoProf2(10450)->Fill(z,polarRadius,theTotalIL_MNE); - hmgr->getHistoProf2(10452)->Fill(z,polarRadius,theTotalIL_MNE * costhetacorrection ); - hmgr->getHisto2(10460)->Fill(z,polarRadius,iMne*fillValue); - hmgr->getHistoProf2(10470)->Fill(z,polarRadius,iMne*fillValue); - hmgr->getHistoProf2(10472)->Fill(z,polarRadius, iMne * fillValue * costhetacorrection ); + // HGC_G10_FR4 + hmgr->getHistoProf1(10440)->Fill(polarRadius,theTotalIL_HGF); + hmgr->getHistoProf2(10450)->Fill(z,polarRadius,theTotalIL_HGF); + hmgr->getHistoProf2(10452)->Fill(z,polarRadius,theTotalIL_HGF * costhetacorrection ); + hmgr->getHisto2(10460)->Fill(z,polarRadius,iHgf*fillValue); + hmgr->getHistoProf2(10470)->Fill(z,polarRadius,iHgf*fillValue); + hmgr->getHistoProf2(10472)->Fill(z,polarRadius, iHgf * fillValue * costhetacorrection ); // Silicon hmgr->getHistoProf1(10540)->Fill(polarRadius,theTotalIL_NIM); From cd08fa875360af8c0a41d26412dbb8d02b6edcdb Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Tue, 2 Apr 2019 16:44:18 +0200 Subject: [PATCH 404/686] New materials in V10, Epoxy and Kapton --- Validation/Geometry/data/hgcalMaterials.l0 | 26 ++-- Validation/Geometry/data/hgcalMaterials.x0 | 26 ++-- .../Geometry/interface/MaterialBudgetData.h | 36 ++++++ .../Geometry/python/plot_hgcal_utils.py | 7 ++ .../Geometry/src/MaterialBudgetCategorizer.cc | 10 +- Validation/Geometry/src/MaterialBudgetData.cc | 26 +++- .../Geometry/src/MaterialBudgetHGCalHistos.cc | 116 ++++++++++++++++++ 7 files changed, 217 insertions(+), 30 deletions(-) diff --git a/Validation/Geometry/data/hgcalMaterials.l0 b/Validation/Geometry/data/hgcalMaterials.l0 index 7dea3e186f367..0322ed590e853 100644 --- a/Validation/Geometry/data/hgcalMaterials.l0 +++ b/Validation/Geometry/data/hgcalMaterials.l0 @@ -1,15 +1,17 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 - - -Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 -H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 -Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 -Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 -StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 -WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton 0 0 0 0 0 0 0 0 0 0 0 + + +Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 +Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 +StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 +Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 +Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/data/hgcalMaterials.x0 b/Validation/Geometry/data/hgcalMaterials.x0 index ab0995ffe777c..4fc0f8df489aa 100644 --- a/Validation/Geometry/data/hgcalMaterials.x0 +++ b/Validation/Geometry/data/hgcalMaterials.x0 @@ -1,15 +1,17 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu 0 0 0 0 0 0 0 0 0 - - -Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 -H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 -Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 -Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 -StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 -WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton 0 0 0 0 0 0 0 0 0 0 0 + + +Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 +Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 +StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 +Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 +Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/interface/MaterialBudgetData.h b/Validation/Geometry/interface/MaterialBudgetData.h index 9b94b87505bd9..934bafc0eabdc 100644 --- a/Validation/Geometry/interface/MaterialBudgetData.h +++ b/Validation/Geometry/interface/MaterialBudgetData.h @@ -56,6 +56,10 @@ class MaterialBudgetData { return theH_ScintillatorFractionMB; } float getLeadFractionMB() const { return theLeadFractionMB; } + float getEpoxyFractionMB() const { + return theEpoxyFractionMB; } + float getKaptonFractionMB() const { + return theKaptonFractionMB; } float getHGC_G10_FR4FractionMB() const { return theHGC_G10_FR4FractionMB; } float getSiliconFractionMB() const { @@ -86,6 +90,10 @@ class MaterialBudgetData { return theH_ScintillatorMB; } float getLeadMB() const { return theLeadMB; } + float getEpoxyMB() const { + return theEpoxyMB; } + float getKaptonMB() const { + return theKaptonMB; } float getHGC_G10_FR4MB() const { return theHGC_G10_FR4MB; } float getSiliconMB() const { @@ -115,6 +123,10 @@ class MaterialBudgetData { return theH_ScintillatorFractionIL; } float getLeadFractionIL() const { return theLeadFractionIL; } + float getEpoxyFractionIL() const { + return theEpoxyFractionIL; } + float getKaptonFractionIL() const { + return theKaptonFractionIL; } float getHGC_G10_FR4FractionIL() const { return theHGC_G10_FR4FractionIL; } float getSiliconFractionIL() const { @@ -145,6 +157,10 @@ class MaterialBudgetData { return theH_ScintillatorIL; } float getLeadIL() const { return theLeadIL; } + float getEpoxyIL() const { + return theEpoxyIL; } + float getKaptonIL() const { + return theKaptonIL; } float getHGC_G10_FR4IL() const { return theHGC_G10_FR4IL; } float getSiliconIL() const { @@ -207,6 +223,10 @@ class MaterialBudgetData { return theH_ScintillatorDmb[is]; } float getLeadDmb( int is ) const { return theLeadDmb[is]; } + float getEpoxyDmb( int is ) const { + return theEpoxyDmb[is]; } + float getKaptonDmb( int is ) const { + return theKaptonDmb[is]; } float getHGC_G10_FR4Dmb( int is ) const { return theHGC_G10_FR4Dmb[is]; } float getSiliconDmb( int is ) const { @@ -240,6 +260,10 @@ class MaterialBudgetData { return theH_ScintillatorDil[is]; } float getLeadDil( int is ) const { return theLeadDil[is]; } + float getEpoxyDil( int is ) const { + return theEpoxyDil[is]; } + float getKaptonDil( int is ) const { + return theKaptonDil[is]; } float getHGC_G10_FR4Dil( int is ) const { return theHGC_G10_FR4Dil[is]; } float getSiliconDil( int is ) const { @@ -425,6 +449,8 @@ class MaterialBudgetData { float theCopperFractionMB; float theH_ScintillatorFractionMB; float theLeadFractionMB; + float theEpoxyFractionMB; + float theKaptonFractionMB; float theHGC_G10_FR4FractionMB; float theSiliconFractionMB; float theStainlessSteelFractionMB; @@ -432,6 +458,8 @@ class MaterialBudgetData { float theCopperMB; float theH_ScintillatorMB; float theLeadMB; + float theEpoxyMB; + float theKaptonMB; float theHGC_G10_FR4MB; float theSiliconMB; float theStainlessSteelMB; @@ -449,6 +477,8 @@ class MaterialBudgetData { float theCopperFractionIL; float theH_ScintillatorFractionIL; float theLeadFractionIL; + float theEpoxyFractionIL; + float theKaptonFractionIL; float theHGC_G10_FR4FractionIL; float theSiliconFractionIL; float theStainlessSteelFractionIL; @@ -456,6 +486,8 @@ class MaterialBudgetData { float theCopperIL; float theH_ScintillatorIL; float theLeadIL; + float theEpoxyIL; + float theKaptonIL; float theHGC_G10_FR4IL; float theSiliconIL; float theStainlessSteelIL; @@ -481,6 +513,8 @@ class MaterialBudgetData { std::array theCopperDmb; std::array theH_ScintillatorDmb; std::array theLeadDmb; + std::array theEpoxyDmb; + std::array theKaptonDmb; std::array theHGC_G10_FR4Dmb; std::array theSiliconDmb; std::array theStainlessSteelDmb; @@ -497,6 +531,8 @@ class MaterialBudgetData { std::array theCopperDil; std::array theH_ScintillatorDil; std::array theLeadDil; + std::array theEpoxyDil; + std::array theKaptonDil; std::array theHGC_G10_FR4Dil; std::array theSiliconDil; std::array theStainlessSteelDil; diff --git a/Validation/Geometry/python/plot_hgcal_utils.py b/Validation/Geometry/python/plot_hgcal_utils.py index 5c34a1e14f95c..29546d7d58694 100644 --- a/Validation/Geometry/python/plot_hgcal_utils.py +++ b/Validation/Geometry/python/plot_hgcal_utils.py @@ -91,6 +91,8 @@ hist_label_to_num['SST'] = [800, 9, 'Stainless Steel'] hist_label_to_num['WCU'] = [900, 28, 'WCu'] hist_label_to_num['LEA'] = [1000, 12, 'Lead'] +hist_label_to_num['EPX'] = [1100, 46, 'Epoxy'] +hist_label_to_num['KAP'] = [1200, 49, 'Kapton'] def TwikiPrintout(plotname, label, zoom): """The plots in the twiki are already too much and to avoid mistakes @@ -209,6 +211,8 @@ def acustompalette(): dEdx['WCu'] = 0.75*dEdx['W']+0.25*dEdx['Copper'] #-------- dEdx['Lead'] = 1.274 #Pb +dEdx['Epoxy'] = 0.53539691*dEdx['C'] + 0.13179314*dEdx['H'] + 0.33280996*dEdx['0'] +dEdx['Kapton'] = 0.59985105*dEdx['C'] + 0.080541353*dEdx['H'] + 0.31960759*dEdx['0'] #Composition of cable as Sunanda uses them is here: #http://cmslxr.fnal.gov/source/Geometry/CMSCommonData/data/materials.xml#2841 dEdx['Cables'] = 0.586*dEdx['Copper'] + 0.259*dEdx['C'] + 0.138*dEdx['0'] + 0.017*dEdx['H'] @@ -225,3 +229,6 @@ def acustompalette(): MatXo['StainlessSteel'] = 17.3555 MatXo['WCu'] = 5.1225 MatXo['Lead'] = 5.6118 +MatXo['Epoxy'] = 315.901 +MatXo['Kapton'] = 365.309 + diff --git a/Validation/Geometry/src/MaterialBudgetCategorizer.cc b/Validation/Geometry/src/MaterialBudgetCategorizer.cc index 583a45b68b6bb..9fac4d97cd19a 100644 --- a/Validation/Geometry/src/MaterialBudgetCategorizer.cc +++ b/Validation/Geometry/src/MaterialBudgetCategorizer.cc @@ -88,13 +88,13 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil cms::Exception("LogicError") <<" File not found " << theMaterialFileName; // fill everything as "other" - float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu, oth; - Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=0.; + float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu,oth,Epoxy,Kapton; + Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=Epoxy=Kapton=0.; std::string materialName; while(theMaterialFile) { theMaterialFile >> materialName; - theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu; + theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu >> Epoxy >> Kapton; // Skip comments if (materialName[0] == '#') continue; @@ -112,6 +112,8 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil theMap[materialName].push_back(StainlessSteel ); // StainlessSteel theMap[materialName].push_back(WCu ); // WCu theMap[materialName].push_back(oth ); // oth + theMap[materialName].push_back(Epoxy ); // Epoxy + theMap[materialName].push_back(Kapton ); // Kapton edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: material " << materialName << " filled " << std::endl @@ -124,6 +126,8 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil << "\tSilicon " << Silicon << std::endl << "\tStainlessSteel " << StainlessSteel << std::endl << "\tWCu " << WCu << std::endl + << "\tEpoxy " << Epoxy << std::endl + << "\tKapton " << Kapton<< std::endl << "\tOTH " << oth; } diff --git a/Validation/Geometry/src/MaterialBudgetData.cc b/Validation/Geometry/src/MaterialBudgetData.cc index 39ec433f46c13..bbc2bf980634e 100644 --- a/Validation/Geometry/src/MaterialBudgetData.cc +++ b/Validation/Geometry/src/MaterialBudgetData.cc @@ -57,6 +57,8 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperMB = 0.f; theH_ScintillatorMB = 0.f; theLeadMB = 0.f; + theEpoxyMB = 0.f; + theKaptonMB = 0.f; theHGC_G10_FR4MB = 0.f; theSiliconMB = 0.f; theStainlessSteelMB = 0.f; @@ -74,6 +76,8 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperIL = 0.f; theH_ScintillatorIL = 0.f; theLeadIL = 0.f; + theEpoxyIL = 0.f; + theKaptonIL = 0.f; theHGC_G10_FR4IL = 0.f; theSiliconIL = 0.f; theStainlessSteelIL = 0.f; @@ -90,6 +94,8 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperFractionMB = 0.f; theH_ScintillatorFractionMB = 0.f; theLeadFractionMB = 0.f; + theEpoxyFractionMB = 0.f; + theKaptonFractionMB = 0.f; theHGC_G10_FR4FractionMB = 0.f; theSiliconFractionMB = 0.f; theStainlessSteelFractionMB = 0.f; @@ -106,6 +112,8 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theCopperFractionIL = 0.f; theH_ScintillatorFractionIL = 0.f; theLeadFractionIL = 0.f; + theEpoxyFractionIL = 0.f; + theKaptonFractionIL = 0.f; theHGC_G10_FR4FractionIL = 0.f; theSiliconFractionIL = 0.f; theStainlessSteelFractionIL = 0.f; @@ -159,7 +167,7 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " Eta " << theEta << " Phi " << thePhi << " TotaLMB" << theTotalMB << " theCopperMB " << theCopperMB << " theH_ScintillatorMB " << theH_ScintillatorMB - << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theHGC_G10_FR4MB " + << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theEpoxyMB " << theEpoxyMB << " theKaptonMB " << theKaptonMB << " theHGC_G10_FR4MB " << theHGC_G10_FR4MB << " theSiliconMB " << theSiliconMB << " theAirMB " << theAirMB << " theStainlessSteelMB " << theStainlessSteelMB << " theWCuMB " << theWCuMB; @@ -169,8 +177,8 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " Eta " << theEta << " Phi " << thePhi << " TotalIL " << theTotalIL << " theCopperIL " << theCopperIL << " theH_ScintillatorIL " << theH_ScintillatorIL - << " CAB " << theCablesIL << " theLeadIL " << theLeadIL - << " theHGC_G10_FR4IL " << theHGC_G10_FR4IL + << " CAB " << theCablesIL << " theLeadIL " << theLeadIL << " theEpoxyIL " << theEpoxyIL + << " theKaptonIL " << theKaptonIL << " theHGC_G10_FR4IL " << theHGC_G10_FR4IL << " theSiliconIL " << theSiliconIL << " Air " << theAirIL << " theStainlessSteelIL " << theStainlessSteelIL << " theWCuIL " << theWCuIL << std::endl; @@ -288,6 +296,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theStainlessSteelFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[7]; theWCuFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[8]; theOtherFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[9]; + theEpoxyFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[10]; + theKaptonFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[11]; if(theOtherFractionMB!=0) @@ -304,6 +314,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theStainlessSteelFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[7]; theWCuFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[8]; theOtherFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[9]; + theEpoxyFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[10]; + theKaptonFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[11]; if(theOtherFractionIL!=0) @@ -348,6 +360,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperDmb[theStepN] = (dmb * theCopperFractionMB); theH_ScintillatorDmb[theStepN] = (dmb * theH_ScintillatorFractionMB); theLeadDmb[theStepN] = (dmb * theLeadFractionMB); + theEpoxyDmb[theStepN] = (dmb * theEpoxyFractionMB); + theKaptonDmb[theStepN] = (dmb * theKaptonFractionMB); theHGC_G10_FR4Dmb[theStepN] = (dmb * theHGC_G10_FR4FractionMB); theSiliconDmb[theStepN] = (dmb * theSiliconFractionMB); theStainlessSteelDmb[theStepN] = (dmb * theStainlessSteelFractionMB); @@ -364,6 +378,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperDil[theStepN] = (dil * theCopperFractionIL); theH_ScintillatorDil[theStepN] = (dil * theH_ScintillatorFractionIL); theLeadDil[theStepN] = (dil * theLeadFractionIL); + theEpoxyDil[theStepN] = (dil * theEpoxyFractionIL); + theKaptonDil[theStepN] = (dil * theKaptonFractionIL); theHGC_G10_FR4Dil[theStepN] = (dil * theHGC_G10_FR4FractionIL); theSiliconDil[theStepN] = (dil * theSiliconFractionIL); theStainlessSteelDil[theStepN] = (dil * theStainlessSteelFractionIL); @@ -546,6 +562,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperMB += (dmb * theCopperFractionMB); theH_ScintillatorMB += (dmb * theH_ScintillatorFractionMB); theLeadMB += (dmb * theLeadFractionMB); + theEpoxyMB += (dmb * theEpoxyFractionMB); + theKaptonMB += (dmb * theKaptonFractionMB); theHGC_G10_FR4MB += (dmb * theHGC_G10_FR4FractionMB); theSiliconMB += (dmb * theSiliconFractionMB); theStainlessSteelMB += (dmb * theStainlessSteelFractionMB); @@ -562,6 +580,8 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theCopperIL += (dil * theCopperFractionIL); theH_ScintillatorIL += (dil * theH_ScintillatorFractionIL); theLeadIL += (dil * theLeadFractionIL); + theEpoxyIL += (dil * theEpoxyFractionIL); + theKaptonIL += (dil * theKaptonFractionIL); theHGC_G10_FR4IL += (dil * theHGC_G10_FR4FractionIL); theSiliconIL += (dil * theSiliconFractionIL); theStainlessSteelIL += (dil * theStainlessSteelFractionIL); diff --git a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc index 004713992fca0..6b003b587d0ae 100644 --- a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc +++ b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc @@ -159,6 +159,28 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("1070", "MB prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1072", "MB ortho prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // Epoxy + hmgr->addHistoProf1( new TProfile("1110", "MB prof Eta [Epoxy];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("1120", "MB prof Phi [Epoxy];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("1130", "MB prof Eta Phi [Epoxy];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("1140", "MB prof R [Epoxy];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("1150", "MB prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1152", "MB ortho prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("1160", "MB prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1170", "MB prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1172", "MB ortho prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + + // Kapton + hmgr->addHistoProf1( new TProfile("1210", "MB prof Eta [Kapton];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("1220", "MB prof Phi [Kapton];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("1230", "MB prof Eta Phi [Kapton];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("1240", "MB prof R [Kapton];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("1250", "MB prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1252", "MB ortho prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("1260", "MB prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1270", "MB prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1272", "MB ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + //========================================================================================================= // total Lambda0 hmgr->addHistoProf1( new TProfile("10010", "IL prof Eta;#eta;#lambda/#lambda_{0} ", 250, -5., 5. ) ); @@ -284,6 +306,28 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("11070", "IL prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11072", "IL ortho prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // Epoxy + hmgr->addHistoProf1( new TProfile("11110", "IL prof Eta [Epoxy];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("11120", "IL prof Phi [Epoxy];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("11130", "IL prof Eta Phi [Epoxy];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("11140", "IL prof R [Epoxy];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("11150", "IL prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11152", "IL ortho prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("11160", "IL prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11170", "IL prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11172", "IL ortho prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + + // Kapton + hmgr->addHistoProf1( new TProfile("11210", "IL prof Eta [Kapton];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("11220", "IL prof Phi [Kapton];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("11230", "IL prof Eta Phi [Kapton];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("11240", "IL prof R [Kapton];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("11250", "IL prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11252", "IL ortho prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("11260", "IL prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11270", "IL prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11272", "IL ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + std::cout << "=== booking user histos done ===" << std::endl; @@ -371,6 +415,16 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(1020)->Fill(theData->getPhi(),theData->getLeadMB()); hmgr->getHistoProf2(1030)->Fill(theData->getEta(),theData->getPhi(),theData->getLeadMB()); + // Epoxy + hmgr->getHistoProf1(1110)->Fill(theData->getEta(),theData->getEpoxyMB()); + hmgr->getHistoProf1(1120)->Fill(theData->getPhi(),theData->getEpoxyMB()); + hmgr->getHistoProf2(1130)->Fill(theData->getEta(),theData->getPhi(),theData->getEpoxyMB()); + + // Kapton + hmgr->getHistoProf1(1210)->Fill(theData->getEta(),theData->getKaptonMB()); + hmgr->getHistoProf1(1220)->Fill(theData->getPhi(),theData->getKaptonMB()); + hmgr->getHistoProf2(1230)->Fill(theData->getEta(),theData->getPhi(),theData->getKaptonMB()); + // // Compute the total x/X0 crossed at each step radius for each path // @@ -386,6 +440,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalMB_SST = 0.0; float theTotalMB_WCU = 0.0; float theTotalMB_LEA = 0.0; + float theTotalMB_EPX = 0.0; + float theTotalMB_KAP = 0.0; for(int iStep = 0; iStep < theData->getNumberOfSteps(); iStep++) { theTotalMB_TOT += theData->getStepDmb(iStep); theTotalMB_COP += theData->getCopperDmb(iStep); @@ -398,6 +454,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalMB_SST += theData->getStainlessSteelDmb(iStep); theTotalMB_WCU += theData->getWCuDmb(iStep); theTotalMB_LEA += theData->getLeadDmb(iStep); + theTotalMB_EPX += theData->getEpoxyDmb(iStep); + theTotalMB_KAP += theData->getKaptonDmb(iStep); int iCop = 0; int iSci = 0; @@ -409,6 +467,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iSst = 0; int iWcu = 0; int iLea = 0; + int iEpx = 0; + int iKap = 0; if( theData->getCopperDmb(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDmb(iStep)>0. ) { iSci = 1; } if( theData->getCablesDmb(iStep)>0. ) { iCab = 1; } @@ -419,6 +479,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getStainlessSteelDmb(iStep)>0. ) { iSst = 1; } if( theData->getWCuDmb(iStep)>0. ) { iWcu = 1; } if( theData->getLeadDmb(iStep)>0. ) { iLea = 1; } + if( theData->getEpoxyDmb(iStep)>0. ) { iEpx = 1; } + if( theData->getKaptonDmb(iStep)>0. ) { iKap = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) @@ -559,6 +621,22 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(1070)->Fill(z,polarRadius,iLea*fillValue); hmgr->getHistoProf2(1072)->Fill(z,polarRadius, iLea * fillValue * costhetacorrection ); + // Epoxy + hmgr->getHistoProf1(1140)->Fill(polarRadius,theTotalMB_EPX); + hmgr->getHistoProf2(1150)->Fill(z,polarRadius,theTotalMB_EPX); + hmgr->getHistoProf2(1152)->Fill(z,polarRadius,theTotalMB_EPX * costhetacorrection ); + hmgr->getHisto2(1160)->Fill(z,polarRadius,iEpx*fillValue); + hmgr->getHistoProf2(1170)->Fill(z,polarRadius,iEpx*fillValue); + hmgr->getHistoProf2(1172)->Fill(z,polarRadius, iEpx * fillValue * costhetacorrection ); + + // Kapton + hmgr->getHistoProf1(1240)->Fill(polarRadius,theTotalMB_KAP); + hmgr->getHistoProf2(1250)->Fill(z,polarRadius,theTotalMB_KAP); + hmgr->getHistoProf2(1252)->Fill(z,polarRadius,theTotalMB_KAP * costhetacorrection ); + hmgr->getHisto2(1260)->Fill(z,polarRadius,iKap*fillValue); + hmgr->getHistoProf2(1270)->Fill(z,polarRadius,iKap*fillValue); + hmgr->getHistoProf2(1272)->Fill(z,polarRadius, iKap * fillValue * costhetacorrection ); + } } @@ -618,6 +696,16 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(11020)->Fill(theData->getPhi(),theData->getLeadIL()); hmgr->getHistoProf2(11030)->Fill(theData->getEta(),theData->getPhi(),theData->getLeadIL()); + // Epoxy + hmgr->getHistoProf1(11110)->Fill(theData->getEta(),theData->getEpoxyIL()); + hmgr->getHistoProf1(11120)->Fill(theData->getPhi(),theData->getEpoxyIL()); + hmgr->getHistoProf2(11130)->Fill(theData->getEta(),theData->getPhi(),theData->getEpoxyIL()); + + // Kapton + hmgr->getHistoProf1(11210)->Fill(theData->getEta(),theData->getKaptonIL()); + hmgr->getHistoProf1(11220)->Fill(theData->getPhi(),theData->getKaptonIL()); + hmgr->getHistoProf2(11230)->Fill(theData->getEta(),theData->getPhi(),theData->getKaptonIL()); + // Compute the total l/l0 crossed at each step radius for each path float theTotalIL_TOT = 0.0; float theTotalIL_COP = 0.0; @@ -630,6 +718,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalIL_SST = 0.0; float theTotalIL_WCU = 0.0; float theTotalIL_LEA = 0.0; + float theTotalIL_EPX = 0.0; + float theTotalIL_KAP = 0.0; for(int iStep = 0; iStep < theData->getNumberOfSteps(); iStep++) { theTotalIL_TOT += theData->getStepDil(iStep); theTotalIL_COP += theData->getCopperDil(iStep); @@ -642,6 +732,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalIL_SST += theData->getStainlessSteelDil(iStep); theTotalIL_WCU += theData->getWCuDil(iStep); theTotalIL_LEA += theData->getLeadDil(iStep); + theTotalIL_EPX += theData->getEpoxyDil(iStep); + theTotalIL_KAP += theData->getKaptonDil(iStep); int iCop = 0; int iSci = 0; @@ -653,6 +745,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iSst = 0; int iWcu = 0; int iLea = 0; + int iEpx = 0; + int iKap = 0; if( theData->getCopperDil(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDil(iStep)>0. ) { iSci = 1; } @@ -664,6 +758,8 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getStainlessSteelDil(iStep)>0. ) { iSst = 1; } if( theData->getWCuDil(iStep)>0. ) { iWcu = 1; } if( theData->getLeadDil(iStep)>0. ) { iLea = 1; } + if( theData->getEpoxyDil(iStep)>0. ) { iEpx = 1; } + if( theData->getKaptonDil(iStep)>0. ) { iKap = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) @@ -802,6 +898,22 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(11070)->Fill(z,polarRadius,iLea*fillValue); hmgr->getHistoProf2(11072)->Fill(z,polarRadius, iLea * fillValue * costhetacorrection ); + // Epoxy + hmgr->getHistoProf1(11140)->Fill(polarRadius,theTotalIL_EPX); + hmgr->getHistoProf2(11150)->Fill(z,polarRadius,theTotalIL_EPX); + hmgr->getHistoProf2(11152)->Fill(z,polarRadius,theTotalIL_EPX * costhetacorrection ); + hmgr->getHisto2(11160)->Fill(z,polarRadius,iEpx*fillValue); + hmgr->getHistoProf2(11170)->Fill(z,polarRadius,iEpx*fillValue); + hmgr->getHistoProf2(11172)->Fill(z,polarRadius, iEpx * fillValue * costhetacorrection ); + + // Kapton + hmgr->getHistoProf1(11240)->Fill(polarRadius,theTotalIL_KAP); + hmgr->getHistoProf2(11250)->Fill(z,polarRadius,theTotalIL_KAP); + hmgr->getHistoProf2(11252)->Fill(z,polarRadius,theTotalIL_KAP * costhetacorrection ); + hmgr->getHisto2(11260)->Fill(z,polarRadius,iKap*fillValue); + hmgr->getHistoProf2(11270)->Fill(z,polarRadius,iKap*fillValue); + hmgr->getHistoProf2(11272)->Fill(z,polarRadius, iKap * fillValue * costhetacorrection ); + } } @@ -835,6 +947,8 @@ void MaterialBudgetHGCalHistos::endOfRun() hmgr->getHisto2(860)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(960)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(1060)->Divide(hmgr->getHisto2(999)); + hmgr->getHisto2(1160)->Divide(hmgr->getHisto2(999)); + hmgr->getHisto2(1260)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(10060)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(10160)->Divide(hmgr->getHisto2(1999)); @@ -847,6 +961,8 @@ void MaterialBudgetHGCalHistos::endOfRun() hmgr->getHisto2(10860)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(10960)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(11060)->Divide(hmgr->getHisto2(1999)); + hmgr->getHisto2(11160)->Divide(hmgr->getHisto2(1999)); + hmgr->getHisto2(11260)->Divide(hmgr->getHisto2(1999)); std::cout << "=== save user histos ===" << std::endl; hmgr->save( theFileName ); From a2df2bb21ea0e79af9fd22cc503a93b7cfa84985 Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Tue, 2 Apr 2019 16:52:34 +0200 Subject: [PATCH 405/686] skip nonexistent branch checks in L1TGlobalUtilHelper --- L1Trigger/L1TGlobal/src/L1TGlobalUtilHelper.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/L1Trigger/L1TGlobal/src/L1TGlobalUtilHelper.cc b/L1Trigger/L1TGlobal/src/L1TGlobalUtilHelper.cc index a9bc8a6bcfa5a..4f5e53f26c075 100644 --- a/L1Trigger/L1TGlobal/src/L1TGlobalUtilHelper.cc +++ b/L1Trigger/L1TGlobal/src/L1TGlobalUtilHelper.cc @@ -52,6 +52,8 @@ void l1t::L1TGlobalUtilHelper::operator()(edm::BranchDescription const& branchDe // TODO decide if the preferred input tags must be given as input parameters // or stay hardwired + if (branchDescription.dropped()) { return; } + std::vector preferredL1TAlgBlkInputTag = { edm::InputTag("gtStage2Digis"), edm::InputTag("hltGtStage2Digis") }; From 31f01543ec5ede51421c8c1825365e8827e83b4c Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Tue, 2 Apr 2019 17:05:35 +0200 Subject: [PATCH 406/686] Cleanup of local tracks fitters' fillDescriptions methods --- .../TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc | 2 -- .../TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc | 6 ++---- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc index 27efb3192b2b6..0f4099e70f315 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSDiamondLocalTrackFitter.cc @@ -102,8 +102,6 @@ CTPPSDiamondLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& edm::ParameterSetDescription desc; desc.add( "recHitsTag", edm::InputTag( "ctppsDiamondRecHits" ) ) ->setComment( "input rechits collection to retrieve" ); - desc.add( "verbosity", 0 ) - ->setComment( "general verbosity of this module" ); edm::ParameterSetDescription trackingAlgoParams; trackingAlgoParams.add( "threshold", 1.5 ) diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc index ab11f0ef3d3f2..99f1452ccb23d 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/TotemTimingLocalTrackFitter.cc @@ -111,8 +111,8 @@ TotemTimingLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& d edm::ParameterSetDescription desc; desc.add( "recHitsTag", edm::InputTag( "totemTimingRecHits" ) ) ->setComment( "input rechits collection to retrieve" ); - desc.add( "verbosity", 0 ) - ->setComment( "general verbosity of this module" ); + desc.add( "maxPlaneActiveChannels", 2 ) + ->setComment( "threshold for discriminating noisy planes" ); edm::ParameterSetDescription trackingAlgoParams; trackingAlgoParams.add( "threshold", 1.5 ) @@ -125,8 +125,6 @@ TotemTimingLocalTrackFitter::fillDescriptions( edm::ConfigurationDescriptions& d ->setComment( "pixel efficiency function parameter determining the smoothness of the step" ); trackingAlgoParams.add( "tolerance", 0.1 /* mm */) ->setComment( "tolerance used for checking if the track contains certain hit" ); - trackingAlgoParams.add( "maxPlaneActiveChannels", 2 ) - ->setComment( "threshold for discriminating noisy planes" ); trackingAlgoParams.add( "pixelEfficiencyFunction", "(x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]" ) ->setComment( "efficiency function for single pixel\n" diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index b851b6e5dedd9..8c07558ac7d3d 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -46,8 +46,9 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, z_width = 2.0 * det->params().at( 2 ); // retrieve the timing calibration part for this channel - const int sector = detid.arm(), station = 0, plane = detid.plane(), channel = detid.channel(); + const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); const auto& ch_params = calib_.parameters( sector, station, plane, channel ); + // offset + time precision set to 0 if not found const double ch_t_offset = calib_.timeOffset( sector, station, plane, channel ); const double ch_t_precis = calib_.timePrecision( sector, station, plane, channel ); From e4f5f9a05e32785bb30a76a2cd758de02d711df4 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Tue, 2 Apr 2019 17:22:10 +0200 Subject: [PATCH 407/686] Let DummyLHEAnalyzer test run out of the box --- GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc | 3 --- GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc b/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc index 2d315a4d25629..602067191f5b1 100755 --- a/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc +++ b/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc @@ -23,7 +23,6 @@ class DummyLHEAnalyzer : public EDAnalyzer { public: explicit DummyLHEAnalyzer( const ParameterSet & cfg ) : dumpHeader_( cfg.getUntrackedParameter("dumpHeader",false) ), - src_( cfg.getParameter( "src" ) ), tokenLHERunInfo_(consumes(cfg.getUntrackedParameter("moduleLabel", std::string("source")) ) ), tokenLHEEvent_(consumes(cfg.getUntrackedParameter("moduleLabel", std::string("source")) ) ) { @@ -32,7 +31,6 @@ class DummyLHEAnalyzer : public EDAnalyzer { void analyze( const Event & iEvent, const EventSetup & iSetup ) override { edm::Handle evt; - //iEvent.getByLabel(src_, evt); iEvent.getByToken(tokenLHEEvent_, evt); const lhef::HEPEUP hepeup_ = evt->hepeup(); @@ -119,7 +117,6 @@ class DummyLHEAnalyzer : public EDAnalyzer { } - InputTag src_; edm::EDGetTokenT tokenLHERunInfo_; edm::EDGetTokenT tokenLHEEvent_; diff --git a/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py b/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py index bdff3670f995b..0a30df91b8ec3 100644 --- a/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py +++ b/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py @@ -11,7 +11,8 @@ ) process.dummy = cms.EDAnalyzer("DummyLHEAnalyzer", - src = cms.InputTag("source") + moduleLabel = cms.untracked.InputTag("externalLHEProducer"), + dumpHeader = cms.untracked.bool(True) ) process.p = cms.Path(process.dummy) From 09203ff3b378e8659d10e799e73ba31beb8a9dc3 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 2 Apr 2019 18:00:20 +0200 Subject: [PATCH 408/686] Add 2 algorithms for HGCal to DD4Hep format --- .../data/cms-test-ddhgcalcell-algorithm.xml | 38 +++ .../DDCMS/data/testDDHGCalCellAlgorithm.xml | 128 ++++++++ .../DDCMS/plugins/DDHGCalCell.cc | 304 ++++++++++++++++++ .../DDCMS/plugins/DDHGCalWafer.cc | 95 ++++++ .../test/python/testDDHGCalCellAlgorithm.py | 24 ++ 5 files changed, 589 insertions(+) create mode 100644 DetectorDescription/DDCMS/data/cms-test-ddhgcalcell-algorithm.xml create mode 100644 DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml create mode 100644 DetectorDescription/DDCMS/plugins/DDHGCalCell.cc create mode 100644 DetectorDescription/DDCMS/plugins/DDHGCalWafer.cc create mode 100644 DetectorDescription/DDCMS/test/python/testDDHGCalCellAlgorithm.py diff --git a/DetectorDescription/DDCMS/data/cms-test-ddhgcalcell-algorithm.xml b/DetectorDescription/DDCMS/data/cms-test-ddhgcalcell-algorithm.xml new file mode 100644 index 0000000000000..6be63785f1e31 --- /dev/null +++ b/DetectorDescription/DDCMS/data/cms-test-ddhgcalcell-algorithm.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml b/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml new file mode 100644 index 0000000000000..a48e95f19518d --- /dev/null +++ b/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HGCalEECellTrunc01Fine, HGCalEECellTrunc02Fine, + HGCalEECellTrunc03Fine + + + HGCalEESensitiveTrunc01Fine, HGCalEESensitiveTrunc02Fine, + HGCalEESensitiveTrunc03Fine + + + HGCalEECellExten01Fine, HGCalEECellExten02Fine, + HGCalEECellExten03Fine + + + HGCalEESensitiveExten01Fine, HGCalEESensitiveExten02Fine, + HGCalEESensitiveExten03Fine + + + HGCalEECellCorner01Fine, HGCalEECellCorner02Fine, + HGCalEECellCorner03Fine, HGCalEECellCorner04Fine, + HGCalEECellCorner05Fine, HGCalEECellCorner06Fine + + + HGCalEESensitiveCorner01Fine, HGCalEESensitiveCorner02Fine, + HGCalEESensitiveCorner03Fine, HGCalEESensitiveCorner04Fine, + HGCalEESensitiveCorner05Fine, HGCalEESensitiveCorner06Fine + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DetectorDescription/DDCMS/plugins/DDHGCalCell.cc b/DetectorDescription/DDCMS/plugins/DDHGCalCell.cc new file mode 100644 index 0000000000000..6606e020c31c3 --- /dev/null +++ b/DetectorDescription/DDCMS/plugins/DDHGCalCell.cc @@ -0,0 +1,304 @@ +#include "DD4hep/DetFactoryHelper.h" +#include "DataFormats/Math/interface/GeantUnits.h" +#include "DetectorDescription/DDCMS/interface/DDPlugins.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +//#define EDM_ML_DEBUG + +static long algorithm(dd4hep::Detector& /* description */, + cms::DDParsingContext& ctxt, + xml_h e, + dd4hep::SensitiveDetector& /* sens */) { + + cms::DDNamespace ns(ctxt,e,true); + cms::DDAlgoArguments args(ctxt, e); + // Header section of original DDHGCalCell.h + double waferSize = args.value("WaferSize"); // size of wafer + double waferT = args.value("WaferThick"); // Thickness of wafer + double cellT = args.value("CellThick"); // Thickness of depletion layer + int nCells = args.value("NCells"); // Number of cells + int posSens = args.value("PosSensitive"); // Position of delpletion layer within wafer + std::string material = args.value("Material");// Material + std::string fullCN = args.value("FullCell");// Name of the full cell + std::string fullSensN = args.value("FullSensitive");// Name of the sensitive part for a full cell + std::vector truncCN = args.value >("TruncatedCell"); // Names of truncated cells + std::vector truncSensN = args.value >("TruncatedSensitive"); // Names of the sensitive parts for truncated cells + std::vector extenCN = args.value >("ExtendedCell"); // Names of extended cells + std::vector extenSensN = args.value >("ExtendedSensitive"); // Names of the sensitive parts for extended cells + std::vector cornrCN = args.value >("CornerCell"); // Names of the corner cells + std::vector cornrSensN = args.value >("CornerSensitive"); // Names of the sensitive parts for corner cells + + if ((truncCN.size() != truncSensN.size()) || + (extenCN.size() != extenSensN.size()) || + (cornrCN.size() != cornrSensN.size())) { + edm::LogError("HGCalGeom") << "The number of cells & sensitive differ:" + << " Truncated " << truncCN.size() << ":" + << truncSensN.size() << " Extended " + << extenCN.size() <<":" << extenSensN.size() + << " Corners " << cornrCN.size() << ":" + << cornrSensN.size(); + throw cms::Exception("DDException") << "The number of cells & sensitive " + << "differ: Truncated " + << truncCN.size() << ":" + << truncSensN.size() << " Extended " + << extenCN.size() <<":" + << extenSensN.size() << " Corners " + << cornrCN.size() << ":" + << cornrSensN.size(); + } + if ((truncCN.size() != 3) || (extenCN.size() != 3) || + (cornrCN.size() != 6)) { + edm::LogError("HGCalGeom") << "DDHGCalCell: The number of cells does not" + << " match with Standard: Truncated " + << truncCN.size() << ":3 Extended " + << extenCN.size() <<":3" << " Corners " + << cornrCN.size() << ":6"; + throw cms::Exception("DDException") << "Wrong size of truncated|extended" + << "|corner cells: " << truncCN.size() + << ":" << extenCN.size() << ":" + << cornrCN.size(); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Wafer r " << waferSize + << " T " << waferT << " Cell T " << cellT + << " Cells/Wafer " << nCells << " Material " + << material << "Sensitive Position " + << posSens << " Full Cell: " << fullCN << ":" + << fullSensN; + for (int k=0; k<3; ++k) + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Truncated Cell[" << k + << "] " << truncCN[k] << ":" + << truncSensN[k]; + for (int k=0; k<3; ++k) + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Extended Cell[" << k + << "] " << extenCN[k] << ":" + << extenSensN[k]; + for (int k=0; k<6; ++k) + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Corner Cell[" << k + << "] " << cornrCN[k] << ":" + << cornrSensN[k]; + edm::LogVerbatim("HGCalGeom") << "Name space " << ns.name(); +#endif + + dd4hep::Material matter = ns.material(material); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << material + << " initialized at " << &matter; +#endif + dd4hep::Volume glog1, glog2; + + static const double sqrt3 = std::sqrt(3.0); + static const double waf2cell = 3.0; + static const double cornerfac= 2.5; + double R = waferSize/(waf2cell*nCells); + double r = 0.5*R*sqrt3; + double dx1 = R; + double dx2 = 0.5*dx1; + double dx3 = cornerfac*dx2; + double dx4 = 0.5*dx2; + double dy1 = r; + double dy2 = 0.5*dy1; + double dy3 = 1.5*dy1; + std::vector xx = {dx1, dx2,-dx2,-dx1,-dx2,dx2, + dx3,-dx4,-dx1,-dx1,-dx4,dx3}; + std::vector yy = {0, dy1,dy1, 0,-dy1,-dy1, + dy2,dy3,dy1,-dy1,-dy3,-dy2}; + double zpos = (posSens == 0) ? -0.5*(waferT-cellT) : 0.5*(waferT-cellT); + dd4hep::Position tran(0,0,zpos); + + // First the full cell + std::vector xw = {xx[0],xx[1],xx[2],xx[3],xx[4],xx[5]}; + std::vector yw = {yy[0],yy[1],yy[2],yy[3],yy[4],yy[5]}; + std::vector zw = {-0.5*waferT,0.5*waferT}; + std::vector zx(2,0), zy(2,0), scale(2,1.0); + dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale); + ns.addSolidNS(ns.prepend(fullCN), solid); + glog1 = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() + << " extruded polygon made of " << material + << " z|x|y|s (0) " << zw[0] << ":" << zx[0] + << ":" << zy[0] << ":" << scale[0] + << " z|x|y|s (1) " << zw[1] << ":" << zx[1] + << ":" << zy[1] << ":" << scale[1] << " and " + << xw.size() << " edges"; + for (unsigned int k=0; k zc = {-0.5*cellT,0.5*cellT}; + solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale); + ns.addSolidNS(ns.prepend(fullSensN), solid); + glog2 = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog2); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() + << " extruded polygon made of " << material + << " z|x|y|s (0) " << zc[0] << ":" << zx[0] + << ":" << zy[0] << ":" << scale[0] + << " z|x|y|s (1) " << zc[1] << ":" << zx[1] + << ":" << zy[1] << ":" << scale[1] << " and " + << xw.size() << " edges"; + for (unsigned int k=0; k xw = {xx[ir0[i]],xx[ir1[i]],xx[ir2[i]],xx[ir3[i]],xx[ir4[i]]}; + std::vector yw = {yy[ir0[i]],yy[ir1[i]],yy[ir2[i]],yy[ir3[i]],yy[ir4[i]]}; + + solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale); + ns.addSolidNS(ns.prepend(truncCN[i]), solid); + glog1 = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() + << " extruded polygon made of " << material + << " z|x|y|s (0) " << zw[0] << ":" << zx[0] + << ":" << zy[0] << ":" << scale[0] + << " z|x|y|s (1) " << zw[1] << ":" << zx[1] + << ":" << zy[1] << ":" << scale[1] << " and " + << xw.size() << " edges"; + for (unsigned int k=0; k xw = {xx[ie0[i]],xx[ie1[i]],xx[ie2[i]],xx[ie3[i]],xx[ie4[i]]}; + std::vector yw = {yy[ie0[i]],yy[ie1[i]],yy[ie2[i]],yy[ie3[i]],yy[ie4[i]]}; + solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale); + ns.addSolidNS(ns.prepend(extenCN[i]), solid); + glog1 = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() + << " extruded polygon made of " << material + << " z|x|y|s (0) " << zw[0] << ":" << zx[0] + << ":" << zy[0] << ":" << scale[0] + << " z|x|y|s (1) " << zw[1] << ":" << zx[1] + << ":" << zy[1] << ":" << scale[1] << " and " + << xw.size() << " edges"; + for (unsigned int k=0; k xw = {xx[ic0[i]],xx[ic1[i]],xx[ic2[i]],xx[ic3[i]],xx[ic4[i]]}; + std::vector yw = {yy[ic0[i]],yy[ic1[i]],yy[ic2[i]],yy[ic3[i]],yy[ic4[i]]}; + solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale); + ns.addSolidNS(ns.prepend(cornrCN[i]), solid); + glog1 = dd4hep::Volume(solid.name(), solid, matter); + ns.addVolumeNS(glog1); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() + << " extruded polygon made of " << material + << " z|x|y|s (0) " << zw[0] << ":" << zx[0] + << ":" << zy[0] << ":" << scale[0] + << " z|x|y|s (1) " << zw[1] << ":" << zx[1] + << ":" << zy[1] << ":" << scale[1] << " and " + << xw.size() << " edges"; + for (unsigned int k=0; k("WaferSize"); + int cellType = args.value("CellType"); + int nColumns = args.value("NColumns"); + int nBottomY = args.value("NBottomY"); + std::vector childNames = args.value >("ChildNames"); + std::vector nCellsRow = args.value >("NCellsRow"); + std::vector angleEdges = args.value >("AngleEdges"); + std::vector detectorType = args.value >("DetectorType"); + std::string parentName = args.parentName(); + dd4hep::Volume mother = ns.volume(parentName); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << childNames.size() << " children: " + << childNames[0] << "; " << childNames[1] + << " positioned in " << nCellsRow.size() + << " rows and " << nColumns + << " columns with lowest column at " + << nBottomY << " in mother " << parentName + << " of size " << waferSize; + for (unsigned int k=0; k Date: Tue, 2 Apr 2019 19:47:20 +0200 Subject: [PATCH 409/686] Take Kevin's comment --- Configuration/Geometry/python/dict2023Geometry.py | 10 +++++----- .../python/upgradeWorkflowComponents.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/Geometry/python/dict2023Geometry.py b/Configuration/Geometry/python/dict2023Geometry.py index 557e8db872290..67f58079ee220 100644 --- a/Configuration/Geometry/python/dict2023Geometry.py +++ b/Configuration/Geometry/python/dict2023Geometry.py @@ -425,7 +425,7 @@ 'from Geometry.EcalMapping.EcalMapping_cfi import *', 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', ], - "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, phase2_hgcalV9, hcalHardcodeConditions, hcalSkipPacker", }, "C5" : { @@ -500,7 +500,7 @@ 'from Geometry.EcalMapping.EcalMapping_cfi import *', 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', ], - "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, phase2_hgcalV9, hcalHardcodeConditions, hcalSkipPacker", }, "C6" : { @@ -586,7 +586,7 @@ 'from Geometry.EcalMapping.EcalMapping_cfi import *', 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', ], - "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker, phase2_hfnose", + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, phase2_hgcalV9, hcalHardcodeConditions, hcalSkipPacker, phase2_hfnose", }, "C7" : { @@ -661,7 +661,7 @@ 'from Geometry.EcalMapping.EcalMapping_cfi import *', 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', ], - "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, phase2_hgcalV9, hcalHardcodeConditions, hcalSkipPacker", }, "C8" : { @@ -735,7 +735,7 @@ 'from Geometry.EcalMapping.EcalMapping_cfi import *', 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', ], - "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, phase2_hgcalV9, phase2_hgcalV10, hcalHardcodeConditions, hcalSkipPacker", }, } diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 4a9e80f350080..f4cc0c2577f4f 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -428,7 +428,7 @@ 'Geom' : 'Extended2023D41', 'HLTmenu': '@fake2', 'GT' : 'auto:phase2_realistic', - 'Era' : 'Phase2C4_timing_layer_bar', + 'Era' : 'Phase2C8_timing_layer_bar', 'ScenToRun' : ['GenSimHLBeamSpotFull','DigiFullTrigger','RecoFullGlobal', 'HARVESTFullGlobal'], }, } From 1e25f5b818f7b5611a442f671ada855220f8ca38 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 27 Mar 2019 17:41:53 +0100 Subject: [PATCH 410/686] First attempt of premixing for MTD --- .../FTLDigi/interface/PMTDSimAccumulator.h | 164 ++++++++++++++++++ DataFormats/FTLDigi/src/classes.h | 1 + DataFormats/FTLDigi/src/classes_def.xml | 7 + .../python/mtdUncalibratedRecHits_cfi.py | 6 + .../python/SimFastTiming_EventContent_cff.py | 17 +- .../FastTimingCommon/interface/MTDDigitizer.h | 100 ++++++++++- .../interface/MTDDigitizerBase.h | 31 +++- .../interface/MTDDigitizerTypes.h | 3 + .../FastTimingCommon/plugins/BuildFile.xml | 1 + .../plugins/PreMixingMTDWorker.cc | 74 ++++++++ .../python/mtdDigitizer_cfi.py | 13 ++ .../MixingModule/python/digitizers_cfi.py | 6 + .../python/mixOne_premix_on_sim_cfi.py | 20 +++ 13 files changed, 429 insertions(+), 14 deletions(-) create mode 100644 DataFormats/FTLDigi/interface/PMTDSimAccumulator.h create mode 100644 SimFastTiming/FastTimingCommon/plugins/PreMixingMTDWorker.cc diff --git a/DataFormats/FTLDigi/interface/PMTDSimAccumulator.h b/DataFormats/FTLDigi/interface/PMTDSimAccumulator.h new file mode 100644 index 0000000000000..2bcb633a764b6 --- /dev/null +++ b/DataFormats/FTLDigi/interface/PMTDSimAccumulator.h @@ -0,0 +1,164 @@ +#ifndef DataFormats_FTLDigi_PMTDSimAccumulator_h +#define DataFormats_FTLDigi_PMTDSimAccumulator_h + +#include "DataFormats/DetId/interface/DetId.h" + +#include +#include + +class PMTDSimAccumulator { +public: + // These two structs are public only because of dictionary generation + class DetIdSize { + public: + DetIdSize() {} + DetIdSize(unsigned int detId, unsigned char row, unsigned char col): + detId_(detId), row_(row), column_(col) + {} + + void increaseSize() { + ++size_; + } + + unsigned int detId() const { return detId_; } + unsigned char row() const { return row_; } + unsigned char column() const { return column_; } + unsigned int size() const { return size_; } + + private: + unsigned int detId_ = 0; + unsigned char row_ = 0; + unsigned char column_ = 0; + unsigned char size_ = 0; + }; + class Data { + public: + constexpr static unsigned energyOffset = 15; + constexpr static unsigned energyMask = 0x1; + constexpr static unsigned sampleOffset = 11; + constexpr static unsigned sampleMask = 0xf; + constexpr static unsigned dataOffset = 0; + constexpr static unsigned dataMask = 0x7ff; + + Data(): data_(0) {} + Data(unsigned short ei, unsigned short si, unsigned short d): + data_((ei << energyOffset) | (si << sampleOffset) | d) + {} + + unsigned int energyIndex() const { return data_ >> energyOffset; } + unsigned int sampleIndex() const { return (data_ >> sampleOffset) & sampleMask; } + unsigned int data() const { return data_ & dataMask; } + + private: + unsigned short data_; + }; + + PMTDSimAccumulator() = default; + ~PMTDSimAccumulator() = default; + + void reserve(size_t size) { + detIdSize_.reserve(size); + data_.reserve(size); + } + + void shrink_to_fit() { + detIdSize_.shrink_to_fit(); + data_.shrink_to_fit(); + } + + /** + * Adds data for a given detId, energyIndex, and sampleIndex. + * + * It is the caller's responsibility to ensure that energyIndex, + * sampleIndex, and data fit in the space reserved for them in the + * Data bitfield above. + */ + void emplace_back(unsigned int detId, unsigned char row, unsigned char column, unsigned short energyIndex, unsigned short sampleIndex, unsigned short data) { + if(detIdSize_.empty() || detIdSize_.back().detId() != detId || detIdSize_.back().row() != row || detIdSize_.back().column() != column) { + detIdSize_.emplace_back(detId, row, column); + } + data_.emplace_back(energyIndex, sampleIndex, data); + detIdSize_.back().increaseSize(); + } + + class TmpElem { + public: + TmpElem(unsigned int detId, unsigned char row, unsigned char column, Data data): + detId_(detId), data_(data), row_(row), column_(column) + {} + + unsigned int detId() const { return detId_; } + unsigned char row() const { return row_; } + unsigned char column() const { return column_; } + unsigned short energyIndex() const { return data_.energyIndex(); } + unsigned short sampleIndex() const { return data_.sampleIndex(); } + unsigned short data() const { return data_.data(); } + private: + unsigned int detId_; + Data data_; + unsigned char row_; + unsigned char column_; + }; + + class const_iterator { + public: + // begin + const_iterator(const PMTDSimAccumulator *acc): + acc_(acc), iDet_(0), iData_(0), + endData_(acc->detIdSize_.empty() ? 0 : acc->detIdSize_.front().size()) + {} + + // end + const_iterator(const PMTDSimAccumulator *acc, unsigned int detSize, unsigned int dataSize): + acc_(acc), iDet_(detSize), iData_(dataSize), endData_(0) + {} + + bool operator==(const const_iterator& other) const { + return iDet_ == other.iDet_ && iData_ == other.iData_; + } + bool operator!=(const const_iterator& other) const { + return !operator==(other); + } + const_iterator& operator++() { + ++iData_; + if(iData_ == endData_) { + ++iDet_; + endData_ += (iDet_ == acc_->detIdSize_.size()) ? 0 : acc_->detIdSize_[iDet_].size(); + } + return *this; + } + const_iterator operator++(int) { + auto tmp = *this; + ++(*this); + return tmp; + } + TmpElem operator*() { + const auto& id = acc_->detIdSize_[iDet_]; + return TmpElem(id.detId(), id.row(), id.column(), + acc_->data_[iData_]); + } + + private: + const PMTDSimAccumulator *acc_; + unsigned int iDet_; + unsigned int iData_; + unsigned int endData_; + }; + + TmpElem back() const { + const auto& id = detIdSize_.back(); + return TmpElem(id.detId(), id.row(), id.column(), + data_.back()); + } + + const_iterator cbegin() const { return const_iterator(this); } + const_iterator begin() const { return cbegin(); } + const_iterator cend() const { return const_iterator(this, detIdSize_.size(), data_.size()); } + const_iterator end() const { return cend(); } + +private: + std::vector detIdSize_; + std::vector data_; +}; + +#endif diff --git a/DataFormats/FTLDigi/src/classes.h b/DataFormats/FTLDigi/src/classes.h index 01e270b847d3f..08ec6ad8b2ccf 100644 --- a/DataFormats/FTLDigi/src/classes.h +++ b/DataFormats/FTLDigi/src/classes.h @@ -1,3 +1,4 @@ #include #include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" +#include "DataFormats/FTLDigi/interface/PMTDSimAccumulator.h" diff --git a/DataFormats/FTLDigi/src/classes_def.xml b/DataFormats/FTLDigi/src/classes_def.xml index 5160a123230c2..ba4aaecac7843 100644 --- a/DataFormats/FTLDigi/src/classes_def.xml +++ b/DataFormats/FTLDigi/src/classes_def.xml @@ -17,4 +17,11 @@ + + + + + + + diff --git a/RecoLocalFastTime/FTLRecProducers/python/mtdUncalibratedRecHits_cfi.py b/RecoLocalFastTime/FTLRecProducers/python/mtdUncalibratedRecHits_cfi.py index d22ae5d0e8715..47e41748787c1 100644 --- a/RecoLocalFastTime/FTLRecProducers/python/mtdUncalibratedRecHits_cfi.py +++ b/RecoLocalFastTime/FTLRecProducers/python/mtdUncalibratedRecHits_cfi.py @@ -34,3 +34,9 @@ BarrelHitsName = cms.string('FTLBarrel'), EndcapHitsName = cms.string('FTLEndcap') ) + +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(mtdUncalibratedRecHits, + barrelDigis = 'mixData:FTLBarrel', + endcapDigis = 'mixData:FTLEndcap', +) diff --git a/SimFastTiming/Configuration/python/SimFastTiming_EventContent_cff.py b/SimFastTiming/Configuration/python/SimFastTiming_EventContent_cff.py index bc70b4fc5e248..84333c00c2566 100644 --- a/SimFastTiming/Configuration/python/SimFastTiming_EventContent_cff.py +++ b/SimFastTiming/Configuration/python/SimFastTiming_EventContent_cff.py @@ -20,8 +20,17 @@ outputCommands = cms.untracked.vstring() ) -_phase2_timing_extraCommands = [ 'keep *_mix_FTLBarrel_*','keep *_mix_FTLEndcap_*','keep *_mix_InitialVertices_*' ] +_phase2_timing_extraCommands = cms.PSet( # using PSet in order to customize with Modifier + value = cms.vstring( 'keep *_mix_FTLBarrel_*','keep *_mix_FTLEndcap_*','keep *_mix_InitialVertices_*' ) +) +# For premixing switch the sim digi collections to the ones including pileup +# Unsure what to do with InitialVertices, they don't seem to be consumed downstream? +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(_phase2_timing_extraCommands, + value = [ 'keep *_mixData_FTLBarrel_*','keep *_mixData_FTLEndcap_*','keep *_mix_InitialVertices_*' ] +) from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing -phase2_timing.toModify( SimFastTimingRAW, outputCommands = SimFastTimingRAW.outputCommands + _phase2_timing_extraCommands ) -phase2_timing.toModify( SimFastTimingFEVTDEBUG, outputCommands = SimFastTimingFEVTDEBUG.outputCommands + _phase2_timing_extraCommands ) -phase2_timing.toModify( SimFastTimingRECO, outputCommands = SimFastTimingRECO.outputCommands + _phase2_timing_extraCommands ) +phase2_timing.toModify( SimFastTimingRAW, outputCommands = SimFastTimingRAW.outputCommands + _phase2_timing_extraCommands.value ) +phase2_timing.toModify( SimFastTimingFEVTDEBUG, outputCommands = SimFastTimingFEVTDEBUG.outputCommands + _phase2_timing_extraCommands.value ) +phase2_timing.toModify( SimFastTimingRECO, outputCommands = SimFastTimingRECO.outputCommands + _phase2_timing_extraCommands.value ) +phase2_timing.toModify( SimFastTimingPREMIX, outputCommands = SimFastTimingRECO.outputCommands + _phase2_timing_extraCommands.value ) diff --git a/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h b/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h index cb3096c1d4f11..dfa3d0e54be41 100644 --- a/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h +++ b/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h @@ -23,6 +23,8 @@ #include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h" +#include "DataFormats/Math/interface/liblogintpack.h" + #include #include #include @@ -50,6 +52,73 @@ namespace mtd_digitizer { } } + inline + void saveSimHitAccumulator(PMTDSimAccumulator& simResult, const MTDSimHitDataAccumulator& simData, const float minCharge, const float maxCharge) { + constexpr auto nEnergies = std::tuple_size::value; + static_assert(nEnergies <= PMTDSimAccumulator::Data::energyMask+1, "PMTDSimAccumulator bit pattern needs to updated"); + static_assert(nSamples <= PMTDSimAccumulator::Data::sampleMask+1, "PMTDSimAccumulator bit pattern needs to updated"); + + const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2; + const float maxPackChargeLog = std::log(maxCharge); + constexpr uint16_t base = 1< minCharge) { + unsigned short packed; + if(iEn == 1) { + // assuming linear range for tof of 0..26 + packed = samples[iSample]/PREMIX_MAX_TOF * base; + } + else { + packed = logintpack::pack16log(samples[iSample], minPackChargeLog, maxPackChargeLog, base); + } + simResult.emplace_back(elem.first.detid_, elem.first.row_, elem.first.column_, + iEn, iSample, packed); + } + } + } + } + } + + inline + void loadSimHitAccumulator(MTDSimHitDataAccumulator& simData, const PMTDSimAccumulator& simAccumulator, const float minCharge, const float maxCharge) { + const float minPackChargeLog = minCharge > 0.f ? std::log(minCharge) : -2; + const float maxPackChargeLog = std::log(maxCharge); + constexpr uint16_t base = 1<second.hit_info; + + size_t iEn = detIdIndexHitInfo.energyIndex(); + size_t iSample = detIdIndexHitInfo.sampleIndex(); + + float value; + if(iEn == 1) { + value = static_cast(detIdIndexHitInfo.data())/base*PREMIX_MAX_TOF; + } + else { + value = logintpack::unpack16log(detIdIndexHitInfo.data(), minPackChargeLog, maxPackChargeLog, base); + } + + if(iEn == 0) { + hit_info[iEn][iSample] += value; + } + else if(hit_info[iEn][iSample] == 0) { + // For iEn==1 the digitizers just set the TOF of the first SimHit + hit_info[iEn][iSample] = value; + } + } + } + template class MTDDigitizer : public MTDDigitizerBase { @@ -76,7 +145,9 @@ namespace mtd_digitizer { void accumulate(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) override; void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) override; void accumulate(edm::Handle const &hits, int bxCrossing, CLHEP::HepRandomEngine* hre) override; - + // for premixing + void accumulate(const PMTDSimAccumulator& simAccumulator) override; + /** @short actions at the start/end of event */ @@ -156,20 +227,33 @@ namespace mtd_digitizer { hitRefs.clear(); } + + template + void MTDDigitizer::accumulate(const PMTDSimAccumulator& simAccumulator) { + loadSimHitAccumulator(simHitAccumulator_, simAccumulator, premixStage1MinCharge_, premixStage1MaxCharge_); + } template void MTDDigitizer::initializeEvent(edm::Event const& e, edm::EventSetup const& c) { deviceSim_.getEvent(e); - electronicsSim_.getEvent(e); + if(not premixStage1_) { + electronicsSim_.getEvent(e); + } } template void MTDDigitizer::finalizeEvent(edm::Event& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) { - - auto digiCollection = std::make_unique(); - electronicsSim_.run(simHitAccumulator_,*digiCollection, hre); - e.put(std::move(digiCollection),digiCollection_); + if(premixStage1_) { + auto simResult = std::make_unique(); + saveSimHitAccumulator(*simResult, simHitAccumulator_, premixStage1MinCharge_, premixStage1MaxCharge_); // FIXME + e.put(std::move(simResult), digiCollection_); + } + else { + auto digiCollection = std::make_unique(); + electronicsSim_.run(simHitAccumulator_,*digiCollection, hre); + e.put(std::move(digiCollection),digiCollection_); + } //release memory for next event resetSimHitDataAccumulator(); @@ -184,7 +268,9 @@ namespace mtd_digitizer { geom_ = geom.product(); deviceSim_.getEventSetup(es); - electronicsSim_.getEventSetup(es); + if(not premixStage1_) { + electronicsSim_.getEventSetup(es); + } } } diff --git a/SimFastTiming/FastTimingCommon/interface/MTDDigitizerBase.h b/SimFastTiming/FastTimingCommon/interface/MTDDigitizerBase.h index ac95defa49ea1..57ff29301a039 100644 --- a/SimFastTiming/FastTimingCommon/interface/MTDDigitizerBase.h +++ b/SimFastTiming/FastTimingCommon/interface/MTDDigitizerBase.h @@ -10,6 +10,7 @@ #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" #include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" +#include "DataFormats/FTLDigi/interface/PMTDSimAccumulator.h" #include "SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h" #include "CLHEP/Units/GlobalPhysicalConstants.h" @@ -36,13 +37,27 @@ class MTDDigitizerBase { digiCollection_( config.getParameter("digiCollectionTag") ), verbosity_( config.getUntrackedParameter< uint32_t >("verbosity",0) ), refSpeed_( 0.1*CLHEP::c_light ), + premixStage1MinCharge_( config.getParameter("premixStage1MinCharge") ), + premixStage1MaxCharge_( config.getParameter("premixStage1MaxCharge") ), + premixStage1_( config.getParameter("premixStage1")), name_( config.getParameter("digitizerName") ) { iC.consumes >(inputSimHits_); - if ( name_ == "BTLTileDigitizer" || name_ == "BTLBarDigitizer" ) - parent.produces(digiCollection_); + if ( name_ == "BTLTileDigitizer" || name_ == "BTLBarDigitizer" ) { + if(premixStage1_) { + parent.produces(digiCollection_); + } + else { + parent.produces(digiCollection_); + } + } else if ( name_ == "ETLDigitizer" ) - parent.produces(digiCollection_); + if(premixStage1_) { + parent.produces(digiCollection_); + } + else { + parent.produces(digiCollection_); + } else throw cms::Exception("[MTDDigitizerBase::MTDDigitizerBase]") << name_ << " is an invalid MTD digitizer name"; @@ -57,6 +72,8 @@ class MTDDigitizerBase { virtual void accumulate(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) = 0; virtual void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) = 0; virtual void accumulate(edm::Handle const &hits, int bxCrossing, CLHEP::HepRandomEngine* hre) = 0; + // for premixing + virtual void accumulate(const PMTDSimAccumulator& simAccumulator) = 0; /** @short actions at the start/end of event @@ -86,6 +103,14 @@ class MTDDigitizerBase { //reference speed to evaluate time of arrival at the sensititive detector, assuming the center of CMS const float refSpeed_; + // Minimum charge threshold for premixing stage1 + double premixStage1MinCharge_; + // Maximum charge for packing in premixing stage1 + double premixStage1MaxCharge_; + + // flag telling whether we are runing in premixing stage1 + const bool premixStage1_; + private: std::string name_; diff --git a/SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h b/SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h index 134a4a513f50a..bad4b173b969c 100644 --- a/SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h +++ b/SimFastTiming/FastTimingCommon/interface/MTDDigitizerTypes.h @@ -19,6 +19,9 @@ namespace mtd_digitizer { std::array hit_info; }; + // Maximum value of time-of-flight for premixing packing + constexpr float PREMIX_MAX_TOF = 26.0f; + struct MTDCellId { MTDCellId() : detid_(0), row_(0), column_(0) {} const uint32_t detid_; diff --git a/SimFastTiming/FastTimingCommon/plugins/BuildFile.xml b/SimFastTiming/FastTimingCommon/plugins/BuildFile.xml index 37afe76076a5f..4498a986122b8 100644 --- a/SimFastTiming/FastTimingCommon/plugins/BuildFile.xml +++ b/SimFastTiming/FastTimingCommon/plugins/BuildFile.xml @@ -11,6 +11,7 @@ + diff --git a/SimFastTiming/FastTimingCommon/plugins/PreMixingMTDWorker.cc b/SimFastTiming/FastTimingCommon/plugins/PreMixingMTDWorker.cc new file mode 100644 index 0000000000000..c14ce3690eeae --- /dev/null +++ b/SimFastTiming/FastTimingCommon/plugins/PreMixingMTDWorker.cc @@ -0,0 +1,74 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/ProducerBase.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/FTLDigi/interface/PMTDSimAccumulator.h" +#include "SimFastTiming/FastTimingCommon/interface/MTDDigitizerBase.h" + +#include "SimGeneral/PreMixingModule/interface/PreMixingWorker.h" +#include "SimGeneral/PreMixingModule/interface/PreMixingWorkerFactory.h" + +class PreMixingMTDWorker: public PreMixingWorker { +public: + PreMixingMTDWorker(const edm::ParameterSet& ps, edm::ProducerBase& producer, edm::ConsumesCollector&& iC); + ~PreMixingMTDWorker() override = default; + + PreMixingMTDWorker(const PreMixingMTDWorker&) = delete; + PreMixingMTDWorker& operator=(const PreMixingMTDWorker&) = delete; + + void beginRun(const edm::Run& run, const edm::EventSetup& ES) override; + void endRun() override; + void initializeEvent(const edm::Event &e, const edm::EventSetup& ES) override {} + void addSignals(const edm::Event &e, const edm::EventSetup& ES) override; + void addPileups(const PileUpEventPrincipal&, const edm::EventSetup& ES) override; + void put(edm::Event &e,const edm::EventSetup& ES, std::vector const& ps, int bs) override; + +private: + edm::EDGetTokenT signalToken_; + + edm::InputTag pileInputTag_; + + std::unique_ptr digitizer_; +}; + +PreMixingMTDWorker::PreMixingMTDWorker(const edm::ParameterSet& ps, edm::ProducerBase& producer, edm::ConsumesCollector&& iC): + signalToken_(iC.consumes(ps.getParameter("digiTagSig"))), + pileInputTag_(ps.getParameter("pileInputTag")), + digitizer_(MTDDigitizerFactory::get()->create(ps.getParameter("digitizerName"), + ps,iC,producer)) +{} + +void PreMixingMTDWorker::beginRun(const edm::Run& run, const edm::EventSetup& ES) { + digitizer_->beginRun(ES); +} + +void PreMixingMTDWorker::endRun() { + digitizer_->endRun(); +} + +void PreMixingMTDWorker::addSignals(const edm::Event &e,const edm::EventSetup& ES) { + edm::Handle handle; + e.getByToken(signalToken_, handle); + digitizer_->accumulate(*handle); +} + +void PreMixingMTDWorker::addPileups(const PileUpEventPrincipal& pep, const edm::EventSetup& ES) { + edm::Handle handle; + pep.getByLabel(pileInputTag_, handle); + digitizer_->accumulate(*handle); +} + +void PreMixingMTDWorker::put(edm::Event &e,const edm::EventSetup& ES, std::vector const& ps, int bs) { + edm::Service rng; + digitizer_->finalizeEvent(e, ES, &rng->getEngine(e.streamID())); +} + +DEFINE_PREMIXING_WORKER(PreMixingMTDWorker); diff --git a/SimFastTiming/FastTimingCommon/python/mtdDigitizer_cfi.py b/SimFastTiming/FastTimingCommon/python/mtdDigitizer_cfi.py index 42708cb6239a5..24de0eae4a05f 100644 --- a/SimFastTiming/FastTimingCommon/python/mtdDigitizer_cfi.py +++ b/SimFastTiming/FastTimingCommon/python/mtdDigitizer_cfi.py @@ -5,6 +5,9 @@ inputSimHits = cms.InputTag("g4SimHits:FastTimerHitsBarrel"), digiCollectionTag = cms.string("FTLBarrel"), maxSimHitsAccTime = cms.uint32(100), + premixStage1 = cms.bool(False), + premixStage1MinCharge = cms.double(1e-4), # These give relative precision of 1.1 %, + premixStage1MaxCharge = cms.double(1e6), # can the range be squeezed? DeviceSimulation = cms.PSet( bxTime = cms.double(25), # [ns] LightYield = cms.double(40000.), # [photons/MeV] @@ -51,6 +54,9 @@ inputSimHits = cms.InputTag("g4SimHits:FastTimerHitsBarrel"), digiCollectionTag = cms.string("FTLBarrel"), maxSimHitsAccTime = cms.uint32(100), + premixStage1 = cms.bool(False), + premixStage1MinCharge = cms.double(1e-4), + premixStage1MaxCharge = cms.double(1e6), DeviceSimulation = cms.PSet( bxTime = cms.double(25), # [ns] LightYield = cms.double(40000.), # [photons/MeV] @@ -68,6 +74,9 @@ inputSimHits = cms.InputTag("g4SimHits:FastTimerHitsEndcap"), digiCollectionTag = cms.string("FTLEndcap"), maxSimHitsAccTime = cms.uint32(100), + premixStage1 = cms.bool(False), + premixStage1MinCharge = cms.double(1e-4), + premixStage1MaxCharge = cms.double(1e6), DeviceSimulation = cms.PSet( bxTime = cms.double(25), tofDelay = cms.double(1), @@ -89,6 +98,10 @@ ) ) +from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1 +for _m in [_barrel_tile_MTDDigitizer, _barrel_bar_MTDDigitizer, _endcap_MTDDigitizer]: + premix_stage1.toModify(_m, premixStage1 = True) + # Fast Timing mtdDigitizer = cms.PSet( accumulatorType = cms.string("MTDDigiProducer"), diff --git a/SimGeneral/MixingModule/python/digitizers_cfi.py b/SimGeneral/MixingModule/python/digitizers_cfi.py index e0fd1d3544733..481a580b6154e 100644 --- a/SimGeneral/MixingModule/python/digitizers_cfi.py +++ b/SimGeneral/MixingModule/python/digitizers_cfi.py @@ -98,6 +98,12 @@ (premix_stage2 & phase2_hfnose).toModify(theDigitizers, hfnoseDigitizer = dict(premixStage1 = True), ) +(premix_stage2 & (phase2_timing_layer_tile | phase2_timing_layer_bar)).toModify(theDigitizers, + fastTimingLayer = dict( + barrelDigitizer = dict(premixStage1 = True), + endcapDigitizer = dict(premixStage1 = True) + ) +) theDigitizersValid = cms.PSet(theDigitizers) theDigitizers.mergedtruth.select.signalOnlyTP = True diff --git a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py index 360687cd86037..8d369e5e6c93f 100644 --- a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py +++ b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py @@ -13,6 +13,7 @@ from SimTracker.SiPhase2Digitizer.phase2TrackerDigitizer_cfi import phase2TrackerDigitizer, _premixStage1ModifyDict as _phase2TrackerPremixStage1ModifyDict from SimGeneral.MixingModule.ecalDigitizer_cfi import ecalDigitizer from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import hgceeDigitizer, hgchebackDigitizer, hgchefrontDigitizer, hfnoseDigitizer +from SimFastTiming.FastTimingCommon.mtdDigitizer_cfi import mtdDigitizer hcalSimBlock.HcalPreMixStage2 = cms.bool(True) @@ -201,6 +202,8 @@ from Configuration.Eras.Modifier_phase2_common_cff import phase2_common from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker +from Configuration.Eras.Modifier_phase2_timing_layer_tile_cff import phase2_timing_layer_tile +from Configuration.Eras.Modifier_phase2_timing_layer_bar_cff import phase2_timing_layer_bar from Configuration.Eras.Modifier_phase2_hcal_cff import phase2_hcal from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose @@ -237,6 +240,23 @@ ), ) +# MTD +(phase2_timing_layer_tile | phase2_timing_layer_bar).toModify(mixData, + workers = dict( + mtdBarrel = cms.PSet( + mtdDigitizer.barrelDigitizer, + workerType = cms.string("PreMixingMTDWorker"), + digiTagSig = cms.InputTag("mix", "FTLBarrel"), + pileInputTag = cms.InputTag("mix", "FTLBarrel"), + ), + mtdEndcap = cms.PSet( + mtdDigitizer.endcapDigitizer, + workerType = cms.string("PreMixingMTDWorker"), + digiTagSig = cms.InputTag("mix", "FTLEndcap"), + pileInputTag = cms.InputTag("mix", "FTLEndcap"), + ), + ) +) # ECAL phase2_common.toModify (mixData, workers=dict(ecal=dict(doES=False))) phase2_hgcal.toModify(mixData, workers=dict(ecal=dict(doEE=False))) From 604dcb1b331b75112862918d58d65e9e00b6eddd Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 3 Apr 2019 11:26:22 +0200 Subject: [PATCH 411/686] Use bare and not the tau-reco charged hadron to determine distance for merging --- .../plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 76bf82d2a4a9f..48321f97476d6 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -208,7 +208,7 @@ PFRecoTauChargedHadronFromPFCandidatePlugin::return_type PFRecoTauChargedHadronF int jetConstituentPdgId = std::abs(jetConstituent->pdgId()); if ( !(jetConstituentPdgId == 130 || jetConstituentPdgId == 22) ) continue; - double dR = deltaR(atECALEntrance(jetConstituent.get(), bField_), atECALEntrance(&*chargedHadron, bField_)); + double dR = deltaR(atECALEntrance(jetConstituent.get(), bField_), atECALEntrance(chargedHadron->chargedPFCandidate_.get(), bField_)); double dRmerge = -1.; int minBlockElementMatches = 1000; int maxUnmatchedBlockElements = 0; From 0ff4bf1e07305ae2599a439e42146822045c3909 Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Wed, 3 Apr 2019 11:48:29 +0200 Subject: [PATCH 412/686] Adding Aluminium --- Validation/Geometry/data/hgcalMaterials.l0 | 26 ++++----- Validation/Geometry/data/hgcalMaterials.x0 | 25 ++++---- .../Geometry/interface/MaterialBudgetData.h | 18 ++++++ .../Geometry/python/plot_hgcal_utils.py | 2 + .../Geometry/src/MaterialBudgetCategorizer.cc | 8 ++- Validation/Geometry/src/MaterialBudgetData.cc | 20 +++++-- .../Geometry/src/MaterialBudgetHGCalHistos.cc | 57 +++++++++++++++++++ Validation/Geometry/test/runP_HGCal_cfg.py | 2 +- 8 files changed, 125 insertions(+), 33 deletions(-) diff --git a/Validation/Geometry/data/hgcalMaterials.l0 b/Validation/Geometry/data/hgcalMaterials.l0 index 0322ed590e853..83b493a3661b5 100644 --- a/Validation/Geometry/data/hgcalMaterials.l0 +++ b/Validation/Geometry/data/hgcalMaterials.l0 @@ -1,17 +1,17 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton 0 0 0 0 0 0 0 0 0 0 0 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton-Aluminium 0 0 0 0 0 0 0 0 0 0 0 0 -Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 -HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 -Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 -WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 -Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 -Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 - +Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 +Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 +StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 +WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 +Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 +Aluminium 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/data/hgcalMaterials.x0 b/Validation/Geometry/data/hgcalMaterials.x0 index 4fc0f8df489aa..2bb7e9712c902 100644 --- a/Validation/Geometry/data/hgcalMaterials.x0 +++ b/Validation/Geometry/data/hgcalMaterials.x0 @@ -1,17 +1,18 @@ -#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton 0 0 0 0 0 0 0 0 0 0 0 +#Categories:Air-Cables-Copper-H_Scintillator-Lead-HGC_G10_FR4-Silicon-StainlessSteel-WCu-Epoxy-Kapton-Aluminium 0 0 0 0 0 0 0 0 0 0 0 0 -Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 -Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 -HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 -Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 -WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 -Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 -Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 +Air 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Cables 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Copper 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +H_Scintillator 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +Lead 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +HGC_G10-FR4 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000 +Silicon 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 +StainlessSteel 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 +WCu 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 +Epoxy 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 +Kapton 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 +Aluminium 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.000 diff --git a/Validation/Geometry/interface/MaterialBudgetData.h b/Validation/Geometry/interface/MaterialBudgetData.h index 934bafc0eabdc..5fb90611e87fd 100644 --- a/Validation/Geometry/interface/MaterialBudgetData.h +++ b/Validation/Geometry/interface/MaterialBudgetData.h @@ -60,6 +60,8 @@ class MaterialBudgetData { return theEpoxyFractionMB; } float getKaptonFractionMB() const { return theKaptonFractionMB; } + float getAluminiumFractionMB() const { + return theAluminiumFractionMB; } float getHGC_G10_FR4FractionMB() const { return theHGC_G10_FR4FractionMB; } float getSiliconFractionMB() const { @@ -94,6 +96,8 @@ class MaterialBudgetData { return theEpoxyMB; } float getKaptonMB() const { return theKaptonMB; } + float getAluminiumMB() const { + return theAluminiumMB; } float getHGC_G10_FR4MB() const { return theHGC_G10_FR4MB; } float getSiliconMB() const { @@ -127,6 +131,8 @@ class MaterialBudgetData { return theEpoxyFractionIL; } float getKaptonFractionIL() const { return theKaptonFractionIL; } + float getAluminiumFractionIL() const { + return theAluminiumFractionIL; } float getHGC_G10_FR4FractionIL() const { return theHGC_G10_FR4FractionIL; } float getSiliconFractionIL() const { @@ -161,6 +167,8 @@ class MaterialBudgetData { return theEpoxyIL; } float getKaptonIL() const { return theKaptonIL; } + float getAluminiumIL() const { + return theAluminiumIL; } float getHGC_G10_FR4IL() const { return theHGC_G10_FR4IL; } float getSiliconIL() const { @@ -227,6 +235,8 @@ class MaterialBudgetData { return theEpoxyDmb[is]; } float getKaptonDmb( int is ) const { return theKaptonDmb[is]; } + float getAluminiumDmb( int is ) const { + return theAluminiumDmb[is]; } float getHGC_G10_FR4Dmb( int is ) const { return theHGC_G10_FR4Dmb[is]; } float getSiliconDmb( int is ) const { @@ -264,6 +274,8 @@ class MaterialBudgetData { return theEpoxyDil[is]; } float getKaptonDil( int is ) const { return theKaptonDil[is]; } + float getAluminiumDil( int is ) const { + return theAluminiumDil[is]; } float getHGC_G10_FR4Dil( int is ) const { return theHGC_G10_FR4Dil[is]; } float getSiliconDil( int is ) const { @@ -451,6 +463,7 @@ class MaterialBudgetData { float theLeadFractionMB; float theEpoxyFractionMB; float theKaptonFractionMB; + float theAluminiumFractionMB; float theHGC_G10_FR4FractionMB; float theSiliconFractionMB; float theStainlessSteelFractionMB; @@ -460,6 +473,7 @@ class MaterialBudgetData { float theLeadMB; float theEpoxyMB; float theKaptonMB; + float theAluminiumMB; float theHGC_G10_FR4MB; float theSiliconMB; float theStainlessSteelMB; @@ -479,6 +493,7 @@ class MaterialBudgetData { float theLeadFractionIL; float theEpoxyFractionIL; float theKaptonFractionIL; + float theAluminiumFractionIL; float theHGC_G10_FR4FractionIL; float theSiliconFractionIL; float theStainlessSteelFractionIL; @@ -488,6 +503,7 @@ class MaterialBudgetData { float theLeadIL; float theEpoxyIL; float theKaptonIL; + float theAluminiumIL; float theHGC_G10_FR4IL; float theSiliconIL; float theStainlessSteelIL; @@ -515,6 +531,7 @@ class MaterialBudgetData { std::array theLeadDmb; std::array theEpoxyDmb; std::array theKaptonDmb; + std::array theAluminiumDmb; std::array theHGC_G10_FR4Dmb; std::array theSiliconDmb; std::array theStainlessSteelDmb; @@ -533,6 +550,7 @@ class MaterialBudgetData { std::array theLeadDil; std::array theEpoxyDil; std::array theKaptonDil; + std::array theAluminiumDil; std::array theHGC_G10_FR4Dil; std::array theSiliconDil; std::array theStainlessSteelDil; diff --git a/Validation/Geometry/python/plot_hgcal_utils.py b/Validation/Geometry/python/plot_hgcal_utils.py index 29546d7d58694..c06493bf683b6 100644 --- a/Validation/Geometry/python/plot_hgcal_utils.py +++ b/Validation/Geometry/python/plot_hgcal_utils.py @@ -93,6 +93,7 @@ hist_label_to_num['LEA'] = [1000, 12, 'Lead'] hist_label_to_num['EPX'] = [1100, 46, 'Epoxy'] hist_label_to_num['KAP'] = [1200, 49, 'Kapton'] +hist_label_to_num['ALU'] = [1300, 33, 'Aluminium'] def TwikiPrintout(plotname, label, zoom): """The plots in the twiki are already too much and to avoid mistakes @@ -194,6 +195,7 @@ def acustompalette(): dEdx['H'] = 0. #3.437E-05 -> essentially zero dEdx['Br'] = 0. #9.814E-04 -> essentially zero dEdx['W'] = 2.210 +dEdx['Al'] = 0.4358 #-------- dEdx['Copper'] = 1.257 diff --git a/Validation/Geometry/src/MaterialBudgetCategorizer.cc b/Validation/Geometry/src/MaterialBudgetCategorizer.cc index 9fac4d97cd19a..4b4ebec2d1941 100644 --- a/Validation/Geometry/src/MaterialBudgetCategorizer.cc +++ b/Validation/Geometry/src/MaterialBudgetCategorizer.cc @@ -88,13 +88,13 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil cms::Exception("LogicError") <<" File not found " << theMaterialFileName; // fill everything as "other" - float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu,oth,Epoxy,Kapton; - Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=Epoxy=Kapton=0.; + float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu,oth,Epoxy,Kapton,Aluminium; + Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=Epoxy=Kapton=Aluminium=0.; std::string materialName; while(theMaterialFile) { theMaterialFile >> materialName; - theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu >> Epoxy >> Kapton; + theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu >> Epoxy >> Kapton >> Aluminium; // Skip comments if (materialName[0] == '#') continue; @@ -114,6 +114,7 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil theMap[materialName].push_back(oth ); // oth theMap[materialName].push_back(Epoxy ); // Epoxy theMap[materialName].push_back(Kapton ); // Kapton + theMap[materialName].push_back(Aluminium ); // Aluminium edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: material " << materialName << " filled " << std::endl @@ -128,6 +129,7 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil << "\tWCu " << WCu << std::endl << "\tEpoxy " << Epoxy << std::endl << "\tKapton " << Kapton<< std::endl + << "\tAluminium " << Aluminium<< std::endl << "\tOTH " << oth; } diff --git a/Validation/Geometry/src/MaterialBudgetData.cc b/Validation/Geometry/src/MaterialBudgetData.cc index bbc2bf980634e..fcdb9cca1adfd 100644 --- a/Validation/Geometry/src/MaterialBudgetData.cc +++ b/Validation/Geometry/src/MaterialBudgetData.cc @@ -59,6 +59,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theLeadMB = 0.f; theEpoxyMB = 0.f; theKaptonMB = 0.f; + theAluminiumMB = 0.f; theHGC_G10_FR4MB = 0.f; theSiliconMB = 0.f; theStainlessSteelMB = 0.f; @@ -78,6 +79,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theLeadIL = 0.f; theEpoxyIL = 0.f; theKaptonIL = 0.f; + theAluminiumIL = 0.f; theHGC_G10_FR4IL = 0.f; theSiliconIL = 0.f; theStainlessSteelIL = 0.f; @@ -96,6 +98,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theLeadFractionMB = 0.f; theEpoxyFractionMB = 0.f; theKaptonFractionMB = 0.f; + theAluminiumFractionMB = 0.f; theHGC_G10_FR4FractionMB = 0.f; theSiliconFractionMB = 0.f; theStainlessSteelFractionMB = 0.f; @@ -114,6 +117,7 @@ void MaterialBudgetData::dataStartTrack( const G4Track* aTrack ) theLeadFractionIL = 0.f; theEpoxyFractionIL = 0.f; theKaptonFractionIL = 0.f; + theAluminiumFractionIL = 0.f; theHGC_G10_FR4FractionIL = 0.f; theSiliconFractionIL = 0.f; theStainlessSteelFractionIL = 0.f; @@ -167,7 +171,7 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " Eta " << theEta << " Phi " << thePhi << " TotaLMB" << theTotalMB << " theCopperMB " << theCopperMB << " theH_ScintillatorMB " << theH_ScintillatorMB - << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theEpoxyMB " << theEpoxyMB << " theKaptonMB " << theKaptonMB << " theHGC_G10_FR4MB " + << " CAB " << theCablesMB << " theLeadMB " << theLeadMB << " theEpoxyMB " << theEpoxyMB << " theKaptonMB " << theKaptonMB << " theAluminiumMB " << theAluminiumMB << " theHGC_G10_FR4MB " << theHGC_G10_FR4MB << " theSiliconMB " << theSiliconMB << " theAirMB " << theAirMB << " theStainlessSteelMB " << theStainlessSteelMB << " theWCuMB " << theWCuMB; @@ -178,8 +182,8 @@ void MaterialBudgetData::dataEndTrack( const G4Track* aTrack ) << " TotalIL " << theTotalIL << " theCopperIL " << theCopperIL << " theH_ScintillatorIL " << theH_ScintillatorIL << " CAB " << theCablesIL << " theLeadIL " << theLeadIL << " theEpoxyIL " << theEpoxyIL - << " theKaptonIL " << theKaptonIL << " theHGC_G10_FR4IL " << theHGC_G10_FR4IL - << " theSiliconIL " << theSiliconIL << " Air " + << " theKaptonIL " << theKaptonIL << " theAluminiumIL " << theAluminiumIL << " theHGC_G10_FR4IL " + << theHGC_G10_FR4IL << " theSiliconIL " << theSiliconIL << " Air " << theAirIL << " theStainlessSteelIL " << theStainlessSteelIL << " theWCuIL " << theWCuIL << std::endl; } @@ -298,10 +302,13 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theOtherFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[9]; theEpoxyFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[10]; theKaptonFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[11]; + theAluminiumFractionMB = myMaterialBudgetCategorizer->HGCalx0fraction(materialName)[12]; if(theOtherFractionMB!=0) - edm::LogWarning("MaterialBudget") << "MaterialBudgetData: Material found with no category: " << materialName + // edm::LogWarning("MaterialBudget") << "MaterialBudgetData: Material found with no category: " << materialName + // << " in volume " << volumeName << std::endl; + std::cout << "MaterialBudgetData: Material found with no category: " << materialName << " in volume " << volumeName << std::endl; theAirFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[0]; @@ -316,6 +323,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theOtherFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[9]; theEpoxyFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[10]; theKaptonFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[11]; + theAluminiumFractionIL = myMaterialBudgetCategorizer->HGCall0fraction(materialName)[12]; if(theOtherFractionIL!=0) @@ -362,6 +370,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theLeadDmb[theStepN] = (dmb * theLeadFractionMB); theEpoxyDmb[theStepN] = (dmb * theEpoxyFractionMB); theKaptonDmb[theStepN] = (dmb * theKaptonFractionMB); + theAluminiumDmb[theStepN] = (dmb * theAluminiumFractionMB); theHGC_G10_FR4Dmb[theStepN] = (dmb * theHGC_G10_FR4FractionMB); theSiliconDmb[theStepN] = (dmb * theSiliconFractionMB); theStainlessSteelDmb[theStepN] = (dmb * theStainlessSteelFractionMB); @@ -380,6 +389,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theLeadDil[theStepN] = (dil * theLeadFractionIL); theEpoxyDil[theStepN] = (dil * theEpoxyFractionIL); theKaptonDil[theStepN] = (dil * theKaptonFractionIL); + theAluminiumDil[theStepN] = (dil * theAluminiumFractionIL); theHGC_G10_FR4Dil[theStepN] = (dil * theHGC_G10_FR4FractionIL); theSiliconDil[theStepN] = (dil * theSiliconFractionIL); theStainlessSteelDil[theStepN] = (dil * theStainlessSteelFractionIL); @@ -564,6 +574,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theLeadMB += (dmb * theLeadFractionMB); theEpoxyMB += (dmb * theEpoxyFractionMB); theKaptonMB += (dmb * theKaptonFractionMB); + theAluminiumMB += (dmb * theAluminiumFractionMB); theHGC_G10_FR4MB += (dmb * theHGC_G10_FR4FractionMB); theSiliconMB += (dmb * theSiliconFractionMB); theStainlessSteelMB += (dmb * theStainlessSteelFractionMB); @@ -582,6 +593,7 @@ void MaterialBudgetData::dataPerStep( const G4Step* aStep ) theLeadIL += (dil * theLeadFractionIL); theEpoxyIL += (dil * theEpoxyFractionIL); theKaptonIL += (dil * theKaptonFractionIL); + theAluminiumIL += (dil * theAluminiumFractionIL); theHGC_G10_FR4IL += (dil * theHGC_G10_FR4FractionIL); theSiliconIL += (dil * theSiliconFractionIL); theStainlessSteelIL += (dil * theStainlessSteelFractionIL); diff --git a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc index 6b003b587d0ae..8f19bfa3ad51c 100644 --- a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc +++ b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc @@ -181,6 +181,17 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("1270", "MB prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1272", "MB ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // Aluminium + hmgr->addHistoProf1( new TProfile("1310", "MB prof Eta [Aluminium];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("1320", "MB prof Phi [Aluminium];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("1330", "MB prof Eta Phi [Aluminium];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("1340", "MB prof R [Aluminium];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("1350", "MB prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1352", "MB ortho prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("1360", "MB prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1370", "MB prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("1372", "MB ortho prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + //========================================================================================================= // total Lambda0 hmgr->addHistoProf1( new TProfile("10010", "IL prof Eta;#eta;#lambda/#lambda_{0} ", 250, -5., 5. ) ); @@ -328,6 +339,17 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("11270", "IL prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11272", "IL ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + // Aluminium + hmgr->addHistoProf1( new TProfile("11310", "IL prof Eta [Aluminium];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); + hmgr->addHistoProf1( new TProfile("11320", "IL prof Phi [Aluminium];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); + hmgr->addHistoProf2( new TProfile2D("11330", "IL prof Eta Phi [Aluminium];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("11340", "IL prof R [Aluminium];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf2( new TProfile2D("11350", "IL prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11352", "IL ortho prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHisto2( new TH2F("11360", "IL prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11370", "IL prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + hmgr->addHistoProf2( new TProfile2D("11372", "IL ortho prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); + std::cout << "=== booking user histos done ===" << std::endl; @@ -425,6 +447,10 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(1220)->Fill(theData->getPhi(),theData->getKaptonMB()); hmgr->getHistoProf2(1230)->Fill(theData->getEta(),theData->getPhi(),theData->getKaptonMB()); + // Kapton + hmgr->getHistoProf1(1310)->Fill(theData->getEta(),theData->getAluminiumMB()); + hmgr->getHistoProf1(1320)->Fill(theData->getPhi(),theData->getAluminiumMB()); + hmgr->getHistoProf2(1330)->Fill(theData->getEta(),theData->getPhi(),theData->getAluminiumMB()); // // Compute the total x/X0 crossed at each step radius for each path // @@ -442,6 +468,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalMB_LEA = 0.0; float theTotalMB_EPX = 0.0; float theTotalMB_KAP = 0.0; + float theTotalMB_ALU = 0.0; for(int iStep = 0; iStep < theData->getNumberOfSteps(); iStep++) { theTotalMB_TOT += theData->getStepDmb(iStep); theTotalMB_COP += theData->getCopperDmb(iStep); @@ -456,6 +483,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalMB_LEA += theData->getLeadDmb(iStep); theTotalMB_EPX += theData->getEpoxyDmb(iStep); theTotalMB_KAP += theData->getKaptonDmb(iStep); + theTotalMB_ALU += theData->getAluminiumDmb(iStep); int iCop = 0; int iSci = 0; @@ -469,6 +497,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iLea = 0; int iEpx = 0; int iKap = 0; + int iAlu = 0; if( theData->getCopperDmb(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDmb(iStep)>0. ) { iSci = 1; } if( theData->getCablesDmb(iStep)>0. ) { iCab = 1; } @@ -481,6 +510,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getLeadDmb(iStep)>0. ) { iLea = 1; } if( theData->getEpoxyDmb(iStep)>0. ) { iEpx = 1; } if( theData->getKaptonDmb(iStep)>0. ) { iKap = 1; } + if( theData->getAluminiumDmb(iStep)>0. ) { iAlu = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) @@ -637,6 +667,14 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(1270)->Fill(z,polarRadius,iKap*fillValue); hmgr->getHistoProf2(1272)->Fill(z,polarRadius, iKap * fillValue * costhetacorrection ); + // Aluminium + hmgr->getHistoProf1(1340)->Fill(polarRadius,theTotalMB_ALU); + hmgr->getHistoProf2(1350)->Fill(z,polarRadius,theTotalMB_ALU); + hmgr->getHistoProf2(1352)->Fill(z,polarRadius,theTotalMB_ALU * costhetacorrection ); + hmgr->getHisto2(1360)->Fill(z,polarRadius,iAlu*fillValue); + hmgr->getHistoProf2(1370)->Fill(z,polarRadius,iAlu*fillValue); + hmgr->getHistoProf2(1372)->Fill(z,polarRadius, iAlu * fillValue * costhetacorrection ); + } } @@ -706,6 +744,11 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf1(11220)->Fill(theData->getPhi(),theData->getKaptonIL()); hmgr->getHistoProf2(11230)->Fill(theData->getEta(),theData->getPhi(),theData->getKaptonIL()); + // Aluminium + hmgr->getHistoProf1(11310)->Fill(theData->getEta(),theData->getAluminiumIL()); + hmgr->getHistoProf1(11320)->Fill(theData->getPhi(),theData->getAluminiumIL()); + hmgr->getHistoProf2(11330)->Fill(theData->getEta(),theData->getPhi(),theData->getAluminiumIL()); + // Compute the total l/l0 crossed at each step radius for each path float theTotalIL_TOT = 0.0; float theTotalIL_COP = 0.0; @@ -720,6 +763,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() float theTotalIL_LEA = 0.0; float theTotalIL_EPX = 0.0; float theTotalIL_KAP = 0.0; + float theTotalIL_ALU = 0.0; for(int iStep = 0; iStep < theData->getNumberOfSteps(); iStep++) { theTotalIL_TOT += theData->getStepDil(iStep); theTotalIL_COP += theData->getCopperDil(iStep); @@ -734,6 +778,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() theTotalIL_LEA += theData->getLeadDil(iStep); theTotalIL_EPX += theData->getEpoxyDil(iStep); theTotalIL_KAP += theData->getKaptonDil(iStep); + theTotalIL_ALU += theData->getAluminiumDil(iStep); int iCop = 0; int iSci = 0; @@ -747,6 +792,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iLea = 0; int iEpx = 0; int iKap = 0; + int iAlu = 0; if( theData->getCopperDil(iStep)>0. ) { iCop = 1; } if( theData->getH_ScintillatorDil(iStep)>0. ) { iSci = 1; } @@ -760,6 +806,7 @@ void MaterialBudgetHGCalHistos::fillEndTrack() if( theData->getLeadDil(iStep)>0. ) { iLea = 1; } if( theData->getEpoxyDil(iStep)>0. ) { iEpx = 1; } if( theData->getKaptonDil(iStep)>0. ) { iKap = 1; } + if( theData->getAluminiumDil(iStep)>0. ) { iAlu = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) @@ -914,6 +961,14 @@ void MaterialBudgetHGCalHistos::fillEndTrack() hmgr->getHistoProf2(11270)->Fill(z,polarRadius,iKap*fillValue); hmgr->getHistoProf2(11272)->Fill(z,polarRadius, iKap * fillValue * costhetacorrection ); + // Aluminium + hmgr->getHistoProf1(11340)->Fill(polarRadius,theTotalIL_ALU); + hmgr->getHistoProf2(11350)->Fill(z,polarRadius,theTotalIL_ALU); + hmgr->getHistoProf2(11352)->Fill(z,polarRadius,theTotalIL_ALU * costhetacorrection ); + hmgr->getHisto2(11360)->Fill(z,polarRadius,iAlu*fillValue); + hmgr->getHistoProf2(11370)->Fill(z,polarRadius,iAlu*fillValue); + hmgr->getHistoProf2(11372)->Fill(z,polarRadius, iAlu * fillValue * costhetacorrection ); + } } @@ -949,6 +1004,7 @@ void MaterialBudgetHGCalHistos::endOfRun() hmgr->getHisto2(1060)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(1160)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(1260)->Divide(hmgr->getHisto2(999)); + hmgr->getHisto2(1360)->Divide(hmgr->getHisto2(999)); hmgr->getHisto2(10060)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(10160)->Divide(hmgr->getHisto2(1999)); @@ -963,6 +1019,7 @@ void MaterialBudgetHGCalHistos::endOfRun() hmgr->getHisto2(11060)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(11160)->Divide(hmgr->getHisto2(1999)); hmgr->getHisto2(11260)->Divide(hmgr->getHisto2(1999)); + hmgr->getHisto2(11360)->Divide(hmgr->getHisto2(1999)); std::cout << "=== save user histos ===" << std::endl; hmgr->save( theFileName ); diff --git a/Validation/Geometry/test/runP_HGCal_cfg.py b/Validation/Geometry/test/runP_HGCal_cfg.py index 8cc750aa7295e..7a901298d5a0a 100644 --- a/Validation/Geometry/test/runP_HGCal_cfg.py +++ b/Validation/Geometry/test/runP_HGCal_cfg.py @@ -76,7 +76,7 @@ ) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(200) + input = cms.untracked.int32(-1) ) process.p1 = cms.Path(process.g4SimHits) From f68bffa2f31cd6e606674be20ad7c3db001fb0c9 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 3 Apr 2019 11:52:14 +0200 Subject: [PATCH 413/686] Remove useless comment --- SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h b/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h index dfa3d0e54be41..5cd5bc6548549 100644 --- a/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h +++ b/SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h @@ -246,7 +246,7 @@ namespace mtd_digitizer { CLHEP::HepRandomEngine* hre) { if(premixStage1_) { auto simResult = std::make_unique(); - saveSimHitAccumulator(*simResult, simHitAccumulator_, premixStage1MinCharge_, premixStage1MaxCharge_); // FIXME + saveSimHitAccumulator(*simResult, simHitAccumulator_, premixStage1MinCharge_, premixStage1MaxCharge_); e.put(std::move(simResult), digiCollection_); } else { From 0439bf3be8d6cada94af880aa93dae4928d83f19 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Wed, 3 Apr 2019 09:58:48 +0200 Subject: [PATCH 414/686] Comments PR #26266 --- .../interface/backend/HGCalShowerShape.h | 2 ++ L1Trigger/L1THGCal/python/customClustering.py | 36 +++++++++++-------- .../hgcalLayersCalibrationCoefficients_cfi.py | 4 ++- .../src/backend/HGCalHistoClusteringImpl.cc | 14 +------- .../src/backend/HGCalMulticlusteringImpl.cc | 14 +------- .../L1THGCal/src/backend/HGCalShowerShape.cc | 22 ++++++++++++ .../selectors/HGC3DClusterSimpleSelector.cc | 14 ++++---- ...elector.cc => HGC3DClusterTMVASelector.cc} | 4 +-- 8 files changed, 59 insertions(+), 51 deletions(-) rename L1Trigger/L1THGCalUtilities/plugins/selectors/{HGC3DClusterTVMASelector.cc => HGC3DClusterTMVASelector.cc} (94%) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h index 61b0f7ef6db4a..ba234be8a11c2 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h @@ -44,6 +44,8 @@ class HGCalShowerShape{ float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const; float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius=5.) const; + void fillShapes(l1t::HGCalMulticluster&, const HGCalTriggerGeometryBase&) const; + private: float meanX(const std::vector >& energy_X_tc) const; diff --git a/L1Trigger/L1THGCal/python/customClustering.py b/L1Trigger/L1THGCal/python/customClustering.py index 5c22ea3cfd6d0..c7696c0d528b9 100644 --- a/L1Trigger/L1THGCal/python/customClustering.py +++ b/L1Trigger/L1THGCal/python/customClustering.py @@ -8,6 +8,22 @@ 3, 3, 3, 3, 3, 3, 3, 3 # 28 - 35 ) +EE_DR_GROUP = 7 +FH_DR_GROUP = 6 +BH_DR_GROUP = 12 +MAX_LAYERS = 52 + +dr_layerbylayer = ([0] + # no layer 0 + [0.015]*EE_DR_GROUP + [0.020]*EE_DR_GROUP + [0.030]*EE_DR_GROUP + [0.040]*EE_DR_GROUP + # EM + [0.040]*FH_DR_GROUP + [0.050]*FH_DR_GROUP + # FH + [0.050]*BH_DR_GROUP) # BH + + +dr_layerbylayer_Bcoefficient = ([0] + # no layer 0 + [0.020]*EE_DR_GROUP + [0.020]*EE_DR_GROUP + [0.02]*EE_DR_GROUP + [0.020]*EE_DR_GROUP + # EM + [0.020]*FH_DR_GROUP + [0.020]*FH_DR_GROUP + # FH + [0.020]*BH_DR_GROUP) # BH + def custom_2dclustering_distance(process, distance=6.,# cm @@ -107,16 +123,6 @@ def custom_3dclustering_histoSecondaryMax(process, parameters_c3d.type_multicluster = cms.string('HistoSecondaryMaxC3d') return process -dr_layerbylayer = ([0] + # no layer 0 - [0.015]*7 + [0.020]*7 + [0.030]*7 + [0.040]*7 + # EM - [0.040]*6 + [0.050]*6 + # FH - [0.050]*12) # BH - - -dr_layerbylayer_Bcoefficient = ([0] + # no layer 0 - [0.020]*7 + [0.020]*7 + [0.02]*7 + [0.020]*7 + # EM - [0.020]*6 + [0.020]*6 + # FH - [0.020]*12) # BH def custom_3dclustering_histoMax_variableDr(process, distances = dr_layerbylayer, @@ -197,23 +203,23 @@ def custom_3dclustering_clusteringRadiusLayerbyLayerFixedEta(process, distance_c parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters parameters_c3d.dR_multicluster_byLayer_coefficientA = distance_coefficientA - parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*53 ) + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*(MAX_LAYERS+1) ) return process def custom_3dclustering_clusteringRadiusNoLayerDependenceFixedEta(process, distance_coefficientA = 0.03): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters - parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*53 ) - parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*53 ) + parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*(MAX_LAYERS+1) ) + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [0]*(MAX_LAYERS+1) ) return process def custom_3dclustering_clusteringRadiusNoLayerDependenceVariableEta(process, distance_coefficientA = 0.03, distance_coefficientB = 0.02): parameters_c3d = process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters - parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*53 ) - parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [distance_coefficientB]*53 ) + parameters_c3d.dR_multicluster_byLayer_coefficientA = cms.vdouble( [distance_coefficientA]*(MAX_LAYERS+1) ) + parameters_c3d.dR_multicluster_byLayer_coefficientB = cms.vdouble( [distance_coefficientB]*(MAX_LAYERS+1) ) return process diff --git a/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py b/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py index ec5002153e25b..f1f31913e26e5 100644 --- a/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalLayersCalibrationCoefficients_cfi.py @@ -112,11 +112,13 @@ from RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi import dEdX +EE_LAYERS = 28 TrgLayer_dEdX_weights = cms.vdouble() for lid, lw in enumerate(dEdX.weights): - if lid > 29: + if lid > (EE_LAYERS+1): TrgLayer_dEdX_weights.append(lw) else: + # Only half the layers are read in the EE at L1T if (lid % 2) == 1: TrgLayer_dEdX_weights.append(lw+dEdX.weights[lid-1]) else: diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc index b35d2232eec6c..753b73878f537 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoClusteringImpl.cc @@ -159,19 +159,7 @@ finalizeClusters(std::vector& multiclusters_in, if( multicluster.pt() > ptC3dThreshold_ ){ //compute shower shapes - multicluster.showerLength(shape_.showerLength(multicluster)); - multicluster.coreShowerLength(shape_.coreShowerLength(multicluster, triggerGeometry)); - multicluster.firstLayer(shape_.firstLayer(multicluster)); - multicluster.maxLayer(shape_.maxLayer(multicluster)); - multicluster.sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multicluster)); - multicluster.sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multicluster)); - multicluster.sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multicluster)); - multicluster.sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multicluster)); - multicluster.sigmaZZ(shape_.sigmaZZ(multicluster)); - multicluster.sigmaRRTot(shape_.sigmaRRTot(multicluster)); - multicluster.sigmaRRMax(shape_.sigmaRRMax(multicluster)); - multicluster.sigmaRRMean(shape_.sigmaRRMean(multicluster)); - multicluster.eMax(shape_.eMax(multicluster)); + shape_.fillShapes(multicluster, triggerGeometry); // fill quality flag multicluster.setHwQual(id_->decision(multicluster)); // fill H/E diff --git a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc index 6d912c26d4975..c32f8c4f91889 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc @@ -190,19 +190,7 @@ finalizeClusters(std::vector& multiclusters_in, if( multicluster.pt() > ptC3dThreshold_ ){ //compute shower shapes - multicluster.showerLength(shape_.showerLength(multicluster)); - multicluster.coreShowerLength(shape_.coreShowerLength(multicluster, triggerGeometry)); - multicluster.firstLayer(shape_.firstLayer(multicluster)); - multicluster.maxLayer(shape_.maxLayer(multicluster)); - multicluster.sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multicluster)); - multicluster.sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multicluster)); - multicluster.sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multicluster)); - multicluster.sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multicluster)); - multicluster.sigmaZZ(shape_.sigmaZZ(multicluster)); - multicluster.sigmaRRTot(shape_.sigmaRRTot(multicluster)); - multicluster.sigmaRRMax(shape_.sigmaRRMax(multicluster)); - multicluster.sigmaRRMean(shape_.sigmaRRMean(multicluster)); - multicluster.eMax(shape_.eMax(multicluster)); + shape_.fillShapes(multicluster, triggerGeometry); // fill quality flag multicluster.setHwQual(id_->decision(multicluster)); // fill H/E diff --git a/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc b/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc index ef77603b47a2d..2fe43fbdecc16 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc @@ -486,3 +486,25 @@ float HGCalShowerShape::sigmaRRTot(const l1t::HGCalCluster& c2d) const { return Srr; } + + + +void +HGCalShowerShape:: +fillShapes(l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const +{ + c3d.showerLength(showerLength(c3d)); + c3d.coreShowerLength(coreShowerLength(c3d, triggerGeometry)); + c3d.firstLayer(firstLayer(c3d)); + c3d.maxLayer(maxLayer(c3d)); + c3d.sigmaEtaEtaTot(sigmaEtaEtaTot(c3d)); + c3d.sigmaEtaEtaMax(sigmaEtaEtaMax(c3d)); + c3d.sigmaPhiPhiTot(sigmaPhiPhiTot(c3d)); + c3d.sigmaPhiPhiMax(sigmaPhiPhiMax(c3d)); + c3d.sigmaZZ(sigmaZZ(c3d)); + c3d.sigmaRRTot(sigmaRRTot(c3d)); + c3d.sigmaRRMax(sigmaRRMax(c3d)); + c3d.sigmaRRMean(sigmaRRMean(c3d)); + c3d.eMax(eMax(c3d)); +} + diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc index d35223d3be7b8..7be9149f93775 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc @@ -1,5 +1,5 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -8,15 +8,15 @@ #include "CommonTools/Utils/interface/StringCutObjectSelector.h" namespace l1t { - class HGC3DClusterSimpleSelector : public edm::stream::EDProducer<> { + class HGC3DClusterSimpleSelector : public edm::global::EDProducer<> { public: explicit HGC3DClusterSimpleSelector(const edm::ParameterSet&) ; ~HGC3DClusterSimpleSelector() override {} + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; private: - edm::EDGetTokenT src_; - StringCutObjectSelector cut_; - void produce(edm::Event&, const edm::EventSetup&) override; + const edm::EDGetTokenT src_; + const StringCutObjectSelector cut_; }; // class } // namespace @@ -30,9 +30,9 @@ l1t::HGC3DClusterSimpleSelector::HGC3DClusterSimpleSelector(const edm::Parameter void -l1t::HGC3DClusterSimpleSelector::produce(edm::Event & iEvent, const edm::EventSetup &) +l1t::HGC3DClusterSimpleSelector::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup &) const { - std::unique_ptr out(new l1t::HGCalMulticlusterBxCollection()); + std::unique_ptr out = std::make_unique(); edm::Handle multiclusters; iEvent.getByToken(src_, multiclusters); diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc similarity index 94% rename from L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc rename to L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc index d8020af7129f7..c049c3935e026 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTVMASelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc @@ -72,8 +72,8 @@ l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector(const edm::ParameterSet void l1t::HGC3DClusterTMVASelector::produce(edm::Event & iEvent, const edm::EventSetup &) { - std::unique_ptr out(new l1t::HGCalMulticlusterBxCollection()); - std::unique_ptr fail(new l1t::HGCalMulticlusterBxCollection()); + std::unique_ptr out = std::make_unique(); + std::unique_ptr fail = std::make_unique(); edm::Handle multiclusters; iEvent.getByToken(src_, multiclusters); From fa558db8e1f705f0b205e34ddb0c4c6940875996 Mon Sep 17 00:00:00 2001 From: david walter Date: Wed, 3 Apr 2019 12:13:18 +0200 Subject: [PATCH 415/686] move trigger configuration into ZCounting_cff.py --- DQMOffline/Lumi/interface/TTrigger.h | 2 +- DQMOffline/Lumi/plugins/ZCounting.cc | 29 +++++++--- DQMOffline/Lumi/plugins/ZCounting.h | 6 +++ DQMOffline/Lumi/python/ZCounting_cff.py | 3 ++ DQMOffline/Lumi/src/TTrigger.cc | 8 +-- DQMOffline/Lumi/test/ZCounting_cfg.py | 71 ++++++------------------- 6 files changed, 51 insertions(+), 68 deletions(-) diff --git a/DQMOffline/Lumi/interface/TTrigger.h b/DQMOffline/Lumi/interface/TTrigger.h index abc85249be546..1c7ab4d570ec6 100644 --- a/DQMOffline/Lumi/interface/TTrigger.h +++ b/DQMOffline/Lumi/interface/TTrigger.h @@ -9,7 +9,7 @@ namespace ZCountingTrigger class TTrigger { public: - TTrigger(); + TTrigger(std::vector, std::vector); ~TTrigger(){} // Methods diff --git a/DQMOffline/Lumi/plugins/ZCounting.cc b/DQMOffline/Lumi/plugins/ZCounting.cc index b08d9f488794e..99ea9c94b6b7b 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.cc +++ b/DQMOffline/Lumi/plugins/ZCounting.cc @@ -58,6 +58,10 @@ ZCounting::ZCounting(const edm::ParameterSet& iConfig): fMuonName_token = consumes(fMuonName); fTrackName_token = consumes(fTrackName); + // Trigger-specific Parameters + fMuonHLTNames = iConfig.getParameter>("MuonTriggerNames"); + fMuonHLTObjectNames = iConfig.getParameter>("MuonTriggerObjectNames"); + // Electron-specific parameters fGsfElectronName_token = consumes>(fElectronName); fSCName_token = consumes>(fSCName); @@ -120,7 +124,7 @@ void ZCounting::dqmBeginRun(edm::Run const &, edm::EventSetup const &) edm::LogInfo("ZCounting") << "ZCounting::beginRun" << std::endl; // Triggers - fTrigger.reset(new ZCountingTrigger::TTrigger()); + fTrigger.reset(new ZCountingTrigger::TTrigger(fMuonHLTNames,fMuonHLTObjectNames)); } // @@ -129,7 +133,6 @@ void ZCounting::dqmBeginRun(edm::Run const &, edm::EventSetup const &) void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, edm::EventSetup const &) { edm::LogInfo("ZCounting") << "ZCounting::bookHistograms" << std::endl; - ibooker_.cd(); ibooker_.setCurrentFolder("ZCounting/Histograms"); @@ -180,7 +183,7 @@ void ZCounting::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {// Fill event tree on the fly edm::LogInfo("ZCounting") << "ZCounting::analyze" << std::endl; analyzeMuons(iEvent, iSetup); - analyzeElectrons(iEvent, iSetup); + //analyzeElectrons(iEvent, iSetup); } void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -190,8 +193,10 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS //------------------------------- edm::Handle hVertexProduct; iEvent.getByToken(fPVName_token,hVertexProduct); - if(!hVertexProduct.isValid()) return; - + if(!hVertexProduct.isValid()){ + edm::LogWarning("ZCounting") << "ZCounting::analyzeMuons - no valid primary vertex product found" << std::endl; + return; + } const reco::VertexCollection *pvCol = hVertexProduct.product(); const reco::Vertex* pv = &(*pvCol->begin()); int nvtx = 0; @@ -261,7 +266,7 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS TLorentzVector vProbe(0.,0.,0.,0.); TLorentzVector vTrack(0.,0.,0.,0.); - // Tag loop +// Tag loop for(auto const & itMu1 : *hMuonProduct) { float pt1 = itMu1.muonBestTrack()->pt(); @@ -290,6 +295,7 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS if(pt2 < PtCutL2_) continue; if(fabs(eta2) > EtaCutL2_) continue; if(q1 == q2) continue; + std::cout<<"good probe found"< fHLTTag_token; std::string fPVName; edm::EDGetTokenT fPVName_token; + + // Muons std::string fMuonName; edm::EDGetTokenT fMuonName_token; + std::vector fMuonHLTNames; + std::vector fMuonHLTObjectNames; + + // Tracks std::string fTrackName; edm::EDGetTokenT fTrackName_token; diff --git a/DQMOffline/Lumi/python/ZCounting_cff.py b/DQMOffline/Lumi/python/ZCounting_cff.py index 2e9c1424908fd..786c75a5e964f 100644 --- a/DQMOffline/Lumi/python/ZCounting_cff.py +++ b/DQMOffline/Lumi/python/ZCounting_cff.py @@ -17,6 +17,9 @@ beamspotName = cms.InputTag('offlineBeamSpot'), conversionsName = cms.InputTag('conversions'), + MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*"), + MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07"), + IDType = cms.untracked.string("Tight"),# Tight, Medium, Loose IsoType = cms.untracked.string("NULL"), # Tracker-based, PF-based IsoCut = cms.untracked.double(0.), # {0.05, 0.10} for Tracker-based, {0.15, 0.25} for PF-based diff --git a/DQMOffline/Lumi/src/TTrigger.cc b/DQMOffline/Lumi/src/TTrigger.cc index 7887545a5cbc8..2a7df43ebeb62 100644 --- a/DQMOffline/Lumi/src/TTrigger.cc +++ b/DQMOffline/Lumi/src/TTrigger.cc @@ -22,10 +22,12 @@ using namespace ZCountingTrigger; // the trigger can evolve and obtain a different trigger object name, but we still want this to // be associated with the same leg (e.g. the trailing electron in a dielectron trigger) // -TTrigger::TTrigger() { +TTrigger::TTrigger(std::vector muonTriggerNames, std::vector muonTriggerObjectNames) { - fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_IsoMu27_v*",0)); - fRecords.back().objectMap.push_back(std::pair("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07",0)); + for(unsigned int i = 0; i < muonTriggerNames.size(); ++i){ + fRecords.push_back(ZCountingTrigger::TriggerRecord(muonTriggerNames.at(i),0)); + fRecords.back().objectMap.push_back(std::pair(muonTriggerObjectNames.at(i),0)); + } fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele35_WPTight_Gsf_v*",1)); fRecords.back().objectMap.push_back(std::pair("hltEle35noerWPTightGsfTrackIsoFilter",0)); fRecords.push_back(ZCountingTrigger::TriggerRecord("HLT_Ele27_WPTight_Gsf_v*",2)); diff --git a/DQMOffline/Lumi/test/ZCounting_cfg.py b/DQMOffline/Lumi/test/ZCounting_cfg.py index 0cef3300c91e4..3e0f9db624c0a 100644 --- a/DQMOffline/Lumi/test/ZCounting_cfg.py +++ b/DQMOffline/Lumi/test/ZCounting_cfg.py @@ -18,7 +18,9 @@ process.load("DQMServices.Components.DQMEnvironment_cfi") process.MessageLogger.cerr.FwkReport.reportEvery = 1000 -process.GlobalTag.globaltag = '92X_dataRun2_Prompt_v4' +process.GlobalTag.globaltag = '101X_dataRun2_Prompt_v9' +#process.GlobalTag.globaltag = '92X_dataRun2_Prompt_v4' + # trigger filter process.load('HLTrigger/HLTfilters/hltHighLevel_cfi') @@ -28,10 +30,11 @@ from CondCore.CondDB.CondDB_cfi import * -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) ) process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( -'/store/data/Run2017B/SingleMuon/RECO/PromptReco-v1/000/297/218/00000/14C84999-6457-E711-AAE4-02163E0136E0.root' +#'/store/data/Run2017B/SingleMuon/RECO/PromptReco-v1/000/297/218/00000/14C84999-6457-E711-AAE4-02163E0136E0.root' +'file:/eos/cms/store/data/Run2018D/SingleMuon/AOD/22Jan2019-v2/110000/104D2C01-12D2-0742-BE61-897755323EDE.root' ) ) @@ -41,61 +44,17 @@ process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False), Rethrow = cms.untracked.vstring('ProductNotFound'), - fileMode = cms.untracked.string('NOMERGE') + fileMode = cms.untracked.string('FULLMERGE') ) -from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer -process.zcounting = DQMEDAnalyzer('ZCounting', - TriggerEvent = cms.InputTag('hltTriggerSummaryAOD','','HLT'), - TriggerResults = cms.InputTag('TriggerResults','','HLT'), - edmPVName = cms.untracked.string('offlinePrimaryVertices'), - edmName = cms.untracked.string('muons'), - edmTrackName = cms.untracked.string('generalTracks'), - - edmGsfEleName = cms.untracked.string('gedGsfElectrons'), - edmSCName = cms.untracked.string('particleFlowEGamma'), - - effAreasConfigFile = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt"), - - rhoname = cms.InputTag('fixedGridRhoFastjetAll'), - beamspotName = cms.InputTag('offlineBeamSpot'), - conversionsName = cms.InputTag('conversions'), - - IDType = cms.untracked.string("Tight"),# Tight, Medium, Loose - IsoType = cms.untracked.string("NULL"), # Tracker-based, PF-based - IsoCut = cms.untracked.double(0.), # {0.05, 0.10} for Tracker-based, {0.15, 0.25} for PF-based - - PtCutL1 = cms.untracked.double(30.0), - PtCutL2 = cms.untracked.double(30.0), - EtaCutL1 = cms.untracked.double(2.4), - EtaCutL2 = cms.untracked.double(2.4), - - PtCutEleTag = cms.untracked.double(40.0), - PtCutEleProbe = cms.untracked.double(35.0), - EtaCutEleTag = cms.untracked.double(2.5), - EtaCutEleProbe = cms.untracked.double(2.5), - MassCutEleLow = cms.untracked.double(80.0), - MassCutEleHigh = cms.untracked.double(100.0), - - ElectronIDType = cms.untracked.string("TIGHT"), - - MassBin = cms.untracked.int32(50), - MassMin = cms.untracked.double(66.0), - MassMax = cms.untracked.double(116.0), - - LumiBin = cms.untracked.int32(2500), - LumiMin = cms.untracked.double(0.0), - LumiMax = cms.untracked.double(2500.0), - - PVBin = cms.untracked.int32(60), - PVMin = cms.untracked.double(0.0), - PVMax = cms.untracked.double(60.0), - - VtxNTracksFitMin = cms.untracked.double(0.), - VtxNdofMin = cms.untracked.double(4.), - VtxAbsZMax = cms.untracked.double(24.), - VtxRhoMax = cms.untracked.double(2.) - ) + +from DQMOffline.Lumi.ZCounting_cff import zcounting + +process.load("DQMOffline.Lumi.ZCounting_cff") + +process.zcounting.MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*","HLT_IsoMu24_v*") +process.zcounting.MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07", + "hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07") process.DQMoutput = cms.OutputModule("DQMRootOutputModule", fileName = cms.untracked.string("OUT_step1.root")) From 36006f1223e70d35cc7cf760b5db6c600251e998 Mon Sep 17 00:00:00 2001 From: Jan Steggemann Date: Wed, 3 Apr 2019 13:22:12 +0200 Subject: [PATCH 416/686] Rectify coding style and adhere to naming convention --- DataFormats/TauReco/src/classes_def_2.xml | 5 ++++- .../RecoTau/plugins/PFTauMiniAODPrimaryVertexProducer.cc | 2 +- RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DataFormats/TauReco/src/classes_def_2.xml b/DataFormats/TauReco/src/classes_def_2.xml index 282646c1173db..aa18dbb0f2d37 100644 --- a/DataFormats/TauReco/src/classes_def_2.xml +++ b/DataFormats/TauReco/src/classes_def_2.xml @@ -51,7 +51,10 @@ - + ("lostCandidatesTag", edm::InputTag("lostTracks")); desc.add("packedCandidatesTag", edm::InputTag("packedPFCandidates")); - descriptions.add("PFTauMiniAODPrimaryVertexProducer", desc); + descriptions.add("pfTauMiniAODPrimaryVertexProducer", desc); } DEFINE_FWK_MODULE(PFTauMiniAODPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 64e808a9c0cdc..50783393c6ab2 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -43,7 +43,7 @@ void PFTauPrimaryVertexProducer::nonTauTracksInPV(const reco::VertexRef &thePVRe void PFTauPrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { auto desc = PFTauPrimaryVertexProducerBase::getDescriptionsBase(); - descriptions.add("PFTauPrimaryVertexProducer", desc); + descriptions.add("pfTauPrimaryVertexProducer", desc); } DEFINE_FWK_MODULE(PFTauPrimaryVertexProducer); From 37597dd61e42c7a21e9efbf21c08f51972d7d281 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 3 Apr 2019 13:53:33 +0200 Subject: [PATCH 417/686] Added this in unit test --- DetectorDescription/DDCMS/test/runTest.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DetectorDescription/DDCMS/test/runTest.sh b/DetectorDescription/DDCMS/test/runTest.sh index e00361c1626c5..85bdd8b511d69 100755 --- a/DetectorDescription/DDCMS/test/runTest.sh +++ b/DetectorDescription/DDCMS/test/runTest.sh @@ -16,6 +16,7 @@ F11=${LOCAL_TEST_DIR}/python/testMuonGeometry.py F12=${LOCAL_TEST_DIR}/python/testShapes.py F13=${LOCAL_TEST_DIR}/python/testNavigateGeometry.py F14=${LOCAL_TEST_DIR}/python/testTGeoIterator.py +F15=${LOCAL_TEST_DIR}/python/testDDHGCalCellAlgorithm.py echo " testing DetectorDescription/DDCMS" @@ -50,3 +51,5 @@ echo "===== Test \"cmsRun testNavigateGeometry.py\" ====" (cmsRun $F13) || die "Failure using cmsRun $F13" $? echo "===== Test \"cmsRun testTGeoIterator.py\" ====" (cmsRun $F14) || die "Failure using cmsRun $F14" $? +echo "===== Test \"cmsRun testDDHGCalCellAlgorithm.py\" ====" +(cmsRun $F15) || die "Failure using cmsRun $F15" $? From 559a733b86927ec2f3dfc8d231e36411f21b3eae Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 3 Apr 2019 14:47:37 +0200 Subject: [PATCH 418/686] Enlarged xi range, new plots added. --- .../CTPPSProtonReconstructionPlotter.cc | 58 +++++++++++++------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc index a66c7ff5ac0d6..1a924a73ad7b3 100644 --- a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -76,9 +76,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> std::unique_ptr p_th_y_vs_xi; SingleRPPlots() : - h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), - h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), - p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)) + h_xi(new TH1D("", ";#xi", 100, 0., 0.3)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.3)) {} void fill(const reco::ForwardProton &p) @@ -105,24 +105,27 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> struct MultiRPPlots { - std::unique_ptr h_xi, h_th_x, h_th_y, h_vtx_y, h_t, h_chi_sq, h_chi_sq_norm; + std::unique_ptr h_xi, h_th_x, h_th_y, h_vtx_y, h_t_unif, h_t, h_chi_sq, h_chi_sq_norm; std::unique_ptr h_t_xi_range1, h_t_xi_range2, h_t_xi_range3; + std::unique_ptr h_n_tracking_RPs, h_n_timing_RPs; std::unique_ptr h2_th_x_vs_xi, h2_th_y_vs_xi, h2_vtx_y_vs_xi, h2_t_vs_xi; std::unique_ptr p_th_x_vs_xi, p_th_y_vs_xi, p_vtx_y_vs_xi; MultiRPPlots() : - h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), + h_xi(new TH1D("", ";#xi", 100, 0., 0.3)), h_th_x(new TH1D("", ";#theta_{x} (rad)", 100, -500E-6, +500E-6)), h_th_y(new TH1D("", ";#theta_{y} (rad)", 100, -500E-6, +500E-6)), h_vtx_y(new TH1D("", ";vtx_{y} (cm)", 100, -2., +2.)), h_chi_sq(new TH1D("", ";#chi^{2}", 100, 0., 0.)), h_chi_sq_norm(new TH1D("", ";#chi^{2}/ndf", 100, 0., 5.)), - h2_th_x_vs_xi(new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), - h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), - h2_vtx_y_vs_xi(new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25, 100, -500E-3, +500E-3)), - p_th_x_vs_xi(new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25)), - p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)), - p_vtx_y_vs_xi(new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25)) + h_n_tracking_RPs(new TH1D("", ";n of tracking RPs", 4, -0.5, +3.5)), + h_n_timing_RPs(new TH1D("", ";n of timing RPs", 4, -0.5, +3.5)), + h2_th_x_vs_xi(new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.3, 100, -500E-6, +500E-6)), + h2_vtx_y_vs_xi(new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.3, 100, -500E-3, +500E-3)), + p_th_x_vs_xi(new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.3)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.3)), + p_vtx_y_vs_xi(new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.3)) { std::vector v_t_bin_edges; for (double t = 0; t <= 5.; ) { @@ -130,11 +133,12 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> const double de_t = 0.05 + 0.09 * t + 0.02 * t*t; t += de_t; } + h_t_unif.reset(new TH1D("", ";|t| (GeV^2)", 100, 0., 5.)); h_t.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); h_t_xi_range1.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); h_t_xi_range2.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); h_t_xi_range3.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); - h2_t_vs_xi.reset(new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.25, v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h2_t_vs_xi.reset(new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.3, v_t_bin_edges.size() - 1, v_t_bin_edges.data())); } void fill(const reco::ForwardProton &p) @@ -142,6 +146,16 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> if (!p.validFit()) return; + unsigned int n_tracking_RPs=0, n_timing_RPs=0; + for (const auto &tr : p.contributingLocalTracks()) + { + CTPPSDetId detId(tr->getRPId()); + if (detId.subdetId() == CTPPSDetId::sdTrackingStrip || detId.subdetId() == CTPPSDetId::sdTrackingPixel) + n_tracking_RPs++; + if (detId.subdetId() == CTPPSDetId::sdTimingDiamond || detId.subdetId() == CTPPSDetId::sdTimingFastSilicon) + n_timing_RPs++; + } + const double th_x = p.thetaX(); const double th_y = p.thetaY(); const double mt = - p.t(); @@ -150,6 +164,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> if (p.ndof() > 0) h_chi_sq_norm->Fill(p.normalizedChi2()); + h_n_tracking_RPs->Fill(n_tracking_RPs); + h_n_timing_RPs->Fill(n_timing_RPs); + h_xi->Fill(p.xi()); h_th_x->Fill(th_x); @@ -157,6 +174,7 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> h_vtx_y->Fill(p.vertex().y()); + h_t_unif->Fill(mt); h_t->Fill(mt); if (p.xi() > 0.04 && p.xi() < 0.07) h_t_xi_range1->Fill(mt); if (p.xi() > 0.07 && p.xi() < 0.10) h_t_xi_range2->Fill(mt); @@ -177,6 +195,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> h_chi_sq->Write("h_chi_sq"); h_chi_sq_norm->Write("h_chi_sq_norm"); + h_n_tracking_RPs->Write("h_n_tracking_RPs"); + h_n_timing_RPs->Write("h_n_timing_RPs"); + h_xi->Write("h_xi"); h_th_x->Write("h_th_x"); @@ -200,6 +221,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> profileToRMSGraph(p_vtx_y_vs_xi.get(), g_vtx_y_RMS_vs_xi.get()); g_vtx_y_RMS_vs_xi->Write("g_vtx_y_RMS_vs_xi"); + h_t->Scale(1., "width"); + + h_t_unif->Write("h_t_unif"); h_t->Write("h_t"); h_t_xi_range1->Write("h_t_xi_range1"); h_t_xi_range2->Write("h_t_xi_range2"); @@ -222,11 +246,11 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> std::unique_ptr h2_th_y_mu_vs_th_y_si; SingleMultiCorrelationPlots() : - h2_xi_mu_vs_xi_si(new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.25, 100, 0., 0.25)), + h2_xi_mu_vs_xi_si(new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.3, 100, 0., 0.3)), h_xi_diff_mu_si(new TH1D("", ";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1)), h_xi_diff_si_mu(new TH1D("", ";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1)), - h2_xi_diff_si_mu_vs_xi_mu(new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25, 100, -0.10, 0.10)), - p_xi_diff_si_mu_vs_xi_mu(new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25)), + h2_xi_diff_si_mu_vs_xi_mu(new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.3, 100, -0.10, 0.10)), + p_xi_diff_si_mu_vs_xi_mu(new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.3)), h2_th_y_mu_vs_th_y_si(new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6)) {} @@ -272,9 +296,9 @@ class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> ArmCorrelationPlots() : h_xi_si_diffNF(new TH1D("", ";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02)), - p_xi_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.25)), + p_xi_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.3)), h_th_y_si_diffNF(new TH1D("", ";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6)), - p_th_y_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25)) + p_th_y_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.3)) {} void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m) From f3b2161524df81c8ed8d8b1711ebc38a32697088 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 3 Apr 2019 14:48:34 +0200 Subject: [PATCH 419/686] Timing parameters: added to constructor, added setters. --- DataFormats/ProtonReco/interface/ForwardProton.h | 8 ++++++-- DataFormats/ProtonReco/src/ForwardProton.cc | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h index f438c519ea245..ad47b5ad86cb6 100644 --- a/DataFormats/ProtonReco/interface/ForwardProton.h +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -38,8 +38,9 @@ namespace reco ForwardProton(); /// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, - const CovarianceMatrix& cov, ReconstructionMethod method, - const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ); + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid, + const float time=0., const float time_err=0. ); /// fitted vertex position const Point& vertex() const { return vertex_; } @@ -107,8 +108,11 @@ namespace reco /// time of proton arrival at forward stations float time() const { return time_; } + void setTime(float time) { time_ = time; } + /// uncertainty on time of proton arrival at forward stations float timeError() const { return time_err_; } + void setTimeError(float time_err) { time_err_ = time_err; } /// set the flag for the fit validity void setValidFit( bool valid = true ) { valid_fit_ = valid; } diff --git a/DataFormats/ProtonReco/src/ForwardProton.cc b/DataFormats/ProtonReco/src/ForwardProton.cc index 1a650733cbd8a..b9b9c95d25557 100644 --- a/DataFormats/ProtonReco/src/ForwardProton.cc +++ b/DataFormats/ProtonReco/src/ForwardProton.cc @@ -17,9 +17,10 @@ ForwardProton::ForwardProton() : ForwardProton::ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, const CovarianceMatrix& cov, ReconstructionMethod method, - const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid, + const float time, const float time_err ) : vertex_( vtx ), momentum_( momentum ), - time_( 0. ), time_err_( 0. ), xi_( xi ), + time_( time ), time_err_( time_err ), xi_( xi ), covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), valid_fit_( valid ), method_( method ), contributing_local_tracks_( local_tracks ) {} From fbe892c1bad0e184a0da34178b486ce26ffe7654 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Apr 2019 07:49:13 -0500 Subject: [PATCH 420/686] Added missing skipEvents to LHESource When the LHESource gained a fillDescriptions validator, that function did not include 'skipEvents' as an allowed parameter. --- GeneratorInterface/LHEInterface/plugins/LHESource.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/GeneratorInterface/LHEInterface/plugins/LHESource.cc b/GeneratorInterface/LHEInterface/plugins/LHESource.cc index 577fa9d160b0e..a072d5ad54af7 100644 --- a/GeneratorInterface/LHEInterface/plugins/LHESource.cc +++ b/GeneratorInterface/LHEInterface/plugins/LHESource.cc @@ -205,6 +205,7 @@ LHESource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.setComment("A source which reads LHE files."); edm::ProducerSourceFromFiles::fillDescription(desc); + desc.addUntracked("skipEvents", 0U)->setComment("Skip the first 'skipEvents' events."); descriptions.add("source", desc); } From 10b4881f26ee38de7caa57dd2ce03751b20d75fb Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 3 Apr 2019 14:51:31 +0200 Subject: [PATCH 421/686] Added checks, added missing resize. --- .../CTPPSInterpolatedOpticalFunctionsESSource.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc index d4db89148683a..d56847c8b9384 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -159,16 +159,22 @@ std::shared_ptr CTPPSInterpolatedO const auto rpId = rp_p.first; const auto &rp_it2 = ofs2.find(rpId); if (rp_it2 == ofs2.end()) - throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Mismatch between ofs1 and ofs2."; + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "RP mismatch between ofs1 and ofs2."; const auto &of1 = rp_p.second; const auto &of2 = rp_it2->second; - LHCInterpolatedOpticalFunctionsSet iof; - iof.m_z = of1.getScoringPlaneZ(); + const size_t num_xi_vals1 = of1.getXiValues().size(); + const size_t num_xi_vals2 = of2.getXiValues().size(); + + if (num_xi_vals1 != num_xi_vals2) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Size mismatch between ofs1 and ofs2."; - const size_t num_xi_vals = of1.getXiValues().size(); + const size_t num_xi_vals = num_xi_vals1; + LHCInterpolatedOpticalFunctionsSet iof; + iof.m_z = of1.getScoringPlaneZ(); + iof.m_fcn_values.resize(LHCInterpolatedOpticalFunctionsSet::nFunctions); iof.m_xi_values.resize(num_xi_vals); for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) From 61ba17746bfc3c63605d96f914345a11d61c27e9 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 3 Apr 2019 14:57:40 +0200 Subject: [PATCH 422/686] Multiple configurations/IOVs can be provided. --- .../plugins/CTPPSOpticalFunctionsESSource.cc | 130 +++++++++++------- .../python/ctppsOpticalFunctions_cff.py | 18 +-- 2 files changed, 87 insertions(+), 61 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc index cf1d7f4c28cc8..f9284a0f2746c 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc @@ -6,7 +6,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" -#include "FWCore/Framework/interface/ESProducts.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" #include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" @@ -22,51 +21,67 @@ class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSe CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); ~CTPPSOpticalFunctionsESSource() override = default; - edm::ESProducts> produce(const CTPPSOpticsRcd &); + std::unique_ptr produce(const CTPPSOpticsRcd &); static void fillDescriptions(edm::ConfigurationDescriptions&); private: void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; - edm::EventRange m_validityRange; - bool m_insideValidityRange; - struct FileInfo { - double xangle; - std::string fileName; + double m_xangle; + std::string m_fileName; }; - std::vector m_fileInfo; struct RPInfo { - std::string dirName; - double scoringPlaneZ; + std::string m_dirName; + double m_scoringPlaneZ; + }; + + struct Entry + { + edm::EventRange m_validityRange; + std::vector m_fileInfo; + std::unordered_map m_rpInfo; }; - std::unordered_map m_rpInfo; + + std::vector m_entries; + + bool m_currentEntryValid; + unsigned int m_currentEntry; }; //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) : - m_validityRange(conf.getParameter("validityRange")), - m_insideValidityRange(false) + m_currentEntryValid(false), + m_currentEntry(0) { - for (const auto &pset : conf.getParameter>("opticalFunctions")) + for (const auto &entry_pset : conf.getParameter>("configuration")) { - const double &xangle = pset.getParameter("xangle"); - const std::string &fileName = pset.getParameter("fileName").fullPath(); - m_fileInfo.push_back({xangle, fileName}); - } + edm::EventRange validityRange = entry_pset.getParameter("validityRange"); - for (const auto &pset : conf.getParameter>("scoringPlanes")) - { - const unsigned int rpId = pset.getParameter("rpId"); - const std::string dirName = pset.getParameter("dirName"); - const double z = pset.getParameter("z"); - const RPInfo entry = {dirName, z}; - m_rpInfo.emplace(rpId, entry); + std::vector fileInfo; + for (const auto &pset : entry_pset.getParameter>("opticalFunctions")) + { + const double &xangle = pset.getParameter("xangle"); + const std::string &fileName = pset.getParameter("fileName").fullPath(); + fileInfo.push_back({xangle, fileName}); + } + + std::unordered_map rpInfo; + for (const auto &pset : entry_pset.getParameter>("scoringPlanes")) + { + const unsigned int rpId = pset.getParameter("rpId"); + const std::string dirName = pset.getParameter("dirName"); + const double z = pset.getParameter("z"); + const RPInfo entry = {dirName, z}; + rpInfo.emplace(rpId, entry); + } + + m_entries.push_back({validityRange, fileInfo, rpInfo}); } setWhatProduced(this); @@ -78,56 +93,60 @@ CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::Paramete void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { - if (edm::contains(m_validityRange, iosv.eventID())) + for (unsigned int idx = 0; idx < m_entries.size(); ++idx) { - m_insideValidityRange = true; - oValidity = edm::ValidityInterval(edm::IOVSyncValue(m_validityRange.startEventID()), edm::IOVSyncValue(m_validityRange.endEventID())); - } else { - m_insideValidityRange = false; + const auto &entry = m_entries[idx]; - if (iosv.eventID() < m_validityRange.startEventID()) + // is within an entry ? + if (edm::contains(entry.m_validityRange, iosv.eventID())) { - edm::RunNumber_t run = m_validityRange.startEventID().run(); - edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); - edm::EventID endEvent = (lb > 1) ? edm::EventID(run, lb-1, 0) : edm::EventID(run-1, edm::EventID::maxLuminosityBlockNumber(), 0); - - oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(endEvent)); - } else { - edm::RunNumber_t run = m_validityRange.startEventID().run(); - edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); - edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber()-1) ? edm::EventID(run, lb+1, 0) : edm::EventID(run+1, 0, 0); - - oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); + m_currentEntryValid = true; + m_currentEntry = idx; + oValidity = edm::ValidityInterval(edm::IOVSyncValue(entry.m_validityRange.startEventID()), edm::IOVSyncValue(entry.m_validityRange.endEventID())); + return; } } + + // not within any entry + m_currentEntryValid = true; + m_currentEntry = 0; + + edm::LogInfo("") << "No configuration entry found for event " << iosv.eventID() << ", no optical functions will be available."; + + const edm::EventID start(iosv.eventID().run(), iosv.eventID().luminosityBlock(), iosv.eventID().event()); + const edm::EventID end(iosv.eventID().run(), iosv.eventID().luminosityBlock(), iosv.eventID().event()); + oValidity = edm::ValidityInterval(edm::IOVSyncValue(start), edm::IOVSyncValue(end)); } //---------------------------------------------------------------------------------------------------- -edm::ESProducts > +std::unique_ptr CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) { - // fill the output + // prepare output, empty by default auto output = std::make_unique(); - if (m_insideValidityRange) + // fill the output + if (m_currentEntryValid) { - for (const auto &fi : m_fileInfo) + const auto &entry = m_entries[m_currentEntry]; + + for (const auto &fi : entry.m_fileInfo) { std::unordered_map xa_data; - for (const auto &rpi : m_rpInfo) + for (const auto &rpi : entry.m_rpInfo) { - LHCOpticalFunctionsSet fcn(fi.fileName, rpi.second.dirName, rpi.second.scoringPlaneZ); + LHCOpticalFunctionsSet fcn(fi.m_fileName, rpi.second.m_dirName, rpi.second.m_scoringPlaneZ); xa_data.emplace(rpi.first, std::move(fcn)); } - output->emplace(fi.xangle, xa_data); + output->emplace(fi.m_xangle, xa_data); } } // commit the output - return edm::es::products(std::move(output)); + return output; } //---------------------------------------------------------------------------------------------------- @@ -137,20 +156,25 @@ CTPPSOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions& { edm::ParameterSetDescription desc; - desc.add("validityRange", edm::EventRange())->setComment("interval of validity"); + edm::ParameterSetDescription config_desc; + + config_desc.add("validityRange", edm::EventRange())->setComment("interval of validity"); edm::ParameterSetDescription of_desc; of_desc.add("xangle")->setComment("half crossing angle value in urad"); of_desc.add("fileName")->setComment("ROOT file with optical functions"); std::vector of; - desc.addVPSet("opticalFunctions", of_desc, of)->setComment("list of optical functions at different crossing angles"); + config_desc.addVPSet("opticalFunctions", of_desc, of)->setComment("list of optical functions at different crossing angles"); edm::ParameterSetDescription sp_desc; sp_desc.add("rpId")->setComment("associated detector DetId"); sp_desc.add("dirName")->setComment("associated path to the optical functions file"); sp_desc.add("z")->setComment("longitudinal position at scoring plane/detector"); std::vector sp; - desc.addVPSet("scoringPlanes", sp_desc, sp)->setComment("list of sensitive planes/detectors stations"); + config_desc.addVPSet("scoringPlanes", sp_desc, sp)->setComment("list of sensitive planes/detectors stations"); + + std::vector config; + desc.addVPSet("configuration", config_desc, sp)->setComment("list of configuration blocks"); descriptions.add("ctppsOpticalFunctionsESSource", desc); } diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py index 5a6068db262c4..05c2dae04514e 100644 --- a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -2,11 +2,11 @@ from CalibPPS.ESProducers.ctppsLHCInfo_cff import * -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import * -# optical functions for 2016 data -ctppsOpticalFunctionsESSource_2016 = _optics_tmp.clone( - validityRange = cms.EventRange("270293:min - 290872:max"), +# add 2016 pre-TS2 configuration +config_2016_preTS2 = cms.PSet( + validityRange = cms.EventRange("273725:min - 280385:max"), opticalFunctions = cms.VPSet( cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) @@ -14,13 +14,15 @@ scoringPlanes = cms.VPSet( # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002, strip + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003, strip + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102, strip + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103, strip ) ) +ctppsOpticalFunctionsESSource.configuration.append(config_2016_preTS2) + # optics interpolation between crossing angles from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import * ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ctppsLHCInfoLabel From baa62b210d64590becaedf1e1526af8d83d251cc Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 3 Apr 2019 14:59:49 +0200 Subject: [PATCH 423/686] Additional algorithms added. --- RecoCTPPS/ProtonReconstruction/BuildFile.xml | 4 + .../interface/ProtonReconstructionAlgorithm.h | 6 +- .../plugins/CTPPSProtonProducer.cc | 313 ++++++++++++++++-- .../src/ProtonReconstructionAlgorithm.cc | 104 +++--- 4 files changed, 327 insertions(+), 100 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/BuildFile.xml b/RecoCTPPS/ProtonReconstruction/BuildFile.xml index a87f2226bea56..b097e3ca679ce 100644 --- a/RecoCTPPS/ProtonReconstruction/BuildFile.xml +++ b/RecoCTPPS/ProtonReconstruction/BuildFile.xml @@ -8,6 +8,10 @@ + + + + diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index 558f8060e91a2..160bf9c8914c2 100644 --- a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -33,13 +33,11 @@ class ProtonReconstructionAlgorithm void release(); /// run proton reconstruction using single-RP strategy - void reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& input, - reco::ForwardProtonCollection& output, + reco::ForwardProton reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track, const LHCInfo& lhcInfo, std::ostream& os) const; /// run proton reconstruction using multiple-RP strategy - void reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& input, - reco::ForwardProtonCollection& output, + reco::ForwardProton reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector &tracks, const LHCInfo& lhcInfo, std::ostream& os) const; private: diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index d53e20e6a613e..ea891c8fe40d3 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -27,6 +27,9 @@ #include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" +#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" +#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" + //---------------------------------------------------------------------------------------------------- class CTPPSProtonProducer : public edm::stream::EDProducer<> @@ -52,6 +55,24 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> std::string singleRPReconstructionLabel_; std::string multiRPReconstructionLabel_; + double localAngleXMin_, localAngleXMax_, localAngleYMin_, localAngleYMax_; + + struct AssociationCuts + { + bool x_cut_apply; + double x_cut_value; + bool y_cut_apply; + double y_cut_value; + bool xi_cut_apply; + double xi_cut_value; + bool th_y_cut_apply; + double th_y_cut_value; + }; + + std::map association_cuts_; // map: arm -> AssociationCuts + + unsigned int max_n_timing_tracks_; + ProtonReconstructionAlgorithm algorithm_; bool opticsValid_; @@ -68,10 +89,32 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), multiRPReconstructionLabel_ (iConfig.getParameter("multiRPReconstructionLabel")), + + localAngleXMin_ (iConfig.getParameter("localAngleXMin")), + localAngleXMax_ (iConfig.getParameter("localAngleXMax")), + localAngleYMin_ (iConfig.getParameter("localAngleYMin")), + localAngleYMax_ (iConfig.getParameter("localAngleYMax")), + + max_n_timing_tracks_ (iConfig.getParameter("max_n_timing_tracks")), + algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), opticsValid_(false), currentCrossingAngle_(-1.) { + for (const std::string §or : { "45", "56" }) + { + const unsigned int arm = (sector == "45") ? 0 : 1; + + association_cuts_[arm].x_cut_apply = iConfig.getParameter ("association_" + sector + "_x_cut_apply"); + association_cuts_[arm].x_cut_value = iConfig.getParameter("association_" + sector + "_x_cut_value"); + association_cuts_[arm].y_cut_apply = iConfig.getParameter ("association_" + sector + "_y_cut_apply"); + association_cuts_[arm].y_cut_value = iConfig.getParameter("association_" + sector + "_y_cut_value"); + association_cuts_[arm].xi_cut_apply = iConfig.getParameter ("association_" + sector + "_xi_cut_apply"); + association_cuts_[arm].xi_cut_value = iConfig.getParameter("association_" + sector + "_xi_cut_value"); + association_cuts_[arm].th_y_cut_apply = iConfig.getParameter ("association_" + sector + "_th_y_cut_apply"); + association_cuts_[arm].th_y_cut_value = iConfig.getParameter("association_" + sector + "_th_y_cut_value"); + } + if (doSingleRPReconstruction_) produces(singleRPReconstructionLabel_); @@ -105,6 +148,31 @@ void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("multiRPReconstructionLabel", "multiRP") ->setComment("output label for multi-RP reconstruction products"); + desc.add("localAngleXMin", -0.03)->setComment("minimal accepted value of local horizontal angle (rad)"); + desc.add("localAngleXMax", +0.03)->setComment("maximal accepted value of local horizontal angle (rad)"); + desc.add("localAngleYMin", -0.04)->setComment("minimal accepted value of local vertical angle (rad)"); + desc.add("localAngleYMax", +0.04)->setComment("maximal accepted value of local vertical angle (rad)"); + + desc.add("association_45_x_cut_apply", false)->setComment("whether to apply track-association cut in x, sector 45"); + desc.add("association_45_x_cut_value", 800E-6)->setComment("threshold of track-association cut in x, mm, sector 45"); + desc.add("association_45_y_cut_apply", false)->setComment("whether to apply track-association cut in y, sector 45"); + desc.add("association_45_y_cut_value", 600E-6)->setComment("threshold of track-association cut in y, mm, sector 45"); + desc.add("association_45_xi_cut_apply", true)->setComment("whether to apply track-association cut in xi, sector 45"); + desc.add("association_45_xi_cut_value", 0.013)->setComment("threshold of track-association cut in xi, sector 45"); + desc.add("association_45_th_y_cut_apply", true)->setComment("whether to apply track-association cut in th_y, sector 45"); + desc.add("association_45_th_y_cut_value", 20E-6)->setComment("threshold of track-association cut in th_y, rad, sector 45"); + + desc.add("association_56_x_cut_apply", false)->setComment("whether to apply track-association cut in x, sector 56"); + desc.add("association_56_x_cut_value", 800E-6)->setComment("threshold of track-association cut in x, mm, sector 56"); + desc.add("association_56_y_cut_apply", false)->setComment("whether to apply track-association cut in y, sector 56"); + desc.add("association_56_y_cut_value", 600E-6)->setComment("threshold of track-association cut in y, mm, sector 56"); + desc.add("association_56_xi_cut_apply", true)->setComment("whether to apply track-association cut in xi, sector 56"); + desc.add("association_56_xi_cut_value", 0.013)->setComment("threshold of track-association cut in xi, sector 56"); + desc.add("association_56_th_y_cut_apply", true)->setComment("whether to apply track-association cut in th_y, sector 56"); + desc.add("association_56_th_y_cut_value", 20E-6)->setComment("threshold of track-association cut in th_y, rad, sector 56"); + + desc.add("max_n_timing_tracks", 5)->setComment("maximum number of timing tracks per RP"); + desc.add("fitVtxY", true) ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); @@ -125,6 +193,9 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe edm::ESHandle hOpticalFunctions; iSetup.get().get(hOpticalFunctions); + edm::ESHandle hGeometry; + iSetup.get().get(hGeometry); + // re-initialise algorithm upon crossing-angle change if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { currentCrossingAngle_ = hLHCInfo->crossingAngle(); @@ -150,60 +221,230 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // prepare log std::ostringstream ssLog; if (verbosity_) - ssLog << "input tracks:"; + ssLog << "* input tracks:" << std::endl; // get input edm::Handle hTracks; iEvent.getByToken(tracksToken_, hTracks); - // keep only tracks from tracker RPs, split them by LHC sector - CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; - std::map nTracksPerRP; - for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { + // select tracks with small local angles, split them by LHC sector and tracker/timing RPs + std::map> trackingSelection, timingSelection; + + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) + { const auto& tr = hTracks->at(idx); - const CTPPSDetId rpId(tr.getRPId()); - if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) + + if (tr.getTx() < localAngleXMin_ || tr.getTx() > localAngleXMax_ + || tr.getTy() < localAngleYMin_ || tr.getTy() > localAngleYMax_) continue; + const CTPPSDetId rpId(tr.getRPId()); + if (verbosity_) - ssLog << "\n\t" + ssLog << "\t" + << "[" << idx << "] " << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " - << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; + << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; - CTPPSLocalTrackLiteRef r_track(hTracks, idx); - if (rpId.arm() == 0) - tracks_45.push_back(r_track); - if (rpId.arm() == 1) - tracks_56.push_back(r_track); + const bool trackerRP = (rpId.subdetId() == CTPPSDetId::sdTrackingStrip || rpId.subdetId() == CTPPSDetId::sdTrackingPixel); - nTracksPerRP[rpId]++; + if (trackerRP) + trackingSelection[rpId.arm()].push_back(idx); + else + timingSelection[rpId.arm()].push_back(idx); } - // for the moment: check whether there is no more than 1 track in each arm - bool singleTrack_45 = true, singleTrack_56 = true; - for (const auto& detid_num : nTracksPerRP) { - if (detid_num.second > 1) { - const CTPPSDetId& rpId = detid_num.first; - if (rpId.arm() == 0) - singleTrack_45 = false; - if (rpId.arm() == 1) - singleTrack_56 = false; + // process each arm + for (const auto &arm_it : trackingSelection) + { + const auto &indeces = arm_it.second; + + const auto &ac = association_cuts_[arm_it.first]; + + // do single-RP reco if needed + std::map singleRPResultsIndexed; + if (doSingleRPReconstruction_ || ac.xi_cut_apply || ac.th_y_cut_apply) + { + for (const auto &idx : indeces) + { + if (verbosity_) + ssLog << std::endl << "* reconstruction from track " << idx << std::endl; + + singleRPResultsIndexed[idx] = algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), *hLHCInfo, ssLog); + } } - } - // single-RP reconstruction - if (doSingleRPReconstruction_) { - algorithm_.reconstructFromSingleRP(tracks_45, *pOutSingleRP, *hLHCInfo, ssLog); - algorithm_.reconstructFromSingleRP(tracks_56, *pOutSingleRP, *hLHCInfo, ssLog); - } + // do multi-RP reco if chosen + if (doMultiRPReconstruction_) + { + // check that exactly two tracking RPs are involved + // - 1 is insufficient for multi-RP reconstruction + // - PPS did not use more than 2 tracking RPs per arm -> algorithms are tuned to this + std::set rpIds; + for (const auto &idx : indeces) + rpIds.insert(hTracks->at(idx).getRPId()); + if (rpIds.size() != 2) + continue; + + // find matching track pairs from different tracking RPs + std::vector> idx_pairs; + std::map idx_pair_multiplicity; + for (const auto &i : indeces) + { + for (const auto &j : indeces) + { + if (j <= i) + continue; + + const auto &tr_i = hTracks->at(i); + const auto &tr_j = hTracks->at(j); + + const auto &pr_i = singleRPResultsIndexed[i]; + const auto &pr_j = singleRPResultsIndexed[j]; + + if (tr_i.getRPId() == tr_j.getRPId()) + continue; + + bool matching = true; + + if (ac.x_cut_apply && fabs(tr_i.getX() - tr_j.getX()) > ac.x_cut_value) + matching = false; + if (ac.y_cut_apply && fabs(tr_i.getY() - tr_j.getY()) > ac.y_cut_value) + matching = false; + if (ac.xi_cut_apply && fabs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value) + matching = false; + if (ac.th_y_cut_apply && fabs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value) + matching = false; + + if (!matching) + continue; + + idx_pairs.emplace_back(i, j); + idx_pair_multiplicity[i]++; + idx_pair_multiplicity[j]++; + } + } + + // evaluate track multiplicity in each timing RP + std::map timing_RP_track_multiplicity; + for (const auto &ti : timingSelection[arm_it.first]) + { + const auto &tr = hTracks->at(ti); + timing_RP_track_multiplicity[tr.getRPId()]++; + } + + // associate tracking-RP pairs with timing-RP tracks + std::map> mached_timing_track_indeces; + std::map matched_timing_track_multiplicity; + for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) + { + const auto &i = idx_pairs[pr_idx].first; + const auto &j = idx_pairs[pr_idx].second; + + // skip non-unique associations + if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) + continue; + + const auto &tr_i = hTracks->at(i); + const auto &tr_j = hTracks->at(j); + + const double z_i = hGeometry->getRPTranslation(tr_i.getRPId()).z(); + const double z_j = hGeometry->getRPTranslation(tr_j.getRPId()).z(); + + for (const auto &ti : timingSelection[arm_it.first]) + { + const auto &tr_ti = hTracks->at(ti); + + // skip if timing RP saturated (high track multiplicity) + if (timing_RP_track_multiplicity[tr_ti.getRPId()] > max_n_timing_tracks_) + continue; + + // interpolation from tracking RPs + const double z_ti = - hGeometry->getRPTranslation(tr_ti.getRPId()).z(); // the minus sign fixes a bug in the diamond geometry + const double f_i = (z_ti - z_j) / (z_i - z_j), f_j = (z_i - z_ti) / (z_i - z_j); + const double x_inter = f_i * tr_i.getX() + f_j * tr_j.getX(); + const double x_inter_unc_sq = f_i*f_i * tr_i.getXUnc()*tr_i.getXUnc() + f_j*f_j * tr_j.getXUnc()*tr_j.getXUnc(); + + const double de_x = tr_ti.getX() - x_inter; + const double de_x_unc = sqrt(tr_ti.getXUnc()*tr_ti.getXUnc() + x_inter_unc_sq); + + const bool matching = (fabs(de_x) <= de_x_unc); + + ssLog << "ti=" << ti << ", i=" << i << ", j=" << j + << " | z_ti=" << z_ti << ", z_i=" << z_i << ", z_j=" << z_j + << " | x_ti=" << tr_ti.getX() << ", x_inter=" << x_inter << ", de_x=" << de_x << ", de_x_unc=" << de_x_unc + << ", matching=" << matching << std::endl; + + if (!matching) + continue; + + mached_timing_track_indeces[pr_idx].push_back(ti); + matched_timing_track_multiplicity[ti]++; + } + } + + // process associated tracks + for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) + { + const auto &i = idx_pairs[pr_idx].first; + const auto &j = idx_pairs[pr_idx].second; + + // skip non-unique associations of tracking-RP tracks + if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) + continue; + + if (verbosity_) + ssLog << std::endl << "* reconstruction from tracking-RP tracks: " << i << ", " << j << " and timing-RP tracks: "; + + // process tracking-RP data + CTPPSLocalTrackLiteRefVector sel_tracks; + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, i)); + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, j)); + reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_tracks, *hLHCInfo, ssLog); + + // process timing-RP data + double Sw=0., Swt=0.; + for (const auto &ti : mached_timing_track_indeces[pr_idx]) + { + // skip non-unique associations of timing-RP tracks + if (matched_timing_track_multiplicity[ti] > 1) + continue; + + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, ti)); + + if (verbosity_) + ssLog << ti << ", "; + + const auto &tr = hTracks->at(ti); + const double t_unc = tr.getTimeUnc(); + const double w = (t_unc > 0.) ? 1./t_unc/t_unc : 1.; + Sw += w; + Swt += w * tr.getTime(); + } + + float time = 0., time_unc = 0.; + if (Sw > 0.) + { + time = Swt / Sw; + time_unc = 1. / sqrt(Sw); + } + + if (verbosity_) + ssLog << std::endl << " time = " << time << " +- " << time_unc << std::endl; + + // save combined output + proton.setContributingLocalTracks(sel_tracks); + proton.setTime(time); + proton.setTimeError(time_unc); + + pOutMultiRP->emplace_back(proton); + } + } - // multi-RP reconstruction - if (doMultiRPReconstruction_) { - if (singleTrack_45) - algorithm_.reconstructFromMultiRP(tracks_45, *pOutMultiRP, *hLHCInfo, ssLog); - if (singleTrack_56) - algorithm_.reconstructFromMultiRP(tracks_56, *pOutMultiRP, *hLHCInfo, ssLog); + // save single-RP results (un-indexed) + for (const auto &p : singleRPResultsIndexed) + pOutSingleRP->emplace_back(std::move(p.second)); } // dump log diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index a923bd072e658..2a525d4686d55 100644 --- a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -141,17 +141,9 @@ double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const dou //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& tracks, - reco::ForwardProtonCollection& output, - const LHCInfo& lhcInfo, std::ostream& os) const +reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& tracks, + const LHCInfo& lhcInfo, std::ostream& os) const { - if (!initialized_) - return; - - // need at least two tracks - if (tracks.size() < 2) - return; - // make sure optics is available for all tracks for (const auto &it : tracks) { auto oit = m_rp_optics_.find(it->getRPId()); @@ -223,10 +215,10 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrack unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); if (verbosity_) - os << "\n" + os << "ProtonReconstructionAlgorithm::reconstructFromMultiRP(" << armId << ")" << std::endl << " initial estimate: xi_init = " << xi_init << ", th_x_init = " << th_x_init - << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "."; + << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "." << std::endl; // minimisation fitter_->Config().ParSettings(0).Set("xi", xi_init, 0.005); @@ -248,12 +240,12 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrack const double *params = result.GetParams(); if (verbosity_) - os << "\n" - << "xi=" << params[0] << " +- " << result.Error(0) + os + << " xi=" << params[0] << " +- " << result.Error(0) << ", th_x=" << params[1] << " +-" << result.Error(1) << ", th_y=" << params[2] << " +-" << result.Error(2) << ", vtx_y=" << params[3] << " +-" << result.Error(3) - << ", chiSq = " << result.Chi2(); + << ", chiSq = " << result.Chi2() << std::endl; // save reco candidate using FP = reco::ForwardProton; @@ -291,67 +283,59 @@ void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrack } } - output.emplace_back(result.Chi2(), ndf, vertex, momentum, xi, cm, FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); + return reco::ForwardProton(result.Chi2(), ndf, vertex, momentum, xi, cm, + FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); } //---------------------------------------------------------------------------------------------------- -void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& tracks, - reco::ForwardProtonCollection& output, +reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track, const LHCInfo& lhcInfo, std::ostream& os) const { - if (!initialized_) - return; - - // make sure optics is available for all tracks - for (const auto &it : tracks) { - auto oit = m_rp_optics_.find(it->getRPId()); - if (oit == m_rp_optics_.end()) - throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << it->getRPId() - << ", i.e. " << CTPPSDetId(it->getRPId()) << "."; - } + CTPPSDetId rpId(track->getRPId()); - // rough estimate of xi and th_y from each track - for (const auto &track : tracks) { - CTPPSDetId rpId(track->getRPId()); + if (verbosity_) + os << "reconstructFromSingleRP(" << rpId.arm()*100 + rpId.station()*10 + rpId.rp() << ")" << std::endl; - if (verbosity_) - os << "\nreconstructFromSingleRP(" << rpId.arm()*100 + rpId.station()*10 + rpId.rp() << ")"; + // make sure optics is available for the track + auto oit = m_rp_optics_.find(track->getRPId()); + if (oit == m_rp_optics_.end()) + throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << track->getRPId() + << ", i.e. " << rpId << "."; - auto oit = m_rp_optics_.find(track->getRPId()); - const double x_full = track->getX()*1E-1 + oit->second.x0; // conversion mm --> cm - const double xi = oit->second.s_xi_vs_x_d->Eval(x_full); - const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); - const double th_y = track->getY()*1E-1 / L_y; // conversion mm --> cm + // rough estimate of xi and th_y from each track + const double x_full = track->getX()*1E-1 + oit->second.x0; // conversion mm --> cm + const double xi = oit->second.s_xi_vs_x_d->Eval(x_full); + const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); + const double th_y = track->getY()*1E-1 / L_y; // conversion mm --> cm - const double ep_x = 1E-6; - const double dxi_dx = (oit->second.s_xi_vs_x_d->Eval(x_full + ep_x) - xi) / ep_x; - const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-1; // conversion mm --> cm + const double ep_x = 1E-6; + const double dxi_dx = (oit->second.s_xi_vs_x_d->Eval(x_full + ep_x) - xi) / ep_x; + const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-1; // conversion mm --> cm - const double ep_xi = 1E-4; - const double dL_y_dxi = ( oit->second.s_L_y_vs_xi->Eval(xi + ep_xi) - L_y ) / ep_xi; - const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); + const double ep_xi = 1E-4; + const double dL_y_dxi = ( oit->second.s_L_y_vs_xi->Eval(xi + ep_xi) - L_y ) / ep_xi; + const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); - if (verbosity_) - os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; + if (verbosity_) + os << " xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "." << std::endl; - using FP = reco::ForwardProton; + using FP = reco::ForwardProton; - // save proton candidate + // save proton candidate + const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention + const FP::Point vertex(0., 0., 0.); + const double cos_th = sqrt(1. - th_y*th_y); + const double p = lhcInfo.energy() * (1. - xi); + const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); - const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention - const FP::Point vertex(0., 0., 0.); - const double cos_th = sqrt(1. - th_y*th_y); - const double p = lhcInfo.energy() * (1. - xi); - const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); + FP::CovarianceMatrix cm; + cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; + cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; - FP::CovarianceMatrix cm; - cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; - cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; + CTPPSLocalTrackLiteRefVector trk; + trk.push_back( track ); - CTPPSLocalTrackLiteRefVector trk; - trk.push_back( track ); - output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, trk, true); - } + return reco::ForwardProton(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, trk, true); } From 2ac70762e3f0881778f47f69ba84075b9978eee1 Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Wed, 3 Apr 2019 03:09:50 -0500 Subject: [PATCH 424/686] keep hidden valley and dark matter particles in miniAOD --- .../PatAlgos/python/slimming/prunedGenParticles_cfi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PhysicsTools/PatAlgos/python/slimming/prunedGenParticles_cfi.py b/PhysicsTools/PatAlgos/python/slimming/prunedGenParticles_cfi.py index 495a17eb7d271..1ecc6795334aa 100644 --- a/PhysicsTools/PatAlgos/python/slimming/prunedGenParticles_cfi.py +++ b/PhysicsTools/PatAlgos/python/slimming/prunedGenParticles_cfi.py @@ -36,6 +36,10 @@ "keep abs(pdgId) = 10511 || abs(pdgId) = 10521 || abs(pdgId) = 10513 || abs(pdgId) = 10523 || abs(pdgId) = 20513 || abs(pdgId) = 20523 || abs(pdgId) = 10531 || abs(pdgId) = 10533 || abs(pdgId) = 20533 || abs(pdgId) = 10541 || abs(pdgId) = 10543 || abs(pdgId) = 20543", #keep SUSY particles "keep (1000001 <= abs(pdgId) <= 1000039 ) || ( 2000001 <= abs(pdgId) <= 2000015)", +# keep hidden valley particles + "keep (4900001 <= abs(pdgId) <= 4900991)", +# keep dark matter particles + "keep (51 <= abs(pdgId) <= 53)", # keep protons "keep pdgId = 2212", "keep status == 3 || ( 21 <= status <= 29) || ( 11 <= status <= 19)", #keep event summary (status=3 for pythia6, 21 <= status <= 29 for pythia8) From efea8ff4a1f3e2a70b3917e13cbf1e89296049dd Mon Sep 17 00:00:00 2001 From: mauro verzetti Date: Mon, 1 Apr 2019 16:58:09 +0200 Subject: [PATCH 425/686] split matching into GSF to track and GSF to Packed, store the first in AOD --- DataFormats/TrackReco/interface/TrackFwd.h | 4 + DataFormats/TrackReco/src/classes_def.xml | 2 + .../LowPtGSFToPackedCandidateLinker.cc | 17 ++-- .../python/RecoEgamma_EventContent_cff.py | 3 + .../plugins/LowPtGSFToTrackLinker.cc | 93 +++++++++++++++++++ .../python/lowPtGsfElectronSequence_cff.py | 4 + .../python/lowPtGsfToTrackLinks_cfi.py | 3 + 7 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 RecoEgamma/EgammaElectronProducers/plugins/LowPtGSFToTrackLinker.cc create mode 100644 RecoEgamma/EgammaElectronProducers/python/lowPtGsfToTrackLinks_cfi.py diff --git a/DataFormats/TrackReco/interface/TrackFwd.h b/DataFormats/TrackReco/interface/TrackFwd.h index 8657f7894987a..b1f09fca5f0b2 100644 --- a/DataFormats/TrackReco/interface/TrackFwd.h +++ b/DataFormats/TrackReco/interface/TrackFwd.h @@ -7,6 +7,7 @@ #include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/Common/interface/RefToBase.h" #include "DataFormats/Common/interface/RefToBaseVector.h" +#include "DataFormats/Common/interface/Association.h" namespace reco { @@ -19,6 +20,9 @@ typedef std::vector TrackCollection; /// persistent reference to a Track typedef edm::Ref TrackRef; +/// association to a track collection +typedef edm::Association TrackAssociation; + /// persistent reference to a Track collection typedef edm::RefProd TrackRefProd; diff --git a/DataFormats/TrackReco/src/classes_def.xml b/DataFormats/TrackReco/src/classes_def.xml index c16b1f80467a8..9190b8e2d04cd 100644 --- a/DataFormats/TrackReco/src/classes_def.xml +++ b/DataFormats/TrackReco/src/classes_def.xml @@ -358,6 +358,8 @@ + + diff --git a/PhysicsTools/PatAlgos/plugins/LowPtGSFToPackedCandidateLinker.cc b/PhysicsTools/PatAlgos/plugins/LowPtGSFToPackedCandidateLinker.cc index b29220b6bcadb..9c992daaa0966 100644 --- a/PhysicsTools/PatAlgos/plugins/LowPtGSFToPackedCandidateLinker.cc +++ b/PhysicsTools/PatAlgos/plugins/LowPtGSFToPackedCandidateLinker.cc @@ -34,7 +34,7 @@ class LowPtGSFToPackedCandidateLinker : public edm::global::EDProducer<> { const edm::EDGetTokenT tracks_; const edm::EDGetTokenT > pf2packed_; const edm::EDGetTokenT > lost2trk_; - const edm::EDGetTokenT< std::vector > preid_; + const edm::EDGetTokenT< edm::Association > gsf2trk_; const edm::EDGetTokenT< std::vector > gsftracks_; }; @@ -45,7 +45,7 @@ LowPtGSFToPackedCandidateLinker::LowPtGSFToPackedCandidateLinker(const edm::Para tracks_{consumes(iConfig.getParameter("tracks"))}, pf2packed_{consumes >(iConfig.getParameter("packedCandidates"))}, lost2trk_{consumes >(iConfig.getParameter("lostTracks"))}, - preid_{consumes >(iConfig.getParameter("gsfPreID"))}, + gsf2trk_{consumes >(iConfig.getParameter("gsfToTrack"))}, gsftracks_{consumes >(iConfig.getParameter("gsfTracks"))} { produces< edm::Association > ("packedCandidates"); produces< edm::Association > ("lostTracks"); @@ -75,8 +75,8 @@ void LowPtGSFToPackedCandidateLinker::produce(edm::StreamID, edm::Event& iEvent, edm::Handle tracks; iEvent.getByToken(tracks_, tracks); - edm::Handle > preid; - iEvent.getByToken(preid_, preid); + edm::Handle > gsf2trk; + iEvent.getByToken(gsf2trk_, gsf2trk); // collection sizes, for reference const size_t npf = pfcands->size(); @@ -120,9 +120,10 @@ void LowPtGSFToPackedCandidateLinker::produce(edm::StreamID, edm::Event& iEvent, //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations for(unsigned int igsf=0; igsf < ngsf; ++igsf) { reco::GsfTrackRef gref(gsftracks, igsf); - reco::TrackRef trk = preid->at( - gref->seedRef().castTo().index() - ).trackRef(); + reco::TrackRef trk = (*gsf2trk)[gref]; + if(trk.id() != tracks.id()) { + throw cms::Exception("WrongCollection", "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks"); + } size_t trkid = trk.index(); if(trk2packed[trkid] != npacked) { @@ -153,7 +154,7 @@ void LowPtGSFToPackedCandidateLinker::fillDescriptions(edm::ConfigurationDescrip desc.add("packedCandidates", edm::InputTag("packedPFCandidates")); desc.add("lostTracks", edm::InputTag("lostTracks")); desc.add("tracks", edm::InputTag("generalTracks")); - desc.add("gsfPreID", edm::InputTag("lowPtGsfElectronSeeds")); + desc.add("gsfToTrack", edm::InputTag("lowPtGsfToTrackLinks")); desc.add("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks")); descriptions.add("lowPtGsfLinksDefault", desc); } diff --git a/RecoEgamma/Configuration/python/RecoEgamma_EventContent_cff.py b/RecoEgamma/Configuration/python/RecoEgamma_EventContent_cff.py index f6226b798332d..908e887d2765a 100644 --- a/RecoEgamma/Configuration/python/RecoEgamma_EventContent_cff.py +++ b/RecoEgamma/Configuration/python/RecoEgamma_EventContent_cff.py @@ -46,6 +46,7 @@ 'keep recoGsfElectrons_lowPtGsfElectrons_*_*', 'keep recoGsfElectronCores_lowPtGsfElectronCores_*_*', 'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*', + 'keep *_lowPtGsfToTrackLinks_*_*', 'keep recoSuperClusters_lowPtGsfElectronSuperClusters_*_*', 'keep floatedmValueMap_lowPtGsfElectronSeedValueMaps_*_*', 'keep floatedmValueMap_lowPtGsfElectronID_*_*', @@ -110,6 +111,7 @@ 'keep recoGsfElectrons_lowPtGsfElectrons_*_*', 'keep recoGsfElectronCores_lowPtGsfElectronCores_*_*', 'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*', + 'keep *_lowPtGsfToTrackLinks_*_*', 'keep recoSuperClusters_lowPtGsfElectronSuperClusters_*_*', 'keep floatedmValueMap_lowPtGsfElectronSeedValueMaps_*_*', 'keep floatedmValueMap_lowPtGsfElectronID_*_*', @@ -163,6 +165,7 @@ 'keep recoGsfElectrons_lowPtGsfElectrons_*_*', 'keep recoGsfElectronCores_lowPtGsfElectronCores_*_*', 'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*', + 'keep *_lowPtGsfToTrackLinks_*_*', 'keep recoSuperClusters_lowPtGsfElectronSuperClusters_*_*', 'keep floatedmValueMap_lowPtGsfElectronSeedValueMaps_*_*', 'keep floatedmValueMap_lowPtGsfElectronID_*_*', diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGSFToTrackLinker.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGSFToTrackLinker.cc new file mode 100644 index 0000000000000..9425828897271 --- /dev/null +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGSFToTrackLinker.cc @@ -0,0 +1,93 @@ +#include + +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" +#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" +#include "DataFormats/Common/interface/Association.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "DataFormats/ParticleFlowReco/interface/PreId.h" +#include "DataFormats/ParticleFlowReco/interface/PreIdFwd.h" +#include "DataFormats/EgammaReco/interface/ElectronSeed.h" +#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" +#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +class LowPtGSFToTrackLinker : public edm::global::EDProducer<> { +public: + explicit LowPtGSFToTrackLinker(const edm::ParameterSet&); + ~LowPtGSFToTrackLinker() override; + + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + const edm::EDGetTokenT tracks_; + const edm::EDGetTokenT< std::vector > preid_; + const edm::EDGetTokenT< std::vector > gsftracks_; +}; + +LowPtGSFToTrackLinker::LowPtGSFToTrackLinker(const edm::ParameterSet& iConfig) : + tracks_{consumes(iConfig.getParameter("tracks"))}, + preid_{consumes >(iConfig.getParameter("gsfPreID"))}, + gsftracks_{consumes >(iConfig.getParameter("gsfTracks"))} { + produces< edm::Association > (); + } + +LowPtGSFToTrackLinker::~LowPtGSFToTrackLinker() {} + +void LowPtGSFToTrackLinker::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { + edm::Handle > gsftracks; + iEvent.getByToken(gsftracks_, gsftracks); + + edm::Handle tracks; + iEvent.getByToken(tracks_, tracks); + + edm::Handle > preid; + iEvent.getByToken(preid_, preid); + + // collection sizes, for reference + const size_t ngsf = gsftracks->size(); + + //store mapping for association + std::vector gsf2track(ngsf, -1); + + //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations + for(unsigned int igsf=0; igsf < ngsf; ++igsf) { + reco::GsfTrackRef gref(gsftracks, igsf); + reco::TrackRef trk = preid->at( + gref->seedRef().castTo().index() + ).trackRef(); + + if(trk.id() != tracks.id()) { + throw cms::Exception("WrongCollection", "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks"); + } + + size_t trkid = trk.index(); + gsf2track[igsf] = trkid; + } + + // create output collections from the mappings + auto assoc = std::make_unique< edm::Association >(tracks); + edm::Association::Filler filler(*assoc); + filler.insert(gsftracks, gsf2track.begin(), gsf2track.end()); + filler.fill(); + iEvent.put(std::move(assoc)); +} + +void LowPtGSFToTrackLinker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("tracks", edm::InputTag("generalTracks")); + desc.add("gsfPreID", edm::InputTag("lowPtGsfElectronSeeds")); + desc.add("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks")); + descriptions.add("lowPtGsfToTrackLinksDefault", desc); +} + +DEFINE_FWK_MODULE(LowPtGSFToTrackLinker); diff --git a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py index 9ca351ec52b18..342eaf1a609e7 100644 --- a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py +++ b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py @@ -41,6 +41,9 @@ fastSim.toModify(lowPtGsfEleGsfTracks,src = cms.InputTag("fastLowPtGsfTkfTrackCandidates")) +# GSFTrack to track association +from RecoEgamma.EgammaElectronProducers.lowPtGsfToTrackLinks_cfi import * + # GsfPFRecTracks from RecoParticleFlow.PFTracking.pfTrackElec_cfi import * lowPtGsfElePfGsfTracks = pfTrackElec.clone() @@ -73,6 +76,7 @@ lowPtGsfElectronSeeds, lowPtGsfEleCkfTrackCandidates, lowPtGsfEleGsfTracks, + lowPtGsfToTrackLinks, lowPtGsfElePfGsfTracks, lowPtGsfElectronSuperClusters, lowPtGsfElectronCores, diff --git a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfToTrackLinks_cfi.py b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfToTrackLinks_cfi.py new file mode 100644 index 0000000000000..4611ac80dd9da --- /dev/null +++ b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfToTrackLinks_cfi.py @@ -0,0 +1,3 @@ +from RecoEgamma.EgammaElectronProducers.lowPtGsfToTrackLinksDefault_cfi import * + +lowPtGsfToTrackLinks = lowPtGsfToTrackLinksDefault.clone() From ecfec234160d61365f6f31c4e5527ba9a9ba83cf Mon Sep 17 00:00:00 2001 From: andrius Date: Wed, 3 Apr 2019 15:44:40 +0200 Subject: [PATCH 426/686] A small fix to dqmMemoryStats.py --- DQMServices/FileIO/python/DQM.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/FileIO/python/DQM.py b/DQMServices/FileIO/python/DQM.py index 78f54028f6263..fe176b663cba2 100644 --- a/DQMServices/FileIO/python/DQM.py +++ b/DQMServices/FileIO/python/DQM.py @@ -52,7 +52,7 @@ def read_objects_dqmio(self): yield (fullname, t_tree.Value, ) def read_objects_root(self): - xml_re = re.compile(r"^<(.+)>(.+)=(.+)<\/\1>$") + xml_re = re.compile(r"^<(.+)>(.+)=(.*)<\/\1>$") def parse_directory(di): directory = self._root_file.GetDirectory(di) for key in directory.GetListOfKeys(): From 331d218f322ef043c9b7c19e8ccee2180c3411c3 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 3 Apr 2019 16:20:53 +0200 Subject: [PATCH 427/686] remove incorrect build dependencies --- FWCore/TestProcessor/test/BuildFile.xml | 1 - Geometry/HcalCommonData/test/BuildFile.xml | 1 - Geometry/HcalTowerAlgo/test/BuildFile.xml | 1 - MuonAnalysis/MomentumScaleCalibration/bin/BuildFile.xml | 1 - 4 files changed, 4 deletions(-) diff --git a/FWCore/TestProcessor/test/BuildFile.xml b/FWCore/TestProcessor/test/BuildFile.xml index 126eadf3bffb7..5d8725e97c070 100644 --- a/FWCore/TestProcessor/test/BuildFile.xml +++ b/FWCore/TestProcessor/test/BuildFile.xml @@ -2,7 +2,6 @@ - diff --git a/Geometry/HcalCommonData/test/BuildFile.xml b/Geometry/HcalCommonData/test/BuildFile.xml index 2dbf9c23214af..50cbce541e885 100644 --- a/Geometry/HcalCommonData/test/BuildFile.xml +++ b/Geometry/HcalCommonData/test/BuildFile.xml @@ -1,7 +1,6 @@ - diff --git a/Geometry/HcalTowerAlgo/test/BuildFile.xml b/Geometry/HcalTowerAlgo/test/BuildFile.xml index f513bad93fd5e..4ae6967005039 100644 --- a/Geometry/HcalTowerAlgo/test/BuildFile.xml +++ b/Geometry/HcalTowerAlgo/test/BuildFile.xml @@ -2,7 +2,6 @@ - diff --git a/MuonAnalysis/MomentumScaleCalibration/bin/BuildFile.xml b/MuonAnalysis/MomentumScaleCalibration/bin/BuildFile.xml index 9932169ce479f..c5d700ca3fed7 100644 --- a/MuonAnalysis/MomentumScaleCalibration/bin/BuildFile.xml +++ b/MuonAnalysis/MomentumScaleCalibration/bin/BuildFile.xml @@ -1,4 +1,3 @@ - From 0ac3da731b9d47dd5c87979d3111dad4777448bd Mon Sep 17 00:00:00 2001 From: David Date: Wed, 3 Apr 2019 16:29:12 +0200 Subject: [PATCH 428/686] move wrapper to interface --- FWCore/PyDevParameterSet/{src => interface}/PyBind11Wrapper.h | 0 FWCore/PyDevParameterSet/interface/Python11ParameterSet.h | 2 +- FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename FWCore/PyDevParameterSet/{src => interface}/PyBind11Wrapper.h (100%) diff --git a/FWCore/PyDevParameterSet/src/PyBind11Wrapper.h b/FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h similarity index 100% rename from FWCore/PyDevParameterSet/src/PyBind11Wrapper.h rename to FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h diff --git a/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h b/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h index f205582d049bf..eb3a53e428d09 100644 --- a/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h +++ b/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h @@ -3,7 +3,7 @@ #include #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PyDevParameterSet/src/PyBind11Wrapper.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/ESInputTag.h" diff --git a/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc b/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc index 21e123b4447c1..9a3cf6c027857 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc @@ -1,4 +1,4 @@ -#include "PyBind11Wrapper.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" #include "FWCore/Utilities/interface/Exception.h" //#include namespace edm { From d4156accbbf29c25374e1c9de1b5e8bf392158e8 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 3 Apr 2019 16:34:01 +0200 Subject: [PATCH 429/686] switch to pybind11 --- Fireworks/FWInterface/BuildFile.xml | 2 +- Fireworks/FWInterface/src/FWPathsPopup.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Fireworks/FWInterface/BuildFile.xml b/Fireworks/FWInterface/BuildFile.xml index da15bbb606f65..ae866434a3230 100644 --- a/Fireworks/FWInterface/BuildFile.xml +++ b/Fireworks/FWInterface/BuildFile.xml @@ -16,7 +16,7 @@ - + diff --git a/Fireworks/FWInterface/src/FWPathsPopup.cc b/Fireworks/FWInterface/src/FWPathsPopup.cc index 0feebb15bc422..c8031423b7dd4 100644 --- a/Fireworks/FWInterface/src/FWPathsPopup.cc +++ b/Fireworks/FWInterface/src/FWPathsPopup.cc @@ -24,7 +24,7 @@ #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" #include "FWCore/ServiceRegistry/interface/StreamContext.h" -#include "FWCore/PythonParameterSet/src/PythonWrapper.h" +#include "FWCore/PyDevParameterSet/src/PyBind11Wrapper.h" #include #include "TGLabel.h" #include "KeySymbols.h" @@ -253,7 +253,7 @@ FWPathsPopup::scheduleReloadEvent() } catch (boost::python::error_already_set const&) { - edm::pythonToCppException("Configuration"); + edm::pythonToCppException("Configuration",""); Py_Finalize(); } catch (cms::Exception &exception) From 9073dac0d33e0edcc0676ae17324d57e3ca9bf25 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Apr 2019 09:45:07 -0500 Subject: [PATCH 430/686] Removed FEDNumbering::fromDet The method was not in use. --- .../FEDRawData/interface/FEDNumbering.h | 3 - DataFormats/FEDRawData/src/FEDNumbering.cc | 217 ------------------ .../FEDRawData/test/FEDNumbering_t.cpp | 117 ---------- 3 files changed, 337 deletions(-) diff --git a/DataFormats/FEDRawData/interface/FEDNumbering.h b/DataFormats/FEDRawData/interface/FEDNumbering.h index eef85d3f2359f..cd2766bc91b94 100644 --- a/DataFormats/FEDRawData/interface/FEDNumbering.h +++ b/DataFormats/FEDRawData/interface/FEDNumbering.h @@ -13,7 +13,6 @@ */ #include -#include class FEDNumbering { @@ -27,8 +26,6 @@ class FEDNumbering { static bool inRange(int); static bool inRangeNoGT(int); - static const std::string &fromDet(int); - enum { NOT_A_FEDID = -1, MAXFEDID = 4096, // must be larger than largest used FED id diff --git a/DataFormats/FEDRawData/src/FEDNumbering.cc b/DataFormats/FEDRawData/src/FEDNumbering.cc index c3097bb706f9f..c7fa1ba83273a 100644 --- a/DataFormats/FEDRawData/src/FEDNumbering.cc +++ b/DataFormats/FEDRawData/src/FEDNumbering.cc @@ -127,220 +127,8 @@ namespace { return in; } - constexpr std::array initFromIndex() { - std::array fromIndex= {{0}}; - int i = 0; - int index = 0; - for(i=0; i< FEDNumbering::lastFEDId(); i++) - fromIndex[i] = index; //empty - ++index; - for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) - { - fromIndex[i] = index; //"SiPixel"; - } - ++index; - for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) - { - fromIndex[i] = index; //"SiStrip"; - } - ++index; - for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) - { - fromIndex[i] = index; //"PreShower"; - } - ++index; - for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) - { - fromIndex[i] = index; //"Ecal"; - } - ++index; - for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) - { - fromIndex[i] = index; //"Castor"; - } - ++index; - for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) - { - fromIndex[i] = index; //"Hcal"; - } - ++index; - for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) - { - fromIndex[i] = index; //"LumiScalers"; - } - ++index; - for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) - { - fromIndex[i] = index; //"CSC"; - } - ++index; - for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) - { - fromIndex[i] = index; //"CSCTF"; - } - ++index; - for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) - { - fromIndex[i] = index; //"DT"; - } - ++index; - for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) - { - fromIndex[i] = index; //"DTTF"; - } - ++index; - for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) - { - fromIndex[i] = index; //"RPC"; - } - ++index; - for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) - { - fromIndex[i] = index; //"TriggerGTP"; - } - ++index; - for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) - { - fromIndex[i] = index; //"TriggerEGTP"; - } - ++index; - for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) - { - fromIndex[i] = index; //"TriggerGCT"; - } - ++index; - for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) - { - fromIndex[i] = index; //"TriggerLTC"; - } - ++index; - for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) - { - fromIndex[i] = index; //"TriggerLTCmtcc"; - } - ++index; - for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) - { - fromIndex[i] = index; //"CSCDDU"; - } - ++index; - for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) - { - fromIndex[i] = index; //"CSCContingency"; - } - ++index; - for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) - { - fromIndex[i] = index; //"CSCTFSP"; - } - ++index; - for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) - { - fromIndex[i] = index; //"DAQ"; - } - //++index; same name so no need for new index - for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) - { - fromIndex[i] = index; //"DAQ"; - } - ++index; - for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) - { - fromIndex[i] = index; //"TCDS"; - } - ++index; - for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) - { - fromIndex[i] = index; //"Hcal"; - } - ++index; - for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) - { - fromIndex[i] = index; //"SiPixel"; - } - ++index; - for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) - { - fromIndex[i] = index; //"DTUROS"; - } - ++index; - for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) - { - fromIndex[i] = index; //"L1T"; - } - return fromIndex; - } - - - std::array initFromString() { - std::array fromString; - int index = 0; - fromString[index] = ""; - ++index; - fromString[index] = "SiPixel"; - ++index; - fromString[index] = "SiStrip"; - ++index; - fromString[index] = "PreShower"; - ++index; - fromString[index] = "Ecal"; - ++index; - fromString[index] = "Castor"; - ++index; - fromString[index] = "Hcal"; - ++index; - fromString[index] = "LumiScalers"; - ++index; - fromString[index] = "CSC"; - ++index; - fromString[index] = "CSCTF"; - ++index; - fromString[index] = "DT"; - ++index; - fromString[index] = "DTTF"; - ++index; - fromString[index] = "RPC"; - ++index; - fromString[index] = "TriggerGTP"; - ++index; - fromString[index] = "TriggerEGTP"; - ++index; - fromString[index] = "TriggerGCT"; - ++index; - fromString[index] = "TriggerLTC"; - ++index; - fromString[index] = "TriggerLTCmtcc"; - ++index; - fromString[index] = "CSCDDU"; - ++index; - fromString[index] = "CSCContingency"; - ++index; - fromString[index] = "CSCTFSP"; - ++index; - fromString[index] = "DAQ"; - ++index; - fromString[index] = "TCDS"; - ++index; - fromString[index] = "Hcal"; - ++index; - fromString[index] = "SiPixel"; - ++index; - fromString[index] = "DTUROS"; - ++index; - fromString[index] = "L1T"; - - assert(index+1 == fromString.size()); - return fromString; - } - constexpr std::array in_ = initIn(); - constexpr std::array fromIndex_ = initFromIndex(); - - const std::array fromString_ = initFromString(); - - - } bool FEDNumbering::inRange(int i) @@ -352,8 +140,3 @@ bool FEDNumbering::inRangeNoGT(int i) if((i>=MINTriggerGTPFEDID && i<=MAXTriggerGTPFEDID) || (i>=MINTriggerEGTPFEDID && i<=MAXTriggerEGTPFEDID)) return false; return in_[i]; } - -string const &FEDNumbering::fromDet(int i) -{ - return fromString_[fromIndex_[i]]; -} diff --git a/DataFormats/FEDRawData/test/FEDNumbering_t.cpp b/DataFormats/FEDRawData/test/FEDNumbering_t.cpp index c215d4795d26b..3471084a2e6dc 100644 --- a/DataFormats/FEDRawData/test/FEDNumbering_t.cpp +++ b/DataFormats/FEDRawData/test/FEDNumbering_t.cpp @@ -14,7 +14,6 @@ class testFEDNumbering: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(testFEDNumbering); CPPUNIT_TEST(test_inRange); - CPPUNIT_TEST(test_fromDet); CPPUNIT_TEST_SUITE_END(); @@ -147,119 +146,3 @@ void testFEDNumbering::test_inRange(){ CPPUNIT_ASSERT(FEDNumbering::inRange(i)); } } - -void testFEDNumbering::test_fromDet(){ - int i = 0; - for(i=FEDNumbering::MINSiPixelFEDID; i<=FEDNumbering::MAXSiPixelFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiPixel"); - } - for(i=FEDNumbering::MAXSiPixelFEDID+1; i<=FEDNumbering::MINSiStripFEDID-1; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i).empty()); - } - for(i=FEDNumbering::MINSiStripFEDID; i<=FEDNumbering::MAXSiStripFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiStrip"); - } - for(i=FEDNumbering::MINPreShowerFEDID; i<=FEDNumbering::MAXPreShowerFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="PreShower"); - } - for(i=FEDNumbering::MINECALFEDID; i<=FEDNumbering::MAXECALFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Ecal"); - } - for(i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Castor"); - } - for(i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Hcal"); - } - for(i=FEDNumbering::MINLUMISCALERSFEDID; i<=FEDNumbering::MAXLUMISCALERSFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="LumiScalers"); - } - for(i=FEDNumbering::MINCSCFEDID; i<=FEDNumbering::MAXCSCFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSC"); - } - for(i=FEDNumbering::MINCSCTFFEDID; i<=FEDNumbering::MAXCSCTFFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCTF"); - } - for(i=FEDNumbering::MINDTFEDID; i<=FEDNumbering::MAXDTFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DT"); - } - for(i=FEDNumbering::MINDTTFFEDID; i<=FEDNumbering::MAXDTTFFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DTTF"); - } - for(i=FEDNumbering::MINRPCFEDID; i<=FEDNumbering::MAXRPCFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="RPC"); - } - for(i=FEDNumbering::MINTriggerGTPFEDID; i<=FEDNumbering::MAXTriggerGTPFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerGTP"); - } - for(i=FEDNumbering::MINTriggerEGTPFEDID; i<=FEDNumbering::MAXTriggerEGTPFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerEGTP"); - } - for(i=FEDNumbering::MINTriggerGCTFEDID; i<=FEDNumbering::MAXTriggerGCTFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerGCT"); - } - for(i=FEDNumbering::MINTriggerLTCFEDID; i<=FEDNumbering::MAXTriggerLTCFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerLTC"); - } - for(i=FEDNumbering::MINTriggerLTCmtccFEDID; i<=FEDNumbering::MAXTriggerLTCmtccFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TriggerLTCmtcc"); - } - for(i=FEDNumbering::MINCSCDDUFEDID; i<=FEDNumbering::MAXCSCDDUFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCDDU"); - } - for(i=FEDNumbering::MINCSCContingencyFEDID; i<=FEDNumbering::MAXCSCContingencyFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCContingency"); - } - for(i=FEDNumbering::MINCSCTFSPFEDID; i<=FEDNumbering::MAXCSCTFSPFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="CSCTFSP"); - } - for(i=FEDNumbering::MINDAQeFEDFEDID; i<=FEDNumbering::MAXDAQeFEDFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DAQ"); - } - for(i=FEDNumbering::MINDAQmFEDFEDID; i<=FEDNumbering::MAXDAQmFEDFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DAQ"); - } - for(i=FEDNumbering::MINTCDSuTCAFEDID; i<=FEDNumbering::MAXTCDSuTCAFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="TCDS"); - } - for(i=FEDNumbering::MINHCALuTCAFEDID; i<=FEDNumbering::MAXHCALuTCAFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="Hcal"); - } - for(i=FEDNumbering::MINSiPixeluTCAFEDID; i<=FEDNumbering::MAXSiPixeluTCAFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="SiPixel"); - } - for(i=FEDNumbering::MINDTUROSFEDID; i<=FEDNumbering::MAXDTUROSFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="DTUROS"); - } - for(i=FEDNumbering::MINTriggerUpgradeFEDID; i<=FEDNumbering::MAXTriggerUpgradeFEDID; i++) - { - CPPUNIT_ASSERT(FEDNumbering::fromDet(i) =="L1T"); - } -} From 44223416b964818e09eb5e913dbaa875062a7f86 Mon Sep 17 00:00:00 2001 From: Wagner Carvalho Date: Wed, 3 Apr 2019 16:55:46 +0200 Subject: [PATCH 431/686] Add small changes in CondCore for PPS proton reco, and serialization test code for LHCOpticalFunctions --- CondCore/CTPPSPlugins/src/plugin.cc | 4 +++- CondCore/Utilities/src/CondDBFetch.cc | 1 + CondCore/Utilities/src/CondDBImport.cc | 1 + CondCore/Utilities/src/CondFormats.h | 1 + CondFormats/CTPPSReadoutObjects/test/BuildFile.xml | 4 ++++ .../test/testSerializationLHCOpticalFunctionsSet.cc | 11 +++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 CondFormats/CTPPSReadoutObjects/test/testSerializationLHCOpticalFunctionsSet.cc diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index 2fe0ac1625e95..2f03dbb87c98a 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -13,6 +13,8 @@ #include "CondFormats/AlignmentRecord/interface/RPMisalignedAlignmentRecord.h" #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" REGISTER_PLUGIN(CTPPSBeamParametersRcd,CTPPSBeamParameters); REGISTER_PLUGIN(CTPPSPixelDAQMappingRcd,CTPPSPixelDAQMapping); @@ -22,4 +24,4 @@ REGISTER_PLUGIN(CTPPSRPAlignmentCorrectionsDataRcd,CTPPSRPAlignmentCorrectionsDa REGISTER_PLUGIN(RPRealAlignmentRecord,CTPPSRPAlignmentCorrectionsData); REGISTER_PLUGIN(RPMisalignedAlignmentRecord,CTPPSRPAlignmentCorrectionsData); REGISTER_PLUGIN(PPSTimingCalibrationRcd,PPSTimingCalibration); - +REGISTER_PLUGIN(CTPPSOpticsRcd,LHCOpticalFunctionsSetCollection); diff --git a/CondCore/Utilities/src/CondDBFetch.cc b/CondCore/Utilities/src/CondDBFetch.cc index d3520496247d5..0e565094c1014 100644 --- a/CondCore/Utilities/src/CondDBFetch.cc +++ b/CondCore/Utilities/src/CondDBFetch.cc @@ -53,6 +53,7 @@ namespace cond { FETCH_PAYLOAD_CASE( CTPPSPixelAnalysisMask ) FETCH_PAYLOAD_CASE( CTPPSPixelGainCalibrations ) FETCH_PAYLOAD_CASE( CTPPSRPAlignmentCorrectionsData ) + FETCH_PAYLOAD_CASE( LHCOpticalFunctionsSetCollection ) FETCH_PAYLOAD_CASE( CastorChannelQuality ) FETCH_PAYLOAD_CASE( CastorElectronicsMap ) FETCH_PAYLOAD_CASE( CastorGainWidths ) diff --git a/CondCore/Utilities/src/CondDBImport.cc b/CondCore/Utilities/src/CondDBImport.cc index 1be5546d1fb8b..ed04f6cdf7786 100644 --- a/CondCore/Utilities/src/CondDBImport.cc +++ b/CondCore/Utilities/src/CondDBImport.cc @@ -68,6 +68,7 @@ namespace cond { IMPORT_PAYLOAD_CASE( CTPPSPixelAnalysisMask ) IMPORT_PAYLOAD_CASE( CTPPSPixelGainCalibrations ) IMPORT_PAYLOAD_CASE( CTPPSRPAlignmentCorrectionsData ) + IMPORT_PAYLOAD_CASE( LHCOpticalFunctionsSetCollection ) IMPORT_PAYLOAD_CASE( CastorChannelQuality ) IMPORT_PAYLOAD_CASE( CastorElectronicsMap ) IMPORT_PAYLOAD_CASE( CastorGainWidths ) diff --git a/CondCore/Utilities/src/CondFormats.h b/CondCore/Utilities/src/CondFormats.h index 3809277da5e18..7d9edc411798d 100644 --- a/CondCore/Utilities/src/CondFormats.h +++ b/CondCore/Utilities/src/CondFormats.h @@ -31,6 +31,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelGainCalibrations.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSRPAlignmentCorrectionsData.h" #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" #include "CondFormats/DTObjects/interface/DTCCBConfig.h" #include "CondFormats/DTObjects/interface/DTDeadFlag.h" #include "CondFormats/DTObjects/interface/DTHVStatus.h" diff --git a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml index f925e58a4f741..6598cce3c526a 100644 --- a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml @@ -5,3 +5,7 @@ + + + + diff --git a/CondFormats/CTPPSReadoutObjects/test/testSerializationLHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/test/testSerializationLHCOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..f0c1fa874ee2f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/test/testSerializationLHCOpticalFunctionsSet.cc @@ -0,0 +1,11 @@ +#include "CondFormats/Serialization/interface/Test.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" + +int main() +{ + testSerialization() ; + testSerialization() ; + + return 0 ; +} From 0c3767e058327404c667b6d4e484fc0f089e94c8 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Wed, 3 Apr 2019 17:14:00 +0200 Subject: [PATCH 432/686] Avoid dependence on namespace in volume name string (ok for geometry test, not for Geant4) --- Geometry/MTDCommonData/src/ETLNumberingScheme.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/MTDCommonData/src/ETLNumberingScheme.cc b/Geometry/MTDCommonData/src/ETLNumberingScheme.cc index 430dfb9606618..61b8aef82ed40 100644 --- a/Geometry/MTDCommonData/src/ETLNumberingScheme.cc +++ b/Geometry/MTDCommonData/src/ETLNumberingScheme.cc @@ -47,7 +47,7 @@ uint32_t ETLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const { int nSide(7); const std::string& sideName ( baseNumber.getLevelName( nSide ) ) ; // Side choice: from scenario D41 is given by level 8 (HGCal v10) - if ( sideName == "caloBase:CALOECTSFront" ) { nSide = 8 ;} + if ( sideName.find("CALOECTSFront") != std::string::npos ) { nSide = 8 ;} const uint32_t sideCopy ( baseNumber.getCopyNumber( nSide ) ) ; const uint32_t zside ( sideCopy == 1 ? 1 : 0 ) ; From 383c2b07b29021793541c554cd0c0633b048e4ad Mon Sep 17 00:00:00 2001 From: David Lange Date: Wed, 3 Apr 2019 18:44:26 +0200 Subject: [PATCH 433/686] Update PyBind11ProcessDesc.cc --- FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc index 1728448801bb0..4c45ac9e502f4 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc @@ -2,7 +2,7 @@ #include "FWCore/ParameterSet/interface/ProcessDesc.h" #include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" #include "FWCore/PyDevParameterSet/src/initializePyBind11Module.h" -#include "FWCore/PyDevParameterSet/src/PyBind11Wrapper.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" #include #include From 2cd11b722181319bf9bdbf5367b536c87deda2c3 Mon Sep 17 00:00:00 2001 From: David Lange Date: Wed, 3 Apr 2019 19:16:21 +0200 Subject: [PATCH 434/686] Update FWPathsPopup.cc --- Fireworks/FWInterface/src/FWPathsPopup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fireworks/FWInterface/src/FWPathsPopup.cc b/Fireworks/FWInterface/src/FWPathsPopup.cc index c8031423b7dd4..5933167183dec 100644 --- a/Fireworks/FWInterface/src/FWPathsPopup.cc +++ b/Fireworks/FWInterface/src/FWPathsPopup.cc @@ -24,7 +24,7 @@ #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" #include "FWCore/ServiceRegistry/interface/StreamContext.h" -#include "FWCore/PyDevParameterSet/src/PyBind11Wrapper.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" #include #include "TGLabel.h" #include "KeySymbols.h" From fae348f1ba900aae2f9858d03177b1b2dd060426 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 3 Apr 2019 20:32:00 +0200 Subject: [PATCH 435/686] Fix the scintillator cell size for V10 --- Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml b/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml index 3a18953cd0dbd..533bb83c53f8a 100644 --- a/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml @@ -129,7 +129,7 @@ - + From 1641f75a18a6a1ce7da263a34a26e8e99f27f285 Mon Sep 17 00:00:00 2001 From: david walter Date: Wed, 3 Apr 2019 23:45:43 +0200 Subject: [PATCH 436/686] cosmetics: add axis labels and histogram titles for muon histograms --- DQMOffline/Lumi/plugins/ZCounting.cc | 77 +++++++++++++++++++--------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/DQMOffline/Lumi/plugins/ZCounting.cc b/DQMOffline/Lumi/plugins/ZCounting.cc index 99ea9c94b6b7b..a6b9d3ee7c67c 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.cc +++ b/DQMOffline/Lumi/plugins/ZCounting.cc @@ -61,6 +61,9 @@ ZCounting::ZCounting(const edm::ParameterSet& iConfig): // Trigger-specific Parameters fMuonHLTNames = iConfig.getParameter>("MuonTriggerNames"); fMuonHLTObjectNames = iConfig.getParameter>("MuonTriggerObjectNames"); + if(fMuonHLTNames.size() != fMuonHLTObjectNames.size()){ + edm::LogError("ZCounting") << "List of MuonTriggerNames and MuonTriggerObjectNames has to be the same length" << std::endl; + } // Electron-specific parameters fGsfElectronName_token = consumes>(fElectronName); @@ -138,26 +141,56 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e // Muon histograms - h_mass_HLT_pass_central = ibooker_.book2D("h_mass_HLT_pass_central", "h_mass_HLT_pass_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_HLT_pass_forward = ibooker_.book2D("h_mass_HLT_pass_forward", "h_mass_HLT_pass_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_HLT_fail_central = ibooker_.book2D("h_mass_HLT_fail_central", "h_mass_HLT_fail_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_HLT_fail_forward = ibooker_.book2D("h_mass_HLT_fail_forward", "h_mass_HLT_fail_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - - h_mass_SIT_pass_central = ibooker_.book2D("h_mass_SIT_pass_central", "h_mass_SIT_pass_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_SIT_pass_forward = ibooker_.book2D("h_mass_SIT_pass_forward", "h_mass_SIT_pass_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_SIT_fail_central = ibooker_.book2D("h_mass_SIT_fail_central", "h_mass_SIT_fail_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_SIT_fail_forward = ibooker_.book2D("h_mass_SIT_fail_forward", "h_mass_SIT_fail_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - - h_mass_Sta_pass_central = ibooker_.book2D("h_mass_Sta_pass_central", "h_mass_Sta_pass_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_pass_forward = ibooker_.book2D("h_mass_Sta_pass_forward", "h_mass_Sta_pass_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_fail_central = ibooker_.book2D("h_mass_Sta_fail_central", "h_mass_Sta_fail_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_fail_forward = ibooker_.book2D("h_mass_Sta_fail_forward", "h_mass_Sta_fail_forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - - h_npv = ibooker_.book2D("h_npv", "h_npv", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); - h_yield_Z = ibooker_.book1D("h_yield_Z", "h_yield_Z", LumiBin_, LumiMin_, LumiMax_); - h_yieldBB_Z = ibooker_.book1D("h_yieldBB_Z", "h_yieldBB_Z", LumiBin_, LumiMin_, LumiMax_); - h_yieldEE_Z = ibooker_.book1D("h_yieldEE_Z", "h_yieldEE_Z", LumiBin_, LumiMin_, LumiMax_); - + h_mass_HLT_pass_central = ibooker_.book2D("h_mass_HLT_pass_central", "Muon HLT passing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_HLT_pass_forward = ibooker_.book2D("h_mass_HLT_pass_forward", "Muon HLT passing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_HLT_fail_central = ibooker_.book2D("h_mass_HLT_fail_central", "Muon HLT failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_HLT_fail_forward = ibooker_.book2D("h_mass_HLT_fail_forward", "Muon HLT failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + + h_mass_SIT_pass_central = ibooker_.book2D("h_mass_SIT_pass_central", "Muon SIT passing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_SIT_pass_forward = ibooker_.book2D("h_mass_SIT_pass_forward", "Muon SIT passing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_SIT_fail_central = ibooker_.book2D("h_mass_SIT_fail_central", "Muon SIT_failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_SIT_fail_forward = ibooker_.book2D("h_mass_SIT_fail_forward", "Muon SIT failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + + h_mass_Sta_pass_central = ibooker_.book2D("h_mass_Sta_pass_central", "Muon Sta passing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Sta_pass_forward = ibooker_.book2D("h_mass_Sta_pass_forward", "Muon Sta passing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Sta_fail_central = ibooker_.book2D("h_mass_Sta_fail_central", "Muon Sta failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Sta_fail_forward = ibooker_.book2D("h_mass_Sta_fail_forward", "Muon Sta failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + + h_npv = ibooker_.book2D("h_npv", "Events with valid primary vertex", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); + h_yield_Z = ibooker_.book1D("h_yield_Z", "reconstructed Z bosons", LumiBin_, LumiMin_, LumiMax_); + h_yieldBB_Z = ibooker_.book1D("h_yieldBB_Z", "reconstructed Z bosons in barrel", LumiBin_, LumiMin_, LumiMax_); + h_yieldEE_Z = ibooker_.book1D("h_yieldEE_Z", "reconstructed Z bosons in endcap", LumiBin_, LumiMin_, LumiMax_); + + // Axis titles + h_mass_HLT_pass_central ->setAxisTitle("luminosiry section",1); + h_mass_HLT_pass_forward ->setAxisTitle("luminosiry section",1); + h_mass_HLT_fail_central ->setAxisTitle("luminosiry section",1); + h_mass_HLT_fail_forward ->setAxisTitle("luminosiry section",1); + h_mass_SIT_pass_central ->setAxisTitle("luminosiry section",1); + h_mass_SIT_pass_forward ->setAxisTitle("luminosiry section",1); + h_mass_SIT_fail_central ->setAxisTitle("luminosiry section",1); + h_mass_SIT_fail_forward ->setAxisTitle("luminosiry section",1); + h_mass_Sta_pass_central ->setAxisTitle("luminosiry section",1); + h_mass_Sta_pass_forward ->setAxisTitle("luminosiry section",1); + h_mass_Sta_fail_central ->setAxisTitle("luminosiry section",1); + h_mass_Sta_fail_forward ->setAxisTitle("luminosiry section",1); + h_mass_HLT_pass_central ->setAxisTitle("tag and probe mass",2); + h_mass_HLT_pass_forward ->setAxisTitle("tag and probe mass",2); + h_mass_HLT_fail_central ->setAxisTitle("tag and probe mass",2); + h_mass_HLT_fail_forward ->setAxisTitle("tag and probe mass",2); + h_mass_SIT_pass_central ->setAxisTitle("tag and probe mass",2); + h_mass_SIT_pass_forward ->setAxisTitle("tag and probe mass",2); + h_mass_SIT_fail_central ->setAxisTitle("tag and probe mass",2); + h_mass_SIT_fail_forward ->setAxisTitle("tag and probe mass",2); + h_mass_Sta_pass_central ->setAxisTitle("tag and probe mass",2); + h_mass_Sta_pass_forward ->setAxisTitle("tag and probe mass",2); + h_mass_Sta_fail_central ->setAxisTitle("tag and probe mass",2); + h_mass_Sta_fail_forward ->setAxisTitle("tag and probe mass",2); + h_npv ->setAxisTitle("luminosity section", 1); + h_npv ->setAxisTitle("number of primary vertices", 2); + h_yield_Z ->setAxisTitle("luminosiry section",1); + h_yieldBB_Z ->setAxisTitle("luminosiry section",1); + h_yieldEE_Z ->setAxisTitle("luminosiry section",1); // Electron histograms h_ee_mass_id_pass_central = ibooker_.book2D("h_ee_mass_id_pass_central", "h_ee_mass_id_pass_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); @@ -183,7 +216,7 @@ void ZCounting::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {// Fill event tree on the fly edm::LogInfo("ZCounting") << "ZCounting::analyze" << std::endl; analyzeMuons(iEvent, iSetup); - //analyzeElectrons(iEvent, iSetup); + analyzeElectrons(iEvent, iSetup); } void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -295,7 +328,6 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS if(pt2 < PtCutL2_) continue; if(fabs(eta2) > EtaCutL2_) continue; if(q1 == q2) continue; - std::cout<<"good probe found"< Date: Wed, 3 Apr 2019 23:13:39 +0200 Subject: [PATCH 437/686] Bug fix for behavior after exceptions with concurrent lumis This fixes a bug that would be encountered when more than one lumi is being processed concurrently and there is an exception. If the exception is associated with a lumi other than the last one read, an infinite wait will be entered. The wait is in the processLumis function of the EventProcessor. It waits on every task in the stream SerialTaskQueues. In the above situation the serial queue is not resumed before the wait and there are still tasks in the queues. There is code that would clean these up in the function endUnfinishedLumis but that only runs after the wait is over and processLumis has returned. Too late. This commit also fixes the maxEvent output parameter which was broken when more than one lumi is processed concurrently. As far as I know nothing uses this, but it is an advertised parameter of the Framework that is supposed to work. One note about this. If events are running concurrently when the limit is reached, then all the events already running will complete, so the job could write more than the requested number of events to output. This adds two new unit tests. One test would fail with an infinite wait if executed in a release before this commit. The other tests the maxEvent output parameter. Plus I added an assert that checks that the reference count is one in normalEnd when we try to delete RunResources and get endRun to execute. --- FWCore/Framework/interface/EventProcessor.h | 1 + FWCore/Framework/src/EventProcessor.cc | 58 ++++++++++++++++--- FWCore/Framework/src/TransitionProcessors.icc | 3 + FWCore/Framework/test/run_cmsRun.sh | 25 ++++++++ .../Framework/test/stubs/ToyIntProducers.cc | 22 ++++++- .../test/testConcurrentLumiExceptions_cfg.py | 30 ++++++++++ .../Framework/test/testMaxEventsOutput_cfg.py | 41 +++++++++++++ 7 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 FWCore/Framework/test/testConcurrentLumiExceptions_cfg.py create mode 100644 FWCore/Framework/test/testMaxEventsOutput_cfg.py diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 5b93c0ce00ce9..8d8310a715b30 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -331,6 +331,7 @@ namespace edm { std::string exceptionMessageFiles_; std::string exceptionMessageRuns_; std::string exceptionMessageLumis_; + std::atomic exceptionMessageLumisIsSet_; bool forceLooperToEnd_; bool looperBeginJobRun_; bool forceESCacheClearOnNewRun_; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index cc4e83c78b253..36f3a92c6db82 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -244,6 +244,7 @@ namespace edm { exceptionMessageFiles_(), exceptionMessageRuns_(), exceptionMessageLumis_(), + exceptionMessageLumisIsSet_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -280,6 +281,7 @@ namespace edm { exceptionMessageFiles_(), exceptionMessageRuns_(), exceptionMessageLumis_(), + exceptionMessageLumisIsSet_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -318,6 +320,7 @@ namespace edm { exceptionMessageFiles_(), exceptionMessageRuns_(), exceptionMessageLumis_(), + exceptionMessageLumisIsSet_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -1155,7 +1158,9 @@ namespace edm { [this,i,h = holder](std::exception_ptr const* iPtr) mutable { if(iPtr) { - h.doneWaiting(*iPtr); + WaitingTaskHolder tmp(h); + tmp.doneWaiting(*iPtr); + streamEndLumiAsync(h, i, streamLumiStatus_[i]); } else { handleNextEventForStreamAsync(std::move(h), i); } @@ -1511,11 +1516,8 @@ namespace edm { bool EventProcessor::readNextEventForStream(unsigned int iStreamIndex, LuminosityBlockProcessingStatus& iStatus) { - if(shouldWeStop()) { - return false; - } - if(deferredExceptionPtrIsSet_.load(std::memory_order_acquire)) { + iStatus.endLumi(); return false; } @@ -1523,6 +1525,13 @@ namespace edm { return false; } + if (shouldWeStop()) { + lastSourceTransition_ = InputSource::IsStop; + iStatus.stopProcessingEvents(); + iStatus.endLumi(); + return false; + } + ServiceRegistry::Operate operate(serviceToken_); try { //need to use lock in addition to the serial task queue because @@ -1562,6 +1571,7 @@ namespace edm { bool expected =false; if(deferredExceptionPtrIsSet_.compare_exchange_strong(expected,true)) { deferredExceptionPtr_ = std::current_exception(); + iStatus.endLumi(); } return false; } @@ -1578,10 +1588,36 @@ namespace edm { if(readNextEventForStream(iStreamIndex, *status) ) { auto recursionTask = make_waiting_task(tbb::task::allocate_root(), [this,iTask,iStreamIndex](std::exception_ptr const* iPtr) mutable { if(iPtr) { + // Try to end the stream properly even if an exception was + // thrown on an event. bool expected = false; if(deferredExceptionPtrIsSet_.compare_exchange_strong(expected,true)) { + // This is the case where the exception in iPtr is the primary + // exception and we want to see its message. deferredExceptionPtr_ = *iPtr; - iTask.doneWaiting(*iPtr); + std::exception_ptr excpt = *iPtr; + auto delayError = make_waiting_task(tbb::task::allocate_root(), [this, iTask, excpt](std::exception_ptr const* jPtr) mutable { + if (jPtr) { + std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); + setExceptionMessageLumis(message); + } + iTask.doneWaiting(excpt); + }); + WaitingTaskHolder delayErrorHolder(delayError); + streamEndLumiAsync(std::move(delayErrorHolder), iStreamIndex, streamLumiStatus_[iStreamIndex]); + } else { + // Something else already threw and set the deferred exception so + // we simply ignore subsequent exceptions. + std::exception_ptr excpt; + auto ignoreError = make_waiting_task(tbb::task::allocate_root(), [this, iTask, excpt](std::exception_ptr const* jPtr) mutable { + if (jPtr) { + std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); + setExceptionMessageLumis(message); + } + iTask.doneWaiting(excpt); + }); + WaitingTaskHolder ignoreErrorHolder(ignoreError); + streamEndLumiAsync(std::move(ignoreErrorHolder), iStreamIndex, streamLumiStatus_[iStreamIndex]); } //the stream will stop now return; @@ -1603,6 +1639,11 @@ namespace edm { } } } catch(...) { + // It is unlikely we will ever get in here ... + // But if we do try to clean up and propagate the exception + if (streamLumiStatus_[iStreamIndex]) { + streamEndLumiAsync(iTask, iStreamIndex, streamLumiStatus_[iStreamIndex]); + } bool expected = false; if(deferredExceptionPtrIsSet_.compare_exchange_strong(expected,true)) { auto e =std::current_exception(); @@ -1747,7 +1788,10 @@ namespace edm { } void EventProcessor::setExceptionMessageLumis(std::string& message) { - exceptionMessageLumis_ = message; + bool expected = false; + if (exceptionMessageLumisIsSet_.compare_exchange_strong(expected,true)) { + exceptionMessageLumis_ = message; + } } bool EventProcessor::setDeferredException(std::exception_ptr iException) { diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index 16bece4709012..fe92974f595dc 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -10,6 +10,8 @@ //Transition processing helpers +#include + struct FileResources { FileResources(EventProcessor& iEP): ep_(iEP) {} @@ -143,6 +145,7 @@ public: lumis_.normalEnd(); if(currentRun_) { currentRun_->normalEnd(); + assert(currentRun_.use_count() == 1); } currentRun_.reset(); } diff --git a/FWCore/Framework/test/run_cmsRun.sh b/FWCore/Framework/test/run_cmsRun.sh index 9ad28edf2dbf9..cc9e4f444dc07 100755 --- a/FWCore/Framework/test/run_cmsRun.sh +++ b/FWCore/Framework/test/run_cmsRun.sh @@ -5,4 +5,29 @@ function die { echo $1: status $2 ; exit $2; } (cmsRun --help ) || die 'Failure running cmsRun --help' $? +# This test is supposed to throw an exception. +# We had a bug where EventProcessor went into an +# infinite wait under the circumstances in this test +# and after an exception. The conditions were multiple +# concurrent lumis in flight with an exception on an +# event in a lumi before the last lumi. +# This test passes as long as it does not go into +# an infinite wait. +F2=${LOCAL_TEST_DIR}/testConcurrentLumiExceptions_cfg.py +echo $F2 "This test intentionally throws an exception" +(cmsRun $F2 ) && die "No exception using $F2" $? +# Test maxEvents output parameter +F3=${LOCAL_TEST_DIR}/testMaxEventsOutput_cfg.py +echo $F3 +(cmsRun $F3 ) || die "Failure running cmsRun $F3" $? +# 6th word on the line containing the string "events" +# output by edmFileUtil +nEvents=`edmFileUtil file:testMaxEventsOutput.root | grep events | awk ' {print $6; exit} '` +if [ "$nEvents" -lt 6 ] || [ "$nEvents" -gt 9 ]; then +echo "maxEvents output test failed, nEvents = " $nEvents +exit 1 +fi +echo "number of events written = " $nEvents + +exit 0 diff --git a/FWCore/Framework/test/stubs/ToyIntProducers.cc b/FWCore/Framework/test/stubs/ToyIntProducers.cc index bf4dfffb948fb..ca4a2455d48a5 100644 --- a/FWCore/Framework/test/stubs/ToyIntProducers.cc +++ b/FWCore/Framework/test/stubs/ToyIntProducers.cc @@ -158,17 +158,20 @@ namespace edmtest { token_{produces()}, value_(p.getParameter("ivalue")), iterations_(p.getParameter("iterations")), - pi_(std::acos(-1)){ + pi_(std::acos(-1)), + lumiNumberToThrow_(p.getParameter("lumiNumberToThrow")) { } void produce(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const override; - + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: const edm::EDPutTokenT token_; const int value_; const unsigned int iterations_; const double pi_; - + const unsigned int lumiNumberToThrow_; }; void @@ -181,6 +184,19 @@ namespace edmtest { } e.emplace(token_,value_+sum); + + if (e.luminosityBlock() == lumiNumberToThrow_) { + throw cms::Exception("Test"); + } + } + + void + BusyWaitIntProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("ivalue"); + desc.add("iterations"); + desc.add("lumiNumberToThrow", 0); + descriptions.addDefault(desc); } //-------------------------------------------------------------------- diff --git a/FWCore/Framework/test/testConcurrentLumiExceptions_cfg.py b/FWCore/Framework/test/testConcurrentLumiExceptions_cfg.py new file mode 100644 index 0000000000000..9741bd02bd181 --- /dev/null +++ b/FWCore/Framework/test/testConcurrentLumiExceptions_cfg.py @@ -0,0 +1,30 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("TEST") + +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(1), + firstLuminosityBlock = cms.untracked.uint32(1), + firstEvent = cms.untracked.uint32(1), + numberEventsInLuminosityBlock = cms.untracked.uint32(1), + numberEventsInRun = cms.untracked.uint32(100) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(20) +) + +process.options = cms.untracked.PSet( + numberOfThreads = cms.untracked.uint32(4), + numberOfStreams = cms.untracked.uint32(4), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(4) +) + +process.busy1 = cms.EDProducer("BusyWaitIntProducer", + ivalue = cms.int32(1), + iterations = cms.uint32(10*1000*1000), + lumiNumberToThrow = cms.uint32(7) +) + +process.p1 = cms.Path(process.busy1) diff --git a/FWCore/Framework/test/testMaxEventsOutput_cfg.py b/FWCore/Framework/test/testMaxEventsOutput_cfg.py new file mode 100644 index 0000000000000..92e8d029f76c2 --- /dev/null +++ b/FWCore/Framework/test/testMaxEventsOutput_cfg.py @@ -0,0 +1,41 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("TEST") + +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(1), + firstLuminosityBlock = cms.untracked.uint32(1), + firstEvent = cms.untracked.uint32(1), + numberEventsInLuminosityBlock = cms.untracked.uint32(1), + numberEventsInRun = cms.untracked.uint32(100) +) + +# set to 6 output events. Actual number could be +# anywhere from 6 to 9 because after 6 events written +# it will finish the other events already running concurrently. +# In this config there are 3 other streams possible. +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(20), + output = cms.untracked.int32(6) +) + +process.options = cms.untracked.PSet( + numberOfThreads = cms.untracked.uint32(4), + numberOfStreams = cms.untracked.uint32(4), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(4) +) + +process.busy1 = cms.EDProducer("BusyWaitIntProducer", + ivalue = cms.int32(1), + iterations = cms.uint32(10*1000*1000), + lumiNumberToThrow = cms.uint32(7) +) + +process.p1 = cms.Path(process.busy1) +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('testMaxEventsOutput.root') +) + +process.e = cms.EndPath(process.out) + From 2c39353750003eecc344c94fe904df630a1363cd Mon Sep 17 00:00:00 2001 From: david walter Date: Thu, 4 Apr 2019 11:26:50 +0200 Subject: [PATCH 438/686] add year specific configuration with era modifier --- .../Eras/python/Era_Run2_2016_cff.py | 3 ++- .../Eras/python/Era_Run2_2017_cff.py | 3 ++- .../Eras/python/Era_Run2_2018_cff.py | 3 ++- .../python/Modifier_run2_zcount_2016_cff.py | 4 ++++ .../python/Modifier_run2_zcount_2017_cff.py | 4 ++++ .../python/Modifier_run2_zcount_2018_cff.py | 4 ++++ .../StandardSequences/python/Eras.py | 1 + DQMOffline/Lumi/python/ZCounting_cff.py | 22 +++++++++++++++++++ DQMOffline/Lumi/test/ZCounting_cfg.py | 9 ++++---- 9 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py create mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py create mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py diff --git a/Configuration/Eras/python/Era_Run2_2016_cff.py b/Configuration/Eras/python/Era_Run2_2016_cff.py index 3bdc3fee27097..6fe939421f913 100644 --- a/Configuration/Eras/python/Era_Run2_2016_cff.py +++ b/Configuration/Eras/python/Era_Run2_2016_cff.py @@ -4,6 +4,7 @@ from Configuration.Eras.Modifier_run2_25ns_specific_cff import run2_25ns_specific from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 +from Configuration.Eras.Modifier_run2_zcount_2016_cff import run2_zcount_2016 -Run2_2016 = cms.ModifierChain(run2_common, run2_25ns_specific, stage2L1Trigger, ctpps_2016) +Run2_2016 = cms.ModifierChain(run2_common, run2_25ns_specific, stage2L1Trigger, ctpps_2016, run2_zcount_2016) diff --git a/Configuration/Eras/python/Era_Run2_2017_cff.py b/Configuration/Eras/python/Era_Run2_2017_cff.py index cf3f112d2b10e..811b027b89386 100644 --- a/Configuration/Eras/python/Era_Run2_2017_cff.py +++ b/Configuration/Eras/python/Era_Run2_2017_cff.py @@ -10,6 +10,7 @@ from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017 +from Configuration.Eras.Modifier_run2_zcount_2017_cff import run2_zcount_2017 -Run2_2017 = cms.ModifierChain(Run2_2016, phase1Pixel, run2_ECAL_2017, run2_HF_2017, run2_HCAL_2017, run2_HE_2017, run2_HEPlan1_2017, trackingPhase1, run2_GEM_2017, stage2L1Trigger_2017) +Run2_2017 = cms.ModifierChain(Run2_2016, phase1Pixel, run2_ECAL_2017, run2_HF_2017, run2_HCAL_2017, run2_HE_2017, run2_HEPlan1_2017, trackingPhase1, run2_GEM_2017, stage2L1Trigger_2017, run2_zcount_2017) diff --git a/Configuration/Eras/python/Era_Run2_2018_cff.py b/Configuration/Eras/python/Era_Run2_2018_cff.py index 02bbd4001d43c..e8e49f41ed1fb 100644 --- a/Configuration/Eras/python/Era_Run2_2018_cff.py +++ b/Configuration/Eras/python/Era_Run2_2018_cff.py @@ -9,5 +9,6 @@ from Configuration.Eras.Modifier_run2_HCAL_2018_cff import run2_HCAL_2018 from Configuration.Eras.Modifier_run2_DT_2018_cff import run2_DT_2018 from Configuration.Eras.Modifier_run2_SiPixel_2018_cff import run2_SiPixel_2018 +from Configuration.Eras.Modifier_run2_zcount_2018_cff import run2_zcount_2018 -Run2_2018 = cms.ModifierChain(Run2_2017.copyAndExclude([run2_HEPlan1_2017]), run2_CSC_2018, run2_HCAL_2018, run2_HB_2018, run2_HE_2018,run2_DT_2018, run2_SiPixel_2018) +Run2_2018 = cms.ModifierChain(Run2_2017.copyAndExclude([run2_HEPlan1_2017]), run2_CSC_2018, run2_HCAL_2018, run2_HB_2018, run2_HE_2018,run2_DT_2018, run2_SiPixel_2018, run2_zcount_2018) diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py new file mode 100644 index 0000000000000..f547ebf28cce8 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_zcount_2016 = cms.Modifier() + diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py new file mode 100644 index 0000000000000..1ddd404892642 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_zcount_2017 = cms.Modifier() + diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py new file mode 100644 index 0000000000000..f6a5e65ba7272 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_zcount_2018 = cms.Modifier() + diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index fde246b53c80e..18c14c9374325 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -61,6 +61,7 @@ def __init__(self): 'run2_nanoAOD_94XMiniAODv1', 'run2_nanoAOD_94XMiniAODv2', 'run2_nanoAOD_94X2016', 'run2_miniAOD_devel', 'run2_nanoAOD_102Xv1', 'hcalHardcodeConditions', 'hcalSkipPacker', + 'run2_zcount_2016','run2_zcount_2017','run2_zcount_2018', 'bParking'] internalUseModChains = ['run2_2017_noTrackingModifier'] diff --git a/DQMOffline/Lumi/python/ZCounting_cff.py b/DQMOffline/Lumi/python/ZCounting_cff.py index 786c75a5e964f..7976c2b4b3904 100644 --- a/DQMOffline/Lumi/python/ZCounting_cff.py +++ b/DQMOffline/Lumi/python/ZCounting_cff.py @@ -55,3 +55,25 @@ VtxAbsZMax = cms.untracked.double(24.), VtxRhoMax = cms.untracked.double(2.) ) + + +from Configuration.StandardSequences.Eras import eras + +eras.run2_zcount_2016.toModify( zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*","HLT_IsoTkMu24_v*"), + MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07", + "hltL3fL1sMu22L1f0Tkf24QL3trkIsoFiltered0p09"), + PtCutL1 = cms.untracked.double(27.0), + PtCutL2 = cms.untracked.double(27.0) + ) + +eras.run2_zcount_2017.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*"), + MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07"), + PtCutL1 = cms.untracked.double(30.0), + PtCutL2 = cms.untracked.double(30.0) + ) + +eras.run2_zcount_2018.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*"), + MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07"), + PtCutL1 = cms.untracked.double(27.0), + PtCutL2 = cms.untracked.double(27.0) + ) diff --git a/DQMOffline/Lumi/test/ZCounting_cfg.py b/DQMOffline/Lumi/test/ZCounting_cfg.py index 3e0f9db624c0a..defff66b3a611 100644 --- a/DQMOffline/Lumi/test/ZCounting_cfg.py +++ b/DQMOffline/Lumi/test/ZCounting_cfg.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras -process = cms.Process('RECODQM') +process = cms.Process('RECODQM', eras.Run2_2018) # import of standard configurations process.load('Configuration/StandardSequences/Services_cff') @@ -52,9 +53,9 @@ process.load("DQMOffline.Lumi.ZCounting_cff") -process.zcounting.MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*","HLT_IsoMu24_v*") -process.zcounting.MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07", - "hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07") +#process.zcounting.MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*","HLT_IsoMu24_v*") +#process.zcounting.MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07", +# "hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07") process.DQMoutput = cms.OutputModule("DQMRootOutputModule", fileName = cms.untracked.string("OUT_step1.root")) From 000305ccc68a698bf795b19a20d0197ea481a503 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 4 Apr 2019 11:35:21 +0200 Subject: [PATCH 439/686] Megre Geometry records --- .../DDCMS/plugins/DDCMSDetector.cc | 4 ++-- .../DDCMS/plugins/DDDetectorESProducer.cc | 8 ++++---- .../plugins/DDSpecParRegistryESProducer.cc | 4 ++-- .../DDCMS/plugins/DDTestDumpFile.cc | 4 ++-- .../DDCMS/plugins/DDTestDumpGeometry.cc | 4 ++-- .../DDCMS/plugins/DDTestNavigateGeometry.cc | 4 ++-- .../plugins/DDVectorRegistryESProducer.cc | 4 ++-- .../DDCMS/src/ES_DDDetector.cc | 4 ++-- DetectorDescription/Parser/test/testmat.cpp | 2 +- .../RegressionTest/test/dumpDDCompactView.cpp | 2 +- .../test/dumpDDExpandedView.cpp | 2 +- .../RegressionTest/test/testDDCompactView.cpp | 2 +- .../plugins/DTGeometryValidate.cc | 4 ++-- .../plugins/dd4hep/DTGeometryBuilder.cc | 6 +++--- .../plugins/dd4hep/DTGeometryESProducer.cc | 20 +++++++++---------- .../plugins/dd4hep/DTGeometryTest.cc | 4 ++-- .../plugins/DDTestMuonNumbering.cc | 4 ++-- .../plugins/MuonNumberingESProducer.cc | 6 +++--- .../Records/interface/DDSpecParRegistryRcd.h | 4 ++-- .../Records/interface/DDVectorRegistryRcd.h | 4 ++-- .../interface/DetectorDescriptionRcd.h | 6 ------ Geometry/Records/interface/MuonGeometryRcd.h | 18 ----------------- .../Records/interface/MuonGeometryRecord.h | 4 +++- Geometry/Records/interface/MuonNumberingRcd.h | 11 ---------- .../Records/interface/MuonNumberingRecord.h | 4 +++- .../Records/src/DetectorDescriptionRcd.cc | 4 ---- Geometry/Records/src/MuonGeometryRcd.cc | 4 ---- Geometry/Records/src/MuonNumberingRcd.cc | 4 ---- 28 files changed, 54 insertions(+), 97 deletions(-) delete mode 100644 Geometry/Records/interface/DetectorDescriptionRcd.h delete mode 100644 Geometry/Records/interface/MuonGeometryRcd.h delete mode 100644 Geometry/Records/interface/MuonNumberingRcd.h delete mode 100644 Geometry/Records/src/DetectorDescriptionRcd.cc delete mode 100644 Geometry/Records/src/MuonGeometryRcd.cc delete mode 100644 Geometry/Records/src/MuonNumberingRcd.cc diff --git a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc index b5d5f9689dfd6..8067fae7fc259 100644 --- a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc +++ b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc @@ -5,7 +5,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" @@ -39,7 +39,7 @@ void DDCMSDetector::analyze(const Event&, const EventSetup& iEventSetup) { ESTransientHandle det; - iEventSetup.get().get(m_tag.module(), det); + iEventSetup.get().get(m_tag.module(), det); LogInfo("DDCMS") << "Iterate over the detectors:\n"; for( auto const& it : det->description()->detectors()) { diff --git a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc index 403d083b264e8..80f6adae40dc9 100644 --- a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc @@ -24,7 +24,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" @@ -41,7 +41,7 @@ class DDDetectorESProducer : public ESProducer, using ReturnType = unique_ptr; using Detector = dd4hep::Detector; - ReturnType produce(const DetectorDescriptionRcd&); + ReturnType produce(const GeometryFileRcd&); static void fillDescriptions(ConfigurationDescriptions&); protected: @@ -58,7 +58,7 @@ DDDetectorESProducer::DDDetectorESProducer(const ParameterSet& iConfig) m_label(iConfig.getParameter("appendToDataLabel")) { setWhatProduced(this); - findingRecord(); + findingRecord(); } DDDetectorESProducer::~DDDetectorESProducer() @@ -81,7 +81,7 @@ DDDetectorESProducer::setIntervalFor(const eventsetup::EventSetupRecordKey& iKey } DDDetectorESProducer::ReturnType -DDDetectorESProducer::produce(const DetectorDescriptionRcd& iRecord) +DDDetectorESProducer::produce(const GeometryFileRcd& iRecord) { LogDebug("Geometry") << "DDDetectorESProducer::Produce " << m_label; return make_unique(m_label, m_confGeomXMLFiles); diff --git a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc index 52a9b69a17256..47e35ef808f7f 100644 --- a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc @@ -26,7 +26,7 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" @@ -70,7 +70,7 @@ DDSpecParRegistryESProducer::ReturnType DDSpecParRegistryESProducer::produce(const DDSpecParRegistryRcd& iRecord) { edm::ESHandle det; - iRecord.getRecord().get(m_label, det); + iRecord.getRecord().get(m_label, det); const DDSpecParRegistry* registry = det->description()->extension(); auto product = std::make_unique(); diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc index 44c4c2db261ad..4ab1a14a40206 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" @@ -45,7 +45,7 @@ DDTestDumpFile::analyze(const Event&, const EventSetup& iEventSetup) { LogVerbatim("Geometry") << "DDTestDumpFile::analyze: " << m_label; ESTransientHandle det; - iEventSetup.get().get(m_label.module(), det); + iEventSetup.get().get(m_label.module(), det); TGeoManager& geom = det->description()->manager(); diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc index c57c49e0fda94..cda6b744b0756 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" @@ -40,7 +40,7 @@ DDTestDumpGeometry::analyze(const Event&, const EventSetup& iEventSetup) { LogVerbatim("Geometry") << "DDTestDumpGeometry::analyze: " << m_tag; ESTransientHandle det; - iEventSetup.get().get(m_tag.module(), det); + iEventSetup.get().get(m_tag.module(), det); TGeoManager const& geom = det->description()->manager(); diff --git a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc index 6e530d5e324b6..50819428a4fb0 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" @@ -59,7 +59,7 @@ DDTestNavigateGeometry::analyze(const Event&, const EventSetup& iEventSetup) } }); - const DetectorDescriptionRcd& ddRecord = iEventSetup.get(); + const GeometryFileRcd& ddRecord = iEventSetup.get(); ESTransientHandle ddd; ddRecord.get(m_tag.module(), ddd); diff --git a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc index dcbe927e379ca..db9a8088aeca6 100644 --- a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc @@ -27,7 +27,7 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" @@ -73,7 +73,7 @@ DDVectorRegistryESProducer::produce(const DDVectorRegistryRcd& iRecord) { LogDebug("Geometry") << "DDVectorRegistryESProducer::produce\n"; edm::ESHandle det; - iRecord.getRecord().get(m_label, det); + iRecord.getRecord().get(m_label, det); const DDVectorsMap& registry = det->vectors(); diff --git a/DetectorDescription/DDCMS/src/ES_DDDetector.cc b/DetectorDescription/DDCMS/src/ES_DDDetector.cc index 368276b9605e5..591862535d81b 100644 --- a/DetectorDescription/DDCMS/src/ES_DDDetector.cc +++ b/DetectorDescription/DDCMS/src/ES_DDDetector.cc @@ -2,7 +2,7 @@ #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "FWCore/Framework/interface/data_default_record_trait.h" using namespace cms; @@ -11,4 +11,4 @@ TYPELOOKUP_DATA_REG(DDDetector); TYPELOOKUP_DATA_REG(DDSpecParRegistry); TYPELOOKUP_DATA_REG(DDVectorRegistry); -EVENTSETUP_DATA_DEFAULT_RECORD(DDDetector, DetectorDescriptionRcd); +EVENTSETUP_DATA_DEFAULT_RECORD(DDDetector, GeometryFileRcd); diff --git a/DetectorDescription/Parser/test/testmat.cpp b/DetectorDescription/Parser/test/testmat.cpp index 1943eadc63f89..26fe40dcfabc9 100644 --- a/DetectorDescription/Parser/test/testmat.cpp +++ b/DetectorDescription/Parser/test/testmat.cpp @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); // E. Make the services available. diff --git a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp index 6216f0a364699..ad2811b6d0cf1 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp index 3c75786a062e8..4265de9943dc2 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp index 050f8f4abdb5b..abf34e5e9c78b 100644 --- a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc index 7d1d158f034e4..d6d550194524f 100644 --- a/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc +++ b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc @@ -7,7 +7,7 @@ #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/DTGeometry/interface/DTLayer.h" -#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Fireworks/Core/interface/FWGeometry.h" @@ -95,7 +95,7 @@ DTGeometryValidate::DTGeometryValidate(const edm::ParameterSet& iConfig) void DTGeometryValidate::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { - eventSetup.get().get(dtGeometry_); + eventSetup.get().get(dtGeometry_); if(dtGeometry_.isValid()) { LogVerbatim("DTGeometry") << "Validating DT chamber geometry"; diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc index fa000cdf74660..a94d440b41d21 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc @@ -30,9 +30,9 @@ #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" -#include "Geometry/Records/interface/MuonNumberingRcd.h" -#include "Geometry/Records/interface/MuonGeometryRcd.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc index 72579341f126f..49a7b52cbdd21 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc @@ -37,10 +37,10 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/ReusableObjectHolder.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" -#include "Geometry/Records/interface/MuonNumberingRcd.h" -#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/Records/interface/DDSpecParRegistryRcd.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" @@ -65,15 +65,15 @@ class DTGeometryESProducer : public ESProducer { using ReturnType = shared_ptr; using Detector = dd4hep::Detector; - ReturnType produce(const MuonGeometryRcd& record); + ReturnType produce(const MuonGeometryRecord& record); private: using HostType = ESProductHost; - void setupGeometry(MuonNumberingRcd const&, shared_ptr&); + void setupGeometry(MuonNumberingRecord const&, shared_ptr&); void setupDBGeometry(DTRecoGeometryRcd const&, shared_ptr&); ReusableObjectHolder m_holder; @@ -108,7 +108,7 @@ DTGeometryESProducer::DTGeometryESProducer(const ParameterSet & iConfig) DTGeometryESProducer::~DTGeometryESProducer(){} std::shared_ptr -DTGeometryESProducer::produce(const MuonGeometryRcd & record) { +DTGeometryESProducer::produce(const MuonGeometryRecord & record) { auto host = m_holder.makeOrGet([]() { return new HostType; @@ -118,7 +118,7 @@ DTGeometryESProducer::produce(const MuonGeometryRcd & record) { BenchmarkGrd counter("DTGeometryESProducer"); if(m_fromDDD) { - host->ifRecordChanges(record, + host->ifRecordChanges(record, [this, &host](auto const& rec) { setupGeometry(rec, host); }); @@ -159,7 +159,7 @@ DTGeometryESProducer::produce(const MuonGeometryRcd & record) { } void -DTGeometryESProducer::setupGeometry(const MuonNumberingRcd& record, +DTGeometryESProducer::setupGeometry(const MuonNumberingRecord& record, shared_ptr& host) { host->clear(); @@ -167,7 +167,7 @@ DTGeometryESProducer::setupGeometry(const MuonNumberingRcd& record, record.get(mdc); edm::ESTransientHandle cpv; - record.getRecord().get(m_tag.module(), cpv); + record.getRecord().get(m_tag.module(), cpv); ESTransientHandle registry; record.getRecord().get(m_tag.module(), registry); diff --git a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc index dd353c831b7d9..f3fcb359d1975 100644 --- a/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc @@ -4,7 +4,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include #include @@ -34,7 +34,7 @@ DTGeometryTest::analyze(const Event&, const EventSetup& iEventSetup) { LogVerbatim("Geometry") << "DTGeometryTest::analyze: " << m_label; ESTransientHandle pDD; - iEventSetup.get().get(m_label, pDD); + iEventSetup.get().get(m_label, pDD); LogVerbatim("Geometry") << " Geometry node for DTGeom is " << &(*pDD); LogVerbatim("Geometry") << " I have " << pDD->detTypes().size() << " detTypes"; diff --git a/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc index a42bcfbc54794..1f317d5e4deb4 100644 --- a/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc +++ b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include @@ -26,7 +26,7 @@ DDTestMuonNumbering::analyze(const Event&, const EventSetup& iEventSetup) { LogVerbatim("Geometry") << "DDTestMuonNumbering::analyze"; ESTransientHandle numbering; - iEventSetup.get().get(numbering); + iEventSetup.get().get(numbering); LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values().size(); LogVerbatim("Geometry").log([&numbering](auto& log) { diff --git a/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc index ef065de6c94e9..2d4f073c32c90 100644 --- a/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc +++ b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc @@ -23,7 +23,7 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonNumberingRecord.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" @@ -39,7 +39,7 @@ class MuonNumberingESProducer : public ESProducer { using ReturnType = unique_ptr; - ReturnType produce(const MuonNumberingRcd&); + ReturnType produce(const MuonNumberingRecord&); private: const string m_label; @@ -58,7 +58,7 @@ MuonNumberingESProducer::~MuonNumberingESProducer() {} MuonNumberingESProducer::ReturnType -MuonNumberingESProducer::produce(const MuonNumberingRcd& iRecord) +MuonNumberingESProducer::produce(const MuonNumberingRecord& iRecord) { LogDebug("Geometry") << "MuonNumberingESProducer::produce from " << m_label << " with " << m_key; auto product = make_unique(); diff --git a/Geometry/Records/interface/DDSpecParRegistryRcd.h b/Geometry/Records/interface/DDSpecParRegistryRcd.h index a15fe98073c61..db84073ccd1d1 100644 --- a/Geometry/Records/interface/DDSpecParRegistryRcd.h +++ b/Geometry/Records/interface/DDSpecParRegistryRcd.h @@ -2,9 +2,9 @@ #define GEOMETRY_RECORDS_DD_SPECPAR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "boost/mpl/vector.hpp" class DDSpecParRegistryRcd : public edm::eventsetup::DependentRecordImplementation< -DDSpecParRegistryRcd, boost::mpl::vector> {}; +DDSpecParRegistryRcd, boost::mpl::vector> {}; #endif diff --git a/Geometry/Records/interface/DDVectorRegistryRcd.h b/Geometry/Records/interface/DDVectorRegistryRcd.h index 70cdf499ccb55..191e6feaba85e 100644 --- a/Geometry/Records/interface/DDVectorRegistryRcd.h +++ b/Geometry/Records/interface/DDVectorRegistryRcd.h @@ -2,9 +2,9 @@ #define GEOMETRY_RECORDS_DD_VECTOR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" #include "boost/mpl/vector.hpp" class DDVectorRegistryRcd : public edm::eventsetup::DependentRecordImplementation< -DDVectorRegistryRcd, boost::mpl::vector> {}; +DDVectorRegistryRcd, boost::mpl::vector> {}; #endif diff --git a/Geometry/Records/interface/DetectorDescriptionRcd.h b/Geometry/Records/interface/DetectorDescriptionRcd.h deleted file mode 100644 index 2cc78dafa7a1c..0000000000000 --- a/Geometry/Records/interface/DetectorDescriptionRcd.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GEOMETRY_RECORDS_DETECTOR_DESCRIPTION_RCD_H -#define GEOMETRY_RECORDS_DETECTOR_DESCRIPTION_RCD_H - -#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" -class DetectorDescriptionRcd : public edm::eventsetup::EventSetupRecordImplementation {}; -#endif diff --git a/Geometry/Records/interface/MuonGeometryRcd.h b/Geometry/Records/interface/MuonGeometryRcd.h deleted file mode 100644 index 2596cabfe9b42..0000000000000 --- a/Geometry/Records/interface/MuonGeometryRcd.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef GEOMETRY_RECORDS_MUON_GEOMETRY_RCD_H -#define GEOMETRY_RECORDS_MUON_GEOMETRY_RCD_H - -#include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" -#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" -#include "Geometry/Records/interface/MuonNumberingRcd.h" -#include "Geometry/Records/interface/DTRecoGeometryRcd.h" -#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorRcd.h" -#include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" -#include "boost/mpl/vector.hpp" - -class MuonGeometryRcd : public edm::eventsetup::DependentRecordImplementation< -MuonGeometryRcd, boost::mpl::vector> {}; -#endif diff --git a/Geometry/Records/interface/MuonGeometryRecord.h b/Geometry/Records/interface/MuonGeometryRecord.h index 364f2ad6d5361..d61294f76d1a8 100644 --- a/Geometry/Records/interface/MuonGeometryRecord.h +++ b/Geometry/Records/interface/MuonGeometryRecord.h @@ -10,6 +10,8 @@ #include "FWCore/Framework/interface/EventSetupRecordImplementation.h" #include "FWCore/Framework/interface/DependentRecordImplementation.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "Geometry/Records/interface/MuonNumberingRecord.h" #include "Geometry/Records/interface/ME0RecoGeometryRcd.h" #include "Geometry/Records/interface/GEMRecoGeometryRcd.h" @@ -25,6 +27,6 @@ #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" -class MuonGeometryRecord : public edm::eventsetup::DependentRecordImplementation > {}; +class MuonGeometryRecord : public edm::eventsetup::DependentRecordImplementation > {}; #endif diff --git a/Geometry/Records/interface/MuonNumberingRcd.h b/Geometry/Records/interface/MuonNumberingRcd.h deleted file mode 100644 index 7725b038cb943..0000000000000 --- a/Geometry/Records/interface/MuonNumberingRcd.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GEOMETRY_RECORDS_MUON_NUMBERING_RCD_H -#define GEOMETRY_RECORDS_MUON_NUMBERING_RCD_H - -#include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" -#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" -#include "boost/mpl/vector.hpp" - -class MuonNumberingRcd : public edm::eventsetup::DependentRecordImplementation< -MuonNumberingRcd, boost::mpl::vector> {}; -#endif diff --git a/Geometry/Records/interface/MuonNumberingRecord.h b/Geometry/Records/interface/MuonNumberingRecord.h index 6ed4ebcd0330b..79656deafbb07 100644 --- a/Geometry/Records/interface/MuonNumberingRecord.h +++ b/Geometry/Records/interface/MuonNumberingRecord.h @@ -20,11 +20,13 @@ #include #include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/Records/interface/GeometryFileRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "FWCore/Framework/interface/DependentRecordImplementation.h" #include "Geometry/Records/interface/CSCRecoDigiParametersRcd.h" #include "Geometry/Records/interface/CSCRecoGeometryRcd.h" #include "Geometry/Records/interface/DTRecoGeometryRcd.h" -class MuonNumberingRecord : public edm::eventsetup::DependentRecordImplementation > {}; +class MuonNumberingRecord : public edm::eventsetup::DependentRecordImplementation > {}; #endif diff --git a/Geometry/Records/src/DetectorDescriptionRcd.cc b/Geometry/Records/src/DetectorDescriptionRcd.cc deleted file mode 100644 index 62fb1f2506ab0..0000000000000 --- a/Geometry/Records/src/DetectorDescriptionRcd.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "Geometry/Records/interface/DetectorDescriptionRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" - -EVENTSETUP_RECORD_REG(DetectorDescriptionRcd); diff --git a/Geometry/Records/src/MuonGeometryRcd.cc b/Geometry/Records/src/MuonGeometryRcd.cc deleted file mode 100644 index ce708b1216097..0000000000000 --- a/Geometry/Records/src/MuonGeometryRcd.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "Geometry/Records/interface/MuonGeometryRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" - -EVENTSETUP_RECORD_REG(MuonGeometryRcd); diff --git a/Geometry/Records/src/MuonNumberingRcd.cc b/Geometry/Records/src/MuonNumberingRcd.cc deleted file mode 100644 index 32a182a28d6ed..0000000000000 --- a/Geometry/Records/src/MuonNumberingRcd.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "Geometry/Records/interface/MuonNumberingRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" - -EVENTSETUP_RECORD_REG(MuonNumberingRcd); From e8b16e00fda3f089fb04002478d573eedf985f37 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Thu, 4 Apr 2019 11:40:07 +0200 Subject: [PATCH 440/686] Changed type of singStripIeta to bool. Added some cosmetic changes in code. --- .../HcalRecAlgos/src/HFStripFilter.cc | 188 +++++++++--------- 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index db53d74b79362..698c5ae6c02b2 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -34,7 +34,6 @@ HFStripFilter::~HFStripFilter() edm::LogInfo("HFStripFilter") << "destructor called"; } - void HFStripFilter::runFilter(HFRecHitCollection& rec, const HcalChannelQuality* myqual) const { @@ -49,25 +48,23 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, d1max.setEnergy(-10); // find d1 and d2 seed hits with max energy and time < timeMax_ - for (auto& it : rec) - { - if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; - // find HF hit with maximum signal in depth = 1 - if (it.id().depth() == 1) { - if (it.energy() > d1max.energy() && std::abs(it.id().ieta()) < seedHitIetaMax_) { - d1max = it; - } + for (auto& it : rec) { + if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; + // find HF hit with maximum signal in depth = 1 + if (it.id().depth() == 1) { + if (it.energy() > d1max.energy() && std::abs(it.id().ieta()) < seedHitIetaMax_) { + d1max = it; } } + } - if (d1max.energy() > 0) d1strip.push_back(d1max); - - int signStripIeta = 0; + bool signStripIeta = false; int stripIphiMax = 0; int stripIetaMax = 0; int stripDepthMax = 0; if (d1max.energy() > 0) { + d1strip.push_back(d1max); signStripIeta = std::signbit(d1max.id().ieta()); stripIphiMax = d1max.id().iphi(); stripIetaMax = d1max.id().ieta(); @@ -75,14 +72,13 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, } d2max.setEnergy(-10); - for (auto& it : rec) - { - if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; - // find HFhit with maximum signal in depth = 2 - if (it.id().depth() == 2 && it.energy() > d2max.energy() && std::abs(it.id().ieta()) - < seedHitIetaMax_) { + for (auto& it : rec) { + if (it.time() > timeMax_ || it.time() < 0 || it.energy() < stripThreshold_) continue; + // find HFhit with maximum signal in depth = 2 + if (it.id().depth() == 2) { + if (it.energy() > d2max.energy() && std::abs(it.id().ieta()) < seedHitIetaMax_) { if (d1max.energy() > 0) { - int signIeta = std::signbit(it.id().ieta()); + bool signIeta = std::signbit(it.id().ieta()); if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta) { d2max = it; } @@ -91,10 +87,11 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, } } } + } if (d2max.energy() > 0) d2strip.push_back(d2max); - // check if possible seed hits have energies not too small + // check if at least one of possible seed hits has enough energy if (d1max.energy() < maxThreshold_ && d2max.energy() < maxThreshold_) return; if (d1max.energy() <= 0 && d2max.energy() > 0) { @@ -108,97 +105,99 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, if (verboseLevel_ >= 30) { if (d1max.energy() > 0) { ss << " MaxHit in Depth 1: ieta = " << d1max.id().ieta() << " iphi = " << stripIphiMax - << " energy = " << d1max.energy() << " time = " << d1max.time() << std::endl; } + << " energy = " << d1max.energy() << " time = " << d1max.time() << std::endl; + } if (d2max.energy() > 0) { ss << " MaxHit in Depth 2: ieta = " << d2max.id().ieta() << " iphi = " << stripIphiMax - << " energy = " << d2max.energy() << " time = " << d2max.time() << std::endl; } + << " energy = " << d2max.energy() << " time = " << d2max.time() << std::endl; + } ss << " stripThreshold_ = " << stripThreshold_ << std::endl; } // prepare the strips: all hits along given ieta in one wedge (d1strip and d2strip) //--------------------------------------------------------------------------------- - for (auto& it : rec) - { - if (it.energy() < stripThreshold_) continue; - int signIeta = std::signbit(it.id().ieta()); + for (auto& it : rec) { + if (it.energy() < stripThreshold_) continue; + bool signIeta = std::signbit(it.id().ieta()); - if (verboseLevel_ >= 30) { - ss << " HF hit: ieta = " << it.id().ieta() << "\t iphi = " << it.id().iphi() - << "\t depth = " << it.id().depth() << "\t time = " << it.time() << "\t energy = " - << it.energy() << "\t flags = " << it.flags() << std::endl; - } + if (verboseLevel_ >= 30) { + ss << " HF hit: ieta = " << it.id().ieta() << "\t iphi = " << it.id().iphi() + << "\t depth = " << it.id().depth() << "\t time = " << it.time() << "\t energy = " + << it.energy() << "\t flags = " << it.flags() << std::endl; + } - // collect hits with the same iphi but different ieta into strips - if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta && - it.time() < maxStripTime_) { - if (it.id().depth() == 1) { - // check if hit = it is already in d1strip - bool pass = false; - if (d1strip.empty()) { - if (std::abs(it.id().iphi() - stripIetaMax) <= gap_) { - d1strip.push_back(it); - pass = true; - } - } else { - for (auto& it1 : d1strip) { - if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { - pass = true; - break; - } - } + // collect hits with the same iphi but different ieta into strips + if (it.id().iphi() == stripIphiMax && signIeta == signStripIeta && it.time() < maxStripTime_) { + if (it.id().depth() == 1) { + // check if hit = it is already in d1strip + bool pass = false; + if (d1strip.empty()) { + if (std::abs(it.id().iphi() - stripIetaMax) <= gap_) { + d1strip.push_back(it); + pass = true; } - if (pass) continue; - // add hit = (*it) to d1strip if distance to the closest hit in d1strip <= gap_ - for (auto& it1 : d1strip) { - // check distance along Ieta to the closest hit - if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { - d1strip.push_back(it); + } else { + for (auto& it1 : d1strip) { + if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { + pass = true; break; } } } - else if (it.id().depth() == 2) { - // check if hit = it is already in d2strip - bool pass= false; - if (d2strip.empty()) { - if (std::abs(it.id().ieta() - stripIetaMax) <= gap_) { - d2strip.push_back(it); - pass = true; - } - } else { - for (auto& it1 : d2strip) { - if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { - pass = true; - break; - } + if (pass) continue; + // add hit = it to d1strip if distance to the closest hit in d1strip <= gap_ + for (auto& it1 : d1strip) { + // check distance along Ieta to the closest hit + if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { + d1strip.push_back(it); + break; + } + } + } + else if (it.id().depth() == 2) { + // check if hit = it is already in d2strip + bool pass= false; + if (d2strip.empty()) { + if (std::abs(it.id().ieta() - stripIetaMax) <= gap_) { + d2strip.push_back(it); + pass = true; + } + } else { + for (auto& it1 : d2strip) { + if (it.id().ieta() == it1.id().ieta() && it.energy() == it1.energy()) { + pass = true; + break; } } - if (pass) continue; + } + if (pass) continue; - // add hit = (*it) to d2strip if distance to the closest hit in d1strip <= gap_ - for (auto& it1 : d2strip) { - // check distance along Ieta to the closest hit - if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { - d2strip.push_back(it); - break; - } + // add hit = it to d2strip if distance to the closest hit in d1strip <= gap_ + for (auto& it1 : d2strip) { + // check distance along Ieta to the closest hit + if (std::abs(it1.id().ieta() - it.id().ieta()) <= gap_) { + d2strip.push_back(it); + break; } - } + } } } + } if (verboseLevel_ >= 30) { ss << " Lstrip1 = " << (int)d1strip.size() << " (iphi = " << stripIphiMax << ") Lstrip2 = " << (int)d2strip.size() << std::endl << " Strip1: "; for (auto& it1 : d1strip) { - ss << it1.energy() << " (" << it1.id().ieta() << ") "; } + ss << it1.energy() << " (" << it1.id().ieta() << ") "; + } ss << std::endl << " Strip2: "; for (auto& it1 : d2strip) { - ss << it1.energy() << " (" << it1.id().ieta() << ") "; } + ss << it1.energy() << " (" << it1.id().ieta() << ") "; + } ss << std::endl; } - // check if one of strips in depth1 or depth2 >= lstrips_ + // check if at least one of strips in depth1 or depth2 is not less than lstrips_ if ((int)d1strip.size() < lstrips_ && (int)d2strip.size() < lstrips_) { if (verboseLevel_ >= 30) { LogDebug("HFSFilter") << ss.str(); @@ -256,18 +255,17 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, // get information about the neighboring wedges from HcalTopology HcalDetId neighbour; - for (auto& it : rec) - { - if (it.energy() < stripThreshold_) continue; - if (it.id().ieta() < ietaMin || it.id().ieta() > ietaMax) continue; - HcalDetId id(HcalForward, it.id().ieta(), stripIphiMax, stripDepthMax); - bool neigh = myqual->topo()->decIPhi(id, neighbour); - iphi1 = (neigh) ? neighbour.iphi() : 0; - neigh = myqual->topo()->incIPhi(id, neighbour); - iphi2 = (neigh) ? neighbour.iphi() : 0; - if (it.id().iphi() == iphi1) energyIphi1 += it.energy(); // Energy iphi1 - else if (it.id().iphi() == iphi2) energyIphi2 += it.energy(); // Energy iphi2 - } + for (auto& it : rec) { + if (it.energy() < stripThreshold_) continue; + if (it.id().ieta() < ietaMin || it.id().ieta() > ietaMax) continue; + HcalDetId id(HcalForward, it.id().ieta(), stripIphiMax, stripDepthMax); + bool neigh = myqual->topo()->decIPhi(id, neighbour); + iphi1 = (neigh) ? neighbour.iphi() : 0; + neigh = myqual->topo()->incIPhi(id, neighbour); + iphi2 = (neigh) ? neighbour.iphi() : 0; + if (it.id().iphi() == iphi1) energyIphi1 += it.energy(); // Energy iphi1 + else if (it.id().iphi() == iphi2) energyIphi2 += it.energy(); // Energy iphi2 + } double ratio1 = eStrip > 0 ? energyIphi1/eStrip : 0; double ratio2 = eStrip > 0 ? energyIphi2/eStrip : 0; @@ -289,7 +287,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, << " mark hits in strips now " << std::endl; } - // Figure out which rechits need to be tagged (d1.strip) + // Figure out which rechits need to be tagged (d1strip) for (auto& it1 : d1strip) { if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; HFRecHitCollection::iterator hit = rec.find(it1.id()); @@ -302,7 +300,7 @@ void HFStripFilter::runFilter(HFRecHitCollection& rec, } } - // Figure out which rechits need to be tagged (d2.strip) + // Figure out which rechits need to be tagged (dstrip) for (auto& it1 : d2strip) { if (it1.id().ieta() < ietaMin || it1.id().ieta() > ietaMax) continue; HFRecHitCollection::iterator hit = rec.find(it1.id()); From 08b1330c7c8f414db45c4e0e434312bf68bb1092 Mon Sep 17 00:00:00 2001 From: david walter Date: Thu, 4 Apr 2019 12:06:55 +0200 Subject: [PATCH 441/686] mainly cosmetics: fix poor naming convention, fix poor histogram binning and disable electron Z counting --- DQMOffline/Lumi/plugins/ZCounting.cc | 61 +++++++++++++------------ DQMOffline/Lumi/plugins/ZCounting.h | 8 ++-- DQMOffline/Lumi/python/ZCounting_cff.py | 4 +- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/DQMOffline/Lumi/plugins/ZCounting.cc b/DQMOffline/Lumi/plugins/ZCounting.cc index a6b9d3ee7c67c..dceef0612016b 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.cc +++ b/DQMOffline/Lumi/plugins/ZCounting.cc @@ -151,10 +151,10 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_mass_SIT_fail_central = ibooker_.book2D("h_mass_SIT_fail_central", "Muon SIT_failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); h_mass_SIT_fail_forward = ibooker_.book2D("h_mass_SIT_fail_forward", "Muon SIT failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_pass_central = ibooker_.book2D("h_mass_Sta_pass_central", "Muon Sta passing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_pass_forward = ibooker_.book2D("h_mass_Sta_pass_forward", "Muon Sta passing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_fail_central = ibooker_.book2D("h_mass_Sta_fail_central", "Muon Sta failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_mass_Sta_fail_forward = ibooker_.book2D("h_mass_Sta_fail_forward", "Muon Sta failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Glo_pass_central = ibooker_.book2D("h_mass_Glo_pass_central", "Muon Glo passing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Glo_pass_forward = ibooker_.book2D("h_mass_Glo_pass_forward", "Muon Glo passing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Glo_fail_central = ibooker_.book2D("h_mass_Glo_fail_central", "Muon Glo failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_mass_Glo_fail_forward = ibooker_.book2D("h_mass_Glo_fail_forward", "Muon Glo failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); h_npv = ibooker_.book2D("h_npv", "Events with valid primary vertex", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); h_yield_Z = ibooker_.book1D("h_yield_Z", "reconstructed Z bosons", LumiBin_, LumiMin_, LumiMax_); @@ -170,10 +170,10 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_mass_SIT_pass_forward ->setAxisTitle("luminosiry section",1); h_mass_SIT_fail_central ->setAxisTitle("luminosiry section",1); h_mass_SIT_fail_forward ->setAxisTitle("luminosiry section",1); - h_mass_Sta_pass_central ->setAxisTitle("luminosiry section",1); - h_mass_Sta_pass_forward ->setAxisTitle("luminosiry section",1); - h_mass_Sta_fail_central ->setAxisTitle("luminosiry section",1); - h_mass_Sta_fail_forward ->setAxisTitle("luminosiry section",1); + h_mass_Glo_pass_central ->setAxisTitle("luminosiry section",1); + h_mass_Glo_pass_forward ->setAxisTitle("luminosiry section",1); + h_mass_Glo_fail_central ->setAxisTitle("luminosiry section",1); + h_mass_Glo_fail_forward ->setAxisTitle("luminosiry section",1); h_mass_HLT_pass_central ->setAxisTitle("tag and probe mass",2); h_mass_HLT_pass_forward ->setAxisTitle("tag and probe mass",2); h_mass_HLT_fail_central ->setAxisTitle("tag and probe mass",2); @@ -182,16 +182,17 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_mass_SIT_pass_forward ->setAxisTitle("tag and probe mass",2); h_mass_SIT_fail_central ->setAxisTitle("tag and probe mass",2); h_mass_SIT_fail_forward ->setAxisTitle("tag and probe mass",2); - h_mass_Sta_pass_central ->setAxisTitle("tag and probe mass",2); - h_mass_Sta_pass_forward ->setAxisTitle("tag and probe mass",2); - h_mass_Sta_fail_central ->setAxisTitle("tag and probe mass",2); - h_mass_Sta_fail_forward ->setAxisTitle("tag and probe mass",2); + h_mass_Glo_pass_central ->setAxisTitle("tag and probe mass",2); + h_mass_Glo_pass_forward ->setAxisTitle("tag and probe mass",2); + h_mass_Glo_fail_central ->setAxisTitle("tag and probe mass",2); + h_mass_Glo_fail_forward ->setAxisTitle("tag and probe mass",2); h_npv ->setAxisTitle("luminosity section", 1); h_npv ->setAxisTitle("number of primary vertices", 2); h_yield_Z ->setAxisTitle("luminosiry section",1); h_yieldBB_Z ->setAxisTitle("luminosiry section",1); h_yieldEE_Z ->setAxisTitle("luminosiry section",1); + /* // Electron histograms h_ee_mass_id_pass_central = ibooker_.book2D("h_ee_mass_id_pass_central", "h_ee_mass_id_pass_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); h_ee_mass_id_fail_central = ibooker_.book2D("h_ee_mass_id_fail_central", "h_ee_mass_id_fail_central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); @@ -205,7 +206,7 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_ee_yield_Z_ebeb = ibooker_.book1D("h_ee_yield_Z_ebeb", "h_ee_yield_Z_ebeb", LumiBin_, LumiMin_, LumiMax_); h_ee_yield_Z_ebee = ibooker_.book1D("h_ee_yield_Z_ebee", "h_ee_yield_Z_ebee", LumiBin_, LumiMin_, LumiMax_); - h_ee_yield_Z_eeee = ibooker_.book1D("h_ee_yield_Z_eeee", "h_ee_yield_Z_eeee", LumiBin_, LumiMin_, LumiMax_); + h_ee_yield_Z_eeee = ibooker_.book1D("h_ee_yield_Z_eeee", "h_ee_yield_Z_eeee", LumiBin_, LumiMin_, LumiMax_);*/ } // @@ -216,7 +217,7 @@ void ZCounting::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {// Fill event tree on the fly edm::LogInfo("ZCounting") << "ZCounting::analyze" << std::endl; analyzeMuons(iEvent, iSetup); - analyzeElectrons(iEvent, iSetup); + //analyzeElectrons(iEvent, iSetup); } void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -351,25 +352,25 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS if(isTagCentral){ h_mass_HLT_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { h_mass_HLT_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); } if(isProbeCentral){ h_mass_HLT_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { h_mass_HLT_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); } } @@ -378,13 +379,13 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS if(isProbeCentral){ h_mass_HLT_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { h_mass_HLT_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); h_mass_SIT_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); } } @@ -394,35 +395,35 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS else if(!isTagCentral && !isProbeCentral) h_yieldEE_Z->Fill(iEvent.luminosityBlock()); } else if(itMu2.isGlobalMuon()){ - // category NoSel: probe is a GLB muon but failing selection + // category Glo: probe is a Global muon but failing selection if(isProbeCentral){ h_mass_SIT_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { h_mass_SIT_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); - h_mass_Sta_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_pass_forward->Fill(iEvent.luminosityBlock(), dilepMass); } } else if(itMu2.isStandAloneMuon()){ - // category STA: probe is a STA muon + // category Sta: probe is a Standalone muon if(isProbeCentral){ - h_mass_Sta_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { - h_mass_Sta_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); } } else if(itMu2.innerTrack()->hitPattern().trackerLayersWithMeasurement() >= 6 && itMu2.innerTrack()->hitPattern().numberOfValidPixelHits() >= 1){ // cateogry Trk: probe is a tracker track if(isProbeCentral){ - h_mass_Sta_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); } else { - h_mass_Sta_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); + h_mass_Glo_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); } } @@ -461,8 +462,8 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS if(fabs(eta2) > MUON_BOUND) isTrackCentral = true; if(itTrk.hitPattern().trackerLayersWithMeasurement() >= 6 && itTrk.hitPattern().numberOfValidPixelHits() >= 1){ - if(isTrackCentral) h_mass_Sta_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); - else h_mass_Sta_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); + if(isTrackCentral) h_mass_Glo_fail_central->Fill(iEvent.luminosityBlock(), dilepMass); + else h_mass_Glo_fail_forward->Fill(iEvent.luminosityBlock(), dilepMass); } }//End of probe loop over tracks diff --git a/DQMOffline/Lumi/plugins/ZCounting.h b/DQMOffline/Lumi/plugins/ZCounting.h index 352594b8f4488..e863413a2398c 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.h +++ b/DQMOffline/Lumi/plugins/ZCounting.h @@ -173,10 +173,10 @@ class ZCounting: public DQMEDAnalyzer{ MonitorElement* h_mass_SIT_fail_central; MonitorElement* h_mass_SIT_fail_forward; - MonitorElement* h_mass_Sta_pass_central; - MonitorElement* h_mass_Sta_pass_forward; - MonitorElement* h_mass_Sta_fail_central; - MonitorElement* h_mass_Sta_fail_forward; + MonitorElement* h_mass_Glo_pass_central; + MonitorElement* h_mass_Glo_pass_forward; + MonitorElement* h_mass_Glo_fail_central; + MonitorElement* h_mass_Glo_fail_forward; MonitorElement* h_npv; MonitorElement* h_yield_Z; diff --git a/DQMOffline/Lumi/python/ZCounting_cff.py b/DQMOffline/Lumi/python/ZCounting_cff.py index 7976c2b4b3904..57240ac4bdfcc 100644 --- a/DQMOffline/Lumi/python/ZCounting_cff.py +++ b/DQMOffline/Lumi/python/ZCounting_cff.py @@ -43,8 +43,8 @@ MassMax = cms.untracked.double(116.0), LumiBin = cms.untracked.int32(2500), - LumiMin = cms.untracked.double(0.0), - LumiMax = cms.untracked.double(2500.0), + LumiMin = cms.untracked.double(0.5), + LumiMax = cms.untracked.double(2500.5), PVBin = cms.untracked.int32(60), PVMin = cms.untracked.double(0.0), From 9b32a7fc9f21e28186dc278f4c8392d9584ffb68 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 12:14:05 +0200 Subject: [PATCH 442/686] move PythonFramework to PyDevParameterSet --- .../interface/PyBind11ProcessDesc.h | 2 +- FWCore/PyDevParameterSet/src/PyBind11Module.h | 9 ++++-- .../src/PyBind11ProcessDesc.cc | 18 +++++++----- FWCore/PythonFramework/BuildFile.xml | 4 +-- .../interface/PythonEventProcessor.h | 3 +- FWCore/PythonFramework/python/CmsRun.py | 3 +- .../src/PythonEventProcessor.cc | 4 +-- FWCore/PythonFramework/src/PythonModule.cc | 28 +++++++++++-------- 8 files changed, 43 insertions(+), 28 deletions(-) diff --git a/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h b/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h index 037e142bea351..1021d662f54fc 100644 --- a/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h +++ b/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h @@ -50,7 +50,7 @@ class PyBind11ProcessDesc { Python11ParameterSet theProcessPSet; pybind11::object theMainModule; - // pybind11::object theMainNamespace; + bool theOwnsInterpreter; }; #endif diff --git a/FWCore/PyDevParameterSet/src/PyBind11Module.h b/FWCore/PyDevParameterSet/src/PyBind11Module.h index 2f71869a4dd30..148ddd0620767 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11Module.h +++ b/FWCore/PyDevParameterSet/src/PyBind11Module.h @@ -34,8 +34,13 @@ PYBIND11_MODULE(libFWCorePyDevParameterSet,m) { - - // pybind11::register_exception_translator(translatorlibFWCorePythonParameterSet); + pybind11::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const cms::Exception &e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + } + }); pybind11::class_(m,"InputTag") .def(pybind11::init<>()) diff --git a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc index 1728448801bb0..7baf569bdd40d 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc @@ -11,14 +11,15 @@ PyBind11ProcessDesc::PyBind11ProcessDesc() : theProcessPSet(), - theMainModule() + theMainModule(), + theOwnsInterpreter(false) { - pybind11::initialize_interpreter(); } PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config) : theProcessPSet(), - theMainModule() + theMainModule(), + theOwnsInterpreter(true) { pybind11::initialize_interpreter(); edm::python::initializePyBind11Module(); @@ -29,7 +30,9 @@ PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config) : PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config, int argc, char* argv[]) : theProcessPSet(), - theMainModule() + theMainModule(), + theOwnsInterpreter(true) + { pybind11::initialize_interpreter(); edm::python::initializePyBind11Module(); @@ -58,9 +61,10 @@ PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config, int argc, ch PyBind11ProcessDesc::~PyBind11ProcessDesc() { - theMainModule=pybind11::object(); - pybind11::finalize_interpreter(); - + if ( theOwnsInterpreter ) { + theMainModule=pybind11::object(); + pybind11::finalize_interpreter(); + } } void PyBind11ProcessDesc::prepareToRead() { diff --git a/FWCore/PythonFramework/BuildFile.xml b/FWCore/PythonFramework/BuildFile.xml index 500892db85659..8551be07e579f 100644 --- a/FWCore/PythonFramework/BuildFile.xml +++ b/FWCore/PythonFramework/BuildFile.xml @@ -1,7 +1,7 @@ - + - + diff --git a/FWCore/PythonFramework/interface/PythonEventProcessor.h b/FWCore/PythonFramework/interface/PythonEventProcessor.h index 9fd5a63f0c3e8..3a484ee58aed8 100644 --- a/FWCore/PythonFramework/interface/PythonEventProcessor.h +++ b/FWCore/PythonFramework/interface/PythonEventProcessor.h @@ -20,6 +20,7 @@ // system include files #include "FWCore/Framework/interface/EventProcessor.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" // user include files @@ -30,7 +31,7 @@ class PythonEventProcessor { public: - PythonEventProcessor(PythonProcessDesc const&); + PythonEventProcessor(PyBind11ProcessDesc const&); ~PythonEventProcessor(); // ---------- const member functions --------------------- /// Return the number of events this EventProcessor has tried to process diff --git a/FWCore/PythonFramework/python/CmsRun.py b/FWCore/PythonFramework/python/CmsRun.py index 8206ce714eff9..191984d50e9a3 100644 --- a/FWCore/PythonFramework/python/CmsRun.py +++ b/FWCore/PythonFramework/python/CmsRun.py @@ -1,5 +1,5 @@ import libFWCorePythonFramework as _pf -import libFWCorePythonParameterSet as _pp +import libFWCorePyDevParameterSet as _pp class CmsRun(object): def __init__(self,process): @@ -8,6 +8,7 @@ def __init__(self,process): procDesc = _pp.ProcessDesc() process.fillProcessDesc(procDesc.pset()) self._cppProcessor = _pf.PythonEventProcessor(procDesc) + def run(self): """Process all the events """ diff --git a/FWCore/PythonFramework/src/PythonEventProcessor.cc b/FWCore/PythonFramework/src/PythonEventProcessor.cc index 290ab1a295a05..46d24bb5182e7 100644 --- a/FWCore/PythonFramework/src/PythonEventProcessor.cc +++ b/FWCore/PythonFramework/src/PythonEventProcessor.cc @@ -15,7 +15,7 @@ // user include files #include "FWCore/PythonFramework/interface/PythonEventProcessor.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" #include "FWCore/Framework/interface/defaultCmsRunServices.h" #include "FWCore/ParameterSet/interface/ProcessDesc.h" @@ -58,7 +58,7 @@ namespace { // // constructors and destructor // -PythonEventProcessor::PythonEventProcessor(PythonProcessDesc const& iDesc) +PythonEventProcessor::PythonEventProcessor(PyBind11ProcessDesc const& iDesc) : forcePluginSetupFirst_(setupPluginSystem()) ,processor_(addDefaultServicesToProcessDesc(iDesc.processDesc()),createJobReport(),edm::serviceregistry::kOverlapIsError) { diff --git a/FWCore/PythonFramework/src/PythonModule.cc b/FWCore/PythonFramework/src/PythonModule.cc index 07e5c7459d39b..fe62821e6e579 100644 --- a/FWCore/PythonFramework/src/PythonModule.cc +++ b/FWCore/PythonFramework/src/PythonModule.cc @@ -1,12 +1,14 @@ #ifndef FWCore_PythonFramework_PythonModule_h #define FWCore_PythonFramework_PythonModule_h -#include "FWCore/PythonParameterSet/interface/BoostPython.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" + +#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" #include "FWCore/PythonFramework/interface/PythonEventProcessor.h" #include "FWCore/Utilities/interface/Exception.h" +#include + // This is to give some special handling to cms::Exceptions thrown // in C++ code called by python. Only at the very top level do // we need the exception message returned by the function "what". @@ -16,21 +18,23 @@ // improve these messages even more by adding something in the python // to add module type and label context to the messages being caught // here. At this point we did not think it worth the time to implement. -namespace { - void translator(cms::Exception const& ex) { - PyErr_SetString(PyExc_RuntimeError, ex.message().c_str()); - } -} -BOOST_PYTHON_MODULE(libFWCorePythonFramework) +PYBIND11_MODULE(libFWCorePythonFramework,m) { - boost::python::register_exception_translator(translator); + pybind11::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const cms::Exception &e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + } + }); - boost::python::class_("PythonEventProcessor", boost::python::init()) + pybind11::class_(m,"PythonEventProcessor") + .def(pybind11::init()) .def("run", &PythonEventProcessor::run) .def("totalEvents", &PythonEventProcessor::totalEvents) .def("totalEventsPassed", &PythonEventProcessor::totalEventsPassed) - .def("totalEventsFailed", &PythonEventProcessor::totalEventsFailed) - ; + .def("totalEventsFailed", &PythonEventProcessor::totalEventsFailed); + } #endif From acec66203b93f8b4b57790caa93237e2bc472c25 Mon Sep 17 00:00:00 2001 From: david walter Date: Thu, 4 Apr 2019 12:22:50 +0200 Subject: [PATCH 443/686] add 2d histograms for pileup corrections and background subtraction --- DQMOffline/Lumi/plugins/ZCounting.cc | 22 ++++++++++++++-------- DQMOffline/Lumi/plugins/ZCounting.h | 3 ++- DQMOffline/Lumi/python/ZCounting_cff.py | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/DQMOffline/Lumi/plugins/ZCounting.cc b/DQMOffline/Lumi/plugins/ZCounting.cc index dceef0612016b..310fd26f6709c 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.cc +++ b/DQMOffline/Lumi/plugins/ZCounting.cc @@ -156,10 +156,11 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_mass_Glo_fail_central = ibooker_.book2D("h_mass_Glo_fail_central", "Muon Glo failing probes central", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); h_mass_Glo_fail_forward = ibooker_.book2D("h_mass_Glo_fail_forward", "Muon Glo failing probes forward", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); - h_npv = ibooker_.book2D("h_npv", "Events with valid primary vertex", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); - h_yield_Z = ibooker_.book1D("h_yield_Z", "reconstructed Z bosons", LumiBin_, LumiMin_, LumiMax_); - h_yieldBB_Z = ibooker_.book1D("h_yieldBB_Z", "reconstructed Z bosons in barrel", LumiBin_, LumiMin_, LumiMax_); - h_yieldEE_Z = ibooker_.book1D("h_yieldEE_Z", "reconstructed Z bosons in endcap", LumiBin_, LumiMin_, LumiMax_); + h_npv = ibooker_.book2D("h_npv", "Events with valid primary vertex", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); + h_mass_yield_Z = ibooker_.book2D("h_mass_yield_Z", "reconstructed Z bosons", LumiBin_, LumiMin_, LumiMax_, MassBin_, MassMin_, MassMax_); + h_npv_yield_Z = ibooker_.book2D("h_npv_yield_Z", "reconstructed Z bosons", LumiBin_, LumiMin_, LumiMax_, PVBin_, PVMin_, PVMax_); + h_yieldBB_Z = ibooker_.book1D("h_yieldBB_Z", "reconstructed Z bosons in barrel", LumiBin_, LumiMin_, LumiMax_); + h_yieldEE_Z = ibooker_.book1D("h_yieldEE_Z", "reconstructed Z bosons in endcap", LumiBin_, LumiMin_, LumiMax_); // Axis titles h_mass_HLT_pass_central ->setAxisTitle("luminosiry section",1); @@ -186,9 +187,13 @@ void ZCounting::bookHistograms(DQMStore::IBooker & ibooker_, edm::Run const &, e h_mass_Glo_pass_forward ->setAxisTitle("tag and probe mass",2); h_mass_Glo_fail_central ->setAxisTitle("tag and probe mass",2); h_mass_Glo_fail_forward ->setAxisTitle("tag and probe mass",2); - h_npv ->setAxisTitle("luminosity section", 1); - h_npv ->setAxisTitle("number of primary vertices", 2); - h_yield_Z ->setAxisTitle("luminosiry section",1); + h_npv ->setAxisTitle("luminosity section", 1); + h_npv ->setAxisTitle("number of primary vertices", 2); + h_npv_yield_Z ->setAxisTitle("luminosiry section",1); + h_npv_yield_Z ->setAxisTitle("number of primary vertices",2); + h_mass_yield_Z ->setAxisTitle("luminosiry section",1); + h_mass_yield_Z ->setAxisTitle("tag and probe mass",2); + h_yieldBB_Z ->setAxisTitle("luminosiry section",1); h_yieldEE_Z ->setAxisTitle("luminosiry section",1); @@ -390,7 +395,8 @@ void ZCounting::analyzeMuons(const edm::Event& iEvent, const edm::EventSetup& iS } // category 2HLT + 1HLT: Fill once for Z yield - h_yield_Z->Fill(iEvent.luminosityBlock()); + h_npv_yield_Z->Fill(iEvent.luminosityBlock(), nvtx); + h_mass_yield_Z->Fill(iEvent.luminosityBlock(), dilepMass); if(isTagCentral && isProbeCentral) h_yieldBB_Z->Fill(iEvent.luminosityBlock()); else if(!isTagCentral && !isProbeCentral) h_yieldEE_Z->Fill(iEvent.luminosityBlock()); } diff --git a/DQMOffline/Lumi/plugins/ZCounting.h b/DQMOffline/Lumi/plugins/ZCounting.h index e863413a2398c..913df5e30984c 100644 --- a/DQMOffline/Lumi/plugins/ZCounting.h +++ b/DQMOffline/Lumi/plugins/ZCounting.h @@ -179,7 +179,8 @@ class ZCounting: public DQMEDAnalyzer{ MonitorElement* h_mass_Glo_fail_forward; MonitorElement* h_npv; - MonitorElement* h_yield_Z; + MonitorElement* h_npv_yield_Z; + MonitorElement* h_mass_yield_Z; MonitorElement* h_yieldBB_Z; MonitorElement* h_yieldEE_Z; diff --git a/DQMOffline/Lumi/python/ZCounting_cff.py b/DQMOffline/Lumi/python/ZCounting_cff.py index 57240ac4bdfcc..1481af5f9f2a6 100644 --- a/DQMOffline/Lumi/python/ZCounting_cff.py +++ b/DQMOffline/Lumi/python/ZCounting_cff.py @@ -47,8 +47,8 @@ LumiMax = cms.untracked.double(2500.5), PVBin = cms.untracked.int32(60), - PVMin = cms.untracked.double(0.0), - PVMax = cms.untracked.double(60.0), + PVMin = cms.untracked.double(0.5), + PVMax = cms.untracked.double(60.5), VtxNTracksFitMin = cms.untracked.double(0.), VtxNdofMin = cms.untracked.double(4.), From 43f507be52ddd8532b1f80bafc60f8e0528298f6 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 14:43:28 +0200 Subject: [PATCH 444/686] update unit test --- FWCore/Integration/test/BuildFile.xml | 2 +- FWCore/Integration/test/EDAlias_t.cpp | 1 - FWCore/Integration/test/SwitchProducer_t.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/FWCore/Integration/test/BuildFile.xml b/FWCore/Integration/test/BuildFile.xml index 705558020be47..bafe263f3e6bc 100644 --- a/FWCore/Integration/test/BuildFile.xml +++ b/FWCore/Integration/test/BuildFile.xml @@ -139,7 +139,7 @@ - + diff --git a/FWCore/Integration/test/EDAlias_t.cpp b/FWCore/Integration/test/EDAlias_t.cpp index 00fd6429a5aba..f06454d1e8128 100644 --- a/FWCore/Integration/test/EDAlias_t.cpp +++ b/FWCore/Integration/test/EDAlias_t.cpp @@ -3,7 +3,6 @@ #include "DataFormats/TestObjects/interface/ToyProducts.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" #include "FWCore/TestProcessor/interface/TestProcessor.h" #include diff --git a/FWCore/Integration/test/SwitchProducer_t.cpp b/FWCore/Integration/test/SwitchProducer_t.cpp index cec34fea8bfe8..75d67f5be7815 100644 --- a/FWCore/Integration/test/SwitchProducer_t.cpp +++ b/FWCore/Integration/test/SwitchProducer_t.cpp @@ -3,7 +3,7 @@ #include "DataFormats/TestObjects/interface/ToyProducts.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" +#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" #include "FWCore/TestProcessor/interface/TestProcessor.h" #include @@ -49,8 +49,8 @@ TEST_CASE("Configuration", s_tag) { const std::string baseConfigTest2Disabled = makeConfig(false, test1, test2); SECTION("Configuration hash is not changed") { - auto pset = edm::boost_python::readConfig(baseConfig); - auto psetTest2Disabled = edm::boost_python::readConfig(baseConfigTest2Disabled); + auto pset = edm::cmspybind11::readConfig(baseConfig); + auto psetTest2Disabled = edm::cmspybind11::readConfig(baseConfigTest2Disabled); pset->registerIt(); psetTest2Disabled->registerIt(); REQUIRE(pset->id() == psetTest2Disabled->id()); @@ -107,8 +107,8 @@ TEST_CASE("Configuration with EDAlias", s_tag) { const std::string baseConfigTest2Disabled = makeConfig(false, test1, test2, otherprod, othername); SECTION("Configuration hash is not changed") { - auto pset = edm::boost_python::readConfig(baseConfig); - auto psetTest2Disabled = edm::boost_python::readConfig(baseConfigTest2Disabled); + auto pset = edm::cmspybind11::readConfig(baseConfig); + auto psetTest2Disabled = edm::cmspybind11::readConfig(baseConfigTest2Disabled); pset->registerIt(); psetTest2Disabled->registerIt(); REQUIRE(pset->id() == psetTest2Disabled->id()); From 77e0dffc871f9398424bce069d5d2baf98fbd786 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 4 Apr 2019 14:48:19 +0200 Subject: [PATCH 445/686] PPS customisations guarded with ctpps_2016 era, geometry supplied. --- PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 278bfb306fd5f..15a11496fadbd 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -514,9 +514,11 @@ def miniAOD_customizeData(process): runOnData( process, outputModules = [] ) process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff") process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") + process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi") task = getPatAlgosToolsTask(process) - task.add(process.ctppsLocalTrackLiteProducer) - task.add(process.ctppsProtons) + from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 + ctpps_2016.toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer)) + ctpps_2016.toModify(task, func=lambda t: t.add(process.ctppsProtons)) def miniAOD_customizeAllData(process): miniAOD_customizeCommon(process) From deb12a6fb8fc21aa51725bbfab036ad06cacd685 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 4 Apr 2019 14:48:55 +0200 Subject: [PATCH 446/686] Bugfix: validity set according to iosv. --- CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc index 4898db7933e78..b1f98f3842c13 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc @@ -54,12 +54,12 @@ void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecor const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { // TODO: the IOV specified in config is temporarily replaced with a hardcoded one - m_insideValidityRange = true; - edm::IOVSyncValue beg(edm::EventID(270293, 0, 0), edm::Timestamp(1461016800ULL << 32)); edm::IOVSyncValue end(edm::EventID(290872, 0, 0), edm::Timestamp(1483138800ULL << 32)); oValidity = edm::ValidityInterval(beg, end); + m_insideValidityRange = (beg < iosv && iosv < end); + /* if (edm::contains(m_validityRange, iosv.eventID())) { From 6abb355c607c8c14cccb43369b12472cf338a683 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 4 Apr 2019 14:49:18 +0200 Subject: [PATCH 447/686] Bugfix: flag value inverted. --- CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc index f9284a0f2746c..7284ebd3a3053 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc @@ -108,7 +108,7 @@ void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventS } // not within any entry - m_currentEntryValid = true; + m_currentEntryValid = false; m_currentEntry = 0; edm::LogInfo("") << "No configuration entry found for event " << iosv.eventID() << ", no optical functions will be available."; From d9e8b517cdfc579c29621cb8088e10fffdf6738e Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 15:29:55 +0200 Subject: [PATCH 448/686] remove incorrect dependencies and an obsolete build file --- .../AlignmentPlugins/plugins/BuildFile.xml | 3 -- CondCore/EcalPlugins/plugins/BuildFile.xml | 54 ------------------- CondCore/HLTPlugins/plugins/BuildFile.xml | 1 - CondCore/HcalPlugins/interface/BuildFile | 13 ----- CondCore/HcalPlugins/plugins/BuildFile.xml | 9 ---- .../PCLConfigPlugins/plugins/BuildFile.xml | 1 - CondCore/RunInfoPlugins/plugins/BuildFile.xml | 1 - CondCore/SiStripPlugins/plugins/BuildFile.xml | 11 ---- 8 files changed, 93 deletions(-) delete mode 100644 CondCore/HcalPlugins/interface/BuildFile diff --git a/CondCore/AlignmentPlugins/plugins/BuildFile.xml b/CondCore/AlignmentPlugins/plugins/BuildFile.xml index 43f706fcdbb9a..dd5a4298a1136 100644 --- a/CondCore/AlignmentPlugins/plugins/BuildFile.xml +++ b/CondCore/AlignmentPlugins/plugins/BuildFile.xml @@ -7,7 +7,6 @@ - @@ -18,7 +17,6 @@ - @@ -29,5 +27,4 @@ - diff --git a/CondCore/EcalPlugins/plugins/BuildFile.xml b/CondCore/EcalPlugins/plugins/BuildFile.xml index b4ac54b3de51f..086173f0ea297 100755 --- a/CondCore/EcalPlugins/plugins/BuildFile.xml +++ b/CondCore/EcalPlugins/plugins/BuildFile.xml @@ -3,7 +3,6 @@ - @@ -11,7 +10,6 @@ - @@ -19,7 +17,6 @@ - @@ -27,7 +24,6 @@ - @@ -35,7 +31,6 @@ - @@ -43,7 +38,6 @@ - @@ -51,7 +45,6 @@ - @@ -59,7 +52,6 @@ - @@ -67,7 +59,6 @@ - @@ -75,7 +66,6 @@ - @@ -83,7 +73,6 @@ - @@ -91,7 +80,6 @@ - @@ -99,7 +87,6 @@ - @@ -107,7 +94,6 @@ - @@ -115,7 +101,6 @@ - @@ -123,7 +108,6 @@ - @@ -131,7 +115,6 @@ - @@ -139,7 +122,6 @@ - @@ -147,7 +129,6 @@ - @@ -155,7 +136,6 @@ - @@ -163,7 +143,6 @@ - @@ -171,7 +150,6 @@ - @@ -179,7 +157,6 @@ - @@ -187,7 +164,6 @@ - @@ -195,7 +171,6 @@ - @@ -203,7 +178,6 @@ - @@ -211,7 +185,6 @@ - @@ -219,7 +192,6 @@ - @@ -227,7 +199,6 @@ - @@ -235,7 +206,6 @@ - @@ -243,7 +213,6 @@ - @@ -251,7 +220,6 @@ - @@ -259,7 +227,6 @@ - @@ -267,7 +234,6 @@ - @@ -275,7 +241,6 @@ - @@ -284,7 +249,6 @@ - @@ -292,7 +256,6 @@ - @@ -300,7 +263,6 @@ - @@ -308,7 +270,6 @@ - @@ -316,7 +277,6 @@ - @@ -324,7 +284,6 @@ - @@ -332,7 +291,6 @@ - @@ -340,7 +298,6 @@ - @@ -348,7 +305,6 @@ - @@ -356,7 +312,6 @@ - @@ -364,7 +319,6 @@ - @@ -372,7 +326,6 @@ - @@ -380,7 +333,6 @@ - @@ -388,7 +340,6 @@ - @@ -396,7 +347,6 @@ - @@ -404,7 +354,6 @@ - @@ -412,7 +361,6 @@ - @@ -420,7 +368,6 @@ - @@ -428,6 +375,5 @@ - diff --git a/CondCore/HLTPlugins/plugins/BuildFile.xml b/CondCore/HLTPlugins/plugins/BuildFile.xml index 0e08d217b0ae3..da43982679ba4 100644 --- a/CondCore/HLTPlugins/plugins/BuildFile.xml +++ b/CondCore/HLTPlugins/plugins/BuildFile.xml @@ -2,5 +2,4 @@ - diff --git a/CondCore/HcalPlugins/interface/BuildFile b/CondCore/HcalPlugins/interface/BuildFile deleted file mode 100644 index 95566cbc15899..0000000000000 --- a/CondCore/HcalPlugins/interface/BuildFile +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/CondCore/HcalPlugins/plugins/BuildFile.xml b/CondCore/HcalPlugins/plugins/BuildFile.xml index 7c32873dd0de0..b9cecfe372ba8 100644 --- a/CondCore/HcalPlugins/plugins/BuildFile.xml +++ b/CondCore/HcalPlugins/plugins/BuildFile.xml @@ -3,7 +3,6 @@ - @@ -11,7 +10,6 @@ - @@ -19,7 +17,6 @@ - @@ -27,7 +24,6 @@ - @@ -35,7 +31,6 @@ - @@ -43,7 +38,6 @@ - @@ -51,19 +45,16 @@ - - - diff --git a/CondCore/PCLConfigPlugins/plugins/BuildFile.xml b/CondCore/PCLConfigPlugins/plugins/BuildFile.xml index b492e6ffcd290..b5b98f830b187 100644 --- a/CondCore/PCLConfigPlugins/plugins/BuildFile.xml +++ b/CondCore/PCLConfigPlugins/plugins/BuildFile.xml @@ -2,5 +2,4 @@ - diff --git a/CondCore/RunInfoPlugins/plugins/BuildFile.xml b/CondCore/RunInfoPlugins/plugins/BuildFile.xml index 4e290c7753304..e0950977fb00f 100644 --- a/CondCore/RunInfoPlugins/plugins/BuildFile.xml +++ b/CondCore/RunInfoPlugins/plugins/BuildFile.xml @@ -4,5 +4,4 @@ - diff --git a/CondCore/SiStripPlugins/plugins/BuildFile.xml b/CondCore/SiStripPlugins/plugins/BuildFile.xml index 13bbacee2a1a0..5282032ba3d4c 100644 --- a/CondCore/SiStripPlugins/plugins/BuildFile.xml +++ b/CondCore/SiStripPlugins/plugins/BuildFile.xml @@ -4,7 +4,6 @@ - @@ -14,7 +13,6 @@ - @@ -24,7 +22,6 @@ - @@ -34,7 +31,6 @@ - @@ -44,7 +40,6 @@ - @@ -54,7 +49,6 @@ - @@ -64,7 +58,6 @@ - @@ -74,7 +67,6 @@ - @@ -84,7 +76,6 @@ - @@ -94,7 +85,6 @@ - @@ -104,7 +94,6 @@ - From c749f511bd72ec31346bf6740658cf8ba0433dd3 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 15:37:06 +0200 Subject: [PATCH 449/686] no boost_python in this package --- PhysicsTools/SelectorUtils/bin/BuildFile.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/PhysicsTools/SelectorUtils/bin/BuildFile.xml b/PhysicsTools/SelectorUtils/bin/BuildFile.xml index ecfe21ab04b38..c3a84e76e5b6d 100644 --- a/PhysicsTools/SelectorUtils/bin/BuildFile.xml +++ b/PhysicsTools/SelectorUtils/bin/BuildFile.xml @@ -5,7 +5,6 @@ - From 361cbd6b8544743599e4ecd0de19ebcc3cc54abd Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 15:50:05 +0200 Subject: [PATCH 450/686] no need for boost_python --- CondCore/Utilities/plugins/BuildFile.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/CondCore/Utilities/plugins/BuildFile.xml b/CondCore/Utilities/plugins/BuildFile.xml index d33e9fd729580..b807ab1c3665a 100644 --- a/CondCore/Utilities/plugins/BuildFile.xml +++ b/CondCore/Utilities/plugins/BuildFile.xml @@ -11,9 +11,7 @@ - - From 739dd4534a57364d6159076aac91cdf2b4421e01 Mon Sep 17 00:00:00 2001 From: "W. David Dagenhart" Date: Thu, 4 Apr 2019 15:55:46 +0200 Subject: [PATCH 451/686] Fix previous commit --- FWCore/Framework/test/testMaxEventsOutput_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/Framework/test/testMaxEventsOutput_cfg.py b/FWCore/Framework/test/testMaxEventsOutput_cfg.py index 92e8d029f76c2..819863e34d7d5 100644 --- a/FWCore/Framework/test/testMaxEventsOutput_cfg.py +++ b/FWCore/Framework/test/testMaxEventsOutput_cfg.py @@ -29,7 +29,7 @@ process.busy1 = cms.EDProducer("BusyWaitIntProducer", ivalue = cms.int32(1), iterations = cms.uint32(10*1000*1000), - lumiNumberToThrow = cms.uint32(7) + lumiNumberToThrow = cms.uint32(0) ) process.p1 = cms.Path(process.busy1) From f399773b26161ef0c52c66c399719840806616f0 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 16:08:33 +0200 Subject: [PATCH 452/686] remove unneeded includes --- CondCore/Utilities/interface/PayloadInspector.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/CondCore/Utilities/interface/PayloadInspector.h b/CondCore/Utilities/interface/PayloadInspector.h index e910c4127262b..9047b96ca0bcd 100644 --- a/CondCore/Utilities/interface/PayloadInspector.h +++ b/CondCore/Utilities/interface/PayloadInspector.h @@ -8,8 +8,6 @@ #include #include #include -#include -#include #include #include #include From 3c37ae76ab4cddb5a2c5584994123d1de84873c4 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 16:28:30 +0200 Subject: [PATCH 453/686] Convert to degree only to find the name of rot matrix --- Geometry/HcalAlgo/plugins/DDHCalAngular.cc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc index 6baf5a990da96..693dd0c7ec668 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc @@ -11,9 +11,9 @@ #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "Geometry/HcalAlgo/plugins/DDHCalAngular.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG -using namespace geant_units; using namespace geant_units::operators; DDHCalAngular::DDHCalAngular() { @@ -66,20 +66,14 @@ void DDHCalAngular::execute(DDCompactView& cpv) { double phix = startAngle; int copyNo = startCopyNo; double theta = 90._deg; - for (int ii=0; ii= 360) { - iphi -= 360; - phideg = iphi; - phix = convertDegToRad(phideg); - } double phiy = phix + 90._deg; DDRotation rotation; std::string rotstr("NULL"); - - if (iphi != 0) { + + int phideg = std::lround(convertRadToDeg(phix)); + if (phideg >= 360) phideg -= 360; + if (phideg != 0) { rotstr = "R"; if (phideg >=0 && phideg < 100) rotstr = "R0"; rotstr = rotstr + std::to_string(phideg); From 28783feb3eb4fb128b43f40dbd2e85c0d1677316 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 19:13:07 +0200 Subject: [PATCH 454/686] Use a function in DDTypes --- DetectorDescription/Core/interface/DDTypes.h | 4 ++++ DetectorDescription/Core/src/DDTypes.cc | 13 +++++++++++++ Geometry/HcalAlgo/plugins/DDHCalAngular.cc | 16 +++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/DetectorDescription/Core/interface/DDTypes.h b/DetectorDescription/Core/interface/DDTypes.h index 84670f6f4c948..a0f8c1803a0b2 100644 --- a/DetectorDescription/Core/interface/DDTypes.h +++ b/DetectorDescription/Core/interface/DDTypes.h @@ -35,4 +35,8 @@ std::ostream & operator<<(std::ostream & os, const DDStringVectorArguments & t); // Formats an angle in radians as a 0-padded string in degrees; e.g. "0001.293900" for 1.2939 degrees. std::string formatAsDegrees(double radianVal); +// Formats an angle in radians as a 0-padded string in degrees expressed as integer between 0 and 360; e.g. "090" for -270.001 degrees. +std::string formatAsDegreesInInteger(double radianVal); + + #endif // DDTYPES diff --git a/DetectorDescription/Core/src/DDTypes.cc b/DetectorDescription/Core/src/DDTypes.cc index e58ef7215a46f..51c9a4706fc95 100644 --- a/DetectorDescription/Core/src/DDTypes.cc +++ b/DetectorDescription/Core/src/DDTypes.cc @@ -81,3 +81,16 @@ std::string formatAsDegrees(double radianVal) return degstr; else return "0000.000000"; } + +// Formats an angle in radians as a 0-padded string in degrees expressed as integer between 0 and 360; e.g. "090" for -270.001 degrees. +std::string formatAsDegreesInInteger(double radianVal) { + + const unsigned short numlen = 4; + char degstr[numlen]; + int degVal = std::lround(convertRadToDeg( radianVal )); + if (degVal < 0) degVal += 360; + int retval = snprintf(degstr, numlen, "%0*d", numlen-1, degVal); + + if (retval == numlen - 1) return degstr; + else return "000"; +} diff --git a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc index 693dd0c7ec668..f094b863931b5 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc @@ -8,8 +8,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/GeantUnits.h" -#include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDTypes.h" #include "Geometry/HcalAlgo/plugins/DDHCalAngular.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" @@ -71,19 +72,16 @@ void DDHCalAngular::execute(DDCompactView& cpv) { DDRotation rotation; std::string rotstr("NULL"); - int phideg = std::lround(convertRadToDeg(phix)); - if (phideg >= 360) phideg -= 360; - if (phideg != 0) { - rotstr = "R"; - if (phideg >=0 && phideg < 100) rotstr = "R0"; - rotstr = rotstr + std::to_string(phideg); + static const int tol = 0.1; + if (std::abs(phix) > tol) { + rotstr = "R" + formatAsDegreesInInteger(phix); rotation = DDRotation(DDName(rotstr, rotns)); if (!rotation) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, " - << phideg << ", 90, " << (phideg+90) - << ", 0, 0"; + << convertRadToDeg(phi) << ", 90, " + << (90+convertRadToDeg(phi)) << ", 0, 0"; #endif rotation = DDrot(DDName(rotstr, rotns), theta, phix, theta, phiy, 0,0); } From ca03edfe8b8687f80f1a28416bb1c16ab06e9766 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 19:50:04 +0200 Subject: [PATCH 455/686] Correct typing error --- Geometry/HcalAlgo/plugins/DDHCalAngular.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc index f094b863931b5..79beca3c6acce 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc @@ -72,7 +72,7 @@ void DDHCalAngular::execute(DDCompactView& cpv) { DDRotation rotation; std::string rotstr("NULL"); - static const int tol = 0.1; + static const double tol = 0.1; if (std::abs(phix) > tol) { rotstr = "R" + formatAsDegreesInInteger(phix); rotation = DDRotation(DDName(rotstr, rotns)); From 21f11285d7f7068373942cf4ba1cb66f7cc39757 Mon Sep 17 00:00:00 2001 From: david walter Date: Thu, 4 Apr 2019 20:02:45 +0200 Subject: [PATCH 456/686] rename modifiers with a more general name --- Configuration/Eras/python/Era_Run2_2016_cff.py | 4 ++-- Configuration/Eras/python/Era_Run2_2017_cff.py | 4 ++-- Configuration/Eras/python/Era_Run2_2018_cff.py | 4 ++-- Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py | 4 ---- Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py | 4 ---- Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py | 4 ---- Configuration/StandardSequences/python/Eras.py | 2 +- DQMOffline/Lumi/python/ZCounting_cff.py | 6 +++--- 8 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py delete mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py delete mode 100644 Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py diff --git a/Configuration/Eras/python/Era_Run2_2016_cff.py b/Configuration/Eras/python/Era_Run2_2016_cff.py index 6fe939421f913..b928c51073904 100644 --- a/Configuration/Eras/python/Era_Run2_2016_cff.py +++ b/Configuration/Eras/python/Era_Run2_2016_cff.py @@ -4,7 +4,7 @@ from Configuration.Eras.Modifier_run2_25ns_specific_cff import run2_25ns_specific from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 -from Configuration.Eras.Modifier_run2_zcount_2016_cff import run2_zcount_2016 +from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import run2_HLTconditions_2016 -Run2_2016 = cms.ModifierChain(run2_common, run2_25ns_specific, stage2L1Trigger, ctpps_2016, run2_zcount_2016) +Run2_2016 = cms.ModifierChain(run2_common, run2_25ns_specific, stage2L1Trigger, ctpps_2016, run2_HLTconditions_2016) diff --git a/Configuration/Eras/python/Era_Run2_2017_cff.py b/Configuration/Eras/python/Era_Run2_2017_cff.py index 811b027b89386..28ec88e2cabf3 100644 --- a/Configuration/Eras/python/Era_Run2_2017_cff.py +++ b/Configuration/Eras/python/Era_Run2_2017_cff.py @@ -10,7 +10,7 @@ from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017 -from Configuration.Eras.Modifier_run2_zcount_2017_cff import run2_zcount_2017 +from Configuration.Eras.Modifier_run2_HLTconditions_2017_cff import run2_HLTconditions_2017 -Run2_2017 = cms.ModifierChain(Run2_2016, phase1Pixel, run2_ECAL_2017, run2_HF_2017, run2_HCAL_2017, run2_HE_2017, run2_HEPlan1_2017, trackingPhase1, run2_GEM_2017, stage2L1Trigger_2017, run2_zcount_2017) +Run2_2017 = cms.ModifierChain(Run2_2016, phase1Pixel, run2_ECAL_2017, run2_HF_2017, run2_HCAL_2017, run2_HE_2017, run2_HEPlan1_2017, trackingPhase1, run2_GEM_2017, stage2L1Trigger_2017, run2_HLTconditions_2017) diff --git a/Configuration/Eras/python/Era_Run2_2018_cff.py b/Configuration/Eras/python/Era_Run2_2018_cff.py index e8e49f41ed1fb..6b73a4ec20641 100644 --- a/Configuration/Eras/python/Era_Run2_2018_cff.py +++ b/Configuration/Eras/python/Era_Run2_2018_cff.py @@ -9,6 +9,6 @@ from Configuration.Eras.Modifier_run2_HCAL_2018_cff import run2_HCAL_2018 from Configuration.Eras.Modifier_run2_DT_2018_cff import run2_DT_2018 from Configuration.Eras.Modifier_run2_SiPixel_2018_cff import run2_SiPixel_2018 -from Configuration.Eras.Modifier_run2_zcount_2018_cff import run2_zcount_2018 +from Configuration.Eras.Modifier_run2_HLTconditions_2018_cff import run2_HLTconditions_2018 -Run2_2018 = cms.ModifierChain(Run2_2017.copyAndExclude([run2_HEPlan1_2017]), run2_CSC_2018, run2_HCAL_2018, run2_HB_2018, run2_HE_2018,run2_DT_2018, run2_SiPixel_2018, run2_zcount_2018) +Run2_2018 = cms.ModifierChain(Run2_2017.copyAndExclude([run2_HEPlan1_2017]), run2_CSC_2018, run2_HCAL_2018, run2_HB_2018, run2_HE_2018,run2_DT_2018, run2_SiPixel_2018, run2_HLTconditions_2018) diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py deleted file mode 100644 index f547ebf28cce8..0000000000000 --- a/Configuration/Eras/python/Modifier_run2_zcount_2016_cff.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -run2_zcount_2016 = cms.Modifier() - diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py deleted file mode 100644 index 1ddd404892642..0000000000000 --- a/Configuration/Eras/python/Modifier_run2_zcount_2017_cff.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -run2_zcount_2017 = cms.Modifier() - diff --git a/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py b/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py deleted file mode 100644 index f6a5e65ba7272..0000000000000 --- a/Configuration/Eras/python/Modifier_run2_zcount_2018_cff.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -run2_zcount_2018 = cms.Modifier() - diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index 18c14c9374325..0218c72d65303 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -61,7 +61,7 @@ def __init__(self): 'run2_nanoAOD_94XMiniAODv1', 'run2_nanoAOD_94XMiniAODv2', 'run2_nanoAOD_94X2016', 'run2_miniAOD_devel', 'run2_nanoAOD_102Xv1', 'hcalHardcodeConditions', 'hcalSkipPacker', - 'run2_zcount_2016','run2_zcount_2017','run2_zcount_2018', + 'run2_HLTconditions_2016','run2_HLTconditions_2017','run2_HLTconditions_2018', 'bParking'] internalUseModChains = ['run2_2017_noTrackingModifier'] diff --git a/DQMOffline/Lumi/python/ZCounting_cff.py b/DQMOffline/Lumi/python/ZCounting_cff.py index 1481af5f9f2a6..7d6b733789b59 100644 --- a/DQMOffline/Lumi/python/ZCounting_cff.py +++ b/DQMOffline/Lumi/python/ZCounting_cff.py @@ -59,20 +59,20 @@ from Configuration.StandardSequences.Eras import eras -eras.run2_zcount_2016.toModify( zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*","HLT_IsoTkMu24_v*"), +eras.run2_HLTconditions_2016.toModify( zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*","HLT_IsoTkMu24_v*"), MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07", "hltL3fL1sMu22L1f0Tkf24QL3trkIsoFiltered0p09"), PtCutL1 = cms.untracked.double(27.0), PtCutL2 = cms.untracked.double(27.0) ) -eras.run2_zcount_2017.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*"), +eras.run2_HLTconditions_2017.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu27_v*"), MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07"), PtCutL1 = cms.untracked.double(30.0), PtCutL2 = cms.untracked.double(30.0) ) -eras.run2_zcount_2018.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*"), +eras.run2_HLTconditions_2018.toModify(zcounting, MuonTriggerNames = cms.vstring("HLT_IsoMu24_v*"), MuonTriggerObjectNames = cms.vstring("hltL3crIsoL1sSingleMu22L1f0L2f10QL3f24QL3trkIsoFiltered0p07"), PtCutL1 = cms.untracked.double(27.0), PtCutL2 = cms.untracked.double(27.0) From e3dfdbf42624c74cea2f80f82a4c48f45868d041 Mon Sep 17 00:00:00 2001 From: david walter Date: Thu, 4 Apr 2019 20:05:37 +0200 Subject: [PATCH 457/686] add the renamed modifiers --- .../Eras/python/Modifier_run2_HLTconditions_2016_cff.py | 4 ++++ .../Eras/python/Modifier_run2_HLTconditions_2017_cff.py | 4 ++++ .../Eras/python/Modifier_run2_HLTconditions_2018_cff.py | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 Configuration/Eras/python/Modifier_run2_HLTconditions_2016_cff.py create mode 100644 Configuration/Eras/python/Modifier_run2_HLTconditions_2017_cff.py create mode 100644 Configuration/Eras/python/Modifier_run2_HLTconditions_2018_cff.py diff --git a/Configuration/Eras/python/Modifier_run2_HLTconditions_2016_cff.py b/Configuration/Eras/python/Modifier_run2_HLTconditions_2016_cff.py new file mode 100644 index 0000000000000..3042f08ac8ab3 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_HLTconditions_2016_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_HLTconditions_2016 = cms.Modifier() + diff --git a/Configuration/Eras/python/Modifier_run2_HLTconditions_2017_cff.py b/Configuration/Eras/python/Modifier_run2_HLTconditions_2017_cff.py new file mode 100644 index 0000000000000..fc19016e5ed47 --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_HLTconditions_2017_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_HLTconditions_2017 = cms.Modifier() + diff --git a/Configuration/Eras/python/Modifier_run2_HLTconditions_2018_cff.py b/Configuration/Eras/python/Modifier_run2_HLTconditions_2018_cff.py new file mode 100644 index 0000000000000..b7e31489f5b6d --- /dev/null +++ b/Configuration/Eras/python/Modifier_run2_HLTconditions_2018_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +run2_HLTconditions_2018 = cms.Modifier() + From da09b6a7b8e9b762c4291fc192addba7d1458e2d Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Apr 2019 21:20:11 +0200 Subject: [PATCH 458/686] use python3 compatible syntax --- DQMOffline/L1Trigger/python/L1TCommon.py | 4 +- .../L1Trigger/python/L1TEGammaOffline_cfi.py | 23 +++---- .../python/L1TEtSumJetOffline_cfi.py | 61 ++++++++++--------- .../python/L1THistDefinitions_cff.py | 8 +-- .../L1Trigger/python/L1TMuonDQMOffline_cfi.py | 16 +++-- .../L1Trigger/python/L1TTauOffline_cfi.py | 16 ++--- .../Trigger/python/FSQHLTOfflineSource_cfi.py | 18 +++--- 7 files changed, 74 insertions(+), 72 deletions(-) diff --git a/DQMOffline/L1Trigger/python/L1TCommon.py b/DQMOffline/L1Trigger/python/L1TCommon.py index 9a16761308150..51d2f8f0d4880 100644 --- a/DQMOffline/L1Trigger/python/L1TCommon.py +++ b/DQMOffline/L1Trigger/python/L1TCommon.py @@ -1,8 +1,10 @@ +import six + def generateEfficiencyStrings(variables, plots): stringTemplate = "{plot} " + \ "'{var} efficiency; Offline E_{{T}}^{{miss}} (GeV); {var} efficiency'" + \ " {num_path} {den_path}" - for variable, thresholds in variables.iteritems(): + for variable, thresholds in six.iteritems(variables): for plot in plots[variable]: for threshold in thresholds: plotName = '{0}_threshold_{1}'.format(plot, threshold) diff --git a/DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py b/DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py index f44552d1e7de7..d36a1476ccfb0 100644 --- a/DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py +++ b/DQMOffline/L1Trigger/python/L1TEGammaOffline_cfi.py @@ -1,14 +1,15 @@ +from builtins import range import FWCore.ParameterSet.Config as cms from DQMOffline.L1Trigger.L1THistDefinitions_cff import histDefinitions electronEfficiencyThresholds = [34, 36, 38, 40, 42] electronEfficiencyBins = [] -electronEfficiencyBins.extend(list(xrange(2, 42, 2))) -electronEfficiencyBins.extend(list(xrange(42, 45, 3))) -electronEfficiencyBins.extend(list(xrange(45, 50, 5))) -electronEfficiencyBins.extend(list(xrange(50, 70, 10))) -electronEfficiencyBins.extend(list(xrange(70, 101, 30))) +electronEfficiencyBins.extend(list(range(2, 42, 2))) +electronEfficiencyBins.extend(list(range(42, 45, 3))) +electronEfficiencyBins.extend(list(range(45, 50, 5))) +electronEfficiencyBins.extend(list(range(50, 70, 10))) +electronEfficiencyBins.extend(list(range(70, 101, 30))) # additional efficiency vs eta, phi and # vertices plots will # be created for the following probe electron pT thresholds @@ -67,12 +68,12 @@ deepInspectionElectronThresholds_HI = [15] electronEfficiencyBins_HI = [] -electronEfficiencyBins_HI.extend(list(xrange(1, 26, 1))) -electronEfficiencyBins_HI.extend(list(xrange(26, 42, 2))) -electronEfficiencyBins_HI.extend(list(xrange(42, 45, 3))) -electronEfficiencyBins_HI.extend(list(xrange(45, 50, 5))) -electronEfficiencyBins_HI.extend(list(xrange(50, 70, 10))) -electronEfficiencyBins_HI.extend(list(xrange(70, 101, 30))) +electronEfficiencyBins_HI.extend(list(range(1, 26, 1))) +electronEfficiencyBins_HI.extend(list(range(26, 42, 2))) +electronEfficiencyBins_HI.extend(list(range(42, 45, 3))) +electronEfficiencyBins_HI.extend(list(range(45, 50, 5))) +electronEfficiencyBins_HI.extend(list(range(50, 70, 10))) +electronEfficiencyBins_HI.extend(list(range(70, 101, 30))) photonEfficiencyThresholds_HI = electronEfficiencyThresholds_HI photonEfficiencyBins_HI = electronEfficiencyBins_HI diff --git a/DQMOffline/L1Trigger/python/L1TEtSumJetOffline_cfi.py b/DQMOffline/L1Trigger/python/L1TEtSumJetOffline_cfi.py index 3563ccaf20f55..2987074da24e0 100644 --- a/DQMOffline/L1Trigger/python/L1TEtSumJetOffline_cfi.py +++ b/DQMOffline/L1Trigger/python/L1TEtSumJetOffline_cfi.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms from DQMOffline.L1Trigger.L1THistDefinitions_cff import histDefinitions @@ -8,38 +9,38 @@ httEfficiencyThresholds = [120, 160, 200, 240, 280] jetEfficiencyBins = [] -jetEfficiencyBins.extend(list(xrange(0, 120, 10))) -jetEfficiencyBins.extend(list(xrange(120, 180, 20))) -jetEfficiencyBins.extend(list(xrange(180, 300, 40))) -jetEfficiencyBins.extend(list(xrange(300, 401, 100))) +jetEfficiencyBins.extend(list(range(0, 120, 10))) +jetEfficiencyBins.extend(list(range(120, 180, 20))) +jetEfficiencyBins.extend(list(range(180, 300, 40))) +jetEfficiencyBins.extend(list(range(300, 401, 100))) metEfficiencyBins = [] -metEfficiencyBins.extend(list(xrange(0, 40, 4))) -metEfficiencyBins.extend(list(xrange(40, 70, 2))) -metEfficiencyBins.extend(list(xrange(70, 100, 5))) -metEfficiencyBins.extend(list(xrange(100, 160, 10))) -metEfficiencyBins.extend(list(xrange(160, 261, 20))) +metEfficiencyBins.extend(list(range(0, 40, 4))) +metEfficiencyBins.extend(list(range(40, 70, 2))) +metEfficiencyBins.extend(list(range(70, 100, 5))) +metEfficiencyBins.extend(list(range(100, 160, 10))) +metEfficiencyBins.extend(list(range(160, 261, 20))) mhtEfficiencyBins = [] -mhtEfficiencyBins.extend(list(xrange(30, 50, 1))) -mhtEfficiencyBins.extend(list(xrange(50, 80, 5))) -mhtEfficiencyBins.extend(list(xrange(80, 140, 10))) -mhtEfficiencyBins.extend(list(xrange(140, 200, 15))) -mhtEfficiencyBins.extend(list(xrange(200, 300, 20))) -mhtEfficiencyBins.extend(list(xrange(300, 401, 50))) +mhtEfficiencyBins.extend(list(range(30, 50, 1))) +mhtEfficiencyBins.extend(list(range(50, 80, 5))) +mhtEfficiencyBins.extend(list(range(80, 140, 10))) +mhtEfficiencyBins.extend(list(range(140, 200, 15))) +mhtEfficiencyBins.extend(list(range(200, 300, 20))) +mhtEfficiencyBins.extend(list(range(300, 401, 50))) ettEfficiencyBins = [] -ettEfficiencyBins.extend(list(xrange(0, 30, 30))) -ettEfficiencyBins.extend(list(xrange(30, 50, 10))) -ettEfficiencyBins.extend(list(xrange(50, 90, 5))) -ettEfficiencyBins.extend(list(xrange(90, 141, 2))) +ettEfficiencyBins.extend(list(range(0, 30, 30))) +ettEfficiencyBins.extend(list(range(30, 50, 10))) +ettEfficiencyBins.extend(list(range(50, 90, 5))) +ettEfficiencyBins.extend(list(range(90, 141, 2))) httEfficiencyBins = [] -httEfficiencyBins.extend(list(xrange(0, 100, 5))) -httEfficiencyBins.extend(list(xrange(100, 200, 10))) -httEfficiencyBins.extend(list(xrange(200, 400, 20))) -httEfficiencyBins.extend(list(xrange(400, 500, 50))) -httEfficiencyBins.extend(list(xrange(500, 601, 10))) +httEfficiencyBins.extend(list(range(0, 100, 5))) +httEfficiencyBins.extend(list(range(100, 200, 10))) +httEfficiencyBins.extend(list(range(200, 400, 20))) +httEfficiencyBins.extend(list(range(400, 500, 50))) +httEfficiencyBins.extend(list(range(500, 601, 10))) # from https://twiki.cern.ch/twiki/bin/view/CMS/JetID13TeVRun2017 centralJetSelection = [ @@ -149,12 +150,12 @@ # modifications for the pp reference run jetEfficiencyThresholds_HI = [8, 16, 24, 44, 60, 80, 90] jetEfficiencyBins_HI = [] -jetEfficiencyBins_HI.extend(list(xrange(0, 60, 2))) -jetEfficiencyBins_HI.extend(list(xrange(60, 90, 5))) -jetEfficiencyBins_HI.extend(list(xrange(90, 120, 10))) -jetEfficiencyBins_HI.extend(list(xrange(120, 180, 20))) -jetEfficiencyBins_HI.extend(list(xrange(180, 300, 40))) -jetEfficiencyBins_HI.extend(list(xrange(300, 401, 100))) +jetEfficiencyBins_HI.extend(list(range(0, 60, 2))) +jetEfficiencyBins_HI.extend(list(range(60, 90, 5))) +jetEfficiencyBins_HI.extend(list(range(90, 120, 10))) +jetEfficiencyBins_HI.extend(list(range(120, 180, 20))) +jetEfficiencyBins_HI.extend(list(range(180, 300, 40))) +jetEfficiencyBins_HI.extend(list(range(300, 401, 100))) from Configuration.Eras.Modifier_ppRef_2017_cff import ppRef_2017 ppRef_2017.toModify( diff --git a/DQMOffline/L1Trigger/python/L1THistDefinitions_cff.py b/DQMOffline/L1Trigger/python/L1THistDefinitions_cff.py index 873e666d404be..729c2e9afcab4 100644 --- a/DQMOffline/L1Trigger/python/L1THistDefinitions_cff.py +++ b/DQMOffline/L1Trigger/python/L1THistDefinitions_cff.py @@ -1,10 +1,10 @@ - +from builtins import range import FWCore.ParameterSet.Config as cms et_vs_et_bins = [] -et_vs_et_bins.extend(list(xrange(0, 50, 1))) -et_vs_et_bins.extend(list(xrange(50, 150, 5))) -et_vs_et_bins.extend(list(xrange(150, 500, 50))) +et_vs_et_bins.extend(list(range(0, 50, 1))) +et_vs_et_bins.extend(list(range(50, 150, 5))) +et_vs_et_bins.extend(list(range(150, 500, 50))) histDefinitions = cms.PSet( nVertex=cms.PSet( diff --git a/DQMOffline/L1Trigger/python/L1TMuonDQMOffline_cfi.py b/DQMOffline/L1Trigger/python/L1TMuonDQMOffline_cfi.py index 3c7296969cd4e..79c705e8f5369 100644 --- a/DQMOffline/L1Trigger/python/L1TMuonDQMOffline_cfi.py +++ b/DQMOffline/L1Trigger/python/L1TMuonDQMOffline_cfi.py @@ -1,16 +1,14 @@ +from builtins import range import FWCore.ParameterSet.Config as cms # define binning for efficiency plots # pt -effVsPtBins = range(0, 30, 1) -effVsPtBins += range(30, 50, 2) -effVsPtBins += range(50, 70, 5) -effVsPtBins += range(70, 100, 10) -effVsPtBins += range(100, 200, 25) -effVsPtBins += range(200, 300, 50) -effVsPtBins += range(300, 500, 100) -effVsPtBins += range(500, 700, 200) -effVsPtBins += range(700, 1000, 300) +import itertools +effVsPtBins=list(itertools.chain(range(0, 30, 1), range(30, 50, 2), + range(50, 70, 5), range(70, 100, 10), + range(100, 200, 25), range(200, 300, 50), + range(300, 500, 100), range(500, 700, 200), + range(700, 1000, 300))) effVsPtBins.append(1000) # phi diff --git a/DQMOffline/L1Trigger/python/L1TTauOffline_cfi.py b/DQMOffline/L1Trigger/python/L1TTauOffline_cfi.py index f610c5a778e3c..4a956651878f6 100644 --- a/DQMOffline/L1Trigger/python/L1TTauOffline_cfi.py +++ b/DQMOffline/L1Trigger/python/L1TTauOffline_cfi.py @@ -4,14 +4,14 @@ tauEfficiencyThresholds = [28, 30, 32, 128, 176] tauEfficiencyBins = [] -tauEfficiencyBins.extend(list(xrange(0, 50, 1))) -tauEfficiencyBins.extend(list(xrange(50, 60, 2))) -tauEfficiencyBins.extend(list(xrange(60, 80, 5))) -tauEfficiencyBins.extend(list(xrange(80, 200, 10))) -tauEfficiencyBins.extend(list(xrange(200, 300, 20))) -tauEfficiencyBins.extend(list(xrange(300, 400, 50))) -tauEfficiencyBins.extend(list(xrange(400, 600, 100))) -tauEfficiencyBins.extend(list(xrange(600, 1200, 200))) +tauEfficiencyBins.extend(list(range(0, 50, 1))) +tauEfficiencyBins.extend(list(range(50, 60, 2))) +tauEfficiencyBins.extend(list(range(60, 80, 5))) +tauEfficiencyBins.extend(list(range(80, 200, 10))) +tauEfficiencyBins.extend(list(range(200, 300, 20))) +tauEfficiencyBins.extend(list(range(300, 400, 50))) +tauEfficiencyBins.extend(list(range(400, 600, 100))) +tauEfficiencyBins.extend(list(range(600, 1200, 200))) from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer l1tTauOfflineDQM = DQMEDAnalyzer( diff --git a/DQMOffline/Trigger/python/FSQHLTOfflineSource_cfi.py b/DQMOffline/Trigger/python/FSQHLTOfflineSource_cfi.py index c0c6a396f9f80..e2189d1b24d78 100644 --- a/DQMOffline/Trigger/python/FSQHLTOfflineSource_cfi.py +++ b/DQMOffline/Trigger/python/FSQHLTOfflineSource_cfi.py @@ -86,7 +86,7 @@ def getHighMultVPSet(): partialPathName = "HLT_PixelTracks_Multiplicity"+str(t)+"_v" tracksL = 0 tracksH = 200 - tracksBins = (tracksH-tracksL)/5 + tracksBins = (tracksH-tracksL)//5 tracksCount = cms.PSet( triggerSelection = cms.string(partialPathName+"*"), handlerType = cms.string("RecoTrackCounterWithVertexConstraint"), @@ -168,7 +168,7 @@ def getHighMultVPSet(): combinedObjectSortCriteria = cms.string("at(0).pt"), combinedObjectDimension = cms.int32(1), combinedObjectDrawables = cms.VPSet( - cms.PSet (name = cms.string("pt"), expression = cms.string("at(0).pt"), bins = cms.int32(256/4), min = cms.double(0), max = cms.double(256)), + cms.PSet (name = cms.string("pt"), expression = cms.string("at(0).pt"), bins = cms.int32(256//4), min = cms.double(0), max = cms.double(256)), ) ) ret.append(l1) @@ -195,7 +195,7 @@ def getPTAveVPSet(thresholds = [30, 60, 80, 100, 160, 220, 300], flavour="HFJEC" #partialPathName = "HLT_DiPFJetAve"+ str(t) +"_HFJEC_" partialPathName = "HLT_DiPFJetAve"+ str(t)+"_" + flavour + "_v" - ptBinLow = t/2 + ptBinLow = t//2 ptBinHigh = max(100, t*2) ptBins = min(100, ptBinHigh-ptBinLow) @@ -233,8 +233,8 @@ def getPTAveVPSet(thresholds = [30, 60, 80, 100, 160, 220, 300], flavour="HFJEC" combinedObjectSortCriteria = cms.string("at(0).pt"), combinedObjectDimension = cms.int32(1), combinedObjectDrawables = cms.VPSet( - cms.PSet (name = cms.string("pt"), expression = cms.string("at(0).pt"), bins = cms.int32(256/4), min = cms.double(0), max = cms.double(256)), - cms.PSet (name = cms.string("eta"), expression = cms.string("at(0).eta"), bins = cms.int32(104/4), min = cms.double(-5.2), max = cms.double(5.2)) + cms.PSet (name = cms.string("pt"), expression = cms.string("at(0).pt"), bins = cms.int32(256//4), min = cms.double(0), max = cms.double(256)), + cms.PSet (name = cms.string("eta"), expression = cms.string("at(0).eta"), bins = cms.int32(104//4), min = cms.double(-5.2), max = cms.double(5.2)) ) ) ret.append(l1) @@ -415,9 +415,9 @@ def getSinglePFJet(thresholds, flavour=None, etaMin=-1, srcType="genJets", parti partialPathNameLoc += flavour+"_" partialPathNameLoc += "v" - marginLow = max(t-t/2, 15) + marginLow = max(t-t//2, 15) ptBinLow = max(t-marginLow,0) - marginHigh = min(max(t/2, 20), 50) + marginHigh = min(max(t//2, 20), 50) ptBinHigh = t+marginHigh ptBins = min(100, ptBinHigh-ptBinLow) fromJets = cms.PSet( @@ -495,9 +495,9 @@ def getDoublePFJet(thresholds, flavour=None, etaMin=-1, srcType="genJets" ): partialPathName += flavour+"_" partialPathName += "v" - marginLow = max(t-t/2, 15) + marginLow = max(t-t//2, 15) ptBinLow = max(t-marginLow,0) - marginHigh = min(max(t/3, 15), 50) + marginHigh = min(max(t//3, 15), 50) ptBinHigh = t+marginHigh ptBins = min(100, ptBinHigh-ptBinLow) fromJets = cms.PSet( From 9cd9c11da0be2d8c948b80443f155d116244e57a Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 4 Apr 2019 22:56:36 +0200 Subject: [PATCH 459/686] Update testmat.cpp --- DetectorDescription/Parser/test/testmat.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DetectorDescription/Parser/test/testmat.cpp b/DetectorDescription/Parser/test/testmat.cpp index 653e457de5d16..d5a3def245476 100644 --- a/DetectorDescription/Parser/test/testmat.cpp +++ b/DetectorDescription/Parser/test/testmat.cpp @@ -56,7 +56,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); From 0021c74460cacd7f497fefe993fb479c2d5e25b0 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 4 Apr 2019 22:58:11 +0200 Subject: [PATCH 460/686] Update dumpDDCompactView.cpp --- DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp index 3e662937591a9..42cf977b5cc33 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp @@ -64,7 +64,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); From 8444fcfbe42fa4daefcb263c374b82290595964a Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 4 Apr 2019 22:59:24 +0200 Subject: [PATCH 461/686] Update dumpDDExpandedView.cpp --- .../RegressionTest/test/dumpDDExpandedView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp index b47d7a4800133..164da26057aa2 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp @@ -60,7 +60,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); From ec28c2eb6a03f27eae6a425bc1629e1b151a9d42 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Thu, 4 Apr 2019 23:00:45 +0200 Subject: [PATCH 462/686] Update testDDCompactView.cpp --- DetectorDescription/RegressionTest/test/testDDCompactView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp index 17d838d82b183..86dad772c3e45 100644 --- a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp @@ -60,7 +60,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::make_unique(config))); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); From 8a5c43626752aac7392800c2184dae93f9ec670c Mon Sep 17 00:00:00 2001 From: Norraphat Date: Fri, 5 Apr 2019 00:28:12 +0200 Subject: [PATCH 463/686] add standard prod-like 2018 relvals with b-parking --- .../python/relval_standard.py | 10 +++++++++ .../python/relval_steps.py | 21 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_standard.py b/Configuration/PyReleaseValidation/python/relval_standard.py index c2768582ae616..e68bc43e3a796 100644 --- a/Configuration/PyReleaseValidation/python/relval_standard.py +++ b/Configuration/PyReleaseValidation/python/relval_standard.py @@ -6,6 +6,7 @@ overridesEv5={'-n':'5'} +overridesEv100={'-n':'100'} # each workflow defines a name and a list of steps to be done. # if no explicit name/label given for the workflow (first arg), @@ -30,6 +31,15 @@ workflows[1303.17] = ['', ['ProdQCD_Pt_3000_3500_13UP17','DIGIUP17PROD1','RECOPRODUP17']] workflows.addOverride(1303.17,overridesEv5) +#####Prod2018 +#workflows[1301.18] = ['', ['ProdMinBias_13UP18','DIGIUP18PROD1','RECOPRODUP18']] +workflows[1302.18] = ['', ['ProdTTbar_13UP18','DIGIUP18PROD1','RECOPRODUP18']] +#workflows[1303.18] = ['', ['ProdQCD_Pt_3000_3500_13UP18','DIGIUP18PROD1','RECOPRODUP18']] +workflows[1304.18] = ['', ['ProdZEE_13UP18','DIGIUP18PROD1','RECOPRODUP18','MINIAODMCUP18']] +workflows[1304.181] = ['', ['ProdZEE_13UP18','DIGIUP18PROD1','RECOPRODUP18bParking','MINIAODMCUP18bParking']] +#workflows.addOverride(1303.17,overridesEv5) + + ### data ### workflows[4.5] = ['', ['RunCosmicsA','RECOCOSD','ALCACOSD','HARVESTDC']] #workflows[4.6] = ['', ['MinimumBias2010A','RECODR1','HARVESTDR1']] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 22193a75a6004..eba5d7ba0827a 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1551,6 +1551,7 @@ def lhegensim2018(fragment,howMuch): steps['DIGIUP17']=merge([step2Upg2017Defaults]) steps['DIGIUP18']=merge([step2Upg2018Defaults]) steps['DIGIUP17PROD1']=merge([{'-s':'DIGI,L1,DIGI2RAW,HLT:@relval2017','--eventcontent':'RAWSIM','--datatier':'GEN-SIM-RAW'},step2Upg2017Defaults]) +steps['DIGIUP18PROD1']=merge([{'-s':'DIGI,L1,DIGI2RAW,HLT:@relval2018','--eventcontent':'RAWSIM','--datatier':'GEN-SIM-RAW'},step2Upg2018Defaults]) steps['DIGIUP17_PU25']=merge([PU25UP17,step2Upg2017Defaults]) steps['DIGIUP18_PU25']=merge([PU25UP18,step2Upg2018Defaults]) @@ -2197,6 +2198,10 @@ def gen2018HiMix(fragment,howMuch): steps['RECOPRODUP15']=merge([{ '-s':'RAW2DIGI,L1Reco,RECO,RECOSIM,EI,PAT','--datatier':'AODSIM,MINIAODSIM','--eventcontent':'AODSIM,MINIAODSIM'},step3Up2015Defaults]) ## for 2017 PROD steps['RECOPRODUP17']=merge([{ '--era' :'Run2_2017','--conditions': 'auto:phase1_2017_realistic'},steps['RECOPRODUP15']]) +## for 2018 PROD +steps['RECOPRODUP18']=merge([{ '-s':'RAW2DIGI,L1Reco,RECO,RECOSIM,EI','--era' :'Run2_2018','--conditions': 'auto:phase1_2018_realistic','--datatier':'AODSIM','--eventcontent':'AODSIM'},step3Up2015Defaults]) +steps['RECOPRODUP18bParking']=merge([{ '-s':'RAW2DIGI,L1Reco,RECO,RECOSIM,EI','--era' :'Run2_2018,bParking','--conditions': 'auto:phase1_2018_realistic','--datatier':'AODSIM','--eventcontent':'AODSIM'},step3Up2015Defaults]) +## steps['RECOCOS']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,DQM','--scenario':'cosmics','--datatier':'GEN-SIM-RECO,DQMIO','--eventcontent':'RECOSIM,DQM'},stCond,step3Defaults]) steps['RECOHAL']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,DQM','--scenario':'cosmics'},step3Up2015Hal]) steps['RECOCOS_UP15']=merge([{'--conditions':'auto:run2_mc_cosmics','-s':'RAW2DIGI,L1Reco,RECO,ALCA:MuAlGlobalCosmics,DQM','--scenario':'cosmics'},step3Up2015Hal]) @@ -2802,17 +2807,25 @@ def gen2018HiMix(fragment,howMuch): #steps['MINIAODDATA'] =merge([stepMiniAODData]) #steps['MINIAODDreHLT'] =merge([{'--conditions':'auto:run1_data_%s'%menu},stepMiniAODData]) #steps['MINIAODDATAs2'] =merge([{'--filein':'file:step2.root'},stepMiniAODData]) + +#MiniAOD 2016 steps['MINIAODMCUP15'] =merge([stepMiniAODMC]) #steps['MINIAODMCUP1550'] =merge([{'--conditions':'auto:run2_mc_50ns','--era':'Run2_50ns'},stepMiniAODMC]) #steps['MINIAODMCUP15HI'] =merge([{'--conditions':'auto:run2_mc_hi','--era':'Run2_HI'},stepMiniAODMC]) steps['MINIAODMCUP15FS'] =merge([{'--filein':'file:step1.root','--fast':''},stepMiniAODMC]) steps['MINIAODMCUP15FS50'] =merge([{'--conditions':'auto:run2_mc_50ns','--era':'Run2_50ns'},steps['MINIAODMCUP15FS']]) +steps['DBLMINIAODMCUP15NODQM'] = merge([{'--conditions':'auto:run2_mc', + '-s':'PAT', + '--datatier' : 'MINIAODSIM', + '--eventcontent':'MINIAOD',},stepMiniAODMC]) + +#MiniAOD 2017 steps['MINIAODMCUP17FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2017_realistic','--era':'Run2_2017_FastSim'},stepMiniAODMC]) + +#MiniAOD 2018 +steps['MINIAODMCUP18'] =merge([{'--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018'},stepMiniAODMC]) +steps['MINIAODMCUP18bParking'] =merge([{'--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018,bParking'},stepMiniAODMC]) steps['MINIAODMCUP18FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018_FastSim'},stepMiniAODMC]) -steps['DBLMINIAODMCUP15NODQM'] = merge([{'--conditions':'auto:run2_mc', - '-s':'PAT', - '--datatier' : 'MINIAODSIM', - '--eventcontent':'MINIAOD',},stepMiniAODMC]) stepNanoAODDefaults = { '-s': 'NANO,DQM:@nanoAODDQM', '-n': 1000 } stepNanoAODData = merge([{ '--data':'', '--eventcontent' : 'NANOAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ]) From d410adb66a17907afb376caec8f8d8fd57ae2403 Mon Sep 17 00:00:00 2001 From: Norraphat Date: Fri, 5 Apr 2019 00:36:23 +0200 Subject: [PATCH 464/686] remove unnecessary line --- Configuration/PyReleaseValidation/python/relval_standard.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_standard.py b/Configuration/PyReleaseValidation/python/relval_standard.py index e68bc43e3a796..a6bb100c90b68 100644 --- a/Configuration/PyReleaseValidation/python/relval_standard.py +++ b/Configuration/PyReleaseValidation/python/relval_standard.py @@ -6,7 +6,6 @@ overridesEv5={'-n':'5'} -overridesEv100={'-n':'100'} # each workflow defines a name and a list of steps to be done. # if no explicit name/label given for the workflow (first arg), From 6da492811377b49011afafe11a571ebc458fcaa2 Mon Sep 17 00:00:00 2001 From: Cristina Date: Tue, 26 Mar 2019 15:25:01 -0500 Subject: [PATCH 465/686] add flags to run only on selected layers and damaged clusters --- .../interface/PixelCPEClusterRepair.h | 27 ++++++++++++++++++- .../python/PixelCPEClusterRepair_cfi.py | 5 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h index c932ee9e40192..cd7f469ae6c3e 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h @@ -110,7 +110,32 @@ class PixelCPEClusterRepair : public PixelCPEBase //bool DoCosmics_; //bool LoadTemplatesFromDB_; - + + // read sub-detectors to recommend 2D + class Rule { + public: + // parse a rule from a string + Rule(const std::string &str) ; + // check this DetId to recommend 2D or not (default false) + bool recommend(DetId detid, const TrackerTopology &tTopo) const { + // check detector + if (detid.subdetId() == subdet_) { + // check layer + if ( (layer_ == 0) || (layer_ == int(tTopo.layer(detid))) ) { + return true; + } + else return false; + } + else return false; + } + private: + int subdet_; + int layer_; + }; + std::vector Recommend2D_; + + // run on damaged hits or not + bool RunDamagedClusters_; }; #endif diff --git a/RecoLocalTracker/SiPixelRecHits/python/PixelCPEClusterRepair_cfi.py b/RecoLocalTracker/SiPixelRecHits/python/PixelCPEClusterRepair_cfi.py index 5a44925c0d9b7..dfd42986c45d4 100644 --- a/RecoLocalTracker/SiPixelRecHits/python/PixelCPEClusterRepair_cfi.py +++ b/RecoLocalTracker/SiPixelRecHits/python/PixelCPEClusterRepair_cfi.py @@ -12,6 +12,11 @@ MaxSizeMismatchInY = cms.double(0.3), MinChargeRatio = cms.double(0.8), + # layers to run on: (only PXB 2,PXB 3,PXB 4 for now) + Recommend2D = cms.vstring("PXB 2","PXB 3","PXB 4"), + + # to run on damaged clusterss or not (default=no) + RunDamagedClusters = cms.bool(False), # petar, for clusterProbability() from TTRHs ClusterProbComputationFlag = cms.int32(0), From 5b963b9b81695537dcf1b02659b4259c22349123 Mon Sep 17 00:00:00 2001 From: Cristina Date: Tue, 26 Mar 2019 15:27:23 -0500 Subject: [PATCH 466/686] modify when recommend 2D --- .../src/PixelCPEClusterRepair.cc | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 04db502ca89d7..52f6664ad8a70 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -19,6 +19,8 @@ #include #include "boost/multi_array.hpp" +#include +#include #include @@ -91,6 +93,18 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, maxSizeMismatchInY_ = conf.getParameter("MaxSizeMismatchInY"); minChargeRatio_ = conf.getParameter("MinChargeRatio"); + // read sub-detectors to recommend 2D + // can be: + // XYX (XYZ = PXB, PXE) + // XYZ n (XYZ as above, n = layer, wheel or disk = 1 .. 6 ;) + std::vector str_Recommend2D = conf.getParameter >("Recommend2D"); + Recommend2D_.reserve(str_Recommend2D.size()); + for (std::vector::const_iterator it = str_Recommend2D.begin(), ed = str_Recommend2D.end(); it != ed; ++it) { + Recommend2D_.push_back(Rule(*it)); + } + + // run CR on damaged clusters (and not only on edge hits) + RunDamagedClusters_ = conf.existsAs("RunDamagedClusters")?conf.getParameter("RunDamagedClusters"):false; } @@ -492,10 +506,15 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus { DetId id = (theDetParam.theDet->geographicalId()); - bool isBarrel = GeomDetEnumerators::isBarrel(theDetParam.thePart); - int layer=ttopo_.layer(id); - if(!isBarrel){ - //only run on barrel + + bool recommend = false; + for (std::vector::const_iterator itr = Recommend2D_.begin(), edr = Recommend2D_.end(); itr != edr; ++itr) { + recommend = itr->recommend(id, ttopo_); + if(recommend) break; + } + + // only run on those layers recommended by configuration + if(!recommend) { theClusterParam.recommended2D_ = false; return; } @@ -534,8 +553,10 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus theClusterParam.recommended2D_ = true; theClusterParam.hasBadPixels_ = true; - //for now, don't try to fix any clusters in layer 1 - if( layer == 1 ) theClusterParam.recommended2D_ = false; + // if not RunDamagedClusters flag, don't try to fix any clusters + if(!RunDamagedClusters_) { + theClusterParam.recommended2D_ = false; + } // Figure out what edge flags to set for truncated cluster // Truncated clusters usually come from dead double columns @@ -644,3 +665,24 @@ PixelCPEClusterRepair::localError(DetParam const & theDetParam, ClusterParam & return LocalError(xerr*xerr, 0, yerr*yerr); } +PixelCPEClusterRepair::Rule::Rule(const std::string &str) { + static const boost::regex rule("([A-Z]+)(\\s+(\\d+))?"); + boost::cmatch match; + // match and check it works + if (!regex_match(str.c_str(), match, rule)) + throw cms::Exception("Configuration") << "Rule '" << str << "' not understood.\n"; + + // subdet + subdet_ = -1; + if (strncmp(match[1].first, "PXB", 3) == 0) subdet_ = PixelSubdetector::PixelBarrel; + else if (strncmp(match[1].first, "PXE", 3) == 0) subdet_ = PixelSubdetector::PixelEndcap; + if (subdet_ == -1) { + throw cms::Exception("PixelCPEClusterRepair::Configuration") << "Detector '" << match[1].first << "' not understood. Should be PXB, PXE.\n"; + } + // layer (if present) + if (match[3].first != match[3].second) { + layer_ = atoi(match[3].first); + } else { + layer_ = 0; + } +}//end Rule::Rule From 1bb9ed2099502fd41296548cbc56fc19740a34c0 Mon Sep 17 00:00:00 2001 From: Cristina Date: Tue, 26 Mar 2019 15:58:28 -0500 Subject: [PATCH 467/686] turning on CR --- .../python/TTRHBuilderWithTemplate_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTracker/TransientTrackingRecHit/python/TTRHBuilderWithTemplate_cfi.py b/RecoTracker/TransientTrackingRecHit/python/TTRHBuilderWithTemplate_cfi.py index e173cd43e73c7..bb8c745055f53 100644 --- a/RecoTracker/TransientTrackingRecHit/python/TTRHBuilderWithTemplate_cfi.py +++ b/RecoTracker/TransientTrackingRecHit/python/TTRHBuilderWithTemplate_cfi.py @@ -12,6 +12,6 @@ trackingPhase2PU140.toModify(TTRHBuilderAngleAndTemplate, Phase2StripCPE = cms.string('Phase2StripCPE')) # uncomment these two lines to turn on Cluster Repair CPE -# from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel -# phase1Pixel.toModify(TTRHBuilderAngleAndTemplate, PixelCPE = cms.string('PixelCPEClusterRepair')) +from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel +phase1Pixel.toModify(TTRHBuilderAngleAndTemplate, PixelCPE = cms.string('PixelCPEClusterRepair')) From 4eb37bd66e5bef08629ab1c46bab3e2c31115f9d Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 4 Apr 2019 21:33:19 +0200 Subject: [PATCH 468/686] solve conflicts with old local conditions --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index e65855805a698..4a684dcd3bfef 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,11 +24,11 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '105X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v1', + 'run1_data' : '106X_dataRun2_v4', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v1', + 'run2_data' : '106X_dataRun2_v4', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v1', + 'run2_data_relval' : '106X_dataRun2_relval_v2', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) From 6d0e7dd9e3dc19c88e7901e4917adea9b8822356 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Fri, 5 Apr 2019 03:29:21 -0500 Subject: [PATCH 469/686] Removed unused variable from SiPixelFedFillerWordEventNumber This was causing a compiler warning. --- .../SiPixelTools/plugins/SiPixelFedFillerWordEventNumber.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/CalibTracker/SiPixelTools/plugins/SiPixelFedFillerWordEventNumber.cc b/CalibTracker/SiPixelTools/plugins/SiPixelFedFillerWordEventNumber.cc index e73f9eec42c22..6db795a3968d2 100755 --- a/CalibTracker/SiPixelTools/plugins/SiPixelFedFillerWordEventNumber.cc +++ b/CalibTracker/SiPixelTools/plugins/SiPixelFedFillerWordEventNumber.cc @@ -365,7 +365,6 @@ SiPixelFedFillerWordEventNumber ::produce(edm::Event& iEvent, const edm::EventSe auto FillerWordEventNumbers2 = std::make_unique>(); auto SaveFillerWords = std::make_unique>(); //===== Loop over all the FEDs ======================================================== - FEDNumbering fednum; std::pair fedIds; fedIds.first = 0; fedIds.second = 39; From 5f930a35eb0b5b4051b95ec73def8e489c9c592f Mon Sep 17 00:00:00 2001 From: David Date: Fri, 5 Apr 2019 14:08:38 +0200 Subject: [PATCH 470/686] __cmp__ is removed in python3 --- FWCore/ParameterSet/python/Types.py | 50 ++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/FWCore/ParameterSet/python/Types.py b/FWCore/ParameterSet/python/Types.py index c2ded1db72c7d..f5291ce8c36e8 100644 --- a/FWCore/ParameterSet/python/Types.py +++ b/FWCore/ParameterSet/python/Types.py @@ -4,7 +4,7 @@ from .Mixins import saveOrigin from .ExceptionHandling import format_typename, format_outerframe from past.builtins import long - +import codecs import copy import math import six @@ -167,7 +167,8 @@ def pythonValue(self, options=PrintOptions()): @staticmethod def formatValueForConfig(value): l = len(value) - value = value.encode("string-escape") + t=codecs.escape_encode(value.encode('utf-8')) + value = t[0].decode('utf-8') newL = len(value) if l != newL: #get rid of the hex encoding @@ -481,13 +482,26 @@ def pythonValue(self, options=PrintOptions()): @staticmethod def _isValid(value): return True - def __cmp__(self,other): - v = self.__moduleLabel != other.__moduleLabel - if not v: - v= self.__productInstance != other.__productInstance - if not v: - v=self.__processName != other.__processName - return v + def __eq__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) == + (other.__moduleLabel,other.__productInstance,other.__processName)) + def __ne__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) != + (other.__moduleLabel,other.__productInstance,other.__processName)) + def __lt__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) < + (other.__moduleLabel,other.__productInstance,other.__processName)) + def __gt__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) > + (other.__moduleLabel,other.__productInstance,other.__processName)) + def __le__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) <= + (other.__moduleLabel,other.__productInstance,other.__processName)) + def __ge__(self,other): + return ((self.__moduleLabel,self.__productInstance,self.__processName) >= + (other.__moduleLabel,other.__productInstance,other.__processName)) + + def value(self): "Return the string rep" return self.configValue() @@ -505,7 +519,6 @@ def _setValues(self,moduleLabel,productInstanceLabel='',processName=''): self.__moduleLabel = moduleLabel self.__productInstance = productInstanceLabel self.__processName=processName - if -1 != moduleLabel.find(":"): toks = moduleLabel.split(":") self.__moduleLabel = toks[0] @@ -557,11 +570,18 @@ def pythonValue(self, options=PrintOptions()): @staticmethod def _isValid(value): return True - def __cmp__(self,other): - v = self.__moduleLabel != other.__moduleLabel - if not v: - v= self.__data != other.__data - return v + def __eq__(self,other): + return ((self.__moduleLabel,self.__data) == (other.__moduleLabel,other.__data)) + def __ne__(self,other): + return ((self.__moduleLabel,self.__data) != (other.__moduleLabel,other.__data)) + def __lt__(self,other): + return ((self.__moduleLabel,self.__data) < (other.__moduleLabel,other.__data)) + def __gt__(self,other): + return ((self.__moduleLabel,self.__data) > (other.__moduleLabel,other.__data)) + def __le__(self,other): + return ((self.__moduleLabel,self.__data) <= (other.__moduleLabel,other.__data)) + def __ge__(self,other): + return ((self.__moduleLabel,self.__data) >= (other.__moduleLabel,other.__data)) def value(self): "Return the string rep" return self.configValue() From a04aa6e1e783ef7eac8372bfcde372a530816c70 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 5 Apr 2019 14:13:27 +0200 Subject: [PATCH 471/686] python3 compatibility --- PhysicsTools/PatAlgos/python/tools/jetTools.py | 6 +++--- PhysicsTools/SelectorUtils/python/centralIDRegistry.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PhysicsTools/PatAlgos/python/tools/jetTools.py b/PhysicsTools/PatAlgos/python/tools/jetTools.py index 8d4acd84e70b1..e817010eec80a 100644 --- a/PhysicsTools/PatAlgos/python/tools/jetTools.py +++ b/PhysicsTools/PatAlgos/python/tools/jetTools.py @@ -868,7 +868,7 @@ def __init__(self): and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=True) self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging, in most cases just the labels of the btag discriminators that \ you are interested in is all relevant information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. \ - If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(supportedBtagDiscr.keys()+supportedMetaDiscr.keys()),Type=list) + If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list) self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects contain all relevant information from which all discriminators of a certain \ type have been calculated. You might be interested in keeping this information for low level tests or to re-calculate some discriminators from hand. Note that this information \ on the one hand can be very space consuming and that it is not necessary to access the pre-calculated btag discriminator information that has been derived from it. Only in very \ @@ -1274,7 +1274,7 @@ def __init__(self): applied. If you are not interested in MET(Type1) corrections to this new patJet collection pass None as third argument of the python tuple.", tuple, acceptNoneValue=True) self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging in general the btag discriminators is all relevant \ information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. If this list is empty no btag \ - discriminator information will be added to your new patJet collection.", allowedValues=(supportedBtagDiscr.keys()+supportedMetaDiscr.keys()),Type=list) + discriminator information will be added to your new patJet collection.", allowedValues=(list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list) self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects conatin all relevant information from which all discriminators of a certain \ type have been calculated. Note that this information on the one hand can be very space consuming and on the other hand is not necessary to access the btag discriminator \ information that has been derived from it. Only in very special cases the btagInfos might really be needed in your analysis. Add here all btagInfos, that you are interested \ @@ -1487,7 +1487,7 @@ def __init__(self): and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=True) self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging, in most cases just the labels of the btag discriminators that \ you are interested in is all relevant information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. \ - If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(supportedBtagDiscr.keys()+supportedMetaDiscr.keys()),Type=list) + If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list) self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects contain all relevant information from which all discriminators of a certain \ type have been calculated. You might be interested in keeping this information for low level tests or to re-calculate some discriminators from hand. Note that this information \ on the one hand can be very space consuming and that it is not necessary to access the pre-calculated btag discriminator information that has been derived from it. Only in very \ diff --git a/PhysicsTools/SelectorUtils/python/centralIDRegistry.py b/PhysicsTools/SelectorUtils/python/centralIDRegistry.py index 24050e203db18..a66653bb77685 100644 --- a/PhysicsTools/SelectorUtils/python/centralIDRegistry.py +++ b/PhysicsTools/SelectorUtils/python/centralIDRegistry.py @@ -12,10 +12,10 @@ def register(self,name,md5): else: raise Exception('md5 %s already exists with name %s!'%(md5,self.md5toName[md5])) # register name -> md5 - if name not in self.nameToMD5: - self.nameToMD5[name] = md5 + if name.value() not in self.nameToMD5: + self.nameToMD5[name.value()] = md5 else: - raise Exception('Name %s already exists with md5 %s!'%(name,self.nameToMD5[name])) + raise Exception('Name %s already exists with md5 %s!'%(name.value(),self.nameToMD5[name.value()])) def getNameFromMD5(self,md5): if md5 in self.md5toName: @@ -24,8 +24,8 @@ def getNameFromMD5(self,md5): return '' def getMD5FromName(self,name): - if name in self.nameToMD5: - return self.nameToMD5[name] + if name.value() in self.nameToMD5: + return self.nameToMD5[name.value()] else: return '' From 846d426268dfcbeea0ad29abb64c136d42bd2b82 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 5 Apr 2019 15:17:53 +0200 Subject: [PATCH 472/686] First version of MTD geometry --- .../DDCMS/data/cms-2015-muon-geometry.xml | 2 +- .../DDCMS/data/cms-mf-geometry.xml | 2 +- .../DDCMS/data/cms-test-shapes.xml | 2 +- .../DDCMS/data/cms-tracker.xml | 2 +- .../DDCMS/data/cms_tracker.xml | 2 +- .../DDCMS/data/testDDAngularAlgorithm.xml | 2 +- .../DDCMS/data/testDDHGCalCellAlgorithm.xml | 2 +- .../DDCMS/plugins/DDCMSDetector.cc | 30 ++++---- .../DDCMS/plugins/DDDefinitions2Objects.cc | 9 ++- DetectorDescription/DDCMS/src/DDNamespace.cc | 7 +- .../data/dd4hep/cms-mtd-geometry.xml | 69 +++++++++++++++++++ .../test/python/testMTDGeometry.py | 58 ++++++++++++++++ 12 files changed, 159 insertions(+), 28 deletions(-) create mode 100644 Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml create mode 100644 Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py diff --git a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml index 3edc29e248829..bc1714d1a6e2d 100644 --- a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml +++ b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml @@ -63,7 +63,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/cms-mf-geometry.xml b/DetectorDescription/DDCMS/data/cms-mf-geometry.xml index 944ab2c338e35..b692a525c41bc 100644 --- a/DetectorDescription/DDCMS/data/cms-mf-geometry.xml +++ b/DetectorDescription/DDCMS/data/cms-mf-geometry.xml @@ -31,7 +31,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/cms-test-shapes.xml b/DetectorDescription/DDCMS/data/cms-test-shapes.xml index dec5a2bee2588..6c348bdd315eb 100644 --- a/DetectorDescription/DDCMS/data/cms-test-shapes.xml +++ b/DetectorDescription/DDCMS/data/cms-test-shapes.xml @@ -44,7 +44,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/cms-tracker.xml b/DetectorDescription/DDCMS/data/cms-tracker.xml index 88146198e7d8e..53409414e9242 100644 --- a/DetectorDescription/DDCMS/data/cms-tracker.xml +++ b/DetectorDescription/DDCMS/data/cms-tracker.xml @@ -259,7 +259,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/cms_tracker.xml b/DetectorDescription/DDCMS/data/cms_tracker.xml index 31362af4090e8..1a48d75a89c1d 100644 --- a/DetectorDescription/DDCMS/data/cms_tracker.xml +++ b/DetectorDescription/DDCMS/data/cms_tracker.xml @@ -267,7 +267,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/testDDAngularAlgorithm.xml b/DetectorDescription/DDCMS/data/testDDAngularAlgorithm.xml index c5f6cc53e3929..4514221ce163b 100644 --- a/DetectorDescription/DDCMS/data/testDDAngularAlgorithm.xml +++ b/DetectorDescription/DDCMS/data/testDDAngularAlgorithm.xml @@ -41,7 +41,7 @@ - + diff --git a/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml b/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml index a48e95f19518d..eafa5b53001af 100644 --- a/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml +++ b/DetectorDescription/DDCMS/data/testDDHGCalCellAlgorithm.xml @@ -57,7 +57,7 @@ - + diff --git a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc index 0c3ba5d23609a..f90b3048b4eac 100644 --- a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc +++ b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc @@ -41,23 +41,27 @@ DDCMSDetector::analyze(const Event&, const EventSetup& iEventSetup) ESTransientHandle det; iEventSetup.get().get(m_tag.module(), det); - LogInfo("DDCMS") << "Iterate over the detectors:\n"; - for( auto const& it : det->description()->detectors()) { - dd4hep::DetElement det(it.second); - LogInfo("DDCMS") << it.first << ": " << det.path() << "\n"; - } - LogInfo("DDCMS") << "..done!\n"; + LogVerbatim("Geometry") << "Iterate over the detectors:\n"; + LogVerbatim("Geometry").log([&](auto& log) { + for(auto const& it : det->description()->detectors()) { + dd4hep::DetElement det(it.second); + log << it.first << ": " << det.path(); + } + }); + LogVerbatim("Geometry") << "..done!"; ESTransientHandle registry; iEventSetup.get().get(m_tag.module(), registry); - LogInfo("DDCMS") << "DD Vector Registry size: " << registry->vectors.size() << "\n"; - for( const auto& p: registry->vectors ) { - LogInfo("DDCMS") << " " << p.first << " => "; - for( const auto& i : p.second ) - LogInfo("DDCMS") << i << ", "; - LogInfo("DDCMS") << '\n'; - } + LogVerbatim("Geometry") << "DD Vector Registry size: " << registry->vectors.size(); + LogVerbatim("Geometry").log([&](auto& log) { + for(const auto& p: registry->vectors) { + log << " " << p.first << " => "; + for(const auto& i : p.second) + log << i << ", "; + log << '\n'; + } + }); } void diff --git a/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc b/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc index 1641c540c9391..813cc96cbe987 100644 --- a/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc +++ b/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc @@ -655,6 +655,9 @@ template <> void Converter::operator()( xml_h element ) const { int copy = e.attr( DD_CMU( copyNumber )); string parentName = ns.attr( e.child( DD_CMU( rParent )), _U( name )); string childName = ns.attr( e.child( DD_CMU( rChild )), _U( name )); + + if( strchr( parentName.c_str(), NAMESPACE_SEP ) == nullptr ) + parentName = ns.name() + parentName; Volume parent = ns.volume( parentName ); if( strchr( childName.c_str(), NAMESPACE_SEP ) == nullptr ) @@ -1312,12 +1315,11 @@ template <> void Converter::operator()(xml_h /* element */) const { cms::DDParsingContext* context = _param(); DDRegistry* res = _option(); cms::DDNamespace ns( context ); - + int count = 0; + printout( context->debug_constants ? ALWAYS : DEBUG, "DD4CMS","+++ RESOLVING %ld unknown constants.....", res->unresolvedConst.size()); - // FIXME: Avoid an infinite loop in a case - // when a referred constant is not defined while( !res->unresolvedConst.empty()) { for( auto i : res->unresolvedConst ) { const string& n = i.first; @@ -1348,6 +1350,7 @@ template <> void Converter::operator()(xml_h /* element */) const { break; } } + if( ++count > 10000) break; } if( !res->unresolvedConst.empty()) { for(const auto& e : res->unresolvedConst) diff --git a/DetectorDescription/DDCMS/src/DDNamespace.cc b/DetectorDescription/DDCMS/src/DDNamespace.cc index 50f15fed9c24c..3d47d90bb4d19 100644 --- a/DetectorDescription/DDCMS/src/DDNamespace.cc +++ b/DetectorDescription/DDCMS/src/DDNamespace.cc @@ -192,15 +192,12 @@ DDNamespace::addVolume( dd4hep::Volume vol ) const dd4hep::Volume DDNamespace::volume( const string& name, bool exc ) const { - size_t idx; auto i = m_context->volumes.find( name ); if( i != m_context->volumes.end()) { return (*i).second; } - if(( idx = name.find( NAMESPACE_SEP )) != string::npos ) { - string n = name; - n[idx] = NAMESPACE_SEP; - i = m_context->volumes.find( n ); + if(name.front() == NAMESPACE_SEP) { + i = m_context->volumes.find(name.substr(1,name.size())); if( i != m_context->volumes.end()) return (*i).second; } diff --git a/Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml b/Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml new file mode 100644 index 0000000000000..d7cebaa67da3c --- /dev/null +++ b/Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py b/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py new file mode 100644 index 0000000000000..6158c8bd95e0a --- /dev/null +++ b/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py @@ -0,0 +1,58 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("MTDGeometryTest") + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.MessageLogger = cms.Service( + "MessageLogger", + statistics = cms.untracked.vstring('cout', 'mtdGeometry'), + categories = cms.untracked.vstring('Geometry'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING'), + noLineBreaks = cms.untracked.bool(True) + ), + mtdGeometry = cms.untracked.PSet( + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + threshold = cms.untracked.string('INFO'), + Geometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ) + ), + destinations = cms.untracked.vstring('cout', + 'mtdGeometry') + ) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('Geometry/MTDCommonData/data/dd4hep/cms-mtd-geometry.xml'), + appendToDataLabel = cms.string('MTD') + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MTD') + ) + +process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer", + appendToDataLabel = cms.string('MTD') + ) + +process.test = cms.EDAnalyzer("DDCMSDetector", + DDDetector = cms.ESInputTag('MTD') + ) + +process.p = cms.Path(process.test) From 17a9b5da6368d1aa78d3652b94a71f4447712577 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Mon, 11 Dec 2017 15:43:17 +0100 Subject: [PATCH 473/686] refactoring of StreamerOutputModuleBase: moved serialization code to external base class (which doesn't inherit from edm::one::OutputModule). This allows sharing serialization code with global and limited output modules. --- .../interface/StreamerOutputModuleBase.h | 42 +-- .../interface/StreamerOutputModuleCommon.h | 71 +++++ .../Streamer/src/StreamerOutputModuleBase.cc | 267 ++---------------- .../src/StreamerOutputModuleCommon.cc | 249 ++++++++++++++++ 4 files changed, 347 insertions(+), 282 deletions(-) create mode 100644 IOPool/Streamer/interface/StreamerOutputModuleCommon.h create mode 100644 IOPool/Streamer/src/StreamerOutputModuleCommon.cc diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index a48deb53209e0..98f206de2628e 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -1,12 +1,13 @@ #ifndef IOPool_Streamer_StreamerOutputModuleBase_h #define IOPool_Streamer_StreamerOutputModuleBase_h +#include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h" #include "FWCore/Framework/interface/one/OutputModule.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "IOPool/Streamer/interface/MsgTools.h" -#include "IOPool/Streamer/interface/StreamSerializer.h" -#include -#include +//#include "IOPool/Streamer/interface/StreamSerializer.h" +//#include +//#include class InitMsgBuilder; class EventMsgBuilder; @@ -15,7 +16,8 @@ namespace edm { typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - class StreamerOutputModuleBase : public one::OutputModule { + class StreamerOutputModuleBase : public one::OutputModule, + StreamerOutputModuleCommon { public: explicit StreamerOutputModuleBase(ParameterSet const& ps); ~StreamerOutputModuleBase() override; @@ -35,39 +37,15 @@ namespace edm { virtual void doOutputHeader(InitMsgBuilder const& init_message) = 0; virtual void doOutputEvent(EventMsgBuilder const& msg) = 0; - std::unique_ptr serializeRegistry(); - std::unique_ptr serializeEvent(EventForOutput const& e); Trig getTriggerResults(EDGetTokenT const& token, EventForOutput const& e) const; - void setHltMask(EventForOutput const& e); - void setLumiSection(); - private: - SelectedProducts const* selections_; - - int maxEventSize_; - bool useCompression_; - int compressionLevel_; - - // test luminosity sections - int lumiSectionInterval_; - double timeInSecSinceUTC; - - StreamSerializer serializer_; - - SerializeDataBuffer serializeDataBuffer_; - - //Event variables, made class memebers to avoid re instatiation for each event. - unsigned int hltsize_; - uint32 lumi_; - std::vector l1bit_; - std::vector hltbits_; - uint32 origSize_; - char host_name_[255]; + virtual void getSelections() override; + private: edm::EDGetTokenT trToken_; - Strings hltTriggerSelections_; - uint32 outputModuleId_; + }; //end-of-class-def + } // end of namespace-edm #endif diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h new file mode 100644 index 0000000000000..c98993902ed70 --- /dev/null +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -0,0 +1,71 @@ +#ifndef IOPool_Streamer_StreamerOutputModuleCommon_h +#define IOPool_Streamer_StreamerOutputModuleCommon_h + +#include "IOPool/Streamer/interface/MsgTools.h" +#include "FWCore/Common/interface/TriggerNames.h" +#include "IOPool/Streamer/interface/StreamSerializer.h" +#include "DataFormats/Common/interface/Handle.h" +#include +#include + +class InitMsgBuilder; +class EventMsgBuilder; +namespace edm { + class ParameterSet; + class ParameterSetDescription; + class EventForOutput; + class ThinnedAssociationsHelper; + class TriggerResults; + + class StreamerOutputModuleCommon { + public: + explicit StreamerOutputModuleCommon(ParameterSet const& ps); + ~StreamerOutputModuleCommon(); + static void fillDescription(ParameterSetDescription & desc); + + std::unique_ptr serializeRegistry(BranchIDLists const& branchLists, + ThinnedAssociationsHelper const& helper, + std::string const& processName, + std::string const& moduleLabel, + ParameterSetID const& toplevel); + + std::unique_ptr serializeEvent(EventForOutput const& e, + Handle const& triggerResults, + ParameterSetID const& selectorCfg); + + void clearSerializeDataBuffer() { + serializeDataBuffer_.header_buf_.clear(); + serializeDataBuffer_.header_buf_.shrink_to_fit(); + } + + protected: + virtual void getSelections() = 0; + + SelectedProducts const* selections_; + std::unique_ptr serializer_; + + private: + void setHltMask(EventForOutput const& e, Handle const& triggerResults, std::vector& hltbits) const; + + int maxEventSize_; + bool useCompression_; + int compressionLevel_; + + // test luminosity sections + int lumiSectionInterval_; + double timeInSecSinceUTC; + + SerializeDataBuffer serializeDataBuffer_; + + unsigned int hltsize_; + uint32 origSize_; + char host_name_[255]; + + Strings hltTriggerSelections_; + uint32 outputModuleId_; + + }; //end-of-class-def + +} // end of namespace-edm + +#endif diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index a43402d16ea7b..2bcb27cf1473a 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -4,114 +4,39 @@ #include "IOPool/Streamer/interface/InitMsgBuilder.h" #include "IOPool/Streamer/interface/EventMsgBuilder.h" #include "FWCore/Framework/interface/EventForOutput.h" -#include "FWCore/Framework/interface/EventSelector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "FWCore/Utilities/interface/DebugMacros.h" -//#include "FWCore/Utilities/interface/Digest.h" -#include "FWCore/Version/interface/GetReleaseVersion.h" #include "DataFormats/Common/interface/TriggerResults.h" #include "DataFormats/Provenance/interface/ModuleDescription.h" #include "DataFormats/Provenance/interface/ParameterSetID.h" -#include -#include -#include -#include -#include -#include #include "zlib.h" -namespace { - //A utility function that packs bits from source into bytes, with - // packInOneByte as the numeber of bytes that are packed from source to dest. -/* inline void printBits(unsigned char c) { - for (int i = 7; i >= 0; --i) { - int bit = ((c >> i) & 1); - std::cout << " " << bit; - } - } */ - - void packIntoString(std::vector const& source, - std::vector& package) { - if (source.empty()) {return;} - unsigned int packInOneByte = 4; - unsigned int sizeOfPackage = 1+((source.size()-1)/packInOneByte); //Two bits per HLT - - package.resize(sizeOfPackage); - memset(&package[0], 0x00, sizeOfPackage); - - for (std::vector::size_type i=0; i != source.size() ; ++i) { - unsigned int whichByte = i/packInOneByte; - unsigned int indxWithinByte = i % packInOneByte; - package[whichByte] = package[whichByte] | (source[i] << (indxWithinByte*2)); - } - //for (unsigned int i=0; i !=package.size() ; ++i) - // printBits(package[i]); - // std::cout << std::endl; - - } -} - namespace edm { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : one::OutputModuleBase::OutputModuleBase(ps), one::OutputModule(ps), - selections_(&keptProducts()[InEvent]), - maxEventSize_(ps.getUntrackedParameter("max_event_size")), - useCompression_(ps.getUntrackedParameter("use_compression")), - compressionLevel_(ps.getUntrackedParameter("compression_level")), - lumiSectionInterval_(ps.getUntrackedParameter("lumiSection_interval")), - serializer_(selections_), - serializeDataBuffer_(), - hltsize_(0), - lumi_(0), - l1bit_(0), - hltbits_(0), - origSize_(0), - host_name_(), - trToken_(consumes(edm::InputTag("TriggerResults"))), - hltTriggerSelections_(), - outputModuleId_(0) { - // no compression as default value - we need this! - - // test luminosity sections - struct timeval now; - struct timezone dummyTZ; - gettimeofday(&now, &dummyTZ); - timeInSecSinceUTC = static_cast(now.tv_sec) + (static_cast(now.tv_usec)/1000000.0); - - if(useCompression_ == true) { - if(compressionLevel_ <= 0) { - FDEBUG(9) << "Compression Level = " << compressionLevel_ - << " no compression" << std::endl; - compressionLevel_ = 0; - useCompression_ = false; - } else if(compressionLevel_ > 9) { - FDEBUG(9) << "Compression Level = " << compressionLevel_ - << " using max compression level 9" << std::endl; - compressionLevel_ = 9; - } - } - serializeDataBuffer_.bufs_.resize(maxEventSize_); - int got_host = gethostname(host_name_, 255); - if(got_host != 0) strncpy(host_name_, "noHostNameFoundOrTooLong", sizeof(host_name_)); - //loadExtraClasses(); - - // 25-Jan-2008, KAB - pull out the trigger selection request - // which we need for the INIT message - hltTriggerSelections_ = EventSelector::getEventSelectionVString(ps); + StreamerOutputModuleCommon(ps), + trToken_(consumes(edm::InputTag("TriggerResults"))) { } StreamerOutputModuleBase::~StreamerOutputModuleBase() {} + void StreamerOutputModuleBase::getSelections() { + selections_ = &keptProducts()[InEvent]; + serializer_.reset(new StreamSerializer(selections_)); + } + void StreamerOutputModuleBase::beginRun(RunForOutput const&) { start(); - std::unique_ptr init_message = serializeRegistry(); + + std::unique_ptr init_message = + serializeRegistry(*branchIDLists(), *thinnedAssociationsHelper(), + OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID()); + doOutputHeader(*init_message); - serializeDataBuffer_.header_buf_.clear(); - serializeDataBuffer_.header_buf_.shrink_to_fit(); + clearSerializeDataBuffer(); } void @@ -124,7 +49,7 @@ namespace edm { void StreamerOutputModuleBase::endJob() { - stop(); // for closing of files, notify storage manager, etc. + stop(); } void @@ -135,68 +60,11 @@ namespace edm { void StreamerOutputModuleBase::write(EventForOutput const& e) { - std::unique_ptr msg = serializeEvent(e); + Handle const& triggerResults = getTriggerResults(trToken_, e); + std::unique_ptr msg = serializeEvent(e, triggerResults, selectorConfig()); doOutputEvent(*msg); // You can't use msg in StreamerOutputModuleBase after this point } - std::unique_ptr - StreamerOutputModuleBase::serializeRegistry() { - - serializer_.serializeRegistry(serializeDataBuffer_, *branchIDLists(), *thinnedAssociationsHelper()); - - // resize bufs_ to reflect space used in serializer_ + header - // I just added an overhead for header of 50000 for now - unsigned int src_size = serializeDataBuffer_.currentSpaceUsed(); - unsigned int new_size = src_size + 50000; - if(serializeDataBuffer_.header_buf_.size() < new_size) serializeDataBuffer_.header_buf_.resize(new_size); - - //Build the INIT Message - //Following values are strictly DUMMY and will be replaced - // once available with Utility function etc. - uint32 run = 1; - - //Get the Process PSet ID - ParameterSetID toplevel = moduleDescription().mainParameterSetID(); - - //In case we need to print it - // cms::Digest dig(toplevel.compactForm()); - // cms::MD5Result r1 = dig.digest(); - // std::string hexy = r1.toString(); - // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl; - - Strings hltTriggerNames = getAllTriggerNames(); - hltsize_ = hltTriggerNames.size(); - - //L1 stays dummy as of today - Strings l1_names; //3 - l1_names.push_back("t1"); - l1_names.push_back("t10"); - l1_names.push_back("t2"); - - //Setting the process name to HLT - std::string processName = OutputModule::processName(); - - std::string moduleLabel = description().moduleLabel(); - uLong crc = crc32(0L, Z_NULL, 0); - Bytef const* buf = (Bytef const*)(moduleLabel.data()); - crc = crc32(crc, buf, moduleLabel.length()); - outputModuleId_ = static_cast(crc); - - auto init_message = std::make_unique( - &serializeDataBuffer_.header_buf_[0], serializeDataBuffer_.header_buf_.size(), - run, Version((uint8 const*)toplevel.compactForm().c_str()), - getReleaseVersion().c_str() , processName.c_str(), - moduleLabel.c_str(), outputModuleId_, - hltTriggerNames, hltTriggerSelections_, l1_names, - (uint32)serializeDataBuffer_.adler32_chksum()); - - // copy data into the destination message - unsigned char* src = serializeDataBuffer_.bufferPointer(); - std::copy(src, src + src_size, init_message->dataAddress()); - init_message->setDataLength(src_size); - return init_message; - } - Trig StreamerOutputModuleBase::getTriggerResults(EDGetTokenT const& token, EventForOutput const& e) const { Trig result; @@ -204,110 +72,9 @@ namespace edm { return result; } - void - StreamerOutputModuleBase::setHltMask(EventForOutput const& e) { - - hltbits_.clear(); // If there was something left over from last event - - Handle const& prod = getTriggerResults(trToken_, e); - //Trig const& prod = getTrigMask(e); - std::vector vHltState; - - if (prod.isValid()) { - for(std::vector::size_type i=0; i != hltsize_ ; ++i) { - vHltState.push_back(((prod->at(i)).state())); - } - } else { - // We fill all Trigger bits to valid state. - for(std::vector::size_type i=0; i != hltsize_ ; ++i) { - vHltState.push_back(hlt::Pass); - } - } - //Pack into member hltbits_ - packIntoString(vHltState, hltbits_); - - //This is Just a printing code. - //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl; - //for(unsigned int i=0; i != hltbits_.size() ; ++i) { - // printBits(hltbits_[i]); - //} - //std::cout << "\n"; - } - -// test luminosity sections - void - StreamerOutputModuleBase::setLumiSection() { - struct timeval now; - struct timezone dummyTZ; - gettimeofday(&now, &dummyTZ); - double timeInSec = static_cast(now.tv_sec) + (static_cast(now.tv_usec)/1000000.0) - timeInSecSinceUTC; - // what about overflows? - if(lumiSectionInterval_ > 0) lumi_ = static_cast(timeInSec/lumiSectionInterval_) + 1; - } - - std::unique_ptr - StreamerOutputModuleBase::serializeEvent(EventForOutput const& e) { - //Lets Build the Event Message first - - //Following is strictly DUMMY Data for L! Trig and will be replaced with actual - // once figured out, there is no logic involved here. - l1bit_.push_back(true); - l1bit_.push_back(true); - l1bit_.push_back(false); - //End of dummy data - - setHltMask(e); - - if (lumiSectionInterval_ == 0) { - lumi_ = e.luminosityBlock(); - } else { - setLumiSection(); - } - - serializer_.serializeEvent(e, selectorConfig(), useCompression_, compressionLevel_, serializeDataBuffer_); - - // resize bufs_ to reflect space used in serializer_ + header - // I just added an overhead for header of 50000 for now - unsigned int src_size = serializeDataBuffer_.currentSpaceUsed(); - unsigned int new_size = src_size + 50000; - if(serializeDataBuffer_.bufs_.size() < new_size) serializeDataBuffer_.bufs_.resize(new_size); - - auto msg = std::make_unique( - &serializeDataBuffer_.bufs_[0], serializeDataBuffer_.bufs_.size(), e.id().run(), - e.id().event(), lumi_, outputModuleId_, 0, - l1bit_, (uint8*)&hltbits_[0], hltsize_, - (uint32)serializeDataBuffer_.adler32_chksum(), host_name_); - msg->setOrigDataSize(origSize_); // we need this set to zero - - // copy data into the destination message - // an alternative is to have serializer only to the serialization - // in serializeEvent, and then call a new member "getEventData" that - // takes the compression arguments and a place to put the data. - // This will require one less copy. The only catch is that the - // space provided in bufs_ should be at least the uncompressed - // size + overhead for header because we will not know the actual - // compressed size. - - unsigned char* src = serializeDataBuffer_.bufferPointer(); - std::copy(src,src + src_size, msg->eventAddr()); - msg->setEventLength(src_size); - if(useCompression_) msg->setOrigDataSize(serializeDataBuffer_.currentEventSize()); - - l1bit_.clear(); //Clear up for the next event to come. - return msg; - } - void StreamerOutputModuleBase::fillDescription(ParameterSetDescription& desc) { - desc.addUntracked("max_event_size", 7000000) - ->setComment("Starting size in bytes of the serialized event buffer."); - desc.addUntracked("use_compression", true) - ->setComment("If True, compression will be used to write streamer file."); - desc.addUntracked("compression_level", 1) - ->setComment("ROOT compression level to use."); - desc.addUntracked("lumiSection_interval", 0) - ->setComment("If 0, use lumi section number from event.\n" - "If not 0, the interval in seconds between fake lumi sections."); + StreamerOutputModuleCommon::fillDescription(desc); OutputModule::fillDescription(desc); } } // end of namespace-edm diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc new file mode 100644 index 0000000000000..ed3480c14584e --- /dev/null +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -0,0 +1,249 @@ +#include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h" + +#include "IOPool/Streamer/interface/InitMsgBuilder.h" +#include "IOPool/Streamer/interface/EventMsgBuilder.h" +#include "FWCore/Framework/interface/EventForOutput.h" +#include "FWCore/Framework/interface/EventSelector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/DebugMacros.h" +#include "FWCore/Version/interface/GetReleaseVersion.h" +#include "DataFormats/Common/interface/TriggerResults.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" +#include "DataFormats/Provenance/interface/ParameterSetID.h" +#include "DataFormats/Provenance/interface/SelectedProducts.h" +#include "FWCore/Framework/interface/getAllTriggerNames.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace edm { + StreamerOutputModuleCommon::StreamerOutputModuleCommon(ParameterSet const& ps) : + maxEventSize_(ps.getUntrackedParameter("max_event_size")), + useCompression_(ps.getUntrackedParameter("use_compression")), + compressionLevel_(ps.getUntrackedParameter("compression_level")), + lumiSectionInterval_(ps.getUntrackedParameter("lumiSection_interval")), + serializeDataBuffer_(), + hltsize_(0), + origSize_(0), + host_name_(), + hltTriggerSelections_(), + outputModuleId_(0) { + // no compression as default value - we need this! + + //inheriting class must implement getSelections method to retrieve selection from base output module + //::getSelections { + // selections_(&keptProducts()[InEvent]), + // serializer_(selections_), + // selectionsInitialized_=true; + //} + + // test luminosity sections + struct timeval now; + struct timezone dummyTZ; + gettimeofday(&now, &dummyTZ); + timeInSecSinceUTC = static_cast(now.tv_sec) + (static_cast(now.tv_usec)/1000000.0); + + if(useCompression_ == true) { + if(compressionLevel_ <= 0) { + FDEBUG(9) << "Compression Level = " << compressionLevel_ + << " no compression" << std::endl; + compressionLevel_ = 0; + useCompression_ = false; + } else if(compressionLevel_ > 9) { + FDEBUG(9) << "Compression Level = " << compressionLevel_ + << " using max compression level 9" << std::endl; + compressionLevel_ = 9; + } + } + serializeDataBuffer_.bufs_.resize(maxEventSize_); + int got_host = gethostname(host_name_, 255); + if(got_host != 0) strncpy(host_name_, "noHostNameFoundOrTooLong", sizeof(host_name_)); + //loadExtraClasses(); + + // 25-Jan-2008, KAB - pull out the trigger selection request + // which we need for the INIT message + hltTriggerSelections_ = EventSelector::getEventSelectionVString(ps); + } + + StreamerOutputModuleCommon::~StreamerOutputModuleCommon() {} + + + std::unique_ptr + StreamerOutputModuleCommon::serializeRegistry( const BranchIDLists &branchLists, + ThinnedAssociationsHelper const& helper, + std::string const& processName, + std::string const& moduleLabel, + ParameterSetID const& toplevel) + { + + if (serializer_.get()==nullptr) getSelections(); + + serializer_->serializeRegistry(serializeDataBuffer_, branchLists, helper); + + // resize bufs_ to reflect space used in serializer_ + header + // I just added an overhead for header of 50000 for now + unsigned int src_size = serializeDataBuffer_.currentSpaceUsed(); + unsigned int new_size = src_size + 50000; + if(serializeDataBuffer_.header_buf_.size() < new_size) serializeDataBuffer_.header_buf_.resize(new_size); + + //Build the INIT Message + //Following values are strictly DUMMY and will be replaced + // once available with Utility function etc. + uint32 run = 1; + + //Get the Process PSet ID + + //In case we need to print it + // cms::Digest dig(toplevel.compactForm()); + // cms::MD5Result r1 = dig.digest(); + // std::string hexy = r1.toString(); + // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl; + Strings const& hltTriggerNames = edm::getAllTriggerNames(); + hltsize_ = hltTriggerNames.size(); + + //L1 stays dummy as of today + Strings l1_names; //3 + l1_names.push_back("t1"); + l1_names.push_back("t10"); + l1_names.push_back("t2"); + + //Setting the process name to HLT + uLong crc = crc32(0L, Z_NULL, 0); + Bytef const* buf = (Bytef const*)(moduleLabel.data()); + crc = crc32(crc, buf, moduleLabel.length()); + outputModuleId_ = static_cast(crc); + + auto init_message = std::make_unique( + &serializeDataBuffer_.header_buf_[0], serializeDataBuffer_.header_buf_.size(), + run, Version((uint8 const*)toplevel.compactForm().c_str()), + getReleaseVersion().c_str() , processName.c_str(), + moduleLabel.c_str(), outputModuleId_, + hltTriggerNames, hltTriggerSelections_, l1_names, + (uint32)serializeDataBuffer_.adler32_chksum()); + + // copy data into the destination message + unsigned char* src = serializeDataBuffer_.bufferPointer(); + std::copy(src, src + src_size, init_message->dataAddress()); + init_message->setDataLength(src_size); + return init_message; + } + + void + StreamerOutputModuleCommon::setHltMask(EventForOutput const& e, Handle const& triggerResults, std::vector& hltbits) const { + + hltbits.clear(); + + std::vector vHltState; + + if (triggerResults.isValid()) { + for(std::vector::size_type i=0; i != hltsize_ ; ++i) { + vHltState.push_back(((triggerResults->at(i)).state())); + } + } else { + // We fill all Trigger bits to valid state. + for(std::vector::size_type i=0; i != hltsize_ ; ++i) { + vHltState.push_back(hlt::Pass); + } + } + + //Pack into member hltbits + if (!vHltState.empty()) { + unsigned int packInOneByte = 4; + unsigned int sizeOfPackage = 1+((vHltState.size()-1)/packInOneByte); //Two bits per HLT + + hltbits.resize(sizeOfPackage); + std::fill(hltbits.begin(), hltbits.end(), 0); + + for (std::vector::size_type i=0; i != vHltState.size() ; ++i) { + unsigned int whichByte = i/packInOneByte; + unsigned int indxWithinByte = i % packInOneByte; + hltbits[whichByte] = hltbits[whichByte] | (vHltState[i] << (indxWithinByte*2)); + } + } + + //This is Just a printing code. + //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl; + //for(unsigned int i=0; i != hltbits_.size() ; ++i) { + // printBits(hltbits_[i]); + //} + //std::cout << "\n"; + } + + std::unique_ptr + StreamerOutputModuleCommon::serializeEvent(EventForOutput const& e, Handle const& triggerResults, ParameterSetID const& selectorCfg) { + //Lets Build the Event Message first + + //Following is strictly DUMMY Data for L! Trig and will be replaced with actual + // once figured out, there is no logic involved here. + std::vector l1bit = {true,true,false}; + //End of dummy data + + std::vector hltbits; + setHltMask(e, triggerResults, hltbits); + + uint32 lumi; + if (lumiSectionInterval_ == 0) { + lumi = e.luminosityBlock(); + } else { + + struct timeval now; + struct timezone dummyTZ; + gettimeofday(&now, &dummyTZ); + double timeInSec = static_cast(now.tv_sec) + (static_cast(now.tv_usec)/1000000.0) - timeInSecSinceUTC; + // what about overflows? + if(lumiSectionInterval_ > 0) lumi = static_cast(timeInSec/lumiSectionInterval_) + 1; + } + + if (serializer_.get()==nullptr) getSelections(); + + serializer_->serializeEvent(e, selectorCfg, useCompression_, compressionLevel_, serializeDataBuffer_); + + // resize bufs_ to reflect space used in serializer_ + header + // I just added an overhead for header of 50000 for now + unsigned int src_size = serializeDataBuffer_.currentSpaceUsed(); + unsigned int new_size = src_size + 50000; + if(serializeDataBuffer_.bufs_.size() < new_size) serializeDataBuffer_.bufs_.resize(new_size); + + auto msg = std::make_unique( + &serializeDataBuffer_.bufs_[0], serializeDataBuffer_.bufs_.size(), e.id().run(), + e.id().event(), lumi, outputModuleId_, 0, + l1bit, (uint8*)&hltbits[0], hltsize_, + (uint32)serializeDataBuffer_.adler32_chksum(), host_name_); + msg->setOrigDataSize(origSize_); // we need this set to zero + + // copy data into the destination message + // an alternative is to have serializer only to the serialization + // in serializeEvent, and then call a new member "getEventData" that + // takes the compression arguments and a place to put the data. + // This will require one less copy. The only catch is that the + // space provided in bufs_ should be at least the uncompressed + // size + overhead for header because we will not know the actual + // compressed size. + + unsigned char* src = serializeDataBuffer_.bufferPointer(); + std::copy(src,src + src_size, msg->eventAddr()); + msg->setEventLength(src_size); + if(useCompression_) msg->setOrigDataSize(serializeDataBuffer_.currentEventSize()); + + return msg; + } + + void + StreamerOutputModuleCommon::fillDescription(ParameterSetDescription& desc) { + desc.addUntracked("max_event_size", 7000000) + ->setComment("Starting size in bytes of the serialized event buffer."); + desc.addUntracked("use_compression", true) + ->setComment("If True, compression will be used to write streamer file."); + desc.addUntracked("compression_level", 1) + ->setComment("ROOT compression level to use."); + desc.addUntracked("lumiSection_interval", 0) + ->setComment("If 0, use lumi section number from event.\n" + "If not 0, the interval in seconds between fake lumi sections."); + } +} // end of namespace-edm From e661ffbdfb9e55ddecb169fa5a0510756f6ee6a9 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Mon, 11 Dec 2017 16:13:45 +0100 Subject: [PATCH 474/686] DAQ output module rewrite based on edm::limited::OutputModule. It is registered in the Framework as vFOutputModule. For backwards compatibility and testing/comparison, old module will not (yet) be removed and will be usable using the old macro name (ShmStreamConsumer). --- .../Utilities/interface/EvFOutputModule.h | 49 +++ EventFilter/Utilities/plugins/SealModule.cc | 4 +- EventFilter/Utilities/src/EvFOutputModule.cc | 385 ++++++++++++++++++ 3 files changed, 436 insertions(+), 2 deletions(-) create mode 100644 EventFilter/Utilities/interface/EvFOutputModule.h create mode 100644 EventFilter/Utilities/src/EvFOutputModule.cc diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h new file mode 100644 index 0000000000000..d994224874e52 --- /dev/null +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -0,0 +1,49 @@ +#ifndef EventFilter_Utilities_EvFOutputModule_h +#define EventFilter_Utilities_EvFOutputModule_h + +#include "FWCore/Framework/interface/limited/OutputModule.h" +#include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h" +#include "FWCore/Utilities/interface/EDGetToken.h" + +typedef edm::detail::TriggerResultsBasedEventSelector::handle_t Trig; + +namespace evf { + + class FastMonitoringService; + class EvFOutputEventWriter; + class EvFOutputJSONWriter; + + typedef edm::limited::OutputModule,edm::RunCache> EvFOutputModuleType; + + class EvFOutputModule : + public EvFOutputModuleType + { + public: + explicit EvFOutputModule(edm::ParameterSet const& ps); + ~EvFOutputModule() override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + //pure in parent class but unused here + void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} + void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {} + void writeRun(edm::RunForOutput const&) override {} + + std::shared_ptr globalBeginRun(edm::Run const& run, edm::EventSetup const& setup) const override; + std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const override; + void write(edm::EventForOutput const& e) override; + void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const override; + + Trig getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const; + + edm::ParameterSet const& ps_; + std::string streamLabel_; + edm::EDGetTokenT trToken_; + + evf::FastMonitoringService *fms_; + + }; //end-of-class-def + +} // end of namespace-evf + +#endif diff --git a/EventFilter/Utilities/plugins/SealModule.cc b/EventFilter/Utilities/plugins/SealModule.cc index 7f40a6df7dbc8..ecd02d58374c0 100644 --- a/EventFilter/Utilities/plugins/SealModule.cc +++ b/EventFilter/Utilities/plugins/SealModule.cc @@ -2,6 +2,7 @@ #include "FWCore/ServiceRegistry/interface/ServiceMaker.h" #include "EventFilter/Utilities/interface/EvFDaqDirector.h" #include "EventFilter/Utilities/interface/FastMonitoringService.h" +#include "EventFilter/Utilities/interface/EvFOutputModule.h" #include "EventFilter/Utilities/plugins/ExceptionGenerator.h" #include "EventFilter/Utilities/plugins/EvFBuildingThrottle.h" #include "EventFilter/Utilities/plugins/EvFFEDSelector.h" @@ -20,10 +21,9 @@ using namespace evf; typedef edm::serviceregistry::AllArgsMaker FastMonitoringServiceMaker; typedef RawEventOutputModuleForBU RawStreamFileWriterForBU; -typedef RecoEventOutputModuleForFU EvFOutputModule; +typedef RecoEventOutputModuleForFU ShmStreamConsumer; //legacy name for ConfDB compatibility -typedef EvFOutputModule ShmStreamConsumer; //DEFINE_FWK_SERVICE_MAKER(MicroStateService, MicroStateServiceMaker); diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc new file mode 100644 index 0000000000000..a912363499d83 --- /dev/null +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -0,0 +1,385 @@ +#include "EventFilter/Utilities/interface/EvFOutputModule.h" + +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "EventFilter/Utilities/interface/FastMonitoringService.h" +#include "EventFilter/Utilities/interface/EvFDaqDirector.h" + +#include "EventFilter/Utilities/interface/JsonMonitorable.h" +#include "EventFilter/Utilities/interface/FastMonitor.h" +#include "EventFilter/Utilities/interface/JSONSerializer.h" +#include "EventFilter/Utilities/interface/FileIO.h" +#include "FWCore/Utilities/interface/Adler32Calculator.h" + +#include "FWCore/Framework/interface/EventForOutput.h" +#include "FWCore/Framework/interface/LuminosityBlockForOutput.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" + +#include "IOPool/Streamer/interface/StreamerOutputFile.h" +#include "IOPool/Streamer/interface/InitMsgBuilder.h" +#include "IOPool/Streamer/interface/EventMsgBuilder.h" + +#include +#include +#include + +namespace evf { + + class EvFOutputEventWriter + { + public: + + explicit EvFOutputEventWriter(std::string const& filePath): + filePath_(filePath), + accepted_(0) + { + stream_writer_events_.reset(new StreamerOutputFile(filePath)); + } + + ~EvFOutputEventWriter() { + } + + void reset() { + stream_writer_events_.reset(); + } + + void doOutputEvent(EventMsgBuilder const& msg) { + EventMsgView eview(msg.startAddress()); + stream_writer_events_->write(eview); + } + + uint32 get_adler32() const { + return stream_writer_events_->adler32(); + } + + std::string const& getFilePath() const {return filePath_;} + + unsigned long getAccepted() const {return accepted_;} + void incAccepted() {accepted_++;} + + private: + std::string filePath_; + unsigned long accepted_; + std::shared_ptr stream_writer_events_; + + }; + + class StreamerCommonWrapper:public edm::StreamerOutputModuleCommon { + public: + StreamerCommonWrapper(edm::ParameterSet const& ps, edm::SelectedProducts const* selections): + StreamerOutputModuleCommon(ps) + { + selections_ = selections; + } + + void getSelections() { + serializer_.reset(new edm::StreamSerializer(selections_)); + } + }; + + + class EvFOutputJSONWriter { + public: + EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel): + streamerCommonWrapper_(ps, selections), + processed_(0), + accepted_(0), + errorEvents_(0), + retCodeMask_(0), + filelist_(), + filesize_(0), + inputFiles_(), + fileAdler32_(1), + hltErrorEvents_(0) + { + + transferDestination_ = edm::Service()->getStreamDestinations(streamLabel); + mergeType_ = edm::Service()->getStreamMergeType(streamLabel,evf::MergeTypeDAT); + + std::string baseRunDir = edm::Service()->baseRunDir(); + LogDebug("EvFOutputModule") << "writing .dat files to -: " << baseRunDir; + + edm::Service()->createRunOpendirMaybe(); + + processed_.setName("Processed"); + accepted_.setName("Accepted"); + errorEvents_.setName("ErrorEvents"); + retCodeMask_.setName("ReturnCodeMask"); + filelist_.setName("Filelist"); + filesize_.setName("Filesize"); + inputFiles_.setName("InputFiles"); + fileAdler32_.setName("FileAdler32"); + transferDestination_.setName("TransferDestination"); + mergeType_.setName("MergeType"); + hltErrorEvents_.setName("HLTErrorEvents"); + + outJsonDef_.setDefaultGroup("data"); + outJsonDef_.addLegendItem("Processed","integer",jsoncollector::DataPointDefinition::SUM); + outJsonDef_.addLegendItem("Accepted","integer",jsoncollector::DataPointDefinition::SUM); + outJsonDef_.addLegendItem("ErrorEvents","integer",jsoncollector::DataPointDefinition::SUM); + outJsonDef_.addLegendItem("ReturnCodeMask","integer",jsoncollector::DataPointDefinition::BINARYOR); + outJsonDef_.addLegendItem("Filelist","string",jsoncollector::DataPointDefinition::MERGE); + outJsonDef_.addLegendItem("Filesize","integer",jsoncollector::DataPointDefinition::SUM); + outJsonDef_.addLegendItem("InputFiles","string",jsoncollector::DataPointDefinition::CAT); + outJsonDef_.addLegendItem("FileAdler32","integer",jsoncollector::DataPointDefinition::ADLER32); + outJsonDef_.addLegendItem("TransferDestination","string",jsoncollector::DataPointDefinition::SAME); + outJsonDef_.addLegendItem("MergeType","string",jsoncollector::DataPointDefinition::SAME); + outJsonDef_.addLegendItem("HLTErrorEvents","integer",jsoncollector::DataPointDefinition::SUM); + + std::stringstream tmpss,ss; + tmpss << baseRunDir << "/open/" << "output_" << getpid() << ".jsd"; + ss << baseRunDir << "/" << "output_" << getpid() << ".jsd"; + std::string outTmpJsonDefName = tmpss.str(); + std::string outJsonDefName = ss.str(); + + edm::Service()->lockInitLock(); + struct stat fstat; + if (stat (outJsonDefName.c_str(), &fstat) != 0) { //file does not exist + LogDebug("EvFOutputModule") << "writing output definition file -: " << outJsonDefName; + std::string content; + jsoncollector::JSONSerializer::serialize(&outJsonDef_,content); + jsoncollector::FileIO::writeStringToFile(outTmpJsonDefName, content); + boost::filesystem::rename(outTmpJsonDefName,outJsonDefName); + } + edm::Service()->unlockInitLock(); + + jsonMonitor_.reset(new jsoncollector::FastMonitor(&outJsonDef_,true)); + jsonMonitor_->setDefPath(outJsonDefName); + jsonMonitor_->registerGlobalMonitorable(&processed_,false); + jsonMonitor_->registerGlobalMonitorable(&accepted_,false); + jsonMonitor_->registerGlobalMonitorable(&errorEvents_,false); + jsonMonitor_->registerGlobalMonitorable(&retCodeMask_,false); + jsonMonitor_->registerGlobalMonitorable(&filelist_,false); + jsonMonitor_->registerGlobalMonitorable(&filesize_,false); + jsonMonitor_->registerGlobalMonitorable(&inputFiles_,false); + jsonMonitor_->registerGlobalMonitorable(&fileAdler32_,false); + jsonMonitor_->registerGlobalMonitorable(&transferDestination_,false); + jsonMonitor_->registerGlobalMonitorable(&mergeType_,false); + jsonMonitor_->registerGlobalMonitorable(&hltErrorEvents_,false); + jsonMonitor_->commit(nullptr); + } + + StreamerCommonWrapper streamerCommonWrapper_; + + jsoncollector::IntJ processed_; + jsoncollector::IntJ accepted_; + jsoncollector::IntJ errorEvents_; + jsoncollector::IntJ retCodeMask_; + jsoncollector::StringJ filelist_; + jsoncollector::IntJ filesize_; + jsoncollector::StringJ inputFiles_; + jsoncollector::IntJ fileAdler32_; + jsoncollector::StringJ transferDestination_; + jsoncollector::StringJ mergeType_; + jsoncollector::IntJ hltErrorEvents_; + std::shared_ptr jsonMonitor_; + jsoncollector::DataPointDefinition outJsonDef_; + + }; + + EvFOutputModule::EvFOutputModule(edm::ParameterSet const& ps) : + edm::limited::OutputModuleBase(ps), + EvFOutputModuleType(ps), + ps_(ps), + streamLabel_(ps.getParameter("@module_label")), + trToken_(consumes(edm::InputTag("TriggerResults"))) + { + unsigned int concurrencyLimit = ps.getUntrackedParameter("concurrencyLimit"); + if (concurrencyLimit!=1) { + throw cms::Exception("EvFOutputModule") + << "Concurrency limit " << concurrencyLimit << " detected. Parameter values other than 1 are not supported by this output module"; + } + //replace hltOutoputA with stream if the HLT menu uses this convention + std::string testPrefix="hltOutput"; + if (streamLabel_.find(testPrefix)==0) + streamLabel_=std::string("stream")+streamLabel_.substr(testPrefix.size()); + + if (streamLabel_.find("_")!=std::string::npos) { + throw cms::Exception("EvFOutputModule") + << "Underscore character is reserved can not be used for stream names in FFF, but was detected in stream name -: " << streamLabel_; + } + + std::string streamLabelLow = streamLabel_; + boost::algorithm::to_lower(streamLabelLow); + auto streampos = streamLabelLow.rfind("stream"); + if (streampos !=0 && streampos!=std::string::npos) + throw cms::Exception("EvFOutputModule") + << "stream (case-insensitive) sequence was found in stream suffix. This is reserved and can not be used for names in FFF based HLT, but was detected in stream name"; + + fms_ = (evf::FastMonitoringService *)(edm::Service().operator->()); + } + + + EvFOutputModule::~EvFOutputModule() {} + + + void EvFOutputModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + edm::StreamerOutputModuleCommon::fillDescription(desc); + EvFOutputModuleType::fillDescription(desc); + + // Use addDefault here instead of add for 4 reasons: + // 1. Because EvFOutputModule_cfi.py is explicitly defined it does not need to be autogenerated + // The explicitly defined version overrides the autogenerated version of the cfi file. + // 2. That cfi file is not used anywhere in the release anyway + // 3. There are two plugin names used for the same template instantiation of this + // type, "ShmStreamConsumer" and "EvFOutputModule" and this causes name conflict + // problems for the cfi generation code which are avoided with addDefault. + // 4. At the present time, there is only one type of Consumer used to instantiate + // instances of this template, but if there were more than one type then this function + // would need to be specialized for each type unless the descriptions were the same + // and addDefault was used. + descriptions.addDefault(desc); + } + + + std::shared_ptr + EvFOutputModule::globalBeginRun(edm::Run const& run, edm::EventSetup const& setup) const + { + //create run Cache holding JSON file writer and variables + auto rc = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); + + //output INI file (non-const). This doesn't require globalBeginRun to be finished + const std::string openIniFileName = edm::Service()->getOpenInitFilePath(streamLabel_); + edm::LogInfo("EvFOutputModule") << "beginRun init stream -: " << openIniFileName; + + std::shared_ptr stream_writer_preamble; + stream_writer_preamble.reset(new StreamerOutputFile(openIniFileName)); + uint32 preamble_adler32 = 1; + + edm::BranchIDLists const* bidlPtr; + std::unique_ptr branchIDListsCopyTmp; + if (!droppedBranchIDToKeptBranchID().empty()) { + //copy unique_ptr will lose scope when beginRun returns + branchIDListsCopyTmp = branchIDListsCopy(); + bidlPtr = branchIDListsCopyTmp.get(); + } + else { + //get pointer to original + bidlPtr = branchIDListsOrig(); + } + std::unique_ptr init_message = + rc->streamerCommonWrapper_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), + OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID()); + + //Let us turn it into a View + InitMsgView view(init_message->startAddress()); + + //output header + stream_writer_preamble->write(view); + preamble_adler32 = stream_writer_preamble->adler32(); + stream_writer_preamble.reset(); + + struct stat istat; + stat(openIniFileName.c_str(), &istat); + //read back file to check integrity of what was written + off_t readInput=0; + uint32_t adlera=1,adlerb=0; + FILE *src = fopen(openIniFileName.c_str(),"r"); + + //allocate buffer to write INI file + unsigned char * outBuf = new unsigned char[1024*1024]; + while (readInputstreamerCommonWrapper_.clearSerializeDataBuffer(); + + //free output buffer needed only for the file write + delete [] outBuf; + outBuf=nullptr; + + uint32_t adler32c = (adlerb << 16) | adlera; + if (adler32c != preamble_adler32) { + throw cms::Exception("EvFOutputModule") << "Checksum mismatch of ini file -: " << openIniFileName + << " expected:" << preamble_adler32 << " obtained:" << adler32c; + } + else { + LogDebug("EvFOutputModule") << "Ini file checksum -: "<< streamLabel_ << " " << adler32c; + boost::filesystem::rename(openIniFileName,edm::Service()->getInitFilePath(streamLabel_)); + } + + return rc; + } + + + Trig + EvFOutputModule::getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const { + Trig result; + e.getByToken(token, result); + return result; + } + + + std::shared_ptr + EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const + { + auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(),streamLabel_); + auto lumiWriter = std::make_shared(openDatFilePath); + return lumiWriter; + } + + + void + EvFOutputModule::write(edm::EventForOutput const& e) { + + edm::Handle const& triggerResults = getTriggerResults(trToken_, e); + //use invalid index as this parameter is anyway ignored by the cache getter function + auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); + std::unique_ptr msg = rc->streamerCommonWrapper_.serializeEvent(e, triggerResults, selectorConfig()); + + auto lumiWriter = const_cast(luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex())); + lumiWriter->incAccepted(); + lumiWriter->doOutputEvent(*msg); //msg is written and discarded at this point + } + + + void + EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const + { + //edm::LogInfo("EvFOutputModule") << "end lumi"; + auto lumiWriter = luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex()); + auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); + + rc->fileAdler32_.value() = lumiWriter->get_adler32(); + const_cast(lumiWriter)->reset(); + + bool abortFlag = false; + rc->processed_.value() = fms_->getEventsProcessedForLumi(iLB.luminosityBlock(),&abortFlag); + rc->accepted_.value() = lumiWriter->getAccepted(); + if (abortFlag) { + edm::LogInfo("EvFOutputModule") << "Abort flag has been set. Output is suppressed"; + return; + } + + if(rc->processed_.value()!=0) { + struct stat istat; + boost::filesystem::path openDatFilePath = lumiWriter->getFilePath(); + stat(openDatFilePath.string().c_str(), &istat); + rc->filesize_ = istat.st_size; + boost::filesystem::rename(openDatFilePath.string().c_str(), edm::Service()->getDatFilePath(iLB.luminosityBlock(),streamLabel_)); + rc->filelist_ = openDatFilePath.filename().string(); + } else { + //remove empty file when no event processing has occurred + remove(lumiWriter->getFilePath().c_str()); + rc->filesize_ = 0; + rc->filelist_ = ""; + rc->fileAdler32_.value()=-1; //no files in signed long + } + + //produce JSON file + rc->jsonMonitor_->snap(iLB.luminosityBlock()); + const std::string outputJsonNameStream = + edm::Service()->getOutputJsonFilePath(iLB.luminosityBlock(),streamLabel_); + rc->jsonMonitor_->outputFullJSON(outputJsonNameStream,iLB.luminosityBlock()); + } + +} // end of namespace-evf + From 43b066a2349a09e14aa159aad63d03952835eb60 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Mon, 11 Dec 2017 16:16:14 +0100 Subject: [PATCH 475/686] updated test scripts Conflicts: EventFilter/Utilities/test/startFU.py --- EventFilter/Utilities/test/startBU.py | 20 +++++++++++--- EventFilter/Utilities/test/startFU.py | 40 +++++++++++++-------------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/EventFilter/Utilities/test/startBU.py b/EventFilter/Utilities/test/startBU.py index 1a897585fc628..cd210d14255f7 100644 --- a/EventFilter/Utilities/test/startBU.py +++ b/EventFilter/Utilities/test/startBU.py @@ -16,13 +16,25 @@ "Run Number") options.register ('buBaseDir', - '/fff/BU0/ramdisk/', # default value + 'ramdisk/', # default value VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, # string, int, or float "BU base directory") +options.register ('fffBaseDir', + '.', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "FFF base directory") + options.parseArguments() +#try to create 'ramdisk' directory +try: + os.makedirs(options.fffBaseDir+"/"+options.buBaseDir) +except:pass + + cmsswbase = os.path.expandvars("$CMSSW_BASE/") process = cms.Process("FAKEBU") @@ -49,14 +61,14 @@ process.source = cms.Source("EmptySource", firstRun= cms.untracked.uint32(options.runNumber), - numberEventsInLuminosityBlock = cms.untracked.uint32(200), + numberEventsInLuminosityBlock = cms.untracked.uint32(5), numberEventsInRun = cms.untracked.uint32(0) ) process.EvFDaqDirector = cms.Service("EvFDaqDirector", runNumber = cms.untracked.uint32(options.runNumber), - baseDir = cms.untracked.string(options.buBaseDir), - buBaseDir = cms.untracked.string(options.buBaseDir), + baseDir = cms.untracked.string(options.fffBaseDir+"/"+options.buBaseDir), + buBaseDir = cms.untracked.string(options.fffBaseDir+"/"+options.buBaseDir), directorIsBu = cms.untracked.bool(True), copyRunDir = cms.untracked.bool(False)) #obsolete: diff --git a/EventFilter/Utilities/test/startFU.py b/EventFilter/Utilities/test/startFU.py index 2d936fa72930c..9f473addb826e 100644 --- a/EventFilter/Utilities/test/startFU.py +++ b/EventFilter/Utilities/test/startFU.py @@ -12,24 +12,38 @@ "Run Number") options.register ('buBaseDir', - '/fff/BU0/ramdisk', # default value + 'ramdisk', # default value VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, # string, int, or float "BU base directory") options.register ('fuBaseDir', - '/fff/data', # default value + 'data', # default value VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, # string, int, or float "BU base directory") +options.register ('fffBaseDir', + '.', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "FFF base directory") + + options.register ('numThreads', - 1, # default value + 2, # default value VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, # string, int, or float "Number of CMSSW threads") +options.register ('numFwkStreams', + 2, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of CMSSW streams") + + options.parseArguments() cmsswbase = os.path.expandvars("$CMSSW_BASE/") @@ -41,7 +55,7 @@ process.options = cms.untracked.PSet( numberOfThreads = cms.untracked.uint32(options.numThreads), - numberOfStreams = cms.untracked.uint32(options.numThreads), + numberOfStreams = cms.untracked.uint32(options.numThreads) ) process.MessageLogger = cms.Service("MessageLogger", cout = cms.untracked.PSet(threshold = cms.untracked.string( "INFO" )), @@ -58,8 +72,8 @@ useFileService = cms.untracked.bool(False), fileServiceHost = cms.untracked.string("htcp40.cern.ch"), runNumber = cms.untracked.uint32(options.runNumber), - baseDir = cms.untracked.string(options.fuBaseDir), - buBaseDir = cms.untracked.string(options.buBaseDir), + baseDir = cms.untracked.string(options.fffBaseDir +"/"+options.fuBaseDir), + buBaseDir = cms.untracked.string(options.fffBaseDir+"/"+options.buBaseDir), directorIsBu = cms.untracked.bool(False), testModeNoBuilderUnit = cms.untracked.bool(False)) @@ -69,20 +83,6 @@ print(str(ex)) pass -process.PrescaleService = cms.Service( "PrescaleService", - lvl1DefaultLabel = cms.string( "B" ), - lvl1Labels = cms.vstring( 'A', - 'B' - ), - prescaleTable = cms.VPSet( - cms.PSet( pathName = cms.string( "p1" ), - prescales = cms.vuint32( 0, 10) - ), - cms.PSet( pathName = cms.string( "p2" ), - prescales = cms.vuint32( 0, 100) - ) - )) - process.source = cms.Source("FedRawDataInputSource", runNumber = cms.untracked.uint32(options.runNumber), getLSFromFilename = cms.untracked.bool(True), From 698f4d71f76982f2b7acc91c14b6a843780ff59b Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Wed, 13 Feb 2019 13:26:18 +0100 Subject: [PATCH 476/686] branchListIDs is now const, can be used in the OutputModule --- EventFilter/Utilities/src/EvFOutputModule.cc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index a912363499d83..878f3bd6002a7 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -247,18 +247,8 @@ namespace evf { std::shared_ptr stream_writer_preamble; stream_writer_preamble.reset(new StreamerOutputFile(openIniFileName)); uint32 preamble_adler32 = 1; + edm::BranchIDLists const* bidlPtr = branchIDLists(); - edm::BranchIDLists const* bidlPtr; - std::unique_ptr branchIDListsCopyTmp; - if (!droppedBranchIDToKeptBranchID().empty()) { - //copy unique_ptr will lose scope when beginRun returns - branchIDListsCopyTmp = branchIDListsCopy(); - bidlPtr = branchIDListsCopyTmp.get(); - } - else { - //get pointer to original - bidlPtr = branchIDListsOrig(); - } std::unique_ptr init_message = rc->streamerCommonWrapper_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID()); From d44adeb9ce87f38b5fdf93b7cf4b82d4fc5ce9c6 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Wed, 13 Feb 2019 14:01:49 +0100 Subject: [PATCH 477/686] ForOutput LB and Run can now be used in EvFOutputModule --- EventFilter/Utilities/interface/EvFOutputModule.h | 11 ++++++----- EventFilter/Utilities/src/EvFOutputModule.cc | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h index d994224874e52..eaa997f1cc688 100644 --- a/EventFilter/Utilities/interface/EvFOutputModule.h +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -24,15 +24,16 @@ namespace evf { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: + void write(edm::EventForOutput const& e) override; + //pure in parent class but unused here void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} - void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {} void writeRun(edm::RunForOutput const&) override {} + void globalEndRun(edm::RunForOutput const&) const override {} - std::shared_ptr globalBeginRun(edm::Run const& run, edm::EventSetup const& setup) const override; - std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const override; - void write(edm::EventForOutput const& e) override; - void globalEndLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const override; + std::shared_ptr globalBeginRun(edm::RunForOutput const& run) const override; + std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const override; + void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const override; Trig getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const; diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index 878f3bd6002a7..d5867ef2ae628 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -235,7 +235,7 @@ namespace evf { std::shared_ptr - EvFOutputModule::globalBeginRun(edm::Run const& run, edm::EventSetup const& setup) const + EvFOutputModule::globalBeginRun(edm::RunForOutput const& run, edm::EventSetup const& setup) const { //create run Cache holding JSON file writer and variables auto rc = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); @@ -309,7 +309,7 @@ namespace evf { std::shared_ptr - EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const + EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB, edm::EventSetup const&) const { auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(),streamLabel_); auto lumiWriter = std::make_shared(openDatFilePath); @@ -332,7 +332,7 @@ namespace evf { void - EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlock const& iLB, edm::EventSetup const&) const + EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const { //edm::LogInfo("EvFOutputModule") << "end lumi"; auto lumiWriter = luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex()); From 547dfb05cd78de8633fd6eb569d92aa8d3aaeb52 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Wed, 13 Feb 2019 15:33:20 +0100 Subject: [PATCH 478/686] trying to get rid of getSelections call and populate info at creation of the call. There is also possibility to inherit Common by EvFOutputModule, but serializer calls will then have to be const-friendly (i.e there is need to initialize several variables earlier). --- EventFilter/Utilities/src/EvFOutputModule.cc | 23 ++++--------------- .../interface/StreamerOutputModuleBase.h | 2 -- .../interface/StreamerOutputModuleCommon.h | 4 ++-- .../Streamer/src/StreamerOutputModuleBase.cc | 11 ++++----- .../src/StreamerOutputModuleCommon.cc | 16 ++++--------- 5 files changed, 15 insertions(+), 41 deletions(-) diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index d5867ef2ae628..8867e061f884c 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -65,24 +65,11 @@ namespace evf { }; - class StreamerCommonWrapper:public edm::StreamerOutputModuleCommon { - public: - StreamerCommonWrapper(edm::ParameterSet const& ps, edm::SelectedProducts const* selections): - StreamerOutputModuleCommon(ps) - { - selections_ = selections; - } - - void getSelections() { - serializer_.reset(new edm::StreamSerializer(selections_)); - } - }; - class EvFOutputJSONWriter { public: EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel): - streamerCommonWrapper_(ps, selections), + streamerCommon_(ps, selections), processed_(0), accepted_(0), errorEvents_(0), @@ -160,7 +147,7 @@ namespace evf { jsonMonitor_->commit(nullptr); } - StreamerCommonWrapper streamerCommonWrapper_; + StreamerOutputModuleCommon streamerCommon_; jsoncollector::IntJ processed_; jsoncollector::IntJ accepted_; @@ -250,7 +237,7 @@ namespace evf { edm::BranchIDLists const* bidlPtr = branchIDLists(); std::unique_ptr init_message = - rc->streamerCommonWrapper_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), + rc->streamerCommon_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID()); //Let us turn it into a View @@ -280,7 +267,7 @@ namespace evf { fclose(src); //clear serialization buffers - rc->streamerCommonWrapper_.clearSerializeDataBuffer(); + rc->streamerCommon_.clearSerializeDataBuffer(); //free output buffer needed only for the file write delete [] outBuf; @@ -323,7 +310,7 @@ namespace evf { edm::Handle const& triggerResults = getTriggerResults(trToken_, e); //use invalid index as this parameter is anyway ignored by the cache getter function auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); - std::unique_ptr msg = rc->streamerCommonWrapper_.serializeEvent(e, triggerResults, selectorConfig()); + std::unique_ptr msg = rc->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); auto lumiWriter = const_cast(luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex())); lumiWriter->incAccepted(); diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index 98f206de2628e..26fda3ac4a267 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -39,8 +39,6 @@ namespace edm { Trig getTriggerResults(EDGetTokenT const& token, EventForOutput const& e) const; - virtual void getSelections() override; - private: edm::EDGetTokenT trToken_; diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h index c98993902ed70..4321483d0a5e8 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -19,7 +19,7 @@ namespace edm { class StreamerOutputModuleCommon { public: - explicit StreamerOutputModuleCommon(ParameterSet const& ps); + explicit StreamerOutputModuleCommon(ParameterSet const& ps, SelectedProducts const* selections) : ~StreamerOutputModuleCommon(); static void fillDescription(ParameterSetDescription & desc); @@ -39,7 +39,7 @@ namespace edm { } protected: - virtual void getSelections() = 0; + //virtual void getSelections() = 0; SelectedProducts const* selections_; std::unique_ptr serializer_; diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 2bcb27cf1473a..940f1710e4b3b 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -16,17 +16,14 @@ namespace edm { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : one::OutputModuleBase::OutputModuleBase(ps), one::OutputModule(ps), - StreamerOutputModuleCommon(ps), - trToken_(consumes(edm::InputTag("TriggerResults"))) { + StreamerOutputModuleCommon(ps,&keptProducts()[InEvent]), + trToken_(consumes(edm::InputTag("TriggerResults"))), + selections_(&keptProducts()[InEvent]), + serializer_(selections_) { } StreamerOutputModuleBase::~StreamerOutputModuleBase() {} - void StreamerOutputModuleBase::getSelections() { - selections_ = &keptProducts()[InEvent]; - serializer_.reset(new StreamSerializer(selections_)); - } - void StreamerOutputModuleBase::beginRun(RunForOutput const&) { start(); diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc index ed3480c14584e..0110a7f2951c5 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -23,7 +23,10 @@ #include namespace edm { - StreamerOutputModuleCommon::StreamerOutputModuleCommon(ParameterSet const& ps) : + StreamerOutputModuleCommon::StreamerOutputModuleCommon(ParameterSet const& ps, SelectedProducts const* selections) : + + selections_(selections), + serializer_(selections_), maxEventSize_(ps.getUntrackedParameter("max_event_size")), useCompression_(ps.getUntrackedParameter("use_compression")), compressionLevel_(ps.getUntrackedParameter("compression_level")), @@ -36,13 +39,6 @@ namespace edm { outputModuleId_(0) { // no compression as default value - we need this! - //inheriting class must implement getSelections method to retrieve selection from base output module - //::getSelections { - // selections_(&keptProducts()[InEvent]), - // serializer_(selections_), - // selectionsInitialized_=true; - //} - // test luminosity sections struct timeval now; struct timezone dummyTZ; @@ -82,8 +78,6 @@ namespace edm { ParameterSetID const& toplevel) { - if (serializer_.get()==nullptr) getSelections(); - serializer_->serializeRegistry(serializeDataBuffer_, branchLists, helper); // resize bufs_ to reflect space used in serializer_ + header @@ -200,8 +194,6 @@ namespace edm { if(lumiSectionInterval_ > 0) lumi = static_cast(timeInSec/lumiSectionInterval_) + 1; } - if (serializer_.get()==nullptr) getSelections(); - serializer_->serializeEvent(e, selectorCfg, useCompression_, compressionLevel_, serializeDataBuffer_); // resize bufs_ to reflect space used in serializer_ + header From 136564dc88519270bbd2e3ef26ce68fb62fd01d1 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Thu, 14 Feb 2019 16:36:46 +0100 Subject: [PATCH 479/686] - Added support for CMSSW_10_5_X - StreamerOutputModuleCommon no longer needs getSelections. serializer is initialized at construction. - updated test scripts --- EventFilter/Utilities/interface/EvFOutputModule.h | 2 +- EventFilter/Utilities/src/EvFOutputModule.cc | 15 +++++++-------- EventFilter/Utilities/test/startBU.py | 7 ++----- EventFilter/Utilities/test/startFU.py | 14 ++++++++++++-- .../interface/StreamerOutputModuleCommon.h | 10 +++------- IOPool/Streamer/src/StreamerOutputModuleBase.cc | 6 ++---- IOPool/Streamer/src/StreamerOutputModuleCommon.cc | 7 +++---- 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h index eaa997f1cc688..c2f24eebdeba7 100644 --- a/EventFilter/Utilities/interface/EvFOutputModule.h +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -13,7 +13,7 @@ namespace evf { class EvFOutputEventWriter; class EvFOutputJSONWriter; - typedef edm::limited::OutputModule,edm::RunCache> EvFOutputModuleType; + typedef edm::limited::OutputModule,edm::LuminosityBlockCache> EvFOutputModuleType; class EvFOutputModule : public EvFOutputModuleType diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index 8867e061f884c..096e0f6137bd9 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -147,7 +147,7 @@ namespace evf { jsonMonitor_->commit(nullptr); } - StreamerOutputModuleCommon streamerCommon_; + edm::StreamerOutputModuleCommon streamerCommon_; jsoncollector::IntJ processed_; jsoncollector::IntJ accepted_; @@ -222,7 +222,7 @@ namespace evf { std::shared_ptr - EvFOutputModule::globalBeginRun(edm::RunForOutput const& run, edm::EventSetup const& setup) const + EvFOutputModule::globalBeginRun(edm::RunForOutput const& run) const { //create run Cache holding JSON file writer and variables auto rc = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); @@ -296,7 +296,7 @@ namespace evf { std::shared_ptr - EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB, edm::EventSetup const&) const + EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const { auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(),streamLabel_); auto lumiWriter = std::make_shared(openDatFilePath); @@ -308,11 +308,10 @@ namespace evf { EvFOutputModule::write(edm::EventForOutput const& e) { edm::Handle const& triggerResults = getTriggerResults(trToken_, e); - //use invalid index as this parameter is anyway ignored by the cache getter function + //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by e.getRun() auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); std::unique_ptr msg = rc->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); - - auto lumiWriter = const_cast(luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex())); + auto lumiWriter = const_cast(luminosityBlockCache(e.getLuminosityBlock().index() )); lumiWriter->incAccepted(); lumiWriter->doOutputEvent(*msg); //msg is written and discarded at this point } @@ -321,8 +320,8 @@ namespace evf { void EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const { - //edm::LogInfo("EvFOutputModule") << "end lumi"; - auto lumiWriter = luminosityBlockCache(edm::LuminosityBlockIndex::invalidLuminosityBlockIndex()); + auto lumiWriter = luminosityBlockCache(iLB.index()); + //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by iLB.getRun() auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); rc->fileAdler32_.value() = lumiWriter->get_adler32(); diff --git a/EventFilter/Utilities/test/startBU.py b/EventFilter/Utilities/test/startBU.py index cd210d14255f7..d8c74f838e8ec 100644 --- a/EventFilter/Utilities/test/startBU.py +++ b/EventFilter/Utilities/test/startBU.py @@ -43,9 +43,6 @@ ) process.options = cms.untracked.PSet( - multiProcesses = cms.untracked.PSet( - maxChildProcesses = cms.untracked.int32(0) - ) ) process.MessageLogger = cms.Service("MessageLogger", @@ -61,7 +58,7 @@ process.source = cms.Source("EmptySource", firstRun= cms.untracked.uint32(options.runNumber), - numberEventsInLuminosityBlock = cms.untracked.uint32(5), + numberEventsInLuminosityBlock = cms.untracked.uint32(105), numberEventsInRun = cms.untracked.uint32(0) ) @@ -94,7 +91,7 @@ process.out = cms.OutputModule("RawStreamFileWriterForBU", ProductLabel = cms.untracked.string("s"), numWriters = cms.untracked.uint32(1), - eventBufferSize = cms.untracked.uint32(100), + eventBufferSize = cms.untracked.uint32(105), numEventsPerFile= cms.untracked.uint32(20), jsonDefLocation = cms.untracked.string(cmsswbase+"/src/EventFilter/Utilities/plugins/budef.jsd"), jsonEoLDefLocation = cms.untracked.string(cmsswbase+"/src/EventFilter/Utilities/plugins/eols.jsd"), diff --git a/EventFilter/Utilities/test/startFU.py b/EventFilter/Utilities/test/startFU.py index 9f473addb826e..e4de28127c9ee 100644 --- a/EventFilter/Utilities/test/startFU.py +++ b/EventFilter/Utilities/test/startFU.py @@ -55,7 +55,7 @@ process.options = cms.untracked.PSet( numberOfThreads = cms.untracked.uint32(options.numThreads), - numberOfStreams = cms.untracked.uint32(options.numThreads) + numberOfStreams = cms.untracked.uint32(options.numFwkStreams) ) process.MessageLogger = cms.Service("MessageLogger", cout = cms.untracked.PSet(threshold = cms.untracked.string( "INFO" )), @@ -135,4 +135,14 @@ SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p2' )) ) -process.ep = cms.EndPath(process.streamA+process.streamB) +process.streamC = cms.OutputModule("ShmStreamConsumer", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p2' )) +) + +#process.streamD = cms.OutputModule("EventStreamFileWriter", +# SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p2' )) +#) + +process.ep = cms.EndPath(process.streamA+process.streamB+process.streamC + #+process.streamD +) diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h index 4321483d0a5e8..a972a3f39f266 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -19,7 +19,7 @@ namespace edm { class StreamerOutputModuleCommon { public: - explicit StreamerOutputModuleCommon(ParameterSet const& ps, SelectedProducts const* selections) : + explicit StreamerOutputModuleCommon(ParameterSet const& ps, SelectedProducts const* selections); ~StreamerOutputModuleCommon(); static void fillDescription(ParameterSetDescription & desc); @@ -38,15 +38,11 @@ namespace edm { serializeDataBuffer_.header_buf_.shrink_to_fit(); } - protected: - //virtual void getSelections() = 0; - - SelectedProducts const* selections_; - std::unique_ptr serializer_; - private: void setHltMask(EventForOutput const& e, Handle const& triggerResults, std::vector& hltbits) const; + StreamSerializer serializer_; + int maxEventSize_; bool useCompression_; int compressionLevel_; diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 940f1710e4b3b..8ea401026871d 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -17,10 +17,8 @@ namespace edm { one::OutputModuleBase::OutputModuleBase(ps), one::OutputModule(ps), StreamerOutputModuleCommon(ps,&keptProducts()[InEvent]), - trToken_(consumes(edm::InputTag("TriggerResults"))), - selections_(&keptProducts()[InEvent]), - serializer_(selections_) { - } + trToken_(consumes(edm::InputTag("TriggerResults"))) + {} StreamerOutputModuleBase::~StreamerOutputModuleBase() {} diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc index 0110a7f2951c5..b285640ddaf3b 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -25,8 +25,7 @@ namespace edm { StreamerOutputModuleCommon::StreamerOutputModuleCommon(ParameterSet const& ps, SelectedProducts const* selections) : - selections_(selections), - serializer_(selections_), + serializer_(selections), maxEventSize_(ps.getUntrackedParameter("max_event_size")), useCompression_(ps.getUntrackedParameter("use_compression")), compressionLevel_(ps.getUntrackedParameter("compression_level")), @@ -78,7 +77,7 @@ namespace edm { ParameterSetID const& toplevel) { - serializer_->serializeRegistry(serializeDataBuffer_, branchLists, helper); + serializer_.serializeRegistry(serializeDataBuffer_, branchLists, helper); // resize bufs_ to reflect space used in serializer_ + header // I just added an overhead for header of 50000 for now @@ -194,7 +193,7 @@ namespace edm { if(lumiSectionInterval_ > 0) lumi = static_cast(timeInSec/lumiSectionInterval_) + 1; } - serializer_->serializeEvent(e, selectorCfg, useCompression_, compressionLevel_, serializeDataBuffer_); + serializer_.serializeEvent(e, selectorCfg, useCompression_, compressionLevel_, serializeDataBuffer_); // resize bufs_ to reflect space used in serializer_ + header // I just added an overhead for header of 50000 for now From 10a71fb1f49889a9b1153adcf11d733f8c5986fa Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Fri, 15 Feb 2019 17:00:04 +0100 Subject: [PATCH 480/686] -protect constness of shared_ptr which would be undetected without stripping const in write and global EoL -propagate and use ofstream close to close streamer data file in the output module --- EventFilter/Utilities/src/EvFOutputModule.cc | 18 ++++++++++-------- IOPool/Streamer/interface/StreamSerializer.h | 2 +- IOPool/Streamer/interface/StreamerFileIO.h | 1 + IOPool/Streamer/interface/StreamerOutputFile.h | 2 ++ IOPool/Streamer/src/StreamSerializer.cc | 2 +- IOPool/Streamer/src/StreamerFileIO.cc | 4 ++++ 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index 096e0f6137bd9..d525fa04b406b 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -32,16 +32,16 @@ namespace evf { explicit EvFOutputEventWriter(std::string const& filePath): filePath_(filePath), - accepted_(0) + accepted_(0), + stream_writer_events_(new StreamerOutputFile(filePath)) { - stream_writer_events_.reset(new StreamerOutputFile(filePath)); } ~EvFOutputEventWriter() { } - void reset() { - stream_writer_events_.reset(); + void close() { + stream_writer_events_->close(); } void doOutputEvent(EventMsgBuilder const& msg) { @@ -61,7 +61,7 @@ namespace evf { private: std::string filePath_; unsigned long accepted_; - std::shared_ptr stream_writer_events_; + edm::propagate_const> stream_writer_events_; }; @@ -308,10 +308,12 @@ namespace evf { EvFOutputModule::write(edm::EventForOutput const& e) { edm::Handle const& triggerResults = getTriggerResults(trToken_, e); + //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by e.getRun() auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); - std::unique_ptr msg = rc->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); auto lumiWriter = const_cast(luminosityBlockCache(e.getLuminosityBlock().index() )); + + std::unique_ptr msg = rc->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); lumiWriter->incAccepted(); lumiWriter->doOutputEvent(*msg); //msg is written and discarded at this point } @@ -320,12 +322,12 @@ namespace evf { void EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const { - auto lumiWriter = luminosityBlockCache(iLB.index()); //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by iLB.getRun() auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); + auto lumiWriter = luminosityBlockCache(iLB.index()); rc->fileAdler32_.value() = lumiWriter->get_adler32(); - const_cast(lumiWriter)->reset(); + const_cast(lumiWriter)->close(); bool abortFlag = false; rc->processed_.value() = fms_->getEventsProcessedForLumi(iLB.luminosityBlock(),&abortFlag); diff --git a/IOPool/Streamer/interface/StreamSerializer.h b/IOPool/Streamer/interface/StreamSerializer.h index bb0491c3dc67f..e486c64f5d1f5 100644 --- a/IOPool/Streamer/interface/StreamSerializer.h +++ b/IOPool/Streamer/interface/StreamSerializer.h @@ -78,7 +78,7 @@ namespace edm int serializeEvent(EventForOutput const& event, ParameterSetID const& selectorConfig, bool use_compression, int compression_level, - SerializeDataBuffer &data_buffer); + SerializeDataBuffer &data_buffer) const; /** * Compresses the data in the specified input buffer into the diff --git a/IOPool/Streamer/interface/StreamerFileIO.h b/IOPool/Streamer/interface/StreamerFileIO.h index f0306cdce7596..161f6e6f56b85 100644 --- a/IOPool/Streamer/interface/StreamerFileIO.h +++ b/IOPool/Streamer/interface/StreamerFileIO.h @@ -34,6 +34,7 @@ class OutputFile void set_do_adler(bool v) { do_adler_ = v; } void set_current_offset(uint64 v) { current_offset_ = v; } + void close(); private: uint64 current_offset_; /** Location of current ioptr */ diff --git a/IOPool/Streamer/interface/StreamerOutputFile.h b/IOPool/Streamer/interface/StreamerOutputFile.h index 4b2f8271f9a26..144c3ec3bf79f 100644 --- a/IOPool/Streamer/interface/StreamerOutputFile.h +++ b/IOPool/Streamer/interface/StreamerOutputFile.h @@ -56,6 +56,8 @@ class StreamerOutputFile uint32 adler32() const { return streamerfile_->adler32(); } + void close() { streamerfile_->close(); } + private: void writeEventHeader(const EventMsgView& ineview); void writeStart(const InitMsgView& inview); diff --git a/IOPool/Streamer/src/StreamSerializer.cc b/IOPool/Streamer/src/StreamSerializer.cc index 3ae127df29072..655cd28f1deca 100644 --- a/IOPool/Streamer/src/StreamSerializer.cc +++ b/IOPool/Streamer/src/StreamSerializer.cc @@ -128,7 +128,7 @@ namespace edm { int StreamSerializer::serializeEvent(EventForOutput const& event, ParameterSetID const& selectorConfig, bool use_compression, int compression_level, - SerializeDataBuffer& data_buffer) { + SerializeDataBuffer& data_buffer) const { EventSelectionIDVector selectionIDs = event.eventSelectionIDs(); selectionIDs.push_back(selectorConfig); diff --git a/IOPool/Streamer/src/StreamerFileIO.cc b/IOPool/Streamer/src/StreamerFileIO.cc index 6bd5fa766c75c..0a9d0af78c8b2 100644 --- a/IOPool/Streamer/src/StreamerFileIO.cc +++ b/IOPool/Streamer/src/StreamerFileIO.cc @@ -36,3 +36,7 @@ return true; } + void OutputFile::close() + { + ost_->close(); + } From 90f531b072b84f3ac2cdac59dbe2011d2bdff9d0 Mon Sep 17 00:00:00 2001 From: Sebastian Wozniewski Date: Fri, 5 Apr 2019 15:32:22 +0200 Subject: [PATCH 481/686] fix fillDescr config of PFRecoTauChargedHadronProducer --- .../Configuration/python/RecoPFTauTag_cff.py | 2 +- .../plugins/PFRecoTauChargedHadronProducer.cc | 93 +++++++++++-------- ... => PFRecoTauChargedHadronProducer_cff.py} | 6 +- 3 files changed, 60 insertions(+), 41 deletions(-) rename RecoTauTag/RecoTau/python/{PFRecoTauChargedHadronProducer_cfi.py => PFRecoTauChargedHadronProducer_cff.py} (83%) diff --git a/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py b/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py index c6efb918c36ab..fafe8bf5050bd 100644 --- a/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py +++ b/RecoTauTag/Configuration/python/RecoPFTauTag_cff.py @@ -34,7 +34,7 @@ ak4PFJetsLegacyHPSPiZeros.jetSrc = PFRecoTauPFJetInputs.inputJetCollection # import charged hadrons -from RecoTauTag.RecoTau.PFRecoTauChargedHadronProducer_cfi import ak4PFJetsRecoTauChargedHadrons +from RecoTauTag.RecoTau.PFRecoTauChargedHadronProducer_cff import ak4PFJetsRecoTauChargedHadrons ak4PFJetsRecoTauChargedHadrons = ak4PFJetsRecoTauChargedHadrons.clone() #------------------------------------------------------------------------------- diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 521a4c63eb0cf..f42d15fb5f959 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -321,13 +321,23 @@ PFRecoTauChargedHadronProducer::fillDescriptions(edm::ConfigurationDescriptions& // ak4PFJetsRecoTauChargedHadrons edm::ParameterSetDescription desc; { - edm::ParameterSetDescription vpsd_ranking; - vpsd_ranking.add("selectionPassFunction", "-pt"); - vpsd_ranking.add("selectionFailValue", 1000.0); - vpsd_ranking.add("selection", "algoIs(\"kChargedPFCandidate\")"); - vpsd_ranking.add("name", "ChargedPFCandidate"); - vpsd_ranking.add("plugin", "PFRecoTauChargedHadronStringQuality"); - desc.addVPSet("ranking", vpsd_ranking); + edm::ParameterSetDescription desc_ranking; + desc_ranking.add("selectionPassFunction", "-pt"); + desc_ranking.add("selectionFailValue", 1000.0); + desc_ranking.add("selection", "algoIs(\"kChargedPFCandidate\")"); + desc_ranking.add("name", "ChargedPFCandidate"); + desc_ranking.add("plugin", "PFRecoTauChargedHadronStringQuality"); + + edm::ParameterSet pset_ranking; + pset_ranking.addParameter("selectionPassFunction", "-pt"); + pset_ranking.addParameter("selectionFailValue", 1000.0); + pset_ranking.addParameter("selection", "algoIs(\"kChargedPFCandidate\")"); + pset_ranking.addParameter("name", "ChargedPFCandidate"); + pset_ranking.addParameter("plugin", "PFRecoTauChargedHadronStringQuality"); + std::vector vpsd_ranking; + vpsd_ranking.push_back(pset_ranking); + + desc.addVPSet("ranking", desc_ranking, vpsd_ranking); } desc.add("verbosity", 0); @@ -337,15 +347,15 @@ PFRecoTauChargedHadronProducer::fillDescriptions(edm::ConfigurationDescriptions& desc.add("jetSrc", edm::InputTag("ak4PFJets")); { - edm::ParameterSetDescription vpsd_builders; - vpsd_builders.add("minMergeChargedHadronPt"); - vpsd_builders.add("name"); - vpsd_builders.add("plugin"); - vpsd_builders.addOptional("dRcone"); - vpsd_builders.addOptional("dRconeLimitedToJetArea"); - vpsd_builders.addOptional("dRmergeNeutralHadron"); - vpsd_builders.addOptional("dRmergePhoton"); - vpsd_builders.addOptional("srcTracks"); + edm::ParameterSetDescription desc_builders; + desc_builders.add("minMergeChargedHadronPt"); + desc_builders.add("name"); + desc_builders.add("plugin"); + desc_builders.addOptional("dRcone"); + desc_builders.addOptional("dRconeLimitedToJetArea"); + desc_builders.addOptional("dRmergeNeutralHadron"); + desc_builders.addOptional("dRmergePhoton"); + desc_builders.addOptional("srcTracks"); { edm::ParameterSetDescription pset_signalQualityCuts; @@ -391,31 +401,40 @@ PFRecoTauChargedHadronProducer::fillDescriptions(edm::ConfigurationDescriptions& pset_qualityCuts.add("vertexTrackFiltering", false); pset_qualityCuts.add("recoverLeadingTrk", false); - vpsd_builders.add("qualityCuts", pset_qualityCuts); + desc_builders.add("qualityCuts", pset_qualityCuts); } - vpsd_builders.add("minMergeGammaEt"); - vpsd_builders.add("verbosity", 0); - vpsd_builders.add("minMergeNeutralHadronEt"); - - vpsd_builders.addOptional("dRmergePhotonWrtChargedHadron"); - vpsd_builders.addOptional("dRmergePhotonWrtNeutralHadron"); - vpsd_builders.addOptional("maxUnmatchedBlockElementsNeutralHadron"); - vpsd_builders.addOptional("dRmergePhotonWrtElectron"); - vpsd_builders.addOptional>("chargedHadronCandidatesParticleIds"); - vpsd_builders.addOptional("minBlockElementMatchesPhoton"); - vpsd_builders.addOptional("dRmergeNeutralHadronWrtNeutralHadron"); - vpsd_builders.addOptional("maxUnmatchedBlockElementsPhoton"); - vpsd_builders.addOptional("dRmergeNeutralHadronWrtOther"); - vpsd_builders.addOptional("dRmergeNeutralHadronWrtElectron"); - vpsd_builders.addOptional("minBlockElementMatchesNeutralHadron"); - vpsd_builders.addOptional("dRmergePhotonWrtOther"); - vpsd_builders.addOptional("dRmergeNeutralHadronWrtChargedHadron"); - - desc.addVPSet("builders", vpsd_builders); + desc_builders.add("minMergeGammaEt"); + desc_builders.add("verbosity", 0); + desc_builders.add("minMergeNeutralHadronEt"); + + desc_builders.addOptional("dRmergePhotonWrtChargedHadron"); + desc_builders.addOptional("dRmergePhotonWrtNeutralHadron"); + desc_builders.addOptional("maxUnmatchedBlockElementsNeutralHadron"); + desc_builders.addOptional("dRmergePhotonWrtElectron"); + desc_builders.addOptional>("chargedHadronCandidatesParticleIds"); + desc_builders.addOptional("minBlockElementMatchesPhoton"); + desc_builders.addOptional("dRmergeNeutralHadronWrtNeutralHadron"); + desc_builders.addOptional("maxUnmatchedBlockElementsPhoton"); + desc_builders.addOptional("dRmergeNeutralHadronWrtOther"); + desc_builders.addOptional("dRmergeNeutralHadronWrtElectron"); + desc_builders.addOptional("minBlockElementMatchesNeutralHadron"); + desc_builders.addOptional("dRmergePhotonWrtOther"); + desc_builders.addOptional("dRmergeNeutralHadronWrtChargedHadron"); + + edm::ParameterSet pset_builders; + pset_builders.addParameter("name",""); + pset_builders.addParameter("plugin",""); + edm::ParameterSet qualityCuts; + pset_builders.addParameter("qualityCuts",qualityCuts); + pset_builders.addParameter("verbosity",0); + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + + desc.addVPSet("builders", desc_builders, vpsd_builders); } - descriptions.add("ak4PFJetsRecoTauChargedHadrons", desc); + descriptions.add("pfRecoTauChargedHadronProducer", desc); } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cff.py similarity index 83% rename from RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py rename to RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cff.py index c4db3a6374f98..6ea27b22657eb 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cff.py @@ -3,10 +3,11 @@ import RecoTauTag.RecoTau.PFRecoTauChargedHadronBuilderPlugins_cfi as builders import RecoTauTag.RecoTau.PFRecoTauChargedHadronQualityPlugins_cfi as ranking +from RecoTauTag.RecoTau.pfRecoTauChargedHadronProducer_cfi import pfRecoTauChargedHadronProducer from RecoTauTag.RecoTau.PFRecoTauQualityCuts_cfi import PFTauQualityCuts from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs -ak4PFJetsRecoTauChargedHadrons = cms.EDProducer("PFRecoTauChargedHadronProducer", +ak4PFJetsRecoTauChargedHadrons = pfRecoTauChargedHadronProducer.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -20,6 +21,5 @@ ranking.isChargedPFCandidate, ranking.isTrack, ranking.isPFNeutralHadron - ), - verbosity = cms.int32(0) + ) ) From 3f88f49755f49d874898e9c5609c5705b2412959 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 5 Apr 2019 17:04:56 +0200 Subject: [PATCH 482/686] Ecal geometry description --- .../EcalAlgo/test/python/testEcalGeometry.py | 58 +++++++++++++++ .../data/dd4hep/cms-ecal-geometry.xml | 70 +++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Geometry/EcalAlgo/test/python/testEcalGeometry.py create mode 100644 Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml diff --git a/Geometry/EcalAlgo/test/python/testEcalGeometry.py b/Geometry/EcalAlgo/test/python/testEcalGeometry.py new file mode 100644 index 0000000000000..be089da6ad203 --- /dev/null +++ b/Geometry/EcalAlgo/test/python/testEcalGeometry.py @@ -0,0 +1,58 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("EcalGeometryTest") + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.MessageLogger = cms.Service( + "MessageLogger", + statistics = cms.untracked.vstring('cout', 'ecalGeometry'), + categories = cms.untracked.vstring('Geometry'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING'), + noLineBreaks = cms.untracked.bool(True) + ), + ecalGeometry = cms.untracked.PSet( + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + threshold = cms.untracked.string('INFO'), + Geometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ) + ), + destinations = cms.untracked.vstring('cout', + 'ecalGeometry') + ) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml'), + appendToDataLabel = cms.string('Ecal') + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('Ecal') + ) + +process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer", + appendToDataLabel = cms.string('Ecal') + ) + +process.test = cms.EDAnalyzer("DDCMSDetector", + DDDetector = cms.ESInputTag('Ecal') + ) + +process.p = cms.Path(process.test) diff --git a/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml b/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml new file mode 100644 index 0000000000000..ef7e668873a58 --- /dev/null +++ b/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a586d4ce4bd02fe3b8b968ce7d5f412b9ef882c6 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 5 Apr 2019 17:11:28 +0200 Subject: [PATCH 483/686] Remove tracker from configuration --- Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml b/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml index ef7e668873a58..eaf55e57f9fed 100644 --- a/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml +++ b/Geometry/EcalCommonData/data/dd4hep/cms-ecal-geometry.xml @@ -36,7 +36,6 @@ - From fabae2689699b1e58bf4a84b3b647777f09a9d54 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 5 Apr 2019 17:22:48 +0200 Subject: [PATCH 484/686] Tracker geometry description --- .../data/dd4hep/cms-tracker-geometry.xml | 72 +++++++++++++++++++ .../test/python/testTrackerGeometry.py | 58 +++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml create mode 100644 Geometry/TrackerGeometryBuilder/test/python/testTrackerGeometry.py diff --git a/Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml b/Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml new file mode 100644 index 0000000000000..fc02009640f30 --- /dev/null +++ b/Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/TrackerGeometryBuilder/test/python/testTrackerGeometry.py b/Geometry/TrackerGeometryBuilder/test/python/testTrackerGeometry.py new file mode 100644 index 0000000000000..7456a343f19bc --- /dev/null +++ b/Geometry/TrackerGeometryBuilder/test/python/testTrackerGeometry.py @@ -0,0 +1,58 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("TrackerGeometryTest") + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.MessageLogger = cms.Service( + "MessageLogger", + statistics = cms.untracked.vstring('cout', 'trackerGeometry'), + categories = cms.untracked.vstring('Geometry'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING'), + noLineBreaks = cms.untracked.bool(True) + ), + trackerGeometry = cms.untracked.PSet( + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + threshold = cms.untracked.string('INFO'), + Geometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ) + ), + destinations = cms.untracked.vstring('cout', + 'trackerGeometry') + ) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry.xml'), + appendToDataLabel = cms.string('Tracker') + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('Tracker') + ) + +process.DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer", + appendToDataLabel = cms.string('Tracker') + ) + +process.test = cms.EDAnalyzer("DDCMSDetector", + DDDetector = cms.ESInputTag('Tracker') + ) + +process.p = cms.Path(process.test) From f300aefc4ed7c575547de41cd5ff8bdcf3bae7ec Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 5 Apr 2019 18:26:40 +0200 Subject: [PATCH 485/686] Channel time offset applied at the OOT computation level --- .../src/CTPPSDiamondRecHitProducerAlgorithm.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 8c07558ac7d3d..8f4fb7a3dbd81 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -56,24 +56,27 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, for ( const auto& digi : vec ) { const int t_lead = digi.getLeadingEdge(), t_trail = digi.getTrailingEdge(); + // skip invalid digis if ( t_lead == 0 && t_trail == 0 ) continue; - const int time_slice = ( t_lead != 0 ) - ? t_lead / 1024 - : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; - double tot = -1., t_mean = 0.; if ( t_lead != 0 && t_trail != 0 ) { - tot = ( t_trail-t_lead )*ts_to_ns_; + tot = ( t_trail-t_lead )*ts_to_ns_; // in ns if ( calib_fct_ ) { + // compute the time-walk correction t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); if ( std::isnan( t_mean ) ) t_mean = 0.; } } + + const int time_slice = ( t_lead != 0 ) + ? ( t_lead-ch_t_offset/ts_to_ns_ ) / 1024 + : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; + // calibrated time of arrival - const double t0 = ( t_lead % 1024 )*ts_to_ns_+ ch_t_offset-t_mean; + const double t0 = ( t_lead % 1024 )*ts_to_ns_-t_mean; rec_hits.emplace_back( // spatial information From 80fa1f187eed2e70b254aaaff1af8ba2e5175376 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Fri, 5 Apr 2019 18:27:06 +0200 Subject: [PATCH 486/686] Better time-walk correction variable naming --- .../src/CTPPSDiamondRecHitProducerAlgorithm.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 8f4fb7a3dbd81..e61a89110ea27 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -60,14 +60,14 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, if ( t_lead == 0 && t_trail == 0 ) continue; - double tot = -1., t_mean = 0.; + double tot = -1., ch_t_twc = 0.; if ( t_lead != 0 && t_trail != 0 ) { tot = ( t_trail-t_lead )*ts_to_ns_; // in ns if ( calib_fct_ ) { // compute the time-walk correction - t_mean = calib_fct_->evaluate( std::vector{ tot }, ch_params ); - if ( std::isnan( t_mean ) ) - t_mean = 0.; + ch_t_twc = calib_fct_->evaluate( std::vector{ tot }, ch_params ); + if ( std::isnan( ch_t_twc ) ) + ch_t_twc = 0.; } } @@ -76,7 +76,7 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING; // calibrated time of arrival - const double t0 = ( t_lead % 1024 )*ts_to_ns_-t_mean; + const double t0 = ( t_lead % 1024 )*ts_to_ns_-ch_t_twc; rec_hits.emplace_back( // spatial information From 2d43723df62bc5920eaa633a9071fbf7d7ada410 Mon Sep 17 00:00:00 2001 From: "W. David Dagenhart" Date: Thu, 4 Apr 2019 21:46:27 +0200 Subject: [PATCH 487/686] Improve exception handling for end stream exceptions These improvements are particularly relevant when running with concurrent lumis. More thread safe. Just use an atomic for exceptionMessageLumis_. No reason to pass around the string. It's always the same. Set the deferredExceptionPtr_ when there are exceptions in end lumi transitions to shut down quicker and with less noise in the printed exceptions. Some cleanup to slightly simplify this part of the code. --- FWCore/Framework/interface/EventProcessor.h | 6 +- FWCore/Framework/src/EventProcessor.cc | 113 +++++++++--------- FWCore/Framework/src/TransitionProcessors.icc | 3 +- FWCore/Framework/test/MockEventProcessor.cc | 2 +- FWCore/Framework/test/MockEventProcessor.h | 2 +- 5 files changed, 62 insertions(+), 64 deletions(-) diff --git a/FWCore/Framework/interface/EventProcessor.h b/FWCore/Framework/interface/EventProcessor.h index 8d8310a715b30..bc5418851189a 100644 --- a/FWCore/Framework/interface/EventProcessor.h +++ b/FWCore/Framework/interface/EventProcessor.h @@ -222,6 +222,7 @@ namespace edm { edm::WaitingTaskHolder iHolder); void continueLumiAsync(edm::WaitingTaskHolder iHolder); + void handleEndLumiExceptions(std::exception_ptr const* iPtr, WaitingTaskHolder& holder); void globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus); void streamEndLumiAsync(edm::WaitingTaskHolder iTask, unsigned int iStreamIndex, @@ -239,7 +240,7 @@ namespace edm { void setExceptionMessageFiles(std::string& message); void setExceptionMessageRuns(std::string& message); - void setExceptionMessageLumis(std::string& message); + void setExceptionMessageLumis(); bool setDeferredException(std::exception_ptr); @@ -330,8 +331,7 @@ namespace edm { bool fileModeNoMerge_; std::string exceptionMessageFiles_; std::string exceptionMessageRuns_; - std::string exceptionMessageLumis_; - std::atomic exceptionMessageLumisIsSet_; + std::atomic exceptionMessageLumis_; bool forceLooperToEnd_; bool looperBeginJobRun_; bool forceESCacheClearOnNewRun_; diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 36f3a92c6db82..fed92c59a066c 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -243,8 +243,7 @@ namespace edm { fileModeNoMerge_(false), exceptionMessageFiles_(), exceptionMessageRuns_(), - exceptionMessageLumis_(), - exceptionMessageLumisIsSet_(false), + exceptionMessageLumis_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -280,8 +279,7 @@ namespace edm { fileModeNoMerge_(false), exceptionMessageFiles_(), exceptionMessageRuns_(), - exceptionMessageLumis_(), - exceptionMessageLumisIsSet_(false), + exceptionMessageLumis_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -319,8 +317,7 @@ namespace edm { fileModeNoMerge_(false), exceptionMessageFiles_(), exceptionMessageRuns_(), - exceptionMessageLumis_(), - exceptionMessageLumisIsSet_(false), + exceptionMessageLumis_(false), forceLooperToEnd_(false), looperBeginJobRun_(false), forceESCacheClearOnNewRun_(false), @@ -757,10 +754,11 @@ namespace edm { } // Try block catch (cms::Exception & e) { - if (!exceptionMessageLumis_.empty()) { - e.addAdditionalInfo(exceptionMessageLumis_); + if (exceptionMessageLumis_) { + std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); + e.addAdditionalInfo(message); if (e.alreadyPrinted()) { - LogAbsolute("Additional Exceptions") << exceptionMessageLumis_; + LogAbsolute("Additional Exceptions") << message; } } if (!exceptionMessageRuns_.empty()) { @@ -1244,6 +1242,15 @@ namespace edm { }) ); } + void EventProcessor::handleEndLumiExceptions(std::exception_ptr const* iPtr, WaitingTaskHolder& holder) { + if (setDeferredException(*iPtr)) { + WaitingTaskHolder tmp(holder); + tmp.doneWaiting(*iPtr); + } else { + setExceptionMessageLumis(); + } + } + void EventProcessor::globalEndLumiAsync(edm::WaitingTaskHolder iTask, std::shared_ptr iLumiStatus) { @@ -1259,11 +1266,7 @@ namespace edm { std::exception_ptr ptr; if(iPtr) { - ptr = *iPtr; - WaitingTaskHolder tmp(iTask); - //set the exception early to prevent a beginLumi from running - // we use a copy to keep t from resetting on doneWaiting call. - tmp.doneWaiting(ptr); + handleEndLumiExceptions(iPtr, iTask); } else { try { ServiceRegistry::Operate operate(serviceToken_); @@ -1272,36 +1275,55 @@ namespace edm { auto const& es = esp_->eventSetup(); looper_->doEndLuminosityBlock(lp, es, &processContext_); } - }catch(...) { - if(not ptr) { - ptr = std::current_exception(); - } + } catch(...) { + ptr = std::current_exception(); } } ServiceRegistry::Operate operate(serviceToken_); + + // Try hard to clean up resources so the + // process can terminate in a controlled + // fashion even after exceptions have occurred. + try { deleteLumiFromCache(*status); + } catch(...) { + if (not ptr) { + ptr = std::current_exception(); + } + } + + try { //release our hold on the IOV iovQueue_.resume(); + } catch(...) { + if (not ptr) { + ptr = std::current_exception(); + } + } + + try { status->resumeGlobalLumiQueue(); } catch(...) { - if( not ptr) { + if (not ptr) { ptr = std::current_exception(); } } + try { + // This call to status.reset() must occur before iTask is destroyed. + // Otherwise there will be a data race which could result in endRun + // being delayed until it is too late to successfully call it. status.reset(); } catch(...) { - if( not ptr) { + if (not ptr) { ptr = std::current_exception(); } } - // This call to doneWaiting must be after the call to status.reset(). - // Otherwise there will be a data race which could result in - // endRun being delayed until it is too late to successfully call - // it. - iTask.doneWaiting(ptr); + if (ptr) { + handleEndLumiExceptions(&ptr, iTask); + } }); auto writeT = edm::make_waiting_task( @@ -1340,9 +1362,8 @@ namespace edm { std::shared_ptr iLumiStatus) { auto t =edm::make_waiting_task(tbb::task::allocate_root(), [this, iStreamIndex, iTask](std::exception_ptr const* iPtr) mutable { - std::exception_ptr ptr; if(iPtr) { - ptr = *iPtr; + handleEndLumiExceptions(iPtr, iTask); } auto status =streamLumiStatus_[iStreamIndex]; //reset status before releasing queue else get race condtion @@ -1353,10 +1374,11 @@ namespace edm { //are we the last one? if( status->streamFinishedLumi()) { globalEndLumiAsync(iTask, std::move(status)); + } else { + status.reset(); } - iTask.doneWaiting(ptr); }); - + edm::WaitingTaskHolder lumiDoneTask{t}; iLumiStatus->setEndTime(); @@ -1595,30 +1617,10 @@ namespace edm { // This is the case where the exception in iPtr is the primary // exception and we want to see its message. deferredExceptionPtr_ = *iPtr; - std::exception_ptr excpt = *iPtr; - auto delayError = make_waiting_task(tbb::task::allocate_root(), [this, iTask, excpt](std::exception_ptr const* jPtr) mutable { - if (jPtr) { - std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); - setExceptionMessageLumis(message); - } - iTask.doneWaiting(excpt); - }); - WaitingTaskHolder delayErrorHolder(delayError); - streamEndLumiAsync(std::move(delayErrorHolder), iStreamIndex, streamLumiStatus_[iStreamIndex]); - } else { - // Something else already threw and set the deferred exception so - // we simply ignore subsequent exceptions. - std::exception_ptr excpt; - auto ignoreError = make_waiting_task(tbb::task::allocate_root(), [this, iTask, excpt](std::exception_ptr const* jPtr) mutable { - if (jPtr) { - std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); - setExceptionMessageLumis(message); - } - iTask.doneWaiting(excpt); - }); - WaitingTaskHolder ignoreErrorHolder(ignoreError); - streamEndLumiAsync(std::move(ignoreErrorHolder), iStreamIndex, streamLumiStatus_[iStreamIndex]); + WaitingTaskHolder tempHolder(iTask); + tempHolder.doneWaiting(*iPtr); } + streamEndLumiAsync(std::move(iTask), iStreamIndex, streamLumiStatus_[iStreamIndex]); //the stream will stop now return; } @@ -1787,11 +1789,8 @@ namespace edm { exceptionMessageRuns_ = message; } - void EventProcessor::setExceptionMessageLumis(std::string& message) { - bool expected = false; - if (exceptionMessageLumisIsSet_.compare_exchange_strong(expected,true)) { - exceptionMessageLumis_ = message; - } + void EventProcessor::setExceptionMessageLumis() { + exceptionMessageLumis_ = true; } bool EventProcessor::setDeferredException(std::exception_ptr iException) { diff --git a/FWCore/Framework/src/TransitionProcessors.icc b/FWCore/Framework/src/TransitionProcessors.icc index fe92974f595dc..155291e8992ed 100644 --- a/FWCore/Framework/src/TransitionProcessors.icc +++ b/FWCore/Framework/src/TransitionProcessors.icc @@ -102,8 +102,7 @@ public: } } catch(...) { if(not currentRun_->ep_.setDeferredException(std::current_exception())) { - std::string message("Another exception was caught while trying to clean up lumis after the primary fatal exception."); - currentRun_->ep_.setExceptionMessageLumis(message); + currentRun_->ep_.setExceptionMessageLumis(); } } diff --git a/FWCore/Framework/test/MockEventProcessor.cc b/FWCore/Framework/test/MockEventProcessor.cc index 4fcac253975a6..a73ef3296db87 100644 --- a/FWCore/Framework/test/MockEventProcessor.cc +++ b/FWCore/Framework/test/MockEventProcessor.cc @@ -368,7 +368,7 @@ namespace edm { void MockEventProcessor::setExceptionMessageFiles(std::string&) {} void MockEventProcessor::setExceptionMessageRuns(std::string&) {} - void MockEventProcessor::setExceptionMessageLumis(std::string&) {} + void MockEventProcessor::setExceptionMessageLumis() {} bool MockEventProcessor::setDeferredException(std::exception_ptr) { return true;} diff --git a/FWCore/Framework/test/MockEventProcessor.h b/FWCore/Framework/test/MockEventProcessor.h index 8b4704928aa96..53bdba2a64367 100644 --- a/FWCore/Framework/test/MockEventProcessor.h +++ b/FWCore/Framework/test/MockEventProcessor.h @@ -78,7 +78,7 @@ namespace edm { void setExceptionMessageFiles(std::string& message); void setExceptionMessageRuns(std::string& message); - void setExceptionMessageLumis(std::string& message); + void setExceptionMessageLumis(); bool setDeferredException(std::exception_ptr); From 412316eeb9560e00f0548189ce765495f9592510 Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Sat, 6 Apr 2019 11:05:47 +0200 Subject: [PATCH 488/686] Adjusting the limits for the z zoom plots --- Validation/Geometry/test/MaterialBudgetHGCal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/Geometry/test/MaterialBudgetHGCal.py b/Validation/Geometry/test/MaterialBudgetHGCal.py index 23b0acdca4d6a..738c219c8270f 100644 --- a/Validation/Geometry/test/MaterialBudgetHGCal.py +++ b/Validation/Geometry/test/MaterialBudgetHGCal.py @@ -640,7 +640,7 @@ def create2DPlots(detector, plot, plotnum, plotmat): if plot == "x_vs_z_vs_Rsum" or plot == "l_vs_z_vs_Rsum" or plot == "x_vs_z_vs_Rsumcos" or plot == "l_vs_z_vs_Rsumcos" or plot == "x_vs_z_vs_Rloc" or plot == "l_vs_z_vs_Rloc" or plot == "x_vs_z_vs_Rloccos" or plot == "l_vs_z_vs_Rloccos": #Z+ #hist2d_X0_total.GetXaxis().SetLimits( 3100., 5200.) - hist2d_X0_total.GetXaxis().SetRangeUser( 3100., 5200.) + hist2d_X0_total.GetXaxis().SetRangeUser( 3100., 5400.) #Do not draw eta values in the zoom case keep_alive = [] #hist2d_X0_total.Draw("COLZ") @@ -650,7 +650,7 @@ def create2DPlots(detector, plot, plotnum, plotmat): can2.SaveAs( "%s/%s/%s_%s%s_ZplusZoom.png" % (theDirname, "ZPlusZoom", detector, plot, plotmat)) #Z- #hist2d_X0_total.GetXaxis().SetLimits( 3100., 5200.) - hist2d_X0_total.GetXaxis().SetRangeUser( -5200., -3100.) + hist2d_X0_total.GetXaxis().SetRangeUser( -5400., -3100.) #Do not draw eta values in the zoom case keep_alive = [] #hist2d_X0_total.Draw("COLZ") From e86af36657d578da8c76e6e64dd7fa4829909c4a Mon Sep 17 00:00:00 2001 From: David Lange Date: Sat, 6 Apr 2019 14:30:49 +0200 Subject: [PATCH 489/686] Update Types.py --- FWCore/ParameterSet/python/Types.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/FWCore/ParameterSet/python/Types.py b/FWCore/ParameterSet/python/Types.py index f5291ce8c36e8..a6e34aa6dad82 100644 --- a/FWCore/ParameterSet/python/Types.py +++ b/FWCore/ParameterSet/python/Types.py @@ -167,8 +167,13 @@ def pythonValue(self, options=PrintOptions()): @staticmethod def formatValueForConfig(value): l = len(value) - t=codecs.escape_encode(value.encode('utf-8')) - value = t[0].decode('utf-8') + import sys + if sys.version_info >= (3, 0): #python2 and python3 are different due to byptes vs strings + import codecs + t=codecs.escape_encode(value.encode('utf-8')) + value = t[0].decode('utf-8') + else: #be conservative and don't change the python2 version + value = value.encode("string-escape") newL = len(value) if l != newL: #get rid of the hex encoding From cc6db462bf443e24b681eaf69f1ee13b60d4b506 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 6 Apr 2019 15:45:10 +0200 Subject: [PATCH 490/686] remove boost python pset --- FWCore/PythonParameterSet/BuildFile.xml | 8 - FWCore/PythonParameterSet/bin/BuildFile.xml | 7 - .../PythonParameterSet/bin/edmConfigHash.cpp | 42 - .../bin/edmParameterSetDump.cpp | 36 - .../interface/BoostPython.h | 6 - .../interface/MakeParameterSets.h | 37 - .../interface/PythonParameterSet.h | 131 --- .../interface/PythonProcessDesc.h | 55 -- .../interface/pythonFileToConfigure.h | 16 - .../python/test/testTask_cff.py | 248 ------ .../src/MakeParameterSets.cc | 86 -- FWCore/PythonParameterSet/src/PythonModule.h | 159 ---- .../src/PythonParameterSet.cc | 46 - .../src/PythonProcessDesc.cc | 99 --- .../PythonParameterSet/src/PythonWrapper.cc | 46 - FWCore/PythonParameterSet/src/PythonWrapper.h | 42 - .../src/initializeModule.cc | 39 - .../PythonParameterSet/src/initializeModule.h | 33 - .../src/pythonFileToConfigure.cc | 54 -- FWCore/PythonParameterSet/test/BuildFile.xml | 7 - FWCore/PythonParameterSet/test/fip.txt | 1 - .../test/makeprocess_t.cppunit.cc | 802 ------------------ .../test/makepset_t.cppunit.cc | 506 ----------- .../test/processbuilder_t.cppunit.cpp | 404 --------- .../test/readpsetsfrom_t.cppunit.cc | 53 -- FWCore/PythonParameterSet/test/ufip.txt | 1 - 26 files changed, 2964 deletions(-) delete mode 100644 FWCore/PythonParameterSet/BuildFile.xml delete mode 100644 FWCore/PythonParameterSet/bin/BuildFile.xml delete mode 100644 FWCore/PythonParameterSet/bin/edmConfigHash.cpp delete mode 100644 FWCore/PythonParameterSet/bin/edmParameterSetDump.cpp delete mode 100644 FWCore/PythonParameterSet/interface/BoostPython.h delete mode 100644 FWCore/PythonParameterSet/interface/MakeParameterSets.h delete mode 100644 FWCore/PythonParameterSet/interface/PythonParameterSet.h delete mode 100644 FWCore/PythonParameterSet/interface/PythonProcessDesc.h delete mode 100644 FWCore/PythonParameterSet/interface/pythonFileToConfigure.h delete mode 100644 FWCore/PythonParameterSet/python/test/testTask_cff.py delete mode 100644 FWCore/PythonParameterSet/src/MakeParameterSets.cc delete mode 100644 FWCore/PythonParameterSet/src/PythonModule.h delete mode 100644 FWCore/PythonParameterSet/src/PythonParameterSet.cc delete mode 100644 FWCore/PythonParameterSet/src/PythonProcessDesc.cc delete mode 100644 FWCore/PythonParameterSet/src/PythonWrapper.cc delete mode 100644 FWCore/PythonParameterSet/src/PythonWrapper.h delete mode 100644 FWCore/PythonParameterSet/src/initializeModule.cc delete mode 100644 FWCore/PythonParameterSet/src/initializeModule.h delete mode 100644 FWCore/PythonParameterSet/src/pythonFileToConfigure.cc delete mode 100644 FWCore/PythonParameterSet/test/BuildFile.xml delete mode 100644 FWCore/PythonParameterSet/test/fip.txt delete mode 100644 FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc delete mode 100644 FWCore/PythonParameterSet/test/makepset_t.cppunit.cc delete mode 100644 FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp delete mode 100644 FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc delete mode 100644 FWCore/PythonParameterSet/test/ufip.txt diff --git a/FWCore/PythonParameterSet/BuildFile.xml b/FWCore/PythonParameterSet/BuildFile.xml deleted file mode 100644 index cbe832d11d86d..0000000000000 --- a/FWCore/PythonParameterSet/BuildFile.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/FWCore/PythonParameterSet/bin/BuildFile.xml b/FWCore/PythonParameterSet/bin/BuildFile.xml deleted file mode 100644 index cc14bd46d50ac..0000000000000 --- a/FWCore/PythonParameterSet/bin/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/FWCore/PythonParameterSet/bin/edmConfigHash.cpp b/FWCore/PythonParameterSet/bin/edmConfigHash.cpp deleted file mode 100644 index afcc74945d8fc..0000000000000 --- a/FWCore/PythonParameterSet/bin/edmConfigHash.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// This will return the ParameterSetID of the parameter set -// defined in the python file or configuration string. -// Warning, this may not be the same as the ParameterSetID -// of a cmsRun process, because validation code may insert -// additional parameters into the configuration. - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include - -#include -#include - -int main(int argc, char **argv) try { - // config can either be a name or a string - std::string config; - - if(argc == 1) { - // Read input from cin into configstring.. - std::string line; - while(std::getline(std::cin, line)) { - config += line; - config += '\n'; - } - } else if(argc == 2) { - config = std::string(argv[1]); - } - - std::shared_ptr parameterSet = edm::boost_python::readConfig(config); - parameterSet->registerIt(); - std::cout << parameterSet->id() << std::endl; - return 0; -} catch(cms::Exception const& e) { - std::cout << e.explainSelf() << std::endl; - return 1; -} catch(std::exception const& e) { - std::cout << e.what() << std::endl; - return 1; -} diff --git a/FWCore/PythonParameterSet/bin/edmParameterSetDump.cpp b/FWCore/PythonParameterSet/bin/edmParameterSetDump.cpp deleted file mode 100644 index 8bd100829aac9..0000000000000 --- a/FWCore/PythonParameterSet/bin/edmParameterSetDump.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -*- C++ -*- -// -// Package: PythonParameterSet -// Class : edmParameterSetDump -// -// Implementation: -// -// -// Original Author: Rick Wilkinson -// Created: Thu Aug 2 13:33:53 EDT 2007 -// - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include -#include -#include - -int main (int argc, char **argv) try { - if(argc != 2) { - std::cout << "Usage: edmParameterSetDump " << std::endl; - } - std::string fileName(argv[1]); - std::shared_ptr parameterSet = edm::boost_python::readConfig(fileName); - std::cout << "====Main Process====" << std::endl; - std::cout << parameterSet->dump() << std::endl; - return 0; -} catch(cms::Exception const& e) { - std::cout << e.explainSelf() << std::endl; - return 1; -} catch(std::exception const& e) { - std::cout << e.what() << std::endl; - return 1; -} diff --git a/FWCore/PythonParameterSet/interface/BoostPython.h b/FWCore/PythonParameterSet/interface/BoostPython.h deleted file mode 100644 index ff271e3298e55..0000000000000 --- a/FWCore/PythonParameterSet/interface/BoostPython.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FWCore_PythonParameterSet_BoostPython_h -#define FWCore_PythonParameterSet_BoostPython_h -// avoids compiler warning -#undef _POSIX_C_SOURCE -#include -#endif diff --git a/FWCore/PythonParameterSet/interface/MakeParameterSets.h b/FWCore/PythonParameterSet/interface/MakeParameterSets.h deleted file mode 100644 index d52a2c57fb0b0..0000000000000 --- a/FWCore/PythonParameterSet/interface/MakeParameterSets.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef FWCore_PythonParameterSet_MakeParameterSets_h -#define FWCore_PythonParameterSet_MakeParameterSets_h - -//---------------------------------------------------------------------- -// Declare functions used to create ParameterSets. -//---------------------------------------------------------------------- - -#include - -#include -#include - -namespace edm { - class ParameterSet; - namespace boost_python { - - // input can either be a python file name or a python config string - std::unique_ptr - readConfig(std::string const& config); - - /// same, but with arguments - std::unique_ptr - readConfig(std::string const& config, int argc, char* argv[]); - - /// essentially the same as the previous method - void - makeParameterSets(std::string const& configtext, - std::unique_ptr & main); - - /**finds all the PSets used in the top level module referred as a file or as a string containing - python commands. These PSets are bundled into a top level PSet from which they can be retrieved - */ - std::unique_ptr readPSetsFrom(std::string const& fileOrString); - } // BoostPython -} // namespace edm -#endif - diff --git a/FWCore/PythonParameterSet/interface/PythonParameterSet.h b/FWCore/PythonParameterSet/interface/PythonParameterSet.h deleted file mode 100644 index ecb334a805f43..0000000000000 --- a/FWCore/PythonParameterSet/interface/PythonParameterSet.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef FWCore_PythonParameterSet_PythonParameterSet_h -#define FWCore_PythonParameterSet_PythonParameterSet_h - -#include "FWCore/PythonParameterSet/interface/BoostPython.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/src/PythonWrapper.h" - -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Utilities/interface/ESInputTag.h" -#include "DataFormats/Provenance/interface/EventRange.h" -#include "DataFormats/Provenance/interface/LuminosityBlockID.h" -#include "DataFormats/Provenance/interface/LuminosityBlockRange.h" -#include "DataFormats/Provenance/interface/EventID.h" -#include "DataFormats/Provenance/interface/RunLumiEventNumber.h" - -#include -#include - -class PythonParameterSet { -public: - PythonParameterSet(); - - PythonParameterSet(edm::ParameterSet const& p) - : theParameterSet(p) {} - - template - T - getParameter(bool tracked, std::string const& name) const { - T result; - if(tracked) { - result = theParameterSet.template getParameter(name); - } else { - result = theParameterSet.template getUntrackedParameter(name); - } - return result; - } - - - template - void - addParameter(bool tracked, std::string const& name, T const& value) { - if(tracked) { - theParameterSet.template addParameter(name, value); - } else { - theParameterSet.template addUntrackedParameter(name, value); - } - } - - - /// templated on the type of the contained object - template - boost::python::list - getParameters(bool tracked, std::string const& name) const { - std::vector v = getParameter >(tracked, name); - return edm::toPythonList(v); - } - - /// unfortunate side effect: destroys the original list! - template - void - addParameters(bool tracked, std::string const& name, - boost::python::list value) { - std::vector v = edm::toVector(value); - addParameter(tracked, name, v); - } - - - /// these custom classes do seem to be a hassle - /// to wrap, compared to, say, InputTag - /// maybe we will need to template these someday - void addPSet(bool tracked, std::string const& name, - PythonParameterSet const& ppset) { - addParameter(tracked, name, ppset.theParameterSet); - } - - - PythonParameterSet getPSet(bool tracked, std::string const& name) const { - return PythonParameterSet(getParameter(tracked, name)); - } - - - void addVPSet(bool tracked, std::string const& name, - boost::python::list value); - - boost::python::list getVPSet(bool tracked, std::string const& name); - - // no way to interface straight into the other python InputTag - edm::InputTag newInputTag(std::string const& label, - std::string const& instance, - std::string const& process) { - return edm::InputTag(label, instance, process); - } - - edm::ESInputTag newESInputTag(std::string const& module, - std::string const& data) { - return edm::ESInputTag(module, data); - } - - edm::EventID newEventID(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) { - return edm::EventID(run, lumi, event); - } - - edm::LuminosityBlockID newLuminosityBlockID(unsigned int run, unsigned int lumi) { - return edm::LuminosityBlockID(run, lumi); - } - - edm::LuminosityBlockRange newLuminosityBlockRange(unsigned int start, unsigned int startSub, - unsigned int end, unsigned int endSub) { - return edm::LuminosityBlockRange(start, startSub, end, endSub); - } - - edm::EventRange newEventRange(edm::RunNumber_t start, edm::LuminosityBlockNumber_t startLumi, edm::EventNumber_t startSub, - edm::RunNumber_t end, edm::LuminosityBlockNumber_t endLumi, edm::EventNumber_t endSub) { - return edm::EventRange(start, startLumi, startSub, end, endLumi, endSub); - } - - void addNewFileInPath(bool tracked, std::string const& name, std::string const& value); - - PythonParameterSet newPSet() const {return PythonParameterSet();} - - edm::ParameterSet& pset() {return theParameterSet;} - - edm::ParameterSet const& pset() const {return theParameterSet;} - - std::string dump() const {return theParameterSet.dump();} - -private: - edm::ParameterSet theParameterSet; -}; - -#endif diff --git a/FWCore/PythonParameterSet/interface/PythonProcessDesc.h b/FWCore/PythonParameterSet/interface/PythonProcessDesc.h deleted file mode 100644 index 15553170dbb57..0000000000000 --- a/FWCore/PythonParameterSet/interface/PythonProcessDesc.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef FWCore_PythonParameterSet_PythonProcessDesc_h -#define FWCore_PythonParameterSet_PythonProcessDesc_h - -#include "FWCore/PythonParameterSet/interface/BoostPython.h" -#include "FWCore/PythonParameterSet/interface/PythonParameterSet.h" - -#include - -#include -#include - -namespace edm { - class ParameterSet; - class ProcessDesc; -} - -class PythonProcessDesc { -public: - PythonProcessDesc(); - /** This constructor will parse the given file or string - and create two objects in python-land: - * a PythonProcessDesc named 'processDesc' - * a PythonParameterSet named 'processPSet' - It decides whether it's a file or string by seeing if - it ends in '.py' - */ - PythonProcessDesc(std::string const& config); - - PythonProcessDesc(std::string const& config, int argc, char * argv[]); - - PythonParameterSet newPSet() const {return PythonParameterSet();} - - PythonParameterSet& pset() { return theProcessPSet;} - - std::string dump() const; - - // makes a new (copy) of the ParameterSet - std::unique_ptr parameterSet() const; - - // makes a new (copy) of a ProcessDesc - // For backward compatibility only. Remove when no longer needed. - std::shared_ptr processDesc() const; - -private: - void prepareToRead(); - void read(std::string const& config); - void readFile(std::string const& fileName); - void readString(std::string const& pyConfig); - - PythonParameterSet theProcessPSet; - boost::python::object theMainModule; - boost::python::object theMainNamespace; -}; - -#endif diff --git a/FWCore/PythonParameterSet/interface/pythonFileToConfigure.h b/FWCore/PythonParameterSet/interface/pythonFileToConfigure.h deleted file mode 100644 index b5d1e7b8a0287..0000000000000 --- a/FWCore/PythonParameterSet/interface/pythonFileToConfigure.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FWCore_PythonParameterSet_pythonFileToConfigure_h -#define FWCore_PythonParameterSet_pythonFileToConfigure_h - -/* - * pythonFileToConfigure.h - * CMSSW - * - * Created by Chris Jones on 10/3/06. - * - */ -#include - -namespace edm { - std::string pythonFileToConfigure(const std::string& iPythonFileName); -} -#endif diff --git a/FWCore/PythonParameterSet/python/test/testTask_cff.py b/FWCore/PythonParameterSet/python/test/testTask_cff.py deleted file mode 100644 index 0244ccbb4ec47..0000000000000 --- a/FWCore/PythonParameterSet/python/test/testTask_cff.py +++ /dev/null @@ -1,248 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -m1 = cms.EDProducer("prod") -m2 = cms.EDProducer("prod") -m3 = cms.EDProducer("prod") -m4 = cms.EDProducer("prod") -m5 = cms.EDProducer("prod") -m6 = cms.EDProducer("prod") -m7 = cms.EDProducer("prod") -m8 = cms.EDProducer("prod") -m9 = cms.EDProducer("prod") -m10 = cms.EDProducer("prod") -m11 = cms.EDProducer("prod") -m12 = cms.EDProducer("prod") -m13 = cms.EDProducer("prod") -m14 = cms.EDProducer("prod") -m15 = cms.EDProducer("prod") -m16 = cms.EDProducer("prod") -m17 = cms.EDProducer("prod") -m18 = cms.EDProducer("prod") -m19 = cms.EDProducer("prod") -m20 = cms.EDProducer("prod") -m21 = cms.EDProducer("prod") -m22 = cms.EDProducer("prod") -m23 = cms.EDProducer("prod") -m24 = cms.EDProducer("prod") -m25 = cms.EDProducer("prod") -m26 = cms.EDProducer("prod") -m27 = cms.EDProducer("prod") -m28 = cms.EDProducer("prod") -m29 = cms.EDProducer("prod") -m30 = cms.EDProducer("prod") - -p1 = cms.Path(m3+m4) -t1 = cms.Task(m11, m12) -t2 = cms.Task(m13, m14) -t3 = cms.Task(m15, m16) -t4 = cms.Task(m17, m18) -s1 = cms.Sequence(m5+m6, t3, t4) -s2 = cms.Sequence(s1) -p2 = cms.Path(s2, t1, t2) -e1 = cms.EndPath(m7+m8) -t5 = cms.Task(m19, m20) -t6 = cms.Task(m21, m22) -t7 = cms.Task(m23, m24) -t8 = cms.Task(m25, m26) -s3 = cms.Sequence(m9+m10, t5, t6) -s4 = cms.Sequence(s3) -e2 = cms.EndPath(s4, t7, t8) -t9 = cms.Task(m27, m28) - -f1 = cms.EDFilter("filt") -f2 = cms.EDFilter("filt") -f3 = cms.EDFilter("filt") -f4 = cms.EDFilter("filt") -f5 = cms.EDFilter("filt") -f6 = cms.EDFilter("filt") -f7 = cms.EDFilter("filt") -f8 = cms.EDFilter("filt") -f9 = cms.EDFilter("filt") -f10 = cms.EDFilter("filt") -f11 = cms.EDFilter("filt") -f12 = cms.EDFilter("filt") -f13 = cms.EDFilter("filt") -f14 = cms.EDFilter("filt") -f15 = cms.EDFilter("filt") -f16 = cms.EDFilter("filt") -f17 = cms.EDFilter("filt") -f18 = cms.EDFilter("filt") -f19 = cms.EDFilter("filt") -f20 = cms.EDFilter("filt") -f21 = cms.EDFilter("filt") -f22 = cms.EDFilter("filt") -f23 = cms.EDFilter("filt") -f24 = cms.EDFilter("filt") -f25 = cms.EDFilter("filt") -f26 = cms.EDFilter("filt") -f27 = cms.EDFilter("filt") -f28 = cms.EDFilter("filt") -f29 = cms.EDFilter("filt") -f30 = cms.EDFilter("filt") - -pf1 = cms.Path(f3+f4) -tf1 = cms.Task(f11, f12) -tf2 = cms.Task(f13, f14) -tf3 = cms.Task(f15, f16) -tf4 = cms.Task(f17, f18) -sf1 = cms.Sequence(f5+f6, tf3, tf4) -sf2 = cms.Sequence(sf1) -pf2 = cms.Path(sf2, tf1, tf2) -ef1 = cms.EndPath(f7+f8) -tf5 = cms.Task(f19, f20) -tf6 = cms.Task(f21, f22) -tf7 = cms.Task(f23, f24) -tf8 = cms.Task(f25, f26) -sf3 = cms.Sequence(f9+f10, tf5, tf6) -sf4 = cms.Sequence(sf3) -ef2 = cms.EndPath(sf4, tf7, tf8) -tf9 = cms.Task(f27, f28) - -a1 = cms.EDAnalyzer("an") -a2 = cms.EDAnalyzer("an") -a3 = cms.EDAnalyzer("an") -a4 = cms.EDAnalyzer("an") -a5 = cms.EDAnalyzer("an") -a6 = cms.EDAnalyzer("an") -a7 = cms.EDAnalyzer("an") -a8 = cms.EDAnalyzer("an") -a9 = cms.EDAnalyzer("an") -a10 = cms.EDAnalyzer("an") - -pa1 = cms.Path(a3+a4) -sa1 = cms.Sequence(a5+a6) -sa2 = cms.Sequence(sa1) -pa2 = cms.Path(sa2) -ea1 = cms.EndPath(a7+a8) -sa3 = cms.Sequence(a9+a10) -sa4 = cms.Sequence(sa3) -ea2 = cms.EndPath(sa4) - -o1 = cms.OutputModule("out") -o2 = cms.OutputModule("out") -o7 = cms.OutputModule("out") -o8 = cms.OutputModule("out") -o9 = cms.OutputModule("out") -o10 = cms.OutputModule("out") - -eo1 = cms.EndPath(o7+o8) -so3 = cms.Sequence(o9+o10) -so4 = cms.Sequence(so3) -eo2 = cms.EndPath(so4) - -ess1 = cms.ESSource("ess") # labeled case -ess2 = cms.ESSource("ess2") # unlabeled case -ess3 = cms.ESSource("ess") -ess4 = cms.ESSource("ess4") -ess11 = cms.ESSource("ess") -ess12 = cms.ESSource("ess12") -ess13 = cms.ESSource("ess") -ess14 = cms.ESSource("ess14") -ess15 = cms.ESSource("ess") -ess16 = cms.ESSource("ess16") -ess17 = cms.ESSource("ess") -ess18 = cms.ESSource("ess18") -ess19 = cms.ESSource("ess") -ess20 = cms.ESSource("ess20") -ess21 = cms.ESSource("ess") -ess22 = cms.ESSource("ess22") -ess23 = cms.ESSource("ess") -ess24 = cms.ESSource("ess24") -ess25 = cms.ESSource("ess") -ess26 = cms.ESSource("ess26") -ess27 = cms.ESSource("ess") -ess28 = cms.ESSource("ess28") - -tess10 = cms.Task(ess3, ess4) -tess1 = cms.Task(ess11, ess12) -tess2 = cms.Task(ess13, ess14) -tess3 = cms.Task(ess15, ess16) -tess4 = cms.Task(ess17, ess18) -sess1 = cms.Sequence(tess3, tess4) -sess2 = cms.Sequence(sess1) -pess2 = cms.Path(sess2, tess1, tess2) -tess5 = cms.Task(ess19, ess20) -tess6 = cms.Task(ess21, ess22) -tess7 = cms.Task(ess23, ess24) -tess8 = cms.Task(ess25, ess26) -sess3 = cms.Sequence(tess5, tess6) -sess4 = cms.Sequence(sess3) -eess2 = cms.EndPath(sess4, tess7, tess8) - -esp1 = cms.ESProducer("esp") -esp2 = cms.ESProducer("esp2") -esp3 = cms.ESProducer("esp") -esp4 = cms.ESProducer("esp4") -esp11 = cms.ESProducer("esp") -esp12 = cms.ESProducer("esp12") -esp13 = cms.ESProducer("esp") -esp14 = cms.ESProducer("esp14") -esp15 = cms.ESProducer("esp") -esp16 = cms.ESProducer("esp16") -esp17 = cms.ESProducer("esp") -esp18 = cms.ESProducer("esp18") -esp19 = cms.ESProducer("esp") -esp20 = cms.ESProducer("esp20") -esp21 = cms.ESProducer("esp") -esp22 = cms.ESProducer("esp22") -esp23 = cms.ESProducer("esp") -esp24 = cms.ESProducer("esp24") -esp25 = cms.ESProducer("esp") -esp26 = cms.ESProducer("esp26") -esp27 = cms.ESProducer("esp") -esp28 = cms.ESProducer("esp28") - -tesp10 = cms.Task(esp3, esp4) -tesp1 = cms.Task(esp11, esp12) -tesp2 = cms.Task(esp13, esp14) -tesp3 = cms.Task(esp15, esp16) -tesp4 = cms.Task(esp17, esp18) -sesp1 = cms.Sequence(tesp3, tesp4) -sesp2 = cms.Sequence(sesp1) -pesp2 = cms.Path(sesp2, tesp1, tesp2) -tesp5 = cms.Task(esp19, esp20) -tesp6 = cms.Task(esp21, esp22) -tesp7 = cms.Task(esp23, esp24) -tesp8 = cms.Task(esp25, esp26) -sesp3 = cms.Sequence(tesp5, tesp6) -sesp4 = cms.Sequence(sesp3) -eesp2 = cms.EndPath(sesp4, tesp7, tesp8) - -serv1 = cms.Service("serv1") -serv2 = cms.Service("serv2") -serv3 = cms.Service("serv3") -serv4 = cms.Service("serv4") -serv11 = cms.Service("serv11") -serv12 = cms.Service("serv12") -serv13 = cms.Service("serv13") -serv14 = cms.Service("serv14") -serv15 = cms.Service("serv15") -serv16 = cms.Service("serv16") -serv17 = cms.Service("serv17") -serv18 = cms.Service("serv18") -serv19 = cms.Service("serv19") -serv20 = cms.Service("serv20") -serv21 = cms.Service("serv21") -serv22 = cms.Service("serv22") -serv23 = cms.Service("serv23") -serv24 = cms.Service("serv24") -serv25 = cms.Service("serv25") -serv26 = cms.Service("serv26") -serv27 = cms.Service("serv27") -serv28 = cms.Service("serv28") - -tserv10 = cms.Task(serv3, serv4) -tserv1 = cms.Task(serv11, serv12) -tserv2 = cms.Task(serv13, serv14) -tserv3 = cms.Task(serv15, serv16) -tserv4 = cms.Task(serv17, serv18) -sserv1 = cms.Sequence(tserv3, tserv4) -sserv2 = cms.Sequence(sserv1) -pserv2 = cms.Path(sserv2, tserv1, tserv2) -tserv5 = cms.Task(serv19, serv20) -tserv6 = cms.Task(serv21, serv22) -tserv7 = cms.Task(serv23, serv24) -tserv8 = cms.Task(serv25, serv26) -sserv3 = cms.Sequence(tserv5, tserv6) -sserv4 = cms.Sequence(sserv3) -eserv2 = cms.EndPath(sserv4, tserv7, tserv8) diff --git a/FWCore/PythonParameterSet/src/MakeParameterSets.cc b/FWCore/PythonParameterSet/src/MakeParameterSets.cc deleted file mode 100644 index d84a5057526a2..0000000000000 --- a/FWCore/PythonParameterSet/src/MakeParameterSets.cc +++ /dev/null @@ -1,86 +0,0 @@ -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/PythonParameterSet/interface/PythonParameterSet.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" -#include "FWCore/PythonParameterSet/src/initializeModule.h" - -using namespace boost::python; - -static -void -makePSetsFromFile(std::string const& fileName, boost::python::object& mainNamespace) { - std::string initCommand("from FWCore.ParameterSet.Types import makeCppPSet\n" - "execfile('"); - initCommand += fileName + "')"; - - handle<>(PyRun_String(initCommand.c_str(), - Py_file_input, - mainNamespace.ptr(), - mainNamespace.ptr())); - std::string command("makeCppPSet(locals(), topPSet)"); - handle<>(PyRun_String(command.c_str(), - Py_eval_input, - mainNamespace.ptr(), - mainNamespace.ptr())); -} - -static -void -makePSetsFromString(std::string const& module, boost::python::object& mainNamespace) { - std::string command = module; - command += "\nfrom FWCore.ParameterSet.Types import makeCppPSet\nmakeCppPSet(locals(), topPSet)"; - handle<>(PyRun_String(command.c_str(), - Py_file_input, - mainNamespace.ptr(), - mainNamespace.ptr())); -} - -namespace edm { - namespace boost_python { - - std::unique_ptr - readConfig(std::string const& config) { - PythonProcessDesc pythonProcessDesc(config); - return pythonProcessDesc.parameterSet(); - } - - std::unique_ptr - readConfig(std::string const& config, int argc, char* argv[]) { - PythonProcessDesc pythonProcessDesc(config, argc, argv); - return pythonProcessDesc.parameterSet(); - } - - void - makeParameterSets(std::string const& configtext, - std::unique_ptr& main) { - PythonProcessDesc pythonProcessDesc(configtext); - main = pythonProcessDesc.parameterSet(); - } - - std::unique_ptr - readPSetsFrom(std::string const& module) { - python::initializeModule(); - - boost::python::object mainModule = object(handle<>(borrowed(PyImport_AddModule(const_cast("__main__"))))); - - boost::python::object mainNamespace = mainModule.attr("__dict__"); - PythonParameterSet theProcessPSet; - mainNamespace["topPSet"] = ptr(&theProcessPSet); - - try { - // if it ends with py, it's a file - if(module.substr(module.size()-3) == ".py") { - makePSetsFromFile(module,mainNamespace); - } else { - makePSetsFromString(module,mainNamespace); - } - } - catch( error_already_set const& ) { - pythonToCppException("Configuration"); - Py_Finalize(); - } - return std::make_unique(ParameterSet(theProcessPSet.pset())); - } - } // namespace boost_python -} // namespace edm diff --git a/FWCore/PythonParameterSet/src/PythonModule.h b/FWCore/PythonParameterSet/src/PythonModule.h deleted file mode 100644 index 99afaa1e41ed8..0000000000000 --- a/FWCore/PythonParameterSet/src/PythonModule.h +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef FWCore_PythonParameterSet_PythonModule_h -#define FWCore_PythonParameterSet_PythonModule_h - -#include "FWCore/PythonParameterSet/interface/BoostPython.h" -#include "FWCore/PythonParameterSet/interface/PythonParameterSet.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" - -#include "DataFormats/Provenance/interface/EventRange.h" -#include "DataFormats/Provenance/interface/LuminosityBlockID.h" -#include "DataFormats/Provenance/interface/LuminosityBlockRange.h" -#include "DataFormats/Provenance/interface/EventID.h" -#include "DataFormats/Provenance/interface/RunLumiEventNumber.h" -#include "FWCore/Utilities/interface/ESInputTag.h" -#include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/Utilities/interface/InputTag.h" - -#include - -// This is to give some special handling to cms::Exceptions thrown -// in C++ code called by python. Only at the very top level do -// we need the exception message returned by the function "what". -// We only need the central message here as this will get converted -// back into a cms::Exception again when control rises back into -// the C++ code. If necessary it would probably be possible to -// improve these messages even more by adding something in the python -// to add module type and label context to the messages being caught -// here. At this point we did not think it worth the time to implement. -namespace { - void translatorlibFWCorePythonParameterSet(cms::Exception const& ex) { - PyErr_SetString(PyExc_RuntimeError, ex.message().c_str()); - } -} - -BOOST_PYTHON_MODULE(libFWCorePythonParameterSet) -{ - boost::python::register_exception_translator(translatorlibFWCorePythonParameterSet); - - boost::python::class_("InputTag", boost::python::init()) - .def(boost::python::init()) - .def(boost::python::init()) - .def("label", &edm::InputTag::label, boost::python::return_value_policy()) - .def("instance", &edm::InputTag::instance, boost::python::return_value_policy()) - .def("process", &edm::InputTag::process, boost::python::return_value_policy()) - ; - - boost::python::class_("ESInputTag", boost::python::init()) - .def(boost::python::init()) - .def("module", &edm::ESInputTag::module, boost::python::return_value_policy()) - .def("data", &edm::ESInputTag::data, boost::python::return_value_policy()) - ; - - boost::python::class_("EventID", boost::python::init()) - .def("run", &edm::EventID::run) - .def("luminosityBlock", &edm::EventID::luminosityBlock) - .def("event", &edm::EventID::event) - ; - - boost::python::class_("LuminosityBlockID", boost::python::init()) - .def("run", &edm::LuminosityBlockID::run) - .def("luminosityBlock", &edm::LuminosityBlockID::luminosityBlock) - ; - - boost::python::class_("FileInPath", boost::python::init()) - .def("fullPath", &edm::FileInPath::fullPath) - .def("relativePath", &edm::FileInPath::relativePath) - ; - - boost::python::class_("LuminosityBlockRange", boost::python::init()) - .def("start", &edm::LuminosityBlockRange::startRun) - .def("startSub", &edm::LuminosityBlockRange::startLumi) - .def("end", &edm::LuminosityBlockRange::endRun) - .def("endSub", &edm::LuminosityBlockRange::endLumi) - ; - - boost::python::class_("EventRange", boost::python::init()) - .def("start", &edm::EventRange::startRun) - .def("startLumi", &edm::EventRange::startLumi) - .def("startSub", &edm::EventRange::startEvent) - .def("end", &edm::EventRange::endRun) - .def("endLumi", &edm::EventRange::endLumi) - .def("endSub", &edm::EventRange::endEvent) - ; - - boost::python::class_("ParameterSet") - .def("addInt32", &PythonParameterSet::addParameter) - .def("getInt32", &PythonParameterSet::getParameter) - .def("addVInt32", &PythonParameterSet::addParameters) - .def("getVInt32", &PythonParameterSet::getParameters) - .def("addUInt32", &PythonParameterSet::addParameter) - .def("getUInt32", &PythonParameterSet::getParameter) - .def("addVUInt32", &PythonParameterSet::addParameters) - .def("getVUInt32", &PythonParameterSet::getParameters) - .def("addInt64", &PythonParameterSet::addParameter) - .def("getInt64", &PythonParameterSet::getParameter) - .def("addUInt64", &PythonParameterSet::addParameter) - .def("getUInt64", &PythonParameterSet::getParameter) - .def("addVInt64", &PythonParameterSet::addParameters) - .def("getVInt64", &PythonParameterSet::getParameters) - .def("addVUInt64", &PythonParameterSet::addParameters) - .def("getVUInt64", &PythonParameterSet::getParameters) - .def("addDouble", &PythonParameterSet::addParameter) - .def("getDouble", &PythonParameterSet::getParameter) - .def("addVDouble", &PythonParameterSet::addParameters) - .def("getVDouble", &PythonParameterSet::getParameters) - .def("addBool", &PythonParameterSet::addParameter) - .def("getBool", &PythonParameterSet::getParameter) - .def("addString", &PythonParameterSet::addParameter) - .def("getString", &PythonParameterSet::getParameter) - .def("addVString", &PythonParameterSet::addParameters) - .def("getVString", &PythonParameterSet::getParameters) - .def("addInputTag", &PythonParameterSet::addParameter) - .def("getInputTag", &PythonParameterSet::getParameter) - .def("addVInputTag", &PythonParameterSet::addParameters) - .def("getVInputTag", &PythonParameterSet::getParameters) - .def("addESInputTag", &PythonParameterSet::addParameter) - .def("getESInputTag", &PythonParameterSet::getParameter) - .def("addVESInputTag", &PythonParameterSet::addParameters) - .def("getVESInputTag", &PythonParameterSet::getParameters) - .def("addEventID", &PythonParameterSet::addParameter) - .def("getEventID", &PythonParameterSet::getParameter) - .def("addVEventID", &PythonParameterSet::addParameters) - .def("getVEventID", &PythonParameterSet::getParameters) - .def("addLuminosityBlockID", &PythonParameterSet::addParameter) - .def("getLuminosityBlockID", &PythonParameterSet::getParameter) - .def("addVLuminosityBlockID", &PythonParameterSet::addParameters) - .def("getVLuminosityBlockID", &PythonParameterSet::getParameters) - .def("addLuminosityBlockRange", &PythonParameterSet::addParameter) - .def("getLuminosityBlockRange", &PythonParameterSet::getParameter) - .def("addVLuminosityBlockRange", &PythonParameterSet::addParameters) - .def("getVLuminosityBlockRange", &PythonParameterSet::getParameters) - .def("addEventRange", &PythonParameterSet::addParameter) - .def("getEventRange", &PythonParameterSet::getParameter) - .def("addVEventRange", &PythonParameterSet::addParameters) - .def("getVEventRange", &PythonParameterSet::getParameters) - .def("addPSet", &PythonParameterSet::addPSet) - .def("getPSet", &PythonParameterSet::getPSet) - .def("addVPSet", &PythonParameterSet::addVPSet) - .def("getVPSet", &PythonParameterSet::getVPSet) - .def("addFileInPath", &PythonParameterSet::addParameter) - .def("getFileInPath", &PythonParameterSet::getParameter) - .def("newInputTag", &PythonParameterSet::newInputTag) - .def("newESInputTag", &PythonParameterSet::newESInputTag) - .def("newEventID", &PythonParameterSet::newEventID) - .def("newLuminosityBlockID", &PythonParameterSet::newLuminosityBlockID) - .def("newLuminosityBlockRange", &PythonParameterSet::newLuminosityBlockRange) - .def("newEventRange", &PythonParameterSet::newEventRange) - .def("addNewFileInPath", &PythonParameterSet::addNewFileInPath) - .def("newPSet", &PythonParameterSet::newPSet) - .def("dump", &PythonParameterSet::dump) - ; - - boost::python::class_("ProcessDesc", boost::python::init<>()) - .def(boost::python::init()) - .def("newPSet", &PythonProcessDesc::newPSet) - .def("pset", &PythonProcessDesc::pset, boost::python::return_value_policy()) - .def("dump", &PythonProcessDesc::dump) - ; -} -#endif diff --git a/FWCore/PythonParameterSet/src/PythonParameterSet.cc b/FWCore/PythonParameterSet/src/PythonParameterSet.cc deleted file mode 100644 index 15e8dd475011d..0000000000000 --- a/FWCore/PythonParameterSet/src/PythonParameterSet.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "FWCore/PythonParameterSet/interface/PythonParameterSet.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" - -PythonParameterSet::PythonParameterSet() -: theParameterSet() -{ -} - - -void PythonParameterSet::addVPSet(bool tracked, std::string const& name, - boost::python::list value) -{ - std::vector v - = edm::toVector(value); - std::vector v2; - v2.reserve(v.size()); - for(std::vector::iterator ppsetItr = v.begin(), ppsetItrEnd = v.end(); - ppsetItr != ppsetItrEnd; ++ppsetItr) - { - v2.push_back(ppsetItr->theParameterSet); - } - addParameter(tracked, name, v2); -} - - -boost::python::list PythonParameterSet::getVPSet(bool tracked, std::string const& name) -{ - std::vector const& v = - (tracked ? theParameterSet.getParameterSetVector(name) : theParameterSet.getUntrackedParameterSetVector(name)); - - // convert to PythonParameterSets - boost::python::list l; - for(std::vector::const_iterator psetItr = v.begin(), psetItrEnd = v.end(); - psetItr != psetItrEnd; ++psetItr) - { - l.append(PythonParameterSet(*psetItr)); - } - - return l; -} - - -void PythonParameterSet::addNewFileInPath(bool tracked, std::string const & name, std::string const & value) -{ - addParameter(tracked, name, edm::FileInPath(value)); -} diff --git a/FWCore/PythonParameterSet/src/PythonProcessDesc.cc b/FWCore/PythonParameterSet/src/PythonProcessDesc.cc deleted file mode 100644 index d048fdafb14cc..0000000000000 --- a/FWCore/PythonParameterSet/src/PythonProcessDesc.cc +++ /dev/null @@ -1,99 +0,0 @@ -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ParameterSet/interface/ProcessDesc.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" -#include "FWCore/PythonParameterSet/src/initializeModule.h" -#include "FWCore/PythonParameterSet/src/PythonWrapper.h" - -#include - -using namespace boost::python; - -PythonProcessDesc::PythonProcessDesc() : - theProcessPSet(), - theMainModule(), - theMainNamespace() { -} - -PythonProcessDesc::PythonProcessDesc(std::string const& config) : - theProcessPSet(), - theMainModule(), - theMainNamespace() { - prepareToRead(); - read(config); - Py_Finalize(); -} - -PythonProcessDesc::PythonProcessDesc(std::string const& config, int argc, char* argv[]) : - theProcessPSet(), - theMainModule(), - theMainNamespace() { - prepareToRead(); - PySys_SetArgv(argc, argv); - read(config); - Py_Finalize(); -} - -void PythonProcessDesc::prepareToRead() { - edm::python::initializeModule(); - - theMainModule = object(handle<>(borrowed(PyImport_AddModule(const_cast("__main__"))))); - - theMainNamespace = theMainModule.attr("__dict__"); - theMainNamespace["processDesc"] = ptr(this); - theMainNamespace["processPSet"] = ptr(&theProcessPSet); -} - -void PythonProcessDesc::read(std::string const& config) { - try { - // if it ends with py, it's a file - if(config.substr(config.size()-3) == ".py") { - readFile(config); - } else { - readString(config); - } - } - catch(error_already_set const&) { - edm::pythonToCppException("Configuration"); - Py_Finalize(); - } -} - -void PythonProcessDesc::readFile(std::string const& fileName) { - std::string initCommand("import FWCore.ParameterSet.Config as cms\n" - "execfile('"); - initCommand += fileName + "')"; - - handle<>(PyRun_String(initCommand.c_str(), - Py_file_input, - theMainNamespace.ptr(), - theMainNamespace.ptr())); - std::string command("process.fillProcessDesc(processPSet)"); - handle<>(PyRun_String(command.c_str(), - Py_eval_input, - theMainNamespace.ptr(), - theMainNamespace.ptr())); -} - -void PythonProcessDesc::readString(std::string const& pyConfig) { - std::string command = pyConfig; - command += "\nprocess.fillProcessDesc(processPSet)"; - handle<>(PyRun_String(command.c_str(), - Py_file_input, - theMainNamespace.ptr(), - theMainNamespace.ptr())); -} - -std::unique_ptr PythonProcessDesc::parameterSet() const { - return std::make_unique(theProcessPSet.pset()); -} - -std::string PythonProcessDesc::dump() const { - std::ostringstream os; - os << theProcessPSet.dump(); - return os.str(); -} - -// For backward compatibility only. Remove when no longer used. -std::shared_ptr PythonProcessDesc::processDesc() const { - return std::make_shared(parameterSet()); -} diff --git a/FWCore/PythonParameterSet/src/PythonWrapper.cc b/FWCore/PythonParameterSet/src/PythonWrapper.cc deleted file mode 100644 index d1d58618d1df2..0000000000000 --- a/FWCore/PythonParameterSet/src/PythonWrapper.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "FWCore/PythonParameterSet/src/PythonWrapper.h" -#include "FWCore/Utilities/interface/Exception.h" -//#include -namespace edm { - -void pythonToCppException(const std::string& iType) - { - using namespace boost::python; - PyObject *exc=nullptr, *val=nullptr, *trace=nullptr; - PyErr_Fetch(&exc,&val,&trace); - PyErr_NormalizeException(&exc,&val,&trace); - handle<> hExc(allow_null(exc)); - handle<> hVal(allow_null(val)); - handle<> hTrace(allow_null(trace)); - - if(hTrace) { - object oTrace(hTrace); - handle<> hStringTr(PyObject_Str(oTrace.ptr())); - object stringTr(hStringTr); -//std::cout << "PR TR " << stringTr << " DONE "<< std::endl; - } - - if(hVal && hExc) { - object oExc(hExc); - object oVal(hVal); - handle<> hStringVal(PyObject_Str(oVal.ptr())); - object stringVal( hStringVal ); - - handle<> hStringExc(PyObject_Str(oExc.ptr())); - object stringExc( hStringExc); - - //PyErr_Print(); - throw cms::Exception(iType) - << "python encountered the error: " - // include python exception type - << PyString_AsString(stringExc.ptr()) << "\n" - // message in the python exception - << PyString_AsString(stringVal.ptr()) << "\n"; - } else { - throw cms::Exception(iType)<<" unknown python problem occurred.\n"; - } -} - -} - - diff --git a/FWCore/PythonParameterSet/src/PythonWrapper.h b/FWCore/PythonParameterSet/src/PythonWrapper.h deleted file mode 100644 index b66577d090bcf..0000000000000 --- a/FWCore/PythonParameterSet/src/PythonWrapper.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef FWCore_PythonParameterSet_PythonWrapper_h -#define FWCore_PythonParameterSet_PythonWrapper_h - -#include -#include -#include "FWCore/PythonParameterSet/interface/BoostPython.h" - -namespace edm { -void -pythonToCppException(const std::string& iType); - -// boost::python::list toPythonList(const std::vector & v); - // utility to translate from an STL vector of strings to - // a Python list - template - boost::python::list toPythonList(const std::vector & v) { - boost::python::list result; - for(unsigned i = 0; i < v.size(); ++i) { - result.append(v[i]); - } - return result; - } - - - - // and back. Destroys the input via pop()s - template - std::vector toVector(boost::python::list & l) - { - std::vector result; - unsigned n = PyList_Size(l.ptr()); - boost::python::object iter_obj(boost::python::handle<>(PyObject_GetIter(l.ptr()))); - for(unsigned i = 0; i < n; ++i) - { - boost::python::object obj = boost::python::extract(iter_obj.attr("next")()); - result.push_back(boost::python::extract(obj)); - } - return result; - } -} - -#endif diff --git a/FWCore/PythonParameterSet/src/initializeModule.cc b/FWCore/PythonParameterSet/src/initializeModule.cc deleted file mode 100644 index 27d89ab4aeb8e..0000000000000 --- a/FWCore/PythonParameterSet/src/initializeModule.cc +++ /dev/null @@ -1,39 +0,0 @@ -// -*- C++ -*- -// -// Package: PythonParameterSet -// Class : initializeModule -// -// Implementation: -// [Notes on implementation] -// -// Original Author: Chris Jones -// Created: Tue Jan 11 11:05:58 CST 2011 -// - -// system include files - -// user include files -#include "FWCore/PythonParameterSet/src/initializeModule.h" -#include "FWCore/PythonParameterSet/src/PythonModule.h" - - -// -// constants, enums and typedefs -// -static bool s_initialized = false; - -namespace edm { - namespace python { - void initializeModule() { - char *libFWCoreParameterSet = const_cast("libFWCorePythonParameterSet"); - PyImport_AppendInittab(libFWCoreParameterSet, &initlibFWCorePythonParameterSet ); - Py_Initialize(); - if(!s_initialized) - { - PyImport_ImportModule(libFWCoreParameterSet); - s_initialized = true; - } - - } - } -} diff --git a/FWCore/PythonParameterSet/src/initializeModule.h b/FWCore/PythonParameterSet/src/initializeModule.h deleted file mode 100644 index 56f254462af6d..0000000000000 --- a/FWCore/PythonParameterSet/src/initializeModule.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef FWCore_PythonParameterSet_initializeModule_h -#define FWCore_PythonParameterSet_initializeModule_h -// -*- C++ -*- -// -// Package: PythonParameterSet -// Class : initializeModule -// -/**\class initializeModule initializeModule.h FWCore/PythonParameterSet/interface/initializeModule.h - - Description: Function used to initialize access to the PythonParameterSet module - - Usage: - - -*/ -// -// Original Author: Chris Jones -// Created: Tue Jan 11 11:05:56 CST 2011 -// - -// system include files - -// user include files - -// forward declarations -namespace edm { - namespace python { - void initializeModule(); - } -} - - -#endif diff --git a/FWCore/PythonParameterSet/src/pythonFileToConfigure.cc b/FWCore/PythonParameterSet/src/pythonFileToConfigure.cc deleted file mode 100644 index 79c2d76ae6480..0000000000000 --- a/FWCore/PythonParameterSet/src/pythonFileToConfigure.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * pythonToConfigure.cpp - * CMSSW - * - * Created by Chris Jones on 10/3/06. - * - */ - -#include "FWCore/PythonParameterSet/interface/pythonFileToConfigure.h" -#include "FWCore/PythonParameterSet/interface/BoostPython.h" -#include "FWCore/PythonParameterSet/src/PythonWrapper.h" - - -std::string edm::pythonFileToConfigure(const std::string& iPythonFileName) -{ - std::string returnValue; - std::string initCommand("import FWCore.ParameterSet.Config as cms\n" - "fileDict = dict()\n" - "execfile('"); - initCommand += iPythonFileName+"',fileDict)"; - - Py_InitializeEx(0); - using namespace boost::python; - - object main_module(( - boost::python::handle(borrowed(PyImport_AddModule(const_cast("__main__")))))); - object main_namespace = main_module.attr("__dict__"); - try { - try { - object result((boost::python::handle<>(PyRun_String(initCommand.c_str(), - Py_file_input, - main_namespace.ptr(), - main_namespace.ptr())))); - } catch(error_already_set const&) { - edm::pythonToCppException("Configuration"); - } - try { - std::string command("cms.findProcess(fileDict).dumpConfig()"); - object result((handle<>(PyRun_String(command.c_str(), - Py_eval_input, - main_namespace.ptr(), - main_namespace.ptr())))); - returnValue= extract(result); - - }catch( error_already_set const& ) { - edm::pythonToCppException("Configuration"); - } - }catch(...) { - Py_Finalize(); - throw; - } - Py_Finalize(); - return returnValue; -} diff --git a/FWCore/PythonParameterSet/test/BuildFile.xml b/FWCore/PythonParameterSet/test/BuildFile.xml deleted file mode 100644 index 851253e1e6df7..0000000000000 --- a/FWCore/PythonParameterSet/test/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/FWCore/PythonParameterSet/test/fip.txt b/FWCore/PythonParameterSet/test/fip.txt deleted file mode 100644 index a52b9dba51d13..0000000000000 --- a/FWCore/PythonParameterSet/test/fip.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy file for the FileInPath test. diff --git a/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc b/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc deleted file mode 100644 index 3a6300a5eb454..0000000000000 --- a/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc +++ /dev/null @@ -1,802 +0,0 @@ -/* - * makeprocess_t.cc - * EDMProto - * - * Created by Chris Jones on 5/18/05. - * - */ - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -class testmakeprocess: public CppUnit::TestFixture { -CPPUNIT_TEST_SUITE(testmakeprocess); -CPPUNIT_TEST(simpleProcessTest); -CPPUNIT_TEST(usingTest); -CPPUNIT_TEST(pathTest); -CPPUNIT_TEST(moduleTest); -CPPUNIT_TEST(emptyModuleTest); -CPPUNIT_TEST(taskTest); -CPPUNIT_TEST(taskTestWithEmptySchedule); -CPPUNIT_TEST(taskTestWithSchedule); -//CPPUNIT_TEST(windowsLineEndingTest); -//CPPUNIT_TEST_EXCEPTION(emptyPsetTest,edm::Exception); -CPPUNIT_TEST_SUITE_END(); -public: - void setUp(){} - void tearDown(){} - void simpleProcessTest(); - void usingTest(); - void pathTest(); - void moduleTest(); - void emptyModuleTest(); - void taskTest(); - void taskTestWithEmptySchedule(); - void taskTestWithSchedule(); - //void windowsLineEndingTest(); -private: - - typedef std::shared_ptr ParameterSetPtr; - ParameterSetPtr pSet(char const* c) { - - //ParameterSetPtr result( new edm::ProcessDesc(std::string(c)) ); - ParameterSetPtr result = PythonProcessDesc(std::string(c)).parameterSet(); - CPPUNIT_ASSERT(result->getParameter("@process_name") == "test"); - return result; - } - // void emptyPsetTest(); -}; - -///registration of the test so that the runner can find it -CPPUNIT_TEST_SUITE_REGISTRATION(testmakeprocess); - -void testmakeprocess::simpleProcessTest() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "dummy = cms.PSet(b = cms.bool(True))\n"; - ParameterSetPtr test = pSet(kTest); -} - -void testmakeprocess::usingTest() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.dummy = cms.PSet(\n" - " b = cms.bool(True)\n" - ")\n" - "process.dummy2 = cms.PSet(\n" - " d = cms.bool(True)\n" - ")\n" - "process.m1 = cms.EDFilter('Dummy',\n" - " process.dummy\n" - ")\n" - "process.m2 = cms.EDFilter('Dummy2',\n" - " process.dummy2\n" - ")\n" - "process.p = cms.Path(process.m1+process.m2)\n"; - - ParameterSetPtr test = pSet(kTest); - - //CPPUNIT_ASSERT(test->getParameterSet("dummy").getBool("b") == true); - CPPUNIT_ASSERT(test->getParameterSet("m1").getParameter("b") == true); - CPPUNIT_ASSERT(test->getParameterSet("m2").getParameter("d") == true); -} - -void testmakeprocess::pathTest() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone5 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(5)\n" - ")\n" - "process.cone7 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.jtanalyzer = cms.EDAnalyzer('jtanalyzer')\n" - "process.writer = cms.OutputModule('Writer')\n" - "process.cones = cms.Sequence(process.cone5*process.cone7)\n" - "process.term1 = cms.Path(process.cones+process.jtanalyzer)\n" - "process.atEnd = cms.EndPath(process.writer)\n"; - - - ParameterSetPtr test = pSet(kTest); - //CPPUNIT_ASSERT(test->pathFragments().size() == 5); - - edm::ParameterSet& myparams = *(test); - myparams.registerIt(); -// std::cout << "ParameterSet looks like:\n"; -// std::cout << myparams.toString() << std::endl; - std::string rep = myparams.toString(); - edm::ParameterSet copy(rep); - CPPUNIT_ASSERT(copy == myparams); -} - - -edm::ParameterSet modulePSet(std::string const& iLabel, std::string const& iType, std::string const& iCppType) { - edm::ParameterSet temp; - temp.addParameter("s", 1); - temp.addParameter("@module_label", iLabel); - temp.addParameter("@module_type", iType); - temp.addParameter("@module_edm_type", iCppType); - return temp; -} - -void testmakeprocess::moduleTest() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cones = cms.EDFilter('Module',\n" - " s = cms.int32(1)\n" - ")\n" - "process.NoLabelModule = cms.ESProducer('NoLabelModule',\n" - " s = cms.int32(1)\n" - ")\n" - "process.labeled = cms.ESProducer('LabelModule',\n" - " s = cms.int32(1)\n" - ")\n" - "process.source = cms.Source('InputSource',\n" - " s = cms.int32(1)\n" - ")\n" - "process.NoLabelRetriever = cms.ESSource('NoLabelRetriever',\n" - " s = cms.int32(1)\n" - ")\n" - "process.label = cms.ESSource('LabelRetriever',\n" - " s = cms.int32(1)\n" - ")\n" - "process.p = cms.Path(process.cones)\n"; - - - ParameterSetPtr test = pSet(kTest); - - static edm::ParameterSet const kEmpty; - edm::ParameterSet const kCone(modulePSet("cones", "Module","EDFilter")); - std::ostringstream out; - out << kCone.toString() << std::endl; - out << test->getParameterSet("cones").toString() << std::endl; - - edm::ParameterSet const kMainInput(modulePSet("@main_input","InputSource","Source")); - - edm::ParameterSet const kNoLabelModule(modulePSet("", "NoLabelModule","ESProducer")); - edm::ParameterSet const kLabelModule(modulePSet("labeled", "LabelModule","ESProducer")); - edm::ParameterSet const kNoLabelRetriever(modulePSet("", "NoLabelRetriever","ESSource")); - edm::ParameterSet const kLabelRetriever(modulePSet("label", "LabelRetriever","ESSource")); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("cones"))); - CPPUNIT_ASSERT(kCone == test->getParameterSet("cones")); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("@main_input"))); - CPPUNIT_ASSERT(kMainInput == (test->getParameterSet("@main_input"))); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("NoLabelModule@"))); - CPPUNIT_ASSERT(kNoLabelModule == test->getParameterSet("NoLabelModule@")); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("LabelModule@labeled"))); - CPPUNIT_ASSERT(kLabelModule == test->getParameterSet("LabelModule@labeled")); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("NoLabelRetriever@"))); - CPPUNIT_ASSERT(kNoLabelRetriever == test->getParameterSet("NoLabelRetriever@")); - - CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("LabelRetriever@label"))); - CPPUNIT_ASSERT(kLabelRetriever == test->getParameterSet("LabelRetriever@label")); -} - -void testmakeprocess::emptyModuleTest() { - char const* kTest = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.thing = cms.EDFilter('XX')\n" - "process.p = cms.Path(process.thing)\n"; - - ParameterSetPtr test = pSet(kTest); - - edm::ParameterSet& myparams = *(test); - myparams.registerIt(); -// std::cout << "ParameterSet looks like:\n"; -// std::cout << myparams.toString() << std::endl; - std::string rep = myparams.toString(); - edm::ParameterSet copy(rep); - CPPUNIT_ASSERT(copy == myparams); -} - -void testmakeprocess::taskTest() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" - "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," - "process.ess27, process.ess28, process.esp27, process.esp28," - "process.serv27, process.serv28)\n"; - - ParameterSetPtr test = pSet(kTest); - - //std::cout << "Dumping parameter names\n"; - //std::vector names = test->getParameterNames(); - //std::sort(names.begin(), names.end()); - //for (auto const& name : names) { - // std::cout << name << std::endl; - //} - - CPPUNIT_ASSERT(!test->existsAs("m1") && - !test->existsAs("m2") && - test->existsAs("m3") && - test->existsAs("m4") && - test->existsAs("m5") && - test->existsAs("m6") && - test->existsAs("m7") && - test->existsAs("m8") && - test->existsAs("m9") && - test->existsAs("m10") && - test->existsAs("m11") && - test->existsAs("m12") && - test->existsAs("m13") && - test->existsAs("m14") && - test->existsAs("m15") && - test->existsAs("m16") && - test->existsAs("m17") && - test->existsAs("m18") && - test->existsAs("m19") && - test->existsAs("m20") && - test->existsAs("m21") && - test->existsAs("m22") && - test->existsAs("m23") && - test->existsAs("m24") && - test->existsAs("m25") && - test->existsAs("m26") && - !test->existsAs("m27") && - !test->existsAs("m28") && - !test->existsAs("m29") && - !test->existsAs("m30")); - - CPPUNIT_ASSERT(!test->existsAs("f1") && - !test->existsAs("f2") && - test->existsAs("f3") && - test->existsAs("f4") && - test->existsAs("f5") && - test->existsAs("f6") && - test->existsAs("f7") && - test->existsAs("f8") && - test->existsAs("f9") && - test->existsAs("f10") && - test->existsAs("f11") && - test->existsAs("f12") && - test->existsAs("f13") && - test->existsAs("f14") && - test->existsAs("f15") && - test->existsAs("f16") && - test->existsAs("f17") && - test->existsAs("f18") && - test->existsAs("f19") && - test->existsAs("f20") && - test->existsAs("f21") && - test->existsAs("f22") && - test->existsAs("f23") && - test->existsAs("f24") && - test->existsAs("f25") && - test->existsAs("f26") && - !test->existsAs("f27") && - !test->existsAs("f28") && - !test->existsAs("f29") && - !test->existsAs("f30")); - - CPPUNIT_ASSERT(!test->existsAs("a1") && - !test->existsAs("a2") && - test->existsAs("a3") && - test->existsAs("a4") && - test->existsAs("a5") && - test->existsAs("a6") && - test->existsAs("a7") && - test->existsAs("a8") && - test->existsAs("a9") && - test->existsAs("a10")); - - CPPUNIT_ASSERT(!test->existsAs("o1") && - !test->existsAs("o2") && - test->existsAs("o7") && - test->existsAs("o8") && - test->existsAs("o9") && - test->existsAs("o10")); - - CPPUNIT_ASSERT(test->existsAs("ess@ess1") && - test->existsAs("ess2@") && - !test->existsAs("ess@ess3") && - !test->existsAs("ess4@") && - test->existsAs("ess@ess11") && - test->existsAs("ess12@") && - test->existsAs("ess@ess13") && - test->existsAs("ess14@") && - test->existsAs("ess@ess15") && - test->existsAs("ess16@") && - test->existsAs("ess@ess17") && - test->existsAs("ess18@") && - test->existsAs("ess@ess19") && - test->existsAs("ess20@") && - test->existsAs("ess@ess21") && - test->existsAs("ess22@") && - test->existsAs("ess@ess23") && - test->existsAs("ess24@") && - test->existsAs("ess@ess25") && - test->existsAs("ess26@") && - test->existsAs("ess@ess27") && - test->existsAs("ess28@")); - - CPPUNIT_ASSERT(test->existsAs("esp@esp1") && - test->existsAs("esp2@") && - !test->existsAs("esp@esp3") && - !test->existsAs("esp4@") && - test->existsAs("esp@esp11") && - test->existsAs("esp12@") && - test->existsAs("esp@esp13") && - test->existsAs("esp14@") && - test->existsAs("esp@esp15") && - test->existsAs("esp16@") && - test->existsAs("esp@esp17") && - test->existsAs("esp18@") && - test->existsAs("esp@esp19") && - test->existsAs("esp20@") && - test->existsAs("esp@esp21") && - test->existsAs("esp22@") && - test->existsAs("esp@esp23") && - test->existsAs("esp24@") && - test->existsAs("esp@esp25") && - test->existsAs("esp26@") && - test->existsAs("esp@esp27") && - test->existsAs("esp28@")); - - std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); - // Note that the vector is not sorted. The order - // depends on the order of a python iteration through a dictionary - // which could be anything. - std::set serviceNames; - for (auto const& pset : vpsetServices) { - serviceNames.insert(pset.getParameter("@service_type")); - // std::cout << "serviceName = " << pset.getParameter("@service_type") << std::endl; - } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv11"); - expectedServiceNames.emplace_back("serv12"); - expectedServiceNames.emplace_back("serv13"); - expectedServiceNames.emplace_back("serv14"); - expectedServiceNames.emplace_back("serv15"); - expectedServiceNames.emplace_back("serv16"); - expectedServiceNames.emplace_back("serv17"); - expectedServiceNames.emplace_back("serv18"); - expectedServiceNames.emplace_back("serv19"); - expectedServiceNames.emplace_back("serv20"); - expectedServiceNames.emplace_back("serv21"); - expectedServiceNames.emplace_back("serv22"); - expectedServiceNames.emplace_back("serv23"); - expectedServiceNames.emplace_back("serv24"); - expectedServiceNames.emplace_back("serv25"); - expectedServiceNames.emplace_back("serv26"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); - bool result = true; - for (auto const& name : expectedServiceNames) { - if (serviceNames.find(name) == serviceNames.end()) { - result = false; - } - } - if (serviceNames.size() != expectedServiceNames.size()) { - result = false; - } - CPPUNIT_ASSERT(result); -} - -void testmakeprocess::taskTestWithEmptySchedule() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" - "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," - "process.ess27, process.ess28, process.esp27, process.esp28," - "process.serv27, process.serv28)\n" - "process.schedule = cms.Schedule()\n"; - - ParameterSetPtr test = pSet(kTest); - - //std::cout << "Dumping parameter names\n"; - //std::vector names = test->getParameterNames(); - //std::sort(names.begin(), names.end()); - //for (auto const& name : names) { - // std::cout << name << std::endl; - //} - - CPPUNIT_ASSERT(!test->existsAs("m1") && - !test->existsAs("m2") && - !test->existsAs("m3") && - !test->existsAs("m4") && - !test->existsAs("m5") && - !test->existsAs("m6") && - !test->existsAs("m7") && - !test->existsAs("m8") && - !test->existsAs("m9") && - !test->existsAs("m10") && - !test->existsAs("m11") && - !test->existsAs("m12") && - !test->existsAs("m13") && - !test->existsAs("m14") && - !test->existsAs("m15") && - !test->existsAs("m16") && - !test->existsAs("m17") && - !test->existsAs("m18") && - !test->existsAs("m19") && - !test->existsAs("m20") && - !test->existsAs("m21") && - !test->existsAs("m22") && - !test->existsAs("m23") && - !test->existsAs("m24") && - !test->existsAs("m25") && - !test->existsAs("m26") && - !test->existsAs("m27") && - !test->existsAs("m28") && - !test->existsAs("m29") && - !test->existsAs("m30")); - - CPPUNIT_ASSERT(!test->existsAs("f1") && - !test->existsAs("f2") && - !test->existsAs("f3") && - !test->existsAs("f4") && - !test->existsAs("f5") && - !test->existsAs("f6") && - !test->existsAs("f7") && - !test->existsAs("f8") && - !test->existsAs("f9") && - !test->existsAs("f10") && - !test->existsAs("f11") && - !test->existsAs("f12") && - !test->existsAs("f13") && - !test->existsAs("f14") && - !test->existsAs("f15") && - !test->existsAs("f16") && - !test->existsAs("f17") && - !test->existsAs("f18") && - !test->existsAs("f19") && - !test->existsAs("f20") && - !test->existsAs("f21") && - !test->existsAs("f22") && - !test->existsAs("f23") && - !test->existsAs("f24") && - !test->existsAs("f25") && - !test->existsAs("f26") && - !test->existsAs("f27") && - !test->existsAs("f28") && - !test->existsAs("f29") && - !test->existsAs("f30")); - - CPPUNIT_ASSERT(!test->existsAs("a1") && - !test->existsAs("a2") && - !test->existsAs("a3") && - !test->existsAs("a4") && - !test->existsAs("a5") && - !test->existsAs("a6") && - !test->existsAs("a7") && - !test->existsAs("a8") && - !test->existsAs("a9") && - !test->existsAs("a10")); - - CPPUNIT_ASSERT(!test->existsAs("o1") && - !test->existsAs("o2") && - !test->existsAs("o7") && - !test->existsAs("o8") && - !test->existsAs("o9") && - !test->existsAs("o10")); - - CPPUNIT_ASSERT(test->existsAs("ess@ess1") && - test->existsAs("ess2@") && - !test->existsAs("ess@ess3") && - !test->existsAs("ess4@") && - !test->existsAs("ess@ess11") && - !test->existsAs("ess12@") && - !test->existsAs("ess@ess13") && - !test->existsAs("ess14@") && - !test->existsAs("ess@ess15") && - !test->existsAs("ess16@") && - !test->existsAs("ess@ess17") && - !test->existsAs("ess18@") && - !test->existsAs("ess@ess19") && - !test->existsAs("ess20@") && - !test->existsAs("ess@ess21") && - !test->existsAs("ess22@") && - !test->existsAs("ess@ess23") && - !test->existsAs("ess24@") && - !test->existsAs("ess@ess25") && - !test->existsAs("ess26@") && - test->existsAs("ess@ess27") && - test->existsAs("ess28@")); - - CPPUNIT_ASSERT(test->existsAs("esp@esp1") && - test->existsAs("esp2@") && - !test->existsAs("esp@esp3") && - !test->existsAs("esp4@") && - !test->existsAs("esp@esp11") && - !test->existsAs("esp12@") && - !test->existsAs("esp@esp13") && - !test->existsAs("esp14@") && - !test->existsAs("esp@esp15") && - !test->existsAs("esp16@") && - !test->existsAs("esp@esp17") && - !test->existsAs("esp18@") && - !test->existsAs("esp@esp19") && - !test->existsAs("esp20@") && - !test->existsAs("esp@esp21") && - !test->existsAs("esp22@") && - !test->existsAs("esp@esp23") && - !test->existsAs("esp24@") && - !test->existsAs("esp@esp25") && - !test->existsAs("esp26@") && - test->existsAs("esp@esp27") && - test->existsAs("esp28@")); - - std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); - // Note that the vector is not sorted. The order - // depends on the order of a python iteration through a dictionary - // which could be anything. - std::set serviceNames; - for (auto const& pset : vpsetServices) { - serviceNames.insert(pset.getParameter("@service_type")); - // std::cout << "serviceName = " << pset.getParameter("@service_type") << std::endl; - } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); - bool result = true; - for (auto const& name : expectedServiceNames) { - if (serviceNames.find(name) == serviceNames.end()) { - result = false; - } - } - if (serviceNames.size() != expectedServiceNames.size()) { - result = false; - } - CPPUNIT_ASSERT(result); -} - -void testmakeprocess::taskTestWithSchedule() { - char const* kTest = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" - "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," - "process.ess27, process.ess28, process.esp27, process.esp28," - "process.serv27, process.serv28)\n" - "process.schedule = cms.Schedule(process.p1, process.p2, process.e1, process.e2," - "process.pf1, process.pf2, process.ef1, process.ef2," - "process.pa1, process.pa2, process.ea1, process.ea2," - "process.eo1, process.eo2, process.pess2, process.eess2," - "process.pesp2, process.eesp2, process.pserv2, process.eserv2," - "tasks=[process.t9, process.tf9, process.tess10,process.tesp10," - "process.tserv10])\n"; - - ParameterSetPtr test = pSet(kTest); - - //std::cout << "Dumping parameter names\n"; - //std::vector names = test->getParameterNames(); - //std::sort(names.begin(), names.end()); - //for (auto const& name : names) { - // std::cout << name << std::endl; - //} - - CPPUNIT_ASSERT(!test->existsAs("m1") && - !test->existsAs("m2") && - test->existsAs("m3") && - test->existsAs("m4") && - test->existsAs("m5") && - test->existsAs("m6") && - test->existsAs("m7") && - test->existsAs("m8") && - test->existsAs("m9") && - test->existsAs("m10") && - test->existsAs("m11") && - test->existsAs("m12") && - test->existsAs("m13") && - test->existsAs("m14") && - test->existsAs("m15") && - test->existsAs("m16") && - test->existsAs("m17") && - test->existsAs("m18") && - test->existsAs("m19") && - test->existsAs("m20") && - test->existsAs("m21") && - test->existsAs("m22") && - test->existsAs("m23") && - test->existsAs("m24") && - test->existsAs("m25") && - test->existsAs("m26") && - test->existsAs("m27") && - test->existsAs("m28") && - !test->existsAs("m29") && - !test->existsAs("m30")); - - CPPUNIT_ASSERT(!test->existsAs("f1") && - !test->existsAs("f2") && - test->existsAs("f3") && - test->existsAs("f4") && - test->existsAs("f5") && - test->existsAs("f6") && - test->existsAs("f7") && - test->existsAs("f8") && - test->existsAs("f9") && - test->existsAs("f10") && - test->existsAs("f11") && - test->existsAs("f12") && - test->existsAs("f13") && - test->existsAs("f14") && - test->existsAs("f15") && - test->existsAs("f16") && - test->existsAs("f17") && - test->existsAs("f18") && - test->existsAs("f19") && - test->existsAs("f20") && - test->existsAs("f21") && - test->existsAs("f22") && - test->existsAs("f23") && - test->existsAs("f24") && - test->existsAs("f25") && - test->existsAs("f26") && - test->existsAs("f27") && - test->existsAs("f28") && - !test->existsAs("f29") && - !test->existsAs("f30")); - - CPPUNIT_ASSERT(!test->existsAs("a1") && - !test->existsAs("a2") && - test->existsAs("a3") && - test->existsAs("a4") && - test->existsAs("a5") && - test->existsAs("a6") && - test->existsAs("a7") && - test->existsAs("a8") && - test->existsAs("a9") && - test->existsAs("a10")); - - CPPUNIT_ASSERT(!test->existsAs("o1") && - !test->existsAs("o2") && - test->existsAs("o7") && - test->existsAs("o8") && - test->existsAs("o9") && - test->existsAs("o10")); - - CPPUNIT_ASSERT(test->existsAs("ess@ess1") && - test->existsAs("ess2@") && - test->existsAs("ess@ess3") && - test->existsAs("ess4@") && - test->existsAs("ess@ess11") && - test->existsAs("ess12@") && - test->existsAs("ess@ess13") && - test->existsAs("ess14@") && - test->existsAs("ess@ess15") && - test->existsAs("ess16@") && - test->existsAs("ess@ess17") && - test->existsAs("ess18@") && - test->existsAs("ess@ess19") && - test->existsAs("ess20@") && - test->existsAs("ess@ess21") && - test->existsAs("ess22@") && - test->existsAs("ess@ess23") && - test->existsAs("ess24@") && - test->existsAs("ess@ess25") && - test->existsAs("ess26@") && - test->existsAs("ess@ess27") && - test->existsAs("ess28@")); - - CPPUNIT_ASSERT(test->existsAs("esp@esp1") && - test->existsAs("esp2@") && - test->existsAs("esp@esp3") && - test->existsAs("esp4@") && - test->existsAs("esp@esp11") && - test->existsAs("esp12@") && - test->existsAs("esp@esp13") && - test->existsAs("esp14@") && - test->existsAs("esp@esp15") && - test->existsAs("esp16@") && - test->existsAs("esp@esp17") && - test->existsAs("esp18@") && - test->existsAs("esp@esp19") && - test->existsAs("esp20@") && - test->existsAs("esp@esp21") && - test->existsAs("esp22@") && - test->existsAs("esp@esp23") && - test->existsAs("esp24@") && - test->existsAs("esp@esp25") && - test->existsAs("esp26@") && - test->existsAs("esp@esp27") && - test->existsAs("esp28@")); - - std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); - // Note that the vector is not sorted. The order - // depends on the order of a python iteration through a dictionary - // which could be anything. - std::set serviceNames; - for (auto const& pset : vpsetServices) { - serviceNames.insert(pset.getParameter("@service_type")); - // std::cout << "serviceName = " << pset.getParameter("@service_type") << std::endl; - } - std::vector expectedServiceNames; - expectedServiceNames.emplace_back("serv1"); - expectedServiceNames.emplace_back("serv2"); - expectedServiceNames.emplace_back("serv3"); - expectedServiceNames.emplace_back("serv4"); - expectedServiceNames.emplace_back("serv11"); - expectedServiceNames.emplace_back("serv12"); - expectedServiceNames.emplace_back("serv13"); - expectedServiceNames.emplace_back("serv14"); - expectedServiceNames.emplace_back("serv15"); - expectedServiceNames.emplace_back("serv16"); - expectedServiceNames.emplace_back("serv17"); - expectedServiceNames.emplace_back("serv18"); - expectedServiceNames.emplace_back("serv19"); - expectedServiceNames.emplace_back("serv20"); - expectedServiceNames.emplace_back("serv21"); - expectedServiceNames.emplace_back("serv22"); - expectedServiceNames.emplace_back("serv23"); - expectedServiceNames.emplace_back("serv24"); - expectedServiceNames.emplace_back("serv25"); - expectedServiceNames.emplace_back("serv26"); - expectedServiceNames.emplace_back("serv27"); - expectedServiceNames.emplace_back("serv28"); - bool result = true; - for (auto const& name : expectedServiceNames) { - if (serviceNames.find(name) == serviceNames.end()) { - result = false; - } - } - if (serviceNames.size() != expectedServiceNames.size()) { - result = false; - } - CPPUNIT_ASSERT(result); -} - -/* -void testmakeprocess::windowsLineEndingTest() { - - std::ostringstream oss; - char const ret = '\r'; - char const nl = '\n'; - char const dquote = '"'; - char const backsl = '\\'; - - oss << ret << nl - << "import FWCore.ParameterSet.Config as cms" << ret << nl - << "process = cms.Process('test')" << ret << nl - << " source = cms.Source('InputSource'," << ret << nl - << " i=cms.int32(1)" << ret << nl - << " s1 = cms.string(" << dquote << ret << dquote << ')' <getProcessPSet()); - - edm::ParameterSet src = p.getParameterSet("@main_input"); - CPPUNIT_ASSERT(src.getParameter("i") == 1); - std::string s1 = src.getParameter("s1"); - std::string s2 = src.getParameter("s2"); - - std::cerr << "\nsize of s1 is: " << s1.size(); - std::cerr << "\nsize of s2 is: " << s2.size() << '\n'; - - CPPUNIT_ASSERT(s1.size() == 1); - CPPUNIT_ASSERT(s1[0] == ret); - - CPPUNIT_ASSERT(s2.size() == 2); - CPPUNIT_ASSERT(s2[0] == backsl); - CPPUNIT_ASSERT(s2[1] == 'r'); -} -*/ diff --git a/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc b/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc deleted file mode 100644 index 6ec76b54ef57a..0000000000000 --- a/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc +++ /dev/null @@ -1,506 +0,0 @@ -/* - * makepset_t.cc - * EDMProto - * - * Created by Chris Jones on 5/18/05. - * - */ - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" -#include "FWCore/Utilities/interface/EDMException.h" -#include "FWCore/Utilities/interface/resolveSymbolicLinks.h" - -#include "cppunit/extensions/HelperMacros.h" - -#include - -#include -#include -#include -#include // for setenv; is likely to fail -#include -#include -#include - -class testmakepset: public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(testmakepset); - CPPUNIT_TEST(typesTest); - CPPUNIT_TEST(secsourceTest); - CPPUNIT_TEST(usingBlockTest); - CPPUNIT_TEST(fileinpathTest); - CPPUNIT_TEST_SUITE_END(); - - public: - void setUp(){} - void tearDown(){} - void typesTest(); - void secsourceTest(); - void usingBlockTest(); - void fileinpathTest(); - - private: - void secsourceAux(); - void usingBlockAux(); - void fileinpathAux(); -}; - -///registration of the test so that the runner can find it -CPPUNIT_TEST_SUITE_REGISTRATION(testmakepset); - -void testmakepset::secsourceTest() { - try { this->secsourceAux(); } - catch (cms::Exception& x) { - std::cerr << "testmakepset::secsourceTest() caught a cms::Exception\n"; - std::cerr << x.what() << '\n'; - throw; - } - catch (std::exception& x) { - std::cerr << "testmakepset::secsourceTest() caught a std::exception\n"; - std::cerr << x.what() << '\n'; - throw; - } - catch (...) { - std::cerr << "testmakepset::secsourceTest() caught an unidentified exception\n"; - throw; - } -} - -void testmakepset::secsourceAux() { - char const* kTest = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('PROD')\n" - "process.maxEvents = cms.untracked.PSet(\n" - " input = cms.untracked.int32(2)\n" - ")\n" - "process.source = cms.Source('PoolSource',\n" - " fileNames = cms.untracked.vstring('file:main.root')\n" - ")\n" - "process.out = cms.OutputModule('PoolOutputModule',\n" - " fileName = cms.string('file:CumHits.root')\n" - ")\n" - "process.mix = cms.EDFilter('MixingModule',\n" - " input = cms.SecSource('EmbeddedRootSource',\n" - " fileNames = cms.untracked.vstring('file:pileup.root')\n" - " ),\n" - " max_bunch = cms.int32(3),\n" - " average_number = cms.double(14.3),\n" - " min_bunch = cms.int32(-5),\n" - " type = cms.string('fixed')\n" - ")\n" - "process.p = cms.Path(process.mix)\n" - "process.ep = cms.EndPath(process.out)\n"; - - std::string config(kTest); - - // Create the ParameterSet object from this configuration string. - PythonProcessDesc builder(config); - std::shared_ptr ps = builder.parameterSet(); - - CPPUNIT_ASSERT(nullptr != ps.get()); - - // Make sure this ParameterSet object has the right contents - edm::ParameterSet const& mixingModuleParams = ps->getParameterSet("mix"); - edm::ParameterSet const& secondarySourceParams = mixingModuleParams.getParameterSet("input"); - CPPUNIT_ASSERT(secondarySourceParams.getParameter("@module_type") == "EmbeddedRootSource"); - CPPUNIT_ASSERT(secondarySourceParams.getParameter("@module_label") == "input"); - CPPUNIT_ASSERT(secondarySourceParams.getUntrackedParameter >("fileNames")[0] == "file:pileup.root"); -} - -void testmakepset::usingBlockTest() { - try { this->usingBlockAux(); } - catch (cms::Exception& x) { - std::cerr << "testmakepset::usingBlockTest() caught a cms::Exception\n"; - std::cerr << x.what() << '\n'; - throw; - } - catch (...) { - std::cerr << "testmakepset::usingBlockTest() caught an unidentified exception\n"; - throw; - } -} - -void testmakepset::usingBlockAux() { - char const* kTest = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('PROD')\n" - "process.maxEvents = cms.untracked.PSet(\n" - " input = cms.untracked.int32(2)\n" - ")\n" - "process.source = cms.Source('PoolSource',\n" - " fileNames = cms.untracked.vstring('file:main.root')\n" - ")\n" - "process.b = cms.PSet(\n" - " s = cms.string('original'),\n" - " r = cms.double(1.5)\n" - ")\n" - "process.m1 = cms.EDFilter('Class1',\n" - " process.b,\n" - " i = cms.int32(1)\n" - ")\n" - "process.m2 = cms.EDFilter('Class2',\n" - " process.b,\n" - " i = cms.int32(2),\n" - " j = cms.int32(3),\n" - " u = cms.uint64(1011),\n" - " l = cms.int64(101010)\n" - ")\n" - "process.p = cms.Path(process.m1+process.m2)\n"; - - std::string config(kTest); - // Create the ParameterSet object from this configuration string. - PythonProcessDesc builder(config); - std::shared_ptr ps = builder.parameterSet(); - CPPUNIT_ASSERT(nullptr != ps.get()); - - // Make sure this ParameterSet object has the right contents - edm::ParameterSet const& m1Params = ps->getParameterSet("m1"); - edm::ParameterSet const& m2Params = ps->getParameterSet("m2"); - CPPUNIT_ASSERT(m1Params.getParameter("i") == 1); - CPPUNIT_ASSERT(m2Params.getParameter("i") == 2); - CPPUNIT_ASSERT(m2Params.getParameter("j") == 3); - CPPUNIT_ASSERT(m2Params.getParameter("l") == 101010); - CPPUNIT_ASSERT(m2Params.getParameter("u") == 1011); - - CPPUNIT_ASSERT(m1Params.getParameter("s") == "original"); - CPPUNIT_ASSERT(m2Params.getParameter("s") == "original"); - - CPPUNIT_ASSERT(m1Params.getParameter("r") == 1.5); - CPPUNIT_ASSERT(m2Params.getParameter("r") == 1.5); -} - -void testmakepset::fileinpathTest() { - try { this->fileinpathAux(); } - catch (cms::Exception& x) { - std::cerr << "testmakepset::fileinpathTest() caught a cms::Exception\n"; - std::cerr << x.what() << '\n'; - throw; - } - catch (...) { - std::cerr << "testmakepset::fileinpathTest() caught an unidentified exception\n"; - throw; - } -} - -void testmakepset::fileinpathAux() { - char const* kTest = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('PROD')\n" - "process.main = cms.PSet(\n" - " topo = cms.FileInPath('Geometry/TrackerSimData/data/trackersens.xml'),\n" - " fip = cms.FileInPath('FWCore/PythonParameterSet/test/fip.txt'),\n" - " ufip = cms.untracked.FileInPath('FWCore/PythonParameterSet/test/ufip.txt'),\n" - " extraneous = cms.int32(12)\n" - ")\n" - "process.source = cms.Source('EmptySource')\n"; - - std::string config(kTest); - - // Create the ParameterSet object from this configuration string. - PythonProcessDesc builder(config); - std::shared_ptr ps = builder.parameterSet(); - CPPUNIT_ASSERT(nullptr != ps.get()); - - edm::ParameterSet const& innerps = ps->getParameterSet("main"); - edm::FileInPath fip = innerps.getParameter("fip"); - edm::FileInPath ufip = innerps.getUntrackedParameter("ufip"); - CPPUNIT_ASSERT(innerps.existsAs("extraneous")); - CPPUNIT_ASSERT(!innerps.existsAs("absent")); - char *releaseBase = getenv("CMSSW_RELEASE_BASE"); - char *localBase = getenv("CMSSW_BASE"); - bool localArea = (releaseBase != nullptr && strlen(releaseBase) != 0 && strcmp(releaseBase, localBase)); - if(localArea) { - // Need to account for possible symbolic links - std::string const src("/src"); - std::string release = releaseBase + src; - std::string local = localBase + src; - edm::resolveSymbolicLinks(release); - edm::resolveSymbolicLinks(local); - localArea = (local != release); - } - - if(localArea) { - CPPUNIT_ASSERT(fip.location() == edm::FileInPath::Local); - } - CPPUNIT_ASSERT(fip.relativePath() == "FWCore/PythonParameterSet/test/fip.txt"); - CPPUNIT_ASSERT(ufip.relativePath() == "FWCore/PythonParameterSet/test/ufip.txt"); - std::string fullpath = fip.fullPath(); - std::cerr << "fullPath is: " << fip.fullPath() << std::endl; - std::cerr << "copy of fullPath is: " << fullpath << std::endl; - - CPPUNIT_ASSERT(!fullpath.empty()); - - std::string tmpout = fullpath.substr(0, fullpath.find("FWCore/PythonParameterSet/test/fip.txt")) + "tmp.py"; - - edm::FileInPath topo = innerps.getParameter("topo"); - // if the file is local, then just disable this check as then it is expected to fail - { - std::string const src("/src"); - std::string local = localBase + src; - std::string localFile = local + "/Geometry/TrackerSimData/data/trackersens.xml"; - if (!boost::filesystem::exists(localFile) ) - CPPUNIT_ASSERT(topo.location() != edm::FileInPath::Local); - else - std::cerr << "Disabling test against local path for trackersens.xml as package is checked out in this test" << std::endl; - } - CPPUNIT_ASSERT(topo.relativePath() == "Geometry/TrackerSimData/data/trackersens.xml"); - fullpath = topo.fullPath(); - CPPUNIT_ASSERT(!fullpath.empty()); - - std::vector v(1); - CPPUNIT_ASSERT(innerps.getAllFileInPaths(v) == 3); - - CPPUNIT_ASSERT(v.size() == 4); - CPPUNIT_ASSERT(std::count(v.begin(), v.end(), fip) == 1); - CPPUNIT_ASSERT(std::count(v.begin(), v.end(), topo) == 1); - - edm::ParameterSet empty; - v.clear(); - CPPUNIT_ASSERT(empty.getAllFileInPaths(v) == 0); - CPPUNIT_ASSERT(v.empty()); - - // This last test checks that a FileInPath parameter can be read - // successfully even if the associated file no longer exists. - std::ofstream out(tmpout.c_str()); - CPPUNIT_ASSERT(!(!out)); - - char const* kTest2 = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('PROD')\n" - "process.main = cms.PSet(\n" - " fip2 = cms.FileInPath('tmp.py')\n" - ")\n" - "process.source = cms.Source('EmptySource')\n"; - - std::string config2(kTest2); - // Create the ParameterSet object from this configuration string. - PythonProcessDesc builder2(config2); - unlink(tmpout.c_str()); - std::shared_ptr ps2 = builder2.parameterSet(); - - CPPUNIT_ASSERT(nullptr != ps2.get()); - - edm::ParameterSet const& innerps2 = ps2->getParameterSet("main"); - edm::FileInPath fip2 = innerps2.getParameter("fip2"); - if (localArea) { - CPPUNIT_ASSERT(fip2.location() == edm::FileInPath::Local); - } - CPPUNIT_ASSERT(fip2.relativePath() == "tmp.py"); - std::string fullpath2 = fip2.fullPath(); - std::cerr << "fullPath is: " << fip2.fullPath() << std::endl; - std::cerr << "copy of fullPath is: " << fullpath2 << std::endl; - CPPUNIT_ASSERT(!fullpath2.empty()); -} - -void testmakepset::typesTest() { - //vbool vb = {true, false}; - char const* kTest = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('t')\n" - "process.p = cms.PSet(\n" - " input2 = cms.InputTag('Label2','Instance2'),\n" - " sb3 = cms.string(' '),\n" - " input1 = cms.InputTag('Label1','Instance1'),\n" - " input6 = cms.InputTag('source'),\n" - " #justasbig = cms.double(inf),\n" - " input4 = cms.InputTag('Label4','Instance4','Process4'),\n" - " input3 = cms.untracked.InputTag('Label3','Instance3'),\n" - " h2 = cms.uint32(255),\n" - " vi = cms.vint32(1, -2),\n" - " input8 = cms.string('deprecatedString:tag'),\n" - " h1 = cms.int32(74),\n" - " vs = cms.vstring('','1', \n" - " '2', \n" - " 'a', 'XXX'),\n" - " vs2 = cms.vstring(), vs3 = cms.vstring(''),\n" - " sb2 = cms.string(''),\n" - " input7 = cms.InputTag('source','sink'),\n" - " ps = cms.PSet(\n" - " b2 = cms.untracked.bool(True)\n" - " ),\n" - " input5 = cms.InputTag('Label5','','Process5'),\n" - " h3 = cms.untracked.uint32(3487559679),\n" - " input = cms.InputTag('Label'),\n" - " vps = cms.VPSet(cms.PSet(\n" - " b3 = cms.bool(False)\n" - " )),\n" - " #indebt = cms.double(-inf),\n" - " #big = cms.double(inf),\n" - " vinput = cms.VInputTag(cms.InputTag('l1','i1'), cms.InputTag('l2'), cms.InputTag('l3','i3','p3'), cms.InputTag('l4','','p4'), cms.InputTag('source'), \n" - " cms.InputTag('source','sink')),\n" - " ui = cms.uint32(1),\n" - " eventID = cms.EventID(1, 0, 1),\n" - " b = cms.untracked.bool(True),\n" - " d = cms.double(1.0),\n" - " i = cms.int32(1),\n" - " vui = cms.vuint32(1, 2, 1, 255),\n" - " s = cms.string('this string'),\n" - " sb1 = cms.string(''),\n" - " emptyString = cms.untracked.string(''),\n" - " vEventID = cms.VEventID('1:1', '2:2','3:3'),\n" - " lumi = cms.LuminosityBlockID(55, 65),\n" - " vlumis = cms.VLuminosityBlockID('75:85', '95:105'),\n" - " einput1 = cms.ESInputTag(),\n" - " einput2 = cms.ESInputTag(data='blah'),\n" - " einput3 = cms.ESInputTag('ESProd'),\n" - " einput4 = cms.ESInputTag('ESProd','something'),\n" - " einput5 = cms.ESInputTag('ESProd:something'),\n" - " veinput1 = cms.VESInputTag(),\n" - " veinput2 = cms.VESInputTag(cms.ESInputTag(data='blah'),cms.ESInputTag('ESProd'))\n" - ")\n" - - ; - - std::string config2(kTest); - // Create the ParameterSet object from this configuration string. - PythonProcessDesc builder2(config2); - std::shared_ptr ps2 = builder2.parameterSet(); - edm::ParameterSet const& test = ps2->getParameterSet("p"); - - CPPUNIT_ASSERT(1 == test.getParameter("i")); - CPPUNIT_ASSERT(test.retrieve("i").isTracked()); - CPPUNIT_ASSERT(1 == test.getParameter("ui")); - CPPUNIT_ASSERT(1 == test.getParameter("d")); - //CPPUNIT_ASSERT(100000. < test.getParameter("big")); - //CPPUNIT_ASSERT(100000. < test.getParameter("justasbig")); - //CPPUNIT_ASSERT(-1000000. > test.getParameter("indebt")); - - // test hex numbers - CPPUNIT_ASSERT(74 == test.getParameter("h1")); - CPPUNIT_ASSERT(255 == test.getParameter("h2")); - CPPUNIT_ASSERT(3487559679U == test.getUntrackedParameter("h3")); - - //std::cout << test.getParameter("s") << std::endl; - CPPUNIT_ASSERT("this string" == test.getParameter("s")); - //std::cout <<"blank string using single quotes returns \""<("sb1")<<"\""<("sb2")<<"\""<("sb1")); - CPPUNIT_ASSERT("" == test.getUntrackedParameter("emptyString", "default")); - CPPUNIT_ASSERT("" == test.getParameter("sb2")); - CPPUNIT_ASSERT(4 == test.getParameter("sb3").size()); - std::vector vs = test.getParameter >("vs"); - int vssize = vs.size(); - //FIXME doesn't do spaces right - edm::Entry e(test.retrieve("vs")); - CPPUNIT_ASSERT(5 == vssize); - CPPUNIT_ASSERT(vssize && "" == vs[0]); - CPPUNIT_ASSERT(vssize >1 && "1" == vs[1]); - CPPUNIT_ASSERT(vssize >1 && "a" == vs[3]); - //std::cout <<"\""< >("vs")[0]<<"\" \""< >("vs")[1]<<"\" \"" - //< >("vs")[2]<<"\""< >("vs2"); - CPPUNIT_ASSERT(vs.size() == 0); - vs = test.getParameter >("vs3"); - CPPUNIT_ASSERT(vs.size() == 1); - CPPUNIT_ASSERT(vs[0] == ""); - - static unsigned int const vuia[] = {1,2,1,255}; - static std::vector const vui(vuia, vuia+sizeof(vuia)/sizeof(unsigned int)); - CPPUNIT_ASSERT(vui == test.getParameter >("vui")); - - static int const via[] = {1,-2}; - static std::vector const vi(via, via+sizeof(via)/sizeof(int)); - test.getParameter >("vi"); - CPPUNIT_ASSERT(true == test.getUntrackedParameter("b", false)); - CPPUNIT_ASSERT(test.retrieve("vi").isTracked()); - //test.getParameter >("vb"); - edm::ParameterSet const& ps = test.getParameterSet("ps"); - CPPUNIT_ASSERT(true == ps.getUntrackedParameter("b2", false)); - std::vector const& vps = test.getParameterSetVector("vps"); - CPPUNIT_ASSERT(1 == vps.size()); - CPPUNIT_ASSERT(false == vps.front().getParameter("b3")); - - // InputTag - edm::InputTag inputProduct = test.getParameter("input"); - edm::InputTag inputProduct1 = test.getParameter("input1"); - edm::InputTag inputProduct2 = test.getParameter("input2"); - edm::InputTag inputProduct3 = test.getUntrackedParameter("input3"); - edm::InputTag inputProduct4 = test.getParameter("input4"); - edm::InputTag inputProduct5 = test.getParameter("input5"); - edm::InputTag inputProduct6 = test.getParameter("input6"); - edm::InputTag inputProduct7 = test.getParameter("input7"); - edm::InputTag inputProduct8 = test.getParameter("input8"); - - //edm::OutputTag outputProduct = test.getParameter("output"); - - CPPUNIT_ASSERT("Label" == inputProduct.label()); - CPPUNIT_ASSERT("Label1" == inputProduct1.label()); - CPPUNIT_ASSERT("Label2" == inputProduct2.label()); - CPPUNIT_ASSERT("Instance2" == inputProduct2.instance()); - CPPUNIT_ASSERT("Label3" == inputProduct3.label()); - CPPUNIT_ASSERT("Instance3" == inputProduct3.instance()); - CPPUNIT_ASSERT("Label4" == inputProduct4.label()); - CPPUNIT_ASSERT("Instance4" == inputProduct4.instance()); - CPPUNIT_ASSERT("Process4" == inputProduct4.process()); - CPPUNIT_ASSERT("Label5" == inputProduct5.label()); - CPPUNIT_ASSERT("" == inputProduct5.instance()); - CPPUNIT_ASSERT("Process5" == inputProduct5.process()); - CPPUNIT_ASSERT("source" == inputProduct6.label()); - CPPUNIT_ASSERT("source" == inputProduct7.label()); - CPPUNIT_ASSERT("deprecatedString" == inputProduct8.label()); - - // vector of InputTags - - std::vector vtags = test.getParameter >("vinput"); - CPPUNIT_ASSERT("l1" == vtags[0].label()); - CPPUNIT_ASSERT("i1" == vtags[0].instance()); - CPPUNIT_ASSERT("l2" == vtags[1].label()); - CPPUNIT_ASSERT("l3" == vtags[2].label()); - CPPUNIT_ASSERT("i3" == vtags[2].instance()); - CPPUNIT_ASSERT("p3" == vtags[2].process()); - CPPUNIT_ASSERT("l4" == vtags[3].label()); - CPPUNIT_ASSERT("" == vtags[3].instance()); - CPPUNIT_ASSERT("p4" == vtags[3].process()); - CPPUNIT_ASSERT("source" == vtags[4].label()); - CPPUNIT_ASSERT("source" == vtags[5].label()); - - // ESInputTag - edm::ESInputTag einput1 = test.getParameter("einput1"); - edm::ESInputTag einput2 = test.getParameter("einput2"); - edm::ESInputTag einput3 = test.getParameter("einput3"); - edm::ESInputTag einput4 = test.getParameter("einput4"); - edm::ESInputTag einput5 = test.getParameter("einput5"); - CPPUNIT_ASSERT("" == einput1.module()); - CPPUNIT_ASSERT("" == einput1.data()); - CPPUNIT_ASSERT("" == einput2.module()); - CPPUNIT_ASSERT("blah" == einput2.data()); - CPPUNIT_ASSERT("ESProd" == einput3.module()); - CPPUNIT_ASSERT("" == einput3.data()); - CPPUNIT_ASSERT("ESProd" == einput4.module()); - CPPUNIT_ASSERT("something" == einput4.data()); - CPPUNIT_ASSERT("ESProd" == einput5.module()); - CPPUNIT_ASSERT("something" == einput5.data()); - - std::vector veinput1 = test.getParameter >("veinput1"); - std::vector veinput2 = test.getParameter >("veinput2"); - CPPUNIT_ASSERT(0 == veinput1.size()); - CPPUNIT_ASSERT(2 == veinput2.size()); - CPPUNIT_ASSERT("" == veinput2[0].module()); - CPPUNIT_ASSERT("blah" == veinput2[0].data()); - CPPUNIT_ASSERT("ESProd" == veinput2[1].module()); - CPPUNIT_ASSERT("" == veinput2[1].data()); - - edm::EventID eventID = test.getParameter("eventID"); - std::vector vEventID = test.getParameter >("vEventID"); - CPPUNIT_ASSERT(1 == eventID.run()); - CPPUNIT_ASSERT(1 == eventID.event()); - CPPUNIT_ASSERT(1 == vEventID[0].run()); - CPPUNIT_ASSERT(1 == vEventID[0].event()); - CPPUNIT_ASSERT(3 == vEventID[2].run()); - CPPUNIT_ASSERT(3 == vEventID[2].event()); - - edm::LuminosityBlockID lumi = test.getParameter("lumi"); - CPPUNIT_ASSERT(55 == lumi.run()); - CPPUNIT_ASSERT(65 == lumi.luminosityBlock()); - std::vector vlumis = test.getParameter >("vlumis"); - CPPUNIT_ASSERT(vlumis.size() == 2); - CPPUNIT_ASSERT(vlumis[0].run() == 75); - CPPUNIT_ASSERT(vlumis[0].luminosityBlock() == 85); - CPPUNIT_ASSERT(vlumis[1].run() == 95); - CPPUNIT_ASSERT(vlumis[1].luminosityBlock() == 105); - - //CPPUNIT_ASSERT("Label2" == outputProduct.label()); - //CPPUNIT_ASSERT("" == outputProduct.instance()); - //CPPUNIT_ASSERT("Alias2" == outputProduct.alias()); - //BOOST_CHECK_THROW(makePSet(*nodeList), std::runtime_error); -} diff --git a/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp b/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp deleted file mode 100644 index c5cefa913d6ac..0000000000000 --- a/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/** - -@file : processbuilder_t.cpp - -@brief test suit for process building and schedule validation - -*/ - -#include - -#include -#include -#include "FWCore/Utilities/interface/EDMException.h" - -#include - -#include -#include -#include - -class testProcessDesc: public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE(testProcessDesc); - - CPPUNIT_TEST(trivialPathTest); - CPPUNIT_TEST(simplePathTest); - CPPUNIT_TEST(sequenceSubstitutionTest); - CPPUNIT_TEST(attriggertest); - CPPUNIT_TEST(nestedSequenceSubstitutionTest); - CPPUNIT_TEST(sequenceSubstitutionTest2); - CPPUNIT_TEST(sequenceSubstitutionTest3); - CPPUNIT_TEST(multiplePathsTest); - // python throws some different exception - //CPPUNIT_TEST_EXCEPTION(inconsistentPathTest,edm::Exception); - //CPPUNIT_TEST_EXCEPTION(inconsistentMultiplePathTest,edm::Exception); - - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() {} - void tearDown() {} - - void trivialPathTest(); - void simplePathTest(); - void sequenceSubstitutionTest(); - void attriggertest(); - void nestedSequenceSubstitutionTest(); - void sequenceSubstitutionTest2(); - void sequenceSubstitutionTest3(); - void multiplePathsTest(); - void inconsistentPathTest(); - void inconsistentMultiplePathTest(); -}; - -///registration of the test so that the runner can find it -CPPUNIT_TEST_SUITE_REGISTRATION(testProcessDesc); - -void testProcessDesc::trivialPathTest() { - std::string str = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('X')\n" - "process.a = cms.EDFilter('A',\n" - " p = cms.int32(3)\n" - ")\n" - "process.b = cms.EDProducer('B')\n" - "process.c = cms.EDProducer('C')\n" - "process.p = cms.Path(process.a*process.b*process.c)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("p"); - CPPUNIT_ASSERT(s[0]=="a"); - //CPPUNIT_ASSERT(b->getDependencies("a")==""); -} - -void testProcessDesc::simplePathTest() { - - std::string str = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('X')\n" - "process.a = cms.EDFilter('A',\n" - " p = cms.int32(3)\n" - ")\n" - "process.b = cms.EDFilter('A',\n" - " p = cms.int32(3)\n" - ")\n" - "process.c = cms.EDFilter('A',\n" - " p = cms.int32(3)\n" - ")\n" - "process.p = cms.Path(process.a*process.b*process.c)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("p"); - CPPUNIT_ASSERT(s[0]=="a"); - CPPUNIT_ASSERT(s[1]=="b"); - CPPUNIT_ASSERT(s[2]=="c"); - - //CPPUNIT_ASSERT (b->getDependencies("a")==""); - //CPPUNIT_ASSERT (b->getDependencies("b")=="a,"); - //CPPUNIT_ASSERT (b->getDependencies("c")=="a,b,"); -} - -void testProcessDesc:: attriggertest () { - - std::string str = - "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone1 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(5)\n" - ")\n" - "process.cone2 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.somejet1 = cms.EDFilter('PhonyJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.somejet2 = cms.EDFilter('PhonyJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.jtanalyzer = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.output = cms.OutputModule('OutputModule')\n" - "process.cones = cms.Sequence(process.cone1*process.cone2)\n" - "process.jets = cms.Sequence(process.somejet1*process.somejet2)\n" - "process.path1 = cms.Path(process.cones*process.jets*process.jtanalyzer)\n" - "process.epath = cms.EndPath(process.output)\n"; - - try { - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - edm::ParameterSet const& trig_pset = - (*test).getParameterSet("@trigger_paths"); - Strs tnames = trig_pset.getParameter("@trigger_paths"); - Strs enames = (*test).getParameter("@end_paths"); - - CPPUNIT_ASSERT(tnames[0]=="path1"); - CPPUNIT_ASSERT(enames[0]=="epath"); - - // see if the auto-schedule is correct - Strs schedule = (*test).getParameter("@paths"); - CPPUNIT_ASSERT(schedule.size() == 2); - CPPUNIT_ASSERT(schedule[0] == "path1"); - CPPUNIT_ASSERT(schedule[1] == "epath"); - - } - catch (cms::Exception& exc) { - std::cerr << "Got an cms::Exception: " << exc.what() << "\n"; - throw; - } - catch (std::exception& exc) { - std::cerr << "Got an std::exception: " << exc.what() << "\n"; - throw; - } - catch (...) { - std::cerr << "Got an unknown exception: " << "\n"; - throw; - } -} - -void testProcessDesc:: sequenceSubstitutionTest () { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone1 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(5)\n" - ")\n" - "process.cone2 = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.somejet1 = cms.EDFilter('PhonyJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.somejet2 = cms.EDFilter('PhonyJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.jtanalyzer = cms.EDFilter('PhonyConeJet',\n" - " i = cms.int32(7)\n" - ")\n" - "process.cones = cms.Sequence(process.cone1*process.cone2)\n" - "process.jets = cms.Sequence(process.somejet1*process.somejet2)\n" - "process.path1 = cms.Path(process.cones*process.jets*process.jtanalyzer)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("path1"); - CPPUNIT_ASSERT(s[0]=="cone1"); - CPPUNIT_ASSERT(s[1]=="cone2"); - CPPUNIT_ASSERT(s[2]=="somejet1"); - CPPUNIT_ASSERT(s[3]=="somejet2"); - CPPUNIT_ASSERT(s[4]=="jtanalyzer"); - - //CPPUNIT_ASSERT (b->getDependencies("cone1")==""); - //CPPUNIT_ASSERT (b->getDependencies("cone2")=="cone1,"); - //CPPUNIT_ASSERT (b->getDependencies("somejet1")=="cone1,cone2,"); - //CPPUNIT_ASSERT (b->getDependencies("somejet2")=="cone1,cone2,somejet1,"); - //CPPUNIT_ASSERT (b->getDependencies("jtanalyzer")=="cone1,cone2,somejet1,somejet2,"); -} - -void testProcessDesc::nestedSequenceSubstitutionTest() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.c = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.d = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.s1 = cms.Sequence( process.a+ process.b)\n" - "process.s2 = cms.Sequence(process.s1+ process.c)\n" - "process.path1 = cms.Path(process.s2+process.d)\n"; - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("path1"); - CPPUNIT_ASSERT(s[0]=="a"); - CPPUNIT_ASSERT(s[1]=="b"); - CPPUNIT_ASSERT(s[2]=="c"); - CPPUNIT_ASSERT(s[3]=="d"); - - //CPPUNIT_ASSERT (b.getDependencies("a")==""); - //CPPUNIT_ASSERT (b.getDependencies("b")=="a,"); - //CPPUNIT_ASSERT (b.getDependencies("c")=="a,b,"); - //CPPUNIT_ASSERT (b.getDependencies("d")=="a,b,c,"); -} - -void testProcessDesc::sequenceSubstitutionTest2() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.cone3 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.cones = cms.Sequence(process.cone1+ process.cone2+ process.cone3)\n" - "process.jets = cms.Sequence(process.somejet1+ process.somejet2)\n" - "process.path1 = cms.Path(process.cones+process.jets+ process.jtanalyzer)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("path1"); - CPPUNIT_ASSERT(s[0]=="cone1"); - CPPUNIT_ASSERT(s[1]=="cone2"); - CPPUNIT_ASSERT(s[2]=="cone3"); - CPPUNIT_ASSERT(s[3]=="somejet1"); - CPPUNIT_ASSERT(s[4]=="somejet2"); - CPPUNIT_ASSERT(s[5]=="jtanalyzer"); - - //CPPUNIT_ASSERT (b.getDependencies("cone1")==""); - //CPPUNIT_ASSERT (b.getDependencies("cone2")=="cone1,"); - //CPPUNIT_ASSERT (b.getDependencies("cone3")=="cone1,cone2,"); - //CPPUNIT_ASSERT (b.getDependencies("somejet1")=="cone1,cone2,cone3,"); - //CPPUNIT_ASSERT (b.getDependencies("somejet2")=="cone1,cone2,cone3,somejet1,"); - //CPPUNIT_ASSERT (b.getDependencies("jtanalyzer")=="cone1,cone2,cone3,somejet1,somejet2,"); -} - -void testProcessDesc::sequenceSubstitutionTest3() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.c = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.aa = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.bb = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.cc = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.dd = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.aaa = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.bbb = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.ccc = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.ddd = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.eee = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.last = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - - "process.s1 = cms.Sequence(process.a* process.b* process.c)\n" - "process.s2 = cms.Sequence(process.aa*process.bb*cms.ignore(process.cc)*process.dd)\n" - "process.s3 = cms.Sequence(process.aaa*process.bbb*~process.ccc*process.ddd*process.eee)\n" - "process.path1 = cms.Path(process.s1+process.s3+process.s2+process.last)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("path1"); - CPPUNIT_ASSERT(s[0]=="a"); - CPPUNIT_ASSERT(s[1]=="b"); - CPPUNIT_ASSERT(s[2]=="c"); - CPPUNIT_ASSERT(s[3]=="aaa"); - CPPUNIT_ASSERT(s[4]=="bbb"); - CPPUNIT_ASSERT(s[5]=="!ccc"); - CPPUNIT_ASSERT(s[6]=="ddd"); - CPPUNIT_ASSERT(s[7]=="eee"); - CPPUNIT_ASSERT(s[8]=="aa"); - CPPUNIT_ASSERT(s[9]=="bb"); - CPPUNIT_ASSERT(s[10]=="-cc"); - CPPUNIT_ASSERT(s[11]=="dd"); - CPPUNIT_ASSERT(s[12]=="last"); - - //CPPUNIT_ASSERT (b.getDependencies("a")==""); - //CPPUNIT_ASSERT (b.getDependencies("b")=="a,"); - //CPPUNIT_ASSERT (b.getDependencies("c")=="a,b,"); - //CPPUNIT_ASSERT (b.getDependencies("aaa")=="a,b,c,"); - //CPPUNIT_ASSERT (b.getDependencies("bbb")=="a,aaa,b,c,"); - //CPPUNIT_ASSERT (b.getDependencies("ccc")=="a,aaa,b,bbb,c,"); - //CPPUNIT_ASSERT (b.getDependencies("ddd")=="a,aaa,b,bbb,c,ccc,"); - //CPPUNIT_ASSERT (b.getDependencies("eee")=="a,aaa,b,bbb,c,ccc,ddd,"); - //CPPUNIT_ASSERT (b.getDependencies("aa")=="a,aaa,b,bbb,c,ccc,ddd,eee,"); - //CPPUNIT_ASSERT (b.getDependencies("bb")=="a,aa,aaa,b,bbb,c,ccc,ddd,eee,"); - //CPPUNIT_ASSERT (b.getDependencies("cc")=="a,aa,aaa,b,bb,bbb,c,ccc,ddd,eee,"); - //CPPUNIT_ASSERT (b.getDependencies("dd")=="a,aa,aaa,b,bb,bbb,c,cc,ccc,ddd,eee,"); - //CPPUNIT_ASSERT (b.getDependencies("last")=="a,aa,aaa,b,bb,bbb,c,cc,ccc,dd,ddd,eee,"); - -} - -void testProcessDesc::multiplePathsTest() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.cone3 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.anotherjtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.cones = cms.Sequence(process.cone1* process.cone2* process.cone3)\n" - "process.jets = cms.Sequence(process.somejet1* process.somejet2)\n" - "process.path1 = cms.Path(process.cones+ process.jtanalyzer)\n" - "process.path2 = cms.Path(process.jets+ process.anotherjtanalyzer)\n" - "process.schedule = cms.Schedule(process.path2, process.path1)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); - - typedef std::vector Strs; - - Strs s = (*test).getParameter >("path1"); - CPPUNIT_ASSERT(s[0]=="cone1"); - CPPUNIT_ASSERT(s[1]=="cone2"); - CPPUNIT_ASSERT(s[2]=="cone3"); - CPPUNIT_ASSERT(s[3]=="jtanalyzer"); - - //CPPUNIT_ASSERT (b.getDependencies("cone1")==""); - //CPPUNIT_ASSERT (b.getDependencies("cone2")=="cone1,"); - //CPPUNIT_ASSERT (b.getDependencies("cone3")=="cone1,cone2,"); - //CPPUNIT_ASSERT (b.getDependencies("jtanalyzer")=="cone1,cone2,cone3,"); - - s = (*test).getParameter >("path2"); - CPPUNIT_ASSERT(s[0]=="somejet1"); - CPPUNIT_ASSERT(s[1]=="somejet2"); - CPPUNIT_ASSERT(s[2]=="anotherjtanalyzer"); - - //CPPUNIT_ASSERT (b.getDependencies("somejet1")==""); - //CPPUNIT_ASSERT (b.getDependencies("somejet2")=="somejet1,"); - //CPPUNIT_ASSERT (b.getDependencies("anotherjtanalyzer")=="somejet1,somejet2,"); - - Strs schedule = (*test).getParameter >("@paths"); - - CPPUNIT_ASSERT (schedule.size() == 2); - CPPUNIT_ASSERT (schedule[0] == "path2"); - CPPUNIT_ASSERT (schedule[1] == "path1"); -} - -void testProcessDesc::inconsistentPathTest() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.c = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.path1 = cms.Path((process.a*process.b)+ (process.c*process.b))\n"; - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); -} - -void testProcessDesc::inconsistentMultiplePathTest() { - - std::string str = "import FWCore.ParameterSet.Config as cms\n" - "process = cms.Process('test')\n" - "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" - "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" - "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" - "process.cones = cms.Sequence(process.cone1+ process.cone2)\n" - "process.jets = cms.Sequence(process.somejet1* process.somejet2)\n" - "process.path1 = cms.Path(process.cones*process.jtanalyzer)\n" - "process.path2 = cms.Path(process.jets*process.jtanalyzer)\n"; - - std::shared_ptr test = PythonProcessDesc(str).parameterSet(); -} - -#include diff --git a/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc b/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc deleted file mode 100644 index b5b9d7d479cc0..0000000000000 --- a/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * makeprocess_t.cc - * EDMProto - * - * Created by Chris Jones on 5/18/05. - * Changed by Viji Sundararajan on 8-Jul-05. - * - */ - - -#include - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" - -#include - -#include -#include -#include -#include -#include - -class testreadpsetsfrom: public CppUnit::TestFixture -{ -CPPUNIT_TEST_SUITE(testreadpsetsfrom); -CPPUNIT_TEST(simpleTest); -CPPUNIT_TEST_SUITE_END(); -public: - void setUp(){} - void tearDown(){} - void simpleTest(); -private: - -}; - - - -///registration of the test so that the runner can find it -CPPUNIT_TEST_SUITE_REGISTRATION(testreadpsetsfrom); - -void testreadpsetsfrom::simpleTest() -{ - const char* kTest ="import FWCore.ParameterSet.Config as cms\n" - "dummy = cms.PSet(b = cms.bool(True))\n" - "foo = cms.PSet(a = cms.string('blah'))\n" - ; - std::shared_ptr test = edm::boost_python::readPSetsFrom(kTest); - - CPPUNIT_ASSERT(test->getParameterSet("dummy").getParameter("b")==true); - CPPUNIT_ASSERT(test->getParameterSet("foo").getParameter("a")==std::string("blah")); -} - diff --git a/FWCore/PythonParameterSet/test/ufip.txt b/FWCore/PythonParameterSet/test/ufip.txt deleted file mode 100644 index a52b9dba51d13..0000000000000 --- a/FWCore/PythonParameterSet/test/ufip.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy file for the FileInPath test. From 6cedd4e7c6b03ef7902af5e1f975647b21150635 Mon Sep 17 00:00:00 2001 From: federico de guio Date: Sat, 6 Apr 2019 16:18:41 +0200 Subject: [PATCH 491/686] avoid conflict between HE and HGC in phase2 geometry --- SLHCUpgradeSimulations/Configuration/python/aging.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SLHCUpgradeSimulations/Configuration/python/aging.py b/SLHCUpgradeSimulations/Configuration/python/aging.py index 27216dc27e369..0188a8c740cac 100644 --- a/SLHCUpgradeSimulations/Configuration/python/aging.py +++ b/SLHCUpgradeSimulations/Configuration/python/aging.py @@ -232,23 +232,27 @@ def customise_aging_300(process): def customise_aging_1000(process): process=ageHcal(process,1000,5.0e34,"nominal") + process=turn_off_HE_aging(process) #avoid conflict between HGCal and Hcal in phase2 geom configuration process=ageEcal(process,1000,5.0e34) return process def customise_aging_3000(process): process=ageHcal(process,3000,5.0e34,"nominal") + process=turn_off_HE_aging(process) #avoid conflict between HGCal and Hcal in phase2 geom configuration process=ageEcal(process,3000,5.0e34) process=agedHGCal(process) return process def customise_aging_3000_ultimate(process): process=ageHcal(process,3000,7.5e34,"ultimate") + process=turn_off_HE_aging(process) #avoid conflict between HGCal and Hcal in phase2 geom configuration process=ageEcal(process,3000,7.5e34) process=agedHGCal(process) return process def customise_aging_4500_ultimate(process): process=ageHcal(process,4500,7.5e34,"ultimate") + process=turn_off_HE_aging(process) #avoid conflict between HGCal and Hcal in phase2 geom configuration process=ageEcal(process,4500,7.5e34) process=agedHGCal(process) return process From 9e22e8d5821b54b9cbd1b2b5e5516c6d80c7fa6f Mon Sep 17 00:00:00 2001 From: David Date: Sat, 6 Apr 2019 18:46:08 +0200 Subject: [PATCH 492/686] add python3 cmsRun as PyDevParameterSet. Move everything to use PythonParameterSet --- FWCore/Framework/bin/BuildFile.xml | 5 +- ...msRunBoostPython.cpp => cmsRunPython3.cpp} | 4 +- FWCore/Integration/test/BuildFile.xml | 2 +- FWCore/Integration/test/SwitchProducer_t.cpp | 2 +- FWCore/ParameterSetReader/BuildFile.xml | 2 +- .../interface/ProcessDescImpl.h | 2 +- .../src/ParameterSetReader.cc | 4 +- FWCore/PyDevParameterSet/BuildFile.xml | 2 +- .../interface/MakePyBind11ParameterSets.h | 6 +- .../interface/PyBind11ProcessDesc.h | 7 +- .../interface/PyBind11Wrapper.h | 6 +- .../interface/Python11ParameterSet.h | 11 +- .../python/test/testTask_cff.py | 248 ++++++ .../src/MakePyBind11ParameterSets.cc | 14 +- FWCore/PyDevParameterSet/src/PyBind11Module.h | 6 +- .../src/PyBind11ProcessDesc.cc | 178 ++-- .../PyDevParameterSet/src/PyBind11Wrapper.cc | 2 +- .../src/Python11ParameterSet.cc | 73 +- .../src/initializePyBind11Module.cc | 2 +- .../src/initializePyBind11Module.h | 6 +- .../test/makeprocess_t.cppunit.cc | 8 +- .../test/makepset_t.cppunit.cc | 10 +- .../test/processbuilder_t.cppunit.cpp | 20 +- .../test/readpsetsfrom_t.cppunit.cc | 2 +- FWCore/PythonFramework/BuildFile.xml | 2 +- .../interface/PythonEventProcessor.h | 2 +- FWCore/PythonFramework/python/CmsRun.py | 2 +- .../src/PythonEventProcessor.cc | 2 +- FWCore/PythonFramework/src/PythonModule.cc | 2 +- FWCore/PythonParameterSet/BuildFile.xml | 9 + .../interface/MakePyBind11ParameterSets.h | 35 + .../interface/PyBind11ProcessDesc.h | 56 ++ .../interface/PyBind11Wrapper.h | 37 + .../interface/Python11ParameterSet.h | 131 +++ .../python/test/testTask_cff.py | 248 ++++++ .../src/MakePyBind11ParameterSets.cc | 75 ++ .../PythonParameterSet/src/PyBind11Module.h | 184 +++++ .../src/PyBind11ProcessDesc.cc | 116 +++ .../PythonParameterSet/src/PyBind11Wrapper.cc | 12 + .../src/Python11ParameterSet.cc | 46 ++ .../src/initializePyBind11Module.cc | 19 + .../src/initializePyBind11Module.h | 16 + FWCore/PythonParameterSet/test/BuildFile.xml | 7 + FWCore/PythonParameterSet/test/fip.txt | 1 + .../test/makeprocess_t.cppunit.cc | 775 ++++++++++++++++++ .../test/makepset_t.cppunit.cc | 503 ++++++++++++ .../test/processbuilder_t.cppunit.cpp | 404 +++++++++ .../test/readpsetsfrom_t.cppunit.cc | 53 ++ FWCore/PythonParameterSet/test/ufip.txt | 1 + Fireworks/FWInterface/BuildFile.xml | 2 +- Fireworks/FWInterface/src/FWPathsPopup.cc | 2 +- 51 files changed, 3174 insertions(+), 190 deletions(-) rename FWCore/Framework/bin/{cmsRunBoostPython.cpp => cmsRunPython3.cpp} (98%) create mode 100644 FWCore/PyDevParameterSet/python/test/testTask_cff.py create mode 100644 FWCore/PythonParameterSet/BuildFile.xml create mode 100644 FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h create mode 100644 FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h create mode 100644 FWCore/PythonParameterSet/interface/PyBind11Wrapper.h create mode 100644 FWCore/PythonParameterSet/interface/Python11ParameterSet.h create mode 100644 FWCore/PythonParameterSet/python/test/testTask_cff.py create mode 100644 FWCore/PythonParameterSet/src/MakePyBind11ParameterSets.cc create mode 100644 FWCore/PythonParameterSet/src/PyBind11Module.h create mode 100644 FWCore/PythonParameterSet/src/PyBind11ProcessDesc.cc create mode 100644 FWCore/PythonParameterSet/src/PyBind11Wrapper.cc create mode 100644 FWCore/PythonParameterSet/src/Python11ParameterSet.cc create mode 100644 FWCore/PythonParameterSet/src/initializePyBind11Module.cc create mode 100644 FWCore/PythonParameterSet/src/initializePyBind11Module.h create mode 100644 FWCore/PythonParameterSet/test/BuildFile.xml create mode 100644 FWCore/PythonParameterSet/test/fip.txt create mode 100644 FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc create mode 100644 FWCore/PythonParameterSet/test/makepset_t.cppunit.cc create mode 100644 FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp create mode 100644 FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc create mode 100644 FWCore/PythonParameterSet/test/ufip.txt diff --git a/FWCore/Framework/bin/BuildFile.xml b/FWCore/Framework/bin/BuildFile.xml index 8bb7c68587958..f4550bcb0cd17 100644 --- a/FWCore/Framework/bin/BuildFile.xml +++ b/FWCore/Framework/bin/BuildFile.xml @@ -70,7 +70,7 @@ - + @@ -84,6 +84,5 @@ - - + diff --git a/FWCore/Framework/bin/cmsRunBoostPython.cpp b/FWCore/Framework/bin/cmsRunPython3.cpp similarity index 98% rename from FWCore/Framework/bin/cmsRunBoostPython.cpp rename to FWCore/Framework/bin/cmsRunPython3.cpp index e3472bb563268..3b3852daaa9df 100644 --- a/FWCore/Framework/bin/cmsRunBoostPython.cpp +++ b/FWCore/Framework/bin/cmsRunPython3.cpp @@ -24,7 +24,7 @@ PSet script. See notes in EventProcessor.cpp for details about it. #include "FWCore/Utilities/interface/ConvertException.h" #include "FWCore/Utilities/interface/Presence.h" #include "FWCore/Utilities/interface/TimingServiceBase.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" +#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" #include "TError.h" #include "boost/program_options.hpp" @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) { context += fileName; std::shared_ptr processDesc; try { - std::unique_ptr parameterSet = edm::boost_python::readConfig(fileName, argc, argv); + std::unique_ptr parameterSet = edm::cmspybind11_p3::readConfig(fileName, argc, argv); processDesc.reset(new edm::ProcessDesc(std::move(parameterSet))); } catch(cms::Exception& iException) { diff --git a/FWCore/Integration/test/BuildFile.xml b/FWCore/Integration/test/BuildFile.xml index bafe263f3e6bc..705558020be47 100644 --- a/FWCore/Integration/test/BuildFile.xml +++ b/FWCore/Integration/test/BuildFile.xml @@ -139,7 +139,7 @@ - + diff --git a/FWCore/Integration/test/SwitchProducer_t.cpp b/FWCore/Integration/test/SwitchProducer_t.cpp index 75d67f5be7815..298db6ab77595 100644 --- a/FWCore/Integration/test/SwitchProducer_t.cpp +++ b/FWCore/Integration/test/SwitchProducer_t.cpp @@ -3,7 +3,7 @@ #include "DataFormats/TestObjects/interface/ToyProducts.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" +#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h" #include "FWCore/TestProcessor/interface/TestProcessor.h" #include diff --git a/FWCore/ParameterSetReader/BuildFile.xml b/FWCore/ParameterSetReader/BuildFile.xml index 2076d3c42f00f..936e14dddbf5d 100644 --- a/FWCore/ParameterSetReader/BuildFile.xml +++ b/FWCore/ParameterSetReader/BuildFile.xml @@ -1,5 +1,5 @@ - + diff --git a/FWCore/ParameterSetReader/interface/ProcessDescImpl.h b/FWCore/ParameterSetReader/interface/ProcessDescImpl.h index 0e9dd3d1bfbcb..de6b0f9bea161 100644 --- a/FWCore/ParameterSetReader/interface/ProcessDescImpl.h +++ b/FWCore/ParameterSetReader/interface/ProcessDescImpl.h @@ -1,7 +1,7 @@ #ifndef FWCore_Framework_ProcessDescImpl_h #define FWCore_Framework_ProcessDescImpl_h -#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" using ProcessDescImpl = PyBind11ProcessDesc; diff --git a/FWCore/ParameterSetReader/src/ParameterSetReader.cc b/FWCore/ParameterSetReader/src/ParameterSetReader.cc index 15cbaef11fc4f..8fcfc938b5a73 100644 --- a/FWCore/ParameterSetReader/src/ParameterSetReader.cc +++ b/FWCore/ParameterSetReader/src/ParameterSetReader.cc @@ -1,6 +1,6 @@ #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" -#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" -#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h" std::unique_ptr edm::getPSetFromConfig(const std::string &config) { return PyBind11ProcessDesc(config).parameterSet(); diff --git a/FWCore/PyDevParameterSet/BuildFile.xml b/FWCore/PyDevParameterSet/BuildFile.xml index 883d5efcb1b41..d5c452937bc5a 100644 --- a/FWCore/PyDevParameterSet/BuildFile.xml +++ b/FWCore/PyDevParameterSet/BuildFile.xml @@ -2,7 +2,7 @@ - + diff --git a/FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h b/FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h index 7bd16e71d990e..5681fb4e0b395 100644 --- a/FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h +++ b/FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h -#define FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h +#ifndef FWCore_PyDevParameterSet_MakePyBind11ParameterSets_h +#define FWCore_PyDevParameterSet_MakePyBind11ParameterSets_h //---------------------------------------------------------------------- // Declare functions used to create ParameterSets. @@ -12,7 +12,7 @@ namespace edm { class ParameterSet; - namespace cmspybind11 { + namespace cmspybind11_p3 { // input can either be a python file name or a python config string std::unique_ptr readConfig(std::string const& config); diff --git a/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h b/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h index 1021d662f54fc..a9b9247760b87 100644 --- a/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h +++ b/FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h -#define FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h +#ifndef FWCore_PyDevParameterSet_PyBind11ProcessDesc_h +#define FWCore_PyDevParameterSet_PyBind11ProcessDesc_h #include "FWCore/PyDevParameterSet/interface/Python11ParameterSet.h" @@ -13,6 +13,8 @@ namespace edm { class ProcessDesc; } +namespace cmspython3 { + class PyBind11ProcessDesc { public: PyBind11ProcessDesc(); @@ -53,4 +55,5 @@ class PyBind11ProcessDesc { bool theOwnsInterpreter; }; +} #endif diff --git a/FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h b/FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h index 31bbe3031a275..8f8977c36cb17 100644 --- a/FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h +++ b/FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PyBind11ParameterSet_PyBind11Wrapper_h -#define FWCore_PyBind11ParameterSet_PyBind11Wrapper_h +#ifndef FWCore_PyDevParameterSet_PyBind11Wrapper_h +#define FWCore_PyDevParameterSet_PyBind11Wrapper_h #include #include @@ -7,7 +7,7 @@ #include #include -namespace edm { +namespace cmspython3 { void pythonToCppException(const std::string& iType, const std::string& error); diff --git a/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h b/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h index eb3a53e428d09..7987ce9b48ec5 100644 --- a/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h +++ b/FWCore/PyDevParameterSet/interface/Python11ParameterSet.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PyBind11ParameterSet_Python11ParameterSet_h -#define FWCore_PyBind11ParameterSet_Python11ParameterSet_h +#ifndef FWCore_PyDevParameterSet_Python11ParameterSet_h +#define FWCore_PyDevParameterSet_Python11ParameterSet_h #include #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -16,6 +16,7 @@ #include #include +namespace cmspython3 { class Python11ParameterSet { public: Python11ParameterSet(); @@ -52,7 +53,7 @@ class Python11ParameterSet { pybind11::list getParameters(bool tracked, std::string const& name) const { std::vector v = getParameter >(tracked, name); - return edm::toPython11List(v); + return cmspython3::toPython11List(v); } /// unfortunate side effect: destroys the original list! @@ -60,7 +61,7 @@ class Python11ParameterSet { void addParameters(bool tracked, std::string const& name, pybind11::list value) { - std::vector v = edm::toVector(value); + std::vector v = cmspython3::toVector(value); addParameter(tracked, name, v); } @@ -127,5 +128,5 @@ class Python11ParameterSet { private: edm::ParameterSet theParameterSet; }; - +} #endif diff --git a/FWCore/PyDevParameterSet/python/test/testTask_cff.py b/FWCore/PyDevParameterSet/python/test/testTask_cff.py new file mode 100644 index 0000000000000..0244ccbb4ec47 --- /dev/null +++ b/FWCore/PyDevParameterSet/python/test/testTask_cff.py @@ -0,0 +1,248 @@ +import FWCore.ParameterSet.Config as cms + +m1 = cms.EDProducer("prod") +m2 = cms.EDProducer("prod") +m3 = cms.EDProducer("prod") +m4 = cms.EDProducer("prod") +m5 = cms.EDProducer("prod") +m6 = cms.EDProducer("prod") +m7 = cms.EDProducer("prod") +m8 = cms.EDProducer("prod") +m9 = cms.EDProducer("prod") +m10 = cms.EDProducer("prod") +m11 = cms.EDProducer("prod") +m12 = cms.EDProducer("prod") +m13 = cms.EDProducer("prod") +m14 = cms.EDProducer("prod") +m15 = cms.EDProducer("prod") +m16 = cms.EDProducer("prod") +m17 = cms.EDProducer("prod") +m18 = cms.EDProducer("prod") +m19 = cms.EDProducer("prod") +m20 = cms.EDProducer("prod") +m21 = cms.EDProducer("prod") +m22 = cms.EDProducer("prod") +m23 = cms.EDProducer("prod") +m24 = cms.EDProducer("prod") +m25 = cms.EDProducer("prod") +m26 = cms.EDProducer("prod") +m27 = cms.EDProducer("prod") +m28 = cms.EDProducer("prod") +m29 = cms.EDProducer("prod") +m30 = cms.EDProducer("prod") + +p1 = cms.Path(m3+m4) +t1 = cms.Task(m11, m12) +t2 = cms.Task(m13, m14) +t3 = cms.Task(m15, m16) +t4 = cms.Task(m17, m18) +s1 = cms.Sequence(m5+m6, t3, t4) +s2 = cms.Sequence(s1) +p2 = cms.Path(s2, t1, t2) +e1 = cms.EndPath(m7+m8) +t5 = cms.Task(m19, m20) +t6 = cms.Task(m21, m22) +t7 = cms.Task(m23, m24) +t8 = cms.Task(m25, m26) +s3 = cms.Sequence(m9+m10, t5, t6) +s4 = cms.Sequence(s3) +e2 = cms.EndPath(s4, t7, t8) +t9 = cms.Task(m27, m28) + +f1 = cms.EDFilter("filt") +f2 = cms.EDFilter("filt") +f3 = cms.EDFilter("filt") +f4 = cms.EDFilter("filt") +f5 = cms.EDFilter("filt") +f6 = cms.EDFilter("filt") +f7 = cms.EDFilter("filt") +f8 = cms.EDFilter("filt") +f9 = cms.EDFilter("filt") +f10 = cms.EDFilter("filt") +f11 = cms.EDFilter("filt") +f12 = cms.EDFilter("filt") +f13 = cms.EDFilter("filt") +f14 = cms.EDFilter("filt") +f15 = cms.EDFilter("filt") +f16 = cms.EDFilter("filt") +f17 = cms.EDFilter("filt") +f18 = cms.EDFilter("filt") +f19 = cms.EDFilter("filt") +f20 = cms.EDFilter("filt") +f21 = cms.EDFilter("filt") +f22 = cms.EDFilter("filt") +f23 = cms.EDFilter("filt") +f24 = cms.EDFilter("filt") +f25 = cms.EDFilter("filt") +f26 = cms.EDFilter("filt") +f27 = cms.EDFilter("filt") +f28 = cms.EDFilter("filt") +f29 = cms.EDFilter("filt") +f30 = cms.EDFilter("filt") + +pf1 = cms.Path(f3+f4) +tf1 = cms.Task(f11, f12) +tf2 = cms.Task(f13, f14) +tf3 = cms.Task(f15, f16) +tf4 = cms.Task(f17, f18) +sf1 = cms.Sequence(f5+f6, tf3, tf4) +sf2 = cms.Sequence(sf1) +pf2 = cms.Path(sf2, tf1, tf2) +ef1 = cms.EndPath(f7+f8) +tf5 = cms.Task(f19, f20) +tf6 = cms.Task(f21, f22) +tf7 = cms.Task(f23, f24) +tf8 = cms.Task(f25, f26) +sf3 = cms.Sequence(f9+f10, tf5, tf6) +sf4 = cms.Sequence(sf3) +ef2 = cms.EndPath(sf4, tf7, tf8) +tf9 = cms.Task(f27, f28) + +a1 = cms.EDAnalyzer("an") +a2 = cms.EDAnalyzer("an") +a3 = cms.EDAnalyzer("an") +a4 = cms.EDAnalyzer("an") +a5 = cms.EDAnalyzer("an") +a6 = cms.EDAnalyzer("an") +a7 = cms.EDAnalyzer("an") +a8 = cms.EDAnalyzer("an") +a9 = cms.EDAnalyzer("an") +a10 = cms.EDAnalyzer("an") + +pa1 = cms.Path(a3+a4) +sa1 = cms.Sequence(a5+a6) +sa2 = cms.Sequence(sa1) +pa2 = cms.Path(sa2) +ea1 = cms.EndPath(a7+a8) +sa3 = cms.Sequence(a9+a10) +sa4 = cms.Sequence(sa3) +ea2 = cms.EndPath(sa4) + +o1 = cms.OutputModule("out") +o2 = cms.OutputModule("out") +o7 = cms.OutputModule("out") +o8 = cms.OutputModule("out") +o9 = cms.OutputModule("out") +o10 = cms.OutputModule("out") + +eo1 = cms.EndPath(o7+o8) +so3 = cms.Sequence(o9+o10) +so4 = cms.Sequence(so3) +eo2 = cms.EndPath(so4) + +ess1 = cms.ESSource("ess") # labeled case +ess2 = cms.ESSource("ess2") # unlabeled case +ess3 = cms.ESSource("ess") +ess4 = cms.ESSource("ess4") +ess11 = cms.ESSource("ess") +ess12 = cms.ESSource("ess12") +ess13 = cms.ESSource("ess") +ess14 = cms.ESSource("ess14") +ess15 = cms.ESSource("ess") +ess16 = cms.ESSource("ess16") +ess17 = cms.ESSource("ess") +ess18 = cms.ESSource("ess18") +ess19 = cms.ESSource("ess") +ess20 = cms.ESSource("ess20") +ess21 = cms.ESSource("ess") +ess22 = cms.ESSource("ess22") +ess23 = cms.ESSource("ess") +ess24 = cms.ESSource("ess24") +ess25 = cms.ESSource("ess") +ess26 = cms.ESSource("ess26") +ess27 = cms.ESSource("ess") +ess28 = cms.ESSource("ess28") + +tess10 = cms.Task(ess3, ess4) +tess1 = cms.Task(ess11, ess12) +tess2 = cms.Task(ess13, ess14) +tess3 = cms.Task(ess15, ess16) +tess4 = cms.Task(ess17, ess18) +sess1 = cms.Sequence(tess3, tess4) +sess2 = cms.Sequence(sess1) +pess2 = cms.Path(sess2, tess1, tess2) +tess5 = cms.Task(ess19, ess20) +tess6 = cms.Task(ess21, ess22) +tess7 = cms.Task(ess23, ess24) +tess8 = cms.Task(ess25, ess26) +sess3 = cms.Sequence(tess5, tess6) +sess4 = cms.Sequence(sess3) +eess2 = cms.EndPath(sess4, tess7, tess8) + +esp1 = cms.ESProducer("esp") +esp2 = cms.ESProducer("esp2") +esp3 = cms.ESProducer("esp") +esp4 = cms.ESProducer("esp4") +esp11 = cms.ESProducer("esp") +esp12 = cms.ESProducer("esp12") +esp13 = cms.ESProducer("esp") +esp14 = cms.ESProducer("esp14") +esp15 = cms.ESProducer("esp") +esp16 = cms.ESProducer("esp16") +esp17 = cms.ESProducer("esp") +esp18 = cms.ESProducer("esp18") +esp19 = cms.ESProducer("esp") +esp20 = cms.ESProducer("esp20") +esp21 = cms.ESProducer("esp") +esp22 = cms.ESProducer("esp22") +esp23 = cms.ESProducer("esp") +esp24 = cms.ESProducer("esp24") +esp25 = cms.ESProducer("esp") +esp26 = cms.ESProducer("esp26") +esp27 = cms.ESProducer("esp") +esp28 = cms.ESProducer("esp28") + +tesp10 = cms.Task(esp3, esp4) +tesp1 = cms.Task(esp11, esp12) +tesp2 = cms.Task(esp13, esp14) +tesp3 = cms.Task(esp15, esp16) +tesp4 = cms.Task(esp17, esp18) +sesp1 = cms.Sequence(tesp3, tesp4) +sesp2 = cms.Sequence(sesp1) +pesp2 = cms.Path(sesp2, tesp1, tesp2) +tesp5 = cms.Task(esp19, esp20) +tesp6 = cms.Task(esp21, esp22) +tesp7 = cms.Task(esp23, esp24) +tesp8 = cms.Task(esp25, esp26) +sesp3 = cms.Sequence(tesp5, tesp6) +sesp4 = cms.Sequence(sesp3) +eesp2 = cms.EndPath(sesp4, tesp7, tesp8) + +serv1 = cms.Service("serv1") +serv2 = cms.Service("serv2") +serv3 = cms.Service("serv3") +serv4 = cms.Service("serv4") +serv11 = cms.Service("serv11") +serv12 = cms.Service("serv12") +serv13 = cms.Service("serv13") +serv14 = cms.Service("serv14") +serv15 = cms.Service("serv15") +serv16 = cms.Service("serv16") +serv17 = cms.Service("serv17") +serv18 = cms.Service("serv18") +serv19 = cms.Service("serv19") +serv20 = cms.Service("serv20") +serv21 = cms.Service("serv21") +serv22 = cms.Service("serv22") +serv23 = cms.Service("serv23") +serv24 = cms.Service("serv24") +serv25 = cms.Service("serv25") +serv26 = cms.Service("serv26") +serv27 = cms.Service("serv27") +serv28 = cms.Service("serv28") + +tserv10 = cms.Task(serv3, serv4) +tserv1 = cms.Task(serv11, serv12) +tserv2 = cms.Task(serv13, serv14) +tserv3 = cms.Task(serv15, serv16) +tserv4 = cms.Task(serv17, serv18) +sserv1 = cms.Sequence(tserv3, tserv4) +sserv2 = cms.Sequence(sserv1) +pserv2 = cms.Path(sserv2, tserv1, tserv2) +tserv5 = cms.Task(serv19, serv20) +tserv6 = cms.Task(serv21, serv22) +tserv7 = cms.Task(serv23, serv24) +tserv8 = cms.Task(serv25, serv26) +sserv3 = cms.Sequence(tserv5, tserv6) +sserv4 = cms.Sequence(sserv3) +eserv2 = cms.EndPath(sserv4, tserv7, tserv8) diff --git a/FWCore/PyDevParameterSet/src/MakePyBind11ParameterSets.cc b/FWCore/PyDevParameterSet/src/MakePyBind11ParameterSets.cc index d28386fa7e002..8b2bf34f83188 100644 --- a/FWCore/PyDevParameterSet/src/MakePyBind11ParameterSets.cc +++ b/FWCore/PyDevParameterSet/src/MakePyBind11ParameterSets.cc @@ -25,23 +25,23 @@ makePSetsFromString(std::string const& module) { } namespace edm { - namespace cmspybind11 { + namespace cmspybind11_p3 { std::unique_ptr readConfig(std::string const& config) { - PyBind11ProcessDesc pythonProcessDesc(config); + cmspython3::PyBind11ProcessDesc pythonProcessDesc(config); return pythonProcessDesc.parameterSet(); } std::unique_ptr readConfig(std::string const& config, int argc, char* argv[]) { - PyBind11ProcessDesc pythonProcessDesc(config, argc, argv); + cmspython3::PyBind11ProcessDesc pythonProcessDesc(config, argc, argv); return pythonProcessDesc.parameterSet(); } void makeParameterSets(std::string const& configtext, std::unique_ptr& main) { - PyBind11ProcessDesc pythonProcessDesc(configtext); + cmspython3::PyBind11ProcessDesc pythonProcessDesc(configtext); main = pythonProcessDesc.parameterSet(); } @@ -49,10 +49,10 @@ namespace edm { readPSetsFrom(std::string const& module) { pybind11::scoped_interpreter guard{}; - python::initializePyBind11Module(); + edm::python3::initializePyBind11Module(); std::unique_ptr retVal; { - Python11ParameterSet theProcessPSet; + cmspython3::Python11ParameterSet theProcessPSet; pybind11::object mainModule = pybind11::module::import("__main__"); mainModule.attr("topPSet") = pybind11::cast(&theProcessPSet); @@ -65,7 +65,7 @@ namespace edm { } } catch( pybind11::error_already_set const &e ) { - pythonToCppException("Configuration",e.what()); + cmspython3::pythonToCppException("Configuration",e.what()); } retVal=std::make_unique(ParameterSet(theProcessPSet.pset())); } diff --git a/FWCore/PyDevParameterSet/src/PyBind11Module.h b/FWCore/PyDevParameterSet/src/PyBind11Module.h index 148ddd0620767..88cf5bff2d662 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11Module.h +++ b/FWCore/PyDevParameterSet/src/PyBind11Module.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PythonParameterSet_PyBind11Module_h -#define FWCore_PythonParameterSet_PyBind11Module_h +#ifndef FWCore_PyDevParameterSet_PyBind11Module_h +#define FWCore_PyDevParameterSet_PyBind11Module_h #include "FWCore/PyDevParameterSet/interface/Python11ParameterSet.h" #include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" @@ -32,6 +32,8 @@ #include +using namespace cmspython3; + PYBIND11_MODULE(libFWCorePyDevParameterSet,m) { pybind11::register_exception_translator([](std::exception_ptr p) { diff --git a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc index 62d7d20a4814c..d675f83496db0 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc @@ -9,108 +9,110 @@ #include #include -PyBind11ProcessDesc::PyBind11ProcessDesc() : - theProcessPSet(), - theMainModule(), - theOwnsInterpreter(false) -{ -} - -PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config) : - theProcessPSet(), - theMainModule(), - theOwnsInterpreter(true) -{ - pybind11::initialize_interpreter(); - edm::python::initializePyBind11Module(); - prepareToRead(); - read(config); -} - - -PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config, int argc, char* argv[]) : - theProcessPSet(), - theMainModule(), - theOwnsInterpreter(true) - -{ - pybind11::initialize_interpreter(); - edm::python::initializePyBind11Module(); - prepareToRead(); +namespace cmspython3 { + PyBind11ProcessDesc::PyBind11ProcessDesc() : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(false) { -#if PY_MAJOR_VERSION >= 3 - typedef std::unique_ptr WArgUPtr; - std::vector v_argv; - std::vector vp_argv; - v_argv.reserve(argc); - vp_argv.reserve(argc); - for (int i = 0; i < argc; i++) { - v_argv.emplace_back(Py_DecodeLocale(argv[i], NULL), &PyMem_RawFree); - vp_argv.emplace_back(v_argv.back().get()); } + + PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config) : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(true) + { + pybind11::initialize_interpreter(); + edm::python3::initializePyBind11Module(); + prepareToRead(); + read(config); + } + - wchar_t **argvt = vp_argv.data(); + PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config, int argc, char* argv[]) : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(true) + + { + pybind11::initialize_interpreter(); + edm::python3::initializePyBind11Module(); + prepareToRead(); + { +#if PY_MAJOR_VERSION >= 3 + typedef std::unique_ptr WArgUPtr; + std::vector v_argv; + std::vector vp_argv; + v_argv.reserve(argc); + vp_argv.reserve(argc); + for (int i = 0; i < argc; i++) { + v_argv.emplace_back(Py_DecodeLocale(argv[i], NULL), &PyMem_RawFree); + vp_argv.emplace_back(v_argv.back().get()); + } + + wchar_t **argvt = vp_argv.data(); #else - char **argvt = argv; + char **argvt = argv; #endif - PySys_SetArgv(argc, argvt); + PySys_SetArgv(argc, argvt); + } + read(config); } - read(config); -} - + -PyBind11ProcessDesc::~PyBind11ProcessDesc() { - if ( theOwnsInterpreter ) { - theMainModule=pybind11::object(); - pybind11::finalize_interpreter(); + PyBind11ProcessDesc::~PyBind11ProcessDesc() { + if ( theOwnsInterpreter ) { + theMainModule=pybind11::object(); + pybind11::finalize_interpreter(); + } } -} -void PyBind11ProcessDesc::prepareToRead() { - // pybind11::scoped_interpreter guard{}; - theMainModule = pybind11::module::import("__main__"); - theMainModule.attr("processDesc")=this; - theMainModule.attr("processPSet")=&theProcessPSet; -} + void PyBind11ProcessDesc::prepareToRead() { + // pybind11::scoped_interpreter guard{}; + theMainModule = pybind11::module::import("__main__"); + theMainModule.attr("processDesc")=this; + theMainModule.attr("processPSet")=&theProcessPSet; + } -void PyBind11ProcessDesc::read(std::string const& config) { - try { - // if it ends with py, it's a file - if(config.substr(config.size()-3) == ".py") { - readFile(config); - } else { - readString(config); + void PyBind11ProcessDesc::read(std::string const& config) { + try { + // if it ends with py, it's a file + if(config.substr(config.size()-3) == ".py") { + readFile(config); + } else { + readString(config); + } + } + catch(pybind11::error_already_set const&e) { + cmspython3::pythonToCppException("Configuration",e.what()); } } - catch(pybind11::error_already_set const&e) { - edm::pythonToCppException("Configuration",e.what()); + + void PyBind11ProcessDesc::readFile(std::string const& fileName) { + pybind11::eval_file(fileName); + std::string command("process.fillProcessDesc(processPSet)"); + pybind11::exec(command); + } + + void PyBind11ProcessDesc::readString(std::string const& pyConfig) { + std::string command = pyConfig; + command += "\nprocess.fillProcessDesc(processPSet)"; + pybind11::exec(command.c_str()); + } + + std::unique_ptr PyBind11ProcessDesc::parameterSet() const { + return std::make_unique(theProcessPSet.pset()); } -} - -void PyBind11ProcessDesc::readFile(std::string const& fileName) { - pybind11::eval_file(fileName); - std::string command("process.fillProcessDesc(processPSet)"); - pybind11::exec(command); -} - -void PyBind11ProcessDesc::readString(std::string const& pyConfig) { - std::string command = pyConfig; - command += "\nprocess.fillProcessDesc(processPSet)"; - pybind11::exec(command.c_str()); -} - -std::unique_ptr PyBind11ProcessDesc::parameterSet() const { - return std::make_unique(theProcessPSet.pset()); -} -std::string PyBind11ProcessDesc::dump() const { - std::ostringstream os; - os << theProcessPSet.dump(); - return os.str(); -} + std::string PyBind11ProcessDesc::dump() const { + std::ostringstream os; + os << theProcessPSet.dump(); + return os.str(); + } -// For backward compatibility only. Remove when no longer used. -std::unique_ptr PyBind11ProcessDesc::processDesc() const { - return std::make_unique(parameterSet()); + // For backward compatibility only. Remove when no longer used. + std::unique_ptr PyBind11ProcessDesc::processDesc() const { + return std::make_unique(parameterSet()); + } } diff --git a/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc b/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc index 9a3cf6c027857..57c23339ae458 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11Wrapper.cc @@ -1,7 +1,7 @@ #include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" #include "FWCore/Utilities/interface/Exception.h" //#include -namespace edm { +namespace cmspython3 { void pythonToCppException(const std::string& iType, const std::string &error) { diff --git a/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc b/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc index 53c0ece7ffbea..70c4e0758b8ab 100644 --- a/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc +++ b/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc @@ -1,46 +1,47 @@ #include "FWCore/PyDevParameterSet/interface/Python11ParameterSet.h" #include "FWCore/ParameterSet/interface/FileInPath.h" -Python11ParameterSet::Python11ParameterSet() -: theParameterSet() -{ -} - - -void Python11ParameterSet::addVPSet(bool tracked, std::string const& name, - pybind11::list value) -{ - std::vector v - = edm::toVector(value); - std::vector v2; - v2.reserve(v.size()); - for(std::vector::iterator ppsetItr = v.begin(), ppsetItrEnd = v.end(); - ppsetItr != ppsetItrEnd; ++ppsetItr) +namespace cmspython3 { + Python11ParameterSet::Python11ParameterSet() + : theParameterSet() { - v2.push_back(ppsetItr->theParameterSet); } - addParameter(tracked, name, v2); -} + - -pybind11::list Python11ParameterSet::getVPSet(bool tracked, std::string const& name) -{ - std::vector const& v = - (tracked ? theParameterSet.getParameterSetVector(name) : theParameterSet.getUntrackedParameterSetVector(name)); - - // convert to Python11ParameterSets - pybind11::list l; - for(std::vector::const_iterator psetItr = v.begin(), psetItrEnd = v.end(); - psetItr != psetItrEnd; ++psetItr) + void Python11ParameterSet::addVPSet(bool tracked, std::string const& name, + pybind11::list value) { - l.append(Python11ParameterSet(*psetItr)); + std::vector v + = cmspython3::toVector(value); + std::vector v2; + v2.reserve(v.size()); + for(std::vector::iterator ppsetItr = v.begin(), ppsetItrEnd = v.end(); + ppsetItr != ppsetItrEnd; ++ppsetItr) + { + v2.push_back(ppsetItr->theParameterSet); + } + addParameter(tracked, name, v2); } - return l; -} - - -void Python11ParameterSet::addNewFileInPath(bool tracked, std::string const & name, std::string const & value) -{ - addParameter(tracked, name, edm::FileInPath(value)); + pybind11::list Python11ParameterSet::getVPSet(bool tracked, std::string const& name) + { + std::vector const& v = + (tracked ? theParameterSet.getParameterSetVector(name) : theParameterSet.getUntrackedParameterSetVector(name)); + + // convert to Python11ParameterSets + pybind11::list l; + for(std::vector::const_iterator psetItr = v.begin(), psetItrEnd = v.end(); + psetItr != psetItrEnd; ++psetItr) + { + l.append(Python11ParameterSet(*psetItr)); + } + + return l; + } + + + void Python11ParameterSet::addNewFileInPath(bool tracked, std::string const & name, std::string const & value) + { + addParameter(tracked, name, edm::FileInPath(value)); + } } diff --git a/FWCore/PyDevParameterSet/src/initializePyBind11Module.cc b/FWCore/PyDevParameterSet/src/initializePyBind11Module.cc index 4258cb600be80..a7aabd481e172 100644 --- a/FWCore/PyDevParameterSet/src/initializePyBind11Module.cc +++ b/FWCore/PyDevParameterSet/src/initializePyBind11Module.cc @@ -10,7 +10,7 @@ #include namespace edm { - namespace python { + namespace python3 { void initializePyBind11Module() { char *libFWCoreParameterSet = const_cast("libFWCorePyDevParameterSet"); pybind11::module::import(libFWCoreParameterSet); diff --git a/FWCore/PyDevParameterSet/src/initializePyBind11Module.h b/FWCore/PyDevParameterSet/src/initializePyBind11Module.h index 6336fcd9255f5..d3d231ad6efed 100644 --- a/FWCore/PyDevParameterSet/src/initializePyBind11Module.h +++ b/FWCore/PyDevParameterSet/src/initializePyBind11Module.h @@ -1,5 +1,5 @@ -#ifndef FWCore_PyBind11ParameterSet_initializePyBind11Module_h -#define FWCore_PyBind11ParameterSet_initializePyBind11Module_h +#ifndef FWCore_PyDevParameterSet_initializePyBind11Module_h +#define FWCore_PyDevParameterSet_initializePyBind11Module_h // system include files @@ -7,7 +7,7 @@ // forward declarations namespace edm { - namespace python { + namespace python3 { void initializePyBind11Module(); } } diff --git a/FWCore/PyDevParameterSet/test/makeprocess_t.cppunit.cc b/FWCore/PyDevParameterSet/test/makeprocess_t.cppunit.cc index 4b75ba1783644..11569f63c1d51 100644 --- a/FWCore/PyDevParameterSet/test/makeprocess_t.cppunit.cc +++ b/FWCore/PyDevParameterSet/test/makeprocess_t.cppunit.cc @@ -52,7 +52,7 @@ CPPUNIT_TEST_SUITE_END(); ParameterSetPtr pSet(char const* c) { //ParameterSetPtr result( new edm::ProcessDesc(std::string(c)) ); - ParameterSetPtr result = PyBind11ProcessDesc(std::string(c)).parameterSet(); + ParameterSetPtr result = cmspython3::PyBind11ProcessDesc(std::string(c)).parameterSet(); CPPUNIT_ASSERT(result->getParameter("@process_name") == "test"); return result; } @@ -206,7 +206,7 @@ void testmakeprocess::emptyModuleTest() { void testmakeprocess::taskTest() { char const* kTest = "import FWCore.ParameterSet.Config as cms\n" "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "process.load(\"FWCore.PyDevParameterSet.test.testTask_cff\")\n" "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," "process.ess27, process.ess28, process.esp27, process.esp28," "process.serv27, process.serv28)\n"; @@ -384,7 +384,7 @@ void testmakeprocess::taskTest() { void testmakeprocess::taskTestWithEmptySchedule() { char const* kTest = "import FWCore.ParameterSet.Config as cms\n" "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "process.load(\"FWCore.PyDevParameterSet.test.testTask_cff\")\n" "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," "process.ess27, process.ess28, process.esp27, process.esp28," "process.serv27, process.serv28)\n" @@ -546,7 +546,7 @@ void testmakeprocess::taskTestWithEmptySchedule() { void testmakeprocess::taskTestWithSchedule() { char const* kTest = "import FWCore.ParameterSet.Config as cms\n" "process = cms.Process('test')\n" - "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "process.load(\"FWCore.PyDevParameterSet.test.testTask_cff\")\n" "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," "process.ess27, process.ess28, process.esp27, process.esp28," "process.serv27, process.serv28)\n" diff --git a/FWCore/PyDevParameterSet/test/makepset_t.cppunit.cc b/FWCore/PyDevParameterSet/test/makepset_t.cppunit.cc index 95fe0395a6f13..0b8a0a48adcdc 100644 --- a/FWCore/PyDevParameterSet/test/makepset_t.cppunit.cc +++ b/FWCore/PyDevParameterSet/test/makepset_t.cppunit.cc @@ -94,7 +94,7 @@ void testmakepset::secsourceAux() { std::string config(kTest); // Create the ParameterSet object from this configuration string. - PyBind11ProcessDesc builder(config); + cmspython3::PyBind11ProcessDesc builder(config); std::shared_ptr ps = builder.parameterSet(); CPPUNIT_ASSERT(nullptr != ps.get()); @@ -149,7 +149,7 @@ void testmakepset::usingBlockAux() { std::string config(kTest); // Create the ParameterSet object from this configuration string. - PyBind11ProcessDesc builder(config); + cmspython3::PyBind11ProcessDesc builder(config); std::shared_ptr ps = builder.parameterSet(); CPPUNIT_ASSERT(nullptr != ps.get()); @@ -199,7 +199,7 @@ void testmakepset::fileinpathAux() { bool localArea=false; // Create the ParameterSet object from this configuration string. { - PyBind11ProcessDesc builder(config); + cmspython3::PyBind11ProcessDesc builder(config); std::shared_ptr ps = builder.parameterSet(); CPPUNIT_ASSERT(nullptr != ps.get()); @@ -276,7 +276,7 @@ void testmakepset::fileinpathAux() { std::string config2(kTest2); // Create the ParameterSet object from this configuration string. - PyBind11ProcessDesc builder2(config2); + cmspython3::PyBind11ProcessDesc builder2(config2); unlink(tmpout.c_str()); std::shared_ptr ps2 = builder2.parameterSet(); @@ -355,7 +355,7 @@ void testmakepset::typesTest() { std::string config2(kTest); // Create the ParameterSet object from this configuration string. - PyBind11ProcessDesc builder2(config2); + cmspython3::PyBind11ProcessDesc builder2(config2); std::shared_ptr ps2 = builder2.parameterSet(); edm::ParameterSet const& test = ps2->getParameterSet("p"); diff --git a/FWCore/PyDevParameterSet/test/processbuilder_t.cppunit.cpp b/FWCore/PyDevParameterSet/test/processbuilder_t.cppunit.cpp index 7df92d2692cc5..7c0223f86ccdb 100644 --- a/FWCore/PyDevParameterSet/test/processbuilder_t.cppunit.cpp +++ b/FWCore/PyDevParameterSet/test/processbuilder_t.cppunit.cpp @@ -66,7 +66,7 @@ void testProcessDesc::trivialPathTest() { "process.c = cms.EDProducer('C')\n" "process.p = cms.Path(process.a*process.b*process.c)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -91,7 +91,7 @@ void testProcessDesc::simplePathTest() { ")\n" "process.p = cms.Path(process.a*process.b*process.c)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -132,7 +132,7 @@ void testProcessDesc:: attriggertest () { "process.epath = cms.EndPath(process.output)\n"; try { - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -188,7 +188,7 @@ void testProcessDesc:: sequenceSubstitutionTest () { "process.jets = cms.Sequence(process.somejet1*process.somejet2)\n" "process.path1 = cms.Path(process.cones*process.jets*process.jtanalyzer)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -217,7 +217,7 @@ void testProcessDesc::nestedSequenceSubstitutionTest() { "process.s1 = cms.Sequence( process.a+ process.b)\n" "process.s2 = cms.Sequence(process.s1+ process.c)\n" "process.path1 = cms.Path(process.s2+process.d)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -247,7 +247,7 @@ void testProcessDesc::sequenceSubstitutionTest2() { "process.jets = cms.Sequence(process.somejet1+ process.somejet2)\n" "process.path1 = cms.Path(process.cones+process.jets+ process.jtanalyzer)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -290,7 +290,7 @@ void testProcessDesc::sequenceSubstitutionTest3() { "process.s3 = cms.Sequence(process.aaa*process.bbb*~process.ccc*process.ddd*process.eee)\n" "process.path1 = cms.Path(process.s1+process.s3+process.s2+process.last)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -342,7 +342,7 @@ void testProcessDesc::multiplePathsTest() { "process.path2 = cms.Path(process.jets+ process.anotherjtanalyzer)\n" "process.schedule = cms.Schedule(process.path2, process.path1)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); typedef std::vector Strs; @@ -381,7 +381,7 @@ void testProcessDesc::inconsistentPathTest() { "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" "process.c = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" "process.path1 = cms.Path((process.a*process.b)+ (process.c*process.b))\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); } void testProcessDesc::inconsistentMultiplePathTest() { @@ -398,7 +398,7 @@ void testProcessDesc::inconsistentMultiplePathTest() { "process.path1 = cms.Path(process.cones*process.jtanalyzer)\n" "process.path2 = cms.Path(process.jets*process.jtanalyzer)\n"; - std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + std::shared_ptr test = cmspython3::PyBind11ProcessDesc(str).parameterSet(); } #include diff --git a/FWCore/PyDevParameterSet/test/readpsetsfrom_t.cppunit.cc b/FWCore/PyDevParameterSet/test/readpsetsfrom_t.cppunit.cc index f6ba9d8536809..972efd9400c06 100644 --- a/FWCore/PyDevParameterSet/test/readpsetsfrom_t.cppunit.cc +++ b/FWCore/PyDevParameterSet/test/readpsetsfrom_t.cppunit.cc @@ -45,7 +45,7 @@ void testreadpsetsfrom::simpleTest() "dummy = cms.PSet(b = cms.bool(True))\n" "foo = cms.PSet(a = cms.string('blah'))\n" ; - std::shared_ptr test = edm::cmspybind11::readPSetsFrom(kTest); + std::shared_ptr test = edm::cmspybind11_p3::readPSetsFrom(kTest); CPPUNIT_ASSERT(test->getParameterSet("dummy").getParameter("b")==true); CPPUNIT_ASSERT(test->getParameterSet("foo").getParameter("a")==std::string("blah")); diff --git a/FWCore/PythonFramework/BuildFile.xml b/FWCore/PythonFramework/BuildFile.xml index 8551be07e579f..2d4322a7f6edd 100644 --- a/FWCore/PythonFramework/BuildFile.xml +++ b/FWCore/PythonFramework/BuildFile.xml @@ -1,5 +1,5 @@ - + diff --git a/FWCore/PythonFramework/interface/PythonEventProcessor.h b/FWCore/PythonFramework/interface/PythonEventProcessor.h index 3a484ee58aed8..95741383b91c2 100644 --- a/FWCore/PythonFramework/interface/PythonEventProcessor.h +++ b/FWCore/PythonFramework/interface/PythonEventProcessor.h @@ -20,7 +20,7 @@ // system include files #include "FWCore/Framework/interface/EventProcessor.h" -#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" // user include files diff --git a/FWCore/PythonFramework/python/CmsRun.py b/FWCore/PythonFramework/python/CmsRun.py index 191984d50e9a3..cd3af4e16c823 100644 --- a/FWCore/PythonFramework/python/CmsRun.py +++ b/FWCore/PythonFramework/python/CmsRun.py @@ -1,5 +1,5 @@ import libFWCorePythonFramework as _pf -import libFWCorePyDevParameterSet as _pp +import libFWCorePythonParameterSet as _pp class CmsRun(object): def __init__(self,process): diff --git a/FWCore/PythonFramework/src/PythonEventProcessor.cc b/FWCore/PythonFramework/src/PythonEventProcessor.cc index 46d24bb5182e7..f2a575753b9b3 100644 --- a/FWCore/PythonFramework/src/PythonEventProcessor.cc +++ b/FWCore/PythonFramework/src/PythonEventProcessor.cc @@ -15,7 +15,7 @@ // user include files #include "FWCore/PythonFramework/interface/PythonEventProcessor.h" -#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" #include "FWCore/Framework/interface/defaultCmsRunServices.h" #include "FWCore/ParameterSet/interface/ProcessDesc.h" diff --git a/FWCore/PythonFramework/src/PythonModule.cc b/FWCore/PythonFramework/src/PythonModule.cc index fe62821e6e579..3e8090b79a01a 100644 --- a/FWCore/PythonFramework/src/PythonModule.cc +++ b/FWCore/PythonFramework/src/PythonModule.cc @@ -2,7 +2,7 @@ #define FWCore_PythonFramework_PythonModule_h -#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" #include "FWCore/PythonFramework/interface/PythonEventProcessor.h" #include "FWCore/Utilities/interface/Exception.h" diff --git a/FWCore/PythonParameterSet/BuildFile.xml b/FWCore/PythonParameterSet/BuildFile.xml new file mode 100644 index 0000000000000..883d5efcb1b41 --- /dev/null +++ b/FWCore/PythonParameterSet/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h b/FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h new file mode 100644 index 0000000000000..7bd16e71d990e --- /dev/null +++ b/FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h @@ -0,0 +1,35 @@ +#ifndef FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h +#define FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h + +//---------------------------------------------------------------------- +// Declare functions used to create ParameterSets. +//---------------------------------------------------------------------- + +#include + +#include +#include + +namespace edm { + class ParameterSet; + namespace cmspybind11 { + // input can either be a python file name or a python config string + std::unique_ptr + readConfig(std::string const& config); + + /// same, but with arguments + std::unique_ptr + readConfig(std::string const& config, int argc, char* argv[]); + + /// essentially the same as the previous method + void + makeParameterSets(std::string const& configtext, + std::unique_ptr& main); + + /**finds all the PSets used in the top level module referred as a file or as a string containing + python commands. These PSets are bundled into a top level PSet from which they can be retrieved + */ + std::unique_ptr readPSetsFrom(std::string const& fileOrString); + } +} // namespace edm +#endif diff --git a/FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h b/FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h new file mode 100644 index 0000000000000..0019f07c1a167 --- /dev/null +++ b/FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h @@ -0,0 +1,56 @@ +#ifndef FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h +#define FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h + +#include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h" + +#include + +#include +#include + +namespace edm { + class ParameterSet; + class ProcessDesc; +} + +class PyBind11ProcessDesc { +public: + PyBind11ProcessDesc(); + /** This constructor will parse the given file or string + and create two objects in python-land: + * a PythonProcessDesc named 'processDesc' + * a PythonParameterSet named 'processPSet' + It decides whether it's a file or string by seeing if + it ends in '.py' + */ + PyBind11ProcessDesc(std::string const& config); + + PyBind11ProcessDesc(std::string const& config, int argc, char * argv[]); + + ~PyBind11ProcessDesc(); + + Python11ParameterSet newPSet() const {return Python11ParameterSet();} + + Python11ParameterSet& pset() { return theProcessPSet;} + + std::string dump() const; + + // makes a new (copy) of the ParameterSet + std::unique_ptr parameterSet() const; + + // makes a new (copy) of a ProcessDesc + // For backward compatibility only. Remove when no longer needed. + std::unique_ptr processDesc() const; + +private: + void prepareToRead(); + void read(std::string const& config); + void readFile(std::string const& fileName); + void readString(std::string const& pyConfig); + + Python11ParameterSet theProcessPSet; + pybind11::object theMainModule; + bool theOwnsInterpreter; +}; + +#endif diff --git a/FWCore/PythonParameterSet/interface/PyBind11Wrapper.h b/FWCore/PythonParameterSet/interface/PyBind11Wrapper.h new file mode 100644 index 0000000000000..31bbe3031a275 --- /dev/null +++ b/FWCore/PythonParameterSet/interface/PyBind11Wrapper.h @@ -0,0 +1,37 @@ +#ifndef FWCore_PyBind11ParameterSet_PyBind11Wrapper_h +#define FWCore_PyBind11ParameterSet_PyBind11Wrapper_h + +#include +#include +#include +#include +#include + +namespace edm { +void + pythonToCppException(const std::string& iType, const std::string& error); + + // utility to translate from an STL vector of strings to + // a Python list + + template + pybind11::list toPython11List(const std::vector & v) { + pybind11::list result=pybind11::cast(v); + return result; + } + + // and back. Destroys the input via pop()s - well probably not + template + std::vector toVector(pybind11::list & l) + { + std::vector result; + result.reserve(l.size()); + for(unsigned i = 0; i < l.size(); ++i) + { + result.push_back(l[i].cast()); + } + return result; + } +} + +#endif diff --git a/FWCore/PythonParameterSet/interface/Python11ParameterSet.h b/FWCore/PythonParameterSet/interface/Python11ParameterSet.h new file mode 100644 index 0000000000000..a29477cea83bf --- /dev/null +++ b/FWCore/PythonParameterSet/interface/Python11ParameterSet.h @@ -0,0 +1,131 @@ +#ifndef FWCore_PyBind11ParameterSet_Python11ParameterSet_h +#define FWCore_PyBind11ParameterSet_Python11ParameterSet_h +#include + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h" + +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/ESInputTag.h" +#include "DataFormats/Provenance/interface/EventRange.h" +#include "DataFormats/Provenance/interface/LuminosityBlockID.h" +#include "DataFormats/Provenance/interface/LuminosityBlockRange.h" +#include "DataFormats/Provenance/interface/EventID.h" +#include "DataFormats/Provenance/interface/RunLumiEventNumber.h" + +#include +#include + +class Python11ParameterSet { +public: + Python11ParameterSet(); + + Python11ParameterSet(edm::ParameterSet const& p) + : theParameterSet(p) {} + + template + T + getParameter(bool tracked, std::string const& name) const { + T result; + if(tracked) { + result = theParameterSet.template getParameter(name); + } else { + result = theParameterSet.template getUntrackedParameter(name); + } + return result; + } + + + template + void + addParameter(bool tracked, std::string const& name, T const& value) { + if(tracked) { + theParameterSet.template addParameter(name, value); + } else { + theParameterSet.template addUntrackedParameter(name, value); + } + } + + + /// templated on the type of the contained object + template + pybind11::list + getParameters(bool tracked, std::string const& name) const { + std::vector v = getParameter >(tracked, name); + return edm::toPython11List(v); + } + + /// unfortunate side effect: destroys the original list! + template + void + addParameters(bool tracked, std::string const& name, + pybind11::list value) { + std::vector v = edm::toVector(value); + addParameter(tracked, name, v); + } + + + /// these custom classes do seem to be a hassle + /// to wrap, compared to, say, InputTag + /// maybe we will need to template these someday + void addPSet(bool tracked, std::string const& name, + Python11ParameterSet const& ppset) { + addParameter(tracked, name, ppset.theParameterSet); + } + + + Python11ParameterSet getPSet(bool tracked, std::string const& name) const { + return Python11ParameterSet(getParameter(tracked, name)); + } + + + void addVPSet(bool tracked, std::string const& name, + pybind11::list value); + + pybind11::list getVPSet(bool tracked, std::string const& name); + + // no way to interface straight into the other python InputTag + edm::InputTag newInputTag(std::string const& label, + std::string const& instance, + std::string const& process) { + return edm::InputTag(label, instance, process); + } + + edm::ESInputTag newESInputTag(std::string const& module, + std::string const& data) { + return edm::ESInputTag(module, data); + } + + edm::EventID newEventID(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) { + return edm::EventID(run, lumi, event); + } + + edm::LuminosityBlockID newLuminosityBlockID(unsigned int run, unsigned int lumi) { + return edm::LuminosityBlockID(run, lumi); + } + + edm::LuminosityBlockRange newLuminosityBlockRange(unsigned int start, unsigned int startSub, + unsigned int end, unsigned int endSub) { + return edm::LuminosityBlockRange(start, startSub, end, endSub); + } + + edm::EventRange newEventRange(edm::RunNumber_t start, edm::LuminosityBlockNumber_t startLumi, edm::EventNumber_t startSub, + edm::RunNumber_t end, edm::LuminosityBlockNumber_t endLumi, edm::EventNumber_t endSub) { + return edm::EventRange(start, startLumi, startSub, end, endLumi, endSub); + } + + void addNewFileInPath(bool tracked, std::string const& name, std::string const& value); + + Python11ParameterSet newPSet() const {return Python11ParameterSet();} + + edm::ParameterSet& pset() {return theParameterSet;} + + edm::ParameterSet const& pset() const {return theParameterSet;} + + std::string dump() const {return theParameterSet.dump();} + +private: + edm::ParameterSet theParameterSet; +}; + +#endif diff --git a/FWCore/PythonParameterSet/python/test/testTask_cff.py b/FWCore/PythonParameterSet/python/test/testTask_cff.py new file mode 100644 index 0000000000000..0244ccbb4ec47 --- /dev/null +++ b/FWCore/PythonParameterSet/python/test/testTask_cff.py @@ -0,0 +1,248 @@ +import FWCore.ParameterSet.Config as cms + +m1 = cms.EDProducer("prod") +m2 = cms.EDProducer("prod") +m3 = cms.EDProducer("prod") +m4 = cms.EDProducer("prod") +m5 = cms.EDProducer("prod") +m6 = cms.EDProducer("prod") +m7 = cms.EDProducer("prod") +m8 = cms.EDProducer("prod") +m9 = cms.EDProducer("prod") +m10 = cms.EDProducer("prod") +m11 = cms.EDProducer("prod") +m12 = cms.EDProducer("prod") +m13 = cms.EDProducer("prod") +m14 = cms.EDProducer("prod") +m15 = cms.EDProducer("prod") +m16 = cms.EDProducer("prod") +m17 = cms.EDProducer("prod") +m18 = cms.EDProducer("prod") +m19 = cms.EDProducer("prod") +m20 = cms.EDProducer("prod") +m21 = cms.EDProducer("prod") +m22 = cms.EDProducer("prod") +m23 = cms.EDProducer("prod") +m24 = cms.EDProducer("prod") +m25 = cms.EDProducer("prod") +m26 = cms.EDProducer("prod") +m27 = cms.EDProducer("prod") +m28 = cms.EDProducer("prod") +m29 = cms.EDProducer("prod") +m30 = cms.EDProducer("prod") + +p1 = cms.Path(m3+m4) +t1 = cms.Task(m11, m12) +t2 = cms.Task(m13, m14) +t3 = cms.Task(m15, m16) +t4 = cms.Task(m17, m18) +s1 = cms.Sequence(m5+m6, t3, t4) +s2 = cms.Sequence(s1) +p2 = cms.Path(s2, t1, t2) +e1 = cms.EndPath(m7+m8) +t5 = cms.Task(m19, m20) +t6 = cms.Task(m21, m22) +t7 = cms.Task(m23, m24) +t8 = cms.Task(m25, m26) +s3 = cms.Sequence(m9+m10, t5, t6) +s4 = cms.Sequence(s3) +e2 = cms.EndPath(s4, t7, t8) +t9 = cms.Task(m27, m28) + +f1 = cms.EDFilter("filt") +f2 = cms.EDFilter("filt") +f3 = cms.EDFilter("filt") +f4 = cms.EDFilter("filt") +f5 = cms.EDFilter("filt") +f6 = cms.EDFilter("filt") +f7 = cms.EDFilter("filt") +f8 = cms.EDFilter("filt") +f9 = cms.EDFilter("filt") +f10 = cms.EDFilter("filt") +f11 = cms.EDFilter("filt") +f12 = cms.EDFilter("filt") +f13 = cms.EDFilter("filt") +f14 = cms.EDFilter("filt") +f15 = cms.EDFilter("filt") +f16 = cms.EDFilter("filt") +f17 = cms.EDFilter("filt") +f18 = cms.EDFilter("filt") +f19 = cms.EDFilter("filt") +f20 = cms.EDFilter("filt") +f21 = cms.EDFilter("filt") +f22 = cms.EDFilter("filt") +f23 = cms.EDFilter("filt") +f24 = cms.EDFilter("filt") +f25 = cms.EDFilter("filt") +f26 = cms.EDFilter("filt") +f27 = cms.EDFilter("filt") +f28 = cms.EDFilter("filt") +f29 = cms.EDFilter("filt") +f30 = cms.EDFilter("filt") + +pf1 = cms.Path(f3+f4) +tf1 = cms.Task(f11, f12) +tf2 = cms.Task(f13, f14) +tf3 = cms.Task(f15, f16) +tf4 = cms.Task(f17, f18) +sf1 = cms.Sequence(f5+f6, tf3, tf4) +sf2 = cms.Sequence(sf1) +pf2 = cms.Path(sf2, tf1, tf2) +ef1 = cms.EndPath(f7+f8) +tf5 = cms.Task(f19, f20) +tf6 = cms.Task(f21, f22) +tf7 = cms.Task(f23, f24) +tf8 = cms.Task(f25, f26) +sf3 = cms.Sequence(f9+f10, tf5, tf6) +sf4 = cms.Sequence(sf3) +ef2 = cms.EndPath(sf4, tf7, tf8) +tf9 = cms.Task(f27, f28) + +a1 = cms.EDAnalyzer("an") +a2 = cms.EDAnalyzer("an") +a3 = cms.EDAnalyzer("an") +a4 = cms.EDAnalyzer("an") +a5 = cms.EDAnalyzer("an") +a6 = cms.EDAnalyzer("an") +a7 = cms.EDAnalyzer("an") +a8 = cms.EDAnalyzer("an") +a9 = cms.EDAnalyzer("an") +a10 = cms.EDAnalyzer("an") + +pa1 = cms.Path(a3+a4) +sa1 = cms.Sequence(a5+a6) +sa2 = cms.Sequence(sa1) +pa2 = cms.Path(sa2) +ea1 = cms.EndPath(a7+a8) +sa3 = cms.Sequence(a9+a10) +sa4 = cms.Sequence(sa3) +ea2 = cms.EndPath(sa4) + +o1 = cms.OutputModule("out") +o2 = cms.OutputModule("out") +o7 = cms.OutputModule("out") +o8 = cms.OutputModule("out") +o9 = cms.OutputModule("out") +o10 = cms.OutputModule("out") + +eo1 = cms.EndPath(o7+o8) +so3 = cms.Sequence(o9+o10) +so4 = cms.Sequence(so3) +eo2 = cms.EndPath(so4) + +ess1 = cms.ESSource("ess") # labeled case +ess2 = cms.ESSource("ess2") # unlabeled case +ess3 = cms.ESSource("ess") +ess4 = cms.ESSource("ess4") +ess11 = cms.ESSource("ess") +ess12 = cms.ESSource("ess12") +ess13 = cms.ESSource("ess") +ess14 = cms.ESSource("ess14") +ess15 = cms.ESSource("ess") +ess16 = cms.ESSource("ess16") +ess17 = cms.ESSource("ess") +ess18 = cms.ESSource("ess18") +ess19 = cms.ESSource("ess") +ess20 = cms.ESSource("ess20") +ess21 = cms.ESSource("ess") +ess22 = cms.ESSource("ess22") +ess23 = cms.ESSource("ess") +ess24 = cms.ESSource("ess24") +ess25 = cms.ESSource("ess") +ess26 = cms.ESSource("ess26") +ess27 = cms.ESSource("ess") +ess28 = cms.ESSource("ess28") + +tess10 = cms.Task(ess3, ess4) +tess1 = cms.Task(ess11, ess12) +tess2 = cms.Task(ess13, ess14) +tess3 = cms.Task(ess15, ess16) +tess4 = cms.Task(ess17, ess18) +sess1 = cms.Sequence(tess3, tess4) +sess2 = cms.Sequence(sess1) +pess2 = cms.Path(sess2, tess1, tess2) +tess5 = cms.Task(ess19, ess20) +tess6 = cms.Task(ess21, ess22) +tess7 = cms.Task(ess23, ess24) +tess8 = cms.Task(ess25, ess26) +sess3 = cms.Sequence(tess5, tess6) +sess4 = cms.Sequence(sess3) +eess2 = cms.EndPath(sess4, tess7, tess8) + +esp1 = cms.ESProducer("esp") +esp2 = cms.ESProducer("esp2") +esp3 = cms.ESProducer("esp") +esp4 = cms.ESProducer("esp4") +esp11 = cms.ESProducer("esp") +esp12 = cms.ESProducer("esp12") +esp13 = cms.ESProducer("esp") +esp14 = cms.ESProducer("esp14") +esp15 = cms.ESProducer("esp") +esp16 = cms.ESProducer("esp16") +esp17 = cms.ESProducer("esp") +esp18 = cms.ESProducer("esp18") +esp19 = cms.ESProducer("esp") +esp20 = cms.ESProducer("esp20") +esp21 = cms.ESProducer("esp") +esp22 = cms.ESProducer("esp22") +esp23 = cms.ESProducer("esp") +esp24 = cms.ESProducer("esp24") +esp25 = cms.ESProducer("esp") +esp26 = cms.ESProducer("esp26") +esp27 = cms.ESProducer("esp") +esp28 = cms.ESProducer("esp28") + +tesp10 = cms.Task(esp3, esp4) +tesp1 = cms.Task(esp11, esp12) +tesp2 = cms.Task(esp13, esp14) +tesp3 = cms.Task(esp15, esp16) +tesp4 = cms.Task(esp17, esp18) +sesp1 = cms.Sequence(tesp3, tesp4) +sesp2 = cms.Sequence(sesp1) +pesp2 = cms.Path(sesp2, tesp1, tesp2) +tesp5 = cms.Task(esp19, esp20) +tesp6 = cms.Task(esp21, esp22) +tesp7 = cms.Task(esp23, esp24) +tesp8 = cms.Task(esp25, esp26) +sesp3 = cms.Sequence(tesp5, tesp6) +sesp4 = cms.Sequence(sesp3) +eesp2 = cms.EndPath(sesp4, tesp7, tesp8) + +serv1 = cms.Service("serv1") +serv2 = cms.Service("serv2") +serv3 = cms.Service("serv3") +serv4 = cms.Service("serv4") +serv11 = cms.Service("serv11") +serv12 = cms.Service("serv12") +serv13 = cms.Service("serv13") +serv14 = cms.Service("serv14") +serv15 = cms.Service("serv15") +serv16 = cms.Service("serv16") +serv17 = cms.Service("serv17") +serv18 = cms.Service("serv18") +serv19 = cms.Service("serv19") +serv20 = cms.Service("serv20") +serv21 = cms.Service("serv21") +serv22 = cms.Service("serv22") +serv23 = cms.Service("serv23") +serv24 = cms.Service("serv24") +serv25 = cms.Service("serv25") +serv26 = cms.Service("serv26") +serv27 = cms.Service("serv27") +serv28 = cms.Service("serv28") + +tserv10 = cms.Task(serv3, serv4) +tserv1 = cms.Task(serv11, serv12) +tserv2 = cms.Task(serv13, serv14) +tserv3 = cms.Task(serv15, serv16) +tserv4 = cms.Task(serv17, serv18) +sserv1 = cms.Sequence(tserv3, tserv4) +sserv2 = cms.Sequence(sserv1) +pserv2 = cms.Path(sserv2, tserv1, tserv2) +tserv5 = cms.Task(serv19, serv20) +tserv6 = cms.Task(serv21, serv22) +tserv7 = cms.Task(serv23, serv24) +tserv8 = cms.Task(serv25, serv26) +sserv3 = cms.Sequence(tserv5, tserv6) +sserv4 = cms.Sequence(sserv3) +eserv2 = cms.EndPath(sserv4, tserv7, tserv8) diff --git a/FWCore/PythonParameterSet/src/MakePyBind11ParameterSets.cc b/FWCore/PythonParameterSet/src/MakePyBind11ParameterSets.cc new file mode 100644 index 0000000000000..d2201d3ab9cab --- /dev/null +++ b/FWCore/PythonParameterSet/src/MakePyBind11ParameterSets.cc @@ -0,0 +1,75 @@ +#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" +#include "initializePyBind11Module.h" +#include + +static +void +makePSetsFromFile(std::string const& fileName) { + std::string initCommand("from FWCore.ParameterSet.Types import makeCppPSet\n" + "exec(open('"); + initCommand += fileName + "').read())"; + pybind11::exec(initCommand); + pybind11::exec("makeCppPSet(locals(), topPSet)"); +} + +static +void +makePSetsFromString(std::string const& module) { + std::string command = module; + command += "\nfrom FWCore.ParameterSet.Types import makeCppPSet\nmakeCppPSet(locals(), topPSet)"; + pybind11::exec(command); +} + +namespace edm { + namespace cmspybind11 { + std::unique_ptr + readConfig(std::string const& config) { + PyBind11ProcessDesc pythonProcessDesc(config); + return pythonProcessDesc.parameterSet(); + } + + std::unique_ptr + readConfig(std::string const& config, int argc, char* argv[]) { + PyBind11ProcessDesc pythonProcessDesc(config, argc, argv); + return pythonProcessDesc.parameterSet(); + } + + void + makeParameterSets(std::string const& configtext, + std::unique_ptr& main) { + PyBind11ProcessDesc pythonProcessDesc(configtext); + main = pythonProcessDesc.parameterSet(); + } + + std::unique_ptr + readPSetsFrom(std::string const& module) { + + pybind11::scoped_interpreter guard{}; + python::initializePyBind11Module(); + std::unique_ptr retVal; + { + Python11ParameterSet theProcessPSet; + pybind11::object mainModule = pybind11::module::import("__main__"); + mainModule.attr("topPSet") = pybind11::cast(&theProcessPSet); + + try { + // if it ends with py, it's a file + if(module.substr(module.size()-3) == ".py") { + makePSetsFromFile(module); + } else { + makePSetsFromString(module); + } + } + catch( pybind11::error_already_set const &e ) { + pythonToCppException("Configuration",e.what()); + } + retVal=std::make_unique(ParameterSet(theProcessPSet.pset())); + } + return retVal; + } + } +} // namespace edm diff --git a/FWCore/PythonParameterSet/src/PyBind11Module.h b/FWCore/PythonParameterSet/src/PyBind11Module.h new file mode 100644 index 0000000000000..33080d0735f43 --- /dev/null +++ b/FWCore/PythonParameterSet/src/PyBind11Module.h @@ -0,0 +1,184 @@ +#ifndef FWCore_PythonParameterSet_PyBind11Module_h +#define FWCore_PythonParameterSet_PyBind11Module_h + +#include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" + +#include "DataFormats/Provenance/interface/EventRange.h" +#include "DataFormats/Provenance/interface/LuminosityBlockID.h" +#include "DataFormats/Provenance/interface/LuminosityBlockRange.h" +#include "DataFormats/Provenance/interface/EventID.h" +#include "DataFormats/Provenance/interface/RunLumiEventNumber.h" +#include "FWCore/Utilities/interface/ESInputTag.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include +#include + +// This is to give some special handling to cms::Exceptions thrown +// in C++ code called by python. Only at the very top level do +// we need the exception message returned by the function "what". +// We only need the central message here as this will get converted +// back into a cms::Exception again when control rises back into +// the C++ code. If necessary it would probably be possible to +// improve these messages even more by adding something in the python +// to add module type and label context to the messages being caught +// here. At this point we did not think it worth the time to implement. +//namespace { +// void translatorlibFWCorePythonParameterSet(cms::Exception const& ex) { +// PyErr_SetString(PyExc_RuntimeError, ex.message().c_str()); +// } +//} + +#include + +PYBIND11_MODULE(libFWCorePythonParameterSet,m) +{ + pybind11::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const cms::Exception &e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + } + }); + + pybind11::class_(m,"InputTag") + .def(pybind11::init<>()) + .def(pybind11::init()) + .def(pybind11::init()) + .def(pybind11::init()) + .def("label", &edm::InputTag::label, pybind11::return_value_policy::copy) + .def("instance", &edm::InputTag::instance, pybind11::return_value_policy::copy) + .def("process", &edm::InputTag::process, pybind11::return_value_policy::copy) + ; + + pybind11::class_(m,"ESInputTag") + .def(pybind11::init()) + .def(pybind11::init()) + .def("module", &edm::ESInputTag::module, pybind11::return_value_policy::copy) + .def("data", &edm::ESInputTag::data, pybind11::return_value_policy::copy) + ; + + pybind11::class_(m,"EventID") + .def(pybind11::init()) + .def("run", &edm::EventID::run) + .def("luminosityBlock", &edm::EventID::luminosityBlock) + .def("event", &edm::EventID::event) + ; + + pybind11::class_(m,"LuminosityBlockID") + .def(pybind11::init()) + .def("run", &edm::LuminosityBlockID::run) + .def("luminosityBlock", &edm::LuminosityBlockID::luminosityBlock) + ; + + pybind11::class_(m,"FileInPath") + .def(pybind11::init()) + .def("fullPath", &edm::FileInPath::fullPath) + .def("relativePath", &edm::FileInPath::relativePath) + ; + + pybind11::class_(m,"LuminosityBlockRange") + .def(pybind11::init()) + .def("start", &edm::LuminosityBlockRange::startRun) + .def("startSub", &edm::LuminosityBlockRange::startLumi) + .def("end", &edm::LuminosityBlockRange::endRun) + .def("endSub", &edm::LuminosityBlockRange::endLumi) + ; + + pybind11::class_(m,"EventRange") + .def(pybind11::init()) + .def("start", &edm::EventRange::startRun) + .def("startLumi", &edm::EventRange::startLumi) + .def("startSub", &edm::EventRange::startEvent) + .def("end", &edm::EventRange::endRun) + .def("endLumi", &edm::EventRange::endLumi) + .def("endSub", &edm::EventRange::endEvent) + ; + + pybind11::class_(m,"ParameterSet") + .def(pybind11::init<>()) + .def("addInt32", &Python11ParameterSet::addParameter) + .def("getInt32", &Python11ParameterSet::getParameter) + .def("addVInt32", &Python11ParameterSet::addParameters) + .def("getVInt32", &Python11ParameterSet::getParameters) + .def("addUInt32", &Python11ParameterSet::addParameter) + .def("getUInt32", &Python11ParameterSet::getParameter) + .def("addVUInt32", &Python11ParameterSet::addParameters) + .def("getVUInt32", &Python11ParameterSet::getParameters) + .def("addInt64", &Python11ParameterSet::addParameter) + .def("getInt64", &Python11ParameterSet::getParameter) + .def("addUInt64", &Python11ParameterSet::addParameter) + .def("getUInt64", &Python11ParameterSet::getParameter) + .def("addVInt64", &Python11ParameterSet::addParameters) + .def("getVInt64", &Python11ParameterSet::getParameters) + .def("addVUInt64", &Python11ParameterSet::addParameters) + .def("getVUInt64", &Python11ParameterSet::getParameters) + .def("addDouble", &Python11ParameterSet::addParameter) + .def("getDouble", &Python11ParameterSet::getParameter) + .def("addVDouble", &Python11ParameterSet::addParameters) + .def("getVDouble", &Python11ParameterSet::getParameters) + .def("addBool", &Python11ParameterSet::addParameter) + .def("getBool", &Python11ParameterSet::getParameter) + .def("addString", &Python11ParameterSet::addParameter) + .def("getString", &Python11ParameterSet::getParameter) + .def("addVString", &Python11ParameterSet::addParameters) + .def("getVString", &Python11ParameterSet::getParameters) + .def("addInputTag", &Python11ParameterSet::addParameter) + .def("getInputTag", &Python11ParameterSet::getParameter) + .def("addVInputTag", &Python11ParameterSet::addParameters) + .def("getVInputTag", &Python11ParameterSet::getParameters) + .def("addESInputTag", &Python11ParameterSet::addParameter) + .def("getESInputTag", &Python11ParameterSet::getParameter) + .def("addVESInputTag", &Python11ParameterSet::addParameters) + .def("getVESInputTag", &Python11ParameterSet::getParameters) + .def("addEventID", &Python11ParameterSet::addParameter) + .def("getEventID", &Python11ParameterSet::getParameter) + .def("addVEventID", &Python11ParameterSet::addParameters) + .def("getVEventID", &Python11ParameterSet::getParameters) + .def("addLuminosityBlockID", &Python11ParameterSet::addParameter) + .def("getLuminosityBlockID", &Python11ParameterSet::getParameter) + .def("addVLuminosityBlockID", &Python11ParameterSet::addParameters) + .def("getVLuminosityBlockID", &Python11ParameterSet::getParameters) + .def("addLuminosityBlockRange", &Python11ParameterSet::addParameter) + .def("getLuminosityBlockRange", &Python11ParameterSet::getParameter) + .def("addVLuminosityBlockRange", &Python11ParameterSet::addParameters) + .def("getVLuminosityBlockRange", &Python11ParameterSet::getParameters) + .def("addEventRange", &Python11ParameterSet::addParameter) + .def("getEventRange", &Python11ParameterSet::getParameter) + .def("addVEventRange", &Python11ParameterSet::addParameters) + .def("getVEventRange", &Python11ParameterSet::getParameters) + .def("addPSet", &Python11ParameterSet::addPSet) + .def("getPSet", &Python11ParameterSet::getPSet) + .def("addVPSet", &Python11ParameterSet::addVPSet) + .def("getVPSet", &Python11ParameterSet::getVPSet) + .def("addFileInPath", &Python11ParameterSet::addParameter) + .def("getFileInPath", &Python11ParameterSet::getParameter) + .def("newInputTag", &Python11ParameterSet::newInputTag) + .def("newESInputTag", &Python11ParameterSet::newESInputTag) + .def("newEventID", &Python11ParameterSet::newEventID) + .def("newLuminosityBlockID", &Python11ParameterSet::newLuminosityBlockID) + .def("newLuminosityBlockRange", &Python11ParameterSet::newLuminosityBlockRange) + .def("newEventRange", &Python11ParameterSet::newEventRange) + .def("addNewFileInPath", &Python11ParameterSet::addNewFileInPath) + .def("newPSet", &Python11ParameterSet::newPSet) + .def("dump", &Python11ParameterSet::dump) + ; + + pybind11::class_(m,"ProcessDesc")//, pybind11::init<>()) + .def(pybind11::init<>()) + .def(pybind11::init()) + .def("newPSet", &PyBind11ProcessDesc::newPSet) + .def("pset", &PyBind11ProcessDesc::pset, pybind11::return_value_policy::reference) + .def("dump", &PyBind11ProcessDesc::dump) + ; + +} + + + + + + +#endif diff --git a/FWCore/PythonParameterSet/src/PyBind11ProcessDesc.cc b/FWCore/PythonParameterSet/src/PyBind11ProcessDesc.cc new file mode 100644 index 0000000000000..7d5c90a7173ff --- /dev/null +++ b/FWCore/PythonParameterSet/src/PyBind11ProcessDesc.cc @@ -0,0 +1,116 @@ +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ProcessDesc.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PythonParameterSet/src/initializePyBind11Module.h" +#include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h" +#include +#include + +#include +#include + +PyBind11ProcessDesc::PyBind11ProcessDesc() : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(false) +{ +} + +PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config) : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(true) +{ + pybind11::initialize_interpreter(); + edm::python::initializePyBind11Module(); + prepareToRead(); + read(config); +} + + +PyBind11ProcessDesc::PyBind11ProcessDesc(std::string const& config, int argc, char* argv[]) : + theProcessPSet(), + theMainModule(), + theOwnsInterpreter(true) + +{ + pybind11::initialize_interpreter(); + edm::python::initializePyBind11Module(); + prepareToRead(); + { +#if PY_MAJOR_VERSION >= 3 + typedef std::unique_ptr WArgUPtr; + std::vector v_argv; + std::vector vp_argv; + v_argv.reserve(argc); + vp_argv.reserve(argc); + for (int i = 0; i < argc; i++) { + v_argv.emplace_back(Py_DecodeLocale(argv[i], NULL), &PyMem_RawFree); + vp_argv.emplace_back(v_argv.back().get()); + } + + wchar_t **argvt = vp_argv.data(); +#else + char **argvt = argv; +#endif + + PySys_SetArgv(argc, argvt); + } + read(config); +} + + +PyBind11ProcessDesc::~PyBind11ProcessDesc() { + if ( theOwnsInterpreter ) { + theMainModule=pybind11::object(); + pybind11::finalize_interpreter(); + } +} + +void PyBind11ProcessDesc::prepareToRead() { + // pybind11::scoped_interpreter guard{}; + theMainModule = pybind11::module::import("__main__"); + theMainModule.attr("processDesc")=this; + theMainModule.attr("processPSet")=&theProcessPSet; +} + +void PyBind11ProcessDesc::read(std::string const& config) { + try { + // if it ends with py, it's a file + if(config.substr(config.size()-3) == ".py") { + readFile(config); + } else { + readString(config); + } + } + catch(pybind11::error_already_set const&e) { + edm::pythonToCppException("Configuration",e.what()); + } +} + +void PyBind11ProcessDesc::readFile(std::string const& fileName) { + pybind11::eval_file(fileName); + std::string command("process.fillProcessDesc(processPSet)"); + pybind11::exec(command); +} + +void PyBind11ProcessDesc::readString(std::string const& pyConfig) { + std::string command = pyConfig; + command += "\nprocess.fillProcessDesc(processPSet)"; + pybind11::exec(command.c_str()); +} + +std::unique_ptr PyBind11ProcessDesc::parameterSet() const { + return std::make_unique(theProcessPSet.pset()); +} + +std::string PyBind11ProcessDesc::dump() const { + std::ostringstream os; + os << theProcessPSet.dump(); + return os.str(); +} + +// For backward compatibility only. Remove when no longer used. +std::unique_ptr PyBind11ProcessDesc::processDesc() const { + return std::make_unique(parameterSet()); +} diff --git a/FWCore/PythonParameterSet/src/PyBind11Wrapper.cc b/FWCore/PythonParameterSet/src/PyBind11Wrapper.cc new file mode 100644 index 0000000000000..9b752c43b17c1 --- /dev/null +++ b/FWCore/PythonParameterSet/src/PyBind11Wrapper.cc @@ -0,0 +1,12 @@ +#include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h" +#include "FWCore/Utilities/interface/Exception.h" +//#include +namespace edm { + + void pythonToCppException(const std::string& iType, const std::string &error) + { + throw cms::Exception(iType)<<" unknown python problem occurred.\n"<< error << std::endl; + } +} + + diff --git a/FWCore/PythonParameterSet/src/Python11ParameterSet.cc b/FWCore/PythonParameterSet/src/Python11ParameterSet.cc new file mode 100644 index 0000000000000..4f879c04bdfaa --- /dev/null +++ b/FWCore/PythonParameterSet/src/Python11ParameterSet.cc @@ -0,0 +1,46 @@ +#include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" + +Python11ParameterSet::Python11ParameterSet() +: theParameterSet() +{ +} + + +void Python11ParameterSet::addVPSet(bool tracked, std::string const& name, + pybind11::list value) +{ + std::vector v + = edm::toVector(value); + std::vector v2; + v2.reserve(v.size()); + for(std::vector::iterator ppsetItr = v.begin(), ppsetItrEnd = v.end(); + ppsetItr != ppsetItrEnd; ++ppsetItr) + { + v2.push_back(ppsetItr->theParameterSet); + } + addParameter(tracked, name, v2); +} + + +pybind11::list Python11ParameterSet::getVPSet(bool tracked, std::string const& name) +{ + std::vector const& v = + (tracked ? theParameterSet.getParameterSetVector(name) : theParameterSet.getUntrackedParameterSetVector(name)); + + // convert to Python11ParameterSets + pybind11::list l; + for(std::vector::const_iterator psetItr = v.begin(), psetItrEnd = v.end(); + psetItr != psetItrEnd; ++psetItr) + { + l.append(Python11ParameterSet(*psetItr)); + } + + return l; +} + + +void Python11ParameterSet::addNewFileInPath(bool tracked, std::string const & name, std::string const & value) +{ + addParameter(tracked, name, edm::FileInPath(value)); +} diff --git a/FWCore/PythonParameterSet/src/initializePyBind11Module.cc b/FWCore/PythonParameterSet/src/initializePyBind11Module.cc new file mode 100644 index 0000000000000..89d188d1cedf8 --- /dev/null +++ b/FWCore/PythonParameterSet/src/initializePyBind11Module.cc @@ -0,0 +1,19 @@ +// -*- C++ -*- +// +// Package: PyBind11ParameterSet +// Class : initializePyBind11Module +// + +#include "FWCore/PythonParameterSet/src/initializePyBind11Module.h" +#include "PyBind11Module.h" +#include +#include + +namespace edm { + namespace python { + void initializePyBind11Module() { + char *libFWCoreParameterSet = const_cast("libFWCorePythonParameterSet"); + pybind11::module::import(libFWCoreParameterSet); + } + } +} diff --git a/FWCore/PythonParameterSet/src/initializePyBind11Module.h b/FWCore/PythonParameterSet/src/initializePyBind11Module.h new file mode 100644 index 0000000000000..6336fcd9255f5 --- /dev/null +++ b/FWCore/PythonParameterSet/src/initializePyBind11Module.h @@ -0,0 +1,16 @@ +#ifndef FWCore_PyBind11ParameterSet_initializePyBind11Module_h +#define FWCore_PyBind11ParameterSet_initializePyBind11Module_h + +// system include files + +// user include files + +// forward declarations +namespace edm { + namespace python { + void initializePyBind11Module(); + } +} + + +#endif diff --git a/FWCore/PythonParameterSet/test/BuildFile.xml b/FWCore/PythonParameterSet/test/BuildFile.xml new file mode 100644 index 0000000000000..6f434ec3733ec --- /dev/null +++ b/FWCore/PythonParameterSet/test/BuildFile.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/FWCore/PythonParameterSet/test/fip.txt b/FWCore/PythonParameterSet/test/fip.txt new file mode 100644 index 0000000000000..a52b9dba51d13 --- /dev/null +++ b/FWCore/PythonParameterSet/test/fip.txt @@ -0,0 +1 @@ +Dummy file for the FileInPath test. diff --git a/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc b/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc new file mode 100644 index 0000000000000..974caa52c3895 --- /dev/null +++ b/FWCore/PythonParameterSet/test/makeprocess_t.cppunit.cc @@ -0,0 +1,775 @@ +/* + * makeprocess_t.cc + * EDMProto + * + * Created by Chris Jones on 5/18/05. + * + */ + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +class testmakeprocess: public CppUnit::TestFixture { +CPPUNIT_TEST_SUITE(testmakeprocess); +CPPUNIT_TEST(simpleProcessTest); +CPPUNIT_TEST(usingTest); +CPPUNIT_TEST(pathTest); +CPPUNIT_TEST(moduleTest); +CPPUNIT_TEST(emptyModuleTest); +CPPUNIT_TEST(taskTest); +CPPUNIT_TEST(taskTestWithEmptySchedule); +CPPUNIT_TEST(taskTestWithSchedule); +//CPPUNIT_TEST(windowsLineEndingTest); +//CPPUNIT_TEST_EXCEPTION(emptyPsetTest,edm::Exception); +CPPUNIT_TEST_SUITE_END(); +public: + void setUp(){} + void tearDown(){} + void simpleProcessTest(); + void usingTest(); + void pathTest(); + void moduleTest(); + void emptyModuleTest(); + void taskTest(); + void taskTestWithEmptySchedule(); + void taskTestWithSchedule(); + //void windowsLineEndingTest(); +private: + + typedef std::shared_ptr ParameterSetPtr; + ParameterSetPtr pSet(char const* c) { + + //ParameterSetPtr result( new edm::ProcessDesc(std::string(c)) ); + ParameterSetPtr result = PyBind11ProcessDesc(std::string(c)).parameterSet(); + CPPUNIT_ASSERT(result->getParameter("@process_name") == "test"); + return result; + } + // void emptyPsetTest(); +}; + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(testmakeprocess); + +void testmakeprocess::simpleProcessTest() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "dummy = cms.PSet(b = cms.bool(True))\n"; + ParameterSetPtr test = pSet(kTest); +} + +void testmakeprocess::usingTest() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.dummy = cms.PSet(\n" + " b = cms.bool(True)\n" + ")\n" + "process.dummy2 = cms.PSet(\n" + " d = cms.bool(True)\n" + ")\n" + "process.m1 = cms.EDFilter('Dummy',\n" + " process.dummy\n" + ")\n" + "process.m2 = cms.EDFilter('Dummy2',\n" + " process.dummy2\n" + ")\n" + "process.p = cms.Path(process.m1+process.m2)\n"; + + ParameterSetPtr test = pSet(kTest); + + //CPPUNIT_ASSERT(test->getParameterSet("dummy").getBool("b") == true); + CPPUNIT_ASSERT(test->getParameterSet("m1").getParameter("b") == true); + CPPUNIT_ASSERT(test->getParameterSet("m2").getParameter("d") == true); +} + +void testmakeprocess::pathTest() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone5 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(5)\n" + ")\n" + "process.cone7 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.jtanalyzer = cms.EDAnalyzer('jtanalyzer')\n" + "process.writer = cms.OutputModule('Writer')\n" + "process.cones = cms.Sequence(process.cone5*process.cone7)\n" + "process.term1 = cms.Path(process.cones+process.jtanalyzer)\n" + "process.atEnd = cms.EndPath(process.writer)\n"; + + + ParameterSetPtr test = pSet(kTest); + //CPPUNIT_ASSERT(test->pathFragments().size() == 5); + + edm::ParameterSet& myparams = *(test); + myparams.registerIt(); + std::string rep = myparams.toString(); + edm::ParameterSet copy(rep); + CPPUNIT_ASSERT(copy == myparams); +} + + +edm::ParameterSet modulePSet(std::string const& iLabel, std::string const& iType, std::string const& iCppType) { + edm::ParameterSet temp; + temp.addParameter("s", 1); + temp.addParameter("@module_label", iLabel); + temp.addParameter("@module_type", iType); + temp.addParameter("@module_edm_type", iCppType); + return temp; +} + +void testmakeprocess::moduleTest() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cones = cms.EDFilter('Module',\n" + " s = cms.int32(1)\n" + ")\n" + "process.NoLabelModule = cms.ESProducer('NoLabelModule',\n" + " s = cms.int32(1)\n" + ")\n" + "process.labeled = cms.ESProducer('LabelModule',\n" + " s = cms.int32(1)\n" + ")\n" + "process.source = cms.Source('InputSource',\n" + " s = cms.int32(1)\n" + ")\n" + "process.NoLabelRetriever = cms.ESSource('NoLabelRetriever',\n" + " s = cms.int32(1)\n" + ")\n" + "process.label = cms.ESSource('LabelRetriever',\n" + " s = cms.int32(1)\n" + ")\n" + "process.p = cms.Path(process.cones)\n"; + + + ParameterSetPtr test = pSet(kTest); + + static edm::ParameterSet const kEmpty; + edm::ParameterSet const kCone(modulePSet("cones", "Module","EDFilter")); + std::ostringstream out; + out << kCone.toString() << std::endl; + out << test->getParameterSet("cones").toString() << std::endl; + + edm::ParameterSet const kMainInput(modulePSet("@main_input","InputSource","Source")); + + edm::ParameterSet const kNoLabelModule(modulePSet("", "NoLabelModule","ESProducer")); + edm::ParameterSet const kLabelModule(modulePSet("labeled", "LabelModule","ESProducer")); + edm::ParameterSet const kNoLabelRetriever(modulePSet("", "NoLabelRetriever","ESSource")); + edm::ParameterSet const kLabelRetriever(modulePSet("label", "LabelRetriever","ESSource")); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("cones"))); + CPPUNIT_ASSERT(kCone == test->getParameterSet("cones")); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("@main_input"))); + CPPUNIT_ASSERT(kMainInput == (test->getParameterSet("@main_input"))); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("NoLabelModule@"))); + CPPUNIT_ASSERT(kNoLabelModule == test->getParameterSet("NoLabelModule@")); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("LabelModule@labeled"))); + CPPUNIT_ASSERT(kLabelModule == test->getParameterSet("LabelModule@labeled")); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("NoLabelRetriever@"))); + CPPUNIT_ASSERT(kNoLabelRetriever == test->getParameterSet("NoLabelRetriever@")); + + CPPUNIT_ASSERT(kEmpty != (test->getParameterSet("LabelRetriever@label"))); + CPPUNIT_ASSERT(kLabelRetriever == test->getParameterSet("LabelRetriever@label")); +} + +void testmakeprocess::emptyModuleTest() { + char const* kTest = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.thing = cms.EDFilter('XX')\n" + "process.p = cms.Path(process.thing)\n"; + + ParameterSetPtr test = pSet(kTest); + + edm::ParameterSet& myparams = *(test); + myparams.registerIt(); + std::string rep = myparams.toString(); + edm::ParameterSet copy(rep); + CPPUNIT_ASSERT(copy == myparams); +} + +void testmakeprocess::taskTest() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," + "process.ess27, process.ess28, process.esp27, process.esp28," + "process.serv27, process.serv28)\n"; + + ParameterSetPtr test = pSet(kTest); + + + CPPUNIT_ASSERT(!test->existsAs("m1") && + !test->existsAs("m2") && + test->existsAs("m3") && + test->existsAs("m4") && + test->existsAs("m5") && + test->existsAs("m6") && + test->existsAs("m7") && + test->existsAs("m8") && + test->existsAs("m9") && + test->existsAs("m10") && + test->existsAs("m11") && + test->existsAs("m12") && + test->existsAs("m13") && + test->existsAs("m14") && + test->existsAs("m15") && + test->existsAs("m16") && + test->existsAs("m17") && + test->existsAs("m18") && + test->existsAs("m19") && + test->existsAs("m20") && + test->existsAs("m21") && + test->existsAs("m22") && + test->existsAs("m23") && + test->existsAs("m24") && + test->existsAs("m25") && + test->existsAs("m26") && + !test->existsAs("m27") && + !test->existsAs("m28") && + !test->existsAs("m29") && + !test->existsAs("m30")); + + CPPUNIT_ASSERT(!test->existsAs("f1") && + !test->existsAs("f2") && + test->existsAs("f3") && + test->existsAs("f4") && + test->existsAs("f5") && + test->existsAs("f6") && + test->existsAs("f7") && + test->existsAs("f8") && + test->existsAs("f9") && + test->existsAs("f10") && + test->existsAs("f11") && + test->existsAs("f12") && + test->existsAs("f13") && + test->existsAs("f14") && + test->existsAs("f15") && + test->existsAs("f16") && + test->existsAs("f17") && + test->existsAs("f18") && + test->existsAs("f19") && + test->existsAs("f20") && + test->existsAs("f21") && + test->existsAs("f22") && + test->existsAs("f23") && + test->existsAs("f24") && + test->existsAs("f25") && + test->existsAs("f26") && + !test->existsAs("f27") && + !test->existsAs("f28") && + !test->existsAs("f29") && + !test->existsAs("f30")); + + CPPUNIT_ASSERT(!test->existsAs("a1") && + !test->existsAs("a2") && + test->existsAs("a3") && + test->existsAs("a4") && + test->existsAs("a5") && + test->existsAs("a6") && + test->existsAs("a7") && + test->existsAs("a8") && + test->existsAs("a9") && + test->existsAs("a10")); + + CPPUNIT_ASSERT(!test->existsAs("o1") && + !test->existsAs("o2") && + test->existsAs("o7") && + test->existsAs("o8") && + test->existsAs("o9") && + test->existsAs("o10")); + + CPPUNIT_ASSERT(test->existsAs("ess@ess1") && + test->existsAs("ess2@") && + !test->existsAs("ess@ess3") && + !test->existsAs("ess4@") && + test->existsAs("ess@ess11") && + test->existsAs("ess12@") && + test->existsAs("ess@ess13") && + test->existsAs("ess14@") && + test->existsAs("ess@ess15") && + test->existsAs("ess16@") && + test->existsAs("ess@ess17") && + test->existsAs("ess18@") && + test->existsAs("ess@ess19") && + test->existsAs("ess20@") && + test->existsAs("ess@ess21") && + test->existsAs("ess22@") && + test->existsAs("ess@ess23") && + test->existsAs("ess24@") && + test->existsAs("ess@ess25") && + test->existsAs("ess26@") && + test->existsAs("ess@ess27") && + test->existsAs("ess28@")); + + CPPUNIT_ASSERT(test->existsAs("esp@esp1") && + test->existsAs("esp2@") && + !test->existsAs("esp@esp3") && + !test->existsAs("esp4@") && + test->existsAs("esp@esp11") && + test->existsAs("esp12@") && + test->existsAs("esp@esp13") && + test->existsAs("esp14@") && + test->existsAs("esp@esp15") && + test->existsAs("esp16@") && + test->existsAs("esp@esp17") && + test->existsAs("esp18@") && + test->existsAs("esp@esp19") && + test->existsAs("esp20@") && + test->existsAs("esp@esp21") && + test->existsAs("esp22@") && + test->existsAs("esp@esp23") && + test->existsAs("esp24@") && + test->existsAs("esp@esp25") && + test->existsAs("esp26@") && + test->existsAs("esp@esp27") && + test->existsAs("esp28@")); + + std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); + // Note that the vector is not sorted. The order + // depends on the order of a python iteration through a dictionary + // which could be anything. + std::set serviceNames; + for (auto const& pset : vpsetServices) { + serviceNames.insert(pset.getParameter("@service_type")); + } + std::vector expectedServiceNames; + expectedServiceNames.emplace_back("serv1"); + expectedServiceNames.emplace_back("serv2"); + expectedServiceNames.emplace_back("serv11"); + expectedServiceNames.emplace_back("serv12"); + expectedServiceNames.emplace_back("serv13"); + expectedServiceNames.emplace_back("serv14"); + expectedServiceNames.emplace_back("serv15"); + expectedServiceNames.emplace_back("serv16"); + expectedServiceNames.emplace_back("serv17"); + expectedServiceNames.emplace_back("serv18"); + expectedServiceNames.emplace_back("serv19"); + expectedServiceNames.emplace_back("serv20"); + expectedServiceNames.emplace_back("serv21"); + expectedServiceNames.emplace_back("serv22"); + expectedServiceNames.emplace_back("serv23"); + expectedServiceNames.emplace_back("serv24"); + expectedServiceNames.emplace_back("serv25"); + expectedServiceNames.emplace_back("serv26"); + expectedServiceNames.emplace_back("serv27"); + expectedServiceNames.emplace_back("serv28"); + bool result = true; + for (auto const& name : expectedServiceNames) { + if (serviceNames.find(name) == serviceNames.end()) { + result = false; + } + } + if (serviceNames.size() != expectedServiceNames.size()) { + result = false; + } + CPPUNIT_ASSERT(result); +} + +void testmakeprocess::taskTestWithEmptySchedule() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," + "process.ess27, process.ess28, process.esp27, process.esp28," + "process.serv27, process.serv28)\n" + "process.schedule = cms.Schedule()\n"; + + ParameterSetPtr test = pSet(kTest); + + CPPUNIT_ASSERT(!test->existsAs("m1") && + !test->existsAs("m2") && + !test->existsAs("m3") && + !test->existsAs("m4") && + !test->existsAs("m5") && + !test->existsAs("m6") && + !test->existsAs("m7") && + !test->existsAs("m8") && + !test->existsAs("m9") && + !test->existsAs("m10") && + !test->existsAs("m11") && + !test->existsAs("m12") && + !test->existsAs("m13") && + !test->existsAs("m14") && + !test->existsAs("m15") && + !test->existsAs("m16") && + !test->existsAs("m17") && + !test->existsAs("m18") && + !test->existsAs("m19") && + !test->existsAs("m20") && + !test->existsAs("m21") && + !test->existsAs("m22") && + !test->existsAs("m23") && + !test->existsAs("m24") && + !test->existsAs("m25") && + !test->existsAs("m26") && + !test->existsAs("m27") && + !test->existsAs("m28") && + !test->existsAs("m29") && + !test->existsAs("m30")); + + CPPUNIT_ASSERT(!test->existsAs("f1") && + !test->existsAs("f2") && + !test->existsAs("f3") && + !test->existsAs("f4") && + !test->existsAs("f5") && + !test->existsAs("f6") && + !test->existsAs("f7") && + !test->existsAs("f8") && + !test->existsAs("f9") && + !test->existsAs("f10") && + !test->existsAs("f11") && + !test->existsAs("f12") && + !test->existsAs("f13") && + !test->existsAs("f14") && + !test->existsAs("f15") && + !test->existsAs("f16") && + !test->existsAs("f17") && + !test->existsAs("f18") && + !test->existsAs("f19") && + !test->existsAs("f20") && + !test->existsAs("f21") && + !test->existsAs("f22") && + !test->existsAs("f23") && + !test->existsAs("f24") && + !test->existsAs("f25") && + !test->existsAs("f26") && + !test->existsAs("f27") && + !test->existsAs("f28") && + !test->existsAs("f29") && + !test->existsAs("f30")); + + CPPUNIT_ASSERT(!test->existsAs("a1") && + !test->existsAs("a2") && + !test->existsAs("a3") && + !test->existsAs("a4") && + !test->existsAs("a5") && + !test->existsAs("a6") && + !test->existsAs("a7") && + !test->existsAs("a8") && + !test->existsAs("a9") && + !test->existsAs("a10")); + + CPPUNIT_ASSERT(!test->existsAs("o1") && + !test->existsAs("o2") && + !test->existsAs("o7") && + !test->existsAs("o8") && + !test->existsAs("o9") && + !test->existsAs("o10")); + + CPPUNIT_ASSERT(test->existsAs("ess@ess1") && + test->existsAs("ess2@") && + !test->existsAs("ess@ess3") && + !test->existsAs("ess4@") && + !test->existsAs("ess@ess11") && + !test->existsAs("ess12@") && + !test->existsAs("ess@ess13") && + !test->existsAs("ess14@") && + !test->existsAs("ess@ess15") && + !test->existsAs("ess16@") && + !test->existsAs("ess@ess17") && + !test->existsAs("ess18@") && + !test->existsAs("ess@ess19") && + !test->existsAs("ess20@") && + !test->existsAs("ess@ess21") && + !test->existsAs("ess22@") && + !test->existsAs("ess@ess23") && + !test->existsAs("ess24@") && + !test->existsAs("ess@ess25") && + !test->existsAs("ess26@") && + test->existsAs("ess@ess27") && + test->existsAs("ess28@")); + + CPPUNIT_ASSERT(test->existsAs("esp@esp1") && + test->existsAs("esp2@") && + !test->existsAs("esp@esp3") && + !test->existsAs("esp4@") && + !test->existsAs("esp@esp11") && + !test->existsAs("esp12@") && + !test->existsAs("esp@esp13") && + !test->existsAs("esp14@") && + !test->existsAs("esp@esp15") && + !test->existsAs("esp16@") && + !test->existsAs("esp@esp17") && + !test->existsAs("esp18@") && + !test->existsAs("esp@esp19") && + !test->existsAs("esp20@") && + !test->existsAs("esp@esp21") && + !test->existsAs("esp22@") && + !test->existsAs("esp@esp23") && + !test->existsAs("esp24@") && + !test->existsAs("esp@esp25") && + !test->existsAs("esp26@") && + test->existsAs("esp@esp27") && + test->existsAs("esp28@")); + + std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); + // Note that the vector is not sorted. The order + // depends on the order of a python iteration through a dictionary + // which could be anything. + std::set serviceNames; + for (auto const& pset : vpsetServices) { + serviceNames.insert(pset.getParameter("@service_type")); + } + std::vector expectedServiceNames; + expectedServiceNames.emplace_back("serv1"); + expectedServiceNames.emplace_back("serv2"); + expectedServiceNames.emplace_back("serv27"); + expectedServiceNames.emplace_back("serv28"); + bool result = true; + for (auto const& name : expectedServiceNames) { + if (serviceNames.find(name) == serviceNames.end()) { + result = false; + } + } + if (serviceNames.size() != expectedServiceNames.size()) { + result = false; + } + CPPUNIT_ASSERT(result); +} + +void testmakeprocess::taskTestWithSchedule() { + char const* kTest = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.load(\"FWCore.PythonParameterSet.test.testTask_cff\")\n" + "t10 = cms.Task(process.m29, process.m30, process.f29, process.f30," + "process.ess27, process.ess28, process.esp27, process.esp28," + "process.serv27, process.serv28)\n" + "process.schedule = cms.Schedule(process.p1, process.p2, process.e1, process.e2," + "process.pf1, process.pf2, process.ef1, process.ef2," + "process.pa1, process.pa2, process.ea1, process.ea2," + "process.eo1, process.eo2, process.pess2, process.eess2," + "process.pesp2, process.eesp2, process.pserv2, process.eserv2," + "tasks=[process.t9, process.tf9, process.tess10,process.tesp10," + "process.tserv10])\n"; + + ParameterSetPtr test = pSet(kTest); + + CPPUNIT_ASSERT(!test->existsAs("m1") && + !test->existsAs("m2") && + test->existsAs("m3") && + test->existsAs("m4") && + test->existsAs("m5") && + test->existsAs("m6") && + test->existsAs("m7") && + test->existsAs("m8") && + test->existsAs("m9") && + test->existsAs("m10") && + test->existsAs("m11") && + test->existsAs("m12") && + test->existsAs("m13") && + test->existsAs("m14") && + test->existsAs("m15") && + test->existsAs("m16") && + test->existsAs("m17") && + test->existsAs("m18") && + test->existsAs("m19") && + test->existsAs("m20") && + test->existsAs("m21") && + test->existsAs("m22") && + test->existsAs("m23") && + test->existsAs("m24") && + test->existsAs("m25") && + test->existsAs("m26") && + test->existsAs("m27") && + test->existsAs("m28") && + !test->existsAs("m29") && + !test->existsAs("m30")); + + CPPUNIT_ASSERT(!test->existsAs("f1") && + !test->existsAs("f2") && + test->existsAs("f3") && + test->existsAs("f4") && + test->existsAs("f5") && + test->existsAs("f6") && + test->existsAs("f7") && + test->existsAs("f8") && + test->existsAs("f9") && + test->existsAs("f10") && + test->existsAs("f11") && + test->existsAs("f12") && + test->existsAs("f13") && + test->existsAs("f14") && + test->existsAs("f15") && + test->existsAs("f16") && + test->existsAs("f17") && + test->existsAs("f18") && + test->existsAs("f19") && + test->existsAs("f20") && + test->existsAs("f21") && + test->existsAs("f22") && + test->existsAs("f23") && + test->existsAs("f24") && + test->existsAs("f25") && + test->existsAs("f26") && + test->existsAs("f27") && + test->existsAs("f28") && + !test->existsAs("f29") && + !test->existsAs("f30")); + + CPPUNIT_ASSERT(!test->existsAs("a1") && + !test->existsAs("a2") && + test->existsAs("a3") && + test->existsAs("a4") && + test->existsAs("a5") && + test->existsAs("a6") && + test->existsAs("a7") && + test->existsAs("a8") && + test->existsAs("a9") && + test->existsAs("a10")); + + CPPUNIT_ASSERT(!test->existsAs("o1") && + !test->existsAs("o2") && + test->existsAs("o7") && + test->existsAs("o8") && + test->existsAs("o9") && + test->existsAs("o10")); + + CPPUNIT_ASSERT(test->existsAs("ess@ess1") && + test->existsAs("ess2@") && + test->existsAs("ess@ess3") && + test->existsAs("ess4@") && + test->existsAs("ess@ess11") && + test->existsAs("ess12@") && + test->existsAs("ess@ess13") && + test->existsAs("ess14@") && + test->existsAs("ess@ess15") && + test->existsAs("ess16@") && + test->existsAs("ess@ess17") && + test->existsAs("ess18@") && + test->existsAs("ess@ess19") && + test->existsAs("ess20@") && + test->existsAs("ess@ess21") && + test->existsAs("ess22@") && + test->existsAs("ess@ess23") && + test->existsAs("ess24@") && + test->existsAs("ess@ess25") && + test->existsAs("ess26@") && + test->existsAs("ess@ess27") && + test->existsAs("ess28@")); + + CPPUNIT_ASSERT(test->existsAs("esp@esp1") && + test->existsAs("esp2@") && + test->existsAs("esp@esp3") && + test->existsAs("esp4@") && + test->existsAs("esp@esp11") && + test->existsAs("esp12@") && + test->existsAs("esp@esp13") && + test->existsAs("esp14@") && + test->existsAs("esp@esp15") && + test->existsAs("esp16@") && + test->existsAs("esp@esp17") && + test->existsAs("esp18@") && + test->existsAs("esp@esp19") && + test->existsAs("esp20@") && + test->existsAs("esp@esp21") && + test->existsAs("esp22@") && + test->existsAs("esp@esp23") && + test->existsAs("esp24@") && + test->existsAs("esp@esp25") && + test->existsAs("esp26@") && + test->existsAs("esp@esp27") && + test->existsAs("esp28@")); + + std::vector const& vpsetServices = test->getUntrackedParameterSetVector("services"); + // Note that the vector is not sorted. The order + // depends on the order of a python iteration through a dictionary + // which could be anything. + std::set serviceNames; + for (auto const& pset : vpsetServices) { + serviceNames.insert(pset.getParameter("@service_type")); + } + std::vector expectedServiceNames; + expectedServiceNames.emplace_back("serv1"); + expectedServiceNames.emplace_back("serv2"); + expectedServiceNames.emplace_back("serv3"); + expectedServiceNames.emplace_back("serv4"); + expectedServiceNames.emplace_back("serv11"); + expectedServiceNames.emplace_back("serv12"); + expectedServiceNames.emplace_back("serv13"); + expectedServiceNames.emplace_back("serv14"); + expectedServiceNames.emplace_back("serv15"); + expectedServiceNames.emplace_back("serv16"); + expectedServiceNames.emplace_back("serv17"); + expectedServiceNames.emplace_back("serv18"); + expectedServiceNames.emplace_back("serv19"); + expectedServiceNames.emplace_back("serv20"); + expectedServiceNames.emplace_back("serv21"); + expectedServiceNames.emplace_back("serv22"); + expectedServiceNames.emplace_back("serv23"); + expectedServiceNames.emplace_back("serv24"); + expectedServiceNames.emplace_back("serv25"); + expectedServiceNames.emplace_back("serv26"); + expectedServiceNames.emplace_back("serv27"); + expectedServiceNames.emplace_back("serv28"); + bool result = true; + for (auto const& name : expectedServiceNames) { + if (serviceNames.find(name) == serviceNames.end()) { + result = false; + } + } + if (serviceNames.size() != expectedServiceNames.size()) { + result = false; + } + CPPUNIT_ASSERT(result); +} + +/* +void testmakeprocess::windowsLineEndingTest() { + + std::ostringstream oss; + char const ret = '\r'; + char const nl = '\n'; + char const dquote = '"'; + char const backsl = '\\'; + + oss << ret << nl + << "import FWCore.ParameterSet.Config as cms" << ret << nl + << "process = cms.Process('test')" << ret << nl + << " source = cms.Source('InputSource'," << ret << nl + << " i=cms.int32(1)" << ret << nl + << " s1 = cms.string(" << dquote << ret << dquote << ')' <getProcessPSet()); + + edm::ParameterSet src = p.getParameterSet("@main_input"); + CPPUNIT_ASSERT(src.getParameter("i") == 1); + std::string s1 = src.getParameter("s1"); + std::string s2 = src.getParameter("s2"); + + std::cerr << "\nsize of s1 is: " << s1.size(); + std::cerr << "\nsize of s2 is: " << s2.size() << '\n'; + + CPPUNIT_ASSERT(s1.size() == 1); + CPPUNIT_ASSERT(s1[0] == ret); + + CPPUNIT_ASSERT(s2.size() == 2); + CPPUNIT_ASSERT(s2[0] == backsl); + CPPUNIT_ASSERT(s2[1] == 'r'); +} +*/ diff --git a/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc b/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc new file mode 100644 index 0000000000000..7b95d7d28c484 --- /dev/null +++ b/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc @@ -0,0 +1,503 @@ +/* + * makepset_t.cc + * EDMProto + * + * Created by Chris Jones on 5/18/05. + * + */ + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/Utilities/interface/EDMException.h" +#include "FWCore/Utilities/interface/resolveSymbolicLinks.h" + +#include "cppunit/extensions/HelperMacros.h" + +#include + +#include +#include +#include +#include // for setenv; is likely to fail +#include +#include +#include + +class testmakepset: public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(testmakepset); + CPPUNIT_TEST(typesTest); + CPPUNIT_TEST(secsourceTest); + CPPUNIT_TEST(usingBlockTest); + CPPUNIT_TEST(fileinpathTest); + CPPUNIT_TEST_SUITE_END(); + + public: + void setUp(){} + void tearDown(){} + void typesTest(); + void secsourceTest(); + void usingBlockTest(); + void fileinpathTest(); + + private: + void secsourceAux(); + void usingBlockAux(); + void fileinpathAux(); +}; + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(testmakepset); + +void testmakepset::secsourceTest() { + try { this->secsourceAux(); } + catch (cms::Exception& x) { + std::cerr << "testmakepset::secsourceTest() caught a cms::Exception\n"; + std::cerr << x.what() << '\n'; + throw; + } + catch (std::exception& x) { + std::cerr << "testmakepset::secsourceTest() caught a std::exception\n"; + std::cerr << x.what() << '\n'; + throw; + } + catch (...) { + std::cerr << "testmakepset::secsourceTest() caught an unidentified exception\n"; + throw; + } +} + +void testmakepset::secsourceAux() { + char const* kTest = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('PROD')\n" + "process.maxEvents = cms.untracked.PSet(\n" + " input = cms.untracked.int32(2)\n" + ")\n" + "process.source = cms.Source('PoolSource',\n" + " fileNames = cms.untracked.vstring('file:main.root')\n" + ")\n" + "process.out = cms.OutputModule('PoolOutputModule',\n" + " fileName = cms.string('file:CumHits.root')\n" + ")\n" + "process.mix = cms.EDFilter('MixingModule',\n" + " input = cms.SecSource('EmbeddedRootSource',\n" + " fileNames = cms.untracked.vstring('file:pileup.root')\n" + " ),\n" + " max_bunch = cms.int32(3),\n" + " average_number = cms.double(14.3),\n" + " min_bunch = cms.int32(-5),\n" + " type = cms.string('fixed')\n" + ")\n" + "process.p = cms.Path(process.mix)\n" + "process.ep = cms.EndPath(process.out)\n"; + + std::string config(kTest); + + // Create the ParameterSet object from this configuration string. + PyBind11ProcessDesc builder(config); + std::shared_ptr ps = builder.parameterSet(); + + CPPUNIT_ASSERT(nullptr != ps.get()); + + // Make sure this ParameterSet object has the right contents + edm::ParameterSet const& mixingModuleParams = ps->getParameterSet("mix"); + edm::ParameterSet const& secondarySourceParams = mixingModuleParams.getParameterSet("input"); + CPPUNIT_ASSERT(secondarySourceParams.getParameter("@module_type") == "EmbeddedRootSource"); + CPPUNIT_ASSERT(secondarySourceParams.getParameter("@module_label") == "input"); + CPPUNIT_ASSERT(secondarySourceParams.getUntrackedParameter >("fileNames")[0] == "file:pileup.root"); +} + +void testmakepset::usingBlockTest() { + try { this->usingBlockAux(); } + catch (cms::Exception& x) { + std::cerr << "testmakepset::usingBlockTest() caught a cms::Exception\n"; + std::cerr << x.what() << '\n'; + throw; + } + catch (...) { + std::cerr << "testmakepset::usingBlockTest() caught an unidentified exception\n"; + throw; + } +} + +void testmakepset::usingBlockAux() { + char const* kTest = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('PROD')\n" + "process.maxEvents = cms.untracked.PSet(\n" + " input = cms.untracked.int32(2)\n" + ")\n" + "process.source = cms.Source('PoolSource',\n" + " fileNames = cms.untracked.vstring('file:main.root')\n" + ")\n" + "process.b = cms.PSet(\n" + " s = cms.string('original'),\n" + " r = cms.double(1.5)\n" + ")\n" + "process.m1 = cms.EDFilter('Class1',\n" + " process.b,\n" + " i = cms.int32(1)\n" + ")\n" + "process.m2 = cms.EDFilter('Class2',\n" + " process.b,\n" + " i = cms.int32(2),\n" + " j = cms.int32(3),\n" + " u = cms.uint64(1011),\n" + " l = cms.int64(101010)\n" + ")\n" + "process.p = cms.Path(process.m1+process.m2)\n"; + + std::string config(kTest); + // Create the ParameterSet object from this configuration string. + PyBind11ProcessDesc builder(config); + std::shared_ptr ps = builder.parameterSet(); + CPPUNIT_ASSERT(nullptr != ps.get()); + + // Make sure this ParameterSet object has the right contents + edm::ParameterSet const& m1Params = ps->getParameterSet("m1"); + edm::ParameterSet const& m2Params = ps->getParameterSet("m2"); + CPPUNIT_ASSERT(m1Params.getParameter("i") == 1); + CPPUNIT_ASSERT(m2Params.getParameter("i") == 2); + CPPUNIT_ASSERT(m2Params.getParameter("j") == 3); + CPPUNIT_ASSERT(m2Params.getParameter("l") == 101010); + CPPUNIT_ASSERT(m2Params.getParameter("u") == 1011); + + CPPUNIT_ASSERT(m1Params.getParameter("s") == "original"); + CPPUNIT_ASSERT(m2Params.getParameter("s") == "original"); + + CPPUNIT_ASSERT(m1Params.getParameter("r") == 1.5); + CPPUNIT_ASSERT(m2Params.getParameter("r") == 1.5); +} + +void testmakepset::fileinpathTest() { + try { this->fileinpathAux(); } + catch (cms::Exception& x) { + std::cerr << "testmakepset::fileinpathTest() caught a cms::Exception\n"; + std::cerr << x.what() << '\n'; + throw; + } + catch (...) { + std::cerr << "testmakepset::fileinpathTest() caught an unidentified exception\n"; + throw; + } +} + +void testmakepset::fileinpathAux() { + char const* kTest = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('PROD')\n" + "process.main = cms.PSet(\n" + " topo = cms.FileInPath('Geometry/TrackerSimData/data/trackersens.xml'),\n" + " fip = cms.FileInPath('FWCore/PythonParameterSet/test/fip.txt'),\n" + " ufip = cms.untracked.FileInPath('FWCore/PythonParameterSet/test/ufip.txt'),\n" + " extraneous = cms.int32(12)\n" + ")\n" + "process.source = cms.Source('EmptySource')\n"; + + std::string config(kTest); + std::string tmpout; + bool localArea=false; + // Create the ParameterSet object from this configuration string. + { + PyBind11ProcessDesc builder(config); + std::shared_ptr ps = builder.parameterSet(); + CPPUNIT_ASSERT(nullptr != ps.get()); + + edm::ParameterSet const& innerps = ps->getParameterSet("main"); + edm::FileInPath fip = innerps.getParameter("fip"); + edm::FileInPath ufip = innerps.getUntrackedParameter("ufip"); + CPPUNIT_ASSERT(innerps.existsAs("extraneous")); + CPPUNIT_ASSERT(!innerps.existsAs("absent")); + char *releaseBase = getenv("CMSSW_RELEASE_BASE"); + char *localBase = getenv("CMSSW_BASE"); + localArea = (releaseBase != nullptr && strlen(releaseBase) != 0 && strcmp(releaseBase, localBase)); + if(localArea) { + // Need to account for possible symbolic links + std::string const src("/src"); + std::string release = releaseBase + src; + std::string local = localBase + src; + edm::resolveSymbolicLinks(release); + edm::resolveSymbolicLinks(local); + localArea = (local != release); + } + + if(localArea) { + CPPUNIT_ASSERT(fip.location() == edm::FileInPath::Local); + } + CPPUNIT_ASSERT(fip.relativePath() == "FWCore/PythonParameterSet/test/fip.txt"); + CPPUNIT_ASSERT(ufip.relativePath() == "FWCore/PythonParameterSet/test/ufip.txt"); + std::string fullpath = fip.fullPath(); + std::cerr << "fullPath is: " << fip.fullPath() << std::endl; + std::cerr << "copy of fullPath is: " << fullpath << std::endl; + + CPPUNIT_ASSERT(!fullpath.empty()); + + tmpout = fullpath.substr(0, fullpath.find("FWCore/PythonParameterSet/test/fip.txt")) + "tmp.py"; + + edm::FileInPath topo = innerps.getParameter("topo"); + // if the file is local, then just disable this check as then it is expected to fail + { + std::string const src("/src"); + std::string local = localBase + src; + std::string localFile = local + "/Geometry/TrackerSimData/data/trackersens.xml"; + if (!boost::filesystem::exists(localFile) ) + CPPUNIT_ASSERT(topo.location() != edm::FileInPath::Local); + else + std::cerr << "Disabling test against local path for trackersens.xml as package is checked out in this test" << std::endl; + } + CPPUNIT_ASSERT(topo.relativePath() == "Geometry/TrackerSimData/data/trackersens.xml"); + fullpath = topo.fullPath(); + CPPUNIT_ASSERT(!fullpath.empty()); + + std::vector v(1); + CPPUNIT_ASSERT(innerps.getAllFileInPaths(v) == 3); + + CPPUNIT_ASSERT(v.size() == 4); + CPPUNIT_ASSERT(std::count(v.begin(), v.end(), fip) == 1); + CPPUNIT_ASSERT(std::count(v.begin(), v.end(), topo) == 1); + + edm::ParameterSet empty; + v.clear(); + CPPUNIT_ASSERT(empty.getAllFileInPaths(v) == 0); + CPPUNIT_ASSERT(v.empty()); + } + // This last test checks that a FileInPath parameter can be read + // successfully even if the associated file no longer exists. + std::ofstream out(tmpout.c_str()); + CPPUNIT_ASSERT(!(!out)); + + char const* kTest2 = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('PROD')\n" + "process.main = cms.PSet(\n" + " fip2 = cms.FileInPath('tmp.py')\n" + ")\n" + "process.source = cms.Source('EmptySource')\n"; + + std::string config2(kTest2); + // Create the ParameterSet object from this configuration string. + PyBind11ProcessDesc builder2(config2); + unlink(tmpout.c_str()); + std::shared_ptr ps2 = builder2.parameterSet(); + + CPPUNIT_ASSERT(nullptr != ps2.get()); + + edm::ParameterSet const& innerps2 = ps2->getParameterSet("main"); + edm::FileInPath fip2 = innerps2.getParameter("fip2"); + if (localArea) { + CPPUNIT_ASSERT(fip2.location() == edm::FileInPath::Local); + } + CPPUNIT_ASSERT(fip2.relativePath() == "tmp.py"); + std::string fullpath2 = fip2.fullPath(); + std::cerr << "fullPath is: " << fip2.fullPath() << std::endl; + std::cerr << "copy of fullPath is: " << fullpath2 << std::endl; + CPPUNIT_ASSERT(!fullpath2.empty()); +} + +void testmakepset::typesTest() { + //vbool vb = {true, false}; + char const* kTest = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('t')\n" + "process.p = cms.PSet(\n" + " input2 = cms.InputTag('Label2','Instance2'),\n" + " sb3 = cms.string(' '),\n" + " input1 = cms.InputTag('Label1','Instance1'),\n" + " input6 = cms.InputTag('source'),\n" + " ##justasbig = cms.double(inf),\n" + " input4 = cms.InputTag('Label4','Instance4','Process4'),\n" + " input3 = cms.untracked.InputTag('Label3','Instance3'),\n" + " h2 = cms.uint32(255),\n" + " vi = cms.vint32(1, -2),\n" + " input8 = cms.string('deprecatedString:tag'),\n" + " h1 = cms.int32(74),\n" + " vs = cms.vstring('','1', \n" + " '2', \n" + " 'a', 'XXX'),\n" + " vs2 = cms.vstring(), vs3 = cms.vstring(''),\n" + " sb2 = cms.string(''),\n" + " input7 = cms.InputTag('source','sink'),\n" + " ps = cms.PSet(\n" + " b2 = cms.untracked.bool(True)\n" + " ),\n" + " input5 = cms.InputTag('Label5','','Process5'),\n" + " h3 = cms.untracked.uint32(3487559679),\n" + " input = cms.InputTag('Label'),\n" + " vps = cms.VPSet(cms.PSet(\n" + " b3 = cms.bool(False)\n" + " )),\n" + " ##indebt = cms.double(-inf),\n" + " ##big = cms.double(inf),\n" + " vinput = cms.VInputTag(cms.InputTag('l1','i1'), cms.InputTag('l2'), cms.InputTag('l3','i3','p3'), cms.InputTag('l4','','p4'), cms.InputTag('source'), \n" + " cms.InputTag('source','sink')),\n" + " ui = cms.uint32(1),\n" + " eventID = cms.EventID(1, 0, 1),\n" + " b = cms.untracked.bool(True),\n" + " d = cms.double(1.0),\n" + " i = cms.int32(1),\n" + " vui = cms.vuint32(1, 2, 1, 255),\n" + " s = cms.string('this string'),\n" + " sb1 = cms.string(''),\n" + " emptyString = cms.untracked.string(''),\n" + " vEventID = cms.VEventID('1:1', '2:2','3:3'),\n" + " lumi = cms.LuminosityBlockID(55, 65),\n" + " vlumis = cms.VLuminosityBlockID('75:85', '95:105'),\n" + " einput1 = cms.ESInputTag(),\n" + " einput2 = cms.ESInputTag(data='blah'),\n" + " einput3 = cms.ESInputTag('ESProd'),\n" + " einput4 = cms.ESInputTag('ESProd','something'),\n" + " einput5 = cms.ESInputTag('ESProd:something'),\n" + " veinput1 = cms.VESInputTag(),\n" + " veinput2 = cms.VESInputTag(cms.ESInputTag(data='blah'),cms.ESInputTag('ESProd'))\n" + ")\n" + + ; + + std::string config2(kTest); + // Create the ParameterSet object from this configuration string. + PyBind11ProcessDesc builder2(config2); + std::shared_ptr ps2 = builder2.parameterSet(); + edm::ParameterSet const& test = ps2->getParameterSet("p"); + + CPPUNIT_ASSERT(1 == test.getParameter("i")); + CPPUNIT_ASSERT(test.retrieve("i").isTracked()); + CPPUNIT_ASSERT(1 == test.getParameter("ui")); + CPPUNIT_ASSERT(1 == test.getParameter("d")); + //CPPUNIT_ASSERT(100000. < test.getParameter("big")); + //CPPUNIT_ASSERT(100000. < test.getParameter("justasbig")); + //CPPUNIT_ASSERT(-1000000. > test.getParameter("indebt")); + + // test hex numbers + CPPUNIT_ASSERT(74 == test.getParameter("h1")); + CPPUNIT_ASSERT(255 == test.getParameter("h2")); + CPPUNIT_ASSERT(3487559679U == test.getUntrackedParameter("h3")); + + CPPUNIT_ASSERT("this string" == test.getParameter("s")); + CPPUNIT_ASSERT("" == test.getParameter("sb1")); + CPPUNIT_ASSERT("" == test.getUntrackedParameter("emptyString", "default")); + CPPUNIT_ASSERT("" == test.getParameter("sb2")); + CPPUNIT_ASSERT(4 == test.getParameter("sb3").size()); + std::vector vs = test.getParameter >("vs"); + int vssize = vs.size(); + //FIXME doesn't do spaces right + edm::Entry e(test.retrieve("vs")); + CPPUNIT_ASSERT(5 == vssize); + CPPUNIT_ASSERT(vssize && "" == vs[0]); + CPPUNIT_ASSERT(vssize >1 && "1" == vs[1]); + CPPUNIT_ASSERT(vssize >1 && "a" == vs[3]); + vs = test.getParameter >("vs2"); + CPPUNIT_ASSERT(vs.size() == 0); + vs = test.getParameter >("vs3"); + CPPUNIT_ASSERT(vs.size() == 1); + CPPUNIT_ASSERT(vs[0] == ""); + + static unsigned int const vuia[] = {1,2,1,255}; + static std::vector const vui(vuia, vuia+sizeof(vuia)/sizeof(unsigned int)); + CPPUNIT_ASSERT(vui == test.getParameter >("vui")); + + static int const via[] = {1,-2}; + static std::vector const vi(via, via+sizeof(via)/sizeof(int)); + test.getParameter >("vi"); + CPPUNIT_ASSERT(true == test.getUntrackedParameter("b", false)); + CPPUNIT_ASSERT(test.retrieve("vi").isTracked()); + //test.getParameter >("vb"); + edm::ParameterSet const& ps = test.getParameterSet("ps"); + CPPUNIT_ASSERT(true == ps.getUntrackedParameter("b2", false)); + std::vector const& vps = test.getParameterSetVector("vps"); + CPPUNIT_ASSERT(1 == vps.size()); + CPPUNIT_ASSERT(false == vps.front().getParameter("b3")); + + // InputTag + edm::InputTag inputProduct = test.getParameter("input"); + edm::InputTag inputProduct1 = test.getParameter("input1"); + edm::InputTag inputProduct2 = test.getParameter("input2"); + edm::InputTag inputProduct3 = test.getUntrackedParameter("input3"); + edm::InputTag inputProduct4 = test.getParameter("input4"); + edm::InputTag inputProduct5 = test.getParameter("input5"); + edm::InputTag inputProduct6 = test.getParameter("input6"); + edm::InputTag inputProduct7 = test.getParameter("input7"); + edm::InputTag inputProduct8 = test.getParameter("input8"); + + //edm::OutputTag outputProduct = test.getParameter("output"); + + CPPUNIT_ASSERT("Label" == inputProduct.label()); + CPPUNIT_ASSERT("Label1" == inputProduct1.label()); + CPPUNIT_ASSERT("Label2" == inputProduct2.label()); + CPPUNIT_ASSERT("Instance2" == inputProduct2.instance()); + CPPUNIT_ASSERT("Label3" == inputProduct3.label()); + CPPUNIT_ASSERT("Instance3" == inputProduct3.instance()); + CPPUNIT_ASSERT("Label4" == inputProduct4.label()); + CPPUNIT_ASSERT("Instance4" == inputProduct4.instance()); + CPPUNIT_ASSERT("Process4" == inputProduct4.process()); + CPPUNIT_ASSERT("Label5" == inputProduct5.label()); + CPPUNIT_ASSERT("" == inputProduct5.instance()); + CPPUNIT_ASSERT("Process5" == inputProduct5.process()); + CPPUNIT_ASSERT("source" == inputProduct6.label()); + CPPUNIT_ASSERT("source" == inputProduct7.label()); + CPPUNIT_ASSERT("deprecatedString" == inputProduct8.label()); + + // vector of InputTags + + std::vector vtags = test.getParameter >("vinput"); + CPPUNIT_ASSERT("l1" == vtags[0].label()); + CPPUNIT_ASSERT("i1" == vtags[0].instance()); + CPPUNIT_ASSERT("l2" == vtags[1].label()); + CPPUNIT_ASSERT("l3" == vtags[2].label()); + CPPUNIT_ASSERT("i3" == vtags[2].instance()); + CPPUNIT_ASSERT("p3" == vtags[2].process()); + CPPUNIT_ASSERT("l4" == vtags[3].label()); + CPPUNIT_ASSERT("" == vtags[3].instance()); + CPPUNIT_ASSERT("p4" == vtags[3].process()); + CPPUNIT_ASSERT("source" == vtags[4].label()); + CPPUNIT_ASSERT("source" == vtags[5].label()); + + // ESInputTag + edm::ESInputTag einput1 = test.getParameter("einput1"); + edm::ESInputTag einput2 = test.getParameter("einput2"); + edm::ESInputTag einput3 = test.getParameter("einput3"); + edm::ESInputTag einput4 = test.getParameter("einput4"); + edm::ESInputTag einput5 = test.getParameter("einput5"); + CPPUNIT_ASSERT("" == einput1.module()); + CPPUNIT_ASSERT("" == einput1.data()); + CPPUNIT_ASSERT("" == einput2.module()); + CPPUNIT_ASSERT("blah" == einput2.data()); + CPPUNIT_ASSERT("ESProd" == einput3.module()); + CPPUNIT_ASSERT("" == einput3.data()); + CPPUNIT_ASSERT("ESProd" == einput4.module()); + CPPUNIT_ASSERT("something" == einput4.data()); + CPPUNIT_ASSERT("ESProd" == einput5.module()); + CPPUNIT_ASSERT("something" == einput5.data()); + + std::vector veinput1 = test.getParameter >("veinput1"); + std::vector veinput2 = test.getParameter >("veinput2"); + CPPUNIT_ASSERT(0 == veinput1.size()); + CPPUNIT_ASSERT(2 == veinput2.size()); + CPPUNIT_ASSERT("" == veinput2[0].module()); + CPPUNIT_ASSERT("blah" == veinput2[0].data()); + CPPUNIT_ASSERT("ESProd" == veinput2[1].module()); + CPPUNIT_ASSERT("" == veinput2[1].data()); + + edm::EventID eventID = test.getParameter("eventID"); + std::vector vEventID = test.getParameter >("vEventID"); + CPPUNIT_ASSERT(1 == eventID.run()); + CPPUNIT_ASSERT(1 == eventID.event()); + CPPUNIT_ASSERT(1 == vEventID[0].run()); + CPPUNIT_ASSERT(1 == vEventID[0].event()); + CPPUNIT_ASSERT(3 == vEventID[2].run()); + CPPUNIT_ASSERT(3 == vEventID[2].event()); + + edm::LuminosityBlockID lumi = test.getParameter("lumi"); + CPPUNIT_ASSERT(55 == lumi.run()); + CPPUNIT_ASSERT(65 == lumi.luminosityBlock()); + std::vector vlumis = test.getParameter >("vlumis"); + CPPUNIT_ASSERT(vlumis.size() == 2); + CPPUNIT_ASSERT(vlumis[0].run() == 75); + CPPUNIT_ASSERT(vlumis[0].luminosityBlock() == 85); + CPPUNIT_ASSERT(vlumis[1].run() == 95); + CPPUNIT_ASSERT(vlumis[1].luminosityBlock() == 105); + + //CPPUNIT_ASSERT("Label2" == outputProduct.label()); + //CPPUNIT_ASSERT("" == outputProduct.instance()); + //CPPUNIT_ASSERT("Alias2" == outputProduct.alias()); + //BOOST_CHECK_THROW(makePSet(*nodeList), std::runtime_error); +} diff --git a/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp b/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp new file mode 100644 index 0000000000000..03ae5bc66d5ae --- /dev/null +++ b/FWCore/PythonParameterSet/test/processbuilder_t.cppunit.cpp @@ -0,0 +1,404 @@ +/** + +@file : processbuilder_t.cpp + +@brief test suit for process building and schedule validation + +*/ + +#include + +#include +#include +#include "FWCore/Utilities/interface/EDMException.h" + +#include + +#include +#include +#include + +class testProcessDesc: public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testProcessDesc); + + CPPUNIT_TEST(trivialPathTest); + CPPUNIT_TEST(simplePathTest); + CPPUNIT_TEST(sequenceSubstitutionTest); + CPPUNIT_TEST(attriggertest); + CPPUNIT_TEST(nestedSequenceSubstitutionTest); + CPPUNIT_TEST(sequenceSubstitutionTest2); + CPPUNIT_TEST(sequenceSubstitutionTest3); + CPPUNIT_TEST(multiplePathsTest); + // python throws some different exception + //CPPUNIT_TEST_EXCEPTION(inconsistentPathTest,edm::Exception); + //CPPUNIT_TEST_EXCEPTION(inconsistentMultiplePathTest,edm::Exception); + + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() {} + void tearDown() {} + + void trivialPathTest(); + void simplePathTest(); + void sequenceSubstitutionTest(); + void attriggertest(); + void nestedSequenceSubstitutionTest(); + void sequenceSubstitutionTest2(); + void sequenceSubstitutionTest3(); + void multiplePathsTest(); + void inconsistentPathTest(); + void inconsistentMultiplePathTest(); +}; + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(testProcessDesc); + +void testProcessDesc::trivialPathTest() { + std::string str = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('X')\n" + "process.a = cms.EDFilter('A',\n" + " p = cms.int32(3)\n" + ")\n" + "process.b = cms.EDProducer('B')\n" + "process.c = cms.EDProducer('C')\n" + "process.p = cms.Path(process.a*process.b*process.c)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("p"); + CPPUNIT_ASSERT(s[0]=="a"); + //CPPUNIT_ASSERT(b->getDependencies("a")==""); +} + +void testProcessDesc::simplePathTest() { + + std::string str = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('X')\n" + "process.a = cms.EDFilter('A',\n" + " p = cms.int32(3)\n" + ")\n" + "process.b = cms.EDFilter('A',\n" + " p = cms.int32(3)\n" + ")\n" + "process.c = cms.EDFilter('A',\n" + " p = cms.int32(3)\n" + ")\n" + "process.p = cms.Path(process.a*process.b*process.c)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("p"); + CPPUNIT_ASSERT(s[0]=="a"); + CPPUNIT_ASSERT(s[1]=="b"); + CPPUNIT_ASSERT(s[2]=="c"); + + //CPPUNIT_ASSERT (b->getDependencies("a")==""); + //CPPUNIT_ASSERT (b->getDependencies("b")=="a,"); + //CPPUNIT_ASSERT (b->getDependencies("c")=="a,b,"); +} + +void testProcessDesc:: attriggertest () { + + std::string str = + "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone1 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(5)\n" + ")\n" + "process.cone2 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.somejet1 = cms.EDFilter('PhonyJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.somejet2 = cms.EDFilter('PhonyJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.jtanalyzer = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.output = cms.OutputModule('OutputModule')\n" + "process.cones = cms.Sequence(process.cone1*process.cone2)\n" + "process.jets = cms.Sequence(process.somejet1*process.somejet2)\n" + "process.path1 = cms.Path(process.cones*process.jets*process.jtanalyzer)\n" + "process.epath = cms.EndPath(process.output)\n"; + + try { + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + edm::ParameterSet const& trig_pset = + (*test).getParameterSet("@trigger_paths"); + Strs tnames = trig_pset.getParameter("@trigger_paths"); + Strs enames = (*test).getParameter("@end_paths"); + + CPPUNIT_ASSERT(tnames[0]=="path1"); + CPPUNIT_ASSERT(enames[0]=="epath"); + + // see if the auto-schedule is correct + Strs schedule = (*test).getParameter("@paths"); + CPPUNIT_ASSERT(schedule.size() == 2); + CPPUNIT_ASSERT(schedule[0] == "path1"); + CPPUNIT_ASSERT(schedule[1] == "epath"); + + } + catch (cms::Exception& exc) { + std::cerr << "Got an cms::Exception: " << exc.what() << "\n"; + throw; + } + catch (std::exception& exc) { + std::cerr << "Got an std::exception: " << exc.what() << "\n"; + throw; + } + catch (...) { + std::cerr << "Got an unknown exception: " << "\n"; + throw; + } +} + +void testProcessDesc:: sequenceSubstitutionTest () { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone1 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(5)\n" + ")\n" + "process.cone2 = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.somejet1 = cms.EDFilter('PhonyJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.somejet2 = cms.EDFilter('PhonyJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.jtanalyzer = cms.EDFilter('PhonyConeJet',\n" + " i = cms.int32(7)\n" + ")\n" + "process.cones = cms.Sequence(process.cone1*process.cone2)\n" + "process.jets = cms.Sequence(process.somejet1*process.somejet2)\n" + "process.path1 = cms.Path(process.cones*process.jets*process.jtanalyzer)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("path1"); + CPPUNIT_ASSERT(s[0]=="cone1"); + CPPUNIT_ASSERT(s[1]=="cone2"); + CPPUNIT_ASSERT(s[2]=="somejet1"); + CPPUNIT_ASSERT(s[3]=="somejet2"); + CPPUNIT_ASSERT(s[4]=="jtanalyzer"); + + //CPPUNIT_ASSERT (b->getDependencies("cone1")==""); + //CPPUNIT_ASSERT (b->getDependencies("cone2")=="cone1,"); + //CPPUNIT_ASSERT (b->getDependencies("somejet1")=="cone1,cone2,"); + //CPPUNIT_ASSERT (b->getDependencies("somejet2")=="cone1,cone2,somejet1,"); + //CPPUNIT_ASSERT (b->getDependencies("jtanalyzer")=="cone1,cone2,somejet1,somejet2,"); +} + +void testProcessDesc::nestedSequenceSubstitutionTest() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.c = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.d = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.s1 = cms.Sequence( process.a+ process.b)\n" + "process.s2 = cms.Sequence(process.s1+ process.c)\n" + "process.path1 = cms.Path(process.s2+process.d)\n"; + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("path1"); + CPPUNIT_ASSERT(s[0]=="a"); + CPPUNIT_ASSERT(s[1]=="b"); + CPPUNIT_ASSERT(s[2]=="c"); + CPPUNIT_ASSERT(s[3]=="d"); + + //CPPUNIT_ASSERT (b.getDependencies("a")==""); + //CPPUNIT_ASSERT (b.getDependencies("b")=="a,"); + //CPPUNIT_ASSERT (b.getDependencies("c")=="a,b,"); + //CPPUNIT_ASSERT (b.getDependencies("d")=="a,b,c,"); +} + +void testProcessDesc::sequenceSubstitutionTest2() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.cone3 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.cones = cms.Sequence(process.cone1+ process.cone2+ process.cone3)\n" + "process.jets = cms.Sequence(process.somejet1+ process.somejet2)\n" + "process.path1 = cms.Path(process.cones+process.jets+ process.jtanalyzer)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("path1"); + CPPUNIT_ASSERT(s[0]=="cone1"); + CPPUNIT_ASSERT(s[1]=="cone2"); + CPPUNIT_ASSERT(s[2]=="cone3"); + CPPUNIT_ASSERT(s[3]=="somejet1"); + CPPUNIT_ASSERT(s[4]=="somejet2"); + CPPUNIT_ASSERT(s[5]=="jtanalyzer"); + + //CPPUNIT_ASSERT (b.getDependencies("cone1")==""); + //CPPUNIT_ASSERT (b.getDependencies("cone2")=="cone1,"); + //CPPUNIT_ASSERT (b.getDependencies("cone3")=="cone1,cone2,"); + //CPPUNIT_ASSERT (b.getDependencies("somejet1")=="cone1,cone2,cone3,"); + //CPPUNIT_ASSERT (b.getDependencies("somejet2")=="cone1,cone2,cone3,somejet1,"); + //CPPUNIT_ASSERT (b.getDependencies("jtanalyzer")=="cone1,cone2,cone3,somejet1,somejet2,"); +} + +void testProcessDesc::sequenceSubstitutionTest3() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.c = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.aa = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.bb = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.cc = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.dd = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.aaa = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.bbb = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.ccc = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.ddd = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.eee = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.last = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + + "process.s1 = cms.Sequence(process.a* process.b* process.c)\n" + "process.s2 = cms.Sequence(process.aa*process.bb*cms.ignore(process.cc)*process.dd)\n" + "process.s3 = cms.Sequence(process.aaa*process.bbb*~process.ccc*process.ddd*process.eee)\n" + "process.path1 = cms.Path(process.s1+process.s3+process.s2+process.last)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("path1"); + CPPUNIT_ASSERT(s[0]=="a"); + CPPUNIT_ASSERT(s[1]=="b"); + CPPUNIT_ASSERT(s[2]=="c"); + CPPUNIT_ASSERT(s[3]=="aaa"); + CPPUNIT_ASSERT(s[4]=="bbb"); + CPPUNIT_ASSERT(s[5]=="!ccc"); + CPPUNIT_ASSERT(s[6]=="ddd"); + CPPUNIT_ASSERT(s[7]=="eee"); + CPPUNIT_ASSERT(s[8]=="aa"); + CPPUNIT_ASSERT(s[9]=="bb"); + CPPUNIT_ASSERT(s[10]=="-cc"); + CPPUNIT_ASSERT(s[11]=="dd"); + CPPUNIT_ASSERT(s[12]=="last"); + + //CPPUNIT_ASSERT (b.getDependencies("a")==""); + //CPPUNIT_ASSERT (b.getDependencies("b")=="a,"); + //CPPUNIT_ASSERT (b.getDependencies("c")=="a,b,"); + //CPPUNIT_ASSERT (b.getDependencies("aaa")=="a,b,c,"); + //CPPUNIT_ASSERT (b.getDependencies("bbb")=="a,aaa,b,c,"); + //CPPUNIT_ASSERT (b.getDependencies("ccc")=="a,aaa,b,bbb,c,"); + //CPPUNIT_ASSERT (b.getDependencies("ddd")=="a,aaa,b,bbb,c,ccc,"); + //CPPUNIT_ASSERT (b.getDependencies("eee")=="a,aaa,b,bbb,c,ccc,ddd,"); + //CPPUNIT_ASSERT (b.getDependencies("aa")=="a,aaa,b,bbb,c,ccc,ddd,eee,"); + //CPPUNIT_ASSERT (b.getDependencies("bb")=="a,aa,aaa,b,bbb,c,ccc,ddd,eee,"); + //CPPUNIT_ASSERT (b.getDependencies("cc")=="a,aa,aaa,b,bb,bbb,c,ccc,ddd,eee,"); + //CPPUNIT_ASSERT (b.getDependencies("dd")=="a,aa,aaa,b,bb,bbb,c,cc,ccc,ddd,eee,"); + //CPPUNIT_ASSERT (b.getDependencies("last")=="a,aa,aaa,b,bb,bbb,c,cc,ccc,dd,ddd,eee,"); + +} + +void testProcessDesc::multiplePathsTest() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.cone3 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.anotherjtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.cones = cms.Sequence(process.cone1* process.cone2* process.cone3)\n" + "process.jets = cms.Sequence(process.somejet1* process.somejet2)\n" + "process.path1 = cms.Path(process.cones+ process.jtanalyzer)\n" + "process.path2 = cms.Path(process.jets+ process.anotherjtanalyzer)\n" + "process.schedule = cms.Schedule(process.path2, process.path1)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); + + typedef std::vector Strs; + + Strs s = (*test).getParameter >("path1"); + CPPUNIT_ASSERT(s[0]=="cone1"); + CPPUNIT_ASSERT(s[1]=="cone2"); + CPPUNIT_ASSERT(s[2]=="cone3"); + CPPUNIT_ASSERT(s[3]=="jtanalyzer"); + + //CPPUNIT_ASSERT (b.getDependencies("cone1")==""); + //CPPUNIT_ASSERT (b.getDependencies("cone2")=="cone1,"); + //CPPUNIT_ASSERT (b.getDependencies("cone3")=="cone1,cone2,"); + //CPPUNIT_ASSERT (b.getDependencies("jtanalyzer")=="cone1,cone2,cone3,"); + + s = (*test).getParameter >("path2"); + CPPUNIT_ASSERT(s[0]=="somejet1"); + CPPUNIT_ASSERT(s[1]=="somejet2"); + CPPUNIT_ASSERT(s[2]=="anotherjtanalyzer"); + + //CPPUNIT_ASSERT (b.getDependencies("somejet1")==""); + //CPPUNIT_ASSERT (b.getDependencies("somejet2")=="somejet1,"); + //CPPUNIT_ASSERT (b.getDependencies("anotherjtanalyzer")=="somejet1,somejet2,"); + + Strs schedule = (*test).getParameter >("@paths"); + + CPPUNIT_ASSERT (schedule.size() == 2); + CPPUNIT_ASSERT (schedule[0] == "path2"); + CPPUNIT_ASSERT (schedule[1] == "path1"); +} + +void testProcessDesc::inconsistentPathTest() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.a = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.b = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.c = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.path1 = cms.Path((process.a*process.b)+ (process.c*process.b))\n"; + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); +} + +void testProcessDesc::inconsistentMultiplePathTest() { + + std::string str = "import FWCore.ParameterSet.Config as cms\n" + "process = cms.Process('test')\n" + "process.cone1 = cms.EDProducer('PhonyConeJet', i = cms.int32(5))\n" + "process.cone2 = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.somejet1 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.somejet2 = cms.EDProducer('PhonyJet', i = cms.int32(7))\n" + "process.jtanalyzer = cms.EDProducer('PhonyConeJet', i = cms.int32(7))\n" + "process.cones = cms.Sequence(process.cone1+ process.cone2)\n" + "process.jets = cms.Sequence(process.somejet1* process.somejet2)\n" + "process.path1 = cms.Path(process.cones*process.jtanalyzer)\n" + "process.path2 = cms.Path(process.jets*process.jtanalyzer)\n"; + + std::shared_ptr test = PyBind11ProcessDesc(str).parameterSet(); +} + +#include diff --git a/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc b/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc new file mode 100644 index 0000000000000..6759388ff38c2 --- /dev/null +++ b/FWCore/PythonParameterSet/test/readpsetsfrom_t.cppunit.cc @@ -0,0 +1,53 @@ +/* + * makeprocess_t.cc + * EDMProto + * + * Created by Chris Jones on 5/18/05. + * Changed by Viji Sundararajan on 8-Jul-05. + * + */ + + +#include + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h" + +#include + +#include +#include +#include +#include +#include + +class testreadpsetsfrom: public CppUnit::TestFixture +{ +CPPUNIT_TEST_SUITE(testreadpsetsfrom); +CPPUNIT_TEST(simpleTest); +CPPUNIT_TEST_SUITE_END(); +public: + void setUp(){} + void tearDown(){} + void simpleTest(); +private: + +}; + + + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(testreadpsetsfrom); + +void testreadpsetsfrom::simpleTest() +{ + const char* kTest ="import FWCore.ParameterSet.Config as cms\n" + "dummy = cms.PSet(b = cms.bool(True))\n" + "foo = cms.PSet(a = cms.string('blah'))\n" + ; + std::shared_ptr test = edm::cmspybind11::readPSetsFrom(kTest); + + CPPUNIT_ASSERT(test->getParameterSet("dummy").getParameter("b")==true); + CPPUNIT_ASSERT(test->getParameterSet("foo").getParameter("a")==std::string("blah")); +} + diff --git a/FWCore/PythonParameterSet/test/ufip.txt b/FWCore/PythonParameterSet/test/ufip.txt new file mode 100644 index 0000000000000..a52b9dba51d13 --- /dev/null +++ b/FWCore/PythonParameterSet/test/ufip.txt @@ -0,0 +1 @@ +Dummy file for the FileInPath test. diff --git a/Fireworks/FWInterface/BuildFile.xml b/Fireworks/FWInterface/BuildFile.xml index ae866434a3230..da15bbb606f65 100644 --- a/Fireworks/FWInterface/BuildFile.xml +++ b/Fireworks/FWInterface/BuildFile.xml @@ -16,7 +16,7 @@ - + diff --git a/Fireworks/FWInterface/src/FWPathsPopup.cc b/Fireworks/FWInterface/src/FWPathsPopup.cc index 5933167183dec..892963551f27e 100644 --- a/Fireworks/FWInterface/src/FWPathsPopup.cc +++ b/Fireworks/FWInterface/src/FWPathsPopup.cc @@ -24,7 +24,7 @@ #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" #include "FWCore/ServiceRegistry/interface/StreamContext.h" -#include "FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h" +#include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h" #include #include "TGLabel.h" #include "KeySymbols.h" From d0921a5497fcbe9b59f883621aa435f0ef5f9a71 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Sat, 6 Apr 2019 18:55:18 +0200 Subject: [PATCH 493/686] Add option not to print event (per request of K. Lassila-Perini) --- GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc | 5 +++-- GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc diff --git a/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc b/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc old mode 100755 new mode 100644 index 602067191f5b1..20f10ba659c39 --- a/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc +++ b/GeneratorInterface/LHEInterface/test/DummyLHEAnalyzer.cc @@ -17,11 +17,11 @@ using namespace lhef; class DummyLHEAnalyzer : public EDAnalyzer { private: - bool dumpLHE_; - bool checkPDG_; + bool dumpEvent_; bool dumpHeader_; public: explicit DummyLHEAnalyzer( const ParameterSet & cfg ) : + dumpEvent_( cfg.getUntrackedParameter("dumpEvent",true) ), dumpHeader_( cfg.getUntrackedParameter("dumpHeader",false) ), tokenLHERunInfo_(consumes(cfg.getUntrackedParameter("moduleLabel", std::string("source")) ) ), tokenLHEEvent_(consumes(cfg.getUntrackedParameter("moduleLabel", std::string("source")) ) ) @@ -39,6 +39,7 @@ class DummyLHEAnalyzer : public EDAnalyzer { const std::vector idup_ = hepeup_.IDUP; const std::vector pup_ = hepeup_.PUP; + if ( !dumpEvent_ ) { return; } std::cout << "Number of particles = " << nup_ << std::endl; if ( evt->pdf() != NULL ) { diff --git a/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py b/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py index 0a30df91b8ec3..888cba3fd0b22 100644 --- a/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py +++ b/GeneratorInterface/LHEInterface/test/dumpLHE_cfg.py @@ -12,6 +12,7 @@ process.dummy = cms.EDAnalyzer("DummyLHEAnalyzer", moduleLabel = cms.untracked.InputTag("externalLHEProducer"), + dumpEvent = cms.untracked.bool(True), dumpHeader = cms.untracked.bool(True) ) From baee51c86856adebce0be47f594f05709d104765 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 6 Apr 2019 19:08:15 +0200 Subject: [PATCH 494/686] move unit test to ParameterSetReader interface --- FWCore/Integration/test/BuildFile.xml | 2 +- FWCore/Integration/test/SwitchProducer_t.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/FWCore/Integration/test/BuildFile.xml b/FWCore/Integration/test/BuildFile.xml index 705558020be47..e8cbcf6460efc 100644 --- a/FWCore/Integration/test/BuildFile.xml +++ b/FWCore/Integration/test/BuildFile.xml @@ -139,7 +139,7 @@ - + diff --git a/FWCore/Integration/test/SwitchProducer_t.cpp b/FWCore/Integration/test/SwitchProducer_t.cpp index 298db6ab77595..289f9dc506f77 100644 --- a/FWCore/Integration/test/SwitchProducer_t.cpp +++ b/FWCore/Integration/test/SwitchProducer_t.cpp @@ -3,7 +3,7 @@ #include "DataFormats/TestObjects/interface/ToyProducts.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/TestProcessor/interface/TestProcessor.h" #include @@ -49,8 +49,8 @@ TEST_CASE("Configuration", s_tag) { const std::string baseConfigTest2Disabled = makeConfig(false, test1, test2); SECTION("Configuration hash is not changed") { - auto pset = edm::cmspybind11::readConfig(baseConfig); - auto psetTest2Disabled = edm::cmspybind11::readConfig(baseConfigTest2Disabled); + auto pset = edm::readConfig(baseConfig); + auto psetTest2Disabled = edm::readConfig(baseConfigTest2Disabled); pset->registerIt(); psetTest2Disabled->registerIt(); REQUIRE(pset->id() == psetTest2Disabled->id()); @@ -107,8 +107,8 @@ TEST_CASE("Configuration with EDAlias", s_tag) { const std::string baseConfigTest2Disabled = makeConfig(false, test1, test2, otherprod, othername); SECTION("Configuration hash is not changed") { - auto pset = edm::cmspybind11::readConfig(baseConfig); - auto psetTest2Disabled = edm::cmspybind11::readConfig(baseConfigTest2Disabled); + auto pset = edm::readConfig(baseConfig); + auto psetTest2Disabled = edm::readConfig(baseConfigTest2Disabled); pset->registerIt(); psetTest2Disabled->registerIt(); REQUIRE(pset->id() == psetTest2Disabled->id()); From fef2af57fb76b3172b271954cc572db162bad238 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 6 Apr 2019 20:21:41 +0200 Subject: [PATCH 495/686] clang tidy fix --- FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc index d675f83496db0..f125cf1e61da4 100644 --- a/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc +++ b/FWCore/PyDevParameterSet/src/PyBind11ProcessDesc.cc @@ -46,7 +46,7 @@ namespace cmspython3 { v_argv.reserve(argc); vp_argv.reserve(argc); for (int i = 0; i < argc; i++) { - v_argv.emplace_back(Py_DecodeLocale(argv[i], NULL), &PyMem_RawFree); + v_argv.emplace_back(Py_DecodeLocale(argv[i], nullptr), &PyMem_RawFree); vp_argv.emplace_back(v_argv.back().get()); } From f346656bbb1fd186260846b6ddcabc0abcb912ef Mon Sep 17 00:00:00 2001 From: Oz Date: Sat, 6 Apr 2019 23:10:07 +0200 Subject: [PATCH 496/686] Allow different template IDs for 1D and 2D. Lookup all IDs during initialization --- .../SiPixelRecHits/interface/PixelCPEBase.h | 1 + .../interface/PixelCPEClusterRepair.h | 4 ++ .../src/PixelCPEClusterRepair.cc | 64 +++++++++++++++---- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEBase.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEBase.h index 45ce45ea1ac8c..e956931d76a96 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEBase.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEBase.h @@ -76,6 +76,7 @@ class PixelCPEBase : public PixelClusterParameterEstimator float lorentzShiftInCmX; // a FULL shift, in cm float lorentzShiftInCmY; // a FULL shift, in cm int detTemplateId; // det if for templates & generic errors + int detTemplateId2D; // det if for 2D templates }; struct ClusterParam diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h index cd7f469ae6c3e..332f06d35caf3 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h @@ -87,6 +87,8 @@ class PixelCPEClusterRepair : public PixelCPEBase SiPixelTemplateReco::ClusMatrix & clusterPayload, int ID) const; + //Fill IDs for 2D template + void fill2DTemplIDs(); @@ -104,6 +106,8 @@ class PixelCPEClusterRepair : public PixelCPEBase int forwardTemplateID_ ; std::string templateDir_ ; + const SiPixel2DTemplateDBObject * templateDBobject2D_; + // Configure 2D reco. float minChargeRatio_; float maxSizeMismatchInY_ ; diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 52f6664ad8a70..9aabef1cebf29 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -15,7 +15,6 @@ // Commented for now (3/10/17) until we figure out how to resuscitate 2D template splitter /// #include "RecoLocalTracker/SiPixelRecHits/interface/SiPixelTemplateSplit.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include #include "boost/multi_array.hpp" @@ -61,8 +60,8 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, // Initialize template store to the selected ID [Morris, 6/25/08] if ( !SiPixelTemplate2D::pushfile( *templateDBobject2D , thePixelTemp2D_) ) throw cms::Exception("PixelCPEClusterRepair") - << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " - << (*templateDBobject_).version() << "\n\n"; + << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject2D version " + << (*templateDBobject2D).version() << "\n\n"; } else { @@ -82,6 +81,8 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; } + templateDBobject2D_ = templateDBobject2D; + fill2DTemplIDs(); speed_ = conf.getParameter( "speed"); LogDebug("PixelCPEClusterRepair::PixelCPEClusterRepair:") << "Template speed = " << speed_ << "\n"; @@ -107,6 +108,43 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, RunDamagedClusters_ = conf.existsAs("RunDamagedClusters")?conf.getParameter("RunDamagedClusters"):false; } +//----------------------------------------------------------------------------- +// Fill all 2D template IDs +//----------------------------------------------------------------------------- +void PixelCPEClusterRepair::fill2DTemplIDs() +{ + auto const & dus = geom_.detUnits(); + unsigned m_detectors = dus.size(); + for(unsigned int i=1;i<7;++i) { + LogDebug("PixelCPEClusterRepair:: LookingForFirstStrip") << "Subdetector " << i + << " GeomDetEnumerator " << GeomDetEnumerators::tkDetEnum[i] + << " offset " << geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) + << " is it strip? " << (geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() ? + dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip() : false); + if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() && + dus[geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip()) { + if(geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]) < m_detectors) m_detectors = geom_.offsetDU(GeomDetEnumerators::tkDetEnum[i]); + } + } + LogDebug("LookingForFirstStrip") << " Chosen offset: " << m_detectors; + + + m_DetParams.resize(m_detectors); + LogDebug("PixelCPEClusterRepair::fillDetParams():") <<"caching "<getTemplateID(p.theDet->geographicalId()); + if(p.detTemplateId != p.detTemplateId2D && !printed_info){ + edm::LogInfo("PixelCPEClusterRepair") << "different template ID between 1D and 2D " << p.detTemplateId << " " << p.detTemplateId2D << endl; + printed_info = true; + } + } + +} + //----------------------------------------------------------------------------- @@ -144,18 +182,18 @@ PixelCPEClusterRepair::localPosition(DetParam const & theDetParam, ClusterParam << "A non-pixel detector type in here?"; - int ID = -9999; + int ID1 = -9999; + int ID2 = -9999; if ( LoadTemplatesFromDB_ ) { - int ID0 = templateDBobject_->getTemplateID(theDetParam.theDet->geographicalId()); // just to comapre - ID = theDetParam.detTemplateId; - if(ID0!=ID) edm::LogError("PixelCPEClusterRepair") <<" different id"<< ID<<" "< + + + + + + diff --git a/FWCore/ParameterSetReader/bin/edmConfigHash.cpp b/FWCore/ParameterSetReader/bin/edmConfigHash.cpp new file mode 100644 index 0000000000000..6f4e8507129f8 --- /dev/null +++ b/FWCore/ParameterSetReader/bin/edmConfigHash.cpp @@ -0,0 +1,42 @@ + +// This will return the ParameterSetID of the parameter set +// defined in the python file or configuration string. +// Warning, this may not be the same as the ParameterSetID +// of a cmsRun process, because validation code may insert +// additional parameters into the configuration. + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include + +#include +#include + +int main(int argc, char **argv) try { + // config can either be a name or a string + std::string config; + + if(argc == 1) { + // Read input from cin into configstring.. + std::string line; + while(std::getline(std::cin, line)) { + config += line; + config += '\n'; + } + } else if(argc == 2) { + config = std::string(argv[1]); + } + + std::shared_ptr parameterSet = edm::readConfig(config); + parameterSet->registerIt(); + std::cout << parameterSet->id() << std::endl; + return 0; +} catch(cms::Exception const& e) { + std::cout << e.explainSelf() << std::endl; + return 1; +} catch(std::exception const& e) { + std::cout << e.what() << std::endl; + return 1; +} diff --git a/FWCore/ParameterSetReader/bin/edmParameterSetDump.cpp b/FWCore/ParameterSetReader/bin/edmParameterSetDump.cpp new file mode 100644 index 0000000000000..cd907f091cdda --- /dev/null +++ b/FWCore/ParameterSetReader/bin/edmParameterSetDump.cpp @@ -0,0 +1,36 @@ +// -*- C++ -*- +// +// Package: PythonParameterSet +// Class : edmParameterSetDump +// +// Implementation: +// +// +// Original Author: Rick Wilkinson +// Created: Thu Aug 2 13:33:53 EDT 2007 +// + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include +#include +#include + +int main (int argc, char **argv) try { + if(argc != 2) { + std::cout << "Usage: edmParameterSetDump " << std::endl; + } + std::string fileName(argv[1]); + std::shared_ptr parameterSet = edm::readConfig(fileName); + std::cout << "====Main Process====" << std::endl; + std::cout << parameterSet->dump() << std::endl; + return 0; +} catch(cms::Exception const& e) { + std::cout << e.explainSelf() << std::endl; + return 1; +} catch(std::exception const& e) { + std::cout << e.what() << std::endl; + return 1; +} From cbf470de6d8a85cbabb2c4fa9e5395caf569f662 Mon Sep 17 00:00:00 2001 From: Alexander Toropin Date: Sun, 7 Apr 2019 20:15:29 +0200 Subject: [PATCH 499/686] New slopes for S9S1filter --- .../python/HFPhase1Reconstructor_cfi.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py index 82928ae519aa2..c414a6091a30c 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HFPhase1Reconstructor_cfi.py @@ -1,5 +1,15 @@ import FWCore.ParameterSet.Config as cms +# Slopes for the S9S1 filter +_slopes_S9S1_run1 = [-99999,0.0164905,0.0238698,0.0321383, + 0.041296,0.0513428,0.0622789,0.0741041, + 0.0868186,0.100422,0.135313,0.136289,0.0589927] + +_coeffs = [1.0, 2.5, 2.2, 2.0, 1.8, 1.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] + +_slopes_S9S1_run2 = [s*c for s, c in zip(_slopes_S9S1_run1, _coeffs)] + + hfreco = cms.EDProducer("HFPhase1Reconstructor", # Label for the input HFPreRecHitCollection inputLabel = cms.InputTag("hfprereco"), @@ -88,10 +98,7 @@ # S9S1stat = cms.PSet( # WARNING! ONLY LONG PARAMETERS ARE USED IN DEFAULT RECO; SHORT S9S1 IS NOT USED! - short_optimumSlope = cms.vdouble([-99999,0.0164905,0.0238698,0.0321383, - 0.041296,0.0513428,0.0622789,0.0741041, - 0.0868186,0.100422,0.135313,0.136289, - 0.0589927]), + short_optimumSlope = cms.vdouble(_slopes_S9S1_run2), # Short energy cut is 129.9 - 6.61*|ieta|+0.1153*|ieta|^2 shortEnergyParams = cms.vdouble([35.1773, 35.37, 35.7933, 36.4472, @@ -102,10 +109,7 @@ 0,0,0,0, 0,0,0,0,0]), - long_optimumSlope = cms.vdouble([-99999,0.0164905,0.0238698,0.0321383, - 0.041296,0.0513428,0.0622789,0.0741041, - 0.0868186,0.100422,0.135313,0.136289, - 0.0589927]), + long_optimumSlope = cms.vdouble(_slopes_S9S1_run2), # Long energy cut is 162.4-10.9*abs(ieta)+0.21*ieta*ieta longEnergyParams = cms.vdouble([43.5, 45.7, 48.32, 51.36, From ac6051bdffd8e30f66b6e8bce048799fd78bad45 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sun, 7 Apr 2019 20:23:48 -0500 Subject: [PATCH 500/686] Avoid null reference in getTrackFromChargedHadron Calling operator* on a edm:Ref can cause it to return a reference to a nullptr. This is not allowed in C++ which allows the compiler to remove checks. This lead to crashes when clang optimized the code. Getting a pointer instead avoids the problem. --- RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc index 52f2b73f0322e..c9882e238d8ec 100644 --- a/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc +++ b/RecoTauTag/RecoTau/src/pfRecoTauChargedHadronAuxFunctions.cc @@ -14,11 +14,11 @@ const reco::Track* getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron& return chargedHadron.getTrack().get(); } // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist - const pat::PackedCandidate* chargedPFPCand = dynamic_cast (&*chargedHadron.getChargedPFCandidate()); + const pat::PackedCandidate* chargedPFPCand = dynamic_cast (chargedHadron.getChargedPFCandidate().get()); if (chargedPFPCand != nullptr) { return chargedPFPCand->bestTrack(); } - const pat::PackedCandidate* lostTrackCand = dynamic_cast (&*chargedHadron.getLostTrackCandidate()); + const pat::PackedCandidate* lostTrackCand = dynamic_cast (chargedHadron.getLostTrackCandidate().get()); if (lostTrackCand != nullptr) { return lostTrackCand->bestTrack(); } From c4066805747c4b80e00a835bd44a5f6777ad44b8 Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Thu, 4 Apr 2019 12:22:46 +0200 Subject: [PATCH 501/686] dEdx weights and thickness correction factors --- .../python/HGCalRecHit_cfi.py | 59 ++++++++++++++++++- .../python/HGCalUncalibRecHit_cfi.py | 11 +++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py index 8045aa4d04761..5d15f8c8ed4c3 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py @@ -114,7 +114,63 @@ from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 -phase2_hgcalV9.toModify( dEdX, weights = dEdX_weights_v9 ) +phase2_hgcalV9.toModify( dEdX, weights = dEdX_weights_v9 ) + +dEdX_weights_v10 = cms.vdouble(0.0, # there is no layer zero + 8.894541, # Mev + 10.937907, + 10.937907, + 10.937907, + 10.937907, + 10.937907, + 10.937907, + 10.937907, + 10.937907, + 10.932882, + 10.932882, + 10.937907, + 10.937907, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 10.938169, + 32.332097, + 51.574301, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 51.444192, + 69.513118, + 87.582044, + 87.582044, + 87.582044, + 87.582044, + 87.582044, + 87.214571, + 86.888309, + 86.929520, + 86.929520, + 86.929520) + + +from Configuration.Eras.Modifier_phase2_hgcalV10_cff import phase2_hgcalV10 +phase2_hgcalV10.toModify( dEdX, weights = dEdX_weights_v10 ) # HGCAL rechit producer HGCalRecHit = cms.EDProducer( @@ -155,3 +211,4 @@ ) phase2_hgcalV9.toModify( HGCalRecHit , thicknessCorrection = cms.vdouble(0.759,0.760,0.773) ) #120um, 200um, 300um +phase2_hgcalV10.toModify( HGCalRecHit , thicknessCorrection = cms.vdouble(0.781,0.775,0.769) ) #120um, 200um, 300um diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py index a7f3f60eae9a2..8c0eada107873 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py @@ -4,6 +4,8 @@ fCPerMIP_v9 = cms.vdouble(2.06,3.43,5.15) #120um, 200um, 300um +fCPerMIP_v10 = cms.vdouble(2.06,3.43,5.15) #120um, 200um, 300um + # HGCAL producer of rechits starting from digis HGCalUncalibRecHit = cms.EDProducer( "HGCalUncalibRecHitProducer", @@ -52,4 +54,11 @@ from Configuration.Eras.Modifier_phase2_hgcalV9_cff import phase2_hgcalV9 phase2_hgcalV9.toModify( HGCalUncalibRecHit.HGCEEConfig , fCPerMIP = fCPerMIP_v9 ) -phase2_hgcalV9.toModify( HGCalUncalibRecHit.HGCHEFConfig , fCPerMIP = fCPerMIP_v9 ) +phase2_hgcalV9.toModify( HGCalUncalibRecHit.HGCHEFConfig , fCPerMIP = fCPerMIP_v9 ) + +from Configuration.Eras.Modifier_phase2_hgcalV10_cff import phase2_hgcalV10 +phase2_hgcalV10.toModify( HGCalUncalibRecHit.HGCEEConfig , fCPerMIP = fCPerMIP_v10 ) +phase2_hgcalV10.toModify( HGCalUncalibRecHit.HGCHEFConfig , fCPerMIP = fCPerMIP_v10 ) + + + From e54ca1f91f049e9e365ed5174c73c5ce0a6e17f4 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Mon, 8 Apr 2019 12:47:46 +0200 Subject: [PATCH 502/686] converting EvFOutputModule to "one" base class template watching lumi cache. This now permits module to see more than one lumisection. --- .../Utilities/interface/EvFOutputModule.h | 89 +++++++++++++++++-- EventFilter/Utilities/src/EvFOutputModule.cc | 86 +++++++----------- 2 files changed, 112 insertions(+), 63 deletions(-) diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h index c2f24eebdeba7..ad8240712a6eb 100644 --- a/EventFilter/Utilities/interface/EvFOutputModule.h +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -1,19 +1,84 @@ #ifndef EventFilter_Utilities_EvFOutputModule_h #define EventFilter_Utilities_EvFOutputModule_h -#include "FWCore/Framework/interface/limited/OutputModule.h" +#include "IOPool/Streamer/interface/StreamerOutputFile.h" +#include "FWCore/Framework/interface/one/OutputModule.h" #include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h" #include "FWCore/Utilities/interface/EDGetToken.h" +#include "EventFilter/Utilities/interface/JsonMonitorable.h" +#include "EventFilter/Utilities/interface/FastMonitor.h" +# typedef edm::detail::TriggerResultsBasedEventSelector::handle_t Trig; namespace evf { class FastMonitoringService; - class EvFOutputEventWriter; - class EvFOutputJSONWriter; +// class EvFOutputEventWriter; - typedef edm::limited::OutputModule,edm::LuminosityBlockCache> EvFOutputModuleType; + class EvFOutputEventWriter + { + public: + + explicit EvFOutputEventWriter(std::string const& filePath): + filePath_(filePath), + accepted_(0), + stream_writer_events_(new StreamerOutputFile(filePath)) + { + } + + ~EvFOutputEventWriter() { + } + + void close() { + stream_writer_events_->close(); + } + + void doOutputEvent(EventMsgBuilder const& msg) { + EventMsgView eview(msg.startAddress()); + stream_writer_events_->write(eview); + } + + uint32 get_adler32() const { + return stream_writer_events_->adler32(); + } + + std::string const& getFilePath() const {return filePath_;} + + unsigned long getAccepted() const {return accepted_;} + void incAccepted() {accepted_++;} + + private: + std::string filePath_; + unsigned long accepted_; + edm::propagate_const> stream_writer_events_; + + }; + + + class EvFOutputJSONWriter { + public: + EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel); + + edm::StreamerOutputModuleCommon streamerCommon_; + + jsoncollector::IntJ processed_; + jsoncollector::IntJ accepted_; + jsoncollector::IntJ errorEvents_; + jsoncollector::IntJ retCodeMask_; + jsoncollector::StringJ filelist_; + jsoncollector::IntJ filesize_; + jsoncollector::StringJ inputFiles_; + jsoncollector::IntJ fileAdler32_; + jsoncollector::StringJ transferDestination_; + jsoncollector::StringJ mergeType_; + jsoncollector::IntJ hltErrorEvents_; + std::shared_ptr jsonMonitor_; + jsoncollector::DataPointDefinition outJsonDef_; + }; + + + typedef edm::one::OutputModule> EvFOutputModuleType; class EvFOutputModule : public EvFOutputModuleType @@ -24,16 +89,21 @@ namespace evf { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: + void beginRun(edm::RunForOutput const& run) override; void write(edm::EventForOutput const& e) override; //pure in parent class but unused here - void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} + void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} //? void writeRun(edm::RunForOutput const&) override {} - void globalEndRun(edm::RunForOutput const&) const override {} + void endRun(edm::RunForOutput const&) override {} +// void globalEndRun(edm::RunForOutput const&) const override {} + + //void beginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; +// void beginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; +// void endLuminosityBlock(edm::LuminosityBlockForOutput const&) override; - std::shared_ptr globalBeginRun(edm::RunForOutput const& run) const override; std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const override; - void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const override; + void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; Trig getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const; @@ -43,6 +113,9 @@ namespace evf { evf::FastMonitoringService *fms_; + std::shared_ptr jsonWriter_; + + }; //end-of-class-def } // end of namespace-evf diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index d525fa04b406b..a80f03d2e23d1 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -6,8 +6,6 @@ #include "EventFilter/Utilities/interface/FastMonitoringService.h" #include "EventFilter/Utilities/interface/EvFDaqDirector.h" -#include "EventFilter/Utilities/interface/JsonMonitorable.h" -#include "EventFilter/Utilities/interface/FastMonitor.h" #include "EventFilter/Utilities/interface/JSONSerializer.h" #include "EventFilter/Utilities/interface/FileIO.h" #include "FWCore/Utilities/interface/Adler32Calculator.h" @@ -16,7 +14,6 @@ #include "FWCore/Framework/interface/LuminosityBlockForOutput.h" #include "FWCore/Framework/interface/LuminosityBlock.h" -#include "IOPool/Streamer/interface/StreamerOutputFile.h" #include "IOPool/Streamer/interface/InitMsgBuilder.h" #include "IOPool/Streamer/interface/EventMsgBuilder.h" @@ -25,7 +22,7 @@ #include namespace evf { - +/* class EvFOutputEventWriter { public: @@ -65,10 +62,8 @@ namespace evf { }; - - class EvFOutputJSONWriter { - public: - EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel): +*/ + EvFOutputJSONWriter::EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel): streamerCommon_(ps, selections), processed_(0), accepted_(0), @@ -145,28 +140,10 @@ namespace evf { jsonMonitor_->registerGlobalMonitorable(&mergeType_,false); jsonMonitor_->registerGlobalMonitorable(&hltErrorEvents_,false); jsonMonitor_->commit(nullptr); - } - - edm::StreamerOutputModuleCommon streamerCommon_; - - jsoncollector::IntJ processed_; - jsoncollector::IntJ accepted_; - jsoncollector::IntJ errorEvents_; - jsoncollector::IntJ retCodeMask_; - jsoncollector::StringJ filelist_; - jsoncollector::IntJ filesize_; - jsoncollector::StringJ inputFiles_; - jsoncollector::IntJ fileAdler32_; - jsoncollector::StringJ transferDestination_; - jsoncollector::StringJ mergeType_; - jsoncollector::IntJ hltErrorEvents_; - std::shared_ptr jsonMonitor_; - jsoncollector::DataPointDefinition outJsonDef_; - - }; + } EvFOutputModule::EvFOutputModule(edm::ParameterSet const& ps) : - edm::limited::OutputModuleBase(ps), + edm::one::OutputModuleBase(ps), EvFOutputModuleType(ps), ps_(ps), streamLabel_(ps.getParameter("@module_label")), @@ -221,11 +198,11 @@ namespace evf { } - std::shared_ptr - EvFOutputModule::globalBeginRun(edm::RunForOutput const& run) const + void + EvFOutputModule::beginRun(edm::RunForOutput const& run) { //create run Cache holding JSON file writer and variables - auto rc = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); + jsonWriter_ = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); //output INI file (non-const). This doesn't require globalBeginRun to be finished const std::string openIniFileName = edm::Service()->getOpenInitFilePath(streamLabel_); @@ -237,7 +214,7 @@ namespace evf { edm::BranchIDLists const* bidlPtr = branchIDLists(); std::unique_ptr init_message = - rc->streamerCommon_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), + jsonWriter_->streamerCommon_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(), OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID()); //Let us turn it into a View @@ -267,7 +244,7 @@ namespace evf { fclose(src); //clear serialization buffers - rc->streamerCommon_.clearSerializeDataBuffer(); + jsonWriter_->streamerCommon_.clearSerializeDataBuffer(); //free output buffer needed only for the file write delete [] outBuf; @@ -283,7 +260,6 @@ namespace evf { boost::filesystem::rename(openIniFileName,edm::Service()->getInitFilePath(streamLabel_)); } - return rc; } @@ -299,8 +275,8 @@ namespace evf { EvFOutputModule::globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const { auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(),streamLabel_); - auto lumiWriter = std::make_shared(openDatFilePath); - return lumiWriter; + + return std::make_shared(openDatFilePath); } @@ -309,55 +285,55 @@ namespace evf { edm::Handle const& triggerResults = getTriggerResults(trToken_, e); - //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by e.getRun() - auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); - auto lumiWriter = const_cast(luminosityBlockCache(e.getLuminosityBlock().index() )); + //auto lumiWriter = const_cast(luminosityBlockCache(e.getLuminosityBlock().index() )); + auto lumiWriter = luminosityBlockCache(e.getLuminosityBlock().index() ); - std::unique_ptr msg = rc->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); + std::unique_ptr msg = jsonWriter_->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig()); lumiWriter->incAccepted(); lumiWriter->doOutputEvent(*msg); //msg is written and discarded at this point } void - EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const + EvFOutputModule::globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) { - //runCache parameter at this time is ignored. Obtaning index is also currently not possible from RunOutput returned by iLB.getRun() - auto rc = const_cast(EvFOutputModuleType::runCache(edm::RunIndex::invalidRunIndex())); auto lumiWriter = luminosityBlockCache(iLB.index()); + //close dat file + lumiWriter->close(); - rc->fileAdler32_.value() = lumiWriter->get_adler32(); - const_cast(lumiWriter)->close(); + jsonWriter_->fileAdler32_.value() = lumiWriter->get_adler32(); + jsonWriter_->accepted_.value() = lumiWriter->getAccepted(); bool abortFlag = false; - rc->processed_.value() = fms_->getEventsProcessedForLumi(iLB.luminosityBlock(),&abortFlag); - rc->accepted_.value() = lumiWriter->getAccepted(); + jsonWriter_->processed_.value() = fms_->getEventsProcessedForLumi(iLB.luminosityBlock(),&abortFlag); if (abortFlag) { edm::LogInfo("EvFOutputModule") << "Abort flag has been set. Output is suppressed"; return; } - if(rc->processed_.value()!=0) { + if (jsonWriter_->processed_.value()!=0) { struct stat istat; boost::filesystem::path openDatFilePath = lumiWriter->getFilePath(); stat(openDatFilePath.string().c_str(), &istat); - rc->filesize_ = istat.st_size; + jsonWriter_->filesize_ = istat.st_size; boost::filesystem::rename(openDatFilePath.string().c_str(), edm::Service()->getDatFilePath(iLB.luminosityBlock(),streamLabel_)); - rc->filelist_ = openDatFilePath.filename().string(); + jsonWriter_->filelist_ = openDatFilePath.filename().string(); } else { //remove empty file when no event processing has occurred remove(lumiWriter->getFilePath().c_str()); - rc->filesize_ = 0; - rc->filelist_ = ""; - rc->fileAdler32_.value()=-1; //no files in signed long + jsonWriter_->filesize_ = 0; + jsonWriter_->filelist_ = ""; + jsonWriter_->fileAdler32_.value()=-1; //no files in signed long } //produce JSON file - rc->jsonMonitor_->snap(iLB.luminosityBlock()); + jsonWriter_->jsonMonitor_->snap(iLB.luminosityBlock()); const std::string outputJsonNameStream = edm::Service()->getOutputJsonFilePath(iLB.luminosityBlock(),streamLabel_); - rc->jsonMonitor_->outputFullJSON(outputJsonNameStream,iLB.luminosityBlock()); + jsonWriter_->jsonMonitor_->outputFullJSON(outputJsonNameStream,iLB.luminosityBlock()); + } + } // end of namespace-evf From 61aa9fdc1b541ed99bd1354a98cca7e45be247e5 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Mon, 8 Apr 2019 16:26:54 +0200 Subject: [PATCH 503/686] Add missing algorithm to be able to build MTD geometry --- .../DDCMS/plugins/DDPixBarLayerAlgo.cc | 2 +- .../test/python/testMTDGeometry.py | 6 +- .../TrackerCommonData/plugins/BuildFile.xml | 8 ++ .../plugins/dd4hep/DDTrackerRingAlgo.cc | 129 ++++++++++++++++++ 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc diff --git a/DetectorDescription/DDCMS/plugins/DDPixBarLayerAlgo.cc b/DetectorDescription/DDCMS/plugins/DDPixBarLayerAlgo.cc index 6ec27b1b1789c..9c767281e8156 100644 --- a/DetectorDescription/DDCMS/plugins/DDPixBarLayerAlgo.cc +++ b/DetectorDescription/DDCMS/plugins/DDPixBarLayerAlgo.cc @@ -118,7 +118,7 @@ static long algorithm(Detector& description, cms::DDParsingContext& ctxt, xml_h << "rotation: " << rots << "\t90., " << convertRadToDeg( phix ) << ", 90.," << convertRadToDeg( phiy ) << ", 0, 0"; - rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0.,0.); + rot = makeRotation3D(90_deg, phix, 90_deg, phiy, 0., 0.); //cpv.position(ladderHalf, layer, copy, tran, rot); pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot,tran)); diff --git a/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py b/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py index 6158c8bd95e0a..11e3098e00637 100644 --- a/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py +++ b/Geometry/MTDGeometryBuilder/test/python/testMTDGeometry.py @@ -55,4 +55,8 @@ DDDetector = cms.ESInputTag('MTD') ) -process.p = cms.Path(process.test) +process.dump = cms.EDAnalyzer("DDTestDumpFile", + DDDetector = cms.ESInputTag('MTD') +) + +process.p = cms.Path(process.test+process.dump) diff --git a/Geometry/TrackerCommonData/plugins/BuildFile.xml b/Geometry/TrackerCommonData/plugins/BuildFile.xml index c4eba48608a0b..3edb29bdeeada 100644 --- a/Geometry/TrackerCommonData/plugins/BuildFile.xml +++ b/Geometry/TrackerCommonData/plugins/BuildFile.xml @@ -3,3 +3,11 @@ + + + + + + + + diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc new file mode 100644 index 0000000000000..e2a1a235277ab --- /dev/null +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc @@ -0,0 +1,129 @@ +#include "DD4hep/DetFactoryHelper.h" +#include "DataFormats/Math/interface/GeantUnits.h" +#include "DetectorDescription/DDCMS/interface/DDPlugins.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +using namespace std; +using namespace dd4hep; +using namespace cms; +using namespace geant_units::operators; + +static long algorithm(Detector& /* description */, + cms::DDParsingContext& ctxt, xml_h e, + SensitiveDetector& /* sens */) +{ + cms::DDNamespace ns(ctxt, e, true); + DDAlgoArguments args(ctxt, e); + Volume mother = ns.volume(args.parentName()); + string childName = args.value("ChildName"); + Volume child = ns.volume(childName); + + string parentName = args.parentName(); + int n = args.value("N"); + int startCopyNo = args.value("StartCopyNo"); + int incrCopyNo = args.value("IncrCopyNo"); + double rangeAngle = args.value("RangeAngle"); + double startAngle = args.value("StartAngle"); + double radius = args.value("Radius"); + vector center = args.value >("Center"); + bool isZPlus = args.value("IsZPlus") == 1; + double tiltAngle = args.value("TiltAngle"); + bool isFlipped = args.value("IsFlipped") == 1; + double delta = 0.; + + if(fabs(rangeAngle - 360.0_deg) < 0.001_deg) { + delta = rangeAngle/double(n); + } else { + if(n > 1) { + delta = rangeAngle/double(n-1); + } else { + delta = 0.; + } + } + + LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position" + << "ing:: n " << n << " Start, Range, Delta " + << convertRadToDeg(startAngle) << " " + << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) + << " Radius " << radius << " Centre " << center[0] + << ", " << center[1] << ", "<< center[2]; + + LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName + << "\tChild " << childName << " NameSpace " + << ns.name(); + + Rotation3D flipRot, tiltRot, phiRot, globalRot; // Identity + Rotation3D flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix + + // flipMatrix calculus + if(isFlipped) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., 180., " + << "90., 90., " + << "180., 0."; + flipRot = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0._deg); + flipMatrix = flipRot; + } + // tiltMatrix calculus + if(isZPlus) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., 90., " + << convertRadToDeg(tiltAngle) << ", 180., " + << convertRadToDeg(90._deg - tiltAngle) << ", 0."; + tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 180._deg, 90._deg - tiltAngle, 0._deg); + tiltMatrix = tiltRot; + if(isFlipped) { tiltMatrix *= flipMatrix; } + } + else { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., 90., " + << convertRadToDeg(tiltAngle) << ", 0., " + << convertRadToDeg(90._deg + tiltAngle) << ", 0."; + tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 0._deg, 90._deg + tiltAngle, 0._deg); + tiltMatrix = tiltRot; + if(isFlipped) { tiltMatrix *= flipMatrix; } + } + + // Loops for all phi values + double theta = 90._deg; + int copy = startCopyNo; + double phi = startAngle; + + for(int i = 0; i < n; ++i) { + // phiRotMatrix calculus + double phix = phi; + double phiy = phix + 90._deg; + double phideg = convertRadToDeg(phix); + if(phideg != 0.) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., " << convertRadToDeg(phix) + << ", 90.," << convertRadToDeg(phiy) + <<", 0., 0."; + phiRot = makeRotation3D(theta, phix, theta, phiy, 0., 0.); + phiRotMatrix = phiRot; + } + + // globalRot def + globalRotMatrix = phiRotMatrix * tiltMatrix; + globalRot = Rotation3D(globalRotMatrix); + + // translation def + double xpos = radius*cos(phi) + center[0]; + double ypos = radius*sin(phi) + center[1]; + double zpos = center[2]; + Position tran(xpos, ypos, zpos); + + // Positions child with respect to parent + mother.placeVolume(child, copy, Transform3D(globalRot, tran)); + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test " << child << " number " + << copy << " positioned in " << mother << " at " + << tran << " with " << globalRot; + + copy += incrCopyNo; + phi += delta; + } + return 1; +} + +// first argument is the type from the xml file +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerRingAlgo,algorithm) From 013e8c32e0f9e6a1fca9134323091c573aa0a321 Mon Sep 17 00:00:00 2001 From: Cristina Mantilla Date: Mon, 8 Apr 2019 17:12:47 +0200 Subject: [PATCH 504/686] switch to LogWarning instead --- RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 9aabef1cebf29..32ef23509b1f9 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -138,7 +138,7 @@ void PixelCPEClusterRepair::fill2DTemplIDs() p.detTemplateId2D = templateDBobject2D_->getTemplateID(p.theDet->geographicalId()); if(p.detTemplateId != p.detTemplateId2D && !printed_info){ - edm::LogInfo("PixelCPEClusterRepair") << "different template ID between 1D and 2D " << p.detTemplateId << " " << p.detTemplateId2D << endl; + edm::LogWarning("PixelCPEClusterRepair") << "different template ID between 1D and 2D " << p.detTemplateId << " " << p.detTemplateId2D << endl; printed_info = true; } } From c84c22278e5ed588deb83cad5856c79d3271c76d Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 8 Apr 2019 11:07:34 -0500 Subject: [PATCH 505/686] Removed unnecesary include from EcalLaserDbService In addition, concurrent_hash_map.h does not presently compile with gcc9. --- .../EcalLaserCorrection/interface/EcalLaserDbService.h | 1 - 1 file changed, 1 deletion(-) diff --git a/CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h b/CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h index 718404e5eb610..3323b635d07f3 100644 --- a/CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h +++ b/CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h @@ -7,7 +7,6 @@ #include #include -#include #include "DataFormats/DetId/interface/DetId.h" From 8aa9ff4fda4178f8f937d9b0b04f9fcf8bb84cc2 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 8 Apr 2019 19:05:07 +0200 Subject: [PATCH 506/686] Correct the calibration algos --- Calibration/HcalCalibAlgos/macros/CalibCorr.C | 104 ++++--- .../HcalCalibAlgos/macros/CalibFitPlots.C | 19 +- .../HcalCalibAlgos/macros/CalibMonitor.C | 33 ++- Calibration/HcalCalibAlgos/macros/CalibTree.C | 262 +++++++++--------- 4 files changed, 240 insertions(+), 178 deletions(-) diff --git a/Calibration/HcalCalibAlgos/macros/CalibCorr.C b/Calibration/HcalCalibAlgos/macros/CalibCorr.C index 25641e2ab879a..6c8a2c3e12f2d 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibCorr.C +++ b/Calibration/HcalCalibAlgos/macros/CalibCorr.C @@ -64,9 +64,12 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug=false){ return id; } -double puFactor(int type, int ieta, double pmom, double eHcal, double ediff) { +double puFactor(int type, int ieta, double pmom, double eHcal, double ediff, + bool debug=false) { double fac(1.0); + if (debug) std::cout << "Input Type " << type << " ieta " << ieta + << " pmon " << pmom << " E " << eHcal << ":" << ediff; if (type <=2) { double frac = (type == 1) ? 0.02 : 0.03; if (pmom > 0 && ediff > frac*pmom) { @@ -87,50 +90,65 @@ double puFactor(int type, int ieta, double pmom, double eHcal, double ediff) { } } fac = (1.0+a1*(eHcal/pmom)*(ediff/pmom)*(1+a2*(ediff/pmom))); - } else { - int jeta = std::abs(ieta); - double d2p = (ediff/pmom); - const double DELTA_CUT = 0.03; - const int PU_IETA_3 = 25; - if (type == 3) { // 16pu - const double CONST_COR_COEF[4] = { 0.971, 1.008, 0.985, 1.086 }; - const double LINEAR_COR_COEF[4] = { 0, -0.359, -0.251, -0.535 }; - const double SQUARE_COR_COEF[4] = { 0, 0, 0.048, 0.143 }; - const int PU_IETA_1 = 9; - const int PU_IETA_2 = 16; - unsigned icor = (unsigned(jeta >= PU_IETA_1) + - unsigned(jeta >= PU_IETA_2) + - unsigned(jeta >= PU_IETA_3)); - if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + - LINEAR_COR_COEF[icor]*d2p + - SQUARE_COR_COEF[icor]*d2p*d2p); - } else if (type == 4) { // 17pu - const double CONST_COR_COEF[4] = { 0.974, 1.023, 0.989, 1.077 }; - const double LINEAR_COR_COEF[4] = { 0, -0.524, -0.268, -0.584 }; - const double SQUARE_COR_COEF[4] = { 0, 0, 0.053, 0.170 }; - const int PU_IETA_1 = 9; - const int PU_IETA_2 = 18; - unsigned icor = (unsigned(jeta >= PU_IETA_1) + - unsigned(jeta >= PU_IETA_2) + - unsigned(jeta >= PU_IETA_3)); - if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + - LINEAR_COR_COEF[icor]*d2p + - SQUARE_COR_COEF[icor]*d2p*d2p); - } else { // 18pu - const double CONST_COR_COEF[4] = { 0.973, 0.998, 0.992, 0.965 }; - const double LINEAR_COR_COEF[4] = { 0, -0.318, -0.261, -0.406 }; - const double SQUARE_COR_COEF[4] = { 0, 0, 0.047, 0.089 }; - const int PU_IETA_1 = 7; - const int PU_IETA_2 = 16; - unsigned icor = (unsigned(jeta >= PU_IETA_1) + - unsigned(jeta >= PU_IETA_2) + - unsigned(jeta >= PU_IETA_3)); - if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + - LINEAR_COR_COEF[icor]*d2p + - SQUARE_COR_COEF[icor]*d2p*d2p); - } + if (debug) std::cout << " coeff " << a1 << ":" << a2 << " Fac " << fac; + } + } else { + int jeta = std::abs(ieta); + double d2p = (ediff/pmom); + const double DELTA_CUT = 0.03; + const int PU_IETA_3 = 25; + if (type == 3) { // 16pu + const double CONST_COR_COEF[4] = { 0.971, 1.008, 0.985, 1.086 }; + const double LINEAR_COR_COEF[4] = { 0, -0.359, -0.251, -0.535 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.048, 0.143 }; + const int PU_IETA_1 = 9; + const int PU_IETA_2 = 16; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); + if (debug) std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " + << icor << ":" << CONST_COR_COEF[icor] << ":" + << LINEAR_COR_COEF[icor] << ":" + << SQUARE_COR_COEF[icor] << " Fac " << fac; + } else if (type == 4) { // 17pu + const double CONST_COR_COEF[4] = { 0.974, 1.023, 0.989, 1.077 }; + const double LINEAR_COR_COEF[4] = { 0, -0.524, -0.268, -0.584 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.053, 0.170 }; + const int PU_IETA_1 = 9; + const int PU_IETA_2 = 18; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); + if (debug) std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " + << icor << ":" << CONST_COR_COEF[icor] << ":" + << LINEAR_COR_COEF[icor] << ":" + << SQUARE_COR_COEF[icor] << " Fac " << fac; + } else { // 18pu + const double CONST_COR_COEF[4] = { 0.973, 0.998, 0.992, 0.965 }; + const double LINEAR_COR_COEF[4] = { 0, -0.318, -0.261, -0.406 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.047, 0.089 }; + const int PU_IETA_1 = 7; + const int PU_IETA_2 = 16; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); + if (debug) std::cout << " d2p " << d2p << ":" << DELTA_CUT << " coeff " + << icor << ":" << CONST_COR_COEF[icor] << ":" + << LINEAR_COR_COEF[icor] << ":" + << SQUARE_COR_COEF[icor] << " Fac " << fac; } } + if (fac < 0 || fac > 1) fac = 0; + if (debug) std::cout << " Final factor " << fac << std::endl; return fac; } diff --git a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C index 51d28a40f578d..445e726bd47ab 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C +++ b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C @@ -759,7 +759,7 @@ void FitHistExtended(const char* infile, const char* outfile,std::string prefix, if (total > 4) { sprintf (name, "%sOne", hist1->GetName()); TH1D* hist2 = (TH1D*)hist1->Clone(name); - results meanerr = fitOneGauss(hist2,false,debug); + results meanerr = fitOneGauss(hist2,true,debug); value = meanerr.mean; error = meanerr.errmean; width = meanerr.width; werror= meanerr.errwidth; double wbyv = width/value; @@ -1002,8 +1002,23 @@ void PlotHist(const char* infile, std::string prefix, std::string text, double xmin = hist->GetBinLowEdge(1); int nbin = hist->GetNbinsX(); double xmax = hist->GetBinLowEdge(nbin)+hist->GetBinWidth(nbin); + double mean(0), rms(0), total(0); + int kount(0); + for (int k=2; kGetBinContent(k); + double w = hist->GetBinError(k); + mean += (x*w); + rms += (x*x*w); + total += w; + ++kount; + } + mean /= total; + rms /= total; + double error = sqrt(rms-mean*mean)/total; line = new TLine(xmin,p0,xmax,p0); //etamin,1.0,etamax,1.0); - std::cout << xmin << ":" << xmax << ":" << p0 << std::endl; + std::cout << xmin << ":" << xmax << ":" << p0 << " Mean " << nbin + << ":" << kount << ":" << total <<":" << mean << ":" << rms + << ":" << error << std::endl; line->SetLineWidth(2); line->SetLineStyle(2); line->Draw("same"); diff --git a/Calibration/HcalCalibAlgos/macros/CalibMonitor.C b/Calibration/HcalCalibAlgos/macros/CalibMonitor.C index 8337df651e44d..3fa205f5dd422 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibMonitor.C +++ b/Calibration/HcalCalibAlgos/macros/CalibMonitor.C @@ -798,6 +798,7 @@ void CalibMonitor::Loop() { std::vector kounts(kp1,0); std::vector kount50(20,0); for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; @@ -1100,9 +1101,11 @@ bool CalibMonitor::goodTrack(double& eHcal, double &cuti, bool debug) { } correctEnergy(eHcal); select = ((t_qltyFlag) && (t_selectTk) && (t_hmaxNearP < cut) && - (t_eMipDR < 1.0)); + (t_eMipDR < 1.0) && (eHcal > 0.001)); if (debug) { - std::cout << " output " << eHcal << ":" << cut << ":" << select<< std::endl; + std::cout << " output " << select << " Based on " << t_qltyFlag << ":" + << t_selectTk << ":" << t_hmaxNearP << ":" << cut << ":" + << t_eMipDR << ":" << eHcal << std::endl; } return select; } @@ -1263,7 +1266,7 @@ void CalibMonitor::savePlot(const std::string& theName, bool append, bool all) { } void CalibMonitor::correctEnergy(double& eHcal) { - + bool debug(false); double pmom = (useGen_ && (t_gentrackP>0)) ? t_gentrackP : t_p; if ((corrPU_ < 0) && (pmom > 0)) { double ediff = (t_eHcal30-t_eHcal10); @@ -1286,7 +1289,13 @@ void CalibMonitor::correctEnergy(double& eHcal) { } ediff = (Etot3-Etot1); } - double fac = puFactor(-corrPU_,t_ieta,pmom,eHcal,ediff); + double fac = puFactor(-corrPU_,t_ieta,pmom,eHcal,ediff,false); + if (debug) { + double fac1 = puFactor(-corrPU_,t_ieta,pmom,eHcal,ediff,true); + double fac2 = puFactor(2,t_ieta,pmom,eHcal,ediff,true); + std::cout << "PU Factor for " << -corrPU_ << " = " << fac1 << "; for 2 = " + << fac2 << std::endl; + } eHcal *= fac; } else if (corrPU_ > 0) { eHcal = puFactorRho(corrPU_,t_ieta,t_rhoh,eHcal); @@ -2485,7 +2494,17 @@ void CalibPlotProperties::Loop() { if (plotHists_) { h_nvtx->Fill(t_nVtx); - if ((std::fabs(rat-1)<0.15) && (kp == kp50) && + bool bad(false); + for (unsigned int k=0; ksize(); ++k) { + unsigned int id = truncateId((*t_DetIds)[k],truncateFlag_,false); + double cfac = corrFactor_->getCorr(id); + if (cFactor_ != 0) + cfac *= cFactor_->getCorr(t_Run,(*t_DetIds)[k]); + double ener = cfac*(*t_HitEnergies)[k]; + if (corrPU_) correctEnergy(ener); + if (ener < 0.001) bad = true; + } + if ((!bad) && (std::fabs(rat-1)<0.15) && (kp == kp50) && ((std::abs(t_ieta) < 15) || (std::abs(t_ieta) > 17))) { float weight = (dataMC_ ? t_EventWeight : t_EventWeight*puweight(t_nVtx)); @@ -2493,7 +2512,7 @@ void CalibPlotProperties::Loop() { sel += weight; std::vector bv(7,0.0f), ev(7,0.0f); std::vector bnrec(7,0), enrec(7,0); - double eb(0), ee(0); + double eb(0), ee(0); for (unsigned int k=0; ksize(); ++k) { unsigned int id = truncateId((*t_DetIds)[k],truncateFlag_,false); double cfac = corrFactor_->getCorr(id); @@ -2559,7 +2578,7 @@ bool CalibPlotProperties::goodTrack(double& eHcal, double &cuti, bool debug) { } correctEnergy(eHcal); select = ((t_qltyFlag) && (t_selectTk) && (t_hmaxNearP < cut) && - (t_eMipDR < 100.0)); + (t_eMipDR < 100.0) && (eHcal > 0.001)); if (debug) { std::cout << " output " << eHcal << ":" << cut << ":" << select<< std::endl; } diff --git a/Calibration/HcalCalibAlgos/macros/CalibTree.C b/Calibration/HcalCalibAlgos/macros/CalibTree.C index 45e7600f7234a..6f03419354c05 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibTree.C +++ b/Calibration/HcalCalibAlgos/macros/CalibTree.C @@ -128,6 +128,19 @@ class CalibTree { public : + struct myEntry { + myEntry (int k=0, double f0=0, double f1=0, + double f2=0) : kount(k), fact0(f0), fact1(f1), fact2(f2) {} + int kount; + double fact0, fact1, fact2; + }; + + struct energyCalor { + energyCalor (double e1=0, double e2=0, + double e3=0) : Etot(e1), Etot2(e2), ehcal(e3) {} + double Etot, Etot2, ehcal; + }; + CalibTree(const char *dupFileName, const char* rcorFileName, int truncateFlag, bool useMean, int runlo, int runhi, int phimin, int phimax, int zside, int nvxlo, int nvxhi, int sysmode, int rbx, int puCorr, @@ -152,19 +165,13 @@ public : bool useWeight, double fraction, bool debug); void fitPol0(TH1D* hist, bool debug); void highEtaFactors(int ietaMax, bool debug); + energyCalor energyHcal(double pmom, bool final); TChain *fChain; //!pointer to the analyzed TTree or TChain Int_t fCurrent;//!current Tree number in a TChain TH1D *h_pbyE, *h_cvg; TProfile *h_Ebyp_bfr, *h_Ebyp_aftr; - struct myEntry { - myEntry (int k=0, double f0=0, double f1=0, - double f2=0) : kount(k), fact0(f0), fact1(f1), fact2(f2) {} - int kount; - double fact0, fact1, fact2; - }; - private: // Declaration of leaf types @@ -660,112 +667,65 @@ Double_t CalibTree::Loop(int loop, TFile *fout, bool useweight, int nMin, double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p; if (goodTrack()) { ++ntkgood; - double Etot(0), Etot2(0); - for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { - if (selectPhi((*t_DetIds)[idet])) { - unsigned int id = (*t_DetIds)[idet]; - double hitEn(0); - unsigned int detid = truncateId(id,truncateFlag_,false); - if (Cprev.find(detid) != Cprev.end()) - hitEn = Cprev[detid].first * (*t_HitEnergies)[idet]; - else - hitEn = (*t_HitEnergies)[idet]; - if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); - Etot += hitEn; - Etot2 += ((*t_HitEnergies)[idet]); - } - } - // Now the outer cone - double Etot1(0), Etot3(0); - if (t_DetIds1 != 0 && t_DetIds3 != 0) { - for (unsigned int idet=0; idet<(*t_DetIds1).size(); idet++) { - if (selectPhi((*t_DetIds1)[idet])) { - unsigned int id = (*t_DetIds1)[idet]; - unsigned int detid = truncateId(id,truncateFlag_,false); - double hitEn(0); - if (Cprev.find(detid) != Cprev.end()) - hitEn = Cprev[detid].first * (*t_HitEnergies1)[idet]; - else - hitEn = (*t_HitEnergies1)[idet]; - if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); - Etot1 += hitEn; - } + CalibTree::energyCalor en = energyHcal(pmom, true); + double evWt = (useweight) ? t_EventWeight : 1.0; + if (en.ehcal > 0.001) { + double pufac = (en.Etot > 0) ? (en.ehcal/en.Etot) : 1.0; + double ratio = en.ehcal/(pmom-t_eMipDR); + if (debug) std::cout << " Weights " << evWt << ":" << pufac + << " Energy " << en.Etot2 << ":" << en.Etot << ":" + << pmom << ":" << t_eMipDR << ":" << t_eHcal << ":" + << en.ehcal << " ratio " << ratio << std::endl; + if (loop==0) { + h_pbyE->Fill(ratio, evWt); + h_Ebyp_bfr->Fill(t_ieta, ratio, evWt); } - for (unsigned int idet=0; idet<(*t_DetIds3).size(); idet++) { - if (selectPhi((*t_DetIds3)[idet])) { - unsigned int id = (*t_DetIds3)[idet]; - unsigned int detid = truncateId(id,truncateFlag_,false); - double hitEn(0); - if (Cprev.find(detid) != Cprev.end()) - hitEn = Cprev[detid].first * (*t_HitEnergies3)[idet]; - else - hitEn = (*t_HitEnergies3)[idet]; - if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); - Etot3 += hitEn; - } + if (last){ + h_Ebyp_aftr->Fill(t_ieta, ratio, evWt); } - } - eHcalDelta_ = Etot3-Etot1; - double evWt = (useweight) ? t_EventWeight : 1.0; - // PU correction only for loose isolation cut - double ehcal = ((puCorr_ == 0) ? Etot : - ((puCorr_ < 0) ? (Etot*puFactor(-puCorr_,t_ieta,pmom,Etot,eHcalDelta_)) : - puFactorRho(puCorr_,t_ieta,t_rhoh,Etot))); - double pufac = (Etot > 0) ? (ehcal/Etot) : 1.0; - double ratio = ehcal/(pmom-t_eMipDR); - if (debug) std::cout << " Weights " << evWt << ":" << pufac << " Energy " - << Etot2 << ":" << Etot << ":" << pmom << ":" - << t_eMipDR << ":" << t_eHcal << ":" << ehcal - << " ratio " << ratio << std::endl; - if (loop==0) { - h_pbyE->Fill(ratio, evWt); - h_Ebyp_bfr->Fill(t_ieta, ratio, evWt); - } - if (last){ - h_Ebyp_aftr->Fill(t_ieta, ratio, evWt); - } - bool l1c(true); - if (applyL1Cut != 0) l1c = ((t_mindR1 >= l1Cut) || - ((applyL1Cut == 1) && (t_DataType == 1))); - if ((rmin >=0 && ratio > rmin) && (rmax >= 0 && ratio < rmax) && l1c) { - for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { - if (selectPhi((*t_DetIds)[idet])) { - unsigned int id = (*t_DetIds)[idet]; - unsigned int detid = truncateId(id,truncateFlag_,false); - double hitEn=0.0; - if (debug) { - std::cout << "idet " << idet << " detid/hitenergy : " - << std::hex << (*t_DetIds)[idet] << ":" << detid - << "/" << (*t_HitEnergies)[idet] << std::endl; - } - if (Cprev.find(detid) != Cprev.end()) - hitEn = Cprev[detid].first * (*t_HitEnergies)[idet]; - else - hitEn = (*t_HitEnergies)[idet]; - if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); - double Wi = evWt * hitEn/Etot; - double Fac = (inverse) ? (ehcal/(pmom-t_eMipDR)) : - ((pmom-t_eMipDR)/ehcal); - double Fac2= Wi*Fac*Fac; - TH1D* hist(0); - std::map::const_iterator itr = histos.find(detid); - if (itr != histos.end()) hist = itr->second; - if (debug) { - std::cout << "Det Id " << std::hex << detid << std::dec - << " " << hist << std::endl; - } - if (hist != 0) hist->Fill(Fac, Wi);//////histola - Fac *= Wi; - if (SumW.find(detid) != SumW.end() ) { - Wi += SumW[detid].fact0; - Fac += SumW[detid].fact1; - Fac2+= SumW[detid].fact2; - int kount = SumW[detid].kount + 1; - SumW[detid] = myEntry(kount,Wi,Fac,Fac2); - nTrks[detid] += evWt; - } else { - SumW.insert(std::pair(detid,myEntry(1,Wi,Fac,Fac2))); - nTrks.insert(std::pair(detid, evWt)); + bool l1c(true); + if (applyL1Cut != 0) l1c = ((t_mindR1 >= l1Cut) || + ((applyL1Cut == 1) && (t_DataType == 1))); + if ((rmin >=0 && ratio > rmin) && (rmax >= 0 && ratio < rmax) && l1c) { + for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { + if (selectPhi((*t_DetIds)[idet])) { + unsigned int id = (*t_DetIds)[idet]; + unsigned int detid = truncateId(id,truncateFlag_,false); + double hitEn=0.0; + if (debug) { + std::cout << "idet " << idet << " detid/hitenergy : " + << std::hex << (*t_DetIds)[idet] << ":" << detid + << "/" << (*t_HitEnergies)[idet] << std::endl; + } + if (Cprev.find(detid) != Cprev.end()) + hitEn = Cprev[detid].first * (*t_HitEnergies)[idet]; + else + hitEn = (*t_HitEnergies)[idet]; + if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); + double Wi = evWt * hitEn/en.Etot; + double Fac = (inverse) ? (en.ehcal/(pmom-t_eMipDR)) : + ((pmom-t_eMipDR)/en.ehcal); + double Fac2= Wi*Fac*Fac; + TH1D* hist(0); + std::map::const_iterator itr = histos.find(detid); + if (itr != histos.end()) hist = itr->second; + if (debug) { + std::cout << "Det Id " << std::hex << detid << std::dec + << " " << hist << std::endl; + } + if (hist != 0) hist->Fill(Fac, Wi);//////histola + Fac *= Wi; + if (SumW.find(detid) != SumW.end() ) { + Wi += SumW[detid].fact0; + Fac += SumW[detid].fact1; + Fac2+= SumW[detid].fact2; + int kount = SumW[detid].kount + 1; + SumW[detid] = myEntry(kount,Wi,Fac,Fac2); + nTrks[detid] += evWt; + } else { + SumW.insert(std::pair(detid,myEntry(1,Wi,Fac,Fac2))); + nTrks.insert(std::pair(detid, evWt)); + } } } } @@ -1099,22 +1059,12 @@ void CalibTree::makeplots(double rmin, double rmax, int ietaMax, if (std::find(entries.begin(), entries.end(), jentry) != entries.end()) break; nb = fChain->GetEntry(jentry); nbytes += nb; if (goodTrack()) { - double Etot(0); - for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { - double hitEn(0); - unsigned int id = (*t_DetIds)[idet]; - unsigned int detid = truncateId(id,truncateFlag_,false); - if (Cprev.find(detid) != Cprev.end()) - hitEn = Cprev[detid].first * (*t_HitEnergies)[idet]; - else - hitEn = (*t_HitEnergies)[idet]; - if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); - Etot += hitEn; - } + double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p; + CalibTree::energyCalor en1 = energyHcal(pmom, false); + CalibTree::energyCalor en2 = energyHcal(pmom, true); double evWt = (useweight) ? t_EventWeight : 1.0; - double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p; - double ratioi = t_eHcal/(pmom-t_eMipDR); - double ratiof = Etot/(pmom-t_eMipDR); + double ratioi = en1.ehcal/(pmom-t_eMipDR); + double ratiof = en2.ehcal/(pmom-t_eMipDR); if (t_ieta >= -ietaMax && t_ieta <= ietaMax && t_ieta != 0) { if (ratioi>=rmin && ratioi<=rmax) { histos[0].first->Fill(ratioi,evWt); @@ -1215,3 +1165,63 @@ void CalibTree::highEtaFactors(int ietaMax, bool debug) { } } } + +CalibTree::energyCalor CalibTree::energyHcal(double pmom, bool final) { + + double etot = t_eHcal; + double etot2 = t_eHcal; + double ediff = (t_eHcal30 - t_eHcal10); + if (final) { + etot = etot2 = 0; + for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { + if (selectPhi((*t_DetIds)[idet])) { + unsigned int id = (*t_DetIds)[idet]; + double hitEn(0); + unsigned int detid = truncateId(id,truncateFlag_,false); + if (Cprev.find(detid) != Cprev.end()) + hitEn = Cprev[detid].first * (*t_HitEnergies)[idet]; + else + hitEn = (*t_HitEnergies)[idet]; + if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); + etot += hitEn; + etot2 += ((*t_HitEnergies)[idet]); + } + } + // Now the outer cone + double etot1(0), etot3(0); + if (t_DetIds1 != 0 && t_DetIds3 != 0) { + for (unsigned int idet=0; idet<(*t_DetIds1).size(); idet++) { + if (selectPhi((*t_DetIds1)[idet])) { + unsigned int id = (*t_DetIds1)[idet]; + unsigned int detid = truncateId(id,truncateFlag_,false); + double hitEn(0); + if (Cprev.find(detid) != Cprev.end()) + hitEn = Cprev[detid].first * (*t_HitEnergies1)[idet]; + else + hitEn = (*t_HitEnergies1)[idet]; + if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); + etot1 += hitEn; + } + } + for (unsigned int idet=0; idet<(*t_DetIds3).size(); idet++) { + if (selectPhi((*t_DetIds3)[idet])) { + unsigned int id = (*t_DetIds3)[idet]; + unsigned int detid = truncateId(id,truncateFlag_,false); + double hitEn(0); + if (Cprev.find(detid) != Cprev.end()) + hitEn = Cprev[detid].first * (*t_HitEnergies3)[idet]; + else + hitEn = (*t_HitEnergies3)[idet]; + if (cFactor_) hitEn *= cFactor_->getCorr(t_Run,id); + etot3 += hitEn; + } + } + } + ediff = etot3-etot1; + } + // PU correction only for loose isolation cut + double ehcal = ((puCorr_ == 0) ? etot : + ((puCorr_ < 0) ? (etot*puFactor(-puCorr_,t_ieta,pmom,etot,ediff)) : + puFactorRho(puCorr_,t_ieta,t_rhoh,etot))); + return CalibTree::energyCalor(etot,etot2,ehcal); +} From 33902118dd338d05d5630cc16c0b9d99f5696723 Mon Sep 17 00:00:00 2001 From: Francesco Fiori Date: Mon, 8 Apr 2019 20:16:48 +0200 Subject: [PATCH 507/686] defining DQM auto config for rereco --- DQMOffline/Configuration/python/autoDQM.py | 117 ++++++++++++++------- 1 file changed, 78 insertions(+), 39 deletions(-) diff --git a/DQMOffline/Configuration/python/autoDQM.py b/DQMOffline/Configuration/python/autoDQM.py index 1eba20f482c75..e094826b426fe 100644 --- a/DQMOffline/Configuration/python/autoDQM.py +++ b/DQMOffline/Configuration/python/autoDQM.py @@ -1,79 +1,117 @@ -autoDQM = { 'common' : ['DQMOfflineCommon+@L1TMon', +autoDQM = { 'common': ['DQMOfflineCommon+@L1TMon', 'PostDQMOffline', 'DQMHarvestCommon+DQMCertCommon+@L1TMon'], - 'commonSiStripZeroBias' : ['DQMOfflineCommonSiStripZeroBias', - 'PostDQMOffline', - 'DQMHarvestCommonSiStripZeroBias+DQMCertCommon'], - 'trackingOnlyDQM' : ['DQMOfflineTracking', - 'PostDQMOffline', - 'DQMHarvestTracking'], + + 'commonSiStripZeroBias': ['DQMOfflineCommonSiStripZeroBias', + 'PostDQMOffline', + 'DQMHarvestCommonSiStripZeroBias+DQMCertCommon'], + + 'trackingOnlyDQM': ['DQMOfflineTracking', + 'PostDQMOffline', + 'DQMHarvestTracking'], + 'pixelTrackingOnlyDQM': ['DQMOfflinePixelTracking', 'PostDQMOffline', 'DQMHarvestPixelTracking'], + 'outerTracker': ['DQMOuterTracker', 'PostDQMOffline', 'DQMHarvestOuterTracker'], + 'lumi': ['DQMOfflineLumi', 'PostDQMOffline', 'DQMHarvestLumi'], + 'muon': ['DQMOfflineMuon', 'PostDQMOffline', 'DQMHarvestMuon+DQMCertMuon'], - 'hcal': ['DQMOfflineHcal', - 'PostDQMOffline', - 'DQMHarvestHcal'], + + 'hcal': ['DQMOfflineHcal', + 'PostDQMOffline', + 'DQMHarvestHcal'], + 'hcal2': ['HcalDQMOfflineSequence', 'PostDQMOffline', 'HcalDQMOfflinePostProcessor'], - 'jetmet': ['DQMOfflineJetMET', + + 'jetmet': ['DQMOfflineJetMET', + 'PostDQMOffline', + 'DQMHarvestJetMET+DQMCertJetMET'], + + 'ecal': ['DQMOfflineEcal', + 'PostDQMOffline', + 'DQMHarvestEcal+DQMCertEcal'], + + 'egamma': ['DQMOfflineEGamma', + 'PostDQMOffline', + 'DQMHarvestEGamma'], + + 'btag': ['DQMOfflineBTag', + 'PostDQMOffline', + 'DQMHarvestBTag'], + + 'L1TMon': ['DQMOfflineL1TMonitoring', + 'PostDQMOffline', + 'DQMHarvestL1TMonitoring'], + + 'L1TEgamma': ['DQMOfflineL1TEgamma', + 'PostDQMOffline', + 'DQMHarvestL1TEgamma'], + + 'L1TMuon': ['DQMOfflineL1TMuon', 'PostDQMOffline', - 'DQMHarvestJetMET+DQMCertJetMET'], - 'ecal': ['DQMOfflineEcal', - 'PostDQMOffline', - 'DQMHarvestEcal+DQMCertEcal'], - 'egamma': ['DQMOfflineEGamma', + 'DQMHarvestL1TMuon'], + + 'HLTMon': ['HLTMonitoring', + 'PostDQMOffline', + 'HLTMonitoringClient'], + + 'HLTMonPA': ['HLTMonitoringPA', 'PostDQMOffline', 'HLTMonitoringClientPA'], + + 'express': ['@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal', + 'PostDQMOffline', + '@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal'], + + 'allForPrompt': ['@common+@muon+@hcal+@jetmet+@ecal+@egamma', 'PostDQMOffline', - 'DQMHarvestEGamma'], - 'btag': ['DQMOfflineBTag', - 'PostDQMOffline', - 'DQMHarvestBTag'], - 'L1TMon': ['DQMOfflineL1TMonitoring', - 'PostDQMOffline', - 'DQMHarvestL1TMonitoring'], - 'L1TEgamma': ['DQMOfflineL1TEgamma', - 'PostDQMOffline', - 'DQMHarvestL1TEgamma'], - 'L1TMuon': ['DQMOfflineL1TMuon', - 'PostDQMOffline', - 'DQMHarvestL1TMuon'], - 'HLTMon': ['HLTMonitoring', - 'PostDQMOffline', - 'HLTMonitoringClient'], - 'HLTMonPA' : ['HLTMonitoringPA', 'PostDQMOffline', 'HLTMonitoringClientPA'], - 'express': ['@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal', - 'PostDQMOffline', - '@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal'], - 'allForPrompt': ['@common+@muon+@hcal+@jetmet+@ecal+@egamma', - 'PostDQMOffline', - '@common+@muon+@hcal+@jetmet+@ecal+@egamma'], + '@common+@muon+@hcal+@jetmet+@ecal+@egamma'], + + 'rerecoCommon': ['@common+@muon+@hcal+@jetmet+@ecal+@egamma+@L1TMuon+@L1TEgamma', + 'PostDQMOffline', + '@common+@muon+@hcal+@jetmet+@ecal+@egamma+@L1TMuon+@L1TEgamma'], + + 'rerecoSingleMuon': ['@common+@muon+@hcal+@jetmet+@ecal+@egamma+@lumi+@L1TMuon+@L1TEgamma', + 'PostDQMOffline', + '@common+@muon+@hcal+@jetmet+@ecal+@egamma+@lumi+@L1TMuon+@L1TEgamma'], + + 'rerecoZeroBias' : ['@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal+@egamma+@L1TMuon+@L1TEgamma', + 'PostDQMOffline', + '@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal+@egamma+@L1TMuon+@L1TEgamma'], + 'miniAODDQM': ['DQMOfflineMiniAOD', 'PostDQMOfflineMiniAOD', 'DQMHarvestMiniAOD'], + 'nanoAODDQM': ['DQMOfflineNanoAOD', 'PostDQMOffline', 'DQMHarvestNanoAOD'], + 'standardDQM': ['DQMOffline', 'PostDQMOffline', 'dqmHarvesting'], + 'ExtraHLT': ['DQMOfflineExtraHLT', 'PostDQMOffline', 'dqmHarvestingExtraHLT'], + 'standardDQMFakeHLT': ['DQMOfflineFakeHLT', 'PostDQMOffline', 'dqmHarvestingFakeHLT'], + 'liteDQMHI': ['liteDQMOfflineHeavyIons', 'PostDQMOffline', 'dqmHarvesting'], + 'none': ['DQMNone', 'PostDQMOffline', 'DQMNone'], @@ -84,3 +122,4 @@ for i in [0,2]: autoDQM['phase2'][i] = '+'.join([autoDQM[m][i] for m in _phase2_allowed]) autoDQM['phase2'][1] = 'PostDQMOffline' + From 07a0076a5fea3aa7899885db3993225d2c5b3bee Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 8 Apr 2019 13:23:07 -0500 Subject: [PATCH 508/686] Explicitly cast values in array used in FWHeatmapProxyBuilderTemplate This fixes a gcc 9 compilation error. --- .../interface/FWHeatmapProxyBuilderTemplate.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h index 6a4861f7ac270..3b2f8e0bb6553 100644 --- a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h +++ b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h @@ -19,6 +19,7 @@ // // system include files +#include // user include files #include "Fireworks/Core/interface/FWSimpleProxyBuilder.h" @@ -50,9 +51,17 @@ class FWHeatmapProxyBuilderTemplate : public FWSimpleProxyBuilder { static constexpr uint8_t gradient_steps = 9; static constexpr uint8_t gradient[3][gradient_steps] = { - {0.2082*255, 0.0592*255, 0.0780*255, 0.0232*255, 0.1802*255, 0.5301*255, 0.8186*255, 0.9956*255, 0.9764*255}, - {0.1664*255, 0.3599*255, 0.5041*255, 0.6419*255, 0.7178*255, 0.7492*255, 0.7328*255, 0.7862*255, 0.9832*255}, - {0.5293*255, 0.8684*255, 0.8385*255, 0.7914*255, 0.6425*255, 0.4662*255, 0.3499*255, 0.1968*255, 0.0539*255} + {static_cast(0.2082*255), static_cast(0.0592*255), static_cast(0.0780*255), + static_cast(0.0232*255), static_cast(0.1802*255), static_cast(0.5301*255), + static_cast(0.8186*255), static_cast(0.9956*255), static_cast(0.9764*255)}, + + {static_cast(0.1664*255), static_cast(0.3599*255), static_cast(0.5041*255), + static_cast(0.6419*255), static_cast(0.7178*255), static_cast(0.7492*255), + static_cast(0.7328*255), static_cast(0.7862*255), static_cast(0.9832*255)}, + + {static_cast(0.5293*255), static_cast(0.8684*255), static_cast(0.8385*255), + static_cast(0.7914*255), static_cast(0.6425*255), static_cast(0.4662*255), + static_cast(0.3499*255), static_cast(0.1968*255), static_cast(0.0539*255)} }; const T& modelData(int index) { return *reinterpret_cast(m_helper.offsetObject(item()->modelData(index))); } From 2568492775fa35fc1550b83ff98285ea4627bf6f Mon Sep 17 00:00:00 2001 From: Cristina Mantilla Date: Mon, 8 Apr 2019 20:53:21 +0200 Subject: [PATCH 509/686] fix variable names and comments --- .../interface/PixelCPEClusterRepair.h | 4 ++-- .../src/PixelCPEClusterRepair.cc | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h index 332f06d35caf3..6337e867aacf9 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h @@ -136,10 +136,10 @@ class PixelCPEClusterRepair : public PixelCPEBase int subdet_; int layer_; }; - std::vector Recommend2D_; + std::vector recommend2D_; // run on damaged hits or not - bool RunDamagedClusters_; + bool runDamagedClusters_; }; #endif diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 32ef23509b1f9..cea8787eda0ee 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -94,18 +94,18 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, maxSizeMismatchInY_ = conf.getParameter("MaxSizeMismatchInY"); minChargeRatio_ = conf.getParameter("MinChargeRatio"); - // read sub-detectors to recommend 2D + // read sub-detectors and apply rule to recommend 2D // can be: // XYX (XYZ = PXB, PXE) // XYZ n (XYZ as above, n = layer, wheel or disk = 1 .. 6 ;) - std::vector str_Recommend2D = conf.getParameter >("Recommend2D"); - Recommend2D_.reserve(str_Recommend2D.size()); - for (std::vector::const_iterator it = str_Recommend2D.begin(), ed = str_Recommend2D.end(); it != ed; ++it) { - Recommend2D_.push_back(Rule(*it)); + std::vector str_recommend2D = conf.getParameter >("Recommend2D"); + recommend2D_.reserve(str_recommend2D.size()); + for (unsigned int i=0; i("RunDamagedClusters")?conf.getParameter("RunDamagedClusters"):false; + runDamagedClusters_ = conf.existsAs("RunDamagedClusters")?conf.getParameter("RunDamagedClusters"):false; } //----------------------------------------------------------------------------- @@ -193,7 +193,6 @@ PixelCPEClusterRepair::localPosition(DetParam const & theDetParam, ClusterParam else ID1 = ID2 = forwardTemplateID_ ; // forward } - //cout << "PixelCPEClusterRepair : ID1 = " << ID1 << endl; // &&& PM, note for later: PixelCPEBase calculates minInX,Y, and maxInX,Y // Why can't we simply use that and save time with row_offset, col_offset @@ -546,8 +545,8 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus DetId id = (theDetParam.theDet->geographicalId()); bool recommend = false; - for (std::vector::const_iterator itr = Recommend2D_.begin(), edr = Recommend2D_.end(); itr != edr; ++itr) { - recommend = itr->recommend(id, ttopo_); + for (unsigned int i=0; i Date: Tue, 9 Apr 2019 05:36:18 +0200 Subject: [PATCH 510/686] add fillDescriptions method for CPE CR --- .../PixelCPEClusterRepairESProducer.h | 3 +++ .../PixelCPEClusterRepairESProducer.cc | 22 +++++++++++++++++++ .../src/PixelCPEClusterRepair.cc | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepairESProducer.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepairESProducer.h index 7dd87dbcbbc62..599ce19a74895 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepairESProducer.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepairESProducer.h @@ -3,6 +3,8 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h" #include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h" #include @@ -11,6 +13,7 @@ class PixelCPEClusterRepairESProducer: public edm::ESProducer{ public: PixelCPEClusterRepairESProducer(const edm::ParameterSet & p); ~PixelCPEClusterRepairESProducer() override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); std::unique_ptr produce(const TkPixelCPERecord &); private: edm::ParameterSet pset_; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc index b6355b431645e..bf5aad6a12349 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc @@ -37,6 +37,28 @@ PixelCPEClusterRepairESProducer::PixelCPEClusterRepairESProducer(const edm::Para PixelCPEClusterRepairESProducer::~PixelCPEClusterRepairESProducer() {} +void PixelCPEClusterRepairESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // templates2 + edm::ParameterSetDescription desc; + desc.add("DoLorentz", true); + desc.add("DoCosmics", false); + desc.add("LoadTemplatesFromDB", true); + desc.add("RunDamagedClusters", false); + desc.add("ComponentName", "PixelCPEClusterRepair"); + desc.add("MinChargeRatio", 0.8); + desc.add("MaxSizeMismatchInY", 0.3); + desc.add("Alpha2Order", true); + desc.add>("Recommend2D", { + "PXB 2", + "PXB 3", + "PXB 4", + }); + desc.add("ClusterProbComputationFlag", 0); + desc.add("speed", -2); + desc.add("UseClusterSplitter", false); + descriptions.add("templates2", desc); +} + std::unique_ptr PixelCPEClusterRepairESProducer::produce(const TkPixelCPERecord & iRecord){ diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index cea8787eda0ee..c6cf9de701921 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -105,7 +105,7 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, } // run CR on damaged clusters (and not only on edge hits) - runDamagedClusters_ = conf.existsAs("RunDamagedClusters")?conf.getParameter("RunDamagedClusters"):false; + runDamagedClusters_ = conf.getParameter("RunDamagedClusters"); } //----------------------------------------------------------------------------- From 76a045a0bf2e95fa4af0f5144976cc6ee26d3e9c Mon Sep 17 00:00:00 2001 From: Pierre Depasse Date: Tue, 9 Apr 2019 08:11:06 +0200 Subject: [PATCH 511/686] ECAL : automatic Ecal Preshower Gain Switching in DB, by O2O, for 4 ES hlt tags --- .../PopConESTransitionSourceHandler.h | 154 ++++++++++++++++++ .../plugins/ESGainPopConTransitionAnalyzer.cc | 9 + ...rcalibConstantsPopConTransitionAnalyzer.cc | 9 + ...RecHitRatioCutsPopConTransitionAnalyzer.cc | 9 + ...meSampleWeightsPopConTransitionAnalyzer.cc | 9 + .../ESGainPopConTransitionAnalyzer_cfg.py | 43 +++++ ...ibConstantsPopConTransitionAnalyzer_cfg.py | 43 +++++ ...itRatioCutsPopConTransitionAnalyzer_cfg.py | 43 +++++ ...mpleWeightsPopConTransitionAnalyzer_cfg.py | 43 +++++ CondTools/Ecal/python/conddb_init.py | 15 ++ 10 files changed, 377 insertions(+) create mode 100644 CondTools/Ecal/interface/PopConESTransitionSourceHandler.h create mode 100644 CondTools/Ecal/plugins/ESGainPopConTransitionAnalyzer.cc create mode 100644 CondTools/Ecal/plugins/ESIntercalibConstantsPopConTransitionAnalyzer.cc create mode 100644 CondTools/Ecal/plugins/ESRecHitRatioCutsPopConTransitionAnalyzer.cc create mode 100644 CondTools/Ecal/plugins/ESTimeSampleWeightsPopConTransitionAnalyzer.cc create mode 100644 CondTools/Ecal/python/ESGainPopConTransitionAnalyzer_cfg.py create mode 100644 CondTools/Ecal/python/ESIntercalibConstantsPopConTransitionAnalyzer_cfg.py create mode 100644 CondTools/Ecal/python/ESRecHitRatioCutsPopConTransitionAnalyzer_cfg.py create mode 100644 CondTools/Ecal/python/ESTimeSampleWeightsPopConTransitionAnalyzer_cfg.py diff --git a/CondTools/Ecal/interface/PopConESTransitionSourceHandler.h b/CondTools/Ecal/interface/PopConESTransitionSourceHandler.h new file mode 100644 index 0000000000000..0b88a46aea504 --- /dev/null +++ b/CondTools/Ecal/interface/PopConESTransitionSourceHandler.h @@ -0,0 +1,154 @@ +#ifndef PopConBTransitionSourceHandler_H +#define PopConBTransitionSourceHandler_H + +#include "CondCore/CondDB/interface/ConnectionPool.h" +#include "CondCore/CondDB/interface/IOVProxy.h" +#include "CondCore/PopCon/interface/PopConSourceHandler.h" +#include "CondFormats/RunInfo/interface/RunInfo.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include + +namespace popcon { + template + class PopConESTransitionSourceHandler: public PopConSourceHandler { + public: + PopConESTransitionSourceHandler( edm::ParameterSet const & pset ): + m_run( pset.getParameter( "ESTransition" ).getParameter( "runNumber" ) ), + // m_currentThreshold( pset.getParameter( "ESTransition" ).getUntrackedParameter( "currentThreshold", 18000. ) ), + m_tagForRunInfo( pset.getParameter( "ESTransition" ).getParameter( "tagForRunInfo" ) ), + m_ESGain( pset.getParameter( "ESTransition" ).getParameter( "ESGain" ) ), + m_tagForLowGain( pset.getParameter( "ESTransition" ).getParameter( "ESLowGainTag" ) ), + m_tagForHighGain( pset.getParameter( "ESTransition" ).getParameter( "ESHighGainTag" ) ), + m_connectionString( pset.getParameter( "ESTransition" ).getParameter( "connect" ) ), + m_connectionPset( pset.getParameter( "ESTransition" ).getParameter( "DBParameters" ) ) { + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler:" << __func__ << "]: " + << "Initialising Connection Pool" << std::endl; + m_connection.setParameters( m_connectionPset ); + m_connection.configure(); + } + + ~PopConESTransitionSourceHandler() override {} + + std::string id() const final { return std::string( "PopConESTransitionSourceHandler" ); } + + bool checkLowGain() { + //the output boolean is set to true as default + bool isLowGain = true; + cond::persistency::Session& session = PopConSourceHandler::dbSession(); + //reading RunInfo from Conditions + cond::persistency::TransactionScope trans( session.transaction() ); + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "Loading tag for RunInfo " << m_tagForRunInfo + << " and IOV valid for run number: " << m_run << std::endl; + cond::persistency::IOVProxy iov = session.readIov( m_tagForRunInfo ); + cond::Iov_t currentIov = *(iov.find( m_run )); + LogDebug( "PopConESTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << m_tagForRunInfo + << " with size: "<< iov.loadedSize() + << ", IOV valid for run number " << m_run << " starting from: " << currentIov.since + << ", with corresponding payload hash: " << currentIov.payloadId << std::endl; + /* accessing the average magnet current for the run + double current_default = -1; + double avg_current = current_default; + avg_current = session.fetchPayload( currentIov.payloadId )->m_avg_current; + LogDebug( "PopConESTransitionSourceHandler" ) << "Comparing value of magnet current: " << avg_current << " A for run: " << m_run + << " with the corresponding threshold: "<< m_currentThreshold << " A." << std::endl; + comparing the magnet current with the user defined threshold + if( avg_current != current_default && avg_current <= m_currentThreshold ) isLowGain = false; + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "The magnet was " << ( isBOn ? "ON" : "OFF" ) + << " during run " << m_run << std::endl; */ + if (m_ESGain=="HIGH") { + isLowGain=false;} + else { + isLowGain = true;} + trans.close(); + return isLowGain; + } + + virtual void getObjectsForESTransition( bool isLowGain ) { + //reading payloads for 0T and 3.8T from Conditions + cond::persistency::Session& session = PopConSourceHandler::dbSession(); + cond::persistency::TransactionScope trans( session.transaction() ); + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "Loading tag for ES " << ( isLowGain ? "LowGain" : "HighGain" ) << ": " + << ( isLowGain ? m_tagForLowGain : m_tagForHighGain ) + << " and IOV valid for run number: " << m_run << std::endl; + cond::persistency::IOVProxy iov = session.readIov( isLowGain ? m_tagForLowGain : m_tagForHighGain, true ); + cond::Iov_t currentIov = *(iov.find( m_run )); + LogDebug( "PopConESTransitionSourceHandler" ) << "Loaded IOV sequence from tag " << ( isLowGain ? m_tagForLowGain : m_tagForHighGain ) + << " with size: "<< iov.loadedSize() + << ", IOV valid for run number " << m_run << " starting from: " << currentIov.since + << ", with corresponding payload hash: " << currentIov.payloadId + << std::endl; + std::string destTag = this->tagInfo().name; + if( currentIov.payloadId != this->tagInfo().lastPayloadToken ) { + std::ostringstream ss; + ss << "Adding iov with since "<( destTag, iov.timeType() ); + editor.setDescription( "Tag created by PopConESTransitionSourceHandler" ); + } + editor.insert( m_run, currentIov.payloadId ); + editor.flush(); + this->m_userTextLog = ss.str(); + } else { + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "The payload with hash " << currentIov.payloadId + << " corresponding to ES Gain" + << ( isLowGain ? "LOW" : "HIGH" ) + << " is still valid for run " << m_run + << " in the destination tag " << destTag + << ".\nNo transfer needed." <tagInfo().name + << ", size " << this->tagInfo().size + << ", last object valid since " << this->tagInfo().lastInterval.first + << ", hash " << this->tagInfo().lastPayloadToken << std::endl; + //check if a transfer is needed: + //if the new run number is smaller than or equal to the latest IOV, exit. + //This is needed as now the IOV Editor does not always protect for insertions: + //ANY and VALIDATION sychronizations are allowed to write in the past. + if( this->tagInfo().size > 0 && this->tagInfo().lastInterval.first >= m_run ) { + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "last IOV " << this->tagInfo().lastInterval.first + << ( this->tagInfo().lastInterval.first == m_run ? " is equal to" : " is larger than" ) + << " the run proposed for insertion " << m_run + << ". No transfer needed." << std::endl; + return; + } + bool isLowGain = checkLowGain(); + getObjectsForESTransition( isLowGain ); + edm::LogInfo( "PopConESTransitionSourceHandler" ) << "[" << "PopConESTransitionSourceHandler::" << __func__ << "]: " + << "END." << std::endl; + } + + private: + unsigned long long m_run; + double m_currentThreshold; + // for reading from CondDB the current from RunInfo + std::string m_tagForRunInfo; + // for reading from CondDB the Low Gain and High Gain payloads + std::string m_ESGain; + std::string m_tagForLowGain; + std::string m_tagForHighGain; + std::string m_connectionString; + edm::ParameterSet m_connectionPset; + cond::persistency::ConnectionPool m_connection; + }; +} //namespace popcon + +#endif //PopConESTransitionSourceHandler_H diff --git a/CondTools/Ecal/plugins/ESGainPopConTransitionAnalyzer.cc b/CondTools/Ecal/plugins/ESGainPopConTransitionAnalyzer.cc new file mode 100644 index 0000000000000..27ae63c36e584 --- /dev/null +++ b/CondTools/Ecal/plugins/ESGainPopConTransitionAnalyzer.cc @@ -0,0 +1,9 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondFormats/ESObjects/interface/ESGain.h" +#include "CondTools/Ecal/interface/PopConESTransitionSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer< popcon::PopConESTransitionSourceHandler > ESGainPopConTransitionAnalyzer; + +//define this as a plug-in +DEFINE_FWK_MODULE(ESGainPopConTransitionAnalyzer); diff --git a/CondTools/Ecal/plugins/ESIntercalibConstantsPopConTransitionAnalyzer.cc b/CondTools/Ecal/plugins/ESIntercalibConstantsPopConTransitionAnalyzer.cc new file mode 100644 index 0000000000000..d74bdd60edffa --- /dev/null +++ b/CondTools/Ecal/plugins/ESIntercalibConstantsPopConTransitionAnalyzer.cc @@ -0,0 +1,9 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondFormats/ESObjects/interface/ESIntercalibConstants.h" +#include "CondTools/Ecal/interface/PopConESTransitionSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer< popcon::PopConESTransitionSourceHandler > ESIntercalibConstantsPopConTransitionAnalyzer; + +//define this as a plug-in +DEFINE_FWK_MODULE(ESIntercalibConstantsPopConTransitionAnalyzer); diff --git a/CondTools/Ecal/plugins/ESRecHitRatioCutsPopConTransitionAnalyzer.cc b/CondTools/Ecal/plugins/ESRecHitRatioCutsPopConTransitionAnalyzer.cc new file mode 100644 index 0000000000000..17309f84f1985 --- /dev/null +++ b/CondTools/Ecal/plugins/ESRecHitRatioCutsPopConTransitionAnalyzer.cc @@ -0,0 +1,9 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondFormats/ESObjects/interface/ESRecHitRatioCuts.h" +#include "CondTools/Ecal/interface/PopConESTransitionSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer< popcon::PopConESTransitionSourceHandler > ESRecHitRatioCutsPopConTransitionAnalyzer; + +//define this as a plug-in +DEFINE_FWK_MODULE(ESRecHitRatioCutsPopConTransitionAnalyzer); diff --git a/CondTools/Ecal/plugins/ESTimeSampleWeightsPopConTransitionAnalyzer.cc b/CondTools/Ecal/plugins/ESTimeSampleWeightsPopConTransitionAnalyzer.cc new file mode 100644 index 0000000000000..cb1379f7b656e --- /dev/null +++ b/CondTools/Ecal/plugins/ESTimeSampleWeightsPopConTransitionAnalyzer.cc @@ -0,0 +1,9 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondFormats/ESObjects/interface/ESTimeSampleWeights.h" +#include "CondTools/Ecal/interface/PopConESTransitionSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer< popcon::PopConESTransitionSourceHandler > ESTimeSampleWeightsPopConTransitionAnalyzer; + +//define this as a plug-in +DEFINE_FWK_MODULE(ESTimeSampleWeightsPopConTransitionAnalyzer); diff --git a/CondTools/Ecal/python/ESGainPopConTransitionAnalyzer_cfg.py b/CondTools/Ecal/python/ESGainPopConTransitionAnalyzer_cfg.py new file mode 100644 index 0000000000000..31a83953c8220 --- /dev/null +++ b/CondTools/Ecal/python/ESGainPopConTransitionAnalyzer_cfg.py @@ -0,0 +1,43 @@ +import FWCore.ParameterSet.Config as cms +from CondCore.CondDB.CondDB_cfi import * +import CondTools.Ecal.conddb_init as conddb_init + +process = cms.Process("ESGainPopulator") + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("cout"), + cout = cms.untracked.PSet(threshold = cms.untracked.string("INFO")) + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(conddb_init.options.runNumber), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(conddb_init.options.runNumber), + interval = cms.uint64(1) +) + +CondDBConnection = CondDB.clone(connect = cms.string(conddb_init.options.destinationDatabase)) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + toPut = cms.VPSet(cms.PSet(record = cms.string("ESGainRcd"), + tag = cms.string(conddb_init.options.destinationTag) + ) + ) + ) + +process.popConESGain = cms.EDAnalyzer("ESGainPopConTransitionAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string("ESGainRcd"), + Source = cms.PSet(ESTransition = cms.PSet(CondDBConnection, #We write and read from the same DB + runNumber = cms.uint64(conddb_init.options.runNumber), + tagForRunInfo = cms.string(conddb_init.options.tagForRunInfo), + ESGain = cms.string(conddb_init.options.ESGain), + ESLowGainTag = cms.string(conddb_init.options.ESLowGainTag), + ESHighGainTag = cms.string(conddb_init.options.ESHighGainTag) ) + ), + loggingOn = cms.untracked.bool(True), + targetDBConnectionString = cms.untracked.string("") + ) + +process.p = cms.Path(process.popConESGain) diff --git a/CondTools/Ecal/python/ESIntercalibConstantsPopConTransitionAnalyzer_cfg.py b/CondTools/Ecal/python/ESIntercalibConstantsPopConTransitionAnalyzer_cfg.py new file mode 100644 index 0000000000000..c6dd07e2c1b95 --- /dev/null +++ b/CondTools/Ecal/python/ESIntercalibConstantsPopConTransitionAnalyzer_cfg.py @@ -0,0 +1,43 @@ +import FWCore.ParameterSet.Config as cms +from CondCore.CondDB.CondDB_cfi import * +import CondTools.Ecal.conddb_init as conddb_init + +process = cms.Process("ESIntercalibConstantsPopulator") + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("cout"), + cout = cms.untracked.PSet(threshold = cms.untracked.string("INFO")) + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(conddb_init.options.runNumber), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(conddb_init.options.runNumber), + interval = cms.uint64(1) +) + +CondDBConnection = CondDB.clone(connect = cms.string(conddb_init.options.destinationDatabase)) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + toPut = cms.VPSet(cms.PSet(record = cms.string("ESIntercalibConstantsRcd"), + tag = cms.string(conddb_init.options.destinationTag) + ) + ) + ) + +process.popConESIntercalibConstants = cms.EDAnalyzer("ESIntercalibConstantsPopConTransitionAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string("ESIntercalibConstantsRcd"), + Source = cms.PSet(ESTransition = cms.PSet(CondDBConnection, #We write and read from the same DB + runNumber = cms.uint64(conddb_init.options.runNumber), + tagForRunInfo = cms.string(conddb_init.options.tagForRunInfo), + ESGain = cms.string(conddb_init.options.ESGain), + ESLowGainTag = cms.string(conddb_init.options.ESLowGainTag), + ESHighGainTag = cms.string(conddb_init.options.ESHighGainTag) ) + ), + loggingOn = cms.untracked.bool(True), + targetDBConnectionString = cms.untracked.string("") + ) + +process.p = cms.Path(process.popConESIntercalibConstants) diff --git a/CondTools/Ecal/python/ESRecHitRatioCutsPopConTransitionAnalyzer_cfg.py b/CondTools/Ecal/python/ESRecHitRatioCutsPopConTransitionAnalyzer_cfg.py new file mode 100644 index 0000000000000..86525fc150a5a --- /dev/null +++ b/CondTools/Ecal/python/ESRecHitRatioCutsPopConTransitionAnalyzer_cfg.py @@ -0,0 +1,43 @@ +import FWCore.ParameterSet.Config as cms +from CondCore.CondDB.CondDB_cfi import * +import CondTools.Ecal.conddb_init as conddb_init + +process = cms.Process("ESRecHitRatioCutsPopulator") + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("cout"), + cout = cms.untracked.PSet(threshold = cms.untracked.string("INFO")) + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(conddb_init.options.runNumber), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(conddb_init.options.runNumber), + interval = cms.uint64(1) +) + +CondDBConnection = CondDB.clone(connect = cms.string(conddb_init.options.destinationDatabase)) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + toPut = cms.VPSet(cms.PSet(record = cms.string("ESRecHitRatioCutsRcd"), + tag = cms.string(conddb_init.options.destinationTag) + ) + ) + ) + +process.popConESRecHitRatioCuts = cms.EDAnalyzer("ESRecHitRatioCutsPopConTransitionAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string("ESRecHitRatioCutsRcd"), + Source = cms.PSet(ESTransition = cms.PSet(CondDBConnection, #We write and read from the same DB + runNumber = cms.uint64(conddb_init.options.runNumber), + tagForRunInfo = cms.string(conddb_init.options.tagForRunInfo), + ESGain = cms.string(conddb_init.options.ESGain), + ESLowGainTag = cms.string(conddb_init.options.ESLowGainTag), + ESHighGainTag = cms.string(conddb_init.options.ESHighGainTag) ) + ), + loggingOn = cms.untracked.bool(True), + targetDBConnectionString = cms.untracked.string("") + ) + +process.p = cms.Path(process.popConESRecHitRatioCuts) diff --git a/CondTools/Ecal/python/ESTimeSampleWeightsPopConTransitionAnalyzer_cfg.py b/CondTools/Ecal/python/ESTimeSampleWeightsPopConTransitionAnalyzer_cfg.py new file mode 100644 index 0000000000000..586d3eb547b2f --- /dev/null +++ b/CondTools/Ecal/python/ESTimeSampleWeightsPopConTransitionAnalyzer_cfg.py @@ -0,0 +1,43 @@ +import FWCore.ParameterSet.Config as cms +from CondCore.CondDB.CondDB_cfi import * +import CondTools.Ecal.conddb_init as conddb_init + +process = cms.Process("ESTimeSampleWeightsPopulator") + +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring("cout"), + cout = cms.untracked.PSet(threshold = cms.untracked.string("INFO")) + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(conddb_init.options.runNumber), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(conddb_init.options.runNumber), + interval = cms.uint64(1) +) + +CondDBConnection = CondDB.clone(connect = cms.string(conddb_init.options.destinationDatabase)) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + toPut = cms.VPSet(cms.PSet(record = cms.string("ESTimeSampleWeightsRcd"), + tag = cms.string(conddb_init.options.destinationTag) + ) + ) + ) + +process.popConESTimeSampleWeights = cms.EDAnalyzer("ESTimeSampleWeightsPopConTransitionAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string("ESTimeSampleWeightsRcd"), + Source = cms.PSet(ESTransition = cms.PSet(CondDBConnection, #We write and read from the same DB + runNumber = cms.uint64(conddb_init.options.runNumber), + tagForRunInfo = cms.string(conddb_init.options.tagForRunInfo), + ESGain = cms.string(conddb_init.options.ESGain), + ESLowGainTag = cms.string(conddb_init.options.ESLowGainTag), + ESHighGainTag = cms.string(conddb_init.options.ESHighGainTag) ) + ), + loggingOn = cms.untracked.bool(True), + targetDBConnectionString = cms.untracked.string("") + ) + +process.p = cms.Path(process.popConESTimeSampleWeights) diff --git a/CondTools/Ecal/python/conddb_init.py b/CondTools/Ecal/python/conddb_init.py index 39c915ed0a144..33903b7c7cc89 100644 --- a/CondTools/Ecal/python/conddb_init.py +++ b/CondTools/Ecal/python/conddb_init.py @@ -36,4 +36,19 @@ VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float, "the threshold on the magnet current for considering a switch of the magnetic field.") +options.register('ESGain', + '', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "Preshower gain : HIGH or LOW") +options.register('ESLowGainTag', + '', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "the tag name used to retrieve the reference payload for preshower in Low Gain.") +options.register('ESHighGainTag', + '', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "the tag name used to retrieve the reference payload for preshower in High Gain.") options.parseArguments() From 58ec6d62acd2b3c80e182f2c79ad4714bf249fcc Mon Sep 17 00:00:00 2001 From: Jeremiah Mans Date: Thu, 4 Apr 2019 09:47:11 -0500 Subject: [PATCH 512/686] Add support for HB data frames --- .../HcalDigi/interface/QIE11DataFrame.h | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/DataFormats/HcalDigi/interface/QIE11DataFrame.h b/DataFormats/HcalDigi/interface/QIE11DataFrame.h index c8c08e15f0308..6a356ecfdf28f 100644 --- a/DataFormats/HcalDigi/interface/QIE11DataFrame.h +++ b/DataFormats/HcalDigi/interface/QIE11DataFrame.h @@ -15,6 +15,11 @@ class QIE11DataFrame { static const int HEADER_WORDS = 1; static const int FLAG_WORDS = 1; + static const int OFFSET_FLAVOR = 12; + static const int MASK_FLAVOR = 0x7; + static const int FLAVOR_HB = 3; + static const int MASK_LINKERROR = 0x800; + constexpr QIE11DataFrame() { } constexpr QIE11DataFrame(edm::DataFrame const & df) : m_data(df) { } @@ -22,15 +27,23 @@ class QIE11DataFrame { public: constexpr Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { } static const int MASK_ADC = 0xFF; - static const int MASK_TDC = 0x3F; + static const int MASK_TDC_HE = 0x3F; + static const int MASK_TDC_HB = 0x3; static const int OFFSET_TDC = 8; // 8 bits static const int MASK_SOI = 0x4000; + static const int MASK_LE_HB = 0x2000; static const int MASK_CAPID = 0x3; - static const int OFFSET_CAPID = 8; + static const int MASK_CAPID_INV_HB = 0xF3FF; + static const int MASK_CAPID_KEEP_HB = 0x0C00; + static const int OFFSET_CAPID_HE = 8; + static const int OFFSET_CAPID_HB = 10; + constexpr int flavor() const { return ((frame_[0]>>OFFSET_FLAVOR)&MASK_FLAVOR); } constexpr int adc() const { return frame_[i_]&MASK_ADC; } - constexpr int tdc() const { return (frame_[i_]>>OFFSET_TDC)&MASK_TDC; } + constexpr int tdc() const { return (frame_[i_]>>OFFSET_TDC)&((flavor()==FLAVOR_HB)?(MASK_TDC_HB):(MASK_TDC_HE)); } constexpr bool soi() const { return frame_[i_]&MASK_SOI; } - constexpr int capid() const { return ((((frame_[0]>>OFFSET_CAPID)&MASK_CAPID)+i_-HEADER_WORDS)&MASK_CAPID); } + constexpr int capid() const { return (flavor()==FLAVOR_HB)? ((frame_[i_]>>OFFSET_CAPID_HB)&MASK_CAPID) : + ((((frame_[0]>>OFFSET_CAPID_HE)&MASK_CAPID)+i_-HEADER_WORDS)&MASK_CAPID); } + constexpr bool linkError() const { return (flavor()==FLAVOR_HB)? (frame_[i_]&MASK_LE_HB) : (frame_[0]&MASK_LINKERROR); } private: const edm::DataFrame& frame_; edm::DataFrame::size_type i_; @@ -63,11 +76,8 @@ class QIE11DataFrame { return -1; } /// get the flavor of the frame - static const int OFFSET_FLAVOR = 12; - static const int MASK_FLAVOR = 0x7; constexpr int flavor() const { return ((m_data[0]>>OFFSET_FLAVOR)&MASK_FLAVOR); } /// was there a link error? - static const int MASK_LINKERROR = 0x800; constexpr bool linkError() const { return m_data[0]&MASK_LINKERROR; } /// was there a capid rotation error? static const int MASK_CAPIDERROR = 0x400; @@ -81,14 +91,22 @@ class QIE11DataFrame { /// get the sample constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data,i+HEADER_WORDS); } constexpr void setCapid0(int cap0) { - m_data[0]&=0xFCFF; // inversion of the capid0 mask - m_data[0]|=((cap0&Sample::MASK_CAPID)<=size()) return; - m_data[isample+1]=(adc&Sample::MASK_ADC)|(soi?(Sample::MASK_SOI):(0))|((tdc&Sample::MASK_TDC)< Date: Thu, 28 Mar 2019 01:37:37 +0100 Subject: [PATCH 513/686] Allow flavor==3 for HB QIE11 digis --- EventFilter/HcalRawToDigi/src/HcalUnpacker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc index 1f4075fbfe6c6..65e0325f6ac07 100644 --- a/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc +++ b/EventFilter/HcalRawToDigi/src/HcalUnpacker.cc @@ -628,7 +628,7 @@ void HcalUnpacker::unpackUTCA(const FEDRawData& raw, const HcalElectronicsMap& e continue; } ///////////////////////////////////////////////HE UNPACKER////////////////////////////////////////////////////////////////////////////////////// - if (i.flavor() == 1 || i.flavor() == 0) { + if (i.flavor() == 1 || i.flavor() == 0 || i.flavor() == 3) { int ifiber=((i.channelid()>>3)&0x1F); int ichan=(i.channelid()&0x7); HcalElectronicsId eid(crate,slot,ifiber,ichan, false); From 9efd98e054b5eece3b2cf577986f70bc9b6ac208 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 26 Mar 2019 10:20:44 +0100 Subject: [PATCH 514/686] One less legacy module. --- .../Components/plugins/DQMDcsInfoClient.cc | 69 ++++++++----------- .../Components/plugins/DQMDcsInfoClient.h | 10 ++- .../Components/python/DQMDcsInfoClient_cfi.py | 4 +- 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/DQMServices/Components/plugins/DQMDcsInfoClient.cc b/DQMServices/Components/plugins/DQMDcsInfoClient.cc index 47b6a2b8afebd..40fbbf6e8e21a 100644 --- a/DQMServices/Components/plugins/DQMDcsInfoClient.cc +++ b/DQMServices/Components/plugins/DQMDcsInfoClient.cc @@ -2,7 +2,7 @@ /* * \file DQMDcsInfoClient.cc * \author Andreas Meyer - * Last Update: + * Last Update: 2019-03-26 Migrate to DQMEDHarvester * */ @@ -17,8 +17,6 @@ DQMDcsInfoClient::DQMDcsInfoClient( const edm::ParameterSet& ps ) { parameters_ = ps; - dbe_ = edm::Service().operator->(); - subsystemname_ = parameters_.getUntrackedParameter("subSystemFolder", "Info") ; dcsinfofolder_ = parameters_.getUntrackedParameter("dcsInfoFolder", "DcsInfo") ; @@ -30,31 +28,14 @@ DQMDcsInfoClient::~DQMDcsInfoClient() = default; void DQMDcsInfoClient::beginRun(const edm::Run& r, const edm::EventSetup& c) { - // Fetch GlobalTag information and fill the string/ME. - dbe_->cd(); - dbe_->setCurrentFolder(subsystemname_ +"/CMSSWInfo/"); - const edm::ParameterSet &globalTagPSet = - edm::getProcessParameterSetContainingModule(moduleDescription()) - .getParameterSet("PoolDBESSource@GlobalTag"); - - dbe_->bookString("globalTag_Harvesting", globalTagPSet.getParameter("globaltag")); - DCS.clear(); DCS.resize(10); // start with 10 LS, resize later processedLS_.clear(); } void -DQMDcsInfoClient::analyze(const edm::Event& e, const edm::EventSetup& c) -{ - return; -} - -void -DQMDcsInfoClient::endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) +DQMDcsInfoClient::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter, const edm::LuminosityBlock& l, const edm::EventSetup& c) { - if (!dbe_) return; - unsigned int nlumi = l.id().luminosityBlock() ; processedLS_.insert(nlumi); // cout << " in lumi section " << nlumi << endl; @@ -64,7 +45,7 @@ DQMDcsInfoClient::endLuminosityBlock(const edm::LuminosityBlock& l, const edm::E // cout << "DCS size: " << DCS.size() << endl; MonitorElement* DCSbyLS_ = - dbe_->get(subsystemname_ + "/" + dcsinfofolder_ + "/DCSbyLS" ); + igetter.get(subsystemname_ + "/" + dcsinfofolder_ + "/DCSbyLS" ); if ( DCSbyLS_ ) { @@ -86,27 +67,35 @@ DQMDcsInfoClient::endLuminosityBlock(const edm::LuminosityBlock& l, const edm::E } void -DQMDcsInfoClient::endRun(const edm::Run& r, const edm::EventSetup& c) +DQMDcsInfoClient::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) { + // Fetch GlobalTag information and fill the string/ME. + ibooker.cd(); + ibooker.setCurrentFolder(subsystemname_ +"/CMSSWInfo/"); + const edm::ParameterSet &globalTagPSet = + edm::getProcessParameterSetContainingModule(moduleDescription()) + .getParameterSet("PoolDBESSource@GlobalTag"); - // book - dbe_->cd(); - dbe_->setCurrentFolder(subsystemname_ +"/EventInfo/"); + ibooker.bookString("globalTag_Harvesting", globalTagPSet.getParameter("globaltag")); + + ibooker.cd(); + ibooker.setCurrentFolder(subsystemname_ +"/EventInfo/"); unsigned int nlsmax = DCS.size(); - reportSummary_=dbe_->bookFloat("reportSummary"); + reportSummary_=ibooker.bookFloat("reportSummary"); reportSummary_->Fill(1.); - reportSummaryMap_ = dbe_->get(subsystemname_ +"/EventInfo/reportSummaryMap"); - if (reportSummaryMap_) dbe_->removeElement(reportSummaryMap_->getName()); + reportSummaryMap_ = igetter.get(subsystemname_ +"/EventInfo/reportSummaryMap"); + assert(!reportSummaryMap_); // this would be a configuration problem - reportSummaryMap_ = dbe_->book2D("reportSummaryMap", + reportSummaryMap_ = ibooker.book2D("reportSummaryMap", "HV and GT vs Lumi", nlsmax, 0., nlsmax, 25, 0., 25.); + if (processedLS_.size() < 1) return; unsigned int lastProcessedLS = *(--processedLS_.end()); - meProcessedLS_ = dbe_->book1D("ProcessedLS", - "Processed Lumisections", - lastProcessedLS+1, - 0.,lastProcessedLS+1); + meProcessedLS_ = ibooker.book1D("ProcessedLS", + "Processed Lumisections", + lastProcessedLS+1, + 0.,lastProcessedLS+1); reportSummaryMap_->setBinLabel( 1, "CSC+" , 2); reportSummaryMap_->setBinLabel( 2, "CSC-" , 2); reportSummaryMap_->setBinLabel( 3, "DT0" , 2); @@ -146,22 +135,18 @@ DQMDcsInfoClient::endRun(const edm::Run& r, const edm::EventSetup& c) } } - std::set::iterator it,ite; - it = processedLS_.begin(); - ite = processedLS_.end(); unsigned int lastAccessed = 0; - for (; it!=ite; it++) + for (auto ls : processedLS_) { - while (lastAccessed < (*it)) + while (lastAccessed < ls) { // std::cout << "Filling " << lastAccessed << " with -1" << std::endl; meProcessedLS_->Fill(lastAccessed, -1.); lastAccessed++; } // std::cout << "Filling " << *it << " with 1" << std::endl; - meProcessedLS_->Fill(*it); - lastAccessed = (*it)+1; + meProcessedLS_->Fill(ls); + lastAccessed = ls+1; } - } diff --git a/DQMServices/Components/plugins/DQMDcsInfoClient.h b/DQMServices/Components/plugins/DQMDcsInfoClient.h index 6354167be5826..9d8810eff4229 100644 --- a/DQMServices/Components/plugins/DQMDcsInfoClient.h +++ b/DQMServices/Components/plugins/DQMDcsInfoClient.h @@ -15,14 +15,14 @@ #include #include -#include +#include #include // // class declaration // -class DQMDcsInfoClient : public edm::EDAnalyzer { +class DQMDcsInfoClient : public DQMEDHarvester { public: DQMDcsInfoClient( const edm::ParameterSet& ps); ~DQMDcsInfoClient() override; @@ -30,9 +30,8 @@ class DQMDcsInfoClient : public edm::EDAnalyzer { protected: void beginRun(const edm::Run& r, const edm::EventSetup& c) override; - void analyze(const edm::Event& e, const edm::EventSetup& c) override; - void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) override; - void endRun(const edm::Run& r, const edm::EventSetup& c) override; + void dqmEndLuminosityBlock(DQMStore::IBooker&, DQMStore::IGetter&, const edm::LuminosityBlock& l, const edm::EventSetup& c) override; + void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override; private: @@ -40,7 +39,6 @@ class DQMDcsInfoClient : public edm::EDAnalyzer { std::string subsystemname_; std::string dcsinfofolder_; - DQMStore * dbe_; std::vector DCS; std::set processedLS_; diff --git a/DQMServices/Components/python/DQMDcsInfoClient_cfi.py b/DQMServices/Components/python/DQMDcsInfoClient_cfi.py index 76a52a35f9d1d..f690a724334c6 100644 --- a/DQMServices/Components/python/DQMDcsInfoClient_cfi.py +++ b/DQMServices/Components/python/DQMDcsInfoClient_cfi.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms +from DQMServices.Core.DQMEDHarvester import DQMEDHarvester - -dqmDcsInfoClient = cms.EDAnalyzer("DQMDcsInfoClient", +dqmDcsInfoClient = DQMEDHarvester("DQMDcsInfoClient", subSystemFolder = cms.untracked.string('Info'), dcsInfoFolder = cms.untracked.string('DcsInfo') ) From 6a3ff036ca38e2eac2a2259c47cff76bc9b52fe5 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 26 Mar 2019 10:56:40 +0100 Subject: [PATCH 515/686] Code checks. --- DQMServices/Components/plugins/DQMDcsInfoClient.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/Components/plugins/DQMDcsInfoClient.cc b/DQMServices/Components/plugins/DQMDcsInfoClient.cc index 40fbbf6e8e21a..e39e6f67c9488 100644 --- a/DQMServices/Components/plugins/DQMDcsInfoClient.cc +++ b/DQMServices/Components/plugins/DQMDcsInfoClient.cc @@ -90,7 +90,7 @@ DQMDcsInfoClient::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igett reportSummaryMap_ = ibooker.book2D("reportSummaryMap", "HV and GT vs Lumi", nlsmax, 0., nlsmax, 25, 0., 25.); - if (processedLS_.size() < 1) return; + if (processedLS_.empty()) return; unsigned int lastProcessedLS = *(--processedLS_.end()); meProcessedLS_ = ibooker.book1D("ProcessedLS", "Processed Lumisections", From 29f6c857a228901259d309ed905b8b106d2e06a9 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Thu, 21 Mar 2019 17:56:19 +0100 Subject: [PATCH 516/686] Force per-lumi saving. --- DQMServices/Core/interface/MonitorElement.h | 2 +- DQMServices/Core/interface/oneDQMEDAnalyzer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DQMServices/Core/interface/MonitorElement.h b/DQMServices/Core/interface/MonitorElement.h index ee4950560388e..21b4c834cdf29 100644 --- a/DQMServices/Core/interface/MonitorElement.h +++ b/DQMServices/Core/interface/MonitorElement.h @@ -144,7 +144,7 @@ class MonitorElement /// true if ME is meant to be stored for each luminosity section bool getLumiFlag() const - { return data_.flags & DQMNet::DQM_PROP_LUMI; } + { return true; } /// this ME is meant to be stored for each luminosity section void setLumiFlag() diff --git a/DQMServices/Core/interface/oneDQMEDAnalyzer.h b/DQMServices/Core/interface/oneDQMEDAnalyzer.h index 491d59bd42c31..81c9676f341bd 100644 --- a/DQMServices/Core/interface/oneDQMEDAnalyzer.h +++ b/DQMServices/Core/interface/oneDQMEDAnalyzer.h @@ -101,7 +101,7 @@ class DQMLumisEDProducer : public DQMRunEDProducer class DQMBaseClass; -template<> class DQMBaseClass<> : public DQMRunEDProducer<> {}; +template<> class DQMBaseClass<> : public DQMLumisEDProducer {}; template<> class DQMBaseClass : public DQMLumisEDProducer {}; template<> class DQMBaseClass : public DQMRunEDProducer {}; template class DQMBaseClass> : public DQMRunEDProducer>{}; From 24a9647ef6f80c41b8767b813629dde02a4fde6e Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 26 Mar 2019 15:42:29 +0100 Subject: [PATCH 517/686] Condition per-lumi flag on non-legacy. This should avoid the problems with legacy modules. --- DQMServices/Core/interface/MonitorElement.h | 2 +- DQMServices/Core/src/DQMStore.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DQMServices/Core/interface/MonitorElement.h b/DQMServices/Core/interface/MonitorElement.h index 21b4c834cdf29..ee4950560388e 100644 --- a/DQMServices/Core/interface/MonitorElement.h +++ b/DQMServices/Core/interface/MonitorElement.h @@ -144,7 +144,7 @@ class MonitorElement /// true if ME is meant to be stored for each luminosity section bool getLumiFlag() const - { return true; } + { return data_.flags & DQMNet::DQM_PROP_LUMI; } /// this ME is meant to be stored for each luminosity section void setLumiFlag() diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index f333770ad7563..ef8025bd19ed9 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -934,6 +934,10 @@ DQMStore::book_(std::string const& dir, // Create and initialise core object. assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); + if (run_ != 0 && moduleId_ != 0) { + proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. + // for legacy (moduleId_ == 0) this is not always safe. + } me = const_cast(*data_.insert(std::move(proto)).first) .initialise((MonitorElement::Kind)kind, h); @@ -992,6 +996,10 @@ DQMStore::book_(std::string const& dir, // Create it and return for initialisation. assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); + if (run_ != 0 && moduleId_ != 0) { + proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. + // for legacy (moduleId_ == 0) this is not always safe. + } return &const_cast(*data_.insert(std::move(proto)).first); } } From 1433577299868110ae65fed1f32ac1edaf0de6f2 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 27 Mar 2019 20:58:43 +0100 Subject: [PATCH 518/686] Force-on threaded mode in DQMStore for the DQM step. This is set automatically for multi-threaded production jobs, but it would be good to also have it on for single-threaded test jobs. --- Configuration/Applications/python/ConfigBuilder.py | 2 ++ DQMServices/Core/python/DQMStoreNonLegacy_cff.py | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 DQMServices/Core/python/DQMStoreNonLegacy_cff.py diff --git a/Configuration/Applications/python/ConfigBuilder.py b/Configuration/Applications/python/ConfigBuilder.py index ea36a1cdeeecb..8fd8f2d3eada7 100644 --- a/Configuration/Applications/python/ConfigBuilder.py +++ b/Configuration/Applications/python/ConfigBuilder.py @@ -1935,6 +1935,8 @@ def expandMapping(self,seqList,mapping,index=None): def prepare_DQM(self, sequence = 'DQMOffline'): # this one needs replacement + # any 'DQM' job should use DQMStore in non-legacy mode (but not HARVESTING) + self.loadAndRemember("DQMServices/Core/DQMStoreNonLegacy_cff") self.loadDefaultOrSpecifiedCFF(sequence,self.DQMOFFLINEDefaultCFF) sequenceList=sequence.split('.')[-1].split('+') postSequenceList=sequence.split('.')[-1].split('+') diff --git a/DQMServices/Core/python/DQMStoreNonLegacy_cff.py b/DQMServices/Core/python/DQMStoreNonLegacy_cff.py new file mode 100644 index 0000000000000..7848af7c8b3e1 --- /dev/null +++ b/DQMServices/Core/python/DQMStoreNonLegacy_cff.py @@ -0,0 +1,9 @@ +from DQMServices.Core.DQMStore_cfi import DQMStore + +# This flag is turned on automatically when a job runs with more than one stream. +# However, it changes much more than just thread safety related things, so it is +# better to turn it on in *any* job that can be run multi-threaded, to get more +# reliable tests. Running single-threaded with this flag turned on is safe, but +# some modules (HARVESTING, legacy) will not work with this (and therefore can't +# run multi-threaded. +DQMStore.enableMultiThread = True From 59e6614e5f7f9002a144d17a7d847cd77f3bacde Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Fri, 29 Mar 2019 11:04:10 +0100 Subject: [PATCH 519/686] Remove lumi transitions from ElectronDqmAnalyzerBase, they seem to be unused anyways --- .../interface/ElectronDqmAnalyzerBase.h | 8 +---- .../EGamma/src/ElectronDqmAnalyzerBase.cc | 35 +------------------ 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/DQMOffline/EGamma/interface/ElectronDqmAnalyzerBase.h b/DQMOffline/EGamma/interface/ElectronDqmAnalyzerBase.h index ff5fb75b60c5c..7f0d1c39d699e 100644 --- a/DQMOffline/EGamma/interface/ElectronDqmAnalyzerBase.h +++ b/DQMOffline/EGamma/interface/ElectronDqmAnalyzerBase.h @@ -19,7 +19,7 @@ class MonitorElement ; namespace edab { struct Empty {}; } -class ElectronDqmAnalyzerBase : public one::DQMEDAnalyzer> +class ElectronDqmAnalyzerBase : public DQMEDAnalyzer { protected: @@ -28,17 +28,12 @@ class ElectronDqmAnalyzerBase : public one::DQMEDAnalyzer globalBeginLuminosityBlock( edm::LuminosityBlock const &, edm::EventSetup const & ) const final ; - void globalEndLuminosityBlock( edm::LuminosityBlock const &, edm::EventSetup const & ) final ; - void dqmBeginRun( edm::Run const & , edm::EventSetup const & ) override; void bookHistograms( DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; // interface to implement in derived classes void analyze( const edm::Event & e, const edm::EventSetup & c ) override {} // utility methods - bool finalStepDone() { return finalDone_ ; } int verbosity() { return verbosity_ ; } void setBookPrefix( const std::string & ) ; @@ -101,7 +96,6 @@ class ElectronDqmAnalyzerBase : public one::DQMEDAnalyzer ElectronDqmAnalyzerBase::ElectronDqmAnalyzerBase( const edm::ParameterSet& conf ) - : bookPrefix_("ele"), bookIndex_(0), histoNamesReady(false), finalDone_(false) + : bookPrefix_("ele"), bookIndex_(0), histoNamesReady(false) { verbosity_ = conf.getUntrackedParameter("Verbosity") ; finalStep_ = conf.getParameter("FinalStep") ; @@ -55,39 +55,6 @@ std::string ElectronDqmAnalyzerBase::newName( const std::string & name ) return oss.str() ; } -void ElectronDqmAnalyzerBase::dqmBeginRun( edm::Run const & , edm::EventSetup const & ) - { - } - -void ElectronDqmAnalyzerBase::endRun( edm::Run const &, edm::EventSetup const & ) - { - if (finalStep_=="AtRunEnd") - { - if (finalDone_) - { edm::LogWarning("ElectronDqmAnalyzerBase::endRun")<<"finalize() already called" ; } - finalDone_ = true ; - - // --- transfert from endJob() - if (!outputFile_.empty()) - { -// edm::LogWarning("ElectronDqmAnalyzerBase::endRun")<<"finalize() already called" ; - } /**/ - } - } - -std::shared_ptr -ElectronDqmAnalyzerBase::globalBeginLuminosityBlock( edm::LuminosityBlock const &, edm::EventSetup const & ) const { - return std::shared_ptr(); -} -void ElectronDqmAnalyzerBase::globalEndLuminosityBlock( edm::LuminosityBlock const &, edm::EventSetup const & ) - { - if (finalStep_=="AtLumiEnd") - { - if (finalDone_) - { edm::LogWarning("ElectronDqmAnalyzerBase::endLuminosityBlock")<<"finalize() already called" ; } - finalDone_ = true ; - } - } /**/ void ElectronDqmAnalyzerBase::bookHistograms( DQMStore::IBooker & ibooker_, edm::Run const &, edm::EventSetup const &) { From bba919df065928ca49f88caa185942d2ee23a291 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 1 Apr 2019 10:32:57 +0200 Subject: [PATCH 520/686] Decide wether to use per-lumi saving based on the base class. Also add a config option to opt-out non-standard workflows. --- DQMServices/Core/interface/DQMStore.h | 8 +++++++- DQMServices/Core/interface/oneDQMEDAnalyzer.h | 9 +++++++-- DQMServices/Core/python/DQMStore_cfi.py | 5 ++++- DQMServices/Core/src/DQMStore.cc | 12 ++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/DQMServices/Core/interface/DQMStore.h b/DQMServices/Core/interface/DQMStore.h index 09e5927122bc8..a9d26d04ea6b1 100644 --- a/DQMServices/Core/interface/DQMStore.h +++ b/DQMServices/Core/interface/DQMStore.h @@ -240,13 +240,14 @@ class DQMStore { // into the DQMStore via a public API. The central mutex is acquired // *before* invoking and automatically released upon returns. template - void bookTransaction(iFunc f, uint32_t run, uint32_t moduleId) + void bookTransaction(iFunc f, uint32_t run, uint32_t moduleId, bool canSaveByLumi) { std::lock_guard guard(book_mutex_); /* Set the run number and module id only if multithreading is enabled */ if (enableMultiThread_) { run_ = run; moduleId_ = moduleId; + canSaveByLumi_ = canSaveByLumi; } IBooker booker{this}; f(booker); @@ -255,6 +256,7 @@ class DQMStore { if (enableMultiThread_) { run_ = 0; moduleId_ = 0; + canSaveByLumi_ = false; } } @@ -638,6 +640,10 @@ class DQMStore { std::string readSelectedDirectory_{}; uint32_t run_{}; uint32_t moduleId_{}; + // set to true in the transaction if module supports per-lumi saving. + bool canSaveByLumi_{false}; + // set to true in configuration if per-lumi saving is requested. + bool doSaveByLumi_{false}; std::unique_ptr stream_{nullptr}; std::string pwd_{}; diff --git a/DQMServices/Core/interface/oneDQMEDAnalyzer.h b/DQMServices/Core/interface/oneDQMEDAnalyzer.h index 81c9676f341bd..2049f70ff0477 100644 --- a/DQMServices/Core/interface/oneDQMEDAnalyzer.h +++ b/DQMServices/Core/interface/oneDQMEDAnalyzer.h @@ -51,7 +51,8 @@ class DQMRunEDProducer : public edm::one::EDProducerbookHistograms(booker, run, setup); }, run.run(), - this->moduleDescription().id()); + this->moduleDescription().id(), + this->getCanSaveByLumi()); } void endRun(edm::Run const& run, edm::EventSetup const& setup) override {} @@ -70,6 +71,8 @@ class DQMRunEDProducer : public edm::one::EDProducer runToken_; @@ -101,7 +104,9 @@ class DQMLumisEDProducer : public DQMRunEDProducer class DQMBaseClass; -template<> class DQMBaseClass<> : public DQMLumisEDProducer {}; +template<> class DQMBaseClass<> : public DQMLumisEDProducer { + bool getCanSaveByLumi() override { return true; } +}; template<> class DQMBaseClass : public DQMLumisEDProducer {}; template<> class DQMBaseClass : public DQMRunEDProducer {}; template class DQMBaseClass> : public DQMRunEDProducer>{}; diff --git a/DQMServices/Core/python/DQMStore_cfi.py b/DQMServices/Core/python/DQMStore_cfi.py index 3061c52c14367..271026140fba7 100644 --- a/DQMServices/Core/python/DQMStore_cfi.py +++ b/DQMServices/Core/python/DQMStore_cfi.py @@ -10,5 +10,8 @@ #MEs are flagged to be LS based. LSbasedMode = cms.untracked.bool(False), #this is bound to the enableMultiThread flag. - forceResetOnBeginLumi = cms.untracked.bool(False) + forceResetOnBeginLumi = cms.untracked.bool(False), + # similar to LSBasedMode but for offline. Explicitly sets LumiFLag on all + # MEs/modules that allow it (canSaveByLumi) + saveByLumi = cms.untracked.bool(True), ) diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index ef8025bd19ed9..62bdebf6111c9 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -423,6 +423,10 @@ DQMStore::initializeFrom(edm::ParameterSet const& pset) if (LSbasedMode_) std::cout << "DQMStore: LSbasedMode option is enabled\n"; + doSaveByLumi_ = pset.getUntrackedParameter("saveByLumi", false); + if (doSaveByLumi_) + std::cout << "DQMStore: saveByLumi option is enabled\n"; + std::string ref = pset.getUntrackedParameter("referenceFileName", ""); if (! ref.empty()) { std::cout << "DQMStore: using reference file '" << ref << "'\n"; @@ -934,9 +938,9 @@ DQMStore::book_(std::string const& dir, // Create and initialise core object. assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); - if (run_ != 0 && moduleId_ != 0) { + if (doSaveByLumi_ && canSaveByLumi_) { proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. - // for legacy (moduleId_ == 0) this is not always safe. + // for legacy (not DQMEDAnalyzer) this is not save. } me = const_cast(*data_.insert(std::move(proto)).first) .initialise((MonitorElement::Kind)kind, h); @@ -996,9 +1000,9 @@ DQMStore::book_(std::string const& dir, // Create it and return for initialisation. assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); - if (run_ != 0 && moduleId_ != 0) { + if (doSaveByLumi_ && canSaveByLumi_) { proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. - // for legacy (moduleId_ == 0) this is not always safe. + // for legacy (not DQMEDAnalyzer) this is not save. } return &const_cast(*data_.insert(std::move(proto)).first); } From 4c44f2fe232035e652070225b53b6cd53f8fea9e Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 2 Apr 2019 16:15:51 +0200 Subject: [PATCH 521/686] Disable reset of per-lumi histos. I am not entirely sure why this is there. With this reset, no useful output is produced for MEs with setLumiFlag. Harvesters that do want their MEs reset should do so themselves, like in online. Most do, but some don't, and we'll need to fix them. --- DQMServices/FwkIO/plugins/DQMRootSource.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DQMServices/FwkIO/plugins/DQMRootSource.cc b/DQMServices/FwkIO/plugins/DQMRootSource.cc index 6a0080c83f50b..7aad7408e94bc 100644 --- a/DQMServices/FwkIO/plugins/DQMRootSource.cc +++ b/DQMServices/FwkIO/plugins/DQMRootSource.cc @@ -627,12 +627,12 @@ DQMRootSource::readLuminosityBlock_( edm::LuminosityBlockPrincipal& lbCache) edm::Service store; std::vector allMEs = (*store).getAllContents(""); - for(auto const& ME : allMEs) { - // We do not want to reset Run Products here! - if (ME->getLumiFlag()) { - ME->Reset(); - } - } + //for(auto const& ME : allMEs) { + // // We do not want to reset Run Products here! + // if (ME->getLumiFlag()) { + // ME->Reset(); + // } + //} m_lastSeenReducedPHID2 = m_reducedHistoryIDs.at(runLumiRange.m_historyIDIndex); m_lastSeenRun2 = runLumiRange.m_run; m_lastSeenLumi2 = runLumiRange.m_lumi; From 8172dbb0588c265e8b7bc751b98e3eb5788fab8c Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Thu, 4 Apr 2019 17:26:05 +0200 Subject: [PATCH 522/686] Disable per-lumi saving for non-histograms. --- DQMServices/Core/src/DQMStore.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index 62bdebf6111c9..ac255e6a9e2c8 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -939,8 +939,8 @@ DQMStore::book_(std::string const& dir, assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); if (doSaveByLumi_ && canSaveByLumi_) { - proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. // for legacy (not DQMEDAnalyzer) this is not save. + proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. } me = const_cast(*data_.insert(std::move(proto)).first) .initialise((MonitorElement::Kind)kind, h); @@ -1000,10 +1000,8 @@ DQMStore::book_(std::string const& dir, // Create it and return for initialisation. assert(dirs_.count(dir)); MonitorElement proto(&*dirs_.find(dir), name, run_, moduleId_); - if (doSaveByLumi_ && canSaveByLumi_) { - proto.setLumiFlag(); // default to per-lumi mode for all non-legacy MEs. - // for legacy (not DQMEDAnalyzer) this is not save. - } + // this is used only for Int/String/Float. We don't save these by lumi by + // default, since we can't merge them properly. return &const_cast(*data_.insert(std::move(proto)).first); } } From b89707be3765b26120cca3cf148f13c45b46e4eb Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 9 Apr 2019 11:49:55 +0200 Subject: [PATCH 523/686] Address Kevin's comments --- .../plugins/dd4hep/DDTrackerRingAlgo.cc | 222 +++++++++--------- 1 file changed, 112 insertions(+), 110 deletions(-) diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc index e2a1a235277ab..26d4735f123cd 100644 --- a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc @@ -8,122 +8,124 @@ using namespace dd4hep; using namespace cms; using namespace geant_units::operators; -static long algorithm(Detector& /* description */, - cms::DDParsingContext& ctxt, xml_h e, - SensitiveDetector& /* sens */) -{ - cms::DDNamespace ns(ctxt, e, true); - DDAlgoArguments args(ctxt, e); - Volume mother = ns.volume(args.parentName()); - string childName = args.value("ChildName"); - Volume child = ns.volume(childName); - - string parentName = args.parentName(); - int n = args.value("N"); - int startCopyNo = args.value("StartCopyNo"); - int incrCopyNo = args.value("IncrCopyNo"); - double rangeAngle = args.value("RangeAngle"); - double startAngle = args.value("StartAngle"); - double radius = args.value("Radius"); - vector center = args.value >("Center"); - bool isZPlus = args.value("IsZPlus") == 1; - double tiltAngle = args.value("TiltAngle"); - bool isFlipped = args.value("IsFlipped") == 1; - double delta = 0.; - - if(fabs(rangeAngle - 360.0_deg) < 0.001_deg) { - delta = rangeAngle/double(n); - } else { - if(n > 1) { - delta = rangeAngle/double(n-1); +namespace { + static long algorithm(Detector& /* description */, + cms::DDParsingContext& ctxt, xml_h e, + SensitiveDetector& /* sens */) + { + cms::DDNamespace ns(ctxt, e, true); + DDAlgoArguments args(ctxt, e); + Volume mother = ns.volume(args.parentName()); + string childName = args.value("ChildName"); + Volume child = ns.volume(childName); + + string parentName = args.parentName(); + int n = args.value("N"); + int startCopyNo = args.value("StartCopyNo"); + int incrCopyNo = args.value("IncrCopyNo"); + double rangeAngle = args.value("RangeAngle"); + double startAngle = args.value("StartAngle"); + double radius = args.value("Radius"); + vector center = args.value >("Center"); + bool isZPlus = args.value("IsZPlus") == 1; + double tiltAngle = args.value("TiltAngle"); + bool isFlipped = args.value("IsFlipped") == 1; + double delta = 0.; + + if(abs(rangeAngle - 360.0_deg) < 0.001_deg) { + delta = rangeAngle/double(n); } else { - delta = 0.; + if(n > 1) { + delta = rangeAngle/double(n-1); + } else { + delta = 0.; + } } - } - - LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position" - << "ing:: n " << n << " Start, Range, Delta " - << convertRadToDeg(startAngle) << " " - << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) - << " Radius " << radius << " Centre " << center[0] - << ", " << center[1] << ", "<< center[2]; - - LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName - << "\tChild " << childName << " NameSpace " - << ns.name(); - - Rotation3D flipRot, tiltRot, phiRot, globalRot; // Identity - Rotation3D flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix - - // flipMatrix calculus - if(isFlipped) { - LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " - << "\t90., 180., " - << "90., 90., " - << "180., 0."; - flipRot = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0._deg); - flipMatrix = flipRot; - } - // tiltMatrix calculus - if(isZPlus) { - LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " - << "\t90., 90., " - << convertRadToDeg(tiltAngle) << ", 180., " - << convertRadToDeg(90._deg - tiltAngle) << ", 0."; - tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 180._deg, 90._deg - tiltAngle, 0._deg); - tiltMatrix = tiltRot; - if(isFlipped) { tiltMatrix *= flipMatrix; } - } - else { - LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " - << "\t90., 90., " - << convertRadToDeg(tiltAngle) << ", 0., " - << convertRadToDeg(90._deg + tiltAngle) << ", 0."; - tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 0._deg, 90._deg + tiltAngle, 0._deg); - tiltMatrix = tiltRot; - if(isFlipped) { tiltMatrix *= flipMatrix; } - } - - // Loops for all phi values - double theta = 90._deg; - int copy = startCopyNo; - double phi = startAngle; - - for(int i = 0; i < n; ++i) { - // phiRotMatrix calculus - double phix = phi; - double phiy = phix + 90._deg; - double phideg = convertRadToDeg(phix); - if(phideg != 0.) { + + LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parameters for position" + << "ing:: n " << n << " Start, Range, Delta " + << convertRadToDeg(startAngle) << " " + << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) + << " Radius " << radius << " Centre " << center[0] + << ", " << center[1] << ", "<< center[2]; + + LogDebug("TrackerGeom") << "DDTrackerRingAlgo debug: Parent " << parentName + << "\tChild " << childName << " NameSpace " + << ns.name(); + + Rotation3D flipRot, tiltRot, phiRot, globalRot; // Identity + Rotation3D flipMatrix, tiltMatrix, phiRotMatrix, globalRotMatrix; // Identity matrix + + // flipMatrix calculus + if(isFlipped) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., 180., " + << "90., 90., " + << "180., 0."; + flipRot = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0._deg); + flipMatrix = flipRot; + } + // tiltMatrix calculus + if(isZPlus) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., 90., " + << convertRadToDeg(tiltAngle) << ", 180., " + << convertRadToDeg(90._deg - tiltAngle) << ", 0."; + tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 180._deg, 90._deg - tiltAngle, 0._deg); + tiltMatrix = tiltRot; + if(isFlipped) { tiltMatrix *= flipMatrix; } + } + else { LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " - << "\t90., " << convertRadToDeg(phix) - << ", 90.," << convertRadToDeg(phiy) - <<", 0., 0."; - phiRot = makeRotation3D(theta, phix, theta, phiy, 0., 0.); - phiRotMatrix = phiRot; + << "\t90., 90., " + << convertRadToDeg(tiltAngle) << ", 0., " + << convertRadToDeg(90._deg + tiltAngle) << ", 0."; + tiltRot = makeRotation3D(90._deg, 90._deg, tiltAngle, 0._deg, 90._deg + tiltAngle, 0._deg); + tiltMatrix = tiltRot; + if(isFlipped) { tiltMatrix *= flipMatrix; } } - - // globalRot def - globalRotMatrix = phiRotMatrix * tiltMatrix; - globalRot = Rotation3D(globalRotMatrix); - // translation def - double xpos = radius*cos(phi) + center[0]; - double ypos = radius*sin(phi) + center[1]; - double zpos = center[2]; - Position tran(xpos, ypos, zpos); - - // Positions child with respect to parent - mother.placeVolume(child, copy, Transform3D(globalRot, tran)); - LogDebug("TrackerGeom") << "DDTrackerRingAlgo test " << child << " number " - << copy << " positioned in " << mother << " at " - << tran << " with " << globalRot; + // Loops for all phi values + double theta = 90._deg; + int copy = startCopyNo; + double phi = startAngle; - copy += incrCopyNo; - phi += delta; + for(int i = 0; i < n; ++i) { + // phiRotMatrix calculus + double phix = phi; + double phiy = phix + 90._deg; + double phideg = convertRadToDeg(phix); + if(phideg != 0.) { + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test: Creating a new rotation: " + << "\t90., " << convertRadToDeg(phix) + << ", 90.," << convertRadToDeg(phiy) + <<", 0., 0."; + phiRot = makeRotation3D(theta, phix, theta, phiy, 0., 0.); + phiRotMatrix = phiRot; + } + + // globalRot def + globalRotMatrix = phiRotMatrix * tiltMatrix; + globalRot = Rotation3D(globalRotMatrix); + + // translation def + double xpos = radius*cos(phi) + center[0]; + double ypos = radius*sin(phi) + center[1]; + double zpos = center[2]; + Position tran(xpos, ypos, zpos); + + // Positions child with respect to parent + mother.placeVolume(child, copy, Transform3D(globalRot, tran)); + LogDebug("TrackerGeom") << "DDTrackerRingAlgo test " << child << " number " + << copy << " positioned in " << mother << " at " + << tran << " with " << globalRot; + + copy += incrCopyNo; + phi += delta; + } + return 1; } - return 1; } - // first argument is the type from the xml file -DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerRingAlgo,algorithm) +DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerRingAlgo,::algorithm) + From 3e0d38a7cc5e4edbaa23169e322eb62f9e8b0f8a Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 9 Apr 2019 12:06:10 +0200 Subject: [PATCH 524/686] Define an algorithm flag --- DetectorDescription/DDCMS/interface/DDAlgoArguments.h | 2 ++ DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc | 2 +- .../TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DetectorDescription/DDCMS/interface/DDAlgoArguments.h b/DetectorDescription/DDCMS/interface/DDAlgoArguments.h index ca8bb25af9243..4f560de46fd12 100644 --- a/DetectorDescription/DDCMS/interface/DDAlgoArguments.h +++ b/DetectorDescription/DDCMS/interface/DDAlgoArguments.h @@ -14,6 +14,8 @@ namespace cms { using DD3Vector = ROOT::Math::DisplacementVector3D>; + static constexpr long s_executed = 1l; + constexpr unsigned int hash( const char* str, int h = 0 ) { return !str[h] ? 5381 : ( hash( str, h+1 )*33 ) ^ str[h]; diff --git a/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc b/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc index 813cc96cbe987..14bda271706a6 100644 --- a/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc +++ b/DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc @@ -1236,7 +1236,7 @@ template <> void Converter::operator()(xml_h element) const { "DD4CMS","+++ Start executing algorithm %s....", type.c_str()); long ret = PluginService::Create(type, &description, ns.context(), &element, &sd); - if(ret == 1) { + if(ret == s_executed) { printout(ns.context()->debug_algorithms ? ALWAYS : DEBUG, "DD4CMS", "+++ Executed algorithm: %08lX = %s", ret, name.c_str()); return; diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc index 26d4735f123cd..e9c8c48fc3823 100644 --- a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc @@ -13,7 +13,7 @@ namespace { cms::DDParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) { - cms::DDNamespace ns(ctxt, e, true); + DDNamespace ns(ctxt, e, true); DDAlgoArguments args(ctxt, e); Volume mother = ns.volume(args.parentName()); string childName = args.value("ChildName"); @@ -123,7 +123,7 @@ namespace { copy += incrCopyNo; phi += delta; } - return 1; + return s_executed; } } // first argument is the type from the xml file From 8e6f64b0ee882017e16e552156e3b961db10b5fa Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 9 Apr 2019 12:09:56 +0200 Subject: [PATCH 525/686] Correct clang warning --- .../TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc index e9c8c48fc3823..a834ace987a51 100644 --- a/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc +++ b/Geometry/TrackerCommonData/plugins/dd4hep/DDTrackerRingAlgo.cc @@ -9,9 +9,9 @@ using namespace cms; using namespace geant_units::operators; namespace { - static long algorithm(Detector& /* description */, - cms::DDParsingContext& ctxt, xml_h e, - SensitiveDetector& /* sens */) + long algorithm(Detector& /* description */, + cms::DDParsingContext& ctxt, xml_h e, + SensitiveDetector& /* sens */) { DDNamespace ns(ctxt, e, true); DDAlgoArguments args(ctxt, e); From c108f3495aa41a8d9271ce5cc80d92da6a1a673a Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 12:19:26 +0200 Subject: [PATCH 526/686] add clang-format --- .clang-format | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000..013aff69c0620 --- /dev/null +++ b/.clang-format @@ -0,0 +1,19 @@ +--- +Language: Cpp +BasedOnStyle: Google +ColumnLimit: 120 +#didn't we want to change this? +NamespaceIndentation: All +SortIncludes: false +IndentWidth: 2 +AccessModifierOffset: -2 +PenaltyBreakComment: 30 +PenaltyExcessCharacter: 100 +AlignAfterOpenBracket: Align +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +BinPackParameters: false +AlwaysBreakTemplateDeclarations: Yes +ReflowComments: false +BinPackArguments: false +BinPackParameters: false From ac98aef02d44a4daaf5b34f33eba165ff6629042 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Tue, 9 Apr 2019 13:25:41 +0200 Subject: [PATCH 527/686] cucurrencyLimit is not present in one output module, removing reference. --- EventFilter/Utilities/src/EvFOutputModule.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index a80f03d2e23d1..f9fbe362fcbfd 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -149,11 +149,6 @@ namespace evf { streamLabel_(ps.getParameter("@module_label")), trToken_(consumes(edm::InputTag("TriggerResults"))) { - unsigned int concurrencyLimit = ps.getUntrackedParameter("concurrencyLimit"); - if (concurrencyLimit!=1) { - throw cms::Exception("EvFOutputModule") - << "Concurrency limit " << concurrencyLimit << " detected. Parameter values other than 1 are not supported by this output module"; - } //replace hltOutoputA with stream if the HLT menu uses this convention std::string testPrefix="hltOutput"; if (streamLabel_.find(testPrefix)==0) From 8639f5fc2dae0f55526694d2fe38689fd983aaa0 Mon Sep 17 00:00:00 2001 From: Cristina Mantilla Date: Tue, 9 Apr 2019 13:55:17 +0200 Subject: [PATCH 528/686] range based for loop --- .../SiPixelRecHits/src/PixelCPEClusterRepair.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index c6cf9de701921..069e049cfd6b5 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -100,8 +100,8 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const & conf, // XYZ n (XYZ as above, n = layer, wheel or disk = 1 .. 6 ;) std::vector str_recommend2D = conf.getParameter >("Recommend2D"); recommend2D_.reserve(str_recommend2D.size()); - for (unsigned int i=0; igeographicalId()); bool recommend = false; - for (unsigned int i=0; i Date: Tue, 9 Apr 2019 14:16:15 +0200 Subject: [PATCH 529/686] cleanup and adding new test script --- .../Utilities/interface/EvFOutputModule.h | 7 +- EventFilter/Utilities/src/EvFOutputModule.cc | 52 ------- .../Utilities/test/start_multiLS_FU.py | 139 ++++++++++++++++++ 3 files changed, 140 insertions(+), 58 deletions(-) create mode 100644 EventFilter/Utilities/test/start_multiLS_FU.py diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h index ad8240712a6eb..934be82cd7c3e 100644 --- a/EventFilter/Utilities/interface/EvFOutputModule.h +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -93,14 +93,9 @@ namespace evf { void write(edm::EventForOutput const& e) override; //pure in parent class but unused here - void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} //? + void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override {} void writeRun(edm::RunForOutput const&) override {} void endRun(edm::RunForOutput const&) override {} -// void globalEndRun(edm::RunForOutput const&) const override {} - - //void beginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; -// void beginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; -// void endLuminosityBlock(edm::LuminosityBlockForOutput const&) override; std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const override; void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) override; diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index f9fbe362fcbfd..7451bc50ad2df 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -22,47 +22,7 @@ #include namespace evf { -/* - class EvFOutputEventWriter - { - public: - - explicit EvFOutputEventWriter(std::string const& filePath): - filePath_(filePath), - accepted_(0), - stream_writer_events_(new StreamerOutputFile(filePath)) - { - } - - ~EvFOutputEventWriter() { - } - - void close() { - stream_writer_events_->close(); - } - void doOutputEvent(EventMsgBuilder const& msg) { - EventMsgView eview(msg.startAddress()); - stream_writer_events_->write(eview); - } - - uint32 get_adler32() const { - return stream_writer_events_->adler32(); - } - - std::string const& getFilePath() const {return filePath_;} - - unsigned long getAccepted() const {return accepted_;} - void incAccepted() {accepted_++;} - - private: - std::string filePath_; - unsigned long accepted_; - edm::propagate_const> stream_writer_events_; - - }; - -*/ EvFOutputJSONWriter::EvFOutputJSONWriter(edm::ParameterSet const& ps, edm::SelectedProducts const* selections, std::string const& streamLabel): streamerCommon_(ps, selections), processed_(0), @@ -177,18 +137,6 @@ namespace evf { edm::ParameterSetDescription desc; edm::StreamerOutputModuleCommon::fillDescription(desc); EvFOutputModuleType::fillDescription(desc); - - // Use addDefault here instead of add for 4 reasons: - // 1. Because EvFOutputModule_cfi.py is explicitly defined it does not need to be autogenerated - // The explicitly defined version overrides the autogenerated version of the cfi file. - // 2. That cfi file is not used anywhere in the release anyway - // 3. There are two plugin names used for the same template instantiation of this - // type, "ShmStreamConsumer" and "EvFOutputModule" and this causes name conflict - // problems for the cfi generation code which are avoided with addDefault. - // 4. At the present time, there is only one type of Consumer used to instantiate - // instances of this template, but if there were more than one type then this function - // would need to be specialized for each type unless the descriptions were the same - // and addDefault was used. descriptions.addDefault(desc); } diff --git a/EventFilter/Utilities/test/start_multiLS_FU.py b/EventFilter/Utilities/test/start_multiLS_FU.py new file mode 100644 index 0000000000000..0efbfca064ae9 --- /dev/null +++ b/EventFilter/Utilities/test/start_multiLS_FU.py @@ -0,0 +1,139 @@ +from __future__ import print_function +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +import os + +options = VarParsing.VarParsing ('analysis') + +options.register ('runNumber', + 100, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Run Number") + +options.register ('buBaseDir', + 'ramdisk', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "BU base directory") + + +options.register ('fuBaseDir', + 'data', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "BU base directory") + +options.register ('fffBaseDir', + '.', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "FFF base directory") + + +options.register ('numThreads', + 2, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of CMSSW threads") + +options.register ('numFwkStreams', + 2, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of CMSSW streams") + + +options.parseArguments() + +cmsswbase = os.path.expandvars("$CMSSW_BASE/") + +process = cms.Process("TESTFU") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +process.options = cms.untracked.PSet( + numberOfThreads = cms.untracked.uint32(options.numThreads), + numberOfStreams = cms.untracked.uint32(options.numFwkStreams), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(2) +) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string( "INFO" )), + destinations = cms.untracked.vstring( 'cout' ) +) + +process.FastMonitoringService = cms.Service("FastMonitoringService", + sleepTime = cms.untracked.int32(1) +) + +process.EvFDaqDirector = cms.Service("EvFDaqDirector", + useFileService = cms.untracked.bool(False), + fileServiceHost = cms.untracked.string("htcp40.cern.ch"), + runNumber = cms.untracked.uint32(options.runNumber), + baseDir = cms.untracked.string(options.fffBaseDir +"/"+options.fuBaseDir), + buBaseDir = cms.untracked.string(options.fffBaseDir+"/"+options.buBaseDir), + directorIsBu = cms.untracked.bool(False), + testModeNoBuilderUnit = cms.untracked.bool(False) +) + +try: + os.makedirs(options.fuBaseDir+"/run"+str(options.runNumber).zfill(6)) +except Exception as ex: + print(str(ex)) + pass + +process.source = cms.Source("FedRawDataInputSource", + runNumber = cms.untracked.uint32(options.runNumber), + getLSFromFilename = cms.untracked.bool(True), + testModeNoBuilderUnit = cms.untracked.bool(False), + verifyAdler32 = cms.untracked.bool(True), + verifyChecksum = cms.untracked.bool(True), + useL1EventID = cms.untracked.bool(True), + eventChunkSize = cms.untracked.uint32(32), + numBuffers = cms.untracked.uint32(2), + eventChunkBlock = cms.untracked.uint32(32) + ) + +process.PrescaleService = cms.Service( "PrescaleService", + forceDefault = cms.bool( False ), + prescaleTable = cms.VPSet( + cms.PSet( pathName = cms.string( "p1" ), + prescales = cms.vuint32( 10) + ), + cms.PSet( pathName = cms.string( "p2" ), + prescales = cms.vuint32( 100 ) + ) + ), + lvl1DefaultLabel = cms.string( "Default" ), + lvl1Labels = cms.vstring( 'Default' ) + ) + +process.filter1 = cms.EDFilter("HLTPrescaler", + L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) + ) +process.filter2 = cms.EDFilter("HLTPrescaler", + L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) + ) + +process.a = cms.EDAnalyzer("ExceptionGenerator", + defaultAction = cms.untracked.int32(0), + defaultQualifier = cms.untracked.int32(1000)) + +process.b = cms.EDAnalyzer("ExceptionGenerator", + defaultAction = cms.untracked.int32(0), + defaultQualifier = cms.untracked.int32(5)) + +process.p1 = cms.Path(process.a*process.filter1) +process.p2 = cms.Path(process.b*process.filter2) + +process.streamA = cms.OutputModule("EvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p1' )) +) + +process.streamB = cms.OutputModule("EvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p2' )) +) + +process.ep = cms.EndPath(process.streamA+process.streamB) From 04d34ff07b58743b5f854eea1777e1ca70e67060 Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Tue, 9 Apr 2019 15:22:45 +0200 Subject: [PATCH 530/686] applying reviewers comments --- .../Geometry/interface/MaterialBudgetData.h | 80 +++++++++---------- .../Geometry/src/MaterialBudgetHGCalHistos.cc | 52 ++++++------ 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Validation/Geometry/interface/MaterialBudgetData.h b/Validation/Geometry/interface/MaterialBudgetData.h index 5fb90611e87fd..b9bf8965b1b40 100644 --- a/Validation/Geometry/interface/MaterialBudgetData.h +++ b/Validation/Geometry/interface/MaterialBudgetData.h @@ -50,25 +50,25 @@ class MaterialBudgetData { float getAirFractionMB() const { return theAirFractionMB; } //HGCal - float getCopperFractionMB() const { + float getCopperFractionMB() const { return theCopperFractionMB; } - float getH_ScintillatorFractionMB() const { + float getH_ScintillatorFractionMB() const { return theH_ScintillatorFractionMB; } - float getLeadFractionMB() const { + float getLeadFractionMB() const { return theLeadFractionMB; } - float getEpoxyFractionMB() const { + float getEpoxyFractionMB() const { return theEpoxyFractionMB; } - float getKaptonFractionMB() const { + float getKaptonFractionMB() const { return theKaptonFractionMB; } - float getAluminiumFractionMB() const { + float getAluminiumFractionMB() const { return theAluminiumFractionMB; } - float getHGC_G10_FR4FractionMB() const { + float getHGC_G10_FR4FractionMB() const { return theHGC_G10_FR4FractionMB; } - float getSiliconFractionMB() const { + float getSiliconFractionMB() const { return theSiliconFractionMB; } - float getStainlessSteelFractionMB() const { + float getStainlessSteelFractionMB() const { return theStainlessSteelFractionMB; } - float getWCuFractionMB() const { + float getWCuFractionMB() const { return theWCuFractionMB; } float getSupportMB() const { @@ -86,25 +86,25 @@ class MaterialBudgetData { float getAirMB() const { return theAirMB; } //HGCal - float getCopperMB() const { + float getCopperMB() const { return theCopperMB; } - float getH_ScintillatorMB() const { + float getH_ScintillatorMB() const { return theH_ScintillatorMB; } - float getLeadMB() const { + float getLeadMB() const { return theLeadMB; } - float getEpoxyMB() const { + float getEpoxyMB() const { return theEpoxyMB; } - float getKaptonMB() const { + float getKaptonMB() const { return theKaptonMB; } - float getAluminiumMB() const { + float getAluminiumMB() const { return theAluminiumMB; } - float getHGC_G10_FR4MB() const { + float getHGC_G10_FR4MB() const { return theHGC_G10_FR4MB; } - float getSiliconMB() const { + float getSiliconMB() const { return theSiliconMB; } - float getStainlessSteelMB() const { + float getStainlessSteelMB() const { return theStainlessSteelMB; } - float getWCuMB() const { + float getWCuMB() const { return theWCuMB; } float getSupportFractionIL() const { @@ -121,25 +121,25 @@ class MaterialBudgetData { return theOtherFractionIL; } float getAirFractionIL() const { return theAirFractionIL; } - float getCopperFractionIL() const { + float getCopperFractionIL() const { return theCopperFractionIL; } - float getH_ScintillatorFractionIL() const { + float getH_ScintillatorFractionIL() const { return theH_ScintillatorFractionIL; } - float getLeadFractionIL() const { + float getLeadFractionIL() const { return theLeadFractionIL; } - float getEpoxyFractionIL() const { + float getEpoxyFractionIL() const { return theEpoxyFractionIL; } - float getKaptonFractionIL() const { + float getKaptonFractionIL() const { return theKaptonFractionIL; } - float getAluminiumFractionIL() const { + float getAluminiumFractionIL() const { return theAluminiumFractionIL; } - float getHGC_G10_FR4FractionIL() const { + float getHGC_G10_FR4FractionIL() const { return theHGC_G10_FR4FractionIL; } - float getSiliconFractionIL() const { + float getSiliconFractionIL() const { return theSiliconFractionIL; } - float getStainlessSteelFractionIL() const { + float getStainlessSteelFractionIL() const { return theStainlessSteelFractionIL; } - float getWCuFractionIL() const { + float getWCuFractionIL() const { return theWCuFractionIL; } float getTotalIL() const { return theTotalIL; } @@ -157,25 +157,25 @@ class MaterialBudgetData { return theOtherIL; } float getAirIL() const { return theAirIL; } - float getCopperIL() const { + float getCopperIL() const { return theCopperIL; } - float getH_ScintillatorIL() const { + float getH_ScintillatorIL() const { return theH_ScintillatorIL; } - float getLeadIL() const { + float getLeadIL() const { return theLeadIL; } - float getEpoxyIL() const { + float getEpoxyIL() const { return theEpoxyIL; } - float getKaptonIL() const { + float getKaptonIL() const { return theKaptonIL; } - float getAluminiumIL() const { + float getAluminiumIL() const { return theAluminiumIL; } - float getHGC_G10_FR4IL() const { + float getHGC_G10_FR4IL() const { return theHGC_G10_FR4IL; } - float getSiliconIL() const { + float getSiliconIL() const { return theSiliconIL; } - float getStainlessSteelIL() const { + float getStainlessSteelIL() const { return theStainlessSteelIL; } - float getWCuIL() const { + float getWCuIL() const { return theWCuIL; } diff --git a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc index 8f19bfa3ad51c..e88fb202aab69 100644 --- a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc +++ b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc @@ -498,19 +498,19 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iEpx = 0; int iKap = 0; int iAlu = 0; - if( theData->getCopperDmb(iStep)>0. ) { iCop = 1; } - if( theData->getH_ScintillatorDmb(iStep)>0. ) { iSci = 1; } - if( theData->getCablesDmb(iStep)>0. ) { iCab = 1; } - if( theData->getHGC_G10_FR4Dmb(iStep)>0. ) { iHgf = 1; } - if( theData->getSiliconDmb(iStep)>0. ) { iSil = 1; } - if( theData->getOtherDmb(iStep)>0. ) { iOth = 1; } - if( theData->getAirDmb(iStep)>0. ) { iAir = 1; } - if( theData->getStainlessSteelDmb(iStep)>0. ) { iSst = 1; } - if( theData->getWCuDmb(iStep)>0. ) { iWcu = 1; } - if( theData->getLeadDmb(iStep)>0. ) { iLea = 1; } - if( theData->getEpoxyDmb(iStep)>0. ) { iEpx = 1; } - if( theData->getKaptonDmb(iStep)>0. ) { iKap = 1; } - if( theData->getAluminiumDmb(iStep)>0. ) { iAlu = 1; } + if(theData->getCopperDmb(iStep)>0.) { iCop = 1; } + if(theData->getH_ScintillatorDmb(iStep)>0.) { iSci = 1; } + if(theData->getCablesDmb(iStep)>0.) { iCab = 1; } + if(theData->getHGC_G10_FR4Dmb(iStep)>0.) { iHgf = 1; } + if(theData->getSiliconDmb(iStep)>0.) { iSil = 1; } + if(theData->getOtherDmb(iStep)>0.) { iOth = 1; } + if(theData->getAirDmb(iStep)>0.) { iAir = 1; } + if(theData->getStainlessSteelDmb(iStep)>0.) { iSst = 1; } + if(theData->getWCuDmb(iStep)>0.) { iWcu = 1; } + if(theData->getLeadDmb(iStep)>0.) { iLea = 1; } + if(theData->getEpoxyDmb(iStep)>0.) { iEpx = 1; } + if(theData->getKaptonDmb(iStep)>0.) { iKap = 1; } + if(theData->getAluminiumDmb(iStep)>0.) { iAlu = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) @@ -794,19 +794,19 @@ void MaterialBudgetHGCalHistos::fillEndTrack() int iKap = 0; int iAlu = 0; - if( theData->getCopperDil(iStep)>0. ) { iCop = 1; } - if( theData->getH_ScintillatorDil(iStep)>0. ) { iSci = 1; } - if( theData->getCablesDil(iStep)>0. ) { iCab = 1; } - if( theData->getHGC_G10_FR4Dil(iStep)>0. ) { iHgf = 1; } - if( theData->getSiliconDil(iStep)>0. ) { iSil = 1; } - if( theData->getOtherDil(iStep)>0. ) { iOth = 1; } - if( theData->getAirDil(iStep)>0. ) { iAir = 1; } - if( theData->getStainlessSteelDil(iStep)>0. ) { iSst = 1; } - if( theData->getWCuDil(iStep)>0. ) { iWcu = 1; } - if( theData->getLeadDil(iStep)>0. ) { iLea = 1; } - if( theData->getEpoxyDil(iStep)>0. ) { iEpx = 1; } - if( theData->getKaptonDil(iStep)>0. ) { iKap = 1; } - if( theData->getAluminiumDil(iStep)>0. ) { iAlu = 1; } + if(theData->getCopperDil(iStep)>0.) { iCop = 1; } + if(theData->getH_ScintillatorDil(iStep)>0.) { iSci = 1; } + if(theData->getCablesDil(iStep)>0.) { iCab = 1; } + if(theData->getHGC_G10_FR4Dil(iStep)>0.) { iHgf = 1; } + if(theData->getSiliconDil(iStep)>0.) { iSil = 1; } + if(theData->getOtherDil(iStep)>0.) { iOth = 1; } + if(theData->getAirDil(iStep)>0.) { iAir = 1; } + if(theData->getStainlessSteelDil(iStep)>0.) { iSst = 1; } + if(theData->getWCuDil(iStep)>0.) { iWcu = 1; } + if(theData->getLeadDil(iStep)>0.) { iLea = 1; } + if(theData->getEpoxyDil(iStep)>0.) { iEpx = 1; } + if(theData->getKaptonDil(iStep)>0.) { iKap = 1; } + if(theData->getAluminiumDil(iStep)>0.) { iAlu = 1; } float deltaRadius = sqrt( pow( theData->getStepFinalX(iStep)-theData->getStepInitialX(iStep),2 ) From 3d8f041fc0d7b0fc50aafb0f8bbbb0212c9571fc Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Tue, 9 Apr 2019 09:56:12 -0500 Subject: [PATCH 531/686] Avoid ambiguous statement in dqmfilesaver::fillJson gcc9 was parsing the statement as a function declaration rather than a variable declaration. Using brace initialization resolved the ambiguity. --- DQMServices/Components/src/fillJson.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/Components/src/fillJson.cc b/DQMServices/Components/src/fillJson.cc index fcfa8e4f2fa10..0f9ccfa1ecc2a 100644 --- a/DQMServices/Components/src/fillJson.cc +++ b/DQMServices/Components/src/fillJson.cc @@ -94,7 +94,7 @@ dqmfilesaver::fillJson(int run, int lumi, const std::string& dataFilePathName, c pt.put("definition", "/fakeDefinition.jsn"); } else { // The availability test of the EvFDaqDirector Service was done in the ctor. - bfs::path outJsonDefName(edm::Service()->baseRunDir()); //we assume this file is written bu the EvF Output module + bfs::path outJsonDefName{edm::Service()->baseRunDir()}; //we assume this file is written bu the EvF Output module outJsonDefName /= (std::string("output_") + oss_pid.str() + std::string(".jsd")); pt.put("definition", outJsonDefName.string()); } From 592f4f970a1feb8844e4c65d96ddeaa343289205 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 17:38:50 +0200 Subject: [PATCH 532/686] make python3 compatible --- Validation/Configuration/python/ECALHCAL.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/Configuration/python/ECALHCAL.py b/Validation/Configuration/python/ECALHCAL.py index 1ace2542760d8..e699246bfab6c 100644 --- a/Validation/Configuration/python/ECALHCAL.py +++ b/Validation/Configuration/python/ECALHCAL.py @@ -30,7 +30,7 @@ def customise(process): # modify the content #process.output.outputCommands.append("keep *_simHcalUnsuppressedDigis_*_*") - six.iteritems(process.outputModules_()).next()[1].outputCommands.append("keep *_simHcalUnsuppressedDigis_*_*") + six.next(six.iteritems(process.outputModules_()))[1].outputCommands.append("keep *_simHcalUnsuppressedDigis_*_*") # user schedule: use only calorimeters digitization and local reconstruction @@ -84,6 +84,6 @@ def customise(process): process.schedule.append(process.endjob_step) #process.schedule.append(process.out_step) - process.schedule.append(getattr(process,six.iteritems(process.outputModules_()).next()[0]+"_step")) + process.schedule.append(getattr(process,six.next(six.iteritems(process.outputModules_()))[0]+"_step")) return(process) From 885a056e847a08ca52428fcbb826b6afa0e8e55f Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 19:59:39 +0200 Subject: [PATCH 533/686] xrange migration in fwk packages --- DataFormats/FWLite/examples/patZpeak.py | 5 ++- DataFormats/FWLite/test/chainEvent_python.py | 3 +- .../test/pyroot_read_associationvector.py | 3 +- .../test/dump_parameterization.py | 1 + .../scripts/edmStreamStallGrapher.py | 39 ++++++++++--------- .../GuiBrowsers/python/EnablePSetHistory.py | 3 +- .../python/Vispa/Gui/PortConnection.py | 1 + .../python/Vispa/Gui/ToolBoxContainer.py | 1 + .../python/Vispa/Gui/VispaWidget.py | 1 + .../python/Vispa/Main/Application.py | 1 + .../python/Vispa/Main/MainWindow.py | 1 + .../python/Vispa/Main/RotatingIcon.py | 1 + .../python/Vispa/Main/SplitterTab.py | 1 + .../python/Vispa/Main/StartupScreen.py | 1 + .../python/Vispa/Main/TabController.py | 1 + .../ConfigEditor/ConfigDataAccessor.py | 1 + .../Plugins/EdmBrowser/EdmDataAccessor.py | 7 ++-- .../EdmBrowser/EventContentDataAccessor.py | 1 + .../Plugins/EdmBrowser/EventContentView.py | 1 + .../python/Vispa/Views/LineDecayView.py | 1 + .../python/Vispa/Views/PropertyView.py | 1 + .../python/Vispa/Views/TableView.py | 1 + FWCore/Modules/test/emptysource_cfg.py | 3 +- ...urce_firstLuminosityBlockForEachRun_cfg.py | 3 +- .../Modules/test/testBunchCrossingFilter.py | 5 ++- FWCore/ParameterSet/python/Mixins.py | 5 ++- FWCore/ParameterSet/python/SequenceTypes.py | 3 +- FWCore/ParameterSet/python/TreeCrawler.py | 3 +- FWCore/PythonUtilities/python/LumiList.py | 1 + FWCore/PythonUtilities/scripts/generateEDF.py | 1 + FWCore/Skeletons/python/cms.py | 3 +- FWCore/Skeletons/python/utils.py | 3 +- Utilities/RelMon/python/directories2html.py | 7 ++-- Utilities/RelMon/python/dirstructure.py | 3 +- Utilities/RelMon/python/dqm_interfaces.py | 3 +- Utilities/RelMon/python/utils.py | 17 ++++---- Utilities/RelMon/python/utils_v2.py | 7 ++-- Utilities/RelMon/scripts/ValidationMatrix.py | 3 +- .../python/cmsCodeRules/cppFunctionSkipper.py | 1 + .../python/cmsCodeRules/keyFinder.py | 1 + .../python/cmsCodeRules/showPage.py | 1 + .../commentSkipper/buildFileCommentSkipper.py | 1 + .../commentSkipper/cppCommentSkipper.py | 1 + .../ReleaseScripts/scripts/addOnTests.py | 1 + .../scripts/cmsCodeRulesChecker.py | 1 + .../ReleaseScripts/scripts/storeTreeInfo.py | 1 + Utilities/StaticAnalyzers/scripts/statics.py | 1 + 47 files changed, 101 insertions(+), 54 deletions(-) diff --git a/DataFormats/FWLite/examples/patZpeak.py b/DataFormats/FWLite/examples/patZpeak.py index c00afe4f29d01..df7edfb367a1d 100755 --- a/DataFormats/FWLite/examples/patZpeak.py +++ b/DataFormats/FWLite/examples/patZpeak.py @@ -1,5 +1,6 @@ #! /usr/bin/env python +from builtins import range import ROOT import sys from DataFormats.FWLite import Events, Handle @@ -39,9 +40,9 @@ # use muons to make Z peak numMuons = len (muons) if muons < 2: continue - for outer in xrange (numMuons - 1): + for outer in range (numMuons - 1): outerMuon = muons[outer] - for inner in xrange (outer + 1, numMuons): + for inner in range (outer + 1, numMuons): innerMuon = muons[inner] if outerMuon.charge() * innerMuon.charge() >= 0: continue diff --git a/DataFormats/FWLite/test/chainEvent_python.py b/DataFormats/FWLite/test/chainEvent_python.py index 4f6ca35094daf..02aaf503609ad 100644 --- a/DataFormats/FWLite/test/chainEvent_python.py +++ b/DataFormats/FWLite/test/chainEvent_python.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range from DataFormats.FWLite import Events, Handle import optparse @@ -34,7 +35,7 @@ for loop in range (thing.size()): print(thing.at (loop).a) -for i in xrange(events.size()): +for i in range(events.size()): if not events.to(i): print("failed to go to index ",i) exit(1) diff --git a/DataFormats/FWLite/test/pyroot_read_associationvector.py b/DataFormats/FWLite/test/pyroot_read_associationvector.py index 432e922eeff66..35503dac078a1 100644 --- a/DataFormats/FWLite/test/pyroot_read_associationvector.py +++ b/DataFormats/FWLite/test/pyroot_read_associationvector.py @@ -1,5 +1,6 @@ #! /usr/bin/env python +from builtins import range import ROOT import sys from DataFormats.FWLite import Events, Handle @@ -16,7 +17,7 @@ #print "###################### ", count event.getByLabel (label, handle) cont = handle.product() - values = [ cont.value(i).value for i in xrange(len(cont))] + values = [ cont.value(i).value for i in range(len(cont))] for i,v in enumerate(handle.product()): #print v.second.value, values[i] if v.second.value != values[i]: diff --git a/DataFormats/PatCandidates/test/dump_parameterization.py b/DataFormats/PatCandidates/test/dump_parameterization.py index 743f6a6dff4db..763b923439d66 100755 --- a/DataFormats/PatCandidates/test/dump_parameterization.py +++ b/DataFormats/PatCandidates/test/dump_parameterization.py @@ -1,5 +1,6 @@ #!/bin/env python from __future__ import print_function +from builtins import range import ROOT from ROOT import * import sys diff --git a/FWCore/Concurrency/scripts/edmStreamStallGrapher.py b/FWCore/Concurrency/scripts/edmStreamStallGrapher.py index c065a8a4ae29b..de4c799b81ffc 100755 --- a/FWCore/Concurrency/scripts/edmStreamStallGrapher.py +++ b/FWCore/Concurrency/scripts/edmStreamStallGrapher.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range from itertools import groupby from operator import attrgetter,itemgetter import sys @@ -317,7 +318,7 @@ def findStalledModules(processingSteps, numStreams): streamTime = [0]*numStreams streamState = [0]*numStreams stalledModules = {} - modulesActiveOnStream = [{} for x in xrange(numStreams)] + modulesActiveOnStream = [{} for x in range(numStreams)] for n,trans,s,time,isEvent in processingSteps: waitTime = None @@ -351,7 +352,7 @@ def createModuleTiming(processingSteps, numStreams): streamTime = [0]*numStreams streamState = [0]*numStreams moduleTimings = defaultdict(list) - modulesActiveOnStream = [defaultdict(int) for x in xrange(numStreams)] + modulesActiveOnStream = [defaultdict(int) for x in range(numStreams)] for n,trans,s,time,isEvent in processingSteps: waitTime = None modulesOnStream = modulesActiveOnStream[s] @@ -372,7 +373,7 @@ def createModuleTiming(processingSteps, numStreams): def createAsciiImage(processingSteps, numStreams, maxNameSize): streamTime = [0]*numStreams streamState = [0]*numStreams - modulesActiveOnStreams = [{} for x in xrange(numStreams)] + modulesActiveOnStreams = [{} for x in range(numStreams)] for n,trans,s,time,isEvent in processingSteps: waitTime = None modulesActiveOnStream = modulesActiveOnStreams[s] @@ -505,9 +506,9 @@ def unpack(self): # drastically reduces the size of the pdf file. def consolidateContiguousBlocks(numStreams, streamInfo): oldStreamInfo = streamInfo - streamInfo = [[] for x in xrange(numStreams)] + streamInfo = [[] for x in range(numStreams)] - for s in xrange(numStreams): + for s in range(numStreams): if oldStreamInfo[s]: lastStartTime,lastTimeLength,lastColor = oldStreamInfo[s][0].unpack() for info in oldStreamInfo[s][1:]: @@ -580,23 +581,23 @@ def plotPerStreamAboveFirstAndPrepareStack(points, allStackTimes, ax, stream, he def createPDFImage(pdfFile, shownStacks, processingSteps, numStreams, stalledModuleInfo, displayExternalWork, checkOrder): stalledModuleNames = set([x for x in stalledModuleInfo.iterkeys()]) - streamLowestRow = [[] for x in xrange(numStreams)] - modulesActiveOnStreams = [set() for x in xrange(numStreams)] - acquireActiveOnStreams = [set() for x in xrange(numStreams)] - externalWorkOnStreams = [set() for x in xrange(numStreams)] - previousFinishTime = [None for x in xrange(numStreams)] - streamRunningTimes = [[] for x in xrange(numStreams)] - streamExternalWorkRunningTimes = [[] for x in xrange(numStreams)] + streamLowestRow = [[] for x in range(numStreams)] + modulesActiveOnStreams = [set() for x in range(numStreams)] + acquireActiveOnStreams = [set() for x in range(numStreams)] + externalWorkOnStreams = [set() for x in range(numStreams)] + previousFinishTime = [None for x in range(numStreams)] + streamRunningTimes = [[] for x in range(numStreams)] + streamExternalWorkRunningTimes = [[] for x in range(numStreams)] maxNumberOfConcurrentModulesOnAStream = 1 externalWorkModulesInJob = False - previousTime = [0 for x in xrange(numStreams)] + previousTime = [0 for x in range(numStreams)] # The next five variables are only used to check for out of order transitions - finishBeforeStart = [set() for x in xrange(numStreams)] - finishAcquireBeforeStart = [set() for x in xrange(numStreams)] - countSource = [0 for x in xrange(numStreams)] - countDelayedSource = [0 for x in xrange(numStreams)] - countExternalWork = [defaultdict(int) for x in xrange(numStreams)] + finishBeforeStart = [set() for x in range(numStreams)] + finishAcquireBeforeStart = [set() for x in range(numStreams)] + countSource = [0 for x in range(numStreams)] + countDelayedSource = [0 for x in range(numStreams)] + countExternalWork = [defaultdict(int) for x in range(numStreams)] timeOffset = None for n,trans,s,time,isEvent in processingSteps: @@ -730,7 +731,7 @@ def createPDFImage(pdfFile, shownStacks, processingSteps, numStreams, stalledMod ax.set_xlabel("Time (sec)") ax.set_ylabel("Stream ID") ax.set_ylim(-0.5,numStreams-0.5) - ax.yaxis.set_ticks(xrange(numStreams)) + ax.yaxis.set_ticks(range(numStreams)) height = 0.8/maxNumberOfConcurrentModulesOnAStream allStackTimes={'green': [],'limegreen':[], 'red': [], 'blue': [], 'orange': [], 'darkviolet': []} diff --git a/FWCore/GuiBrowsers/python/EnablePSetHistory.py b/FWCore/GuiBrowsers/python/EnablePSetHistory.py index a88f133ea3b68..a557c59ccace7 100644 --- a/FWCore/GuiBrowsers/python/EnablePSetHistory.py +++ b/FWCore/GuiBrowsers/python/EnablePSetHistory.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from copy import deepcopy import inspect import six @@ -575,7 +576,7 @@ def testPSet(self): ) ), seven = cms.vstring('alpha','bravo','charlie'), - eight = cms.vuint32(range(10)), + eight = cms.vuint32(list(range(10))), nine = cms.int32(0) ) ex.zero = cms.string('hello') diff --git a/FWCore/GuiBrowsers/python/Vispa/Gui/PortConnection.py b/FWCore/GuiBrowsers/python/Vispa/Gui/PortConnection.py index e77d26e6f2d25..a673c069a0eaf 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Gui/PortConnection.py +++ b/FWCore/GuiBrowsers/python/Vispa/Gui/PortConnection.py @@ -1,3 +1,4 @@ +from builtins import range import logging from PyQt4.QtCore import Qt, QPoint, QPointF, QRectF, QSizeF, SIGNAL diff --git a/FWCore/GuiBrowsers/python/Vispa/Gui/ToolBoxContainer.py b/FWCore/GuiBrowsers/python/Vispa/Gui/ToolBoxContainer.py index cc57c3224915c..350a1f76c3974 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Gui/ToolBoxContainer.py +++ b/FWCore/GuiBrowsers/python/Vispa/Gui/ToolBoxContainer.py @@ -1,3 +1,4 @@ +from builtins import range from PyQt4.QtCore import * from PyQt4.QtGui import * diff --git a/FWCore/GuiBrowsers/python/Vispa/Gui/VispaWidget.py b/FWCore/GuiBrowsers/python/Vispa/Gui/VispaWidget.py index 65ab235c7f9d0..07aa10e914881 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Gui/VispaWidget.py +++ b/FWCore/GuiBrowsers/python/Vispa/Gui/VispaWidget.py @@ -1,3 +1,4 @@ +from builtins import range import math from PyQt4.QtCore import * diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/Application.py b/FWCore/GuiBrowsers/python/Vispa/Main/Application.py index e82a680b6b80e..cc4569cb2b651 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/Application.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/Application.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range import os import sys import string diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/MainWindow.py b/FWCore/GuiBrowsers/python/Vispa/Main/MainWindow.py index 8d5446b0012a5..502ed0e115c37 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/MainWindow.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/MainWindow.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range import logging import os import math diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/RotatingIcon.py b/FWCore/GuiBrowsers/python/Vispa/Main/RotatingIcon.py index 65ab22969a623..67847cd01ca83 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/RotatingIcon.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/RotatingIcon.py @@ -1,3 +1,4 @@ +from builtins import range from PyQt4.QtCore import QTimeLine,SIGNAL,Qt from PyQt4.QtGui import QLabel,QPixmap,QMatrix,QPainter diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/SplitterTab.py b/FWCore/GuiBrowsers/python/Vispa/Main/SplitterTab.py index 2ccb846a93ac2..d98fd7d1ef167 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/SplitterTab.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/SplitterTab.py @@ -1,3 +1,4 @@ +from builtins import range import logging from PyQt4.QtCore import Qt, SIGNAL, QCoreApplication, QEvent, QSize diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/StartupScreen.py b/FWCore/GuiBrowsers/python/Vispa/Main/StartupScreen.py index bb4e017ad7ebd..ec6d64092a9a3 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/StartupScreen.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/StartupScreen.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range import logging from PyQt4.QtCore import SIGNAL,QRect,QSize,QPoint diff --git a/FWCore/GuiBrowsers/python/Vispa/Main/TabController.py b/FWCore/GuiBrowsers/python/Vispa/Main/TabController.py index c842efc03cbb9..25615288b8dbf 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Main/TabController.py +++ b/FWCore/GuiBrowsers/python/Vispa/Main/TabController.py @@ -1,3 +1,4 @@ +from builtins import range import os.path import logging import math diff --git a/FWCore/GuiBrowsers/python/Vispa/Plugins/ConfigEditor/ConfigDataAccessor.py b/FWCore/GuiBrowsers/python/Vispa/Plugins/ConfigEditor/ConfigDataAccessor.py index 01f8dfbb2155b..d4e6efae17a31 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Plugins/ConfigEditor/ConfigDataAccessor.py +++ b/FWCore/GuiBrowsers/python/Vispa/Plugins/ConfigEditor/ConfigDataAccessor.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys import os.path import logging diff --git a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EdmDataAccessor.py b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EdmDataAccessor.py index b4b81ce99e76b..9b4b64ece97ac 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EdmDataAccessor.py +++ b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EdmDataAccessor.py @@ -1,3 +1,4 @@ +from builtins import range import logging import os.path @@ -20,7 +21,7 @@ def all(container): if hasattr(container,'GetEntries'): try: entries = container.GetEntries() - for entry in xrange(entries): + for entry in range(entries): yield entry except: raise cmserror("Looping of %s failed" %container) @@ -31,7 +32,7 @@ def all(container): container = container.ids() try: entries = container.size() - for entry in xrange(entries): + for entry in range(entries): yield container[entry] except: pass @@ -204,7 +205,7 @@ def getObjectContent(self,object): split_typestring=typestring.split(" ") templates=0 end_typestring=0 - for i in reversed(range(len(split_typestring))): + for i in reversed(list(range(len(split_typestring)))): templates+=split_typestring[i].count("<") templates-=split_typestring[i].count(">") if templates==0: diff --git a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentDataAccessor.py b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentDataAccessor.py index 03de699de13c7..61f2688a00272 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentDataAccessor.py +++ b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentDataAccessor.py @@ -1,3 +1,4 @@ +from builtins import range import sys import logging import os.path diff --git a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentView.py b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentView.py index e02b0dbc17bfd..55521ba7c4a22 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentView.py +++ b/FWCore/GuiBrowsers/python/Vispa/Plugins/EdmBrowser/EventContentView.py @@ -1,3 +1,4 @@ +from builtins import range import logging from PyQt4.QtGui import * diff --git a/FWCore/GuiBrowsers/python/Vispa/Views/LineDecayView.py b/FWCore/GuiBrowsers/python/Vispa/Views/LineDecayView.py index 6c998eb85c88b..50893f6aad42c 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Views/LineDecayView.py +++ b/FWCore/GuiBrowsers/python/Vispa/Views/LineDecayView.py @@ -1,3 +1,4 @@ +from builtins import range import sys import math diff --git a/FWCore/GuiBrowsers/python/Vispa/Views/PropertyView.py b/FWCore/GuiBrowsers/python/Vispa/Views/PropertyView.py index c2ebb2fe63a4e..1208125df2dd1 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Views/PropertyView.py +++ b/FWCore/GuiBrowsers/python/Vispa/Views/PropertyView.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import logging import sys import os.path diff --git a/FWCore/GuiBrowsers/python/Vispa/Views/TableView.py b/FWCore/GuiBrowsers/python/Vispa/Views/TableView.py index 241dcbcc0b94c..5aecbb123f9c2 100644 --- a/FWCore/GuiBrowsers/python/Vispa/Views/TableView.py +++ b/FWCore/GuiBrowsers/python/Vispa/Views/TableView.py @@ -1,3 +1,4 @@ +from builtins import range import logging from PyQt4.QtGui import * diff --git a/FWCore/Modules/test/emptysource_cfg.py b/FWCore/Modules/test/emptysource_cfg.py index d16c351b86abb..28c4fee53e638 100644 --- a/FWCore/Modules/test/emptysource_cfg.py +++ b/FWCore/Modules/test/emptysource_cfg.py @@ -1,5 +1,6 @@ # Configuration file for EmptySource +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("TEST") @@ -22,7 +23,7 @@ numberOfEventsPerRun = process.source.numberEventsInRun.value() run = process.source.firstRun.value() event=0 -for i in xrange(process.maxEvents.input.value()): +for i in range(process.maxEvents.input.value()): numberOfEventsInRun +=1 event += 1 if numberOfEventsInRun > numberOfEventsPerRun: diff --git a/FWCore/Modules/test/emptysource_firstLuminosityBlockForEachRun_cfg.py b/FWCore/Modules/test/emptysource_firstLuminosityBlockForEachRun_cfg.py index 2c1c31e1395ff..44757daa0aa9e 100644 --- a/FWCore/Modules/test/emptysource_firstLuminosityBlockForEachRun_cfg.py +++ b/FWCore/Modules/test/emptysource_firstLuminosityBlockForEachRun_cfg.py @@ -1,5 +1,6 @@ # Configuration file for EmptySource +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("TEST") @@ -34,7 +35,7 @@ def findRunForLumi( lumi) : lumi = process.source.firstLuminosityBlock.value() event=0 oldRun = 2 -for i in xrange(process.maxEvents.input.value()): +for i in range(process.maxEvents.input.value()): numberOfEventsInLumi +=1 event += 1 run = findRunForLumi(lumi) diff --git a/FWCore/Modules/test/testBunchCrossingFilter.py b/FWCore/Modules/test/testBunchCrossingFilter.py index 459fe009d9b32..c50d2fa360c4c 100644 --- a/FWCore/Modules/test/testBunchCrossingFilter.py +++ b/FWCore/Modules/test/testBunchCrossingFilter.py @@ -22,6 +22,7 @@ # 3275-3322, 3330-3377, 3385-3432 # (see https://lpc.web.cern.ch/fillingSchemes/2018/25ns_2556b_2544_2215_2332_144bpi_20injV2.csv) +from builtins import range import FWCore.ParameterSet.Config as cms from FWCore.ParameterSet.pfnInPath import * @@ -51,7 +52,7 @@ # full range of possible bunch crossings [1,3564] process.selectAll = _bunchCrossingFilter.clone( - bunches = cms.vuint32(range(1,3565)) + bunches = cms.vuint32(list(range(1,3565))) ) # select bx 536 @@ -61,7 +62,7 @@ # select the whole train 514-561 process.selectTrain = _bunchCrossingFilter.clone( - bunches = cms.vuint32(range(514,562)) + bunches = cms.vuint32(list(range(514,562))) ) # inverted to veto (non-colliding) bx 1 diff --git a/FWCore/ParameterSet/python/Mixins.py b/FWCore/ParameterSet/python/Mixins.py index db0eacc0e4d6a..b85816b351047 100644 --- a/FWCore/ParameterSet/python/Mixins.py +++ b/FWCore/ParameterSet/python/Mixins.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import inspect import six @@ -744,7 +745,7 @@ def testListConstruction(self): def testLargeList(self): #lists larger than 255 entries can not be initialized #using the constructor - args = [i for i in xrange(0,300)] + args = [i for i in range(0,300)] t = TestList(*args) pdump= t.dumpPython() @@ -826,7 +827,7 @@ class __DummyModule(object): def __init__(self): self.tLPTest = tLPTest self.tLPTestType = tLPTestType - p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in xrange(0,300) ] ) ) + p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) ) #check they are the same self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython()) def testSpecialImportRegistry(self): diff --git a/FWCore/ParameterSet/python/SequenceTypes.py b/FWCore/ParameterSet/python/SequenceTypes.py index 8c27930a41869..f9518a9686694 100644 --- a/FWCore/ParameterSet/python/SequenceTypes.py +++ b/FWCore/ParameterSet/python/SequenceTypes.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +from builtins import range from .Mixins import _ConfigureComponent, PrintOptions from .Mixins import _Labelable, _Unlabelable from .Mixins import _ValidatingParameterListBase @@ -195,7 +196,7 @@ def __init__(self,*arg, **argv): typename = format_typename(self) msg = format_outerframe(2) msg += "The %s constructor takes zero or one sequenceable argument followed by zero or more arguments of type Task. But the following types are given:\n" %typename - for item,i in zip(arg, xrange(1,20)): + for item,i in zip(arg, range(1,20)): try: msg += " %i) %s \n" %(i, item._errorstr()) except: diff --git a/FWCore/ParameterSet/python/TreeCrawler.py b/FWCore/ParameterSet/python/TreeCrawler.py index 59f5dea4acf1d..baa4b52b8ed23 100755 --- a/FWCore/ParameterSet/python/TreeCrawler.py +++ b/FWCore/ParameterSet/python/TreeCrawler.py @@ -24,6 +24,7 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from builtins import range import sys, os, inspect, copy, struct, dis, imp import modulefinder import six @@ -252,7 +253,7 @@ def removeRecursiveLoops( node, verbose=False, currentStack=None ) : duplicateIndex=currentStack.index( node ) # If there isn't a recursive loop this will raise a ValueError if verbose : print("Removing recursive loop in:") - for index in xrange(duplicateIndex,len(currentStack)) : + for index in range(duplicateIndex,len(currentStack)) : print(" ",currentStack[index].name,"-->") print(" ",node.name) currentStack[-1].dependencies.remove(node) diff --git a/FWCore/PythonUtilities/python/LumiList.py b/FWCore/PythonUtilities/python/LumiList.py index 52b123e4d22b8..d653f37345ce3 100644 --- a/FWCore/PythonUtilities/python/LumiList.py +++ b/FWCore/PythonUtilities/python/LumiList.py @@ -10,6 +10,7 @@ """ +from builtins import range import copy import json import re diff --git a/FWCore/PythonUtilities/scripts/generateEDF.py b/FWCore/PythonUtilities/scripts/generateEDF.py index 81e6b5d39364d..b867e92109ace 100755 --- a/FWCore/PythonUtilities/scripts/generateEDF.py +++ b/FWCore/PythonUtilities/scripts/generateEDF.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import sys import re import optparse diff --git a/FWCore/Skeletons/python/cms.py b/FWCore/Skeletons/python/cms.py index 2f9e36a0de183..36e7ca0248b95 100644 --- a/FWCore/Skeletons/python/cms.py +++ b/FWCore/Skeletons/python/cms.py @@ -9,6 +9,7 @@ from __future__ import print_function # system modules +from builtins import range import os import sys @@ -26,7 +27,7 @@ def config(tmpl, pkg_help, tmpl_dir): print(pkg_help) sys.exit(0) kwds['pname'] = sys.argv[1] - for idx in xrange(2, len(sys.argv)): + for idx in range(2, len(sys.argv)): opt = sys.argv[idx] if opt == '-author': kwds['author'] = sys.argv[idx+1] diff --git a/FWCore/Skeletons/python/utils.py b/FWCore/Skeletons/python/utils.py index 8805a961bd560..64a43dfaa921b 100644 --- a/FWCore/Skeletons/python/utils.py +++ b/FWCore/Skeletons/python/utils.py @@ -9,6 +9,7 @@ from __future__ import print_function # system modules +from builtins import range import os import re import sys @@ -23,7 +24,7 @@ def parse_word(word): "Parse word which contas double underscore tag" output = set() words = word.split() - for idx in xrange(0, len(words)): + for idx in range(0, len(words)): pat = words[idx] if pat and len(pat) > 4 and pat[:2] == '__': # we found enclosure tag = pat[2:pat.rfind('__')] diff --git a/Utilities/RelMon/python/directories2html.py b/Utilities/RelMon/python/directories2html.py index b5c3a610b57c9..61566bcff4e84 100755 --- a/Utilities/RelMon/python/directories2html.py +++ b/Utilities/RelMon/python/directories2html.py @@ -11,6 +11,7 @@ # ################################################################################ +from builtins import range from os import chdir,getcwd,listdir,makedirs from os.path import basename,join,exists import cgi @@ -379,7 +380,7 @@ def get_rank_section(directory): h=directory.rank_histo rank_histof=TH1F(h.GetName(),"",h.GetNbinsX(),h.GetXaxis().GetXmin(),h.GetXaxis().GetXmax()) rank_histof.SetLineWidth(2) - for i in xrange(0,h.GetNbinsX()+1): + for i in range(0,h.GetNbinsX()+1): rank_histof.SetBinContent(i,h.GetBinContent(i)) h.SetTitle("Ranks Summary;Rank;Frequency") h.Draw("Hist") @@ -804,14 +805,14 @@ def make_summary_table(indir,aggregation_rules,aggregation_rules_twiki, hashing_ page_html+='
Top...
' # Barbarian vertical space. Suggestions are welcome - for i in xrange(2): + for i in range(2): page_html+='

\n' # Prepare the table page_html+='' - for i in xrange(5): + for i in range(5): page_html+='

\n' page_html+=""" diff --git a/Utilities/RelMon/python/dirstructure.py b/Utilities/RelMon/python/dirstructure.py index a484da4f9da60..ffb3b460361aa 100755 --- a/Utilities/RelMon/python/dirstructure.py +++ b/Utilities/RelMon/python/dirstructure.py @@ -10,6 +10,7 @@ # ################################################################################ +from builtins import range from array import array from copy import deepcopy from os import chdir,getcwd,listdir,makedirs,rmdir @@ -384,7 +385,7 @@ def tcanvas_slow(self,canvas): n_proc=len(tcanvas_print_processes) if n_proc>3: p_to_remove=[] - for iprocess in xrange(0,n_proc): + for iprocess in range(0,n_proc): p=tcanvas_print_processes[iprocess] p.join() p_to_remove.append(iprocess) diff --git a/Utilities/RelMon/python/dqm_interfaces.py b/Utilities/RelMon/python/dqm_interfaces.py index e8f2377c31c90..0d48a35cc04ea 100755 --- a/Utilities/RelMon/python/dqm_interfaces.py +++ b/Utilities/RelMon/python/dqm_interfaces.py @@ -10,6 +10,7 @@ # ################################################################################ +from builtins import range from copy import deepcopy from os import chdir,getcwd,makedirs from os.path import abspath,exists,join, basename @@ -111,7 +112,7 @@ def ls_url(self, url): raw_folder=eval(self.get_data(url)) except: print("Retrying..") - for ntrials in xrange(5): + for ntrials in range(5): try: if ntrials!=0: sleep(2) diff --git a/Utilities/RelMon/python/utils.py b/Utilities/RelMon/python/utils.py index 5ee8126a1f845..ad421b50a7883 100755 --- a/Utilities/RelMon/python/utils.py +++ b/Utilities/RelMon/python/utils.py @@ -11,6 +11,7 @@ ################################################################################ +from builtins import range import array import os import re @@ -167,7 +168,7 @@ def do_test(self): #------------------------------------------------------------------------------- def is_empty(h): - for i in xrange(1,getNbins(h)): + for i in range(1,getNbins(h)): if h.GetBinContent(i)!=0: return False return True #return h.GetSumOfWeights()==0 @@ -177,7 +178,7 @@ def is_empty(h): def is_sparse(h): filled_bins=0. nbins=h.GetNbinsX() - for ibin in xrange(nbins): + for ibin in range(nbins): if h.GetBinContent(ibin)>0: filled_bins+=1 #print "%s %s --> %s" %(filled_bins,nbins,filled_bins/nbins) @@ -222,11 +223,11 @@ def profile2histo(profile): bin_low_edges=[] n_bins=profile.GetNbinsX() - for ibin in xrange(1,n_bins+2): + for ibin in range(1,n_bins+2): bin_low_edges.append(profile.GetBinLowEdge(ibin)) bin_low_edges=array.array('f',bin_low_edges) histo=TH1F(profile.GetName(),profile.GetTitle(),n_bins,bin_low_edges) - for ibin in xrange(0,n_bins+1): + for ibin in range(0,n_bins+1): histo.SetBinContent(ibin,profile.GetBinContent(ibin)) histo.SetBinError(ibin,profile.GetBinError(ibin)) @@ -243,7 +244,7 @@ def check_filled_bins(self,min_filled): n_filled_l=[] for h in self.h1,self.h2: nfilled=0. - for ibin in xrange(1,nbins+1): + for ibin in range(1,nbins+1): if h.GetBinContent(ibin)>0: nfilled+=1 n_filled_l.append(nfilled) @@ -252,7 +253,7 @@ def check_filled_bins(self,min_filled): def absval(self): nbins=getNbins(self.h1) binc=0 - for i in xrange(1,nbins): + for i in range(1,nbins): for h in self.h1,self.h2: binc=h.GetBinContent(i) if binc<0: @@ -328,7 +329,7 @@ def do_test(self): equal = 1 nbins = getNbins(self.h1) n_ok_bins=0.0 - for ibin in xrange(0, nbins+2): + for ibin in range(0, nbins+2): h1bin=self.h1.GetBinContent(ibin) h2bin=self.h2.GetBinContent(ibin) bindiff=h1bin-h2bin @@ -386,7 +387,7 @@ def do_test(self): equal = 1 nbins = getNbins(self.h1) n_ok_bins=0.0 - for ibin in xrange(0,nbins): + for ibin in range(0,nbins): ibin+=1 h1bin=self.h1.GetBinContent(ibin) h2bin=self.h2.GetBinContent(ibin) diff --git a/Utilities/RelMon/python/utils_v2.py b/Utilities/RelMon/python/utils_v2.py index 0f8317e6a643d..65fa39b9d9abe 100755 --- a/Utilities/RelMon/python/utils_v2.py +++ b/Utilities/RelMon/python/utils_v2.py @@ -7,6 +7,7 @@ ''' from __future__ import print_function from __future__ import absolute_import +from builtins import range import sys import re import time @@ -310,7 +311,7 @@ def get_N_bins(self, h): return (x + 1) * (y + 1) * (z + 1) def is_empty(self, h): - for i in xrange(1, self.get_N_bins(h)): + for i in range(1, self.get_N_bins(h)): if h.GetBinContent(i) != 0: return False return True @@ -347,7 +348,7 @@ class Chi2Test(StatisticalTest): name = 'Chi2' def make_absolute(self, h, bin_count): - for i in xrange(1, bin_count): # Why here is no +1? + for i in range(1, bin_count): # Why here is no +1? content = h.GetBinContent(i) if content < 0: h.SetBinContent(i, -1 * content) @@ -356,7 +357,7 @@ def make_absolute(self, h, bin_count): def enough_filled_bins(self, h, bin_count, more_than=3): filled_bins = 0 - for i in xrange(1, bin_count): + for i in range(1, bin_count): if h.GetBinContent(i) > 0: filled_bins += 1 if filled_bins > more_than: diff --git a/Utilities/RelMon/scripts/ValidationMatrix.py b/Utilities/RelMon/scripts/ValidationMatrix.py index fd7f9e2b925a1..a63b8aeb1481e 100755 --- a/Utilities/RelMon/scripts/ValidationMatrix.py +++ b/Utilities/RelMon/scripts/ValidationMatrix.py @@ -10,6 +10,7 @@ ################################################################################ from __future__ import print_function +from builtins import range from optparse import OptionParser import os @@ -219,7 +220,7 @@ def get_filenames_from_pool(all_samples): #files_list.sort(key=name2version) #files_list.sort(key=name2sample) #files_list.sort(key=name2run) - for iname in xrange(len(files_list)): + for iname in range(len(files_list)): filename=files_list[iname] if iname%2==0: ref_filenames.append(filename) diff --git a/Utilities/ReleaseScripts/python/cmsCodeRules/cppFunctionSkipper.py b/Utilities/ReleaseScripts/python/cmsCodeRules/cppFunctionSkipper.py index 3f54b0a5bd766..cea3aeffd9977 100644 --- a/Utilities/ReleaseScripts/python/cmsCodeRules/cppFunctionSkipper.py +++ b/Utilities/ReleaseScripts/python/cmsCodeRules/cppFunctionSkipper.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range __author__="Aurelija" __date__ ="$2010-09-23 15.00.20$" diff --git a/Utilities/ReleaseScripts/python/cmsCodeRules/keyFinder.py b/Utilities/ReleaseScripts/python/cmsCodeRules/keyFinder.py index 109754ce930e9..223b6a6c12c2e 100644 --- a/Utilities/ReleaseScripts/python/cmsCodeRules/keyFinder.py +++ b/Utilities/ReleaseScripts/python/cmsCodeRules/keyFinder.py @@ -1,3 +1,4 @@ +from builtins import range __author__="Aurelija" __date__ ="$Jul 12, 2010 10:08:20 AM$" diff --git a/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py b/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py index 306370bdf663a..531b79088e5b0 100755 --- a/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py +++ b/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range __author__="Aurelija" __date__ ="$2010-08-12 10.50.40$" diff --git a/Utilities/ReleaseScripts/python/commentSkipper/buildFileCommentSkipper.py b/Utilities/ReleaseScripts/python/commentSkipper/buildFileCommentSkipper.py index 5f1f9f315cb0e..02374f3e746b5 100644 --- a/Utilities/ReleaseScripts/python/commentSkipper/buildFileCommentSkipper.py +++ b/Utilities/ReleaseScripts/python/commentSkipper/buildFileCommentSkipper.py @@ -1,3 +1,4 @@ +from builtins import range __author__="Aurelija" __date__ ="$2010-07-20 11.52.22$" diff --git a/Utilities/ReleaseScripts/python/commentSkipper/cppCommentSkipper.py b/Utilities/ReleaseScripts/python/commentSkipper/cppCommentSkipper.py index cfc1359a4ea2c..c308152aaf018 100644 --- a/Utilities/ReleaseScripts/python/commentSkipper/cppCommentSkipper.py +++ b/Utilities/ReleaseScripts/python/commentSkipper/cppCommentSkipper.py @@ -1,3 +1,4 @@ +from builtins import range __author__="Aurelija" __date__ ="$2010-07-13 12.17.20$" diff --git a/Utilities/ReleaseScripts/scripts/addOnTests.py b/Utilities/ReleaseScripts/scripts/addOnTests.py index 5d4c1d9eec397..19f23a2e824e0 100755 --- a/Utilities/ReleaseScripts/scripts/addOnTests.py +++ b/Utilities/ReleaseScripts/scripts/addOnTests.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os import time import sys diff --git a/Utilities/ReleaseScripts/scripts/cmsCodeRulesChecker.py b/Utilities/ReleaseScripts/scripts/cmsCodeRulesChecker.py index f7d9f3d924e87..d643291af9e6e 100755 --- a/Utilities/ReleaseScripts/scripts/cmsCodeRulesChecker.py +++ b/Utilities/ReleaseScripts/scripts/cmsCodeRulesChecker.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range __author__="Aurelija" __date__ ="$2010-07-14 16.48.55$" diff --git a/Utilities/ReleaseScripts/scripts/storeTreeInfo.py b/Utilities/ReleaseScripts/scripts/storeTreeInfo.py index e36a8c5beab2d..9437cd3d7dace 100755 --- a/Utilities/ReleaseScripts/scripts/storeTreeInfo.py +++ b/Utilities/ReleaseScripts/scripts/storeTreeInfo.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os, sys, stat from operator import itemgetter diff --git a/Utilities/StaticAnalyzers/scripts/statics.py b/Utilities/StaticAnalyzers/scripts/statics.py index 290b9bca2acf5..ead35666c5211 100755 --- a/Utilities/StaticAnalyzers/scripts/statics.py +++ b/Utilities/StaticAnalyzers/scripts/statics.py @@ -1,5 +1,6 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import re topfunc = re.compile("::(produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream|streamBeginRun|streamBeginLuminosityBlock|streamEndRun|streamEndLuminosityBlock|globalBeginRun|globalEndRun|globalBeginLuminosityBlock|globalEndLuminosityBlock|endRun|endLuminosityBlock)\(") baseclass = re.compile("edm::(one::|stream::|global::)?ED(Producer|Filter|Analyzer)(Base)?") From af7a3a733ba05a7b2780197c4a32f2363e2bda31 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 20:26:03 +0200 Subject: [PATCH 534/686] xrange mig --- .../analyzers/core/AutoFillTreeProducer.py | 3 ++- .../analyzers/core/ProvenanceAnalyzer.py | 3 ++- .../Heppy/python/analyzers/core/autovars.py | 7 +++--- .../analyzers/eventtopology/MT2Analyzer.py | 1 + .../python/analyzers/gen/GeneratorAnalyzer.py | 9 ++++--- .../Heppy/python/analyzers/gen/LHEAnalyzer.py | 3 ++- .../python/analyzers/objects/JetAnalyzer.py | 1 + .../analyzers/objects/LeptonAnalyzer.py | 3 ++- .../Heppy/python/physicsobjects/Jet.py | 1 + .../python/physicsutils/JetReCalibrator.py | 3 ++- .../physicsutils/QGLikelihoodCalculator.py | 1 + .../Heppy/python/physicsutils/genutils.py | 9 ++++--- PhysicsTools/Heppy/scripts/cmsBatch.py | 1 + .../Heppy/scripts/cmsStageWithFailover.py | 3 ++- PhysicsTools/Heppy/scripts/heppy_report.py | 3 ++- .../Heppy/test/crab/heppy_crab_script.py | 3 ++- .../HeppyCore/python/framework/heppy_loop.py | 3 ++- .../HeppyCore/python/framework/looper.py | 1 + .../HeppyCore/python/statistics/counter.py | 1 + .../HeppyCore/python/utils/dataset.py | 3 ++- .../HeppyCore/python/utils/dataset_test.py | 1 + .../python/utils/edmIntegrityCheck.py | 3 ++- .../python/utils/production_tasks.py | 3 ++- .../HeppyCore/python/utils/testtree.py | 1 + PhysicsTools/HeppyCore/scripts/heppy_batch.py | 3 ++- PhysicsTools/NanoAOD/test/inspectNanoFile.py | 3 ++- .../python/tools/cmsswVersionTools.py | 1 + .../PatAlgos/python/tools/coreTools.py | 1 + .../PatAlgos/python/tools/trigTools.py | 1 + .../test/miniAOD/example_packedCandidates.py | 5 ++-- .../python/ParticleDecayDrawer.py | 11 ++++---- .../PythonAnalysis/python/cmstools.py | 7 +++--- .../PythonAnalysis/python/diffProv.py | 1 + .../PythonAnalysis/python/diff_provenance.py | 1 + .../PythonAnalysis/python/iterators.py | 3 ++- .../PythonAnalysis/python/rootplot/core.py | 25 ++++++++++--------- .../python/rootplot/root2matplotlib.py | 3 ++- .../python/rootplot/rootinfo.py | 5 ++-- .../python/rootplot/rootmath.py | 1 + .../python/rootplot/utilities.py | 11 ++++---- .../PythonAnalysis/test/testHistogrammar.py | 3 ++- PhysicsTools/PythonAnalysis/test/testNumba.py | 1 + .../PythonAnalysis/test/testRootpy.py | 1 + .../PythonAnalysis/test/testhep_ml.py | 1 + .../TagAndProbe/test/utilities/dumpPileup.py | 3 ++- .../PerformanceDB/test/plotPerformanceDB.py | 5 ++-- .../LumiDB/plotdata/checklumidiff.py | 3 ++- .../plotdata/create_public_lumi_plots.py | 9 ++++--- .../plotdata/create_public_pileup_plots.py | 7 +++--- RecoLuminosity/LumiDB/python/CommonUtil.py | 1 + RecoLuminosity/LumiDB/python/dataDML.py | 1 + RecoLuminosity/LumiDB/python/dbUtil.py | 1 + .../LumiDB/python/generateDummyData.py | 1 + RecoLuminosity/LumiDB/python/lumiCalcAPI.py | 3 ++- RecoLuminosity/LumiDB/python/lumiReport.py | 1 + RecoLuminosity/LumiDB/python/lumidbDDL.py | 1 + RecoLuminosity/LumiDB/python/matplotRender.py | 7 +++--- .../LumiDB/python/mpl_axes_hist_fix.py | 7 +++--- RecoLuminosity/LumiDB/python/pyrootRender.py | 1 + .../LumiDB/python/queryDataSource.py | 1 + .../LumiDB/python/selectionParser.py | 1 + RecoLuminosity/LumiDB/python/wordWrappers.py | 3 ++- .../LumiDB/scripts/estimatePileup.py | 3 ++- .../LumiDB/scripts/estimatePileup2.py | 1 + RecoLuminosity/LumiDB/scripts/lumiPatch.py | 1 + RecoLuminosity/LumiDB/scripts/pileupCalc.py | 1 + RecoLuminosity/LumiDB/test/bunchanalysis.py | 1 + RecoLuminosity/LumiDB/test/dumptrgmask.py | 1 + .../LumiDB/test/patchkit/analyze148829.py | 3 ++- .../LumiDB/test/patchkit/analyzelostruns.py | 3 ++- .../LumiDB/test/patchkit/csvLumiLoader.py | 1 + .../LumiDB/test/patchkit/generateFakeLumi.py | 1 + .../LumiDB/test/patchkit/patchHLT.py | 3 ++- .../LumiDB/test/patchkit/patchinstlumi.py | 3 ++- RecoLuminosity/LumiDB/test/pixelLumiLoader.py | 1 + RecoLuminosity/LumiDB/test/pyrootLumi.py | 1 + .../python/GenerateHcalLaserBadRunList.py | 1 + .../python/badGlobalMuonTaggerFWLite.py | 5 ++-- .../python/tools/DisplayManager.py | 1 + .../Configuration/test/compareTauVariables.py | 9 ++++--- .../TauTagTools/test/training/castor.py | 5 ++-- .../test/training/computeTransform.py | 1 + .../test/training/make_eval_plots.py | 1 + .../skimming/buildBackgroundDataSet_cfg.py | 1 + .../skimming/buildSignalDataSet_cfg.py | 1 + .../test/training/training_control_plots.py | 1 + .../scripts/BeamSpotWorkflow.py | 1 + .../BeamSpotProducer/scripts/CommonMethods.py | 1 + .../scripts/beamvalidation.py | 1 + .../BeamSpotProducer/scripts/checkRuns.py | 1 + .../BeamSpotProducer/scripts/createPayload.py | 1 + .../BeamSpotProducer/scripts/ntuplemaker.py | 1 + .../scripts/plotBeamSpotDB.py | 1 + RecoVertex/BeamSpotProducer/scripts/rename.py | 1 + .../root/BxAnalysis/lumiregperbunch.py | 1 + .../test/scripts/AnalyzeLumiScan.py | 1 + .../test/scripts/PlotLumiScan.py | 1 + .../BeamSpotProducer/test/scripts/pv.py | 3 ++- 98 files changed, 188 insertions(+), 90 deletions(-) diff --git a/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py b/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py index c6a7f868b1af6..b93b339ea845f 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py @@ -1,3 +1,4 @@ +from builtins import range from PhysicsTools.Heppy.analyzers.core.TreeAnalyzerNumpy import TreeAnalyzerNumpy from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle #from ROOT import TriggerBitChecker @@ -168,7 +169,7 @@ def fillTree(self, event, resetFirst=True): if isinstance(c, tuple) and isinstance(c[0], AutoHandle): if not isMC and c[-1].mcOnly: continue objects = self.handles[cn].product() - setattr(event, cn, [objects[i] for i in xrange(objects.size())]) + setattr(event, cn, [objects[i] for i in range(objects.size())]) c = c[-1] if not isMC and c.mcOnly: continue if self.scalar: diff --git a/PhysicsTools/Heppy/python/analyzers/core/ProvenanceAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/core/ProvenanceAnalyzer.py index f8caef84a5d14..ab61f6b1bc819 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/ProvenanceAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/ProvenanceAnalyzer.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import itertools from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer @@ -52,7 +53,7 @@ def process(self, event): if eid != self.lastId: #import pdb; pdb.set_trace() history = event.input.object().processHistory() - for i in reversed(range(history.size())): + for i in reversed(list(range(history.size()))): conf = history.at(i) release = conf.releaseVersion().replace('"',"") vnums = self.cmsswVNums(release) diff --git a/PhysicsTools/Heppy/python/analyzers/core/autovars.py b/PhysicsTools/Heppy/python/analyzers/core/autovars.py index 6e072003d6720..f17658433dbf8 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/autovars.py +++ b/PhysicsTools/Heppy/python/analyzers/core/autovars.py @@ -6,6 +6,7 @@ # # TODO: more documentation needed here! +from builtins import range class NTupleVariable: """Branch containing an individual variable (either of the event or of an object), created with a name and a function to compute it - name, type, help, default: obvious @@ -174,7 +175,7 @@ def makeBranchesScalar(self,treeNumpy,isMC): treeNumpy.var("n"+self.name, int) allvars = self.objectType.allVars(isMC) for v in allvars: - for i in xrange(1,self.maxlen+1): + for i in range(1,self.maxlen+1): h = v.help if self.help: h = "%s for %s [%d]" % ( h if h else v.name, self.help, i-1 ) treeNumpy.var("%s%d_%s" % (self.name, i, v.name), type=v.type, default=v.default, title=h, filler=v.filler) @@ -195,7 +196,7 @@ def fillBranchesScalar(self,treeNumpy,collection,isMC): num = min(self.maxlen,len(collection)) treeNumpy.fill("n"+self.name, num) allvars = self.objectType.allVars(isMC) - for i in xrange(num): + for i in range(num): o = collection[i] for v in allvars: treeNumpy.fill("%s%d_%s" % (self.name, i+1, v.name), v(o)) @@ -209,7 +210,7 @@ def fillBranchesVector(self,treeNumpy,collection,isMC): allvars = self.objectType.allVars(isMC) for v in allvars: name="%s_%s" % (self.name, v.name) if v.name != "" else self.name - treeNumpy.vfill(name, [ v(collection[i]) for i in xrange(num) ]) + treeNumpy.vfill(name, [ v(collection[i]) for i in range(num) ]) def __repr__(self): return "" % self.name diff --git a/PhysicsTools/Heppy/python/analyzers/eventtopology/MT2Analyzer.py b/PhysicsTools/Heppy/python/analyzers/eventtopology/MT2Analyzer.py index 86a590032abdf..d2e309dbc7b5e 100644 --- a/PhysicsTools/Heppy/python/analyzers/eventtopology/MT2Analyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/eventtopology/MT2Analyzer.py @@ -1,3 +1,4 @@ +from builtins import range import operator import itertools import copy diff --git a/PhysicsTools/Heppy/python/analyzers/gen/GeneratorAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/gen/GeneratorAnalyzer.py index af8ac538484d5..64ff16a6f9798 100644 --- a/PhysicsTools/Heppy/python/analyzers/gen/GeneratorAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/gen/GeneratorAnalyzer.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle from PhysicsTools.Heppy.physicsutils.genutils import isNotFromHadronicShower, realGenMothers, realGenDaughters @@ -84,12 +85,12 @@ def makeMCInfo(self, event): # " ".join("%d[%d]" % (p.daughter(i).pdgId(), p.daughter(i).status()) for i in xrange(p.numberOfDaughters()))) if id in self.savePreFSRParticleIds: # for light objects, we want them pre-radiation - if any((p.mother(j).pdgId() == p.pdgId()) for j in xrange(p.numberOfMothers())): + if any((p.mother(j).pdgId() == p.pdgId()) for j in range(p.numberOfMothers())): #print " fail auto-decay" continue else: # everything else, we want it after radiation, i.e. just before decay - if any((p.daughter(j).pdgId() == p.pdgId() and p.daughter(j).status() > 2) for j in xrange(p.numberOfDaughters())): + if any((p.daughter(j).pdgId() == p.pdgId() and p.daughter(j).status() > 2) for j in range(p.numberOfDaughters())): #print " fail auto-decay" continue # FIXME find a better criterion to discard there @@ -110,7 +111,7 @@ def makeMCInfo(self, event): if interestingPdgId(mom.pdgId()) or (getattr(mom,'rawIndex',-1) in keymap): #print " interesting mom" # exclude extra x from p -> p + x - if not any(mom.daughter(j2).pdgId() == mom.pdgId() for j2 in xrange(mom.numberOfDaughters())): + if not any(mom.daughter(j2).pdgId() == mom.pdgId() for j2 in range(mom.numberOfDaughters())): #print " pass no-self-decay" ok = True # Account for generator feature with Higgs decaying to itself with same four-vector but no daughters @@ -170,7 +171,7 @@ def makeMCInfo(self, event): print("%3d {%6d}: %+8d %3d : %8.2f %+5.2f %+5.2f : %d %2d : %+8d {%3d}: %s" % ( ip,p.rawIndex, p.pdgId(), p.status(), p.pt(), p.eta(), p.phi(), len(moms), p.numberOfDaughters(), p.motherId, p.motherIndex, - " ".join("%d[%d]" % (p.daughter(i).pdgId(), p.daughter(i).status()) for i in xrange(p.numberOfDaughters())))) + " ".join("%d[%d]" % (p.daughter(i).pdgId(), p.daughter(i).status()) for i in range(p.numberOfDaughters())))) if verbose: print("\n\n") diff --git a/PhysicsTools/Heppy/python/analyzers/gen/LHEAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/gen/LHEAnalyzer.py index 3b1edb09ffff3..d4d8d45bfa3ca 100644 --- a/PhysicsTools/Heppy/python/analyzers/gen/LHEAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/gen/LHEAnalyzer.py @@ -1,3 +1,4 @@ +from builtins import range from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle import PhysicsTools.HeppyCore.framework.config as cfg @@ -43,7 +44,7 @@ def process(self, event): lBar=None nu=None nuBar=None - for i in xrange(0,len(pup)): + for i in range(0,len(pup)): id=hepeup.IDUP[i] status = hepeup.ISTUP[i] idabs=abs(id) diff --git a/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py index 9855d68aeaf30..8ded7decb79b1 100644 --- a/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import math, os from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle diff --git a/PhysicsTools/Heppy/python/analyzers/objects/LeptonAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/objects/LeptonAnalyzer.py index 65777766f317c..5560f7eca56f2 100644 --- a/PhysicsTools/Heppy/python/analyzers/objects/LeptonAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/objects/LeptonAnalyzer.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle from PhysicsTools.Heppy.physicsobjects.Electron import Electron @@ -543,7 +544,7 @@ def plausible(rec,gen): lep.mcLep=gen def isFromB(self,particle,bid=5, done={}): - for i in xrange( particle.numberOfMothers() ): + for i in range( particle.numberOfMothers() ): mom = particle.mother(i) momid = abs(mom.pdgId()) if momid / 1000 == bid or momid / 100 == bid or momid == bid: diff --git a/PhysicsTools/Heppy/python/physicsobjects/Jet.py b/PhysicsTools/Heppy/python/physicsobjects/Jet.py index 2faa9b265b131..376d1f27d3a2f 100644 --- a/PhysicsTools/Heppy/python/physicsobjects/Jet.py +++ b/PhysicsTools/Heppy/python/physicsobjects/Jet.py @@ -1,3 +1,4 @@ +from builtins import range from PhysicsTools.Heppy.physicsobjects.PhysicsObject import * from PhysicsTools.HeppyCore.utils.deltar import deltaPhi import math diff --git a/PhysicsTools/Heppy/python/physicsutils/JetReCalibrator.py b/PhysicsTools/Heppy/python/physicsutils/JetReCalibrator.py index 598900061baed..e2bb4911af36d 100644 --- a/PhysicsTools/Heppy/python/physicsutils/JetReCalibrator.py +++ b/PhysicsTools/Heppy/python/physicsutils/JetReCalibrator.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT import os, types from math import * @@ -88,7 +89,7 @@ def rawP4forType1MET_(self, jet): if emf > self.type1METParams['skipEMfractionThreshold']: return None if self.type1METParams['skipMuons']: - for idau in xrange(jet.numberOfDaughters()): + for idau in range(jet.numberOfDaughters()): pfcand = jet.daughter(idau) if pfcand.isGlobalMuon() or pfcand.isStandAloneMuon(): p4 -= pfcand.p4() diff --git a/PhysicsTools/Heppy/python/physicsutils/QGLikelihoodCalculator.py b/PhysicsTools/Heppy/python/physicsutils/QGLikelihoodCalculator.py index 09a76a107d5e3..3adc2fab81510 100644 --- a/PhysicsTools/Heppy/python/physicsutils/QGLikelihoodCalculator.py +++ b/PhysicsTools/Heppy/python/physicsutils/QGLikelihoodCalculator.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT import math diff --git a/PhysicsTools/Heppy/python/physicsutils/genutils.py b/PhysicsTools/Heppy/python/physicsutils/genutils.py index 6f13ea250f42a..21115a8ca6357 100644 --- a/PhysicsTools/Heppy/python/physicsutils/genutils.py +++ b/PhysicsTools/Heppy/python/physicsutils/genutils.py @@ -1,3 +1,4 @@ +from builtins import range from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import printOut from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import GenParticle @@ -63,7 +64,7 @@ def isPromptLepton(lepton, beforeFSR, includeMotherless=True, includeTauDecays=F def isNotFromHadronicShower(l): - for x in xrange(l.numberOfMothers()): + for x in range(l.numberOfMothers()): mom = l.mother(x) if mom.status() > 2: return True id = abs(mom.pdgId()) @@ -85,7 +86,7 @@ def realGenDaughters(gp,excludeRadiation=True): realGenDaughters(X, excludeRadiation=True) = { b, c } realGenDaughters(X, excludeRadiation=False) = { a, b, c }""" ret = [] - for i in xrange(gp.numberOfDaughters()): + for i in range(gp.numberOfDaughters()): dau = gp.daughter(i) if dau.pdgId() == gp.pdgId(): if excludeRadiation: @@ -100,7 +101,7 @@ def realGenMothers(gp): """Get the mothers of a particle X going through intermediate X -> X' chains. e.g. if Y -> X, X -> X' realGenMothers(X') = Y""" ret = [] - for i in xrange(gp.numberOfMothers()): + for i in range(gp.numberOfMothers()): mom = gp.mother(i) if mom.pdgId() == gp.pdgId(): ret += realGenMothers(mom) @@ -110,7 +111,7 @@ def realGenMothers(gp): def lastGenCopy(gp): me = gp.pdgId(); - for i in xrange(gp.numberOfDaughters()): + for i in range(gp.numberOfDaughters()): if gp.daughter(i).pdgId() == me: return False return True diff --git a/PhysicsTools/Heppy/scripts/cmsBatch.py b/PhysicsTools/Heppy/scripts/cmsBatch.py index d1efd93f91942..770e3df20f92c 100755 --- a/PhysicsTools/Heppy/scripts/cmsBatch.py +++ b/PhysicsTools/Heppy/scripts/cmsBatch.py @@ -3,6 +3,7 @@ # batch mode for cmsRun, March 2009 from __future__ import print_function +from builtins import range import os, sys, imp, re, pprint, string, time,shutil,copy,pickle,math from optparse import OptionParser diff --git a/PhysicsTools/Heppy/scripts/cmsStageWithFailover.py b/PhysicsTools/Heppy/scripts/cmsStageWithFailover.py index d5bcbd696f764..9fa2f37a856b4 100755 --- a/PhysicsTools/Heppy/scripts/cmsStageWithFailover.py +++ b/PhysicsTools/Heppy/scripts/cmsStageWithFailover.py @@ -3,6 +3,7 @@ #this script runs cmsStage multiple times in the case where it failes for some reason from __future__ import print_function +from builtins import range if __name__ == '__main__': import PhysicsTools.HeppyCore.utils.eostools as eostools @@ -31,7 +32,7 @@ sleep_lengths = [1,10,60,600,1800] return_code = 0 - for i in xrange(5): + for i in range(5): #sleep for a while before running time.sleep(sleep_lengths[i]) diff --git a/PhysicsTools/Heppy/scripts/heppy_report.py b/PhysicsTools/Heppy/scripts/heppy_report.py index 7181b3be29dd2..b4e964d526c5c 100755 --- a/PhysicsTools/Heppy/scripts/heppy_report.py +++ b/PhysicsTools/Heppy/scripts/heppy_report.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range from optparse import OptionParser import json import six @@ -15,7 +16,7 @@ def root2map(dir,ana,treename): print("Error: rootfile %s/%s/%s.root does not contain a TTree %s" % (dir,ana,treename,treename)) return None jsonind = {} - for e in xrange(tree.GetEntries()): + for e in range(tree.GetEntries()): tree.GetEntry(e) run,lumi = tree.run, tree.lumi if run not in jsonind: diff --git a/PhysicsTools/Heppy/test/crab/heppy_crab_script.py b/PhysicsTools/Heppy/test/crab/heppy_crab_script.py index 03947045ca0ec..906474c12894f 100755 --- a/PhysicsTools/Heppy/test/crab/heppy_crab_script.py +++ b/PhysicsTools/Heppy/test/crab/heppy_crab_script.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os # probably easier to fetch everything without subdirs, but that's up to user preferences #import PhysicsTools.HeppyCore.framework.config as cfg @@ -14,7 +15,7 @@ print(crabFiles) firstInput = crabFiles[0] print("--------------- using edmFileUtil to convert PFN to LFN -------------------------") -for i in xrange(0,len(crabFiles)) : +for i in range(0,len(crabFiles)) : pfn=os.popen("edmFileUtil -d %s"%(crabFiles[i])).read() pfn=re.sub("\n","",pfn) print(crabFiles[i],"->",pfn) diff --git a/PhysicsTools/HeppyCore/python/framework/heppy_loop.py b/PhysicsTools/HeppyCore/python/framework/heppy_loop.py index 9257f4e4908d6..4e8bceae7ce20 100755 --- a/PhysicsTools/HeppyCore/python/framework/heppy_loop.py +++ b/PhysicsTools/HeppyCore/python/framework/heppy_loop.py @@ -3,6 +3,7 @@ # https://github.com/cbernet/heppy/blob/master/LICENSE from __future__ import print_function +from builtins import range import os import shutil import glob @@ -99,7 +100,7 @@ def split(comps): splitComps = [] for comp in comps: if hasattr( comp, 'fineSplitFactor') and comp.fineSplitFactor>1: - subchunks = range(comp.fineSplitFactor) + subchunks = list(range(comp.fineSplitFactor)) for ichunk, chunk in enumerate([(f,i) for f in comp.files for i in subchunks]): newComp = copy.deepcopy(comp) newComp.files = [chunk[0]] diff --git a/PhysicsTools/HeppyCore/python/framework/looper.py b/PhysicsTools/HeppyCore/python/framework/looper.py index 0146a507ce657..45c9956a5cbad 100644 --- a/PhysicsTools/HeppyCore/python/framework/looper.py +++ b/PhysicsTools/HeppyCore/python/framework/looper.py @@ -3,6 +3,7 @@ # Copyright (C) 2014 Colin Bernet # https://github.com/cbernet/heppy/blob/master/LICENSE +from builtins import range import os import sys import imp diff --git a/PhysicsTools/HeppyCore/python/statistics/counter.py b/PhysicsTools/HeppyCore/python/statistics/counter.py index b461f5b3c0b44..0ef9e45bd8edc 100644 --- a/PhysicsTools/HeppyCore/python/statistics/counter.py +++ b/PhysicsTools/HeppyCore/python/statistics/counter.py @@ -1,6 +1,7 @@ # Copyright (C) 2014 Colin Bernet # https://github.com/cbernet/heppy/blob/master/LICENSE +from builtins import range import pickle from PhysicsTools.HeppyCore.utils.diclist import diclist diff --git a/PhysicsTools/HeppyCore/python/utils/dataset.py b/PhysicsTools/HeppyCore/python/utils/dataset.py index f8c42e9a0275c..7286394926bc0 100644 --- a/PhysicsTools/HeppyCore/python/utils/dataset.py +++ b/PhysicsTools/HeppyCore/python/utils/dataset.py @@ -2,6 +2,7 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import os import pprint import re @@ -170,7 +171,7 @@ def buildListOfFiles(self, pattern='.*root'): if num_files > limit: num_steps = int(num_files/limit)+1 self.files = [] - for i in xrange(num_steps): + for i in range(num_steps): DBSFiles=self.buildListOfFilesDBS(pattern, i*limit, ((i+1)*limit)-1) diff --git a/PhysicsTools/HeppyCore/python/utils/dataset_test.py b/PhysicsTools/HeppyCore/python/utils/dataset_test.py index 565bda4ff563e..1ceec0aa34ce7 100644 --- a/PhysicsTools/HeppyCore/python/utils/dataset_test.py +++ b/PhysicsTools/HeppyCore/python/utils/dataset_test.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range from .dataset import * import unittest diff --git a/PhysicsTools/HeppyCore/python/utils/edmIntegrityCheck.py b/PhysicsTools/HeppyCore/python/utils/edmIntegrityCheck.py index bb4f616f97a99..80a74b379eaa9 100644 --- a/PhysicsTools/HeppyCore/python/utils/edmIntegrityCheck.py +++ b/PhysicsTools/HeppyCore/python/utils/edmIntegrityCheck.py @@ -5,6 +5,7 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import datetime, fnmatch, json, os, shutil, sys, tempfile, time import subprocess @@ -145,7 +146,7 @@ def getCrabIndex(base): good_duplicates = {} bad_jobs = set() sum_dup = 0 - for i in xrange(mmin, mmax+1): + for i in range(mmin, mmax+1): if i in files: duplicates = sorted(files[i]) diff --git a/PhysicsTools/HeppyCore/python/utils/production_tasks.py b/PhysicsTools/HeppyCore/python/utils/production_tasks.py index 5b950cee0a9eb..2a1ff6be8ea0d 100644 --- a/PhysicsTools/HeppyCore/python/utils/production_tasks.py +++ b/PhysicsTools/HeppyCore/python/utils/production_tasks.py @@ -1,6 +1,7 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import copy, datetime, inspect, fnmatch, os, re, subprocess, sys, tempfile, time import glob import gzip @@ -606,7 +607,7 @@ def parseHeader(header): """Parse the header from bjobs""" tokens = [t for t in header.split(' ') if t] result = {} - for i in xrange(len(tokens)): + for i in range(len(tokens)): result[tokens[i]] = i return result diff --git a/PhysicsTools/HeppyCore/python/utils/testtree.py b/PhysicsTools/HeppyCore/python/utils/testtree.py index 3dfe9e7972705..4b4bc2164a9eb 100644 --- a/PhysicsTools/HeppyCore/python/utils/testtree.py +++ b/PhysicsTools/HeppyCore/python/utils/testtree.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from ROOT import TFile from PhysicsTools.HeppyCore.statistics.tree import Tree diff --git a/PhysicsTools/HeppyCore/scripts/heppy_batch.py b/PhysicsTools/HeppyCore/scripts/heppy_batch.py index 3606cb72d9365..084a35a46de6f 100755 --- a/PhysicsTools/HeppyCore/scripts/heppy_batch.py +++ b/PhysicsTools/HeppyCore/scripts/heppy_batch.py @@ -1,6 +1,7 @@ #!/bin/env python from __future__ import print_function +from builtins import range import sys import imp import copy @@ -362,7 +363,7 @@ def PrepareJobUser(self, jobDir, value ): handle.close() components = split( [comp for comp in config.components if len(comp.files)>0] ) - listOfValues = range(0, len(components)) + listOfValues = list(range(0, len(components))) listOfNames = [comp.name for comp in components] batchManager.PrepareJobs( listOfValues, listOfNames ) diff --git a/PhysicsTools/NanoAOD/test/inspectNanoFile.py b/PhysicsTools/NanoAOD/test/inspectNanoFile.py index b425da6768596..e2bda8671772f 100755 --- a/PhysicsTools/NanoAOD/test/inspectNanoFile.py +++ b/PhysicsTools/NanoAOD/test/inspectNanoFile.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from builtins import range import sys, os.path, json from collections import defaultdict import six @@ -93,7 +94,7 @@ def inspectRootFile(infile): entries = tree.GetEntries() trees[treeName] = tree branchList = tree.GetListOfBranches() - allbranches = [ Branch(tree,branchList.At(i)) for i in xrange(branchList.GetSize()) ] + allbranches = [ Branch(tree,branchList.At(i)) for i in range(branchList.GetSize()) ] branchmap = dict((b.name,b) for b in allbranches) branchgroups = {} # make list of counters and countees diff --git a/PhysicsTools/PatAlgos/python/tools/cmsswVersionTools.py b/PhysicsTools/PatAlgos/python/tools/cmsswVersionTools.py index 619797db9fe2b..0d334bcc6a510 100644 --- a/PhysicsTools/PatAlgos/python/tools/cmsswVersionTools.py +++ b/PhysicsTools/PatAlgos/python/tools/cmsswVersionTools.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import FWCore.ParameterSet.Config as cms from FWCore.GuiBrowsers.ConfigToolBase import * diff --git a/PhysicsTools/PatAlgos/python/tools/coreTools.py b/PhysicsTools/PatAlgos/python/tools/coreTools.py index d9af447cf474e..3bf524eeb227c 100644 --- a/PhysicsTools/PatAlgos/python/tools/coreTools.py +++ b/PhysicsTools/PatAlgos/python/tools/coreTools.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from FWCore.GuiBrowsers.ConfigToolBase import * from PhysicsTools.PatAlgos.tools.helpers import * diff --git a/PhysicsTools/PatAlgos/python/tools/trigTools.py b/PhysicsTools/PatAlgos/python/tools/trigTools.py index 25c9bc0c14b15..2e3a04c7b8497 100644 --- a/PhysicsTools/PatAlgos/python/tools/trigTools.py +++ b/PhysicsTools/PatAlgos/python/tools/trigTools.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from FWCore.GuiBrowsers.ConfigToolBase import * from PhysicsTools.PatAlgos.tools.helpers import * diff --git a/PhysicsTools/PatAlgos/test/miniAOD/example_packedCandidates.py b/PhysicsTools/PatAlgos/test/miniAOD/example_packedCandidates.py index f20e70688bf37..e0ddfc0958e5b 100644 --- a/PhysicsTools/PatAlgos/test/miniAOD/example_packedCandidates.py +++ b/PhysicsTools/PatAlgos/test/miniAOD/example_packedCandidates.py @@ -1,5 +1,6 @@ from __future__ import print_function # import ROOT in batch mode +from builtins import range import sys oldargv = sys.argv[:] sys.argv = [ '-b-' ] @@ -49,7 +50,7 @@ def deltaR(a,b): pileup = 0 # now get a list of the PF candidates used to build this lepton, so to exclude them footprint = set() - for i in xrange(lep.numberOfSourceCandidatePtrs()): + for i in range(lep.numberOfSourceCandidatePtrs()): footprint.add(lep.sourceCandidatePtr(i).key()) # the key is the index in the pf collection # now loop on pf candidates for ipf,pf in enumerate(pfs.product()): @@ -73,7 +74,7 @@ def deltaR(a,b): for i,j in enumerate(jets.product()): if j.pt() < 40 or abs(j.eta()) > 2.4: continue sums = [0,0] - for id in xrange(j.numberOfDaughters()): + for id in range(j.numberOfDaughters()): dau = j.daughter(id) if (dau.charge() == 0): continue sums[ abs(dau.dz())<0.1 ] += dau.pt() diff --git a/PhysicsTools/PythonAnalysis/python/ParticleDecayDrawer.py b/PhysicsTools/PythonAnalysis/python/ParticleDecayDrawer.py index a4aba5a1ab139..b49343b06757f 100644 --- a/PhysicsTools/PythonAnalysis/python/ParticleDecayDrawer.py +++ b/PhysicsTools/PythonAnalysis/python/ParticleDecayDrawer.py @@ -5,6 +5,7 @@ # this tool is based on Luca Lista's tree drawer module +from builtins import range class ParticleDecayDrawer(object): """Draws particle decay tree """ @@ -21,7 +22,7 @@ def _select(self, candidate): def _hasValidDaughters(self, candidate): nDaughters = candidate.numChildren() - for i in xrange(nDaughters): + for i in range(nDaughters): if self._select(candidate.listChildren()[i]): return True return False @@ -41,13 +42,13 @@ def _decay(self, candidate, skipList): validDau = 0 nOfDaughters = candidate.numChildren() - for i in xrange(nOfDaughters): + for i in range(nOfDaughters): if self._accept(candidate.listChildren()[i], skipList): validDau+=1 if validDau == 0: return out out += " ->" - for i in xrange(nOfDaughters): + for i in range(nOfDaughters): d = candidate.listChildren()[i] if self._accept(d, skipList): decString = self._decay(d, skipList) @@ -65,7 +66,7 @@ def draw(self, particles): if self._select(particle): skipList.append(particle) nodesList.append(particle) - for j in xrange(particle.numParents()): + for j in range(particle.numParents()): mom = particle.listParents()[j] while (mom.mother()):# != None ): mom = mom.mother() @@ -75,7 +76,7 @@ def draw(self, particles): print("-- decay --") if len(momsList) > 0: if len(momsList) > 1: - for m in xrange(len(momsList)): + for m in range(len(momsList)): decString = self._decay( momsList[m], skipList) if len(decString) > 0: print("{ %s } " %decString) diff --git a/PhysicsTools/PythonAnalysis/python/cmstools.py b/PhysicsTools/PythonAnalysis/python/cmstools.py index caa8e3ad14926..1b0597e6fd66c 100644 --- a/PhysicsTools/PythonAnalysis/python/cmstools.py +++ b/PhysicsTools/PythonAnalysis/python/cmstools.py @@ -5,6 +5,7 @@ """ from __future__ import absolute_import from __future__ import print_function +from builtins import range import re import ROOT import exceptions @@ -29,7 +30,7 @@ def all(container): if hasattr(container,'GetEntries'): try: entries = container.GetEntries() - for entry in xrange(entries): + for entry in range(entries): yield entry except: raise cmserror("Looping of %s failed" %container) @@ -38,7 +39,7 @@ def all(container): elif hasattr(container, 'size'): try: entries = container.size() - for entry in xrange(entries): + for entry in range(entries): yield container[entry] except: pass @@ -133,7 +134,7 @@ def __iter__(self): self.__setBranchIndicies() self._tree.GetEntry(self._index,0) # the real loop - for entry in xrange(self._tree.GetEntries()): + for entry in range(self._tree.GetEntries()): self._index = entry self.__setBranchIndicies() self._tree.GetEntry(self._index,0) diff --git a/PhysicsTools/PythonAnalysis/python/diffProv.py b/PhysicsTools/PythonAnalysis/python/diffProv.py index 605909b118ef5..91487aa23b4a9 100644 --- a/PhysicsTools/PythonAnalysis/python/diffProv.py +++ b/PhysicsTools/PythonAnalysis/python/diffProv.py @@ -1,5 +1,6 @@ from __future__ import print_function +from builtins import range class difference : def __init__(self,v): diff --git a/PhysicsTools/PythonAnalysis/python/diff_provenance.py b/PhysicsTools/PythonAnalysis/python/diff_provenance.py index cd9f367868edb..0a99eec684c2f 100644 --- a/PhysicsTools/PythonAnalysis/python/diff_provenance.py +++ b/PhysicsTools/PythonAnalysis/python/diff_provenance.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range class difference : def __init__(self,v): diff --git a/PhysicsTools/PythonAnalysis/python/iterators.py b/PhysicsTools/PythonAnalysis/python/iterators.py index f0c3fce774785..9465bf2f83b71 100644 --- a/PhysicsTools/PythonAnalysis/python/iterators.py +++ b/PhysicsTools/PythonAnalysis/python/iterators.py @@ -3,6 +3,7 @@ #import cmserror +from builtins import range def addIterator(obj): """function for adding iterators to objects""" if not hasattr(obj, "__iter__"): @@ -25,7 +26,7 @@ def addIterator(obj): def iteratorForSizedObjects(self): """dynamically added iterator""" entries = container.size() - for entry in xrange(entries): + for entry in range(entries): yield obj[entry] diff --git a/PhysicsTools/PythonAnalysis/python/rootplot/core.py b/PhysicsTools/PythonAnalysis/python/rootplot/core.py index 421693e5ba67e..483f5865d6a63 100644 --- a/PhysicsTools/PythonAnalysis/python/rootplot/core.py +++ b/PhysicsTools/PythonAnalysis/python/rootplot/core.py @@ -4,6 +4,7 @@ from __future__ import absolute_import from __future__ import print_function +from builtins import range __license__ = '''\ Copyright (c) 2009-2010 Jeff Klukas @@ -1723,7 +1724,7 @@ def comma_separator(obj, objtype, nhists): elif options.histfill: plot_style = 'histfill' if options.stack: plot_style = 'stack' if not options.markers and use_mpl: - options.marker_styles = ['o' for i in xrange(nhists)] + options.marker_styles = ['o' for i in range(nhists)] if not options.line_colors: options.line_colors = options.colors if not options.fill_colors: @@ -1732,38 +1733,38 @@ def comma_separator(obj, objtype, nhists): options.marker_colors = options.colors if use_mpl: if not options.line_styles: - options.line_styles = ['solid' for i in xrange(nhists)] + options.line_styles = ['solid' for i in range(nhists)] if not options.plot_styles: - options.plot_styles = [plot_style for i in xrange(nhists)] + options.plot_styles = [plot_style for i in range(nhists)] if not options.errorbar_colors: - options.errorbar_colors = [None for i in xrange(nhists)] + options.errorbar_colors = [None for i in range(nhists)] if not options.alphas: - options.alphas = [options.alpha for i in xrange(nhists)] + options.alphas = [options.alpha for i in range(nhists)] else: if not options.line_styles: - options.line_styles = [1 for i in xrange(nhists)] + options.line_styles = [1 for i in range(nhists)] if not options.draw_commands: if options.stack: options.draw_commands = ['stack ' + options.draw - for i in xrange(nhists)] + for i in range(nhists)] else: options.draw_commands = [options.draw - for i in xrange(nhists)] + for i in range(nhists)] if not options.fill_styles: if use_mpl: - options.fill_styles = [None for i in xrange(nhists)] + options.fill_styles = [None for i in range(nhists)] else: if options.fill: - options.fill_styles = [1001 for i in xrange(nhists)] + options.fill_styles = [1001 for i in range(nhists)] else: - options.fill_styles = [0 for i in xrange(nhists)] + options.fill_styles = [0 for i in range(nhists)] if not options.marker_sizes: if options.markers: if use_mpl: size = mpl.rcParams['lines.markersize'] else: size = ROOT.gStyle.GetMarkerSize() else: size = 0 - options.marker_sizes = [size for i in xrange(nhists)] + options.marker_sizes = [size for i in range(nhists)] if options.data: i = options.data - 1 options.line_styles[i] = options.data_linestyle diff --git a/PhysicsTools/PythonAnalysis/python/rootplot/root2matplotlib.py b/PhysicsTools/PythonAnalysis/python/rootplot/root2matplotlib.py index 8e2fc4d713ef1..0fb1dcbe61724 100644 --- a/PhysicsTools/PythonAnalysis/python/rootplot/root2matplotlib.py +++ b/PhysicsTools/PythonAnalysis/python/rootplot/root2matplotlib.py @@ -2,6 +2,7 @@ Utilities for plotting ROOT histograms in matplotlib. """ +from builtins import range __license__ = '''\ Copyright (c) 2009-2010 Jeff Klukas @@ -278,7 +279,7 @@ def bar3d(self, **kwargs): **all_kwargs) plots.append(bar) from matplotlib.ticker import FixedLocator - locator = FixedLocator(range(len(labels))) + locator = FixedLocator(list(range(len(labels)))) ax.w_yaxis.set_major_locator(locator) ax.w_yaxis.set_ticklabels(labels) ax.set_ylim3d(-1, len(labels)) diff --git a/PhysicsTools/PythonAnalysis/python/rootplot/rootinfo.py b/PhysicsTools/PythonAnalysis/python/rootplot/rootinfo.py index 5420b37ff5388..12483ff6fbffd 100644 --- a/PhysicsTools/PythonAnalysis/python/rootplot/rootinfo.py +++ b/PhysicsTools/PythonAnalysis/python/rootplot/rootinfo.py @@ -4,6 +4,7 @@ from __future__ import absolute_import from __future__ import print_function +from builtins import range from .version import __version__ from ROOT import Double @@ -46,7 +47,7 @@ def recurse_thru_file(in_tfile, options, full_path='/'): if obj.InheritsFrom('TH2'): # Print contents as they would look on the 2D graph # Left to right, top to bottom. Start in upper left corner. - for j in reversed(range(obj.GetNbinsY())): + for j in reversed(list(range(obj.GetNbinsY()))): print() print(" %s" % ' '.join( [str(obj.GetBinContent(i+1, j+1)) for i in range(obj.GetNbinsX())]), end=' ') @@ -55,7 +56,7 @@ def recurse_thru_file(in_tfile, options, full_path='/'): [str(obj.GetBinContent(i+1)) for i in range(obj.GetNbinsX())]), end=' ') if "errors" == arg: if obj.InheritsFrom('TH2'): - for j in reversed(range(obj.GetNbinsY())): + for j in reversed(list(range(obj.GetNbinsY()))): print() print(" %s" % ' '.join( [str(obj.GetBinError(i+1, j+1)) for i in range(obj.GetNbinsX())]), end=' ') diff --git a/PhysicsTools/PythonAnalysis/python/rootplot/rootmath.py b/PhysicsTools/PythonAnalysis/python/rootplot/rootmath.py index adad672b3314e..80fdb4b1265f9 100644 --- a/PhysicsTools/PythonAnalysis/python/rootplot/rootmath.py +++ b/PhysicsTools/PythonAnalysis/python/rootplot/rootmath.py @@ -4,6 +4,7 @@ from __future__ import absolute_import from __future__ import print_function +from builtins import range __license__ = '''\ Copyright (c) 2009-2010 Jeff Klukas diff --git a/PhysicsTools/PythonAnalysis/python/rootplot/utilities.py b/PhysicsTools/PythonAnalysis/python/rootplot/utilities.py index bf903d5eec133..6ba4368b11930 100644 --- a/PhysicsTools/PythonAnalysis/python/rootplot/utilities.py +++ b/PhysicsTools/PythonAnalysis/python/rootplot/utilities.py @@ -3,6 +3,7 @@ """ from __future__ import print_function +from builtins import range __license__ = '''\ Copyright (c) 2009-2010 Jeff Klukas @@ -148,13 +149,13 @@ def __init_TGraph(self, hist): hist.GetPoint(i, x, y) self.x.append(copy.copy(x)) self.y.append(copy.copy(y)) - lower = [max(0, hist.GetErrorXlow(i)) for i in xrange(n)] - upper = [max(0, hist.GetErrorXhigh(i)) for i in xrange(n)] + lower = [max(0, hist.GetErrorXlow(i)) for i in range(n)] + upper = [max(0, hist.GetErrorXhigh(i)) for i in range(n)] self.xerr = [lower[:], upper[:]] - lower = [max(0, hist.GetErrorYlow(i)) for i in xrange(n)] - upper = [max(0, hist.GetErrorYhigh(i)) for i in xrange(n)] + lower = [max(0, hist.GetErrorYlow(i)) for i in range(n)] + upper = [max(0, hist.GetErrorYhigh(i)) for i in range(n)] self.yerr = [lower[:], upper[:]] - self.xedges = [self.x[i] - self.xerr[0][i] for i in xrange(n)] + self.xedges = [self.x[i] - self.xerr[0][i] for i in range(n)] self.xedges.append(self.x[n - 1] + self.xerr[1][n - 1]) self.width = [self.xedges[i + 1] - self.xedges[i] for i in range(n)] self.underflow, self.overflow = 0, 0 diff --git a/PhysicsTools/PythonAnalysis/test/testHistogrammar.py b/PhysicsTools/PythonAnalysis/test/testHistogrammar.py index 4ef85bb5aa6e8..0ced7745cd92c 100755 --- a/PhysicsTools/PythonAnalysis/test/testHistogrammar.py +++ b/PhysicsTools/PythonAnalysis/test/testHistogrammar.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from builtins import range import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as pyplot @@ -9,7 +10,7 @@ # generate a stream of uniform random numbers import random -data = [random.random() for i in xrange(2000)] +data = [random.random() for i in range(2000)] # aggregation structure and fill rule histogram = hg.Bin(num=20, low=0, high=1, quantity=lambda x: x, value=hg.Count()) diff --git a/PhysicsTools/PythonAnalysis/test/testNumba.py b/PhysicsTools/PythonAnalysis/test/testNumba.py index 3a28372fef92a..0176b0ecd7ade 100755 --- a/PhysicsTools/PythonAnalysis/test/testNumba.py +++ b/PhysicsTools/PythonAnalysis/test/testNumba.py @@ -7,6 +7,7 @@ # from examples in numba documentaiton # http://numba.pydata.org/numba-doc/dev/user/examples.html (0.33.0) +from builtins import range import numpy as np from numba import guvectorize diff --git a/PhysicsTools/PythonAnalysis/test/testRootpy.py b/PhysicsTools/PythonAnalysis/test/testRootpy.py index 283dc5cd873d6..e53678cf773fc 100755 --- a/PhysicsTools/PythonAnalysis/test/testRootpy.py +++ b/PhysicsTools/PythonAnalysis/test/testRootpy.py @@ -8,6 +8,7 @@ This example demonstrates how to create and work with ROOT histogram in rootpy. """ from __future__ import print_function +from builtins import range print(__doc__) from rootpy.extern.six.moves import range from rootpy.plotting import Hist, Hist2D, Hist3D, HistStack, Legend, Canvas diff --git a/PhysicsTools/PythonAnalysis/test/testhep_ml.py b/PhysicsTools/PythonAnalysis/test/testhep_ml.py index 4c576e460ceeb..42aa11f23d4cc 100755 --- a/PhysicsTools/PythonAnalysis/test/testhep_ml.py +++ b/PhysicsTools/PythonAnalysis/test/testhep_ml.py @@ -6,6 +6,7 @@ """ from __future__ import division, print_function +from builtins import range import numpy from sklearn.linear_model.logistic import LogisticRegression from sklearn.datasets import make_blobs diff --git a/PhysicsTools/TagAndProbe/test/utilities/dumpPileup.py b/PhysicsTools/TagAndProbe/test/utilities/dumpPileup.py index 55c4a1ede3fc3..c545c9d6b1d17 100644 --- a/PhysicsTools/TagAndProbe/test/utilities/dumpPileup.py +++ b/PhysicsTools/TagAndProbe/test/utilities/dumpPileup.py @@ -1,8 +1,9 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import sys import ROOT fin=ROOT.TFile.Open(sys.argv[1]) pu = fin.Get("pileup") -pileup = map( pu.GetBinContent, xrange(1,pu.GetNbinsX()+1) ) +pileup = map( pu.GetBinContent, range(1,pu.GetNbinsX()+1) ) print(",".join(map(lambda x: "%1.3g"%x, pileup))) diff --git a/RecoBTag/PerformanceDB/test/plotPerformanceDB.py b/RecoBTag/PerformanceDB/test/plotPerformanceDB.py index afae18d61b88c..bd29a89745d2b 100644 --- a/RecoBTag/PerformanceDB/test/plotPerformanceDB.py +++ b/RecoBTag/PerformanceDB/test/plotPerformanceDB.py @@ -9,6 +9,7 @@ #____________________________________________________________ from __future__ import print_function +from builtins import range import sys import math import commands @@ -56,7 +57,7 @@ def main(): MCefferrarray_alleta = array('d') - for ipt in xrange(0,ptNbins): + for ipt in range(0,ptNbins): SF_alleta = 0. SFerr_alleta = 0. Eff_alleta = 0. @@ -68,7 +69,7 @@ def main(): ptarray.append( apt ) pterrarray.append( ptbinwidth*0.5 ) - for ieta in xrange(0,etaNbins): + for ieta in range(0,etaNbins): aeta = etamin = ieta*etabinwidth diff --git a/RecoLuminosity/LumiDB/plotdata/checklumidiff.py b/RecoLuminosity/LumiDB/plotdata/checklumidiff.py index 32a7692b1f49d..3888bccfab12e 100644 --- a/RecoLuminosity/LumiDB/plotdata/checklumidiff.py +++ b/RecoLuminosity/LumiDB/plotdata/checklumidiff.py @@ -1,3 +1,4 @@ +from builtins import range import sys,os,os.path,glob,csv,math,datetime def parseplotcache(filelist,fillmin,fillmax): result={}#{fill:{run:delivered}} @@ -9,7 +10,7 @@ def parseplotcache(filelist,fillmin,fillmax): if idx!=0: [run,fill]=row[0].split(':') [lumils,cmsls]=row[1].split(':') - if int(fill) not in range(fillmin,fillmax+1): + if int(fill) not in list(range(fillmin,fillmax+1)): continue delivered=float(row[5]) if int(fill) not in result: diff --git a/RecoLuminosity/LumiDB/plotdata/create_public_lumi_plots.py b/RecoLuminosity/LumiDB/plotdata/create_public_lumi_plots.py index fc5bd1d0c0985..26b0b58effbe8 100755 --- a/RecoLuminosity/LumiDB/plotdata/create_public_lumi_plots.py +++ b/RecoLuminosity/LumiDB/plotdata/create_public_lumi_plots.py @@ -5,6 +5,7 @@ ###################################################################### from __future__ import print_function +from builtins import range import sys import os import commands @@ -729,8 +730,8 @@ def loadCertificationJSON(json_file_name): print(" last day to consider: %s (%d, week %d)" % \ (date_end.isoformat(), year_end, week_end)) num_days = (date_end - date_begin).days + 1 - days = [date_begin + datetime.timedelta(days=i) for i in xrange(num_days)] - years = range(year_begin, year_end + 1) + days = [date_begin + datetime.timedelta(days=i) for i in range(num_days)] + years = list(range(year_begin, year_end + 1)) weeks = [] day_cur = date_begin while day_cur <= date_end: @@ -1588,7 +1589,7 @@ def PlotAllYears(lumi_data_by_day_per_year, mode): for i in times_tmp] times = [matplotlib.dates.date2num(i) for i in times_tmp] # DEBUG DEBUG DEBUG - for i in xrange(len(times) - 1): + for i in range(len(times) - 1): assert times[i] < times[i + 1] # DEBUG DEBUG DEBUG end weights_del = lumi_data.lum_del(units) @@ -1748,7 +1749,7 @@ def PlotAllYears(lumi_data_by_day_per_year, mode): times_tmp = [AtMidnight(i) for i in lumi_data.times()] times = [matplotlib.dates.date2num(i) for i in times_tmp] # DEBUG DEBUG DEBUG - for i in xrange(len(times) - 1): + for i in range(len(times) - 1): assert times[i] < times[i + 1] # DEBUG DEBUG DEBUG end weights_inst = lumi_data.lum_inst_max(units) diff --git a/RecoLuminosity/LumiDB/plotdata/create_public_pileup_plots.py b/RecoLuminosity/LumiDB/plotdata/create_public_pileup_plots.py index bafc05d17bf3f..88506111803d8 100755 --- a/RecoLuminosity/LumiDB/plotdata/create_public_pileup_plots.py +++ b/RecoLuminosity/LumiDB/plotdata/create_public_pileup_plots.py @@ -11,6 +11,7 @@ # --calcMode true --maxPileupBin=40 pu2012DCSONLY.root from __future__ import print_function +from builtins import range import sys import os import commands @@ -195,11 +196,11 @@ def TweakPlot(fig, ax, add_extra_head_room=False): # Turn the ROOT histogram into a Matplotlib one. bin_edges = [pileup_hist.GetBinLowEdge(i) \ - for i in xrange(1, pileup_hist.GetNbinsX() + 1)] + for i in range(1, pileup_hist.GetNbinsX() + 1)] vals = [pileup_hist.GetBinCenter(i) \ - for i in xrange(1, pileup_hist.GetNbinsX() + 1)] + for i in range(1, pileup_hist.GetNbinsX() + 1)] weights = [pileup_hist.GetBinContent(i) \ - for i in xrange(1, pileup_hist.GetNbinsX() + 1)] + for i in range(1, pileup_hist.GetNbinsX() + 1)] # NOTE: Convert units to /pb! weights = [1.e-6 * i for i in weights] diff --git a/RecoLuminosity/LumiDB/python/CommonUtil.py b/RecoLuminosity/LumiDB/python/CommonUtil.py index a2d1ca05a2124..fff8164a7bcea 100644 --- a/RecoLuminosity/LumiDB/python/CommonUtil.py +++ b/RecoLuminosity/LumiDB/python/CommonUtil.py @@ -1,6 +1,7 @@ '''This module collects some frequently used helper functions ''' from __future__ import print_function +from builtins import range import time,ast,re,json,coral,array def flatten(obj): '''Given nested lists or tuples, returns a single flattened list''' diff --git a/RecoLuminosity/LumiDB/python/dataDML.py b/RecoLuminosity/LumiDB/python/dataDML.py index 13c066d665216..b1f9b3a5805bb 100644 --- a/RecoLuminosity/LumiDB/python/dataDML.py +++ b/RecoLuminosity/LumiDB/python/dataDML.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import os,coral,fnmatch,time from RecoLuminosity.LumiDB import nameDealer,dbUtil,revisionDML,lumiTime,CommonUtil,lumiCorrections from datetime import datetime diff --git a/RecoLuminosity/LumiDB/python/dbUtil.py b/RecoLuminosity/LumiDB/python/dbUtil.py index d6dc1d0771131..62f8d9ac145df 100644 --- a/RecoLuminosity/LumiDB/python/dbUtil.py +++ b/RecoLuminosity/LumiDB/python/dbUtil.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import coral from RecoLuminosity.LumiDB import nameDealer class dbUtil(object): diff --git a/RecoLuminosity/LumiDB/python/generateDummyData.py b/RecoLuminosity/LumiDB/python/generateDummyData.py index 57485ce29d7d2..bb157b8ae48c1 100644 --- a/RecoLuminosity/LumiDB/python/generateDummyData.py +++ b/RecoLuminosity/LumiDB/python/generateDummyData.py @@ -1,3 +1,4 @@ +from builtins import range import array,coral from RecoLuminosity.LumiDB import CommonUtil def lumiSummary(schema,nlumils): diff --git a/RecoLuminosity/LumiDB/python/lumiCalcAPI.py b/RecoLuminosity/LumiDB/python/lumiCalcAPI.py index 9ceabbf3a70f6..63745077cc176 100644 --- a/RecoLuminosity/LumiDB/python/lumiCalcAPI.py +++ b/RecoLuminosity/LumiDB/python/lumiCalcAPI.py @@ -1,3 +1,4 @@ +from builtins import range import os,coral,datetime,fnmatch,time from RecoLuminosity.LumiDB import nameDealer,revisionDML,dataDML,lumiTime,CommonUtil,selectionParser,hltTrgSeedMapper,normFunctors,lumiParameters @@ -339,7 +340,7 @@ def instLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=No bxvaluelist.append(bxval) bxerrorlist.append(bxerrArray[idx]) else: - bxidxlist=range(0,len(bxvalueArray)) + bxidxlist=list(range(0,len(bxvalueArray))) bxvaluelist=bxvalueArray.tolist() bxerrorlist=bxerrArray.tolist() del bxvalueArray[:] diff --git a/RecoLuminosity/LumiDB/python/lumiReport.py b/RecoLuminosity/LumiDB/python/lumiReport.py index 2219ea47d013d..7abf1292bef27 100644 --- a/RecoLuminosity/LumiDB/python/lumiReport.py +++ b/RecoLuminosity/LumiDB/python/lumiReport.py @@ -5,6 +5,7 @@ # Author: Zhen Xie # ########################################################### +from builtins import range import os,sys,time from RecoLuminosity.LumiDB import tablePrinter, csvReporter,CommonUtil from RecoLuminosity.LumiDB.wordWrappers import wrap_always, wrap_onspace, wrap_onspace_strict diff --git a/RecoLuminosity/LumiDB/python/lumidbDDL.py b/RecoLuminosity/LumiDB/python/lumidbDDL.py index ec005c128219b..35e1f418dea2a 100644 --- a/RecoLuminosity/LumiDB/python/lumidbDDL.py +++ b/RecoLuminosity/LumiDB/python/lumidbDDL.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import coral from RecoLuminosity.LumiDB import nameDealer,dbUtil #======================================================= diff --git a/RecoLuminosity/LumiDB/python/matplotRender.py b/RecoLuminosity/LumiDB/python/matplotRender.py index 5b3376ceb00dd..794ec4ef4bb22 100644 --- a/RecoLuminosity/LumiDB/python/matplotRender.py +++ b/RecoLuminosity/LumiDB/python/matplotRender.py @@ -5,6 +5,7 @@ -- we support http mode by sending string buf via meme type image/png. Sending a premade static plot to webserver is considered a uploading process instead of http dynamic graphical mode. ''' from __future__ import print_function +from builtins import range import sys,os import numpy,datetime import matplotlib @@ -471,7 +472,7 @@ def plotPerdayX_Time(self,rawdata={},resultlines=[],minTime=None,maxTime=None,nt flat=[] MinDay=minTime.date().toordinal() MaxDay=maxTime.date().toordinal() - fulldays=range(MinDay,MaxDay+1) + fulldays=list(range(MinDay,MaxDay+1)) allstarts=[] allstops=[] for label,yvalues in rawdata.items(): @@ -617,7 +618,7 @@ def plotPeakPerday_Time(self,rawdata={},resultlines=[],minTime=None,maxTime=None flat=[] MinDay=minTime.date().toordinal() MaxDay=maxTime.date().toordinal() - fulldays=range(MinDay,MaxDay+1) + fulldays=list(range(MinDay,MaxDay+1)) for label in rawdata.keys(): yvalues=sorted(rawdata[label]) alldays=[t[0] for t in yvalues] @@ -729,7 +730,7 @@ def plotInst_RunLS(self,rawxdata,rawydata,nticks=6,textoutput=None): peakinst=max(rawydata['Delivered'])/lslength totaldelivered=sum(rawydata['Delivered']) totalrecorded=sum(rawydata['Recorded']) - xpoints=range(1,totalls+1) + xpoints=list(range(1,totalls+1)) #print len(xpoints) ypoints={} ymax={} diff --git a/RecoLuminosity/LumiDB/python/mpl_axes_hist_fix.py b/RecoLuminosity/LumiDB/python/mpl_axes_hist_fix.py index ce3273e295840..9601610df57bc 100644 --- a/RecoLuminosity/LumiDB/python/mpl_axes_hist_fix.py +++ b/RecoLuminosity/LumiDB/python/mpl_axes_hist_fix.py @@ -4,6 +4,7 @@ # This is used by the create_public_lumi_plots.py script. +from builtins import range import numpy as np import itertools import matplotlib.cbook as cbook @@ -196,7 +197,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, if color is None: color = [next(self._get_lines.color_cycle) - for i in xrange(nx)] + for i in range(nx)] else: color = mcolors.colorConverter.to_rgba_array(color) if len(color) != nx: @@ -217,7 +218,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, if len(w) != nx: raise ValueError('weights should have the same shape as x') - for i in xrange(nx): + for i in range(nx): if len(w[i]) != len(x[i]): raise ValueError( 'weights should have the same shape as x') @@ -259,7 +260,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, hist_kwargs['new'] = True n = [] - for i in xrange(nx): + for i in range(nx): # this will automatically overwrite bins, # so that each histogram uses the same bins m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs) diff --git a/RecoLuminosity/LumiDB/python/pyrootRender.py b/RecoLuminosity/LumiDB/python/pyrootRender.py index bca69124c359f..68246b81e87cc 100644 --- a/RecoLuminosity/LumiDB/python/pyrootRender.py +++ b/RecoLuminosity/LumiDB/python/pyrootRender.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys import ROOT from ROOT import TCanvas,TH1F,gROOT,TFile,gStyle,gDirectory,TDatime,TLegend diff --git a/RecoLuminosity/LumiDB/python/queryDataSource.py b/RecoLuminosity/LumiDB/python/queryDataSource.py index 1692cf57dced7..5ea61fa57c2a9 100644 --- a/RecoLuminosity/LumiDB/python/queryDataSource.py +++ b/RecoLuminosity/LumiDB/python/queryDataSource.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import array,coral from RecoLuminosity.LumiDB import CommonUtil,nameDealer diff --git a/RecoLuminosity/LumiDB/python/selectionParser.py b/RecoLuminosity/LumiDB/python/selectionParser.py index c5053f1c21601..1a3e70167f479 100644 --- a/RecoLuminosity/LumiDB/python/selectionParser.py +++ b/RecoLuminosity/LumiDB/python/selectionParser.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import json class selectionParser(object): def __init__(self,selectStr): diff --git a/RecoLuminosity/LumiDB/python/wordWrappers.py b/RecoLuminosity/LumiDB/python/wordWrappers.py index 09a13a4c7d232..aa3b6a27f630d 100644 --- a/RecoLuminosity/LumiDB/python/wordWrappers.py +++ b/RecoLuminosity/LumiDB/python/wordWrappers.py @@ -2,6 +2,7 @@ # word-wrap functions # written by Mike Brown # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/148061 +from builtins import range import math,re from functools import reduce def wrap_always(text, width): @@ -10,7 +11,7 @@ def wrap_always(text, width): It doesn't split the text in words. """ return '\n'.join([ text[width*i:width*(i+1)] \ - for i in xrange(int(math.ceil(1.*len(text)/width))) ]) + for i in range(int(math.ceil(1.*len(text)/width))) ]) def wrap_onspace(text,width): """ diff --git a/RecoLuminosity/LumiDB/scripts/estimatePileup.py b/RecoLuminosity/LumiDB/scripts/estimatePileup.py index 2eb5bc3baf5d7..5ef3c0684d7bb 100755 --- a/RecoLuminosity/LumiDB/scripts/estimatePileup.py +++ b/RecoLuminosity/LumiDB/scripts/estimatePileup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os, sys import coral import array @@ -58,7 +59,7 @@ def fillPileupHistogram (deadTable, parameters, # here we only want the instantaneous luminosities and don't # care which crosings they fall in. So we only want the odd instLumiArray = [(xingInstLumiArray[index], xingInstLumiArray[index + 1]) \ - for index in xrange( 0, len (xingInstLumiArray), 2 ) ] + for index in range( 0, len (xingInstLumiArray), 2 ) ] livetime = 1 if numerator < 0: numerator = 0 diff --git a/RecoLuminosity/LumiDB/scripts/estimatePileup2.py b/RecoLuminosity/LumiDB/scripts/estimatePileup2.py index b84f61cb357cc..4a8a515d56aa1 100755 --- a/RecoLuminosity/LumiDB/scripts/estimatePileup2.py +++ b/RecoLuminosity/LumiDB/scripts/estimatePileup2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range VERSION='2.00' import os, sys import coral diff --git a/RecoLuminosity/LumiDB/scripts/lumiPatch.py b/RecoLuminosity/LumiDB/scripts/lumiPatch.py index dc6ce67e617b8..016b0ba8a0620 100755 --- a/RecoLuminosity/LumiDB/scripts/lumiPatch.py +++ b/RecoLuminosity/LumiDB/scripts/lumiPatch.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range VERSION='1.00' import os,sys,datetime import coral diff --git a/RecoLuminosity/LumiDB/scripts/pileupCalc.py b/RecoLuminosity/LumiDB/scripts/pileupCalc.py index d62b7b0e5de53..24b8615ad956a 100755 --- a/RecoLuminosity/LumiDB/scripts/pileupCalc.py +++ b/RecoLuminosity/LumiDB/scripts/pileupCalc.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range VERSION='1.00' import os,sys,time import optparse diff --git a/RecoLuminosity/LumiDB/test/bunchanalysis.py b/RecoLuminosity/LumiDB/test/bunchanalysis.py index 448d93a5d188f..d47f29888df68 100644 --- a/RecoLuminosity/LumiDB/test/bunchanalysis.py +++ b/RecoLuminosity/LumiDB/test/bunchanalysis.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys,os,os.path,csv #analyse result from lumicalc2 cmmd to find perbunchlumi after subtracting noise #the following example analyses the output from: diff --git a/RecoLuminosity/LumiDB/test/dumptrgmask.py b/RecoLuminosity/LumiDB/test/dumptrgmask.py index 6b2abc504ad84..86ecf1be5ed33 100644 --- a/RecoLuminosity/LumiDB/test/dumptrgmask.py +++ b/RecoLuminosity/LumiDB/test/dumptrgmask.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import coral from RecoLuminosity.LumiDB import sessionManager,dbUtil,nameDealer,dataDML ''' diff --git a/RecoLuminosity/LumiDB/test/patchkit/analyze148829.py b/RecoLuminosity/LumiDB/test/patchkit/analyze148829.py index c0707c4151b84..af5a594a1d2f7 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/analyze148829.py +++ b/RecoLuminosity/LumiDB/test/patchkit/analyze148829.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import csv,os,sys,coral,array from RecoLuminosity.LumiDB import CommonUtil,idDealer,dbUtil,dataDML,revisionDML ilsfilename='/build/zx/patch/Run170899-ls.txt' @@ -21,7 +22,7 @@ def convertlist(l): '''yield successive pairs for l ''' - for i in xrange(0,len(l),2): + for i in range(0,len(l),2): idx=int(l[i]) val=float(l[i+1]) yield (idx,val) diff --git a/RecoLuminosity/LumiDB/test/patchkit/analyzelostruns.py b/RecoLuminosity/LumiDB/test/patchkit/analyzelostruns.py index 0f7a3bad26f97..bcc01000d2b43 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/analyzelostruns.py +++ b/RecoLuminosity/LumiDB/test/patchkit/analyzelostruns.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import csv,os,sys,coral,array from RecoLuminosity.LumiDB import argparse,sessionManager,CommonUtil,idDealer,dbUtil,dataDML,revisionDML beamenergy=4.0e03 @@ -12,7 +13,7 @@ def convertlist(l): '''yield successive pairs for l ''' - for i in xrange(0,len(l),2): + for i in range(0,len(l),2): idx=int(l[i]) val=float(l[i+1]) yield (idx,val) diff --git a/RecoLuminosity/LumiDB/test/patchkit/csvLumiLoader.py b/RecoLuminosity/LumiDB/test/patchkit/csvLumiLoader.py index 86ded7557f5ec..de8781d8d7b48 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/csvLumiLoader.py +++ b/RecoLuminosity/LumiDB/test/patchkit/csvLumiLoader.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os,os.path,sys,time,csv,array,coral from RecoLuminosity.LumiDB import sessionManager,argparse,nameDealer,revisionDML,dataDML,lumiParameters,CommonUtil,lumiTime diff --git a/RecoLuminosity/LumiDB/test/patchkit/generateFakeLumi.py b/RecoLuminosity/LumiDB/test/patchkit/generateFakeLumi.py index ca392b712808d..8a7f372d8acd1 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/generateFakeLumi.py +++ b/RecoLuminosity/LumiDB/test/patchkit/generateFakeLumi.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys def main(*args): filename=args[1] diff --git a/RecoLuminosity/LumiDB/test/patchkit/patchHLT.py b/RecoLuminosity/LumiDB/test/patchkit/patchHLT.py index a7c2cf907444a..5257ac40fd879 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/patchHLT.py +++ b/RecoLuminosity/LumiDB/test/patchkit/patchHLT.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys,os,csv,re,coral,array from RecoLuminosity.LumiDB import argparse,sessionManager,CommonUtil,dataDML,revisionDML,nameDealer,dbUtil DATABRANCH_ID=3 @@ -144,7 +145,7 @@ def parsepresc(inputlistoflist,minlsnum,maxlsnum,lsboundaries): minlsnum=int(minlsnum) pathnames=[] dataresult={}#{cmslsnum:[presc...]} - alllsnum=range(minlsnum,maxlsnum+1) + alllsnum=list(range(minlsnum,maxlsnum+1)) prescidxdict={}#{cmsls:prescidx} for cmsls in alllsnum: dataresult[cmsls]=[] diff --git a/RecoLuminosity/LumiDB/test/patchkit/patchinstlumi.py b/RecoLuminosity/LumiDB/test/patchkit/patchinstlumi.py index 9de45d0c62133..b199444f5ae2c 100644 --- a/RecoLuminosity/LumiDB/test/patchkit/patchinstlumi.py +++ b/RecoLuminosity/LumiDB/test/patchkit/patchinstlumi.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import csv,os,sys,coral,array from RecoLuminosity.LumiDB import CommonUtil,idDealer,dbUtil ilsfilename='Run152474-ls.txt' @@ -21,7 +22,7 @@ def convertlist(l): '''yield successive pairs for l ''' - for i in xrange(0,len(l),2): + for i in range(0,len(l),2): idx=int(l[i]) val=float(l[i+1]) yield (idx,val) diff --git a/RecoLuminosity/LumiDB/test/pixelLumiLoader.py b/RecoLuminosity/LumiDB/test/pixelLumiLoader.py index 9404397b8b819..296a3566db689 100644 --- a/RecoLuminosity/LumiDB/test/pixelLumiLoader.py +++ b/RecoLuminosity/LumiDB/test/pixelLumiLoader.py @@ -6,6 +6,7 @@ ################################################################### from __future__ import print_function +from builtins import range import os,sys,time,json,coral from datetime import datetime from RecoLuminosity.LumiDB import sessionManager,argparse,nameDealer,revisionDML,dataDML,lumiParameters,lumiTime diff --git a/RecoLuminosity/LumiDB/test/pyrootLumi.py b/RecoLuminosity/LumiDB/test/pyrootLumi.py index 19ca4dcb5abe8..90975a7e595c2 100755 --- a/RecoLuminosity/LumiDB/test/pyrootLumi.py +++ b/RecoLuminosity/LumiDB/test/pyrootLumi.py @@ -1,4 +1,5 @@ #! /usr/bin/env python +from builtins import range import commands import sys, os, string, fileinput import Tkinter as tk diff --git a/RecoMET/METFilters/python/GenerateHcalLaserBadRunList.py b/RecoMET/METFilters/python/GenerateHcalLaserBadRunList.py index 8df669606eff9..240a783cbc538 100644 --- a/RecoMET/METFilters/python/GenerateHcalLaserBadRunList.py +++ b/RecoMET/METFilters/python/GenerateHcalLaserBadRunList.py @@ -2,6 +2,7 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import sys, os, string import time diff --git a/RecoMET/METFilters/python/badGlobalMuonTaggerFWLite.py b/RecoMET/METFilters/python/badGlobalMuonTaggerFWLite.py index 1f87170e03e6f..a05dc808c4988 100644 --- a/RecoMET/METFilters/python/badGlobalMuonTaggerFWLite.py +++ b/RecoMET/METFilters/python/badGlobalMuonTaggerFWLite.py @@ -1,3 +1,4 @@ +from builtins import range import ROOT ROOT.gInterpreter.ProcessLine("#include ") @@ -53,13 +54,13 @@ def badMuons(self, allmuons, allvertices): goodMuon.append(3); # maybe good, maybe bad, but we don't care n = len(muons) - for i in xrange(n): + for i in range(n): if (muons[i].pt() < self.ptCut_ or goodMuon[i] != 0): continue; bad = True; if (self.selectClones_): bad = False; # unless proven otherwise n1 = muons[i].numberOfMatches(ROOT.reco.Muon.SegmentArbitration); - for j in xrange(n): + for j in range(n): if (j == i or goodMuon[j] <= 0 or not(self.partnerId(muons[j]))): continue n2 = muons[j].numberOfMatches(ROOT.reco.Muon.SegmentArbitration); if (deltaR(muons[i],muons[j]) < 0.4 or (n1 > 0 and n2 > 0 and ROOT.muon.sharedSegments(muons[i],muons[j]) >= 0.5*min(n1,n2))): diff --git a/RecoTauTag/Configuration/python/tools/DisplayManager.py b/RecoTauTag/Configuration/python/tools/DisplayManager.py index ec73e66a84f06..bf51c13efa446 100644 --- a/RecoTauTag/Configuration/python/tools/DisplayManager.py +++ b/RecoTauTag/Configuration/python/tools/DisplayManager.py @@ -1,3 +1,4 @@ +from builtins import range import ROOT import copy import math diff --git a/RecoTauTag/Configuration/test/compareTauVariables.py b/RecoTauTag/Configuration/test/compareTauVariables.py index 00fd182e28542..e117387df1a93 100644 --- a/RecoTauTag/Configuration/test/compareTauVariables.py +++ b/RecoTauTag/Configuration/test/compareTauVariables.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import sys import numpy as np @@ -60,15 +61,15 @@ def interSect(tree1, tree2, var='ull_dumpTauVariables_EventNumber_DUMP.obj', com tree1.Draw(var) r_evt1 = tree1.GetV1() if len(titles) > 0 and titles[0] == 'Reference': - evt1 = np.array([int(r_evt1[i]) & 0xffffffff for i in xrange(tree2.GetEntries())], dtype=int) + evt1 = np.array([int(r_evt1[i]) & 0xffffffff for i in range(tree2.GetEntries())], dtype=int) else: - evt1 = np.array([r_evt1[i] for i in xrange(tree1.GetEntries())], dtype=int) + evt1 = np.array([r_evt1[i] for i in range(tree1.GetEntries())], dtype=int) tree2.Draw(var) r_evt2 = tree2.GetV1() if len(titles) > 1 and titles[1] == 'Reference': - evt2 = np.array([int(r_evt2[i]) & 0xffffffff for i in xrange(tree2.GetEntries())], dtype=int) + evt2 = np.array([int(r_evt2[i]) & 0xffffffff for i in range(tree2.GetEntries())], dtype=int) else: - evt2 = np.array([int(r_evt2[i]) for i in xrange(tree2.GetEntries())], dtype=int) + evt2 = np.array([int(r_evt2[i]) for i in range(tree2.GetEntries())], dtype=int) if common: indices1 = np.nonzero(np.in1d(evt1, evt2)) indices2 = np.nonzero(np.in1d(evt2, evt1)) diff --git a/RecoTauTag/TauTagTools/test/training/castor.py b/RecoTauTag/TauTagTools/test/training/castor.py index 635ad67cb8117..92e16ec162941 100644 --- a/RecoTauTag/TauTagTools/test/training/castor.py +++ b/RecoTauTag/TauTagTools/test/training/castor.py @@ -20,6 +20,7 @@ # date: May 2006 # @author: Sebastien Binet +from builtins import range import datetime import commands import os @@ -39,7 +40,7 @@ def group(iterator, count): """ itr = iter(iterator) while True: - yield tuple([next(itr) for i in xrange(count)]) + yield tuple([next(itr) for i in range(count)]) __author__ = "Sebastien Binet " __doc__ = """A set of simple helper methods to handle simple tasks with CASTOR. @@ -191,7 +192,7 @@ def pool_nsls( path ) : for an xmlfile_catalog file. """ files = nsls(path) - for i in xrange(len(files)) : + for i in range(len(files)) : files[i] = "rfio:"+files[i] pass diff --git a/RecoTauTag/TauTagTools/test/training/computeTransform.py b/RecoTauTag/TauTagTools/test/training/computeTransform.py index 1f5903e7b3ba5..a8300200d0fd5 100755 --- a/RecoTauTag/TauTagTools/test/training/computeTransform.py +++ b/RecoTauTag/TauTagTools/test/training/computeTransform.py @@ -14,6 +14,7 @@ ''' from __future__ import print_function +from builtins import range from RecoLuminosity.LumiDB import argparse parser = argparse.ArgumentParser( diff --git a/RecoTauTag/TauTagTools/test/training/make_eval_plots.py b/RecoTauTag/TauTagTools/test/training/make_eval_plots.py index f84dbd5164164..cd9a8266d70d4 100755 --- a/RecoTauTag/TauTagTools/test/training/make_eval_plots.py +++ b/RecoTauTag/TauTagTools/test/training/make_eval_plots.py @@ -8,6 +8,7 @@ ''' from __future__ import print_function +from builtins import range import math import sys diff --git a/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py b/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py index 8e2250d8d4ad7..8be4380f6af21 100644 --- a/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py +++ b/RecoTauTag/TauTagTools/test/training/skimming/buildBackgroundDataSet_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import FWCore.ParameterSet.Config as cms import RecoTauTag.TauTagTools.RecoTauCommonJetSelections_cfi as common import sys diff --git a/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py b/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py index d29f0aacc3285..8a0ad672d1239 100644 --- a/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py +++ b/RecoTauTag/TauTagTools/test/training/skimming/buildSignalDataSet_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import FWCore.ParameterSet.Config as cms import RecoTauTag.TauTagTools.RecoTauCommonJetSelections_cfi as common import sys diff --git a/RecoTauTag/TauTagTools/test/training/training_control_plots.py b/RecoTauTag/TauTagTools/test/training/training_control_plots.py index 131743c658f93..4ca65a82ae655 100644 --- a/RecoTauTag/TauTagTools/test/training/training_control_plots.py +++ b/RecoTauTag/TauTagTools/test/training/training_control_plots.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import sys import re import os diff --git a/RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py b/RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py index af55d2ca43128..b595d6751fcbe 100755 --- a/RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py +++ b/RecoVertex/BeamSpotProducer/scripts/BeamSpotWorkflow.py @@ -33,6 +33,7 @@ from __future__ import print_function +from builtins import range import sys,os import commands, re, time import datetime diff --git a/RecoVertex/BeamSpotProducer/scripts/CommonMethods.py b/RecoVertex/BeamSpotProducer/scripts/CommonMethods.py index a7118406c9bac..1e1b705ff533e 100644 --- a/RecoVertex/BeamSpotProducer/scripts/CommonMethods.py +++ b/RecoVertex/BeamSpotProducer/scripts/CommonMethods.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import math, re, optparse, commands, os, sys, time, datetime from BeamSpotObj import BeamSpot from IOVObj import IOV diff --git a/RecoVertex/BeamSpotProducer/scripts/beamvalidation.py b/RecoVertex/BeamSpotProducer/scripts/beamvalidation.py index 0bd2d57fb0e32..12cc90138de18 100644 --- a/RecoVertex/BeamSpotProducer/scripts/beamvalidation.py +++ b/RecoVertex/BeamSpotProducer/scripts/beamvalidation.py @@ -28,6 +28,7 @@ from __future__ import print_function +from builtins import range import os, string, re, sys, math import commands, time import six diff --git a/RecoVertex/BeamSpotProducer/scripts/checkRuns.py b/RecoVertex/BeamSpotProducer/scripts/checkRuns.py index a38fffa24793f..e5490311398bc 100755 --- a/RecoVertex/BeamSpotProducer/scripts/checkRuns.py +++ b/RecoVertex/BeamSpotProducer/scripts/checkRuns.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import sys,os,commands,re import xmlrpclib from CommonMethods import * diff --git a/RecoVertex/BeamSpotProducer/scripts/createPayload.py b/RecoVertex/BeamSpotProducer/scripts/createPayload.py index 4afd212b84364..b73dc66b9f0af 100755 --- a/RecoVertex/BeamSpotProducer/scripts/createPayload.py +++ b/RecoVertex/BeamSpotProducer/scripts/createPayload.py @@ -37,6 +37,7 @@ from __future__ import print_function +from builtins import range import sys,os import commands, re, time import datetime diff --git a/RecoVertex/BeamSpotProducer/scripts/ntuplemaker.py b/RecoVertex/BeamSpotProducer/scripts/ntuplemaker.py index 850c2373ae5f8..8e18476ce2017 100755 --- a/RecoVertex/BeamSpotProducer/scripts/ntuplemaker.py +++ b/RecoVertex/BeamSpotProducer/scripts/ntuplemaker.py @@ -34,6 +34,7 @@ from __future__ import print_function +from builtins import range import os, string, re, sys, math import commands, time from BeamSpotObj import BeamSpot diff --git a/RecoVertex/BeamSpotProducer/scripts/plotBeamSpotDB.py b/RecoVertex/BeamSpotProducer/scripts/plotBeamSpotDB.py index 8498ff0871fb7..fa83ae88b6665 100755 --- a/RecoVertex/BeamSpotProducer/scripts/plotBeamSpotDB.py +++ b/RecoVertex/BeamSpotProducer/scripts/plotBeamSpotDB.py @@ -44,6 +44,7 @@ from __future__ import print_function +from builtins import range import os, string, re, sys, math import commands, time from BeamSpotObj import BeamSpot diff --git a/RecoVertex/BeamSpotProducer/scripts/rename.py b/RecoVertex/BeamSpotProducer/scripts/rename.py index d9e9d02f3d20f..907dd0ba84112 100755 --- a/RecoVertex/BeamSpotProducer/scripts/rename.py +++ b/RecoVertex/BeamSpotProducer/scripts/rename.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import sys,os,commands,re from CommonMethods import * def main(): diff --git a/RecoVertex/BeamSpotProducer/scripts/root/BxAnalysis/lumiregperbunch.py b/RecoVertex/BeamSpotProducer/scripts/root/BxAnalysis/lumiregperbunch.py index 9794dac95753c..0736ef60fc9d6 100755 --- a/RecoVertex/BeamSpotProducer/scripts/root/BxAnalysis/lumiregperbunch.py +++ b/RecoVertex/BeamSpotProducer/scripts/root/BxAnalysis/lumiregperbunch.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import sys,commands,os,calendar from ROOT import gDirectory,TFile diff --git a/RecoVertex/BeamSpotProducer/test/scripts/AnalyzeLumiScan.py b/RecoVertex/BeamSpotProducer/test/scripts/AnalyzeLumiScan.py index e4832d9d82171..1fd2fea7254f0 100644 --- a/RecoVertex/BeamSpotProducer/test/scripts/AnalyzeLumiScan.py +++ b/RecoVertex/BeamSpotProducer/test/scripts/AnalyzeLumiScan.py @@ -15,6 +15,7 @@ #____________________________________________________________ from __future__ import print_function +from builtins import range import sys,os,re,string import commands diff --git a/RecoVertex/BeamSpotProducer/test/scripts/PlotLumiScan.py b/RecoVertex/BeamSpotProducer/test/scripts/PlotLumiScan.py index 84b39a3c183a3..d66006a79960d 100644 --- a/RecoVertex/BeamSpotProducer/test/scripts/PlotLumiScan.py +++ b/RecoVertex/BeamSpotProducer/test/scripts/PlotLumiScan.py @@ -15,6 +15,7 @@ #____________________________________________________________ from __future__ import print_function +from builtins import range import sys,os import string from array import array diff --git a/RecoVertex/BeamSpotProducer/test/scripts/pv.py b/RecoVertex/BeamSpotProducer/test/scripts/pv.py index 2c141d91e2655..116af377af0d2 100644 --- a/RecoVertex/BeamSpotProducer/test/scripts/pv.py +++ b/RecoVertex/BeamSpotProducer/test/scripts/pv.py @@ -2,6 +2,7 @@ #import ROOT from __future__ import print_function +from builtins import range from ROOT import * #gROOT, TFile, TCanvas, TH1F, TH1I, TLegend, TH2F, gPad @@ -176,7 +177,7 @@ def main(): pvStore = ROOT.vector( BeamSpotFitPVData )(0) - for jentry in xrange( entries ): + for jentry in range( entries ): # get the next tree in the chain ientry = fchain.LoadTree(jentry) if ientry < 0: From 78d45648807de8e411d22f27d6afe97fb2dbd2cc Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 20:30:13 +0200 Subject: [PATCH 535/686] xrange mig --- .../python/config/fileinputsource_cfi.py | 1 + .../XMLcfgfiles/ExtractAppInfoFromXML.py | 1 + .../scripts/XMLcfgfiles/psClasses.py | 3 +- .../scripts/filecollector/fileCollector.py | 1 + .../scripts/filecollector/fileCollector2.py | 1 + .../scripts/harvesting_tools/cmsHarvester.py | 3 +- DQMServices/Components/python/HTTP.py | 3 +- .../Components/python/test/check_file4.py | 41 +++++----- .../python/test/check_merged_file1_file2.py | 21 ++--- .../test/check_merged_file1_file2_cfg.py | 21 ++--- .../check_merged_file1_file2_file3_cfg.py | 41 +++++----- .../python/test/check_merged_file1_file3.py | 41 +++++----- .../Components/python/test/createElements.py | 35 +++++---- .../Components/python/test/py2html_new.py | 1 + .../Components/test/test_fastHaddMerge.py | 1 + DQMServices/Components/test/whiteRabbit.py | 1 + DQMServices/FileIO/python/DQM.py | 5 +- DQMServices/FwkIO/scripts/DQMIO2histo.py | 5 +- .../FwkIO/test/check_lumi_only_file.py | 9 ++- .../FwkIO/test/check_merged_file1_file2.py | 17 ++-- ...rged_file1_file3_file2_filterOnRun1_cfg.py | 21 ++--- ...file1_file3_file2_filterOnRun1_copy_cfg.py | 17 ++-- DQMServices/FwkIO/test/check_multi_types.py | 21 ++--- DQMServices/FwkIO/test/check_run_lumi_file.py | 17 ++-- DQMServices/FwkIO/test/check_run_only_file.py | 11 +-- .../FwkIO/test/create_empty_file_cfg.py | 11 +-- DQMServices/FwkIO/test/create_file1_cfg.py | 11 +-- DQMServices/FwkIO/test/create_file2_cfg.py | 11 +-- DQMServices/FwkIO/test/create_file3_cfg.py | 11 +-- DQMServices/FwkIO/test/create_file4_cfg.py | 11 +-- .../FwkIO/test/create_file_multi_types_cfg.py | 3 +- .../FwkIO/test/create_lumi_only_file_cfg.py | 3 +- ...eate_one_run_one_lumi_run_only_file_cfg.py | 3 +- .../FwkIO/test/create_run_lumi_file_cfg.py | 3 +- .../FwkIO/test/create_run_only_file_cfg.py | 3 +- .../FwkIO/test/read_file1_file2_cfg.py | 13 ++-- .../FwkIO/test/read_file1_file3_cfg.py | 11 +-- .../FwkIO/test/read_lumi_only_file_cfg.py | 5 +- .../FwkIO/test/read_merged_file1_file2_cfg.py | 11 +-- .../test/read_merged_file1_file3_file2_cfg.py | 11 +-- .../test/read_merged_file1_file3_file4_cfg.py | 15 ++-- .../FwkIO/test/read_run_lumi_file_cfg.py | 5 +- .../FwkIO/test/read_run_only_file_cfg.py | 5 +- .../python/parserPerfsuiteMetadata.py | 15 ++-- .../Performance/scripts/cmsBenchmark.py | 1 + .../Performance/scripts/cmsPerfClient.py | 1 + .../Performance/scripts/cmsPerfCommons.py | 1 + .../Performance/scripts/cmsPerfPublish.py | 1 + .../Performance/scripts/cmsPerfRegress.py | 1 + .../Performance/scripts/cmsPerfServer.py | 1 + .../Performance/scripts/cmsPerfStripChart.py | 1 + .../Performance/scripts/cmsPerfSuite.py | 3 +- .../scripts/cmsRelvalreportInput.py | 1 + .../Performance/scripts/cmsTiming_parser.py | 1 + Validation/RecoTau/Tools/MultipleCompare.py | 1 + Validation/RecoTau/Tools/web_templates.py | 1 + Validation/RecoTau/python/compare.py | 1 + Validation/RecoTau/python/runTauDisplay.py | 1 + Validation/RecoTau/test/LXBatchValidation.py | 3 +- .../python/plotting/ntupleDataFormat.py | 15 ++-- .../python/plotting/ntuplePrintersDiff.py | 3 +- .../RecoTrack/python/plotting/plotting.py | 77 ++++++++++--------- .../python/plotting/trackingPlots.py | 15 ++-- Validation/RecoTrack/test/analyseMVA.py | 3 +- .../RecoTrack/test/fakeAnalysis/analysis.py | 1 + .../RecoTrack/test/fakeAnalysis/graphics.py | 1 + .../test/fakeAnalysis/graphics_vertical.py | 1 + Validation/RecoTrack/test/publicPlots/plot.py | 3 +- .../RecoVertex/python/plotting/vertexPlots.py | 9 ++- Validation/Tools/python/GenObject.py | 23 +++--- Validation/Tools/scripts/diffTreeTool.py | 1 + .../Tools/scripts/simpleEdmComparison.py | 3 +- .../useReflexToDescribeForGenObject.py | 1 + 73 files changed, 374 insertions(+), 301 deletions(-) diff --git a/DQM/Integration/python/config/fileinputsource_cfi.py b/DQM/Integration/python/config/fileinputsource_cfi.py index df1bc4fc1cfba..0d83f7083d335 100644 --- a/DQM/Integration/python/config/fileinputsource_cfi.py +++ b/DQM/Integration/python/config/fileinputsource_cfi.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import FWCore.ParameterSet.Config as cms # Parameters for runType diff --git a/DQM/Integration/scripts/XMLcfgfiles/ExtractAppInfoFromXML.py b/DQM/Integration/scripts/XMLcfgfiles/ExtractAppInfoFromXML.py index fa1fd9e766b51..e0edc6e70a418 100755 --- a/DQM/Integration/scripts/XMLcfgfiles/ExtractAppInfoFromXML.py +++ b/DQM/Integration/scripts/XMLcfgfiles/ExtractAppInfoFromXML.py @@ -21,6 +21,7 @@ """ from __future__ import print_function ################################################################################ +from builtins import range import sys, os.path from xml.dom import minidom ################################################################################ diff --git a/DQM/Integration/scripts/XMLcfgfiles/psClasses.py b/DQM/Integration/scripts/XMLcfgfiles/psClasses.py index e98e83b0cd36e..e026666643670 100644 --- a/DQM/Integration/scripts/XMLcfgfiles/psClasses.py +++ b/DQM/Integration/scripts/XMLcfgfiles/psClasses.py @@ -1,10 +1,11 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os,subprocess,sys,re,time,random from threading import * from subprocess import call #Some Constants -STATE_CREATED,STATE_COMPLETED,STATE_ERROR=range(3) +STATE_CREATED,STATE_COMPLETED,STATE_ERROR=list(range(3)) ### Classes class BuildThread(Thread): diff --git a/DQM/Integration/scripts/filecollector/fileCollector.py b/DQM/Integration/scripts/filecollector/fileCollector.py index 772e69b59869c..7f9d445a806d2 100755 --- a/DQM/Integration/scripts/filecollector/fileCollector.py +++ b/DQM/Integration/scripts/filecollector/fileCollector.py @@ -1,5 +1,6 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os, time, sys, glob, re, shutil, stat, smtplib, socket from email.MIMEText import MIMEText from fcntl import lockf, LOCK_EX, LOCK_UN diff --git a/DQM/Integration/scripts/filecollector/fileCollector2.py b/DQM/Integration/scripts/filecollector/fileCollector2.py index d11c93f428d37..d928694b45c17 100755 --- a/DQM/Integration/scripts/filecollector/fileCollector2.py +++ b/DQM/Integration/scripts/filecollector/fileCollector2.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os,time,sys,zipfile,re,shutil,stat from fcntl import lockf, LOCK_EX, LOCK_UN from hashlib import md5 diff --git a/DQM/Integration/scripts/harvesting_tools/cmsHarvester.py b/DQM/Integration/scripts/harvesting_tools/cmsHarvester.py index e4b7cd9a6711f..7921ef2bbceca 100755 --- a/DQM/Integration/scripts/harvesting_tools/cmsHarvester.py +++ b/DQM/Integration/scripts/harvesting_tools/cmsHarvester.py @@ -35,6 +35,7 @@ ########################################################################### +from builtins import range __version__ = "3.8.2p1" # (version jump to match release) __author__ = "Jeroen Hegeman (jeroen.hegeman@cern.ch)," \ "Niklas Pietsch (niklas.pietsch@desy.de)" @@ -1568,7 +1569,7 @@ def extract_permissions(rfstat_output): path = "" check_sizes = sorted(castor_paths_dont_touch.keys()) len_castor_path_pieces = len(castor_path_pieces) - for piece_index in xrange (len_castor_path_pieces): + for piece_index in range (len_castor_path_pieces): skip_this_path_piece = False piece = castor_path_pieces[piece_index] ## self.logger.debug("Checking CASTOR path piece `%s'" % \ diff --git a/DQMServices/Components/python/HTTP.py b/DQMServices/Components/python/HTTP.py index 9f1dc73828dd1..3c6c2dd26d36e 100644 --- a/DQMServices/Components/python/HTTP.py +++ b/DQMServices/Components/python/HTTP.py @@ -1,3 +1,4 @@ +from builtins import range from cStringIO import StringIO from pycurl import * @@ -46,7 +47,7 @@ def __init__(self, num_connections = 10, ssl_opts = None, self.request_error = request_error or self._request_error self.request_init = request_init or self._request_init self.cm = CurlMulti() - self.handles = [Curl() for i in xrange(0, num_connections)] + self.handles = [Curl() for i in range(0, num_connections)] self.free = [c for c in self.handles] self.queue = [] diff --git a/DQMServices/Components/python/test/check_file4.py b/DQMServices/Components/python/test/check_file4.py index 5837545a84b08..29cc45f455f67 100644 --- a/DQMServices/Components/python/test/check_file4.py +++ b/DQMServices/Components/python/test/check_file4.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -56,22 +57,22 @@ nLumiPerRun = 10 startIndex = 0 lastIndex =-1 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 1, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 1.0)) expectedIndices.append( (i + 1, 0, 3, startIndex, lastIndex) ) @@ -82,22 +83,22 @@ nHistsFoo = 10 nHistsBar = 2 nLumiPerRun = 10 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 2, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 1.0)) expectedIndices.append( (i + 2, 0, 3, startIndex, lastIndex) ) @@ -115,8 +116,8 @@ indexTreeIndex = 0 # First check on Run 1 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -124,7 +125,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -135,7 +136,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -147,8 +148,8 @@ indexTreeIndex +=1 # Second check on Run 2 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -156,7 +157,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -167,7 +168,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/Components/python/test/check_merged_file1_file2.py b/DQMServices/Components/python/test/check_merged_file1_file2.py index 1c13db0a1dd6e..cd1c5c6fbd47f 100644 --- a/DQMServices/Components/python/test/check_merged_file1_file2.py +++ b/DQMServices/Components/python/test/check_merged_file1_file2.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -46,22 +47,22 @@ nLumiPerRun = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 1, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 110.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 2.0)) expectedIndices.append( (i + 1, 0, 3, startIndex, lastIndex) ) @@ -78,8 +79,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -87,7 +88,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -98,7 +99,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/Components/python/test/check_merged_file1_file2_cfg.py b/DQMServices/Components/python/test/check_merged_file1_file2_cfg.py index 1c13db0a1dd6e..cd1c5c6fbd47f 100644 --- a/DQMServices/Components/python/test/check_merged_file1_file2_cfg.py +++ b/DQMServices/Components/python/test/check_merged_file1_file2_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -46,22 +47,22 @@ nLumiPerRun = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 1, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 110.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 2.0)) expectedIndices.append( (i + 1, 0, 3, startIndex, lastIndex) ) @@ -78,8 +79,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -87,7 +88,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -98,7 +99,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/Components/python/test/check_merged_file1_file2_file3_cfg.py b/DQMServices/Components/python/test/check_merged_file1_file2_file3_cfg.py index 0ea13164bfc32..cf132b98d4c07 100644 --- a/DQMServices/Components/python/test/check_merged_file1_file2_file3_cfg.py +++ b/DQMServices/Components/python/test/check_merged_file1_file2_file3_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -56,22 +57,22 @@ nLumiPerRun1 = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun1): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun1): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 1, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 110.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 2.0)) expectedIndices.append( (i + 1, 0, 3, startIndex, lastIndex) ) @@ -82,22 +83,22 @@ nHistsFoo = 10 nHistsBar = 2 nLumiPerRun2 = 10 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun2): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun2): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 2, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 1.0)) expectedIndices.append( (i + 2, 0, 3, startIndex, lastIndex) ) @@ -116,8 +117,8 @@ indexTreeIndex = 0 # First check on Run 1 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun1): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun1): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -125,7 +126,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -136,7 +137,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -148,8 +149,8 @@ indexTreeIndex +=1 # Second check on Run 2 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun2): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun2): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -157,7 +158,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -168,7 +169,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/Components/python/test/check_merged_file1_file3.py b/DQMServices/Components/python/test/check_merged_file1_file3.py index 21edf960d2a3b..634e40068b451 100644 --- a/DQMServices/Components/python/test/check_merged_file1_file3.py +++ b/DQMServices/Components/python/test/check_merged_file1_file3.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -56,22 +57,22 @@ nLumiPerRun = 10 startIndex = 0 lastIndex =-1 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 1, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 1.0)) expectedIndices.append( (i + 1, 0, 3, startIndex, lastIndex) ) @@ -82,22 +83,22 @@ nHistsFoo = 10 nHistsBar = 2 nLumiPerRun = 10 -for i in xrange(0, nRuns): +for i in range(0, nRuns): # LS-based histograms follow - for l in xrange(0, nLumiPerRun): - for j in xrange(0, nHistsBar): + for l in range(0, nLumiPerRun): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j) + "_lumi", 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j) + "_lumi", 0, 1.0)) expectedIndices.append( (i + 2, l + 1, 3, startIndex, lastIndex) ) startIndex = lastIndex + 1 # Run-based histograms follow - for j in xrange(0, nHistsBar): + for j in range(0, nHistsBar): lastIndex += 1 values.append((folder + "Bar" + str(j), 0, 55.0)) - for j in xrange(0, nHistsFoo): + for j in range(0, nHistsFoo): lastIndex += 1 values.append((folder + "Foo" + str(j), 0, 1.0)) expectedIndices.append( (i + 2, 0, 3, startIndex, lastIndex) ) @@ -115,8 +116,8 @@ indexTreeIndex = 0 # First check on Run 1 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -124,7 +125,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -135,7 +136,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -147,8 +148,8 @@ indexTreeIndex +=1 # Second check on Run 2 -for run in xrange(0, nRuns): - for lumi in xrange(0, nLumiPerRun): +for run in range(0, nRuns): + for lumi in range(0, nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run, indices.Lumi, indices.Type, indices.FirstIndex, indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -156,7 +157,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:', v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -167,7 +168,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/Components/python/test/createElements.py b/DQMServices/Components/python/test/createElements.py index dd35b383f83c6..58353348c1936 100644 --- a/DQMServices/Components/python/test/createElements.py +++ b/DQMServices/Components/python/test/createElements.py @@ -1,9 +1,10 @@ #!/usr/bin/env python +from builtins import range import FWCore.ParameterSet.Config as cms def createElements(): elements = list() - for i in xrange(0,10): + for i in range(0,10): elements.append(cms.untracked.PSet(lowX = cms.untracked.double(0), highX = cms.untracked.double(11), nchX = cms.untracked.int32(11), @@ -30,7 +31,7 @@ def createElements(): def createReadRunElements(): readRunElements = list() - for i in xrange(0,10): + for i in range(0,10): readRunElements.append(cms.untracked.PSet(name = cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries = cms.untracked.vdouble(1) @@ -45,18 +46,18 @@ def createReadRunElements(): def createReadLumiElements(): readLumiElements = list() - for i in xrange(0,10): + for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Bar0"), - means = cms.untracked.vdouble([7 for x in xrange(0,10)]), - entries=cms.untracked.vdouble([55 for x in xrange(0,10)]) + means = cms.untracked.vdouble([7 for x in range(0,10)]), + entries=cms.untracked.vdouble([55 for x in range(0,10)]) )) readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Bar1"), - means = cms.untracked.vdouble([3 for x in xrange(0,10)]), - entries=cms.untracked.vdouble([55 for x in xrange(0,10)]) + means = cms.untracked.vdouble([3 for x in range(0,10)]), + entries=cms.untracked.vdouble([55 for x in range(0,10)]) )) return readLumiElements @@ -64,7 +65,7 @@ def createReadLumiElements(): def createReadRunElements_merged_file1_file2(): readRunElements = list() - for i in xrange(0,10): + for i in range(0,10): readRunElements.append(cms.untracked.PSet(name = cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries = cms.untracked.vdouble(2) @@ -79,17 +80,17 @@ def createReadRunElements_merged_file1_file2(): def createReadLumiElements_merged_file1_file2(): readLumiElements = list() - for i in xrange(0,10): + for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,20)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,20)]) + means = cms.untracked.vdouble([i for x in range(0,20)]), + entries=cms.untracked.vdouble([1 for x in range(0,20)]) )) readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Bar0"), - means = cms.untracked.vdouble([7 for x in xrange(0,20)]), - entries=cms.untracked.vdouble([55 for x in xrange(0,20)]) + means = cms.untracked.vdouble([7 for x in range(0,20)]), + entries=cms.untracked.vdouble([55 for x in range(0,20)]) )) readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Bar1"), - means = cms.untracked.vdouble([3 for x in xrange(0,20)]), - entries=cms.untracked.vdouble([55 for x in xrange(0,20)]) + means = cms.untracked.vdouble([3 for x in range(0,20)]), + entries=cms.untracked.vdouble([55 for x in range(0,20)]) )) return readLumiElements diff --git a/DQMServices/Components/python/test/py2html_new.py b/DQMServices/Components/python/test/py2html_new.py index 3b938f8308bbb..e2076dabccccd 100755 --- a/DQMServices/Components/python/test/py2html_new.py +++ b/DQMServices/Components/python/test/py2html_new.py @@ -3,6 +3,7 @@ # Created: Tue Feb 9 10:06:02 CEST 2010 from __future__ import print_function +from builtins import range import re import sys, os import sqlite3 diff --git a/DQMServices/Components/test/test_fastHaddMerge.py b/DQMServices/Components/test/test_fastHaddMerge.py index 05591a80318bd..97dc8c2a2c417 100644 --- a/DQMServices/Components/test/test_fastHaddMerge.py +++ b/DQMServices/Components/test/test_fastHaddMerge.py @@ -7,6 +7,7 @@ """ from __future__ import print_function +from builtins import range from optparse import OptionParser import sys import commands diff --git a/DQMServices/Components/test/whiteRabbit.py b/DQMServices/Components/test/whiteRabbit.py index 9e106472ef896..ced12a382c424 100755 --- a/DQMServices/Components/test/whiteRabbit.py +++ b/DQMServices/Components/test/whiteRabbit.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -u from __future__ import print_function +from builtins import range import os, sys, re, time, commands, glob from optparse import OptionParser, OptionGroup from threading import Thread diff --git a/DQMServices/FileIO/python/DQM.py b/DQMServices/FileIO/python/DQM.py index fe176b663cba2..70d9974ac0092 100644 --- a/DQMServices/FileIO/python/DQM.py +++ b/DQMServices/FileIO/python/DQM.py @@ -1,6 +1,7 @@ #!/bin/env python from __future__ import print_function +from builtins import range import ROOT as R import os, re @@ -33,7 +34,7 @@ def read_objects(self): def read_objects_dqmio(self): indices = self._root_file.Get("Indices") - for y in xrange(indices.GetEntries()): + for y in range(indices.GetEntries()): indices.GetEntry(y) # print indices.Run, indices.Lumi, indices.Type @@ -45,7 +46,7 @@ def read_objects_dqmio(self): object_type = self.DQMIO_TYPES[indices.Type] t_tree = self._root_file.Get(object_type) - for i in xrange(indices.FirstIndex, indices.LastIndex + 1): + for i in range(indices.FirstIndex, indices.LastIndex + 1): t_tree.GetEntry(i) fullname = str(t_tree.FullName) diff --git a/DQMServices/FwkIO/scripts/DQMIO2histo.py b/DQMServices/FwkIO/scripts/DQMIO2histo.py index 49c6a0cd7f3c6..a4f90c582a2a5 100755 --- a/DQMServices/FwkIO/scripts/DQMIO2histo.py +++ b/DQMServices/FwkIO/scripts/DQMIO2histo.py @@ -9,6 +9,7 @@ """ from __future__ import print_function +from builtins import range import ROOT as R import sys import re @@ -51,13 +52,13 @@ def print_index(self): if args.debug: print("## DEBUG ##:") print("Run,\tLumi,\tType,\t\tFirstIndex,\tLastIndex") - for i in xrange(indices.GetEntries()): + for i in range(indices.GetEntries()): indices.GetEntry(i) print('{0:4d}\t{1:4d}\t{2:4d}({3:s})\t\t{4:4d}\t{5:4d}'.format( indices.Run, indices.Lumi, indices.Type, DQMIO.types[indices.Type], indices.FirstIndex, indices.LastIndex)) - for i in xrange(indices.GetEntries()): + for i in range(indices.GetEntries()): indices.GetEntry(i) if indices.Type < len(DQMIO.types): self.write_to_file(self.types[indices.Type], diff --git a/DQMServices/FwkIO/test/check_lumi_only_file.py b/DQMServices/FwkIO/test/check_lumi_only_file.py index c3a3943cd22b1..8dff09c8a46de 100644 --- a/DQMServices/FwkIO/test/check_lumi_only_file.py +++ b/DQMServices/FwkIO/test/check_lumi_only_file.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -14,8 +15,8 @@ nHists = 10 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for j in xrange(0,nHists): +for i in range(0,nRuns): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,1,3,startIndex,lastIndex) ) @@ -30,7 +31,7 @@ print("wrong number of entries in Indices", indices.GetEntries()) sys.exit(1) -for run in xrange(0,nRuns): +for run in range(0,nRuns): indices.GetEntry(run) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[run]: @@ -38,7 +39,7 @@ print(' expected:', expectedIndices[run]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_merged_file1_file2.py b/DQMServices/FwkIO/test/check_merged_file1_file2.py index d2822dc07e33a..3ac54143eb6da 100644 --- a/DQMServices/FwkIO/test/check_merged_file1_file2.py +++ b/DQMServices/FwkIO/test/check_merged_file1_file2.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -15,14 +16,14 @@ nLumiPerRun = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for l in xrange(0,nLumiPerRun): - for j in xrange(0,nHists): +for i in range(0,nRuns): + for l in range(0,nLumiPerRun): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,l+1,3,startIndex,lastIndex) ) startIndex = lastIndex+1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 2.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) @@ -39,8 +40,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0,nRuns): - for lumi in xrange(0,nLumiPerRun): +for run in range(0,nRuns): + for lumi in range(0,nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -48,7 +49,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -59,7 +60,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_cfg.py b/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_cfg.py index ab3187bfb2655..283b47172e1c0 100644 --- a/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_cfg.py +++ b/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -15,20 +16,20 @@ nLumiPerRun = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for l in xrange(0,nLumiPerRun): +for i in range(0,nRuns): + for l in range(0,nLumiPerRun): if l == 10: - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 1.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) startIndex = lastIndex+1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,l+1,3,startIndex,lastIndex) ) startIndex = lastIndex+1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 1.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) @@ -45,8 +46,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0,nRuns): - for lumi in xrange(0,nLumiPerRun): +for run in range(0,nRuns): + for lumi in range(0,nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -54,7 +55,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -65,7 +66,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -76,7 +77,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_copy_cfg.py b/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_copy_cfg.py index 1ef1bf3e1c811..e4dafcdb6b6ac 100644 --- a/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_copy_cfg.py +++ b/DQMServices/FwkIO/test/check_merged_file1_file3_file2_filterOnRun1_copy_cfg.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -15,14 +16,14 @@ nLumiPerRun = 20 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for l in xrange(0,nLumiPerRun): - for j in xrange(0,nHists): +for i in range(0,nRuns): + for l in range(0,nLumiPerRun): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,l+1,3,startIndex,lastIndex) ) startIndex = lastIndex+1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 2.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) @@ -39,8 +40,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0,nRuns): - for lumi in xrange(0,nLumiPerRun): +for run in range(0,nRuns): + for lumi in range(0,nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -48,7 +49,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -59,7 +60,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_multi_types.py b/DQMServices/FwkIO/test/check_multi_types.py index dab0d124b14ed..27881a08d3aa5 100644 --- a/DQMServices/FwkIO/test/check_multi_types.py +++ b/DQMServices/FwkIO/test/check_multi_types.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -18,17 +19,17 @@ startIndex = 0 lastIndex =-1 typeValues =[3,6] -for i in xrange(0,nRuns): - for l in xrange(0,nLumiPerRun): - for t in xrange(0,nTypes): +for i in range(0,nRuns): + for l in range(0,nLumiPerRun): + for t in range(0,nTypes): lastIndex = startIndex-1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,l+1,typeValues[t],startIndex,lastIndex) ) startIndex = lastIndex+1 - for t in xrange(0,nTypes): - for j in xrange(0,nHists): + for t in range(0,nTypes): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 2.0)) expectedIndices.append( (i+1,0,typeValues[t],startIndex,lastIndex) ) @@ -49,8 +50,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0,nRuns): - for lumi in xrange(0,nLumiPerRun): +for run in range(0,nRuns): + for lumi in range(0,nLumiPerRun): indices.GetEntry(indexTreeIndex) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -58,7 +59,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -69,7 +70,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_run_lumi_file.py b/DQMServices/FwkIO/test/check_run_lumi_file.py index 7098adea23f7c..83e6d6767c086 100644 --- a/DQMServices/FwkIO/test/check_run_lumi_file.py +++ b/DQMServices/FwkIO/test/check_run_lumi_file.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -15,14 +16,14 @@ nLumiPerRun = 1 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for l in xrange(0,1): - for j in xrange(0,nHists): +for i in range(0,nRuns): + for l in range(0,1): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j)+"_lumi", 0, 1.0)) expectedIndices.append( (i+1,l+1,3,startIndex,lastIndex) ) startIndex = lastIndex+1 - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 1.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) @@ -38,8 +39,8 @@ sys.exit(1) indexTreeIndex = 0 -for run in xrange(0,nRuns): - for lumi in xrange(0,1): +for run in range(0,nRuns): + for lumi in range(0,1): indices.GetEntry(indexTreeIndex) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[indexTreeIndex]: @@ -47,7 +48,7 @@ print(' expected:', expectedIndices[indexTreeIndex]) print(' found:',v) sys.exit(1) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) @@ -58,7 +59,7 @@ sys.exit(1) indexTreeIndex +=1 indices.GetEntry(indexTreeIndex) - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/check_run_only_file.py b/DQMServices/FwkIO/test/check_run_only_file.py index c759ce385f78f..7da1dc3ed51f4 100644 --- a/DQMServices/FwkIO/test/check_run_only_file.py +++ b/DQMServices/FwkIO/test/check_run_only_file.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT as R import sys @@ -15,11 +16,11 @@ nHists = 10 startIndex = 0 lastIndex =-1 -for i in xrange(0,nRuns): - for l in xrange(0,nLumiPerRun): +for i in range(0,nRuns): + for l in range(0,nLumiPerRun): #we put dummy lumi entries in for each lumi seen expectedIndices.append((i+1,l+1,1000,0,0)) - for j in xrange(0,nHists): + for j in range(0,nHists): lastIndex +=1 values.append(("Foo"+str(j), 0, 1.0)) expectedIndices.append( (i+1,0,3,startIndex,lastIndex) ) @@ -34,7 +35,7 @@ print("wrong number of entries in Indices", indices.GetEntries()) sys.exit(1) -for run in xrange(0,nRuns+nRuns*nLumiPerRun): +for run in range(0,nRuns+nRuns*nLumiPerRun): indices.GetEntry(run) v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex) if v != expectedIndices[run]: @@ -43,7 +44,7 @@ print(' found:',v) sys.exit(1) if indices.Type !=1000: - for ihist in xrange(indices.FirstIndex,indices.LastIndex+1): + for ihist in range(indices.FirstIndex,indices.LastIndex+1): index = ihist th1fs.GetEntry(ihist) v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries()) diff --git a/DQMServices/FwkIO/test/create_empty_file_cfg.py b/DQMServices/FwkIO/test/create_empty_file_cfg.py index e463aebb3595e..af5d5582c3e52 100644 --- a/DQMServices/FwkIO/test/create_empty_file_cfg.py +++ b/DQMServices/FwkIO/test/create_empty_file_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -7,7 +8,7 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(11), nchX=cms.untracked.int32(11), @@ -24,17 +25,17 @@ fileName = cms.untracked.string("dqm_empty.root")) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(1) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/create_file1_cfg.py b/DQMServices/FwkIO/test/create_file1_cfg.py index c309b4a99bc29..dca0d853c14b2 100644 --- a/DQMServices/FwkIO/test/create_file1_cfg.py +++ b/DQMServices/FwkIO/test/create_file1_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -7,7 +8,7 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(11), nchX=cms.untracked.int32(11), @@ -24,17 +25,17 @@ fileName = cms.untracked.string("dqm_file1.root")) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(1) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/create_file2_cfg.py b/DQMServices/FwkIO/test/create_file2_cfg.py index 50b9cc17a0d7c..582253f77dda4 100644 --- a/DQMServices/FwkIO/test/create_file2_cfg.py +++ b/DQMServices/FwkIO/test/create_file2_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -7,7 +8,7 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(11), nchX=cms.untracked.int32(11), @@ -24,17 +25,17 @@ fileName = cms.untracked.string("dqm_file2.root")) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(1) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/create_file3_cfg.py b/DQMServices/FwkIO/test/create_file3_cfg.py index 6d67610bdd370..d063b0db214a2 100644 --- a/DQMServices/FwkIO/test/create_file3_cfg.py +++ b/DQMServices/FwkIO/test/create_file3_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -8,7 +9,7 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(11), nchX=cms.untracked.int32(11), @@ -25,17 +26,17 @@ fileName = cms.untracked.string("dqm_file3.root")) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i+1), entries=cms.untracked.vdouble(1) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i+1 for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i+1 for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/create_file4_cfg.py b/DQMServices/FwkIO/test/create_file4_cfg.py index 835d8c3950601..cc11bddc4e5ae 100644 --- a/DQMServices/FwkIO/test/create_file4_cfg.py +++ b/DQMServices/FwkIO/test/create_file4_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -7,7 +8,7 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(11), nchX=cms.untracked.int32(11), @@ -27,17 +28,17 @@ fileName = cms.untracked.string("dqm_file4.root")) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(1) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,10)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,10)]) + means = cms.untracked.vdouble([i for x in range(0,10)]), + entries=cms.untracked.vdouble([1 for x in range(0,10)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/create_file_multi_types_cfg.py b/DQMServices/FwkIO/test/create_file_multi_types_cfg.py index 9703d8dc160a7..4297ed4a01c3d 100644 --- a/DQMServices/FwkIO/test/create_file_multi_types_cfg.py +++ b/DQMServices/FwkIO/test/create_file_multi_types_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") @@ -9,7 +10,7 @@ elements = list() extensions = ["","2D"] for t in [0,1]: - for i in xrange(0,10): + for i in range(0,10): elements.append(cms.untracked.PSet(type = cms.untracked.uint32(t+1), lowX=cms.untracked.double(0), highX=cms.untracked.double(10), diff --git a/DQMServices/FwkIO/test/create_lumi_only_file_cfg.py b/DQMServices/FwkIO/test/create_lumi_only_file_cfg.py index d15e5520c3a49..548011decaddf 100644 --- a/DQMServices/FwkIO/test/create_lumi_only_file_cfg.py +++ b/DQMServices/FwkIO/test/create_lumi_only_file_cfg.py @@ -1,10 +1,11 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") process.source = cms.Source("EmptySource", numberEventsInRun = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(10), nchX=cms.untracked.int32(10), diff --git a/DQMServices/FwkIO/test/create_one_run_one_lumi_run_only_file_cfg.py b/DQMServices/FwkIO/test/create_one_run_one_lumi_run_only_file_cfg.py index 29c0975b10271..197b34f9dd12b 100644 --- a/DQMServices/FwkIO/test/create_one_run_one_lumi_run_only_file_cfg.py +++ b/DQMServices/FwkIO/test/create_one_run_one_lumi_run_only_file_cfg.py @@ -1,10 +1,11 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") process.source = cms.Source("EmptySource", numberEventsInRun = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(10), nchX=cms.untracked.int32(10), diff --git a/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py b/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py index b0d1fbffebf76..c6e72fc0960cc 100644 --- a/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py +++ b/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py @@ -1,10 +1,11 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") process.source = cms.Source("EmptySource", numberEventsInRun = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(10), nchX=cms.untracked.int32(10), diff --git a/DQMServices/FwkIO/test/create_run_only_file_cfg.py b/DQMServices/FwkIO/test/create_run_only_file_cfg.py index d34fbb9374c25..01eb03d3deceb 100644 --- a/DQMServices/FwkIO/test/create_run_only_file_cfg.py +++ b/DQMServices/FwkIO/test/create_run_only_file_cfg.py @@ -1,10 +1,11 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process =cms.Process("TEST") process.source = cms.Source("EmptySource", numberEventsInRun = cms.untracked.uint32(1)) elements = list() -for i in xrange(0,10): +for i in range(0,10): elements.append(cms.untracked.PSet(lowX=cms.untracked.double(0), highX=cms.untracked.double(10), nchX=cms.untracked.int32(10), diff --git a/DQMServices/FwkIO/test/read_file1_file2_cfg.py b/DQMServices/FwkIO/test/read_file1_file2_cfg.py index 5ca43bfc8e6bc..5f8df650193a3 100644 --- a/DQMServices/FwkIO/test/read_file1_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_file1_file2_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -6,10 +7,10 @@ fileNames = cms.untracked.vstring("file:dqm_file1.root","file:dqm_file2.root")) seq = cms.untracked.VEventID() -for r in xrange(1,2): +for r in range(1,2): #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,21): + for l in range(1,21): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -21,17 +22,17 @@ eventSequence = seq) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(2) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,20)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,20)]) + means = cms.untracked.vdouble([i for x in range(0,20)]), + entries=cms.untracked.vdouble([1 for x in range(0,20)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/read_file1_file3_cfg.py b/DQMServices/FwkIO/test/read_file1_file3_cfg.py index dfc6b9ab45d53..a300a52d1383e 100644 --- a/DQMServices/FwkIO/test/read_file1_file3_cfg.py +++ b/DQMServices/FwkIO/test/read_file1_file3_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -9,7 +10,7 @@ for r in [1,2]: #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,11): + for l in range(1,11): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -21,18 +22,18 @@ eventSequence = seq) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble([i+x for x in (0,1)]), entries=cms.untracked.vdouble([1 for x in (0,1)]) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), #file3 has means shifted by 1 - means = cms.untracked.vdouble([i+x/10 for x in xrange(0,20)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,20)]) + means = cms.untracked.vdouble([i+x/10 for x in range(0,20)]), + entries=cms.untracked.vdouble([1 for x in range(0,20)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py b/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py index 760b55f855472..5a2e283d5df27 100644 --- a/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py +++ b/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -6,10 +7,10 @@ fileNames = cms.untracked.vstring("file:dqm_lumi_only.root")) seq = cms.untracked.VEventID() -for r in xrange(1,11): +for r in range(1,11): #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,2): + for l in range(1,2): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi diff --git a/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py index 62adbb56b2133..bb2660673c42d 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -10,7 +11,7 @@ for r in [1,]: #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,lumisPerRun[r-1]): + for l in range(1,lumisPerRun[r-1]): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -22,17 +23,17 @@ eventSequence = seq) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble(i), entries=cms.untracked.vdouble(2) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), - means = cms.untracked.vdouble([i for x in xrange(0,20)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,20)]) + means = cms.untracked.vdouble([i for x in range(0,20)]), + entries=cms.untracked.vdouble([1 for x in range(0,20)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py index d1cdaf0e35810..c65bc9f9a30da 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -10,7 +11,7 @@ for r in [1,2]: #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,lumisPerRun[r-1]): + for l in range(1,lumisPerRun[r-1]): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -22,18 +23,18 @@ eventSequence = seq) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble([i+x for x in (0,1)]), entries=cms.untracked.vdouble([x for x in (2,1)]) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), #file3, which is run 2 has means shifted by 1 - means = cms.untracked.vdouble([i+x/20 for x in xrange(0,30)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,30)]) + means = cms.untracked.vdouble([i+x/20 for x in range(0,30)]), + entries=cms.untracked.vdouble([1 for x in range(0,30)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py index 0aa38ed7127a6..69ec7e13f2c65 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -10,7 +11,7 @@ r = 1 #begin run seq.append(cms.EventID(r,0,0)) -for l in xrange(1,11): +for l in range(1,11): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -20,7 +21,7 @@ r = 2 #begin run seq.append(cms.EventID(r,0,0)) -for l in xrange(1,11): +for l in range(1,11): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -30,7 +31,7 @@ r = 1 #begin run seq.append(cms.EventID(r,0,0)) -for l in xrange(100,110): +for l in range(100,110): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi @@ -42,18 +43,18 @@ eventSequence = seq) readRunElements = list() -for i in xrange(0,10): +for i in range(0,10): readRunElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), means = cms.untracked.vdouble([i+x for x in (0,1,0)]), entries=cms.untracked.vdouble([x for x in (1,1,1)]) )) readLumiElements=list() -for i in xrange(0,10): +for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), #file3, which is run 2 has means shifted by 1 - means = cms.untracked.vdouble([(i+x/10-x/20-x/20) for x in xrange(0,30)]), - entries=cms.untracked.vdouble([1 for x in xrange(0,30)]) + means = cms.untracked.vdouble([(i+x/10-x/20-x/20) for x in range(0,30)]), + entries=cms.untracked.vdouble([1 for x in range(0,30)]) )) process.reader = cms.EDAnalyzer("DummyReadDQMStore", diff --git a/DQMServices/FwkIO/test/read_run_lumi_file_cfg.py b/DQMServices/FwkIO/test/read_run_lumi_file_cfg.py index 39d23a4f62729..ea1cbdee54730 100644 --- a/DQMServices/FwkIO/test/read_run_lumi_file_cfg.py +++ b/DQMServices/FwkIO/test/read_run_lumi_file_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -6,10 +7,10 @@ fileNames = cms.untracked.vstring("file:dqm_run_lumi.root")) seq = cms.untracked.VEventID() -for r in xrange(1,11): +for r in range(1,11): #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,2): + for l in range(1,2): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi diff --git a/DQMServices/FwkIO/test/read_run_only_file_cfg.py b/DQMServices/FwkIO/test/read_run_only_file_cfg.py index cbac290dfbe10..63b49cf5dacb8 100644 --- a/DQMServices/FwkIO/test/read_run_only_file_cfg.py +++ b/DQMServices/FwkIO/test/read_run_only_file_cfg.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms process = cms.Process("READ") @@ -7,10 +8,10 @@ #NOTE: even though we only store histograms on runs, we still record the lumis that were seen seq = cms.untracked.VEventID() -for r in xrange(1,11): +for r in range(1,11): #begin run seq.append(cms.EventID(r,0,0)) - for l in xrange(1,2): + for l in range(1,2): #begin lumi seq.append(cms.EventID(r,l,0)) #end lumi diff --git a/Validation/Performance/python/parserPerfsuiteMetadata.py b/Validation/Performance/python/parserPerfsuiteMetadata.py index 58085537ba836..a3bf716bf4728 100644 --- a/Validation/Performance/python/parserPerfsuiteMetadata.py +++ b/Validation/Performance/python/parserPerfsuiteMetadata.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import re import os, sys import time @@ -120,7 +121,7 @@ def findFirstIndex_ofStartsWith(job_lines, start_of_line): def findLineBefore(self, line_index, lines, test_condition): """ finds a line satisfying the `test_condition` comming before the `line_index` """ # we're going backwards the lines list - for line_index in xrange(line_index -1, -1, -1): + for line_index in range(line_index -1, -1, -1): line = lines[line_index] if test_condition(line): @@ -131,7 +132,7 @@ def findLineBefore(self, line_index, lines, test_condition): def findLineAfter(self, line_index, lines, test_condition, return_index = False): """ finds a line satisfying the `test_condition` comming after the `line_index` """ # we're going forward the lines list - for line_index in xrange(line_index + 1, len(lines)): + for line_index in range(line_index + 1, len(lines)): line = lines[line_index] if test_condition(line): @@ -322,11 +323,11 @@ def parseGeneralInfo(self): """ tags_start_index = -1 # set some default try: - tags_start_index = [i for i in xrange(0, len(lines)) if lines[i].startswith("--- Tag ---")][0] + tags_start_index = [i for i in range(0, len(lines)) if lines[i].startswith("--- Tag ---")][0] except: pass if tags_start_index > -1: - tags_end_index = [i for i in xrange(tags_start_index + 1, len(lines)) if lines[i].startswith("---------------------------------------")][0] + tags_end_index = [i for i in range(tags_start_index + 1, len(lines)) if lines[i].startswith("---------------------------------------")][0] # print "tags start index: %s, end index: %s" % (tags_start_index, tags_end_index) tags = lines[tags_start_index:tags_end_index+2] # print [tag.split(" ") for tag in tags] @@ -415,7 +416,7 @@ def parseAllOtherTests(self): jobs = [] #can split it into jobs ! just have to reparse it for the exit codes later.... - for line_index in xrange(0, len(lines)): + for line_index in range(0, len(lines)): line = lines[line_index] if reSubmit.match(line): end_index = self.findLineAfter(line_index, lines, test_condition=lambda l: reWaiting.match(l), return_index = True) @@ -469,7 +470,7 @@ def parseAllOtherTests(self): test[testName] = [] test[testName].append(info) - for line_index in xrange(0, len(lines)): + for line_index in range(0, len(lines)): line = lines[line_index] if reEnd.match(line): @@ -523,7 +524,7 @@ def parseTimeSize(self): jobs = [] start = False timesize_start_indicator = re.compile(r"""^taskset -c (\d+) cmsRelvalreportInput.py""") - for line_index in xrange(0, len(lines)): + for line_index in range(0, len(lines)): line = lines[line_index] # search for start of each TimeSize job (with a certain candle and step) if timesize_start_indicator.match(line): diff --git a/Validation/Performance/scripts/cmsBenchmark.py b/Validation/Performance/scripts/cmsBenchmark.py index 795c523e43cc2..43117ec67196e 100755 --- a/Validation/Performance/scripts/cmsBenchmark.py +++ b/Validation/Performance/scripts/cmsBenchmark.py @@ -56,6 +56,7 @@ """ from __future__ import print_function +from builtins import range import os #Get some environment variables to use cmssw_base=os.environ["CMSSW_BASE"] diff --git a/Validation/Performance/scripts/cmsPerfClient.py b/Validation/Performance/scripts/cmsPerfClient.py index ced7f858f7576..77b8b9a3f02a1 100755 --- a/Validation/Performance/scripts/cmsPerfClient.py +++ b/Validation/Performance/scripts/cmsPerfClient.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import socket, xml, xmlrpclib, os, sys, threading, Queue, time, random, pickle, exceptions import optparse as opt from functools import reduce diff --git a/Validation/Performance/scripts/cmsPerfCommons.py b/Validation/Performance/scripts/cmsPerfCommons.py index 29c60b8ba2ac4..2f4fe678c1b2e 100644 --- a/Validation/Performance/scripts/cmsPerfCommons.py +++ b/Validation/Performance/scripts/cmsPerfCommons.py @@ -1,3 +1,4 @@ +from builtins import range import os, re #Sort the candles to make sure MinBias is executed before QCD_80_120, otherwise DIGI PILEUP would not find its MinBias root files diff --git a/Validation/Performance/scripts/cmsPerfPublish.py b/Validation/Performance/scripts/cmsPerfPublish.py index ab04872a4b9e4..8fc99568b04d2 100755 --- a/Validation/Performance/scripts/cmsPerfPublish.py +++ b/Validation/Performance/scripts/cmsPerfPublish.py @@ -12,6 +12,7 @@ # before python v2.6, when we upgrade to python 2.6 we should use this # functionality. from __future__ import print_function +from builtins import range import tempfile as tmp import optparse as opt import cmsPerfRegress as cpr diff --git a/Validation/Performance/scripts/cmsPerfRegress.py b/Validation/Performance/scripts/cmsPerfRegress.py index 7cc4656ba61bf..babae61d56426 100755 --- a/Validation/Performance/scripts/cmsPerfRegress.py +++ b/Validation/Performance/scripts/cmsPerfRegress.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import time, os, sys, math, re, gzip import tempfile as tmp import optparse as opt diff --git a/Validation/Performance/scripts/cmsPerfServer.py b/Validation/Performance/scripts/cmsPerfServer.py index e8d5d184d7416..2c3dda3ed5580 100755 --- a/Validation/Performance/scripts/cmsPerfServer.py +++ b/Validation/Performance/scripts/cmsPerfServer.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import cmsPerfPublish as cspp import cmsPerfSuite as cps import cmsPerfHarvest as cph diff --git a/Validation/Performance/scripts/cmsPerfStripChart.py b/Validation/Performance/scripts/cmsPerfStripChart.py index fa5f58d7e78f0..2f43740ca8c75 100755 --- a/Validation/Performance/scripts/cmsPerfStripChart.py +++ b/Validation/Performance/scripts/cmsPerfStripChart.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os, sys try: import simplejson as json except ImportError: import json diff --git a/Validation/Performance/scripts/cmsPerfSuite.py b/Validation/Performance/scripts/cmsPerfSuite.py index 4f89053a26366..c8437c02941d4 100755 --- a/Validation/Performance/scripts/cmsPerfSuite.py +++ b/Validation/Performance/scripts/cmsPerfSuite.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from builtins import range import os, time, sys, re, glob, exceptions import optparse as opt import cmsRelRegress as crr @@ -1180,7 +1181,7 @@ def runPerfSuite(self, # specifying the same number of cores and cpus (like: --cores 3, --cpu 3,4,5) AvailableCores=cpus else: - AvailableCores=range(cores) + AvailableCores=list(range(cores)) #Initialize a list that will contain all the simpleGenReport keyword arguments (1 dictionary per test): TestsToDo=[] diff --git a/Validation/Performance/scripts/cmsRelvalreportInput.py b/Validation/Performance/scripts/cmsRelvalreportInput.py index 23b3d426031d1..3fa0c4a42534d 100755 --- a/Validation/Performance/scripts/cmsRelvalreportInput.py +++ b/Validation/Performance/scripts/cmsRelvalreportInput.py @@ -22,6 +22,7 @@ # from __future__ import print_function +from builtins import range import sys, os, re, operator import optparse as opt from cmsPerfCommons import Candles, CandDesc, FileName, KeywordToCfi, CustomiseFragment, CandFname, EventContents diff --git a/Validation/Performance/scripts/cmsTiming_parser.py b/Validation/Performance/scripts/cmsTiming_parser.py index 50385be6e00d3..0f5ceacf2c3fc 100755 --- a/Validation/Performance/scripts/cmsTiming_parser.py +++ b/Validation/Performance/scripts/cmsTiming_parser.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import sys, os import time import optparse diff --git a/Validation/RecoTau/Tools/MultipleCompare.py b/Validation/RecoTau/Tools/MultipleCompare.py index 257daea4a2c8f..25912db77d95e 100644 --- a/Validation/RecoTau/Tools/MultipleCompare.py +++ b/Validation/RecoTau/Tools/MultipleCompare.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import FWCore.ParameterSet.Config as cms import sys import os diff --git a/Validation/RecoTau/Tools/web_templates.py b/Validation/RecoTau/Tools/web_templates.py index 78df2cb88cdbc..425fa8f0cc8c2 100644 --- a/Validation/RecoTau/Tools/web_templates.py +++ b/Validation/RecoTau/Tools/web_templates.py @@ -1,3 +1,4 @@ +from builtins import range main_page_template = ''' diff --git a/Validation/RecoTau/python/compare.py b/Validation/RecoTau/python/compare.py index 10d5cca1d0718..9de88d634a16b 100644 --- a/Validation/RecoTau/python/compare.py +++ b/Validation/RecoTau/python/compare.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range from .officialStyle import officialStyle from array import array from ROOT import gROOT, gStyle, TH1F, TH1D, TF1, TFile, TCanvas, TH2F, TLegend, TGraphAsymmErrors, Double, TLatex diff --git a/Validation/RecoTau/python/runTauDisplay.py b/Validation/RecoTau/python/runTauDisplay.py index 21b6979522d9c..cd81c28924bb7 100644 --- a/Validation/RecoTau/python/runTauDisplay.py +++ b/Validation/RecoTau/python/runTauDisplay.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import ROOT, os, math, sys import numpy as num from DataFormats.FWLite import Events, Handle diff --git a/Validation/RecoTau/test/LXBatchValidation.py b/Validation/RecoTau/test/LXBatchValidation.py index 6bbe9ee486da5..fc66f7b6864ee 100755 --- a/Validation/RecoTau/test/LXBatchValidation.py +++ b/Validation/RecoTau/test/LXBatchValidation.py @@ -3,6 +3,7 @@ # Script to submit Tau Validation jobs to lxbatch # Author: Evan Friis evan.klose.friis@cern.ch from __future__ import print_function +from builtins import range import time import random from Validation.RecoTau.ValidationOptions_cff import * @@ -73,7 +74,7 @@ if options.writeEDMFile != "": cleanupCommand += " rfcp *.root %s;" % options.copyToCastorDir -for iJob in xrange(0, options.nJobs): +for iJob in range(0, options.nJobs): options.batchNumber = iJob #increment batch number #setupCommands = "cd $PWD; scramv1 runtime -sh > tempEnvs_%s_%i; source tempEnvs_%s_%i; rm tempEnvs_%s_%i; export PYTHONPATH=$PWD:$PYTHONPATH; cd -;" % (options.eventType, iJob, options.eventType, iJob, options.eventType, iJob) #cmsRunCommand = "cmsRun $PWD/RunValidation_cfg.py %s;" % returnOptionsString() diff --git a/Validation/RecoTrack/python/plotting/ntupleDataFormat.py b/Validation/RecoTrack/python/plotting/ntupleDataFormat.py index 5975761126a69..f3918c513ef5e 100644 --- a/Validation/RecoTrack/python/plotting/ntupleDataFormat.py +++ b/Validation/RecoTrack/python/plotting/ntupleDataFormat.py @@ -1,3 +1,4 @@ +from builtins import range import math import collections @@ -40,7 +41,7 @@ def __getitem__(self, index): def __iter__(self): """Returns generator for the objects.""" - for index in xrange(self.size()): + for index in range(self.size()): yield self._objclass(self._tree, index) class _Object(object): @@ -291,7 +292,7 @@ def matchedSimHitInfos(self): The generator returns SimHitMatchInfo objects. """ self._checkIsValid() - for imatch in xrange(self._nMatchedSimHits()): + for imatch in range(self._nMatchedSimHits()): yield SimHitMatchInfo(self._tree, self._index, imatch, self._prefix) class _TrackingParticleMatchAdaptor(object): @@ -315,7 +316,7 @@ def matchedTrackingParticleInfos(self): """ self._checkIsValid() - for imatch in xrange(self._nMatchedTrackingParticles()): + for imatch in range(self._nMatchedTrackingParticles()): yield TrackingParticleMatchInfo(self._tree, self._index, imatch, self._prefix) def bestMatchingTrackingParticle(self): @@ -423,7 +424,7 @@ def __iter__(self): Generator returns Event objects. """ - for jentry in xrange(self._entries): + for jentry in range(self._entries): # get the next tree in the chain and verify ientry = self._tree.LoadTree( jentry ) if ientry < 0: break @@ -937,7 +938,7 @@ def seedsForAlgo(self, algo): Generator returns Seed object. """ (offset, next_offset) = _seedOffsetForAlgo(self._tree, algo) - for isee in xrange(offset, next_offset): + for isee in range(offset, next_offset): yield Seed(self._tree, isee) def seedForAlgo(self, algo, iseed): @@ -994,7 +995,7 @@ def matchedTrackInfos(self): The generator returns TrackMatchInfo objects. """ self._checkIsValid() - for imatch in xrange(self._nMatchedTracks()): + for imatch in range(self._nMatchedTracks()): yield TrackMatchInfo(self._tree, self._index, imatch, self._prefix) def bestMatchingTrack(self): @@ -1041,7 +1042,7 @@ def matchedSeedInfos(self): The generator returns SeedMatchInfo objects. """ self._checkIsValid() - for imatch in xrange(self._nMatchedSeeds()): + for imatch in range(self._nMatchedSeeds()): yield SeedMatchInfo(self._tree, self._index, imatch, self._prefix) def nSimHits(self): diff --git a/Validation/RecoTrack/python/plotting/ntuplePrintersDiff.py b/Validation/RecoTrack/python/plotting/ntuplePrintersDiff.py index 4b35406577ed6..fa45abfb08945 100644 --- a/Validation/RecoTrack/python/plotting/ntuplePrintersDiff.py +++ b/Validation/RecoTrack/python/plotting/ntuplePrintersDiff.py @@ -1,3 +1,4 @@ +from builtins import range import re import sys import math @@ -913,7 +914,7 @@ def printHeader(self, track): oriAlgo = track.originalAlgo() algos = [] algoMask = track.algoMask() - for i in xrange(Algo.algoSize): + for i in range(Algo.algoSize): if algoMask & 1: algos.append(Algo.toString(i)) algoMask = algoMask >> 1 diff --git a/Validation/RecoTrack/python/plotting/plotting.py b/Validation/RecoTrack/python/plotting/plotting.py index 9277e5f98cf42..5d96053c038bb 100644 --- a/Validation/RecoTrack/python/plotting/plotting.py +++ b/Validation/RecoTrack/python/plotting/plotting.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import os import sys import math @@ -99,7 +100,7 @@ def _getDirectory(*args, **kwargs): def _th1ToOrderedDict(th1, renameBin=None): values = collections.OrderedDict() - for i in xrange(1, th1.GetNbinsX()+1): + for i in range(1, th1.GetNbinsX()+1): binLabel = th1.GetXaxis().GetBinLabel(i) if renameBin is not None: binLabel = renameBin(binLabel) @@ -198,7 +199,7 @@ def __init__(self, th1, uncertainty): xaxis = th1.GetXaxis() xaxis_arr = xaxis.GetXbins() if xaxis_arr.GetSize() > 0: # unequal binning - lst = [xaxis_arr[i] for i in xrange(0, xaxis_arr.GetSize())] + lst = [xaxis_arr[i] for i in range(0, xaxis_arr.GetSize())] arr = array.array("d", lst) self._ratio = ROOT.TH1F("foo", "foo", xaxis.GetNbins(), arr) else: @@ -320,11 +321,11 @@ def wrap(o): ref = wrappers[0] wrappers_bins = [] - ref_bins = [ref.xvalues(b) for b in xrange(ref.begin(), ref.end())] + ref_bins = [ref.xvalues(b) for b in range(ref.begin(), ref.end())] for w in wrappers: wrappers_bins.append(findBins(w, ref_bins)) - for i, bin in enumerate(xrange(ref.begin(), ref.end())): + for i, bin in enumerate(range(ref.begin(), ref.end())): (scale, ylow, yhigh) = ref.yvalues(bin) for w, bins in zip(wrappers, wrappers_bins): if bins[i] is None: @@ -341,7 +342,7 @@ def _getXmin(obj, limitToNonZeroContent=False): if isinstance(obj, ROOT.TH1): xaxis = obj.GetXaxis() if limitToNonZeroContent: - for i in xrange(1, obj.GetNbinsX()+1): + for i in range(1, obj.GetNbinsX()+1): if obj.GetBinContent(i) != 0: return xaxis.GetBinLowEdge(i) # None for all bins being zero @@ -349,7 +350,7 @@ def _getXmin(obj, limitToNonZeroContent=False): else: return xaxis.GetBinLowEdge(xaxis.GetFirst()) elif isinstance(obj, ROOT.TGraph) or isinstance(obj, ROOT.TGraph2D): - m = min([obj.GetX()[i] for i in xrange(0, obj.GetN())]) + m = min([obj.GetX()[i] for i in range(0, obj.GetN())]) return m*0.9 if m > 0 else m*1.1 raise Exception("Unsupported type %s" % str(obj)) @@ -357,7 +358,7 @@ def _getXmax(obj, limitToNonZeroContent=False): if isinstance(obj, ROOT.TH1): xaxis = obj.GetXaxis() if limitToNonZeroContent: - for i in xrange(obj.GetNbinsX(), 0, -1): + for i in range(obj.GetNbinsX(), 0, -1): if obj.GetBinContent(i) != 0: return xaxis.GetBinUpEdge(i) # None for all bins being zero @@ -365,7 +366,7 @@ def _getXmax(obj, limitToNonZeroContent=False): else: return xaxis.GetBinUpEdge(xaxis.GetLast()) elif isinstance(obj, ROOT.TGraph) or isinstance(obj, ROOT.TGraph2D): - m = max([obj.GetX()[i] for i in xrange(0, obj.GetN())]) + m = max([obj.GetX()[i] for i in range(0, obj.GetN())]) return m*1.1 if m > 0 else m*0.9 raise Exception("Unsupported type %s" % str(obj)) @@ -375,12 +376,12 @@ def _getYmin(obj, limitToNonZeroContent=False): return yaxis.GetBinLowEdge(yaxis.GetFirst()) elif isinstance(obj, ROOT.TH1): if limitToNonZeroContent: - lst = [obj.GetBinContent(i) for i in xrange(1, obj.GetNbinsX()+1) if obj.GetBinContent(i) != 0 ] + lst = [obj.GetBinContent(i) for i in range(1, obj.GetNbinsX()+1) if obj.GetBinContent(i) != 0 ] return min(lst) if len(lst) != 0 else 0 else: return obj.GetMinimum() elif isinstance(obj, ROOT.TGraph) or isinstance(obj, ROOT.TGraph2D): - m = min([obj.GetY()[i] for i in xrange(0, obj.GetN())]) + m = min([obj.GetY()[i] for i in range(0, obj.GetN())]) return m*0.9 if m > 0 else m*1.1 raise Exception("Unsupported type %s" % str(obj)) @@ -390,20 +391,20 @@ def _getYmax(obj, limitToNonZeroContent=False): return yaxis.GetBinUpEdge(yaxis.GetLast()) elif isinstance(obj, ROOT.TH1): if limitToNonZeroContent: - lst = [obj.GetBinContent(i) for i in xrange(1, obj.GetNbinsX()+1) if obj.GetBinContent(i) != 0 ] + lst = [obj.GetBinContent(i) for i in range(1, obj.GetNbinsX()+1) if obj.GetBinContent(i) != 0 ] return max(lst) if len(lst) != 0 else 0 else: return obj.GetMaximum() elif isinstance(obj, ROOT.TGraph) or isinstance(obj, ROOT.TGraph2D): - m = max([obj.GetY()[i] for i in xrange(0, obj.GetN())]) + m = max([obj.GetY()[i] for i in range(0, obj.GetN())]) return m*1.1 if m > 0 else m*0.9 raise Exception("Unsupported type %s" % str(obj)) def _getYmaxWithError(th1): - return max([th1.GetBinContent(i)+th1.GetBinError(i) for i in xrange(1, th1.GetNbinsX()+1)]) + return max([th1.GetBinContent(i)+th1.GetBinError(i) for i in range(1, th1.GetNbinsX()+1)]) def _getYminIgnoreOutlier(th1): - yvals = sorted([n for n in [th1.GetBinContent(i) for i in xrange(1, th1.GetNbinsX()+1)] if n>0]) + yvals = sorted([n for n in [th1.GetBinContent(i) for i in range(1, th1.GetNbinsX()+1)] if n>0]) if len(yvals) == 0: return th1.GetMinimum() if len(yvals) == 1: @@ -412,7 +413,7 @@ def _getYminIgnoreOutlier(th1): # Define outlier as being x10 less than minimum of the 95 % of the non-zero largest values ind_min = len(yvals)-1 - int(len(yvals)*0.95) min_val = yvals[ind_min] - for i in xrange(0, ind_min): + for i in range(0, ind_min): if yvals[i] > 0.1*min_val: return yvals[i] @@ -426,10 +427,10 @@ def _getYminMaxAroundMedian(obj, coverage, coverageRange=None): inRange2 = lambda xmin,xmax: coverageRange[0] <= xmin and xmax <= coverageRange[1] if isinstance(obj, ROOT.TH1): - yvals = [obj.GetBinContent(i) for i in xrange(1, obj.GetNbinsX()+1) if inRange2(obj.GetXaxis().GetBinLowEdge(i), obj.GetXaxis().GetBinUpEdge(i))] + yvals = [obj.GetBinContent(i) for i in range(1, obj.GetNbinsX()+1) if inRange2(obj.GetXaxis().GetBinLowEdge(i), obj.GetXaxis().GetBinUpEdge(i))] yvals = [x for x in yvals if x != 0] elif isinstance(obj, ROOT.TGraph) or isinstance(obj, ROOT.TGraph2D): - yvals = [obj.GetY()[i] for i in xrange(0, obj.GetN()) if inRange(obj.GetX()[i])] + yvals = [obj.GetY()[i] for i in range(0, obj.GetN()) if inRange(obj.GetX()[i])] else: raise Exception("Unsupported type %s" % str(obj)) if len(yvals) == 0: @@ -604,7 +605,7 @@ def _findBoundsY(th1s, ylog, ymin=None, ymax=None, coverage=None, coverageRange= def _th1RemoveEmptyBins(histos, xbinlabels): binsToRemove = set() - for b in xrange(1, histos[0].GetNbinsX()+1): + for b in range(1, histos[0].GetNbinsX()+1): binEmpty = True for h in histos: if h.GetBinContent(b) > 0: @@ -616,7 +617,7 @@ def _th1RemoveEmptyBins(histos, xbinlabels): if len(binsToRemove) > 0: # filter xbinlabels xbinlab_new = [] - for i in xrange(len(xbinlabels)): + for i in range(len(xbinlabels)): if (i+1) not in binsToRemove: xbinlab_new.append(xbinlabels[i]) xbinlabels = xbinlab_new @@ -625,7 +626,7 @@ def _th1RemoveEmptyBins(histos, xbinlabels): histos_new = [] for h in histos: values = [] - for b in xrange(1, h.GetNbinsX()+1): + for b in range(1, h.GetNbinsX()+1): if b not in binsToRemove: values.append( (h.GetXaxis().GetBinLabel(b), h.GetBinContent(b), h.GetBinError(b)) ) @@ -646,9 +647,9 @@ def _th2RemoveEmptyBins(histos, xbinlabels, ybinlabels): xbinsToRemove = set() ybinsToRemove = set() for ih, h in enumerate(histos): - for bx in xrange(1, h.GetNbinsX()+1): + for bx in range(1, h.GetNbinsX()+1): binEmpty = True - for by in xrange(1, h.GetNbinsY()+1): + for by in range(1, h.GetNbinsY()+1): if h.GetBinContent(bx, by) > 0: binEmpty = False break @@ -657,9 +658,9 @@ def _th2RemoveEmptyBins(histos, xbinlabels, ybinlabels): elif ih > 0: xbinsToRemove.discard(bx) - for by in xrange(1, h.GetNbinsY()+1): + for by in range(1, h.GetNbinsY()+1): binEmpty = True - for bx in xrange(1, h.GetNbinsX()+1): + for bx in range(1, h.GetNbinsX()+1): if h.GetBinContent(bx, by) > 0: binEmpty = False break @@ -671,14 +672,14 @@ def _th2RemoveEmptyBins(histos, xbinlabels, ybinlabels): if len(xbinsToRemove) > 0 or len(ybinsToRemove) > 0: xbinlabels_new = [] xbins = [] - for b in xrange(1, len(xbinlabels)+1): + for b in range(1, len(xbinlabels)+1): if b not in xbinsToRemove: xbinlabels_new.append(histos[0].GetXaxis().GetBinLabel(b)) xbins.append(b) xbinlabels = xbinlabels_new ybinlabels_new = [] ybins = [] - for b in xrange(1, len(ybinlabels)+1): + for b in range(1, len(ybinlabels)+1): if b not in ybinsToRemove: ybinlabels.append(histos[0].GetYaxis().GetBinLabel(b)) ybins.append(b) @@ -703,10 +704,10 @@ def _th2RemoveEmptyBins(histos, xbinlabels, ybinlabels): return (histos, xbinlabels, ybinlabels) def _mergeBinLabelsX(histos): - return _mergeBinLabels([[h.GetXaxis().GetBinLabel(i) for i in xrange(1, h.GetNbinsX()+1)] for h in histos]) + return _mergeBinLabels([[h.GetXaxis().GetBinLabel(i) for i in range(1, h.GetNbinsX()+1)] for h in histos]) def _mergeBinLabelsY(histos): - return _mergeBinLabels([[h.GetYaxis().GetBinLabel(i) for i in xrange(1, h.GetNbinsY()+1)] for h in histos]) + return _mergeBinLabels([[h.GetYaxis().GetBinLabel(i) for i in range(1, h.GetNbinsY()+1)] for h in histos]) def _mergeBinLabels(labelsAll): labels_merged = labelsAll[0] @@ -797,7 +798,7 @@ def create(self, tdirectory): # effects downstream ret.SetCanExtend(False) - for i in xrange(0, histoA.GetNbinsX()+2): # include under- and overflow too + for i in range(0, histoA.GetNbinsX()+2): # include under- and overflow too val = histoA.GetBinContent(i)-histoB.GetBinContent(i) ret.SetBinContent(i, val) ret.SetBinError(i, math.sqrt(val)) @@ -837,7 +838,7 @@ def create(self, tdirectory): # effects downstream ret.SetCanExtend(False) - for i in xrange(0, histo.GetNbinsX()+2): + for i in range(0, histo.GetNbinsX()+2): ret.SetBinContent(i, self._func(histo.GetBinContent(i))) return ret @@ -881,7 +882,7 @@ def create(self, tdirectory): hfakedup = hreco.Clone(self._name) hfakedup.SetTitle(self._title) - for i in xrange(1, hassoc.GetNbinsX()+1): + for i in range(1, hassoc.GetNbinsX()+1): numerVal = hassoc.GetBinContent(i) - hdup.GetBinContent(i) denomVal = hreco.GetBinContent(i) @@ -935,7 +936,7 @@ def create(self, tdirectory): ret.SetTitle(self._title) # calculate efficiency - for i in xrange(1, histo.GetNbinsX()+1): + for i in range(1, histo.GetNbinsX()+1): n = histo.GetBinContent(i) val = n/n_tot errVal = math.sqrt(val*(1-val)/n_tot) @@ -1026,7 +1027,7 @@ def create(self, tdirectory): binIndexOrder.sort(key=lambda t: t[0]) tmpVal = [] tmpLab = [] - for i in xrange(0, len(binValues)): + for i in range(0, len(binValues)): fromIndex = binIndexOrder[i][1] tmpVal.append(binValues[fromIndex]) tmpLab.append(binLabels[fromIndex]) @@ -1153,7 +1154,7 @@ def create(self, tdirectory): yerrdown = [] z = [] - for i in xrange(1, xhisto.GetNbinsX()+1): + for i in range(1, xhisto.GetNbinsX()+1): x.append(xhisto.GetBinContent(i)) xerrup.append(xhisto.GetBinError(i)) xerrdown.append(xhisto.GetBinError(i)) @@ -1216,7 +1217,7 @@ def _drawFrame(pad, bounds, zmax=None, xbinlabels=None, xbinlabelsize=None, xbin frame.Draw("") xaxis = frame.GetXaxis() - for i in xrange(nbins): + for i in range(nbins): xaxis.SetBinLabel(i+1, xbinlabels[i]) if xbinlabelsize is not None: xaxis.SetLabelSize(xbinlabelsize) @@ -1890,7 +1891,7 @@ def create(self, tdirNEvents, requireAllHistograms=False): if self._fallback is not None: profileX = [self._profileX]*len(self._histograms) - for i in xrange(0, len(self._histograms)): + for i in range(0, len(self._histograms)): if self._histograms[i] is None: self._histograms[i] = self._createOne(self._fallback["name"], i, tdirNEvents[i][0], tdirNEvents[i][1]) profileX[i] = self._fallback.get("profileX", self._profileX) @@ -2074,7 +2075,7 @@ def _styleHist(h, msty, col): print(self._name) width = max([len(l) for l in xbinlabels]) tmp = "%%-%ds " % width - for b in xrange(1, histos[0].GetNbinsX()+1): + for b in range(1, histos[0].GetNbinsX()+1): s = tmp % xbinlabels[b-1] for h in histos: s += "%.3f " % h.GetBinContent(b) @@ -2947,7 +2948,7 @@ def create(self, openFiles, legendLabels, dqmSubFolder): return None # Replace all None columns with lists of column length - for i in xrange(len(tbl)): + for i in range(len(tbl)): if tbl[i] is None: tbl[i] = [None]*colLen diff --git a/Validation/RecoTrack/python/plotting/trackingPlots.py b/Validation/RecoTrack/python/plotting/trackingPlots.py index b9fd5c6837009..af9e8331e9bad 100644 --- a/Validation/RecoTrack/python/plotting/trackingPlots.py +++ b/Validation/RecoTrack/python/plotting/trackingPlots.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range import os import copy import collections @@ -1076,7 +1077,7 @@ def draw(self, legendLabels, prefix=None, directory="", *args, **kwargs): legendLabels = legendLabels[:] if max(map(len, legendLabels)) > 20: haveShortLabels = True - labels_short = [str(chr(ord('A')+i)) for i in xrange(len(legendLabels))] + labels_short = [str(chr(ord('A')+i)) for i in range(len(legendLabels))] for i, ls in enumerate(labels_short): legendLabels[i] = "%s: %s" % (ls, legendLabels[i]) else: @@ -1130,7 +1131,7 @@ def draw(self, legendLabels, prefix=None, directory="", *args, **kwargs): if len(histos_linear) == 0: return [] - data = [ [h.GetBinContent(i) for i in xrange(1, h.GetNbinsX()+1)] for h in histos_linear] + data = [ [h.GetBinContent(i) for i in range(1, h.GetNbinsX()+1)] for h in histos_linear] table = html.Table(["dummy"]*len(histos_linear), xbinlabels, data, None, None, None) data = table.tableAsRowColumn() @@ -1637,7 +1638,7 @@ def _create(self, tdirectory): ret = timeTh1.Clone(self._name) xaxis = ret.GetXaxis() - for i in xrange(1, ret.GetNbinsX()+1): + for i in range(1, ret.GetNbinsX()+1): ret.SetBinContent(i, ret.GetBinContent(i)/nevents) ret.SetBinError(i, ret.GetBinError(i)/nevents) xaxis.SetBinLabel(i, xaxis.GetBinLabel(i).replace(" (unscheduled)", "")) @@ -1689,12 +1690,12 @@ def create(self, tdirectory): if h_reco_per_iter is None: return None values = {} - for i in xrange(1, h_reco_per_iter.GetNbinsX()+1): + for i in range(1, h_reco_per_iter.GetNbinsX()+1): values[h_reco_per_iter.GetXaxis().GetBinLabel(i)] = h_reco_per_iter.GetBinContent(i) result = [] - for i in xrange(1, timeTh1.GetNbinsX()+1): + for i in range(1, timeTh1.GetNbinsX()+1): iterName = timeTh1.GetXaxis().GetBinLabel(i) if iterName in values: ntrk = values[iterName] @@ -1726,10 +1727,10 @@ def _edit(s): # remove "Tracks" from the track producer name to get the iteration name # muonSeeded iterations do not have "Step" in the producer name, so add it here return s.replace("Tracks", "").replace("muonSeeded", "muonSeededStep") - return [_edit(xaxis.GetBinLabel(i)) for i in xrange(1, h.GetNbinsX()+1)] + return [_edit(xaxis.GetBinLabel(i)) for i in range(1, h.GetNbinsX()+1)] def __call__(self, tdirectory, labels): - ret = range(0, len(labels)) + ret = list(range(0, len(labels))) f = tdirectory.GetFile() if not f: return ret diff --git a/Validation/RecoTrack/test/analyseMVA.py b/Validation/RecoTrack/test/analyseMVA.py index 92a9bdef663d6..a5ae0fc0bbd2c 100755 --- a/Validation/RecoTrack/test/analyseMVA.py +++ b/Validation/RecoTrack/test/analyseMVA.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from builtins import range import array import collections import itertools @@ -112,7 +113,7 @@ def addTH(name, *args, **kwargs): new_bins = array.array("d", [0]*(bins+1)) new_bins[0] = 10**minLog10 mult = 10**width - for i in xrange(1, bins+1): + for i in range(1, bins+1): new_bins[i] = new_bins[i-1]*mult axis.Set(bins, new_bins) h[name] = _h diff --git a/Validation/RecoTrack/test/fakeAnalysis/analysis.py b/Validation/RecoTrack/test/fakeAnalysis/analysis.py index 5b34b32c00490..53dc79c6e7618 100644 --- a/Validation/RecoTrack/test/fakeAnalysis/analysis.py +++ b/Validation/RecoTrack/test/fakeAnalysis/analysis.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import ROOT from array import array from collections import OrderedDict diff --git a/Validation/RecoTrack/test/fakeAnalysis/graphics.py b/Validation/RecoTrack/test/fakeAnalysis/graphics.py index 9a23281b04883..636935d6db542 100644 --- a/Validation/RecoTrack/test/fakeAnalysis/graphics.py +++ b/Validation/RecoTrack/test/fakeAnalysis/graphics.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import ROOT from array import array from copy import copy diff --git a/Validation/RecoTrack/test/fakeAnalysis/graphics_vertical.py b/Validation/RecoTrack/test/fakeAnalysis/graphics_vertical.py index 09bd743d0a844..918cfa90e78ed 100644 --- a/Validation/RecoTrack/test/fakeAnalysis/graphics_vertical.py +++ b/Validation/RecoTrack/test/fakeAnalysis/graphics_vertical.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import ROOT from array import array diff --git a/Validation/RecoTrack/test/publicPlots/plot.py b/Validation/RecoTrack/test/publicPlots/plot.py index 1df0b7e55cf3c..f3c62242122d3 100755 --- a/Validation/RecoTrack/test/publicPlots/plot.py +++ b/Validation/RecoTrack/test/publicPlots/plot.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import copy import math import array @@ -978,7 +979,7 @@ def plotResol(files, prefix, pileup, hasPU70=False): x = [] y = [] axis = h.GetXaxis() - for i in xrange(1, h.GetNbinsX()+1): + for i in range(1, h.GetNbinsX()+1): x.append(axis.GetBinCenter(i)**2) y.append(h.GetBinContent(i)) diff --git a/Validation/RecoVertex/python/plotting/vertexPlots.py b/Validation/RecoVertex/python/plotting/vertexPlots.py index ea8138dd59d99..a7eb014ed3d68 100644 --- a/Validation/RecoVertex/python/plotting/vertexPlots.py +++ b/Validation/RecoVertex/python/plotting/vertexPlots.py @@ -1,3 +1,4 @@ +from builtins import range import copy from Validation.RecoTrack.plotting.plotting import Plot, PlotGroup, PlotFolder, Plotter @@ -16,8 +17,8 @@ _minMaxPt = [5e-1, 1, 5, 1e1, 5e1, 1e2, 5e2, 1e3, 5e3, 1e4] _minPull = [0, 0.5, 0.8, 0.9] _maxPull = [1.1, 1.2, 1.5, 2] -_minVertexZ = range(-60,-10,10) -_maxVertexZ = range(20,70,10) +_minVertexZ = list(range(-60,-10,10)) +_maxVertexZ = list(range(20,70,10)) _vertexNumberOfEventsHistogram = "DQMData/Run 1/Vertexing/Run summary/PrimaryVertexV/GenPV_Z" @@ -205,7 +206,7 @@ ## Extended set of plots _common = dict(drawStyle = "HIST", stat=True) -_commonXY = dict(xmin=[x*0.1 for x in xrange(-6, 6, 1)], xmax=[x*0.1 for x in xrange(-5, 7, 1)]) +_commonXY = dict(xmin=[x*0.1 for x in range(-6, 6, 1)], xmax=[x*0.1 for x in range(-5, 7, 1)]) _commonZ = dict(xmin=[-60,-30], xmax=[30,60]) _commonXY.update(_common) _commonZ.update(_common) @@ -394,7 +395,7 @@ def _formatOrNone(num, func): h = tdirectory.Get("globalEfficiencies") if h: d = {} - for i in xrange(1, h.GetNbinsX()+1): + for i in range(1, h.GetNbinsX()+1): d[h.GetXaxis().GetBinLabel(i)] = h.GetBinContent(i) ret.extend([ _formatOrNone(d.get("effic_vs_Z", None), lambda n: "%.4f"%n), diff --git a/Validation/Tools/python/GenObject.py b/Validation/Tools/python/GenObject.py index 79ab9d0bd83e8..d064f7e120bce 100755 --- a/Validation/Tools/python/GenObject.py +++ b/Validation/Tools/python/GenObject.py @@ -4,6 +4,7 @@ ## the classes may not function as intended. +from builtins import range from FWCore.Utilities.Enumerate import Enumerate from DataFormats.FWLite import Events, Handle import re @@ -1030,7 +1031,7 @@ def prepareTuple (tupleName, files, numEventsWanted = 0): def getRunEventEntryDict (chain, tupleName, numEntries): """Returns a dictionary of run, event tuples to entryIndicies""" reeDict = {} - for entryIndex in xrange (numEntries): + for entryIndex in range (numEntries): event = GenObject.loadEventFromTree (chain, entryIndex, onlyRunEvent = True) @@ -1110,11 +1111,11 @@ def pairEquivalentObjects (vec1, vec2): if not len1 or not len2: # Nothing to see here folks. Keep moving. if len1: - noMatch1Set = set( xrange(len1) ) + noMatch1Set = set( range(len1) ) else: noMatch1Set = set () if len2: - noMatch2Set = set( xrange(len2) ) + noMatch2Set = set( range(len2) ) else: noMatch2Set = set () if debug: warn ("Nothing found", sapces=6) @@ -1127,8 +1128,8 @@ def pairEquivalentObjects (vec1, vec2): if GenObject._kitchenSinkDict.get ('strictPairing') or \ equivList == [('index', 0)]: # we're only matching on index, nothing else matters - matchedSet = set (zip ( range( min (len1, len2) ), - range( min (len1, len2) ) ) ) + matchedSet = set (zip ( list(range( min (len1, len2))), + list(range( min (len1, len2))) ) ) if len1 > len2: # since main pairing goes from 0..len2-1, we now want # to go from len2..len1 inclusive @@ -1155,10 +1156,10 @@ def pairEquivalentObjects (vec1, vec2): # First, look for vec2 objects that are equivalent to a # given vec1 object. - for index1 in xrange (len1): + for index1 in range (len1): objList = [] obj1 = vec1[index1] - for index2 in xrange (len2): + for index2 in range (len2): total = 0. obj2 = vec2[index2] ok = True @@ -1182,10 +1183,10 @@ def pairEquivalentObjects (vec1, vec2): firstDict[index1] = objList # Now do the same thing, but this time look for vec1 objects # that are equivalent to a given vec2 object - for index2 in xrange (len2): + for index2 in range (len2): objList = [] obj2 = vec2[index2] - for index1 in xrange (len1): + for index1 in range (len1): total = 0. obj1 = vec1[index1] ok = True @@ -1463,7 +1464,7 @@ def saveTupleAs (chain, rootFile): print("saveTupleAs") rootfile, tree = GenObject.setupOutputTree (rootFile, "goTree") numEntries = GenObject._kitchenSinkDict[chain]['numEntries'] - for entryIndex in xrange (numEntries): + for entryIndex in range (numEntries): event = GenObject.loadEventFromTree (chain, entryIndex) if GenObject._kitchenSinkDict.get('blur'): where = "run %d event %d" % (event['runevent'].run, @@ -1496,7 +1497,7 @@ def printTuple (chain): numEntries = GenObject._kitchenSinkDict[chain]['numEntries'] debug = GenObject._kitchenSinkDict.get ('debug', False) if debug: warn (numEntries) - for entryIndex in xrange (numEntries): + for entryIndex in range (numEntries): if debug: warn (entryIndex, spaces=3) event = GenObject.loadEventFromTree (chain, entryIndex) GenObject.printEvent (event) diff --git a/Validation/Tools/scripts/diffTreeTool.py b/Validation/Tools/scripts/diffTreeTool.py index afac1538d9204..85fb5ddce4d7d 100755 --- a/Validation/Tools/scripts/diffTreeTool.py +++ b/Validation/Tools/scripts/diffTreeTool.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import optparse import os import re diff --git a/Validation/Tools/scripts/simpleEdmComparison.py b/Validation/Tools/scripts/simpleEdmComparison.py index d7243eb297fe2..c22d116d89837 100755 --- a/Validation/Tools/scripts/simpleEdmComparison.py +++ b/Validation/Tools/scripts/simpleEdmComparison.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import inspect import itertools import logging @@ -148,7 +149,7 @@ def compareEvents(event1, event2, handleName, label, options): chain2.toBegin() logging.info("Testing identity for handle=%s, label=%s" % (handleName, label)) # Use itertools to iterate over lists in || - for ev1, ev2, count in itertools.izip(chain1, chain2, xrange(numEvents)): + for ev1, ev2, count in itertools.izip(chain1, chain2, range(numEvents)): evCount, evMismatch = compareEvents(event1=ev1, event2=ev2, handleName=handleName, label=label, options=options) totalCount += evCount mismatches += evMismatch diff --git a/Validation/Tools/scripts/useReflexToDescribeForGenObject.py b/Validation/Tools/scripts/useReflexToDescribeForGenObject.py index ea9c313c14c62..8bbfa1994accc 100755 --- a/Validation/Tools/scripts/useReflexToDescribeForGenObject.py +++ b/Validation/Tools/scripts/useReflexToDescribeForGenObject.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import ROOT import re import pprint From 4ed08024b12806875d7a771159b9b77bcf50bdd1 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 9 Apr 2019 21:29:47 +0200 Subject: [PATCH 536/686] xrange mig --- .../scripts/tkal_create_file_lists.py | 7 +++--- .../python/alignmentsetup/helper.py | 3 ++- .../python/mpslib/Mpslibclass.py | 7 +++--- .../python/mpslib/tools.py | 3 ++- .../python/mpsvalidate/beamerCreator.py | 1 + .../python/mpsvalidate/bigModule.py | 1 + .../python/mpsvalidate/bigStructure.py | 1 + .../python/mpsvalidate/geometry.py | 3 ++- .../python/mpsvalidate/pdfCreator.py | 1 + .../python/mpsvalidate/subModule.py | 1 + .../python/mpsvalidate/timeStructure.py | 1 + .../scripts/mps_check.py | 3 ++- .../scripts/mps_fetch.py | 3 ++- .../scripts/mps_fire.py | 7 +++--- .../scripts/mps_merge.py | 5 ++-- .../scripts/mps_monitormerge.py | 13 ++++++----- .../scripts/mps_setup.py | 5 ++-- .../scripts/mps_splice.py | 3 ++- .../scripts/mps_update.py | 3 ++- .../python/MCScenario_CRAFT1_22X.py | 1 + .../python/MuonGeometrySanityCheck_cfi.py | 5 ++-- .../MuonAlignment/python/geometryDiff.py | 1 + .../python/makeMuonMisalignmentScenario.py | 1 + Alignment/MuonAlignment/python/svgfig.py | 11 +++++---- .../scripts/alignmentValidation.py | 1 + .../scripts/applyRadialCorrections.py | 1 + .../scripts/corrVsCorr.py | 1 + .../scripts/createBeamHaloJobs.py | 1 + .../scripts/createCSCRingsJobs.py | 1 + .../scripts/createJobs.py | 1 + .../scripts/createTree.py | 1 + .../scripts/findQualityFiles.py | 1 + .../scripts/groupFilesInBlocks.py | 1 + .../scripts/motionPolicyChamber.py | 1 + .../scripts/plotscripts.py | 23 ++++++++++--------- .../scripts/reportVsReport.py | 1 + .../python/TkAlAllInOneTool/dataset.py | 3 ++- .../TkAlAllInOneTool/genericValidation.py | 1 + .../TkAlAllInOneTool/helperFunctions.py | 1 + .../TkAlAllInOneTool/plottingOptions.py | 1 + .../python/TkAlAllInOneTool/presentation.py | 11 +++++---- .../OfflineValidation/test/submitAllJobs.py | 3 ++- 42 files changed, 93 insertions(+), 51 deletions(-) diff --git a/Alignment/CommonAlignment/scripts/tkal_create_file_lists.py b/Alignment/CommonAlignment/scripts/tkal_create_file_lists.py index 80e4ff6125050..1488273a45102 100755 --- a/Alignment/CommonAlignment/scripts/tkal_create_file_lists.py +++ b/Alignment/CommonAlignment/scripts/tkal_create_file_lists.py @@ -2,6 +2,7 @@ from __future__ import print_function +from builtins import range import os import re import sys @@ -581,7 +582,7 @@ def _create_json_file(self, name, first, last = None): name += "_JSON.txt" print_msg("Creating JSON file: "+name) - json_file = LumiList.LumiList(runs = xrange(first, last+1)) + json_file = LumiList.LumiList(runs = range(first, last+1)) if self._args.json: global_json = LumiList.LumiList(filename = self._args.json) json_file = json_file & global_json @@ -912,7 +913,7 @@ def das_client(query, check_key = None): """ error = True - for i in xrange(5): # maximum of 5 tries + for i in range(5): # maximum of 5 tries try: das_data = cmssw_das_client.get_data(query, limit = 0) except IOError as e: @@ -1127,7 +1128,7 @@ def get_chunks(long_list, chunk_size): - `chunk_size`: maximum size of created sub-lists """ - for i in xrange(0, len(long_list), chunk_size): + for i in range(0, len(long_list), chunk_size): yield long_list[i:i+chunk_size] diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/alignmentsetup/helper.py b/Alignment/MillePedeAlignmentAlgorithm/python/alignmentsetup/helper.py index b35e6e0bb6952..a9c8a39f9ea6a 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/alignmentsetup/helper.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/alignmentsetup/helper.py @@ -1,3 +1,4 @@ +from builtins import range import os import FWCore.ParameterSet.Config as cms @@ -34,7 +35,7 @@ def set_pede_option(process, option, drop = False): existing_options = process.AlignmentProducer.algoConfig.pedeSteerer.options exists = False - for i in xrange(len(existing_options)): + for i in range(len(existing_options)): if existing_options[i].split()[0] == option.split()[0]: existing_options[i] = option.strip() exists = True diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/Mpslibclass.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/Mpslibclass.py index 643bb4011c107..a2dc696879322 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/Mpslibclass.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/Mpslibclass.py @@ -38,6 +38,7 @@ # JOBSP3 - possible name as given to mps_setup.pl -N ... # JOBID - ID of the LSF/HTCondor job +from builtins import range import datetime import time import os @@ -146,7 +147,7 @@ def print_memdb(self): #print interesting Job-level lists ---- to add: t/evt, fix remarks print('### dir jobid stat try rtime nevt remark weight name') print("------------------------------------------------------------------------------") - for i in xrange(self.nJobs): + for i in range(self.nJobs): print('%03d %6s %9s %6s %3d %5d %8d %8s %5s %s' % ( self.JOBNUMBER[i], self.JOBDIR[i], @@ -161,7 +162,7 @@ def print_memdb(self): #print merge Jobs if merge mode if self.driver == 'merge': - for i in xrange(self.nJobs,len(self.JOBDIR)): + for i in range(self.nJobs,len(self.JOBDIR)): print('%s %6s %9s %6s %3d %5d %8d %8s %5s %s' % ( 'MMM', self.JOBDIR[i], @@ -217,7 +218,7 @@ def write_db(self): DBFILE.write("%s\n" % item) #write mps.db jobinfo - for i in xrange(len(self.JOBID)): + for i in range(len(self.JOBID)): DBFILE.write('%03d:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n' % (i+1, self.JOBDIR[i], diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/tools.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/tools.py index e284833336bb4..213d1c87ad14c 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/tools.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpslib/tools.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import os import re import sys @@ -248,7 +249,7 @@ def remove_existing_object(path): except OSError as e: if e.args != (13, "Permission denied"): raise backup_path = path.rstrip("/")+"~" - for _ in xrange(5): + for _ in range(5): try: if os.path.exists(backup_path): remove_method(backup_path) move_method(path, backup_path) diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/beamerCreator.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/beamerCreator.py index 446c508de6ef1..9d5c77637762c 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/beamerCreator.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/beamerCreator.py @@ -2,6 +2,7 @@ # Creates beamer out of the histograms, parsed data and a given template. ## +from builtins import range import logging import os import string diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigModule.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigModule.py index a78d78763f400..257723495afe0 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigModule.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigModule.py @@ -3,6 +3,7 @@ # a list of PlotData objects. ## +from builtins import range import logging import ROOT diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigStructure.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigStructure.py index f41c5f4237fc1..008cd529270d8 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigStructure.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/bigStructure.py @@ -3,6 +3,7 @@ # as humanreadable text. ## +from builtins import range import logging import ROOT diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/geometry.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/geometry.py index 8b1970b06decb..8203f568828be 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/geometry.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/geometry.py @@ -2,6 +2,7 @@ # Classes which provide the geometry information. ## +from builtins import range import itertools import os @@ -71,7 +72,7 @@ def create_children_list(self): # loop over discriminators -> create patterns # pattern {"half": 2, "side": 2, "layer": 6, ...} ranges = struct.ndiscriminator - pranges = [range(1, x+1) for x in ranges] + pranges = [list(range(1, x+1)) for x in ranges] # loop over all possible combinations of the values of the # discriminators for number in itertools.product(*pranges): diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/pdfCreator.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/pdfCreator.py index 7d66fea871786..66a598cb698a5 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/pdfCreator.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/pdfCreator.py @@ -2,6 +2,7 @@ # Creates pdf out of the histograms, parsed data and a given template. ## +from builtins import range import logging import os import string diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/subModule.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/subModule.py index 309a72076497f..d3d543f9eaa96 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/subModule.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/subModule.py @@ -4,6 +4,7 @@ # list with the PlotData of the histograms ## +from builtins import range import logging import ROOT diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/timeStructure.py b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/timeStructure.py index 2ba9d19732e24..4daa78effa627 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/timeStructure.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/mpsvalidate/timeStructure.py @@ -4,6 +4,7 @@ # get a time dependent plot. ## +from builtins import range import logging import ROOT diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_check.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_check.py index 7abdbfbdf2fcb..4143b0dad0dd0 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_check.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_check.py @@ -12,6 +12,7 @@ # It also retirieves number of events from alignment.log and cputime from STDOUT from __future__ import print_function +from builtins import range import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib import subprocess import re @@ -28,7 +29,7 @@ eoslsoutput = "" # loop over FETCH jobs -for i in xrange(len(lib.JOBID)): +for i in range(len(lib.JOBID)): # FIXME use bools? batchSuccess = 0 batchExited = 0 diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fetch.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fetch.py index 7cf7ea75fb2cb..0a5efd6d464f1 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fetch.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fetch.py @@ -8,6 +8,7 @@ # hence this function does hardly anything except for calling # mps_check.py. +from builtins import range import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib import os @@ -18,7 +19,7 @@ lib.read_db() # loop over DONE jobs -for i in xrange(len(lib.JOBID)): +for i in range(len(lib.JOBID)): # check also "FETCH" to recover from possibly failed runs of 'mps_fetch.py' if lib.JOBSTATUS[i] in ("DONE", "EXIT", "FETCH", "DISABLEDFETCH"): # move the LSF output to /jobData/ diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py index fdd44d5c6ee54..742580c42b028 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py @@ -13,6 +13,7 @@ # mps_fire.py -h from __future__ import print_function +from builtins import range import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib import Alignment.MillePedeAlignmentAlgorithm.mpslib.tools as mps_tools import os @@ -256,7 +257,7 @@ def write_HTCondor_submit_file_mille(path, script, lib, proxy_path=None): resources = '-q '+resources nSub = 0 # number of submitted Jobs - for i in xrange(lib.nJobs): + for i in range(lib.nJobs): if lib.JOBDIR[i] not in job_mask: continue if lib.JOBSTATUS[i] == 'SETUP': if nSub < args.maxJobs: @@ -319,7 +320,7 @@ def write_HTCondor_submit_file_mille(path, script, lib, proxy_path=None): # check whether all other jobs are OK mergeOK = True - for i in xrange(lib.nJobs): + for i in range(lib.nJobs): if lib.JOBSTATUS[i] != 'OK': if 'DISABLED' not in lib.JOBSTATUS[i]: mergeOK = False @@ -420,7 +421,7 @@ def write_HTCondor_submit_file_mille(path, script, lib, proxy_path=None): job_submit_file] else: submission = ["bsub", "-J", curJobName, resources, scriptPath] - for _ in xrange(5): + for _ in range(5): try: result = subprocess.check_output(submission, stderr=subprocess.STDOUT) break diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_merge.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_merge.py index 7088dd4ca9d0c..70ea97467991b 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_merge.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_merge.py @@ -7,6 +7,7 @@ # mps_merge.pl [-c] inCfg mergeCfg mergeDir njobs from __future__ import print_function +from builtins import range import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib import re import os @@ -74,7 +75,7 @@ # build list of binary files binaryList = '' firstentry = True -for i in xrange(nJobs): +for i in range(nJobs): separator = ',\n ' if firstentry: separator = '\n ' @@ -105,7 +106,7 @@ # build list of tree files treeList ='' firstentry = True -for i in xrange(nJobs): +for i in range(nJobs): separator = ',\n ' if firstentry: separator = '\n ' diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_monitormerge.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_monitormerge.py index 9bda4dc98ba08..a8641ec9ab0ca 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_monitormerge.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_monitormerge.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os import subprocess import argparse @@ -20,29 +21,29 @@ # read mps.db lib = mpslib.jobdatabase() lib.read_db() -for i in xrange(lib.nJobs): +for i in range(lib.nJobs): print(lib.JOBSP3[i]) # count how much jobs there are of each dataset occurences = [] items = [] -for i in xrange(lib.nJobs): +for i in range(lib.nJobs): if lib.JOBSP3[i] not in items: items.append(lib.JOBSP3[i]) -for i in xrange(len(items)): +for i in range(len(items)): occurences.append(lib.JOBSP3.count(items[i])) # copy files from eos and combine root-files of each dataset with "hadd" counter = 0 -for i in xrange(len(items)): +for i in range(len(items)): command = 'hadd ' command += 'monitormerge_'+items[i]+'.root ' - for j in xrange(occurences[i]): + for j in range(occurences[i]): os.system('cp '+eosDir+'/millePedeMonitor%03d.root .' % (counter+j+1)) command += 'millePedeMonitor%03d.root ' % (counter+j+1) os.system(command) - for j in xrange(occurences[i]): + for j in range(occurences[i]): os.system('rm millePedeMonitor%03d.root' % (counter+j+1)) counter += occurences[i] diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_setup.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_setup.py index 1e462f7f3d860..3315b202363cb 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_setup.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os import re import sys @@ -166,7 +167,7 @@ os.makedirs("jobData") nJobExist = 0; -for j in xrange(1, args.n_jobs + 1): +for j in range(1, args.n_jobs + 1): i = j+nJobExist jobdir = "job{0:03d}".format(i) print("jobdir", jobdir) @@ -216,7 +217,7 @@ # Create (update) the local database -for j in xrange(1, args.n_jobs + 1): +for j in range(1, args.n_jobs + 1): i = j+nJobExist jobdir = "job{0:03d}".format(i) lib.JOBDIR.append(jobdir) diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_splice.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_splice.py index 3d3462f479383..76acf5e576306 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_splice.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_splice.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import re import argparse import math @@ -59,7 +60,7 @@ numberOfExtends = int(math.ceil(numberOfFiles/255.)) # Create and insert the readFile.extend lines -for j in xrange(numberOfExtends): +for j in range(numberOfExtends): insertBlock = "readFiles.extend([\n " i=0 currentStart = j*255 diff --git a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_update.py b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_update.py index fdcbb6011504d..bc93d003a826a 100755 --- a/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_update.py +++ b/Alignment/MillePedeAlignmentAlgorithm/scripts/mps_update.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os import re import subprocess @@ -46,7 +47,7 @@ def fill_time_info(mps_index, status, cpu_time): lib.read_db() submitted_jobs = {} -for i in xrange(len(lib.JOBID)): +for i in range(len(lib.JOBID)): submitted = True for status in ("SETUP", "OK", "DONE", "FETCH", "ABEND", "WARN", "FAIL"): if status in lib.JOBSTATUS[i]: diff --git a/Alignment/MuonAlignment/python/MCScenario_CRAFT1_22X.py b/Alignment/MuonAlignment/python/MCScenario_CRAFT1_22X.py index ec60b02bbff3f..364ae4db42f0f 100644 --- a/Alignment/MuonAlignment/python/MCScenario_CRAFT1_22X.py +++ b/Alignment/MuonAlignment/python/MCScenario_CRAFT1_22X.py @@ -23,6 +23,7 @@ # ./Alignment/MuonAlignment/python/geometryXMLtoCSV.py < MCScenario_CRAFT1_22X_CHECKME.xml > MCScenario_CRAFT1_22X_CHECKME.csv # and then open MCScenario_CRAFT1_22X_CHECKME.csv in Excel +from builtins import range import random, os from math import * diff --git a/Alignment/MuonAlignment/python/MuonGeometrySanityCheck_cfi.py b/Alignment/MuonAlignment/python/MuonGeometrySanityCheck_cfi.py index 23efd8922d66d..70f0d5caf1282 100644 --- a/Alignment/MuonAlignment/python/MuonGeometrySanityCheck_cfi.py +++ b/Alignment/MuonAlignment/python/MuonGeometrySanityCheck_cfi.py @@ -1,3 +1,4 @@ +from builtins import range import FWCore.ParameterSet.Config as cms MuonGeometrySanityCheck = cms.EDAnalyzer( @@ -16,7 +17,7 @@ def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, l for stationName in "1", "2", "3", "4": numSectors = 12 if stationName == "4": numSectors = 14 - for sectorName in map(str, range(1, numSectors+1)): + for sectorName in map(str, list(range(1, numSectors+1))): name = "MB" + wheelName + "/" + stationName + "/" + sectorName if chambers: output.append(name) @@ -37,7 +38,7 @@ def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, l for ringName in ringNames: numChambers = 36 if stationName + "/" + ringName in ("-4/1", "-3/1", "-2/1", "+2/1", "+3/1", "+4/1"): numChambers = 18 - for chamberName in map(str, range(1, numChambers+1)): + for chamberName in map(str, list(range(1, numChambers+1))): name = "ME" + stationName + "/" + ringName + "/" + chamberName if chambers: if me42 or stationName + "/" + ringName not in ("-4/2", "+4/2"): diff --git a/Alignment/MuonAlignment/python/geometryDiff.py b/Alignment/MuonAlignment/python/geometryDiff.py index 141f245674b27..7f7789a95677d 100755 --- a/Alignment/MuonAlignment/python/geometryDiff.py +++ b/Alignment/MuonAlignment/python/geometryDiff.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range from Alignment.MuonAlignment.geometryXMLparser import MuonGeometry, dtorder, cscorder import sys, getopt diff --git a/Alignment/MuonAlignment/python/makeMuonMisalignmentScenario.py b/Alignment/MuonAlignment/python/makeMuonMisalignmentScenario.py index a1fbeb5969a04..94f73d058f1a1 100644 --- a/Alignment/MuonAlignment/python/makeMuonMisalignmentScenario.py +++ b/Alignment/MuonAlignment/python/makeMuonMisalignmentScenario.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range from optparse import OptionParser from random import gauss from math import sqrt diff --git a/Alignment/MuonAlignment/python/svgfig.py b/Alignment/MuonAlignment/python/svgfig.py index 172d72bc938d2..9b74e47c0e70a 100644 --- a/Alignment/MuonAlignment/python/svgfig.py +++ b/Alignment/MuonAlignment/python/svgfig.py @@ -16,6 +16,7 @@ # # Full licence is in the file COPYING and at http://www.gnu.org/copyleft/gpl.html +from builtins import range import re, codecs, os, platform, copy, itertools, math, cmath, random, sys, copy _epsilon = 1e-5 @@ -1744,7 +1745,7 @@ def Path(self, trans=None, local=False): mode = "S" vx, vy = [0.]*len(self.d), [0.]*len(self.d) - for i in xrange(len(self.d)): + for i in range(len(self.d)): inext = (i+1) % len(self.d) iprev = (i-1) % len(self.d) @@ -1757,7 +1758,7 @@ def Path(self, trans=None, local=False): raise ValueError("mode must be \"lines\", \"bezier\", \"velocity\", \"foreback\", \"smooth\", or an abbreviation") d = [] - indexes = range(len(self.d)) + indexes = list(range(len(self.d))) if self.loop and len(self.d) > 0: indexes.append(0) for i in indexes: @@ -2611,7 +2612,7 @@ def compute_ticks(self, N, format): if N >= 0: output = {} x = self.low - for i in xrange(N): + for i in range(N): if format == unumber and abs(x) < eps: label = u"0" else: label = format(x) output[x] = label @@ -2681,7 +2682,7 @@ def regular_miniticks(self, N): """ output = [] x = self.low - for i in xrange(N): + for i in range(N): output.append(x) x += (self.high - self.low)/(N-1.) return output @@ -2727,7 +2728,7 @@ def compute_logticks(self, base, N, format): if N >= 0: output = {} x = self.low - for i in xrange(N): + for i in range(N): if format == unumber and abs(x) < eps: label = u"0" else: label = format(x) output[x] = label diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/alignmentValidation.py b/Alignment/MuonAlignmentAlgorithms/scripts/alignmentValidation.py index e54939d88a646..087cefa0c0013 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/alignmentValidation.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/alignmentValidation.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import re,os,sys,shutil import optparse diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/applyRadialCorrections.py b/Alignment/MuonAlignmentAlgorithms/scripts/applyRadialCorrections.py index 37f40933a5d83..2a7627579dc48 100644 --- a/Alignment/MuonAlignmentAlgorithms/scripts/applyRadialCorrections.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/applyRadialCorrections.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range mep11angle = 0.002 # guess mep12angle = 0.002 # guess mep13angle = 0.002 # guess diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/corrVsCorr.py b/Alignment/MuonAlignmentAlgorithms/scripts/corrVsCorr.py index 69e23a177b97c..89b71e197de68 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/corrVsCorr.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/corrVsCorr.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import sys, optparse copyargs = sys.argv[:] diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/createBeamHaloJobs.py b/Alignment/MuonAlignmentAlgorithms/scripts/createBeamHaloJobs.py index 9a38385927e63..a6f54e31af95a 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/createBeamHaloJobs.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/createBeamHaloJobs.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +from builtins import range import os, sys, re, optparse, math copyargs = sys.argv[:] diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/createCSCRingsJobs.py b/Alignment/MuonAlignmentAlgorithms/scripts/createCSCRingsJobs.py index ed39907af6ae9..eeb2d92b20b17 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/createCSCRingsJobs.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/createCSCRingsJobs.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os, sys, optparse, math copyargs = sys.argv[:] diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/createJobs.py b/Alignment/MuonAlignmentAlgorithms/scripts/createJobs.py index 5488d4cc53451..1c0ddf4c6af27 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/createJobs.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/createJobs.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os, sys, optparse, math copyargs = sys.argv[:] diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/createTree.py b/Alignment/MuonAlignmentAlgorithms/scripts/createTree.py index 47594b0fc3111..67da471f9a7af 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/createTree.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/createTree.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import re,os,sys import optparse diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/findQualityFiles.py b/Alignment/MuonAlignmentAlgorithms/scripts/findQualityFiles.py index 260819a440d8b..0e427242e2ef6 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/findQualityFiles.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/findQualityFiles.py @@ -7,6 +7,7 @@ ###################################################### from __future__ import print_function +from builtins import range import os,sys, DLFCN import optparse diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/groupFilesInBlocks.py b/Alignment/MuonAlignmentAlgorithms/scripts/groupFilesInBlocks.py index 936420f7395f1..3d8b4cf77ba3e 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/groupFilesInBlocks.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/groupFilesInBlocks.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import re,os,sys,shutil,math import optparse diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py b/Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py index deedc51b3b147..1752beb07e77f 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import os, sys, optparse, math, copy from Alignment.MuonAlignment.geometryXMLparser import MuonGeometry, dtorder, cscorder diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/plotscripts.py b/Alignment/MuonAlignmentAlgorithms/scripts/plotscripts.py index d6a7a4ed5c550..aa063b4371949 100644 --- a/Alignment/MuonAlignmentAlgorithms/scripts/plotscripts.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/plotscripts.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT, array, os, re, random from math import * import time @@ -1407,7 +1408,7 @@ def createPeaksProfile(the2d, rebin=1): hpeaks.Reset() hpeaks.Rebin(rebin) bad_fit_bins = [] - for i in xrange(0, int(the2d.GetNbinsX()), rebin): + for i in range(0, int(the2d.GetNbinsX()), rebin): tmp = the2d.ProjectionY("tmp", i+1, i + rebin) nn = tmp.GetEntries() @@ -1515,7 +1516,7 @@ def mapplot(tfiles, name, param, mode="from2d", window=10., abscissa=None, title skip = 10 #f = ROOT.TF1("g", "gaus", -40., 40) - for i in xrange(0, int(the2d.GetNbinsX()), skip): + for i in range(0, int(the2d.GetNbinsX()), skip): tmp = the2d.ProjectionY("tmp", i+1, i + skip) if tmp.GetEntries() > 1: #tmp.Fit("g","LNq") @@ -1840,7 +1841,7 @@ def curvatureplot(tfiles, name, param, mode="from2d", window=15., widebins=False hist2d.Add(tfile.Get(hdir+"th2f"+hsuffix)) hist = ROOT.TH1F("hist", "", prof.GetNbinsX(), prof.GetBinLowEdge(1), -prof.GetBinLowEdge(1)) - for i in xrange(1, prof.GetNbinsX()+1): + for i in range(1, prof.GetNbinsX()+1): hist.SetBinContent(i, prof.GetBinContent(i)) hist.SetBinError(i, prof.GetBinError(i)) @@ -1854,7 +1855,7 @@ def curvatureplot(tfiles, name, param, mode="from2d", window=15., widebins=False htmp = ROOT.gROOT.FindObject("tmp") if htmp != None: htmp.Delete() - for i in xrange(0, int(prof.GetNbinsX()), skip): + for i in range(0, int(prof.GetNbinsX()), skip): tmp = hist2d.ProjectionY("tmp", i+1, i + skip) if tmp.GetEntries() > 1: hist.SetBinContent(i/skip+1, tmp.GetMean()) @@ -2484,7 +2485,7 @@ def polynomials(tfile, reports, name, twobin=True, suppressblue=False): trackdxdz_minimum, trackdxdz_maximum = None, None for h in chamber_x_trackdxdz, chamber_y_trackdxdz, chamber_dxdz_trackdxdz, chamber_dydz_trackdxdz: if not not h: - for i in xrange(1, h.GetNbinsX()+1): + for i in range(1, h.GetNbinsX()+1): if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \ h.GetBinContent(i) + h.GetBinError(i) > -10.: if not trackdxdz_minimum or trackdxdz_minimum > h.GetBinCenter(i): @@ -2499,7 +2500,7 @@ def polynomials(tfile, reports, name, twobin=True, suppressblue=False): trackdydz_minimum, trackdydz_maximum = None, None for h in chamber_x_trackdydz, chamber_y_trackdydz, chamber_dxdz_trackdydz, chamber_dydz_trackdydz: if not not h: - for i in xrange(1, h.GetNbinsX()+1): + for i in range(1, h.GetNbinsX()+1): if h.GetBinError(i) > 0.01 and h.GetBinContent(i) - h.GetBinError(i) < 10. and \ h.GetBinContent(i) + h.GetBinError(i) > -10.: if not trackdydz_minimum or trackdydz_minimum > h.GetBinCenter(i): @@ -2967,7 +2968,7 @@ def segdiff(tfiles, component, pair, **args): tmppos.Add(tfile.Get(pdir + posname)) tmpneg.Add(tfile.Get(pdir + negname)) - for i in xrange(1, tmpprof.GetNbinsX()+1): + for i in range(1, tmpprof.GetNbinsX()+1): if tmpprof.GetBinError(i) < 1e-5: tmpprof.SetBinError(i, 100.) tmpprof.SetAxisRange(-window, window, "Y") @@ -3193,7 +3194,7 @@ def segdiffvsphi_xalign(tfiles, wheel, window=10.): gtemp_11_phi, gtemp_11_val, gtemp_11_err = [], [], [] gtemp_12_phi, gtemp_12_val, gtemp_12_err = [], [], [] gtemp_21_phi, gtemp_21_val, gtemp_21_err = [], [], [] - for sector in xrange(1, 12+1): + for sector in range(1, 12+1): #print "sect", sector r1 = segdiff_xalign(tfiles, "x_dt1_csc", wheel=wheel, sector=sector, cscstations = "12") r2 = segdiff_xalign(tfiles, "x_dt2_csc", wheel=wheel, sector=sector, cscstations = "1") @@ -3308,7 +3309,7 @@ def segdiffvsphi(tfiles, reports, component, wheel, window=5., excludesectors=() gtemp_12_phi, gtemp_12_val, gtemp_12_err, gtemp_12_val2, gtemp_12_err2 = [], [], [], [], [] gtemp_23_phi, gtemp_23_val, gtemp_23_err, gtemp_23_val2, gtemp_23_err2 = [], [], [], [], [] gtemp_34_phi, gtemp_34_val, gtemp_34_err, gtemp_34_val2, gtemp_34_err2 = [], [], [], [], [] - for sector in xrange(1, 12+1): + for sector in range(1, 12+1): #print "sect", sector r1_found, r2_found, r3_found, r4_found = False, False, False, False for r1 in reports: @@ -3466,8 +3467,8 @@ def segdiffvsphicsc(tfiles, component, pair, window=5., **args): gtemp_2_phi, gtemp_2_val, gtemp_2_err, gtemp_2_val2, gtemp_2_err2 = [], [], [], [], [] for ring in rings: - chambers = xrange(1,37) - if ring == 1: chambers = xrange(1,19) + chambers = range(1,37) + if ring == 1: chambers = range(1,19) for chamber in chambers: phi, val, err, val2, err2, fit1, fit2, fit3 = segdiff(tfiles, component, pair, endcap=endcap, ring=ring, chamber=chamber) diff --git a/Alignment/MuonAlignmentAlgorithms/scripts/reportVsReport.py b/Alignment/MuonAlignmentAlgorithms/scripts/reportVsReport.py index cd3db94d2cabe..8bba1acddd30e 100755 --- a/Alignment/MuonAlignmentAlgorithms/scripts/reportVsReport.py +++ b/Alignment/MuonAlignmentAlgorithms/scripts/reportVsReport.py @@ -1,6 +1,7 @@ #! /usr/bin/env python from __future__ import print_function +from builtins import range import sys, optparse copyargs = sys.argv[:] diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py index 11193d5d05920..405b05e04f921 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py @@ -3,6 +3,7 @@ # idea stolen from: # http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ # PhysicsTools/PatAlgos/python/tools/cmsswVersionTools.py +from builtins import range import bisect import datetime import json @@ -88,7 +89,7 @@ def __init__( self, datasetName, dasLimit = 0, tryPredefinedFirst = True, def __chunks( self, theList, n ): """ Yield successive n-sized chunks from theList. """ - for i in xrange( 0, len( theList ), n ): + for i in range( 0, len( theList ), n ): yield theList[i:i+n] __source_template= ("%(header)s" diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/genericValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/genericValidation.py index 73bf8420c65b1..d41e23f411ddf 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/genericValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/genericValidation.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range from abc import ABCMeta, abstractmethod, abstractproperty import os import re diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py index bc6e4b6b093f3..12de88e07acd0 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/helperFunctions.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import os import re import ROOT diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py index bb1060df6b048..9d04e37b9c106 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py @@ -1,4 +1,5 @@ from __future__ import absolute_import +from builtins import range import os import random diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py index c56b2afe05bfc..3d82b0ce4f667 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py @@ -1,5 +1,6 @@ from __future__ import print_function from __future__ import absolute_import +from builtins import range import abc import math import os @@ -65,7 +66,7 @@ def fit(self, plots): if residual != 0: rowlengths.append(residual) nrows += 1 - for _ in xrange(fullRows): + for _ in range(fullRows): rowlengths.append(length) # Now, fill the pattern. @@ -73,12 +74,12 @@ def fit(self, plots): if residual == 0 and len(plots[0])%length != 0 and\ len(plots[0])%nrows == 0: # It's better to arrange plots in columns, not rows. - self.pattern.extend(range(i, i+nrows*(length-1)+1, nrows) + self.pattern.extend(list(range(i, i+nrows*(length-1)+1, nrows)) for i in range(1, nrows+1)) else: if residual != 0: - self.pattern.append(range(1, 1+residual)) - self.pattern.extend(range(i, i+length) for i in + self.pattern.append(list(range(1, 1+residual))) + self.pattern.extend(list(range(i, i+length)) for i in range(residual+1, nplots-length+2, length)) self.width = 1.0/length @@ -166,7 +167,7 @@ def writePage(plots, title, layout): plotrows = [] for row in layout.pattern: plotrow = [] - for i in xrange(len(row)): + for i in range(len(row)): plotrow.append(plotTemplate.replace('[width]', str(layout.width)).\ replace('[height]', str(layout.height)).\ replace('[path]', plots[row[i]-1])) diff --git a/Alignment/OfflineValidation/test/submitAllJobs.py b/Alignment/OfflineValidation/test/submitAllJobs.py index 773682b7bd488..1b05bb1205ef2 100644 --- a/Alignment/OfflineValidation/test/submitAllJobs.py +++ b/Alignment/OfflineValidation/test/submitAllJobs.py @@ -4,6 +4,7 @@ ''' from __future__ import print_function +from builtins import range __author__ = 'Marco Musich' __copyright__ = 'Copyright 2015, CERN CMS' __credits__ = ['Ernesto Migliore', 'Salvatore Di Guida', 'Javier Duarte'] @@ -167,7 +168,7 @@ def split(sequence, size): # based on http://sandrotosi.blogspot.com/2011/04/python-group-list-in-sub-lists-of-n.html # about generators see also http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained ########################## - for i in xrange(0, len(sequence), size): + for i in range(0, len(sequence), size): yield sequence[i:i+size] ############# From b4ed7604bf02ee44c9d01b4ce02e317ffd0338b9 Mon Sep 17 00:00:00 2001 From: Ahmad Muhammad Date: Wed, 10 Apr 2019 05:23:43 +0200 Subject: [PATCH 537/686] Data relvals 2018 ABC,2016 and 2017 relvals using Offline GTs now by default --- .../python/relval_standard.py | 106 +++++++++--------- .../python/relval_steps.py | 63 +++++++---- 2 files changed, 92 insertions(+), 77 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_standard.py b/Configuration/PyReleaseValidation/python/relval_standard.py index c2768582ae616..228e77e8baeb0 100644 --- a/Configuration/PyReleaseValidation/python/relval_standard.py +++ b/Configuration/PyReleaseValidation/python/relval_standard.py @@ -324,74 +324,74 @@ workflows[136.7952] = ['',['RunJetHT2017C_94Xv2NanoAODINPUT','NANOEDM2017_94XMiniAODv2','HARVESTNANOAOD2017_94XMiniAODv2']] ### run 2018A ### -workflows[136.849] = ['',['RunHLTPhy2018A','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.850] = ['',['RunEGamma2018A','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM']] -workflows[136.851] = ['',['RunDoubleMuon2018A','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.852] = ['',['RunJetHT2018A','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt','HARVEST2018']] -workflows[136.853] = ['',['RunMET2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Prompt','HARVEST2018']] -workflows[136.854] = ['',['RunMuonEG2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Prompt','HARVEST2018']] -workflows[136.855] = ['',['RunSingleMu2018A','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi','HARVEST2018_L1TMuDQM']] -workflows[136.856] = ['',['RunZeroBias2018A','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.857] = ['',['RunMuOnia2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Prompt','HARVEST2018']] -workflows[136.858] = ['',['RunNoBPTX2018A','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Prompt','HARVEST2018']] -workflows[136.859] = ['',['RunDisplacedJet2018A','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Prompt','HARVEST2018']] -workflows[136.860] = ['',['RunCharmonium2018A','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Prompt','HARVEST2018']] +workflows[136.849] = ['',['RunHLTPhy2018A','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.850] = ['',['RunEGamma2018A','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Offline_L1TEgDQM','HARVEST2018_L1TEgDQM']] +workflows[136.851] = ['',['RunDoubleMuon2018A','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.852] = ['',['RunJetHT2018A','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Offline','HARVEST2018']] +workflows[136.853] = ['',['RunMET2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Offline','HARVEST2018']] +workflows[136.854] = ['',['RunMuonEG2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Offline','HARVEST2018']] +workflows[136.855] = ['',['RunSingleMu2018A','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Offline_Lumi','HARVEST2018_L1TMuDQM']] +workflows[136.856] = ['',['RunZeroBias2018A','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.857] = ['',['RunMuOnia2018A','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Offline','HARVEST2018']] +workflows[136.858] = ['',['RunNoBPTX2018A','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Offline','HARVEST2018']] +workflows[136.859] = ['',['RunDisplacedJet2018A','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Offline','HARVEST2018']] +workflows[136.860] = ['',['RunCharmonium2018A','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Offline','HARVEST2018']] ### wf to test 90 m beta* Totem run reconstruction ### -workflows[136.8501] = ['',['RunEGamma2018A','HLTDR2_2018','RECODR2_2018reHLT_skimParkingBPH_Prompt','HARVEST2018']] -workflows[136.8561] = ['',['RunZeroBias_hBStarTk','HLTDR2_2018_hBStar','RECODR2_2018reHLT_Prompt_hBStar','HARVEST2018_hBStar']] -workflows[136.8562] = ['',['RunZeroBias1_hBStarRP','HLTDR2_2018_hBStar','RECODR2_2018reHLT_Prompt_hBStar','HARVEST2018_hBStar']] +workflows[136.8501] = ['',['RunEGamma2018A','HLTDR2_2018','RECODR2_2018reHLT_skimParkingBPH_Offline','HARVEST2018']] +workflows[136.8561] = ['',['RunZeroBias_hBStarTk','HLTDR2_2018_hBStar','RECODR2_2018reHLT_Offline_hBStar','HARVEST2018_hBStar']] +workflows[136.8562] = ['',['RunZeroBias1_hBStarRP','HLTDR2_2018_hBStar','RECODR2_2018reHLT_Offline_hBStar','HARVEST2018_hBStar']] ### NANOAOD wf on 2018 prompt reco MINIADD workflows[136.8521] = ['',['RunJetHT2018A_nano','NANOEDM2018','HARVESTNANOAOD2018']] ### run 2018B ### -workflows[136.861] = ['',['RunHLTPhy2018B','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.862] = ['',['RunEGamma2018B','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM']] -workflows[136.863] = ['',['RunDoubleMuon2018B','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.864] = ['',['RunJetHT2018B','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt','HARVEST2018']] -workflows[136.865] = ['',['RunMET2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Prompt','HARVEST2018']] -workflows[136.866] = ['',['RunMuonEG2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Prompt','HARVEST2018']] -workflows[136.867] = ['',['RunSingleMu2018B','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi','HARVEST2018_L1TMuDQM']] -workflows[136.868] = ['',['RunZeroBias2018B','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.869] = ['',['RunMuOnia2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Prompt','HARVEST2018']] -workflows[136.870] = ['',['RunNoBPTX2018B','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Prompt','HARVEST2018']] -workflows[136.871] = ['',['RunDisplacedJet2018B','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Prompt','HARVEST2018']] -workflows[136.872] = ['',['RunCharmonium2018B','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Prompt','HARVEST2018']] -workflows[136.898] = ['',['RunParkingBPH2018B','HLTDR2_2018','RECODR2_2018reHLT_skimParkingBPH_Prompt','HARVEST2018']] +workflows[136.861] = ['',['RunHLTPhy2018B','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.862] = ['',['RunEGamma2018B','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Offline_L1TEgDQM','HARVEST2018_L1TEgDQM']] +workflows[136.863] = ['',['RunDoubleMuon2018B','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.864] = ['',['RunJetHT2018B','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Offline','HARVEST2018']] +workflows[136.865] = ['',['RunMET2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Offline','HARVEST2018']] +workflows[136.866] = ['',['RunMuonEG2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Offline','HARVEST2018']] +workflows[136.867] = ['',['RunSingleMu2018B','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Offline_Lumi','HARVEST2018_L1TMuDQM']] +workflows[136.868] = ['',['RunZeroBias2018B','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.869] = ['',['RunMuOnia2018B','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Offline','HARVEST2018']] +workflows[136.870] = ['',['RunNoBPTX2018B','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Offline','HARVEST2018']] +workflows[136.871] = ['',['RunDisplacedJet2018B','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Offline','HARVEST2018']] +workflows[136.872] = ['',['RunCharmonium2018B','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Offline','HARVEST2018']] +workflows[136.898] = ['',['RunParkingBPH2018B','HLTDR2_2018','RECODR2_2018reHLT_skimParkingBPH_Offline','HARVEST2018']] workflows[136.8642] = ['',['RunJetHT2018BHEfail','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt_HEfail','HARVEST2018_HEfail']] workflows[136.8643] = ['',['RunJetHT2018BBadHcalMitig','HLTDR2_2018_BadHcalMitig','RECODR2_2018reHLT_skimJetHT_Prompt_BadHcalMitig','HARVEST2018_BadHcalMitig']] ### run 2018C ### -workflows[136.873] = ['',['RunHLTPhy2018C','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.874] = ['',['RunEGamma2018C','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM']] -workflows[136.875] = ['',['RunDoubleMuon2018C','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.876] = ['',['RunJetHT2018C','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt','HARVEST2018']] -workflows[136.877] = ['',['RunMET2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Prompt','HARVEST2018']] -workflows[136.878] = ['',['RunMuonEG2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Prompt','HARVEST2018']] -workflows[136.879] = ['',['RunSingleMu2018C','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi','HARVEST2018_L1TMuDQM']] -workflows[136.880] = ['',['RunZeroBias2018C','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.881] = ['',['RunMuOnia2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Prompt','HARVEST2018']] -workflows[136.882] = ['',['RunNoBPTX2018C','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Prompt','HARVEST2018']] -workflows[136.883] = ['',['RunDisplacedJet2018C','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Prompt','HARVEST2018']] -workflows[136.884] = ['',['RunCharmonium2018C','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Prompt','HARVEST2018']] +workflows[136.873] = ['',['RunHLTPhy2018C','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.874] = ['',['RunEGamma2018C','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Offline_L1TEgDQM','HARVEST2018_L1TEgDQM']] +workflows[136.875] = ['',['RunDoubleMuon2018C','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.876] = ['',['RunJetHT2018C','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Offline','HARVEST2018']] +workflows[136.877] = ['',['RunMET2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Offline','HARVEST2018']] +workflows[136.878] = ['',['RunMuonEG2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Offline','HARVEST2018']] +workflows[136.879] = ['',['RunSingleMu2018C','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Offline_Lumi','HARVEST2018_L1TMuDQM']] +workflows[136.880] = ['',['RunZeroBias2018C','HLTDR2_2018','RECODR2_2018reHLT_Offline','HARVEST2018']] +workflows[136.881] = ['',['RunMuOnia2018C','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Offline','HARVEST2018']] +workflows[136.882] = ['',['RunNoBPTX2018C','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Offline','HARVEST2018']] +workflows[136.883] = ['',['RunDisplacedJet2018C','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Offline','HARVEST2018']] +workflows[136.884] = ['',['RunCharmonium2018C','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Offline','HARVEST2018']] ### run 2018D ### -workflows[136.885] = ['',['RunHLTPhy2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.886] = ['',['RunEGamma2018D','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM']] -workflows[136.887] = ['',['RunDoubleMuon2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.888] = ['',['RunJetHT2018D','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt','HARVEST2018']] -workflows[136.889] = ['',['RunMET2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Prompt','HARVEST2018']] -workflows[136.890] = ['',['RunMuonEG2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Prompt','HARVEST2018']] -workflows[136.891] = ['',['RunSingleMu2018D','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi','HARVEST2018_L1TMuDQM']] -workflows[136.892] = ['',['RunZeroBias2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018']] -workflows[136.893] = ['',['RunMuOnia2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Prompt','HARVEST2018']] -workflows[136.894] = ['',['RunNoBPTX2018D','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Prompt','HARVEST2018']] -workflows[136.895] = ['',['RunDisplacedJet2018D','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Prompt','HARVEST2018']] -workflows[136.896] = ['',['RunCharmonium2018D','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Prompt','HARVEST2018']] +workflows[136.885] = ['',['RunHLTPhy2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018_Prompt']] +workflows[136.886] = ['',['RunEGamma2018D','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM_Prompt']] +workflows[136.887] = ['',['RunDoubleMuon2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018_Prompt']] +workflows[136.888] = ['',['RunJetHT2018D','HLTDR2_2018','RECODR2_2018reHLT_skimJetHT_Prompt','HARVEST2018_Prompt']] +workflows[136.889] = ['',['RunMET2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMET_Prompt','HARVEST2018_Prompt']] +workflows[136.890] = ['',['RunMuonEG2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMuonEG_Prompt','HARVEST2018_Prompt']] +workflows[136.891] = ['',['RunSingleMu2018D','HLTDR2_2018','RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi','HARVEST2018_L1TMuDQM_Prompt']] +workflows[136.892] = ['',['RunZeroBias2018D','HLTDR2_2018','RECODR2_2018reHLT_Prompt','HARVEST2018_Prompt']] +workflows[136.893] = ['',['RunMuOnia2018D','HLTDR2_2018','RECODR2_2018reHLT_skimMuOnia_Prompt','HARVEST2018_Prompt']] +workflows[136.894] = ['',['RunNoBPTX2018D','HLTDR2_2018','RECODR2_2018reHLTAlCaTkCosmics_Prompt','HARVEST2018_Prompt']] +workflows[136.895] = ['',['RunDisplacedJet2018D','HLTDR2_2018','RECODR2_2018reHLT_skimDisplacedJet_Prompt','HARVEST2018_Prompt']] +workflows[136.896] = ['',['RunCharmonium2018D','HLTDR2_2018','RECODR2_2018reHLT_skimCharmonium_Prompt','HARVEST2018_Prompt']] # multi-run harvesting -workflows[137.8] = ['',['RunEGamma2018C','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM', +workflows[137.8] = ['',['RunEGamma2018C','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Offline_L1TEgDQM', 'RunEGamma2018D','HLTDR2_2018','RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM','HARVEST2018_L1TEgDQM_MULTIRUN']] ### fastsim ### diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 22193a75a6004..0d16a0d1efc89 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2142,48 +2142,60 @@ def gen2018HiMix(fragment,howMuch): 'RECODR2reHLTAlCaTkCosmics']: steps[sname+"_HIPM"] = merge([{'--era': steps[sname]['--era']+"_HIPM"},steps[sname]]) -# RECO step with Prompt-like GT -steps['RECODR2_2016reHLT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT']]) +# RECO step with offline GT +steps['RECODR2_2016reHLT_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT']]) steps['RECODR2_2016reHLT_Prompt_L1TEgDQM']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'},steps['RECODR2_2016reHLT_Prompt']]) -steps['RECODR2_2016reHLT_skimDoubleEG_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimDoubleEG']]) -steps['RECODR2_2016reHLT_skimJetHT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimJetHT']]) -steps['RECODR2_2016reHLT_skimMET_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimMET']]) -steps['RECODR2_2016reHLT_skimMuonEG_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimMuonEG']]) -steps['RECODR2_2016reHLT_skimSingleMu_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimSingleMu']]) -steps['RECODR2_2016reHLT_skimSinglePh_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimSinglePh']]) -steps['RECODR2_2016reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2016reHLT_skimMuOnia']]) +steps['RECODR2_2016reHLT_skimDoubleEG_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimDoubleEG']]) +steps['RECODR2_2016reHLT_skimJetHT_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimJetHT']]) +steps['RECODR2_2016reHLT_skimMET_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimMET']]) +steps['RECODR2_2016reHLT_skimMuonEG_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimMuonEG']]) +steps['RECODR2_2016reHLT_skimSingleMu_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimSingleMu']]) +steps['RECODR2_2016reHLT_skimSinglePh_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimSinglePh']]) +steps['RECODR2_2016reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2016reHLT_skimMuOnia']]) steps['RECODR2_2016reHLT_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@lumi'},steps['RECODR2_2016reHLT_Prompt']]) steps['RECODR2_2016reHLT_Prompt_Lumi_L1TMuDQM']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2016reHLT_Prompt']]) -steps['RECODR2_2017reHLT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT']]) +steps['RECODR2_2017reHLT_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT']]) steps['RECODR2_2017reHLT_Prompt_L1TEgDQM']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'},steps['RECODR2_2017reHLT_Prompt']]) -steps['RECODR2_2017reHLT_skimDoubleEG_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimDoubleEG']]) -steps['RECODR2_2017reHLT_skimJetHT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimJetHT']]) -steps['RECODR2_2017reHLT_skimDisplacedJet_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimDisplacedJet']]) -steps['RECODR2_2017reHLT_skimMET_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimMET']]) -steps['RECODR2_2017reHLT_skimMuonEG_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimMuonEG']]) -steps['RECODR2_2017reHLT_skimSingleMu_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimSingleMu']]) -steps['RECODR2_2017reHLT_skimSinglePh_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimSinglePh']]) -steps['RECODR2_2017reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimMuOnia']]) -steps['RECODR2_2017reHLT_skimCharmonium_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLT_skimCharmonium']]) +steps['RECODR2_2017reHLT_skimDoubleEG_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimDoubleEG']]) +steps['RECODR2_2017reHLT_skimJetHT_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimJetHT']]) +steps['RECODR2_2017reHLT_skimDisplacedJet_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimDisplacedJet']]) +steps['RECODR2_2017reHLT_skimMET_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimMET']]) +steps['RECODR2_2017reHLT_skimMuonEG_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimMuonEG']]) +steps['RECODR2_2017reHLT_skimSingleMu_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimSingleMu']]) +steps['RECODR2_2017reHLT_skimSinglePh_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimSinglePh']]) +steps['RECODR2_2017reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimMuOnia']]) +steps['RECODR2_2017reHLT_skimCharmonium_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLT_skimCharmonium']]) steps['RECODR2_2017reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2017reHLT_skimSingleMu_Prompt']]) -steps['RECODR2_2017reHLTAlCaTkCosmics_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLTAlCaTkCosmics']]) -steps['RECODR2_2017reHLTSiPixelCalZeroBias_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2017reHLTSiPixelCalZeroBias']]) +steps['RECODR2_2017reHLTAlCaTkCosmics_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLTAlCaTkCosmics']]) +steps['RECODR2_2017reHLTSiPixelCalZeroBias_Prompt']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2017reHLTSiPixelCalZeroBias']]) steps['RECODR2_2018reHLT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT']]) +steps['RECODR2_2018reHLT_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT']]) steps['RECODR2_2018reHLT_skimEGamma_Prompt_L1TEgDQM']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimEGamma_L1TEgDQM']]) +steps['RECODR2_2018reHLT_skimEGamma_Offline_L1TEgDQM']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimEGamma_L1TEgDQM']]) steps['RECODR2_2018reHLT_skimJetHT_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimJetHT']]) +steps['RECODR2_2018reHLT_skimJetHT_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimJetHT']]) steps['RECODR2_2018reHLT_skimDisplacedJet_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimDisplacedJet']]) +steps['RECODR2_2018reHLT_skimDisplacedJet_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimDisplacedJet']]) steps['RECODR2_2018reHLT_skimMET_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimMET']]) +steps['RECODR2_2018reHLT_skimMET_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimMET']]) steps['RECODR2_2018reHLT_skimMuonEG_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimMuonEG']]) +steps['RECODR2_2018reHLT_skimMuonEG_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimMuonEG']]) steps['RECODR2_2018reHLT_skimSingleMu_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimSingleMu']]) +steps['RECODR2_2018reHLT_skimSingleMu_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimSingleMu']]) steps['RECODR2_2018reHLT_skimMuOnia_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimMuOnia']]) +steps['RECODR2_2018reHLT_skimMuOnia_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimMuOnia']]) steps['RECODR2_2018reHLT_skimCharmonium_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimCharmonium']]) +steps['RECODR2_2018reHLT_skimCharmonium_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimCharmonium']]) steps['RECODR2_2018reHLT_skimParkingBPH_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLT_skimParkingBPH']]) +steps['RECODR2_2018reHLT_skimParkingBPH_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLT_skimParkingBPH']]) steps['RECODR2_2018reHLT_skimSingleMu_Prompt_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Prompt']]) +steps['RECODR2_2018reHLT_skimSingleMu_Offline_Lumi']=merge([{'-s':'RAW2DIGI,L1Reco,RECO,SKIM:MuonPOGSkim+ZMu+MuTau,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@standardDQM+@ExtraHLT+@miniAODDQM+@lumi+@L1TMuon'},steps['RECODR2_2018reHLT_skimSingleMu_Offline']]) steps['RECODR2_2018reHLTAlCaTkCosmics_Prompt']=merge([{'--conditions':'auto:run2_data_promptlike'},steps['RECODR2_2018reHLTAlCaTkCosmics']]) - +steps['RECODR2_2018reHLTAlCaTkCosmics_Offline']=merge([{'--conditions':'auto:run2_data'},steps['RECODR2_2018reHLTAlCaTkCosmics']]) steps['RECODR2_2018reHLT_Prompt_hBStar']=merge([{'--era':'Run2_2018_highBetaStar'},steps['RECODR2_2018reHLT_Prompt']]) +steps['RECODR2_2018reHLT_Offline_hBStar']=merge([{'--era':'Run2_2018_highBetaStar'},steps['RECODR2_2018reHLT_Offline']]) steps['RECODR2_2018reHLT_skimJetHT_Prompt_HEfail']=merge([{'--conditions':'auto:run2_data_promptlike_HEfail'},steps['RECODR2_2018reHLT_skimJetHT']]) steps['RECODR2_2018reHLT_skimJetHT_Prompt_BadHcalMitig']=merge([{'--conditions':'auto:run2_data_promptlike_HEfail','--era':'Run2_2018,pf_badHcalMitigation'},steps['RECODR2_2018reHLT_skimJetHT']]) @@ -2465,12 +2477,15 @@ def gen2018HiMix(fragment,howMuch): steps['HARVEST2016'] = merge([ {'--era':'Run2_2016'}, steps['HARVESTDR2'] ]) steps['HARVEST2016_L1TEgDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'}, steps['HARVEST2016'] ]) steps['HARVEST2016_L1TMuDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TMuon'}, steps['HARVEST2016'] ]) -steps['HARVEST2017'] = merge([ {'--conditions':'auto:run2_data_relval','--era':'Run2_2017','--conditions':'auto:run2_data_promptlike',}, steps['HARVESTD'] ]) +steps['HARVEST2017'] = merge([ {'--conditions':'auto:run2_data_relval','--era':'Run2_2017','--conditions':'auto:run2_data'}, steps['HARVESTD'] ]) steps['HARVEST2017_L1TEgDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'}, steps['HARVEST2017'] ]) steps['HARVEST2017_L1TMuDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TMuon'}, steps['HARVEST2017'] ]) -steps['HARVEST2018'] = merge([ {'--conditions':'auto:run2_data_relval','--era':'Run2_2018','--conditions':'auto:run2_data_promptlike',}, steps['HARVESTD'] ]) +steps['HARVEST2018'] = merge([ {'--conditions':'auto:run2_data_relval','--era':'Run2_2018','--conditions':'auto:run2_data',}, steps['HARVESTD'] ]) +steps['HARVEST2018_Prompt'] = merge([ {'--conditions':'auto:run2_data_relval','--era':'Run2_2018','--conditions':'auto:run2_data_promptlike',}, steps['HARVESTD'] ]) steps['HARVEST2018_L1TEgDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'}, steps['HARVEST2018'] ]) +steps['HARVEST2018_L1TEgDQM_Prompt'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TEgamma'}, steps['HARVEST2018_Prompt'] ]) steps['HARVEST2018_L1TMuDQM'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TMuon'}, steps['HARVEST2018'] ]) +steps['HARVEST2018_L1TMuDQM_Prompt'] = merge([ {'-s':'HARVESTING:@standardDQM+@ExtraHLT+@miniAODDQM+@L1TMuon'}, steps['HARVEST2018_Prompt'] ]) steps['HARVEST2018_hBStar'] = merge([ {'--era' : 'Run2_2018_highBetaStar'}, steps['HARVEST2018'] ]) steps['HARVEST2018_HEfail'] = merge([ {'--conditions':'auto:run2_data_promptlike_HEfail'}, steps['HARVEST2018'] ]) steps['HARVEST2018_BadHcalMitig'] = merge([ {'--era' : 'Run2_2018,pf_badHcalMitigation','--conditions':'auto:run2_data_promptlike_HEfail'}, steps['HARVEST2018'] ]) From 53841a1689516b86c1541c628a40d3cc5e5f8d84 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2019 08:44:25 +0200 Subject: [PATCH 538/686] migrate away from commands --- Utilities/General/python/cmssw_das_client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Utilities/General/python/cmssw_das_client.py b/Utilities/General/python/cmssw_das_client.py index 755d18e3d6f56..fe92d743fc175 100644 --- a/Utilities/General/python/cmssw_das_client.py +++ b/Utilities/General/python/cmssw_das_client.py @@ -1,4 +1,3 @@ -from commands import getstatusoutput import time import os from json import loads, dumps @@ -79,6 +78,8 @@ def get_data(query, limit=None, threshold=None, idx=None, host=None, cmd=None): if os.path.isfile(os.path.join(path, 'dasgoclient')): cmd = "dasgoclient" break - err, out = getstatusoutput("%s %s --query '%s'" % (cmd, cmd_opts, query)) - if not err: return loads(out) - return {'status' : 'error', 'reason' : out} + + p = subprocess.Popen("%s %s --query '%s'" % (cmd, cmd_opts, query),shell=True, stdout=PIPE, stderr=subprocess.STDOUT) + stdout, stderr = p.communicate() + if not p.returncode: return loads(out) + return {'status' : 'error', 'reason' : stdout} From 555d068396ae995e8559381c1d20c8ea7fcc4f67 Mon Sep 17 00:00:00 2001 From: Salavat Date: Wed, 10 Apr 2019 10:28:32 +0200 Subject: [PATCH 539/686] adding HBX/HEX crosstalk channels --- .../src/HcalText2DetIdConverter.cc | 25 +++++++++++- .../HcalDetId/interface/HcalCalibDetId.h | 19 +++++++-- DataFormats/HcalDetId/src/HcalCalibDetId.cc | 40 ++++++++++++++----- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc index a0d2496b71655..c06857fa8bc3a 100644 --- a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc +++ b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc @@ -158,7 +158,17 @@ bool HcalText2DetIdConverter::init (DetId fId) { setField (1, calibId.rm()); setField (2, calibId.fiber()); setField (3, calibId.channel()); - } + } else if ( calibId.calibFlavor()==HcalCalibDetId::HBX) { + flavorName="HBX"; + setField (1, calibId.ieta()); + setField (2, calibId.iphi()); + setField (3, calibId.depth()); + } else if ( calibId.calibFlavor()==HcalCalibDetId::HEX) { + flavorName="HEX"; + setField (1, calibId.ieta()); + setField (2, calibId.iphi()); + setField (3, calibId.depth()); + } } else { flavorName = "UNKNOWN_FLAVOR"; @@ -234,6 +244,19 @@ bool HcalText2DetIdConverter::init (const std::string& fFlavor, const std::strin int iphi=getField(2); mId = HcalCalibDetId (ieta,iphi); } + else if (flavorName=="HBX") { + int ieta=getField(1); + int iphi=getField(2); + int depth=getField(3); + mId = HcalCalibDetId (HcalCalibDetId::HBX, ieta, iphi, depth); + } + else if (flavorName=="HEX") { + int ieta=getField(1); + int iphi=getField(2); + int depth=getField(3); + mId = HcalCalibDetId (HcalCalibDetId::HEX, ieta, iphi, depth); + + } else if (flavorName=="UMNQIE") { int channel=getField(1); mId = HcalCalibDetId (HcalCalibDetId::uMNqie,channel); diff --git a/DataFormats/HcalDetId/interface/HcalCalibDetId.h b/DataFormats/HcalDetId/interface/HcalCalibDetId.h index 11c5cb093f464..c1386ca3baddb 100644 --- a/DataFormats/HcalDetId/interface/HcalCalibDetId.h +++ b/DataFormats/HcalDetId/interface/HcalCalibDetId.h @@ -8,7 +8,7 @@ /** \class HcalCalibDetId * * Contents of the HcalCalibDetId : - * [19:17] Calibration Category (1 = CalibUnit, 2 = HX, 3=uMNio/qie, 4=CastorRad) + * [19:17] Calibration Category (1 = CalibUnit, 2 = HOX, 3=uMNio/qie, 4=CastorRad, 5=LASMON, 6=HBX, 7=HEX) * * For CalibUnit: * [16:14] Subdetector @@ -29,13 +29,24 @@ * [9:5] fiber-in-rm * [4:0] channel-on-fiber * + * For Laser Monitoring channels: + * [16:10] ieta + * [9:5] iphi + * [3:0] cbox * + * For HBX/HEX: + * [19:17] 6 or 7 (CalibType) + * [15:15] 0/1 (Side) + * [14:10] ieta (1-29) + * [9:3] iphi (1-72) + * [2:0] depth (1-7) + * * \author J. Mans - Minnesota */ class HcalCalibDetId : public HcalOtherDetId { public: /** Type identifier within calibration det ids */ - enum CalibDetType { CalibrationBox = 1, HOCrosstalk = 2, uMNqie = 3, CastorRadFacility = 4, LASERMON = 5 }; + enum CalibDetType { CalibrationBox = 1, HOCrosstalk = 2, uMNqie = 3, CastorRadFacility = 4, LASERMON = 5, HBX = 6, HEX = 7 }; /** Create a null det id */ HcalCalibDetId(); @@ -50,7 +61,7 @@ class HcalCalibDetId : public HcalOtherDetId { HcalCalibDetId(int ieta, int iphi); /** Construct a uMNqie id or other id which uses a single value plus a DetType */ HcalCalibDetId(CalibDetType dt, int value); - /** Construct a Castor radiation test facility id or other id which uses three values plus a DetType */ + /** Construct a Castor radiation test facility id or other id which uses three values plus a DetType */ HcalCalibDetId(CalibDetType dt, int value1, int value2, int value3); /// get the flavor of this calibration detid @@ -79,6 +90,8 @@ class HcalCalibDetId : public HcalOtherDetId { /// get the sign of ieta (+/-1) int zside() const; + /// get the depth (where relevant) + int depth() const; /// constants static const int cbox_MixerHigh = 0; // HB/HE/HO/HF diff --git a/DataFormats/HcalDetId/src/HcalCalibDetId.cc b/DataFormats/HcalDetId/src/HcalCalibDetId.cc index 66716c8df249b..42160cca10a17 100644 --- a/DataFormats/HcalDetId/src/HcalCalibDetId.cc +++ b/DataFormats/HcalDetId/src/HcalCalibDetId.cc @@ -27,10 +27,10 @@ HcalCalibDetId::HcalCalibDetId(HcalSubdetector subdet, int ieta, int iphi, int c } HcalCalibDetId::HcalCalibDetId(int ieta, int iphi) : HcalOtherDetId(HcalCalibration) { - id_|=(HOCrosstalk<<17); // Calibration Category, bits [17:19] (= "2" for HOX) - id_|=(iphi&0x7F) // phi index, bits [0:6] - |((abs(ieta)&0xF)<<7) // eta index, bits [7:10] - |(((ieta > 0)?(1):(0))<<11); // z side, bit [11] + id_|=(HOCrosstalk<<17); // Calibration Category, bits [17:19] (= "2" for HOX) + id_|=(iphi&0x7F) // phi index, bits [0:6] + |((abs(ieta)&0xF)<<7) // eta index, bits [7:10] + |(((ieta > 0)?(1):(0))<<11); // z side, bit [11] } HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value) : HcalOtherDetId(HcalCalibration) { @@ -39,10 +39,19 @@ HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value) : HcalOtherDetId(Hcal } HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value1, int value2, int value3) : HcalOtherDetId(HcalCalibration) { - id_|=(dt<<17); - id_|=(value1&0x3F)<<10; - id_|=(value2&0x1F)<<5; - id_|=(value3&0x1F); + id_|=(dt<<17); // Calibration Category, bits [17:19] + + if(dt == HBX || dt == HEX) { + id_|=(value3&0x7) // depth index, bits [0:2] + |((value2&0x7F)<<3) // phi index, bits [3:9] + |((value1&0x1F)<<10) // eta index, bits [10:14] + |(((value1 > 0)?(1):(0))<<15); // z side, bit [15] + } + else { + id_|=(value1&0x3F)<<10; + id_|=(value2&0x1F)<<5; + id_|=(value3&0x1F); + } } HcalCalibDetId::HcalCalibDetId(const DetId& gen) { @@ -75,17 +84,22 @@ HcalSubdetector HcalCalibDetId::hcalSubdet() const { } int HcalCalibDetId::ieta() const { - return (calibFlavor()==CalibrationBox)?(((id_>>11)&0x7)-2):((calibFlavor()==HOCrosstalk)?(((id_>>7)&0xF)*zside()):(calibFlavor()==LASERMON?((id_>>10)&0x3F):(0))); + return (calibFlavor()==CalibrationBox)?(((id_>>11)&0x7)-2):((calibFlavor()==HOCrosstalk)?(((id_>>7)&0xF)*zside()):(calibFlavor()==LASERMON?((id_>>10)&0x3F):(((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>10)&0x1F)*zside():(0))))); } int HcalCalibDetId::iphi() const { - return (calibFlavor()==CalibrationBox)?((id_>>4)&0x7F):((calibFlavor()==HOCrosstalk)?(id_&0x7F):(calibFlavor()==LASERMON?((id_>>5)&0x1F):(0))); + return (calibFlavor()==CalibrationBox)?((id_>>4)&0x7F):((calibFlavor()==HOCrosstalk)?(id_&0x7F):(calibFlavor()==LASERMON?((id_>>5)&0x1F):(((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>3)&0x7F):(0))))); } int HcalCalibDetId::zside() const { - return (calibFlavor()==HOCrosstalk)?(((id_>>11)&0x1)?(1):(-1)):(0); + return (calibFlavor()==HOCrosstalk)?(((id_>>11)&0x1)?(1):(-1)):((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>15)&0x1)?(1):(-1):(0)); } +int HcalCalibDetId::depth() const { + return (calibFlavor()==HBX || calibFlavor()==HEX)?(id_&0x7):(0); +} + + std::string HcalCalibDetId::cboxChannelString() const { switch (cboxChannel()) { case(cbox_MixerHigh): return "Mixer-High"; @@ -130,6 +144,10 @@ std::ostream& operator<<(std::ostream& s,const HcalCalibDetId& id) { return s << "(LASERMON" << id.channel() << ')'; case (HcalCalibDetId::CastorRadFacility): return s << "(CastorRadFacility " << id.rm() << " / " << id.fiber() << " / " << id.channel() << ')'; + case (HcalCalibDetId::HBX): + return s << "(HBX " << id.ieta() << "," << id.iphi() << "," << id.depth() << ")"; + case (HcalCalibDetId::HEX): + return s << "(HEX " << id.ieta() << "," << id.iphi() << "," << id.depth() << ")"; default: return s; }; } From c08f9483779a30848e95b1e1a1a0f9514ae94c83 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Wed, 10 Apr 2019 10:48:58 +0200 Subject: [PATCH 540/686] add file which also tests streamer output module --- EventFilter/Utilities/test/start_file_FU.py | 144 ++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 EventFilter/Utilities/test/start_file_FU.py diff --git a/EventFilter/Utilities/test/start_file_FU.py b/EventFilter/Utilities/test/start_file_FU.py new file mode 100644 index 0000000000000..9d4be17c3f802 --- /dev/null +++ b/EventFilter/Utilities/test/start_file_FU.py @@ -0,0 +1,144 @@ +from __future__ import print_function +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +import os + +options = VarParsing.VarParsing ('analysis') + +options.register ('runNumber', + 100, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Run Number") + +options.register ('buBaseDir', + 'ramdisk', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "BU base directory") + + +options.register ('fuBaseDir', + 'data', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "BU base directory") + +options.register ('fffBaseDir', + '.', # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, # string, int, or float + "FFF base directory") + + +options.register ('numThreads', + 2, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of CMSSW threads") + +options.register ('numFwkStreams', + 2, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of CMSSW streams") + + +options.parseArguments() + +cmsswbase = os.path.expandvars("$CMSSW_BASE/") + +process = cms.Process("TESTFU") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +process.options = cms.untracked.PSet( + numberOfThreads = cms.untracked.uint32(options.numThreads), + numberOfStreams = cms.untracked.uint32(options.numFwkStreams), + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(2) +) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string( "INFO" )), + destinations = cms.untracked.vstring( 'cout' ) +) + +process.FastMonitoringService = cms.Service("FastMonitoringService", + sleepTime = cms.untracked.int32(1) +) + +process.EvFDaqDirector = cms.Service("EvFDaqDirector", + useFileService = cms.untracked.bool(False), + fileServiceHost = cms.untracked.string("htcp40.cern.ch"), + runNumber = cms.untracked.uint32(options.runNumber), + baseDir = cms.untracked.string(options.fffBaseDir +"/"+options.fuBaseDir), + buBaseDir = cms.untracked.string(options.fffBaseDir+"/"+options.buBaseDir), + directorIsBu = cms.untracked.bool(False), + testModeNoBuilderUnit = cms.untracked.bool(False) +) + +try: + os.makedirs(options.fuBaseDir+"/run"+str(options.runNumber).zfill(6)) +except Exception as ex: + print(str(ex)) + pass + +process.source = cms.Source("FedRawDataInputSource", + runNumber = cms.untracked.uint32(options.runNumber), + getLSFromFilename = cms.untracked.bool(True), + testModeNoBuilderUnit = cms.untracked.bool(False), + verifyAdler32 = cms.untracked.bool(True), + verifyChecksum = cms.untracked.bool(True), + useL1EventID = cms.untracked.bool(True), + eventChunkSize = cms.untracked.uint32(32), + numBuffers = cms.untracked.uint32(2), + eventChunkBlock = cms.untracked.uint32(32) + ) + +process.PrescaleService = cms.Service( "PrescaleService", + forceDefault = cms.bool( False ), + prescaleTable = cms.VPSet( + cms.PSet( pathName = cms.string( "p1" ), + prescales = cms.vuint32( 10) + ), + cms.PSet( pathName = cms.string( "p2" ), + prescales = cms.vuint32( 100 ) + ) + ), + lvl1DefaultLabel = cms.string( "Default" ), + lvl1Labels = cms.vstring( 'Default' ) + ) + +process.filter1 = cms.EDFilter("HLTPrescaler", + L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) + ) +process.filter2 = cms.EDFilter("HLTPrescaler", + L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) + ) + +process.a = cms.EDAnalyzer("ExceptionGenerator", + defaultAction = cms.untracked.int32(0), + defaultQualifier = cms.untracked.int32(1000)) + +process.b = cms.EDAnalyzer("ExceptionGenerator", + defaultAction = cms.untracked.int32(0), + defaultQualifier = cms.untracked.int32(5)) + +process.p1 = cms.Path(process.a*process.filter1) +process.p2 = cms.Path(process.b*process.filter2) + +process.streamA = cms.OutputModule("EvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p1' )) +) + +process.streamB = cms.OutputModule("EvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p2' )) +) + +process.fileWriter = cms.OutputModule("EventStreamFileWriter", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'p1' )) +) + + +process.ep = cms.EndPath(process.streamA+process.streamB+process.fileWriter) From 43866524acbfe50bc99519c2928acba71ed881e4 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 9 Apr 2019 19:28:25 +0200 Subject: [PATCH 541/686] Perform per-lumi reset in offline harvesting. This is required for the proposed changes to per-lumi saving; the reset no longer happens in the DQMRootSource, instead the subsystems are responsible if they want to see statistics of one lumisection only. --- .../interface/DQWorkerClient.h | 1 + .../plugins/EcalDQMonitorClient.cc | 5 +++++ DQM/EcalMonitorClient/src/DQWorkerClient.cc | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/DQM/EcalMonitorClient/interface/DQWorkerClient.h b/DQM/EcalMonitorClient/interface/DQWorkerClient.h index f5be98878967a..7ef32fbced950 100644 --- a/DQM/EcalMonitorClient/interface/DQWorkerClient.h +++ b/DQM/EcalMonitorClient/interface/DQWorkerClient.h @@ -25,6 +25,7 @@ namespace ecaldqm static void fillDescriptions(edm::ParameterSetDescription&); void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + void resetPerLumi(); void bookMEs(DQMStore::IBooker&) override; void releaseMEs() override; diff --git a/DQM/EcalMonitorClient/plugins/EcalDQMonitorClient.cc b/DQM/EcalMonitorClient/plugins/EcalDQMonitorClient.cc index f065a41d30a3f..61c10d47bee63 100644 --- a/DQM/EcalMonitorClient/plugins/EcalDQMonitorClient.cc +++ b/DQM/EcalMonitorClient/plugins/EcalDQMonitorClient.cc @@ -102,6 +102,11 @@ EcalDQMonitorClient::dqmEndLuminosityBlock(DQMStore::IBooker& _ibooker, DQMStore ecaldqmEndLuminosityBlock(_lumi, _es); runWorkers(_igetter, ecaldqm::DQWorkerClient::kLumi); + + executeOnWorkers_([](ecaldqm::DQWorker* worker){ + ecaldqm::DQWorkerClient* client(static_cast(worker)); + client->resetPerLumi(); + }, "dqmEndLuminosityBlock", "Reset per-lumi MEs"); } void diff --git a/DQM/EcalMonitorClient/src/DQWorkerClient.cc b/DQM/EcalMonitorClient/src/DQWorkerClient.cc index bf9c76ae6e03a..2f345c7c09ee1 100644 --- a/DQM/EcalMonitorClient/src/DQWorkerClient.cc +++ b/DQM/EcalMonitorClient/src/DQWorkerClient.cc @@ -169,6 +169,23 @@ namespace ecaldqm } } + void + DQWorkerClient::resetPerLumi() + { + for (auto const& meset : MEs_) { + int i = 0; + while (auto me = meset.second->getME(i)) { + if (me->getLumiFlag()) { + std::cout << "+++ reset " << me->getFullname() << "\n"; + // reset per-lumi histograms in offline harvesting so that they only show + // data of the current lumisection. + me->Reset(); + } + i++; + } + } + } + void DQWorkerClient::towerAverage_(MESet& _target, MESet const& _source, float _threshold) { From 7a5715a5aa45510a0617c95b55388d2490f1beaa Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 9 Apr 2019 20:04:35 +0200 Subject: [PATCH 542/686] Make code checks happy. --- DQM/EcalMonitorClient/interface/DQWorkerClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/EcalMonitorClient/interface/DQWorkerClient.h b/DQM/EcalMonitorClient/interface/DQWorkerClient.h index 7ef32fbced950..48959f98cab8a 100644 --- a/DQM/EcalMonitorClient/interface/DQWorkerClient.h +++ b/DQM/EcalMonitorClient/interface/DQWorkerClient.h @@ -20,7 +20,7 @@ namespace ecaldqm }; DQWorkerClient(); - virtual ~DQWorkerClient() {} + ~DQWorkerClient() override {} static void fillDescriptions(edm::ParameterSetDescription&); From 2f334a26ab52e771f5668f24851895d972c9f997 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2019 11:53:26 +0200 Subject: [PATCH 543/686] fix problems --- Utilities/General/python/cmssw_das_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Utilities/General/python/cmssw_das_client.py b/Utilities/General/python/cmssw_das_client.py index fe92d743fc175..b0bd537387654 100644 --- a/Utilities/General/python/cmssw_das_client.py +++ b/Utilities/General/python/cmssw_das_client.py @@ -2,6 +2,7 @@ import os from json import loads, dumps from types import GeneratorType +import subprocess #Copied from das_client.py @@ -79,7 +80,7 @@ def get_data(query, limit=None, threshold=None, idx=None, host=None, cmd=None): cmd = "dasgoclient" break - p = subprocess.Popen("%s %s --query '%s'" % (cmd, cmd_opts, query),shell=True, stdout=PIPE, stderr=subprocess.STDOUT) + p = subprocess.Popen("%s %s --query '%s'" % (cmd, cmd_opts, query),shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = p.communicate() - if not p.returncode: return loads(out) + if not p.returncode: return loads(stdout) return {'status' : 'error', 'reason' : stdout} From 765136dd46447d206379476227fd59a758010a8b Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 10 Apr 2019 12:35:06 +0200 Subject: [PATCH 544/686] Add reset calls in DigiRunSummary. This should prevent double counting issues in HCAL. --- DQM/HcalTasks/src/DigiRunSummary.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DQM/HcalTasks/src/DigiRunSummary.cc b/DQM/HcalTasks/src/DigiRunSummary.cc index 8651c04aab015..b51fe081f91e3 100644 --- a/DQM/HcalTasks/src/DigiRunSummary.cc +++ b/DQM/HcalTasks/src/DigiRunSummary.cc @@ -224,6 +224,8 @@ namespace hcaldqm // push all the flags for all FEDs for this LS _vflagsLS.push_back(lssum); + cDigiSize_Crate.reset(); + cOccupancy_depth.reset(); } /* From 7f41cc198b87e3551dd941edd8d508c5c205ae0a Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Wed, 10 Apr 2019 12:07:51 +0100 Subject: [PATCH 545/686] adding fixedGridRhoFastjetAllTmp to miniAOD event content --- PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py index 84d755f7f5322..6df101d5d1147 100644 --- a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py @@ -47,6 +47,7 @@ 'keep double_fixedGridRhoAll__*', 'keep double_fixedGridRhoFastjetAll__*', + 'keep double_fixedGridRhoFastjetAllTmp__*', 'keep double_fixedGridRhoFastjetAllCalo__*', 'keep double_fixedGridRhoFastjetCentral_*_*', 'keep double_fixedGridRhoFastjetCentralCalo__*', From 99deffa08447b79d973f14f8a7045852ca6e54e2 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2019 13:37:29 +0200 Subject: [PATCH 546/686] replace map --- DQM/EcalMonitorTasks/python/TrigPrimTask_cfi.py | 4 ++-- DQM/Integration/python/config/inputsource_cfi.py | 2 +- SimMuon/Configuration/python/SimMuon_EventContent_cff.py | 4 +++- Validation/RecoTrack/python/trackingNtuple_cff.py | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DQM/EcalMonitorTasks/python/TrigPrimTask_cfi.py b/DQM/EcalMonitorTasks/python/TrigPrimTask_cfi.py index 1094da6ab03bd..d2a13a723818e 100644 --- a/DQM/EcalMonitorTasks/python/TrigPrimTask_cfi.py +++ b/DQM/EcalMonitorTasks/python/TrigPrimTask_cfi.py @@ -144,7 +144,7 @@ nbins = cms.untracked.int32(8), low = cms.untracked.double(-0.5), title = cms.untracked.string('TT flag'), - labels = cms.untracked.vstring(map(str, range(0, 8))) + labels = cms.untracked.vstring([ str(i) for i in range(0, 8)]) ), otype = cms.untracked.string('Ecal3P'), btype = cms.untracked.string('DCC'), @@ -158,7 +158,7 @@ nbins = cms.untracked.int32(8), low = cms.untracked.double(-0.5), title = cms.untracked.string('TT flag'), - labels = cms.untracked.vstring(map(str, range(0, 8))) + labels = cms.untracked.vstring([ str(i) for i in range(0, 8)]) ), otype = cms.untracked.string('Ecal3P'), xaxis = cms.untracked.PSet( diff --git a/DQM/Integration/python/config/inputsource_cfi.py b/DQM/Integration/python/config/inputsource_cfi.py index 3aa604d445768..53c99bb638660 100644 --- a/DQM/Integration/python/config/inputsource_cfi.py +++ b/DQM/Integration/python/config/inputsource_cfi.py @@ -77,7 +77,7 @@ ) else: print("The list of input files is provided. Disabling discovery and running on everything.") - files = map(lambda x: "file://" + x, options.inputFiles) + files = ["file://" + x for x in options.inputFiles] source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(files), secondaryFileNames = cms.untracked.vstring() diff --git a/SimMuon/Configuration/python/SimMuon_EventContent_cff.py b/SimMuon/Configuration/python/SimMuon_EventContent_cff.py index 234bcf9c5bb64..2c0327c100564 100644 --- a/SimMuon/Configuration/python/SimMuon_EventContent_cff.py +++ b/SimMuon/Configuration/python/SimMuon_EventContent_cff.py @@ -85,4 +85,6 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim def _renameForFastsim(s): return s.replace("_g4Sim", "_MuonSim") -fastSim.toModify(SimMuonPREMIX, outputCommands = map(_renameForFastsim, SimMuonPREMIX.outputCommands.value())) + +fastSim.toModify(SimMuonPREMIX, outputCommands = list( ( _renameForFastsim(item) for item in SimMuonPREMIX.outputCommands.value()))) + diff --git a/Validation/RecoTrack/python/trackingNtuple_cff.py b/Validation/RecoTrack/python/trackingNtuple_cff.py index b6ea13f281d93..e12cb3a5ff82d 100644 --- a/Validation/RecoTrack/python/trackingNtuple_cff.py +++ b/Validation/RecoTrack/python/trackingNtuple_cff.py @@ -79,9 +79,9 @@ def _filterForNtuple(lst): def _seedProdToTrackCands(name): return name.replace("seedTracks", "").replace("Seeds", "TrackCandidates") -trackingNtuple.trackCandidates = map(_seedProdToTrackCands, _seedProducers) -trackingPhase1.toModify(trackingNtuple, trackCandidates=map(_seedProdToTrackCands, _seedProducers_trackingPhase1)) -trackingPhase2PU140.toModify(trackingNtuple, trackCandidates=map(_seedProdToTrackCands, _seedProducers_trackingPhase2PU140)) +trackingNtuple.trackCandidates = [_seedProdToTrackCands(i) for i in _seedProducers] +trackingPhase1.toModify(trackingNtuple, trackCandidates=[_seedProdToTrackCands(i) for i in _seedProducers_trackingPhase1]) +trackingPhase2PU140.toModify(trackingNtuple, trackCandidates=[_seedProdToTrackCands(i) for i in _seedProducers_trackingPhase2PU140]) trackingNtupleTask = cms.Task() # reproduce hits because they're not stored in RECO From 7e4ae4cda12ef1fbe04fcaa799f3c7c188759f8d Mon Sep 17 00:00:00 2001 From: Sam Harper Date: Wed, 10 Apr 2019 13:01:48 +0100 Subject: [PATCH 547/686] converting dR to dR squared --- .../plugins/PhotonIDValueMapProducer.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc index e264bb06f1a33..2eae7a571741f 100644 --- a/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc +++ b/RecoEgamma/PhotonIdentification/plugins/PhotonIDValueMapProducer.cc @@ -145,11 +145,11 @@ const std::string names[nVars_] = { }; // options and bitflags -constexpr float coneSizeDR = 0.3; +constexpr float coneSizeDR2 = 0.3*0.3; constexpr float dxyMax = 0.1; constexpr float dzMax = 0.2; -constexpr float dRvetoBarrel = 0.02; -constexpr float dRvetoEndcap = 0.02; +constexpr float dRveto2Barrel = 0.02*0.02; +constexpr float dRveto2Endcap = 0.02*0.02; constexpr float ptMin = 0.1; const unsigned char PV_CONSTRAINT = 0x1; @@ -272,7 +272,7 @@ void PhotonIDValueMapProducer::produce(edm::StreamID, edm::Event& iEvent, const // Check if this candidate is within the isolation cone float dR2 = deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi()); - if (dR2 > coneSizeDR * coneSizeDR) + if (dR2 > coneSizeDR2) continue; // Check if this candidate is not in the footprint @@ -372,7 +372,7 @@ float PhotonIDValueMapProducer::computeWorstPFChargedIsolation(const reco::Photo { float worstIsolation = 0.0; - const float dRveto = photon.isEB() ? dRvetoBarrel : dRvetoEndcap; + const float dRveto2 = photon.isEB() ? dRveto2Barrel : dRveto2Endcap; std::vector chargedCands; chargedCands.reserve(pfCands.size()); @@ -406,8 +406,8 @@ float PhotonIDValueMapProducer::computeWorstPFChargedIsolation(const reco::Photo auto iCand = aCCand.candidate; float dR2 = deltaR2(phoWrtVtxEta, phoWrtVtxPhi, iCand->eta(), iCand->phi()); - if (dR2 > coneSizeDR * coneSizeDR || - (options & DR_VETO && dR2 < dRveto * dRveto)) + if (dR2 > coneSizeDR2 || + (options & DR_VETO && dR2 < dRveto2)) continue; float dxy = -999; From b73b52713695f31fe09e0dbdb1adaa7faee4c90f Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2019 14:46:00 +0200 Subject: [PATCH 548/686] xrange migration --- EgammaAnalysis/ElectronTools/test/compareMass.py | 11 ++++++----- L1Trigger/L1THGCal/test/macros/DrawingUtilities.py | 3 ++- L1Trigger/L1THGCal/test/macros/drawTriggerCells.py | 5 +++-- L1Trigger/L1THGCal/test/macros/drawTriggerModules.py | 7 ++++--- .../L1THGCal/test/macros/drawTriggerModulesHex.py | 7 ++++--- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/EgammaAnalysis/ElectronTools/test/compareMass.py b/EgammaAnalysis/ElectronTools/test/compareMass.py index c299f836d48ff..4329f2c5a6c04 100644 --- a/EgammaAnalysis/ElectronTools/test/compareMass.py +++ b/EgammaAnalysis/ElectronTools/test/compareMass.py @@ -1,3 +1,4 @@ +from builtins import range import ROOT masseb = [] @@ -9,7 +10,7 @@ masseb.append(ROOT.TH1F("masseb1", "", 80, 70, 110)) massee.append(ROOT.TH1F("massee1", "", 80, 70, 110)) -for z in xrange(e): +for z in range(e): t1.GetEntry(z) if(abs(t1.l1eta)<1.479 and abs(t1.l2eta)<1.479): masseb[-1].Fill(t1.mass) @@ -23,7 +24,7 @@ masseb.append(ROOT.TH1F("masseb2", "", 80, 70, 110)) massee.append(ROOT.TH1F("massee2", "", 80, 70, 110)) -for z in xrange(e): +for z in range(e): t2.GetEntry(z) if(abs(t2.l1eta)<1.479 and abs(t2.l2eta)<1.479): masseb[-1].Fill(t2.mass) @@ -37,7 +38,7 @@ masseb.append(ROOT.TH1F("masseb3", "", 80, 70, 110)) massee.append(ROOT.TH1F("massee3", "", 80, 70, 110)) -for z in xrange(e): +for z in range(e): t3.GetEntry(z) if(abs(t3.l1eta)<1.479 and abs(t3.l2eta)<1.479): masseb[-1].Fill(t3.mass) @@ -51,7 +52,7 @@ masseb.append(ROOT.TH1F("masseb4", "", 80, 70, 110)) massee.append(ROOT.TH1F("massee4", "", 80, 70, 110)) -for z in xrange(e): +for z in range(e): t4.GetEntry(z) if(abs(t4.l1eta)<1.479 and abs(t4.l2eta)<1.479): masseb[-1].Fill(t4.mass) @@ -61,7 +62,7 @@ c = [] ratio = [] -for i in xrange(2): +for i in range(2): c.append(ROOT.TCanvas("c"+str(i), "c")) c[-1].Divide(2,2) c[-1].cd(1) diff --git a/L1Trigger/L1THGCal/test/macros/DrawingUtilities.py b/L1Trigger/L1THGCal/test/macros/DrawingUtilities.py index 2257ef06c4f97..84a39ebd07e1f 100644 --- a/L1Trigger/L1THGCal/test/macros/DrawingUtilities.py +++ b/L1Trigger/L1THGCal/test/macros/DrawingUtilities.py @@ -1,3 +1,4 @@ +from builtins import range import ROOT import waferGeometry import math @@ -147,7 +148,7 @@ def hexagon(self): def hexagon_lines(self): xs,ys = self.hexagon_points() lines = [] - for i in xrange(len(xs)-1): + for i in range(len(xs)-1): lines.append(ROOT.TLine(xs[i], ys[i], xs[i+1], ys[i+1])) self.lines = lines return lines diff --git a/L1Trigger/L1THGCal/test/macros/drawTriggerCells.py b/L1Trigger/L1THGCal/test/macros/drawTriggerCells.py index 15c8dc315a6bf..baa3d9e6a2385 100644 --- a/L1Trigger/L1THGCal/test/macros/drawTriggerCells.py +++ b/L1Trigger/L1THGCal/test/macros/drawTriggerCells.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT import random @@ -94,7 +95,7 @@ def boxlines(box): entryList1.__class__ = ROOT.TEntryList nentry = entryList1.GetN() treeCells.SetEntryList(entryList1) -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print("Entry {0}/{1}".format(ie, nentry)) entry = entryList1.GetEntry(ie) treeCells.GetEntry(entry) @@ -123,7 +124,7 @@ def boxlines(box): entryList2.__class__ = ROOT.TEntryList nentry = entryList2.GetN() treeTriggerCells.SetEntryList(entryList2) -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print("Entry {0}/{1}".format(ie, nentry)) entry = entryList2.GetEntry(ie) treeTriggerCells.GetEntry(entry) diff --git a/L1Trigger/L1THGCal/test/macros/drawTriggerModules.py b/L1Trigger/L1THGCal/test/macros/drawTriggerModules.py index 774cd281b30b6..88c307c8fac8b 100644 --- a/L1Trigger/L1THGCal/test/macros/drawTriggerModules.py +++ b/L1Trigger/L1THGCal/test/macros/drawTriggerModules.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT import random @@ -108,7 +109,7 @@ def boxlines(box): entryList1.__class__ = ROOT.TEntryList nentry = entryList1.GetN() treeCells.SetEntryList(entryList1) -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print("Entry {0}/{1}".format(ie, nentry)) entry = entryList1.GetEntry(ie) treeCells.GetEntry(entry) @@ -137,7 +138,7 @@ def boxlines(box): entryList2.__class__ = ROOT.TEntryList nentry = entryList2.GetN() treeTriggerCells.SetEntryList(entryList2) -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print("Entry {0}/{1}".format(ie, nentry)) entry = entryList2.GetEntry(ie) treeTriggerCells.GetEntry(entry) @@ -164,7 +165,7 @@ def boxlines(box): entryList3.__class__ = ROOT.TEntryList nentry = entryList3.GetN() treeModules.SetEntryList(entryList3) -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print("Entry {0}/{1}".format(ie, nentry)) entry = entryList3.GetEntry(ie) treeModules.GetEntry(entry) diff --git a/L1Trigger/L1THGCal/test/macros/drawTriggerModulesHex.py b/L1Trigger/L1THGCal/test/macros/drawTriggerModulesHex.py index 401c177093fbc..b87ce2647eb85 100644 --- a/L1Trigger/L1THGCal/test/macros/drawTriggerModulesHex.py +++ b/L1Trigger/L1THGCal/test/macros/drawTriggerModulesHex.py @@ -1,4 +1,5 @@ from __future__ import print_function +from builtins import range import ROOT from DrawingUtilities import Cell, TriggerCell, Module @@ -27,7 +28,7 @@ nentry = entryList1.GetN() treeCells.SetEntryList(entryList1) print('>> Reading cell tree') -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print(" Entry {0}/{1}".format(ie, nentry)) entry = entryList1.GetEntry(ie) treeCells.GetEntry(entry) @@ -59,7 +60,7 @@ nentry = entryList2.GetN() treeTriggerCells.SetEntryList(entryList2) print('>> Reading trigger cell tree') -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print(" Entry {0}/{1}".format(ie, nentry)) entry = entryList2.GetEntry(ie) treeTriggerCells.GetEntry(entry) @@ -86,7 +87,7 @@ nentry = entryList3.GetN() treeModules.SetEntryList(entryList3) print('>> Reading module tree') -for ie in xrange(nentry): +for ie in range(nentry): if ie%10000==0: print(" Entry {0}/{1}".format(ie, nentry)) entry = entryList3.GetEntry(ie) treeModules.GetEntry(entry) From e249312815749918eedbcfb1b82955239810b1c5 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 10 Apr 2019 08:29:14 -0500 Subject: [PATCH 549/686] Allow return value optimization in getAnyPtr The gcc 9 compiler gave a warning stating the use of std::move was preventing return value optimization. --- FWCore/Utilities/interface/getAnyPtr.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FWCore/Utilities/interface/getAnyPtr.h b/FWCore/Utilities/interface/getAnyPtr.h index bfdd649fe7d63..09fd1b7c43d5f 100644 --- a/FWCore/Utilities/interface/getAnyPtr.h +++ b/FWCore/Utilities/interface/getAnyPtr.h @@ -18,8 +18,7 @@ namespace edm { assert(p != nullptr); pointerUnion.vp = p; pointerUnion.ucp += offset; - std::unique_ptr tp(pointerUnion.tp); - return(std::move(tp)); + return std::unique_ptr(pointerUnion.tp); } } From ad0ff8775bdbe329735bee1613352c929fb9baee Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2019 15:35:36 +0200 Subject: [PATCH 550/686] add bool function --- FWCore/ParameterSet/python/Types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FWCore/ParameterSet/python/Types.py b/FWCore/ParameterSet/python/Types.py index a6e34aa6dad82..d1794bef80772 100644 --- a/FWCore/ParameterSet/python/Types.py +++ b/FWCore/ParameterSet/python/Types.py @@ -151,7 +151,8 @@ def insertInto(self, parameterSet, myname): parameterSet.addBool(self.isTracked(), myname, self.value()) def __nonzero__(self): return self.value() - + def __bool__(self): + return self.__nonzero__() class string(_SimpleParameterTypeBase): From 9e32e5ffde85854a01410ebb0c180073996fdb5d Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Wed, 10 Apr 2019 16:31:56 +0200 Subject: [PATCH 551/686] Include cmath to track recognition algorithm for header consistency --- RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h index 1ddb3c48cbc81..ec72806478c38 100644 --- a/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h +++ b/RecoCTPPS/TotemRPLocal/interface/CTPPSTimingTrackRecognition.h @@ -21,6 +21,7 @@ #include #include #include +#include /** * Class intended to perform general CTPPS timing detectors track recognition, From c0a250f16f6716285cf602c498edefdb0c6cc03f Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 10 Apr 2019 16:35:02 +0200 Subject: [PATCH 552/686] Coerce the FwkIO unit tests into passing again... ... by emulating the per-lumi reset in in the DQMStore. Ideally we'd test for the new behaviour of harvesting instead of emulating the old behaviour for the tests, but that would break the assumption in the tests that saving and loading DQMIO files does not change the contents. We could keep this (and solve many other problems) by keeping the per-lumi histos and their per-run harvested versions separate in the DQMStore, but the legacy-mode DQMStore in Harvesting really does not understand such concepts. So, we have to admit defeat and cheat in the tests until we can run harvesting with a properly structured DQMStore. The forceResetOnBeginLumi option was not used anywhere, so changing the behaviour to something more sane should be safe; expanding the per-run reset to per-lumi histos makes sense in general as well. --- DQMServices/Core/src/DQMStore.cc | 2 +- DQMServices/FwkIO/plugins/DQMRootSource.cc | 3 --- DQMServices/FwkIO/test/copy_file_multi_types_cfg.py | 2 +- DQMServices/FwkIO/test/create_run_lumi_file_cfg.py | 3 ++- DQMServices/FwkIO/test/merge_file1_file2_cfg.py | 2 +- DQMServices/FwkIO/test/merge_file1_file3_file2_cfg.py | 2 +- .../FwkIO/test/merge_file1_file3_file2_filterOnRun1_cfg.py | 2 +- DQMServices/FwkIO/test/merge_file1_file3_file4_cfg.py | 2 +- DQMServices/FwkIO/test/read_file1_file2_cfg.py | 2 +- DQMServices/FwkIO/test/read_file1_file3_cfg.py | 2 +- DQMServices/FwkIO/test/read_lumi_only_file_cfg.py | 2 +- DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py | 2 +- DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py | 2 +- DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py | 2 +- .../read_write_merged_file1_file3_file2_filterOnRun1_cfg.py | 2 +- 15 files changed, 15 insertions(+), 17 deletions(-) diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index ac255e6a9e2c8..b3c85f62e0b8a 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -377,7 +377,7 @@ DQMStore::DQMStore(edm::ParameterSet const& pset, edm::ActivityRegistry& ar) } if(pset.getUntrackedParameter("forceResetOnBeginLumi",false) && enableMultiThread_ == false) { forceResetOnBeginLumi_ = true; - ar.watchPostSourceLumi([this](edm::LuminosityBlockIndex){ forceReset(); }); + ar.watchPreSourceLumi([this](edm::LuminosityBlockIndex){ forceReset(); }); } ar.watchPostGlobalBeginLumi(this, &DQMStore::postGlobalBeginLumi); } diff --git a/DQMServices/FwkIO/plugins/DQMRootSource.cc b/DQMServices/FwkIO/plugins/DQMRootSource.cc index 7aad7408e94bc..216d72d8992b4 100644 --- a/DQMServices/FwkIO/plugins/DQMRootSource.cc +++ b/DQMServices/FwkIO/plugins/DQMRootSource.cc @@ -585,9 +585,6 @@ DQMRootSource::readRun_(edm::RunPrincipal& rpCache) edm::Service store; std::vector allMEs = (*store).getAllContents(""); for(auto const& ME : allMEs) { - // We do not want to reset here Lumi products, since a dedicated - // resetting is done at every lumi transition. - if (ME->getLumiFlag()) continue; if ( !(*store).isCollate() ) ME->Reset(); } diff --git a/DQMServices/FwkIO/test/copy_file_multi_types_cfg.py b/DQMServices/FwkIO/test/copy_file_multi_types_cfg.py index 83a12f897489d..6c6002309c564 100644 --- a/DQMServices/FwkIO/test/copy_file_multi_types_cfg.py +++ b/DQMServices/FwkIO/test/copy_file_multi_types_cfg.py @@ -9,6 +9,6 @@ fileName = cms.untracked.string("dqm_copy_multi_types.root")) process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py b/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py index b0d1fbffebf76..47750351db5eb 100644 --- a/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py +++ b/DQMServices/FwkIO/test/create_run_lumi_file_cfg.py @@ -26,5 +26,6 @@ process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) -process.add_(cms.Service("DQMStore",forceResetOnBeginRun = cms.untracked.bool(True))) +process.add_(cms.Service("DQMStore",forceResetOnBeginRun = cms.untracked.bool(True), verbose = cms.untracked.int32(10))) +process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/merge_file1_file2_cfg.py b/DQMServices/FwkIO/test/merge_file1_file2_cfg.py index bfb3fe64878f2..62c65e0a0ce50 100644 --- a/DQMServices/FwkIO/test/merge_file1_file2_cfg.py +++ b/DQMServices/FwkIO/test/merge_file1_file2_cfg.py @@ -9,6 +9,6 @@ fileName = cms.untracked.string("dqm_merged_file1_file2.root")) process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/merge_file1_file3_file2_cfg.py b/DQMServices/FwkIO/test/merge_file1_file3_file2_cfg.py index a442ea32f45ce..4df413eab86a4 100644 --- a/DQMServices/FwkIO/test/merge_file1_file3_file2_cfg.py +++ b/DQMServices/FwkIO/test/merge_file1_file3_file2_cfg.py @@ -11,6 +11,6 @@ fileName = cms.untracked.string("dqm_merged_file1_file3_file2.root")) process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/merge_file1_file3_file2_filterOnRun1_cfg.py b/DQMServices/FwkIO/test/merge_file1_file3_file2_filterOnRun1_cfg.py index 7af458781441a..80a20d2b0e825 100644 --- a/DQMServices/FwkIO/test/merge_file1_file3_file2_filterOnRun1_cfg.py +++ b/DQMServices/FwkIO/test/merge_file1_file3_file2_filterOnRun1_cfg.py @@ -13,6 +13,6 @@ filterOnRun = cms.untracked.uint32(1)) process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/merge_file1_file3_file4_cfg.py b/DQMServices/FwkIO/test/merge_file1_file3_file4_cfg.py index 13cf0383e0003..c382fa191777f 100644 --- a/DQMServices/FwkIO/test/merge_file1_file3_file4_cfg.py +++ b/DQMServices/FwkIO/test/merge_file1_file3_file4_cfg.py @@ -9,6 +9,6 @@ fileName = cms.untracked.string("dqm_merged_file1_file3_file4.root")) process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_file1_file2_cfg.py b/DQMServices/FwkIO/test/read_file1_file2_cfg.py index 5ca43bfc8e6bc..029258d527509 100644 --- a/DQMServices/FwkIO/test/read_file1_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_file1_file2_cfg.py @@ -40,6 +40,6 @@ process.e = cms.EndPath(process.check+process.reader) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_file1_file3_cfg.py b/DQMServices/FwkIO/test/read_file1_file3_cfg.py index dfc6b9ab45d53..8ad7e12cd2042 100644 --- a/DQMServices/FwkIO/test/read_file1_file3_cfg.py +++ b/DQMServices/FwkIO/test/read_file1_file3_cfg.py @@ -41,6 +41,6 @@ process.e = cms.EndPath(process.check+process.reader) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py b/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py index 760b55f855472..be3932f6ba4b6 100644 --- a/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py +++ b/DQMServices/FwkIO/test/read_lumi_only_file_cfg.py @@ -22,6 +22,6 @@ process.e = cms.EndPath(process.check) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py index 62adbb56b2133..deb7ddc8f3c28 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file2_cfg.py @@ -41,6 +41,6 @@ process.e = cms.EndPath(process.check+process.reader) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py index d1cdaf0e35810..7005bb306903e 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file3_file2_cfg.py @@ -42,6 +42,6 @@ process.e = cms.EndPath(process.check+process.reader) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py b/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py index 0aa38ed7127a6..c8386aed95ce5 100644 --- a/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py +++ b/DQMServices/FwkIO/test/read_merged_file1_file3_file4_cfg.py @@ -62,6 +62,6 @@ process.e = cms.EndPath(process.check+process.reader) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) #process.add_(cms.Service("Tracer")) diff --git a/DQMServices/FwkIO/test/read_write_merged_file1_file3_file2_filterOnRun1_cfg.py b/DQMServices/FwkIO/test/read_write_merged_file1_file3_file2_filterOnRun1_cfg.py index 7c687831bc404..c92aca3aac1d1 100644 --- a/DQMServices/FwkIO/test/read_write_merged_file1_file3_file2_filterOnRun1_cfg.py +++ b/DQMServices/FwkIO/test/read_write_merged_file1_file3_file2_filterOnRun1_cfg.py @@ -11,5 +11,5 @@ process.e = cms.EndPath(process.out) -process.add_(cms.Service("DQMStore")) +process.add_(cms.Service("DQMStore", forceResetOnBeginLumi = cms.untracked.bool(True))) From 4bc1f8630bce8bd8fc20e19c1ab7ae183cc20149 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Wed, 10 Apr 2019 17:02:05 +0200 Subject: [PATCH 553/686] removing unnecessary usage of shared_ptr for three variables in EvFOutputModule. --- EventFilter/Utilities/interface/EvFOutputModule.h | 4 ++-- EventFilter/Utilities/src/EvFOutputModule.cc | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/EventFilter/Utilities/interface/EvFOutputModule.h b/EventFilter/Utilities/interface/EvFOutputModule.h index 934be82cd7c3e..d32a2e84245a9 100644 --- a/EventFilter/Utilities/interface/EvFOutputModule.h +++ b/EventFilter/Utilities/interface/EvFOutputModule.h @@ -51,7 +51,7 @@ namespace evf { private: std::string filePath_; unsigned long accepted_; - edm::propagate_const> stream_writer_events_; + edm::propagate_const> stream_writer_events_; }; @@ -108,7 +108,7 @@ namespace evf { evf::FastMonitoringService *fms_; - std::shared_ptr jsonWriter_; + std::unique_ptr jsonWriter_; }; //end-of-class-def diff --git a/EventFilter/Utilities/src/EvFOutputModule.cc b/EventFilter/Utilities/src/EvFOutputModule.cc index 7451bc50ad2df..d50c8f5ac8716 100644 --- a/EventFilter/Utilities/src/EvFOutputModule.cc +++ b/EventFilter/Utilities/src/EvFOutputModule.cc @@ -145,14 +145,13 @@ namespace evf { EvFOutputModule::beginRun(edm::RunForOutput const& run) { //create run Cache holding JSON file writer and variables - jsonWriter_ = std::make_shared(ps_,&keptProducts()[edm::InEvent],streamLabel_); + jsonWriter_ = std::make_unique(ps_,&keptProducts()[edm::InEvent],streamLabel_); //output INI file (non-const). This doesn't require globalBeginRun to be finished const std::string openIniFileName = edm::Service()->getOpenInitFilePath(streamLabel_); edm::LogInfo("EvFOutputModule") << "beginRun init stream -: " << openIniFileName; - std::shared_ptr stream_writer_preamble; - stream_writer_preamble.reset(new StreamerOutputFile(openIniFileName)); + StreamerOutputFile stream_writer_preamble(openIniFileName); uint32 preamble_adler32 = 1; edm::BranchIDLists const* bidlPtr = branchIDLists(); @@ -164,9 +163,9 @@ namespace evf { InitMsgView view(init_message->startAddress()); //output header - stream_writer_preamble->write(view); - preamble_adler32 = stream_writer_preamble->adler32(); - stream_writer_preamble.reset(); + stream_writer_preamble.write(view); + preamble_adler32 = stream_writer_preamble.adler32(); + stream_writer_preamble.close(); struct stat istat; stat(openIniFileName.c_str(), &istat); From c117a7e654a4ce69482b74d03494e4bd200f7668 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Mar 2019 03:32:46 +0100 Subject: [PATCH 554/686] Tight muon hit matching --- Validation/MuonHits/BuildFile.xml | 7 +- .../MuonHits/interface/CSCSimHitMatcher.h | 80 ++++ .../MuonHits/interface/DTSimHitMatcher.h | 82 ++++ .../MuonHits/interface/GEMSimHitMatcher.h | 93 +++++ .../MuonHits/interface/ME0SimHitMatcher.h | 89 ++++ Validation/MuonHits/interface/MuonHitHelper.h | 58 +++ .../MuonHits/interface/MuonSimHitMatcher.h | 112 +++++ .../MuonHits/interface/RPCSimHitMatcher.h | 53 +++ Validation/MuonHits/plugins/BuildFile.xml | 13 + .../MuonSimHitsValidAnalyzer.cc | 0 .../MuonSimHitsValidAnalyzer.h | 4 +- .../MuonHits/{src => plugins}/SealModule.cc | 3 - .../MuonHits/python/muonSimHitMatcherPSet.py | 45 ++ Validation/MuonHits/src/CSCSimHitMatcher.cc | 380 +++++++++++++++++ Validation/MuonHits/src/DTSimHitMatcher.cc | 387 ++++++++++++++++++ Validation/MuonHits/src/GEMSimHitMatcher.cc | 320 +++++++++++++++ Validation/MuonHits/src/ME0SimHitMatcher.cc | 224 ++++++++++ Validation/MuonHits/src/MuonHitHelper.cc | 181 ++++++++ Validation/MuonHits/src/MuonSimHitMatcher.cc | 151 +++++++ Validation/MuonHits/src/RPCSimHitMatcher.cc | 171 ++++++++ 20 files changed, 2447 insertions(+), 6 deletions(-) create mode 100644 Validation/MuonHits/interface/CSCSimHitMatcher.h create mode 100644 Validation/MuonHits/interface/DTSimHitMatcher.h create mode 100644 Validation/MuonHits/interface/GEMSimHitMatcher.h create mode 100644 Validation/MuonHits/interface/ME0SimHitMatcher.h create mode 100644 Validation/MuonHits/interface/MuonHitHelper.h create mode 100644 Validation/MuonHits/interface/MuonSimHitMatcher.h create mode 100644 Validation/MuonHits/interface/RPCSimHitMatcher.h create mode 100644 Validation/MuonHits/plugins/BuildFile.xml rename Validation/MuonHits/{src => plugins}/MuonSimHitsValidAnalyzer.cc (100%) rename Validation/MuonHits/{src => plugins}/MuonSimHitsValidAnalyzer.h (97%) rename Validation/MuonHits/{src => plugins}/SealModule.cc (98%) create mode 100644 Validation/MuonHits/python/muonSimHitMatcherPSet.py create mode 100644 Validation/MuonHits/src/CSCSimHitMatcher.cc create mode 100644 Validation/MuonHits/src/DTSimHitMatcher.cc create mode 100644 Validation/MuonHits/src/GEMSimHitMatcher.cc create mode 100644 Validation/MuonHits/src/ME0SimHitMatcher.cc create mode 100644 Validation/MuonHits/src/MuonHitHelper.cc create mode 100644 Validation/MuonHits/src/MuonSimHitMatcher.cc create mode 100644 Validation/MuonHits/src/RPCSimHitMatcher.cc diff --git a/Validation/MuonHits/BuildFile.xml b/Validation/MuonHits/BuildFile.xml index 8896987508d9c..9dd05125a275c 100644 --- a/Validation/MuonHits/BuildFile.xml +++ b/Validation/MuonHits/BuildFile.xml @@ -10,7 +10,12 @@ + + + - + + + diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h new file mode 100644 index 0000000000000..b452652905997 --- /dev/null +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -0,0 +1,80 @@ +#ifndef Validation_MuonHits_CSCSimHitMatcher_h +#define Validation_MuonHits_CSCSimHitMatcher_h + +/**\class CSCSimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" + +class CSCSimHitMatcher : public MuonSimHitMatcher +{ +public: + + // constructor + CSCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~CSCSimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // partitions' detIds with SimHits + std::set detIds(int type = 0) const; + + // chamber detIds with SimHits + std::set chamberIds(int type = 0) const; + + // CSC station detIds with SimHits + std::set chamberIdsStation(int station) const; + + // was there a hit in a particular DT/CSC station? + bool hitStation(int, int) const; + + // number of stations with hits in at least X layers + int nStations(int nl=4) const; + + // #layers with hits + int nLayersWithHitsInChamber(unsigned int) const; + + // How many CSC chambers with minimum number of layer with simhits did this simtrack get? + int nCoincidenceChambers(int min_n_layers = 4) const; + + // calculated the fitted position in a given layer for CSC simhits in a chamber + GlobalPoint simHitPositionKeyLayer(unsigned int chamberid) const; + + // local bending in a CSC chamber + float LocalBendingInChamber(unsigned int detid) const; + + // calculate average strip (strip for GEM/ME0, half-strip for CSC) number for a provided collection of simhits + float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; + + // calculate average wg number for a provided collection of simhits (for CSC) + float simHitsMeanWG(const edm::PSimHitContainer& sim_hits) const; + + void chamberIdsToString(const std::set& set) const; + + // calculate the average position at the second station + GlobalPoint simHitsMeanPositionStation(int n) const; + + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC + std::set hitWiregroupsInDetId(unsigned int, int margin_n_wg = 0) const; // CSC + + void camberIdsToString(const std::set&) const; + +private: + + void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& csc_hits); + + edm::ESHandle csc_geom_; +}; + +#endif diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h new file mode 100644 index 0000000000000..6015239906b91 --- /dev/null +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -0,0 +1,82 @@ +#ifndef Validation_MuonHits_DTSimHitMatcher_h +#define Validation_MuonHits_DTSimHitMatcher_h + +/**\class DTSimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" +#include "Geometry/DTGeometry/interface/DTGeometry.h" + +class DTSimHitMatcher : public MuonSimHitMatcher +{ +public: + + // constructor + DTSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~DTSimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // partitions' detIds with SimHits + std::set detIds(int type = 0) const; + + // chamber detIds with SimHits + std::set chamberIds(int type = 0) const; + + // DT station detIds with SimHits + std::set chamberIdsStation(int station) const; + + // DT layer detIds with SimHits + std::set layerIds() const; + + // DT super layer detIds with SimHits + std::set superlayerIds() const; + + // was there a hit in a particular DT/CSC station? + bool hitStation(int, int, int) const; + + // number of stations with hits in at least X layers + int nStations(int nsl=1, int nl=3) const; + + // access to DT hits + int nCellsWithHitsInLayer(unsigned int) const; + int nLayersWithHitsInSuperLayer(unsigned int) const; + int nSuperLayersWithHitsInChamber(unsigned int) const; + int nLayersWithHitsInChamber(unsigned int) const; + const edm::PSimHitContainer& hitsInLayer(unsigned int) const; + const edm::PSimHitContainer& hitsInSuperLayer(unsigned int) const; + const edm::PSimHitContainer& hitsInChamber(unsigned int) const; + + // calculate average wg number for a provided collection of simhits (for DT) + float simHitsMeanWire(const edm::PSimHitContainer& sim_hits) const; + + // calculate the average position at the second station + GlobalPoint simHitsMeanPositionStation(int n) const; + + std::set hitWiresInDTLayerId(unsigned int, int margin_n_wires = 0) const; // DT + std::set hitWiresInDTSuperLayerId(unsigned int, int margin_n_wires = 0) const; // DT + std::set hitWiresInDTChamberId(unsigned int, int margin_n_wires = 0) const; // DT + + void dtChamberIdsToString(const std::set&) const; + +private: + + void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& hits); + + std::map layer_to_hits_; + std::map superlayer_to_hits_; + + edm::ESHandle dt_geom_; +}; + +#endif diff --git a/Validation/MuonHits/interface/GEMSimHitMatcher.h b/Validation/MuonHits/interface/GEMSimHitMatcher.h new file mode 100644 index 0000000000000..6172e1a1279e9 --- /dev/null +++ b/Validation/MuonHits/interface/GEMSimHitMatcher.h @@ -0,0 +1,93 @@ +#ifndef Validation_MuonHits_GEMSimHitMatcher_h +#define Validation_MuonHits_GEMSimHitMatcher_h + +/**\class GEMSimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" + +class GEMSimHitMatcher : public MuonSimHitMatcher +{ +public: + + // constructor + GEMSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~GEMSimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // partitions' detIds with SimHits + std::set detIds(int gem_type = MuonHitHelper::GEM_ALL) const; + + // chamber detIds with SimHits + std::set chamberIds(int gem_type = MuonHitHelper::GEM_ALL) const; + + // GEM detid's with hits in 2 layers of coincidence pads + // those are layer==1 only detid's + std::set detIdsCoincidences() const; + + // GEM superchamber detIds with SimHits + std::set superChamberIds() const; + + // GEM superchamber detIds with SimHits 2 layers of coincidence pads + std::set superChamberIdsCoincidences() const; + + // simhits from a particular partition (GEM)/layer (CSC)/ME0, chamber or superchamber + const edm::PSimHitContainer& hitsInSuperChamber(unsigned int) const; + + // was there a hit in a particular station? + bool hitStation(int, int) const; + + // number of stations with hits in at least X layers + int nStations(int nl=2) const; + + // #layers with hits + // for CSC: "super-chamber" means chamber + int nLayersWithHitsInSuperChamber(unsigned int) const; + + // How many pads with simhits in GEM did this simtrack get? + int nPadsWithHits() const; + + // How many coincidence pads with simhits in GEM did this simtrack get? + int nCoincidencePadsWithHits() const; + + // transverse position in GEM + float simHitsGEMCentralPosition(const edm::PSimHitContainer& sim_hits) const; + + // calculate average strip number for a provided collection of simhits + float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; + + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; + std::set hitPadsInDetId(unsigned int) const; + std::set hitCoPadsInDetId(unsigned int) const; + + // what unique partitions numbers were hit by this simtrack? + std::set hitPartitions() const; + +private: + + void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& hits); + + edm::ESHandle gem_geom_; + + std::map superchamber_to_hits_; + + // detids with hits in pads + std::map > detids_to_pads_; + + // detids with hits in 2-layer pad coincidences + std::map > detids_to_copads_; +}; + +#endif diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h new file mode 100644 index 0000000000000..21669b44ae150 --- /dev/null +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -0,0 +1,89 @@ +#ifndef Validation_MuonHits_ME0SimHitMatcher_h +#define Validation_MuonHits_ME0SimHitMatcher_h + +/**\class ME0SimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" + +class ME0SimHitMatcher : public MuonSimHitMatcher +{ +public: + + // constructor + ME0SimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~ME0SimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // partitions' detIds with SimHits + std::set detIds() const; + + // chamber detIds with SimHits + std::set chamberIds() const; + + // simhits from a particular partition, chamber + const edm::PSimHitContainer& hitsInSuperChamber(unsigned int) const; + + // detid's with hits in 2 layers of coincidence pads + std::set detIdsCoincidences(int min_n_layers = 2) const; + + // ME0 superchamber detIds with SimHits + std::set superChamberIds() const; + + // ME0 superchamber detIds with SimHits >=4 layers of coincidence pads + std::set superChamberIdsCoincidences(int min_n_layers = 2) const; + + // #layers with hits + int nLayersWithHitsInSuperChamber(unsigned int) const; + + float simHitsCentralPosition(const edm::PSimHitContainer& sim_hits) const; + + // How many pads with simhits in GEM did this simtrack get? + int nPadsWithHits() const; + + // How many coincidence pads with simhits in GEM did this simtrack get? + int nCoincidencePadsWithHits() const; + + // How many ME0 chambers with minimum number of layer with simhits did this simtrack get? + int nCoincidenceChambers(int min_n_layers = 4) const; + + // calculated the fitted position in a given layer for CSC simhits in a chamber + GlobalPoint simHitPositionKeyLayer(unsigned int chamberid) const; + + // calculate average strip (strip for GEM/ME0, half-strip for CSC) number for a provided collection of simhits + float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; + + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC + std::set hitPadsInDetId(unsigned int) const; // GEM + + // what unique partitions numbers were hit by this simtrack? + std::set hitPartitions() const; // GEM + +private: + + void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& me0_hits); + + edm::ESHandle me0_geom_; + + // detids with hits in pads + std::map > detids_to_pads_; + + // detids with hits in 2-layer pad coincidences + std::map > detids_to_copads_; + + std::map superChamber_to_hits_; +}; + +#endif diff --git a/Validation/MuonHits/interface/MuonHitHelper.h b/Validation/MuonHits/interface/MuonHitHelper.h new file mode 100644 index 0000000000000..c02f004cbfe76 --- /dev/null +++ b/Validation/MuonHits/interface/MuonHitHelper.h @@ -0,0 +1,58 @@ +#ifndef Validation_MuonHits_MuonHitHelper_h +#define Validation_MuonHits_MuonHitHelper_h + +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" + +class MuonHitHelper +{ + public: + + /// CSC chamber types, according to CSCDetId::iChamberType() + enum CSCType {CSC_ALL = 0, CSC_ME11, + CSC_ME1a, CSC_ME1b, CSC_ME12, CSC_ME13, CSC_ME21, + CSC_ME22, CSC_ME31, CSC_ME32, CSC_ME41, CSC_ME42}; + + /// GEM chamber types + enum GEMType {GEM_ALL = 0, GEM_ME11, GEM_ME21}; + + /// RPC endcap chamber types + enum RPCType {RPC_ALL = 0, + RPC_ME12, RPC_ME13, RPC_ME22, RPC_ME23, RPC_ME31, + RPC_ME32, RPC_ME33, RPC_ME41, RPC_ME42, RPC_ME43, + RPC_MB01, RPC_MB02, RPC_MB03, RPC_MB04, + RPC_MB11p, RPC_MB12p, RPC_MB13p, RPC_MB14p, + RPC_MB21p, RPC_MB22p, RPC_MB23p, RPC_MB24p, + RPC_MB11n, RPC_MB12n, RPC_MB13n, RPC_MB14n, + RPC_MB21n, RPC_MB22n, RPC_MB23n, RPC_MB24n}; + + /// DT chamber types + enum DTType {DT_ALL = 0, + DT_MB01, DT_MB02, DT_MB03, DT_MB04, + DT_MB11p, DT_MB12p, DT_MB13p, DT_MB14p, + DT_MB21p, DT_MB22p, DT_MB23p, DT_MB24p, + DT_MB11n, DT_MB12n, DT_MB13n, DT_MB14n, + DT_MB21n, DT_MB22n, DT_MB23n, DT_MB24n}; + + /// check detid type + static bool isDT(unsigned int detId); + static bool isGEM(unsigned int detId); + static bool isCSC(unsigned int detId); + static bool isRPC(unsigned int detId); + static bool isME0(unsigned int detId); + + // return MuonType for a particular DetId + static int toGEMType(int st, int ri); + static int toRPCType(int re, int st, int ri); + static int toDTType(int wh, int st); + static int toCSCType(int st, int ri); + + // get chamber number + static int chamber(const DetId& id); +}; + +#endif diff --git a/Validation/MuonHits/interface/MuonSimHitMatcher.h b/Validation/MuonHits/interface/MuonSimHitMatcher.h new file mode 100644 index 0000000000000..e111b72cc5747 --- /dev/null +++ b/Validation/MuonHits/interface/MuonSimHitMatcher.h @@ -0,0 +1,112 @@ +#ifndef Validation_MuonHits_MuonSimHitMatcher_h +#define Validation_MuonHits_MuonSimHitMatcher_h + +/**\class MuonSimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" +#include "Validation/MuonHits/interface/MuonHitHelper.h" +#include "DataFormats/Math/interface/deltaPhi.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" + +#include +#include +#include + +class MuonSimHitMatcher +{ + public: + + // constructor + MuonSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~MuonSimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // access to all the Muon SimHits (use MuonSubdetId::SubSystem) + const edm::PSimHitContainer& simHits(int) const; + + // partitions' detIds with SimHits + std::set detIds(int type = 0) const; + + // chamber detIds with SimHits + std::set chamberIds(int type = 0) const; + + // simhits from a particular partition, chamber + const edm::PSimHitContainer& hitsInDetId(unsigned int) const; + const edm::PSimHitContainer& hitsInChamber(unsigned int) const; + + // calculate Global average position for a provided collection of simhits + GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer& sim_hits) const; + + // calculate Global average momentum for a provided collection of simhits in CSC + GlobalVector simHitsMeanMomentum(const edm::PSimHitContainer& sim_hits) const; + + // calculate the average position at the second station + GlobalPoint simHitsMeanPositionStation(int n) const; + +protected: + + std::vector + getIdsOfSimTrackShower(unsigned trk_id, + const edm::SimTrackContainer& simTracks, + const edm::SimVertexContainer& simVertices); + + bool verboseSimTrack_; + bool simMuOnly_; + bool discardEleHits_; + bool verbose_; + bool hasGeometry_; + + const TrackingGeometry* geometry_; + + edm::EDGetTokenT simVertexInput_; + edm::EDGetTokenT simTrackInput_; + edm::EDGetTokenT simHitInput_; + + edm::Handle simTracksH_; + edm::Handle simVerticesH_; + edm::Handle simHitsH_; + + edm::SimTrackContainer simTracks_; + edm::SimVertexContainer simVertices_; + // input collection + edm::PSimHitContainer simHits_; + + std::vector track_ids_; + std::map trkid_to_index_; + + edm::PSimHitContainer no_hits_; + + // selected hits + edm::PSimHitContainer hits_; + std::map detid_to_hits_; + std::map chamber_to_hits_; + + edm::ParameterSet simHitPSet_; +}; + +#endif diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h new file mode 100644 index 0000000000000..3be92034ab088 --- /dev/null +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -0,0 +1,53 @@ +#ifndef Validation_MuonHits_RPCSimHitMatcher_h +#define Validation_MuonHits_RPCSimHitMatcher_h + +/**\class RPCSimHitMatcher + + Description: Matching of muon SimHit to SimTrack + + Author: Sven Dildick (TAMU), Tao Huang (TAMU) +*/ + +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" + +class RPCSimHitMatcher : public MuonSimHitMatcher +{ + public: + + // constructor + RPCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + + // destructor + ~RPCSimHitMatcher() {} + + // initialize the event + void init(const edm::Event& e, const edm::EventSetup& eventSetup); + + // do the matching + void match(const SimTrack& t, const SimVertex& v); + + // partitions' detIds with SimHits + std::set detIds(int type = 0) const; + + // chamber detIds with SimHits + std::set chamberIds(int type = 0) const; + + bool hitStation(int st) const; + + // number of stations with hits in at least X layers + int nStations() const; + + // calculate average strip number for a provided collection of simhits + float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; + + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC + +private: + + void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& rpc_hits); + + edm::ESHandle rpc_geom_; +}; + +#endif diff --git a/Validation/MuonHits/plugins/BuildFile.xml b/Validation/MuonHits/plugins/BuildFile.xml new file mode 100644 index 0000000000000..93dd4cd7147ac --- /dev/null +++ b/Validation/MuonHits/plugins/BuildFile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Validation/MuonHits/src/MuonSimHitsValidAnalyzer.cc b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc similarity index 100% rename from Validation/MuonHits/src/MuonSimHitsValidAnalyzer.cc rename to Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc diff --git a/Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h similarity index 97% rename from Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h rename to Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h index 8f6c3426d12f8..e4e0fa4d9346e 100644 --- a/Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h +++ b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h @@ -1,5 +1,5 @@ -#ifndef MuonSimHitsValidAnalyzer_h -#define MuonSimHitsValidAnalyzer_h +#ifndef Validation_MuonHits_MuonSimHitsValidAnalyzer_h +#define Validation_MuonHits_MuonSimHitsValidAnalyzer_h /// framework & common header files #include "FWCore/Framework/interface/Frameworkfwd.h" diff --git a/Validation/MuonHits/src/SealModule.cc b/Validation/MuonHits/plugins/SealModule.cc similarity index 98% rename from Validation/MuonHits/src/SealModule.cc rename to Validation/MuonHits/plugins/SealModule.cc index d1fc4046e5cce..81be597a8556b 100644 --- a/Validation/MuonHits/src/SealModule.cc +++ b/Validation/MuonHits/plugins/SealModule.cc @@ -3,7 +3,4 @@ #include "DQMServices/Core/interface/DQMStore.h" #include "Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h" - - - DEFINE_FWK_MODULE(MuonSimHitsValidAnalyzer); diff --git a/Validation/MuonHits/python/muonSimHitMatcherPSet.py b/Validation/MuonHits/python/muonSimHitMatcherPSet.py new file mode 100644 index 0000000000000..fed85cfc078b8 --- /dev/null +++ b/Validation/MuonHits/python/muonSimHitMatcherPSet.py @@ -0,0 +1,45 @@ +import FWCore.ParameterSet.Config as cms + +muonSimHitMatcherPSet = cms.PSet( + simTrack = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits"), + ), + simVertex = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits"), + ), + gemSimHit = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits", "MuonGEMHits"), + simMuOnly = cms.bool(True), + discardEleHits = cms.bool(True), + ), + me0SimHit = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits", "MuonME0Hits"), + simMuOnly = cms.bool(True), + discardEleHits = cms.bool(True), + minNHitsChamber = cms.int32(4), + ), + rpcSimHit = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits", "MuonRPCHits"), + simMuOnly = cms.bool(True), + discardEleHits = cms.bool(True), + ), + cscSimHit = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits", "MuonCSCHits"), + simMuOnly = cms.bool(True), + discardEleHits = cms.bool(True), + minNHitsChamber = cms.int32(4), + ), + dtSimHit = cms.PSet( + verbose = cms.int32(1), + inputTag = cms.InputTag("g4SimHits", "MuonDTHits"), + simMuOnly = cms.bool(True), + discardEleHits = cms.bool(True), + minNHitsChamber = cms.int32(4), + ) +) diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc new file mode 100644 index 0000000000000..5dfdd8dc4340e --- /dev/null +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -0,0 +1,380 @@ +#include "Validation/MuonHits/interface/CSCSimHitMatcher.h" + +using namespace std; + +CSCSimHitMatcher::CSCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) + : MuonSimHitMatcher(ps, std::move(iC)) +{ + simHitPSet_ = ps.getParameterSet("cscSimHit"); + verbose_ = simHitPSet_.getParameter("verbose"); + simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); + discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); + + simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); +} + +/// initialize the event +void CSCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + iSetup.get().get(csc_geom_); + if (csc_geom_.isValid()) { + geometry_ = &*csc_geom_; + } else { + hasGeometry_ = false; + std::cout << "+++ Info: CSC geometry is unavailable. +++\n"; + } + MuonSimHitMatcher::init(iEvent, iSetup); +} + +/// do the matching +void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + MuonSimHitMatcher::match(track, vertex); + + if (hasGeometry_) { + + matchSimHitsToSimTrack(track_ids_, simHits_); + + if (verbose_) { + cout<<"nTrackIds "<(cout, " ")); cout< track_ids, const edm::PSimHitContainer& hits) +{ + for (const auto& track_id: track_ids) + { + for (const auto& h: hits) + { + if (h.trackId() != track_id) continue; + int pdgid = h.particleType(); + if (simMuOnly_ && std::abs(pdgid) != 13) continue; + // discard electron hits in the CSC chambers + if (discardEleHits_ && pdgid == 11) continue; + + const CSCDetId& layer_id( h.detUnitId() ); + hits_.push_back(h); + detid_to_hits_[ h.detUnitId() ].push_back(h); + chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + } + } +} + + +std::set +CSCSimHitMatcher::detIds(int csc_type) const +{ + std::set result; + for (const auto& p: detid_to_hits_) + { + const auto& id = p.first; + if (csc_type > 0) + { + CSCDetId detId(id); + if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) continue; + } + result.insert(id); + } + return result; +} + + +std::set +CSCSimHitMatcher::chamberIds(int csc_type) const +{ + std::set result; + for (const auto& p: chamber_to_hits_) + { + const auto& id = p.first; + if (csc_type > 0) + { + CSCDetId detId(id); + if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) continue; + } + result.insert(id); + } + return result; +} + + +int +CSCSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const +{ + set layers_with_hits; + for (const auto& h: MuonSimHitMatcher::hitsInChamber(detid)) { + const CSCDetId& idd(h.detUnitId()); + layers_with_hits.insert(idd.layer()); + } + return layers_with_hits.size(); +} + + +bool +CSCSimHitMatcher::hitStation(int st, int nlayers) const +{ + int nst=0; + for(const auto& ddt: chamberIds()) { + + const CSCDetId id(ddt); + int ri(id.ring()); + if (id.station()!=st) continue; + + // ME1/a case - check the ME1/b chamber + if (st==1 and ri==4) { + CSCDetId idME1b(id.endcap(), id.station(), 1, id.chamber(), 0); + const int nl1a(nLayersWithHitsInChamber(id.rawId())); + const int nl1b(nLayersWithHitsInChamber(idME1b.rawId())); + if (nl1a + nl1b < nlayers) continue; + ++nst; + } + // ME1/b case - check the ME1/a chamber + else if (st==1 and ri==1) { + CSCDetId idME1a(id.endcap(), id.station(), 4, id.chamber(), 0); + const int nl1a(nLayersWithHitsInChamber(idME1a.rawId())); + const int nl1b(nLayersWithHitsInChamber(id.rawId())); + if (nl1a + nl1b < nlayers) continue; + ++nst; + } + // default case + else { + const int nl(nLayersWithHitsInChamber(id.rawId())); + if (nl < nlayers) continue; + ++nst; + } + } + return nst; +} + +int +CSCSimHitMatcher::nStations(int nlayers) const +{ + return (hitStation(1, nlayers) + + hitStation(2, nlayers) + + hitStation(3, nlayers) + + hitStation(4, nlayers)); +} + +float +CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const +{ + const CSCDetId cscid(detid); + if (nLayersWithHitsInChamber(detid)<6) return -100; + float phi_layer1=-10; + float phi_layer6=10; + + if (cscid.station()==1 and (cscid.ring()==1 or cscid.ring()==4)){ + // phi in layer 1 + const CSCDetId cscid1a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), 1); + const CSCDetId cscid1b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), 1); + const edm::PSimHitContainer& hits1a = MuonSimHitMatcher::hitsInDetId(cscid1a.rawId()); + const edm::PSimHitContainer& hits1b = MuonSimHitMatcher::hitsInDetId(cscid1b.rawId()); + const GlobalPoint& gp1a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1a.rawId())); + const GlobalPoint& gp1b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1b.rawId())); + if (hits1a.size()>0 and hits1b.size()>0) + phi_layer1 = (gp1a.phi()+gp1b.phi())/2.0; + else if (hits1a.size()>0) phi_layer1 = gp1a.phi(); + else if (hits1b.size()>0) phi_layer1 = gp1b.phi(); + else std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; + + // phi in layer 6 + const CSCDetId cscid6a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), 6); + const CSCDetId cscid6b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), 6); + const edm::PSimHitContainer& hits6a = MuonSimHitMatcher::hitsInDetId(cscid6a.rawId()); + const edm::PSimHitContainer& hits6b = MuonSimHitMatcher::hitsInDetId(cscid6b.rawId()); + const GlobalPoint& gp6a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6a.rawId())); + const GlobalPoint& gp6b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6b.rawId())); + if (hits6a.size()>0 and hits6b.size()>0) + phi_layer6 = (gp6a.phi()+gp6b.phi())/2.0; + else if (hits6a.size()>0) phi_layer6 = gp6a.phi(); + else if (hits6b.size()>0) phi_layer6 = gp6b.phi(); + else std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; + + + } + else { + // phi in layer 1 + const CSCDetId cscid1(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 1); + const edm::PSimHitContainer& hits1 = MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); + if (hits1.size()==0) std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; + const GlobalPoint& gp1 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); + phi_layer1 = gp1.phi(); + + // phi in layer 6 + const CSCDetId cscid6(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 6); + const edm::PSimHitContainer& hits6 = MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); + if (hits6.size()==0) std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; + const GlobalPoint& gp6 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); + phi_layer6 = gp6.phi(); + } + return deltaPhi(phi_layer6,phi_layer1); +} + + +float +CSCSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + float s; + const auto& d = h.detUnitId(); + s = dynamic_cast(geometry_)->layer(d)->geometry()->strip(lp); + // convert to half-strip: + s *= 2.; + sums += s; + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + + +float +CSCSimHitMatcher::simHitsMeanWG(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) { + const LocalPoint& lp = h.entryPoint(); + float s; + const auto& d = h.detUnitId(); + // find nearest wire + const auto& layerG(dynamic_cast(geometry_)->layer(d)->geometry()); + int nearestWire(layerG->nearestWire(lp)); + // then find the corresponding wire group + s = layerG->wireGroup(nearestWire); + sums += s; + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + + + + +std::set +CSCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const +{ + set result; + const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); + CSCDetId id(detid); + int max_nstrips = dynamic_cast(geometry_)->layer(id)->geometry()->numberOfStrips(); + for (const auto& h: simhits) { + const LocalPoint& lp = h.entryPoint(); + int central_strip = dynamic_cast(geometry_)->layer(id)->geometry()->nearestStrip(lp); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } + return result; +} + + +std::set +CSCSimHitMatcher::hitWiregroupsInDetId(unsigned int detid, int margin_n_wg) const +{ + set result; + const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); + CSCDetId id(detid); + int max_n_wg = dynamic_cast(geometry_)->layer(id)->geometry()->numberOfWireGroups(); + for (const auto& h: simhits) { + const LocalPoint& lp = h.entryPoint(); + const auto& layer_geo = dynamic_cast(geometry_)->layer(id)->geometry(); + int central_wg = layer_geo->wireGroup(layer_geo->nearestWire(lp)); + int wg_min = central_wg - margin_n_wg; + wg_min = (wg_min > 0) ? wg_min : 1; + int wg_max = central_wg + margin_n_wg; + wg_max = (wg_max <= max_n_wg) ? wg_max : max_n_wg; + for (int wg = wg_min; wg <= wg_max; ++wg) result.insert(wg); + } + return result; +} + +int +CSCSimHitMatcher::nCoincidenceChambers(int min_n_layers) const +{ + int result = 0; + const auto& chamber_ids = chamberIds(); + for (const auto& id: chamber_ids) + { + if (nLayersWithHitsInChamber(id) >= min_n_layers) result += 1; + } + return result; +} + +void +CSCSimHitMatcher::chamberIdsToString(const std::set& set) const +{ + for (const auto& p: set) { + CSCDetId detId(p); + std::cout << " " << detId << "\n"; + } +} + + +std::set +CSCSimHitMatcher::chamberIdsStation(int station) const +{ + set result; + switch(station){ + case 1: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME1a)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME1b)); + const auto& p3(chamberIds(MuonHitHelper::CSC_ME12)); + const auto& p4(chamberIds(MuonHitHelper::CSC_ME13)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + result.insert(p3.begin(),p3.end()); + result.insert(p4.begin(),p4.end()); + break; + } + case 2: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME21)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME22)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + break; + } + case 3: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME31)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME32)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + break; + } + case 4: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME41)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME42)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + break; + } + }; + return result; +} + + diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc new file mode 100644 index 0000000000000..53e607e0c1905 --- /dev/null +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -0,0 +1,387 @@ +#include "Validation/MuonHits/interface/DTSimHitMatcher.h" + +using namespace std; + +DTSimHitMatcher::DTSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) + : MuonSimHitMatcher(ps, std::move(iC)) +{ + simHitPSet_ = ps.getParameterSet("dtSimHit"); + verbose_ = simHitPSet_.getParameter("verbose"); + simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); + discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); + + simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); +} + +/// initialize the event +void DTSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + iSetup.get().get(dt_geom_); + if (dt_geom_.isValid()) { + geometry_ = &*dt_geom_; + } else { + hasGeometry_ = false; + std::cout << "+++ Info: DT geometry is unavailable. +++\n"; + } + MuonSimHitMatcher::init(iEvent, iSetup); +} + +/// do the matching +void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + MuonSimHitMatcher::match(track, vertex); + + if (hasGeometry_) { + + matchSimHitsToSimTrack(track_ids_, simHits_); + + if (verbose_) { + cout<<"nTrackIds "< track_ids, const edm::PSimHitContainer& dt_hits) +{ + for (const auto& track_id: track_ids) + { + for (const auto& h: dt_hits) + { + if (h.trackId() != track_id) continue; + int pdgid = h.particleType(); + if (simMuOnly_ && std::abs(pdgid) != 13) continue; + // discard electron hits in the DT chambers + if (discardEleHits_ && pdgid == 11) continue; + + const DTWireId layer_id( h.detUnitId() ); + detid_to_hits_[ h.detUnitId() ].push_back(h); + hits_.push_back(h); + layer_to_hits_ [ layer_id.layerId().rawId() ].push_back(h); + superlayer_to_hits_ [ layer_id.superlayerId().rawId() ].push_back(h); + chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + } + } +} + +std::set +DTSimHitMatcher::detIds(int dt_type) const +{ + std::set result; + for (const auto& p: detid_to_hits_) + { + const auto& id = p.first; + if (dt_type > 0) + { + DTWireId detId(id); + if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) continue; + } + result.insert(id); + } + return result; +} + + +std::set +DTSimHitMatcher::chamberIds(int dt_type) const +{ + std::set result; + for (const auto& p: chamber_to_hits_) + { + const auto& id = p.first; + if (dt_type > 0) + { + DTChamberId detId(id); + if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) continue; + } + result.insert(id); + } + return result; +} + +std::set +DTSimHitMatcher::layerIds() const +{ + std::set result; + for (const auto& p: layer_to_hits_) result.insert(p.first); + return result; +} + +std::set +DTSimHitMatcher::superlayerIds() const +{ + std::set result; + for (const auto& p: superlayer_to_hits_) result.insert(p.first); + return result; +} + +const edm::PSimHitContainer& +DTSimHitMatcher::hitsInLayer(unsigned int detid) const +{ + if (!MuonHitHelper::isDT(detid)) return no_hits_; + + const DTWireId id(detid); + if (layer_to_hits_.find(id.layerId().rawId()) == layer_to_hits_.end()) return no_hits_; + return layer_to_hits_.at(id.layerId().rawId()); +} + +const edm::PSimHitContainer& +DTSimHitMatcher::hitsInSuperLayer(unsigned int detid) const +{ + if (!MuonHitHelper::isDT(detid)) return no_hits_; + + const DTWireId id(detid); + if (superlayer_to_hits_.find(id.superlayerId().rawId()) == superlayer_to_hits_.end()) return no_hits_; + return superlayer_to_hits_.at(id.superlayerId().rawId()); +} + +const edm::PSimHitContainer& +DTSimHitMatcher::hitsInChamber(unsigned int detid) const +{ + if (!MuonHitHelper::isDT(detid)) return no_hits_; + + const DTWireId id(detid); + if (chamber_to_hits_.find(id.chamberId().rawId()) == chamber_to_hits_.end()) return no_hits_; + return chamber_to_hits_.at(id.chamberId().rawId()); +} + +bool +DTSimHitMatcher::hitStation(int st, int nsuperlayers, int nlayers) const +{ + int nst=0; + for(const auto& ddt: chamberIds()) { + + const DTChamberId id(ddt); + if (id.station()!=st) continue; + + // require at least 1 superlayer + const int nsl(nSuperLayersWithHitsInChamber(id.rawId())); + if (nsl < nsuperlayers) continue; + + // require at least 3 layers hit per chamber + const int nl(nLayersWithHitsInChamber(id.rawId())); + if (nl < nlayers) continue; + ++nst; + } + return nst; +} + +int +DTSimHitMatcher::nStations(int nsuperlayers, int nlayers) const +{ + return (hitStation(1, nsuperlayers, nlayers) + + hitStation(2, nsuperlayers, nlayers) + + hitStation(3, nsuperlayers, nlayers) + + hitStation(4, nsuperlayers, nlayers)); +} + + +int +DTSimHitMatcher::nCellsWithHitsInLayer(unsigned int detid) const +{ + set layers_with_hits; + const auto& hits = hitsInLayer(detid); + for (const auto& h: hits) { + if (MuonHitHelper::isDT(detid)) { + const DTWireId idd(h.detUnitId()); + layers_with_hits.insert(idd.wire()); + } + } + return layers_with_hits.size(); +} + +int +DTSimHitMatcher::nLayersWithHitsInSuperLayer(unsigned int detid) const +{ + set layers_with_hits; + const auto& hits = hitsInSuperLayer(detid); + for (const auto& h: hits) { + if (MuonHitHelper::isDT(detid)) { + const DTLayerId idd(h.detUnitId()); + layers_with_hits.insert(idd.layer()); + } + } + return layers_with_hits.size(); +} + +int +DTSimHitMatcher::nSuperLayersWithHitsInChamber(unsigned int detid) const +{ + set sl_with_hits; + const auto& hits = MuonSimHitMatcher::hitsInChamber(detid); + for (const auto& h: hits) { + if (MuonHitHelper::isDT(detid)) { + const DTSuperLayerId idd(h.detUnitId()); + sl_with_hits.insert(idd.superLayer()); + } + } + return sl_with_hits.size(); +} + +int +DTSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const +{ + int nLayers = 0; + const auto& superLayers(dynamic_cast(geometry_)->chamber(DTChamberId(detid))->superLayers()); + for (const auto& sl: superLayers) { + nLayers += nLayersWithHitsInSuperLayer(sl->id().rawId()); + } + return nLayers; +} +float +DTSimHitMatcher::simHitsMeanWire(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + float s; + const auto& d = h.detUnitId(); + if (MuonHitHelper::isDT(d)) + { + // find nearest wire + s = dynamic_cast(geometry_)->layer(DTLayerId(d))->specificTopology().channel(lp); + } + else continue; + sums += s; + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + +std::set +DTSimHitMatcher::hitWiresInDTLayerId(unsigned int detid, int margin_n_wires) const +{ + set result; + if ( MuonHitHelper::isDT(detid) ) { + DTLayerId id(detid); + int max_nwires = dynamic_cast(geometry_)->layer(id)->specificTopology().channels(); + for (int wn = 0; wn <= max_nwires; ++wn) { + DTWireId wid(id,wn); + for (const auto& h: MuonSimHitMatcher::hitsInDetId(wid.rawId())) { + if (verbose_) cout << "central DTWireId "<< wid << " simhit " < 0) ? smin : 1; + int smax = wn + margin_n_wires; + smax = (smax <= max_nwires) ? smax : max_nwires; + for (int ss = smin; ss <= smax; ++ss) { + DTWireId widd(id, ss); + if (verbose_) cout << "\tadding DTWireId to collection "<< widd << endl; + result.insert(widd.rawId()); + } + } + } + } + return result; +} + + +std::set +DTSimHitMatcher::hitWiresInDTSuperLayerId(unsigned int detid, int margin_n_wires) const +{ + set result; + const auto& layers(dynamic_cast(geometry_)->superLayer(DTSuperLayerId(detid))->layers()); + for (const auto& l: layers) { + if (verbose_)cout << "hitWiresInDTSuperLayerId::l id "<id() << endl; + const auto& p(hitWiresInDTLayerId(l->id().rawId(), margin_n_wires)); + result.insert(p.begin(),p.end()); + } + return result; +} + + +std::set +DTSimHitMatcher::hitWiresInDTChamberId(unsigned int detid, int margin_n_wires) const +{ + set result; + const auto& superLayers(dynamic_cast(geometry_)->chamber(DTChamberId(detid))->superLayers()); + for (const auto& sl: superLayers) { + if (verbose_)cout << "hitWiresInDTChamberId::sl id "<id() << endl; + const auto& p(hitWiresInDTSuperLayerId(sl->id().rawId(), margin_n_wires)); + result.insert(p.begin(),p.end()); + } + return result; +} + + +void +DTSimHitMatcher::dtChamberIdsToString(const std::set& set) const +{ + for (const auto& p: set) { + DTChamberId detId(p); + std::cout << " " << detId << "\n"; + } +} + +std::set +DTSimHitMatcher::chamberIdsStation(int station) const +{ + set result; + switch(station){ + case 1: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB21p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB11p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB01)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB11n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB21n)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + result.insert(p3.begin(),p3.end()); + result.insert(p4.begin(),p4.end()); + result.insert(p5.begin(),p5.end()); + break; + } + case 2: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB22p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB12p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB02)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB12n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB22n)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + result.insert(p3.begin(),p3.end()); + result.insert(p4.begin(),p4.end()); + result.insert(p5.begin(),p5.end()); + break; + } + case 3: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB23p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB13p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB03)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB13n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB23n)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + result.insert(p3.begin(),p3.end()); + result.insert(p4.begin(),p4.end()); + result.insert(p5.begin(),p5.end()); + break; + } + case 4: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB24p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB14p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB04)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB14n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB24n)); + result.insert(p1.begin(),p1.end()); + result.insert(p2.begin(),p2.end()); + result.insert(p3.begin(),p3.end()); + result.insert(p4.begin(),p4.end()); + result.insert(p5.begin(),p5.end()); + break; + } + }; + return result; +} diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc new file mode 100644 index 0000000000000..07fc6c6eec573 --- /dev/null +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -0,0 +1,320 @@ +#include "Validation/MuonHits/interface/GEMSimHitMatcher.h" + +using namespace std; + +GEMSimHitMatcher::GEMSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) + : MuonSimHitMatcher(ps, std::move(iC)) +{ + simHitPSet_ = ps.getParameterSet("gemSimHit"); + verbose_ = simHitPSet_.getParameter("verbose"); + simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); + discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); + + simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); +} + +/// initialize the event +void GEMSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + iSetup.get().get(gem_geom_); + if (gem_geom_.isValid()) { + geometry_ = dynamic_cast(&*gem_geom_); + } else { + hasGeometry_ = false; + std::cout << "+++ Info: GEM geometry is unavailable. +++\n"; + } + MuonSimHitMatcher::init(iEvent, iSetup); +} + +/// do the matching +void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + MuonSimHitMatcher::match(track, vertex); + + if (hasGeometry_) { + + matchSimHitsToSimTrack(track_ids_, simHits_); + + if (verbose_) { + cout<<"nTrackIds "<(cout, " ")); cout< track_ids, const edm::PSimHitContainer& gem_hits) +{ + for (const auto& track_id: track_ids) + { + for (const auto& h: gem_hits) + { + if (h.trackId() != track_id) continue; + int pdgid = h.particleType(); + if (simMuOnly_ && std::abs(pdgid) != 13) continue; + // discard electron hits in the GEM chambers + if (discardEleHits_ && pdgid == 11) continue; + + const GEMDetId& p_id( h.detUnitId() ); + detid_to_hits_[ h.detUnitId() ].push_back(h); + hits_.push_back(h); + chamber_to_hits_[ p_id.chamberId().rawId() ].push_back(h); + superchamber_to_hits_[ p_id.superChamberId().rawId() ].push_back(h); + } + } +} + +std::set +GEMSimHitMatcher::detIds(int gem_type) const +{ + std::set result; + for (const auto& p: detid_to_hits_) + { + const auto& id = p.first; + if (gem_type > 0) + { + GEMDetId detId(id); + if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) continue; + } + result.insert(id); + } + return result; +} + +std::set +GEMSimHitMatcher::detIdsCoincidences() const +{ + std::set result; + for (const auto& p: detids_to_copads_) result.insert(p.first); + return result; +} + + +std::set +GEMSimHitMatcher::chamberIds(int gem_type) const +{ + std::set result; + for (const auto& p: chamber_to_hits_) + { + const auto& id = p.first; + if (gem_type > 0) + { + GEMDetId detId(id); + if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) continue; + } + result.insert(id); + } + return result; +} + + +std::set +GEMSimHitMatcher::superChamberIds() const +{ + std::set result; + for (const auto& p: superchamber_to_hits_) result.insert(p.first); + return result; +} + + +std::set +GEMSimHitMatcher::superChamberIdsCoincidences() const +{ + std::set result; + for (const auto& p: detids_to_copads_) + { + const GEMDetId& p_id(p.first); + result.insert(p_id.superChamberId().rawId()); + } + return result; +} + + +const edm::PSimHitContainer& +GEMSimHitMatcher::hitsInSuperChamber(unsigned int detid) const +{ + if (MuonHitHelper::isGEM(detid)) + { + const GEMDetId id(detid); + if (superchamber_to_hits_.find(id.chamberId().rawId()) == superchamber_to_hits_.end()) return no_hits_; + return superchamber_to_hits_.at(id.chamberId().rawId()); + } + + return no_hits_; +} + + +int +GEMSimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const +{ + set layers_with_hits; + const auto& hits = hitsInSuperChamber(detid); + for (const auto& h: hits) + { + const GEMDetId& idd(h.detUnitId()); + layers_with_hits.insert(idd.layer()); + } + return layers_with_hits.size(); +} + + +bool +GEMSimHitMatcher::hitStation(int st, int nlayers) const +{ + int nst=0; + for(const auto& ddt: chamberIds()) { + + const GEMDetId id(ddt); + if (id.station()!=st) continue; + + const int nl(nLayersWithHitsInSuperChamber(id.rawId())); + if (nl < nlayers) continue; + ++nst; + } + return nst; +} + +int +GEMSimHitMatcher::nStations(int nlayers) const +{ + return (hitStation(1, nlayers) + hitStation(2, nlayers)); +} + +float +GEMSimHitMatcher::simHitsGEMCentralPosition(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -0.0; // point "zero" + + float central = -0.0; + size_t n = 0; + for (const auto& h: sim_hits) + { + LocalPoint lp( 0., 0., 0. );//local central + GlobalPoint gp; + if ( MuonHitHelper::isGEM(h.detUnitId()) ) + { + gp = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp); + } + central = gp.perp(); + if (n>=1) std::cout <<"warning! find more than one simhits in GEM chamber " << std::endl; + ++n; + } + + return central; +} + + + +float +GEMSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + const auto& d = h.detUnitId(); + sums += dynamic_cast(geometry_)->etaPartition(d)->strip(lp); + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + + +std::set +GEMSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const +{ + set result; + const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); + GEMDetId id(detid); + int max_nstrips = dynamic_cast(geometry_)->etaPartition(id)->nstrips(); + for (const auto& h: simhits) + { + const LocalPoint& lp = h.entryPoint(); + int central_strip = static_cast(dynamic_cast(geometry_)->etaPartition(id)->topology().channel(lp)); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } + return result; +} + + +std::set +GEMSimHitMatcher::hitPadsInDetId(unsigned int detid) const +{ + set none; + if (detids_to_pads_.find(detid) == detids_to_pads_.end()) return none; + return detids_to_pads_.at(detid); +} + + +std::set +GEMSimHitMatcher::hitCoPadsInDetId(unsigned int detid) const +{ + set none; + if (detids_to_copads_.find(detid) == detids_to_copads_.end()) return none; + return detids_to_copads_.at(detid); +} + + +std::set +GEMSimHitMatcher::hitPartitions() const +{ + std::set result; + + const auto& detids = detIds(); + for (const auto& id: detids) + { + GEMDetId idd(id); + result.insert( idd.roll() ); + } + return result; +} + + +int +GEMSimHitMatcher::nPadsWithHits() const +{ + int result = 0; + const auto& pad_ids = detIds(); + for (const auto& id: pad_ids) + { + result += hitPadsInDetId(id).size(); + } + return result; +} + + +int +GEMSimHitMatcher::nCoincidencePadsWithHits() const +{ + int result = 0; + const auto& copad_ids = detIdsCoincidences(); + for (const auto& id: copad_ids) + { + result += hitCoPadsInDetId(id).size(); + } + return result; +} diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc new file mode 100644 index 0000000000000..9f2500a7cb729 --- /dev/null +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -0,0 +1,224 @@ +#include "Validation/MuonHits/interface/ME0SimHitMatcher.h" + +using namespace std; + +ME0SimHitMatcher::ME0SimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) + : MuonSimHitMatcher(ps, std::move(iC)) +{ + simHitPSet_ = ps.getParameterSet("me0SimHit"); + verbose_ = simHitPSet_.getParameter("verbose"); + simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); + discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); + + simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); +} + +/// initialize the event +void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + iSetup.get().get(me0_geom_); + if (me0_geom_.isValid()) { + geometry_ = &*me0_geom_; + } else { + hasGeometry_ = false; + std::cout << "+++ Info: ME0 geometry is unavailable. +++\n"; + } + ME0SimHitMatcher::init(iEvent, iSetup); +} + +/// do the matching +void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + MuonSimHitMatcher::match(track, vertex); + + if (hasGeometry_) { + + matchSimHitsToSimTrack(track_ids_, simHits_); + + if (verbose_) { + cout<<"nTrackIds "<(cout, " ")); cout< track_ids, const edm::PSimHitContainer& me0_hits) +{ + for (const auto& track_id: track_ids) + { + for (const auto& h: me0_hits) + { + if (h.trackId() != track_id) continue; + int pdgid = h.particleType(); + if (simMuOnly_ && std::abs(pdgid) != 13) continue; + // discard electron hits in the ME0 chambers + if (discardEleHits_ && std::abs(pdgid) == 11) continue; + + const ME0DetId& layer_id( h.detUnitId() ); + detid_to_hits_[ h.detUnitId() ].push_back(h); + hits_.push_back(h); + chamber_to_hits_[ layer_id.layerId().rawId() ].push_back(h); + superChamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + } + } +} +std::set +ME0SimHitMatcher::detIds() const +{ + std::set result; + for (const auto& p: detid_to_hits_) result.insert(p.first); + return result; +} + +std::set +ME0SimHitMatcher::detIdsCoincidences(int min_n_layers) const +{ + std::set result; + + // int result = 0; + // const auto& chamber_ids = chamberIds(); + // for (const auto& id: chamber_ids) + // { + // if (nLayersWithHitsInSuperChamber(id) >= min_n_layers) result += 1; + // } + // return result; + + // for (const auto& p: detids_to_copads_) result.insert(p.first); + return result; +} + +std::set +ME0SimHitMatcher::chamberIds() const +{ + std::set result; + for (const auto& p: chamber_to_hits_) result.insert(p.first); + return result; +} + +const edm::PSimHitContainer& +ME0SimHitMatcher::hitsInSuperChamber(unsigned int detid) const +{ + if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end()) return no_hits_; + return superChamber_to_hits_.at(detid); +} + +int +ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const +{ + set layers_with_hits; + const auto& hits = hitsInSuperChamber(detid); + for (const auto& h: hits) + { + const ME0DetId& idd(h.detUnitId()); + layers_with_hits.insert(idd.layer()); + } + return layers_with_hits.size(); +} + +float +ME0SimHitMatcher::simHitsCentralPosition(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -0.0; // point "zero" + + float central = -0.0; + size_t n = 0; + for (const auto& h: sim_hits) + { + LocalPoint lp( 0., 0., 0. );//local central + const GlobalPoint& gp = dynamic_cast(geometry_)->idToDet(h.detUnitId())->surface().toGlobal(lp); + central = gp.perp(); + if (n>=1) std::cout <<"warning! find more than one simhits in ME0 chamber " << std::endl; + ++n; + } + + return central; +} + +float +ME0SimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + float s; + const auto& d = h.detUnitId(); + s = dynamic_cast(geometry_)->etaPartition(d)->strip(lp); + sums += s; + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + + +std::set +ME0SimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const +{ + set result; + const auto& simhits = hitsInDetId(detid); + ME0DetId id(detid); + int max_nstrips = dynamic_cast(geometry_)->etaPartition(id)->nstrips(); + for (const auto& h: simhits) + { + const LocalPoint& lp = h.entryPoint(); + int central_strip = 1 + static_cast(dynamic_cast(geometry_)->etaPartition(id)->topology().channel(lp)); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } + return result; +} + +std::set +ME0SimHitMatcher::hitPadsInDetId(unsigned int detid) const +{ + set none; + if (detids_to_pads_.find(detid) == detids_to_pads_.end()) return none; + return detids_to_pads_.at(detid); +} + + +std::set +ME0SimHitMatcher::hitPartitions() const +{ + std::set result; + + const auto& detids = detIds(); + for (const auto& id: detids) + { + ME0DetId idd(id); + result.insert( idd.roll() ); + } + return result; +} + + +int +ME0SimHitMatcher::nPadsWithHits() const +{ + int result = 0; + const auto& pad_ids = detIds(); + for (const auto& id: pad_ids) + { + result += hitPadsInDetId(id).size(); + } + return result; +} + diff --git a/Validation/MuonHits/src/MuonHitHelper.cc b/Validation/MuonHits/src/MuonHitHelper.cc new file mode 100644 index 0000000000000..a69395d2ea84d --- /dev/null +++ b/Validation/MuonHits/src/MuonHitHelper.cc @@ -0,0 +1,181 @@ +#include "Validation/MuonHits/interface/MuonHitHelper.h" + +bool MuonHitHelper::isDT(unsigned int detId) +{ + return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::DT; +} + +bool MuonHitHelper::isGEM(unsigned int detId) +{ + return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::GEM; +} + +bool MuonHitHelper::isCSC(unsigned int detId) +{ + return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::CSC; +} + +bool MuonHitHelper::isRPC(unsigned int detId) +{ + return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::RPC; +} + +bool MuonHitHelper::isME0(unsigned int detId) +{ + return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::ME0; +} + +int MuonHitHelper::chamber(const DetId& id) +{ + if (id.det() != DetId::Detector::Muon) return -99; + int chamberN = 0; + switch(id.subdetId()){ + case MuonSubdetId::GEM: + chamberN = GEMDetId(id).chamber(); + break; + case MuonSubdetId::RPC: + // works only for endcap!! + chamberN = RPCDetId(id).sector(); + break; + case MuonSubdetId::CSC: + chamberN = CSCDetId(id).chamber(); + break; + case MuonSubdetId::ME0: + chamberN = ME0DetId(id).chamber(); + break; + case MuonSubdetId::DT: + chamberN = DTChamberId(id).sector(); + break; + }; + return chamberN; +} + +// return MuonType for a particular DetId +int MuonHitHelper::toGEMType(int st, int ri) +{ + if (st==1) { + if (ri==1) return GEM_ME11; + } + else if (st==2) { + if (ri==1) return GEM_ME21; + } + return GEM_ALL; +} + +int MuonHitHelper::toRPCType(int re, int st, int ri) +{ + // endcap + if (std::abs(re)==1) { + if (st ==1) { + if (ri==2) return RPC_ME12; + if (ri==3) return RPC_ME13; + } + else if (st ==2) { + if (ri==2) return RPC_ME22; + if (ri==3) return RPC_ME23; + } + else if (st ==3) { + if (ri==1) return RPC_ME31; + if (ri==2) return RPC_ME32; + if (ri==3) return RPC_ME33; + } + else if (st ==4) { + if (ri==1) return RPC_ME41; + if (ri==2) return RPC_ME42; + if (ri==3) return RPC_ME43; + } + } + // Barrel + else { + if (ri==-2) { + if (st==1) return RPC_MB21n; + if (st==2) return RPC_MB22n; + if (st==3) return RPC_MB23n; + if (st==4) return RPC_MB24n; + } + else if (ri==-1) { + if (st==1) return RPC_MB11n; + if (st==2) return RPC_MB12n; + if (st==3) return RPC_MB13n; + if (st==4) return RPC_MB14n; + } + else if (ri==0) { + if (st==1) return RPC_MB01; + if (st==2) return RPC_MB02; + if (st==3) return RPC_MB03; + if (st==4) return RPC_MB04; + } + else if (ri==1) { + if (st==1) return RPC_MB11p; + if (st==2) return RPC_MB12p; + if (st==3) return RPC_MB13p; + if (st==4) return RPC_MB14p; + } + else if (ri==2) { + if (st==1) return RPC_MB21p; + if (st==2) return RPC_MB22p; + if (st==3) return RPC_MB23p; + if (st==4) return RPC_MB24p; + } + } + return RPC_ALL; +} + +int MuonHitHelper::toDTType(int wh, int st) +{ + if (wh==-2) { + if (st==1) return DT_MB21n; + if (st==2) return DT_MB22n; + if (st==3) return DT_MB23n; + if (st==4) return DT_MB24n; + } + if (wh==-1) { + if (st==1) return DT_MB11n; + if (st==2) return DT_MB12n; + if (st==3) return DT_MB13n; + if (st==4) return DT_MB14n; + } + if (wh==0) { + if (st==1) return DT_MB01; + if (st==2) return DT_MB02; + if (st==3) return DT_MB03; + if (st==4) return DT_MB04; + } + if (wh==1) { + if (st==1) return DT_MB11p; + if (st==2) return DT_MB12p; + if (st==3) return DT_MB13p; + if (st==4) return DT_MB14p; + } + if (wh==2) { + if (st==1) return DT_MB21p; + if (st==2) return DT_MB22p; + if (st==3) return DT_MB23p; + if (st==4) return DT_MB24p; + } + return DT_ALL; +} + +int MuonHitHelper::toCSCType(int st, int ri) +{ + if (st==1) { + if (ri==0) return CSC_ME11; + if (ri==1) return CSC_ME1b; + if (ri==2) return CSC_ME12; + if (ri==3) return CSC_ME13; + if (ri==4) return CSC_ME1a; + } + else if (st==2) { + if (ri==1) return CSC_ME21; + if (ri==2) return CSC_ME22; + } + else if (st==3) { + if (ri==1) return CSC_ME31; + if (ri==2) return CSC_ME32; + } + else if (st==4) { + if (ri==1) return CSC_ME41; + if (ri==2) return CSC_ME42; + } + return CSC_ALL; +} diff --git a/Validation/MuonHits/src/MuonSimHitMatcher.cc b/Validation/MuonHits/src/MuonSimHitMatcher.cc new file mode 100644 index 0000000000000..c103d8c68a506 --- /dev/null +++ b/Validation/MuonHits/src/MuonSimHitMatcher.cc @@ -0,0 +1,151 @@ +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" + +#include + +using namespace std; + +MuonSimHitMatcher::MuonSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) +{ + const auto& simVertex = ps.getParameterSet("simVertex"); + const auto& simTrack = ps.getParameterSet("simTrack"); + verboseSimTrack_ = simTrack.getParameter("verbose"); + + simVertexInput_ = iC.consumes(simVertex.getParameter("inputTag")); + simTrackInput_ = iC.consumes(simTrack.getParameter("inputTag")); +} + +/// initialize the event +void MuonSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + hasGeometry_ = true; + + iEvent.getByToken(simTrackInput_, simTracksH_); + iEvent.getByToken(simVertexInput_, simVerticesH_); + iEvent.getByToken(simHitInput_, simHitsH_); +} + +/// do the matching +void MuonSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + simTracks_ = *simTracksH_.product(); + simVertices_ = *simVerticesH_.product(); + simHits_ = *simHitsH_.product(); + + // fill trkId2Index association: + int no = 0; + trkid_to_index_.clear(); + for (const auto& t: simTracks_) { + trkid_to_index_[t.trackId()] = no; + no++; + } + + vector track_ids = getIdsOfSimTrackShower(track.trackId(), simTracks_, simVertices_); + if (verboseSimTrack_) { + std::cout << "Printing track_ids" << std::endl; + for (const auto& id: track_ids) std::cout << "id: " << id << std::endl; + } +} + +std::vector +MuonSimHitMatcher::getIdsOfSimTrackShower(unsigned int initial_trk_id, + const edm::SimTrackContainer & simTracks, const edm::SimVertexContainer & simVertices) +{ + vector result; + result.push_back(initial_trk_id); + + if (!simMuOnly_) return result; + + for (const auto& t: simTracks_) + { + SimTrack last_trk = t; + //if (std::abs(t.type()) != 13) continue; + bool is_child = 0; + while (1) + { + if ( last_trk.noVertex() ) break; + if ( simVertices_[last_trk.vertIndex()].noParent() ) break; + + unsigned parentId = simVertices_[last_trk.vertIndex()].parentIndex(); + if ( parentId == initial_trk_id ) + { + is_child = 1; + break; + } + + const auto& association = trkid_to_index_.find( parentId ); + if ( association == trkid_to_index_.end() ) break; + + last_trk = simTracks_[ association->second ]; + } + if (is_child) + { + result.push_back(t.trackId()); + } + } + return result; +} + +const edm::PSimHitContainer& +MuonSimHitMatcher::simHits(int sub) const +{ + return hits_; +} + +const edm::PSimHitContainer& +MuonSimHitMatcher::hitsInDetId(unsigned int detid) const +{ + if (detid_to_hits_.find(detid) == detid_to_hits_.end()) return no_hits_; + return detid_to_hits_.at(detid); +} + + +const edm::PSimHitContainer& +MuonSimHitMatcher::hitsInChamber(unsigned int detid) const +{ + if (chamber_to_hits_.find(detid) == chamber_to_hits_.end()) return no_hits_; + return chamber_to_hits_.at(detid); +} + + +GlobalPoint +MuonSimHitMatcher::simHitsMeanPosition(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return GlobalPoint(); // point "zero" + + float sumx, sumy, sumz; + sumx = sumy = sumz = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + const GlobalPoint& gp = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp); + sumx += gp.x(); + sumy += gp.y(); + sumz += gp.z(); + ++n; + } + if (n == 0) return GlobalPoint(); + return GlobalPoint(sumx/n, sumy/n, sumz/n); +} + +GlobalVector +MuonSimHitMatcher::simHitsMeanMomentum(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return GlobalVector(); // point "zero" + + float sumx, sumy, sumz; + sumx = sumy = sumz = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalVector& lv = h.momentumAtEntry(); + const GlobalVector& gv = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lv); + sumx += gv.x(); + sumy += gv.y(); + sumz += gv.z(); + ++n; + } + if (n == 0) return GlobalVector(); + return GlobalVector(sumx/n, sumy/n, sumz/n); +} + diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc new file mode 100644 index 0000000000000..076f390088e61 --- /dev/null +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -0,0 +1,171 @@ +#include "Validation/MuonHits/interface/RPCSimHitMatcher.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" + +using namespace std; + +RPCSimHitMatcher::RPCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) + : MuonSimHitMatcher(ps, std::move(iC)) +{ + simHitPSet_ = ps.getParameterSet("rpcSimHit"); + verbose_ = simHitPSet_.getParameter("verbose"); + simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); + discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); + + simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); +} + +/// initialize the event +void RPCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + iSetup.get().get(rpc_geom_); + if (rpc_geom_.isValid()) { + geometry_ = &*rpc_geom_; + } else { + hasGeometry_ = false; + std::cout << "+++ Info: RPC geometry is unavailable. +++\n"; + } + MuonSimHitMatcher::init(iEvent, iSetup); +} + +/// do the matching +void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) +{ + MuonSimHitMatcher::match(track, vertex); + + if (hasGeometry_) { + + matchSimHitsToSimTrack(track_ids_, simHits_); + + if (verbose_) { + cout<<"nSimHits "<(cout, " ")); cout< track_ids_, const edm::PSimHitContainer& hits) +{ + for (const auto& track_id: track_ids_) + { + for (const auto& h: hits) + { + if (h.trackId() != track_id) continue; + int pdgid = h.particleType(); + if (simMuOnly_ && std::abs(pdgid) != 13) continue; + // discard electron hits in the RPC chambers + if (discardEleHits_ && pdgid == 11) continue; + + const RPCDetId& layer_id( h.detUnitId() ); + detid_to_hits_[ h.detUnitId() ].push_back(h); + hits_.push_back(h); + chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + } + } +} + + +std::set +RPCSimHitMatcher::detIds(int type) const +{ + std::set result; + for (const auto& p: detid_to_hits_) + { + const auto& id = p.first; + if (type > 0) + { + RPCDetId detId(id); + if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type) continue; + } + result.insert(id); + } + return result; +} + + +std::set +RPCSimHitMatcher::chamberIds(int type) const +{ + std::set result; + for (const auto& p: chamber_to_hits_) + { + const auto& id = p.first; + if (type > 0) + { + RPCDetId detId(id); + if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type) continue; + } + result.insert(id); + } + return result; +} + +bool +RPCSimHitMatcher::hitStation(int st) const +{ + int nst=0; + for(const auto& ddt: chamberIds()) { + const RPCDetId id(ddt); + if (id.station()!=st) continue; + ++nst; + } + return nst; +} + +int +RPCSimHitMatcher::nStations() const +{ + return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4)); +} + +float +RPCSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const +{ + if (sim_hits.empty()) return -1.f; + + float sums = 0.f; + size_t n = 0; + for (const auto& h: sim_hits) + { + const LocalPoint& lp = h.entryPoint(); + const auto& d = h.detUnitId(); + sums += dynamic_cast(geometry_)->roll(d)->strip(lp); + ++n; + } + if (n == 0) return -1.f; + return sums/n; +} + + +std::set +RPCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const +{ + set result; + RPCDetId id(detid); + for (const auto& roll: dynamic_cast(geometry_)->chamber(id)->rolls()) { + int max_nstrips = roll->nstrips(); + for (const auto& h: MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) { + const LocalPoint& lp = h.entryPoint(); + int central_strip = static_cast(roll->topology().channel(lp)); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } + } + return result; +} From c34f60120ac72a8d28747515fa1b3307508bb656 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Mar 2019 04:23:56 +0100 Subject: [PATCH 555/686] Implement missing functions and remove obsolete functions GEM and ME0 --- .../MuonHits/interface/ME0SimHitMatcher.h | 25 ++----- Validation/MuonHits/src/GEMSimHitMatcher.cc | 71 +++++++++++++++++++ Validation/MuonHits/src/ME0SimHitMatcher.cc | 62 ++++++++-------- 3 files changed, 112 insertions(+), 46 deletions(-) diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h index 21669b44ae150..875923a8d2f28 100644 --- a/Validation/MuonHits/interface/ME0SimHitMatcher.h +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -33,35 +33,21 @@ class ME0SimHitMatcher : public MuonSimHitMatcher // chamber detIds with SimHits std::set chamberIds() const; - // simhits from a particular partition, chamber - const edm::PSimHitContainer& hitsInSuperChamber(unsigned int) const; - - // detid's with hits in 2 layers of coincidence pads - std::set detIdsCoincidences(int min_n_layers = 2) const; - // ME0 superchamber detIds with SimHits std::set superChamberIds() const; - // ME0 superchamber detIds with SimHits >=4 layers of coincidence pads - std::set superChamberIdsCoincidences(int min_n_layers = 2) const; + // simhits from a particular partition, chamber + const edm::PSimHitContainer& hitsInSuperChamber(unsigned int) const; // #layers with hits int nLayersWithHitsInSuperChamber(unsigned int) const; - float simHitsCentralPosition(const edm::PSimHitContainer& sim_hits) const; - - // How many pads with simhits in GEM did this simtrack get? - int nPadsWithHits() const; - - // How many coincidence pads with simhits in GEM did this simtrack get? - int nCoincidencePadsWithHits() const; + // ME0 superchamber detIds with SimHits >=4 layers of coincidence pads + std::set superChamberIdsCoincidences(int min_n_layers = 4) const; // How many ME0 chambers with minimum number of layer with simhits did this simtrack get? int nCoincidenceChambers(int min_n_layers = 4) const; - // calculated the fitted position in a given layer for CSC simhits in a chamber - GlobalPoint simHitPositionKeyLayer(unsigned int chamberid) const; - // calculate average strip (strip for GEM/ME0, half-strip for CSC) number for a provided collection of simhits float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; @@ -71,6 +57,9 @@ class ME0SimHitMatcher : public MuonSimHitMatcher // what unique partitions numbers were hit by this simtrack? std::set hitPartitions() const; // GEM + // How many pads with simhits in GEM did this simtrack get? + int nPadsWithHits() const; + private: void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& me0_hits); diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index 07fc6c6eec573..0bfa5f0eaa937 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -78,6 +78,77 @@ GEMSimHitMatcher::matchSimHitsToSimTrack(std::vector track_ids, co superchamber_to_hits_[ p_id.superChamberId().rawId() ].push_back(h); } } + + // find pads with hits + const auto& detids = detIds(); + // find 2-layer coincidence pads with hits + for (const auto& d: detids) { + GEMDetId id(d); + const auto& hits = hitsInDetId(d); + const auto& roll = dynamic_cast(geometry_)->etaPartition(id); + //int max_npads = roll->npads(); + set pads; + for (const auto& h: hits) { + const LocalPoint& lp = h.entryPoint(); + pads.insert( 1 + static_cast(roll->padTopology().channel(lp)) ); + } + detids_to_pads_[d] = pads; + } + + // find 2-layer coincidence pads with hits + for (const auto& d: detids) { + GEMDetId id1(d); + if (id1.layer() != 1) continue; + + // find pads with hits in layer1 + const auto& hits1 = hitsInDetId(d); + const auto& roll1 = dynamic_cast(geometry_)->etaPartition(id1); + set pads1; + set pads2; + set copads; + + for (const auto& h: hits1) { + const LocalPoint& lp = h.entryPoint(); + pads1.insert( 1 + static_cast(roll1->padTopology().channel(lp)) ); + if (verbose_) std::cout <<"GEMHits detid1 "<(roll1->padTopology().channel(lp)) << std::endl; + } + + // find pads with hits in layer2 + for (const auto& d2 : detids){ + //staggered geometry???? improve here !! + GEMDetId id2(d2); + // does layer 2 has simhits? + if (id2.layer() !=2 or + id2.region() != id1.region() or + id2.ring()!=id1.ring() or + id2.station()!=id1.station() or + abs(id2.roll()-id1.roll())>1) + continue; + const auto& hits2 = hitsInDetId(id2()); + const auto& roll2 = dynamic_cast(geometry_)->etaPartition(id2); + for (const auto& h: hits2) { + const LocalPoint& lp = h.entryPoint(); + pads2.insert( 1 + static_cast(roll2->padTopology().channel(lp)) ); + if (verbose_) std::cout <<"GEMHits detid2 "<(roll2->padTopology().channel(lp)) << std::endl; + } + } + + for (const auto& pad1 : pads1) { + for (const auto& pad2 : pads2){ + if (abs(pad1-pad2) <= 2) { + if (copads.find(pad1) == copads.end()) + copads.insert(pad1); + if (copads.find(pad2) == copads.end()) + copads.insert(pad2); + } + } + } + + if (copads.empty()) continue; + + //detids here is layer1 id + detids_to_copads_[d] = copads; + } } std::set diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index 9f2500a7cb729..a7982522c7d2e 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -72,7 +72,23 @@ ME0SimHitMatcher::matchSimHitsToSimTrack(std::vector track_ids, co superChamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); } } + + // find pads with hits + const auto& detids = detIds(); + for (const auto& d: detids) { + GEMDetId id(d); + const auto& hits = hitsInDetId(d); + const auto& roll = dynamic_cast(geometry_)->etaPartition(id); + //int max_npads = roll->npads(); + set pads; + for (const auto& h: hits) { + const LocalPoint& lp = h.entryPoint(); + pads.insert( 1 + static_cast(roll->padTopology().channel(lp)) ); + } + detids_to_pads_[d] = pads; + } } + std::set ME0SimHitMatcher::detIds() const { @@ -82,27 +98,18 @@ ME0SimHitMatcher::detIds() const } std::set -ME0SimHitMatcher::detIdsCoincidences(int min_n_layers) const +ME0SimHitMatcher::chamberIds() const { std::set result; - - // int result = 0; - // const auto& chamber_ids = chamberIds(); - // for (const auto& id: chamber_ids) - // { - // if (nLayersWithHitsInSuperChamber(id) >= min_n_layers) result += 1; - // } - // return result; - - // for (const auto& p: detids_to_copads_) result.insert(p.first); + for (const auto& p: chamber_to_hits_) result.insert(p.first); return result; } std::set -ME0SimHitMatcher::chamberIds() const +ME0SimHitMatcher::superChamberIds() const { std::set result; - for (const auto& p: chamber_to_hits_) result.insert(p.first); + for (const auto& p: superChamber_to_hits_) result.insert(p.first); return result; } @@ -126,25 +133,25 @@ ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const return layers_with_hits.size(); } -float -ME0SimHitMatcher::simHitsCentralPosition(const edm::PSimHitContainer& sim_hits) const +std::set +ME0SimHitMatcher::superChamberIdsCoincidences(int min_n_layers) const { - if (sim_hits.empty()) return -0.0; // point "zero" - - float central = -0.0; - size_t n = 0; - for (const auto& h: sim_hits) - { - LocalPoint lp( 0., 0., 0. );//local central - const GlobalPoint& gp = dynamic_cast(geometry_)->idToDet(h.detUnitId())->surface().toGlobal(lp); - central = gp.perp(); - if (n>=1) std::cout <<"warning! find more than one simhits in ME0 chamber " << std::endl; - ++n; + set result; + // loop over the super chamber Ids + for (const auto& p : superChamberIds()) { + if (nLayersWithHitsInSuperChamber(p) >= min_n_layers) { + result.insert(p); + } } + return result; +} - return central; +int ME0SimHitMatcher::nCoincidenceChambers(int min_n_layers) const +{ + return superChamberIdsCoincidences(min_n_layers).size(); } + float ME0SimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const { @@ -221,4 +228,3 @@ ME0SimHitMatcher::nPadsWithHits() const } return result; } - From 17847282d2a6daa9d811c0a7a68ad4a6661efe4d Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Mar 2019 04:32:28 +0100 Subject: [PATCH 556/686] Update documentation --- Validation/MuonHits/interface/CSCSimHitMatcher.h | 14 +++++++------- Validation/MuonHits/interface/DTSimHitMatcher.h | 8 ++++---- Validation/MuonHits/interface/GEMSimHitMatcher.h | 5 ++--- Validation/MuonHits/interface/ME0SimHitMatcher.h | 12 ++++++------ Validation/MuonHits/interface/RPCSimHitMatcher.h | 10 +++++----- .../MuonHits/python/muonSimHitMatcherPSet.py | 14 +++++++------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h index b452652905997..4bc617df40f2a 100644 --- a/Validation/MuonHits/interface/CSCSimHitMatcher.h +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -3,7 +3,7 @@ /**\class CSCSimHitMatcher - Description: Matching of muon SimHit to SimTrack + Description: Matching of CSC SimHit to SimTrack Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ @@ -28,15 +28,15 @@ class CSCSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type = 0) const; + std::set detIds(int type MuonHitHelper::CSC_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type = 0) const; + std::set chamberIds(int type MuonHitHelper::CSC_ALL) const; // CSC station detIds with SimHits std::set chamberIdsStation(int station) const; - // was there a hit in a particular DT/CSC station? + // was there a hit in a particular CSC station? bool hitStation(int, int) const; // number of stations with hits in at least X layers @@ -54,7 +54,7 @@ class CSCSimHitMatcher : public MuonSimHitMatcher // local bending in a CSC chamber float LocalBendingInChamber(unsigned int detid) const; - // calculate average strip (strip for GEM/ME0, half-strip for CSC) number for a provided collection of simhits + // calculate average strip number for a provided collection of simhits float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; // calculate average wg number for a provided collection of simhits (for CSC) @@ -65,8 +65,8 @@ class CSCSimHitMatcher : public MuonSimHitMatcher // calculate the average position at the second station GlobalPoint simHitsMeanPositionStation(int n) const; - std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC - std::set hitWiregroupsInDetId(unsigned int, int margin_n_wg = 0) const; // CSC + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; + std::set hitWiregroupsInDetId(unsigned int, int margin_n_wg = 0) const; void camberIdsToString(const std::set&) const; diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h index 6015239906b91..f84f5c1d387c2 100644 --- a/Validation/MuonHits/interface/DTSimHitMatcher.h +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -3,7 +3,7 @@ /**\class DTSimHitMatcher - Description: Matching of muon SimHit to SimTrack + Description: Matching of DT SimHit to SimTrack Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ @@ -28,10 +28,10 @@ class DTSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type = 0) const; + std::set detIds(int type MuonHitHelper::DT_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type = 0) const; + std::set chamberIds(int type MuonHitHelper::DT_ALL) const; // DT station detIds with SimHits std::set chamberIdsStation(int station) const; @@ -57,7 +57,7 @@ class DTSimHitMatcher : public MuonSimHitMatcher const edm::PSimHitContainer& hitsInSuperLayer(unsigned int) const; const edm::PSimHitContainer& hitsInChamber(unsigned int) const; - // calculate average wg number for a provided collection of simhits (for DT) + // calculate average wg number for a provided collection of simhits float simHitsMeanWire(const edm::PSimHitContainer& sim_hits) const; // calculate the average position at the second station diff --git a/Validation/MuonHits/interface/GEMSimHitMatcher.h b/Validation/MuonHits/interface/GEMSimHitMatcher.h index 6172e1a1279e9..c821fdbd0246e 100644 --- a/Validation/MuonHits/interface/GEMSimHitMatcher.h +++ b/Validation/MuonHits/interface/GEMSimHitMatcher.h @@ -3,7 +3,7 @@ /**\class GEMSimHitMatcher - Description: Matching of muon SimHit to SimTrack + Description: Matching of GEM SimHit to SimTrack Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ @@ -43,7 +43,7 @@ class GEMSimHitMatcher : public MuonSimHitMatcher // GEM superchamber detIds with SimHits 2 layers of coincidence pads std::set superChamberIdsCoincidences() const; - // simhits from a particular partition (GEM)/layer (CSC)/ME0, chamber or superchamber + // simhits from a particular superchamber const edm::PSimHitContainer& hitsInSuperChamber(unsigned int) const; // was there a hit in a particular station? @@ -53,7 +53,6 @@ class GEMSimHitMatcher : public MuonSimHitMatcher int nStations(int nl=2) const; // #layers with hits - // for CSC: "super-chamber" means chamber int nLayersWithHitsInSuperChamber(unsigned int) const; // How many pads with simhits in GEM did this simtrack get? diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h index 875923a8d2f28..9fc40262f81fc 100644 --- a/Validation/MuonHits/interface/ME0SimHitMatcher.h +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -3,7 +3,7 @@ /**\class ME0SimHitMatcher - Description: Matching of muon SimHit to SimTrack + Description: Matching of ME0 SimHit to SimTrack Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ @@ -48,16 +48,16 @@ class ME0SimHitMatcher : public MuonSimHitMatcher // How many ME0 chambers with minimum number of layer with simhits did this simtrack get? int nCoincidenceChambers(int min_n_layers = 4) const; - // calculate average strip (strip for GEM/ME0, half-strip for CSC) number for a provided collection of simhits + // calculate average strip for a provided collection of simhits float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; - std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC - std::set hitPadsInDetId(unsigned int) const; // GEM + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; + std::set hitPadsInDetId(unsigned int) const; // what unique partitions numbers were hit by this simtrack? - std::set hitPartitions() const; // GEM + std::set hitPartitions() const; - // How many pads with simhits in GEM did this simtrack get? + // How many pads with simhits in ME0 did this simtrack get? int nPadsWithHits() const; private: diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h index 3be92034ab088..a1ea97f32bc12 100644 --- a/Validation/MuonHits/interface/RPCSimHitMatcher.h +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -3,7 +3,7 @@ /**\class RPCSimHitMatcher - Description: Matching of muon SimHit to SimTrack + Description: Matching of RPC SimHit to SimTrack Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ @@ -28,20 +28,20 @@ class RPCSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type = 0) const; + std::set detIds(int type MuonHitHelper::RPC_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type = 0) const; + std::set chamberIds(int type MuonHitHelper::RPC_ALL) const; bool hitStation(int st) const; - // number of stations with hits in at least X layers + // number of stations with hits int nStations() const; // calculate average strip number for a provided collection of simhits float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; - std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; // GEM/ME0 or CSC + std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; private: diff --git a/Validation/MuonHits/python/muonSimHitMatcherPSet.py b/Validation/MuonHits/python/muonSimHitMatcherPSet.py index fed85cfc078b8..42797c65be87b 100644 --- a/Validation/MuonHits/python/muonSimHitMatcherPSet.py +++ b/Validation/MuonHits/python/muonSimHitMatcherPSet.py @@ -2,41 +2,41 @@ muonSimHitMatcherPSet = cms.PSet( simTrack = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits"), ), simVertex = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits"), ), gemSimHit = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits", "MuonGEMHits"), simMuOnly = cms.bool(True), discardEleHits = cms.bool(True), ), me0SimHit = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits", "MuonME0Hits"), simMuOnly = cms.bool(True), discardEleHits = cms.bool(True), minNHitsChamber = cms.int32(4), ), rpcSimHit = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits", "MuonRPCHits"), simMuOnly = cms.bool(True), discardEleHits = cms.bool(True), ), cscSimHit = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits", "MuonCSCHits"), simMuOnly = cms.bool(True), discardEleHits = cms.bool(True), minNHitsChamber = cms.int32(4), ), dtSimHit = cms.PSet( - verbose = cms.int32(1), + verbose = cms.int32(0), inputTag = cms.InputTag("g4SimHits", "MuonDTHits"), simMuOnly = cms.bool(True), discardEleHits = cms.bool(True), From 6f63a61102d5049e15d81101969786e24681d278 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Mar 2019 13:39:18 +0100 Subject: [PATCH 557/686] Fix compilation errors --- Validation/MuonHits/interface/CSCSimHitMatcher.h | 4 ++-- Validation/MuonHits/interface/DTSimHitMatcher.h | 4 ++-- Validation/MuonHits/interface/RPCSimHitMatcher.h | 4 ++-- Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc | 5 +---- Validation/MuonHits/src/CSCSimHitMatcher.cc | 4 +--- Validation/MuonHits/src/DTSimHitMatcher.cc | 2 +- Validation/MuonHits/src/RPCSimHitMatcher.cc | 2 +- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h index 4bc617df40f2a..d895cb307eeeb 100644 --- a/Validation/MuonHits/interface/CSCSimHitMatcher.h +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -28,10 +28,10 @@ class CSCSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type MuonHitHelper::CSC_ALL) const; + std::set detIds(int type = MuonHitHelper::CSC_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type MuonHitHelper::CSC_ALL) const; + std::set chamberIds(int type = MuonHitHelper::CSC_ALL) const; // CSC station detIds with SimHits std::set chamberIdsStation(int station) const; diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h index f84f5c1d387c2..17324ffd38287 100644 --- a/Validation/MuonHits/interface/DTSimHitMatcher.h +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -28,10 +28,10 @@ class DTSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type MuonHitHelper::DT_ALL) const; + std::set detIds(int type = MuonHitHelper::DT_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type MuonHitHelper::DT_ALL) const; + std::set chamberIds(int type = MuonHitHelper::DT_ALL) const; // DT station detIds with SimHits std::set chamberIdsStation(int station) const; diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h index a1ea97f32bc12..8d196bb849600 100644 --- a/Validation/MuonHits/interface/RPCSimHitMatcher.h +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -28,10 +28,10 @@ class RPCSimHitMatcher : public MuonSimHitMatcher void match(const SimTrack& t, const SimVertex& v); // partitions' detIds with SimHits - std::set detIds(int type MuonHitHelper::RPC_ALL) const; + std::set detIds(int type = MuonHitHelper::RPC_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int type MuonHitHelper::RPC_ALL) const; + std::set chamberIds(int type = MuonHitHelper::RPC_ALL) const; bool hitStation(int st) const; diff --git a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc index 355040194251c..c7cc0800f9624 100644 --- a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc +++ b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.cc @@ -1,4 +1,4 @@ -#include "Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h" +#include "Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h" #include "TFile.h" #include "TTree.h" @@ -504,6 +504,3 @@ void MuonSimHitsValidAnalyzer::fillDT(const edm::Event& iEvent, edm::LogInfo("MuonSimHitsValidAnalyzer::fillDT") << eventout << "\n"; return; } - - - diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index 5dfdd8dc4340e..05425b339bacf 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -318,7 +318,7 @@ int CSCSimHitMatcher::nCoincidenceChambers(int min_n_layers) const { int result = 0; - const auto& chamber_ids = chamberIds(); + const auto& chamber_ids = chamberIds(0); for (const auto& id: chamber_ids) { if (nLayersWithHitsInChamber(id) >= min_n_layers) result += 1; @@ -376,5 +376,3 @@ CSCSimHitMatcher::chamberIdsStation(int station) const }; return result; } - - diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index 53e607e0c1905..ecd14f62637b6 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -39,7 +39,7 @@ void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) cout<<"nTrackIds "< Date: Tue, 26 Mar 2019 13:52:44 +0100 Subject: [PATCH 558/686] Apply code-checks --- Validation/MuonHits/src/CSCSimHitMatcher.cc | 16 ++++++++-------- Validation/MuonHits/src/MuonSimHitMatcher.cc | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index 05425b339bacf..a112ce88f5be1 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -185,10 +185,10 @@ CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const const edm::PSimHitContainer& hits1b = MuonSimHitMatcher::hitsInDetId(cscid1b.rawId()); const GlobalPoint& gp1a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1a.rawId())); const GlobalPoint& gp1b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1b.rawId())); - if (hits1a.size()>0 and hits1b.size()>0) + if (!hits1a.empty() and !hits1b.empty()) phi_layer1 = (gp1a.phi()+gp1b.phi())/2.0; - else if (hits1a.size()>0) phi_layer1 = gp1a.phi(); - else if (hits1b.size()>0) phi_layer1 = gp1b.phi(); + else if (!hits1a.empty()) phi_layer1 = gp1a.phi(); + else if (!hits1b.empty()) phi_layer1 = gp1b.phi(); else std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; // phi in layer 6 @@ -198,10 +198,10 @@ CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const const edm::PSimHitContainer& hits6b = MuonSimHitMatcher::hitsInDetId(cscid6b.rawId()); const GlobalPoint& gp6a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6a.rawId())); const GlobalPoint& gp6b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6b.rawId())); - if (hits6a.size()>0 and hits6b.size()>0) + if (!hits6a.empty() and !hits6b.empty()) phi_layer6 = (gp6a.phi()+gp6b.phi())/2.0; - else if (hits6a.size()>0) phi_layer6 = gp6a.phi(); - else if (hits6b.size()>0) phi_layer6 = gp6b.phi(); + else if (!hits6a.empty()) phi_layer6 = gp6a.phi(); + else if (!hits6b.empty()) phi_layer6 = gp6b.phi(); else std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; @@ -210,14 +210,14 @@ CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const // phi in layer 1 const CSCDetId cscid1(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 1); const edm::PSimHitContainer& hits1 = MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); - if (hits1.size()==0) std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; + if (hits1.empty()) std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; const GlobalPoint& gp1 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); phi_layer1 = gp1.phi(); // phi in layer 6 const CSCDetId cscid6(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 6); const edm::PSimHitContainer& hits6 = MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); - if (hits6.size()==0) std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; + if (hits6.empty()) std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; const GlobalPoint& gp6 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); phi_layer6 = gp6.phi(); } diff --git a/Validation/MuonHits/src/MuonSimHitMatcher.cc b/Validation/MuonHits/src/MuonSimHitMatcher.cc index c103d8c68a506..c8b17d22776ba 100644 --- a/Validation/MuonHits/src/MuonSimHitMatcher.cc +++ b/Validation/MuonHits/src/MuonSimHitMatcher.cc @@ -59,8 +59,8 @@ MuonSimHitMatcher::getIdsOfSimTrackShower(unsigned int initial_trk_id, { SimTrack last_trk = t; //if (std::abs(t.type()) != 13) continue; - bool is_child = 0; - while (1) + bool is_child = false; + while (true) { if ( last_trk.noVertex() ) break; if ( simVertices_[last_trk.vertIndex()].noParent() ) break; @@ -68,7 +68,7 @@ MuonSimHitMatcher::getIdsOfSimTrackShower(unsigned int initial_trk_id, unsigned parentId = simVertices_[last_trk.vertIndex()].parentIndex(); if ( parentId == initial_trk_id ) { - is_child = 1; + is_child = true; break; } From 306234052bae9dcd447e76a303ead57b9306381e Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Mar 2019 14:34:45 +0100 Subject: [PATCH 559/686] Fix Clang error --- Validation/MuonHits/plugins/SealModule.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonHits/plugins/SealModule.cc b/Validation/MuonHits/plugins/SealModule.cc index 81be597a8556b..19adcc2b71c64 100644 --- a/Validation/MuonHits/plugins/SealModule.cc +++ b/Validation/MuonHits/plugins/SealModule.cc @@ -2,5 +2,5 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "DQMServices/Core/interface/DQMStore.h" -#include "Validation/MuonHits/src/MuonSimHitsValidAnalyzer.h" +#include "Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h" DEFINE_FWK_MODULE(MuonSimHitsValidAnalyzer); From 44b21ad50626407489f9c9a47b10a097948f46ca Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Wed, 27 Mar 2019 12:21:38 -0500 Subject: [PATCH 560/686] Bugfix --- Validation/MuonHits/src/ME0SimHitMatcher.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index a7982522c7d2e..f3961758d3afe 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -23,7 +23,7 @@ void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe hasGeometry_ = false; std::cout << "+++ Info: ME0 geometry is unavailable. +++\n"; } - ME0SimHitMatcher::init(iEvent, iSetup); + MuonSimHitMatcher::init(iEvent, iSetup); } /// do the matching From aeaf726b47c88949ef27f7fa2bc9cdece6eb3c64 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Wed, 3 Apr 2019 17:28:39 +0200 Subject: [PATCH 561/686] Apply google clang style --- .../MuonHits/interface/CSCSimHitMatcher.h | 22 +- .../MuonHits/interface/DTSimHitMatcher.h | 31 +- .../MuonHits/interface/GEMSimHitMatcher.h | 25 +- .../MuonHits/interface/ME0SimHitMatcher.h | 24 +- Validation/MuonHits/interface/MuonHitHelper.h | 97 +++-- .../MuonHits/interface/MuonSimHitMatcher.h | 45 +-- .../MuonHits/interface/RPCSimHitMatcher.h | 12 +- Validation/MuonHits/src/CSCSimHitMatcher.cc | 368 +++++++++--------- Validation/MuonHits/src/DTSimHitMatcher.cc | 351 ++++++++--------- Validation/MuonHits/src/GEMSimHitMatcher.cc | 310 +++++++-------- Validation/MuonHits/src/ME0SimHitMatcher.cc | 172 ++++---- Validation/MuonHits/src/MuonHitHelper.cc | 258 ++++++------ Validation/MuonHits/src/MuonSimHitMatcher.cc | 102 +++-- Validation/MuonHits/src/RPCSimHitMatcher.cc | 118 +++--- 14 files changed, 933 insertions(+), 1002 deletions(-) diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h index d895cb307eeeb..72f654e89cd44 100644 --- a/Validation/MuonHits/interface/CSCSimHitMatcher.h +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -11,12 +11,10 @@ #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" -class CSCSimHitMatcher : public MuonSimHitMatcher -{ -public: - +class CSCSimHitMatcher : public MuonSimHitMatcher { + public: // constructor - CSCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + CSCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~CSCSimHitMatcher() {} @@ -40,15 +38,17 @@ class CSCSimHitMatcher : public MuonSimHitMatcher bool hitStation(int, int) const; // number of stations with hits in at least X layers - int nStations(int nl=4) const; + int nStations(int nl = 4) const; // #layers with hits int nLayersWithHitsInChamber(unsigned int) const; - // How many CSC chambers with minimum number of layer with simhits did this simtrack get? + // How many CSC chambers with minimum number of layer with simhits did this + // simtrack get? int nCoincidenceChambers(int min_n_layers = 4) const; - // calculated the fitted position in a given layer for CSC simhits in a chamber + // calculated the fitted position in a given layer for CSC simhits in a + // chamber GlobalPoint simHitPositionKeyLayer(unsigned int chamberid) const; // local bending in a CSC chamber @@ -70,9 +70,9 @@ class CSCSimHitMatcher : public MuonSimHitMatcher void camberIdsToString(const std::set&) const; -private: - - void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& csc_hits); + private: + void matchSimHitsToSimTrack(std::vector track_ids, + const edm::PSimHitContainer& csc_hits); edm::ESHandle csc_geom_; }; diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h index 17324ffd38287..4881fa98353b2 100644 --- a/Validation/MuonHits/interface/DTSimHitMatcher.h +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -8,15 +8,13 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ -#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" -class DTSimHitMatcher : public MuonSimHitMatcher -{ -public: - +class DTSimHitMatcher : public MuonSimHitMatcher { + public: // constructor - DTSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + DTSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~DTSimHitMatcher() {} @@ -46,7 +44,7 @@ class DTSimHitMatcher : public MuonSimHitMatcher bool hitStation(int, int, int) const; // number of stations with hits in at least X layers - int nStations(int nsl=1, int nl=3) const; + int nStations(int nsl = 1, int nl = 3) const; // access to DT hits int nCellsWithHitsInLayer(unsigned int) const; @@ -63,18 +61,21 @@ class DTSimHitMatcher : public MuonSimHitMatcher // calculate the average position at the second station GlobalPoint simHitsMeanPositionStation(int n) const; - std::set hitWiresInDTLayerId(unsigned int, int margin_n_wires = 0) const; // DT - std::set hitWiresInDTSuperLayerId(unsigned int, int margin_n_wires = 0) const; // DT - std::set hitWiresInDTChamberId(unsigned int, int margin_n_wires = 0) const; // DT + std::set hitWiresInDTLayerId( + unsigned int, int margin_n_wires = 0) const; // DT + std::set hitWiresInDTSuperLayerId( + unsigned int, int margin_n_wires = 0) const; // DT + std::set hitWiresInDTChamberId( + unsigned int, int margin_n_wires = 0) const; // DT void dtChamberIdsToString(const std::set&) const; -private: - - void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& hits); + private: + void matchSimHitsToSimTrack(std::vector track_ids, + const edm::PSimHitContainer& hits); - std::map layer_to_hits_; - std::map superlayer_to_hits_; + std::map layer_to_hits_; + std::map superlayer_to_hits_; edm::ESHandle dt_geom_; }; diff --git a/Validation/MuonHits/interface/GEMSimHitMatcher.h b/Validation/MuonHits/interface/GEMSimHitMatcher.h index c821fdbd0246e..ebe1f0272791a 100644 --- a/Validation/MuonHits/interface/GEMSimHitMatcher.h +++ b/Validation/MuonHits/interface/GEMSimHitMatcher.h @@ -8,15 +8,13 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ -#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" -class GEMSimHitMatcher : public MuonSimHitMatcher -{ -public: - +class GEMSimHitMatcher : public MuonSimHitMatcher { + public: // constructor - GEMSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + GEMSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~GEMSimHitMatcher() {} @@ -31,7 +29,8 @@ class GEMSimHitMatcher : public MuonSimHitMatcher std::set detIds(int gem_type = MuonHitHelper::GEM_ALL) const; // chamber detIds with SimHits - std::set chamberIds(int gem_type = MuonHitHelper::GEM_ALL) const; + std::set chamberIds( + int gem_type = MuonHitHelper::GEM_ALL) const; // GEM detid's with hits in 2 layers of coincidence pads // those are layer==1 only detid's @@ -50,7 +49,7 @@ class GEMSimHitMatcher : public MuonSimHitMatcher bool hitStation(int, int) const; // number of stations with hits in at least X layers - int nStations(int nl=2) const; + int nStations(int nl = 2) const; // #layers with hits int nLayersWithHitsInSuperChamber(unsigned int) const; @@ -62,7 +61,7 @@ class GEMSimHitMatcher : public MuonSimHitMatcher int nCoincidencePadsWithHits() const; // transverse position in GEM - float simHitsGEMCentralPosition(const edm::PSimHitContainer& sim_hits) const; + float simHitsGEMCentralPosition(const edm::PSimHitContainer& sim_hits) const; // calculate average strip number for a provided collection of simhits float simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const; @@ -74,13 +73,13 @@ class GEMSimHitMatcher : public MuonSimHitMatcher // what unique partitions numbers were hit by this simtrack? std::set hitPartitions() const; -private: - - void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& hits); + private: + void matchSimHitsToSimTrack(std::vector track_ids, + const edm::PSimHitContainer& hits); edm::ESHandle gem_geom_; - std::map superchamber_to_hits_; + std::map superchamber_to_hits_; // detids with hits in pads std::map > detids_to_pads_; diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h index 9fc40262f81fc..9c81acef33cbb 100644 --- a/Validation/MuonHits/interface/ME0SimHitMatcher.h +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -8,15 +8,13 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ -#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include "Validation/MuonHits/interface/MuonSimHitMatcher.h" -class ME0SimHitMatcher : public MuonSimHitMatcher -{ -public: - +class ME0SimHitMatcher : public MuonSimHitMatcher { + public: // constructor - ME0SimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + ME0SimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~ME0SimHitMatcher() {} @@ -43,9 +41,11 @@ class ME0SimHitMatcher : public MuonSimHitMatcher int nLayersWithHitsInSuperChamber(unsigned int) const; // ME0 superchamber detIds with SimHits >=4 layers of coincidence pads - std::set superChamberIdsCoincidences(int min_n_layers = 4) const; + std::set superChamberIdsCoincidences( + int min_n_layers = 4) const; - // How many ME0 chambers with minimum number of layer with simhits did this simtrack get? + // How many ME0 chambers with minimum number of layer with simhits did this + // simtrack get? int nCoincidenceChambers(int min_n_layers = 4) const; // calculate average strip for a provided collection of simhits @@ -60,9 +60,9 @@ class ME0SimHitMatcher : public MuonSimHitMatcher // How many pads with simhits in ME0 did this simtrack get? int nPadsWithHits() const; -private: - - void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& me0_hits); + private: + void matchSimHitsToSimTrack(std::vector track_ids, + const edm::PSimHitContainer& me0_hits); edm::ESHandle me0_geom_; @@ -72,7 +72,7 @@ class ME0SimHitMatcher : public MuonSimHitMatcher // detids with hits in 2-layer pad coincidences std::map > detids_to_copads_; - std::map superChamber_to_hits_; + std::map superChamber_to_hits_; }; #endif diff --git a/Validation/MuonHits/interface/MuonHitHelper.h b/Validation/MuonHits/interface/MuonHitHelper.h index c02f004cbfe76..fd97dfd9645c8 100644 --- a/Validation/MuonHits/interface/MuonHitHelper.h +++ b/Validation/MuonHits/interface/MuonHitHelper.h @@ -3,40 +3,91 @@ #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" -#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" -class MuonHitHelper -{ +class MuonHitHelper { public: - /// CSC chamber types, according to CSCDetId::iChamberType() - enum CSCType {CSC_ALL = 0, CSC_ME11, - CSC_ME1a, CSC_ME1b, CSC_ME12, CSC_ME13, CSC_ME21, - CSC_ME22, CSC_ME31, CSC_ME32, CSC_ME41, CSC_ME42}; + enum CSCType { + CSC_ALL = 0, + CSC_ME11, + CSC_ME1a, + CSC_ME1b, + CSC_ME12, + CSC_ME13, + CSC_ME21, + CSC_ME22, + CSC_ME31, + CSC_ME32, + CSC_ME41, + CSC_ME42 + }; /// GEM chamber types - enum GEMType {GEM_ALL = 0, GEM_ME11, GEM_ME21}; + enum GEMType { GEM_ALL = 0, GEM_ME11, GEM_ME21 }; /// RPC endcap chamber types - enum RPCType {RPC_ALL = 0, - RPC_ME12, RPC_ME13, RPC_ME22, RPC_ME23, RPC_ME31, - RPC_ME32, RPC_ME33, RPC_ME41, RPC_ME42, RPC_ME43, - RPC_MB01, RPC_MB02, RPC_MB03, RPC_MB04, - RPC_MB11p, RPC_MB12p, RPC_MB13p, RPC_MB14p, - RPC_MB21p, RPC_MB22p, RPC_MB23p, RPC_MB24p, - RPC_MB11n, RPC_MB12n, RPC_MB13n, RPC_MB14n, - RPC_MB21n, RPC_MB22n, RPC_MB23n, RPC_MB24n}; + enum RPCType { + RPC_ALL = 0, + RPC_ME12, + RPC_ME13, + RPC_ME22, + RPC_ME23, + RPC_ME31, + RPC_ME32, + RPC_ME33, + RPC_ME41, + RPC_ME42, + RPC_ME43, + RPC_MB01, + RPC_MB02, + RPC_MB03, + RPC_MB04, + RPC_MB11p, + RPC_MB12p, + RPC_MB13p, + RPC_MB14p, + RPC_MB21p, + RPC_MB22p, + RPC_MB23p, + RPC_MB24p, + RPC_MB11n, + RPC_MB12n, + RPC_MB13n, + RPC_MB14n, + RPC_MB21n, + RPC_MB22n, + RPC_MB23n, + RPC_MB24n + }; /// DT chamber types - enum DTType {DT_ALL = 0, - DT_MB01, DT_MB02, DT_MB03, DT_MB04, - DT_MB11p, DT_MB12p, DT_MB13p, DT_MB14p, - DT_MB21p, DT_MB22p, DT_MB23p, DT_MB24p, - DT_MB11n, DT_MB12n, DT_MB13n, DT_MB14n, - DT_MB21n, DT_MB22n, DT_MB23n, DT_MB24n}; + enum DTType { + DT_ALL = 0, + DT_MB01, + DT_MB02, + DT_MB03, + DT_MB04, + DT_MB11p, + DT_MB12p, + DT_MB13p, + DT_MB14p, + DT_MB21p, + DT_MB22p, + DT_MB23p, + DT_MB24p, + DT_MB11n, + DT_MB12n, + DT_MB13n, + DT_MB14n, + DT_MB21n, + DT_MB22n, + DT_MB23n, + DT_MB24n + }; /// check detid type static bool isDT(unsigned int detId); diff --git a/Validation/MuonHits/interface/MuonSimHitMatcher.h b/Validation/MuonHits/interface/MuonSimHitMatcher.h index e111b72cc5747..eb99675850064 100644 --- a/Validation/MuonHits/interface/MuonSimHitMatcher.h +++ b/Validation/MuonHits/interface/MuonSimHitMatcher.h @@ -8,34 +8,32 @@ Author: Sven Dildick (TAMU), Tao Huang (TAMU) */ -#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/Math/interface/deltaPhi.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" +#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" -#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" +#include "SimDataFormats/Vertex/interface/SimVertexContainer.h" #include "Validation/MuonHits/interface/MuonHitHelper.h" -#include "DataFormats/Math/interface/deltaPhi.h" -#include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" -#include #include #include +#include -class MuonSimHitMatcher -{ +class MuonSimHitMatcher { public: - // constructor - MuonSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + MuonSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~MuonSimHitMatcher() {} @@ -62,18 +60,17 @@ class MuonSimHitMatcher // calculate Global average position for a provided collection of simhits GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer& sim_hits) const; - // calculate Global average momentum for a provided collection of simhits in CSC + // calculate Global average momentum for a provided collection of simhits in + // CSC GlobalVector simHitsMeanMomentum(const edm::PSimHitContainer& sim_hits) const; // calculate the average position at the second station GlobalPoint simHitsMeanPositionStation(int n) const; -protected: - - std::vector - getIdsOfSimTrackShower(unsigned trk_id, - const edm::SimTrackContainer& simTracks, - const edm::SimVertexContainer& simVertices); + protected: + std::vector getIdsOfSimTrackShower( + unsigned trk_id, const edm::SimTrackContainer& simTracks, + const edm::SimVertexContainer& simVertices); bool verboseSimTrack_; bool simMuOnly_; @@ -103,8 +100,8 @@ class MuonSimHitMatcher // selected hits edm::PSimHitContainer hits_; - std::map detid_to_hits_; - std::map chamber_to_hits_; + std::map detid_to_hits_; + std::map chamber_to_hits_; edm::ParameterSet simHitPSet_; }; diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h index 8d196bb849600..cc5f640ff046c 100644 --- a/Validation/MuonHits/interface/RPCSimHitMatcher.h +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -11,12 +11,10 @@ #include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "Validation/MuonHits/interface/MuonSimHitMatcher.h" -class RPCSimHitMatcher : public MuonSimHitMatcher -{ +class RPCSimHitMatcher : public MuonSimHitMatcher { public: - // constructor - RPCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector && iC); + RPCSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC); // destructor ~RPCSimHitMatcher() {} @@ -43,9 +41,9 @@ class RPCSimHitMatcher : public MuonSimHitMatcher std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; -private: - - void matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& rpc_hits); + private: + void matchSimHitsToSimTrack(std::vector track_ids, + const edm::PSimHitContainer& rpc_hits); edm::ESHandle rpc_geom_; }; diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index a112ce88f5be1..7cce1d53206b7 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -2,20 +2,21 @@ using namespace std; -CSCSimHitMatcher::CSCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) - : MuonSimHitMatcher(ps, std::move(iC)) -{ +CSCSimHitMatcher::CSCSimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) + : MuonSimHitMatcher(ps, std::move(iC)) { simHitPSet_ = ps.getParameterSet("cscSimHit"); verbose_ = simHitPSet_.getParameter("verbose"); simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); - simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + simHitInput_ = iC.consumes( + simHitPSet_.getParameter("inputTag")); } /// initialize the event -void CSCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void CSCSimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { iSetup.get().get(csc_geom_); if (csc_geom_.isValid()) { geometry_ = &*csc_geom_; @@ -27,115 +28,100 @@ void CSCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe } /// do the matching -void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout<<"nTrackIds "<(cout, " ")); cout<(cout, " ")); + cout << endl; } } } } } -void -CSCSimHitMatcher::matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& hits) -{ - for (const auto& track_id: track_ids) - { - for (const auto& h: hits) - { +void CSCSimHitMatcher::matchSimHitsToSimTrack( + std::vector track_ids, const edm::PSimHitContainer& hits) { + for (const auto& track_id : track_ids) { + for (const auto& h : hits) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; // discard electron hits in the CSC chambers if (discardEleHits_ && pdgid == 11) continue; - const CSCDetId& layer_id( h.detUnitId() ); + const CSCDetId& layer_id(h.detUnitId()); hits_.push_back(h); - detid_to_hits_[ h.detUnitId() ].push_back(h); - chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + detid_to_hits_[h.detUnitId()].push_back(h); + chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h); } } } - -std::set -CSCSimHitMatcher::detIds(int csc_type) const -{ +std::set CSCSimHitMatcher::detIds(int csc_type) const { std::set result; - for (const auto& p: detid_to_hits_) - { + for (const auto& p : detid_to_hits_) { const auto& id = p.first; - if (csc_type > 0) - { + if (csc_type > 0) { CSCDetId detId(id); - if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) continue; + if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) + continue; } result.insert(id); } return result; } - -std::set -CSCSimHitMatcher::chamberIds(int csc_type) const -{ +std::set CSCSimHitMatcher::chamberIds(int csc_type) const { std::set result; - for (const auto& p: chamber_to_hits_) - { + for (const auto& p : chamber_to_hits_) { const auto& id = p.first; - if (csc_type > 0) - { + if (csc_type > 0) { CSCDetId detId(id); - if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) continue; + if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type) + continue; } result.insert(id); } return result; } - -int -CSCSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const -{ +int CSCSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const { set layers_with_hits; - for (const auto& h: MuonSimHitMatcher::hitsInChamber(detid)) { + for (const auto& h : MuonSimHitMatcher::hitsInChamber(detid)) { const CSCDetId& idd(h.detUnitId()); layers_with_hits.insert(idd.layer()); } return layers_with_hits.size(); } - -bool -CSCSimHitMatcher::hitStation(int st, int nlayers) const -{ - int nst=0; - for(const auto& ddt: chamberIds()) { - +bool CSCSimHitMatcher::hitStation(int st, int nlayers) const { + int nst = 0; + for (const auto& ddt : chamberIds()) { const CSCDetId id(ddt); int ri(id.ring()); - if (id.station()!=st) continue; + if (id.station() != st) continue; // ME1/a case - check the ME1/b chamber - if (st==1 and ri==4) { + if (st == 1 and ri == 4) { CSCDetId idME1b(id.endcap(), id.station(), 1, id.chamber(), 0); const int nl1a(nLayersWithHitsInChamber(id.rawId())); const int nl1b(nLayersWithHitsInChamber(idME1b.rawId())); @@ -143,7 +129,7 @@ CSCSimHitMatcher::hitStation(int st, int nlayers) const ++nst; } // ME1/b case - check the ME1/a chamber - else if (st==1 and ri==1) { + else if (st == 1 and ri == 1) { CSCDetId idME1a(id.endcap(), id.station(), 4, id.chamber(), 0); const int nl1a(nLayersWithHitsInChamber(idME1a.rawId())); const int nl1b(nLayersWithHitsInChamber(id.rawId())); @@ -160,107 +146,128 @@ CSCSimHitMatcher::hitStation(int st, int nlayers) const return nst; } -int -CSCSimHitMatcher::nStations(int nlayers) const -{ - return (hitStation(1, nlayers) + - hitStation(2, nlayers) + - hitStation(3, nlayers) + - hitStation(4, nlayers)); +int CSCSimHitMatcher::nStations(int nlayers) const { + return (hitStation(1, nlayers) + hitStation(2, nlayers) + + hitStation(3, nlayers) + hitStation(4, nlayers)); } -float -CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const -{ +float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { const CSCDetId cscid(detid); - if (nLayersWithHitsInChamber(detid)<6) return -100; - float phi_layer1=-10; - float phi_layer6=10; + if (nLayersWithHitsInChamber(detid) < 6) return -100; + float phi_layer1 = -10; + float phi_layer6 = 10; - if (cscid.station()==1 and (cscid.ring()==1 or cscid.ring()==4)){ + if (cscid.station() == 1 and (cscid.ring() == 1 or cscid.ring() == 4)) { // phi in layer 1 - const CSCDetId cscid1a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), 1); - const CSCDetId cscid1b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), 1); - const edm::PSimHitContainer& hits1a = MuonSimHitMatcher::hitsInDetId(cscid1a.rawId()); - const edm::PSimHitContainer& hits1b = MuonSimHitMatcher::hitsInDetId(cscid1b.rawId()); - const GlobalPoint& gp1a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1a.rawId())); - const GlobalPoint& gp1b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1b.rawId())); + const CSCDetId cscid1a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), + 1); + const CSCDetId cscid1b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), + 1); + const edm::PSimHitContainer& hits1a = + MuonSimHitMatcher::hitsInDetId(cscid1a.rawId()); + const edm::PSimHitContainer& hits1b = + MuonSimHitMatcher::hitsInDetId(cscid1b.rawId()); + const GlobalPoint& gp1a = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1a.rawId())); + const GlobalPoint& gp1b = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1b.rawId())); if (!hits1a.empty() and !hits1b.empty()) - phi_layer1 = (gp1a.phi()+gp1b.phi())/2.0; - else if (!hits1a.empty()) phi_layer1 = gp1a.phi(); - else if (!hits1b.empty()) phi_layer1 = gp1b.phi(); - else std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; + phi_layer1 = (gp1a.phi() + gp1b.phi()) / 2.0; + else if (!hits1a.empty()) + phi_layer1 = gp1a.phi(); + else if (!hits1b.empty()) + phi_layer1 = gp1b.phi(); + else + std::cerr << " no hits in layer1, cant not find global phi of hits " + << std::endl; // phi in layer 6 - const CSCDetId cscid6a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), 6); - const CSCDetId cscid6b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), 6); - const edm::PSimHitContainer& hits6a = MuonSimHitMatcher::hitsInDetId(cscid6a.rawId()); - const edm::PSimHitContainer& hits6b = MuonSimHitMatcher::hitsInDetId(cscid6b.rawId()); - const GlobalPoint& gp6a = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6a.rawId())); - const GlobalPoint& gp6b = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6b.rawId())); + const CSCDetId cscid6a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), + 6); + const CSCDetId cscid6b(cscid.endcap(), cscid.station(), 1, cscid.chamber(), + 6); + const edm::PSimHitContainer& hits6a = + MuonSimHitMatcher::hitsInDetId(cscid6a.rawId()); + const edm::PSimHitContainer& hits6b = + MuonSimHitMatcher::hitsInDetId(cscid6b.rawId()); + const GlobalPoint& gp6a = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6a.rawId())); + const GlobalPoint& gp6b = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6b.rawId())); if (!hits6a.empty() and !hits6b.empty()) - phi_layer6 = (gp6a.phi()+gp6b.phi())/2.0; - else if (!hits6a.empty()) phi_layer6 = gp6a.phi(); - else if (!hits6b.empty()) phi_layer6 = gp6b.phi(); - else std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; + phi_layer6 = (gp6a.phi() + gp6b.phi()) / 2.0; + else if (!hits6a.empty()) + phi_layer6 = gp6a.phi(); + else if (!hits6b.empty()) + phi_layer6 = gp6b.phi(); + else + std::cerr << " no hits in layer6, cant not find global phi of hits " + << std::endl; - - } - else { + } else { // phi in layer 1 - const CSCDetId cscid1(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 1); - const edm::PSimHitContainer& hits1 = MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); - if (hits1.empty()) std::cerr <<" no hits in layer1, cant not find global phi of hits " << std::endl; - const GlobalPoint& gp1 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); + const CSCDetId cscid1(cscid.endcap(), cscid.station(), cscid.ring(), + cscid.chamber(), 1); + const edm::PSimHitContainer& hits1 = + MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); + if (hits1.empty()) + std::cerr << " no hits in layer1, cant not find global phi of hits " + << std::endl; + const GlobalPoint& gp1 = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); phi_layer1 = gp1.phi(); // phi in layer 6 - const CSCDetId cscid6(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 6); - const edm::PSimHitContainer& hits6 = MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); - if (hits6.empty()) std::cerr <<" no hits in layer6, cant not find global phi of hits " << std::endl; - const GlobalPoint& gp6 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); + const CSCDetId cscid6(cscid.endcap(), cscid.station(), cscid.ring(), + cscid.chamber(), 6); + const edm::PSimHitContainer& hits6 = + MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); + if (hits6.empty()) + std::cerr << " no hits in layer6, cant not find global phi of hits " + << std::endl; + const GlobalPoint& gp6 = + simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); phi_layer6 = gp6.phi(); } - return deltaPhi(phi_layer6,phi_layer1); + return deltaPhi(phi_layer6, phi_layer1); } - -float -CSCSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const -{ +float CSCSimHitMatcher::simHitsMeanStrip( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); float s; const auto& d = h.detUnitId(); - s = dynamic_cast(geometry_)->layer(d)->geometry()->strip(lp); + s = dynamic_cast(geometry_) + ->layer(d) + ->geometry() + ->strip(lp); // convert to half-strip: s *= 2.; sums += s; ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } - -float -CSCSimHitMatcher::simHitsMeanWG(const edm::PSimHitContainer& sim_hits) const -{ +float CSCSimHitMatcher::simHitsMeanWG( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); float s; const auto& d = h.detUnitId(); // find nearest wire - const auto& layerG(dynamic_cast(geometry_)->layer(d)->geometry()); + const auto& layerG( + dynamic_cast(geometry_)->layer(d)->geometry()); int nearestWire(layerG->nearestWire(lp)); // then find the corresponding wire group s = layerG->wireGroup(nearestWire); @@ -268,22 +275,24 @@ CSCSimHitMatcher::simHitsMeanWG(const edm::PSimHitContainer& sim_hits) const ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } - - - -std::set -CSCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const -{ +std::set CSCSimHitMatcher::hitStripsInDetId(unsigned int detid, + int margin_n_strips) const { set result; const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); CSCDetId id(detid); - int max_nstrips = dynamic_cast(geometry_)->layer(id)->geometry()->numberOfStrips(); - for (const auto& h: simhits) { + int max_nstrips = dynamic_cast(geometry_) + ->layer(id) + ->geometry() + ->numberOfStrips(); + for (const auto& h : simhits) { const LocalPoint& lp = h.entryPoint(); - int central_strip = dynamic_cast(geometry_)->layer(id)->geometry()->nearestStrip(lp); + int central_strip = dynamic_cast(geometry_) + ->layer(id) + ->geometry() + ->nearestStrip(lp); int smin = central_strip - margin_n_strips; smin = (smin > 0) ? smin : 1; int smax = central_strip + margin_n_strips; @@ -293,17 +302,19 @@ CSCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) cons return result; } - -std::set -CSCSimHitMatcher::hitWiregroupsInDetId(unsigned int detid, int margin_n_wg) const -{ +std::set CSCSimHitMatcher::hitWiregroupsInDetId(unsigned int detid, + int margin_n_wg) const { set result; const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); CSCDetId id(detid); - int max_n_wg = dynamic_cast(geometry_)->layer(id)->geometry()->numberOfWireGroups(); - for (const auto& h: simhits) { + int max_n_wg = dynamic_cast(geometry_) + ->layer(id) + ->geometry() + ->numberOfWireGroups(); + for (const auto& h : simhits) { const LocalPoint& lp = h.entryPoint(); - const auto& layer_geo = dynamic_cast(geometry_)->layer(id)->geometry(); + const auto& layer_geo = + dynamic_cast(geometry_)->layer(id)->geometry(); int central_wg = layer_geo->wireGroup(layer_geo->nearestWire(lp)); int wg_min = central_wg - margin_n_wg; wg_min = (wg_min > 0) ? wg_min : 1; @@ -314,65 +325,58 @@ CSCSimHitMatcher::hitWiregroupsInDetId(unsigned int detid, int margin_n_wg) cons return result; } -int -CSCSimHitMatcher::nCoincidenceChambers(int min_n_layers) const -{ +int CSCSimHitMatcher::nCoincidenceChambers(int min_n_layers) const { int result = 0; const auto& chamber_ids = chamberIds(0); - for (const auto& id: chamber_ids) - { + for (const auto& id : chamber_ids) { if (nLayersWithHitsInChamber(id) >= min_n_layers) result += 1; } return result; } -void -CSCSimHitMatcher::chamberIdsToString(const std::set& set) const -{ - for (const auto& p: set) { +void CSCSimHitMatcher::chamberIdsToString( + const std::set& set) const { + for (const auto& p : set) { CSCDetId detId(p); std::cout << " " << detId << "\n"; } } - -std::set -CSCSimHitMatcher::chamberIdsStation(int station) const -{ +std::set CSCSimHitMatcher::chamberIdsStation(int station) const { set result; - switch(station){ - case 1: { - const auto& p1(chamberIds(MuonHitHelper::CSC_ME1a)); - const auto& p2(chamberIds(MuonHitHelper::CSC_ME1b)); - const auto& p3(chamberIds(MuonHitHelper::CSC_ME12)); - const auto& p4(chamberIds(MuonHitHelper::CSC_ME13)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - result.insert(p3.begin(),p3.end()); - result.insert(p4.begin(),p4.end()); - break; - } - case 2: { - const auto& p1(chamberIds(MuonHitHelper::CSC_ME21)); - const auto& p2(chamberIds(MuonHitHelper::CSC_ME22)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - break; - } - case 3: { - const auto& p1(chamberIds(MuonHitHelper::CSC_ME31)); - const auto& p2(chamberIds(MuonHitHelper::CSC_ME32)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - break; - } - case 4: { - const auto& p1(chamberIds(MuonHitHelper::CSC_ME41)); - const auto& p2(chamberIds(MuonHitHelper::CSC_ME42)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - break; - } + switch (station) { + case 1: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME1a)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME1b)); + const auto& p3(chamberIds(MuonHitHelper::CSC_ME12)); + const auto& p4(chamberIds(MuonHitHelper::CSC_ME13)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + result.insert(p3.begin(), p3.end()); + result.insert(p4.begin(), p4.end()); + break; + } + case 2: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME21)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME22)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + break; + } + case 3: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME31)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME32)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + break; + } + case 4: { + const auto& p1(chamberIds(MuonHitHelper::CSC_ME41)); + const auto& p2(chamberIds(MuonHitHelper::CSC_ME42)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + break; + } }; return result; } diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index ecd14f62637b6..3e5d593a27862 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -2,20 +2,21 @@ using namespace std; -DTSimHitMatcher::DTSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) - : MuonSimHitMatcher(ps, std::move(iC)) -{ +DTSimHitMatcher::DTSimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) + : MuonSimHitMatcher(ps, std::move(iC)) { simHitPSet_ = ps.getParameterSet("dtSimHit"); verbose_ = simHitPSet_.getParameter("verbose"); simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); - simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + simHitInput_ = iC.consumes( + simHitPSet_.getParameter("inputTag")); } /// initialize the event -void DTSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void DTSimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { iSetup.get().get(dt_geom_); if (dt_geom_.isValid()) { geometry_ = &*dt_geom_; @@ -27,140 +28,125 @@ void DTSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSet } /// do the matching -void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout<<"nTrackIds "< track_ids, const edm::PSimHitContainer& dt_hits) -{ - for (const auto& track_id: track_ids) - { - for (const auto& h: dt_hits) - { +void DTSimHitMatcher::matchSimHitsToSimTrack( + std::vector track_ids, const edm::PSimHitContainer& dt_hits) { + for (const auto& track_id : track_ids) { + for (const auto& h : dt_hits) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; // discard electron hits in the DT chambers if (discardEleHits_ && pdgid == 11) continue; - const DTWireId layer_id( h.detUnitId() ); - detid_to_hits_[ h.detUnitId() ].push_back(h); + const DTWireId layer_id(h.detUnitId()); + detid_to_hits_[h.detUnitId()].push_back(h); hits_.push_back(h); - layer_to_hits_ [ layer_id.layerId().rawId() ].push_back(h); - superlayer_to_hits_ [ layer_id.superlayerId().rawId() ].push_back(h); - chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + layer_to_hits_[layer_id.layerId().rawId()].push_back(h); + superlayer_to_hits_[layer_id.superlayerId().rawId()].push_back(h); + chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h); } } } -std::set -DTSimHitMatcher::detIds(int dt_type) const -{ +std::set DTSimHitMatcher::detIds(int dt_type) const { std::set result; - for (const auto& p: detid_to_hits_) - { + for (const auto& p : detid_to_hits_) { const auto& id = p.first; - if (dt_type > 0) - { + if (dt_type > 0) { DTWireId detId(id); - if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) continue; + if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) + continue; } result.insert(id); } return result; } - -std::set -DTSimHitMatcher::chamberIds(int dt_type) const -{ +std::set DTSimHitMatcher::chamberIds(int dt_type) const { std::set result; - for (const auto& p: chamber_to_hits_) - { + for (const auto& p : chamber_to_hits_) { const auto& id = p.first; - if (dt_type > 0) - { + if (dt_type > 0) { DTChamberId detId(id); - if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) continue; + if (MuonHitHelper::toDTType(detId.wheel(), detId.station()) != dt_type) + continue; } result.insert(id); } return result; } -std::set -DTSimHitMatcher::layerIds() const -{ +std::set DTSimHitMatcher::layerIds() const { std::set result; - for (const auto& p: layer_to_hits_) result.insert(p.first); + for (const auto& p : layer_to_hits_) result.insert(p.first); return result; } -std::set -DTSimHitMatcher::superlayerIds() const -{ +std::set DTSimHitMatcher::superlayerIds() const { std::set result; - for (const auto& p: superlayer_to_hits_) result.insert(p.first); + for (const auto& p : superlayer_to_hits_) result.insert(p.first); return result; } -const edm::PSimHitContainer& -DTSimHitMatcher::hitsInLayer(unsigned int detid) const -{ +const edm::PSimHitContainer& DTSimHitMatcher::hitsInLayer( + unsigned int detid) const { if (!MuonHitHelper::isDT(detid)) return no_hits_; const DTWireId id(detid); - if (layer_to_hits_.find(id.layerId().rawId()) == layer_to_hits_.end()) return no_hits_; + if (layer_to_hits_.find(id.layerId().rawId()) == layer_to_hits_.end()) + return no_hits_; return layer_to_hits_.at(id.layerId().rawId()); } -const edm::PSimHitContainer& -DTSimHitMatcher::hitsInSuperLayer(unsigned int detid) const -{ +const edm::PSimHitContainer& DTSimHitMatcher::hitsInSuperLayer( + unsigned int detid) const { if (!MuonHitHelper::isDT(detid)) return no_hits_; const DTWireId id(detid); - if (superlayer_to_hits_.find(id.superlayerId().rawId()) == superlayer_to_hits_.end()) return no_hits_; + if (superlayer_to_hits_.find(id.superlayerId().rawId()) == + superlayer_to_hits_.end()) + return no_hits_; return superlayer_to_hits_.at(id.superlayerId().rawId()); } -const edm::PSimHitContainer& -DTSimHitMatcher::hitsInChamber(unsigned int detid) const -{ +const edm::PSimHitContainer& DTSimHitMatcher::hitsInChamber( + unsigned int detid) const { if (!MuonHitHelper::isDT(detid)) return no_hits_; const DTWireId id(detid); - if (chamber_to_hits_.find(id.chamberId().rawId()) == chamber_to_hits_.end()) return no_hits_; + if (chamber_to_hits_.find(id.chamberId().rawId()) == chamber_to_hits_.end()) + return no_hits_; return chamber_to_hits_.at(id.chamberId().rawId()); } -bool -DTSimHitMatcher::hitStation(int st, int nsuperlayers, int nlayers) const -{ - int nst=0; - for(const auto& ddt: chamberIds()) { - +bool DTSimHitMatcher::hitStation(int st, int nsuperlayers, int nlayers) const { + int nst = 0; + for (const auto& ddt : chamberIds()) { const DTChamberId id(ddt); - if (id.station()!=st) continue; + if (id.station() != st) continue; // require at least 1 superlayer const int nsl(nSuperLayersWithHitsInChamber(id.rawId())); @@ -174,22 +160,17 @@ DTSimHitMatcher::hitStation(int st, int nsuperlayers, int nlayers) const return nst; } -int -DTSimHitMatcher::nStations(int nsuperlayers, int nlayers) const -{ +int DTSimHitMatcher::nStations(int nsuperlayers, int nlayers) const { return (hitStation(1, nsuperlayers, nlayers) + hitStation(2, nsuperlayers, nlayers) + hitStation(3, nsuperlayers, nlayers) + hitStation(4, nsuperlayers, nlayers)); } - -int -DTSimHitMatcher::nCellsWithHitsInLayer(unsigned int detid) const -{ +int DTSimHitMatcher::nCellsWithHitsInLayer(unsigned int detid) const { set layers_with_hits; const auto& hits = hitsInLayer(detid); - for (const auto& h: hits) { + for (const auto& h : hits) { if (MuonHitHelper::isDT(detid)) { const DTWireId idd(h.detUnitId()); layers_with_hits.insert(idd.wire()); @@ -198,12 +179,10 @@ DTSimHitMatcher::nCellsWithHitsInLayer(unsigned int detid) const return layers_with_hits.size(); } -int -DTSimHitMatcher::nLayersWithHitsInSuperLayer(unsigned int detid) const -{ +int DTSimHitMatcher::nLayersWithHitsInSuperLayer(unsigned int detid) const { set layers_with_hits; const auto& hits = hitsInSuperLayer(detid); - for (const auto& h: hits) { + for (const auto& h : hits) { if (MuonHitHelper::isDT(detid)) { const DTLayerId idd(h.detUnitId()); layers_with_hits.insert(idd.layer()); @@ -212,12 +191,10 @@ DTSimHitMatcher::nLayersWithHitsInSuperLayer(unsigned int detid) const return layers_with_hits.size(); } -int -DTSimHitMatcher::nSuperLayersWithHitsInChamber(unsigned int detid) const -{ +int DTSimHitMatcher::nSuperLayersWithHitsInChamber(unsigned int detid) const { set sl_with_hits; const auto& hits = MuonSimHitMatcher::hitsInChamber(detid); - for (const auto& h: hits) { + for (const auto& h : hits) { if (MuonHitHelper::isDT(detid)) { const DTSuperLayerId idd(h.detUnitId()); sl_with_hits.insert(idd.superLayer()); @@ -226,59 +203,63 @@ DTSimHitMatcher::nSuperLayersWithHitsInChamber(unsigned int detid) const return sl_with_hits.size(); } -int -DTSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const -{ +int DTSimHitMatcher::nLayersWithHitsInChamber(unsigned int detid) const { int nLayers = 0; - const auto& superLayers(dynamic_cast(geometry_)->chamber(DTChamberId(detid))->superLayers()); - for (const auto& sl: superLayers) { + const auto& superLayers(dynamic_cast(geometry_) + ->chamber(DTChamberId(detid)) + ->superLayers()); + for (const auto& sl : superLayers) { nLayers += nLayersWithHitsInSuperLayer(sl->id().rawId()); } return nLayers; } -float -DTSimHitMatcher::simHitsMeanWire(const edm::PSimHitContainer& sim_hits) const -{ +float DTSimHitMatcher::simHitsMeanWire( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); float s; const auto& d = h.detUnitId(); - if (MuonHitHelper::isDT(d)) - { + if (MuonHitHelper::isDT(d)) { // find nearest wire - s = dynamic_cast(geometry_)->layer(DTLayerId(d))->specificTopology().channel(lp); - } - else continue; + s = dynamic_cast(geometry_) + ->layer(DTLayerId(d)) + ->specificTopology() + .channel(lp); + } else + continue; sums += s; ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } -std::set -DTSimHitMatcher::hitWiresInDTLayerId(unsigned int detid, int margin_n_wires) const -{ +std::set DTSimHitMatcher::hitWiresInDTLayerId( + unsigned int detid, int margin_n_wires) const { set result; - if ( MuonHitHelper::isDT(detid) ) { + if (MuonHitHelper::isDT(detid)) { DTLayerId id(detid); - int max_nwires = dynamic_cast(geometry_)->layer(id)->specificTopology().channels(); + int max_nwires = dynamic_cast(geometry_) + ->layer(id) + ->specificTopology() + .channels(); for (int wn = 0; wn <= max_nwires; ++wn) { - DTWireId wid(id,wn); - for (const auto& h: MuonSimHitMatcher::hitsInDetId(wid.rawId())) { - if (verbose_) cout << "central DTWireId "<< wid << " simhit " < 0) ? smin : 1; int smax = wn + margin_n_wires; smax = (smax <= max_nwires) ? smax : max_nwires; for (int ss = smin; ss <= smax; ++ss) { DTWireId widd(id, ss); - if (verbose_) cout << "\tadding DTWireId to collection "<< widd << endl; + if (verbose_) + cout << "\tadding DTWireId to collection " << widd << endl; result.insert(widd.rawId()); } } @@ -287,101 +268,97 @@ DTSimHitMatcher::hitWiresInDTLayerId(unsigned int detid, int margin_n_wires) con return result; } - -std::set -DTSimHitMatcher::hitWiresInDTSuperLayerId(unsigned int detid, int margin_n_wires) const -{ +std::set DTSimHitMatcher::hitWiresInDTSuperLayerId( + unsigned int detid, int margin_n_wires) const { set result; - const auto& layers(dynamic_cast(geometry_)->superLayer(DTSuperLayerId(detid))->layers()); - for (const auto& l: layers) { - if (verbose_)cout << "hitWiresInDTSuperLayerId::l id "<id() << endl; + const auto& layers(dynamic_cast(geometry_) + ->superLayer(DTSuperLayerId(detid)) + ->layers()); + for (const auto& l : layers) { + if (verbose_) cout << "hitWiresInDTSuperLayerId::l id " << l->id() << endl; const auto& p(hitWiresInDTLayerId(l->id().rawId(), margin_n_wires)); - result.insert(p.begin(),p.end()); + result.insert(p.begin(), p.end()); } return result; } - -std::set -DTSimHitMatcher::hitWiresInDTChamberId(unsigned int detid, int margin_n_wires) const -{ +std::set DTSimHitMatcher::hitWiresInDTChamberId( + unsigned int detid, int margin_n_wires) const { set result; - const auto& superLayers(dynamic_cast(geometry_)->chamber(DTChamberId(detid))->superLayers()); - for (const auto& sl: superLayers) { - if (verbose_)cout << "hitWiresInDTChamberId::sl id "<id() << endl; + const auto& superLayers(dynamic_cast(geometry_) + ->chamber(DTChamberId(detid)) + ->superLayers()); + for (const auto& sl : superLayers) { + if (verbose_) cout << "hitWiresInDTChamberId::sl id " << sl->id() << endl; const auto& p(hitWiresInDTSuperLayerId(sl->id().rawId(), margin_n_wires)); - result.insert(p.begin(),p.end()); + result.insert(p.begin(), p.end()); } return result; } - -void -DTSimHitMatcher::dtChamberIdsToString(const std::set& set) const -{ - for (const auto& p: set) { +void DTSimHitMatcher::dtChamberIdsToString( + const std::set& set) const { + for (const auto& p : set) { DTChamberId detId(p); std::cout << " " << detId << "\n"; } } -std::set -DTSimHitMatcher::chamberIdsStation(int station) const -{ +std::set DTSimHitMatcher::chamberIdsStation(int station) const { set result; - switch(station){ - case 1: { - const auto& p1(chamberIds(MuonHitHelper::DT_MB21p)); - const auto& p2(chamberIds(MuonHitHelper::DT_MB11p)); - const auto& p3(chamberIds(MuonHitHelper::DT_MB01)); - const auto& p4(chamberIds(MuonHitHelper::DT_MB11n)); - const auto& p5(chamberIds(MuonHitHelper::DT_MB21n)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - result.insert(p3.begin(),p3.end()); - result.insert(p4.begin(),p4.end()); - result.insert(p5.begin(),p5.end()); - break; - } - case 2: { - const auto& p1(chamberIds(MuonHitHelper::DT_MB22p)); - const auto& p2(chamberIds(MuonHitHelper::DT_MB12p)); - const auto& p3(chamberIds(MuonHitHelper::DT_MB02)); - const auto& p4(chamberIds(MuonHitHelper::DT_MB12n)); - const auto& p5(chamberIds(MuonHitHelper::DT_MB22n)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - result.insert(p3.begin(),p3.end()); - result.insert(p4.begin(),p4.end()); - result.insert(p5.begin(),p5.end()); - break; - } - case 3: { - const auto& p1(chamberIds(MuonHitHelper::DT_MB23p)); - const auto& p2(chamberIds(MuonHitHelper::DT_MB13p)); - const auto& p3(chamberIds(MuonHitHelper::DT_MB03)); - const auto& p4(chamberIds(MuonHitHelper::DT_MB13n)); - const auto& p5(chamberIds(MuonHitHelper::DT_MB23n)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - result.insert(p3.begin(),p3.end()); - result.insert(p4.begin(),p4.end()); - result.insert(p5.begin(),p5.end()); - break; - } - case 4: { - const auto& p1(chamberIds(MuonHitHelper::DT_MB24p)); - const auto& p2(chamberIds(MuonHitHelper::DT_MB14p)); - const auto& p3(chamberIds(MuonHitHelper::DT_MB04)); - const auto& p4(chamberIds(MuonHitHelper::DT_MB14n)); - const auto& p5(chamberIds(MuonHitHelper::DT_MB24n)); - result.insert(p1.begin(),p1.end()); - result.insert(p2.begin(),p2.end()); - result.insert(p3.begin(),p3.end()); - result.insert(p4.begin(),p4.end()); - result.insert(p5.begin(),p5.end()); - break; - } + switch (station) { + case 1: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB21p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB11p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB01)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB11n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB21n)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + result.insert(p3.begin(), p3.end()); + result.insert(p4.begin(), p4.end()); + result.insert(p5.begin(), p5.end()); + break; + } + case 2: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB22p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB12p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB02)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB12n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB22n)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + result.insert(p3.begin(), p3.end()); + result.insert(p4.begin(), p4.end()); + result.insert(p5.begin(), p5.end()); + break; + } + case 3: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB23p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB13p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB03)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB13n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB23n)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + result.insert(p3.begin(), p3.end()); + result.insert(p4.begin(), p4.end()); + result.insert(p5.begin(), p5.end()); + break; + } + case 4: { + const auto& p1(chamberIds(MuonHitHelper::DT_MB24p)); + const auto& p2(chamberIds(MuonHitHelper::DT_MB14p)); + const auto& p3(chamberIds(MuonHitHelper::DT_MB04)); + const auto& p4(chamberIds(MuonHitHelper::DT_MB14n)); + const auto& p5(chamberIds(MuonHitHelper::DT_MB24n)); + result.insert(p1.begin(), p1.end()); + result.insert(p2.begin(), p2.end()); + result.insert(p3.begin(), p3.end()); + result.insert(p4.begin(), p4.end()); + result.insert(p5.begin(), p5.end()); + break; + } }; return result; } diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index 0bfa5f0eaa937..e05b154c81a47 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -2,20 +2,21 @@ using namespace std; -GEMSimHitMatcher::GEMSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) - : MuonSimHitMatcher(ps, std::move(iC)) -{ +GEMSimHitMatcher::GEMSimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) + : MuonSimHitMatcher(ps, std::move(iC)) { simHitPSet_ = ps.getParameterSet("gemSimHit"); verbose_ = simHitPSet_.getParameter("verbose"); simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); - simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + simHitInput_ = iC.consumes( + simHitPSet_.getParameter("inputTag")); } /// initialize the event -void GEMSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void GEMSimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { iSetup.get().get(gem_geom_); if (gem_geom_.isValid()) { geometry_ = dynamic_cast(&*gem_geom_); @@ -27,232 +28,217 @@ void GEMSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe } /// do the matching -void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout<<"nTrackIds "<(cout, " ")); cout<(cout, " ")); + cout << endl; } const auto& gem_sch_ids = superChamberIds(); - for (const auto& id: gem_sch_ids) { + for (const auto& id : gem_sch_ids) { const auto& gem_simhits = hitsInSuperChamber(id); const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); - cout<<"gemschid "< track_ids, const edm::PSimHitContainer& gem_hits) -{ - for (const auto& track_id: track_ids) - { - for (const auto& h: gem_hits) - { +void GEMSimHitMatcher::matchSimHitsToSimTrack( + std::vector track_ids, + const edm::PSimHitContainer& gem_hits) { + for (const auto& track_id : track_ids) { + for (const auto& h : gem_hits) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; // discard electron hits in the GEM chambers if (discardEleHits_ && pdgid == 11) continue; - const GEMDetId& p_id( h.detUnitId() ); - detid_to_hits_[ h.detUnitId() ].push_back(h); + const GEMDetId& p_id(h.detUnitId()); + detid_to_hits_[h.detUnitId()].push_back(h); hits_.push_back(h); - chamber_to_hits_[ p_id.chamberId().rawId() ].push_back(h); - superchamber_to_hits_[ p_id.superChamberId().rawId() ].push_back(h); + chamber_to_hits_[p_id.chamberId().rawId()].push_back(h); + superchamber_to_hits_[p_id.superChamberId().rawId()].push_back(h); } } // find pads with hits const auto& detids = detIds(); // find 2-layer coincidence pads with hits - for (const auto& d: detids) { + for (const auto& d : detids) { GEMDetId id(d); const auto& hits = hitsInDetId(d); - const auto& roll = dynamic_cast(geometry_)->etaPartition(id); - //int max_npads = roll->npads(); + const auto& roll = + dynamic_cast(geometry_)->etaPartition(id); + // int max_npads = roll->npads(); set pads; - for (const auto& h: hits) { + for (const auto& h : hits) { const LocalPoint& lp = h.entryPoint(); - pads.insert( 1 + static_cast(roll->padTopology().channel(lp)) ); + pads.insert(1 + static_cast(roll->padTopology().channel(lp))); } detids_to_pads_[d] = pads; } // find 2-layer coincidence pads with hits - for (const auto& d: detids) { + for (const auto& d : detids) { GEMDetId id1(d); if (id1.layer() != 1) continue; // find pads with hits in layer1 const auto& hits1 = hitsInDetId(d); - const auto& roll1 = dynamic_cast(geometry_)->etaPartition(id1); + const auto& roll1 = + dynamic_cast(geometry_)->etaPartition(id1); set pads1; set pads2; set copads; - for (const auto& h: hits1) { + for (const auto& h : hits1) { const LocalPoint& lp = h.entryPoint(); - pads1.insert( 1 + static_cast(roll1->padTopology().channel(lp)) ); - if (verbose_) std::cout <<"GEMHits detid1 "<(roll1->padTopology().channel(lp)) << std::endl; + pads1.insert(1 + static_cast(roll1->padTopology().channel(lp))); + if (verbose_) + std::cout << "GEMHits detid1 " << id1 << " pad1 " + << 1 + static_cast(roll1->padTopology().channel(lp)) + << std::endl; } // find pads with hits in layer2 - for (const auto& d2 : detids){ - //staggered geometry???? improve here !! + for (const auto& d2 : detids) { + // staggered geometry???? improve here !! GEMDetId id2(d2); // does layer 2 has simhits? - if (id2.layer() !=2 or - id2.region() != id1.region() or - id2.ring()!=id1.ring() or - id2.station()!=id1.station() or - abs(id2.roll()-id1.roll())>1) + if (id2.layer() != 2 or id2.region() != id1.region() or + id2.ring() != id1.ring() or id2.station() != id1.station() or + abs(id2.roll() - id1.roll()) > 1) continue; const auto& hits2 = hitsInDetId(id2()); - const auto& roll2 = dynamic_cast(geometry_)->etaPartition(id2); - for (const auto& h: hits2) { + const auto& roll2 = + dynamic_cast(geometry_)->etaPartition(id2); + for (const auto& h : hits2) { const LocalPoint& lp = h.entryPoint(); - pads2.insert( 1 + static_cast(roll2->padTopology().channel(lp)) ); - if (verbose_) std::cout <<"GEMHits detid2 "<(roll2->padTopology().channel(lp)) << std::endl; + pads2.insert(1 + static_cast(roll2->padTopology().channel(lp))); + if (verbose_) + std::cout << "GEMHits detid2 " << id2 << " pad2 " + << 1 + static_cast(roll2->padTopology().channel(lp)) + << std::endl; } } for (const auto& pad1 : pads1) { - for (const auto& pad2 : pads2){ - if (abs(pad1-pad2) <= 2) { - if (copads.find(pad1) == copads.end()) - copads.insert(pad1); - if (copads.find(pad2) == copads.end()) - copads.insert(pad2); + for (const auto& pad2 : pads2) { + if (abs(pad1 - pad2) <= 2) { + if (copads.find(pad1) == copads.end()) copads.insert(pad1); + if (copads.find(pad2) == copads.end()) copads.insert(pad2); } } } if (copads.empty()) continue; - //detids here is layer1 id + // detids here is layer1 id detids_to_copads_[d] = copads; } } -std::set -GEMSimHitMatcher::detIds(int gem_type) const -{ +std::set GEMSimHitMatcher::detIds(int gem_type) const { std::set result; - for (const auto& p: detid_to_hits_) - { + for (const auto& p : detid_to_hits_) { const auto& id = p.first; - if (gem_type > 0) - { + if (gem_type > 0) { GEMDetId detId(id); - if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) continue; + if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) + continue; } result.insert(id); } return result; } -std::set -GEMSimHitMatcher::detIdsCoincidences() const -{ +std::set GEMSimHitMatcher::detIdsCoincidences() const { std::set result; - for (const auto& p: detids_to_copads_) result.insert(p.first); + for (const auto& p : detids_to_copads_) result.insert(p.first); return result; } - -std::set -GEMSimHitMatcher::chamberIds(int gem_type) const -{ +std::set GEMSimHitMatcher::chamberIds(int gem_type) const { std::set result; - for (const auto& p: chamber_to_hits_) - { + for (const auto& p : chamber_to_hits_) { const auto& id = p.first; - if (gem_type > 0) - { + if (gem_type > 0) { GEMDetId detId(id); - if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) continue; + if (MuonHitHelper::toGEMType(detId.station(), detId.ring()) != gem_type) + continue; } result.insert(id); } return result; } - -std::set -GEMSimHitMatcher::superChamberIds() const -{ +std::set GEMSimHitMatcher::superChamberIds() const { std::set result; - for (const auto& p: superchamber_to_hits_) result.insert(p.first); + for (const auto& p : superchamber_to_hits_) result.insert(p.first); return result; } - -std::set -GEMSimHitMatcher::superChamberIdsCoincidences() const -{ +std::set GEMSimHitMatcher::superChamberIdsCoincidences() const { std::set result; - for (const auto& p: detids_to_copads_) - { + for (const auto& p : detids_to_copads_) { const GEMDetId& p_id(p.first); result.insert(p_id.superChamberId().rawId()); } return result; } - -const edm::PSimHitContainer& -GEMSimHitMatcher::hitsInSuperChamber(unsigned int detid) const -{ - if (MuonHitHelper::isGEM(detid)) - { +const edm::PSimHitContainer& GEMSimHitMatcher::hitsInSuperChamber( + unsigned int detid) const { + if (MuonHitHelper::isGEM(detid)) { const GEMDetId id(detid); - if (superchamber_to_hits_.find(id.chamberId().rawId()) == superchamber_to_hits_.end()) return no_hits_; + if (superchamber_to_hits_.find(id.chamberId().rawId()) == + superchamber_to_hits_.end()) + return no_hits_; return superchamber_to_hits_.at(id.chamberId().rawId()); } return no_hits_; } - -int -GEMSimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const -{ +int GEMSimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const { set layers_with_hits; const auto& hits = hitsInSuperChamber(detid); - for (const auto& h: hits) - { + for (const auto& h : hits) { const GEMDetId& idd(h.detUnitId()); layers_with_hits.insert(idd.layer()); } return layers_with_hits.size(); } - -bool -GEMSimHitMatcher::hitStation(int st, int nlayers) const -{ - int nst=0; - for(const auto& ddt: chamberIds()) { - +bool GEMSimHitMatcher::hitStation(int st, int nlayers) const { + int nst = 0; + for (const auto& ddt : chamberIds()) { const GEMDetId id(ddt); - if (id.station()!=st) continue; + if (id.station() != st) continue; const int nl(nLayersWithHitsInSuperChamber(id.rawId())); if (nl < nlayers) continue; @@ -261,130 +247,108 @@ GEMSimHitMatcher::hitStation(int st, int nlayers) const return nst; } -int -GEMSimHitMatcher::nStations(int nlayers) const -{ +int GEMSimHitMatcher::nStations(int nlayers) const { return (hitStation(1, nlayers) + hitStation(2, nlayers)); } -float -GEMSimHitMatcher::simHitsGEMCentralPosition(const edm::PSimHitContainer& sim_hits) const -{ - if (sim_hits.empty()) return -0.0; // point "zero" +float GEMSimHitMatcher::simHitsGEMCentralPosition( + const edm::PSimHitContainer& sim_hits) const { + if (sim_hits.empty()) return -0.0; // point "zero" float central = -0.0; size_t n = 0; - for (const auto& h: sim_hits) - { - LocalPoint lp( 0., 0., 0. );//local central + for (const auto& h : sim_hits) { + LocalPoint lp(0., 0., 0.); // local central GlobalPoint gp; - if ( MuonHitHelper::isGEM(h.detUnitId()) ) - { + if (MuonHitHelper::isGEM(h.detUnitId())) { gp = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp); } central = gp.perp(); - if (n>=1) std::cout <<"warning! find more than one simhits in GEM chamber " << std::endl; + if (n >= 1) + std::cout << "warning! find more than one simhits in GEM chamber " + << std::endl; ++n; } return central; } - - -float -GEMSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const -{ +float GEMSimHitMatcher::simHitsMeanStrip( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); const auto& d = h.detUnitId(); - sums += dynamic_cast(geometry_)->etaPartition(d)->strip(lp); + sums += + dynamic_cast(geometry_)->etaPartition(d)->strip(lp); ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } - -std::set -GEMSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const -{ +std::set GEMSimHitMatcher::hitStripsInDetId(unsigned int detid, + int margin_n_strips) const { set result; const auto& simhits = MuonSimHitMatcher::hitsInDetId(detid); GEMDetId id(detid); - int max_nstrips = dynamic_cast(geometry_)->etaPartition(id)->nstrips(); - for (const auto& h: simhits) - { - const LocalPoint& lp = h.entryPoint(); - int central_strip = static_cast(dynamic_cast(geometry_)->etaPartition(id)->topology().channel(lp)); - int smin = central_strip - margin_n_strips; - smin = (smin > 0) ? smin : 1; - int smax = central_strip + margin_n_strips; - smax = (smax <= max_nstrips) ? smax : max_nstrips; - for (int ss = smin; ss <= smax; ++ss) result.insert(ss); - } + int max_nstrips = + dynamic_cast(geometry_)->etaPartition(id)->nstrips(); + for (const auto& h : simhits) { + const LocalPoint& lp = h.entryPoint(); + int central_strip = + static_cast(dynamic_cast(geometry_) + ->etaPartition(id) + ->topology() + .channel(lp)); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } return result; } - -std::set -GEMSimHitMatcher::hitPadsInDetId(unsigned int detid) const -{ +std::set GEMSimHitMatcher::hitPadsInDetId(unsigned int detid) const { set none; if (detids_to_pads_.find(detid) == detids_to_pads_.end()) return none; return detids_to_pads_.at(detid); } - -std::set -GEMSimHitMatcher::hitCoPadsInDetId(unsigned int detid) const -{ +std::set GEMSimHitMatcher::hitCoPadsInDetId(unsigned int detid) const { set none; if (detids_to_copads_.find(detid) == detids_to_copads_.end()) return none; return detids_to_copads_.at(detid); } - -std::set -GEMSimHitMatcher::hitPartitions() const -{ +std::set GEMSimHitMatcher::hitPartitions() const { std::set result; const auto& detids = detIds(); - for (const auto& id: detids) - { + for (const auto& id : detids) { GEMDetId idd(id); - result.insert( idd.roll() ); + result.insert(idd.roll()); } return result; } - -int -GEMSimHitMatcher::nPadsWithHits() const -{ +int GEMSimHitMatcher::nPadsWithHits() const { int result = 0; const auto& pad_ids = detIds(); - for (const auto& id: pad_ids) - { + for (const auto& id : pad_ids) { result += hitPadsInDetId(id).size(); } return result; } - -int -GEMSimHitMatcher::nCoincidencePadsWithHits() const -{ +int GEMSimHitMatcher::nCoincidencePadsWithHits() const { int result = 0; const auto& copad_ids = detIdsCoincidences(); - for (const auto& id: copad_ids) - { + for (const auto& id : copad_ids) { result += hitCoPadsInDetId(id).size(); } return result; diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index f3961758d3afe..b2a6b8ecfba66 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -2,20 +2,21 @@ using namespace std; -ME0SimHitMatcher::ME0SimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) - : MuonSimHitMatcher(ps, std::move(iC)) -{ +ME0SimHitMatcher::ME0SimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) + : MuonSimHitMatcher(ps, std::move(iC)) { simHitPSet_ = ps.getParameterSet("me0SimHit"); verbose_ = simHitPSet_.getParameter("verbose"); simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); - simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + simHitInput_ = iC.consumes( + simHitPSet_.getParameter("inputTag")); } /// initialize the event -void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void ME0SimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { iSetup.get().get(me0_geom_); if (me0_geom_.isValid()) { geometry_ = &*me0_geom_; @@ -27,115 +28,108 @@ void ME0SimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe } /// do the matching -void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout<<"nTrackIds "<(cout, " ")); cout<(cout, " ")); + cout << endl; } } } } -void -ME0SimHitMatcher::matchSimHitsToSimTrack(std::vector track_ids, const edm::PSimHitContainer& me0_hits) -{ - for (const auto& track_id: track_ids) - { - for (const auto& h: me0_hits) - { +void ME0SimHitMatcher::matchSimHitsToSimTrack( + std::vector track_ids, + const edm::PSimHitContainer& me0_hits) { + for (const auto& track_id : track_ids) { + for (const auto& h : me0_hits) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; // discard electron hits in the ME0 chambers if (discardEleHits_ && std::abs(pdgid) == 11) continue; - const ME0DetId& layer_id( h.detUnitId() ); - detid_to_hits_[ h.detUnitId() ].push_back(h); + const ME0DetId& layer_id(h.detUnitId()); + detid_to_hits_[h.detUnitId()].push_back(h); hits_.push_back(h); - chamber_to_hits_[ layer_id.layerId().rawId() ].push_back(h); - superChamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + chamber_to_hits_[layer_id.layerId().rawId()].push_back(h); + superChamber_to_hits_[layer_id.chamberId().rawId()].push_back(h); } } // find pads with hits const auto& detids = detIds(); - for (const auto& d: detids) { + for (const auto& d : detids) { GEMDetId id(d); const auto& hits = hitsInDetId(d); - const auto& roll = dynamic_cast(geometry_)->etaPartition(id); - //int max_npads = roll->npads(); + const auto& roll = + dynamic_cast(geometry_)->etaPartition(id); + // int max_npads = roll->npads(); set pads; - for (const auto& h: hits) { + for (const auto& h : hits) { const LocalPoint& lp = h.entryPoint(); - pads.insert( 1 + static_cast(roll->padTopology().channel(lp)) ); + pads.insert(1 + static_cast(roll->padTopology().channel(lp))); } detids_to_pads_[d] = pads; } } -std::set -ME0SimHitMatcher::detIds() const -{ +std::set ME0SimHitMatcher::detIds() const { std::set result; - for (const auto& p: detid_to_hits_) result.insert(p.first); + for (const auto& p : detid_to_hits_) result.insert(p.first); return result; } -std::set -ME0SimHitMatcher::chamberIds() const -{ +std::set ME0SimHitMatcher::chamberIds() const { std::set result; - for (const auto& p: chamber_to_hits_) result.insert(p.first); + for (const auto& p : chamber_to_hits_) result.insert(p.first); return result; } -std::set -ME0SimHitMatcher::superChamberIds() const -{ +std::set ME0SimHitMatcher::superChamberIds() const { std::set result; - for (const auto& p: superChamber_to_hits_) result.insert(p.first); + for (const auto& p : superChamber_to_hits_) result.insert(p.first); return result; } -const edm::PSimHitContainer& -ME0SimHitMatcher::hitsInSuperChamber(unsigned int detid) const -{ - if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end()) return no_hits_; +const edm::PSimHitContainer& ME0SimHitMatcher::hitsInSuperChamber( + unsigned int detid) const { + if (superChamber_to_hits_.find(detid) == superChamber_to_hits_.end()) + return no_hits_; return superChamber_to_hits_.at(detid); } -int -ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const -{ +int ME0SimHitMatcher::nLayersWithHitsInSuperChamber(unsigned int detid) const { set layers_with_hits; const auto& hits = hitsInSuperChamber(detid); - for (const auto& h: hits) - { + for (const auto& h : hits) { const ME0DetId& idd(h.detUnitId()); layers_with_hits.insert(idd.layer()); } return layers_with_hits.size(); } -std::set -ME0SimHitMatcher::superChamberIdsCoincidences(int min_n_layers) const -{ +std::set ME0SimHitMatcher::superChamberIdsCoincidences( + int min_n_layers) const { set result; // loop over the super chamber Ids for (const auto& p : superChamberIds()) { @@ -146,21 +140,17 @@ ME0SimHitMatcher::superChamberIdsCoincidences(int min_n_layers) const return result; } -int ME0SimHitMatcher::nCoincidenceChambers(int min_n_layers) const -{ +int ME0SimHitMatcher::nCoincidenceChambers(int min_n_layers) const { return superChamberIdsCoincidences(min_n_layers).size(); } - -float -ME0SimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const -{ +float ME0SimHitMatcher::simHitsMeanStrip( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); float s; const auto& d = h.detUnitId(); @@ -169,61 +159,53 @@ ME0SimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } - -std::set -ME0SimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const -{ +std::set ME0SimHitMatcher::hitStripsInDetId(unsigned int detid, + int margin_n_strips) const { set result; const auto& simhits = hitsInDetId(detid); ME0DetId id(detid); - int max_nstrips = dynamic_cast(geometry_)->etaPartition(id)->nstrips(); - for (const auto& h: simhits) - { - const LocalPoint& lp = h.entryPoint(); - int central_strip = 1 + static_cast(dynamic_cast(geometry_)->etaPartition(id)->topology().channel(lp)); - int smin = central_strip - margin_n_strips; - smin = (smin > 0) ? smin : 1; - int smax = central_strip + margin_n_strips; - smax = (smax <= max_nstrips) ? smax : max_nstrips; - for (int ss = smin; ss <= smax; ++ss) result.insert(ss); - } + int max_nstrips = + dynamic_cast(geometry_)->etaPartition(id)->nstrips(); + for (const auto& h : simhits) { + const LocalPoint& lp = h.entryPoint(); + int central_strip = + 1 + static_cast(dynamic_cast(geometry_) + ->etaPartition(id) + ->topology() + .channel(lp)); + int smin = central_strip - margin_n_strips; + smin = (smin > 0) ? smin : 1; + int smax = central_strip + margin_n_strips; + smax = (smax <= max_nstrips) ? smax : max_nstrips; + for (int ss = smin; ss <= smax; ++ss) result.insert(ss); + } return result; } -std::set -ME0SimHitMatcher::hitPadsInDetId(unsigned int detid) const -{ +std::set ME0SimHitMatcher::hitPadsInDetId(unsigned int detid) const { set none; if (detids_to_pads_.find(detid) == detids_to_pads_.end()) return none; return detids_to_pads_.at(detid); } - -std::set -ME0SimHitMatcher::hitPartitions() const -{ +std::set ME0SimHitMatcher::hitPartitions() const { std::set result; const auto& detids = detIds(); - for (const auto& id: detids) - { + for (const auto& id : detids) { ME0DetId idd(id); - result.insert( idd.roll() ); + result.insert(idd.roll()); } return result; } - -int -ME0SimHitMatcher::nPadsWithHits() const -{ +int ME0SimHitMatcher::nPadsWithHits() const { int result = 0; const auto& pad_ids = detIds(); - for (const auto& id: pad_ids) - { + for (const auto& id : pad_ids) { result += hitPadsInDetId(id).size(); } return result; diff --git a/Validation/MuonHits/src/MuonHitHelper.cc b/Validation/MuonHits/src/MuonHitHelper.cc index a69395d2ea84d..ec3281ac78927 100644 --- a/Validation/MuonHits/src/MuonHitHelper.cc +++ b/Validation/MuonHits/src/MuonHitHelper.cc @@ -1,181 +1,165 @@ #include "Validation/MuonHits/interface/MuonHitHelper.h" -bool MuonHitHelper::isDT(unsigned int detId) -{ - return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::DT; +bool MuonHitHelper::isDT(unsigned int detId) { + return (DetId(detId)).det() == DetId::Muon && + (DetId(detId)).subdetId() == MuonSubdetId::DT; } -bool MuonHitHelper::isGEM(unsigned int detId) -{ - return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::GEM; +bool MuonHitHelper::isGEM(unsigned int detId) { + return (DetId(detId)).det() == DetId::Muon && + (DetId(detId)).subdetId() == MuonSubdetId::GEM; } -bool MuonHitHelper::isCSC(unsigned int detId) -{ - return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::CSC; +bool MuonHitHelper::isCSC(unsigned int detId) { + return (DetId(detId)).det() == DetId::Muon && + (DetId(detId)).subdetId() == MuonSubdetId::CSC; } -bool MuonHitHelper::isRPC(unsigned int detId) -{ - return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::RPC; +bool MuonHitHelper::isRPC(unsigned int detId) { + return (DetId(detId)).det() == DetId::Muon && + (DetId(detId)).subdetId() == MuonSubdetId::RPC; } -bool MuonHitHelper::isME0(unsigned int detId) -{ - return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::ME0; +bool MuonHitHelper::isME0(unsigned int detId) { + return (DetId(detId)).det() == DetId::Muon && + (DetId(detId)).subdetId() == MuonSubdetId::ME0; } -int MuonHitHelper::chamber(const DetId& id) -{ +int MuonHitHelper::chamber(const DetId& id) { if (id.det() != DetId::Detector::Muon) return -99; int chamberN = 0; - switch(id.subdetId()){ - case MuonSubdetId::GEM: - chamberN = GEMDetId(id).chamber(); - break; - case MuonSubdetId::RPC: - // works only for endcap!! - chamberN = RPCDetId(id).sector(); - break; - case MuonSubdetId::CSC: - chamberN = CSCDetId(id).chamber(); - break; - case MuonSubdetId::ME0: - chamberN = ME0DetId(id).chamber(); - break; - case MuonSubdetId::DT: - chamberN = DTChamberId(id).sector(); - break; + switch (id.subdetId()) { + case MuonSubdetId::GEM: + chamberN = GEMDetId(id).chamber(); + break; + case MuonSubdetId::RPC: + // works only for endcap!! + chamberN = RPCDetId(id).sector(); + break; + case MuonSubdetId::CSC: + chamberN = CSCDetId(id).chamber(); + break; + case MuonSubdetId::ME0: + chamberN = ME0DetId(id).chamber(); + break; + case MuonSubdetId::DT: + chamberN = DTChamberId(id).sector(); + break; }; return chamberN; } // return MuonType for a particular DetId -int MuonHitHelper::toGEMType(int st, int ri) -{ - if (st==1) { - if (ri==1) return GEM_ME11; - } - else if (st==2) { - if (ri==1) return GEM_ME21; +int MuonHitHelper::toGEMType(int st, int ri) { + if (st == 1) { + if (ri == 1) return GEM_ME11; + } else if (st == 2) { + if (ri == 1) return GEM_ME21; } return GEM_ALL; } -int MuonHitHelper::toRPCType(int re, int st, int ri) -{ +int MuonHitHelper::toRPCType(int re, int st, int ri) { // endcap - if (std::abs(re)==1) { - if (st ==1) { - if (ri==2) return RPC_ME12; - if (ri==3) return RPC_ME13; - } - else if (st ==2) { - if (ri==2) return RPC_ME22; - if (ri==3) return RPC_ME23; - } - else if (st ==3) { - if (ri==1) return RPC_ME31; - if (ri==2) return RPC_ME32; - if (ri==3) return RPC_ME33; - } - else if (st ==4) { - if (ri==1) return RPC_ME41; - if (ri==2) return RPC_ME42; - if (ri==3) return RPC_ME43; + if (std::abs(re) == 1) { + if (st == 1) { + if (ri == 2) return RPC_ME12; + if (ri == 3) return RPC_ME13; + } else if (st == 2) { + if (ri == 2) return RPC_ME22; + if (ri == 3) return RPC_ME23; + } else if (st == 3) { + if (ri == 1) return RPC_ME31; + if (ri == 2) return RPC_ME32; + if (ri == 3) return RPC_ME33; + } else if (st == 4) { + if (ri == 1) return RPC_ME41; + if (ri == 2) return RPC_ME42; + if (ri == 3) return RPC_ME43; } } // Barrel else { - if (ri==-2) { - if (st==1) return RPC_MB21n; - if (st==2) return RPC_MB22n; - if (st==3) return RPC_MB23n; - if (st==4) return RPC_MB24n; - } - else if (ri==-1) { - if (st==1) return RPC_MB11n; - if (st==2) return RPC_MB12n; - if (st==3) return RPC_MB13n; - if (st==4) return RPC_MB14n; - } - else if (ri==0) { - if (st==1) return RPC_MB01; - if (st==2) return RPC_MB02; - if (st==3) return RPC_MB03; - if (st==4) return RPC_MB04; - } - else if (ri==1) { - if (st==1) return RPC_MB11p; - if (st==2) return RPC_MB12p; - if (st==3) return RPC_MB13p; - if (st==4) return RPC_MB14p; - } - else if (ri==2) { - if (st==1) return RPC_MB21p; - if (st==2) return RPC_MB22p; - if (st==3) return RPC_MB23p; - if (st==4) return RPC_MB24p; + if (ri == -2) { + if (st == 1) return RPC_MB21n; + if (st == 2) return RPC_MB22n; + if (st == 3) return RPC_MB23n; + if (st == 4) return RPC_MB24n; + } else if (ri == -1) { + if (st == 1) return RPC_MB11n; + if (st == 2) return RPC_MB12n; + if (st == 3) return RPC_MB13n; + if (st == 4) return RPC_MB14n; + } else if (ri == 0) { + if (st == 1) return RPC_MB01; + if (st == 2) return RPC_MB02; + if (st == 3) return RPC_MB03; + if (st == 4) return RPC_MB04; + } else if (ri == 1) { + if (st == 1) return RPC_MB11p; + if (st == 2) return RPC_MB12p; + if (st == 3) return RPC_MB13p; + if (st == 4) return RPC_MB14p; + } else if (ri == 2) { + if (st == 1) return RPC_MB21p; + if (st == 2) return RPC_MB22p; + if (st == 3) return RPC_MB23p; + if (st == 4) return RPC_MB24p; } } return RPC_ALL; } -int MuonHitHelper::toDTType(int wh, int st) -{ - if (wh==-2) { - if (st==1) return DT_MB21n; - if (st==2) return DT_MB22n; - if (st==3) return DT_MB23n; - if (st==4) return DT_MB24n; +int MuonHitHelper::toDTType(int wh, int st) { + if (wh == -2) { + if (st == 1) return DT_MB21n; + if (st == 2) return DT_MB22n; + if (st == 3) return DT_MB23n; + if (st == 4) return DT_MB24n; } - if (wh==-1) { - if (st==1) return DT_MB11n; - if (st==2) return DT_MB12n; - if (st==3) return DT_MB13n; - if (st==4) return DT_MB14n; + if (wh == -1) { + if (st == 1) return DT_MB11n; + if (st == 2) return DT_MB12n; + if (st == 3) return DT_MB13n; + if (st == 4) return DT_MB14n; } - if (wh==0) { - if (st==1) return DT_MB01; - if (st==2) return DT_MB02; - if (st==3) return DT_MB03; - if (st==4) return DT_MB04; + if (wh == 0) { + if (st == 1) return DT_MB01; + if (st == 2) return DT_MB02; + if (st == 3) return DT_MB03; + if (st == 4) return DT_MB04; } - if (wh==1) { - if (st==1) return DT_MB11p; - if (st==2) return DT_MB12p; - if (st==3) return DT_MB13p; - if (st==4) return DT_MB14p; + if (wh == 1) { + if (st == 1) return DT_MB11p; + if (st == 2) return DT_MB12p; + if (st == 3) return DT_MB13p; + if (st == 4) return DT_MB14p; } - if (wh==2) { - if (st==1) return DT_MB21p; - if (st==2) return DT_MB22p; - if (st==3) return DT_MB23p; - if (st==4) return DT_MB24p; + if (wh == 2) { + if (st == 1) return DT_MB21p; + if (st == 2) return DT_MB22p; + if (st == 3) return DT_MB23p; + if (st == 4) return DT_MB24p; } return DT_ALL; } -int MuonHitHelper::toCSCType(int st, int ri) -{ - if (st==1) { - if (ri==0) return CSC_ME11; - if (ri==1) return CSC_ME1b; - if (ri==2) return CSC_ME12; - if (ri==3) return CSC_ME13; - if (ri==4) return CSC_ME1a; - } - else if (st==2) { - if (ri==1) return CSC_ME21; - if (ri==2) return CSC_ME22; - } - else if (st==3) { - if (ri==1) return CSC_ME31; - if (ri==2) return CSC_ME32; - } - else if (st==4) { - if (ri==1) return CSC_ME41; - if (ri==2) return CSC_ME42; +int MuonHitHelper::toCSCType(int st, int ri) { + if (st == 1) { + if (ri == 0) return CSC_ME11; + if (ri == 1) return CSC_ME1b; + if (ri == 2) return CSC_ME12; + if (ri == 3) return CSC_ME13; + if (ri == 4) return CSC_ME1a; + } else if (st == 2) { + if (ri == 1) return CSC_ME21; + if (ri == 2) return CSC_ME22; + } else if (st == 3) { + if (ri == 1) return CSC_ME31; + if (ri == 2) return CSC_ME32; + } else if (st == 4) { + if (ri == 1) return CSC_ME41; + if (ri == 2) return CSC_ME42; } return CSC_ALL; } diff --git a/Validation/MuonHits/src/MuonSimHitMatcher.cc b/Validation/MuonHits/src/MuonSimHitMatcher.cc index c8b17d22776ba..60e6b105adc84 100644 --- a/Validation/MuonHits/src/MuonSimHitMatcher.cc +++ b/Validation/MuonHits/src/MuonSimHitMatcher.cc @@ -4,19 +4,21 @@ using namespace std; -MuonSimHitMatcher::MuonSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) -{ +MuonSimHitMatcher::MuonSimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) { const auto& simVertex = ps.getParameterSet("simVertex"); const auto& simTrack = ps.getParameterSet("simTrack"); verboseSimTrack_ = simTrack.getParameter("verbose"); - simVertexInput_ = iC.consumes(simVertex.getParameter("inputTag")); - simTrackInput_ = iC.consumes(simTrack.getParameter("inputTag")); + simVertexInput_ = iC.consumes( + simVertex.getParameter("inputTag")); + simTrackInput_ = iC.consumes( + simTrack.getParameter("inputTag")); } /// initialize the event -void MuonSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void MuonSimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { hasGeometry_ = true; iEvent.getByToken(simTrackInput_, simTracksH_); @@ -25,8 +27,7 @@ void MuonSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iS } /// do the matching -void MuonSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void MuonSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { simTracks_ = *simTracksH_.product(); simVertices_ = *simVerticesH_.product(); simHits_ = *simHitsH_.product(); @@ -34,118 +35,105 @@ void MuonSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) // fill trkId2Index association: int no = 0; trkid_to_index_.clear(); - for (const auto& t: simTracks_) { + for (const auto& t : simTracks_) { trkid_to_index_[t.trackId()] = no; no++; } - vector track_ids = getIdsOfSimTrackShower(track.trackId(), simTracks_, simVertices_); + track_ids_ = + getIdsOfSimTrackShower(track.trackId(), simTracks_, simVertices_); if (verboseSimTrack_) { std::cout << "Printing track_ids" << std::endl; - for (const auto& id: track_ids) std::cout << "id: " << id << std::endl; + for (const auto& id : track_ids_) std::cout << "id: " << id << std::endl; } } -std::vector -MuonSimHitMatcher::getIdsOfSimTrackShower(unsigned int initial_trk_id, - const edm::SimTrackContainer & simTracks, const edm::SimVertexContainer & simVertices) -{ +std::vector MuonSimHitMatcher::getIdsOfSimTrackShower( + unsigned int initial_trk_id, const edm::SimTrackContainer& simTracks, + const edm::SimVertexContainer& simVertices) { vector result; result.push_back(initial_trk_id); if (!simMuOnly_) return result; - for (const auto& t: simTracks_) - { + for (const auto& t : simTracks_) { SimTrack last_trk = t; - //if (std::abs(t.type()) != 13) continue; + // if (std::abs(t.type()) != 13) continue; bool is_child = false; - while (true) - { - if ( last_trk.noVertex() ) break; - if ( simVertices_[last_trk.vertIndex()].noParent() ) break; + while (true) { + if (last_trk.noVertex()) break; + if (simVertices_[last_trk.vertIndex()].noParent()) break; unsigned parentId = simVertices_[last_trk.vertIndex()].parentIndex(); - if ( parentId == initial_trk_id ) - { + if (parentId == initial_trk_id) { is_child = true; break; } - const auto& association = trkid_to_index_.find( parentId ); - if ( association == trkid_to_index_.end() ) break; + const auto& association = trkid_to_index_.find(parentId); + if (association == trkid_to_index_.end()) break; - last_trk = simTracks_[ association->second ]; + last_trk = simTracks_[association->second]; } - if (is_child) - { + if (is_child) { result.push_back(t.trackId()); } } return result; } -const edm::PSimHitContainer& -MuonSimHitMatcher::simHits(int sub) const -{ +const edm::PSimHitContainer& MuonSimHitMatcher::simHits(int sub) const { return hits_; } -const edm::PSimHitContainer& -MuonSimHitMatcher::hitsInDetId(unsigned int detid) const -{ +const edm::PSimHitContainer& MuonSimHitMatcher::hitsInDetId( + unsigned int detid) const { if (detid_to_hits_.find(detid) == detid_to_hits_.end()) return no_hits_; return detid_to_hits_.at(detid); } - -const edm::PSimHitContainer& -MuonSimHitMatcher::hitsInChamber(unsigned int detid) const -{ +const edm::PSimHitContainer& MuonSimHitMatcher::hitsInChamber( + unsigned int detid) const { if (chamber_to_hits_.find(detid) == chamber_to_hits_.end()) return no_hits_; return chamber_to_hits_.at(detid); } - -GlobalPoint -MuonSimHitMatcher::simHitsMeanPosition(const edm::PSimHitContainer& sim_hits) const -{ - if (sim_hits.empty()) return GlobalPoint(); // point "zero" +GlobalPoint MuonSimHitMatcher::simHitsMeanPosition( + const edm::PSimHitContainer& sim_hits) const { + if (sim_hits.empty()) return GlobalPoint(); // point "zero" float sumx, sumy, sumz; sumx = sumy = sumz = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); - const GlobalPoint& gp = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp); + const GlobalPoint& gp = + geometry_->idToDet(h.detUnitId())->surface().toGlobal(lp); sumx += gp.x(); sumy += gp.y(); sumz += gp.z(); ++n; } if (n == 0) return GlobalPoint(); - return GlobalPoint(sumx/n, sumy/n, sumz/n); + return GlobalPoint(sumx / n, sumy / n, sumz / n); } -GlobalVector -MuonSimHitMatcher::simHitsMeanMomentum(const edm::PSimHitContainer& sim_hits) const -{ - if (sim_hits.empty()) return GlobalVector(); // point "zero" +GlobalVector MuonSimHitMatcher::simHitsMeanMomentum( + const edm::PSimHitContainer& sim_hits) const { + if (sim_hits.empty()) return GlobalVector(); // point "zero" float sumx, sumy, sumz; sumx = sumy = sumz = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalVector& lv = h.momentumAtEntry(); - const GlobalVector& gv = geometry_->idToDet(h.detUnitId())->surface().toGlobal(lv); + const GlobalVector& gv = + geometry_->idToDet(h.detUnitId())->surface().toGlobal(lv); sumx += gv.x(); sumy += gv.y(); sumz += gv.z(); ++n; } if (n == 0) return GlobalVector(); - return GlobalVector(sumx/n, sumy/n, sumz/n); + return GlobalVector(sumx / n, sumy / n, sumz / n); } - diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index 117b014779e69..84825e89fedd5 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -3,20 +3,21 @@ using namespace std; -RPCSimHitMatcher::RPCSimHitMatcher(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) - : MuonSimHitMatcher(ps, std::move(iC)) -{ +RPCSimHitMatcher::RPCSimHitMatcher(const edm::ParameterSet& ps, + edm::ConsumesCollector&& iC) + : MuonSimHitMatcher(ps, std::move(iC)) { simHitPSet_ = ps.getParameterSet("rpcSimHit"); verbose_ = simHitPSet_.getParameter("verbose"); simMuOnly_ = simHitPSet_.getParameter("simMuOnly"); discardEleHits_ = simHitPSet_.getParameter("discardEleHits"); - simHitInput_ = iC.consumes(simHitPSet_.getParameter("inputTag")); + simHitInput_ = iC.consumes( + simHitPSet_.getParameter("inputTag")); } /// initialize the event -void RPCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void RPCSimHitMatcher::init(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { iSetup.get().get(rpc_geom_); if (rpc_geom_.isValid()) { geometry_ = &*rpc_geom_; @@ -28,136 +29,121 @@ void RPCSimHitMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSe } /// do the matching -void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) -{ +void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout<<"nSimHits "<(cout, " ")); cout<(cout, " ")); + cout << endl; } } } - } - - -void -RPCSimHitMatcher::matchSimHitsToSimTrack(std::vector track_ids_, const edm::PSimHitContainer& hits) -{ - for (const auto& track_id: track_ids_) - { - for (const auto& h: hits) - { +void RPCSimHitMatcher::matchSimHitsToSimTrack( + std::vector track_ids_, const edm::PSimHitContainer& hits) { + for (const auto& track_id : track_ids_) { + for (const auto& h : hits) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; // discard electron hits in the RPC chambers if (discardEleHits_ && pdgid == 11) continue; - const RPCDetId& layer_id( h.detUnitId() ); - detid_to_hits_[ h.detUnitId() ].push_back(h); + const RPCDetId& layer_id(h.detUnitId()); + detid_to_hits_[h.detUnitId()].push_back(h); hits_.push_back(h); - chamber_to_hits_[ layer_id.chamberId().rawId() ].push_back(h); + chamber_to_hits_[layer_id.chamberId().rawId()].push_back(h); } } } - -std::set -RPCSimHitMatcher::detIds(int type) const -{ +std::set RPCSimHitMatcher::detIds(int type) const { std::set result; - for (const auto& p: detid_to_hits_) - { + for (const auto& p : detid_to_hits_) { const auto& id = p.first; - if (type > 0) - { + if (type > 0) { RPCDetId detId(id); - if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type) continue; + if (MuonHitHelper::toRPCType(detId.region(), detId.station(), + detId.ring()) != type) + continue; } result.insert(id); } return result; } - -std::set -RPCSimHitMatcher::chamberIds(int type) const -{ +std::set RPCSimHitMatcher::chamberIds(int type) const { std::set result; - for (const auto& p: chamber_to_hits_) - { + for (const auto& p : chamber_to_hits_) { const auto& id = p.first; - if (type > 0) - { + if (type > 0) { RPCDetId detId(id); - if (MuonHitHelper::toRPCType(detId.region(), detId.station(), detId.ring()) != type) continue; + if (MuonHitHelper::toRPCType(detId.region(), detId.station(), + detId.ring()) != type) + continue; } result.insert(id); } return result; } -bool -RPCSimHitMatcher::hitStation(int st) const -{ - int nst=0; - for(const auto& ddt: chamberIds(0)) { +bool RPCSimHitMatcher::hitStation(int st) const { + int nst = 0; + for (const auto& ddt : chamberIds(0)) { const RPCDetId id(ddt); - if (id.station()!=st) continue; + if (id.station() != st) continue; ++nst; } return nst; } -int -RPCSimHitMatcher::nStations() const -{ +int RPCSimHitMatcher::nStations() const { return (hitStation(1) + hitStation(2) + hitStation(3) + hitStation(4)); } -float -RPCSimHitMatcher::simHitsMeanStrip(const edm::PSimHitContainer& sim_hits) const -{ +float RPCSimHitMatcher::simHitsMeanStrip( + const edm::PSimHitContainer& sim_hits) const { if (sim_hits.empty()) return -1.f; float sums = 0.f; size_t n = 0; - for (const auto& h: sim_hits) - { + for (const auto& h : sim_hits) { const LocalPoint& lp = h.entryPoint(); const auto& d = h.detUnitId(); sums += dynamic_cast(geometry_)->roll(d)->strip(lp); ++n; } if (n == 0) return -1.f; - return sums/n; + return sums / n; } - -std::set -RPCSimHitMatcher::hitStripsInDetId(unsigned int detid, int margin_n_strips) const -{ +std::set RPCSimHitMatcher::hitStripsInDetId(unsigned int detid, + int margin_n_strips) const { set result; RPCDetId id(detid); - for (const auto& roll: dynamic_cast(geometry_)->chamber(id)->rolls()) { + for (const auto& roll : + dynamic_cast(geometry_)->chamber(id)->rolls()) { int max_nstrips = roll->nstrips(); - for (const auto& h: MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) { + for (const auto& h : MuonSimHitMatcher::hitsInDetId(roll->id().rawId())) { const LocalPoint& lp = h.entryPoint(); int central_strip = static_cast(roll->topology().channel(lp)); int smin = central_strip - margin_n_strips; From b2f22812cc0e0c848c122c5ab4dc6bdeff57f5d2 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Wed, 10 Apr 2019 17:28:28 +0200 Subject: [PATCH 562/686] Remove unused variable in Geometry/MTDNumberingBuilder , pointed by clang warning --- Geometry/MTDNumberingBuilder/plugins/CmsMTDSubStrctBuilder.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/plugins/CmsMTDSubStrctBuilder.cc b/Geometry/MTDNumberingBuilder/plugins/CmsMTDSubStrctBuilder.cc index ec8a9bd33dfb0..2dc1835c3175b 100644 --- a/Geometry/MTDNumberingBuilder/plugins/CmsMTDSubStrctBuilder.cc +++ b/Geometry/MTDNumberingBuilder/plugins/CmsMTDSubStrctBuilder.cc @@ -9,10 +9,6 @@ #include -namespace { - constexpr std::array sides{ { "PositiveZ","NegativeZ" } }; -} - CmsMTDSubStrctBuilder::CmsMTDSubStrctBuilder() {} From e010a192156d757c030817c872ee774dfedba79a Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Wed, 10 Apr 2019 18:03:29 +0200 Subject: [PATCH 563/686] Suggestions by @fabiocos --- Validation/MuonHits/plugins/BuildFile.xml | 1 - .../plugins/MuonSimHitsValidAnalyzer.h | 17 ++----- Validation/MuonHits/src/CSCSimHitMatcher.cc | 24 +++++---- Validation/MuonHits/src/DTSimHitMatcher.cc | 34 ++++++++----- Validation/MuonHits/src/GEMSimHitMatcher.cc | 49 ++++++++++--------- Validation/MuonHits/src/ME0SimHitMatcher.cc | 23 +++++---- Validation/MuonHits/src/MuonSimHitMatcher.cc | 4 +- Validation/MuonHits/src/RPCSimHitMatcher.cc | 25 +++++----- 8 files changed, 95 insertions(+), 82 deletions(-) diff --git a/Validation/MuonHits/plugins/BuildFile.xml b/Validation/MuonHits/plugins/BuildFile.xml index 93dd4cd7147ac..027a53565f395 100644 --- a/Validation/MuonHits/plugins/BuildFile.xml +++ b/Validation/MuonHits/plugins/BuildFile.xml @@ -8,6 +8,5 @@ - diff --git a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h index e4e0fa4d9346e..3bbf5fd382201 100644 --- a/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h +++ b/Validation/MuonHits/plugins/MuonSimHitsValidAnalyzer.h @@ -12,13 +12,11 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "DataFormats/GeometrySurface/interface/BoundPlane.h" -#include "DataFormats/DetId/interface/DetId.h" -#include -#include -#include +#include "DQMServices/Core/interface/DQMStore.h" +#include "DQMServices/Core/interface/MonitorElement.h" +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" /// muon CSC, DT and RPC geometry info #include "Geometry/Records/interface/MuonGeometryRecord.h" @@ -27,22 +25,13 @@ #include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "DataFormats/MuonDetId/interface/MuonSubdetId.h" -/// muon CSC detector id -#include "DataFormats/MuonDetId/interface/CSCDetId.h" - /// data in edm::event -//#include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include "SimDataFormats/Vertex/interface/SimVertexContainer.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -/// helper files -#include -#include "CLHEP/Units/GlobalSystemOfUnits.h" - #include - #include #include #include diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index 7cce1d53206b7..415535b36c058 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -22,7 +22,8 @@ void CSCSimHitMatcher::init(const edm::Event& iEvent, geometry_ = &*csc_geom_; } else { hasGeometry_ = false; - std::cout << "+++ Info: CSC geometry is unavailable. +++\n"; + edm::LogWarning("CSCSimHitMatcher") + << "+++ Info: CSC geometry is unavailable. +++\n"; } MuonSimHitMatcher::init(iEvent, iSetup); } @@ -35,9 +36,11 @@ void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout << "nTrackIds " << track_ids_.size() << " nSelectedCSCSimHits " - << hits_.size() << endl; - cout << "detids CSC " << detIds(0).size() << endl; + edm::LogInfo("CSCSimHitMatcher") + << "nTrackIds " << track_ids_.size() << " nSelectedCSCSimHits " + << hits_.size() << endl; + edm::LogInfo("CSCSimHitMatcher") + << "detids CSC " << detIds(0).size() << endl; for (const auto& id : detIds(0)) { const auto& simhits = hitsInDetId(id); @@ -45,13 +48,14 @@ void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { const auto& strips = hitStripsInDetId(id); CSCDetId cscid(id); if (cscid.station() == 1 and (cscid.ring() == 1 or cscid.ring() == 4)) { - cout << "cscdetid " << CSCDetId(id) << ": " << simhits.size() << " " - << simhits_gp.phi() << " " << detid_to_hits_[id].size() << endl; - cout << "nStrip " << strips.size() << endl; - cout << "strips : "; + edm::LogInfo("CSCSimHitMatcher") + << "cscdetid " << CSCDetId(id) << ": " << simhits.size() << " " + << simhits_gp.phi() << " " << detid_to_hits_[id].size() << endl; + edm::LogInfo("CSCSimHitMatcher") + << "nStrip " << strips.size() << endl; + edm::LogInfo("CSCSimHitMatcher") << "strips : "; std::copy(strips.begin(), strips.end(), ostream_iterator(cout, " ")); - cout << endl; } } } @@ -338,7 +342,7 @@ void CSCSimHitMatcher::chamberIdsToString( const std::set& set) const { for (const auto& p : set) { CSCDetId detId(p); - std::cout << " " << detId << "\n"; + edm::LogInfo("CSCSimHitMatcher") << " " << detId << "\n"; } } diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index 3e5d593a27862..194b273e7935d 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -22,7 +22,8 @@ void DTSimHitMatcher::init(const edm::Event& iEvent, geometry_ = &*dt_geom_; } else { hasGeometry_ = false; - std::cout << "+++ Info: DT geometry is unavailable. +++\n"; + edm::LogWarning("DTSimHitMatcher") + << "+++ Info: DT geometry is unavailable. +++\n"; } MuonSimHitMatcher::init(iEvent, iSetup); } @@ -35,17 +36,20 @@ void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " - << hits_.size() << endl; - cout << "detids GEM " << detIds(0).size() << endl; + edm::LogInfo("DTSimHitMatcher") + << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " + << hits_.size() << endl; + edm::LogInfo("DTSimHitMatcher") + << "detids GEM " << detIds(0).size() << endl; const auto& dt_det_ids = detIds(0); for (const auto& id : dt_det_ids) { const auto& dt_simhits = MuonSimHitMatcher::hitsInDetId(id); const auto& dt_simhits_gp = simHitsMeanPosition(dt_simhits); - cout << "DTWireId " << DTWireId(id) << ": nHits " << dt_simhits.size() - << " eta " << dt_simhits_gp.eta() << " phi " << dt_simhits_gp.phi() - << " nCh " << chamber_to_hits_[id].size() << endl; + edm::LogInfo("DTSimHitMatcher") + << "DTWireId " << DTWireId(id) << ": nHits " << dt_simhits.size() + << " eta " << dt_simhits_gp.eta() << " phi " << dt_simhits_gp.phi() + << " nCh " << chamber_to_hits_[id].size() << endl; } } } @@ -251,7 +255,8 @@ std::set DTSimHitMatcher::hitWiresInDTLayerId( DTWireId wid(id, wn); for (const auto& h : MuonSimHitMatcher::hitsInDetId(wid.rawId())) { if (verbose_) - cout << "central DTWireId " << wid << " simhit " << h << endl; + edm::LogInfo("DTSimHitMatcher") + << "central DTWireId " << wid << " simhit " << h << endl; int smin = wn - margin_n_wires; smin = (smin > 0) ? smin : 1; int smax = wn + margin_n_wires; @@ -259,7 +264,8 @@ std::set DTSimHitMatcher::hitWiresInDTLayerId( for (int ss = smin; ss <= smax; ++ss) { DTWireId widd(id, ss); if (verbose_) - cout << "\tadding DTWireId to collection " << widd << endl; + edm::LogInfo("DTSimHitMatcher") + << "\tadding DTWireId to collection " << widd << endl; result.insert(widd.rawId()); } } @@ -275,7 +281,9 @@ std::set DTSimHitMatcher::hitWiresInDTSuperLayerId( ->superLayer(DTSuperLayerId(detid)) ->layers()); for (const auto& l : layers) { - if (verbose_) cout << "hitWiresInDTSuperLayerId::l id " << l->id() << endl; + if (verbose_) + edm::LogInfo("DTSimHitMatcher") + << "hitWiresInDTSuperLayerId::l id " << l->id() << endl; const auto& p(hitWiresInDTLayerId(l->id().rawId(), margin_n_wires)); result.insert(p.begin(), p.end()); } @@ -289,7 +297,9 @@ std::set DTSimHitMatcher::hitWiresInDTChamberId( ->chamber(DTChamberId(detid)) ->superLayers()); for (const auto& sl : superLayers) { - if (verbose_) cout << "hitWiresInDTChamberId::sl id " << sl->id() << endl; + if (verbose_) + edm::LogInfo("DTSimHitMatcher") + << "hitWiresInDTChamberId::sl id " << sl->id() << endl; const auto& p(hitWiresInDTSuperLayerId(sl->id().rawId(), margin_n_wires)); result.insert(p.begin(), p.end()); } @@ -300,7 +310,7 @@ void DTSimHitMatcher::dtChamberIdsToString( const std::set& set) const { for (const auto& p : set) { DTChamberId detId(p); - std::cout << " " << detId << "\n"; + edm::LogInfo("DTSimHitMatcher") << " " << detId << "\n"; } } diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index e05b154c81a47..ec2e0dbcf9d77 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -22,7 +22,8 @@ void GEMSimHitMatcher::init(const edm::Event& iEvent, geometry_ = dynamic_cast(&*gem_geom_); } else { hasGeometry_ = false; - std::cout << "+++ Info: GEM geometry is unavailable. +++\n"; + edm::LogWarning("GEMSimHitMatcher") + << "+++ Info: GEM geometry is unavailable. +++\n"; } MuonSimHitMatcher::init(iEvent, iSetup); } @@ -35,32 +36,34 @@ void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " - << hits_.size() << endl; - cout << "detids GEM " << detIds(0).size() << endl; + edm::LogInfo("GEMSimHitMatcher") + << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " + << hits_.size() << endl; + edm::LogInfo("GEMSimHitMatcher") + << "detids GEM " << detIds(0).size() << endl; const auto& gem_ch_ids = detIds(); for (const auto& id : gem_ch_ids) { const auto& gem_simhits = MuonSimHitMatcher::hitsInDetId(id); const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); - cout << "gemchid " << GEMDetId(id) << ": nHits " << gem_simhits.size() - << " phi " << gem_simhits_gp.phi() << " nCh " - << chamber_to_hits_[id].size() << endl; + edm::LogInfo("GEMSimHitMatcher") + << "gemchid " << GEMDetId(id) << ": nHits " << gem_simhits.size() + << " phi " << gem_simhits_gp.phi() << " nCh " + << chamber_to_hits_[id].size() << endl; const auto& strips = hitStripsInDetId(id); - cout << "nStrip " << strips.size() << endl; - cout << "strips : "; + edm::LogInfo("GEMSimHitMatcher") << "nStrip " << strips.size() << endl; + edm::LogInfo("GEMSimHitMatcher") << "strips : "; std::copy(strips.begin(), strips.end(), ostream_iterator(cout, " ")); - cout << endl; } const auto& gem_sch_ids = superChamberIds(); for (const auto& id : gem_sch_ids) { const auto& gem_simhits = hitsInSuperChamber(id); const auto& gem_simhits_gp = simHitsMeanPosition(gem_simhits); - cout << "gemschid " << GEMDetId(id) << ": " - << nCoincidencePadsWithHits() << " | " << gem_simhits.size() << " " - << gem_simhits_gp.phi() << " " << superchamber_to_hits_[id].size() - << endl; + edm::LogInfo("GEMSimHitMatcher") + << "gemschid " << GEMDetId(id) << ": " << nCoincidencePadsWithHits() + << " | " << gem_simhits.size() << " " << gem_simhits_gp.phi() << " " + << superchamber_to_hits_[id].size() << endl; } } } @@ -119,9 +122,10 @@ void GEMSimHitMatcher::matchSimHitsToSimTrack( const LocalPoint& lp = h.entryPoint(); pads1.insert(1 + static_cast(roll1->padTopology().channel(lp))); if (verbose_) - std::cout << "GEMHits detid1 " << id1 << " pad1 " - << 1 + static_cast(roll1->padTopology().channel(lp)) - << std::endl; + edm::LogInfo("GEMSimHitMatcher") + << "GEMHits detid1 " << id1 << " pad1 " + << 1 + static_cast(roll1->padTopology().channel(lp)) + << std::endl; } // find pads with hits in layer2 @@ -140,9 +144,10 @@ void GEMSimHitMatcher::matchSimHitsToSimTrack( const LocalPoint& lp = h.entryPoint(); pads2.insert(1 + static_cast(roll2->padTopology().channel(lp))); if (verbose_) - std::cout << "GEMHits detid2 " << id2 << " pad2 " - << 1 + static_cast(roll2->padTopology().channel(lp)) - << std::endl; + edm::LogInfo("GEMSimHitMatcher") + << "GEMHits detid2 " << id2 << " pad2 " + << 1 + static_cast(roll2->padTopology().channel(lp)) + << std::endl; } } @@ -265,8 +270,8 @@ float GEMSimHitMatcher::simHitsGEMCentralPosition( } central = gp.perp(); if (n >= 1) - std::cout << "warning! find more than one simhits in GEM chamber " - << std::endl; + edm::LogWarning("GEMSimHitMatcher") + << "warning! find more than one simhits in GEM chamber " << std::endl; ++n; } diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index b2a6b8ecfba66..0d6693d5169a8 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -22,7 +22,8 @@ void ME0SimHitMatcher::init(const edm::Event& iEvent, geometry_ = &*me0_geom_; } else { hasGeometry_ = false; - std::cout << "+++ Info: ME0 geometry is unavailable. +++\n"; + edm::LogWarning("ME0SimHitMatcher") + << "+++ Info: ME0 geometry is unavailable. +++\n"; } MuonSimHitMatcher::init(iEvent, iSetup); } @@ -35,23 +36,25 @@ void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " - << hits_.size() << endl; - cout << "detids ME0 " << detIds().size() << endl; + edm::LogInfo("ME0SimHitMatcher") + << "nTrackIds " << track_ids_.size() << " nSelectedME0SimHits " + << hits_.size() << endl; + edm::LogInfo("ME0SimHitMatcher") + << "detids ME0 " << detIds().size() << endl; const auto& me0_ch_ids = detIds(); for (const auto& id : me0_ch_ids) { const auto& me0_simhits = MuonSimHitMatcher::hitsInChamber(id); const auto& me0_simhits_gp = simHitsMeanPosition(me0_simhits); - cout << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() - << " phi " << me0_simhits_gp.phi() << " nCh " - << chamber_to_hits_[id].size() << endl; + edm::LogInfo("ME0SimHitMatcher") + << "me0chid " << ME0DetId(id) << ": nHits " << me0_simhits.size() + << " phi " << me0_simhits_gp.phi() << " nCh " + << chamber_to_hits_[id].size() << endl; const auto& strips = hitStripsInDetId(id); - cout << "nStrip " << strips.size() << endl; - cout << "strips : "; + edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size() << endl; + edm::LogInfo("ME0SimHitMatcher") << "strips : "; std::copy(strips.begin(), strips.end(), ostream_iterator(cout, " ")); - cout << endl; } } } diff --git a/Validation/MuonHits/src/MuonSimHitMatcher.cc b/Validation/MuonHits/src/MuonSimHitMatcher.cc index 60e6b105adc84..cf26b358c51e1 100644 --- a/Validation/MuonHits/src/MuonSimHitMatcher.cc +++ b/Validation/MuonHits/src/MuonSimHitMatcher.cc @@ -43,8 +43,8 @@ void MuonSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { track_ids_ = getIdsOfSimTrackShower(track.trackId(), simTracks_, simVertices_); if (verboseSimTrack_) { - std::cout << "Printing track_ids" << std::endl; - for (const auto& id : track_ids_) std::cout << "id: " << id << std::endl; + edm::LogInfo("MuonSimHitMatcher") << "Printing track_ids" << std::endl; + for (const auto& id : track_ids_) edm::LogInfo("MuonSimHitMatcher") << "id: " << id << std::endl; } } diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index 84825e89fedd5..addd970c5c7b1 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -23,7 +23,8 @@ void RPCSimHitMatcher::init(const edm::Event& iEvent, geometry_ = &*rpc_geom_; } else { hasGeometry_ = false; - std::cout << "+++ Info: RPC geometry is unavailable. +++\n"; + edm::LogWarning("RPCSimHitMatcher") + << "+++ Info: RPC geometry is unavailable. +++\n"; } MuonSimHitMatcher::init(iEvent, iSetup); } @@ -36,23 +37,25 @@ void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { matchSimHitsToSimTrack(track_ids_, simHits_); if (verbose_) { - cout << "nSimHits " << simHits_.size() << " nTrackIds " - << track_ids_.size() << endl; - cout << "detids RPC " << detIds().size() << endl; + edm::LogInfo("RPCSimHitMatcher") + << "nSimHits " << simHits_.size() << " nTrackIds " + << track_ids_.size() << endl; + edm::LogInfo("RPCSimHitMatcher") + << "detids RPC " << detIds().size() << endl; const auto& ch_ids = chamberIds(); for (const auto& id : ch_ids) { const auto& simhits = MuonSimHitMatcher::hitsInChamber(id); const auto& simhits_gp = simHitsMeanPosition(simhits); - cout << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() - << " eta " << simhits_gp.eta() << " phi " << simhits_gp.phi() - << " nCh " << chamber_to_hits_[id].size() << endl; + edm::LogInfo("RPCSimHitMatcher") + << "RPCDetId " << RPCDetId(id) << ": nHits " << simhits.size() + << " eta " << simhits_gp.eta() << " phi " << simhits_gp.phi() + << " nCh " << chamber_to_hits_[id].size() << endl; const auto& strips = hitStripsInDetId(id); - cout << "nStrips " << strips.size() << endl; - cout << "strips : "; + edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl; + edm::LogInfo("RPCSimHitMatcher") << "strips : "; std::copy(strips.begin(), strips.end(), - ostream_iterator(cout, " ")); - cout << endl; + ostream_iterator(std::cout, " ")); } } } From 104862692405fd9c1a21580518b3a5c7f22d082d Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Wed, 10 Apr 2019 18:32:21 +0200 Subject: [PATCH 564/686] Clang warnings in FastSimulation/SimplifiedGeometryPropagator: use CMS_THREAD_GUARD (reusing std::once_flag) and remove unused [this] from lambda expression --- .../plugins/NuclearInteraction.cc | 6 ++++-- .../plugins/NuclearInteractionFTF.cc | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc index 4437f57062549..3d1420116f355 100644 --- a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc +++ b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc @@ -21,6 +21,8 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/thread_safety_macros.h" + // Fast Sim headers #include "FastSimulation/SimplifiedGeometryPropagator/interface/Particle.h" #include "FastSimulation/SimplifiedGeometryPropagator/interface/SimplifiedGeometry.h" @@ -200,8 +202,8 @@ namespace fastsim // TODO: Is this correct? // Thread safety static std::once_flag initializeOnce; - [[cms::thread_guard("initializeOnce")]] std::vector< std::vector > NuclearInteraction::theRatiosMap; - [[cms::thread_guard("initializeOnce")]] std::map NuclearInteraction::theIDMap; + CMS_THREAD_GUARD(initializeOnce) std::vector< std::vector > NuclearInteraction::theRatiosMap; + CMS_THREAD_GUARD(initializeOnce) std::map NuclearInteraction::theIDMap; } diff --git a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteractionFTF.cc b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteractionFTF.cc index a690fbf5f2935..2605798bed9ce 100644 --- a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteractionFTF.cc +++ b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteractionFTF.cc @@ -18,6 +18,8 @@ #include "FastSimulation/SimplifiedGeometryPropagator/interface/Constants.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" +#include "FWCore/Utilities/interface/thread_safety_macros.h" + // Math #include "DataFormats/Math/interface/LorentzVector.h" @@ -239,8 +241,8 @@ namespace fastsim // Is this correct? // Thread safety static std::once_flag initializeOnce; - [[cms::thread_guard("initializeOnce")]] const G4ParticleDefinition* NuclearInteractionFTF::theG4Hadron[] = {nullptr}; - [[cms::thread_guard("initializeOnce")]] int NuclearInteractionFTF::theId[] = {0}; + CMS_THREAD_GUARD(initializeOnce) const G4ParticleDefinition* NuclearInteractionFTF::theG4Hadron[] = {nullptr}; + CMS_THREAD_GUARD(initializeOnce) int NuclearInteractionFTF::theId[] = {0}; } fastsim::NuclearInteractionFTF::NuclearInteractionFTF(const std::string & name,const edm::ParameterSet & cfg) @@ -274,7 +276,7 @@ fastsim::NuclearInteractionFTF::NuclearInteractionFTF(const std::string & name,c theDiffuseElastic = new G4DiffuseElastic(); // Geant4 particles and cross sections - std::call_once(initializeOnce, [this] () { + std::call_once(initializeOnce, [] () { theG4Hadron[0] = G4Proton::Proton(); theG4Hadron[1] = G4Neutron::Neutron(); theG4Hadron[2] = G4PionPlus::PionPlus(); From 419349bb4b4c3f81f47b725107369fe9063a330f Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 10 Apr 2019 18:42:08 +0200 Subject: [PATCH 565/686] For some reason the standalone build does not have this transition available. --- DQMServices/Core/src/DQMStore.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index b3c85f62e0b8a..7382e1207cfdd 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -376,8 +376,10 @@ DQMStore::DQMStore(edm::ParameterSet const& pset, edm::ActivityRegistry& ar) ar.watchPostSourceRun([this](edm::RunIndex){ forceReset(); }); } if(pset.getUntrackedParameter("forceResetOnBeginLumi",false) && enableMultiThread_ == false) { +#if !WITHOUT_CMS_FRAMEWORK forceResetOnBeginLumi_ = true; ar.watchPreSourceLumi([this](edm::LuminosityBlockIndex){ forceReset(); }); +#endif } ar.watchPostGlobalBeginLumi(this, &DQMStore::postGlobalBeginLumi); } From a0c43f3ea4e248d9b0b318bc1b566f1e8f36e5c0 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 10 Apr 2019 18:44:42 +0200 Subject: [PATCH 566/686] Add some reset calls to TrackingMonitorClient. This should take care of resetting the LSanalysis MEs. --- .../src/TrackingQualityChecker.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/DQM/TrackingMonitorClient/src/TrackingQualityChecker.cc b/DQM/TrackingMonitorClient/src/TrackingQualityChecker.cc index b0df51cf5ad95..2f12b73578ba4 100644 --- a/DQM/TrackingMonitorClient/src/TrackingQualityChecker.cc +++ b/DQM/TrackingMonitorClient/src/TrackingQualityChecker.cc @@ -363,6 +363,17 @@ void TrackingQualityChecker::fillTrackingStatus(DQMStore::IBooker & ibooker, DQM } } + // After harvesting, all per-lumi MEs are reset, to make sure we only get + // events of the new lumisection next time. + for (std::map::iterator it = TrackingMEsMap.begin(); + it != TrackingMEsMap.end(); it++) { + std::string localMEdirpath = it->second.HistoDir; + std::vector tmpMEvec = igetter.getContents(ibooker.pwd()+"/"+localMEdirpath); + for ( auto ime : tmpMEvec ) { + ime->Reset(); + } + } + if (verbose_) std::cout << "[TrackingQualityChecker::fillTrackingStatus] gstatus: " << gstatus << std::endl; size_t nQT = TrackingMEsMap.size(); if (gstatus < 1.) gstatus = -1.; From bec1c249ee7a17f4e150c1e79a92c30122b30f48 Mon Sep 17 00:00:00 2001 From: Cristina Mantilla Date: Wed, 10 Apr 2019 19:55:27 +0200 Subject: [PATCH 567/686] set recommend2D to false by default --- RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 069e049cfd6b5..bbb06a3232bac 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -541,7 +541,9 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus SiPixelTemplateReco::ClusMatrix & clusterPayload, int ID ) const { - + // recommend2D is false by default + theClusterParam.recommended2D_ = false; + DetId id = (theDetParam.theDet->geographicalId()); bool recommend = false; From efe01464cf0feaefa94469b48c6ef51071cecbe1 Mon Sep 17 00:00:00 2001 From: Alessandro Rossi Date: Thu, 11 Apr 2019 00:58:27 +0200 Subject: [PATCH 568/686] Added Residuals plots and fix monitoring plots for ClusterRepairs --- .../interface/TrackerValidationVariables.h | 6 ++- .../src/TrackerValidationVariables.cc | 13 +++++ .../plugins/SiPixelPhase1RecHits.cc | 2 + .../plugins/SiPixelPhase1TrackResiduals.cc | 17 ++++++- .../python/SiPixelPhase1RecHits_cfi.py | 20 ++++---- .../python/SiPixelPhase1TrackResiduals_cfi.py | 48 ++++++++++++++++++- 6 files changed, 92 insertions(+), 14 deletions(-) diff --git a/Alignment/OfflineValidation/interface/TrackerValidationVariables.h b/Alignment/OfflineValidation/interface/TrackerValidationVariables.h index de24622d1e262..2374ce36e5e38 100644 --- a/Alignment/OfflineValidation/interface/TrackerValidationVariables.h +++ b/Alignment/OfflineValidation/interface/TrackerValidationVariables.h @@ -26,7 +26,7 @@ class TrackerValidationVariables AVHitStruct() : resX(-999.), resY(-999.), resErrX(-999.), resErrY(-999.), resXprime(-999.), resXatTrkY(-999.), resXprimeErr(-999.), resYprime(-999.), resYprimeErr(-999.), phi(-999.), eta(-999.), inside(false), localX(-999.), localY(-999.), localXnorm(-999.), localYnorm(-999.), localAlpha(-999.), localBeta(-999.), - rawDetId(0) {} + rawDetId(0), isOnEdgePixel(false), isOtherBadPixel(false) {} float resX; float resY; float resErrX; @@ -46,6 +46,8 @@ class TrackerValidationVariables float localAlpha; float localBeta; uint32_t rawDetId; + bool isOnEdgePixel; + bool isOtherBadPixel; }; struct AVTrackStruct @@ -68,7 +70,7 @@ class TrackerValidationVariables float dz; int charge; int numberOfValidHits; - int numberOfLostHits; + int numberOfLostHits; std::vector hits; }; diff --git a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc index 214bf20a6e473..4c018ef54e936 100644 --- a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc +++ b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc @@ -29,6 +29,7 @@ #include "DataFormats/Math/interface/deltaPhi.h" #include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" @@ -80,6 +81,12 @@ void TrackerValidationVariables::fillHitQuantities(reco::Track const & track, st if(IntSubDetID == 0) continue; + if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == PixelSubdetector::PixelEndcap){ + const SiPixelRecHit* prechit = dynamic_cast(hit);//to be used to get the associated cluster and the cluster probability + if(prechit->isOnEdge()) hitStruct.isOnEdgePixel=true; + if(prechit->hasBadPixels()) hitStruct.isOtherBadPixel=true; + } + auto lPTrk = trajParams[h].position(); // update state auto lVTrk = trajParams[h].direction(); @@ -214,6 +221,12 @@ TrackerValidationVariables::fillHitQuantities(const Trajectory* trajectory, std: unsigned int IntSubDetID = (hit_detId.subdetId()); if(IntSubDetID == 0) continue; + + if (IntSubDetID == PixelSubdetector::PixelBarrel || IntSubDetID == PixelSubdetector::PixelEndcap){ + const SiPixelRecHit* prechit = dynamic_cast(hit.get());//to be used to get the associated cluster and the cluster probability + if(prechit->isOnEdge()) hitStruct.isOnEdgePixel=true; + if(prechit->hasBadPixels()) hitStruct.isOtherBadPixel=true; + } //first calculate residuals in cartesian coordinates in the local module coordinate system diff --git a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc index 7fd9fb44eaea2..4bb45ef1a70be 100644 --- a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc +++ b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1RecHits.cc @@ -166,6 +166,8 @@ void SiPixelPhase1RecHits::analyze(const edm::Event& iEvent, const edm::EventSet } histo[NRECHITS].executePerEventHarvesting(&iEvent); + histo[NONEDGE].executePerEventHarvesting(&iEvent); + histo[NOTHERBAD].executePerEventHarvesting(&iEvent); } } //namespace diff --git a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackResiduals.cc b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackResiduals.cc index 28b4a5e3020e7..b079f5ad420ac 100644 --- a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackResiduals.cc +++ b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackResiduals.cc @@ -25,7 +25,11 @@ namespace { class SiPixelPhase1TrackResiduals final : public SiPixelPhase1Base { enum { RESIDUAL_X, - RESIDUAL_Y + RESIDUAL_Y, + RESONEDGE_X, + RESONEDGE_Y, + RESOTHERBAD_X, + RESOTHERBAD_Y }; public: @@ -80,6 +84,17 @@ void SiPixelPhase1TrackResiduals::analyze(const edm::Event& iEvent, const edm::E histo[RESIDUAL_X].fill(it.resXprime, id, &iEvent); histo[RESIDUAL_Y].fill(it.resYprime, id, &iEvent); + + if(it.isOnEdgePixel){ + histo[RESONEDGE_X].fill(it.resXprime, id, &iEvent); + histo[RESONEDGE_Y].fill(it.resYprime, id, &iEvent); + } + + if(it.isOtherBadPixel){ + histo[RESOTHERBAD_X].fill(it.resXprime, id, &iEvent); + histo[RESOTHERBAD_Y].fill(it.resYprime, id, &iEvent); + } + } } diff --git a/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py b/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py index 9248b2387795a..e4a25af427809 100644 --- a/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py +++ b/DQM/SiPixelPhase1Track/python/SiPixelPhase1RecHits_cfi.py @@ -133,25 +133,25 @@ Specification().groupBy("PXBarrel/PXLayer/Event") .reduce("COUNT") .groupBy("PXBarrel/PXLayer/") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXBarrel/Event") .reduce("COUNT") .groupBy("PXBarrel") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXForward/PXDisk/Event") .reduce("COUNT") .groupBy("PXForward/PXDisk/") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXForward/PXDisk/Event") .reduce("COUNT") .groupBy("PXForward") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXAll/Event") .reduce("COUNT") .groupBy("PXAll") - .save(nbins=100, xmin=0, xmax=1000) + .save(nbins=100, xmin=0, xmax=500) ) ) @@ -181,25 +181,25 @@ Specification().groupBy("PXBarrel/PXLayer/Event") .reduce("COUNT") .groupBy("PXBarrel/PXLayer/") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXBarrel/Event") .reduce("COUNT") .groupBy("PXBarrel") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXForward/PXDisk/Event") .reduce("COUNT") .groupBy("PXForward/PXDisk/") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXForward/PXDisk/Event") .reduce("COUNT") .groupBy("PXForward") - .save(nbins=100, xmin=0, xmax=1000), + .save(nbins=100, xmin=0, xmax=500), Specification().groupBy("PXAll/Event") .reduce("COUNT") .groupBy("PXAll") - .save(nbins=100, xmin=0, xmax=1000) + .save(nbins=100, xmin=0, xmax=500) ) ) diff --git a/DQM/SiPixelPhase1Track/python/SiPixelPhase1TrackResiduals_cfi.py b/DQM/SiPixelPhase1Track/python/SiPixelPhase1TrackResiduals_cfi.py index 2ef49ff61b017..b01487f121d50 100644 --- a/DQM/SiPixelPhase1Track/python/SiPixelPhase1TrackResiduals_cfi.py +++ b/DQM/SiPixelPhase1Track/python/SiPixelPhase1TrackResiduals_cfi.py @@ -35,9 +35,55 @@ xlabel = "(y_rec - y_pred) [cm]", ) +SiPixelPhase1TrackResidualsResOnEdgeX = DefaultHistoTrack.clone( + name = "residual_OnEdge_x", + title = "Track Residuals X (OnEdge Clusters)", + range_min = -0.1, range_max = 0.1, range_nbins = 100, + xlabel = "(x_rec - x_pred) [cm]", + dimensions = 1, + specs = VPSet( + Specification().groupBy("PXBarrel/PXLayer").saveAll(), + Specification().groupBy("PXForward/PXDisk").saveAll(), + Specification(PerLayer1D).groupBy("PXBarrel/Shell/PXLayer").save(), + Specification(PerLayer1D).groupBy("PXForward/HalfCylinder/PXRing/PXDisk").save() + ) +) + +SiPixelPhase1TrackResidualsResOnEdgeY = SiPixelPhase1TrackResidualsResOnEdgeX.clone( + name = "residual_OnEdge_y", + title = "Track Residuals Y (OnEdge Clusters)", + xlabel = "(y_rec - y_pred) [cm]", +) + + +SiPixelPhase1TrackResidualsResOtherBadX = DefaultHistoTrack.clone( + name = "residual_OtherBad_x", + title = "Track Residuals X (OtherBad Clusters)", + range_min = -0.1, range_max = 0.1, range_nbins = 100, + xlabel = "(x_rec - x_pred) [cm]", + dimensions = 1, + specs = VPSet( + Specification().groupBy("PXBarrel/PXLayer").saveAll(), + Specification().groupBy("PXForward/PXDisk").saveAll(), + Specification(PerLayer1D).groupBy("PXBarrel/Shell/PXLayer").save(), + Specification(PerLayer1D).groupBy("PXForward/HalfCylinder/PXRing/PXDisk").save() + ) +) + +SiPixelPhase1TrackResidualsResOtherBadY = SiPixelPhase1TrackResidualsResOtherBadX.clone( + name = "residual_OtherBad_y", + title = "Track Residuals Y (OtherBad Clusters)", + xlabel = "(y_rec - y_pred) [cm]", +) + + SiPixelPhase1TrackResidualsConf = cms.VPSet( SiPixelPhase1TrackResidualsResidualsX, - SiPixelPhase1TrackResidualsResidualsY + SiPixelPhase1TrackResidualsResidualsY, + SiPixelPhase1TrackResidualsResOnEdgeX, + SiPixelPhase1TrackResidualsResOnEdgeY, + SiPixelPhase1TrackResidualsResOtherBadX, + SiPixelPhase1TrackResidualsResOtherBadY ) from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer From 9c8dd72bfed6f2ad6a76c5b1e3db3a07798767b6 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 11 Apr 2019 08:44:00 +0200 Subject: [PATCH 569/686] more print migrations --- RecoEgamma/ElectronIdentification/python/FWLite.py | 2 +- .../ElectronIdentification/test/runElectron_VID.py | 2 +- .../test/test_eleid_fwlite.py | 2 +- .../PhotonIdentification/test/runPhoton_VID.py | 2 +- RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py | 14 +++++++------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/RecoEgamma/ElectronIdentification/python/FWLite.py b/RecoEgamma/ElectronIdentification/python/FWLite.py index 9ee170a0d5241..2775c18400360 100644 --- a/RecoEgamma/ElectronIdentification/python/FWLite.py +++ b/RecoEgamma/ElectronIdentification/python/FWLite.py @@ -43,7 +43,7 @@ def __call__(self, ele, convs, beam_spot, rho, debug=False): mva, category = electron_mva_id(electron[0], convs, beam_spot, rho) ''' if not self._init: - print('Initializing ' + self.name + self.tag) + print(('Initializing ' + self.name + self.tag)) ROOT.gSystem.Load("libRecoEgammaElectronIdentification") categoryCutStrings = ROOT.vector(ROOT.string)() for x in self.categoryCuts : diff --git a/RecoEgamma/ElectronIdentification/test/runElectron_VID.py b/RecoEgamma/ElectronIdentification/test/runElectron_VID.py index d1ed67b37a294..9d9680f2862df 100644 --- a/RecoEgamma/ElectronIdentification/test/runElectron_VID.py +++ b/RecoEgamma/ElectronIdentification/test/runElectron_VID.py @@ -46,7 +46,7 @@ # You can list here either AOD or miniAOD files, but not both types mixed # -print sys.argv[2] +print(sys.argv[2]) useAOD = bool(int(sys.argv[2])) if useAOD == True : diff --git a/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py b/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py index 2dceeb27dc10b..5312b3c41260a 100644 --- a/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py +++ b/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py @@ -48,7 +48,7 @@ nEvent = event._event.id().event() - print("processing event {0}: {1}...".format(i, nEvent)) + print(("processing event {0}: {1}...".format(i, nEvent))) # Save information on the first electron in an event, # if there is any the first electron of the diff --git a/RecoEgamma/PhotonIdentification/test/runPhoton_VID.py b/RecoEgamma/PhotonIdentification/test/runPhoton_VID.py index 5f374122fcf22..40781a5d944b8 100644 --- a/RecoEgamma/PhotonIdentification/test/runPhoton_VID.py +++ b/RecoEgamma/PhotonIdentification/test/runPhoton_VID.py @@ -44,7 +44,7 @@ # You can list here either AOD or miniAOD files, but not both types mixed # -print sys.argv[2] +print(sys.argv[2]) useAOD = bool(int(sys.argv[2])) if useAOD == True : diff --git a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py index d49d22be832a6..c5dfe0406ad08 100644 --- a/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunTauRecoOnMiniAOD.py @@ -26,11 +26,11 @@ outMode = 0 # store original MiniAOD and new selectedPatTaus # outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones) -print 'Running Tau reco&id with MiniAOD inputs:' -print '\t Run on signal:', runSignal -print '\t Recluster jets:', reclusterJets -print '\t Use Phase2 settings:', phase2 -print '\t Output mode:', outMode +print('Running Tau reco&id with MiniAOD inputs:') +print('\t Run on signal:', runSignal) +print('\t Recluster jets:', reclusterJets) +print('\t Use Phase2 settings:', phase2) +print('\t Output mode:', outMode) ##### from Configuration.StandardSequences.Eras import eras @@ -54,7 +54,7 @@ process.maxEvents = cms.untracked.PSet( input=cms.untracked.int32(maxEvents) ) -print '\t Max events:', process.maxEvents.input.value() +print('\t Max events:', process.maxEvents.input.value()) if runSignal: readFiles.extend([ @@ -112,7 +112,7 @@ process.options.numberOfThreads = cms.untracked.uint32(4) # process.options.numberOfThreads=cms.untracked.uint32(1) process.options.numberOfStreams = cms.untracked.uint32(0) -print '\t No. of threads:', process.options.numberOfThreads.value(), ', no. of streams:', process.options.numberOfStreams.value() +print('\t No. of threads:', process.options.numberOfThreads.value(), ', no. of streams:', process.options.numberOfStreams.value()) process.options = cms.untracked.PSet( process.options, From 78b0167ee3efcfb83aeaea6c73780c8b092ffa50 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 11 Apr 2019 08:46:52 +0200 Subject: [PATCH 570/686] remove iteritems --- .../test/python/SiStripBadAPVListBuilder_byHand_cfg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalibTracker/SiStripESProducers/test/python/SiStripBadAPVListBuilder_byHand_cfg.py b/CalibTracker/SiStripESProducers/test/python/SiStripBadAPVListBuilder_byHand_cfg.py index dc60dad66ee9d..a1e6ffe21df25 100644 --- a/CalibTracker/SiStripESProducers/test/python/SiStripBadAPVListBuilder_byHand_cfg.py +++ b/CalibTracker/SiStripESProducers/test/python/SiStripBadAPVListBuilder_byHand_cfg.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms - +import six process = cms.Process("CALIB") #################################################### @@ -53,7 +53,7 @@ def getFileInPath(rfile): #print(detDict) APVsToKill = [] -for det,napv in detDict.iteritems(): +for det,napv in six.iteritems(detDict): APVsToKill.append( cms.PSet( DetId = cms.uint32(int(det)), From 1f5c14090f441dc620ea1e7c0f17157499c4a20a Mon Sep 17 00:00:00 2001 From: David Date: Thu, 11 Apr 2019 08:49:43 +0200 Subject: [PATCH 571/686] remove atoi --- IOPool/Input/test/PrePoolInputTest_cfg.py | 11 +++++------ IOPool/Input/test/RunPerLumiTest_cfg.py | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/IOPool/Input/test/PrePoolInputTest_cfg.py b/IOPool/Input/test/PrePoolInputTest_cfg.py index dc56d73909128..f3d0a9e308576 100644 --- a/IOPool/Input/test/PrePoolInputTest_cfg.py +++ b/IOPool/Input/test/PrePoolInputTest_cfg.py @@ -4,13 +4,12 @@ import FWCore.ParameterSet.Config as cms from sys import argv -from string import atoi process = cms.Process("TESTPROD") process.load("FWCore.Framework.test.cmsExceptionsFatal_cff") process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(atoi(argv[3])) + input = cms.untracked.int32(int(argv[3])) ) process.Thing = cms.EDProducer("ThingProducer") @@ -20,10 +19,10 @@ ) process.source = cms.Source("EmptySource", - firstRun = cms.untracked.uint32(atoi(argv[4])), - numberEventsInRun = cms.untracked.uint32(atoi(argv[5])), - firstLuminosityBlock = cms.untracked.uint32(atoi(argv[6])), - numberEventsInLuminosityBlock = cms.untracked.uint32(atoi(argv[7])) + firstRun = cms.untracked.uint32(int(argv[4])), + numberEventsInRun = cms.untracked.uint32(int(argv[5])), + firstLuminosityBlock = cms.untracked.uint32(int(argv[6])), + numberEventsInLuminosityBlock = cms.untracked.uint32(int(argv[7])) ) process.p = cms.Path(process.Thing) diff --git a/IOPool/Input/test/RunPerLumiTest_cfg.py b/IOPool/Input/test/RunPerLumiTest_cfg.py index 263e489c17a43..4871ba31a2d70 100644 --- a/IOPool/Input/test/RunPerLumiTest_cfg.py +++ b/IOPool/Input/test/RunPerLumiTest_cfg.py @@ -4,13 +4,12 @@ import FWCore.ParameterSet.Config as cms from sys import argv -from string import atoi process = cms.Process("TESTRECO") process.load("FWCore.Framework.test.cmsExceptionsFatal_cff") process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(atoi(argv[2])) + input = cms.untracked.int32(int(argv[2])) ) process.OtherThing = cms.EDProducer("OtherThingProducer") From 9fc8dfd94f0b33151885eb4db6675d261e7d97fd Mon Sep 17 00:00:00 2001 From: David Date: Thu, 11 Apr 2019 08:54:27 +0200 Subject: [PATCH 572/686] undo --- RecoEgamma/ElectronIdentification/python/FWLite.py | 2 +- RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoEgamma/ElectronIdentification/python/FWLite.py b/RecoEgamma/ElectronIdentification/python/FWLite.py index 2775c18400360..9ee170a0d5241 100644 --- a/RecoEgamma/ElectronIdentification/python/FWLite.py +++ b/RecoEgamma/ElectronIdentification/python/FWLite.py @@ -43,7 +43,7 @@ def __call__(self, ele, convs, beam_spot, rho, debug=False): mva, category = electron_mva_id(electron[0], convs, beam_spot, rho) ''' if not self._init: - print(('Initializing ' + self.name + self.tag)) + print('Initializing ' + self.name + self.tag) ROOT.gSystem.Load("libRecoEgammaElectronIdentification") categoryCutStrings = ROOT.vector(ROOT.string)() for x in self.categoryCuts : diff --git a/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py b/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py index 5312b3c41260a..2dceeb27dc10b 100644 --- a/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py +++ b/RecoEgamma/ElectronIdentification/test/test_eleid_fwlite.py @@ -48,7 +48,7 @@ nEvent = event._event.id().event() - print(("processing event {0}: {1}...".format(i, nEvent))) + print("processing event {0}: {1}...".format(i, nEvent)) # Save information on the first electron in an event, # if there is any the first electron of the From dfa0859e84a36a0745aa4f21fe09fe91f42e3125 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Thu, 11 Apr 2019 09:41:33 +0200 Subject: [PATCH 573/686] Review suggestions addressed. --- .../plugins/CTPPSProtonProducer.cc | 109 ++++++++++-------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index ea891c8fe40d3..3393ae1194a92 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -67,6 +67,34 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> double xi_cut_value; bool th_y_cut_apply; double th_y_cut_value; + + void load(const edm::ParameterSet &ps) + { + x_cut_apply = ps.getParameter ("x_cut_apply"); + x_cut_value = ps.getParameter("x_cut_value"); + y_cut_apply = ps.getParameter ("y_cut_apply"); + y_cut_value = ps.getParameter("y_cut_value"); + xi_cut_apply = ps.getParameter ("xi_cut_apply"); + xi_cut_value = ps.getParameter("xi_cut_value"); + th_y_cut_apply = ps.getParameter ("th_y_cut_apply"); + th_y_cut_value = ps.getParameter("th_y_cut_value"); + } + + static edm::ParameterSetDescription getDefaultParameters() + { + edm::ParameterSetDescription desc; + + desc.add("x_cut_apply", false)->setComment("whether to apply track-association cut in x"); + desc.add("x_cut_value", 800E-6)->setComment("threshold of track-association cut in x, mm"); + desc.add("y_cut_apply", false)->setComment("whether to apply track-association cut in y"); + desc.add("y_cut_value", 600E-6)->setComment("threshold of track-association cut in y, mm"); + desc.add("xi_cut_apply", true)->setComment("whether to apply track-association cut in xi"); + desc.add("xi_cut_value", 0.013)->setComment("threshold of track-association cut in xi"); + desc.add("th_y_cut_apply", true)->setComment("whether to apply track-association cut in th_y"); + desc.add("th_y_cut_value", 20E-6)->setComment("threshold of track-association cut in th_y, rad"); + + return desc; + } }; std::map association_cuts_; // map: arm -> AssociationCuts @@ -104,15 +132,7 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : for (const std::string §or : { "45", "56" }) { const unsigned int arm = (sector == "45") ? 0 : 1; - - association_cuts_[arm].x_cut_apply = iConfig.getParameter ("association_" + sector + "_x_cut_apply"); - association_cuts_[arm].x_cut_value = iConfig.getParameter("association_" + sector + "_x_cut_value"); - association_cuts_[arm].y_cut_apply = iConfig.getParameter ("association_" + sector + "_y_cut_apply"); - association_cuts_[arm].y_cut_value = iConfig.getParameter("association_" + sector + "_y_cut_value"); - association_cuts_[arm].xi_cut_apply = iConfig.getParameter ("association_" + sector + "_xi_cut_apply"); - association_cuts_[arm].xi_cut_value = iConfig.getParameter("association_" + sector + "_xi_cut_value"); - association_cuts_[arm].th_y_cut_apply = iConfig.getParameter ("association_" + sector + "_th_y_cut_apply"); - association_cuts_[arm].th_y_cut_value = iConfig.getParameter("association_" + sector + "_th_y_cut_value"); + association_cuts_[arm].load(iConfig.getParameterSet("association_cuts_" + sector)); } if (doSingleRPReconstruction_) @@ -153,23 +173,13 @@ void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("localAngleYMin", -0.04)->setComment("minimal accepted value of local vertical angle (rad)"); desc.add("localAngleYMax", +0.04)->setComment("maximal accepted value of local vertical angle (rad)"); - desc.add("association_45_x_cut_apply", false)->setComment("whether to apply track-association cut in x, sector 45"); - desc.add("association_45_x_cut_value", 800E-6)->setComment("threshold of track-association cut in x, mm, sector 45"); - desc.add("association_45_y_cut_apply", false)->setComment("whether to apply track-association cut in y, sector 45"); - desc.add("association_45_y_cut_value", 600E-6)->setComment("threshold of track-association cut in y, mm, sector 45"); - desc.add("association_45_xi_cut_apply", true)->setComment("whether to apply track-association cut in xi, sector 45"); - desc.add("association_45_xi_cut_value", 0.013)->setComment("threshold of track-association cut in xi, sector 45"); - desc.add("association_45_th_y_cut_apply", true)->setComment("whether to apply track-association cut in th_y, sector 45"); - desc.add("association_45_th_y_cut_value", 20E-6)->setComment("threshold of track-association cut in th_y, rad, sector 45"); - - desc.add("association_56_x_cut_apply", false)->setComment("whether to apply track-association cut in x, sector 56"); - desc.add("association_56_x_cut_value", 800E-6)->setComment("threshold of track-association cut in x, mm, sector 56"); - desc.add("association_56_y_cut_apply", false)->setComment("whether to apply track-association cut in y, sector 56"); - desc.add("association_56_y_cut_value", 600E-6)->setComment("threshold of track-association cut in y, mm, sector 56"); - desc.add("association_56_xi_cut_apply", true)->setComment("whether to apply track-association cut in xi, sector 56"); - desc.add("association_56_xi_cut_value", 0.013)->setComment("threshold of track-association cut in xi, sector 56"); - desc.add("association_56_th_y_cut_apply", true)->setComment("whether to apply track-association cut in th_y, sector 56"); - desc.add("association_56_th_y_cut_value", 20E-6)->setComment("threshold of track-association cut in th_y, rad, sector 56"); + for (const std::string §or : { "45", "56" }) + { + desc.add("association_cuts_" + sector, AssociationCuts::getDefaultParameters()) + ->setComment("track-association cuts for sector " + sector); + } + + std::vector config; desc.add("max_n_timing_tracks", 5)->setComment("maximum number of timing tracks per RP"); @@ -258,7 +268,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // process each arm for (const auto &arm_it : trackingSelection) { - const auto &indeces = arm_it.second; + const auto &indices = arm_it.second; const auto &ac = association_cuts_[arm_it.first]; @@ -266,7 +276,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe std::map singleRPResultsIndexed; if (doSingleRPReconstruction_ || ac.xi_cut_apply || ac.th_y_cut_apply) { - for (const auto &idx : indeces) + for (const auto &idx : indices) { if (verbosity_) ssLog << std::endl << "* reconstruction from track " << idx << std::endl; @@ -282,7 +292,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // - 1 is insufficient for multi-RP reconstruction // - PPS did not use more than 2 tracking RPs per arm -> algorithms are tuned to this std::set rpIds; - for (const auto &idx : indeces) + for (const auto &idx : indices) rpIds.insert(hTracks->at(idx).getRPId()); if (rpIds.size() != 2) continue; @@ -290,9 +300,9 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // find matching track pairs from different tracking RPs std::vector> idx_pairs; std::map idx_pair_multiplicity; - for (const auto &i : indeces) + for (const auto &i : indices) { - for (const auto &j : indeces) + for (const auto &j : indices) { if (j <= i) continue; @@ -308,13 +318,13 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe bool matching = true; - if (ac.x_cut_apply && fabs(tr_i.getX() - tr_j.getX()) > ac.x_cut_value) + if (ac.x_cut_apply && std::abs(tr_i.getX() - tr_j.getX()) > ac.x_cut_value) matching = false; - if (ac.y_cut_apply && fabs(tr_i.getY() - tr_j.getY()) > ac.y_cut_value) + if (ac.y_cut_apply && std::abs(tr_i.getY() - tr_j.getY()) > ac.y_cut_value) matching = false; - if (ac.xi_cut_apply && fabs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value) + if (ac.xi_cut_apply && std::abs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value) matching = false; - if (ac.th_y_cut_apply && fabs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value) + if (ac.th_y_cut_apply && std::abs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value) matching = false; if (!matching) @@ -335,7 +345,7 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe } // associate tracking-RP pairs with timing-RP tracks - std::map> mached_timing_track_indeces; + std::map> matched_timing_track_indices; std::map matched_timing_track_multiplicity; for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) { @@ -369,17 +379,18 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe const double de_x = tr_ti.getX() - x_inter; const double de_x_unc = sqrt(tr_ti.getXUnc()*tr_ti.getXUnc() + x_inter_unc_sq); - const bool matching = (fabs(de_x) <= de_x_unc); + const bool matching = (std::abs(de_x) <= de_x_unc); - ssLog << "ti=" << ti << ", i=" << i << ", j=" << j - << " | z_ti=" << z_ti << ", z_i=" << z_i << ", z_j=" << z_j - << " | x_ti=" << tr_ti.getX() << ", x_inter=" << x_inter << ", de_x=" << de_x << ", de_x_unc=" << de_x_unc - << ", matching=" << matching << std::endl; + if (verbosity_) + ssLog << "ti=" << ti << ", i=" << i << ", j=" << j + << " | z_ti=" << z_ti << ", z_i=" << z_i << ", z_j=" << z_j + << " | x_ti=" << tr_ti.getX() << ", x_inter=" << x_inter << ", de_x=" << de_x << ", de_x_unc=" << de_x_unc + << ", matching=" << matching << std::endl; if (!matching) continue; - mached_timing_track_indeces[pr_idx].push_back(ti); + matched_timing_track_indices[pr_idx].push_back(ti); matched_timing_track_multiplicity[ti]++; } } @@ -404,8 +415,8 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_tracks, *hLHCInfo, ssLog); // process timing-RP data - double Sw=0., Swt=0.; - for (const auto &ti : mached_timing_track_indeces[pr_idx]) + double sw=0., swt=0.; + for (const auto &ti : matched_timing_track_indices[pr_idx]) { // skip non-unique associations of timing-RP tracks if (matched_timing_track_multiplicity[ti] > 1) @@ -419,15 +430,15 @@ void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe const auto &tr = hTracks->at(ti); const double t_unc = tr.getTimeUnc(); const double w = (t_unc > 0.) ? 1./t_unc/t_unc : 1.; - Sw += w; - Swt += w * tr.getTime(); + sw += w; + swt += w * tr.getTime(); } float time = 0., time_unc = 0.; - if (Sw > 0.) + if (sw > 0.) { - time = Swt / Sw; - time_unc = 1. / sqrt(Sw); + time = swt / sw; + time_unc = 1. / sqrt(sw); } if (verbosity_) From 211cbf0799a5855296017e03fa6a14e97ccc90ac Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Thu, 11 Apr 2019 09:57:31 +0200 Subject: [PATCH 574/686] making variable names start with a lowercase letter --- .../Geometry/src/MaterialBudgetCategorizer.cc | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Validation/Geometry/src/MaterialBudgetCategorizer.cc b/Validation/Geometry/src/MaterialBudgetCategorizer.cc index 4b4ebec2d1941..3ad425fd6175b 100644 --- a/Validation/Geometry/src/MaterialBudgetCategorizer.cc +++ b/Validation/Geometry/src/MaterialBudgetCategorizer.cc @@ -88,13 +88,13 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil cms::Exception("LogicError") <<" File not found " << theMaterialFileName; // fill everything as "other" - float Air,Cables,Copper,H_Scintillator,Lead,HGC_G10_FR4,Silicon,StainlessSteel,WCu,oth,Epoxy,Kapton,Aluminium; - Air=Cables=Copper=H_Scintillator=Lead=HGC_G10_FR4=Silicon=StainlessSteel=WCu=Epoxy=Kapton=Aluminium=0.; + float air,cables,copper,h_scintillator,lead,hgc_g10_fr4,silicon,stainlesssteel,wcu,oth,epoxy,kapton,aluminium; + air=cables=copper=h_scintillator=lead=hgc_g10_fr4=silicon=stainlesssteel=wcu=epoxy=kapton=aluminium=0.; std::string materialName; while(theMaterialFile) { theMaterialFile >> materialName; - theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> HGC_G10_FR4 >> Silicon >> StainlessSteel >> WCu >> Epoxy >> Kapton >> Aluminium; + theMaterialFile >> air >> cables >> copper >> h_scintillator >> lead >> hgc_g10_fr4 >> silicon >> stainlesssteel >> wcu >> epoxy >> kapton >> aluminium; // Skip comments if (materialName[0] == '#') continue; @@ -102,34 +102,34 @@ void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFil std::replace(materialName.begin(), materialName.end(), '*', ' '); oth = 0.000; theMap[materialName].clear(); // clear before re-filling - theMap[materialName].push_back(Air ); // Air - theMap[materialName].push_back(Cables ); // Cables - theMap[materialName].push_back(Copper ); // Copper - theMap[materialName].push_back(H_Scintillator ); // H_Scintillator - theMap[materialName].push_back(Lead ); // Lead - theMap[materialName].push_back(HGC_G10_FR4); // HGC_G10_FR4 - theMap[materialName].push_back(Silicon ); // Silicon - theMap[materialName].push_back(StainlessSteel ); // StainlessSteel - theMap[materialName].push_back(WCu ); // WCu + theMap[materialName].push_back(air ); // air + theMap[materialName].push_back(cables ); // cables + theMap[materialName].push_back(copper ); // copper + theMap[materialName].push_back(h_scintillator ); // h_scintillator + theMap[materialName].push_back(lead ); // lead + theMap[materialName].push_back(hgc_g10_fr4); // hgc_g10_fr4 + theMap[materialName].push_back(silicon ); // silicon + theMap[materialName].push_back(stainlesssteel ); // stainlesssteel + theMap[materialName].push_back(wcu ); // wcu theMap[materialName].push_back(oth ); // oth - theMap[materialName].push_back(Epoxy ); // Epoxy - theMap[materialName].push_back(Kapton ); // Kapton - theMap[materialName].push_back(Aluminium ); // Aluminium + theMap[materialName].push_back(epoxy ); // epoxy + theMap[materialName].push_back(kapton ); // kapton + theMap[materialName].push_back(aluminium ); // aluminium edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: material " << materialName << " filled " << std::endl - << "\tAir " << Air << std::endl - << "\tCables " << Cables << std::endl - << "\tCopper " << Copper << std::endl - << "\tH_Scintillator " << H_Scintillator << std::endl - << "\tLead " << Lead << std::endl - << "\tHGC_G10_FR4 " << HGC_G10_FR4 << std::endl - << "\tSilicon " << Silicon << std::endl - << "\tStainlessSteel " << StainlessSteel << std::endl - << "\tWCu " << WCu << std::endl - << "\tEpoxy " << Epoxy << std::endl - << "\tKapton " << Kapton<< std::endl - << "\tAluminium " << Aluminium<< std::endl + << "\tair " << air << std::endl + << "\tcables " << cables << std::endl + << "\tcopper " << copper << std::endl + << "\th_scintillator " << h_scintillator << std::endl + << "\tlead " << lead << std::endl + << "\thgc_g10_fr4 " << hgc_g10_fr4 << std::endl + << "\tsilicon " << silicon << std::endl + << "\tstainlesssteel " << stainlesssteel << std::endl + << "\twcu " << wcu << std::endl + << "\tepoxy " << epoxy << std::endl + << "\tkapton " << kapton<< std::endl + << "\taluminium " << aluminium<< std::endl << "\tOTH " << oth; } From 8459861f75676405edf10af4ba637a80e6bb0d9a Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Thu, 11 Apr 2019 10:10:56 +0200 Subject: [PATCH 575/686] replacing magic numbers --- .../Geometry/src/MaterialBudgetHGCalHistos.cc | 244 +++++++++--------- 1 file changed, 128 insertions(+), 116 deletions(-) diff --git a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc index e88fb202aab69..0519d30d3628e 100644 --- a/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc +++ b/Validation/Geometry/src/MaterialBudgetHGCalHistos.cc @@ -31,16 +31,28 @@ void MaterialBudgetHGCalHistos::book() int nrbin = 345; float rMin = -50.; float rMax = 3400.; + // eta + int netabin = 250; + float etaMin = -5.; + float etaMax = 5.; + // phi + int nphibin = 180; + float phiMin = -3.2; + float phiMax = 3.2; + // R for profile histos + int nRbin = 300; + float RMin = 0.; + float RMax = 3000.; // total X0 - hmgr->addHistoProf1( new TProfile("10", "MB prof Eta;#eta;x/X_{0} ", 250, -5., 5. ) ); - hmgr->addHisto1( new TH1F("11", "Eta " , 250, -5., 5. ) ); - hmgr->addHistoProf1( new TProfile("20", "MB prof Phi;#varphi [rad];x/X_{0} ", 180, -3.2, 3.2 ) ); - hmgr->addHisto1( new TH1F("21", "Phi " , 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("30", "MB prof Eta Phi;#eta;#varphi;x/X_{0} ", 250, -5., 5., 180, -3.2, 3.2) ); - hmgr->addHisto2( new TH2F("31", "Eta vs Phi " , 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("40", "MB prof R;R [mm];x/X_{0} ", 300, 0., 3000. ) ); - hmgr->addHisto1( new TH1F("41", "R " , 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10", "MB prof Eta;#eta;x/X_{0} ", netabin, etaMin, etaMax ) ); + hmgr->addHisto1( new TH1F("11", "Eta " , netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("20", "MB prof Phi;#varphi [rad];x/X_{0} ", nphibin, phiMin, phiMax ) ); + hmgr->addHisto1( new TH1F("21", "Phi " , nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("30", "MB prof Eta Phi;#eta;#varphi;x/X_{0} ", netabin, etaMin, etaMax, nphibin, phiMin, phiMax) ); + hmgr->addHisto2( new TH2F("31", "Eta vs Phi " , netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("40", "MB prof R;R [mm];x/X_{0} ", nRbin, RMin, RMax ) ); + hmgr->addHisto1( new TH1F("41", "R " , nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("50", "MB prof sum R z;z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("999", "Tot track length for MB", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("51", "R vs z " , nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -50,10 +62,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("72", "MB ortho prof local R z;z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Copper - hmgr->addHistoProf1( new TProfile("110", "MB prof Eta [Copper];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("120", "MB prof Phi [Copper];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("130", "MB prof Eta Phi [Copper];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("140", "MB prof R [Copper];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("110", "MB prof Eta [Copper];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("120", "MB prof Phi [Copper];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("130", "MB prof Eta Phi [Copper];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("140", "MB prof R [Copper];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("150", "MB prof sum R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("152", "MB ortho prof sum R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("160", "MB prof local R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -61,10 +73,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("172", "MB ortho prof local R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // H_Scintillator - hmgr->addHistoProf1( new TProfile("210", "MB prof Eta [Scintillator];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("220", "MB prof Phi [Scintillator];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("230", "MB prof Eta Phi [Scintillator];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("240", "MB prof R [Scintillator];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("210", "MB prof Eta [Scintillator];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("220", "MB prof Phi [Scintillator];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("230", "MB prof Eta Phi [Scintillator];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("240", "MB prof R [Scintillator];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("250", "MB prof sum R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("252", "MB ortho prof sum R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("260", "MB prof local R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -72,10 +84,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("272", "MB ortho prof local R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Cables - hmgr->addHistoProf1( new TProfile("310", "MB prof Eta [Cables];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("320", "MB prof Phi [Cables];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("330", "MB prof Eta Phi [Cables];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("340", "MB prof R [Cables];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("310", "MB prof Eta [Cables];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("320", "MB prof Phi [Cables];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("330", "MB prof Eta Phi [Cables];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("340", "MB prof R [Cables];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("350", "MB prof sum R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("352", "MB ortho prof sum R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("360", "MB prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -83,10 +95,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("372", "MB ortho prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // HGC_G10_FR4 - hmgr->addHistoProf1( new TProfile("410", "MB prof Eta [HGC_G10_FR4];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("420", "MB prof Phi [HGC_G10_FR4];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("430", "MB prof Eta Phi [HGC_G10_FR4];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("440", "MB prof R [HGC_G10_FR4];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("410", "MB prof Eta [HGC_G10_FR4];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("420", "MB prof Phi [HGC_G10_FR4];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("430", "MB prof Eta Phi [HGC_G10_FR4];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("440", "MB prof R [HGC_G10_FR4];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("450", "MB prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("452", "MB ortho prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("460", "MB prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -94,10 +106,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("472", "MB ortho prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Silicon - hmgr->addHistoProf1( new TProfile("510", "MB prof Eta [Silicon];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("520", "MB prof Phi [Silicon];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("530", "MB prof Eta Phi [Silicon];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("540", "MB prof R [Silicon];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("510", "MB prof Eta [Silicon];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("520", "MB prof Phi [Silicon];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("530", "MB prof Eta Phi [Silicon];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("540", "MB prof R [Silicon];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("550", "MB prof sum R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("552", "MB ortho prof sum R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("560", "MB prof local R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -105,10 +117,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("572", "MB ortho prof local R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Other - hmgr->addHistoProf1( new TProfile("610", "MB prof Eta [Other];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("620", "MB prof Phi [Other];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("630", "MB prof Eta Phi [Other];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("640", "MB prof R [Other];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("610", "MB prof Eta [Other];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("620", "MB prof Phi [Other];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("630", "MB prof Eta Phi [Other];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("640", "MB prof R [Other];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("650", "MB prof sum R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("652", "MB ortho prof sum R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("660", "MB prof local R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -116,10 +128,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("672", "MB ortho prof local R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Air - hmgr->addHistoProf1( new TProfile("710", "MB prof Eta [Air];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("720", "MB prof Phi [Air];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("730", "MB prof Eta Phi [Air];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("740", "MB prof R [Air];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("710", "MB prof Eta [Air];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("720", "MB prof Phi [Air];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("730", "MB prof Eta Phi [Air];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("740", "MB prof R [Air];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("750", "MB prof sum R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("752", "MB ortho prof sum R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("760", "MB prof local R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -127,10 +139,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("772", "MB ortho prof local R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); //StainlessSteel - hmgr->addHistoProf1( new TProfile("810", "MB prof Eta [StainlessSteel];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("820", "MB prof Phi [StainlessSteel];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("830", "MB prof Eta Phi [StainlessSteel];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("840", "MB prof R [StainlessSteel];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("810", "MB prof Eta [StainlessSteel];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("820", "MB prof Phi [StainlessSteel];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("830", "MB prof Eta Phi [StainlessSteel];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("840", "MB prof R [StainlessSteel];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("850", "MB prof sum R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("852", "MB ortho prof sum R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("860", "MB prof local R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -138,10 +150,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("872", "MB ortho prof local R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); //WCu - hmgr->addHistoProf1( new TProfile("910", "MB prof Eta [WCu];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("920", "MB prof Phi [WCu];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("930", "MB prof Eta Phi [WCu];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("940", "MB prof R [WCu];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("910", "MB prof Eta [WCu];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("920", "MB prof Phi [WCu];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("930", "MB prof Eta Phi [WCu];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("940", "MB prof R [WCu];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("950", "MB prof sum R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("952", "MB ortho prof sum R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("960", "MB prof local R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -149,10 +161,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("972", "MB ortho prof local R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Lead - hmgr->addHistoProf1( new TProfile("1010", "MB prof Eta [Lead];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("1020", "MB prof Phi [Lead];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("1030", "MB prof Eta Phi [Lead];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("1040", "MB prof R [Lead];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("1010", "MB prof Eta [Lead];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("1020", "MB prof Phi [Lead];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("1030", "MB prof Eta Phi [Lead];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("1040", "MB prof R [Lead];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("1050", "MB prof sum R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1052", "MB ortho prof sum R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("1060", "MB prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -160,10 +172,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("1072", "MB ortho prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Epoxy - hmgr->addHistoProf1( new TProfile("1110", "MB prof Eta [Epoxy];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("1120", "MB prof Phi [Epoxy];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("1130", "MB prof Eta Phi [Epoxy];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("1140", "MB prof R [Epoxy];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("1110", "MB prof Eta [Epoxy];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("1120", "MB prof Phi [Epoxy];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("1130", "MB prof Eta Phi [Epoxy];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("1140", "MB prof R [Epoxy];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("1150", "MB prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1152", "MB ortho prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("1160", "MB prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -171,10 +183,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("1172", "MB ortho prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Kapton - hmgr->addHistoProf1( new TProfile("1210", "MB prof Eta [Kapton];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("1220", "MB prof Phi [Kapton];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("1230", "MB prof Eta Phi [Kapton];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("1240", "MB prof R [Kapton];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("1210", "MB prof Eta [Kapton];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("1220", "MB prof Phi [Kapton];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("1230", "MB prof Eta Phi [Kapton];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("1240", "MB prof R [Kapton];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("1250", "MB prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1252", "MB ortho prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("1260", "MB prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -182,10 +194,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("1272", "MB ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Aluminium - hmgr->addHistoProf1( new TProfile("1310", "MB prof Eta [Aluminium];#eta;x/X_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("1320", "MB prof Phi [Aluminium];#varphi [rad];x/X_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("1330", "MB prof Eta Phi [Aluminium];#eta;#varphi;x/X_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("1340", "MB prof R [Aluminium];R [mm];x/X_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("1310", "MB prof Eta [Aluminium];#eta;x/X_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("1320", "MB prof Phi [Aluminium];#varphi [rad];x/X_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("1330", "MB prof Eta Phi [Aluminium];#eta;#varphi;x/X_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("1340", "MB prof R [Aluminium];R [mm];x/X_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("1350", "MB prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("1352", "MB ortho prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("1360", "MB prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -194,12 +206,12 @@ void MaterialBudgetHGCalHistos::book() //========================================================================================================= // total Lambda0 - hmgr->addHistoProf1( new TProfile("10010", "IL prof Eta;#eta;#lambda/#lambda_{0} ", 250, -5., 5. ) ); - hmgr->addHistoProf1( new TProfile("10020", "IL prof Phi;#varphi [rad];#lambda/#lambda_{0} ", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10030", "IL prof Eta Phi;#eta;#varphi;#lambda/#lambda_{0} ", 250, -5., 5., 180, -3.2, 3.2 ) ); + hmgr->addHistoProf1( new TProfile("10010", "IL prof Eta;#eta;#lambda/#lambda_{0} ", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10020", "IL prof Phi;#varphi [rad];#lambda/#lambda_{0} ", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10030", "IL prof Eta Phi;#eta;#varphi;#lambda/#lambda_{0} ", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); // rr - hmgr->addHistoProf1( new TProfile("10040", "IL prof R;R [mm];#lambda/#lambda_{0} ", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10040", "IL prof R;R [mm];#lambda/#lambda_{0} ", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10050", "IL prof sum R z;z [mm];R [mm];#lambda/#lambda_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10052", "IL ortho prof sum R z;z [mm];R [mm];#lambda/#lambda_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("1999", "Tot track length for l0", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -208,10 +220,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10072", "IL ortho prof local R z;z [mm];R [mm];#lambda/#lambda_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Copper - hmgr->addHistoProf1( new TProfile("10110", "IL prof Eta [Copper];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10120", "IL prof Phi [Copper];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10130", "IL prof Eta Phi [Copper];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10140", "IL prof R [Copper];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10110", "IL prof Eta [Copper];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10120", "IL prof Phi [Copper];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10130", "IL prof Eta Phi [Copper];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10140", "IL prof R [Copper];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10150", "IL prof sum R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10152", "IL ortho prof sum R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10160", "IL prof local R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -219,10 +231,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10172", "IL ortho prof local R z [Copper];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // H_Scintillator - hmgr->addHistoProf1( new TProfile("10210", "IL prof Eta [Scintillator];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10220", "IL prof Phi [Scintillator];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10230", "IL prof Eta Phi [Scintillator];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10240", "IL prof R [Scintillator];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10210", "IL prof Eta [Scintillator];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10220", "IL prof Phi [Scintillator];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10230", "IL prof Eta Phi [Scintillator];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10240", "IL prof R [Scintillator];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10250", "IL prof sum R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10252", "IL ortho prof sum R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10260", "IL prof local R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -230,10 +242,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10272", "IL ortho prof local R z [Scintillator];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Cables - hmgr->addHistoProf1( new TProfile("10310", "IL prof Eta [Cables];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10320", "IL prof Phi [Cables];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10330", "IL prof Eta Phi [Cables];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10340", "IL prof R [Cables];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10310", "IL prof Eta [Cables];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10320", "IL prof Phi [Cables];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10330", "IL prof Eta Phi [Cables];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10340", "IL prof R [Cables];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10350", "IL prof sum R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10352", "IL ortho prof sum R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10360", "IL prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -241,10 +253,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10372", "IL ortho prof local R z [Cables];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // HGC_G10_FR4 - hmgr->addHistoProf1( new TProfile("10410", "IL prof Eta [HGC_G10_FR4];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10420", "IL prof Phi [HGC_G10_FR4];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10430", "IL prof Eta Phi [HGC_G10_FR4];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10440", "IL prof R [HGC_G10_FR4];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10410", "IL prof Eta [HGC_G10_FR4];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10420", "IL prof Phi [HGC_G10_FR4];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10430", "IL prof Eta Phi [HGC_G10_FR4];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10440", "IL prof R [HGC_G10_FR4];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10450", "IL prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10452", "IL ortho prof sum R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10460", "IL prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -252,10 +264,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10472", "IL ortho prof local R z [HGC_G10_FR4];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Silicon - hmgr->addHistoProf1( new TProfile("10510", "IL prof Eta [Silicon];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10520", "IL prof Phi [Silicon];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10530", "IL prof Eta Phi [Silicon];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10540", "IL prof R [Silicon];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10510", "IL prof Eta [Silicon];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10520", "IL prof Phi [Silicon];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10530", "IL prof Eta Phi [Silicon];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10540", "IL prof R [Silicon];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10550", "IL prof sum R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10552", "IL ortho prof sum R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10560", "IL prof local R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -263,10 +275,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10572", "IL ortho prof local R z [Silicon];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Other - hmgr->addHistoProf1( new TProfile("10610", "IL prof Eta [Other];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10620", "IL prof Phi [Other];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10630", "IL prof Eta Phi [Other];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10640", "IL prof R [Other];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10610", "IL prof Eta [Other];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10620", "IL prof Phi [Other];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10630", "IL prof Eta Phi [Other];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10640", "IL prof R [Other];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10650", "IL prof sum R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10652", "IL ortho prof sum R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10660", "IL prof local R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -274,10 +286,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10672", "IL ortho prof local R z [Other];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Air - hmgr->addHistoProf1( new TProfile("10710", "IL prof Eta [Air];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10720", "IL prof Phi [Air];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10730", "IL prof Eta Phi [Air];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10740", "IL prof R [Air];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10710", "IL prof Eta [Air];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10720", "IL prof Phi [Air];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10730", "IL prof Eta Phi [Air];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10740", "IL prof R [Air];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10750", "IL prof sum R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10752", "IL ortho prof sum R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10760", "IL prof local R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -285,10 +297,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10772", "IL ortho prof local R z [Air];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); //StainlessSteel - hmgr->addHistoProf1( new TProfile("10810", "IL prof Eta [StainlessSteel];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10820", "IL prof Phi [StainlessSteel];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10830", "IL prof Eta Phi [StainlessSteel];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10840", "IL prof R [StainlessSteel];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10810", "IL prof Eta [StainlessSteel];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10820", "IL prof Phi [StainlessSteel];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10830", "IL prof Eta Phi [StainlessSteel];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10840", "IL prof R [StainlessSteel];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10850", "IL prof sum R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10852", "IL ortho prof sum R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10860", "IL prof local R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -296,10 +308,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10872", "IL ortho prof local R z [StainlessSteel];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); //WCu - hmgr->addHistoProf1( new TProfile("10910", "IL prof Eta [WCu];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("10920", "IL prof Phi [WCu];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("10930", "IL prof Eta Phi [WCu];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("10940", "IL prof R [WCu];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("10910", "IL prof Eta [WCu];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("10920", "IL prof Phi [WCu];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("10930", "IL prof Eta Phi [WCu];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("10940", "IL prof R [WCu];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("10950", "IL prof sum R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("10952", "IL ortho prof sum R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("10960", "IL prof local R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -307,10 +319,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("10972", "IL ortho prof local R z [WCu];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Lead - hmgr->addHistoProf1( new TProfile("11010", "IL prof Eta [Lead];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("11020", "IL prof Phi [Lead];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("11030", "IL prof Eta Phi [Lead];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("11040", "IL prof R [Lead];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("11010", "IL prof Eta [Lead];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("11020", "IL prof Phi [Lead];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("11030", "IL prof Eta Phi [Lead];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("11040", "IL prof R [Lead];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("11050", "IL prof sum R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11052", "IL ortho prof sum R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("11060", "IL prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -318,10 +330,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("11072", "IL ortho prof local R z [Lead];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Epoxy - hmgr->addHistoProf1( new TProfile("11110", "IL prof Eta [Epoxy];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("11120", "IL prof Phi [Epoxy];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("11130", "IL prof Eta Phi [Epoxy];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("11140", "IL prof R [Epoxy];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("11110", "IL prof Eta [Epoxy];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("11120", "IL prof Phi [Epoxy];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("11130", "IL prof Eta Phi [Epoxy];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("11140", "IL prof R [Epoxy];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("11150", "IL prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11152", "IL ortho prof sum R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("11160", "IL prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -329,10 +341,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("11172", "IL ortho prof local R z [Epoxy];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Kapton - hmgr->addHistoProf1( new TProfile("11210", "IL prof Eta [Kapton];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("11220", "IL prof Phi [Kapton];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("11230", "IL prof Eta Phi [Kapton];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("11240", "IL prof R [Kapton];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("11210", "IL prof Eta [Kapton];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("11220", "IL prof Phi [Kapton];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("11230", "IL prof Eta Phi [Kapton];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("11240", "IL prof R [Kapton];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("11250", "IL prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11252", "IL ortho prof sum R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("11260", "IL prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); @@ -340,10 +352,10 @@ void MaterialBudgetHGCalHistos::book() hmgr->addHistoProf2( new TProfile2D("11272", "IL ortho prof local R z [Kapton];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); // Aluminium - hmgr->addHistoProf1( new TProfile("11310", "IL prof Eta [Aluminium];#eta;#lambda/#lambda_{0}", 250, -5.0, 5.0 ) ); - hmgr->addHistoProf1( new TProfile("11320", "IL prof Phi [Aluminium];#varphi [rad];#lambda/#lambda_{0}", 180, -3.2, 3.2 ) ); - hmgr->addHistoProf2( new TProfile2D("11330", "IL prof Eta Phi [Aluminium];#eta;#varphi;#lambda/#lambda_{0}", 250, -5., 5., 180, -3.2, 3.2 ) ); - hmgr->addHistoProf1( new TProfile("11340", "IL prof R [Aluminium];R [mm];#lambda/#lambda_{0}", 300, 0., 3000. ) ); + hmgr->addHistoProf1( new TProfile("11310", "IL prof Eta [Aluminium];#eta;#lambda/#lambda_{0}", netabin, etaMin, etaMax ) ); + hmgr->addHistoProf1( new TProfile("11320", "IL prof Phi [Aluminium];#varphi [rad];#lambda/#lambda_{0}", nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf2( new TProfile2D("11330", "IL prof Eta Phi [Aluminium];#eta;#varphi;#lambda/#lambda_{0}", netabin, etaMin, etaMax, nphibin, phiMin, phiMax ) ); + hmgr->addHistoProf1( new TProfile("11340", "IL prof R [Aluminium];R [mm];#lambda/#lambda_{0}", nRbin, RMin, RMax ) ); hmgr->addHistoProf2( new TProfile2D("11350", "IL prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHistoProf2( new TProfile2D("11352", "IL ortho prof sum R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); hmgr->addHisto2( new TH2F("11360", "IL prof local R z [Aluminium];z [mm];R [mm];x/X_{0} ", nzbin, zMin, zMax, nrbin, rMin, rMax ) ); From 8b8cdcefb55fe37d6d58fcd8ebf2206fd9c1738f Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Thu, 11 Apr 2019 10:17:07 +0200 Subject: [PATCH 576/686] v9 and v10 fCperMIP are the same --- .../HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py index 8c0eada107873..83fedabd3cee0 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py @@ -4,7 +4,7 @@ fCPerMIP_v9 = cms.vdouble(2.06,3.43,5.15) #120um, 200um, 300um -fCPerMIP_v10 = cms.vdouble(2.06,3.43,5.15) #120um, 200um, 300um +fCPerMIP_v10 = fCPerMIP_v9 # HGCAL producer of rechits starting from digis HGCalUncalibRecHit = cms.EDProducer( From 760a3d4549472568ca21a15a72820da4ae0d41d1 Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Thu, 11 Apr 2019 10:18:11 +0200 Subject: [PATCH 577/686] Using edm::isNotFinite instead of std::isnan --- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index e61a89110ea27..1483568984c46 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -7,6 +7,7 @@ ****************************************************************************/ #include "RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h" +#include "FWCore/Utilities/interface/isNotFinite.h" #include // isnan //---------------------------------------------------------------------------------------------------- @@ -66,7 +67,7 @@ CTPPSDiamondRecHitProducerAlgorithm::build( const CTPPSGeometry& geom, if ( calib_fct_ ) { // compute the time-walk correction ch_t_twc = calib_fct_->evaluate( std::vector{ tot }, ch_params ); - if ( std::isnan( ch_t_twc ) ) + if ( edm::isNotFinite( ch_t_twc ) ) ch_t_twc = 0.; } } From 1818129ec4ea48a915945da56b663a94c59d50ee Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Thu, 11 Apr 2019 10:24:34 +0200 Subject: [PATCH 578/686] Update FiniteMathChecker.cc Updated the path to the `edm::isNotFinite` header. --- Utilities/StaticAnalyzers/src/FiniteMathChecker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc b/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc index dc077b2df35e4..077c279f23b5a 100644 --- a/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc +++ b/Utilities/StaticAnalyzers/src/FiniteMathChecker.cc @@ -35,7 +35,7 @@ void FiniteMathChecker::checkPreStmt(const clang::CallExpr *CE, clang::ento::Che return; if (!BT) - BT.reset(new clang::ento::BugType(this,"std::isnan / std::isinf does not work when fast-math is used. Please use edm::isNotFinite from 'FWCore/Utilities/interface/isNotFinite.h'", "fastmath plugin")); + BT.reset(new clang::ento::BugType(this,"std::isnan / std::isinf does not work when fast-math is used. Please use edm::isNotFinite from 'FWCore/Utilities/interface/isFinite.h'", "fastmath plugin")); std::unique_ptr report = llvm::make_unique(*BT, BT->getName(), N); report->addRange(Callee->getSourceRange()); From 149e39974e846449be50f2e5a664c01a356bd6ef Mon Sep 17 00:00:00 2001 From: Laurent Forthomme Date: Thu, 11 Apr 2019 10:29:54 +0200 Subject: [PATCH 579/686] Corrected include path to isNotFinite definition header --- .../TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc index 1483568984c46..9eaff7da82a78 100644 --- a/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoCTPPS/TotemRPLocal/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -7,8 +7,7 @@ ****************************************************************************/ #include "RecoCTPPS/TotemRPLocal/interface/CTPPSDiamondRecHitProducerAlgorithm.h" -#include "FWCore/Utilities/interface/isNotFinite.h" -#include // isnan +#include "FWCore/Utilities/interface/isFinite.h" //---------------------------------------------------------------------------------------------------- From 7e0cac3ac7e5395da613b78b8650db9d66e57692 Mon Sep 17 00:00:00 2001 From: Andreas Psallidas Date: Thu, 11 Apr 2019 10:47:23 +0200 Subject: [PATCH 580/686] safer type for thickness corrections --- RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py index 5d15f8c8ed4c3..e3b1430a0da74 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalRecHit_cfi.py @@ -210,5 +210,5 @@ ) -phase2_hgcalV9.toModify( HGCalRecHit , thicknessCorrection = cms.vdouble(0.759,0.760,0.773) ) #120um, 200um, 300um -phase2_hgcalV10.toModify( HGCalRecHit , thicknessCorrection = cms.vdouble(0.781,0.775,0.769) ) #120um, 200um, 300um +phase2_hgcalV9.toModify( HGCalRecHit , thicknessCorrection = [0.759,0.760,0.773] ) #120um, 200um, 300um +phase2_hgcalV10.toModify( HGCalRecHit , thicknessCorrection = [0.781,0.775,0.769] ) #120um, 200um, 300um From 580c1740dc59e5b89e511ad16266c430c022b2c2 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 11 Apr 2019 11:39:26 +0200 Subject: [PATCH 581/686] introduce call_once to initialize static objects, this removes the clang warning --- .../plugins/NuclearInteraction.cc | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc index 3d1420116f355..37d155538da9b 100644 --- a/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc +++ b/FastSimulation/SimplifiedGeometryPropagator/plugins/NuclearInteraction.cc @@ -220,32 +220,35 @@ fastsim::NuclearInteraction::NuclearInteraction(const std::string & name,const e inputFile = cfg.getUntrackedParameter("inputFile",""); // The evolution of the interaction lengths with energy - theRatiosMap.resize(theHadronID.size()); - for(unsigned i=0; i Date: Thu, 11 Apr 2019 12:37:56 +0200 Subject: [PATCH 582/686] Fix a long-standing bug in DQMStore. Changing the std::set while iterating over it is not a good idea (even UB?). This caused some per-lumi MEs to be doubly cloned, and effectively a reset histogram was written to the output in some cases. --- DQMServices/Core/src/DQMStore.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DQMServices/Core/src/DQMStore.cc b/DQMServices/Core/src/DQMStore.cc index 7382e1207cfdd..a885d8f1d3eef 100644 --- a/DQMServices/Core/src/DQMStore.cc +++ b/DQMServices/Core/src/DQMStore.cc @@ -1933,7 +1933,12 @@ DQMStore::cloneLumiHistograms(uint32_t const run, uint32_t const lumi, uint32_t std::string null_str(""); auto i = data_.lower_bound(MonitorElement(&null_str, null_str, run, moduleId)); auto e = data_.lower_bound(MonitorElement(&null_str, null_str, run, moduleId + 1)); + // we will later modify data_, so better do two passes. + auto tobehandled = std::vector(); for (; i != e; ++i) { + tobehandled.push_back(&*i); + } + for (auto i : tobehandled) { // handle only lumisection-based histograms if (not LSbasedMode_ and not i->getLumiFlag()) continue; @@ -1970,7 +1975,12 @@ DQMStore::cloneRunHistograms(uint32_t const run, uint32_t const moduleId) std::string null_str(""); auto i = data_.lower_bound(MonitorElement(&null_str, null_str, run, moduleId)); auto e = data_.lower_bound(MonitorElement(&null_str, null_str, run, moduleId + 1)); + // we will later modify data_, so better do two passes. + auto tobehandled = std::vector(); for (; i != e; ++i) { + tobehandled.push_back(&*i); + } + for (auto i : tobehandled) { // handle only non lumisection-based histograms if (LSbasedMode_ or i->getLumiFlag()) continue; From 5026817b3504ca6af7ba38578155fab42e60d9ec Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 11 Apr 2019 15:03:34 +0200 Subject: [PATCH 583/686] Fix include for HFStripFilter --- RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h | 1 + RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h index cfd483d71826d..127f9acaf8973 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h @@ -5,6 +5,7 @@ #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" class HFStripFilter { diff --git a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc index 698c5ae6c02b2..667116aa2b9ef 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/HFStripFilter.cc @@ -1,7 +1,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h" -#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" #include "RecoLocalCalo/HcalRecAlgos/interface/HFStripFilter.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" From b68fac585b4c3554d439aa9880eed82f9abbf9b6 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Thu, 11 Apr 2019 16:33:13 +0200 Subject: [PATCH 584/686] Turn off per lumi saving by default. --- DQMServices/Core/python/DQMStore_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/Core/python/DQMStore_cfi.py b/DQMServices/Core/python/DQMStore_cfi.py index 271026140fba7..401c29935f87f 100644 --- a/DQMServices/Core/python/DQMStore_cfi.py +++ b/DQMServices/Core/python/DQMStore_cfi.py @@ -13,5 +13,5 @@ forceResetOnBeginLumi = cms.untracked.bool(False), # similar to LSBasedMode but for offline. Explicitly sets LumiFLag on all # MEs/modules that allow it (canSaveByLumi) - saveByLumi = cms.untracked.bool(True), + saveByLumi = cms.untracked.bool(False), ) From bb668a8c844ce6b075ea2bd3924811cbaef7d4e8 Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Thu, 11 Apr 2019 19:15:52 +0200 Subject: [PATCH 585/686] Replace remaining cout by LogInfo --- Validation/MuonHits/src/CSCSimHitMatcher.cc | 5 +++-- Validation/MuonHits/src/DTSimHitMatcher.cc | 4 ++-- Validation/MuonHits/src/GEMSimHitMatcher.cc | 5 +++-- Validation/MuonHits/src/ME0SimHitMatcher.cc | 7 ++++--- Validation/MuonHits/src/RPCSimHitMatcher.cc | 5 +++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index 415535b36c058..dd35bc812e858 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -54,8 +54,9 @@ void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { edm::LogInfo("CSCSimHitMatcher") << "nStrip " << strips.size() << endl; edm::LogInfo("CSCSimHitMatcher") << "strips : "; - std::copy(strips.begin(), strips.end(), - ostream_iterator(cout, " ")); + for (const auto& p : strips) { + edm::LogInfo("CSCSimHitMatcher") << p; + } } } } diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index 194b273e7935d..5b1299d4f0517 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -37,10 +37,10 @@ void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { if (verbose_) { edm::LogInfo("DTSimHitMatcher") - << "nTrackIds " << track_ids_.size() << " nSelectedGEMSimHits " + << "nTrackIds " << track_ids_.size() << " nSelectedDTSimHits " << hits_.size() << endl; edm::LogInfo("DTSimHitMatcher") - << "detids GEM " << detIds(0).size() << endl; + << "detids DT " << detIds(0).size() << endl; const auto& dt_det_ids = detIds(0); for (const auto& id : dt_det_ids) { diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index ec2e0dbcf9d77..f5f61286c1f7b 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -53,8 +53,9 @@ void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { const auto& strips = hitStripsInDetId(id); edm::LogInfo("GEMSimHitMatcher") << "nStrip " << strips.size() << endl; edm::LogInfo("GEMSimHitMatcher") << "strips : "; - std::copy(strips.begin(), strips.end(), - ostream_iterator(cout, " ")); + for (const auto& p : strips) { + edm::LogInfo("GEMSimHitMatcher") << p; + } } const auto& gem_sch_ids = superChamberIds(); for (const auto& id : gem_sch_ids) { diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index 0d6693d5169a8..eb25c3318c06a 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -53,8 +53,9 @@ void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { const auto& strips = hitStripsInDetId(id); edm::LogInfo("ME0SimHitMatcher") << "nStrip " << strips.size() << endl; edm::LogInfo("ME0SimHitMatcher") << "strips : "; - std::copy(strips.begin(), strips.end(), - ostream_iterator(cout, " ")); + for (const auto& p : strips) { + edm::LogInfo("ME0SimHitMatcher") << p; + } } } } @@ -82,7 +83,7 @@ void ME0SimHitMatcher::matchSimHitsToSimTrack( // find pads with hits const auto& detids = detIds(); for (const auto& d : detids) { - GEMDetId id(d); + ME0DetId id(d); const auto& hits = hitsInDetId(d); const auto& roll = dynamic_cast(geometry_)->etaPartition(id); diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index addd970c5c7b1..3887e7a72840b 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -54,8 +54,9 @@ void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { const auto& strips = hitStripsInDetId(id); edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl; edm::LogInfo("RPCSimHitMatcher") << "strips : "; - std::copy(strips.begin(), strips.end(), - ostream_iterator(std::cout, " ")); + for (const auto& p : strips){ + edm::LogInfo("RPCSimHitMatcher") << p; + } } } } From 468cac2ab542a92d97ec6f18013dcbd29a07bac2 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 11 Apr 2019 19:52:17 +0200 Subject: [PATCH 586/686] Update the packages for code format an correct TB geometry for scenario 1 of October TB --- .../data/TB181/Oct181/hgcal.xml | 5 +- .../data/TB181/Oct181/hgcalHE.xml | 51 +- .../interface/FastTimeDDDConstants.h | 51 +- .../interface/FastTimeParameters.h | 22 +- .../interface/FastTimeParametersFromDD.h | 9 +- .../interface/HGCalDDDConstants.h | 302 ++-- .../interface/HGCalGeomParameters.h | 52 +- .../interface/HGCalGeomTools.h | 28 +- .../interface/HGCalGeometryMode.h | 30 +- .../interface/HGCalParameters.h | 289 ++-- .../interface/HGCalParametersFromDD.h | 14 +- .../interface/HGCalWaferIndex.h | 9 +- .../interface/HGCalWaferType.h | 43 +- .../plugins/DDAHcalModuleAlgo.cc | 254 +-- .../plugins/DDAHcalModuleAlgo.h | 66 +- .../HGCalCommonData/plugins/DDHGCalCell.cc | 387 +++-- .../HGCalCommonData/plugins/DDHGCalCell.h | 42 +- .../HGCalCommonData/plugins/DDHGCalEEAlgo.cc | 486 +++--- .../HGCalCommonData/plugins/DDHGCalEEAlgo.h | 93 +- .../HGCalCommonData/plugins/DDHGCalHEAlgo.cc | 773 +++++---- .../HGCalCommonData/plugins/DDHGCalHEAlgo.h | 124 +- .../HGCalCommonData/plugins/DDHGCalModule.cc | 355 ++-- .../HGCalCommonData/plugins/DDHGCalModule.h | 76 +- .../plugins/DDHGCalModuleAlgo.cc | 333 ++-- .../plugins/DDHGCalModuleAlgo.h | 78 +- .../plugins/DDHGCalNoTaperEndcap.cc | 188 +-- .../plugins/DDHGCalNoTaperEndcap.h | 58 +- .../plugins/DDHGCalTBModule.cc | 353 ++-- .../HGCalCommonData/plugins/DDHGCalTBModule.h | 84 +- .../plugins/DDHGCalTBModuleX.cc | 481 +++--- .../plugins/DDHGCalTBModuleX.h | 98 +- .../HGCalCommonData/plugins/DDHGCalWafer.cc | 126 +- .../HGCalCommonData/plugins/DDHGCalWafer.h | 41 +- .../HGCalCommonData/plugins/DDHGCalWafer8.cc | 162 +- .../HGCalCommonData/plugins/DDHGCalWafer8.h | 36 +- .../plugins/DDHGCalWaferAlgo.cc | 97 +- .../plugins/DDHGCalWaferAlgo.h | 43 +- .../FastTimeNumberingInitialization.cc | 28 +- .../plugins/FastTimeParametersESModule.cc | 70 +- .../plugins/HGCalNumberingInitialization.cc | 39 +- .../plugins/HGCalParametersESModule.cc | 45 +- Geometry/HGCalCommonData/plugins/module.cc | 43 +- .../src/FastTimeDDDConstants.cc | 190 +-- .../HGCalCommonData/src/FastTimeParameters.cc | 4 +- .../src/FastTimeParametersFromDD.cc | 93 +- .../HGCalCommonData/src/HGCalDDDConstants.cc | 1430 +++++++++-------- .../src/HGCalGeomParameters.cc | 1416 ++++++++-------- .../HGCalCommonData/src/HGCalGeomTools.cc | 117 +- .../HGCalCommonData/src/HGCalGeometryMode.cc | 28 +- .../HGCalCommonData/src/HGCalParameters.cc | 166 +- .../src/HGCalParametersFromDD.cc | 409 ++--- .../HGCalCommonData/src/HGCalWaferIndex.cc | 54 +- .../HGCalCommonData/src/HGCalWaferType.cc | 207 +-- .../test/FastTimeNumberingTester.cc | 56 +- .../HGCalCommonData/test/HGCGeometryTester.cc | 81 +- .../test/HGCalNumberingTester.cc | 283 ++-- .../test/HGCalParameterTester.cc | 502 +++--- .../test/HGCalParametersAnalyzer.cc | 279 ++-- .../test/dumpTBGeometry_cfg.py | 3 +- SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h | 33 +- SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc | 136 +- SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc | 222 ++- SimG4CMS/HGCalTestBeam/plugins/HGCPassive.h | 84 +- .../HGCalTestBeam/plugins/HGCalTB16SD01.cc | 154 +- .../HGCalTestBeam/plugins/HGCalTBAnalyzer.cc | 1178 +++++++------- .../plugins/HGCalTBCheckGunPosition.cc | 118 +- SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc | 167 +- .../plugins/HGCalTimingAnalyzer.cc | 313 ++-- SimG4CMS/HGCalTestBeam/src/AHCalDetId.cc | 71 +- 69 files changed, 6890 insertions(+), 6868 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml index 14fc0964acb48..62529f96d7c80 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml @@ -94,7 +94,6 @@ - @@ -226,6 +225,10 @@ + + + + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml index 3bc53cfe108f4..9066d354ac65a 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml @@ -19,11 +19,12 @@ hgcalwafer:HGCalHEWaferFine, hgcalwafer:HGCalHEWaferCoarse - + hgcal:HGCalHESiliconSensitive, hgcal:HGCalHEPCB, hgcal:HGCalHEKapton, hgcal:HGCalHEAbsorber, hgcal:HGCalHECuAbsorber, hgcal:HGCalHEPCBAbsorber, - hgcal:HGCalHECuKapton, hgcal:HGCalHECuPCB + hgcal:HGCalHECuKapton, hgcal:HGCalHECuPCB, + hgcal:HGCalHEAirAbsorber materials:Air, materials:Air, materials:Air, materials:Air, materials:Air, materials:Iron, @@ -121,18 +122,18 @@ 23, 5, 15, 0, 28, 7, 7, 7, 27, 1, 2, 6, 21, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, 20, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, 26, 8, - 40, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 53, 37, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 48, 37, 43, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 50, 37, 42, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 52, 37, 62, 63, 32, 60, 39, 39, 39, 36, 38, - 51, 37, 41, 63, 32, 60, 39, 39, 39, 59, 33, 59, 33, 35, 38, - 49, 40, 56, 37, 57, 40, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 52, 37, 45, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, - 54, 37, 44, 63, 32, 60, 39, 39, 39, 59, 33, 34, 38, - 55, 37, 47, 63, 32, 60, 39, 39, 39, 59, 33, 38, - 53, 37, 46, 63, 32, 60, 39, 39, 39, 59, 33, 38, - 52, 37, 46, 63, 32, 60, 39, 39, 39, 59, 33, 38, 58, 40 + 40, 61, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 53, 37, 61, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 48, 37, 43, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 50, 37, 42, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 52, 37, 62, 32, 60, 39, 39, 39, 36, 63, 38, + 51, 37, 41, 32, 60, 39, 39, 39, 59, 33, 59, 33, 35, 63, 38, + 49, 40, 56, 37, 57, 40, 61, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 52, 37, 45, 32, 60, 39, 39, 39, 59, 33, 35, 63, 38, + 54, 37, 44, 32, 60, 39, 39, 39, 59, 33, 34, 63, 38, + 55, 37, 47, 32, 60, 39, 39, 39, 59, 33, 34, 38, + 53, 37, 46, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 52, 37, 46, 32, 60, 39, 39, 39, 59, 33, 35, 38, 58, 40 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, @@ -147,18 +148,18 @@ 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, 0, 0, + 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 6, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 7, 3, 5, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 9, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 6, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 7, 3, 5, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, - 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, 0, 0 + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h b/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h index 63773f16999a3..69468b7bffd2e 100644 --- a/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h @@ -5,47 +5,44 @@ * * this class reads the constant section of * the numbering xml-file for fast timer device - * + * * \author Sunanda Banerjee, SINP * */ -#include -#include -#include +#include +#include +#include #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" class FastTimeDDDConstants { - -public: - + public: FastTimeDDDConstants(const FastTimeParameters* ftp); ~FastTimeDDDConstants(); - std::pair getZPhi(double z, double phi) const; - std::pair getEtaPhi(double r, double phi) const; - GlobalPoint getPosition(int type, int izeta, int iphi, - int zside) const; - std::vector getCorners(int type, int izeta,int iphi, - int zside) const; - int getCells(int type) const; - double getRin(int type) const; - double getRout(int type) const; - double getZHalf(int type) const; - double getZPos(int type) const; - bool isValidXY(int type, int izeta, int iphi) const; - int numberEtaZ(int type) const; - int numberPhi(int type) const; - -private: - void initialize(); + std::pair getZPhi(double z, double phi) const; + std::pair getEtaPhi(double r, double phi) const; + GlobalPoint getPosition(int type, int izeta, int iphi, int zside) const; + std::vector getCorners(int type, int izeta, int iphi, + int zside) const; + int getCells(int type) const; + double getRin(int type) const; + double getRout(int type) const; + double getZHalf(int type) const; + double getZPos(int type) const; + bool isValidXY(int type, int izeta, int iphi) const; + int numberEtaZ(int type) const; + int numberPhi(int type) const; + + private: + void initialize(); const FastTimeParameters* ftpar_; - double etaMin_, etaMax_, dEta_; - double dZBarrel_, dPhiBarrel_, dPhiEndcap_; - std::vector rLimits_; + double etaMin_, etaMax_, dEta_; + double dZBarrel_, dPhiBarrel_, dPhiEndcap_; + std::vector rLimits_; }; #endif diff --git a/Geometry/HGCalCommonData/interface/FastTimeParameters.h b/Geometry/HGCalCommonData/interface/FastTimeParameters.h index bed1fb1863c05..894408291d5cc 100644 --- a/Geometry/HGCalCommonData/interface/FastTimeParameters.h +++ b/Geometry/HGCalCommonData/interface/FastTimeParameters.h @@ -1,25 +1,23 @@ #ifndef Geometry_HGCalCommonData_FastTimeParameters_h #define Geometry_HGCalCommonData_FastTimeParameters_h -#include "CondFormats/Serialization/interface/Serializable.h" +#include +#include #include #include -#include -#include +#include "CondFormats/Serialization/interface/Serializable.h" class FastTimeParameters { - -public: - + public: FastTimeParameters(); ~FastTimeParameters(); - int nZBarrel_; - int nPhiBarrel_; - int nEtaEndcap_; - int nPhiEndcap_; - std::vector geomParBarrel_; - std::vector geomParEndcap_; + int nZBarrel_; + int nPhiBarrel_; + int nEtaEndcap_; + int nPhiEndcap_; + std::vector geomParBarrel_; + std::vector geomParEndcap_; COND_SERIALIZABLE; }; diff --git a/Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h b/Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h index aac1214d48366..3349e5316e9c2 100644 --- a/Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h +++ b/Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h @@ -8,13 +8,14 @@ class DDCompactView; class FastTimeParameters; class FastTimeParametersFromDD { -public: + public: FastTimeParametersFromDD() {} virtual ~FastTimeParametersFromDD() {} - bool build(const DDCompactView*, FastTimeParameters&, const std::string&, - const int); -private: + bool build(const DDCompactView *, FastTimeParameters &, const std::string &, + const int); + + private: std::vector getDDDArray(const std::string &, const DDsvalues_type &); }; diff --git a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h index c42bc4715bba9..27c7452e7ef11 100644 --- a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h @@ -5,170 +5,198 @@ * * this class reads the constant section of the numbering * xml-files of the high granulairy calorimeter - * + * * $Date: 2014/03/20 00:06:50 $ * \author Sunanda Banerjee, SINP * */ +#include #include #include -#include #include "DataFormats/DetId/interface/DetId.h" #include "DetectorDescription/Core/interface/DDsvalues.h" -#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include class HGCalDDDConstants { - -public: - + public: HGCalDDDConstants(const HGCalParameters* hp, const std::string& name); ~HGCalDDDConstants(); enum class CellType { - UndefinedType=-1, CentralType=0, BottomLeftEdge=1, LeftEdge=2, - TopLeftEdge=3, TopRightEdge=4, RightEdge=5, BottomRightEdge=6, - BottomCorner=11, BottomLeftCorner=12, TopLeftCorner=13, - TopCorner=14, TopRightCorner=15, BottomRightCorner=16}; + UndefinedType = -1, + CentralType = 0, + BottomLeftEdge = 1, + LeftEdge = 2, + TopLeftEdge = 3, + TopRightEdge = 4, + RightEdge = 5, + BottomRightEdge = 6, + BottomCorner = 11, + BottomLeftCorner = 12, + TopLeftCorner = 13, + TopCorner = 14, + TopRightCorner = 15, + BottomRightCorner = 16 + }; - std::pair assignCell(float x, float y, int lay, int subSec, - bool reco) const; - std::array assignCellHex(float x, float y, int lay, - bool reco) const; - std::array assignCellTrap(float x, float y, float z, int lay, - bool reco) const; - bool cellInLayer(int waferU, int waferV, int cellU, int cellV, - int lay, bool reco) const; - double cellSizeHex(int type) const; - std::pair cellSizeTrap(int type, int irad) const { - return std::pair(hgpar_->radiusLayer_[type][irad-1], - hgpar_->radiusLayer_[type][irad]); + std::pair assignCell(float x, float y, int lay, int subSec, + bool reco) const; + std::array assignCellHex(float x, float y, int lay, bool reco) const; + std::array assignCellTrap(float x, float y, float z, int lay, + bool reco) const; + bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, + bool reco) const; + double cellSizeHex(int type) const; + std::pair cellSizeTrap(int type, int irad) const { + return std::pair(hgpar_->radiusLayer_[type][irad - 1], + hgpar_->radiusLayer_[type][irad]); + } + double cellThickness(int layer, int waferU, int waferV) const; + CellType cellType(int type, int waferU, int waferV) const; + double distFromEdgeHex(double x, double y, double z) const; + double distFromEdgeTrap(double x, double y, double z) const; + void etaPhiFromPosition(const double x, const double y, const double z, + const int layer, int& ieta, int& iphi, int& type, + double& wt) const; + int firstLayer() const { return hgpar_->firstLayer_; } + HGCalGeometryMode::GeometryMode geomMode() const { return mode_; } + int getLayer(double z, bool reco) const; + HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, + bool reco) const; + std::vector getModules() const; + const HGCalParameters* getParameter() const { return hgpar_; } + int getPhiBins(int lay) const; + std::pair getREtaRange(int lay) const; + HGCalParameters::hgtrform getTrForm(unsigned int k) const { + return hgpar_->getTrForm(k); + } + unsigned int getTrFormN() const { return hgpar_->trformIndex_.size(); } + std::vector getTrForms() const; + int getTypeTrap(int layer) const; + int getTypeHex(int layer, int waferU, int waferV) const; + int getUVMax(int type) const { + return ((type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_); + } + bool isHalfCell(int waferType, int cell) const; + bool isValidHex(int lay, int mod, int cell, bool reco) const; + bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV) const; + bool isValidTrap(int lay, int ieta, int iphi) const; + int lastLayer(bool reco) const; + int layerIndex(int lay, bool reco) const; + unsigned int layers(bool reco) const; + unsigned int layersInit(bool reco) const; + std::pair locateCell(int cell, int lay, int type, + bool reco) const; + std::pair locateCell(int lay, int waferU, int waferV, int cellU, + int cellV, bool reco, bool all, + bool debug = false) const; + std::pair locateCellHex(int cell, int wafer, bool reco) const; + std::pair locateCellTrap(int lay, int ieta, int iphi, + bool reco) const; + int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; } + bool maskCell(const DetId& id, int corners) const; + int maxCellUV() const { + return ((mode_ == HGCalGeometryMode::Trapezoid) ? hgpar_->nCellsFine_ + : 2 * hgpar_->nCellsFine_); + } + int maxCells(bool reco) const; + int maxCells(int lay, bool reco) const; + int maxModules() const { return modHalf_; } + int maxMoudlesPerLayer() const { return maxWafersPerLayer_; } + int maxRows(int lay, bool reco) const; + double minSlope() const { return hgpar_->slopeMin_[0]; } + int modifyUV(int uv, int type1, int type2) const; + int modules(int lay, bool reco) const; + int modulesInit(int lay, bool reco) const; + double mouseBite(bool reco) const; + int numberCells(bool reco) const; + std::vector numberCells(int lay, bool reco) const; + int numberCellsHexagon(int wafer) const; + int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const; + std::pair rangeR(double z, bool reco) const; + std::pair rangeZ(bool reco) const; + std::pair rowColumnWafer(const int wafer) const; + int sectors() const { return hgpar_->nSectors_; } + std::pair simToReco(int cell, int layer, int mod, bool half) const; + unsigned int volumes() const { return hgpar_->moduleLayR_.size(); } + int waferFromCopy(int copy) const; + void waferFromPosition(const double x, const double y, int& wafer, int& icell, + int& celltyp) const; + void waferFromPosition(const double x, const double y, const int layer, + int& waferU, int& waferV, int& cellU, int& cellV, + int& celltype, double& wt, bool debug = false) const; + bool waferInLayer(int wafer, int lay, bool reco) const; + bool waferFullInLayer(int wafer, int lay, bool reco) const; + int waferCount(const int type) const { + return ((type == 0) ? waferMax_[2] : waferMax_[3]); + } + int waferMax() const { return waferMax_[1]; } + int waferMin() const { return waferMax_[0]; } + std::pair waferPosition(int wafer, bool reco) const; + std::pair waferPosition(int waferU, int waferV, + bool reco) const; + double waferSepar(bool reco) const { + return (reco ? hgpar_->sensorSeparation_ + : HGCalParameters::k_ScaleToDDD * hgpar_->sensorSeparation_); + } + double waferSize(bool reco) const { + return (reco ? hgpar_->waferSize_ + : HGCalParameters::k_ScaleToDDD * hgpar_->waferSize_); + } + int wafers() const; + int wafers(int layer, int type) const; + int waferToCopy(int wafer) const { + return ((wafer >= 0) && (wafer < (int)(hgpar_->waferCopy_.size()))) + ? hgpar_->waferCopy_[wafer] + : (int)(hgpar_->waferCopy_.size()); } - double cellThickness(int layer, int waferU, int waferV) const; - CellType cellType(int type, int waferU, int waferV) const; - double distFromEdgeHex(double x, double y, double z) const; - double distFromEdgeTrap(double x, double y, double z) const; - void etaPhiFromPosition(const double x, const double y, - const double z, const int layer, - int& ieta, int& iphi, int& type, - double& wt) const; - int firstLayer() const {return hgpar_->firstLayer_;} - HGCalGeometryMode::GeometryMode geomMode() const {return mode_;} - int getLayer(double z, bool reco) const; - HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const; - std::vector getModules() const; - const HGCalParameters* getParameter() const {return hgpar_;} - int getPhiBins(int lay) const; - std::pair getREtaRange(int lay) const; - HGCalParameters::hgtrform getTrForm(unsigned int k) const {return hgpar_->getTrForm(k);} - unsigned int getTrFormN() const {return hgpar_->trformIndex_.size();} - std::vector getTrForms() const ; - int getTypeTrap(int layer) const; - int getTypeHex(int layer, int waferU, int waferV) const; - int getUVMax(int type) const - {return ((type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_);} - bool isHalfCell(int waferType, int cell) const; - bool isValidHex(int lay, int mod, int cell, bool reco) const; - bool isValidHex8(int lay, int modU, int modV, int cellU, - int cellV) const; - bool isValidTrap(int lay, int ieta, int iphi) const; - int lastLayer(bool reco) const; - int layerIndex(int lay, bool reco) const; - unsigned int layers(bool reco) const; - unsigned int layersInit(bool reco) const; - std::pair locateCell(int cell, int lay, int type, - bool reco) const; - std::pair locateCell(int lay, int waferU, int waferV, int cellU, - int cellV, bool reco, bool all, - bool debug=false) const; - std::pair locateCellHex(int cell, int wafer, bool reco) const; - std::pair locateCellTrap(int lay, int ieta, int iphi, - bool reco) const; - int levelTop(int ind=0) const {return hgpar_->levelT_[ind];} - bool maskCell(const DetId& id, int corners) const; - int maxCellUV() const { - return ((mode_==HGCalGeometryMode::Trapezoid) ? hgpar_->nCellsFine_ : - 2*hgpar_->nCellsFine_);} - int maxCells(bool reco) const; - int maxCells(int lay, bool reco) const; - int maxModules() const {return modHalf_;} - int maxMoudlesPerLayer() const {return maxWafersPerLayer_;} - int maxRows(int lay, bool reco) const; - double minSlope() const {return hgpar_->slopeMin_[0];} - int modifyUV(int uv, int type1, int type2) const; - int modules(int lay, bool reco) const; - int modulesInit(int lay, bool reco) const; - double mouseBite(bool reco) const; - int numberCells(bool reco) const; - std::vector numberCells(int lay, bool reco) const; - int numberCellsHexagon(int wafer) const; - int numberCellsHexagon(int lay, int waferU, int waferV, - bool flag) const; - std::pair rangeR(double z, bool reco) const; - std::pair rangeZ(bool reco) const; - std::pair rowColumnWafer(const int wafer) const; - int sectors() const {return hgpar_->nSectors_;} - std::pair simToReco(int cell, int layer, int mod, bool half) const; - unsigned int volumes() const {return hgpar_->moduleLayR_.size();} - int waferFromCopy(int copy) const; - void waferFromPosition(const double x, const double y, - int& wafer, int& icell, - int& celltyp) const; - void waferFromPosition(const double x, const double y, - const int layer, int& waferU, - int& waferV, int& cellU, int& cellV, - int& celltype, double& wt, - bool debug=false) const; - bool waferInLayer(int wafer, int lay, bool reco) const; - bool waferFullInLayer(int wafer, int lay, bool reco) const; - int waferCount(const int type) const {return ((type == 0) ? waferMax_[2] : waferMax_[3]);} - int waferMax() const {return waferMax_[1];} - int waferMin() const {return waferMax_[0];} - std::pair waferPosition(int wafer, bool reco) const; - std::pair waferPosition(int waferU, int waferV, bool reco) const; - double waferSepar(bool reco) const {return (reco ? hgpar_->sensorSeparation_ : HGCalParameters::k_ScaleToDDD*hgpar_->sensorSeparation_);} - double waferSize(bool reco) const {return (reco ? hgpar_->waferSize_ : HGCalParameters::k_ScaleToDDD*hgpar_->waferSize_);} - int wafers() const; - int wafers(int layer, int type) const; - int waferToCopy(int wafer) const {return ((wafer>=0)&&(wafer< (int)(hgpar_->waferCopy_.size()))) ? hgpar_->waferCopy_[wafer] : (int)(hgpar_->waferCopy_.size());} // wafer transverse thickness classification (2 = coarse, 1 = fine) - int waferTypeT(int wafer) const {return ((wafer>=0)&&(wafer<(int)(hgpar_->waferTypeT_.size()))) ? hgpar_->waferTypeT_[wafer] : 0;} + int waferTypeT(int wafer) const { + return ((wafer >= 0) && (wafer < (int)(hgpar_->waferTypeT_.size()))) + ? hgpar_->waferTypeT_[wafer] + : 0; + } // wafer longitudinal thickness classification (1 = 100um, 2 = 200um, 3=300um) - int waferTypeL(int wafer) const {return ((wafer>=0)&&(wafer<(int)(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0;} - int waferType(DetId const& id) const; - int waferUVMax() const {return hgpar_->waferUVMax_;} - bool waferVirtual(int layer, int waferU, int waferV) const; - double waferZ(int layer, bool reco) const; + int waferTypeL(int wafer) const { + return ((wafer >= 0) && (wafer < (int)(hgpar_->waferTypeL_.size()))) + ? hgpar_->waferTypeL_[wafer] + : 0; + } + int waferType(DetId const& id) const; + int waferUVMax() const { return hgpar_->waferUVMax_; } + bool waferVirtual(int layer, int waferU, int waferV) const; + double waferZ(int layer, bool reco) const; -private: - int cellHex(double xx, double yy, const double& cellR, - const std::vector& posX, - const std::vector& posY) const; - void cellHex(double xloc, double yloc, int cellType, int& cellU, - int& cellV, bool debug=false) const; - std::pair getIndex(int lay, bool reco) const; + private: + int cellHex(double xx, double yy, const double& cellR, + const std::vector& posX, + const std::vector& posY) const; + void cellHex(double xloc, double yloc, int cellType, int& cellU, int& cellV, + bool debug = false) const; + std::pair getIndex(int lay, bool reco) const; bool isValidCell(int layindex, int wafer, int cell) const; bool waferInLayerTest(int wafer, int lay, bool full) const; const double k_horizontalShift = 1.0; - const float dPhiMin = 0.02; - typedef std::array, 2> Simrecovecs; - typedef std::array HGCWaferParam; - const HGCalParameters* hgpar_; - constexpr static double tan30deg_ = 0.5773502693; - const double sqrt3_; - double rmax_, hexside_; - HGCalGeometryMode::GeometryMode mode_; - int32_t tot_wafers_, modHalf_; - std::array tot_layers_; - Simrecovecs max_modules_layer_; - int32_t maxWafersPerLayer_; - std::map waferLayer_; - std::array waferMax_; - std::unordered_map waferIn_; + const float dPhiMin = 0.02; + typedef std::array, 2> Simrecovecs; + typedef std::array HGCWaferParam; + const HGCalParameters* hgpar_; + constexpr static double tan30deg_ = 0.5773502693; + const double sqrt3_; + double rmax_, hexside_; + HGCalGeometryMode::GeometryMode mode_; + int32_t tot_wafers_, modHalf_; + std::array tot_layers_; + Simrecovecs max_modules_layer_; + int32_t maxWafersPerLayer_; + std::map waferLayer_; + std::array waferMax_; + std::unordered_map waferIn_; }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h index d4a9ca4961d62..8ec86d72704a3 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h @@ -5,40 +5,38 @@ * * this class extracts some geometry constants from CompactView * to be used by Reco Geometry/Topology - * + * * $Date: 2015/06/25 00:06:50 $ * \author Sunanda Banerjee, Fermilab * \author Lindsey Gray, Fermilab (for fixes) * */ +#include #include #include #include -#include -#include "DetectorDescription/Core/interface/DDsvalues.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DetectorDescription/Core/interface/DDsvalues.h" #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" -class DDCompactView; +class DDCompactView; class DDFilteredView; class HGCalParameters; class HGCalGeomParameters { - -public: - + public: HGCalGeomParameters(); ~HGCalGeomParameters(); void loadGeometryHexagon(const DDFilteredView&, HGCalParameters&, - const std::string&, const DDCompactView*, - const std::string&, const std::string&, - HGCalGeometryMode::WaferMode); + const std::string&, const DDCompactView*, + const std::string&, const std::string&, + HGCalGeometryMode::WaferMode); void loadGeometryHexagon8(const DDFilteredView&, HGCalParameters&, int); void loadSpecParsHexagon(const DDFilteredView&, HGCalParameters&, - const DDCompactView*, const std::string&, - const std::string&); + const DDCompactView*, const std::string&, + const std::string&); void loadSpecParsHexagon8(const DDFilteredView&, HGCalParameters&); void loadSpecParsTrapezoid(const DDFilteredView&, HGCalParameters&); void loadWaferHexagon(HGCalParameters& php); @@ -46,30 +44,30 @@ class HGCalGeomParameters { void loadCellParsHexagon(const DDCompactView* cpv, HGCalParameters& php); void loadCellTrapezoid(HGCalParameters& php); -private: - + private: struct layerParameters { double rmin, rmax, zpos; - layerParameters(double rin=0, double rout=0, - double zp=0) : rmin(rin), rmax(rout), zpos(zp) {} + layerParameters(double rin = 0, double rout = 0, double zp = 0) + : rmin(rin), rmax(rout), zpos(zp) {} }; struct cellParameters { - bool half; - int wafer; + bool half; + int wafer; GlobalPoint xyz; - cellParameters(bool h=false, int w=0, - GlobalPoint p=GlobalPoint(0,0,0)) : half(h), wafer(w), - xyz(std::move(p)) {} + cellParameters(bool h = false, int w = 0, + GlobalPoint p = GlobalPoint(0, 0, 0)) + : half(h), wafer(w), xyz(std::move(p)) {} }; std::vector getDDDArray(const std::string&, const DDsvalues_type&, - const int); - std::pair cellPosition(const std::vector& wafers, - std::vector::const_iterator& itrf, - int wafer, double xx, double yy); + const int); + std::pair cellPosition( + const std::vector& wafers, + std::vector::const_iterator& itrf, int wafer, double xx, + double yy); - const double sqrt3_; - double waferSize_; + const double sqrt3_; + double waferSize_; }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalGeomTools.h b/Geometry/HGCalCommonData/interface/HGCalGeomTools.h index 6c92ea383828b..03934b66ab781 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeomTools.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeomTools.h @@ -5,26 +5,24 @@ #include class HGCalGeomTools { - -public: - + public: HGCalGeomTools() {} ~HGCalGeomTools() {} static double radius(double z, std::vector const& zFront, - std::vector const& rFront, - std::vector const& slope); + std::vector const& rFront, + std::vector const& slope); static double radius(double z, int layer0, int layerf, - std::vector const& zFront, - std::vector const& rFront); - static std::pair zradius(double z1, double z2, - std::vector const& zFront, - std::vector const& rFront); - static std::pair waferCorner(double xpos, double ypos, - double r, double R, - double rMin, double rMax, - bool oldBug=false); + std::vector const& zFront, + std::vector const& rFront); + static std::pair zradius(double z1, double z2, + std::vector const& zFront, + std::vector const& rFront); + static std::pair waferCorner(double xpos, double ypos, + double r, double R, + double rMin, double rMax, + bool oldBug = false); -private: + private: static constexpr double tol = 0.0001; }; diff --git a/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h b/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h index 8271a1ce6adbe..1f96fa401749d 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h @@ -1,31 +1,37 @@ #ifndef Geometry_HGCalCommonData_HGCalGeometryMode_H #define Geometry_HGCalCommonData_HGCalGeometryMode_H -#include "FWCore/Utilities/interface/Exception.h" +#include #include #include -#include +#include "FWCore/Utilities/interface/Exception.h" -template< typename T > +template class HGCalStringToEnumParser { std::map enumMap; -public: - + + public: HGCalStringToEnumParser(void); - T parseString(const std::string &value) { + T parseString(const std::string &value) { typename std::map::const_iterator itr = enumMap.find(value); if (itr == enumMap.end()) - throw cms::Exception("Configuration") << "the value " << value - << " is not defined."; + throw cms::Exception("Configuration") + << "the value " << value << " is not defined."; return itr->second; } }; namespace HGCalGeometryMode { - enum GeometryMode { Square=0, Hexagon=1, HexagonFull=2, Hexagon8=3, - Hexagon8Full=4, Trapezoid=5}; - enum WaferMode { Polyhedra=0, ExtrudedPolygon=1}; -} +enum GeometryMode { + Square = 0, + Hexagon = 1, + HexagonFull = 2, + Hexagon8 = 3, + Hexagon8Full = 4, + Trapezoid = 5 +}; +enum WaferMode { Polyhedra = 0, ExtrudedPolygon = 1 }; +} // namespace HGCalGeometryMode #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalParameters.h b/Geometry/HGCalCommonData/interface/HGCalParameters.h index db5c207ac9fcc..d484826f7e2b8 100644 --- a/Geometry/HGCalCommonData/interface/HGCalParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalParameters.h @@ -1,173 +1,170 @@ #ifndef Geometry_HGCalCommonData_HGCalParameters_h #define Geometry_HGCalCommonData_HGCalParameters_h -#include "CondFormats/Serialization/interface/Serializable.h" -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" -#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include -#include -#include -#include #include +#include +#include #include +#include +#include "CondFormats/Serialization/interface/Serializable.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" class HGCalParameters { + public: + typedef std::vector > layer_map; + typedef std::unordered_map wafer_map; + typedef std::unordered_map > waferT_map; -public: - - typedef std::vector > layer_map; - typedef std::unordered_map wafer_map; - typedef std::unordered_map > waferT_map; - - static constexpr double k_ScaleFromDDD = 0.1; - static constexpr double k_ScaleToDDD = 10.0; - static constexpr uint32_t k_CornerSize = 6; + static constexpr double k_ScaleFromDDD = 0.1; + static constexpr double k_ScaleToDDD = 10.0; + static constexpr uint32_t k_CornerSize = 6; struct hgtrap { - int lay; - float bl, tl, h, dz, alpha, cellSize; + int lay; + float bl, tl, h, dz, alpha, cellSize; }; struct hgtrform { - int zp, lay, sec, subsec; - CLHEP::Hep3Vector h3v; + int zp, lay, sec, subsec; + CLHEP::Hep3Vector h3v; CLHEP::HepRotation hr; }; - + HGCalParameters(const std::string& nam); - ~HGCalParameters( void ); - void fillModule(const hgtrap& mytr, bool reco); - hgtrap getModule(unsigned int k, bool reco) const; - void fillTrForm(const hgtrform& mytr); - hgtrform getTrForm(unsigned int k) const; - void addTrForm(const CLHEP::Hep3Vector& h3v); - void scaleTrForm(double); - int scintCells(const int layer) const - { return nPhiBinBH_[scintType(layer)]; } - double scintCellSize(const int layer) const - { return cellSize_[scintType(layer)]; } - int scintType(const int layer) const - { return ((layer < layerFrontBH_[1]) ? 0 : 1); } - std::array getID(unsigned int k) const; + ~HGCalParameters(void); + void fillModule(const hgtrap& mytr, bool reco); + hgtrap getModule(unsigned int k, bool reco) const; + void fillTrForm(const hgtrform& mytr); + hgtrform getTrForm(unsigned int k) const; + void addTrForm(const CLHEP::Hep3Vector& h3v); + void scaleTrForm(double); + int scintCells(const int layer) const { return nPhiBinBH_[scintType(layer)]; } + double scintCellSize(const int layer) const { + return cellSize_[scintType(layer)]; + } + int scintType(const int layer) const { + return ((layer < layerFrontBH_[1]) ? 0 : 1); + } + std::array getID(unsigned int k) const; - std::string name_; - int detectorType_; - int nCells_; - int nSectors_; - std::vector cellSize_; - std::vector moduleLayS_; - std::vector moduleBlS_; - std::vector moduleTlS_; - std::vector moduleHS_; - std::vector moduleDzS_; - std::vector moduleAlphaS_; - std::vector moduleCellS_; - std::vector moduleLayR_; - std::vector moduleBlR_; - std::vector moduleTlR_; - std::vector moduleHR_; - std::vector moduleDzR_; - std::vector moduleAlphaR_; - std::vector moduleCellR_; - std::vector trformIndex_; - std::vector trformTranX_; - std::vector trformTranY_; - std::vector trformTranZ_; - std::vector trformRotXX_; - std::vector trformRotYX_; - std::vector trformRotZX_; - std::vector trformRotXY_; - std::vector trformRotYY_; - std::vector trformRotZY_; - std::vector trformRotXZ_; - std::vector trformRotYZ_; - std::vector trformRotZZ_; - std::vector layer_; - std::vector layerIndex_; - std::vector layerGroup_; - std::vector cellFactor_; - std::vector depth_; - std::vector depthIndex_; - std::vector depthLayerF_; - std::vector zLayerHex_; - std::vector rMinLayHex_; - std::vector rMaxLayHex_; - std::vector waferCopy_; - std::vector waferTypeL_; - std::vector waferTypeT_; - std::vector waferPosX_; - std::vector waferPosY_; - std::vector cellFineX_; - std::vector cellFineY_; - wafer_map cellFineIndex_; - std::vector cellFineHalf_; - std::vector cellCoarseX_; - std::vector cellCoarseY_; - wafer_map cellCoarseIndex_; - std::vector cellCoarseHalf_; - std::vector layerGroupM_; - std::vector layerGroupO_; - std::vector boundR_; - std::vector rLimit_; - std::vector cellFine_; - std::vector cellCoarse_; - double waferR_; - std::vector levelT_; - int levelZSide_; + std::string name_; + int detectorType_; + int nCells_; + int nSectors_; + std::vector cellSize_; + std::vector moduleLayS_; + std::vector moduleBlS_; + std::vector moduleTlS_; + std::vector moduleHS_; + std::vector moduleDzS_; + std::vector moduleAlphaS_; + std::vector moduleCellS_; + std::vector moduleLayR_; + std::vector moduleBlR_; + std::vector moduleTlR_; + std::vector moduleHR_; + std::vector moduleDzR_; + std::vector moduleAlphaR_; + std::vector moduleCellR_; + std::vector trformIndex_; + std::vector trformTranX_; + std::vector trformTranY_; + std::vector trformTranZ_; + std::vector trformRotXX_; + std::vector trformRotYX_; + std::vector trformRotZX_; + std::vector trformRotXY_; + std::vector trformRotYY_; + std::vector trformRotZY_; + std::vector trformRotXZ_; + std::vector trformRotYZ_; + std::vector trformRotZZ_; + std::vector layer_; + std::vector layerIndex_; + std::vector layerGroup_; + std::vector cellFactor_; + std::vector depth_; + std::vector depthIndex_; + std::vector depthLayerF_; + std::vector zLayerHex_; + std::vector rMinLayHex_; + std::vector rMaxLayHex_; + std::vector waferCopy_; + std::vector waferTypeL_; + std::vector waferTypeT_; + std::vector waferPosX_; + std::vector waferPosY_; + std::vector cellFineX_; + std::vector cellFineY_; + wafer_map cellFineIndex_; + std::vector cellFineHalf_; + std::vector cellCoarseX_; + std::vector cellCoarseY_; + wafer_map cellCoarseIndex_; + std::vector cellCoarseHalf_; + std::vector layerGroupM_; + std::vector layerGroupO_; + std::vector boundR_; + std::vector rLimit_; + std::vector cellFine_; + std::vector cellCoarse_; + double waferR_; + std::vector levelT_; + int levelZSide_; HGCalGeometryMode::GeometryMode mode_; - std::vector slopeMin_; - std::vector zFrontMin_; - std::vector rMinFront_; - layer_map copiesInLayers_; - int nCellsFine_; - int nCellsCoarse_; - double waferSize_; - double waferThick_; - double sensorSeparation_; - double mouseBite_; - int waferUVMax_; - std::vector waferUVMaxLayer_; - bool defineFull_; - std::vector cellThickness_; - std::vector radius100to200_; - std::vector radius200to300_; - int choiceType_; - int nCornerCut_; - double fracAreaMin_; - double zMinForRad_; - std::vector radiusMixBoundary_; - std::vector nPhiBinBH_; - std::vector layerFrontBH_; - std::vector rMinLayerBH_; - std::vector radiusLayer_[2]; - std::vector iradMinBH_; - std::vector iradMaxBH_; - double minTileSize_; - std::vector firstModule_; - std::vector lastModule_; - std::vector slopeTop_; - std::vector zFrontTop_; - std::vector rMaxFront_; - std::vector zRanges_; - int firstLayer_; - int firstMixedLayer_; - wafer_map wafersInLayers_; - wafer_map typesInLayers_; - waferT_map waferTypes_; + std::vector slopeMin_; + std::vector zFrontMin_; + std::vector rMinFront_; + layer_map copiesInLayers_; + int nCellsFine_; + int nCellsCoarse_; + double waferSize_; + double waferThick_; + double sensorSeparation_; + double mouseBite_; + int waferUVMax_; + std::vector waferUVMaxLayer_; + bool defineFull_; + std::vector cellThickness_; + std::vector radius100to200_; + std::vector radius200to300_; + int choiceType_; + int nCornerCut_; + double fracAreaMin_; + double zMinForRad_; + std::vector radiusMixBoundary_; + std::vector nPhiBinBH_; + std::vector layerFrontBH_; + std::vector rMinLayerBH_; + std::vector radiusLayer_[2]; + std::vector iradMinBH_; + std::vector iradMaxBH_; + double minTileSize_; + std::vector firstModule_; + std::vector lastModule_; + std::vector slopeTop_; + std::vector zFrontTop_; + std::vector rMaxFront_; + std::vector zRanges_; + int firstLayer_; + int firstMixedLayer_; + wafer_map wafersInLayers_; + wafer_map typesInLayers_; + waferT_map waferTypes_; COND_SERIALIZABLE; -private: - - const int kMaskZside = 0x1; - const int kMaskLayer = 0x7F; - const int kMaskSector = 0x3FF; - const int kMaskSubSec = 0x1; - const int kShiftZside = 19; - const int kShiftLayer = 12; + private: + const int kMaskZside = 0x1; + const int kMaskLayer = 0x7F; + const int kMaskSector = 0x3FF; + const int kMaskSubSec = 0x1; + const int kShiftZside = 19; + const int kShiftLayer = 12; const int kShiftSector = 1; const int kShiftSubSec = 0; - }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h b/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h index bec971de707cc..4fa81254762d7 100644 --- a/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h +++ b/Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h @@ -1,24 +1,24 @@ #ifndef HGCalCommonData_HGCalParametersFromDD_h #define HGCalCommonData_HGCalParametersFromDD_h -#include "DetectorDescription/Core/interface/DDsvalues.h" #include #include +#include "DetectorDescription/Core/interface/DDsvalues.h" class DDCompactView; class HGCalParameters; class HGCalParametersFromDD { -public: + public: HGCalParametersFromDD() {} virtual ~HGCalParametersFromDD() {} - bool build(const DDCompactView*, HGCalParameters&, const std::string&, - const std::string&, const std::string&, const std::string&); + bool build(const DDCompactView*, HGCalParameters&, const std::string&, + const std::string&, const std::string&, const std::string&); -private: - void getCellPosition(HGCalParameters& php, int type); - double getDDDValue(const char* s, const DDsvalues_type& sv); + private: + void getCellPosition(HGCalParameters& php, int type); + double getDDDValue(const char* s, const DDsvalues_type& sv); std::vector getDDDArray(const char* s, const DDsvalues_type& sv); }; diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h index d9e0abcec96fa..ee1c9dc3c0c2b 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h @@ -5,19 +5,16 @@ #include class HGCalWaferIndex { - -public: - + public: HGCalWaferIndex() {} ~HGCalWaferIndex() {} static int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, - bool old=false); + bool old = false); static int32_t waferLayer(const int32_t index); static int32_t waferU(const int32_t index); static int32_t waferV(const int32_t index); static int32_t waferCopy(const int32_t index); - static bool waferFormat(const int32_t index); - + static bool waferFormat(const int32_t index); }; #endif diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferType.h b/Geometry/HGCalCommonData/interface/HGCalWaferType.h index 16259a0a932c7..b8687bf715116 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferType.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferType.h @@ -7,44 +7,41 @@ * (taken from Philippe Bloch's parametrisation) * rad100, rad200 parameters assume r,z to be in cm * xpos, ypos, zpos, zmin, waferSize are all in mm - * + * * $Date: 2018/03/22 00:06:50 $ * \author Sunanda Banerjee, Fermilab * */ #include -#include #include +#include class HGCalWaferType { - -public: - - HGCalWaferType(const std::vector& rad100, - const std::vector& rad200, - double waferSize, double zMin, int choice, - unsigned int cutValue, double cutFracArea); + public: + HGCalWaferType(const std::vector& rad100, + const std::vector& rad200, double waferSize, + double zMin, int choice, unsigned int cutValue, + double cutFracArea); ~HGCalWaferType(); int getType(double xpos, double ypos, double zpos); - std::pair rLimits(double zpos); - -private: + std::pair rLimits(double zpos); - double areaPolygon(std::vector const&, std::vector const&); - std::pair intersection(int, int, std::vector const&, - std::vector const&, double xp, - double yp, double rr); + private: + double areaPolygon(std::vector const&, std::vector const&); + std::pair intersection(int, int, std::vector const&, + std::vector const&, double xp, + double yp, double rr); - const double sqrt3_ = 1.0/std::sqrt(3.0); + const double sqrt3_ = 1.0 / std::sqrt(3.0); const std::vector rad100_; const std::vector rad200_; - const double waferSize_; - const double zMin_; - const int choice_; - const unsigned int cutValue_; - const double cutFracArea_; - double r_, R_; + const double waferSize_; + const double zMin_; + const int choice_; + const unsigned int cutValue_; + const double cutFracArea_; + double r_, R_; }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc index a4ce9f34dede1..9e46c96f22838 100644 --- a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc @@ -3,19 +3,19 @@ // Description: Geometry factory class for HGCal (EE and HESil) /////////////////////////////////////////////////////////////////////////////// -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" -#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" -#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG @@ -27,67 +27,66 @@ DDAHcalModuleAlgo::DDAHcalModuleAlgo() { DDAHcalModuleAlgo::~DDAHcalModuleAlgo() {} -void DDAHcalModuleAlgo::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs){ - - tile = sArgs["TileName"]; +void DDAHcalModuleAlgo::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + tile = sArgs["TileName"]; #ifdef EDM_ML_DEBUG std::cout << "DDAHcalModuleAlgo: Tile " << tile << std::endl; #endif - materials = vsArgs["MaterialNames"]; - names = vsArgs["VolumeNames"]; - thick = vArgs["Thickness"]; - for (unsigned int i=0; i> Constructing DDAHcalModuleAlgo..." << std::endl; #endif - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG std::cout << "<<== End of DDAHcalModuleAlgo construction ..." << std::endl; #endif } -void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG std::cout << "DDAHcalModuleAlgo test: \t\tInside Layers" << std::endl; #endif - double zi(zMinBlock); - int laymin(0); - for (unsigned int i=0; i layerThick[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] - << " is smaller than thickness " << thickTot - << " of all its components **** ERROR ****\n"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " is smaller than thickness " << thickTot + << " of all its components **** ERROR ****\n"; } else if (thickTot < layerThick[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick[i] << " does not match with " - << thickTot << " of the components\n"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " does not match with " << thickTot << " of the components\n"; } - } // End of loop over blocks + } // End of loop over blocks } void DDAHcalModuleAlgo::positionSensitive(DDLogicalPart& glog, - DDCompactView& cpv) { - int ncol = tileN[0]/2; - int nrow = tileN[1]/2; + DDCompactView& cpv) { + int ncol = tileN[0] / 2; + int nrow = tileN[1] / 2; #ifdef EDM_ML_DEBUG - int kount(0); - std::cout << glog.ddname() << " Row " << nrow << " Column " << ncol - << std::endl; + int kount(0); + std::cout << glog.ddname() << " Row " << nrow << " Column " << ncol + << std::endl; #endif - for (int nr=-nrow; nr <= nrow; ++nr) { + for (int nr = -nrow; nr <= nrow; ++nr) { int inr = (nr >= 0) ? nr : -nr; - double ypos = (nr >= 0) ? (inr-0.5)*tileStep[1] : -(inr-0.5)*tileStep[1]; - for (int nc=-ncol; nc <= ncol; ++nc) { + double ypos = + (nr >= 0) ? (inr - 0.5) * tileStep[1] : -(inr - 0.5) * tileStep[1]; + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = (nc >= 0) ? nc : -nc; - double xpos = (nc >= 0) ? (inc-0.5)*tileStep[0] : -(inc-0.5)*tileStep[0]; + double xpos = + (nc >= 0) ? (inc - 0.5) * tileStep[0] : -(inc - 0.5) * tileStep[0]; if (nr != 0 && nc != 0) { - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - int copy = inr*10 + inc; - if (nc < 0) copy += 100; - if (nr < 0) copy += 1000; - DDName name = DDName(DDSplit(tile).first, DDSplit(tile).second); - cpv.position(name, glog.ddname(), copy, tran, rotation); -#ifdef EDM_ML_DEBUG - kount++; - std::cout << "DDAHcalModuleAlgo: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + int copy = inr * 10 + inc; + if (nc < 0) copy += 100; + if (nr < 0) copy += 1000; + DDName name = DDName(DDSplit(tile).first, DDSplit(tile).second); + cpv.position(name, glog.ddname(), copy, tran, rotation); +#ifdef EDM_ML_DEBUG + kount++; + std::cout << "DDAHcalModuleAlgo: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation << std::endl; #endif } } } #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo: " << kount << " tiles for " - << glog.ddname() << std::endl; + std::cout << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname() + << std::endl; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h index b2783e527c176..4849280957ebc 100644 --- a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h +++ b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h @@ -3,49 +3,45 @@ #include #include +#include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" -#include +#include "DetectorDescription/Core/interface/DDTypes.h" class DDAHcalModuleAlgo : public DDAlgorithm { - -public: - //Constructor and Destructor - DDAHcalModuleAlgo(); //const std::string & name); + public: + // Constructor and Destructor + DDAHcalModuleAlgo(); // const std::string & name); ~DDAHcalModuleAlgo() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; - -protected: - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - void positionSensitive(DDLogicalPart& glog, DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + void positionSensitive(DDLogicalPart& glog, DDCompactView& cpv); - std::string tile; //Scintillator tile - std::vector materials; //Materials - std::vector names; //Names - std::vector thick; //Thickness of the material - std::vector copyNumber; //Initial copy numbers - std::vector layers; //Number of layers in a section - std::vector layerThick; //Thickness of each section - std::vector layerType; //Type of the layer - std::vector layerSense; //Content of a layer (sensitive?) - std::vector widths; //Width (passive, active) - std::vector heights; //Heights (passive, active) - std::vector tileN; // # of tiles (along x, y) - std::vector tileStep; //Separation between tiles (x, y) - double zMinBlock; //Starting z-value of the block - std::string idName; //Name of the "parent" volume. - std::string idNameSpace; //Namespace of this and ALL sub-parts - std::unordered_set copies; //List of copy #'s + private: + std::string tile; // Scintillator tile + std::vector materials; // Materials + std::vector names; // Names + std::vector thick; // Thickness of the material + std::vector copyNumber; // Initial copy numbers + std::vector layers; // Number of layers in a section + std::vector layerThick; // Thickness of each section + std::vector layerType; // Type of the layer + std::vector layerSense; // Content of a layer (sensitive?) + std::vector widths; // Width (passive, active) + std::vector heights; // Heights (passive, active) + std::vector tileN; // # of tiles (along x, y) + std::vector tileStep; // Separation between tiles (x, y) + double zMinBlock; // Starting z-value of the block + std::string idName; // Name of the "parent" volume. + std::string idNameSpace; // Namespace of this and ALL sub-parts + std::unordered_set copies; // List of copy #'s }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc b/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc index 8d64ce5c54d87..df438a85af084 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc @@ -1,12 +1,12 @@ -#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalCell.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "DetectorDescription/Core/interface/DDutils.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalCell.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" //#define EDM_ML_DEBUG @@ -18,68 +18,59 @@ DDHGCalCell::DDHGCalCell() { DDHGCalCell::~DDHGCalCell() {} -void DDHGCalCell::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments &, - const DDMapArguments &, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) { - - waferSize_ = nArgs["WaferSize"]; - waferT_ = nArgs["WaferThick"]; - cellT_ = nArgs["CellThick"]; - nCells_ = (int)(nArgs["NCells"]); - posSens_ = (int)(nArgs["PosSensitive"]); - material_ = sArgs["Material"]; - fullCN_ = sArgs["FullCell"]; - fullSensN_ = sArgs["FullSensitive"]; - truncCN_ = vsArgs["TruncatedCell"]; - truncSensN_ = vsArgs["TruncatedSensitive"]; - extenCN_ = vsArgs["ExtendedCell"]; - extenSensN_ = vsArgs["ExtendedSensitive"]; - cornrCN_ = vsArgs["CornerCell"]; - cornrSensN_ = vsArgs["CornerSensitive"]; - nameSpace_ = DDCurrentNamespace::ns(); +void DDHGCalCell::initialize(const DDNumericArguments &nArgs, + const DDVectorArguments &, const DDMapArguments &, + const DDStringArguments &sArgs, + const DDStringVectorArguments &vsArgs) { + waferSize_ = nArgs["WaferSize"]; + waferT_ = nArgs["WaferThick"]; + cellT_ = nArgs["CellThick"]; + nCells_ = (int)(nArgs["NCells"]); + posSens_ = (int)(nArgs["PosSensitive"]); + material_ = sArgs["Material"]; + fullCN_ = sArgs["FullCell"]; + fullSensN_ = sArgs["FullSensitive"]; + truncCN_ = vsArgs["TruncatedCell"]; + truncSensN_ = vsArgs["TruncatedSensitive"]; + extenCN_ = vsArgs["ExtendedCell"]; + extenSensN_ = vsArgs["ExtendedSensitive"]; + cornrCN_ = vsArgs["CornerCell"]; + cornrSensN_ = vsArgs["CornerSensitive"]; + nameSpace_ = DDCurrentNamespace::ns(); if ((truncCN_.size() != truncSensN_.size()) || (extenCN_.size() != extenSensN_.size()) || (cornrCN_.size() != cornrSensN_.size())) - edm::LogWarning("HGCalGeom") << "The number of cells & sensitive differ:" - << " Truncated " << truncCN_.size() << ":" - << truncSensN_.size() << " Extended " - << extenCN_.size() <<":" << extenSensN_.size() - << " Corners " << cornrCN_.size() << ":" - << cornrSensN_.size(); + edm::LogWarning("HGCalGeom") + << "The number of cells & sensitive differ:" + << " Truncated " << truncCN_.size() << ":" << truncSensN_.size() + << " Extended " << extenCN_.size() << ":" << extenSensN_.size() + << " Corners " << cornrCN_.size() << ":" << cornrSensN_.size(); if ((truncCN_.size() != 3) || (extenCN_.size() != 3) || (cornrCN_.size() != 6)) - edm::LogWarning("HGCalGeom") << "DDHGCalCell: The number of cells does not" - << " match with Standard: Truncated " - << truncCN_.size() << ":3 Extended " - << extenCN_.size() <<":3" << " Corners " - << cornrCN_.size() << ":6"; + edm::LogWarning("HGCalGeom") + << "DDHGCalCell: The number of cells does not" + << " match with Standard: Truncated " << truncCN_.size() + << ":3 Extended " << extenCN_.size() << ":3" + << " Corners " << cornrCN_.size() << ":6"; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Wafer r " << waferSize_ - << " T " << waferT_ << " Cell T " << cellT_ - << " Cells/Wafer " << nCells_ << " Material " - << material_ << "Sensitive Position " - << posSens_ << " NameSpace " << nameSpace_ - << " Full Cell: " << fullCN_ << ":" - << fullSensN_; - for (unsigned int k=0; k> Executing DDHGCalCell..."; #endif @@ -87,206 +78,196 @@ void DDHGCalCell::execute(DDCompactView& cpv) { DDName matName(DDSplit(material_).first, DDSplit(material_).second); DDMaterial matter(matName); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << matName - << " initialized at " << &matter; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalCell: " << matName << " initialized at " << &matter; #endif DDLogicalPart glog1, glog2; static const double sqrt3 = std::sqrt(3.0); - double R = waferSize_/(3.0*nCells_); - double r = 0.5*R*sqrt3; + double R = waferSize_ / (3.0 * nCells_); + double r = 0.5 * R * sqrt3; double dx1 = R; - double dx2 = 0.5*dx1; - double dx3 = 2.5*dx2; - double dx4 = 0.5*dx2; + double dx2 = 0.5 * dx1; + double dx3 = 2.5 * dx2; + double dx4 = 0.5 * dx2; double dy1 = r; - double dy2 = 0.5*dy1; - double dy3 = 1.5*dy1; - std::vector xx = {dx1,dx2,-dx2,-dx1,-dx2,dx2, - dx3,-dx4,-dx1,-dx1,-dx4,dx3}; - std::vector yy = {0,dy1,dy1,0,-dy1,-dy1, - dy2,dy3,dy1,-dy1,-dy3,-dy2}; - double zpos = (posSens_ == 0) ? -0.5*(waferT_-cellT_) : 0.5*(waferT_-cellT_); - DDTranslation tran(0,0,zpos); - + double dy2 = 0.5 * dy1; + double dy3 = 1.5 * dy1; + std::vector xx = {dx1, dx2, -dx2, -dx1, -dx2, dx2, + dx3, -dx4, -dx1, -dx1, -dx4, dx3}; + std::vector yy = {0, dy1, dy1, 0, -dy1, -dy1, + dy2, dy3, dy1, -dy1, -dy3, -dy2}; + double zpos = + (posSens_ == 0) ? -0.5 * (waferT_ - cellT_) : 0.5 * (waferT_ - cellT_); + DDTranslation tran(0, 0, zpos); + // First the full cell - std::vector xw = {xx[0],xx[1],xx[2],xx[3],xx[4],xx[5]}; - std::vector yw = {yy[0],yy[1],yy[2],yy[3],yy[4],yy[5]}; - std::vector zw = {-0.5*waferT_,0.5*waferT_}; - std::vector zx(2,0), zy(2,0), scale(2,1.0); + std::vector xw = {xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]}; + std::vector yw = {yy[0], yy[1], yy[2], yy[3], yy[4], yy[5]}; + std::vector zw = {-0.5 * waferT_, 0.5 * waferT_}; + std::vector zx(2, 0), zy(2, 0), scale(2, 1.0); DDSolid solid = DDSolidFactory::extrudedpolygon(DDName(fullCN_, nameSpace_), - xw, yw, zw, zx, zy, scale); + xw, yw, zw, zx, zy, scale); glog1 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zw[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zw[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xw.size() << " edges"; - for (unsigned int k=0; k zc = {-0.5*cellT_,0.5*cellT_}; - solid = DDSolidFactory::extrudedpolygon(DDName(fullSensN_, nameSpace_), - xw, yw, zc, zx, zy, scale); + std::vector zc = {-0.5 * cellT_, 0.5 * cellT_}; + solid = DDSolidFactory::extrudedpolygon(DDName(fullSensN_, nameSpace_), xw, + yw, zc, zx, zy, scale); glog2 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zc[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zc[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xw.size() << " edges"; - for (unsigned int k=0; k xw = {xx[ir0[i]],xx[ir1[i]],xx[ir2[i]],xx[ir3[i]],xx[ir4[i]]}; - std::vector yw = {yy[ir0[i]],yy[ir1[i]],yy[ir2[i]],yy[ir3[i]],yy[ir4[i]]}; - solid = DDSolidFactory::extrudedpolygon(DDName(truncCN_[i], nameSpace_), - xw, yw, zw, zx, zy, scale); + static const int ir0[] = {0, 1, 0}; + static const int ir1[] = {1, 2, 1}; + static const int ir2[] = {2, 3, 3}; + static const int ir3[] = {3, 4, 4}; + static const int ir4[] = {5, 5, 5}; + for (unsigned int i = 0; i < truncCN_.size(); ++i) { + std::vector xw = {xx[ir0[i]], xx[ir1[i]], xx[ir2[i]], xx[ir3[i]], + xx[ir4[i]]}; + std::vector yw = {yy[ir0[i]], yy[ir1[i]], yy[ir2[i]], yy[ir3[i]], + yy[ir4[i]]}; + solid = DDSolidFactory::extrudedpolygon(DDName(truncCN_[i], nameSpace_), xw, + yw, zw, zx, zy, scale); glog1 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zw[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zw[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xw.size() << " edges"; - for (unsigned int k=0; k xw = {xx[ie0[i]],xx[ie1[i]],xx[ie2[i]],xx[ie3[i]],xx[ie4[i]]}; - std::vector yw = {yy[ie0[i]],yy[ie1[i]],yy[ie2[i]],yy[ie3[i]],yy[ie4[i]]}; - solid = DDSolidFactory::extrudedpolygon(DDName(extenCN_[i], nameSpace_), - xw, yw, zw, zx, zy, scale); + static const int ie0[] = {1, 5, 0}; + static const int ie1[] = {2, 6, 1}; + static const int ie2[] = {3, 7, 8}; + static const int ie3[] = {10, 3, 9}; + static const int ie4[] = {11, 4, 5}; + for (unsigned int i = 0; i < extenCN_.size(); ++i) { + std::vector xw = {xx[ie0[i]], xx[ie1[i]], xx[ie2[i]], xx[ie3[i]], + xx[ie4[i]]}; + std::vector yw = {yy[ie0[i]], yy[ie1[i]], yy[ie2[i]], yy[ie3[i]], + yy[ie4[i]]}; + solid = DDSolidFactory::extrudedpolygon(DDName(extenCN_[i], nameSpace_), xw, + yw, zw, zx, zy, scale); glog1 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zw[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zw[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xw.size() << " edges"; - for (unsigned int k=0; k xw = {xx[ic0[i]],xx[ic1[i]],xx[ic2[i]],xx[ic3[i]],xx[ic4[i]]}; - std::vector yw = {yy[ic0[i]],yy[ic1[i]],yy[ic2[i]],yy[ic3[i]],yy[ic4[i]]}; - solid = DDSolidFactory::extrudedpolygon(DDName(cornrCN_[i], nameSpace_), - xw, yw, zw, zx, zy, scale); + static const int ic0[] = {0, 1, 1, 1, 1, 0}; + static const int ic1[] = {1, 2, 2, 7, 3, 1}; + static const int ic2[] = {8, 3, 3, 3, 4, 3}; + static const int ic3[] = {3, 5, 10, 4, 5, 9}; + static const int ic4[] = {5, 11, 5, 5, 6, 5}; + for (unsigned int i = 0; i < cornrCN_.size(); ++i) { + std::vector xw = {xx[ic0[i]], xx[ic1[i]], xx[ic2[i]], xx[ic3[i]], + xx[ic4[i]]}; + std::vector yw = {yy[ic0[i]], yy[ic1[i]], yy[ic2[i]], yy[ic3[i]], + yy[ic4[i]]}; + solid = DDSolidFactory::extrudedpolygon(DDName(cornrCN_[i], nameSpace_), xw, + yw, zw, zx, zy, scale); glog1 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zw[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zw[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xw.size() << " edges"; - for (unsigned int k=0; k #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalCell : public DDAlgorithm { - -public: - //Constructor and Destructor + public: + // Constructor and Destructor DDHGCalCell(); ~DDHGCalCell() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; + + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; void execute(DDCompactView& cpv) override; -private: - double waferSize_; //Wafer Size - double waferT_; //Wafer Thickness - double cellT_; //Cell Thickness - int nCells_; //Number of columns (8:12) - int posSens_; //Position depleted layer - std::string material_; //Name of the material - std::string fullCN_, fullSensN_; //Name of full cell - std::vector truncCN_, truncSensN_; //Names of truncated cells - std::vector extenCN_, extenSensN_; //Names of extended cells - std::vector cornrCN_, cornrSensN_; //Names of corner cells - std::string nameSpace_; //Namespace to be used + private: + double waferSize_; // Wafer Size + double waferT_; // Wafer Thickness + double cellT_; // Cell Thickness + int nCells_; // Number of columns (8:12) + int posSens_; // Position depleted layer + std::string material_; // Name of the material + std::string fullCN_, fullSensN_; // Name of full cell + std::vector truncCN_, truncSensN_; // Names of truncated cells + std::vector extenCN_, extenSensN_; // Names of extended cells + std::vector cornrCN_, cornrSensN_; // Names of corner cells + std::string nameSpace_; // Namespace to be used }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc index 987862e421adb..83cd584861849 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc @@ -3,14 +3,14 @@ // Description: Geometry factory class for HGCal (EE and HESil) /////////////////////////////////////////////////////////////////////////////// -#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h" #include "DataFormats/Math/interface/GeantUnits.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDSolid.h" -#include "DetectorDescription/Core/interface/DDMaterial.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDMaterial.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" @@ -24,127 +24,122 @@ DDHGCalEEAlgo::DDHGCalEEAlgo() { #endif } -DDHGCalEEAlgo::~DDHGCalEEAlgo() { } - -void DDHGCalEEAlgo::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs) { +DDHGCalEEAlgo::~DDHGCalEEAlgo() {} - wafers_ = vsArgs["WaferNames"]; +void DDHGCalEEAlgo::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + wafers_ = vsArgs["WaferNames"]; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << wafers_.size() - << " wafers"; - for (unsigned int i=0; i 0) { - for (unsigned int i=0; i 0) { - int ii = layerType_[i]; - copyNumber_[ii] = firstLayer_; + int ii = layerType_[i]; + copyNumber_[ii] = firstLayer_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " - << i << ":" << ii << " with " - << materials_[ii] << " changed to " - << copyNumber_[ii]; + edm::LogVerbatim("HGCalGeom") + << "First copy number for layer type " << i << ":" << ii << " with " + << materials_[ii] << " changed to " << copyNumber_[ii]; #endif - break; + break; } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() - << " layers" ; - for (unsigned int i=0; i(rad100to200_, rad200to300_, - (waferSize_+waferSepar_), - zMinRadPar_, choiceType_, - nCutRadPar_, fracAreaMin_); + waferType_ = std::make_unique( + rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, + choiceType_, nCutRadPar_, fracAreaMin_); } //////////////////////////////////////////////////////////////////// @@ -152,18 +147,17 @@ void DDHGCalEEAlgo::initialize(const DDNumericArguments & nArgs, //////////////////////////////////////////////////////////////////// void DDHGCalEEAlgo::execute(DDCompactView& cpv) { - #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalEEAlgo..."; copies_.clear(); #endif - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << copies_.size() - << " different wafer copy numbers"; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalEEAlgo: " << copies_.size() << " different wafer copy numbers"; int k(0); - for (std::unordered_set::const_iterator itr=copies_.begin(); - itr != copies_.end(); ++itr,++k) { + for (std::unordered_set::const_iterator itr = copies_.begin(); + itr != copies_.end(); ++itr, ++k) { edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr); } copies_.clear(); @@ -171,204 +165,200 @@ void DDHGCalEEAlgo::execute(DDCompactView& cpv) { #endif } -void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: \t\tInside Layers"; #endif - double zi(zMinBlock_); - int laymin(0); + double zi(zMinBlock_); + int laymin(0); const double tol(0.01); - for (unsigned int i=0; i zr = HGCalGeomTools::zradius(zz,zz+thick_[ii], - zFrontT_,rMaxFront_); - zz += hthick; - thickTot += thick_[ii]; + for (unsigned int i = 0; i < layers_.size(); i++) { + double zo = zi + layerThick_[i]; + double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); + int laymax = laymin + layers_[i]; + double zz = zi; + double thickTot(0); + for (int ly = laymin; ly < laymax; ++ly) { + int ii = layerType_[ly]; + int copy = copyNumber_[ii]; + double hthick = 0.5 * thick_[ii]; + double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_); + std::pair zr = + HGCalGeomTools::zradius(zz, zz + thick_[ii], zFrontT_, rMaxFront_); + zz += hthick; + thickTot += thick_[ii]; - std::string name = names_[ii]+std::to_string(copy); + std::string name = names_[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: Layer " << ly << ":" - << ii << " Front " << zi << ", " << routF - << " Back " << zo << ", " << rinB - << " superlayer thickness " - << layerThick_[i]; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalEEAlgo: Layer " << ly << ":" << ii << " Front " << zi + << ", " << routF << " Back " << zo << ", " << rinB + << " superlayer thickness " << layerThick_[i]; #endif - DDName matName(DDSplit(materials_[ii]).first, - DDSplit(materials_[ii]).second); + DDName matName(DDSplit(materials_[ii]).first, + DDSplit(materials_[ii]).second); DDMaterial matter(matName); DDLogicalPart glog; if (layerSense_[ly] < 1) { - int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0 || - zr.first < 0) ? 2 : 3; - std::vector pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); - if (layerSense_[ly] == 0 || absorbMode_ == 0) { - double rmax = routF*cosAlpha_ - tol; - pgonZ[0] =-hthick; pgonZ[1] = hthick; - pgonRin[0] = rinB; pgonRin[1] = rinB; - pgonRout[0] = rmax; pgonRout[1] = rmax; - } else { - for (int isec=0; isec pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); + if (layerSense_[ly] == 0 || absorbMode_ == 0) { + double rmax = routF * cosAlpha_ - tol; + pgonZ[0] = -hthick; + pgonZ[1] = hthick; + pgonRin[0] = rinB; + pgonRin[1] = rinB; + pgonRout[0] = rmax; + pgonRout[1] = rmax; + } else { + for (int isec = 0; isec < nsec; ++isec) { + double zs = + ((isec == 0) ? (zz - hthick) + : (isec == nsec - 1) ? (zz + hthick) : zr.first); + double rm = + (((isec == 0) || (isec == nsec - 1)) + ? HGCalGeomTools::radius(zs, zFrontT_, rMaxFront_, slopeT_) + : zr.second) * + cosAlpha_ - + tol; + pgonZ[isec] = zs - zz; + pgonRin[isec] = rinB; + pgonRout[isec] = rm; + } + } + DDSolid solid = + DDSolidFactory::polyhedra(DDName(name, nameSpace_), sectors_, + -alpha_, 2._pi, pgonZ, pgonRin, pgonRout); + glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << solid.name() - << " polyhedra of " << sectors_ - << " sectors covering " - << convertRadToDeg(-alpha_) << ":" - << convertRadToDeg(-alpha_+2._pi) - << " with " << pgonZ.size() - << " sections and filled with " - << matName << ":" << &matter; - for (unsigned int k=0; k layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " - << layerThick_[i] << " is smaller than " - << thickTot << ": thickness of all its " - << "components **** ERROR ****"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " is smaller than " << thickTot << ": thickness of all its " + << "components **** ERROR ****"; } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick_[i] << " does not match with " - << thickTot << " of the components"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " does not match with " << thickTot << " of the components"; } - } // End of loop over blocks + } // End of loop over blocks } void DDHGCalEEAlgo::positionSensitive(const DDLogicalPart& glog, double rin, - double rout, double zpos, int layertype, - DDCompactView& cpv) { + double rout, double zpos, int layertype, + DDCompactView& cpv) { static const double sqrt3 = std::sqrt(3.0); - double r = 0.5*(waferSize_ + waferSepar_); - double R = 2.0*r/sqrt3; - double dy = 0.75*R; - int N = (int)(0.5*rout/r) + 2; + double r = 0.5 * (waferSize_ + waferSepar_); + double R = 2.0 * r / sqrt3; + double dy = 0.75 * R; + int N = (int)(0.5 * rout / r) + 2; #ifdef EDM_ML_DEBUG - int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); - std::vector ntype(6,0); - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << glog.ddname() - << " rout " << rout << " N " << N - << " for maximum u, v; r " << r << " R " - << R << " dy " << dy; + int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); + std::vector ntype(6, 0); + edm::LogVerbatim("HGCalGeom") + << "DDHGCalEEAlgo: " << glog.ddname() << " rout " << rout << " N " << N + << " for maximum u, v; r " << r << " R " << R << " dy " << dy; #endif for (int u = -N; u <= N; ++u) { int iu = std::abs(u); for (int v = -N; v <= N; ++v) { int iv = std::abs(v); - int nr = 2*v; - int nc =-2*u+v; - double xpos = nc*r; - double ypos = nr*dy; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); + int nr = 2 * v; + int nc = -2 * u + v; + double xpos = nc * r; + double ypos = nr * dy; + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); #ifdef EDM_ML_DEBUG ++ntot; if (((corner.first <= 0) && std::abs(u) < 5 && std::abs(v) < 5) || - (std::abs(u) < 2 && std::abs(v) < 2)) { - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << glog.ddname() - << " R " << rin << ":" << rout - << "\n Z " << zpos << " LayerType " - << layertype << " u " << u << " v " << v - << " with " << corner.first <<" corners"; + (std::abs(u) < 2 && std::abs(v) < 2)) { + edm::LogVerbatim("HGCalGeom") + << "DDHGCalEEAlgo: " << glog.ddname() << " R " << rin << ":" << rout + << "\n Z " << zpos << " LayerType " << layertype << " u " << u + << " v " << v << " with " << corner.first << " corners"; } #endif if (corner.first > 0) { - int type = waferType_->getType(xpos,ypos,zpos); - int copy = type*1000000 + iv*100 + iu; - if (u < 0) copy += 10000; - if (v < 0) copy += 100000; + int type = waferType_->getType(xpos, ypos, zpos); + int copy = type * 1000000 + iv * 100 + iu; + if (u < 0) copy += 10000; + if (v < 0) copy += 100000; #ifdef EDM_ML_DEBUG - if (iu > ium) ium = iu; - if (iv > ivm) ivm = iv; - kount++; - if (copies_.count(copy) == 0) copies_.insert(copy); + if (iu > ium) ium = iu; + if (iv > ivm) ivm = iv; + kount++; + if (copies_.count(copy) == 0) copies_.insert(copy); #endif - if (corner.first == (int)(HGCalParameters::k_CornerSize)) { + if (corner.first == (int)(HGCalParameters::k_CornerSize)) { #ifdef EDM_ML_DEBUG - if (iu > iumAll) iumAll = iu; - if (iv > ivmAll) ivmAll = iv; - ++nin; + if (iu > iumAll) iumAll = iu; + if (iv > ivmAll) ivmAll = iv; + ++nin; #endif - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - if (layertype > 1) type += 3; - DDName name = DDName(DDSplit(wafers_[type]).first, - DDSplit(wafers_[type]).second); - cpv.position(name, glog.ddname(), copy, tran, rotation); + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + if (layertype > 1) type += 3; + DDName name = DDName(DDSplit(wafers_[type]).first, + DDSplit(wafers_[type]).second); + cpv.position(name, glog.ddname(), copy, tran, rotation); #ifdef EDM_ML_DEBUG - ++ntype[type]; - edm::LogVerbatim("HGCalGeom") << " DDHGCalEEAlgo: " << name - << " number " << copy - << " positioned in " << glog.ddname() - << " at " << tran - << " with " << rotation; + ++ntype[type]; + edm::LogVerbatim("HGCalGeom") + << " DDHGCalEEAlgo: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation; #endif - } + } } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: Maximum # of u " << ium - << ":" << iumAll << " # of v " << ivm << ":" - << ivmAll << " and " << nin << ":" << kount - << ":" << ntot << " wafers (" << ntype[0] - << ":" << ntype[1] << ":" << ntype[2] << ":" - << ntype[3] << ":" << ntype[4] << ":" - << ntype[5] << ") for " << glog.ddname() - << " R " << rin << ":" << rout; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalEEAlgo: Maximum # of u " << ium << ":" << iumAll << " # of v " + << ivm << ":" << ivmAll << " and " << nin << ":" << kount << ":" << ntot + << " wafers (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ":" + << ntype[3] << ":" << ntype[4] << ":" << ntype[5] << ") for " + << glog.ddname() << " R " << rin << ":" << rout; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h index 383ebcf9b5f53..f20d85b674890 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h @@ -7,66 +7,61 @@ #include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDTypes.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" class DDHGCalEEAlgo : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalEEAlgo(); //const std::string & name); + public: + // Constructor and Destructor + DDHGCalEEAlgo(); // const std::string & name); ~DDHGCalEEAlgo() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; -protected: - - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - void positionSensitive(const DDLogicalPart& glog, double rin, - double rout, double zpos, int layertype, - DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + void positionSensitive(const DDLogicalPart& glog, double rin, double rout, + double zpos, int layertype, DDCompactView& cpv); + private: std::unique_ptr waferType_; - std::vector wafers_; //Wafers - std::vector materials_; //Materials - std::vector names_; //Names - std::vector thick_; //Thickness of the material - std::vector copyNumber_; //Initial copy numbers - std::vector layers_; //Number of layers in a section - std::vector layerThick_; //Thickness of each section - std::vector layerType_; //Type of the layer - std::vector layerSense_; //Content of a layer (sensitive?) - int firstLayer_; //Copy # of the first sensitive layer - int absorbMode_; //Absorber mode - double zMinBlock_; //Starting z-value of the block - std::vector rad100to200_; //Parameters for 120-200mum trans. - std::vector rad200to300_; //Parameters for 200-300mum trans. - double zMinRadPar_; //Minimum z for radius parametriz. - int choiceType_; //Type of parametrization to be used - int nCutRadPar_; //Cut off threshold for corners - double fracAreaMin_; //Minimum fractional conatined area - double waferSize_; //Width of the wafer - double waferSepar_; //Sensor separation - int sectors_; //Sectors - std::vector slopeB_; //Slope at the lower R - std::vector zFrontB_; //Starting Z values for the slopes - std::vector rMinFront_; //Corresponding rMin's - std::vector slopeT_; //Slopes at the larger R - std::vector zFrontT_; //Starting Z values for the slopes - std::vector rMaxFront_; //Corresponding rMax's - std::string nameSpace_; //Namespace of this and ALL sub-parts - std::unordered_set copies_; //List of copy #'s - double alpha_, cosAlpha_; + std::vector wafers_; // Wafers + std::vector materials_; // Materials + std::vector names_; // Names + std::vector thick_; // Thickness of the material + std::vector copyNumber_; // Initial copy numbers + std::vector layers_; // Number of layers in a section + std::vector layerThick_; // Thickness of each section + std::vector layerType_; // Type of the layer + std::vector layerSense_; // Content of a layer (sensitive?) + int firstLayer_; // Copy # of the first sensitive layer + int absorbMode_; // Absorber mode + double zMinBlock_; // Starting z-value of the block + std::vector rad100to200_; // Parameters for 120-200mum trans. + std::vector rad200to300_; // Parameters for 200-300mum trans. + double zMinRadPar_; // Minimum z for radius parametriz. + int choiceType_; // Type of parametrization to be used + int nCutRadPar_; // Cut off threshold for corners + double fracAreaMin_; // Minimum fractional conatined area + double waferSize_; // Width of the wafer + double waferSepar_; // Sensor separation + int sectors_; // Sectors + std::vector slopeB_; // Slope at the lower R + std::vector zFrontB_; // Starting Z values for the slopes + std::vector rMinFront_; // Corresponding rMin's + std::vector slopeT_; // Slopes at the larger R + std::vector zFrontT_; // Starting Z values for the slopes + std::vector rMaxFront_; // Corresponding rMax's + std::string nameSpace_; // Namespace of this and ALL sub-parts + std::unordered_set copies_; // List of copy #'s + double alpha_, cosAlpha_; }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc index 0919bda3e3159..38f40f3fbc961 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc @@ -3,13 +3,13 @@ // Description: Geometry factory class for HGCal (Mix) /////////////////////////////////////////////////////////////////////////////// -#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h" #include "DataFormats/Math/interface/GeantUnits.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" @@ -23,172 +23,167 @@ DDHGCalHEAlgo::DDHGCalHEAlgo() { #endif } -DDHGCalHEAlgo::~DDHGCalHEAlgo() { } - -void DDHGCalHEAlgo::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs) { +DDHGCalHEAlgo::~DDHGCalHEAlgo() {} - wafers_ = vsArgs["WaferNames"]; -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << wafers_.size() - << " wafers"; - for (unsigned int i=0; i 0) { - for (unsigned int i=0; i 0) { - int ii = layerType_[i]; - copyNumber_[ii] = firstLayer_; + int ii = layerType_[i]; + copyNumber_[ii] = firstLayer_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "First copy number for layer type " - << i << ":" << ii << " with " - << materials_[ii] << " changed to " - << copyNumber_[ii]; + edm::LogVerbatim("HGCalGeom") + << "First copy number for layer type " << i << ":" << ii << " with " + << materials_[ii] << " changed to " << copyNumber_[ii]; #endif - break; + break; } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size() - << " layers" ; - for (unsigned int i=0; i(rad100to200_, rad200to300_, - (waferSize_+waferSepar_), - zMinRadPar_, choiceType_, - nCutRadPar_, fracAreaMin_); + waferType_ = std::make_unique( + rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, + choiceType_, nCutRadPar_, fracAreaMin_); } //////////////////////////////////////////////////////////////////// @@ -196,18 +191,17 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments & nArgs, //////////////////////////////////////////////////////////////////// void DDHGCalHEAlgo::execute(DDCompactView& cpv) { - #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalHEAlgo..."; copies_.clear(); #endif - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << copies_.size() - << " different wafer copy numbers"; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: " << copies_.size() << " different wafer copy numbers"; int k(0); - for (std::unordered_set::const_iterator itr=copies_.begin(); - itr != copies_.end(); ++itr,++k) { + for (std::unordered_set::const_iterator itr = copies_.begin(); + itr != copies_.end(); ++itr, ++k) { edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr); } copies_.clear(); @@ -215,358 +209,357 @@ void DDHGCalHEAlgo::execute(DDCompactView& cpv) { #endif } -void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: \t\tInside Layers"; #endif - double zi(zMinBlock_); - int laymin(0); + double zi(zMinBlock_); + int laymin(0); const double tol(0.01); - for (unsigned int i=0; i zr = HGCalGeomTools::zradius(zz,zz+thick_[ii], - zFrontT_,rMaxFront_); - zz += hthick; - thickTot += thick_[ii]; + for (unsigned int i = 0; i < layers_.size(); i++) { + double zo = zi + layerThick_[i]; + double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); + int laymax = laymin + layers_[i]; + double zz = zi; + double thickTot(0); + for (int ly = laymin; ly < laymax; ++ly) { + int ii = layerType_[ly]; + int copy = copyNumber_[ii]; + double hthick = 0.5 * thick_[ii]; + double rinB = HGCalGeomTools::radius(zo, zFrontB_, rMinFront_, slopeB_); + std::pair zr = + HGCalGeomTools::zradius(zz, zz + thick_[ii], zFrontT_, rMaxFront_); + zz += hthick; + thickTot += thick_[ii]; - std::string name = names_[ii]+std::to_string(copy); + std::string name = names_[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Layer " << ly << ":" - << ii << " Front " << zi << ", " << routF - << " Back " << zo << ", " << rinB - << " superlayer thickness " - << layerThick_[i]; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: Layer " << ly << ":" << ii << " Front " << zi + << ", " << routF << " Back " << zo << ", " << rinB + << " superlayer thickness " << layerThick_[i]; #endif - DDName matName(DDSplit(materials_[ii]).first, - DDSplit(materials_[ii]).second); + DDName matName(DDSplit(materials_[ii]).first, + DDSplit(materials_[ii]).second); DDMaterial matter(matName); DDLogicalPart glog; if (layerSense_[ly] < 1) { - int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0 || - zr.first < 0) ? 2 : 3; - std::vector pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); + int nsec = + (layerSense_[ly] == 0 || absorbMode_ == 0 || zr.first < 0) ? 2 : 3; + std::vector pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); if (layerSense_[ly] == 0 || absorbMode_ == 0) { - double rmax = (std::min(routF, - HGCalGeomTools::radius(zz+hthick,zFrontT_,rMaxFront_,slopeT_))* - cosAlpha_) - tol; - pgonZ[0] =-hthick; pgonZ[1] = hthick; - pgonRin[0] = rinB; pgonRin[1] = rinB; - pgonRout[0] = rmax; pgonRout[1] = rmax; + double rmax = + (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, + rMaxFront_, slopeT_)) * + cosAlpha_) - + tol; + pgonZ[0] = -hthick; + pgonZ[1] = hthick; + pgonRin[0] = rinB; + pgonRin[1] = rinB; + pgonRout[0] = rmax; + pgonRout[1] = rmax; } else { - for (int isec=0; isec layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " - << layerThick_[i] << " is smaller than " - << thickTot << ": thickness of all its " - << "components **** ERROR ****"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " is smaller than " << thickTot << ": thickness of all its " + << "components **** ERROR ****"; } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick_[i] << " does not match with " - << thickTot << " of the components"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " does not match with " << thickTot << " of the components"; } - } // End of loop over blocks + } // End of loop over blocks } -void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, - const std::string& nameM, int copyM, - double thick, const DDMaterial& matter, - double rin, double rmid, double rout, - double zz, DDCompactView& cpv) { - +void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, + const std::string& nameM, int copyM, + double thick, const DDMaterial& matter, + double rin, double rmid, double rout, double zz, + DDCompactView& cpv) { DDLogicalPart glog1; DDTranslation tran; - DDRotation rot; - for (unsigned int ly=0; ly thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick - << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << thick << " is smaller than " + << thickTot << ": thickness of all its components in " + << "the top part **** ERROR ****"; } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick - << " does not match with " << thickTot - << " of the components in top part"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << thick << " does not match with " + << thickTot << " of the components in top part"; } // Make the bottom part next - name = nameM+"Bottom"; - solid = DDSolidFactory::tubs(DDName(name, nameSpace_), - hthick, rin, rmid, 0.0, 2._pi); + name = nameM + "Bottom"; + solid = DDSolidFactory::tubs(DDName(name, nameSpace_), hthick, rin, rmid, 0.0, + 2._pi); glog1 = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << solid.name() - << " Tubs made of " << matter.name() - << " of dimensions " << rin << ", " << rmid - << ", " << hthick << ", 0.0, 360.0"; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: " << solid.name() << " Tubs made of " << matter.name() + << " of dimensions " << rin << ", " << rmid << ", " << hthick + << ", 0.0, 360.0"; #endif cpv.position(glog1, glog, 1, tran, rot); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog1.name() - << " number 1 positioned in " << glog.name() - << " at " << tran << " with " << rot; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: " << glog1.name() << " number 1 positioned in " + << glog.name() << " at " << tran << " with " << rot; #endif thickTot = 0; - zpos =-hthick; - for (unsigned int ly=0; ly thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick - << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << thick << " is smaller than " + << thickTot << ": thickness of all its components in " + << "the top part **** ERROR ****"; } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick - << " does not match with " << thickTot - << " of the components in top part"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << thick << " does not match with " + << thickTot << " of the components in top part"; } } void DDHGCalHEAlgo::positionSensitive(const DDLogicalPart& glog, double rin, - double rout, double zpos, int layertype, - DDCompactView& cpv) { + double rout, double zpos, int layertype, + DDCompactView& cpv) { static const double sqrt3 = std::sqrt(3.0); - double r = 0.5*(waferSize_ + waferSepar_); - double R = 2.0*r/sqrt3; - double dy = 0.75*R; - int N = (int)(0.5*rout/r) + 2; + double r = 0.5 * (waferSize_ + waferSepar_); + double R = 2.0 * r / sqrt3; + double dy = 0.75 * R; + int N = (int)(0.5 * rout / r) + 2; #ifdef EDM_ML_DEBUG - int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); - std::vector ntype(6,0); - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << glog.ddname() - << " rout " << rout << " N " << N - << " for maximum u, v"; + int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); + std::vector ntype(6, 0); + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: " << glog.ddname() << " rout " << rout << " N " << N + << " for maximum u, v"; #endif for (int u = -N; u <= N; ++u) { int iu = std::abs(u); for (int v = -N; v <= N; ++v) { int iv = std::abs(v); - int nr = 2*v; - int nc =-2*u+v; - double xpos = nc*r; - double ypos = nr*dy; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); + int nr = 2 * v; + int nc = -2 * u + v; + double xpos = nc * r; + double ypos = nr * dy; + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); #ifdef EDM_ML_DEBUG ++ntot; #endif if (corner.first > 0) { - int type = waferType_->getType(xpos,ypos,zpos); - int copy = type*1000000 + iv*100 + iu; - if (u < 0) copy += 10000; - if (v < 0) copy += 100000; -#ifdef EDM_ML_DEBUG - if (iu > ium) ium = iu; - if (iv > ivm) ivm = iv; - kount++; - if (copies_.count(copy) == 0) copies_.insert(copy); -#endif - if (corner.first == (int)(HGCalParameters::k_CornerSize)) { -#ifdef EDM_ML_DEBUG - if (iu > iumAll) iumAll = iu; - if (iv > ivmAll) ivmAll = iv; - ++nin; -#endif - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - if (layertype > 1) type += 3; - DDName name = DDName(DDSplit(wafers_[type]).first, - DDSplit(wafers_[type]).second); - cpv.position(name, glog.ddname(), copy, tran, rotation); -#ifdef EDM_ML_DEBUG - ++ntype[type]; - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << name - << " number " << copy - << " positioned in " << glog.ddname() - << " at " << tran - << " with " << rotation; -#endif - } + int type = waferType_->getType(xpos, ypos, zpos); + int copy = type * 1000000 + iv * 100 + iu; + if (u < 0) copy += 10000; + if (v < 0) copy += 100000; +#ifdef EDM_ML_DEBUG + if (iu > ium) ium = iu; + if (iv > ivm) ivm = iv; + kount++; + if (copies_.count(copy) == 0) copies_.insert(copy); +#endif + if (corner.first == (int)(HGCalParameters::k_CornerSize)) { +#ifdef EDM_ML_DEBUG + if (iu > iumAll) iumAll = iu; + if (iv > ivmAll) ivmAll = iv; + ++nin; +#endif + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + if (layertype > 1) type += 3; + DDName name = DDName(DDSplit(wafers_[type]).first, + DDSplit(wafers_[type]).second); + cpv.position(name, glog.ddname(), copy, tran, rotation); +#ifdef EDM_ML_DEBUG + ++ntype[type]; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation; +#endif + } } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: Maximum # of u " << ium - << ":" << iumAll << " # of v " << ivm << ":" - << ivmAll << " and " << nin << ":" << kount - << ":" << ntot << " wafers (" << ntype[0] - << ":" << ntype[1] << ":" << ntype[2] << ":" - << ntype[3] << ":" << ntype[4] << ":" - << ntype[5] << ") for " << glog.ddname() - << " R " << rin << ":" << rout; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalHEAlgo: Maximum # of u " << ium << ":" << iumAll << " # of v " + << ivm << ":" << ivmAll << " and " << nin << ":" << kount << ":" << ntot + << " wafers (" << ntype[0] << ":" << ntype[1] << ":" << ntype[2] << ":" + << ntype[3] << ":" << ntype[4] << ":" << ntype[5] << ") for " + << glog.ddname() << " R " << rin << ":" << rout; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h index c53fad60992be..3a595d359fa8f 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h @@ -7,84 +7,78 @@ #include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" +#include "DetectorDescription/Core/interface/DDTypes.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" class DDHGCalHEAlgo : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalHEAlgo(); //const std::string & name); + public: + // Constructor and Destructor + DDHGCalHEAlgo(); // const std::string & name); ~DDHGCalHEAlgo() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; -protected: - - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - void positionMix(const DDLogicalPart& glog,const std::string& name, - int copy, double thick, const DDMaterial& matter, - double rin, double rmid, double routF, double zz, - DDCompactView& cpv); - void positionSensitive(const DDLogicalPart& glog, double rin, - double rout, double zpos, int layertype, - DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + void positionMix(const DDLogicalPart& glog, const std::string& name, int copy, + double thick, const DDMaterial& matter, double rin, + double rmid, double routF, double zz, DDCompactView& cpv); + void positionSensitive(const DDLogicalPart& glog, double rin, double rout, + double zpos, int layertype, DDCompactView& cpv); + private: std::unique_ptr waferType_; - std::vector wafers_; //Wafers - std::vector materials_; //Materials - std::vector names_; //Names - std::vector thick_; //Thickness of the material - std::vector copyNumber_; //Initial copy numbers - std::vector layers_; //Number of layers in a section - std::vector layerThick_; //Thickness of each section - std::vector rMixLayer_; //Partition between Si/Sci part - std::vector layerType_; //Type of the layer - std::vector layerSense_; //Content of a layer (sensitive?) - int firstLayer_; //Copy # of the first sensitive layer - int absorbMode_; //Absorber mode - std::vector materialsTop_; //Materials of top layers - std::vector namesTop_; //Names of top layers - std::vector layerThickTop_; //Thickness of the top sections - std::vector layerTypeTop_; //Type of the Top layer - std::vector copyNumberTop_; //Initial copy numbers (top section) - std::vector materialsBot_; //Materials of bottom layers - std::vector namesBot_; //Names of bottom layers - std::vector layerThickBot_; //Thickness of the bottom sections - std::vector layerTypeBot_; //Type of the bottom layers - std::vector copyNumberBot_; //Initial copy numbers (bot section) - std::vector layerSenseBot_; //Content of bottom layer (sensitive?) + std::vector wafers_; // Wafers + std::vector materials_; // Materials + std::vector names_; // Names + std::vector thick_; // Thickness of the material + std::vector copyNumber_; // Initial copy numbers + std::vector layers_; // Number of layers in a section + std::vector layerThick_; // Thickness of each section + std::vector rMixLayer_; // Partition between Si/Sci part + std::vector layerType_; // Type of the layer + std::vector layerSense_; // Content of a layer (sensitive?) + int firstLayer_; // Copy # of the first sensitive layer + int absorbMode_; // Absorber mode + std::vector materialsTop_; // Materials of top layers + std::vector namesTop_; // Names of top layers + std::vector layerThickTop_; // Thickness of the top sections + std::vector layerTypeTop_; // Type of the Top layer + std::vector copyNumberTop_; // Initial copy numbers (top section) + std::vector materialsBot_; // Materials of bottom layers + std::vector namesBot_; // Names of bottom layers + std::vector layerThickBot_; // Thickness of the bottom sections + std::vector layerTypeBot_; // Type of the bottom layers + std::vector copyNumberBot_; // Initial copy numbers (bot section) + std::vector layerSenseBot_; // Content of bottom layer (sensitive?) - double zMinBlock_; //Starting z-value of the block - std::vector rad100to200_; //Parameters for 120-200mum trans. - std::vector rad200to300_; //Parameters for 200-300mum trans. - double zMinRadPar_; //Minimum z for radius parametriz. - int choiceType_; //Type of parametrization to be used - int nCutRadPar_; //Cut off threshold for corners - double fracAreaMin_; //Minimum fractional conatined area - double waferSize_; //Width of the wafer - double waferSepar_; //Sensor separation - int sectors_; //Sectors - std::vector slopeB_; //Slope at the lower R - std::vector zFrontB_; //Starting Z values for the slopes - std::vector rMinFront_; //Corresponding rMin's - std::vector slopeT_; //Slopes at the larger R - std::vector zFrontT_; //Starting Z values for the slopes - std::vector rMaxFront_; //Corresponding rMax's - std::string nameSpace_; //Namespace of this and ALL sub-parts - std::unordered_set copies_; //List of copy #'s - double alpha_, cosAlpha_; + double zMinBlock_; // Starting z-value of the block + std::vector rad100to200_; // Parameters for 120-200mum trans. + std::vector rad200to300_; // Parameters for 200-300mum trans. + double zMinRadPar_; // Minimum z for radius parametriz. + int choiceType_; // Type of parametrization to be used + int nCutRadPar_; // Cut off threshold for corners + double fracAreaMin_; // Minimum fractional conatined area + double waferSize_; // Width of the wafer + double waferSepar_; // Sensor separation + int sectors_; // Sectors + std::vector slopeB_; // Slope at the lower R + std::vector zFrontB_; // Starting Z values for the slopes + std::vector rMinFront_; // Corresponding rMin's + std::vector slopeT_; // Slopes at the larger R + std::vector zFrontT_; // Starting Z values for the slopes + std::vector rMaxFront_; // Corresponding rMax's + std::string nameSpace_; // Namespace of this and ALL sub-parts + std::unordered_set copies_; // List of copy #'s + double alpha_, cosAlpha_; }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc b/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc index e404d752dda53..35f83575f066a 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc @@ -3,21 +3,21 @@ // Description: Geometry factory class for HGCal (EE and HESil) /////////////////////////////////////////////////////////////////////////////// -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" -#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" -#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalModule.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalModule.h" //#define EDM_ML_DEBUG @@ -29,71 +29,68 @@ DDHGCalModule::DDHGCalModule() { DDHGCalModule::~DDHGCalModule() {} -void DDHGCalModule::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs){ - - wafer = vsArgs["WaferName"]; +void DDHGCalModule::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + wafer = vsArgs["WaferName"]; #ifdef EDM_ML_DEBUG std::cout << "DDHGCalModule: " << wafer.size() << " wafers" << std::endl; - for (unsigned int i=0; i> Constructing DDHGCalModule..." << std::endl; #endif copies.clear(); - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG std::cout << copies.size() << " different wafer copy numbers" << std::endl; int nk(0), k(0); - for (std::unordered_set::const_iterator itr=copies.begin(); - itr != copies.end(); ++itr,++k) { + for (std::unordered_set::const_iterator itr = copies.begin(); + itr != copies.end(); ++itr, ++k) { std::cout << "[" << k << "] : " << (*itr) << " "; ++nk; - if (nk == 8) { std::cout << std::endl; nk = 0;} + if (nk == 8) { + std::cout << std::endl; + nk = 0; + } } if (nk > 0) std::cout << std::endl; #endif @@ -127,99 +126,100 @@ void DDHGCalModule::execute(DDCompactView& cpv) { #endif } -void DDHGCalModule::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDHGCalModule::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG std::cout << "DDHGCalModule test: \t\tInside Layers" << std::endl; #endif - double zi(zMinBlock); - int laymin(0); + double zi(zMinBlock); + int laymin(0); const double tol(0.01); - for (unsigned int i=0; i pgonZ, pgonRin, pgonRout; - pgonZ.emplace_back(-0.5*thick[ii]); pgonZ.emplace_back(0.5*thick[ii]); - pgonRin.emplace_back(rinB); pgonRin.emplace_back(rinB); - pgonRout.emplace_back(rmax); pgonRout.emplace_back(rmax); - DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), - sectors, -alpha, CLHEP::twopi, - pgonZ, pgonRin, pgonRout); - glog = DDLogicalPart(solid.ddname(), matter, solid); + double alpha = CLHEP::pi / sectors; + double rmax = routF * cos(alpha) - tol; + std::vector pgonZ, pgonRin, pgonRout; + pgonZ.emplace_back(-0.5 * thick[ii]); + pgonZ.emplace_back(0.5 * thick[ii]); + pgonRin.emplace_back(rinB); + pgonRin.emplace_back(rinB); + pgonRout.emplace_back(rmax); + pgonRout.emplace_back(rmax); + DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), + sectors, -alpha, CLHEP::twopi, + pgonZ, pgonRin, pgonRout); + glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: " << solid.name() - << " polyhedra of " << sectors << " sectors covering " - << -alpha/CLHEP::deg << ":" - << (-alpha+CLHEP::twopi)/CLHEP::deg - << " with " << pgonZ.size() << " sections" << std::endl; - for (unsigned int k=0; k layerThick[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] - << " is smaller than thickness " << thickTot - << " of all its components **** ERROR ****\n"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " is smaller than thickness " << thickTot + << " of all its components **** ERROR ****\n"; } else if (thickTot < layerThick[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick[i] << " does not match with " - << thickTot << " of the components\n"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " does not match with " << thickTot << " of the components\n"; } - } // End of loop over blocks + } // End of loop over blocks } double DDHGCalModule::rMax(double z) { @@ -227,9 +227,9 @@ double DDHGCalModule::rMax(double z) { #ifdef EDM_ML_DEBUG unsigned int ik(0); #endif - for (unsigned int k=0; k= 0) ? nr : -nr; - for (int nc=-ncol; nc <= ncol; ++nc) { + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = (nc >= 0) ? nc : -nc; - if (inr%2 == inc%2) { - double xpos = nc*dx; - double ypos = nr*dy; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); - ++ntot; - if (corner.first > 0) { - int copy = inr*100 + inc; - if (nc < 0) copy += 10000; - if (nr < 0) copy += 100000; - if (inc > incm) incm = inc; - if (inr > inrm) inrm = inr; - kount++; - if (copies.count(copy) == 0) copies.insert(copy); - if (corner.first == (int)(HGCalParameters::k_CornerSize)) { - double rpos = std::sqrt(xpos*xpos+ypos*ypos); - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - ++nin; - DDName name = (rpos < rMaxFine) ? - DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) : - DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second); - cpv.position(name, glog.ddname(), copy, tran, rotation); - if (rpos < rMaxFine) ++nfine; - else ++ncoarse; + if (inr % 2 == inc % 2) { + double xpos = nc * dx; + double ypos = nr * dy; + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); + ++ntot; + if (corner.first > 0) { + int copy = inr * 100 + inc; + if (nc < 0) copy += 10000; + if (nr < 0) copy += 100000; + if (inc > incm) incm = inc; + if (inr > inrm) inrm = inr; + kount++; + if (copies.count(copy) == 0) copies.insert(copy); + if (corner.first == (int)(HGCalParameters::k_CornerSize)) { + double rpos = std::sqrt(xpos * xpos + ypos * ypos); + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + ++nin; + DDName name = + (rpos < rMaxFine) + ? DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) + : DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second); + cpv.position(name, glog.ddname(), copy, tran, rotation); + if (rpos < rMaxFine) + ++nfine; + else + ++ncoarse; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + std::cout << "DDHGCalModule: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation << std::endl; #endif - } - } + } + } } } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: # of columns " << incm << " # of rows " - << inrm << " and " << nin << ":" << kount << ":" << ntot - << " wafers (" << nfine << ":" << ncoarse << ") for " - << glog.ddname() << " R " << rin << ":" << rout << std::endl; + std::cout << "DDHGCalModule: # of columns " << incm << " # of rows " << inrm + << " and " << nin << ":" << kount << ":" << ntot << " wafers (" + << nfine << ":" << ncoarse << ") for " << glog.ddname() << " R " + << rin << ":" << rout << std::endl; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModule.h b/Geometry/HGCalCommonData/plugins/DDHGCalModule.h index 03ab367a655c2..445503a6b66e8 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModule.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModule.h @@ -3,54 +3,50 @@ #include #include +#include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" -#include +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalModule : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalModule(); //const std::string & name); + public: + // Constructor and Destructor + DDHGCalModule(); // const std::string & name); ~DDHGCalModule() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; - -protected: - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - double rMax(double z); - void positionSensitive(DDLogicalPart& glog, double rin, double rout, - DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + double rMax(double z); + void positionSensitive(DDLogicalPart& glog, double rin, double rout, + DDCompactView& cpv); - std::vector wafer; //Wafers - std::vector materials; //Materials - std::vector names; //Names - std::vector thick; //Thickness of the material - std::vector copyNumber; //Initial copy numbers - std::vector layers; //Number of layers in a section - std::vector layerThick; //Thickness of each section - std::vector layerType; //Type of the layer - std::vector layerSense; //COntent of a layer (sensitive?) - double zMinBlock; //Starting z-value of the block - double rMaxFine; //Maximum r-value for fine wafer - double waferW; //Width of the wafer - int sectors; //Sectors - std::vector slopeB; //Slope at the lower R - std::vector slopeT; //Slopes at the larger R - std::vector zFront; //Starting Z values for the slopes - std::vector rMaxFront; //Corresponding rMax's - std::string idName; //Name of the "parent" volume. - std::string idNameSpace; //Namespace of this and ALL sub-parts - std::unordered_set copies; //List of copy #'s + private: + std::vector wafer; // Wafers + std::vector materials; // Materials + std::vector names; // Names + std::vector thick; // Thickness of the material + std::vector copyNumber; // Initial copy numbers + std::vector layers; // Number of layers in a section + std::vector layerThick; // Thickness of each section + std::vector layerType; // Type of the layer + std::vector layerSense; // COntent of a layer (sensitive?) + double zMinBlock; // Starting z-value of the block + double rMaxFine; // Maximum r-value for fine wafer + double waferW; // Width of the wafer + int sectors; // Sectors + std::vector slopeB; // Slope at the lower R + std::vector slopeT; // Slopes at the larger R + std::vector zFront; // Starting Z values for the slopes + std::vector rMaxFront; // Corresponding rMax's + std::string idName; // Name of the "parent" volume. + std::string idNameSpace; // Namespace of this and ALL sub-parts + std::unordered_set copies; // List of copy #'s }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc index 3a11dd42e568e..604d8c8a9782d 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc @@ -3,21 +3,21 @@ // Description: Geometry factory class for HGCal (EE and HESil) /////////////////////////////////////////////////////////////////////////////// -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" -#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" -#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h" //#define EDM_ML_DEBUG @@ -29,72 +29,71 @@ DDHGCalModuleAlgo::DDHGCalModuleAlgo() { DDHGCalModuleAlgo::~DDHGCalModuleAlgo() {} -void DDHGCalModuleAlgo::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs){ - - wafer = vsArgs["WaferName"]; +void DDHGCalModuleAlgo::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + wafer = vsArgs["WaferName"]; #ifdef EDM_ML_DEBUG std::cout << "DDHGCalModuleAlgo: " << wafer.size() << " wafers" << std::endl; - for (unsigned int i=0; i> Constructing DDHGCalModuleAlgo..." << std::endl; #endif copies.clear(); - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG std::cout << copies.size() << " different wafer copy numbers" << std::endl; #endif @@ -120,97 +118,100 @@ void DDHGCalModuleAlgo::execute(DDCompactView& cpv) { #endif } -void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG std::cout << "DDHGCalModuleAlgo test: \t\tInside Layers" << std::endl; #endif - double zi(zMinBlock); - int laymin(0); + double zi(zMinBlock); + int laymin(0); const double tol(0.01); - for (unsigned int i=0; i pgonZ, pgonRin, pgonRout; - pgonZ.emplace_back(-0.5*thick[ii]); pgonZ.emplace_back(0.5*thick[ii]); - pgonRin.emplace_back(rinB); pgonRin.emplace_back(rinB); - pgonRout.emplace_back(rmax); pgonRout.emplace_back(rmax); - DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), - sectors, -alpha, CLHEP::twopi, - pgonZ, pgonRin, pgonRout); - glog = DDLogicalPart(solid.ddname(), matter, solid); + double alpha = CLHEP::pi / sectors; + double rmax = routF * cos(alpha) - tol; + std::vector pgonZ, pgonRin, pgonRout; + pgonZ.emplace_back(-0.5 * thick[ii]); + pgonZ.emplace_back(0.5 * thick[ii]); + pgonRin.emplace_back(rinB); + pgonRin.emplace_back(rinB); + pgonRout.emplace_back(rmax); + pgonRout.emplace_back(rmax); + DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), + sectors, -alpha, CLHEP::twopi, + pgonZ, pgonRin, pgonRout); + glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: " << solid.name() - << " polyhedra of " << sectors << " sectors covering " - << -alpha/CLHEP::deg << ":" - << (-alpha+CLHEP::twopi)/CLHEP::deg - << " with " << pgonZ.size() << " sections" << std::endl; - for (unsigned int k=0; k layerThick[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] - << " is smaller than thickness " << thickTot - << " of all its components **** ERROR ****\n"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " is smaller than thickness " << thickTot + << " of all its components **** ERROR ****\n"; } else if (thickTot < layerThick[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick[i] << " does not match with " - << thickTot << " of the components\n"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick[i] + << " does not match with " << thickTot << " of the components\n"; } - } // End of loop over blocks + } // End of loop over blocks } double DDHGCalModuleAlgo::rMax(double z) { @@ -218,9 +219,9 @@ double DDHGCalModuleAlgo::rMax(double z) { #ifdef EDM_ML_DEBUG unsigned int ik(0); #endif - for (unsigned int k=0; k= 0) ? nr : -nr; - for (int nc=-ncol; nc <= ncol; ++nc) { + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = (nc >= 0) ? nc : -nc; - if (inr%2 == inc%2) { - double xpos = nc*dx; - double ypos = nr*dy; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); - if (corner.first == (int)(HGCalParameters::k_CornerSize)) { - double rpos = std::sqrt(xpos*xpos+ypos*ypos); - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - int copy = inr*100 + inc; - if (nc < 0) copy += 10000; - if (nr < 0) copy += 100000; - DDName name = (rpos < rMaxFine) ? - DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) : - DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second); - cpv.position(name, glog.ddname(), copy, tran, rotation); - if (inc > incm) incm = inc; - if (inr > inrm) inrm = inr; - kount++; - if (copies.count(copy) == 0) - copies.insert(copy); + if (inr % 2 == inc % 2) { + double xpos = nc * dx; + double ypos = nr * dy; + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); + if (corner.first == (int)(HGCalParameters::k_CornerSize)) { + double rpos = std::sqrt(xpos * xpos + ypos * ypos); + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + int copy = inr * 100 + inc; + if (nc < 0) copy += 10000; + if (nr < 0) copy += 100000; + DDName name = + (rpos < rMaxFine) + ? DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) + : DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second); + cpv.position(name, glog.ddname(), copy, tran, rotation); + if (inc > incm) incm = inc; + if (inr > inrm) inrm = inr; + kount++; + if (copies.count(copy) == 0) copies.insert(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + std::cout << "DDHGCalModuleAlgo: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation << std::endl; #endif - } + } } } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: # of columns " << incm << " # of rows " - << inrm << " and " << kount << " wafers for " << glog.ddname() - << std::endl; + std::cout << "DDHGCalModuleAlgo: # of columns " << incm << " # of rows " + << inrm << " and " << kount << " wafers for " << glog.ddname() + << std::endl; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h index 15637f9510575..8a234f3e16861 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h @@ -3,55 +3,51 @@ #include #include +#include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" -#include +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalModuleAlgo : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalModuleAlgo(); //const std::string & name); + public: + // Constructor and Destructor + DDHGCalModuleAlgo(); // const std::string & name); ~DDHGCalModuleAlgo() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; - -protected: - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - double rMax(double z); - void positionSensitive(DDLogicalPart& glog, double rin, double rout, - DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + double rMax(double z); + void positionSensitive(DDLogicalPart& glog, double rin, double rout, + DDCompactView& cpv); - std::vector wafer; //Wafers - std::vector materials; //Materials - std::vector names; //Names - std::vector thick; //Thickness of the material - std::vector copyNumber; //Initial copy numbers - std::vector layers; //Number of layers in a section - std::vector layerThick; //Thickness of each section - std::vector layerType; //Type of the layer - std::vector layerSense; //COntent of a layer (sensitive?) - double zMinBlock; //Starting z-value of the block - double rMaxFine; //Maximum r-value for fine wafer - double waferW; //Width of the wafer - double waferGap; //Gap between 2 wafers - int sectors; //Sectors - std::vector slopeB; //Slope at the lower R - std::vector slopeT; //Slopes at the larger R - std::vector zFront; //Starting Z values for the slopes - std::vector rMaxFront; //Corresponding rMax's - std::string idName; //Name of the "parent" volume. - std::string idNameSpace; //Namespace of this and ALL sub-parts - std::unordered_set copies; //List of copy #'s + private: + std::vector wafer; // Wafers + std::vector materials; // Materials + std::vector names; // Names + std::vector thick; // Thickness of the material + std::vector copyNumber; // Initial copy numbers + std::vector layers; // Number of layers in a section + std::vector layerThick; // Thickness of each section + std::vector layerType; // Type of the layer + std::vector layerSense; // COntent of a layer (sensitive?) + double zMinBlock; // Starting z-value of the block + double rMaxFine; // Maximum r-value for fine wafer + double waferW; // Width of the wafer + double waferGap; // Gap between 2 wafers + int sectors; // Sectors + std::vector slopeB; // Slope at the lower R + std::vector slopeT; // Slopes at the larger R + std::vector zFront; // Starting Z values for the slopes + std::vector rMaxFront; // Corresponding rMax's + std::string idName; // Name of the "parent" volume. + std::string idNameSpace; // Namespace of this and ALL sub-parts + std::unordered_set copies; // List of copy #'s }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc index fd51a8c4f3c34..e5daa2f0ff9cb 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc @@ -1,69 +1,70 @@ -#include #include +#include #include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDSolid.h" -#include "DetectorDescription/Core/interface/DDMaterial.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" -#include "DetectorDescription/Core/interface/DDSplit.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDMaterial.h" +#include "DetectorDescription/Core/interface/DDSolid.h" +#include "DetectorDescription/Core/interface/DDSplit.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG DDHGCalNoTaperEndcap::DDHGCalNoTaperEndcap() { - edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap test: Creating an instance"; + edm::LogInfo("HGCalGeom") + << "DDHGCalNoTaperEndcap test: Creating an instance"; } DDHGCalNoTaperEndcap::~DDHGCalNoTaperEndcap() {} -void DDHGCalNoTaperEndcap::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments & ) { - m_tiltAngle = nArgs["tiltAngle"]; - m_invert = int( nArgs["invert"] ); - m_rMin = int( nArgs["rMin"] ); - m_rMax = int( nArgs["rMax"] ); - m_zoffset = nArgs["zoffset"]; - m_xyoffset = nArgs["xyoffset"]; - m_n = int( nArgs["n"] ); - m_startCopyNo = int( nArgs["startCopyNo"] ); - m_incrCopyNo = int( nArgs["incrCopyNo"] ); - m_childName = sArgs["ChildName"]; +void DDHGCalNoTaperEndcap::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments&) { + m_tiltAngle = nArgs["tiltAngle"]; + m_invert = int(nArgs["invert"]); + m_rMin = int(nArgs["rMin"]); + m_rMax = int(nArgs["rMax"]); + m_zoffset = nArgs["zoffset"]; + m_xyoffset = nArgs["xyoffset"]; + m_n = int(nArgs["n"]); + m_startCopyNo = int(nArgs["startCopyNo"]); + m_incrCopyNo = int(nArgs["incrCopyNo"]); + m_childName = sArgs["ChildName"]; m_idNameSpace = DDCurrentNamespace::ns(); - edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap: NameSpace " << m_idNameSpace - << "\tParent " << parent().name(); + edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap: NameSpace " + << m_idNameSpace << "\tParent " << parent().name(); } -void DDHGCalNoTaperEndcap::execute( DDCompactView& cpv ) { +void DDHGCalNoTaperEndcap::execute(DDCompactView& cpv) { int lastCopyNo = m_startCopyNo; - lastCopyNo = createQuarter( cpv, 1, 1, lastCopyNo ); - lastCopyNo = createQuarter( cpv, -1, 1, lastCopyNo ); - lastCopyNo = createQuarter( cpv, -1, -1, lastCopyNo ); - createQuarter( cpv, 1, -1, lastCopyNo ); + lastCopyNo = createQuarter(cpv, 1, 1, lastCopyNo); + lastCopyNo = createQuarter(cpv, -1, 1, lastCopyNo); + lastCopyNo = createQuarter(cpv, -1, -1, lastCopyNo); + createQuarter(cpv, 1, -1, lastCopyNo); } -int -DDHGCalNoTaperEndcap::createQuarter( DDCompactView& cpv, int xQuadrant, int yQuadrant, int startCopyNo ) { - int copyNo = startCopyNo; +int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, + int yQuadrant, int startCopyNo) { + int copyNo = startCopyNo; double tiltAngle = m_tiltAngle; - double xphi = xQuadrant*tiltAngle; - double yphi = yQuadrant*tiltAngle; - double theta = 90.*CLHEP::deg; - double phiX = 0.0; - double phiY = theta; - double phiZ = 3*theta; - double offsetZ = m_zoffset; - double offsetXY = m_xyoffset; + double xphi = xQuadrant * tiltAngle; + double yphi = yQuadrant * tiltAngle; + double theta = 90. * CLHEP::deg; + double phiX = 0.0; + double phiY = theta; + double phiZ = 3 * theta; + double offsetZ = m_zoffset; + double offsetXY = m_xyoffset; + + double offsetX = xQuadrant * 0.5 * offsetXY; + double offsetY = yQuadrant * 0.5 * offsetXY; - double offsetX = xQuadrant*0.5*offsetXY; - double offsetY = yQuadrant*0.5*offsetXY; - #ifdef EDM_ML_DEBUG int rowmax(0), column(0); #endif @@ -76,70 +77,71 @@ DDHGCalNoTaperEndcap::createQuarter( DDCompactView& cpv, int xQuadrant, int yQua #ifdef EDM_ML_DEBUG row++; #endif - double limit1 = sqrt((offsetX+0.5*xQuadrant*offsetXY)* - (offsetX+0.5*xQuadrant*offsetXY) + - (offsetY+0.5*yQuadrant*offsetXY)* - (offsetY+0.5*yQuadrant*offsetXY) ); - double limit2 = sqrt((offsetX-0.5*xQuadrant*offsetXY)* - (offsetX-0.5*xQuadrant*offsetXY) + - (offsetY-0.5*yQuadrant*offsetXY)* - (offsetY-0.5*yQuadrant*offsetXY) ); + double limit1 = sqrt((offsetX + 0.5 * xQuadrant * offsetXY) * + (offsetX + 0.5 * xQuadrant * offsetXY) + + (offsetY + 0.5 * yQuadrant * offsetXY) * + (offsetY + 0.5 * yQuadrant * offsetXY)); + double limit2 = sqrt((offsetX - 0.5 * xQuadrant * offsetXY) * + (offsetX - 0.5 * xQuadrant * offsetXY) + + (offsetY - 0.5 * yQuadrant * offsetXY) * + (offsetY - 0.5 * yQuadrant * offsetXY)); // Make sure we do not add supermodules in rMin area if (limit2 > m_rMin && limit1 < m_rMax) { #ifdef EDM_ML_DEBUG - std::cout << m_childName << " copyNo = " << copyNo << " (" << column - << "," << row << "): offsetX,Y = " << offsetX << "," - << offsetY << " limit=" << limit1 << ":" << limit2 - << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl; + std::cout << m_childName << " copyNo = " << copyNo << " (" << column + << "," << row << "): offsetX,Y = " << offsetX << "," + << offsetY << " limit=" << limit1 << ":" << limit2 + << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl; #endif - DDRotation rotation; - std::string rotstr( "NULL" ); - - // Check if we've already created the rotation matrix - rotstr = "R"; - rotstr += std::to_string(copyNo); - rotation = DDRotation(DDName(rotstr)); - if (!rotation) { - rotation = DDrot(DDName(rotstr, m_idNameSpace), - std::make_unique( *DDcreateRotationMatrix( theta, phiX, theta + yphi, phiY, -yphi, phiZ ) - * ( *DDcreateRotationMatrix( theta + xphi, phiX, 90.*CLHEP::deg, 90.*CLHEP::deg, xphi, 0.0 )))); - } - - - DDTranslation tran(offsetX, offsetY, offsetZ); - edm::LogInfo("HGCalGeom") << "Module " << copyNo << ": location = " - << tran << " Rotation " << rotation; - - DDName parentName = parent().name(); - cpv.position(DDName(m_childName), parentName, copyNo, tran, rotation); - - copyNo += m_incrCopyNo; + DDRotation rotation; + std::string rotstr("NULL"); + + // Check if we've already created the rotation matrix + rotstr = "R"; + rotstr += std::to_string(copyNo); + rotation = DDRotation(DDName(rotstr)); + if (!rotation) { + rotation = DDrot( + DDName(rotstr, m_idNameSpace), + std::make_unique( + *DDcreateRotationMatrix(theta, phiX, theta + yphi, phiY, + -yphi, phiZ) * + (*DDcreateRotationMatrix(theta + xphi, phiX, 90. * CLHEP::deg, + 90. * CLHEP::deg, xphi, 0.0)))); + } + + DDTranslation tran(offsetX, offsetY, offsetZ); + edm::LogInfo("HGCalGeom") + << "Module " << copyNo << ": location = " << tran << " Rotation " + << rotation; + + DDName parentName = parent().name(); + cpv.position(DDName(m_childName), parentName, copyNo, tran, rotation); + + copyNo += m_incrCopyNo; } else { #ifdef EDM_ML_DEBUG - std::cout << " (" << column << "," << row << "): offsetX,Y = " - << offsetX << "," << offsetY << " is out of limit=" << limit1 - << ":" << limit2 << " rMin, rMax = " << m_rMin << "," - << m_rMax << std::endl; + std::cout << " (" << column << "," << row + << "): offsetX,Y = " << offsetX << "," << offsetY + << " is out of limit=" << limit1 << ":" << limit2 + << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl; #endif } - yphi += yQuadrant*2.*tiltAngle; - offsetY += yQuadrant*offsetXY; - + yphi += yQuadrant * 2. * tiltAngle; + offsetY += yQuadrant * offsetXY; } #ifdef EDM_ML_DEBUG if (row > rowmax) rowmax = row; #endif - xphi += xQuadrant*2.*tiltAngle; - yphi = yQuadrant*tiltAngle; - offsetY = yQuadrant*0.5*offsetXY; - offsetX += xQuadrant*offsetXY; - + xphi += xQuadrant * 2. * tiltAngle; + yphi = yQuadrant * tiltAngle; + offsetY = yQuadrant * 0.5 * offsetXY; + offsetX += xQuadrant * offsetXY; } #ifdef EDM_ML_DEBUG - std::cout << rowmax << " rows and " << column << " columns in quadrant " - << xQuadrant << ":" << yQuadrant << std::endl; + std::cout << rowmax << " rows and " << column << " columns in quadrant " + << xQuadrant << ":" << yQuadrant << std::endl; #endif return copyNo; } - diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h index 5db3f0d2dd4da..2b30bbcae7cb6 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h @@ -3,39 +3,37 @@ #include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalNoTaperEndcap : public DDAlgorithm { - -public: - DDHGCalNoTaperEndcap( void ); - ~DDHGCalNoTaperEndcap( void ) override; - - void initialize( const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs ) override; - - void execute( DDCompactView& cpv ) override; - -private: - - int createQuarter( DDCompactView& cpv, int xQuadrant, int yQuadrant, int startCopyNo ); - - double m_startAngle; // Start angle - double m_tiltAngle; // Tilt angle - int m_invert; // Inverted or forward - double m_rMin; // Inner radius - double m_rMax; // Outer radius - double m_zoffset; // Offset in z - double m_xyoffset; // Offset in x or y - int m_n; // Mumber of copies - int m_startCopyNo; // Start copy Number - int m_incrCopyNo; // Increment copy Number - std::string m_childName; // Children name - std::string m_idNameSpace; // Namespace of this and ALL sub-parts + public: + DDHGCalNoTaperEndcap(void); + ~DDHGCalNoTaperEndcap(void) override; + + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + + void execute(DDCompactView& cpv) override; + + private: + int createQuarter(DDCompactView& cpv, int xQuadrant, int yQuadrant, + int startCopyNo); + + double m_startAngle; // Start angle + double m_tiltAngle; // Tilt angle + int m_invert; // Inverted or forward + double m_rMin; // Inner radius + double m_rMax; // Outer radius + double m_zoffset; // Offset in z + double m_xyoffset; // Offset in x or y + int m_n; // Mumber of copies + int m_startCopyNo; // Start copy Number + int m_incrCopyNo; // Increment copy Number + std::string m_childName; // Children name + std::string m_idNameSpace; // Namespace of this and ALL sub-parts }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc index 8b86a388fe353..260c69f602f54 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc @@ -1,16 +1,16 @@ -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" -#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" -#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG @@ -22,81 +22,85 @@ DDHGCalTBModule::DDHGCalTBModule() { DDHGCalTBModule::~DDHGCalTBModule() {} -void DDHGCalTBModule::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs){ - - wafer_ = vsArgs["WaferName"]; - covers_ = vsArgs["CoverName"]; +void DDHGCalTBModule::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + wafer_ = vsArgs["WaferName"]; + covers_ = vsArgs["CoverName"]; #ifdef EDM_ML_DEBUG std::cout << "DDHGCalTBModule: " << wafer_.size() << " wafers" << std::endl; unsigned int i(0); for (auto wafer : wafer_) { - std::cout << "Wafer[" << i << "] " << wafer << std::endl; ++i;} + std::cout << "Wafer[" << i << "] " << wafer << std::endl; + ++i; + } std::cout << "DDHGCalTBModule: " << covers_.size() << " covers" << std::endl; i = 0; for (auto cover : covers_) { - std::cout << "Cover[" << i << "] " << cover << std::endl; ++i;} + std::cout << "Cover[" << i << "] " << cover << std::endl; + ++i; + } #endif - materials_ = vsArgs["MaterialNames"]; - names_ = vsArgs["VolumeNames"]; - thick_ = vArgs["Thickness"]; - for (unsigned int i=0; i> Constructing DDHGCalTBModule..." << std::endl; #endif copies_.clear(); - constructLayers (parent(), cpv); + constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG std::cout << copies_.size() << " different wafer copy numbers" << std::endl; #endif @@ -122,84 +125,85 @@ void DDHGCalTBModule::execute(DDCompactView& cpv) { #endif } -void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, - DDCompactView& cpv) { - +void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG std::cout << "DDHGCalTBModule test: \t\tInside Layers" << std::endl; #endif - double zi(zMinBlock_); - int laymin(0); - for (unsigned int i=0; i layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] - << " is smaller than thickness " << thickTot - << " of all its components **** ERROR ****\n"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " is smaller than thickness " << thickTot + << " of all its components **** ERROR ****\n"; } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << layerThick_[i] << " does not match with " - << thickTot << " of the components\n"; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << layerThick_[i] + << " does not match with " << thickTot << " of the components\n"; } - } // End of loop over blocks + } // End of loop over blocks } double DDHGCalTBModule::rMax(double z) { @@ -207,9 +211,9 @@ double DDHGCalTBModule::rMax(double z) { #ifdef EDM_ML_DEBUG unsigned int ik(0); #endif - for (unsigned int k=0; k= 0) ? nr : -nr; - for (int nc=-ncol; nc <= ncol; ++nc) { + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = (nc >= 0) ? nc : -nc; - if (inr%2 == inc%2) { - double xpos = nc*dx; - double ypos = nr*dy; - xc[0] = xpos+dx; yc[0] = ypos-0.5*rr; - xc[1] = xpos+dx; yc[1] = ypos+0.5*rr; - xc[2] = xpos; yc[2] = ypos+rr; - xc[3] = xpos-dx; yc[3] = ypos+0.5*rr; - xc[4] = xpos+dx; yc[4] = ypos-0.5*rr; - xc[5] = xpos; yc[5] = ypos-rr; + if (inr % 2 == inc % 2) { + double xpos = nc * dx; + double ypos = nr * dy; + xc[0] = xpos + dx; + yc[0] = ypos - 0.5 * rr; + xc[1] = xpos + dx; + yc[1] = ypos + 0.5 * rr; + xc[2] = xpos; + yc[2] = ypos + rr; + xc[3] = xpos - dx; + yc[3] = ypos + 0.5 * rr; + xc[4] = xpos + dx; + yc[4] = ypos - 0.5 * rr; + xc[5] = xpos; + yc[5] = ypos - rr; bool cornerAll(true); - for (int k=0; k<6; ++k) { - double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]); + for (int k = 0; k < 6; ++k) { + double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]); if (rpos < rin || rpos > rout) cornerAll = false; } - if (cornerAll) { - double rpos = std::sqrt(xpos*xpos+ypos*ypos); - DDTranslation tran(xpos, ypos, 0.0); - DDRotation rotation; - int copy = inr*100 + inc; - if (nc < 0) copy += 10000; - if (nr < 0) copy += 100000; - DDName name; - if (type == 1) { - name = (rpos < rMaxFine_) ? - DDName(DDSplit(wafer_[0]).first, DDSplit(wafer_[0]).second) : - DDName(DDSplit(wafer_[1]).first, DDSplit(wafer_[1]).second); - } else { - name = DDName(DDSplit(covers_[type-2]).first, - DDSplit(covers_[type-2]).second); - } - cpv.position(name, glog.ddname(), copy, tran, rotation); - if (inc > incm) incm = inc; - if (inr > inrm) inrm = inr; - kount++; - if (copies_.count(copy) == 0 && type == 1) - copies_.insert(copy); + if (cornerAll) { + double rpos = std::sqrt(xpos * xpos + ypos * ypos); + DDTranslation tran(xpos, ypos, 0.0); + DDRotation rotation; + int copy = inr * 100 + inc; + if (nc < 0) copy += 10000; + if (nr < 0) copy += 100000; + DDName name; + if (type == 1) { + name = (rpos < rMaxFine_) ? DDName(DDSplit(wafer_[0]).first, + DDSplit(wafer_[0]).second) + : DDName(DDSplit(wafer_[1]).first, + DDSplit(wafer_[1]).second); + } else { + name = DDName(DDSplit(covers_[type - 2]).first, + DDSplit(covers_[type - 2]).second); + } + cpv.position(name, glog.ddname(), copy, tran, rotation); + if (inc > incm) incm = inc; + if (inr > inrm) inrm = inr; + kount++; + if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + std::cout << "DDHGCalTBModule: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation << std::endl; #endif - } + } } } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: # of columns " << incm << " # of rows " - << inrm << " and " << kount << " wafers for " << glog.ddname() - << std::endl; + std::cout << "DDHGCalTBModule: # of columns " << incm << " # of rows " << inrm + << " and " << kount << " wafers for " << glog.ddname() << std::endl; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h index cc55ec1ce826d..1c259af4fc586 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h @@ -3,58 +3,54 @@ #include #include +#include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" -#include +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalTBModule : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalTBModule(); //const std::string & name); + public: + // Constructor and Destructor + DDHGCalTBModule(); // const std::string & name); ~DDHGCalTBModule() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; - -protected: - void constructLayers (const DDLogicalPart&, DDCompactView& cpv); - double rMax(double z); - void positionSensitive(DDLogicalPart& glog, int type, double rin, - double rout, DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructLayers(const DDLogicalPart&, DDCompactView& cpv); + double rMax(double z); + void positionSensitive(DDLogicalPart& glog, int type, double rin, double rout, + DDCompactView& cpv); - std::vector wafer_; //Wafers - std::vector covers_; //Insensitive layers of hexagonal size - std::vector materials_; //Materials - std::vector names_; //Names - std::vector thick_; //Thickness of the material - std::vector copyNumber_; //Initial copy numbers - std::vector layers_; //Number of layers in a section - std::vector layerThick_; //Thickness of each section - std::vector layerType_; //Type of the layer - std::vector layerSense_; //COntent of a layer (sensitive?) - double zMinBlock_; //Starting z-value of the block - double rMaxFine_; //Maximum r-value for fine wafer - double waferW_; //Width of the wafer - double waferGap_; //Gap between 2 wafers - double absorbW_; //Width of the absorber - double absorbH_; //Height of the absorber - int sectors_; //Sectors - std::vector slopeB_; //Slope at the lower R - std::vector slopeT_; //Slopes at the larger R - std::vector zFront_; //Starting Z values for the slopes - std::vector rMaxFront_; //Corresponding rMax's - std::string idName_; //Name of the "parent" volume. - std::string idNameSpace_; //Namespace of this and ALL sub-parts - std::unordered_set copies_; //List of copy #'s + private: + std::vector wafer_; // Wafers + std::vector covers_; // Insensitive layers of hexagonal size + std::vector materials_; // Materials + std::vector names_; // Names + std::vector thick_; // Thickness of the material + std::vector copyNumber_; // Initial copy numbers + std::vector layers_; // Number of layers in a section + std::vector layerThick_; // Thickness of each section + std::vector layerType_; // Type of the layer + std::vector layerSense_; // COntent of a layer (sensitive?) + double zMinBlock_; // Starting z-value of the block + double rMaxFine_; // Maximum r-value for fine wafer + double waferW_; // Width of the wafer + double waferGap_; // Gap between 2 wafers + double absorbW_; // Width of the absorber + double absorbH_; // Height of the absorber + int sectors_; // Sectors + std::vector slopeB_; // Slope at the lower R + std::vector slopeT_; // Slopes at the larger R + std::vector zFront_; // Starting Z values for the slopes + std::vector rMaxFront_; // Corresponding rMax's + std::string idName_; // Name of the "parent" volume. + std::string idNameSpace_; // Namespace of this and ALL sub-parts + std::unordered_set copies_; // List of copy #'s }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc index aa828ddf87842..fce4531577c5d 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc @@ -1,60 +1,65 @@ -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h" -//#define EDM_ML_DEBUG +#define EDM_ML_DEBUG using namespace geant_units::operators; -DDHGCalTBModuleX::DDHGCalTBModuleX() : factor_(0.5*sqrt(2.0)), - tan30deg_(tan(30._deg)) { +DDHGCalTBModuleX::DDHGCalTBModuleX() + : factor_(0.5 * sqrt(2.0)), tan30deg_(tan(30._deg)) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX info: Creating instance"; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX info: Creating instance"; #endif } DDHGCalTBModuleX::~DDHGCalTBModuleX() {} -void DDHGCalTBModuleX::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments &vsArgs){ - - wafer_ = vsArgs["WaferName"]; - covers_ = vsArgs["CoverName"]; - genMat_ = sArgs["GeneralMaterial"]; +void DDHGCalTBModuleX::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + wafer_ = vsArgs["WaferName"]; + covers_ = vsArgs["CoverName"]; + genMat_ = sArgs["GeneralMaterial"]; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: Material " << genMat_ - << " with " << wafer_.size() << " wafers"; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: Material " << genMat_ << " with " << wafer_.size() + << " wafers"; unsigned int i(0); for (auto wafer : wafer_) { - edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer; ++i;} - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << covers_.size() - << " covers"; + edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer; + ++i; + } + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << covers_.size() << " covers"; i = 0; for (auto cover : covers_) { - edm::LogVerbatim("HGCalGeom") << "Cover[" << i << "] " << cover; ++i;} + edm::LogVerbatim("HGCalGeom") << "Cover[" << i << "] " << cover; + ++i; + } #endif - materials_ = vsArgs["MaterialNames"]; - names_ = vsArgs["VolumeNames"]; - layerThick_ = vArgs["Thickness"]; - for (unsigned int k=0; k 1) ? ((unsigned int)(layerFrontOut_[0])) : - blockThick_.size()); - for (unsigned int i=0; i 1) { - for (unsigned int i=lastF; i 1) + edm::LogVerbatim("HGCalGeom") + << "Block [" << i << "] of thickness " << blockThick_[i] + << " with inner layers " << layerFrontIn_[i] << ":" + << layerBackIn_[i] << " and outer layers " << layerFrontOut_[i] + << ":" << layerBackOut_[i]; + else + edm::LogVerbatim("HGCalGeom") + << "Block [" << i << "] of thickness " << blockThick_[i] + << " with inner layers " << layerFrontIn_[i] << ":" << layerBackIn_[i]; } #endif - layerType_ = dbl_to_int(vArgs["LayerType"]); - layerSense_ = dbl_to_int(vArgs["LayerSense"]); - maxModule_ = dbl_to_int(vArgs["MaxModule"]); + layerType_ = dbl_to_int(vArgs["LayerType"]); + layerSense_ = dbl_to_int(vArgs["LayerSense"]); + maxModule_ = dbl_to_int(vArgs["MaxModule"]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << layerType_.size() - << " layers"; - for (unsigned int i=0; i> Constructing DDHGCalTBModuleX..."; #endif copies_.clear(); - constructBlocks (parent(), cpv); + constructBlocks(parent(), cpv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << copies_.size() - << " different wafer copy numbers"; + edm::LogVerbatim("HGCalGeom") + << copies_.size() << " different wafer copy numbers"; #endif copies_.clear(); #ifdef EDM_ML_DEBUG @@ -138,233 +141,227 @@ void DDHGCalTBModuleX::execute(DDCompactView& cpv) { #endif } -void DDHGCalTBModuleX::constructBlocks(const DDLogicalPart& parent, - DDCompactView& cpv) { - +void DDHGCalTBModuleX::constructBlocks(const DDLogicalPart& parent, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: Inside constructBlock"; #endif - double zi(zMinBlock_); - for (unsigned int i=0; i 1) - constructLayers(i,layerFrontOut_[i],layerBackOut_[i],-0.5*blockThick_[i], - blockThick_[i],true,glog,cpv); - zi = zo; + constructLayers(i, layerFrontOut_[i], layerBackOut_[i], + -0.5 * blockThick_[i], blockThick_[i], true, glog, cpv); + zi = zo; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: All blocks are " - << "placed in " << zMinBlock_ << ":" << zi; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: All blocks are " << "placed in " << zMinBlock_ + << ":" << zi; #endif } void DDHGCalTBModuleX::constructLayers(int block, int firstLayer, - int lastLayer, double zFront, - double totalWidth, bool ignoreCenter, - const DDLogicalPart& module, - DDCompactView& cpv) { - + int lastLayer, double zFront, + double totalWidth, bool ignoreCenter, + const DDLogicalPart& module, + DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: \t\tInside Block " - << block << " Layers " << firstLayer << ":" - << lastLayer << " zFront " << zFront - << " thickness " << totalWidth - << " ignore Center " << ignoreCenter; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: \t\tInside Block " << block << " Layers " + << firstLayer << ":" << lastLayer << " zFront " << zFront + << " thickness " << totalWidth << " ignore Center " << ignoreCenter; #endif - double zi(zFront), thickTot(0); - for (int ly=firstLayer; ly<=lastLayer; ++ly) { - int ii = layerType_[ly]; - int copy = copyNumber_[ii]; - double zz = zi + (0.5*layerThick_[ii]); - double zo = zi + layerThick_[ii]; - thickTot += layerThick_[ii]; + double zi(zFront), thickTot(0); + for (int ly = firstLayer; ly <= lastLayer; ++ly) { + int ii = layerType_[ly]; + int copy = copyNumber_[ii]; + double zz = zi + (0.5 * layerThick_[ii]); + double zo = zi + layerThick_[ii]; + thickTot += layerThick_[ii]; - std::string name = "HGCal"+names_[ii]+std::to_string(copy); + std::string name = "HGCal" + names_[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name << " Layer " - << ly << ":" << ii << " Z " << zi << ":" - << zo << " Thick " << layerThick_[ii] - << " Sense " << layerSense_[ly]; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << name << " Layer " << ly << ":" << ii + << " Z " << zi << ":" << zo << " Thick " << layerThick_[ii] + << " Sense " << layerSense_[ly]; #endif - DDName matName(DDSplit(materials_[ii]).first, - DDSplit(materials_[ii]).second); + DDName matName(DDSplit(materials_[ii]).first, + DDSplit(materials_[ii]).second); DDMaterial matter(matName); DDLogicalPart glog; if (layerSense_[ly] == 0) { - DDSolid solid = DDSolidFactory::box(DDName(name, idNameSpace_), - absorbW_, absorbH_, - 0.5*layerThick_[ii]); + DDSolid solid = DDSolidFactory::box(DDName(name, idNameSpace_), absorbW_, + absorbH_, 0.5*layerThick_[ii]); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " - << solid.name() << " box of dimension " - << absorbW_ << ":" << absorbH_ - << ":" << 0.5*layerThick_[ii]; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << solid.name() << " box of dimension " + << absorbW_ << ":" << absorbH_ << ":" << 0.5*layerThick_[ii]; #endif - DDTranslation r1(0,0,zz); + DDTranslation r1(0, 0, zz); DDRotation rot; cpv.position(glog, module, copy, r1, rot); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << glog.name() - << " number " << copy - << " positioned in " << module.name() - << " at " << r1 << " with " << rot; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << glog.name() << " number " << copy + << " positioned in " << module.name() << " at " << r1 << " with " + << rot; #endif } else if (layerSense_[ly] > 0) { positionSensitive(zz, copy, layerSense_[ly], rMax_, maxModule_[ly], - ignoreCenter, name, matter, module, cpv); + ignoreCenter, name, matter, module, cpv); } ++copyNumber_[ii]; - zi = zo; - } // End of loop over layers in a block + zi = zo; + } // End of loop over layers in a block - if (fabs(thickTot-totalWidth) < tolerance_) { + if (fabs(thickTot - totalWidth) < tolerance_) { } else if (thickTot > totalWidth) { - edm::LogError("HGCalGeom") << "Thickness of the partition " - << totalWidth << " is smaller than " << thickTot - << ": total thickness of all its components in " - << module.name() << " Layers " << firstLayer - << ":" << lastLayer << ":" << ignoreCenter - << "**** ERROR ****"; + edm::LogError("HGCalGeom") + << "Thickness of the partition " << totalWidth << " is smaller than " + << thickTot << ": total thickness of all its components in " + << module.name() << " Layers " << firstLayer << ":" << lastLayer << ":" + << ignoreCenter << "**** ERROR ****"; } else if (thickTot < totalWidth) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " - << totalWidth << " does not match with " - << thickTot << " of the components in " - << module.name() << " Layers " << firstLayer - << ":" << lastLayer << ":" << ignoreCenter; + edm::LogWarning("HGCalGeom") + << "Thickness of the partition " << totalWidth << " does not match with " + << thickTot << " of the components in " << module.name() << " Layers " + << firstLayer << ":" << lastLayer << ":" << ignoreCenter; } } -void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, - double rout, int ncrMax, - bool ignoreCenter, - const std::string& nameIn, - const DDMaterial& matter, - const DDLogicalPart& glog, - DDCompactView& cpv) { - double ww = (waferW_+waferGap_); - double dx = 0.5*ww; - double dy = 3.0*dx*tan30deg_; - double rr = 2.0*dx*tan30deg_; - int ncol = (int)(2.0*rout/ww) + 1; - int nrow = (int)(rout/(ww*tan30deg_)) + 1; +void DDHGCalTBModuleX::positionSensitive( + double zpos, int copyIn, int type, double rout, int ncrMax, + bool ignoreCenter, const std::string& nameIn, const DDMaterial& matter, + const DDLogicalPart& glog, DDCompactView& cpv) { + double ww = (waferW_ + waferGap_); + double dx = 0.5 * ww; + double dy = 3.0 * dx * tan30deg_; + double rr = 2.0 * dx * tan30deg_; + int ncol = (int)(2.0 * rout / ww) + 1; + int nrow = (int)(rout / (ww * tan30deg_)) + 1; #ifdef EDM_ML_DEBUG - int incm(0), inrm(0); - edm::LogVerbatim("HGCalGeom") << glog.ddname() << " Copy " << copyIn - << " Type " << type << " rout " << rout - << " Row " << nrow << " column " << ncol - << " ncrMax " << ncrMax << " Z " << zpos - << " Center " << ignoreCenter << " name " - << nameIn << " matter " << matter.name(); - int kount(0); + int incm(0), inrm(0); + edm::LogVerbatim("HGCalGeom") + << glog.ddname() << " Copy " << copyIn << " Type " << type << " rout " + << rout << " Row " << nrow << " column " << ncol << " ncrMax " << ncrMax + << " Z " << zpos << " Center " << ignoreCenter << " name " << nameIn + << " matter " << matter.name(); + int kount(0); #endif if (ncrMax >= 0) { - nrow = std::min(nrow,ncrMax); - ncol = std::min(ncol,ncrMax); + nrow = std::min(nrow, ncrMax); + ncol = std::min(ncol, ncrMax); } - for (int nr=-nrow; nr <= nrow; ++nr) { + for (int nr = -nrow; nr <= nrow; ++nr) { int inr = std::abs(nr); - for (int nc=-ncol; nc <= ncol; ++nc) { + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = std::abs(nc); - if ((inr%2 == inc%2) && (!ignoreCenter || nc != 0 || nr != 0)) { - double xpos = nc*dx; - double ypos = nr*dy; - double xc[6], yc[6]; - xc[0] = xpos+dx; yc[0] = ypos-0.5*rr; - xc[1] = xpos+dx; yc[1] = ypos+0.5*rr; - xc[2] = xpos; yc[2] = ypos+rr; - xc[3] = xpos-dx; yc[3] = ypos+0.5*rr; - xc[4] = xpos+dx; yc[4] = ypos-0.5*rr; - xc[5] = xpos; yc[5] = ypos-rr; + if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 || nr != 0)) { + double xpos = nc * dx; + double ypos = nr * dy; + double xc[6], yc[6]; + xc[0] = xpos + dx; + yc[0] = ypos - 0.5 * rr; + xc[1] = xpos + dx; + yc[1] = ypos + 0.5 * rr; + xc[2] = xpos; + yc[2] = ypos + rr; + xc[3] = xpos - dx; + yc[3] = ypos + 0.5 * rr; + xc[4] = xpos + dx; + yc[4] = ypos - 0.5 * rr; + xc[5] = xpos; + yc[5] = ypos - rr; bool cornerAll(true); - for (int k=0; k<6; ++k) { - double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]); - if (rpos > rout) cornerAll = false; - } - if (cornerAll) { - double rpos = std::sqrt(xpos*xpos+ypos*ypos); - DDTranslation tran(xpos, ypos, zpos); - DDRotation rotation; - int copy = inr*100 + inc; - if (nc < 0) copy += 10000; - if (nr < 0) copy += 100000; - DDName name, nameX; - if (type == 1) { - nameX = DDName(DDSplit(covers_[0]).first, - DDSplit(covers_[0]).second); - std::string name0 = nameIn + "M" + std::to_string(copy); - DDLogicalPart glog1 = DDLogicalPart(DDName(name0, idNameSpace_), - matter, nameX); - cpv.position(glog1.ddname(),glog.ddname(),copyIn,tran,rotation); + for (int k = 0; k < 6; ++k) { + double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]); + if (rpos > rout) cornerAll = false; + } + if (cornerAll) { + double rpos = std::sqrt(xpos * xpos + ypos * ypos); + DDTranslation tran(xpos, ypos, zpos); + DDRotation rotation; + int copy = inr * 100 + inc; + if (nc < 0) copy += 10000; + if (nr < 0) copy += 100000; + DDName name, nameX; + if (type == 1) { + nameX = + DDName(DDSplit(covers_[0]).first, DDSplit(covers_[0]).second); + std::string name0 = nameIn + "M" + std::to_string(copy); + DDLogicalPart glog1 = + DDLogicalPart(DDName(name0, idNameSpace_), matter, nameX); + cpv.position(glog1.ddname(), glog.ddname(), copyIn, tran, rotation); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " - << glog1.ddname() << " number " - << copyIn << " positioned in " - << glog.ddname() << " at " << tran - << " with " << rotation; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << glog1.ddname() << " number " + << copyIn << " positioned in " << glog.ddname() << " at " + << tran << " with " << rotation; #endif - name = (rpos < rMaxFine_) ? - DDName(DDSplit(wafer_[0]).first, DDSplit(wafer_[0]).second) : - DDName(DDSplit(wafer_[1]).first, DDSplit(wafer_[1]).second); - DDTranslation tran1; - cpv.position(name, glog1.ddname(), copy, tran1, rotation); + name = (rpos < rMaxFine_) ? DDName(DDSplit(wafer_[0]).first, + DDSplit(wafer_[0]).second) + : DDName(DDSplit(wafer_[1]).first, + DDSplit(wafer_[1]).second); + DDTranslation tran1; + cpv.position(name, glog1.ddname(), copy, tran1, rotation); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name - << " number " << copy - << " positioned in " - << glog1.ddname() << " at " << tran1 - << " with " << rotation; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << name << " number " << copy + << " positioned in " << glog1.ddname() << " at " << tran1 + << " with " << rotation; #endif - if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); - } else { - name = DDName(DDSplit(covers_[type-1]).first, - DDSplit(covers_[type-1]).second); - copy += copyIn*1000000; - cpv.position(name, glog.ddname(), copy, tran, rotation); + if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); + } else { + name = DDName(DDSplit(covers_[type - 1]).first, + DDSplit(covers_[type - 1]).second); + copy += copyIn * 1000000; + cpv.position(name, glog.ddname(), copy, tran, rotation); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name - << " number " << copy - << " positioned in " - << glog.ddname() << " at " << tran - << " with " << rotation; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation; #endif - } + } #ifdef EDM_ML_DEBUG - if (inc > incm) incm = inc; - if (inr > inrm) inrm = inr; - kount++; + if (inc > incm) incm = inc; + if (inr > inrm) inrm = inr; + kount++; #endif - } + } } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: # of columns " << incm - << " # of rows " << inrm << " and " << kount - << " wafers for " << glog.ddname(); + edm::LogVerbatim("HGCalGeom") + << "DDHGCalTBModuleX: # of columns " << incm << " # of rows " << inrm + << " and " << kount << " wafers for " << glog.ddname(); #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h index c6c28c9292e92..0cb06b0266891 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h @@ -2,70 +2,66 @@ #define HGCalCommonData_DDHGCalTBModuleX_h #include +#include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" -#include +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalTBModuleX : public DDAlgorithm { - -public: - //Constructor and Destructor - DDHGCalTBModuleX(); // + public: + // Constructor and Destructor + DDHGCalTBModuleX(); // ~DDHGCalTBModuleX() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; - -protected: - void constructBlocks (const DDLogicalPart&, DDCompactView& cpv); - void constructLayers (int block, int layerFront, int layerBack, - double zFront, double thick, bool ignore, - const DDLogicalPart&, DDCompactView&); - void positionSensitive(double zpos, int copyIn, int type, - double rmax, int ncrMax, bool ignoreCenter, - const std::string&, const DDMaterial&, - const DDLogicalPart&, DDCompactView& cpv); + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; -private: + protected: + void constructBlocks(const DDLogicalPart&, DDCompactView& cpv); + void constructLayers(int block, int layerFront, int layerBack, double zFront, + double thick, bool ignore, const DDLogicalPart&, + DDCompactView&); + void positionSensitive(double zpos, int copyIn, int type, double rmax, + int ncrMax, bool ignoreCenter, const std::string&, + const DDMaterial&, const DDLogicalPart&, + DDCompactView& cpv); + private: static constexpr double tolerance_ = 0.00001; const double factor_, tan30deg_; - std::vector wafer_; //Wafers - std::vector covers_; //Insensitive layers of hexagonal size - std::string genMat_; //General material used for blocks - std::vector materials_; //Material names in each layer - std::vector names_; //Names of each layer - std::vector layerThick_; //Thickness of the material - std::vector copyNumber_; //Copy numbers (initiated to 1) - std::vector blockThick_; //Thickness of each section - int inOut_; //Number of inner+outer parts - std::vector layerFrontIn_; //First layer index (inner) in block - std::vector layerBackIn_; //Last layer index (inner) in block - std::vector layerFrontOut_;//First layer index (outner) in block - std::vector layerBackOut_; //Last layer index (outner) in block - std::vector layerType_; //Type of the layer - std::vector layerSense_; //Content of a layer - std::vector maxModule_; //Maximum # of row/column - double zMinBlock_; //Starting z-value of the block - double rMaxFine_; //Maximum r-value for fine wafer - double waferW_; //Width of the wafer - double waferGap_; //Gap between 2 wafers - double absorbW_; //Width of the absorber - double absorbH_; //Height of the absorber - double rMax_; //Maximum radial extent - double rMaxB_; //Maximum radial extent of a block - std::string idName_; //Name of the "parent" volume. - std::string idNameSpace_; //Namespace of this and ALL sub-parts - std::unordered_set copies_; //List of copy #'s + std::vector wafer_; // Wafers + std::vector covers_; // Insensitive layers of hexagonal size + std::string genMat_; // General material used for blocks + std::vector materials_; // Material names in each layer + std::vector names_; // Names of each layer + std::vector layerThick_; // Thickness of the material + std::vector copyNumber_; // Copy numbers (initiated to 1) + std::vector blockThick_; // Thickness of each section + int inOut_; // Number of inner+outer parts + std::vector layerFrontIn_; // First layer index (inner) in block + std::vector layerBackIn_; // Last layer index (inner) in block + std::vector layerFrontOut_; // First layer index (outner) in block + std::vector layerBackOut_; // Last layer index (outner) in block + std::vector layerType_; // Type of the layer + std::vector layerSense_; // Content of a layer + std::vector maxModule_; // Maximum # of row/column + double zMinBlock_; // Starting z-value of the block + double rMaxFine_; // Maximum r-value for fine wafer + double waferW_; // Width of the wafer + double waferGap_; // Gap between 2 wafers + double absorbW_; // Width of the absorber + double absorbH_; // Height of the absorber + double rMax_; // Maximum radial extent + double rMaxB_; // Maximum radial extent of a block + std::string idName_; // Name of the "parent" volume. + std::string idNameSpace_; // Namespace of this and ALL sub-parts + std::unordered_set copies_; // List of copy #'s }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc index 35cad1407bccc..ceb546c9f8e9b 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc @@ -1,13 +1,13 @@ -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalWafer.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG @@ -19,89 +19,89 @@ DDHGCalWafer::DDHGCalWafer() { DDHGCalWafer::~DDHGCalWafer() {} -void DDHGCalWafer::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) { - - waferSize_ = nArgs["WaferSize"]; - cellType_ = (int)(nArgs["CellType"]); - nColumns_ = (int)(nArgs["NColumns"]); - nBottomY_ = (int)(nArgs["NBottomY"]); - childNames_ = vsArgs["ChildNames"]; - nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]); +void DDHGCalWafer::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + waferSize_ = nArgs["WaferSize"]; + cellType_ = (int)(nArgs["CellType"]); + nColumns_ = (int)(nArgs["NColumns"]); + nBottomY_ = (int)(nArgs["NBottomY"]); + childNames_ = vsArgs["ChildNames"]; + nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]); angleEdges_ = dbl_to_int(vArgs["AngleEdges"]); - detectorType_= dbl_to_int(vArgs["DetectorType"]); + detectorType_ = dbl_to_int(vArgs["DetectorType"]); idNameSpace_ = DDCurrentNamespace::ns(); - parentName_ = parent().name(); + parentName_ = parent().name(); #ifdef EDM_ML_DEBUG std::cout << childNames_.size() << " children: " << childNames_[0] << "; " - << childNames_[1] << " in namespace " << idNameSpace_ - << " positioned in " << nCellsRow_.size() << " rows and " - << nColumns_ << " columns with lowest column at " << nBottomY_ - << " in mother " << parentName_ << " of size " << waferSize_ - << std::endl; - for (unsigned int k=0; k> Constructing DDHGCalWafer..."; #endif - double dx = 0.5*waferSize_/nColumns_; - double dy = 0.5*dx*tan(30.0*CLHEP::deg); - int ny = nBottomY_; - int kount(0); + double dx = 0.5 * waferSize_ / nColumns_; + double dy = 0.5 * dx * tan(30.0 * CLHEP::deg); + int ny = nBottomY_; + int kount(0); - for (unsigned int ir=0; ir=0 && irot < 100) rotstr = "R0"; - else rotstr = "R"; - rotstr = rotstr + std::to_string(irot); - rot = DDRotation(DDName(rotstr, idNameSpace_)); - if (!rot) { + if (irot >= 0 && irot < 100) + rotstr = "R0"; + else + rotstr = "R"; + rotstr = rotstr + std::to_string(irot); + rot = DDRotation(DDName(rotstr, idNameSpace_)); + if (!rot) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: Creating new rotation " - << DDName(rotstr, idNameSpace_) << "\t90, " << irot - << ", 90, " << (irot+90) << ", 0, 0" << std::endl; + std::cout << "DDHGCalWaferAlgo: Creating new rotation " + << DDName(rotstr, idNameSpace_) << "\t90, " << irot + << ", 90, " << (irot + 90) << ", 0, 0" << std::endl; #endif - rot = DDrot(DDName(rotstr, idNameSpace_), 90*CLHEP::deg, - irot*CLHEP::deg, 90*CLHEP::deg, (90+irot)*CLHEP::deg, - 0*CLHEP::deg,0*CLHEP::deg); - } + rot = DDrot(DDName(rotstr, idNameSpace_), 90 * CLHEP::deg, + irot * CLHEP::deg, 90 * CLHEP::deg, + (90 + irot) * CLHEP::deg, 0 * CLHEP::deg, 0 * CLHEP::deg); + } } - double xpos = dx*nx; - nx += 2; + double xpos = dx * nx; + nx += 2; DDTranslation tran(xpos, ypos, 0); - int copy = cellType_*1000+kount; - cpv.position(DDName(name,idNameSpace_), parentName_, copy, tran, rot); + int copy = cellType_ * 1000 + kount; + cpv.position(DDName(name, idNameSpace_), parentName_, copy, tran, rot); ++kount; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWafer: " << DDName(name,idNameSpace_) << " number " - << copy << " positioned in " << parentName_ << " at " << tran - << " with " << rot << std::endl; + std::cout << "DDHGCalWafer: " << DDName(name, idNameSpace_) << " number " + << copy << " positioned in " << parentName_ << " at " << tran + << " with " << rot << std::endl; #endif } - ny += 6; + ny += 6; } } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.h b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.h index d5ec3a280a8b9..c2f7317949206 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.h @@ -4,35 +4,32 @@ #include #include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalWafer : public DDAlgorithm { - -public: - //Constructor and Destructor + public: + // Constructor and Destructor DDHGCalWafer(); ~DDHGCalWafer() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; -private: + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; - double waferSize_; //Wafer Size - int cellType_; //Type (1 fine; 2 coarse) - int nColumns_; //Maximum number of columns - int nBottomY_; //Index of cell position of bottom row - std::vector childNames_; //Names of children - std::vector nCellsRow_; //Number of cells in a row - std::vector angleEdges_; //Rotation angles to be used for edges - std::vector detectorType_; //Detector type of edge cells - std::string idNameSpace_; //Namespace of this and ALL sub-parts - DDName parentName_; //Parent name + private: + double waferSize_; // Wafer Size + int cellType_; // Type (1 fine; 2 coarse) + int nColumns_; // Maximum number of columns + int nBottomY_; // Index of cell position of bottom row + std::vector childNames_; // Names of children + std::vector nCellsRow_; // Number of cells in a row + std::vector angleEdges_; // Rotation angles to be used for edges + std::vector detectorType_; // Detector type of edge cells + std::string idNameSpace_; // Namespace of this and ALL sub-parts + DDName parentName_; // Parent name }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc index f138c417552b9..84a47eb05ff13 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc @@ -1,12 +1,12 @@ -#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer8.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "DetectorDescription/Core/interface/DDutils.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer8.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" //#define EDM_ML_DEBUG @@ -18,103 +18,107 @@ DDHGCalWafer8::DDHGCalWafer8() { DDHGCalWafer8::~DDHGCalWafer8() {} -void DDHGCalWafer8::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments &, - const DDMapArguments &, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) { - - waferSize_ = nArgs["WaferSize"]; - waferT_ = nArgs["WaferThick"]; - waferSepar_ = nArgs["SensorSeparation"]; - mouseBite_ = nArgs["MouseBite"]; - nCells_ = (int)(nArgs["NCells"]); - cellType_ = (int)(nArgs["CellType"]); - material_ = sArgs["Material"]; - cellNames_ = vsArgs["CellNames"]; - nameSpace_ = DDCurrentNamespace::ns(); +void DDHGCalWafer8::initialize(const DDNumericArguments &nArgs, + const DDVectorArguments &, + const DDMapArguments &, + const DDStringArguments &sArgs, + const DDStringVectorArguments &vsArgs) { + waferSize_ = nArgs["WaferSize"]; + waferT_ = nArgs["WaferThick"]; + waferSepar_ = nArgs["SensorSeparation"]; + mouseBite_ = nArgs["MouseBite"]; + nCells_ = (int)(nArgs["NCells"]); + cellType_ = (int)(nArgs["CellType"]); + material_ = sArgs["Material"]; + cellNames_ = vsArgs["CellNames"]; + nameSpace_ = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: Wafer 2r " << waferSize_ - << " T " << waferT_ << " Half Separation " - << waferSepar_ << " Mouse bite radius " - << mouseBite_ << " Cells/Wafer " << nCells_ - << " Cell Type " << cellType_ - << " Material " << material_ << " Names " - << parent().name() << " NameSpace " - << nameSpace_ << " # of cells " - << cellNames_.size(); - for (unsigned int k=0; k> Executing DDHGCalWafer8..."; #endif static const double sqrt3 = std::sqrt(3.0); - double rM = 0.5*(waferSize_ + waferSepar_); - double RM2 = rM/sqrt3; - double R = waferSize_/(3.0*nCells_); - double r = 0.5*R*sqrt3; + double rM = 0.5 * (waferSize_ + waferSepar_); + double RM2 = rM / sqrt3; + double R = waferSize_ / (3.0 * nCells_); + double r = 0.5 * R * sqrt3; // First the full cell - std::vector xM = {rM,0,-rM,-rM,0,rM}; - std::vector yM = {RM2,2*RM2,RM2,-RM2,-2*RM2,-RM2}; - std::vector zw = {-0.5*waferT_,0.5*waferT_}; - std::vector zx(2,0), zy(2,0), scale(2,1.0); - DDName parentName = parent().name(); - DDSolid solid = DDSolidFactory::extrudedpolygon(parentName, - xM, yM, zw, zx, zy, scale); + std::vector xM = {rM, 0, -rM, -rM, 0, rM}; + std::vector yM = {RM2, 2 * RM2, RM2, -RM2, -2 * RM2, -RM2}; + std::vector zw = {-0.5 * waferT_, 0.5 * waferT_}; + std::vector zx(2, 0), zy(2, 0), scale(2, 1.0); + DDName parentName = parent().name(); + DDSolid solid = + DDSolidFactory::extrudedpolygon(parentName, xM, yM, zw, zx, zy, scale); DDName matName(DDSplit(material_).first, DDSplit(material_).second); DDMaterial matter(matName); DDLogicalPart glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: " << solid.name() - << " extruded polygon made of " << matName - << " z|x|y|s (0) " << zw[0] << ":" << zx[0] - << ":" << zy[0] << ":" << scale[0] - << " z|x|y|s (1) " << zw[1] << ":" << zx[1] - << ":" << zy[1] << ":" << scale[1] << " and " - << xM.size() << " edges"; - for (unsigned int k=0; k #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalWafer8 : public DDAlgorithm { - -public: - //Constructor and Destructor + public: + // Constructor and Destructor DDHGCalWafer8(); ~DDHGCalWafer8() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; + + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; void execute(DDCompactView& cpv) override; -private: - double waferSize_; // Wafer size - double waferT_; // Wafer thickness - double waferSepar_; // Sensor separation - double mouseBite_; // MouseBite radius - int nCells_; // Half number of cells along u-v axis - int cellType_; // Cell Type (0,1,2: Fine, Course 2/3) - std::string material_; // Material name for module with gap + private: + double waferSize_; // Wafer size + double waferT_; // Wafer thickness + double waferSepar_; // Sensor separation + double mouseBite_; // MouseBite radius + int nCells_; // Half number of cells along u-v axis + int cellType_; // Cell Type (0,1,2: Fine, Course 2/3) + std::string material_; // Material name for module with gap std::vector cellNames_; // Name of the cells - std::string nameSpace_; // Namespace to be used + std::string nameSpace_; // Namespace to be used }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc index ff202e5288e20..a1e73c0fa8b18 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc @@ -1,17 +1,17 @@ /////////////////////////////////////////////////////////////////////////////// // File: DDHGCalWaferAlgo.cc -// Description: Position inside the mother according to (eta,phi) +// Description: Position inside the mother according to (eta,phi) /////////////////////////////////////////////////////////////////////////////// -#include #include +#include -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG @@ -23,74 +23,75 @@ DDHGCalWaferAlgo::DDHGCalWaferAlgo() { DDHGCalWaferAlgo::~DDHGCalWaferAlgo() {} -void DDHGCalWaferAlgo::initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & , - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) { - - cellSize = nArgs["CellSize"]; - cellType = (int)(nArgs["CellType"]); - childNames = vsArgs["ChildNames"]; - positionX = dbl_to_int(vArgs["PositionX"]); - positionY = dbl_to_int(vArgs["PositionY"]); - angles = vArgs["Angles"]; - detectorType= dbl_to_int(vArgs["DetectorType"]); +void DDHGCalWaferAlgo::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) { + cellSize = nArgs["CellSize"]; + cellType = (int)(nArgs["CellType"]); + childNames = vsArgs["ChildNames"]; + positionX = dbl_to_int(vArgs["PositionX"]); + positionY = dbl_to_int(vArgs["PositionY"]); + angles = vArgs["Angles"]; + detectorType = dbl_to_int(vArgs["DetectorType"]); #ifdef EDM_ML_DEBUG std::cout << childNames.size() << " children: " << childNames[0] << "; " - << childNames[1] << " positioned " << positionX.size() - << " times with cell size " << cellSize << std::endl; - for (unsigned int k=0; k> Constructing DDHGCalWaferAlgo..."; #endif - double dx = 0.5*cellSize; - double dy = 0.5*dx*tan(30.0*CLHEP::deg); + double dx = 0.5 * cellSize; + double dy = 0.5 * dx * tan(30.0 * CLHEP::deg); - for (unsigned int k=0; k=0 && angles[k] < 100) rotstr = "R0"; - else rotstr = "R"; + if (angles[k] >= 0 && angles[k] < 100) + rotstr = "R0"; + else + rotstr = "R"; rotstr = rotstr + std::to_string(angles[k]); - rotation = DDRotation(DDName(rotstr, rotns)); + rotation = DDRotation(DDName(rotstr, rotns)); if (!rotation) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: Creating new rotation " - << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, " - << (angles[k]+90) << ", 0, 0" << std::endl; + std::cout << "DDHGCalWaferAlgo: Creating new rotation " + << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, " + << (angles[k] + 90) << ", 0, 0" << std::endl; #endif - rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg, - angles[k]*CLHEP::deg, 90*CLHEP::deg, - (90+angles[k])*CLHEP::deg, 0*CLHEP::deg,0*CLHEP::deg); + rotation = DDrot(DDName(rotstr, rotns), 90 * CLHEP::deg, + angles[k] * CLHEP::deg, 90 * CLHEP::deg, + (90 + angles[k]) * CLHEP::deg, 0 * CLHEP::deg, + 0 * CLHEP::deg); } } - double xpos = dx*positionX[k]; - double ypos = dy*positionY[k]; + double xpos = dx * positionX[k]; + double ypos = dy * positionY[k]; DDTranslation tran(xpos, ypos, 0); - int copy = cellType*1000+k; - cpv.position(DDName(name,idNameSpace), parentName, copy, tran, rotation); + int copy = cellType * 1000 + k; + cpv.position(DDName(name, idNameSpace), parentName, copy, tran, rotation); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: " << DDName(name,idNameSpace) << " number " - << copy << " positioned in " << parentName << " at " << tran - << " with " << rotation << std::endl; + std::cout << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace) << " number " + << copy << " positioned in " << parentName << " at " << tran + << " with " << rotation << std::endl; #endif } } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h index 23498721b784c..77bb6a3b576ad 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h @@ -4,36 +4,33 @@ #include #include #include -#include "DetectorDescription/Core/interface/DDTypes.h" #include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDTypes.h" class DDHGCalWaferAlgo : public DDAlgorithm { - -public: - //Constructor and Destructor + public: + // Constructor and Destructor DDHGCalWaferAlgo(); ~DDHGCalWaferAlgo() override; - - void initialize(const DDNumericArguments & nArgs, - const DDVectorArguments & vArgs, - const DDMapArguments & mArgs, - const DDStringArguments & sArgs, - const DDStringVectorArguments & vsArgs) override; - void execute(DDCompactView& cpv) override; -private: + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + void execute(DDCompactView& cpv) override; - double cellSize; //Cell Size - int cellType; //Type (1 fine; 2 coarse) - std::vector childNames; //Names of children - std::vector positionX; //Position in X - std::vector positionY; //Position in Y - std::vector angles; //Rotation angle - std::vector detectorType; //Detector type - std::string idName; //Name of the "parent" volume. - std::string rotns; //Namespace for rotation matrix - std::string idNameSpace; //Namespace of this and ALL sub-parts - DDName parentName; //Parent name + private: + double cellSize; // Cell Size + int cellType; // Type (1 fine; 2 coarse) + std::vector childNames; // Names of children + std::vector positionX; // Position in X + std::vector positionY; // Position in Y + std::vector angles; // Rotation angle + std::vector detectorType; // Detector type + std::string idName; // Name of the "parent" volume. + std::string rotns; // Namespace for rotation matrix + std::string idNameSpace; // Namespace of this and ALL sub-parts + DDName parentName; // Parent name }; #endif diff --git a/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc b/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc index cbb348b0e9251..b159d69388059 100644 --- a/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc +++ b/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc @@ -2,8 +2,9 @@ // // Package: FastTimeNumberingInitialization // Class: FastTimeNumberingInitialization -// -/**\class FastTimeNumberingInitialization FastTimeNumberingInitialization.h Geometry/HGCalCommonData/interface/FastTimeNumberingInitialization.h +// +/**\class FastTimeNumberingInitialization FastTimeNumberingInitialization.h + Geometry/HGCalCommonData/interface/FastTimeNumberingInitialization.h Description: @@ -13,7 +14,8 @@ // // Original Author: Sunanda Banerjee // Created: Tue Mar 21 16:40:29 PDT 2013 -// $Id: FastTimeNumberingInitialization.cc,v 1.0 2014/04/24 12:47:41 sunanda Exp $ +// $Id: FastTimeNumberingInitialization.cc,v 1.0 2014/04/24 12:47:41 sunanda Exp +// $ // // @@ -21,24 +23,23 @@ #include // user include files -#include #include #include -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include #include #include -#include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" #include #include +#include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" //#define EDM_ML_DEBUG class FastTimeNumberingInitialization : public edm::ESProducer { - -public: + public: FastTimeNumberingInitialization(const edm::ParameterSet&); ~FastTimeNumberingInitialization() override; @@ -47,27 +48,26 @@ class FastTimeNumberingInitialization : public edm::ESProducer { ReturnType produce(const IdealGeometryRecord&); }; -FastTimeNumberingInitialization::FastTimeNumberingInitialization(const edm::ParameterSet&) { +FastTimeNumberingInitialization::FastTimeNumberingInitialization( + const edm::ParameterSet&) { #ifdef EDM_ML_DEBUG - std::cout <<"constructing FastTimeNumberingInitialization" << std::endl; + std::cout << "constructing FastTimeNumberingInitialization" << std::endl; #endif setWhatProduced(this); } FastTimeNumberingInitialization::~FastTimeNumberingInitialization() {} - // ------------ method called to produce the data ------------ FastTimeNumberingInitialization::ReturnType FastTimeNumberingInitialization::produce(const IdealGeometryRecord& iRecord) { #ifdef EDM_ML_DEBUG std::cout << "in FastTimeNumberingInitialization::produce" << std::endl; #endif - edm::ESHandle pFTpar; + edm::ESHandle pFTpar; iRecord.get(pFTpar); return std::make_unique(&(*pFTpar)); } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_EVENTSETUP_MODULE(FastTimeNumberingInitialization); - diff --git a/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc b/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc index 2e6a2ff3ed561..fd6def4ada5d4 100644 --- a/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc +++ b/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc @@ -1,42 +1,42 @@ -#include "FWCore/Framework/interface/ModuleFactory.h" +#include "DetectorDescription/Core/interface/DDCompactView.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" -#include "DetectorDescription/Core/interface/DDCompactView.h" -#include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" #include //#define EDM_ML_DEBUG -class FastTimeParametersESModule : public edm::ESProducer { -public: - FastTimeParametersESModule(const edm::ParameterSet &); +class FastTimeParametersESModule : public edm::ESProducer { + public: + FastTimeParametersESModule(const edm::ParameterSet&); ~FastTimeParametersESModule(void) override; - + using ReturnType = std::unique_ptr; - static void fillDescriptions( edm::ConfigurationDescriptions & ) { } - + static void fillDescriptions(edm::ConfigurationDescriptions&) {} + ReturnType produce(const IdealGeometryRecord&); -private: + private: std::vector name_; - std::vector type_; + std::vector type_; }; -FastTimeParametersESModule::FastTimeParametersESModule(const edm::ParameterSet& iC) { - - name_ = iC.getUntrackedParameter >("Names"); - type_ = iC.getUntrackedParameter >("Types"); - edm::LogInfo("HGCalGeom") << "FastTimeParametersESModule for " - << name_.size() << " types"; +FastTimeParametersESModule::FastTimeParametersESModule( + const edm::ParameterSet& iC) { + name_ = iC.getUntrackedParameter >("Names"); + type_ = iC.getUntrackedParameter >("Types"); + edm::LogInfo("HGCalGeom") + << "FastTimeParametersESModule for " << name_.size() << " types"; #ifdef EDM_ML_DEBUG std::cout << "FastTimeParametersESModule for " << name_.size() << " types:"; - for (unsigned int k=0; k cpv; iRecord.get(cpv); - + auto ptp = std::make_unique(); FastTimeParametersFromDD builder; - for (unsigned int k=0; knPhiBarrel_ << " Geometry parameters = ( "; - for (unsigned k=0; kgeomParBarrel_.size(); ++k) + std::cout << "FastTimeParametersESModule:: Barrel Parameters: " + << " number of cells along z|phi = " << ptp->nZBarrel_ << "|" + << ptp->nPhiBarrel_ << " Geometry parameters = ( "; + for (unsigned k = 0; k < ptp->geomParBarrel_.size(); ++k) std::cout << "[" << k << "] " << ptp->geomParBarrel_[k] << " "; std::cout << ")" << std::endl; - std::cout << "FastTimeParametersESModule:: Endcap Parameters: " - << " number of cells along eta|phi = " << ptp->nEtaEndcap_ << "|" - << ptp->nPhiEndcap_ << " Geometry parameters = ( "; - for (unsigned k=0; kgeomParEndcap_.size(); ++k) + std::cout << "FastTimeParametersESModule:: Endcap Parameters: " + << " number of cells along eta|phi = " << ptp->nEtaEndcap_ << "|" + << ptp->nPhiEndcap_ << " Geometry parameters = ( "; + for (unsigned k = 0; k < ptp->geomParEndcap_.size(); ++k) std::cout << "[" << k << "] " << ptp->geomParEndcap_[k] << " "; std::cout << ")" << std::endl; #endif return ptp; } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_EVENTSETUP_MODULE(FastTimeParametersESModule); diff --git a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc index 3a2a8dfdfc62c..adb50e42959eb 100644 --- a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc +++ b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc @@ -2,8 +2,9 @@ // // Package: HGCalNumberingInitialization // Class: HGCalNumberingInitialization -// -/**\class HGCalNumberingInitialization HGCalNumberingInitialization.h Geometry/HGCalCommonData/interface/HGCalNumberingInitialization.h +// +/**\class HGCalNumberingInitialization HGCalNumberingInitialization.h + Geometry/HGCalCommonData/interface/HGCalNumberingInitialization.h Description: @@ -15,26 +16,24 @@ // Created: Tue Mar 21 16:40:29 PDT 2013 // - // system include files #include // user include files -#include "FWCore/Framework/interface/ModuleFactory.h" -#include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" //#define EDM_ML_DEBUG class HGCalNumberingInitialization : public edm::ESProducer { - -public: + public: HGCalNumberingInitialization(const edm::ParameterSet&); ~HGCalNumberingInitialization() override; @@ -42,13 +41,14 @@ class HGCalNumberingInitialization : public edm::ESProducer { ReturnType produce(const IdealGeometryRecord&); -private: + private: HGCalDDDConstants* hgcalDDDConst_; - std::string name_; + std::string name_; }; -HGCalNumberingInitialization::HGCalNumberingInitialization(const edm::ParameterSet& iConfig) : hgcalDDDConst_(nullptr) { - +HGCalNumberingInitialization::HGCalNumberingInitialization( + const edm::ParameterSet& iConfig) + : hgcalDDDConst_(nullptr) { name_ = iConfig.getUntrackedParameter("Name"); edm::LogInfo("HGCalGeom") << "HGCalNumberingInitialization for " << name_; #ifdef EDM_ML_DEBUG @@ -59,20 +59,17 @@ HGCalNumberingInitialization::HGCalNumberingInitialization(const edm::ParameterS HGCalNumberingInitialization::~HGCalNumberingInitialization() {} - // ------------ method called to produce the data ------------ -HGCalNumberingInitialization::ReturnType -HGCalNumberingInitialization::produce(const IdealGeometryRecord& iRecord) { - +HGCalNumberingInitialization::ReturnType HGCalNumberingInitialization::produce( + const IdealGeometryRecord& iRecord) { edm::LogInfo("HGCalGeom") << "in HGCalNumberingInitialization::produce"; if (hgcalDDDConst_ == nullptr) { - edm::ESHandle pHGpar; + edm::ESHandle pHGpar; iRecord.get(name_, pHGpar); hgcalDDDConst_ = new HGCalDDDConstants(&(*pHGpar), name_); } - return ReturnType(hgcalDDDConst_) ; + return ReturnType(hgcalDDDConst_); } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_EVENTSETUP_MODULE(HGCalNumberingInitialization); - diff --git a/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc b/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc index 0dd940896e596..f4eed9deef8bd 100644 --- a/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc +++ b/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc @@ -1,60 +1,59 @@ -#include "FWCore/Framework/interface/ModuleFactory.h" +#include "DetectorDescription/Core/interface/DDCompactView.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "DetectorDescription/Core/interface/DDCompactView.h" -#include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" #include //#define EDM_ML_DEBUG -class HGCalParametersESModule : public edm::ESProducer { -public: - HGCalParametersESModule( const edm::ParameterSet & ); - ~HGCalParametersESModule( void ) override; - +class HGCalParametersESModule : public edm::ESProducer { + public: + HGCalParametersESModule(const edm::ParameterSet&); + ~HGCalParametersESModule(void) override; + using ReturnType = std::unique_ptr; - - ReturnType produce( const IdealGeometryRecord&); -private: - std::string name_, namew_, namec_, namet_; + ReturnType produce(const IdealGeometryRecord&); + + private: + std::string name_, namew_, namec_, namet_; }; HGCalParametersESModule::HGCalParametersESModule(const edm::ParameterSet& iC) { - - name_ = iC.getUntrackedParameter("Name"); + name_ = iC.getUntrackedParameter("Name"); namew_ = iC.getUntrackedParameter("NameW"); namec_ = iC.getUntrackedParameter("NameC"); namet_ = iC.getUntrackedParameter("NameT"); edm::LogInfo("HGCalGeom") << "HGCalParametersESModule for " << name_ << ":" - << namew_ << ":" << namec_ << ":" << namet_; + << namew_ << ":" << namec_ << ":" << namet_; #ifdef EDM_ML_DEBUG - std::cout << "HGCalParametersESModule for " << name_ << ":" << namew_ << ":" - << namec_ << ":" << namet_ << std::endl; + std::cout << "HGCalParametersESModule for " << name_ << ":" << namew_ << ":" + << namec_ << ":" << namet_ << std::endl; #endif setWhatProduced(this, name_); } HGCalParametersESModule::~HGCalParametersESModule() {} -HGCalParametersESModule::ReturnType -HGCalParametersESModule::produce(const IdealGeometryRecord& iRecord) { +HGCalParametersESModule::ReturnType HGCalParametersESModule::produce( + const IdealGeometryRecord& iRecord) { edm::LogInfo("HGCalGeom") - << "HGCalParametersESModule::produce(const IdealGeometryRecord& iRecord)"; + << "HGCalParametersESModule::produce(const IdealGeometryRecord& iRecord)"; edm::ESTransientHandle cpv; iRecord.get(cpv); auto ptp = std::make_unique(name_); HGCalParametersFromDD builder; builder.build(&(*cpv), *ptp, name_, namew_, namec_, namet_); - + return ptp; } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_EVENTSETUP_MODULE(HGCalParametersESModule); diff --git a/Geometry/HGCalCommonData/plugins/module.cc b/Geometry/HGCalCommonData/plugins/module.cc index 56883f4d45cf4..2f7274396ba7a 100644 --- a/Geometry/HGCalCommonData/plugins/module.cc +++ b/Geometry/HGCalCommonData/plugins/module.cc @@ -1,26 +1,31 @@ +#include "DetectorDescription/Core/interface/DDAlgorithmFactory.h" +#include "Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalCell.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalCell.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer8.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalModule.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h" -#include "Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h" -#include "Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h" -#include "DetectorDescription/Core/interface/DDAlgorithmFactory.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalWafer8.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h" -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalEEAlgo, "hgcal:DDHGCalEEAlgo"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalHEAlgo, "hgcal:DDHGCalHEAlgo"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalCell, "hgcal:DDHGCalCell"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalWaferAlgo, "hgcal:DDHGCalWaferAlgo"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalWafer, "hgcal:DDHGCalWafer"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalWafer8, "hgcal:DDHGCalWafer8"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalModule, "hgcal:DDHGCalModule"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalModuleAlgo, "hgcal:DDHGCalModuleAlgo"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalTBModule, "hgcal:DDHGCalTBModule"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalTBModuleX, "hgcal:DDHGCalTBModuleX"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalNoTaperEndcap, "hgcal:DDHGCalNoTaperEndcap"); -DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDAHcalModuleAlgo, "hgcal:DDAHcalModuleAlgo"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalEEAlgo, "hgcal:DDHGCalEEAlgo"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalHEAlgo, "hgcal:DDHGCalHEAlgo"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalCell, "hgcal:DDHGCalCell"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWaferAlgo, + "hgcal:DDHGCalWaferAlgo"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWafer, "hgcal:DDHGCalWafer"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWafer8, "hgcal:DDHGCalWafer8"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalModule, "hgcal:DDHGCalModule"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalModuleAlgo, + "hgcal:DDHGCalModuleAlgo"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalTBModule, "hgcal:DDHGCalTBModule"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalTBModuleX, + "hgcal:DDHGCalTBModuleX"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalNoTaperEndcap, + "hgcal:DDHGCalNoTaperEndcap"); +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDAHcalModuleAlgo, + "hgcal:DDAHcalModuleAlgo"); diff --git a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc index f6a5ecf73706e..ca07354420245 100644 --- a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc @@ -8,105 +8,110 @@ //#define EDM_ML_DEBUG -FastTimeDDDConstants::FastTimeDDDConstants(const FastTimeParameters* ft) : ftpar_(ft) { - +FastTimeDDDConstants::FastTimeDDDConstants(const FastTimeParameters* ft) + : ftpar_(ft) { #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants::FastTimeDDDConstants ( const FastTimeParameters* ft ) constructor\n"; + std::cout << "FastTimeDDDConstants::FastTimeDDDConstants ( const " + "FastTimeParameters* ft ) constructor\n"; #endif initialize(); - } -FastTimeDDDConstants::~FastTimeDDDConstants() { +FastTimeDDDConstants::~FastTimeDDDConstants() { #ifdef EDM_ML_DEBUG std::cout << "FastTimeDDDConstants:destructed!!!" << std::endl; #endif } -std::pair FastTimeDDDConstants::getZPhi(double z, double phi) const { - +std::pair FastTimeDDDConstants::getZPhi(double z, double phi) const { if (phi < 0) phi += CLHEP::twopi; - int iz = (int)(z/dZBarrel_) + 1; - if (iz > ftpar_->nZBarrel_) iz = ftpar_->nZBarrel_; - int iphi = (int)(phi/dPhiBarrel_) + 1; + int iz = (int)(z / dZBarrel_) + 1; + if (iz > ftpar_->nZBarrel_) iz = ftpar_->nZBarrel_; + int iphi = (int)(phi / dPhiBarrel_) + 1; if (iphi > ftpar_->nPhiBarrel_) iphi = 1; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants:Barrel z|phi " << z << " " - << phi/CLHEP::deg << " iz|iphi " << iz << " " << iphi << std::endl; + std::cout << "FastTimeDDDConstants:Barrel z|phi " << z << " " + << phi / CLHEP::deg << " iz|iphi " << iz << " " << iphi + << std::endl; #endif - return std::pair(iz,iphi); + return std::pair(iz, iphi); } -std::pair FastTimeDDDConstants::getEtaPhi(double r, double phi) const { - +std::pair FastTimeDDDConstants::getEtaPhi(double r, + double phi) const { if (phi < 0) phi += CLHEP::twopi; - int ir(ftpar_->nEtaEndcap_); - for (unsigned int k=1; knEtaEndcap_); + for (unsigned int k = 1; k < rLimits_.size(); ++k) { if (r > rLimits_[k]) { - ir = k; break; + ir = k; + break; } } - int iphi = (int)(phi/dPhiEndcap_) + 1; + int iphi = (int)(phi / dPhiEndcap_) + 1; if (iphi > ftpar_->nPhiEndcap_) iphi = 1; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants:Endcap r|phi " << r << " " - << phi/CLHEP::deg << " ir|iphi " << ir << " " << iphi << std::endl; + std::cout << "FastTimeDDDConstants:Endcap r|phi " << r << " " + << phi / CLHEP::deg << " ir|iphi " << ir << " " << iphi + << std::endl; #endif - return std::pair(ir,iphi); + return std::pair(ir, iphi); } GlobalPoint FastTimeDDDConstants::getPosition(int type, int izeta, int iphi, - int zside) const { - + int zside) const { double x(0), y(0), z(0); if (type == 1) { - double phi = (iphi-0.5)*dPhiBarrel_; - x = ftpar_->geomParBarrel_[2]*cos(phi); - y = ftpar_->geomParBarrel_[2]*sin(phi); - z = ftpar_->geomParBarrel_[0]+(izeta-0.5)*dZBarrel_; + double phi = (iphi - 0.5) * dPhiBarrel_; + x = ftpar_->geomParBarrel_[2] * cos(phi); + y = ftpar_->geomParBarrel_[2] * sin(phi); + z = ftpar_->geomParBarrel_[0] + (izeta - 0.5) * dZBarrel_; } else if (type == 2) { - double phi = (iphi-0.5)*dPhiEndcap_; - double r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) ? 0 : - 0.5*(rLimits_[izeta-1]+rLimits_[izeta]); - x = (zside < 0) ? -r*cos(phi) : r*cos(phi); - y = r*sin(phi); + double phi = (iphi - 0.5) * dPhiEndcap_; + double r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) + ? 0 + : 0.5 * (rLimits_[izeta - 1] + rLimits_[izeta]); + x = (zside < 0) ? -r * cos(phi) : r * cos(phi); + y = r * sin(phi); z = ftpar_->geomParEndcap_[2]; } if (zside < 0) z = -z; - GlobalPoint p(x,y,z); + GlobalPoint p(x, y, z); return p; } -std::vector FastTimeDDDConstants::getCorners(int type, int izeta, - int iphi, - int zside) const { - +std::vector FastTimeDDDConstants::getCorners(int type, int izeta, + int iphi, + int zside) const { double x(0), y(0), z(0), dx(0), dz(0), r(0), phi(0); if (type == 1) { - phi = (iphi-0.5)*dPhiBarrel_; - r = ftpar_->geomParBarrel_[2]; - x = r*cos(phi); - y = r*sin(phi); - z = ftpar_->geomParBarrel_[0]+(izeta-0.5)*dZBarrel_; - dx = 0.5*ftpar_->geomParBarrel_[3]; - dz = 0.5*dZBarrel_; + phi = (iphi - 0.5) * dPhiBarrel_; + r = ftpar_->geomParBarrel_[2]; + x = r * cos(phi); + y = r * sin(phi); + z = ftpar_->geomParBarrel_[0] + (izeta - 0.5) * dZBarrel_; + dx = 0.5 * ftpar_->geomParBarrel_[3]; + dz = 0.5 * dZBarrel_; } else if (type == 2) { - phi = (iphi-0.5)*dPhiEndcap_; - r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) ? 0 : - 0.5*(rLimits_[izeta-1]+rLimits_[izeta]); - x = (zside < 0) ? -r*cos(phi) : r*cos(phi); - y = r*sin(phi); - z = ftpar_->geomParEndcap_[2]; - dx = 0.5*r*dPhiEndcap_; - dz = 0.5*ftpar_->geomParEndcap_[3]; + phi = (iphi - 0.5) * dPhiEndcap_; + r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) + ? 0 + : 0.5 * (rLimits_[izeta - 1] + rLimits_[izeta]); + x = (zside < 0) ? -r * cos(phi) : r * cos(phi); + y = r * sin(phi); + z = ftpar_->geomParEndcap_[2]; + dx = 0.5 * r * dPhiEndcap_; + dz = 0.5 * ftpar_->geomParEndcap_[3]; } - if (zside < 0) {z = -z; dz = -dz;} - static const int signx[8] = {-1,-1, 1, 1,-1,-1, 1, 1}; - static const int signy[8] = {-1, 1, 1,-1,-1, 1, 1,-1}; - static const int signz[8] = {-1,-1,-1,-1, 1, 1, 1, 1}; + if (zside < 0) { + z = -z; + dz = -dz; + } + static const int signx[8] = {-1, -1, 1, 1, -1, -1, 1, 1}; + static const int signy[8] = {-1, 1, 1, -1, -1, 1, 1, -1}; + static const int signz[8] = {-1, -1, -1, -1, 1, 1, 1, 1}; std::vector pts; - for (unsigned int i=0; i != 8; ++i) { - GlobalPoint p(x+signx[i]*dx,y+signy[i]*dx,z+signz[i]*dz); + for (unsigned int i = 0; i != 8; ++i) { + GlobalPoint p(x + signx[i] * dx, y + signy[i] * dx, z + signz[i] * dz); pts.emplace_back(p); } return pts; @@ -115,9 +120,9 @@ std::vector FastTimeDDDConstants::getCorners(int type, int izeta, int FastTimeDDDConstants::getCells(int type) const { int numb(0); if (type == 1) { - numb = (ftpar_->nZBarrel_)*(ftpar_->nPhiBarrel_); + numb = (ftpar_->nZBarrel_) * (ftpar_->nPhiBarrel_); } else if (type == 2) { - numb = (ftpar_->nEtaEndcap_)*(ftpar_->nPhiEndcap_); + numb = (ftpar_->nEtaEndcap_) * (ftpar_->nPhiEndcap_); } return numb; } @@ -135,7 +140,7 @@ double FastTimeDDDConstants::getRin(int type) const { double FastTimeDDDConstants::getRout(int type) const { double value(0); if (type == 1) { - value = (ftpar_->geomParBarrel_[2]+ftpar_->geomParBarrel_[3]); + value = (ftpar_->geomParBarrel_[2] + ftpar_->geomParBarrel_[3]); } else if (type == 2) { value = (ftpar_->geomParEndcap_[1]); } @@ -145,7 +150,7 @@ double FastTimeDDDConstants::getRout(int type) const { double FastTimeDDDConstants::getZHalf(int type) const { double value(0); if (type == 1) { - value = 0.5*(ftpar_->geomParBarrel_[1]-ftpar_->geomParBarrel_[0]); + value = 0.5 * (ftpar_->geomParBarrel_[1] - ftpar_->geomParBarrel_[0]); } else if (type == 2) { value = (ftpar_->geomParEndcap_[3]); } @@ -155,7 +160,7 @@ double FastTimeDDDConstants::getZHalf(int type) const { double FastTimeDDDConstants::getZPos(int type) const { double value(0); if (type == 1) { - value = 0.5*(ftpar_->geomParBarrel_[1]+ftpar_->geomParBarrel_[0]); + value = 0.5 * (ftpar_->geomParBarrel_[1] + ftpar_->geomParBarrel_[0]); } else if (type == 2) { value = (ftpar_->geomParEndcap_[2]); } @@ -165,11 +170,11 @@ double FastTimeDDDConstants::getZPos(int type) const { bool FastTimeDDDConstants::isValidXY(int type, int izeta, int iphi) const { bool ok(false); if (type == 1) { - ok = ((izeta > 0) && (izeta <= ftpar_->nZBarrel_) && - (iphi > 0) && (iphi <= ftpar_->nPhiBarrel_)); + ok = ((izeta > 0) && (izeta <= ftpar_->nZBarrel_) && (iphi > 0) && + (iphi <= ftpar_->nPhiBarrel_)); } else if (type == 2) { - ok = ((izeta > 0) && (izeta <= ftpar_->nEtaEndcap_) && - (iphi > 0) && (iphi <= ftpar_->nPhiEndcap_)); + ok = ((izeta > 0) && (izeta <= ftpar_->nEtaEndcap_) && (iphi > 0) && + (iphi <= ftpar_->nPhiEndcap_)); } return ok; } @@ -195,38 +200,37 @@ int FastTimeDDDConstants::numberPhi(int type) const { } void FastTimeDDDConstants::initialize() { - - double thmin = atan(ftpar_->geomParEndcap_[0]/ftpar_->geomParEndcap_[2]); - etaMax_ = -log(0.5*thmin); - double thmax = atan(ftpar_->geomParEndcap_[1]/ftpar_->geomParEndcap_[2]); - etaMin_ = -log(0.5*thmax); - dEta_ = (etaMax_-etaMin_)/ftpar_->nEtaEndcap_; + double thmin = atan(ftpar_->geomParEndcap_[0] / ftpar_->geomParEndcap_[2]); + etaMax_ = -log(0.5 * thmin); + double thmax = atan(ftpar_->geomParEndcap_[1] / ftpar_->geomParEndcap_[2]); + etaMin_ = -log(0.5 * thmax); + dEta_ = (etaMax_ - etaMin_) / ftpar_->nEtaEndcap_; #ifdef EDM_ML_DEBUG - std::cout << "Theta range " << thmin/CLHEP::deg << ":" << thmax/CLHEP::deg - << " Eta range " << etaMin_ << ":" << etaMax_ << ":" << dEta_ - << std::endl; + std::cout << "Theta range " << thmin / CLHEP::deg << ":" << thmax / CLHEP::deg + << " Eta range " << etaMin_ << ":" << etaMax_ << ":" << dEta_ + << std::endl; #endif - for (int k=0; k<=ftpar_->nEtaEndcap_; ++k) { - double eta = etaMin_ + k*dEta_; - double theta = 2.0*atan(exp(-eta)); - double rval = (ftpar_->geomParEndcap_[2])*tan(theta); + for (int k = 0; k <= ftpar_->nEtaEndcap_; ++k) { + double eta = etaMin_ + k * dEta_; + double theta = 2.0 * atan(exp(-eta)); + double rval = (ftpar_->geomParEndcap_[2]) * tan(theta); rLimits_.emplace_back(rval); } - dZBarrel_ = ftpar_->geomParBarrel_[1]/ftpar_->nZBarrel_; - dPhiBarrel_ = CLHEP::twopi/ftpar_->nPhiBarrel_; - dPhiEndcap_ = CLHEP::twopi/ftpar_->nPhiEndcap_; + dZBarrel_ = ftpar_->geomParBarrel_[1] / ftpar_->nZBarrel_; + dPhiBarrel_ = CLHEP::twopi / ftpar_->nPhiBarrel_; + dPhiEndcap_ = CLHEP::twopi / ftpar_->nPhiEndcap_; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants initialized with " << ftpar_->nZBarrel_ - << ":" << ftpar_->nPhiBarrel_ << ":" << getCells(1) - << " cells for barrel; dz|dphi " << dZBarrel_ << "|" << dPhiBarrel_ - << " and " << ftpar_->nEtaEndcap_ << ":" << ftpar_->nPhiEndcap_ - << ":" << getCells(2) << " cells for endcap; dphi " << dPhiEndcap_ - << " The Limits in R are" << std::endl; - for (unsigned int k=0; knZBarrel_ + << ":" << ftpar_->nPhiBarrel_ << ":" << getCells(1) + << " cells for barrel; dz|dphi " << dZBarrel_ << "|" << dPhiBarrel_ + << " and " << ftpar_->nEtaEndcap_ << ":" << ftpar_->nPhiEndcap_ + << ":" << getCells(2) << " cells for endcap; dphi " << dPhiEndcap_ + << " The Limits in R are" << std::endl; + for (unsigned int k = 0; k < rLimits_.size(); ++k) { std::cout << "[" << k << "] " << rLimits_[k] << " "; - if (k%8 == 7) std::cout << std::endl; + if (k % 8 == 7) std::cout << std::endl; } - if ((rLimits_.size()-1)%8 != 7) std::cout << std::endl; + if ((rLimits_.size() - 1) % 8 != 7) std::cout << std::endl; #endif } diff --git a/Geometry/HGCalCommonData/src/FastTimeParameters.cc b/Geometry/HGCalCommonData/src/FastTimeParameters.cc index aa7460ff93bc6..4bfd5c0a97c9c 100644 --- a/Geometry/HGCalCommonData/src/FastTimeParameters.cc +++ b/Geometry/HGCalCommonData/src/FastTimeParameters.cc @@ -1,8 +1,8 @@ #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" -FastTimeParameters::FastTimeParameters() { } +FastTimeParameters::FastTimeParameters() {} -FastTimeParameters::~FastTimeParameters() { } +FastTimeParameters::~FastTimeParameters() {} #include "FWCore/Utilities/interface/typelookup.h" diff --git a/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc b/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc index 62292c9d1e4f1..df8a30ed406be 100644 --- a/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc +++ b/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc @@ -1,32 +1,30 @@ #include "Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h" -#include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" #include "DetectorDescription/Core/interface/DDutils.h" +#include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" -#include #include +#include +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" //#define EDM_ML_DEBUG bool FastTimeParametersFromDD::build(const DDCompactView* cpv, - FastTimeParameters& php, - const std::string& name, - const int type) { - + FastTimeParameters& php, + const std::string& name, const int type) { #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersFromDD::build called with names " << name - << " and type " << type << std::endl; + std::cout << "FastTimeParametersFromDD::build called with names " << name + << " and type " << type << std::endl; #endif - //Special parameters at simulation level - std::string attribute = "Volume"; - const std::string& value = name; + // Special parameters at simulation level + std::string attribute = "Volume"; + const std::string& value = name; DDValue val(attribute, value, 0.0); DDSpecificsMatchesValueFilter filter{val}; - DDFilteredView fv(*cpv,filter); + DDFilteredView fv(*cpv, filter); bool ok = fv.firstChild(); if (ok) { @@ -34,60 +32,61 @@ bool FastTimeParametersFromDD::build(const DDCompactView* cpv, std::vector temp; if (type == 1) { php.geomParBarrel_ = getDDDArray("geomParsB", sv); - temp = getDDDArray("numberZB", sv); - php.nZBarrel_ = (int)(temp[0]); - temp = getDDDArray("numberPhiB", sv); - php.nPhiBarrel_ = (int)(temp[0]); + temp = getDDDArray("numberZB", sv); + php.nZBarrel_ = (int)(temp[0]); + temp = getDDDArray("numberPhiB", sv); + php.nPhiBarrel_ = (int)(temp[0]); #ifdef EDM_ML_DEBUG - std::cout << "Barrel Parameters: " << php.nZBarrel_ << ":" - << php.nPhiBarrel_ << ":" << php.geomParBarrel_[0] << ":" - << php.geomParBarrel_[1] << std::endl; + std::cout << "Barrel Parameters: " << php.nZBarrel_ << ":" + << php.nPhiBarrel_ << ":" << php.geomParBarrel_[0] << ":" + << php.geomParBarrel_[1] << std::endl; #endif } else if (type == 2) { php.geomParEndcap_ = getDDDArray("geomParsE", sv); - temp = getDDDArray("numberEtaE", sv); - php.nEtaEndcap_ = (int)(temp[0]); - temp = getDDDArray("numberPhiE", sv); - php.nPhiEndcap_ = (int)(temp[0]); + temp = getDDDArray("numberEtaE", sv); + php.nEtaEndcap_ = (int)(temp[0]); + temp = getDDDArray("numberPhiE", sv); + php.nPhiEndcap_ = (int)(temp[0]); #ifdef EDM_ML_DEBUG - std::cout << "Endcap Parameters: " << php.nEtaEndcap_ << ":" - << php.nPhiEndcap_ << ":" << php.geomParEndcap_[0] << ":" - << php.geomParEndcap_[1] << ":" << php.geomParEndcap_[2] - << std::endl; + std::cout << "Endcap Parameters: " << php.nEtaEndcap_ << ":" + << php.nPhiEndcap_ << ":" << php.geomParEndcap_[0] << ":" + << php.geomParEndcap_[1] << ":" << php.geomParEndcap_[2] + << std::endl; #endif } else { - edm::LogWarning("HGCalGeom") << "Unknown Geometry type " << type - << " for FastTiming " << name; + edm::LogWarning("HGCalGeom") + << "Unknown Geometry type " << type << " for FastTiming " << name; } } else { - edm::LogError("HGCalGeom") << " Attribute " << val - << " not found but needed."; - throw cms::Exception("DDException") << "Attribute " << val - << " not found but needed."; + edm::LogError("HGCalGeom") + << " Attribute " << val << " not found but needed."; + throw cms::Exception("DDException") + << "Attribute " << val << " not found but needed."; } #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersFromDD::Returns with flag " << ok - << " for " << name << " and type " << type << std::endl; + std::cout << "FastTimeParametersFromDD::Returns with flag " << ok << " for " + << name << " and type " << type << std::endl; #endif return ok; } -std::vector FastTimeParametersFromDD::getDDDArray(const std::string & str, - const DDsvalues_type & sv) { - +std::vector FastTimeParametersFromDD::getDDDArray( + const std::string& str, const DDsvalues_type& sv) { DDValue value(str); - if (DDfetch(&sv,value)) { - const std::vector & fvec = value.doubles(); + if (DDfetch(&sv, value)) { + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 1) { edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str - << " bins " << nval << " < 1 ==> illegal"; - throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str; + << " bins " << nval << " < 1 ==> illegal"; + throw cms::Exception("DDException") + << "HGCalGeomParameters: cannot get array " << str; } return fvec; } else { - edm::LogError("HGCalGeom") << "HGCalGeomParameters: cannot get array " - << str; - throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str; + edm::LogError("HGCalGeom") + << "HGCalGeomParameters: cannot get array " << str; + throw cms::Exception("DDException") + << "HGCalGeomParameters: cannot get array " << str; } } diff --git a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc index 2c331432ea932..9c795f01747b9 100644 --- a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc @@ -1,13 +1,13 @@ #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h" -#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" -#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" +#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" -#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" #include "CLHEP/Units/GlobalPhysicalConstants.h" @@ -23,20 +23,21 @@ static const int maxType = 2; static const int minType = 0; HGCalDDDConstants::HGCalDDDConstants(const HGCalParameters* hp, - const std::string& name) : hgpar_(hp), - sqrt3_(std::sqrt(3.0)) { + const std::string& name) + : hgpar_(hp), sqrt3_(std::sqrt(3.0)) { mode_ = hgpar_->mode_; if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull) || (mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - rmax_ = (HGCalParameters::k_ScaleFromDDD * (hgpar_->waferR_) * - std::cos(30.0*CLHEP::deg)); - hexside_ = 2.0 * rmax_ * tan30deg_; + rmax_ = (HGCalParameters::k_ScaleFromDDD * (hgpar_->waferR_) * + std::cos(30.0 * CLHEP::deg)); + hexside_ = 2.0 * rmax_ * tan30deg_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "rmax_ " << rmax_ << ":" << hexside_ - << " CellSize " << 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[0] - << ":" << 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[1]; + edm::LogVerbatim("HGCalGeom") + << "rmax_ " << rmax_ << ":" << hexside_ << " CellSize " + << 0.5 * HGCalParameters::k_ScaleFromDDD * hgpar_->cellSize_[0] << ":" + << 0.5 * HGCalParameters::k_ScaleFromDDD * hgpar_->cellSize_[1]; #endif } // init maps and constants @@ -44,172 +45,178 @@ HGCalDDDConstants::HGCalDDDConstants(const HGCalParameters* hp, maxWafersPerLayer_ = 0; for (int simreco = 0; simreco < 2; ++simreco) { tot_layers_[simreco] = layersInit((bool)simreco); - max_modules_layer_[simreco].resize(tot_layers_[simreco]+1); - for (unsigned int layer=1; layer <= tot_layers_[simreco]; ++layer) { - max_modules_layer_[simreco][layer] = modulesInit(layer,(bool)simreco); + max_modules_layer_[simreco].resize(tot_layers_[simreco] + 1); + for (unsigned int layer = 1; layer <= tot_layers_[simreco]; ++layer) { + max_modules_layer_[simreco][layer] = modulesInit(layer, (bool)simreco); if (simreco == 1) { modHalf_ += max_modules_layer_[simreco][layer]; - maxWafersPerLayer_ = std::max(maxWafersPerLayer_, - max_modules_layer_[simreco][layer]); + maxWafersPerLayer_ = + std::max(maxWafersPerLayer_, max_modules_layer_[simreco][layer]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " - << max_modules_layer_[simreco][layer] - << ":" << modHalf_ << " modules"; + edm::LogVerbatim("HGCalGeom") << "Layer " << layer << " with " + << max_modules_layer_[simreco][layer] + << ":" << modHalf_ << " modules"; #endif } } } tot_wafers_ = wafers(); - + #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants initialized for " - << name << " with " << layers(false) << ":" - << layers(true) << " layers, " << wafers() - << ":" << 2*modHalf_ << " wafers with maximum " - << maxWafersPerLayer_ << " per layer and " - << "maximum of " << maxCells(false) << ":" - << maxCells(true) << " cells"; + edm::LogVerbatim("HGCalGeom") + << "HGCalDDDConstants initialized for " << name << " with " + << layers(false) << ":" << layers(true) << " layers, " << wafers() << ":" + << 2 * modHalf_ << " wafers with maximum " << maxWafersPerLayer_ + << " per layer and " + << "maximum of " << maxCells(false) << ":" << maxCells(true) << " cells"; #endif if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull) || (mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { int wminT(9999999), wmaxT(-9999999), kount1(0), kount2(0); - for (unsigned int i=0; iwaferCopy_[wafer]),HGCalWaferIndex::waferV(hgpar_->waferCopy_[wafer])); + int kndx = HGCalWaferIndex::waferIndex( + lay0, HGCalWaferIndex::waferU(hgpar_->waferCopy_[wafer]), + HGCalWaferIndex::waferV(hgpar_->waferCopy_[wafer])); waferIn_[kndx] = waferIn; } if (waferIn) { - int waferU = (((mode_ == HGCalGeometryMode::Hexagon) || - (mode_ == HGCalGeometryMode::HexagonFull)) ? wafer : - HGCalWaferIndex::waferU(hgpar_->waferCopy_[wafer])); + int waferU = + (((mode_ == HGCalGeometryMode::Hexagon) || + (mode_ == HGCalGeometryMode::HexagonFull)) + ? wafer + : HGCalWaferIndex::waferU(hgpar_->waferCopy_[wafer])); if (waferU < wmin) wmin = waferU; if (waferU > wmax) wmax = waferU; ++kount; } } - if (wminT > wmin) wminT = wmin; - if (wmaxT < wmax) wmaxT = wmax; - if (kount1 < kount) kount1= kount; + if (wminT > wmin) wminT = wmin; + if (wmaxT < wmax) wmaxT = wmax; + if (kount1 < kount) kount1 = kount; kount2 += kount; #ifdef EDM_ML_DEBUG - int lay1 = getIndex(lay0,true).first; - edm::LogVerbatim("HGCalGeom") << "Index " << i << " Layer " << lay0 - << ":" << lay1 << " Wafer " << wmin - << ":" << wmax << ":" << kount; + int lay1 = getIndex(lay0, true).first; + edm::LogVerbatim("HGCalGeom") + << "Index " << i << " Layer " << lay0 << ":" << lay1 << " Wafer " + << wmin << ":" << wmax << ":" << kount; #endif - HGCWaferParam a1{ {wmin,wmax,kount} }; + HGCWaferParam a1{{wmin, wmax, kount}}; waferLayer_[lay0] = a1; } - waferMax_ = std::array{ {wminT,wmaxT,kount1,kount2} }; + waferMax_ = std::array{{wminT, wmaxT, kount1, kount2}}; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Overall wafer statistics: " << wminT - << ":" << wmaxT << ":" << kount1 << ":" - << kount2; + edm::LogVerbatim("HGCalGeom") + << "Overall wafer statistics: " << wminT << ":" << wmaxT << ":" + << kount1 << ":" << kount2; #endif } } HGCalDDDConstants::~HGCalDDDConstants() {} -std::pair HGCalDDDConstants::assignCell(float x, float y, int lay, - int subSec, bool reco) const { - const auto & index = getIndex(lay, reco); - if (index.first < 0) return std::make_pair(-1,-1); +std::pair HGCalDDDConstants::assignCell(float x, float y, int lay, + int subSec, bool reco) const { + const auto& index = getIndex(lay, reco); + if (index.first < 0) return std::make_pair(-1, -1); if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - float xx = (reco) ? x : HGCalParameters::k_ScaleFromDDD*x; - float yy = (reco) ? y : HGCalParameters::k_ScaleFromDDD*y; + float xx = (reco) ? x : HGCalParameters::k_ScaleFromDDD * x; + float yy = (reco) ? y : HGCalParameters::k_ScaleFromDDD * y; - //First the wafer + // First the wafer int wafer = cellHex(xx, yy, rmax_, hgpar_->waferPosX_, hgpar_->waferPosY_); if (wafer < 0 || wafer >= (int)(hgpar_->waferTypeT_.size())) { - edm::LogWarning("HGCalGeom") << "Wafer no. out of bound for " << wafer - << ":" << (hgpar_->waferTypeT_).size() - << ":" << (hgpar_->waferPosX_).size() - << ":" << (hgpar_->waferPosY_).size() - << " ***** ERROR *****"; - return std::make_pair(-1,-1); + edm::LogWarning("HGCalGeom") + << "Wafer no. out of bound for " << wafer << ":" + << (hgpar_->waferTypeT_).size() << ":" << (hgpar_->waferPosX_).size() + << ":" << (hgpar_->waferPosY_).size() << " ***** ERROR *****"; + return std::make_pair(-1, -1); } else { // Now the cell xx -= hgpar_->waferPosX_[wafer]; yy -= hgpar_->waferPosY_[wafer]; - if (hgpar_->waferTypeT_[wafer] == 1) - return std::make_pair(wafer,cellHex(xx, yy, - 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[0], - hgpar_->cellFineX_, hgpar_->cellFineY_)); + if (hgpar_->waferTypeT_[wafer] == 1) + return std::make_pair(wafer, + cellHex(xx, yy, + 0.5 * HGCalParameters::k_ScaleFromDDD * + hgpar_->cellSize_[0], + hgpar_->cellFineX_, hgpar_->cellFineY_)); else - return std::make_pair(wafer,cellHex(xx, yy, - 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[1], - hgpar_->cellCoarseX_, hgpar_->cellCoarseY_)); + return std::make_pair( + wafer, cellHex(xx, yy, + 0.5 * HGCalParameters::k_ScaleFromDDD * + hgpar_->cellSize_[1], + hgpar_->cellCoarseX_, hgpar_->cellCoarseY_)); } } else { - return std::make_pair(-1,-1); + return std::make_pair(-1, -1); } } -std::array HGCalDDDConstants::assignCellHex(float x, float y, int lay, - bool reco) const { +std::array HGCalDDDConstants::assignCellHex(float x, float y, int lay, + bool reco) const { int waferU(0), waferV(0), waferType(-1), cellU(0), cellV(0); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - double xx = (reco) ? HGCalParameters::k_ScaleToDDD*x : x; - double yy = (reco) ? HGCalParameters::k_ScaleToDDD*y : y; + double xx = (reco) ? HGCalParameters::k_ScaleToDDD * x : x; + double yy = (reco) ? HGCalParameters::k_ScaleToDDD * y : y; double wt(1.0); - waferFromPosition(xx,yy,lay,waferU,waferV,cellU,cellV,waferType,wt); + waferFromPosition(xx, yy, lay, waferU, waferV, cellU, cellV, waferType, wt); } - return std::array{ {waferU,waferV,waferType,cellU,cellV} }; + return std::array{{waferU, waferV, waferType, cellU, cellV}}; } -std::array HGCalDDDConstants::assignCellTrap(float x, float y, - float z, int layer, - bool reco) const { - +std::array HGCalDDDConstants::assignCellTrap(float x, float y, float z, + int layer, + bool reco) const { int irad(-1), iphi(-1), type(-1); - const auto & indx = getIndex(layer,reco); - if (indx.first < 0) return std::array{ {irad,iphi,type} }; - double xx = (z > 0) ? x : -x; - double r = (reco ? std::sqrt(x*x+y*y) : - HGCalParameters::k_ScaleFromDDD*std::sqrt(x*x+y*y)); - double phi = (r == 0. ? 0. : std::atan2(y,xx)); - if (phi < 0) phi += (2.0*M_PI); - type = hgpar_->scintType(layer); - auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), - hgpar_->radiusLayer_[type].end(), r); - irad = (int)(ir - hgpar_->radiusLayer_[type].begin()); - irad = std::min(std::max(irad,hgpar_->iradMinBH_[indx.first]), - hgpar_->iradMaxBH_[indx.first]); - iphi = 1 + (int)(phi/indx.second); + const auto& indx = getIndex(layer, reco); + if (indx.first < 0) return std::array{{irad, iphi, type}}; + double xx = (z > 0) ? x : -x; + double r = + (reco ? std::sqrt(x * x + y * y) + : HGCalParameters::k_ScaleFromDDD * std::sqrt(x * x + y * y)); + double phi = (r == 0. ? 0. : std::atan2(y, xx)); + if (phi < 0) phi += (2.0 * M_PI); + type = hgpar_->scintType(layer); + auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), + hgpar_->radiusLayer_[type].end(), r); + irad = (int)(ir - hgpar_->radiusLayer_[type].begin()); + irad = std::min(std::max(irad, hgpar_->iradMinBH_[indx.first]), + hgpar_->iradMaxBH_[indx.first]); + iphi = 1 + (int)(phi / indx.second); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "assignCellTrap Input " << x << ":" << y - << ":" << z << ":" << layer << ":" << reco - << " x|r " << xx << ":" << r << " phi " - << phi << " o/p " << irad << ":" << iphi - << ":" << type; + edm::LogVerbatim("HGCalGeom") + << "assignCellTrap Input " << x << ":" << y << ":" << z << ":" << layer + << ":" << reco << " x|r " << xx << ":" << r << " phi " << phi << " o/p " + << irad << ":" << iphi << ":" << type; #endif - return std::array{ {irad,iphi,type} }; + return std::array{{irad, iphi, type}}; } -bool HGCalDDDConstants::cellInLayer(int waferU, int waferV, int cellU, +bool HGCalDDDConstants::cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const { - const auto & indx = getIndex(lay,true); + const auto& indx = getIndex(lay, true); if (indx.first >= 0) { if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full) || (mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - const auto & xy = (((mode_ == HGCalGeometryMode::Hexagon8) || - (mode_ == HGCalGeometryMode::Hexagon8Full)) ? - locateCell(lay, waferU, waferV, cellU, cellV, reco, true, false) : - locateCell(cellU, lay, waferU, reco)); - double rpos = sqrt(xy.first*xy.first + xy.second*xy.second); - return ((rpos >= hgpar_->rMinLayHex_[indx.first]) && + const auto& xy = (((mode_ == HGCalGeometryMode::Hexagon8) || + (mode_ == HGCalGeometryMode::Hexagon8Full)) + ? locateCell(lay, waferU, waferV, cellU, cellV, + reco, true, false) + : locateCell(cellU, lay, waferU, reco)); + double rpos = sqrt(xy.first * xy.first + xy.second * xy.second); + return ((rpos >= hgpar_->rMinLayHex_[indx.first]) && (rpos <= hgpar_->rMaxLayHex_[indx.first])); } else { return true; @@ -219,32 +226,36 @@ bool HGCalDDDConstants::cellInLayer(int waferU, int waferV, int cellU, } } -double HGCalDDDConstants::cellThickness(int layer, int waferU, +double HGCalDDDConstants::cellThickness(int layer, int waferU, int waferV) const { - double thick(-1); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(layer,waferU,waferV)); - int type = ((itr == hgpar_->typesInLayers_.end() ? maxType : - hgpar_->waferTypeL_[itr->second])); - thick = 10000.0*hgpar_->cellThickness_[type]; // cm to micron + auto itr = hgpar_->typesInLayers_.find( + HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + int type = ((itr == hgpar_->typesInLayers_.end() + ? maxType + : hgpar_->waferTypeL_[itr->second])); + thick = 10000.0 * hgpar_->cellThickness_[type]; // cm to micron } else if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - int type = (((waferU>=0)&&(waferU<(int)(hgpar_->waferTypeL_.size()))) ? - hgpar_->waferTypeL_[waferU] : minType); - thick = 100.0*type; // type = 1,2,3 for 100,200,300 micron + int type = (((waferU >= 0) && (waferU < (int)(hgpar_->waferTypeL_.size()))) + ? hgpar_->waferTypeL_[waferU] + : minType); + thick = 100.0 * type; // type = 1,2,3 for 100,200,300 micron } return thick; } double HGCalDDDConstants::cellSizeHex(int type) const { - int indx = (((mode_ == HGCalGeometryMode::Hexagon8) || - (mode_ == HGCalGeometryMode::Hexagon8Full)) ? - ((type >= 1) ? 1 : 0) : ((type == 1) ? 1 : 0)); - double cell = ((mode_ == HGCalGeometryMode::Trapezoid) ? - 0.5*hgpar_->cellSize_[indx] : - 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[indx]); + int indx = (((mode_ == HGCalGeometryMode::Hexagon8) || + (mode_ == HGCalGeometryMode::Hexagon8Full)) + ? ((type >= 1) ? 1 : 0) + : ((type == 1) ? 1 : 0)); + double cell = + ((mode_ == HGCalGeometryMode::Trapezoid) + ? 0.5 * hgpar_->cellSize_[indx] + : 0.5 * HGCalParameters::k_ScaleFromDDD * hgpar_->cellSize_[indx]); return cell; } @@ -254,25 +265,36 @@ HGCalDDDConstants::CellType HGCalDDDConstants::cellType(int type, int cellU, // =11..16: the corners clockwise from bottom int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; if (cellU == 0) { - if (cellV == 0) return HGCalDDDConstants::CellType::BottomLeftCorner; - else if (cellV-cellU == N-1) return HGCalDDDConstants::CellType::BottomCorner; - else return HGCalDDDConstants::CellType::BottomLeftEdge; + if (cellV == 0) + return HGCalDDDConstants::CellType::BottomLeftCorner; + else if (cellV - cellU == N - 1) + return HGCalDDDConstants::CellType::BottomCorner; + else + return HGCalDDDConstants::CellType::BottomLeftEdge; } else if (cellV == 0) { - if (cellU-cellV == N) return HGCalDDDConstants::CellType::TopLeftCorner; - else return HGCalDDDConstants::CellType::LeftEdge; - } else if (cellU-cellV == N) { - if (cellU == 2*N-1) return HGCalDDDConstants::CellType::TopCorner; - else return HGCalDDDConstants::CellType::TopLeftEdge; - } else if (cellU == 2*N-1) { - if (cellV == 2*N-1) return HGCalDDDConstants::CellType::TopRightCorner; - else return HGCalDDDConstants::CellType::TopRightEdge; - } else if (cellV == 2*N-1) { - if (cellV-cellU == N-1) return HGCalDDDConstants::CellType::BottomRightCorner; - else return HGCalDDDConstants::CellType::RightEdge; - } else if (cellV-cellU == N-1) { + if (cellU - cellV == N) + return HGCalDDDConstants::CellType::TopLeftCorner; + else + return HGCalDDDConstants::CellType::LeftEdge; + } else if (cellU - cellV == N) { + if (cellU == 2 * N - 1) + return HGCalDDDConstants::CellType::TopCorner; + else + return HGCalDDDConstants::CellType::TopLeftEdge; + } else if (cellU == 2 * N - 1) { + if (cellV == 2 * N - 1) + return HGCalDDDConstants::CellType::TopRightCorner; + else + return HGCalDDDConstants::CellType::TopRightEdge; + } else if (cellV == 2 * N - 1) { + if (cellV - cellU == N - 1) + return HGCalDDDConstants::CellType::BottomRightCorner; + else + return HGCalDDDConstants::CellType::RightEdge; + } else if (cellV - cellU == N - 1) { return HGCalDDDConstants::CellType::BottomRightEdge; - } else if ((cellU > 2*N-1) || (cellV > 2*N-1) || (cellV >= (cellU+N)) || - (cellU > (cellV+N))) { + } else if ((cellU > 2 * N - 1) || (cellV > 2 * N - 1) || + (cellV >= (cellU + N)) || (cellU > (cellV + N))) { return HGCalDDDConstants::CellType::UndefinedType; } else { return HGCalDDDConstants::CellType::CentralType; @@ -280,163 +302,162 @@ HGCalDDDConstants::CellType HGCalDDDConstants::cellType(int type, int cellU, } double HGCalDDDConstants::distFromEdgeHex(double x, double y, double z) const { - - //Assming the point is within a hexagonal plane of the wafer, calculate - //the shortest distance from the edge + // Assming the point is within a hexagonal plane of the wafer, calculate + // the shortest distance from the edge if (z < 0) x = -x; double dist(0); - //Input x, y in Geant4 unit and transformed to CMSSW standard - double xx = HGCalParameters::k_ScaleFromDDD*x; - double yy = HGCalParameters::k_ScaleFromDDD*y; + // Input x, y in Geant4 unit and transformed to CMSSW standard + double xx = HGCalParameters::k_ScaleFromDDD * x; + double yy = HGCalParameters::k_ScaleFromDDD * y; int sizew = (int)(hgpar_->waferPosX_.size()); int wafer = sizew; - //Transform to the local coordinate frame of the wafer first - for (int k=0; kwaferPosX_[k]); - double dy = std::abs(yy-hgpar_->waferPosY_[k]); + // Transform to the local coordinate frame of the wafer first + for (int k = 0; k < sizew; ++k) { + double dx = std::abs(xx - hgpar_->waferPosX_[k]); + double dy = std::abs(yy - hgpar_->waferPosY_[k]); if ((dx <= rmax_) && (dy <= hexside_) && - ((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy)))) { - wafer = k; - xx -= hgpar_->waferPosX_[k]; - yy -= hgpar_->waferPosY_[k]; + ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy)))) { + wafer = k; + xx -= hgpar_->waferPosX_[k]; + yy -= hgpar_->waferPosY_[k]; break; } } - //Look at only one quarter (both x,y are positive) + // Look at only one quarter (both x,y are positive) if (wafer < sizew) { - if (std::abs(yy) < 0.5*hexside_) { + if (std::abs(yy) < 0.5 * hexside_) { dist = rmax_ - std::abs(xx); } else { - dist = 0.5*((rmax_-std::abs(xx))-sqrt3_*(std::abs(yy)-0.5*hexside_)); + dist = 0.5 * ((rmax_ - std::abs(xx)) - + sqrt3_ * (std::abs(yy) - 0.5 * hexside_)); } } else { dist = 0; } dist *= HGCalParameters::k_ScaleToDDD; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DistFromEdgeHex: Local " << xx << ":" - << yy << " wafer " << wafer << " flag " - << (wafer < sizew) << " Distance " << rmax_ - << ":" << (rmax_-std::abs(xx)) << ":" - << (std::abs(yy)-0.5*hexside_) << ":" - << 0.5*hexside_ << ":" << dist; + edm::LogVerbatim("HGCalGeom") + << "DistFromEdgeHex: Local " << xx << ":" << yy << " wafer " << wafer + << " flag " << (wafer < sizew) << " Distance " << rmax_ << ":" + << (rmax_ - std::abs(xx)) << ":" << (std::abs(yy) - 0.5 * hexside_) << ":" + << 0.5 * hexside_ << ":" << dist; #endif return dist; } double HGCalDDDConstants::distFromEdgeTrap(double x, double y, double z) const { - - //Assming the point is within the eta-phi plane of the scintillator tile, - //calculate the shortest distance from the edge - int lay = getLayer(z,false); - double xx = (z < 0) ? -x : x; - int indx = layerIndex(lay,false); - double r = HGCalParameters::k_ScaleFromDDD*std::sqrt(x*x+y*y); - double phi = (r == 0. ? 0. : std::atan2(y,xx)); - if (phi < 0) phi += (2.0*M_PI); - int type = hgpar_->scintType(lay); - double cell = hgpar_->scintCellSize(lay); - //Compare with the center of the tile find distances along R and also phi - //Take the smaller value - auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), - hgpar_->radiusLayer_[type].end(), r); - int irad = (int)(ir-hgpar_->radiusLayer_[type].begin()); - if (irad < hgpar_->iradMinBH_[indx]) irad = hgpar_->iradMinBH_[indx]; - else if (irad > hgpar_->iradMaxBH_[indx]) irad = hgpar_->iradMaxBH_[indx]; - int iphi = 1 + (int)(phi/cell); - double dphi = std::max(0.0,(0.5*cell-std::abs(phi-(iphi-0.5)*cell))); - double dist = std::min((r-hgpar_->radiusLayer_[type][irad-1]), - (hgpar_->radiusLayer_[type][irad]-r)); + // Assming the point is within the eta-phi plane of the scintillator tile, + // calculate the shortest distance from the edge + int lay = getLayer(z, false); + double xx = (z < 0) ? -x : x; + int indx = layerIndex(lay, false); + double r = HGCalParameters::k_ScaleFromDDD * std::sqrt(x * x + y * y); + double phi = (r == 0. ? 0. : std::atan2(y, xx)); + if (phi < 0) phi += (2.0 * M_PI); + int type = hgpar_->scintType(lay); + double cell = hgpar_->scintCellSize(lay); + // Compare with the center of the tile find distances along R and also phi + // Take the smaller value + auto ir = std::lower_bound(hgpar_->radiusLayer_[type].begin(), + hgpar_->radiusLayer_[type].end(), r); + int irad = (int)(ir - hgpar_->radiusLayer_[type].begin()); + if (irad < hgpar_->iradMinBH_[indx]) + irad = hgpar_->iradMinBH_[indx]; + else if (irad > hgpar_->iradMaxBH_[indx]) + irad = hgpar_->iradMaxBH_[indx]; + int iphi = 1 + (int)(phi / cell); + double dphi = + std::max(0.0, (0.5 * cell - std::abs(phi - (iphi - 0.5) * cell))); + double dist = std::min((r - hgpar_->radiusLayer_[type][irad - 1]), + (hgpar_->radiusLayer_[type][irad] - r)); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "DistFromEdgeTrap: Global " << x << ":" - << y << ":" << z << " Layer " << lay - << " Index " << indx << ":" << type << " xx " - << xx << " R " << r << ":" << irad << ":" - << hgpar_->radiusLayer_[type][irad-1] << ":" - << hgpar_->radiusLayer_[type][irad] - << " Phi " << phi << ":" << iphi << ":" - << (iphi-0.5)*cell << " cell " << cell - << " Dphi " << dphi << " Dist " << dist - << ":" << r*dphi; + edm::LogVerbatim("HGCalGeom") + << "DistFromEdgeTrap: Global " << x << ":" << y << ":" << z << " Layer " + << lay << " Index " << indx << ":" << type << " xx " << xx << " R " << r + << ":" << irad << ":" << hgpar_->radiusLayer_[type][irad - 1] << ":" + << hgpar_->radiusLayer_[type][irad] << " Phi " << phi << ":" << iphi + << ":" << (iphi - 0.5) * cell << " cell " << cell << " Dphi " << dphi + << " Dist " << dist << ":" << r * dphi; #endif - return HGCalParameters::k_ScaleToDDD*std::min(r*dphi,dist); + return HGCalParameters::k_ScaleToDDD * std::min(r * dphi, dist); } int HGCalDDDConstants::getLayer(double z, bool reco) const { - - //Get the layer # from the gloabl z coordinate - unsigned int k = 0; - double zz = (reco ? std::abs(z) : - HGCalParameters::k_ScaleFromDDD*std::abs(z)); + // Get the layer # from the gloabl z coordinate + unsigned int k = 0; + double zz = + (reco ? std::abs(z) : HGCalParameters::k_ScaleFromDDD * std::abs(z)); const auto& zLayerHex = hgpar_->zLayerHex_; - std::find_if(zLayerHex.begin()+1,zLayerHex.end(),[&k,&zz,&zLayerHex](double zLayer){ ++k; return zz < 0.5*(zLayerHex[k-1]+zLayerHex[k]);}); + std::find_if(zLayerHex.begin() + 1, zLayerHex.end(), + [&k, &zz, &zLayerHex](double zLayer) { + ++k; + return zz < 0.5 * (zLayerHex[k - 1] + zLayerHex[k]); + }); int lay = k; if (((mode_ == HGCalGeometryMode::Hexagon) || - (mode_ == HGCalGeometryMode::HexagonFull)) & reco) { - int indx = layerIndex(lay,false); + (mode_ == HGCalGeometryMode::HexagonFull)) & + reco) { + int indx = layerIndex(lay, false); if (indx >= 0) lay = hgpar_->layerGroup_[indx]; } else { lay += (hgpar_->firstLayer_ - 1); } return lay; } - -HGCalParameters::hgtrap HGCalDDDConstants::getModule(unsigned int indx, - bool hexType, - bool reco) const { +HGCalParameters::hgtrap HGCalDDDConstants::getModule(unsigned int indx, + bool hexType, + bool reco) const { HGCalParameters::hgtrap mytr; if (hexType) { if (indx >= hgpar_->waferTypeL_.size()) - edm::LogWarning("HGCalGeom") << "Wafer no. out bound for index " << indx - << ":" << (hgpar_->waferTypeL_).size() - << ":" << (hgpar_->waferPosX_).size() - << ":" << (hgpar_->waferPosY_).size() - << " ***** ERROR *****"; - unsigned int type = ((indx < hgpar_->waferTypeL_.size()) ? - hgpar_->waferTypeL_[indx] : 3); + edm::LogWarning("HGCalGeom") + << "Wafer no. out bound for index " << indx << ":" + << (hgpar_->waferTypeL_).size() << ":" << (hgpar_->waferPosX_).size() + << ":" << (hgpar_->waferPosY_).size() << " ***** ERROR *****"; + unsigned int type = + ((indx < hgpar_->waferTypeL_.size()) ? hgpar_->waferTypeL_[indx] : 3); if (type > 0) --type; mytr = hgpar_->getModule(type, reco); - } else { - mytr = hgpar_->getModule(indx,reco); + } else { + mytr = hgpar_->getModule(indx, reco); } return mytr; } std::vector HGCalDDDConstants::getModules() const { - std::vector mytrs; - for (unsigned int k=0; kmoduleLayR_.size(); ++k) - mytrs.emplace_back(hgpar_->getModule(k,true)); + for (unsigned int k = 0; k < hgpar_->moduleLayR_.size(); ++k) + mytrs.emplace_back(hgpar_->getModule(k, true)); return mytrs; } int HGCalDDDConstants::getPhiBins(int lay) const { - return ((mode_ == HGCalGeometryMode::Trapezoid) ? hgpar_->scintCells(lay) : 0); + return ((mode_ == HGCalGeometryMode::Trapezoid) ? hgpar_->scintCells(lay) + : 0); } -std::pair HGCalDDDConstants::getREtaRange(int lay) const { +std::pair HGCalDDDConstants::getREtaRange(int lay) const { int irmin(0), irmax(0); if (mode_ == HGCalGeometryMode::Trapezoid) { - int indx = layerIndex(lay,false); - if ((indx >=0) && (indx < static_cast(hgpar_->iradMinBH_.size()))) { + int indx = layerIndex(lay, false); + if ((indx >= 0) && (indx < static_cast(hgpar_->iradMinBH_.size()))) { irmin = hgpar_->iradMinBH_[indx]; irmax = hgpar_->iradMaxBH_[indx]; } } - return std::make_pair(irmin,irmax); + return std::make_pair(irmin, irmax); } std::vector HGCalDDDConstants::getTrForms() const { - std::vector mytrs; - for (unsigned int k=0; ktrformIndex_.size(); ++k) + for (unsigned int k = 0; k < hgpar_->trformIndex_.size(); ++k) mytrs.emplace_back(hgpar_->getTrForm(k)); return mytrs; } int HGCalDDDConstants::getTypeTrap(int layer) const { - //Get the module type for scinitllator + // Get the module type for scinitllator if (mode_ == HGCalGeometryMode::Trapezoid) { return hgpar_->scintType(layer); } else { @@ -445,12 +466,14 @@ int HGCalDDDConstants::getTypeTrap(int layer) const { } int HGCalDDDConstants::getTypeHex(int layer, int waferU, int waferV) const { - //Get the module type for a silicon wafer + // Get the module type for a silicon wafer if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(layer,waferU,waferV)); - return ((itr == hgpar_->typesInLayers_.end() ? 2 : - hgpar_->waferTypeL_[itr->second])); + auto itr = hgpar_->typesInLayers_.find( + HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + return ((itr == hgpar_->typesInLayers_.end() + ? 2 + : hgpar_->waferTypeL_[itr->second])); } else { return -1; } @@ -458,106 +481,104 @@ int HGCalDDDConstants::getTypeHex(int layer, int waferU, int waferV) const { bool HGCalDDDConstants::isHalfCell(int waferType, int cell) const { if (waferType < 1 || cell < 0) return false; - return waferType == 2 ? hgpar_->cellCoarseHalf_[cell] : hgpar_->cellFineHalf_[cell]; + return waferType == 2 ? hgpar_->cellCoarseHalf_[cell] + : hgpar_->cellFineHalf_[cell]; } -bool HGCalDDDConstants::isValidHex(int lay, int mod, int cell, +bool HGCalDDDConstants::isValidHex(int lay, int mod, int cell, bool reco) const { - //Check validity for a layer|wafer|cell of pre-TDR version + // Check validity for a layer|wafer|cell of pre-TDR version bool result(false), resultMod(false); - int cellmax(0); + int cellmax(0); if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { int32_t copyNumber = hgpar_->waferCopy_[mod]; result = ((lay > 0 && lay <= (int)(layers(reco)))); if (result) { - const int32_t lay_idx = reco ? (lay-1)*3 + 1 : lay; + const int32_t lay_idx = reco ? (lay - 1) * 3 + 1 : lay; const auto& the_modules = hgpar_->copiesInLayers_[lay_idx]; auto moditr = the_modules.find(copyNumber); result = resultMod = (moditr != the_modules.end()); #ifdef EDM_ML_DEBUG - if (!result) - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants: Layer " << lay - << ":" << lay_idx << " Copy " - << copyNumber << ":" << mod - << " Flag " << result; + if (!result) + edm::LogVerbatim("HGCalGeom") + << "HGCalDDDConstants: Layer " << lay << ":" << lay_idx << " Copy " + << copyNumber << ":" << mod << " Flag " << result; #endif if (result) { if (moditr->second >= 0) { if (mod >= (int)(hgpar_->waferTypeT_.size())) - edm::LogWarning("HGCalGeom") << "Module no. out of bound for " - << mod << " to be compared with " - << (hgpar_->waferTypeT_).size() - << " ***** ERROR *****"; - cellmax = ((hgpar_->waferTypeT_[mod]==1) ? - (int)(hgpar_->cellFineX_.size()) : - (int)(hgpar_->cellCoarseX_.size())); - result = (cell >=0 && cell <= cellmax); + edm::LogWarning("HGCalGeom") + << "Module no. out of bound for " << mod + << " to be compared with " << (hgpar_->waferTypeT_).size() + << " ***** ERROR *****"; + cellmax = ((hgpar_->waferTypeT_[mod] == 1) + ? (int)(hgpar_->cellFineX_.size()) + : (int)(hgpar_->cellCoarseX_.size())); + result = (cell >= 0 && cell <= cellmax); } else { result = isValidCell(lay_idx, mod, cell); } } } } - + #ifdef EDM_ML_DEBUG - if (!result) - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants: Layer " << lay << ":" - << (lay > 0 && (lay <= (int)(layers(reco)))) - << " Module " << mod << ":" << resultMod - << " Cell " << cell << ":" << cellmax << ":" - << (cell >=0 && cell <= cellmax) - << ":" << maxCells(reco); + if (!result) + edm::LogVerbatim("HGCalGeom") + << "HGCalDDDConstants: Layer " << lay << ":" + << (lay > 0 && (lay <= (int)(layers(reco)))) << " Module " << mod << ":" + << resultMod << " Cell " << cell << ":" << cellmax << ":" + << (cell >= 0 && cell <= cellmax) << ":" << maxCells(reco); #endif return result; } -bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, - int cellV) const { - //Check validity for a layer|wafer|cell of post-TDR version - int indx = HGCalWaferIndex::waferIndex(layer,modU,modV); - auto itr = hgpar_->typesInLayers_.find(indx); +bool HGCalDDDConstants::isValidHex8(int layer, int modU, int modV, int cellU, + int cellV) const { + // Check validity for a layer|wafer|cell of post-TDR version + int indx = HGCalWaferIndex::waferIndex(layer, modU, modV); + auto itr = hgpar_->typesInLayers_.find(indx); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:WaferType " - << layer << ":" << modU << ":" << modV << ":" - << indx << " Test " - << (itr == hgpar_->typesInLayers_.end()); + edm::LogVerbatim("HGCalGeom") + << "HGCalDDDConstants::isValidHex8:WaferType " << layer << ":" << modU + << ":" << modV << ":" << indx << " Test " + << (itr == hgpar_->typesInLayers_.end()); #endif if (itr == hgpar_->typesInLayers_.end()) return false; - auto jtr = waferIn_.find(indx); + auto jtr = waferIn_.find(indx); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:WaferIn " << jtr->first << ":" << jtr->second; #endif - if (!(jtr->second)) return false; - int N = ((hgpar_->waferTypeL_[itr->second] == 0) ? hgpar_->nCellsFine_ : - hgpar_->nCellsCoarse_); + if (!(jtr->second)) return false; + int N = ((hgpar_->waferTypeL_[itr->second] == 0) ? hgpar_->nCellsFine_ + : hgpar_->nCellsCoarse_); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants::isValidHex8:Cell " - << cellU << ":" << cellV << ":" << N - << " Tests " << (cellU >= 0) << ":" - << (cellU < 2*N) << ":" << (cellV >= 0) << ":" - << (cellV < 2*N) << ":" << ((cellV-cellU) < N) - << ":" << ((cellU-cellV) <= N); + edm::LogVerbatim("HGCalGeom") + << "HGCalDDDConstants::isValidHex8:Cell " << cellU << ":" << cellV << ":" + << N << " Tests " << (cellU >= 0) << ":" << (cellU < 2 * N) << ":" + << (cellV >= 0) << ":" << (cellV < 2 * N) << ":" << ((cellV - cellU) < N) + << ":" << ((cellU - cellV) <= N); #endif - if ((cellU >= 0) && (cellU < 2*N) && (cellV >= 0) && (cellV < 2*N)) { - return (((cellV-cellU) < N) && ((cellU-cellV) <= N)); + if ((cellU >= 0) && (cellU < 2 * N) && (cellV >= 0) && (cellV < 2 * N)) { + return (((cellV - cellU) < N) && ((cellU - cellV) <= N)); } else { return false; } } bool HGCalDDDConstants::isValidTrap(int layer, int irad, int iphi) const { - //Check validity for a layer|eta|phi of scintillator - const auto & indx = getIndex(layer,true); + // Check validity for a layer|eta|phi of scintillator + const auto& indx = getIndex(layer, true); if (indx.first < 0) return false; return ((irad >= hgpar_->iradMinBH_[indx.first]) && - (irad <= hgpar_->iradMaxBH_[indx.first]) && - (iphi > 0) && (iphi <= hgpar_->scintCells(layer))); + (irad <= hgpar_->iradMaxBH_[indx.first]) && (iphi > 0) && + (iphi <= hgpar_->scintCells(layer))); } int HGCalDDDConstants::lastLayer(bool reco) const { - return (hgpar_->firstLayer_+tot_layers_[(int)reco]-1); + return (hgpar_->firstLayer_ + tot_layers_[(int)reco] - 1); } unsigned int HGCalDDDConstants::layers(bool reco) const { @@ -566,10 +587,10 @@ unsigned int HGCalDDDConstants::layers(bool reco) const { int HGCalDDDConstants::layerIndex(int lay, bool reco) const { int ll = lay - hgpar_->firstLayer_; - if (ll<0 || ll>=(int)(hgpar_->layerIndex_.size())) return -1; + if (ll < 0 || ll >= (int)(hgpar_->layerIndex_.size())) return -1; if ((mode_ == HGCalGeometryMode::Hexagon) || - (mode_ == HGCalGeometryMode::HexagonFull)) { - if (reco && ll>=(int)(hgpar_->depthIndex_.size())) return -1; + (mode_ == HGCalGeometryMode::HexagonFull)) { + if (reco && ll >= (int)(hgpar_->depthIndex_.size())) return -1; return (reco ? hgpar_->depthLayerF_[ll] : hgpar_->layerIndex_[ll]); } else { return (hgpar_->layerIndex_[ll]); @@ -580,54 +601,56 @@ unsigned int HGCalDDDConstants::layersInit(bool reco) const { return (reco ? hgpar_->depthIndex_.size() : hgpar_->layerIndex_.size()); } -std::pair HGCalDDDConstants::locateCell(int cell, int lay, - int type, bool reco) const { +std::pair HGCalDDDConstants::locateCell(int cell, int lay, + int type, + bool reco) const { // type refers to wafer # for hexagon cell float x(999999.), y(999999.); - const auto & index = getIndex(lay, reco); + const auto& index = getIndex(lay, reco); int i = index.first; - if (i < 0) return std::make_pair(x,y); + if (i < 0) return std::make_pair(x, y); if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - x = hgpar_->waferPosX_[type]; - y = hgpar_->waferPosY_[type]; + x = hgpar_->waferPosX_[type]; + y = hgpar_->waferPosY_[type]; if (hgpar_->waferTypeT_[type] == 1) { - x += hgpar_->cellFineX_[cell]; - y += hgpar_->cellFineY_[cell]; + x += hgpar_->cellFineX_[cell]; + y += hgpar_->cellFineY_[cell]; } else { - x += hgpar_->cellCoarseX_[cell]; - y += hgpar_->cellCoarseY_[cell]; + x += hgpar_->cellCoarseX_[cell]; + y += hgpar_->cellCoarseY_[cell]; } if (!reco) { - x *= HGCalParameters::k_ScaleToDDD; - y *= HGCalParameters::k_ScaleToDDD; + x *= HGCalParameters::k_ScaleToDDD; + y *= HGCalParameters::k_ScaleToDDD; } } - return std::make_pair(x,y); + return std::make_pair(x, y); } -std::pair HGCalDDDConstants::locateCell(int lay, int waferU, - int waferV, int cellU, - int cellV, bool reco, - bool all, bool +std::pair HGCalDDDConstants::locateCell(int lay, int waferU, + int waferV, int cellU, + int cellV, bool reco, + bool all, + bool #ifdef EDM_ML_DEBUG - debug + debug #endif - ) const { + ) const { float x(0), y(0); - int indx = HGCalWaferIndex::waferIndex(lay,waferU,waferV); - auto itr = hgpar_->typesInLayers_.find(indx); - int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : - hgpar_->waferTypeL_[itr->second]); + int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV); + auto itr = hgpar_->typesInLayers_.find(indx); + int type = ((itr == hgpar_->typesInLayers_.end()) + ? 2 + : hgpar_->waferTypeL_[itr->second]); #ifdef EDM_ML_DEBUG - if (debug) - edm::LogVerbatim("HGCalGeom") << "LocateCell " << lay << ":" << waferU - << ":" << waferV << ":" << indx << ":" - << (itr == hgpar_->typesInLayers_.end()) - << ":" << type; + if (debug) + edm::LogVerbatim("HGCalGeom") + << "LocateCell " << lay << ":" << waferU << ":" << waferV << ":" << indx + << ":" << (itr == hgpar_->typesInLayers_.end()) << ":" << type; #endif - int kndx = cellV*100 + cellU; + int kndx = cellV * 100 + cellU; if (type == 0) { auto ktr = hgpar_->cellFineIndex_.find(kndx); if (ktr != hgpar_->cellFineIndex_.end()) { @@ -635,10 +658,10 @@ std::pair HGCalDDDConstants::locateCell(int lay, int waferU, y = hgpar_->cellFineY_[ktr->second]; } #ifdef EDM_ML_DEBUG - if (debug) - edm::LogVerbatim("HGCalGeom") << "Fine " << cellU << ":" << cellV << ":" - << kndx << ":" << x << ":" << y << ":" - << (ktr != hgpar_->cellFineIndex_.end()); + if (debug) + edm::LogVerbatim("HGCalGeom") + << "Fine " << cellU << ":" << cellV << ":" << kndx << ":" << x << ":" + << y << ":" << (ktr != hgpar_->cellFineIndex_.end()); #endif } else { auto ktr = hgpar_->cellCoarseIndex_.find(kndx); @@ -647,10 +670,10 @@ std::pair HGCalDDDConstants::locateCell(int lay, int waferU, y = hgpar_->cellCoarseY_[ktr->second]; } #ifdef EDM_ML_DEBUG - if (debug) - edm::LogVerbatim("HGCalGeom") << "Coarse " << cellU << ":" << cellV <<":" - << kndx << ":" << x << ":" << y << ":" - << (ktr != hgpar_->cellCoarseIndex_.end()); + if (debug) + edm::LogVerbatim("HGCalGeom") + << "Coarse " << cellU << ":" << cellV << ":" << kndx << ":" << x + << ":" << y << ":" << (ktr != hgpar_->cellCoarseIndex_.end()); #endif } if (!reco) { @@ -658,58 +681,58 @@ std::pair HGCalDDDConstants::locateCell(int lay, int waferU, y *= HGCalParameters::k_ScaleToDDD; } if (all) { - const auto & xy = waferPosition(waferU, waferV, reco); + const auto& xy = waferPosition(waferU, waferV, reco); x += xy.first; y += xy.second; #ifdef EDM_ML_DEBUG - if (debug) + if (debug) edm::LogVerbatim("HGCalGeom") << "With wafer " << x << ":" << y << ":" << xy.first << ":" << xy.second; #endif } - return std::make_pair(x,y); + return std::make_pair(x, y); } -std::pair HGCalDDDConstants::locateCellHex(int cell, int wafer, - bool reco) const { +std::pair HGCalDDDConstants::locateCellHex(int cell, int wafer, + bool reco) const { float x(0), y(0); if (hgpar_->waferTypeT_[wafer] == 1) { - x = hgpar_->cellFineX_[cell]; - y = hgpar_->cellFineY_[cell]; + x = hgpar_->cellFineX_[cell]; + y = hgpar_->cellFineY_[cell]; } else { - x = hgpar_->cellCoarseX_[cell]; - y = hgpar_->cellCoarseY_[cell]; + x = hgpar_->cellCoarseX_[cell]; + y = hgpar_->cellCoarseY_[cell]; } if (!reco) { x *= HGCalParameters::k_ScaleToDDD; y *= HGCalParameters::k_ScaleToDDD; } - return std::make_pair(x,y); + return std::make_pair(x, y); } -std::pair HGCalDDDConstants::locateCellTrap(int lay, int irad, - int iphi, bool reco) const { - +std::pair HGCalDDDConstants::locateCellTrap(int lay, int irad, + int iphi, + bool reco) const { float x(0), y(0); - const auto & indx = getIndex(lay,reco); + const auto& indx = getIndex(lay, reco); if (indx.first >= 0) { - int ir = std::abs(irad); - int type = hgpar_->scintType(lay); - double phi = (iphi-0.5)*indx.second; - double z = hgpar_->zLayerHex_[indx.first]; - double r = 0.5*(hgpar_->radiusLayer_[type][ir-1] + - hgpar_->radiusLayer_[type][ir]); - std::pair range = rangeR(z,true); - r = std::max(range.first, std::min(r,range.second)); - x = r*std::cos(phi); - y = r*std::sin(phi); - if (irad < 0) x =-x; + int ir = std::abs(irad); + int type = hgpar_->scintType(lay); + double phi = (iphi - 0.5) * indx.second; + double z = hgpar_->zLayerHex_[indx.first]; + double r = 0.5 * (hgpar_->radiusLayer_[type][ir - 1] + + hgpar_->radiusLayer_[type][ir]); + std::pair range = rangeR(z, true); + r = std::max(range.first, std::min(r, range.second)); + x = r * std::cos(phi); + y = r * std::sin(phi); + if (irad < 0) x = -x; } if (!reco) { x *= HGCalParameters::k_ScaleToDDD; y *= HGCalParameters::k_ScaleToDDD; } - return std::make_pair(x,y); + return std::make_pair(x, y); } bool HGCalDDDConstants::maskCell(const DetId& detId, int corners) const { @@ -720,100 +743,117 @@ bool HGCalDDDConstants::maskCell(const DetId& detId, int corners) const { int N(0), layer(0), waferU(0), waferV(0), u(0), v(0); if (detId.det() == DetId::Forward) { HFNoseDetId id(detId); - N = getUVMax(id.type()); - layer = id.layer(); + N = getUVMax(id.type()); + layer = id.layer(); waferU = id.waferU(); waferV = id.waferV(); - u = id.cellU(); - v = id.cellV(); + u = id.cellU(); + v = id.cellV(); } else { HGCSiliconDetId id(detId); - N = getUVMax(id.type()); - layer = id.layer(); + N = getUVMax(id.type()); + layer = id.layer(); waferU = id.waferU(); waferV = id.waferV(); - u = id.cellU(); - v = id.cellV(); + u = id.cellU(); + v = id.cellV(); } - int wl = HGCalWaferIndex::waferIndex(layer,waferU,waferV); + int wl = HGCalWaferIndex::waferIndex(layer, waferU, waferV); auto itr = hgpar_->waferTypes_.find(wl); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "MaskCell: Layer " << layer - << " Wafer " << waferU << ":" - << waferV << " Index " << wl << ":" - << (itr != hgpar_->waferTypes_.end()); + edm::LogVerbatim("HGCalGeom") + << "MaskCell: Layer " << layer << " Wafer " << waferU << ":" << waferV + << " Index " << wl << ":" << (itr != hgpar_->waferTypes_.end()); #endif if (itr != hgpar_->waferTypes_.end()) { int ncor = (itr->second).first; int fcor = (itr->second).second; if (ncor < corners) { - mask = true; + mask = true; } else { if (ncor == 4) { switch (fcor) { - case(0): { mask = (v >= N); break; } - case(1): { mask = (u >= N); break; } - case(2): { mask = (u <= v); break; } - case(3): { mask = (v < N); break; } - case(4): { mask = (u < N); break; } - default: { mask = (u > v); break; } + case (0): { + mask = (v >= N); + break; + } + case (1): { + mask = (u >= N); + break; + } + case (2): { + mask = (u <= v); + break; + } + case (3): { + mask = (v < N); + break; + } + case (4): { + mask = (u < N); + break; + } + default: { + mask = (u > v); + break; + } } } else { switch (fcor) { - case(0): { + case (0): { if (ncor == 3) { - mask = !((u > 2*v) && (v < N)); + mask = !((u > 2 * v) && (v < N)); } else { - mask = ((u >= N) && (v >= N) && ((u+v) > (3*N-2))); + mask = ((u >= N) && (v >= N) && ((u + v) > (3 * N - 2))); } - break; + break; } - case(1): { + case (1): { if (ncor == 3) { - mask = !((u+v) < N); + mask = !((u + v) < N); } else { - mask = ((u >= N) && (u > v) && ((2*u-v) > 2*N)); + mask = ((u >= N) && (u > v) && ((2 * u - v) > 2 * N)); } - break; + break; } - case(2): { + case (2): { if (ncor == 3) { - mask = !((u < N) && (v > u) && (v > (2*u-1))); + mask = !((u < N) && (v > u) && (v > (2 * u - 1))); } else { - mask = ((u > 2*v) && (v < N)); + mask = ((u > 2 * v) && (v < N)); } - break; + break; } - case(3): { + case (3): { if (ncor == 3) { - mask = !((v >= u) && ((2*v-u) > (2*N-2))); + mask = !((v >= u) && ((2 * v - u) > (2 * N - 2))); } else { - mask = ((u+v) < N); + mask = ((u + v) < N); } - break; + break; } - case(4) : { + case (4): { if (ncor == 3) { - mask = !((u >= N) && (v >= N) && ((u+v) > (3*N-2))); + mask = !((u >= N) && (v >= N) && ((u + v) > (3 * N - 2))); } else { - mask = ((u < N) && (v > u) && (v > (2*u-1))); + mask = ((u < N) && (v > u) && (v > (2 * u - 1))); } - break; + break; } - default: { + default: { if (ncor == 3) { - mask = !((u >= N) && (u > v) && ((2*u-v) > 2*N)); + mask = !((u >= N) && (u > v) && ((2 * u - v) > 2 * N)); } else { - mask = ((v >= u) && ((2*v-u) > (2*N-2))); + mask = ((v >= u) && ((2 * v - u) > (2 * N - 2))); } break; } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Corners: " << ncor << ":" << fcor - << " N " << N << " u " << u << " v " - << v << " Mask " << mask; + edm::LogVerbatim("HGCalGeom") + << "Corners: " << ncor << ":" << fcor << " N " << N << " u " << u + << " v " << v << " Mask " << mask; #endif } } @@ -823,9 +863,8 @@ bool HGCalDDDConstants::maskCell(const DetId& detId, int corners) const { } int HGCalDDDConstants::maxCells(bool reco) const { - int cells(0); - for (unsigned int i = 0; idepth_[i] : hgpar_->layer_[i]; if (cells < maxCells(lay, reco)) cells = maxCells(lay, reco); } @@ -833,16 +872,16 @@ int HGCalDDDConstants::maxCells(bool reco) const { } int HGCalDDDConstants::maxCells(int lay, bool reco) const { - - const auto & index = getIndex(lay, reco); + const auto& index = getIndex(lay, reco); if (index.first < 0) return 0; if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { unsigned int cells(0); - for (unsigned int k=0; kwaferTypeT_.size(); ++k) { - if (waferInLayerTest(k,index.first,hgpar_->defineFull_)) { - unsigned int cell = (hgpar_->waferTypeT_[k]==1) ? - (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size()); + for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) { + if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) { + unsigned int cell = (hgpar_->waferTypeT_[k] == 1) + ? (hgpar_->cellFineX_.size()) + : (hgpar_->cellCoarseX_.size()); if (cell > cells) cells = cell; } } @@ -850,111 +889,116 @@ int HGCalDDDConstants::maxCells(int lay, bool reco) const { } else if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { int cells(0); - for (unsigned int k=0; kwaferCopy_.size(); ++k) { - if (waferInLayerTest(k,index.first,hgpar_->defineFull_)) { - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(lay,HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]),HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]))); - int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : - hgpar_->waferTypeL_[itr->second]); - int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; - cells = std::max(cells,3*N*N); + for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) { + if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) { + auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex( + lay, HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]), + HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]))); + int type = ((itr == hgpar_->typesInLayers_.end()) + ? 2 + : hgpar_->waferTypeL_[itr->second]); + int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; + cells = std::max(cells, 3 * N * N); } } return cells; } else if (mode_ == HGCalGeometryMode::Trapezoid) { - return hgpar_->scintCells(index.first+hgpar_->firstLayer_); + return hgpar_->scintCells(index.first + hgpar_->firstLayer_); } else { return 0; } } int HGCalDDDConstants::maxRows(int lay, bool reco) const { - int kymax(0); - const auto & index = getIndex(lay, reco); + const auto& index = getIndex(lay, reco); int i = index.first; if (i < 0) return kymax; if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - for (unsigned int k=0; kwaferCopy_.size(); ++k) { - if (waferInLayerTest(k,i,hgpar_->defineFull_)) { - int ky = ((hgpar_->waferCopy_[k])/100)%100; + for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) { + if (waferInLayerTest(k, i, hgpar_->defineFull_)) { + int ky = ((hgpar_->waferCopy_[k]) / 100) % 100; if (ky > kymax) kymax = ky; } } } else if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - kymax = 1+2*hgpar_->waferUVMaxLayer_[index.first]; + kymax = 1 + 2 * hgpar_->waferUVMaxLayer_[index.first]; } return kymax; } int HGCalDDDConstants::modifyUV(int uv, int type1, int type2) const { // Modify u/v for transition of type1 to type2 - return (((type1==type2) || (type1*type2 !=0)) ? uv : - ((type1==0) ? (2*uv+1)/3 : (3*uv)/2)); + return (((type1 == type2) || (type1 * type2 != 0)) + ? uv + : ((type1 == 0) ? (2 * uv + 1) / 3 : (3 * uv) / 2)); } int HGCalDDDConstants::modules(int lay, bool reco) const { - if (getIndex(lay,reco).first < 0) return 0; - else return max_modules_layer_[(int)reco][lay]; + if (getIndex(lay, reco).first < 0) + return 0; + else + return max_modules_layer_[(int)reco][lay]; } int HGCalDDDConstants::modulesInit(int lay, bool reco) const { int nmod(0); - const auto & index = getIndex(lay, reco); + const auto& index = getIndex(lay, reco); if (index.first < 0) return nmod; if (mode_ != HGCalGeometryMode::Trapezoid) { - for (unsigned int k=0; kwaferPosX_.size(); ++k) { - if (waferInLayerTest(k,index.first,hgpar_->defineFull_)) ++nmod; + for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) { + if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) ++nmod; } } else { - nmod = 1+hgpar_->lastModule_[index.first]-hgpar_->firstModule_[index.first]; + nmod = 1 + hgpar_->lastModule_[index.first] - + hgpar_->firstModule_[index.first]; } return nmod; } double HGCalDDDConstants::mouseBite(bool reco) const { - - return (reco ? hgpar_->mouseBite_ : HGCalParameters::k_ScaleToDDD*hgpar_->mouseBite_); + return (reco ? hgpar_->mouseBite_ + : HGCalParameters::k_ScaleToDDD * hgpar_->mouseBite_); } int HGCalDDDConstants::numberCells(bool reco) const { - int cells(0); unsigned int nlayer = (reco) ? hgpar_->depth_.size() : hgpar_->layer_.size(); - for (unsigned k=0; k ncells = numberCells(((reco) ? hgpar_->depth_[k] : hgpar_->layer_[k]), reco); - cells = std::accumulate(ncells.begin(),ncells.end(),cells); + for (unsigned k = 0; k < nlayer; ++k) { + std::vector ncells = + numberCells(((reco) ? hgpar_->depth_[k] : hgpar_->layer_[k]), reco); + cells = std::accumulate(ncells.begin(), ncells.end(), cells); } return cells; } std::vector HGCalDDDConstants::numberCells(int lay, bool reco) const { - - const auto & index = getIndex(lay, reco); + const auto& index = getIndex(lay, reco); int i = index.first; std::vector ncell; if (i >= 0) { if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - for (unsigned int k=0; kwaferTypeT_.size(); ++k) { - if (waferInLayerTest(k,i,hgpar_->defineFull_)) { - unsigned int cell = (hgpar_->waferTypeT_[k]==1) ? - (hgpar_->cellFineX_.size()) : (hgpar_->cellCoarseX_.size()); + for (unsigned int k = 0; k < hgpar_->waferTypeT_.size(); ++k) { + if (waferInLayerTest(k, i, hgpar_->defineFull_)) { + unsigned int cell = (hgpar_->waferTypeT_[k] == 1) + ? (hgpar_->cellFineX_.size()) + : (hgpar_->cellCoarseX_.size()); ncell.emplace_back((int)(cell)); } } } else if (mode_ == HGCalGeometryMode::Trapezoid) { int nphi = hgpar_->scintCells(lay); - for (int k=hgpar_->firstModule_[i]; k<=hgpar_->lastModule_[i]; ++k) + for (int k = hgpar_->firstModule_[i]; k <= hgpar_->lastModule_[i]; ++k) ncell.emplace_back(nphi); } else { - for (unsigned int k=0; kwaferCopy_.size(); ++k) { - if (waferInLayerTest(k,index.first,hgpar_->defineFull_)) { - int cell = numberCellsHexagon(lay, - HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]), - HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]), - true); + for (unsigned int k = 0; k < hgpar_->waferCopy_.size(); ++k) { + if (waferInLayerTest(k, index.first, hgpar_->defineFull_)) { + int cell = numberCellsHexagon( + lay, HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]), + HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]), true); ncell.emplace_back(cell); } } @@ -964,11 +1008,10 @@ std::vector HGCalDDDConstants::numberCells(int lay, bool reco) const { } int HGCalDDDConstants::numberCellsHexagon(int wafer) const { - if (wafer >= 0 && wafer < (int)(hgpar_->waferTypeT_.size())) { - if (hgpar_->waferTypeT_[wafer]==1) + if (hgpar_->waferTypeT_[wafer] == 1) return (int)(hgpar_->cellFineX_.size()); - else + else return (int)(hgpar_->cellCoarseX_.size()); } else { return 0; @@ -977,36 +1020,38 @@ int HGCalDDDConstants::numberCellsHexagon(int wafer) const { int HGCalDDDConstants::numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const { - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(lay,waferU,waferV)); - int type = ((itr == hgpar_->typesInLayers_.end()) ? 2 : - hgpar_->waferTypeL_[itr->second]); - int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; - if (flag) return (3*N*N); - else return N; + auto itr = hgpar_->typesInLayers_.find( + HGCalWaferIndex::waferIndex(lay, waferU, waferV)); + int type = ((itr == hgpar_->typesInLayers_.end()) + ? 2 + : hgpar_->waferTypeL_[itr->second]); + int N = (type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; + if (flag) + return (3 * N * N); + else + return N; } -std::pair HGCalDDDConstants::rangeR(double z, bool reco) const { +std::pair HGCalDDDConstants::rangeR(double z, bool reco) const { double rmin(0), rmax(0), zz(0); if (hgpar_->detectorType_ > 0) { - zz = (reco ? std::abs(z) : HGCalParameters::k_ScaleFromDDD*std::abs(z)); + zz = (reco ? std::abs(z) : HGCalParameters::k_ScaleFromDDD * std::abs(z)); if (hgpar_->detectorType_ <= 2) { - rmin = HGCalGeomTools::radius(zz,hgpar_->zFrontMin_, - hgpar_->rMinFront_, hgpar_->slopeMin_); + rmin = HGCalGeomTools::radius(zz, hgpar_->zFrontMin_, hgpar_->rMinFront_, + hgpar_->slopeMin_); } else { - rmin = HGCalGeomTools::radius(zz, hgpar_->firstLayer_, - hgpar_->firstMixedLayer_, - hgpar_->zLayerHex_, - hgpar_->radiusMixBoundary_); + rmin = HGCalGeomTools::radius( + zz, hgpar_->firstLayer_, hgpar_->firstMixedLayer_, hgpar_->zLayerHex_, + hgpar_->radiusMixBoundary_); } - if ((hgpar_->detectorType_ == 2) && + if ((hgpar_->detectorType_ == 2) && (zz >= hgpar_->zLayerHex_[hgpar_->firstMixedLayer_ - 1])) { - rmax = HGCalGeomTools::radius(zz, hgpar_->firstLayer_, - hgpar_->firstMixedLayer_, - hgpar_->zLayerHex_, - hgpar_->radiusMixBoundary_); + rmax = HGCalGeomTools::radius( + zz, hgpar_->firstLayer_, hgpar_->firstMixedLayer_, hgpar_->zLayerHex_, + hgpar_->radiusMixBoundary_); } else { - rmax = HGCalGeomTools::radius(zz, hgpar_->zFrontTop_, - hgpar_->rMaxFront_, hgpar_->slopeTop_); + rmax = HGCalGeomTools::radius(zz, hgpar_->zFrontTop_, hgpar_->rMaxFront_, + hgpar_->slopeTop_); } } if (!reco) { @@ -1017,59 +1062,57 @@ std::pair HGCalDDDConstants::rangeR(double z, bool reco) const { edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeR: " << z << ":" << zz << " R " << rmin << ":" << rmax; #endif - return std::pair(rmin,rmax); + return std::pair(rmin, rmax); } -std::pair HGCalDDDConstants::rangeZ(bool reco) const { +std::pair HGCalDDDConstants::rangeZ(bool reco) const { double zmin = (hgpar_->zLayerHex_[0] - hgpar_->waferThick_); - double zmax = (hgpar_->zLayerHex_[hgpar_->zLayerHex_.size()-1] + - hgpar_->waferThick_); + double zmax = + (hgpar_->zLayerHex_[hgpar_->zLayerHex_.size() - 1] + hgpar_->waferThick_); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeZ: " << zmin << ":" + edm::LogVerbatim("HGCalGeom") << "HGCalDDDConstants:rangeZ: " << zmin << ":" << zmax << ":" << hgpar_->waferThick_; #endif if (!reco) { zmin *= HGCalParameters::k_ScaleToDDD; zmax *= HGCalParameters::k_ScaleToDDD; } - return std::pair(zmin,zmax); + return std::pair(zmin, zmax); } -std::pair HGCalDDDConstants::rowColumnWafer(int wafer) const { +std::pair HGCalDDDConstants::rowColumnWafer(int wafer) const { int row(0), col(0); if (wafer < (int)(hgpar_->waferCopy_.size())) { int copy = hgpar_->waferCopy_[wafer]; - col = copy%100; - if ((copy/10000)%10 != 0) col = -col; - row = (copy/100)%100; - if ((copy/100000)%10 != 0) row = -row; + col = copy % 100; + if ((copy / 10000) % 10 != 0) col = -col; + row = (copy / 100) % 100; + if ((copy / 100000) % 10 != 0) row = -row; } - return std::make_pair(row,col); + return std::make_pair(row, col); } -std::pair HGCalDDDConstants::simToReco(int cell, int lay, int mod, - bool half) const { - +std::pair HGCalDDDConstants::simToReco(int cell, int lay, int mod, + bool half) const { if ((mode_ != HGCalGeometryMode::Hexagon) && (mode_ != HGCalGeometryMode::HexagonFull)) { - return std::make_pair(cell,lay); + return std::make_pair(cell, lay); } else { - const auto & index = getIndex(lay, false); + const auto& index = getIndex(lay, false); int i = index.first; if (i < 0) { - edm::LogWarning("HGCalGeom") << "Wrong Layer # " << lay - << " not in the list ***** ERROR *****"; - return std::make_pair(-1,-1); + edm::LogWarning("HGCalGeom") + << "Wrong Layer # " << lay << " not in the list ***** ERROR *****"; + return std::make_pair(-1, -1); } if (mod >= (int)(hgpar_->waferTypeL_).size()) { - edm::LogWarning("HGCalGeom") << "Invalid Wafer # " << mod - << "should be < " - << (hgpar_->waferTypeL_).size() - << " ***** ERROR *****"; - return std::make_pair(-1,-1); + edm::LogWarning("HGCalGeom") + << "Invalid Wafer # " << mod << "should be < " + << (hgpar_->waferTypeL_).size() << " ***** ERROR *****"; + return std::make_pair(-1, -1); } int depth(-1); - int kx = cell; + int kx = cell; int type = hgpar_->waferTypeL_[mod]; if (type == 1) { depth = hgpar_->layerGroup_[i]; @@ -1077,18 +1120,18 @@ std::pair HGCalDDDConstants::simToReco(int cell, int lay, int mod, depth = hgpar_->layerGroupM_[i]; } else { depth = hgpar_->layerGroupO_[i]; - } - return std::make_pair(kx,depth); + } + return std::make_pair(kx, depth); } } int HGCalDDDConstants::waferFromCopy(int copy) const { const int ncopies = hgpar_->waferCopy_.size(); - int wafer(ncopies); + int wafer(ncopies); bool result(false); - for (int k=0; kwaferCopy_[k]) { - wafer = k; + wafer = k; result = true; break; } @@ -1096,94 +1139,97 @@ int HGCalDDDConstants::waferFromCopy(int copy) const { if (!result) { wafer = -1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Cannot find " << copy << " in a list of " - << ncopies << " members"; - for (int k=0; kwaferCopy_[k]; + edm::LogVerbatim("HGCalGeom") + << "Cannot find " << copy << " in a list of " << ncopies << " members"; + for (int k = 0; k < ncopies; ++k) + edm::LogVerbatim("HGCalGeom") + << "[" << k << "] " << hgpar_->waferCopy_[k]; #endif } return wafer; } void HGCalDDDConstants::waferFromPosition(const double x, const double y, - int& wafer, int& icell, + int& wafer, int& icell, int& celltyp) const { - //Input x, y in Geant4 unit and transformed to CMSSW standard - double xx = HGCalParameters::k_ScaleFromDDD*x; - double yy = HGCalParameters::k_ScaleFromDDD*y; + // Input x, y in Geant4 unit and transformed to CMSSW standard + double xx = HGCalParameters::k_ScaleFromDDD * x; + double yy = HGCalParameters::k_ScaleFromDDD * y; int size_ = (int)(hgpar_->waferCopy_.size()); - wafer = size_; - for (int k=0; kwaferPosX_[k]); - double dy = std::abs(yy-hgpar_->waferPosY_[k]); + wafer = size_; + for (int k = 0; k < size_; ++k) { + double dx = std::abs(xx - hgpar_->waferPosX_[k]); + double dy = std::abs(yy - hgpar_->waferPosY_[k]); if (dx <= rmax_ && dy <= hexside_) { - if ((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy))) { - wafer = k; + if ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy))) { + wafer = k; celltyp = hgpar_->waferTypeT_[k]; - xx -= hgpar_->waferPosX_[k]; - yy -= hgpar_->waferPosY_[k]; + xx -= hgpar_->waferPosX_[k]; + yy -= hgpar_->waferPosY_[k]; break; } } } if (wafer < size_) { - if (celltyp == 1) - icell = cellHex(xx, yy, 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[0], - hgpar_->cellFineX_, hgpar_->cellFineY_); + if (celltyp == 1) + icell = cellHex( + xx, yy, 0.5 * HGCalParameters::k_ScaleFromDDD * hgpar_->cellSize_[0], + hgpar_->cellFineX_, hgpar_->cellFineY_); else - icell = cellHex(xx, yy, 0.5*HGCalParameters::k_ScaleFromDDD*hgpar_->cellSize_[1], - hgpar_->cellCoarseX_, hgpar_->cellCoarseY_); + icell = cellHex( + xx, yy, 0.5 * HGCalParameters::k_ScaleFromDDD * hgpar_->cellSize_[1], + hgpar_->cellCoarseX_, hgpar_->cellCoarseY_); } else { wafer = -1; #ifdef EDM_ML_DEBUG - edm::LogWarning("HGCalGeom") << "Cannot get wafer type corresponding to " + edm::LogWarning("HGCalGeom") << "Cannot get wafer type corresponding to " << x << ":" << y << " " << xx << ":" << yy; #endif } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Position " << x << ":" << y << " Wafer " - << wafer << ":" << size_ << " XX " << xx << ":" - << yy << " Cell " << icell << " Type " << celltyp; + edm::LogVerbatim("HGCalGeom") + << "Position " << x << ":" << y << " Wafer " << wafer << ":" << size_ + << " XX " << xx << ":" << yy << " Cell " << icell << " Type " << celltyp; #endif } void HGCalDDDConstants::waferFromPosition(const double x, const double y, const int layer, int& waferU, int& waferV, int& cellU, int& cellV, - int& celltype, double& wt, bool + int& celltype, double& wt, + bool #ifdef EDM_ML_DEBUG - debug + debug #endif - ) const { - - double xx(HGCalParameters::k_ScaleFromDDD*x); - double yy(HGCalParameters::k_ScaleFromDDD*y); - waferU = waferV = 1+hgpar_->waferUVMax_; - for (unsigned int k=0; kwaferPosX_.size(); ++k) { - double dx = std::abs(xx-hgpar_->waferPosX_[k]); - double dy = std::abs(yy-hgpar_->waferPosY_[k]); + ) const { + + double xx(HGCalParameters::k_ScaleFromDDD * x); + double yy(HGCalParameters::k_ScaleFromDDD * y); + waferU = waferV = 1 + hgpar_->waferUVMax_; + for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) { + double dx = std::abs(xx - hgpar_->waferPosX_[k]); + double dy = std::abs(yy - hgpar_->waferPosY_[k]); if (dx <= rmax_ && dy <= hexside_) { - if ((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy))) { - waferU = HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]); - waferV = HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]); - auto itr = hgpar_->typesInLayers_.find(HGCalWaferIndex::waferIndex(layer,waferU,waferV)); - celltype = ((itr == hgpar_->typesInLayers_.end()) ? 2 : - hgpar_->waferTypeL_[itr->second]); + if ((dy <= 0.5 * hexside_) || (dx * tan30deg_ <= (hexside_ - dy))) { + waferU = HGCalWaferIndex::waferU(hgpar_->waferCopy_[k]); + waferV = HGCalWaferIndex::waferV(hgpar_->waferCopy_[k]); + auto itr = hgpar_->typesInLayers_.find( + HGCalWaferIndex::waferIndex(layer, waferU, waferV)); + celltype = ((itr == hgpar_->typesInLayers_.end()) + ? 2 + : hgpar_->waferTypeL_[itr->second]); #ifdef EDM_ML_DEBUG - if (debug) - edm::LogVerbatim("HGCalGeom") << "WaferFromPosition:: Input " << xx - << ":" << yy << " compared with " - << hgpar_->waferPosX_[k] << ":" - << hgpar_->waferPosY_[k] - << " difference " << dx << ":" << dy - << ":" << dx*tan30deg_ << ":" - << (hexside_-dy) << " comparator " - << rmax_ << ":" << hexside_ <<" wafer " - << waferU << ":" << waferV << ":" - << celltype; + if (debug) + edm::LogVerbatim("HGCalGeom") + << "WaferFromPosition:: Input " << xx << ":" << yy + << " compared with " << hgpar_->waferPosX_[k] << ":" + << hgpar_->waferPosY_[k] << " difference " << dx << ":" << dy + << ":" << dx * tan30deg_ << ":" << (hexside_ - dy) + << " comparator " << rmax_ << ":" << hexside_ << " wafer " + << waferU << ":" << waferV << ":" << celltype; #endif - xx -= hgpar_->waferPosX_[k]; - yy -= hgpar_->waferPosY_[k]; + xx -= hgpar_->waferPosX_[k]; + yy -= hgpar_->waferPosY_[k]; break; } } @@ -1191,55 +1237,53 @@ void HGCalDDDConstants::waferFromPosition(const double x, const double y, if (std::abs(waferU) <= hgpar_->waferUVMax_) { cellHex(xx, yy, celltype, cellU, cellV #ifdef EDM_ML_DEBUG - , debug + , + debug #endif - ); - wt = ((celltype < 2) ? - (hgpar_->cellThickness_[celltype]/hgpar_->waferThick_) : 1.0); + ); + wt = ((celltype < 2) + ? (hgpar_->cellThickness_[celltype] / hgpar_->waferThick_) + : 1.0); } else { - cellU = cellV = 2*hgpar_->nCellsFine_; - wt = 1.0; - celltype =-1; + cellU = cellV = 2 * hgpar_->nCellsFine_; + wt = 1.0; + celltype = -1; } #ifdef EDM_ML_DEBUG if (celltype < 0) { - double x1(HGCalParameters::k_ScaleFromDDD*x); - double y1(HGCalParameters::k_ScaleFromDDD*y); - edm::LogVerbatim("HGCalGeom") << "waferFromPosition: Bad type for X " - << x << ":" << x1 << ":" << xx << " Y " << y - << ":" << y1 << ":" << yy << " Wafer " - << waferU << ":" << waferV << " Cell " - << cellU << ":" << cellV; - for (unsigned int k=0; kwaferPosX_.size(); ++k) { - double dx = std::abs(x1-hgpar_->waferPosX_[k]); - double dy = std::abs(y1-hgpar_->waferPosY_[k]); - edm::LogVerbatim("HGCalGeom") << "Wafer [" << k << "] Position (" - << hgpar_->waferPosX_[k] << ", " - << hgpar_->waferPosY_[k] << ") difference " - << dx << ":" << dy << ":" << dx*tan30deg_ - << ":" << hexside_-dy << " Paramerers " - << rmax_ << ":" << hexside_; + double x1(HGCalParameters::k_ScaleFromDDD * x); + double y1(HGCalParameters::k_ScaleFromDDD * y); + edm::LogVerbatim("HGCalGeom") + << "waferFromPosition: Bad type for X " << x << ":" << x1 << ":" << xx + << " Y " << y << ":" << y1 << ":" << yy << " Wafer " << waferU << ":" + << waferV << " Cell " << cellU << ":" << cellV; + for (unsigned int k = 0; k < hgpar_->waferPosX_.size(); ++k) { + double dx = std::abs(x1 - hgpar_->waferPosX_[k]); + double dy = std::abs(y1 - hgpar_->waferPosY_[k]); + edm::LogVerbatim("HGCalGeom") + << "Wafer [" << k << "] Position (" << hgpar_->waferPosX_[k] << ", " + << hgpar_->waferPosY_[k] << ") difference " << dx << ":" << dy << ":" + << dx * tan30deg_ << ":" << hexside_ - dy << " Paramerers " << rmax_ + << ":" << hexside_; } } #endif } - -bool HGCalDDDConstants::waferInLayer(int wafer, int lay, bool reco) const { - const auto & indx = getIndex(lay, reco); +bool HGCalDDDConstants::waferInLayer(int wafer, int lay, bool reco) const { + const auto& indx = getIndex(lay, reco); if (indx.first < 0) return false; - return waferInLayerTest(wafer,indx.first,hgpar_->defineFull_); + return waferInLayerTest(wafer, indx.first, hgpar_->defineFull_); } - + bool HGCalDDDConstants::waferFullInLayer(int wafer, int lay, bool reco) const { - const auto & indx = getIndex(lay, reco); + const auto& indx = getIndex(lay, reco); if (indx.first < 0) return false; - return waferInLayerTest(wafer,indx.first,false); + return waferInLayerTest(wafer, indx.first, false); } -std::pair HGCalDDDConstants::waferPosition(int wafer, - bool reco) const { - +std::pair HGCalDDDConstants::waferPosition(int wafer, + bool reco) const { double xx(0), yy(0); if (wafer >= 0 && wafer < (int)(hgpar_->waferPosX_.size())) { xx = hgpar_->waferPosX_[wafer]; @@ -1249,34 +1293,32 @@ std::pair HGCalDDDConstants::waferPosition(int wafer, xx *= HGCalParameters::k_ScaleToDDD; yy *= HGCalParameters::k_ScaleToDDD; } - return std::make_pair(xx,yy); + return std::make_pair(xx, yy); } -std::pair HGCalDDDConstants::waferPosition(int waferU, - int waferV, - bool reco) const { - +std::pair HGCalDDDConstants::waferPosition(int waferU, + int waferV, + bool reco) const { double xx(0), yy(0); - int indx = HGCalWaferIndex::waferIndex(0,waferU,waferV); + int indx = HGCalWaferIndex::waferIndex(0, waferU, waferV); auto itr = hgpar_->wafersInLayers_.find(indx); if (itr != hgpar_->wafersInLayers_.end()) { - xx = hgpar_->waferPosX_[itr->second]; - yy = hgpar_->waferPosY_[itr->second]; + xx = hgpar_->waferPosX_[itr->second]; + yy = hgpar_->waferPosY_[itr->second]; } if (!reco) { xx *= HGCalParameters::k_ScaleToDDD; yy *= HGCalParameters::k_ScaleToDDD; } - return std::make_pair(xx,yy); + return std::make_pair(xx, yy); } int HGCalDDDConstants::waferType(DetId const& id) const { - int type(1); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - type = ((id.det() != DetId::Forward) ? (1 + HGCSiliconDetId(id).type()) : - (1 + HFNoseDetId(id).type())); + type = ((id.det() != DetId::Forward) ? (1 + HGCSiliconDetId(id).type()) + : (1 + HFNoseDetId(id).type())); } else if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { type = waferTypeL(HGCalDetId(id).wafer()); @@ -1288,28 +1330,30 @@ bool HGCalDDDConstants::waferVirtual(int layer, int waferU, int waferV) const { bool type(false); if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { - int wl = HGCalWaferIndex::waferIndex(layer,waferU,waferV,false); - type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end()); + int wl = HGCalWaferIndex::waferIndex(layer, waferU, waferV, false); + type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end()); } else if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) { - int wl = HGCalWaferIndex::waferIndex(layer,waferU,0,true); - type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end()); + int wl = HGCalWaferIndex::waferIndex(layer, waferU, 0, true); + type = (hgpar_->waferTypes_.find(wl) != hgpar_->waferTypes_.end()); } return type; } double HGCalDDDConstants::waferZ(int lay, bool reco) const { - const auto & index = getIndex(lay, reco); - if (index.first < 0) return 0; - else return (reco ? hgpar_->zLayerHex_[index.first] : - HGCalParameters::k_ScaleToDDD*hgpar_->zLayerHex_[index.first]); + const auto& index = getIndex(lay, reco); + if (index.first < 0) + return 0; + else + return (reco ? hgpar_->zLayerHex_[index.first] + : HGCalParameters::k_ScaleToDDD * + hgpar_->zLayerHex_[index.first]); } int HGCalDDDConstants::wafers() const { - int wafer(0); if (mode_ != HGCalGeometryMode::Trapezoid) { - for (unsigned int i = 0; idepth_[i]; wafer += modules(lay, true); } @@ -1320,8 +1364,7 @@ int HGCalDDDConstants::wafers() const { } int HGCalDDDConstants::wafers(int layer, int type) const { - - int wafer(0); + int wafer(0); if (mode_ != HGCalGeometryMode::Trapezoid) { auto itr = waferLayer_.find(layer); if (itr != waferLayer_.end()) { @@ -1329,25 +1372,27 @@ int HGCalDDDConstants::wafers(int layer, int type) const { wafer = (itr->second)[ity]; } } else { - const auto & index = getIndex(layer, true); - wafer = 1+hgpar_->lastModule_[index.first]-hgpar_->firstModule_[index.first]; + const auto& index = getIndex(layer, true); + wafer = 1 + hgpar_->lastModule_[index.first] - + hgpar_->firstModule_[index.first]; } return wafer; } -int HGCalDDDConstants::cellHex(double xx, double yy, - const double& cellR, +int HGCalDDDConstants::cellHex(double xx, double yy, const double& cellR, const std::vector& posX, const std::vector& posY) const { int num(0); const double tol(0.00001); - double cellY = 2.0*cellR*tan30deg_; - for (unsigned int k=0; knCellsFine_ : hgpar_->nCellsCoarse_; - double Rc = 2*rmax_/(3*N); - double rc = 0.5*Rc*sqrt3_; - double v0 = ((xloc/Rc -1.0)/1.5); - int cv0 = (v0 > 0) ? (N + (int)(v0+0.5)) : (N - (int)(-v0+0.5)); - double u0 = (0.5*yloc/rc+0.5*cv0); - int cu0 = (u0 > 0) ? (N/2 + (int)(u0+0.5)) : (N/2 - (int)(-u0+0.5)); - cu0 = std::max(0,std::min(cu0,2*N-1)); - cv0 = std::max(0,std::min(cv0,2*N-1)); - if (cv0-cu0 >= N) cv0 = cu0+N-1; + ) const { + int N = (cellType == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_; + double Rc = 2 * rmax_ / (3 * N); + double rc = 0.5 * Rc * sqrt3_; + double v0 = ((xloc / Rc - 1.0) / 1.5); + int cv0 = (v0 > 0) ? (N + (int)(v0 + 0.5)) : (N - (int)(-v0 + 0.5)); + double u0 = (0.5 * yloc / rc + 0.5 * cv0); + int cu0 = (u0 > 0) ? (N / 2 + (int)(u0 + 0.5)) : (N / 2 - (int)(-u0 + 0.5)); + cu0 = std::max(0, std::min(cu0, 2 * N - 1)); + cv0 = std::max(0, std::min(cv0, 2 * N - 1)); + if (cv0 - cu0 >= N) cv0 = cu0 + N - 1; #ifdef EDM_ML_DEBUG if (debug) - edm::LogVerbatim("HGCalGeom") << "cellHex: input " << xloc << ":" - << yloc << ":" << cellType << " parameter " - << rc << ":" << Rc << " u0 " << u0 << ":" - << cu0 << " v0 " << v0 << ":" << cv0; + edm::LogVerbatim("HGCalGeom") + << "cellHex: input " << xloc << ":" << yloc << ":" << cellType + << " parameter " << rc << ":" << Rc << " u0 " << u0 << ":" << cu0 + << " v0 " << v0 << ":" << cv0; #endif bool found(false); - static const int shift[3] = {0,1,-1}; - for (int i1=0; i1<3; ++i1) { - cellU = cu0 + shift[i1]; - for (int i2=0; i2<3; ++i2) { - cellV = cv0 + shift[i2]; - if (((cellV-cellU) < N) && ((cellU-cellV) <= N) && (cellU >= 0) && - (cellV >= 0) && (cellU < 2*N) && (cellV < 2*N)) { - double xc = (1.5*(cellV-N)+1.0)*Rc; - double yc = (2*cellU-cellV-N)*rc; - if ((std::abs(yloc-yc) <= rc) && (std::abs(xloc-xc) <= Rc) && - ((std::abs(xloc-xc) <= 0.5*Rc) || - (std::abs(yloc-yc) <= sqrt3_*(Rc-std::abs(xloc-xc))))) { + static const int shift[3] = {0, 1, -1}; + for (int i1 = 0; i1 < 3; ++i1) { + cellU = cu0 + shift[i1]; + for (int i2 = 0; i2 < 3; ++i2) { + cellV = cv0 + shift[i2]; + if (((cellV - cellU) < N) && ((cellU - cellV) <= N) && (cellU >= 0) && + (cellV >= 0) && (cellU < 2 * N) && (cellV < 2 * N)) { + double xc = (1.5 * (cellV - N) + 1.0) * Rc; + double yc = (2 * cellU - cellV - N) * rc; + if ((std::abs(yloc - yc) <= rc) && (std::abs(xloc - xc) <= Rc) && + ((std::abs(xloc - xc) <= 0.5 * Rc) || + (std::abs(yloc - yc) <= sqrt3_ * (Rc - std::abs(xloc - xc))))) { #ifdef EDM_ML_DEBUG if (debug) - edm::LogVerbatim("HGCalGeom") << "cellHex: local " << xc << ":" - << yc << " difference " - << std::abs(xloc-xc) << ":" - << std::abs(yloc-yc) << ":" - << sqrt3_*(Rc-std::abs(yloc-yc)) - << " comparator " << rc << ":" << Rc - << " (u,v) = (" << cellU << "," - << cellV << ")"; + edm::LogVerbatim("HGCalGeom") + << "cellHex: local " << xc << ":" << yc << " difference " + << std::abs(xloc - xc) << ":" << std::abs(yloc - yc) << ":" + << sqrt3_ * (Rc - std::abs(yloc - yc)) << " comparator " << rc + << ":" << Rc << " (u,v) = (" << cellU << "," << cellV << ")"; #endif - found = true; break; + found = true; + break; } } } if (found) break; } - if (!found) { cellU = cu0; cellV = cv0; } + if (!found) { + cellU = cu0; + cellV = cv0; + } } -std::pair HGCalDDDConstants::getIndex(int lay, bool reco) const { - - int indx = layerIndex(lay,reco); - if (indx<0) return std::make_pair(-1,0); +std::pair HGCalDDDConstants::getIndex(int lay, bool reco) const { + int indx = layerIndex(lay, reco); + if (indx < 0) return std::make_pair(-1, 0); float cell(0); if ((mode_ == HGCalGeometryMode::Hexagon) || - (mode_ == HGCalGeometryMode::HexagonFull)) { + (mode_ == HGCalGeometryMode::HexagonFull)) { cell = (reco ? hgpar_->moduleCellR_[0] : hgpar_->moduleCellS_[0]); } else { if ((mode_ == HGCalGeometryMode::Hexagon8) || @@ -1428,57 +1474,51 @@ std::pair HGCalDDDConstants::getIndex(int lay, bool reco) const { cell = hgpar_->scintCellSize(lay); } } - return std::make_pair(indx,cell); + return std::make_pair(indx, cell); } bool HGCalDDDConstants::isValidCell(int lay, int wafer, int cell) const { - // Calculate the position of the cell // Works for options HGCalHexagon/HGCalHexagonFull double x = hgpar_->waferPosX_[wafer]; double y = hgpar_->waferPosY_[wafer]; if (hgpar_->waferTypeT_[wafer] == 1) { - x += hgpar_->cellFineX_[cell]; - y += hgpar_->cellFineY_[cell]; + x += hgpar_->cellFineX_[cell]; + y += hgpar_->cellFineY_[cell]; } else { - x += hgpar_->cellCoarseX_[cell]; - y += hgpar_->cellCoarseY_[cell]; + x += hgpar_->cellCoarseX_[cell]; + y += hgpar_->cellCoarseY_[cell]; } - double rr = sqrt(x*x+y*y); - bool result = ((rr >= hgpar_->rMinLayHex_[lay-1]) && - (rr <= hgpar_->rMaxLayHex_[lay-1]) && - (wafer < (int)(hgpar_->waferPosX_.size()))); + double rr = sqrt(x * x + y * y); + bool result = ((rr >= hgpar_->rMinLayHex_[lay - 1]) && + (rr <= hgpar_->rMaxLayHex_[lay - 1]) && + (wafer < (int)(hgpar_->waferPosX_.size()))); #ifdef EDM_ML_DEBUG - if (!result) - edm::LogVerbatim("HGCalGeom") << "Input " << lay << ":" << wafer << ":" - << cell << " Position " << x << ":" << y - << ":" << rr << " Compare Limits " - << hgpar_->rMinLayHex_[lay-1] << ":" - << hgpar_->rMaxLayHex_[lay-1] - << " Flag " << result; + if (!result) + edm::LogVerbatim("HGCalGeom") + << "Input " << lay << ":" << wafer << ":" << cell << " Position " << x + << ":" << y << ":" << rr << " Compare Limits " + << hgpar_->rMinLayHex_[lay - 1] << ":" << hgpar_->rMaxLayHex_[lay - 1] + << " Flag " << result; #endif return result; } bool HGCalDDDConstants::waferInLayerTest(int wafer, int lay, bool full) const { - bool flag = ((mode_ == HGCalGeometryMode::Hexagon) || - (mode_ == HGCalGeometryMode::HexagonFull)) ? true : false; - std::pair corner = - HGCalGeomTools::waferCorner(hgpar_->waferPosX_[wafer], - hgpar_->waferPosY_[wafer], - rmax_, hexside_, - hgpar_->rMinLayHex_[lay], - hgpar_->rMaxLayHex_[lay], flag); - bool in = (full ? (corner.first > 0) : - (corner.first == (int)(HGCalParameters::k_CornerSize))); + (mode_ == HGCalGeometryMode::HexagonFull)) + ? true + : false; + std::pair corner = HGCalGeomTools::waferCorner( + hgpar_->waferPosX_[wafer], hgpar_->waferPosY_[wafer], rmax_, hexside_, + hgpar_->rMinLayHex_[lay], hgpar_->rMaxLayHex_[lay], flag); + bool in = (full ? (corner.first > 0) + : (corner.first == (int)(HGCalParameters::k_CornerSize))); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "WaferInLayerTest: Layer " << lay - << " wafer " << wafer << " R-limits " - << hgpar_->rMinLayHex_[lay] << ":" - << hgpar_->rMaxLayHex_[lay] << " Corners " - << corner.first << ":" << corner.second - << " In " << in; + edm::LogVerbatim("HGCalGeom") + << "WaferInLayerTest: Layer " << lay << " wafer " << wafer << " R-limits " + << hgpar_->rMinLayHex_[lay] << ":" << hgpar_->rMaxLayHex_[lay] + << " Corners " << corner.first << ":" << corner.second << " In " << in; #endif return in; } diff --git a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc index 01db327a043fe..06c58dae7e42c 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc @@ -4,27 +4,27 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" -#include "DetectorDescription/Core/interface/DDutils.h" -#include "DetectorDescription/Core/interface/DDValue.h" -#include "DetectorDescription/Core/interface/DDFilter.h" -#include "DetectorDescription/Core/interface/DDSolid.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/Point3D.h" #include "DetectorDescription/Core/interface/DDConstant.h" +#include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" +#include "DetectorDescription/Core/interface/DDSolid.h" +#include "DetectorDescription/Core/interface/DDValue.h" #include "DetectorDescription/Core/interface/DDVectorGetter.h" +#include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" -#include "DataFormats/Math/interface/Point3D.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include #include //#define EDM_ML_DEBUG -const double tolerance = 0.001; +const double tolerance = 0.001; HGCalGeomParameters::HGCalGeomParameters() : sqrt3_(std::sqrt(3.0)) { #ifdef EDM_ML_DEBUG @@ -33,78 +33,74 @@ HGCalGeomParameters::HGCalGeomParameters() : sqrt3_(std::sqrt(3.0)) { #endif } -HGCalGeomParameters::~HGCalGeomParameters() { +HGCalGeomParameters::~HGCalGeomParameters() { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "HGCalGeomParameters::destructed!!!"; #endif } -void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, - HGCalParameters& php, - const std::string & sdTag1, - const DDCompactView* cpv, - const std::string & sdTag2, - const std::string & sdTag3, - HGCalGeometryMode::WaferMode mode) { - +void HGCalGeomParameters::loadGeometryHexagon( + const DDFilteredView& _fv, HGCalParameters& php, const std::string& sdTag1, + const DDCompactView* cpv, const std::string& sdTag2, + const std::string& sdTag3, HGCalGeometryMode::WaferMode mode) { DDFilteredView fv = _fv; bool dodet(true); - std::map layers; - std::vector trforms; - std::vector trformUse; - + std::map layers; + std::vector trforms; + std::vector trformUse; + while (dodet) { - const DDSolid & sol = fv.logicalPart().solid(); + const DDSolid& sol = fv.logicalPart().solid(); // Layers first std::vector copy = fv.copyNumbers(); int nsiz = (int)(copy.size()); - int lay = (nsiz > 0) ? copy[nsiz-1] : 0; - int zp = (nsiz > 2) ? copy[nsiz-3] : -1; + int lay = (nsiz > 0) ? copy[nsiz - 1] : 0; + int zp = (nsiz > 2) ? copy[nsiz - 3] : -1; if (zp != 1) zp = -1; if (lay == 0) { - throw cms::Exception("DDException") << "Funny layer # " << lay << " zp " - << zp << " in " << nsiz - << " components"; + throw cms::Exception("DDException") + << "Funny layer # " << lay << " zp " << zp << " in " << nsiz + << " components"; } else { - if (std::find(php.layer_.begin(),php.layer_.end(),lay) == - php.layer_.end()) php.layer_.emplace_back(lay); + if (std::find(php.layer_.begin(), php.layer_.end(), lay) == + php.layer_.end()) + php.layer_.emplace_back(lay); auto itr = layers.find(lay); if (itr == layers.end()) { - double rin(0), rout(0); - if ((sol.shape() == DDSolidShape::ddpolyhedra_rz) || - (sol.shape() == DDSolidShape::ddpolyhedra_rrz)) { - const DDPolyhedra& polyhedra = static_cast(sol); - const std::vector& rmin = polyhedra.rMinVec(); - const std::vector& rmax = polyhedra.rMaxVec(); - rin = 0.5*HGCalParameters::k_ScaleFromDDD*(rmin[0]+rmin[1]); - rout = 0.5*HGCalParameters::k_ScaleFromDDD*(rmax[0]+rmax[1]); - } else if (sol.shape() == DDSolidShape::ddtubs) { - const DDTubs & tube = static_cast(sol); - rin = HGCalParameters::k_ScaleFromDDD*tube.rIn(); - rout = HGCalParameters::k_ScaleFromDDD*tube.rOut(); - } - double zp = HGCalParameters::k_ScaleFromDDD*fv.translation().Z(); - HGCalGeomParameters::layerParameters laypar(rin,rout,zp); + double rin(0), rout(0); + if ((sol.shape() == DDSolidShape::ddpolyhedra_rz) || + (sol.shape() == DDSolidShape::ddpolyhedra_rrz)) { + const DDPolyhedra& polyhedra = static_cast(sol); + const std::vector& rmin = polyhedra.rMinVec(); + const std::vector& rmax = polyhedra.rMaxVec(); + rin = 0.5 * HGCalParameters::k_ScaleFromDDD * (rmin[0] + rmin[1]); + rout = 0.5 * HGCalParameters::k_ScaleFromDDD * (rmax[0] + rmax[1]); + } else if (sol.shape() == DDSolidShape::ddtubs) { + const DDTubs& tube = static_cast(sol); + rin = HGCalParameters::k_ScaleFromDDD * tube.rIn(); + rout = HGCalParameters::k_ScaleFromDDD * tube.rOut(); + } + double zp = HGCalParameters::k_ScaleFromDDD * fv.translation().Z(); + HGCalGeomParameters::layerParameters laypar(rin, rout, zp); layers[lay] = laypar; } DD3Vector x, y, z; - fv.rotation().GetComponents( x, y, z ) ; - const CLHEP::HepRep3x3 rotation ( x.X(), y.X(), z.X(), - x.Y(), y.Y(), z.Y(), - x.Z(), y.Z(), z.Z() ); - const CLHEP::HepRotation hr ( rotation ); - double xx = HGCalParameters::k_ScaleFromDDD*fv.translation().X(); + fv.rotation().GetComponents(x, y, z); + const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), + x.Z(), y.Z(), z.Z()); + const CLHEP::HepRotation hr(rotation); + double xx = HGCalParameters::k_ScaleFromDDD * fv.translation().X(); if (std::abs(xx) < tolerance) xx = 0; - double yy = HGCalParameters::k_ScaleFromDDD*fv.translation().Y(); + double yy = HGCalParameters::k_ScaleFromDDD * fv.translation().Y(); if (std::abs(yy) < tolerance) yy = 0; - const CLHEP::Hep3Vector h3v ( xx, yy, fv.translation().Z() ); + const CLHEP::Hep3Vector h3v(xx, yy, fv.translation().Z()); HGCalParameters::hgtrform mytrf; - mytrf.zp = zp; - mytrf.lay = lay; - mytrf.sec = 0; - mytrf.subsec= 0; - mytrf.h3v = h3v; - mytrf.hr = hr; + mytrf.zp = zp; + mytrf.lay = lay; + mytrf.sec = 0; + mytrf.subsec = 0; + mytrf.h3v = h3v; + mytrf.hr = hr; trforms.emplace_back(mytrf); trformUse.emplace_back(false); } @@ -112,84 +108,88 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, } // Then wafers - // This assumes layers are build starting from 1 (which on 25 Jan 2016, they were) - // to ensure that new copy numbers are always added - // to the end of the list. - std::unordered_map copies; - HGCalParameters::layer_map copiesInLayers(layers.size()+1); - std::vector wafer2copy; - std::vector wafers; + // This assumes layers are build starting from 1 (which on 25 Jan 2016, they + // were) to ensure that new copy numbers are always added to the end of the + // list. + std::unordered_map copies; + HGCalParameters::layer_map copiesInLayers(layers.size() + 1); + std::vector wafer2copy; + std::vector wafers; std::string attribute = "Volume"; DDValue val1(attribute, sdTag2, 0.0); DDSpecificsMatchesValueFilter filter1{val1}; - DDFilteredView fv1(*cpv,filter1); + DDFilteredView fv1(*cpv, filter1); bool ok = fv1.firstChild(); if (!ok) { - edm::LogError("HGCalGeom") << " Attribute " << val1 - << " not found but needed."; - throw cms::Exception("DDException") << "Attribute " << val1 - << " not found but needed."; + edm::LogError("HGCalGeom") + << " Attribute " << val1 << " not found but needed."; + throw cms::Exception("DDException") + << "Attribute " << val1 << " not found but needed."; } else { dodet = true; std::unordered_set names; while (dodet) { - const DDSolid & sol = fv1.logicalPart().solid(); - const std::string & name = fv1.logicalPart().name().name(); + const DDSolid& sol = fv1.logicalPart().solid(); + const std::string& name = fv1.logicalPart().name().name(); std::vector copy = fv1.copyNumbers(); - int nsiz = (int)(copy.size()); - int wafer = (nsiz > 0) ? copy[nsiz-1] : 0; - int layer = (nsiz > 1) ? copy[nsiz-2] : 0; + int nsiz = (int)(copy.size()); + int wafer = (nsiz > 0) ? copy[nsiz - 1] : 0; + int layer = (nsiz > 1) ? copy[nsiz - 2] : 0; if (nsiz < 2) { - edm::LogError("HGCalGeom") << "Funny wafer # " << wafer << " in " - << nsiz << " components"; + edm::LogError("HGCalGeom") + << "Funny wafer # " << wafer << " in " << nsiz << " components"; throw cms::Exception("DDException") << "Funny wafer # " << wafer; } else if (layer > (int)(layers.size())) { - edm::LogWarning("HGCalGeom") << "Funny wafer # " << wafer - << " Layer " << layer << ":" - << layers.size() << " among " - << nsiz << " components"; - } else { + edm::LogWarning("HGCalGeom") + << "Funny wafer # " << wafer << " Layer " << layer << ":" + << layers.size() << " among " << nsiz << " components"; + } else { auto itr = copies.find(wafer); auto cpy = copiesInLayers[layer].find(wafer); if (itr != copies.end() && cpy == copiesInLayers[layer].end()) { copiesInLayers[layer][wafer] = itr->second; - } - if (itr == copies.end()) { + } + if (itr == copies.end()) { copies[wafer] = wafer2copy.size(); copiesInLayers[layer][wafer] = wafer2copy.size(); - double xx = HGCalParameters::k_ScaleFromDDD*fv1.translation().X(); + double xx = HGCalParameters::k_ScaleFromDDD * fv1.translation().X(); if (std::abs(xx) < tolerance) xx = 0; - double yy = HGCalParameters::k_ScaleFromDDD*fv1.translation().Y(); + double yy = HGCalParameters::k_ScaleFromDDD * fv1.translation().Y(); if (std::abs(yy) < tolerance) yy = 0; wafer2copy.emplace_back(wafer); - GlobalPoint p(xx,yy,HGCalParameters::k_ScaleFromDDD*fv1.translation().Z()); - HGCalGeomParameters::cellParameters cell(false,wafer,p); + GlobalPoint p( + xx, yy, HGCalParameters::k_ScaleFromDDD * fv1.translation().Z()); + HGCalGeomParameters::cellParameters cell(false, wafer, p); wafers.emplace_back(cell); - if ( names.count(name) == 0 ) { + if (names.count(name) == 0) { std::vector zv, rv; if (mode == HGCalGeometryMode::Polyhedra) { - const DDPolyhedra & polyhedra = static_cast(sol); + const DDPolyhedra& polyhedra = static_cast(sol); zv = polyhedra.zVec(); rv = polyhedra.rMaxVec(); } else { - const DDExtrudedPolygon & polygon = static_cast(sol); + const DDExtrudedPolygon& polygon = + static_cast(sol); zv = polygon.zVec(); rv = polygon.xVec(); } - php.waferR_ = rv[0]/std::cos(30.0*CLHEP::deg); + php.waferR_ = rv[0] / std::cos(30.0 * CLHEP::deg); php.waferSize_ = HGCalParameters::k_ScaleFromDDD * rv[0]; - double dz = 0.5*(zv[1]-zv[0]); + double dz = 0.5 * (zv[1] - zv[0]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Mode " << mode << " R " - << php.waferSize_ << ":" - << php.waferR_ << " z " << dz; + edm::LogVerbatim("HGCalGeom") + << "Mode " << mode << " R " << php.waferSize_ << ":" + << php.waferR_ << " z " << dz; #endif HGCalParameters::hgtrap mytr; - mytr.lay = 1; mytr.bl = php.waferR_; - mytr.tl = php.waferR_; mytr.h = php.waferR_; - mytr.dz = dz; mytr.alpha = 0.0; + mytr.lay = 1; + mytr.bl = php.waferR_; + mytr.tl = php.waferR_; + mytr.h = php.waferR_; + mytr.dz = dz; + mytr.alpha = 0.0; mytr.cellSize = waferSize_; - php.fillModule(mytr,false); + php.fillModule(mytr, false); names.insert(name); } } @@ -199,62 +199,63 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, } // Finally the cells - std::map wafertype; - std::map cellsf, cellsc; + std::map wafertype; + std::map cellsf, cellsc; DDValue val2(attribute, sdTag3, 0.0); DDSpecificsMatchesValueFilter filter2{val2}; - DDFilteredView fv2(*cpv,filter2); + DDFilteredView fv2(*cpv, filter2); ok = fv2.firstChild(); if (!ok) { - edm::LogError("HGCalGeom") << " Attribute " << val2 - << " not found but needed."; - throw cms::Exception("DDException") << "Attribute " << val2 - << " not found but needed."; + edm::LogError("HGCalGeom") + << " Attribute " << val2 << " not found but needed."; + throw cms::Exception("DDException") + << "Attribute " << val2 << " not found but needed."; } else { dodet = true; while (dodet) { - const DDSolid & sol = fv2.logicalPart().solid(); - const std::string & name = sol.name().name(); + const DDSolid& sol = fv2.logicalPart().solid(); + const std::string& name = sol.name().name(); std::vector copy = fv2.copyNumbers(); int nsiz = (int)(copy.size()); - int cellx= (nsiz > 0) ? copy[nsiz-1] : 0; - int wafer= (nsiz > 1) ? copy[nsiz-2] : 0; - int cell = cellx%1000; - int type = cellx/1000; + int cellx = (nsiz > 0) ? copy[nsiz - 1] : 0; + int wafer = (nsiz > 1) ? copy[nsiz - 2] : 0; + int cell = cellx % 1000; + int type = cellx / 1000; if (type != 1 && type != 2) { - edm::LogError("HGCalGeom") << "Funny cell # " << cell << " type " + edm::LogError("HGCalGeom") << "Funny cell # " << cell << " type " << type << " in " << nsiz << " components"; throw cms::Exception("DDException") << "Funny cell # " << cell; } else { auto ktr = wafertype.find(wafer); if (ktr == wafertype.end()) wafertype[wafer] = type; bool newc(false); - std::map::iterator itr; + std::map::iterator itr; double cellsize = php.cellSize_[0]; if (type == 1) { itr = cellsf.find(cell); - newc= (itr == cellsf.end()); + newc = (itr == cellsf.end()); } else { itr = cellsc.find(cell); - newc= (itr == cellsc.end()); + newc = (itr == cellsc.end()); cellsize = php.cellSize_[1]; } if (newc) { bool half = (name.find("Half") != std::string::npos); - double xx = HGCalParameters::k_ScaleFromDDD*fv2.translation().X(); - double yy = HGCalParameters::k_ScaleFromDDD*fv2.translation().Y(); + double xx = HGCalParameters::k_ScaleFromDDD * fv2.translation().X(); + double yy = HGCalParameters::k_ScaleFromDDD * fv2.translation().Y(); if (half) { - math::XYZPointD p1(-2.0*cellsize/9.0,0,0); + math::XYZPointD p1(-2.0 * cellsize / 9.0, 0, 0); math::XYZPointD p2 = fv2.rotation()(p1); - xx += (HGCalParameters::k_ScaleFromDDD*(p2.X())); - yy += (HGCalParameters::k_ScaleFromDDD*(p2.Y())); + xx += (HGCalParameters::k_ScaleFromDDD * (p2.X())); + yy += (HGCalParameters::k_ScaleFromDDD * (p2.Y())); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Type " << type << " Cell " - << cellx << " local " << xx << ":" - << yy << " new " << p1 << ":"<< p2; + edm::LogVerbatim("HGCalGeom") + << "Type " << type << " Cell " << cellx << " local " << xx + << ":" << yy << " new " << p1 << ":" << p2; #endif } - HGCalGeomParameters::cellParameters cp(half,wafer,GlobalPoint(xx,yy,0)); + HGCalGeomParameters::cellParameters cp(half, wafer, + GlobalPoint(xx, yy, 0)); if (type == 1) { cellsf[cell] = cp; } else { @@ -266,21 +267,21 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, } } - if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) || + if (((cellsf.size() + cellsc.size()) == 0) || (wafers.empty()) || (layers.empty())) { - edm::LogError("HGCalGeom") << "HGCalGeomParameters : number of cells " - << cellsf.size() << ":" << cellsc.size() - << " wafers " << wafers.size() << " layers " - << layers.size() << " illegal"; + edm::LogError("HGCalGeom") + << "HGCalGeomParameters : number of cells " << cellsf.size() << ":" + << cellsc.size() << " wafers " << wafers.size() << " layers " + << layers.size() << " illegal"; throw cms::Exception("DDException") - << "HGCalGeomParameters: mismatch between geometry and specpar: cells " - << cellsf.size() << ":" << cellsc.size() << " wafers " << wafers.size() - << " layers " << layers.size(); + << "HGCalGeomParameters: mismatch between geometry and specpar: cells " + << cellsf.size() << ":" << cellsc.size() << " wafers " << wafers.size() + << " layers " << layers.size(); } - for (unsigned int i=0; i 0) { - php.scaleTrForm(double(1.0/nz)); + php.scaleTrForm(double(1.0 / nz)); } } } } - double rmin = HGCalParameters::k_ScaleFromDDD*php.waferR_; - for (unsigned i = 0; i < wafer2copy.size(); ++i ) { + double rmin = HGCalParameters::k_ScaleFromDDD * php.waferR_; + for (unsigned i = 0; i < wafer2copy.size(); ++i) { php.waferCopy_.emplace_back(wafer2copy[i]); php.waferPosX_.emplace_back(wafers[i].xyz.x()); php.waferPosY_.emplace_back(wafers[i].xyz.y()); @@ -322,10 +323,11 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, int typet = (ktr == wafertype.end()) ? 0 : (ktr->second); php.waferTypeT_.emplace_back(typet); double r = wafers[i].xyz.perp(); - int type(3); - for (int k=1; k<4; ++k) { - if ((r+rmin)<=php.boundR_[k]) { - type = k; break; + int type(3); + for (int k = 1; k < 4; ++k) { + if ((r + rmin) <= php.boundR_[k]) { + type = k; + break; } } php.waferTypeL_.emplace_back(type); @@ -333,49 +335,50 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, php.copiesInLayers_ = copiesInLayers; php.nSectors_ = (int)(php.waferCopy_.size()); - std::vector::const_iterator itrf = wafers.end(); - for (unsigned int i=0; i::const_iterator itrf = + wafers.end(); + for (unsigned int i = 0; i < cellsf.size(); ++i) { auto itr = cellsf.find(i); if (itr == cellsf.end()) { edm::LogError("HGCalGeom") << "HGCalGeomParameters: missing info for" << " fine cell number " << i; throw cms::Exception("DDException") - << "HGCalGeomParameters: missing info for fine cell number " << i; + << "HGCalGeomParameters: missing info for fine cell number " << i; } else { double xx = (itr->second).xyz.x(); double yy = (itr->second).xyz.y(); - int waf= (itr->second).wafer; - std::pair xy = cellPosition(wafers,itrf,waf,xx,yy); + int waf = (itr->second).wafer; + std::pair xy = cellPosition(wafers, itrf, waf, xx, yy); php.cellFineX_.emplace_back(xy.first); php.cellFineY_.emplace_back(xy.second); - php.cellFineHalf_.emplace_back((itr->second).half); + php.cellFineHalf_.emplace_back((itr->second).half); } } itrf = wafers.end(); - for (unsigned int i=0; isecond).xyz.x(); double yy = (itr->second).xyz.y(); - int waf= (itr->second).wafer; - std::pair xy = cellPosition(wafers,itrf,waf,xx,yy); + int waf = (itr->second).wafer; + std::pair xy = cellPosition(wafers, itrf, waf, xx, yy); php.cellCoarseX_.emplace_back(xy.first); php.cellCoarseY_.emplace_back(xy.second); - php.cellCoarseHalf_.emplace_back((itr->second).half); + php.cellCoarseHalf_.emplace_back((itr->second).half); } } int depth(0); - for (unsigned int i=0; i::const_iterator itr=theModules.begin(); + for (std::unordered_map::const_iterator itr = theModules.begin(); itr != theModules.end(); ++itr, ++k2) { - edm::LogVerbatim("HGCalGeom") << "[" << k2 << "] " << itr->first << ":" - << itr->second; + edm::LogVerbatim("HGCalGeom") + << "[" << k2 << "] " << itr->first << ":" << itr->second; } } #endif } -void HGCalGeomParameters::loadGeometryHexagon8(const DDFilteredView& _fv, - HGCalParameters& php, - int firstLayer) { - +void HGCalGeomParameters::loadGeometryHexagon8(const DDFilteredView& _fv, + HGCalParameters& php, + int firstLayer) { DDFilteredView fv = _fv; bool dodet(true); - std::map layers; - std::map,HGCalParameters::hgtrform> trforms; - int levelTop = 3+std::max(php.levelT_[0],php.levelT_[1]); + std::map layers; + std::map, HGCalParameters::hgtrform> trforms; + int levelTop = 3 + std::max(php.levelT_[0], php.levelT_[1]); while (dodet) { - const DDSolid & sol = fv.logicalPart().solid(); + const DDSolid& sol = fv.logicalPart().solid(); // Layers first std::vector copy = fv.copyNumbers(); int nsiz = (int)(copy.size()); - int lay = (nsiz > levelTop) ? copy[nsiz-4] : copy[nsiz-1]; - int zside= (nsiz > php.levelZSide_) ? copy[php.levelZSide_] : -1; + int lay = (nsiz > levelTop) ? copy[nsiz - 4] : copy[nsiz - 1]; + int zside = (nsiz > php.levelZSide_) ? copy[php.levelZSide_] : -1; if (zside != 1) zside = -1; if (lay == 0) { - edm::LogError("HGCalGeom") << "Funny layer # " << lay << " zp " - << zside << " in " << nsiz << " components"; + edm::LogError("HGCalGeom") << "Funny layer # " << lay << " zp " << zside + << " in " << nsiz << " components"; throw cms::Exception("DDException") << "Funny layer # " << lay; } else { - if (std::find(php.layer_.begin(),php.layer_.end(),lay) == - php.layer_.end()) php.layer_.emplace_back(lay); + if (std::find(php.layer_.begin(), php.layer_.end(), lay) == + php.layer_.end()) + php.layer_.emplace_back(lay); auto itr = layers.find(lay); if (itr == layers.end()) { - const DDTubs & tube = static_cast(sol); - double rin = HGCalParameters::k_ScaleFromDDD*tube.rIn(); - double rout= HGCalParameters::k_ScaleFromDDD*tube.rOut(); - double zp = HGCalParameters::k_ScaleFromDDD*fv.translation().Z(); - HGCalGeomParameters::layerParameters laypar(rin,rout,zp); + const DDTubs& tube = static_cast(sol); + double rin = HGCalParameters::k_ScaleFromDDD * tube.rIn(); + double rout = HGCalParameters::k_ScaleFromDDD * tube.rOut(); + double zp = HGCalParameters::k_ScaleFromDDD * fv.translation().Z(); + HGCalGeomParameters::layerParameters laypar(rin, rout, zp); layers[lay] = laypar; } - if (trforms.find(std::make_pair(lay,zside)) == trforms.end()) { + if (trforms.find(std::make_pair(lay, zside)) == trforms.end()) { DD3Vector x, y, z; - fv.rotation().GetComponents( x, y, z ) ; - const CLHEP::HepRep3x3 rotation ( x.X(), y.X(), z.X(), - x.Y(), y.Y(), z.Y(), - x.Z(), y.Z(), z.Z() ); - const CLHEP::HepRotation hr ( rotation ); - double xx = ((std::abs(fv.translation().X()) < tolerance) ? 0 : - fv.translation().X()); - double yy = ((std::abs(fv.translation().Y()) < tolerance) ? 0 : - fv.translation().Y()); - const CLHEP::Hep3Vector h3v (xx, yy, fv.translation().Z()); + fv.rotation().GetComponents(x, y, z); + const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), + z.Y(), x.Z(), y.Z(), z.Z()); + const CLHEP::HepRotation hr(rotation); + double xx = ((std::abs(fv.translation().X()) < tolerance) + ? 0 + : fv.translation().X()); + double yy = ((std::abs(fv.translation().Y()) < tolerance) + ? 0 + : fv.translation().Y()); + const CLHEP::Hep3Vector h3v(xx, yy, fv.translation().Z()); HGCalParameters::hgtrform mytrf; - mytrf.zp = zside; - mytrf.lay = lay; - mytrf.sec = 0; - mytrf.subsec= 0; - mytrf.h3v = h3v; - mytrf.hr = hr; - trforms[std::make_pair(lay,zside)] = mytrf; + mytrf.zp = zside; + mytrf.lay = lay; + mytrf.sec = 0; + mytrf.subsec = 0; + mytrf.h3v = h3v; + mytrf.hr = hr; + trforms[std::make_pair(lay, zside)] = mytrf; } } dodet = fv.next(); } double rmin(0), rmax(0); - for (unsigned int i=0; i layer.second.rmin) rmin = layer.second.rmin; if (rmax < layer.second.rmax) rmax = layer.second.rmax; @@ -566,49 +559,42 @@ void HGCalGeomParameters::loadGeometryHexagon8(const DDFilteredView& _fv, } php.rLimit_.emplace_back(rmin); php.rLimit_.emplace_back(rmax); - php.depth_ = php.layer_; + php.depth_ = php.layer_; php.depthIndex_ = php.layerIndex_; - php.depthLayerF_= php.layerIndex_; + php.depthLayerF_ = php.layerIndex_; - for (unsigned int i=0; i= 0) ? nr : -nr; - for (int nc=-ncol; nc <= ncol; ++nc) { + for (int nc = -ncol; nc <= ncol; ++nc) { int inc = (nc >= 0) ? nc : -nc; - if (inr%2 == inc%2) { - double xpos = nc*dx; - double ypos = nr*dy; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); - double rpos = std::sqrt(xpos*xpos+ypos*ypos); + if (inr % 2 == inc % 2) { + double xpos = nc * dx; + double ypos = nr * dy; + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true); + double rpos = std::sqrt(xpos * xpos + ypos * ypos); int typet = (rpos < rMaxFine) ? 1 : 2; int typel(3); - for (int k=1; k<4; ++k) { - if ((rpos+rmin)<=php.boundR_[k]) { - typel = k; break; + for (int k = 1; k < 4; ++k) { + if ((rpos + rmin) <= php.boundR_[k]) { + typel = k; + break; } } ++ntot; if (corner.first > 0) { - int copy = inr*100 + inc; + int copy = inr * 100 + inc; if (nc < 0) copy += 10000; if (nr < 0) copy += 100000; if (inc > incm) incm = inc; if (inr > inrm) inrm = inr; kount++; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << kount << ":" << ntot << " Copy " - << copy << " Type " << typel << ":" - << typet << " Location " << corner.first - << " Position " << xpos << ":" << ypos - << " Layers " << php.layer_.size(); + edm::LogVerbatim("HGCalGeom") + << kount << ":" << ntot << " Copy " << copy << " Type " << typel + << ":" << typet << " Location " << corner.first << " Position " + << xpos << ":" << ypos << " Layers " << php.layer_.size(); #endif php.waferCopy_.emplace_back(copy); php.waferTypeL_.emplace_back(typel); php.waferTypeT_.emplace_back(typet); php.waferPosX_.emplace_back(xpos); php.waferPosY_.emplace_back(ypos); - for (unsigned int il=0; il corner = - HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, - php.rMinLayHex_[il], - php.rMaxLayHex_[il], true); + for (unsigned int il = 0; il < php.layer_.size(); ++il) { + std::pair corner = HGCalGeomTools::waferCorner( + xpos, ypos, dx, rr, php.rMinLayHex_[il], php.rMaxLayHex_[il], + true); if (corner.first > 0) { auto cpy = copiesInLayers[php.layer_[il]].find(copy); - if (cpy == copiesInLayers[php.layer_[il]].end()) - copiesInLayers[php.layer_[il]][copy] = ((corner.first == (int)(HGCalParameters::k_CornerSize)) ? php.waferCopy_.size() : -1); + if (cpy == copiesInLayers[php.layer_[il]].end()) + copiesInLayers[php.layer_[il]][copy] = + ((corner.first == (int)(HGCalParameters::k_CornerSize)) + ? php.waferCopy_.size() + : -1); } - if ((corner.first > 0) && + if ((corner.first > 0) && (corner.first < (int)(HGCalParameters::k_CornerSize))) { - int wl = HGCalWaferIndex::waferIndex(php.layer_[il],copy,0,true); - waferTypes[wl] = std::make_pair(corner.first,corner.second); + int wl = + HGCalWaferIndex::waferIndex(php.layer_[il], copy, 0, true); + waferTypes[wl] = std::make_pair(corner.first, corner.second); } } } @@ -918,45 +915,41 @@ void HGCalGeomParameters::loadWaferHexagon(HGCalParameters& php) { } } php.copiesInLayers_ = copiesInLayers; - php.waferTypes_ = waferTypes; - php.nSectors_ = (int)(php.waferCopy_.size()); - php.waferUVMax_ = 0; + php.waferTypes_ = waferTypes; + php.nSectors_ = (int)(php.waferCopy_.size()); + php.waferUVMax_ = 0; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalWaferHexagon: # of columns " - << incm << " # of rows " << inrm << " and " - << kount << ":" << ntot << " wafers; R " - << rin << ":" << rout; - edm::LogVerbatim("HGCalGeom") << "Dump copiesInLayers for " - << php.copiesInLayers_.size() << " layers"; - for (unsigned int k=0; k::const_iterator itr=theModules.begin(); - itr != theModules.end(); ++itr,++k2) { - edm::LogVerbatim("HGCalGeom") << "[" << k2 << "] " << itr->first << ":" - << itr->second; + for (std::unordered_map::const_iterator itr = theModules.begin(); + itr != theModules.end(); ++itr, ++k2) { + edm::LogVerbatim("HGCalGeom") + << "[" << k2 << "] " << itr->first << ":" << itr->second; } } #endif } void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { - double waferW(php.waferSize_); double waferS(php.sensorSeparation_); - auto wType = std::make_unique(php.radius100to200_, - php.radius200to300_, - HGCalParameters::k_ScaleToDDD*(waferW+waferS), - HGCalParameters::k_ScaleToDDD*php.zMinForRad_, - php.choiceType_, - php.nCornerCut_, - php.fracAreaMin_); - + auto wType = std::make_unique( + php.radius100to200_, php.radius200to300_, + HGCalParameters::k_ScaleToDDD * (waferW + waferS), + HGCalParameters::k_ScaleToDDD * php.zMinForRad_, php.choiceType_, + php.nCornerCut_, php.fracAreaMin_); + double rout(php.rLimit_[1]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Input waferWidth " << waferW << ":" - << waferS << " R Max: " << rout; + edm::LogVerbatim("HGCalGeom") + << "Input waferWidth " << waferW << ":" << waferS << " R Max: " << rout; #endif // Clear the vectors php.waferCopy_.clear(); @@ -964,338 +957,337 @@ void HGCalGeomParameters::loadWaferHexagon8(HGCalParameters& php) { php.waferTypeT_.clear(); php.waferPosX_.clear(); php.waferPosY_.clear(); - double r = 0.5*(waferW+waferS); - double R = 2.0*r/sqrt3_; - double dy = 0.75*R; - int N = (r == 0) ? 3 : ((int)(0.5*rout/r) + 3); - int ns1 = (2*N+1)*(2*N+1); - int ns2 = ns1*php.zLayerHex_.size(); + double r = 0.5 * (waferW + waferS); + double R = 2.0 * r / sqrt3_; + double dy = 0.75 * R; + int N = (r == 0) ? 3 : ((int)(0.5 * rout / r) + 3); + int ns1 = (2 * N + 1) * (2 * N + 1); + int ns2 = ns1 * php.zLayerHex_.size(); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "r " << r << " dy " << dy << " N " << N << " sizes " << ns1 << ":" << ns2; - std::vector indtypes(ns1+1); + std::vector indtypes(ns1 + 1); indtypes.clear(); #endif - HGCalParameters::wafer_map wafersInLayers(ns1+1); - HGCalParameters::wafer_map typesInLayers(ns2+1); - HGCalParameters::waferT_map waferTypes(ns2+1); + HGCalParameters::wafer_map wafersInLayers(ns1 + 1); + HGCalParameters::wafer_map typesInLayers(ns2 + 1); + HGCalParameters::waferT_map waferTypes(ns2 + 1); int ipos(0), lpos(0), uvmax(0); - std::vector uvmx(php.zLayerHex_.size(),0); + std::vector uvmx(php.zLayerHex_.size(), 0); for (int v = -N; v <= N; ++v) { for (int u = -N; u <= N; ++u) { - int nr = 2*v; - int nc =-2*u+v; - double xpos = nc*r; - double ypos = nr*dy; - int indx = HGCalWaferIndex::waferIndex(0,u,v); + int nr = 2 * v; + int nc = -2 * u + v; + double xpos = nc * r; + double ypos = nr * dy; + int indx = HGCalWaferIndex::waferIndex(0, u, v); php.waferCopy_.emplace_back(indx); php.waferPosX_.emplace_back(xpos); php.waferPosY_.emplace_back(ypos); wafersInLayers[indx] = ipos; ++ipos; - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, r, R, 0, rout, false); - if ((corner.first == (int)(HGCalParameters::k_CornerSize)) || + std::pair corner = + HGCalGeomTools::waferCorner(xpos, ypos, r, R, 0, rout, false); + if ((corner.first == (int)(HGCalParameters::k_CornerSize)) || ((corner.first > 0) && php.defineFull_)) { - uvmax = std::max(uvmax,std::max(std::abs(u),std::abs(v))); + uvmax = std::max(uvmax, std::max(std::abs(u), std::abs(v))); } - for (unsigned int i=0; igetType(HGCalParameters::k_ScaleToDDD*xpos,HGCalParameters::k_ScaleToDDD*ypos,HGCalParameters::k_ScaleToDDD*zpos); + int type = wType->getType(HGCalParameters::k_ScaleToDDD * xpos, + HGCalParameters::k_ScaleToDDD * ypos, + HGCalParameters::k_ScaleToDDD * zpos); php.waferTypeL_.emplace_back(type); - int kndx = HGCalWaferIndex::waferIndex(lay,u,v); + int kndx = HGCalWaferIndex::waferIndex(lay, u, v); typesInLayers[kndx] = lpos; ++lpos; #ifdef EDM_ML_DEBUG indtypes.emplace_back(kndx); #endif - std::pair corner = - HGCalGeomTools::waferCorner(xpos, ypos, r, R, - php.rMinLayHex_[i], - php.rMaxLayHex_[i], false); + std::pair corner = HGCalGeomTools::waferCorner( + xpos, ypos, r, R, php.rMinLayHex_[i], php.rMaxLayHex_[i], false); #ifdef EDM_ML_DEBUG - if (((corner.first==0) && std::abs(u) < 5 && std::abs(v) < 5) || + if (((corner.first == 0) && std::abs(u) < 5 && std::abs(v) < 5) || (std::abs(u) < 2 && std::abs(v) < 2)) { - edm::LogVerbatim("HGCalGeom") << "Layer " << lay << " R " - << php.rMinLayHex_[i] << ":" - << php.rMaxLayHex_[i] << " u " - << u << " v " << v << " with " - << corner.first << " corners"; + edm::LogVerbatim("HGCalGeom") + << "Layer " << lay << " R " << php.rMinLayHex_[i] << ":" + << php.rMaxLayHex_[i] << " u " << u << " v " << v << " with " + << corner.first << " corners"; } #endif - if ((corner.first == (int)(HGCalParameters::k_CornerSize)) || + if ((corner.first == (int)(HGCalParameters::k_CornerSize)) || ((corner.first > 0) && php.defineFull_)) { - uvmx[i] = std::max(uvmx[i],std::max(std::abs(u),std::abs(v))); + uvmx[i] = std::max(uvmx[i], std::max(std::abs(u), std::abs(v))); } - if ((corner.first < (int)(HGCalParameters::k_CornerSize)) && + if ((corner.first < (int)(HGCalParameters::k_CornerSize)) && (corner.first > 0)) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Layer " << lay << " u|v " << u - << ":" << v << " with " - << corner.first << " corners First " - << corner.second; + edm::LogVerbatim("HGCalGeom") + << "Layer " << lay << " u|v " << u << ":" << v << " with " + << corner.first << " corners First " << corner.second; #endif - int wl = HGCalWaferIndex::waferIndex(lay,u,v); - waferTypes[wl] = std::make_pair(corner.first,corner.second); + int wl = HGCalWaferIndex::waferIndex(lay, u, v); + waferTypes[wl] = std::make_pair(corner.first, corner.second); } } } } - php.waferUVMax_ = uvmax; - php.waferUVMaxLayer_= uvmx; + php.waferUVMax_ = uvmax; + php.waferUVMaxLayer_ = uvmx; php.wafersInLayers_ = wafersInLayers; - php.typesInLayers_ = typesInLayers; - php.waferTypes_ = waferTypes; - php.nSectors_ = (int)(php.waferCopy_.size()); + php.typesInLayers_ = typesInLayers; + php.waferTypes_ = waferTypes; + php.nSectors_ = (int)(php.waferCopy_.size()); HGCalParameters::hgtrap mytr; - mytr.lay = 1; mytr.bl = php.waferR_; - mytr.tl = php.waferR_; mytr.h = php.waferR_; - mytr.alpha = 0.0; mytr.cellSize = HGCalParameters::k_ScaleToDDD*php.waferSize_; - for (auto const & dz : php.cellThickness_) { - mytr.dz = 0.5*HGCalParameters::k_ScaleToDDD*dz; - php.fillModule(mytr,false); + mytr.lay = 1; + mytr.bl = php.waferR_; + mytr.tl = php.waferR_; + mytr.h = php.waferR_; + mytr.alpha = 0.0; + mytr.cellSize = HGCalParameters::k_ScaleToDDD * php.waferSize_; + for (auto const& dz : php.cellThickness_) { + mytr.dz = 0.5 * HGCalParameters::k_ScaleToDDD * dz; + php.fillModule(mytr, false); } - for (unsigned k=0; k php.waferUVMax_) php.waferUVMax_ = php.iradMaxBH_[k]; - int kk = ((php.firstLayer_+(int)(k)) < php.layerFrontBH_[1]) ? 0 : 1; + for (unsigned int k = 0; k < php.zLayerHex_.size(); ++k) { + if (php.iradMaxBH_[k] > php.waferUVMax_) + php.waferUVMax_ = php.iradMaxBH_[k]; + int kk = ((php.firstLayer_ + (int)(k)) < php.layerFrontBH_[1]) ? 0 : 1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Layer " << php.firstLayer_+k << ":" - << kk << " Radius range " - << php.iradMinBH_[k] << ":" - << php.iradMaxBH_[k]; + edm::LogVerbatim("HGCalGeom") + << "Layer " << php.firstLayer_ + k << ":" << kk << " Radius range " + << php.iradMinBH_[k] << ":" << php.iradMaxBH_[k]; #endif mytr.lay = php.firstLayer_ + k; - for (int irad=php.iradMinBH_[k]; irad<=php.iradMaxBH_[k]; ++irad) { - double rmin = php.radiusLayer_[kk][irad-1]; - double rmax = php.radiusLayer_[kk][irad]; - mytr.bl = 0.5*rmin*php.scintCellSize(mytr.lay); - mytr.tl = 0.5*rmax*php.scintCellSize(mytr.lay); - mytr.h = 0.5*(rmax-rmin); - mytr.dz = 0.5*php.waferThick_; - mytr.cellSize = 0.5*(rmax+rmin)*php.scintCellSize(mytr.lay); - php.fillModule(mytr,true); - mytr.bl *= HGCalParameters::k_ScaleToDDD; - mytr.tl *= HGCalParameters::k_ScaleToDDD; - mytr.h *= HGCalParameters::k_ScaleToDDD; - mytr.dz *= HGCalParameters::k_ScaleToDDD; + for (int irad = php.iradMinBH_[k]; irad <= php.iradMaxBH_[k]; ++irad) { + double rmin = php.radiusLayer_[kk][irad - 1]; + double rmax = php.radiusLayer_[kk][irad]; + mytr.bl = 0.5 * rmin * php.scintCellSize(mytr.lay); + mytr.tl = 0.5 * rmax * php.scintCellSize(mytr.lay); + mytr.h = 0.5 * (rmax - rmin); + mytr.dz = 0.5 * php.waferThick_; + mytr.cellSize = 0.5 * (rmax + rmin) * php.scintCellSize(mytr.lay); + php.fillModule(mytr, true); + mytr.bl *= HGCalParameters::k_ScaleToDDD; + mytr.tl *= HGCalParameters::k_ScaleToDDD; + mytr.h *= HGCalParameters::k_ScaleToDDD; + mytr.dz *= HGCalParameters::k_ScaleToDDD; mytr.cellSize *= HGCalParameters::k_ScaleFromDDD; php.fillModule(mytr, false); - if (irad == php.iradMinBH_[k]) php.firstModule_.emplace_back(im); + if (irad == php.iradMinBH_[k]) php.firstModule_.emplace_back(im); ++im; - if (irad == php.iradMaxBH_[k]-1) php.lastModule_.emplace_back(im); + if (irad == php.iradMaxBH_[k] - 1) php.lastModule_.emplace_back(im); } } - php.nSectors_ = php.waferUVMax_; + php.nSectors_ = php.waferUVMax_; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Maximum radius index " << php.waferUVMax_; - for (unsigned int k=0; k< php.firstModule_.size(); ++k) - edm::LogVerbatim("HGCalGeom") << "Layer " << k+php.firstLayer_ - << " Modules " << php.firstModule_[k] - << ":" << php.lastModule_[k]; + for (unsigned int k = 0; k < php.firstModule_.size(); ++k) + edm::LogVerbatim("HGCalGeom") + << "Layer " << k + php.firstLayer_ << " Modules " << php.firstModule_[k] + << ":" << php.lastModule_[k]; #endif } -std::vector HGCalGeomParameters::getDDDArray(const std::string & str, - const DDsvalues_type & sv, - const int nmin) { +std::vector HGCalGeomParameters::getDDDArray(const std::string& str, + const DDsvalues_type& sv, + const int nmin) { DDValue value(str); - if (DDfetch(&sv,value)) { - const std::vector & fvec = value.doubles(); + if (DDfetch(&sv, value)) { + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nmin > 0) { if (nval < nmin) { - edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str - << " bins " << nval << " < " << nmin - << " ==> illegal"; - throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str; + edm::LogError("HGCalGeom") + << "HGCalGeomParameters : # of " << str << " bins " << nval << " < " + << nmin << " ==> illegal"; + throw cms::Exception("DDException") + << "HGCalGeomParameters: cannot get array " << str; } } else { if (nval < 1 && nmin == 0) { edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str << " bins " << nval << " < 1 ==> illegal" << " (nmin=" << nmin << ")"; - throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str; + throw cms::Exception("DDException") + << "HGCalGeomParameters: cannot get array " << str; } } return fvec; } else { if (nmin >= 0) { - edm::LogError("HGCalGeom") << "HGCalGeomParameters: cannot get array " - << str; - throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str; + edm::LogError("HGCalGeom") + << "HGCalGeomParameters: cannot get array " << str; + throw cms::Exception("DDException") + << "HGCalGeomParameters: cannot get array " << str; } std::vector fvec; return fvec; } } -std::pair -HGCalGeomParameters::cellPosition(const std::vector& wafers, - std::vector::const_iterator& itrf, - int wafer, double xx, double yy) { - +std::pair HGCalGeomParameters::cellPosition( + const std::vector& wafers, + std::vector::const_iterator& itrf, + int wafer, double xx, double yy) { if (itrf == wafers.end()) { - for (std::vector::const_iterator itr = wafers.begin(); + for (std::vector::const_iterator itr = + wafers.begin(); itr != wafers.end(); ++itr) { if (itr->wafer == wafer) { itrf = itr; @@ -1310,5 +1302,5 @@ HGCalGeomParameters::cellPosition(const std::vectorxyz.y()); if (std::abs(dy) < tolerance) dy = 0; } - return std::make_pair(dx,dy); + return std::make_pair(dx, dy); } diff --git a/Geometry/HGCalCommonData/src/HGCalGeomTools.cc b/Geometry/HGCalCommonData/src/HGCalGeomTools.cc index 4b5eb738822ee..33714ed8ddbc2 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomTools.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomTools.cc @@ -1,94 +1,99 @@ #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" -#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include //#define EDM_ML_DEBUG double HGCalGeomTools::radius(double z, std::vector const& zFront, - std::vector const& rFront, - std::vector const& slope) { - + std::vector const& rFront, + std::vector const& slope) { double r = rFront[0]; #ifdef EDM_ML_DEBUG unsigned int ik(0); #endif - for (unsigned int k=0; k const& zFront, - std::vector const& rFront) { - + std::vector const& zFront, + std::vector const& rFront) { double r = rFront[0]; #ifdef EDM_ML_DEBUG unsigned int ik(0); #endif - for (unsigned int k=0; k HGCalGeomTools::zradius(double z1, double z2, - std::vector const& zF, - std::vector const& rF) { - +std::pair HGCalGeomTools::zradius( + double z1, double z2, std::vector const& zF, + std::vector const& rF) { double z(-1), r(-1); - for (unsigned int k=0; k zF[k]-tol) && (z2 < zF[k]+tol)) { - z = zF[k]; r = rF[k]; break; + for (unsigned int k = 0; k < rF.size(); ++k) { + if ((z1 > zF[k] - tol) && (z2 < zF[k] + tol)) { + z = zF[k]; + r = rF[k]; + break; } } - return std::make_pair(z,r); + return std::make_pair(z, r); } - -std::pair HGCalGeomTools::waferCorner(double xpos, - double ypos, - double r, double R, - double rMin, - double rMax, - bool oldBug) { + +std::pair HGCalGeomTools::waferCorner(double xpos, + double ypos, double r, + double R, double rMin, + double rMax, + bool oldBug) { double xc[HGCalParameters::k_CornerSize], yc[HGCalParameters::k_CornerSize]; - xc[0] = xpos; yc[0] = ypos+R; - xc[1] = xpos-r; yc[1] = ypos+0.5*R; + xc[0] = xpos; + yc[0] = ypos + R; + xc[1] = xpos - r; + yc[1] = ypos + 0.5 * R; if (oldBug) { - xc[2] = xpos+r; yc[2] = ypos-0.5*R; + xc[2] = xpos + r; + yc[2] = ypos - 0.5 * R; } else { - xc[2] = xpos-r; yc[2] = ypos-0.5*R; + xc[2] = xpos - r; + yc[2] = ypos - 0.5 * R; } - xc[3] = xpos; yc[3] = ypos-R; - xc[4] = xpos+r; yc[4] = ypos-0.5*R; - xc[5] = xpos+r; yc[5] = ypos+0.5*R; - int32_t nCorner(0), firstCorner(-1), firstMiss(-1); + xc[3] = xpos; + yc[3] = ypos - R; + xc[4] = xpos + r; + yc[4] = ypos - 0.5 * R; + xc[5] = xpos + r; + yc[5] = ypos + 0.5 * R; + int32_t nCorner(0), firstCorner(-1), firstMiss(-1); #ifdef EDM_ML_DEBUG std::vector corners; #endif - for (uint32_t k=0; k= rMin)) { #ifdef EDM_ML_DEBUG corners.emplace_back(k); @@ -96,23 +101,25 @@ std::pair HGCalGeomTools::waferCorner(double xpos, if (firstCorner < 0) firstCorner = k; ++nCorner; } else { - if (firstMiss < 0) firstMiss = k; + if (firstMiss < 0) firstMiss = k; } } if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) { - firstCorner = firstMiss+HGCalParameters::k_CornerSize-nCorner; + firstCorner = firstMiss + HGCalParameters::k_CornerSize - nCorner; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "waferCorner:: R " << rMin << ":" << rMax - << nCorner << " corners; first corner " - << firstCorner; - for (uint32_t k=0; k -HGCalStringToEnumParser::HGCalStringToEnumParser() { - enumMap["HGCalGeometryMode::Square"] = HGCalGeometryMode::Square; - enumMap["HGCalGeometryMode::Hexagon"] = HGCalGeometryMode::Hexagon; - enumMap["HGCalGeometryMode::HexagonFull"] = HGCalGeometryMode::HexagonFull; - enumMap["HGCalGeometryMode::Hexagon8"] = HGCalGeometryMode::Hexagon8; +template <> +HGCalStringToEnumParser< + HGCalGeometryMode::GeometryMode>::HGCalStringToEnumParser() { + enumMap["HGCalGeometryMode::Square"] = HGCalGeometryMode::Square; + enumMap["HGCalGeometryMode::Hexagon"] = HGCalGeometryMode::Hexagon; + enumMap["HGCalGeometryMode::HexagonFull"] = HGCalGeometryMode::HexagonFull; + enumMap["HGCalGeometryMode::Hexagon8"] = HGCalGeometryMode::Hexagon8; enumMap["HGCalGeometryMode::Hexagon8Full"] = HGCalGeometryMode::Hexagon8Full; - enumMap["HGCalGeometryMode::Trapezoid"] = HGCalGeometryMode::Trapezoid; - } - -template<> -HGCalStringToEnumParser::HGCalStringToEnumParser() { - enumMap["HGCalGeometryMode::Polyhedra"] = HGCalGeometryMode::Polyhedra; - enumMap["HGCalGeometryMode::ExtrudedPolygon"] = HGCalGeometryMode::ExtrudedPolygon; + enumMap["HGCalGeometryMode::Trapezoid"] = HGCalGeometryMode::Trapezoid; } +template <> +HGCalStringToEnumParser< + HGCalGeometryMode::WaferMode>::HGCalStringToEnumParser() { + enumMap["HGCalGeometryMode::Polyhedra"] = HGCalGeometryMode::Polyhedra; + enumMap["HGCalGeometryMode::ExtrudedPolygon"] = + HGCalGeometryMode::ExtrudedPolygon; +} diff --git a/Geometry/HGCalCommonData/src/HGCalParameters.cc b/Geometry/HGCalCommonData/src/HGCalParameters.cc index 7bed7bb3dfdde..5f0550ff433b8 100644 --- a/Geometry/HGCalCommonData/src/HGCalParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalParameters.cc @@ -1,19 +1,18 @@ #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" //#define EDM_ML_DEBUG -HGCalParameters::HGCalParameters(const std::string& nam): name_(nam) { +HGCalParameters::HGCalParameters(const std::string& nam) : name_(nam) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Construct HGCalParameters for " << name_; #endif - } +} -HGCalParameters::~HGCalParameters() { } +HGCalParameters::~HGCalParameters() {} void HGCalParameters::fillModule(const HGCalParameters::hgtrap& mytr, - bool reco) { - + bool reco) { if (reco) { moduleLayR_.emplace_back(mytr.lay); moduleBlR_.emplace_back(mytr.bl); @@ -33,60 +32,56 @@ void HGCalParameters::fillModule(const HGCalParameters::hgtrap& mytr, } } -HGCalParameters::hgtrap HGCalParameters::getModule(unsigned int k, - bool reco) const { +HGCalParameters::hgtrap HGCalParameters::getModule(unsigned int k, + bool reco) const { HGCalParameters::hgtrap mytr; if (reco) { if (k < moduleLayR_.size()) { - mytr.lay = moduleLayR_[k]; - mytr.bl = moduleBlR_[k]; - mytr.tl = moduleTlR_[k]; - mytr.h = moduleHR_[k]; - mytr.dz = moduleDzR_[k]; - mytr.alpha = moduleAlphaR_[k]; + mytr.lay = moduleLayR_[k]; + mytr.bl = moduleBlR_[k]; + mytr.tl = moduleTlR_[k]; + mytr.h = moduleHR_[k]; + mytr.dz = moduleDzR_[k]; + mytr.alpha = moduleAlphaR_[k]; mytr.cellSize = moduleCellR_[k]; } else { - mytr.lay = -1; - mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0; + mytr.lay = -1; + mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0; } } else { if (k < moduleLayS_.size()) { - mytr.lay = moduleLayS_[k]; - mytr.bl = moduleBlS_[k]; - mytr.tl = moduleTlS_[k]; - mytr.h = moduleHS_[k]; - mytr.dz = moduleDzS_[k]; - mytr.alpha = moduleAlphaS_[k]; + mytr.lay = moduleLayS_[k]; + mytr.bl = moduleBlS_[k]; + mytr.tl = moduleTlS_[k]; + mytr.h = moduleHS_[k]; + mytr.dz = moduleDzS_[k]; + mytr.alpha = moduleAlphaS_[k]; mytr.cellSize = moduleCellS_[k]; } else { - mytr.lay = -1; - mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0; + mytr.lay = -1; + mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0; } } return mytr; } void HGCalParameters::fillTrForm(const HGCalParameters::hgtrform& mytr) { - - int zp = (mytr.zp == 1) ? 1 : 0; - uint32_t indx = ((zp & kMaskZside) << kShiftZside); - indx |= ((mytr.lay & kMaskLayer) << kShiftLayer); - indx |= ((mytr.sec & kMaskSector) << kShiftSector); - indx |= ((mytr.subsec & kMaskSubSec) << kShiftSubSec); + int zp = (mytr.zp == 1) ? 1 : 0; + uint32_t indx = ((zp & kMaskZside) << kShiftZside); + indx |= ((mytr.lay & kMaskLayer) << kShiftLayer); + indx |= ((mytr.sec & kMaskSector) << kShiftSector); + indx |= ((mytr.subsec & kMaskSubSec) << kShiftSubSec); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "ZP " << zp << ":" << kMaskZside << ":" - << kShiftZside - << ((zp & kMaskZside) << kShiftZside) - << " Lay " << mytr.lay << ":" << kMaskLayer - << ":" << kShiftLayer << ":" - << ((mytr.lay & kMaskLayer) << kShiftLayer) - << " Sector " << mytr.sec << ":" - << kMaskSector << ":" << kShiftSector << ":" - << ((mytr.sec & kMaskSector) << kShiftSector) - << " SubSec " << mytr.subsec << ":" - << kMaskSubSec << ":" << kShiftSubSec << ":" - <<((mytr.subsec & kMaskSubSec) << kShiftSubSec) - << " Index " << std::hex << indx << std::dec; + edm::LogVerbatim("HGCalGeom") + << "ZP " << zp << ":" << kMaskZside << ":" << kShiftZside + << ((zp & kMaskZside) << kShiftZside) << " Lay " << mytr.lay << ":" + << kMaskLayer << ":" << kShiftLayer << ":" + << ((mytr.lay & kMaskLayer) << kShiftLayer) << " Sector " << mytr.sec + << ":" << kMaskSector << ":" << kShiftSector << ":" + << ((mytr.sec & kMaskSector) << kShiftSector) << " SubSec " << mytr.subsec + << ":" << kMaskSubSec << ":" << kShiftSubSec << ":" + << ((mytr.subsec & kMaskSubSec) << kShiftSubSec) << " Index " << std::hex + << indx << std::dec; #endif trformIndex_.emplace_back(indx); trformTranX_.emplace_back(mytr.h3v.x()); @@ -103,81 +98,74 @@ void HGCalParameters::fillTrForm(const HGCalParameters::hgtrform& mytr) { trformRotZZ_.emplace_back(mytr.hr.zz()); #ifdef EDM_ML_DEBUG unsigned int k = trformIndex_.size() - 1; - edm::LogVerbatim("HGCalGeom") << "HGCalParameters[" << k << "] Index " - << std::hex << trformIndex_[k] << std::dec - << " (" << mytr.zp << ", "<< mytr.lay - << ", " << mytr.sec << ", " << mytr.subsec - << ") Translation (" << trformTranX_[k] << ", " - << trformTranY_[k] << ", " << trformTranZ_[k] - << ") Rotation (" << trformRotXX_[k] << ", " - << trformRotYX_[k] << ", " << trformRotZX_[k] - << ", " << trformRotXY_[k] << ", " - << trformRotYY_[k] << ", " << trformRotZY_[k] - << ", " << trformRotXZ_[k] << ", " - << trformRotYZ_[k] << ", " << trformRotZZ_[k]; + edm::LogVerbatim("HGCalGeom") + << "HGCalParameters[" << k << "] Index " << std::hex << trformIndex_[k] + << std::dec << " (" << mytr.zp << ", " << mytr.lay << ", " << mytr.sec + << ", " << mytr.subsec << ") Translation (" << trformTranX_[k] << ", " + << trformTranY_[k] << ", " << trformTranZ_[k] << ") Rotation (" + << trformRotXX_[k] << ", " << trformRotYX_[k] << ", " << trformRotZX_[k] + << ", " << trformRotXY_[k] << ", " << trformRotYY_[k] << ", " + << trformRotZY_[k] << ", " << trformRotXZ_[k] << ", " << trformRotYZ_[k] + << ", " << trformRotZZ_[k]; #endif } HGCalParameters::hgtrform HGCalParameters::getTrForm(unsigned int k) const { - HGCalParameters::hgtrform mytr; if (k < trformIndex_.size()) { - const auto & id = getID(k); - mytr.zp = id[0]; - mytr.lay = id[1]; - mytr.sec = id[2]; - mytr.subsec= id[3]; - mytr.h3v = CLHEP::Hep3Vector(trformTranX_[k],trformTranY_[k],trformTranZ_[k]); - const CLHEP::HepRep3x3 rotation(trformRotXX_[k],trformRotXY_[k],trformRotXZ_[k], - trformRotYX_[k],trformRotYY_[k],trformRotYZ_[k], - trformRotZX_[k],trformRotZY_[k],trformRotZZ_[k]); + const auto& id = getID(k); + mytr.zp = id[0]; + mytr.lay = id[1]; + mytr.sec = id[2]; + mytr.subsec = id[3]; + mytr.h3v = + CLHEP::Hep3Vector(trformTranX_[k], trformTranY_[k], trformTranZ_[k]); + const CLHEP::HepRep3x3 rotation( + trformRotXX_[k], trformRotXY_[k], trformRotXZ_[k], trformRotYX_[k], + trformRotYY_[k], trformRotYZ_[k], trformRotZX_[k], trformRotZY_[k], + trformRotZZ_[k]); mytr.hr = CLHEP::HepRotation(rotation); } else { mytr.zp = mytr.lay = mytr.sec = mytr.subsec = 0; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalParameters[" << k << "] Index " - << std::hex << trformIndex_[k] << std::dec - << " (" << mytr.zp << ", "<< mytr.lay - << ", " << mytr.sec << ", " << mytr.subsec - << ") Translation (" << mytr.h3v.x() << ", " - << mytr.h3v.y() << ", " << mytr.h3v.z() - << ") Rotation (" << mytr.hr.xx() << ", " - << mytr.hr.yx() << ", " << mytr.hr.zx() << ", " - << mytr.hr.xy() << ", " << mytr.hr.yy() - << ", " << mytr.hr.zy() << ", " << mytr.hr.xz() - << ", " << mytr.hr.yz() <<", " << mytr.hr.zz(); + edm::LogVerbatim("HGCalGeom") + << "HGCalParameters[" << k << "] Index " << std::hex << trformIndex_[k] + << std::dec << " (" << mytr.zp << ", " << mytr.lay << ", " << mytr.sec + << ", " << mytr.subsec << ") Translation (" << mytr.h3v.x() << ", " + << mytr.h3v.y() << ", " << mytr.h3v.z() << ") Rotation (" << mytr.hr.xx() + << ", " << mytr.hr.yx() << ", " << mytr.hr.zx() << ", " << mytr.hr.xy() + << ", " << mytr.hr.yy() << ", " << mytr.hr.zy() << ", " << mytr.hr.xz() + << ", " << mytr.hr.yz() << ", " << mytr.hr.zz(); #endif return mytr; } void HGCalParameters::addTrForm(const CLHEP::Hep3Vector& h3v) { - unsigned int k = trformTranX_.size(); if (k > 0) { - trformTranX_[k-1] += h3v.x(); - trformTranY_[k-1] += h3v.y(); - trformTranZ_[k-1] += h3v.z(); + trformTranX_[k - 1] += h3v.x(); + trformTranY_[k - 1] += h3v.y(); + trformTranZ_[k - 1] += h3v.z(); } } void HGCalParameters::scaleTrForm(double scale) { unsigned int k = trformTranX_.size(); if (k > 0) { - trformTranX_[k-1] *= scale; - trformTranY_[k-1] *= scale; - trformTranZ_[k-1] *= scale; + trformTranX_[k - 1] *= scale; + trformTranY_[k - 1] *= scale; + trformTranZ_[k - 1] *= scale; } } -std::array HGCalParameters::getID(unsigned int k) const { - - int zp = ((trformIndex_[k] >> kShiftZside) & kMaskZside); +std::array HGCalParameters::getID(unsigned int k) const { + int zp = ((trformIndex_[k] >> kShiftZside) & kMaskZside); if (zp != 1) zp = -1; - int lay = ((trformIndex_[k] >> kShiftLayer) & kMaskLayer); - int sec = ((trformIndex_[k] >> kShiftSector) & kMaskSector); + int lay = ((trformIndex_[k] >> kShiftLayer) & kMaskLayer); + int sec = ((trformIndex_[k] >> kShiftSector) & kMaskSector); int subsec = ((trformIndex_[k] >> kShiftSubSec) & kMaskSubSec); - return std::array{ {zp,lay,sec,subsec} }; + return std::array{{zp, lay, sec, subsec}}; } #include "FWCore/Utilities/interface/typelookup.h" diff --git a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc index dd26a645dc915..489b40963727c 100644 --- a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc +++ b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc @@ -1,72 +1,72 @@ #include "Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h" -#include "Geometry/HGCalCommonData/interface/HGCalGeomParameters.h" -#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" -#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" #include "DetectorDescription/Core/interface/DDutils.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeomParameters.h" +#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" -#include #include +#include +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" //#define EDM_ML_DEBUG namespace { - HGCalGeometryMode::GeometryMode getGeometryMode(const char* s, - const DDsvalues_type & sv) { - DDValue val(s); - if (DDfetch(&sv, val)) { - const std::vector & fvec = val.strings(); - if (fvec.empty()) { - throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; - } - - HGCalStringToEnumParser eparser; - HGCalGeometryMode::GeometryMode result = (HGCalGeometryMode::GeometryMode) eparser.parseString(fvec[0]); - return result; - } else { - throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag"; +HGCalGeometryMode::GeometryMode getGeometryMode(const char* s, + const DDsvalues_type& sv) { + DDValue val(s); + if (DDfetch(&sv, val)) { + const std::vector& fvec = val.strings(); + if (fvec.empty()) { + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; } - } - HGCalGeometryMode::WaferMode getGeometryWaferMode(const char* s, - const DDsvalues_type & sv){ - DDValue val(s); - if (DDfetch(&sv, val)) { - const std::vector & fvec = val.strings(); - if (fvec.empty()) { - throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; - } - HGCalStringToEnumParser eparser; - HGCalGeometryMode::WaferMode result = (HGCalGeometryMode::WaferMode) eparser.parseString(fvec[0]); - return result; - } else { - throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag"; + HGCalStringToEnumParser eparser; + HGCalGeometryMode::GeometryMode result = + (HGCalGeometryMode::GeometryMode)eparser.parseString(fvec[0]); + return result; + } else { + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag"; + } +} +HGCalGeometryMode::WaferMode getGeometryWaferMode(const char* s, + const DDsvalues_type& sv) { + DDValue val(s); + if (DDfetch(&sv, val)) { + const std::vector& fvec = val.strings(); + if (fvec.empty()) { + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; } + + HGCalStringToEnumParser eparser; + HGCalGeometryMode::WaferMode result = + (HGCalGeometryMode::WaferMode)eparser.parseString(fvec[0]); + return result; + } else { + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag"; } } +} // namespace bool HGCalParametersFromDD::build(const DDCompactView* cpv, - HGCalParameters& php, - const std::string& name, - const std::string& namew, - const std::string& namec, - const std::string& namet) { - + HGCalParameters& php, const std::string& name, + const std::string& namew, + const std::string& namec, + const std::string& namet) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalParametersFromDD::build called with " - << "names " << name << ":" << namew << ":" - << namec << ":" << namet; + edm::LogVerbatim("HGCalGeom") + << "HGCalParametersFromDD::build called with " + << "names " << name << ":" << namew << ":" << namec << ":" << namet; #endif - //Special parameters at simulation level - std::string attribute = "Volume"; - std::string value = name; + // Special parameters at simulation level + std::string attribute = "Volume"; + std::string value = name; DDValue val(attribute, value, 0.0); DDSpecificsMatchesValueFilter filter{val}; - DDFilteredView fv(*cpv,filter); + DDFilteredView fv(*cpv, filter); bool ok = fv.firstChild(); HGCalGeometryMode::WaferMode mode(HGCalGeometryMode::Polyhedra); @@ -74,170 +74,173 @@ bool HGCalParametersFromDD::build(const DDCompactView* cpv, DDsvalues_type sv(fv.mergedSpecifics()); php.mode_ = getGeometryMode("GeometryMode", sv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "GeometryMode " << php.mode_ - << ":" << HGCalGeometryMode::Hexagon << ":" - << HGCalGeometryMode::HexagonFull << ":" - << ":" << HGCalGeometryMode::Hexagon8 << ":" - << HGCalGeometryMode::Hexagon8Full << ":" - << ":" << HGCalGeometryMode::Trapezoid; + edm::LogVerbatim("HGCalGeom") + << "GeometryMode " << php.mode_ << ":" << HGCalGeometryMode::Hexagon + << ":" << HGCalGeometryMode::HexagonFull << ":" + << ":" << HGCalGeometryMode::Hexagon8 << ":" + << HGCalGeometryMode::Hexagon8Full << ":" + << ":" << HGCalGeometryMode::Trapezoid; #endif - php.levelZSide_ = 3; // Default level for ZSide - php.detectorType_ = 0; // These two parameters are - php.firstMixedLayer_ =-1; // defined for post TDR geometry - HGCalGeomParameters *geom = new HGCalGeomParameters(); + php.levelZSide_ = 3; // Default level for ZSide + php.detectorType_ = 0; // These two parameters are + php.firstMixedLayer_ = -1; // defined for post TDR geometry + HGCalGeomParameters* geom = new HGCalGeomParameters(); if ((php.mode_ == HGCalGeometryMode::Hexagon) || - (php.mode_ == HGCalGeometryMode::HexagonFull)) { - attribute = "OnlyForHGCalNumbering"; - value = namet; + (php.mode_ == HGCalGeometryMode::HexagonFull)) { + attribute = "OnlyForHGCalNumbering"; + value = namet; DDValue val2(attribute, value, 0.0); DDSpecificsMatchesValueFilter filter2{val2}; - DDFilteredView fv2(*cpv,filter2); + DDFilteredView fv2(*cpv, filter2); bool ok2 = fv2.firstChild(); if (ok2) { - DDsvalues_type sv2(fv2.mergedSpecifics()); - mode = getGeometryWaferMode("WaferMode", sv2); + DDsvalues_type sv2(fv2.mergedSpecifics()); + mode = getGeometryWaferMode("WaferMode", sv2); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" - << HGCalGeometryMode::Polyhedra << ":" - << HGCalGeometryMode::ExtrudedPolygon; + edm::LogVerbatim("HGCalGeom") + << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra + << ":" << HGCalGeometryMode::ExtrudedPolygon; #endif } - php.minTileSize_ = 0; + php.minTileSize_ = 0; } if ((php.mode_ == HGCalGeometryMode::Hexagon8) || - (php.mode_ == HGCalGeometryMode::Hexagon8Full)) { - php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv)); - php.levelZSide_ = (int)(getDDDValue("LevelZSide",sv)); - php.nCellsFine_ = php.nCellsCoarse_ = 0; - php.firstLayer_ = 1; + (php.mode_ == HGCalGeometryMode::Hexagon8Full)) { + php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv)); + php.levelZSide_ = (int)(getDDDValue("LevelZSide", sv)); + php.nCellsFine_ = php.nCellsCoarse_ = 0; + php.firstLayer_ = 1; php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv)); - php.detectorType_ = (int)(getDDDValue("DetectorType", sv)); - php.minTileSize_ = 0; + php.detectorType_ = (int)(getDDDValue("DetectorType", sv)); + php.minTileSize_ = 0; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" - << php.levelT_[1] << " ZSide Level " - << php.levelZSide_ << " first layers " - << php.firstLayer_ << ":" - << php.firstMixedLayer_ << " Det Type " - << php.detectorType_; + edm::LogVerbatim("HGCalGeom") + << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] + << " ZSide Level " << php.levelZSide_ << " first layers " + << php.firstLayer_ << ":" << php.firstMixedLayer_ << " Det Type " + << php.detectorType_; #endif - attribute = "OnlyForHGCalNumbering"; - value = namet; + attribute = "OnlyForHGCalNumbering"; + value = namet; DDValue val2(attribute, value, 0.0); DDSpecificsMatchesValueFilter filter2{val2}; - DDFilteredView fv2(*cpv,filter2); + DDFilteredView fv2(*cpv, filter2); bool ok2 = fv2.firstChild(); if (ok2) { - DDsvalues_type sv2(fv2.mergedSpecifics()); - mode = getGeometryWaferMode("WaferMode", sv2); - php.nCellsFine_ = (int)(getDDDValue("NumberOfCellsFine", sv2)); - php.nCellsCoarse_ = (int)(getDDDValue("NumberOfCellsCoarse",sv2)); - php.waferSize_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("WaferSize", sv2); - php.waferThick_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("WaferThickness", sv2); - php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("SensorSeparation", sv2); - php.mouseBite_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("MouseBite", sv2); - php.waferR_ = 0.5*HGCalParameters::k_ScaleToDDD*php.waferSize_/std::cos(30.0*CLHEP::deg); - php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD*php.waferSize_/php.nCellsFine_); - php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD*php.waferSize_/php.nCellsCoarse_); + DDsvalues_type sv2(fv2.mergedSpecifics()); + mode = getGeometryWaferMode("WaferMode", sv2); + php.nCellsFine_ = (int)(getDDDValue("NumberOfCellsFine", sv2)); + php.nCellsCoarse_ = (int)(getDDDValue("NumberOfCellsCoarse", sv2)); + php.waferSize_ = + HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferSize", sv2); + php.waferThick_ = HGCalParameters::k_ScaleFromDDD * + getDDDValue("WaferThickness", sv2); + php.sensorSeparation_ = HGCalParameters::k_ScaleFromDDD * + getDDDValue("SensorSeparation", sv2); + php.mouseBite_ = + HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2); + php.waferR_ = 0.5 * HGCalParameters::k_ScaleToDDD * php.waferSize_ / + std::cos(30.0 * CLHEP::deg); + php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * + php.waferSize_ / php.nCellsFine_); + php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * + php.waferSize_ / php.nCellsCoarse_); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "WaferMode " << mode << ":" - << HGCalGeometryMode::Polyhedra << ":" - << HGCalGeometryMode::ExtrudedPolygon - << " # of cells|size for fine/coarse " - << php.nCellsFine_ << ":" - << php.cellSize_[0] << ":" - << php.nCellsCoarse_ << ":" - << php.cellSize_[1] << " wafer Params " - << php.waferSize_ << ":" - << php.waferR_ << ":" - << php.waferThick_ << ":" - << php.sensorSeparation_ << ":" - << php.mouseBite_ << ":" << php.waferR_; + edm::LogVerbatim("HGCalGeom") + << "WaferMode " << mode << ":" << HGCalGeometryMode::Polyhedra + << ":" << HGCalGeometryMode::ExtrudedPolygon + << " # of cells|size for fine/coarse " << php.nCellsFine_ << ":" + << php.cellSize_[0] << ":" << php.nCellsCoarse_ << ":" + << php.cellSize_[1] << " wafer Params " << php.waferSize_ << ":" + << php.waferR_ << ":" << php.waferThick_ << ":" + << php.sensorSeparation_ << ":" << php.mouseBite_ << ":" + << php.waferR_; #endif - for (int k=0; k<2; ++k) getCellPosition(php, k); + for (int k = 0; k < 2; ++k) getCellPosition(php, k); } } if (php.mode_ == HGCalGeometryMode::Hexagon) { - //Load the SpecPars + // Load the SpecPars php.firstLayer_ = 1; geom->loadSpecParsHexagon(fv, php, cpv, namew, namec); - //Load the Geometry parameters + // Load the Geometry parameters geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode); - //Load cell parameters + // Load cell parameters geom->loadCellParsHexagon(cpv, php); - //Set complete fill mode + // Set complete fill mode php.defineFull_ = false; } else if (php.mode_ == HGCalGeometryMode::HexagonFull) { - //Load the SpecPars + // Load the SpecPars php.firstLayer_ = 1; geom->loadSpecParsHexagon(fv, php, cpv, namew, namec); - //Load the Geometry parameters + // Load the Geometry parameters geom->loadGeometryHexagon(fv, php, name, cpv, namew, namec, mode); - //Modify some constants + // Modify some constants geom->loadWaferHexagon(php); - //Load cell parameters + // Load cell parameters geom->loadCellParsHexagon(cpv, php); - //Set complete fill mode + // Set complete fill mode php.defineFull_ = true; } else if (php.mode_ == HGCalGeometryMode::Hexagon8) { - //Load the SpecPars + // Load the SpecPars geom->loadSpecParsHexagon8(fv, php); - //Load Geometry parameters + // Load Geometry parameters geom->loadGeometryHexagon8(fv, php, 1); - //Set complete fill mode + // Set complete fill mode php.defineFull_ = false; - //Load wafer positions + // Load wafer positions geom->loadWaferHexagon8(php); } else if (php.mode_ == HGCalGeometryMode::Hexagon8Full) { - //Load the SpecPars + // Load the SpecPars geom->loadSpecParsHexagon8(fv, php); - //Load Geometry parameters + // Load Geometry parameters geom->loadGeometryHexagon8(fv, php, 1); - //Set complete fill mode + // Set complete fill mode php.defineFull_ = true; - //Load wafer positions + // Load wafer positions geom->loadWaferHexagon8(php); } else if (php.mode_ == HGCalGeometryMode::Trapezoid) { - //Load maximum eta & top level - php.levelT_ = dbl_to_int(getDDDArray("LevelTop",sv)); - php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv)); + // Load maximum eta & top level + php.levelT_ = dbl_to_int(getDDDArray("LevelTop", sv)); + php.firstLayer_ = (int)(getDDDValue("FirstLayer", sv)); php.firstMixedLayer_ = (int)(getDDDValue("FirstMixedLayer", sv)); - php.detectorType_ = (int)(getDDDValue("DetectorType", sv)); - php.waferThick_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("WaferThickness", sv); - php.minTileSize_ = HGCalParameters::k_ScaleFromDDD*getDDDValue("MinimumTileSize", sv); - php.waferSize_ = php.waferR_ = 0; - php.sensorSeparation_= php.mouseBite_ = 0; + php.detectorType_ = (int)(getDDDValue("DetectorType", sv)); + php.waferThick_ = + HGCalParameters::k_ScaleFromDDD * getDDDValue("WaferThickness", sv); + php.minTileSize_ = + HGCalParameters::k_ScaleFromDDD * getDDDValue("MinimumTileSize", sv); + php.waferSize_ = php.waferR_ = 0; + php.sensorSeparation_ = php.mouseBite_ = 0; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "Top levels " << php.levelT_[0] << ":" - << php.levelT_[1] << " first layers " - << php.firstLayer_ << ":" - << php.firstMixedLayer_ << " Det Type " - << php.detectorType_ << " thickenss " - << php.waferThick_; + edm::LogVerbatim("HGCalGeom") + << "Top levels " << php.levelT_[0] << ":" << php.levelT_[1] + << " first layers " << php.firstLayer_ << ":" << php.firstMixedLayer_ + << " Det Type " << php.detectorType_ << " thickenss " + << php.waferThick_; #endif - //Load the SpecPars + // Load the SpecPars geom->loadSpecParsTrapezoid(fv, php); - //Load Geometry parameters + // Load Geometry parameters geom->loadGeometryHexagon8(fv, php, php.firstLayer_); - //Load cell positions + // Load cell positions geom->loadCellTrapezoid(php); } else { - edm::LogError("HGCalGeom") << "Unknown Geometry type " << php.mode_ - << " for HGCal " << name << ":" << namew - << ":" << namec; - throw cms::Exception("DDException") - << "Unknown Geometry type " << php.mode_ << " for HGCal " << name - << ":" << namew << ":" << namec; + edm::LogError("HGCalGeom") + << "Unknown Geometry type " << php.mode_ << " for HGCal " << name + << ":" << namew << ":" << namec; + throw cms::Exception("DDException") + << "Unknown Geometry type " << php.mode_ << " for HGCal " << name + << ":" << namew << ":" << namec; } } else { - edm::LogError("HGCalGeom") << " Attribute " << val - << " not found but needed."; - throw cms::Exception("DDException") << "Attribute " << val - << " not found but needed."; + edm::LogError("HGCalGeom") + << " Attribute " << val << " not found but needed."; + throw cms::Exception("DDException") + << "Attribute " << val << " not found but needed."; } #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Return from HGCalParametersFromDD::build" - << " with flag " << ok; + << " with flag " << ok; #endif return ok; } @@ -250,89 +253,89 @@ void HGCalParametersFromDD::getCellPosition(HGCalParameters& php, int type) { php.cellFineX_.clear(); php.cellFineY_.clear(); } - HGCalParameters::wafer_map cellIndex; + HGCalParameters::wafer_map cellIndex; #ifdef EDM_ML_DEBUG std::vector indtypes; -#endif - int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_; - double R = php.waferSize_/(3*N); - double r = 0.5*R*sqrt(3.0); - int n2 = N/2; - int ipos(0); - for (int u=0; u<2*N; ++u) { - for (int v=0; v<2*N; ++v) { - if (((v-u) < N) && (u-v) <= N) { - double yp = (u-0.5*v-n2)*2*r; - double xp = (1.5*(v-N)+1.0)*R; - int id = v*100 + u; +#endif + int N = (type == 1) ? php.nCellsCoarse_ : php.nCellsFine_; + double R = php.waferSize_ / (3 * N); + double r = 0.5 * R * sqrt(3.0); + int n2 = N / 2; + int ipos(0); + for (int u = 0; u < 2 * N; ++u) { + for (int v = 0; v < 2 * N; ++v) { + if (((v - u) < N) && (u - v) <= N) { + double yp = (u - 0.5 * v - n2) * 2 * r; + double xp = (1.5 * (v - N) + 1.0) * R; + int id = v * 100 + u; #ifdef EDM_ML_DEBUG - indtypes.emplace_back(id); -#endif - if (type == 1) { - php.cellCoarseX_.emplace_back(xp); - php.cellCoarseY_.emplace_back(yp); - } else { - php.cellFineX_.emplace_back(xp); - php.cellFineY_.emplace_back(yp); - } - cellIndex[id] = ipos; - ++ipos; + indtypes.emplace_back(id); +#endif + if (type == 1) { + php.cellCoarseX_.emplace_back(xp); + php.cellCoarseY_.emplace_back(yp); + } else { + php.cellFineX_.emplace_back(xp); + php.cellFineY_.emplace_back(yp); + } + cellIndex[id] = ipos; + ++ipos; } } } - if (type == 1) php.cellCoarseIndex_ = cellIndex; - else php.cellFineIndex_ = cellIndex; + if (type == 1) + php.cellCoarseIndex_ = cellIndex; + else + php.cellFineIndex_ = cellIndex; #ifdef EDM_ML_DEBUG if (type == 1) { - edm::LogVerbatim("HGCalGeom") << "CellPosition for type " << type - << " for " << php.cellCoarseX_.size() - << " cells"; - for (unsigned int k=0; k & fvec = val.doubles(); + const std::vector& fvec = val.doubles(); if (fvec.empty()) { throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; } return fvec[0]; } else { - throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag"; + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag"; } } -std::vector HGCalParametersFromDD::getDDDArray(const char* s, - const DDsvalues_type& sv) { +std::vector HGCalParametersFromDD::getDDDArray( + const char* s, const DDsvalues_type& sv) { DDValue val(s); if (DDfetch(&sv, val)) { - const std::vector & fvec = val.doubles(); + const std::vector& fvec = val.doubles(); if (fvec.empty()) { throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag."; } return fvec; } else { - throw cms::Exception("HGCalGeom") << "Failed to get "<< s << " tag"; + throw cms::Exception("HGCalGeom") << "Failed to get " << s << " tag"; } } diff --git a/Geometry/HGCalCommonData/src/HGCalWaferIndex.cc b/Geometry/HGCalCommonData/src/HGCalWaferIndex.cc index 66e91d902b741..3b14c0c5c6589 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferIndex.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferIndex.cc @@ -1,57 +1,57 @@ #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" -const int kHGCalWaferUOffset = 0; -const int kHGCalWaferUMask = 0x1F; +const int kHGCalWaferUOffset = 0; +const int kHGCalWaferUMask = 0x1F; const int kHGCalWaferUSignOffset = 5; -const int kHGCalWaferUSignMask = 0x1; -const int kHGCalWaferVOffset = 6; -const int kHGCalWaferVMask = 0x1F; +const int kHGCalWaferUSignMask = 0x1; +const int kHGCalWaferVOffset = 6; +const int kHGCalWaferVMask = 0x1F; const int kHGCalWaferVSignOffset = 11; -const int kHGCalWaferVSignMask = 0x1; -const int kHGCalLayerOffset = 18; -const int kHGCalLayerMask = 0x1F; -const int kHGCalWaferCopyOffset = 0; -const int kHGCalWaferCopyMask = 0x7FFFF; -const int kHGCalLayerOldMask = 0x1000000; +const int kHGCalWaferVSignMask = 0x1; +const int kHGCalLayerOffset = 18; +const int kHGCalLayerMask = 0x1F; +const int kHGCalWaferCopyOffset = 0; +const int kHGCalWaferCopyMask = 0x7FFFF; +const int kHGCalLayerOldMask = 0x1000000; -int32_t HGCalWaferIndex::waferIndex(int32_t layer, int32_t waferU, - int32_t waferV, bool old) { +int32_t HGCalWaferIndex::waferIndex(int32_t layer, int32_t waferU, + int32_t waferV, bool old) { int32_t id(0); if (old) { - id |= (((waferU & kHGCalWaferCopyMask) << kHGCalWaferCopyOffset) | - ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | - kHGCalLayerOldMask); + id |= + (((waferU & kHGCalWaferCopyMask) << kHGCalWaferCopyOffset) | + ((layer & kHGCalLayerMask) << kHGCalLayerOffset) | kHGCalLayerOldMask); } else { int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); int waferUsign = (waferU >= 0) ? 0 : 1; int waferVsign = (waferV >= 0) ? 0 : 1; id |= (((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) | - ((waferUsign& kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) | - ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) | - ((waferVsign& kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) | - ((layer & kHGCalLayerMask) << kHGCalLayerOffset)); + ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) | + ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) | + ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) | + ((layer & kHGCalLayerMask) << kHGCalLayerOffset)); } return id; } int HGCalWaferIndex::waferLayer(const int32_t id) { - return (id>>kHGCalLayerOffset)&kHGCalLayerMask; + return (id >> kHGCalLayerOffset) & kHGCalLayerMask; } int HGCalWaferIndex::waferU(const int32_t id) { - int32_t iu = (id>>kHGCalWaferUOffset)&kHGCalWaferUMask; - return (((id>>kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -iu : iu); + int32_t iu = (id >> kHGCalWaferUOffset) & kHGCalWaferUMask; + return (((id >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -iu : iu); } int HGCalWaferIndex::waferV(const int32_t id) { - int32_t iv = (id>>kHGCalWaferVOffset)&kHGCalWaferVMask; - return (((id>>kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -iv : iv); + int32_t iv = (id >> kHGCalWaferVOffset) & kHGCalWaferVMask; + return (((id >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -iv : iv); } int HGCalWaferIndex::waferCopy(const int32_t id) { - return (id>>kHGCalWaferCopyOffset)&kHGCalWaferCopyMask; + return (id >> kHGCalWaferCopyOffset) & kHGCalWaferCopyMask; } bool HGCalWaferIndex::waferFormat(const int32_t id) { - return ((id&kHGCalLayerOldMask) == 0); + return ((id & kHGCalLayerOldMask) == 0); } diff --git a/Geometry/HGCalCommonData/src/HGCalWaferType.cc b/Geometry/HGCalCommonData/src/HGCalWaferType.cc index 20ab5be41b2df..bde086aaeb68d 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferType.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferType.cc @@ -1,135 +1,156 @@ #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" -#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" //#define EDM_ML_DEBUG -HGCalWaferType::HGCalWaferType(const std::vector& rad100, - const std::vector& rad200, - double waferSize, double zMin, - int choice, unsigned int cornerCut, - double cutArea) : rad100_(rad100), - rad200_(rad200), - waferSize_(waferSize), - zMin_(zMin), choice_(choice), - cutValue_(cornerCut), - cutFracArea_(cutArea) { - r_ = 0.5*waferSize_; - R_ = sqrt3_*waferSize_; +HGCalWaferType::HGCalWaferType(const std::vector& rad100, + const std::vector& rad200, + double waferSize, double zMin, int choice, + unsigned int cornerCut, double cutArea) + : rad100_(rad100), + rad200_(rad200), + waferSize_(waferSize), + zMin_(zMin), + choice_(choice), + cutValue_(cornerCut), + cutFracArea_(cutArea) { + r_ = 0.5 * waferSize_; + R_ = sqrt3_ * waferSize_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalWaferType: initialized with waferR's " - << waferSize_ << ":" << r_ << ":" << R_ - << " Choice " << choice_ << " Cuts " - << cutValue_ << ":" << cutFracArea_ << " zMin " - << zMin_ << " with " << rad100_.size() << ":" - << rad200_.size() << " parameters for R:"; - for (unsigned k=0; k xc(HGCalParameters::k_CornerSize,0); - std::vector yc(HGCalParameters::k_CornerSize,0); - xc[0] = xpos+r_; yc[0] = ypos+0.5*R_; - xc[1] = xpos; yc[1] = ypos+R_; - xc[2] = xpos-r_; yc[2] = ypos+0.5*R_; - xc[3] = xpos-r_; yc[3] = ypos-0.5*R_; - xc[4] = xpos; yc[4] = ypos-R_; - xc[5] = xpos+r_; yc[5] = ypos-0.5*R_; - std::pair rv = rLimits(zpos); - std::vector fine, coarse; - for (unsigned int k=0; k xc(HGCalParameters::k_CornerSize, 0); + std::vector yc(HGCalParameters::k_CornerSize, 0); + xc[0] = xpos + r_; + yc[0] = ypos + 0.5 * R_; + xc[1] = xpos; + yc[1] = ypos + R_; + xc[2] = xpos - r_; + yc[2] = ypos + 0.5 * R_; + xc[3] = xpos - r_; + yc[3] = ypos - 0.5 * R_; + xc[4] = xpos; + yc[4] = ypos - R_; + xc[5] = xpos + r_; + yc[5] = ypos - 0.5 * R_; + std::pair rv = rLimits(zpos); + std::vector fine, coarse; + for (unsigned int k = 0; k < HGCalParameters::k_CornerSize; ++k) { + double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]); + if (rpos <= rv.first) + fine.emplace_back(k); + else if (rpos <= rv.second) + coarse.emplace_back(k); } - int type(-2); + int type(-2); double fracArea(0); if (choice_ == 1) { - if (fine.size() >= cutValue_) type = 0; - else if (coarse.size() >= cutValue_) type = 1; - else type = 2; + if (fine.size() >= cutValue_) + type = 0; + else if (coarse.size() >= cutValue_) + type = 1; + else + type = 2; } else { - if (fine.size() >= 4) type = 0; - else if (coarse.size() >= 4 && fine.size() <= 1) type = 1; - else if (coarse.size() < 2 && fine.empty()) type = 2; - else if (!fine.empty()) type =-1; + if (fine.size() >= 4) + type = 0; + else if (coarse.size() >= 4 && fine.size() <= 1) + type = 1; + else if (coarse.size() < 2 && fine.empty()) + type = 2; + else if (!fine.empty()) + type = -1; if (type < 0) { unsigned int kmax = (type == -1) ? fine.size() : coarse.size(); std::vector xcn, ycn; - for (unsigned int k=0; k xy = intersection(k1, k2, xc, yc, xpos, - ypos, rr); - xcn.emplace_back(xy.first); ycn.emplace_back(xy.second); - } + for (unsigned int k = 0; k < kmax; ++k) { + unsigned int k1 = (type == -1) ? fine[k] : coarse[k]; + unsigned int k2 = (k1 == xc.size() - 1) ? 0 : k1 + 1; + bool ok = ((type == -1) + ? (std::find(fine.begin(), fine.end(), k2) != fine.end()) + : (std::find(coarse.begin(), coarse.end(), k2) != + coarse.end())); + xcn.emplace_back(xc[k1]); + ycn.emplace_back(yc[k1]); + if (!ok) { + double rr = (type == -1) ? rv.first : rv.second; + std::pair xy = + intersection(k1, k2, xc, yc, xpos, ypos, rr); + xcn.emplace_back(xy.first); + ycn.emplace_back(xy.second); + } } - fracArea = areaPolygon(xcn,ycn)/areaPolygon(xc,yc); - type = (fracArea > cutFracArea_) ? -(1+type) : -type; + fracArea = areaPolygon(xcn, ycn) / areaPolygon(xc, yc); + type = (fracArea > cutFracArea_) ? -(1 + type) : -type; } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "HGCalWaferType: position " << xpos << ":" - << ypos << ":" << zpos << " R " << ":" - << rv.first << ":" << rv.second - << " corners|type " << fine.size() << ":" - << coarse.size() << ":" << fracArea - << ":" << type ; + edm::LogVerbatim("HGCalGeom") + << "HGCalWaferType: position " << xpos << ":" << ypos << ":" << zpos + << " R " + << ":" << rv.first << ":" << rv.second << " corners|type " << fine.size() + << ":" << coarse.size() << ":" << fracArea << ":" << type; #endif return type; } -std::pair HGCalWaferType::rLimits(double zpos) { +std::pair HGCalWaferType::rLimits(double zpos) { double zz = std::abs(zpos); if (zz < zMin_) zz = zMin_; zz *= HGCalParameters::k_ScaleFromDDD; - double rfine = rad100_[0]; + double rfine = rad100_[0]; double rcoarse = rad200_[0]; - for (int i=1; i<5; ++i) { - rfine *= zz; rfine += rad100_[i]; - rcoarse *= zz; rcoarse += rad200_[i]; + for (int i = 1; i < 5; ++i) { + rfine *= zz; + rfine += rad100_[i]; + rcoarse *= zz; + rcoarse += rad200_[i]; } - return std::pair(rfine*HGCalParameters::k_ScaleToDDD,rcoarse*HGCalParameters::k_ScaleToDDD); + return std::pair(rfine * HGCalParameters::k_ScaleToDDD, + rcoarse * HGCalParameters::k_ScaleToDDD); } double HGCalWaferType::areaPolygon(std::vector const& x, - std::vector const& y) { + std::vector const& y) { double area = 0.0; int n = x.size(); - int j = n-1; - for (int i=0; i HGCalWaferType::intersection(int k1, int k2, - std::vector const& x, - std::vector const& y, - double xpos, double ypos, - double rr) { - double slope = (x[k1]-x[k2])/(y[k1]-y[k2]); - double interc = x[k1]-slope*y[k1]; +std::pair HGCalWaferType::intersection( + int k1, int k2, std::vector const& x, std::vector const& y, + double xpos, double ypos, double rr) { + double slope = (x[k1] - x[k2]) / (y[k1] - y[k2]); + double interc = x[k1] - slope * y[k1]; double xx[2], yy[2], dist[2]; - double v1 = std::sqrt((slope*slope+1)*rr*rr-(interc*interc)); - yy[0] = (-slope*interc+v1)/(1+slope*slope); - yy[1] = (-slope*interc-v1)/(1+slope*slope); - for (int i=0; i<2; ++i) { - xx[i] = (slope*yy[i] + interc); - dist[i] = ((xx[i]-xpos)*(xx[i]-xpos)) + ((yy[i]-ypos)*(yy[i]-ypos)); + double v1 = std::sqrt((slope * slope + 1) * rr * rr - (interc * interc)); + yy[0] = (-slope * interc + v1) / (1 + slope * slope); + yy[1] = (-slope * interc - v1) / (1 + slope * slope); + for (int i = 0; i < 2; ++i) { + xx[i] = (slope * yy[i] + interc); + dist[i] = + ((xx[i] - xpos) * (xx[i] - xpos)) + ((yy[i] - ypos) * (yy[i] - ypos)); } - if (dist[0] > dist[1]) return std::pair(xx[1],yy[1]); - else return std::pair(xx[0],yy[0]); + if (dist[0] > dist[1]) + return std::pair(xx[1], yy[1]); + else + return std::pair(xx[0], yy[0]); } diff --git a/Geometry/HGCalCommonData/test/FastTimeNumberingTester.cc b/Geometry/HGCalCommonData/test/FastTimeNumberingTester.cc index 0640acc9c519a..317d53803fffb 100644 --- a/Geometry/HGCalCommonData/test/FastTimeNumberingTester.cc +++ b/Geometry/HGCalCommonData/test/FastTimeNumberingTester.cc @@ -2,8 +2,9 @@ // // Package: FastTimeNumberingTester // Class: FastTimeNumberingTester -// -/**\class FastTimeNumberingTester FastTimeNumberingTester.cc test/FastTimeNumberingTester.cc +// +/**\class FastTimeNumberingTester FastTimeNumberingTester.cc + test/FastTimeNumberingTester.cc Description: @@ -20,31 +21,31 @@ //#define EDM_ML_DEBUG // system include files -#include -#include #include +#include +#include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/ForwardDetId/interface/FastTimeDetId.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDExpandedView.h" #include "DetectorDescription/Core/interface/DDSpecifics.h" -#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h" -#include "DataFormats/ForwardDetId/interface/FastTimeDetId.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" class FastTimeNumberingTester : public edm::one::EDAnalyzer<> { -public: - explicit FastTimeNumberingTester( const edm::ParameterSet& ); + public: + explicit FastTimeNumberingTester(const edm::ParameterSet&); ~FastTimeNumberingTester() override; void beginJob() override {} @@ -52,37 +53,38 @@ class FastTimeNumberingTester : public edm::one::EDAnalyzer<> { void endJob() override {} }; -FastTimeNumberingTester::FastTimeNumberingTester(const edm::ParameterSet& ) {} +FastTimeNumberingTester::FastTimeNumberingTester(const edm::ParameterSet&) {} FastTimeNumberingTester::~FastTimeNumberingTester() {} // ------------ method called to produce the data ------------ -void FastTimeNumberingTester::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - +void FastTimeNumberingTester::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::ESHandle pFTNDC; iSetup.get().get(pFTNDC); const FastTimeDDDConstants fTnDC(*pFTNDC); std::cout << "Fast timing device with " << fTnDC.getCells(1) << ":" - << fTnDC.getCells(2) << " cells" << " for barrel and endcap\n"; - for (int type=1; type<=2; ++type) { - for (int ix=0; ix<400; ++ix) { - for (int iy=0; iy<400; ++iy) { - if (fTnDC.isValidXY(type,ix,iy)) { - FastTimeDetId id1(type,ix,iy,1), id2(type,ix,iy,-1); - std::cout << "Valid ID " << id1 << " and " << id2 << std::endl; - } else { + << fTnDC.getCells(2) << " cells" + << " for barrel and endcap\n"; + for (int type = 1; type <= 2; ++type) { + for (int ix = 0; ix < 400; ++ix) { + for (int iy = 0; iy < 400; ++iy) { + if (fTnDC.isValidXY(type, ix, iy)) { + FastTimeDetId id1(type, ix, iy, 1), id2(type, ix, iy, -1); + std::cout << "Valid ID " << id1 << " and " << id2 << std::endl; + } else { #ifdef EDM_ML_DEBUG - std::cout << "ix = " << ix << ", iy = " << iy << " is not valid for " - << "FastTime type " << type << std::endl; + std::cout << "ix = " << ix << ", iy = " << iy << " is not valid for " + << "FastTime type " << type << std::endl; #endif - } - iy += 9; + } + iy += 9; } ix += 9; } } } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_MODULE(FastTimeNumberingTester); diff --git a/Geometry/HGCalCommonData/test/HGCGeometryTester.cc b/Geometry/HGCalCommonData/test/HGCGeometryTester.cc index 7e2d678658c39..2901fbcada278 100644 --- a/Geometry/HGCalCommonData/test/HGCGeometryTester.cc +++ b/Geometry/HGCalCommonData/test/HGCGeometryTester.cc @@ -2,7 +2,7 @@ // // Package: HGCGeometryTester // Class: HGCGeometryTester -// +// /**\class HGCGeometryTester HGCGeometryTester.cc test/HGCGeometryTester.cc Description: @@ -17,86 +17,83 @@ // // - // system include files -#include -#include #include +#include +#include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDExpandedView.h" -#include "DetectorDescription/Core/interface/DDSpecifics.h" #include "DetectorDescription/Core/interface/DDSolid.h" +#include "DetectorDescription/Core/interface/DDSpecifics.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" class HGCGeometryTester : public edm::one::EDAnalyzer<> { -public: - explicit HGCGeometryTester( const edm::ParameterSet& ); + public: + explicit HGCGeometryTester(const edm::ParameterSet&); ~HGCGeometryTester() override; void beginJob() override {} void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; void endJob() override {} -private: + + private: bool square; }; HGCGeometryTester::HGCGeometryTester(const edm::ParameterSet& iC) { - square = iC.getUntrackedParameter("SquareType",true); + square = iC.getUntrackedParameter("SquareType", true); } HGCGeometryTester::~HGCGeometryTester() {} // ------------ method called to produce the data ------------ -void HGCGeometryTester::analyze( const edm::Event& iEvent, - const edm::EventSetup& iSetup ) { - +void HGCGeometryTester::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::ESTransientHandle pDD; - iSetup.get().get( pDD ); - - //parse the DD for sensitive volumes + iSetup.get().get(pDD); + + // parse the DD for sensitive volumes DDExpandedView eview(*pDD); - std::map > svPars; + std::map > svPars; do { - const DDLogicalPart &logPart=eview.logicalPart(); - const std::string & name=logPart.name().fullname(); + const DDLogicalPart& logPart = eview.logicalPart(); + const std::string& name = logPart.name().fullname(); - //only EE sensitive volumes for the moment + // only EE sensitive volumes for the moment if ((name.find("HGCal") != std::string::npos) && - (name.find("Sensitive") != std::string::npos)) { - - size_t pos=name.find("Sensitive")+9; - int layer=atoi(name.substr(pos,name.size()-1).c_str()); + (name.find("Sensitive") != std::string::npos)) { + size_t pos = name.find("Sensitive") + 9; + int layer = atoi(name.substr(pos, name.size() - 1).c_str()); if (svPars.find(name) == svPars.end()) { - //print half height and widths for the trapezoid - std::vector solidPar=eview.logicalPart().solid().parameters(); - if (square) { - svPars[name] = std::pair(solidPar[3], - 0.5*(solidPar[4]+solidPar[5])); - std::cout << name << " Layer " << layer << " " << solidPar[3] - << " " << solidPar[4] << " " << solidPar[5] << std::endl; - } else { - svPars[name] = std::pair(solidPar[0], - 0.5*(solidPar[2]-solidPar[1])); - std::cout << name << " Layer " << layer << " " << solidPar[0] - << " " << solidPar[1] << " " << solidPar[2] << std::endl; - } + // print half height and widths for the trapezoid + std::vector solidPar = eview.logicalPart().solid().parameters(); + if (square) { + svPars[name] = std::pair( + solidPar[3], 0.5 * (solidPar[4] + solidPar[5])); + std::cout << name << " Layer " << layer << " " << solidPar[3] << " " + << solidPar[4] << " " << solidPar[5] << std::endl; + } else { + svPars[name] = std::pair( + solidPar[0], 0.5 * (solidPar[2] - solidPar[1])); + std::cout << name << " Layer " << layer << " " << solidPar[0] << " " + << solidPar[1] << " " << solidPar[2] << std::endl; + } } } - }while(eview.next() ); + } while (eview.next()); } - -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_MODULE(HGCGeometryTester); diff --git a/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc b/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc index 9ede0ea439a29..e4a5a690b9a53 100644 --- a/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalNumberingTester.cc @@ -2,8 +2,9 @@ // // Package: HGCalNumberingTester // Class: HGCalNumberingTester -// -/**\class HGCalNumberingTester HGCalNumberingTester.cc test/HGCalNumberingTester.cc +// +/**\class HGCalNumberingTester HGCalNumberingTester.cc + test/HGCalNumberingTester.cc Description: @@ -16,11 +17,10 @@ // // - // system include files -#include -#include #include +#include +#include #include #include @@ -28,177 +28,191 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDExpandedView.h" #include "DetectorDescription/Core/interface/DDSpecifics.h" -#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" class HGCalNumberingTester : public edm::one::EDAnalyzer<> { -public: - explicit HGCalNumberingTester( const edm::ParameterSet& ); + public: + explicit HGCalNumberingTester(const edm::ParameterSet&); ~HGCalNumberingTester() override; void beginJob() override {} void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; void endJob() override {} -private: - std::string nameSense_, nameDetector_; + + private: + std::string nameSense_, nameDetector_; std::vector positionX_, positionY_; - int increment_, detType_; - bool reco_; + int increment_, detType_; + bool reco_; }; HGCalNumberingTester::HGCalNumberingTester(const edm::ParameterSet& iC) { - nameSense_ = iC.getParameter("NameSense"); + nameSense_ = iC.getParameter("NameSense"); nameDetector_ = iC.getParameter("NameDevice"); - positionX_ = iC.getParameter >("LocalPositionX"); - positionY_ = iC.getParameter >("LocalPositionY"); - increment_ = iC.getParameter("Increment"); - detType_ = iC.getParameter("DetType"); - reco_ = iC.getParameter("Reco"); + positionX_ = iC.getParameter >("LocalPositionX"); + positionY_ = iC.getParameter >("LocalPositionY"); + increment_ = iC.getParameter("Increment"); + detType_ = iC.getParameter("DetType"); + reco_ = iC.getParameter("Reco"); std::string unit("mm"); if (reco_) { - for (unsigned int k=0; k pHGNDC; - iSetup.get().get(nameSense_,pHGNDC); + iSetup.get().get(nameSense_, pHGNDC); const HGCalDDDConstants hgdc(*pHGNDC); - std::cout << nameDetector_ << " Layers = " << hgdc.layers(reco_) - << " Sectors = " << hgdc.sectors() << " Minimum Slope = " - << hgdc.minSlope() << std::endl; + std::cout << nameDetector_ << " Layers = " << hgdc.layers(reco_) + << " Sectors = " << hgdc.sectors() + << " Minimum Slope = " << hgdc.minSlope() << std::endl; if (detType_ != 0) { std::cout << "Minimum Wafer # " << hgdc.waferMin() << " Mamximum Wafer # " - << hgdc.waferMax() << " Wafer counts " << hgdc.waferCount(0) - << ":" << hgdc.waferCount(1) << std::endl; - for (unsigned int i=0; i xy; - std::string flg; - int subsec(0); - int loff = hgdc.firstLayer(); + std::pair xy; + std::string flg; + int subsec(0); + int loff = hgdc.firstLayer(); double scl = (reco_ ? 10.0 : 1.0); - for (unsigned int k=0; k kxy, lxy; - kxy = hgdc.assignCell(localx,localy,i+loff,subsec,reco_); - xy = hgdc.locateCell(kxy.second,i+loff,kxy.first,reco_); - lxy = hgdc.assignCell(xy.first,xy.second,i+loff,0,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - std::cout << "Input: (" << localx << "," << localy << "," << i+loff - << ", " << subsec << "), assignCell o/p (" << kxy.first - << ", " << kxy.second << ") locateCell o/p (" << xy.first - << ", " << xy.second << ")," << " final (" << lxy.first - << ", " << lxy.second << ")" << flg << std::endl; - kxy = hgdc.assignCell(-localx,-localy,i+loff,subsec,reco_); - xy = hgdc.locateCell(kxy.second,i+loff,kxy.first,reco_); - lxy = hgdc.assignCell(xy.first,xy.second,i+loff,0,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - std::cout << "Input: (" <<-localx << "," <<-localy << "," << i+loff - << ", " << subsec << "), assignCell o/p (" << kxy.first - << ", " << kxy.second << ") locateCell o/p (" << xy.first - << ", " << xy.second << ")," << " final (" << lxy.first - << ", " << lxy.second << ")" << flg << std::endl; + std::pair kxy, lxy; + kxy = hgdc.assignCell(localx, localy, i + loff, subsec, reco_); + xy = hgdc.locateCell(kxy.second, i + loff, kxy.first, reco_); + lxy = hgdc.assignCell(xy.first, xy.second, i + loff, 0, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + std::cout << "Input: (" << localx << "," << localy << "," << i + loff + << ", " << subsec << "), assignCell o/p (" << kxy.first + << ", " << kxy.second << ") locateCell o/p (" << xy.first + << ", " << xy.second << ")," + << " final (" << lxy.first << ", " << lxy.second << ")" << flg + << std::endl; + kxy = hgdc.assignCell(-localx, -localy, i + loff, subsec, reco_); + xy = hgdc.locateCell(kxy.second, i + loff, kxy.first, reco_); + lxy = hgdc.assignCell(xy.first, xy.second, i + loff, 0, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + std::cout << "Input: (" << -localx << "," << -localy << "," << i + loff + << ", " << subsec << "), assignCell o/p (" << kxy.first + << ", " << kxy.second << ") locateCell o/p (" << xy.first + << ", " << xy.second << ")," + << " final (" << lxy.first << ", " << lxy.second << ")" << flg + << std::endl; } else if (detType_ == 0) { - std::array kxy, lxy; - double zpos = hgdc.waferZ(i+loff,reco_); - kxy = hgdc.assignCellTrap(localx,localy,zpos,i+loff,reco_); - xy = hgdc.locateCellTrap(i+loff,kxy[0],kxy[1],reco_); - lxy = hgdc.assignCellTrap(xy.first,xy.second,zpos,i+loff,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - std::cout << "Input: (" << localx << "," << localy << "," << zpos - << ", " << i+loff << "), assignCell o/p (" << kxy[0] << ":" - << kxy[1] << ":" << kxy[2] << ") locateCell o/p (" - << xy.first << ", " << xy.second << ")," << " final (" - << lxy[0] << ":" << lxy[1] << ":" << lxy[2] << ") Dist " - << hgdc.distFromEdgeTrap(scl*localx,scl*localy,scl*zpos) - << " " << flg << std::endl; - kxy = hgdc.assignCellTrap(-localx,-localy,zpos,i+loff,reco_); - xy = hgdc.locateCellTrap(i+loff,kxy[0],kxy[1],reco_); - lxy = hgdc.assignCellTrap(xy.first,xy.second,zpos,i+loff,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - std::cout << "Input: (" <<-localx << "," <<-localy << "," << zpos - << ", " << i+loff << "), assignCell o/p (" << kxy[0] << ":" - << kxy[1] << ":" << kxy[2] << ") locateCell o/p (" - << xy.first << ", " << xy.second << ")," << " final (" - << lxy[0] << ":" << lxy[1] << ":" << lxy[2] << ") Dist " - << hgdc.distFromEdgeTrap(scl*localx,scl*localy,scl*zpos) - << " " << flg << std::endl; + std::array kxy, lxy; + double zpos = hgdc.waferZ(i + loff, reco_); + kxy = hgdc.assignCellTrap(localx, localy, zpos, i + loff, reco_); + xy = hgdc.locateCellTrap(i + loff, kxy[0], kxy[1], reco_); + lxy = hgdc.assignCellTrap(xy.first, xy.second, zpos, i + loff, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + std::cout << "Input: (" << localx << "," << localy << "," << zpos + << ", " << i + loff << "), assignCell o/p (" << kxy[0] << ":" + << kxy[1] << ":" << kxy[2] << ") locateCell o/p (" << xy.first + << ", " << xy.second << ")," + << " final (" << lxy[0] << ":" << lxy[1] << ":" << lxy[2] + << ") Dist " + << hgdc.distFromEdgeTrap(scl * localx, scl * localy, + scl * zpos) + << " " << flg << std::endl; + kxy = hgdc.assignCellTrap(-localx, -localy, zpos, i + loff, reco_); + xy = hgdc.locateCellTrap(i + loff, kxy[0], kxy[1], reco_); + lxy = hgdc.assignCellTrap(xy.first, xy.second, zpos, i + loff, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + std::cout << "Input: (" << -localx << "," << -localy << "," << zpos + << ", " << i + loff << "), assignCell o/p (" << kxy[0] << ":" + << kxy[1] << ":" << kxy[2] << ") locateCell o/p (" << xy.first + << ", " << xy.second << ")," + << " final (" << lxy[0] << ":" << lxy[1] << ":" << lxy[2] + << ") Dist " + << hgdc.distFromEdgeTrap(scl * localx, scl * localy, + scl * zpos) + << " " << flg << std::endl; } else { - std::array kxy, lxy; - kxy = hgdc.assignCellHex(localx,localy,i+loff,reco_); - xy = hgdc.locateCell(i+loff,kxy[0],kxy[1],kxy[3],kxy[4],reco_,true); - lxy = hgdc.assignCellHex(xy.first,xy.second,i+loff,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - double zpos = hgdc.waferZ(i+loff,reco_); - std::cout << "Input: (" << localx << "," << localy << ", " << i+loff - << "), assignCell o/p (" << kxy[0] << ":" << kxy[1] - << ":" << kxy[2] << ":" << kxy[3] << ":" << kxy[4] - << ") locateCell o/p (" << xy.first << ", " << xy.second - << ")," << " final (" << lxy[0] << ":" << lxy[1] << ":" - << lxy[2] << ":" << lxy[3] << ":" << lxy[4] << ") Dist " - << hgdc.distFromEdgeHex(scl*localx,scl*localy,scl*zpos) - << " " << flg << std::endl; - kxy = hgdc.assignCellHex(-localx,-localy,i+loff,reco_); - xy = hgdc.locateCell(i+loff,kxy[0],kxy[1],kxy[3],kxy[4],reco_,true); - lxy = hgdc.assignCellHex(xy.first,xy.second,i+loff,reco_); - flg = (kxy == lxy) ? " " : " ***** Error *****"; - std::cout << "Input: (" <<-localx << "," <<-localy << ", " << i+loff - << "), assignCell o/p (" << kxy[0] << ":" << kxy[1] - << ":" << kxy[2] << ":" << kxy[3] << ":" << kxy[4] - << ") locateCell o/p (" << xy.first << ", " << xy.second - << ")," << " final (" << lxy[0] << ":" << lxy[1] << ":" - << lxy[2] << ":" << lxy[3] << ":" << lxy[4] << ") Dist " - << hgdc.distFromEdgeHex(scl*localx,scl*localy,scl*zpos) - << " " << flg << std::endl; + std::array kxy, lxy; + kxy = hgdc.assignCellHex(localx, localy, i + loff, reco_); + xy = hgdc.locateCell(i + loff, kxy[0], kxy[1], kxy[3], kxy[4], reco_, + true); + lxy = hgdc.assignCellHex(xy.first, xy.second, i + loff, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + double zpos = hgdc.waferZ(i + loff, reco_); + std::cout << "Input: (" << localx << "," << localy << ", " << i + loff + << "), assignCell o/p (" << kxy[0] << ":" << kxy[1] << ":" + << kxy[2] << ":" << kxy[3] << ":" << kxy[4] + << ") locateCell o/p (" << xy.first << ", " << xy.second + << ")," + << " final (" << lxy[0] << ":" << lxy[1] << ":" << lxy[2] + << ":" << lxy[3] << ":" << lxy[4] << ") Dist " + << hgdc.distFromEdgeHex(scl * localx, scl * localy, + scl * zpos) + << " " << flg << std::endl; + kxy = hgdc.assignCellHex(-localx, -localy, i + loff, reco_); + xy = hgdc.locateCell(i + loff, kxy[0], kxy[1], kxy[3], kxy[4], reco_, + true); + lxy = hgdc.assignCellHex(xy.first, xy.second, i + loff, reco_); + flg = (kxy == lxy) ? " " : " ***** Error *****"; + std::cout << "Input: (" << -localx << "," << -localy << ", " << i + loff + << "), assignCell o/p (" << kxy[0] << ":" << kxy[1] << ":" + << kxy[2] << ":" << kxy[3] << ":" << kxy[4] + << ") locateCell o/p (" << xy.first << ", " << xy.second + << ")," + << " final (" << lxy[0] << ":" << lxy[1] << ":" << lxy[2] + << ":" << lxy[3] << ":" << lxy[4] << ") Dist " + << hgdc.distFromEdgeHex(scl * localx, scl * localy, + scl * zpos) + << " " << flg << std::endl; } - if (k == 0 && i==0 && detType_ == 1) { - std::vector ncells = hgdc.numberCells(i+1,reco_); - std::cout << "Layer " << i+1 << " with " << ncells.size() << " rows" - << std::endl; - int ntot(0); - for (unsigned int k=0; k ncells = hgdc.numberCells(i + 1, reco_); + std::cout << "Layer " << i + 1 << " with " << ncells.size() << " rows" + << std::endl; + int ntot(0); + for (unsigned int k = 0; k < ncells.size(); ++k) { + ntot += ncells[k]; + std::cout << "Row " << k << " with " << ncells[k] << " cells\n"; + } + std::cout << "Total Cells " << ntot << ":" + << hgdc.maxCells(i + 1, reco_) << std::endl; } i += increment_; } @@ -208,26 +222,25 @@ void HGCalNumberingTester::analyze( const edm::Event& iEvent, const edm::EventSe if (hgdc.getParameter()->detectorType_ > 0) { unsigned int kk(0); for (auto const& zz : hgdc.getParameter()->zLayerHex_) { - std::pair rr = hgdc.rangeR(zz, true); + std::pair rr = hgdc.rangeR(zz, true); std::cout << "[" << kk << "]\t z = " << zz << "\t rMin = " << rr.first - << "\t rMax = " << rr.second << std::endl; + << "\t rMax = " << rr.second << std::endl; ++kk; } } - //For scintillators + // For scintillators if (hgdc.geomMode() == HGCalGeometryMode::Trapezoid) { unsigned int kk(0); for (auto const& lay : hgdc.getParameter()->layer_) { auto rRange = hgdc.getREtaRange(lay); std::cout << "[" << kk << "] Layer " << lay << " R/Eta " << rRange.first - << ":" << rRange.second << " nPhi " << hgdc.getPhiBins(lay) - << std::endl; + << ":" << rRange.second << " nPhi " << hgdc.getPhiBins(lay) + << std::endl; ++kk; } } } - -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_MODULE(HGCalNumberingTester); diff --git a/Geometry/HGCalCommonData/test/HGCalParameterTester.cc b/Geometry/HGCalCommonData/test/HGCalParameterTester.cc index 0dd3213bff521..fd1b72b3aeb1b 100644 --- a/Geometry/HGCalCommonData/test/HGCalParameterTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalParameterTester.cc @@ -1,259 +1,256 @@ #include #include -#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" class HGCalParameterTester : public edm::one::EDAnalyzer<> { - -public: - explicit HGCalParameterTester( const edm::ParameterSet& ); + public: + explicit HGCalParameterTester(const edm::ParameterSet&); ~HGCalParameterTester() override {} - + void beginJob() override {} void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; void endJob() override {} -private: - template void myPrint(std::string const& s, - std::vector const& obj, int n) const; + + private: + template + void myPrint(std::string const& s, std::vector const& obj, int n) const; void myPrint(std::string const& s, std::vector const& obj1, - std::vector const& obj2, int n) const; + std::vector const& obj2, int n) const; void myPrint(std::string const& s, HGCalParameters::wafer_map const& obj, - int n) const; + int n) const; void printTrform(edm::ESHandle const&) const; void printWaferType(edm::ESHandle const& phgp) const; const std::string name_; - const int mode_; + const int mode_; }; -HGCalParameterTester::HGCalParameterTester(const edm::ParameterSet& ic) : - name_(ic.getUntrackedParameter("Name")), - mode_(ic.getUntrackedParameter("Mode")) { } - -void HGCalParameterTester::analyze(const edm::Event& iEvent, - const edm::EventSetup& iSetup) { +HGCalParameterTester::HGCalParameterTester(const edm::ParameterSet& ic) + : name_(ic.getUntrackedParameter("Name")), + mode_(ic.getUntrackedParameter("Mode")) {} +void HGCalParameterTester::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::LogVerbatim("HGCalGeomr") << "HGCalParameter::Here I am"; auto start = std::chrono::high_resolution_clock::now(); - + edm::ESHandle phgp; iSetup.get().get(name_, phgp); std::cout << phgp->name_ << "\n"; if (mode_ == 0) { - std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; - std::cout << "WaferR_: " << phgp->waferR_ << "\n"; - std::cout << "nCells_: " << phgp->nCells_ << "\n"; - std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; - std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; + std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; + std::cout << "WaferR_: " << phgp->waferR_ << "\n"; + std::cout << "nCells_: " << phgp->nCells_ << "\n"; + std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; + std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; std::cout << "FirstMixedLayer: " << phgp->firstMixedLayer_ << "\n"; - std::cout << "mode_: " << phgp->mode_ << "\n"; + std::cout << "mode_: " << phgp->mode_ << "\n"; - myPrint("CellSize", phgp->cellSize_, 10); - myPrint("slopeMin", phgp->slopeMin_, 10); - myPrint("slopeTop", phgp->slopeTop_, 10); - myPrint("zFrontTop", phgp->zFrontTop_, 10); - myPrint("rMaxFront", phgp->rMaxFront_, 10); - myPrint("zRanges", phgp->zRanges_, 10); - myPrint("moduleBlS", phgp->moduleBlS_, 10); - myPrint("moduleTlS", phgp->moduleTlS_, 10); - myPrint("moduleHS", phgp->moduleHS_, 10); - myPrint("moduleDzS", phgp->moduleDzS_, 10); - myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); - myPrint("moduleCellS", phgp->moduleCellS_, 10); - myPrint("moduleBlR", phgp->moduleBlR_, 10); - myPrint("moduleTlR", phgp->moduleTlR_, 10); - myPrint("moduleHR", phgp->moduleHR_, 10); - myPrint("moduleDzR", phgp->moduleDzR_, 10); - myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); - myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); - myPrint("trformTranY", phgp->trformTranY_, 10); - myPrint("trformTranZ", phgp->trformTranZ_, 10); - myPrint("trformRotXX", phgp->trformRotXX_, 10); - myPrint("trformRotYX", phgp->trformRotYX_, 10); - myPrint("trformRotZX", phgp->trformRotZX_, 10); - myPrint("trformRotXY", phgp->trformRotXY_, 10); - myPrint("trformRotYY", phgp->trformRotYY_, 10); - myPrint("trformRotZY", phgp->trformRotZY_, 10); - myPrint("trformRotXZ", phgp->trformRotXZ_, 10); - myPrint("trformRotYZ", phgp->trformRotYZ_, 10); - myPrint("trformRotZZ", phgp->trformRotZZ_, 10); - myPrint("zLayerHex", phgp->zLayerHex_, 10); - myPrint("rMinLayHex", phgp->rMinLayHex_, 10); - myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); - myPrint("waferPos", phgp->waferPosX_, phgp->waferPosY_,4); - myPrint("cellFine", phgp->cellFineX_, phgp->cellFineY_,4); - myPrint("cellFineHalf", phgp->cellFineHalf_, 10); - myPrint("cellCoarse", phgp->cellCoarseX_, phgp->cellCoarseY_,4); - myPrint("cellCoarseHalf", phgp->cellCoarseHalf_, 10); - myPrint("boundR", phgp->boundR_, 10); - myPrint("moduleLayS", phgp->moduleLayS_, 10); - myPrint("moduleLayR", phgp->moduleLayR_, 10); - myPrint("layer", phgp->layer_, 18); - myPrint("layerIndex", phgp->layerIndex_, 18); - myPrint("layerGroup", phgp->layerGroup_, 18); - myPrint("cellFactor", phgp->cellFactor_, 10); - myPrint("depth", phgp->depth_, 18); - myPrint("depthIndex", phgp->depthIndex_, 18); - myPrint("depthLayerF", phgp->depthLayerF_, 18); - myPrint("waferCopy", phgp->waferCopy_, 8); - myPrint("waferTypeL", phgp->waferTypeL_, 20); - myPrint("waferTypeT", phgp->waferTypeT_, 20); - myPrint("layerGroupM", phgp->layerGroupM_, 18); - myPrint("layerGroupO", phgp->layerGroupO_, 18); + myPrint("CellSize", phgp->cellSize_, 10); + myPrint("slopeMin", phgp->slopeMin_, 10); + myPrint("slopeTop", phgp->slopeTop_, 10); + myPrint("zFrontTop", phgp->zFrontTop_, 10); + myPrint("rMaxFront", phgp->rMaxFront_, 10); + myPrint("zRanges", phgp->zRanges_, 10); + myPrint("moduleBlS", phgp->moduleBlS_, 10); + myPrint("moduleTlS", phgp->moduleTlS_, 10); + myPrint("moduleHS", phgp->moduleHS_, 10); + myPrint("moduleDzS", phgp->moduleDzS_, 10); + myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); + myPrint("moduleCellS", phgp->moduleCellS_, 10); + myPrint("moduleBlR", phgp->moduleBlR_, 10); + myPrint("moduleTlR", phgp->moduleTlR_, 10); + myPrint("moduleHR", phgp->moduleHR_, 10); + myPrint("moduleDzR", phgp->moduleDzR_, 10); + myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); + myPrint("moduleCellR", phgp->moduleCellR_, 10); + myPrint("trformTranX", phgp->trformTranY_, 10); + myPrint("trformTranY", phgp->trformTranY_, 10); + myPrint("trformTranZ", phgp->trformTranZ_, 10); + myPrint("trformRotXX", phgp->trformRotXX_, 10); + myPrint("trformRotYX", phgp->trformRotYX_, 10); + myPrint("trformRotZX", phgp->trformRotZX_, 10); + myPrint("trformRotXY", phgp->trformRotXY_, 10); + myPrint("trformRotYY", phgp->trformRotYY_, 10); + myPrint("trformRotZY", phgp->trformRotZY_, 10); + myPrint("trformRotXZ", phgp->trformRotXZ_, 10); + myPrint("trformRotYZ", phgp->trformRotYZ_, 10); + myPrint("trformRotZZ", phgp->trformRotZZ_, 10); + myPrint("zLayerHex", phgp->zLayerHex_, 10); + myPrint("rMinLayHex", phgp->rMinLayHex_, 10); + myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); + myPrint("waferPos", phgp->waferPosX_, phgp->waferPosY_, 4); + myPrint("cellFine", phgp->cellFineX_, phgp->cellFineY_, 4); + myPrint("cellFineHalf", phgp->cellFineHalf_, 10); + myPrint("cellCoarse", phgp->cellCoarseX_, phgp->cellCoarseY_, 4); + myPrint("cellCoarseHalf", phgp->cellCoarseHalf_, 10); + myPrint("boundR", phgp->boundR_, 10); + myPrint("moduleLayS", phgp->moduleLayS_, 10); + myPrint("moduleLayR", phgp->moduleLayR_, 10); + myPrint("layer", phgp->layer_, 18); + myPrint("layerIndex", phgp->layerIndex_, 18); + myPrint("layerGroup", phgp->layerGroup_, 18); + myPrint("cellFactor", phgp->cellFactor_, 10); + myPrint("depth", phgp->depth_, 18); + myPrint("depthIndex", phgp->depthIndex_, 18); + myPrint("depthLayerF", phgp->depthLayerF_, 18); + myPrint("waferCopy", phgp->waferCopy_, 8); + myPrint("waferTypeL", phgp->waferTypeL_, 20); + myPrint("waferTypeT", phgp->waferTypeT_, 20); + myPrint("layerGroupM", phgp->layerGroupM_, 18); + myPrint("layerGroupO", phgp->layerGroupO_, 18); printTrform(phgp); - myPrint("levelTop", phgp->levelT_, 10); + myPrint("levelTop", phgp->levelT_, 10); printWaferType(phgp); } else if (mode_ == 1) { - - std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; + std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; std::cout << "Wafer Parameters: " << phgp->waferSize_ << ":" - << phgp->waferR_ << ":" << phgp->waferThick_ << ":" - << phgp->sensorSeparation_ << ":" << phgp->mouseBite_ << "\n"; - std::cout << "nCells_: " << phgp->nCellsFine_ << ":" - << phgp->nCellsCoarse_ << "\n"; - std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; - std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; + << phgp->waferR_ << ":" << phgp->waferThick_ << ":" + << phgp->sensorSeparation_ << ":" << phgp->mouseBite_ << "\n"; + std::cout << "nCells_: " << phgp->nCellsFine_ << ":" << phgp->nCellsCoarse_ + << "\n"; + std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; + std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; std::cout << "FirstMixedLayer: " << phgp->firstMixedLayer_ << "\n"; - std::cout << "mode_: " << phgp->mode_ << "\n"; - std::cout << "waferUVMax: " << phgp->waferUVMax_ << "\n"; + std::cout << "mode_: " << phgp->mode_ << "\n"; + std::cout << "waferUVMax: " << phgp->waferUVMax_ << "\n"; - myPrint("waferUVMaxLayer", phgp->waferUVMaxLayer_, 20); - myPrint("CellThickness", phgp->cellThickness_, 10); - myPrint("radius100to200", phgp->radius100to200_, 10); - myPrint("radius200to300", phgp->radius200to300_, 10); - std::cout << "choiceType " << phgp->choiceType_ << " nCornerCut " - << phgp->nCornerCut_ << " fracAreaMin " << phgp->fracAreaMin_ - << " zMinForRad " << phgp->zMinForRad_ << "\n"; - - myPrint("CellSize", phgp->cellSize_, 10); - myPrint("radiusMixBoundary", phgp->radiusMixBoundary_, 10); - myPrint("slopeMin", phgp->slopeMin_, 10); - myPrint("zFrontMin", phgp->zFrontMin_, 10); - myPrint("rMinFront", phgp->rMinFront_, 10); - myPrint("slopeTop", phgp->slopeTop_, 10); - myPrint("zFrontTop", phgp->zFrontTop_, 10); - myPrint("rMaxFront", phgp->rMaxFront_, 10); - myPrint("zRanges", phgp->zRanges_, 10); - myPrint("moduleBlS", phgp->moduleBlS_, 10); - myPrint("moduleTlS", phgp->moduleTlS_, 10); - myPrint("moduleHS", phgp->moduleHS_, 10); - myPrint("moduleDzS", phgp->moduleDzS_, 10); - myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); - myPrint("moduleCellS", phgp->moduleCellS_, 10); - myPrint("moduleBlR", phgp->moduleBlR_, 10); - myPrint("moduleTlR", phgp->moduleTlR_, 10); - myPrint("moduleHR", phgp->moduleHR_, 10); - myPrint("moduleDzR", phgp->moduleDzR_, 10); - myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); - myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); - myPrint("trformTranY", phgp->trformTranY_, 10); - myPrint("trformTranZ", phgp->trformTranZ_, 10); - myPrint("trformRotXX", phgp->trformRotXX_, 10); - myPrint("trformRotYX", phgp->trformRotYX_, 10); - myPrint("trformRotZX", phgp->trformRotZX_, 10); - myPrint("trformRotXY", phgp->trformRotXY_, 10); - myPrint("trformRotYY", phgp->trformRotYY_, 10); - myPrint("trformRotZY", phgp->trformRotZY_, 10); - myPrint("trformRotXZ", phgp->trformRotXZ_, 10); - myPrint("trformRotYZ", phgp->trformRotYZ_, 10); - myPrint("trformRotZZ", phgp->trformRotZZ_, 10); - myPrint("zLayerHex", phgp->zLayerHex_, 10); - myPrint("rMinLayHex", phgp->rMinLayHex_, 10); - myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); - myPrint("waferPos", phgp->waferPosX_, phgp->waferPosY_,4); - myPrint("cellFineIndex", phgp->cellFineIndex_, 10); - myPrint("cellFine", phgp->cellFineX_, phgp->cellFineY_,4); - myPrint("cellCoarseIndex", phgp->cellCoarseIndex_, 10); - myPrint("cellCoarse" , phgp->cellCoarseX_, phgp->cellCoarseY_,4); - myPrint("layer", phgp->layer_, 18); - myPrint("layerIndex", phgp->layerIndex_, 18); - myPrint("depth", phgp->depth_, 18); - myPrint("depthIndex", phgp->depthIndex_, 18); - myPrint("depthLayerF", phgp->depthLayerF_, 18); - myPrint("waferCopy", phgp->waferCopy_, 8); - myPrint("waferTypeL", phgp->waferTypeL_, 20); + myPrint("waferUVMaxLayer", phgp->waferUVMaxLayer_, 20); + myPrint("CellThickness", phgp->cellThickness_, 10); + myPrint("radius100to200", phgp->radius100to200_, 10); + myPrint("radius200to300", phgp->radius200to300_, 10); + std::cout << "choiceType " << phgp->choiceType_ << " nCornerCut " + << phgp->nCornerCut_ << " fracAreaMin " << phgp->fracAreaMin_ + << " zMinForRad " << phgp->zMinForRad_ << "\n"; + + myPrint("CellSize", phgp->cellSize_, 10); + myPrint("radiusMixBoundary", phgp->radiusMixBoundary_, 10); + myPrint("slopeMin", phgp->slopeMin_, 10); + myPrint("zFrontMin", phgp->zFrontMin_, 10); + myPrint("rMinFront", phgp->rMinFront_, 10); + myPrint("slopeTop", phgp->slopeTop_, 10); + myPrint("zFrontTop", phgp->zFrontTop_, 10); + myPrint("rMaxFront", phgp->rMaxFront_, 10); + myPrint("zRanges", phgp->zRanges_, 10); + myPrint("moduleBlS", phgp->moduleBlS_, 10); + myPrint("moduleTlS", phgp->moduleTlS_, 10); + myPrint("moduleHS", phgp->moduleHS_, 10); + myPrint("moduleDzS", phgp->moduleDzS_, 10); + myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); + myPrint("moduleCellS", phgp->moduleCellS_, 10); + myPrint("moduleBlR", phgp->moduleBlR_, 10); + myPrint("moduleTlR", phgp->moduleTlR_, 10); + myPrint("moduleHR", phgp->moduleHR_, 10); + myPrint("moduleDzR", phgp->moduleDzR_, 10); + myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); + myPrint("moduleCellR", phgp->moduleCellR_, 10); + myPrint("trformTranX", phgp->trformTranY_, 10); + myPrint("trformTranY", phgp->trformTranY_, 10); + myPrint("trformTranZ", phgp->trformTranZ_, 10); + myPrint("trformRotXX", phgp->trformRotXX_, 10); + myPrint("trformRotYX", phgp->trformRotYX_, 10); + myPrint("trformRotZX", phgp->trformRotZX_, 10); + myPrint("trformRotXY", phgp->trformRotXY_, 10); + myPrint("trformRotYY", phgp->trformRotYY_, 10); + myPrint("trformRotZY", phgp->trformRotZY_, 10); + myPrint("trformRotXZ", phgp->trformRotXZ_, 10); + myPrint("trformRotYZ", phgp->trformRotYZ_, 10); + myPrint("trformRotZZ", phgp->trformRotZZ_, 10); + myPrint("zLayerHex", phgp->zLayerHex_, 10); + myPrint("rMinLayHex", phgp->rMinLayHex_, 10); + myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); + myPrint("waferPos", phgp->waferPosX_, phgp->waferPosY_, 4); + myPrint("cellFineIndex", phgp->cellFineIndex_, 10); + myPrint("cellFine", phgp->cellFineX_, phgp->cellFineY_, 4); + myPrint("cellCoarseIndex", phgp->cellCoarseIndex_, 10); + myPrint("cellCoarse", phgp->cellCoarseX_, phgp->cellCoarseY_, 4); + myPrint("layer", phgp->layer_, 18); + myPrint("layerIndex", phgp->layerIndex_, 18); + myPrint("depth", phgp->depth_, 18); + myPrint("depthIndex", phgp->depthIndex_, 18); + myPrint("depthLayerF", phgp->depthLayerF_, 18); + myPrint("waferCopy", phgp->waferCopy_, 8); + myPrint("waferTypeL", phgp->waferTypeL_, 20); printTrform(phgp); - myPrint("levelTop", phgp->levelT_, 10); + myPrint("levelTop", phgp->levelT_, 10); printWaferType(phgp); } else { - - std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; - std::cout << "nCells_: " << phgp->nCellsFine_ << ":" - << phgp->nCellsCoarse_ << "\n"; - std::cout << "MinTileZize: " << phgp->minTileSize_ << "\n"; - std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; + std::cout << "DetectorType: " << phgp->detectorType_ << "\n"; + std::cout << "nCells_: " << phgp->nCellsFine_ << ":" << phgp->nCellsCoarse_ + << "\n"; + std::cout << "MinTileZize: " << phgp->minTileSize_ << "\n"; + std::cout << "FirstLayer: " << phgp->firstLayer_ << "\n"; std::cout << "FirstMixedLayer: " << phgp->firstMixedLayer_ << "\n"; - std::cout << "mode_: " << phgp->mode_ << "\n"; - std::cout << "waferUVMax: " << phgp->waferUVMax_ << "\n"; - std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; - std::cout << "nCells_: " << phgp->nCellsFine_ << ":" - << phgp->nCellsCoarse_ << "\n"; - - myPrint("CellSize", phgp->cellSize_, 10); - myPrint("radiusMixBoundary", phgp->radiusMixBoundary_, 10); - myPrint("nPhiBinBH", phgp->nPhiBinBH_, 18); - myPrint("layerFrontBH", phgp->layerFrontBH_, 10); - myPrint("rMinLayerBH", phgp->rMinLayerBH_, 10); - myPrint("slopeMin", phgp->slopeMin_, 10); - myPrint("zFrontMin", phgp->zFrontMin_, 10); - myPrint("rMinFront", phgp->rMinFront_, 10); - myPrint("radiusLayer[0]", phgp->radiusLayer_[0], 10); - myPrint("radiusLayer[1]", phgp->radiusLayer_[1], 10); - myPrint("iradMinBH", phgp->iradMinBH_, 20); - myPrint("iradMaxBH", phgp->iradMaxBH_, 20); - myPrint("slopeTop", phgp->slopeTop_, 10); - myPrint("zFrontTop", phgp->zFrontTop_, 10); - myPrint("rMaxFront", phgp->rMaxFront_, 10); - myPrint("zRanges", phgp->zRanges_, 10); - myPrint("firstModule", phgp->firstModule_, 10); - myPrint("lastModule", phgp->lastModule_, 10); - myPrint("moduleBlS", phgp->moduleBlS_, 10); - myPrint("moduleTlS", phgp->moduleTlS_, 10); - myPrint("moduleHS", phgp->moduleHS_, 10); - myPrint("moduleDzS", phgp->moduleDzS_, 10); - myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); - myPrint("moduleCellS", phgp->moduleCellS_, 10); - myPrint("moduleBlR", phgp->moduleBlR_, 10); - myPrint("moduleTlR", phgp->moduleTlR_, 10); - myPrint("moduleHR", phgp->moduleHR_, 10); - myPrint("moduleDzR", phgp->moduleDzR_, 10); - myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); - myPrint("moduleCellR", phgp->moduleCellR_, 10); - myPrint("trformTranX", phgp->trformTranY_, 10); - myPrint("trformTranY", phgp->trformTranY_, 10); - myPrint("trformTranZ", phgp->trformTranZ_, 10); - myPrint("trformRotXX", phgp->trformRotXX_, 10); - myPrint("trformRotYX", phgp->trformRotYX_, 10); - myPrint("trformRotZX", phgp->trformRotZX_, 10); - myPrint("trformRotXY", phgp->trformRotXY_, 10); - myPrint("trformRotYY", phgp->trformRotYY_, 10); - myPrint("trformRotZY", phgp->trformRotZY_, 10); - myPrint("trformRotXZ", phgp->trformRotXZ_, 10); - myPrint("trformRotYZ", phgp->trformRotYZ_, 10); - myPrint("trformRotZZ", phgp->trformRotZZ_, 10); - myPrint("zLayerHex", phgp->zLayerHex_, 10); - myPrint("rMinLayHex", phgp->rMinLayHex_, 10); - myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); - myPrint("layer", phgp->layer_, 18); - myPrint("layerIndex", phgp->layerIndex_, 18); - myPrint("depth", phgp->depth_, 18); - myPrint("depthIndex", phgp->depthIndex_, 18); - myPrint("depthLayerF", phgp->depthLayerF_, 18); + std::cout << "mode_: " << phgp->mode_ << "\n"; + std::cout << "waferUVMax: " << phgp->waferUVMax_ << "\n"; + std::cout << "nSectors_: " << phgp->nSectors_ << "\n"; + std::cout << "nCells_: " << phgp->nCellsFine_ << ":" << phgp->nCellsCoarse_ + << "\n"; + + myPrint("CellSize", phgp->cellSize_, 10); + myPrint("radiusMixBoundary", phgp->radiusMixBoundary_, 10); + myPrint("nPhiBinBH", phgp->nPhiBinBH_, 18); + myPrint("layerFrontBH", phgp->layerFrontBH_, 10); + myPrint("rMinLayerBH", phgp->rMinLayerBH_, 10); + myPrint("slopeMin", phgp->slopeMin_, 10); + myPrint("zFrontMin", phgp->zFrontMin_, 10); + myPrint("rMinFront", phgp->rMinFront_, 10); + myPrint("radiusLayer[0]", phgp->radiusLayer_[0], 10); + myPrint("radiusLayer[1]", phgp->radiusLayer_[1], 10); + myPrint("iradMinBH", phgp->iradMinBH_, 20); + myPrint("iradMaxBH", phgp->iradMaxBH_, 20); + myPrint("slopeTop", phgp->slopeTop_, 10); + myPrint("zFrontTop", phgp->zFrontTop_, 10); + myPrint("rMaxFront", phgp->rMaxFront_, 10); + myPrint("zRanges", phgp->zRanges_, 10); + myPrint("firstModule", phgp->firstModule_, 10); + myPrint("lastModule", phgp->lastModule_, 10); + myPrint("moduleBlS", phgp->moduleBlS_, 10); + myPrint("moduleTlS", phgp->moduleTlS_, 10); + myPrint("moduleHS", phgp->moduleHS_, 10); + myPrint("moduleDzS", phgp->moduleDzS_, 10); + myPrint("moduleAlphaS", phgp->moduleAlphaS_, 10); + myPrint("moduleCellS", phgp->moduleCellS_, 10); + myPrint("moduleBlR", phgp->moduleBlR_, 10); + myPrint("moduleTlR", phgp->moduleTlR_, 10); + myPrint("moduleHR", phgp->moduleHR_, 10); + myPrint("moduleDzR", phgp->moduleDzR_, 10); + myPrint("moduleAlphaR", phgp->moduleAlphaR_, 10); + myPrint("moduleCellR", phgp->moduleCellR_, 10); + myPrint("trformTranX", phgp->trformTranY_, 10); + myPrint("trformTranY", phgp->trformTranY_, 10); + myPrint("trformTranZ", phgp->trformTranZ_, 10); + myPrint("trformRotXX", phgp->trformRotXX_, 10); + myPrint("trformRotYX", phgp->trformRotYX_, 10); + myPrint("trformRotZX", phgp->trformRotZX_, 10); + myPrint("trformRotXY", phgp->trformRotXY_, 10); + myPrint("trformRotYY", phgp->trformRotYY_, 10); + myPrint("trformRotZY", phgp->trformRotZY_, 10); + myPrint("trformRotXZ", phgp->trformRotXZ_, 10); + myPrint("trformRotYZ", phgp->trformRotYZ_, 10); + myPrint("trformRotZZ", phgp->trformRotZZ_, 10); + myPrint("zLayerHex", phgp->zLayerHex_, 10); + myPrint("rMinLayHex", phgp->rMinLayHex_, 10); + myPrint("rMaxLayHex", phgp->rMaxLayHex_, 10); + myPrint("layer", phgp->layer_, 18); + myPrint("layerIndex", phgp->layerIndex_, 18); + myPrint("depth", phgp->depth_, 18); + myPrint("depthIndex", phgp->depthIndex_, 18); + myPrint("depthLayerF", phgp->depthLayerF_, 18); printTrform(phgp); - myPrint("levelTop", phgp->levelT_, 10); + myPrint("levelTop", phgp->levelT_, 10); printWaferType(phgp); } @@ -262,82 +259,101 @@ void HGCalParameterTester::analyze(const edm::Event& iEvent, std::cout << "Elapsed time: " << elapsed.count() << " s\n"; } -template -void HGCalParameterTester::myPrint(std::string const& s, - std::vector const& obj, int n) const { +template +void HGCalParameterTester::myPrint(std::string const& s, + std::vector const& obj, int n) const { int k(0); std::cout << s << " with " << obj.size() << " elements\n"; for (auto const& it : obj) { - std::cout << it << ", "; ++k; - if (k == n) { std::cout << "\n"; k = 0;} + std::cout << it << ", "; + ++k; + if (k == n) { + std::cout << "\n"; + k = 0; + } } if (k > 0) std::cout << "\n"; } -void HGCalParameterTester::myPrint(std::string const& s, - std::vector const& obj1, - std::vector const& obj2, - int n) const { +void HGCalParameterTester::myPrint(std::string const& s, + std::vector const& obj1, + std::vector const& obj2, + int n) const { int k(0); std::cout << s << " with " << obj1.size() << " elements\n"; - for (unsigned int k1=0; k1 0) std::cout << "\n"; } -void HGCalParameterTester::myPrint(std::string const& s, - HGCalParameters::wafer_map const& obj, - int n) const { +void HGCalParameterTester::myPrint(std::string const& s, + HGCalParameters::wafer_map const& obj, + int n) const { int k(0); std::cout << s << " with " << obj.size() << " elements\n"; for (auto const& it : obj) { - std::cout << it.first << ":" << it.second << ", "; ++k; - if (k == n) { std::cout << "\n"; k = 0;} + std::cout << it.first << ":" << it.second << ", "; + ++k; + if (k == n) { + std::cout << "\n"; + k = 0; + } } if (k > 0) std::cout << "\n"; } -void HGCalParameterTester::printTrform(edm::ESHandle const& phgp) const { +void HGCalParameterTester::printTrform( + edm::ESHandle const& phgp) const { int k(0); - std::cout << "TrformIndex with " << phgp->trformIndex_.size() << " elements\n"; - for (unsigned int i=0; itrformIndex_.size(); ++i) { - std::array id = phgp->getID(i); + std::cout << "TrformIndex with " << phgp->trformIndex_.size() + << " elements\n"; + for (unsigned int i = 0; i < phgp->trformIndex_.size(); ++i) { + std::array id = phgp->getID(i); std::cout << id[0] << ":" << id[1] << ":" << id[2] << ":" << id[3] << ", "; - ++k; - if (k == 10) { std::cout << "\n"; k = 0;} + ++k; + if (k == 10) { + std::cout << "\n"; + k = 0; + } } if (k > 0) std::cout << "\n"; } -void HGCalParameterTester::printWaferType(edm::ESHandle const& phgp) const { +void HGCalParameterTester::printWaferType( + edm::ESHandle const& phgp) const { int k(0); std::cout << "waferTypes with " << phgp->waferTypes_.size() << " elements\n"; - std::map,int> kounts; - std::map,int>::iterator itr; + std::map, int> kounts; + std::map, int>::iterator itr; for (auto const& it : phgp->waferTypes_) { std::cout << " [" << k << "] " << HGCalWaferIndex::waferLayer(it.first); - if (HGCalWaferIndex::waferFormat(it.first)) { + if (HGCalWaferIndex::waferFormat(it.first)) { std::cout << ":" << HGCalWaferIndex::waferU(it.first) << ":" - << HGCalWaferIndex::waferV(it.first); + << HGCalWaferIndex::waferV(it.first); } else { std::cout << ":" << HGCalWaferIndex::waferCopy(it.first); } std::cout << " ==> (" << (it.second).first << ":" << (it.second).second - << ")" << std::endl; + << ")" << std::endl; itr = kounts.find(it.second); - if (itr == kounts.end()) kounts[it.second] = 1; - else ++(itr->second); + if (itr == kounts.end()) + kounts[it.second] = 1; + else + ++(itr->second); ++k; } if (!kounts.empty()) { std::cout << "Summary of waferTypes ==========================\n"; for (itr = kounts.begin(); itr != kounts.end(); ++itr) std::cout << "Type (" << (itr->first).first << ":" << (itr->first).second - << ") Kount " << itr->second << std::endl; + << ") Kount " << itr->second << std::endl; } } - DEFINE_FWK_MODULE(HGCalParameterTester); diff --git a/Geometry/HGCalCommonData/test/HGCalParametersAnalyzer.cc b/Geometry/HGCalCommonData/test/HGCalParametersAnalyzer.cc index 53aa4e404c794..8e667cfbbbea3 100644 --- a/Geometry/HGCalCommonData/test/HGCalParametersAnalyzer.cc +++ b/Geometry/HGCalCommonData/test/HGCalParametersAnalyzer.cc @@ -1,233 +1,186 @@ #include -#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "Geometry/Records/interface/PHGCalParametersRcd.h" #include "CondFormats/GeometryObjects/interface/PHGCalParameters.h" +#include "Geometry/Records/interface/PHGCalParametersRcd.h" -class HGCalParametersAnalyzer : public edm::one::EDAnalyzer<> -{ -public: - explicit HGCalParametersAnalyzer( const edm::ParameterSet& ) {} +class HGCalParametersAnalyzer : public edm::one::EDAnalyzer<> { + public: + explicit HGCalParametersAnalyzer(const edm::ParameterSet&) {} ~HGCalParametersAnalyzer() override {} - + void beginJob() override {} void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; void endJob() override {} }; -void -HGCalParametersAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) -{ +void HGCalParametersAnalyzer::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::LogInfo("HGCalParametersAnalyzer") << "Here I am"; - + edm::ESHandle phgp; - iSetup.get().get( phgp ); + iSetup.get().get(phgp); std::cout << phgp->name_ << "\n"; - for (auto it : phgp->cellSize_) - std::cout << it << ", "; + for (auto it : phgp->cellSize_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleBlS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleBlS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleTlS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleTlS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleHS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleHS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleDzS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleDzS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleAlphaS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleAlphaS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleCellS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleCellS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleBlR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleBlR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleTlR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleTlR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleHR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleHR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleDzR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleDzR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleAlphaR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleAlphaR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleCellR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleCellR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformTranX_) - std::cout << it << ", "; + + for (auto it : phgp->trformTranX_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformTranY_) - std::cout << it << ", "; + + for (auto it : phgp->trformTranY_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformTranZ_) - std::cout << it << ", "; + + for (auto it : phgp->trformTranZ_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotXX_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotXX_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotYX_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotYX_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotZX_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotZX_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotXY_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotXY_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotYY_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotYY_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotZY_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotZY_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotXZ_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotXZ_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotYZ_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotYZ_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformRotZZ_) - std::cout << it << ", "; + + for (auto it : phgp->trformRotZZ_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->zLayerHex_) - std::cout << it << ", "; + + for (auto it : phgp->zLayerHex_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->rMinLayHex_) - std::cout << it << ", "; + + for (auto it : phgp->rMinLayHex_) std::cout << it << ", "; + std::cout << "\n"; + + for (auto it : phgp->rMaxLayHex_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->rMaxLayHex_) - std::cout << it << ", "; + + for (unsigned int k = 0; k < phgp->waferPosX_.size(); ++k) + std::cout << "(" << phgp->waferPosX_[k] << ", " << phgp->waferPosY_[k] + << ") "; std::cout << "\n"; - - for (unsigned int k=0; kwaferPosX_.size(); ++k) - std::cout << "(" << phgp->waferPosX_[k] << ", " << phgp->waferPosY_[k] - << ") "; - std::cout << "\n"; - - for (unsigned int k=0; kcellFineX_.size(); ++k) - std::cout << "(" << phgp->cellFineX_[k] << ", " << phgp->cellFineY_[k] - << ") "; + + for (unsigned int k = 0; k < phgp->cellFineX_.size(); ++k) + std::cout << "(" << phgp->cellFineX_[k] << ", " << phgp->cellFineY_[k] + << ") "; std::cout << "\n"; - - for (unsigned int k=0; kcellCoarseX_.size(); ++k) + + for (unsigned int k = 0; k < phgp->cellCoarseX_.size(); ++k) std::cout << "(" << phgp->cellCoarseX_[k] << ", " << phgp->cellCoarseY_[k] - << ") "; + << ") "; std::cout << "\n"; - - for (auto it : phgp->boundR_) - std::cout << it << ", "; + + for (auto it : phgp->boundR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleLayS_) - std::cout << it << ", "; + + for (auto it : phgp->moduleLayS_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->moduleLayR_) - std::cout << it << ", "; + + for (auto it : phgp->moduleLayR_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->layer_) - std::cout << it << ", "; + + for (auto it : phgp->layer_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->layerIndex_) - std::cout << it << ", "; + + for (auto it : phgp->layerIndex_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->layerGroup_) - std::cout << it << ", "; + + for (auto it : phgp->layerGroup_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->cellFactor_) - std::cout << it << ", "; + + for (auto it : phgp->cellFactor_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->depth_) - std::cout << it << ", "; + + for (auto it : phgp->depth_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->depthIndex_) - std::cout << it << ", "; + + for (auto it : phgp->depthIndex_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->depthLayerF_) - std::cout << it << ", "; + + for (auto it : phgp->depthLayerF_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->waferCopy_) - std::cout << it << ", "; + + for (auto it : phgp->waferCopy_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->waferTypeL_) - std::cout << it << ", "; + + for (auto it : phgp->waferTypeL_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->waferTypeT_) - std::cout << it << ", "; + + for (auto it : phgp->waferTypeT_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->layerGroupM_) - std::cout << it << ", "; + + for (auto it : phgp->layerGroupM_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->layerGroupO_) - std::cout << it << ", "; + + for (auto it : phgp->layerGroupO_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->trformIndex_) - std::cout << it << ", "; + + for (auto it : phgp->trformIndex_) std::cout << it << ", "; std::cout << "\n"; - - for (auto it : phgp->slopeMin_) - std::cout << it << ", "; + + for (auto it : phgp->slopeMin_) std::cout << it << ", "; std::cout << "\n"; - - std::cout << phgp->waferR_ << "\n"; - std::cout << phgp->nCells_ << "\n"; + + std::cout << phgp->waferR_ << "\n"; + std::cout << phgp->nCells_ << "\n"; std::cout << phgp->nSectors_ << "\n"; - std::cout << phgp->mode_ << "\n"; + std::cout << phgp->mode_ << "\n"; } DEFINE_FWK_MODULE(HGCalParametersAnalyzer); diff --git a/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py b/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py index 75fe75edc67f3..8e669f81a079c 100644 --- a/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py +++ b/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py @@ -14,6 +14,7 @@ level = cms.untracked.int32(14) )) -process.dump = cms.EDAnalyzer("DumpSimGeometry") +process.dump = cms.EDAnalyzer("DumpSimGeometry", + outputFileName = cms.untracked.string('TBGeom.root')) process.p = cms.Path(process.dump) diff --git a/SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h b/SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h index e98e78cefb9b3..62648c4ded217 100644 --- a/SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h +++ b/SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h @@ -3,15 +3,15 @@ #include #include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" - +#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" /** \class AHCalDetId - * Cell identifier class for the HCAL subdetectors, precision readout cells only + * Cell identifier class for the HCAL subdetectors, precision readout cells + * only */ class AHCalDetId : public DetId { -public: + public: /** Create a null cellid*/ AHCalDetId(); /** Create cellid from raw id (0=invalid tower id) */ @@ -22,8 +22,8 @@ class AHCalDetId : public DetId { AHCalDetId(const DetId& id); /** Assignment from a generic cell id */ AHCalDetId& operator=(const DetId& id) { - id_=id.rawId(); - return *this; + id_ = id.rawId(); + return *this; } /// get the subdetector @@ -32,25 +32,26 @@ class AHCalDetId : public DetId { int zside() const { return 1; } /// get the row number int irow() const; - int irowAbs() const { - return ((id_>>HcalDetId::kHcalEtaOffset2)&HcalDetId::kHcalEtaMask2); } + int irowAbs() const { + return ((id_ >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2); + } /// get the column number int icol() const; - int icolAbs() const { return (id_&HcalDetId::kHcalPhiMask2); } + int icolAbs() const { return (id_ & HcalDetId::kHcalPhiMask2); } /// get the layer number - static const int MaxDepth=12; + static const int MaxDepth = 12; int depth() const; /// get the local coordinate in the plane and along depth - std::pair getXY() const; + std::pair getXY() const; double getZ() const; static const AHCalDetId Undefined; - const double deltaX_ = 3.0; // Size of tile along X - const double deltaY_ = 3.0; // Size of tile along Y - const double deltaZ_ = 8.1; // Thickness of a single layer - const double zFirst_ = 1.76; // Position of the center + const double deltaX_ = 3.0; // Size of tile along X + const double deltaY_ = 3.0; // Size of tile along Y + const double deltaZ_ = 8.1; // Thickness of a single layer + const double zFirst_ = 1.76; // Position of the center }; -std::ostream& operator<<(std::ostream&,const AHCalDetId& id); +std::ostream& operator<<(std::ostream&, const AHCalDetId& id); #endif diff --git a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc index be9a434143a4e..7d5e5e1c1caec 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc @@ -5,15 +5,15 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" -#include "G4LogicalVolumeStore.hh" #include "G4LogicalVolume.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4ParticleTable.hh" #include "G4Step.hh" #include "G4Track.hh" -#include "G4ParticleTable.hh" #include "G4VProcess.hh" -#include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" #include #include @@ -22,121 +22,113 @@ //#define EDM_ML_DEBUG class AHCalSD : public CaloSD { - -public: - - AHCalSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); + public: + AHCalSD(const std::string&, const DDCompactView&, + const SensitiveDetectorCatalog&, edm::ParameterSet const&, + const SimTrackManager*); ~AHCalSD() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - bool unpackIndex(const uint32_t & idx, int & row, - int& col, int& depth); -protected: - - double getEnergyDeposit(const G4Step*) override; - bool filterHit(CaloG4Hit*, double) override; + uint32_t setDetUnitId(const G4Step* step) override; + bool unpackIndex(const uint32_t& idx, int& row, int& col, int& depth); -private: + protected: + double getEnergyDeposit(const G4Step*) override; + bool filterHit(CaloG4Hit*, double) override; - bool useBirk; - double birk1, birk2, birk3, betaThr; - double eminHit; + private: + bool useBirk; + double birk1, birk2, birk3, betaThr; + double eminHit; }; -AHCalSD::AHCalSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager) : - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("AHCalSD").getParameter("TimeSliceUnit")), - p.getParameter("AHCalSD").getParameter("IgnoreTrackID")) { - +AHCalSD::AHCalSD(const std::string& name, const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, const SimTrackManager* manager) + : CaloSD(name, cpv, clg, p, manager, + (float)(p.getParameter("AHCalSD") + .getParameter("TimeSliceUnit")), + p.getParameter("AHCalSD").getParameter( + "IgnoreTrackID")) { edm::ParameterSet m_HC = p.getParameter("AHCalSD"); - useBirk = m_HC.getParameter("UseBirkLaw"); - birk1 = m_HC.getParameter("BirkC1")*(CLHEP::g/(CLHEP::MeV*CLHEP::cm2)); - birk2 = m_HC.getParameter("BirkC2"); - birk3 = m_HC.getParameter("BirkC3"); - eminHit = m_HC.getParameter("EminHit")*CLHEP::MeV; - - edm::LogVerbatim("HcalSim") << "AHCalSD:: Use of Birks law is set to " - << useBirk << " with three constants kB = " - << birk1 << ", C1 = " << birk2 << ", C2 = " - << birk3 << "\nAHCalSD:: Threshold for storing" - << " hits: " << eminHit; + useBirk = m_HC.getParameter("UseBirkLaw"); + birk1 = m_HC.getParameter("BirkC1") * + (CLHEP::g / (CLHEP::MeV * CLHEP::cm2)); + birk2 = m_HC.getParameter("BirkC2"); + birk3 = m_HC.getParameter("BirkC3"); + eminHit = m_HC.getParameter("EminHit") * CLHEP::MeV; + + edm::LogVerbatim("HcalSim") + << "AHCalSD:: Use of Birks law is set to " << useBirk + << " with three constants kB = " << birk1 << ", C1 = " << birk2 + << ", C2 = " << birk3 << "\nAHCalSD:: Threshold for storing" + << " hits: " << eminHit; } double AHCalSD::getEnergyDeposit(const G4Step* aStep) { - double destep = aStep->GetTotalEnergyDeposit(); - double wt2 = aStep->GetTrack()->GetWeight(); + double wt2 = aStep->GetTrack()->GetWeight(); double weight = (wt2 > 0.0) ? wt2 : 1.0; #ifdef EDM_ML_DEBUG double weight0 = weight; #endif if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " - << weight; + edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " << weight; #endif - double edep = weight*destep; + double edep = weight * destep; return edep; } -uint32_t AHCalSD::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t AHCalSD::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); int depth = (touch->GetReplicaNumber(1)); - int incol = ((touch->GetReplicaNumber(0))%10); - int inrow = ((touch->GetReplicaNumber(0))/10)%10; - int jncol = ((touch->GetReplicaNumber(0))/100)%10; - int jnrow = ((touch->GetReplicaNumber(0))/1000)%10; - int col = (jncol == 0) ? incol : -incol; - int row = (jnrow == 0) ? inrow : -inrow; - uint32_t index = AHCalDetId(row,col,depth).rawId(); + int incol = ((touch->GetReplicaNumber(0)) % 10); + int inrow = ((touch->GetReplicaNumber(0)) / 10) % 10; + int jncol = ((touch->GetReplicaNumber(0)) / 100) % 10; + int jnrow = ((touch->GetReplicaNumber(0)) / 1000) % 10; + int col = (jncol == 0) ? incol : -incol; + int row = (jnrow == 0) ? inrow : -inrow; + uint32_t index = AHCalDetId(row, col, depth).rawId(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "AHCalSD: det = " << HcalOther - << " depth = " << depth << " row = " << row - << " column = " << col << " packed index = 0x" - << std::hex << index << std::dec; + edm::LogVerbatim("HcalSim") + << "AHCalSD: det = " << HcalOther << " depth = " << depth + << " row = " << row << " column = " << col << " packed index = 0x" + << std::hex << index << std::dec; bool flag = unpackIndex(index, row, col, depth); - edm::LogVerbatim("HcalSim") << "Results from unpacker for 0x" << std::hex - << index << std::dec << " Flag " << flag - << " Row " << row << " Col " << col << " Depth " - << depth; + edm::LogVerbatim("HcalSim") + << "Results from unpacker for 0x" << std::hex << index << std::dec + << " Flag " << flag << " Row " << row << " Col " << col << " Depth " + << depth; #endif return index; } bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) { - DetId gen(idx); HcalSubdetector subdet = (HcalSubdetector(gen.subdetId())); - bool rcode = (gen.det()==DetId::Hcal && subdet!=HcalOther); + bool rcode = (gen.det() == DetId::Hcal && subdet != HcalOther); row = col = depth = 0; if (rcode) { - row = AHCalDetId(idx).irow(); - col = AHCalDetId(idx).icol(); + row = AHCalDetId(idx).irow(); + col = AHCalDetId(idx).icol(); depth = AHCalDetId(idx).depth(); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "AHCalSD: packed index = 0x" << std::hex - << idx << std::dec << " Row " << row - << " Column " << col << " Depth " << depth - << " OK " << rcode; + edm::LogVerbatim("HcalSim") + << "AHCalSD: packed index = 0x" << std::hex << idx << std::dec << " Row " + << row << " Column " << col << " Depth " << depth << " OK " << rcode; #endif return rcode; } - + bool AHCalSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit)); } -#include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" typedef AHCalSD AHcalSensitiveDetector; DEFINE_SENSITIVEDETECTOR(AHcalSensitiveDetector); - diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc index 7f4f038d559c0..29116456c06ec 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc @@ -1,75 +1,73 @@ /////////////////////////////////////////////////////////////////////////////// // File: HGCPassive.cc -//copied from SimG4HGCalValidation +// copied from SimG4HGCalValidation // Description: Main analysis class for HGCal Validation of G4 Hits /////////////////////////////////////////////////////////////////////////////// #include "HGCPassive.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "G4TransportationManager.hh" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "G4TransportationManager.hh" #include -#include #include +#include #include -#include +#include //#define EDM_ML_DEBUG -HGCPassive::HGCPassive(const edm::ParameterSet &p) : topPV_(nullptr), topLV_(nullptr), - count_(0), init_(false) { - +HGCPassive::HGCPassive(const edm::ParameterSet& p) + : topPV_(nullptr), topLV_(nullptr), count_(0), init_(false) { edm::ParameterSet m_Passive = p.getParameter("HGCPassive"); - LVNames_ = m_Passive.getParameter >("LVNames"); - motherName_= m_Passive.getParameter("MotherName"); + LVNames_ = m_Passive.getParameter >("LVNames"); + motherName_ = m_Passive.getParameter("MotherName"); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ValidHGCal") << "Name of the mother volume " <(Form("%sPassiveHits",name.c_str())); + produces(Form("%sPassiveHits", name.c_str())); #ifdef EDM_ML_DEBUG edm::LogVerbatim("ValidHGCal") << "Collection name[" << k << "] " << name; ++k; #endif } -} - -HGCPassive::~HGCPassive() { } +} + +HGCPassive::~HGCPassive() {} void HGCPassive::produce(edm::Event& e, const edm::EventSetup&) { - - for (unsigned int k=0; k hgcPH(new edm::PassiveHitContainer); + for (unsigned int k = 0; k < LVNames_.size(); ++k) { + std::unique_ptr hgcPH( + new edm::PassiveHitContainer); endOfEvent(*hgcPH, k); - e.put(std::move(hgcPH),Form("%sPassiveHits",LVNames_[k].c_str())); + e.put(std::move(hgcPH), Form("%sPassiveHits", LVNames_[k].c_str())); } } -void HGCPassive::update(const BeginOfRun * run) { - +void HGCPassive::update(const BeginOfRun* run) { topPV_ = getTopPV(); if (topPV_ == nullptr) { edm::LogWarning("HGCPassive") << "Cannot find top level volume\n"; } else { init_ = true; - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); for (auto lvcite : *lvs) { findLV(lvcite); - } + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ValidHGCal") << "HGCPassive::Finds " << mapLV_.size() - << " logical volumes"; + edm::LogVerbatim("ValidHGCal") + << "HGCPassive::Finds " << mapLV_.size() << " logical volumes"; unsigned int k(0); for (const auto& lvs : mapLV_) { - edm::LogVerbatim("ValidHGCal") << "Entry[" << k << "] " << lvs.first - << ": (" << (lvs.second).first << ", " - << (lvs.second).second << ")"; + edm::LogVerbatim("ValidHGCal") + << "Entry[" << k << "] " << lvs.first << ": (" << (lvs.second).first + << ", " << (lvs.second).second << ")"; ++k; } #endif @@ -77,90 +75,90 @@ void HGCPassive::update(const BeginOfRun * run) { } //=================================================================== per EVENT -void HGCPassive::update(const BeginOfEvent * evt) { - +void HGCPassive::update(const BeginOfEvent* evt) { int iev = (*evt)()->GetEventID(); - edm::LogVerbatim("ValidHGCal") << "HGCPassive: =====> Begin event = " - << iev << std::endl; - + edm::LogVerbatim("ValidHGCal") + << "HGCPassive: =====> Begin event = " << iev << std::endl; + ++count_; store_.clear(); } -// //=================================================================== each STEP -void HGCPassive::update(const G4Step * aStep) { - +// //=================================================================== each +// STEP +void HGCPassive::update(const G4Step* aStep) { if (aStep != nullptr) { - - G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector(); + G4VSensitiveDetector* curSD = + aStep->GetPreStepPoint()->GetSensitiveDetector(); const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable(); - if (curSD==nullptr) { + if (curSD == nullptr) { G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume(); auto it = (init_) ? mapLV_.find(plv) : findLV(plv); - double time = aStep->GetTrack()->GetGlobalTime(); - double energy = (aStep->GetTotalEnergyDeposit())/CLHEP::GeV; + double time = aStep->GetTrack()->GetGlobalTime(); + double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV; unsigned int copy(0); - if (((aStep->GetPostStepPoint() == nullptr) || - (aStep->GetTrack()->GetNextVolume() == nullptr)) && - (aStep->IsLastStepInVolume())) { + if (((aStep->GetPostStepPoint() == nullptr) || + (aStep->GetTrack()->GetNextVolume() == nullptr)) && + (aStep->IsLastStepInVolume())) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ValidHGCal") << plv->GetName() << " F|L Step " - << aStep->IsFirstStepInVolume() << ":" - << aStep->IsLastStepInVolume() - << " Position" << aStep->GetPreStepPoint()->GetPosition() - << " Track " << aStep->GetTrack()->GetDefinition()->GetParticleName() - << " at" << aStep->GetTrack()->GetPosition() - << " Volume " << aStep->GetTrack()->GetVolume() - << ":" << aStep->GetTrack()->GetNextVolume() - << " Status " << aStep->GetTrack()->GetTrackStatus() - << " KE " << aStep->GetTrack()->GetKineticEnergy() - << " Deposit " << aStep->GetTotalEnergyDeposit() - << " Map " << (it != mapLV_.end()); + edm::LogVerbatim("ValidHGCal") + << plv->GetName() << " F|L Step " << aStep->IsFirstStepInVolume() + << ":" << aStep->IsLastStepInVolume() << " Position" + << aStep->GetPreStepPoint()->GetPosition() << " Track " + << aStep->GetTrack()->GetDefinition()->GetParticleName() << " at" + << aStep->GetTrack()->GetPosition() << " Volume " + << aStep->GetTrack()->GetVolume() << ":" + << aStep->GetTrack()->GetNextVolume() << " Status " + << aStep->GetTrack()->GetTrackStatus() << " KE " + << aStep->GetTrack()->GetKineticEnergy() << " Deposit " + << aStep->GetTotalEnergyDeposit() << " Map " + << (it != mapLV_.end()); #endif - energy += (aStep->GetPreStepPoint()->GetKineticEnergy()/CLHEP::GeV); + energy += (aStep->GetPreStepPoint()->GetKineticEnergy() / CLHEP::GeV); } else { - time = (aStep->GetPostStepPoint()->GetGlobalTime()); - copy = (unsigned int)(touchable->GetReplicaNumber(0) + - 1000*touchable->GetReplicaNumber(1)); + time = (aStep->GetPostStepPoint()->GetGlobalTime()); + copy = (unsigned int)(touchable->GetReplicaNumber(0) + + 1000 * touchable->GetReplicaNumber(1)); } if (it != mapLV_.end()) { - storeInfo(it, plv, copy, time, energy, true); + storeInfo(it, plv, copy, time, energy, true); } else if (topLV_ != nullptr) { - auto itr = findLV(topLV_); - if (itr != mapLV_.end()) { - storeInfo(itr, topLV_, copy, time, energy, true); - } + auto itr = findLV(topLV_); + if (itr != mapLV_.end()) { + storeInfo(itr, topLV_, copy, time, energy, true); + } } - }//if (curSD==NULL) + } // if (curSD==NULL) - //Now for the mother volumes + // Now for the mother volumes int level = (touchable->GetHistoryDepth()); if (level > 0) { - double energy = (aStep->GetTotalEnergyDeposit())/CLHEP::GeV; - double time = (aStep->GetTrack()->GetGlobalTime()); + double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV; + double time = (aStep->GetTrack()->GetGlobalTime()); - for (int i=level; i>0; --i) { - G4LogicalVolume* plv = touchable->GetVolume(i)->GetLogicalVolume(); - auto it = (init_) ? mapLV_.find(plv) : findLV(plv); + for (int i = level; i > 0; --i) { + G4LogicalVolume* plv = touchable->GetVolume(i)->GetLogicalVolume(); + auto it = (init_) ? mapLV_.find(plv) : findLV(plv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ValidHGCal") << "Level: " << ii << ":" << i << " " - << plv->GetName() <<" flag in the List " - << (it != mapLV_.end()); + edm::LogVerbatim("ValidHGCal") + << "Level: " << ii << ":" << i << " " << plv->GetName() + << " flag in the List " << (it != mapLV_.end()); #endif - if (it != mapLV_.end()) { - unsigned int copy = (i == level) ? 0 : - (unsigned int)(touchable->GetReplicaNumber(i) + - 1000*touchable->GetReplicaNumber(i+1)); - storeInfo(it, plv, copy, time, energy, false); - } + if (it != mapLV_.end()) { + unsigned int copy = + (i == level) + ? 0 + : (unsigned int)(touchable->GetReplicaNumber(i) + + 1000 * touchable->GetReplicaNumber(i + 1)); + storeInfo(it, plv, copy, time, energy, false); + } } } - }//if (aStep != NULL) + } // if (aStep != NULL) - -}//end update aStep +} // end update aStep //================================================================ End of EVENT @@ -173,33 +171,35 @@ void HGCPassive::endOfEvent(edm::PassiveHitContainer& hgcPH, unsigned int k) { auto it = mapLV_.find(lv); if (it != mapLV_.end()) { if ((it->second).first == k) { - PassiveHit hit((it->second).second,(element.first).second, - (element.second)[1],(element.second)[2], - (element.second)[0]); - hgcPH.push_back(hit); + PassiveHit hit((it->second).second, (element.first).second, + (element.second)[1], (element.second)[2], + (element.second)[0]); + hgcPH.push_back(hit); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ValidHGCal") << "HGCPassive[" << k << "] Hit[" - << kount << "] " << hit; - ++kount; + edm::LogVerbatim("ValidHGCal") + << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit; + ++kount; #endif } } } } -G4VPhysicalVolume * HGCPassive::getTopPV() { - return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume(); +G4VPhysicalVolume* HGCPassive::getTopPV() { + return G4TransportationManager::GetTransportationManager() + ->GetNavigatorForTracking() + ->GetWorldVolume(); } -HGCPassive::volumeIterator HGCPassive::findLV(G4LogicalVolume * plv) { +HGCPassive::volumeIterator HGCPassive::findLV(G4LogicalVolume* plv) { auto itr = mapLV_.find(plv); if (itr == mapLV_.end()) { std::string name = plv->GetName(); - for (unsigned int k=0; k(k,name); - itr = mapLV_.find(plv); - break; + mapLV_[plv] = std::pair(k, name); + itr = mapLV_.find(plv); + break; } } } @@ -210,28 +210,24 @@ HGCPassive::volumeIterator HGCPassive::findLV(G4LogicalVolume * plv) { } void HGCPassive::storeInfo(const HGCPassive::volumeIterator it, - G4LogicalVolume* plv, unsigned int copy, - double time, double energy, bool flag) { - - std::pair key(plv,copy); - auto itr = store_.find(key); + G4LogicalVolume* plv, unsigned int copy, double time, + double energy, bool flag) { + std::pair key(plv, copy); + auto itr = store_.find(key); double ee = (flag) ? energy : 0; if (itr == store_.end()) { - store_[key] = { {time, energy, energy} }; + store_[key] = {{time, energy, energy}}; } else { (itr->second)[1] += ee; (itr->second)[2] += energy; } #ifdef EDM_ML_DEBUG - itr = store_.find(key); - edm::LogVerbatim("ValidHGCal") << "HGCPassive: Element " - << (it->second).first << ":" - << (it->second).second << ":" << copy << " T " - << (itr->second)[0] << " E " - << (itr->second)[1] << ":" - << (itr->second)[2]; + itr = store_.find(key); + edm::LogVerbatim("ValidHGCal") + << "HGCPassive: Element " << (it->second).first << ":" + << (it->second).second << ":" << copy << " T " << (itr->second)[0] + << " E " << (itr->second)[1] << ":" << (itr->second)[2]; #endif } -DEFINE_SIMWATCHER (HGCPassive); - +DEFINE_SIMWATCHER(HGCPassive); diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.h b/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.h index 1f8b59350dbc4..7331a90cd698e 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.h +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCPassive.h @@ -1,14 +1,14 @@ /////////////////////////////////////////////////////////////////////////////// // File: HGCPassive.cc -//copied from SimG4HGCalValidation +// copied from SimG4HGCalValidation // Description: Main analysis class for HGCal Validation of G4 Hits /////////////////////////////////////////////////////////////////////////////// -#include "SimG4Core/Notification/interface/BeginOfRun.h" #include "SimG4Core/Notification/interface/BeginOfEvent.h" +#include "SimG4Core/Notification/interface/BeginOfRun.h" #include "SimG4Core/Notification/interface/EndOfEvent.h" -#include "SimG4Core/Watcher/interface/SimProducer.h" #include "SimG4Core/Notification/interface/Observer.h" +#include "SimG4Core/Watcher/interface/SimProducer.h" // to retreive hits #include "SimDataFormats/CaloHit/interface/PassiveHit.h" @@ -17,17 +17,17 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" -#include "FWCore/PluginManager/interface/ModuleDef.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" #include "SimDataFormats/CaloHit/interface/PassiveHit.h" -#include "G4Step.hh" #include "G4LogicalVolumeStore.hh" #include "G4PhysicalVolumeStore.hh" -#include "G4Track.hh" +#include "G4Step.hh" #include "G4TouchableHistory.hh" +#include "G4Track.hh" #include #include @@ -35,47 +35,45 @@ #include class HGCPassive : public SimProducer, - public Observer, - public Observer, - public Observer { - - -public: + public Observer, + public Observer, + public Observer { + public: HGCPassive(const edm::ParameterSet &p); ~HGCPassive() override; - void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event &, const edm::EventSetup &) override; -private: - HGCPassive(const HGCPassive&) = delete; // stop default - const HGCPassive& operator=(const HGCPassive&) = delete; + private: + HGCPassive(const HGCPassive &) = delete; // stop default + const HGCPassive &operator=(const HGCPassive &) = delete; // observer classes - void update(const BeginOfRun * run) override; - void update(const BeginOfEvent * evt) override; - void update(const G4Step * step) override; - - //void endOfEvent(edm::PassiveHitContainer &HGCEEAbsE); - void endOfEvent(edm::PassiveHitContainer& hgcPH, unsigned int k); - - typedef std::map>::iterator volumeIterator; - G4VPhysicalVolume * getTopPV(); - volumeIterator findLV(G4LogicalVolume * plv); - void storeInfo(const volumeIterator itr, G4LogicalVolume* plv, - unsigned int copy, double time, double energy, bool flag); - -private: - + void update(const BeginOfRun *run) override; + void update(const BeginOfEvent *evt) override; + void update(const G4Step *step) override; + + // void endOfEvent(edm::PassiveHitContainer &HGCEEAbsE); + void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k); + + typedef std::map>::iterator + volumeIterator; + G4VPhysicalVolume *getTopPV(); + volumeIterator findLV(G4LogicalVolume *plv); + void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, + unsigned int copy, double time, double energy, bool flag); + + private: std::vector LVNames_; - G4VPhysicalVolume *topPV_; - G4LogicalVolume *topLV_; - std::map> mapLV_; - std::string motherName_; - - // some private members for ananlysis - unsigned int count_; - bool init_; - std::map,std::array> store_; + G4VPhysicalVolume *topPV_; + G4LogicalVolume *topLV_; + std::map> mapLV_; + std::string motherName_; + + // some private members for ananlysis + unsigned int count_; + bool init_; + std::map, std::array> + store_; }; - - diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc index ba7a95bc74311..01f402a24ade9 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc @@ -1,5 +1,3 @@ -#include "SimG4CMS/Calo/interface/CaloSD.h" -#include "SimG4Core/Notification/interface/TrackInformation.h" #include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" @@ -7,141 +5,141 @@ #include "DetectorDescription/Core/interface/DDSplit.h" #include "DetectorDescription/Core/interface/DDValue.h" #include "FWCore/Utilities/interface/Exception.h" +#include "SimG4CMS/Calo/interface/CaloSD.h" +#include "SimG4Core/Notification/interface/TrackInformation.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "G4LogicalVolumeStore.hh" +#include "G4Material.hh" #include "G4Step.hh" #include "G4Track.hh" -#include "G4Material.hh" -#include "G4LogicalVolumeStore.hh" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include //#define EDM_ML_DEBUG class HGCalTB16SD01 : public CaloSD { - -public: - - HGCalTB16SD01(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, edm::ParameterSet const &, - const SimTrackManager*); + public: + HGCalTB16SD01(const std::string&, const DDCompactView&, + const SensitiveDetectorCatalog&, edm::ParameterSet const&, + const SimTrackManager*); ~HGCalTB16SD01() override = default; uint32_t setDetUnitId(const G4Step* step) override; - static uint32_t packIndex(int det, int lay, int x, int y); - static void unpackIndex(const uint32_t & idx, int& det, int& lay, - int& x, int& y); - -protected: + static uint32_t packIndex(int det, int lay, int x, int y); + static void unpackIndex(const uint32_t& idx, int& det, int& lay, int& x, + int& y); - double getEnergyDeposit(const G4Step*) override; + protected: + double getEnergyDeposit(const G4Step*) override; -private: - void initialize(const G4StepPoint* point); + private: + void initialize(const G4StepPoint* point); - std::string matName_; - bool useBirk_; - double birk1_, birk2_, birk3_; - bool initialize_; - G4Material* matScin_; + std::string matName_; + bool useBirk_; + double birk1_, birk2_, birk3_; + bool initialize_; + G4Material* matScin_; }; -HGCalTB16SD01::HGCalTB16SD01(const std::string& name, - const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, - const SimTrackManager* manager) : - CaloSD(name, cpv, clg, p, manager), initialize_(true) { - +HGCalTB16SD01::HGCalTB16SD01(const std::string& name, const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, cpv, clg, p, manager), initialize_(true) { // Values from NIM 80 (1970) 239-244: as implemented in Geant3 edm::ParameterSet m_HC = p.getParameter("HGCalTestBeamSD"); - matName_ = m_HC.getParameter("Material"); - useBirk_ = m_HC.getParameter("UseBirkLaw"); - birk1_ = m_HC.getParameter("BirkC1")*(g/(MeV*cm2)); - birk2_ = m_HC.getParameter("BirkC2"); - birk3_ = m_HC.getParameter("BirkC3"); - matScin_ = nullptr; - - edm::LogVerbatim("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " - << useBirk_ << " for " << matName_ - << " with three constants kB = " << birk1_ - << ", C1 = " << birk2_ << ", C2 = " << birk3_; + matName_ = m_HC.getParameter("Material"); + useBirk_ = m_HC.getParameter("UseBirkLaw"); + birk1_ = m_HC.getParameter("BirkC1") * (g / (MeV * cm2)); + birk2_ = m_HC.getParameter("BirkC2"); + birk3_ = m_HC.getParameter("BirkC3"); + matScin_ = nullptr; + + edm::LogVerbatim("HGCSim") + << "HGCalTB16SD01:: Use of Birks law is set to " << useBirk_ << " for " + << matName_ << " with three constants kB = " << birk1_ + << ", C1 = " << birk2_ << ", C2 = " << birk3_; } double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) { - auto const point = aStep->GetPreStepPoint(); if (initialize_) initialize(point); double destep = aStep->GetTotalEnergyDeposit(); - double wt2 = aStep->GetTrack()->GetWeight(); + double wt2 = aStep->GetTrack()->GetWeight(); double weight = (wt2 > 0.0) ? wt2 : 1.0; if (useBirk_ && matScin_ == point->GetMaterial()) { weight *= getAttenuation(aStep, birk1_, birk2_, birk3_); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " - << point->GetTouchable()->GetVolume()->GetName() - << " with " << point->GetMaterial()->GetName() - << " weight " << weight << ":" << wt2; + edm::LogVerbatim("HGCSim") + << "HGCalTB16SD01: Detector " + << point->GetTouchable()->GetVolume()->GetName() << " with " + << point->GetMaterial()->GetName() << " weight " << weight << ":" << wt2; #endif - return weight*destep; + return weight * destep; } -uint32_t HGCalTB16SD01::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t HGCalTB16SD01::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); int det(1), x(0), y(0); int lay = (touch->GetReplicaNumber(0)); - return packIndex (det, lay, x, y); + return packIndex(det, lay, x, y); } uint32_t HGCalTB16SD01::packIndex(int det, int lay, int x, int y) { - int ix = 0, ixx = x; - if (x < 0) { ix = 1; ixx =-x;} + if (x < 0) { + ix = 1; + ixx = -x; + } int iy = 0, iyy = y; - if (y < 0) { iy = 1; iyy =-y;} - uint32_t idx = (det&15)<<28; //bits 28-31 - idx += (lay&127)<<21; //bits 21-27 - idx += (iy&1)<<19; //bit 19 - idx += (iyy&511)<<10; //bits 10-18 - idx += (ix&1)<<9; //bit 9 - idx += (ixx&511); //bits 0-8 + if (y < 0) { + iy = 1; + iyy = -y; + } + uint32_t idx = (det & 15) << 28; // bits 28-31 + idx += (lay & 127) << 21; // bits 21-27 + idx += (iy & 1) << 19; // bit 19 + idx += (iyy & 511) << 10; // bits 10-18 + idx += (ix & 1) << 9; // bit 9 + idx += (ixx & 511); // bits 0-8 #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << det << " Layer " - << lay << " x " << x << " " << ix << " " << ixx - << " y " << y << " " << iy << " " << iyy << " ID " - << std::hex << idx << std::dec; + edm::LogVerbatim("HGCSim") + << "HGCalTB16SD01: Detector " << det << " Layer " << lay << " x " << x + << " " << ix << " " << ixx << " y " << y << " " << iy << " " << iyy + << " ID " << std::hex << idx << std::dec; #endif return idx; } -void HGCalTB16SD01::unpackIndex(const uint32_t & idx, int& det, int& lay, - int& x, int& y) { - - det = (idx>>28)&15; - lay = (idx>>21)&127; - y = (idx>>10)&511; if (((idx>>19)&1) == 1) y = -y; - x = (idx)&511; if (((idx>>9)&1) == 1) x = -x; - +void HGCalTB16SD01::unpackIndex(const uint32_t& idx, int& det, int& lay, int& x, + int& y) { + det = (idx >> 28) & 15; + lay = (idx >> 21) & 127; + y = (idx >> 10) & 511; + if (((idx >> 19) & 1) == 1) y = -y; + x = (idx)&511; + if (((idx >> 9) & 1) == 1) x = -x; } void HGCalTB16SD01::initialize(const G4StepPoint* point) { if (matName_ == point->GetMaterial()->GetName()) { - matScin_ = point->GetMaterial(); + matScin_ = point->GetMaterial(); initialize_ = false; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Material pointer for " - << matName_ << " is initialized to : " < -#include #include -#include +#include #include +#include #include +#include // user include files #include "CommonTools/UtilAlgos/interface/TFileService.h" @@ -12,15 +12,15 @@ #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -40,335 +40,356 @@ #include "SimDataFormats/CaloHit/interface/PassiveHit.h" // Root objects -#include "TROOT.h" -#include "TSystem.h" #include "TFile.h" #include "TH1.h" #include "TH2.h" #include "TProfile.h" #include "TProfile2D.h" +#include "TROOT.h" +#include "TSystem.h" #include "TTree.h" //#define EDM_ML_DEBUG -class HGCalTBAnalyzer : public edm::one::EDAnalyzer { - -public: +class HGCalTBAnalyzer : public edm::one::EDAnalyzer { + public: explicit HGCalTBAnalyzer(edm::ParameterSet const&); ~HGCalTBAnalyzer() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); -private: - void beginJob() override ; + private: + void beginJob() override; void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override {} void analyze(edm::Event const&, edm::EventSetup const&) override; void analyzeSimHits(int type, std::vector& hits, double zFront); - void analyzeSimTracks(edm::Handle const& SimTk, - edm::Handle const& SimVtx); - template void analyzeDigi(int type, const T1& detId, uint16_t adc); - void analyzeRecHits(int type, edm::Handle & hits); - void analyzePassiveHits (edm::Handle const& hgcPh, - int subdet); - - edm::Service fs_; - const HGCalDDDConstants *hgcons_[2]; - const HGCalGeometry *hgeom_[2]; - bool ifEE_, ifFH_, ifBH_, ifBeam_; - bool doTree_, doTreeCell_; - bool doSimHits_, doDigis_, doRecHits_; - bool doPassive_; - std::string detectorEE_, detectorFH_; - std::string detectorBH_, detectorBeam_; - double zFrontEE_, zFrontFH_, zFrontBH_; - int sampleIndex_; - std::vector idBeams_; - edm::EDGetTokenT tok_hitsEE_, tok_hitsFH_; - edm::EDGetTokenT tok_hitsBH_, tok_hitsBeam_; - edm::EDGetTokenT tok_simTk_; + void analyzeSimTracks(edm::Handle const& SimTk, + edm::Handle const& SimVtx); + template + void analyzeDigi(int type, const T1& detId, uint16_t adc); + void analyzeRecHits(int type, edm::Handle& hits); + void analyzePassiveHits(edm::Handle const& hgcPh, + int subdet); + + edm::Service fs_; + const HGCalDDDConstants* hgcons_[2]; + const HGCalGeometry* hgeom_[2]; + bool ifEE_, ifFH_, ifBH_, ifBeam_; + bool doTree_, doTreeCell_; + bool doSimHits_, doDigis_, doRecHits_; + bool doPassive_; + std::string detectorEE_, detectorFH_; + std::string detectorBH_, detectorBeam_; + double zFrontEE_, zFrontFH_, zFrontBH_; + int sampleIndex_; + std::vector idBeams_; + edm::EDGetTokenT tok_hitsEE_, tok_hitsFH_; + edm::EDGetTokenT tok_hitsBH_, tok_hitsBeam_; + edm::EDGetTokenT tok_simTk_; edm::EDGetTokenT tok_simVtx_; - edm::EDGetToken tok_digiEE_, tok_digiFH_, tok_digiBH_; - edm::EDGetToken tok_hitrEE_, tok_hitrFH_, tok_hitrBH_; - edm::EDGetTokenT tok_hepMC_; + edm::EDGetToken tok_digiEE_, tok_digiFH_, tok_digiBH_; + edm::EDGetToken tok_hitrEE_, tok_hitrFH_, tok_hitrBH_; + edm::EDGetTokenT tok_hepMC_; edm::EDGetTokenT tok_hgcPHEE_, tok_hgcPHFH_; edm::EDGetTokenT tok_hgcPHBH_, tok_hgcPHCMSE_; - TTree *tree_; - TH1D *hSimHitE_[4], *hSimHitT_[4]; - TH1D *hDigiADC_[3], *hDigiLng_[2]; - TH1D *hRecHitE_[3], *hSimHitEn_[4], *hBeam_; - TH2D *hDigiOcc_[3], *hRecHitOcc_[3]; - TProfile *hSimHitLng_[3], *hSimHitLng1_[3]; - TProfile *hSimHitLng2_[3]; - TProfile *hRecHitLng_[3], *hRecHitLng1_[3]; - TProfile2D *hSimHitLat_[3], *hRecHitLat_[3]; - std::vector hSimHitLayEn1EE_, hSimHitLayEn2EE_; - std::vector hSimHitLayEn1FH_, hSimHitLayEn2FH_; - std::vector hSimHitLayEn1BH_, hSimHitLayEn2BH_; - std::vector hSimHitLayEnBeam_; - std::vector simHitLayEn1EE_, simHitLayEn2EE_; - std::vector simHitLayEn1FH_, simHitLayEn2FH_; - std::vector simHitLayEn1BH_, simHitLayEn2BH_; - std::vector simHitLayEnBeam_; - std::vector simHitCellIdEE_, simHitCellIdFH_; - std::vector simHitCellIdBH_, simHitCellIdBeam_; - std::vector simHitCellEnEE_, simHitCellEnFH_; - std::vector simHitCellEnBH_, simHitCellEnBeam_; - - std::vector hgcPassiveEEEnergy_, hgcPassiveFHEnergy_, hgcPassiveBHEnergy_, hgcPassiveCMSEEnergy_; - std::vector hgcPassiveEEName_, hgcPassiveFHName_, hgcPassiveBHName_, hgcPassiveCMSEName_; - std::vector hgcPassiveEEID_, hgcPassiveFHID_, hgcPassiveBHID_, hgcPassiveCMSEID_; - - double xBeam_, yBeam_, zBeam_, pBeam_; + TTree* tree_; + TH1D *hSimHitE_[4], *hSimHitT_[4]; + TH1D *hDigiADC_[3], *hDigiLng_[2]; + TH1D *hRecHitE_[3], *hSimHitEn_[4], *hBeam_; + TH2D *hDigiOcc_[3], *hRecHitOcc_[3]; + TProfile *hSimHitLng_[3], *hSimHitLng1_[3]; + TProfile* hSimHitLng2_[3]; + TProfile *hRecHitLng_[3], *hRecHitLng1_[3]; + TProfile2D *hSimHitLat_[3], *hRecHitLat_[3]; + std::vector hSimHitLayEn1EE_, hSimHitLayEn2EE_; + std::vector hSimHitLayEn1FH_, hSimHitLayEn2FH_; + std::vector hSimHitLayEn1BH_, hSimHitLayEn2BH_; + std::vector hSimHitLayEnBeam_; + std::vector simHitLayEn1EE_, simHitLayEn2EE_; + std::vector simHitLayEn1FH_, simHitLayEn2FH_; + std::vector simHitLayEn1BH_, simHitLayEn2BH_; + std::vector simHitLayEnBeam_; + std::vector simHitCellIdEE_, simHitCellIdFH_; + std::vector simHitCellIdBH_, simHitCellIdBeam_; + std::vector simHitCellEnEE_, simHitCellEnFH_; + std::vector simHitCellEnBH_, simHitCellEnBeam_; + + std::vector hgcPassiveEEEnergy_, hgcPassiveFHEnergy_, + hgcPassiveBHEnergy_, hgcPassiveCMSEEnergy_; + std::vector hgcPassiveEEName_, hgcPassiveFHName_, + hgcPassiveBHName_, hgcPassiveCMSEName_; + std::vector hgcPassiveEEID_, hgcPassiveFHID_, hgcPassiveBHID_, + hgcPassiveCMSEID_; + + double xBeam_, yBeam_, zBeam_, pBeam_; }; HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { - usesResource("TFileService"); - //now do whatever initialization is needed - detectorEE_ = iConfig.getParameter("DetectorEE"); - detectorFH_ = iConfig.getParameter("DetectorFH"); - detectorBH_ = iConfig.getParameter("DetectorBH"); - detectorBeam_= iConfig.getParameter("DetectorBeam"); - ifEE_ = iConfig.getParameter("UseEE"); - ifFH_ = iConfig.getParameter("UseFH"); - ifBH_ = iConfig.getParameter("UseBH"); - ifBeam_ = iConfig.getParameter("UseBeam"); - zFrontEE_ = iConfig.getParameter("ZFrontEE"); - zFrontFH_ = iConfig.getParameter("ZFrontFH"); - zFrontBH_ = iConfig.getParameter("ZFrontBH"); - idBeams_ = iConfig.getParameter>("IDBeams"); - doSimHits_ = iConfig.getParameter("DoSimHits"); - doDigis_ = iConfig.getParameter("DoDigis"); + // now do whatever initialization is needed + detectorEE_ = iConfig.getParameter("DetectorEE"); + detectorFH_ = iConfig.getParameter("DetectorFH"); + detectorBH_ = iConfig.getParameter("DetectorBH"); + detectorBeam_ = iConfig.getParameter("DetectorBeam"); + ifEE_ = iConfig.getParameter("UseEE"); + ifFH_ = iConfig.getParameter("UseFH"); + ifBH_ = iConfig.getParameter("UseBH"); + ifBeam_ = iConfig.getParameter("UseBeam"); + zFrontEE_ = iConfig.getParameter("ZFrontEE"); + zFrontFH_ = iConfig.getParameter("ZFrontFH"); + zFrontBH_ = iConfig.getParameter("ZFrontBH"); + idBeams_ = iConfig.getParameter>("IDBeams"); + doSimHits_ = iConfig.getParameter("DoSimHits"); + doDigis_ = iConfig.getParameter("DoDigis"); sampleIndex_ = iConfig.getParameter("SampleIndex"); - doRecHits_ = iConfig.getParameter("DoRecHits"); - doTree_ = iConfig.getUntrackedParameter("DoTree",false); - doTreeCell_ = iConfig.getUntrackedParameter("DoTreeCell",false); - doPassive_ = iConfig.getUntrackedParameter("DoPassive",false); + doRecHits_ = iConfig.getParameter("DoRecHits"); + doTree_ = iConfig.getUntrackedParameter("DoTree", false); + doTreeCell_ = iConfig.getUntrackedParameter("DoTreeCell", false); + doPassive_ = iConfig.getUntrackedParameter("DoPassive", false); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ - << " Digis = " << doDigis_ << ":" << sampleIndex_ - << " RecHits = " << doRecHits_ << " useDets " - << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" - << ifBeam_ << " zFront " << zFrontEE_ << ":" - << zFrontFH_ << ":" << zFrontBH_ << " IdBeam " - << idBeams_.size() << ":"; - for (unsigned int k=0; k("GeneratorSrc"); - tok_hepMC_ = consumes(tmp0); + tok_hepMC_ = consumes(tmp0); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0; #endif - std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); - tok_hitsEE_ = consumes(edm::InputTag("g4SimHits",tmp1)); - tok_simTk_ = consumes(edm::InputTag("g4SimHits")); - tok_simVtx_ = consumes(edm::InputTag("g4SimHits")); + std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); + tok_hitsEE_ = + consumes(edm::InputTag("g4SimHits", tmp1)); + tok_simTk_ = consumes(edm::InputTag("g4SimHits")); + tok_simVtx_ = consumes(edm::InputTag("g4SimHits")); edm::InputTag tmp2 = iConfig.getParameter("DigiSrcEE"); - tok_digiEE_ = consumes(tmp2); + tok_digiEE_ = consumes(tmp2); edm::InputTag tmp3 = iConfig.getParameter("RecHitSrcEE"); - tok_hitrEE_ = consumes(tmp3); + tok_hitrEE_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifEE_) { - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorEE_ - << " with tags " << tmp1 << ", " << tmp2 << ", " - << tmp3; + edm::LogVerbatim("HGCSim") + << "HGCalTBAnalyzer:: Detector " << detectorEE_ << " with tags " << tmp1 + << ", " << tmp2 << ", " << tmp3; } #endif - tmp1 = iConfig.getParameter("CaloHitSrcFH"); - tok_hitsFH_ = consumes(edm::InputTag("g4SimHits",tmp1)); - tmp2 = iConfig.getParameter("DigiSrcFH"); - tok_digiFH_ = consumes(tmp2); - tmp3 = iConfig.getParameter("RecHitSrcFH"); - tok_hitrFH_ = consumes(tmp3); + tmp1 = iConfig.getParameter("CaloHitSrcFH"); + tok_hitsFH_ = + consumes(edm::InputTag("g4SimHits", tmp1)); + tmp2 = iConfig.getParameter("DigiSrcFH"); + tok_digiFH_ = consumes(tmp2); + tmp3 = iConfig.getParameter("RecHitSrcFH"); + tok_hitrFH_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifFH_) { - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorFH_ - << " with tags " << tmp1 << ", " << tmp2 << ", " - << tmp3; + edm::LogVerbatim("HGCSim") + << "HGCalTBAnalyzer:: Detector " << detectorFH_ << " with tags " << tmp1 + << ", " << tmp2 << ", " << tmp3; } #endif - tmp1 = iConfig.getParameter("CaloHitSrcBH"); - tok_hitsBH_ = consumes(edm::InputTag("g4SimHits",tmp1)); - tmp2 = iConfig.getParameter("DigiSrcBH"); - tok_digiBH_ = consumes(tmp2); - tmp3 = iConfig.getParameter("RecHitSrcBH"); - tok_hitrBH_ = consumes(tmp3); - - ///Passive hits + tmp1 = iConfig.getParameter("CaloHitSrcBH"); + tok_hitsBH_ = + consumes(edm::InputTag("g4SimHits", tmp1)); + tmp2 = iConfig.getParameter("DigiSrcBH"); + tok_digiBH_ = consumes(tmp2); + tmp3 = iConfig.getParameter("RecHitSrcBH"); + tok_hitrBH_ = consumes(tmp3); + + /// Passive hits edm::InputTag tmp = iConfig.getParameter("HGCPassiveEE"); - tok_hgcPHEE_ = consumes(tmp); + tok_hgcPHEE_ = consumes(tmp); tmp = iConfig.getParameter("HGCPassiveFH"); - tok_hgcPHFH_ = consumes(tmp); + tok_hgcPHFH_ = consumes(tmp); tmp = iConfig.getParameter("HGCPassiveBH"); - tok_hgcPHBH_ = consumes(tmp); + tok_hgcPHBH_ = consumes(tmp); tmp = iConfig.getParameter("HGCPassiveCMSE"); - tok_hgcPHCMSE_ = consumes(tmp); + tok_hgcPHCMSE_ = consumes(tmp); #ifdef EDM_ML_DEBUG if (ifBH_) { - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorBH_ - << " with tags " << tmp1 << ", " << tmp2 << ", " - << tmp3; + edm::LogVerbatim("HGCSim") + << "HGCalTBAnalyzer:: Detector " << detectorBH_ << " with tags " << tmp1 + << ", " << tmp2 << ", " << tmp3; } #endif - tmp1 = iConfig.getParameter("CaloHitSrcBeam"); - tok_hitsBeam_= consumes(edm::InputTag("g4SimHits",tmp1)); + tmp1 = iConfig.getParameter("CaloHitSrcBeam"); + tok_hitsBeam_ = + consumes(edm::InputTag("g4SimHits", tmp1)); #ifdef EDM_ML_DEBUG if (ifBeam_) { - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " - << detectorBeam_ << " with tags " << tmp1; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorBeam_ + << " with tags " << tmp1; } #endif } HGCalTBAnalyzer::~HGCalTBAnalyzer() {} -void HGCalTBAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void HGCalTBAnalyzer::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.setUnknown(); - desc.add("DetectorEE","HGCalEESensitive"); - desc.add("UseEE",true); - desc.add("ZFrontEE",0.0); - desc.add("CaloHitSrcEE","HGCHitsEE"); - desc.add("DigiSrcEE",edm::InputTag("hgcalDigis","EE")); - desc.add("RecHitSrcEE",edm::InputTag("HGCalRecHit","HGCEERecHits")); - desc.add("DetectorFH","HGCalHESiliconSensitive"); - desc.add("UseFH",false); - desc.add("ZFrontFH",0.0); - desc.add("CaloHitSrcFH","HGCHitsHEfront"); - desc.add("DigiSrcFH",edm::InputTag("hgcalDigis","HEfront")); - desc.add("RecHitSrcFH",edm::InputTag("HGCalRecHit","HGCHEFRecHits")); - desc.add("DetectorBH","AHCal"); - desc.add("UseBH",false); - desc.add("ZFrontBH",0.0); - desc.add("CaloHitSrcBH","HcalHits"); - desc.add("DigiSrcBH",edm::InputTag("hgcalDigis","HEback")); - desc.add("RecHitSrcBH",edm::InputTag("HGCalRecHit","HGCHEBRecHits")); - desc.add("DetectorBeam","HcalTB06BeamDetector"); - desc.add("UseBeam",false); - desc.add("CaloHitSrcBeam","HcalTB06BeamHits"); - std::vector ids = {1000,1001,1002,1003,1004,1005,1006,1007,1008,1011,1012,1013,1014,2001,2002,2003,2004,2005}; - desc.add>("IDBeams",ids); - desc.add("GeneratorSrc",edm::InputTag("generatorSmeared")); - desc.add("HGCPassiveEE",edm::InputTag("g4SimHits","HGCalEEPassiveHits")); - desc.add("HGCPassiveFH",edm::InputTag("g4SimHits","HGCalHEPassiveHits")); - desc.add("HGCPassiveBH",edm::InputTag("g4SimHits","HGCalAHPassiveHits")); - desc.add("HGCPassiveCMSE",edm::InputTag("g4SimHits","CMSEPassiveHits")); - - desc.add("DoSimHits",true); - desc.add("DoDigis",true); - desc.add("DoRecHits",true); - desc.add("SampleIndex",0); - desc.addUntracked("DoTree",true); - desc.addUntracked("DoTreeCell",true); - desc.addUntracked("DoPassive",false); - - descriptions.add("HGCalTBAnalyzer",desc); + desc.add("DetectorEE", "HGCalEESensitive"); + desc.add("UseEE", true); + desc.add("ZFrontEE", 0.0); + desc.add("CaloHitSrcEE", "HGCHitsEE"); + desc.add("DigiSrcEE", edm::InputTag("hgcalDigis", "EE")); + desc.add("RecHitSrcEE", + edm::InputTag("HGCalRecHit", "HGCEERecHits")); + desc.add("DetectorFH", "HGCalHESiliconSensitive"); + desc.add("UseFH", false); + desc.add("ZFrontFH", 0.0); + desc.add("CaloHitSrcFH", "HGCHitsHEfront"); + desc.add("DigiSrcFH", edm::InputTag("hgcalDigis", "HEfront")); + desc.add("RecHitSrcFH", + edm::InputTag("HGCalRecHit", "HGCHEFRecHits")); + desc.add("DetectorBH", "AHCal"); + desc.add("UseBH", false); + desc.add("ZFrontBH", 0.0); + desc.add("CaloHitSrcBH", "HcalHits"); + desc.add("DigiSrcBH", edm::InputTag("hgcalDigis", "HEback")); + desc.add("RecHitSrcBH", + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")); + desc.add("DetectorBeam", "HcalTB06BeamDetector"); + desc.add("UseBeam", false); + desc.add("CaloHitSrcBeam", "HcalTB06BeamHits"); + std::vector ids = {1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, + 1011, 1012, 1013, 1014, 2001, 2002, 2003, 2004, 2005}; + desc.add>("IDBeams", ids); + desc.add("GeneratorSrc", edm::InputTag("generatorSmeared")); + desc.add("HGCPassiveEE", + edm::InputTag("g4SimHits", "HGCalEEPassiveHits")); + desc.add("HGCPassiveFH", + edm::InputTag("g4SimHits", "HGCalHEPassiveHits")); + desc.add("HGCPassiveBH", + edm::InputTag("g4SimHits", "HGCalAHPassiveHits")); + desc.add("HGCPassiveCMSE", + edm::InputTag("g4SimHits", "CMSEPassiveHits")); + + desc.add("DoSimHits", true); + desc.add("DoDigis", true); + desc.add("DoRecHits", true); + desc.add("SampleIndex", 0); + desc.addUntracked("DoTree", true); + desc.addUntracked("DoTreeCell", true); + desc.addUntracked("DoPassive", false); + + descriptions.add("HGCalTBAnalyzer", desc); } void HGCalTBAnalyzer::beginJob() { - char name[40], title[100]; hBeam_ = fs_->make("BeamP", "Beam Momentum", 1000, 0, 1000.0); - for (int i=0; i<3; ++i) { + for (int i = 0; i < 3; ++i) { bool book(ifEE_); - std::string det(detectorEE_); + std::string det(detectorEE_); if (i == 1) { book = ifFH_; - det = detectorFH_; + det = detectorFH_; } else if (i == 2) { book = ifBH_; - det = detectorBH_; + det = detectorBH_; } if (doSimHits_ && book) { - sprintf (name, "SimHitEn%s", det.c_str()); - sprintf (title,"Sim Hit Energy for %s", det.c_str()); - hSimHitE_[i] = fs_->make(name,title,100000,0.,0.2); - sprintf (name, "SimHitEnX%s", det.c_str()); - sprintf (title,"Sim Hit Energy for %s", det.c_str()); - hSimHitEn_[i] = fs_->make(name,title,100000,0.,0.2); - sprintf (name, "SimHitTm%s", det.c_str()); - sprintf (title,"Sim Hit Timing for %s", det.c_str()); - hSimHitT_[i] = fs_->make(name,title,5000,0.,500.0); - sprintf (name, "SimHitLat%s", det.c_str()); - sprintf (title,"Lateral Shower profile (Sim Hit) for %s", det.c_str()); - hSimHitLat_[i] = fs_->make(name,title,100,-100.,100.,100,-100.,100.); - sprintf (name, "SimHitLng%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile (Sim Hit) for %s",det.c_str()); - hSimHitLng_[i] = fs_->make(name,title,50,0.,100.); - sprintf (name, "SimHitLng1%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile (Layer) for %s",det.c_str()); - hSimHitLng1_[i] = fs_->make(name,title,200,0.,100.); - sprintf (name, "SimHitLng2%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile (Layer) for %s",det.c_str()); - hSimHitLng2_[i] = fs_->make(name,title,200,0.,100.); + sprintf(name, "SimHitEn%s", det.c_str()); + sprintf(title, "Sim Hit Energy for %s", det.c_str()); + hSimHitE_[i] = fs_->make(name, title, 100000, 0., 0.2); + sprintf(name, "SimHitEnX%s", det.c_str()); + sprintf(title, "Sim Hit Energy for %s", det.c_str()); + hSimHitEn_[i] = fs_->make(name, title, 100000, 0., 0.2); + sprintf(name, "SimHitTm%s", det.c_str()); + sprintf(title, "Sim Hit Timing for %s", det.c_str()); + hSimHitT_[i] = fs_->make(name, title, 5000, 0., 500.0); + sprintf(name, "SimHitLat%s", det.c_str()); + sprintf(title, "Lateral Shower profile (Sim Hit) for %s", det.c_str()); + hSimHitLat_[i] = fs_->make(name, title, 100, -100., 100., 100, + -100., 100.); + sprintf(name, "SimHitLng%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile (Sim Hit) for %s", + det.c_str()); + hSimHitLng_[i] = fs_->make(name, title, 50, 0., 100.); + sprintf(name, "SimHitLng1%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile (Layer) for %s", det.c_str()); + hSimHitLng1_[i] = fs_->make(name, title, 200, 0., 100.); + sprintf(name, "SimHitLng2%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile (Layer) for %s", det.c_str()); + hSimHitLng2_[i] = fs_->make(name, title, 200, 0., 100.); } if (doDigis_ && book) { - sprintf (name, "DigiADC%s", det.c_str()); - sprintf (title,"ADC at Digi level for %s", det.c_str()); - hDigiADC_[i] = fs_->make(name,title,100,0.,100.0); - sprintf (name, "DigiOcc%s", det.c_str()); - sprintf (title,"Occupancy (Digi)for %s", det.c_str()); - hDigiOcc_[i] = fs_->make(name,title,100,-10.,10.,100,-10.,10.); - sprintf (name, "DigiLng%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile (Digi) for %s",det.c_str()); - hDigiLng_[i] = fs_->make(name,title,100,0.,10.); + sprintf(name, "DigiADC%s", det.c_str()); + sprintf(title, "ADC at Digi level for %s", det.c_str()); + hDigiADC_[i] = fs_->make(name, title, 100, 0., 100.0); + sprintf(name, "DigiOcc%s", det.c_str()); + sprintf(title, "Occupancy (Digi)for %s", det.c_str()); + hDigiOcc_[i] = + fs_->make(name, title, 100, -10., 10., 100, -10., 10.); + sprintf(name, "DigiLng%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile (Digi) for %s", det.c_str()); + hDigiLng_[i] = fs_->make(name, title, 100, 0., 10.); } if (doRecHits_ && book) { - sprintf (name, "RecHitEn%s", det.c_str()); - sprintf (title,"Rec Hit Energy for %s", det.c_str()); - hRecHitE_[i] = fs_->make(name,title,1000,0.,10.0); - sprintf (name, "RecHitOcc%s", det.c_str()); - sprintf (title,"Occupancy (Rec Hit)for %s", det.c_str()); - hRecHitOcc_[i] = fs_->make(name,title,100,-10.,10.,100,-10.,10.); - sprintf (name, "RecHitLat%s", det.c_str()); - sprintf (title,"Lateral Shower profile (Rec Hit) for %s", det.c_str()); - hRecHitLat_[i] = fs_->make(name,title,100,-10.,10.,100,-10.,10.); - sprintf (name, "RecHitLng%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile (Rec Hit) for %s",det.c_str()); - hRecHitLng_[i] = fs_->make(name,title,100,0.,10.); - sprintf (name, "RecHitLng1%s", det.c_str()); - sprintf (title,"Longitudinal Shower profile vs Layer for %s",det.c_str()); - hRecHitLng1_[i] = fs_->make(name,title,120,0.,60.); + sprintf(name, "RecHitEn%s", det.c_str()); + sprintf(title, "Rec Hit Energy for %s", det.c_str()); + hRecHitE_[i] = fs_->make(name, title, 1000, 0., 10.0); + sprintf(name, "RecHitOcc%s", det.c_str()); + sprintf(title, "Occupancy (Rec Hit)for %s", det.c_str()); + hRecHitOcc_[i] = + fs_->make(name, title, 100, -10., 10., 100, -10., 10.); + sprintf(name, "RecHitLat%s", det.c_str()); + sprintf(title, "Lateral Shower profile (Rec Hit) for %s", det.c_str()); + hRecHitLat_[i] = + fs_->make(name, title, 100, -10., 10., 100, -10., 10.); + sprintf(name, "RecHitLng%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile (Rec Hit) for %s", + det.c_str()); + hRecHitLng_[i] = fs_->make(name, title, 100, 0., 10.); + sprintf(name, "RecHitLng1%s", det.c_str()); + sprintf(title, "Longitudinal Shower profile vs Layer for %s", + det.c_str()); + hRecHitLng1_[i] = fs_->make(name, title, 120, 0., 60.); } } if (ifBeam_ && doSimHits_) { - sprintf (name, "SimHitEn%s", detectorBeam_.c_str()); - sprintf (title,"Sim Hit Energy for %s", detectorBeam_.c_str()); - hSimHitE_[3] = fs_->make(name,title,100000,0.,0.2); - sprintf (name, "SimHitEnX%s", detectorBeam_.c_str()); - sprintf (title,"Sim Hit Energy for %s", detectorBeam_.c_str()); - hSimHitEn_[3] = fs_->make(name,title,100000,0.,0.2); - sprintf (name, "SimHitTm%s", detectorBeam_.c_str()); - sprintf (title,"Sim Hit Timing for %s", detectorBeam_.c_str()); - hSimHitT_[3] = fs_->make(name,title,5000,0.,500.0); + sprintf(name, "SimHitEn%s", detectorBeam_.c_str()); + sprintf(title, "Sim Hit Energy for %s", detectorBeam_.c_str()); + hSimHitE_[3] = fs_->make(name, title, 100000, 0., 0.2); + sprintf(name, "SimHitEnX%s", detectorBeam_.c_str()); + sprintf(title, "Sim Hit Energy for %s", detectorBeam_.c_str()); + hSimHitEn_[3] = fs_->make(name, title, 100000, 0., 0.2); + sprintf(name, "SimHitTm%s", detectorBeam_.c_str()); + sprintf(title, "Sim Hit Timing for %s", detectorBeam_.c_str()); + hSimHitT_[3] = fs_->make(name, title, 5000, 0., 500.0); } if (doSimHits_ && doTree_) { - tree_ = fs_->make("HGCTB","SimHitEnergy"); + tree_ = fs_->make("HGCTB", "SimHitEnergy"); tree_->Branch("simHitLayEn1EE", &simHitLayEn1EE_); tree_->Branch("simHitLayEn2EE", &simHitLayEn2EE_); tree_->Branch("simHitLayEn1FH", &simHitLayEn1FH_); tree_->Branch("simHitLayEn2FH", &simHitLayEn2FH_); tree_->Branch("simHitLayEn1BH", &simHitLayEn1BH_); tree_->Branch("simHitLayEn2BH", &simHitLayEn2BH_); - tree_->Branch("xBeam", &xBeam_, "xBeam/D"); - tree_->Branch("yBeam", &yBeam_, "yBeam/D"); - tree_->Branch("zBeam", &zBeam_, "zBeam/D"); - tree_->Branch("pBeam", &pBeam_, "pBeam/D"); + tree_->Branch("xBeam", &xBeam_, "xBeam/D"); + tree_->Branch("yBeam", &yBeam_, "yBeam/D"); + tree_->Branch("zBeam", &zBeam_, "zBeam/D"); + tree_->Branch("pBeam", &pBeam_, "pBeam/D"); if (doTreeCell_) { tree_->Branch("simHitCellIdEE", &simHitCellIdEE_); tree_->Branch("simHitCellEnEE", &simHitCellEnEE_); @@ -382,26 +403,25 @@ void HGCalTBAnalyzer::beginJob() { } if (doPassive_ && doTree_) { - tree_->Branch("hgcPassiveEEEnergy", &hgcPassiveEEEnergy_); - tree_->Branch("hgcPassiveEEName", &hgcPassiveEEName_); - tree_->Branch("hgcPassiveEEID", &hgcPassiveEEID_); - tree_->Branch("hgcPassiveFHEnergy", &hgcPassiveFHEnergy_); - tree_->Branch("hgcPassiveFHName", &hgcPassiveFHName_); - tree_->Branch("hgcPassiveFHID", &hgcPassiveFHID_); - tree_->Branch("hgcPassiveBHEnergy", &hgcPassiveBHEnergy_); - tree_->Branch("hgcPassiveBHName", &hgcPassiveBHName_); - tree_->Branch("hgcPassiveBHID", &hgcPassiveBHID_); + tree_->Branch("hgcPassiveEEEnergy", &hgcPassiveEEEnergy_); + tree_->Branch("hgcPassiveEEName", &hgcPassiveEEName_); + tree_->Branch("hgcPassiveEEID", &hgcPassiveEEID_); + tree_->Branch("hgcPassiveFHEnergy", &hgcPassiveFHEnergy_); + tree_->Branch("hgcPassiveFHName", &hgcPassiveFHName_); + tree_->Branch("hgcPassiveFHID", &hgcPassiveFHID_); + tree_->Branch("hgcPassiveBHEnergy", &hgcPassiveBHEnergy_); + tree_->Branch("hgcPassiveBHName", &hgcPassiveBHName_); + tree_->Branch("hgcPassiveBHID", &hgcPassiveBHID_); tree_->Branch("hgcPassiveCMSEEnergy", &hgcPassiveCMSEEnergy_); - tree_->Branch("hgcPassiveCMSEName", &hgcPassiveCMSEName_); - tree_->Branch("hgcPassiveCMSEID", &hgcPassiveCMSEID_); + tree_->Branch("hgcPassiveCMSEName", &hgcPassiveCMSEName_); + tree_->Branch("hgcPassiveCMSEID", &hgcPassiveCMSEID_); } } void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { - char name[40], title[100]; if (ifEE_) { - edm::ESHandle pHGDC; + edm::ESHandle pHGDC; iSetup.get().get(detectorEE_, pHGDC); hgcons_[0] = &(*pHGDC); if (doDigis_ || doRecHits_) { @@ -411,30 +431,31 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } else { hgeom_[0] = nullptr; } - for (unsigned int l=0; llayers(false); ++l) { - sprintf (name, "SimHitEnA%d%s", l, detectorEE_.c_str()); - sprintf (title,"Sim Hit Energy in SIM layer %d for %s",l+1, - detectorEE_.c_str()); - hSimHitLayEn1EE_.push_back(fs_->make(name,title,100000,0.,0.2)); - if (l%3 == 0) { - sprintf (name, "SimHitEnB%d%s", (l/3+1), detectorEE_.c_str()); - sprintf (title,"Sim Hit Energy in layer %d for %s",(l/3+1), - detectorEE_.c_str()); - hSimHitLayEn2EE_.push_back(fs_->make(name,title,100000,0.,0.2)); + for (unsigned int l = 0; l < hgcons_[0]->layers(false); ++l) { + sprintf(name, "SimHitEnA%d%s", l, detectorEE_.c_str()); + sprintf(title, "Sim Hit Energy in SIM layer %d for %s", l + 1, + detectorEE_.c_str()); + hSimHitLayEn1EE_.push_back(fs_->make(name, title, 100000, 0., 0.2)); + if (l % 3 == 0) { + sprintf(name, "SimHitEnB%d%s", (l / 3 + 1), detectorEE_.c_str()); + sprintf(title, "Sim Hit Energy in layer %d for %s", (l / 3 + 1), + detectorEE_.c_str()); + hSimHitLayEn2EE_.push_back( + fs_->make(name, title, 100000, 0., 0.2)); } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorEE_ - << " defined with " << hgcons_[0]->layers(false) - << " layers"; + edm::LogVerbatim("HGCSim") + << "HGCalTBAnalyzer::" << detectorEE_ << " defined with " + << hgcons_[0]->layers(false) << " layers"; #endif } else { hgcons_[0] = nullptr; - hgeom_[0] = nullptr; + hgeom_[0] = nullptr; } if (ifFH_) { - edm::ESHandle pHGDC; + edm::ESHandle pHGDC; iSetup.get().get(detectorFH_, pHGDC); hgcons_[1] = &(*pHGDC); if (doDigis_ || doRecHits_) { @@ -444,227 +465,242 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } else { hgeom_[1] = nullptr; } - for (unsigned int l=0; llayers(false); ++l) { - sprintf (name, "SimHitEnA%d%s", l, detectorFH_.c_str()); - sprintf (title,"Sim Hit Energy in layer %d for %s",l+1, - detectorFH_.c_str()); - hSimHitLayEn1FH_.push_back(fs_->make(name,title,100000,0.,0.2)); - if (l%3 == 0) { - sprintf (name, "SimHitEnB%d%s", (l/3+1), detectorFH_.c_str()); - sprintf (title,"Sim Hit Energy in layer %d for %s",(l/3+1), - detectorFH_.c_str()); - hSimHitLayEn2FH_.push_back(fs_->make(name,title,100000,0.,0.2)); + for (unsigned int l = 0; l < hgcons_[1]->layers(false); ++l) { + sprintf(name, "SimHitEnA%d%s", l, detectorFH_.c_str()); + sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1, + detectorFH_.c_str()); + hSimHitLayEn1FH_.push_back(fs_->make(name, title, 100000, 0., 0.2)); + if (l % 3 == 0) { + sprintf(name, "SimHitEnB%d%s", (l / 3 + 1), detectorFH_.c_str()); + sprintf(title, "Sim Hit Energy in layer %d for %s", (l / 3 + 1), + detectorFH_.c_str()); + hSimHitLayEn2FH_.push_back( + fs_->make(name, title, 100000, 0., 0.2)); } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorFH_ - << " defined with " << hgcons_[1]->layers(false) - << " layers"; + edm::LogVerbatim("HGCSim") + << "HGCalTBAnalyzer::" << detectorFH_ << " defined with " + << hgcons_[1]->layers(false) << " layers"; #endif } else { hgcons_[1] = nullptr; - hgeom_[1] = nullptr; + hgeom_[1] = nullptr; } if (ifBH_) { - for (int l=0; lmake(name,title,100000,0.,0.2)); - sprintf (name, "SimHitEnB%d%s", l, detectorBH_.c_str()); - sprintf (title,"Sim Hit Energy in layer %d for %s",l+1, - detectorBH_.c_str()); - hSimHitLayEn2BH_.push_back(fs_->make(name,title,100000,0.,0.2)); + for (int l = 0; l < AHCalDetId::MaxDepth; ++l) { + sprintf(name, "SimHitEnA%d%s", l, detectorBH_.c_str()); + sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1, + detectorBH_.c_str()); + hSimHitLayEn1BH_.push_back(fs_->make(name, title, 100000, 0., 0.2)); + sprintf(name, "SimHitEnB%d%s", l, detectorBH_.c_str()); + sprintf(title, "Sim Hit Energy in layer %d for %s", l + 1, + detectorBH_.c_str()); + hSimHitLayEn2BH_.push_back(fs_->make(name, title, 100000, 0., 0.2)); } } if (ifBeam_) { - for (unsigned int l=0; lmake(name,title,100000,0.,0.2)); + for (unsigned int l = 0; l < idBeams_.size(); ++l) { + sprintf(name, "SimHitEna%d%s", l, detectorBeam_.c_str()); + sprintf(title, "Sim Hit Energy in type %d for %s", idBeams_[l], + detectorBeam_.c_str()); + hSimHitLayEnBeam_.push_back( + fs_->make(name, title, 100000, 0., 0.2)); } } } -void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, - const edm::EventSetup& iSetup) { - - //Generator input +void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { + // Generator input edm::Handle evtMC; - iEvent.getByToken(tok_hepMC_,evtMC); + iEvent.getByToken(tok_hepMC_, evtMC); if (!evtMC.isValid()) { edm::LogWarning("HGCal") << "no HepMCProduct found"; - } else { - const HepMC::GenEvent * myGenEvent = evtMC->GetEvent(); + } else { + const HepMC::GenEvent* myGenEvent = evtMC->GetEvent(); unsigned int k(0); - for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); + for (HepMC::GenEvent::particle_const_iterator p = + myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p, ++k) { if (k == 0) hBeam_->Fill((*p)->momentum().rho()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Particle[" << k << "] with p " - << (*p)->momentum().rho() << " theta " - << (*p)->momentum().theta() << " phi " - << (*p)->momentum().phi(); + edm::LogVerbatim("HGCSim") + << "Particle[" << k << "] with p " << (*p)->momentum().rho() + << " theta " << (*p)->momentum().theta() << " phi " + << (*p)->momentum().phi(); #endif } } - //Now the Simhits + // Now the Simhits if (doSimHits_) { - edm::Handle SimTk; + edm::Handle SimTk; iEvent.getByToken(tok_simTk_, SimTk); edm::Handle SimVtx; iEvent.getByToken(tok_simVtx_, SimVtx); analyzeSimTracks(SimTk, SimVtx); - - simHitLayEn1EE_.clear(); simHitLayEn2EE_.clear(); - simHitLayEn1FH_.clear(); simHitLayEn2FH_.clear(); - simHitLayEn1BH_.clear(); simHitLayEn2BH_.clear(); + + simHitLayEn1EE_.clear(); + simHitLayEn2EE_.clear(); + simHitLayEn1FH_.clear(); + simHitLayEn2FH_.clear(); + simHitLayEn1BH_.clear(); + simHitLayEn2BH_.clear(); simHitLayEnBeam_.clear(); - simHitCellIdEE_.clear(); simHitCellEnEE_.clear(); - simHitCellIdFH_.clear(); simHitCellEnFH_.clear(); - simHitCellIdBH_.clear(); simHitCellEnBH_.clear(); - simHitCellIdBeam_.clear(); simHitCellEnBeam_.clear(); + simHitCellIdEE_.clear(); + simHitCellEnEE_.clear(); + simHitCellIdFH_.clear(); + simHitCellEnFH_.clear(); + simHitCellIdBH_.clear(); + simHitCellEnBH_.clear(); + simHitCellIdBeam_.clear(); + simHitCellEnBeam_.clear(); edm::Handle theCaloHitContainers; - std::vector caloHits; + std::vector caloHits; if (ifEE_) { - simHitLayEn1EE_ = std::vector(hgcons_[0]->layers(false),0); - simHitLayEn2EE_ = std::vector(hgcons_[0]->layers(true),0); + simHitLayEn1EE_ = std::vector(hgcons_[0]->layers(false), 0); + simHitLayEn2EE_ = std::vector(hgcons_[0]->layers(true), 0); iEvent.getByToken(tok_hitsEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorEE_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "PcalohitContainer for " << detectorEE_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); - analyzeSimHits(0, caloHits, zFrontEE_); + caloHits.clear(); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); + analyzeSimHits(0, caloHits, zFrontEE_); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " - << detectorEE_ << " !!!"; + edm::LogVerbatim("HGCSim") + << "PCaloHitContainer does not exist for " << detectorEE_ << " !!!"; #endif } } if (ifFH_) { - simHitLayEn1FH_ = std::vector(hgcons_[1]->layers(false),0); - simHitLayEn2FH_ = std::vector(hgcons_[1]->layers(true),0); + simHitLayEn1FH_ = std::vector(hgcons_[1]->layers(false), 0); + simHitLayEn2FH_ = std::vector(hgcons_[1]->layers(true), 0); iEvent.getByToken(tok_hitsFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorFH_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "PcalohitContainer for " << detectorFH_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); - analyzeSimHits(1, caloHits, zFrontFH_); + caloHits.clear(); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); + analyzeSimHits(1, caloHits, zFrontFH_); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " - << detectorFH_ << " !!!"; + edm::LogVerbatim("HGCSim") + << "PCaloHitContainer does not exist for " << detectorFH_ << " !!!"; #endif } } if (ifBH_) { - simHitLayEn1BH_ = std::vector(AHCalDetId::MaxDepth,0); - simHitLayEn2BH_ = std::vector(AHCalDetId::MaxDepth,0); + simHitLayEn1BH_ = std::vector(AHCalDetId::MaxDepth, 0); + simHitLayEn2BH_ = std::vector(AHCalDetId::MaxDepth, 0); iEvent.getByToken(tok_hitsBH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBH_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "PcalohitContainer for " << detectorBH_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); - analyzeSimHits(2, caloHits, zFrontBH_); + caloHits.clear(); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); + analyzeSimHits(2, caloHits, zFrontBH_); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " - << detectorBH_ << " !!!"; + edm::LogVerbatim("HGCSim") + << "PCaloHitContainer does not exist for " << detectorBH_ << " !!!"; #endif } } if (ifBeam_) { - simHitLayEnBeam_ = std::vector(idBeams_.size(),0); + simHitLayEnBeam_ = std::vector(idBeams_.size(), 0); iEvent.getByToken(tok_hitsBeam_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBeam_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "PcalohitContainer for " << detectorBeam_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); - analyzeSimHits(3, caloHits, 0.0); + caloHits.clear(); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); + analyzeSimHits(3, caloHits, 0.0); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " - << detectorBeam_ << " !!!"; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorBeam_ << " !!!"; #endif } } - //if (doTree_) tree_->Fill(); - }//if (doSimHits_) + // if (doTree_) tree_->Fill(); + } // if (doSimHits_) ////Store the info about the Passive hits if (doPassive_) { - hgcPassiveEEEnergy_.clear(); hgcPassiveFHEnergy_.clear(); - hgcPassiveBHEnergy_.clear(); hgcPassiveCMSEEnergy_.clear(); - hgcPassiveEEName_.clear(); hgcPassiveFHName_.clear(); - hgcPassiveBHName_.clear(); hgcPassiveCMSEName_.clear(); - hgcPassiveEEID_.clear(); hgcPassiveFHID_.clear(); - hgcPassiveBHID_.clear(); hgcPassiveCMSEID_.clear(); - - ///EE - edm::Handle hgcPHEE; - iEvent.getByToken(tok_hgcPHEE_,hgcPHEE); + hgcPassiveEEEnergy_.clear(); + hgcPassiveFHEnergy_.clear(); + hgcPassiveBHEnergy_.clear(); + hgcPassiveCMSEEnergy_.clear(); + hgcPassiveEEName_.clear(); + hgcPassiveFHName_.clear(); + hgcPassiveBHName_.clear(); + hgcPassiveCMSEName_.clear(); + hgcPassiveEEID_.clear(); + hgcPassiveFHID_.clear(); + hgcPassiveBHID_.clear(); + hgcPassiveCMSEID_.clear(); + + /// EE + edm::Handle hgcPHEE; + iEvent.getByToken(tok_hgcPHEE_, hgcPHEE); analyzePassiveHits(hgcPHEE, 1); - ///FH - edm::Handle hgcPHFH; - iEvent.getByToken(tok_hgcPHFH_,hgcPHFH); + /// FH + edm::Handle hgcPHFH; + iEvent.getByToken(tok_hgcPHFH_, hgcPHFH); analyzePassiveHits(hgcPHFH, 2); - ///BH - edm::Handle hgcPHBH; - iEvent.getByToken(tok_hgcPHBH_,hgcPHBH); + /// BH + edm::Handle hgcPHBH; + iEvent.getByToken(tok_hgcPHBH_, hgcPHBH); analyzePassiveHits(hgcPHBH, 3); - ///CMSE - edm::Handle hgcPHCMSE; - iEvent.getByToken(tok_hgcPHCMSE_,hgcPHCMSE); + /// CMSE + edm::Handle hgcPHCMSE; + iEvent.getByToken(tok_hgcPHCMSE_, hgcPHCMSE); analyzePassiveHits(hgcPHCMSE, 4); } if ((doSimHits_ || doPassive_) && (doTree_)) tree_->Fill(); - //Now the Digis + // Now the Digis if (doDigis_) { if (ifEE_) { edm::Handle theDigiContainers; iEvent.getByToken(tok_digiEE_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCDigiCintainer for " << detectorEE_ - << " with " << theDigiContainers->size() - << " element(s)"; + edm::LogVerbatim("HGCSim") + << "HGCDigiCintainer for " << detectorEE_ << " with " + << theDigiContainers->size() << " element(s)"; #endif - for (auto it : *theDigiContainers) { - HGCalDetId detId = (it.id()); - const HGCSample& hgcSample = it.sample(sampleIndex_); - uint16_t adc = hgcSample.data(); - analyzeDigi(0, detId, adc); - } + for (auto it : *theDigiContainers) { + HGCalDetId detId = (it.id()); + const HGCSample& hgcSample = it.sample(sampleIndex_); + uint16_t adc = hgcSample.data(); + analyzeDigi(0, detId, adc); + } } } if (ifFH_) { @@ -672,36 +708,36 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_digiFH_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCDigiContainer for " << detectorFH_ - << " with " << theDigiContainers->size() - << " element(s)"; + edm::LogVerbatim("HGCSim") + << "HGCDigiContainer for " << detectorFH_ << " with " + << theDigiContainers->size() << " element(s)"; #endif - for (auto it : *theDigiContainers) { - HGCalDetId detId = (it.id()); - const HGCSample& hgcSample = it.sample(sampleIndex_); - uint16_t adc = hgcSample.data(); - analyzeDigi(1, detId, adc); - } + for (auto it : *theDigiContainers) { + HGCalDetId detId = (it.id()); + const HGCSample& hgcSample = it.sample(sampleIndex_); + uint16_t adc = hgcSample.data(); + analyzeDigi(1, detId, adc); + } } } } - //The Rechits + // The Rechits if (doRecHits_) { edm::Handle theCaloHitContainers; if (ifEE_) { iEvent.getByToken(tok_hitrEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorEE_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "HGCRecHitCollection for " << detectorEE_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - analyzeRecHits(0, theCaloHitContainers); + analyzeRecHits(0, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " - << detectorEE_ << " !!!"; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorEE_ << " !!!"; #endif } } @@ -709,328 +745,330 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitrFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorFH_ - << " has " << theCaloHitContainers->size() - << " hits"; + edm::LogVerbatim("HGCSim") + << "HGCRecHitCollection for " << detectorFH_ << " has " + << theCaloHitContainers->size() << " hits"; #endif - analyzeRecHits(1, theCaloHitContainers); + analyzeRecHits(1, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " - << detectorFH_ << " !!!"; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorFH_ << " !!!"; #endif - }//else - }//if (ifFH_) - }//if (doRecHits_) - -}//void HGCalTBAnalyzer::analyze - -void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, - double zFront) { - - std::map map_hits, map_hitn; - std::map map_hitDepth; - std::map > map_hitLayer, map_hitCell; - double entot(0); - for (unsigned int i=0; i& hits, + double zFront) { + std::map map_hits, map_hitn; + std::map map_hitDepth; + std::map> map_hitLayer, map_hitCell; + double entot(0); + for (unsigned int i = 0; i < hits.size(); i++) { + double energy = hits[i].energy(); + double time = hits[i].time(); + uint32_t id = hits[i].id(); + entot += energy; + int subdet, zside, layer, sector, subsector(0), cell, depth(0), idx(0); if (type == 2) { - subdet = HcalDetId(id).subdet(); + subdet = HcalDetId(id).subdet(); if (subdet != HcalOther) continue; AHCalDetId hid(id); - layer = depth = hid.depth(); - zside = hid.zside(); - sector = hid.irow(); - cell = hid.icol(); - idx = ((hid.irowAbs()*100) + (hid.icolAbs())); + layer = depth = hid.depth(); + zside = hid.zside(); + sector = hid.irow(); + cell = hid.icol(); + idx = ((hid.irowAbs() * 100) + (hid.icolAbs())); } else if (type == 3) { HcalTestBeamNumbering::unpackIndex(id, subdet, layer, sector, cell); - depth = layer; zside = 1; - idx = subdet*1000 + layer; - layer = idx; + depth = layer; + zside = 1; + idx = subdet * 1000 + layer; + layer = idx; } else { HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector, - subsector, cell); - depth = hgcons_[type]->simToReco(cell,layer,sector,true).second; - idx = sector*1000+cell; + subsector, cell); + depth = hgcons_[type]->simToReco(cell, layer, sector, true).second; + idx = sector * 1000 + cell; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "SimHit:Hit[" << i << "] Id " << subdet - << ":" << zside << ":" << layer << ":" - << sector << ":" << subsector << ":" << cell - << ":" << depth << " Energy " << energy - << " Time " << time; + edm::LogVerbatim("HGCSim") + << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside << ":" + << layer << ":" << sector << ":" << subsector << ":" << cell << ":" + << depth << " Energy " << energy << " Time " << time; #endif if (map_hits.count(id) != 0) { map_hits[id] += energy; } else { - map_hits[id] = energy; + map_hits[id] = energy; } if (map_hitLayer.count(layer) != 0) { - double ee = energy + map_hitLayer[layer].second; - map_hitLayer[layer] = std::pair(id,ee); + double ee = energy + map_hitLayer[layer].second; + map_hitLayer[layer] = std::pair(id, ee); } else { - map_hitLayer[layer] = std::pair(id,energy); + map_hitLayer[layer] = std::pair(id, energy); } if (depth >= 0) { if (map_hitCell.count(idx) != 0) { - double ee = energy + map_hitCell[idx].second; - map_hitCell[idx] = std::pair(id,ee); + double ee = energy + map_hitCell[idx].second; + map_hitCell[idx] = std::pair(id, ee); } else { - map_hitCell[idx] = std::pair(id,energy); + map_hitCell[idx] = std::pair(id, energy); } if (map_hitDepth.count(depth) != 0) { - map_hitDepth[depth] += energy; + map_hitDepth[depth] += energy; } else { - map_hitDepth[depth] = energy; + map_hitDepth[depth] = energy; } - uint32_t idn = (type >= 2) ? id : - HGCalTestNumbering::packHexagonIndex(subdet, zside, depth, sector, - subsector, cell); + uint32_t idn = (type >= 2) + ? id + : HGCalTestNumbering::packHexagonIndex( + subdet, zside, depth, sector, subsector, cell); if (map_hitn.count(idn) != 0) { - map_hitn[idn] += energy; + map_hitn[idn] += energy; } else { - map_hitn[idn] = energy; + map_hitn[idn] = energy; } } - hSimHitT_[type]->Fill(time,energy); + hSimHitT_[type]->Fill(time, energy); } hSimHitEn_[type]->Fill(entot); - for (auto itr : map_hits) { + for (auto itr : map_hits) { hSimHitE_[type]->Fill(itr.second); } for (auto itr : map_hitLayer) { - int layer = itr.first - 1; - double energy = (itr.second).second; + int layer = itr.first - 1; + double energy = (itr.second).second; double zp(0); - if (type < 2) zp = hgcons_[type]->waferZ(layer+1,false); - else if (type == 2) zp = AHCalDetId((itr.second).first).getZ(); + if (type < 2) + zp = hgcons_[type]->waferZ(layer + 1, false); + else if (type == 2) + zp = AHCalDetId((itr.second).first).getZ(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " Z " << zp - << ":" << zp-zFront << " E " << energy; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer + 1 << " Z " << zp + << ":" << zp - zFront << " E " << energy; #endif if (type < 3) { - hSimHitLng_[type]->Fill(zp-zFront,energy); - hSimHitLng2_[type]->Fill(layer+1,energy); + hSimHitLng_[type]->Fill(zp - zFront, energy); + hSimHitLng2_[type]->Fill(layer + 1, energy); } if (type == 0) { if (layer < (int)(hSimHitLayEn1EE_.size())) { - simHitLayEn1EE_[layer] = energy; - hSimHitLayEn1EE_[layer]->Fill(energy); + simHitLayEn1EE_[layer] = energy; + hSimHitLayEn1EE_[layer]->Fill(energy); } } else if (type == 1) { if (layer < (int)(hSimHitLayEn1FH_.size())) { - simHitLayEn1FH_[layer] = energy; - hSimHitLayEn1FH_[layer]->Fill(energy); + simHitLayEn1FH_[layer] = energy; + hSimHitLayEn1FH_[layer]->Fill(energy); } } else if (type == 2) { if (layer < (int)(hSimHitLayEn1BH_.size())) { - simHitLayEn1BH_[layer] = energy; - hSimHitLayEn1BH_[layer]->Fill(energy); + simHitLayEn1BH_[layer] = energy; + hSimHitLayEn1BH_[layer]->Fill(energy); } } else { - for (unsigned int k=0; kFill(energy); - break; - } + for (unsigned int k = 0; k < idBeams_.size(); ++k) { + if (layer + 1 == idBeams_[k]) { + simHitLayEnBeam_[k] = energy; + hSimHitLayEnBeam_[k]->Fill(energy); + break; + } } } } for (auto itr : map_hitDepth) { - int layer = itr.first - 1; - double energy = itr.second; + int layer = itr.first - 1; + double energy = itr.second; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " " << energy; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer + 1 << " " << energy; #endif - hSimHitLng1_[type]->Fill(layer+1,energy); + hSimHitLng1_[type]->Fill(layer + 1, energy); if (type == 0) { if (layer < (int)(hSimHitLayEn2EE_.size())) { - simHitLayEn2EE_[layer] = energy; - hSimHitLayEn2EE_[layer]->Fill(energy); + simHitLayEn2EE_[layer] = energy; + hSimHitLayEn2EE_[layer]->Fill(energy); } } else if (type == 1) { if (layer < (int)(hSimHitLayEn2FH_.size())) { - simHitLayEn2FH_[layer] = energy; - hSimHitLayEn2FH_[layer]->Fill(energy); + simHitLayEn2FH_[layer] = energy; + hSimHitLayEn2FH_[layer]->Fill(energy); } } else if (type == 2) { if (layer < (int)(hSimHitLayEn2BH_.size())) { - simHitLayEn2BH_[layer] = energy; - hSimHitLayEn2BH_[layer]->Fill(energy); + simHitLayEn2BH_[layer] = energy; + hSimHitLayEn2BH_[layer]->Fill(energy); } } } if (type < 3) { for (auto itr : map_hitCell) { - uint32_t id = ((itr.second).first); - double energy = ((itr.second).second); - std::pair xy(0,0); + uint32_t id = ((itr.second).first); + double energy = ((itr.second).second); + std::pair xy(0, 0); double xx(0); if (type == 2) { - xy = AHCalDetId(id).getXY(); - xx = xy.first; + xy = AHCalDetId(id).getXY(); + xx = xy.first; } else { - int subdet, zside, layer, sector, subsector, cell; - HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector, - subsector, cell); - xy = hgcons_[type]->locateCell(cell,layer,sector,false); - double zp = hgcons_[type]->waferZ(layer,false); - xx = (zp < 0) ? -xy.first : xy.first; + int subdet, zside, layer, sector, subsector, cell; + HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector, + subsector, cell); + xy = hgcons_[type]->locateCell(cell, layer, sector, false); + double zp = hgcons_[type]->waferZ(layer, false); + xx = (zp < 0) ? -xy.first : xy.first; } - hSimHitLat_[type]->Fill(xx,xy.second,energy); + hSimHitLat_[type]->Fill(xx, xy.second, energy); } } for (auto itr : map_hitn) { - uint32_t id = itr.first; - double energy = itr.second; + uint32_t id = itr.first; + double energy = itr.second; if (type == 0) { - simHitCellIdEE_.push_back(id); simHitCellEnEE_.push_back(energy); + simHitCellIdEE_.push_back(id); + simHitCellEnEE_.push_back(energy); } else if (type == 1) { - simHitCellIdFH_.push_back(id); simHitCellEnFH_.push_back(energy); + simHitCellIdFH_.push_back(id); + simHitCellEnFH_.push_back(energy); } else if (type == 2) { - simHitCellIdBH_.push_back(id); simHitCellEnBH_.push_back(energy); + simHitCellIdBH_.push_back(id); + simHitCellEnBH_.push_back(energy); } else if (type == 3) { - simHitCellIdBeam_.push_back(id); simHitCellEnBeam_.push_back(energy); + simHitCellIdBeam_.push_back(id); + simHitCellEnBeam_.push_back(energy); } } } -void HGCalTBAnalyzer::analyzeSimTracks(edm::Handle const& SimTk, - edm::Handle const& SimVtx) { - +void HGCalTBAnalyzer::analyzeSimTracks( + edm::Handle const& SimTk, + edm::Handle const& SimVtx) { xBeam_ = yBeam_ = zBeam_ = pBeam_ = -1000000; int vertIndex(-1); for (auto simTrkItr : *SimTk) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Track " << simTrkItr.trackId() << " Vertex " - << simTrkItr.vertIndex() << " Type " - << simTrkItr.type() << " Charge " - << simTrkItr.charge() << " momentum " - << simTrkItr.momentum() << " " - << simTrkItr.momentum().P(); + edm::LogVerbatim("HGCSim") + << "Track " << simTrkItr.trackId() << " Vertex " + << simTrkItr.vertIndex() << " Type " << simTrkItr.type() << " Charge " + << simTrkItr.charge() << " momentum " << simTrkItr.momentum() << " " + << simTrkItr.momentum().P(); #endif if (vertIndex == -1) { vertIndex = simTrkItr.vertIndex(); - pBeam_ = simTrkItr.momentum().P(); + pBeam_ = simTrkItr.momentum().P(); } } if (vertIndex != -1 && vertIndex < (int)SimVtx->size()) { - edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); - for (int iv=0; ivbegin(); + for (int iv = 0; iv < vertIndex; iv++) simVtxItr++; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Vertex " << vertIndex << " position " - << simVtxItr->position(); + edm::LogVerbatim("HGCSim") + << "Vertex " << vertIndex << " position " << simVtxItr->position(); #endif xBeam_ = simVtxItr->position().X(); yBeam_ = simVtxItr->position().Y(); zBeam_ = simVtxItr->position().Z(); } - } -template -void HGCalTBAnalyzer::analyzeDigi (int type, const T1& detId, uint16_t adc) { - +template +void HGCalTBAnalyzer::analyzeDigi(int type, const T1& detId, uint16_t adc) { DetId id1 = DetId(detId.rawId()); GlobalPoint global = hgeom_[type]->getPosition(id1); - hDigiOcc_[type]->Fill(global.x(),global.y()); + hDigiOcc_[type]->Fill(global.x(), global.y()); hDigiLng_[type]->Fill(global.z()); hDigiADC_[type]->Fill(adc); } -void HGCalTBAnalyzer::analyzeRecHits (int type, - edm::Handle& hits) { - - std::map map_hitLayer; - std::map > map_hitCell; +void HGCalTBAnalyzer::analyzeRecHits(int type, + edm::Handle& hits) { + std::map map_hitLayer; + std::map> map_hitCell; for (auto it : *hits) { - DetId detId = it.id(); + DetId detId = it.id(); GlobalPoint global = hgeom_[type]->getPosition(detId); - double energy = it.energy(); - int layer = HGCalDetId(detId).layer(); - int cell = HGCalDetId(detId).cell(); - hRecHitOcc_[type]->Fill(global.x(),global.y(),energy); + double energy = it.energy(); + int layer = HGCalDetId(detId).layer(); + int cell = HGCalDetId(detId).cell(); + hRecHitOcc_[type]->Fill(global.x(), global.y(), energy); hRecHitE_[type]->Fill(energy); if (map_hitLayer.count(layer) != 0) { map_hitLayer[layer] += energy; } else { - map_hitLayer[layer] = energy; + map_hitLayer[layer] = energy; } if (map_hitCell.count(cell) != 0) { - double ee = energy + map_hitCell[cell].second; - map_hitCell[cell] = std::pair(detId,ee); + double ee = energy + map_hitCell[cell].second; + map_hitCell[cell] = std::pair(detId, ee); } else { - map_hitCell[cell] = std::pair(detId,energy); + map_hitCell[cell] = std::pair(detId, energy); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "RecHit: " << layer << " " << global.x() - << " " << global.y() << " " << global.z() - << " " << energy; + edm::LogVerbatim("HGCSim") + << "RecHit: " << layer << " " << global.x() << " " << global.y() << " " + << global.z() << " " << energy; #endif } for (auto itr : map_hitLayer) { - int layer = itr.first; - double energy = itr.second; - double zp = hgcons_[type]->waferZ(layer,true); + int layer = itr.first; + double energy = itr.second; + double zp = hgcons_[type]->waferZ(layer, true); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer << " " << zp - << " " << energy; + edm::LogVerbatim("HGCSim") + << "SimHit:Layer " << layer << " " << zp << " " << energy; #endif - hRecHitLng_[type]->Fill(zp,energy); - hRecHitLng1_[type]->Fill(layer,energy); + hRecHitLng_[type]->Fill(zp, energy); + hRecHitLng1_[type]->Fill(layer, energy); } for (auto itr : map_hitCell) { - DetId detId = ((itr.second).first); - double energy = ((itr.second).second); + DetId detId = ((itr.second).first); + double energy = ((itr.second).second); GlobalPoint global = hgeom_[type]->getPosition(detId); - hRecHitLat_[type]->Fill(global.x(),global.y(),energy); + hRecHitLat_[type]->Fill(global.x(), global.y(), energy); } } -void HGCalTBAnalyzer::analyzePassiveHits (edm::Handleconst& hgcPH, int subdet) { - +void HGCalTBAnalyzer::analyzePassiveHits( + edm::Handle const& hgcPH, int subdet) { for (auto v : *hgcPH) { - double energy = v.energy(); - std::string name = v.vname(); - unsigned int id = v.id(); + double energy = v.energy(); + std::string name = v.vname(); + unsigned int id = v.id(); #ifdef EDM_ML_DEBUG - double time = v.time(); + double time = v.time(); edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::analyzePassiveHits:Energy:" - << "Time:Name:Id : " << energy << ":" << time - << ":" << name << ":" << id; -#endif + << "Time:Name:Id : " << energy << ":" << time + << ":" << name << ":" << id; +#endif - if (subdet==1) { + if (subdet == 1) { hgcPassiveEEEnergy_.push_back(energy); hgcPassiveEEName_.push_back(name); hgcPassiveEEID_.push_back(id); - } else if (subdet==2) { + } else if (subdet == 2) { hgcPassiveFHEnergy_.push_back(energy); hgcPassiveFHName_.push_back(name); hgcPassiveFHID_.push_back(id); - } else if (subdet==3) { + } else if (subdet == 3) { hgcPassiveBHEnergy_.push_back(energy); hgcPassiveBHName_.push_back(name); hgcPassiveBHID_.push_back(id); - } else if (subdet==4) { + } else if (subdet == 4) { hgcPassiveCMSEEnergy_.push_back(energy); hgcPassiveCMSEName_.push_back(name); hgcPassiveCMSEID_.push_back(id); } } } - -//define this as a plug-in + +// define this as a plug-in DEFINE_FWK_MODULE(HGCalTBAnalyzer); diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc index 86ea0f57a0b8c..96a2e324d6e5a 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc @@ -2,8 +2,9 @@ // // Package: HGCalTestBeam/HGCalTBCheckGunPostion // Class: HGCalTBCheckGunPostion -// -/**\class HGCalTBCheckGunPostion HGCalTBCheckGunPostion.cc Geometry/HGCalTestBeam/plugins/HGCalTBCheckGunPostion.cc +// +/**\class HGCalTBCheckGunPostion HGCalTBCheckGunPostion.cc + Geometry/HGCalTestBeam/plugins/HGCalTBCheckGunPostion.cc Description: [one line class summary] @@ -16,22 +17,21 @@ // // - // system include files #include // user include files +#include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/stream/EDFilter.h" -#include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/StreamID.h" -#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" //#define EDM_ML_DEBUG @@ -40,28 +40,29 @@ // class HGCalTBCheckGunPostion : public edm::stream::EDFilter<> { - -public: + public: explicit HGCalTBCheckGunPostion(const edm::ParameterSet&); ~HGCalTBCheckGunPostion() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); -private: + private: void beginStream(edm::StreamID) override {} bool filter(edm::Event&, const edm::EventSetup&) override; void endStream() override {} void beginRun(edm::Run const&, edm::EventSetup const&) override {} void endRun(edm::Run const&, edm::EventSetup const&) override {} - void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {} - void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {} + void beginLuminosityBlock(edm::LuminosityBlock const&, + edm::EventSetup const&) override {} + void endLuminosityBlock(edm::LuminosityBlock const&, + edm::EventSetup const&) override {} // ----------member data --------------------------- - edm::EDGetTokenT hepMCproductLabel_; - bool verbosity_, method2_; - double tan30deg_, hexwidth_, hexside_; + edm::EDGetTokenT hepMCproductLabel_; + bool verbosity_, method2_; + double tan30deg_, hexwidth_, hexside_; }; // @@ -75,91 +76,96 @@ class HGCalTBCheckGunPostion : public edm::stream::EDFilter<> { // // constructors and destructor // -HGCalTBCheckGunPostion::HGCalTBCheckGunPostion(const edm::ParameterSet& iConfig) { - //now do what ever initialization is needed +HGCalTBCheckGunPostion::HGCalTBCheckGunPostion( + const edm::ParameterSet& iConfig) { + // now do what ever initialization is needed edm::InputTag tmp0 = iConfig.getParameter("HepMCProductLabel"); - verbosity_ = iConfig.getUntrackedParameter("Verbosity",false); - method2_ = iConfig.getUntrackedParameter("Method2",false); + verbosity_ = iConfig.getUntrackedParameter("Verbosity", false); + method2_ = iConfig.getUntrackedParameter("Method2", false); hepMCproductLabel_ = consumes(tmp0); - - //hexside = 7; //cm - check it + + // hexside = 7; //cm - check it tan30deg_ = 0.5773502693; hexwidth_ = 6.185; - hexside_ = 2.0 * hexwidth_ * tan30deg_; + hexside_ = 2.0 * hexwidth_ * tan30deg_; } -HGCalTBCheckGunPostion::~HGCalTBCheckGunPostion() { } +HGCalTBCheckGunPostion::~HGCalTBCheckGunPostion() {} // // member functions // // ------------ method called on each new Event ------------ -bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, - const edm::EventSetup& iSetup) { +bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::Handle hepmc; iEvent.getByToken(hepMCproductLabel_, hepmc); #ifdef DebugLog - if (verbosity_) + if (verbosity_) edm::LogVerbatim("HGCSim") << "isHandle valid: " << isHandle valid; #endif double x(0), y(0); - + if (hepmc.isValid()) { const HepMC::GenEvent* Evt = hepmc->GetEvent(); - + #ifdef DebugLog - if (verbosity_) + if (verbosity_) edm::LogVerbatim("HGCSim") << "vertex " << Evt->vertices_size(); #endif for (HepMC::GenEvent::vertex_const_iterator p = Evt->vertices_begin(); - p != Evt->vertices_end(); ++p) { - x = (*p)->position().x()/10.; // in cm - y = (*p)->position().y()/10.; // in cm + p != Evt->vertices_end(); ++p) { + x = (*p)->position().x() / 10.; // in cm + y = (*p)->position().y() / 10.; // in cm #ifdef DebugLog - z = (*p)->position().z()/10.; // in cm - if (verbosity_) - edm::LogVerbatim("HGCSim") << " x: " << (*p)->position().x() << ":" - << x << " y: " << (*p)->position().y() - <<":" << y << " z: " << (*p)->position().z() - << ":" << z; + z = (*p)->position().z() / 10.; // in cm + if (verbosity_) + edm::LogVerbatim("HGCSim") + << " x: " << (*p)->position().x() << ":" << x + << " y: " << (*p)->position().y() << ":" << y + << " z: " << (*p)->position().z() << ":" << z; #endif } - }//if (genEventInfoHandle.isValid()) + } // if (genEventInfoHandle.isValid()) - bool flag(false); + bool flag(false); if (method2_) { - bool cond1 = y==0 && x >=(-hexside_ * sqrt(3)/2.); - bool cond2 = ((y+hexside_) >= -x/sqrt(3)) && (y<0&&x<0); - bool cond3 = (y*sqrt(3) >= (x - hexside_*sqrt(3))) && (y<0 && x>0); - bool cond4 = y==0 && x <=(hexside_ * sqrt(3)/2.); - bool cond5 = (-y*sqrt(3) >= (x - hexside_*sqrt(3))) && (y>0&&x>0); - bool cond6 = ((y-hexside_) <= x/sqrt(3)) && (y>0&&x<0); + bool cond1 = y == 0 && x >= (-hexside_ * sqrt(3) / 2.); + bool cond2 = ((y + hexside_) >= -x / sqrt(3)) && (y < 0 && x < 0); + bool cond3 = (y * sqrt(3) >= (x - hexside_ * sqrt(3))) && (y < 0 && x > 0); + bool cond4 = y == 0 && x <= (hexside_ * sqrt(3) / 2.); + bool cond5 = (-y * sqrt(3) >= (x - hexside_ * sqrt(3))) && (y > 0 && x > 0); + bool cond6 = ((y - hexside_) <= x / sqrt(3)) && (y > 0 && x < 0); flag = cond1 || cond2 || cond3 || cond4 || cond5 || cond6; } else { double absx = std::abs(x); double absy = std::abs(y); if (absx <= hexwidth_ && absy <= hexside_) { - if (absy <= hexwidth_*tan30deg_ || - absx <= (2.*hexwidth_ - absy/tan30deg_)) flag = true; + if (absy <= hexwidth_ * tan30deg_ || + absx <= (2. * hexwidth_ - absy / tan30deg_)) + flag = true; } } - + #ifdef DebugLog - if (verbosity_) - edm::LogVerbatim("HGCSim") << "Selection Flag " << flag; + if (verbosity_) edm::LogVerbatim("HGCSim") << "Selection Flag " << flag; #endif return flag; } - -// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void HGCalTBCheckGunPostion::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - //The following says we do not know what parameters are allowed so do no validation - // Please change this to state exactly what you do use, even if it is no parameters + +// ------------ method fills 'descriptions' with the allowed parameters for the +// module ------------ +void HGCalTBCheckGunPostion::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { + // The following says we do not know what parameters are allowed so do no + // validation + // Please change this to state exactly what you do use, even if it is no + // parameters edm::ParameterSetDescription desc; desc.setUnknown(); descriptions.addDefault(desc); } -//define this as a plug-in +// define this as a plug-in DEFINE_FWK_MODULE(HGCalTBCheckGunPostion); diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc index 1cbf82d0ccec5..8f3de50fba8b8 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc @@ -1,13 +1,13 @@ +#include "CommonTools/UtilAlgos/interface/TFileService.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/Exception.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "SimG4Core/Watcher/interface/SimWatcher.h" -#include "SimG4Core/Notification/interface/Observer.h" #include "SimG4Core/Notification/interface/BeginOfTrack.h" #include "SimG4Core/Notification/interface/EndOfTrack.h" +#include "SimG4Core/Notification/interface/Observer.h" +#include "SimG4Core/Watcher/interface/SimWatcher.h" #include "G4LogicalVolumeStore.hh" #include "G4Step.hh" @@ -21,120 +21,114 @@ //#define EDM_ML_DEBUG -class HGCalTBMB : public SimWatcher, +class HGCalTBMB : public SimWatcher, public Observer, public Observer, public Observer { - -public: - + public: HGCalTBMB(const edm::ParameterSet&); ~HGCalTBMB() override; - -private: - HGCalTBMB(const HGCalTBMB&) = delete; // stop default - const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... - + private: + HGCalTBMB(const HGCalTBMB&) = delete; // stop default + const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... + void update(const BeginOfTrack*) override; void update(const G4Step*) override; void update(const EndOfTrack*) override; bool stopAfter(const G4Step*); - int findVolume(const G4VTouchable* touch, bool stop) const; - - std::vector listNames_; - std::string stopName_; - double stopZ_; - unsigned int nList_; - std::vector radLen_, intLen_, stepLen_; - std::vector me100_, me200_, me300_; + int findVolume(const G4VTouchable* touch, bool stop) const; + + std::vector listNames_; + std::string stopName_; + double stopZ_; + unsigned int nList_; + std::vector radLen_, intLen_, stepLen_; + std::vector me100_, me200_, me300_; }; HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { - edm::ParameterSet m_p = p.getParameter("HGCalTBMB"); - listNames_ = m_p.getParameter >("DetectorNames"); - stopName_ = m_p.getParameter("StopName"); - stopZ_ = m_p.getParameter("MaximumZ"); - nList_ = listNames_.size(); - edm::LogVerbatim("HGCSim") << "HGCalTBMB initialized for " << nList_ - << " volumes"; - for (unsigned int k=0; k >("DetectorNames"); + stopName_ = m_p.getParameter("StopName"); + stopZ_ = m_p.getParameter("MaximumZ"); + nList_ = listNames_.size(); + edm::LogVerbatim("HGCSim") + << "HGCalTBMB initialized for " << nList_ << " volumes"; + for (unsigned int k = 0; k < nList_; ++k) edm::LogVerbatim("HGCSim") << " [" << k << "] " << listNames_[k]; - edm::LogVerbatim("HGCSim") << "Stop after " << stopZ_ - << " or reaching volume " << stopName_; + edm::LogVerbatim("HGCSim") + << "Stop after " << stopZ_ << " or reaching volume " << stopName_; edm::Service tfile; - if ( !tfile.isAvailable() ) + if (!tfile.isAvailable()) throw cms::Exception("BadConfig") << "TFileService unavailable: " << "please add it to config file"; - char name[20], title[80]; + char name[20], title[80]; TH1D* hist; - for (unsigned int i=0; i<=nList_; i++) { + for (unsigned int i = 0; i <= nList_; i++) { std::string named = (i == nList_) ? "Total" : listNames_[i]; sprintf(name, "RadL%d", i); sprintf(title, "MB(X0) for (%s)", named.c_str()); - hist = tfile->make(name,title,1000,0.0,100.0); + hist = tfile->make(name, title, 1000, 0.0, 100.0); hist->Sumw2(true); me100_.push_back(hist); sprintf(name, "IntL%d", i); sprintf(title, "MB(L0) for (%s)", named.c_str()); - hist = tfile->make(name,title,1000,0.0,10.0); + hist = tfile->make(name, title, 1000, 0.0, 10.0); hist->Sumw2(true); me200_.push_back(hist); sprintf(name, "StepL%d", i); sprintf(title, "MB(Step) for (%s)", named.c_str()); - hist = tfile->make(name,title,1000,0.0,50000.0); + hist = tfile->make(name, title, 1000, 0.0, 50000.0); hist->Sumw2(true); me300_.push_back(hist); } edm::LogVerbatim("HGCSim") << "HGCalTBMB: Booking user histos done ==="; } -HGCalTBMB::~HGCalTBMB() { } +HGCalTBMB::~HGCalTBMB() {} void HGCalTBMB::update(const BeginOfTrack* trk) { - - radLen_ = std::vector(nList_+1,0); - intLen_ = std::vector(nList_+1,0); - stepLen_ = std::vector(nList_+1,0); + radLen_ = std::vector(nList_ + 1, 0); + intLen_ = std::vector(nList_ + 1, 0); + stepLen_ = std::vector(nList_ + 1, 0); #ifdef EDM_ML_DEBUG - const G4Track * aTrack = (*trk)(); // recover G4 pointer if wanted - const G4ThreeVector& mom = aTrack->GetMomentum() ; - double theEnergy = aTrack->GetTotalEnergy(); - int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding()); - edm::LogVerbatim("HGCSim") << "MaterialBudgetHcalHistos: Track " - << aTrack->GetTrackID() << " Code " << theID - << " Energy " << theEnergy/CLHEP::GeV - << " GeV; Momentum " << mom ; + const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted + const G4ThreeVector& mom = aTrack->GetMomentum(); + double theEnergy = aTrack->GetTotalEnergy(); + int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding()); + edm::LogVerbatim("HGCSim") + << "MaterialBudgetHcalHistos: Track " << aTrack->GetTrackID() << " Code " + << theID << " Energy " << theEnergy / CLHEP::GeV << " GeV; Momentum " + << mom; #endif } - -void HGCalTBMB::update(const G4Step* aStep) { - G4Material * material = aStep->GetPreStepPoint()->GetMaterial(); - double step = aStep->GetStepLength(); - double radl = material->GetRadlen(); - double intl = material->GetNuclearInterLength(); +void HGCalTBMB::update(const G4Step* aStep) { + G4Material* material = aStep->GetPreStepPoint()->GetMaterial(); + double step = aStep->GetStepLength(); + double radl = material->GetRadlen(); + double intl = material->GetNuclearInterLength(); const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); - int indx = findVolume(touch,false); + int indx = findVolume(touch, false); if (indx >= 0) { stepLen_[indx] += step; - radLen_[indx] += (step/radl); - intLen_[indx] += (step/intl); + radLen_[indx] += (step / radl); + intLen_[indx] += (step / intl); } stepLen_[nList_] += step; - radLen_[nList_] += (step/radl); - intLen_[nList_] += (step/intl); + radLen_[nList_] += (step / radl); + intLen_[nList_] += (step / intl); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalTBMB::Step in " - << touch->GetVolume(0)->GetLogicalVolume()->GetName() - << " Index " << indx <<" Step " << step - << " RadL " << step/radl << " IntL " << step/intl; + edm::LogVerbatim("HGCSim") + << "HGCalTBMB::Step in " + << touch->GetVolume(0)->GetLogicalVolume()->GetName() << " Index " << indx + << " Step " << step << " RadL " << step / radl << " IntL " << step / intl; #endif if (stopAfter(aStep)) { @@ -144,52 +138,50 @@ void HGCalTBMB::update(const G4Step* aStep) { } void HGCalTBMB::update(const EndOfTrack* trk) { - - for (unsigned int ii=0; ii<=nList_; ++ii) { + for (unsigned int ii = 0; ii <= nList_; ++ii) { me100_[ii]->Fill(radLen_[ii]); me200_[ii]->Fill(intLen_[ii]); me300_[ii]->Fill(stepLen_[ii]); #ifdef EDM_ML_DEBUG std::string name("Total"); if (ii < nList_) name = listNames_[ii]; - edm::LogVerbatim("HGCSim") << "HGCalTBMB::Volume[" << ii << "]: " << name - << " == Step " << stepLen_[ii] << " RadL " - << radLen_[ii] << " IntL " << intLen_[ii]; + edm::LogVerbatim("HGCSim") + << "HGCalTBMB::Volume[" << ii << "]: " << name << " == Step " + << stepLen_[ii] << " RadL " << radLen_[ii] << " IntL " << intLen_[ii]; #endif } } bool HGCalTBMB::stopAfter(const G4Step* aStep) { - - bool flag(false); + bool flag(false); const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); - G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition(); - if (aStep->GetPostStepPoint() != nullptr) + G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition(); + if (aStep->GetPostStepPoint() != nullptr) hitPoint = aStep->GetPostStepPoint()->GetPosition(); - double zz = hitPoint.z(); + double zz = hitPoint.z(); - if ((findVolume(touch,true) == 0) || (zz > stopZ_)) flag = true; + if ((findVolume(touch, true) == 0) || (zz > stopZ_)) flag = true; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << " HGCalTBMB::Name " - << touch->GetVolume(0)->GetName() << " z " - << zz << " Flag" << flag; + edm::LogVerbatim("HGCSim") + << " HGCalTBMB::Name " << touch->GetVolume(0)->GetName() << " z " << zz + << " Flag" << flag; #endif return flag; } int HGCalTBMB::findVolume(const G4VTouchable* touch, bool stop) const { - - int ivol =-1; - int level = (touch->GetHistoryDepth())+1; + int ivol = -1; + int level = (touch->GetHistoryDepth()) + 1; for (int ii = 0; ii < level; ii++) { std::string name = touch->GetVolume(ii)->GetName(); if (stop) { - if (strcmp(name.c_str(),stopName_.c_str()) == 0) ivol = 0; + if (strcmp(name.c_str(), stopName_.c_str()) == 0) ivol = 0; } else { - for (unsigned int k=0; k= 0) break; @@ -201,5 +193,4 @@ int HGCalTBMB::findVolume(const G4VTouchable* touch, bool stop) const { #include "FWCore/PluginManager/interface/ModuleDef.h" #include "SimG4Core/Watcher/interface/SimWatcherFactory.h" -DEFINE_SIMWATCHER (HGCalTBMB); - +DEFINE_SIMWATCHER(HGCalTBMB); diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTimingAnalyzer.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTimingAnalyzer.cc index 6a1e04a3c06fe..c309766bf90e0 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTimingAnalyzer.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTimingAnalyzer.cc @@ -1,10 +1,10 @@ // system include files -#include -#include #include -#include +#include #include +#include #include +#include // user include files #include "CommonTools/UtilAlgos/interface/TFileService.h" @@ -12,14 +12,14 @@ #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -43,307 +43,310 @@ //#define EDM_ML_DEBUG -class HGCalTimingAnalyzer : public edm::one::EDAnalyzer { - -public: +class HGCalTimingAnalyzer + : public edm::one::EDAnalyzer { + public: explicit HGCalTimingAnalyzer(edm::ParameterSet const&); ~HGCalTimingAnalyzer() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); -private: - void beginJob() override ; + private: + void beginJob() override; void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override {} void analyze(edm::Event const&, edm::EventSetup const&) override; void analyzeSimHits(int type, std::vector const& hits); - void analyzeSimTracks(edm::Handle const& SimTk, - edm::Handle const& SimVtx); + void analyzeSimTracks(edm::Handle const& SimTk, + edm::Handle const& SimVtx); - edm::Service fs_; - const HGCalDDDConstants *hgcons_; - bool doTree_, groupHits_; - std::string detectorEE_, detectorBeam_; - double timeUnit_; - std::vector idBeams_; - edm::EDGetTokenT tok_hitsEE_, tok_hitsBeam_; - edm::EDGetTokenT tok_simTk_; + edm::Service fs_; + const HGCalDDDConstants* hgcons_; + bool doTree_, groupHits_; + std::string detectorEE_, detectorBeam_; + double timeUnit_; + std::vector idBeams_; + edm::EDGetTokenT tok_hitsEE_, tok_hitsBeam_; + edm::EDGetTokenT tok_simTk_; edm::EDGetTokenT tok_simVtx_; - edm::EDGetTokenT tok_hepMC_; - TTree *tree_; - std::vector simHitCellIdEE_, simHitCellIdBeam_; - std::vector simHitCellEnEE_, simHitCellEnBeam_; - std::vector simHitCellTmEE_, simHitCellTmBeam_; - double xBeam_, yBeam_, zBeam_, pBeam_; + edm::EDGetTokenT tok_hepMC_; + TTree* tree_; + std::vector simHitCellIdEE_, simHitCellIdBeam_; + std::vector simHitCellEnEE_, simHitCellEnBeam_; + std::vector simHitCellTmEE_, simHitCellTmBeam_; + double xBeam_, yBeam_, zBeam_, pBeam_; }; HGCalTimingAnalyzer::HGCalTimingAnalyzer(const edm::ParameterSet& iConfig) { - usesResource("TFileService"); - //now do whatever initialization is needed - detectorEE_ = iConfig.getParameter("DetectorEE"); - detectorBeam_= iConfig.getParameter("DetectorBeam"); + // now do whatever initialization is needed + detectorEE_ = iConfig.getParameter("DetectorEE"); + detectorBeam_ = iConfig.getParameter("DetectorBeam"); // Group hits (if groupHits_ = true) if hits come within timeUnit_ - groupHits_ = iConfig.getParameter("GroupHits"); - timeUnit_ = iConfig.getParameter("TimeUnit"); + groupHits_ = iConfig.getParameter("GroupHits"); + timeUnit_ = iConfig.getParameter("TimeUnit"); // Only look into the beam counters with ID's as in idBeams_ - idBeams_ = iConfig.getParameter>("IDBeams"); - doTree_ = iConfig.getUntrackedParameter("DoTree",false); + idBeams_ = iConfig.getParameter>("IDBeams"); + doTree_ = iConfig.getUntrackedParameter("DoTree", false); if (!groupHits_) timeUnit_ = 0.000001; #ifdef EDM_ML_DEBUG std::cout << "HGCalTimingAnalyzer:: Group Hits " << groupHits_ << " in " - << timeUnit_ << " IdBeam " << idBeams_.size() << ":"; + << timeUnit_ << " IdBeam " << idBeams_.size() << ":"; for (const auto& id : idBeams_) std::cout << " " << id; std::cout << std::endl; #endif if (idBeams_.empty()) idBeams_.push_back(1001); edm::InputTag tmp0 = iConfig.getParameter("GeneratorSrc"); - tok_hepMC_ = consumes(tmp0); + tok_hepMC_ = consumes(tmp0); #ifdef EDM_ML_DEBUG std::cout << "HGCalTimingAnalyzer:: GeneratorSource = " << tmp0 << std::endl; #endif - tok_simTk_ = consumes(edm::InputTag("g4SimHits")); - tok_simVtx_ = consumes(edm::InputTag("g4SimHits")); - std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); - tok_hitsEE_ = consumes(edm::InputTag("g4SimHits",tmp1)); + tok_simTk_ = consumes(edm::InputTag("g4SimHits")); + tok_simVtx_ = consumes(edm::InputTag("g4SimHits")); + std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); + tok_hitsEE_ = + consumes(edm::InputTag("g4SimHits", tmp1)); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTimingAnalyzer:: Detector " << detectorEE_ - << " with tags " << tmp1 << std::endl; + std::cout << "HGCalTimingAnalyzer:: Detector " << detectorEE_ << " with tags " + << tmp1 << std::endl; #endif - tmp1 = iConfig.getParameter("CaloHitSrcBeam"); - tok_hitsBeam_= consumes(edm::InputTag("g4SimHits",tmp1)); + tmp1 = iConfig.getParameter("CaloHitSrcBeam"); + tok_hitsBeam_ = + consumes(edm::InputTag("g4SimHits", tmp1)); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTimingAnalyzer:: Detector " << detectorBeam_ - << " with tags " << tmp1 << std::endl; + std::cout << "HGCalTimingAnalyzer:: Detector " << detectorBeam_ + << " with tags " << tmp1 << std::endl; #endif } HGCalTimingAnalyzer::~HGCalTimingAnalyzer() {} -void HGCalTimingAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void HGCalTimingAnalyzer::fillDescriptions( + edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("DetectorEE","HGCalEESensitive"); - desc.add("DetectorBeam","HcalTB06BeamDetector"); - desc.add("GroupHits",false); - desc.add("TimeUnit",0.001); - std::vector ids = {1001,1002,1003,1004,1005}; - desc.add>("IDBeams",ids); - desc.addUntracked("DoTree",true); - desc.add("GeneratorSrc",edm::InputTag("generatorSmeared")); - desc.add("CaloHitSrcEE","HGCHitsEE"); - desc.add("CaloHitSrcBeam","HcalTB06BeamHits"); - descriptions.add("HGCalTimingAnalyzer",desc); + desc.add("DetectorEE", "HGCalEESensitive"); + desc.add("DetectorBeam", "HcalTB06BeamDetector"); + desc.add("GroupHits", false); + desc.add("TimeUnit", 0.001); + std::vector ids = {1001, 1002, 1003, 1004, 1005}; + desc.add>("IDBeams", ids); + desc.addUntracked("DoTree", true); + desc.add("GeneratorSrc", edm::InputTag("generatorSmeared")); + desc.add("CaloHitSrcEE", "HGCHitsEE"); + desc.add("CaloHitSrcBeam", "HcalTB06BeamHits"); + descriptions.add("HGCalTimingAnalyzer", desc); } void HGCalTimingAnalyzer::beginJob() { - std::string det(detectorEE_); + std::string det(detectorEE_); if (doTree_) { - tree_ = fs_->make("HGCTB","SimHitEnergy"); - tree_->Branch("xBeam", &xBeam_, "xBeam/D"); - tree_->Branch("yBeam", &yBeam_, "yBeam/D"); - tree_->Branch("zBeam", &zBeam_, "zBeam/D"); - tree_->Branch("pBeam", &pBeam_, "pBeam/D"); - tree_->Branch("simHitCellIdEE_", &simHitCellIdEE_); - tree_->Branch("simHitCellEnEE_", &simHitCellEnEE_); - tree_->Branch("simHitCellTmEE_", &simHitCellTmEE_); + tree_ = fs_->make("HGCTB", "SimHitEnergy"); + tree_->Branch("xBeam", &xBeam_, "xBeam/D"); + tree_->Branch("yBeam", &yBeam_, "yBeam/D"); + tree_->Branch("zBeam", &zBeam_, "zBeam/D"); + tree_->Branch("pBeam", &pBeam_, "pBeam/D"); + tree_->Branch("simHitCellIdEE_", &simHitCellIdEE_); + tree_->Branch("simHitCellEnEE_", &simHitCellEnEE_); + tree_->Branch("simHitCellTmEE_", &simHitCellTmEE_); tree_->Branch("simHitCellIdBeam_", &simHitCellIdBeam_); tree_->Branch("simHitCellEnBeam_", &simHitCellEnBeam_); tree_->Branch("simHitCellTmBeam_", &simHitCellTmBeam_); } } -void HGCalTimingAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { - edm::ESHandle pHGDC; +void HGCalTimingAnalyzer::beginRun(const edm::Run&, + const edm::EventSetup& iSetup) { + edm::ESHandle pHGDC; iSetup.get().get(detectorEE_, pHGDC); hgcons_ = &(*pHGDC); - + #ifdef EDM_ML_DEBUG std::cout << "HGCalTimingAnalyzer::" << detectorEE_ << " defined with " - << hgcons_->layers(false) << " layers" << std::endl; + << hgcons_->layers(false) << " layers" << std::endl; #endif - } -void HGCalTimingAnalyzer::analyze(const edm::Event& iEvent, - const edm::EventSetup& iSetup) { - +void HGCalTimingAnalyzer::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup) { #ifdef EDM_ML_DEBUG - //Generator input + // Generator input edm::Handle evtMC; - iEvent.getByToken(tok_hepMC_,evtMC); + iEvent.getByToken(tok_hepMC_, evtMC); if (!evtMC.isValid()) { edm::LogWarning("HGCal") << "no HepMCProduct found"; - } else { - const HepMC::GenEvent * myGenEvent = evtMC->GetEvent(); + } else { + const HepMC::GenEvent* myGenEvent = evtMC->GetEvent(); unsigned int k(0); - for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); + for (HepMC::GenEvent::particle_const_iterator p = + myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p, ++k) { - std::cout << "Particle[" << k << "] with p " << (*p)->momentum().rho() - << " theta " << (*p)->momentum().theta() << " phi " - << (*p)->momentum().phi() << std::endl; + std::cout << "Particle[" << k << "] with p " << (*p)->momentum().rho() + << " theta " << (*p)->momentum().theta() << " phi " + << (*p)->momentum().phi() << std::endl; } } #endif - //Now the Simhits - edm::Handle SimTk; + // Now the Simhits + edm::Handle SimTk; iEvent.getByToken(tok_simTk_, SimTk); edm::Handle SimVtx; iEvent.getByToken(tok_simVtx_, SimVtx); analyzeSimTracks(SimTk, SimVtx); - simHitCellIdEE_.clear(); simHitCellIdBeam_.clear(); - simHitCellEnEE_.clear(); simHitCellEnBeam_.clear(); - simHitCellTmEE_.clear(); simHitCellTmBeam_.clear(); + simHitCellIdEE_.clear(); + simHitCellIdBeam_.clear(); + simHitCellEnEE_.clear(); + simHitCellEnBeam_.clear(); + simHitCellTmEE_.clear(); + simHitCellTmBeam_.clear(); edm::Handle theCaloHitContainers; - std::vector caloHits; + std::vector caloHits; iEvent.getByToken(tok_hitsEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG std::cout << "PcalohitContainer for " << detectorEE_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + << theCaloHitContainers->size() << " hits" << std::endl; #endif caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); analyzeSimHits(0, caloHits); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorEE_ - << " !!!" << std::endl; + std::cout << "PCaloHitContainer does not exist for " << detectorEE_ + << " !!!" << std::endl; #endif } - + iEvent.getByToken(tok_hitsBeam_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG std::cout << "PcalohitContainer for " << detectorBeam_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + << theCaloHitContainers->size() << " hits" << std::endl; #endif caloHits.clear(); - caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), - theCaloHitContainers->end()); + caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), + theCaloHitContainers->end()); analyzeSimHits(1, caloHits); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorBeam_ - << " !!!" << std::endl; + std::cout << "PCaloHitContainer does not exist for " << detectorBeam_ + << " !!!" << std::endl; #endif } if (doTree_) tree_->Fill(); - } -void HGCalTimingAnalyzer::analyzeSimHits (int type, - std::vector const& hits) { - +void HGCalTimingAnalyzer::analyzeSimHits(int type, + std::vector const& hits) { #ifdef EDM_ML_DEBUG unsigned int i(0); #endif - std::map,std::pair > map_hits; + std::map, std::pair> map_hits; for (const auto& hit : hits) { - double energy = hit.energy(); - double time = hit.time(); - uint32_t id = hit.id(); + double energy = hit.energy(); + double time = hit.time(); + uint32_t id = hit.id(); if (type == 0) { - int subdet, zside, layer, sector, subsector, cell; + int subdet, zside, layer, sector, subsector, cell; HGCalTestNumbering::unpackHexagonIndex(id, subdet, zside, layer, sector, - subsector, cell); - std::pair recoLayerCell = hgcons_->simToReco(cell,layer,sector,true); - id = HGCalDetId((ForwardSubdetector)(subdet),zside, - recoLayerCell.second,subsector,sector, - recoLayerCell.first).rawId(); + subsector, cell); + std::pair recoLayerCell = + hgcons_->simToReco(cell, layer, sector, true); + id = HGCalDetId((ForwardSubdetector)(subdet), zside, recoLayerCell.second, + subsector, sector, recoLayerCell.first) + .rawId(); #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside - << ":" << layer << ":" << sector << ":" << subsector << ":" - << recoLayerCell.first << ":" << recoLayerCell.second - << " Energy " << energy << " Time " << time << std::endl; + std::cout << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside + << ":" << layer << ":" << sector << ":" << subsector << ":" + << recoLayerCell.first << ":" << recoLayerCell.second + << " Energy " << energy << " Time " << time << std::endl; #endif } else { #ifdef EDM_ML_DEBUG - int subdet, layer, x, y; + int subdet, layer, x, y; HcalTestBeamNumbering::unpackIndex(id, subdet, layer, x, y); - std::cout << "SimHit:Hit[" << i << "] Beam Subdet " << subdet - << " Layer " << layer << " x|y " << x << ":" << y - << " Energy " << energy << " Time " << time << std::endl; + std::cout << "SimHit:Hit[" << i << "] Beam Subdet " << subdet << " Layer " + << layer << " x|y " << x << ":" << y << " Energy " << energy + << " Time " << time << std::endl; #endif } - uint64_t tid = (uint64_t)((time+50.0)/timeUnit_); - std::pair key(id,tid); + uint64_t tid = (uint64_t)((time + 50.0) / timeUnit_); + std::pair key(id, tid); auto itr = map_hits.find(key); if (itr == map_hits.end()) { - map_hits[key] = std::pair(time,0.0); - itr = map_hits.find(key); + map_hits[key] = std::pair(time, 0.0); + itr = map_hits.find(key); } energy += (itr->second).second; - map_hits[key] = std::pair((itr->second).first,energy); + map_hits[key] = std::pair((itr->second).first, energy); #ifdef EDM_ML_DEBUG ++i; #endif } - + #ifdef EDM_ML_DEBUG std::cout << "analyzeSimHits: Finds " << map_hits.size() << " hits " - << " from the Hit Vector of size " << hits.size() << " for type " - << type << std::endl; + << " from the Hit Vector of size " << hits.size() << " for type " + << type << std::endl; #endif - for (const auto& itr: map_hits) { - uint32_t id = (itr.first).first; - double time = (itr.second).first; + for (const auto& itr : map_hits) { + uint32_t id = (itr.first).first; + double time = (itr.second).first; double energy = (itr.second).second; if (type == 0) { - simHitCellIdEE_.push_back(id); + simHitCellIdEE_.push_back(id); simHitCellEnEE_.push_back(energy); simHitCellTmEE_.push_back(time); } else { - simHitCellIdBeam_.push_back(id); + simHitCellIdBeam_.push_back(id); simHitCellEnBeam_.push_back(energy); simHitCellTmBeam_.push_back(time); } #ifdef EDM_ML_DEBUG std::cout << "SimHit::ID: " << std::hex << id << std::dec << " T: " << time - << " E: " << energy << std::endl; + << " E: " << energy << std::endl; #endif } } - -void HGCalTimingAnalyzer::analyzeSimTracks(edm::Handle const& SimTk, - edm::Handle const& SimVtx) { - +void HGCalTimingAnalyzer::analyzeSimTracks( + edm::Handle const& SimTk, + edm::Handle const& SimVtx) { xBeam_ = yBeam_ = zBeam_ = pBeam_ = -1000000; int vertIndex(-1); - for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); - simTrkItr!= SimTk->end(); simTrkItr++) { + for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); + simTrkItr != SimTk->end(); simTrkItr++) { #ifdef EDM_ML_DEBUG std::cout << "Track " << simTrkItr->trackId() << " Vertex " - << simTrkItr->vertIndex() << " Type " << simTrkItr->type() - << " Charge " << simTrkItr->charge() << " momentum " - << simTrkItr->momentum() << " " << simTrkItr->momentum().P() - << std::endl; + << simTrkItr->vertIndex() << " Type " << simTrkItr->type() + << " Charge " << simTrkItr->charge() << " momentum " + << simTrkItr->momentum() << " " << simTrkItr->momentum().P() + << std::endl; #endif if (vertIndex == -1) { vertIndex = simTrkItr->vertIndex(); - pBeam_ = simTrkItr->momentum().P(); + pBeam_ = simTrkItr->momentum().P(); } } if (vertIndex != -1 && vertIndex < (int)SimVtx->size()) { - edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); - for (int iv=0; ivbegin(); + for (int iv = 0; iv < vertIndex; iv++) simVtxItr++; #ifdef EDM_ML_DEBUG - std::cout << "Vertex " << vertIndex << " position " - << simVtxItr->position() << std::endl; + std::cout << "Vertex " << vertIndex << " position " << simVtxItr->position() + << std::endl; #endif xBeam_ = simVtxItr->position().X(); yBeam_ = simVtxItr->position().Y(); zBeam_ = simVtxItr->position().Z(); } - } - -//define this as a plug-in + +// define this as a plug-in DEFINE_FWK_MODULE(HGCalTimingAnalyzer); diff --git a/SimG4CMS/HGCalTestBeam/src/AHCalDetId.cc b/SimG4CMS/HGCalTestBeam/src/AHCalDetId.cc index 064095e482631..35a634d05a32f 100644 --- a/SimG4CMS/HGCalTestBeam/src/AHCalDetId.cc +++ b/SimG4CMS/HGCalTestBeam/src/AHCalDetId.cc @@ -1,66 +1,67 @@ #include "SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h" -#include "FWCore/Utilities/interface/Exception.h" #include +#include "FWCore/Utilities/interface/Exception.h" -const AHCalDetId AHCalDetId::Undefined(0,0,0); +const AHCalDetId AHCalDetId::Undefined(0, 0, 0); -AHCalDetId::AHCalDetId() : DetId() { -} +AHCalDetId::AHCalDetId() : DetId() {} -AHCalDetId::AHCalDetId(uint32_t rawid) : DetId(rawid) { -} +AHCalDetId::AHCalDetId(uint32_t rawid) : DetId(rawid) {} -AHCalDetId::AHCalDetId(int row, int col, int depth) : DetId(Hcal,HcalOther) { - int icol = (col > 0) ? col : 10-col; - int irow = (row > 0) ? row : 10-row; - id_ |= (HcalDetId::kHcalIdFormat2) | - ((depth&HcalDetId::kHcalDepthMask2)< 0) ? col : 10 - col; + int irow = (row > 0) ? row : 10 - row; + id_ |= + (HcalDetId::kHcalIdFormat2) | + ((depth & HcalDetId::kHcalDepthMask2) << HcalDetId::kHcalDepthOffset2) | + (HcalDetId::kHcalZsideMask2) | + ((irow & HcalDetId::kHcalEtaMask2) << HcalDetId::kHcalEtaOffset2) | + (icol & HcalDetId::kHcalPhiMask2); } AHCalDetId::AHCalDetId(const DetId& gen) { if (!gen.null()) { - HcalSubdetector subdet=(HcalSubdetector(gen.subdetId())); - if (gen.det()!=Hcal || subdet!=HcalOther) { - throw cms::Exception("Invalid DetId") << "Cannot initialize AHCalDetId from " << std::hex << gen.rawId() << std::dec; - } + HcalSubdetector subdet = (HcalSubdetector(gen.subdetId())); + if (gen.det() != Hcal || subdet != HcalOther) { + throw cms::Exception("Invalid DetId") + << "Cannot initialize AHCalDetId from " << std::hex << gen.rawId() + << std::dec; + } } - id_=gen.rawId(); + id_ = gen.rawId(); } int AHCalDetId::irow() const { - int value = ((id_>>HcalDetId::kHcalEtaOffset2)&HcalDetId::kHcalEtaMask2); - if (value >= 10) value = -(value%10); + int value = ((id_ >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2); + if (value >= 10) value = -(value % 10); return value; } - -int AHCalDetId::icol() const { - int value = (id_&HcalDetId::kHcalPhiMask2); - if (value >= 10) value = -(value%10); + +int AHCalDetId::icol() const { + int value = (id_ & HcalDetId::kHcalPhiMask2); + if (value >= 10) value = -(value % 10); return value; } int AHCalDetId::depth() const { - return ((id_>>HcalDetId::kHcalDepthOffset2)&HcalDetId::kHcalDepthMask2); + return ((id_ >> HcalDetId::kHcalDepthOffset2) & HcalDetId::kHcalDepthMask2); } -std::pair AHCalDetId::getXY() const { +std::pair AHCalDetId::getXY() const { int row = irow(); int col = icol(); - double shiftx = (col > 0) ? -0.5*deltaX_ : 0.5*deltaX_; - double shifty = (row > 0) ? -0.5*deltaY_ : 0.5*deltaY_; - return std::pair(col*deltaX_+shiftx,row*deltaY_+shifty); + double shiftx = (col > 0) ? -0.5 * deltaX_ : 0.5 * deltaX_; + double shifty = (row > 0) ? -0.5 * deltaY_ : 0.5 * deltaY_; + return std::pair(col * deltaX_ + shiftx, + row * deltaY_ + shifty); } double AHCalDetId::getZ() const { int lay = depth(); - return (zFirst_+(lay-1)*deltaZ_); + return (zFirst_ + (lay - 1) * deltaZ_); } -std::ostream& operator<<(std::ostream& s,const AHCalDetId& id) { - return s << "(AHCal " << id.irow() << ',' << id.icol() << ',' << id.depth() << ')'; +std::ostream& operator<<(std::ostream& s, const AHCalDetId& id) { + return s << "(AHCal " << id.irow() << ',' << id.icol() << ',' << id.depth() + << ')'; } - - From 9ed530d203f2ae3be13b0af41bc0009dbf2d177a Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 00:40:23 +0200 Subject: [PATCH 587/686] update MC GTs in 106X --- Configuration/AlCa/python/autoCond.py | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index e65855805a698..e613f62192298 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -2,27 +2,27 @@ ### NEW KEYS ### # GlobalTag for MC production with perfectly aligned and calibrated detector for Run1 - 'run1_design' : '105X_mcRun1_design_v1', + 'run1_design' : '106X_mcRun1_design_v1', # GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1 - 'run1_mc' : '105X_mcRun1_realistic_v1', + 'run1_mc' : '106X_mcRun1_realistic_v1', # GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_hi' : '105X_mcRun1_HeavyIon_v1', + 'run1_mc_hi' : '106X_mcRun1_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_pa' : '105X_mcRun1_pA_v1', + 'run1_mc_pa' : '106X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '105X_mcRun2_startup_v2', + 'run2_mc_50ns' : '106X_mcRun2_startup_v1', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '105X_mcRun2_asymptotic_l1stage1_v2', + 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '105X_mcRun2_design_v3', + 'run2_design' : '106X_mcRun2_design_v2', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '105X_mcRun2_asymptotic_v4', + 'run2_mc' : '106X_mcRun2_asymptotic_v1', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v4', + 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '105X_mcRun2_HeavyIon_v2', + 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '105X_mcRun2_pA_v2', + 'run2_mc_pa' : '106X_mcRun2_pA_v1', # GlobalTag for Run1 data reprocessing 'run1_data' : '106X_dataRun2_v1', # GlobalTag for Run2 data reprocessing @@ -44,31 +44,31 @@ # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v2', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v3', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '106X_mc2017_realistic_v1', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v2', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '106X_upgrade2018_design_v1', + 'phase1_2018_design' : '106X_upgrade2018_design_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v1', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v1', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '106X_postLS2_design_v1', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '106X_postLS2_realistic_v1', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v3', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_v5' + 'phase2_realistic' : '106X_upgrade2023_realistic_v1' } aliases = { From f3dcf189e95970946fa11f849f4142c860be4039 Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 01:50:23 +0200 Subject: [PATCH 588/686] update tracker mis-alignment scenario for 2018 cosmics simulation --- Configuration/AlCa/python/autoCond.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index e613f62192298..3925925df6508 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -60,9 +60,9 @@ # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 From bb5a0f08e56be5f69be732c5299c7b2746b49e1c Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 05:45:23 +0200 Subject: [PATCH 589/686] Fix JEC in 2017 and 2018 --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 3925925df6508..dda35d76518a0 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -16,7 +16,7 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 'run2_design' : '106X_mcRun2_design_v2', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '106X_mcRun2_asymptotic_v1', + 'run2_mc' : '106X_mcRun2_asymptotic_v2', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 @@ -54,11 +54,11 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) 'phase1_2018_design' : '106X_upgrade2018_design_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v2', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v3', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode From afb48224a29363cdca75773b044ce8f5deab24f9 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 4 Apr 2019 21:33:19 +0200 Subject: [PATCH 590/686] update pixel local reco conditions in 2017 data --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index dda35d76518a0..86311827f1160 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,11 +24,11 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v1', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v1', + 'run1_data' : '106X_dataRun2_v4', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v1', + 'run2_data' : '106X_dataRun2_v4', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v1', + 'run2_data_relval' : '106X_dataRun2_relval_v2', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) From 812ccae98cf1ba63b38f808d641630b9a4e1cb60 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 11 Apr 2019 06:38:59 +0200 Subject: [PATCH 591/686] update LHCinfo and HLT PF calibration --- Configuration/AlCa/python/autoCond.py | 62 +++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 86311827f1160..4bd96b98c27cd 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -10,65 +10,65 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 'run1_mc_pa' : '106X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '106X_mcRun2_startup_v1', + 'run2_mc_50ns' : '106X_mcRun2_startup_v2', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v1', + 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '106X_mcRun2_design_v2', + 'run2_design' : '106X_mcRun2_design_v3', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '106X_mcRun2_asymptotic_v2', + 'run2_mc' : '106X_mcRun2_asymptotic_v3', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', + 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v2', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v1', + 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v2', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '106X_mcRun2_pA_v1', + 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v4', + 'run1_data' : '106X_dataRun2_v5', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v4', + 'run2_data' : '106X_dataRun2_v5', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v2', + 'run2_data_relval' : '106X_dataRun2_relval_v3', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v1', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v1', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v2', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v2', # GlobalTag for Run1 HLT: it points to the online GT - 'run1_hlt' : '101X_dataRun2_HLT_frozen_v8', + 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT - 'run2_hlt' : '101X_dataRun2_HLT_frozen_v8', + 'run2_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT RelVals: customizations to run with fixed L1 Menu - 'run2_hlt_relval' : '103X_dataRun2_HLT_relval_v7', - 'run2_hlt_relval_hi' : '103X_dataRun2_HLT_relval_HI_v3', + 'run2_hlt_relval' : '103X_dataRun2_HLT_relval_v8', + 'run2_hlt_relval_hi' : '103X_dataRun2_HLT_relval_HI_v4', # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT - 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', + 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v9', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v3', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v4', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '106X_mc2017_realistic_v2', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v3', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', + 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', + 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '106X_upgrade2018_design_v2', + 'phase1_2018_design' : '106X_upgrade2018_design_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v3', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v4', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', + 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v3', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v4', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v3', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v2', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v3', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v4', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '106X_postLS2_realistic_v3', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '106X_upgrade2023_realistic_v1' + 'phase2_realistic' : '106X_upgrade2023_realistic_v2' } aliases = { From 7fd727dcf63cd5899390c5f343c0cacc0b80f1b4 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 11 Apr 2019 22:32:10 +0200 Subject: [PATCH 592/686] update Run-2 2016-2018 data JEC/JER --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 4bd96b98c27cd..57cd8de8df124 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,11 +24,11 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v5', + 'run1_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v5', + 'run2_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v3', + 'run2_data_relval' : '106X_dataRun2_relval_v4', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) From 2ca0670f1a6b82a1ba08619c80c782eeb5405d3c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 12 Apr 2019 03:23:02 +0200 Subject: [PATCH 593/686] Avoid remaining overlap --- .../data/TB181/Oct181/hgcal.xml | 6 +- .../plugins/DDAHcalModuleAlgo.cc | 104 ++++++++++-------- .../test/dumpTBGeometry_cfg.py | 6 + 3 files changed, 65 insertions(+), 51 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml index 62529f96d7c80..96f0a52434edb 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml @@ -3,7 +3,7 @@ - + @@ -16,9 +16,9 @@ - + - + > Constructing DDAHcalModuleAlgo..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDAHcalModuleAlgo..."; #endif constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - std::cout << "<<== End of DDAHcalModuleAlgo construction ..." << std::endl; + edm::LogVerbatim("HGCalGeom") <<"<<== End of DDAHcalModuleAlgo construction"; #endif } void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo test: \t\tInside Layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDAHcalModuleAlgo test: \t\tInside Layers"; #endif double zi(zMinBlock); int laymin(0); @@ -126,9 +132,9 @@ void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, std::string name = "HGCal" + names[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii - << " Front " << zi << " Back " << zo << " superlayer thickness " - << layerThick[i] << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo test: Layer " << ly << ":" << ii << " Front " + << zi << " Back " << zo << " superlayer thickness " << layerThick[i]; #endif DDName matName(DDSplit(materials[ii]).first, DDSplit(materials[ii]).second); @@ -140,10 +146,10 @@ void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, 0.5 * heights[0], 0.5 * thick[ii]); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo test: " << solid.name() - << " Box made of " << matName << " of dimensions " - << 0.5 * widths[0] << ", " << 0.5 * heights[0] << ", " - << 0.5 * thick[ii] << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " + << matName << " of dimensions " << 0.5 * widths[0] << ", " + << 0.5 * heights[0] << ", " << 0.5 * thick[ii]; #endif } else { DDSolid solid = @@ -151,10 +157,10 @@ void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, 0.5 * heights[1], 0.5 * thick[ii]); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo test: " << solid.name() - << " Box made of " << matName << " of dimensions " - << 0.5 * widths[1] << ", " << 0.5 * heights[1] << ", " - << 0.5 * thick[ii] << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo: " << solid.name() << " Box made of " + << matName << " of dimensions " << 0.5 * widths[1] << ", " + << 0.5 * heights[1] << ", " << 0.5 * thick[ii]; #endif positionSensitive(glog, cpv); } @@ -163,9 +169,10 @@ void DDAHcalModuleAlgo::constructLayers(const DDLogicalPart& module, cpv.position(glog, module, copy, r1, rot); ++copyNumber[ii]; #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo test: " << glog.name() << " number " - << copy << " positioned in " << module.name() << " at " << r1 - << " with " << rot << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo: " << glog.name() << " number " << copy + << " positioned in " << module.name() << " at " << r1 << " with " + << rot; #endif zz += (0.5 * thick[ii]); } // End of loop over layers in a block @@ -191,8 +198,8 @@ void DDAHcalModuleAlgo::positionSensitive(DDLogicalPart& glog, int nrow = tileN[1] / 2; #ifdef EDM_ML_DEBUG int kount(0); - std::cout << glog.ddname() << " Row " << nrow << " Column " << ncol - << std::endl; + edm::LogVerbatim("HGCalGeom") + << glog.ddname() << " Row " << nrow << " Column " << ncol; #endif for (int nr = -nrow; nr <= nrow; ++nr) { int inr = (nr >= 0) ? nr : -nr; @@ -212,15 +219,16 @@ void DDAHcalModuleAlgo::positionSensitive(DDLogicalPart& glog, cpv.position(name, glog.ddname(), copy, tran, rotation); #ifdef EDM_ML_DEBUG kount++; - std::cout << "DDAHcalModuleAlgo: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo: " << name << " number " << copy + << " positioned in " << glog.ddname() << " at " << tran + << " with " << rotation; #endif } } } #ifdef EDM_ML_DEBUG - std::cout << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname() - << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDAHcalModuleAlgo: " << kount << " tiles for " << glog.ddname(); #endif } diff --git a/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py b/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py index 8e669f81a079c..023bd22567387 100644 --- a/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py +++ b/Geometry/HGCalCommonData/test/dumpTBGeometry_cfg.py @@ -2,6 +2,12 @@ process = cms.Process("DUMP") process.load("Geometry.HGCalCommonData.testTB160XML_cfi") +process.load('FWCore.MessageService.MessageLogger_cfi') + +if 'MessageLogger' in process.__dict__: + process.MessageLogger.categories.append('G4cerr') + process.MessageLogger.categories.append('G4cout') + process.MessageLogger.categories.append('HGCalGeom') process.source = cms.Source("EmptySource") From dd3172f0fb2ca78db0b419ec64991b952575c6c9 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 12 Apr 2019 03:41:41 +0200 Subject: [PATCH 594/686] Switvh off the debig --- Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml | 2 +- Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml index 96f0a52434edb..bcebce39ede7c 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml @@ -18,7 +18,7 @@ - + Date: Fri, 12 Apr 2019 09:45:16 +0200 Subject: [PATCH 595/686] more unification of HBX/HEX with HOX --- .../src/HcalText2DetIdConverter.cc | 25 +++------ .../HcalDetId/interface/HcalCalibDetId.h | 17 +++---- DataFormats/HcalDetId/src/HcalCalibDetId.cc | 51 +++++++++---------- 3 files changed, 40 insertions(+), 53 deletions(-) diff --git a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc index c06857fa8bc3a..89ec78d3dc39b 100644 --- a/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc +++ b/CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc @@ -162,12 +162,12 @@ bool HcalText2DetIdConverter::init (DetId fId) { flavorName="HBX"; setField (1, calibId.ieta()); setField (2, calibId.iphi()); - setField (3, calibId.depth()); + setField (3, -999); } else if ( calibId.calibFlavor()==HcalCalibDetId::HEX) { flavorName="HEX"; setField (1, calibId.ieta()); setField (2, calibId.iphi()); - setField (3, calibId.depth()); + setField (3, -999); } } else { @@ -239,23 +239,14 @@ bool HcalText2DetIdConverter::init (const std::string& fFlavor, const std::strin int channel = calibChannel (field3); mId = HcalCalibDetId (sd, ieta,iphi,channel); } - else if (flavorName=="HOX") { - int ieta=getField(1); - int iphi=getField(2); - mId = HcalCalibDetId (ieta,iphi); - } - else if (flavorName=="HBX") { + else if (flavorName=="HOX" || flavorName=="HBX" || flavorName=="HEX") { int ieta=getField(1); int iphi=getField(2); - int depth=getField(3); - mId = HcalCalibDetId (HcalCalibDetId::HBX, ieta, iphi, depth); - } - else if (flavorName=="HEX") { - int ieta=getField(1); - int iphi=getField(2); - int depth=getField(3); - mId = HcalCalibDetId (HcalCalibDetId::HEX, ieta, iphi, depth); - + mId = (flavorName=="HOX")? + (HcalCalibDetId(HcalCalibDetId::HOCrosstalk,ieta,iphi)): + ((flavorName=="HBX")?(HcalCalibDetId(HcalCalibDetId::HBX,ieta,iphi)): + (HcalCalibDetId(HcalCalibDetId::HEX,ieta,iphi)) + ); } else if (flavorName=="UMNQIE") { int channel=getField(1); diff --git a/DataFormats/HcalDetId/interface/HcalCalibDetId.h b/DataFormats/HcalDetId/interface/HcalCalibDetId.h index c1386ca3baddb..c2978d5aab150 100644 --- a/DataFormats/HcalDetId/interface/HcalCalibDetId.h +++ b/DataFormats/HcalDetId/interface/HcalCalibDetId.h @@ -36,10 +36,9 @@ * * For HBX/HEX: * [19:17] 6 or 7 (CalibType) - * [15:15] 0/1 (Side) - * [14:10] ieta (1-29) - * [9:3] iphi (1-72) - * [2:0] depth (1-7) + * [12:12] side (true = positive) + * [11:7] ieta (1-29) + * [6:0] iphi (1-72) * * \author J. Mans - Minnesota */ @@ -57,7 +56,9 @@ class HcalCalibDetId : public HcalOtherDetId { HcalCalibDetId& operator=(const DetId& id); /** Construct a calibration box - channel detid */ HcalCalibDetId(HcalSubdetector subdet, int ieta, int iphi, int ctype); - /** Construct an HO Crosstalk id */ + /** Construct an HOX/HBX/HEX Crosstalk id */ + HcalCalibDetId(CalibDetType dt, int ieta, int iphi); + /** Keep old HOX constructor for back-compatibility */ HcalCalibDetId(int ieta, int iphi); /** Construct a uMNqie id or other id which uses a single value plus a DetType */ HcalCalibDetId(CalibDetType dt, int value); @@ -66,12 +67,10 @@ class HcalCalibDetId : public HcalOtherDetId { /// get the flavor of this calibration detid CalibDetType calibFlavor() const { return (CalibDetType)((id_>>17)&0x7); } - - /// get the HcalSubdetector (if relevant) HcalSubdetector hcalSubdet() const; /// get the rbx name (if relevant) -// std::string rbx() const; + /// std::string rbx() const; /// get the "ieta" identifier (if relevant) int ieta() const; /// get the low-edge iphi (if relevant) @@ -90,8 +89,6 @@ class HcalCalibDetId : public HcalOtherDetId { /// get the sign of ieta (+/-1) int zside() const; - /// get the depth (where relevant) - int depth() const; /// constants static const int cbox_MixerHigh = 0; // HB/HE/HO/HF diff --git a/DataFormats/HcalDetId/src/HcalCalibDetId.cc b/DataFormats/HcalDetId/src/HcalCalibDetId.cc index 42160cca10a17..dcb47350962c8 100644 --- a/DataFormats/HcalDetId/src/HcalCalibDetId.cc +++ b/DataFormats/HcalDetId/src/HcalCalibDetId.cc @@ -26,11 +26,21 @@ HcalCalibDetId::HcalCalibDetId(HcalSubdetector subdet, int ieta, int iphi, int c else id_|=((iphi&0x7F)<<4); // phi index, bits [4:10], simply allow all values from 0-127, shouldn't be any } +// keep old HOX constructor for back-compatibility HcalCalibDetId::HcalCalibDetId(int ieta, int iphi) : HcalOtherDetId(HcalCalibration) { - id_|=(HOCrosstalk<<17); // Calibration Category, bits [17:19] (= "2" for HOX) - id_|=(iphi&0x7F) // phi index, bits [0:6] - |((abs(ieta)&0xF)<<7) // eta index, bits [7:10] - |(((ieta > 0)?(1):(0))<<11); // z side, bit [11] + id_|=(HOCrosstalk<<17); // Calibration Category, bits [17:19] (= "2" for HOX) + id_|=(iphi&0x7F) // phi index, bits [0:6] + |((abs(ieta)&0xF)<<7) // eta index, bits [7:10] + |(((ieta > 0)?(1):(0))<<11); // z side, bit [11] +} + +HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int ieta, int iphi) : HcalOtherDetId(HcalCalibration) { + id_|=(dt<<17); // Calibration Category, bits [17:19] (= "2" for HOX, "6" for HBX, "7" for HEX) + id_|=(iphi&0x7F); // phi index, bits [0:6]; + + (dt==HOCrosstalk)? + (id_|=((abs(ieta)&0xF) <<7)|(((ieta > 0)?(1):(0))<<11)): + (id_|=((abs(ieta)&0x1F)<<7)|(((ieta > 0)?(1):(0))<<12)); } HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value) : HcalOtherDetId(HcalCalibration) { @@ -40,18 +50,9 @@ HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value) : HcalOtherDetId(Hcal HcalCalibDetId::HcalCalibDetId(CalibDetType dt, int value1, int value2, int value3) : HcalOtherDetId(HcalCalibration) { id_|=(dt<<17); // Calibration Category, bits [17:19] - - if(dt == HBX || dt == HEX) { - id_|=(value3&0x7) // depth index, bits [0:2] - |((value2&0x7F)<<3) // phi index, bits [3:9] - |((value1&0x1F)<<10) // eta index, bits [10:14] - |(((value1 > 0)?(1):(0))<<15); // z side, bit [15] - } - else { - id_|=(value1&0x3F)<<10; - id_|=(value2&0x1F)<<5; - id_|=(value3&0x1F); - } + id_|=(value1&0x3F)<<10; + id_|=(value2&0x1F)<<5; + id_|=(value3&0x1F); } HcalCalibDetId::HcalCalibDetId(const DetId& gen) { @@ -84,22 +85,20 @@ HcalSubdetector HcalCalibDetId::hcalSubdet() const { } int HcalCalibDetId::ieta() const { - return (calibFlavor()==CalibrationBox)?(((id_>>11)&0x7)-2):((calibFlavor()==HOCrosstalk)?(((id_>>7)&0xF)*zside()):(calibFlavor()==LASERMON?((id_>>10)&0x3F):(((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>10)&0x1F)*zside():(0))))); + CalibDetType cf = calibFlavor(); + return (cf==CalibrationBox)?(((id_>>11)&0x7)-2):((cf==HOCrosstalk)?(((id_>>7)&0xF)*zside()):(cf==LASERMON?((id_>>10)&0x3F):(((cf==HBX || cf==HEX)?((id_>>10)&0x1F)*zside():(0))))); } int HcalCalibDetId::iphi() const { - return (calibFlavor()==CalibrationBox)?((id_>>4)&0x7F):((calibFlavor()==HOCrosstalk)?(id_&0x7F):(calibFlavor()==LASERMON?((id_>>5)&0x1F):(((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>3)&0x7F):(0))))); + CalibDetType cf = calibFlavor(); + return (cf==CalibrationBox)?((id_>>4)&0x7F):((cf==HOCrosstalk || cf==HBX || cf==HEX)?(id_&0x7F):(cf==LASERMON?((id_>>5)&0x1F):(0))); } int HcalCalibDetId::zside() const { - return (calibFlavor()==HOCrosstalk)?(((id_>>11)&0x1)?(1):(-1)):((calibFlavor()==HBX || calibFlavor()==HEX)?((id_>>15)&0x1)?(1):(-1):(0)); -} - -int HcalCalibDetId::depth() const { - return (calibFlavor()==HBX || calibFlavor()==HEX)?(id_&0x7):(0); + CalibDetType cf = calibFlavor(); + return (cf==HOCrosstalk)?(((id_>>11)&0x1)?(1):(-1)):((cf==HBX || cf==HEX)?((id_>>12)&0x1)?(1):(-1):(0)); } - std::string HcalCalibDetId::cboxChannelString() const { switch (cboxChannel()) { case(cbox_MixerHigh): return "Mixer-High"; @@ -145,9 +144,9 @@ std::ostream& operator<<(std::ostream& s,const HcalCalibDetId& id) { case (HcalCalibDetId::CastorRadFacility): return s << "(CastorRadFacility " << id.rm() << " / " << id.fiber() << " / " << id.channel() << ')'; case (HcalCalibDetId::HBX): - return s << "(HBX " << id.ieta() << "," << id.iphi() << "," << id.depth() << ")"; + return s << "(HBX " << id.ieta() << "," << id.iphi() << ")"; case (HcalCalibDetId::HEX): - return s << "(HEX " << id.ieta() << "," << id.iphi() << "," << id.depth() << ")"; + return s << "(HEX " << id.ieta() << "," << id.iphi() << ")"; default: return s; }; } From ad4125cb6a3103b1206d31f1d1d891414ef76e62 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 12 Apr 2019 10:36:04 +0200 Subject: [PATCH 596/686] more iteritems --- .../Configuration/python/tools/adaptToRunAtMiniAOD.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py index ef9bbde729194..751584882c73c 100644 --- a/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py +++ b/RecoTauTag/Configuration/python/tools/adaptToRunAtMiniAOD.py @@ -1,4 +1,5 @@ import FWCore.ParameterSet.Config as cms +import six ###### # Tools to adapt Tau sequences to run tau ReReco+PAT at MiniAOD samples @@ -115,7 +116,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.combinatoricRecoTaus.jetSrc = jetCollection # Adapt builders for builder in process.combinatoricRecoTaus.builders: - for name,value in builder.parameters_().iteritems(): + for name,value in six.iteritems(builder.parameters_()): if name == 'qualityCuts': builder.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' elif name == 'pfCandSrc': @@ -129,7 +130,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): elif mod.name.value() == 'TTIworkaround': modifiersToRemove_.append(mod) continue - for name,value in mod.parameters_().iteritems(): + for name,value in six.iteritems(mod.parameters_()): if name == 'qualityCuts': mod.qualityCuts.primaryVertexSrc = 'offlineSlimmedPrimaryVertices' for mod in modifiersToRemove_: @@ -167,7 +168,7 @@ def adaptTauToMiniAODReReco(process, reclusterJets=True): process.tauMatch.matched = cms.InputTag("prunedGenParticles") # Remove unsupported tauIDs - for name, src in process.patTaus.tauIDSources.parameters_().iteritems(): + for name, src in six.iteritems(process.patTaus.tauIDSources.parameters_()): if name.find('againstElectron') > -1 or name.find('againstMuon') > -1: delattr(process.patTaus.tauIDSources,name) # Add MiniAOD specific ones From 768b22281b8a15a215d9f5536f1378da62f780a1 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 12 Apr 2019 11:43:45 +0200 Subject: [PATCH 597/686] integer division wanted --- DQMServices/FwkIO/test/read_file1_file3_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/FwkIO/test/read_file1_file3_cfg.py b/DQMServices/FwkIO/test/read_file1_file3_cfg.py index a300a52d1383e..4395793b3d5dc 100644 --- a/DQMServices/FwkIO/test/read_file1_file3_cfg.py +++ b/DQMServices/FwkIO/test/read_file1_file3_cfg.py @@ -32,7 +32,7 @@ for i in range(0,10): readLumiElements.append(cms.untracked.PSet(name=cms.untracked.string("Foo"+str(i)), #file3 has means shifted by 1 - means = cms.untracked.vdouble([i+x/10 for x in range(0,20)]), + means = cms.untracked.vdouble([i+x//10 for x in range(0,20)]), entries=cms.untracked.vdouble([1 for x in range(0,20)]) )) From 27224f36265ed7c53ce8a35dec8143fff4b43280 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 18 Feb 2019 10:41:26 +0100 Subject: [PATCH 598/686] Tool to convert almost arbitrary ROOT files into SQLite databases. Represents TTrees as Tables and converts objects to JSON. So far only tested with DQMIO files. Does not actually work with DQMIO files, since ROOT can't correctly convert NaN/Inf to JSON. --- DQMServices/Components/scripts/root2sqlite.py | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 DQMServices/Components/scripts/root2sqlite.py diff --git a/DQMServices/Components/scripts/root2sqlite.py b/DQMServices/Components/scripts/root2sqlite.py new file mode 100644 index 0000000000000..79e15dc3dad81 --- /dev/null +++ b/DQMServices/Components/scripts/root2sqlite.py @@ -0,0 +1,116 @@ +import re +import json +import ROOT +import sqlite3 +import argparse + +parser = argparse.ArgumentParser(description="Convert arbitrary ROOT file to SQLite database, mapping TTrees to tables and converting TObjects to JSON.") + +parser.add_argument('inputfile', help='ROOT file to read') +parser.add_argument('-o', '--output', help='SQLite file to write', default='root.sqlite') +args = parser.parse_args() + +f = ROOT.TFile(args.inputfile) +db = sqlite3.connect(args.output) + +basic_objects = {} + +def tosqlite(x): + if isinstance(x, ROOT.string): + try: + return unicode(x.data()) + except: + return buffer(x.data()) + if isinstance(x, int): + return x + if isinstance(x, float): + return x + if isinstance(x, long): + return x + else: + try: + rootobj = unicode(ROOT.TBufferJSON.ConvertToJSON(x)) + # turns out ROOT does not generate valid JSON for NaN/inf + obj = json.loads(rootobj) + jsonobj = json.dumps(obj, allow_nan=False) + return jsonobj + except: + print x, x.__class__ + return "<%s>" % x + +def columnescape(s): + # add whatever is not a valid column name here + SQLKWDs = ["index"] + if s.lower() in SQLKWDs: + return s + "_" + else: + return s + +def treetotable(ttree, name): + name = name.replace("/", "_") + branches = [b.GetName() for b in ttree.GetListOfBranches()] + colnames = ", ".join(columnescape(b) for b in branches) + create = "CREATE TABLE %s(%s);" % (name, colnames) + print create + db.execute(create) + data = [] + for i in range(ttree.GetEntries()): + ttree.GetEntry(i) + vals = tuple([tosqlite(getattr(ttree, b)) for b in branches]) + data.append(vals) + insert = "INSERT INTO %s(%s) VALUES (%s);" % (name, colnames, ",".join(["?"] * len(branches))) + print insert + db.executemany(insert, data) + +def read_objects_root(rootfile): + xml_re = re.compile(r"^<(.+)>(.+)=(.+)<\/\1>$") + def parse_directory(di): + directory = rootfile.GetDirectory(di) + for key in directory.GetListOfKeys(): + entry = key.GetName() + rtype = key.GetClassName() + fullpath = "%s/%s" % (di, entry) if di != "" else entry + if (rtype == "TDirectoryFile"): + for k, v, t in parse_directory(fullpath): + yield (k, v, t) + else: + obj = rootfile.Get(fullpath) + if obj: + yield (fullpath, obj, rtype) + else: + # special case to parse the xml abomination + m = xml_re.search(entry) + if m: + name = m.group(1) + typecode = m.group(2) + value = m.group(3) + fp = "%s/%s" % (di, name) + yield (fp, value, rtype) + else: + raise Exception("Invalid xml:" + entry) + path_fix = re.compile(r"^\/Run \d+") + for fullname, obj, rtype in parse_directory(""): + yield fullname, obj, rtype + +def save_keyvalue(dictionary, name): + name = name.replace("/", "_") + create = "CREATE TABLE %s(key, value);" % name + print create + db.execute(create) + data = [] + for k, v in dictionary.iteritems(): + vals = (unicode(k), tosqlite(v)) + data.append(vals) + insert = "INSERT INTO %s(key, value) VALUES (?,?);" % name + print insert + db.executemany(insert, data) + + +for name, obj, rtype in read_objects_root(f): + print name, obj, rtype + if rtype == "TTree": + treetotable(obj, name) + else: + basic_objects[name] = obj + +save_keyvalue(basic_objects, "TDirectory") From fd7850180774d05db81d8b57b94af5946f62328e Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 19 Feb 2019 17:09:15 +0100 Subject: [PATCH 599/686] Reading DQMIO from dataset to collect fine-granularity plots. Reading only seems to work single threaded, threading with ROOT is hard... --- .../Components/scripts/dqmiodatasetharvest.py | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100755 DQMServices/Components/scripts/dqmiodatasetharvest.py diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py new file mode 100755 index 0000000000000..76c4a6147b94e --- /dev/null +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -0,0 +1,246 @@ +#!/usr/bin/env python +import re +import json +import ROOT +import sqlite3 +import argparse +import threading +import subprocess + +parser = argparse.ArgumentParser(description="Collect a MEs from DQMIO data, with maximum possible granularity") + +parser.add_argument('dataset', help='dataset name, like "/StreamHIExpress/HIRun2018A-Express-v1/DQMIO"') +parser.add_argument('-o', '--output', help='SQLite file to write', default='dqmio.sqlite') +parser.add_argument('-j', '--njobs', help='Number of threads to read files', type=int, default=1) +args = parser.parse_args() + + +# we can save a lot of time by only scanning some types, if we know all interesting MEs are of these types. +interesting_types = { + "TH2Fs", +} + +interesting_mes = { + "PixelPhase1/Phase1_MechanicalView/PXBarrel/digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_1", + "PixelPhase1/Phase1_MechanicalView/PXBarrel/digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_2", + "PixelPhase1/Phase1_MechanicalView/PXBarrel/digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_3", + "PixelPhase1/Phase1_MechanicalView/PXBarrel/digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_4", + "PixelPhase1/Phase1_MechanicalView/PXForward/digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_1", + "PixelPhase1/Phase1_MechanicalView/PXForward/digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_2", + "SiStrip/MechanicalView/TEC/MINUS/wheel_1/TkHMap_NumberValidHits_TECM_W1", + "SiStrip/MechanicalView/TEC/MINUS/wheel_2/TkHMap_NumberValidHits_TECM_W2", + "SiStrip/MechanicalView/TEC/MINUS/wheel_3/TkHMap_NumberValidHits_TECM_W3", + "SiStrip/MechanicalView/TEC/MINUS/wheel_4/TkHMap_NumberValidHits_TECM_W4", + "SiStrip/MechanicalView/TEC/MINUS/wheel_5/TkHMap_NumberValidHits_TECM_W5", + "SiStrip/MechanicalView/TEC/MINUS/wheel_6/TkHMap_NumberValidHits_TECM_W6", + "SiStrip/MechanicalView/TEC/MINUS/wheel_7/TkHMap_NumberValidHits_TECM_W7", + "SiStrip/MechanicalView/TEC/MINUS/wheel_8/TkHMap_NumberValidHits_TECM_W8", + "SiStrip/MechanicalView/TEC/MINUS/wheel_9/TkHMap_NumberValidHits_TECM_W9", + "SiStrip/MechanicalView/TEC/PLUS/wheel_1/TkHMap_NumberValidHits_TECP_W1", + "SiStrip/MechanicalView/TEC/PLUS/wheel_2/TkHMap_NumberValidHits_TECP_W2", + "SiStrip/MechanicalView/TEC/PLUS/wheel_3/TkHMap_NumberValidHits_TECP_W3", + "SiStrip/MechanicalView/TEC/PLUS/wheel_4/TkHMap_NumberValidHits_TECP_W4", + "SiStrip/MechanicalView/TEC/PLUS/wheel_5/TkHMap_NumberValidHits_TECP_W5", + "SiStrip/MechanicalView/TEC/PLUS/wheel_6/TkHMap_NumberValidHits_TECP_W6", + "SiStrip/MechanicalView/TEC/PLUS/wheel_7/TkHMap_NumberValidHits_TECP_W7", + "SiStrip/MechanicalView/TEC/PLUS/wheel_8/TkHMap_NumberValidHits_TECP_W8", + "SiStrip/MechanicalView/TEC/PLUS/wheel_9/TkHMap_NumberValidHits_TECP_W9", + "SiStrip/MechanicalView/TIB/layer_1/TkHMap_NumberValidHits_TIB_L1", + "SiStrip/MechanicalView/TIB/layer_2/TkHMap_NumberValidHits_TIB_L2", + "SiStrip/MechanicalView/TIB/layer_3/TkHMap_NumberValidHits_TIB_L3", + "SiStrip/MechanicalView/TIB/layer_4/TkHMap_NumberValidHits_TIB_L4", + "SiStrip/MechanicalView/TID/MINUS/wheel_1/TkHMap_NumberValidHits_TIDM_D1", + "SiStrip/MechanicalView/TID/MINUS/wheel_2/TkHMap_NumberValidHits_TIDM_D2", + "SiStrip/MechanicalView/TID/MINUS/wheel_3/TkHMap_NumberValidHits_TIDM_D3", + "SiStrip/MechanicalView/TID/PLUS/wheel_1/TkHMap_NumberValidHits_TIDP_D1", + "SiStrip/MechanicalView/TID/PLUS/wheel_2/TkHMap_NumberValidHits_TIDP_D2", + "SiStrip/MechanicalView/TID/PLUS/wheel_3/TkHMap_NumberValidHits_TIDP_D3", + "SiStrip/MechanicalView/TOB/layer_1/TkHMap_NumberValidHits_TOB_L1", + "SiStrip/MechanicalView/TOB/layer_2/TkHMap_NumberValidHits_TOB_L2", + "SiStrip/MechanicalView/TOB/layer_3/TkHMap_NumberValidHits_TOB_L3", + "SiStrip/MechanicalView/TOB/layer_4/TkHMap_NumberValidHits_TOB_L4", + "SiStrip/MechanicalView/TOB/layer_5/TkHMap_NumberValidHits_TOB_L5", + "SiStrip/MechanicalView/TOB/layer_6/TkHMap_NumberValidHits_TOB_L6", + "EcalBarrel/EBOccupancyTask/EBOT digi occupancy", + "EcalEndcap/EEOccupancyTask/EEOT digi occupancy EE -", + "EcalEndcap/EEOccupancyTask/EEOT digi occupancy EE +", + "EcalPreshower/ESOccupancyTask/ES Energy Density Z -1 P 1", + "EcalPreshower/ESOccupancyTask/ES Energy Density Z -1 P 2", + "EcalPreshower/ESOccupancyTask/ES Energy Density Z 1 P 1", + "EcalPreshower/ESOccupancyTask/ES Energy Density Z 1 P 2", + "Hcal/DigiRunHarvesting/Occupancy/depth/depth1", + "Hcal/DigiRunHarvesting/Occupancy/depth/depth2", + "Hcal/DigiRunHarvesting/Occupancy/depth/depth3", + "Hcal/DigiRunHarvesting/Occupancy/depth/depth4", + "CSC/CSCOfflineMonitor/Occupancy/hOStripsAndWiresAndCLCT", + "RPC/AllHits/SummaryHistograms/Occupancy_for_Barrel", + "RPC/AllHits/SummaryHistograms/Occupancy_for_Endcap", + "DT/02-Segments/Wheel-1/numberOfSegments_W-1", + "DT/02-Segments/Wheel-2/numberOfSegments_W-2", + "DT/02-Segments/Wheel0/numberOfSegments_W0", + "DT/02-Segments/Wheel1/numberOfSegments_W1", + "DT/02-Segments/Wheel2/numberOfSegments_W2", + + "L1T/L1TObjects/L1TEGamma/timing/egamma_eta_phi_bx_0", + "L1T/L1TObjects/L1TJet/timing/jet_eta_phi_bx_0", + "L1T/L1TObjects/L1TMuon/timing/muons_eta_phi_bx_0", + "L1T/L1TObjects/L1TTau/timing/tau_eta_phi_bx_0", + "L1T/L1TObjects/L1TEGamma/timing/denominator_egamma", + "L1T/L1TObjects/L1TJet/timing/denominator_jet", + "L1T/L1TObjects/L1TMuon/timing/denominator_muons", + "L1T/L1TObjects/L1TTau/timing/denominator_tau", +} + +inf = re.compile("([- \[])inf([,}\]])") +nan = re.compile("([- \[])nan([,}\]])") + +def tosqlite(x): + if isinstance(x, ROOT.string): + try: + return unicode(x.data()) + except: + return buffer(x.data()) + if isinstance(x, int): + return x + if isinstance(x, float): + return x + if isinstance(x, long): + return x + else: + try: + rootobj = unicode(ROOT.TBufferJSON.ConvertToJSON(x)) + # turns out ROOT does not generate valid JSON for NaN/inf + clean = nan.sub('\\g<1>0\\g<2>', inf.sub('\\g<1>1e38\\g<2>', rootobj)) + obj = json.loads(clean) + jsonobj = json.dumps(obj, allow_nan=False) + return jsonobj + except Exception as e: + return json.dumps({"root2sqlite_error": e.__repr__(), "root2sqlite_object": x.__repr__()}) + +def dasquery(dataset): + if not dataset.endswith("DQMIO"): + raise Exception("This tool probably cannot read the dataset you specified. The name should end with DQMIO.") + dasquery = ["dasgoclient", "-query=file dataset=%s" % dataset] + print "Querying das ... %s" % dasquery + files = subprocess.check_output(dasquery) + files = files.splitlines() + print "Got %d files." % len(files) + return files + + +treenames = { + 0: "Ints", + 1: "Floats", + 2: "Strings", + 3: "TH1Fs", + 4: "TH1Ss", + 5: "TH1Ds", + 6: "TH2Fs", + 7: "TH2Ss", + 8: "TH2Ds", + 9: "TH3Fs", + 10: "TProfiles", + 11: "TProfile2Ds", +} + +maketable = """ + CREATE TABLE IF NOT EXISTS monitorelements ( + name, + fromrun, fromlumi, torun, tolumi, + metype, + value + ); """ +insertinto = """ + INSERT INTO monitorelements ( + name, + fromrun, fromlumi, torun, tolumi, + metype, + value + ) VALUES ( + ?, ?, ?, ?, ?, ?, ? + ); """ + +db = sqlite3.connect(args.output) +db.execute(maketable) +outputqueue = [] + +def insertintodb(): + try: + while True: + rows = outputqueue.pop() + db.executemany(insertinto, rows); + db.commit() + except IndexError: + pass + +def harvestfile(fname): + f = ROOT.TFile.Open("root://eoscms//eos/cms" + fname) + idxtree = getattr(f, "Indices") + #idxtree.GetEntry._threaded = True # now the blocking call should release the GIL... + + # we have no good way to find out which lumis where processed in a job. + # so we watch the per-lumi indices and assume that all mentioned lumis + # are covered in the end-of-job MEs. This might fail if there are no + # per-lumi MEs. + knownlumis = set() + + for i in range(idxtree.GetEntries()): + idxtree.GetEntry(i) + run, lumi, metype = idxtree.Run, idxtree.Lumi, idxtree.Type + if lumi != 0: + knownlumis.add(lumi) + + if not treenames[metype] in interesting_types: + continue + + mes_to_store = [] + + endrun = run # assume no multi-run files for now + if lumi == 0: # per-job ME + endlumi = max(knownlumis) + lumi = min(knownlumis) + else: + endlumi = lumi + + # inclusive range -- for 0 entries, row is left out + firstidx, lastidx = idxtree.FirstIndex, idxtree.LastIndex + metree = getattr(f, treenames[metype]) + + for x in range(firstidx, lastidx+1): + metree.GetEntry(x) + mename = str(metree.FullName) + if mename in interesting_mes: + value = metree.Value + + mes_to_store.append(( + mename, + run, lumi, endrun, endlumi, + metype, + tosqlite(value)), + ) + + print "Processing run %d, lumi %d, type %s, found %d" % (run, lumi, treenames[metype], len(mes_to_store)) + outputqueue.append(mes_to_store) + +def poolexec(func, queue, njobs, mainwork): + class executor(threading.Thread): + def run(self): + try: + # there is no point in checking for empty here, since it might not be atomic + while True: + item = queue.pop() + func(item) + except IndexError: + # queue is drained, all is fine. + pass + workers = [executor() for _ in range(njobs)] + for worker in workers: + worker.start() + while any(w.isAlive() for w in workers): + for worker in workers: + worker.join(0.1) + mainwork() + +files = dasquery(args.dataset) +poolexec(harvestfile, files, args.njobs, insertintodb) + From ddd84b58baaba34a9dff966c5daea7600fe03b87 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 19 Feb 2019 17:09:55 +0100 Subject: [PATCH 600/686] Allow opening remote files, and hack around inf and nan. --- DQMServices/Components/scripts/root2sqlite.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) mode change 100644 => 100755 DQMServices/Components/scripts/root2sqlite.py diff --git a/DQMServices/Components/scripts/root2sqlite.py b/DQMServices/Components/scripts/root2sqlite.py old mode 100644 new mode 100755 index 79e15dc3dad81..318a3e4ce2f05 --- a/DQMServices/Components/scripts/root2sqlite.py +++ b/DQMServices/Components/scripts/root2sqlite.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import re import json import ROOT @@ -10,11 +11,14 @@ parser.add_argument('-o', '--output', help='SQLite file to write', default='root.sqlite') args = parser.parse_args() -f = ROOT.TFile(args.inputfile) +f = ROOT.TFile.Open(args.inputfile) db = sqlite3.connect(args.output) basic_objects = {} +inf = re.compile("([- \[])inf([,}\]])") +nan = re.compile("([- \[])nan([,}\]])") + def tosqlite(x): if isinstance(x, ROOT.string): try: @@ -31,12 +35,12 @@ def tosqlite(x): try: rootobj = unicode(ROOT.TBufferJSON.ConvertToJSON(x)) # turns out ROOT does not generate valid JSON for NaN/inf - obj = json.loads(rootobj) + clean = nan.sub('\\g<1>0\\g<2>', inf.sub('\\g<1>1e38\\g<2>', rootobj)) + obj = json.loads(clean) jsonobj = json.dumps(obj, allow_nan=False) return jsonobj - except: - print x, x.__class__ - return "<%s>" % x + except Exception as e: + return json.dumps({"root2sqlite_error": e.__repr__(), "root2sqlite_object": x.__repr__()}) def columnescape(s): # add whatever is not a valid column name here From 564692579c9a4b775e713eb1789ba03dd49a48f1 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 19 Feb 2019 17:16:42 +0100 Subject: [PATCH 601/686] Remove ineffective threading code --- .../Components/scripts/dqmiodatasetharvest.py | 37 ++----------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index 76c4a6147b94e..b67412b182dea 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -4,14 +4,12 @@ import ROOT import sqlite3 import argparse -import threading import subprocess parser = argparse.ArgumentParser(description="Collect a MEs from DQMIO data, with maximum possible granularity") parser.add_argument('dataset', help='dataset name, like "/StreamHIExpress/HIRun2018A-Express-v1/DQMIO"') parser.add_argument('-o', '--output', help='SQLite file to write', default='dqmio.sqlite') -parser.add_argument('-j', '--njobs', help='Number of threads to read files', type=int, default=1) args = parser.parse_args() @@ -162,16 +160,6 @@ def dasquery(dataset): db = sqlite3.connect(args.output) db.execute(maketable) -outputqueue = [] - -def insertintodb(): - try: - while True: - rows = outputqueue.pop() - db.executemany(insertinto, rows); - db.commit() - except IndexError: - pass def harvestfile(fname): f = ROOT.TFile.Open("root://eoscms//eos/cms" + fname) @@ -220,27 +208,10 @@ def harvestfile(fname): ) print "Processing run %d, lumi %d, type %s, found %d" % (run, lumi, treenames[metype], len(mes_to_store)) - outputqueue.append(mes_to_store) - -def poolexec(func, queue, njobs, mainwork): - class executor(threading.Thread): - def run(self): - try: - # there is no point in checking for empty here, since it might not be atomic - while True: - item = queue.pop() - func(item) - except IndexError: - # queue is drained, all is fine. - pass - workers = [executor() for _ in range(njobs)] - for worker in workers: - worker.start() - while any(w.isAlive() for w in workers): - for worker in workers: - worker.join(0.1) - mainwork() + db.executemany(insertinto, mes_to_store); + db.commit() files = dasquery(args.dataset) -poolexec(harvestfile, files, args.njobs, insertintodb) +for fname in files: + harvestfile(fname) From bbc8ce6beb21f8ab479ef67acf109b5c48a0042e Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 20 Feb 2019 15:26:09 +0100 Subject: [PATCH 602/686] Parallelize using multiprocessing. Since we are mostly io-latency limited, up to -j100 gives useful speedups. Not sure if EOS is happy when people do that. --- .../Components/scripts/dqmiodatasetharvest.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index b67412b182dea..d8276fe3c13a5 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -5,11 +5,14 @@ import sqlite3 import argparse import subprocess +import multiprocessing parser = argparse.ArgumentParser(description="Collect a MEs from DQMIO data, with maximum possible granularity") parser.add_argument('dataset', help='dataset name, like "/StreamHIExpress/HIRun2018A-Express-v1/DQMIO"') parser.add_argument('-o', '--output', help='SQLite file to write', default='dqmio.sqlite') +parser.add_argument('-j', '--njobs', help='Number of threads to read files', type=int, default=1) +parser.add_argument('-l', '--limit', help='Only load up to LIMIT files', type=int, default=-1) args = parser.parse_args() @@ -171,6 +174,7 @@ def harvestfile(fname): # are covered in the end-of-job MEs. This might fail if there are no # per-lumi MEs. knownlumis = set() + mes_to_store = [] for i in range(idxtree.GetEntries()): idxtree.GetEntry(i) @@ -181,7 +185,6 @@ def harvestfile(fname): if not treenames[metype] in interesting_types: continue - mes_to_store = [] endrun = run # assume no multi-run files for now if lumi == 0: # per-job ME @@ -208,10 +211,14 @@ def harvestfile(fname): ) print "Processing run %d, lumi %d, type %s, found %d" % (run, lumi, treenames[metype], len(mes_to_store)) - db.executemany(insertinto, mes_to_store); - db.commit() + + return mes_to_store files = dasquery(args.dataset) -for fname in files: - harvestfile(fname) +if args.limit > 0: files = files[:args.limit] +pool = multiprocessing.Pool(processes=args.njobs) +for mes_to_store in pool.imap_unordered(harvestfile, files): +#for mes_to_store in map(harvestfile, files): + db.executemany(insertinto, mes_to_store); + db.commit() From 6cb76c86876530923705cccc3273f6d34a16100f Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Thu, 21 Feb 2019 11:05:52 +0100 Subject: [PATCH 603/686] Only read the branches that are needed, saves a bit of time --- DQMServices/Components/scripts/dqmiodatasetharvest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index d8276fe3c13a5..9283b21260359 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -196,11 +196,14 @@ def harvestfile(fname): # inclusive range -- for 0 entries, row is left out firstidx, lastidx = idxtree.FirstIndex, idxtree.LastIndex metree = getattr(f, treenames[metype]) + metree.SetBranchStatus("*",0) + metree.SetBranchStatus("FullName",1) for x in range(firstidx, lastidx+1): metree.GetEntry(x) mename = str(metree.FullName) if mename in interesting_mes: + metree.GetEntry(x, 1) value = metree.Value mes_to_store.append(( @@ -210,15 +213,17 @@ def harvestfile(fname): tosqlite(value)), ) - print "Processing run %d, lumi %d, type %s, found %d" % (run, lumi, treenames[metype], len(mes_to_store)) - return mes_to_store files = dasquery(args.dataset) if args.limit > 0: files = files[:args.limit] pool = multiprocessing.Pool(processes=args.njobs) +ctr = 0 for mes_to_store in pool.imap_unordered(harvestfile, files): #for mes_to_store in map(harvestfile, files): db.executemany(insertinto, mes_to_store); db.commit() + ctr += 1 + print "Processed %d files of %d, got %d MEs...\r" % (ctr, len(files), len(mes_to_store)), +print "\nDone." From 0b1c90a404fab2027dda4596c97d40963f6b13ce Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Thu, 21 Feb 2019 16:37:32 +0100 Subject: [PATCH 604/686] Add code for conversion back to TTree --- .../Components/scripts/dqmiodatasetharvest.py | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index 9283b21260359..dff33f2dcf84b 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -102,7 +102,7 @@ def tosqlite(x): except: return buffer(x.data()) if isinstance(x, int): - return x + return x if isinstance(x, float): return x if isinstance(x, long): @@ -160,6 +160,9 @@ def dasquery(dataset): ) VALUES ( ?, ?, ?, ?, ?, ?, ? ); """ +dumpmes = """ + SELECT fromlumi, tolumi, fromrun, name, value FROM monitorelements ORDER BY fromrun, fromlumi ASC; +""" db = sqlite3.connect(args.output) db.execute(maketable) @@ -210,8 +213,8 @@ def harvestfile(fname): mename, run, lumi, endrun, endlumi, metype, - tosqlite(value)), - ) + tosqlite(value), + )) return mes_to_store @@ -227,3 +230,47 @@ def harvestfile(fname): ctr += 1 print "Processed %d files of %d, got %d MEs...\r" % (ctr, len(files), len(mes_to_store)), print "\nDone." + +sqlite2tree = """ +// Convert the sqlite format saved above back into a TTree. +// Saving TTrees with objects (TH1's) seems to be close to impossible in Python, +// so we do the roundtrip via SQLite and JSON in a ROOT macro. +// This needs a ROOT with TBufferJSON::FromJSON, which the 6.12 in CMSSW for +// for now does not have. We can load a newer version from SFT (on lxplus6, +// in (!) a cmsenv): +// source /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.16.00-f8770/x86_64-slc6-gcc8-opt/bin/thisroot.sh +// root sqlite2tree.C +// It is rather slow, but the root file is a lot more compact. + +int run; +int fromlumi; +int tolumi; + +int sqlite2tree() { + + auto sql = TSQLiteServer("sqlite:///tmp/dqmio.sqlite"); + auto query = "SELECT fromlumi, tolumi, fromrun, name, value FROM monitorelements ORDER BY fromrun, fromlumi ASC;"; + auto res = sql.Query(query); + + TFile outfile("/tmp/dqmio.root", "RECREATE"); + auto outtree = new TTree("MEs", "MonitorElements by run and lumisection"); + auto nameb = outtree->Branch("name", &name); + auto valueb = outtree->Branch("value", &value,128*1024,0); + auto runb = outtree->Branch("run", &run); + auto fromlumib = outtree->Branch("fromlumi",&fromlumi); + auto tolumib = outtree->Branch("tolumi", &tolumi); + + + while (auto row = res->Next()) { + fromlumi = atoi(row->GetField(0)); + tolumi = atoi(row->GetField(1)); + run = atoi(row->GetField(2)); + name = new TString(row->GetField(3)); + TBufferJSON::FromJSON(value, row->GetField(4)); + outtree->Fill(); + } + return 0; +} +""" + + From cf9d5583cd56ae985c62d372b2c93af5e07ddc3e Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 6 Mar 2019 17:06:26 +0100 Subject: [PATCH 605/686] Fix a bug in the TTree conversion. No idea why the TH2 pointer needs to be null, but otherwise the object is not always read (many duplicates). --- DQMServices/Components/scripts/dqmiodatasetharvest.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index dff33f2dcf84b..e0ee5d926f575 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -245,14 +245,16 @@ def harvestfile(fname): int run; int fromlumi; int tolumi; +TString* name; +TH2F* value; int sqlite2tree() { - auto sql = TSQLiteServer("sqlite:///tmp/dqmio.sqlite"); + auto sql = TSQLiteServer("sqlite:///dev/shm/schneiml/CMSSW_10_5_0_pre1/src/dqmio.sqlite"); auto query = "SELECT fromlumi, tolumi, fromrun, name, value FROM monitorelements ORDER BY fromrun, fromlumi ASC;"; auto res = sql.Query(query); - TFile outfile("/tmp/dqmio.root", "RECREATE"); + TFile outfile("/dev/shm/dqmio.root", "RECREATE"); auto outtree = new TTree("MEs", "MonitorElements by run and lumisection"); auto nameb = outtree->Branch("name", &name); auto valueb = outtree->Branch("value", &value,128*1024,0); @@ -266,6 +268,7 @@ def harvestfile(fname): tolumi = atoi(row->GetField(1)); run = atoi(row->GetField(2)); name = new TString(row->GetField(3)); + value = nullptr; TBufferJSON::FromJSON(value, row->GetField(4)); outtree->Fill(); } From c6231094dc85d3ca67f9b75a370840512bade735 Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Thu, 7 Mar 2019 12:05:24 +0100 Subject: [PATCH 606/686] Remove the splitlevel=0 option as suggested by @bluehood. This makes the resulting file readable by `RDataFrame`. Also add the index needed for the query in the conversion script to finish in reasonable time. --- DQMServices/Components/scripts/dqmiodatasetharvest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index e0ee5d926f575..57e1b9db29459 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -151,6 +151,9 @@ def dasquery(dataset): metype, value ); """ +makeindex = """ + CREATE INDEX runorder ON monitorelements(fromrun, fromlumi); +""" insertinto = """ INSERT INTO monitorelements ( name, @@ -166,6 +169,7 @@ def dasquery(dataset): db = sqlite3.connect(args.output) db.execute(maketable) +db.execute(makeindex) def harvestfile(fname): f = ROOT.TFile.Open("root://eoscms//eos/cms" + fname) @@ -257,7 +261,7 @@ def harvestfile(fname): TFile outfile("/dev/shm/dqmio.root", "RECREATE"); auto outtree = new TTree("MEs", "MonitorElements by run and lumisection"); auto nameb = outtree->Branch("name", &name); - auto valueb = outtree->Branch("value", &value,128*1024,0); + auto valueb = outtree->Branch("value", &value,128*1024); auto runb = outtree->Branch("run", &run); auto fromlumib = outtree->Branch("fromlumi",&fromlumi); auto tolumib = outtree->Branch("tolumi", &tolumi); From 897ef161468156a33766cb4fc235d3d29f312755 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Fri, 12 Apr 2019 11:58:48 +0200 Subject: [PATCH 607/686] Use python3 print. --- DQMServices/Components/scripts/dqmiodatasetharvest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index 57e1b9db29459..f7a05623df7ef 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import re import json import ROOT @@ -122,10 +123,10 @@ def dasquery(dataset): if not dataset.endswith("DQMIO"): raise Exception("This tool probably cannot read the dataset you specified. The name should end with DQMIO.") dasquery = ["dasgoclient", "-query=file dataset=%s" % dataset] - print "Querying das ... %s" % dasquery + print("Querying das ... %s" % dasquery) files = subprocess.check_output(dasquery) files = files.splitlines() - print "Got %d files." % len(files) + print("Got %d files." % len(files)) return files @@ -232,8 +233,8 @@ def harvestfile(fname): db.executemany(insertinto, mes_to_store); db.commit() ctr += 1 - print "Processed %d files of %d, got %d MEs...\r" % (ctr, len(files), len(mes_to_store)), -print "\nDone." + print("Processed %d files of %d, got %d MEs...\r" % (ctr, len(files), len(mes_to_store)), end='') +print("\nDone.") sqlite2tree = """ // Convert the sqlite format saved above back into a TTree. From 0abd3db9f62effc1920591e007504cc8f02d7b01 Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 00:40:23 +0200 Subject: [PATCH 608/686] update MC GTs in 106X --- Configuration/AlCa/python/autoCond.py | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 4a684dcd3bfef..3cf49ac4d500a 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -2,27 +2,27 @@ ### NEW KEYS ### # GlobalTag for MC production with perfectly aligned and calibrated detector for Run1 - 'run1_design' : '105X_mcRun1_design_v1', + 'run1_design' : '106X_mcRun1_design_v1', # GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1 - 'run1_mc' : '105X_mcRun1_realistic_v1', + 'run1_mc' : '106X_mcRun1_realistic_v1', # GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_hi' : '105X_mcRun1_HeavyIon_v1', + 'run1_mc_hi' : '106X_mcRun1_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 - 'run1_mc_pa' : '105X_mcRun1_pA_v1', + 'run1_mc_pa' : '106X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '105X_mcRun2_startup_v2', + 'run2_mc_50ns' : '106X_mcRun2_startup_v1', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '105X_mcRun2_asymptotic_l1stage1_v2', + 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '105X_mcRun2_design_v3', + 'run2_design' : '106X_mcRun2_design_v2', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '105X_mcRun2_asymptotic_v4', + 'run2_mc' : '106X_mcRun2_asymptotic_v1', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '105X_mcRun2cosmics_startup_deco_v4', + 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '105X_mcRun2_HeavyIon_v2', + 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v1', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '105X_mcRun2_pA_v2', + 'run2_mc_pa' : '106X_mcRun2_pA_v1', # GlobalTag for Run1 data reprocessing 'run1_data' : '106X_dataRun2_v4', # GlobalTag for Run2 data reprocessing @@ -44,31 +44,31 @@ # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v2', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v3', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '106X_mc2017_realistic_v1', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v2', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '106X_upgrade2018_design_v1', + 'phase1_2018_design' : '106X_upgrade2018_design_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v1', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v1', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '106X_postLS2_design_v1', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '106X_postLS2_realistic_v1', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v3', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '105X_upgrade2023_realistic_v5' + 'phase2_realistic' : '106X_upgrade2023_realistic_v1' } aliases = { From be65eed24a69f34577dd13cdb54351ac55561035 Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 01:50:23 +0200 Subject: [PATCH 609/686] update tracker mis-alignment scenario for 2018 cosmics simulation --- Configuration/AlCa/python/autoCond.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 3cf49ac4d500a..26d508188f167 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -60,9 +60,9 @@ # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 From 8627442d52aea54374b925ea2a4b56f4f41a843c Mon Sep 17 00:00:00 2001 From: tocheng Date: Wed, 10 Apr 2019 05:45:23 +0200 Subject: [PATCH 610/686] Fix JEC in 2017 and 2018 --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 26d508188f167..86311827f1160 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -16,7 +16,7 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 'run2_design' : '106X_mcRun2_design_v2', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '106X_mcRun2_asymptotic_v1', + 'run2_mc' : '106X_mcRun2_asymptotic_v2', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 @@ -54,11 +54,11 @@ # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) 'phase1_2018_design' : '106X_upgrade2018_design_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v2', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v2', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v3', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode From 70a736da96e8ab45ca2f016cb9d89dc090163795 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 11 Apr 2019 06:38:59 +0200 Subject: [PATCH 611/686] update LHCinfo and HLT PF calibration --- Configuration/AlCa/python/autoCond.py | 62 +++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 86311827f1160..4bd96b98c27cd 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -10,65 +10,65 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1 'run1_mc_pa' : '106X_mcRun1_pA_v1', # GlobalTag for MC production with pessimistic alignment and calibrations for Run2 - 'run2_mc_50ns' : '106X_mcRun2_startup_v1', + 'run2_mc_50ns' : '106X_mcRun2_startup_v2', # GlobalTag for MC production (L1 Trigger Stage1) with starup-like alignment and calibrations for Run2, L1 trigger in Stage1 mode - 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v1', + 'run2_mc_l1stage1' : '106X_mcRun2_asymptotic_l1stage1_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for Run2 - 'run2_design' : '106X_mcRun2_design_v2', + 'run2_design' : '106X_mcRun2_design_v3', #GlobalTag for MC production with optimistic alignment and calibrations for Run2 - 'run2_mc' : '106X_mcRun2_asymptotic_v2', + 'run2_mc' : '106X_mcRun2_asymptotic_v3', # GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode - 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v1', + 'run2_mc_cosmics' : '106X_mcRun2cosmics_startup_deco_v2', # GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2 - 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v1', + 'run2_mc_hi' : '106X_mcRun2_HeavyIon_v2', # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 - 'run2_mc_pa' : '106X_mcRun2_pA_v1', + 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v4', + 'run1_data' : '106X_dataRun2_v5', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v4', + 'run2_data' : '106X_dataRun2_v5', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v2', + 'run2_data_relval' : '106X_dataRun2_relval_v3', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v1', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v1', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v2', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v2', # GlobalTag for Run1 HLT: it points to the online GT - 'run1_hlt' : '101X_dataRun2_HLT_frozen_v8', + 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT - 'run2_hlt' : '101X_dataRun2_HLT_frozen_v8', + 'run2_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT RelVals: customizations to run with fixed L1 Menu - 'run2_hlt_relval' : '103X_dataRun2_HLT_relval_v7', - 'run2_hlt_relval_hi' : '103X_dataRun2_HLT_relval_HI_v3', + 'run2_hlt_relval' : '103X_dataRun2_HLT_relval_v8', + 'run2_hlt_relval_hi' : '103X_dataRun2_HLT_relval_HI_v4', # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT - 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', + 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v9', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v3', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v4', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '106X_mc2017_realistic_v2', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v3', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', + 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v2', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', + 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v2', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '106X_upgrade2018_design_v2', + 'phase1_2018_design' : '106X_upgrade2018_design_v3', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v3', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v4', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', + 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v2', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v3', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v4', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v2', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v3', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v2', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v3', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '106X_postLS2_design_v3', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v4', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '106X_postLS2_realistic_v3', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v4', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 - 'phase2_realistic' : '106X_upgrade2023_realistic_v1' + 'phase2_realistic' : '106X_upgrade2023_realistic_v2' } aliases = { From 2dbb0c33399b3478e620c1ec624c0f045f2edc78 Mon Sep 17 00:00:00 2001 From: tocheng Date: Thu, 11 Apr 2019 22:32:10 +0200 Subject: [PATCH 612/686] update Run-2 2016-2018 data JEC/JER --- Configuration/AlCa/python/autoCond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 4bd96b98c27cd..57cd8de8df124 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,11 +24,11 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v5', + 'run1_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v5', + 'run2_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v3', + 'run2_data_relval' : '106X_dataRun2_relval_v4', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) From 967250ae9f534874c2b6aa6a4908003c88a8e410 Mon Sep 17 00:00:00 2001 From: tocheng Date: Fri, 12 Apr 2019 12:35:45 +0200 Subject: [PATCH 613/686] Fix PPS Geometry and add LHC optical function --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 57cd8de8df124..eca796b48b005 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v6', + 'run1_data' : '106X_dataRun2_v7', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v6', + 'run2_data' : '106X_dataRun2_v7', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v4', + 'run2_data_relval' : '106X_dataRun2_relval_v5', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v3', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v2', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v2', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v3', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v3', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT From 80b040b2198e7a681cbee52492f5524fa883eb17 Mon Sep 17 00:00:00 2001 From: david walter Date: Fri, 12 Apr 2019 15:31:44 +0200 Subject: [PATCH 614/686] give vector of strings by reference instead of by value --- DQMOffline/Lumi/interface/TTrigger.h | 2 +- DQMOffline/Lumi/src/TTrigger.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DQMOffline/Lumi/interface/TTrigger.h b/DQMOffline/Lumi/interface/TTrigger.h index 1c7ab4d570ec6..520ad1967e2e0 100644 --- a/DQMOffline/Lumi/interface/TTrigger.h +++ b/DQMOffline/Lumi/interface/TTrigger.h @@ -9,7 +9,7 @@ namespace ZCountingTrigger class TTrigger { public: - TTrigger(std::vector, std::vector); + TTrigger(const std::vector &muonTriggerNames, const std::vector &muonTriggerObjectNames); ~TTrigger(){} // Methods diff --git a/DQMOffline/Lumi/src/TTrigger.cc b/DQMOffline/Lumi/src/TTrigger.cc index 2a7df43ebeb62..505e2b0972ade 100644 --- a/DQMOffline/Lumi/src/TTrigger.cc +++ b/DQMOffline/Lumi/src/TTrigger.cc @@ -22,7 +22,7 @@ using namespace ZCountingTrigger; // the trigger can evolve and obtain a different trigger object name, but we still want this to // be associated with the same leg (e.g. the trailing electron in a dielectron trigger) // -TTrigger::TTrigger(std::vector muonTriggerNames, std::vector muonTriggerObjectNames) { +TTrigger::TTrigger(const std::vector &muonTriggerNames, const std::vector &muonTriggerObjectNames) { for(unsigned int i = 0; i < muonTriggerNames.size(); ++i){ fRecords.push_back(ZCountingTrigger::TriggerRecord(muonTriggerNames.at(i),0)); From 1a913cb96f2282efed2f3839d38237d1309a070f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 12 Apr 2019 16:09:18 +0200 Subject: [PATCH 615/686] Clean up the prints and make it conform clang --- SimG4CMS/Calo/interface/CaloG4Hit.h | 135 +- SimG4CMS/Calo/interface/CaloG4HitCollection.h | 1 - SimG4CMS/Calo/interface/CaloGVHit.h | 86 +- SimG4CMS/Calo/interface/CaloHit.h | 1 - SimG4CMS/Calo/interface/CaloHitID.h | 47 +- SimG4CMS/Calo/interface/CaloMeanResponse.h | 28 +- SimG4CMS/Calo/interface/CaloSD.h | 189 +- SimG4CMS/Calo/interface/CaloSteppingAction.h | 67 +- SimG4CMS/Calo/interface/CaloTrkProcessing.h | 81 +- SimG4CMS/Calo/interface/ECalSD.h | 84 +- .../Calo/interface/EnergyResolutionVsLumi.h | 37 +- SimG4CMS/Calo/interface/EvolutionECAL.h | 35 +- SimG4CMS/Calo/interface/HCalSD.h | 154 +- SimG4CMS/Calo/interface/HFCherenkov.h | 91 +- SimG4CMS/Calo/interface/HFDarkening.h | 16 +- SimG4CMS/Calo/interface/HFFibre.h | 35 +- SimG4CMS/Calo/interface/HFFibreFiducial.h | 2 +- SimG4CMS/Calo/interface/HFGflash.h | 49 +- .../Calo/interface/HFNoseNumberingScheme.h | 10 +- SimG4CMS/Calo/interface/HFNoseSD.h | 56 +- SimG4CMS/Calo/interface/HFShower.h | 50 +- SimG4CMS/Calo/interface/HFShowerFibreBundle.h | 43 +- SimG4CMS/Calo/interface/HFShowerLibrary.h | 71 +- SimG4CMS/Calo/interface/HFShowerPMT.h | 46 +- SimG4CMS/Calo/interface/HFShowerParam.h | 60 +- SimG4CMS/Calo/interface/HGCMouseBite.h | 27 +- SimG4CMS/Calo/interface/HGCNumberingScheme.h | 10 +- SimG4CMS/Calo/interface/HGCSD.h | 67 +- SimG4CMS/Calo/interface/HGCScintSD.h | 52 +- .../Calo/interface/HGCalNumberingScheme.h | 19 +- SimG4CMS/Calo/interface/HGCalSD.h | 58 +- SimG4CMS/Calo/interface/HcalNumberingFromPS.h | 21 +- SimG4CMS/Calo/interface/HcalNumberingScheme.h | 2 - SimG4CMS/Calo/interface/HcalQie.h | 41 +- SimG4CMS/Calo/interface/HcalTestAnalysis.h | 71 +- SimG4CMS/Calo/interface/HcalTestHistoClass.h | 1 - .../Calo/interface/HcalTestHistoManager.h | 18 +- SimG4CMS/Calo/interface/HcalTestNS.h | 10 +- .../Calo/interface/HcalTestNumberingScheme.h | 9 +- SimG4CMS/Calo/plugins/module.cc | 5 +- SimG4CMS/Calo/src/CaloG4Hit.cc | 72 +- SimG4CMS/Calo/src/CaloGVHit.cc | 39 +- SimG4CMS/Calo/src/CaloHitID.cc | 80 +- SimG4CMS/Calo/src/CaloMeanResponse.cc | 162 +- SimG4CMS/Calo/src/CaloSD.cc | 814 +++-- SimG4CMS/Calo/src/CaloSteppingAction.cc | 359 +-- SimG4CMS/Calo/src/CaloTrkProcessing.cc | 498 ++- SimG4CMS/Calo/src/ECalSD.cc | 434 ++- SimG4CMS/Calo/src/EnergyResolutionVsLumi.cc | 210 +- SimG4CMS/Calo/src/EvolutionECAL.cc | 390 ++- SimG4CMS/Calo/src/HCalSD.cc | 976 +++--- SimG4CMS/Calo/src/HFCherenkov.cc | 527 ++-- SimG4CMS/Calo/src/HFDarkening.cc | 61 +- SimG4CMS/Calo/src/HFFibre.cc | 192 +- SimG4CMS/Calo/src/HFFibreFiducial.cc | 2722 ++++++++--------- SimG4CMS/Calo/src/HFGflash.cc | 421 +-- SimG4CMS/Calo/src/HFNoseNumberingScheme.cc | 44 +- SimG4CMS/Calo/src/HFNoseSD.cc | 235 +- SimG4CMS/Calo/src/HFShower.cc | 476 ++- SimG4CMS/Calo/src/HFShowerFibreBundle.cc | 181 +- SimG4CMS/Calo/src/HFShowerLibrary.cc | 697 ++--- SimG4CMS/Calo/src/HFShowerPMT.cc | 164 +- SimG4CMS/Calo/src/HFShowerParam.cc | 410 ++- SimG4CMS/Calo/src/HGCMouseBite.cc | 47 +- SimG4CMS/Calo/src/HGCNumberingScheme.cc | 67 +- SimG4CMS/Calo/src/HGCSD.cc | 245 +- SimG4CMS/Calo/src/HGCScintSD.cc | 226 +- SimG4CMS/Calo/src/HGCalNumberingScheme.cc | 155 +- SimG4CMS/Calo/src/HGCalSD.cc | 249 +- SimG4CMS/Calo/src/HcalNumberingFromPS.cc | 189 +- SimG4CMS/Calo/src/HcalNumberingScheme.cc | 29 +- SimG4CMS/Calo/src/HcalQie.cc | 399 ++- SimG4CMS/Calo/src/HcalTestAnalysis.cc | 678 ++-- SimG4CMS/Calo/src/HcalTestHistoManager.cc | 46 +- SimG4CMS/Calo/src/HcalTestNS.cc | 22 +- SimG4CMS/Calo/src/HcalTestNumberingScheme.cc | 51 +- SimG4CMS/Calo/test/CaloSimHitStudy.cc | 660 ++-- SimG4CMS/Calo/test/EcalSimHitStudy.cc | 394 ++- SimG4CMS/Calo/test/HFPMTHitAnalyzer.cc | 370 +-- SimG4CMS/Calo/test/HOSimHitStudy.cc | 896 +++--- SimG4CMS/Calo/test/HcalSimHitDump.cc | 95 +- SimG4CMS/Calo/test/HcalTestNumberingTest.cc | 68 +- SimG4CMS/Calo/test/HitParentTest.cc | 502 +-- 83 files changed, 8353 insertions(+), 9084 deletions(-) diff --git a/SimG4CMS/Calo/interface/CaloG4Hit.h b/SimG4CMS/Calo/interface/CaloG4Hit.h index ab4e5d404113a..55e22de003429 100644 --- a/SimG4CMS/Calo/interface/CaloG4Hit.h +++ b/SimG4CMS/Calo/interface/CaloG4Hit.h @@ -3,7 +3,7 @@ /////////////////////////////////////////////////////////////////////////////// // File: CaloG4Hit.h // Date: 10.02 Taken from CMSCaloHit -// +// // Hit class for Calorimeters (Ecal, Hcal, ...) // // One Hit object should be created @@ -14,16 +14,15 @@ // This implies that all hit objects created for a given shower // have the same value for // - Entry (= local coordinates of the entrance point of the particle -// in the unit where the shower starts) +// in the unit where the shower starts) // - the TrackID (= Identification number of the incident particle) // - the IncidentEnergy (= energy of that particle) // -// Modified: +// Modified: // /////////////////////////////////////////////////////////////////////////////// #include "SimG4CMS/Calo/interface/CaloHitID.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Math/interface/Point3D.h" #include @@ -31,71 +30,67 @@ #include "G4VHit.hh" class CaloG4Hit : public G4VHit { - public: - CaloG4Hit(); ~CaloG4Hit() override; - CaloG4Hit(const CaloG4Hit &right); - const CaloG4Hit& operator=(const CaloG4Hit &right); - bool operator==(const CaloG4Hit &){return false;} - inline void * operator new(size_t); - inline void operator delete(void * CaloG4Hit); - - void Draw() override{} - void Print() override; - + CaloG4Hit(const CaloG4Hit& right); + const CaloG4Hit& operator=(const CaloG4Hit& right); + bool operator==(const CaloG4Hit&) { return false; } + inline void* operator new(size_t); + inline void operator delete(void* CaloG4Hit); + + void Draw() override {} + void Print() override; + public: - - math::XYZPoint getEntry() const {return entry;} - void setEntry(double x, double y, double z) {entry.SetCoordinates(x,y,z);} - - math::XYZPoint getEntryLocal() const {return entryLocal;} - void setEntryLocal(double x, double y, double z) {entryLocal.SetCoordinates(x,y,z);} - - math::XYZPoint getPosition() const {return pos;} - void setPosition(double x, double y, double z) {pos.SetCoordinates(x,y,z);} - - double getEM() const {return elem;} - void setEM (double e) {elem = e;} - - double getHadr() const {return hadr;} - void setHadr (double e) {hadr = e;} - - double getIncidentEnergy() const {return theIncidentEnergy;} - void setIncidentEnergy (double e) {theIncidentEnergy = e;} - - int getTrackID() const {return hitID.trackID();} - uint32_t getUnitID() const {return hitID.unitID();} - double getTimeSlice() const {return hitID.timeSlice();} - int getTimeSliceID() const {return hitID.timeSliceID();} - uint16_t getDepth() const {return hitID.depth();} - - CaloHitID getID() const {return hitID;} - void setID (uint32_t i, double d, int j, uint16_t k=0) { hitID.setID(i,d,j,k);} - void setID (const CaloHitID& id) {hitID = id;} - - void addEnergyDeposit(double em, double hd); - void addEnergyDeposit(const CaloG4Hit& aHit); - - double getEnergyDeposit() const {return (elem+hadr);} - + math::XYZPoint getEntry() const { return entry; } + void setEntry(double x, double y, double z) { entry.SetCoordinates(x, y, z); } + + math::XYZPoint getEntryLocal() const { return entryLocal; } + void setEntryLocal(double x, double y, double z) { entryLocal.SetCoordinates(x, y, z); } + + math::XYZPoint getPosition() const { return pos; } + void setPosition(double x, double y, double z) { pos.SetCoordinates(x, y, z); } + + double getEM() const { return elem; } + void setEM(double e) { elem = e; } + + double getHadr() const { return hadr; } + void setHadr(double e) { hadr = e; } + + double getIncidentEnergy() const { return theIncidentEnergy; } + void setIncidentEnergy(double e) { theIncidentEnergy = e; } + + int getTrackID() const { return hitID.trackID(); } + uint32_t getUnitID() const { return hitID.unitID(); } + double getTimeSlice() const { return hitID.timeSlice(); } + int getTimeSliceID() const { return hitID.timeSliceID(); } + uint16_t getDepth() const { return hitID.depth(); } + + CaloHitID getID() const { return hitID; } + void setID(uint32_t i, double d, int j, uint16_t k = 0) { hitID.setID(i, d, j, k); } + void setID(const CaloHitID& id) { hitID = id; } + + void addEnergyDeposit(double em, double hd); + void addEnergyDeposit(const CaloG4Hit& aHit); + + double getEnergyDeposit() const { return (elem + hadr); } + private: - - math::XYZPoint entry; //Entry point (Global coordinate) - math::XYZPoint entryLocal; //Entry point (Local coordinate) - math::XYZPoint pos; //Position (Global coordinate) - double elem; //EnergyDeposit of EM particles - double hadr; //EnergyDeposit of HD particles - double theIncidentEnergy; //Energy of the primary particle - CaloHitID hitID; //Identification number of the hit given - //by primary particle, Cell ID, Time of - //the hit + math::XYZPoint entry; //Entry point (Global coordinate) + math::XYZPoint entryLocal; //Entry point (Local coordinate) + math::XYZPoint pos; //Position (Global coordinate) + double elem; //EnergyDeposit of EM particles + double hadr; //EnergyDeposit of HD particles + double theIncidentEnergy; //Energy of the primary particle + CaloHitID hitID; //Identification number of the hit given + //by primary particle, Cell ID, Time of + //the hit }; class CaloG4HitLess { public: - bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) { + bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) { if (a->getTrackID() != b->getTrackID()) { return (a->getTrackID() < b->getTrackID()); } else if (a->getUnitID() != b->getUnitID()) { @@ -110,25 +105,21 @@ class CaloG4HitLess { class CaloG4HitEqual { public: - bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) { - return (a->getTrackID() == b->getTrackID() && - a->getUnitID() == b->getUnitID() && - a->getDepth() == b->getDepth() && - a->getTimeSliceID() == b->getTimeSliceID()); + bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) { + return (a->getTrackID() == b->getTrackID() && a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() && + a->getTimeSliceID() == b->getTimeSliceID()); } }; -extern G4ThreadLocal G4Allocator *fpCaloG4HitAllocator; +extern G4ThreadLocal G4Allocator* fpCaloG4HitAllocator; -inline void * CaloG4Hit::operator new(size_t) { - if (!fpCaloG4HitAllocator) fpCaloG4HitAllocator = - new G4Allocator; +inline void* CaloG4Hit::operator new(size_t) { + if (!fpCaloG4HitAllocator) + fpCaloG4HitAllocator = new G4Allocator; return (void*)fpCaloG4HitAllocator->MallocSingle(); } -inline void CaloG4Hit::operator delete(void * aHit) { - fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*) aHit); -} +inline void CaloG4Hit::operator delete(void* aHit) { fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*)aHit); } std::ostream& operator<<(std::ostream&, const CaloG4Hit&); diff --git a/SimG4CMS/Calo/interface/CaloG4HitCollection.h b/SimG4CMS/Calo/interface/CaloG4HitCollection.h index 9abfe6bc62358..c7f766896701a 100644 --- a/SimG4CMS/Calo/interface/CaloG4HitCollection.h +++ b/SimG4CMS/Calo/interface/CaloG4HitCollection.h @@ -11,4 +11,3 @@ typedef G4THitsCollection CaloG4HitCollection; #endif - diff --git a/SimG4CMS/Calo/interface/CaloGVHit.h b/SimG4CMS/Calo/interface/CaloGVHit.h index 04221ef374c12..1f9fb49b1064c 100644 --- a/SimG4CMS/Calo/interface/CaloGVHit.h +++ b/SimG4CMS/Calo/interface/CaloGVHit.h @@ -3,7 +3,7 @@ /////////////////////////////////////////////////////////////////////////////// // File: CaloGVHit.h // Date: 10.02 Taken from CMSCaloHit -// +// // Hit class for Calorimeters (Ecal, Hcal, ...) // // One Hit object should be created @@ -14,11 +14,11 @@ // This implies that all hit objects created for a given shower // have the same value for // - Entry (= local coordinates of the entrance point of the particle -// in the unit where the shower starts) +// in the unit where the shower starts) // - the TrackID (= Identification number of the incident particle) // - the IncidentEnergy (= energy of that particle) // -// Modified: +// Modified: // /////////////////////////////////////////////////////////////////////////////// @@ -28,54 +28,50 @@ #include class CaloGVHit { - public: - CaloGVHit(); ~CaloGVHit(); - CaloGVHit(const CaloGVHit &right); - const CaloGVHit& operator=(const CaloGVHit &right); - bool operator==(const CaloGVHit &){return false;} - + CaloGVHit(const CaloGVHit& right); + const CaloGVHit& operator=(const CaloGVHit& right); + bool operator==(const CaloGVHit&) { return false; } + public: - - inline double getEM() const {return elem_;} - inline void setEM (double e) {elem_ = e;} - - inline double getHadr() const {return hadr_;} - inline void setHadr (double e) {hadr_ = e;} - - inline int getEventID() const {return eventID_;} - inline void setEventID(int id) {eventID_ = id;} + inline double getEM() const { return elem_; } + inline void setEM(double e) { elem_ = e; } + + inline double getHadr() const { return hadr_; } + inline void setHadr(double e) { hadr_ = e; } + + inline int getEventID() const { return eventID_; } + inline void setEventID(int id) { eventID_ = id; } + + inline int getTrackID() const { return hitID_.trackID(); } + inline uint32_t getUnitID() const { return hitID_.unitID(); } + inline double getTimeSlice() const { return hitID_.timeSlice(); } + inline int getTimeSliceID() const { return hitID_.timeSliceID(); } + inline uint16_t getDepth() const { return hitID_.depth(); } + + inline CaloHitID getID() const { return hitID_; } + inline void setID(uint32_t i, double d, int j, uint16_t k = 0) { hitID_.setID(i, d, j, k); } + inline void setID(const CaloHitID& id) { hitID_ = id; } + + void addEnergyDeposit(double em, double hd); + void addEnergyDeposit(const CaloGVHit& aHit); - inline int getTrackID() const {return hitID_.trackID();} - inline uint32_t getUnitID() const {return hitID_.unitID();} - inline double getTimeSlice() const {return hitID_.timeSlice();} - inline int getTimeSliceID() const {return hitID_.timeSliceID();} - inline uint16_t getDepth() const {return hitID_.depth();} + inline double getEnergyDeposit() const { return (elem_ + hadr_); } - inline CaloHitID getID() const {return hitID_;} - inline void setID (uint32_t i, double d, int j, uint16_t k=0) { - hitID_.setID(i,d,j,k);} - inline void setID (const CaloHitID& id) {hitID_ = id;} - - void addEnergyDeposit(double em, double hd); - void addEnergyDeposit(const CaloGVHit& aHit); - - inline double getEnergyDeposit() const {return (elem_+hadr_);} - private: - int eventID_; //Event ID - double elem_; //EnergyDeposit of EM particles - double hadr_; //EnergyDeposit of HD particles - CaloHitID hitID_; //Identification number of the hit given - //by primary particle, Cell ID, Time of - //the hit + int eventID_; //Event ID + double elem_; //EnergyDeposit of EM particles + double hadr_; //EnergyDeposit of HD particles + CaloHitID hitID_; //Identification number of the hit given + //by primary particle, Cell ID, Time of + //the hit }; class CaloGVHitLess { public: - inline bool operator()( const CaloGVHit* a, const CaloGVHit* b) { + inline bool operator()(const CaloGVHit* a, const CaloGVHit* b) { if (a->getEventID() != b->getEventID()) { return (a->getEventID() < b->getEventID()); } else if (a->getTrackID() != b->getTrackID()) { @@ -92,12 +88,10 @@ class CaloGVHitLess { class CaloGVHitEqual { public: - inline bool operator()( const CaloGVHit* a, const CaloGVHit* b) { - return (a->getEventID() == b->getEventID() && - a->getTrackID() == b->getTrackID() && - a->getUnitID() == b->getUnitID() && - a->getDepth() == b->getDepth() && - a->getTimeSliceID() == b->getTimeSliceID()); + inline bool operator()(const CaloGVHit* a, const CaloGVHit* b) { + return (a->getEventID() == b->getEventID() && a->getTrackID() == b->getTrackID() && + a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() && + a->getTimeSliceID() == b->getTimeSliceID()); } }; diff --git a/SimG4CMS/Calo/interface/CaloHit.h b/SimG4CMS/Calo/interface/CaloHit.h index ac677215ccdcd..32ad1b44bbbc8 100644 --- a/SimG4CMS/Calo/interface/CaloHit.h +++ b/SimG4CMS/Calo/interface/CaloHit.h @@ -1,2 +1 @@ #include "SimDataFormats/CaloHit/interface/CaloHit.h" - diff --git a/SimG4CMS/Calo/interface/CaloHitID.h b/SimG4CMS/Calo/interface/CaloHitID.h index 03fd582067249..5f644f93d6421 100644 --- a/SimG4CMS/Calo/interface/CaloHitID.h +++ b/SimG4CMS/Calo/interface/CaloHitID.h @@ -9,39 +9,34 @@ #include class CaloHitID { - public: - - CaloHitID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0, - float tSlice=1, bool ignoreTkID=false); - CaloHitID(float tSlice=1, bool ignoreTkID=false); + CaloHitID( + uint32_t unitID, double timeSlice, int trackID, uint16_t depth = 0, float tSlice = 1, bool ignoreTkID = false); + CaloHitID(float tSlice = 1, bool ignoreTkID = false); CaloHitID(const CaloHitID&); const CaloHitID& operator=(const CaloHitID&); virtual ~CaloHitID(); - uint32_t unitID() const {return theUnitID;} - int timeSliceID() const {return theTimeSliceID;} - double timeSlice() const {return theTimeSlice;} - int trackID() const {return theTrackID;} - uint16_t depth() const {return theDepth;} - void setID(uint32_t unitID, double timeSlice, int trackID, - uint16_t depth=0); - void reset(); + uint32_t unitID() const { return theUnitID; } + int timeSliceID() const { return theTimeSliceID; } + double timeSlice() const { return theTimeSlice; } + int trackID() const { return theTrackID; } + uint16_t depth() const { return theDepth; } + void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth = 0); + void reset(); - bool operator==(const CaloHitID& ) const; - bool operator<(const CaloHitID& ) const; - bool operator>(const CaloHitID& ) const; - -private: - - uint32_t theUnitID; - double theTimeSlice; - int theTrackID; - int theTimeSliceID; - uint16_t theDepth; - float timeSliceUnit; - bool ignoreTrackID; + bool operator==(const CaloHitID&) const; + bool operator<(const CaloHitID&) const; + bool operator>(const CaloHitID&) const; +private: + uint32_t theUnitID; + double theTimeSlice; + int theTrackID; + int theTimeSliceID; + uint16_t theDepth; + float timeSliceUnit; + bool ignoreTrackID; }; std::ostream& operator<<(std::ostream&, const CaloHitID&); diff --git a/SimG4CMS/Calo/interface/CaloMeanResponse.h b/SimG4CMS/Calo/interface/CaloMeanResponse.h index fbafdfecfb0de..dd6c9b9f206fb 100644 --- a/SimG4CMS/Calo/interface/CaloMeanResponse.h +++ b/SimG4CMS/Calo/interface/CaloMeanResponse.h @@ -8,24 +8,20 @@ #include class CaloMeanResponse { - -public: - - CaloMeanResponse(edm::ParameterSet const & p); +public: + CaloMeanResponse(edm::ParameterSet const& p); virtual ~CaloMeanResponse(); - double getWeight(int genPID, double genP); + double getWeight(int genPID, double genP); private: - - void readResponse (std::string fName); - - bool useTable; - double scale; - int piLast, pLast; - std::vector pionTypes, protonTypes; - std::vector pionMomentum, pionTable; - std::vector protonMomentum, protonTable; - + void readResponse(std::string fName); + + bool useTable; + double scale; + int piLast, pLast; + std::vector pionTypes, protonTypes; + std::vector pionMomentum, pionTable; + std::vector protonMomentum, protonTable; }; -#endif // SimG4CMS_CaloMeanResponse_h +#endif // SimG4CMS_CaloMeanResponse_h diff --git a/SimG4CMS/Calo/interface/CaloSD.h b/SimG4CMS/Calo/interface/CaloSD.h index 030c763f8a05b..97072b10b8eb7 100644 --- a/SimG4CMS/Calo/interface/CaloSD.h +++ b/SimG4CMS/Calo/interface/CaloSD.h @@ -20,7 +20,7 @@ #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - + #include "G4VPhysicalVolume.hh" #include "G4Track.hh" #include "G4VGFlashSensitiveDetector.hh" @@ -34,70 +34,69 @@ class CaloSlaveSD; class G4GFlashSpot; class SimTrackManager; -class CaloSD : public SensitiveCaloDetector, +class CaloSD : public SensitiveCaloDetector, public G4VGFlashSensitiveDetector, - public Observer, - public Observer, - public Observer, - public Observer, - public Observer { - -public: - - CaloSD(const std::string& aSDname, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager*, - float timeSlice=1., bool ignoreTkID=false); + public Observer, + public Observer, + public Observer, + public Observer, + public Observer { +public: + CaloSD(const std::string& aSDname, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager*, + float timeSlice = 1., + bool ignoreTkID = false); ~CaloSD() override; - G4bool ProcessHits(G4Step * step, G4TouchableHistory *) override; - bool ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) override; + G4bool ProcessHits(G4Step* step, G4TouchableHistory*) override; + bool ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) override; - uint32_t setDetUnitId(const G4Step* step) override =0; - - void Initialize(G4HCofThisEvent * HCE) override; - void EndOfEvent(G4HCofThisEvent * eventHC) override; - void clear() override; - void DrawAll() override; - void PrintAll() override; + uint32_t setDetUnitId(const G4Step* step) override = 0; - void clearHits() override; - void fillHits(edm::PCaloHitContainer&, const std::string&) override; + void Initialize(G4HCofThisEvent* HCE) override; + void EndOfEvent(G4HCofThisEvent* eventHC) override; + void clear() override; + void DrawAll() override; + void PrintAll() override; -protected: + void clearHits() override; + void fillHits(edm::PCaloHitContainer&, const std::string&) override; - virtual double getEnergyDeposit(const G4Step* step); - virtual bool getFromLibrary(const G4Step* step); - - G4ThreeVector setToLocal(const G4ThreeVector&, const G4VTouchable*) const; - G4ThreeVector setToGlobal(const G4ThreeVector&, const G4VTouchable*) const; - - bool hitExists(const G4Step*); - bool checkHit(); - CaloG4Hit* createNewHit(const G4Step*); - void updateHit(CaloG4Hit*); - void resetForNewPrimary(const G4Step*); - double getAttenuation(const G4Step* aStep, double birk1, double birk2, - double birk3) const; - - void update(const BeginOfRun *) override; - void update(const BeginOfEvent *) override; - void update(const BeginOfTrack * trk) override; - void update(const EndOfTrack * trk) override; - void update(const ::EndOfEvent *) override; - virtual void initRun(); - virtual void initEvent(const BeginOfEvent *); - virtual void endEvent(); - virtual bool filterHit(CaloG4Hit*, double); - - virtual int getTrackID(const G4Track*); - virtual int setTrackID(const G4Step*); - virtual uint16_t getDepth(const G4Step*); - double getResponseWt(const G4Track*); - int getNumberOfHits(); +protected: + virtual double getEnergyDeposit(const G4Step* step); + virtual bool getFromLibrary(const G4Step* step); + + G4ThreeVector setToLocal(const G4ThreeVector&, const G4VTouchable*) const; + G4ThreeVector setToGlobal(const G4ThreeVector&, const G4VTouchable*) const; + + bool hitExists(const G4Step*); + bool checkHit(); + CaloG4Hit* createNewHit(const G4Step*); + void updateHit(CaloG4Hit*); + void resetForNewPrimary(const G4Step*); + double getAttenuation(const G4Step* aStep, double birk1, double birk2, double birk3) const; + + void update(const BeginOfRun*) override; + void update(const BeginOfEvent*) override; + void update(const BeginOfTrack* trk) override; + void update(const EndOfTrack* trk) override; + void update(const ::EndOfEvent*) override; + virtual void initRun(); + virtual void initEvent(const BeginOfEvent*); + virtual void endEvent(); + virtual bool filterHit(CaloG4Hit*, double); + + virtual int getTrackID(const G4Track*); + virtual int setTrackID(const G4Step*); + virtual uint16_t getDepth(const G4Step*); + double getResponseWt(const G4Track*); + int getNumberOfHits(); inline void setParameterized(bool val) { isParameterized = val; } - inline void setUseMap(bool val) { useMap = val; } + inline void setUseMap(bool val) { useMap = val; } inline void processHit(const G4Step* step) { // check if it is in the same unit and timeslice as the previous one @@ -111,67 +110,63 @@ class CaloSD : public SensitiveCaloDetector, inline void setNumberCheckedHits(int val) { nCheckedHits = val; } private: - - void storeHit(CaloG4Hit*); - bool saveHit(CaloG4Hit*); - void cleanHitCollection(); + void storeHit(CaloG4Hit*); + bool saveHit(CaloG4Hit*); + void cleanHitCollection(); protected: - // Data relative to primary particle (the one which triggers a shower) // These data are common to all Hits of a given shower. // One shower is made of several hits which differ by the // unit ID (crystal/fibre/scintillator) and the Time slice ID. - G4ThreeVector entrancePoint; - G4ThreeVector entranceLocal; - G4ThreeVector posGlobal; - float incidentEnergy; - float edepositEM, edepositHAD; + G4ThreeVector entrancePoint; + G4ThreeVector entranceLocal; + G4ThreeVector posGlobal; + float incidentEnergy; + float edepositEM, edepositHAD; - CaloHitID currentID, previousID; + CaloHitID currentID, previousID; - double energyCut, tmaxHit, eminHit; + double energyCut, tmaxHit, eminHit; - CaloG4Hit* currentHit; + CaloG4Hit* currentHit; - bool suppressHeavy; - double kmaxIon, kmaxNeutron, kmaxProton; + bool suppressHeavy; + double kmaxIon, kmaxNeutron, kmaxProton; - bool forceSave; + bool forceSave; private: + const SimTrackManager* m_trackManager; - const SimTrackManager* m_trackManager; - - std::unique_ptr slave; - std::unique_ptr meanResponse; - - CaloG4HitCollection* theHC; + std::unique_ptr slave; + std::unique_ptr meanResponse; - bool ignoreTrackID; - bool isParameterized; - bool useMap; // use map for comparison of ID - bool corrTOFBeam; + CaloG4HitCollection* theHC; - int hcID; - int primAncestor; - int cleanIndex; - int totalHits; - int primIDSaved; // ID of the last saved primary - int nCheckedHits; // number of last hits to compare ID + bool ignoreTrackID; + bool isParameterized; + bool useMap; // use map for comparison of ID + bool corrTOFBeam; - float timeSlice; - double eminHitD; - double correctT; + int hcID; + int primAncestor; + int cleanIndex; + int totalHits; + int primIDSaved; // ID of the last saved primary + int nCheckedHits; // number of last hits to compare ID - std::map hitMap; - std::map tkMap; + float timeSlice; + double eminHitD; + double correctT; - std::vector reusehit; - std::vector hitvec; - std::vector selIndex; + std::map hitMap; + std::map tkMap; + std::vector reusehit; + std::vector hitvec; + std::vector selIndex; }; -#endif // SimG4CMS_CaloSD_h +#endif // SimG4CMS_CaloSD_h diff --git a/SimG4CMS/Calo/interface/CaloSteppingAction.h b/SimG4CMS/Calo/interface/CaloSteppingAction.h index e8491a55a17f5..156a66bc7bf11 100644 --- a/SimG4CMS/Calo/interface/CaloSteppingAction.h +++ b/SimG4CMS/Calo/interface/CaloSteppingAction.h @@ -48,57 +48,54 @@ #include class CaloSteppingAction : public SimProducer, - public Observer, - public Observer, - public Observer, - public Observer, + public Observer, + public Observer, + public Observer, + public Observer, public Observer { - public: CaloSteppingAction(const edm::ParameterSet &p); ~CaloSteppingAction() override; - void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event &, const edm::EventSetup &) override; private: - void fillHits(edm::PCaloHitContainer& cc, int type); + void fillHits(edm::PCaloHitContainer &cc, int type); // observer classes - void update(const BeginOfJob * job) override; - void update(const BeginOfRun * run) override; - void update(const BeginOfEvent * evt) override; - void update(const G4Step * step) override; - void update(const EndOfEvent * evt) override; + void update(const BeginOfJob *job) override; + void update(const BeginOfRun *run) override; + void update(const BeginOfEvent *evt) override; + void update(const G4Step *step) override; + void update(const EndOfEvent *evt) override; - void NaNTrap(const G4Step*) const; - uint32_t getDetIDHC(int det, int lay, int depth, - const math::XYZVectorD& pos) const; - void fillHit(uint32_t id, double dE, double time, int primID, - uint16_t depth, double em, int flag); + void NaNTrap(const G4Step *) const; + uint32_t getDetIDHC(int det, int lay, int depth, const math::XYZVectorD &pos) const; + void fillHit(uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag); uint16_t getDepth(bool flag, double crystalDepth, double radl) const; - double curve_LY(double crystalLength, double crystalDepth) const; - double getBirkL3(double dE, double step, double chg, double dens) const; - double getBirkHC(double dE, double step, double chg, double dens) const; - void saveHits(int flag); + double curve_LY(double crystalLength, double crystalDepth) const; + double getBirkL3(double dE, double step, double chg, double dens) const; + double getBirkHC(double dE, double step, double chg, double dens) const; + void saveHits(int flag); - static const int nSD_= 3; + static const int nSD_ = 3; std::unique_ptr ebNumberingScheme_; std::unique_ptr eeNumberingScheme_; - std::unique_ptr hcNumberingPS_; + std::unique_ptr hcNumberingPS_; #ifdef HcalNumberingTest - std::unique_ptr hcNumbering_; + std::unique_ptr hcNumbering_; #endif - std::unique_ptr hcNumberingScheme_; - std::unique_ptr slave_[nSD_]; + std::unique_ptr hcNumberingScheme_; + std::unique_ptr slave_[nSD_]; - std::vector nameEBSD_, nameEESD_, nameHCSD_; - std::vector nameHitC_; - std::vector volEBSD_, volEESD_, volHCSD_; - std::map xtalMap_; - int count_, eventID_; - double slopeLY_, birkC1EC_, birkSlopeEC_; - double birkCutEC_, birkC1HC_, birkC2HC_; - double birkC3HC_; - std::map,CaloGVHit> hitMap_[nSD_]; + std::vector nameEBSD_, nameEESD_, nameHCSD_; + std::vector nameHitC_; + std::vector volEBSD_, volEESD_, volHCSD_; + std::map xtalMap_; + int count_, eventID_; + double slopeLY_, birkC1EC_, birkSlopeEC_; + double birkCutEC_, birkC1HC_, birkC2HC_; + double birkC3HC_; + std::map, CaloGVHit> hitMap_[nSD_]; }; #endif diff --git a/SimG4CMS/Calo/interface/CaloTrkProcessing.h b/SimG4CMS/Calo/interface/CaloTrkProcessing.h index 6ad2b9f764d43..1586c881d67a6 100644 --- a/SimG4CMS/Calo/interface/CaloTrkProcessing.h +++ b/SimG4CMS/Calo/interface/CaloTrkProcessing.h @@ -20,64 +20,51 @@ class G4LogicalVolume; class G4Step; class SimTrackManager; -class CaloTrkProcessing : public SensitiveCaloDetector, - public Observer, - public Observer { - +class CaloTrkProcessing : public SensitiveCaloDetector, + public Observer, + public Observer { public: - - CaloTrkProcessing(const std::string& aSDname, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager*); + CaloTrkProcessing(const std::string& aSDname, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager*); ~CaloTrkProcessing() override; - void Initialize(G4HCofThisEvent * ) override {} - void clearHits() override {} - bool ProcessHits(G4Step * , G4TouchableHistory * ) override { - return true; - } - uint32_t setDetUnitId(const G4Step * step) override {return 0;} - void EndOfEvent(G4HCofThisEvent * ) override {} - void fillHits(edm::PCaloHitContainer&, const std::string& ) override {} + void Initialize(G4HCofThisEvent*) override {} + void clearHits() override {} + bool ProcessHits(G4Step*, G4TouchableHistory*) override { return true; } + uint32_t setDetUnitId(const G4Step* step) override { return 0; } + void EndOfEvent(G4HCofThisEvent*) override {} + void fillHits(edm::PCaloHitContainer&, const std::string&) override {} private: - - void update(const BeginOfEvent * evt) override; - void update(const G4Step *) override; + void update(const BeginOfEvent* evt) override; + void update(const G4Step*) override; std::vector getNames(G4String, const DDsvalues_type&); - std::vector getNumbers(G4String, const DDsvalues_type&); - int isItCalo(const G4VTouchable*); - int isItInside(const G4VTouchable*, int, int); - + std::vector getNumbers(G4String, const DDsvalues_type&); + int isItCalo(const G4VTouchable*); + int isItInside(const G4VTouchable*, int, int); struct Detector { Detector() {} - std::string name; - G4LogicalVolume* lv; - int level; - std::vector fromDets; + std::string name; + G4LogicalVolume* lv; + int level; + std::vector fromDets; std::vector fromDetL; - std::vector fromLevels; + std::vector fromLevels; }; - - // Utilities to get detector levels during a step - int detLevels(const G4VTouchable*) const; - G4LogicalVolume* detLV(const G4VTouchable*, int) const; - void detectorLevel(const G4VTouchable*, int&, int*, - G4String*) const; - bool testBeam, putHistory; - double eMin; - int lastTrackID; - std::vector detectors; - const SimTrackManager* m_trackManager; + // Utilities to get detector levels during a step + int detLevels(const G4VTouchable*) const; + G4LogicalVolume* detLV(const G4VTouchable*, int) const; + void detectorLevel(const G4VTouchable*, int&, int*, G4String*) const; + + bool testBeam, putHistory; + double eMin; + int lastTrackID; + std::vector detectors; + const SimTrackManager* m_trackManager; }; #endif - - - - - - - - diff --git a/SimG4CMS/Calo/interface/ECalSD.h b/SimG4CMS/Calo/interface/ECalSD.h index 053ef10585d31..6f794c3445bbf 100644 --- a/SimG4CMS/Calo/interface/ECalSD.h +++ b/SimG4CMS/Calo/interface/ECalSD.h @@ -28,61 +28,57 @@ class G4LogicalVolume; class EnergyResolutionVsLumi; class ECalSD : public CaloSD { - -public: - - ECalSD(const std::string&, const DDCompactView &, const SensitiveDetectorCatalog &, - edm::ParameterSet const & p, const SimTrackManager*); +public: + ECalSD(const std::string &, + const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &p, + const SimTrackManager *); ~ECalSD() override; - uint32_t setDetUnitId(const G4Step*) override; - void setNumberingScheme(EcalNumberingScheme*); + uint32_t setDetUnitId(const G4Step *) override; + void setNumberingScheme(EcalNumberingScheme *); protected: + double getEnergyDeposit(const G4Step *) override; + int getTrackID(const G4Track *) override; + uint16_t getDepth(const G4Step *) override; - double getEnergyDeposit(const G4Step*) override; - int getTrackID(const G4Track*) override; - uint16_t getDepth(const G4Step*) override; - -private: +private: + void initMap(const G4String &, const DDCompactView &); + uint16_t getRadiationLength(const G4StepPoint *hitPoint, const G4LogicalVolume *lv); + uint16_t getLayerIDForTimeSim(); + double curve_LY(const G4LogicalVolume *); - void initMap(const G4String&, const DDCompactView &); - uint16_t getRadiationLength(const G4StepPoint* hitPoint, - const G4LogicalVolume* lv); - uint16_t getLayerIDForTimeSim(); - double curve_LY(const G4LogicalVolume*); + void getBaseNumber(const G4Step *); + double getBirkL3(const G4Step *); - void getBaseNumber(const G4Step*); - double getBirkL3(const G4Step*); - - std::vector getDDDArray(const std::string&, - const DDsvalues_type&); - std::vector getStringArray(const std::string&, - const DDsvalues_type&); + std::vector getDDDArray(const std::string &, const DDsvalues_type &); + std::vector getStringArray(const std::string &, const DDsvalues_type &); // initialised before run - bool isEB; - bool isEE; - EcalNumberingScheme * numberingScheme; - bool useWeight, storeTrack, storeRL, storeLayerTimeSim; - bool useBirk, useBirkL3; - double birk1, birk2, birk3, birkSlope, birkCut; - double slopeLY, scaleRL; - std::string crystalMat, depth1Name, depth2Name; - std::map xtalLMap; - std::vector useDepth1, useDepth2, noWeight; - EcalBaseNumber theBaseNumber; - EnergyResolutionVsLumi ageing; - bool ageingWithSlopeLY; + bool isEB; + bool isEE; + EcalNumberingScheme *numberingScheme; + bool useWeight, storeTrack, storeRL, storeLayerTimeSim; + bool useBirk, useBirkL3; + double birk1, birk2, birk3, birkSlope, birkCut; + double slopeLY, scaleRL; + std::string crystalMat, depth1Name, depth2Name; + std::map xtalLMap; + std::vector useDepth1, useDepth2, noWeight; + EcalBaseNumber theBaseNumber; + EnergyResolutionVsLumi ageing; + bool ageingWithSlopeLY; // run time cache - G4ThreeVector currentLocalPoint; - double crystalLength; - double crystalDepth; - uint16_t depth; - + G4ThreeVector currentLocalPoint; + double crystalLength; + double crystalDepth; + uint16_t depth; + #ifdef plotDebug - TH2F *g2L_[4]; + TH2F *g2L_[4]; #endif }; -#endif // ECalSD_h +#endif // ECalSD_h diff --git a/SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h b/SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h index f03984117e9f8..0218e1da78335 100644 --- a/SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h +++ b/SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h @@ -16,20 +16,18 @@ #include "DataFormats/DetId/interface/DetId.h" class EnergyResolutionVsLumi { - - public: - +public: EnergyResolutionVsLumi(); - EnergyResolutionVsLumi(double lumi, double instlumi){ - m_lumi=lumi; - m_instlumi=instlumi; + EnergyResolutionVsLumi(double lumi, double instlumi) { + m_lumi = lumi; + m_instlumi = instlumi; calcmuTot(); }; virtual ~EnergyResolutionVsLumi(); - - struct DegradationAtEta{ + + struct DegradationAtEta { double eta; double muEM; double muHD; @@ -39,15 +37,15 @@ class EnergyResolutionVsLumi { double noiseIncreaseADC; double resolutitonConstantTerm; }; - + DegradationAtEta CalculateDegradation(double eta); - double Resolution(double eta, double ene); + double Resolution(double eta, double ene); //void Decomposition(); - void setLumi(double x){m_lumi=x;}; - void setInstLumi(double x){m_instlumi=x;}; - void setLumies(double x, double y){m_lumi=x, m_instlumi=y, calcmuTot();}; - + void setLumi(double x) { m_lumi = x; }; + void setInstLumi(double x) { m_instlumi = x; }; + void setLumies(double x, double y) { m_lumi = x, m_instlumi = y, calcmuTot(); }; + double calcmuEM(double eta); double calcmuHD(double eta); double calcampDropTransparency(double eta); @@ -56,22 +54,19 @@ class EnergyResolutionVsLumi { double calcnoiseIncreaseADC(double eta); double calcnoiseADC(double eta); double calcresolutitonConstantTerm(double eta); - + double calcLightCollectionEfficiencyWeighted(DetId id, double z); - double calcLightCollectionEfficiencyWeighted2(double eta, double z, double mu_ind=-1.0); + double calcLightCollectionEfficiencyWeighted2(double eta, double z, double mu_ind = -1.0); double calcmuTot(double eta); - void calcmuTot(); + void calcmuTot(); double getmuTot(double eta, int ix, int iy); - - private: +private: double m_lumi; double m_instlumi; double mu_eta[10085]; double vpt_eta[10085]; - - }; #endif diff --git a/SimG4CMS/Calo/interface/EvolutionECAL.h b/SimG4CMS/Calo/interface/EvolutionECAL.h index 6457397ae80e4..24b245cc01388 100644 --- a/SimG4CMS/Calo/interface/EvolutionECAL.h +++ b/SimG4CMS/Calo/interface/EvolutionECAL.h @@ -21,33 +21,24 @@ #include class EvolutionECAL { - public: - EvolutionECAL(); virtual ~EvolutionECAL(); - double LightCollectionEfficiency(double z, double mu); - double DamageProfileEta(double eta); - double DamageProfileEtaAPD(double eta); - double InducedAbsorptionHadronic(double lumi, double eta); - double DoseLongitudinalProfile(double z); - double InducedAbsorptionEM(double lumi, double eta); - double DegradationMeanEM50GeV(double mu); - double DegradationNonLinearityEM50GeV(double mu, double ene); - double ResolutionConstantTermEM50GeV(double mu); - double ChargeVPTCathode(double instLumi, double eta, double integralLumi); - double AgingVPT(double instLumi, double integralLumi, double eta); - double NoiseFactorFE(double lumi, double eta); - Double_t EquilibriumFractionColorCentersEM(double *x, double *par); - double LightCollectionEfficiencyWeighted(double z, double mu_ind); - - - + double DamageProfileEta(double eta); + double DamageProfileEtaAPD(double eta); + double InducedAbsorptionHadronic(double lumi, double eta); + double DoseLongitudinalProfile(double z); + double InducedAbsorptionEM(double lumi, double eta); + double DegradationMeanEM50GeV(double mu); + double DegradationNonLinearityEM50GeV(double mu, double ene); + double ResolutionConstantTermEM50GeV(double mu); + double ChargeVPTCathode(double instLumi, double eta, double integralLumi); + double AgingVPT(double instLumi, double integralLumi, double eta); + double NoiseFactorFE(double lumi, double eta); + Double_t EquilibriumFractionColorCentersEM(double *x, double *par); + double LightCollectionEfficiencyWeighted(double z, double mu_ind); }; - - #endif - diff --git a/SimG4CMS/Calo/interface/HCalSD.h b/SimG4CMS/Calo/interface/HCalSD.h index 304ce61343258..8a012a787037e 100644 --- a/SimG4CMS/Calo/interface/HCalSD.h +++ b/SimG4CMS/Calo/interface/HCalSD.h @@ -34,91 +34,87 @@ class G4Step; class HcalTestNS; class TH1F; -class HCalSD : public CaloSD, public Observer { - -public: - - HCalSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); +class HCalSD : public CaloSD, public Observer { +public: + HCalSD(const std::string&, + const DDCompactView&, + const SensitiveDetectorCatalog&, + edm::ParameterSet const&, + const SimTrackManager*); ~HCalSD() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - void setNumberingScheme(HcalNumberingScheme* ); + uint32_t setDetUnitId(const G4Step* step) override; + void setNumberingScheme(HcalNumberingScheme*); protected: - - double getEnergyDeposit(const G4Step*) override; - bool getFromLibrary(const G4Step*) override; + double getEnergyDeposit(const G4Step*) override; + bool getFromLibrary(const G4Step*) override; using CaloSD::update; - void update(const BeginOfJob *) override; - void initRun() override; - bool filterHit(CaloG4Hit*, double) override; - -private: - - void fillLogVolumeVector(const std::string&, const std::string&, - const DDCompactView&, - std::vector&, - std::vector&); - - uint32_t setDetUnitId(int, const G4ThreeVector&, int, int); - uint32_t setDetUnitId(HcalNumberingFromDDD::HcalID& tmp); - std::vector getDDDArray(const std::string&, - const DDsvalues_type&); - std::vector getNames(DDFilteredView&); - bool isItHF(const G4Step *); - bool isItHF(const G4String&); - bool isItFibre(const G4LogicalVolume*); - bool isItFibre(const G4String&); - bool isItPMT(const G4LogicalVolume*); - bool isItStraightBundle(const G4LogicalVolume*); - bool isItConicalBundle(const G4LogicalVolume*); - bool isItScintillator(const G4Material*); - bool isItinFidVolume (const G4ThreeVector&); - void getFromHFLibrary(const G4Step * step, bool& isKilled); - void hitForFibre(const G4Step * step); - void getFromParam(const G4Step * step, bool& isKilled); - void getHitPMT(const G4Step * step); - void getHitFibreBundle(const G4Step * step, bool type); - void readWeightFromFile(const std::string&); - double layerWeight(int, const G4ThreeVector&, int, int); - void plotProfile(const G4Step* step, const G4ThreeVector& pos, - double edep, double time, int id); - void plotHF(const G4ThreeVector& pos, bool emType); - void modifyDepth(HcalNumberingFromDDD::HcalID& id); + void update(const BeginOfJob*) override; + void initRun() override; + bool filterHit(CaloG4Hit*, double) override; + +private: + void fillLogVolumeVector(const std::string&, + const std::string&, + const DDCompactView&, + std::vector&, + std::vector&); + + uint32_t setDetUnitId(int, const G4ThreeVector&, int, int); + uint32_t setDetUnitId(HcalNumberingFromDDD::HcalID& tmp); + std::vector getDDDArray(const std::string&, const DDsvalues_type&); + std::vector getNames(DDFilteredView&); + bool isItHF(const G4Step*); + bool isItHF(const G4String&); + bool isItFibre(const G4LogicalVolume*); + bool isItFibre(const G4String&); + bool isItPMT(const G4LogicalVolume*); + bool isItStraightBundle(const G4LogicalVolume*); + bool isItConicalBundle(const G4LogicalVolume*); + bool isItScintillator(const G4Material*); + bool isItinFidVolume(const G4ThreeVector&); + void getFromHFLibrary(const G4Step* step, bool& isKilled); + void hitForFibre(const G4Step* step); + void getFromParam(const G4Step* step, bool& isKilled); + void getHitPMT(const G4Step* step); + void getHitFibreBundle(const G4Step* step, bool type); + void readWeightFromFile(const std::string&); + double layerWeight(int, const G4ThreeVector&, int, int); + void plotProfile(const G4Step* step, const G4ThreeVector& pos, double edep, double time, int id); + void plotHF(const G4ThreeVector& pos, bool emType); + void modifyDepth(HcalNumberingFromDDD::HcalID& id); std::unique_ptr numberingFromDDD; - std::unique_ptr numberingScheme; - std::unique_ptr showerLibrary; - std::unique_ptr hfshower; - std::unique_ptr showerParam; - std::unique_ptr showerPMT; - std::unique_ptr showerBundle; - - const HcalDDDSimConstants* hcalConstants; - const HBHEDarkening* m_HBDarkening; - const HBHEDarkening* m_HEDarkening; - std::unique_ptr m_HFDarkening; - std::unique_ptr m_HcalTestNS; - - bool isHF; - bool agingFlagHB, agingFlagHE; - bool useBirk, useLayerWt, useFibreBundle, usePMTHit; - bool testNumber, neutralDensity, testNS_; - double birk1, birk2, birk3, betaThr; - bool useHF, useShowerLibrary, useParam, applyFidCut; - double eminHitHB, eminHitHE, eminHitHO, eminHitHF; - double deliveredLumi; - double weight_; - int depth_; - std::vector gpar; - std::vector hfLevels; - std::vector hfNames, fibreNames, matNames; - std::vector materials; + std::unique_ptr numberingScheme; + std::unique_ptr showerLibrary; + std::unique_ptr hfshower; + std::unique_ptr showerParam; + std::unique_ptr showerPMT; + std::unique_ptr showerBundle; + + const HcalDDDSimConstants* hcalConstants; + const HBHEDarkening* m_HBDarkening; + const HBHEDarkening* m_HEDarkening; + std::unique_ptr m_HFDarkening; + std::unique_ptr m_HcalTestNS; + + bool isHF; + bool agingFlagHB, agingFlagHE; + bool useBirk, useLayerWt, useFibreBundle, usePMTHit; + bool testNumber, neutralDensity, testNS_; + double birk1, birk2, birk3, betaThr; + bool useHF, useShowerLibrary, useParam, applyFidCut; + double eminHitHB, eminHitHE, eminHitHO, eminHitHF; + double deliveredLumi; + double weight_; + int depth_; + std::vector gpar; + std::vector hfLevels; + std::vector hfNames, fibreNames, matNames; + std::vector materials; std::vector hfLV, fibreLV, pmtLV, fibre1LV, fibre2LV; - std::map layerWeights; - TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad; - + std::map layerWeights; + TH1F *hit_[9], *time_[9], *dist_[9], *hzvem, *hzvhad; }; -#endif // HCalSD_h +#endif // HCalSD_h diff --git a/SimG4CMS/Calo/interface/HFCherenkov.h b/SimG4CMS/Calo/interface/HFCherenkov.h index 6e520712cf2d4..8c10a7ed2b9ba 100644 --- a/SimG4CMS/Calo/interface/HFCherenkov.h +++ b/SimG4CMS/Calo/interface/HFCherenkov.h @@ -17,62 +17,59 @@ #include class HFCherenkov { - public: + HFCherenkov(edm::ParameterSet const& p); + virtual ~HFCherenkov(); - HFCherenkov(edm::ParameterSet const & p); - virtual ~HFCherenkov(); - - int computeNPE(const G4Step* step, const G4ParticleDefinition* pDef, - double pBeta, double u, double v, double w, - double step_length, double zFiber, - double Dose, int Npe_Dose); - - int computeNPEinPMT(const G4ParticleDefinition* pDef,double pBeta, - double u, double v, double w, - double step_length); + int computeNPE(const G4Step* step, + const G4ParticleDefinition* pDef, + double pBeta, + double u, + double v, + double w, + double step_length, + double zFiber, + double Dose, + int Npe_Dose); - int computeNPhTrapped(double pBeta, double u, double v, - double w, double step_length, - double zFiber, double Dose, - int Npe_Dose); - double smearNPE(G4int Npe); + int computeNPEinPMT(const G4ParticleDefinition* pDef, double pBeta, double u, double v, double w, double step_length); - std::vector getMom(); - std::vector getWL(); - std::vector getWLIni(); - std::vector getWLTrap(); - std::vector getWLAtten(); - std::vector getWLHEM(); - std::vector getWLQEff(); - void clearVectors(); - -private: + int computeNPhTrapped( + double pBeta, double u, double v, double w, double step_length, double zFiber, double Dose, int Npe_Dose); + double smearNPE(G4int Npe); - bool isApplicable(const G4ParticleDefinition* aParticleType); - // Returns true -> 'is applicable', for all charged particles. - int computeNbOfPhotons(double pBeta, double step_length); - double computeQEff(double wavelength); - double computeHEMEff(double wavelength); + std::vector getMom(); + std::vector getWL(); + std::vector getWLIni(); + std::vector getWLTrap(); + std::vector getWLAtten(); + std::vector getWLHEM(); + std::vector getWLQEff(); + void clearVectors(); private: + bool isApplicable(const G4ParticleDefinition* aParticleType); + // Returns true -> 'is applicable', for all charged particles. + int computeNbOfPhotons(double pBeta, double step_length); + double computeQEff(double wavelength); + double computeHEMEff(double wavelength); - double ref_index; - double lambda1, lambda2; - double aperture, aperturetrapped, apertureTrap; - double gain, fibreR, sinPsimax; - bool checkSurvive; - bool UseNewPMT; +private: + double ref_index; + double lambda1, lambda2; + double aperture, aperturetrapped, apertureTrap; + double gain, fibreR, sinPsimax; + bool checkSurvive; + bool UseNewPMT; - G4ThreeVector phMom; - std::vector wl; - std::vector momZ; - std::vector wlini; - std::vector wltrap; - std::vector wlatten; - std::vector wlhem; - std::vector wlqeff; + G4ThreeVector phMom; + std::vector wl; + std::vector momZ; + std::vector wlini; + std::vector wltrap; + std::vector wlatten; + std::vector wlhem; + std::vector wlqeff; }; #endif - diff --git a/SimG4CMS/Calo/interface/HFDarkening.h b/SimG4CMS/Calo/interface/HFDarkening.h index 05030d9a6e377..094aa0f92c3e1 100644 --- a/SimG4CMS/Calo/interface/HFDarkening.h +++ b/SimG4CMS/Calo/interface/HFDarkening.h @@ -7,32 +7,30 @@ typedef std::vector vecOfDoubles; -namespace edm -{ +namespace edm { class ParameterSet; } class HFDarkening { - public: HFDarkening(const edm::ParameterSet& pset); ~HFDarkening(); - + double dose(unsigned int layer, double radius); double int_lumi(double intlumi); double degradation(double mrad); - + //These constants are used in HcalSD.cc static const unsigned int numberOfZLayers = 33; static const unsigned int numberOfRLayers = 13; - - static const unsigned int lowZLimit = 1115; + + static const unsigned int lowZLimit = 1115; static const unsigned int upperZLimit = 1280; - + private: double HFDoseLayerDarkeningPars[numberOfZLayers][numberOfRLayers]; static const unsigned int _numberOfZLayers = numberOfZLayers; static const unsigned int _numberOfRLayers = numberOfRLayers; }; -#endif // HFDarkening_h +#endif // HFDarkening_h diff --git a/SimG4CMS/Calo/interface/HFFibre.h b/SimG4CMS/Calo/interface/HFFibre.h index 7aed56089e030..143d47e1aa5ff 100644 --- a/SimG4CMS/Calo/interface/HFFibre.h +++ b/SimG4CMS/Calo/interface/HFFibre.h @@ -15,37 +15,28 @@ #include #include -class DDCompactView; +class DDCompactView; class HFFibre { - public: - //Constructor and Destructor - HFFibre(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p); + HFFibre(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p); ~HFFibre() = default; - void initRun(const HcalDDDSimConstants*); - double attLength(double lambda); - double tShift(const G4ThreeVector& point, int depth, - int fromEndAbs=0); - double zShift(const G4ThreeVector& point, int depth, - int fromEndAbs=0); + void initRun(const HcalDDDSimConstants*); + double attLength(double lambda); + double tShift(const G4ThreeVector& point, int depth, int fromEndAbs = 0); + double zShift(const G4ThreeVector& point, int depth, int fromEndAbs = 0); protected: - - std::vector getDDDArray(const std::string&, - const DDsvalues_type&, int&); + std::vector getDDDArray(const std::string&, const DDsvalues_type&, int&); private: - - double cFibre; - std::vector gpar, radius; - std::vector shortFL, longFL; - std::vector attL; - int nBinR, nBinAtt; - double lambLim[2]; - + double cFibre; + std::vector gpar, radius; + std::vector shortFL, longFL; + std::vector attL; + int nBinR, nBinAtt; + double lambLim[2]; }; #endif diff --git a/SimG4CMS/Calo/interface/HFFibreFiducial.h b/SimG4CMS/Calo/interface/HFFibreFiducial.h index 3c8f7c8b6823a..78f8c78329c5a 100644 --- a/SimG4CMS/Calo/interface/HFFibreFiducial.h +++ b/SimG4CMS/Calo/interface/HFFibreFiducial.h @@ -8,7 +8,7 @@ #include "G4ThreeVector.hh" namespace HFFibreFiducial { - int PMTNumber(const G4ThreeVector& pe_effect); // M.K. HF acceptance + int PMTNumber(const G4ThreeVector& pe_effect); // M.K. HF acceptance }; #endif diff --git a/SimG4CMS/Calo/interface/HFGflash.h b/SimG4CMS/Calo/interface/HFGflash.h index c9329b13f64ca..3613cb099291c 100644 --- a/SimG4CMS/Calo/interface/HFGflash.h +++ b/SimG4CMS/Calo/interface/HFGflash.h @@ -27,46 +27,43 @@ class G4Step; class HFGflash { - -public: - - HFGflash(edm::ParameterSet const & p); +public: + HFGflash(edm::ParameterSet const &p); virtual ~HFGflash(); struct Hit { Hit() {} - G4ThreeVector position; - int depth = 0; - double time = 0.; - double edep = 0.; - double pez = 0.; + G4ThreeVector position; + int depth = 0; + double time = 0.; + double edep = 0.; + double pez = 0.; }; - std::vector gfParameterization(const G4Step * aStep, bool onlyLong=false); - -private: + std::vector gfParameterization(const G4Step *aStep, bool onlyLong = false); - GflashTrajectory* theHelix; +private: + GflashTrajectory *theHelix; G4Step *theGflashStep; G4Navigator *theGflashNavigator; - G4TouchableHandle theGflashTouchableHandle; + G4TouchableHandle theGflashTouchableHandle; Gflash::CalorimeterNumber jCalorimeter; - bool theWatcherOn; - bool theFillHisto; + bool theWatcherOn; + bool theFillHisto; G4double theBField; - G4int showerType ; - G4double energyToDeposit; - G4double energyScale[Gflash::kNumberCalorimeter]; - G4double longHcal[Gflash::NPar]; - G4double longEcal[Gflash::NPar]; - G4double lateralPar[4]; + G4int showerType; + G4double energyToDeposit; + G4double energyScale[Gflash::kNumberCalorimeter]; + G4double longHcal[Gflash::NPar]; + G4double longEcal[Gflash::NPar]; + G4double lateralPar[4]; - TH1F *em_incE, *em_ssp_rho, *em_ssp_z, *em_long, *em_lateral; - TH1F *em_long_sd, *em_lateral_sd, *em_nSpots_sd, *em_ze_ratio; - TH2F *em_2d, *em_2d_sd, *em_ze, *em_ratio, *em_ratio_selected; + TH1F *em_incE, *em_ssp_rho, *em_ssp_z, *em_long, *em_lateral; + TH1F *em_long_sd, *em_lateral_sd, *em_nSpots_sd, *em_ze_ratio; + TH2F *em_2d, *em_2d_sd, *em_ze, *em_ratio, *em_ratio_selected; }; -#endif // HFGflash_h +#endif // HFGflash_h diff --git a/SimG4CMS/Calo/interface/HFNoseNumberingScheme.h b/SimG4CMS/Calo/interface/HFNoseNumberingScheme.h index ee3ef50760714..217dd2ec188bd 100644 --- a/SimG4CMS/Calo/interface/HFNoseNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HFNoseNumberingScheme.h @@ -12,23 +12,19 @@ #include "G4ThreeVector.hh" class HFNoseNumberingScheme { - public: - HFNoseNumberingScheme(const HGCalDDDConstants& hgc); ~HFNoseNumberingScheme() {} /** @short assigns the det id to a hit */ - uint32_t getUnitID(int layer, int module, int cell, int iz, - const G4ThreeVector &pos, double& wt); + uint32_t getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector& pos, double& wt); private: - HFNoseNumberingScheme() = delete; - const HGCalDDDConstants& hgcons_; - const HGCalGeometryMode::GeometryMode mode_; + const HGCalDDDConstants& hgcons_; + const HGCalGeometryMode::GeometryMode mode_; }; #endif diff --git a/SimG4CMS/Calo/interface/HFNoseSD.h b/SimG4CMS/Calo/interface/HFNoseSD.h index 76a4401da1848..87502bc110274 100644 --- a/SimG4CMS/Calo/interface/HFNoseSD.h +++ b/SimG4CMS/Calo/interface/HFNoseSD.h @@ -19,41 +19,39 @@ class G4LogicalVolume; class G4Step; class HFNoseSD : public CaloSD, public Observer { +public: + HFNoseSD(const std::string &, + const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, + const SimTrackManager *); + ~HFNoseSD() override = default; -public: - - HFNoseSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); - ~HFNoseSD() override = default; - - uint32_t setDetUnitId(const G4Step* step) override; + uint32_t setDetUnitId(const G4Step *step) override; protected: - - double getEnergyDeposit(const G4Step*) override; + double getEnergyDeposit(const G4Step *) override; using CaloSD::update; - void update(const BeginOfJob *) override; - void initRun() override; - bool filterHit(CaloG4Hit*, double) override; - -private: + void update(const BeginOfJob *) override; + void initRun() override; + bool filterHit(CaloG4Hit *, double) override; - uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); - bool isItinFidVolume (const G4ThreeVector&); +private: + uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); + bool isItinFidVolume(const G4ThreeVector &); - const HGCalDDDConstants* hgcons_; + const HGCalDDDConstants *hgcons_; std::unique_ptr numberingScheme_; - std::unique_ptr mouseBite_; - std::string nameX_; - HGCalGeometryMode::GeometryMode geom_mode_; - double eminHit_, slopeMin_, weight_; - double mouseBiteCut_, distanceFromEdge_; - int levelT1_, levelT2_, cornerMinMask_; - bool storeAllG4Hits_; - bool fiducialCut_, rejectMB_, waferRot_; - const double tan30deg_; - std::vector angles_; + std::unique_ptr mouseBite_; + std::string nameX_; + HGCalGeometryMode::GeometryMode geom_mode_; + double eminHit_, slopeMin_, weight_; + double mouseBiteCut_, distanceFromEdge_; + int levelT1_, levelT2_, cornerMinMask_; + bool storeAllG4Hits_; + bool fiducialCut_, rejectMB_, waferRot_; + const double tan30deg_; + std::vector angles_; }; -#endif // HFNoseSD_h +#endif // HFNoseSD_h diff --git a/SimG4CMS/Calo/interface/HFShower.h b/SimG4CMS/Calo/interface/HFShower.h index 752d50cd7c7a7..0f96340ffbc9e 100644 --- a/SimG4CMS/Calo/interface/HFShower.h +++ b/SimG4CMS/Calo/interface/HFShower.h @@ -14,50 +14,42 @@ #include "G4ThreeVector.hh" #include "G4String.hh" -class DDCompactView; +class DDCompactView; class G4Step; #include - -class HFShower { - -public: - HFShower(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p, int chk=0); +class HFShower { +public: + HFShower(const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p, int chk = 0); virtual ~HFShower(); public: - struct Hit { Hit() {} - int depth; - double time; - double wavelength; - double momentum; - G4ThreeVector position; + int depth; + double time; + double wavelength; + double momentum; + G4ThreeVector position; }; - void initRun(const HcalDDDSimConstants*); - std::vector getHits(const G4Step * aStep, double weight); - std::vector getHits(const G4Step * aStep, bool forLibrary); - std::vector getHits(const G4Step * aStep, bool forLibraryProducer, double zoffset); - - -private: + void initRun(const HcalDDDSimConstants *); + std::vector getHits(const G4Step *aStep, double weight); + std::vector getHits(const G4Step *aStep, bool forLibrary); + std::vector getHits(const G4Step *aStep, bool forLibraryProducer, double zoffset); +private: std::vector getDDDArray(const std::string &, const DDsvalues_type &, int &); - bool applyFidCut; + bool applyFidCut; -private: +private: + HFCherenkov *cherenkov; + HFFibre *fibre; - HFCherenkov* cherenkov; - HFFibre* fibre; - - int chkFibre; - double probMax; + int chkFibre; + double probMax; std::vector gpar; - }; -#endif // HFShower_h +#endif // HFShower_h diff --git a/SimG4CMS/Calo/interface/HFShowerFibreBundle.h b/SimG4CMS/Calo/interface/HFShowerFibreBundle.h index 4fe5333ff1a89..72f487bef79e5 100644 --- a/SimG4CMS/Calo/interface/HFShowerFibreBundle.h +++ b/SimG4CMS/Calo/interface/HFShowerFibreBundle.h @@ -11,35 +11,30 @@ #include "DetectorDescription/Core/interface/DDsvalues.h" #include "SimG4CMS/Calo/interface/HFCherenkov.h" -class DDCompactView; +class DDCompactView; class G4Step; #include #include - -class HFShowerFibreBundle { - -public: - HFShowerFibreBundle(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p); +class HFShowerFibreBundle { +public: + HFShowerFibreBundle(const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p); virtual ~HFShowerFibreBundle(); - double getHits(const G4Step * aStep, bool type); - double getRadius(); - void initRun(const HcalDDDSimConstants*); - -private: - - std::vector getDDDArray(const std::string&, const DDsvalues_type&); - -private: - - HFCherenkov *cherenkov1, *cherenkov2; - double facTube, facCone; //Packing factors - int indexR, indexF; - std::vector rTable; // R-table - std::vector pmtR1, pmtFib1; // R-index, fibre table for right box - std::vector pmtR2, pmtFib2; // R-index, fibre table for left box + double getHits(const G4Step *aStep, bool type); + double getRadius(); + void initRun(const HcalDDDSimConstants *); + +private: + std::vector getDDDArray(const std::string &, const DDsvalues_type &); + +private: + HFCherenkov *cherenkov1, *cherenkov2; + double facTube, facCone; //Packing factors + int indexR, indexF; + std::vector rTable; // R-table + std::vector pmtR1, pmtFib1; // R-index, fibre table for right box + std::vector pmtR2, pmtFib2; // R-index, fibre table for left box }; -#endif // HFShowerFibreBundle_h +#endif // HFShowerFibreBundle_h diff --git a/SimG4CMS/Calo/interface/HFShowerLibrary.h b/SimG4CMS/Calo/interface/HFShowerLibrary.h index 2abd4f0c69793..75b6224413920 100644 --- a/SimG4CMS/Calo/interface/HFShowerLibrary.h +++ b/SimG4CMS/Calo/interface/HFShowerLibrary.h @@ -13,7 +13,7 @@ #include "DetectorDescription/Core/interface/DDsvalues.h" #include "G4ThreeVector.hh" - + //ROOT #include "TROOT.h" #include "TFile.h" @@ -22,64 +22,61 @@ #include #include -class DDCompactView; +class DDCompactView; class G4Step; class G4ParticleTable; class HFShowerLibrary { - public: - //Constructor and Destructor - HFShowerLibrary(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p); + HFShowerLibrary(const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p); ~HFShowerLibrary(); public: - struct Hit { Hit() {} - G4ThreeVector position; - int depth; - double time; + G4ThreeVector position; + int depth; + double time; }; - void initRun(G4ParticleTable*, const HcalDDDSimConstants*); - std::vector getHits(const G4Step * aStep, bool &ok, double weight, - bool onlyLong=false); - std::vector fillHits(const G4ThreeVector & p, const G4ThreeVector & v, - int parCode, double parEnergy, bool & ok, - double weight, double time, bool onlyLong=false); -protected: + void initRun(G4ParticleTable *, const HcalDDDSimConstants *); + std::vector getHits(const G4Step *aStep, bool &ok, double weight, bool onlyLong = false); + std::vector fillHits(const G4ThreeVector &p, + const G4ThreeVector &v, + int parCode, + double parEnergy, + bool &ok, + double weight, + double time, + bool onlyLong = false); - bool rInside(double r); - void getRecord(int, int); - void loadEventInfo(TBranch *); - void interpolate(int, double); - void extrapolate(int, double); - void storePhoton(int j); - std::vector getDDDArray(const std::string&, const DDsvalues_type&, - int&); +protected: + bool rInside(double r); + void getRecord(int, int); + void loadEventInfo(TBranch *); + void interpolate(int, double); + void extrapolate(int, double); + void storePhoton(int j); + std::vector getDDDArray(const std::string &, const DDsvalues_type &, int &); private: + HFFibre *fibre; + TFile *hf; + TBranch *emBranch, *hadBranch; - HFFibre * fibre; - TFile * hf; - TBranch *emBranch, *hadBranch; - - bool verbose, applyFidCut, newForm, v3version; - int nMomBin, totEvents, evtPerBin; - float libVers, listVersion; + bool verbose, applyFidCut, newForm, v3version; + int nMomBin, totEvents, evtPerBin; + float libVers, listVersion; std::vector pmom; - double probMax, backProb; - double dphi, rMin, rMax; + double probMax, backProb; + double dphi, rMin, rMax; std::vector gpar; - int npe; + int npe; HFShowerPhotonCollection pe; - HFShowerPhotonCollection* photo; + HFShowerPhotonCollection *photo; HFShowerPhotonCollection photon; - }; #endif diff --git a/SimG4CMS/Calo/interface/HFShowerPMT.h b/SimG4CMS/Calo/interface/HFShowerPMT.h index 0490627ea0432..2120af6da4293 100644 --- a/SimG4CMS/Calo/interface/HFShowerPMT.h +++ b/SimG4CMS/Calo/interface/HFShowerPMT.h @@ -2,7 +2,7 @@ #define SimG4CMS_HFShowerPMT_h /////////////////////////////////////////////////////////////////////////////// // File: HFShowerPMT.h -// Description: Maps HF PMT's to given +// Description: Maps HF PMT's to given /////////////////////////////////////////////////////////////////////////////// #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -11,36 +11,30 @@ #include "DetectorDescription/Core/interface/DDsvalues.h" #include "SimG4CMS/Calo/interface/HFCherenkov.h" -class DDCompactView; +class DDCompactView; class G4Step; #include #include - -class HFShowerPMT { - -public: - HFShowerPMT(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p); +class HFShowerPMT { +public: + HFShowerPMT(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p); virtual ~HFShowerPMT(); - double getHits(const G4Step * aStep); - double getRadius(); - void initRun(const HcalDDDSimConstants*); - -private: - - std::vector getDDDArray(const std::string&, const DDsvalues_type&); - -private: - - HFCherenkov* cherenkov; - double pePerGeV; // PE per GeV of energy deposit - int indexR, indexF; - std::vector rTable; // R-table - std::vector pmtR1, pmtFib1; // R-index, fibre table for right box - std::vector pmtR2, pmtFib2; // R-index, fibre table for left box - + double getHits(const G4Step* aStep); + double getRadius(); + void initRun(const HcalDDDSimConstants*); + +private: + std::vector getDDDArray(const std::string&, const DDsvalues_type&); + +private: + HFCherenkov* cherenkov; + double pePerGeV; // PE per GeV of energy deposit + int indexR, indexF; + std::vector rTable; // R-table + std::vector pmtR1, pmtFib1; // R-index, fibre table for right box + std::vector pmtR2, pmtFib2; // R-index, fibre table for left box }; -#endif // HFShowerPMT_h +#endif // HFShowerPMT_h diff --git a/SimG4CMS/Calo/interface/HFShowerParam.h b/SimG4CMS/Calo/interface/HFShowerParam.h index eb013e5d21c3a..aac01131823e1 100644 --- a/SimG4CMS/Calo/interface/HFShowerParam.h +++ b/SimG4CMS/Calo/interface/HFShowerParam.h @@ -22,45 +22,39 @@ class G4Step; #include #include #include - -class HFShowerParam { - -public: - HFShowerParam(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p); +class HFShowerParam { +public: + HFShowerParam(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p); virtual ~HFShowerParam(); -public: - +public: struct Hit { Hit() {} - G4ThreeVector position; - int depth; - double time; - double edep; + G4ThreeVector position; + int depth; + double time; + double edep; }; - void initRun(const HcalDDDSimConstants*); - std::vector getHits(const G4Step * aStep, double weight, bool& isKilled); - -private: - - std::vector getDDDArray(const std::string&, const DDsvalues_type&); - - HFShowerLibrary* showerLibrary; - HFFibre* fibre; - HFGflash* gflash; - double pePerGeV, edMin, ref_index, aperture, attLMeanInv; - bool trackEM, onlyLong, applyFidCut, parametrizeLast; - G4int emPDG, epPDG, gammaPDG; - std::vector gpar; - bool fillHisto; - TH1F *em_long_1, *em_lateral_1, *em_long_2, *em_lateral_2; - TH1F *hzvem, *hzvhad, *em_long_1_tuned, *em_long_gflash; - TH1F *em_long_sl; - TH2F *em_2d_1, *em_2d_2; + void initRun(const HcalDDDSimConstants*); + std::vector getHits(const G4Step* aStep, double weight, bool& isKilled); + +private: + std::vector getDDDArray(const std::string&, const DDsvalues_type&); + + HFShowerLibrary* showerLibrary; + HFFibre* fibre; + HFGflash* gflash; + double pePerGeV, edMin, ref_index, aperture, attLMeanInv; + bool trackEM, onlyLong, applyFidCut, parametrizeLast; + G4int emPDG, epPDG, gammaPDG; + std::vector gpar; + bool fillHisto; + TH1F *em_long_1, *em_lateral_1, *em_long_2, *em_lateral_2; + TH1F *hzvem, *hzvhad, *em_long_1_tuned, *em_long_gflash; + TH1F* em_long_sl; + TH2F *em_2d_1, *em_2d_2; }; - -#endif // HFShowerParam_h +#endif // HFShowerParam_h diff --git a/SimG4CMS/Calo/interface/HGCMouseBite.h b/SimG4CMS/Calo/interface/HGCMouseBite.h index f8cc01b5cf7d3..f856607da7fdb 100644 --- a/SimG4CMS/Calo/interface/HGCMouseBite.h +++ b/SimG4CMS/Calo/interface/HGCMouseBite.h @@ -7,21 +7,16 @@ #include class HGCMouseBite { - -public: - - HGCMouseBite(const HGCalDDDConstants& hgc, const std::vector& angle, - double maxLength, bool waferRotate); - bool exclude(G4ThreeVector& point, int zside, int waferU, - int waferV); - -private: - - const HGCalDDDConstants& hgcons_; - double cut_; - bool rot_; - bool modeUV_; - std::vector > projXY_; +public: + HGCMouseBite(const HGCalDDDConstants& hgc, const std::vector& angle, double maxLength, bool waferRotate); + bool exclude(G4ThreeVector& point, int zside, int waferU, int waferV); + +private: + const HGCalDDDConstants& hgcons_; + double cut_; + bool rot_; + bool modeUV_; + std::vector > projXY_; }; -#endif // HGCMouseBite_h +#endif // HGCMouseBite_h diff --git a/SimG4CMS/Calo/interface/HGCNumberingScheme.h b/SimG4CMS/Calo/interface/HGCNumberingScheme.h index 7d789516f9495..2ee837f8dc50f 100644 --- a/SimG4CMS/Calo/interface/HGCNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HGCNumberingScheme.h @@ -11,20 +11,17 @@ #include "G4ThreeVector.hh" class HGCNumberingScheme { - public: - enum HGCNumberingParameters { HGCCellSize }; - HGCNumberingScheme(const HGCalDDDConstants& hgc, std::string& name ); + HGCNumberingScheme(const HGCalDDDConstants& hgc, std::string& name); ~HGCNumberingScheme(); /** @short assigns the det id to a hit */ - uint32_t getUnitID(ForwardSubdetector subdet, int layer, int module, - int cell, int iz, const G4ThreeVector &pos); + uint32_t getUnitID(ForwardSubdetector subdet, int layer, int module, int cell, int iz, const G4ThreeVector& pos); /** @short maps a hit position to a sequential cell in a trapezoid surface defined by h,b,t @@ -34,10 +31,9 @@ class HGCNumberingScheme { /** @short inverts the cell number in a trapezoid surface to local coordinates */ - std::pair getLocalCoords(int cell, int layer); + std::pair getLocalCoords(int cell, int layer); private: - HGCNumberingScheme() = delete; const HGCalDDDConstants& hgcons_; }; diff --git a/SimG4CMS/Calo/interface/HGCSD.h b/SimG4CMS/Calo/interface/HGCSD.h index 3a82fd1f88f8b..2332a7ea8e1e8 100644 --- a/SimG4CMS/Calo/interface/HGCSD.h +++ b/SimG4CMS/Calo/interface/HGCSD.h @@ -23,49 +23,46 @@ class G4Material; class G4Step; class HGCSD : public CaloSD, public Observer { - -public: - - HGCSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); +public: + HGCSD(const std::string &, + const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, + const SimTrackManager *); ~HGCSD() override = default; - uint32_t setDetUnitId(const G4Step* step) override; + uint32_t setDetUnitId(const G4Step *step) override; protected: - - double getEnergyDeposit(const G4Step* ) override; + double getEnergyDeposit(const G4Step *) override; using CaloSD::update; - void update(const BeginOfJob *) override; - void initRun() override; - void initEvent(const BeginOfEvent*) override; - void endEvent() override; - bool filterHit(CaloG4Hit*, double) override; - -private: + void update(const BeginOfJob *) override; + void initRun() override; + void initEvent(const BeginOfEvent *) override; + void endEvent() override; + bool filterHit(CaloG4Hit *, double) override; - uint32_t setDetUnitId(ForwardSubdetector&, int, int, - int, int, G4ThreeVector &); - bool isItinFidVolume (const G4ThreeVector&) {return true;} +private: + uint32_t setDetUnitId(ForwardSubdetector &, int, int, int, int, G4ThreeVector &); + bool isItinFidVolume(const G4ThreeVector &) { return true; } - std::string nameX_; - HGCalGeometryMode::GeometryMode geom_mode_; + std::string nameX_; + HGCalGeometryMode::GeometryMode geom_mode_; std::unique_ptr numberingScheme_; - std::unique_ptr mouseBite_; - double eminHit_; - ForwardSubdetector myFwdSubdet_; - double slopeMin_; - int levelT_; - bool storeAllG4Hits_, rejectMB_, waferRot_; - double mouseBiteCut_; - std::vector angles_; + std::unique_ptr mouseBite_; + double eminHit_; + ForwardSubdetector myFwdSubdet_; + double slopeMin_; + int levelT_; + bool storeAllG4Hits_, rejectMB_, waferRot_; + double mouseBiteCut_; + std::vector angles_; - TTree *tree_; - uint32_t t_EventID_; - std::vector t_Layer_, t_Parcode_; - std::vector t_dEStep1_, t_dEStep2_, t_TrackE_; - std::vector t_Angle_; + TTree *tree_; + uint32_t t_EventID_; + std::vector t_Layer_, t_Parcode_; + std::vector t_dEStep1_, t_dEStep2_, t_TrackE_; + std::vector t_Angle_; }; -#endif // HGCSD_h +#endif // HGCSD_h diff --git a/SimG4CMS/Calo/interface/HGCScintSD.h b/SimG4CMS/Calo/interface/HGCScintSD.h index 185c39ffc65ef..0a796313513ee 100644 --- a/SimG4CMS/Calo/interface/HGCScintSD.h +++ b/SimG4CMS/Calo/interface/HGCScintSD.h @@ -18,39 +18,37 @@ class G4LogicalVolume; class G4Step; class HGCScintSD : public CaloSD, public Observer { +public: + HGCScintSD(const std::string &, + const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, + const SimTrackManager *); + ~HGCScintSD() override = default; -public: - - HGCScintSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, edm::ParameterSet const &, - const SimTrackManager*); - ~HGCScintSD() override = default; - - uint32_t setDetUnitId(const G4Step* step) override; + uint32_t setDetUnitId(const G4Step *step) override; protected: - - double getEnergyDeposit(const G4Step*) override; + double getEnergyDeposit(const G4Step *) override; using CaloSD::update; - void update(const BeginOfJob *) override; - void initRun() override; - bool filterHit(CaloG4Hit*, double) override; - -private: + void update(const BeginOfJob *) override; + void initRun() override; + bool filterHit(CaloG4Hit *, double) override; - uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); - bool isItinFidVolume (const G4ThreeVector&); +private: + uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); + bool isItinFidVolume(const G4ThreeVector &); - const HGCalDDDConstants* hgcons_; + const HGCalDDDConstants *hgcons_; std::unique_ptr numberingScheme_; - DetId::Detector mydet_; - std::string nameX_; - HGCalGeometryMode::GeometryMode geom_mode_; - double eminHit_, slopeMin_, distanceFromEdge_; - int levelT1_, levelT2_; - bool storeAllG4Hits_, fiducialCut_; - bool useBirk_; - double birk1_, birk2_, birk3_, weight_; + DetId::Detector mydet_; + std::string nameX_; + HGCalGeometryMode::GeometryMode geom_mode_; + double eminHit_, slopeMin_, distanceFromEdge_; + int levelT1_, levelT2_; + bool storeAllG4Hits_, fiducialCut_; + bool useBirk_; + double birk1_, birk2_, birk3_, weight_; }; -#endif // HGCScintSD_h +#endif // HGCScintSD_h diff --git a/SimG4CMS/Calo/interface/HGCalNumberingScheme.h b/SimG4CMS/Calo/interface/HGCalNumberingScheme.h index d054e4eacdbcd..4c89e658cb44d 100644 --- a/SimG4CMS/Calo/interface/HGCalNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HGCalNumberingScheme.h @@ -14,28 +14,23 @@ #include "G4ThreeVector.hh" class HGCalNumberingScheme { - public: - - HGCalNumberingScheme(const HGCalDDDConstants& hgc, - const DetId::Detector& det, const std::string& name); + HGCalNumberingScheme(const HGCalDDDConstants& hgc, const DetId::Detector& det, const std::string& name); ~HGCalNumberingScheme(); /** @short assigns the det id to a hit */ - uint32_t getUnitID(int layer, int module, int cell, int iz, - const G4ThreeVector &pos, double& wt); + uint32_t getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector& pos, double& wt); private: - - void checkPosition(uint32_t index, const G4ThreeVector &pos) const; + void checkPosition(uint32_t index, const G4ThreeVector& pos) const; HGCalNumberingScheme() = delete; - const HGCalDDDConstants& hgcons_; - const HGCalGeometryMode::GeometryMode mode_; - DetId::Detector det_; - std::string name_; + const HGCalDDDConstants& hgcons_; + const HGCalGeometryMode::GeometryMode mode_; + DetId::Detector det_; + std::string name_; }; #endif diff --git a/SimG4CMS/Calo/interface/HGCalSD.h b/SimG4CMS/Calo/interface/HGCalSD.h index 3389576b2d3f1..22db851fe9295 100644 --- a/SimG4CMS/Calo/interface/HGCalSD.h +++ b/SimG4CMS/Calo/interface/HGCalSD.h @@ -19,42 +19,40 @@ class G4LogicalVolume; class G4Step; class HGCalSD : public CaloSD, public Observer { +public: + HGCalSD(const std::string &, + const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, + const SimTrackManager *); + ~HGCalSD() override = default; -public: - - HGCalSD(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); - ~HGCalSD() override = default; - - uint32_t setDetUnitId(const G4Step* step) override; + uint32_t setDetUnitId(const G4Step *step) override; protected: - - double getEnergyDeposit(const G4Step*) override; + double getEnergyDeposit(const G4Step *) override; using CaloSD::update; - void update(const BeginOfJob *) override; - void initRun() override; - bool filterHit(CaloG4Hit*, double) override; - -private: + void update(const BeginOfJob *) override; + void initRun() override; + bool filterHit(CaloG4Hit *, double) override; - uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); - bool isItinFidVolume (const G4ThreeVector&); +private: + uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &); + bool isItinFidVolume(const G4ThreeVector &); - const HGCalDDDConstants* hgcons_; + const HGCalDDDConstants *hgcons_; std::unique_ptr numberingScheme_; - std::unique_ptr mouseBite_; - DetId::Detector mydet_; - std::string nameX_; - HGCalGeometryMode::GeometryMode geom_mode_; - double eminHit_, slopeMin_, distanceFromEdge_; - double mouseBiteCut_, weight_; - int levelT1_, levelT2_, cornerMinMask_; - bool storeAllG4Hits_; - bool fiducialCut_, rejectMB_, waferRot_; - const double tan30deg_; - std::vector angles_; + std::unique_ptr mouseBite_; + DetId::Detector mydet_; + std::string nameX_; + HGCalGeometryMode::GeometryMode geom_mode_; + double eminHit_, slopeMin_, distanceFromEdge_; + double mouseBiteCut_, weight_; + int levelT1_, levelT2_, cornerMinMask_; + bool storeAllG4Hits_; + bool fiducialCut_, rejectMB_, waferRot_; + const double tan30deg_; + std::vector angles_; }; -#endif // HGCalSD_h +#endif // HGCalSD_h diff --git a/SimG4CMS/Calo/interface/HcalNumberingFromPS.h b/SimG4CMS/Calo/interface/HcalNumberingFromPS.h index b9e6f38944d6e..f75ea57cb8d89 100644 --- a/SimG4CMS/Calo/interface/HcalNumberingFromPS.h +++ b/SimG4CMS/Calo/interface/HcalNumberingFromPS.h @@ -9,24 +9,21 @@ #include class HcalNumberingFromPS { - public: HcalNumberingFromPS(const edm::ParameterSet&); ~HcalNumberingFromPS() {} - HcalNumberingFromDDD::HcalID unitID(int det, int layer, int depth, - const math::XYZVectorD& pos) const; - std::pair getEta(const int& det, const math::XYZVectorD& pos) const; - std::pair getPhi(const int& det, const int& ieta, - const double& phi) const; + HcalNumberingFromDDD::HcalID unitID(int det, int layer, int depth, const math::XYZVectorD& pos) const; + std::pair getEta(const int& det, const math::XYZVectorD& pos) const; + std::pair getPhi(const int& det, const int& ieta, const double& phi) const; private: - static const int nEtas_=29; - std::vector etaTable_, phibin_, phioff_; - std::vector etaMin_, etaMax_, depthHBHE_; - int etaHBHE_, depth29Mx_; - double rMinHO_; - std::vector zHO_; + static const int nEtas_ = 29; + std::vector etaTable_, phibin_, phioff_; + std::vector etaMin_, etaMax_, depthHBHE_; + int etaHBHE_, depth29Mx_; + double rMinHO_; + std::vector zHO_; std::vector > segmentation_; }; diff --git a/SimG4CMS/Calo/interface/HcalNumberingScheme.h b/SimG4CMS/Calo/interface/HcalNumberingScheme.h index 4d5729b33e153..1c2e92e8bf68a 100644 --- a/SimG4CMS/Calo/interface/HcalNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HcalNumberingScheme.h @@ -11,12 +11,10 @@ #include class HcalNumberingScheme : public CaloNumberingScheme { - public: HcalNumberingScheme(); ~HcalNumberingScheme() override; virtual uint32_t getUnitID(const HcalNumberingFromDDD::HcalID& id); - }; #endif diff --git a/SimG4CMS/Calo/interface/HcalQie.h b/SimG4CMS/Calo/interface/HcalQie.h index cd048dfa7a6f2..e01e1afc1a11e 100644 --- a/SimG4CMS/Calo/interface/HcalQie.h +++ b/SimG4CMS/Calo/interface/HcalQie.h @@ -16,36 +16,31 @@ namespace CLHEP { } class HcalQie { - public: - - HcalQie(edm::ParameterSet const & p); + HcalQie(edm::ParameterSet const& p); virtual ~HcalQie(); - std::vector getCode(int, const std::vector&, CLHEP::HepRandomEngine*); - double getEnergy(const std::vector&); + std::vector getCode(int, const std::vector&, CLHEP::HepRandomEngine*); + double getEnergy(const std::vector&); private: - - std::vector shape(); - std::vector code(); - std::vector charge(); - std::vector weight(int binofmax, int mode, int npre, int numbucket); - double codeToQ(int ic); - int getCode(double charge); - double getShape(double time); + std::vector shape(); + std::vector code(); + std::vector charge(); + std::vector weight(int binofmax, int mode, int npre, int numbucket); + double codeToQ(int ic); + int getCode(double charge); + double getShape(double time); private: - - std::vector shape_; - std::vector code_; - std::vector charge_; - int binOfMax, signalBuckets, preSamples, numOfBuckets; - std::vector weight_; - double sigma, qToPE, eDepPerPE, baseline; - int bmin_, bmax_; - double phase_, rescale_; - + std::vector shape_; + std::vector code_; + std::vector charge_; + int binOfMax, signalBuckets, preSamples, numOfBuckets; + std::vector weight_; + double sigma, qToPE, eDepPerPE, baseline; + int bmin_, bmax_; + double phase_, rescale_; }; #endif diff --git a/SimG4CMS/Calo/interface/HcalTestAnalysis.h b/SimG4CMS/Calo/interface/HcalTestAnalysis.h index 543c67733b4bd..c3c2329eee215 100644 --- a/SimG4CMS/Calo/interface/HcalTestAnalysis.h +++ b/SimG4CMS/Calo/interface/HcalTestAnalysis.h @@ -21,7 +21,6 @@ #include #include - class G4Step; class BeginOfJob; class BeginOfRun; @@ -33,65 +32,63 @@ namespace CLHEP { } class HcalTestAnalysis : public SimWatcher, - public Observer, - public Observer, - public Observer, - public Observer, - public Observer { - + public Observer, + public Observer, + public Observer, + public Observer, + public Observer { public: HcalTestAnalysis(const edm::ParameterSet &p); ~HcalTestAnalysis() override; private: // observer classes - void update(const BeginOfJob * run) override; - void update(const BeginOfRun * run) override; - void update(const BeginOfEvent * evt) override; - void update(const EndOfEvent * evt) override; - void update(const G4Step * step) override; + void update(const BeginOfJob *run) override; + void update(const BeginOfRun *run) override; + void update(const BeginOfEvent *evt) override; + void update(const EndOfEvent *evt) override; + void update(const G4Step *step) override; // analysis-related stuff std::vector layerGrouping(int); std::vector towersToAdd(int centre, int nadd); - void fill(const EndOfEvent * ev); - void qieAnalysis(CLHEP::HepRandomEngine*); - void layerAnalysis(); + void fill(const EndOfEvent *ev); + void qieAnalysis(CLHEP::HepRandomEngine *); + void layerAnalysis(); double timeOfFlight(int det, int layer, double eta); private: - //Keep parameters to instantiate HcalTestHistoClass later - std::string fileName_; + std::string fileName_; // Qie Analysis - std::unique_ptr myqie_; - int addTower_; + std::unique_ptr myqie_; + int addTower_; // Private Tuples - std::unique_ptr tuplesManager_; - HcalTestHistoClass* tuples_; + std::unique_ptr tuplesManager_; + HcalTestHistoClass *tuples_; // Numbering scheme - std::unique_ptr numberingFromDDD_; - const HcalDDDSimConstants* hcons_; - HcalTestNumberingScheme* org_; + std::unique_ptr numberingFromDDD_; + const HcalDDDSimConstants *hcons_; + HcalTestNumberingScheme *org_; // Hits for qie analysis - std::vector caloHitCache_; - std::vector group_, tower_; - int nGroup_, nTower_; - + std::vector caloHitCache_; + std::vector group_, tower_; + int nGroup_, nTower_; + // to read from ParameterSet - std::vector names_; - double eta0_, phi0_; - int centralTower_; - - // some private members for ananlysis - unsigned int count_; - double edepEB_, edepEE_, edepHB_, edepHE_; - double edepHO_, edepl_[20]; - double mudist_[20]; // Distance of muon from central part + std::vector names_; + double eta0_, phi0_; + int centralTower_; + + // some private members for ananlysis + unsigned int count_; + double edepEB_, edepEE_, edepHB_, edepHE_; + double edepHO_, edepl_[20]; + double mudist_[20]; // Distance of muon from central part }; #endif diff --git a/SimG4CMS/Calo/interface/HcalTestHistoClass.h b/SimG4CMS/Calo/interface/HcalTestHistoClass.h index 380f108f54027..37c51ed6ec083 100644 --- a/SimG4CMS/Calo/interface/HcalTestHistoClass.h +++ b/SimG4CMS/Calo/interface/HcalTestHistoClass.h @@ -1,2 +1 @@ #include "SimDataFormats/CaloTest/interface/HcalTestHistoClass.h" - diff --git a/SimG4CMS/Calo/interface/HcalTestHistoManager.h b/SimG4CMS/Calo/interface/HcalTestHistoManager.h index 9a6fd893f03b9..720b594be9859 100644 --- a/SimG4CMS/Calo/interface/HcalTestHistoManager.h +++ b/SimG4CMS/Calo/interface/HcalTestHistoManager.h @@ -20,21 +20,17 @@ #include class HcalTestHistoManager { - -public: - - HcalTestHistoManager(const std::string &); +public: + HcalTestHistoManager(const std::string&); virtual ~HcalTestHistoManager(); - void fillTree(HcalTestHistoClass * histos); + void fillTree(HcalTestHistoClass* histos); private: - - edm::Service fs; - TTree *tree; - HcalTestHistoClass *h; - int kount; - + edm::Service fs_; + TTree* tree_; + std::unique_ptr h_; + int kount_; }; #endif diff --git a/SimG4CMS/Calo/interface/HcalTestNS.h b/SimG4CMS/Calo/interface/HcalTestNS.h index 1c10dd597f451..53a07711d4cf3 100644 --- a/SimG4CMS/Calo/interface/HcalTestNS.h +++ b/SimG4CMS/Calo/interface/HcalTestNS.h @@ -6,18 +6,14 @@ #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h" class HcalTestNS { - -public: - +public: HcalTestNS(const edm::EventSetup*); virtual ~HcalTestNS(); bool compare(HcalNumberingFromDDD::HcalID const&, uint32_t const&); private: - - const HcalDDDRecConstants* hcons_; - + const HcalDDDRecConstants* hcons_; }; -#endif // HcalTestNS_h +#endif // HcalTestNS_h diff --git a/SimG4CMS/Calo/interface/HcalTestNumberingScheme.h b/SimG4CMS/Calo/interface/HcalTestNumberingScheme.h index 121d6fd618963..d3b91baff008c 100644 --- a/SimG4CMS/Calo/interface/HcalTestNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HcalTestNumberingScheme.h @@ -9,17 +9,14 @@ #include "DataFormats/HcalDetId/interface/HcalTestNumbering.h" class HcalTestNumberingScheme : public HcalNumberingScheme { - public: HcalTestNumberingScheme(bool forTB); ~HcalTestNumberingScheme() override; uint32_t getUnitID(const HcalNumberingFromDDD::HcalID& id) override; - static uint32_t packHcalIndex(int det, int z, int depth, int eta, - int phi, int lay); - static void unpackHcalIndex(const uint32_t & idx, int& det, int& z, - int& depth, int& eta, int& phi, int& lay); -private: + static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay); + static void unpackHcalIndex(const uint32_t& idx, int& det, int& z, int& depth, int& eta, int& phi, int& lay); +private: HcalTestNumberingScheme() = delete; bool forTBH2; diff --git a/SimG4CMS/Calo/plugins/module.cc b/SimG4CMS/Calo/plugins/module.cc index 9285b38c8651d..91a4a0e66419a 100644 --- a/SimG4CMS/Calo/plugins/module.cc +++ b/SimG4CMS/Calo/plugins/module.cc @@ -10,7 +10,6 @@ #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" #include "SimG4Core/Watcher/interface/SimWatcherFactory.h" #include "FWCore/PluginManager/interface/ModuleDef.h" - typedef ECalSD EcalSensitiveDetector; DEFINE_SENSITIVEDETECTOR(EcalSensitiveDetector); @@ -27,5 +26,5 @@ DEFINE_SENSITIVEDETECTOR(HFNoseSensitiveDetector); DEFINE_SENSITIVEDETECTOR(CaloTrkProcessing); -DEFINE_SIMWATCHER (HcalTestAnalysis); -DEFINE_SIMWATCHER (CaloSteppingAction); +DEFINE_SIMWATCHER(HcalTestAnalysis); +DEFINE_SIMWATCHER(CaloSteppingAction); diff --git a/SimG4CMS/Calo/src/CaloG4Hit.cc b/SimG4CMS/Calo/src/CaloG4Hit.cc index 19639bb180d70..370921a223060 100644 --- a/SimG4CMS/Calo/src/CaloG4Hit.cc +++ b/SimG4CMS/Calo/src/CaloG4Hit.cc @@ -3,74 +3,64 @@ // Description: Transient Hit class for the calorimeters /////////////////////////////////////////////////////////////////////////////// #include "SimG4CMS/Calo/interface/CaloG4Hit.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include #include "G4SystemOfUnits.hh" -G4ThreadLocal G4Allocator *fpCaloG4HitAllocator = nullptr; +G4ThreadLocal G4Allocator* fpCaloG4HitAllocator = nullptr; -CaloG4Hit::CaloG4Hit(){ - - setEntry(0.,0.,0.); - setEntryLocal(0.,0.,0.); - elem = 0.; - hadr = 0.; +CaloG4Hit::CaloG4Hit() { + setEntry(0., 0., 0.); + setEntryLocal(0., 0., 0.); + elem = 0.; + hadr = 0.; theIncidentEnergy = 0.; } -CaloG4Hit::~CaloG4Hit(){} - -CaloG4Hit::CaloG4Hit(const CaloG4Hit &right) { +CaloG4Hit::~CaloG4Hit() {} - entry = right.entry; - entryLocal = right.entryLocal; - pos = right.pos; - elem = right.elem; - hadr = right.hadr; +CaloG4Hit::CaloG4Hit(const CaloG4Hit& right) { + entry = right.entry; + entryLocal = right.entryLocal; + pos = right.pos; + elem = right.elem; + hadr = right.hadr; theIncidentEnergy = right.theIncidentEnergy; - hitID = right.hitID; + hitID = right.hitID; } -const CaloG4Hit& CaloG4Hit::operator=(const CaloG4Hit &right) { - - entry = right.entry; - entryLocal = right.entryLocal; - pos = right.pos; - elem = right.elem; - hadr = right.hadr; +const CaloG4Hit& CaloG4Hit::operator=(const CaloG4Hit& right) { + entry = right.entry; + entryLocal = right.entryLocal; + pos = right.pos; + elem = right.elem; + hadr = right.hadr; theIncidentEnergy = right.theIncidentEnergy; - hitID = right.hitID; - + hitID = right.hitID; + return *this; } void CaloG4Hit::addEnergyDeposit(double em, double hd) { - - elem += em ; + elem += em; hadr += hd; } -void CaloG4Hit::addEnergyDeposit(const CaloG4Hit& aHit) { +void CaloG4Hit::addEnergyDeposit(const CaloG4Hit& aHit) { addEnergyDeposit(aHit.getEM(), aHit.getHadr()); } - addEnergyDeposit(aHit.getEM(),aHit.getHadr()); -} - -void CaloG4Hit::Print() { - LogDebug("CaloSim") << (*this); -} +void CaloG4Hit::Print() { edm::LogVerbatim("CaloSim") << (*this); } std::ostream& operator<<(std::ostream& os, const CaloG4Hit& hit) { - os << " Data of this CaloG4Hit are:" << "\n" + os << " Data of this CaloG4Hit are:" + << "\n" << " HitID: " << hit.getID() << "\n" << " EnergyDeposit of EM particles = " << hit.getEM() << "\n" << " EnergyDeposit of HD particles = " << hit.getHadr() << "\n" - << " Energy of primary particle = " << hit.getIncidentEnergy()/MeV - << " (MeV)"<< "\n" - << " Entry point in Calorimeter (global) : " << hit.getEntry() - << " (local) " << hit.getEntryLocal() << "\n" + << " Energy of primary particle = " << hit.getIncidentEnergy() / MeV << " (MeV)" + << "\n" + << " Entry point in Calorimeter (global) : " << hit.getEntry() << " (local) " << hit.getEntryLocal() << "\n" << " Position of Hit (global) : " << hit.getPosition() << "\n" << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; return os; } - - diff --git a/SimG4CMS/Calo/src/CaloGVHit.cc b/SimG4CMS/Calo/src/CaloGVHit.cc index 5cec46056c6b9..92a3da721724d 100644 --- a/SimG4CMS/Calo/src/CaloGVHit.cc +++ b/SimG4CMS/Calo/src/CaloGVHit.cc @@ -5,42 +5,37 @@ CaloGVHit::CaloGVHit() { eventID_ = 0; - elem_ = 0.; - hadr_ = 0.; + elem_ = 0.; + hadr_ = 0.; } -CaloGVHit::~CaloGVHit(){} +CaloGVHit::~CaloGVHit() {} -CaloGVHit::CaloGVHit(const CaloGVHit &right) { - eventID_ = right.eventID_; - elem_ = right.elem_; - hadr_ = right.hadr_; - hitID_ = right.hitID_; +CaloGVHit::CaloGVHit(const CaloGVHit& right) { + eventID_ = right.eventID_; + elem_ = right.elem_; + hadr_ = right.hadr_; + hitID_ = right.hitID_; } -const CaloGVHit& CaloGVHit::operator=(const CaloGVHit &right) { - eventID_ = right.eventID_; - elem_ = right.elem_; - hadr_ = right.hadr_; - hitID_ = right.hitID_; +const CaloGVHit& CaloGVHit::operator=(const CaloGVHit& right) { + eventID_ = right.eventID_; + elem_ = right.elem_; + hadr_ = right.hadr_; + hitID_ = right.hitID_; return *this; } void CaloGVHit::addEnergyDeposit(double em, double hd) { - elem_ += em ; + elem_ += em; hadr_ += hd; } -void CaloGVHit::addEnergyDeposit(const CaloGVHit& aHit) { - - addEnergyDeposit(aHit.getEM(),aHit.getHadr()); -} +void CaloGVHit::addEnergyDeposit(const CaloGVHit& aHit) { addEnergyDeposit(aHit.getEM(), aHit.getHadr()); } std::ostream& operator<<(std::ostream& os, const CaloGVHit& hit) { - os << " Data of this CaloGVHit are:" - << " EventID: " << hit.getEventID() - << " HitID: " << hit.getID() - << " EnergyDeposit (EM): " << hit.getEM() + os << " Data of this CaloGVHit are:" + << " EventID: " << hit.getEventID() << " HitID: " << hit.getID() << " EnergyDeposit (EM): " << hit.getEM() << " (Had): " << hit.getHadr() << "\n"; return os; } diff --git a/SimG4CMS/Calo/src/CaloHitID.cc b/SimG4CMS/Calo/src/CaloHitID.cc index 3f00832978c5a..fa64c6f07e136 100644 --- a/SimG4CMS/Calo/src/CaloHitID.cc +++ b/SimG4CMS/Calo/src/CaloHitID.cc @@ -6,71 +6,66 @@ #include -CaloHitID::CaloHitID(uint32_t unitID, double timeSlice, int trackID, - uint16_t depth, float tSlice, bool ignoreTkID) : - timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { +CaloHitID::CaloHitID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth, float tSlice, bool ignoreTkID) + : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { setID(unitID, timeSlice, trackID, depth); } -CaloHitID::CaloHitID(float tSlice, bool ignoreTkID) : - timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { - reset(); -} +CaloHitID::CaloHitID(float tSlice, bool ignoreTkID) : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { reset(); } -CaloHitID::CaloHitID(const CaloHitID & id) { - theUnitID = id.theUnitID; - theTimeSlice = id.theTimeSlice; - theTrackID = id.theTrackID; +CaloHitID::CaloHitID(const CaloHitID& id) { + theUnitID = id.theUnitID; + theTimeSlice = id.theTimeSlice; + theTrackID = id.theTrackID; theTimeSliceID = id.theTimeSliceID; - theDepth = id.theDepth; - timeSliceUnit = id.timeSliceUnit; - ignoreTrackID = id.ignoreTrackID; + theDepth = id.theDepth; + timeSliceUnit = id.timeSliceUnit; + ignoreTrackID = id.ignoreTrackID; } -const CaloHitID& CaloHitID::operator=(const CaloHitID & id) { - theUnitID = id.theUnitID; - theTimeSlice = id.theTimeSlice; - theTrackID = id.theTrackID; +const CaloHitID& CaloHitID::operator=(const CaloHitID& id) { + theUnitID = id.theUnitID; + theTimeSlice = id.theTimeSlice; + theTrackID = id.theTrackID; theTimeSliceID = id.theTimeSliceID; - theDepth = id.theDepth; - timeSliceUnit = id.timeSliceUnit; - ignoreTrackID = id.ignoreTrackID; + theDepth = id.theDepth; + timeSliceUnit = id.timeSliceUnit; + ignoreTrackID = id.ignoreTrackID; return *this; } CaloHitID::~CaloHitID() {} -void CaloHitID::setID(uint32_t unitID, double timeSlice, int trackID, - uint16_t depth) { - theUnitID = unitID; +void CaloHitID::setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth) { + theUnitID = unitID; theTimeSlice = timeSlice; - theTrackID = trackID; - theTimeSliceID = (int)(theTimeSlice/timeSliceUnit); - theDepth = depth; + theTrackID = trackID; + theTimeSliceID = (int)(theTimeSlice / timeSliceUnit); + theDepth = depth; } void CaloHitID::reset() { - theUnitID = 0; - theTimeSlice =-2*timeSliceUnit; - theTrackID =-2; - theTimeSliceID = (int)(theTimeSlice/timeSliceUnit); - theDepth = 0; + theUnitID = 0; + theTimeSlice = -2 * timeSliceUnit; + theTrackID = -2; + theTimeSliceID = (int)(theTimeSlice / timeSliceUnit); + theDepth = 0; } bool CaloHitID::operator==(const CaloHitID& id) const { - return ((theUnitID == id.unitID()) && - (theTrackID == id.trackID() || ignoreTrackID) && - (theTimeSliceID == id.timeSliceID()) && - (theDepth == id.depth())) ? true : false; + return ((theUnitID == id.unitID()) && (theTrackID == id.trackID() || ignoreTrackID) && + (theTimeSliceID == id.timeSliceID()) && (theDepth == id.depth())) + ? true + : false; } bool CaloHitID::operator<(const CaloHitID& id) const { if (theTrackID != id.trackID()) { return (theTrackID > id.trackID()); - } else if (theUnitID != id.unitID()) { + } else if (theUnitID != id.unitID()) { return (theUnitID > id.unitID()); - } else if (theDepth != id.depth()) { + } else if (theDepth != id.depth()) { return (theDepth > id.depth()); } else { return (theTimeSliceID > id.timeSliceID()); @@ -80,9 +75,9 @@ bool CaloHitID::operator<(const CaloHitID& id) const { bool CaloHitID::operator>(const CaloHitID& id) const { if (theTrackID != id.trackID()) { return (theTrackID < id.trackID()); - } else if (theUnitID != id.unitID()) { + } else if (theUnitID != id.unitID()) { return (theUnitID < id.unitID()); - } else if (theDepth != id.depth()) { + } else if (theDepth != id.depth()) { return (theDepth < id.depth()); } else { return (theTimeSliceID < id.timeSliceID()); @@ -90,8 +85,7 @@ bool CaloHitID::operator>(const CaloHitID& id) const { } std::ostream& operator<<(std::ostream& os, const CaloHitID& id) { - os << "UnitID 0x" << std::hex << id.unitID() << std::dec << " Depth " - << std::setw(6) << id.depth() << " Time " << std::setw(6) - << id.timeSlice() << " TrackID " << std::setw(8) << id.trackID(); + os << "UnitID 0x" << std::hex << id.unitID() << std::dec << " Depth " << std::setw(6) << id.depth() << " Time " + << std::setw(6) << id.timeSlice() << " TrackID " << std::setw(8) << id.trackID(); return os; } diff --git a/SimG4CMS/Calo/src/CaloMeanResponse.cc b/SimG4CMS/Calo/src/CaloMeanResponse.cc index 96b0cda5af32e..496e8a2fdf00e 100644 --- a/SimG4CMS/Calo/src/CaloMeanResponse.cc +++ b/SimG4CMS/Calo/src/CaloMeanResponse.cc @@ -7,28 +7,25 @@ #include #include -//#define DebugLog - -CaloMeanResponse::CaloMeanResponse(edm::ParameterSet const & p) { +//#define EDM_ML_DEBUG +CaloMeanResponse::CaloMeanResponse(edm::ParameterSet const& p) { edm::ParameterSet m_p = p.getParameter("CaloResponse"); - edm::FileInPath fp = m_p.getParameter("ResponseFile"); - std::string fName = fp.fullPath(); - useTable = m_p.getParameter("UseResponseTable"); - scale = m_p.getParameter("ResponseScale"); - edm::LogInfo("CaloSim") << "CaloMeanResponse initialized with scale " - << scale << " and use Table " << useTable - << " from file " << fName; - - readResponse (fName); + edm::FileInPath fp = m_p.getParameter("ResponseFile"); + std::string fName = fp.fullPath(); + useTable = m_p.getParameter("UseResponseTable"); + scale = m_p.getParameter("ResponseScale"); + edm::LogVerbatim("CaloSim") << "CaloMeanResponse initialized with scale " << scale << " and use Table " << useTable + << " from file " << fName; + readResponse(fName); } CaloMeanResponse::~CaloMeanResponse() {} double CaloMeanResponse::getWeight(int genPID, double genP) { double weight = 1; - bool found=false; - for (unsigned int i=0; i= 0) weight *= pionTable[piLast]; - for (unsigned int i=0; i= 0) + weight *= pionTable[piLast]; + for (unsigned int i = 0; i < pionTable.size(); i++) { + if (genP < pionMomentum[i]) { + if (i == 0) + weight = scale * pionTable[i]; + else + weight = + scale * ((pionTable[i - 1] * (pionMomentum[i] - genP) + pionTable[i] * (genP - pionMomentum[i - 1])) / + (pionMomentum[i] - pionMomentum[i - 1])); + break; + } } } -#ifdef DebugLog - LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID - << " uses pion list and gets weight " << weight - << " for momentum " << genP/GeV << " GeV/c"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses pion list and gets weight " + << weight << " for momentum " << genP / GeV << " GeV/c"; #endif } else { - for (unsigned int i=0; i= 0) weight *= protonTable[pLast]; - for (unsigned int i=0; i= 0) + weight *= protonTable[pLast]; + for (unsigned int i = 0; i < protonTable.size(); i++) { + if (genP < protonMomentum[i]) { + if (i == 0) + weight = scale * protonTable[i]; + else + weight = + scale * + ((protonTable[i - 1] * (protonMomentum[i] - genP) + protonTable[i] * (genP - protonMomentum[i - 1])) / + (protonMomentum[i] - protonMomentum[i - 1])); + break; + } + } } -#ifdef DebugLog - LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID - << " uses proton list and gets weight " << weight - << " for momentum " << genP/GeV << " GeV/c"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " uses proton list and gets " + << "weight " << weight << " for momentum " << genP / GeV << " GeV/c"; #endif } else { -#ifdef DebugLog - LogDebug("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID - << " is not in either lists and weight " << weight; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloMeanResponse::getWeight PID " << genPID << " is not in either lists and " + << "weight " << weight; #endif } } return weight; } -void CaloMeanResponse::readResponse (std::string fName) { - +void CaloMeanResponse::readResponse(std::string fName) { std::ifstream infile; infile.open(fName.c_str(), std::ios::in); if (infile) { - int nene, npart, pid; + int nene, npart, pid; double ene, responseData, responseMC, ratio; // First read the pion data infile >> nene >> npart; - for (int i=0; i> pid; pionTypes.push_back(pid); } - for (int i=0; i> ene >> responseData >> responseMC; - if (responseMC > 0) ratio = responseData/responseMC; - else ratio = 1; - pionMomentum.push_back(ene*GeV); + if (responseMC > 0) + ratio = responseData / responseMC; + else + ratio = 1; + pionMomentum.push_back(ene * GeV); pionTable.push_back(ratio); } // Then read the proton data infile >> nene >> npart; - for (int i=0; i> pid; protonTypes.push_back(pid); } - for (int i=0; i> ene >> responseData >> responseMC; - if (responseMC > 0) ratio = responseData/responseMC; - else ratio = 1; - protonMomentum.push_back(ene*GeV); + if (responseMC > 0) + ratio = responseData / responseMC; + else + ratio = 1; + protonMomentum.push_back(ene * GeV); protonTable.push_back(ratio); } infile.close(); } piLast = (int)(pionTable.size()) - 1; - pLast = (int)(protonTable.size()) - 1; -#ifdef DebugLog - LogDebug("CaloSim") << "CaloMeanResponse::readResponse finds " - << pionTypes.size() << " particles to use pion response" - << " map with a table of " << pionTable.size() - << " data points " << piLast; - for (unsigned int i=0; i " << pionTable[i]; - LogDebug("CaloSim") << "CaloMeanResponse::readResponse finds " - << protonTypes.size() << " particles to use proton " - << "response map with a table of " << protonTable.size() - << " data points " << pLast; - for (unsigned int i=0; i " << protonTable[i]; + pLast = (int)(protonTable.size()) - 1; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloMeanResponse::readResponse finds " << pionTypes.size() + << " particles to use pion " + << "response map with a table of " << pionTable.size() << " data points " << piLast; + for (unsigned int i = 0; i < pionTypes.size(); i++) + edm::LogVerbatim("CaloSim") << "Particle ID[" << i << "] = " << pionTypes[i]; + for (unsigned int i = 0; i < pionTable.size(); i++) + edm::LogVerbatim("CaloSim") << "Momentum[" << i << "] (" << pionMomentum[i] / GeV << " GeV/c) --> " << pionTable[i]; + edm::LogVerbatim("CaloSim") << "CaloMeanResponse::readResponse finds " << protonTypes.size() << " particles to use " + << "proton response map with a table of " << protonTable.size() << " data points " + << pLast; + for (unsigned int i = 0; i < protonTypes.size(); i++) + edm::LogVerbatim("CaloSim") << "Particle ID[" << i << "] = " << protonTypes[i]; + for (unsigned int i = 0; i < protonTable.size(); i++) + edm::LogVerbatim("CaloSim") << "Momentum[" << i << "] (" << protonMomentum[i] / GeV << " GeV/c) --> " + << protonTable[i]; #endif } diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index c0160f3f545eb..2ca3ae1767a0e 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -23,44 +23,55 @@ #include #include -//#define DebugLog - -CaloSD::CaloSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager, - float timeSliceUnit, bool ignoreTkID) : - SensitiveCaloDetector(name, cpv, clg, p), - G4VGFlashSensitiveDetector(), eminHit(0.),currentHit(nullptr), - m_trackManager(manager), theHC(nullptr), ignoreTrackID(ignoreTkID), hcID(-1), - timeSlice(timeSliceUnit), eminHitD(0.) { - +//#define EDM_ML_DEBUG + +CaloSD::CaloSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager, + float timeSliceUnit, + bool ignoreTkID) + : SensitiveCaloDetector(name, cpv, clg, p), + G4VGFlashSensitiveDetector(), + eminHit(0.), + currentHit(nullptr), + m_trackManager(manager), + theHC(nullptr), + ignoreTrackID(ignoreTkID), + hcID(-1), + timeSlice(timeSliceUnit), + eminHitD(0.) { //Parameters edm::ParameterSet m_CaloSD = p.getParameter("CaloSD"); - energyCut = m_CaloSD.getParameter("EminTrack")*GeV; - tmaxHit = m_CaloSD.getParameter("TmaxHit")*ns; + energyCut = m_CaloSD.getParameter("EminTrack") * GeV; + tmaxHit = m_CaloSD.getParameter("TmaxHit") * ns; std::vector eminHits = m_CaloSD.getParameter >("EminHits"); std::vector tmaxHits = m_CaloSD.getParameter >("TmaxHits"); std::vector hcn = m_CaloSD.getParameter >("HCNames"); - std::vector useResMap = m_CaloSD.getParameter >("UseResponseTables"); + std::vector useResMap = m_CaloSD.getParameter >("UseResponseTables"); std::vector eminHitX = m_CaloSD.getParameter >("EminHitsDepth"); - suppressHeavy= m_CaloSD.getParameter("SuppressHeavy"); - kmaxIon = m_CaloSD.getParameter("IonThreshold")*MeV; - kmaxProton = m_CaloSD.getParameter("ProtonThreshold")*MeV; - kmaxNeutron = m_CaloSD.getParameter("NeutronThreshold")*MeV; + suppressHeavy = m_CaloSD.getParameter("SuppressHeavy"); + kmaxIon = m_CaloSD.getParameter("IonThreshold") * MeV; + kmaxProton = m_CaloSD.getParameter("ProtonThreshold") * MeV; + kmaxNeutron = m_CaloSD.getParameter("NeutronThreshold") * MeV; nCheckedHits = m_CaloSD.getUntrackedParameter("CheckHits", 25); - useMap = m_CaloSD.getUntrackedParameter("UseMap", true); - int verbn = m_CaloSD.getUntrackedParameter("Verbosity", 0); - corrTOFBeam = m_CaloSD.getParameter("CorrectTOFBeam"); - double beamZ = m_CaloSD.getParameter("BeamPosition")*cm; - correctT = beamZ/c_light/nanosecond; + useMap = m_CaloSD.getUntrackedParameter("UseMap", true); + int verbn = m_CaloSD.getUntrackedParameter("Verbosity", 0); + corrTOFBeam = m_CaloSD.getParameter("CorrectTOFBeam"); + double beamZ = m_CaloSD.getParameter("BeamPosition") * cm; + correctT = beamZ / c_light / nanosecond; SetVerboseLevel(verbn); meanResponse.reset(nullptr); - for (unsigned int k=0; k 0) { meanResponse.reset(new CaloMeanResponse(p)); break; @@ -69,59 +80,48 @@ CaloSD::CaloSD(const std::string& name, const DDCompactView & cpv, } slave.reset(new CaloSlaveSD(name)); - currentID = CaloHitID(timeSlice, ignoreTrackID); + currentID = CaloHitID(timeSlice, ignoreTrackID); previousID = CaloHitID(timeSlice, ignoreTrackID); isParameterized = false; - - entrancePoint.set(0.,0.,0.); - entranceLocal.set(0.,0.,0.); - posGlobal.set(0.,0.,0.); + + entrancePoint.set(0., 0., 0.); + entranceLocal.set(0., 0., 0.); + posGlobal.set(0., 0., 0.); incidentEnergy = edepositEM = edepositHAD = 0.f; primAncestor = cleanIndex = totalHits = primIDSaved = 0; forceSave = false; - - edm::LogVerbatim("CaloSim") << "CaloSD: Minimum energy of track for saving it " - << energyCut/GeV << " GeV" << "\n" - << " Use of HitID Map " << useMap << "\n" - << " Check last " << nCheckedHits - << " before saving the hit\n" - << " Correct TOF globally by " << correctT - << " ns (Flag =" << corrTOFBeam << ")\n" - << " Save hits recorded before " << tmaxHit - << " ns and if energy is above " << eminHit/MeV - << " MeV (for depth 0) or " << eminHitD/MeV - << " MeV (for nonzero depths);\n" - << " Time Slice Unit " - << timeSlice << " Ignore TrackID Flag " << ignoreTrackID; -} -CaloSD::~CaloSD() -{ - delete theHC; + edm::LogVerbatim("CaloSim") << "CaloSD: Minimum energy of track for saving it " << energyCut / GeV << " GeV" + << "\n" + << " Use of HitID Map " << useMap << "\n" + << " Check last " << nCheckedHits << " before saving the hit\n" + << " Correct TOF globally by " << correctT << " ns (Flag =" << corrTOFBeam << ")\n" + << " Save hits recorded before " << tmaxHit << " ns and if energy is above " + << eminHit / MeV << " MeV (for depth 0) or " << eminHitD / MeV + << " MeV (for nonzero depths);\n" + << " Time Slice Unit " << timeSlice << " Ignore TrackID Flag " << ignoreTrackID; } -G4bool CaloSD::ProcessHits(G4Step * aStep, G4TouchableHistory * ) { - - NaNTrap( aStep ); +CaloSD::~CaloSD() { delete theHC; } + +G4bool CaloSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + NaNTrap(aStep); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() - << " ID= " << aStep->GetTrack()->GetTrackID() - << " prID= " << aStep->GetTrack()->GetParentID() - << " Eprestep= " << aStep->GetPreStepPoint()->GetKineticEnergy() - << " step= " << aStep->GetStepLength() - << " Edep= " << aStep->GetTotalEnergyDeposit(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " ID= " << aStep->GetTrack()->GetTrackID() + << " prID= " << aStep->GetTrack()->GetParentID() + << " Eprestep= " << aStep->GetPreStepPoint()->GetKineticEnergy() + << " step= " << aStep->GetStepLength() << " Edep= " << aStep->GetTotalEnergyDeposit(); #endif // apply shower library or parameterisation - if(isParameterized) { - if(getFromLibrary(aStep)) { - + if (isParameterized) { + if (getFromLibrary(aStep)) { // for parameterized showers the primary track should be killed - aStep->GetTrack()->SetTrackStatus(fStopAndKill); - auto tv = aStep->GetSecondary(); + aStep->GetTrack()->SetTrackStatus(fStopAndKill); + auto tv = aStep->GetSecondary(); auto vol = aStep->GetPreStepPoint()->GetPhysicalVolume(); - for(auto & tk : *tv) { + for (auto& tk : *tv) { if (tk->GetVolume() == vol) { tk->SetTrackStatus(fStopAndKill); } @@ -133,101 +133,91 @@ G4bool CaloSD::ProcessHits(G4Step * aStep, G4TouchableHistory * ) { // ignore steps without energy deposit edepositEM = edepositHAD = 0.f; unsigned int unitID = setDetUnitId(aStep); - auto const theTrack = aStep->GetTrack(); + auto const theTrack = aStep->GetTrack(); uint16_t depth = getDepth(aStep); - - double time = theTrack->GetGlobalTime()/nanosecond; - int primaryID = getTrackID(theTrack); - if(unitID > 0) { - currentID.setID(unitID, time, primaryID, depth); - } else { - if(aStep->GetTotalEnergyDeposit() > 0.0) { + + double time = theTrack->GetGlobalTime() / nanosecond; + int primaryID = getTrackID(theTrack); + if (unitID > 0) { + currentID.setID(unitID, time, primaryID, depth); + } else { + if (aStep->GetTotalEnergyDeposit() > 0.0) { const G4TouchableHistory* touch = static_cast(theTrack->GetTouchable()); - edm::LogVerbatim("CaloSim") << "CaloSD::ProcessHits: unitID= " << unitID - << " currUnit= " << currentID.unitID() - << " Detector: " << GetName() - << " trackID= " << theTrack->GetTrackID() << " " - << theTrack->GetDefinition()->GetParticleName() - << "\n Edep= " << aStep->GetTotalEnergyDeposit() - << " PV: " << touch->GetVolume(0)->GetName() - << " PVid= " << touch->GetReplicaNumber(0) - << " MVid= " << touch->GetReplicaNumber(1); + edm::LogVerbatim("CaloSim") << "CaloSD::ProcessHits: unitID= " << unitID << " currUnit= " << currentID.unitID() + << " Detector: " << GetName() << " trackID= " << theTrack->GetTrackID() << " " + << theTrack->GetDefinition()->GetParticleName() + << "\n Edep= " << aStep->GetTotalEnergyDeposit() + << " PV: " << touch->GetVolume(0)->GetName() + << " PVid= " << touch->GetReplicaNumber(0) << " MVid= " << touch->GetReplicaNumber(1); } return false; } - if(aStep->GetTotalEnergyDeposit() == 0.0) { - //---VI: This line is for backward compatibility and should be removed + if (aStep->GetTotalEnergyDeposit() == 0.0) { + //---VI: This line is for backward compatibility and should be removed hitExists(aStep); - //--- - return false; + //--- + return false; } double energy = getEnergyDeposit(aStep); - if(energy > 0.0) { - if(G4TrackToParticleID::isGammaElectronPositron(theTrack)) { - edepositEM = energy; + if (energy > 0.0) { + if (G4TrackToParticleID::isGammaElectronPositron(theTrack)) { + edepositEM = energy; } else { edepositHAD = energy; } -#ifdef DebugLog - G4TouchableHistory* touch =(G4TouchableHistory*)(theTrack->GetTouchable()); - edm::LogVerbatim("CaloSim") - << "CaloSD::" << GetName() - << " PV:" << touch->GetVolume(0)->GetName() - << " PVid=" << touch->GetReplicaNumber(0) - << " MVid=" << touch->GetReplicaNumber(1) - << " Unit:" << std::hex << unitID << std::dec - << " Edep=" << edepositEM << " " << edepositHAD - << " ID=" << theTrack->GetTrackID() - << " pID=" << theTrack->GetParentID() - << " E=" << theTrack->GetKineticEnergy() - << " S=" << aStep->GetStepLength() - << "\n " << theTrack->GetDefinition()->GetParticleName() - << " primaryID= " << primaryID - << " currentID= (" << currentID - << ") previousID= (" << previousID << ")"; -#endif - if(!hitExists(aStep)) { +#ifdef EDM_ML_DEBUG + G4TouchableHistory* touch = (G4TouchableHistory*)(theTrack->GetTouchable()); + edm::LogVerbatim("CaloSim") << "CaloSD::" << GetName() << " PV:" << touch->GetVolume(0)->GetName() + << " PVid=" << touch->GetReplicaNumber(0) << " MVid=" << touch->GetReplicaNumber(1) + << " Unit:" << std::hex << unitID << std::dec << " Edep=" << edepositEM << " " + << edepositHAD << " ID=" << theTrack->GetTrackID() << " pID=" << theTrack->GetParentID() + << " E=" << theTrack->GetKineticEnergy() << " S=" << aStep->GetStepLength() << "\n " + << theTrack->GetDefinition()->GetParticleName() << " primaryID= " << primaryID + << " currentID= (" << currentID << ") previousID= (" << previousID << ")"; +#endif + if (!hitExists(aStep)) { currentHit = createNewHit(aStep); } return true; } return false; -} - -bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory * ) { +} +bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory*) { edepositEM = edepositHAD = 0.f; const G4Track* track = aSpot->GetOriginatorTrack()->GetPrimaryTrack(); - if(!G4TrackToParticleID::isGammaElectronPositron(track)) { return false; } + if (!G4TrackToParticleID::isGammaElectronPositron(track)) { + return false; + } double edep = aSpot->GetEnergySpot()->GetEnergy(); - if (edep <= 0.0) { return false; } + if (edep <= 0.0) { + return false; + } edepositEM = edep; G4Step fFakeStep; - G4StepPoint * fFakePreStepPoint = fFakeStep.GetPreStepPoint(); - G4StepPoint * fFakePostStepPoint = fFakeStep.GetPostStepPoint(); + G4StepPoint* fFakePreStepPoint = fFakeStep.GetPreStepPoint(); + G4StepPoint* fFakePostStepPoint = fFakeStep.GetPostStepPoint(); fFakePreStepPoint->SetPosition(aSpot->GetPosition()); fFakePostStepPoint->SetPosition(aSpot->GetPosition()); - + G4TouchableHandle fTouchableHandle = aSpot->GetTouchableHandle(); fFakePreStepPoint->SetTouchableHandle(fTouchableHandle); fFakeStep.SetTotalEnergyDeposit(edep); - + unsigned int unitID = setDetUnitId(&fFakeStep); if (unitID > 0) { - double time = 0; + double time = 0; int primaryID = getTrackID(track); uint16_t depth = getDepth(&fFakeStep); currentID.setID(unitID, time, primaryID, depth); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD:: GetSpotInfo for" - << " Unit 0x" << std::hex << currentID.unitID() - << std::dec << " Edeposit = " << edepositEM << " " - << edepositHAD; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD:: GetSpotInfo for Unit 0x" << std::hex << currentID.unitID() << std::dec + << " Edeposit = " << edepositEM << " " << edepositHAD; #endif - // Update if in the same detector, time-slice and for same track + // Update if in the same detector, time-slice and for same track if (currentID == previousID) { updateHit(currentHit); } else { @@ -235,72 +225,69 @@ bool CaloSD::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory * ) { // Reset entry point for new primary if (currentID.trackID() != previousID.trackID()) { entrancePoint = aSpot->GetPosition(); - entranceLocal = aSpot->GetTouchableHandle()->GetHistory()-> - GetTopTransform().TransformPoint(entrancePoint); + entranceLocal = aSpot->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(entrancePoint); incidentEnergy = track->GetKineticEnergy(); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloSD: Incident energy " - << incidentEnergy/GeV << " GeV and" - << " entrance point " << entrancePoint - << " (Global) " << entranceLocal << " (Local)"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: Incident energy " << incidentEnergy / GeV << " GeV and" + << " entrance point " << entrancePoint << " (Global) " << entranceLocal + << " (Local)"; #endif } - if (!checkHit()) { currentHit = createNewHit(&fFakeStep); } + if (!checkHit()) { + currentHit = createNewHit(&fFakeStep); + } } return true; } return false; -} - -double CaloSD::getEnergyDeposit(const G4Step* aStep) { - return aStep->GetTotalEnergyDeposit(); } -bool CaloSD::getFromLibrary(const G4Step*) { - return false; -} +double CaloSD::getEnergyDeposit(const G4Step* aStep) { return aStep->GetTotalEnergyDeposit(); } -void CaloSD::Initialize(G4HCofThisEvent * HCE) { +bool CaloSD::getFromLibrary(const G4Step*) { return false; } + +void CaloSD::Initialize(G4HCofThisEvent* HCE) { totalHits = 0; - -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD : Initialize called for " << GetName(); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD : Initialize called for " << GetName(); #endif - + //This initialization is performed at the beginning of an event //------------------------------------------------------------ theHC = new CaloG4HitCollection(GetName(), collectionName[0]); - - if (hcID<0) { - hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); + + if (hcID < 0) { + hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } HCE->AddHitsCollection(hcID, theHC); } -void CaloSD::EndOfEvent(G4HCofThisEvent* ) { +void CaloSD::EndOfEvent(G4HCofThisEvent*) { // clean the hits for the last tracks - + cleanHitCollection(); - -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC->entries() - << " entries"; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: EndofEvent entered with " << theHC->entries() << " entries"; #endif } -void CaloSD::clear() {} +void CaloSD::clear() {} -void CaloSD::DrawAll() {} +void CaloSD::DrawAll() {} void CaloSD::PrintAll() { -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("CaloSim") << "CaloSD: Collection " << theHC->GetName(); #endif theHC->PrintAllHits(); -} +} void CaloSD::fillHits(edm::PCaloHitContainer& cc, const std::string& hname) { - if (slave.get()->name() == hname) { cc=slave.get()->hits(); } + if (slave.get()->name() == hname) { + cc = slave.get()->hits(); + } slave.get()->Clean(); } @@ -313,69 +300,64 @@ G4ThreeVector CaloSD::setToGlobal(const G4ThreeVector& local, const G4VTouchable } bool CaloSD::hitExists(const G4Step* aStep) { - // Update if in the same detector, time-slice and for same track + // Update if in the same detector, time-slice and for same track if (currentID == previousID) { updateHit(currentHit); return true; } - + // Reset entry point for new primary posGlobal = aStep->GetPreStepPoint()->GetPosition(); - if (currentID.trackID() != previousID.trackID()) { + if (currentID.trackID() != previousID.trackID()) { resetForNewPrimary(aStep); } return checkHit(); } -bool CaloSD::checkHit() { +bool CaloSD::checkHit() { //look in the HitContainer whether a hit with the same ID already exists: bool found = false; if (useMap) { - std::map::const_iterator it = hitMap.find(currentID); + std::map::const_iterator it = hitMap.find(currentID); if (it != hitMap.end()) { currentHit = it->second; - found = true; + found = true; } } else if (nCheckedHits > 0) { - int minhit= (theHC->entries()>nCheckedHits ? theHC->entries()-nCheckedHits : 0); - int maxhit= theHC->entries()-1; - - for (int j=maxhit; j>minhit; --j) { + int minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0); + int maxhit = theHC->entries() - 1; + + for (int j = maxhit; j > minhit; --j) { if ((*theHC)[j]->getID() == currentID) { currentHit = (*theHC)[j]; - found = true; + found = true; break; } - } + } + } + + if (found) { + updateHit(currentHit); } - - if (found) { updateHit(currentHit); } return found; } int CaloSD::getNumberOfHits() { return theHC->entries(); } CaloG4Hit* CaloSD::createNewHit(const G4Step* aStep) { - auto const theTrack = aStep->GetTrack(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::CreateNewHit " << getNumberOfHits() - << " for " << GetName() - << " Unit:" << currentID.unitID() - << " " << currentID.depth() - << " Edep= " << edepositEM << " " << edepositHAD - << " primaryID= " << currentID.trackID() - << " timeSlice= " << currentID.timeSliceID() - << " ID= " << theTrack->GetTrackID() - << " " <GetDefinition()->GetParticleName() - << " E(GeV)= " << theTrack->GetKineticEnergy()/GeV - << " parentID= " << theTrack->GetParentID() - << "\n Ein= " << incidentEnergy - << " entranceGlobal: " << entrancePoint - << " entranceLocal: " << entranceLocal - << " posGlobal: " << posGlobal; -#endif - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::CreateNewHit " << getNumberOfHits() << " for " << GetName() + << " Unit:" << currentID.unitID() << " " << currentID.depth() << " Edep= " << edepositEM + << " " << edepositHAD << " primaryID= " << currentID.trackID() + << " timeSlice= " << currentID.timeSliceID() << " ID= " << theTrack->GetTrackID() << " " + << theTrack->GetDefinition()->GetParticleName() + << " E(GeV)= " << theTrack->GetKineticEnergy() / GeV + << " parentID= " << theTrack->GetParentID() << "\n Ein= " << incidentEnergy + << " entranceGlobal: " << entrancePoint << " entranceLocal: " << entranceLocal + << " posGlobal: " << posGlobal; +#endif + CaloG4Hit* aHit; if (!reusehit.empty()) { aHit = reusehit[0]; @@ -385,24 +367,23 @@ CaloG4Hit* CaloSD::createNewHit(const G4Step* aStep) { } else { aHit = new CaloG4Hit; } - + aHit->setID(currentID); - aHit->setEntry(entrancePoint.x(),entrancePoint.y(),entrancePoint.z()); - aHit->setEntryLocal(entranceLocal.x(),entranceLocal.y(),entranceLocal.z()); - aHit->setPosition(posGlobal.x(),posGlobal.y(),posGlobal.z()); + aHit->setEntry(entrancePoint.x(), entrancePoint.y(), entrancePoint.z()); + aHit->setEntryLocal(entranceLocal.x(), entranceLocal.y(), entranceLocal.z()); + aHit->setPosition(posGlobal.x(), posGlobal.y(), posGlobal.z()); aHit->setIncidentEnergy(incidentEnergy); updateHit(aHit); - + storeHit(aHit); double etrack = 0; - if (currentID.trackID() == primIDSaved) { // The track is saved; nothing to be done + if (currentID.trackID() == primIDSaved) { // The track is saved; nothing to be done } else if (currentID.trackID() == theTrack->GetTrackID()) { - etrack= theTrack->GetKineticEnergy(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID.trackID() - << " etrack " << etrack << " eCut " << energyCut - << " force: " << forceSave - << " save: " << (etrack >= energyCut || forceSave); + etrack = theTrack->GetKineticEnergy(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID.trackID() << " etrack " << etrack + << " eCut " << energyCut << " force: " << forceSave + << " save: " << (etrack >= energyCut || forceSave); #endif if (etrack >= energyCut || forceSave) { TrackInformation* trkInfo = cmsTrackInformation(theTrack); @@ -410,52 +391,47 @@ CaloG4Hit* CaloSD::createNewHit(const G4Step* aStep) { trkInfo->putInHistory(); } } else { - TrackWithHistory * trkh = tkMap[currentID.trackID()]; -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD : TrackwithHistory pointer for " - << currentID.trackID() << " is " << trkh; + TrackWithHistory* trkh = tkMap[currentID.trackID()]; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD : TrackwithHistory pointer for " << currentID.trackID() << " is " << trkh; #endif if (trkh != nullptr) { etrack = sqrt(trkh->momentum().Mag2()); if (etrack >= energyCut) { trkh->save(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " - << currentID.trackID() << " with Hit"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: set save the track " << currentID.trackID() << " with Hit"; #endif } } } primIDSaved = currentID.trackID(); - if (useMap) ++totalHits; + if (useMap) + ++totalHits; return aHit; -} +} void CaloSD::updateHit(CaloG4Hit* aHit) { - - aHit->addEnergyDeposit(edepositEM,edepositHAD); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD:" << GetName() << " Add energy deposit in " - << currentID << " Edep_em(MeV)= " - << edepositEM << " Edep_had(MeV)= " << edepositHAD; + aHit->addEnergyDeposit(edepositEM, edepositHAD); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD:" << GetName() << " Add energy deposit in " << currentID + << " Edep_em(MeV)= " << edepositEM << " Edep_had(MeV)= " << edepositHAD; #endif // buffer for next steps: previousID = currentID; } -void CaloSD::resetForNewPrimary(const G4Step* aStep) { +void CaloSD::resetForNewPrimary(const G4Step* aStep) { auto const preStepPoint = aStep->GetPreStepPoint(); - entrancePoint = preStepPoint->GetPosition(); - entranceLocal = setToLocal(entrancePoint, preStepPoint->GetTouchable()); + entrancePoint = preStepPoint->GetPosition(); + entranceLocal = setToLocal(entrancePoint, preStepPoint->GetTouchable()); incidentEnergy = preStepPoint->GetKineticEnergy(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") - << "CaloSD::resetForNewPrimary for " << GetName() - << " ID= " << aStep->GetTrack()->GetTrackID() - << " Ein= " << incidentEnergy/GeV - << " GeV and" << " entrance point global: " << entrancePoint - << " local: " << entranceLocal; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::resetForNewPrimary for " << GetName() + << " ID= " << aStep->GetTrack()->GetTrackID() << " Ein= " << incidentEnergy / GeV + << " GeV and" + << " entrance point global: " << entrancePoint << " local: " << entranceLocal; #endif } @@ -466,172 +442,164 @@ double CaloSD::getAttenuation(const G4Step* aStep, double birk1, double birk2, d if (charge != 0. && length > 0.) { double density = aStep->GetPreStepPoint()->GetMaterial()->GetDensity(); - double dedx = aStep->GetTotalEnergyDeposit()/length; - double rkb = birk1/density; - double c = birk2*rkb*rkb; - if (std::abs(charge) >= 2.) rkb /= birk3; // based on alpha particle data - weight = 1./(1.+rkb*dedx+c*dedx*dedx); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::getAttenuation in " << mat->GetName() - << " Charge " << charge << " dE/dx " << dedx - << " Birk Const " << rkb << ", " << c << " Weight = " - << weight << " dE " << aStep->GetTotalEnergyDeposit(); + double dedx = aStep->GetTotalEnergyDeposit() / length; + double rkb = birk1 / density; + double c = birk2 * rkb * rkb; + if (std::abs(charge) >= 2.) + rkb /= birk3; // based on alpha particle data + weight = 1. / (1. + rkb * dedx + c * dedx * dedx); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::getAttenuation in " << aStep->GetPreStepPoint()->GetMaterial()->GetName() + << " Charge " << charge << " dE/dx " << dedx << " Birk Const " << rkb << ", " << c + << " Weight = " << weight << " dE " << aStep->GetTotalEnergyDeposit(); #endif } return weight; } -void CaloSD::update(const BeginOfRun *) { - initRun(); -} +void CaloSD::update(const BeginOfRun*) { initRun(); } -void CaloSD::update(const BeginOfEvent * g4Event) { -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " - << GetName() << " !" ; +void CaloSD::update(const BeginOfEvent* g4Event) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !"; #endif clearHits(); initEvent(g4Event); } -void CaloSD::update(const EndOfTrack * trk) { +void CaloSD::update(const EndOfTrack* trk) { int id = (*trk)()->GetTrackID(); - TrackInformation *trkI = cmsTrackInformation((*trk)()); + TrackInformation* trkI = cmsTrackInformation((*trk)()); int lastTrackID = -1; - if (trkI) lastTrackID = trkI->getIDonCaloSurface(); + if (trkI) + lastTrackID = trkI->getIDonCaloSurface(); if (id == lastTrackID) { - const TrackContainer * trksForThisEvent = m_trackManager->trackContainer(); + const TrackContainer* trksForThisEvent = m_trackManager->trackContainer(); if (trksForThisEvent != nullptr) { int it = (int)(trksForThisEvent->size()) - 1; if (it >= 0) { - TrackWithHistory * trkH = (*trksForThisEvent)[it]; - if (trkH->trackID() == (unsigned int)(id)) tkMap[id] = trkH; -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from " - << "Container of size " << trksForThisEvent->size() - << " with ID " << trkH->trackID(); + TrackWithHistory* trkH = (*trksForThisEvent)[it]; + if (trkH->trackID() == (unsigned int)(id)) + tkMap[id] = trkH; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size " + << trksForThisEvent->size() << " with ID " << trkH->trackID(); } else { - edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from " - << "Container of size " << trksForThisEvent->size() - << " with no ID"; + edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size " + << trksForThisEvent->size() << " with no ID"; #endif } } } } -void CaloSD::update(const ::EndOfEvent * ) { - +void CaloSD::update(const ::EndOfEvent*) { endEvent(); slave.get()->ReserveMemory(theHC->entries()); int count(0); int wrong(0); - double eEM(0.0); - double eHAD(0.0); - double eEM2(0.0); - double eHAD2(0.0); - double tt(0.0); - double zloc(0.0); - double zglob(0.0); - double ee(0.0); - - for (int i=0; ientries(); ++i) { - if(!saveHit((*theHC)[i])) { ++wrong; } + double eEM(0.0); + double eHAD(0.0); + double eEM2(0.0); + double eHAD2(0.0); + double tt(0.0); + double zloc(0.0); + double zglob(0.0); + double ee(0.0); + + for (int i = 0; i < theHC->entries(); ++i) { + if (!saveHit((*theHC)[i])) { + ++wrong; + } ++count; double x = (*theHC)[i]->getEM(); eEM += x; - eEM2 += x*x; + eEM2 += x * x; x = (*theHC)[i]->getHadr(); eHAD += x; - eHAD2 += x*x; + eHAD2 += x * x; tt += (*theHC)[i]->getTimeSlice(); ee += (*theHC)[i]->getIncidentEnergy(); zglob += std::abs((*theHC)[i]->getEntry().z()); - zloc += std::abs((*theHC)[i]->getEntryLocal().z()); + zloc += std::abs((*theHC)[i]->getEntryLocal().z()); } - - double norm = (count>0) ? 1.0/count : 0.0; - eEM *= norm; - eEM2 *= norm; - eHAD *= norm; + + double norm = (count > 0) ? 1.0 / count : 0.0; + eEM *= norm; + eEM2 *= norm; + eHAD *= norm; eHAD2 *= norm; - eEM2 = std::sqrt(eEM2 - eEM*eEM); - eHAD2 = std::sqrt(eHAD2 - eHAD*eHAD); - tt *= norm; - ee *= norm; + eEM2 = std::sqrt(eEM2 - eEM * eEM); + eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD); + tt *= norm; + ee *= norm; zglob *= norm; - zloc *= norm; - - edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count - << " hits; " << wrong - << " track IDs not given properly and " - << totalHits-count << " hits not passing cuts" - << "\n EmeanEM= " << eEM << " ErmsEM= " << eEM2 - << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 - << " TimeMean= " << tt << " E0mean= " << ee - << " Zglob= " << zglob << " Zloc= " << zloc - << " "; - - tkMap.erase (tkMap.begin(), tkMap.end()); + zloc *= norm; + + edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong + << " track IDs not given properly and " << totalHits - count + << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2 + << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt + << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " "; + + tkMap.erase(tkMap.begin(), tkMap.end()); } -void CaloSD::clearHits() { - if (useMap) hitMap.erase (hitMap.begin(), hitMap.end()); - for (unsigned int i = 0; i().swap(reusehit); - cleanIndex = 0; + cleanIndex = 0; previousID.reset(); primIDSaved = -99; -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: Clears hit vector for " << GetName() - << " and initialise slave: " << slave; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: Clears hit vector for " << GetName() + << " and initialise slave: " << slave.get()->name(); #endif slave.get()->Initialize(); } void CaloSD::initRun() {} -void CaloSD::initEvent(const BeginOfEvent *) {} +void CaloSD::initEvent(const BeginOfEvent*) {} void CaloSD::endEvent() {} int CaloSD::getTrackID(const G4Track* aTrack) { - int primaryID = 0; forceSave = false; TrackInformation* trkInfo = cmsTrackInformation(aTrack); if (trkInfo) { - primaryID = trkInfo->getIDonCaloSurface(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: hit update from track Id on Calo Surface " - << trkInfo->getIDonCaloSurface(); -#endif + primaryID = trkInfo->getIDonCaloSurface(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: hit update from track Id on Calo Surface " << trkInfo->getIDonCaloSurface(); +#endif } else { primaryID = aTrack->GetTrackID(); -#ifdef DebugLog - edm::LogWarning("CaloSim") << "CaloSD: Problem with primaryID **** set by " - << "force to TkID **** " << primaryID << " in " - << preStepPoint->GetTouchable()->GetVolume(0)->GetName(); +#ifdef EDM_ML_DEBUG + edm::LogWarning("CaloSim") << "CaloSD: Problem with primaryID **** set by force to TkID **** " << primaryID; #endif } return primaryID; } int CaloSD::setTrackID(const G4Step* aStep) { - auto const theTrack = aStep->GetTrack(); - TrackInformation * trkInfo = cmsTrackInformation(theTrack); + TrackInformation* trkInfo = cmsTrackInformation(theTrack); int primaryID = trkInfo->getIDonCaloSurface(); - if (primaryID == 0) { primaryID = theTrack->GetTrackID(); } + if (primaryID == 0) { + primaryID = theTrack->GetTrackID(); + } if (primaryID != previousID.trackID()) { resetForNewPrimary(aStep); } -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::setTrackID for " << GetName() - << " trackID= " << aStep->GetTrack()->GetTrackID() - << " primaryID= " << primaryID; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::setTrackID for " << GetName() + << " trackID= " << aStep->GetTrack()->GetTrackID() << " primaryID= " << primaryID; #endif return primaryID; } @@ -640,42 +608,44 @@ uint16_t CaloSD::getDepth(const G4Step*) { return 0; } bool CaloSD::filterHit(CaloG4Hit* hit, double time) { double emin(eminHit); - if (hit->getDepth() > 0) emin = eminHitD; -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::filterHit(..) Depth " << hit->getDepth() - << " Emin = " << emin - << " (" << eminHit << ", " << eminHitD << ")"; -#endif + if (hit->getDepth() > 0) + emin = eminHitD; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD::filterHit(..) Depth " << hit->getDepth() << " Emin = " << emin << " (" + << eminHit << ", " << eminHitD << ")"; +#endif return ((time <= tmaxHit) && (hit->getEnergyDeposit() > emin)); } double CaloSD::getResponseWt(const G4Track* aTrack) { double wt = 1.0; if (meanResponse.get()) { - TrackInformation * trkInfo = cmsTrackInformation(aTrack); + TrackInformation* trkInfo = cmsTrackInformation(aTrack); wt = meanResponse.get()->getWeight(trkInfo->genParticlePID(), trkInfo->genParticleP()); } return wt; } void CaloSD::storeHit(CaloG4Hit* hit) { - if (hit == nullptr || previousID.trackID()<0) { + if (hit == nullptr || previousID.trackID() < 0) { edm::LogWarning("CaloSim") << "CaloSD: hit to be stored is nullptr !!" - << " previousID.trackID()= " << previousID.trackID(); + << " previousID.trackID()= " << previousID.trackID(); return; } - + theHC->insert(hit); - if (useMap) hitMap.insert(std::pair(previousID,hit)); + if (useMap) + hitMap.insert(std::pair(previousID, hit)); } -bool CaloSD::saveHit(CaloG4Hit* aHit) { +bool CaloSD::saveHit(CaloG4Hit* aHit) { int tkID; - bool ok = true; + bool ok = true; if (m_trackManager) { tkID = m_trackManager->giveMotherNeeded(aHit->getTrackID()); if (tkID == 0) { - if (m_trackManager->trackExists(aHit->getTrackID())) tkID = (aHit->getTrackID()); + if (m_trackManager->trackExists(aHit->getTrackID())) + tkID = (aHit->getTrackID()); else { ok = false; } @@ -684,76 +654,72 @@ bool CaloSD::saveHit(CaloG4Hit* aHit) { tkID = aHit->getTrackID(); ok = false; } -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CalosD: Track ID " << aHit->getTrackID() - << " changed to " << tkID << " by SimTrackManager" - << " Status " << ok; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CalosD: Track ID " << aHit->getTrackID() << " changed to " << tkID + << " by SimTrackManager Status " << ok; #endif double time = aHit->getTimeSlice(); - if (corrTOFBeam) time += correctT; - slave.get()->processHits(aHit->getUnitID(), aHit->getEM()/GeV, - aHit->getHadr()/GeV, time, tkID, aHit->getDepth()); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: Store Hit at " << std::hex - << aHit->getUnitID() << std::dec << " " - << aHit->getDepth() << " due to " << tkID - << " in time " << time << " of energy " - << aHit->getEM()/GeV << " GeV (EM) and " - << aHit->getHadr()/GeV << " GeV (Hadr)"; + if (corrTOFBeam) + time += correctT; + slave.get()->processHits(aHit->getUnitID(), aHit->getEM() / GeV, aHit->getHadr() / GeV, time, tkID, aHit->getDepth()); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: Store Hit at " << std::hex << aHit->getUnitID() << std::dec << " " + << aHit->getDepth() << " due to " << tkID << " in time " << time << " of energy " + << aHit->getEM() / GeV << " GeV (EM) and " << aHit->getHadr() / GeV << " GeV (Hadr)"; #endif return ok; } -void CaloSD::update(const BeginOfTrack * trk) { +void CaloSD::update(const BeginOfTrack* trk) { int primary = -1; - TrackInformation * trkInfo = cmsTrackInformation((*trk)()); - if ( trkInfo->isPrimary() ) primary = (*trk)()->GetTrackID(); - -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() - << " primary ID = " << primary - << " primary ancestor ID " << primAncestor; -#endif - - // update the information if a different primary track ID - + TrackInformation* trkInfo = cmsTrackInformation((*trk)()); + if (trkInfo->isPrimary()) + primary = (*trk)()->GetTrackID(); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary + << " primary ancestor ID " << primAncestor; +#endif + + // update the information if a different primary track ID + if (primary > 0 && primary != primAncestor) { primAncestor = primary; - + // clean the hits information - - if (theHC->entries()>0) cleanHitCollection(); - + + if (theHC->entries() > 0) + cleanHitCollection(); } } void CaloSD::cleanHitCollection() { std::vector* theCollection = theHC->GetVector(); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: collection before merging, size = " - << theHC->entries(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: collection before merging, size = " << theHC->entries(); #endif - - selIndex.reserve(theHC->entries()-cleanIndex); - if ( reusehit.empty() ) reusehit.reserve(theHC->entries()-cleanIndex); + + selIndex.reserve(theHC->entries() - cleanIndex); + if (reusehit.empty()) + reusehit.reserve(theHC->entries() - cleanIndex); // if no map used, merge before hits to have the save situation as a map - if ( !useMap ) { + if (!useMap) { hitvec.swap(*theCollection); - sort((hitvec.begin()+cleanIndex), hitvec.end(), CaloG4HitLess()); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD::cleanHitCollection: sort hits in buffer " - << "starting from element = " << cleanIndex; - for (unsigned int i = 0; ientries(); } -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: collection after merging, size= " - << theHC->entries() - << " Size of reusehit= " << reusehit.size() - << "\n starting hit selection from index = " - << cleanIndex; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: collection after merging, size= " << theHC->entries() + << " Size of reusehit= " << reusehit.size() + << "\n starting hit selection from index = " << cleanIndex; #endif - + int addhit = 0; - selIndex.reserve(theCollection->size()-cleanIndex); - for (unsigned int i = cleanIndex; isize(); ++i) { + selIndex.reserve(theCollection->size() - cleanIndex); + for (unsigned int i = cleanIndex; i < theCollection->size(); ++i) { CaloG4Hit* aHit((*theCollection)[i]); - + // selection - + double time = aHit->getTimeSlice(); - if (corrTOFBeam) time += correctT; - if (!filterHit(aHit,time)) { -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: dropped CaloG4Hit " << " " << *aHit; + if (corrTOFBeam) + time += correctT; + if (!filterHit(aHit, time)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: dropped CaloG4Hit " + << " " << *aHit; #endif - + // create the list of hits to be reused - + reusehit.push_back((*theCollection)[i]); ++addhit; } else { - selIndex.push_back(i-cleanIndex); + selIndex.push_back(i - cleanIndex); } } -#ifdef DebugLog - edm::LogVerbatim("CaloSim") << "CaloSD: Size of reusehit after selection = " - << reusehit.size() << " Number of added hit = " - << addhit; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: Size of reusehit after selection = " << reusehit.size() + << " Number of added hit = " << addhit; #endif if (useMap) { - if ( addhit>0 ) { - int offset = reusehit.size()-addhit; - for (int ii = addhit-1; ii>=0; --ii) { - CaloHitID theID = reusehit[offset+ii]->getID(); + if (addhit > 0) { + int offset = reusehit.size() - addhit; + for (int ii = addhit - 1; ii >= 0; --ii) { + CaloHitID theID = reusehit[offset + ii]->getID(); hitMap.erase(theID); } } } - for (unsigned int j = 0; jresize(cleanIndex+selIndex.size()); + theCollection->resize(cleanIndex + selIndex.size()); std::vector().swap(selIndex); -#ifdef DebugLog - edm::LogVerbatim("CaloSim") - << "CaloSD: hit collection after selection, size = " - << theHC->entries(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloSD: hit collection after selection, size = " << theHC->entries(); theHC->PrintAllHits(); #endif - + cleanIndex = theHC->entries(); } diff --git a/SimG4CMS/Calo/src/CaloSteppingAction.cc b/SimG4CMS/Calo/src/CaloSteppingAction.cc index 33b3ab5d694ce..66353cbbc893f 100644 --- a/SimG4CMS/Calo/src/CaloSteppingAction.cc +++ b/SimG4CMS/Calo/src/CaloSteppingAction.cc @@ -30,377 +30,336 @@ //#define EDM_ML_DEBUG -CaloSteppingAction::CaloSteppingAction(const edm::ParameterSet &p) : - count_(0) { - +CaloSteppingAction::CaloSteppingAction(const edm::ParameterSet& p) : count_(0) { edm::ParameterSet iC = p.getParameter("CaloSteppingAction"); - nameEBSD_ = iC.getParameter >("EBSDNames"); - nameEESD_ = iC.getParameter >("EESDNames"); - nameHCSD_ = iC.getParameter >("HCSDNames"); - nameHitC_ = iC.getParameter >("HitCollNames"); - slopeLY_ = iC.getParameter("SlopeLightYield"); - birkC1EC_ = iC.getParameter("BirkC1EC")*(g/(MeV*cm2)); - birkSlopeEC_ = iC.getParameter("BirkSlopeEC"); - birkCutEC_ = iC.getParameter("BirkCutEC"); - birkC1HC_ = iC.getParameter("BirkC1HC")*(g/(MeV*cm2)); - birkC2HC_ = iC.getParameter("BirkC2HC"); - birkC3HC_ = iC.getParameter("BirkC3HC"); - - edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEBSD_.size() - << " names for EB SD's"; - for (unsigned int k=0; k >("EBSDNames"); + nameEESD_ = iC.getParameter >("EESDNames"); + nameHCSD_ = iC.getParameter >("HCSDNames"); + nameHitC_ = iC.getParameter >("HitCollNames"); + slopeLY_ = iC.getParameter("SlopeLightYield"); + birkC1EC_ = iC.getParameter("BirkC1EC") * (g / (MeV * cm2)); + birkSlopeEC_ = iC.getParameter("BirkSlopeEC"); + birkCutEC_ = iC.getParameter("BirkCutEC"); + birkC1HC_ = iC.getParameter("BirkC1HC") * (g / (MeV * cm2)); + birkC2HC_ = iC.getParameter("BirkC2HC"); + birkC3HC_ = iC.getParameter("BirkC3HC"); + + edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEBSD_.size() << " names for EB SD's"; + for (unsigned int k = 0; k < nameEBSD_.size(); ++k) edm::LogVerbatim("Step") << "[" << k << "] " << nameEBSD_[k]; - edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEESD_.size() - << " names for EE SD's"; - for (unsigned int k=0; k(); eeNumberingScheme_ = std::make_unique(); - hcNumberingPS_ = std::make_unique(iC); + hcNumberingPS_ = std::make_unique(iC); hcNumberingScheme_ = std::make_unique(); #ifdef HcalNumberingTest hcNumbering_.reset(nullptr); #endif - for (int k=0; k(nameHitC_[k]); produces(nameHitC_[k]); } -} - +} + CaloSteppingAction::~CaloSteppingAction() { edm::LogVerbatim("Step") << "CaloSteppingAction: --------> Total number of " - << "selected entries : " << count_; + << "selected entries : " << count_; } void CaloSteppingAction::produce(edm::Event& e, const edm::EventSetup&) { - - for (int k=0; k(); - fillHits(*product,k); - e.put(std::move(product),nameHitC_[k]); + fillHits(*product, k); + e.put(std::move(product), nameHitC_[k]); } } void CaloSteppingAction::fillHits(edm::PCaloHitContainer& cc, int type) { - edm::LogVerbatim("Step") << "CaloSteppingAction::fillHits for type " - << type << " with " - << slave_[type].get()->hits().size() << " hits"; + edm::LogVerbatim("Step") << "CaloSteppingAction::fillHits for type " << type << " with " + << slave_[type].get()->hits().size() << " hits"; cc = slave_[type].get()->hits(); slave_[type].get()->Clean(); } -void CaloSteppingAction::update(const BeginOfJob * job) { +void CaloSteppingAction::update(const BeginOfJob* job) { edm::LogVerbatim("Step") << "CaloSteppingAction:: Enter BeginOfJob"; #ifdef HcalNumberingTest // Numbering From DDD - edm::ESHandle hdc; + edm::ESHandle hdc; (*job)()->get().get(hdc); const HcalDDDSimConstants* hcons_ = hdc.product(); edm::LogVerbatim("Step") << "CaloSteppingAction:: Initialise " - << "HcalNumberingFromDDD"; + << "HcalNumberingFromDDD"; hcNumbering_ = std::make_unique(hcons_); #endif } //==================================================================== per RUN -void CaloSteppingAction::update(const BeginOfRun * run) { - +void CaloSteppingAction::update(const BeginOfRun* run) { int irun = (*run)()->GetRunID(); edm::LogVerbatim("Step") << "CaloSteppingAction:: Begin of Run = " << irun; - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); if (lvs) { - std::map nameMap; - std::map::const_iterator itr; + std::map nameMap; + std::map::const_iterator itr; for (auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi) nameMap.emplace((*lvi)->GetName(), *lvi); for (auto const& name : nameEBSD_) { for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) { - const std::string &lvname = itr->first; - if (lvname.find(name) != std::string::npos) { - volEBSD_.emplace_back(itr->second); - int type = (lvname.find("refl") == std::string::npos) ? -1 : 1; - G4Trap* solid = static_cast(itr->second->GetSolid()); - double dz = 2*solid->GetZHalfLength(); - xtalMap_.insert(std::pair(itr->second,dz*type)); - } + const std::string& lvname = itr->first; + if (lvname.find(name) != std::string::npos) { + volEBSD_.emplace_back(itr->second); + int type = (lvname.find("refl") == std::string::npos) ? -1 : 1; + G4Trap* solid = static_cast(itr->second->GetSolid()); + double dz = 2 * solid->GetZHalfLength(); + xtalMap_.insert(std::pair(itr->second, dz * type)); + } } } for (auto const& name : nameEESD_) { for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) { - const std::string &lvname = itr->first; - if (lvname.find(name) != std::string::npos) { - volEESD_.emplace_back(itr->second); - int type = (lvname.find("refl") == std::string::npos) ? 1 : -1; - G4Trap* solid = static_cast(itr->second->GetSolid()); - double dz = 2*solid->GetZHalfLength(); - xtalMap_.insert(std::pair(itr->second,dz*type)); - } + const std::string& lvname = itr->first; + if (lvname.find(name) != std::string::npos) { + volEESD_.emplace_back(itr->second); + int type = (lvname.find("refl") == std::string::npos) ? 1 : -1; + G4Trap* solid = static_cast(itr->second->GetSolid()); + double dz = 2 * solid->GetZHalfLength(); + xtalMap_.insert(std::pair(itr->second, dz * type)); + } } } for (auto const& name : nameHCSD_) { for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) { - const std::string &lvname = itr->first; - if (lvname.find(name) != std::string::npos) - volHCSD_.emplace_back(itr->second); + const std::string& lvname = itr->first; + if (lvname.find(name) != std::string::npos) + volHCSD_.emplace_back(itr->second); } } } #ifdef EDM_ML_DEBUG edm::LogVerbatim("Step") << volEBSD_.size() << " logical volumes for EB SD"; - for (unsigned int k=0; kGetEventID(); - edm::LogVerbatim("Step") <<"CaloSteppingAction: Begin of event = " - << eventID_; - for (int k=0; kGetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); - bool hc = (std::find(volHCSD_.begin(),volHCSD_.end(),lv) != volHCSD_.end()); - bool eb = (std::find(volEBSD_.begin(),volEBSD_.end(),lv)!=volEBSD_.end()); - bool ee = (std::find(volEESD_.begin(),volEESD_.end(),lv)!=volEESD_.end()); - if (hc || eb || ee) { + bool hc = (std::find(volHCSD_.begin(), volHCSD_.end(), lv) != volHCSD_.end()); + bool eb = (std::find(volEBSD_.begin(), volEBSD_.end(), lv) != volEBSD_.end()); + bool ee = (std::find(volEESD_.begin(), volEESD_.end(), lv) != volEESD_.end()); + if (hc || eb || ee) { double dEStep = aStep->GetTotalEnergyDeposit(); auto const theTrack = aStep->GetTrack(); - double time = theTrack->GetGlobalTime()/nanosecond; - int primID = theTrack->GetTrackID(); - bool em = G4TrackToParticleID::isGammaElectronPositron(theTrack); - auto const touch = aStep->GetPreStepPoint()->GetTouchable(); - auto const& hitPoint= aStep->GetPreStepPoint()->GetPosition(); + double time = theTrack->GetGlobalTime() / nanosecond; + int primID = theTrack->GetTrackID(); + bool em = G4TrackToParticleID::isGammaElectronPositron(theTrack); + auto const touch = aStep->GetPreStepPoint()->GetTouchable(); + auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition(); if (hc) { - int depth = (touch->GetReplicaNumber(0))%10 + 1; - int lay = (touch->GetReplicaNumber(0)/10)%100 + 1; - int det = (touch->GetReplicaNumber(1))/1000; - auto unitID = getDetIDHC(det, lay, depth, - math::XYZVectorD(hitPoint.x(),hitPoint.y(), - hitPoint.z())); + int depth = (touch->GetReplicaNumber(0)) % 10 + 1; + int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1; + int det = (touch->GetReplicaNumber(1)) / 1000; + auto unitID = getDetIDHC(det, lay, depth, math::XYZVectorD(hitPoint.x(), hitPoint.y(), hitPoint.z())); if (unitID > 0 && dEStep > 0.0) { - dEStep *= getBirkHC(dEStep, aStep->GetStepLength(), - aStep->GetPreStepPoint()->GetCharge(), - aStep->GetPreStepPoint()->GetMaterial()->GetDensity()); - fillHit(unitID, dEStep, time, primID, 0, em, 2); + dEStep *= getBirkHC(dEStep, + aStep->GetStepLength(), + aStep->GetPreStepPoint()->GetCharge(), + aStep->GetPreStepPoint()->GetMaterial()->GetDensity()); + fillHit(unitID, dEStep, time, primID, 0, em, 2); } } else { EcalBaseNumber theBaseNumber; - int size = touch->GetHistoryDepth()+1; - if (theBaseNumber.getCapacity() < size ) theBaseNumber.setSize(size); + int size = touch->GetHistoryDepth() + 1; + if (theBaseNumber.getCapacity() < size) + theBaseNumber.setSize(size); //Get name and copy numbers if (size > 1) { - for (int ii = 0; ii < size ; ii++) { - theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), - touch->GetReplicaNumber(ii)); - } + for (int ii = 0; ii < size; ii++) { + theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii)); + } } - auto unitID = (eb ? (ebNumberingScheme_->getUnitID(theBaseNumber)) : - (eeNumberingScheme_->getUnitID(theBaseNumber))); + auto unitID = + (eb ? (ebNumberingScheme_->getUnitID(theBaseNumber)) : (eeNumberingScheme_->getUnitID(theBaseNumber))); if (unitID > 0 && dEStep > 0.0) { - auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint); - auto ite = xtalMap_.find(lv); - double crystalLength = ((ite == xtalMap_.end()) ? 230.0 : - std::abs(ite->second)); - double crystalDepth = ((ite == xtalMap_.end()) ? 0.0 : - (std::abs(0.5*(ite->second)+local.z()))); - double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen(); - bool flag = ((ite == xtalMap_.end()) ? true : (((ite->second) >= 0) - ? true : false)); - auto depth = getDepth(flag, crystalDepth, radl); - dEStep *= (getBirkL3(dEStep,aStep->GetStepLength(), - aStep->GetPreStepPoint()->GetCharge(), - aStep->GetPreStepPoint()->GetMaterial()->GetDensity()) * - curve_LY(crystalLength,crystalDepth)); - fillHit(unitID, dEStep, time, primID, depth, em, (eb ? 0 : 1)); + auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint); + auto ite = xtalMap_.find(lv); + double crystalLength = ((ite == xtalMap_.end()) ? 230.0 : std::abs(ite->second)); + double crystalDepth = ((ite == xtalMap_.end()) ? 0.0 : (std::abs(0.5 * (ite->second) + local.z()))); + double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen(); + bool flag = ((ite == xtalMap_.end()) ? true : (((ite->second) >= 0) ? true : false)); + auto depth = getDepth(flag, crystalDepth, radl); + dEStep *= (getBirkL3(dEStep, + aStep->GetStepLength(), + aStep->GetPreStepPoint()->GetCharge(), + aStep->GetPreStepPoint()->GetMaterial()->GetDensity()) * + curve_LY(crystalLength, crystalDepth)); + fillHit(unitID, dEStep, time, primID, depth, em, (eb ? 0 : 1)); } } } } //================================================================ End of EVENT -void CaloSteppingAction::update(const EndOfEvent * evt) { - +void CaloSteppingAction::update(const EndOfEvent* evt) { ++count_; - // Fill event input - edm::LogVerbatim("Step") << "CaloSteppingAction: EndOfEvent " - << (*evt)()->GetEventID(); + // Fill event input + edm::LogVerbatim("Step") << "CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID(); } void CaloSteppingAction::NaNTrap(const G4Step* aStep) const { - auto currentPos = aStep->GetTrack()->GetPosition(); double xyz = currentPos.x() + currentPos.y() + currentPos.z(); auto currentMom = aStep->GetTrack()->GetMomentum(); xyz += currentMom.x() + currentMom.y() + currentMom.z(); if (edm::isNotFinite(xyz)) { - auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume(); + auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume(); auto& nameOfVol = pCurrentVol->GetName(); - throw cms::Exception("Unknown", "CaloSteppingAction") - << " Corrupted Event - NaN detected in volume " << nameOfVol << "\n"; + throw cms::Exception("Unknown", "CaloSteppingAction") + << " Corrupted Event - NaN detected in volume " << nameOfVol << "\n"; } } -uint32_t CaloSteppingAction::getDetIDHC(int det, int lay, int depth, - const math::XYZVectorD& pos) const { - - HcalNumberingFromDDD::HcalID tmp = hcNumberingPS_.get()->unitID(det, lay, - depth, pos); +uint32_t CaloSteppingAction::getDetIDHC(int det, int lay, int depth, const math::XYZVectorD& pos) const { + HcalNumberingFromDDD::HcalID tmp = hcNumberingPS_.get()->unitID(det, lay, depth, pos); #ifdef HcalNumberingTest auto id0 = hcNumberingScheme_.get()->getUnitID(tmp); - HcalNumberingFromDDD::HcalID tmpO= hcNumbering_.get()->unitID(det, pos, - depth, lay); + HcalNumberingFromDDD::HcalID tmpO = hcNumbering_.get()->unitID(det, pos, depth, lay); auto idO = hcNumberingScheme_.get()->getUnitID(tmpO); std::string error = (id0 == idO) ? " ** OK **" : " ** ERROR **"; - edm::LogVerbatim("Step") << "Det ID " << HcalDetId(id0) << " Original " - << HcalDetId(idO) << error; + edm::LogVerbatim("Step") << "Det ID " << HcalDetId(id0) << " Original " << HcalDetId(idO) << error; #endif return (hcNumberingScheme_.get()->getUnitID(tmp)); } -void CaloSteppingAction::fillHit(uint32_t id, double dE, double time, - int primID, uint16_t depth, double em, - int flag) { - CaloHitID currentID(id, time, primID, depth); - double edepEM = (em ? dE : 0); +void CaloSteppingAction::fillHit(uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag) { + CaloHitID currentID(id, time, primID, depth); + double edepEM = (em ? dE : 0); double edepHAD = (em ? 0 : dE); - std::pair evID = std::make_pair(eventID_,currentID); + std::pair evID = std::make_pair(eventID_, currentID); auto it = hitMap_[flag].find(evID); if (it != hitMap_[flag].end()) { - (it->second).addEnergyDeposit(edepEM,edepHAD); + (it->second).addEnergyDeposit(edepEM, edepHAD); } else { CaloGVHit aHit; aHit.setEventID(eventID_); aHit.setID(currentID); - aHit.addEnergyDeposit(edepEM,edepHAD); + aHit.addEnergyDeposit(edepEM, edepHAD); hitMap_[flag][evID] = aHit; } } -uint16_t CaloSteppingAction::getDepth(bool flag, double crystalDepth, - double radl) const { +uint16_t CaloSteppingAction::getDepth(bool flag, double crystalDepth, double radl) const { uint16_t depth1 = (flag ? 0 : PCaloHit::kEcalDepthRefz); - uint16_t depth2 = (uint16_t)floor(crystalDepth/radl); - uint16_t depth = (((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1); + uint16_t depth2 = (uint16_t)floor(crystalDepth / radl); + uint16_t depth = (((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("Step") << "CaloSteppingAction::getDepth radl " << radl - << ":" << crystalDepth << " depth " << depth; + edm::LogVerbatim("Step") << "CaloSteppingAction::getDepth radl " << radl << ":" << crystalDepth << " depth " << depth; #endif return depth; } -double CaloSteppingAction::curve_LY(double crystalLength, - double crystalDepth) const { - +double CaloSteppingAction::curve_LY(double crystalLength, double crystalDepth) const { double weight = 1.; double dapd = crystalLength - crystalDepth; - if (dapd >= -0.1 || dapd <= crystalLength+0.1) { + if (dapd >= -0.1 || dapd <= crystalLength + 0.1) { if (dapd <= 100.) weight = 1.0 + slopeLY_ - dapd * 0.01 * slopeLY_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("Step") << "CaloSteppingAction::curve_LY " << crystalDepth - << ":" << crystalLength << ":" << dapd << ":" - << weight; + edm::LogVerbatim("Step") << "CaloSteppingAction::curve_LY " << crystalDepth << ":" << crystalLength << ":" << dapd + << ":" << weight; #endif } else { edm::LogWarning("Step") << "CaloSteppingAction: light coll curve : wrong " - << "distance to APD " << dapd << " crlength = " - << crystalLength <<" crystal Depth = " - << crystalDepth << " weight = " << weight; + << "distance to APD " << dapd << " crlength = " << crystalLength + << " crystal Depth = " << crystalDepth << " weight = " << weight; } return weight; } -double CaloSteppingAction::getBirkL3(double dEStep, double step, - double charge, double density) const { - +double CaloSteppingAction::getBirkL3(double dEStep, double step, double charge, double density) const { double weight = 1.; if (charge != 0. && step > 0.) { - double dedx = dEStep/step; - double rkb = birkC1EC_/density; + double dedx = dEStep / step; + double rkb = birkC1EC_ / density; if (dedx > 0) { - weight = 1. - birkSlopeEC_*log(rkb*dedx); - if (weight < birkCutEC_) weight = birkCutEC_; - else if (weight > 1.) weight = 1.; + weight = 1. - birkSlopeEC_ * log(rkb * dedx); + if (weight < birkCutEC_) + weight = birkCutEC_; + else if (weight > 1.) + weight = 1.; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkL3 Charge " - << charge << " dE/dx " << dedx - << " Birk Const " << rkb << " Weight = " << weight - << " dE " << dEStep << " step " << step; + edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkL3 Charge " << charge << " dE/dx " << dedx << " Birk Const " + << rkb << " Weight = " << weight << " dE " << dEStep << " step " << step; #endif } return weight; } -double CaloSteppingAction::getBirkHC(double dEStep, double step, double charge, - double density) const { - +double CaloSteppingAction::getBirkHC(double dEStep, double step, double charge, double density) const { double weight = 1.; if (charge != 0. && step > 0.) { - double dedx = dEStep/step; - double rkb = birkC1HC_/density; - double c = birkC2HC_*rkb*rkb; - if (std::abs(charge) >= 2.) rkb /= birkC3HC_; - weight = 1./(1.+rkb*dedx+c*dedx*dedx); + double dedx = dEStep / step; + double rkb = birkC1HC_ / density; + double c = birkC2HC_ * rkb * rkb; + if (std::abs(charge) >= 2.) + rkb /= birkC3HC_; + weight = 1. / (1. + rkb * dedx + c * dedx * dedx); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkHC Charge " - << charge << " dE/dx " << dedx - << " Birk Const " << rkb << ", " << c - << " Weight = " << weight << " dE " - << dEStep; + edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkHC Charge " << charge << " dE/dx " << dedx << " Birk Const " + << rkb << ", " << c << " Weight = " << weight << " dE " << dEStep; #endif } return weight; } void CaloSteppingAction::saveHits(int type) { - - edm::LogVerbatim("Step") << "CaloSteppingAction:: saveHits for type " - << type << " with " << hitMap_[type].size() - << " hits"; + edm::LogVerbatim("Step") << "CaloSteppingAction:: saveHits for type " << type << " with " << hitMap_[type].size() + << " hits"; slave_[type].get()->ReserveMemory(hitMap_[type].size()); for (auto const& hit : hitMap_[type]) { slave_[type].get()->processHits(hit.second.getUnitID(), - hit.second.getEM()/GeV, - hit.second.getHadr()/GeV, - hit.second.getTimeSlice(), - hit.second.getTrackID(), - hit.second.getDepth()); + hit.second.getEM() / GeV, + hit.second.getHadr() / GeV, + hit.second.getTimeSlice(), + hit.second.getTrackID(), + hit.second.getDepth()); } } diff --git a/SimG4CMS/Calo/src/CaloTrkProcessing.cc b/SimG4CMS/Calo/src/CaloTrkProcessing.cc index f330df18822a3..a299d6deba11f 100644 --- a/SimG4CMS/Calo/src/CaloTrkProcessing.cc +++ b/SimG4CMS/Calo/src/CaloTrkProcessing.cc @@ -20,411 +20,379 @@ #include "G4SystemOfUnits.hh" -//#define DebugLog - -CaloTrkProcessing::CaloTrkProcessing(const std::string& name, - const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, - const SimTrackManager* manager) : - SensitiveCaloDetector(name, cpv, clg, p), lastTrackID(-1), - m_trackManager(manager) { - +//#define EDM_ML_DEBUG + +CaloTrkProcessing::CaloTrkProcessing(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : SensitiveCaloDetector(name, cpv, clg, p), lastTrackID(-1), m_trackManager(manager) { //Initialise the parameter set edm::ParameterSet m_p = p.getParameter("CaloTrkProcessing"); - testBeam = m_p.getParameter("TestBeam"); - eMin = m_p.getParameter("EminTrack")*MeV; + testBeam = m_p.getParameter("TestBeam"); + eMin = m_p.getParameter("EminTrack") * MeV; putHistory = m_p.getParameter("PutHistory"); - edm::LogInfo("CaloSim") << "CaloTrkProcessing: Initailised with TestBeam = " - << testBeam << " Emin = " << eMin << " MeV and" - << " History flag " << putHistory; + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Initailised with TestBeam = " << testBeam << " Emin = " << eMin + << " MeV and" + << " History flag " << putHistory; - //Get the names - G4String attribute = "ReadOutName"; - DDSpecificsMatchesValueFilter filter{DDValue(attribute,name,0)}; - DDFilteredView fv(cpv,filter); + //Get the names + G4String attribute = "ReadOutName"; + DDSpecificsMatchesValueFilter filter{DDValue(attribute, name, 0)}; + DDFilteredView fv(cpv, filter); fv.firstChild(); DDsvalues_type sv(fv.mergedSpecifics()); - G4String value = "Calorimeter"; - std::vector caloNames = getNames (value, sv); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; - for (unsigned int i=0; i caloNames = getNames(value, sv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; + for (unsigned int i = 0; i < caloNames.size(); i++) + edm::LogVerbatim("CaloSim") << " (" << i << ") " << caloNames[i]; #endif - value = "Levels"; - std::vector levels = getNumbers (value, sv); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; - for (unsigned int i=0; i levels = getNumbers(value, sv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; + for (unsigned int i = 0; i < levels.size(); i++) + edm::LogVerbatim("CaloSim") << " (" << i << ") " << levels[i]; #endif - value = "Neighbours"; - std::vector neighbours = getNumbers (value, sv); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; - for (unsigned int i=0; i neighbours = getNumbers(value, sv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; + for (unsigned int i = 0; i < neighbours.size(); i++) + edm::LogVerbatim("CaloSim") << " (" << i << ") " << neighbours[i]; #endif - value = "Inside"; - std::vector insideNames = getNames (value, sv); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; - for (unsigned int i=0; i insideNames = getNames(value, sv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; + for (unsigned int i = 0; i < insideNames.size(); i++) + edm::LogVerbatim("CaloSim") << " (" << i << ") " << insideNames[i]; #endif - value = "InsideLevel"; - std::vector insideLevel = getNumbers (value, sv); -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; - for (unsigned int i=0; i insideLevel = getNumbers(value, sv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Names for " << value << ":"; + for (unsigned int i = 0; i < insideLevel.size(); i++) + edm::LogVerbatim("CaloSim") << " (" << i << ") " << insideLevel[i]; #endif if (caloNames.size() < neighbours.size()) { - edm::LogError("CaloSim") << "CaloTrkProcessing: # of Calorimeter bins " - << caloNames.size() << " does not match with " - << neighbours.size() << " ==> illegal "; + edm::LogError("CaloSim") << "CaloTrkProcessing: # of Calorimeter bins " << caloNames.size() + << " does not match with " << neighbours.size() << " ==> illegal "; throw cms::Exception("Unknown", "CaloTrkProcessing") - << "Calorimeter array size does not match with size of neighbours\n"; + << "Calorimeter array size does not match with size of neighbours\n"; } - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); - std::vector::const_iterator lvcite; + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); + std::vector::const_iterator lvcite; int istart = 0; - for (unsigned int i=0; i(neighbours[i]); + for (unsigned int i = 0; i < caloNames.size(); i++) { + G4LogicalVolume* lv = nullptr; + G4String name = caloNames[i]; + int number = static_cast(neighbours[i]); for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) { if ((*lvcite)->GetName() == name) { - lv = (*lvcite); - break; + lv = (*lvcite); + break; } } if (lv != nullptr) { - CaloTrkProcessing::Detector detector; - detector.name = name; - detector.lv = lv; - detector.level = static_cast(levels[i]); - if (istart+number > (int)(insideNames.size())) { - edm::LogError("CaloSim") << "CaloTrkProcessing: # of InsideNames bins " - << insideNames.size() <<" too few compaerd to " - << istart+number << " requested ==> illegal "; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "InsideNames array size does not match with list of neighbours\n"; - } - std::vector inside; - std::vector insideLV; - std::vector insideLevels; - for (int k = 0; k < number; k++) { - lv = nullptr; - name = insideNames[istart+k]; - for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) - if ((*lvcite)->GetName() == name) { - lv = (*lvcite); - break; - } - inside.push_back(name); - insideLV.push_back(lv); - insideLevels.push_back(static_cast(insideLevel[istart+k])); - } - detector.fromDets = inside; - detector.fromDetL = insideLV; - detector.fromLevels = insideLevels; - detectors.push_back(detector); + CaloTrkProcessing::Detector detector; + detector.name = name; + detector.lv = lv; + detector.level = static_cast(levels[i]); + if (istart + number > (int)(insideNames.size())) { + edm::LogError("CaloSim") << "CaloTrkProcessing: # of InsideNames bins " << insideNames.size() + << " too few compaerd to " << istart + number << " requested ==> illegal "; + throw cms::Exception("Unknown", "CaloTrkProcessing") + << "InsideNames array size does not match with list of neighbours\n"; + } + std::vector inside; + std::vector insideLV; + std::vector insideLevels; + for (int k = 0; k < number; k++) { + lv = nullptr; + name = insideNames[istart + k]; + for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) + if ((*lvcite)->GetName() == name) { + lv = (*lvcite); + break; + } + inside.push_back(name); + insideLV.push_back(lv); + insideLevels.push_back(static_cast(insideLevel[istart + k])); + } + detector.fromDets = inside; + detector.fromDetL = insideLV; + detector.fromLevels = insideLevels; + detectors.push_back(detector); } istart += number; } - edm::LogInfo("CaloSim") << "CaloTrkProcessing: with " << detectors.size() - << " calorimetric volumes"; - for (unsigned int i=0; iGetTrack(); - int id = theTrack->GetTrackID(); + G4Track* theTrack = aStep->GetTrack(); + int id = theTrack->GetTrackID(); + + TrackInformation* trkInfo = dynamic_cast(theTrack->GetUserInformation()); - TrackInformation* trkInfo = dynamic_cast - (theTrack->GetUserInformation()); - if (trkInfo == nullptr) { edm::LogError("CaloSim") << "CaloTrkProcessing: No trk info !!!! abort "; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "cannot get trkInfo for Track " << id << "\n"; + throw cms::Exception("Unknown", "CaloTrkProcessing") << "cannot get trkInfo for Track " << id << "\n"; } - + if (testBeam) { if (trkInfo->getIDonCaloSurface() == 0) { -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing set IDonCaloSurface to " << id - << " at step Number " - << theTrack->GetCurrentStepNumber(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing set IDonCaloSurface to " << id << " at step Number " + << theTrack->GetCurrentStepNumber(); #endif - trkInfo->setIDonCaloSurface(id,0,0, - theTrack->GetDefinition()->GetPDGEncoding(), - theTrack->GetMomentum().mag()); + trkInfo->setIDonCaloSurface(id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag()); lastTrackID = id; - if (theTrack->GetKineticEnergy()/MeV > eMin) - trkInfo->putInHistory(); - } + if (theTrack->GetKineticEnergy() / MeV > eMin) + trkInfo->putInHistory(); + } } else { if (putHistory) { trkInfo->putInHistory(); // trkInfo->setAncestor(); } -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing Entered for " << id - << " at stepNumber "<< theTrack->GetCurrentStepNumber() - << " IDonCaloSur.. " << trkInfo->getIDonCaloSurface() - << " CaloCheck " << trkInfo->caloIDChecked(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing Entered for " << id << " at stepNumber " + << theTrack->GetCurrentStepNumber() << " IDonCaloSur.. " + << trkInfo->getIDonCaloSurface() << " CaloCheck " << trkInfo->caloIDChecked(); #endif if (trkInfo->getIDonCaloSurface() != 0) { if (trkInfo->caloIDChecked() == false) { - G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); - const G4VTouchable* post_touch = postStepPoint->GetTouchable(); + G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); + const G4VTouchable* post_touch = postStepPoint->GetTouchable(); - if (isItInside(post_touch, trkInfo->getIDCaloVolume(), - trkInfo->getIDLastVolume()) > 0) { + if (isItInside(post_touch, trkInfo->getIDCaloVolume(), trkInfo->getIDLastVolume()) > 0) { trkInfo->setIDonCaloSurface(0, -1, -1, 0, 0); } else { trkInfo->setCaloIDChecked(true); } } } else { - G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); - const G4VTouchable* post_touch = postStepPoint->GetTouchable(); - int ical = isItCalo(post_touch); + G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); + const G4VTouchable* post_touch = postStepPoint->GetTouchable(); + int ical = isItCalo(post_touch); if (ical >= 0) { - G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); - const G4VTouchable* pre_touch = preStepPoint->GetTouchable(); - int inside = isItInside(pre_touch, ical, -1); - if (inside >= 0 || (theTrack->GetCurrentStepNumber()==1)) { - trkInfo->setIDonCaloSurface(id,ical,inside, - theTrack->GetDefinition()->GetPDGEncoding(), - theTrack->GetMomentum().mag()); + G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); + const G4VTouchable* pre_touch = preStepPoint->GetTouchable(); + int inside = isItInside(pre_touch, ical, -1); + if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) { + trkInfo->setIDonCaloSurface( + id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag()); trkInfo->setCaloIDChecked(true); - lastTrackID = id; - if (theTrack->GetKineticEnergy()/MeV > eMin) trkInfo->putInHistory(); -#ifdef DebugLog - LogDebug("CaloSim") <<"CaloTrkProcessing: set ID on Calo " << ical - << " surface (Inside " << inside << ") to " - << id << " of a Track with Kinetic Energy " - << theTrack->GetKineticEnergy()/MeV << " MeV"; + lastTrackID = id; + if (theTrack->GetKineticEnergy() / MeV > eMin) + trkInfo->putInHistory(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: set ID on Calo " << ical << " surface (Inside " << inside + << ") to " << id << " of a Track with Kinetic Energy " + << theTrack->GetKineticEnergy() / MeV << " MeV"; #endif - } + } } } } } -std::vector CaloTrkProcessing::getNames(const G4String str, - const DDsvalues_type &sv){ - -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing::getNames called for " << str; +std::vector CaloTrkProcessing::getNames(const G4String str, const DDsvalues_type& sv) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing::getNames called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("CaloSim") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << value; #endif - const std::vector & fvec = value.strings(); + const std::vector& fvec = value.strings(); int nval = fvec.size(); if (nval < 1) { - - edm::LogError("CaloSim") << "CaloTrkProcessing: # of " << str - << " bins " << nval << " < 1 ==> illegal "; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "nval < 2 for array " << str << "\n"; + edm::LogError("CaloSim") << "CaloTrkProcessing: # of " << str << " bins " << nval << " < 1 ==> illegal "; + throw cms::Exception("Unknown", "CaloTrkProcessing") << "nval < 2 for array " << str << "\n"; } - + return fvec; } else { - edm::LogError("CaloSim") << "CaloTrkProcessing: cannot get array " << str ; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "cannot get array " << str << "\n"; + edm::LogError("CaloSim") << "CaloTrkProcessing: cannot get array " << str; + throw cms::Exception("Unknown", "CaloTrkProcessing") << "cannot get array " << str << "\n"; } } -std::vector CaloTrkProcessing::getNumbers(const G4String str, - const DDsvalues_type &sv) { - -#ifdef DebugLog - LogDebug("CaloSim") << "CaloTrkProcessing::getNumbers called for " << str; +std::vector CaloTrkProcessing::getNumbers(const G4String str, const DDsvalues_type& sv) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing::getNumbers called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("CaloSim") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CaloSim") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 1) { - edm::LogError("CaloSim") << "CaloTrkProcessing: # of " << str - << " bins " << nval << " < 1 ==> illegal "; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "nval < 2 for array " << str << "\n"; + edm::LogError("CaloSim") << "CaloTrkProcessing: # of " << str << " bins " << nval << " < 1 ==> illegal "; + throw cms::Exception("Unknown", "CaloTrkProcessing") << "nval < 2 for array " << str << "\n"; } - + return fvec; } else { - edm::LogError("CaloSim") << "CaloTrkProcessing: cannot get array " << str ; - throw cms::Exception("Unknown", "CaloTrkProcessing") - << "cannot get array " << str << "\n"; + edm::LogError("CaloSim") << "CaloTrkProcessing: cannot get array " << str; + throw cms::Exception("Unknown", "CaloTrkProcessing") << "cannot get array " << str << "\n"; } } int CaloTrkProcessing::isItCalo(const G4VTouchable* touch) { - int lastLevel = -1; - G4LogicalVolume* lv=nullptr; - for (unsigned int it=0; it < detectors.size(); it++) { + G4LogicalVolume* lv = nullptr; + for (unsigned int it = 0; it < detectors.size(); it++) { if (lastLevel != detectors[it].level) { lastLevel = detectors[it].level; - lv = detLV(touch, lastLevel); -#ifdef DebugLog - std::string name1 = "Unknown"; - if (lv != 0) name1 = lv->GetName(); - LogDebug("CaloSim") << "CaloTrkProcessing: volume " << name1 - << " at Level " << lastLevel; + lv = detLV(touch, lastLevel); +#ifdef EDM_ML_DEBUG + std::string name1 = "Unknown"; + if (lv != 0) + name1 = lv->GetName(); + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel; int levels = detLevels(touch); if (levels > 0) { - G4String name2[20]; int copyno2[20]; - detectorLevel(touch, levels, copyno2, name2); - for (int i2=0; i2(detectors.size());} - else {id1 = idcal; id2 = id1+1;} + if (idcal < 0) { + id1 = 0; + id2 = static_cast(detectors.size()); + } else { + id1 = idcal; + id2 = id1 + 1; + } for (int it1 = id1; it1 < id2; it1++) { if (idin < 0) { for (unsigned int it2 = 0; it2 < detectors[it1].fromDets.size(); it2++) { - if (lastLevel != detectors[it1].fromLevels[it2]) { - lastLevel = detectors[it1].fromLevels[it2]; - lv = detLV(touch,lastLevel); -#ifdef DebugLog - std::string name1 = "Unknown"; - if (lv != 0) name1 = lv->GetName(); - LogDebug("CaloSim") << "CaloTrkProcessing: volume " << name1 - << " at Level " << lastLevel; - int levels = detLevels(touch); - if (levels > 0) { - G4String name2[20]; int copyno2[20]; - detectorLevel(touch, levels, copyno2, name2); - for (int i2=0; i2GetName(); + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel; + int levels = detLevels(touch); + if (levels > 0) { + G4String name2[20]; + int copyno2[20]; + detectorLevel(touch, levels, copyno2, name2); + for (int i2 = 0; i2 < levels; i2++) + edm::LogVerbatim("CaloSim") << " " << i2 << " " << name2[i2] << " " << copyno2[i2]; + } #endif - } - bool ok = (lv == detectors[it1].fromDetL[it2]); - if (ok) return it2; + } + bool ok = (lv == detectors[it1].fromDetL[it2]); + if (ok) + return it2; } } else { lastLevel = detectors[it1].fromLevels[idin]; - lv = detLV(touch,lastLevel); -#ifdef DebugLog - std::string name1 = "Unknown"; - if (lv != 0) name1 = lv->GetName(); - LogDebug("CaloSim") << "CaloTrkProcessing: volume " << name1 - << " at Level " << lastLevel; + lv = detLV(touch, lastLevel); +#ifdef EDM_ML_DEBUG + std::string name1 = "Unknown"; + if (lv != 0) + name1 = lv->GetName(); + edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel; int levels = detLevels(touch); if (levels > 0) { - G4String name2[20]; int copyno2[20]; - detectorLevel(touch, levels, copyno2, name2); - for (int i2=0; i2GetHistoryDepth())+1); + if (touch) + return ((touch->GetHistoryDepth()) + 1); else return 0; } -G4LogicalVolume* CaloTrkProcessing::detLV(const G4VTouchable* touch, - int currentlevel) const { - - G4LogicalVolume* lv=nullptr; +G4LogicalVolume* CaloTrkProcessing::detLV(const G4VTouchable* touch, int currentlevel) const { + G4LogicalVolume* lv = nullptr; if (touch) { - int level = ((touch->GetHistoryDepth())+1); + int level = ((touch->GetHistoryDepth()) + 1); if (level > 0 && level >= currentlevel) { - int ii = level - currentlevel; - lv = touch->GetVolume(ii)->GetLogicalVolume(); + int ii = level - currentlevel; + lv = touch->GetVolume(ii)->GetLogicalVolume(); return lv; - } + } } return lv; } -void CaloTrkProcessing::detectorLevel(const G4VTouchable* touch, int& level, - int* copyno, G4String* name) const { - +void CaloTrkProcessing::detectorLevel(const G4VTouchable* touch, int& level, int* copyno, G4String* name) const { static const std::string unknown("Unknown"); //Get name and copy numbers if (level > 0) { for (int ii = 0; ii < level; ii++) { - int i = level - ii - 1; + int i = level - ii - 1; G4VPhysicalVolume* pv = touch->GetVolume(i); - if (pv != nullptr) - name[ii] = pv->GetName(); + if (pv != nullptr) + name[ii] = pv->GetName(); else - name[ii] = unknown; + name[ii] = unknown; copyno[ii] = touch->GetReplicaNumber(i); } } diff --git a/SimG4CMS/Calo/src/ECalSD.cc b/SimG4CMS/Calo/src/ECalSD.cc index f8e58278bb0d3..aa9396d19bdc3 100644 --- a/SimG4CMS/Calo/src/ECalSD.cc +++ b/SimG4CMS/Calo/src/ECalSD.cc @@ -29,23 +29,28 @@ #include "G4SystemOfUnits.hh" -#include +#include //#define EDM_ML_DEBUG template -bool any(const std::vector & v, const T &what) { +bool any(const std::vector& v, const T& what) { return std::find(v.begin(), v.end(), what) != v.end(); } -ECalSD::ECalSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager) : - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("ECalSD").getParameter("TimeSliceUnit")), - p.getParameter("ECalSD").getParameter("IgnoreTrackID")), - numberingScheme(nullptr){ - +ECalSD::ECalSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("ECalSD").getParameter("TimeSliceUnit")), + p.getParameter("ECalSD").getParameter("IgnoreTrackID")), + numberingScheme(nullptr) { // static SimpleConfigurable on1(false, "ECalSD:UseBirkLaw"); // static SimpleConfigurable bk1(0.00463,"ECalSD:BirkC1"); // static SimpleConfigurable bk2(-0.03, "ECalSD:BirkC2"); @@ -56,124 +61,125 @@ ECalSD::ECalSD(const std::string& name, const DDCompactView & cpv, // birk2 = bk2.value()*(g/(MeV*cm2))*(g/(MeV*cm2)); edm::ParameterSet m_EC = p.getParameter("ECalSD"); - useBirk = m_EC.getParameter("UseBirkLaw"); - useBirkL3 = m_EC.getParameter("BirkL3Parametrization"); - birk1 = m_EC.getParameter("BirkC1")*(g/(MeV*cm2)); - birk2 = m_EC.getParameter("BirkC2"); - birk3 = m_EC.getParameter("BirkC3"); - birkSlope = m_EC.getParameter("BirkSlope"); - birkCut = m_EC.getParameter("BirkCut"); - slopeLY = m_EC.getParameter("SlopeLightYield"); - storeTrack = m_EC.getParameter("StoreSecondary"); - crystalMat = m_EC.getUntrackedParameter("XtalMat","E_PbWO4"); - bool isItTB = m_EC.getUntrackedParameter("TestBeam", false); - bool nullNS = m_EC.getUntrackedParameter("NullNumbering", false); - storeRL = m_EC.getUntrackedParameter("StoreRadLength", false); - scaleRL = m_EC.getUntrackedParameter("ScaleRadLength",1.0); + useBirk = m_EC.getParameter("UseBirkLaw"); + useBirkL3 = m_EC.getParameter("BirkL3Parametrization"); + birk1 = m_EC.getParameter("BirkC1") * (g / (MeV * cm2)); + birk2 = m_EC.getParameter("BirkC2"); + birk3 = m_EC.getParameter("BirkC3"); + birkSlope = m_EC.getParameter("BirkSlope"); + birkCut = m_EC.getParameter("BirkCut"); + slopeLY = m_EC.getParameter("SlopeLightYield"); + storeTrack = m_EC.getParameter("StoreSecondary"); + crystalMat = m_EC.getUntrackedParameter("XtalMat", "E_PbWO4"); + bool isItTB = m_EC.getUntrackedParameter("TestBeam", false); + bool nullNS = m_EC.getUntrackedParameter("NullNumbering", false); + storeRL = m_EC.getUntrackedParameter("StoreRadLength", false); + scaleRL = m_EC.getUntrackedParameter("ScaleRadLength", 1.0); //Changes for improved timing simulation storeLayerTimeSim = m_EC.getUntrackedParameter("StoreLayerTimeSim", false); - - ageingWithSlopeLY = m_EC.getUntrackedParameter("AgeingWithSlopeLY", false); - if(ageingWithSlopeLY) ageing.setLumies(p.getParameter("ECalSD").getParameter("DelivLuminosity"), - p.getParameter("ECalSD").getParameter("InstLuminosity")); + + ageingWithSlopeLY = m_EC.getUntrackedParameter("AgeingWithSlopeLY", false); + if (ageingWithSlopeLY) + ageing.setLumies(p.getParameter("ECalSD").getParameter("DelivLuminosity"), + p.getParameter("ECalSD").getParameter("InstLuminosity")); //Material list for HB/HE/HO sensitive detectors std::string attribute = "ReadOutName"; - DDSpecificsMatchesValueFilter filter{DDValue(attribute,name,0)}; - DDFilteredView fv(cpv,filter); + DDSpecificsMatchesValueFilter filter{DDValue(attribute, name, 0)}; + DDFilteredView fv(cpv, filter); fv.firstChild(); DDsvalues_type sv(fv.mergedSpecifics()); // Use of Weight - useWeight= true; - std::vector tempD = getDDDArray("EnergyWeight",sv); - if (!tempD.empty()) { if (tempD[0] < 0.1) useWeight = false; } + useWeight = true; + std::vector tempD = getDDDArray("EnergyWeight", sv); + if (!tempD.empty()) { + if (tempD[0] < 0.1) + useWeight = false; + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD:: useWeight " << tempD.size() << ":" - << useWeight << std::endl; + edm::LogVerbatim("EcalSim") << "ECalSD:: useWeight " << tempD.size() << ":" << useWeight << std::endl; #endif - std::vector tempS = getStringArray("Depth1Name",sv); - if (!tempS.empty()) depth1Name = tempS[0]; - else depth1Name = " "; - tempS = getStringArray("Depth2Name",sv); - if (!tempS.empty()) depth2Name = tempS[0]; - else depth2Name = " "; + std::vector tempS = getStringArray("Depth1Name", sv); + if (!tempS.empty()) + depth1Name = tempS[0]; + else + depth1Name = " "; + tempS = getStringArray("Depth2Name", sv); + if (!tempS.empty()) + depth2Name = tempS[0]; + else + depth2Name = " "; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "Names (Depth 1):" << depth1Name << " (Depth 2):" - << depth2Name << std::endl; + edm::LogVerbatim("EcalSim") << "Names (Depth 1):" << depth1Name << " (Depth 2):" << depth2Name << std::endl; #endif - EcalNumberingScheme* scheme=nullptr; + EcalNumberingScheme* scheme = nullptr; if (nullNS) { scheme = nullptr; } else if (name == "EcalHitsEB") { scheme = dynamic_cast(new EcalBarrelNumberingScheme()); - isEB=true; - } else if (name == "EcalHitsEE") { + isEB = true; + } else if (name == "EcalHitsEE") { scheme = dynamic_cast(new EcalEndcapNumberingScheme()); - isEE=true; + isEE = true; } else if (name == "EcalHitsES") { - if (isItTB) scheme = dynamic_cast(new ESTBNumberingScheme()); - else scheme = dynamic_cast(new EcalPreshowerNumberingScheme()); + if (isItTB) + scheme = dynamic_cast(new ESTBNumberingScheme()); + else + scheme = dynamic_cast(new EcalPreshowerNumberingScheme()); useWeight = false; } else { edm::LogWarning("EcalSim") << "ECalSD: ReadoutName not supported"; } - if (scheme) setNumberingScheme(scheme); + if (scheme) + setNumberingScheme(scheme); #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << "Constructing a ECalSD with name " << GetName(); #endif if (useWeight) { - edm::LogVerbatim("EcalSim") << "ECalSD:: Use of Birks law is set to " - << useBirk << " with three constants kB = " - << birk1 << ", C1 = " << birk2 << ", C2 = " - << birk3 <<"\n Use of L3 parametrization " - << useBirkL3 << " with slope " << birkSlope - << " and cut off " << birkCut << "\n" - << " Slope for Light yield is set to " - << slopeLY; + edm::LogVerbatim("EcalSim") << "ECalSD:: Use of Birks law is set to " << useBirk + << " with three constants kB = " << birk1 << ", C1 = " << birk2 + << ", C2 = " << birk3 << "\n Use of L3 parametrization " << useBirkL3 + << " with slope " << birkSlope << " and cut off " << birkCut << "\n" + << " Slope for Light yield is set to " << slopeLY; } else { - edm::LogVerbatim("EcalSim") << "ECalSD:: energy deposit is not corrected " - << " by Birk or light yield curve"; + edm::LogVerbatim("EcalSim") << "ECalSD:: energy deposit is not corrected " + << " by Birk or light yield curve"; } - edm::LogVerbatim("EcalSim") << "ECalSD:: Suppression Flag " << suppressHeavy - << "\tprotons below " << kmaxProton << " MeV," - << "\tneutrons below " << kmaxNeutron << " MeV" - << "\tions below " << kmaxIon << " MeV" - << "\n\tDepth1 Name = " << depth1Name - << "\tDepth2 Name = " << depth2Name - << "\n\tstoreRL" << storeRL << ":" << scaleRL - << "\tstoreLayerTimeSim " << storeLayerTimeSim - << "\n\ttime Granularity " - << p.getParameter("ECalSD").getParameter("TimeSliceUnit") - << " ns"; - if (useWeight) initMap(name,cpv); + edm::LogVerbatim("EcalSim") << "ECalSD:: Suppression Flag " << suppressHeavy << "\tprotons below " << kmaxProton + << " MeV," + << "\tneutrons below " << kmaxNeutron << " MeV" + << "\tions below " << kmaxIon << " MeV" + << "\n\tDepth1 Name = " << depth1Name << "\tDepth2 Name = " << depth2Name << "\n\tstoreRL" + << storeRL << ":" << scaleRL << "\tstoreLayerTimeSim " << storeLayerTimeSim + << "\n\ttime Granularity " + << p.getParameter("ECalSD").getParameter("TimeSliceUnit") + << " ns"; + if (useWeight) + initMap(name, cpv); #ifdef plotDebug edm::Service tfile; - if ( tfile.isAvailable() ) { + if (tfile.isAvailable()) { TFileDirectory ecDir = tfile->mkdir("ProfileFromECalSD"); - static const std::string ctype[4] = {"EB","EBref","EE","EERef"}; - for (int k=0; k<4; ++k) { - std::string name = "ECLL_"+ctype[k]; - std::string title= "Local vs Global for "+ctype[k]; + static const std::string ctype[4] = {"EB", "EBref", "EE", "EERef"}; + for (int k = 0; k < 4; ++k) { + std::string name = "ECLL_" + ctype[k]; + std::string title = "Local vs Global for " + ctype[k]; double xmin = (k > 1) ? 3000.0 : 1000.0; - g2L_[k] = ecDir.make(name.c_str(),title.c_str(),100,xmin, - xmin+1000.,100,0.0,3000.); + g2L_[k] = ecDir.make(name.c_str(), title.c_str(), 100, xmin, xmin + 1000., 100, 0.0, 3000.); } } else { - for (int k=0; k<4; ++k) g2L_[k] = 0; + for (int k = 0; k < 4; ++k) + g2L_[k] = 0; } #endif - } -ECalSD::~ECalSD() { - delete numberingScheme; -} - -double ECalSD::getEnergyDeposit(const G4Step * aStep) { +ECalSD::~ECalSD() { delete numberingScheme; } +double ECalSD::getEnergyDeposit(const G4Step* aStep) { const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4Track* theTrack = aStep->GetTrack(); double edep = aStep->GetTotalEnergyDeposit(); @@ -181,43 +187,47 @@ double ECalSD::getEnergyDeposit(const G4Step * aStep) { // take into account light collection curve for crystals double weight = 1.; if (suppressHeavy) { - TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation()); + TrackInformation* trkInfo = (TrackInformation*)(theTrack->GetUserInformation()); if (trkInfo) { int pdg = theTrack->GetDefinition()->GetPDGEncoding(); - if (!(trkInfo->isPrimary())) { // Only secondary particles + if (!(trkInfo->isPrimary())) { // Only secondary particles double ke = theTrack->GetKineticEnergy(); - if (((pdg/1000000000 == 1 && ((pdg/10000)%100) > 0 && - ((pdg/10)%100) > 0)) && (ke 0 && ((pdg / 10) % 100) > 0)) && (ke < kmaxIon)) + weight = 0; + if ((pdg == 2212) && (ke < kmaxProton)) + weight = 0; + if ((pdg == 2112) && (ke < kmaxNeutron)) + weight = 0; } } } const G4LogicalVolume* lv = preStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume(); double wt1 = 1.0; - if (useWeight && !any(noWeight,lv)) { + if (useWeight && !any(noWeight, lv)) { weight *= curve_LY(lv); if (useBirk) { - if (useBirkL3) weight *= getBirkL3(aStep); - else weight *= getAttenuation(aStep, birk1, birk2, birk3); + if (useBirkL3) + weight *= getBirkL3(aStep); + else + weight *= getAttenuation(aStep, birk1, birk2, birk3); } wt1 = getResponseWt(theTrack); } - edep *= weight*wt1; + edep *= weight * wt1; // Russian Roulette double wt2 = theTrack->GetWeight(); - if(wt2 > 0.0) { edep *= wt2; } + if (wt2 > 0.0) { + edep *= wt2; + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << lv->GetName() - << " Light Collection Efficiency " << weight << ":" - << wt1 << " wt2= " << wt2 - << " Weighted Energy Deposit " << edep/MeV << " MeV"; + edm::LogVerbatim("EcalSim") << lv->GetName() << " Light Collection Efficiency " << weight << ":" << wt1 + << " wt2= " << wt2 << " Weighted Energy Deposit " << edep / MeV << " MeV"; #endif - return edep; + return edep; } int ECalSD::getTrackID(const G4Track* aTrack) { - int primaryID(0); + int primaryID(0); if (storeTrack && depth > 0) { forceSave = true; primaryID = aTrack->GetTrackID(); @@ -227,8 +237,7 @@ int ECalSD::getTrackID(const G4Track* aTrack) { return primaryID; } -uint16_t ECalSD::getDepth(const G4Step * aStep) { - +uint16_t ECalSD::getDepth(const G4Step* aStep) { // this method should be called first at a step const G4StepPoint* hitPoint = aStep->GetPreStepPoint(); currentLocalPoint = setToLocal(hitPoint->GetPosition(), hitPoint->GetTouchable()); @@ -236,67 +245,56 @@ uint16_t ECalSD::getDepth(const G4Step * aStep) { auto ite = xtalLMap.find(lv); crystalLength = (ite == xtalLMap.end()) ? 230.0 : std::abs(ite->second); - crystalDepth = (ite == xtalLMap.end()) - ? 0.0 : (std::abs(0.5*(ite->second)+currentLocalPoint.z())); - depth = any(useDepth1,lv) ? 1 : (any(useDepth2,lv) ? 2 : 0); + crystalDepth = (ite == xtalLMap.end()) ? 0.0 : (std::abs(0.5 * (ite->second) + currentLocalPoint.z())); + depth = any(useDepth1, lv) ? 1 : (any(useDepth2, lv) ? 2 : 0); if (storeRL) { - uint16_t depth1 = (ite == xtalLMap.end()) ? 0 : (((ite->second) >= 0) ? 0 : - PCaloHit::kEcalDepthRefz); + uint16_t depth1 = (ite == xtalLMap.end()) ? 0 : (((ite->second) >= 0) ? 0 : PCaloHit::kEcalDepthRefz); uint16_t depth2 = getRadiationLength(hitPoint, lv); - depth |= (((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1); + depth |= (((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1); } else if (storeLayerTimeSim) { uint16_t depth2 = getLayerIDForTimeSim(); - depth |= ((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset); + depth |= ((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::Depth " << std::hex << depth1 << ":" - << depth2 << ":" << depth << std::dec << " L " - << (ite == xtalLMap.end()) << ":" <second; + edm::LogVerbatim("EcalSim") << "ECalSD::Depth " << std::hex << depth1 << ":" << depth2 << ":" << depth << std::dec + << " L " << (ite == xtalLMap.end()) << ":" << ite->second; #endif return depth; } uint16_t ECalSD::getRadiationLength(const G4StepPoint* hitPoint, const G4LogicalVolume* lv) { - uint16_t thisX0 = 0; if (useWeight) { double radl = hitPoint->GetMaterial()->GetRadlen(); - thisX0 = (uint16_t)floor(scaleRL*crystalDepth/radl); + thisX0 = (uint16_t)floor(scaleRL * crystalDepth / radl); #ifdef plotDebug const std::string& lvname = lv->GetName(); - int k1 = (lvname.find("EFRY")!=std::string::npos) ? 2 : 0; - int k2 = (lvname.find("refl")!=std::string::npos) ? 1 : 0; - int kk = k1+k2; - double rz = (k1 == 0) ? (hitPoint->GetPosition()).rho() : - std::abs((hitPoint->GetPosition()).z()); - edm::LogVerbatim("EcalSim") << lvname << " # " << k1 << ":" << k2 << ":" - << kk << " rz " << rz << " D " << thisX0; - g2L_[kk]->Fill(rz,thisX0); + int k1 = (lvname.find("EFRY") != std::string::npos) ? 2 : 0; + int k2 = (lvname.find("refl") != std::string::npos) ? 1 : 0; + int kk = k1 + k2; + double rz = (k1 == 0) ? (hitPoint->GetPosition()).rho() : std::abs((hitPoint->GetPosition()).z()); + edm::LogVerbatim("EcalSim") << lvname << " # " << k1 << ":" << k2 << ":" << kk << " rz " << rz << " D " << thisX0; + g2L_[kk]->Fill(rz, thisX0); #endif #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << lv->GetName() << " Global " - << hitPoint->GetPosition() << ":" - << (hitPoint->GetPosition()).rho() - << " Local " << localPoint - << " Crystal Length " << crlength - << " Radl " << radl << " DetZ " << detz - << " Index " << thisX0 - << " : " << getLayerIDForTimeSim(); + edm::LogVerbatim("EcalSim") << lv->GetName() << " Global " << hitPoint->GetPosition() << ":" + << (hitPoint->GetPosition()).rho() << " Local " << localPoint << " Crystal Length " + << crlength << " Radl " << radl << " DetZ " << detz << " Index " << thisX0 << " : " + << getLayerIDForTimeSim(); #endif - } + } return thisX0; } -uint16_t ECalSD::getLayerIDForTimeSim() -{ - const double invLayerSize = 0.1; //layer size in 1/mm - return (int)crystalDepth*invLayerSize; +uint16_t ECalSD::getLayerIDForTimeSim() { + const double invLayerSize = 0.1; //layer size in 1/mm + return (int)crystalDepth * invLayerSize; } -uint32_t ECalSD::setDetUnitId(const G4Step * aStep) { +uint32_t ECalSD::setDetUnitId(const G4Step* aStep) { if (numberingScheme == nullptr) { - return EBDetId(1,1)(); + return EBDetId(1, 1)(); } else { getBaseNumber(aStep); return numberingScheme->getUnitID(theBaseNumber); @@ -305,50 +303,47 @@ uint32_t ECalSD::setDetUnitId(const G4Step * aStep) { void ECalSD::setNumberingScheme(EcalNumberingScheme* scheme) { if (scheme != nullptr) { - edm::LogVerbatim("EcalSim") << "EcalSD: updates numbering scheme for " - << GetName(); - if (numberingScheme) delete numberingScheme; + edm::LogVerbatim("EcalSim") << "EcalSD: updates numbering scheme for " << GetName(); + if (numberingScheme) + delete numberingScheme; numberingScheme = scheme; } } -void ECalSD::initMap(const G4String& sd, const DDCompactView & cpv) { - +void ECalSD::initMap(const G4String& sd, const DDCompactView& cpv) { G4String attribute = "ReadOutName"; - DDSpecificsMatchesValueFilter filter{DDValue(attribute,sd,0)}; - DDFilteredView fv(cpv,filter); + DDSpecificsMatchesValueFilter filter{DDValue(attribute, sd, 0)}; + DDFilteredView fv(cpv, filter); fv.firstChild(); std::vector lvused; - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); - std::map nameMap; + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); + std::map nameMap; for (auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi) nameMap.emplace((*lvi)->GetName(), *lvi); - bool dodet=true; + bool dodet = true; while (dodet) { - const std::string &matname = fv.logicalPart().material().name().name(); - const std::string &lvname = fv.logicalPart().name().name(); + const std::string& matname = fv.logicalPart().material().name().name(); + const std::string& lvname = fv.logicalPart().name().name(); const G4LogicalVolume* lv = nameMap[lvname]; int ibec = (lvname.find("EFRY") == std::string::npos) ? 0 : 1; int iref = (lvname.find("refl") == std::string::npos) ? 0 : 1; - int type = (ibec+iref == 1) ? 1 : -1; + int type = (ibec + iref == 1) ? 1 : -1; if (depth1Name != " ") { if (strncmp(lvname.c_str(), depth1Name.c_str(), 4) == 0) { if (!any(useDepth1, lv)) { - useDepth1.push_back(lv); + useDepth1.push_back(lv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname <<" in Depth 1 volume list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << " in Depth 1 volume list"; #endif } const G4LogicalVolume* lvr = nameMap[lvname + "_refl"]; if (lvr != nullptr && !any(useDepth1, lvr)) { useDepth1.push_back(lvr); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname << "_refl" - <<" in Depth 1 volume list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << "_refl" + << " in Depth 1 volume list"; #endif } } @@ -358,58 +353,52 @@ void ECalSD::initMap(const G4String& sd, const DDCompactView & cpv) { if (!any(useDepth2, lv)) { useDepth2.push_back(lv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname <<" in Depth 2 volume list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << " in Depth 2 volume list"; #endif } const G4LogicalVolume* lvr = nameMap[lvname + "_refl"]; - if (lvr != nullptr && !any(useDepth2,lvr)) { + if (lvr != nullptr && !any(useDepth2, lvr)) { useDepth2.push_back(lvr); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname << "_refl" - <<" in Depth 2 volume list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << "_refl" + << " in Depth 2 volume list"; #endif } } } if (lv != nullptr) { if (crystalMat.size() == matname.size() && !strcmp(crystalMat.c_str(), matname.c_str())) { - if (!any(lvused,lv)) { + if (!any(lvused, lv)) { lvused.push_back(lv); - const DDSolid & sol = fv.logicalPart().solid(); - const std::vector & paras = sol.parameters(); + const DDSolid& sol = fv.logicalPart().solid(); + const std::vector& paras = sol.parameters(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap (for " << sd - << "): Solid " << lvname << " Shape " - << sol.shape() << " Parameter 0 = " - << paras[0] << " Logical Volume " << lv; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap (for " << sd << "): Solid " << lvname << " Shape " + << sol.shape() << " Parameter 0 = " << paras[0] << " Logical Volume " << lv; #endif if (sol.shape() == DDSolidShape::ddtrap) { - double dz = 2*paras[0]; - xtalLMap.insert(std::pair(lv,dz*type)); + double dz = 2 * paras[0]; + xtalLMap.insert(std::pair(lv, dz * type)); lv = nameMap[lvname + "_refl"]; if (lv != nullptr) { - xtalLMap.insert(std::pair(lv,-dz*type)); + xtalLMap.insert(std::pair(lv, -dz * type)); } } } } else { - if (!any(noWeight,lv)) { + if (!any(noWeight, lv)) { noWeight.push_back(lv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname << " Material " << matname - << " in noWeight list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << " Material " << matname + << " in noWeight list"; #endif } lv = nameMap[lvname]; - if (lv != nullptr && !any(noWeight,lv)) { + if (lv != nullptr && !any(noWeight, lv)) { noWeight.push_back(lv); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " - << lvname << " Material " << matname - << " in noWeight list"; + edm::LogVerbatim("EcalSim") << "ECalSD::initMap Logical Volume " << lvname << " Material " << matname + << " in noWeight list"; #endif } } @@ -417,64 +406,58 @@ void ECalSD::initMap(const G4String& sd, const DDCompactView & cpv) { dodet = fv.next(); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD: Length Table for " << attribute << " = " - << sd << ":"; - int i=0; + edm::LogVerbatim("EcalSim") << "ECalSD: Length Table for " << attribute << " = " << sd << ":"; + int i = 0; for (auto ite : xtalLMap) { G4String name("Unknown"); - if (ite.first != 0) name = (ite.first)->GetName(); - edm::LogVerbatim("EcalSim") << " " << i << " " << ite.first << " " << name - << " L = " << ite.second; + if (ite.first != 0) + name = (ite.first)->GetName(); + edm::LogVerbatim("EcalSim") << " " << i << " " << ite.first << " " << name << " L = " << ite.second; ++i; } #endif } double ECalSD::curve_LY(const G4LogicalVolume* lv) { - double weight = 1.; if (ageingWithSlopeLY) { //position along the crystal in mm from 0 to 230 (in EB) - if (crystalDepth >= -0.1 || crystalDepth <= crystalLength+0.1) - weight = ageing.calcLightCollectionEfficiencyWeighted(currentID.unitID(), - crystalDepth/crystalLength); + if (crystalDepth >= -0.1 || crystalDepth <= crystalLength + 0.1) + weight = ageing.calcLightCollectionEfficiencyWeighted(currentID.unitID(), crystalDepth / crystalLength); } else { double dapd = crystalLength - crystalDepth; - if (dapd >= -0.1 || dapd <= crystalLength+0.1) { + if (dapd >= -0.1 || dapd <= crystalLength + 0.1) { if (dapd <= 100.) weight = 1.0 + slopeLY - dapd * 0.01 * slopeLY; } else { edm::LogWarning("EcalSim") << "ECalSD: light coll curve : wrong distance " - << "to APD " << dapd << " crlength = " - << crystalLength <<" crystal name = " <GetName() - << " z of localPoint = " << currentLocalPoint.z() - << " take weight = " << weight; + << "to APD " << dapd << " crlength = " << crystalLength + << " crystal name = " << lv->GetName() + << " z of localPoint = " << currentLocalPoint.z() << " take weight = " << weight; } } return weight; } void ECalSD::getBaseNumber(const G4Step* aStep) { - theBaseNumber.reset(); const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); - int theSize = touch->GetHistoryDepth()+1; - if ( theBaseNumber.getCapacity() < theSize ) theBaseNumber.setSize(theSize); + int theSize = touch->GetHistoryDepth() + 1; + if (theBaseNumber.getCapacity() < theSize) + theBaseNumber.setSize(theSize); //Get name and copy numbers - if ( theSize > 1 ) { - for (int ii = 0; ii < theSize ; ii++) { - theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(),touch->GetReplicaNumber(ii)); + if (theSize > 1) { + for (int ii = 0; ii < theSize; ii++) { + theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii)); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::getBaseNumber(): Adding level " << ii - << ": " << touch->GetVolume(ii)->GetName() << "[" - << touch->GetReplicaNumber(ii) << "]"; + edm::LogVerbatim("EcalSim") << "ECalSD::getBaseNumber(): Adding level " << ii << ": " + << touch->GetVolume(ii)->GetName() << "[" << touch->GetReplicaNumber(ii) << "]"; #endif } } } double ECalSD::getBirkL3(const G4Step* aStep) { - double weight = 1.; const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); double charge = preStepPoint->GetCharge(); @@ -482,35 +465,34 @@ double ECalSD::getBirkL3(const G4Step* aStep) { if (charge != 0. && aStep->GetStepLength() > 0.) { const G4Material* mat = preStepPoint->GetMaterial(); double density = mat->GetDensity(); - double dedx = aStep->GetTotalEnergyDeposit()/aStep->GetStepLength(); - double rkb = birk1/density; + double dedx = aStep->GetTotalEnergyDeposit() / aStep->GetStepLength(); + double rkb = birk1 / density; if (dedx > 0) { - weight = 1. - birkSlope*log(rkb*dedx); - if (weight < birkCut) weight = birkCut; - else if (weight > 1.) weight = 1.; + weight = 1. - birkSlope * log(rkb * dedx); + if (weight < birkCut) + weight = birkCut; + else if (weight > 1.) + weight = 1.; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "ECalSD::getBirkL3 in " << mat->GetName() - << " Charge " << charge << " dE/dx " << dedx - << " Birk Const " << rkb << " Weight = " << weight - << " dE " << aStep->GetTotalEnergyDeposit(); + edm::LogVerbatim("EcalSim") << "ECalSD::getBirkL3 in " << mat->GetName() << " Charge " << charge << " dE/dx " + << dedx << " Birk Const " << rkb << " Weight = " << weight << " dE " + << aStep->GetTotalEnergyDeposit(); #endif } return weight; } -std::vector ECalSD::getDDDArray(const std::string & str, - const DDsvalues_type & sv) { - +std::vector ECalSD::getDDDArray(const std::string& str, const DDsvalues_type& sv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << "ECalSD:getDDDArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { + if (DDfetch(&sv, value)) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); return fvec; } else { std::vector fvec; @@ -518,18 +500,16 @@ std::vector ECalSD::getDDDArray(const std::string & str, } } -std::vector ECalSD::getStringArray(const std::string & str, - const DDsvalues_type & sv) { - +std::vector ECalSD::getStringArray(const std::string& str, const DDsvalues_type& sv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << "ECalSD:getStringArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { + if (DDfetch(&sv, value)) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << value; #endif - const std::vector & fvec = value.strings(); + const std::vector& fvec = value.strings(); return fvec; } else { std::vector fvec; diff --git a/SimG4CMS/Calo/src/EnergyResolutionVsLumi.cc b/SimG4CMS/Calo/src/EnergyResolutionVsLumi.cc index 7a0b7ba5a74bb..b877f784a82ff 100644 --- a/SimG4CMS/Calo/src/EnergyResolutionVsLumi.cc +++ b/SimG4CMS/Calo/src/EnergyResolutionVsLumi.cc @@ -6,18 +6,14 @@ #include "DataFormats/EcalDetId/interface/EEDetId.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" -EnergyResolutionVsLumi::EnergyResolutionVsLumi() -{ - m_lumi=0; - m_instlumi=0; +EnergyResolutionVsLumi::EnergyResolutionVsLumi() { + m_lumi = 0; + m_instlumi = 0; } -EnergyResolutionVsLumi::~EnergyResolutionVsLumi() -{ -} +EnergyResolutionVsLumi::~EnergyResolutionVsLumi() {} -EnergyResolutionVsLumi::DegradationAtEta EnergyResolutionVsLumi::CalculateDegradation(double eta) -{ +EnergyResolutionVsLumi::DegradationAtEta EnergyResolutionVsLumi::CalculateDegradation(double eta) { DegradationAtEta result; result.eta = eta; @@ -28,136 +24,130 @@ EnergyResolutionVsLumi::DegradationAtEta EnergyResolutionVsLumi::CalculateDegrad // Index of induced absorption due to EM damages in PWO4 result.muEM = model.InducedAbsorptionEM(instLumi, eta); - + // Index of induced absorption due to hadron damages in PWO4 result.muHD = model.InducedAbsorptionHadronic(totLumi, eta); // Average degradation of amplitude due to transparency change - result.ampDropTransparency = model.DegradationMeanEM50GeV(result.muEM+result.muHD); + result.ampDropTransparency = model.DegradationMeanEM50GeV(result.muEM + result.muHD); // Average degradation of amplitude due to photo-detector aging result.ampDropPhotoDetector = model.AgingVPT(instLumi, totLumi, eta); - result.ampDropTotal = result.ampDropTransparency*result.ampDropPhotoDetector; + result.ampDropTotal = result.ampDropTransparency * result.ampDropPhotoDetector; // Noise increase in ADC counts due to photo-detector and front-end - result.noiseIncreaseADC = model.NoiseFactorFE(totLumi, eta); + result.noiseIncreaseADC = model.NoiseFactorFE(totLumi, eta); // Resolution degradation due to LY non-uniformity caused by transparency loss - result.resolutitonConstantTerm = model.ResolutionConstantTermEM50GeV(result.muEM+result.muHD); + result.resolutitonConstantTerm = model.ResolutionConstantTermEM50GeV(result.muEM + result.muHD); return result; } -double EnergyResolutionVsLumi::calcmuEM(double eta) -{ +double EnergyResolutionVsLumi::calcmuEM(double eta) { double instLumi = m_instlumi; EvolutionECAL model; double result = model.InducedAbsorptionEM(instLumi, eta); return result; } -double EnergyResolutionVsLumi::calcmuHD(double eta) -{ +double EnergyResolutionVsLumi::calcmuHD(double eta) { double totLumi = m_lumi; EvolutionECAL model; double result = model.InducedAbsorptionHadronic(totLumi, eta); return result; } -void EnergyResolutionVsLumi::calcmuTot(){ - - for(int iEta=1; iEta<=EBDetId::MAX_IETA ;++iEta) { - if(iEta==0) continue; +void EnergyResolutionVsLumi::calcmuTot() { + for (int iEta = 1; iEta <= EBDetId::MAX_IETA; ++iEta) { + if (iEta == 0) + continue; - double eta=EBDetId::approxEta(EBDetId(iEta,1)); - eta = std::abs(eta); - double r= calcmuTot(eta); - - mu_eta[iEta]=r; - vpt_eta[iEta]=1.0; + double eta = EBDetId::approxEta(EBDetId(iEta, 1)); + eta = std::abs(eta); + double r = calcmuTot(eta); + mu_eta[iEta] = r; + vpt_eta[iEta] = 1.0; } - for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) { - for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) { - if (EEDetId::validDetId(iX,iY,1)) - { - EEDetId eedetidpos(iX,iY,1); - double eta= -log(tan(0.5*atan(sqrt((iX-50.0)*(iX-50.0)+(iY-50.0)*(iY-50.0))*2.98/328.))); - eta = std::abs(eta); - double r=calcmuTot(eta); - double v=calcampDropPhotoDetector(eta); - - mu_eta[EBDetId::MAX_IETA+iX+iY*(EEDetId::IX_MAX)]=r; - vpt_eta[EBDetId::MAX_IETA+iX+iY*(EEDetId::IX_MAX)]=v; - //std::cout<<"eta/mu/vpt"<0.98) { zcor=0.98; } + if (z < 0.02) { + zcor = 0.02; + } else if (z > 0.98) { + zcor = 0.98; + } - double result=model.LightCollectionEfficiencyWeighted( zcor , muTot)*v; - - return result; + double result = model.LightCollectionEfficiencyWeighted(zcor, muTot) * v; + + return result; } -double EnergyResolutionVsLumi::calcLightCollectionEfficiencyWeighted2(double eta, double z, double mu_ind) -{ - if(mu_ind<0) mu_ind=this->calcmuTot(eta); - double v= this->calcampDropPhotoDetector(eta); +double EnergyResolutionVsLumi::calcLightCollectionEfficiencyWeighted2(double eta, double z, double mu_ind) { + if (mu_ind < 0) + mu_ind = this->calcmuTot(eta); + double v = this->calcampDropPhotoDetector(eta); EvolutionECAL model; - double result=model.LightCollectionEfficiencyWeighted( z , mu_ind)*v; - return result; + double result = model.LightCollectionEfficiencyWeighted(z, mu_ind) * v; + return result; } -double EnergyResolutionVsLumi::calcmuTot(double eta) -{ +double EnergyResolutionVsLumi::calcmuTot(double eta) { double totLumi = m_lumi; double instLumi = m_instlumi; EvolutionECAL model; double muEM = model.InducedAbsorptionEM(instLumi, eta); double muH = model.InducedAbsorptionHadronic(totLumi, eta); - double result=muEM+muH; + double result = muEM + muH; return result; -} +} -double EnergyResolutionVsLumi::calcampDropTransparency(double eta) -{ - double muEM=this->calcmuEM(eta); - double muHD=this->calcmuHD(eta); +double EnergyResolutionVsLumi::calcampDropTransparency(double eta) { + double muEM = this->calcmuEM(eta); + double muHD = this->calcmuHD(eta); EvolutionECAL model; - double result = model.DegradationMeanEM50GeV(muEM+muHD); + double result = model.DegradationMeanEM50GeV(muEM + muHD); return result; } -double EnergyResolutionVsLumi::calcampDropPhotoDetector(double eta) -{ +double EnergyResolutionVsLumi::calcampDropPhotoDetector(double eta) { double instLumi = m_instlumi; double totLumi = m_lumi; EvolutionECAL model; @@ -165,16 +155,14 @@ double EnergyResolutionVsLumi::calcampDropPhotoDetector(double eta) return result; } -double EnergyResolutionVsLumi::calcampDropTotal(double eta) -{ - double tra= this->calcampDropTransparency(eta); - double pho= this->calcampDropPhotoDetector(eta); - double result = tra*pho; +double EnergyResolutionVsLumi::calcampDropTotal(double eta) { + double tra = this->calcampDropTransparency(eta); + double pho = this->calcampDropPhotoDetector(eta); + double result = tra * pho; return result; } -double EnergyResolutionVsLumi::calcnoiseIncreaseADC(double eta) -{ +double EnergyResolutionVsLumi::calcnoiseIncreaseADC(double eta) { double totLumi = m_lumi; EvolutionECAL model; double result = model.NoiseFactorFE(totLumi, eta); @@ -182,47 +170,43 @@ double EnergyResolutionVsLumi::calcnoiseIncreaseADC(double eta) // noise increase in ADC } -double EnergyResolutionVsLumi::calcnoiseADC(double eta) -{ +double EnergyResolutionVsLumi::calcnoiseADC(double eta) { double totLumi = m_lumi; double Nadc = 1.1; - double result =1.0; + double result = 1.0; EvolutionECAL model; - if(std::abs(eta)<1.497){ + if (std::abs(eta) < 1.497) { Nadc = 1.1; - result = model.NoiseFactorFE(totLumi, eta)*Nadc; - }else{ + result = model.NoiseFactorFE(totLumi, eta) * Nadc; + } else { Nadc = 2.0; - result=Nadc; + result = Nadc; // endcaps no increase in ADC } return result; - } -double EnergyResolutionVsLumi::calcresolutitonConstantTerm(double eta) -{ - double muEM=this->calcmuEM(eta); - double muHD=this->calcmuHD(eta); +double EnergyResolutionVsLumi::calcresolutitonConstantTerm(double eta) { + double muEM = this->calcmuEM(eta); + double muHD = this->calcmuHD(eta); EvolutionECAL model; - double result = model.ResolutionConstantTermEM50GeV(muEM+muHD); + double result = model.ResolutionConstantTermEM50GeV(muEM + muHD); return result; } -double EnergyResolutionVsLumi::Resolution(double eta, double ene) -{ +double EnergyResolutionVsLumi::Resolution(double eta, double ene) { // Initial parameters for ECAL resolution double S; double Nadc; double adc2GeV; double C; - if(eta<1.497){ - S = 0.028; // CMS note 2006/148 (EB test beam) - Nadc = 1.1; + if (eta < 1.497) { + S = 0.028; // CMS note 2006/148 (EB test beam) + Nadc = 1.1; adc2GeV = 0.039; C = 0.003; - }else{ - S = 0.052; // CMS DN 2009/002 + } else { + S = 0.052; // CMS DN 2009/002 Nadc = 2.0; adc2GeV = 0.069; C = 0.004; @@ -234,11 +218,10 @@ double EnergyResolutionVsLumi::Resolution(double eta, double ene) S /= sqrt(d.ampDropTotal); Nadc *= d.noiseIncreaseADC; adc2GeV /= d.ampDropTotal; - double N = Nadc*adc2GeV*3.0; // 3x3 noise in GeV - C = sqrt(C*C + d.resolutitonConstantTerm*d.resolutitonConstantTerm); - - return sqrt(S*S/ene + N*N/ene/ene + C*C); + double N = Nadc * adc2GeV * 3.0; // 3x3 noise in GeV + C = sqrt(C * C + d.resolutitonConstantTerm * d.resolutitonConstantTerm); + return sqrt(S * S / ene + N * N / ene / ene + C * C); } /* void EnergyResolutionVsLumi::Decomposition() @@ -281,6 +264,3 @@ void EnergyResolutionVsLumi::Decomposition() } } */ - - - diff --git a/SimG4CMS/Calo/src/EvolutionECAL.cc b/SimG4CMS/Calo/src/EvolutionECAL.cc index 6f5fc7b72ed09..b4639befd6670 100644 --- a/SimG4CMS/Calo/src/EvolutionECAL.cc +++ b/SimG4CMS/Calo/src/EvolutionECAL.cc @@ -1,60 +1,55 @@ #include "SimG4CMS/Calo/interface/EvolutionECAL.h" +// destructor -// destructor +EvolutionECAL::~EvolutionECAL() {} -EvolutionECAL::~EvolutionECAL() -{ -} - -// constructor -EvolutionECAL::EvolutionECAL() -{ -} +// constructor +EvolutionECAL::EvolutionECAL() {} //_____________________________________________________ -double EvolutionECAL::LightCollectionEfficiency(double z, double mu) -{ +double EvolutionECAL::LightCollectionEfficiency(double z, double mu) { double f = 0; - if(z<=0) return f; - if(z>=0.22) return f; - - double e0 = 6.91563e-02; - double e1 = 1.64406e+00; - double e2 = 6.42509e-01; - double E = e0/(1+exp(e1*(log10(mu)-e2))); + if (z <= 0) + return f; + if (z >= 0.22) + return f; - double d0 = 3.85334e-01; + double e0 = 6.91563e-02; + double e1 = 1.64406e+00; + double e2 = 6.42509e-01; + double E = e0 / (1 + exp(e1 * (log10(mu) - e2))); + + double d0 = 3.85334e-01; double d1 = -1.04647e-02; - double D = d0*exp(d1*mu); + double D = d0 * exp(d1 * mu); - double c0 = 3.77629e-01; + double c0 = 3.77629e-01; double c1 = -3.23755e-01; - double c2 = 1.50247e+00; - double c3 = 3.03278e-01; - double C = -1 + c0*exp(c1*mu)*(1+c2*exp(c3*mu)); + double c2 = 1.50247e+00; + double c3 = 3.03278e-01; + double C = -1 + c0 * exp(c1 * mu) * (1 + c2 * exp(c3 * mu)); double b0 = -3.33575e-01; - double b1 = 4.44856e-01; - double b2 = 1.91766e+00; - double b3 = 2.69423e+00; - double b4 = 1.06905e+00; - double B = (1/mu)*(b0 + b1*log10(mu) + b2*pow(log10(mu),2) - + b3*pow(log10(mu),3) + b4*pow(log10(mu),4)); - - double a0 = 7.18248e-02; + double b1 = 4.44856e-01; + double b2 = 1.91766e+00; + double b3 = 2.69423e+00; + double b4 = 1.06905e+00; + double B = + (1 / mu) * (b0 + b1 * log10(mu) + b2 * pow(log10(mu), 2) + b3 * pow(log10(mu), 3) + b4 * pow(log10(mu), 4)); + + double a0 = 7.18248e-02; double a1 = 1.89016e+00; double a2 = 2.15651e-02; double a3 = 2.30786e-02; - double A = exp(B*mu*0.015)*(a0/(exp(a1*(log10(mu)+a2))+1)+a3); + double A = exp(B * mu * 0.015) * (a0 / (exp(a1 * (log10(mu) + a2)) + 1) + a3); + + double R = 0.01 * D * (4 / (0.222 + E) / (0.222 + E) - 1 / ((0.22 - z) * (z + E))); + f = A * exp(-B * mu * (0.22 - z)) * (1 + C * exp(R)); - double R = 0.01*D*( 4/(0.222+E)/(0.222+E) - 1/((0.22-z)*(z+E)) ); - f = A * exp(-B*mu*(0.22-z)) * (1+C*exp(R)); - return f; } - //_____________________________________________________ // // This function is for CMSSW FullSim "slope_LY" @@ -122,263 +117,260 @@ double EvolutionECAL::LightCollectionEfficiency(double z, double mu) */ +double EvolutionECAL::LightCollectionEfficiencyWeighted(double z, double mu_ind) { + if (z <= 0) + return 0; + if (z >= 1) + return 0; + if (mu_ind < 0) + return 1; -double EvolutionECAL::LightCollectionEfficiencyWeighted(double z, double mu_ind) -{ - if(z<=0) return 0; - if(z>=1) return 0; - if(mu_ind<0) return 1; - - double mu = mu_ind + 0.7; + double mu = mu_ind + 0.7; double lmu = log10(mu); - - double e0 = 6.91563e-02; - double e1 = 1.64406e+00; - double e2 = 6.42509e-01; - double E = e0/(1+exp(e1*(lmu-e2))); - double d0 = 3.85334e-01; + double e0 = 6.91563e-02; + double e1 = 1.64406e+00; + double e2 = 6.42509e-01; + double E = e0 / (1 + exp(e1 * (lmu - e2))); + + double d0 = 3.85334e-01; double d1 = -1.04647e-02; - double D = d0*exp(d1*mu); + double D = d0 * exp(d1 * mu); - double c0 = 3.77629e-01; + double c0 = 3.77629e-01; double c1 = -3.23755e-01; - double c2 = 1.50247e+00; - double c3 = 3.03278e-01; - double C = -1 + c0*exp(c1*mu)*(1+c2*exp(c3*mu)); + double c2 = 1.50247e+00; + double c3 = 3.03278e-01; + double C = -1 + c0 * exp(c1 * mu) * (1 + c2 * exp(c3 * mu)); double b0 = -3.33575e-01; - double b1 = 4.44856e-01; - double b2 = 1.91766e+00; - double b3 = 2.69423e+00; - double b4 = 1.06905e+00; - double B = (1/mu)*(b0 + b1*lmu + b2*pow(lmu,2) - + b3*pow(lmu,3) + b4*pow(lmu,4)); + double b1 = 4.44856e-01; + double b2 = 1.91766e+00; + double b3 = 2.69423e+00; + double b4 = 1.06905e+00; + double B = (1 / mu) * (b0 + b1 * lmu + b2 * pow(lmu, 2) + b3 * pow(lmu, 3) + b4 * pow(lmu, 4)); - double a0 = 7.18248e-02; + double a0 = 7.18248e-02; double a1 = 1.89016e+00; double a2 = 2.15651e-02; double a3 = 2.30786e-02; - double A = exp(B*mu*0.015)*(a0/(exp(a1*(lmu+a2))+1)+a3); + double A = exp(B * mu * 0.015) * (a0 / (exp(a1 * (lmu + a2)) + 1) + a3); - double R = 0.01*D*( 4/(0.222+E)/(0.222+E) - 1/((0.22*0.22)*(1.-z)*(z+E/0.22)) ); + double R = 0.01 * D * (4 / (0.222 + E) / (0.222 + E) - 1 / ((0.22 * 0.22) * (1. - z) * (z + E / 0.22))); // for undamaged crystal, mu0 = 0.7 - double A0 = 0.0631452; + double A0 = 0.0631452; double B0 = -0.52267; double C0 = -0.139646; - double D0 = 0.382522; - double E0 = 0.054473; - double R0 = 0.01*D0*( 4/(0.222+E0)/(0.222+E0) - 1/((0.22*0.22)*(1.-z)*(z+E0/0.22)) ); - - - double f = A/A0 * exp(-(B*mu-B0*0.7)*0.22*(1.-z)) * (1+C*exp(R))/(1+C0*exp(R0)); - - return f; -} + double D0 = 0.382522; + double E0 = 0.054473; + double R0 = 0.01 * D0 * (4 / (0.222 + E0) / (0.222 + E0) - 1 / ((0.22 * 0.22) * (1. - z) * (z + E0 / 0.22))); + double f = A / A0 * exp(-(B * mu - B0 * 0.7) * 0.22 * (1. - z)) * (1 + C * exp(R)) / (1 + C0 * exp(R0)); + return f; +} //_________________________________________________________ -double EvolutionECAL::DamageProfileEta(double eta) -{ +double EvolutionECAL::DamageProfileEta(double eta) { double x = fabs(eta); - if(x<1.497){ - return exp( -4.11065 + 0.258478*x ); - }else{ - return exp( -13.5112 + 7.913860*x - 0.998649*x*x ); + if (x < 1.497) { + return exp(-4.11065 + 0.258478 * x); + } else { + return exp(-13.5112 + 7.913860 * x - 0.998649 * x * x); } } - //_________________________________________________________ -double EvolutionECAL::DamageProfileEtaAPD(double eta) -{ +double EvolutionECAL::DamageProfileEtaAPD(double eta) { double x = fabs(eta); - if(x<1.497){ - double et=x/1.48*34.0; - double etaprof=( 9.54827 + et*0.0379222 + - et*et*(-0.00257047) + - et*et*et*0.00073546 + - et*et*et*et*(-1.49683e-05) - )/9.54827; + if (x < 1.497) { + double et = x / 1.48 * 34.0; + double etaprof = (9.54827 + et * 0.0379222 + et * et * (-0.00257047) + et * et * et * 0.00073546 + + et * et * et * et * (-1.49683e-05)) / + 9.54827; return etaprof; - }else{ + } else { return 1.0; } } - //_________________________________________________________ -double EvolutionECAL::InducedAbsorptionHadronic(double lumi, double eta) -{ - double fluence = DamageProfileEta(eta) * 2.7e+13/500.0 * lumi; - double mu = 2.08E-13 * pow( fluence, 1.0049); +double EvolutionECAL::InducedAbsorptionHadronic(double lumi, double eta) { + double fluence = DamageProfileEta(eta) * 2.7e+13 / 500.0 * lumi; + double mu = 2.08E-13 * pow(fluence, 1.0049); return mu; } - //_________________________________________________________ -double EvolutionECAL::DoseLongitudinalProfile(double z) -{ +double EvolutionECAL::DoseLongitudinalProfile(double z) { double alpha = 4.72877e+00; - double beta = 5.91296e-01; - double amp1 = 6.24495e+02; - double amp2 = 1.84367e-01; - double offset = 2.00705e+01; - if (z>=0.0 && z<=22.0) { - double term1 = (amp1 / TMath::Gamma(alpha)) * pow((beta*z),(alpha-1)) * exp (-beta*z); - double term2 = amp2*(z-11.0)*(z-11.0) + offset; - return (term1 + term2)/150.44; - } else { - return 0; + double beta = 5.91296e-01; + double amp1 = 6.24495e+02; + double amp2 = 1.84367e-01; + double offset = 2.00705e+01; + if (z >= 0.0 && z <= 22.0) { + double term1 = (amp1 / TMath::Gamma(alpha)) * pow((beta * z), (alpha - 1)) * exp(-beta * z); + double term2 = amp2 * (z - 11.0) * (z - 11.0) + offset; + return (term1 + term2) / 150.44; + } else { + return 0; } } - - //_________________________________________________________ -Double_t EvolutionECAL::EquilibriumFractionColorCentersEM(double *x, double *par) -{ +Double_t EvolutionECAL::EquilibriumFractionColorCentersEM(double *x, double *par) { double instantLumi = par[0]; double eta = par[1]; - double rate = DoseLongitudinalProfile(x[0])*5.0*DamageProfileEta(eta)*instantLumi/1e+34; - if(rate<=0.0) rate=0.0; + double rate = DoseLongitudinalProfile(x[0]) * 5.0 * DamageProfileEta(eta) * instantLumi / 1e+34; + if (rate <= 0.0) + rate = 0.0; double alpha = par[2]; - return rate/(alpha + rate); + return rate / (alpha + rate); } - - - //____________________________________________________________ -double EvolutionECAL::InducedAbsorptionEM(double lumi, double eta) -{ - double mu_max = 2.0; - double alpha1 = 3.41488e+00; - - TF1 *ftmp1 = new TF1("ftmp1",this,&EvolutionECAL::EquilibriumFractionColorCentersEM, - 0.0,22.0,3,"EvolutionECAL" , "EquilibriumFractionColorCentersEM"); +double EvolutionECAL::InducedAbsorptionEM(double lumi, double eta) { + double mu_max = 2.0; + double alpha1 = 3.41488e+00; + + TF1 *ftmp1 = new TF1("ftmp1", + this, + &EvolutionECAL::EquilibriumFractionColorCentersEM, + 0.0, + 22.0, + 3, + "EvolutionECAL", + "EquilibriumFractionColorCentersEM"); ftmp1->SetParameters(lumi, eta, alpha1); - double muEM = mu_max*ftmp1->Integral(0.0, 22.0)/22.0; - - delete ftmp1; + double muEM = mu_max * ftmp1->Integral(0.0, 22.0) / 22.0; + + delete ftmp1; return muEM; } - //_____________________________________________________________ -double EvolutionECAL::DegradationMeanEM50GeV(double mu) -{ +double EvolutionECAL::DegradationMeanEM50GeV(double mu) { double retval = 1.0; double x = mu; - if( x<1e-4 ) return retval; - if( x>=200.0 ) x=200.0; // parameterization is not valid for large mu - - double par[11] = { 1.00000e+01, - -4.41441e-01, 7.08607e-02, -3.75572e-01, -3.60410e-01, 1.30130e-01, - -4.72350e-01, 3.36315e-01, -1.19872e-01, 1.99574e-02,-1.22910e-03 }; - + if (x < 1e-4) + return retval; + if (x >= 200.0) + x = 200.0; // parameterization is not valid for large mu + + double par[11] = {1.00000e+01, + -4.41441e-01, + 7.08607e-02, + -3.75572e-01, + -3.60410e-01, + 1.30130e-01, + -4.72350e-01, + 3.36315e-01, + -1.19872e-01, + 1.99574e-02, + -1.22910e-03}; double alpha = par[0]; - double f1 = par[1]*x + par[2]*x*x; + double f1 = par[1] * x + par[2] * x * x; double u = log(x); double f2 = par[10]; - for(int i=9; i>=3; i--) f2 = par[i] + f2*u; + for (int i = 9; i >= 3; i--) + f2 = par[i] + f2 * u; - retval = f1/(1.0+exp(alpha*u)) + f2/(1.0+exp(-alpha*u)); + retval = f1 / (1.0 + exp(alpha * u)) + f2 / (1.0 + exp(-alpha * u)); retval = exp(retval); return retval; - - } - - - //_____________________________________________________________ -double EvolutionECAL::DegradationNonLinearityEM50GeV(double mu, double ene) -{ - if(ene<=1e-3) return 0.0; +double EvolutionECAL::DegradationNonLinearityEM50GeV(double mu, double ene) { + if (ene <= 1e-3) + return 0.0; double x = mu; - if( mu<=0.06 ) x=0.06; - if( mu>=150.0 ) x=150.0; - - double par[9] = { 5.17712e-03, 1.97597e-02, 3.36596e-02, 2.84505e-02, 1.38480e-02, - 1.11498e-02, 7.73634e-03, -1.30767e-03, -2.20628e-03 }; + if (mu <= 0.06) + x = 0.06; + if (mu >= 150.0) + x = 150.0; + + double par[9] = {5.17712e-03, + 1.97597e-02, + 3.36596e-02, + 2.84505e-02, + 1.38480e-02, + 1.11498e-02, + 7.73634e-03, + -1.30767e-03, + -2.20628e-03}; double u = log10(x); double slope = par[8]; - for(int i=7; i>=0; i--) slope = par[i] + slope*u; + for (int i = 7; i >= 0; i--) + slope = par[i] + slope * u; - double retval = 1.0 + slope*log10(ene/50.0); - if(retval<=0.0) retval = 0.0; + double retval = 1.0 + slope * log10(ene / 50.0); + if (retval <= 0.0) + retval = 0.0; return retval; - } - //_____________________________________________________________ -double EvolutionECAL::ResolutionConstantTermEM50GeV(double mu) -{ - +double EvolutionECAL::ResolutionConstantTermEM50GeV(double mu) { double x = mu; - if( mu<=0.01 ) x=0.01; - if( mu>=200.0 ) x=200.0; - - double par[10] = { -6.21503e+00, 1.59759e+00, -4.75221e-02, -3.90299e-02, 3.97269e-03, - 2.29574e-03, -1.05280e-04, -9.60963e-05, -1.29594e-06, 1.70850e-06 }; + if (mu <= 0.01) + x = 0.01; + if (mu >= 200.0) + x = 200.0; + + double par[10] = {-6.21503e+00, + 1.59759e+00, + -4.75221e-02, + -3.90299e-02, + 3.97269e-03, + 2.29574e-03, + -1.05280e-04, + -9.60963e-05, + -1.29594e-06, + 1.70850e-06}; double u = log(x); double f = par[9]; - for(int i=8; i>=0; i--) f = par[i] + f*u; + for (int i = 8; i >= 0; i--) + f = par[i] + f * u; return exp(f); - } - //__________________________________________________________ -double EvolutionECAL::ChargeVPTCathode(double instLumi, double eta, double integralLumi) -{ +double EvolutionECAL::ChargeVPTCathode(double instLumi, double eta, double integralLumi) { double charge = 0.0; double tmpLumi = 0.0; double stepLumi = 1.0; double muEM = InducedAbsorptionEM(instLumi, eta); - while(tmpLumi #endif -HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager) : - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("HCalSD").getParameter("TimeSliceUnit")), - p.getParameter("HCalSD").getParameter("IgnoreTrackID")), - hcalConstants(nullptr), m_HBDarkening(nullptr), m_HEDarkening(nullptr), isHF(false), - weight_(1.0), depth_(1) { - - numberingFromDDD.reset(nullptr); - numberingScheme.reset(nullptr); - showerLibrary.reset(nullptr); - hfshower.reset(nullptr); +HCalSD::HCalSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("HCalSD").getParameter("TimeSliceUnit")), + p.getParameter("HCalSD").getParameter("IgnoreTrackID")), + hcalConstants(nullptr), + m_HBDarkening(nullptr), + m_HEDarkening(nullptr), + isHF(false), + weight_(1.0), + depth_(1) { + numberingFromDDD.reset(nullptr); + numberingScheme.reset(nullptr); + showerLibrary.reset(nullptr); + hfshower.reset(nullptr); showerParam.reset(nullptr); - showerPMT.reset(nullptr); + showerPMT.reset(nullptr); showerBundle.reset(nullptr); m_HFDarkening.reset(nullptr); m_HcalTestNS.reset(nullptr); @@ -70,68 +79,61 @@ HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, // Values from NIM 80 (1970) 239-244: as implemented in Geant3 edm::ParameterSet m_HC = p.getParameter("HCalSD"); - useBirk = m_HC.getParameter("UseBirkLaw"); - birk1 = m_HC.getParameter("BirkC1")*(g/(MeV*cm2)); - birk2 = m_HC.getParameter("BirkC2"); - birk3 = m_HC.getParameter("BirkC3"); + useBirk = m_HC.getParameter("UseBirkLaw"); + birk1 = m_HC.getParameter("BirkC1") * (g / (MeV * cm2)); + birk2 = m_HC.getParameter("BirkC2"); + birk3 = m_HC.getParameter("BirkC3"); useShowerLibrary = m_HC.getParameter("UseShowerLibrary"); - useParam = m_HC.getParameter("UseParametrize"); - testNumber = m_HC.getParameter("TestNumberingScheme"); - neutralDensity = m_HC.getParameter("doNeutralDensityFilter"); - usePMTHit = m_HC.getParameter("UsePMTHits"); - betaThr = m_HC.getParameter("BetaThreshold"); - eminHitHB = m_HC.getParameter("EminHitHB")*MeV; - eminHitHE = m_HC.getParameter("EminHitHE")*MeV; - eminHitHO = m_HC.getParameter("EminHitHO")*MeV; - eminHitHF = m_HC.getParameter("EminHitHF")*MeV; - useFibreBundle = m_HC.getParameter("UseFibreBundleHits"); - deliveredLumi = m_HC.getParameter("DelivLuminosity"); - agingFlagHB = m_HC.getParameter("HBDarkening"); - agingFlagHE = m_HC.getParameter("HEDarkening"); + useParam = m_HC.getParameter("UseParametrize"); + testNumber = m_HC.getParameter("TestNumberingScheme"); + neutralDensity = m_HC.getParameter("doNeutralDensityFilter"); + usePMTHit = m_HC.getParameter("UsePMTHits"); + betaThr = m_HC.getParameter("BetaThreshold"); + eminHitHB = m_HC.getParameter("EminHitHB") * MeV; + eminHitHE = m_HC.getParameter("EminHitHE") * MeV; + eminHitHO = m_HC.getParameter("EminHitHO") * MeV; + eminHitHF = m_HC.getParameter("EminHitHF") * MeV; + useFibreBundle = m_HC.getParameter("UseFibreBundleHits"); + deliveredLumi = m_HC.getParameter("DelivLuminosity"); + agingFlagHB = m_HC.getParameter("HBDarkening"); + agingFlagHE = m_HC.getParameter("HEDarkening"); bool agingFlagHF = m_HC.getParameter("HFDarkening"); - useHF = m_HC.getUntrackedParameter("UseHF",true); - bool forTBH2 = m_HC.getUntrackedParameter("ForTBH2",false); - useLayerWt = m_HC.getUntrackedParameter("UseLayerWt",false); - std::string file = m_HC.getUntrackedParameter("WtFile","None"); - testNS_ = m_HC.getUntrackedParameter("TestNS",false); - edm::ParameterSet m_HF = p.getParameter("HFShower"); - applyFidCut = m_HF.getParameter("ApplyFiducialCut"); + useHF = m_HC.getUntrackedParameter("UseHF", true); + bool forTBH2 = m_HC.getUntrackedParameter("ForTBH2", false); + useLayerWt = m_HC.getUntrackedParameter("UseLayerWt", false); + std::string file = m_HC.getUntrackedParameter("WtFile", "None"); + testNS_ = m_HC.getUntrackedParameter("TestNS", false); + edm::ParameterSet m_HF = p.getParameter("HFShower"); + applyFidCut = m_HF.getParameter("ApplyFiducialCut"); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "***************************************************" - << "\n" - << "* Constructing a HCalSD with name " << name << "\n" - << "\n" - << "***************************************************"; + edm::LogVerbatim("HcalSim") << "***************************************************" + << "\n" + << "* Constructing a HCalSD with name " << name << "\n" + << "\n" + << "***************************************************"; #endif edm::LogVerbatim("HcalSim") << "HCalSD:: Use of HF code is set to " << useHF - << "\nUse of shower parametrization set to " - << useParam << "\nUse of shower library is set to " - << useShowerLibrary << "\nUse PMT Hit is set to " - << usePMTHit << " with beta Threshold "<< betaThr - << "\nUSe of FibreBundle Hit set to "<(new HcalTestNumberingScheme(forTBH2)); - } else { + } else { scheme = new HcalNumberingScheme(); } setNumberingScheme(scheme); @@ -139,7 +141,7 @@ HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, // always call getFromLibrary() method to identify HF region setParameterized(true); - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); // std::vector::const_iterator lvcite; const G4LogicalVolume* lv; std::string attribute, value; @@ -147,30 +149,31 @@ HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, if (useHF) { if (useParam) { showerParam.reset(new HFShowerParam(name, cpv, p)); - } else { - if (useShowerLibrary) { showerLibrary.reset(new HFShowerLibrary(name, cpv, p)); } + } else { + if (useShowerLibrary) { + showerLibrary.reset(new HFShowerLibrary(name, cpv, p)); + } hfshower.reset(new HFShower(name, cpv, p, 0)); } // HF volume names attribute = "Volume"; - value = "HF"; - DDSpecificsMatchesValueFilter filter0{DDValue(attribute,value,0)}; - DDFilteredView fv0(cpv,filter0); + value = "HF"; + DDSpecificsMatchesValueFilter filter0{DDValue(attribute, value, 0)}; + DDFilteredView fv0(cpv, filter0); hfNames = getNames(fv0); fv0.firstChild(); DDsvalues_type sv0(fv0.mergedSpecifics()); - std::vector temp = getDDDArray("Levels",sv0); + std::vector temp = getDDDArray("Levels", sv0); unsigned int nhf = hfNames.size(); std::stringstream ss; - ss << "HCalSD: Names to be tested for " << attribute - << " = " << value << " has " << nhf << " elements"; - for (unsigned int i=0; i < nhf; ++i) { + ss << "HCalSD: Names to be tested for " << attribute << " = " << value << " has " << nhf << " elements"; + for (unsigned int i = 0; i < nhf; ++i) { G4String namv = hfNames[i]; - lv = nullptr; - for(auto lvol : *lvs) { - if(lvol->GetName() == namv) { + lv = nullptr; + for (auto lvol : *lvs) { + if (lvol->GetName() == namv) { lv = lvol; break; } @@ -178,11 +181,10 @@ HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, hfLV.push_back(lv); int level = static_cast(temp[i]); hfLevels.push_back(level); - ss << "\n HF[" << i << "] = " << namv - << " LV " << hfLV[i] << " at level " << hfLevels[i]; + ss << "\n HF[" << i << "] = " << namv << " LV " << hfLV[i] << " at level " << hfLevels[i]; } edm::LogVerbatim("HcalSim") << ss.str(); - + // HF Fibre volume names fillLogVolumeVector(attribute, "HFFibre", cpv, fibreLV, fibreNames); std::vector tempNames; @@ -192,21 +194,21 @@ HCalSD::HCalSD(const std::string& name, const DDCompactView & cpv, } //Material list for HB/HE/HO sensitive detectors - const G4MaterialTable * matTab = G4Material::GetMaterialTable(); + const G4MaterialTable* matTab = G4Material::GetMaterialTable(); std::vector::const_iterator matite; - attribute = "OnlyForHcalSimNumbering"; + attribute = "OnlyForHcalSimNumbering"; DDSpecificsHasNamedValueFilter filter2{attribute}; - DDFilteredView fv2(cpv,filter2); + DDFilteredView fv2(cpv, filter2); bool dodet = fv2.firstChild(); DDsvalues_type sv(fv2.mergedSpecifics()); while (dodet) { - const DDLogicalPart & log = fv2.logicalPart(); + const DDLogicalPart& log = fv2.logicalPart(); G4String namx = log.name().name(); if (!isItHF(namx) && !isItFibre(namx)) { bool notIn = true; - for (unsigned int i=0; i tfile; - if ( tfile.isAvailable() ) { - static const char * const labels[] = {"HB", "HE", "HO", "HF Absorber", "HF PMT", - "HF Absorber Long", "HF Absorber Short", - "HF PMT Long", "HF PMT Short"}; + if (tfile.isAvailable()) { + static const char* const labels[] = {"HB", + "HE", + "HO", + "HF Absorber", + "HF PMT", + "HF Absorber Long", + "HF Absorber Short", + "HF PMT Long", + "HF PMT Short"}; TFileDirectory hcDir = tfile->mkdir("ProfileFromHCalSD"); char name[20], title[60]; - for (int i=0; i<9; ++i) { - sprintf (title, "Hit energy in %s", labels[i]); - sprintf (name, "HCalSDHit%d", i); + for (int i = 0; i < 9; ++i) { + sprintf(title, "Hit energy in %s", labels[i]); + sprintf(name, "HCalSDHit%d", i); hit_[i] = hcDir.make(name, title, 2000, 0., 2000.); - sprintf (title, "Energy (MeV)"); + sprintf(title, "Energy (MeV)"); hit_[i]->GetXaxis()->SetTitle(title); hit_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (title, "Time of the hit in %s", labels[i]); - sprintf (name, "HCalSDTime%d", i); + sprintf(title, "Time of the hit in %s", labels[i]); + sprintf(name, "HCalSDTime%d", i); time_[i] = hcDir.make(name, title, 2000, 0., 2000.); - sprintf (title, "Time (ns)"); + sprintf(title, "Time (ns)"); time_[i]->GetXaxis()->SetTitle(title); time_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (title, "Longitudinal profile in %s", labels[i]); - sprintf (name, "HCalSDDist%d", i); + sprintf(title, "Longitudinal profile in %s", labels[i]); + sprintf(name, "HCalSDDist%d", i); dist_[i] = hcDir.make(name, title, 2000, 0., 2000.); - sprintf (title, "Distance (mm)"); + sprintf(title, "Distance (mm)"); dist_[i]->GetXaxis()->SetTitle(title); dist_[i]->GetYaxis()->SetTitle("Hits"); } if (useHF && (!useParam)) { - hzvem = hcDir.make("hzvem", "Longitudinal Profile (EM Part)",330,0.0,1650.0); + hzvem = hcDir.make("hzvem", "Longitudinal Profile (EM Part)", 330, 0.0, 1650.0); hzvem->GetXaxis()->SetTitle("Longitudinal Profile (EM Part)"); - hzvhad = hcDir.make("hzvhad","Longitudinal Profile (Had Part)",330,0.0,1650.0); + hzvhad = hcDir.make("hzvhad", "Longitudinal Profile (Had Part)", 330, 0.0, 1650.0); hzvhad->GetXaxis()->SetTitle("Longitudinal Profile (Hadronic Part)"); } } #endif } -void HCalSD::fillLogVolumeVector(const std::string& attribute, const std::string& value, +void HCalSD::fillLogVolumeVector(const std::string& attribute, + const std::string& value, const DDCompactView& cpv, std::vector& lvvec, std::vector& lvnames) { - - const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance(); + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); const G4LogicalVolume* lv; - DDSpecificsMatchesValueFilter filter{DDValue(attribute,value,0)}; - DDFilteredView fv(cpv,filter); + DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0)}; + DDFilteredView fv(cpv, filter); lvnames = getNames(fv); unsigned int nvol = lvnames.size(); std::stringstream ss; ss << "HCalSD: " << nvol << " names to be tested for " << attribute << " <" << value << ">:"; - for (unsigned int i=0; iGetTrack(); - depth_ = (aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(0))%10; - weight_= 1.0; + depth_ = (aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(0)) % 10; + weight_ = 1.0; bool kill(false); isHF = isItHF(aStep); - if(isHF) { + if (isHF) { if (m_HFDarkening) { G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition(); - const double invcm = 1./CLHEP::cm; - double r = hitPoint.perp()*invcm; - double z = std::abs(hitPoint.z())*invcm; + const double invcm = 1. / CLHEP::cm; + double r = hitPoint.perp() * invcm; + double z = std::abs(hitPoint.z()) * invcm; double dose_acquired = 0.; - if (z>=HFDarkening::lowZLimit && z <= HFDarkening::upperZLimit) { - unsigned int hfZLayer = (unsigned int)((z - HFDarkening::lowZLimit)/5); - if (hfZLayer >= HFDarkening::upperZLimit) hfZLayer = (HFDarkening::upperZLimit-1); + if (z >= HFDarkening::lowZLimit && z <= HFDarkening::upperZLimit) { + unsigned int hfZLayer = (unsigned int)((z - HFDarkening::lowZLimit) / 5); + if (hfZLayer >= HFDarkening::upperZLimit) + hfZLayer = (HFDarkening::upperZLimit - 1); float normalized_lumi = m_HFDarkening->int_lumi(deliveredLumi); for (int i = hfZLayer; i != HFDarkening::numberOfZLayers; ++i) { - dose_acquired = m_HFDarkening->dose(i,r); - weight_ *= m_HFDarkening->degradation(normalized_lumi*dose_acquired); + dose_acquired = m_HFDarkening->dose(i, r); + weight_ *= m_HFDarkening->degradation(normalized_lumi * dose_acquired); } } #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary: HFLumiDarkening at " - << "r= " << r << ", z= " << z << " Dose= " - << dose_acquired << " weight= " << weight_; + << "r= " << r << ", z= " << z << " Dose= " << dose_acquired << " weight= " << weight_; #endif } @@ -347,53 +361,41 @@ bool HCalSD::getFromLibrary(const G4Step * aStep) { getFromParam(aStep, kill); #ifdef EDM_ML_DEBUG G4String nameVolume = lv->GetName(); - edm::LogVerbatim("HcalSim") << "HCalSD: " << getNumberOfHits() - << " hits from parametrization in " - << nameVolume << " for Track " - << track->GetTrackID() <<" (" - << track->GetDefinition()->GetParticleName() - <<")"; + edm::LogVerbatim("HcalSim") << "HCalSD: " << getNumberOfHits() << " hits from parametrization in " << nameVolume + << " for Track " << track->GetTrackID() << " (" + << track->GetDefinition()->GetParticleName() << ")"; #endif } else if (useShowerLibrary && !G4TrackToParticleID::isMuon(track)) { - if(G4TrackToParticleID::isGammaElectronPositron(track) || - G4TrackToParticleID::isStableHadronIon(track) ) { + if (G4TrackToParticleID::isGammaElectronPositron(track) || G4TrackToParticleID::isStableHadronIon(track)) { #ifdef EDM_ML_DEBUG - auto nameVolume = - aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); - edm::LogVerbatim("HcalSim") << "HCalSD: Starts shower library from " - << nameVolume << " for Track " - << track->GetTrackID() << " (" - << track->GetDefinition()->GetParticleName() - << ")"; + auto nameVolume = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); + edm::LogVerbatim("HcalSim") << "HCalSD: Starts shower library from " << nameVolume << " for Track " + << track->GetTrackID() << " (" << track->GetDefinition()->GetParticleName() << ")"; #endif - getFromHFLibrary(aStep, kill); + getFromHFLibrary(aStep, kill); } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary ID= " - << track->GetTrackID() << " (" - << track->GetDefinition()->GetParticleName() - << ") kill= " << kill << " weight= " << weight_ - << " depth= " << depth_ << " isHF: " << isHF; + edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary ID= " << track->GetTrackID() << " (" + << track->GetDefinition()->GetParticleName() << ") kill= " << kill + << " weight= " << weight_ << " depth= " << depth_ << " isHF: " << isHF; #endif return kill; -} +} double HCalSD::getEnergyDeposit(const G4Step* aStep) { double destep(0.0); auto const lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); auto const theTrack = aStep->GetTrack(); - if(isHF) { + if (isHF) { if (useShowerLibrary && G4TrackToParticleID::isMuon(theTrack) && isItFibre(lv)) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: Hit at Fibre in LV " << lv->GetName() - << " for track " - << aStep->GetTrack()->GetTrackID() <<" (" - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << ")"; + edm::LogVerbatim("HcalSim") << "HCalSD: Hit at Fibre in LV " << lv->GetName() << " for track " + << aStep->GetTrack()->GetTrackID() << " (" + << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")"; #endif hitForFibre(aStep); } @@ -401,35 +403,35 @@ double HCalSD::getEnergyDeposit(const G4Step* aStep) { } if (isItPMT(lv)) { - if(usePMTHit && showerPMT) { getHitPMT(aStep); } + if (usePMTHit && showerPMT) { + getHitPMT(aStep); + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: Hit from PMT parametrization in LV " - << lv->GetName() << " for Track " - << aStep->GetTrack()->GetTrackID() << " (" - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << ")"; + edm::LogVerbatim("HcalSim") << "HCalSD: Hit from PMT parametrization in LV " << lv->GetName() << " for Track " + << aStep->GetTrack()->GetTrackID() << " (" + << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")"; #endif return destep; } else if (isItStraightBundle(lv)) { - if(useFibreBundle && showerBundle) { getHitFibreBundle(aStep, false); } + if (useFibreBundle && showerBundle) { + getHitFibreBundle(aStep, false); + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: Hit from straight FibreBundle in LV: " - << lv->GetName() << " for track " - << aStep->GetTrack()->GetTrackID() << " (" - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << ")"; + edm::LogVerbatim("HcalSim") << "HCalSD: Hit from straight FibreBundle in LV: " << lv->GetName() << " for track " + << aStep->GetTrack()->GetTrackID() << " (" + << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")"; #endif return destep; - } else if(isItConicalBundle(lv)) { - if(useFibreBundle && showerBundle) { getHitFibreBundle(aStep, true); } + } else if (isItConicalBundle(lv)) { + if (useFibreBundle && showerBundle) { + getHitFibreBundle(aStep, true); + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: Hit from conical FibreBundle PV: " - << lv->GetName() << " for track " - << aStep->GetTrack()->GetTrackID() << " (" - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << ")"; + edm::LogVerbatim("HcalSim") << "HCalSD: Hit from conical FibreBundle PV: " << lv->GetName() << " for track " + << aStep->GetTrack()->GetTrackID() << " (" + << aStep->GetTrack()->GetDefinition()->GetParticleName() << ")"; #endif return destep; } @@ -441,108 +443,109 @@ double HCalSD::getEnergyDeposit(const G4Step* aStep) { uint32_t detid = setDetUnitId(aStep); int det(0), ieta(0), phi(0), z(0), lay, depth(-1); if (testNumber) { - HcalTestNumbering::unpackHcalIndex(detid,det,z,depth,ieta,phi,lay); - if (z==0) { z = -1; } + HcalTestNumbering::unpackHcalIndex(detid, det, z, depth, ieta, phi, lay); + if (z == 0) { + z = -1; + } } else { HcalDetId hcid(detid); - det = hcid.subdetId(); + det = hcid.subdetId(); ieta = hcid.ietaAbs(); - phi = hcid.iphi(); - z = hcid.zside(); + phi = hcid.iphi(); + z = hcid.zside(); } - lay = (touch->GetReplicaNumber(0)/10)%100 + 1; + lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: det: " << det << " ieta: "<< ieta - << " iphi: " << phi << " zside " << z << " lay: " - << lay-2; -#endif - if (depth_==0 && (det==1 || det==2) && ((!testNumber) || neutralDensity)) - weight_ = hcalConstants->getLayer0Wt(det,phi,z); + edm::LogVerbatim("HcalSim") << "HCalSD: det: " << det << " ieta: " << ieta << " iphi: " << phi << " zside " << z + << " lay: " << lay - 2; +#endif + if (depth_ == 0 && (det == 1 || det == 2) && ((!testNumber) || neutralDensity)) + weight_ = hcalConstants->getLayer0Wt(det, phi, z); if (useLayerWt) { G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition(); - weight_ = layerWeight(det+2, hitPoint, depth_, lay); + weight_ = layerWeight(det + 2, hitPoint, depth_, lay); } if (m_HBDarkening && det == 1) { - double dweight = m_HBDarkening->degradation(deliveredLumi,ieta,lay); + double dweight = m_HBDarkening->degradation(deliveredLumi, ieta, lay); weight_ *= dweight; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi - << " coefficient = " << dweight << " Weight= " - << weight_; -#endif + edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi << " coefficient = " << dweight + << " Weight= " << weight_; +#endif } if (m_HEDarkening && det == 2) { - double dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay); + double dweight = m_HEDarkening->degradation(deliveredLumi, ieta, lay); weight_ *= dweight; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi - << " coefficient = " << dweight << " Weight= " - << weight_; -#endif + edm::LogVerbatim("HcalSim") << "HCalSD: HB Lumi: " << deliveredLumi << " coefficient = " << dweight + << " Weight= " << weight_; +#endif } if (suppressHeavy) { - TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation()); + TrackInformation* trkInfo = (TrackInformation*)(theTrack->GetUserInformation()); if (trkInfo) { int pdg = theTrack->GetDefinition()->GetPDGEncoding(); - if (!(trkInfo->isPrimary())) { // Only secondary particles + if (!(trkInfo->isPrimary())) { // Only secondary particles double ke = theTrack->GetKineticEnergy(); - if ( pdg/1000000000 == 1 && (pdg/10000)%100 > 0 && - (pdg/10)%100 > 0 && ke 0 && (pdg / 10) % 100 > 0 && ke < kmaxIon) + weight_ = 0; + if ((pdg == 2212) && (ke < kmaxProton)) + weight_ = 0; + if ((pdg == 2112) && (ke < kmaxNeutron)) + weight_ = 0; } } } if (useBirk) { const G4Material* mat = aStep->GetPreStepPoint()->GetMaterial(); - if (isItScintillator(mat)) weight_ *= getAttenuation(aStep, birk1, birk2, birk3); + if (isItScintillator(mat)) + weight_ *= getAttenuation(aStep, birk1, birk2, birk3); } double wt1 = getResponseWt(theTrack); double wt2 = theTrack->GetWeight(); - double edep = weight_*wt1*destep; - if (wt2 > 0.0) { edep *= wt2; } + double edep = weight_ * wt1 * destep; + if (wt2 > 0.0) { + edep *= wt2; + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") - << "HCalSD: edep= " << edep << " Det: " << det+2 << " depth= " << depth_ - << " weight= " << weight_ << " wt1= " << wt1 << " wt2= " << wt2; + edm::LogVerbatim("HcalSim") << "HCalSD: edep= " << edep << " Det: " << det + 2 << " depth= " << depth_ + << " weight= " << weight_ << " wt1= " << wt1 << " wt2= " << wt2; #endif return edep; } -uint32_t HCalSD::setDetUnitId(const G4Step * aStep) { - - auto const prePoint = aStep->GetPreStepPoint(); - auto const touch = prePoint->GetTouchable(); +uint32_t HCalSD::setDetUnitId(const G4Step* aStep) { + auto const prePoint = aStep->GetPreStepPoint(); + auto const touch = prePoint->GetTouchable(); const G4ThreeVector& hitPoint = prePoint->GetPosition(); - int depth = (touch->GetReplicaNumber(0))%10 + 1; - int lay = (touch->GetReplicaNumber(0)/10)%100 + 1; - int det = (touch->GetReplicaNumber(1))/1000; + int depth = (touch->GetReplicaNumber(0)) % 10 + 1; + int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1; + int det = (touch->GetReplicaNumber(1)) / 1000; - return setDetUnitId (det, hitPoint, depth, lay); + return setDetUnitId(det, hitPoint, depth, lay); } -void HCalSD::setNumberingScheme(HcalNumberingScheme * scheme) { +void HCalSD::setNumberingScheme(HcalNumberingScheme* scheme) { if (scheme != nullptr) { - edm::LogVerbatim("HcalSim") << "HCalSD: updates numbering scheme for " - << GetName(); + edm::LogVerbatim("HcalSim") << "HCalSD: updates numbering scheme for " << GetName(); numberingScheme.reset(scheme); } } -void HCalSD::update(const BeginOfJob * job) { - +void HCalSD::update(const BeginOfJob* job) { const edm::EventSetup* es = (*job)(); - edm::ESHandle hdc; + edm::ESHandle hdc; es->get().get(hdc); if (hdc.isValid()) { hcalConstants = hdc.product(); } else { edm::LogError("HcalSim") << "HCalSD : Cannot find HcalDDDSimConstant"; - throw cms::Exception("Unknown", "HCalSD") << "Cannot find HcalDDDSimConstant" << "\n"; + throw cms::Exception("Unknown", "HCalSD") << "Cannot find HcalDDDSimConstant" + << "\n"; } numberingFromDDD.reset(new HcalNumberingFromDDD(hcalConstants)); @@ -550,99 +553,102 @@ void HCalSD::update(const BeginOfJob * job) { //Special Geometry parameters gpar = hcalConstants->getGparHF(); std::stringstream sss; - for (unsigned int ig=0; iggetMaxDepth(2) - << gpar.size()<< " gpar (cm)" << sss.str(); + edm::LogVerbatim("HcalSim") << "Maximum depth for HF " << hcalConstants->getMaxDepth(2) << gpar.size() << " gpar (cm)" + << sss.str(); //Test Hcal Numbering Scheme - if (testNS_) m_HcalTestNS.reset(new HcalTestNS(es)); + if (testNS_) + m_HcalTestNS.reset(new HcalTestNS(es)); if (agingFlagHB) { edm::ESHandle hdark; - es->get().get("HB",hdark); + es->get().get("HB", hdark); m_HBDarkening = &*hdark; } if (agingFlagHE) { edm::ESHandle hdark; - es->get().get("HE",hdark); + es->get().get("HE", hdark); m_HEDarkening = &*hdark; } } void HCalSD::initRun() { - if (showerLibrary.get()) showerLibrary.get()->initRun(nullptr, hcalConstants); - if (showerParam.get()) showerParam.get()->initRun(hcalConstants); - if (hfshower.get()) hfshower.get()->initRun(hcalConstants); - if (showerPMT.get()) showerPMT.get()->initRun(hcalConstants); - if (showerBundle.get()) showerBundle.get()->initRun(hcalConstants); + if (showerLibrary.get()) + showerLibrary.get()->initRun(nullptr, hcalConstants); + if (showerParam.get()) + showerParam.get()->initRun(hcalConstants); + if (hfshower.get()) + hfshower.get()->initRun(hcalConstants); + if (showerPMT.get()) + showerPMT.get()->initRun(hcalConstants); + if (showerBundle.get()) + showerBundle.get()->initRun(hcalConstants); } bool HCalSD::filterHit(CaloG4Hit* aHit, double time) { - double threshold=0; + double threshold = 0; DetId theId(aHit->getUnitID()); switch (theId.subdetId()) { - case HcalBarrel: - threshold = eminHitHB; break; - case HcalEndcap: - threshold = eminHitHE; break; - case HcalOuter: - threshold = eminHitHO; break; - case HcalForward: - threshold = eminHitHF; break; - default: - break; + case HcalBarrel: + threshold = eminHitHB; + break; + case HcalEndcap: + threshold = eminHitHE; + break; + case HcalOuter: + threshold = eminHitHO; + break; + case HcalForward: + threshold = eminHitHF; + break; + default: + break; } return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > threshold)); } -uint32_t HCalSD::setDetUnitId (int det, const G4ThreeVector& pos, int depth, int lay=1) { +uint32_t HCalSD::setDetUnitId(int det, const G4ThreeVector& pos, int depth, int lay = 1) { uint32_t id = 0; if (numberingFromDDD.get()) { //get the ID's as eta, phi, depth, ... indices - HcalNumberingFromDDD::HcalID tmp = - numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(),pos.y(), - pos.z()),depth,lay); + HcalNumberingFromDDD::HcalID tmp = + numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(), pos.y(), pos.z()), depth, lay); id = setDetUnitId(tmp); } return id; } -uint32_t HCalSD::setDetUnitId (HcalNumberingFromDDD::HcalID& tmp) { +uint32_t HCalSD::setDetUnitId(HcalNumberingFromDDD::HcalID& tmp) { modifyDepth(tmp); uint32_t id = (numberingScheme.get()) ? numberingScheme.get()->getUnitID(tmp) : 0; if ((!testNumber) && m_HcalTestNS.get()) { - bool ok = m_HcalTestNS.get()->compare(tmp,id); + bool ok = m_HcalTestNS.get()->compare(tmp, id); if (!ok) - edm::LogWarning("HcalSim") << "Det ID from HCalSD " << HcalDetId(id) - << " " << std::hex << id << std::dec - << " does not match one from relabller for " - << tmp.subdet << ":" << tmp.etaR << ":" - << tmp.phi << ":" << tmp.phis << ":" - << tmp.depth << ":" << tmp.lay << std::endl; + edm::LogWarning("HcalSim") << "Det ID from HCalSD " << HcalDetId(id) << " " << std::hex << id << std::dec + << " does not match one from relabller for " << tmp.subdet << ":" << tmp.etaR << ":" + << tmp.phi << ":" << tmp.phis << ":" << tmp.depth << ":" << tmp.lay << std::endl; } return id; } -std::vector HCalSD::getDDDArray(const std::string & str, - const DDsvalues_type & sv) { +std::vector HCalSD::getDDDArray(const std::string& str, const DDsvalues_type& sv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalSim") << "HCalSD:getDDDArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { + if (DDfetch(&sv, value)) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalSim") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 1) { - edm::LogError("HcalSim") << "HCalSD : # of " << str << " bins " << nval - << " < 2 ==> illegal"; + edm::LogError("HcalSim") << "HCalSD : # of " << str << " bins " << nval << " < 2 ==> illegal"; throw cms::Exception("Unknown", "HCalSD") << "nval < 2 for array " << str << "\n"; } - + return fvec; } else { edm::LogError("HcalSim") << "HCalSD : cannot get array " << str; @@ -651,197 +657,217 @@ std::vector HCalSD::getDDDArray(const std::string & str, } std::vector HCalSD::getNames(DDFilteredView& fv) { - std::vector tmp; bool dodet = fv.firstChild(); while (dodet) { - const DDLogicalPart & log = fv.logicalPart(); + const DDLogicalPart& log = fv.logicalPart(); bool ok = true; - for (unsigned int i=0; iGetPreStepPoint()->GetTouchable(); int levels = (touch->GetHistoryDepth()) + 1; - for (unsigned int it=0; it < hfNames.size(); ++it) { + for (unsigned int it = 0; it < hfNames.size(); ++it) { if (levels >= hfLevels[it]) { - const G4LogicalVolume* lv = touch->GetVolume(levels-hfLevels[it])->GetLogicalVolume(); - if (lv == hfLV[it]) return true; + const G4LogicalVolume* lv = touch->GetVolume(levels - hfLevels[it])->GetLogicalVolume(); + if (lv == hfLV[it]) + return true; } } return false; } -bool HCalSD::isItHF (const G4String& name) { - for (auto nam : hfNames) if (name == nam) { return true; } +bool HCalSD::isItHF(const G4String& name) { + for (auto nam : hfNames) + if (name == nam) { + return true; + } return false; } -bool HCalSD::isItFibre (const G4LogicalVolume* lv) { - for (auto lvol : fibreLV) if (lv == lvol) { return true; } +bool HCalSD::isItFibre(const G4LogicalVolume* lv) { + for (auto lvol : fibreLV) + if (lv == lvol) { + return true; + } return false; } -bool HCalSD::isItFibre (const G4String& name) { - for (auto nam : fibreNames) if (name == nam) { return true; } +bool HCalSD::isItFibre(const G4String& name) { + for (auto nam : fibreNames) + if (name == nam) { + return true; + } return false; } -bool HCalSD::isItPMT (const G4LogicalVolume* lv) { - for (auto lvol : pmtLV) if (lv == lvol) { return true; } +bool HCalSD::isItPMT(const G4LogicalVolume* lv) { + for (auto lvol : pmtLV) + if (lv == lvol) { + return true; + } return false; } -bool HCalSD::isItStraightBundle (const G4LogicalVolume* lv) { - for (auto lvol : fibre1LV) if (lv == lvol) { return true; } +bool HCalSD::isItStraightBundle(const G4LogicalVolume* lv) { + for (auto lvol : fibre1LV) + if (lv == lvol) { + return true; + } return false; } -bool HCalSD::isItConicalBundle (const G4LogicalVolume* lv) { - for (auto lvol : fibre2LV) if (lv == lvol) { return true; } +bool HCalSD::isItConicalBundle(const G4LogicalVolume* lv) { + for (auto lvol : fibre2LV) + if (lv == lvol) { + return true; + } return false; } -bool HCalSD::isItScintillator (const G4Material* mat) { - for (auto amat : materials) if (amat == mat) { return true; } +bool HCalSD::isItScintillator(const G4Material* mat) { + for (auto amat : materials) + if (amat == mat) { + return true; + } return false; } -bool HCalSD::isItinFidVolume (const G4ThreeVector& hitPoint) { +bool HCalSD::isItinFidVolume(const G4ThreeVector& hitPoint) { bool flag = true; if (applyFidCut) { int npmt = HFFibreFiducial::PMTNumber(hitPoint); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume:#PMT= " << npmt - << " for hit point " << hitPoint; + edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume:#PMT= " << npmt << " for hit point " << hitPoint; #endif - if (npmt <= 0) flag = false; + if (npmt <= 0) + flag = false; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume: point " << hitPoint - << " return flag " << flag; + edm::LogVerbatim("HcalSim") << "HCalSD::isItinFidVolume: point " << hitPoint << " return flag " << flag; #endif return flag; } -void HCalSD::getFromHFLibrary (const G4Step* aStep, bool& isKilled) { - +void HCalSD::getFromHFLibrary(const G4Step* aStep, bool& isKilled) { std::vector hits = showerLibrary.get()->getHits(aStep, isKilled, weight_, false); - if(!isKilled || hits.empty()) { return; } + if (!isKilled || hits.empty()) { + return; + } int primaryID = setTrackID(aStep); // Reset entry point for new primary resetForNewPrimary(aStep); - auto const theTrack = aStep->GetTrack(); + auto const theTrack = aStep->GetTrack(); int det = 5; if (G4TrackToParticleID::isGammaElectronPositron(theTrack)) { - edepositEM = 1.*GeV; + edepositEM = 1. * GeV; edepositHAD = 0.; } else { - edepositEM = 0.; - edepositHAD = 1.*GeV; + edepositEM = 0.; + edepositHAD = 1. * GeV; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary " <GetDefinition()->GetParticleName() - << " of " << aStep->GetPreStepPoint()->GetKineticEnergy()/GeV << " GeV"; + edm::LogVerbatim("HcalSim") << "HCalSD::getFromLibrary " << hits.size() << " hits for " << GetName() << " of " + << primaryID << " with " << theTrack->GetDefinition()->GetParticleName() << " of " + << aStep->GetPreStepPoint()->GetKineticEnergy() / GeV << " GeV"; #endif - for (unsigned int i=0; i hits = hfshower.get()->getHits(aStep, weight_); - if(hits.empty()) { return; } + if (hits.empty()) { + return; + } auto const theTrack = aStep->GetTrack(); int primaryID = setTrackID(aStep); - int det = 5; + int det = 5; if (G4TrackToParticleID::isGammaElectronPositron(theTrack)) { - edepositEM = 1.*GeV; + edepositEM = 1. * GeV; edepositHAD = 0.; } else { - edepositEM = 0.; - edepositHAD = 1.*GeV; + edepositEM = 0.; + edepositHAD = 1. * GeV; } - + #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::hitForFibre " << hits.size() - << " hits for " << GetName() << " of " << primaryID - << " with " << theTrack->GetDefinition()->GetParticleName() - << " of " << preStepPoint->GetKineticEnergy()/GeV - << " GeV in detector type " << det; + edm::LogVerbatim("HcalSim") << "HCalSD::hitForFibre " << hits.size() << " hits for " << GetName() << " of " + << primaryID << " with " << theTrack->GetDefinition()->GetParticleName() << " of " + << preStepPoint->GetKineticEnergy() / GeV << " GeV in detector type " << det; #endif - for (unsigned int i=0; i 0.) ? true : false; - plotHF(hitPoint,emType); + plotHF(hitPoint, emType); #endif processHit(aStep); } } } -void HCalSD::getFromParam (const G4Step* aStep, bool& isKilled) { - +void HCalSD::getFromParam(const G4Step* aStep, bool& isKilled) { std::vector hits = showerParam.get()->getHits(aStep, weight_, isKilled); - if(!isKilled || hits.empty()) { return; } + if (!isKilled || hits.empty()) { + return; + } - int primaryID = setTrackID(aStep); - int det = 5; + int primaryID = setTrackID(aStep); + int det = 5; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::getFromParam " << hits.size() << " hits for " - << GetName() << " of " << primaryID << " with " - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << " of " << preStepPoint->GetKineticEnergy()/GeV - << " GeV in detector type " << det; + edm::LogVerbatim("HcalSim") << "HCalSD::getFromParam " << hits.size() << " hits for " << GetName() << " of " + << primaryID << " with " << aStep->GetTrack()->GetDefinition()->GetParticleName() + << " of " << preStepPoint->GetKineticEnergy() / GeV << " GeV in detector type " << det; #endif - for (unsigned int i=0; iGetPreStepPoint(); - auto const theTrack = aStep->GetTrack(); - double edep = showerPMT->getHits(aStep); + auto const theTrack = aStep->GetTrack(); + double edep = showerPMT->getHits(aStep); if (edep >= 0.) { edep *= GeV; - double etrack = preStepPoint->GetKineticEnergy(); - int primaryID = 0; + double etrack = preStepPoint->GetKineticEnergy(); + int primaryID = 0; if (etrack >= energyCut) { - primaryID = theTrack->GetTrackID(); + primaryID = theTrack->GetTrackID(); } else { - primaryID = theTrack->GetParentID(); - if (primaryID == 0) primaryID = theTrack->GetTrackID(); + primaryID = theTrack->GetParentID(); + if (primaryID == 0) + primaryID = theTrack->GetTrackID(); } // Reset entry point for new primary resetForNewPrimary(aStep); // - int det = static_cast(HcalForward); - const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); - double rr = (hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y()); - double phi = (rr == 0. ? 0. :atan2(hitPoint.y(),hitPoint.x())); - double etaR = showerPMT->getRadius(); - int depth = 1; + int det = static_cast(HcalForward); + const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); + double rr = (hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y()); + double phi = (rr == 0. ? 0. : atan2(hitPoint.y(), hitPoint.x())); + double etaR = showerPMT->getRadius(); + int depth = 1; if (etaR < 0) { - depth = 2; - etaR =-etaR; + depth = 2; + etaR = -etaR; } - if (hitPoint.z() < 0) etaR =-etaR; + if (hitPoint.z() < 0) + etaR = -etaR; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR " - << etaR << " phi " << phi/deg << " depth " <GetPostStepPoint()->GetGlobalTime()); uint32_t unitID = 0; if (numberingFromDDD) { - HcalNumberingFromDDD::HcalID tmp = - numberingFromDDD.get()->unitID(det,etaR,phi,depth,1); + HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, etaR, phi, depth, 1); unitID = setDetUnitId(tmp); } currentID.setID(unitID, time, primaryID, 1); edepositHAD = aStep->GetTotalEnergyDeposit(); - edepositEM =-edepositHAD + edep; + edepositEM = -edepositHAD + edep; #ifdef plotDebug plotProfile(aStep, hitPoint, edep, time, depth); #endif #ifdef EDM_ML_DEBUG double beta = preStepPoint->GetBeta(); - edm::LogVerbatim("HcalSim") << "HCalSD::getHitPMT 1 hit for " << GetName() - << " of " << primaryID << " with " - << theTrack->GetDefinition()->GetParticleName() - << " of " << preStepPoint->GetKineticEnergy()/GeV - << " GeV with velocity " << beta << " UnitID " - << std::hex << unitID << std::dec; + edm::LogVerbatim("HcalSim") << "HCalSD::getHitPMT 1 hit for " << GetName() << " of " << primaryID << " with " + << theTrack->GetDefinition()->GetParticleName() << " of " + << preStepPoint->GetKineticEnergy() / GeV << " GeV with velocity " << beta << " UnitID " + << std::hex << unitID << std::dec; #endif processHit(aStep); } } -void HCalSD::getHitFibreBundle (const G4Step* aStep, bool type) { +void HCalSD::getHitFibreBundle(const G4Step* aStep, bool type) { auto const preStepPoint = aStep->GetPreStepPoint(); - auto const theTrack = aStep->GetTrack(); - double edep = showerBundle.get()->getHits(aStep, type); + auto const theTrack = aStep->GetTrack(); + double edep = showerBundle.get()->getHits(aStep, type); if (edep >= 0.0) { edep *= GeV; - double etrack = preStepPoint->GetKineticEnergy(); - int primaryID = 0; + double etrack = preStepPoint->GetKineticEnergy(); + int primaryID = 0; if (etrack >= energyCut) { - primaryID = theTrack->GetTrackID(); + primaryID = theTrack->GetTrackID(); } else { - primaryID = theTrack->GetParentID(); - if (primaryID == 0) primaryID = theTrack->GetTrackID(); + primaryID = theTrack->GetParentID(); + if (primaryID == 0) + primaryID = theTrack->GetTrackID(); } // Reset entry point for new primary resetForNewPrimary(aStep); // - int det = static_cast(HcalForward); - const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); - double rr = hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y(); - double phi = rr == 0. ? 0. :atan2(hitPoint.y(),hitPoint.x()); - double etaR = showerBundle->getRadius(); - int depth = 1; + int det = static_cast(HcalForward); + const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); + double rr = hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y(); + double phi = rr == 0. ? 0. : atan2(hitPoint.y(), hitPoint.x()); + double etaR = showerBundle->getRadius(); + int depth = 1; if (etaR < 0.) { - depth = 2; - etaR =-etaR; + depth = 2; + etaR = -etaR; } - if (hitPoint.z() < 0.) etaR =-etaR; + if (hitPoint.z() < 0.) + etaR = -etaR; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::Hit for Detector " << det - << " etaR " << etaR << " phi " << phi/deg - << " depth " << depth; + edm::LogVerbatim("HcalSim") << "HCalSD::Hit for Detector " << det << " etaR " << etaR << " phi " << phi / deg + << " depth " << depth; #endif double time = (aStep->GetPostStepPoint()->GetGlobalTime()); uint32_t unitID = 0; if (numberingFromDDD) { - HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det,etaR,phi,depth,1); + HcalNumberingFromDDD::HcalID tmp = numberingFromDDD.get()->unitID(det, etaR, phi, depth, 1); unitID = setDetUnitId(tmp); } - if (type) currentID.setID(unitID, time, primaryID, 3); - else currentID.setID(unitID, time, primaryID, 2); + if (type) + currentID.setID(unitID, time, primaryID, 3); + else + currentID.setID(unitID, time, primaryID, 2); edepositHAD = aStep->GetTotalEnergyDeposit(); - edepositEM =-edepositHAD + edep; + edepositEM = -edepositHAD + edep; #ifdef plotDebug plotProfile(aStep, hitPoint, edep, time, depth); #endif #ifdef EDM_ML_DEBUG double beta = preStepPoint->GetBeta(); - edm::LogVerbatim("HcalSim") << "HCalSD::getHitFibreBundle 1 hit for " - << GetName() << " of " << primaryID << " with " - << theTrack->GetDefinition()->GetParticleName() - << " of " << preStepPoint->GetKineticEnergy()/GeV - << " GeV with velocity " << beta << " UnitID " - << std::hex << unitID << std::dec; + edm::LogVerbatim("HcalSim") << "HCalSD::getHitFibreBundle 1 hit for " << GetName() << " of " << primaryID + << " with " << theTrack->GetDefinition()->GetParticleName() << " of " + << preStepPoint->GetKineticEnergy() / GeV << " GeV with velocity " << beta << " UnitID " + << std::hex << unitID << std::dec; #endif processHit(aStep); - } // non-zero energy deposit + } // non-zero energy deposit } void HCalSD::readWeightFromFile(const std::string& fName) { - std::ifstream infile; - int entry=0; + int entry = 0; infile.open(fName.c_str(), std::ios::in); if (infile) { - int det, zside, etaR, phi, lay; + int det, zside, etaR, phi, lay; double wt; while (infile >> det >> zside >> etaR >> phi >> lay >> wt) { - uint32_t id = HcalTestNumbering::packHcalIndex(det,zside,1,etaR,phi,lay); - layerWeights.insert(std::pair(id,wt)); + uint32_t id = HcalTestNumbering::packHcalIndex(det, zside, 1, etaR, phi, lay); + layerWeights.insert(std::pair(id, wt)); ++entry; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile:Entry " << entry - << " ID " << std::hex << id << std::dec << " (" - << det << "/" << zside << "/1/" << etaR << "/" - << phi << "/" << lay << ") Weight " << wt; + edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile:Entry " << entry << " ID " << std::hex << id + << std::dec << " (" << det << "/" << zside << "/1/" << etaR << "/" << phi << "/" + << lay << ") Weight " << wt; #endif } infile.close(); } - edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile: reads " << entry - << " weights from " << fName; - if (entry <= 0) useLayerWt = false; + edm::LogVerbatim("HcalSim") << "HCalSD::readWeightFromFile: reads " << entry << " weights from " << fName; + if (entry <= 0) + useLayerWt = false; } -double HCalSD::layerWeight(int det, const G4ThreeVector& pos, int depth, int lay) { - +double HCalSD::layerWeight(int det, const G4ThreeVector& pos, int depth, int lay) { double wt = 1.; if (numberingFromDDD) { //get the ID's as eta, phi, depth, ... indices - HcalNumberingFromDDD::HcalID tmp = - numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(),pos.y(), - pos.z()),depth,lay); + HcalNumberingFromDDD::HcalID tmp = + numberingFromDDD.get()->unitID(det, math::XYZVectorD(pos.x(), pos.y(), pos.z()), depth, lay); modifyDepth(tmp); - uint32_t id = HcalTestNumbering::packHcalIndex(tmp.subdet, tmp.zside, 1, - tmp.etaR, tmp.phis,tmp.lay); - std::map::const_iterator ite = layerWeights.find(id); - if (ite != layerWeights.end()) wt = ite->second; + uint32_t id = HcalTestNumbering::packHcalIndex(tmp.subdet, tmp.zside, 1, tmp.etaR, tmp.phis, tmp.lay); + std::map::const_iterator ite = layerWeights.find(id); + if (ite != layerWeights.end()) + wt = ite->second; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HCalSD::layerWeight: ID " << std::hex << id - << std::dec << " (" << tmp.subdet << "/" - << tmp.zside << "/1/" << tmp.etaR << "/" - << tmp.phis << "/" << tmp.lay << ") Weight " <GetPreStepPoint()->GetTouchable(); - static const G4String modName[8] = {"HEModule", "HVQF" , "HBModule", "MBAT", - "MBBT" , "MBBTC", "MBBT_R1P", "MBBT_R1M"}; + static const G4String modName[8] = {"HEModule", "HVQF", "HBModule", "MBAT", "MBBT", "MBBTC", "MBBT_R1P", "MBBT_R1M"}; G4ThreeVector local; - bool found=false; - double depth=-2000; + bool found = false; + double depth = -2000; int idx = 4; - for (int n=0; nGetHistoryDepth(); ++n) { + for (int n = 0; n < touch->GetHistoryDepth(); ++n) { G4String name = touch->GetVolume(n)->GetName(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "plotProfile Depth " << n << " Name " - << name; + edm::LogVerbatim("HcalSim") << "plotProfile Depth " << n << " Name " << name; #endif - for (unsigned int ii=0; ii<8; ++ii) { + for (unsigned int ii = 0; ii < 8; ++ii) { if (name == modName[ii]) { found = true; int dn = touch->GetHistoryDepth() - n; local = touch->GetHistory()->GetTransform(dn).TransformPoint(global); - if (ii == 0) {depth = local.z() - 4006.5; idx = 1;} - else if (ii == 1) {depth = local.z() + 825.0; idx = 3;} - else if (ii == 2) {depth = local.x() - 1775.; idx = 0;} - else {depth = local.y() + 15.; idx = 2;} + if (ii == 0) { + depth = local.z() - 4006.5; + idx = 1; + } else if (ii == 1) { + depth = local.z() + 825.0; + idx = 3; + } else if (ii == 2) { + depth = local.x() - 1775.; + idx = 0; + } else { + depth = local.y() + 15.; + idx = 2; + } break; } } - if (found) break; + if (found) + break; } - if (!found) depth = std::abs(global.z()) - 11500; + if (!found) + depth = std::abs(global.z()) - 11500; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "plotProfile Found " << found << " Global " - << global << " Local " << local << " depth " - << depth << " ID " << id << " EDEP " << edep - << " Time " << time; + edm::LogVerbatim("HcalSim") << "plotProfile Found " << found << " Global " << global << " Local " << local + << " depth " << depth << " ID " << id << " EDEP " << edep << " Time " << time; #endif - if (hit_[idx] != nullptr) hit_[idx]->Fill(edep); - if (time_[idx] != nullptr) time_[idx]->Fill(time,edep); - if (dist_[idx] != nullptr) dist_[idx]->Fill(depth,edep); - int jd = 2*idx + id - 7; + if (hit_[idx] != nullptr) + hit_[idx]->Fill(edep); + if (time_[idx] != nullptr) + time_[idx]->Fill(time, edep); + if (dist_[idx] != nullptr) + dist_[idx]->Fill(depth, edep); + int jd = 2 * idx + id - 7; if (jd >= 0 && jd < 4) { jd += 5; - if (hit_[jd] != nullptr) hit_[jd]->Fill(edep); - if (time_[jd] != nullptr) time_[jd]->Fill(time,edep); - if (dist_[jd] != nullptr) dist_[jd]->Fill(depth,edep); + if (hit_[jd] != nullptr) + hit_[jd]->Fill(edep); + if (time_[jd] != nullptr) + time_[jd]->Fill(time, edep); + if (dist_[jd] != nullptr) + dist_[jd]->Fill(depth, edep); } } void HCalSD::plotHF(const G4ThreeVector& hitPoint, bool emType) { - double zv = std::abs(hitPoint.z()) - gpar[4]; + double zv = std::abs(hitPoint.z()) - gpar[4]; if (emType) { - if (hzvem != nullptr) hzvem->Fill(zv); + if (hzvem != nullptr) + hzvem->Fill(zv); } else { - if (hzvhad != nullptr) hzvhad->Fill(zv); + if (hzvhad != nullptr) + hzvhad->Fill(zv); } } void HCalSD::modifyDepth(HcalNumberingFromDDD::HcalID& id) { if (id.subdet == 4) { int ieta = (id.zside == 0) ? -id.etaR : id.etaR; - if (hcalConstants->maxHFDepth(ieta,id.phis) > 2) { + if (hcalConstants->maxHFDepth(ieta, id.phis) > 2) { if (id.depth <= 2) { - if (G4UniformRand() > 0.5) id.depth += 2; + if (G4UniformRand() > 0.5) + id.depth += 2; } } - } else if ((id.subdet == 1 || id.subdet ==2) && testNumber) { + } else if ((id.subdet == 1 || id.subdet == 2) && testNumber) { id.depth = (depth_ == 0) ? 1 : 2; } } diff --git a/SimG4CMS/Calo/src/HFCherenkov.cc b/SimG4CMS/Calo/src/HFCherenkov.cc index 3e02adcbad1db..98e67d28b9b8f 100644 --- a/SimG4CMS/Calo/src/HFCherenkov.cc +++ b/SimG4CMS/Calo/src/HFCherenkov.cc @@ -13,65 +13,60 @@ #include "Randomize.hh" #include "G4SystemOfUnits.hh" -//#define DebugLog - -HFCherenkov::HFCherenkov(edm::ParameterSet const & m_HF) { - - ref_index = m_HF.getParameter("RefIndex"); - lambda1 = ((m_HF.getParameter("Lambda1"))/pow(double(10),7))*cm; - lambda2 = ((m_HF.getParameter("Lambda2"))/pow(double(10),7))*cm; - aperture = cos(asin(m_HF.getParameter("Aperture"))); - apertureTrap = cos(asin(m_HF.getParameter("ApertureTrapped"))); +//#define EDM_ML_DEBUG + +HFCherenkov::HFCherenkov(edm::ParameterSet const& m_HF) { + ref_index = m_HF.getParameter("RefIndex"); + lambda1 = ((m_HF.getParameter("Lambda1")) / pow(double(10), 7)) * cm; + lambda2 = ((m_HF.getParameter("Lambda2")) / pow(double(10), 7)) * cm; + aperture = cos(asin(m_HF.getParameter("Aperture"))); + apertureTrap = cos(asin(m_HF.getParameter("ApertureTrapped"))); aperturetrapped = m_HF.getParameter("CosApertureTrapped"); - gain = m_HF.getParameter("Gain"); - checkSurvive = m_HF.getParameter("CheckSurvive"); - UseNewPMT = m_HF.getParameter("UseR7600UPMT"); - sinPsimax = m_HF.getUntrackedParameter("SinPsiMax",0.5); - fibreR = m_HF.getUntrackedParameter("FibreR",0.3)*mm; - - edm::LogInfo("HFShower") << "HFCherenkov:: initialised with ref_index " - << ref_index << " lambda1/lambda2 (cm) " - << lambda1/cm << "|" << lambda2/cm - << " aperture(total/trapped) " << aperture << "|" - << apertureTrap << "|" << aperturetrapped - << " Check photon survival in HF " << checkSurvive - << " Gain " << gain << " useNewPMT " << UseNewPMT - << " FibreR " << fibreR; + gain = m_HF.getParameter("Gain"); + checkSurvive = m_HF.getParameter("CheckSurvive"); + UseNewPMT = m_HF.getParameter("UseR7600UPMT"); + sinPsimax = m_HF.getUntrackedParameter("SinPsiMax", 0.5); + fibreR = m_HF.getUntrackedParameter("FibreR", 0.3) * mm; + + edm::LogVerbatim("HFShower") << "HFCherenkov:: initialised with ref_index " << ref_index << " lambda1/lambda2 (cm) " + << lambda1 / cm << "|" << lambda2 / cm << " aperture(total/trapped) " << aperture << "|" + << apertureTrap << "|" << aperturetrapped << " Check photon survival in HF " + << checkSurvive << " Gain " << gain << " useNewPMT " << UseNewPMT << " FibreR " + << fibreR; clearVectors(); } HFCherenkov::~HFCherenkov() {} -int HFCherenkov::computeNPhTrapped(double pBeta, - double u, double v, double w, - double step_length, double zFiber, - double dose, int npe_Dose) { - - if (pBeta < (1/ref_index) || step_length < 0.0001) {return 0;} +int HFCherenkov::computeNPhTrapped( + double pBeta, double u, double v, double w, double step_length, double zFiber, double dose, int npe_Dose) { + if (pBeta < (1 / ref_index) || step_length < 0.0001) { + return 0; + } - double uv = sqrt(u*u + v*v); + double uv = sqrt(u * u + v * v); int nbOfPhotons = computeNbOfPhotons(pBeta, step_length); if (nbOfPhotons < 0) { return 0; } else if (nbOfPhotons > 0) { - double w_ph=0; + double w_ph = 0; for (int i = 0; i < nbOfPhotons; i++) { - double rand = G4UniformRand(); - double theta_C = acos(1./(pBeta*ref_index)); - double phi_C = 2*M_PI*rand; + double rand = G4UniformRand(); + double theta_C = acos(1. / (pBeta * ref_index)); + double phi_C = 2 * M_PI * rand; double sinTheta = sin(theta_C); double cosTheta = cos(theta_C); - double cosPhi = cos(phi_C); + double cosPhi = cos(phi_C); //photon momentum - if (uv < 0.001) { // aligned with z-axis - w_ph = cosTheta; - } else { // general case - w_ph = w * cosTheta - sinTheta * cosPhi * uv; + if (uv < 0.001) { // aligned with z-axis + w_ph = cosTheta; + } else { // general case + w_ph = w * cosTheta - sinTheta * cosPhi * uv; } - if (w_ph > apertureTrap) { // phton trapped inside fiber - npe_Dose += 1; + if (w_ph > apertureTrap) { // phton trapped inside fiber + npe_Dose += 1; } } } @@ -79,327 +74,309 @@ int HFCherenkov::computeNPhTrapped(double pBeta, return n_photons; } -int HFCherenkov::computeNPE(const G4Step * aStep, const G4ParticleDefinition* pDef, - double pBeta, double u, double v, double w, - double step_length, double zFiber, - double dose, int npe_Dose) { - +int HFCherenkov::computeNPE(const G4Step* aStep, + const G4ParticleDefinition* pDef, + double pBeta, + double u, + double v, + double w, + double step_length, + double zFiber, + double dose, + int npe_Dose) { clearVectors(); - if (!isApplicable(pDef)) {return 0;} - if (pBeta < (1/ref_index) || step_length < 0.0001) { -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: pBeta " << pBeta - << " 1/mu " << (1/ref_index) << " step_length " - << step_length; + if (!isApplicable(pDef)) { + return 0; + } + if (pBeta < (1 / ref_index) || step_length < 0.0001) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: pBeta " << pBeta << " 1/mu " << (1 / ref_index) + << " step_length " << step_length; #endif return 0; } - - double uv = sqrt(u*u + v*v); - int nbOfPhotons = computeNbOfPhotons(pBeta, step_length) - *aStep->GetTrack()->GetWeight(); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: pBeta " << pBeta - << " u/v/w " << u << "/" << v << "/" << w - << " step_length " << step_length << " zFib " << zFiber - << " nbOfPhotons " << nbOfPhotons; + + double uv = sqrt(u * u + v * v); + int nbOfPhotons = computeNbOfPhotons(pBeta, step_length) * aStep->GetTrack()->GetWeight(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: pBeta " << pBeta << " u/v/w " << u << "/" << v << "/" << w + << " step_length " << step_length << " zFib " << zFiber << " nbOfPhotons " + << nbOfPhotons; #endif if (nbOfPhotons < 0) { return 0; } else if (nbOfPhotons > 0) { - G4StepPoint * preStepPoint = aStep->GetPreStepPoint(); + G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4TouchableHandle& theTouchable = preStepPoint->GetTouchableHandle(); - G4ThreeVector localprepos = theTouchable->GetHistory()-> - GetTopTransform().TransformPoint(aStep->GetPreStepPoint()->GetPosition()); - G4ThreeVector localpostpos = theTouchable->GetHistory()-> - GetTopTransform().TransformPoint(aStep->GetPostStepPoint()->GetPosition()); - - double length=sqrt((localpostpos.x()-localprepos.x())*(localpostpos.x()-localprepos.x()) - +(localpostpos.y()-localprepos.y())*(localpostpos.y()-localprepos.y())); - double yemit = std::sqrt(fibreR*fibreR-length*length/4.); + G4ThreeVector localprepos = + theTouchable->GetHistory()->GetTopTransform().TransformPoint(aStep->GetPreStepPoint()->GetPosition()); + G4ThreeVector localpostpos = + theTouchable->GetHistory()->GetTopTransform().TransformPoint(aStep->GetPostStepPoint()->GetPosition()); + + double length = sqrt((localpostpos.x() - localprepos.x()) * (localpostpos.x() - localprepos.x()) + + (localpostpos.y() - localprepos.y()) * (localpostpos.y() - localprepos.y())); + double yemit = std::sqrt(fibreR * fibreR - length * length / 4.); - double u_ph=0,v_ph=0, w_ph=0; + double u_ph = 0, v_ph = 0, w_ph = 0; for (int i = 0; i < nbOfPhotons; i++) { - double rand = G4UniformRand(); - double theta_C = acos(1./(pBeta*ref_index)); - double phi_C = 2*M_PI*rand; + double rand = G4UniformRand(); + double theta_C = acos(1. / (pBeta * ref_index)); + double phi_C = 2 * M_PI * rand; double sinTheta = sin(theta_C); double cosTheta = cos(theta_C); - double cosPhi = cos(phi_C); - double sinPhi = sin(phi_C); + double cosPhi = cos(phi_C); + double sinPhi = sin(phi_C); //photon momentum - if (uv < 0.001) { // aligned with z-axis - u_ph = sinTheta * cosPhi ; - v_ph = sinTheta * sinPhi; - w_ph = cosTheta; - } else { // general case - u_ph = uv * cosTheta + sinTheta * cosPhi * w; - v_ph = sinTheta * sinPhi; - w_ph = w * cosTheta - sinTheta * cosPhi * uv; + if (uv < 0.001) { // aligned with z-axis + u_ph = sinTheta * cosPhi; + v_ph = sinTheta * sinPhi; + w_ph = cosTheta; + } else { // general case + u_ph = uv * cosTheta + sinTheta * cosPhi * w; + v_ph = sinTheta * sinPhi; + w_ph = w * cosTheta - sinTheta * cosPhi * uv; } double r_lambda = G4UniformRand(); - double lambda0 = (lambda1 * lambda2) / (lambda2 - r_lambda * - (lambda2 - lambda1)); - double lambda = (lambda0/cm) * pow(double(10),7); // lambda is in nm + double lambda0 = (lambda1 * lambda2) / (lambda2 - r_lambda * (lambda2 - lambda1)); + double lambda = (lambda0 / cm) * pow(double(10), 7); // lambda is in nm wlini.push_back(lambda); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: " << i << " lambda " - << lambda << " w_ph " << w_ph << " aperture " - << aperture; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: " << i << " lambda " << lambda << " w_ph " << w_ph + << " aperture " << aperture; #endif -// -------------- - double xemit=length*(G4UniformRand()-0.5); - double gam=atan2(yemit,xemit); - double eps=atan2(v_ph,u_ph); - double sinBeta=sin(gam-eps); - double rho=sqrt(xemit*xemit+yemit*yemit); - double sinEta=rho/fibreR*sinBeta; - double cosEta=sqrt(1.-sinEta*sinEta); - double sinPsi=sqrt(1.-w_ph*w_ph); - double cosKsi=cosEta*sinPsi; -#ifdef DebugLog - if (cosKsi < aperturetrapped && w_ph>0.) { - LogDebug("HFShower") << "HFCherenkov::Trapped photon : " << u_ph << " " - << v_ph << " " << w_ph << " " << xemit << " " - << gam << " " << eps << " " << sinBeta << " " - << rho << " " << sinEta << " " << cosEta << " " - << " " << sinPsi << " " << cosKsi; + // -------------- + double xemit = length * (G4UniformRand() - 0.5); + double gam = atan2(yemit, xemit); + double eps = atan2(v_ph, u_ph); + double sinBeta = sin(gam - eps); + double rho = sqrt(xemit * xemit + yemit * yemit); + double sinEta = rho / fibreR * sinBeta; + double cosEta = sqrt(1. - sinEta * sinEta); + double sinPsi = sqrt(1. - w_ph * w_ph); + double cosKsi = cosEta * sinPsi; +#ifdef EDM_ML_DEBUG + if (cosKsi < aperturetrapped && w_ph > 0.) { + edm::LogVerbatim("HFShower") << "HFCherenkov::Trapped photon : " << u_ph << " " << v_ph << " " << w_ph << " " + << xemit << " " << gam << " " << eps << " " << sinBeta << " " << rho << " " + << sinEta << " " << cosEta << " " + << " " << sinPsi << " " << cosKsi; } else { - LogDebug("HFShower") << "HFCherenkov::Rejected photon : " << u_ph <<" " - << v_ph << " " << w_ph << " " << xemit << " " - << gam << " " << eps << " " << sinBeta << " " - << rho << " " << sinEta << " " << cosEta << " " - << " " << sinPsi << " " << cosKsi; + edm::LogVerbatim("HFShower") << "HFCherenkov::Rejected photon : " << u_ph << " " << v_ph << " " << w_ph << " " + << xemit << " " << gam << " " << eps << " " << sinBeta << " " << rho << " " + << sinEta << " " << cosEta << " " + << " " << sinPsi << " " << cosKsi; } #endif - if (cosKsi < aperturetrapped // photon trapped inside fiber - && w_ph>0. // and moves to PMT - && sinPsi < sinPsimax) { // and is not reflected at fiber end - wltrap.push_back(lambda); - double prob_HF = 1.0; //photon survived in HF - double a0_inv = 0.1234; //meter^-1 - double prob_MX = exp( - 0.5 * a0_inv ); //light mixer - if (checkSurvive) { - double a_inv = a0_inv + 0.14 * pow(dose,0.30); - double z_meters = zFiber; - prob_HF = exp(-z_meters * a_inv ); //photon survived in HF - } - rand = G4UniformRand(); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: probHF " << prob_HF - << " prob_MX " << prob_MX << " Random " << rand - << " Survive? " << (rand < (prob_HF * prob_MX)); + if (cosKsi < aperturetrapped // photon trapped inside fiber + && w_ph > 0. // and moves to PMT + && sinPsi < sinPsimax) { // and is not reflected at fiber end + wltrap.push_back(lambda); + double prob_HF = 1.0; //photon survived in HF + double a0_inv = 0.1234; //meter^-1 + double prob_MX = exp(-0.5 * a0_inv); //light mixer + if (checkSurvive) { + double a_inv = a0_inv + 0.14 * pow(dose, 0.30); + double z_meters = zFiber; + prob_HF = exp(-z_meters * a_inv); //photon survived in HF + } + rand = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: probHF " << prob_HF << " prob_MX " << prob_MX + << " Random " << rand << " Survive? " << (rand < (prob_HF * prob_MX)); #endif - if (rand < (prob_HF * prob_MX)) { // survived and sent to light mixer - wlatten.push_back(lambda); - rand = G4UniformRand(); - double effHEM = computeHEMEff(lambda); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: w_ph " << w_ph - << " effHEM " << effHEM << " Random " << rand - << " Survive? " << (w_ph>0.997||(rand 0.997 || (rand < effHEM)); #endif - if (w_ph>0.997 || (rand 0.997 || (rand < effHEM)) { // survived HEM + wlhem.push_back(lambda); + double qEffic = computeQEff(lambda); + rand = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: qEffic " << qEffic << " Random " << rand + << " Survive? " << (rand < qEffic); #endif - if (rand < qEffic) { // made photoelectron - npe_Dose += 1; - momZ.push_back(w_ph); - wl.push_back(lambda); - wlqeff.push_back(lambda); - } // made pe - } // passed HEM - } // passed fiber - } // end of if(w_ph < w_aperture), trapped inside fiber - }// end of ++NbOfPhotons - } // end of if(NbOfPhotons)} - int npe = npe_Dose; // Nb of photoelectrons -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPE: npe " << npe; + if (rand < qEffic) { // made photoelectron + npe_Dose += 1; + momZ.push_back(w_ph); + wl.push_back(lambda); + wlqeff.push_back(lambda); + } // made pe + } // passed HEM + } // passed fiber + } // end of if(w_ph < w_aperture), trapped inside fiber + } // end of ++NbOfPhotons + } // end of if(NbOfPhotons)} + int npe = npe_Dose; // Nb of photoelectrons +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPE: npe " << npe; #endif return npe; } -int HFCherenkov::computeNPEinPMT(const G4ParticleDefinition* pDef, double pBeta, - double u, double v, double w, - double step_length){ +int HFCherenkov::computeNPEinPMT( + const G4ParticleDefinition* pDef, double pBeta, double u, double v, double w, double step_length) { clearVectors(); int npe_ = 0; - if (!isApplicable(pDef)) {return 0;} - if (pBeta < (1/ref_index) || step_length < 0.0001) { -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: pBeta " << pBeta - << " 1/mu " << (1/ref_index) << " step_length " - << step_length; + if (!isApplicable(pDef)) { + return 0; + } + if (pBeta < (1 / ref_index) || step_length < 0.0001) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPEinPMT: pBeta " << pBeta << " 1/mu " << (1 / ref_index) + << " step_length " << step_length; #endif return 0; } - - double uv = sqrt(u*u + v*v); + + double uv = sqrt(u * u + v * v); int nbOfPhotons = computeNbOfPhotons(pBeta, step_length); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: pBeta " << pBeta - << " u/v/w " << u << "/" << v << "/" << w - << " step_length " << step_length - << " nbOfPhotons " << nbOfPhotons; -#endif +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPEinPMT: pBeta " << pBeta << " u/v/w " << u << "/" << v << "/" + << w << " step_length " << step_length << " nbOfPhotons " << nbOfPhotons; +#endif if (nbOfPhotons < 0) { return 0; } else if (nbOfPhotons > 0) { - double w_ph=0; + double w_ph = 0; for (int i = 0; i < nbOfPhotons; i++) { - double rand = G4UniformRand(); - double theta_C = acos(1./(pBeta*ref_index)); - double phi_C = 2*M_PI*rand; + double rand = G4UniformRand(); + double theta_C = acos(1. / (pBeta * ref_index)); + double phi_C = 2 * M_PI * rand; double sinTheta = sin(theta_C); double cosTheta = cos(theta_C); - double cosPhi = cos(phi_C); + double cosPhi = cos(phi_C); //photon momentum - if (uv < 0.001) { // aligned with z-axis - w_ph = cosTheta; - } else { // general case - w_ph = w * cosTheta - sinTheta * cosPhi * uv; + if (uv < 0.001) { // aligned with z-axis + w_ph = cosTheta; + } else { // general case + w_ph = w * cosTheta - sinTheta * cosPhi * uv; } double r_lambda = G4UniformRand(); - double lambda0 = (lambda1 * lambda2) / (lambda2 - r_lambda * - (lambda2 - lambda1)); - double lambda = (lambda0/cm) * pow(double(10),7); // lambda is in nm + double lambda0 = (lambda1 * lambda2) / (lambda2 - r_lambda * (lambda2 - lambda1)); + double lambda = (lambda0 / cm) * pow(double(10), 7); // lambda is in nm wlini.push_back(lambda); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: " < aperture) { // phton trapped inside PMT glass - wltrap.push_back(lambda); - rand = G4UniformRand(); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: Random " << rand - << " Survive? " << (rand < 1.); + if (w_ph > aperture) { // phton trapped inside PMT glass + wltrap.push_back(lambda); + rand = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPEinPMT: Random " << rand << " Survive? " << (rand < 1.); #endif - if (rand < 1.0) { // survived all the times and sent to photo-cathode - wlatten.push_back(lambda); - double qEffic = computeQEff(lambda);//Quantum efficiency of the PMT - rand = G4UniformRand(); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: qEffic " - << qEffic << " Random " << rand - << " Survive? " <<(rand < qEffic); + if (rand < 1.0) { // survived all the times and sent to photo-cathode + wlatten.push_back(lambda); + double qEffic = computeQEff(lambda); //Quantum efficiency of the PMT + rand = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPEinPMT: qEffic " << qEffic << " Random " << rand + << " Survive? " << (rand < qEffic); #endif - if (rand < qEffic) { // made photoelectron - npe_ += 1; - momZ.push_back(w_ph); - wl.push_back(lambda); - wlqeff.push_back(lambda); - } // made pe - } // accepted all Cherenkov photons - } // end of if(w_ph < w_aperture), trapped inside glass - }// end of ++NbOfPhotons - } // end of if(NbOfPhotons)} -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNPEinPMT: npe " << npe_; + if (rand < qEffic) { // made photoelectron + npe_ += 1; + momZ.push_back(w_ph); + wl.push_back(lambda); + wlqeff.push_back(lambda); + } // made pe + } // accepted all Cherenkov photons + } // end of if(w_ph < w_aperture), trapped inside glass + } // end of ++NbOfPhotons + } // end of if(NbOfPhotons)} +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNPEinPMT: npe " << npe_; #endif return npe_; } -std::vector HFCherenkov::getWLIni() { +std::vector HFCherenkov::getWLIni() { std::vector v = wlini; return v; } -std::vector HFCherenkov::getWLTrap() { +std::vector HFCherenkov::getWLTrap() { std::vector v = wltrap; return v; } -std::vector HFCherenkov::getWLAtten() { +std::vector HFCherenkov::getWLAtten() { std::vector v = wlatten; return v; } -std::vector HFCherenkov::getWLHEM() { - std::vector v = wlhem; +std::vector HFCherenkov::getWLHEM() { + std::vector v = wlhem; return v; } -std::vector HFCherenkov::getWLQEff() { +std::vector HFCherenkov::getWLQEff() { std::vector v = wlqeff; return v; } -std::vector HFCherenkov::getWL() { +std::vector HFCherenkov::getWL() { std::vector v = wl; return v; } -std::vector HFCherenkov::getMom() { +std::vector HFCherenkov::getMom() { std::vector v = momZ; return v; } int HFCherenkov::computeNbOfPhotons(double beta, G4double stepL) { - double pBeta = beta; double alpha = 0.0073; double step_length = stepL; - double theta_C = acos(1./(pBeta*ref_index)); - double lambdaDiff = (1./lambda1 - 1./lambda2); - double cherenPhPerLength = 2 * M_PI * alpha * lambdaDiff*cm; - double d_NOfPhotons = cherenPhPerLength * sin(theta_C)*sin(theta_C) * (step_length/cm); + double theta_C = acos(1. / (pBeta * ref_index)); + double lambdaDiff = (1. / lambda1 - 1. / lambda2); + double cherenPhPerLength = 2 * M_PI * alpha * lambdaDiff * cm; + double d_NOfPhotons = cherenPhPerLength * sin(theta_C) * sin(theta_C) * (step_length / cm); int nbOfPhotons = int(d_NOfPhotons); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeNbOfPhotons: StepLength " - << step_length << " theta_C " << theta_C - << " lambdaDiff " << lambdaDiff - << " cherenPhPerLength " << cherenPhPerLength - << " Photons " << d_NOfPhotons << " " << nbOfPhotons; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeNbOfPhotons: StepLength " << step_length << " theta_C " + << theta_C << " lambdaDiff " << lambdaDiff << " cherenPhPerLength " << cherenPhPerLength + << " Photons " << d_NOfPhotons << " " << nbOfPhotons; #endif return nbOfPhotons; } double HFCherenkov::computeQEff(double wavelength) { - double qeff(0.); if (UseNewPMT) { - if (wavelength<=350) { - qeff=2.45867*(TMath::Landau(wavelength,353.820,59.1324)); - } else if (wavelength>350 && wavelength<500) { - qeff= 0.441989*exp(-pow((wavelength-358.371),2)/(2*pow((138.277),2))); - } else if (wavelength>=500 && wavelength<550) { - qeff= 0.271862*exp(-pow((wavelength-491.505),2)/(2*pow((47.0418),2))); - } else if (wavelength>=550) { - qeff= 0.137297*exp(-pow((wavelength-520.260),2)/(2*pow((75.5023),2))); + if (wavelength <= 350) { + qeff = 2.45867 * (TMath::Landau(wavelength, 353.820, 59.1324)); + } else if (wavelength > 350 && wavelength < 500) { + qeff = 0.441989 * exp(-pow((wavelength - 358.371), 2) / (2 * pow((138.277), 2))); + } else if (wavelength >= 500 && wavelength < 550) { + qeff = 0.271862 * exp(-pow((wavelength - 491.505), 2) / (2 * pow((47.0418), 2))); + } else if (wavelength >= 550) { + qeff = 0.137297 * exp(-pow((wavelength - 520.260), 2) / (2 * pow((75.5023), 2))); } -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov:: for new PMT : wavelength === " - << wavelength << "\tqeff ===\t" << qeff; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov:: for new PMT : wavelength === " << wavelength << "\tqeff ===\t" + << qeff; #endif } else { - double y = (wavelength - 275.) /180.; - double func = 1. / (1. + 250.*pow((y/5.),4)); - double qE_R7525 = 0.77 * y * exp(-y) * func ; - qeff = qE_R7525; -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov:: for old PMT : wavelength === " - << wavelength << "; qeff = " << qeff; + double y = (wavelength - 275.) / 180.; + double func = 1. / (1. + 250. * pow((y / 5.), 4)); + double qE_R7525 = 0.77 * y * exp(-y) * func; + qeff = qE_R7525; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeQEff: wavelength " << wavelength << " y/func " << y << "/" + << func << " qeff " << qeff; + edm::LogVerbatim("HFShower") << "HFCherenkov:: for old PMT : wavelength === " << wavelength << "; qeff = " << qeff; #endif } - -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeQEff: wavelength " << wavelength - << " y/func " << y << "/" << func << " qeff " << qeff; -#endif return qeff; } double HFCherenkov::computeHEMEff(double wavelength) { - double hEMEff = 0; if (wavelength < 400.) { hEMEff = 0.; @@ -416,35 +393,32 @@ double HFCherenkov::computeHEMEff(double wavelength) { // abs(wavelength - 575.) < 25.) //hEMEff = 0.96; hEMEff = 0.98; - } else if (wavelength > 565. && wavelength <= 635.) { // added later + } else if (wavelength > 565. && wavelength <= 635.) { // added later // abs(wavelength - 600.) < 35.) hEMEff = (701.7268 / wavelength) - 0.186; } } -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::computeHEMEff: wavelength " - << wavelength << " hEMEff " << hEMEff; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::computeHEMEff: wavelength " << wavelength << " hEMEff " << hEMEff; #endif return hEMEff; } double HFCherenkov::smearNPE(int npe) { - double pe = 0.; if (npe > 0) { for (int i = 0; i < npe; ++i) { - double val = G4Poisson(gain); - pe += (val/gain) + 0.001*G4UniformRand(); + double val = G4Poisson(gain); + pe += (val / gain) + 0.001 * G4UniformRand(); } } -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::smearNPE: npe " << npe << " pe " << pe; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::smearNPE: npe " << npe << " pe " << pe; #endif return pe; } void HFCherenkov::clearVectors() { - wl.clear(); wlini.clear(); wltrap.clear(); @@ -456,10 +430,9 @@ void HFCherenkov::clearVectors() { bool HFCherenkov::isApplicable(const G4ParticleDefinition* aParticleType) { bool tmp = (aParticleType->GetPDGCharge() != 0); -#ifdef DebugLog - LogDebug("HFShower") << "HFCherenkov::isApplicable: aParticleType " - << aParticleType->GetParticleName() << " PDGCharge " - << aParticleType->GetPDGCharge() << " Result " << tmp; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFCherenkov::isApplicable: aParticleType " << aParticleType->GetParticleName() + << " PDGCharge " << aParticleType->GetPDGCharge() << " Result " << tmp; #endif return tmp; } diff --git a/SimG4CMS/Calo/src/HFDarkening.cc b/SimG4CMS/Calo/src/HFDarkening.cc index 61fa787772d01..f300db93ce740 100644 --- a/SimG4CMS/Calo/src/HFDarkening.cc +++ b/SimG4CMS/Calo/src/HFDarkening.cc @@ -18,7 +18,7 @@ HFDarkening::HFDarkening(const edm::ParameterSet& pset) { //HF area of consideration is 1115 cm from interaction point to 1280cm in z-axis //Radius (cm) - 13 cm from Beam pipe to 130cm (the top of HF active area) //Dose in MRad - + vecOfDoubles HFDosePars = pset.getParameter("doseLayerDepth"); int i = 0; for (int Z = 0; Z != _numberOfZLayers; ++Z) { @@ -29,40 +29,49 @@ HFDarkening::HFDarkening(const edm::ParameterSet& pset) { } } -HFDarkening::~HFDarkening() { } +HFDarkening::~HFDarkening() {} double HFDarkening::dose(unsigned int layer, double Radius) { // Radii are 13-17, 17-20, 20-24, 24-29, 29-34, 34-41, 41-48, 48-58, 58-69, 69-82, 82-98, 98-116, 116-130 // These radii are specific to the geometry of the dose map, which closely matches HF Tower Geometry, // but not exactly. - if (layer > (_numberOfZLayers-1)) - { + if (layer > (_numberOfZLayers - 1)) { return 0.; } - + int radius = 0; - if (Radius <= 17.0) radius = 0; - else if (Radius <= 20.0) radius = 1; - else if (Radius <= 24.0) radius = 2; - else if (Radius <= 29.0) radius = 3; - else if (Radius <= 34.0) radius = 4; - else if (Radius <= 41.0) radius = 5; - else if (Radius <= 48.0) radius = 6; - else if (Radius <= 58.0) radius = 7; - else if (Radius <= 69.0) radius = 8; - else if (Radius <= 82.0) radius = 9; - else if (Radius <= 98.0) radius = 10; - else if (Radius <= 116.0) radius = 11; - else if (Radius <= 130.0) radius = 12; - else return 0.; - + if (Radius <= 17.0) + radius = 0; + else if (Radius <= 20.0) + radius = 1; + else if (Radius <= 24.0) + radius = 2; + else if (Radius <= 29.0) + radius = 3; + else if (Radius <= 34.0) + radius = 4; + else if (Radius <= 41.0) + radius = 5; + else if (Radius <= 48.0) + radius = 6; + else if (Radius <= 58.0) + radius = 7; + else if (Radius <= 69.0) + radius = 8; + else if (Radius <= 82.0) + radius = 9; + else if (Radius <= 98.0) + radius = 10; + else if (Radius <= 116.0) + radius = 11; + else if (Radius <= 130.0) + radius = 12; + else + return 0.; + return HFDoseLayerDarkeningPars[layer][radius]; } -double HFDarkening::degradation(double mrad) { - return (exp(-1.44*pow(mrad/100,0.44)*0.2/4.343)); -} +double HFDarkening::degradation(double mrad) { return (exp(-1.44 * pow(mrad / 100, 0.44) * 0.2 / 4.343)); } -double HFDarkening::int_lumi(double intlumi) { - return (intlumi/500.); -} +double HFDarkening::int_lumi(double intlumi) { return (intlumi / 500.); } diff --git a/SimG4CMS/Calo/src/HFFibre.cc b/SimG4CMS/Calo/src/HFFibre.cc index a234605b9d826..e25a01adb5252 100644 --- a/SimG4CMS/Calo/src/HFFibre.cc +++ b/SimG4CMS/Calo/src/HFFibre.cc @@ -15,181 +15,172 @@ #include #include -//#define DebugLog - -HFFibre::HFFibre(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p) { +//#define EDM_ML_DEBUG +HFFibre::HFFibre(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p) { edm::ParameterSet m_HF = p.getParameter("HFShower"); - cFibre = c_light*(m_HF.getParameter("CFibre")); - - edm::LogVerbatim("HFShower") << "HFFibre:: Speed of light in fibre " << cFibre - << " m/ns"; - - std::string attribute = "Volume"; - std::string value = "HF"; - DDSpecificsMatchesValueFilter filter1{DDValue(attribute,value,0)}; - DDFilteredView fv1(cpv,filter1); + cFibre = c_light * (m_HF.getParameter("CFibre")); + + edm::LogVerbatim("HFShower") << "HFFibre:: Speed of light in fibre " << cFibre << " m/ns"; + + std::string attribute = "Volume"; + std::string value = "HF"; + DDSpecificsMatchesValueFilter filter1{DDValue(attribute, value, 0)}; + DDFilteredView fv1(cpv, filter1); bool dodet = fv1.firstChild(); if (dodet) { DDsvalues_type sv(fv1.mergedSpecifics()); // Attenuation length - nBinAtt = -1; - attL = getDDDArray("attl",sv,nBinAtt); + nBinAtt = -1; + attL = getDDDArray("attl", sv, nBinAtt); std::stringstream ss1; - for (int it=0; it nvec = getDDDArray("lambLim",sv,nb); + int nb = 2; + std::vector nvec = getDDDArray("lambLim", sv, nb); lambLim[0] = static_cast(nvec[0]); lambLim[1] = static_cast(nvec[1]); - edm::LogVerbatim("HFShower") << "HFFibre: Limits on lambda " << lambLim[0] - << " and " << lambLim[1]; + edm::LogVerbatim("HFShower") << "HFFibre: Limits on lambda " << lambLim[0] << " and " << lambLim[1]; // Fibre Lengths - nb = 0; - longFL = getDDDArray("LongFL",sv,nb); + nb = 0; + longFL = getDDDArray("LongFL", sv, nb); std::stringstream ss2; - for (int it=0; itgetGparHF(); - radius = hcons->getRTableHF(); + gpar = hcons->getGparHF(); + radius = hcons->getRTableHF(); - nBinR = (int)(radius.size()); + nBinR = (int)(radius.size()); std::stringstream sss; - for (int i=0; i= nBinAtt) - j = nBinAtt-1; + int j = i; + if (i >= nBinAtt) + j = nBinAtt - 1; else if (i < 0) j = 0; double att = attL[j]; -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFFibre::attLength for Lambda " << lambda - << " index " << i << " " << j << " Att. Length " - << att; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibre::attLength for Lambda " << lambda << " index " << i << " " << j + << " Att. Length " << att; #endif return att; } double HFFibre::tShift(const G4ThreeVector& point, int depth, int fromEndAbs) { - double zFibre = zShift(point, depth, fromEndAbs); - double time = zFibre/cFibre; -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFFibre::tShift for point " << point - << " ( depth = " << depth <<", traversed length = " - << zFibre/cm << " cm) = " << time/ns << " ns"; + double time = zFibre / cFibre; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibre::tShift for point " << point << " ( depth = " << depth + << ", traversed length = " << zFibre / cm << " cm) = " << time / ns << " ns"; #endif return time; } -double HFFibre::zShift(const G4ThreeVector& point, int depth, int fromEndAbs) { // point is z-local +double HFFibre::zShift(const G4ThreeVector& point, int depth, int fromEndAbs) { // point is z-local double zFibre = 0; - double hR = sqrt((point.x())*(point.x())+(point.y())*(point.y())); - int ieta = 0; - double length = 250*cm; + double hR = sqrt((point.x()) * (point.x()) + (point.y()) * (point.y())); + int ieta = 0; + double length = 250 * cm; if (fromEndAbs < 0) { - zFibre = 0.5*gpar[1] - point.z(); // Never, as fromEndAbs=0 (?) + zFibre = 0.5 * gpar[1] - point.z(); // Never, as fromEndAbs=0 (?) } else { // Defines the Radius bin by radial subdivision - for (int i = nBinR-1; i > 0; --i) if (hR < radius[i]) ieta = nBinR - i - 1; + for (int i = nBinR - 1; i > 0; --i) + if (hR < radius[i]) + ieta = nBinR - i - 1; // define the length of the fibre if (depth == 2) { - if ((int)(shortFL.size()) > ieta) length = shortFL[ieta]; + if ((int)(shortFL.size()) > ieta) + length = shortFL[ieta]; } else { - if ((int)(longFL.size()) > ieta) length = longFL[ieta]; + if ((int)(longFL.size()) > ieta) + length = longFL[ieta]; } zFibre = length; if (fromEndAbs > 0) { - zFibre -= gpar[1]; // Never, as fromEndAbs=0 (M.K. ?) - } else { - double zz = 0.5*gpar[1] + point.z(); - zFibre -= zz; + zFibre -= gpar[1]; // Never, as fromEndAbs=0 (M.K. ?) + } else { + double zz = 0.5 * gpar[1] + point.z(); + zFibre -= zz; } - if (depth == 2) zFibre += gpar[0]; // here zFibre is reduced for Short + if (depth == 2) + zFibre += gpar[0]; // here zFibre is reduced for Short } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFFibre::zShift for point " << point - << " (R = " << hR/cm << " cm, Index = " << ieta - << ", depth = " << depth << ", Fibre Length = " - << length/cm << " cm = " << zFibre/cm - << " cm)"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibre::zShift for point " << point << " (R = " << hR / cm + << " cm, Index = " << ieta << ", depth = " << depth << ", Fibre Length = " << length / cm + << " cm = " << zFibre / cm << " cm)"; #endif return zFibre; } -std::vector HFFibre::getDDDArray(const std::string & str, - const DDsvalues_type & sv, - int & nmin) { - -#ifdef DebugLog - LogDebug("HFShower") << "HFFibre:getDDDArray called for " << str - << " with nMin " << nmin; +std::vector HFFibre::getDDDArray(const std::string& str, const DDsvalues_type& sv, int& nmin) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibre:getDDDArray called for " << str << " with nMin " << nmin; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("HFShower") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nmin > 0) { if (nval < nmin) { - edm::LogError("HFShower") << "HFFibre : # of " << str << " bins " - << nval << " < " << nmin << " ==> illegal"; - throw cms::Exception("Unknown", "HFFibre") - << "nval < nmin for array " << str <<"\n"; + edm::LogError("HFShower") << "HFFibre : # of " << str << " bins " << nval << " < " << nmin << " ==> illegal"; + throw cms::Exception("Unknown", "HFFibre") << "nval < nmin for array " << str << "\n"; } } else { if (nval < 1 && nmin != 0) { - edm::LogError("HFShower") << "HFFibre : # of " << str << " bins " - << nval << " < 1 ==> illegal (nmin=" - << nmin << ")"; - throw cms::Exception("Unknown", "HFFibre") - << "nval < 1 for array " << str <<"\n"; + edm::LogError("HFShower") << "HFFibre : # of " << str << " bins " << nval << " < 1 ==> illegal (nmin=" << nmin + << ")"; + throw cms::Exception("Unknown", "HFFibre") << "nval < 1 for array " << str << "\n"; } } nmin = nval; @@ -197,8 +188,7 @@ std::vector HFFibre::getDDDArray(const std::string & str, } else { if (nmin != 0) { edm::LogError("HFShower") << "HFFibre : cannot get array " << str; - throw cms::Exception("Unknown", "HFFibre") - << "cannot get array " << str <<"\n"; + throw cms::Exception("Unknown", "HFFibre") << "cannot get array " << str << "\n"; } else { std::vector fvec; return fvec; diff --git a/SimG4CMS/Calo/src/HFFibreFiducial.cc b/SimG4CMS/Calo/src/HFFibreFiducial.cc index aec9fa99636b5..580ea9a66c5fb 100644 --- a/SimG4CMS/Calo/src/HFFibreFiducial.cc +++ b/SimG4CMS/Calo/src/HFFibreFiducial.cc @@ -4,326 +4,327 @@ #include "CLHEP/Units/GlobalPhysicalConstants.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" -int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect) -{ - double xv = pe_effect.x(); // X in global system - double yv = pe_effect.y(); // Y in global system - double phi = atan2(yv, xv); // In global system - if (phi < 0.) phi+=CLHEP::pi; // Just for security - double dph = CLHEP::pi/18; // 10 deg = a half sector width - double sph = dph+dph; // 20 deg = a sector width - int nphi = phi/dph; // 10 deg sector # - LogDebug("HFShower") <<"HFFibreFiducial:***> P = " << pe_effect - << ", phi = " << phi/CLHEP::deg; - if (nphi > 35) nphi=35; // Just for security - double xl=0.; // local sector coordinates (left/right) - double yl=0.; // local sector coordinates (down/up) - int nwid=0; // CMS widget number (@@ not used now M.K.) - double phir= 0.; // phi for rotation to the sector system - if (nphi==0 || nphi==35) - { - yl=xv; - xl=yv; - nwid=6; - } - else if (nphi==17 || nphi==18) - { - yl=-xv; - xl=-yv; - nwid=15; - phir=CLHEP::pi; // nr=9 ? - } - else - { - int nr = (nphi+1)/2; // a sector # (@@ internal definition) - nwid = 6-nr; - if(nwid <= 0) nwid+=18; // @@ +z || -z M.K. to be improved - phir= sph*nr; // nontrivial phi for rotation to the sector system - double cosr= cos(phir); - double sinr= sin(phir); - yl= xv*cosr+yv*sinr; - xl= yv*cosr-xv*sinr; - LogDebug("HFShower") << "HFFibreFiducial: nr " << nr << " phi " - << phir/CLHEP::deg; +#define EDM_ML_DEBUG + +int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect) { + double xv = pe_effect.x(); // X in global system + double yv = pe_effect.y(); // Y in global system + double phi = atan2(yv, xv); // In global system + if (phi < 0.) + phi += CLHEP::pi; // Just for security + double dph = CLHEP::pi / 18; // 10 deg = a half sector width + double sph = dph + dph; // 20 deg = a sector width + int nphi = phi / dph; // 10 deg sector # +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial:***> P = " << pe_effect << ", phi = " << phi / CLHEP::deg; +#endif + if (nphi > 35) + nphi = 35; // Just for security + double xl = 0.; // local sector coordinates (left/right) + double yl = 0.; // local sector coordinates (down/up) + int nwid = 0; // CMS widget number (@@ not used now M.K.) + double phir = 0.; // phi for rotation to the sector system + if (nphi == 0 || nphi == 35) { + yl = xv; + xl = yv; + nwid = 6; + } else if (nphi == 17 || nphi == 18) { + yl = -xv; + xl = -yv; + nwid = 15; + phir = CLHEP::pi; // nr=9 ? + } else { + int nr = (nphi + 1) / 2; // a sector # (@@ internal definition) + nwid = 6 - nr; + if (nwid <= 0) + nwid += 18; // @@ +z || -z M.K. to be improved + phir = sph * nr; // nontrivial phi for rotation to the sector system + double cosr = cos(phir); + double sinr = sin(phir); + yl = xv * cosr + yv * sinr; + xl = yv * cosr - xv * sinr; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial: nr " << nr << " phi " << phir / CLHEP::deg; +#endif } - if (yl < 0) yl =-yl; - LogDebug("HFShower") << "HFFibreFiducial: Global Point " << pe_effect - << " nphi " << nphi - << " Local Sector Coordinates (" - << xl << ", " << yl << "), widget # " << nwid; + if (yl < 0) + yl = -yl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial: Global Point " << pe_effect << " nphi " << nphi + << " Local Sector Coordinates (" << xl << ", " << yl << "), widget # " << nwid; +#endif // Provides a PMT # for the (x,y) hit in the widget # nwid (M. Kosov, 11.2010) // Send comments/questions to Mikhail.Kossov@cern.ch // nwid = 1-18 for Forward HF, 19-36 for Backward HF (all equal now) // npmt = 0 for No Hit, 1-24 for H(Long) PMT, 25-48 for E(Short) PMT, negative for souces - static const int nWidM=36; - if (nwid > nWidM || nwid <= 0) { - LogDebug("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " - << nwid << " == wrong widget number"; + static const int nWidM = 36; + if (nwid > nWidM || nwid <= 0) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " << nwid << " == wrong widget number"; +#endif return 0; } - static const double yMin= 13.1*CLHEP::cm; // start of the active area (Conv to mm?) - static const double yMax=129.6*CLHEP::cm; // finish of the active area (Conv to mm?) - if( yl < yMin || yl >= yMax ) { - LogDebug("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " - << "Point with y = " << yl - << " outside acceptance [" << yMin << ":" - << yMax << "], X = " << xv << ", Y = " - << yv << ", x = " << xl << ", nW = " - << nwid << ", phi = " << phi/CLHEP::deg - << ", phir = " << phir/CLHEP::deg; - return 0; // ===> out of the acceptance + static const double yMin = 13.1 * CLHEP::cm; // start of the active area (Conv to mm?) + static const double yMax = 129.6 * CLHEP::cm; // finish of the active area (Conv to mm?) + if (yl < yMin || yl >= yMax) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " + << "Point with y = " << yl << " outside acceptance [" << yMin << ":" << yMax + << "], X = " << xv << ", Y = " << yv << ", x = " << xl << ", nW = " << nwid + << ", phi = " << phi / CLHEP::deg << ", phir = " << phir / CLHEP::deg; +#endif + return 0; // ===> out of the acceptance } - bool left=true; // flag of the left part of the widget - double r=xl/yl; // for the widget acceptance check - if (r < 0) - { - r=-r; - left=false; + bool left = true; // flag of the left part of the widget + double r = xl / yl; // for the widget acceptance check + if (r < 0) { + r = -r; + left = false; } - static const double tg10=.17632698070847; // phi-angular acceptance of the widget + static const double tg10 = .17632698070847; // phi-angular acceptance of the widget if (r > tg10) { - LogDebug("HFShower") <<"-Warning-HFFibreFiducial::PMTNumber: (x = " - << xl << ", y = " << yl << ", tg = " << r - << ") out of the widget acceptance tg(10) " - << tg10; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: (x = " << xl << ", y = " << yl + << ", tg = " << r << ") out of the widget acceptance tg(10) " << tg10; +#endif return 0; } - static const int nLay=233; // a # of the sensetive layers in the widget - static const int nL001=4; - static const int nL002=4; - static const int nL003=5; - static const int nL004=5; - static const int nL005=5; // (5) - static const int nL006=5; - static const int nL007=5; - static const int nL008=6; - static const int nL009=6; - static const int nL010=6; // (6) - static const int nL011=6; - static const int nL012=6; - static const int nL013=6; - static const int nL014=7; - static const int nL015=7; - static const int nL016=7; // (6) - static const int nL017=7; - static const int nL018=7; - static const int nL019=7; - static const int nL020=8; - static const int nL021=8; - static const int nL022=8; // (5) - static const int nL023=8; - static const int nL024=8; - static const int nL025=9; - static const int nL026=9; - static const int nL027=9; // (6) - static const int nL028=9; - static const int nL029=9; - static const int nL030=9; - static const int nL031=10; - static const int nL032=10; - static const int nL033=10; // (6) - static const int nL034=10; - static const int nL035=10; - static const int nL036=10; - static const int nL037=11; - static const int nL038=11; // (5) - static const int nL039=11; - static const int nL040=11; - static const int nL041=11; - static const int nL042=12; - static const int nL043=12; - static const int nL044=12; - static const int nL045=12; // (6) - static const int nL046=12; - static const int nL047=12; - static const int nL048=13; - static const int nL049=13; - static const int nL050=13; // (6) - static const int nL051=13; - static const int nL052=13; - static const int nL053=13; - static const int nL054=14; - static const int nL055=14; - static const int nL056=14; // (5) - static const int nL057=14; - static const int nL058=14; - static const int nL059=15; - static const int nL060=15; - static const int nL061=15; // (6) - static const int nL062=15; - static const int nL063=15; - static const int nL064=15; - static const int nL065=16; - static const int nL066=16; - static const int nL067=16; // (6) - static const int nL068=16; - static const int nL069=16; - static const int nL070=16; - static const int nL071=17; - static const int nL072=17; - static const int nL073=17; // (5) - static const int nL074=17; - static const int nL075=17; - static const int nL076=18; - static const int nL077=18; - static const int nL078=18; // (6) - static const int nL079=18; - static const int nL080=18; - static const int nL081=18; - static const int nL082=19; - static const int nL083=19; // (6) - static const int nL084=19; - static const int nL085=19; - static const int nL086=19; - static const int nL087=19; - static const int nL088=20; - static const int nL089=20; - static const int nL090=20; // (5) - static const int nL091=20; - static const int nL092=20; - static const int nL093=21; - static const int nL094=21; - static const int nL095=21; // (6) - static const int nL096=21; - static const int nL097=21; - static const int nL098=21; - static const int nL099=22; - static const int nL100=22; - static const int nL101=22; // (6) - static const int nL102=22; - static const int nL103=22; - static const int nL104=22; - static const int nL105=23; - static const int nL106=23; - static const int nL107=23; // (5) - static const int nL108=23; - static const int nL109=23; - static const int nL110=24; - static const int nL111=24; - static const int nL112=24; // (6) - static const int nL113=24; - static const int nL114=24; - static const int nL115=24; - static const int nL116=25; - static const int nL117=25; - static const int nL118=25; // (6) - static const int nL119=25; - static const int nL120=25; - static const int nL121=25; - static const int nL122=26; - static const int nL123=26; - static const int nL124=26; // (5) - static const int nL125=26; - static const int nL126=26; - static const int nL127=27; - static const int nL128=27; - static const int nL129=27; // (6) - static const int nL130=27; - static const int nL131=27; - static const int nL132=27; - static const int nL133=28; - static const int nL134=28; - static const int nL135=28; // (6) - static const int nL136=28; - static const int nL137=28; - static const int nL138=28; - static const int nL139=29; - static const int nL140=29; - static const int nL141=29; // (5) - static const int nL142=29; - static const int nL143=29; - static const int nL144=30; - static const int nL145=30; - static const int nL146=30; // (6) - static const int nL147=30; - static const int nL148=30; - static const int nL149=30; - static const int nL150=31; - static const int nL151=31; - static const int nL152=31; // (6) - static const int nL153=31; - static const int nL154=31; - static const int nL155=31; - static const int nL156=32; - static const int nL157=32; // (5) - static const int nL158=32; - static const int nL159=32; - static const int nL160=32; - static const int nL161=33; - static const int nL162=33; // (6) - static const int nL163=33; - static const int nL164=33; - static const int nL165=33; - static const int nL166=33; - static const int nL167=34; - static const int nL168=34; - static const int nL169=34; // (6) - static const int nL170=34; - static const int nL171=34; - static const int nL172=34; - static const int nL173=35; - static const int nL174=35; - static const int nL175=35; // (5) - static const int nL176=35; - static const int nL177=35; - static const int nL178=36; - static const int nL179=36; - static const int nL180=36; // (6) - static const int nL181=36; - static const int nL182=36; - static const int nL183=36; - static const int nL184=37; - static const int nL185=37; - static const int nL186=37; // (6) - static const int nL187=37; - static const int nL188=37; - static const int nL189=37; - static const int nL190=38; - static const int nL191=38; - static const int nL192=38; // (5) - static const int nL193=38; - static const int nL194=38; - static const int nL195=39; - static const int nL196=39; - static const int nL197=39; - static const int nL198=39; // (6) - static const int nL199=39; - static const int nL200=39; - static const int nL201=40; - static const int nL202=40; - static const int nL203=40; // (6) - static const int nL204=40; - static const int nL205=40; - static const int nL206=40; - static const int nL207=41; - static const int nL208=41; - static const int nL209=41; // (5) - static const int nL210=41; - static const int nL211=41; - static const int nL212=42; - static const int nL213=42; - static const int nL214=42; - static const int nL215=42; // (6) - static const int nL216=42; - static const int nL217=42; - static const int nL218=43; - static const int nL219=43; - static const int nL220=43; // (6) - static const int nL221=43; - static const int nL222=43; - static const int nL223=43; - static const int nL224=44; - static const int nL225=44; - static const int nL226=44; // (5) - static const int nL227=44; - static const int nL228=44; - static const int nL229=45; - static const int nL230=45; - static const int nL231=45; // (5+1=6) - static const int nL232=45; - static const int nL233=45; + static const int nLay = 233; // a # of the sensetive layers in the widget + static const int nL001 = 4; + static const int nL002 = 4; + static const int nL003 = 5; + static const int nL004 = 5; + static const int nL005 = 5; // (5) + static const int nL006 = 5; + static const int nL007 = 5; + static const int nL008 = 6; + static const int nL009 = 6; + static const int nL010 = 6; // (6) + static const int nL011 = 6; + static const int nL012 = 6; + static const int nL013 = 6; + static const int nL014 = 7; + static const int nL015 = 7; + static const int nL016 = 7; // (6) + static const int nL017 = 7; + static const int nL018 = 7; + static const int nL019 = 7; + static const int nL020 = 8; + static const int nL021 = 8; + static const int nL022 = 8; // (5) + static const int nL023 = 8; + static const int nL024 = 8; + static const int nL025 = 9; + static const int nL026 = 9; + static const int nL027 = 9; // (6) + static const int nL028 = 9; + static const int nL029 = 9; + static const int nL030 = 9; + static const int nL031 = 10; + static const int nL032 = 10; + static const int nL033 = 10; // (6) + static const int nL034 = 10; + static const int nL035 = 10; + static const int nL036 = 10; + static const int nL037 = 11; + static const int nL038 = 11; // (5) + static const int nL039 = 11; + static const int nL040 = 11; + static const int nL041 = 11; + static const int nL042 = 12; + static const int nL043 = 12; + static const int nL044 = 12; + static const int nL045 = 12; // (6) + static const int nL046 = 12; + static const int nL047 = 12; + static const int nL048 = 13; + static const int nL049 = 13; + static const int nL050 = 13; // (6) + static const int nL051 = 13; + static const int nL052 = 13; + static const int nL053 = 13; + static const int nL054 = 14; + static const int nL055 = 14; + static const int nL056 = 14; // (5) + static const int nL057 = 14; + static const int nL058 = 14; + static const int nL059 = 15; + static const int nL060 = 15; + static const int nL061 = 15; // (6) + static const int nL062 = 15; + static const int nL063 = 15; + static const int nL064 = 15; + static const int nL065 = 16; + static const int nL066 = 16; + static const int nL067 = 16; // (6) + static const int nL068 = 16; + static const int nL069 = 16; + static const int nL070 = 16; + static const int nL071 = 17; + static const int nL072 = 17; + static const int nL073 = 17; // (5) + static const int nL074 = 17; + static const int nL075 = 17; + static const int nL076 = 18; + static const int nL077 = 18; + static const int nL078 = 18; // (6) + static const int nL079 = 18; + static const int nL080 = 18; + static const int nL081 = 18; + static const int nL082 = 19; + static const int nL083 = 19; // (6) + static const int nL084 = 19; + static const int nL085 = 19; + static const int nL086 = 19; + static const int nL087 = 19; + static const int nL088 = 20; + static const int nL089 = 20; + static const int nL090 = 20; // (5) + static const int nL091 = 20; + static const int nL092 = 20; + static const int nL093 = 21; + static const int nL094 = 21; + static const int nL095 = 21; // (6) + static const int nL096 = 21; + static const int nL097 = 21; + static const int nL098 = 21; + static const int nL099 = 22; + static const int nL100 = 22; + static const int nL101 = 22; // (6) + static const int nL102 = 22; + static const int nL103 = 22; + static const int nL104 = 22; + static const int nL105 = 23; + static const int nL106 = 23; + static const int nL107 = 23; // (5) + static const int nL108 = 23; + static const int nL109 = 23; + static const int nL110 = 24; + static const int nL111 = 24; + static const int nL112 = 24; // (6) + static const int nL113 = 24; + static const int nL114 = 24; + static const int nL115 = 24; + static const int nL116 = 25; + static const int nL117 = 25; + static const int nL118 = 25; // (6) + static const int nL119 = 25; + static const int nL120 = 25; + static const int nL121 = 25; + static const int nL122 = 26; + static const int nL123 = 26; + static const int nL124 = 26; // (5) + static const int nL125 = 26; + static const int nL126 = 26; + static const int nL127 = 27; + static const int nL128 = 27; + static const int nL129 = 27; // (6) + static const int nL130 = 27; + static const int nL131 = 27; + static const int nL132 = 27; + static const int nL133 = 28; + static const int nL134 = 28; + static const int nL135 = 28; // (6) + static const int nL136 = 28; + static const int nL137 = 28; + static const int nL138 = 28; + static const int nL139 = 29; + static const int nL140 = 29; + static const int nL141 = 29; // (5) + static const int nL142 = 29; + static const int nL143 = 29; + static const int nL144 = 30; + static const int nL145 = 30; + static const int nL146 = 30; // (6) + static const int nL147 = 30; + static const int nL148 = 30; + static const int nL149 = 30; + static const int nL150 = 31; + static const int nL151 = 31; + static const int nL152 = 31; // (6) + static const int nL153 = 31; + static const int nL154 = 31; + static const int nL155 = 31; + static const int nL156 = 32; + static const int nL157 = 32; // (5) + static const int nL158 = 32; + static const int nL159 = 32; + static const int nL160 = 32; + static const int nL161 = 33; + static const int nL162 = 33; // (6) + static const int nL163 = 33; + static const int nL164 = 33; + static const int nL165 = 33; + static const int nL166 = 33; + static const int nL167 = 34; + static const int nL168 = 34; + static const int nL169 = 34; // (6) + static const int nL170 = 34; + static const int nL171 = 34; + static const int nL172 = 34; + static const int nL173 = 35; + static const int nL174 = 35; + static const int nL175 = 35; // (5) + static const int nL176 = 35; + static const int nL177 = 35; + static const int nL178 = 36; + static const int nL179 = 36; + static const int nL180 = 36; // (6) + static const int nL181 = 36; + static const int nL182 = 36; + static const int nL183 = 36; + static const int nL184 = 37; + static const int nL185 = 37; + static const int nL186 = 37; // (6) + static const int nL187 = 37; + static const int nL188 = 37; + static const int nL189 = 37; + static const int nL190 = 38; + static const int nL191 = 38; + static const int nL192 = 38; // (5) + static const int nL193 = 38; + static const int nL194 = 38; + static const int nL195 = 39; + static const int nL196 = 39; + static const int nL197 = 39; + static const int nL198 = 39; // (6) + static const int nL199 = 39; + static const int nL200 = 39; + static const int nL201 = 40; + static const int nL202 = 40; + static const int nL203 = 40; // (6) + static const int nL204 = 40; + static const int nL205 = 40; + static const int nL206 = 40; + static const int nL207 = 41; + static const int nL208 = 41; + static const int nL209 = 41; // (5) + static const int nL210 = 41; + static const int nL211 = 41; + static const int nL212 = 42; + static const int nL213 = 42; + static const int nL214 = 42; + static const int nL215 = 42; // (6) + static const int nL216 = 42; + static const int nL217 = 42; + static const int nL218 = 43; + static const int nL219 = 43; + static const int nL220 = 43; // (6) + static const int nL221 = 43; + static const int nL222 = 43; + static const int nL223 = 43; + static const int nL224 = 44; + static const int nL225 = 44; + static const int nL226 = 44; // (5) + static const int nL227 = 44; + static const int nL228 = 44; + static const int nL229 = 45; + static const int nL230 = 45; + static const int nL231 = 45; // (5+1=6) + static const int nL232 = 45; + static const int nL233 = 45; //------------------------------------------------------------------------------------ // Mean numbers of fibers in the layer is used. In some widgets it's bigger *** // (if the fiber passed throug the hole closer to the edge) and sometimes it *** @@ -335,1126 +336,924 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect) // to be individual for widgets and the FXX/BXX sources-tables can be used. *** // ********************** M.Kosov, Mikhail.Kosssov@cern.ch ********************* // NNI, NN=tower#(1-24), i=0: dead; i=1: E(L); i=2: H(S); i=3: ESource; i=4: HSource - static const int tR001[nL001]={132,131,132,131}; // Left Part of the widget (-phi) - static const int tR002[nL002]={131,132,131,132}; - static const int tR003[nL003]={132,131,132,131,132}; - static const int tR004[nL004]={133,132,131,132,131}; // (5) - static const int tR005[nL005]={132,131,132,131,132}; - static const int tR006[nL006]={131,132,131,132,131}; - static const int tR007[nL007]={132,131,132,131,132}; - static const int tR008[nL008]={131,132,131,132,131,132}; // _______________________13_ - static const int tR009[nL009]={122,121,122,121,122,121}; - static const int tR010[nL010]={121,122,121,122,123,122}; // (6) (A) - static const int tR011[nL011]={122,121,122,121,122,121}; - static const int tR012[nL012]={121,122,121,122,121,122}; - static const int tR013[nL013]={122,121,122,121,122,121}; - static const int tR014[nL014]={121,122,121,122,121,122,121}; //____________________12_ - static const int tR015[nL015]={122,121,242,241,242,241,242}; // (6) - static const int tR016[nL016]={241,242,241,242,241,242,241}; - static const int tR017[nL017]={242,241,242,241,242,241,242}; - static const int tR018[nL018]={241,242,241,242,243,242,241}; - static const int tR019[nL019]={242,241,242,241,242,241,242}; - static const int tR020[nL020]={241,242,241,242,241,242,241,242}; - static const int tR021[nL021]={242,241,242,241,242,241,242,241}; // (5) - static const int tR022[nL022]={241,242,241,242,241,242,241,242}; //________________24_ - static const int tR023[nL023]={232,231,232,231,232,231,232,231}; - static const int tR024[nL024]={231,232,231,232,231,232,231,232}; - static const int tR025[nL025]={232,231,232,231,232,231,232,231,232}; - static const int tR026[nL026]={231,232,231,232,233,232,231,232,231}; - static const int tR027[nL027]={232,231,232,231,232,231,232,231,232}; // (6) - static const int tR028[nL028]={231,232,231,232,231,232,231,232,231}; - static const int tR029[nL029]={232,231,232,231,232,231,232,231,232}; - static const int tR030[nL030]={231,232,231,232,231,232,231,232,231}; - static const int tR031[nL031]={232,231,232,231,232,231,232,231,232,231}; //________23_ - static const int tR032[nL032]={231,232,231,222,221,222,221,222,221,222}; - static const int tR033[nL033]={222,221,222,221,222,221,222,221,222,221}; // (6) - static const int tR034[nL034]={221,222,221,222,221,222,221,222,221,222}; - static const int tR035[nL035]={222,221,222,221,222,221,222,221,222,221}; - static const int tR036[nL036]={221,222,221,222,223,222,221,222,221,222}; - static const int tR037[nL037]={222,221,222,221,222,221,222,221,222,221,222}; - static const int tR038[nL038]={221,222,221,222,221,222,221,222,221,222,221}; - static const int tR039[nL039]={222,221,222,221,222,221,222,221,222,221,222}; // (5) - static const int tR040[nL040]={221,222,221,222,221,222,221,222,221,222,221};//_____22_ - static const int tR041[nL041]={212,211,212,211,212,211,212,211,212,211,212}; - static const int tR042[nL042]={211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR043[nL043]={212,211,212,211,212,211,212,211,212,211,212,211}; - static const int tR044[nL044]={211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR045[nL045]={212,211,212,211,212,211,212,211,212,211,212,211};//(6) - static const int tR046[nL046]={211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR047[nL047]={212,211,212,211,212,211,212,211,212,211,212,211}; - static const int tR048[nL048]={211,212,211,212,211,212,211,214,211,212,211,212,211}; - static const int tR049[nL049]={212,211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR050[nL050]={211,212,211,212,211,212,211,212,211,212,211,212,211}; - static const int tR051[nL051]={212,211,212,211,212,211,212,211,212,211,212,211,212};//(6) - static const int tR052[nL052]={211,212,211,212,211,212,211,212,211,212,211,212,211}; - static const int tR053[nL053]={212,211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR054[nL054]={211,212,211,212,211,212,211,212,211,212,211,212,211,212}; - static const int tR055[nL055]={212,211,212,211,212,211,212,211,212,211,212,211,212,211}; + static const int tR001[nL001] = {132, 131, 132, 131}; // Left Part of the widget (-phi) + static const int tR002[nL002] = {131, 132, 131, 132}; + static const int tR003[nL003] = {132, 131, 132, 131, 132}; + static const int tR004[nL004] = {133, 132, 131, 132, 131}; // (5) + static const int tR005[nL005] = {132, 131, 132, 131, 132}; + static const int tR006[nL006] = {131, 132, 131, 132, 131}; + static const int tR007[nL007] = {132, 131, 132, 131, 132}; + static const int tR008[nL008] = {131, 132, 131, 132, 131, 132}; // _______________________13_ + static const int tR009[nL009] = {122, 121, 122, 121, 122, 121}; + static const int tR010[nL010] = {121, 122, 121, 122, 123, 122}; // (6) (A) + static const int tR011[nL011] = {122, 121, 122, 121, 122, 121}; + static const int tR012[nL012] = {121, 122, 121, 122, 121, 122}; + static const int tR013[nL013] = {122, 121, 122, 121, 122, 121}; + static const int tR014[nL014] = {121, 122, 121, 122, 121, 122, 121}; //____________________12_ + static const int tR015[nL015] = {122, 121, 242, 241, 242, 241, 242}; // (6) + static const int tR016[nL016] = {241, 242, 241, 242, 241, 242, 241}; + static const int tR017[nL017] = {242, 241, 242, 241, 242, 241, 242}; + static const int tR018[nL018] = {241, 242, 241, 242, 243, 242, 241}; + static const int tR019[nL019] = {242, 241, 242, 241, 242, 241, 242}; + static const int tR020[nL020] = {241, 242, 241, 242, 241, 242, 241, 242}; + static const int tR021[nL021] = {242, 241, 242, 241, 242, 241, 242, 241}; // (5) + static const int tR022[nL022] = {241, 242, 241, 242, 241, 242, 241, 242}; //________________24_ + static const int tR023[nL023] = {232, 231, 232, 231, 232, 231, 232, 231}; + static const int tR024[nL024] = {231, 232, 231, 232, 231, 232, 231, 232}; + static const int tR025[nL025] = {232, 231, 232, 231, 232, 231, 232, 231, 232}; + static const int tR026[nL026] = {231, 232, 231, 232, 233, 232, 231, 232, 231}; + static const int tR027[nL027] = {232, 231, 232, 231, 232, 231, 232, 231, 232}; // (6) + static const int tR028[nL028] = {231, 232, 231, 232, 231, 232, 231, 232, 231}; + static const int tR029[nL029] = {232, 231, 232, 231, 232, 231, 232, 231, 232}; + static const int tR030[nL030] = {231, 232, 231, 232, 231, 232, 231, 232, 231}; + static const int tR031[nL031] = {232, 231, 232, 231, 232, 231, 232, 231, 232, 231}; //________23_ + static const int tR032[nL032] = {231, 232, 231, 222, 221, 222, 221, 222, 221, 222}; + static const int tR033[nL033] = {222, 221, 222, 221, 222, 221, 222, 221, 222, 221}; // (6) + static const int tR034[nL034] = {221, 222, 221, 222, 221, 222, 221, 222, 221, 222}; + static const int tR035[nL035] = {222, 221, 222, 221, 222, 221, 222, 221, 222, 221}; + static const int tR036[nL036] = {221, 222, 221, 222, 223, 222, 221, 222, 221, 222}; + static const int tR037[nL037] = {222, 221, 222, 221, 222, 221, 222, 221, 222, 221, 222}; + static const int tR038[nL038] = {221, 222, 221, 222, 221, 222, 221, 222, 221, 222, 221}; + static const int tR039[nL039] = {222, 221, 222, 221, 222, 221, 222, 221, 222, 221, 222}; // (5) + static const int tR040[nL040] = {221, 222, 221, 222, 221, 222, 221, 222, 221, 222, 221}; //_____22_ + static const int tR041[nL041] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR042[nL042] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR043[nL043] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; + static const int tR044[nL044] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR045[nL045] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; //(6) + static const int tR046[nL046] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR047[nL047] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; + static const int tR048[nL048] = {211, 212, 211, 212, 211, 212, 211, 214, 211, 212, 211, 212, 211}; + static const int tR049[nL049] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR050[nL050] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; + static const int tR051[nL051] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; //(6) + static const int tR052[nL052] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; + static const int tR053[nL053] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR054[nL054] = {211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212}; + static const int tR055[nL055] = {212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211, 212, 211}; // _______________________________________________________________________________21_ (5) - static const int tR056[nL056]={211,212,211,202,201,202,201,202,201,202,201,202,201,202}; - static const int tR057[nL057]={202,201,202,201,202,201,202,201,202,201,202,201,202,201}; - static const int tR058[nL058]={201,202,201,202,201,202,201,202,201,202,201,202,201,202}; - static const int tR059[nL059]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202}; - static const int tR060[nL060]={201,202,201,202,201,202,201,202,201,202,201,202,201,202, - 201}; - static const int tR061[nL061]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202}; // (6) - static const int tR062[nL062]={201,202,201,202,201,202,201,204,201,202,201,202,201,202, - 201}; - static const int tR063[nL063]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202}; - static const int tR064[nL064]={201,202,201,202,201,202,201,202,201,202,201,202,201,202, - 201}; - static const int tR065[nL065]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202,201}; - static const int tR066[nL066]={201,202,201,202,201,202,201,202,201,202,201,202,201,202, - 201,202}; // (6) - static const int tR067[nL067]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202,201}; - static const int tR068[nL068]={201,202,201,202,201,202,201,202,201,202,201,202,201,202, - 201,202}; - static const int tR069[nL069]={202,201,202,201,202,201,202,201,202,201,202,201,202,201, - 202,201}; - static const int tR070[nL070]={201,202,201,202,201,202,201,202,201,202,201,202,201,202, - 201,202}; - static const int tR071[nL071]={202,201,202,201,202,201,202,201,202,201,192,191,192,191, - 192,191,192}; // ___________________________________20_ - static const int tR072[nL072]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191}; - static const int tR073[nL073]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192}; // (5) - static const int tR074[nL074]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191}; - static const int tR075[nL075]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192}; - static const int tR076[nL076]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191,192}; - static const int tR077[nL077]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191}; - static const int tR078[nL078]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191,192}; // (6) - static const int tR079[nL079]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191}; - static const int tR080[nL080]={191,192,191,192,191,192,191,194,191,192,191,192,191,192, - 191,192,191,192}; - static const int tR081[nL081]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191}; - static const int tR082[nL082]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191,192,191}; - static const int tR083[nL083]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191,192}; - static const int tR084[nL084]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191,192,191}; // (6) - static const int tR085[nL085]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191,192}; - static const int tR086[nL086]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,191,192,191}; - static const int tR087[nL087]={192,191,192,191,192,191,192,191,192,191,192,191,192,191, - 192,191,192,191,192}; - static const int tR088[nL088]={191,192,191,192,191,192,191,192,191,192,191,192,191,192, - 191,192,181,182,181,182}; // _______________________19_ + static const int tR056[nL056] = {211, 212, 211, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR057[nL057] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR058[nL058] = {201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR059[nL059] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR060[nL060] = {201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR061[nL061] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; // (6) + static const int tR062[nL062] = {201, 202, 201, 202, 201, 202, 201, 204, 201, 202, 201, 202, 201, 202, 201}; + static const int tR063[nL063] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR064[nL064] = {201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR065[nL065] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR066[nL066] = { + 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; // (6) + static const int tR067[nL067] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR068[nL068] = {201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR069[nL069] = {202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201}; + static const int tR070[nL070] = {201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202, 201, 202}; + static const int tR071[nL071] = {202, + 201, + 202, + 201, + 202, + 201, + 202, + 201, + 202, + 201, + 192, + 191, + 192, + 191, + 192, + 191, + 192}; // ___________________________________20_ + static const int tR072[nL072] = {191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR073[nL073] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; // (5) + static const int tR074[nL074] = {191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR075[nL075] = {192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR076[nL076] = { + 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR077[nL077] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR078[nL078] = { + 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; // (6) + static const int tR079[nL079] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR080[nL080] = { + 191, 192, 191, 192, 191, 192, 191, 194, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR081[nL081] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR082[nL082] = { + 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR083[nL083] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR084[nL084] = { + 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; // (6) + static const int tR085[nL085] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR086[nL086] = { + 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191}; + static const int tR087[nL087] = { + 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192, 191, 192}; + static const int tR088[nL088] = {191, 192, 191, 192, 191, 192, 191, 192, 191, 192, + 191, 192, 191, 192, 191, 192, 181, 182, 181, 182}; // _______________________19_ // ------------------------------------------------------------------------------------ - static const int tR089[nL089]={192,191,192,191,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181}; // (5) - static const int tR090[nL090]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182}; - static const int tR091[nL091]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181}; - static const int tR092[nL092]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182}; - static const int tR093[nL093]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182}; - static const int tR094[nL094]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181}; - static const int tR095[nL095]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182}; // (6) - static const int tR096[nL096]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181}; - static const int tR097[nL097]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182}; - static const int tR098[nL098]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181}; - static const int tR099[nL099]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181}; - static const int tR100[nL100]={181,182,181,182,181,182,181,182,181,182,181,182,183,182, - 181,182,181,182,181,182,181,182}; // (6) - static const int tR101[nL101]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181}; - static const int tR102[nL102]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181,182}; - static const int tR103[nL103]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181}; - static const int tR104[nL104]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181,182}; - static const int tR105[nL105]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181,182}; - static const int tR106[nL106]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181,182,181}; - static const int tR107[nL107]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181,182}; // (5) - static const int tR108[nL108]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181,182,181}; - static const int tR109[nL109]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,181,182,181,182,181,182}; - static const int tR110[nL110]={181,182,181,182,181,182,181,182,181,182,181,182,181,182, - 181,182,181,182,181,182,181,182,181,182}; - static const int tR111[nL111]={182,181,182,181,182,181,182,181,182,181,182,181,182,181, - 182,181,182,171,172,171,172,171,172,171}; // _________4_ - static const int tR112[nL112]={181,182,181,182,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172}; // (6) - static const int tR113[nL113]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171}; - static const int tR114[nL114]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172}; - static const int tR115[nL115]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171}; - static const int tR116[nL116]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171}; - static const int tR117[nL117]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172}; - static const int tR118[nL118]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171}; - static const int tR119[nL119]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172}; // (6) - static const int tR120[nL120]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171}; - static const int tR121[nL121]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172}; - static const int tR122[nL122]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR123[nL123]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR124[nL124]={171,172,171,172,171,172,171,172,171,172,171,172,173,172, - 171,172,171,172,171,172,171,172,171,172,171,172};// (5) - static const int tR125[nL125]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR126[nL126]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR127[nL127]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR128[nL128]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR129[nL129]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR130[nL130]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172,171};//(6) - static const int tR131[nL131]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR132[nL132]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR133[nL133]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR134[nL134]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR135[nL135]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,172,171,172,171,172,171}; - static const int tR136[nL136]={171,172,171,172,171,172,171,172,171,172,171,172,171,172, - 171,172,171,172,171,172,171,172,171,172,171,172,171,172}; - static const int tR137[nL137]={172,171,172,171,172,171,172,171,172,171,172,171,172,171, - 172,171,172,171,172,171,172,171,162,161,162,161,162,161}; + static const int tR089[nL089] = {192, 191, 192, 191, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; // (5) + static const int tR090[nL090] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR091[nL091] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR092[nL092] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR093[nL093] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR094[nL094] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR095[nL095] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; // (6) + static const int tR096[nL096] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR097[nL097] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR098[nL098] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR099[nL099] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR100[nL100] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 183, 182, 181, 182, 181, 182, 181, 182, 181, 182}; // (6) + static const int tR101[nL101] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR102[nL102] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR103[nL103] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR104[nL104] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR105[nL105] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR106[nL106] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR107[nL107] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; // (5) + static const int tR108[nL108] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181}; + static const int tR109[nL109] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR110[nL110] = {181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, + 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182}; + static const int tR111[nL111] = {182, 181, 182, 181, 182, 181, 182, 181, 182, 181, 182, 181, + 182, 181, 182, 181, 182, 171, 172, 171, 172, 171, 172, 171}; // _________4_ + static const int tR112[nL112] = {181, 182, 181, 182, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; // (6) + static const int tR113[nL113] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR114[nL114] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR115[nL115] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR116[nL116] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR117[nL117] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR118[nL118] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR119[nL119] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; // (6) + static const int tR120[nL120] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR121[nL121] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR122[nL122] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR123[nL123] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR124[nL124] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 173, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; // (5) + static const int tR125[nL125] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR126[nL126] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR127[nL127] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR128[nL128] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR129[nL129] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR130[nL130] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; //(6) + static const int tR131[nL131] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR132[nL132] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR133[nL133] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR134[nL134] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR135[nL135] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171}; + static const int tR136[nL136] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, + 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172}; + static const int tR137[nL137] = {172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, + 172, 171, 172, 171, 172, 171, 172, 171, 162, 161, 162, 161, 162, 161}; // ____________________________________________________________________________(6)___3_ - static const int tR138[nL138]={171,172,171,172,171,172,171,172,171,172,171,172,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162}; - static const int tR139[nL139]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162}; - static const int tR140[nL140]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161}; - static const int tR141[nL141]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162}; // (5) - static const int tR142[nL142]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161}; - static const int tR143[nL143]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162}; - static const int tR144[nL144]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162}; - static const int tR145[nL145]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161}; - static const int tR146[nL146]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,163,162,161,162,161,162,161,162,161,162,161,162, - 161,162}; - static const int tR147[nL147]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161}; // (6) - static const int tR148[nL148]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162}; - static const int tR149[nL149]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161}; - static const int tR150[nL150]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161}; - static const int tR151[nL151]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162}; - static const int tR152[nL152]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161}; // (6) - static const int tR153[nL153]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162}; - static const int tR154[nL154]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161}; - static const int tR155[nL155]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162}; - static const int tR156[nL156]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162}; - static const int tR157[nL157]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161}; - static const int tR158[nL158]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162}; // (5) - static const int tR159[nL159]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161}; - static const int tR160[nL160]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,163,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162}; - static const int tR161[nL161]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162}; - static const int tR162[nL162]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161}; - static const int tR163[nL163]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162}; // (6) - static const int tR164[nL164]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161}; - static const int tR165[nL165]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162}; - static const int tR166[nL166]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161}; - static const int tR167[nL167]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,162,161}; - static const int tR168[nL168]={161,162,161,162,161,162,161,162,161,162,161,162,161,162, - 161,162,161,162,161,162,161,162,161,162,161,162,161,152, - 151,152,151,152,151,152}; // _________________________2_ - static const int tR169[nL169]={162,161,162,161,162,161,162,161,162,161,162,161,162,161, - 162,161,162,161,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151}; // (6) - static const int tR170[nL170]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152}; - static const int tR171[nL171]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151}; - static const int tR172[nL172]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152}; - static const int tR173[nL173]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152}; - static const int tR174[nL174]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151}; - static const int tR175[nL175]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152}; // (5) - static const int tR176[nL176]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151}; - static const int tR177[nL177]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152}; - static const int tR178[nL178]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,153,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152}; - static const int tR179[nL179]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151}; - static const int tR180[nL180]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152}; // (6) - static const int tR181[nL181]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151}; - static const int tR182[nL182]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152}; - static const int tR183[nL183]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151}; - static const int tR184[nL184]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151}; - static const int tR185[nL185]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152}; - static const int tR186[nL186]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151}; - static const int tR187[nL187]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152}; // (6) - static const int tR188[nL188]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151}; - static const int tR189[nL189]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152}; - static const int tR190[nL190]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152}; - static const int tR191[nL191]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151}; - static const int tR192[nL192]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152}; // (5) - static const int tR193[nL193]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151}; - static const int tR194[nL194]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152}; - static const int tR195[nL195]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152}; - static const int tR196[nL196]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,153,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151}; - static const int tR197[nL197]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152}; // (6) - static const int tR198[nL198]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151}; - static const int tR199[nL199]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152}; - static const int tR200[nL200]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151}; - static const int tR201[nL201]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151}; - static const int tR202[nL202]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152}; - static const int tR203[nL203]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151}; //(6) - static const int tR204[nL204]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,151,152}; - static const int tR205[nL205]={152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,152,151,152,151,152,151,152,151,152,151, - 152,151,152,151,142,141,142,141,142,141,142,141}; - static const int tR206[nL206]={151,152,151,152,151,152,151,152,151,152,151,152,151,152, - 151,152,151,152,151,152,151,152,151,152,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142};//__1_ - static const int tR207[nL207]={152,151,152,151,152,151,152,151,152,151,152,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142}; - static const int tR208[nL208]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141}; - static const int tR209[nL209]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142};//(5) - static const int tR210[nL210]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141}; - static const int tR211[nL211]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142}; - static const int tR212[nL212]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,143,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142}; - static const int tR213[nL213]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141}; - static const int tR214[nL214]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142}; - static const int tR215[nL215]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141}; - static const int tR216[nL216]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142}; - static const int tR217[nL217]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141}; - static const int tR218[nL218]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141}; - static const int tR219[nL219]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142}; - static const int tR220[nL220]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141}; - static const int tR221[nL221]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142}; // (6) - static const int tR222[nL222]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141}; - static const int tR223[nL223]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142}; - static const int tR224[nL224]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142}; - static const int tR225[nL225]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141}; - static const int tR226[nL226]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,143,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142}; // (5) - static const int tR227[nL227]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141}; - static const int tR228[nL228]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142}; - static const int tR229[nL229]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142}; - static const int tR230[nL230]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141}; - static const int tR231[nL231]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141,142,141,142, 0, 0, 0, - 0, 0, 0}; // (5+1=6) - static const int tR232[nL232]={141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142,141,142,141,142,141,142,141,142,141,142, - 141,142,141,142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; - static const int tR233[nL233]={142,141,142,141,142,141,142,141,142,141,142,141,142,141, - 142,141,142,141,142,141,142,141, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; + static const int tR138[nL138] = {171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 171, 172, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR139[nL139] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR140[nL140] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR141[nL141] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; // (5) + static const int tR142[nL142] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR143[nL143] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR144[nL144] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR145[nL145] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR146[nL146] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 163, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR147[nL147] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; // (6) + static const int tR148[nL148] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR149[nL149] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR150[nL150] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR151[nL151] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR152[nL152] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; // (6) + static const int tR153[nL153] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR154[nL154] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR155[nL155] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR156[nL156] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR157[nL157] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR158[nL158] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; // (5) + static const int tR159[nL159] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR160[nL160] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 163, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR161[nL161] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR162[nL162] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR163[nL163] = { + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; // (6) + static const int tR164[nL164] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR165[nL165] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162}; + static const int tR166[nL166] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR167[nL167] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161}; + static const int tR168[nL168] = {161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, + 161, 162, 161, 152, 151, 152, 151, 152, 151, 152}; // _________________________2_ + static const int tR169[nL169] = {162, 161, 162, 161, 162, 161, 162, 161, 162, 161, 162, 161, + 162, 161, 162, 161, 162, 161, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; // (6) + static const int tR170[nL170] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR171[nL171] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR172[nL172] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR173[nL173] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR174[nL174] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR175[nL175] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; // (5) + static const int tR176[nL176] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR177[nL177] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR178[nL178] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 153, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR179[nL179] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR180[nL180] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; // (6) + static const int tR181[nL181] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR182[nL182] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR183[nL183] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR184[nL184] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR185[nL185] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR186[nL186] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR187[nL187] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; // (6) + static const int tR188[nL188] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR189[nL189] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR190[nL190] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR191[nL191] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR192[nL192] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; // (5) + static const int tR193[nL193] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR194[nL194] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR195[nL195] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR196[nL196] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 153, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR197[nL197] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; // (6) + static const int tR198[nL198] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR199[nL199] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR200[nL200] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR201[nL201] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; + static const int tR202[nL202] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR203[nL203] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151}; //(6) + static const int tR204[nL204] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152}; + static const int tR205[nL205] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, + 152, 151, 152, 151, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR206[nL206] = {151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, + 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; //__1_ + static const int tR207[nL207] = {152, 151, 152, 151, 152, 151, 152, 151, 152, 151, 152, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR208[nL208] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR209[nL209] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; //(5) + static const int tR210[nL210] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR211[nL211] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR212[nL212] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 143, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR213[nL213] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR214[nL214] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR215[nL215] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR216[nL216] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR217[nL217] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR218[nL218] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR219[nL219] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR220[nL220] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR221[nL221] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; // (6) + static const int tR222[nL222] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR223[nL223] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR224[nL224] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR225[nL225] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR226[nL226] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 143, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; // (5) + static const int tR227[nL227] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR228[nL228] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR229[nL229] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142}; + static const int tR230[nL230] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141}; + static const int tR231[nL231] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 0, 0, 0, 0, 0, 0}; // (5+1=6) + static const int tR232[nL232] = {141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, + 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + static const int tR233[nL233] = {142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, 141, 142, + 141, 142, 141, 142, 141, 142, 141, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------ - static const int tL001[nL001]={131,132,131,132}; // Left Part of the widget (-phi) - static const int tL002[nL002]={132,131,132,131}; - static const int tL003[nL003]={131,132,131,132,131}; - static const int tL004[nL004]={132,131,132,131,132}; // (5) - static const int tL005[nL005]={131,132,131,132,131}; - static const int tL006[nL006]={132,131,132,131,132}; - static const int tL007[nL007]={131,132,131,132,131}; - static const int tL008[nL008]={132,131,132,131,132,131}; // ______________________13_ - static const int tL009[nL009]={121,122,121,122,121,122}; - static const int tL010[nL010]={122,121,122,121,124,121}; - static const int tL011[nL011]={121,122,121,122,121,122}; // (6) (B) - static const int tL012[nL012]={122,121,122,121,122,121}; - static const int tL013[nL013]={121,122,121,122,121,122}; - static const int tL014[nL014]={122,121,122,121,122,121,122}; //___________________12_ - static const int tL015[nL015]={121,122,111,112,111,112,111}; - static const int tL016[nL016]={112,111,112,111,112,111,112}; - static const int tL017[nL017]={111,112,111,112,111,112,111}; // (6) - static const int tL018[nL018]={112,111,112,111,114,111,112}; - static const int tL019[nL019]={111,112,111,112,111,112,111}; - static const int tL020[nL020]={112,111,112,111,112,111,112,111}; - static const int tL021[nL021]={111,112,111,112,111,112,111,112}; // (5) - static const int tL022[nL022]={112,111,112,111,112,111,112,111}; //_______________11_ - static const int tL023[nL023]={101,102,101,102,101,102,101,102}; - static const int tL024[nL024]={102,101,102,101,102,101,102,101}; - static const int tL025[nL025]={101,102,101,102,101,102,101,102,101}; - static const int tL026[nL026]={102,101,102,101,104,101,102,101,102}; - static const int tL027[nL027]={101,102,101,102,101,102,101,102,101}; // (6) - static const int tL028[nL028]={102,101,102,101,102,101,102,101,102}; - static const int tL029[nL029]={101,102,101,102,101,102,101,102,101}; - static const int tL030[nL030]={102,101,102,101,102,101,102,101,102}; - static const int tL031[nL031]={101,102,101,102,101,102,101,102,101,102}; //_______10_ - static const int tL032[nL032]={102,101,102, 91, 92, 91, 92, 91, 92, 91}; - static const int tL033[nL033]={ 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; // (6) - static const int tL034[nL034]={ 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; - static const int tL035[nL035]={ 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; - static const int tL036[nL036]={ 92, 91, 92, 91, 94, 91, 92, 91, 92, 91}; - static const int tL037[nL037]={ 91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; - static const int tL038[nL038]={ 92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; - static const int tL039[nL039]={ 91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; // (5) - static const int tL040[nL040]={ 92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; - static const int tL041[nL041]={ 91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; - static const int tL042[nL042]={ 92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91};//_9_ - static const int tL043[nL043]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; - static const int tL044[nL044]={ 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL045[nL045]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82};//(6) - static const int tL046[nL046]={ 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL047[nL047]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; - static const int tL048[nL048]={ 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; - static const int tL049[nL049]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL050[nL050]={ 82, 81, 82, 81, 82, 81, 82, 81, 84, 81, 82, 81, 82};//(6) - static const int tL051[nL051]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL052[nL052]={ 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; - static const int tL053[nL053]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL054[nL054]={ 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; - static const int tL055[nL055]={ 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; + static const int tL001[nL001] = {131, 132, 131, 132}; // Left Part of the widget (-phi) + static const int tL002[nL002] = {132, 131, 132, 131}; + static const int tL003[nL003] = {131, 132, 131, 132, 131}; + static const int tL004[nL004] = {132, 131, 132, 131, 132}; // (5) + static const int tL005[nL005] = {131, 132, 131, 132, 131}; + static const int tL006[nL006] = {132, 131, 132, 131, 132}; + static const int tL007[nL007] = {131, 132, 131, 132, 131}; + static const int tL008[nL008] = {132, 131, 132, 131, 132, 131}; // ______________________13_ + static const int tL009[nL009] = {121, 122, 121, 122, 121, 122}; + static const int tL010[nL010] = {122, 121, 122, 121, 124, 121}; + static const int tL011[nL011] = {121, 122, 121, 122, 121, 122}; // (6) (B) + static const int tL012[nL012] = {122, 121, 122, 121, 122, 121}; + static const int tL013[nL013] = {121, 122, 121, 122, 121, 122}; + static const int tL014[nL014] = {122, 121, 122, 121, 122, 121, 122}; //___________________12_ + static const int tL015[nL015] = {121, 122, 111, 112, 111, 112, 111}; + static const int tL016[nL016] = {112, 111, 112, 111, 112, 111, 112}; + static const int tL017[nL017] = {111, 112, 111, 112, 111, 112, 111}; // (6) + static const int tL018[nL018] = {112, 111, 112, 111, 114, 111, 112}; + static const int tL019[nL019] = {111, 112, 111, 112, 111, 112, 111}; + static const int tL020[nL020] = {112, 111, 112, 111, 112, 111, 112, 111}; + static const int tL021[nL021] = {111, 112, 111, 112, 111, 112, 111, 112}; // (5) + static const int tL022[nL022] = {112, 111, 112, 111, 112, 111, 112, 111}; //_______________11_ + static const int tL023[nL023] = {101, 102, 101, 102, 101, 102, 101, 102}; + static const int tL024[nL024] = {102, 101, 102, 101, 102, 101, 102, 101}; + static const int tL025[nL025] = {101, 102, 101, 102, 101, 102, 101, 102, 101}; + static const int tL026[nL026] = {102, 101, 102, 101, 104, 101, 102, 101, 102}; + static const int tL027[nL027] = {101, 102, 101, 102, 101, 102, 101, 102, 101}; // (6) + static const int tL028[nL028] = {102, 101, 102, 101, 102, 101, 102, 101, 102}; + static const int tL029[nL029] = {101, 102, 101, 102, 101, 102, 101, 102, 101}; + static const int tL030[nL030] = {102, 101, 102, 101, 102, 101, 102, 101, 102}; + static const int tL031[nL031] = {101, 102, 101, 102, 101, 102, 101, 102, 101, 102}; //_______10_ + static const int tL032[nL032] = {102, 101, 102, 91, 92, 91, 92, 91, 92, 91}; + static const int tL033[nL033] = {91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; // (6) + static const int tL034[nL034] = {92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; + static const int tL035[nL035] = {91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; + static const int tL036[nL036] = {92, 91, 92, 91, 94, 91, 92, 91, 92, 91}; + static const int tL037[nL037] = {91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; + static const int tL038[nL038] = {92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; + static const int tL039[nL039] = {91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; // (5) + static const int tL040[nL040] = {92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92}; + static const int tL041[nL041] = {91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; + static const int tL042[nL042] = {92, 91, 92, 91, 92, 91, 92, 91, 92, 91, 92, 91}; //_9_ + static const int tL043[nL043] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; + static const int tL044[nL044] = {82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL045[nL045] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; //(6) + static const int tL046[nL046] = {82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL047[nL047] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; + static const int tL048[nL048] = {82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; + static const int tL049[nL049] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL050[nL050] = {82, 81, 82, 81, 82, 81, 82, 81, 84, 81, 82, 81, 82}; //(6) + static const int tL051[nL051] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL052[nL052] = {82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; + static const int tL053[nL053] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL054[nL054] = {82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81}; + static const int tL055[nL055] = {81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82, 81, 82}; // ________________________________________________________________________________8_ (5) - static const int tL056[nL056]={ 82, 81, 82, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; - static const int tL057[nL057]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; - static const int tL058[nL058]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; - static const int tL059[nL059]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71}; - static const int tL060[nL060]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, - 72}; - static const int tL061[nL061]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71}; // (6) - static const int tL062[nL062]={ 72, 71, 72, 71, 72, 71, 72, 71, 74, 71, 72, 71, 72, 71, - 71}; - static const int tL063[nL063]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71}; - static const int tL064[nL064]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, - 72}; - static const int tL065[nL065]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71, 72}; - static const int tL066[nL066]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, - 72, 71}; // (6) - static const int tL067[nL067]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71, 72}; - static const int tL068[nL068]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, - 72, 71}; - static const int tL069[nL069]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, - 71, 72}; - static const int tL070[nL070]={ 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, - 72, 71}; - static const int tL071[nL071]={ 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 61, 62, 61, 62, - 61, 62, 61}; // _____________________________________7_ - static const int tL072[nL072]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62}; - static const int tL073[nL073]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61}; // (5) - static const int tL074[nL074]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62}; - static const int tL075[nL075]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61}; - static const int tL076[nL076]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62, 61}; - static const int tL077[nL077]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62}; - static const int tL078[nL078]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62, 61}; // (6) - static const int tL079[nL079]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62}; - static const int tL080[nL080]={ 62, 61, 62, 61, 62, 61, 62, 61, 64, 61, 62, 61, 62, 61, - 62, 61, 62, 61}; - static const int tL081[nL081]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62}; - static const int tL082[nL082]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62, 61, 62}; - static const int tL083[nL083]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62, 61}; // (6) - static const int tL084[nL084]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62, 61, 62}; - static const int tL085[nL085]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62, 61}; - static const int tL086[nL086]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 62, 61, 62}; - static const int tL087[nL087]={ 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, - 61, 62, 61, 62, 61}; - static const int tL088[nL088]={ 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, - 62, 61, 52, 51, 52, 51}; // _________________________6_ + static const int tL056[nL056] = {82, 81, 82, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL057[nL057] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL058[nL058] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL059[nL059] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL060[nL060] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL061[nL061] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; // (6) + static const int tL062[nL062] = {72, 71, 72, 71, 72, 71, 72, 71, 74, 71, 72, 71, 72, 71, 71}; + static const int tL063[nL063] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL064[nL064] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL065[nL065] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL066[nL066] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; // (6) + static const int tL067[nL067] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL068[nL068] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL069[nL069] = {71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72}; + static const int tL070[nL070] = {72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 71}; + static const int tL071[nL071] = { + 71, 72, 71, 72, 71, 72, 71, 72, 71, 72, 61, 62, 61, 62, 61, 62, 61}; // _____________________________________7_ + static const int tL072[nL072] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL073[nL073] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; // (5) + static const int tL074[nL074] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL075[nL075] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; + static const int tL076[nL076] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; + static const int tL077[nL077] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL078[nL078] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; // (6) + static const int tL079[nL079] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL080[nL080] = {62, 61, 62, 61, 62, 61, 62, 61, 64, 61, 62, 61, 62, 61, 62, 61, 62, 61}; + static const int tL081[nL081] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL082[nL082] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL083[nL083] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; // (6) + static const int tL084[nL084] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL085[nL085] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; + static const int tL086[nL086] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62}; + static const int tL087[nL087] = {61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61, 62, 61}; + static const int tL088[nL088] = {62, 61, 62, 61, 62, 61, 62, 61, 62, 61, + 62, 61, 62, 61, 62, 61, 52, 51, 52, 51}; // _________________________6_ //------------------------------------------------------------------------------------- - static const int tL089[nL089]={ 61, 62, 61, 62, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52}; // (5) - static const int tL090[nL090]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51}; - static const int tL091[nL091]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52}; - static const int tL092[nL092]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51}; - static const int tL093[nL093]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51}; - static const int tL094[nL094]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52}; - static const int tL095[nL095]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51}; // (6) - static const int tL096[nL096]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52}; - static const int tL097[nL097]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51}; - static const int tL098[nL098]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52}; - static const int tL099[nL099]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52}; - static const int tL100[nL100]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 53, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51}; // (6) - static const int tL101[nL101]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52}; - static const int tL102[nL102]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51}; - static const int tL103[nL103]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52}; - static const int tL104[nL104]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51}; - static const int tL105[nL105]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52, 51}; - static const int tL106[nL106]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51, 52}; - static const int tL107[nL107]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52, 51}; // (5) - static const int tL108[nL108]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51, 52}; - static const int tL109[nL109]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 52, 51, 52, 51, 52, 51}; - static const int tL110[nL110]={ 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, - 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; - static const int tL111[nL111]={ 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, - 51, 52, 51, 42, 41, 42, 41, 42, 41, 42}; // _________4_ - static const int tL112[nL112]={ 52, 51, 52, 51, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; // (6) - static const int tL113[nL113]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL114[nL114]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL115[nL115]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL116[nL116]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL117[nL117]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL118[nL118]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL119[nL119]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; // (6) - static const int tL120[nL120]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL121[nL121]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL122[nL122]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL123[nL123]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL124[nL124]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 43, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41};// (5) - static const int tL125[nL125]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL126[nL126]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL127[nL127]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL128[nL128]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL129[nL129]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL130[nL130]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42};//(6) - static const int tL131[nL131]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL132[nL132]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL133[nL133]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL134[nL134]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL135[nL135]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; - static const int tL136[nL136]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, - 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; - static const int tL137[nL137]={ 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, - 41, 42, 41, 42, 41, 42, 41, 42, 31, 32, 31, 32, 31, 32}; + static const int tL089[nL089] = {61, 62, 61, 62, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; // (5) + static const int tL090[nL090] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL091[nL091] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL092[nL092] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL093[nL093] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL094[nL094] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL095[nL095] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; // (6) + static const int tL096[nL096] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL097[nL097] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL098[nL098] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL099[nL099] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL100[nL100] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 53, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; // (6) + static const int tL101[nL101] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL102[nL102] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL103[nL103] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL104[nL104] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL105[nL105] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL106[nL106] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL107[nL107] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; // (5) + static const int tL108[nL108] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52}; + static const int tL109[nL109] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL110[nL110] = {52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, + 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51}; + static const int tL111[nL111] = {51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52, + 51, 52, 51, 52, 51, 42, 41, 42, 41, 42, 41, 42}; // _________4_ + static const int tL112[nL112] = {52, 51, 52, 51, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; // (6) + static const int tL113[nL113] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL114[nL114] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL115[nL115] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL116[nL116] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL117[nL117] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL118[nL118] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL119[nL119] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; // (6) + static const int tL120[nL120] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL121[nL121] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL122[nL122] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL123[nL123] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL124[nL124] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 43, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; // (5) + static const int tL125[nL125] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL126[nL126] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL127[nL127] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL128[nL128] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL129[nL129] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL130[nL130] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; //(6) + static const int tL131[nL131] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL132[nL132] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL133[nL133] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL134[nL134] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL135[nL135] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42}; + static const int tL136[nL136] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, + 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41}; + static const int tL137[nL137] = {41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, + 41, 42, 41, 42, 41, 42, 41, 42, 31, 32, 31, 32, 31, 32}; // ____________________________________________________________________________(6)___3_ - static const int tL138[nL138]={ 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; - static const int tL139[nL139]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31}; - static const int tL140[nL140]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32}; - static const int tL141[nL141]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31}; // (5) - static const int tL142[nL142]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32}; - static const int tL143[nL143]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31}; - static const int tL144[nL144]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31}; - static const int tL145[nL145]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32}; - static const int tL146[nL146]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 33, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31}; - static const int tL147[nL147]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32}; // (6) - static const int tL148[nL148]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31}; - static const int tL149[nL149]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32}; - static const int tL150[nL150]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32}; - static const int tL151[nL151]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31}; - static const int tL152[nL152]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32}; // (6) - static const int tL153[nL153]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31}; - static const int tL154[nL154]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32}; - static const int tL155[nL155]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31}; - static const int tL156[nL156]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31}; - static const int tL157[nL157]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32}; - static const int tL158[nL158]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31}; // (5) - static const int tL159[nL159]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32}; - static const int tL160[nL160]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 33, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31}; - static const int tL161[nL161]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31}; - static const int tL162[nL162]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32}; - static const int tL163[nL163]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31}; // (6) - static const int tL164[nL164]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32}; - static const int tL165[nL165]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31}; - static const int tL166[nL166]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32}; - static const int tL167[nL167]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 31, 32}; - static const int tL168[nL168]={ 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, - 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 21, - 22, 21, 22, 21, 22, 21}; // _________________________2_ - static const int tL169[nL169]={ 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, - 31, 32, 31, 32, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22}; // (6) - static const int tL170[nL170]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21}; - static const int tL171[nL171]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22}; - static const int tL172[nL172]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21}; - static const int tL173[nL173]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21}; - static const int tL174[nL174]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22}; - static const int tL175[nL175]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21}; // (5) - static const int tL176[nL176]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22}; - static const int tL177[nL177]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21}; - static const int tL178[nL178]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 23, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL179[nL179]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL180[nL180]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21}; // (6) - static const int tL181[nL181]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL182[nL182]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL183[nL183]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL184[nL184]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL185[nL185]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL186[nL186]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL187[nL187]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (6) - static const int tL188[nL188]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL189[nL189]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL190[nL190]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL191[nL191]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL192[nL192]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (5) - static const int tL193[nL193]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL194[nL194]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL195[nL195]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL196[nL196]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 23, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL197[nL197]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (6) - static const int tL198[nL198]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL199[nL199]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL200[nL200]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL201[nL201]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; - static const int tL202[nL202]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL203[nL203]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; //(6) - static const int tL204[nL204]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; - static const int tL205[nL205]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, - 21, 22, 21, 22, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL206[nL206]={ 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, - 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11};//__1_ - static const int tL207[nL207]={ 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; - static const int tL208[nL208]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL209[nL209]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11};//(5) - static const int tL210[nL210]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL211[nL211]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; - static const int tL212[nL212]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 13, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; - static const int tL213[nL213]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL214[nL214]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; - static const int tL215[nL215]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL216[nL216]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; - static const int tL217[nL217]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; - static const int tL218[nL218]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12}; - static const int tL219[nL219]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11}; - static const int tL220[nL220]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12}; - static const int tL221[nL221]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11}; // (6) - static const int tL222[nL222]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12}; - static const int tL223[nL223]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11}; - static const int tL224[nL224]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11}; - static const int tL225[nL225]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12}; - static const int tL226[nL226]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 13, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11}; // (5) - static const int tL227[nL227]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12}; - static const int tL228[nL228]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11}; - static const int tL229[nL229]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11}; - static const int tL230[nL230]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12}; - static const int tL231[nL231]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 0, 0, 0, - 0, 0, 0}; // (5+1=6) - static const int tL232[nL232]={ 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, - 12, 11, 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; - static const int tL233[nL233]={ 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, - 11, 12, 11, 12, 11, 12, 11, 12, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; - static const int nSL[nLay]={ - nL001, nL002, nL003, nL004, nL005, nL006, nL007, nL008, nL009 ,nL010, - nL011, nL012, nL013, nL014, nL015, nL016, nL017, nL018, nL019 ,nL020, - nL021, nL022, nL023, nL024, nL025, nL026, nL027, nL028, nL029 ,nL030, - nL031, nL032, nL033, nL034, nL035, nL036, nL037, nL038, nL039 ,nL040, - nL041, nL042, nL043, nL044, nL045, nL046, nL047, nL048, nL049 ,nL050, - nL051, nL052, nL053, nL054, nL055, nL056, nL057, nL058, nL059 ,nL060, - nL061, nL062, nL063, nL064, nL065, nL066, nL067, nL068, nL069 ,nL070, - nL071, nL072, nL073, nL074, nL075, nL076, nL077, nL078, nL079 ,nL080, - nL081, nL082, nL083, nL084, nL085, nL086, nL087, nL088, nL089 ,nL090, - nL091, nL092, nL093, nL094, nL095, nL096, nL097, nL098, nL099 ,nL100, - nL101, nL102, nL103, nL104, nL105, nL106, nL107, nL108, nL109 ,nL110, - nL111, nL112, nL113, nL114, nL115, nL116, nL117, nL118, nL119 ,nL120, - nL121, nL122, nL123, nL124, nL125, nL126, nL127, nL128, nL129 ,nL130, - nL131, nL132, nL133, nL134, nL135, nL136, nL137, nL138, nL139 ,nL140, - nL141, nL142, nL143, nL144, nL145, nL146, nL147, nL148, nL149 ,nL150, - nL151, nL152, nL153, nL154, nL155, nL156, nL157, nL158, nL159 ,nL160, - nL161, nL162, nL163, nL164, nL165, nL166, nL167, nL168, nL169 ,nL170, - nL171, nL172, nL173, nL174, nL175, nL176, nL177, nL178, nL179 ,nL180, - nL181, nL182, nL183, nL184, nL185, nL186, nL187, nL188, nL189 ,nL190, - nL191, nL192, nL193, nL194, nL195, nL196, nL197, nL198, nL199 ,nL200, - nL201, nL202, nL203, nL204, nL205, nL206, nL207, nL208, nL209 ,nL210, - nL211, nL212, nL213, nL214, nL215, nL216, nL217, nL218, nL219 ,nL220, - nL221, nL222, nL223, nL224, nL225, nL226, nL227, nL228, nL229 ,nL230, - nL231, nL232, nL233}; - static const int * const nLT[nLay]={ - tL001, tL002, tL003, tL004, tL005, tL006, tL007, tL008, tL009 ,tL010, - tL011, tL012, tL013, tL014, tL015, tL016, tL017, tL018, tL019 ,tL020, - tL021, tL022, tL023, tL024, tL025, tL026, tL027, tL028, tL029 ,tL030, - tL031, tL032, tL033, tL034, tL035, tL036, tL037, tL038, tL039 ,tL040, - tL041, tL042, tL043, tL044, tL045, tL046, tL047, tL048, tL049 ,tL050, - tL051, tL052, tL053, tL054, tL055, tL056, tL057, tL058, tL059 ,tL060, - tL061, tL062, tL063, tL064, tL065, tL066, tL067, tL068, tL069 ,tL070, - tL071, tL072, tL073, tL074, tL075, tL076, tL077, tL078, tL079 ,tL080, - tL081, tL082, tL083, tL084, tL085, tL086, tL087, tL088, tL089 ,tL090, - tL091, tL092, tL093, tL094, tL095, tL096, tL097, tL098, tL099 ,tL100, - tL101, tL102, tL103, tL104, tL105, tL106, tL107, tL108, tL109 ,tL110, - tL111, tL112, tL113, tL114, tL115, tL116, tL117, tL118, tL119 ,tL120, - tL121, tL122, tL123, tL124, tL125, tL126, tL127, tL128, tL129 ,tL130, - tL131, tL132, tL133, tL134, tL135, tL136, tL137, tL138, tL139 ,tL140, - tL141, tL142, tL143, tL144, tL145, tL146, tL147, tL148, tL149 ,tL150, - tL151, tL152, tL153, tL154, tL155, tL156, tL157, tL158, tL159 ,tL160, - tL161, tL162, tL163, tL164, tL165, tL166, tL167, tL168, tL169 ,tL170, - tL171, tL172, tL173, tL174, tL175, tL176, tL177, tL178, tL179 ,tL180, - tL181, tL182, tL183, tL184, tL185, tL186, tL187, tL188, tL189 ,tL190, - tL191, tL192, tL193, tL194, tL195, tL196, tL197, tL198, tL199 ,tL200, - tL201, tL202, tL203, tL204, tL205, tL206, tL207, tL208, tL209 ,tL210, - tL211, tL212, tL213, tL214, tL215, tL216, tL217, tL218, tL219 ,tL220, - tL221, tL222, tL223, tL224, tL225, tL226, tL227, tL228, tL229 ,tL230, - tL231, tL232, tL233}; - static const int * const nRT[nLay]={ - tR001, tR002, tR003, tR004, tR005, tR006, tR007, tR008, tR009 ,tR010, - tR011, tR012, tR013, tR014, tR015, tR016, tR017, tR018, tR019 ,tR020, - tR021, tR022, tR023, tR024, tR025, tR026, tR027, tR028, tR029 ,tR030, - tR031, tR032, tR033, tR034, tR035, tR036, tR037, tR038, tR039 ,tR040, - tR041, tR042, tR043, tR044, tR045, tR046, tR047, tR048, tR049 ,tR050, - tR051, tR052, tR053, tR054, tR055, tR056, tR057, tR058, tR059 ,tR060, - tR061, tR062, tR063, tR064, tR065, tR066, tR067, tR068, tR069 ,tR070, - tR071, tR072, tR073, tR074, tR075, tR076, tR077, tR078, tR079 ,tR080, - tR081, tR082, tR083, tR084, tR085, tR086, tR087, tR088, tR089 ,tR090, - tR091, tR092, tR093, tR094, tR095, tR096, tR097, tR098, tR099 ,tR100, - tR101, tR102, tR103, tR104, tR105, tR106, tR107, tR108, tR109 ,tR110, - tR111, tR112, tR113, tR114, tR115, tR116, tR117, tR118, tR119 ,tR120, - tR121, tR122, tR123, tR124, tR125, tR126, tR127, tR128, tR129 ,tR130, - tR131, tR132, tR133, tR134, tR135, tR136, tR137, tR138, tR139 ,tR140, - tR141, tR142, tR143, tR144, tR145, tR146, tR147, tR148, tR149 ,tR150, - tR151, tR152, tR153, tR154, tR155, tR156, tR157, tR158, tR159 ,tR160, - tR161, tR162, tR163, tR164, tR165, tR166, tR167, tR168, tR169 ,tR170, - tR171, tR172, tR173, tR174, tR175, tR176, tR177, tR178, tR179 ,tR180, - tR181, tR182, tR183, tR184, tR185, tR186, tR187, tR188, tR189 ,tR190, - tR191, tR192, tR193, tR194, tR195, tR196, tR197, tR198, tR199 ,tR200, - tR201, tR202, tR203, tR204, tR205, tR206, tR207, tR208, tR209 ,tR210, - tR211, tR212, tR213, tR214, tR215, tR216, tR217, tR218, tR219 ,tR220, - tR221, tR222, tR223, tR224, tR225, tR226, tR227, tR228, tR229 ,tR230, - tR231, tR232, tR233}; + static const int tL138[nL138] = {42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 42, 41, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL139[nL139] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL140[nL140] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL141[nL141] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; // (5) + static const int tL142[nL142] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL143[nL143] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL144[nL144] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL145[nL145] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL146[nL146] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 33, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL147[nL147] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; // (6) + static const int tL148[nL148] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL149[nL149] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL150[nL150] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL151[nL151] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL152[nL152] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; // (6) + static const int tL153[nL153] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL154[nL154] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL155[nL155] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL156[nL156] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL157[nL157] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL158[nL158] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; // (5) + static const int tL159[nL159] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL160[nL160] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 33, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL161[nL161] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL162[nL162] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL163[nL163] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; // (6) + static const int tL164[nL164] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL165[nL165] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31}; + static const int tL166[nL166] = {32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL167[nL167] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32}; + static const int tL168[nL168] = { + 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, + 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 21, 22, 21, 22, 21, 22, 21}; // _________________________2_ + static const int tL169[nL169] = {31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, 32, 31, + 32, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; // (6) + static const int tL170[nL170] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL171[nL171] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL172[nL172] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL173[nL173] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL174[nL174] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL175[nL175] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (5) + static const int tL176[nL176] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL177[nL177] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL178[nL178] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 23, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL179[nL179] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL180[nL180] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (6) + static const int tL181[nL181] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL182[nL182] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL183[nL183] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL184[nL184] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL185[nL185] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL186[nL186] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL187[nL187] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (6) + static const int tL188[nL188] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL189[nL189] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL190[nL190] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL191[nL191] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL192[nL192] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (5) + static const int tL193[nL193] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL194[nL194] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL195[nL195] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL196[nL196] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 23, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL197[nL197] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; // (6) + static const int tL198[nL198] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL199[nL199] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL200[nL200] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL201[nL201] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; + static const int tL202[nL202] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL203[nL203] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22}; //(6) + static const int tL204[nL204] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, + 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21}; + static const int tL205[nL205] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL206[nL206] = {22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 22, + 21, 22, 21, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; //__1_ + static const int tL207[nL207] = {21, 22, 21, 22, 21, 22, 21, 22, 21, 22, 21, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL208[nL208] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL209[nL209] = { + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; //(5) + static const int tL210[nL210] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL211[nL211] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL212[nL212] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 13, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL213[nL213] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL214[nL214] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL215[nL215] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL216[nL216] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL217[nL217] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL218[nL218] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL219[nL219] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL220[nL220] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL221[nL221] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; // (6) + static const int tL222[nL222] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL223[nL223] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL224[nL224] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL225[nL225] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL226[nL226] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 13, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; // (5) + static const int tL227[nL227] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL228[nL228] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL229[nL229] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11}; + static const int tL230[nL230] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12}; + static const int tL231[nL231] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 0, 0, 0, 0, 0, 0}; // (5+1=6) + static const int tL232[nL232] = {12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, + 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + static const int tL233[nL233] = {11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12, 11, + 12, 11, 12, 11, 12, 11, 12, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + static const int nSL[nLay] = { + nL001, nL002, nL003, nL004, nL005, nL006, nL007, nL008, nL009, nL010, nL011, nL012, nL013, nL014, nL015, nL016, + nL017, nL018, nL019, nL020, nL021, nL022, nL023, nL024, nL025, nL026, nL027, nL028, nL029, nL030, nL031, nL032, + nL033, nL034, nL035, nL036, nL037, nL038, nL039, nL040, nL041, nL042, nL043, nL044, nL045, nL046, nL047, nL048, + nL049, nL050, nL051, nL052, nL053, nL054, nL055, nL056, nL057, nL058, nL059, nL060, nL061, nL062, nL063, nL064, + nL065, nL066, nL067, nL068, nL069, nL070, nL071, nL072, nL073, nL074, nL075, nL076, nL077, nL078, nL079, nL080, + nL081, nL082, nL083, nL084, nL085, nL086, nL087, nL088, nL089, nL090, nL091, nL092, nL093, nL094, nL095, nL096, + nL097, nL098, nL099, nL100, nL101, nL102, nL103, nL104, nL105, nL106, nL107, nL108, nL109, nL110, nL111, nL112, + nL113, nL114, nL115, nL116, nL117, nL118, nL119, nL120, nL121, nL122, nL123, nL124, nL125, nL126, nL127, nL128, + nL129, nL130, nL131, nL132, nL133, nL134, nL135, nL136, nL137, nL138, nL139, nL140, nL141, nL142, nL143, nL144, + nL145, nL146, nL147, nL148, nL149, nL150, nL151, nL152, nL153, nL154, nL155, nL156, nL157, nL158, nL159, nL160, + nL161, nL162, nL163, nL164, nL165, nL166, nL167, nL168, nL169, nL170, nL171, nL172, nL173, nL174, nL175, nL176, + nL177, nL178, nL179, nL180, nL181, nL182, nL183, nL184, nL185, nL186, nL187, nL188, nL189, nL190, nL191, nL192, + nL193, nL194, nL195, nL196, nL197, nL198, nL199, nL200, nL201, nL202, nL203, nL204, nL205, nL206, nL207, nL208, + nL209, nL210, nL211, nL212, nL213, nL214, nL215, nL216, nL217, nL218, nL219, nL220, nL221, nL222, nL223, nL224, + nL225, nL226, nL227, nL228, nL229, nL230, nL231, nL232, nL233}; + static const int* const nLT[nLay] = { + tL001, tL002, tL003, tL004, tL005, tL006, tL007, tL008, tL009, tL010, tL011, tL012, tL013, tL014, tL015, tL016, + tL017, tL018, tL019, tL020, tL021, tL022, tL023, tL024, tL025, tL026, tL027, tL028, tL029, tL030, tL031, tL032, + tL033, tL034, tL035, tL036, tL037, tL038, tL039, tL040, tL041, tL042, tL043, tL044, tL045, tL046, tL047, tL048, + tL049, tL050, tL051, tL052, tL053, tL054, tL055, tL056, tL057, tL058, tL059, tL060, tL061, tL062, tL063, tL064, + tL065, tL066, tL067, tL068, tL069, tL070, tL071, tL072, tL073, tL074, tL075, tL076, tL077, tL078, tL079, tL080, + tL081, tL082, tL083, tL084, tL085, tL086, tL087, tL088, tL089, tL090, tL091, tL092, tL093, tL094, tL095, tL096, + tL097, tL098, tL099, tL100, tL101, tL102, tL103, tL104, tL105, tL106, tL107, tL108, tL109, tL110, tL111, tL112, + tL113, tL114, tL115, tL116, tL117, tL118, tL119, tL120, tL121, tL122, tL123, tL124, tL125, tL126, tL127, tL128, + tL129, tL130, tL131, tL132, tL133, tL134, tL135, tL136, tL137, tL138, tL139, tL140, tL141, tL142, tL143, tL144, + tL145, tL146, tL147, tL148, tL149, tL150, tL151, tL152, tL153, tL154, tL155, tL156, tL157, tL158, tL159, tL160, + tL161, tL162, tL163, tL164, tL165, tL166, tL167, tL168, tL169, tL170, tL171, tL172, tL173, tL174, tL175, tL176, + tL177, tL178, tL179, tL180, tL181, tL182, tL183, tL184, tL185, tL186, tL187, tL188, tL189, tL190, tL191, tL192, + tL193, tL194, tL195, tL196, tL197, tL198, tL199, tL200, tL201, tL202, tL203, tL204, tL205, tL206, tL207, tL208, + tL209, tL210, tL211, tL212, tL213, tL214, tL215, tL216, tL217, tL218, tL219, tL220, tL221, tL222, tL223, tL224, + tL225, tL226, tL227, tL228, tL229, tL230, tL231, tL232, tL233}; + static const int* const nRT[nLay] = { + tR001, tR002, tR003, tR004, tR005, tR006, tR007, tR008, tR009, tR010, tR011, tR012, tR013, tR014, tR015, tR016, + tR017, tR018, tR019, tR020, tR021, tR022, tR023, tR024, tR025, tR026, tR027, tR028, tR029, tR030, tR031, tR032, + tR033, tR034, tR035, tR036, tR037, tR038, tR039, tR040, tR041, tR042, tR043, tR044, tR045, tR046, tR047, tR048, + tR049, tR050, tR051, tR052, tR053, tR054, tR055, tR056, tR057, tR058, tR059, tR060, tR061, tR062, tR063, tR064, + tR065, tR066, tR067, tR068, tR069, tR070, tR071, tR072, tR073, tR074, tR075, tR076, tR077, tR078, tR079, tR080, + tR081, tR082, tR083, tR084, tR085, tR086, tR087, tR088, tR089, tR090, tR091, tR092, tR093, tR094, tR095, tR096, + tR097, tR098, tR099, tR100, tR101, tR102, tR103, tR104, tR105, tR106, tR107, tR108, tR109, tR110, tR111, tR112, + tR113, tR114, tR115, tR116, tR117, tR118, tR119, tR120, tR121, tR122, tR123, tR124, tR125, tR126, tR127, tR128, + tR129, tR130, tR131, tR132, tR133, tR134, tR135, tR136, tR137, tR138, tR139, tR140, tR141, tR142, tR143, tR144, + tR145, tR146, tR147, tR148, tR149, tR150, tR151, tR152, tR153, tR154, tR155, tR156, tR157, tR158, tR159, tR160, + tR161, tR162, tR163, tR164, tR165, tR166, tR167, tR168, tR169, tR170, tR171, tR172, tR173, tR174, tR175, tR176, + tR177, tR178, tR179, tR180, tR181, tR182, tR183, tR184, tR185, tR186, tR187, tR188, tR189, tR190, tR191, tR192, + tR193, tR194, tR195, tR196, tR197, tR198, tR199, tR200, tR201, tR202, tR203, tR204, tR205, tR206, tR207, tR208, + tR209, tR210, tR211, tR212, tR213, tR214, tR215, tR216, tR217, tR218, tR219, tR220, tR221, tR222, tR223, tR224, + tR225, tR226, tR227, tR228, tR229, tR230, tR231, tR232, tR233}; /* // The following are differences in the Source tube positions(not used so far) @@ -1503,50 +1302,57 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect) static const int B18[nS]={0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0}; */ - static const double cellSize = 0.5*CLHEP::cm; // 0.5 cm is the cell size + static const double cellSize = 0.5 * CLHEP::cm; // 0.5 cm is the cell size if (!(xl > 0.)) - xl=-xl; - double fx=xl/cellSize; - int ny=static_cast((yl-yMin)/cellSize); // Layer number (starting from 0) - if (ny < 0 || ny >= nLay) {// Sould never happen as was checked beforehand - LogDebug("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " - << "check limits y = " << yl << ", nL=" - << nLay; + xl = -xl; + double fx = xl / cellSize; + int ny = static_cast((yl - yMin) / cellSize); // Layer number (starting from 0) + if (ny < 0 || ny >= nLay) { // Sould never happen as was checked beforehand +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: " + << "check limits y = " << yl << ", nL=" << nLay; +#endif return 0; } - int nx=static_cast(fx); // Cell number (starting from 0) - LogDebug("HFShower") << "HFFibreFiducial::PMTNumber:X = " << xv - << ", Y = " << yv << ", Z = " << pe_effect.z() - << ", fX = " << fx << "-> nX = " << nx - << ", nY = " << ny << ", mX = " << nSL[ny] - << ", x = " << xl << ", y = "<< yl << ", s = " - << cellSize << ", nW = " << nwid << ", phi = " - << phi/CLHEP::deg << ", phis = " - << atan2(xl, yl)/CLHEP::deg - << ", phir = " << phir/CLHEP::deg; + int nx = static_cast(fx); // Cell number (starting from 0) +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial::PMTNumber:X = " << xv << ", Y = " << yv << ", Z = " << pe_effect.z() + << ", fX = " << fx << "-> nX = " << nx << ", nY = " << ny << ", mX = " << nSL[ny] + << ", x = " << xl << ", y = " << yl << ", s = " << cellSize << ", nW = " << nwid + << ", phi = " << phi / CLHEP::deg << ", phis = " << atan2(xl, yl) / CLHEP::deg + << ", phir = " << phir / CLHEP::deg; +#endif if (nx >= nSL[ny]) { - LogDebug("HFShower") << "HFFibreFiducial::nx/ny (" << nx - << "," << ny <<") " << " above limit " - << nSL[ny]; - return 0; // ===> out of the acceptance +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial::nx/ny (" << nx << "," << ny << ") " + << " above limit " << nSL[ny]; +#endif + return 0; // ===> out of the acceptance } - int code=0; // a prototype - if (left) code=nLT[ny][nx]; - else code=nRT[ny][nx]; - int flag= code%10; - int npmt= code/10; - bool src= false; // by default: not a source-tube - LogDebug("HFShower") << "HFFibreFiducial::nx/ny (" << nx << "," - << ny << ") code/flag/npmt " << code << "/" - << flag << "/" << npmt; + int code = 0; // a prototype + if (left) + code = nLT[ny][nx]; + else + code = nRT[ny][nx]; + int flag = code % 10; + int npmt = code / 10; + bool src = false; // by default: not a source-tube +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial::nx/ny (" << nx << "," << ny << ") code/flag/npmt " << code << "/" + << flag << "/" << npmt; +#endif - if (!flag) return 0; // ===> no fiber in the cell - else if (flag==1) npmt += 24; - else if (flag==3 || flag==4) { - src=true; + if (!flag) + return 0; // ===> no fiber in the cell + else if (flag == 1) + npmt += 24; + else if (flag == 3 || flag == 4) { + src = true; } - LogDebug("HFShower") << "HFFibreFiducial::PMTNumber: src = " << src - << ", npmt =" << npmt; - if (src) return -npmt; // return the negative number for the source +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFFibreFiducial::PMTNumber: src = " << src << ", npmt =" << npmt; +#endif + if (src) + return -npmt; // return the negative number for the source return npmt; -} // End of PMTNumber +} // End of PMTNumber diff --git a/SimG4CMS/Calo/src/HFGflash.cc b/SimG4CMS/Calo/src/HFGflash.cc index 60c10711c97dc..28265581207bb 100644 --- a/SimG4CMS/Calo/src/HFGflash.cc +++ b/SimG4CMS/Calo/src/HFGflash.cc @@ -32,17 +32,15 @@ #include -//#define DebugLog +//#define EDM_ML_DEBUG -HFGflash::HFGflash(edm::ParameterSet const & p) { - - edm::ParameterSet m_HF = p.getParameter("HFGflash"); - theBField = m_HF.getUntrackedParameter("BField", 3.8); - theWatcherOn = m_HF.getUntrackedParameter("WatcherOn",true); - theFillHisto = m_HF.getUntrackedParameter("FillHisto",true); - edm::LogInfo("HFShower") << "HFGFlash:: Set B-Field to " << theBField - << ", WatcherOn to " << theWatcherOn - << " and FillHisto to " << theFillHisto; +HFGflash::HFGflash(edm::ParameterSet const& p) { + edm::ParameterSet m_HF = p.getParameter("HFGflash"); + theBField = m_HF.getUntrackedParameter("BField", 3.8); + theWatcherOn = m_HF.getUntrackedParameter("WatcherOn", true); + theFillHisto = m_HF.getUntrackedParameter("FillHisto", true); + edm::LogVerbatim("HFShower") << "HFGFlash:: Set B-Field to " << theBField << ", WatcherOn to " << theWatcherOn + << " and FillHisto to " << theFillHisto; theHelix = new GflashTrajectory; theGflashStep = new G4Step(); @@ -50,35 +48,75 @@ HFGflash::HFGflash(edm::ParameterSet const & p) { // theGflashNavigator = 0; theGflashTouchableHandle = new G4TouchableHistory(); -#ifdef DebugLog +#ifdef EDM_ML_DEBUG if (theFillHisto) { edm::Service tfile; - if ( tfile.isAvailable() ) { + if (tfile.isAvailable()) { TFileDirectory showerDir = tfile->mkdir("GflashEMShowerProfile"); - em_incE = showerDir.make("em_incE","Incoming energy (GeV)",500,0,500.); - em_ssp_rho = showerDir.make("em_ssp_rho","Shower starting position;#rho (cm);Number of Events",100,100.0,200.0); - em_ssp_z = showerDir.make("em_ssp_z","Shower starting position;z (cm);Number of Events",2000,0.0,2000.0); - em_long = showerDir.make("em_long","Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0); - em_lateral = showerDir.make("em_lateral","Lateral Profile;Radiation Length;Moliere Radius",100,0.0,5.0); - em_2d = showerDir.make("em_2d","Lateral Profile vs. Shower Depth;Radiation Length;Moliere Radius",800,800.0,1600.0,100,0.0,5.0); - em_long_sd = showerDir.make("em_long_sd","Longitudinal Profile in Sensitive Detector;Radiation Length;Number of Spots",800,800.0,1600.0); - em_lateral_sd = showerDir.make("em_lateral_sd","Lateral Profile vs. Shower Depth in Sensitive Detector;Radiation Length;Moliere Radius",100,0.0,5.0); - em_2d_sd = showerDir.make("em_2d_sd","Lateral Profile vs. Shower Depth in Sensitive Detector;Radiation Length;Moliere Radius",800,800.0,1600.0,100,0.0,5.0); - em_ze = showerDir.make("em_ze","Profile vs. Energy;Radiation Length;Moliere Radius",800,800.0,1600.0,1000,0.0,1.0); - em_ratio = showerDir.make("em_ratio","Profile vs. Energy;Radiation Length;Moliere Radius",800,800.0,1600.0,1000,0.0,100.0); - em_ratio_selected = showerDir.make("em_ratio_selected","Profile vs. Energy;Radiation Length;Moliere Radius",800,800.0,1600.0,1000,0.0,100.0); - em_nSpots_sd = showerDir.make("em_nSpots_sd","Number of Gflash Spots in Sensitive Detector;Number of Spots;Number of Events",100,0.0,100); - em_ze_ratio = showerDir.make("em_ze_ratio","Ratio of Energy and Z Position",1000,0.0,0.001); + em_incE = showerDir.make("em_incE", "Incoming energy (GeV)", 500, 0, 500.); + em_ssp_rho = + showerDir.make("em_ssp_rho", "Shower starting position;#rho (cm);Number of Events", 100, 100.0, 200.0); + em_ssp_z = + showerDir.make("em_ssp_z", "Shower starting position;z (cm);Number of Events", 2000, 0.0, 2000.0); + em_long = + showerDir.make("em_long", "Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0); + em_lateral = showerDir.make("em_lateral", "Lateral Profile;Radiation Length;Moliere Radius", 100, 0.0, 5.0); + em_2d = showerDir.make("em_2d", + "Lateral Profile vs. Shower Depth;Radiation Length;Moliere Radius", + 800, + 800.0, + 1600.0, + 100, + 0.0, + 5.0); + em_long_sd = showerDir.make("em_long_sd", + "Longitudinal Profile in Sensitive Detector;Radiation Length;Number of Spots", + 800, + 800.0, + 1600.0); + em_lateral_sd = + showerDir.make("em_lateral_sd", + "Lateral Profile vs. Shower Depth in Sensitive Detector;Radiation Length;Moliere Radius", + 100, + 0.0, + 5.0); + em_2d_sd = + showerDir.make("em_2d_sd", + "Lateral Profile vs. Shower Depth in Sensitive Detector;Radiation Length;Moliere Radius", + 800, + 800.0, + 1600.0, + 100, + 0.0, + 5.0); + em_ze = showerDir.make( + "em_ze", "Profile vs. Energy;Radiation Length;Moliere Radius", 800, 800.0, 1600.0, 1000, 0.0, 1.0); + em_ratio = showerDir.make( + "em_ratio", "Profile vs. Energy;Radiation Length;Moliere Radius", 800, 800.0, 1600.0, 1000, 0.0, 100.0); + em_ratio_selected = showerDir.make("em_ratio_selected", + "Profile vs. Energy;Radiation Length;Moliere Radius", + 800, + 800.0, + 1600.0, + 1000, + 0.0, + 100.0); + em_nSpots_sd = + showerDir.make("em_nSpots_sd", + "Number of Gflash Spots in Sensitive Detector;Number of Spots;Number of Events", + 100, + 0.0, + 100); + em_ze_ratio = showerDir.make("em_ze_ratio", "Ratio of Energy and Z Position", 1000, 0.0, 0.001); } else { theFillHisto = false; - edm::LogInfo("HFShower") << "HFGFlash::No file is available for saving" - << " histos so the flag is set to false"; + edm::LogVerbatim("HFShower") << "HFGFlash::No file is available for saving" + << " histos so the flag is set to false"; } } #endif jCalorimeter = Gflash::kHF; - } HFGflash::~HFGflash() { @@ -87,129 +125,138 @@ HFGflash::~HFGflash() { delete theGflashNavigator; } -std::vector HFGflash::gfParameterization(const G4Step * aStep, bool onlyLong) { - double tempZCalo = 26; // Gflash::Z[jCalorimeter] +std::vector HFGflash::gfParameterization(const G4Step* aStep, bool onlyLong) { + double tempZCalo = 26; // Gflash::Z[jCalorimeter] double hfcriticalEnergy = 0.021; // Gflash::criticalEnergy std::vector hit; HFGflash::Hit oneHit; - auto const preStepPoint = aStep->GetPreStepPoint(); - auto const track = aStep->GetTrack(); + auto const preStepPoint = aStep->GetPreStepPoint(); + auto const track = aStep->GetTrack(); // This part of code is copied from the original GFlash Fortran code. // reference : hep-ex/0001020v1 - const G4double energyCutoff = 1; - const G4int maxNumberOfSpots = 10000000; + const G4double energyCutoff = 1; + const G4int maxNumberOfSpots = 10000000; - G4ThreeVector showerStartingPosition = track->GetPosition()/cm; - G4ThreeVector showerMomentum = preStepPoint->GetMomentum()/GeV; + G4ThreeVector showerStartingPosition = track->GetPosition() / cm; + G4ThreeVector showerMomentum = preStepPoint->GetMomentum() / GeV; jCalorimeter = Gflash::kHF; - const G4double invgev = 1.0/CLHEP::GeV; - G4double energy = preStepPoint->GetTotalEnergy()*invgev; // energy left in GeV + const G4double invgev = 1.0 / CLHEP::GeV; + G4double energy = preStepPoint->GetTotalEnergy() * invgev; // energy left in GeV G4double logEinc = std::log(energy); - G4double y = energy / hfcriticalEnergy; // y = E/Ec, criticalEnergy is in GeV + G4double y = energy / hfcriticalEnergy; // y = E/Ec, criticalEnergy is in GeV G4double logY = std::log(y); - - G4double nSpots = 93.0 * std::log(tempZCalo) * energy; // total number of spot due linearization - if(energy < 1.6) nSpots = 140.4 * std::log(tempZCalo) * std::pow(energy,0.876); + G4double nSpots = 93.0 * std::log(tempZCalo) * energy; // total number of spot due linearization + if (energy < 1.6) + nSpots = 140.4 * std::log(tempZCalo) * std::pow(energy, 0.876); // // implementing magnetic field effects double charge = track->GetStep()->GetPreStepPoint()->GetCharge(); - theHelix->initializeTrajectory(showerMomentum,showerStartingPosition,charge,theBField); + theHelix->initializeTrajectory(showerMomentum, showerStartingPosition, charge, theBField); G4double pathLength0 = theHelix->getPathLengthAtZ(showerStartingPosition.getZ()); - G4double pathLength = pathLength0; // this will grow along the shower development + G4double pathLength = pathLength0; // this will grow along the shower development //--- 2.2 Fix intrinsic properties of em. showers. G4double fluctuatedTmax = std::log(logY - 0.7157); - G4double fluctuatedAlpha= std::log(0.7996 +(0.4581 + 1.8628/tempZCalo)*logY); + G4double fluctuatedAlpha = std::log(0.7996 + (0.4581 + 1.8628 / tempZCalo) * logY); - G4double sigmaTmax = 1.0/( -1.4 + 1.26 * logY); - G4double sigmaAlpha = 1.0/( -0.58 + 0.86 * logY); - G4double rho = 0.705 - 0.023 * logY; - G4double sqrtPL = std::sqrt((1.0+rho)/2.0); - G4double sqrtLE = std::sqrt((1.0-rho)/2.0); + G4double sigmaTmax = 1.0 / (-1.4 + 1.26 * logY); + G4double sigmaAlpha = 1.0 / (-0.58 + 0.86 * logY); + G4double rho = 0.705 - 0.023 * logY; + G4double sqrtPL = std::sqrt((1.0 + rho) / 2.0); + G4double sqrtLE = std::sqrt((1.0 - rho) / 2.0); G4double norm1 = G4RandGauss::shoot(); G4double norm2 = G4RandGauss::shoot(); - G4double tempTmax = fluctuatedTmax + sigmaTmax*(sqrtPL*norm1 + sqrtLE*norm2); - G4double tempAlpha = fluctuatedAlpha + sigmaAlpha*(sqrtPL*norm1 - sqrtLE*norm2); + G4double tempTmax = fluctuatedTmax + sigmaTmax * (sqrtPL * norm1 + sqrtLE * norm2); + G4double tempAlpha = fluctuatedAlpha + sigmaAlpha * (sqrtPL * norm1 - sqrtLE * norm2); // tmax, alpha, beta : parameters of gamma distribution G4double tmax = std::exp(tempTmax); G4double alpha = std::exp(tempAlpha); - G4double beta = (alpha - 1.0)/tmax; + G4double beta = (alpha - 1.0) / tmax; - if (!alpha) return hit; - if (!beta) return hit; - if (alpha < 0.00001) return hit; - if (beta < 0.00001) return hit; - - // spot fluctuations are added to tmax, alpha, beta - G4double averageTmax = logY-0.858; - G4double averageAlpha = 0.21+(0.492+2.38/tempZCalo)*logY; - G4double spotTmax = averageTmax * (0.698 + .00212*tempZCalo); - G4double spotAlpha= averageAlpha * (0.639 + .00334*tempZCalo); - G4double spotBeta = (spotAlpha-1.0)/spotTmax; - - if (!spotAlpha) return hit; - if (!spotBeta) return hit; - if (spotAlpha < 0.00001) return hit; - if (spotBeta < 0.00001) return hit; + if (!alpha) + return hit; + if (!beta) + return hit; + if (alpha < 0.00001) + return hit; + if (beta < 0.00001) + return hit; -#ifdef DebugLog - LogDebug("HFShower") << "Incoming energy = " << energy << " Position (rho,z) = (" << showerStartingPosition.rho() << ", " << showerStartingPosition.z() << ")"; + // spot fluctuations are added to tmax, alpha, beta + G4double averageTmax = logY - 0.858; + G4double averageAlpha = 0.21 + (0.492 + 2.38 / tempZCalo) * logY; + G4double spotTmax = averageTmax * (0.698 + .00212 * tempZCalo); + G4double spotAlpha = averageAlpha * (0.639 + .00334 * tempZCalo); + G4double spotBeta = (spotAlpha - 1.0) / spotTmax; + + if (!spotAlpha) + return hit; + if (!spotBeta) + return hit; + if (spotAlpha < 0.00001) + return hit; + if (spotBeta < 0.00001) + return hit; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: Incoming energy = " << energy << " Position (rho,z) = (" + << showerStartingPosition.rho() << ", " << showerStartingPosition.z() << ")"; - if(theFillHisto) { + if (theFillHisto) { em_incE->Fill(energy); em_ssp_rho->Fill(showerStartingPosition.rho()); em_ssp_z->Fill(std::abs(showerStartingPosition.z())); } #endif // parameters for lateral distribution and fluctuation - G4double z1=0.0251+0.00319*logEinc; - G4double z2=0.1162-0.000381*tempZCalo; + G4double z1 = 0.0251 + 0.00319 * logEinc; + G4double z2 = 0.1162 - 0.000381 * tempZCalo; - G4double k1=0.659 - 0.00309 * tempZCalo; - G4double k2=0.645; - G4double k3=-2.59; - G4double k4=0.3585+ 0.0421*logEinc; + G4double k1 = 0.659 - 0.00309 * tempZCalo; + G4double k2 = 0.645; + G4double k3 = -2.59; + G4double k4 = 0.3585 + 0.0421 * logEinc; - G4double p1=2.623 -0.00094*tempZCalo; - G4double p2=0.401 +0.00187*tempZCalo; - G4double p3=1.313 -0.0686*logEinc; + G4double p1 = 2.623 - 0.00094 * tempZCalo; + G4double p2 = 0.401 + 0.00187 * tempZCalo; + G4double p3 = 1.313 - 0.0686 * logEinc; // // @@@ dwjang, intial tuning by comparing 20-150GeV TB data // // the width of energy response is not yet tuned. const G4double e25Scale = 1.03551; - z1 *= 9.76972e-01 - 3.85026e-01 * std::tanh(1.82790e+00*std::log(energy) - 3.66237e+00); + z1 *= 9.76972e-01 - 3.85026e-01 * std::tanh(1.82790e+00 * std::log(energy) - 3.66237e+00); p1 *= 0.96; G4double stepLengthLeft = 10000; - G4int nSpots_sd = 0; // count total number of spots in SD - G4double zInX0 = 0.0; // shower depth in X0 unit - G4double deltaZInX0 = 0.0; // segment of depth in X0 unit - G4double deltaZ = 0.0; // segment of depth in cm - G4double stepLengthLeftInX0 = 0.0; // step length left in X0 unit + G4int nSpots_sd = 0; // count total number of spots in SD + G4double zInX0 = 0.0; // shower depth in X0 unit + G4double deltaZInX0 = 0.0; // segment of depth in X0 unit + G4double deltaZ = 0.0; // segment of depth in cm + G4double stepLengthLeftInX0 = 0.0; // step length left in X0 unit - const G4double divisionStepInX0 = 0.1; //step size in X0 unit + const G4double divisionStepInX0 = 0.1; //step size in X0 unit Genfun::IncompleteGamma gammaDist; - G4double energyInGamma = 0.0; // energy in a specific depth(z) according to Gamma distribution - G4double preEnergyInGamma = 0.0; // energy calculated in a previous depth - G4double sigmaInGamma = 0.; // sigma of energy in a specific depth(z) according to Gamma distribution - G4double preSigmaInGamma = 0.0; // sigma of energy in a previous depth + G4double energyInGamma = 0.0; // energy in a specific depth(z) according to Gamma distribution + G4double preEnergyInGamma = 0.0; // energy calculated in a previous depth + G4double sigmaInGamma = 0.; // sigma of energy in a specific depth(z) according to Gamma distribution + G4double preSigmaInGamma = 0.0; // sigma of energy in a previous depth - //energy segment in Gamma distribution of shower in each step - G4double deltaEnergy =0.0 ; // energy in deltaZ - G4int spotCounter = 0; // keep track of number of spots generated + //energy segment in Gamma distribution of shower in each step + G4double deltaEnergy = 0.0; // energy in deltaZ + G4int spotCounter = 0; // keep track of number of spots generated //step increment along the shower direction G4double deltaStep = 0.0; @@ -219,119 +266,121 @@ std::vector HFGflash::gfParameterization(const G4Step * aStep, bo // this needs to be deleted manually at the end of this loop. // theGflashNavigator = new G4Navigator(); - theGflashNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()); + theGflashNavigator->SetWorldVolume( + G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()); // // loop for longitudinal integration -#ifdef DebugLog - LogDebug("HFShower") << " Energy = " << energy << " Step Length Left = " << stepLengthLeft; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: Energy = " << energy << " Step Length Left = " << stepLengthLeft; #endif - while(energy > 0.0 && stepLengthLeft > 0.0) { + while (energy > 0.0 && stepLengthLeft > 0.0) { stepLengthLeftInX0 = stepLengthLeft / Gflash::radLength[jCalorimeter]; - if ( stepLengthLeftInX0 < divisionStepInX0 ) { + if (stepLengthLeftInX0 < divisionStepInX0) { deltaZInX0 = stepLengthLeftInX0; - deltaZ = deltaZInX0 * Gflash::radLength[jCalorimeter]; + deltaZ = deltaZInX0 * Gflash::radLength[jCalorimeter]; stepLengthLeft = 0.0; } else { deltaZInX0 = divisionStepInX0; - deltaZ = deltaZInX0 * Gflash::radLength[jCalorimeter]; + deltaZ = deltaZInX0 * Gflash::radLength[jCalorimeter]; stepLengthLeft -= deltaZ; } zInX0 += deltaZInX0; - -#ifdef DebugLog - LogDebug("HFShower") << " zInX0 = " << zInX0 << " spotBeta*zInX0 = " << spotBeta*zInX0; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: zInX0 = " << zInX0 << " spotBeta*zInX0 = " << spotBeta * zInX0; #endif - if ((!zInX0) || (! (spotBeta*zInX0 != 0) ) || (zInX0 < 0.01) || - (spotBeta*zInX0 < 0.00001) || (! (zInX0*beta != 0) ) || (zInX0*beta < 0.00001)) + if ((!zInX0) || (!(spotBeta * zInX0 != 0)) || (zInX0 < 0.01) || (spotBeta * zInX0 < 0.00001) || + (!(zInX0 * beta != 0)) || (zInX0 * beta < 0.00001)) return hit; G4int nSpotsInStep = 0; -#ifdef DebugLog - LogDebug("HFShower") << " Energy - Energy Cut off = " << energy - energyCutoff; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: Energy - Energy Cut off = " << energy - energyCutoff; #endif - if ( energy > energyCutoff ) { - preEnergyInGamma = energyInGamma; + if (energy > energyCutoff) { + preEnergyInGamma = energyInGamma; gammaDist.a().setValue(alpha); //alpha - - energyInGamma = gammaDist(beta*zInX0); //beta - G4double energyInDeltaZ = energyInGamma - preEnergyInGamma; - deltaEnergy = std::min(energy,energy*energyInDeltaZ); - - preSigmaInGamma = sigmaInGamma; - gammaDist.a().setValue(spotAlpha); //alpha spot - sigmaInGamma = gammaDist(spotBeta*zInX0); //beta spot - nSpotsInStep = std::max(1,int(nSpots * (sigmaInGamma - preSigmaInGamma))); + + energyInGamma = gammaDist(beta * zInX0); //beta + G4double energyInDeltaZ = energyInGamma - preEnergyInGamma; + deltaEnergy = std::min(energy, energy * energyInDeltaZ); + + preSigmaInGamma = sigmaInGamma; + gammaDist.a().setValue(spotAlpha); //alpha spot + sigmaInGamma = gammaDist(spotBeta * zInX0); //beta spot + nSpotsInStep = std::max(1, int(nSpots * (sigmaInGamma - preSigmaInGamma))); } else { deltaEnergy = energy; - preSigmaInGamma = sigmaInGamma; - nSpotsInStep = std::max(1,int(nSpots * (1.0 - preSigmaInGamma))); + preSigmaInGamma = sigmaInGamma; + nSpotsInStep = std::max(1, int(nSpots * (1.0 - preSigmaInGamma))); } - if ( deltaEnergy > energy || (energy-deltaEnergy) < energyCutoff ) deltaEnergy = energy; + if (deltaEnergy > energy || (energy - deltaEnergy) < energyCutoff) + deltaEnergy = energy; - energy -= deltaEnergy; + energy -= deltaEnergy; - if ( spotCounter+nSpotsInStep > maxNumberOfSpots ) { + if (spotCounter + nSpotsInStep > maxNumberOfSpots) { nSpotsInStep = maxNumberOfSpots - spotCounter; - if (nSpotsInStep < 1) nSpotsInStep = 1; + if (nSpotsInStep < 1) + nSpotsInStep = 1; } - // // It begins with 0.5 of deltaZ and then icreases by 1 deltaZ - deltaStep += 0.5*deltaZ; + deltaStep += 0.5 * deltaZ; pathLength += deltaStep; - deltaStep = 0.5*deltaZ; - + deltaStep = 0.5 * deltaZ; //lateral shape and fluctuations for homogenous calo. - G4double tScale = tmax *alpha/(alpha-1.0) * (1.0 - std::exp(-fluctuatedAlpha)); - G4double tau = std::min(10.0,(zInX0 - 0.5*deltaZInX0)/tScale); - G4double rCore = z1 + z2 * tau; - G4double rTail = k1 *( std::exp(k3*(tau-k2)) + std::exp(k4*(tau-k2))); // @@ check RT3 sign - G4double p23 = (p2 - tau)/p3; - G4double probabilityWeight = p1 * std::exp( p23 - std::exp(p23) ); - + G4double tScale = tmax * alpha / (alpha - 1.0) * (1.0 - std::exp(-fluctuatedAlpha)); + G4double tau = std::min(10.0, (zInX0 - 0.5 * deltaZInX0) / tScale); + G4double rCore = z1 + z2 * tau; + G4double rTail = k1 * (std::exp(k3 * (tau - k2)) + std::exp(k4 * (tau - k2))); // @@ check RT3 sign + G4double p23 = (p2 - tau) / p3; + G4double probabilityWeight = p1 * std::exp(p23 - std::exp(p23)); // Deposition of spots according to lateral distr. // Apply absolute energy scale // Convert into MeV unit G4double emSpotEnergy = deltaEnergy / (nSpotsInStep * e25Scale * GeV); -#ifdef DebugLog - LogDebug("HFShower") << " nSpotsInStep = " << nSpotsInStep; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: nSpotsInStep = " << nSpotsInStep; #endif - for (G4int ispot = 0 ; ispot < nSpotsInStep ; ispot++) { + for (G4int ispot = 0; ispot < nSpotsInStep; ispot++) { spotCounter++; G4double u1 = G4UniformRand(); G4double u2 = G4UniformRand(); G4double rInRM = 0.0; - + if (u1 < probabilityWeight) { - rInRM = rCore * std::sqrt( u2/(1.0-u2) ); + rInRM = rCore * std::sqrt(u2 / (1.0 - u2)); } else { - rInRM = rTail * std::sqrt( u2/(1.0-u2) ); + rInRM = rTail * std::sqrt(u2 / (1.0 - u2)); } - - G4double rShower = rInRM * Gflash::rMoliere[jCalorimeter]; - + + G4double rShower = rInRM * Gflash::rMoliere[jCalorimeter]; + //Uniform & random rotation of spot along the azimuthal angle - G4double azimuthalAngle = twopi*G4UniformRand(); - + G4double azimuthalAngle = twopi * G4UniformRand(); + //Compute global position of generated spots with taking into account magnetic field //Divide deltaZ into nSpotsInStep and give a spot a global position - G4double incrementPath = (deltaZ/nSpotsInStep)*(ispot+0.5 - 0.5*nSpotsInStep); + G4double incrementPath = (deltaZ / nSpotsInStep) * (ispot + 0.5 - 0.5 * nSpotsInStep); // trajectoryPoint give a spot an imaginary point along the shower development GflashTrajectoryPoint trajectoryPoint; - theHelix->getGflashTrajectoryPoint(trajectoryPoint,pathLength+incrementPath); + theHelix->getGflashTrajectoryPoint(trajectoryPoint, pathLength + incrementPath); - G4ThreeVector SpotPosition0 = trajectoryPoint.getPosition() + rShower*std::cos(azimuthalAngle)*trajectoryPoint.getOrthogonalUnitVector() + rShower*std::sin(azimuthalAngle)*trajectoryPoint.getCrossUnitVector(); + G4ThreeVector SpotPosition0 = trajectoryPoint.getPosition() + + rShower * std::cos(azimuthalAngle) * trajectoryPoint.getOrthogonalUnitVector() + + rShower * std::sin(azimuthalAngle) * trajectoryPoint.getCrossUnitVector(); //!V.Ivanchenko - not clear if it is correct // Convert into mm unit @@ -342,60 +391,68 @@ std::vector HFGflash::gfParameterization(const G4Step * aStep, bo //--------------------------------------------------- // to make a different time for each fake step. (0.03 nsec is corresponding to 1cm step size) - timeGlobal += 0.0001*nanosecond; + timeGlobal += 0.0001 * nanosecond; + + //fill equivalent changes to a (fake) step associated with a spot - //fill equivalent changes to a (fake) step associated with a spot - - G4double zInX0_spot = std::abs(pathLength+incrementPath - pathLength0)/Gflash::radLength[jCalorimeter]; + G4double zInX0_spot = std::abs(pathLength + incrementPath - pathLength0) / Gflash::radLength[jCalorimeter]; -#ifdef DebugLog - LogDebug("HFShower") << "zInX0_spot,emSpotEnergy/GeV =" << zInX0_spot << " , " << emSpotEnergy/GeV << "emSpotEnergy/GeV =" << emSpotEnergy/GeV; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFGflash: zInX0_spot,emSpotEnergy/GeV =" << zInX0_spot << " , " + << emSpotEnergy / GeV << "emSpotEnergy/GeV =" << emSpotEnergy / GeV; #endif - if (zInX0_spot <= 0) continue; - if (emSpotEnergy <= 0) continue; - if (rShower/Gflash::rMoliere[jCalorimeter] <= 0) continue; + if (zInX0_spot <= 0) + continue; + if (emSpotEnergy <= 0) + continue; + if (rShower / Gflash::rMoliere[jCalorimeter] <= 0) + continue; - oneHit.depth = 1; + oneHit.depth = 1; -#ifdef DebugLog +#ifdef EDM_ML_DEBUG if (theFillHisto) { - em_long->Fill(SpotPosition0.z()/cm,emSpotEnergy*invgev); - em_lateral->Fill(rShower/Gflash::rMoliere[jCalorimeter],emSpotEnergy*invgev); - em_2d->Fill(SpotPosition0.z()/cm,rShower/Gflash::rMoliere[jCalorimeter],emSpotEnergy*invgev); + em_long->Fill(SpotPosition0.z() / cm, emSpotEnergy * invgev); + em_lateral->Fill(rShower / Gflash::rMoliere[jCalorimeter], emSpotEnergy * invgev); + em_2d->Fill(SpotPosition0.z() / cm, rShower / Gflash::rMoliere[jCalorimeter], emSpotEnergy * invgev); } #endif //!V.Ivanchenko what this means?? //if(SpotPosition0 == 0) continue; - double energyratio = emSpotEnergy/(preStepPoint->GetTotalEnergy()/(nSpots*e25Scale)); + double energyratio = emSpotEnergy / (preStepPoint->GetTotalEnergy() / (nSpots * e25Scale)); - if (emSpotEnergy/GeV < 0.0001) continue; - if (energyratio > 80) continue; + if (emSpotEnergy / GeV < 0.0001) + continue; + if (energyratio > 80) + continue; - double zshift =0; - if(SpotPosition0.z() > 0) zshift = 18; - if(SpotPosition0.z() < 0) zshift = -18; + double zshift = 0; + if (SpotPosition0.z() > 0) + zshift = 18; + if (SpotPosition0.z() < 0) + zshift = -18; - - G4ThreeVector gfshift(0,0,zshift*(pow(100,0.1)/pow(energy,0.1))); + G4ThreeVector gfshift(0, 0, zshift * (pow(100, 0.1) / pow(energy, 0.1))); G4ThreeVector SpotPosition = gfshift + SpotPosition0; - double LengthWeight = std::fabs(std::pow(SpotPosition0.z()/11370,1)); - if (G4UniformRand()> 0.0021 * energyratio * LengthWeight) continue; + double LengthWeight = std::fabs(std::pow(SpotPosition0.z() / 11370, 1)); + if (G4UniformRand() > 0.0021 * energyratio * LengthWeight) + continue; oneHit.position = SpotPosition; - oneHit.time = timeGlobal; - oneHit.edep = emSpotEnergy*invgev; + oneHit.time = timeGlobal; + oneHit.edep = emSpotEnergy * invgev; hit.push_back(oneHit); nSpots_sd++; - - } // end of for spot iteration - } // end of while for longitudinal integration -#ifdef DebugLog + } // end of for spot iteration + + } // end of while for longitudinal integration +#ifdef EDM_ML_DEBUG if (theFillHisto) { em_nSpots_sd->Fill(nSpots_sd); } diff --git a/SimG4CMS/Calo/src/HFNoseNumberingScheme.cc b/SimG4CMS/Calo/src/HFNoseNumberingScheme.cc index a190e36e5e0cb..092b254da075e 100644 --- a/SimG4CMS/Calo/src/HFNoseNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HFNoseNumberingScheme.cc @@ -8,49 +8,45 @@ //#define EDM_ML_DEBUG -HFNoseNumberingScheme::HFNoseNumberingScheme(const HGCalDDDConstants& hgc) : - hgcons_(hgc), mode_(hgc.geomMode()) { +HFNoseNumberingScheme::HFNoseNumberingScheme(const HGCalDDDConstants& hgc) : hgcons_(hgc), mode_(hgc.geomMode()) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCSim") << "Creating HFNoseNumberingScheme"; #endif } -uint32_t HFNoseNumberingScheme::getUnitID(int layer, int module, int cell, - int iz, const G4ThreeVector &pos, - double& wt) { +uint32_t HFNoseNumberingScheme::getUnitID( + int layer, int module, int cell, int iz, const G4ThreeVector& pos, double& wt) { // module is the copy number of the wafer as placed in the layer uint32_t index(0); wt = 1.0; - int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0); + int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0); if (cell >= 0) { - waferType = module/1000000; - waferU = module%100; - if ((module/10000)%10 > 0) waferU = -waferU; - waferV = (module/100)%100; - if ((module/100000)%10 > 0) waferV = -waferV; - cellU = cell%100; - cellV = (cell/100)%100; + waferType = module / 1000000; + waferU = module % 100; + if ((module / 10000) % 10 > 0) + waferU = -waferU; + waferV = (module / 100) % 100; + if ((module / 100000) % 10 > 0) + waferV = -waferV; + cellU = cell % 100; + cellV = (cell / 100) % 100; } else if (mode_ == HGCalGeometryMode::Hexagon8Full) { double xx = (pos.z() > 0) ? pos.x() : -pos.x(); - hgcons_.waferFromPosition(xx,pos.y(),layer,waferU,waferV,cellU, - cellV,waferType,wt); + hgcons_.waferFromPosition(xx, pos.y(), layer, waferU, waferV, cellU, cellV, waferType, wt); } if (waferType >= 0) { - index = HFNoseDetId(iz,waferType,layer,waferU,waferV,cellU,cellV).rawId(); + index = HFNoseDetId(iz, waferType, layer, waferU, waferV, cellU, cellV).rawId(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "OK WaferType " << waferType << " Wafer " - << waferU << ":" << waferV << " Cell " - << cellU << ":" << cellV; + edm::LogVerbatim("HFNSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell " + << cellU << ":" << cellV; } else { edm::LogVerbatim("HFNSim") << "Bad WaferType " << waferType; #endif } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "HFNoseNumberingScheme::i/p " << layer << ":" - << module << ":" << cell << ":" << iz << ":" - << pos.x() << ":" << pos.y() << ":" << pos.z() - << " ID " << std::hex << index << std::dec - << " wt " << wt; + edm::LogVerbatim("HFNSim") << "HFNoseNumberingScheme::i/p " << layer << ":" << module << ":" << cell << ":" << iz + << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex << index + << std::dec << " wt " << wt; #endif return index; } diff --git a/SimG4CMS/Calo/src/HFNoseSD.cc b/SimG4CMS/Calo/src/HFNoseSD.cc index a15f253f5d8ec..0fb13ed3c8a3f 100644 --- a/SimG4CMS/Calo/src/HFNoseSD.cc +++ b/SimG4CMS/Calo/src/HFNoseSD.cc @@ -27,155 +27,141 @@ //#define EDM_ML_DEBUG -HFNoseSD::HFNoseSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager): - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("HFNoseSD").getParameter("TimeSliceUnit")), - p.getParameter("HFNoseSD").getParameter("IgnoreTrackID")), - hgcons_(nullptr), slopeMin_(0), levelT1_(99), levelT2_(99), - tan30deg_(std::tan(30.0*CLHEP::deg)) { - - numberingScheme_.reset(nullptr); mouseBite_.reset(nullptr); +HFNoseSD::HFNoseSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("HFNoseSD").getParameter("TimeSliceUnit")), + p.getParameter("HFNoseSD").getParameter("IgnoreTrackID")), + hgcons_(nullptr), + slopeMin_(0), + levelT1_(99), + levelT2_(99), + tan30deg_(std::tan(30.0 * CLHEP::deg)) { + numberingScheme_.reset(nullptr); + mouseBite_.reset(nullptr); edm::ParameterSet m_HFN = p.getParameter("HFNoseSD"); - eminHit_ = m_HFN.getParameter("EminHit")*CLHEP::MeV; - fiducialCut_ = m_HFN.getParameter("FiducialCut"); - distanceFromEdge_= m_HFN.getParameter("DistanceFromEdge"); - storeAllG4Hits_ = m_HFN.getParameter("StoreAllG4Hits"); - rejectMB_ = m_HFN.getParameter("RejectMouseBite"); - waferRot_ = m_HFN.getParameter("RotatedWafer"); - cornerMinMask_ = m_HFN.getParameter("CornerMinMask"); - angles_ = m_HFN.getUntrackedParameter>("WaferAngles"); - - nameX_ = ((name.find("HFNoseHits")!=std::string::npos) ? - "HGCalHFNoseSensitive" : "HFNoseSensitive"); - - if(storeAllG4Hits_) { + eminHit_ = m_HFN.getParameter("EminHit") * CLHEP::MeV; + fiducialCut_ = m_HFN.getParameter("FiducialCut"); + distanceFromEdge_ = m_HFN.getParameter("DistanceFromEdge"); + storeAllG4Hits_ = m_HFN.getParameter("StoreAllG4Hits"); + rejectMB_ = m_HFN.getParameter("RejectMouseBite"); + waferRot_ = m_HFN.getParameter("RotatedWafer"); + cornerMinMask_ = m_HFN.getParameter("CornerMinMask"); + angles_ = m_HFN.getUntrackedParameter>("WaferAngles"); + + nameX_ = ((name.find("HFNoseHits") != std::string::npos) ? "HGCalHFNoseSensitive" : "HFNoseSensitive"); + + if (storeAllG4Hits_) { setUseMap(false); setNumberCheckedHits(0); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim")<< "**************************************************" - << "\n" - << "* *" - << "\n" - << "* Constructing a HFNoseSD with name " << name << "\n" - << "* *" - << "\n" - << "**************************************************"; + edm::LogVerbatim("HFNSim") << "**************************************************" + << "\n" + << "* *" + << "\n" + << "* Constructing a HFNoseSD with name " << name << "\n" + << "* *" + << "\n" + << "**************************************************"; #endif - edm::LogVerbatim("HFNSim") << "HFNoseSD:: Threshold for storing hits: " - << eminHit_ << " for " << name; - edm::LogVerbatim("HFNSim") << "Flag for storing individual Geant4 Hits " - << storeAllG4Hits_; + edm::LogVerbatim("HFNSim") << "HFNoseSD:: Threshold for storing hits: " << eminHit_ << " for " << name; + edm::LogVerbatim("HFNSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_; edm::LogVerbatim("HFNSim") << "Fiducial volume cut with cut from eta/phi " - << "boundary " << fiducialCut_ << " at " - << distanceFromEdge_; - edm::LogVerbatim("HFNSim") << "Reject MosueBite Flag: " << rejectMB_ - << " cuts along " << angles_.size() << " axes: " - << angles_[0] << ", " << angles_[1]; + << "boundary " << fiducialCut_ << " at " << distanceFromEdge_; + edm::LogVerbatim("HFNSim") << "Reject MosueBite Flag: " << rejectMB_ << " cuts along " << angles_.size() + << " axes: " << angles_[0] << ", " << angles_[1]; } double HFNoseSD::getEnergyDeposit(const G4Step* aStep) { - double r = aStep->GetPreStepPoint()->GetPosition().perp(); double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z()); #ifdef EDM_ML_DEBUG - G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); + G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName(); - G4LogicalVolume* lv = - aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); - edm::LogVerbatim("HFNSim") << "HFNoseSD: Hit from standard path from " - << lv->GetName() << " for Track " - << aStep->GetTrack()->GetTrackID() << " (" - << parCode << ":" << parName << ") R = " << r - << " Z = " << z << " slope = " << r/z << ":" - << slopeMin_; + G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); + edm::LogVerbatim("HFNSim") << "HFNoseSD: Hit from standard path from " << lv->GetName() << " for Track " + << aStep->GetTrack()->GetTrackID() << " (" << parCode << ":" << parName << ") R = " << r + << " Z = " << z << " slope = " << r / z << ":" << slopeMin_; #endif // Apply fiducial cut - if (r < z*slopeMin_) { + if (r < z * slopeMin_) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HFNSim") << "HFNoseSD: Fiducial Volume cut"; #endif - return 0.0; + return 0.0; } - double wt1 = getResponseWt(aStep->GetTrack()); - double wt2 = aStep->GetTrack()->GetWeight(); - double destep = weight_*wt1*(aStep->GetTotalEnergyDeposit()); - if (wt2 > 0) destep *= wt2; + double wt1 = getResponseWt(aStep->GetTrack()); + double wt2 = aStep->GetTrack()->GetWeight(); + double destep = weight_ * wt1 * (aStep->GetTotalEnergyDeposit()); + if (wt2 > 0) + destep *= wt2; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "HFNoseSD: weights= " << weight_ << ":" - << wt1 << ":" << wt2 << " Total weight " - << weight_*wt1*wt2 << " deStep: " - << aStep->GetTotalEnergyDeposit() - << ":" <GetTotalEnergyDeposit() << ":" << destep; #endif return destep; } -uint32_t HFNoseSD::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t HFNoseSD::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); - //determine the exact position in global coordinates in the mass geometry - G4ThreeVector hitPoint = preStepPoint->GetPosition(); + //determine the exact position in global coordinates in the mass geometry + G4ThreeVector hitPoint = preStepPoint->GetPosition(); float globalZ = touch->GetTranslation(0).z(); - int iz( globalZ>0 ? 1 : -1); + int iz(globalZ > 0 ? 1 : -1); int layer, module, cell; - if ((touch->GetHistoryDepth() == levelT1_) || - (touch->GetHistoryDepth() == levelT2_)) { - layer = touch->GetReplicaNumber(0); + if ((touch->GetHistoryDepth() == levelT1_) || (touch->GetHistoryDepth() == levelT2_)) { + layer = touch->GetReplicaNumber(0); module = -1; - cell = -1; + cell = -1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "DepthsTop: " << touch->GetHistoryDepth() - << ":" << levelT1_ << ":" << levelT2_ - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HFNSim") << "DepthsTop: " << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_ + << " name " << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" + << module << ":" << cell; #endif } else { - layer = touch->GetReplicaNumber(3); + layer = touch->GetReplicaNumber(3); module = touch->GetReplicaNumber(2); - cell = touch->GetReplicaNumber(1); + cell = touch->GetReplicaNumber(1); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "DepthsInside: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HFNSim") << "DepthsInside: " << touch->GetHistoryDepth() << " name " + << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" << module + << ":" << cell; #endif } #ifdef EDM_ML_DEBUG G4Material* mat = aStep->GetPreStepPoint()->GetMaterial(); - edm::LogVerbatim("HFNSim") << "Depths: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << ":" << touch->GetReplicaNumber(0) << " " - << touch->GetVolume(1)->GetName() - << ":" << touch->GetReplicaNumber(1) << " " - << touch->GetVolume(2)->GetName() - << ":" << touch->GetReplicaNumber(2) << " " - << touch->GetVolume(3)->GetName() - << ":" << touch->GetReplicaNumber(3) << " " - << touch->GetVolume(4)->GetName() - << ":" << touch->GetReplicaNumber(4) << " " - << " layer:module:cell " << layer << ":" - << module << ":" << cell << " Material " - << mat->GetName() << ":" << mat->GetRadlen(); + edm::LogVerbatim("HFNSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName() + << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":" + << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":" + << touch->GetReplicaNumber(2) << " " << touch->GetVolume(3)->GetName() << ":" + << touch->GetReplicaNumber(3) << " " << touch->GetVolume(4)->GetName() << ":" + << touch->GetReplicaNumber(4) << " " + << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material " + << mat->GetName() << ":" << mat->GetRadlen(); #endif // The following statement should be examined later before elimination - if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) return 0; - - uint32_t id = setDetUnitId (layer, module, cell, iz, hitPoint); + if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) + return 0; + + uint32_t id = setDetUnitId(layer, module, cell, iz, hitPoint); if (rejectMB_ && id != 0) { auto uv = HFNoseDetId(id).waferUV(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "ID " << std::hex << id << std::dec - << " " << HFNoseDetId(id); + edm::LogVerbatim("HFNSim") << "ID " << std::hex << id << std::dec << " " << HFNoseDetId(id); #endif if (mouseBite_->exclude(hitPoint, iz, uv.first, uv.second)) { id = 0; @@ -187,56 +173,51 @@ uint32_t HFNoseSD::setDetUnitId(const G4Step * aStep) { return id; } -void HFNoseSD::update(const BeginOfJob * job) { - +void HFNoseSD::update(const BeginOfJob* job) { const edm::EventSetup* es = (*job)(); - edm::ESHandle hdc; - es->get().get(nameX_,hdc); + edm::ESHandle hdc; + es->get().get(nameX_, hdc); if (hdc.isValid()) { - hgcons_ = hdc.product(); - geom_mode_ = hgcons_->geomMode(); - slopeMin_ = hgcons_->minSlope(); - levelT1_ = hgcons_->levelTop(0); - levelT2_ = hgcons_->levelTop(1); + hgcons_ = hdc.product(); + geom_mode_ = hgcons_->geomMode(); + slopeMin_ = hgcons_->minSlope(); + levelT1_ = hgcons_->levelTop(0); + levelT2_ = hgcons_->levelTop(1); double waferSize = hgcons_->waferSize(false); double mouseBite = hgcons_->mouseBite(false); - mouseBiteCut_ = waferSize*tan30deg_ - mouseBite; + mouseBiteCut_ = waferSize * tan30deg_ - mouseBite; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HFNSim") << "HFNoseSD::Initialized with mode " - << geom_mode_ << " Slope cut " << slopeMin_ - << " top Level " << levelT1_ << ":" << levelT2_ - << " wafer " << waferSize << ":" << mouseBite; + edm::LogVerbatim("HFNSim") << "HFNoseSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_ + << " top Level " << levelT1_ << ":" << levelT2_ << " wafer " << waferSize << ":" + << mouseBite; #endif numberingScheme_.reset(new HFNoseNumberingScheme(*hgcons_)); - if (rejectMB_) - mouseBite_.reset(new HGCMouseBite(*hgcons_,angles_,mouseBiteCut_, - waferRot_)); + if (rejectMB_) + mouseBite_.reset(new HGCMouseBite(*hgcons_, angles_, mouseBiteCut_, waferRot_)); } else { throw cms::Exception("Unknown", "HFNoseSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } } -void HFNoseSD::initRun() { -} +void HFNoseSD::initRun() {} bool HFNoseSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_)); } -uint32_t HFNoseSD::setDetUnitId (int layer, int module, int cell, int iz, - G4ThreeVector &pos) { - uint32_t id = numberingScheme_ ? - numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; +uint32_t HFNoseSD::setDetUnitId(int layer, int module, int cell, int iz, G4ThreeVector& pos) { + uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; if (cornerMinMask_ > 2) { - if (hgcons_->maskCell(DetId(id), cornerMinMask_)) id = 0; + if (hgcons_->maskCell(DetId(id), cornerMinMask_)) + id = 0; } return id; } -bool HFNoseSD::isItinFidVolume (const G4ThreeVector& pos) { +bool HFNoseSD::isItinFidVolume(const G4ThreeVector& pos) { if (fiducialCut_) { - return (hgcons_->distFromEdgeHex(pos.x(),pos.y(),pos.z()) > distanceFromEdge_); + return (hgcons_->distFromEdgeHex(pos.x(), pos.y(), pos.z()) > distanceFromEdge_); } else { return true; } diff --git a/SimG4CMS/Calo/src/HFShower.cc b/SimG4CMS/Calo/src/HFShower.cc index bf0f66c747ed6..922ebcea14af3 100644 --- a/SimG4CMS/Calo/src/HFShower.cc +++ b/SimG4CMS/Calo/src/HFShower.cc @@ -19,312 +19,293 @@ #include "CLHEP/Units/GlobalPhysicalConstants.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" -//#define DebugLog +//#define EDM_ML_DEBUG -#include - -HFShower::HFShower(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p, int chk) : cherenkov(nullptr), - fibre(nullptr), - chkFibre(chk) { +#include +HFShower::HFShower(const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p, int chk) + : cherenkov(nullptr), fibre(nullptr), chkFibre(chk) { edm::ParameterSet m_HF = p.getParameter("HFShower"); - applyFidCut = m_HF.getParameter("ApplyFiducialCut"); - probMax = m_HF.getParameter("ProbMax"); + applyFidCut = m_HF.getParameter("ApplyFiducialCut"); + probMax = m_HF.getParameter("ProbMax"); - edm::LogVerbatim("HFShower") << "HFShower:: Maximum probability cut off " - << probMax << " Check flag " << chkFibre; + edm::LogVerbatim("HFShower") << "HFShower:: Maximum probability cut off " << probMax << " Check flag " << chkFibre; cherenkov = new HFCherenkov(m_HF); - fibre = new HFFibre(name, cpv, p); + fibre = new HFFibre(name, cpv, p); } -HFShower::~HFShower() { - if (cherenkov) delete cherenkov; - if (fibre) delete fibre; +HFShower::~HFShower() { + if (cherenkov) + delete cherenkov; + if (fibre) + delete fibre; } -std::vector HFShower::getHits(const G4Step * aStep, double weight) { - +std::vector HFShower::getHits(const G4Step *aStep, double weight) { std::vector hits; - int nHit = 0; + int nHit = 0; - double edep = weight*(aStep->GetTotalEnergyDeposit()); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits: energy " << aStep->GetTotalEnergyDeposit() << " weight " << weight << " edep " << edep; + double edep = weight * (aStep->GetTotalEnergyDeposit()); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits: energy " << aStep->GetTotalEnergyDeposit() << " weight " << weight + << " edep " << edep; #endif - double stepl = 0.; + double stepl = 0.; if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) stepl = aStep->GetStepLength(); if ((edep == 0.) || (stepl == 0.)) { -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit; #endif return hits; } const G4Track *aTrack = aStep->GetTrack(); const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle(); - + HFShower::Hit hit; - double energy = aParticle->GetTotalEnergy(); + double energy = aParticle->GetTotalEnergy(); double momentum = aParticle->GetTotalMomentum(); - double pBeta = momentum / energy; - double dose = 0.; - int npeDose = 0; + double pBeta = momentum / energy; + double dose = 0.; + int npeDose = 0; - const G4ThreeVector& momentumDir = aParticle->GetMomentumDirection(); + const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection(); const G4ParticleDefinition *particleDef = aTrack->GetDefinition(); - - const G4StepPoint * preStepPoint = aStep->GetPreStepPoint(); - const G4ThreeVector& globalPos = preStepPoint->GetPosition(); - G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); + + const G4StepPoint *preStepPoint = aStep->GetPreStepPoint(); + const G4ThreeVector &globalPos = preStepPoint->GetPosition(); + G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); //double zv = std::abs(globalPos.z()) - gpar[4] - 0.5*gpar[1]; - double zv = std::abs(globalPos.z()) - gpar[4]; - G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv); - G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()-> - GetTopTransform().TransformAxis(momentumDir); + double zv = std::abs(globalPos.z()) - gpar[4]; + G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv); + G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir); // @@ Here the depth should be changed (Fibers all long in Geometry!) - int depth = 1; - int npmt = 0; - bool ok = true; + int depth = 1; + int npmt = 0; + bool ok = true; if (zv < 0. || zv > gpar[1]) { - ok = false; // beyond the fiber in Z + ok = false; // beyond the fiber in Z } if (ok && applyFidCut) { npmt = HFFibreFiducial::PMTNumber(globalPos); if (npmt <= 0) { ok = false; - } else if (npmt > 24) { // a short fibre + } else if (npmt > 24) { // a short fibre if (zv > gpar[0]) { - depth = 2; + depth = 2; } else { ok = false; } } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower: npmt " << npmt - << " zv " << std::abs(globalPos.z()) - << ":" << gpar[4] << ":" << zv << ":" - << gpar[0] << " ok " << ok << " depth " << depth; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower: npmt " << npmt << " zv " << std::abs(globalPos.z()) << ":" << gpar[4] + << ":" << zv << ":" << gpar[0] << " ok " << ok << " depth " << depth; #endif } else { - depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10; // All LONG! + depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG! } - G4ThreeVector translation = - preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation(); - - double u = localMom.x(); - double v = localMom.y(); - double w = localMom.z(); - double zCoor = localPos.z(); - double zFibre = (0.5*gpar[1]-zCoor-translation.z()); - double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); - double time = fibre->tShift(localPos, depth, chkFibre); - -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " - << zCoor << "(" << globalPos.z() << ") " << zFibre - << " Trans " << translation << " Time " << tSlice - << " " << time << "\n Direction " - << momentumDir << " Local " << localMom; -#endif + G4ThreeVector translation = preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation(); + + double u = localMom.x(); + double v = localMom.y(); + double w = localMom.z(); + double zCoor = localPos.z(); + double zFibre = (0.5 * gpar[1] - zCoor - translation.z()); + double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); + double time = fibre->tShift(localPos, depth, chkFibre); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") " + << zFibre << " Trans " << translation << " Time " << tSlice << " " << time + << "\n Direction " << momentumDir << " Local " << localMom; +#endif // Here npe should be 0 if there is no fiber (@@ M.K.) int npe = 1; std::vector wavelength; std::vector momz; - if (!applyFidCut) { // _____ Tmp close of the cherenkov function - if (ok) npe = cherenkov->computeNPE(aStep,particleDef,pBeta,u,v,w,stepl,zFibre,dose, npeDose); + if (!applyFidCut) { // _____ Tmp close of the cherenkov function + if (ok) + npe = cherenkov->computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose); wavelength = cherenkov->getWL(); - momz = cherenkov->getMom(); - } // ^^^^^ End of Tmp close of the cherenkov function - if(ok && npe>0) { - for (int i = 0; iattLength(wavelength[i]); - double r1 = G4UniformRand(); - double r2 = G4UniformRand(); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits: " << i << " attenuation " - << r1 <<":" << exp(-p*zFibre) << " r2 " << r2 - << ":" << probMax << " Survive: " - << (r1 <= exp(-p*zFibre) && r2 <= probMax); + momz = cherenkov->getMom(); + } // ^^^^^ End of Tmp close of the cherenkov function + if (ok && npe > 0) { + for (int i = 0; i < npe; ++i) { + double p = 1.; + if (!applyFidCut) + p = fibre->attLength(wavelength[i]); + double r1 = G4UniformRand(); + double r2 = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits: " << i << " attenuation " << r1 << ":" << exp(-p * zFibre) + << " r2 " << r2 << ":" << probMax + << " Survive: " << (r1 <= exp(-p * zFibre) && r2 <= probMax); #endif - if (applyFidCut || chkFibre < 0 || (r1 <= exp(-p*zFibre) && r2 <= probMax)) { - hit.depth = depth; - hit.time = tSlice+time; + if (applyFidCut || chkFibre < 0 || (r1 <= exp(-p * zFibre) && r2 <= probMax)) { + hit.depth = depth; + hit.time = tSlice + time; if (!applyFidCut) { - hit.wavelength = wavelength[i]; // Tmp - hit.momentum = momz[i]; // Tmp + hit.wavelength = wavelength[i]; // Tmp + hit.momentum = momz[i]; // Tmp } else { - hit.wavelength = 300.; // Tmp - hit.momentum = 1.; // Tmp + hit.wavelength = 300.; // Tmp + hit.momentum = 1.; // Tmp } - hit.position = globalPos; + hit.position = globalPos; hits.push_back(hit); nHit++; } } } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit; - for (int i=0; i HFShower::getHits(const G4Step * aStep, - bool forLibraryProducer, - double zoffset) { - +std::vector HFShower::getHits(const G4Step *aStep, bool forLibraryProducer, double zoffset) { std::vector hits; - int nHit = 0; + int nHit = 0; - double edep = aStep->GetTotalEnergyDeposit(); - double stepl = 0.; + double edep = aStep->GetTotalEnergyDeposit(); + double stepl = 0.; if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) stepl = aStep->GetStepLength(); if ((edep == 0.) || (stepl == 0.)) { -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit; #endif return hits; } const G4Track *aTrack = aStep->GetTrack(); const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle(); - + HFShower::Hit hit; - double energy = aParticle->GetTotalEnergy(); + double energy = aParticle->GetTotalEnergy(); double momentum = aParticle->GetTotalMomentum(); - double pBeta = momentum / energy; - double dose = 0.; - int npeDose = 0; + double pBeta = momentum / energy; + double dose = 0.; + int npeDose = 0; - const G4ThreeVector& momentumDir = aParticle->GetMomentumDirection(); + const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection(); G4ParticleDefinition *particleDef = aTrack->GetDefinition(); - - G4StepPoint * preStepPoint = aStep->GetPreStepPoint(); - const G4ThreeVector& globalPos = preStepPoint->GetPosition(); - G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); + + G4StepPoint *preStepPoint = aStep->GetPreStepPoint(); + const G4ThreeVector &globalPos = preStepPoint->GetPosition(); + G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); //double zv = std::abs(globalPos.z()) - gpar[4] - 0.5*gpar[1]; //double zv = std::abs(globalPos.z()) - gpar[4]; - double zv = gpar[1]-(std::abs(globalPos.z()) - zoffset); - G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv); - G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()-> - GetTopTransform().TransformAxis(momentumDir); + double zv = gpar[1] - (std::abs(globalPos.z()) - zoffset); + G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv); + G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir); // @@ Here the depth should be changed (Fibers all long in Geometry!) - int depth = 1; - int npmt = 0; - bool ok = true; + int depth = 1; + int npmt = 0; + bool ok = true; if (zv < 0. || zv > gpar[1]) { - ok = false; // beyond the fiber in Z + ok = false; // beyond the fiber in Z } if (ok && applyFidCut) { npmt = HFFibreFiducial::PMTNumber(globalPos); if (npmt <= 0) { ok = false; - } else if (npmt > 24) { // a short fibre + } else if (npmt > 24) { // a short fibre if (zv > gpar[0]) { - depth = 2; + depth = 2; } else { ok = false; } } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower: npmt " << npmt - << " zv " << std::abs(globalPos.z()) - << ":" << gpar[4] << ":" << zv << ":" - << gpar[0] << " ok " << ok << " depth " << depth; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower: npmt " << npmt << " zv " << std::abs(globalPos.z()) << ":" << gpar[4] + << ":" << zv << ":" << gpar[0] << " ok " << ok << " depth " << depth; #endif } else { - depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10; // All LONG! + depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG! } - G4ThreeVector translation = - preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation(); - - double u = localMom.x(); - double v = localMom.y(); - double w = localMom.z(); - double zCoor = localPos.z(); - double zFibre = (0.5*gpar[1]-zCoor-translation.z()); - double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); - double time = fibre->tShift(localPos, depth, chkFibre); - -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " <GetTouchable()->GetVolume(1)->GetObjectTranslation(); + + double u = localMom.x(); + double v = localMom.y(); + double w = localMom.z(); + double zCoor = localPos.z(); + double zFibre = (0.5 * gpar[1] - zCoor - translation.z()); + double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); + double time = fibre->tShift(localPos, depth, chkFibre); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") " + << zFibre << " Trans " << translation << " Time " << tSlice << " " << time + << "\n Direction " << momentumDir << " Local " << localMom; +#endif // Here npe should be 0 if there is no fiber (@@ M.K.) int npe = 1; std::vector wavelength; std::vector momz; - if (!applyFidCut) { // _____ Tmp close of the cherenkov function - if (ok) npe = cherenkov->computeNPE(aStep,particleDef,pBeta,u,v,w,stepl,zFibre,dose, npeDose); + if (!applyFidCut) { // _____ Tmp close of the cherenkov function + if (ok) + npe = cherenkov->computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose); wavelength = cherenkov->getWL(); - momz = cherenkov->getMom(); - } // ^^^^^ End of Tmp close of the cherenkov function - if (ok && npe>0) { - for (int i = 0; iattLength(wavelength[i]); - double r1 = G4UniformRand(); - double r2 = G4UniformRand(); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits: " << i << " attenuation " - << r1 << ":" << exp(-p*zFibre) << " r2 " << r2 - << ":" << probMax << " Survive: " - << (r1 <= exp(-p*zFibre) && r2 <= probMax); + momz = cherenkov->getMom(); + } // ^^^^^ End of Tmp close of the cherenkov function + if (ok && npe > 0) { + for (int i = 0; i < npe; ++i) { + double p = 1.; + if (!applyFidCut) + p = fibre->attLength(wavelength[i]); + double r1 = G4UniformRand(); + double r2 = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits: " << i << " attenuation " << r1 << ":" << exp(-p * zFibre) + << " r2 " << r2 << ":" << probMax + << " Survive: " << (r1 <= exp(-p * zFibre) && r2 <= probMax); #endif - if (applyFidCut || chkFibre < 0 || (r1 <= exp(-p*zFibre) && r2 <= probMax)) { - hit.depth = depth; - hit.time = tSlice+time; + if (applyFidCut || chkFibre < 0 || (r1 <= exp(-p * zFibre) && r2 <= probMax)) { + hit.depth = depth; + hit.time = tSlice + time; if (!applyFidCut) { - hit.wavelength = wavelength[i]; // Tmp - hit.momentum = momz[i]; // Tmp + hit.wavelength = wavelength[i]; // Tmp + hit.momentum = momz[i]; // Tmp } else { - hit.wavelength = 300.; // Tmp - hit.momentum = 1.; // Tmp + hit.wavelength = 300.; // Tmp + hit.momentum = 1.; // Tmp } - hit.position = globalPos; + hit.position = globalPos; hits.push_back(hit); nHit++; } } } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit; - for (int i=0; i HFShower::getHits(const G4Step * aStep, bool forLibrary) { +std::vector HFShower::getHits(const G4Step *aStep, bool forLibrary) { std::vector hits; - int nHit = 0; + int nHit = 0; - double edep = aStep->GetTotalEnergyDeposit(); - double stepl = 0.; + double edep = aStep->GetTotalEnergyDeposit(); + double stepl = 0.; if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) stepl = aStep->GetStepLength(); if ((edep == 0.) || (stepl == 0.)) { -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShower::getHits: Number of Hits " << nHit; #endif return hits; @@ -334,78 +315,73 @@ std::vector HFShower::getHits(const G4Step * aStep, bool forLibra const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle(); HFShower::Hit hit; - double energy = aParticle->GetTotalEnergy(); + double energy = aParticle->GetTotalEnergy(); double momentum = aParticle->GetTotalMomentum(); - double pBeta = momentum / energy; - double dose = 0.; - int npeDose = 0; + double pBeta = momentum / energy; + double dose = 0.; + int npeDose = 0; - const G4ThreeVector& momentumDir = aParticle->GetMomentumDirection(); + const G4ThreeVector &momentumDir = aParticle->GetMomentumDirection(); G4ParticleDefinition *particleDef = aTrack->GetDefinition(); - const G4StepPoint * preStepPoint = aStep->GetPreStepPoint(); - const G4ThreeVector& globalPos = preStepPoint->GetPosition(); - G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); - double zv = std::abs(globalPos.z()) - gpar[4] - 0.5*gpar[1]; - G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv); - G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()-> - GetTopTransform().TransformAxis(momentumDir); + const G4StepPoint *preStepPoint = aStep->GetPreStepPoint(); + const G4ThreeVector &globalPos = preStepPoint->GetPosition(); + G4String name = preStepPoint->GetTouchable()->GetSolid(0)->GetName(); + double zv = std::abs(globalPos.z()) - gpar[4] - 0.5 * gpar[1]; + G4ThreeVector localPos = G4ThreeVector(globalPos.x(), globalPos.y(), zv); + G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(momentumDir); // @@ Here the depth should be changed (Fibers are all long in Geometry!) - int depth = 1; - int npmt = 0; - bool ok = true; + int depth = 1; + int npmt = 0; + bool ok = true; if (zv < 0 || zv > gpar[1]) { - ok = false; // beyond the fiber in Z + ok = false; // beyond the fiber in Z } if (ok && applyFidCut) { - npmt = HFFibreFiducial:: PMTNumber(globalPos); + npmt = HFFibreFiducial::PMTNumber(globalPos); if (npmt <= 0) { ok = false; - } else if (npmt > 24) { // a short fibre + } else if (npmt > 24) { // a short fibre if (zv > gpar[0]) { - depth = 2; + depth = 2; } else { ok = false; } } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower:getHits(SL): npmt " << npmt - << " zv " << std::abs(globalPos.z()) - << ":" << gpar[4] << ":" << zv << ":" - << gpar[0] << " ok " << ok << " depth " << depth; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower:getHits(SL): npmt " << npmt << " zv " << std::abs(globalPos.z()) << ":" + << gpar[4] << ":" << zv << ":" << gpar[0] << " ok " << ok << " depth " << depth; #endif } else { - depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10; // All LONG! + depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0)) % 10; // All LONG! } - G4ThreeVector translation = - preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation(); - - double u = localMom.x(); - double v = localMom.y(); - double w = localMom.z(); - double zCoor = localPos.z(); - double zFibre = (0.5*gpar[1]-zCoor-translation.z()); - double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); - double time = fibre->tShift(localPos, depth, chkFibre); - -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShower::getHits(SL): in " << name << " Z " - << zCoor << "(" << globalPos.z() << ") " << zFibre - << " Trans " << translation << " Time " << tSlice - << " " << time << "\n Direction " - << momentumDir << " Local " << localMom; + G4ThreeVector translation = preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation(); + + double u = localMom.x(); + double v = localMom.y(); + double w = localMom.z(); + double zCoor = localPos.z(); + double zFibre = (0.5 * gpar[1] - zCoor - translation.z()); + double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); + double time = fibre->tShift(localPos, depth, chkFibre); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower::getHits(SL): in " << name << " Z " << zCoor << "(" << globalPos.z() << ") " + << zFibre << " Trans " << translation << " Time " << tSlice << " " << time + << "\n Direction " << momentumDir << " Local " << localMom; #endif // npe should be 0 int npe = 0; - if(ok) npe = cherenkov->computeNPE(aStep,particleDef,pBeta,u,v,w, stepl,zFibre, dose, npeDose); + if (ok) + npe = cherenkov->computeNPE(aStep, particleDef, pBeta, u, v, w, stepl, zFibre, dose, npeDose); std::vector wavelength = cherenkov->getWL(); - std::vector momz = cherenkov->getMom(); + std::vector momz = cherenkov->getMom(); - for (int i = 0; i HFShower::getHits(const G4Step * aStep, bool forLibra return hits; } -std::vector HFShower::getDDDArray(const std::string & str, - const DDsvalues_type & sv, - int & nmin) { -#ifdef DebugLog - LogDebug("HFShower") << "HFShower:getDDDArray called for " << str - << " with nMin " << nmin; +std::vector HFShower::getDDDArray(const std::string &str, const DDsvalues_type &sv, int &nmin) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShower:getDDDArray called for " << str << " with nMin " << nmin; #endif DDValue value(str); if (DDfetch(&sv, value)) { -#ifdef DebugLog - LogDebug("HFShower") << value; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector &fvec = value.doubles(); int nval = fvec.size(); if (nmin > 0) { if (nval < nmin) { - edm::LogError("HFShower") << "HFShower : # of " << str << " bins " - << nval << " < " << nmin << " ==> illegal"; - throw cms::Exception("Unknown", "HFShower") - << "nval < nmin for array " << str << "\n"; + edm::LogError("HFShower") << "HFShower : # of " << str << " bins " << nval << " < " << nmin << " ==> illegal"; + throw cms::Exception("Unknown", "HFShower") << "nval < nmin for array " << str << "\n"; } } else { if (nval < 2) { - edm::LogError("HFShower") << "HFShower : # of " << str << " bins " << nval - << " < 2 ==> illegal" << " (nmin=" << nmin << ")"; + edm::LogError("HFShower") << "HFShower : # of " << str << " bins " << nval << " < 2 ==> illegal" + << " (nmin=" << nmin << ")"; throw cms::Exception("Unknown", "HFShower") << "nval < 2 for array " << str; } } @@ -450,9 +421,10 @@ std::vector HFShower::getDDDArray(const std::string & str, } } -void HFShower::initRun(const HcalDDDSimConstants* hcons) { - +void HFShower::initRun(const HcalDDDSimConstants *hcons) { //Special Geometry parameters gpar = hcons->getGparHF(); - if (fibre) { fibre->initRun(hcons); } + if (fibre) { + fibre->initRun(hcons); + } } diff --git a/SimG4CMS/Calo/src/HFShowerFibreBundle.cc b/SimG4CMS/Calo/src/HFShowerFibreBundle.cc index 614092c4e9b36..9c6a50995e013 100644 --- a/SimG4CMS/Calo/src/HFShowerFibreBundle.cc +++ b/SimG4CMS/Calo/src/HFShowerFibreBundle.cc @@ -18,64 +18,59 @@ #include "CLHEP/Units/GlobalSystemOfUnits.h" #include -//#define DebugLog - -HFShowerFibreBundle::HFShowerFibreBundle(const std::string & name, - const DDCompactView & cpv, - edm::ParameterSet const & p) { +//#define EDM_ML_DEBUG +HFShowerFibreBundle::HFShowerFibreBundle(const std::string& name, + const DDCompactView& cpv, + edm::ParameterSet const& p) { edm::ParameterSet m_HF1 = p.getParameter("HFShowerStraightBundle"); - facTube = m_HF1.getParameter("FactorBundle"); - cherenkov1 = new HFCherenkov(m_HF1); + facTube = m_HF1.getParameter("FactorBundle"); + cherenkov1 = new HFCherenkov(m_HF1); edm::ParameterSet m_HF2 = p.getParameter("HFShowerConicalBundle"); - facCone = m_HF2.getParameter("FactorBundle"); - cherenkov2 = new HFCherenkov(m_HF2); - edm::LogInfo("HFShower") << "HFShowerFibreBundle intialized with factors: " - << facTube << " for the straight portion and " - << facCone << " for the curved portion"; + facCone = m_HF2.getParameter("FactorBundle"); + cherenkov2 = new HFCherenkov(m_HF2); + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle intialized with factors: " << facTube + << " for the straight portion and " << facCone << " for the curved portion"; //Special Geometry parameters std::string attribute = "Volume"; - std::string value = "HFPMT"; - DDSpecificsMatchesValueFilter filter1{DDValue(attribute,value,0)}; - DDFilteredView fv1(cpv,filter1); + std::string value = "HFPMT"; + DDSpecificsMatchesValueFilter filter1{DDValue(attribute, value, 0)}; + DDFilteredView fv1(cpv, filter1); if (fv1.firstChild()) { DDsvalues_type sv1(fv1.mergedSpecifics()); std::vector neta; - neta = getDDDArray("indexPMTR",sv1); - for (unsigned int ii=0; ii(neta[ii]); - int ir=-1, ifib=-1; + int ir = -1, ifib = -1; if (index >= 0) { - ir = index/10; ifib = index%10; + ir = index / 10; + ifib = index % 10; } pmtR1.push_back(ir); pmtFib1.push_back(ifib); } - neta = getDDDArray("indexPMTL",sv1); - for (unsigned int ii=0; ii(neta[ii]); - int ir=-1, ifib=-1; + int ir = -1, ifib = -1; if (index >= 0) { - ir = index/10; ifib = index%10; + ir = index / 10; + ifib = index % 10; } pmtR2.push_back(ir); pmtFib2.push_back(ifib); } - edm::LogInfo("HFShower") << "HFShowerFibreBundle: gets the Index matches " - << "for " << neta.size() << " PMTs"; - for (unsigned int ii=0; iigetRTableHF(); + rTable = hcons->getRTableHF(); std::stringstream sss; - for (unsigned int ig=0; igGetPreStepPoint(); - const G4VTouchable* touch = preStepPoint->GetTouchable(); - int boxNo = touch->GetReplicaNumber(1); - int pmtNo = touch->GetReplicaNumber(0); + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); + const G4VTouchable* touch = preStepPoint->GetTouchable(); + int boxNo = touch->GetReplicaNumber(1); + int pmtNo = touch->GetReplicaNumber(0); if (boxNo <= 1) { - indexR = pmtR1[pmtNo-1]; - indexF = pmtFib1[pmtNo-1]; + indexR = pmtR1[pmtNo - 1]; + indexF = pmtFib1[pmtNo - 1]; } else { - indexR = pmtR2[pmtNo-1]; - indexF = pmtFib2[pmtNo-1]; + indexR = pmtR2[pmtNo - 1]; + indexF = pmtFib2[pmtNo - 1]; } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG double edep = aStep->GetTotalEnergyDeposit(); - LogDebug("HFShower") << "HFShowerFibreBundle: Box " << boxNo << " PMT " - << pmtNo << " Mapped Indices " << indexR << ", " - << indexF << " Edeposit " << edep/MeV << " MeV"; + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle: Box " << boxNo << " PMT " << pmtNo << " Mapped Indices " + << indexR << ", " << indexF << " Edeposit " << edep / MeV << " MeV"; #endif double photons = 0; if (indexR >= 0 && indexF > 0) { - const G4Track *aTrack = aStep->GetTrack(); - const G4ParticleDefinition *particleDef = aTrack->GetDefinition(); + const G4Track* aTrack = aStep->GetTrack(); + const G4ParticleDefinition* particleDef = aTrack->GetDefinition(); double stepl = aStep->GetStepLength(); - double beta = preStepPoint->GetBeta(); + double beta = preStepPoint->GetBeta(); G4ThreeVector pDir = aTrack->GetDynamicParticle()->GetMomentumDirection(); - G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()-> - GetTopTransform().TransformAxis(pDir); + G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(pDir); if (type) { - photons = facCone*cherenkov2->computeNPEinPMT(particleDef, beta, - localMom.x(), localMom.y(), - localMom.z(), stepl); + photons = + facCone * cherenkov2->computeNPEinPMT(particleDef, beta, localMom.x(), localMom.y(), localMom.z(), stepl); } else { - photons = facTube*cherenkov1->computeNPEinPMT(particleDef, beta, - localMom.x(), localMom.y(), - localMom.z(), stepl); + photons = + facTube * cherenkov1->computeNPEinPMT(particleDef, beta, localMom.x(), localMom.y(), localMom.z(), stepl); } -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerFibreBundle::getHits: for particle " - << particleDef->GetParticleName() << " Step " << stepl - << " Beta " << beta << " Direction " << pDir - << " Local " << localMom << " p.e. " << photons; -#endif - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle::getHits: for particle " << particleDef->GetParticleName() + << " Step " << stepl << " Beta " << beta << " Direction " << pDir << " Local " + << localMom << " p.e. " << photons; +#endif } return photons; } - + double HFShowerFibreBundle::getRadius() { - double r = 0.; - if (indexR >= 0 && indexR+1 < (int)(rTable.size())) - r = 0.5*(rTable[indexR]+rTable[indexR+1]); -#ifdef DebugLog + if (indexR >= 0 && indexR + 1 < (int)(rTable.size())) + r = 0.5 * (rTable[indexR] + rTable[indexR + 1]); +#ifdef EDM_ML_DEBUG else - LogDebug("HFShower") << "HFShowerFibreBundle::getRadius: R " << indexR - << " F " << indexF; + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle::getRadius: R " << indexR << " F " << indexF; #endif - if (indexF == 2) r =-r; -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerFibreBundle: Radius (" << indexR << "/" - << indexF << ") " << r; + if (indexF == 2) + r = -r; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle: Radius (" << indexR << "/" << indexF << ") " << r; #endif return r; } -std::vector HFShowerFibreBundle::getDDDArray(const std::string & str, - const DDsvalues_type& sv){ - -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerFibreBundle:getDDDArray called for " << str; +std::vector HFShowerFibreBundle::getDDDArray(const std::string& str, const DDsvalues_type& sv) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerFibreBundle:getDDDArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("HFShower") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 2) { - edm::LogError("HFShower") << "HFShowerFibreBundle: # of " << str - << " bins " << nval << " < 2 ==> illegal"; - throw cms::Exception("Unknown", "HFShowerFibreBundle") - << "nval < 2 for array " << str << "\n"; + edm::LogError("HFShower") << "HFShowerFibreBundle: # of " << str << " bins " << nval << " < 2 ==> illegal"; + throw cms::Exception("Unknown", "HFShowerFibreBundle") << "nval < 2 for array " << str << "\n"; } return fvec; } else { - edm::LogError("HFShower") <<"HFShowerFibreBundle: cannot get array " <("HFShower"); - probMax = m_HF.getParameter("ProbMax"); - - edm::ParameterSet m_HS= p.getParameter("HFShowerLibrary"); - edm::FileInPath fp = m_HS.getParameter("FileName"); - std::string pTreeName = fp.fullPath(); - backProb = m_HS.getParameter("BackProbability"); - std::string emName = m_HS.getParameter("TreeEMID"); - std::string hadName = m_HS.getParameter("TreeHadID"); - std::string branchEvInfo = m_HS.getUntrackedParameter("BranchEvt","HFShowerLibraryEventInfos_hfshowerlib_HFShowerLibraryEventInfo"); - std::string branchPre = m_HS.getUntrackedParameter("BranchPre","HFShowerPhotons_hfshowerlib_"); - std::string branchPost = m_HS.getUntrackedParameter("BranchPost","_R.obj"); - verbose = m_HS.getUntrackedParameter("Verbosity",false); - applyFidCut = m_HS.getParameter("ApplyFiducialCut"); - - if (pTreeName.find(".") == 0) pTreeName.erase(0,2); +//#define EDM_ML_DEBUG + +HFShowerLibrary::HFShowerLibrary(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p) + : fibre(nullptr), hf(nullptr), emBranch(nullptr), hadBranch(nullptr), npe(0) { + edm::ParameterSet m_HF = p.getParameter("HFShower"); + probMax = m_HF.getParameter("ProbMax"); + + edm::ParameterSet m_HS = p.getParameter("HFShowerLibrary"); + edm::FileInPath fp = m_HS.getParameter("FileName"); + std::string pTreeName = fp.fullPath(); + backProb = m_HS.getParameter("BackProbability"); + std::string emName = m_HS.getParameter("TreeEMID"); + std::string hadName = m_HS.getParameter("TreeHadID"); + std::string branchEvInfo = m_HS.getUntrackedParameter( + "BranchEvt", "HFShowerLibraryEventInfos_hfshowerlib_HFShowerLibraryEventInfo"); + std::string branchPre = m_HS.getUntrackedParameter("BranchPre", "HFShowerPhotons_hfshowerlib_"); + std::string branchPost = m_HS.getUntrackedParameter("BranchPost", "_R.obj"); + verbose = m_HS.getUntrackedParameter("Verbosity", false); + applyFidCut = m_HS.getParameter("ApplyFiducialCut"); + + if (pTreeName.find(".") == 0) + pTreeName.erase(0, 2); const char* nTree = pTreeName.c_str(); - hf = TFile::Open(nTree); + hf = TFile::Open(nTree); - if (!hf->IsOpen()) { - edm::LogError("HFShower") << "HFShowerLibrary: opening " << nTree - << " failed"; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "Opening of " << pTreeName << " fails\n"; + if (!hf->IsOpen()) { + edm::LogError("HFShower") << "HFShowerLibrary: opening " << nTree << " failed"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "Opening of " << pTreeName << " fails\n"; } else { - edm::LogVerbatim("HFShower") << "HFShowerLibrary: opening " << nTree - << " successfully"; + edm::LogVerbatim("HFShower") << "HFShowerLibrary: opening " << nTree << " successfully"; } newForm = (branchEvInfo.empty()); TTree* event(nullptr); - if (newForm) event = (TTree *) hf ->Get("HFSimHits"); - else event = (TTree *) hf ->Get("Events"); + if (newForm) + event = (TTree*)hf->Get("HFSimHits"); + else + event = (TTree*)hf->Get("Events"); if (event) { - TBranch *evtInfo(nullptr); + TBranch* evtInfo(nullptr); if (!newForm) { std::string info = branchEvInfo + branchPost; - evtInfo = event->GetBranch(info.c_str()); + evtInfo = event->GetBranch(info.c_str()); } if (evtInfo || newForm) { loadEventInfo(evtInfo); } else { edm::LogError("HFShower") << "HFShowerLibrary: HFShowerLibrayEventInfo" << " Branch does not exist in Event"; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "Event information absent\n"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "Event information absent\n"; } } else { edm::LogError("HFShower") << "HFShowerLibrary: Events Tree does not " << "exist"; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "Events tree absent\n"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "Events tree absent\n"; } - + std::stringstream ss; - ss << "HFShowerLibrary: Library " << libVers << " ListVersion " << listVersion - << " Events Total " << totEvents << " and " << evtPerBin << " per bin\n"; + ss << "HFShowerLibrary: Library " << libVers << " ListVersion " << listVersion << " Events Total " << totEvents + << " and " << evtPerBin << " per bin\n"; ss << "HFShowerLibrary: Energies (GeV) with " << nMomBin << " bins\n"; - for (int i=0; i 0) { ss << "\n"; } - ss << " " << pmom[i]/CLHEP::GeV; + for (int i = 0; i < nMomBin; ++i) { + if (i / 10 * 10 == i && i > 0) { + ss << "\n"; + } + ss << " " << pmom[i] / CLHEP::GeV; } edm::LogVerbatim("HFShower") << ss.str(); std::string nameBr = branchPre + emName + branchPost; - emBranch = event->GetBranch(nameBr.c_str()); - if (verbose) emBranch->Print(); - nameBr = branchPre + hadName + branchPost; - hadBranch = event->GetBranch(nameBr.c_str()); - if (verbose) hadBranch->Print(); - - v3version=false; - if ( emBranch->GetClassName() == std::string("vector") ) { - v3version=true; + emBranch = event->GetBranch(nameBr.c_str()); + if (verbose) + emBranch->Print(); + nameBr = branchPre + hadName + branchPost; + hadBranch = event->GetBranch(nameBr.c_str()); + if (verbose) + hadBranch->Print(); + + v3version = false; + if (emBranch->GetClassName() == std::string("vector")) { + v3version = true; } - - edm::LogVerbatim("HFShower") << " HFShowerLibrary:Branch " << emName - << " has " << emBranch->GetEntries() - << " entries and Branch " << hadName - << " has " << hadBranch->GetEntries() - << " entries" - << "\n HFShowerLibrary::No packing information -" - << " Assume x, y, z are not in packed form" - << "\n Maximum probability cut off " - << probMax << " Back propagation of light prob. " - << backProb; - + + edm::LogVerbatim("HFShower") << " HFShowerLibrary:Branch " << emName << " has " << emBranch->GetEntries() + << " entries and Branch " << hadName << " has " << hadBranch->GetEntries() << " entries" + << "\n HFShowerLibrary::No packing information -" + << " Assume x, y, z are not in packed form" + << "\n Maximum probability cut off " << probMax << " Back propagation of light prob. " + << backProb; + fibre = new HFFibre(name, cpv, p); photo = new HFShowerPhotonCollection; } HFShowerLibrary::~HFShowerLibrary() { - if (hf) hf->Close(); + if (hf) + hf->Close(); delete fibre; delete photo; } void HFShowerLibrary::initRun(G4ParticleTable*, const HcalDDDSimConstants* hcons) { + if (fibre) + fibre->initRun(hcons); - if (fibre) fibre->initRun(hcons); - //Radius (minimum and maximum) std::vector rTable = hcons->getRTableHF(); rMin = rTable[0]; - rMax = rTable[rTable.size()-1]; + rMax = rTable[rTable.size() - 1]; //Delta phi - std::vector phibin = hcons->getPhiTableHF(); - dphi = phibin[0]; - edm::LogVerbatim("HFShower") << "HFShowerLibrary: rMIN " << rMin/cm - << " cm and rMax " << rMax/cm - << " (Half) Phi Width of wedge " - << dphi/deg; + std::vector phibin = hcons->getPhiTableHF(); + dphi = phibin[0]; + edm::LogVerbatim("HFShower") << "HFShowerLibrary: rMIN " << rMin / cm << " cm and rMax " << rMax / cm + << " (Half) Phi Width of wedge " << dphi / deg; //Special Geometry parameters gpar = hcons->getGparHF(); } -std::vector HFShowerLibrary::getHits(const G4Step * aStep, - bool & isKilled, +std::vector HFShowerLibrary::getHits(const G4Step* aStep, + bool& isKilled, double weight, bool onlyLong) { - - auto const preStepPoint = aStep->GetPreStepPoint(); - auto const postStepPoint = aStep->GetPostStepPoint(); + auto const preStepPoint = aStep->GetPreStepPoint(); + auto const postStepPoint = aStep->GetPostStepPoint(); auto const track = aStep->GetTrack(); - // Get Z-direction + // Get Z-direction auto const aParticle = track->GetDynamicParticle(); const G4ThreeVector& momDir = aParticle->GetMomentumDirection(); - const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); - int parCode = track->GetDefinition()->GetPDGEncoding(); + const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); + int parCode = track->GetDefinition()->GetPDGEncoding(); - // VI: for ions use internally pdg code of alpha in order to keep + // VI: for ions use internally pdg code of alpha in order to keep // consistency with previous simulation - if(track->GetDefinition()->IsGeneralIon()) { parCode = 1000020040; } - -#ifdef DebugLog - G4String partType = track->GetDefinition()->GetParticleName(); - const G4ThreeVector localPos = - preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint); - double zoff = localPos.z() + 0.5*gpar[1]; - - edm::LogVerbatim("HFShower") << "HFShowerLibrary::getHits " << partType - << " of energy " << pin/GeV << " GeV" - << " weight= " << weight << " onlyLong: " << onlyLong - << " dir.orts " << momDir.x() << ", " <GetDefinition()->IsGeneralIon()) { + parCode = 1000020040; + } + +#ifdef EDM_ML_DEBUG + G4String partType = track->GetDefinition()->GetParticleName(); + const G4ThreeVector localPos = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint); + double zoff = localPos.z() + 0.5 * gpar[1]; + + edm::LogVerbatim("HFShower") << "HFShowerLibrary::getHits " << partType << " of energy " + << track->GetKineticEnergy() / GeV << " GeV weight= " << weight + << " onlyLong: " << onlyLong << " dir.orts " << momDir.x() << ", " << momDir.y() << ", " + << momDir.z() << " Pos x,y,z = " << hitPoint.x() << "," << hitPoint.y() << "," + << hitPoint.z() << " (" << zoff << ") sphi,cphi,stheta,ctheta = " << sin(momDir.phi()) + << "," << cos(momDir.phi()) << ", " << sin(momDir.theta()) << "," << cos(momDir.theta()); #endif - double tSlice = (postStepPoint->GetGlobalTime())/CLHEP::nanosecond; + double tSlice = (postStepPoint->GetGlobalTime()) / CLHEP::nanosecond; // use kinetic energy for protons and ions - double pin = (track->GetDefinition()->GetBaryonNumber() > 0) - ? preStepPoint->GetKineticEnergy() : preStepPoint->GetTotalEnergy(); + double pin = (track->GetDefinition()->GetBaryonNumber() > 0) ? preStepPoint->GetKineticEnergy() + : preStepPoint->GetTotalEnergy(); - return fillHits(hitPoint,momDir,parCode,pin,isKilled,weight,tSlice,onlyLong); + return fillHits(hitPoint, momDir, parCode, pin, isKilled, weight, tSlice, onlyLong); } -std::vector HFShowerLibrary::fillHits(const G4ThreeVector & hitPoint, - const G4ThreeVector & momDir, - int parCode, double pin, bool & ok, - double weight, double tSlice,bool onlyLong) { - +std::vector HFShowerLibrary::fillHits(const G4ThreeVector& hitPoint, + const G4ThreeVector& momDir, + int parCode, + double pin, + bool& ok, + double weight, + double tSlice, + bool onlyLong) { std::vector hit; ok = false; bool isEM = G4TrackToParticleID::isGammaElectronPositron(parCode); // shower is built only for gamma, e+- and stable hadrons - if (!isEM && !G4TrackToParticleID::isStableHadron(parCode)) { + if (!isEM && !G4TrackToParticleID::isStableHadron(parCode)) { return hit; } ok = true; // remove low-energy component - const double threshold = 50*MeV; - if(pin < threshold) { return hit; } + const double threshold = 50 * MeV; + if (pin < threshold) { + return hit; + } - double pz = momDir.z(); - double zint = hitPoint.z(); + double pz = momDir.z(); + double zint = hitPoint.z(); // if particle moves from interaction point or "backwards (halo) bool backward = (pz * zint < 0.) ? true : false; - - double sphi = sin(momDir.phi()); - double cphi = cos(momDir.phi()); + + double sphi = sin(momDir.phi()); + double cphi = cos(momDir.phi()); double ctheta = cos(momDir.theta()); double stheta = sin(momDir.theta()); - if(isEM) { - if (pin 0 && - (pe[i].z() >= 0 || (zv > gpar[0] && (!onlyLong)))) { + if (zv <= gpar[1] && pe[i].lambda() > 0 && (pe[i].z() >= 0 || (zv > gpar[0] && (!onlyLong)))) { int depth = 1; if (onlyLong) { - } else if (!backward) { // fully valid only for "front" particles - if (pe[i].z() < 0) depth = 2;// with "front"-simulated shower lib. + } else if (!backward) { // fully valid only for "front" particles + if (pe[i].z() < 0) + depth = 2; // with "front"-simulated shower lib. } else { // for "backward" particles - almost equal double r = G4UniformRand(); // share between L and S fibers - if (r > 0.5) depth = 2; - } - + if (r > 0.5) + depth = 2; + } // Updated coordinate transformation from local // back to global using two Euler angles: phi and theta double pex = pe[i].x(); double pey = pe[i].y(); - double xx = pex*ctheta*cphi - pey*sphi + zv*stheta*cphi; - double yy = pex*ctheta*sphi + pey*cphi + zv*stheta*sphi; - double zz = -pex*stheta + zv*ctheta; + double xx = pex * ctheta * cphi - pey * sphi + zv * stheta * cphi; + double yy = pex * ctheta * sphi + pey * cphi + zv * stheta * sphi; + double zz = -pex * stheta + zv * ctheta; - G4ThreeVector pos = hitPoint + G4ThreeVector(xx,yy,zz); - zv = std::abs(pos.z()) - gpar[4] - 0.5*gpar[1]; - G4ThreeVector lpos = G4ThreeVector(pos.x(),pos.y(),zv); + G4ThreeVector pos = hitPoint + G4ThreeVector(xx, yy, zz); + zv = std::abs(pos.z()) - gpar[4] - 0.5 * gpar[1]; + G4ThreeVector lpos = G4ThreeVector(pos.x(), pos.y(), zv); - zv = fibre->zShift(lpos,depth,0); // distance to PMT ! + zv = fibre->zShift(lpos, depth, 0); // distance to PMT ! - double r = pos.perp(); - double p = fibre->attLength(pe[i].lambda()); + double r = pos.perp(); + double p = fibre->attLength(pe[i].lambda()); double fi = pos.phi(); - if (fi < 0) fi += CLHEP::twopi; - int isect = int(fi/dphi) + 1; - isect = (isect + 1) / 2; - double dfi = ((isect*2-1)*dphi - fi); - if (dfi < 0) dfi = -dfi; - double dfir = r * sin(dfi); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerLibrary: Position shift " << xx - << ", " << yy << ", " << zz << ": " << pos - << " R " << r << " Phi " << fi << " Section " - << isect << " R*Dfi " << dfir << " Dist " << zv; + if (fi < 0) + fi += CLHEP::twopi; + int isect = int(fi / dphi) + 1; + isect = (isect + 1) / 2; + double dfi = ((isect * 2 - 1) * dphi - fi); + if (dfi < 0) + dfi = -dfi; + double dfir = r * sin(dfi); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: Position shift " << xx << ", " << yy << ", " << zz << ": " + << pos << " R " << r << " Phi " << fi << " Section " << isect << " R*Dfi " << dfir + << " Dist " << zv; #endif - zz = std::abs(pos.z()); - double r1 = G4UniformRand(); - double r2 = G4UniformRand(); - double r3 = backward ? G4UniformRand() : -9999.; - if (!applyFidCut) dfir += gpar[5]; - -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerLibrary: rLimits " << rInside(r) - << " attenuation " << r1 <<":" << exp(-p*zv) - << " r2 " << r2 << " r3 " << r3 << " rDfi " - << gpar[5] << " zz " - << zz << " zLim " << gpar[4] << ":" - << gpar[4]+gpar[1] << "\n" - << " rInside(r) :" << rInside(r) - << " r1 <= exp(-p*zv) :" << (r1 <= exp(-p*zv)) - << " r2 <= probMax :" << (r2 <= probMax*weight) - << " r3 <= backProb :" << (r3 <= backProb) - << " dfir > gpar[5] :" << (dfir > gpar[5]) - << " zz >= gpar[4] :" << (zz >= gpar[4]) - << " zz <= gpar[4]+gpar[1] :" - << (zz <= gpar[4]+gpar[1]); + zz = std::abs(pos.z()); + double r1 = G4UniformRand(); + double r2 = G4UniformRand(); + double r3 = backward ? G4UniformRand() : -9999.; + if (!applyFidCut) + dfir += gpar[5]; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: rLimits " << rInside(r) << " attenuation " << r1 << ":" + << exp(-p * zv) << " r2 " << r2 << " r3 " << r3 << " rDfi " << gpar[5] << " zz " + << zz << " zLim " << gpar[4] << ":" << gpar[4] + gpar[1] << "\n" + << " rInside(r) :" << rInside(r) << " r1 <= exp(-p*zv) :" << (r1 <= exp(-p * zv)) + << " r2 <= probMax :" << (r2 <= probMax * weight) + << " r3 <= backProb :" << (r3 <= backProb) + << " dfir > gpar[5] :" << (dfir > gpar[5]) << " zz >= gpar[4] :" << (zz >= gpar[4]) + << " zz <= gpar[4]+gpar[1] :" << (zz <= gpar[4] + gpar[1]); #endif - if (rInside(r) && r1 <= exp(-p*zv) && r2 <= probMax*weight && - dfir > gpar[5] && zz >= gpar[4] && zz <= gpar[4]+gpar[1] && - r3 <= backProb && (depth != 2 || zz >= gpar[4]+gpar[0])) { + if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax * weight && dfir > gpar[5] && zz >= gpar[4] && + zz <= gpar[4] + gpar[1] && r3 <= backProb && (depth != 2 || zz >= gpar[4] + gpar[0])) { oneHit.position = pos; - oneHit.depth = depth; - oneHit.time = (tSlice+(pe[i].t())+(fibre->tShift(lpos,depth,1))); + oneHit.depth = depth; + oneHit.time = (tSlice + (pe[i].t()) + (fibre->tShift(lpos, depth, 1))); hit.push_back(oneHit); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit - <<" position " << (hit[nHit].position) - << " Depth " << (hit[nHit].depth) <<" Time " - << tSlice << ":" << pe[i].t() << ":" - << fibre->tShift(lpos,depth,1) << ":" - << (hit[nHit].time); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit << " position " << (hit[nHit].position) + << " Depth " << (hit[nHit].depth) << " Time " << tSlice << ":" << pe[i].t() << ":" + << fibre->tShift(lpos, depth, 1) << ":" << (hit[nHit].time); #endif ++nHit; } -#ifdef DebugLog - else LogDebug("HFShower") << "HFShowerLibrary: REJECTED !!!"; +#ifdef EDM_ML_DEBUG + else + edm::LogVerbatim("HFShower") << "HFShowerLibrary: REJECTED !!!"; #endif - if (onlyLong && zz >= gpar[4]+gpar[0] && zz <= gpar[4]+gpar[1]) { - r1 = G4UniformRand(); - r2 = G4UniformRand(); - if (rInside(r) && r1 <= exp(-p*zv) && r2 <= probMax && dfir > gpar[5]){ + if (onlyLong && zz >= gpar[4] + gpar[0] && zz <= gpar[4] + gpar[1]) { + r1 = G4UniformRand(); + r2 = G4UniformRand(); + if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax && dfir > gpar[5]) { oneHit.position = pos; - oneHit.depth = 2; - oneHit.time = (tSlice+(pe[i].t())+(fibre->tShift(lpos,2,1))); + oneHit.depth = 2; + oneHit.time = (tSlice + (pe[i].t()) + (fibre->tShift(lpos, 2, 1))); hit.push_back(oneHit); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit - << " position " << (hit[nHit].position) - << " Depth " << (hit[nHit].depth) <<" Time " - << tSlice << ":" << pe[i].t() << ":" - << fibre->tShift(lpos,2,1) << ":" - << (hit[nHit].time); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit << " position " << (hit[nHit].position) + << " Depth " << (hit[nHit].depth) << " Time " << tSlice << ":" << pe[i].t() + << ":" << fibre->tShift(lpos, 2, 1) << ":" << (hit[nHit].time); #endif ++nHit; } @@ -349,42 +333,36 @@ std::vector HFShowerLibrary::fillHits(const G4ThreeVector } } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerLibrary: Total Hits " << nHit - << " out of " << npe << " PE"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: Total Hits " << nHit << " out of " << npe << " PE"; #endif if (nHit > npe && !onlyLong) { - edm::LogWarning("HFShower") << "HFShowerLibrary: Hit buffer " << npe - << " smaller than " << nHit << " Hits"; + edm::LogWarning("HFShower") << "HFShowerLibrary: Hit buffer " << npe << " smaller than " << nHit << " Hits"; } return hit; } -bool HFShowerLibrary::rInside(double r) { - - return (r >= rMin && r <= rMax); -} +bool HFShowerLibrary::rInside(double r) { return (r >= rMin && r <= rMax); } void HFShowerLibrary::getRecord(int type, int record) { - - int nrc = record-1; + int nrc = record - 1; photon.clear(); photo->clear(); if (type > 0) { if (newForm) { - if ( !v3version ) { + if (!v3version) { hadBranch->SetAddress(&photo); - hadBranch->GetEntry(nrc+totEvents); - } - else{ + hadBranch->GetEntry(nrc + totEvents); + } else { std::vector t; - std::vector *tp=&t; + std::vector* tp = &t; hadBranch->SetAddress(&tp); - hadBranch->GetEntry(nrc+totEvents); - unsigned int tSize=t.size()/5; + hadBranch->GetEntry(nrc + totEvents); + unsigned int tSize = t.size() / 5; photo->reserve(tSize); - for ( unsigned int i=0; ipush_back( HFShowerPhoton( t[i], t[1*tSize+i], t[2*tSize+i], t[3*tSize+i], t[4*tSize+i] ) ); + for (unsigned int i = 0; i < tSize; i++) { + photo->push_back( + HFShowerPhoton(t[i], t[1 * tSize + i], t[2 * tSize + i], t[3 * tSize + i], t[4 * tSize + i])); } } } else { @@ -396,16 +374,16 @@ void HFShowerLibrary::getRecord(int type, int record) { if (!v3version) { emBranch->SetAddress(&photo); emBranch->GetEntry(nrc); - } - else{ + } else { std::vector t; - std::vector *tp=&t; + std::vector* tp = &t; emBranch->SetAddress(&tp); emBranch->GetEntry(nrc); - unsigned int tSize=t.size()/5; + unsigned int tSize = t.size() / 5; photo->reserve(tSize); - for ( unsigned int i=0; ipush_back( HFShowerPhoton( t[i], t[1*tSize+i], t[2*tSize+i], t[3*tSize+i], t[4*tSize+i] ) ); + for (unsigned int i = 0; i < tSize; i++) { + photo->push_back( + HFShowerPhoton(t[i], t[1 * tSize + i], t[2 * tSize + i], t[3 * tSize + i], t[4 * tSize + i])); } } } else { @@ -413,112 +391,108 @@ void HFShowerLibrary::getRecord(int type, int record) { emBranch->GetEntry(nrc); } } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG int nPhoton = (newForm) ? photo->size() : photon.size(); - LogDebug("HFShower") << "HFShowerLibrary::getRecord: Record " << record - << " of type " << type << " with " << nPhoton - << " photons"; - for (int j = 0; j < nPhoton; j++) - if (newForm) LogDebug("HFShower") << "Photon " << j << " " << photo->at(j); - else LogDebug("HFShower") << "Photon " << j << " " << photon[j]; + edm::LogVerbatim("HFShower") << "HFShowerLibrary::getRecord: Record " << record << " of type " << type << " with " + << nPhoton << " photons"; + for (int j = 0; j < nPhoton; j++) + if (newForm) + edm::LogVerbatim("HFShower") << "Photon " << j << " " << photo->at(j); + else + edm::LogVerbatim("HFShower") << "Photon " << j << " " << photon[j]; #endif } void HFShowerLibrary::loadEventInfo(TBranch* branch) { - if (branch) { std::vector eventInfoCollection; branch->SetAddress(&eventInfoCollection); branch->GetEntry(0); - edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads " - << " EventInfo Collection of size " - << eventInfoCollection.size() << " records"; - totEvents = eventInfoCollection[0].totalEvents(); - nMomBin = eventInfoCollection[0].numberOfBins(); - evtPerBin = eventInfoCollection[0].eventsPerBin(); - libVers = eventInfoCollection[0].showerLibraryVersion(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads EventInfo Collection of size " + << eventInfoCollection.size() << " records"; +#endif + totEvents = eventInfoCollection[0].totalEvents(); + nMomBin = eventInfoCollection[0].numberOfBins(); + evtPerBin = eventInfoCollection[0].eventsPerBin(); + libVers = eventInfoCollection[0].showerLibraryVersion(); listVersion = eventInfoCollection[0].physListVersion(); - pmom = eventInfoCollection[0].energyBins(); + pmom = eventInfoCollection[0].energyBins(); } else { - edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads " - << " EventInfo from hardwired numbers"; - nMomBin = 16; - evtPerBin = 5000; - totEvents = nMomBin*evtPerBin; - libVers = 1.1; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary::loadEventInfo loads EventInfo from hardwired" + << " numbers"; +#endif + nMomBin = 16; + evtPerBin = 5000; + totEvents = nMomBin * evtPerBin; + libVers = 1.1; listVersion = 3.6; - pmom = {2,3,5,7,10,15,20,30,50,75,100,150,250,350,500,1000}; + pmom = {2, 3, 5, 7, 10, 15, 20, 30, 50, 75, 100, 150, 250, 350, 500, 1000}; } - for (int i=0; i= pmom[j] && pin < pmom[j+1]) { - w = (pin-pmom[j])/(pmom[j+1]-pmom[j]); - if (j == nMomBin-2) { - irc[1] = int(evtPerBin*0.5*r); + for (int j = 0; j < nMomBin - 1; j++) { + if (pin >= pmom[j] && pin < pmom[j + 1]) { + w = (pin - pmom[j]) / (pmom[j + 1] - pmom[j]); + if (j == nMomBin - 2) { + irc[1] = int(evtPerBin * 0.5 * r); } else { - irc[1] = int(evtPerBin*r); + irc[1] = int(evtPerBin * r); } - irc[1] += (j+1)*evtPerBin + 1; + irc[1] += (j + 1) * evtPerBin + 1; r = G4UniformRand(); - irc[0] = int(evtPerBin*r) + 1 + j*evtPerBin; - if (irc[0]<0) { - edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " - << irc[0] << " now set to 0"; + irc[0] = int(evtPerBin * r) + 1 + j * evtPerBin; + if (irc[0] < 0) { + edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " << irc[0] << " now set to 0"; irc[0] = 0; } else if (irc[0] > totEvents) { - edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " - << irc[0] << " now set to "<< totEvents; + edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[0] = " << irc[0] << " now set to " << totEvents; irc[0] = totEvents; } } } } - if (irc[1]<1) { - edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " - << irc[1] << " now set to 1"; + if (irc[1] < 1) { + edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " << irc[1] << " now set to 1"; irc[1] = 1; } else if (irc[1] > totEvents) { - edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " - << irc[1] << " now set to "<< totEvents; + edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[1] = " << irc[1] << " now set to " << totEvents; irc[1] = totEvents; } -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerLibrary:: Select records " << irc[0] - << " and " << irc[1] << " with weights " << 1-w - << " and " << w; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary:: Select records " << irc[0] << " and " << irc[1] << " with weights " + << 1 - w << " and " << w; #endif - pe.clear(); - npe = 0; + pe.clear(); + npe = 0; int npold = 0; - for (int ir=0; ir < 2; ir++) { - if (irc[ir]>0) { - getRecord (type, irc[ir]); + for (int ir = 0; ir < 2; ir++) { + if (irc[ir] > 0) { + getRecord(type, irc[ir]); int nPhoton = (newForm) ? photo->size() : photon.size(); - npold += nPhoton; - for (int j=0; j w) || (ir > 0 && r < w)) { - storePhoton (j); + if ((ir == 0 && r > w) || (ir > 0 && r < w)) { + storePhoton(j); } } } @@ -526,135 +500,115 @@ void HFShowerLibrary::interpolate(int type, double pin) { if ((npe > npold || (npold == 0 && irc[0] > 0)) && !(npe == 0 && npold == 0)) edm::LogWarning("HFShower") << "HFShowerLibrary: Interpolation Warning ==" - << " records " << irc[0] << " and " << irc[1] - << " gives a buffer of " << npold + << " records " << irc[0] << " and " << irc[1] << " gives a buffer of " << npold << " photons and fills " << npe << " *****"; -#ifdef DebugLog +#ifdef EDM_ML_DEBUG else - LogDebug("HFShower") << "HFShowerLibrary: Interpolation == records " - << irc[0] << " and " << irc[1] << " gives a " - << "buffer of " << npold << " photons and fills " - << npe << " PE"; - for (int j=0; j irc(nrec); - for (int ir=0; ir totEvents) { - edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir - << "] = " << irc[ir] << " now set to " + edm::LogWarning("HFShower") << "HFShowerLibrary:: Illegal irc[" << ir << "] = " << irc[ir] << " now set to " << totEvents; irc[ir] = totEvents; -#ifdef DebugLog +#ifdef EDM_ML_DEBUG } else { - LogDebug("HFShower") << "HFShowerLibrary::Extrapolation use irc[" - << ir << "] = " << irc[ir]; + edm::LogVerbatim("HFShower") << "HFShowerLibrary::Extrapolation use irc[" << ir << "] = " << irc[ir]; #endif } } - pe.clear(); - npe = 0; + pe.clear(); + npe = 0; int npold = 0; - for (int ir=0; ir0) { - getRecord (type, irc[ir]); + for (int ir = 0; ir < nrec; ir++) { + if (irc[ir] > 0) { + getRecord(type, irc[ir]); int nPhoton = (newForm) ? photo->size() : photon.size(); - npold += nPhoton; - for (int j=0; j npold || npold == 0) - edm::LogWarning("HFShower") << "HFShowerLibrary: Extrapolation Warning == " - << nrec << " records " << irc[0] << ", " - << irc[1] << ", ... gives a buffer of " <at(j)); - else pe.push_back(photon[j]); -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe " - << npe << " " << pe[npe]; + if (newForm) + pe.push_back(photo->at(j)); + else + pe.push_back(photon[j]); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary: storePhoton " << j << " npe " << npe << " " << pe[npe]; #endif npe++; } -std::vector HFShowerLibrary::getDDDArray(const std::string & str, - const DDsvalues_type & sv, - int & nmin) { - -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerLibrary:getDDDArray called for " << str - << " with nMin " << nmin; +std::vector HFShowerLibrary::getDDDArray(const std::string& str, const DDsvalues_type& sv, int& nmin) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerLibrary:getDDDArray called for " << str << " with nMin " << nmin; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("HFShower") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nmin > 0) { if (nval < nmin) { - edm::LogError("HFShower") << "HFShowerLibrary : # of " << str - << " bins " << nval << " < " << nmin + edm::LogError("HFShower") << "HFShowerLibrary : # of " << str << " bins " << nval << " < " << nmin << " ==> illegal"; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "nval < nmin for array " << str << "\n"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "nval < nmin for array " << str << "\n"; } } else { if (nval < 2) { - edm::LogError("HFShower") << "HFShowerLibrary : # of " << str - << " bins " << nval << " < 2 ==> illegal" + edm::LogError("HFShower") << "HFShowerLibrary : # of " << str << " bins " << nval << " < 2 ==> illegal" << " (nmin=" << nmin << ")"; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "nval < 2 for array " << str << "\n"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "nval < 2 for array " << str << "\n"; } } nmin = nval; @@ -662,7 +616,6 @@ std::vector HFShowerLibrary::getDDDArray(const std::string & str, return fvec; } else { edm::LogError("HFShower") << "HFShowerLibrary : cannot get array " << str; - throw cms::Exception("Unknown", "HFShowerLibrary") - << "cannot get array " << str << "\n"; + throw cms::Exception("Unknown", "HFShowerLibrary") << "cannot get array " << str << "\n"; } } diff --git a/SimG4CMS/Calo/src/HFShowerPMT.cc b/SimG4CMS/Calo/src/HFShowerPMT.cc index 69b0c2cbc7d33..282a350671ee4 100644 --- a/SimG4CMS/Calo/src/HFShowerPMT.cc +++ b/SimG4CMS/Calo/src/HFShowerPMT.cc @@ -18,167 +18,151 @@ #include "CLHEP/Units/GlobalSystemOfUnits.h" #include -//#define DebugLog +//#define EDM_ML_DEBUG -HFShowerPMT::HFShowerPMT(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p) : cherenkov(nullptr) { +HFShowerPMT::HFShowerPMT(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p) + : cherenkov(nullptr) { + edm::ParameterSet m_HF = p.getParameter("HFShowerPMT"); + pePerGeV = m_HF.getParameter("PEPerGeVPMT"); - edm::ParameterSet m_HF = p.getParameter("HFShowerPMT"); - pePerGeV = m_HF.getParameter("PEPerGeVPMT"); - //Special Geometry parameters std::string attribute = "Volume"; - std::string value = "HFPMT"; - DDSpecificsMatchesValueFilter filter1{DDValue(attribute,value,0)}; - DDFilteredView fv1(cpv,filter1); + std::string value = "HFPMT"; + DDSpecificsMatchesValueFilter filter1{DDValue(attribute, value, 0)}; + DDFilteredView fv1(cpv, filter1); if (fv1.firstChild()) { DDsvalues_type sv1(fv1.mergedSpecifics()); std::vector neta; - neta = getDDDArray("indexPMTR",sv1); - for (unsigned int ii=0; ii(neta[ii]); - int ir=-1, ifib=-1; + int ir = -1, ifib = -1; if (index >= 0) { - ir = index/10; ifib = index%10; + ir = index / 10; + ifib = index % 10; } pmtR1.push_back(ir); pmtFib1.push_back(ifib); } - neta = getDDDArray("indexPMTL",sv1); - for (unsigned int ii=0; ii(neta[ii]); - int ir=-1, ifib=-1; + int ir = -1, ifib = -1; if (index >= 0) { - ir = index/10; ifib = index%10; + ir = index / 10; + ifib = index % 10; } pmtR2.push_back(ir); pmtFib2.push_back(ifib); } -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerPMT: gets the Index matches for " - << neta.size() << " PMTs"; - for (unsigned int ii=0; iigetRTableHF(); std::stringstream sss; - for (unsigned int ig=0; igGetPreStepPoint(); - const G4VTouchable* touch = preStepPoint->GetTouchable(); - int boxNo = touch->GetReplicaNumber(2); - int pmtNo = touch->GetReplicaNumber(1); + G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); + const G4VTouchable* touch = preStepPoint->GetTouchable(); + int boxNo = touch->GetReplicaNumber(2); + int pmtNo = touch->GetReplicaNumber(1); if (boxNo <= 1) { - indexR = pmtR1[pmtNo-1]; - indexF = pmtFib1[pmtNo-1]; + indexR = pmtR1[pmtNo - 1]; + indexF = pmtFib1[pmtNo - 1]; } else { - indexR = pmtR2[pmtNo-1]; - indexF = pmtFib2[pmtNo-1]; + indexR = pmtR2[pmtNo - 1]; + indexF = pmtFib2[pmtNo - 1]; } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG double edep = aStep->GetTotalEnergyDeposit(); - LogDebug("HFShower") << "HFShowerPMT: Box " << boxNo << " PMT " - << pmtNo << " Mapped Indices " << indexR << ", " - << indexF << " Edeposit " << edep/MeV << " MeV; PE " - << edep*pePerGeV/GeV; + edm::LogVerbatim("HFShower") << "HFShowerPMT: Box " << boxNo << " PMT " << pmtNo << " Mapped Indices " << indexR + << ", " << indexF << " Edeposit " << edep / MeV << " MeV; PE " << edep * pePerGeV / GeV; #endif double photons = 0; if (indexR >= 0 && indexF > 0) { - G4Track *aTrack = aStep->GetTrack(); - G4ParticleDefinition *particleDef = aTrack->GetDefinition(); + G4Track* aTrack = aStep->GetTrack(); + G4ParticleDefinition* particleDef = aTrack->GetDefinition(); double stepl = aStep->GetStepLength(); - double beta = preStepPoint->GetBeta(); + double beta = preStepPoint->GetBeta(); G4ThreeVector pDir = aTrack->GetDynamicParticle()->GetMomentumDirection(); - G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()-> - GetTopTransform().TransformAxis(pDir); - photons = cherenkov->computeNPEinPMT(particleDef, beta, localMom.x(), - localMom.y(), localMom.z(), stepl); -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerPMT::getHits: for particle " - << particleDef->GetParticleName() << " Step " << stepl - << " Beta " << beta << " Direction " << pDir - << " Local " << localMom << " p.e. " << photons; -#endif - + G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformAxis(pDir); + photons = cherenkov->computeNPEinPMT(particleDef, beta, localMom.x(), localMom.y(), localMom.z(), stepl); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerPMT::getHits: for particle " << particleDef->GetParticleName() << " Step " + << stepl << " Beta " << beta << " Direction " << pDir << " Local " << localMom + << " p.e. " << photons; +#endif } return photons; } - + double HFShowerPMT::getRadius() { - double r = 0.; - if (indexR >= 0 && indexR+1 < (int)(rTable.size())) - r = 0.5*(rTable[indexR]+rTable[indexR+1]); -#ifdef DebugLog + if (indexR >= 0 && indexR + 1 < (int)(rTable.size())) + r = 0.5 * (rTable[indexR] + rTable[indexR + 1]); +#ifdef EDM_ML_DEBUG else - LogDebug("HFShower") << "HFShowerPMT::getRadius: R " << indexR - << " F " << indexF; + edm::LogVerbatim("HFShower") << "HFShowerPMT::getRadius: R " << indexR << " F " << indexF; #endif - if (indexF == 2) r =-r; -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerPMT: Radius (" << indexR << "/" << indexF - << ") " << r; + if (indexF == 2) + r = -r; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerPMT: Radius (" << indexR << "/" << indexF << ") " << r; #endif return r; } -std::vector HFShowerPMT::getDDDArray(const std::string & str, - const DDsvalues_type & sv) { - -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerPMT:getDDDArray called for " << str; +std::vector HFShowerPMT::getDDDArray(const std::string& str, const DDsvalues_type& sv) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerPMT:getDDDArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) { -#ifdef DebugLog - LogDebug("HFShower") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 2) { - edm::LogError("HFShower") << "HFShowerPMT: # of " << str - << " bins " << nval << " < 2 ==> illegal"; - throw cms::Exception("Unknown", "HFShowerPMT") - << "nval < 2 for array " << str << "\n"; + edm::LogError("HFShower") << "HFShowerPMT: # of " << str << " bins " << nval << " < 2 ==> illegal"; + throw cms::Exception("Unknown", "HFShowerPMT") << "nval < 2 for array " << str << "\n"; } return fvec; } else { edm::LogError("HFShower") << "HFShowerPMT: cannot get array " << str; - throw cms::Exception("Unknown", "HFShowerPMT") - << "cannot get array " << str << "\n"; + throw cms::Exception("Unknown", "HFShowerPMT") << "cannot get array " << str << "\n"; } } diff --git a/SimG4CMS/Calo/src/HFShowerParam.cc b/SimG4CMS/Calo/src/HFShowerParam.cc index b30b646f71af1..34427aa0385ec 100644 --- a/SimG4CMS/Calo/src/HFShowerParam.cc +++ b/SimG4CMS/Calo/src/HFShowerParam.cc @@ -22,71 +22,75 @@ #include "CLHEP/Units/GlobalPhysicalConstants.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" -#include +#include -//#define DebugLog +//#define EDM_ML_DEBUG //#define plotDebug //#define mkdebug -HFShowerParam::HFShowerParam(const std::string & name, const DDCompactView & cpv, - edm::ParameterSet const & p) : showerLibrary(nullptr), - fibre(nullptr), gflash(nullptr), - fillHisto(false) { - edm::ParameterSet m_HF = p.getParameter("HFShower"); - pePerGeV = m_HF.getParameter("PEPerGeV"); - trackEM = m_HF.getParameter("TrackEM"); - bool useShowerLibrary = m_HF.getParameter("UseShowerLibrary"); - bool useGflash = m_HF.getParameter("UseHFGflash"); - edMin = m_HF.getParameter("EminLibrary"); - onlyLong = m_HF.getParameter("OnlyLong"); - ref_index = m_HF.getParameter("RefIndex"); - double lambdaMean = m_HF.getParameter("LambdaMean"); - aperture = cos(asin(m_HF.getParameter("Aperture"))); - applyFidCut = m_HF.getParameter("ApplyFiducialCut"); - parametrizeLast = m_HF.getUntrackedParameter("ParametrizeLast",false); - edm::LogVerbatim("HFShower") << "HFShowerParam::Use of shower library is set to " - << useShowerLibrary << " Use of Gflash is set to " - << useGflash << " P.E. per GeV " << pePerGeV - << ", ref. index of fibre " << ref_index - << ", Track EM Flag " << trackEM << ", edMin " - << edMin << " GeV, use of Short fibre info in" - << " shower library set to " << !(onlyLong) - << ", use of parametrization for last part set to " - << parametrizeLast << ", Mean lambda " << lambdaMean - << ", aperture (cutoff) " << aperture - << ", Application of Fiducial Cut " << applyFidCut; +HFShowerParam::HFShowerParam(const std::string& name, const DDCompactView& cpv, edm::ParameterSet const& p) + : showerLibrary(nullptr), fibre(nullptr), gflash(nullptr), fillHisto(false) { + edm::ParameterSet m_HF = p.getParameter("HFShower"); + pePerGeV = m_HF.getParameter("PEPerGeV"); + trackEM = m_HF.getParameter("TrackEM"); + bool useShowerLibrary = m_HF.getParameter("UseShowerLibrary"); + bool useGflash = m_HF.getParameter("UseHFGflash"); + edMin = m_HF.getParameter("EminLibrary"); + onlyLong = m_HF.getParameter("OnlyLong"); + ref_index = m_HF.getParameter("RefIndex"); + double lambdaMean = m_HF.getParameter("LambdaMean"); + aperture = cos(asin(m_HF.getParameter("Aperture"))); + applyFidCut = m_HF.getParameter("ApplyFiducialCut"); + parametrizeLast = m_HF.getUntrackedParameter("ParametrizeLast", false); + edm::LogVerbatim("HFShower") << "HFShowerParam::Use of shower library is set to " << useShowerLibrary + << " Use of Gflash is set to " << useGflash << " P.E. per GeV " << pePerGeV + << ", ref. index of fibre " << ref_index << ", Track EM Flag " << trackEM << ", edMin " + << edMin << " GeV, use of Short fibre info in" + << " shower library set to " << !(onlyLong) + << ", use of parametrization for last part set to " << parametrizeLast + << ", Mean lambda " << lambdaMean << ", aperture (cutoff) " << aperture + << ", Application of Fiducial Cut " << applyFidCut; #ifdef plotDebug edm::Service tfile; if (tfile.isAvailable()) { fillHisto = true; - LogDebug("HFShower") << "HFShowerParam::Save histos in directory " - << "ProfileFromParam"; + edm::LogVerbatim("HFShower") << "HFShowerParam::Save histos in directory " + << "ProfileFromParam"; TFileDirectory showerDir = tfile->mkdir("ProfileFromParam"); - hzvem = showerDir.make("hzvem", "Longitudinal Profile (EM Part);Number of PE",330,0.0,1650.0); - hzvhad = showerDir.make("hzvhad","Longitudinal Profile (Had Part);Number of PE",330,0.0,1650.0); - em_2d_1 = showerDir.make("em_2d_1","Lateral Profile vs. Shower Depth;cm;Events",800,800.0,1600.0,100,50.0,150.0); - em_long_1 = showerDir.make("em_long_1","Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0); - em_long_1_tuned = showerDir.make("em_long_1_tuned","Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0); - em_lateral_1 = showerDir.make("em_lateral_1","Lateral Profile;cm;Events",100,50.0,150.0); - em_2d_2 = showerDir.make("em_2d_2","Lateral Profile vs. Shower Depth;cm;Events",800,800.0,1600.0,100,50.0,150.0); - em_long_2 = showerDir.make("em_long_2","Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0); - em_lateral_2 = showerDir.make("em_lateral_2","Lateral Profile;cm;Events",100,50.0,150.0); - em_long_gflash = showerDir.make("em_long_gflash","Longitudinal Profile From GFlash;cm;Number of Spots",800,800.0,1600.0); - em_long_sl = showerDir.make("em_long_sl","Longitudinal Profile From Shower Library;cm;Number of Spots",800,800.0,1600.0); + hzvem = showerDir.make("hzvem", "Longitudinal Profile (EM Part);Number of PE", 330, 0.0, 1650.0); + hzvhad = showerDir.make("hzvhad", "Longitudinal Profile (Had Part);Number of PE", 330, 0.0, 1650.0); + em_2d_1 = showerDir.make( + "em_2d_1", "Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0); + em_long_1 = + showerDir.make("em_long_1", "Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0); + em_long_1_tuned = showerDir.make( + "em_long_1_tuned", "Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0); + em_lateral_1 = showerDir.make("em_lateral_1", "Lateral Profile;cm;Events", 100, 50.0, 150.0); + em_2d_2 = showerDir.make( + "em_2d_2", "Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0); + em_long_2 = + showerDir.make("em_long_2", "Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0); + em_lateral_2 = showerDir.make("em_lateral_2", "Lateral Profile;cm;Events", 100, 50.0, 150.0); + em_long_gflash = showerDir.make( + "em_long_gflash", "Longitudinal Profile From GFlash;cm;Number of Spots", 800, 800.0, 1600.0); + em_long_sl = showerDir.make( + "em_long_sl", "Longitudinal Profile From Shower Library;cm;Number of Spots", 800, 800.0, 1600.0); } else { fillHisto = false; - edm::LogVerbatim("HFShower") << "HFShowerParam::No file is available for " - << "saving histos so the flag is set to false"; + edm::LogVerbatim("HFShower") << "HFShowerParam::No file is available for saving histos so the " + << "flag is set to false"; } #endif - - if (useShowerLibrary) showerLibrary = new HFShowerLibrary(name,cpv,p); - if (useGflash) gflash = new HFGflash(p); + + if (useShowerLibrary) + showerLibrary = new HFShowerLibrary(name, cpv, p); + if (useGflash) + gflash = new HFGflash(p); fibre = new HFFibre(name, cpv, p); attLMeanInv = fibre->attLength(lambdaMean); - edm::LogVerbatim("HFShower") << "att. length used for (lambda=" << lambdaMean - << ") = " << 1/(attLMeanInv*cm) << " cm"; + edm::LogVerbatim("HFShower") << "att. length used for (lambda=" << lambdaMean << ") = " << 1 / (attLMeanInv * cm) + << " cm"; } HFShowerParam::~HFShowerParam() { @@ -96,98 +100,96 @@ HFShowerParam::~HFShowerParam() { } void HFShowerParam::initRun(const HcalDDDSimConstants* hcons) { - if (showerLibrary) showerLibrary->initRun(nullptr, hcons); - if (fibre) fibre->initRun(hcons); + if (showerLibrary) + showerLibrary->initRun(nullptr, hcons); + if (fibre) + fibre->initRun(hcons); } -std::vector HFShowerParam::getHits(const G4Step * aStep, - double weight, - bool& isKilled) { - auto const preStepPoint = aStep->GetPreStepPoint(); - auto const track = aStep->GetTrack(); +std::vector HFShowerParam::getHits(const G4Step* aStep, double weight, bool& isKilled) { + auto const preStepPoint = aStep->GetPreStepPoint(); + auto const track = aStep->GetTrack(); bool isEM = G4TrackToParticleID::isGammaElectronPositron(track); - const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); - double zv = std::abs(hitPoint.z()) - gpar[4] - 0.5*gpar[1]; - G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(),hitPoint.y(),zv); + const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); + double zv = std::abs(hitPoint.z()) - gpar[4] - 0.5 * gpar[1]; + G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(), hitPoint.y(), zv); - double pin = (preStepPoint->GetTotalEnergy())/GeV; - double zint = hitPoint.z(); - double zz = std::abs(zint) - gpar[4]; + double pin = (preStepPoint->GetTotalEnergy()) / GeV; + double zint = hitPoint.z(); + double zz = std::abs(zint) - gpar[4]; -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: getHits " - << track->GetDefinition()->GetParticleName() - << " of energy " << pin << " GeV" - << " Pos x,y,z = " << hitPoint.x() << "," - << hitPoint.y() << "," << zint << " (" << zz << "," - << localPoint.z() << ", " - << (localPoint.z()+0.5*gpar[1]) << ") Local " - << localPoint; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam: getHits " << track->GetDefinition()->GetParticleName() + << " of energy " << pin << " GeV Pos x,y,z = " << hitPoint.x() << "," << hitPoint.y() + << "," << zint << " (" << zz << "," << localPoint.z() << ", " + << (localPoint.z() + 0.5 * gpar[1]) << ") Local " << localPoint; #endif std::vector hits; HFShowerParam::Hit hit; hit.position = hitPoint; // look for other charged particles - bool other = false; + bool other = false; double pBeta = track->GetDynamicParticle()->GetTotalMomentum() / track->GetDynamicParticle()->GetTotalEnergy(); - double dirz = (track->GetDynamicParticle()->GetMomentumDirection()).z(); - if (hitPoint.z() < 0) dirz *= -1.; -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: getHits Momentum " - <GetDynamicParticle()->GetMomentumDirection() - << " HitPoint " << hitPoint << " dirz " << dirz; -#endif - if (!isEM && track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1/ref_index) && - aStep->GetTotalEnergyDeposit() > 0.) { other = true; } + double dirz = (track->GetDynamicParticle()->GetMomentumDirection()).z(); + if (hitPoint.z() < 0) + dirz *= -1.; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam: getHits Momentum " + << track->GetDynamicParticle()->GetMomentumDirection() << " HitPoint " << hitPoint + << " dirz " << dirz; +#endif + if (!isEM && track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1 / ref_index) && + aStep->GetTotalEnergyDeposit() > 0.) { + other = true; + } // take only e+-/gamma/or special particles if (isEM || other) { // Leave out the last part double edep = 0.; - if ((!trackEM) && ((zz<(gpar[1]-gpar[2])) || parametrizeLast) && (!other)){ + if ((!trackEM) && ((zz < (gpar[1] - gpar[2])) || parametrizeLast) && (!other)) { edep = pin; isKilled = true; - } else if ((track->GetDefinition()->GetPDGCharge() != 0) && - (pBeta > (1/ref_index)) && (dirz > aperture)) { - edep = (aStep->GetTotalEnergyDeposit())/GeV; + } else if ((track->GetDefinition()->GetPDGCharge() != 0) && (pBeta > (1 / ref_index)) && (dirz > aperture)) { + edep = (aStep->GetTotalEnergyDeposit()) / GeV; } std::string path = "ShowerLibrary"; -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: getHits edep = " << edep - << " weight " << weight << " final " < 0) { if ((showerLibrary || gflash) && isKilled && pin > edMin && (!other)) { if (showerLibrary) { - std::vector hitSL = showerLibrary->getHits(aStep,isKilled,weight,onlyLong); - for (unsigned int i=0; i hitSL = showerLibrary->getHits(aStep, isKilled, weight, onlyLong); + for (unsigned int i = 0; i < hitSL.size(); i++) { bool ok = true; -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShowerParam: getHits applyFidCut = " << applyFidCut; #endif - if (applyFidCut) { // @@ For showerlibrary no z-cut for Short (no z) - int npmt = HFFibreFiducial:: PMTNumber(hitSL[i].position); - if (npmt <= 0) ok = false; - } + if (applyFidCut) { // @@ For showerlibrary no z-cut for Short (no z) + int npmt = HFFibreFiducial::PMTNumber(hitSL[i].position); + if (npmt <= 0) + ok = false; + } if (ok) { hit.position = hitSL[i].position; - hit.depth = hitSL[i].depth; - hit.time = hitSL[i].time; - hit.edep = 1; + hit.depth = hitSL[i].depth; + hit.time = hitSL[i].time; + hit.edep = 1; hits.push_back(hit); #ifdef plotDebug if (fillHisto) { - double zv = std::abs(hit.position.z()) - gpar[4]; + double zv = std::abs(hit.position.z()) - gpar[4]; hzvem->Fill(zv); - em_long_sl->Fill(hit.position.z()/cm); - double sq = sqrt(pow(hit.position.x()/cm,2)+pow(hit.position.y()/cm,2)); - double zp = hit.position.z()/cm; + em_long_sl->Fill(hit.position.z() / cm); + double sq = sqrt(pow(hit.position.x() / cm, 2) + pow(hit.position.y() / cm, 2)); + double zp = hit.position.z() / cm; if (hit.depth == 1) { - em_2d_1->Fill(zp, sq); + em_2d_1->Fill(zp, sq); em_lateral_1->Fill(sq); em_long_1->Fill(zp); } else if (hit.depth == 2) { @@ -197,93 +199,87 @@ std::vector HFShowerParam::getHits(const G4Step * aStep, } } #endif -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: Hit at depth " - << hit.depth << " with edep " << hit.edep - << " Time " << hit.time; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") + << "HFShowerParam: Hit at depth " << hit.depth << " with edep " << hit.edep << " Time " << hit.time; #endif } } - } else { // GFlash clusters with known z - std::vectorhitSL=gflash->gfParameterization(aStep, onlyLong); - for (unsigned int i=0; i hitSL = gflash->gfParameterization(aStep, onlyLong); + for (unsigned int i = 0; i < hitSL.size(); ++i) { bool ok = true; - G4ThreeVector pe_effect(hitSL[i].position.x(), hitSL[i].position.y(), - hitSL[i].position.z()); - double zv = std::abs(pe_effect.z()) - gpar[4]; + G4ThreeVector pe_effect(hitSL[i].position.x(), hitSL[i].position.y(), hitSL[i].position.z()); + double zv = std::abs(pe_effect.z()) - gpar[4]; //depth - int depth = 1; - int npmt = 0; + int depth = 1; + int npmt = 0; if (zv < 0. || zv > gpar[1]) { #ifdef mkdebug - std::cout<<"-#Zcut-HFShowerParam::getHits:z="< 0.5) depth = 2; - if (depth == 2 && zv < gpar[0]) ok = false; + if (G4UniformRand() > 0.5) + depth = 2; + if (depth == 2 && zv < gpar[0]) + ok = false; } //attenuation - double dist = fibre->zShift(localPoint,depth,0); // distance to PMT - double r1 = G4UniformRand(); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam:Distance to PMT (" < exp(-attLMeanInv*zv)); + double dist = fibre->zShift(localPoint, depth, 0); // distance to PMT + double r1 = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam:Distance to PMT (" << npmt << ") " << dist + << ", exclusion flag " << (r1 > exp(-attLMeanInv * zv)); #endif - if (r1 > exp(-attLMeanInv*dist)) ok = false; + if (r1 > exp(-attLMeanInv * dist)) + ok = false; if (ok) { - double r2 = G4UniformRand(); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam:Extra exclusion " - << r2 << ">" << weight << " " - << (r2 > weight); + double r2 = G4UniformRand(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") + << "HFShowerParam:Extra exclusion " << r2 << ">" << weight << " " << (r2 > weight); #endif if (r2 < weight) { - double time = fibre->tShift(localPoint,depth,0); + double time = fibre->tShift(localPoint, depth, 0); hit.position = hitSL[i].position; - hit.depth = depth; - hit.time = time + hitSL[i].time; - hit.edep = 1; + hit.depth = depth; + hit.time = time + hitSL[i].time; + hit.edep = 1; hits.push_back(hit); #ifdef plotDebug if (fillHisto) { - em_long_gflash->Fill(pe_effect.z()/cm, hitSL[i].edep); + em_long_gflash->Fill(pe_effect.z() / cm, hitSL[i].edep); hzvem->Fill(zv); - double sq = sqrt(pow(hit.position.x()/cm,2)+pow(hit.position.y()/cm,2)); - double zp = hit.position.z()/cm; + double sq = sqrt(pow(hit.position.x() / cm, 2) + pow(hit.position.y() / cm, 2)); + double zp = hit.position.z() / cm; if (hit.depth == 1) { em_2d_1->Fill(zp, sq); em_lateral_1->Fill(s); @@ -295,37 +291,36 @@ std::vector HFShowerParam::getHits(const G4Step * aStep, } } #endif -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: Hit at depth " - << hit.depth << " with edep " - << hit.edep << " Time " << hit.time; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") + << "HFShowerParam: Hit at depth " << hit.depth << " with edep " << hit.edep << " Time " << hit.time; #endif } } } } } else { - path = "Rest"; - edep *= pePerGeV; + path = "Rest"; + edep *= pePerGeV; double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime()); - double time = fibre->tShift(localPoint,1,0); // remaining part + double time = fibre->tShift(localPoint, 1, 0); // remaining part bool ok = true; - if (applyFidCut) { // @@ For showerlibrary no z-cut for Short (no z) - int npmt = HFFibreFiducial:: PMTNumber(hitPoint); - if (npmt <= 0) ok = false; - } -#ifdef DebugLog + if (applyFidCut) { // @@ For showerlibrary no z-cut for Short (no z) + int npmt = HFFibreFiducial::PMTNumber(hitPoint); + if (npmt <= 0) + ok = false; + } +#ifdef EDM_ML_DEBUG edm::LogVerbatim("HFShower") << "HFShowerParam: getHits hitPoint " << hitPoint << " flag " << ok; #endif if (ok) { - hit.depth = 1; - hit.time = tSlice+time; - hit.edep = edep; + hit.depth = 1; + hit.time = tSlice + time; + hit.edep = edep; hits.push_back(hit); -#ifdef DebugLog - edm::LogVerbatim("HFShower") << "HFShowerParam: Hit at depth 1 with edep " - << edep << " Time " << tSlice << ":" << time - << ":" << hit.time; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam: Hit at depth 1 with edep " << edep << " Time " << tSlice + << ":" << time << ":" << hit.time; #endif #ifdef plotDebug double zv = std::abs(hitPoint.z()) - gpar[4]; @@ -334,14 +329,13 @@ std::vector HFShowerParam::getHits(const G4Step * aStep, } #endif if (zz >= gpar[0]) { - time = fibre->tShift(localPoint,2,0); + time = fibre->tShift(localPoint, 2, 0); hit.depth = 2; - hit.time = tSlice+time; + hit.time = tSlice + time; hits.push_back(hit); -#ifdef DebugLog - edm::LogVerbatim("HFShower") <<"HFShowerParam: Hit at depth 2 with edep " - << edep << " Time " << tSlice << ":" << time - << hit.time; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam: Hit at depth 2 with edep " << edep << " Time " << tSlice + << ":" << time << hit.time; #endif #ifdef plotDebug if (fillHisto) { @@ -351,52 +345,42 @@ std::vector HFShowerParam::getHits(const G4Step * aStep, } } } -#ifdef DebugLog - for (unsigned int ii=0; ii 12790) edm::LogVerbatim("HFShower")<< "HFShowerParam: Abnormal hit along " - << path << " in " - << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName() - << " at " << hits[ii].position << " zz " - << zv << " Edep " << edep << " due to " - <GetDefinition()->GetParticleName() - << " time " << hit.time; + if (zv > 12790) + edm::LogVerbatim("HFShower") << "HFShowerParam: Abnormal hit along " << path << " in " + << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName() << " at " + << hits[ii].position << " zz " << zv << " Edep " << edep << " due to " + << track->GetDefinition()->GetParticleName() << " time " << hit.time; } - edm::LogVerbatim("HFShower") << "HFShowerParam: getHits kill (" << kill - << ") track " << track->GetTrackID() - << " at " << hitPoint - << " and deposit " << edep << " " << hits.size() - << " times" << " ZZ " << zz << " " << gpar[0]; + edm::LogVerbatim("HFShower") << "HFShowerParam: getHits kill (" << isKilled << ") track " << track->GetTrackID() + << " at " << hitPoint << " and deposit " << edep << " " << hits.size() << " times" + << " ZZ " << zz << " " << gpar[0]; #endif } } return hits; } -std::vector HFShowerParam::getDDDArray(const std::string & str, - const DDsvalues_type & sv) -{ -#ifdef DebugLog - LogDebug("HFShower") << "HFShowerParam:getDDDArray called for " << str; +std::vector HFShowerParam::getDDDArray(const std::string& str, const DDsvalues_type& sv) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << "HFShowerParam:getDDDArray called for " << str; #endif DDValue value(str); - if (DDfetch(&sv,value)) - { -#ifdef DebugLog - LogDebug("HFShower") << value; + if (DDfetch(&sv, value)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HFShower") << value; #endif - const std::vector & fvec = value.doubles(); + const std::vector& fvec = value.doubles(); int nval = fvec.size(); if (nval < 2) { - edm::LogError("HFShower") << "HFShowerParam : # of " << str - << " bins " << nval << " < 2 ==> illegal"; - throw cms::Exception("Unknown", "HFShowerParam") << "nval < 2 for array " - << str << "\n"; + edm::LogError("HFShower") << "HFShowerParam : # of " << str << " bins " << nval << " < 2 ==> illegal"; + throw cms::Exception("Unknown", "HFShowerParam") << "nval < 2 for array " << str << "\n"; } return fvec; } else { edm::LogError("HFShower") << "HFShowerParam : cannot get array " << str; - throw cms::Exception("Unknown", "HFShowerParam") << "cannot get array " - << str << "\n"; + throw cms::Exception("Unknown", "HFShowerParam") << "cannot get array " << str << "\n"; } } diff --git a/SimG4CMS/Calo/src/HGCMouseBite.cc b/SimG4CMS/Calo/src/HGCMouseBite.cc index aec7a7ba2c299..89b58ee96ba91 100644 --- a/SimG4CMS/Calo/src/HGCMouseBite.cc +++ b/SimG4CMS/Calo/src/HGCMouseBite.cc @@ -6,32 +6,26 @@ //#define EDM_ML_DEBUG -HGCMouseBite::HGCMouseBite(const HGCalDDDConstants& hgc, - const std::vector& angle, double maxL, - bool rot) : hgcons_(hgc), cut_(maxL), rot_(rot) { - - modeUV_ = ((hgcons_.geomMode() == HGCalGeometryMode::Hexagon8) || - (hgcons_.geomMode() == HGCalGeometryMode::Hexagon8Full)); +HGCMouseBite::HGCMouseBite(const HGCalDDDConstants& hgc, const std::vector& angle, double maxL, bool rot) + : hgcons_(hgc), cut_(maxL), rot_(rot) { + modeUV_ = + ((hgcons_.geomMode() == HGCalGeometryMode::Hexagon8) || (hgcons_.geomMode() == HGCalGeometryMode::Hexagon8Full)); for (auto ang : angle) { - projXY_.push_back(std::pair(cos(ang*CLHEP::deg),sin(ang*CLHEP::deg))); + projXY_.push_back(std::pair(cos(ang * CLHEP::deg), sin(ang * CLHEP::deg))); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Creating HGCMosueBite with cut at " << cut_ - << " with mode " << modeUV_ << " along " - << angle.size() << " axes"; - for (unsigned int k=0; k xy = (modeUV_ ? - hgcons_.waferPosition(waferU,waferV,false) : - hgcons_.waferPosition(waferU,false)); + std::pair xy = + (modeUV_ ? hgcons_.waferPosition(waferU, waferV, false) : hgcons_.waferPosition(waferU, false)); double xx = (zside > 0) ? xy.first : -xy.first; double dx(0), dy(0); if (rot_) { @@ -42,15 +36,16 @@ bool HGCMouseBite::exclude(G4ThreeVector& point, int zside, int waferU, dy = std::abs(point.y() - xy.second); } for (auto proj : projXY_) { - double dist = dx*proj.first + dy*proj.second; - if (dist > cut_) {check = true; break;} + double dist = dx * proj.first + dy * proj.second; + if (dist > cut_) { + check = true; + break; + } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCMouseBite:: Point " << point << " zside " - << zside << " wafer " << waferU << ":" << waferV - << " position " << xy.first << ":" << xx << ":" - << xy.second << " dxy " << dx << ":" << dy - << " check " << check; + edm::LogVerbatim("HGCSim") << "HGCMouseBite:: Point " << point << " zside " << zside << " wafer " << waferU << ":" + << waferV << " position " << xy.first << ":" << xx << ":" << xy.second << " dxy " << dx + << ":" << dy << " check " << check; #endif return check; } diff --git a/SimG4CMS/Calo/src/HGCNumberingScheme.cc b/SimG4CMS/Calo/src/HGCNumberingScheme.cc index 5f25119e4d9df..b12aac3d93f79 100644 --- a/SimG4CMS/Calo/src/HGCNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HGCNumberingScheme.cc @@ -15,69 +15,58 @@ //#define EDM_ML_DEBUG -HGCNumberingScheme::HGCNumberingScheme(const HGCalDDDConstants& hgc, - std::string & name ) : - hgcons_(hgc) { - edm::LogInfo("HGCSim") << "Creating HGCNumberingScheme for " << name; +HGCNumberingScheme::HGCNumberingScheme(const HGCalDDDConstants& hgc, std::string& name) : hgcons_(hgc) { + edm::LogVerbatim("HGCSim") << "Creating HGCNumberingScheme for " << name; } -HGCNumberingScheme::~HGCNumberingScheme() { - edm::LogInfo("HGCSim") << "Deleting HGCNumberingScheme"; -} +HGCNumberingScheme::~HGCNumberingScheme() { edm::LogVerbatim("HGCSim") << "Deleting HGCNumberingScheme"; } -uint32_t HGCNumberingScheme::getUnitID(ForwardSubdetector subdet, int layer, - int module, int cell, int iz, - const G4ThreeVector &pos) { +uint32_t HGCNumberingScheme::getUnitID( + ForwardSubdetector subdet, int layer, int module, int cell, int iz, const G4ThreeVector& pos) { // module is the copy number of the wafer as placed in the layer - int icell(0), celltyp(0), wafer(0); + int icell(0), celltyp(0), wafer(0); uint32_t index(0); if (hgcons_.geomMode() == HGCalGeometryMode::HexagonFull) { if (cell >= 0) { - wafer = hgcons_.waferFromCopy(module); - celltyp = cell/1000; - icell = cell%1000; + wafer = hgcons_.waferFromCopy(module); + celltyp = cell / 1000; + icell = cell % 1000; } else { - hgcons_.waferFromPosition(pos.x(),pos.y(),wafer,icell,celltyp); + hgcons_.waferFromPosition(pos.x(), pos.y(), wafer, icell, celltyp); } if (wafer >= 0) { - if (celltyp != 1) celltyp = 0; - index = HGCalTestNumbering::packHexagonIndex((int)subdet,iz,layer,wafer, - celltyp,icell); + if (celltyp != 1) + celltyp = 0; + index = HGCalTestNumbering::packHexagonIndex((int)subdet, iz, layer, wafer, celltyp, icell); } } else if (hgcons_.geomMode() == HGCalGeometryMode::Hexagon) { - wafer = hgcons_.waferFromCopy(module); - celltyp = cell/1000; - icell = cell%1000; - if (celltyp != 1) celltyp = 0; - - index = HGCalTestNumbering::packHexagonIndex((int)subdet,iz,layer,wafer, - celltyp,icell); + wafer = hgcons_.waferFromCopy(module); + celltyp = cell / 1000; + icell = cell % 1000; + if (celltyp != 1) + celltyp = 0; + + index = HGCalTestNumbering::packHexagonIndex((int)subdet, iz, layer, wafer, celltyp, icell); //check if it fits - if (!hgcons_.isValidHex(layer,wafer,icell,false)) { + if (!hgcons_.isValidHex(layer, wafer, icell, false)) { index = 0; edm::LogError("HGCSim") << "[HGCNumberingScheme] ID out of bounds :" - << " Subdet= " << subdet << " Zside= " << iz - << " Layer= " << layer << " Wafer= " << wafer - << ":" << module << " CellType= " << celltyp - << " Cell= " << icell; + << " Subdet= " << subdet << " Zside= " << iz << " Layer= " << layer << " Wafer= " << wafer + << ":" << module << " CellType= " << celltyp << " Cell= " << icell; } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCNumberingScheme::i/p " << subdet << ":" - << layer << ":" << module << ":" << iz << ":" - << wafer << ":" << celltyp << ":" << icell << ":" - << std::hex << index << std::dec; + edm::LogVerbatim("HGCSim") << "HGCNumberingScheme::i/p " << subdet << ":" << layer << ":" << module << ":" << iz + << ":" << wafer << ":" << celltyp << ":" << icell << ":" << std::hex << index << std::dec; #endif return index; } int HGCNumberingScheme::assignCell(float x, float y, int layer) { - - std::pair phicell = hgcons_.assignCell(x,y,layer,0,false); + std::pair phicell = hgcons_.assignCell(x, y, layer, 0, false); return phicell.second; } -std::pair HGCNumberingScheme::getLocalCoords(int cell, int layer){ - - return hgcons_.locateCell(cell,layer,0,false); +std::pair HGCNumberingScheme::getLocalCoords(int cell, int layer) { + return hgcons_.locateCell(cell, layer, 0, false); } diff --git a/SimG4CMS/Calo/src/HGCSD.cc b/SimG4CMS/Calo/src/HGCSD.cc index 5d9325c209da3..8b5f788316216 100644 --- a/SimG4CMS/Calo/src/HGCSD.cc +++ b/SimG4CMS/Calo/src/HGCSD.cc @@ -36,100 +36,102 @@ //#define EDM_ML_DEBUG //#define plotDebug -HGCSD::HGCSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager) : - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), - p.getParameter("HGCSD").getParameter("IgnoreTrackID")), - slopeMin_(0), levelT_(99), tree_(nullptr) { - - numberingScheme_.reset(nullptr); mouseBite_.reset(nullptr); +HGCSD::HGCSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), + p.getParameter("HGCSD").getParameter("IgnoreTrackID")), + slopeMin_(0), + levelT_(99), + tree_(nullptr) { + numberingScheme_.reset(nullptr); + mouseBite_.reset(nullptr); edm::ParameterSet m_HGC = p.getParameter("HGCSD"); - eminHit_ = m_HGC.getParameter("EminHit")*CLHEP::MeV; - storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); - rejectMB_ = m_HGC.getParameter("RejectMouseBite"); - waferRot_ = m_HGC.getParameter("RotatedWafer"); - angles_ = m_HGC.getUntrackedParameter>("WaferAngles"); - double waferSize = m_HGC.getUntrackedParameter("WaferSize")*CLHEP::mm; - double mouseBite = m_HGC.getUntrackedParameter("MouseBite")*CLHEP::mm; - mouseBiteCut_ = waferSize*tan(30.0*CLHEP::deg) - mouseBite; + eminHit_ = m_HGC.getParameter("EminHit") * CLHEP::MeV; + storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); + rejectMB_ = m_HGC.getParameter("RejectMouseBite"); + waferRot_ = m_HGC.getParameter("RotatedWafer"); + angles_ = m_HGC.getUntrackedParameter>("WaferAngles"); + double waferSize = m_HGC.getUntrackedParameter("WaferSize") * CLHEP::mm; + double mouseBite = m_HGC.getUntrackedParameter("MouseBite") * CLHEP::mm; + mouseBiteCut_ = waferSize * tan(30.0 * CLHEP::deg) - mouseBite; - if(storeAllG4Hits_) { + if (storeAllG4Hits_) { setUseMap(false); setNumberCheckedHits(0); } //this is defined in the hgcsens.xml G4String myName = name; - myFwdSubdet_= ForwardSubdetector::ForwardEmpty; + myFwdSubdet_ = ForwardSubdetector::ForwardEmpty; nameX_ = "HGCal"; - if (myName.find("HitsEE")!=std::string::npos) { + if (myName.find("HitsEE") != std::string::npos) { myFwdSubdet_ = ForwardSubdetector::HGCEE; - nameX_ = "HGCalEESensitive"; - } else if (myName.find("HitsHEfront")!=std::string::npos) { + nameX_ = "HGCalEESensitive"; + } else if (myName.find("HitsHEfront") != std::string::npos) { myFwdSubdet_ = ForwardSubdetector::HGCHEF; - nameX_ = "HGCalHESiliconSensitive"; - } else if (myName.find("HitsHEback")!=std::string::npos) { + nameX_ = "HGCalHESiliconSensitive"; + } else if (myName.find("HitsHEback") != std::string::npos) { myFwdSubdet_ = ForwardSubdetector::HGCHEB; - nameX_ = "HGCalHEScintillatorSensitive"; + nameX_ = "HGCalHEScintillatorSensitive"; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim")<< "**************************************************" - << "\n" - << "* *" - << "\n" - << "* Constructing a HGCSD with name " << name << "\n" - << "* *" - << "\n" - << "**************************************************"; + edm::LogVerbatim("HGCSim") << "**************************************************" + << "\n" + << "* *" + << "\n" + << "* Constructing a HGCSD with name " << name << "\n" + << "* *" + << "\n" + << "**************************************************"; #endif - edm::LogVerbatim("HGCSim") << "HGCSD:: Threshold for storing hits: " - << eminHit << " for " << nameX_ << " subdet " - << myFwdSubdet_; - edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " - << storeAllG4Hits_; - edm::LogVerbatim("HGCSim") << "Reject MosueBite Flag: " << rejectMB_ - << " Size of wafer " << waferSize - << " Mouse Bite " << mouseBite << ":" - << mouseBiteCut_ << " along " << angles_.size() - << " axes"; + edm::LogVerbatim("HGCSim") << "HGCSD:: Threshold for storing hits: " << eminHit << " for " << nameX_ << " subdet " + << myFwdSubdet_; + edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_; + edm::LogVerbatim("HGCSim") << "Reject MosueBite Flag: " << rejectMB_ << " Size of wafer " << waferSize + << " Mouse Bite " << mouseBite << ":" << mouseBiteCut_ << " along " << angles_.size() + << " axes"; } double HGCSD::getEnergyDeposit(const G4Step* aStep) { - double r = aStep->GetPreStepPoint()->GetPosition().perp(); double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z()); #ifdef EDM_ML_DEBUG G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); - G4LogicalVolume* lv = - aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); - edm::LogVerbatim("HGCSim") << "HGCSD: Hit from standard path from " - << lv->GetName() << " for Track " - << aStep->GetTrack()->GetTrackID() << " (" - << aStep->GetTrack()->GetDefinition()->GetParticleName() - << ") R = " << r << " Z = " - << z << " slope = " << r/z << ":" << slopeMin_; + G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); + edm::LogVerbatim("HGCSim") << "HGCSD: Hit from standard path from " << lv->GetName() << " for Track " + << aStep->GetTrack()->GetTrackID() << " (" + << aStep->GetTrack()->GetDefinition()->GetParticleName() << ") R = " << r << " Z = " << z + << " slope = " << r / z << ":" << slopeMin_; #endif // Apply fiductial volume - if (r < z*slopeMin_) { return 0.0; } - - double wt1 = getResponseWt(aStep->GetTrack()); - double wt2 = aStep->GetTrack()->GetWeight(); - double destep = wt1*aStep->GetTotalEnergyDeposit(); - if (wt2 > 0) destep *= wt2; + if (r < z * slopeMin_) { + return 0.0; + } + + double wt1 = getResponseWt(aStep->GetTrack()); + double wt2 = aStep->GetTrack()->GetWeight(); + double destep = wt1 * aStep->GetTotalEnergyDeposit(); + if (wt2 > 0) + destep *= wt2; #ifdef plotDebug const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); G4double tmptrackE = aStep->GetTrack()->GetKineticEnergy(); - G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); - G4double angle = (aStep->GetTrack()->GetMomentumDirection().theta())/CLHEP::deg; - G4int layer = ((touch->GetHistoryDepth() == levelT_) ? - touch->GetReplicaNumber(0) : touch->GetReplicaNumber(2)); - G4int ilayer = (layer-1)/3; + G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); + G4double angle = (aStep->GetTrack()->GetMomentumDirection().theta()) / CLHEP::deg; + G4int layer = ((touch->GetHistoryDepth() == levelT_) ? touch->GetReplicaNumber(0) : touch->GetReplicaNumber(2)); + G4int ilayer = (layer - 1) / 3; if (aStep->GetTotalEnergyDeposit() > 0) { t_Layer_.emplace_back(ilayer); t_Parcode_.emplace_back(parCode); @@ -143,92 +145,81 @@ double HGCSD::getEnergyDeposit(const G4Step* aStep) { return destep; } -uint32_t HGCSD::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t HGCSD::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); - //determine the exact position in global coordinates in the mass geometry - G4ThreeVector hitPoint = preStepPoint->GetPosition(); - float globalZ=touch->GetTranslation(0).z(); - int iz( globalZ>0 ? 1 : -1); + //determine the exact position in global coordinates in the mass geometry + G4ThreeVector hitPoint = preStepPoint->GetPosition(); + float globalZ = touch->GetTranslation(0).z(); + int iz(globalZ > 0 ? 1 : -1); - //convert to local coordinates (=local to the current volume): + //convert to local coordinates (=local to the current volume): G4ThreeVector localpos = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint); - - //get the det unit id with + + //get the det unit id with ForwardSubdetector subdet = myFwdSubdet_; int layer, module, cell; if (touch->GetHistoryDepth() == levelT_) { - layer = touch->GetReplicaNumber(0); + layer = touch->GetReplicaNumber(0); module = -1; - cell = -1; + cell = -1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName() + << " layer:module:cell " << layer << ":" << module << ":" << cell; #endif } else { - layer = touch->GetReplicaNumber(2); + layer = touch->GetReplicaNumber(2); module = touch->GetReplicaNumber(1); - cell = touch->GetReplicaNumber(0); + cell = touch->GetReplicaNumber(0); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << ":" << touch->GetReplicaNumber(0) << " " - << touch->GetVolume(1)->GetName() - << ":" << touch->GetReplicaNumber(1) << " " - << touch->GetVolume(2)->GetName() - << ":" << touch->GetReplicaNumber(2) << " " - << " layer:module:cell " << layer << ":" - << module << ":" << cell <<" Material " - << mat->GetName() << ":" - << aStep->GetPreStepPoint()->GetMaterial()->GetRadlen(); + edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName() + << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":" + << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":" + << touch->GetReplicaNumber(2) << " " + << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material " + << mat->GetName() << ":" << aStep->GetPreStepPoint()->GetMaterial()->GetRadlen(); #endif // The following statement should be examined later before elimination - // VI: this is likely a check if media is vacuum - not needed - if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) return 0; - - uint32_t id = setDetUnitId (subdet, layer, module, cell, iz, localpos); + // VI: this is likely a check if media is vacuum - not needed + if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) + return 0; + + uint32_t id = setDetUnitId(subdet, layer, module, cell, iz, localpos); if (rejectMB_ && id != 0) { int det, z, lay, wafer, type, ic; HGCalTestNumbering::unpackHexagonIndex(id, det, z, lay, wafer, type, ic); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec - << " Decode " << det << ":" << z << ":" << lay - << ":" << wafer << ":" << type << ":" << ic; + edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec << " Decode " << det << ":" << z << ":" << lay + << ":" << wafer << ":" << type << ":" << ic; #endif - if (mouseBite_->exclude(hitPoint, z, wafer, 0)) id = 0; + if (mouseBite_->exclude(hitPoint, z, wafer, 0)) + id = 0; } return id; } -void HGCSD::update(const BeginOfJob * job) { - +void HGCSD::update(const BeginOfJob* job) { const edm::EventSetup* es = (*job)(); - edm::ESHandle hdc; - es->get().get(nameX_,hdc); + edm::ESHandle hdc; + es->get().get(nameX_, hdc); if (hdc.isValid()) { const HGCalDDDConstants* hgcons = hdc.product(); - geom_mode_ = hgcons->geomMode(); - slopeMin_ = hgcons->minSlope(); - levelT_ = hgcons->levelTop(); - numberingScheme_.reset(new HGCNumberingScheme(*hgcons,nameX_)); - if (rejectMB_) mouseBite_.reset(new HGCMouseBite(*hgcons,angles_, - mouseBiteCut_,waferRot_)); + geom_mode_ = hgcons->geomMode(); + slopeMin_ = hgcons->minSlope(); + levelT_ = hgcons->levelTop(); + numberingScheme_.reset(new HGCNumberingScheme(*hgcons, nameX_)); + if (rejectMB_) + mouseBite_.reset(new HGCMouseBite(*hgcons, angles_, mouseBiteCut_, waferRot_)); } else { - edm::LogError("HGCSim") << "HCalSD : Cannot find HGCalDDDConstants for " - << nameX_; - throw cms::Exception("Unknown", "HGCSD") - << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; + edm::LogError("HGCSim") << "HCalSD : Cannot find HGCalDDDConstants for " << nameX_; + throw cms::Exception("Unknown", "HGCSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCSD::Initialized with mode " << geom_mode_ - << " Slope cut " << slopeMin_ << " top Level " - << levelT_; + edm::LogVerbatim("HGCSim") << "HGCSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_ + << " top Level " << levelT_; #endif } @@ -237,13 +228,13 @@ void HGCSD::initRun() { edm::Service tfile; if (tfile.isAvailable()) { tree_ = tfile->make("TreeHGCSD", "TreeHGCSD"); - tree_->Branch("EventID", &t_EventID_); - tree_->Branch("Layer", &t_Layer_); - tree_->Branch("ParticleCode", &t_Parcode_); + tree_->Branch("EventID", &t_EventID_); + tree_->Branch("Layer", &t_Layer_); + tree_->Branch("ParticleCode", &t_Parcode_); tree_->Branch("dEStepOriginal", &t_dEStep1_); tree_->Branch("dEStepWeighted", &t_dEStep2_); - tree_->Branch("TrackEnergy", &t_TrackE_); - tree_->Branch("ThetaAngle", &t_Angle_); + tree_->Branch("TrackEnergy", &t_TrackE_); + tree_->Branch("ThetaAngle", &t_Angle_); } #endif } @@ -263,7 +254,8 @@ void HGCSD::initEvent(const BeginOfEvent* g4Event) { void HGCSD::endEvent() { #ifdef plotDebug - if (tree_) tree_->Fill(); + if (tree_) + tree_->Fill(); #endif } @@ -271,10 +263,7 @@ bool HGCSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_)); } -uint32_t HGCSD::setDetUnitId (ForwardSubdetector &subdet, int layer, int module, - int cell, int iz, G4ThreeVector &pos) { - uint32_t id = numberingScheme_ ? - numberingScheme_->getUnitID(subdet, layer, module, cell, iz, pos) : 0; +uint32_t HGCSD::setDetUnitId(ForwardSubdetector& subdet, int layer, int module, int cell, int iz, G4ThreeVector& pos) { + uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(subdet, layer, module, cell, iz, pos) : 0; return id; } - diff --git a/SimG4CMS/Calo/src/HGCScintSD.cc b/SimG4CMS/Calo/src/HGCScintSD.cc index e9cdc19760bb4..f7ac2ed7982e2 100644 --- a/SimG4CMS/Calo/src/HGCScintSD.cc +++ b/SimG4CMS/Calo/src/HGCScintSD.cc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // File: HGCScintSD.cc -// Description: Sensitive Detector class for the Scintillator part of +// Description: Sensitive Detector class for the Scintillator part of // High Granularity Calorimeter /////////////////////////////////////////////////////////////////////////////// @@ -34,26 +34,33 @@ //#define EDM_ML_DEBUG -HGCScintSD::HGCScintSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, - const SimTrackManager* manager): - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), - p.getParameter("HGCSD").getParameter("IgnoreTrackID")), - hgcons_(nullptr), slopeMin_(0), levelT1_(99), levelT2_(99) { - +HGCScintSD::HGCScintSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), + p.getParameter("HGCSD").getParameter("IgnoreTrackID")), + hgcons_(nullptr), + slopeMin_(0), + levelT1_(99), + levelT2_(99) { numberingScheme_.reset(nullptr); edm::ParameterSet m_HGC = p.getParameter("HGCScintSD"); - eminHit_ = m_HGC.getParameter("EminHit")*CLHEP::MeV; - fiducialCut_ = m_HGC.getParameter("FiducialCut"); - distanceFromEdge_= m_HGC.getParameter("DistanceFromEdge"); - useBirk_ = m_HGC.getParameter("UseBirkLaw"); - birk1_ = m_HGC.getParameter("BirkC1")*(CLHEP::g/(CLHEP::MeV*CLHEP::cm2)); - birk2_ = m_HGC.getParameter("BirkC2"); - birk3_ = m_HGC.getParameter("BirkC3"); - storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); + eminHit_ = m_HGC.getParameter("EminHit") * CLHEP::MeV; + fiducialCut_ = m_HGC.getParameter("FiducialCut"); + distanceFromEdge_ = m_HGC.getParameter("DistanceFromEdge"); + useBirk_ = m_HGC.getParameter("UseBirkLaw"); + birk1_ = m_HGC.getParameter("BirkC1") * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2)); + birk2_ = m_HGC.getParameter("BirkC2"); + birk3_ = m_HGC.getParameter("BirkC3"); + storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); if (storeAllG4Hits_) { setUseMap(false); @@ -64,180 +71,153 @@ HGCScintSD::HGCScintSD(const std::string& name, const DDCompactView & cpv, G4String myName = name; mydet_ = DetId::Forward; nameX_ = "HGCal"; - if (myName.find("HitsHEback")!=std::string::npos) { - mydet_ = DetId::HGCalHSc; - nameX_ = "HGCalHEScintillatorSensitive"; + if (myName.find("HitsHEback") != std::string::npos) { + mydet_ = DetId::HGCalHSc; + nameX_ = "HGCalHEScintillatorSensitive"; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim")<< "**************************************************" - << "\n" - << "* *" - << "\n" - << "* Constructing a HGCScintSD with name " << name << "\n" - << "* *" - << "\n" - << "**************************************************"; + edm::LogVerbatim("HGCSim") << "**************************************************" + << "\n" + << "* *" + << "\n" + << "* Constructing a HGCScintSD with name " << name << "\n" + << "* *" + << "\n" + << "**************************************************"; #endif - edm::LogVerbatim("HGCSim") << "HGCScintSD:: Threshold for storing hits: " - << eminHit_ << " for " << nameX_ << " detector " - << mydet_; - edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " - << storeAllG4Hits_; + edm::LogVerbatim("HGCSim") << "HGCScintSD:: Threshold for storing hits: " << eminHit_ << " for " << nameX_ + << " detector " << mydet_; + edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_; edm::LogVerbatim("HGCSim") << "Fiducial volume cut with cut from eta/phi " - << "boundary " << fiducialCut_ << " at " - << distanceFromEdge_; + << "boundary " << fiducialCut_ << " at " << distanceFromEdge_; edm::LogVerbatim("HGCSim") << "Use of Birks law is set to " << useBirk_ - << " with three constants kB = " << birk1_ - << ", C1 = " << birk2_ << ", C2 = " << birk3_; + << " with three constants kB = " << birk1_ << ", C1 = " << birk2_ << ", C2 = " << birk3_; } double HGCScintSD::getEnergyDeposit(const G4Step* aStep) { - double r = aStep->GetPreStepPoint()->GetPosition().perp(); double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z()); #ifdef EDM_ML_DEBUG - G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); + G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName(); - G4LogicalVolume* lv = - aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); - edm::LogVerbatim("HGCSim") << "HGCScintSD: Hit from standard path from " - << lv->GetName() << " for Track " - << aStep->GetTrack()->GetTrackID() << " (" - << parCode << ":" << parName << ") R = " << r - << " Z = " << z << " slope = " << r/z << ":" - << slopeMin_; + G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); + edm::LogVerbatim("HGCSim") << "HGCScintSD: Hit from standard path from " << lv->GetName() << " for Track " + << aStep->GetTrack()->GetTrackID() << " (" << parCode << ":" << parName << ") R = " << r + << " Z = " << z << " slope = " << r / z << ":" << slopeMin_; #endif // Apply fiducial cut - if (r < z*slopeMin_) { + if (r < z * slopeMin_) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCSim") << "HGCScintSD: Fiducial Volume cut"; #endif - return 0.0; + return 0.0; } - double wt1 = getResponseWt(aStep->GetTrack()); - double wt2 = aStep->GetTrack()->GetWeight(); - double wt3 = (useBirk_ ? getAttenuation(aStep, birk1_, birk2_, birk3_) : - 1.0); - double destep = weight_*wt1*wt3*(aStep->GetTotalEnergyDeposit()); - if (wt2 > 0) destep *= wt2; + double wt1 = getResponseWt(aStep->GetTrack()); + double wt2 = aStep->GetTrack()->GetWeight(); + double wt3 = (useBirk_ ? getAttenuation(aStep, birk1_, birk2_, birk3_) : 1.0); + double destep = weight_ * wt1 * wt3 * (aStep->GetTotalEnergyDeposit()); + if (wt2 > 0) + destep *= wt2; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalSim") << "HGCScintSD: weights= " << weight_ << ":" - << wt1 << ":" << wt2 << ":" << wt3 - << " Total weight " << weight_*wt1*wt2*wt3 - << " deStep: " <GetTotalEnergyDeposit() - << ":" <GetTotalEnergyDeposit() << ":" << destep; #endif return destep; } -uint32_t HGCScintSD::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t HGCScintSD::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); - //determine the exact position in global coordinates in the mass geometry - G4ThreeVector hitPoint = preStepPoint->GetPosition(); - float globalZ = touch->GetTranslation(0).z(); - int iz( globalZ>0 ? 1 : -1); + //determine the exact position in global coordinates in the mass geometry + G4ThreeVector hitPoint = preStepPoint->GetPosition(); + float globalZ = touch->GetTranslation(0).z(); + int iz(globalZ > 0 ? 1 : -1); int layer, module, cell; - if ((touch->GetHistoryDepth() == levelT1_) || - (touch->GetHistoryDepth() == levelT2_)) { - layer = touch->GetReplicaNumber(0); + if ((touch->GetHistoryDepth() == levelT1_) || (touch->GetHistoryDepth() == levelT2_)) { + layer = touch->GetReplicaNumber(0); module = -1; - cell = -1; + cell = -1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() - << ":" << levelT1_ << ":" << levelT2_ - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_ + << " name " << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" + << module << ":" << cell; #endif } else { - layer = touch->GetReplicaNumber(3); + layer = touch->GetReplicaNumber(3); module = touch->GetReplicaNumber(2); - cell = touch->GetReplicaNumber(1); + cell = touch->GetReplicaNumber(1); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "DepthsInside: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HGCSim") << "DepthsInside: " << touch->GetHistoryDepth() << " name " + << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" << module + << ":" << cell; #endif } #ifdef EDM_ML_DEBUG G4Material* mat = aStep->GetPreStepPoint()->GetMaterial(); - edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << ":" << touch->GetReplicaNumber(0) << " " - << touch->GetVolume(1)->GetName() - << ":" << touch->GetReplicaNumber(1) << " " - << touch->GetVolume(2)->GetName() - << ":" << touch->GetReplicaNumber(2) << " " - << touch->GetVolume(3)->GetName() - << ":" << touch->GetReplicaNumber(3) << " " - << touch->GetVolume(4)->GetName() - << ":" << touch->GetReplicaNumber(4) << " " - << " layer:module:cell " << layer << ":" - << module << ":" << cell << " Material " - << mat->GetName() << ":" << mat->GetRadlen(); + edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName() + << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":" + << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":" + << touch->GetReplicaNumber(2) << " " << touch->GetVolume(3)->GetName() << ":" + << touch->GetReplicaNumber(3) << " " << touch->GetVolume(4)->GetName() << ":" + << touch->GetReplicaNumber(4) << " " + << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material " + << mat->GetName() << ":" << mat->GetRadlen(); #endif // The following statement should be examined later before elimination - if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) return 0; - - uint32_t id = setDetUnitId (layer, module, cell, iz, hitPoint); + if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) + return 0; + + uint32_t id = setDetUnitId(layer, module, cell, iz, hitPoint); if (!isItinFidVolume(hitPoint)) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec - << " " << HGCScintillatorDetId(id) - << " is rejected by fiducilal volume cut"; + edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec << " " << HGCScintillatorDetId(id) + << " is rejected by fiducilal volume cut"; #endif id = 0; } return id; } -void HGCScintSD::update(const BeginOfJob * job) { - +void HGCScintSD::update(const BeginOfJob* job) { const edm::EventSetup* es = (*job)(); - edm::ESHandle hdc; - es->get().get(nameX_,hdc); + edm::ESHandle hdc; + es->get().get(nameX_, hdc); if (hdc.isValid()) { - hgcons_ = hdc.product(); + hgcons_ = hdc.product(); geom_mode_ = hgcons_->geomMode(); - slopeMin_ = hgcons_->minSlope(); - levelT1_ = hgcons_->levelTop(0); - levelT2_ = hgcons_->levelTop(1); + slopeMin_ = hgcons_->minSlope(); + levelT1_ = hgcons_->levelTop(0); + levelT2_ = hgcons_->levelTop(1); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCScintSD::Initialized with mode " - << geom_mode_ << " Slope cut " << slopeMin_ - << " top Level " << levelT1_ << ":" << levelT2_; + edm::LogVerbatim("HGCSim") << "HGCScintSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_ + << " top Level " << levelT1_ << ":" << levelT2_; #endif - numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_,mydet_,nameX_)); + numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_, mydet_, nameX_)); } else { throw cms::Exception("Unknown", "HGCScintSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } } -void HGCScintSD::initRun() { -} +void HGCScintSD::initRun() {} bool HGCScintSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_)); } -uint32_t HGCScintSD::setDetUnitId (int layer, int module, int cell, int iz, - G4ThreeVector &pos) { - uint32_t id = numberingScheme_ ? - numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; +uint32_t HGCScintSD::setDetUnitId(int layer, int module, int cell, int iz, G4ThreeVector& pos) { + uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; return id; } -bool HGCScintSD::isItinFidVolume (const G4ThreeVector& pos) { +bool HGCScintSD::isItinFidVolume(const G4ThreeVector& pos) { if (fiducialCut_) { - return (hgcons_->distFromEdgeTrap(pos.x(),pos.y(),pos.z()) > distanceFromEdge_); + return (hgcons_->distFromEdgeTrap(pos.x(), pos.y(), pos.z()) > distanceFromEdge_); } else { return true; } diff --git a/SimG4CMS/Calo/src/HGCalNumberingScheme.cc b/SimG4CMS/Calo/src/HGCalNumberingScheme.cc index e6a797e0b02cb..4e551af879cdf 100644 --- a/SimG4CMS/Calo/src/HGCalNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HGCalNumberingScheme.cc @@ -8,13 +8,12 @@ //#define EDM_ML_DEBUG -HGCalNumberingScheme::HGCalNumberingScheme(const HGCalDDDConstants& hgc, - const DetId::Detector& det, - const std::string & name) : - hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) { +HGCalNumberingScheme::HGCalNumberingScheme(const HGCalDDDConstants& hgc, + const DetId::Detector& det, + const std::string& name) + : hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Creating HGCalNumberingScheme for " << name_ - << " Det " << det_; + edm::LogVerbatim("HGCSim") << "Creating HGCalNumberingScheme for " << name_ << " Det " << det_; #endif } @@ -24,125 +23,107 @@ HGCalNumberingScheme::~HGCalNumberingScheme() { #endif } -uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, - int iz, const G4ThreeVector &pos, - double& wt) { +uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector& pos, double& wt) { // module is the copy number of the wafer as placed in the layer uint32_t index(0); wt = 1.0; - if ((mode_ == HGCalGeometryMode::Hexagon8Full) || - (mode_ == HGCalGeometryMode::Hexagon8)) { - int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0); + if ((mode_ == HGCalGeometryMode::Hexagon8Full) || (mode_ == HGCalGeometryMode::Hexagon8)) { + int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0); if (cell >= 0) { - waferType = module/1000000; - waferU = module%100; - if ((module/10000)%10 > 0) waferU = -waferU; - waferV = (module/100)%100; - if ((module/100000)%10 > 0) waferV = -waferV; - cellU = cell%100; - cellV = (cell/100)%100; + waferType = module / 1000000; + waferU = module % 100; + if ((module / 10000) % 10 > 0) + waferU = -waferU; + waferV = (module / 100) % 100; + if ((module / 100000) % 10 > 0) + waferV = -waferV; + cellU = cell % 100; + cellV = (cell / 100) % 100; } else if (mode_ == HGCalGeometryMode::Hexagon8Full) { double xx = (pos.z() > 0) ? pos.x() : -pos.x(); - hgcons_.waferFromPosition(xx,pos.y(),layer,waferU,waferV,cellU, - cellV,waferType,wt); + hgcons_.waferFromPosition(xx, pos.y(), layer, waferU, waferV, cellU, cellV, waferType, wt); } if (waferType >= 0) { - index = HGCSiliconDetId(det_,iz,waferType,layer,waferU,waferV, - cellU,cellV).rawId(); + index = HGCSiliconDetId(det_, iz, waferType, layer, waferU, waferV, cellU, cellV).rawId(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " - << waferU << ":" << waferV << " Cell " - << cellU << ":" << cellV; + edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer " << waferU << ":" << waferV << " Cell " + << cellU << ":" << cellV; } else { edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType; #endif } } else if (mode_ == HGCalGeometryMode::Trapezoid) { - std::array id = hgcons_.assignCellTrap(pos.x(),pos.y(),pos.z(), - layer,false); + std::array id = hgcons_.assignCellTrap(pos.x(), pos.y(), pos.z(), layer, false); if (id[2] >= 0) { - index = HGCScintillatorDetId(id[2], layer, iz*id[0], id[1]).rawId(); + index = HGCScintillatorDetId(id[2], layer, iz * id[0], id[1]).rawId(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] - << " Type " << id[2] << " Layer|iz " - << layer << ":" << iz << " " - << HGCScintillatorDetId(index); + edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2] << " Layer|iz " << layer + << ":" << iz << " " << HGCScintillatorDetId(index); } else { - edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] - << " Type " << id[2] << " Layer|iz " << layer - << ":" << iz; + edm::LogVerbatim("HGCSim") << "Radius/Phi " << id[0] << ":" << id[1] << " Type " << id[2] << " Layer|iz " << layer + << ":" << iz; #endif } - } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":" - << layer << ":" << module << ":" << cell << ":" - << iz << ":" << pos.x() << ":" << pos.y() << ":" - << pos.z() << " ID " << std::hex << index - << std::dec << " wt " << wt; - checkPosition(index,pos); + edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":" << layer << ":" << module << ":" << cell + << ":" << iz << ":" << pos.x() << ":" << pos.y() << ":" << pos.z() << " ID " << std::hex + << index << std::dec << " wt " << wt; + checkPosition(index, pos); #endif return index; } -void HGCalNumberingScheme::checkPosition(uint32_t index, - const G4ThreeVector &pos) const { - - std::pair xy; - bool ok(false); - double z1(0), drMax(10.0), dzMax(1.0); - int lay(-1); +void HGCalNumberingScheme::checkPosition(uint32_t index, const G4ThreeVector& pos) const { + std::pair xy; + bool ok(false); + double z1(0), drMax(10.0), dzMax(1.0); + int lay(-1); if (index == 0) { } else if (DetId(index).det() == DetId::HGCalHSi) { HGCSiliconDetId id = HGCSiliconDetId(index); - lay= id.layer(); - xy = hgcons_.locateCell(lay,id.waferU(),id.waferV(),id.cellU(), - id.cellV(),false,true); - z1 = hgcons_.waferZ(lay,false); + lay = id.layer(); + xy = hgcons_.locateCell(lay, id.waferU(), id.waferV(), id.cellU(), id.cellV(), false, true); + z1 = hgcons_.waferZ(lay, false); ok = true; - drMax = 10.0; dzMax = 1.0; + drMax = 10.0; + dzMax = 1.0; } else if (DetId(index).det() == DetId::HGCalHSc) { HGCScintillatorDetId id = HGCScintillatorDetId(index); - lay= id.layer(); - xy = hgcons_.locateCellTrap(lay,id.ietaAbs(),id.iphi(),false); - z1 = hgcons_.waferZ(lay,false); + lay = id.layer(); + xy = hgcons_.locateCellTrap(lay, id.ietaAbs(), id.iphi(), false); + z1 = hgcons_.waferZ(lay, false); ok = true; - drMax = 50.0; dzMax = 5.0; + drMax = 50.0; + dzMax = 5.0; } if (ok) { - double r1 = std::sqrt(xy.first*xy.first+xy.second*xy.second); + double r1 = std::sqrt(xy.first * xy.first + xy.second * xy.second); double r2 = pos.perp(); double z2 = std::abs(pos.z()); - std::pair zrange = hgcons_.rangeZ(false); - std::pair rrange = hgcons_.rangeR(z2,false); - bool match= (std::abs(r1-r2) < drMax) && (std::abs(z1-z2) < dzMax); - bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && - (z2 >= zrange.first) && (z2 <= zrange.second)); - bool outok= ((r1 >= rrange.first) && (r1 <= rrange.second) && - (z1 >= zrange.first) && (z1 <= zrange.second)); - std::string ck = (((r1 < rrange.first-10.0) || (r1 > rrange.second+10.0) || - (z1 < zrange.first-5.0) || (z1 > zrange.second+5.0)) ? - "***** ERROR *****" : ""); + std::pair zrange = hgcons_.rangeZ(false); + std::pair rrange = hgcons_.rangeR(z2, false); + bool match = (std::abs(r1 - r2) < drMax) && (std::abs(z1 - z2) < dzMax); + bool inok = ((r2 >= rrange.first) && (r2 <= rrange.second) && (z2 >= zrange.first) && (z2 <= zrange.second)); + bool outok = ((r1 >= rrange.first) && (r1 <= rrange.second) && (z1 >= zrange.first) && (z1 <= zrange.second)); + std::string ck = (((r1 < rrange.first - 10.0) || (r1 > rrange.second + 10.0) || (z1 < zrange.first - 5.0) || + (z1 > zrange.second + 5.0)) + ? "***** ERROR *****" + : ""); if (!(match && inok && outok)) { - edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::Detector " << det_ - << " Layer " << lay << " R " << r2 << ":" - << r1 << ":" << rrange.first << ":" - << rrange.second << " Z " << z2 << ":" << z1 - << ":" << zrange.first << ":" << zrange.second - << " Match " << match << ":" << inok << ":" - << outok << " " << ck; - edm::LogVerbatim("HGCSim") << "Original " << pos.x() << ":" << pos.y() - << " return " << xy.first << ":" << xy.second; + edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::Detector " << det_ << " Layer " << lay << " R " << r2 << ":" + << r1 << ":" << rrange.first << ":" << rrange.second << " Z " << z2 << ":" << z1 << ":" + << zrange.first << ":" << zrange.second << " Match " << match << ":" << inok << ":" + << outok << " " << ck; + edm::LogVerbatim("HGCSim") << "Original " << pos.x() << ":" << pos.y() << " return " << xy.first << ":" + << xy.second; if (DetId(index).det() == DetId::HGCalHSi) { - double wt=0, xx = ((pos.z() > 0) ? pos.x() : -pos.x()); - int waferU,waferV,cellU,cellV,waferType; - hgcons_.waferFromPosition(xx,pos.y(),lay,waferU,waferV,cellU, - cellV,waferType,wt,true); - xy = hgcons_.locateCell(lay,waferU,waferV,cellU,cellV,false,true,true); - edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " - << HGCSiliconDetId(index) << " position " - << xy.first << ":" << xy.second; + double wt = 0, xx = ((pos.z() > 0) ? pos.x() : -pos.x()); + int waferU, waferV, cellU, cellV, waferType; + hgcons_.waferFromPosition(xx, pos.y(), lay, waferU, waferV, cellU, cellV, waferType, wt, true); + xy = hgcons_.locateCell(lay, waferU, waferV, cellU, cellV, false, true, true); + edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme " << HGCSiliconDetId(index) << " position " << xy.first + << ":" << xy.second; } } } diff --git a/SimG4CMS/Calo/src/HGCalSD.cc b/SimG4CMS/Calo/src/HGCalSD.cc index 0687767817b4f..028af52a4370c 100644 --- a/SimG4CMS/Calo/src/HGCalSD.cc +++ b/SimG4CMS/Calo/src/HGCalSD.cc @@ -27,28 +27,37 @@ //#define EDM_ML_DEBUG -HGCalSD::HGCalSD(const std::string& name, const DDCompactView & cpv, - const SensitiveDetectorCatalog & clg, - edm::ParameterSet const & p, const SimTrackManager* manager): - CaloSD(name, cpv, clg, p, manager, - (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), - p.getParameter("HGCSD").getParameter("IgnoreTrackID")), - hgcons_(nullptr), slopeMin_(0), levelT1_(99), levelT2_(99), - tan30deg_(std::tan(30.0*CLHEP::deg)) { - - numberingScheme_.reset(nullptr); mouseBite_.reset(nullptr); +HGCalSD::HGCalSD(const std::string& name, + const DDCompactView& cpv, + const SensitiveDetectorCatalog& clg, + edm::ParameterSet const& p, + const SimTrackManager* manager) + : CaloSD(name, + cpv, + clg, + p, + manager, + (float)(p.getParameter("HGCSD").getParameter("TimeSliceUnit")), + p.getParameter("HGCSD").getParameter("IgnoreTrackID")), + hgcons_(nullptr), + slopeMin_(0), + levelT1_(99), + levelT2_(99), + tan30deg_(std::tan(30.0 * CLHEP::deg)) { + numberingScheme_.reset(nullptr); + mouseBite_.reset(nullptr); edm::ParameterSet m_HGC = p.getParameter("HGCSD"); - eminHit_ = m_HGC.getParameter("EminHit")*CLHEP::MeV; - fiducialCut_ = m_HGC.getParameter("FiducialCut"); - distanceFromEdge_= m_HGC.getParameter("DistanceFromEdge"); - storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); - rejectMB_ = m_HGC.getParameter("RejectMouseBite"); - waferRot_ = m_HGC.getParameter("RotatedWafer"); - cornerMinMask_ = m_HGC.getParameter("CornerMinMask"); - angles_ = m_HGC.getUntrackedParameter>("WaferAngles"); - - if(storeAllG4Hits_) { + eminHit_ = m_HGC.getParameter("EminHit") * CLHEP::MeV; + fiducialCut_ = m_HGC.getParameter("FiducialCut"); + distanceFromEdge_ = m_HGC.getParameter("DistanceFromEdge"); + storeAllG4Hits_ = m_HGC.getParameter("StoreAllG4Hits"); + rejectMB_ = m_HGC.getParameter("RejectMouseBite"); + waferRot_ = m_HGC.getParameter("RotatedWafer"); + cornerMinMask_ = m_HGC.getParameter("CornerMinMask"); + angles_ = m_HGC.getUntrackedParameter>("WaferAngles"); + + if (storeAllG4Hits_) { setUseMap(false); setNumberCheckedHits(0); } @@ -57,135 +66,113 @@ HGCalSD::HGCalSD(const std::string& name, const DDCompactView & cpv, G4String myName = name; mydet_ = DetId::Forward; nameX_ = "HGCal"; - if (myName.find("HitsEE")!=std::string::npos) { - mydet_ = DetId::HGCalEE; - nameX_ = "HGCalEESensitive"; - } else if (myName.find("HitsHEfront")!=std::string::npos) { - mydet_ = DetId::HGCalHSi; - nameX_ = "HGCalHESiliconSensitive"; + if (myName.find("HitsEE") != std::string::npos) { + mydet_ = DetId::HGCalEE; + nameX_ = "HGCalEESensitive"; + } else if (myName.find("HitsHEfront") != std::string::npos) { + mydet_ = DetId::HGCalHSi; + nameX_ = "HGCalHESiliconSensitive"; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim")<< "**************************************************" - << "\n" - << "* *" - << "\n" - << "* Constructing a HGCalSD with name " << name << "\n" - << "* *" - << "\n" - << "**************************************************"; + edm::LogVerbatim("HGCSim") << "**************************************************" + << "\n" + << "* *" + << "\n" + << "* Constructing a HGCalSD with name " << name << "\n" + << "* *" + << "\n" + << "**************************************************"; #endif - edm::LogVerbatim("HGCSim") << "HGCalSD:: Threshold for storing hits: " - << eminHit_ << " for " << nameX_ << " detector " - << mydet_; - edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " - << storeAllG4Hits_; + edm::LogVerbatim("HGCSim") << "HGCalSD:: Threshold for storing hits: " << eminHit_ << " for " << nameX_ + << " detector " << mydet_; + edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_; edm::LogVerbatim("HGCSim") << "Fiducial volume cut with cut from eta/phi " - << "boundary " << fiducialCut_ << " at " - << distanceFromEdge_; - edm::LogVerbatim("HGCSim") << "Reject MosueBite Flag: " << rejectMB_ - << " cuts along " << angles_.size() << " axes: " - << angles_[0] << ", " << angles_[1]; + << "boundary " << fiducialCut_ << " at " << distanceFromEdge_; + edm::LogVerbatim("HGCSim") << "Reject MosueBite Flag: " << rejectMB_ << " cuts along " << angles_.size() + << " axes: " << angles_[0] << ", " << angles_[1]; } double HGCalSD::getEnergyDeposit(const G4Step* aStep) { - double r = aStep->GetPreStepPoint()->GetPosition().perp(); double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z()); #ifdef EDM_ML_DEBUG - G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); + G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding(); G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName(); - G4LogicalVolume* lv = - aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); - edm::LogVerbatim("HGCSim") << "HGCalSD: Hit from standard path from " - << lv->GetName() << " for Track " - << aStep->GetTrack()->GetTrackID() << " (" - << parCode << ":" << parName << ") R = " << r - << " Z = " << z << " slope = " << r/z << ":" - << slopeMin_; + G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume(); + edm::LogVerbatim("HGCSim") << "HGCalSD: Hit from standard path from " << lv->GetName() << " for Track " + << aStep->GetTrack()->GetTrackID() << " (" << parCode << ":" << parName << ") R = " << r + << " Z = " << z << " slope = " << r / z << ":" << slopeMin_; #endif // Apply fiducial cut - if (r < z*slopeMin_) { + if (r < z * slopeMin_) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCSim") << "HGCalSD: Fiducial Volume cut"; #endif - return 0.0; + return 0.0; } - double wt1 = getResponseWt(aStep->GetTrack()); - double wt2 = aStep->GetTrack()->GetWeight(); - double destep = weight_*wt1*(aStep->GetTotalEnergyDeposit()); - if (wt2 > 0) destep *= wt2; + double wt1 = getResponseWt(aStep->GetTrack()); + double wt2 = aStep->GetTrack()->GetWeight(); + double destep = weight_ * wt1 * (aStep->GetTotalEnergyDeposit()); + if (wt2 > 0) + destep *= wt2; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalSD: weights= " << weight_ << ":" - << wt1 << ":" << wt2 << " Total weight " - << weight_*wt1*wt2 << " deStep: " - << aStep->GetTotalEnergyDeposit() - << ":" <GetTotalEnergyDeposit() << ":" << destep; #endif return destep; } -uint32_t HGCalSD::setDetUnitId(const G4Step * aStep) { - - const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); +uint32_t HGCalSD::setDetUnitId(const G4Step* aStep) { + const G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); const G4VTouchable* touch = preStepPoint->GetTouchable(); - //determine the exact position in global coordinates in the mass geometry - G4ThreeVector hitPoint = preStepPoint->GetPosition(); + //determine the exact position in global coordinates in the mass geometry + G4ThreeVector hitPoint = preStepPoint->GetPosition(); float globalZ = touch->GetTranslation(0).z(); - int iz( globalZ>0 ? 1 : -1); + int iz(globalZ > 0 ? 1 : -1); int layer, module, cell; - if ((touch->GetHistoryDepth() == levelT1_) || - (touch->GetHistoryDepth() == levelT2_)) { - layer = touch->GetReplicaNumber(0); + if ((touch->GetHistoryDepth() == levelT1_) || (touch->GetHistoryDepth() == levelT2_)) { + layer = touch->GetReplicaNumber(0); module = -1; - cell = -1; + cell = -1; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() - << ":" << levelT1_ << ":" << levelT2_ - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_ + << " name " << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" + << module << ":" << cell; #endif } else { - layer = touch->GetReplicaNumber(3); + layer = touch->GetReplicaNumber(3); module = touch->GetReplicaNumber(2); - cell = touch->GetReplicaNumber(1); + cell = touch->GetReplicaNumber(1); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "DepthsInside: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << " layer:module:cell " << layer << ":" - << module << ":" << cell; + edm::LogVerbatim("HGCSim") << "DepthsInside: " << touch->GetHistoryDepth() << " name " + << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" << module + << ":" << cell; #endif } #ifdef EDM_ML_DEBUG G4Material* mat = aStep->GetPreStepPoint()->GetMaterial(); - edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() - << " name " << touch->GetVolume(0)->GetName() - << ":" << touch->GetReplicaNumber(0) << " " - << touch->GetVolume(1)->GetName() - << ":" << touch->GetReplicaNumber(1) << " " - << touch->GetVolume(2)->GetName() - << ":" << touch->GetReplicaNumber(2) << " " - << touch->GetVolume(3)->GetName() - << ":" << touch->GetReplicaNumber(3) << " " - << touch->GetVolume(4)->GetName() - << ":" << touch->GetReplicaNumber(4) << " " - << " layer:module:cell " << layer << ":" - << module << ":" << cell << " Material " - << mat->GetName() << ":" << mat->GetRadlen(); + edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName() + << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":" + << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":" + << touch->GetReplicaNumber(2) << " " << touch->GetVolume(3)->GetName() << ":" + << touch->GetReplicaNumber(3) << " " << touch->GetVolume(4)->GetName() << ":" + << touch->GetReplicaNumber(4) << " " + << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material " + << mat->GetName() << ":" << mat->GetRadlen(); #endif // The following statement should be examined later before elimination - if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) return 0; - - uint32_t id = setDetUnitId (layer, module, cell, iz, hitPoint); + if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.) + return 0; + + uint32_t id = setDetUnitId(layer, module, cell, iz, hitPoint); if (rejectMB_ && id != 0) { auto uv = HGCSiliconDetId(id).waferUV(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec - << " " << HGCSiliconDetId(id); + edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec << " " << HGCSiliconDetId(id); #endif if (mouseBite_->exclude(hitPoint, iz, uv.first, uv.second)) { id = 0; @@ -195,61 +182,57 @@ uint32_t HGCalSD::setDetUnitId(const G4Step * aStep) { } } #ifdef EDM_ML_DEBUG - if (id != 0) edm::LogVerbatim("HGCSim") << HGCSiliconDetId(id); + if (id != 0) + edm::LogVerbatim("HGCSim") << HGCSiliconDetId(id); #endif return id; } -void HGCalSD::update(const BeginOfJob * job) { - +void HGCalSD::update(const BeginOfJob* job) { const edm::EventSetup* es = (*job)(); - edm::ESHandle hdc; - es->get().get(nameX_,hdc); + edm::ESHandle hdc; + es->get().get(nameX_, hdc); if (hdc.isValid()) { - hgcons_ = hdc.product(); - geom_mode_ = hgcons_->geomMode(); - slopeMin_ = hgcons_->minSlope(); - levelT1_ = hgcons_->levelTop(0); - levelT2_ = hgcons_->levelTop(1); + hgcons_ = hdc.product(); + geom_mode_ = hgcons_->geomMode(); + slopeMin_ = hgcons_->minSlope(); + levelT1_ = hgcons_->levelTop(0); + levelT2_ = hgcons_->levelTop(1); double waferSize = hgcons_->waferSize(false); double mouseBite = hgcons_->mouseBite(false); - mouseBiteCut_ = waferSize*tan30deg_ - mouseBite; + mouseBiteCut_ = waferSize * tan30deg_ - mouseBite; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCSim") << "HGCalSD::Initialized with mode " - << geom_mode_ << " Slope cut " << slopeMin_ - << " top Level " << levelT1_ << ":" << levelT2_ - << " wafer " << waferSize << ":" << mouseBite; + edm::LogVerbatim("HGCSim") << "HGCalSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_ + << " top Level " << levelT1_ << ":" << levelT2_ << " wafer " << waferSize << ":" + << mouseBite; #endif - numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_,mydet_,nameX_)); - if (rejectMB_) - mouseBite_.reset(new HGCMouseBite(*hgcons_,angles_,mouseBiteCut_, - waferRot_)); + numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_, mydet_, nameX_)); + if (rejectMB_) + mouseBite_.reset(new HGCMouseBite(*hgcons_, angles_, mouseBiteCut_, waferRot_)); } else { throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n"; } } -void HGCalSD::initRun() { -} +void HGCalSD::initRun() {} bool HGCalSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_)); } -uint32_t HGCalSD::setDetUnitId (int layer, int module, int cell, int iz, - G4ThreeVector &pos) { - uint32_t id = numberingScheme_ ? - numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; +uint32_t HGCalSD::setDetUnitId(int layer, int module, int cell, int iz, G4ThreeVector& pos) { + uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0; if (cornerMinMask_ > 2) { - if (hgcons_->maskCell(DetId(id), cornerMinMask_)) id = 0; + if (hgcons_->maskCell(DetId(id), cornerMinMask_)) + id = 0; } return id; } -bool HGCalSD::isItinFidVolume (const G4ThreeVector& pos) { +bool HGCalSD::isItinFidVolume(const G4ThreeVector& pos) { if (fiducialCut_) { - return (hgcons_->distFromEdgeHex(pos.x(),pos.y(),pos.z()) > distanceFromEdge_); + return (hgcons_->distFromEdgeHex(pos.x(), pos.y(), pos.z()) > distanceFromEdge_); } else { return true; } diff --git a/SimG4CMS/Calo/src/HcalNumberingFromPS.cc b/SimG4CMS/Calo/src/HcalNumberingFromPS.cc index 483f457b3a5d9..1d6fe573a30ad 100644 --- a/SimG4CMS/Calo/src/HcalNumberingFromPS.cc +++ b/SimG4CMS/Calo/src/HcalNumberingFromPS.cc @@ -11,149 +11,142 @@ using namespace geant_units::operators; HcalNumberingFromPS::HcalNumberingFromPS(const edm::ParameterSet& conf) { - etaTable_ = conf.getParameter >("EtaTable"); - phibin_ = conf.getParameter >("PhiBin"); - phioff_ = conf.getParameter >("PhiOffset"); - etaMin_ = conf.getParameter >("EtaMin"); - etaMax_ = conf.getParameter >("EtaMax"); - etaHBHE_ = conf.getParameter("EtaHBHE"); - depthHBHE_= conf.getParameter >("DepthHBHE"); - depth29Mx_= conf.getParameter("Depth29Max"); - rMinHO_ = conf.getParameter("RMinHO"); - zHO_ = conf.getParameter >("ZHO"); - const double deg = M_PI/180.0; - for (auto & phi : phibin_) phi *= deg; - for (auto & phi : phioff_) phi *= deg; + phibin_ = conf.getParameter >("PhiBin"); + phioff_ = conf.getParameter >("PhiOffset"); + etaMin_ = conf.getParameter >("EtaMin"); + etaMax_ = conf.getParameter >("EtaMax"); + etaHBHE_ = conf.getParameter("EtaHBHE"); + depthHBHE_ = conf.getParameter >("DepthHBHE"); + depth29Mx_ = conf.getParameter("Depth29Max"); + rMinHO_ = conf.getParameter("RMinHO"); + zHO_ = conf.getParameter >("ZHO"); + const double deg = M_PI / 180.0; + for (auto& phi : phibin_) + phi *= deg; + for (auto& phi : phioff_) + phi *= deg; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: EtaTable with " - << etaTable_.size() << " elements"; - for (unsigned k=0; k0) { - segmentation_[ring] = conf.getUntrackedParameter >(name,segmentation_[ring-1]); + snprintf(name, 10, "Eta%d", ring + 1); + if (ring > 0) { + segmentation_[ring] = conf.getUntrackedParameter >(name, segmentation_[ring - 1]); } else { segmentation_[ring] = conf.getUntrackedParameter >(name); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "HcalNumberingFromPS:: Ring " << ring+1 - << " with " << segmentation_[ring].size() - << " layers"; - for (unsigned int k=0; k HcalNumberingFromPS::getEta(const int& det, - const math::XYZVectorD& pos) const { - +std::pair HcalNumberingFromPS::getEta(const int& det, const math::XYZVectorD& pos) const { int ieta(1); int subdet(det); double eta = std::abs(pos.Eta()); if (pos.Rho() > rMinHO_) { - subdet = static_cast(HcalOuter); + subdet = static_cast(HcalOuter); double z = std::abs(pos.z()); if (z > zHO_[3]) { - if (eta <= etaTable_[10]) eta = etaTable_[10]+0.001; + if (eta <= etaTable_[10]) + eta = etaTable_[10] + 0.001; } else if (z > zHO_[1]) { - if (eta <= etaTable_[4]) eta = etaTable_[4]+0.001; + if (eta <= etaTable_[4]) + eta = etaTable_[4] + 0.001; } } for (unsigned int i = 1; i < etaTable_.size(); i++) { - if (eta < etaTable_[i]) { ieta = i; break; } + if (eta < etaTable_[i]) { + ieta = i; + break; + } } - if ((subdet == static_cast(HcalBarrel)) || - (subdet == static_cast(HcalOuter))) { - if (ieta > etaMax_[0]) ieta = etaMax_[0]; + if ((subdet == static_cast(HcalBarrel)) || (subdet == static_cast(HcalOuter))) { + if (ieta > etaMax_[0]) + ieta = etaMax_[0]; } else if (det == static_cast(HcalEndcap)) { - if (ieta <= etaMin_[1]) ieta = etaMin_[1]; + if (ieta <= etaMin_[1]) + ieta = etaMin_[1]; } - return std::make_pair(subdet,ieta); + return std::make_pair(subdet, ieta); } -std::pair HcalNumberingFromPS::getPhi(const int& det, const int& ieta, - const double& phi) const { - - double fioff = ((det == static_cast(HcalEndcap)) ? phioff_[1] : - phioff_[0]); - double fibin = phibin_[ieta-1]; - int nphi = int((2._pi+0.1*fibin)/fibin); - double hphi = phi+fioff; - if (hphi < 0) hphi += (2._pi); - int iphi = int(hphi/fibin) + 1; - if (iphi > nphi) iphi = 1; +std::pair HcalNumberingFromPS::getPhi(const int& det, const int& ieta, const double& phi) const { + double fioff = ((det == static_cast(HcalEndcap)) ? phioff_[1] : phioff_[0]); + double fibin = phibin_[ieta - 1]; + int nphi = int((2._pi + 0.1 * fibin) / fibin); + double hphi = phi + fioff; + if (hphi < 0) + hphi += (2._pi); + int iphi = int(hphi / fibin) + 1; + if (iphi > nphi) + iphi = 1; const double fiveDegInRad = 5._deg; - int units = int(fibin/fiveDegInRad+0.5); - if (units < 1) units = 1; + int units = int(fibin / fiveDegInRad + 0.5); + if (units < 1) + units = 1; int iphi_skip = iphi; - if (units==2) iphi_skip = (iphi-1)*2+1; - else if (units==4) iphi_skip = (iphi-1)*4-1; - if (iphi_skip < 0) iphi_skip += 72; - return std::make_pair(iphi,iphi_skip); + if (units == 2) + iphi_skip = (iphi - 1) * 2 + 1; + else if (units == 4) + iphi_skip = (iphi - 1) * 4 - 1; + if (iphi_skip < 0) + iphi_skip += 72; + return std::make_pair(iphi, iphi_skip); } diff --git a/SimG4CMS/Calo/src/HcalNumberingScheme.cc b/SimG4CMS/Calo/src/HcalNumberingScheme.cc index 5fbe65c99a158..d4044ec345a8b 100644 --- a/SimG4CMS/Calo/src/HcalNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HcalNumberingScheme.cc @@ -11,33 +11,26 @@ //#define EDM_ML_DEBUG HcalNumberingScheme::HcalNumberingScheme() : CaloNumberingScheme(0) { - edm::LogInfo("HcalSim") << "Creating HcalNumberingScheme" << std::endl; + edm::LogVerbatim("HcalSim") << "Creating HcalNumberingScheme"; } -HcalNumberingScheme::~HcalNumberingScheme() { - edm::LogInfo("HcalSim") << "Deleting HcalNumberingScheme" << std::endl; -} - -uint32_t HcalNumberingScheme::getUnitID(const HcalNumberingFromDDD::HcalID& id){ +HcalNumberingScheme::~HcalNumberingScheme() { edm::LogVerbatim("HcalSim") << "Deleting HcalNumberingScheme"; } - int zside = 2*(id.zside) - 1; - int etaR = zside*(id.etaR); - HcalSubdetector subdet = (HcalSubdetector)(id.subdet); +uint32_t HcalNumberingScheme::getUnitID(const HcalNumberingFromDDD::HcalID& id) { + int zside = 2 * (id.zside) - 1; + int etaR = zside * (id.etaR); + HcalSubdetector subdet = (HcalSubdetector)(id.subdet); //pack it into an integer // to be consistent with HcalDetId convention - HcalDetId hid(subdet,etaR,id.phis,id.depth); + HcalDetId hid(subdet, etaR, id.phis, id.depth); uint32_t index = hid.rawId(); #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "HcalNumberingScheme det = " << id.subdet - << " depth/lay = " << id.depth << "/" << id.lay - << " zside = " << id.zside << " eta/R = " << id.etaR - << " phi = " << id.phis << " oldphi = " << id.phi - << " packed index = 0x" << std::hex << index - << std::dec << " " << hid << " " << HcalDetId(index) - << std::endl; + edm::LogVerbatim("HcalSim") << "HcalNumberingScheme det = " << id.subdet << " depth/lay = " << id.depth << "/" + << id.lay << " zside = " << id.zside << " eta/R = " << id.etaR << " phi = " << id.phis + << " oldphi = " << id.phi << " packed index = 0x" << std::hex << index << std::dec << " " + << hid << " " << HcalDetId(index); #endif return index; - } diff --git a/SimG4CMS/Calo/src/HcalQie.cc b/SimG4CMS/Calo/src/HcalQie.cc index 07f37c757c644..29d46f0679e45 100644 --- a/SimG4CMS/Calo/src/HcalQie.cc +++ b/SimG4CMS/Calo/src/HcalQie.cc @@ -13,10 +13,9 @@ #include #include -//#define DebugLog - -HcalQie::HcalQie(edm::ParameterSet const & p) { +//#define EDM_ML_DEBUG +HcalQie::HcalQie(edm::ParameterSet const& p) { //static SimpleConfigurable p1(4.0, "HcalQie:qToPE"); //static SimpleConfigurable p2(6, "HcalQie:BinOfMax"); //static SimpleConfigurable p3(2, "HcalQie:SignalBuckets"); @@ -26,89 +25,88 @@ HcalQie::HcalQie(edm::ParameterSet const & p) { //static SimpleConfigurable p7(0.0005,"HcalQie:EDepPerPE"); //static SimpleConfigurable p8(4, "HcalQie:BaseLine"); - edm::ParameterSet m_HQ = p.getParameter("HcalQie"); - qToPE = m_HQ.getParameter("qToPE"); - binOfMax = m_HQ.getParameter("BinOfMax"); + edm::ParameterSet m_HQ = p.getParameter("HcalQie"); + qToPE = m_HQ.getParameter("qToPE"); + binOfMax = m_HQ.getParameter("BinOfMax"); signalBuckets = m_HQ.getParameter("SignalBuckets"); - preSamples = m_HQ.getParameter("PreSamples"); - numOfBuckets = m_HQ.getParameter("NumOfBuckets"); - sigma = m_HQ.getParameter("SigmaNoise"); - eDepPerPE = m_HQ.getParameter("EDepPerPE"); - int bl = m_HQ.getParameter("BaseLine"); - - shape_ = shape(); - code_ = code(); + preSamples = m_HQ.getParameter("PreSamples"); + numOfBuckets = m_HQ.getParameter("NumOfBuckets"); + sigma = m_HQ.getParameter("SigmaNoise"); + eDepPerPE = m_HQ.getParameter("EDepPerPE"); + int bl = m_HQ.getParameter("BaseLine"); + + shape_ = shape(); + code_ = code(); charge_ = charge(); if (signalBuckets == 1) { - phase_ = -3; rescale_ = 1.46; + phase_ = -3; + rescale_ = 1.46; } else if (signalBuckets == 3) { - phase_ = -1; rescale_ = 1.06; + phase_ = -1; + rescale_ = 1.06; } else if (signalBuckets == 4) { - phase_ = 0; rescale_ = 1.03; + phase_ = 0; + rescale_ = 1.03; } else { - phase_ = -2; rescale_ = 1.14; signalBuckets = 2; + phase_ = -2; + rescale_ = 1.14; + signalBuckets = 2; } weight_ = weight(binOfMax, signalBuckets, preSamples, numOfBuckets); - baseline= codeToQ(bl); - bmin_ = binOfMax-3; - if (bmin_<0) bmin_ = 0; - if (binOfMax>numOfBuckets) - bmax_ = numOfBuckets+5; - else - bmax_ = binOfMax+5; - - edm::LogInfo("HcalSim") << "HcalQie: initialized with binOfMax " << binOfMax - << " sample from " << bmin_ << " to " << bmax_ - << "; signalBuckets " << signalBuckets - << " Baseline/Phase/Scale " << baseline << "/" - << phase_ << "/" << rescale_ << "\n" - <<" Noise " << sigma - << "fC fCToPE " << qToPE << " EDepPerPE " - << eDepPerPE; + baseline = codeToQ(bl); + bmin_ = binOfMax - 3; + if (bmin_ < 0) + bmin_ = 0; + if (binOfMax > numOfBuckets) + bmax_ = numOfBuckets + 5; + else + bmax_ = binOfMax + 5; + + edm::LogVerbatim("HcalSim") << "HcalQie: initialized with binOfMax " << binOfMax << " sample from " << bmin_ << " to " + << bmax_ << "; signalBuckets " << signalBuckets << " Baseline/Phase/Scale " << baseline + << "/" << phase_ << "/" << rescale_ << "\n Noise " << sigma + << "fC fCToPE " << qToPE << " EDepPerPE " << eDepPerPE; } -HcalQie::~HcalQie() { - edm::LogInfo("HcalSim") << "HcalQie:: Deleting Qie"; -} +HcalQie::~HcalQie() { edm::LogVerbatim("HcalSim") << "HcalQie:: Deleting Qie"; } std::vector HcalQie::shape() { - // pulse shape time constants in ns - const float ts1 = 8.; // scintillation time constants : 1,2,3 - const float ts2 = 10.; - const float ts3 = 29.3; - const float thpd = 4.; // HPD current collection drift time - const float tpre = 5.; // preamp time constant - - const float wd1 = 2.; // relative weights of decay exponents + const float ts1 = 8.; // scintillation time constants : 1,2,3 + const float ts2 = 10.; + const float ts3 = 29.3; + const float thpd = 4.; // HPD current collection drift time + const float tpre = 5.; // preamp time constant + + const float wd1 = 2.; // relative weights of decay exponents const float wd2 = 0.7; const float wd3 = 1.; // HPD starts at I and rises to 2I in thpd of time - double norm=0.0; + double norm = 0.0; int j, hpd_siz = (int)(thpd); std::vector hpd_drift(hpd_siz); - for (j=0; j preamp(preamp_siz); norm = 0; - for (j=0; j HcalQie::shape() { int tmax = 6 * (int)ts3; std::vector scnt_decay(tmax); norm = 0; - for (j=0; j pulse(nsiz,0.0); // zeroing output pulse shape + std::vector pulse(nsiz, 0.0); // zeroing output pulse shape norm = 0; - int i, k; - for (i=0; i HcalQie::code() { - unsigned int CodeFADCdata[122] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127}; std::vector temp(122); int i; - for (i = 0; i < 122; i++) + for (i = 0; i < 122; i++) temp[i] = (int)CodeFADCdata[i]; -#ifdef DebugLog +#ifdef EDM_ML_DEBUG int siz = temp.size(); - LogDebug("HcalSim") << "HcalQie: Codes in array of size " << siz; - for (i=0; i HcalQie::charge() { - - double ChargeFADCdata[122] = { - -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, - 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 16.5, 18.5, 20.5, - 22.5, 24.5, 26.5, 28.5, 31.5, 34.5, 37.5, 40.5, 44.5, 48.5, - 52.5, 57.5, 62.5, 67.5, 72.5, 77.5, 82.5, 87.5, - 92.5, 97.5, 102.5, 107.5, 112.5, 117.5, 122.5, 127.5, 132.5, 142.5, - 152.5, 162.5, 172.5, 182.5, 192.5, 202.5, 217.5, 232.5, 247.5, 262.5, - 282.5, 302.5, 322.5, 347.5, 372.5, 397.5, 422.5, 447.5, - 472.5, 497.5, 522.5, 547.5, 572.5, 597.5, 622.5, 647.5, 672.5, 697.5, - 722.5, 772.5, 822.5, 872.5, 922.5, 972.5, 1022.5, 1072.5, 1147.5, 1222.5, - 1297.5,1372.5, 1472.5, 1572.5, 1672.5, 1797.5, 1922.5, 2047.5, - 2172.5,2297.5, 2422.5, 2547.5, 2672.5, 2797.5, 2922.5, 3047.5, 3172.5, 3397.5, - 3422.5,3547.5, 3672.5, 3922.5, 4172.5, 4422.5, 4672.5, 4922.5, 5172.5, 5422.5, - 5797.5,6172.5, 6547.5, 6922.5, 7422.5, 7922.5, 8422.5, 9047.5 }; + double ChargeFADCdata[122] = { + -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, + 12.5, 13.5, 14.5, 16.5, 18.5, 20.5, 22.5, 24.5, 26.5, 28.5, 31.5, 34.5, 37.5, 40.5, + 44.5, 48.5, 52.5, 57.5, 62.5, 67.5, 72.5, 77.5, 82.5, 87.5, 92.5, 97.5, 102.5, 107.5, + 112.5, 117.5, 122.5, 127.5, 132.5, 142.5, 152.5, 162.5, 172.5, 182.5, 192.5, 202.5, 217.5, 232.5, + 247.5, 262.5, 282.5, 302.5, 322.5, 347.5, 372.5, 397.5, 422.5, 447.5, 472.5, 497.5, 522.5, 547.5, + 572.5, 597.5, 622.5, 647.5, 672.5, 697.5, 722.5, 772.5, 822.5, 872.5, 922.5, 972.5, 1022.5, 1072.5, + 1147.5, 1222.5, 1297.5, 1372.5, 1472.5, 1572.5, 1672.5, 1797.5, 1922.5, 2047.5, 2172.5, 2297.5, 2422.5, 2547.5, + 2672.5, 2797.5, 2922.5, 3047.5, 3172.5, 3397.5, 3422.5, 3547.5, 3672.5, 3922.5, 4172.5, 4422.5, 4672.5, 4922.5, + 5172.5, 5422.5, 5797.5, 6172.5, 6547.5, 6922.5, 7422.5, 7922.5, 8422.5, 9047.5}; std::vector temp(122); int i; for (i = 0; i < 122; i++) temp[i] = (double)(ChargeFADCdata[i]); -#ifdef DebugLog +#ifdef EDM_ML_DEBUG int siz = temp.size(); - LogDebug("HcalSim") << "HcalQie: Charges in array of size " << siz; - for (i=0; i HcalQie::weight(int binOfMax, int mode, int npre, - int bucket) { - - std::vector temp(bucket,0); +std::vector HcalQie::weight(int binOfMax, int mode, int npre, int bucket) { + std::vector temp(bucket, 0); int i; - for (i=binOfMax-1; i0) { - for (i=0; i 0) { + for (i = 0; i < npre; i++) { + int j = binOfMax - 2 - i; + temp[j] = -(double)mode / (double)npre; } } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG int siz = temp.size(); - LogDebug("HcalSim") << "HcalQie: Weights in array of size " << siz - << " and Npre " << npre; - for (i=0; i binsum(nmax,0); - double norm=0, sum=0.; - for (int i=bmin_; i binsum(nmax, 0); + double norm = 0, sum = 0.; + for (int i = bmin_; i < bmax_; i++) { + bintime += bunchSpace; + for (int j = 0; j < (int)(bunchSpace); j++) { + double tim = bintime + j; + double tmp = getShape(tim); + binsum[i] += tmp; + } + sum += binsum[i]; } - if (sum>0) norm = (photo/(sum*qToPE)); -#ifdef DebugLog - LogDebug("HcalSim") << "HcalQie::getCode: PE " << photo << " Sum " << sum - << " Norm. " << norm; + if (sum > 0) + norm = (photo / (sum * qToPE)); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "HcalQie::getCode: PE " << photo << " Sum " << sum << " Norm. " << norm; #endif - for (int i=bmin_; i temp(numOfBuckets,0); - for (int i=0; i temp(numOfBuckets, 0); + for (int i = 0; i < numOfBuckets; i++) { temp[i] = getCode(work[i]); - esum += work[i]; + esum += work[i]; } -#ifdef DebugLog - LogDebug("HcalSim") << "HcalQie::getCode: Input " << etot << " GeV; Photons " - << photons << "; Output " << esum << " fc"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "HcalQie::getCode: Input " << etot << " GeV; Photons " << photons << "; Output " + << esum << " fc"; #endif return temp; } - double HcalQie::getEnergy(const std::vector& code) { - std::vector work(numOfBuckets); - double sum=0; - for (int i=0; i #include -HcalTestAnalysis::HcalTestAnalysis(const edm::ParameterSet &p): - addTower_(3),tuples_(nullptr),hcons_(nullptr),org_(nullptr) { - +HcalTestAnalysis::HcalTestAnalysis(const edm::ParameterSet& p) + : addTower_(3), tuples_(nullptr), hcons_(nullptr), org_(nullptr) { edm::ParameterSet m_Anal = p.getParameter("HcalTestAnalysis"); - eta0_ = m_Anal.getParameter("Eta0"); - phi0_ = m_Anal.getParameter("Phi0"); - int laygroup = m_Anal.getParameter("LayerGrouping"); + eta0_ = m_Anal.getParameter("Eta0"); + phi0_ = m_Anal.getParameter("Phi0"); + int laygroup = m_Anal.getParameter("LayerGrouping"); centralTower_ = m_Anal.getParameter("CentralTower"); - names_ = m_Anal.getParameter >("Names"); - fileName_ = m_Anal.getParameter("FileName"); + names_ = m_Anal.getParameter >("Names"); + fileName_ = m_Anal.getParameter("FileName"); - tuplesManager_.reset(nullptr); + tuplesManager_.reset(nullptr); numberingFromDDD_.reset(nullptr); - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Initialised as observer of " - << "begin/end events and of G4step"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Initialised as observer of begin/end events" + << " and of G4step"; count_ = 0; group_ = layerGrouping(laygroup); - nGroup_= 0; - for (unsigned int i=0; inGroup_) nGroup_ = group_[i]; + nGroup_ = 0; + for (unsigned int i = 0; i < group_.size(); i++) + if (group_[i] > nGroup_) + nGroup_ = group_[i]; tower_ = towersToAdd(centralTower_, addTower_); - nTower_= tower_.size()/2; + nTower_ = tower_.size() / 2; - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: initialised for " << nGroup_ - << " Longitudinal groups and " << nTower_ - << " towers"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: initialised for " << nGroup_ << " Longitudinal groups and " + << nTower_ << " towers"; // qie myqie_.reset(new HcalQie(p)); -} - +} + HcalTestAnalysis::~HcalTestAnalysis() { - edm::LogInfo("HcalSim") << "HcalTestAnalysis: --------> Total number of " - << "selected entries : " << count_; - edm::LogInfo("HcalSim") << "HcalTestAnalysis: Pointers:: HistoClass " - << tuples_ << ", Numbering Scheme " << org_; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: --------> Total number of selected entries : " << count_; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Pointers:: HistoClass " << tuples_ << ", Numbering Scheme " << org_; } std::vector HcalTestAnalysis::layerGrouping(int group) { - std::vector temp(19); if (group <= 1) { int grp[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}; - for (int i=0; i<19; i++) + for (int i = 0; i < 19; i++) temp[i] = grp[i]; - } else if (group == 2) { + } else if (group == 2) { int grp[19] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; - for (int i=0; i<19; i++) + for (int i = 0; i < 19; i++) temp[i] = grp[i]; } else if (group == 3) { int grp[19] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7}; - for (int i=0; i<19; i++) + for (int i = 0; i < 19; i++) temp[i] = grp[i]; } else if (group == 4) { int grp[19] = {1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7}; - for (int i=0; i<19; i++) + for (int i = 0; i < 19; i++) temp[i] = grp[i]; } else { int grp[19] = {1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7}; - for (int i=0; i<19; i++) + for (int i = 0; i < 19; i++) temp[i] = grp[i]; } - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Layer Grouping "; - for (int i=0; i<19; i++) - edm::LogInfo("HcalSim") << "HcalTestAnalysis: Group[" << i << "] = " - << temp[i]; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Layer Grouping "; + for (int i = 0; i < 19; i++) + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Group[" << i << "] = " << temp[i]; return temp; } std::vector HcalTestAnalysis::towersToAdd(int centre, int nadd) { - - int etac = (centre/100)%100; - int phic = (centre%100); + int etac = (centre / 100) % 100; + int phic = (centre % 100); int etamin, etamax, phimin, phimax; - if (etac>0) { - etamin = etac-nadd; - etamax = etac+nadd; + if (etac > 0) { + etamin = etac - nadd; + etamax = etac + nadd; } else { etamin = etac; etamax = etac; } - if (phic>0) { - phimin = phic-nadd; - phimax = phic+nadd; + if (phic > 0) { + phimin = phic - nadd; + phimax = phic + nadd; } else { phimin = phic; phimax = phic; } - int nbuf, kount=0; - nbuf = (etamax-etamin+1)*(phimax-phimin+1); - std::vector temp(2*nbuf); - for (int eta=etamin; eta<=etamax; eta++) { - for (int phi=phimin; phi<=phimax; phi++) { - temp[kount] = (eta*100 + phi); - temp[kount+nbuf] = std::max(abs(eta-etac),abs(phi-phic)); + int nbuf, kount = 0; + nbuf = (etamax - etamin + 1) * (phimax - phimin + 1); + std::vector temp(2 * nbuf); + for (int eta = etamin; eta <= etamax; eta++) { + for (int phi = phimin; phi <= phimax; phi++) { + temp[kount] = (eta * 100 + phi); + temp[kount + nbuf] = std::max(abs(eta - etac), abs(phi - phic)); kount++; } } - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Towers to be considered for" - << " Central " << centre << " and " << nadd - << " on either side"; - for (int i=0; i hdc; + edm::ESHandle hdc; (*job)()->get().get(hdc); hcons_ = hdc.product(); - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Initialise " - << "HcalNumberingFromDDD for " << names_[0]; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Initialise HcalNumberingFromDDD for " << names_[0]; numberingFromDDD_.reset(new HcalNumberingFromDDD(hcons_)); // Ntuples tuplesManager_.reset(new HcalTestHistoManager(fileName_)); // Numbering scheme - org_ = new HcalTestNumberingScheme(false); - + org_ = new HcalTestNumberingScheme(false); } //==================================================================== per RUN -void HcalTestAnalysis::update(const BeginOfRun * run) { - +void HcalTestAnalysis::update(const BeginOfRun* run) { int irun = (*run)()->GetRunID(); - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Begin of Run = " << irun; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Begin of Run = " << irun; bool loop = true, eta = true, phi = true; - int etac = (centralTower_/100)%100; + int etac = (centralTower_ / 100) % 100; if (etac == 0) { etac = 1; - eta = false; + eta = false; } - int phic = (centralTower_%100); + int phic = (centralTower_ % 100); if (phic == 0) { phic = 1; - phi = false; + phi = false; } - int idet = static_cast(HcalBarrel); + int idet = static_cast(HcalBarrel); while (loop) { - HcalCellType::HcalCell tmp = hcons_->cell(idet,1,1,etac,phic); + HcalCellType::HcalCell tmp = hcons_->cell(idet, 1, 1, etac, phic); if (tmp.ok) { - if (eta) eta0_ = tmp.eta; - if (phi) phi0_ = tmp.phi; + if (eta) + eta0_ = tmp.eta; + if (phi) + phi0_ = tmp.phi; loop = false; } else if (idet == static_cast(HcalBarrel)) { idet = static_cast(HcalEndcap); @@ -193,92 +184,84 @@ void HcalTestAnalysis::update(const BeginOfRun * run) { } } - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: Central Tower " - << centralTower_ << " corresponds to eta0 = " - << eta0_ << " phi0 = " << phi0_; - + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: Central Tower " << centralTower_ + << " corresponds to eta0 = " << eta0_ << " phi0 = " << phi0_; + std::string sdname = names_[0]; G4SDManager* sd = G4SDManager::GetSDMpointerIfExist(); if (sd != nullptr) { G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(sdname); - if (aSD==nullptr) { + if (aSD == nullptr) { edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: No SD with " - << "name " << sdname << " in this Setup"; + << "name " << sdname << " in this Setup"; } else { HCalSD* theCaloSD = dynamic_cast(aSD); - edm::LogInfo("HcalSim") << "HcalTestAnalysis::beginOfRun: Finds SD with " - << "name " << theCaloSD->GetName() - << " in this Setup"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::beginOfRun: Finds SD with name " << theCaloSD->GetName() + << " in this Setup"; if (org_) { theCaloSD->setNumberingScheme(org_); - edm::LogInfo("HcalSim") << "HcalTestAnalysis::beginOfRun: set a new " - << "numbering scheme"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::beginOfRun: set a new numbering scheme"; } } } else { edm::LogWarning("HcalSim") << "HcalTestAnalysis::beginOfRun: Could not get" - << " SD Manager!"; + << " SD Manager!"; } - } //=================================================================== per EVENT -void HcalTestAnalysis::update(const BeginOfEvent * evt) { - +void HcalTestAnalysis::update(const BeginOfEvent* evt) { // create tuple object tuples_ = new HcalTestHistoClass(); // Reset counters tuples_->setCounters(); - + int i = 0; edepEB_ = edepEE_ = edepHB_ = edepHE_ = edepHO_ = 0.; - for (i = 0; i < 20; i++) edepl_[i] = 0.; - for (i = 0; i < 20; i++) mudist_[i] = -1.; + for (i = 0; i < 20; i++) + edepl_[i] = 0.; + for (i = 0; i < 20; i++) + mudist_[i] = -1.; - edm::LogVerbatim("HcalSim") <<"HcalTestAnalysis: Begin of event = " - << (*evt)()->GetEventID(); + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Begin of event = " << (*evt)()->GetEventID(); } //=================================================================== each STEP -void HcalTestAnalysis::update(const G4Step * aStep) { - +void HcalTestAnalysis::update(const G4Step* aStep) { if (aStep != nullptr) { - G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume(); + G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume(); G4String name = curPV->GetName(); - name.assign(name,0,3); + name.assign(name, 0, 3); double edeposit = aStep->GetTotalEnergyDeposit(); - int layer=-1; + int layer = -1; if (name == "EBR") { edepEB_ += edeposit; } else if (name == "EFR") { edepEE_ += edeposit; } else if (name == "HBS") { - layer = (curPV->GetCopyNo()/10)%100; + layer = (curPV->GetCopyNo() / 10) % 100; if (layer >= 0 && layer < 17) { - edepHB_ += edeposit; + edepHB_ += edeposit; } else { - edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HB " - << curPV->GetName() << curPV->GetCopyNo(); - layer = -1; + edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HB " << curPV->GetName() << curPV->GetCopyNo(); + layer = -1; } } else if (name == "HES") { - layer = (curPV->GetCopyNo()/10)%100; + layer = (curPV->GetCopyNo() / 10) % 100; if (layer >= 0 && layer < 19) { - edepHE_ += edeposit; + edepHE_ += edeposit; } else { - edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HE " - << curPV->GetName() << curPV->GetCopyNo(); - layer = -1; + edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HE " << curPV->GetName() << curPV->GetCopyNo(); + layer = -1; } } else if (name == "HTS") { - layer = (curPV->GetCopyNo()/10)%100; + layer = (curPV->GetCopyNo() / 10) % 100; if (layer >= 17 && layer < 20) { - edepHO_ += edeposit; - } else { - edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HO " - << curPV->GetName() << curPV->GetCopyNo(); - layer = -1; - } + edepHO_ += edeposit; + } else { + edm::LogWarning("HcalSim") << "HcalTestAnalysis::Error in HO " << curPV->GetName() << curPV->GetCopyNo(); + layer = -1; + } } if (layer >= 0 && layer < 20) { edepl_[layer] += edeposit; @@ -289,31 +272,27 @@ void HcalTestAnalysis::update(const G4Step * aStep) { math::XYZPoint pos(aStep->GetPreStepPoint()->GetPosition().x(), aStep->GetPreStepPoint()->GetPosition().y(), aStep->GetPreStepPoint()->GetPosition().z()); - double theta = pos.theta(); - double eta = -log(tan(theta * 0.5)); - double phi = pos.phi(); - double dist = sqrt ((eta-eta0_)*(eta-eta0_) + - (phi-phi0_)*(phi-phi0_)); - mudist_[layer] = dist*std::sqrt(pos.perp2()); + double theta = pos.theta(); + double eta = -log(tan(theta * 0.5)); + double phi = pos.phi(); + double dist = sqrt((eta - eta0_) * (eta - eta0_) + (phi - phi0_) * (phi - phi0_)); + mudist_[layer] = dist * std::sqrt(pos.perp2()); } } if (layer >= 0 && layer < 20) { - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: " << name - << " Layer " << std::setw(3) << layer - << " Edep " << std::setw(6) - << edeposit/MeV << " MeV"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: " << name << " Layer " << std::setw(3) << layer + << " Edep " << std::setw(6) << edeposit / MeV << " MeV"; } } else { - edm::LogInfo("HcalSim") << "HcalTestAnalysis:: G4Step: Null Step"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: G4Step: Null Step"; } } //================================================================ End of EVENT -void HcalTestAnalysis::update(const EndOfEvent * evt) { - +void HcalTestAnalysis::update(const EndOfEvent* evt) { ++count_; - // Fill event input + // Fill event input fill(evt); edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after Fill"; @@ -327,152 +306,135 @@ void HcalTestAnalysis::update(const EndOfEvent * evt) { edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after LayerAnalysis"; // Writing the data to the Tree - tuplesManager_.get()->fillTree(tuples_); // (no need to delete it...) - tuples_ = nullptr; // but avoid to reuse it... + tuplesManager_.get()->fillTree(tuples_); // (no need to delete it...) + tuples_ = nullptr; // but avoid to reuse it... edm::LogVerbatim("HcalSim") << "HcalTestAnalysis:: --- after fillTree"; - } //--------------------------------------------------- -void HcalTestAnalysis::fill(const EndOfEvent * evt) { +void HcalTestAnalysis::fill(const EndOfEvent* evt) { + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Fill event " << (*evt)()->GetEventID(); - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis: Fill event " - << (*evt)()->GetEventID(); - - // access to the G4 hit collections + // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); - - int nhc = 0, neb = 0, nef = 0, j = 0; - caloHitCache_.erase (caloHitCache_.begin(), caloHitCache_.end()); - + + int nhc = 0, neb = 0, nef = 0, j = 0; + caloHitCache_.erase(caloHitCache_.begin(), caloHitCache_.end()); + // Hcal int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[0]); - CaloG4HitCollection* theHCHC = (CaloG4HitCollection*) allHC->GetHC(HCHCid); - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " - << names_[0] << " of ID " << HCHCid - << " is obtained at " << theHCHC; + CaloG4HitCollection* theHCHC = (CaloG4HitCollection*)allHC->GetHC(HCHCid); + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[0] << " of ID " << HCHCid + << " is obtained at " << theHCHC; if (HCHCid >= 0 && theHCHC != nullptr) { for (j = 0; j < theHCHC->entries(); j++) { + CaloG4Hit* aHit = (*theHCHC)[j]; + + double e = aHit->getEnergyDeposit() / GeV; + double time = aHit->getTimeSlice(); + + math::XYZPoint pos = aHit->getPosition(); + double theta = pos.theta(); + double eta = -log(tan(theta * 0.5)); + double phi = pos.phi(); - CaloG4Hit* aHit = (*theHCHC)[j]; - - double e = aHit->getEnergyDeposit()/GeV; - double time = aHit->getTimeSlice(); - - math::XYZPoint pos = aHit->getPosition(); - double theta = pos.theta(); - double eta = -log(tan(theta * 0.5)); - double phi = pos.phi(); - uint32_t unitID = aHit->getUnitID(); int subdet, zside, layer, etaIndex, phiIndex, lay; - org_->unpackHcalIndex(unitID,subdet,zside,layer,etaIndex,phiIndex,lay); - double jitter = time-timeOfFlight(subdet,lay,eta); - if (jitter<0) jitter = 0; - CaloHit hit(subdet,lay,e,eta,phi,jitter,unitID); + org_->unpackHcalIndex(unitID, subdet, zside, layer, etaIndex, phiIndex, lay); + double jitter = time - timeOfFlight(subdet, lay, eta); + if (jitter < 0) + jitter = 0; + CaloHit hit(subdet, lay, e, eta, phi, jitter, unitID); caloHitCache_.push_back(hit); nhc++; - std::string det = "HB"; + std::string det = "HB"; if (subdet == static_cast(HcalForward)) { - det = "HF"; + det = "HF"; } else if (subdet == static_cast(HcalEndcap)) { - if (etaIndex <= 20) { - det = "HES"; - } else { - det = "HED"; - } + if (etaIndex <= 20) { + det = "HES"; + } else { + det = "HED"; + } } - edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " - << std::setw(2) << layer << " time " - << std::setw(6) << time << " theta " - << std::setw(8) << theta << " eta " - << std::setw(8) << eta << " phi " - << std::setw(8) << phi << " e " - << std::setw(8) << e; + edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time " + << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta " + << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8) + << e; } } edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::HCAL hits : " << nhc; // EB int EBHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[1]); - CaloG4HitCollection* theEBHC = (CaloG4HitCollection*) allHC->GetHC(EBHCid); - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " - << names_[1] << " of ID " << EBHCid - << " is obtained at " << theEBHC; + CaloG4HitCollection* theEBHC = (CaloG4HitCollection*)allHC->GetHC(EBHCid); + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[1] << " of ID " << EBHCid + << " is obtained at " << theEBHC; if (EBHCid >= 0 && theEBHC != nullptr) { for (j = 0; j < theEBHC->entries(); j++) { + CaloG4Hit* aHit = (*theEBHC)[j]; + + double e = aHit->getEnergyDeposit() / GeV; + double time = aHit->getTimeSlice(); + std::string det = "EB"; + + math::XYZPoint pos = aHit->getPosition(); + double theta = pos.theta(); + double eta = -log(tan(theta / 2.)); + double phi = pos.phi(); - CaloG4Hit* aHit = (*theEBHC)[j]; - - double e = aHit->getEnergyDeposit()/GeV; - double time = aHit->getTimeSlice(); - std::string det = "EB"; - - math::XYZPoint pos = aHit->getPosition(); - double theta = pos.theta(); - double eta = -log(tan(theta/2.)); - double phi = pos.phi(); - - HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta,phi,1,1); + HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta, phi, 1, 1); uint32_t unitID = org_->getUnitID(id); int subdet, zside, layer, ieta, iphi, lay; - org_->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay); + org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay); subdet = 10; - layer = 0; - unitID = org_->packHcalIndex(subdet,zside,layer,ieta,iphi,lay); - CaloHit hit(subdet,lay,e,eta,phi,time,unitID); + layer = 0; + unitID = org_->packHcalIndex(subdet, zside, layer, ieta, iphi, lay); + CaloHit hit(subdet, lay, e, eta, phi, time, unitID); caloHitCache_.push_back(hit); neb++; - edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " - << std::setw(2) << layer << " time " - << std::setw(6) << time << " theta " - << std::setw(8) << theta << " eta " - << std::setw(8) << eta << " phi " - << std::setw(8) << phi << " e " - << std::setw(8) << e; + edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time " + << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta " + << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8) + << e; } } edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::EB hits : " << neb; // EE int EEHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names_[2]); - CaloG4HitCollection* theEEHC = (CaloG4HitCollection*) allHC->GetHC(EEHCid); - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " - << names_[2] << " of ID " << EEHCid - << " is obtained at " << theEEHC; + CaloG4HitCollection* theEEHC = (CaloG4HitCollection*)allHC->GetHC(EEHCid); + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[2] << " of ID " << EEHCid + << " is obtained at " << theEEHC; if (EEHCid >= 0 && theEEHC != nullptr) { for (j = 0; j < theEEHC->entries(); j++) { + CaloG4Hit* aHit = (*theEEHC)[j]; - CaloG4Hit* aHit = (*theEEHC)[j]; - - double e = aHit->getEnergyDeposit()/GeV; - double time = aHit->getTimeSlice(); + double e = aHit->getEnergyDeposit() / GeV; + double time = aHit->getTimeSlice(); std::string det = "EE"; - - math::XYZPoint pos = aHit->getPosition(); - double theta = pos.theta(); - double eta = -log(tan(theta/2.)); - double phi = pos.phi(); - HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta,phi,1,1); + math::XYZPoint pos = aHit->getPosition(); + double theta = pos.theta(); + double eta = -log(tan(theta / 2.)); + double phi = pos.phi(); + + HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta, phi, 1, 1); uint32_t unitID = org_->getUnitID(id); int subdet, zside, layer, ieta, iphi, lay; - org_->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay); + org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay); subdet = 11; - layer = 0; - unitID = org_->packHcalIndex(subdet,zside,layer,ieta,iphi,lay); - CaloHit hit(subdet,lay,e,eta,phi,time,unitID); + layer = 0; + unitID = org_->packHcalIndex(subdet, zside, layer, ieta, iphi, lay); + CaloHit hit(subdet, lay, e, eta, phi, time, unitID); caloHitCache_.push_back(hit); nef++; - edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " - << std::setw(2) << layer << " time " - << std::setw(6) << time << " theta " - << std::setw(8) << theta << " eta " - << std::setw(8) << eta << " phi " - << std::setw(8) << phi << " e " - << std::setw(8) << e; + edm::LogVerbatim("HcalSim") << "HcalTest: " << det << " layer " << std::setw(2) << layer << " time " + << std::setw(6) << time << " theta " << std::setw(8) << theta << " eta " + << std::setw(8) << eta << " phi " << std::setw(8) << phi << " e " << std::setw(8) + << e; } } edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::EE hits : " << nef; @@ -480,35 +442,35 @@ void HcalTestAnalysis::fill(const EndOfEvent * evt) { //----------------------------------------------------------------------------- void HcalTestAnalysis::qieAnalysis(CLHEP::HepRandomEngine* engine) { - //Fill tuple with hit information int hittot = caloHitCache_.size(); tuples_->fillHits(caloHitCache_); //Get the index of the central tower - HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta0_,phi0_,1,1); + HcalNumberingFromDDD::HcalID id = numberingFromDDD_->unitID(eta0_, phi0_, 1, 1); uint32_t unitID = org_->getUnitID(id); int subdet, zside, layer, ieta, iphi, lay; - org_->unpackHcalIndex(unitID,subdet,zside,layer,ieta,iphi,lay); - int laymax = 0; + org_->unpackHcalIndex(unitID, subdet, zside, layer, ieta, iphi, lay); + int laymax = 0; std::string det = "Unknown"; if (subdet == static_cast(HcalBarrel)) { - laymax = 4; det = "HB"; + laymax = 4; + det = "HB"; } else if (subdet == static_cast(HcalEndcap)) { - laymax = 2; det = "HES"; + laymax = 2; + det = "HES"; } - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: " << det << " Eta " - << ieta << " Phi " << iphi << " Laymax " - << laymax << " Hits " << hittot; - - if (laymax>0 && hittot>0) { - std::vector hits(hittot); - std::vector eqielay(80,0.0), esimlay(80,0.0), esimtot(4,0.0); - std::vector eqietow(200,0.0), esimtow(200,0.0), eqietot(4,0.0); - int etac = (centralTower_/100)%100; - int phic = (centralTower_%100); - - for (int layr=0; layr 0 && hittot > 0) { + std::vector hits(hittot); + std::vector eqielay(80, 0.0), esimlay(80, 0.0), esimtot(4, 0.0); + std::vector eqietow(200, 0.0), esimtow(200, 0.0), eqietot(4, 0.0); + int etac = (centralTower_ / 100) % 100; + int phic = (centralTower_ % 100); + + for (int layr = 0; layr < nGroup_; layr++) { /* int layx, layy=20; for (int i=0; i<20; i++) @@ -523,126 +485,148 @@ void HcalTestAnalysis::qieAnalysis(CLHEP::HepRandomEngine* engine) { else layx = 1; } */ - for (int it=0; it 0 && layer < 20) group = group_[layer]; - if (subdetc == subdet && group == layr+1) { - int zsidec, ietac, iphic, idx; - unitID = hit.id(); - org_->unpackHcalIndex(unitID,subdetc,zsidec,layer,ietac,iphic,lay); - if (etac > 0 && phic > 0) { - idx = ietac*100 + iphic; - } else if (etac > 0) { - idx = ietac*100; - } else if (phic > 0) { - idx = iphic; - } else { - idx = 0; - } - if (zsidec==zside && idx==tower_[it]) { - hits[nhit] = hit; - edm::LogVerbatim("HcalSim") << "HcalTest: Hit " << nhit << " " - << hit; - nhit++; - esim += hit.e(); - } - } - } - - std::vector cd = myqie_->getCode(nhit, hits, engine); - double eqie = myqie_->getEnergy(cd); - - edm::LogVerbatim("HcalSim") <<"HcalTestAnalysis::Qie: Energy in layer " - << layr << " Sim " << esim << " After QIE " - << eqie; - for (int i=0; i<4; i++) { - if (tower_[nTower_+it] <= i) { - esimtot[i] += esim; - eqietot[i] += eqie; - esimlay[20*i+layr] += esim; - eqielay[20*i+layr] += eqie; - esimtow[50*i+it] += esim; - eqietow[50*i+it] += eqie; - } - } + for (int it = 0; it < nTower_; it++) { + int nhit = 0; + double esim = 0; + for (int k1 = 0; k1 < hittot; k1++) { + CaloHit hit = caloHitCache_[k1]; + int subdetc = hit.det(); + int layer = hit.layer(); + int group = 0; + if (layer > 0 && layer < 20) + group = group_[layer]; + if (subdetc == subdet && group == layr + 1) { + int zsidec, ietac, iphic, idx; + unitID = hit.id(); + org_->unpackHcalIndex(unitID, subdetc, zsidec, layer, ietac, iphic, lay); + if (etac > 0 && phic > 0) { + idx = ietac * 100 + iphic; + } else if (etac > 0) { + idx = ietac * 100; + } else if (phic > 0) { + idx = iphic; + } else { + idx = 0; + } + if (zsidec == zside && idx == tower_[it]) { + hits[nhit] = hit; + edm::LogVerbatim("HcalSim") << "HcalTest: Hit " << nhit << " " << hit; + nhit++; + esim += hit.e(); + } + } + } + + std::vector cd = myqie_->getCode(nhit, hits, engine); + double eqie = myqie_->getEnergy(cd); + + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: Energy in layer " << layr << " Sim " << esim + << " After QIE " << eqie; + for (int i = 0; i < 4; i++) { + if (tower_[nTower_ + it] <= i) { + esimtot[i] += esim; + eqietot[i] += eqie; + esimlay[20 * i + layr] += esim; + eqielay[20 * i + layr] += eqie; + esimtow[50 * i + it] += esim; + eqietow[50 * i + it] += eqie; + } + } } } - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: Total energy " - << esimtot[3] << " (SimHit) " << eqietot[3] - << " (After QIE)"; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::Qie: Total energy " << esimtot[3] << " (SimHit) " << eqietot[3] + << " (After QIE)"; std::vector latphi(10); - int nt = 2*addTower_ + 1; - for (int it=0; it latfs(10,0.), latfq(10,0.), longs(20), longq(20); - if (esimtot[i]>0) scals = 1./esimtot[i]; - if (eqietot[i]>0) scalq = 1./eqietot[i]; - for (int it=0; it latfs(10, 0.), latfq(10, 0.), longs(20), longq(20); + if (esimtot[i] > 0) + scals = 1. / esimtot[i]; + if (eqietot[i] > 0) + scalq = 1. / eqietot[i]; + for (int it = 0; it < nTower_; it++) { + int phib = it % nt; + latfs[phib] += scals * esimtow[50 * i + it]; + latfq[phib] += scalq * eqietow[50 * i + it]; } - for (int layr=0; layr<=nGroup_; layr++) { - longs[layr] = scals*esimlay[20*i+layr]; - longq[layr] = scalq*eqielay[20*i+layr]; + for (int layr = 0; layr <= nGroup_; layr++) { + longs[layr] = scals * esimlay[20 * i + layr]; + longq[layr] = scalq * eqielay[20 * i + layr]; } - tuples_->fillQie(i,esimtot[i],eqietot[i],nGroup_,longs,longq, - nt,latphi,latfs,latfq); + tuples_->fillQie(i, esimtot[i], eqietot[i], nGroup_, longs, longq, nt, latphi, latfs, latfq); } } } //--------------------------------------------------- -void HcalTestAnalysis::layerAnalysis(){ - +void HcalTestAnalysis::layerAnalysis() { int i = 0; - edm::LogVerbatim("HcalSim") << "\n ===>>> HcalTestAnalysis: Energy deposit " - << "\n at EB : " << std::setw(6) << edepEB_/MeV - << "\n at EE : " << std::setw(6) << edepEE_/MeV - << "\n at HB : " << std::setw(6) << edepHB_/MeV - << "\n at HE : " << std::setw(6) << edepHE_/MeV - << "\n at HO : " << std::setw(6) << edepHO_/MeV - << "\n ---- HcalTestAnalysis: Energy deposit " - << "in Layers"; - for (i = 0; i < 20; i++) - edm::LogVerbatim("HcalSim") << " Layer " << std::setw(2) << i << " E " - << std::setw(8) << edepl_[i]/MeV << " MeV"; - - tuples_->fillLayers(edepl_, edepHO_, edepHB_+edepHE_, mudist_); + edm::LogVerbatim("HcalSim") << "\n ===>>> HcalTestAnalysis: Energy deposit " + << "\n at EB : " << std::setw(6) << edepEB_ / MeV << "\n at EE : " << std::setw(6) + << edepEE_ / MeV << "\n at HB : " << std::setw(6) << edepHB_ / MeV + << "\n at HE : " << std::setw(6) << edepHE_ / MeV << "\n at HO : " << std::setw(6) + << edepHO_ / MeV << "\n ---- HcalTestAnalysis: Energy deposit in Layers"; + for (i = 0; i < 20; i++) + edm::LogVerbatim("HcalSim") << " Layer " << std::setw(2) << i << " E " << std::setw(8) << edepl_[i] / MeV << " MeV"; + + tuples_->fillLayers(edepl_, edepHO_, edepHB_ + edepHE_, mudist_); } - //--------------------------------------------------- double HcalTestAnalysis::timeOfFlight(int det, int layer, double eta) { - - double theta = 2.0*atan(exp(-eta)); - double dist = 0.; + double theta = 2.0 * atan(exp(-eta)); + double dist = 0.; if (det == static_cast(HcalBarrel)) { - const double rLay[19] = { - 1836.0, 1902.0, 1962.0, 2022.0, 2082.0, 2142.0, 2202.0, 2262.0, 2322.0, - 2382.0, 2448.0, 2514.0, 2580.0, 2646.0, 2712.0, 2776.0, 2862.5, 3847.0, - 4052.0}; - if (layer>0 && layer<20) dist += rLay[layer-1]*mm/sin(theta); + const double rLay[19] = {1836.0, + 1902.0, + 1962.0, + 2022.0, + 2082.0, + 2142.0, + 2202.0, + 2262.0, + 2322.0, + 2382.0, + 2448.0, + 2514.0, + 2580.0, + 2646.0, + 2712.0, + 2776.0, + 2862.5, + 3847.0, + 4052.0}; + if (layer > 0 && layer < 20) + dist += rLay[layer - 1] * mm / sin(theta); } else { - const double zLay[19] = { - 4034.0, 4032.0, 4123.0, 4210.0, 4297.0, 4384.0, 4471.0, 4558.0, 4645.0, - 4732.0, 4819.0, 4906.0, 4993.0, 5080.0, 5167.0, 5254.0, 5341.0, 5428.0, - 5515.0}; - if (layer>0 && layer<20) dist += zLay[layer-1]*mm/cos(theta); + const double zLay[19] = {4034.0, + 4032.0, + 4123.0, + 4210.0, + 4297.0, + 4384.0, + 4471.0, + 4558.0, + 4645.0, + 4732.0, + 4819.0, + 4906.0, + 4993.0, + 5080.0, + 5167.0, + 5254.0, + 5341.0, + 5428.0, + 5515.0}; + if (layer > 0 && layer < 20) + dist += zLay[layer - 1] * mm / cos(theta); } - double tmp = dist/c_light/ns; - edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::timeOfFlight " << tmp - << " for det/lay " << det << " " << layer - << " eta/theta " << eta << " " << theta/deg - << " dist " << dist; + double tmp = dist / c_light / ns; + edm::LogVerbatim("HcalSim") << "HcalTestAnalysis::timeOfFlight " << tmp << " for det/lay " << det << " " << layer + << " eta/theta " << eta << " " << theta / deg << " dist " << dist; return tmp; } diff --git a/SimG4CMS/Calo/src/HcalTestHistoManager.cc b/SimG4CMS/Calo/src/HcalTestHistoManager.cc index b78d85b6e4f8b..14265d22cb414 100644 --- a/SimG4CMS/Calo/src/HcalTestHistoManager.cc +++ b/SimG4CMS/Calo/src/HcalTestHistoManager.cc @@ -10,36 +10,34 @@ #include #include -HcalTestHistoManager::HcalTestHistoManager(const std::string & file) : - tree(nullptr), h(nullptr), kount(0) { - if (fs.isAvailable()) { - h = new HcalTestHistoClass(); - - tree = fs->make("HcalTest", "HcalTest"); - tree->SetAutoSave(10000); - tree->Branch("HcalTestHisto", "HcalTestHistoClass", &h); - edm::LogInfo("HcalSim") << "HcalTestHistoManager:===>>> Book the Tree"; +//#define EDM_ML_DEBUG + +HcalTestHistoManager::HcalTestHistoManager(const std::string& file) : tree_(nullptr), kount_(0) { + if (fs_.isAvailable()) { + h_.reset(new HcalTestHistoClass()); + + tree_ = fs_->make("HcalTest", "HcalTest"); + tree_->SetAutoSave(10000); + tree_->Branch("HcalTestHisto", "HcalTestHistoClass", &h_); + edm::LogVerbatim("HcalSim") << "HcalTestHistoManager:===>>> Book the Tree"; } else { - edm::LogInfo("HcalSim") << "HcalTestHistoManager:===>>> No file provided"; + edm::LogVerbatim("HcalSim") << "HcalTestHistoManager:===>>> No file provided"; } } HcalTestHistoManager::~HcalTestHistoManager() { - - edm::LogInfo("HcalSim") << "=============================================" - << "========================================\n" - << "=== HcalTestHistoManager: Start writing user " - << "histograms after " << kount << " events "; - if (h) delete h; + edm::LogVerbatim("HcalSim") << "=================================================================" + << "====================\n=== HcalTestHistoManager: Start writing user " + << "histograms after " << kount_ << " events "; } -void HcalTestHistoManager::fillTree(HcalTestHistoClass * histos) { - - kount++; - LogDebug("HcalSim") << "HcalTestHistoManager: tree pointer for " << kount - << " = " << histos; - if (tree) { - h = histos; - tree->Fill(); +void HcalTestHistoManager::fillTree(HcalTestHistoClass* histos) { + ++kount_; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalSim") << "HcalTestHistoManager: tree pointer for " << kount_ << " = " << histos; +#endif + if (tree_) { + h_.reset(histos); + tree_->Fill(); } } diff --git a/SimG4CMS/Calo/src/HcalTestNS.cc b/SimG4CMS/Calo/src/HcalTestNS.cc index 4fdd73abe2478..fe1ef687f5f0d 100644 --- a/SimG4CMS/Calo/src/HcalTestNS.cc +++ b/SimG4CMS/Calo/src/HcalTestNS.cc @@ -9,8 +9,7 @@ //#define EDM_ML_DEBUG HcalTestNS::HcalTestNS(const edm::EventSetup* iSetup) { - - edm::ESHandle hdc; + edm::ESHandle hdc; iSetup->get().get(hdc); if (hdc.isValid()) { hcons_ = hdc.product(); @@ -22,19 +21,18 @@ HcalTestNS::HcalTestNS(const edm::EventSetup* iSetup) { HcalTestNS::~HcalTestNS() {} -bool HcalTestNS::compare(HcalNumberingFromDDD::HcalID const& tmp, - uint32_t const& id) { - +bool HcalTestNS::compare(HcalNumberingFromDDD::HcalID const& tmp, uint32_t const& id) { HcalNumberingScheme* scheme = dynamic_cast(new HcalTestNumberingScheme(false)); uint32_t id0 = scheme->getUnitID(tmp); - DetId hid = HcalHitRelabeller::relabel(id0,hcons_); - bool ok = (id == hid.rawId()); + DetId hid = HcalHitRelabeller::relabel(id0, hcons_); + bool ok = (id == hid.rawId()); #ifdef EDM_ML_DEBUG - std::cout << "Det ID from HCalSD " << HcalDetId(id) << " " << std::hex << id - << std::dec << " from relabller " << HcalDetId(hid) << " " - << std::hex << hid.rawId() << std::dec; - if (!ok) std::cout << " **** ERROR ****" << std::endl; - else std::cout << " OK " << std::endl; + std::cout << "Det ID from HCalSD " << HcalDetId(id) << " " << std::hex << id << std::dec << " from relabller " + << HcalDetId(hid) << " " << std::hex << hid.rawId() << std::dec; + if (!ok) + std::cout << " **** ERROR ****" << std::endl; + else + std::cout << " OK " << std::endl; #endif return ok; } diff --git a/SimG4CMS/Calo/src/HcalTestNumberingScheme.cc b/SimG4CMS/Calo/src/HcalTestNumberingScheme.cc index b437bb9b5388e..cb200886e6986 100644 --- a/SimG4CMS/Calo/src/HcalTestNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HcalTestNumberingScheme.cc @@ -10,58 +10,45 @@ //#define EDM_ML_DEBUG -HcalTestNumberingScheme::HcalTestNumberingScheme(bool forTB) : - HcalNumberingScheme(), forTBH2(forTB) { - edm::LogInfo("HcalSim") << "Creating HcalTestNumberingScheme with TB Flag " - << forTBH2 << std::endl; +HcalTestNumberingScheme::HcalTestNumberingScheme(bool forTB) : HcalNumberingScheme(), forTBH2(forTB) { + edm::LogVerbatim("HcalSim") << "Creating HcalTestNumberingScheme with TB Flag " << forTBH2; } HcalTestNumberingScheme::~HcalTestNumberingScheme() { - edm::LogInfo("HcalSim") << "Deleting HcalTestNumberingScheme" << std::endl; + edm::LogVerbatim("HcalSim") << "Deleting HcalTestNumberingScheme"; } -uint32_t HcalTestNumberingScheme::getUnitID(const HcalNumberingFromDDD::HcalID& - id) { - +uint32_t HcalTestNumberingScheme::getUnitID(const HcalNumberingFromDDD::HcalID& id) { //pack it into an integer uint32_t index = 0; if (forTBH2) { // TB H2 Case - int etaR = id.etaR; - int phi = id.phis; - HcalSubdetector subdet = (HcalSubdetector)(id.subdet); - if (subdet == HcalBarrel && phi > 4) { // HB2 + int etaR = id.etaR; + int phi = id.phis; + HcalSubdetector subdet = (HcalSubdetector)(id.subdet); + if (subdet == HcalBarrel && phi > 4) { // HB2 if (etaR > 4 && etaR < 10) - index = HcalDetId(subdet,id.lay,id.phis,1).rawId(); - } else { // HB1 - index = HcalDetId(subdet,etaR,id.phis,id.depth).rawId(); + index = HcalDetId(subdet, id.lay, id.phis, 1).rawId(); + } else { // HB1 + index = HcalDetId(subdet, etaR, id.phis, id.depth).rawId(); } } else { // Test case - index = HcalTestNumbering::packHcalIndex(id.subdet, id.zside, id.depth, - id.etaR, id.phis, id.lay); + index = HcalTestNumbering::packHcalIndex(id.subdet, id.zside, id.depth, id.etaR, id.phis, id.lay); } #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "HcalTestNumberingScheme det = " << id.subdet - << " depth/lay = " << id.depth << "/" << id.lay - << " zside = " << id.zside << " eta/R = " << id.etaR - << " phi = " << id.phis << " packed index = 0x" - << std::hex << index << std::dec << std::endl; + edm::LogVerbatim("HcalSim") << "HcalTestNumberingScheme det = " << id.subdet << " depth/lay = " << id.depth << "/" + << id.lay << " zside = " << id.zside << " eta/R = " << id.etaR << " phi = " << id.phis + << " packed index = 0x" << std::hex << index << std::dec << std::endl; #endif return index; - } -uint32_t HcalTestNumberingScheme::packHcalIndex(int det, int z, int depth, - int eta, int phi, int lay) { - - return HcalTestNumbering::packHcalIndex(det, z, depth, eta, phi, lay); +uint32_t HcalTestNumberingScheme::packHcalIndex(int det, int z, int depth, int eta, int phi, int lay) { + return HcalTestNumbering::packHcalIndex(det, z, depth, eta, phi, lay); } -void HcalTestNumberingScheme::unpackHcalIndex(const uint32_t & idx, - int& det, int& z, - int& depth, int& eta, - int& phi, int& lay) { - +void HcalTestNumberingScheme::unpackHcalIndex( + const uint32_t& idx, int& det, int& z, int& depth, int& eta, int& phi, int& lay) { HcalTestNumbering::unpackHcalIndex(idx, det, z, depth, eta, phi, lay); } diff --git a/SimG4CMS/Calo/test/CaloSimHitStudy.cc b/SimG4CMS/Calo/test/CaloSimHitStudy.cc index f175024eccc1e..ee32f0cdfb0aa 100644 --- a/SimG4CMS/Calo/test/CaloSimHitStudy.cc +++ b/SimG4CMS/Calo/test/CaloSimHitStudy.cc @@ -34,69 +34,65 @@ #include #include -class CaloSimHitStudy: public edm::one::EDAnalyzer { +class CaloSimHitStudy : public edm::one::EDAnalyzer { public: - CaloSimHitStudy(const edm::ParameterSet& ps); ~CaloSimHitStudy() override {} static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); protected: - void beginJob() override {} void analyze(edm::Event const&, edm::EventSetup const&) override; void beginRun(edm::Run const&, edm::EventSetup const&) override {} void endRun(edm::Run const&, edm::EventSetup const&) override {} - void analyzeHits (std::vector &, int); - void analyzeHits (edm::Handle&, int); - void analyzeHits (std::vector &, std::vector &, std::vector &); + void analyzeHits(std::vector&, int); + void analyzeHits(edm::Handle&, int); + void analyzeHits(std::vector&, std::vector&, std::vector&); private: - - std::string g4Label, hitLab[4]; + std::string g4Label, hitLab[4]; edm::EDGetTokenT tok_evt_; edm::EDGetTokenT toks_calo_[4]; edm::EDGetTokenT toks_track_[3]; edm::EDGetTokenT toks_tkHigh_[6]; edm::EDGetTokenT toks_tkLow_[6]; - std::string muonLab[3], tkHighLab[6], tkLowLab[6]; - double tmax_, eMIP_; - bool storeRL_, testNumber_; - - TH1F *hit_[9], *time_[9], *edepEM_[9], *edepHad_[9], *edep_[9]; - TH1F *etot_[9], *etotg_[9], *timeAll_[9], *hitMu, *hitHigh; - TH1F *hitLow, *eneInc_, *etaInc_, *phiInc_, *ptInc_; - TH1F *hitTk_[15], *edepTk_[15], *tofTk_[15], *edepC_[9],*edepT_[9]; + std::string muonLab[3], tkHighLab[6], tkLowLab[6]; + double tmax_, eMIP_; + bool storeRL_, testNumber_; + + TH1F *hit_[9], *time_[9], *edepEM_[9], *edepHad_[9], *edep_[9]; + TH1F *etot_[9], *etotg_[9], *timeAll_[9], *hitMu, *hitHigh; + TH1F *hitLow, *eneInc_, *etaInc_, *phiInc_, *ptInc_; + TH1F *hitTk_[15], *edepTk_[15], *tofTk_[15], *edepC_[9], *edepT_[9]; }; CaloSimHitStudy::CaloSimHitStudy(const edm::ParameterSet& ps) { - usesResource(TFileService::kSharedResource); - tok_evt_ = consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel","VtxSmeared"))); - g4Label = ps.getUntrackedParameter("ModuleLabel","g4SimHits"); - hitLab[0] = ps.getUntrackedParameter("EBCollection","EcalHitsEB"); - hitLab[1] = ps.getUntrackedParameter("EECollection","EcalHitsEE"); - hitLab[2] = ps.getUntrackedParameter("ESCollection","EcalHitsES"); - hitLab[3] = ps.getUntrackedParameter("HCCollection","HcalHits"); - - - double maxEnergy_= ps.getUntrackedParameter("MaxEnergy", 200.0); - tmax_ = ps.getUntrackedParameter("TimeCut", 100.0); - eMIP_ = ps.getUntrackedParameter("MIPCut", 0.70); - storeRL_ = ps.getUntrackedParameter("StoreRL", false); - testNumber_ = ps.getUntrackedParameter("TestNumbering",false); - - muonLab[0] = "MuonRPCHits"; - muonLab[1] = "MuonCSCHits"; - muonLab[2] = "MuonDTHits"; - tkHighLab[0]= "TrackerHitsPixelBarrelHighTof"; - tkHighLab[1]= "TrackerHitsPixelEndcapHighTof"; - tkHighLab[2]= "TrackerHitsTECHighTof"; - tkHighLab[3]= "TrackerHitsTIBHighTof"; - tkHighLab[4]= "TrackerHitsTIDHighTof"; - tkHighLab[5]= "TrackerHitsTOBHighTof"; + tok_evt_ = + consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel", "VtxSmeared"))); + g4Label = ps.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hitLab[0] = ps.getUntrackedParameter("EBCollection", "EcalHitsEB"); + hitLab[1] = ps.getUntrackedParameter("EECollection", "EcalHitsEE"); + hitLab[2] = ps.getUntrackedParameter("ESCollection", "EcalHitsES"); + hitLab[3] = ps.getUntrackedParameter("HCCollection", "HcalHits"); + + double maxEnergy_ = ps.getUntrackedParameter("MaxEnergy", 200.0); + tmax_ = ps.getUntrackedParameter("TimeCut", 100.0); + eMIP_ = ps.getUntrackedParameter("MIPCut", 0.70); + storeRL_ = ps.getUntrackedParameter("StoreRL", false); + testNumber_ = ps.getUntrackedParameter("TestNumbering", false); + + muonLab[0] = "MuonRPCHits"; + muonLab[1] = "MuonCSCHits"; + muonLab[2] = "MuonDTHits"; + tkHighLab[0] = "TrackerHitsPixelBarrelHighTof"; + tkHighLab[1] = "TrackerHitsPixelEndcapHighTof"; + tkHighLab[2] = "TrackerHitsTECHighTof"; + tkHighLab[3] = "TrackerHitsTIBHighTof"; + tkHighLab[4] = "TrackerHitsTIDHighTof"; + tkHighLab[5] = "TrackerHitsTOBHighTof"; tkLowLab[0] = "TrackerHitsPixelBarrelLowTof"; tkLowLab[1] = "TrackerHitsPixelEndcapLowTof"; tkLowLab[2] = "TrackerHitsTECLowTof"; @@ -105,447 +101,505 @@ CaloSimHitStudy::CaloSimHitStudy(const edm::ParameterSet& ps) { tkLowLab[5] = "TrackerHitsTOBLowTof"; // register for data access - for ( unsigned i=0; i != 4; i++ ) - toks_calo_[i] = consumes(edm::InputTag(g4Label,hitLab[i])); + for (unsigned i = 0; i != 4; i++) + toks_calo_[i] = consumes(edm::InputTag(g4Label, hitLab[i])); - for ( unsigned i=0; i != 3; i++ ) - toks_track_[i] = consumes(edm::InputTag(g4Label,muonLab[i])); + for (unsigned i = 0; i != 3; i++) + toks_track_[i] = consumes(edm::InputTag(g4Label, muonLab[i])); - for ( unsigned i=0; i != 6; i++ ) { - toks_tkHigh_[i] = consumes(edm::InputTag(g4Label,tkHighLab[i])); - toks_tkLow_[i] = consumes(edm::InputTag(g4Label,tkLowLab[i])); + for (unsigned i = 0; i != 6; i++) { + toks_tkHigh_[i] = consumes(edm::InputTag(g4Label, tkHighLab[i])); + toks_tkLow_[i] = consumes(edm::InputTag(g4Label, tkLowLab[i])); } - - edm::LogInfo("HitStudy") << "Module Label: " << g4Label << " Hits: " - << hitLab[0] << ", " << hitLab[1] << ", " - << hitLab[2] << ", "<< hitLab[3] - << " MaxEnergy: " << maxEnergy_ << " Tmax: " - << tmax_ << " MIP Cut: " << eMIP_; + edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label << " Hits: " << hitLab[0] << ", " << hitLab[1] << ", " + << hitLab[2] << ", " << hitLab[3] << " MaxEnergy: " << maxEnergy_ + << " Tmax: " << tmax_ << " MIP Cut: " << eMIP_; edm::Service tfile; - - if ( !tfile.isAvailable() ) + + if (!tfile.isAvailable()) throw cms::Exception("BadConfig") << "TFileService unavailable: " << "please add it to config file"; - char name[20], title[120]; - sprintf (title, "Incident PT (GeV)"); + char name[20], title[120]; + sprintf(title, "Incident PT (GeV)"); ptInc_ = tfile->make("PtInc", title, 1000, 0., maxEnergy_); - ptInc_->GetXaxis()-> SetTitle(title); + ptInc_->GetXaxis()->SetTitle(title); ptInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident Energy (GeV)"); + sprintf(title, "Incident Energy (GeV)"); eneInc_ = tfile->make("EneInc", title, 1000, 0., maxEnergy_); - eneInc_->GetXaxis()-> SetTitle(title); + eneInc_->GetXaxis()->SetTitle(title); eneInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #eta"); + sprintf(title, "Incident #eta"); etaInc_ = tfile->make("EtaInc", title, 200, -5., 5.); etaInc_->GetXaxis()->SetTitle(title); etaInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #phi"); + sprintf(title, "Incident #phi"); phiInc_ = tfile->make("PhiInc", title, 200, -3.1415926, 3.1415926); phiInc_->GetXaxis()->SetTitle(title); phiInc_->GetYaxis()->SetTitle("Events"); std::string dets[9] = {"EB", "EB(APD)", "EB(ATJ)", "EE", "ES", "HB", "HE", "HO", "HF"}; - for (int i=0; i<9; i++) { - sprintf (name, "Hit%d", i); - sprintf (title, "Number of hits in %s", dets[i].c_str()); - hit_[i] = tfile->make(name, title, 1000, 0., 20000.); - hit_[i]->GetXaxis()->SetTitle(title); + for (int i = 0; i < 9; i++) { + sprintf(name, "Hit%d", i); + sprintf(title, "Number of hits in %s", dets[i].c_str()); + hit_[i] = tfile->make(name, title, 1000, 0., 20000.); + hit_[i]->GetXaxis()->SetTitle(title); hit_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "Time%d", i); - sprintf (title, "Time of the hit (ns) in %s", dets[i].c_str()); - time_[i] = tfile->make(name, title, 1000, 0., 1000.); - time_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Time%d", i); + sprintf(title, "Time of the hit (ns) in %s", dets[i].c_str()); + time_[i] = tfile->make(name, title, 1000, 0., 1000.); + time_[i]->GetXaxis()->SetTitle(title); time_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "TimeAll%d", i); - sprintf (title, "Hit time (ns) in %s with no check on Track ID", dets[i].c_str()); - timeAll_[i] = tfile->make(name, title, 1000, 0., 1000.); - timeAll_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "TimeAll%d", i); + sprintf(title, "Hit time (ns) in %s with no check on Track ID", dets[i].c_str()); + timeAll_[i] = tfile->make(name, title, 1000, 0., 1000.); + timeAll_[i]->GetXaxis()->SetTitle(title); timeAll_[i]->GetYaxis()->SetTitle("Hits"); double ymax = maxEnergy_; - if (i==1 || i==2 || i==4) ymax = 1.0; - else if (i>4 && i<8) ymax = 10.0; - sprintf (name, "Edep%d", i); - sprintf (title, "Energy deposit (GeV) in %s", dets[i].c_str()); - edep_[i] = tfile->make(name, title, 5000, 0., ymax); - edep_[i]->GetXaxis()->SetTitle(title); + if (i == 1 || i == 2 || i == 4) + ymax = 1.0; + else if (i > 4 && i < 8) + ymax = 10.0; + sprintf(name, "Edep%d", i); + sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str()); + edep_[i] = tfile->make(name, title, 5000, 0., ymax); + edep_[i]->GetXaxis()->SetTitle(title); edep_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "EdepEM%d", i); - sprintf (title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str()); - edepEM_[i] = tfile->make(name, title, 5000, 0., ymax); - edepEM_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepEM%d", i); + sprintf(title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str()); + edepEM_[i] = tfile->make(name, title, 5000, 0., ymax); + edepEM_[i]->GetXaxis()->SetTitle(title); edepEM_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "EdepHad%d", i); - sprintf (title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str()); - edepHad_[i] = tfile->make(name, title, 5000, 0., ymax); - edepHad_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepHad%d", i); + sprintf(title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str()); + edepHad_[i] = tfile->make(name, title, 5000, 0., ymax); + edepHad_[i]->GetXaxis()->SetTitle(title); edepHad_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "Etot%d", i); - sprintf (title, "Total energy deposit (GeV) in %s", dets[i].c_str()); - etot_[i] = tfile->make(name, title, 5000, 0., ymax); - etot_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Etot%d", i); + sprintf(title, "Total energy deposit (GeV) in %s", dets[i].c_str()); + etot_[i] = tfile->make(name, title, 5000, 0., ymax); + etot_[i]->GetXaxis()->SetTitle(title); etot_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EtotG%d", i); - sprintf (title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str()); - etotg_[i] = tfile->make(name, title, 5000, 0., ymax); - etotg_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EtotG%d", i); + sprintf(title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str()); + etotg_[i] = tfile->make(name, title, 5000, 0., ymax); + etotg_[i]->GetXaxis()->SetTitle(title); etotg_[i]->GetYaxis()->SetTitle("Events"); } - std::string detx[9] = {"EB/EE (MIP)", "HB/HE (MIP)", "HB/HE/HO (MIP)", "EB/EE (no MIP)", "HB/HE (no MIP)", "HB/HE/HO (no MIP)", "EB/EE (All)", "HB/HE (All)", "HB/HE/HO (All)"}; - for (int i=0; i<9; i++) { + std::string detx[9] = {"EB/EE (MIP)", + "HB/HE (MIP)", + "HB/HE/HO (MIP)", + "EB/EE (no MIP)", + "HB/HE (no MIP)", + "HB/HE/HO (no MIP)", + "EB/EE (All)", + "HB/HE (All)", + "HB/HE/HO (All)"}; + for (int i = 0; i < 9; i++) { double ymax = 1.0; - if (i==0 || i==3 || i==6) ymax = maxEnergy_; - sprintf (name, "EdepCal%d", i); - sprintf (title, "Energy deposit in %s", detx[i].c_str()); - edepC_[i] = tfile->make(name, title, 5000, 0., ymax); - edepC_[i]->GetXaxis()->SetTitle(title); + if (i == 0 || i == 3 || i == 6) + ymax = maxEnergy_; + sprintf(name, "EdepCal%d", i); + sprintf(title, "Energy deposit in %s", detx[i].c_str()); + edepC_[i] = tfile->make(name, title, 5000, 0., ymax); + edepC_[i]->GetXaxis()->SetTitle(title); edepC_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EdepCalT%d", i); - sprintf (title, "Energy deposit (t < %f ns) in %s", tmax_,detx[i].c_str()); - edepT_[i] = tfile->make(name, title, 5000, 0., ymax); - edepT_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepCalT%d", i); + sprintf(title, "Energy deposit (t < %f ns) in %s", tmax_, detx[i].c_str()); + edepT_[i] = tfile->make(name, title, 5000, 0., ymax); + edepT_[i]->GetXaxis()->SetTitle(title); edepT_[i]->GetYaxis()->SetTitle("Events"); } - hitLow = tfile->make("HitLow","Number of hits in Track (Low)",1000,0,10000.); + hitLow = tfile->make("HitLow", "Number of hits in Track (Low)", 1000, 0, 10000.); hitLow->GetXaxis()->SetTitle("Number of hits in Track (Low)"); hitLow->GetYaxis()->SetTitle("Events"); - hitHigh= tfile->make("HitHigh","Number of hits in Track (High)",1000,0,10000.); + hitHigh = tfile->make("HitHigh", "Number of hits in Track (High)", 1000, 0, 10000.); hitHigh->GetXaxis()->SetTitle("Number of hits in Track (High)"); hitHigh->GetYaxis()->SetTitle("Events"); - hitMu = tfile->make("HitMu","Number of hits in Track (Muon)",1000,0,5000.); + hitMu = tfile->make("HitMu", "Number of hits in Track (Muon)", 1000, 0, 5000.); hitMu->GetXaxis()->SetTitle("Number of hits in Muon"); hitMu->GetYaxis()->SetTitle("Events"); - std::string dett[15] = {"Pixel Barrel (High)", "Pixel Endcap (High)", - "TEC (High)", "TIB (High)", "TID (High)", - "TOB (High)", "Pixel Barrel (Low)", - "Pixel Endcap (Low)","TEC (Low)", "TIB (Low)", - "TID (Low)", "TOB (Low)", "RPC", "CSC", "DT"}; - for (int i=0; i<15; i++) { - sprintf (name, "HitTk%d", i); - sprintf (title, "Number of hits in %s", dett[i].c_str()); - hitTk_[i] = tfile->make(name, title, 1000, 0., 1000.); - hitTk_[i]->GetXaxis()->SetTitle(title); + std::string dett[15] = {"Pixel Barrel (High)", + "Pixel Endcap (High)", + "TEC (High)", + "TIB (High)", + "TID (High)", + "TOB (High)", + "Pixel Barrel (Low)", + "Pixel Endcap (Low)", + "TEC (Low)", + "TIB (Low)", + "TID (Low)", + "TOB (Low)", + "RPC", + "CSC", + "DT"}; + for (int i = 0; i < 15; i++) { + sprintf(name, "HitTk%d", i); + sprintf(title, "Number of hits in %s", dett[i].c_str()); + hitTk_[i] = tfile->make(name, title, 1000, 0., 1000.); + hitTk_[i]->GetXaxis()->SetTitle(title); hitTk_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "TimeTk%d", i); - sprintf (title, "Time of the hit (ns) in %s", dett[i].c_str()); - tofTk_[i] = tfile->make(name, title, 1000, 0., 200.); - tofTk_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "TimeTk%d", i); + sprintf(title, "Time of the hit (ns) in %s", dett[i].c_str()); + tofTk_[i] = tfile->make(name, title, 1000, 0., 200.); + tofTk_[i]->GetXaxis()->SetTitle(title); tofTk_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "EdepTk%d", i); - sprintf (title, "Energy deposit (GeV) in %s", dett[i].c_str()); - edepTk_[i] = tfile->make(name, title, 5000, 0., 10.); - edepTk_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepTk%d", i); + sprintf(title, "Energy deposit (GeV) in %s", dett[i].c_str()); + edepTk_[i] = tfile->make(name, title, 5000, 0., 10.); + edepTk_[i]->GetXaxis()->SetTitle(title); edepTk_[i]->GetYaxis()->SetTitle("Hits"); } } -void CaloSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - +void CaloSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.addUntracked("SourceLabel", "generatorSmeared"); desc.addUntracked("ModuleLabel", "g4SimHits"); - desc.addUntracked("EBCollection","EcalHitsEB"); - desc.addUntracked("EECollection","EcalHitsEE"); - desc.addUntracked("ESCollection","EcalHitsES"); - desc.addUntracked("HCCollection","HcalHits"); - desc.addUntracked("MaxEnergy", 200.0); - desc.addUntracked("TimeCut", 100.0); - desc.addUntracked("MIPCut", 0.70); - desc.addUntracked("StoreRL", false); + desc.addUntracked("EBCollection", "EcalHitsEB"); + desc.addUntracked("EECollection", "EcalHitsEE"); + desc.addUntracked("ESCollection", "EcalHitsES"); + desc.addUntracked("HCCollection", "HcalHits"); + desc.addUntracked("MaxEnergy", 200.0); + desc.addUntracked("TimeCut", 100.0); + desc.addUntracked("MIPCut", 0.70); + desc.addUntracked("StoreRL", false); desc.addUntracked("TestNumbering", false); - descriptions.add("CaloSimHitStudy",desc); + descriptions.add("CaloSimHitStudy", desc); } -void CaloSimHitStudy::analyze(edm::Event const& e, edm::EventSetup const& ) { - - LogDebug("HitStudy") << "Run = " << e.id().run() << " Event = " - << e.id().event(); +void CaloSimHitStudy::analyze(edm::Event const& e, edm::EventSetup const&) { + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy:Run = " << e.id().run() << " Event = " << e.id().event(); - edm::Handle EvtHandle; + edm::Handle EvtHandle; e.getByToken(tok_evt_, EvtHandle); - const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); + const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); - double eInc=0, etaInc=0, phiInc=0; - HepMC::GenEvent::particle_const_iterator p=myGenEvent->particles_begin(); + double eInc = 0, etaInc = 0, phiInc = 0; + HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); if (p != myGenEvent->particles_end()) { - eInc = (*p)->momentum().e(); + eInc = (*p)->momentum().e(); etaInc = (*p)->momentum().eta(); phiInc = (*p)->momentum().phi(); } - double ptInc = eInc/std::cosh(etaInc); + double ptInc = eInc / std::cosh(etaInc); ptInc_->Fill(ptInc); eneInc_->Fill(eInc); etaInc_->Fill(etaInc); phiInc_->Fill(phiInc); std::vector ebHits, eeHits, hcHits; - for (int i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { bool getHits = false; edm::Handle hitsCalo; - e.getByToken(toks_calo_[i],hitsCalo); - if (hitsCalo.isValid()) getHits = true; - LogDebug("HitStudy") << "HcalValidation: Input flags Hits " << getHits; + e.getByToken(toks_calo_[i], hitsCalo); + if (hitsCalo.isValid()) + getHits = true; + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy: Input flags Hits " << getHits; if (getHits) { std::vector caloHits; - caloHits.insert(caloHits.end(),hitsCalo->begin(),hitsCalo->end()); - if (i == 0) ebHits.insert(ebHits.end(),hitsCalo->begin(),hitsCalo->end()); - else if (i == 1) eeHits.insert(eeHits.end(),hitsCalo->begin(),hitsCalo->end()); - else if (i == 3) hcHits.insert(hcHits.end(),hitsCalo->begin(),hitsCalo->end()); - LogDebug("HitStudy") << "HcalValidation: Hit buffer " - << caloHits.size(); - analyzeHits (caloHits, i); + caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end()); + if (i == 0) + ebHits.insert(ebHits.end(), hitsCalo->begin(), hitsCalo->end()); + else if (i == 1) + eeHits.insert(eeHits.end(), hitsCalo->begin(), hitsCalo->end()); + else if (i == 3) + hcHits.insert(hcHits.end(), hitsCalo->begin(), hitsCalo->end()); + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy: Hit buffer " << caloHits.size(); + analyzeHits(caloHits, i); } } - analyzeHits (ebHits, eeHits, hcHits); + analyzeHits(ebHits, eeHits, hcHits); - std::vector muonHits; + std::vector muonHits; edm::Handle hitsTrack; - for (int i=0; i<3; i++) { - e.getByToken(toks_track_[i],hitsTrack); + for (int i = 0; i < 3; i++) { + e.getByToken(toks_track_[i], hitsTrack); if (hitsTrack.isValid()) { - muonHits.insert(muonHits.end(),hitsTrack->begin(),hitsTrack->end()); - analyzeHits (hitsTrack, i+12); + muonHits.insert(muonHits.end(), hitsTrack->begin(), hitsTrack->end()); + analyzeHits(hitsTrack, i + 12); } } unsigned int nhmu = muonHits.size(); hitMu->Fill(double(nhmu)); - std::vector tkHighHits; - for (int i=0; i<6; i++) { - e.getByToken(toks_tkHigh_[i],hitsTrack); + std::vector tkHighHits; + for (int i = 0; i < 6; i++) { + e.getByToken(toks_tkHigh_[i], hitsTrack); if (hitsTrack.isValid()) { - tkHighHits.insert(tkHighHits.end(),hitsTrack->begin(),hitsTrack->end()); - analyzeHits (hitsTrack, i); + tkHighHits.insert(tkHighHits.end(), hitsTrack->begin(), hitsTrack->end()); + analyzeHits(hitsTrack, i); } } unsigned int nhtkh = tkHighHits.size(); hitHigh->Fill(double(nhtkh)); - std::vector tkLowHits; - for (int i=0; i<6; i++) { - e.getByToken(toks_tkLow_[i],hitsTrack); + std::vector tkLowHits; + for (int i = 0; i < 6; i++) { + e.getByToken(toks_tkLow_[i], hitsTrack); if (hitsTrack.isValid()) { - tkLowHits.insert(tkLowHits.end(),hitsTrack->begin(),hitsTrack->end()); - analyzeHits (hitsTrack, i+6); + tkLowHits.insert(tkLowHits.end(), hitsTrack->begin(), hitsTrack->end()); + analyzeHits(hitsTrack, i + 6); } } unsigned int nhtkl = tkLowHits.size(); hitLow->Fill(double(nhtkl)); } -void CaloSimHitStudy::analyzeHits (std::vector& hits, int indx) { - +void CaloSimHitStudy::analyzeHits(std::vector& hits, int indx) { int nHit = hits.size(); - int nHB=0, nHE=0, nHO=0, nHF=0, nEB=0, nEBAPD=0, nEBATJ=0, nEE=0, nES=0, nBad=0; - std::map hitMap; - std::vector etot(9,0), etotG(9,0); - for (int i=0; i hitMap; + std::vector etot(9, 0), etotG(9, 0); + for (int i = 0; i < nHit; i++) { + double edep = hits[i].energy(); + double time = hits[i].time(); unsigned int id_ = hits[i].id(); - double edepEM = hits[i].energyEM(); - double edepHad = hits[i].energyHad(); + double edepEM = hits[i].energyEM(); + double edepHad = hits[i].energyHad(); if (indx == 0) { - int dep = (hits[i].depth())&PCaloHit::kEcalDepthIdMask; - if (dep==1) id_ |= 0x20000; - else if (dep==2) id_ |= 0x40000; + int dep = (hits[i].depth()) & PCaloHit::kEcalDepthIdMask; + if (dep == 1) + id_ |= 0x20000; + else if (dep == 2) + id_ |= 0x40000; } - std::map::const_iterator it = hitMap.find(id_); + std::map::const_iterator it = hitMap.find(id_); if (it == hitMap.end()) { - hitMap.insert(std::pair(id_,time)); + hitMap.insert(std::pair(id_, time)); } int idx = -1; if (indx != 3) { if (indx == 0) { - if (storeRL_) idx = 0; - else idx = ((hits[i].depth())&PCaloHit::kEcalDepthIdMask); - } else idx = indx+2; + if (storeRL_) + idx = 0; + else + idx = ((hits[i].depth()) & PCaloHit::kEcalDepthIdMask); + } else + idx = indx + 2; time_[idx]->Fill(time); edep_[idx]->Fill(edep); edepEM_[idx]->Fill(edepEM); edepHad_[idx]->Fill(edepHad); - if (idx == 0) nEB++; - else if (idx == 1) nEBAPD++; - else if (idx == 2) nEBATJ++; - else if (idx == 3) nEE++; - else if (idx == 4) nES++; - else nBad++; - if (indx >=0 && indx < 3) { - etot[idx] += edep; - if (time < 100) etotG[idx] += edep; + if (idx == 0) + nEB++; + else if (idx == 1) + nEBAPD++; + else if (idx == 2) + nEBATJ++; + else if (idx == 3) + nEE++; + else if (idx == 4) + nES++; + else + nBad++; + if (indx >= 0 && indx < 3) { + etot[idx] += edep; + if (time < 100) + etotG[idx] += edep; } } else { int subdet(0); if (testNumber_) { - int ieta(0), phi(0), z(0), lay(0), depth(0); - HcalTestNumbering::unpackHcalIndex(id_,subdet,z,depth,ieta,phi,lay); + int ieta(0), phi(0), z(0), lay(0), depth(0); + HcalTestNumbering::unpackHcalIndex(id_, subdet, z, depth, ieta, phi, lay); } else { - HcalDetId id = HcalDetId(id_); - subdet = id.subdet(); + HcalDetId id = HcalDetId(id_); + subdet = id.subdet(); + } + if (subdet == static_cast(HcalBarrel)) { + idx = indx + 2; + nHB++; + } else if (subdet == static_cast(HcalEndcap)) { + idx = indx + 3; + nHE++; + } else if (subdet == static_cast(HcalOuter)) { + idx = indx + 4; + nHO++; + } else if (subdet == static_cast(HcalForward)) { + idx = indx + 5; + nHF++; } - if (subdet == static_cast(HcalBarrel)) {idx = indx+2; nHB++;} - else if (subdet == static_cast(HcalEndcap)) {idx = indx+3; nHE++;} - else if (subdet == static_cast(HcalOuter)) {idx = indx+4; nHO++;} - else if (subdet == static_cast(HcalForward)) {idx = indx+5; nHF++;} if (idx > 0) { - time_[idx]->Fill(time); - edep_[idx]->Fill(edep); - edepEM_[idx]->Fill(edepEM); - edepHad_[idx]->Fill(edepHad); - etot[idx] += edep; - if (time < 100) etotG[idx] += edep; + time_[idx]->Fill(time); + edep_[idx]->Fill(edep); + edepEM_[idx]->Fill(edepEM); + edepHad_[idx]->Fill(edepHad); + etot[idx] += edep; + if (time < 100) + etotG[idx] += edep; } else { - nBad++; + nBad++; } } } if (indx < 3) { - etot_[indx+2]->Fill(etot[indx+2]); - etotg_[indx+2]->Fill(etotG[indx+2]); + etot_[indx + 2]->Fill(etot[indx + 2]); + etotg_[indx + 2]->Fill(etotG[indx + 2]); if (indx == 0) { etot_[indx]->Fill(etot[indx]); etotg_[indx]->Fill(etotG[indx]); - etot_[indx+1]->Fill(etot[indx+1]); - etotg_[indx+1]->Fill(etotG[indx+1]); + etot_[indx + 1]->Fill(etot[indx + 1]); + etotg_[indx + 1]->Fill(etotG[indx + 1]); hit_[indx]->Fill(double(nEB)); - hit_[indx+1]->Fill(double(nEBAPD)); - hit_[indx+2]->Fill(double(nEBATJ)); + hit_[indx + 1]->Fill(double(nEBAPD)); + hit_[indx + 2]->Fill(double(nEBATJ)); } else { - hit_[indx+2]->Fill(double(nHit)); + hit_[indx + 2]->Fill(double(nHit)); } } else if (indx == 3) { hit_[5]->Fill(double(nHB)); hit_[6]->Fill(double(nHE)); hit_[7]->Fill(double(nHO)); hit_[8]->Fill(double(nHF)); - for (int idx=5; idx<9; idx++) { + for (int idx = 5; idx < 9; idx++) { etot_[idx]->Fill(etot[idx]); etotg_[idx]->Fill(etotG[idx]); } } - LogDebug("HitStudy") << "CaloSimHitStudy::analyzeHits: EB " << nEB << ", " - << nEBAPD << ", " << nEBATJ << " EE " << nEE << " ES " - << nES << " HB " << nHB << " HE " << nHE << " HO " - << nHO << " HF " << nHF << " Bad " << nBad << " All " - << nHit << " Reduced " << hitMap.size(); - std::map::const_iterator it = hitMap.begin(); - for (; it !=hitMap.end(); it++) { - double time = it->second; + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy::analyzeHits: EB " << nEB << ", " << nEBAPD << ", " << nEBATJ + << " EE " << nEE << " ES " << nES << " HB " << nHB << " HE " << nHE << " HO " << nHO + << " HF " << nHF << " Bad " << nBad << " All " << nHit << " Reduced " << hitMap.size(); + std::map::const_iterator it = hitMap.begin(); + for (; it != hitMap.end(); it++) { + double time = it->second; unsigned int id_ = (it->first); - int idx = -1; + int idx = -1; if (indx < 3) { if (indx == 0) { - if ((id_&0x20000) != 0) idx = indx+1; - else if ((id_&0x40000) != 0) idx = indx+1; - else idx = indx; + if ((id_ & 0x20000) != 0) + idx = indx + 1; + else if ((id_ & 0x40000) != 0) + idx = indx + 1; + else + idx = indx; } else { - idx = indx + 2; + idx = indx + 2; } - if (idx >= 0 && idx < 5) timeAll_[idx]->Fill(time); + if (idx >= 0 && idx < 5) + timeAll_[idx]->Fill(time); } else if (indx == 3) { int idx(-1), subdet(0); if (testNumber_) { - int ieta(0), phi(0), z(0), lay(0), depth(0); - HcalTestNumbering::unpackHcalIndex(id_,subdet,z,depth,ieta,phi,lay); + int ieta(0), phi(0), z(0), lay(0), depth(0); + HcalTestNumbering::unpackHcalIndex(id_, subdet, z, depth, ieta, phi, lay); } else { - HcalDetId id = HcalDetId(id_); - subdet = id.subdet(); + HcalDetId id = HcalDetId(id_); + subdet = id.subdet(); + } + if (subdet == static_cast(HcalBarrel)) { + idx = indx + 2; + } else if (subdet == static_cast(HcalEndcap)) { + idx = indx + 3; + } else if (subdet == static_cast(HcalOuter)) { + idx = indx + 4; + } else if (subdet == static_cast(HcalForward)) { + idx = indx + 5; } - if (subdet == static_cast(HcalBarrel)) {idx = indx+2;} - else if (subdet == static_cast(HcalEndcap)) {idx = indx+3;} - else if (subdet == static_cast(HcalOuter)) {idx = indx+4;} - else if (subdet == static_cast(HcalForward)) {idx = indx+5;} if (idx > 0) { - timeAll_[idx]->Fill(time); + timeAll_[idx]->Fill(time); } } } - } -void CaloSimHitStudy::analyzeHits (edm::Handle& hits, - int indx) { - +void CaloSimHitStudy::analyzeHits(edm::Handle& hits, int indx) { int nHit = 0; edm::PSimHitContainer::const_iterator ihit; std::string label(" "); - if (indx >= 0 && indx < 6) label = tkHighLab[indx]; - else if (indx >= 6 && indx <12) label = tkLowLab[indx-6]; - else if (indx >=12 && indx <15) label = muonLab[indx-12]; - for (ihit=hits->begin(); ihit!=hits->end(); ihit++) { + if (indx >= 0 && indx < 6) + label = tkHighLab[indx]; + else if (indx >= 6 && indx < 12) + label = tkLowLab[indx - 6]; + else if (indx >= 12 && indx < 15) + label = muonLab[indx - 12]; + for (ihit = hits->begin(); ihit != hits->end(); ihit++) { edepTk_[indx]->Fill(ihit->energyLoss()); tofTk_[indx]->Fill(ihit->timeOfFlight()); nHit++; } hitTk_[indx]->Fill(float(nHit)); - LogDebug("HitStudy") << "CaloSimHitStudy::analyzeHits: for " << label - << " Index " << indx << " # of Hits " << nHit; + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy::analyzeHits: for " << label << " Index " << indx << " # of Hits " + << nHit; } -void CaloSimHitStudy::analyzeHits (std::vector& ebHits, - std::vector& eeHits, - std::vector& hcHits) { - - double edepEB=0, edepEBT = 0; - for (unsigned int i=0; i& ebHits, + std::vector& eeHits, + std::vector& hcHits) { + double edepEB = 0, edepEBT = 0; + for (unsigned int i = 0; i < ebHits.size(); i++) { + double edep = ebHits[i].energy(); + double time = ebHits[i].time(); + if (((ebHits[i].depth()) & PCaloHit::kEcalDepthIdMask) == 0) { edepEB += edep; - if (time < tmax_) edepEBT += edep; + if (time < tmax_) + edepEBT += edep; } } - double edepEE=0, edepEET = 0; - for (unsigned int i=0; i(HcalBarrel) || - subdet == static_cast(HcalEndcap)) { + if (subdet == static_cast(HcalBarrel) || subdet == static_cast(HcalEndcap)) { edepH += edep; - if (time < tmax_) edepHT += edep; + if (time < tmax_) + edepHT += edep; } else if (subdet == static_cast(HcalOuter)) { edepHO += edep; - if (time < tmax_) edepHOT += edep; + if (time < tmax_) + edepHOT += edep; } } - double edepE = edepEB+edepEE; - double edepET = edepEBT+edepEET; - double edepHC = edepH+edepHO; - double edepHCT= edepHT+edepHOT; - LogDebug("HitStudy") << "CaloSimHitStudy::energy in EB " << edepEB << " (" - << edepEBT << ") from " << ebHits.size() << " hits; " - << " energy in EE " << edepEE << " (" << edepEET - << ") from " << eeHits.size() << " hits; energy in HC " - << edepH << ", " << edepHO << " (" << edepHT << ", " - << edepHOT <<") from " << hcHits.size() << " hits"; - - edepC_[6]->Fill(edepE); edepT_[6]->Fill(edepET); - edepC_[7]->Fill(edepH); edepT_[7]->Fill(edepHT); - edepC_[8]->Fill(edepHC); edepT_[8]->Fill(edepHCT); + double edepE = edepEB + edepEE; + double edepET = edepEBT + edepEET; + double edepHC = edepH + edepHO; + double edepHCT = edepHT + edepHOT; + edm::LogVerbatim("HitStudy") << "CaloSimHitStudy::energy in EB " << edepEB << " (" << edepEBT << ") from " + << ebHits.size() << " hits; " + << " energy in EE " << edepEE << " (" << edepEET << ") from " << eeHits.size() + << " hits; energy in HC " << edepH << ", " << edepHO << " (" << edepHT << ", " << edepHOT + << ") from " << hcHits.size() << " hits"; + + edepC_[6]->Fill(edepE); + edepT_[6]->Fill(edepET); + edepC_[7]->Fill(edepH); + edepT_[7]->Fill(edepHT); + edepC_[8]->Fill(edepHC); + edepT_[8]->Fill(edepHCT); if (edepE < eMIP_) { - edepC_[0]->Fill(edepE); edepC_[1]->Fill(edepH); edepC_[2]->Fill(edepHC); + edepC_[0]->Fill(edepE); + edepC_[1]->Fill(edepH); + edepC_[2]->Fill(edepHC); } else { - edepC_[3]->Fill(edepE); edepC_[4]->Fill(edepH); edepC_[5]->Fill(edepHC); + edepC_[3]->Fill(edepE); + edepC_[4]->Fill(edepH); + edepC_[5]->Fill(edepHC); } if (edepET < eMIP_) { - edepT_[0]->Fill(edepET); edepT_[1]->Fill(edepHT); edepT_[2]->Fill(edepHCT); + edepT_[0]->Fill(edepET); + edepT_[1]->Fill(edepHT); + edepT_[2]->Fill(edepHCT); } else { - edepT_[3]->Fill(edepET); edepT_[4]->Fill(edepHT); edepT_[5]->Fill(edepHCT); + edepT_[3]->Fill(edepET); + edepT_[4]->Fill(edepHT); + edepT_[5]->Fill(edepHCT); } } diff --git a/SimG4CMS/Calo/test/EcalSimHitStudy.cc b/SimG4CMS/Calo/test/EcalSimHitStudy.cc index bfb2a87af3755..833d5ebc8d972 100644 --- a/SimG4CMS/Calo/test/EcalSimHitStudy.cc +++ b/SimG4CMS/Calo/test/EcalSimHitStudy.cc @@ -42,273 +42,264 @@ //#define EDM_ML_DEBUG -class EcalSimHitStudy: public edm::one::EDAnalyzer { - +class EcalSimHitStudy : public edm::one::EDAnalyzer { public: - EcalSimHitStudy(const edm::ParameterSet& ps); ~EcalSimHitStudy() override {} static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); protected: - void beginJob() override; void analyze(edm::Event const&, edm::EventSetup const&) override; void beginRun(edm::Run const&, edm::EventSetup const&) override {} void endRun(edm::Run const&, edm::EventSetup const&) override {} - void analyzeHits (std::vector &, int); + void analyzeHits(std::vector&, int); private: - struct EcalHit { uint16_t id; - double time, energy; - EcalHit(uint16_t i=0, double t=0, double e=0) : id(i), time(t), - energy(e) {} + double time, energy; + EcalHit(uint16_t i = 0, double t = 0, double e = 0) : id(i), time(t), energy(e) {} }; - static const int ndets_ = 2; - std::string g4Label_, hitLab_[ndets_]; - edm::EDGetTokenT tok_evt_; + static const int ndets_ = 2; + std::string g4Label_, hitLab_[ndets_]; + edm::EDGetTokenT tok_evt_; edm::EDGetTokenT toks_calo_[2]; - double maxEnergy_, tmax_, w0_; - int selX_; - const CaloGeometry *geometry_; - TH1F *ptInc_, *etaInc_, *phiInc_, *eneInc_; - TH1F *hit_[ndets_], *time_[ndets_], *timeAll_[ndets_]; - TH1F *edepEM_[ndets_], *edepHad_[ndets_], *edep_[ndets_]; - TH1F *etot_[ndets_], *etotg_[ndets_], *edepAll_[ndets_]; - TH1F *r1by9_[ndets_], *r1by25_[ndets_], *r9by25_[ndets_]; - TH1F *sEtaEta_[ndets_], *sEtaPhi_[ndets_], *sPhiPhi_[ndets_]; + double maxEnergy_, tmax_, w0_; + int selX_; + const CaloGeometry* geometry_; + TH1F *ptInc_, *etaInc_, *phiInc_, *eneInc_; + TH1F *hit_[ndets_], *time_[ndets_], *timeAll_[ndets_]; + TH1F *edepEM_[ndets_], *edepHad_[ndets_], *edep_[ndets_]; + TH1F *etot_[ndets_], *etotg_[ndets_], *edepAll_[ndets_]; + TH1F *r1by9_[ndets_], *r1by25_[ndets_], *r9by25_[ndets_]; + TH1F *sEtaEta_[ndets_], *sEtaPhi_[ndets_], *sPhiPhi_[ndets_]; }; - EcalSimHitStudy::EcalSimHitStudy(const edm::ParameterSet& ps) { - usesResource(TFileService::kSharedResource); - g4Label_ = ps.getUntrackedParameter("ModuleLabel","g4SimHits"); - hitLab_[0]= ps.getUntrackedParameter("EBCollection","EcalHitsEB"); - hitLab_[1]= ps.getUntrackedParameter("EECollection","EcalHitsEE"); - tok_evt_ = consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel","VtxSmeared"))); - maxEnergy_= ps.getUntrackedParameter("MaxEnergy", 200.0); - tmax_ = ps.getUntrackedParameter("TimeCut", 100.0); - w0_ = ps.getUntrackedParameter("W0", 4.7); - selX_ = ps.getUntrackedParameter("SelectX",-1); - - for (int i=0; i(edm::InputTag(g4Label_,hitLab_[i])); - - edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " Hits: " - << hitLab_[0] << ", " << hitLab_[1] - << " MaxEnergy: " << maxEnergy_ << " Tmax: " - << tmax_ << " Select " << selX_; + g4Label_ = ps.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hitLab_[0] = ps.getUntrackedParameter("EBCollection", "EcalHitsEB"); + hitLab_[1] = ps.getUntrackedParameter("EECollection", "EcalHitsEE"); + tok_evt_ = + consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel", "VtxSmeared"))); + maxEnergy_ = ps.getUntrackedParameter("MaxEnergy", 200.0); + tmax_ = ps.getUntrackedParameter("TimeCut", 100.0); + w0_ = ps.getUntrackedParameter("W0", 4.7); + selX_ = ps.getUntrackedParameter("SelectX", -1); + + for (int i = 0; i < ndets_; ++i) + toks_calo_[i] = consumes(edm::InputTag(g4Label_, hitLab_[i])); + + edm::LogVerbatim("HitStudy") << "Module Label: " << g4Label_ << " Hits: " << hitLab_[0] << ", " << hitLab_[1] + << " MaxEnergy: " << maxEnergy_ << " Tmax: " << tmax_ << " Select " << selX_; } -void EcalSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - +void EcalSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.addUntracked("ModuleLabel","g4SimHits"); - desc.addUntracked("EBCollection","EcalHitsEB"); - desc.addUntracked("EECollection","EcalHitsEE"); - desc.addUntracked("SourceLabel","VtxSmeared"); + desc.addUntracked("ModuleLabel", "g4SimHits"); + desc.addUntracked("EBCollection", "EcalHitsEB"); + desc.addUntracked("EECollection", "EcalHitsEE"); + desc.addUntracked("SourceLabel", "VtxSmeared"); desc.addUntracked("MaxEnergy", 200.0); desc.addUntracked("TimeCut", 100.0); - desc.addUntracked("SelectX",-1); - descriptions.add("EcalSimHitStudy",desc); + desc.addUntracked("SelectX", -1); + descriptions.add("EcalSimHitStudy", desc); } void EcalSimHitStudy::beginJob() { - edm::Service tfile; - if ( !tfile.isAvailable() ) + if (!tfile.isAvailable()) throw cms::Exception("BadConfig") << "TFileService unavailable: " << "please add it to config file"; - char name[20], title[120]; - sprintf (title, "Incident PT (GeV)"); + char name[20], title[120]; + sprintf(title, "Incident PT (GeV)"); ptInc_ = tfile->make("PtInc", title, 1000, 0., maxEnergy_); - ptInc_->GetXaxis()-> SetTitle(title); + ptInc_->GetXaxis()->SetTitle(title); ptInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident Energy (GeV)"); + sprintf(title, "Incident Energy (GeV)"); eneInc_ = tfile->make("EneInc", title, 1000, 0., maxEnergy_); - eneInc_->GetXaxis()-> SetTitle(title); + eneInc_->GetXaxis()->SetTitle(title); eneInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #eta"); + sprintf(title, "Incident #eta"); etaInc_ = tfile->make("EtaInc", title, 200, -5., 5.); etaInc_->GetXaxis()->SetTitle(title); etaInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #phi"); + sprintf(title, "Incident #phi"); phiInc_ = tfile->make("PhiInc", title, 200, -3.1415926, 3.1415926); phiInc_->GetXaxis()->SetTitle(title); phiInc_->GetYaxis()->SetTitle("Events"); std::string dets[ndets_] = {"EB", "EE"}; - for (int i=0; imake(name, title, 1000, 0., 20000.); - hit_[i]->GetXaxis()->SetTitle(title); + for (int i = 0; i < ndets_; i++) { + sprintf(name, "Hit%d", i); + sprintf(title, "Number of hits in %s", dets[i].c_str()); + hit_[i] = tfile->make(name, title, 1000, 0., 20000.); + hit_[i]->GetXaxis()->SetTitle(title); hit_[i]->GetYaxis()->SetTitle("Events"); hit_[i]->Sumw2(); - sprintf (name, "Time%d", i); - sprintf (title, "Time of the hit (ns) in %s", dets[i].c_str()); - time_[i] = tfile->make(name, title, 1000, 0., 1000.); - time_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Time%d", i); + sprintf(title, "Time of the hit (ns) in %s", dets[i].c_str()); + time_[i] = tfile->make(name, title, 1000, 0., 1000.); + time_[i]->GetXaxis()->SetTitle(title); time_[i]->GetYaxis()->SetTitle("Hits"); time_[i]->Sumw2(); - sprintf (name, "TimeAll%d", i); - sprintf (title, "Hit time (ns) in %s (for first hit in the cell)", dets[i].c_str()); - timeAll_[i] = tfile->make(name, title, 1000, 0., 1000.); - timeAll_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "TimeAll%d", i); + sprintf(title, "Hit time (ns) in %s (for first hit in the cell)", dets[i].c_str()); + timeAll_[i] = tfile->make(name, title, 1000, 0., 1000.); + timeAll_[i]->GetXaxis()->SetTitle(title); timeAll_[i]->GetYaxis()->SetTitle("Hits"); timeAll_[i]->Sumw2(); - sprintf (name, "Edep%d", i); - sprintf (title, "Energy deposit (GeV) in %s", dets[i].c_str()); - edep_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - edep_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Edep%d", i); + sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str()); + edep_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + edep_[i]->GetXaxis()->SetTitle(title); edep_[i]->GetYaxis()->SetTitle("Hits"); edep_[i]->Sumw2(); - sprintf (name, "EdepAll%d", i); - sprintf (title, "Total Energy deposit in the cell (GeV) in %s", dets[i].c_str()); - edepAll_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - edepAll_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepAll%d", i); + sprintf(title, "Total Energy deposit in the cell (GeV) in %s", dets[i].c_str()); + edepAll_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + edepAll_[i]->GetXaxis()->SetTitle(title); edepAll_[i]->GetYaxis()->SetTitle("Hits"); edepAll_[i]->Sumw2(); - sprintf (name, "EdepEM%d", i); - sprintf (title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str()); - edepEM_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - edepEM_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepEM%d", i); + sprintf(title, "Energy deposit (GeV) by EM particles in %s", dets[i].c_str()); + edepEM_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + edepEM_[i]->GetXaxis()->SetTitle(title); edepEM_[i]->GetYaxis()->SetTitle("Hits"); edepEM_[i]->Sumw2(); - sprintf (name, "EdepHad%d", i); - sprintf (title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str()); - edepHad_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - edepHad_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepHad%d", i); + sprintf(title, "Energy deposit (GeV) by hadrons in %s", dets[i].c_str()); + edepHad_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + edepHad_[i]->GetXaxis()->SetTitle(title); edepHad_[i]->GetYaxis()->SetTitle("Hits"); edepHad_[i]->Sumw2(); - sprintf (name, "Etot%d", i); - sprintf (title, "Total energy deposit (GeV) in %s", dets[i].c_str()); - etot_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - etot_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Etot%d", i); + sprintf(title, "Total energy deposit (GeV) in %s", dets[i].c_str()); + etot_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + etot_[i]->GetXaxis()->SetTitle(title); etot_[i]->GetYaxis()->SetTitle("Events"); etot_[i]->Sumw2(); - sprintf (name, "EtotG%d", i); - sprintf (title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str()); - etotg_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); - etotg_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EtotG%d", i); + sprintf(title, "Total energy deposit (GeV) in %s (t < 100 ns)", dets[i].c_str()); + etotg_[i] = tfile->make(name, title, 5000, 0., maxEnergy_); + etotg_[i]->GetXaxis()->SetTitle(title); etotg_[i]->GetYaxis()->SetTitle("Events"); etotg_[i]->Sumw2(); - sprintf (name, "r1by9%d", i); - sprintf (title, "E1/E9 in %s", dets[i].c_str()); - r1by9_[i] = tfile->make(name, title, 100, 0.0, 1.0); - r1by9_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "r1by9%d", i); + sprintf(title, "E1/E9 in %s", dets[i].c_str()); + r1by9_[i] = tfile->make(name, title, 100, 0.0, 1.0); + r1by9_[i]->GetXaxis()->SetTitle(title); r1by9_[i]->GetYaxis()->SetTitle("Events"); r1by9_[i]->Sumw2(); - sprintf (name, "r1by25%d", i); - sprintf (title, "E1/E25 in %s", dets[i].c_str()); - r1by25_[i] = tfile->make(name, title, 100, 0.0, 1.0); - r1by25_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "r1by25%d", i); + sprintf(title, "E1/E25 in %s", dets[i].c_str()); + r1by25_[i] = tfile->make(name, title, 100, 0.0, 1.0); + r1by25_[i]->GetXaxis()->SetTitle(title); r1by25_[i]->GetYaxis()->SetTitle("Events"); r1by25_[i]->Sumw2(); - sprintf (name, "r9by25%d", i); - sprintf (title, "E9/E25 in %s", dets[i].c_str()); - r9by25_[i] = tfile->make(name, title, 100, 0.0, 1.0); - r9by25_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "r9by25%d", i); + sprintf(title, "E9/E25 in %s", dets[i].c_str()); + r9by25_[i] = tfile->make(name, title, 100, 0.0, 1.0); + r9by25_[i]->GetXaxis()->SetTitle(title); r9by25_[i]->GetYaxis()->SetTitle("Events"); r9by25_[i]->Sumw2(); double ymax = (i == 0) ? 0.0005 : 0.005; - sprintf (name, "sEtaEta%d", i); - sprintf (title, "Cov(#eta,#eta) in %s", dets[i].c_str()); - sEtaEta_[i] = tfile->make(name, title, 1000, 0.0, ymax); - sEtaEta_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "sEtaEta%d", i); + sprintf(title, "Cov(#eta,#eta) in %s", dets[i].c_str()); + sEtaEta_[i] = tfile->make(name, title, 1000, 0.0, ymax); + sEtaEta_[i]->GetXaxis()->SetTitle(title); sEtaEta_[i]->GetYaxis()->SetTitle("Events"); sEtaEta_[i]->Sumw2(); - sprintf (name, "sEtaPhi%d", i); - sprintf (title, "Cov(#eta,#phi) in %s", dets[i].c_str()); - sEtaPhi_[i] = tfile->make(name, title, 1000, 0.0, ymax); - sEtaPhi_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "sEtaPhi%d", i); + sprintf(title, "Cov(#eta,#phi) in %s", dets[i].c_str()); + sEtaPhi_[i] = tfile->make(name, title, 1000, 0.0, ymax); + sEtaPhi_[i]->GetXaxis()->SetTitle(title); sEtaPhi_[i]->GetYaxis()->SetTitle("Events"); sEtaPhi_[i]->Sumw2(); ymax = (i == 0) ? 0.001 : 0.01; - sprintf (name, "sPhiPhi%d", i); - sprintf (title, "Cov(#phi,#phi) in %s", dets[i].c_str()); - sPhiPhi_[i] = tfile->make(name, title, 1000, 0.0, ymax); - sPhiPhi_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "sPhiPhi%d", i); + sprintf(title, "Cov(#phi,#phi) in %s", dets[i].c_str()); + sPhiPhi_[i] = tfile->make(name, title, 1000, 0.0, ymax); + sPhiPhi_[i]->GetXaxis()->SetTitle(title); sPhiPhi_[i]->GetYaxis()->SetTitle("Events"); sPhiPhi_[i]->Sumw2(); } } void EcalSimHitStudy::analyze(const edm::Event& e, const edm::EventSetup& iS) { - #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HitStudy") << "Run = " << e.id().run() << " Event = " - << e.id().event(); + edm::LogVerbatim("HitStudy") << "Run = " << e.id().run() << " Event = " << e.id().event(); #endif // get handles to calogeometry edm::ESHandle pG; iS.get().get(pG); geometry_ = pG.product(); - edm::Handle EvtHandle; + edm::Handle EvtHandle; e.getByToken(tok_evt_, EvtHandle); - const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); + const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); - double eInc=0, etaInc=0, phiInc=0; - HepMC::GenEvent::particle_const_iterator p=myGenEvent->particles_begin(); + double eInc = 0, etaInc = 0, phiInc = 0; + HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); if (p != myGenEvent->particles_end()) { - eInc = (*p)->momentum().e(); + eInc = (*p)->momentum().e(); etaInc = (*p)->momentum().eta(); phiInc = (*p)->momentum().phi(); } - double ptInc = eInc/std::cosh(etaInc); + double ptInc = eInc / std::cosh(etaInc); ptInc_->Fill(ptInc); eneInc_->Fill(eInc); etaInc_->Fill(etaInc); phiInc_->Fill(phiInc); int type(-1); - if (std::abs(etaInc) < 1.46) type = 0; - else if (std::abs(etaInc) > 1.49 && std::abs(etaInc) < 3.0) type = 1; + if (std::abs(etaInc) < 1.46) + type = 0; + else if (std::abs(etaInc) > 1.49 && std::abs(etaInc) < 3.0) + type = 1; if (type >= 0) { bool getHits(false); edm::Handle hitsCalo; - e.getByToken(toks_calo_[type],hitsCalo); - if (hitsCalo.isValid()) getHits = true; + e.getByToken(toks_calo_[type], hitsCalo); + if (hitsCalo.isValid()) + getHits = true; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HitStudy") << "EcalSimHitStudy: Input flags Hits " - << getHits << " with " << hitsCalo->size() - << " hits"; + edm::LogVerbatim("HitStudy") << "EcalSimHitStudy: Input flags Hits " << getHits << " with " << hitsCalo->size() + << " hits"; #endif if (getHits) { std::vector caloHits; - caloHits.insert(caloHits.end(),hitsCalo->begin(),hitsCalo->end()); - if (!caloHits.empty()) analyzeHits (caloHits, type); + caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end()); + if (!caloHits.empty()) + analyzeHits(caloHits, type); } } } -void EcalSimHitStudy::analyzeHits (std::vector& hits, int indx) { - +void EcalSimHitStudy::analyzeHits(std::vector& hits, int indx) { unsigned int nEC(0); - std::map hitMap; - double etot(0), etotG(0); + std::map hitMap; + double etot(0), etotG(0); for (auto hit : hits) { - double edep = hit.energy(); - double time = hit.time(); + double edep = hit.energy(); + double time = hit.time(); unsigned int id_ = hit.id(); - double edepEM = hit.energyEM(); - double edepHad = hit.energyHad(); + double edepEM = hit.energyEM(); + double edepHad = hit.energyHad(); if (indx == 0) { - if ((hit.depth()==1) || (hit.depth()==2)) continue; + if ((hit.depth() == 1) || (hit.depth() == 2)) + continue; } if (time <= tmax_) { auto it = hitMap.find(id_); if (it == hitMap.end()) { - uint16_t dep = hit.depth(); - hitMap[id_] = EcalHit(dep,time,edep); + uint16_t dep = hit.depth(); + hitMap[id_] = EcalHit(dep, time, edep); } else { - (it->second).energy += edep; + (it->second).energy += edep; } - etotG += edep; + etotG += edep; ++nEC; } time_[indx]->Fill(time); @@ -317,31 +308,30 @@ void EcalSimHitStudy::analyzeHits (std::vector& hits, int indx) { edepHad_[indx]->Fill(edepHad); etot += edep; } - - double edepM(0); + + double edepM(0); unsigned int idM(0); - uint16_t depM(0); + uint16_t depM(0); for (auto it : hitMap) { if (it.second.energy > edepM) { - idM = it.first; + idM = it.first; edepM = it.second.energy; - depM = it.second.id; + depM = it.second.id; } } - + bool select(true); if (selX_ >= 0) { - if ((depM & 0X4) != 0) select = (selX_ > 0); - else select = (selX_ == 0); + if ((depM & 0X4) != 0) + select = (selX_ > 0); + else + select = (selX_ == 0); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HitStudy") << "EcalSimHitStudy::analyzeHits: Index " - << indx << " Emax " << edepM << " IDMax " - << std::hex << idM << ":" << depM << std::dec - << " Select " << select << ":" << selX_ - << " Hits " << hits.size() << ":" << nEC << ":" - << hitMap.size() << " ETotal " << etot << ":" - << etotG; + edm::LogVerbatim("HitStudy") << "EcalSimHitStudy::analyzeHits: Index " << indx << " Emax " << edepM << " IDMax " + << std::hex << idM << ":" << depM << std::dec << " Select " << select << ":" << selX_ + << " Hits " << hits.size() << ":" << nEC << ":" << hitMap.size() << " ETotal " << etot + << ":" << etotG; #endif if (select) { etot_[indx]->Fill(etot); @@ -352,53 +342,59 @@ void EcalSimHitStudy::analyzeHits (std::vector& hits, int indx) { edepAll_[indx]->Fill((it.second).energy); } - math::XYZVector meanPosition(0.0, 0.0, 0.0); + math::XYZVector meanPosition(0.0, 0.0, 0.0); std::vector position; - std::vector energy; - double e9(0), e25(0); + std::vector energy; + double e9(0), e25(0); for (auto it : hitMap) { DetId id(it.first); - int deta(99), dphi(99), dz(0); + int deta(99), dphi(99), dz(0); if (indx == 0) { - deta = std::abs(EBDetId(id).ietaAbs()-EBDetId(idM).ietaAbs()); - dphi = std::abs(EBDetId(id).iphi()-EBDetId(idM).iphi()); - if (dphi > 180) dphi = std::abs(dphi-360); - dz = std::abs(EBDetId(id).zside()-EBDetId(idM).zside()); + deta = std::abs(EBDetId(id).ietaAbs() - EBDetId(idM).ietaAbs()); + dphi = std::abs(EBDetId(id).iphi() - EBDetId(idM).iphi()); + if (dphi > 180) + dphi = std::abs(dphi - 360); + dz = std::abs(EBDetId(id).zside() - EBDetId(idM).zside()); } else { - deta = std::abs(EEDetId(id).ix()-EEDetId(idM).ix()); - dphi = std::abs(EEDetId(id).iy()-EEDetId(idM).iy()); - dz = std::abs(EEDetId(id).zside()-EEDetId(idM).zside()); + deta = std::abs(EEDetId(id).ix() - EEDetId(idM).ix()); + dphi = std::abs(EEDetId(id).iy() - EEDetId(idM).iy()); + dz = std::abs(EEDetId(id).zside() - EEDetId(idM).zside()); } - if (deta <= 1 && dphi <= 1 && dz < 1) e9 += (it.second).energy; + if (deta <= 1 && dphi <= 1 && dz < 1) + e9 += (it.second).energy; if (deta <= 2 && dphi <= 2 && dz < 1) { - e25 += (it.second).energy; - GlobalPoint gpos = geometry_->getGeometry(id)->getPosition(); - math::XYZVector pos(gpos.x(),gpos.y(),gpos.z()); - meanPosition += (it.second).energy * pos; - position.push_back(pos); energy.push_back((it.second).energy); + e25 += (it.second).energy; + GlobalPoint gpos = geometry_->getGeometry(id)->getPosition(); + math::XYZVector pos(gpos.x(), gpos.y(), gpos.z()); + meanPosition += (it.second).energy * pos; + position.push_back(pos); + energy.push_back((it.second).energy); } } - double r1by9 = (e9 > 0) ? (edepM/e9) : -1; - double r1by25 = (e25 > 0) ? (edepM/e25) : -1; - double r9by25 = (e25 > 0) ? (e9/e25) : -1; + double r1by9 = (e9 > 0) ? (edepM / e9) : -1; + double r1by25 = (e25 > 0) ? (edepM / e25) : -1; + double r9by25 = (e25 > 0) ? (e9 / e25) : -1; meanPosition /= e25; double denom(0), numEtaEta(0), numEtaPhi(0), numPhiPhi(0); - for (unsigned int k=0; k +M_PI) { dPhi = 2*M_PI - dPhi; } - if (dPhi < -M_PI) { dPhi = 2*M_PI + dPhi; } + if (dPhi > +M_PI) { + dPhi = 2 * M_PI - dPhi; + } + if (dPhi < -M_PI) { + dPhi = 2 * M_PI + dPhi; + } - double w = std::max(0.0,(w0_+std::log(energy[k]/e25))); - denom += w; + double w = std::max(0.0, (w0_ + std::log(energy[k] / e25))); + denom += w; numEtaEta += std::abs(w * dEta * dEta); numEtaPhi += std::abs(w * dEta * dPhi); numPhiPhi += std::abs(w * dPhi * dPhi); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HitStudy") << "[" << k << "] dEta " << dEta <<" dPhi " - << dPhi << " Wt " << energy[k]/e25 << ":" - << std::log(energy[k]/e25) << ":" << w; + edm::LogVerbatim("HitStudy") << "[" << k << "] dEta " << dEta << " dPhi " << dPhi << " Wt " << energy[k] / e25 + << ":" << std::log(energy[k] / e25) << ":" << w; #endif } double sEtaEta = (denom > 0) ? (numEtaEta / denom) : -1.0; @@ -406,17 +402,17 @@ void EcalSimHitStudy::analyzeHits (std::vector& hits, int indx) { double sPhiPhi = (denom > 0) ? (numPhiPhi / denom) : -1.0; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HitStudy") << "EcalSimHitStudy::Ratios " << r1by9 - << " : " << r1by25 << " : " << r9by25 - << " Covariances " << sEtaEta << " : " - << sEtaPhi << " : " << sPhiPhi; + edm::LogVerbatim("HitStudy") << "EcalSimHitStudy::Ratios " << r1by9 << " : " << r1by25 << " : " << r9by25 + << " Covariances " << sEtaEta << " : " << sEtaPhi << " : " << sPhiPhi; #endif - r1by9_[indx]->Fill(r1by9); r1by25_[indx]->Fill(r1by25); - r9by25_[indx]->Fill(r9by25); sEtaEta_[indx]->Fill(sEtaEta); - sEtaPhi_[indx]->Fill(sEtaPhi); sPhiPhi_[indx]->Fill(sPhiPhi); + r1by9_[indx]->Fill(r1by9); + r1by25_[indx]->Fill(r1by25); + r9by25_[indx]->Fill(r9by25); + sEtaEta_[indx]->Fill(sEtaEta); + sEtaPhi_[indx]->Fill(sEtaPhi); + sPhiPhi_[indx]->Fill(sPhiPhi); } } //define this as a plug-in DEFINE_FWK_MODULE(EcalSimHitStudy); - diff --git a/SimG4CMS/Calo/test/HFPMTHitAnalyzer.cc b/SimG4CMS/Calo/test/HFPMTHitAnalyzer.cc index 3d684924bdcb0..8c98d9bf2726f 100644 --- a/SimG4CMS/Calo/test/HFPMTHitAnalyzer.cc +++ b/SimG4CMS/Calo/test/HFPMTHitAnalyzer.cc @@ -18,7 +18,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" #include "FWCore/Utilities/interface/Exception.h" @@ -32,21 +32,19 @@ #include "TH1F.h" #include "TProfile.h" -class HFPMTHitAnalyzer : public edm::one::EDAnalyzer { - +class HFPMTHitAnalyzer : public edm::one::EDAnalyzer { public: - explicit HFPMTHitAnalyzer(const edm::ParameterSet&); + explicit HFPMTHitAnalyzer(const edm::ParameterSet &); ~HFPMTHitAnalyzer() override {} - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); private: - void beginJob() override; - void beginRun(edm::Run const&, edm::EventSetup const&) override {} - void analyze(const edm::Event&, const edm::EventSetup&) override; + void beginRun(edm::Run const &, edm::EventSetup const &) override {} + void analyze(const edm::Event &, const edm::EventSetup &) override; void endJob() override; - void endRun(edm::Run const&, edm::EventSetup const&) override {} - void analyzeHits (std::vector &,const std::vector &); + void endRun(edm::Run const &, edm::EventSetup const &) override {} + void analyzeHits(std::vector &, const std::vector &); //user parameters std::string g4Label, hcalHits; @@ -59,245 +57,260 @@ class HFPMTHitAnalyzer : public edm::one::EDAnalyzer(edm::InputTag(iConfig.getUntrackedParameter("SourceLabel","VtxSmeared"))); - g4Label = iConfig.getUntrackedParameter("ModuleLabel","g4SimHits"); - hcalHits = iConfig.getUntrackedParameter("HitCollection","HcalHits"); + tok_evt_ = consumes( + edm::InputTag(iConfig.getUntrackedParameter("SourceLabel", "VtxSmeared"))); + g4Label = iConfig.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hcalHits = iConfig.getUntrackedParameter("HitCollection", "HcalHits"); - tok_calo_ = consumes(edm::InputTag(g4Label,hcalHits)); + tok_calo_ = consumes(edm::InputTag(g4Label, hcalHits)); tok_track_ = consumes(edm::InputTag(g4Label)); } -void HFPMTHitAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - +void HFPMTHitAnalyzer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.addUntracked("SourceLabel","generatorSmeared"); - desc.addUntracked("ModuleLabel","g4SimHits"); - desc.addUntracked("HitCollection","HcalHits"); - descriptions.add("HFPMTHitAnalyzer",desc); + desc.addUntracked("SourceLabel", "generatorSmeared"); + desc.addUntracked("ModuleLabel", "g4SimHits"); + desc.addUntracked("HitCollection", "HcalHits"); + descriptions.add("HFPMTHitAnalyzer", desc); } void HFPMTHitAnalyzer::beginJob() { - event_no = 0; char name[20], title[120], sub[11]; edm::Service fs; - if ( !fs.isAvailable() ) + if (!fs.isAvailable()) throw cms::Exception("BadConfig") << "TFileService unavailable: " << "please add it to config file"; TFileDirectory HFHitsDir = fs->mkdir("HFPMTHits"); h_HFDepHit = HFHitsDir.make("Hit20", "Depths in HF", 50, 0., 50.); h_HFDepHit->GetXaxis()->SetTitle("Depths in HF"); - for (int i=0; i<3; i++) { - if (i == 0) sprintf (sub, "(PMT)"); - else if (i == 1) sprintf (sub, "(Bundle)"); - else sprintf (sub, "(Jungle)"); - sprintf (name,"Eta%d",i); sprintf (title,"Eta Index of hits in %s",sub); - h_HFEta[i] = HFHitsDir.make(name,title,100,0,100.); + for (int i = 0; i < 3; i++) { + if (i == 0) + sprintf(sub, "(PMT)"); + else if (i == 1) + sprintf(sub, "(Bundle)"); + else + sprintf(sub, "(Jungle)"); + sprintf(name, "Eta%d", i); + sprintf(title, "Eta Index of hits in %s", sub); + h_HFEta[i] = HFHitsDir.make(name, title, 100, 0, 100.); h_HFEta[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Phi%d",i); sprintf (title,"Phi Index of hits in %s",sub); - h_HFPhi[i] = HFHitsDir.make(name,title,100,0,100.); + sprintf(name, "Phi%d", i); + sprintf(title, "Phi Index of hits in %s", sub); + h_HFPhi[i] = HFHitsDir.make(name, title, 100, 0, 100.); h_HFPhi[i]->GetXaxis()->SetTitle(title); } TFileDirectory HFSourcePart = fs->mkdir("HFMCinfo"); - hHF_MC_e = HFSourcePart.make("MCEnergy","Energy of Generated Particle",1000,0.,500.); + hHF_MC_e = HFSourcePart.make("MCEnergy", "Energy of Generated Particle", 1000, 0., 500.); hHF_MC_e->GetXaxis()->SetTitle("Energy of Generated Particle"); //energy Histograms - TFileDirectory HFPCaloHitEnergyDir = fs->mkdir("HFPCaloHitEnergy"); - for (int i=0; i<3; i++) { - if (i == 0) sprintf (sub, "(Absorber)"); - else if (i == 1) sprintf (sub, "(PMT)"); - else sprintf (sub, "(All)"); - sprintf (name,"Energy1%d",i); sprintf (title,"Energy in depth 1 %s",sub); - hHF_e_1[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + TFileDirectory HFPCaloHitEnergyDir = fs->mkdir("HFPCaloHitEnergy"); + for (int i = 0; i < 3; i++) { + if (i == 0) + sprintf(sub, "(Absorber)"); + else if (i == 1) + sprintf(sub, "(PMT)"); + else + sprintf(sub, "(All)"); + sprintf(name, "Energy1%d", i); + sprintf(title, "Energy in depth 1 %s", sub); + hHF_e_1[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_e_1[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Energy2%d",i); sprintf (title,"Energy in depth 2 %s",sub); - hHF_e_2[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + sprintf(name, "Energy2%d", i); + sprintf(title, "Energy in depth 2 %s", sub); + hHF_e_2[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_e_2[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Energy12%d",i); sprintf (title,"Energy in depths 1,2 %s",sub); - hHF_e_12[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + sprintf(name, "Energy12%d", i); + sprintf(title, "Energy in depths 1,2 %s", sub); + hHF_e_12[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_e_12[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Em1%d",i); sprintf (title,"EM energy in depth 1 %s",sub); - hHF_em_1[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + sprintf(name, "Em1%d", i); + sprintf(title, "EM energy in depth 1 %s", sub); + hHF_em_1[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_em_1[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Em2%d",i); sprintf (title,"EM energy in depth 2 %s",sub); - hHF_em_2[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + sprintf(name, "Em2%d", i); + sprintf(title, "EM energy in depth 2 %s", sub); + hHF_em_2[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_em_2[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Em12%d",i); sprintf (title,"EM energy in depths 1,2 %s",sub); - hHF_em_12[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,500.); + sprintf(name, "Em12%d", i); + sprintf(title, "EM energy in depths 1,2 %s", sub); + hHF_em_12[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 500.); hHF_em_12[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Had1%d",i); sprintf (title,"Had energy in depth 1 %s",sub); - hHF_had_1[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,0.1); + sprintf(name, "Had1%d", i); + sprintf(title, "Had energy in depth 1 %s", sub); + hHF_had_1[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 0.1); hHF_had_1[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Had2%d",i); sprintf (title,"Had energy in depth 2 %s",sub); - hHF_had_2[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,0.1); + sprintf(name, "Had2%d", i); + sprintf(title, "Had energy in depth 2 %s", sub); + hHF_had_2[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 0.1); hHF_had_2[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Had12%d",i); sprintf (title,"Had energy in depths 1,2 %s",sub); - hHF_had_12[i] = HFPCaloHitEnergyDir.make(name,title,1000,0.,0.1); + sprintf(name, "Had12%d", i); + sprintf(title, "Had energy in depths 1,2 %s", sub); + hHF_had_12[i] = HFPCaloHitEnergyDir.make(name, title, 1000, 0., 0.1); hHF_had_12[i]->GetXaxis()->SetTitle(title); } //Timing Histograms TFileDirectory HFPCaloHitTimeDir = fs->mkdir("HFPCaloHitTime"); - for (int i=0; i<3; i++) { - if (i == 0) sprintf (sub, "(Absorber)"); - else if (i == 1) sprintf (sub, "(PMT)"); - else sprintf (sub, "(All)"); - sprintf (name,"Time1Ewt%d",i); sprintf (title,"Time (energy weighted) in depth 1 %s",sub); - hHF1_time_Ewt[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + for (int i = 0; i < 3; i++) { + if (i == 0) + sprintf(sub, "(Absorber)"); + else if (i == 1) + sprintf(sub, "(PMT)"); + else + sprintf(sub, "(All)"); + sprintf(name, "Time1Ewt%d", i); + sprintf(title, "Time (energy weighted) in depth 1 %s", sub); + hHF1_time_Ewt[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF1_time_Ewt[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Time2Ewt%d",i); sprintf (title,"Time (energy weighted) in depth 2 %s",sub); - hHF2_time_Ewt[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + sprintf(name, "Time2Ewt%d", i); + sprintf(title, "Time (energy weighted) in depth 2 %s", sub); + hHF2_time_Ewt[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF2_time_Ewt[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Time12Ewt%d",i); sprintf (title,"Time (energy weighted) in depths 1,2 %s",sub); - hHF12_time_Ewt[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + sprintf(name, "Time12Ewt%d", i); + sprintf(title, "Time (energy weighted) in depths 1,2 %s", sub); + hHF12_time_Ewt[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF12_time_Ewt[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Time1%d",i); sprintf (title,"Time in depth 1 %s",sub); - hHF1_time[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + sprintf(name, "Time1%d", i); + sprintf(title, "Time in depth 1 %s", sub); + hHF1_time[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF1_time[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Time2%d",i); sprintf (title,"Time in depth 2 %s",sub); - hHF2_time[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + sprintf(name, "Time2%d", i); + sprintf(title, "Time in depth 2 %s", sub); + hHF2_time[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF2_time[i]->GetXaxis()->SetTitle(title); - sprintf (name,"Time12%d",i); sprintf (title,"Time in depths 1,2 %s",sub); - hHF12_time[i] = HFPCaloHitTimeDir.make(name,title,400,0.,400.); + sprintf(name, "Time12%d", i); + sprintf(title, "Time in depths 1,2 %s", sub); + hHF12_time[i] = HFPCaloHitTimeDir.make(name, title, 400, 0., 400.); hHF12_time[i]->GetXaxis()->SetTitle(title); } } -void HFPMTHitAnalyzer::analyze(const edm::Event& iEvent, - const edm::EventSetup& iSetup) { - ++event_no; - if (event_no%500==0) std::cout<<"Event # "< caloHits; edm::Handle hitsHcal; - iEvent.getByToken(tok_calo_,hitsHcal); + iEvent.getByToken(tok_calo_, hitsHcal); std::vector simTracks; edm::Handle Tracks; - iEvent.getByToken (tok_track_, Tracks); + iEvent.getByToken(tok_track_, Tracks); - edm::Handle EvtHandle; + edm::Handle EvtHandle; iEvent.getByToken(tok_evt_, EvtHandle); - const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); + const HepMC::GenEvent *myGenEvent = EvtHandle->GetEvent(); - float orig_energy=0; - for (HepMC::GenEvent::particle_const_iterator p=myGenEvent->particles_begin(); - p != myGenEvent->particles_end(); ++p ) { - - orig_energy=(*p)->momentum().e(); + float orig_energy = 0; + for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); + ++p) { + orig_energy = (*p)->momentum().e(); hHF_MC_e->Fill(orig_energy); } - caloHits.insert(caloHits.end(),hitsHcal->begin(),hitsHcal->end()); - analyzeHits (caloHits,*Tracks); - + caloHits.insert(caloHits.end(), hitsHcal->begin(), hitsHcal->end()); + analyzeHits(caloHits, *Tracks); } -void HFPMTHitAnalyzer::analyzeHits (std::vector& hits, - const std::vector& tracks1) { - +void HFPMTHitAnalyzer::analyzeHits(std::vector &hits, const std::vector &tracks1) { int nHit = hits.size(); float energy1[3], energy2[3], energy12[3]; float em1[3], had1[3], em2[3], had2[3], em12[3], had12[3]; - for (int i=0; i<3; i++) { + for (int i = 0; i < 3; i++) { energy1[i] = energy2[i] = energy12[i] = 0; - em1[i] = em2[i] = em12[i] = 0; - had1[i] = had2[i] = had12[i] = 0; + em1[i] = em2[i] = em12[i] = 0; + had1[i] = had2[i] = had12[i] = 0; } - LogDebug("HFShower") << "HFPMTHitAnalyser::Entry " << event_no << " with " - << nHit << " hits"; - for (int i=0; i(HcalForward)) { - h_HFDepHit->Fill(double(depth+10*depthX)); - if (depthX > 0) { - int ieta = id.ietaAbs(); - int iphi = id.iphi(); - if (depth != 1) { - ieta += 50; - iphi += 50; - } - if (depthX <= 3) { - h_HFEta[depthX-1]->Fill(double(ieta)); - h_HFPhi[depthX-1]->Fill(double(iphi)); - } - } - if (depth==1) { - energy1[pmtHit] += energy; - energy12[pmtHit] += energy; - em1[pmtHit] += em; - em12[pmtHit] += em; - had1[pmtHit] += had; - had12[pmtHit] += had; - energy1[2] += energy; - energy12[2] += energy; - em1[2] += em; - em12[2] += em; - had1[2] += had; - had12[2] += had; - hHF1_time[pmtHit]->Fill(time); - hHF1_time[2]->Fill(time); - hHF1_time_Ewt[pmtHit]->Fill(time,energy); - hHF1_time_Ewt[2]->Fill(time,energy); - } - if (depth==2) { - energy2[pmtHit] += energy; - energy12[pmtHit] += energy; - em2[pmtHit] += em; - em12[pmtHit] += em; - had2[pmtHit] += had; - had12[pmtHit] += had; - energy2[2] += energy; - energy12[2] += energy; - em2[2] += em; - em12[2] += em; - had2[2] += had; - had12[2] += had; - hHF2_time[pmtHit]->Fill(time); - hHF2_time[2]->Fill(time); - hHF2_time_Ewt[pmtHit]->Fill(time,energy); - hHF2_time_Ewt[2]->Fill(time,energy); - } + h_HFDepHit->Fill(double(depth + 10 * depthX)); + if (depthX > 0) { + int ieta = id.ietaAbs(); + int iphi = id.iphi(); + if (depth != 1) { + ieta += 50; + iphi += 50; + } + if (depthX <= 3) { + h_HFEta[depthX - 1]->Fill(double(ieta)); + h_HFPhi[depthX - 1]->Fill(double(iphi)); + } + } + if (depth == 1) { + energy1[pmtHit] += energy; + energy12[pmtHit] += energy; + em1[pmtHit] += em; + em12[pmtHit] += em; + had1[pmtHit] += had; + had12[pmtHit] += had; + energy1[2] += energy; + energy12[2] += energy; + em1[2] += em; + em12[2] += em; + had1[2] += had; + had12[2] += had; + hHF1_time[pmtHit]->Fill(time); + hHF1_time[2]->Fill(time); + hHF1_time_Ewt[pmtHit]->Fill(time, energy); + hHF1_time_Ewt[2]->Fill(time, energy); + } + if (depth == 2) { + energy2[pmtHit] += energy; + energy12[pmtHit] += energy; + em2[pmtHit] += em; + em12[pmtHit] += em; + had2[pmtHit] += had; + had12[pmtHit] += had; + energy2[2] += energy; + energy12[2] += energy; + em2[2] += em; + em12[2] += em; + had2[2] += had; + had12[2] += had; + hHF2_time[pmtHit]->Fill(time); + hHF2_time[2]->Fill(time); + hHF2_time_Ewt[pmtHit]->Fill(time, energy); + hHF2_time_Ewt[2]->Fill(time, energy); + } } } } - for (int i=0; i<3; i++) { + for (int i = 0; i < 3; i++) { hHF_e_1[i]->Fill(energy1[i]); hHF_e_2[i]->Fill(energy2[i]); hHF_e_12[i]->Fill(energy12[i]); @@ -307,11 +320,10 @@ void HFPMTHitAnalyzer::analyzeHits (std::vector& hits, hHF_had_1[i]->Fill(had1[i]); hHF_had_2[i]->Fill(had2[i]); hHF_had_12[i]->Fill(had12[i]); - LogDebug("HFShower") << "HFPMTHitAnalyser:: Type " << i << " Energy 1|2| " - << energy1[i] << " " << energy2[i] << " " - << energy12[i] << " EM Energy 1|2| " << em1[i] << " " - << em2[i] << " " << em12[i] << " Had Energy 1|2| " - << had1[i] << " " << had2[i] << " " << had12[i]; + edm::LogVerbatim("HFShower") << "HFPMTHitAnalyser:: Type " << i << " Energy 1|2| " << energy1[i] << " " + << energy2[i] << " " << energy12[i] << " EM Energy 1|2| " << em1[i] << " " << em2[i] + << " " << em12[i] << " Had Energy 1|2| " << had1[i] << " " << had2[i] << " " + << had12[i]; } } diff --git a/SimG4CMS/Calo/test/HOSimHitStudy.cc b/SimG4CMS/Calo/test/HOSimHitStudy.cc index d79b4cafcac32..65ba354a07579 100644 --- a/SimG4CMS/Calo/test/HOSimHitStudy.cc +++ b/SimG4CMS/Calo/test/HOSimHitStudy.cc @@ -38,662 +38,662 @@ #include #include -class HOSimHitStudy: public edm::one::EDAnalyzer { - +class HOSimHitStudy : public edm::one::EDAnalyzer { public: - - HOSimHitStudy(const edm::ParameterSet& ps); + HOSimHitStudy(const edm::ParameterSet &ps); ~HOSimHitStudy() override {} - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); protected: - void beginJob() override; - void beginRun(edm::Run const&, edm::EventSetup const&) override {} + void beginRun(edm::Run const &, edm::EventSetup const &) override {} void endJob() override {} - void endRun(edm::Run const&, edm::EventSetup const&) override {} - void analyze(const edm::Event& e, const edm::EventSetup& c) override; + void endRun(edm::Run const &, edm::EventSetup const &) override {} + void analyze(const edm::Event &e, const edm::EventSetup &c) override; - void analyzeHits (); + void analyzeHits(); private: - - std::string g4Label, hitLab[2]; + std::string g4Label, hitLab[2]; edm::EDGetTokenT tok_evt_; edm::EDGetTokenT toks_calo_[2]; std::vector ecalHits, hcalHits; - double maxEnergy, scaleEB, scaleHB, scaleHO; - bool scheme_, print_; - double tcut_; - TH1F *hit_[3], *time_[3], *edepTW_[3], *edepTWT_[3]; - TH1F *edep_[3], *hitTow_[3], *eneInc_, *etaInc_, *phiInc_; - TH1F *edepT_[3], *eEB_, *eEBHB_, *eEBHBHO_, *eEBHBHOT_; - TH1F *edepZon_[3], *edepZonT_[3], *eEBT_, *eEBHBT_; - TH1F *eHOE17_[15], *eHOE18_[15], *eHOE_[15]; - TH1F *eHOE17T_[15], *eHOE18T_[15], *eHOET_[15]; - TH1F *eHOEta17_[15], *eHOEta18_[15], *eHOEta_[15]; - TH1F *eHOEta17T_[15], *eHOEta18T_[15], *eHOEtaT_[15]; - TH1F *nHOE1_[15],*nHOE1T_[15], *nHOEta1_[15],*nHOEta1T_[15]; - TProfile *eHO1_, *eHO1T_, *eHO17_, *eHO17T_, *eHO18_, *eHO18T_; - TProfile *nHO1_, *nHO1T_, *nHOE2_[15], *nHOE2T_[15]; - TProfile *nHOEta2_[15], *nHOEta2T_[15]; - TProfile2D *eHO2_, *eHO2T_, *nHO2_, *nHO2T_; - double eInc, etaInc, phiInc; + double maxEnergy, scaleEB, scaleHB, scaleHO; + bool scheme_, print_; + double tcut_; + TH1F *hit_[3], *time_[3], *edepTW_[3], *edepTWT_[3]; + TH1F *edep_[3], *hitTow_[3], *eneInc_, *etaInc_, *phiInc_; + TH1F *edepT_[3], *eEB_, *eEBHB_, *eEBHBHO_, *eEBHBHOT_; + TH1F *edepZon_[3], *edepZonT_[3], *eEBT_, *eEBHBT_; + TH1F *eHOE17_[15], *eHOE18_[15], *eHOE_[15]; + TH1F *eHOE17T_[15], *eHOE18T_[15], *eHOET_[15]; + TH1F *eHOEta17_[15], *eHOEta18_[15], *eHOEta_[15]; + TH1F *eHOEta17T_[15], *eHOEta18T_[15], *eHOEtaT_[15]; + TH1F *nHOE1_[15], *nHOE1T_[15], *nHOEta1_[15], *nHOEta1T_[15]; + TProfile *eHO1_, *eHO1T_, *eHO17_, *eHO17T_, *eHO18_, *eHO18T_; + TProfile *nHO1_, *nHO1T_, *nHOE2_[15], *nHOE2T_[15]; + TProfile *nHOEta2_[15], *nHOEta2T_[15]; + TProfile2D *eHO2_, *eHO2T_, *nHO2_, *nHO2T_; + double eInc, etaInc, phiInc; }; -HOSimHitStudy::HOSimHitStudy(const edm::ParameterSet& ps) { - +HOSimHitStudy::HOSimHitStudy(const edm::ParameterSet &ps) { usesResource(TFileService::kSharedResource); - tok_evt_ = consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel","VtxSmeared"))); - g4Label = ps.getUntrackedParameter("ModuleLabel","g4SimHits"); - hitLab[0] = ps.getUntrackedParameter("EBCollection","EcalHitsEB"); - hitLab[1] = ps.getUntrackedParameter("HCCollection","HcalHits"); + tok_evt_ = + consumes(edm::InputTag(ps.getUntrackedParameter("SourceLabel", "VtxSmeared"))); + g4Label = ps.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hitLab[0] = ps.getUntrackedParameter("EBCollection", "EcalHitsEB"); + hitLab[1] = ps.getUntrackedParameter("HCCollection", "HcalHits"); - for ( unsigned i=0; i != 2; i++ ) - toks_calo_[i] = consumes(edm::InputTag(g4Label,hitLab[i])); + for (unsigned i = 0; i != 2; i++) + toks_calo_[i] = consumes(edm::InputTag(g4Label, hitLab[i])); maxEnergy = ps.getUntrackedParameter("MaxEnergy", 200.0); - scaleEB = ps.getUntrackedParameter("ScaleEB", 1.0); - scaleHB = ps.getUntrackedParameter("ScaleHB", 100.0); - scaleHO = ps.getUntrackedParameter("ScaleHO", 2.0); - tcut_ = ps.getUntrackedParameter("TimeCut", 100.0); - scheme_ = ps.getUntrackedParameter("TestNumbering", false); - print_ = ps.getUntrackedParameter("PrintExcessEnergy", true); - edm::LogInfo("HitStudy") << "Module Label: " << g4Label << " Hits: " - << hitLab[0] << ", " << hitLab[1] - << " MaxEnergy: " << maxEnergy - << " Scale factor for EB " << scaleEB - << ", for HB " << scaleHB << " and for HO " - << scaleHO << " time Cut " << tcut_; + scaleEB = ps.getUntrackedParameter("ScaleEB", 1.0); + scaleHB = ps.getUntrackedParameter("ScaleHB", 100.0); + scaleHO = ps.getUntrackedParameter("ScaleHO", 2.0); + tcut_ = ps.getUntrackedParameter("TimeCut", 100.0); + scheme_ = ps.getUntrackedParameter("TestNumbering", false); + print_ = ps.getUntrackedParameter("PrintExcessEnergy", true); + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::Module Label: " << g4Label << " Hits: " << hitLab[0] << ", " + << hitLab[1] << " MaxEnergy: " << maxEnergy << " Scale factor for EB " << scaleEB + << ", for HB " << scaleHB << " and for HO " << scaleHO << " time Cut " << tcut_; } -void HOSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - +void HOSimHitStudy::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.addUntracked("SourceLabel","generatorSmeared"); - desc.addUntracked("ModuleLabel","g4SimHits"); - desc.addUntracked("EBCollection","EcalHitsEB"); - desc.addUntracked("HCCollection","HcalHits"); - desc.addUntracked("MaxEnergy",50.0); - desc.addUntracked("ScaleEB",1.02); - desc.addUntracked("ScaleHB",104.4); - desc.addUntracked("ScaleHO",2.33); - desc.addUntracked("TimeCut",100.0); - desc.addUntracked("PrintExcessEnergy",true); - desc.addUntracked("TestNumbering",false); - descriptions.add("HOSimHitStudy",desc); + desc.addUntracked("SourceLabel", "generatorSmeared"); + desc.addUntracked("ModuleLabel", "g4SimHits"); + desc.addUntracked("EBCollection", "EcalHitsEB"); + desc.addUntracked("HCCollection", "HcalHits"); + desc.addUntracked("MaxEnergy", 50.0); + desc.addUntracked("ScaleEB", 1.02); + desc.addUntracked("ScaleHB", 104.4); + desc.addUntracked("ScaleHO", 2.33); + desc.addUntracked("TimeCut", 100.0); + desc.addUntracked("PrintExcessEnergy", true); + desc.addUntracked("TestNumbering", false); + descriptions.add("HOSimHitStudy", desc); } void HOSimHitStudy::beginJob() { - edm::Service tfile; - - if ( !tfile.isAvailable() ) + + if (!tfile.isAvailable()) throw cms::Exception("BadConfig") << "TFileService unavailable: " << "please add it to config file"; std::string dets[3] = {"EB", "HB", "HO"}; - char name[60], title[100]; + char name[60], title[100]; double ymax = maxEnergy; - sprintf (title, "Incident Energy (GeV)"); + sprintf(title, "Incident Energy (GeV)"); eneInc_ = tfile->make("EneInc", title, 1000, 0., ymax); - eneInc_->GetXaxis()->SetTitle(title); + eneInc_->GetXaxis()->SetTitle(title); eneInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #eta"); + sprintf(title, "Incident #eta"); etaInc_ = tfile->make("EtaInc", title, 200, -5., 5.); - etaInc_->GetXaxis()->SetTitle(title); + etaInc_->GetXaxis()->SetTitle(title); etaInc_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Incident #phi"); + sprintf(title, "Incident #phi"); phiInc_ = tfile->make("PhiInc", title, 200, -3.1415926, 3.1415926); - phiInc_->GetXaxis()->SetTitle(title); + phiInc_->GetXaxis()->SetTitle(title); phiInc_->GetYaxis()->SetTitle("Events"); int itcut = (int)(tcut_); - for (int i=0; i<3; i++) { - sprintf (name, "Hit%d", i); - sprintf (title, "Number of hits in %s", dets[i].c_str()); - hit_[i] = tfile->make(name, title, 1000, 0., 20000.); - hit_[i]->GetXaxis()->SetTitle(title); + for (int i = 0; i < 3; i++) { + sprintf(name, "Hit%d", i); + sprintf(title, "Number of hits in %s", dets[i].c_str()); + hit_[i] = tfile->make(name, title, 1000, 0., 20000.); + hit_[i]->GetXaxis()->SetTitle(title); hit_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "Time%d", i); - sprintf (title, "Time of the hit (ns) in %s", dets[i].c_str()); - time_[i] = tfile->make(name, title, 1200, 0., 1200.); - time_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "Time%d", i); + sprintf(title, "Time of the hit (ns) in %s", dets[i].c_str()); + time_[i] = tfile->make(name, title, 1200, 0., 1200.); + time_[i]->GetXaxis()->SetTitle(title); time_[i]->GetYaxis()->SetTitle("Hits"); - if (i > 0) ymax = 1.0; - else ymax = 50.0; - sprintf (name, "Edep%d", i); - sprintf (title, "Energy deposit (GeV) in %s", dets[i].c_str()); - edep_[i] = tfile->make(name, title, 5000, 0., ymax); - edep_[i]->GetXaxis()->SetTitle(title); + if (i > 0) + ymax = 1.0; + else + ymax = 50.0; + sprintf(name, "Edep%d", i); + sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str()); + edep_[i] = tfile->make(name, title, 5000, 0., ymax); + edep_[i]->GetXaxis()->SetTitle(title); edep_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "EdepT%d", i); - sprintf (title, "Energy deposit (GeV) in %s for t < %d ns", dets[i].c_str(), itcut); - edepT_[i] = tfile->make(name, title, 5000, 0., ymax); - edepT_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepT%d", i); + sprintf(title, "Energy deposit (GeV) in %s for t < %d ns", dets[i].c_str(), itcut); + edepT_[i] = tfile->make(name, title, 5000, 0., ymax); + edepT_[i]->GetXaxis()->SetTitle(title); edepT_[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "HitTow%d", i); - sprintf (title, "Number of towers with hits in %s", dets[i].c_str()); - hitTow_[i] = tfile->make(name, title, 1000, 0., 20000.); - hitTow_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "HitTow%d", i); + sprintf(title, "Number of towers with hits in %s", dets[i].c_str()); + hitTow_[i] = tfile->make(name, title, 1000, 0., 20000.); + hitTow_[i]->GetXaxis()->SetTitle(title); hitTow_[i]->GetYaxis()->SetTitle("Events"); - if (i > 0) ymax = 0.05*maxEnergy; - else ymax = maxEnergy; - sprintf (name, "EdepTW%d", i); - sprintf (title, "Energy deposit (GeV) in %s Tower", dets[i].c_str()); - edepTW_[i] = tfile->make(name, title, 5000, 0., ymax); - edepTW_[i]->GetXaxis()->SetTitle(title); + if (i > 0) + ymax = 0.05 * maxEnergy; + else + ymax = maxEnergy; + sprintf(name, "EdepTW%d", i); + sprintf(title, "Energy deposit (GeV) in %s Tower", dets[i].c_str()); + edepTW_[i] = tfile->make(name, title, 5000, 0., ymax); + edepTW_[i]->GetXaxis()->SetTitle(title); edepTW_[i]->GetYaxis()->SetTitle("Towers"); - sprintf (name, "EdepTWT%d", i); - sprintf (title, "Energy deposit (GeV) in %s Tower for t < %d ns", dets[i].c_str(), itcut); - edepTWT_[i] = tfile->make(name, title, 5000, 0., ymax); - edepTWT_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepTWT%d", i); + sprintf(title, "Energy deposit (GeV) in %s Tower for t < %d ns", dets[i].c_str(), itcut); + edepTWT_[i] = tfile->make(name, title, 5000, 0., ymax); + edepTWT_[i]->GetXaxis()->SetTitle(title); edepTWT_[i]->GetYaxis()->SetTitle("Towers"); - sprintf (name, "EdepZone%d", i); - sprintf (title, "Energy deposit (GeV) in %s", dets[i].c_str()); - edepZon_[i] = tfile->make(name, title, 5000, 0., ymax); - edepZon_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepZone%d", i); + sprintf(title, "Energy deposit (GeV) in %s", dets[i].c_str()); + edepZon_[i] = tfile->make(name, title, 5000, 0., ymax); + edepZon_[i]->GetXaxis()->SetTitle(title); edepZon_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EdepZoneT%d", i); - sprintf (title, "Energy deposit (GeV) in %s for t < %d ns", dets[i].c_str(), itcut); - edepZonT_[i] = tfile->make(name, title, 5000, 0., ymax); - edepZonT_[i]->GetXaxis()->SetTitle(title); + sprintf(name, "EdepZoneT%d", i); + sprintf(title, "Energy deposit (GeV) in %s for t < %d ns", dets[i].c_str(), itcut); + edepZonT_[i] = tfile->make(name, title, 5000, 0., ymax); + edepZonT_[i]->GetXaxis()->SetTitle(title); edepZonT_[i]->GetYaxis()->SetTitle("Events"); } - sprintf (title, "Energy Measured in EB (GeV)"); - eEB_ = tfile->make("EEB", title, 5000, 0., maxEnergy); - eEB_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB (GeV)"); + eEB_ = tfile->make("EEB", title, 5000, 0., maxEnergy); + eEB_->GetXaxis()->SetTitle(title); eEB_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Energy Measured in EB+HB (GeV)"); - eEBHB_ = tfile->make("EEBHB", title, 5000, 0., maxEnergy); - eEBHB_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB+HB (GeV)"); + eEBHB_ = tfile->make("EEBHB", title, 5000, 0., maxEnergy); + eEBHB_->GetXaxis()->SetTitle(title); eEBHB_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Energy Measured in EB+HB+HO (GeV)"); - eEBHBHO_ = tfile->make("EEBHBHO", title, 5000, 0., maxEnergy); - eEBHBHO_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB+HB+HO (GeV)"); + eEBHBHO_ = tfile->make("EEBHBHO", title, 5000, 0., maxEnergy); + eEBHBHO_->GetXaxis()->SetTitle(title); eEBHBHO_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Energy Measured in EB (GeV) for t < %d ns", itcut); - eEBT_ = tfile->make("EEBT", title, 5000, 0., maxEnergy); - eEBT_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB (GeV) for t < %d ns", itcut); + eEBT_ = tfile->make("EEBT", title, 5000, 0., maxEnergy); + eEBT_->GetXaxis()->SetTitle(title); eEBT_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Energy Measured in EB+HB (GeV) for t < %d ns", itcut); - eEBHBT_ = tfile->make("EEBHBT", title, 5000, 0., maxEnergy); - eEBHBT_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB+HB (GeV) for t < %d ns", itcut); + eEBHBT_ = tfile->make("EEBHBT", title, 5000, 0., maxEnergy); + eEBHBT_->GetXaxis()->SetTitle(title); eEBHBT_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Energy Measured in EB+HB+HO (GeV) for t < %d ns", itcut); - eEBHBHOT_ = tfile->make("EEBHBHOT", title, 5000, 0., maxEnergy); - eEBHBHOT_->GetXaxis()->SetTitle(title); + sprintf(title, "Energy Measured in EB+HB+HO (GeV) for t < %d ns", itcut); + eEBHBHOT_ = tfile->make("EEBHBHOT", title, 5000, 0., maxEnergy); + eEBHBHOT_->GetXaxis()->SetTitle(title); eEBHBHOT_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO"); + sprintf(title, "SimHit energy in HO"); eHO1_ = tfile->make("EHO1", title, 30, -1.305, 1.305); - eHO1_->GetXaxis()->SetTitle(title); + eHO1_->GetXaxis()->SetTitle(title); eHO1_->GetYaxis()->SetTitle("Events"); - eHO2_ = tfile->make("EHO2", title, 30,-1.305,1.305,72,-3.1415926,3.1415926); - eHO2_->GetXaxis()->SetTitle(title); + eHO2_ = tfile->make("EHO2", title, 30, -1.305, 1.305, 72, -3.1415926, 3.1415926); + eHO2_->GetXaxis()->SetTitle(title); eHO2_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO Layer 17"); + sprintf(title, "SimHit energy in HO Layer 17"); eHO17_ = tfile->make("EHO17", title, 30, -1.305, 1.305); - eHO17_->GetXaxis()->SetTitle(title); + eHO17_->GetXaxis()->SetTitle(title); eHO17_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO Layer 18"); + sprintf(title, "SimHit energy in HO Layer 18"); eHO18_ = tfile->make("EHO18", title, 30, -1.305, 1.305); - eHO18_->GetXaxis()->SetTitle(title); + eHO18_->GetXaxis()->SetTitle(title); eHO18_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO for t < %d ns", itcut); + sprintf(title, "SimHit energy in HO for t < %d ns", itcut); eHO1T_ = tfile->make("EHO1T", title, 30, -1.305, 1.305); - eHO1T_->GetXaxis()->SetTitle(title); + eHO1T_->GetXaxis()->SetTitle(title); eHO1T_->GetYaxis()->SetTitle("Events"); - eHO2T_ = tfile->make("EHO2T", title, 30,-1.305,1.305,72,-3.1415926,3.1415926); - eHO2T_->GetXaxis()->SetTitle(title); + eHO2T_ = tfile->make("EHO2T", title, 30, -1.305, 1.305, 72, -3.1415926, 3.1415926); + eHO2T_->GetXaxis()->SetTitle(title); eHO2T_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO Layer 17 for t < %d ns", itcut); + sprintf(title, "SimHit energy in HO Layer 17 for t < %d ns", itcut); eHO17T_ = tfile->make("EHO17T", title, 30, -1.305, 1.305); - eHO17T_->GetXaxis()->SetTitle(title); + eHO17T_->GetXaxis()->SetTitle(title); eHO17T_->GetYaxis()->SetTitle("Events"); - sprintf (title, "SimHit energy in HO Layer 18 for t < %d ns", itcut); + sprintf(title, "SimHit energy in HO Layer 18 for t < %d ns", itcut); eHO18T_ = tfile->make("EHO18T", title, 30, -1.305, 1.305); - eHO18T_->GetXaxis()->SetTitle(title); + eHO18T_->GetXaxis()->SetTitle(title); eHO18T_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Number of layers hit in HO"); + sprintf(title, "Number of layers hit in HO"); nHO1_ = tfile->make("NHO1", title, 30, -1.305, 1.305); - nHO1_->GetXaxis()->SetTitle(title); + nHO1_->GetXaxis()->SetTitle(title); nHO1_->GetYaxis()->SetTitle("Events"); - nHO2_ = tfile->make("NHO2", title, 30,-1.305,1.305,72,-3.1415926,3.1415926); - nHO2_->GetXaxis()->SetTitle(title); + nHO2_ = tfile->make("NHO2", title, 30, -1.305, 1.305, 72, -3.1415926, 3.1415926); + nHO2_->GetXaxis()->SetTitle(title); nHO2_->GetYaxis()->SetTitle("Events"); - sprintf (title, "Number of layers hit in HO for t < %d ns", itcut); + sprintf(title, "Number of layers hit in HO for t < %d ns", itcut); nHO1T_ = tfile->make("NHO1T", title, 30, -1.305, 1.305); - nHO1T_->GetXaxis()->SetTitle(title); + nHO1T_->GetXaxis()->SetTitle(title); nHO1T_->GetYaxis()->SetTitle("Events"); - nHO2T_ = tfile->make("NHO2T", title, 30,-1.305,1.305,72,-3.1415926,3.1415926); - nHO2T_->GetXaxis()->SetTitle(title); + nHO2T_ = tfile->make("NHO2T", title, 30, -1.305, 1.305, 72, -3.1415926, 3.1415926); + nHO2T_->GetXaxis()->SetTitle(title); nHO2T_->GetYaxis()->SetTitle("Events"); - for (int i=0; i<15; i++) { - sprintf (name, "EHOE%d", i+1); - sprintf (title, "SimHit energy in HO (Beam in #eta=%d bin)",i+1); + for (int i = 0; i < 15; i++) { + sprintf(name, "EHOE%d", i + 1); + sprintf(title, "SimHit energy in HO (Beam in #eta=%d bin)", i + 1); eHOE_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOE_[i]->GetXaxis()->SetTitle(title); + eHOE_[i]->GetXaxis()->SetTitle(title); eHOE_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOE17%d", i+1); - sprintf (title, "SimHit energy in Layer 17 (Beam in #eta=%d bin)",i+1); + sprintf(name, "EHOE17%d", i + 1); + sprintf(title, "SimHit energy in Layer 17 (Beam in #eta=%d bin)", i + 1); eHOE17_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOE17_[i]->GetXaxis()->SetTitle(title); + eHOE17_[i]->GetXaxis()->SetTitle(title); eHOE17_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOE18%d", i+1); - sprintf (title, "SimHit energy in Layer 18 (Beam in #eta=%d bin)",i+1); + sprintf(name, "EHOE18%d", i + 1); + sprintf(title, "SimHit energy in Layer 18 (Beam in #eta=%d bin)", i + 1); eHOE18_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOE18_[i]->GetXaxis()->SetTitle(title); + eHOE18_[i]->GetXaxis()->SetTitle(title); eHOE18_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOE%dT", i+1); - sprintf (title, "SimHit energy in HO (Beam in #eta=%d bin, t < %d ns)",i+1,itcut); + sprintf(name, "EHOE%dT", i + 1); + sprintf(title, "SimHit energy in HO (Beam in #eta=%d bin, t < %d ns)", i + 1, itcut); eHOET_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOET_[i]->GetXaxis()->SetTitle(title); + eHOET_[i]->GetXaxis()->SetTitle(title); eHOET_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOE17%dT", i+1); - sprintf (title, "SimHit energy in Layer 17 (Beam in #eta=%d bin, t < %d ns)",i+1,itcut); + sprintf(name, "EHOE17%dT", i + 1); + sprintf(title, "SimHit energy in Layer 17 (Beam in #eta=%d bin, t < %d ns)", i + 1, itcut); eHOE17T_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOE17T_[i]->GetXaxis()->SetTitle(title); + eHOE17T_[i]->GetXaxis()->SetTitle(title); eHOE17T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOE18%dT", i+1); - sprintf (title, "SimHit energy in Layer 18 (Beam in #eta=%d bin, t < %d ns)",i+1,itcut); + sprintf(name, "EHOE18%dT", i + 1); + sprintf(title, "SimHit energy in Layer 18 (Beam in #eta=%d bin, t < %d ns)", i + 1, itcut); eHOE18T_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOE18T_[i]->GetXaxis()->SetTitle(title); + eHOE18T_[i]->GetXaxis()->SetTitle(title); eHOE18T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta%d", i+1); - sprintf (title, "SimHit energy in HO #eta bin %d (Beam in #eta=%d bin)",i+1,i+1); + sprintf(name, "EHOEta%d", i + 1); + sprintf(title, "SimHit energy in HO #eta bin %d (Beam in #eta=%d bin)", i + 1, i + 1); eHOEta_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEta_[i]->GetXaxis()->SetTitle(title); + eHOEta_[i]->GetXaxis()->SetTitle(title); eHOEta_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta17%d", i+1); - sprintf (title, "SimHit energy in Layer 17 #eta bin %d (Beam in #eta=%d bin)",i+1,i+1); + sprintf(name, "EHOEta17%d", i + 1); + sprintf(title, "SimHit energy in Layer 17 #eta bin %d (Beam in #eta=%d bin)", i + 1, i + 1); eHOEta17_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEta17_[i]->GetXaxis()->SetTitle(title); + eHOEta17_[i]->GetXaxis()->SetTitle(title); eHOEta17_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta18%d", i+1); - sprintf (title, "SimHit energy in Layer 18 #eta bin %d (Beam in #eta=%d bin)",i+1,i+1); + sprintf(name, "EHOEta18%d", i + 1); + sprintf(title, "SimHit energy in Layer 18 #eta bin %d (Beam in #eta=%d bin)", i + 1, i + 1); eHOEta18_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEta18_[i]->GetXaxis()->SetTitle(title); + eHOEta18_[i]->GetXaxis()->SetTitle(title); eHOEta18_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta%dT", i+1); - sprintf (title, "SimHit energy in HO #eta bin %d (Beam in #eta=%d bin, t < %d ns)",i+1,i+1,itcut); + sprintf(name, "EHOEta%dT", i + 1); + sprintf(title, "SimHit energy in HO #eta bin %d (Beam in #eta=%d bin, t < %d ns)", i + 1, i + 1, itcut); eHOEtaT_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEtaT_[i]->GetXaxis()->SetTitle(title); + eHOEtaT_[i]->GetXaxis()->SetTitle(title); eHOEtaT_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta17%dT", i+1); - sprintf (title, "SimHit energy in Layer 17 #eta bin %d (Beam in #eta=%d bin, t < %d ns)",i+1,i+1,itcut); + sprintf(name, "EHOEta17%dT", i + 1); + sprintf(title, "SimHit energy in Layer 17 #eta bin %d (Beam in #eta=%d bin, t < %d ns)", i + 1, i + 1, itcut); eHOEta17T_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEta17T_[i]->GetXaxis()->SetTitle(title); + eHOEta17T_[i]->GetXaxis()->SetTitle(title); eHOEta17T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "EHOEta18%dT", i+1); - sprintf (title, "SimHit energy in Layer 18 #eta bin %d (Beam in #eta=%d bin, t < %d ns)",i+1,i+1,itcut); + sprintf(name, "EHOEta18%dT", i + 1); + sprintf(title, "SimHit energy in Layer 18 #eta bin %d (Beam in #eta=%d bin, t < %d ns)", i + 1, i + 1, itcut); eHOEta18T_[i] = tfile->make(name, title, 1000, 0., 0.25); - eHOEta18T_[i]->GetXaxis()->SetTitle(title); + eHOEta18T_[i]->GetXaxis()->SetTitle(title); eHOEta18T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOE1%d", i+1); - sprintf (title, "Number of layers hit in HO (Beam in #eta=%d bin)",i+1); + sprintf(name, "NHOE1%d", i + 1); + sprintf(title, "Number of layers hit in HO (Beam in #eta=%d bin)", i + 1); nHOE1_[i] = tfile->make(name, title, 20, 0, 20.); - nHOE1_[i]->GetXaxis()->SetTitle(title); + nHOE1_[i]->GetXaxis()->SetTitle(title); nHOE1_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOE2%d", i+1); + sprintf(name, "NHOE2%d", i + 1); nHOE2_[i] = tfile->make(name, title, 72, -3.1415926, 3.1415926); - nHOE2_[i]->GetXaxis()->SetTitle(title); + nHOE2_[i]->GetXaxis()->SetTitle(title); nHOE2_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOE1%dT", i+1); - sprintf (title, "Number of layers hit in HO (Beam in #eta=%d bin, t < %d ns)", i+1,itcut); + sprintf(name, "NHOE1%dT", i + 1); + sprintf(title, "Number of layers hit in HO (Beam in #eta=%d bin, t < %d ns)", i + 1, itcut); nHOE1T_[i] = tfile->make(name, title, 20, 0, 20.); - nHOE1T_[i]->GetXaxis()->SetTitle(title); + nHOE1T_[i]->GetXaxis()->SetTitle(title); nHOE1T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOE2%dT", i+1); + sprintf(name, "NHOE2%dT", i + 1); nHOE2T_[i] = tfile->make(name, title, 72, -3.1415926, 3.1415926); - nHOE2T_[i]->GetXaxis()->SetTitle(title); + nHOE2T_[i]->GetXaxis()->SetTitle(title); nHOE2T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOEta1%d", i+1); - sprintf (title, "Number of layers hit in HO #eta bin %d (Beam in #eta=%d bin)", i+1,i+1); + sprintf(name, "NHOEta1%d", i + 1); + sprintf(title, "Number of layers hit in HO #eta bin %d (Beam in #eta=%d bin)", i + 1, i + 1); nHOEta1_[i] = tfile->make(name, title, 20, 0, 20.); - nHOEta1_[i]->GetXaxis()->SetTitle(title); + nHOEta1_[i]->GetXaxis()->SetTitle(title); nHOEta1_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOEta2%d", i+1); + sprintf(name, "NHOEta2%d", i + 1); nHOEta2_[i] = tfile->make(name, title, 72, -3.1415926, 3.1415926); - nHOEta2_[i]->GetXaxis()->SetTitle(title); + nHOEta2_[i]->GetXaxis()->SetTitle(title); nHOEta2_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOEta1%dT", i+1); - sprintf (title, "Number of layers hit in HO #eta bin %d (Beam in #eta=%d bin, t < %d ns)", i+1,i+1,itcut); + sprintf(name, "NHOEta1%dT", i + 1); + sprintf(title, "Number of layers hit in HO #eta bin %d (Beam in #eta=%d bin, t < %d ns)", i + 1, i + 1, itcut); nHOEta1T_[i] = tfile->make(name, title, 20, 0, 20.); - nHOEta1T_[i]->GetXaxis()->SetTitle(title); + nHOEta1T_[i]->GetXaxis()->SetTitle(title); nHOEta1T_[i]->GetYaxis()->SetTitle("Events"); - sprintf (name, "NHOEta2%dT", i+1); + sprintf(name, "NHOEta2%dT", i + 1); nHOEta2T_[i] = tfile->make(name, title, 72, -3.1415926, 3.1415926); - nHOEta2T_[i]->GetXaxis()->SetTitle(title); + nHOEta2T_[i]->GetXaxis()->SetTitle(title); nHOEta2T_[i]->GetYaxis()->SetTitle("Events"); } } -void HOSimHitStudy::analyze(const edm::Event& e, const edm::EventSetup& ) { - - LogDebug("HitStudy") << "Run = " << e.id().run() << " Event = " - << e.id().event(); +void HOSimHitStudy::analyze(const edm::Event &e, const edm::EventSetup &) { + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::Run = " << e.id().run() << " Event = " << e.id().event(); - edm::Handle EvtHandle; + edm::Handle EvtHandle; e.getByToken(tok_evt_, EvtHandle); - const HepMC::GenEvent* myGenEvent = EvtHandle->GetEvent(); + const HepMC::GenEvent *myGenEvent = EvtHandle->GetEvent(); eInc = etaInc = phiInc = 0; - HepMC::GenEvent::particle_const_iterator p=myGenEvent->particles_begin(); + HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); if (p != myGenEvent->particles_end()) { - eInc = (*p)->momentum().e(); + eInc = (*p)->momentum().e(); etaInc = (*p)->momentum().eta(); phiInc = (*p)->momentum().phi(); } - LogDebug("HitStudy") << "Energy = " << eInc << " Eta = " << etaInc - << " Phi = " << phiInc/CLHEP::deg; + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::Energy = " << eInc << " Eta = " << etaInc + << " Phi = " << phiInc / CLHEP::deg; - for (int i=0; i<2; i++) { + for (int i = 0; i < 2; i++) { bool getHits = false; - if (i == 0) ecalHits.clear(); - else hcalHits.clear(); + if (i == 0) + ecalHits.clear(); + else + hcalHits.clear(); edm::Handle hitsCalo; - e.getByToken(toks_calo_[i],hitsCalo); - if (hitsCalo.isValid()) getHits = true; - LogDebug("HitStudy") << "HcalValidation: Input flag " << hitLab[i] - << " getHits flag " << getHits; + e.getByToken(toks_calo_[i], hitsCalo); + if (hitsCalo.isValid()) + getHits = true; + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::Input flag " << hitLab[i] << " getHits flag " << getHits; if (getHits) { unsigned int isiz; if (i == 0) { - ecalHits.insert(ecalHits.end(),hitsCalo->begin(),hitsCalo->end()); - isiz = ecalHits.size(); + ecalHits.insert(ecalHits.end(), hitsCalo->begin(), hitsCalo->end()); + isiz = ecalHits.size(); } else { - hcalHits.insert(hcalHits.end(),hitsCalo->begin(),hitsCalo->end()); - isiz = hcalHits.size(); + hcalHits.insert(hcalHits.end(), hitsCalo->begin(), hitsCalo->end()); + isiz = hcalHits.size(); } - LogDebug("HitStudy") << "HcalValidation: Hit buffer for " << hitLab[i] - << " has " << isiz << " hits"; + edm::LogVerbatim("HitStudy") << "HOSimHitStudy:: Hit buffer for " << hitLab[i] << " has " << isiz << " hits"; } } - analyzeHits (); + analyzeHits(); } -void HOSimHitStudy::analyzeHits () { - +void HOSimHitStudy::analyzeHits() { //initialize - int nhit[3]; + int nhit[3]; double etot[3], etotT[3]; std::vector ebID, hbID, hoID; - std::vector ebEtow, hbEtow, hoEtow; - std::vector ebEtowT, hbEtowT, hoEtowT; - for (int k=0; k<3; k++) { + std::vector ebEtow, hbEtow, hoEtow; + std::vector ebEtowT, hbEtowT, hoEtowT; + for (int k = 0; k < 3; k++) { nhit[k] = 0; etot[k] = 0; - etotT[k]= 0; + etotT[k] = 0; } eneInc_->Fill(eInc); etaInc_->Fill(etaInc); phiInc_->Fill(phiInc); - - double eHO17=0, eHO18=0, eHO17T=0, eHO18T=0; + + double eHO17 = 0, eHO18 = 0, eHO17T = 0, eHO18T = 0; double eHOE17[15], eHOE18[15], eHOE17T[15], eHOE18T[15]; - for (int k=0; k<15; k++) { + for (int k = 0; k < 15; k++) { eHOE17[k] = eHOE18[k] = eHOE17T[k] = eHOE18T[k] = 0; } // Loop over containers - for (int k=0; k<2; k++) { + for (int k = 0; k < 2; k++) { int nHit; if (k == 0) { nHit = ecalHits.size(); } else { nHit = hcalHits.size(); } - for (int i=0; i(HcalBarrel)) indx = 1; - else if (subdet == static_cast(HcalOuter)) { - indx = 2; - if (lay == 18) { - eHO17 += edep; - if (time < tcut_) eHO17T += edep; - if (eta >=0 && eta < 15) { - eHOE17[eta] += edep; - if (time < tcut_) eHOE17T[eta] += edep; - } - } else { - eHO18 += edep; - if (time < tcut_) eHO18T += edep; - if (eta >=0 && eta < 15) { - eHOE18[eta] += edep; - if (time < tcut_) eHOE18T[eta] += edep; - } - } - } + edep = hcalHits[i].energy(); + time = hcalHits[i].time(); + id_ = hcalHits[i].id(); + int subdet, zside, depth, eta, phi, lay; + if (scheme_) { + HcalTestNumberingScheme::unpackHcalIndex(id_, subdet, zside, depth, eta, phi, lay); + } else { + HcalDetId id = HcalDetId(id_); + subdet = id.subdet(); + zside = id.zside(); + depth = id.depth(); + eta = id.ietaAbs(); + phi = id.iphi(); + lay = -1; + } + edm::LogVerbatim("HitStudy") << "HOSimHitStudy:: Hit " << k << " Subdet:" << subdet << " zside:" << zside + << " depth:" << depth << " layer:" << lay << " eta:" << eta << " phi:" << phi; + if (subdet == static_cast(HcalBarrel)) + indx = 1; + else if (subdet == static_cast(HcalOuter)) { + indx = 2; + if (lay == 18) { + eHO17 += edep; + if (time < tcut_) + eHO17T += edep; + if (eta >= 0 && eta < 15) { + eHOE17[eta] += edep; + if (time < tcut_) + eHOE17T[eta] += edep; + } + } else { + eHO18 += edep; + if (time < tcut_) + eHO18T += edep; + if (eta >= 0 && eta < 15) { + eHOE18[eta] += edep; + if (time < tcut_) + eHOE18T[eta] += edep; + } + } + } } if (indx >= 0) { - double edepT = edep; - time_[indx]->Fill(time); - edep_[indx]->Fill(edep); - etot[indx] += edep; - if (time < tcut_) { - etotT[indx] += edep; - edepT_[indx]->Fill(edep); - edepT = 0; - } - nhit[indx]++; - if (indx == 0) { - bool ok = false; - for (unsigned int j=0; jFill(time); + edep_[indx]->Fill(edep); + etot[indx] += edep; + if (time < tcut_) { + etotT[indx] += edep; + edepT_[indx]->Fill(edep); + edepT = 0; + } + nhit[indx]++; + if (indx == 0) { + bool ok = false; + for (unsigned int j = 0; j < ebID.size(); j++) { + if (id_ == ebID[j]) { + ebEtow[j] += edep; + ebEtowT[j] += edepT; + ok = true; + break; + } + } + if (!ok) { + ebID.push_back(id_); + ebEtow.push_back(edep); + ebEtowT.push_back(edepT); + } + } else if (indx == 1) { + bool ok = false; + for (unsigned int j = 0; j < hbID.size(); j++) { + if (id_ == hbID[j]) { + hbEtow[j] += edep; + hbEtowT[j] += edepT; + ok = true; + break; + } + } + if (!ok) { + hbID.push_back(id_); + hbEtow.push_back(edep); + hbEtowT.push_back(edepT); + } + } else { + bool ok = false; + for (unsigned int j = 0; j < hoID.size(); j++) { + if (id_ == hoID[j]) { + hoEtow[j] += edep; + hoEtowT[j] += edepT; + ok = true; + break; + } + } + if (!ok) { + hoID.push_back(id_); + hoEtow.push_back(edep); + hoEtowT.push_back(edepT); + } + } } } } // Now for towers and total energy deposits - for (int k=0; k<3; k++) { + for (int k = 0; k < 3; k++) { hit_[k]->Fill(double(nhit[k])); edepZon_[k]->Fill(etot[k]); edepZonT_[k]->Fill(etotT[k]); } hitTow_[0]->Fill(double(ebEtow.size())); - for (unsigned int i=0; iFill(ebEtow[i]); edepTWT_[0]->Fill(ebEtowT[i]); } hitTow_[1]->Fill(double(hbEtow.size())); - for (unsigned int i=0; iFill(hbEtow[i]); edepTWT_[1]->Fill(hbEtowT[i]); } hitTow_[2]->Fill(double(hoEtow.size())); - for (unsigned int i=0; iFill(hoEtow[i]); edepTWT_[2]->Fill(hoEtowT[i]); } - double eEB = scaleEB*etot[0]; - double eEBHB = eEB + scaleHB*etot[1]; - double eEBHBHO = eEBHB + scaleHB*scaleHO*etot[2]; + double eEB = scaleEB * etot[0]; + double eEBHB = eEB + scaleHB * etot[1]; + double eEBHBHO = eEBHB + scaleHB * scaleHO * etot[2]; eEB_->Fill(eEB); eEBHB_->Fill(eEBHB); eEBHBHO_->Fill(eEBHBHO); - double eEBT = scaleEB*etotT[0]; - double eEBHBT = eEBT + scaleHB*etotT[1]; - double eEBHBHOT = eEBHBT + scaleHB*scaleHO*etotT[2]; + double eEBT = scaleEB * etotT[0]; + double eEBHBT = eEBT + scaleHB * etotT[1]; + double eEBHBHOT = eEBHBT + scaleHB * scaleHO * etotT[2]; eEBT_->Fill(eEBT); eEBHBT_->Fill(eEBHBT); eEBHBHOT_->Fill(eEBHBHOT); - eHO1_->Fill(etaInc,eHO17+eHO18); - eHO2_->Fill(etaInc,phiInc,eHO17+eHO18); - eHO17_->Fill(etaInc,eHO17); - eHO18_->Fill(etaInc,eHO18); - eHO1T_->Fill(etaInc,eHO17T+eHO18T); - eHO2T_->Fill(etaInc,phiInc,eHO17T+eHO18T); - eHO17T_->Fill(etaInc,eHO17T); - eHO18T_->Fill(etaInc,eHO18T); - int nHO=0, nHOT=0; - if (eHO17 > 0) nHO++; - if (eHO17T > 0) nHOT++; - if (eHO18 > 0) nHO++; - if (eHO18T > 0) nHOT++; - nHO1_->Fill(etaInc,(double)(nHO)); - nHO2_->Fill(etaInc,phiInc,(double)(nHO)); - nHO1T_->Fill(etaInc,(double)(nHOT)); - nHO2T_->Fill(etaInc,phiInc,(double)(nHOT)); - int ieta=15; - for (int k=0; k<15; ++k) { - if (std::abs(etaInc) < 0.087*(k+1)) { - ieta = k; break; + eHO1_->Fill(etaInc, eHO17 + eHO18); + eHO2_->Fill(etaInc, phiInc, eHO17 + eHO18); + eHO17_->Fill(etaInc, eHO17); + eHO18_->Fill(etaInc, eHO18); + eHO1T_->Fill(etaInc, eHO17T + eHO18T); + eHO2T_->Fill(etaInc, phiInc, eHO17T + eHO18T); + eHO17T_->Fill(etaInc, eHO17T); + eHO18T_->Fill(etaInc, eHO18T); + int nHO = 0, nHOT = 0; + if (eHO17 > 0) + nHO++; + if (eHO17T > 0) + nHOT++; + if (eHO18 > 0) + nHO++; + if (eHO18T > 0) + nHOT++; + nHO1_->Fill(etaInc, (double)(nHO)); + nHO2_->Fill(etaInc, phiInc, (double)(nHO)); + nHO1T_->Fill(etaInc, (double)(nHOT)); + nHO2T_->Fill(etaInc, phiInc, (double)(nHOT)); + int ieta = 15; + for (int k = 0; k < 15; ++k) { + if (std::abs(etaInc) < 0.087 * (k + 1)) { + ieta = k; + break; } } - if (ieta>=0 && ieta<15) { - eHOE_[ieta]->Fill(eHO17+eHO18); + if (ieta >= 0 && ieta < 15) { + eHOE_[ieta]->Fill(eHO17 + eHO18); eHOE17_[ieta]->Fill(eHO17); eHOE18_[ieta]->Fill(eHO18); - eHOET_[ieta]->Fill(eHO17T+eHO18T); + eHOET_[ieta]->Fill(eHO17T + eHO18T); eHOE17T_[ieta]->Fill(eHO17T); eHOE18T_[ieta]->Fill(eHO18T); - eHOEta_[ieta]->Fill(eHOE17[ieta]+eHOE18[ieta]); + eHOEta_[ieta]->Fill(eHOE17[ieta] + eHOE18[ieta]); eHOEta17_[ieta]->Fill(eHOE17[ieta]); eHOEta18_[ieta]->Fill(eHOE18[ieta]); nHOE1_[ieta]->Fill((double)(nHO)); - nHOE2_[ieta]->Fill(phiInc,(double)(nHO)); + nHOE2_[ieta]->Fill(phiInc, (double)(nHO)); nHOE1T_[ieta]->Fill((double)(nHOT)); - nHOE2T_[ieta]->Fill(phiInc,(double)(nHOT)); - int nHOE=0, nHOET=0; - if (eHOE17[ieta] > 0) nHOE++; - if (eHOE17T[ieta] > 0) nHOET++; - if (eHOE18[ieta] > 0) nHOE++; - if (eHOE18T[ieta] > 0) nHOET++; + nHOE2T_[ieta]->Fill(phiInc, (double)(nHOT)); + int nHOE = 0, nHOET = 0; + if (eHOE17[ieta] > 0) + nHOE++; + if (eHOE17T[ieta] > 0) + nHOET++; + if (eHOE18[ieta] > 0) + nHOE++; + if (eHOE18T[ieta] > 0) + nHOET++; nHOEta1_[ieta]->Fill((double)(nHOE)); - nHOEta2_[ieta]->Fill(phiInc,(double)(nHOE)); + nHOEta2_[ieta]->Fill(phiInc, (double)(nHOE)); nHOEta1T_[ieta]->Fill((double)(nHOET)); - nHOEta2T_[ieta]->Fill(phiInc,(double)(nHOET)); + nHOEta2T_[ieta]->Fill(phiInc, (double)(nHOET)); } - - LogDebug("HitStudy") << "HOSimHitStudy::analyzeHits: Hits in EB " << nhit[0] - << " in " << ebEtow.size() << " towers with total E " - << etot[0] << "|" << etotT[0] - <<"\n Hits in HB " - << nhit[1] << " in " << hbEtow.size() - << " towers with total E " << etot[1] << "|" << etotT[1] - << "\n Hits in HO " - << nhit[2] << " in " << hoEtow.size() - << " towers with total E " << etot[2] << "|" << etotT[2] - << "\n Energy in EB " << eEB - << "|" << eEBT << " with HB " << eEBHB << "|" << eEBHBT - << " and with HO " << eEBHBHO << "|" << eEBHBHOT - << "\n E in HO layers " - << eHO17 <<"|" << eHO17T <<" " << eHO18 <<"|" << eHO18T - << " number of HO hits " << nHO << "|" << nHOT; - if (eEBHBHO > 0.75*maxEnergy && print_) { - edm::LogInfo("HitStudy") << "Event with excessive energy: EB = " << eEB - << " EB+HB = " << eEBHB << " EB+HB+HO = " - << eEBHBHO; + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::analyzeHits: Hits in EB " << nhit[0] << " in " << ebEtow.size() + << " towers with total E " << etot[0] << "|" << etotT[0] + << "\n Hits in HB " << nhit[1] << " in " << hbEtow.size() + << " towers with total E " << etot[1] << "|" << etotT[1] + << "\n Hits in HO " << nhit[2] << " in " << hoEtow.size() + << " towers with total E " << etot[2] << "|" << etotT[2] + << "\n Energy in EB " << eEB << "|" << eEBT << " with HB " + << eEBHB << "|" << eEBHBT << " and with HO " << eEBHBHO << "|" << eEBHBHOT + << "\n E in HO layers " << eHO17 << "|" << eHO17T << " " + << eHO18 << "|" << eHO18T << " number of HO hits " << nHO << "|" << nHOT; + + if (eEBHBHO > 0.75 * maxEnergy && print_) { + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::Event with excessive energy: EB = " << eEB << " EB+HB = " << eEBHB + << " EB+HB+HO = " << eEBHBHO; const std::string Dets[3] = {"EB", "HB", "HO"}; - for (int k=0; k<2; k++) { + for (int k = 0; k < 2; k++) { int nHit; if (k == 0) { - nHit = ecalHits.size(); + nHit = ecalHits.size(); } else { - nHit = hcalHits.size(); + nHit = hcalHits.size(); } - for (int i=0; i(HcalBarrel)) indx = 1; - else if (subdet == static_cast(HcalOuter)) indx = 2; - ieta = id.ieta(); - iphi = id.iphi(); - depth = id.depth(); - } - if (indx >= 0) { - edm::LogInfo("HitStudy") << Dets[indx] << " " << i << std::hex <(HcalBarrel)) + indx = 1; + else if (subdet == static_cast(HcalOuter)) + indx = 2; + ieta = id.ieta(); + iphi = id.iphi(); + depth = id.depth(); + } + if (indx >= 0) { + edm::LogVerbatim("HitStudy") << "HOSimHitStudy::" << Dets[indx] << " " << i << std::hex << id_ << std::dec + << " (" << ieta << "|" << iphi << "|" << depth << ") " << std::setw(8) << edep + << " " << std::setw(8) << time; + } } } } diff --git a/SimG4CMS/Calo/test/HcalSimHitDump.cc b/SimG4CMS/Calo/test/HcalSimHitDump.cc index 9556f889190ae..055a6772fbbc1 100644 --- a/SimG4CMS/Calo/test/HcalSimHitDump.cc +++ b/SimG4CMS/Calo/test/HcalSimHitDump.cc @@ -28,98 +28,93 @@ #include #include -class HcalSimHitDump: public edm::EDAnalyzer{ +class HcalSimHitDump : public edm::EDAnalyzer { public: - HcalSimHitDump(const edm::ParameterSet& ps); ~HcalSimHitDump() override {} protected: + void beginJob() override {} + void endJob() override {} + void analyze(const edm::Event& e, const edm::EventSetup& c) override; - void beginJob () override {} - void endJob () override {} - void analyze (const edm::Event& e, const edm::EventSetup& c) override; - - void analyzeHits (std::vector &); + void analyzeHits(std::vector&); private: - - std::string g4Label_, hitLab_; + std::string g4Label_, hitLab_; edm::EDGetTokenT toks_calo_; - int nevt_, maxEvent_; + int nevt_, maxEvent_; }; - HcalSimHitDump::HcalSimHitDump(const edm::ParameterSet& ps) : nevt_(0) { - - g4Label_ = ps.getUntrackedParameter("ModuleLabel","g4SimHits"); - hitLab_ = ps.getUntrackedParameter("HCCollection","HcalHits"); + g4Label_ = ps.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hitLab_ = ps.getUntrackedParameter("HCCollection", "HcalHits"); maxEvent_ = ps.getUntrackedParameter("MaxEvent", 10); // register for data access - toks_calo_ = consumes(edm::InputTag(g4Label_,hitLab_)); + toks_calo_ = consumes(edm::InputTag(g4Label_, hitLab_)); - edm::LogInfo("HitStudy") << "Module Label: " << g4Label_ << " Hits: " - << hitLab_ << " MzEvent " << maxEvent_; + edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Module Label: " << g4Label_ << " Hits: " << hitLab_ << " MaxEvent " + << maxEvent_; } -void HcalSimHitDump::analyze(const edm::Event& e, const edm::EventSetup& ) { - +void HcalSimHitDump::analyze(const edm::Event& e, const edm::EventSetup&) { ++nevt_; - edm::LogInfo("HitStudy") << "Serial # " << nevt_ << " Run # " - << e.id().run() << " Event # " << e.id().event(); + edm::LogVerbatim("HitStudy") << "HcalSimHitDump::Serial # " << nevt_ << " Run # " << e.id().run() << " Event # " + << e.id().event(); if (nevt_ <= maxEvent_) { std::vector hcHits; edm::Handle hitsCalo; - e.getByToken(toks_calo_,hitsCalo); + e.getByToken(toks_calo_, hitsCalo); if (hitsCalo.isValid()) { - edm::LogInfo("HitStudy") << "HcalValidation: get valid hist for Hcal"; + edm::LogVerbatim("HitStudy") << "HcalValidation: get valid hist for Hcal"; std::vector caloHits; - caloHits.insert(caloHits.end(),hitsCalo->begin(),hitsCalo->end()); - edm::LogInfo("HitStudy") << "HcalValidation: Hit buffer " - << caloHits.size(); - analyzeHits (caloHits); + caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end()); + edm::LogVerbatim("HitStudy") << "HcalValidation: Hit buffer " << caloHits.size(); + analyzeHits(caloHits); } } } -void HcalSimHitDump::analyzeHits (std::vector& hits) { - +void HcalSimHitDump::analyzeHits(std::vector& hits) { bool testN(false); - for (unsigned int k=1; k>28)&0xF); - if (det != 4) {testN = true; break;} + for (unsigned int k = 1; k < hits.size(); ++k) { + int det = (((hits[k].id()) >> 28) & 0xF); + if (det != 4) { + testN = true; + break; + } } - edm::LogInfo("HitStudy") << "Hit ID uses numbering scheme " << testN - << " (0 normal; 1 test)"; + edm::LogVerbatim("HitStudy") << "Hit ID uses numbering scheme " << testN << " (0 normal; 1 test)"; //Now the dump - for (unsigned int i=0; i @@ -15,7 +15,6 @@ // Created: Mon 2013/12/26 // - // system include files #include #include @@ -48,7 +47,7 @@ class HcalTestNumberingTester : public edm::one::EDAnalyzer<> { public: - explicit HcalTestNumberingTester( const edm::ParameterSet& ); + explicit HcalTestNumberingTester(const edm::ParameterSet&); ~HcalTestNumberingTester() override; void beginJob() override {} @@ -56,13 +55,12 @@ class HcalTestNumberingTester : public edm::one::EDAnalyzer<> { void endJob() override {} }; -HcalTestNumberingTester::HcalTestNumberingTester(const edm::ParameterSet& ) {} +HcalTestNumberingTester::HcalTestNumberingTester(const edm::ParameterSet&) {} HcalTestNumberingTester::~HcalTestNumberingTester() {} // ------------ method called to produce the data ------------ -void HcalTestNumberingTester::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - +void HcalTestNumberingTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { edm::ESHandle pHSNDC; iSetup.get().get(pHSNDC); edm::ESHandle pHRNDC; @@ -70,37 +68,37 @@ void HcalTestNumberingTester::analyze( const edm::Event& iEvent, const edm::Even if (pHSNDC.isValid() && pHRNDC.isValid()) { std::cout << "about to de-reference the edm's" << std::endl; - HcalDDDSimConstants* hcs = (HcalDDDSimConstants*)(&(*pHSNDC)); - HcalDDDRecConstants* hcr = (HcalDDDRecConstants*)(&(*pHRNDC)); - HcalNumberingScheme* schme1= new HcalNumberingScheme(); - HcalNumberingScheme* schme2= dynamic_cast(new HcalTestNumberingScheme(false)); + HcalDDDSimConstants* hcs = (HcalDDDSimConstants*)(&(*pHSNDC)); + HcalDDDRecConstants* hcr = (HcalDDDRecConstants*)(&(*pHRNDC)); + HcalNumberingScheme* schme1 = new HcalNumberingScheme(); + HcalNumberingScheme* schme2 = dynamic_cast(new HcalTestNumberingScheme(false)); - for (int type=0; type<2; ++type) { + for (int type = 0; type < 2; ++type) { HcalSubdetector sub = (type == 0) ? HcalBarrel : HcalEndcap; - for (int zs = 0; zs<2; ++zs) { - int zside = 2*zs - 1; - std::pair etas = hcr->getEtaRange(type); - for (int eta=etas.first; eta<=etas.second; ++eta) { - std::vector > phis = hcr->getPhis(sub,eta); - for (unsigned int k=0; k etd = hcs->getEtaDepth(sub,eta,phi,zside,0,lay); - HcalNumberingFromDDD::HcalID tmp(sub,zs,etd.second,etd.first,phi,phi,lay); - uint32_t id1 = schme1->getUnitID(tmp); - uint32_t id2 = schme2->getUnitID(tmp); - DetId id0 = HcalHitRelabeller::relabel(id2,hcr); - std::cout << "I/P " << sub << ":" << zside*eta << ":" << phi - << ":" << lay << " Normal " << std::hex << id1 - << std::dec << " " << HcalDetId(id1) << " Test " - << std::hex << id2 << std::dec << " " << HcalDetId(id0); - if (id1 != id0.rawId()) std::cout << " *** ERROR ***"; - std::cout << std::endl; - } - } - } + for (int zs = 0; zs < 2; ++zs) { + int zside = 2 * zs - 1; + std::pair etas = hcr->getEtaRange(type); + for (int eta = etas.first; eta <= etas.second; ++eta) { + std::vector > phis = hcr->getPhis(sub, eta); + for (unsigned int k = 0; k < phis.size(); ++k) { + int phi = phis[k].first; + int lmin = (type == 1 && eta == 16) ? 8 : 1; + int lmax = (type == 1) ? 19 : ((eta == 16) ? 7 : 17); + for (int lay = lmin; lay <= lmax; ++lay) { + std::pair etd = hcs->getEtaDepth(sub, eta, phi, zside, 0, lay); + HcalNumberingFromDDD::HcalID tmp(sub, zs, etd.second, etd.first, phi, phi, lay); + uint32_t id1 = schme1->getUnitID(tmp); + uint32_t id2 = schme2->getUnitID(tmp); + DetId id0 = HcalHitRelabeller::relabel(id2, hcr); + std::cout << "I/P " << sub << ":" << zside * eta << ":" << phi << ":" << lay << " Normal " << std::hex + << id1 << std::dec << " " << HcalDetId(id1) << " Test " << std::hex << id2 << std::dec << " " + << HcalDetId(id0); + if (id1 != id0.rawId()) + std::cout << " *** ERROR ***"; + std::cout << std::endl; + } + } + } } } } diff --git a/SimG4CMS/Calo/test/HitParentTest.cc b/SimG4CMS/Calo/test/HitParentTest.cc index 0da025677c19c..9fdb16ebca239 100644 --- a/SimG4CMS/Calo/test/HitParentTest.cc +++ b/SimG4CMS/Calo/test/HitParentTest.cc @@ -33,16 +33,13 @@ #include #include -class HitParentTest: public edm::one::EDAnalyzer { - +class HitParentTest : public edm::one::EDAnalyzer { public: - HitParentTest(const edm::ParameterSet& ps); ~HitParentTest() override {} static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); protected: - void beginJob() override; void beginRun(edm::Run const&, edm::EventSetup const&) override {} void analyze(const edm::Event& e, const edm::EventSetup& c) override; @@ -50,10 +47,9 @@ class HitParentTest: public edm::one::EDAnalyzer &, int type); - void analyzeAPDHits(const std::vector &, int depth); + void analyzeHits(const std::vector&, int type); + void analyzeAPDHits(const std::vector&, int depth); bool simTrackPresent(int id); math::XYZTLorentzVectorD getOldestParentVertex(edm::SimTrackContainer::const_iterator track); @@ -61,8 +57,7 @@ class HitParentTest: public edm::one::EDAnalyzer tok_eb_; edm::EDGetTokenT tok_ee_; edm::EDGetTokenT tok_es_; @@ -71,212 +66,213 @@ class HitParentTest: public edm::one::EDAnalyzer tok_vtx_; /** error and other counters */ - unsigned int total_num_apd_hits_seen[2]; - unsigned int num_apd_hits_no_parent[2]; + unsigned int total_num_apd_hits_seen[2]; + unsigned int num_apd_hits_no_parent[2]; /** number of apd hits for which the parent sim track id was not found in the simtrack collection. */ - unsigned int num_apd_hits_no_simtrack[2]; + unsigned int num_apd_hits_no_simtrack[2]; /** number of APD hits for which no generator particle was found */ - unsigned int num_apd_hits_no_gen_particle[2]; + unsigned int num_apd_hits_no_gen_particle[2]; - edm::Handle SimTk; + edm::Handle SimTk; edm::Handle SimVtx; /** 'histogram' of types of particles going through the APD. Maps from numeric particle code to the number of occurences. */ - std::map particle_type_count; + std::map particle_type_count; - std::string detector[7]; - bool histos; - unsigned int totalHits[7], noParent[7]; - unsigned int noSimTrack[7], noGenParticle[7]; - TH1F *hitType[7], *hitRho[7], *hitZ[7]; + std::string detector[7]; + bool histos; + unsigned int totalHits[7], noParent[7]; + unsigned int noSimTrack[7], noGenParticle[7]; + TH1F *hitType[7], *hitRho[7], *hitZ[7]; }; HitParentTest::HitParentTest(const edm::ParameterSet& ps) { - usesResource(TFileService::kSharedResource); - sourceLabel = ps.getUntrackedParameter("SourceLabel","VtxSmeared"); - g4Label = ps.getUntrackedParameter("ModuleLabel","g4SimHits"); - hitLabEB= ps.getUntrackedParameter("EBCollection","EcalHitsEB"); - hitLabEE= ps.getUntrackedParameter("EECollection","EcalHitsEE"); - hitLabES= ps.getUntrackedParameter("ESCollection","EcalHitsES"); - hitLabHC= ps.getUntrackedParameter("HCCollection","HcalHits"); - edm::LogInfo("HitParentTest") << "Module Label: " << g4Label << " Hits: " - << hitLabEB << ", " << hitLabEE << ", " - << hitLabES << ", " << hitLabHC; - - tok_eb_ = consumes(edm::InputTag(g4Label,hitLabEB)); - tok_ee_ = consumes(edm::InputTag(g4Label,hitLabEE)); - tok_es_ = consumes(edm::InputTag(g4Label,hitLabES)); - tok_hc_ = consumes(edm::InputTag(g4Label,hitLabHC)); + sourceLabel = ps.getUntrackedParameter("SourceLabel", "VtxSmeared"); + g4Label = ps.getUntrackedParameter("ModuleLabel", "g4SimHits"); + hitLabEB = ps.getUntrackedParameter("EBCollection", "EcalHitsEB"); + hitLabEE = ps.getUntrackedParameter("EECollection", "EcalHitsEE"); + hitLabES = ps.getUntrackedParameter("ESCollection", "EcalHitsES"); + hitLabHC = ps.getUntrackedParameter("HCCollection", "HcalHits"); + edm::LogVerbatim("HitParentTest") << "Module Label: " << g4Label << " Hits: " << hitLabEB << ", " << hitLabEE + << ", " << hitLabES << ", " << hitLabHC; + + tok_eb_ = consumes(edm::InputTag(g4Label, hitLabEB)); + tok_ee_ = consumes(edm::InputTag(g4Label, hitLabEE)); + tok_es_ = consumes(edm::InputTag(g4Label, hitLabES)); + tok_hc_ = consumes(edm::InputTag(g4Label, hitLabHC)); tok_tk_ = consumes(edm::InputTag(g4Label)); tok_vtx_ = consumes(edm::InputTag(g4Label)); - for (unsigned int i=0; i<2; ++i) { - total_num_apd_hits_seen[i] = 0; - num_apd_hits_no_parent[i] = 0; - num_apd_hits_no_simtrack[i] = 0; + for (unsigned int i = 0; i < 2; ++i) { + total_num_apd_hits_seen[i] = 0; + num_apd_hits_no_parent[i] = 0; + num_apd_hits_no_simtrack[i] = 0; num_apd_hits_no_gen_particle[i] = 0; } std::string dets[7] = {"EB", "EE", "ES", "HB", "HE", "HO", "HF"}; - for (unsigned int i=0; i<7; ++i) { - detector[i] = dets[i]; - totalHits[i] = 0; - noParent[i] = 0; - noSimTrack[i] = 0; + for (unsigned int i = 0; i < 7; ++i) { + detector[i] = dets[i]; + totalHits[i] = 0; + noParent[i] = 0; + noSimTrack[i] = 0; noGenParticle[i] = 0; } } void HitParentTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.addUntracked("SourceLabel","generatorSmeared"); - desc.addUntracked("ModuleLabel","g4SimHits"); - desc.addUntracked("EBCollection","EcalHitsEB"); - desc.addUntracked("EECollection","EcalHitsEE"); - desc.addUntracked("ESCollection","EcalHitsES"); - desc.addUntracked("HCCollection","HcalHits"); - descriptions.add("HitParentTest",desc); + desc.addUntracked("SourceLabel", "generatorSmeared"); + desc.addUntracked("ModuleLabel", "g4SimHits"); + desc.addUntracked("EBCollection", "EcalHitsEB"); + desc.addUntracked("EECollection", "EcalHitsEE"); + desc.addUntracked("ESCollection", "EcalHitsES"); + desc.addUntracked("HCCollection", "HcalHits"); + descriptions.add("HitParentTest", desc); } void HitParentTest::beginJob() { - edm::Service tfile; - if ( !tfile.isAvailable() ) { - edm::LogInfo("HitParentTest") << "TFileService unavailable: no histograms"; + if (!tfile.isAvailable()) { + edm::LogVerbatim("HitParentTest") << "TFileService unavailable: no histograms"; histos = false; } else { - char name[20], title[100]; + char name[20], title[100]; histos = true; - for (unsigned int i=0; i<7; ++i) { - sprintf (name, "HitType%d", i); - sprintf (title, "Hit types for %s", detector[i].c_str()); + for (unsigned int i = 0; i < 7; ++i) { + sprintf(name, "HitType%d", i); + sprintf(title, "Hit types for %s", detector[i].c_str()); hitType[i] = tfile->make(name, title, 10, 0., 10.); hitType[i]->GetXaxis()->SetTitle(title); hitType[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "RhoVertex%d", i); - sprintf (title, "#rho of the vertex for %s Hits", detector[i].c_str()); + sprintf(name, "RhoVertex%d", i); + sprintf(title, "#rho of the vertex for %s Hits", detector[i].c_str()); hitRho[i] = tfile->make(name, title, 10000, 0., 100.); hitRho[i]->GetXaxis()->SetTitle(title); hitRho[i]->GetYaxis()->SetTitle("Hits"); - sprintf (name, "ZVertex%d", i); - sprintf (title, "z of the vertex for %s Hits", detector[i].c_str()); + sprintf(name, "ZVertex%d", i); + sprintf(title, "z of the vertex for %s Hits", detector[i].c_str()); hitZ[i] = tfile->make(name, title, 2000, -100., 100.); hitZ[i]->GetXaxis()->SetTitle(title); hitZ[i]->GetYaxis()->SetTitle("Hits"); } - } + } } -void HitParentTest::analyze(const edm::Event& e, const edm::EventSetup& ) { - - LogDebug("HitParentTest") << "Run = " << e.id().run() << " Event = " - << e.id().event(); +void HitParentTest::analyze(const edm::Event& e, const edm::EventSetup&) { + edm::LogVerbatim("HitParentTest") << "HitParentTes::Run = " << e.id().run() << " Event = " << e.id().event(); // get PCaloHits for ecal barrel edm::Handle caloHitEB; - e.getByToken(tok_eb_,caloHitEB); + e.getByToken(tok_eb_, caloHitEB); // get PCaloHits for ecal endcap edm::Handle caloHitEE; - e.getByToken(tok_ee_,caloHitEE); + e.getByToken(tok_ee_, caloHitEE); // get PCaloHits for preshower edm::Handle caloHitES; - e.getByToken(tok_es_,caloHitES); + e.getByToken(tok_es_, caloHitES); // get PCaloHits for hcal edm::Handle caloHitHC; - e.getByToken(tok_hc_,caloHitHC); + e.getByToken(tok_hc_, caloHitHC); // get sim tracks e.getByToken(tok_tk_, SimTk); - + // get sim vertices e.getByToken(tok_vtx_, SimVtx); - - LogDebug("HitParentTest") << "HitParentTest: hits valid[EB]: " << caloHitEB.isValid() << " valid[EE]: " << caloHitEE.isValid() << " valid[ES]: " << caloHitES.isValid() << " valid[HC]: " << caloHitHC.isValid(); - + + edm::LogVerbatim("HitParentTest") << "HitParentTest: hits valid[EB]: " << caloHitEB.isValid() + << " valid[EE]: " << caloHitEE.isValid() << " valid[ES]: " << caloHitES.isValid() + << " valid[HC]: " << caloHitHC.isValid(); + if (caloHitEB.isValid()) { for (int depth = 1; depth <= 2; ++depth) analyzeAPDHits(*caloHitEB, depth); analyzeHits(*caloHitEB, 0); } - if (caloHitEE.isValid()) analyzeHits(*caloHitEE, 1); - if (caloHitES.isValid()) analyzeHits(*caloHitES, 2); - if (caloHitHC.isValid()) analyzeHits(*caloHitHC, 3); - + if (caloHitEE.isValid()) + analyzeHits(*caloHitEE, 1); + if (caloHitES.isValid()) + analyzeHits(*caloHitES, 2); + if (caloHitHC.isValid()) + analyzeHits(*caloHitHC, 3); } /** define the comparison for sorting the particle ids counting map */ class HitParentTestComparison { - protected: - const std::map &particle_type_count; + const std::map& particle_type_count; public: - HitParentTestComparison(const std::map &_particle_type_count) : - particle_type_count(_particle_type_count) {} + HitParentTestComparison(const std::map& _particle_type_count) + : particle_type_count(_particle_type_count) {} - bool operator()(int pid1, int pid2) const { - return particle_type_count.at(pid1) > particle_type_count.at(pid2); - } + bool operator()(int pid1, int pid2) const { return particle_type_count.at(pid1) > particle_type_count.at(pid2); } }; void HitParentTest::endJob() { - - edm::LogVerbatim("HitParentTest") << "Total number of APD hits seen: " << total_num_apd_hits_seen[0]+ total_num_apd_hits_seen[1]; - for (unsigned int depth=0; depth<2; ++depth) { - edm::LogVerbatim("HitParentTest") << "APD Hits in depth = " << depth+1 << " Total = " << total_num_apd_hits_seen[depth]; - edm::LogVerbatim("HitParentTest") << "summary of errors:"; - edm::LogVerbatim("HitParentTest") << "number of APD hits with zero geant track id: " << num_apd_hits_no_parent[depth]; - edm::LogVerbatim("HitParentTest") << "number of APD hits for which the parent simtrack was not found in the simtrack collection: " << num_apd_hits_no_simtrack[depth]; - edm::LogVerbatim("HitParentTest") << "number of APD hits for which no generator particle was found: " << num_apd_hits_no_gen_particle[depth]; - edm::LogVerbatim("HitParentTest") << ""; + edm::LogVerbatim("HitParentTest") << "HitParentTest::Total number of APD hits seen: " + << total_num_apd_hits_seen[0] + total_num_apd_hits_seen[1]; + for (unsigned int depth = 0; depth < 2; ++depth) { + edm::LogVerbatim("HitParentTest") << "APD Hits in depth = " << depth + 1 + << " Total = " << total_num_apd_hits_seen[depth]; + edm::LogVerbatim("HitParentTest") << "summary of errors:\n" + << " number of APD hits with zero geant track id: " + << num_apd_hits_no_parent[depth] << "\n" + << "number of APD hits for which the parent simtrack was not found " + << "in the simtrack collection: " << num_apd_hits_no_simtrack[depth] << "\n" + << "number of APD hits for which no generator particle was " + << "found: " << num_apd_hits_no_gen_particle[depth] << "\n"; } - for (unsigned int det=0; det<7; ++det) { + for (unsigned int det = 0; det < 7; ++det) { edm::LogVerbatim("HitParentTest") << "Total number of hits seen in " << detector[det] << ": " << totalHits[det]; - edm::LogVerbatim("HitParentTest") << "summary of errors:"; - edm::LogVerbatim("HitParentTest") << "number of hits with zero geant track id: " << noParent[det]; - edm::LogVerbatim("HitParentTest") << "number of hits for which the parent simtrack was not found in the simtrack collection: " << noSimTrack[det]; - edm::LogVerbatim("HitParentTest") << "number of hits for which no generator particle was found: " << noGenParticle[det]; - edm::LogVerbatim("HitParentTest") << ""; - } - - // sort in decreasing order of occurence + edm::LogVerbatim("HitParentTest") << "summary of errors:\n" + << "number of hits with zero geant track id: " << noParent[det] << "\n" + << "number of hits for which the parent simtrack was not found in " + << "the simtrack collection: " << noSimTrack[det] << "\n" + << "number of hits for which no generator particle was found: " + << noGenParticle[det] << "\n"; + } + + // sort in decreasing order of occurence std::vector sorted_pids; for (std::map::const_iterator it = particle_type_count.begin(); it != particle_type_count.end(); ++it) sorted_pids.push_back(it->first); - // now sort the pids + // now sort the pids - std::sort(sorted_pids.begin(), sorted_pids.end(), HitParentTestComparison(particle_type_count)); + std::sort(sorted_pids.begin(), sorted_pids.end(), HitParentTestComparison(particle_type_count)); - edm::LogVerbatim("HitParentTest") << "frequency particle types through the APD (pid/frequency):"; + edm::LogVerbatim("HitParentTest") << "HitParentTest::Frequency particle types through the APD " + << "(pid/frequency):"; for (unsigned i = 0; i < sorted_pids.size(); ++i) { int pid = sorted_pids[i]; - edm::LogVerbatim("HitParentTest") << " pid " << boost::format("%6d") % pid << ": count " - << boost::format("%6d") % particle_type_count[pid]; - } - + edm::LogVerbatim("HitParentTest") << " pid " << boost::format("%6d") % pid << ": count " + << boost::format("%6d") % particle_type_count[pid]; + } } void HitParentTest::analyzeHits(const std::vector& hits, int type) { - for (std::vector::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) { int id(type), flag(0); if (type == 3) { - HcalDetId id_ = HcalDetId(hit_it->id()); - int subdet = id_.subdet(); - if (subdet == static_cast(HcalEndcap)) id = type+1; - else if (subdet == static_cast(HcalOuter)) id = type+2; - else if (subdet == static_cast(HcalForward)) id = type+3; + HcalDetId id_ = HcalDetId(hit_it->id()); + int subdet = id_.subdet(); + if (subdet == static_cast(HcalEndcap)) + id = type + 1; + else if (subdet == static_cast(HcalOuter)) + id = type + 2; + else if (subdet == static_cast(HcalForward)) + id = type + 3; } ++totalHits[id]; @@ -290,112 +286,115 @@ void HitParentTest::analyzeHits(const std::vector& hits, int type) { bool found = false; flag = 2; // check whether this id is actually there in the list of simtracks - for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found; ++simTrkItr) { - if (hit_geant_track_id == (int)(simTrkItr->trackId())) { - found = true; - flag = 3; - bool match = validSimTrack(hit_geant_track_id, simTrkItr); - - LogDebug("HitParentTest") << "[" << detector[type] << "] Match = " << match << " hit_geant_track_id=" << hit_geant_track_id << " particle id=" << simTrkItr->type(); - - if (!match) { - LogDebug("HitParentTest") << "NO MATCH FOUND !"; - ++noGenParticle[id]; - } - - // beam pipe... - int pid = simTrkItr->type(); - math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr); - - edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr); - - LogDebug("HitParentTest") << "[" << detector[type] << "] Hit pid = " << pid - << " hit track id = " << hit_geant_track_id - << " Oldest Parent's Vertex: " << oldest_parent_vertex - << " rho = " << oldest_parent_vertex.Rho() - << " Oldest Parent's pid: " << oldest_parent_track->type() - << " Oldest Parent's track id: " << oldest_parent_track->trackId() - << "\nHit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")" - << "\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex() << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex()); - if (histos) { - hitRho[id]->Fill(oldest_parent_vertex.Rho()); - hitZ[id]->Fill(oldest_parent_vertex.Z()); - } - } // a match was found - } // geant track id found in simtracks - - if (!found) ++noSimTrack[id]; - } // hits with a valid SimTrack Id - if (histos) hitType[id]->Fill((double)(flag)); - } // loop over all calohits (of the given depth) + for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found; + ++simTrkItr) { + if (hit_geant_track_id == (int)(simTrkItr->trackId())) { + found = true; + flag = 3; + bool match = validSimTrack(hit_geant_track_id, simTrkItr); + + edm::LogVerbatim("HitParentTest") + << "[" << detector[type] << "] Match = " << match << " hit_geant_track_id=" << hit_geant_track_id + << " particle id=" << simTrkItr->type(); + + if (!match) { + edm::LogVerbatim("HitParentTest") << "NO MATCH FOUND !"; + ++noGenParticle[id]; + } + + // beam pipe... + int pid = simTrkItr->type(); + math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr); + + edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr); + + edm::LogVerbatim("HitParentTest") + << "[" << detector[type] << "] Hit pid = " << pid << " hit track id = " << hit_geant_track_id + << " Oldest Parent's Vertex: " << oldest_parent_vertex << " rho = " << oldest_parent_vertex.Rho() + << " Oldest Parent's pid: " << oldest_parent_track->type() + << " Oldest Parent's track id: " << oldest_parent_track->trackId() + << "\nHit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")" + << "\nHit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex() + << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex()); + if (histos) { + hitRho[id]->Fill(oldest_parent_vertex.Rho()); + hitZ[id]->Fill(oldest_parent_vertex.Z()); + } + } // a match was found + } // geant track id found in simtracks + + if (!found) + ++noSimTrack[id]; + } // hits with a valid SimTrack Id + if (histos) + hitType[id]->Fill((double)(flag)); + } // loop over all calohits (of the given depth) } void HitParentTest::analyzeAPDHits(const std::vector& hits, int depth) { - for (std::vector::const_iterator hit_it = hits.begin(); hit_it != hits.end(); ++hit_it) { - if (hit_it->depth() == depth) { - - ++total_num_apd_hits_seen[depth-1]; + ++total_num_apd_hits_seen[depth - 1]; // get the geant track id int hit_geant_track_id = hit_it->geantTrackId(); if (hit_geant_track_id <= 0) { - ++num_apd_hits_no_parent[depth-1]; + ++num_apd_hits_no_parent[depth - 1]; } else { - - bool found = false; - // check whether this id is actually there in the list of simtracks - for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found; ++simTrkItr) { - if (hit_geant_track_id == (int)(simTrkItr->trackId())) { - found = true; - bool match = validSimTrack(hit_geant_track_id, simTrkItr); - - edm::LogInfo("HitParentTest") << "APDHIT Match = " << match << " hit_geant_track_id = " << hit_geant_track_id << " particle id=" << simTrkItr->type(); - - if (!match) { - edm::LogInfo("HitParentTest") << "NO MATCH FOUND !"; - ++num_apd_hits_no_gen_particle[depth-1]; - } - - int apd_pid = simTrkItr->type(); - std::map::iterator count_it = particle_type_count.find(apd_pid); - if (count_it == particle_type_count.end()) - // first occurence of this particle pid - particle_type_count[apd_pid] = 1; - else - ++count_it->second; - - //-------------------- - // check where the oldest parent has its vertex. Should be close to the - // beam pipe... - math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr); - - edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr); - - edm::LogInfo("HitParentTest") << "APD hit pid = " << apd_pid - << " APD hit track id = " << hit_geant_track_id - << " depth = " << hit_it->depth() - << " OLDEST PARENT'S VERTEX: " << oldest_parent_vertex - << " rho = " << oldest_parent_vertex.Rho() - << " OLDEST PARENT'S PID: " << oldest_parent_track->type() - << " OLDEST PARENT'S track id: " << oldest_parent_track->trackId() << "\n" - << "APD hit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")" << "\n" - << "APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex() << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex()); - - } // a match was found - } // geant track id found in simtracks - - if (!found) - ++num_apd_hits_no_simtrack[depth-1]; - } // hits with a valid SimTrack Id - } // right depth index - } // loop over all calohits (of the given depth) + bool found = false; + // check whether this id is actually there in the list of simtracks + for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end() && !found; + ++simTrkItr) { + if (hit_geant_track_id == (int)(simTrkItr->trackId())) { + found = true; + bool match = validSimTrack(hit_geant_track_id, simTrkItr); + + edm::LogVerbatim("HitParentTest") + << "APDHIT Match = " << match << " hit_geant_track_id = " << hit_geant_track_id + << " particle id=" << simTrkItr->type(); + + if (!match) { + edm::LogVerbatim("HitParentTest") << "NO MATCH FOUND !"; + ++num_apd_hits_no_gen_particle[depth - 1]; + } + + int apd_pid = simTrkItr->type(); + std::map::iterator count_it = particle_type_count.find(apd_pid); + if (count_it == particle_type_count.end()) + // first occurence of this particle pid + particle_type_count[apd_pid] = 1; + else + ++count_it->second; + + //-------------------- + // check where the oldest parent has its vertex. Should be close to the + // beam pipe... + math::XYZTLorentzVectorD oldest_parent_vertex = getOldestParentVertex(simTrkItr); + + edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(simTrkItr); + + edm::LogVerbatim("HitParentTest") + << "APD hit pid = " << apd_pid << " APD hit track id = " << hit_geant_track_id + << " depth = " << hit_it->depth() << " OLDEST PARENT'S VERTEX: " << oldest_parent_vertex + << " rho = " << oldest_parent_vertex.Rho() << " OLDEST PARENT'S PID: " << oldest_parent_track->type() + << " OLDEST PARENT'S track id: " << oldest_parent_track->trackId() << "\n" + << "APD hit vertex index: " << simTrkItr->vertIndex() << " (tot #vertices: " << SimVtx->size() << ")" + << "\n" + << "APD hit vertex parent track: " << (*SimVtx)[simTrkItr->vertIndex()].parentIndex() + << " present=" << simTrackPresent((*SimVtx)[simTrkItr->vertIndex()].parentIndex()); + + } // a match was found + } // geant track id found in simtracks + + if (!found) + ++num_apd_hits_no_simtrack[depth - 1]; + } // hits with a valid SimTrack Id + } // right depth index + } // loop over all calohits (of the given depth) } bool HitParentTest::simTrackPresent(int id) { - for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); ++simTrkItr) { if ((int)(simTrkItr->trackId()) == id) return true; @@ -404,9 +403,9 @@ bool HitParentTest::simTrackPresent(int id) { } math::XYZTLorentzVectorD HitParentTest::getOldestParentVertex(edm::SimTrackContainer::const_iterator track) { + static const math::XYZTLorentzVectorD invalid_vertex( + 10000, 10000, 10000, 10000); // default value if no valid vertex found - static const math::XYZTLorentzVectorD invalid_vertex(10000,10000,10000,10000); // default value if no valid vertex found - edm::SimTrackContainer::const_iterator oldest_parent_track = parentSimTrack(track); int vertex_index = oldest_parent_track->vertIndex(); @@ -419,70 +418,79 @@ math::XYZTLorentzVectorD HitParentTest::getOldestParentVertex(edm::SimTrackConta } edm::SimTrackContainer::const_iterator HitParentTest::parentSimTrack(edm::SimTrackContainer::const_iterator thisTrkItr) { - edm::SimTrackContainer::const_iterator itr = SimTk->end(); int vertIndex = thisTrkItr->vertIndex(); - int type = thisTrkItr->type(); int charge = (int)thisTrkItr->charge(); - LogDebug("HitParentTest") << "SimTrackParent " << thisTrkItr->trackId() << " Vertex " << vertIndex << " Type " << type << " Charge " << charge << std::endl; - - if( vertIndex == -1 ) return thisTrkItr; - else if (vertIndex >= (int)SimVtx->size()) return itr; - - edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); - for (int iv=0; ivtype(); + int charge = (int)thisTrkItr->charge(); + edm::LogVerbatim("HitParentTest") << "SimTrackParent:: " << thisTrkItr->trackId() << " Vertex " << vertIndex + << " Type " << type << " Charge " << charge; + + if (vertIndex == -1) + return thisTrkItr; + else if (vertIndex >= (int)SimVtx->size()) + return itr; + + edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin(); + for (int iv = 0; iv < vertIndex; iv++) + simVtxItr++; int parent = simVtxItr->parentIndex(); if (parent < 0 && simVtxItr != SimVtx->begin()) { const math::XYZTLorentzVectorD pos1 = simVtxItr->position(); - for (simVtxItr=SimVtx->begin(); simVtxItr!=SimVtx->end(); ++simVtxItr) { + for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) { if (simVtxItr->parentIndex() > 0) { - const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position(); - double dist = pos2.P(); - if (dist < 0.001) { - parent = simVtxItr->parentIndex(); - break; - } + const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position(); + double dist = pos2.P(); + if (dist < 0.001) { + parent = simVtxItr->parentIndex(); + break; + } } } } - for (edm::SimTrackContainer::const_iterator simTrkItr= SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++){ - if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr) return parentSimTrack(simTrkItr); + for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) { + if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr) + return parentSimTrack(simTrkItr); } return thisTrkItr; } bool HitParentTest::validSimTrack(unsigned int simTkId, edm::SimTrackContainer::const_iterator thisTrkItr) { - - LogDebug("HitParentTest") << "Inside validSimTrack: trackId " << thisTrkItr->trackId() << " vtxIndex " << thisTrkItr->vertIndex() << " to be matched to " << simTkId; + edm::LogVerbatim("HitParentTest") << "Inside validSimTrack: trackId " << thisTrkItr->trackId() << " vtxIndex " + << thisTrkItr->vertIndex() << " to be matched to " << simTkId; //This track originates from simTkId - if (thisTrkItr->trackId() == simTkId) return true; + if (thisTrkItr->trackId() == simTkId) + return true; //Otherwise trace back the history using SimTracks and SimVertices int vertIndex = thisTrkItr->vertIndex(); - if (vertIndex == -1 || vertIndex >= (int)SimVtx->size()) return false; - edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); - for (int iv=0; iv= (int)SimVtx->size()) + return false; + edm::SimVertexContainer::const_iterator simVtxItr = SimVtx->begin(); + for (int iv = 0; iv < vertIndex; iv++) + simVtxItr++; int parent = simVtxItr->parentIndex(); - LogDebug("HitParentTest") << "validSimTrack:: parent index " << parent <<" "; + edm::LogVerbatim("HitParentTest") << "validSimTrack:: parent index " << parent << " "; if (parent < 0 && simVtxItr != SimVtx->begin()) { const math::XYZTLorentzVectorD pos1 = simVtxItr->position(); - for (simVtxItr=SimVtx->begin(); simVtxItr!=SimVtx->end(); ++simVtxItr) { + for (simVtxItr = SimVtx->begin(); simVtxItr != SimVtx->end(); ++simVtxItr) { if (simVtxItr->parentIndex() > 0) { - const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position(); - double dist = pos2.P(); - if (dist < 0.001) { - parent = simVtxItr->parentIndex(); - break; - } + const math::XYZTLorentzVectorD pos2 = pos1 - simVtxItr->position(); + double dist = pos2.P(); + if (dist < 0.001) { + parent = simVtxItr->parentIndex(); + break; + } } } } - LogDebug("HitParentTest") << "final index " << parent; - for (edm::SimTrackContainer::const_iterator simTrkItr= SimTk->begin(); simTrkItr!= SimTk->end(); simTrkItr++){ - if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr) return validSimTrack(simTkId, simTrkItr) ; + edm::LogVerbatim("HitParentTest") << "HitParentTes::final index " << parent; + for (edm::SimTrackContainer::const_iterator simTrkItr = SimTk->begin(); simTrkItr != SimTk->end(); simTrkItr++) { + if ((int)simTrkItr->trackId() == parent && simTrkItr != thisTrkItr) + return validSimTrack(simTkId, simTrkItr); } return false; From f2a7a2303d97d7b9a41630c28df41bd08921e765 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 12 Apr 2019 17:40:31 +0200 Subject: [PATCH 616/686] add a missing include --- SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc index c61af8581117d..69517d8c0ab7f 100644 --- a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc +++ b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc @@ -14,6 +14,7 @@ ////////////////////////////////////////////////////////////// #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimG4Core/Notification/interface/SimG4Exception.h" #include "SimG4CMS/Calo/interface/CaloG4Hit.h" #include "SimG4CMS/Calo/interface/CaloG4HitCollection.h" From f0a7f854114089f4ed2b1a2ff1f76f3d91464cfc Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 04:06:29 +0200 Subject: [PATCH 617/686] Fix clang warnings in Calibration/HcalAlCaRecoProducers --- .../interface/AlCaEcalHcalReadoutsProducer.h | 14 +- .../interface/AlCaHcalNoiseProducer.h | 31 +- .../plugins/AlCaGammaJetSelector.cc | 63 +- .../plugins/AlCaHBHEMuonFilter.cc | 199 ++- .../plugins/AlCaHEMuonFilter.cc | 238 ++-- .../plugins/AlCaIsoTracksFilter.cc | 520 ++++---- .../plugins/AlCaIsoTracksProducerFilter.cc | 132 +- .../plugins/AlCaIsolatedBunchFilter.cc | 180 ++- .../plugins/AlCaIsolatedBunchSelector.cc | 99 +- .../plugins/AlCaLowPUHBHEMuonFilter.cc | 199 ++- .../plugins/ConeDefinition.h | 119 +- .../plugins/PrescalerFHN.cc | 138 +- .../src/AlCaDiJetsProducer.cc | 170 +-- .../src/AlCaEcalHcalReadoutsProducer.cc | 104 +- .../src/AlCaGammaJetProducer.cc | 318 +++-- .../src/AlCaHBHEMuonProducer.cc | 150 +-- .../src/AlCaHOCalibProducer.cc | 1132 +++++++++-------- .../src/AlCaHcalNoiseProducer.cc | 406 +++--- .../src/AlCaIsoTracksProducer.cc | 599 ++++----- .../src/ProducerAnalyzer.cc | 393 +++--- .../src/ProducerAnalyzer.h | 75 +- 21 files changed, 2571 insertions(+), 2708 deletions(-) diff --git a/Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h b/Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h index 7e49bf4afd742..9a8a8eb07eea5 100644 --- a/Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h +++ b/Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h @@ -1,6 +1,5 @@ // -*- C++ -*- - // system include files #include #include @@ -35,17 +34,16 @@ // class AlCaEcalHcalReadoutsProducer : public edm::EDProducer { - public: - explicit AlCaEcalHcalReadoutsProducer(const edm::ParameterSet&); - ~AlCaEcalHcalReadoutsProducer() override; +public: + explicit AlCaEcalHcalReadoutsProducer(const edm::ParameterSet &); + ~AlCaEcalHcalReadoutsProducer() override; + void produce(edm::Event &, const edm::EventSetup &) override; - void produce(edm::Event &, const edm::EventSetup&) override; - private: - // ----------member data --------------------------- +private: + // ----------member data --------------------------- edm::EDGetTokenT tok_hbhe_; edm::EDGetTokenT tok_ho_; edm::EDGetTokenT tok_hf_; - }; diff --git a/Calibration/HcalAlCaRecoProducers/interface/AlCaHcalNoiseProducer.h b/Calibration/HcalAlCaRecoProducers/interface/AlCaHcalNoiseProducer.h index 1a6b2f9981ecd..e955773e1c865 100644 --- a/Calibration/HcalAlCaRecoProducers/interface/AlCaHcalNoiseProducer.h +++ b/Calibration/HcalAlCaRecoProducers/interface/AlCaHcalNoiseProducer.h @@ -1,6 +1,5 @@ // -*- C++ -*- - // system include files #include #include @@ -30,7 +29,6 @@ #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" - #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/METReco/interface/CaloMETCollection.h" @@ -42,24 +40,24 @@ // class AlCaHcalNoiseProducer : public edm::EDProducer { - public: - explicit AlCaHcalNoiseProducer(const edm::ParameterSet&); - ~AlCaHcalNoiseProducer() override; +public: + explicit AlCaHcalNoiseProducer(const edm::ParameterSet &); + ~AlCaHcalNoiseProducer() override; + void produce(edm::Event &, const edm::EventSetup &) override; - void produce(edm::Event &, const edm::EventSetup&) override; - private: - // ----------member data --------------------------- +private: + // ----------member data --------------------------- - bool useMet_; - bool useJet_; - double MetCut_; - double JetMinE_; - double JetHCALminEnergyFraction_; - int nAnomalousEvents; - int nEvents; + bool useMet_; + bool useJet_; + double MetCut_; + double JetMinE_; + double JetHCALminEnergyFraction_; + int nAnomalousEvents; + int nEvents; - std::vector ecalLabels_; + std::vector ecalLabels_; edm::EDGetTokenT tok_jets_; edm::EDGetTokenT tok_met_; @@ -72,5 +70,4 @@ class AlCaHcalNoiseProducer : public edm::EDProducer { edm::EDGetTokenT tok_ps_; edm::EDGetTokenT tok_raw_; std::vector > toks_ecal_; - }; diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaGammaJetSelector.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaGammaJetSelector.cc index 1ef365a299903..e57a073207601 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaGammaJetSelector.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaGammaJetSelector.cc @@ -16,7 +16,6 @@ // // - // system include files #include #include @@ -42,26 +41,23 @@ namespace AlCaGammaJet { Counters() : nProcessed_(0), nSelected_(0) {} mutable std::atomic nProcessed_, nSelected_; }; -} - +} // namespace AlCaGammaJet class AlCaGammaJetSelector : public edm::stream::EDFilter > { - public: explicit AlCaGammaJetSelector(const edm::ParameterSet&, const AlCaGammaJet::Counters* count); ~AlCaGammaJetSelector() override; - - static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& ) { + + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); bool filter(edm::Event&, const edm::EventSetup&) override; void endStream() override; - static void globalEndJob(const AlCaGammaJet::Counters* counters); + static void globalEndJob(const AlCaGammaJet::Counters* counters); private: - void beginRun(edm::Run const&, edm::EventSetup const&) override {} void endRun(edm::Run const&, edm::EventSetup const&) override {} void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {} @@ -76,7 +72,6 @@ class AlCaGammaJetSelector : public edm::stream::EDFilter tok_Photon_; edm::EDGetTokenT tok_PFJet_; - }; // @@ -95,18 +90,17 @@ AlCaGammaJetSelector::AlCaGammaJetSelector(const edm::ParameterSet& iConfig, con nSelected_ = 0; // get input - labelPhoton_ = iConfig.getParameter("PhoInput"); - labelPFJet_ = iConfig.getParameter("PFjetInput"); - minPtJet_ = iConfig.getParameter("MinPtJet"); - minPtPhoton_ = iConfig.getParameter("MinPtPhoton"); + labelPhoton_ = iConfig.getParameter("PhoInput"); + labelPFJet_ = iConfig.getParameter("PFjetInput"); + minPtJet_ = iConfig.getParameter("MinPtJet"); + minPtPhoton_ = iConfig.getParameter("MinPtPhoton"); // Register consumption tok_Photon_ = consumes(labelPhoton_); - tok_PFJet_ = consumes(labelPFJet_); - + tok_PFJet_ = consumes(labelPFJet_); } -AlCaGammaJetSelector::~AlCaGammaJetSelector() { } +AlCaGammaJetSelector::~AlCaGammaJetSelector() {} // // member functions @@ -130,60 +124,57 @@ bool AlCaGammaJetSelector::filter(edm::Event& iEvent, const edm::EventSetup& iSe // Access the collections from iEvent edm::Handle phoHandle; - iEvent.getByToken(tok_Photon_,phoHandle); + iEvent.getByToken(tok_Photon_, phoHandle); if (!phoHandle.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get the product " << labelPhoton_; - return false; // do not filter + return false; // do not filter } const reco::PhotonCollection photons = *(phoHandle.product()); edm::Handle pfjetHandle; - iEvent.getByToken(tok_PFJet_,pfjetHandle); + iEvent.getByToken(tok_PFJet_, pfjetHandle); if (!pfjetHandle.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelPFJet_; - return false; // do not filter + return false; // do not filter } const reco::PFJetCollection pfjets = *(pfjetHandle.product()); // Check the conditions for a good event - if (!(select(photons, pfjets))) return false; + if (!(select(photons, pfjets))) + return false; //std::cout << "good event\n"; nSelected_++; return true; - } void AlCaGammaJetSelector::endStream() { globalCache()->nProcessed_ += nProcessed_; - globalCache()->nSelected_ += nSelected_; + globalCache()->nSelected_ += nSelected_; } // ------------ method called once each job just after ending the event loop ------------ void AlCaGammaJetSelector::globalEndJob(const AlCaGammaJet::Counters* count) { - edm::LogWarning("AlCaGammaJet") << "Finds " << count->nSelected_ - <<" good events out of " - << count->nProcessed_; + edm::LogWarning("AlCaGammaJet") << "Finds " << count->nSelected_ << " good events out of " << count->nProcessed_; } -bool AlCaGammaJetSelector::select (const reco::PhotonCollection &photons, - const reco::PFJetCollection &jets) { - +bool AlCaGammaJetSelector::select(const reco::PhotonCollection& photons, const reco::PFJetCollection& jets) { // Check the requirement for minimum pT - if (photons.empty()) return false; + if (photons.empty()) + return false; bool ok(false); - for (reco::PFJetCollection::const_iterator itr=jets.begin(); - itr!=jets.end(); ++itr) { + for (reco::PFJetCollection::const_iterator itr = jets.begin(); itr != jets.end(); ++itr) { if (itr->pt() >= minPtJet_) { ok = true; break; } } - if (!ok) return ok; - for (reco::PhotonCollection::const_iterator itr=photons.begin(); - itr!=photons.end(); ++itr) { - if (itr->pt() >= minPtPhoton_) return ok; + if (!ok) + return ok; + for (reco::PhotonCollection::const_iterator itr = photons.begin(); itr != photons.end(); ++itr) { + if (itr->pt() >= minPtPhoton_) + return ok; } return false; } diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHBHEMuonFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHBHEMuonFilter.cc index d5c930a1ff7e7..4b1322d8f0e14 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHBHEMuonFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHBHEMuonFilter.cc @@ -44,39 +44,38 @@ namespace AlCaHBHEMuons { Counters() : nAll_(0), nGood_(0), nFinal_(0) {} mutable std::atomic nAll_, nGood_, nFinal_; }; -} +} // namespace AlCaHBHEMuons class AlCaHBHEMuonFilter : public edm::stream::EDFilter > { public: explicit AlCaHBHEMuonFilter(edm::ParameterSet const&, const AlCaHBHEMuons::Counters* count); ~AlCaHBHEMuonFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } - + bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaHBHEMuons::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: + static void globalEndJob(const AlCaHBHEMuons::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); +private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::vector trigNames_, HLTNames_; - std::string processName_; - bool pfCut_; - double trackIsoCut_, caloIsoCut_, pfIsoCut_; - int preScale_; - unsigned int nRun_, nAll_, nGood_, nFinal_; - edm::InputTag triggerResults_, labelMuon_; - edm::EDGetTokenT tok_trigEvt; - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_Muon_; + HLTConfigProvider hltConfig_; + std::vector trigNames_, HLTNames_; + std::string processName_; + bool pfCut_; + double trackIsoCut_, caloIsoCut_, pfIsoCut_; + int preScale_; + unsigned int nRun_, nAll_, nGood_, nFinal_; + edm::InputTag triggerResults_, labelMuon_; + edm::EDGetTokenT tok_trigEvt; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_Muon_; }; // @@ -90,31 +89,30 @@ class AlCaHBHEMuonFilter : public edm::stream::EDFilter >("Triggers"); - processName_ = iConfig.getParameter("ProcessName"); - triggerResults_ = iConfig.getParameter("TriggerResultLabel"); - labelMuon_ = iConfig.getParameter("MuonLabel"); - pfCut_ = iConfig.getParameter("PFCut"); - pfIsoCut_ = iConfig.getParameter("PFIsolationCut"); - trackIsoCut_ = iConfig.getParameter("TrackIsolationCut"); - caloIsoCut_ = iConfig.getParameter("CaloIsolationCut"); - preScale_ = iConfig.getParameter("PreScale"); - if (preScale_ < 1) preScale_ = 1; - - // define tokens for access - tok_trigRes_ = consumes(triggerResults_); - tok_Muon_ = consumes(labelMuon_); - edm::LogInfo("HBHEMuon") << "Parameters read from config file \n" - << "Process " << processName_ << " Prescale " - << preScale_ << " Isolation Cuts " - << trackIsoCut_ << ":" << caloIsoCut_ << "\n"; - for (unsigned int k=0; k >("Triggers"); + processName_ = iConfig.getParameter("ProcessName"); + triggerResults_ = iConfig.getParameter("TriggerResultLabel"); + labelMuon_ = iConfig.getParameter("MuonLabel"); + pfCut_ = iConfig.getParameter("PFCut"); + pfIsoCut_ = iConfig.getParameter("PFIsolationCut"); + trackIsoCut_ = iConfig.getParameter("TrackIsolationCut"); + caloIsoCut_ = iConfig.getParameter("CaloIsolationCut"); + preScale_ = iConfig.getParameter("PreScale"); + if (preScale_ < 1) + preScale_ = 1; + // define tokens for access + tok_trigRes_ = consumes(triggerResults_); + tok_Muon_ = consumes(labelMuon_); + edm::LogInfo("HBHEMuon") << "Parameters read from config file \n" + << "Process " << processName_ << " Prescale " << preScale_ << " Isolation Cuts " + << trackIsoCut_ << ":" << caloIsoCut_ << "\n"; + for (unsigned int k = 0; k < trigNames_.size(); ++k) + edm::LogInfo("HBHEMuon") << "Trigger[" << k << "] " << trigNames_[k] << "\n"; +} // AlCaHBHEMuonFilter::AlCaHBHEMuonFilter constructor AlCaHBHEMuonFilter::~AlCaHBHEMuonFilter() {} @@ -127,11 +125,9 @@ bool AlCaHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetu bool accept(false); ++nAll_; #ifdef DebugLog - edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing() << std::endl; + edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Run " << iEvent.id().run() << " Event " << iEvent.id().event() + << " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() + << std::endl; #endif //Step1: Find if the event passes one of the chosen triggers /////////////////////////////TriggerResults @@ -140,21 +136,20 @@ bool AlCaHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetu if (triggerResults.isValid()) { bool ok(false); std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; i 0) { - ok = true; - } + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigNames_[i]) != std::string::npos) { + if (hlt > 0) { + ok = true; + } #ifdef DebugLog - edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Trigger " - << triggerNames_[iHLT] << " Flag " - << hlt << ":" << ok << std::endl; + edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Trigger " << triggerNames_[iHLT] << " Flag " << hlt << ":" + << ok << std::endl; #endif - } + } } } if (ok) { @@ -162,62 +157,56 @@ bool AlCaHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetu //Get magnetic field edm::ESHandle bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); // get handles to calogeometry edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + // Relevant blocks from iEvent edm::Handle _Muon; iEvent.getByToken(tok_Muon_, _Muon); #ifdef DebugLog - edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Muon Handle " - << _Muon.isValid() << std::endl; + edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Muon Handle " << _Muon.isValid() << std::endl; #endif - if (_Muon.isValid()) { - for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); - RecMuon!= _Muon->end(); ++RecMuon) { + if (_Muon.isValid()) { + for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon != _Muon->end(); ++RecMuon) { #ifdef DebugLog - edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Muon:Track " - << RecMuon->track().isNonnull() - << " innerTrack " - << RecMuon->innerTrack().isNonnull() - << " outerTrack " - << RecMuon->outerTrack().isNonnull() - << " globalTrack " - << RecMuon->globalTrack().isNonnull() - << std::endl; + edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Muon:Track " << RecMuon->track().isNonnull() + << " innerTrack " << RecMuon->innerTrack().isNonnull() << " outerTrack " + << RecMuon->outerTrack().isNonnull() << " globalTrack " + << RecMuon->globalTrack().isNonnull() << std::endl; #endif - if ((RecMuon->track().isNonnull()) && - (RecMuon->innerTrack().isNonnull()) && - (RecMuon->outerTrack().isNonnull()) && - (RecMuon->globalTrack().isNonnull())) { - const reco::Track* pTrack = (RecMuon->innerTrack()).get(); - spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); + if ((RecMuon->track().isNonnull()) && (RecMuon->innerTrack().isNonnull()) && + (RecMuon->outerTrack().isNonnull()) && (RecMuon->globalTrack().isNonnull())) { + const reco::Track* pTrack = (RecMuon->innerTrack()).get(); + spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); #ifdef DebugLog - edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Propagate: ECAL " - << trackID.okECAL << " to HCAL " - << trackID.okHCAL << std::endl; + edm::LogInfo("HBHEMuon") << "AlCaHBHEMuonFilter::Propagate: ECAL " << trackID.okECAL << " to HCAL " + << trackID.okHCAL << std::endl; #endif - double trackIso = RecMuon->isolationR03().sumPt; - double caloIso = RecMuon->isolationR03().emEt + RecMuon->isolationR03().hadEt; - double isolR04 = ((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()); - bool isoCut = (pfCut_) ? (isolR04 < pfIsoCut_) : - ((trackIso < trackIsoCut_) && (caloIso < caloIsoCut_)); - if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { - accept = true; - break; - } - } - } + double trackIso = RecMuon->isolationR03().sumPt; + double caloIso = RecMuon->isolationR03().emEt + RecMuon->isolationR03().hadEt; + double isolR04 = + ((RecMuon->pfIsolationR04().sumChargedHadronPt + + std::max(0., + RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - + (0.5 * RecMuon->pfIsolationR04().sumPUPt))) / + RecMuon->pt()); + bool isoCut = (pfCut_) ? (isolR04 < pfIsoCut_) : ((trackIso < trackIsoCut_) && (caloIso < caloIsoCut_)); + if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { + accept = true; + break; + } + } + } } } } // Step 4: Return the acceptance flag if (accept) { ++nGood_; - if (((nGood_-1)%preScale_) != 0) { + if (((nGood_ - 1) % preScale_) != 0) { accept = false; } else { ++nFinal_; @@ -229,24 +218,21 @@ bool AlCaHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetu // ------------ method called once each job just after ending the event loop ------------ void AlCaHBHEMuonFilter::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; globalCache()->nFinal_ += nFinal_; } void AlCaHBHEMuonFilter::globalEndJob(const AlCaHBHEMuons::Counters* count) { - edm::LogInfo("HBHEMuon") << "Selects " << count->nFinal_ << " out of " - << count->nGood_ << " good events out of " - << count->nAll_ << " total # of events\n"; + edm::LogInfo("HBHEMuon") << "Selects " << count->nFinal_ << " out of " << count->nGood_ << " good events out of " + << count->nAll_ << " total # of events\n"; } - // ------------ method called when starting to processes a run ------------ void AlCaHBHEMuonFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); bool flag = hltConfig_.init(iRun, iSetup, processName_, changed); - edm::LogInfo("HBHEMuon") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << flag << std::endl; + edm::LogInfo("HBHEMuon") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " << flag << std::endl; } // ------------ method called when ending the processing of a run ------------ @@ -256,8 +242,7 @@ void AlCaHBHEMuonFilter::endRun(edm::Run const& iRun, edm::EventSetup const&) { } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void -AlCaHBHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void AlCaHBHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHEMuonFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHEMuonFilter.cc index 68f07474c92e0..bc6d942ee070b 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaHEMuonFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaHEMuonFilter.cc @@ -44,39 +44,38 @@ namespace AlCaHEMuons { Counters() : nAll_(0), nGood_(0), nFinal_(0) {} mutable std::atomic nAll_, nGood_, nFinal_; }; -} +} // namespace AlCaHEMuons class AlCaHEMuonFilter : public edm::stream::EDFilter > { public: explicit AlCaHEMuonFilter(edm::ParameterSet const&, const AlCaHEMuons::Counters* count); ~AlCaHEMuonFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } - + bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaHEMuons::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: + static void globalEndJob(const AlCaHEMuons::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); +private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::vector trigNames_, HLTNames_; - std::string processName_; - bool pfCut_; - double trackIsoCut_, caloIsoCut_, pfIsoCut_, muonptCut_, muonetaCut_; - int preScale_; - unsigned int nRun_, nAll_, nGood_, nFinal_; - edm::InputTag triggerResults_, labelMuon_; - edm::EDGetTokenT tok_trigEvt; - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_Muon_; + HLTConfigProvider hltConfig_; + std::vector trigNames_, HLTNames_; + std::string processName_; + bool pfCut_; + double trackIsoCut_, caloIsoCut_, pfIsoCut_, muonptCut_, muonetaCut_; + int preScale_; + unsigned int nRun_, nAll_, nGood_, nFinal_; + edm::InputTag triggerResults_, labelMuon_; + edm::EDGetTokenT tok_trigEvt; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_Muon_; }; // @@ -90,33 +89,32 @@ class AlCaHEMuonFilter : public edm::stream::EDFilter >("triggers"); - processName_ = iConfig.getParameter("processName"); - triggerResults_ = iConfig.getParameter("triggerResultLabel"); - labelMuon_ = iConfig.getParameter("muonLabel"); - muonptCut_ = iConfig.getParameter("muonPtCut"); - muonetaCut_ = iConfig.getParameter("muonEtaCut"); - pfCut_ = iConfig.getParameter("pfCut"); - pfIsoCut_ = iConfig.getParameter("pfIsolationCut"); - trackIsoCut_ = iConfig.getParameter("trackIsolationCut"); - caloIsoCut_ = iConfig.getParameter("caloIsolationCut"); - preScale_ = iConfig.getParameter("preScale"); - if (preScale_ < 1) preScale_ = 1; - - // define tokens for access - tok_trigRes_ = consumes(triggerResults_); - tok_Muon_ = consumes(labelMuon_); - edm::LogInfo("HEMuon") << "Parameters read from config file \n" - << "Process " << processName_ << " Prescale " - << preScale_ << " Isolation Cuts " - << trackIsoCut_ << ":" << caloIsoCut_ << "\n"; - for (unsigned int k=0; k >("triggers"); + processName_ = iConfig.getParameter("processName"); + triggerResults_ = iConfig.getParameter("triggerResultLabel"); + labelMuon_ = iConfig.getParameter("muonLabel"); + muonptCut_ = iConfig.getParameter("muonPtCut"); + muonetaCut_ = iConfig.getParameter("muonEtaCut"); + pfCut_ = iConfig.getParameter("pfCut"); + pfIsoCut_ = iConfig.getParameter("pfIsolationCut"); + trackIsoCut_ = iConfig.getParameter("trackIsolationCut"); + caloIsoCut_ = iConfig.getParameter("caloIsolationCut"); + preScale_ = iConfig.getParameter("preScale"); + if (preScale_ < 1) + preScale_ = 1; + // define tokens for access + tok_trigRes_ = consumes(triggerResults_); + tok_Muon_ = consumes(labelMuon_); + edm::LogInfo("HEMuon") << "Parameters read from config file \n" + << "Process " << processName_ << " Prescale " << preScale_ << " Isolation Cuts " + << trackIsoCut_ << ":" << caloIsoCut_ << "\n"; + for (unsigned int k = 0; k < trigNames_.size(); ++k) + edm::LogInfo("HEMuon") << "Trigger[" << k << "] " << trigNames_[k] << "\n"; +} // AlCaHEMuonFilter::AlCaHEMuonFilter constructor AlCaHEMuonFilter::~AlCaHEMuonFilter() {} @@ -129,11 +127,9 @@ bool AlCaHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) bool accept(false); ++nAll_; #ifdef DebugLog - edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing() << std::endl; + edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Run " << iEvent.id().run() << " Event " << iEvent.id().event() + << " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() + << std::endl; #endif //Step1: Find if the event passes one of the chosen triggers /////////////////////////////TriggerResults @@ -142,21 +138,20 @@ bool AlCaHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) if (triggerResults.isValid()) { bool ok(false); std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; i 0) { - ok = true; - } + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigNames_[i]) != std::string::npos) { + if (hlt > 0) { + ok = true; + } #ifdef DebugLog - edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Trigger " - << triggerNames_[iHLT] << " Flag " - << hlt << ":" << ok << std::endl; + edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Trigger " << triggerNames_[iHLT] << " Flag " << hlt << ":" << ok + << std::endl; #endif - } + } } } if (ok) { @@ -164,66 +159,61 @@ bool AlCaHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) //Get magnetic field edm::ESHandle bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); // get handles to calogeometry edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + // Relevant blocks from iEvent edm::Handle _Muon; iEvent.getByToken(tok_Muon_, _Muon); #ifdef DebugLog - edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Muon Handle " - << _Muon.isValid() << std::endl; + edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Muon Handle " << _Muon.isValid() << std::endl; #endif - if (_Muon.isValid()) { - for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); - RecMuon!= _Muon->end(); ++RecMuon) { + if (_Muon.isValid()) { + for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon != _Muon->end(); ++RecMuon) { #ifdef DebugLog - edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Muon:Track " - << RecMuon->track().isNonnull() - << " innerTrack " - << RecMuon->innerTrack().isNonnull() - << " outerTrack " - << RecMuon->outerTrack().isNonnull() - << " globalTrack " - << RecMuon->globalTrack().isNonnull() - << std::endl; + edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Muon:Track " << RecMuon->track().isNonnull() << " innerTrack " + << RecMuon->innerTrack().isNonnull() << " outerTrack " + << RecMuon->outerTrack().isNonnull() << " globalTrack " + << RecMuon->globalTrack().isNonnull() << std::endl; #endif - if ((RecMuon->track().isNonnull()) && - (RecMuon->innerTrack().isNonnull()) && - (RecMuon->outerTrack().isNonnull()) && - (RecMuon->globalTrack().isNonnull())) { - bool ptCut = RecMuon->pt() < muonptCut_ ; - bool etaCut = fabs(RecMuon->eta()) < muonetaCut_ ; - if(ptCut || etaCut) continue; + if ((RecMuon->track().isNonnull()) && (RecMuon->innerTrack().isNonnull()) && + (RecMuon->outerTrack().isNonnull()) && (RecMuon->globalTrack().isNonnull())) { + bool ptCut = RecMuon->pt() < muonptCut_; + bool etaCut = fabs(RecMuon->eta()) < muonetaCut_; + if (ptCut || etaCut) + continue; - const reco::Track* pTrack = (RecMuon->innerTrack()).get(); - spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); + const reco::Track* pTrack = (RecMuon->innerTrack()).get(); + spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); #ifdef DebugLog - edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Propagate: ECAL " - << trackID.okECAL << " to HCAL " - << trackID.okHCAL << std::endl; + edm::LogInfo("HEMuon") << "AlCaHEMuonFilter::Propagate: ECAL " << trackID.okECAL << " to HCAL " + << trackID.okHCAL << std::endl; #endif - double trackIso = RecMuon->isolationR03().sumPt; - double caloIso = RecMuon->isolationR03().emEt + RecMuon->isolationR03().hadEt; - double isolR04 = ((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()); - bool isoCut = (pfCut_) ? (isolR04 < pfIsoCut_) : - ((trackIso < trackIsoCut_) && (caloIso < caloIsoCut_)); - if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { - accept = true; - break; - } - } - } + double trackIso = RecMuon->isolationR03().sumPt; + double caloIso = RecMuon->isolationR03().emEt + RecMuon->isolationR03().hadEt; + double isolR04 = + ((RecMuon->pfIsolationR04().sumChargedHadronPt + + std::max(0., + RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - + (0.5 * RecMuon->pfIsolationR04().sumPUPt))) / + RecMuon->pt()); + bool isoCut = (pfCut_) ? (isolR04 < pfIsoCut_) : ((trackIso < trackIsoCut_) && (caloIso < caloIsoCut_)); + if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { + accept = true; + break; + } + } + } } } } // Step 4: Return the acceptance flag if (accept) { ++nGood_; - if (((nGood_-1)%preScale_) != 0) { + if (((nGood_ - 1) % preScale_) != 0) { accept = false; } else { ++nFinal_; @@ -235,24 +225,21 @@ bool AlCaHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) // ------------ method called once each job just after ending the event loop ------------ void AlCaHEMuonFilter::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; globalCache()->nFinal_ += nFinal_; } void AlCaHEMuonFilter::globalEndJob(const AlCaHEMuons::Counters* count) { - edm::LogInfo("HEMuon") << "Selects " << count->nFinal_ << " out of " - << count->nGood_ << " good events out of " - << count->nAll_ << " total # of events\n"; + edm::LogInfo("HEMuon") << "Selects " << count->nFinal_ << " out of " << count->nGood_ << " good events out of " + << count->nAll_ << " total # of events\n"; } - // ------------ method called when starting to processes a run ------------ void AlCaHEMuonFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); bool flag = hltConfig_.init(iRun, iSetup, processName_, changed); - edm::LogInfo("HEMuon") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << flag << std::endl; + edm::LogInfo("HEMuon") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " << flag << std::endl; } // ------------ method called when ending the processing of a run ------------ @@ -262,25 +249,24 @@ void AlCaHEMuonFilter::endRun(edm::Run const& iRun, edm::EventSetup const&) { } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void -AlCaHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void AlCaHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; - std::vector triggers = {"HLT_IsoMu","HLT_Mu"}; - desc.add("processName","HLT"); - desc.add("triggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - desc.add("muonLabel",edm::InputTag("muons")); - desc.add("minimumMuonP",10.0); - desc.add >("triggers",triggers); - desc.add("muonPtCut",20.0); - desc.add("muonEtaCut",1.305); - desc.add("pfCut",true); - desc.add("pfIsolationCut",0.15); - desc.add("trackIsolationCut",3.0); - desc.add("caloIsolationCut",5.0); - desc.add("preScale",1); - descriptions.add("alcaHEMuonFilter",desc); + std::vector triggers = {"HLT_IsoMu", "HLT_Mu"}; + desc.add("processName", "HLT"); + desc.add("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("muonLabel", edm::InputTag("muons")); + desc.add("minimumMuonP", 10.0); + desc.add >("triggers", triggers); + desc.add("muonPtCut", 20.0); + desc.add("muonEtaCut", 1.305); + desc.add("pfCut", true); + desc.add("pfIsolationCut", 0.15); + desc.add("trackIsolationCut", 3.0); + desc.add("caloIsolationCut", 5.0); + desc.add("preScale", 1); + descriptions.add("alcaHEMuonFilter", desc); } //define this as a plug-in diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksFilter.cc index 4b60c832edc3c..e1fd38325418f 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksFilter.cc @@ -63,53 +63,53 @@ namespace AlCaIsoTracks { Counters() : nAll_(0), nGood_(0), nRange_(0), nHigh_(0) {} mutable std::atomic nAll_, nGood_, nRange_, nHigh_; }; -} +} // namespace AlCaIsoTracks class AlCaIsoTracksFilter : public edm::stream::EDFilter > { public: explicit AlCaIsoTracksFilter(edm::ParameterSet const&, const AlCaIsoTracks::Counters* count); ~AlCaIsoTracksFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iConfig) { return std::make_unique(); } bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaIsoTracks::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - + static void globalEndJob(const AlCaIsoTracks::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; + HLTConfigProvider hltConfig_; const std::vector trigNames_; - const edm::InputTag labelGenTrack_, labelRecVtx_; - const edm::InputTag labelEB_, labelEE_, labelHBHE_; - const edm::InputTag triggerEvent_, theTriggerResultsLabel_; - const std::string processName_; - const double a_coneR_, a_mipR_, pTrackMin_, eEcalMax_; - const double maxRestrictionP_, slopeRestrictionP_; - const double eIsolate_; - const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; - const double hitEthrEE2_, hitEthrEE3_; - const double hitEthrEELo_, hitEthrEEHi_; - const double pTrackLow_, pTrackHigh_, pTrackH_; - const int preScale_, preScaleH_; - const std::string theTrackQuality_; - spr::trackSelectionParameters selectionParameter_; - double a_charIsoR_; - unsigned int nRun_, nAll_, nGood_, nRange_, nHigh_; - edm::EDGetTokenT tok_trigEvt_; - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_genTrack_; + const edm::InputTag labelGenTrack_, labelRecVtx_; + const edm::InputTag labelEB_, labelEE_, labelHBHE_; + const edm::InputTag triggerEvent_, theTriggerResultsLabel_; + const std::string processName_; + const double a_coneR_, a_mipR_, pTrackMin_, eEcalMax_; + const double maxRestrictionP_, slopeRestrictionP_; + const double eIsolate_; + const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; + const double hitEthrEE2_, hitEthrEE3_; + const double hitEthrEELo_, hitEthrEEHi_; + const double pTrackLow_, pTrackHigh_, pTrackH_; + const int preScale_, preScaleH_; + const std::string theTrackQuality_; + spr::trackSelectionParameters selectionParameter_; + double a_charIsoR_; + unsigned int nRun_, nAll_, nGood_, nRange_, nHigh_; + edm::EDGetTokenT tok_trigEvt_; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_genTrack_; edm::EDGetTokenT tok_recVtx_; - edm::EDGetTokenT tok_bs_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_hbhe_; + edm::EDGetTokenT tok_bs_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_hbhe_; }; // @@ -123,37 +123,41 @@ class AlCaIsoTracksFilter : public edm::stream::EDFilter >("triggers")), - labelGenTrack_(iConfig.getParameter("labelTrack")), - labelRecVtx_(iConfig.getParameter("labelVertex")), - labelEB_(iConfig.getParameter("labelEBRecHit")), - labelEE_(iConfig.getParameter("labelEERecHit")), - labelHBHE_(iConfig.getParameter("labelHBHERecHit")), - triggerEvent_(iConfig.getParameter("labelTriggerEvent")), - theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), - processName_(iConfig.getParameter("processName")), - a_coneR_(iConfig.getParameter("coneRadius")), - a_mipR_(iConfig.getParameter("coneRadiusMIP")), - pTrackMin_(iConfig.getParameter("minimumTrackP")), - eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), - maxRestrictionP_(iConfig.getParameter("maxTrackP")), - slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), - eIsolate_(iConfig.getParameter("isolationEnergy")), - hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold") ), - hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0") ), - hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1") ), - hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2") ), - hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3") ), - hitEthrEELo_(iConfig.getParameter("EEHitEnergyThresholdLow") ), - hitEthrEEHi_(iConfig.getParameter("EEHitEnergyThresholdHigh") ), - pTrackLow_(iConfig.getParameter("momentumRangeLow")), - pTrackHigh_(iConfig.getParameter("momentumRangeHigh")), - pTrackH_(iConfig.getParameter("momentumHigh")), - preScale_(iConfig.getParameter("preScaleFactor")), - preScaleH_(iConfig.getParameter("preScaleHigh")), - theTrackQuality_(iConfig.getParameter("trackQuality")), - nRun_(0), nAll_(0), nGood_(0), nRange_(0), nHigh_(0) { +AlCaIsoTracksFilter::AlCaIsoTracksFilter(const edm::ParameterSet& iConfig, const AlCaIsoTracks::Counters* count) + : trigNames_(iConfig.getParameter >("triggers")), + labelGenTrack_(iConfig.getParameter("labelTrack")), + labelRecVtx_(iConfig.getParameter("labelVertex")), + labelEB_(iConfig.getParameter("labelEBRecHit")), + labelEE_(iConfig.getParameter("labelEERecHit")), + labelHBHE_(iConfig.getParameter("labelHBHERecHit")), + triggerEvent_(iConfig.getParameter("labelTriggerEvent")), + theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), + processName_(iConfig.getParameter("processName")), + a_coneR_(iConfig.getParameter("coneRadius")), + a_mipR_(iConfig.getParameter("coneRadiusMIP")), + pTrackMin_(iConfig.getParameter("minimumTrackP")), + eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), + maxRestrictionP_(iConfig.getParameter("maxTrackP")), + slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), + eIsolate_(iConfig.getParameter("isolationEnergy")), + hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold")), + hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0")), + hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1")), + hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2")), + hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3")), + hitEthrEELo_(iConfig.getParameter("EEHitEnergyThresholdLow")), + hitEthrEEHi_(iConfig.getParameter("EEHitEnergyThresholdHigh")), + pTrackLow_(iConfig.getParameter("momentumRangeLow")), + pTrackHigh_(iConfig.getParameter("momentumRangeHigh")), + pTrackH_(iConfig.getParameter("momentumHigh")), + preScale_(iConfig.getParameter("preScaleFactor")), + preScaleH_(iConfig.getParameter("preScaleHigh")), + theTrackQuality_(iConfig.getParameter("trackQuality")), + nRun_(0), + nAll_(0), + nGood_(0), + nRange_(0), + nHigh_(0) { //now do what ever initialization is needed const double isolationRadius(28.9); // Different isolation cuts are described in DN-2016/029 @@ -161,61 +165,52 @@ AlCaIsoTracksFilter::AlCaIsoTracksFilter(const edm::ParameterSet& iConfig, const // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18)) // with the factor for exponential slopeRestrictionP_ = log(2.5)/18 // maxRestrictionP_ = 8 GeV as came from a study - reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality_); - selectionParameter_.minPt = iConfig.getParameter("minTrackPt");; - selectionParameter_.minQuality = trackQuality_; - selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); - selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); - selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); - selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); - selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality_); + selectionParameter_.minPt = iConfig.getParameter("minTrackPt"); + ; + selectionParameter_.minQuality = trackQuality_; + selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); + selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); - selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); - selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); - a_charIsoR_ = a_coneR_ + isolationRadius; + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); + a_charIsoR_ = a_coneR_ + isolationRadius; // define tokens for access - tok_trigEvt_ = consumes(triggerEvent_); - tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_trigEvt_ = consumes(triggerEvent_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); tok_genTrack_ = consumes(labelGenTrack_); - tok_recVtx_ = consumes(labelRecVtx_); - tok_bs_ = consumes(iConfig.getParameter("labelBeamSpot")); - - tok_EB_ = consumes(labelEB_); - tok_EE_ = consumes(labelEE_); - tok_hbhe_ = consumes(labelHBHE_); - - edm::LogInfo("HcalIsoTrack") <<"Parameters read from config file \n" - <<"\t minPt " << selectionParameter_.minPt - <<"\t theTrackQuality " << theTrackQuality_ - <<"\t minQuality " << selectionParameter_.minQuality - <<"\t maxDxyPV " << selectionParameter_.maxDxyPV - <<"\t maxDzPV " << selectionParameter_.maxDzPV - <<"\t maxChi2 " << selectionParameter_.maxChi2 - <<"\t maxDpOverP " << selectionParameter_.maxDpOverP - <<"\t minOuterHit " << selectionParameter_.minOuterHit - <<"\t minLayerCrossed " << selectionParameter_.minLayerCrossed - <<"\t maxInMiss " << selectionParameter_.maxInMiss - <<"\t maxOutMiss " << selectionParameter_.maxOutMiss << "\n" - <<"\t a_coneR " << a_coneR_ - <<"\t a_charIsoR " << a_charIsoR_ - <<"\t a_mipR " << a_mipR_ - <<"\t maxRestrictionP_ "<< maxRestrictionP_ - <<"\t slopeRestrictionP_ " << slopeRestrictionP_ - <<"\t eIsolate_ " << eIsolate_ << "\n" - <<"\t Precale factor " << preScale_ - <<"\t in momentum range " << pTrackLow_ - <<":" << pTrackHigh_ << " and prescale factor " - << preScaleH_ << " for p > " << pTrackH_ - <<" Threshold for EB " << hitEthrEB_ << " EE " - << hitEthrEE0_ << ":" << hitEthrEE1_ << ":" - << hitEthrEE2_ << ":" << hitEthrEE3_ << ":" - << hitEthrEELo_ << ":" << hitEthrEEHi_; - - for (unsigned int k=0; k(labelRecVtx_); + tok_bs_ = consumes(iConfig.getParameter("labelBeamSpot")); + + tok_EB_ = consumes(labelEB_); + tok_EE_ = consumes(labelEE_); + tok_hbhe_ = consumes(labelHBHE_); + + edm::LogInfo("HcalIsoTrack") << "Parameters read from config file \n" + << "\t minPt " << selectionParameter_.minPt << "\t theTrackQuality " << theTrackQuality_ + << "\t minQuality " << selectionParameter_.minQuality << "\t maxDxyPV " + << selectionParameter_.maxDxyPV << "\t maxDzPV " << selectionParameter_.maxDzPV + << "\t maxChi2 " << selectionParameter_.maxChi2 << "\t maxDpOverP " + << selectionParameter_.maxDpOverP << "\t minOuterHit " << selectionParameter_.minOuterHit + << "\t minLayerCrossed " << selectionParameter_.minLayerCrossed << "\t maxInMiss " + << selectionParameter_.maxInMiss << "\t maxOutMiss " << selectionParameter_.maxOutMiss + << "\n" + << "\t a_coneR " << a_coneR_ << "\t a_charIsoR " << a_charIsoR_ << "\t a_mipR " + << a_mipR_ << "\t maxRestrictionP_ " << maxRestrictionP_ << "\t slopeRestrictionP_ " + << slopeRestrictionP_ << "\t eIsolate_ " << eIsolate_ << "\n" + << "\t Precale factor " << preScale_ << "\t in momentum range " << pTrackLow_ << ":" + << pTrackHigh_ << " and prescale factor " << preScaleH_ << " for p > " << pTrackH_ + << " Threshold for EB " << hitEthrEB_ << " EE " << hitEthrEE0_ << ":" << hitEthrEE1_ + << ":" << hitEthrEE2_ << ":" << hitEthrEE3_ << ":" << hitEthrEELo_ << ":" + << hitEthrEEHi_; + + for (unsigned int k = 0; k < trigNames_.size(); ++k) edm::LogInfo("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k]; -} // AlCaIsoTracksFilter::AlCaIsoTracksFilter constructor - +} // AlCaIsoTracksFilter::AlCaIsoTracksFilter constructor AlCaIsoTracksFilter::~AlCaIsoTracksFilter() {} @@ -227,10 +222,8 @@ AlCaIsoTracksFilter::~AlCaIsoTracksFilter() {} bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) { bool accept(false); ++nAll_; - edm::LogVerbatim("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); + edm::LogVerbatim("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); //Step1: Find if the event passes one of the chosen triggers bool triggerSatisfied(false); @@ -241,8 +234,7 @@ bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSet edm::Handle triggerEventHandle; iEvent.getByToken(tok_trigEvt_, triggerEventHandle); if (!triggerEventHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " - << triggerEvent_.label() ; + edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " << triggerEvent_.label(); } else { triggerEvent = *(triggerEventHandle.product()); @@ -250,21 +242,22 @@ bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSet edm::Handle triggerResults; iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { - std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; i 0) triggerSatisfied = true; - edm::LogVerbatim("HcalIsoTrack") << triggerNames_[iHLT] - << " has got HLT flag " << hlt - << ":" << triggerSatisfied; - if (triggerSatisfied) break; - } - } - } + std::vector modules; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigNames_[i]) != std::string::npos) { + if (hlt > 0) + triggerSatisfied = true; + edm::LogVerbatim("HcalIsoTrack") + << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" << triggerSatisfied; + if (triggerSatisfied) + break; + } + } + } } } } @@ -274,12 +267,12 @@ bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSet //Get magnetic field edm::ESHandle bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); // get handles to calogeometry and calotopology edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + //Also relevant information to extrapolate tracks to Hcal surface bool foundCollections(true); //Get track collection @@ -292,18 +285,17 @@ bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSet //Define the best vertex and the beamspot edm::Handle recVtxs; - iEvent.getByToken(tok_recVtx_, recVtxs); + iEvent.getByToken(tok_recVtx_, recVtxs); edm::Handle beamSpotH; iEvent.getByToken(tok_bs_, beamSpotH); - math::XYZPoint leadPV(0,0,0); + math::XYZPoint leadPV(0, 0, 0); if (!recVtxs->empty() && !((*recVtxs)[0].isFake())) { - leadPV = math::XYZPoint((*recVtxs)[0].x(),(*recVtxs)[0].y(), - (*recVtxs)[0].z()); + leadPV = math::XYZPoint((*recVtxs)[0].x(), (*recVtxs)[0].y(), (*recVtxs)[0].z()); } else if (beamSpotH.isValid()) { leadPV = beamSpotH->position(); } edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV; - + // RecHits edm::Handle barrelRecHitsHandle; iEvent.getByToken(tok_EB_, barrelRecHitsHandle); @@ -323,124 +315,122 @@ bool AlCaIsoTracksFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSet edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_; foundCollections = false; } - + //Step3 propagate the tracks to calorimeter surface and find // candidates for isolated tracks if (foundCollections) { //Propagate tracks to calorimeter surface) std::vector trkCaloDirections; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDirections, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false); std::vector::const_iterator trkDetItr; unsigned int nTracks(0), nselTracks(0), ntrin(0), ntrout(0), ntrH(0); - for (trkDetItr = trkCaloDirections.begin(),nTracks=0; - trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) { - const reco::Track* pTrack = &(*(trkDetItr->trkItr)); - math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), - pTrack->pz(), pTrack->p()); - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << pTrack->pt() - << "|" << pTrack->eta() << "|" - << pTrack->phi() << "|" <p(); - - //Selection of good track - int ieta(0); - if (trkDetItr->okHCAL) { - HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); - ieta = detId.ietaAbs(); - } - bool qltyFlag = spr::goodTrack(pTrack,leadPV,selectionParameter_,false); - edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " - << qltyFlag << "|" - << trkDetItr->okECAL << "|" - << trkDetItr->okHCAL; - if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) { - double t_p = pTrack->p(); - nselTracks++; - int nNearTRKs(0); - std::vector eIds; - std::vector eHit; - double eEcal = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, - trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR_, - trkDetItr->directionECAL, - eIds, eHit); - double eMipDR(0); - for (unsigned int k=0; kgetPosition(eIds[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit[k] > eThr) eMipDR += eHit[k]; - } - double hmaxNearP = spr::chargeIsolationCone(nTracks, - trkCaloDirections, - a_charIsoR_, - nNearTRKs, false); - double eIsolation = (maxRestrictionP_*exp(slopeRestrictionP_*((double)(ieta)))); - if (eIsolation < eIsolate_) eIsolation = eIsolate_; - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" - << pTrack->pt() << "|" - << pTrack->eta() << "|" - << pTrack->phi() << "|" << t_p - << "e_MIP " << eMipDR <<":" << eEcal - << " Chg Isolation " << hmaxNearP - << ":" << eIsolation; - if (t_p>pTrackMin_ && eMipDR pTrackLow_ && t_p < pTrackHigh_) ntrin++; - else if (t_p > pTrackH_) ntrH++; - else ntrout++; - } - } + for (trkDetItr = trkCaloDirections.begin(), nTracks = 0; trkDetItr != trkCaloDirections.end(); + trkDetItr++, nTracks++) { + const reco::Track* pTrack = &(*(trkDetItr->trkItr)); + math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p()); + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << pTrack->p(); + + //Selection of good track + int ieta(0); + if (trkDetItr->okHCAL) { + HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); + ieta = detId.ietaAbs(); + } + bool qltyFlag = spr::goodTrack(pTrack, leadPV, selectionParameter_, false); + edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr->okECAL << "|" + << trkDetItr->okHCAL; + if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) { + double t_p = pTrack->p(); + nselTracks++; + int nNearTRKs(0); + std::vector eIds; + std::vector eHit; + double eEcal = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR_, + trkDetItr->directionECAL, + eIds, + eHit); + double eMipDR(0); + for (unsigned int k = 0; k < eIds.size(); ++k) { + const GlobalPoint& pos = geo->getPosition(eIds[k]); + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit[k] > eThr) + eMipDR += eHit[k]; + } + double hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false); + double eIsolation = (maxRestrictionP_ * exp(slopeRestrictionP_ * ((double)(ieta)))); + if (eIsolation < eIsolate_) + eIsolation = eIsolate_; + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << t_p << "e_MIP " << eMipDR + << ":" << eEcal << " Chg Isolation " << hmaxNearP << ":" << eIsolation; + if (t_p > pTrackMin_ && eMipDR < eEcalMax_ && hmaxNearP < eIsolation) { + if (t_p > pTrackLow_ && t_p < pTrackHigh_) + ntrin++; + else if (t_p > pTrackH_) + ntrH++; + else + ntrout++; + } + } } accept = (ntrout > 0); if (!accept && ntrin > 0) { - ++nRange_; - if (preScale_ <= 1) accept = true; - else if (nRange_%preScale_ == 1) accept = true; + ++nRange_; + if (preScale_ <= 1) + accept = true; + else if (nRange_ % preScale_ == 1) + accept = true; } if (!accept && ntrH > 0) { - ++nHigh_; - if (preScaleH_ <= 1) accept = true; - else if (nHigh_%preScaleH_ == 1) accept = true; + ++nHigh_; + if (preScaleH_ <= 1) + accept = true; + else if (nHigh_ % preScaleH_ == 1) + accept = true; } } } // Step 4: Return the acceptance flag - if (accept) ++nGood_; + if (accept) + ++nGood_; return accept; } // AlCaIsoTracksFilter::filter // ------------ method called once each job just after ending the event loop ------------ void AlCaIsoTracksFilter::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; globalCache()->nRange_ += nRange_; - globalCache()->nHigh_ += nHigh_; + globalCache()->nHigh_ += nHigh_; } void AlCaIsoTracksFilter::globalEndJob(const AlCaIsoTracks::Counters* count) { - edm::LogVerbatim("HcalIsoTrack") << "Selects " << count->nGood_ << " in " - << count->nAll_ << " events and with " - << count->nRange_ << " events in the p-range" - << count->nHigh_ << " events with high p"; + edm::LogVerbatim("HcalIsoTrack") << "Selects " << count->nGood_ << " in " << count->nAll_ << " events and with " + << count->nRange_ << " events in the p-range" << count->nHigh_ + << " events with high p"; } - // ------------ method called when starting to processes a run ------------ void AlCaIsoTracksFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); - edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << hltConfig_.init(iRun,iSetup,processName_,changed); + edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " + << hltConfig_.init(iRun, iSetup, processName_, changed); } // ------------ method called when ending the processing of a run ------------ @@ -452,53 +442,53 @@ void AlCaIsoTracksFilter::endRun(edm::Run const& iRun, edm::EventSetup const&) { // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void AlCaIsoTracksFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("labelTrack",edm::InputTag("generalTracks")); - desc.add("labelVertex",edm::InputTag("offlinePrimaryVertices")); - desc.add("labelBeamSpot",edm::InputTag("offlineBeamSpot")); - desc.add("labelEBRecHit",edm::InputTag("ecalRecHit","EcalRecHitsEB")); - desc.add("labelEERecHit",edm::InputTag("ecalRecHit","EcalRecHitsEE")); - desc.add("labelHBHERecHit",edm::InputTag("hbhereco")); - desc.add("labelTriggerEvent",edm::InputTag("hltTriggerSummaryAOD","","HLT")); - desc.add("labelTriggerResult",edm::InputTag("TriggerResults","","HLT")); + desc.add("labelTrack", edm::InputTag("generalTracks")); + desc.add("labelVertex", edm::InputTag("offlinePrimaryVertices")); + desc.add("labelBeamSpot", edm::InputTag("offlineBeamSpot")); + desc.add("labelEBRecHit", edm::InputTag("ecalRecHit", "EcalRecHitsEB")); + desc.add("labelEERecHit", edm::InputTag("ecalRecHit", "EcalRecHitsEE")); + desc.add("labelHBHERecHit", edm::InputTag("hbhereco")); + desc.add("labelTriggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT")); + desc.add("labelTriggerResult", edm::InputTag("TriggerResults", "", "HLT")); std::vector trigger; - desc.add >("triggers",trigger); - desc.add("processName","HLT"); + desc.add >("triggers", trigger); + desc.add("processName", "HLT"); // following 10 parameters are parameters to select good tracks - desc.add("trackQuality","highPurity"); - desc.add("minTrackPt",1.0); - desc.add("maxDxyPV",10.0); - desc.add("maxDzPV",100.0); - desc.add("maxChi2",5.0); - desc.add("maxDpOverP",0.1); - desc.add("minOuterHit",4); - desc.add("minLayerCrossed",8); - desc.add("maxInMiss",2); - desc.add("maxOutMiss",2); + desc.add("trackQuality", "highPurity"); + desc.add("minTrackPt", 1.0); + desc.add("maxDxyPV", 10.0); + desc.add("maxDzPV", 100.0); + desc.add("maxChi2", 5.0); + desc.add("maxDpOverP", 0.1); + desc.add("minOuterHit", 4); + desc.add("minLayerCrossed", 8); + desc.add("maxInMiss", 2); + desc.add("maxOutMiss", 2); // Minimum momentum of selected isolated track and signal zone - desc.add("coneRadius",34.98); - desc.add("minimumTrackP",20.0); + desc.add("coneRadius", 34.98); + desc.add("minimumTrackP", 20.0); // signal zone in ECAL and MIP energy cutoff - desc.add("coneRadiusMIP",14.0); - desc.add("maximumEcalEnergy",100.0); + desc.add("coneRadiusMIP", 14.0); + desc.add("maximumEcalEnergy", 100.0); // following 3 parameters are for isolation cuts and described in the code - desc.add("maxTrackP",8.0); - desc.add("slopeTrackP",0.05090504066); - desc.add("isolationEnergy",10.0); + desc.add("maxTrackP", 8.0); + desc.add("slopeTrackP", 0.05090504066); + desc.add("isolationEnergy", 10.0); // energy thershold for ECAL (from Egamma group) - desc.add("EBHitEnergyThreshold",0.08); - desc.add("EEHitEnergyThreshold0",0.30); - desc.add("EEHitEnergyThreshold1",0.00); - desc.add("EEHitEnergyThreshold2",0.00); - desc.add("EEHitEnergyThreshold3",0.00); - desc.add("EEHitEnergyThresholdLow",0.30); - desc.add("EEHitEnergyThresholdHigh",0.30); + desc.add("EBHitEnergyThreshold", 0.08); + desc.add("EEHitEnergyThreshold0", 0.30); + desc.add("EEHitEnergyThreshold1", 0.00); + desc.add("EEHitEnergyThreshold2", 0.00); + desc.add("EEHitEnergyThreshold3", 0.00); + desc.add("EEHitEnergyThresholdLow", 0.30); + desc.add("EEHitEnergyThresholdHigh", 0.30); // Prescale events only containing isolated tracks in the range - desc.add("momentumRangeLow",20.0); - desc.add("momentumRangeHigh",40.0); - desc.add("preScaleFactor",10); - desc.add("momentumHigh",60.0); - desc.add("preScaleHigh",2); - descriptions.add("alcaIsoTracksFilter",desc); + desc.add("momentumRangeLow", 20.0); + desc.add("momentumRangeHigh", 40.0); + desc.add("preScaleFactor", 10); + desc.add("momentumHigh", 60.0); + desc.add("preScaleHigh", 2); + descriptions.add("alcaIsoTracksFilter", desc); } //define this as a plug-in diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksProducerFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksProducerFilter.cc index 9b6d3339e0a1d..68f1c69206ab0 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksProducerFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsoTracksProducerFilter.cc @@ -33,67 +33,60 @@ namespace AlCaIsoTracksProdFilter { Counters() : nAll_(0), nGood_(0) {} mutable std::atomic nAll_, nGood_; }; -} +} // namespace AlCaIsoTracksProdFilter class AlCaIsoTracksProducerFilter : public edm::stream::EDFilter > { public: - explicit AlCaIsoTracksProducerFilter(edm::ParameterSet const&, - const AlCaIsoTracksProdFilter::Counters* count); + explicit AlCaIsoTracksProducerFilter(edm::ParameterSet const&, const AlCaIsoTracksProdFilter::Counters* count); ~AlCaIsoTracksProducerFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iConfig) { return std::make_unique(); } bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaIsoTracksProdFilter::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - + static void globalEndJob(const AlCaIsoTracksProdFilter::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - - // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::vector trigNames_; - unsigned int nRun_, nAll_, nGood_; - edm::EDGetTokenT tok_trigRes_; - std::string processName_; - edm::InputTag triggerResultsLabel_; + // ----------member data --------------------------- + HLTConfigProvider hltConfig_; + std::vector trigNames_; + unsigned int nRun_, nAll_, nGood_; + edm::EDGetTokenT tok_trigRes_; + std::string processName_; + edm::InputTag triggerResultsLabel_; }; -AlCaIsoTracksProducerFilter::AlCaIsoTracksProducerFilter(const edm::ParameterSet& iConfig, const AlCaIsoTracksProdFilter::Counters* count) : - nRun_(0), nAll_(0), nGood_(0) { +AlCaIsoTracksProducerFilter::AlCaIsoTracksProducerFilter(const edm::ParameterSet& iConfig, + const AlCaIsoTracksProdFilter::Counters* count) + : nRun_(0), nAll_(0), nGood_(0) { //now do what ever initialization is needed - trigNames_ = iConfig.getParameter >("triggers"); - processName_ = iConfig.getParameter("processName"); - triggerResultsLabel_ = iConfig.getParameter("triggerResultLabel"); + trigNames_ = iConfig.getParameter >("triggers"); + processName_ = iConfig.getParameter("processName"); + triggerResultsLabel_ = iConfig.getParameter("triggerResultLabel"); // define tokens for access - tok_trigRes_ = consumes(triggerResultsLabel_); - - edm::LogInfo("HcalIsoTrack") << "Use process name " << processName_ - << " Labels " << triggerResultsLabel_ - << " selecting " << trigNames_.size() - << " triggers\n"; - for (unsigned int k=0; k(triggerResultsLabel_); + + edm::LogInfo("HcalIsoTrack") << "Use process name " << processName_ << " Labels " << triggerResultsLabel_ + << " selecting " << trigNames_.size() << " triggers\n"; + for (unsigned int k = 0; k < trigNames_.size(); ++k) { + edm::LogInfo("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k] << std::endl; } } AlCaIsoTracksProducerFilter::~AlCaIsoTracksProducerFilter() {} -bool AlCaIsoTracksProducerFilter::filter(edm::Event& iEvent, - edm::EventSetup const& iSetup) { +bool AlCaIsoTracksProducerFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) { ++nAll_; - edm::LogInfo("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing() << std::endl; - + edm::LogInfo("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() << std::endl; + //Find if the event passes one of the chosen triggers bool triggerSatisfied(false); if (trigNames_.empty()) { @@ -103,64 +96,59 @@ bool AlCaIsoTracksProducerFilter::filter(edm::Event& iEvent, iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; i 0) { - triggerSatisfied = true; - break; - } - } - } - if (triggerSatisfied) break; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigNames_[i]) != std::string::npos) { + edm::LogInfo("HcalIsoTrack") << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" + << triggerSatisfied << std::endl; + if (hlt > 0) { + triggerSatisfied = true; + break; + } + } + } + if (triggerSatisfied) + break; } } } - if (triggerSatisfied) ++nGood_; + if (triggerSatisfied) + ++nGood_; return triggerSatisfied; } void AlCaIsoTracksProducerFilter::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; } void AlCaIsoTracksProducerFilter::globalEndJob(const AlCaIsoTracksProdFilter::Counters* count) { - edm::LogInfo("HcalIsoTrack") << "Selects " << count->nGood_ << " in " - << count->nAll_ << " events " << std::endl; + edm::LogInfo("HcalIsoTrack") << "Selects " << count->nGood_ << " in " << count->nAll_ << " events " << std::endl; } -void AlCaIsoTracksProducerFilter::beginRun(edm::Run const& iRun, - edm::EventSetup const& iSetup) { +void AlCaIsoTracksProducerFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); - bool flag = hltConfig_.init(iRun,iSetup,processName_,changed); - edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << flag << std::endl; + bool flag = hltConfig_.init(iRun, iSetup, processName_, changed); + edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " << flag << std::endl; } -void AlCaIsoTracksProducerFilter::endRun(edm::Run const& iRun, - edm::EventSetup const&) { +void AlCaIsoTracksProducerFilter::endRun(edm::Run const& iRun, edm::EventSetup const&) { ++nRun_; - edm::LogInfo("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run() - << std::endl; + edm::LogInfo("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run() << std::endl; } void AlCaIsoTracksProducerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; - desc.add("triggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - std::vector trigger = {"HLT_IsoTrackHB","HLT_IsoTrackHE"}; - desc.add >("triggers",trigger); - desc.add("processName","HLT"); - descriptions.add("alcaIsoTracksProducerFilter",desc); + desc.add("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + std::vector trigger = {"HLT_IsoTrackHB", "HLT_IsoTrackHE"}; + desc.add >("triggers", trigger); + desc.add("processName", "HLT"); + descriptions.add("alcaIsoTracksProducerFilter", desc); } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchFilter.cc index 713c47e791232..51fe01f829681 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchFilter.cc @@ -33,60 +33,57 @@ namespace AlCaIsolatedBunch { Counters() : nAll_(0), nGood_(0) {} mutable std::atomic nAll_, nGood_; }; -} +} // namespace AlCaIsolatedBunch class AlCaIsolatedBunchFilter : public edm::stream::EDFilter > { public: explicit AlCaIsolatedBunchFilter(edm::ParameterSet const&, const AlCaIsolatedBunch::Counters* count); ~AlCaIsolatedBunchFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iConfig) { return std::unique_ptr(new AlCaIsolatedBunch::Counters()); } bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaIsolatedBunch::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - + static void globalEndJob(const AlCaIsolatedBunch::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::vector trigJetNames_, trigIsoBunchNames_; - edm::InputTag theTriggerResultsLabel_; - std::string processName_; - unsigned int nRun_, nAll_, nGood_; - edm::EDGetTokenT tok_trigRes_; + HLTConfigProvider hltConfig_; + std::vector trigJetNames_, trigIsoBunchNames_; + edm::InputTag theTriggerResultsLabel_; + std::string processName_; + unsigned int nRun_, nAll_, nGood_; + edm::EDGetTokenT tok_trigRes_; }; // // constructors and destructor // -AlCaIsolatedBunchFilter::AlCaIsolatedBunchFilter(const edm::ParameterSet& iConfig, const AlCaIsolatedBunch::Counters* count) : - nRun_(0), nAll_(0), nGood_(0) { +AlCaIsolatedBunchFilter::AlCaIsolatedBunchFilter(const edm::ParameterSet& iConfig, + const AlCaIsolatedBunch::Counters* count) + : nRun_(0), nAll_(0), nGood_(0) { //now do what ever initialization is needed - trigJetNames_ = iConfig.getParameter >("triggerJet"); - trigIsoBunchNames_ = iConfig.getParameter >("triggerIsoBunch"); - processName_ = iConfig.getParameter("processName"); + trigJetNames_ = iConfig.getParameter >("triggerJet"); + trigIsoBunchNames_ = iConfig.getParameter >("triggerIsoBunch"); + processName_ = iConfig.getParameter("processName"); theTriggerResultsLabel_ = iConfig.getParameter("triggerResultLabel"); // define tokens for access - tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); - edm::LogInfo("AlCaIsoBunch") << "Input tag for trigger results " - << theTriggerResultsLabel_ - << " with " << trigIsoBunchNames_.size() << ":" - << trigJetNames_.size() << " trigger names and" - << " process " << processName_ << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Input tag for trigger results " << theTriggerResultsLabel_ << " with " + << trigIsoBunchNames_.size() << ":" << trigJetNames_.size() << " trigger names and" + << " process " << processName_ << std::endl; for (unsigned int k = 0; k < trigIsoBunchNames_.size(); ++k) - edm::LogInfo("AlCaIsoBunch") << "Isolated Bunch[" << k << "] " - << trigIsoBunchNames_[k] << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Isolated Bunch[" << k << "] " << trigIsoBunchNames_[k] << std::endl; for (unsigned int k = 0; k < trigJetNames_.size(); ++k) - edm::LogInfo("AlCaIsoBunch") << "Jet Trigger[" << k << "] " - << trigJetNames_[k] << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Jet Trigger[" << k << "] " << trigJetNames_[k] << std::endl; } AlCaIsolatedBunchFilter::~AlCaIsolatedBunchFilter() {} @@ -96,15 +93,12 @@ AlCaIsolatedBunchFilter::~AlCaIsolatedBunchFilter() {} // // ------------ method called on each new Event ------------ -bool AlCaIsolatedBunchFilter::filter(edm::Event& iEvent, - edm::EventSetup const& iSetup) { +bool AlCaIsolatedBunchFilter::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) { bool accept(false); ++nAll_; #ifdef DebugLog - edm::LogInfo("AlCaIsoBunch") << "Run " << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing() << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() << std::endl; #endif //Step1: Find if the event passes one of the chosen triggers if ((trigIsoBunchNames_.empty()) && (trigJetNames_.empty())) { @@ -114,102 +108,102 @@ bool AlCaIsolatedBunchFilter::filter(edm::Event& iEvent, edm::Handle triggerResults; iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); bool jet(false), isobunch(false); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - if (!jet) { - for (unsigned int i=0; i 0) jet = true; - if (jet) { + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + if (!jet) { + for (unsigned int i = 0; i < trigJetNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigJetNames_[i]) != std::string::npos) { + if (hlt > 0) + jet = true; + if (jet) { #ifdef DebugLog - edm::LogInfo("AlCaIsoBunch") << triggerNames_[iHLT] - << " has got HLT flag " << hlt - << ":" << jet << ":" << isobunch - << std::endl; + edm::LogInfo("AlCaIsoBunch") + << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" << jet << ":" << isobunch << std::endl; #endif - break; - } - } - } - } - if (!isobunch) { - for (unsigned int i=0; i 0) isobunch = true; - if (isobunch) { + break; + } + } + } + } + if (!isobunch) { + for (unsigned int i = 0; i < trigIsoBunchNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigIsoBunchNames_[i]) != std::string::npos) { + if (hlt > 0) + isobunch = true; + if (isobunch) { #ifdef DebugLog - edm::LogInfo("AlCaIsoBunch") << triggerNames_[iHLT] - << " has got HLT flag " << hlt - << ":" << jet << ":" << isobunch - << std::endl; + edm::LogInfo("AlCaIsoBunch") + << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" << jet << ":" << isobunch << std::endl; #endif - break; - } - } - } - } - if (jet && isobunch) { - accept = true; - break; - } + break; + } + } + } + } + if (jet && isobunch) { + accept = true; + break; + } } } } // Step 2: Return the acceptance flag - if (accept) ++nGood_; + if (accept) + ++nGood_; return accept; } // AlCaIsolatedBunchFilter::filter // ------------ method called once each job just after ending the event loop ------------ void AlCaIsolatedBunchFilter::endStream() { - globalCache()->nAll_ += nAll_; + globalCache()->nAll_ += nAll_; globalCache()->nGood_ += nGood_; } void AlCaIsolatedBunchFilter::globalEndJob(const AlCaIsolatedBunch::Counters* count) { - edm::LogInfo("AlCaIsoBunch") << "Selects " << count->nGood_ << " in " - << count->nAll_ << " events" << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Selects " << count->nGood_ << " in " << count->nAll_ << " events" << std::endl; } - // ------------ method called when starting to processes a run ------------ void AlCaIsolatedBunchFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); - edm::LogInfo("AlCaIsoBunch") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " - << hltConfig_.init(iRun,iSetup,processName_,changed) - << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " + << hltConfig_.init(iRun, iSetup, processName_, changed) << std::endl; } // ------------ method called when ending the processing of a run ------------ void AlCaIsolatedBunchFilter::endRun(edm::Run const& iRun, edm::EventSetup const&) { ++nRun_; - edm::LogInfo("AlCaIsoBunch") << "endRun[" << nRun_ << "] " << iRun.run() - << std::endl; + edm::LogInfo("AlCaIsoBunch") << "endRun[" << nRun_ << "] " << iRun.run() << std::endl; } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void AlCaIsolatedBunchFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("triggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - desc.add("processName", "HLT"); + desc.add("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("processName", "HLT"); std::vector isobunch = {"HLT_ZeroBias_IsolatedBunches"}; desc.add >("triggerIsoBunch", isobunch); - std::vector triggers = {"HLT_AK8PFJet", "HLT_AK8PFHT", - "HLT_CaloJet", "HLT_HT", - "HLT_JetE", "HLT_PFHT", - "HLT_DiPFJet", "HLT_PFJet", - "HLT_DiCentralPFJet", "HLT_QuadPFJet", - "HLT_L1_TripleJet_VBF", "HLT_QuadJet", - "HLT_DoubleJet", "HLT_AK8DiPFJet", - "HLT_AK4CaloJet", "HLT_AK4PFJet"}; + std::vector triggers = {"HLT_AK8PFJet", + "HLT_AK8PFHT", + "HLT_CaloJet", + "HLT_HT", + "HLT_JetE", + "HLT_PFHT", + "HLT_DiPFJet", + "HLT_PFJet", + "HLT_DiCentralPFJet", + "HLT_QuadPFJet", + "HLT_L1_TripleJet_VBF", + "HLT_QuadJet", + "HLT_DoubleJet", + "HLT_AK8DiPFJet", + "HLT_AK4CaloJet", + "HLT_AK4PFJet"}; desc.add >("triggerJet", triggers); - descriptions.add("alcaIsolatedBunchFilter",desc); + descriptions.add("alcaIsolatedBunchFilter", desc); } //define this as a plug-in diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchSelector.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchSelector.cc index da131f2047839..02301e060a8ed 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchSelector.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaIsolatedBunchSelector.cc @@ -33,52 +33,51 @@ namespace AlCaIsolatedBunch { Counters() : nAll_(0), nGood_(0) {} mutable std::atomic nAll_, nGood_; }; -} +} // namespace AlCaIsolatedBunch class AlCaIsolatedBunchSelector : public edm::stream::EDFilter > { public: explicit AlCaIsolatedBunchSelector(edm::ParameterSet const&, const AlCaIsolatedBunch::Counters* count); ~AlCaIsolatedBunchSelector() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iConfig) { return std::unique_ptr(new AlCaIsolatedBunch::Counters()); } bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaIsolatedBunch::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - + static void globalEndJob(const AlCaIsolatedBunch::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::string trigName_; - edm::InputTag theTriggerResultsLabel_; - std::string processName_; - unsigned int nRun_, nAll_, nGood_; - edm::EDGetTokenT tok_trigRes_; + HLTConfigProvider hltConfig_; + std::string trigName_; + edm::InputTag theTriggerResultsLabel_; + std::string processName_; + unsigned int nRun_, nAll_, nGood_; + edm::EDGetTokenT tok_trigRes_; }; // // constructors and destructor // -AlCaIsolatedBunchSelector::AlCaIsolatedBunchSelector(const edm::ParameterSet& iConfig, const AlCaIsolatedBunch::Counters* count) : - nRun_(0), nAll_(0), nGood_(0) { +AlCaIsolatedBunchSelector::AlCaIsolatedBunchSelector(const edm::ParameterSet& iConfig, + const AlCaIsolatedBunch::Counters* count) + : nRun_(0), nAll_(0), nGood_(0) { //now do what ever initialization is needed - trigName_ = iConfig.getParameter("triggerName"); - processName_ = iConfig.getParameter("processName"); + trigName_ = iConfig.getParameter("triggerName"); + processName_ = iConfig.getParameter("processName"); theTriggerResultsLabel_ = iConfig.getParameter("triggerResultLabel"); // define tokens for access - tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); - edm::LogInfo("AlCaIsoBunch") << "Input tag for trigger results " - << theTriggerResultsLabel_ - << " with trigger name " << trigName_ - << " and process " << processName_ << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Input tag for trigger results " << theTriggerResultsLabel_ << " with trigger name " + << trigName_ << " and process " << processName_ << std::endl; } AlCaIsolatedBunchSelector::~AlCaIsolatedBunchSelector() {} @@ -88,77 +87,69 @@ AlCaIsolatedBunchSelector::~AlCaIsolatedBunchSelector() {} // // ------------ method called on each new Event ------------ -bool AlCaIsolatedBunchSelector::filter(edm::Event& iEvent, - edm::EventSetup const& iSetup) { +bool AlCaIsolatedBunchSelector::filter(edm::Event& iEvent, edm::EventSetup const& iSetup) { bool accept(false); ++nAll_; #ifdef DebugLog - edm::LogInfo("AlCaIsoBunch") << "Run " << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing() << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() << std::endl; #endif //Step1: Find if the event passes the chosen trigger edm::Handle triggerResults; iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - if (triggerNames_[iHLT].find(trigName_)!=std::string::npos) { - if (hlt > 0) { - accept = true; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + if (triggerNames_[iHLT].find(trigName_) != std::string::npos) { + if (hlt > 0) { + accept = true; #ifdef DebugLog - edm::LogInfo("AlCaIsoBunch") << triggerNames_[iHLT] - << " has got HLT flag " << hlt - << ":" << accept << std::endl; + edm::LogInfo("AlCaIsoBunch") << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" << accept + << std::endl; #endif - break; - } + break; + } } } } // Step 2: Return the acceptance flag - if (accept) ++nGood_; + if (accept) + ++nGood_; return accept; } // AlCaIsolatedBunchSelector::filter // ------------ method called once each job just after ending the event loop ------------ void AlCaIsolatedBunchSelector::endStream() { - globalCache()->nAll_ += nAll_; + globalCache()->nAll_ += nAll_; globalCache()->nGood_ += nGood_; } void AlCaIsolatedBunchSelector::globalEndJob(const AlCaIsolatedBunch::Counters* count) { - edm::LogInfo("AlCaIsoBunch") << "Selects " << count->nGood_ << " in " - << count->nAll_ << " events" << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Selects " << count->nGood_ << " in " << count->nAll_ << " events" << std::endl; } - // ------------ method called when starting to processes a run ------------ void AlCaIsolatedBunchSelector::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); - edm::LogInfo("AlCaIsoBunch") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " - << hltConfig_.init(iRun,iSetup,processName_,changed) - << std::endl; + edm::LogInfo("AlCaIsoBunch") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " + << hltConfig_.init(iRun, iSetup, processName_, changed) << std::endl; } // ------------ method called when ending the processing of a run ------------ void AlCaIsolatedBunchSelector::endRun(edm::Run const& iRun, edm::EventSetup const&) { ++nRun_; - edm::LogInfo("AlCaIsoBunch") << "endRun[" << nRun_ << "] " << iRun.run() - << std::endl; + edm::LogInfo("AlCaIsoBunch") << "endRun[" << nRun_ << "] " << iRun.run() << std::endl; } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void AlCaIsolatedBunchSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("triggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - desc.add("processName", "HLT"); - desc.add("triggerName", "HLT_HcalIsolatedBunch"); - descriptions.add("alcaIsolatedBunchSelector",desc); + desc.add("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("processName", "HLT"); + desc.add("triggerName", "HLT_HcalIsolatedBunch"); + descriptions.add("alcaIsolatedBunchSelector", desc); } //define this as a plug-in diff --git a/Calibration/HcalAlCaRecoProducers/plugins/AlCaLowPUHBHEMuonFilter.cc b/Calibration/HcalAlCaRecoProducers/plugins/AlCaLowPUHBHEMuonFilter.cc index c770aadd9e971..da1acfaeedea8 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/AlCaLowPUHBHEMuonFilter.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/AlCaLowPUHBHEMuonFilter.cc @@ -44,39 +44,38 @@ namespace AlCaLowPUHBHEMuons { Counters() : nAll_(0), nGood_(0) {} mutable std::atomic nAll_, nGood_; }; -} +} // namespace AlCaLowPUHBHEMuons class AlCaLowPUHBHEMuonFilter : public edm::stream::EDFilter > { public: explicit AlCaLowPUHBHEMuonFilter(edm::ParameterSet const&, const AlCaLowPUHBHEMuons::Counters* count); ~AlCaLowPUHBHEMuonFilter() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } - + bool filter(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaLowPUHBHEMuons::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: + static void globalEndJob(const AlCaLowPUHBHEMuons::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); +private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - + // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - std::vector trigNames_, HLTNames_; - std::string processName_; - bool pfCut_; - double trackIsoCut_, caloIsoCut_, pfIsoCut_, minimumMuonpT_, minimumMuoneta_; - int preScale_; - unsigned int nRun_, nAll_, nGood_; - edm::InputTag triggerResults_, labelMuon_; - edm::EDGetTokenT tok_trigEvt; - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_Muon_; + HLTConfigProvider hltConfig_; + std::vector trigNames_, HLTNames_; + std::string processName_; + bool pfCut_; + double trackIsoCut_, caloIsoCut_, pfIsoCut_, minimumMuonpT_, minimumMuoneta_; + int preScale_; + unsigned int nRun_, nAll_, nGood_; + edm::InputTag triggerResults_, labelMuon_; + edm::EDGetTokenT tok_trigEvt; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_Muon_; }; // @@ -90,28 +89,27 @@ class AlCaLowPUHBHEMuonFilter : public edm::stream::EDFilter >("triggers"); - processName_ = iConfig.getParameter("processName"); - triggerResults_ = iConfig.getParameter("triggerResultLabel"); - labelMuon_ = iConfig.getParameter("muonLabel"); - pfIsoCut_ = iConfig.getParameter("pfIsolationCut"); - minimumMuonpT_ = iConfig.getParameter("minimumMuonpT"); - minimumMuoneta_ = iConfig.getParameter("minimumMuoneta"); + trigNames_ = iConfig.getParameter >("triggers"); + processName_ = iConfig.getParameter("processName"); + triggerResults_ = iConfig.getParameter("triggerResultLabel"); + labelMuon_ = iConfig.getParameter("muonLabel"); + pfIsoCut_ = iConfig.getParameter("pfIsolationCut"); + minimumMuonpT_ = iConfig.getParameter("minimumMuonpT"); + minimumMuoneta_ = iConfig.getParameter("minimumMuoneta"); // define tokens for access - tok_trigRes_ = consumes(triggerResults_); - tok_Muon_ = consumes(labelMuon_); - edm::LogInfo("LowPUHBHEMuon") << "Parameters read from config file \n" - << "Process " << processName_ - << " PF Isolation Cuts " << pfIsoCut_ - << " minimum Muon pT cut "<< minimumMuonpT_ - << " minimum Muon eta cut "<< minimumMuoneta_; - for (unsigned int k=0; k(triggerResults_); + tok_Muon_ = consumes(labelMuon_); + edm::LogInfo("LowPUHBHEMuon") << "Parameters read from config file \n" + << "Process " << processName_ << " PF Isolation Cuts " << pfIsoCut_ + << " minimum Muon pT cut " << minimumMuonpT_ << " minimum Muon eta cut " + << minimumMuoneta_; + for (unsigned int k = 0; k < trigNames_.size(); ++k) edm::LogInfo("LowPUHBHEMuon") << "Trigger[" << k << "] " << trigNames_[k]; -} // AlCaLowPUHBHEMuonFilter::AlCaLowPUHBHEMuonFilter constructor - +} // AlCaLowPUHBHEMuonFilter::AlCaLowPUHBHEMuonFilter constructor AlCaLowPUHBHEMuonFilter::~AlCaLowPUHBHEMuonFilter() {} @@ -124,11 +122,9 @@ bool AlCaLowPUHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& bool accept(false); ++nAll_; #ifdef EDM_ML_DEBUG - edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); + edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Run " << iEvent.id().run() << " Event " + << iEvent.id().event() << " Luminosity " << iEvent.luminosityBlock() << " Bunch " + << iEvent.bunchCrossing(); #endif //Step1: Find if the event passes one of the chosen triggers /////////////////////////////TriggerResults @@ -137,21 +133,21 @@ bool AlCaLowPUHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& if (triggerResults.isValid()) { bool ok(false); std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); //std::cout << "trigger names: "< 0) ok = true; + if (hlt > 0) + ok = true; #ifdef EDM_ML_DEBUG - edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Trigger " - << triggerNames_[iHLT] << " Flag " - << hlt << ":" << ok; + edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Trigger " << triggerNames_[iHLT] << " Flag " << hlt + << ":" << ok; #endif - } + } } } if (ok) { @@ -159,52 +155,49 @@ bool AlCaLowPUHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& //Get magnetic field edm::ESHandle bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); // get handles to calogeometry edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + // Relevant blocks from iEvent edm::Handle _Muon; iEvent.getByToken(tok_Muon_, _Muon); #ifdef EDM_ML_DEBUG - edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Muon Handle " - << _Muon.isValid(); + edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Muon Handle " << _Muon.isValid(); #endif - if (_Muon.isValid()) { - for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); - RecMuon!= _Muon->end(); ++RecMuon) { + if (_Muon.isValid()) { + for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon != _Muon->end(); ++RecMuon) { #ifdef EDM_ML_DEBUG - edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Muon:Track " - << RecMuon->track().isNonnull() - << " innerTrack " - << RecMuon->innerTrack().isNonnull() - << " outerTrack " - << RecMuon->outerTrack().isNonnull() - << " globalTrack " - << RecMuon->globalTrack().isNonnull(); + edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Muon:Track " << RecMuon->track().isNonnull() + << " innerTrack " << RecMuon->innerTrack().isNonnull() << " outerTrack " + << RecMuon->outerTrack().isNonnull() << " globalTrack " + << RecMuon->globalTrack().isNonnull(); #endif - if((RecMuon->pt() < minimumMuonpT_) || fabs(RecMuon->eta()< minimumMuoneta_) ) continue; - if ((RecMuon->track().isNonnull()) && - (RecMuon->innerTrack().isNonnull()) && - (RecMuon->outerTrack().isNonnull()) && - (RecMuon->globalTrack().isNonnull())) { - const reco::Track* pTrack = (RecMuon->innerTrack()).get(); - spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); + if ((RecMuon->pt() < minimumMuonpT_) || fabs(RecMuon->eta() < minimumMuoneta_)) + continue; + if ((RecMuon->track().isNonnull()) && (RecMuon->innerTrack().isNonnull()) && + (RecMuon->outerTrack().isNonnull()) && (RecMuon->globalTrack().isNonnull())) { + const reco::Track* pTrack = (RecMuon->innerTrack()).get(); + spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, false); #ifdef EDM_ML_DEBUG - edm::LogInfo("LowPUHBHEMuon") << "AlCaLowPUHBHEMuonFilter::Propagate: ECAL " - << trackID.okECAL << " to HCAL " - << trackID.okHCAL; + edm::LogInfo("LowPUHBHEMuon") + << "AlCaLowPUHBHEMuonFilter::Propagate: ECAL " << trackID.okECAL << " to HCAL " << trackID.okHCAL; #endif - double isolR04 = ((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()); - bool isoCut = (isolR04 < pfIsoCut_); - if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { - accept = true; - break; - } - } - } + double isolR04 = + ((RecMuon->pfIsolationR04().sumChargedHadronPt + + std::max(0., + RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - + (0.5 * RecMuon->pfIsolationR04().sumPUPt))) / + RecMuon->pt()); + bool isoCut = (isolR04 < pfIsoCut_); + if ((trackID.okECAL) && (trackID.okHCAL) && isoCut) { + accept = true; + break; + } + } + } } } } @@ -218,23 +211,20 @@ bool AlCaLowPUHBHEMuonFilter::filter(edm::Event& iEvent, edm::EventSetup const& // ------------ method called once each job just after ending the event loop ------------ void AlCaLowPUHBHEMuonFilter::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; } void AlCaLowPUHBHEMuonFilter::globalEndJob(const AlCaLowPUHBHEMuons::Counters* count) { - edm::LogInfo("LowPUHBHEMuon") << "Selects " << count->nGood_ - << " good events out of " << count->nAll_ - << " total # of events"; + edm::LogInfo("LowPUHBHEMuon") << "Selects " << count->nGood_ << " good events out of " << count->nAll_ + << " total # of events"; } - // ------------ method called when starting to processes a run ------------ void AlCaLowPUHBHEMuonFilter::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); bool flag = hltConfig_.init(iRun, iSetup, processName_, changed); - edm::LogInfo("LowPUHBHEMuon") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << flag; + edm::LogInfo("LowPUHBHEMuon") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " << flag; } // ------------ method called when ending the processing of a run ------------ @@ -244,18 +234,17 @@ void AlCaLowPUHBHEMuonFilter::endRun(edm::Run const& iRun, edm::EventSetup const } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ -void -AlCaLowPUHBHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void AlCaLowPUHBHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - std::vector triggers = {"HLT_L1DoubleMu","HLT_L1SingleMu"}; - desc.add("processName","HLT"); - desc.add("triggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - desc.add("muonLabel",edm::InputTag("muons")); - desc.add("minimumMuonpT",10.0); - desc.add("minimumMuoneta",1.305); - desc.add >("triggers",triggers); - desc.add("pfIsolationCut",0.15); - descriptions.add("alcaLowPUHBHEMuonFilter",desc); + std::vector triggers = {"HLT_L1DoubleMu", "HLT_L1SingleMu"}; + desc.add("processName", "HLT"); + desc.add("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("muonLabel", edm::InputTag("muons")); + desc.add("minimumMuonpT", 10.0); + desc.add("minimumMuoneta", 1.305); + desc.add >("triggers", triggers); + desc.add("pfIsolationCut", 0.15); + descriptions.add("alcaLowPUHBHEMuonFilter", desc); } //define this as a plug-in diff --git a/Calibration/HcalAlCaRecoProducers/plugins/ConeDefinition.h b/Calibration/HcalAlCaRecoProducers/plugins/ConeDefinition.h index ceb4f6683db58..9accf33bb8443 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/ConeDefinition.h +++ b/Calibration/HcalAlCaRecoProducers/plugins/ConeDefinition.h @@ -6,93 +6,64 @@ #include "CommonTools/UtilAlgos/interface/DeltaR.h" -inline double getDistInPlaneSimple(const GlobalPoint caloPoint, - const GlobalPoint rechitPoint) -{ - +inline double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint) { // Simplified version of getDistInPlane // Assume track direction is origin -> point of hcal intersection - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z()); const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit(); - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitUnitVector = rechitVector.unit(); double dotprod = caloIntersectUnitVector.dot(rechitUnitVector); - double rechitdist = caloIntersectVector.mag()/dotprod; - + double rechitdist = caloIntersectVector.mag() / dotprod; - const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); + const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); + GlobalVector distance_vector = effectiveRechitPoint - caloPoint; - GlobalVector distance_vector = effectiveRechitPoint-caloPoint; - - if (dotprod > 0.) - { + if (dotprod > 0.) { return distance_vector.mag(); - } - else - { + } else { return 999999.; - } - } -inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint, - const GlobalVector caloVector, - const GlobalPoint rechitPoint) -{ - +inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint, + const GlobalVector caloVector, + const GlobalPoint rechitPoint) { // Simplified version of getDistInPlane : no cone "within" Hcal, but // don't assume track direction is origin -> point of hcal // intersection. - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); //p + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), + caloPoint.z()); //p const GlobalVector caloUnitVector = caloVector.unit(); - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitUnitVector = rechitVector.unit(); double dotprod_denominator = caloUnitVector.dot(rechitUnitVector); - double dotprod_numerator = caloUnitVector.dot(caloIntersectVector); - double rechitdist = dotprod_numerator/dotprod_denominator; -// double rechitdist=caloIntersectVector.dot(rechitUnitVector); - const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); - GlobalVector distance_vector = effectiveRechitPoint-caloPoint; - if (dotprod_denominator > 0. && dotprod_numerator > 0.) - { - + double dotprod_numerator = caloUnitVector.dot(caloIntersectVector); + double rechitdist = dotprod_numerator / dotprod_denominator; + // double rechitdist=caloIntersectVector.dot(rechitUnitVector); + const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); + GlobalVector distance_vector = effectiveRechitPoint - caloPoint; + if (dotprod_denominator > 0. && dotprod_numerator > 0.) { return distance_vector.mag(); - } - else - { + } else { return 999999.; } } - - inline double getDistInPlane(const GlobalVector trackDirection, - const GlobalPoint caloPoint, - const GlobalPoint rechitPoint, - double coneHeight) -{ - + const GlobalPoint caloPoint, + const GlobalPoint rechitPoint, + double coneHeight) { // The iso track candidate hits the Calo (Ecal or Hcal) at "caloPoint" // with direction "trackDirection". @@ -106,34 +77,27 @@ inline double getDistInPlane(const GlobalVector trackDirection, // the Hcal. Our approach is to see whether/where this line // intersects a cone of height "coneHeight" with vertex at caloPoint // aligned with trackDirection. - // To that end, this function returns the distance between the + // To that end, this function returns the distance between the // center of the base of the cone and the intersection of the rechit // line and the plane that contains the base of the cone. This // distance is compared with the radius of the cone outside this // function. - // Make vector of length cone height along track direction - const GlobalVector heightVector = trackDirection*coneHeight; + const GlobalVector heightVector = trackDirection * coneHeight; // Make vector from origin to point where iso track intersects the // calorimeter. - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z()); // Make vector from origin to point in center of base of cone - const GlobalVector coneBaseVector = heightVector+caloIntersectVector; + const GlobalVector coneBaseVector = heightVector + caloIntersectVector; -// Make point in center of base of cone - const GlobalPoint coneBasePoint(coneBaseVector.x(), - coneBaseVector.y(), - coneBaseVector.z()); + // Make point in center of base of cone + const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z()); // Make unit vector pointing at rechit. - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitDirection = rechitVector.unit(); // Find distance "r" along "rechit line" (with angles theta2 and @@ -152,20 +116,17 @@ inline double getDistInPlane(const GlobalVector trackDirection, // Substitute P_{rh} into equation for plane and solve for rechitdist. // rechitDist turns out to be the ratio of dot products: - double rechitdist = trackDirection.dot(coneBaseVector)/trackDirection.dot(rechitDirection); + double rechitdist = trackDirection.dot(coneBaseVector) / trackDirection.dot(rechitDirection); // Now find distance between point at center of cone base and point // where the "rechit line" intersects the plane defined by the base // of the cone; i.e. the effectiveRecHitPoint. - const GlobalVector effectiveRechitVector = rechitdist*rechitDirection; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); - + const GlobalVector effectiveRechitVector = rechitdist * rechitDirection; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); - GlobalVector distance_vector = effectiveRechitPoint-coneBasePoint; + GlobalVector distance_vector = effectiveRechitPoint - coneBasePoint; return distance_vector.mag(); } #endif - diff --git a/Calibration/HcalAlCaRecoProducers/plugins/PrescalerFHN.cc b/Calibration/HcalAlCaRecoProducers/plugins/PrescalerFHN.cc index 4c46d54b842b1..4fa74425535c7 100644 --- a/Calibration/HcalAlCaRecoProducers/plugins/PrescalerFHN.cc +++ b/Calibration/HcalAlCaRecoProducers/plugins/PrescalerFHN.cc @@ -2,7 +2,7 @@ // // Package: HCALNoiseAlCaReco // Class: HCALNoiseAlCaReco -// +// /**\class HCALNoiseAlCaReco HCALNoiseAlCaReco.cc Description: @@ -44,18 +44,17 @@ using namespace edm; class PrescalerFHN : public edm::EDFilter { - public: - explicit PrescalerFHN(const edm::ParameterSet&); - ~PrescalerFHN() override; +public: + explicit PrescalerFHN(const edm::ParameterSet&); + ~PrescalerFHN() override; - private: - void beginJob() override ; - bool filter(edm::Event&, const edm::EventSetup&) override; - void endJob() override ; - // ----------member data --------------------------- +private: + void beginJob() override; + bool filter(edm::Event&, const edm::EventSetup&) override; + void endJob() override; + // ----------member data --------------------------- - void init(const edm::TriggerResults &, - const edm::TriggerNames & triggerNames); + void init(const edm::TriggerResults&, const edm::TriggerNames& triggerNames); edm::ParameterSetID triggerNamesID_; @@ -78,15 +77,12 @@ class PrescalerFHN : public edm::EDFilter { // // constructors and destructor // -PrescalerFHN::PrescalerFHN(const edm::ParameterSet& iConfig) -{ +PrescalerFHN::PrescalerFHN(const edm::ParameterSet& iConfig) { tok_trigger = consumes(iConfig.getParameter("TriggerResultsTag")); - //now do what ever initialization is needed + //now do what ever initialization is needed std::vector prescales_in(iConfig.getParameter >("Prescales")); - for (std::vector::const_iterator cit = prescales_in.begin(); - cit != prescales_in.end(); cit++) { - + for (std::vector::const_iterator cit = prescales_in.begin(); cit != prescales_in.end(); cit++) { std::string name(cit->getParameter("HLTName")); unsigned int factor(cit->getParameter("PrescaleFactor")); @@ -95,100 +91,82 @@ PrescalerFHN::PrescalerFHN(const edm::ParameterSet& iConfig) prescales[name] = factor; prescale_counter[name] = 0; } - } - -PrescalerFHN::~PrescalerFHN() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - +PrescalerFHN::~PrescalerFHN() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) } - // // member functions // -void PrescalerFHN::init(const edm::TriggerResults &result, - const edm::TriggerNames & triggerNames) -{ +void PrescalerFHN::init(const edm::TriggerResults& result, const edm::TriggerNames& triggerNames) { trigger_indices.clear(); - for (std::map::const_iterator cit = prescales.begin(); - cit != prescales.end(); cit++) { - + for (std::map::const_iterator cit = prescales.begin(); cit != prescales.end(); cit++) { trigger_indices[cit->first] = triggerNames.triggerIndex(cit->first); - + if (trigger_indices[cit->first] >= result.size()) { // trigger path not found LogDebug("") << "requested HLT path does not exist: " << cit->first; trigger_indices.erase(cit->first); } - } } // ------------ method called on each new Event ------------ -bool -PrescalerFHN::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; +bool PrescalerFHN::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; - /* Goal for this skim: + /* Goal for this skim: Prescaling MET HLT paths Option to turn off HSCP filter - Doing that by treating it as an HLT with prescale 1 */ - // Trying to mirror HLTrigger/HLTfilters/src/HLTHighLevel.cc where possible - - Handle trh; - iEvent.getByToken(tok_trigger, trh); - - if (trh.isValid()) { - LogDebug("") << "TriggerResults found, number of HLT paths: " << trh->size(); - } else { - LogDebug("") << "TriggerResults product not found - returning result=false!"; - return false; - } - - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*trh); - if (triggerNamesID_ != triggerNames.parameterSetID()) { - triggerNamesID_ = triggerNames.parameterSetID(); - init(*trh, triggerNames); - } - - // Trigger indices are ready at this point - // - Begin checking for HLT bits - - bool accept_event = false; - for (std::map::const_iterator cit = trigger_indices.begin(); - cit != trigger_indices.end(); cit++) { - if (trh->accept(cit->second)) { - prescale_counter[cit->first]++; - if (prescale_counter[cit->first] >= prescales[cit->first]) { - accept_event = true; - prescale_counter[cit->first] = 0; - } - } - } - - return accept_event; + // Trying to mirror HLTrigger/HLTfilters/src/HLTHighLevel.cc where possible + + Handle trh; + iEvent.getByToken(tok_trigger, trh); + + if (trh.isValid()) { + LogDebug("") << "TriggerResults found, number of HLT paths: " << trh->size(); + } else { + LogDebug("") << "TriggerResults product not found - returning result=false!"; + return false; + } + + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*trh); + if (triggerNamesID_ != triggerNames.parameterSetID()) { + triggerNamesID_ = triggerNames.parameterSetID(); + init(*trh, triggerNames); + } + + // Trigger indices are ready at this point + // - Begin checking for HLT bits + + bool accept_event = false; + for (std::map::const_iterator cit = trigger_indices.begin(); cit != trigger_indices.end(); + cit++) { + if (trh->accept(cit->second)) { + prescale_counter[cit->first]++; + if (prescale_counter[cit->first] >= prescales[cit->first]) { + accept_event = true; + prescale_counter[cit->first] = 0; + } + } + } + + return accept_event; } // ------------ method called once each job just before starting event loop ------------ -void -PrescalerFHN::beginJob() -{ -} +void PrescalerFHN::beginJob() {} // ------------ method called once each job just after ending the event loop ------------ -void -PrescalerFHN::endJob() { -} +void PrescalerFHN::endJob() {} //define this as a plug-in DEFINE_FWK_MODULE(PrescalerFHN); diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaDiJetsProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaDiJetsProducer.cc index 4b3853cc0fc63..83a4c7841645d 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaDiJetsProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaDiJetsProducer.cc @@ -31,77 +31,80 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" -#include +#include // // class declaration // class AlCaDiJetsProducer : public edm::EDProducer { - public: +public: explicit AlCaDiJetsProducer(const edm::ParameterSet&); ~AlCaDiJetsProducer() override; - void beginJob() override ; - void produce(edm::Event &, const edm::EventSetup&) override; + void beginJob() override; + void produce(edm::Event&, const edm::EventSetup&) override; void endJob() override; - private: - bool select (reco::PFJetCollection); + +private: + bool select(reco::PFJetCollection); // ----------member data --------------------------- - - edm::InputTag labelPFJet_, labelHBHE_, labelHF_, labelHO_, labelPFCandidate_, labelVertex_;//labelTrigger_, - double minPtJet_; - int nAll_, nSelect_; - - edm::EDGetTokenT tok_PFJet_; - edm::EDGetTokenT>> tok_HBHE_; - edm::EDGetTokenT>> tok_HF_; - edm::EDGetTokenT>> tok_HO_; + + edm::InputTag labelPFJet_, labelHBHE_, labelHF_, labelHO_, labelPFCandidate_, labelVertex_; //labelTrigger_, + double minPtJet_; + int nAll_, nSelect_; + + edm::EDGetTokenT tok_PFJet_; + edm::EDGetTokenT>> tok_HBHE_; + edm::EDGetTokenT>> tok_HF_; + edm::EDGetTokenT>> tok_HO_; //edm::EDGetTokenT tok_TrigRes_; - edm::EDGetTokenT tok_PFCand_; - edm::EDGetTokenT tok_Vertex_; + edm::EDGetTokenT tok_PFCand_; + edm::EDGetTokenT tok_Vertex_; }; AlCaDiJetsProducer::AlCaDiJetsProducer(const edm::ParameterSet& iConfig) : nAll_(0), nSelect_(0) { - // Take input - labelPFJet_ = iConfig.getParameter("PFjetInput"); - labelHBHE_ = iConfig.getParameter("HBHEInput"); - labelHF_ = iConfig.getParameter("HFInput"); - labelHO_ = iConfig.getParameter("HOInput"); + // Take input + labelPFJet_ = iConfig.getParameter("PFjetInput"); + labelHBHE_ = iConfig.getParameter("HBHEInput"); + labelHF_ = iConfig.getParameter("HFInput"); + labelHO_ = iConfig.getParameter("HOInput"); //labelTrigger_ = iConfig.getParameter("TriggerResults"); - labelPFCandidate_= iConfig.getParameter("particleFlowInput"); - labelVertex_ = iConfig.getParameter("VertexInput"); - minPtJet_ = iConfig.getParameter("MinPtJet"); - - tok_PFJet_ = consumes(labelPFJet_); - tok_HBHE_ = consumes>>(labelHBHE_); - tok_HF_ = consumes>>(labelHF_); - tok_HO_ = consumes>>(labelHO_); + labelPFCandidate_ = iConfig.getParameter("particleFlowInput"); + labelVertex_ = iConfig.getParameter("VertexInput"); + minPtJet_ = iConfig.getParameter("MinPtJet"); + + tok_PFJet_ = consumes(labelPFJet_); + tok_HBHE_ = consumes>>(labelHBHE_); + tok_HF_ = consumes>>(labelHF_); + tok_HO_ = consumes>>(labelHO_); //tok_TrigRes_= consumes(labelTrigger_); tok_PFCand_ = consumes(labelPFCandidate_); tok_Vertex_ = consumes(labelVertex_); // register your products produces(labelPFJet_.encode()); - produces>>(labelHBHE_.encode()); - produces>>(labelHF_.encode()); - produces>>(labelHO_.encode()); + produces>>(labelHBHE_.encode()); + produces>>(labelHF_.encode()); + produces>>(labelHO_.encode()); //produces(labelTrigger_.encode()); produces(labelPFCandidate_.encode()); - produces(labelVertex_.encode()); + produces(labelVertex_.encode()); } -AlCaDiJetsProducer::~AlCaDiJetsProducer() { } +AlCaDiJetsProducer::~AlCaDiJetsProducer() {} -void AlCaDiJetsProducer::beginJob() { } +void AlCaDiJetsProducer::beginJob() {} void AlCaDiJetsProducer::endJob() { edm::LogInfo("AlcaDiJets") << "Accepts " << nSelect_ << " events from a total of " << nAll_ << " events"; } -bool AlCaDiJetsProducer::select (reco::PFJetCollection jt) { - if (jt.size()<2) return false; - if (((jt.at(0)).pt()) pfjet; - iEvent.getByToken(tok_PFJet_,pfjet); + iEvent.getByToken(tok_PFJet_, pfjet); if (!pfjet.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelPFJet_; - return ; + return; } const reco::PFJetCollection pfjets = *(pfjet.product()); edm::Handle pfc; - iEvent.getByToken(tok_PFCand_,pfc); + iEvent.getByToken(tok_PFCand_, pfc); if (!pfc.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelPFCandidate_; - return ; + return; } const reco::PFCandidateCollection pfcand = *(pfc.product()); edm::Handle vt; - iEvent.getByToken(tok_Vertex_,vt); + iEvent.getByToken(tok_Vertex_, vt); if (!vt.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelVertex_; - return ; + return; } const reco::VertexCollection vtx = *(vt.product()); - edm::Handle > > hbhe; - iEvent.getByToken(tok_HBHE_,hbhe); + edm::Handle>> hbhe; + iEvent.getByToken(tok_HBHE_, hbhe); if (!hbhe.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHBHE_; - return ; + return; } - const edm::SortedCollection > Hithbhe = *(hbhe.product()); + const edm::SortedCollection> Hithbhe = *(hbhe.product()); - edm::Handle > > ho; - iEvent.getByToken(tok_HO_,ho); - if(!ho.isValid()) { + edm::Handle>> ho; + iEvent.getByToken(tok_HO_, ho); + if (!ho.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHO_; - return ; + return; } - const edm::SortedCollection > Hitho = *(ho.product()); - - edm::Handle > > hf; - iEvent.getByToken(tok_HF_,hf); - if(!hf.isValid()) { + const edm::SortedCollection> Hitho = *(ho.product()); + + edm::Handle>> hf; + iEvent.getByToken(tok_HF_, hf); + if (!hf.isValid()) { edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHF_; - return ; + return; } - const edm::SortedCollection > Hithf = *(hf.product()); + const edm::SortedCollection> Hithf = *(hf.product()); // See if this event is useful bool accept = select(pfjets); @@ -164,52 +167,53 @@ void AlCaDiJetsProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet //Copy from standard place auto miniPFjetCollection = std::make_unique(); - for(reco::PFJetCollection::const_iterator pfjetItr=pfjets.begin(); - pfjetItr!=pfjets.end(); pfjetItr++) { + for (reco::PFJetCollection::const_iterator pfjetItr = pfjets.begin(); pfjetItr != pfjets.end(); pfjetItr++) { miniPFjetCollection->push_back(*pfjetItr); } auto miniPFCandCollection = std::make_unique(); - for(reco::PFCandidateCollection::const_iterator pfcItr=pfcand.begin(); - pfcItr!=pfcand.end(); pfcItr++) { + for (reco::PFCandidateCollection::const_iterator pfcItr = pfcand.begin(); pfcItr != pfcand.end(); pfcItr++) { miniPFCandCollection->push_back(*pfcItr); } auto miniVtxCollection = std::make_unique(); - for(reco::VertexCollection::const_iterator vtxItr=vtx.begin(); - vtxItr!=vtx.end(); vtxItr++) { + for (reco::VertexCollection::const_iterator vtxItr = vtx.begin(); vtxItr != vtx.end(); vtxItr++) { miniVtxCollection->push_back(*vtxItr); } - auto miniHBHECollection = std::make_unique>>(); - for(edm::SortedCollection >::const_iterator hbheItr=Hithbhe.begin(); - hbheItr!=Hithbhe.end(); hbheItr++) { + auto miniHBHECollection = + std::make_unique>>(); + for (edm::SortedCollection>::const_iterator hbheItr = + Hithbhe.begin(); + hbheItr != Hithbhe.end(); + hbheItr++) { miniHBHECollection->push_back(*hbheItr); } - auto miniHOCollection = std::make_unique>>(); - for(edm::SortedCollection >::const_iterator hoItr=Hitho.begin(); - hoItr!=Hitho.end(); hoItr++) { + auto miniHOCollection = std::make_unique>>(); + for (edm::SortedCollection>::const_iterator hoItr = Hitho.begin(); + hoItr != Hitho.end(); + hoItr++) { miniHOCollection->push_back(*hoItr); } - auto miniHFCollection = std::make_unique>>(); - for(edm::SortedCollection >::const_iterator hfItr=Hithf.begin(); - hfItr!=Hithf.end(); hfItr++) { + auto miniHFCollection = std::make_unique>>(); + for (edm::SortedCollection>::const_iterator hfItr = Hithf.begin(); + hfItr != Hithf.end(); + hfItr++) { miniHFCollection->push_back(*hfItr); } //Put them in the event - iEvent.put(std::move(miniPFjetCollection), labelPFJet_.encode()); - iEvent.put(std::move(miniHBHECollection), labelHBHE_.encode()); - iEvent.put(std::move(miniHFCollection), labelHF_.encode()); - iEvent.put(std::move(miniHOCollection), labelHO_.encode()); + iEvent.put(std::move(miniPFjetCollection), labelPFJet_.encode()); + iEvent.put(std::move(miniHBHECollection), labelHBHE_.encode()); + iEvent.put(std::move(miniHFCollection), labelHF_.encode()); + iEvent.put(std::move(miniHOCollection), labelHO_.encode()); //iEvent.put(std::move(miniTriggerCollection), labelTrigger_.encode()); - iEvent.put(std::move(miniPFCandCollection), labelPFCandidate_.encode()); - iEvent.put(std::move(miniVtxCollection), labelVertex_.encode()); + iEvent.put(std::move(miniPFCandCollection), labelPFCandidate_.encode()); + iEvent.put(std::move(miniVtxCollection), labelVertex_.encode()); } return; - } -DEFINE_FWK_MODULE(AlCaDiJetsProducer); +DEFINE_FWK_MODULE(AlCaDiJetsProducer); diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc index 0bb608539ae53..399adb2dc81e9 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc @@ -1,83 +1,65 @@ #include "Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" - -AlCaEcalHcalReadoutsProducer::AlCaEcalHcalReadoutsProducer(const edm::ParameterSet& iConfig) -{ - - tok_ho_ = consumes(iConfig.getParameter("hoInput")); - tok_hf_ = consumes(iConfig.getParameter("hfInput")); - tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); - - //register your products - produces("HBHERecHitCollection"); - produces("HORecHitCollection"); - produces("HFRecHitCollection"); -} - - -AlCaEcalHcalReadoutsProducer::~AlCaEcalHcalReadoutsProducer() -{ - - +AlCaEcalHcalReadoutsProducer::AlCaEcalHcalReadoutsProducer(const edm::ParameterSet& iConfig) { + tok_ho_ = consumes(iConfig.getParameter("hoInput")); + tok_hf_ = consumes(iConfig.getParameter("hfInput")); + tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); + + //register your products + produces("HBHERecHitCollection"); + produces("HORecHitCollection"); + produces("HFRecHitCollection"); } +AlCaEcalHcalReadoutsProducer::~AlCaEcalHcalReadoutsProducer() {} // ------------ method called to produce the data ------------ -void -AlCaEcalHcalReadoutsProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - using namespace std; - - edm::Handle hbhe; - edm::Handle ho; - edm::Handle hf; - - iEvent.getByToken(tok_hbhe_,hbhe); - if(!hbhe.isValid()){ - LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hbhe product!" << std::endl; - return ; - } +void AlCaEcalHcalReadoutsProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + using namespace std; + + edm::Handle hbhe; + edm::Handle ho; + edm::Handle hf; + + iEvent.getByToken(tok_hbhe_, hbhe); + if (!hbhe.isValid()) { + LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hbhe product!" << std::endl; + return; + } + + iEvent.getByToken(tok_ho_, ho); + if (!ho.isValid()) { + LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get ho product!" << std::endl; + } + + iEvent.getByToken(tok_hf_, hf); + if (!hf.isValid()) { + LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hf product!" << std::endl; + } + //Create empty output collections - iEvent.getByToken(tok_ho_,ho); - if(!ho.isValid()) { - LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get ho product!" << std::endl; - } - - iEvent.getByToken(tok_hf_,hf); - if(!hf.isValid()) { - LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hf product!" << std::endl; - } - //Create empty output collections - auto miniHBHERecHitCollection = std::make_unique(); auto miniHORecHitCollection = std::make_unique(); auto miniHFRecHitCollection = std::make_unique(); const HBHERecHitCollection Hithbhe = *(hbhe.product()); - for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++) - { - miniHBHERecHitCollection->push_back(*hbheItr); - } + for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) { + miniHBHERecHitCollection->push_back(*hbheItr); + } const HORecHitCollection Hitho = *(ho.product()); - for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++) - { - miniHORecHitCollection->push_back(*hoItr); - } + for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) { + miniHORecHitCollection->push_back(*hoItr); + } const HFRecHitCollection Hithf = *(hf.product()); - for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++) - { - miniHFRecHitCollection->push_back(*hfItr); - } - - + for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) { + miniHFRecHitCollection->push_back(*hfItr); + } //Put selected information in the event iEvent.put(std::move(miniHBHERecHitCollection), "HBHERecHitCollection"); iEvent.put(std::move(miniHORecHitCollection), "HORecHitCollection"); iEvent.put(std::move(miniHFRecHitCollection), "HFRecHitCollection"); - - } diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaGammaJetProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaGammaJetProducer.cc index 4ee724b4febe3..175a7e54bb328 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaGammaJetProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaGammaJetProducer.cc @@ -31,89 +31,89 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" -#include +#include // // class declaration // class AlCaGammaJetProducer : public edm::EDProducer { - public: explicit AlCaGammaJetProducer(const edm::ParameterSet&); ~AlCaGammaJetProducer() override; - void beginJob() override ; - void produce(edm::Event &, const edm::EventSetup&) override; + void beginJob() override; + void produce(edm::Event&, const edm::EventSetup&) override; void endJob() override; private: bool select(const reco::PhotonCollection&, const reco::PFJetCollection&); // ----------member data --------------------------- - - edm::InputTag labelPhoton_, labelPFJet_, labelHBHE_, labelHF_, labelHO_, labelTrigger_, labelPFCandidate_, labelVertex_, labelPFMET_, labelGsfEle_, labelRho_, labelConv_, labelBeamSpot_, labelLoosePhot_, labelTightPhot_; - double minPtJet_, minPtPhoton_; - int nAll_, nSelect_; - - edm::EDGetTokenT tok_Photon_; - edm::EDGetTokenT tok_PFJet_; - edm::EDGetTokenT>> tok_HBHE_; - edm::EDGetTokenT>> tok_HF_; - edm::EDGetTokenT>> tok_HO_; - edm::EDGetTokenT tok_TrigRes_; - edm::EDGetTokenT tok_PFCand_; - edm::EDGetTokenT tok_Vertex_; - edm::EDGetTokenT tok_PFMET_; - edm::EDGetTokenT tok_GsfElec_; - edm::EDGetTokenT tok_Rho_; - edm::EDGetTokenT tok_Conv_; - edm::EDGetTokenT tok_BS_; - edm::EDGetTokenT > tok_loosePhoton_; - edm::EDGetTokenT > tok_tightPhoton_; + + edm::InputTag labelPhoton_, labelPFJet_, labelHBHE_, labelHF_, labelHO_, labelTrigger_, labelPFCandidate_, + labelVertex_, labelPFMET_, labelGsfEle_, labelRho_, labelConv_, labelBeamSpot_, labelLoosePhot_, labelTightPhot_; + double minPtJet_, minPtPhoton_; + int nAll_, nSelect_; + + edm::EDGetTokenT tok_Photon_; + edm::EDGetTokenT tok_PFJet_; + edm::EDGetTokenT>> tok_HBHE_; + edm::EDGetTokenT>> tok_HF_; + edm::EDGetTokenT>> tok_HO_; + edm::EDGetTokenT tok_TrigRes_; + edm::EDGetTokenT tok_PFCand_; + edm::EDGetTokenT tok_Vertex_; + edm::EDGetTokenT tok_PFMET_; + edm::EDGetTokenT tok_GsfElec_; + edm::EDGetTokenT tok_Rho_; + edm::EDGetTokenT tok_Conv_; + edm::EDGetTokenT tok_BS_; + edm::EDGetTokenT> tok_loosePhoton_; + edm::EDGetTokenT> tok_tightPhoton_; }; AlCaGammaJetProducer::AlCaGammaJetProducer(const edm::ParameterSet& iConfig) : nAll_(0), nSelect_(0) { - // Take input - labelPhoton_ = iConfig.getParameter("PhoInput"); - labelPFJet_ = iConfig.getParameter("PFjetInput"); - labelHBHE_ = iConfig.getParameter("HBHEInput"); - labelHF_ = iConfig.getParameter("HFInput"); - labelHO_ = iConfig.getParameter("HOInput"); - labelTrigger_ = iConfig.getParameter("TriggerResults"); - labelPFCandidate_= iConfig.getParameter("particleFlowInput"); - labelVertex_ = iConfig.getParameter("VertexInput"); - labelPFMET_ = iConfig.getParameter("METInput"); - labelGsfEle_ = iConfig.getParameter("gsfeleInput"); - labelRho_ = iConfig.getParameter("rhoInput"); - labelConv_ = iConfig.getParameter("ConversionsInput"); - labelBeamSpot_ = iConfig.getParameter("BeamSpotInput"); - labelLoosePhot_ = iConfig.getParameter("PhoLoose"); - labelTightPhot_ = iConfig.getParameter("PhoTight"); - minPtJet_ = iConfig.getParameter("MinPtJet"); - minPtPhoton_ = iConfig.getParameter("MinPtPhoton"); + // Take input + labelPhoton_ = iConfig.getParameter("PhoInput"); + labelPFJet_ = iConfig.getParameter("PFjetInput"); + labelHBHE_ = iConfig.getParameter("HBHEInput"); + labelHF_ = iConfig.getParameter("HFInput"); + labelHO_ = iConfig.getParameter("HOInput"); + labelTrigger_ = iConfig.getParameter("TriggerResults"); + labelPFCandidate_ = iConfig.getParameter("particleFlowInput"); + labelVertex_ = iConfig.getParameter("VertexInput"); + labelPFMET_ = iConfig.getParameter("METInput"); + labelGsfEle_ = iConfig.getParameter("gsfeleInput"); + labelRho_ = iConfig.getParameter("rhoInput"); + labelConv_ = iConfig.getParameter("ConversionsInput"); + labelBeamSpot_ = iConfig.getParameter("BeamSpotInput"); + labelLoosePhot_ = iConfig.getParameter("PhoLoose"); + labelTightPhot_ = iConfig.getParameter("PhoTight"); + minPtJet_ = iConfig.getParameter("MinPtJet"); + minPtPhoton_ = iConfig.getParameter("MinPtPhoton"); tok_Photon_ = consumes(labelPhoton_); - tok_PFJet_ = consumes(labelPFJet_); - tok_HBHE_ = consumes>>(labelHBHE_); - tok_HF_ = consumes>>(labelHF_); - tok_HO_ = consumes>>(labelHO_); - tok_TrigRes_= consumes(labelTrigger_); + tok_PFJet_ = consumes(labelPFJet_); + tok_HBHE_ = consumes>>(labelHBHE_); + tok_HF_ = consumes>>(labelHF_); + tok_HO_ = consumes>>(labelHO_); + tok_TrigRes_ = consumes(labelTrigger_); tok_PFCand_ = consumes(labelPFCandidate_); tok_Vertex_ = consumes(labelVertex_); - tok_PFMET_ = consumes(labelPFMET_); - tok_loosePhoton_ = consumes >(labelLoosePhot_); - tok_tightPhoton_ = consumes >(labelTightPhot_); + tok_PFMET_ = consumes(labelPFMET_); + tok_loosePhoton_ = consumes>(labelLoosePhot_); + tok_tightPhoton_ = consumes>(labelTightPhot_); tok_GsfElec_ = consumes(labelGsfEle_); tok_Rho_ = consumes(labelRho_); - tok_Conv_ = consumes(labelConv_); - tok_BS_ = consumes(labelBeamSpot_); + tok_Conv_ = consumes(labelConv_); + tok_BS_ = consumes(labelBeamSpot_); // register your products produces(labelPhoton_.encode()); produces(labelPFJet_.encode()); - produces>>(labelHBHE_.encode()); - produces>>(labelHF_.encode()); - produces>>(labelHO_.encode()); + produces>>(labelHBHE_.encode()); + produces>>(labelHF_.encode()); + produces>>(labelHO_.encode()); produces(labelTrigger_.encode()); produces>(labelLoosePhot_.encode()); produces>(labelTightPhot_.encode()); @@ -124,33 +124,32 @@ AlCaGammaJetProducer::AlCaGammaJetProducer(const edm::ParameterSet& iConfig) : n produces(labelGsfEle_.encode()); produces(labelConv_.encode()); produces(labelBeamSpot_.encode()); - } -AlCaGammaJetProducer::~AlCaGammaJetProducer() { } +AlCaGammaJetProducer::~AlCaGammaJetProducer() {} -void AlCaGammaJetProducer::beginJob() { } +void AlCaGammaJetProducer::beginJob() {} void AlCaGammaJetProducer::endJob() { edm::LogInfo("AlcaGammaJet") << "Accepts " << nSelect_ << " events from a total of " << nAll_ << " events"; } -bool AlCaGammaJetProducer::select (const reco::PhotonCollection &ph, const reco::PFJetCollection &jt) { - +bool AlCaGammaJetProducer::select(const reco::PhotonCollection& ph, const reco::PFJetCollection& jt) { // Check the requirement for minimum pT - if (ph.empty()) return false; + if (ph.empty()) + return false; bool ok(false); - for (reco::PFJetCollection::const_iterator itr=jt.begin(); - itr!=jt.end(); ++itr) { + for (reco::PFJetCollection::const_iterator itr = jt.begin(); itr != jt.end(); ++itr) { if (itr->pt() >= minPtJet_) { ok = true; break; } } - if (!ok) return ok; - for (reco::PhotonCollection::const_iterator itr=ph.begin(); - itr!=ph.end(); ++itr) { - if (itr->pt() >= minPtPhoton_) return ok; + if (!ok) + return ok; + for (reco::PhotonCollection::const_iterator itr = ph.begin(); itr != ph.end(); ++itr) { + if (itr->pt() >= minPtPhoton_) + return ok; } return false; } @@ -160,106 +159,106 @@ void AlCaGammaJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS // Access the collections from iEvent edm::Handle phoHandle; - iEvent.getByToken(tok_Photon_,phoHandle); + iEvent.getByToken(tok_Photon_, phoHandle); if (!phoHandle.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get the product " << labelPhoton_; - return ; + return; } const reco::PhotonCollection photon = *(phoHandle.product()); edm::Handle pfjet; - iEvent.getByToken(tok_PFJet_,pfjet); + iEvent.getByToken(tok_PFJet_, pfjet); if (!pfjet.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelPFJet_; - return ; + return; } const reco::PFJetCollection pfjets = *(pfjet.product()); edm::Handle pfc; - iEvent.getByToken(tok_PFCand_,pfc); + iEvent.getByToken(tok_PFCand_, pfc); if (!pfc.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelPFCandidate_; - return ; + return; } const reco::PFCandidateCollection pfcand = *(pfc.product()); edm::Handle vt; - iEvent.getByToken(tok_Vertex_,vt); + iEvent.getByToken(tok_Vertex_, vt); if (!vt.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelVertex_; - return ; + return; } const reco::VertexCollection vtx = *(vt.product()); edm::Handle pfmt; - iEvent.getByToken(tok_PFMET_,pfmt); + iEvent.getByToken(tok_PFMET_, pfmt); if (!pfmt.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelPFMET_; - return ; + return; } const reco::PFMETCollection pfmet = *(pfmt.product()); - edm::Handle > > hbhe; - iEvent.getByToken(tok_HBHE_,hbhe); + edm::Handle>> hbhe; + iEvent.getByToken(tok_HBHE_, hbhe); if (!hbhe.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelHBHE_; - return ; + return; } - const edm::SortedCollection > Hithbhe = *(hbhe.product()); + const edm::SortedCollection> Hithbhe = *(hbhe.product()); - edm::Handle > > ho; - iEvent.getByToken(tok_HO_,ho); - if(!ho.isValid()) { + edm::Handle>> ho; + iEvent.getByToken(tok_HO_, ho); + if (!ho.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelHO_; - return ; + return; } - const edm::SortedCollection > Hitho = *(ho.product()); - - edm::Handle > > hf; - iEvent.getByToken(tok_HF_,hf); - if(!hf.isValid()) { + const edm::SortedCollection> Hitho = *(ho.product()); + + edm::Handle>> hf; + iEvent.getByToken(tok_HF_, hf); + if (!hf.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelHF_; - return ; + return; } - const edm::SortedCollection > Hithf = *(hf.product()); + const edm::SortedCollection> Hithf = *(hf.product()); edm::Handle trig; - iEvent.getByToken(tok_TrigRes_,trig); + iEvent.getByToken(tok_TrigRes_, trig); if (!trig.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelTrigger_; - return ; + return; } const edm::TriggerResults trigres = *(trig.product()); edm::Handle rh; - iEvent.getByToken(tok_Rho_,rh); + iEvent.getByToken(tok_Rho_, rh); if (!rh.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelRho_; - return ; + return; } const double rho_val = *(rh.product()); edm::Handle gsf; - iEvent.getByToken(tok_GsfElec_,gsf); - if (!gsf.isValid()){ + iEvent.getByToken(tok_GsfElec_, gsf); + if (!gsf.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelGsfEle_; - return ; + return; } const reco::GsfElectronCollection gsfele = *(gsf.product()); edm::Handle con; - iEvent.getByToken(tok_Conv_,con); - if (!con.isValid()){ + iEvent.getByToken(tok_Conv_, con); + if (!con.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelConv_; - return ; + return; } const reco::ConversionCollection conv = *(con.product()); edm::Handle bs; - iEvent.getByToken(tok_BS_,bs); - if (!bs.isValid()){ + iEvent.getByToken(tok_BS_, bs); + if (!bs.isValid()) { edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelBeamSpot_; - return ; + return; } const reco::BeamSpot beam = *(bs.product()); @@ -270,123 +269,116 @@ void AlCaGammaJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS auto miniPFCandCollection = std::make_unique(); auto miniVtxCollection = std::make_unique(); auto miniPFMETCollection = std::make_unique(); - auto miniHBHECollection = std::make_unique>>(); - auto miniHOCollection = std::make_unique>>(); - auto miniHFCollection = std::make_unique>>(); + auto miniHBHECollection = std::make_unique>>(); + auto miniHOCollection = std::make_unique>>(); + auto miniHFCollection = std::make_unique>>(); auto miniGSFeleCollection = std::make_unique(); auto miniConversionCollection = std::make_unique(); - auto miniBeamSpotCollection = std::make_unique(beam.position(),beam.sigmaZ(), - beam.dxdz(),beam.dydz(),beam.BeamWidthX(), - beam.covariance(),beam.type()); - + auto miniBeamSpotCollection = std::make_unique( + beam.position(), beam.sigmaZ(), beam.dxdz(), beam.dydz(), beam.BeamWidthX(), beam.covariance(), beam.type()); + auto miniTriggerCollection = std::make_unique(); auto miniRhoCollection = std::make_unique(); auto miniLoosePhoton = std::make_unique>(); auto miniTightPhoton = std::make_unique>(); - // See if this event is useful bool accept = select(photon, pfjets); if (accept) { nSelect_++; //Copy from standard place - for(reco::PFJetCollection::const_iterator pfjetItr=pfjets.begin(); - pfjetItr!=pfjets.end(); pfjetItr++) { + for (reco::PFJetCollection::const_iterator pfjetItr = pfjets.begin(); pfjetItr != pfjets.end(); pfjetItr++) { miniPFjetCollection->push_back(*pfjetItr); } - for(reco::PhotonCollection::const_iterator phoItr=photon.begin(); - phoItr!=photon.end(); phoItr++) { + for (reco::PhotonCollection::const_iterator phoItr = photon.begin(); phoItr != photon.end(); phoItr++) { miniPhotonCollection->push_back(*phoItr); } - for(reco::PFCandidateCollection::const_iterator pfcItr=pfcand.begin(); - pfcItr!=pfcand.end(); pfcItr++) { + for (reco::PFCandidateCollection::const_iterator pfcItr = pfcand.begin(); pfcItr != pfcand.end(); pfcItr++) { miniPFCandCollection->push_back(*pfcItr); } - for(reco::VertexCollection::const_iterator vtxItr=vtx.begin(); - vtxItr!=vtx.end(); vtxItr++) { + for (reco::VertexCollection::const_iterator vtxItr = vtx.begin(); vtxItr != vtx.end(); vtxItr++) { miniVtxCollection->push_back(*vtxItr); } - for(reco::PFMETCollection::const_iterator pfmetItr=pfmet.begin(); - pfmetItr!=pfmet.end(); pfmetItr++) { + for (reco::PFMETCollection::const_iterator pfmetItr = pfmet.begin(); pfmetItr != pfmet.end(); pfmetItr++) { miniPFMETCollection->push_back(*pfmetItr); } - for(edm::SortedCollection >::const_iterator hbheItr=Hithbhe.begin(); - hbheItr!=Hithbhe.end(); hbheItr++) { + for (edm::SortedCollection>::const_iterator hbheItr = + Hithbhe.begin(); + hbheItr != Hithbhe.end(); + hbheItr++) { miniHBHECollection->push_back(*hbheItr); } - for(edm::SortedCollection >::const_iterator hoItr=Hitho.begin(); - hoItr!=Hitho.end(); hoItr++) { + for (edm::SortedCollection>::const_iterator hoItr = Hitho.begin(); + hoItr != Hitho.end(); + hoItr++) { miniHOCollection->push_back(*hoItr); } - for(edm::SortedCollection >::const_iterator hfItr=Hithf.begin(); - hfItr!=Hithf.end(); hfItr++) { + for (edm::SortedCollection>::const_iterator hfItr = Hithf.begin(); + hfItr != Hithf.end(); + hfItr++) { miniHFCollection->push_back(*hfItr); } - for(reco::GsfElectronCollection::const_iterator gsfItr=gsfele.begin(); - gsfItr!=gsfele.end(); gsfItr++) { + for (reco::GsfElectronCollection::const_iterator gsfItr = gsfele.begin(); gsfItr != gsfele.end(); gsfItr++) { miniGSFeleCollection->push_back(*gsfItr); } - for(reco::ConversionCollection::const_iterator convItr=conv.begin(); - convItr!=conv.end(); convItr++) { + for (reco::ConversionCollection::const_iterator convItr = conv.begin(); convItr != conv.end(); convItr++) { miniConversionCollection->push_back(*convItr); } *miniTriggerCollection = trigres; *miniRhoCollection = rho_val; - edm::Handle > loosePhotonQual; + edm::Handle> loosePhotonQual; iEvent.getByToken(tok_loosePhoton_, loosePhotonQual); - edm::Handle > tightPhotonQual; + edm::Handle> tightPhotonQual; iEvent.getByToken(tok_tightPhoton_, tightPhotonQual); if (loosePhotonQual.isValid() && tightPhotonQual.isValid()) { miniLoosePhoton->reserve(miniPhotonCollection->size()); miniTightPhoton->reserve(miniPhotonCollection->size()); - for (int iPho=0; iPhosize()); ++iPho) { - edm::Ref photonRef(phoHandle,iPho); - if (!photonRef) { - std::cout << "failed ref" << std::endl; - miniLoosePhoton->push_back(-1); - miniTightPhoton->push_back(-1); - } - else { - miniLoosePhoton->push_back((*loosePhotonQual)[photonRef]); - miniTightPhoton->push_back((*tightPhotonQual)[photonRef]); - } + for (int iPho = 0; iPho < int(miniPhotonCollection->size()); ++iPho) { + edm::Ref photonRef(phoHandle, iPho); + if (!photonRef) { + std::cout << "failed ref" << std::endl; + miniLoosePhoton->push_back(-1); + miniTightPhoton->push_back(-1); + } else { + miniLoosePhoton->push_back((*loosePhotonQual)[photonRef]); + miniTightPhoton->push_back((*tightPhotonQual)[photonRef]); + } } } } //Put them in the event - iEvent.put(std::move(miniPhotonCollection), labelPhoton_.encode()); - iEvent.put(std::move(miniPFjetCollection), labelPFJet_.encode()); - iEvent.put(std::move(miniHBHECollection), labelHBHE_.encode()); - iEvent.put(std::move(miniHFCollection), labelHF_.encode()); - iEvent.put(std::move(miniHOCollection), labelHO_.encode()); - iEvent.put(std::move(miniTriggerCollection), labelTrigger_.encode()); - iEvent.put(std::move(miniPFCandCollection), labelPFCandidate_.encode()); - iEvent.put(std::move(miniVtxCollection), labelVertex_.encode()); - iEvent.put(std::move(miniPFMETCollection), labelPFMET_.encode()); - iEvent.put(std::move(miniGSFeleCollection), labelGsfEle_.encode()); - iEvent.put(std::move(miniRhoCollection), labelRho_.encode()); - iEvent.put(std::move(miniConversionCollection), labelConv_.encode()); - iEvent.put(std::move(miniBeamSpotCollection), labelBeamSpot_.encode()); - iEvent.put(std::move(miniLoosePhoton), labelLoosePhot_.encode()); - iEvent.put(std::move(miniTightPhoton), labelTightPhot_.encode()); + iEvent.put(std::move(miniPhotonCollection), labelPhoton_.encode()); + iEvent.put(std::move(miniPFjetCollection), labelPFJet_.encode()); + iEvent.put(std::move(miniHBHECollection), labelHBHE_.encode()); + iEvent.put(std::move(miniHFCollection), labelHF_.encode()); + iEvent.put(std::move(miniHOCollection), labelHO_.encode()); + iEvent.put(std::move(miniTriggerCollection), labelTrigger_.encode()); + iEvent.put(std::move(miniPFCandCollection), labelPFCandidate_.encode()); + iEvent.put(std::move(miniVtxCollection), labelVertex_.encode()); + iEvent.put(std::move(miniPFMETCollection), labelPFMET_.encode()); + iEvent.put(std::move(miniGSFeleCollection), labelGsfEle_.encode()); + iEvent.put(std::move(miniRhoCollection), labelRho_.encode()); + iEvent.put(std::move(miniConversionCollection), labelConv_.encode()); + iEvent.put(std::move(miniBeamSpotCollection), labelBeamSpot_.encode()); + iEvent.put(std::move(miniLoosePhoton), labelLoosePhot_.encode()); + iEvent.put(std::move(miniTightPhoton), labelTightPhot_.encode()); return; - } -DEFINE_FWK_MODULE(AlCaGammaJetProducer); +DEFINE_FWK_MODULE(AlCaGammaJetProducer); diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaHBHEMuonProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaHBHEMuonProducer.cc index 8bacd319a4771..209d0a1145de1 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaHBHEMuonProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaHBHEMuonProducer.cc @@ -10,7 +10,7 @@ #include #include #include -#include +#include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -43,66 +43,62 @@ namespace AlCaHBHEMuons { Counters() : nAll_(0), nGood_(0) {} mutable std::atomic nAll_, nGood_; }; -} +} // namespace AlCaHBHEMuons class AlCaHBHEMuonProducer : public edm::stream::EDProducer > { public: explicit AlCaHBHEMuonProducer(edm::ParameterSet const&, const AlCaHBHEMuons::Counters* count); ~AlCaHBHEMuonProducer() override; - + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } - void produce(edm::Event &, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; void endStream() override; - static void globalEndJob(const AlCaHBHEMuons::Counters* counters); - -private: + static void globalEndJob(const AlCaHBHEMuons::Counters* counters); +private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - bool select(const reco::MuonCollection &); - + bool select(const reco::MuonCollection&); + // ----------member data --------------------------- - unsigned int nRun_, nAll_, nGood_; - edm::InputTag labelBS_, labelVtx_ ; - edm::InputTag labelEB_, labelEE_, labelHBHE_, labelMuon_; - double pMuonMin_; - - edm::EDGetTokenT tok_BS_; - edm::EDGetTokenT tok_Vtx_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_HBHE_; - edm::EDGetTokenT tok_Muon_; + unsigned int nRun_, nAll_, nGood_; + edm::InputTag labelBS_, labelVtx_; + edm::InputTag labelEB_, labelEE_, labelHBHE_, labelMuon_; + double pMuonMin_; + + edm::EDGetTokenT tok_BS_; + edm::EDGetTokenT tok_Vtx_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_HBHE_; + edm::EDGetTokenT tok_Muon_; }; - -AlCaHBHEMuonProducer::AlCaHBHEMuonProducer(edm::ParameterSet const& iConfig, const AlCaHBHEMuons::Counters* count) : - nRun_(0), nAll_(0), nGood_(0) { +AlCaHBHEMuonProducer::AlCaHBHEMuonProducer(edm::ParameterSet const& iConfig, const AlCaHBHEMuons::Counters* count) + : nRun_(0), nAll_(0), nGood_(0) { //Get the run parameters - labelBS_ = iConfig.getParameter("BeamSpotLabel"); - labelVtx_ = iConfig.getParameter("VertexLabel"); - labelEB_ = iConfig.getParameter("EBRecHitLabel"); - labelEE_ = iConfig.getParameter("EERecHitLabel"); - labelHBHE_ = iConfig.getParameter("HBHERecHitLabel"); - labelMuon_ = iConfig.getParameter("MuonLabel"); - pMuonMin_ = iConfig.getParameter("MinimumMuonP"); + labelBS_ = iConfig.getParameter("BeamSpotLabel"); + labelVtx_ = iConfig.getParameter("VertexLabel"); + labelEB_ = iConfig.getParameter("EBRecHitLabel"); + labelEE_ = iConfig.getParameter("EERecHitLabel"); + labelHBHE_ = iConfig.getParameter("HBHERecHitLabel"); + labelMuon_ = iConfig.getParameter("MuonLabel"); + pMuonMin_ = iConfig.getParameter("MinimumMuonP"); // define tokens for access - tok_Vtx_ = consumes(labelVtx_); - tok_BS_ = consumes(labelBS_); - tok_EB_ = consumes(labelEB_); - tok_EE_ = consumes(labelEE_); - tok_HBHE_ = consumes(labelHBHE_); - tok_Muon_ = consumes(labelMuon_); - - edm::LogInfo("HcalHBHEMuon") << "Parameters read from config file \n" - << "\t minP of muon " << pMuonMin_ - << "\t input labels " << labelBS_ << " " - << labelVtx_ <<" " << labelEB_ << " " << labelEE_ - <<" " << labelHBHE_ << " " << labelMuon_; + tok_Vtx_ = consumes(labelVtx_); + tok_BS_ = consumes(labelBS_); + tok_EB_ = consumes(labelEB_); + tok_EE_ = consumes(labelEE_); + tok_HBHE_ = consumes(labelHBHE_); + tok_Muon_ = consumes(labelMuon_); + + edm::LogInfo("HcalHBHEMuon") << "Parameters read from config file \n" + << "\t minP of muon " << pMuonMin_ << "\t input labels " << labelBS_ << " " << labelVtx_ + << " " << labelEB_ << " " << labelEE_ << " " << labelHBHE_ << " " << labelMuon_; //saves the following collections produces(labelBS_.label()); @@ -113,30 +109,26 @@ AlCaHBHEMuonProducer::AlCaHBHEMuonProducer(edm::ParameterSet const& iConfig, con produces(labelMuon_.label()); } -AlCaHBHEMuonProducer::~AlCaHBHEMuonProducer() { } +AlCaHBHEMuonProducer::~AlCaHBHEMuonProducer() {} void AlCaHBHEMuonProducer::produce(edm::Event& iEvent, edm::EventSetup const& iSetup) { - ++nAll_; bool valid(true); #ifdef DebugLog - edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); + edm::LogInfo("HcalHBHEMuon") << "AlCaHBHEMuonProducer::Run " << iEvent.id().run() << " Event " << iEvent.id().event() + << " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); #endif - + //Step1: Get all the relevant containers edm::Handle bmspot; iEvent.getByToken(tok_BS_, bmspot); - if (!bmspot.isValid()){ + if (!bmspot.isValid()) { edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelBS_; valid = false; } edm::Handle vt; - iEvent.getByToken(tok_Vtx_, vt); + iEvent.getByToken(tok_Vtx_, vt); if (!vt.isValid()) { edm::LogWarning("HcalHBHEMuon") << "AlCaHBHEMuonProducer: Error! can't get product " << labelVtx_; valid = false; @@ -184,9 +176,8 @@ void AlCaHBHEMuonProducer::produce(edm::Event& iEvent, edm::EventSetup const& iS if (valid) { const reco::BeamSpot beam = *(bmspot.product()); - outputBeamSpot = std::make_unique(beam.position(),beam.sigmaZ(), - beam.dxdz(),beam.dydz(),beam.BeamWidthX(), - beam.covariance(),beam.type()); + outputBeamSpot = std::make_unique( + beam.position(), beam.sigmaZ(), beam.dxdz(), beam.dydz(), beam.BeamWidthX(), beam.covariance(), beam.type()); const reco::VertexCollection vtx = *(vt.product()); const EcalRecHitCollection ebcoll = *(barrelRecHitsHandle.product()); const EcalRecHitCollection eecoll = *(endcapRecHitsHandle.product()); @@ -197,44 +188,43 @@ void AlCaHBHEMuonProducer::produce(edm::Event& iEvent, edm::EventSetup const& iS if (accept) { ++nGood_; - - for (reco::VertexCollection::const_iterator vtr=vtx.begin(); vtr!=vtx.end(); ++vtr) - outputVColl->push_back(*vtr); - for (edm::SortedCollection::const_iterator ehit=ebcoll.begin(); ehit!=ebcoll.end(); ++ehit) - outputEBColl->push_back(*ehit); + for (reco::VertexCollection::const_iterator vtr = vtx.begin(); vtr != vtx.end(); ++vtr) + outputVColl->push_back(*vtr); - for (edm::SortedCollection::const_iterator ehit=eecoll.begin(); ehit!=eecoll.end(); ++ehit) - outputEEColl->push_back(*ehit); + for (edm::SortedCollection::const_iterator ehit = ebcoll.begin(); ehit != ebcoll.end(); ++ehit) + outputEBColl->push_back(*ehit); - for (std::vector::const_iterator hhit=hbhecoll.begin(); hhit!=hbhecoll.end(); ++hhit) - outputHBHEColl->push_back(*hhit); + for (edm::SortedCollection::const_iterator ehit = eecoll.begin(); ehit != eecoll.end(); ++ehit) + outputEEColl->push_back(*ehit); - for (reco::MuonCollection::const_iterator muon=muons.begin(); muon!=muons.end(); ++muon) - outputMColl->push_back(*muon); + for (std::vector::const_iterator hhit = hbhecoll.begin(); hhit != hbhecoll.end(); ++hhit) + outputHBHEColl->push_back(*hhit); + + for (reco::MuonCollection::const_iterator muon = muons.begin(); muon != muons.end(); ++muon) + outputMColl->push_back(*muon); } } - iEvent.put(std::move(outputBeamSpot), labelBS_.label()); - iEvent.put(std::move(outputVColl), labelVtx_.label()); - iEvent.put(std::move(outputEBColl), labelEB_.instance()); - iEvent.put(std::move(outputEEColl), labelEE_.instance()); - iEvent.put(std::move(outputHBHEColl), labelHBHE_.label()); - iEvent.put(std::move(outputMColl), labelMuon_.label()); + iEvent.put(std::move(outputBeamSpot), labelBS_.label()); + iEvent.put(std::move(outputVColl), labelVtx_.label()); + iEvent.put(std::move(outputEBColl), labelEB_.instance()); + iEvent.put(std::move(outputEEColl), labelEE_.instance()); + iEvent.put(std::move(outputHBHEColl), labelHBHE_.label()); + iEvent.put(std::move(outputMColl), labelMuon_.label()); } void AlCaHBHEMuonProducer::endStream() { - globalCache()->nAll_ += nAll_; + globalCache()->nAll_ += nAll_; globalCache()->nGood_ += nGood_; } void AlCaHBHEMuonProducer::globalEndJob(const AlCaHBHEMuons::Counters* count) { - edm::LogInfo("HcalHBHEMuon") << "Finds " << count->nGood_ <<" good tracks in " - << count->nAll_ << " events"; + edm::LogInfo("HcalHBHEMuon") << "Finds " << count->nGood_ << " good tracks in " << count->nAll_ << " events"; } void AlCaHBHEMuonProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { - edm::LogInfo("HcalHBHEMuon") << "Run[" << nRun_ << "] " << iRun.run(); + edm::LogInfo("HcalHBHEMuon") << "Run[" << nRun_ << "] " << iRun.run(); } void AlCaHBHEMuonProducer::endRun(edm::Run const& iRun, edm::EventSetup const&) { @@ -242,12 +232,12 @@ void AlCaHBHEMuonProducer::endRun(edm::Run const& iRun, edm::EventSetup const&) edm::LogInfo("HcalHBHEMuon") << "endRun[" << nRun_ << "] " << iRun.run(); } -bool AlCaHBHEMuonProducer::select(const reco::MuonCollection & muons) { - +bool AlCaHBHEMuonProducer::select(const reco::MuonCollection& muons) { bool ok(false); - for (unsigned int k=0; k pMuonMin_) { - ok = true; break; + ok = true; + break; } } return ok; diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaHOCalibProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaHOCalibProducer.cc index 75f5c4e6ac71d..cae5b8c3af032 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaHOCalibProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaHOCalibProducer.cc @@ -1,7 +1,7 @@ // -*- C++ -*- // Dec 2015 : Added bool m_cosmic to choose cosmic or collision run through python file -//integrate the code with some 8_0_X or 7_6_X recent IB and run the +//integrate the code with some 8_0_X or 7_6_X recent IB and run the // following tests: 4.22, 8.0, 25.0, 140.53. You can always activate them using //runTheMatrix.py -l 4.22 @@ -11,7 +11,7 @@ // April 2015 : Remove all digi part // Also look for HO geometry in CMSSW in parallel with stanalone one. // Official one has problem in reco geometry, particularly tiles at the edge of wheel -// Remove all histogrammes except occupancy one +// Remove all histogrammes except occupancy one // Remove Trigger bits // But addition of these variables, ilumi (analyser), inslumi (analyser), nprim @@ -21,10 +21,10 @@ // Oct3 2008 // Difference in tag V00-02-45 with previous code -// 1. One new object on data format, which was realised in +// 1. One new object on data format, which was realised in // CRUZET data analysis. //2. Remove all histogram and cout in the code -//3. An upgrade in code, which increases the acceptance of +//3. An upgrade in code, which increases the acceptance of // muon near the edge (this also realised in CRUZET data). // Difference in wrt V00-02-45 // 1. initialisation tmpHOCalib.htime = -1000; @@ -32,7 +32,7 @@ // Package: AlCaHOCalibProducer // Class: AlCaHOCalibProducer -// +// /**\class AlCaHOCalibProducer AlCaHOCalibProducer.cc Calibration/AlCaHOCalibProducer/src/AlCaHOCalibProducer.cc change magnetic field inside @@ -71,7 +71,6 @@ Ring 0 L0 : Width Tray 6:266.6, 5&4:325.6, 3:330.6, 2:341.6, 1:272.6 // // - // system include files #include @@ -150,58 +149,58 @@ Ring 0 L0 : Width Tray 6:266.6, 5&4:325.6, 3:330.6, 2:341.6, 1:272.6 // class decleration // - class AlCaHOCalibProducer : public edm::EDProducer { public: explicit AlCaHOCalibProducer(const edm::ParameterSet&); ~AlCaHOCalibProducer() override; - typedef Basic3DVector PositionType; - typedef Basic3DVector DirectionType; - typedef Basic3DVector RotationType; - + typedef Basic3DVector PositionType; + typedef Basic3DVector DirectionType; + typedef Basic3DVector RotationType; private: void produce(edm::Event&, const edm::EventSetup&) override; - void beginJob() override ; - void endJob() override ; + void beginJob() override; + void endJob() override; void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override; // void beginRun(edm::Run const &, edm::EventSetup const &) override; void fillHOStore(const reco::TrackRef& ncosm, - HOCalibVariables& tmpHOCalib, - std::unique_ptr &hostore, - int Noccu_old, int indx, - edm::Handle cosmicmuon, - edm::View::const_iterator muon1, - const edm::Event& iEvent, const edm::EventSetup& iSetup); + HOCalibVariables& tmpHOCalib, + std::unique_ptr& hostore, + int Noccu_old, + int indx, + edm::Handle cosmicmuon, + edm::View::const_iterator muon1, + const edm::Event& iEvent, + const edm::EventSetup& iSetup); void findHOEtaPhi(int iphsect, int& ietaho, int& iphiho); // virtual void endRun(edm::Run const &, edm::EventSetup const &) override; // ----------member data --------------------------- - float xhor0; //x-position in ring 0 - float yhor0; //y-position in ring 0 - float xhor1; //x-position in ring 1 - float yhor1; //y-position in ring 1 + float xhor0; //x-position in ring 0 + float yhor0; //y-position in ring 0 + float xhor1; //x-position in ring 1 + float yhor1; //y-position in ring 1 int iring; //Ring number -2,-1,0,1,2 - float localxhor0; //local x-distance from edege in ring 0 - float localyhor0; //local y-distance from edege in ring 0 - float localxhor1; //local x-distance from edege in ring 1 - float localyhor1; //local y-distance from edege in ring 1 + float localxhor0; //local x-distance from edege in ring 0 + float localyhor0; //local y-distance from edege in ring 0 + float localxhor1; //local x-distance from edege in ring 1 + float localyhor1; //local y-distance from edege in ring 1 - TH2F* ho_occupency[5]; + TH2F* ho_occupency[5]; bool m_occupancy; bool m_cosmic; - const int netabin= 16; + const int netabin = 16; const int nphimx = 72; const int netamx = 32; const int ncidmx = 5; const double rHOL0 = 382.0; const double rHOL1 = 407.0; - edm::InputTag muonTags_; // cosmicMuons (for cosmic run) or muons (for collision run) + edm::InputTag muonTags_; // cosmicMuons (for cosmic run) or muons (for collision run) edm::EDGetTokenT tok_muonsCosmic_; edm::EDGetTokenT > tok_muons_; @@ -215,18 +214,18 @@ class AlCaHOCalibProducer : public edm::EDProducer { bool m_hbinfo; int m_startTS; - int m_endTS; + int m_endTS; double m_sigma; - typedef math::Error<5>::type CovarianceMatrix; + typedef math::Error<5>::type CovarianceMatrix; int Noccu; int nRuns; // SteppingHelixPropagator* stepProp; - FreeTrajectoryState getFreeTrajectoryState( const reco::Track& tk, const MagneticField* field, int itag, bool dir); + FreeTrajectoryState getFreeTrajectoryState(const reco::Track& tk, const MagneticField* field, int itag, bool dir); - unsigned int Ntp; // # of HLT trigger paths (should be the same for all events!) - std::map fired; + unsigned int Ntp; // # of HLT trigger paths (should be the same for all events!) + std::map fired; //hcal severity ES const HcalChannelQuality* theHcalChStatus; @@ -252,57 +251,53 @@ AlCaHOCalibProducer::AlCaHOCalibProducer(const edm::ParameterSet& iConfig) { m_hbinfo = iConfig.getUntrackedParameter("hbinfo", false); m_sigma = iConfig.getUntrackedParameter("sigma", 0.05); m_occupancy = iConfig.getUntrackedParameter("plotOccupancy", false); - m_cosmic = iConfig.getUntrackedParameter("CosmicData", false); + m_cosmic = iConfig.getUntrackedParameter("CosmicData", false); // keep InputTag muonTags_ since it is used below. - cowden - muonTags_ = iConfig.getUntrackedParameter("muons"); + muonTags_ = iConfig.getUntrackedParameter("muons"); tok_muonsCosmic_ = consumes(muonTags_); - tok_muons_ = consumes >(muonTags_); - tok_vertex_ = consumes(iConfig.getParameter("vertexTags")); + tok_muons_ = consumes >(muonTags_); + tok_vertex_ = consumes(iConfig.getParameter("vertexTags")); // tok_lumi_ = consumes(iConfig.getParameter("lumiTags")); tok_lumi_ = consumes(iConfig.getParameter("lumiTags")); tok_ho_ = consumes(iConfig.getParameter("hoInput")); tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); - tok_tower_ = consumes(iConfig.getParameter("towerInput")); + tok_tower_ = consumes(iConfig.getParameter("towerInput")); produces("HOCalibVariableCollection").setBranchAlias("HOCalibVariableCollection"); - + if (m_occupancy) { edm::Service fs; - + char title[200]; - for (int ij=0; ij<5; ij++) { - sprintf(title, "ho_occupency (>%i #sigma)", ij+2); - ho_occupency[ij] = fs->make(title, title, netamx+1, -netamx-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); + for (int ij = 0; ij < 5; ij++) { + sprintf(title, "ho_occupency (>%i #sigma)", ij + 2); + ho_occupency[ij] = + fs->make(title, title, netamx + 1, -netamx - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); } - } + } } - -AlCaHOCalibProducer::~AlCaHOCalibProducer() -{ - +AlCaHOCalibProducer::~AlCaHOCalibProducer() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } - // // member functions // // ------------ method called to produce the data ------------ -void -AlCaHOCalibProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - +void AlCaHOCalibProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { int irun = iEvent.id().run(); // int ilumi = iEvent.luminosityBlock(); Nevents++; - if (Nevents%5000==1) edm::LogInfo("HOCalib") <<"AlCaHOCalibProducer Processing event # "<(); @@ -312,67 +307,66 @@ AlCaHOCalibProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) bool muonOK(true); HOCalibVariables tmpHOCalib; tmpHOCalib.nprim = -1; - tmpHOCalib.inslumi=-1.; + tmpHOCalib.inslumi = -1.; if (m_cosmic) { iEvent.getByToken(tok_muonsCosmic_, cosmicmuon); muonOK = (cosmicmuon.isValid() && !cosmicmuon->empty()); } else { - iEvent.getByToken(tok_muons_,collisionmuon); + iEvent.getByToken(tok_muons_, collisionmuon); muonOK = (collisionmuon.isValid() && !collisionmuon->empty()); if (iEvent.isRealData()) { edm::Handle primaryVertices; iEvent.getByToken(tok_vertex_, primaryVertices); - if (primaryVertices.isValid()) { tmpHOCalib.nprim = primaryVertices->size();} + if (primaryVertices.isValid()) { + tmpHOCalib.nprim = primaryVertices->size(); + } + + tmpHOCalib.inslumi = 0.; - tmpHOCalib.inslumi=0.; - edm::Handle lumiScale; iEvent.getByToken(tok_lumi_, lumiScale); if (lumiScale.isValid()) { - if ( lumiScale->empty() ) { + if (lumiScale->empty()) { edm::LogError("HOCalib") << "lumiScale collection is empty"; } else { - tmpHOCalib.inslumi=lumiScale->begin()->pileup(); + tmpHOCalib.inslumi = lumiScale->begin()->pileup(); } } } } - if (muonOK) { - + if (muonOK) { int Noccu_old = Noccu; edm::View::const_iterator muon1; if (m_cosmic) { int indx(0); - for(reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin(); - ncosm != cosmicmuon->end(); ++ncosm,++indx) { - if ((*ncosm).ndof() < 15) continue; - if ((*ncosm).normalizedChi2() >30.0) continue; - reco::TrackRef tRef = reco::TrackRef(cosmicmuon,indx); - fillHOStore(tRef,tmpHOCalib,hostore,Noccu_old,indx,cosmicmuon,muon1, - iEvent, iSetup); + for (reco::TrackCollection::const_iterator ncosm = cosmicmuon->begin(); ncosm != cosmicmuon->end(); + ++ncosm, ++indx) { + if ((*ncosm).ndof() < 15) + continue; + if ((*ncosm).normalizedChi2() > 30.0) + continue; + reco::TrackRef tRef = reco::TrackRef(cosmicmuon, indx); + fillHOStore(tRef, tmpHOCalib, hostore, Noccu_old, indx, cosmicmuon, muon1, iEvent, iSetup); } } else { - for( muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++ ) { - if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon())) continue; - reco::TrackRef ncosm = muon1->innerTrack(); - fillHOStore(ncosm,tmpHOCalib,hostore,Noccu_old,0,cosmicmuon,muon1, - iEvent, iSetup); + for (muon1 = collisionmuon->begin(); muon1 < collisionmuon->end(); muon1++) { + if ((!muon1->isGlobalMuon()) || (!muon1->isTrackerMuon())) + continue; + reco::TrackRef ncosm = muon1->innerTrack(); + fillHOStore(ncosm, tmpHOCalib, hostore, Noccu_old, 0, cosmicmuon, muon1, iEvent, iSetup); } } } iEvent.put(std::move(hostore), "HOCalibVariableCollection"); - } // ------------ method called once each job just before starting event loop ------------ -void -AlCaHOCalibProducer::beginJob() -{ +void AlCaHOCalibProducer::beginJob() { Nevents = 0; nRuns = 0; Noccu = 0; @@ -380,12 +374,12 @@ AlCaHOCalibProducer::beginJob() // ------------ method called once each job just after ending the event loop ------------ void AlCaHOCalibProducer::endJob() { - if (m_occupancy) { - for (int ij=0; ij<5; ij++) { - ho_occupency[ij]->Scale(1./std::max(1,Noccu)); + if (m_occupancy) { + for (int ij = 0; ij < 5; ij++) { + ho_occupency[ij]->Scale(1. / std::max(1, Noccu)); } } - edm::LogInfo("HOCalib") <<" AlCaHOCalibProducer processed event "<< Nevents; + edm::LogInfo("HOCalib") << " AlCaHOCalibProducer processed event " << Nevents; } // ------------ method called once each run just after ending the event loop ------------ @@ -393,41 +387,39 @@ void AlCaHOCalibProducer::endJob() { // ------------ method called once each run before starting event loop ------------ //void AlCaHOCalibProducer::beginRun(edm::Run const & run, const edm::EventSetup & es) {} -void AlCaHOCalibProducer::beginLuminosityBlock(const edm::LuminosityBlock & lBlock, const edm::EventSetup & es) { - - edm::ESHandle hcalChStatus; - es.get().get("withTopo", hcalChStatus ); +void AlCaHOCalibProducer::beginLuminosityBlock(const edm::LuminosityBlock& lBlock, const edm::EventSetup& es) { + edm::ESHandle hcalChStatus; + es.get().get("withTopo", hcalChStatus); theHcalChStatus = hcalChStatus.product(); return; } void AlCaHOCalibProducer::fillHOStore(const reco::TrackRef& ncosm, - HOCalibVariables& tmpHOCalib, - std::unique_ptr &hostore, - int Noccu_old, int indx, - edm::Handle cosmicmuon, - edm::View::const_iterator muon1, - const edm::Event& iEvent, - const edm::EventSetup& iSetup) { - + HOCalibVariables& tmpHOCalib, + std::unique_ptr& hostore, + int Noccu_old, + int indx, + edm::Handle cosmicmuon, + edm::View::const_iterator muon1, + const edm::Event& iEvent, + const edm::EventSetup& iSetup) { edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - const CaloSubdetectorGeometry* gHO = - geo->getSubdetectorGeometry(DetId::Hcal,HcalOuter); - + const CaloSubdetectorGeometry* gHO = geo->getSubdetectorGeometry(DetId::Hcal, HcalOuter); + // Get Hcal Severity Level Computer, so that the severity of each rechit flag/status may be determined // edm::ESHandle hcalSevLvlComputerHndl; iSetup.get().get(hcalSevLvlComputerHndl); const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product(); - int charge = ncosm->charge(); - + int charge = ncosm->charge(); + double innerr = (*ncosm).innerPosition().Perp2(); double outerr = (*ncosm).outerPosition().Perp2(); - int iiner = (innerr 0) ? true : false; - for (int ij=0; ij<3; ij++) {tmpHOCalib.caloen[ij] = 0.0;} + + bool samedir = (tmpmuon3v.dot(tmpmuondir) > 0) ? true : false; + for (int ij = 0; ij < 3; ij++) { + tmpHOCalib.caloen[ij] = 0.0; + } int inearbymuon = 0; localxhor0 = localyhor0 = 20000; //GM for 22OCT07 data if (m_cosmic) { int ind(0); - for(reco::TrackCollection::const_iterator ncosmcor=cosmicmuon->begin(); - ncosmcor != cosmicmuon->end(); ++ncosmcor,++ind) { - if (indx==ind) continue; + for (reco::TrackCollection::const_iterator ncosmcor = cosmicmuon->begin(); ncosmcor != cosmicmuon->end(); + ++ncosmcor, ++ind) { + if (indx == ind) + continue; CLHEP::Hep3Vector tmpmuon3vcor; CLHEP::Hep3Vector tmpmom3v; - if (iiner==1) { - tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).innerPosition().X(),(*ncosmcor).innerPosition().Y(),(*ncosmcor).innerPosition().Z()); - tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).innerMomentum().X(),(*ncosmcor).innerMomentum().Y(),(*ncosmcor).innerMomentum().Z()); + if (iiner == 1) { + tmpmuon3vcor = CLHEP::Hep3Vector( + (*ncosmcor).innerPosition().X(), (*ncosmcor).innerPosition().Y(), (*ncosmcor).innerPosition().Z()); + tmpmom3v = CLHEP::Hep3Vector( + (*ncosmcor).innerMomentum().X(), (*ncosmcor).innerMomentum().Y(), (*ncosmcor).innerMomentum().Z()); } else { - tmpmuon3vcor = CLHEP::Hep3Vector((*ncosmcor).outerPosition().X(),(*ncosmcor).outerPosition().Y(),(*ncosmcor).outerPosition().Z()); - tmpmom3v = CLHEP::Hep3Vector((*ncosmcor).outerMomentum().X(),(*ncosmcor).outerMomentum().Y(),(*ncosmcor).outerMomentum().Z()); - + tmpmuon3vcor = CLHEP::Hep3Vector( + (*ncosmcor).outerPosition().X(), (*ncosmcor).outerPosition().Y(), (*ncosmcor).outerPosition().Z()); + tmpmom3v = CLHEP::Hep3Vector( + (*ncosmcor).outerMomentum().X(), (*ncosmcor).outerMomentum().Y(), (*ncosmcor).outerMomentum().Z()); } - if (tmpmom3v.mag()<0.2 || (*ncosmcor).ndof()<5) continue; - + if (tmpmom3v.mag() < 0.2 || (*ncosmcor).ndof() < 5) + continue; + double angle = tmpmuon3v.angle(tmpmuon3vcor); - if (angle < 7.5*CLHEP::deg) {inearbymuon=1;} // break;} - + if (angle < 7.5 * CLHEP::deg) { + inearbymuon = 1; + } // break;} + // if (muonTagsi_.label() =="cosmicMuons") { - if (angle <7.5*CLHEP::deg) { tmpHOCalib.caloen[0] +=1.;} - if (angle <15.0*CLHEP::deg) { tmpHOCalib.caloen[1] +=1.;} - if (angle <35.0*CLHEP::deg) { tmpHOCalib.caloen[2] +=1.;} + if (angle < 7.5 * CLHEP::deg) { + tmpHOCalib.caloen[0] += 1.; + } + if (angle < 15.0 * CLHEP::deg) { + tmpHOCalib.caloen[1] += 1.; + } + if (angle < 35.0 * CLHEP::deg) { + tmpHOCalib.caloen[2] += 1.; + } } } else { // if (muonTags_.label() =="muons") { edm::Handle calotower; iEvent.getByToken(tok_tower_, calotower); - - for (CaloTowerCollection::const_iterator calt = calotower->begin(); - calt !=calotower->end(); calt++) { + + for (CaloTowerCollection::const_iterator calt = calotower->begin(); calt != calotower->end(); calt++) { //CMSSW_2_1_x const math::XYZVector towermom = (*calt).momentum(); double ith = (*calt).momentum().theta(); double iph = (*calt).momentum().phi(); - - CLHEP::Hep3Vector calo3v(sin(ith)*cos(iph), sin(ith)*sin(iph), cos(ith)); - + + CLHEP::Hep3Vector calo3v(sin(ith) * cos(iph), sin(ith) * sin(iph), cos(ith)); + double angle = tmpmuon3v.angle(calo3v); - - if (angle < 7.5*CLHEP::deg) {tmpHOCalib.caloen[0] += calt->emEnergy()+calt->hadEnergy();} - if (angle < 15*CLHEP::deg) {tmpHOCalib.caloen[1] += calt->emEnergy()+calt->hadEnergy();} - if (angle < 35*CLHEP::deg) {tmpHOCalib.caloen[2] += calt->emEnergy()+calt->hadEnergy();} + + if (angle < 7.5 * CLHEP::deg) { + tmpHOCalib.caloen[0] += calt->emEnergy() + calt->hadEnergy(); + } + if (angle < 15 * CLHEP::deg) { + tmpHOCalib.caloen[1] += calt->emEnergy() + calt->hadEnergy(); + } + if (angle < 35 * CLHEP::deg) { + tmpHOCalib.caloen[2] += calt->emEnergy() + calt->hadEnergy(); + } } } - if ((m_cosmic) || (tmpHOCalib.caloen[0] <=10.0)) { - + if ((m_cosmic) || (tmpHOCalib.caloen[0] <= 10.0)) { GlobalPoint glbpt(posx, posy, posz); - - double mom = sqrt(momx*momx + momy*momy +momz*momz); - + + double mom = sqrt(momx * momx + momy * momy + momz * momz); + momx /= mom; momy /= mom; momz /= mom; - + DirectionType trkdir(momx, momy, momz); - + tmpHOCalib.trkdr = (*ncosm).d0(); tmpHOCalib.trkdz = (*ncosm).dz(); tmpHOCalib.nmuon = (m_cosmic) ? cosmicmuon->size() : 1; tmpHOCalib.trkvx = glbpt.x(); tmpHOCalib.trkvy = glbpt.y(); tmpHOCalib.trkvz = glbpt.z(); - tmpHOCalib.trkmm = mom*charge; + tmpHOCalib.trkmm = mom * charge; tmpHOCalib.trkth = trkdir.theta(); tmpHOCalib.trkph = trkdir.phi(); tmpHOCalib.isect2 = -2; @@ -543,355 +553,438 @@ void AlCaHOCalibProducer::fillHOStore(const reco::TrackRef& ncosm, tmpHOCalib.hody = -100; tmpHOCalib.hoang = -2.0; tmpHOCalib.momatho = -2; - tmpHOCalib.ndof = (inearbymuon ==0) ? (int)(*ncosm).ndof() : -(int)(*ncosm).ndof(); - tmpHOCalib.chisq = (*ncosm).normalizedChi2(); // max(1.,tmpHOCalib.ndof); - if (!m_cosmic) { + tmpHOCalib.ndof = (inearbymuon == 0) ? (int)(*ncosm).ndof() : -(int)(*ncosm).ndof(); + tmpHOCalib.chisq = (*ncosm).normalizedChi2(); // max(1.,tmpHOCalib.ndof); + if (!m_cosmic) { reco::MuonEnergy muonenr = muon1->calEnergy(); - reco::MuonIsolation iso03 = muon1->isolationR03(); - reco::MuonIsolation iso05 = muon1->isolationR05(); + reco::MuonIsolation iso03 = muon1->isolationR03(); + reco::MuonIsolation iso05 = muon1->isolationR05(); tmpHOCalib.tkpt03 = iso03.sumPt; - tmpHOCalib.ecal03 = iso05.sumPt; // iso03.emEt+muonenr.em; - tmpHOCalib.hcal03 = iso03.hadEt+muonenr.had; + tmpHOCalib.ecal03 = iso05.sumPt; // iso03.emEt+muonenr.em; + tmpHOCalib.hcal03 = iso03.hadEt + muonenr.had; } tmpHOCalib.therr = 0.; tmpHOCalib.pherr = 0.; - if (iiner==1) { + if (iiner == 1) { reco::TrackBase::CovarianceMatrix innercov = (*ncosm).innerStateCovariance(); - tmpHOCalib.therr = innercov(1,1); //thetaError(); - tmpHOCalib.pherr = innercov(2,2); //phi0Error(); + tmpHOCalib.therr = innercov(1, 1); //thetaError(); + tmpHOCalib.pherr = innercov(2, 2); //phi0Error(); } else { reco::TrackBase::CovarianceMatrix outercov = (*ncosm).outerStateCovariance(); - tmpHOCalib.therr = outercov(1,1); //thetaError(); - tmpHOCalib.pherr = outercov(2,2); //phi0Error(); + tmpHOCalib.therr = outercov(1, 1); //thetaError(); + tmpHOCalib.pherr = outercov(2, 2); //phi0Error(); } edm::ESHandle theMagField; - iSetup.get().get(theMagField ); + iSetup.get().get(theMagField); - SteppingHelixPropagator myHelix(&*theMagField,anyDirection); + SteppingHelixPropagator myHelix(&*theMagField, anyDirection); myHelix.setMaterialMode(false); myHelix.applyRadX0Correction(true); double phiho = trkpos.phi(); - if (phiho<0) phiho +=CLHEP::twopi; - - int iphisect_dt=int(6*(phiho+10.0*CLHEP::deg)/CLHEP::pi); //for u 18/12/06 - if (iphisect_dt>=12) iphisect_dt=0; + if (phiho < 0) + phiho += CLHEP::twopi; + + int iphisect_dt = int(6 * (phiho + 10.0 * CLHEP::deg) / CLHEP::pi); //for u 18/12/06 + if (iphisect_dt >= 12) + iphisect_dt = 0; int iphisect = -1; bool ipath = false; - for (int kl = 0; kl<=2; kl++) { - - int iphisecttmp = (kl<2) ? iphisect_dt + kl : iphisect_dt - 1; - if (iphisecttmp <0) iphisecttmp = 11; - if (iphisecttmp >=12) iphisecttmp = 0; - - double phipos = iphisecttmp*CLHEP::pi/6.; + for (int kl = 0; kl <= 2; kl++) { + int iphisecttmp = (kl < 2) ? iphisect_dt + kl : iphisect_dt - 1; + if (iphisecttmp < 0) + iphisecttmp = 11; + if (iphisecttmp >= 12) + iphisecttmp = 0; + + double phipos = iphisecttmp * CLHEP::pi / 6.; double phirot = phipos; - + GlobalVector xLocal(-sin(phirot), cos(phirot), 0.); GlobalVector yLocal(0., 0., 1.); GlobalVector zLocal = xLocal.cross(yLocal).unit(); - // GlobalVector zLocal(cos(phirot), sin(phirot), 0.0); - + // GlobalVector zLocal(cos(phirot), sin(phirot), 0.0); + + FreeTrajectoryState freetrajectorystate_ = getFreeTrajectoryState(*ncosm, &(*theMagField), iiner, samedir); - FreeTrajectoryState freetrajectorystate_ = getFreeTrajectoryState(*ncosm,&(*theMagField), iiner, samedir); - Surface::RotationType rot(xLocal, yLocal, zLocal); - - for (int ik=1; ik>=0; ik--) { //propagate track in two HO layers - - double radial = rHOL1; - if (ik==0) radial = rHOL0; - - Surface::PositionType pos(radial*cos(phipos), radial*sin(phipos), 0.); - PlaneBuilder::ReturnType aPlane = PlaneBuilder().plane(pos,rot); - - auto aPlane2 = new Plane(pos,rot); - - SteppingHelixStateInfo steppingHelixstateinfo_; - myHelix.propagate(SteppingHelixStateInfo(freetrajectorystate_), (*aPlane2), steppingHelixstateinfo_); - - if (steppingHelixstateinfo_.isValid()) { - - GlobalPoint hotrkpos2xx(steppingHelixstateinfo_.position().x(), steppingHelixstateinfo_.position().y(), steppingHelixstateinfo_.position().z()); - - if (ik==1) { - HcalDetId ClosestCell = (HcalDetId) gHO->getClosestCell(hotrkpos2xx); - int ixeta = ClosestCell.ieta(); - int ixphi = ClosestCell.iphi(); - tmpHOCalib.isect2 = 100*std::abs(ixeta+50)+std::abs(ixphi); - } - - - GlobalVector hotrkpos2(steppingHelixstateinfo_.position().x(), steppingHelixstateinfo_.position().y(), steppingHelixstateinfo_.position().z()); - CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.momentum().x(), steppingHelixstateinfo_.momentum().y(),steppingHelixstateinfo_.momentum().z()); - - LocalVector lclvt0 = (*aPlane).toLocal(hotrkpos2); - - double xx = lclvt0.x(); - double yy = lclvt0.y(); - - if (ik ==1) { - if ((std::abs(yy) < 130 && xx >-64.7 && xx <138.2) //Ring-0 - ||(std::abs(yy) > 130 && std::abs(yy) <700 && xx >-76.3 && xx <140.5)) { //Ring +-1,2 - ipath = true; //Only look for tracks which as hits in layer 1 - iphisect = iphisecttmp; - } - } - - if (iphisect != iphisecttmp) continue; //Look for ring-0 only when ring1 is accepted for that sector - - switch (ik) - { - case 0 : - xhor0 = xx; //lclvt0.x(); - yhor0 = yy; //lclvt0.y(); - break; - case 1 : - xhor1 = xx; //lclvt0.x(); - yhor1 = yy; //lclvt0.y(); - tmpHOCalib.momatho = hotrkdir2.mag(); - tmpHOCalib.hoang = CLHEP::Hep3Vector(zLocal.x(),zLocal.y(),zLocal.z()).dot(hotrkdir2.unit()); - break; - default : break; - } - } else { - break; - } + + for (int ik = 1; ik >= 0; ik--) { //propagate track in two HO layers + + double radial = rHOL1; + if (ik == 0) + radial = rHOL0; + + Surface::PositionType pos(radial * cos(phipos), radial * sin(phipos), 0.); + PlaneBuilder::ReturnType aPlane = PlaneBuilder().plane(pos, rot); + + auto aPlane2 = new Plane(pos, rot); + + SteppingHelixStateInfo steppingHelixstateinfo_; + myHelix.propagate(SteppingHelixStateInfo(freetrajectorystate_), (*aPlane2), steppingHelixstateinfo_); + + if (steppingHelixstateinfo_.isValid()) { + GlobalPoint hotrkpos2xx(steppingHelixstateinfo_.position().x(), + steppingHelixstateinfo_.position().y(), + steppingHelixstateinfo_.position().z()); + + if (ik == 1) { + HcalDetId ClosestCell = (HcalDetId)gHO->getClosestCell(hotrkpos2xx); + int ixeta = ClosestCell.ieta(); + int ixphi = ClosestCell.iphi(); + tmpHOCalib.isect2 = 100 * std::abs(ixeta + 50) + std::abs(ixphi); + } + + GlobalVector hotrkpos2(steppingHelixstateinfo_.position().x(), + steppingHelixstateinfo_.position().y(), + steppingHelixstateinfo_.position().z()); + CLHEP::Hep3Vector hotrkdir2(steppingHelixstateinfo_.momentum().x(), + steppingHelixstateinfo_.momentum().y(), + steppingHelixstateinfo_.momentum().z()); + + LocalVector lclvt0 = (*aPlane).toLocal(hotrkpos2); + + double xx = lclvt0.x(); + double yy = lclvt0.y(); + + if (ik == 1) { + if ((std::abs(yy) < 130 && xx > -64.7 && xx < 138.2) //Ring-0 + || (std::abs(yy) > 130 && std::abs(yy) < 700 && xx > -76.3 && xx < 140.5)) { //Ring +-1,2 + ipath = true; //Only look for tracks which as hits in layer 1 + iphisect = iphisecttmp; + } + } + + if (iphisect != iphisecttmp) + continue; //Look for ring-0 only when ring1 is accepted for that sector + + switch (ik) { + case 0: + xhor0 = xx; //lclvt0.x(); + yhor0 = yy; //lclvt0.y(); + break; + case 1: + xhor1 = xx; //lclvt0.x(); + yhor1 = yy; //lclvt0.y(); + tmpHOCalib.momatho = hotrkdir2.mag(); + tmpHOCalib.hoang = CLHEP::Hep3Vector(zLocal.x(), zLocal.y(), zLocal.z()).dot(hotrkdir2.unit()); + break; + default: + break; + } + } else { + break; + } } - if (ipath) break; + if (ipath) + break; } - if (ipath) { //If muon crossed HO laeyrs - + if (ipath) { //If muon crossed HO laeyrs + int ietaho = 50; int iphiho = -1; - - for (int ij=0; ij<9; ij++) {tmpHOCalib.hosig[ij]=-100.0;} - for (int ij=0; ij<18; ij++) {tmpHOCalib.hocorsig[ij]=-100.0;} - for (int ij=0; ij<9; ij++) {tmpHOCalib.hbhesig[ij]=-100.0;} + + for (int ij = 0; ij < 9; ij++) { + tmpHOCalib.hosig[ij] = -100.0; + } + for (int ij = 0; ij < 18; ij++) { + tmpHOCalib.hocorsig[ij] = -100.0; + } + for (int ij = 0; ij < 9; ij++) { + tmpHOCalib.hbhesig[ij] = -100.0; + } tmpHOCalib.hocro = -100; tmpHOCalib.htime = -1000; - + int isect = 0; findHOEtaPhi(iphisect, ietaho, iphiho); - - if (ietaho !=0 && iphiho !=0 && std::abs(iring)<=2) { //Muon passed through a tower - isect = 100*std::abs(ietaho+50)+std::abs(iphiho); - if (std::abs(ietaho) >=netabin || iphiho<0) isect *=-1; //Not extrapolated to any tower - if (std::abs(ietaho) >=netabin) isect -=1000000; //not matched with eta - if (iphiho<0) isect -=2000000; //not matched with phi - tmpHOCalib.isect = isect; - - tmpHOCalib.hodx = localxhor1; - tmpHOCalib.hody = localyhor1; - - if (iring==0) { - tmpHOCalib.hocorsig[8] = localxhor0; - tmpHOCalib.hocorsig[9] = localyhor0; - } - - int etamn=-4; - int etamx=4; - if (iring==1) {etamn=5; etamx = 10;} - if (iring==2) {etamn=11; etamx = 16;} - if (iring==-1){etamn=-10; etamx = -5;} - if (iring==-2){etamn=-16; etamx = -11;} - - int phimn = 1; - int phimx = 2; - if (iring ==0) { - phimx =2*int((iphiho+1)/2.); - phimn = phimx - 1; - } else { - phimn = 3*int((iphiho+1)/3.) - 1; - phimx = phimn + 2; - } - - if (phimn <1) phimn += nphimx; - if (phimx >72) phimx -= nphimx; - - if (m_hbinfo) { - for (int ij=0; ij<9; ij++) {tmpHOCalib.hbhesig[ij]=-100.0;} - - edm::Handle hbheht;// iEvent.getByType(hbheht); - iEvent.getByToken(tok_hbhe_,hbheht); - - if (!(*hbheht).empty()) { - if((*hbheht).empty()) throw (int)(*hbheht).size(); - - for (HBHERecHitCollection::const_iterator jk=(*hbheht).begin(); jk!=(*hbheht).end(); jk++){ - HcalDetId id =(*jk).id(); - int tmpeta= id.ieta(); - int tmpphi= id.iphi(); - - int deta = tmpeta-ietaho; - if (tmpeta<0 && ietaho>0) deta += 1; - if (tmpeta>0 && ietaho<0) deta -= 1; - - // if (tmpeta==-1 && ietaho== 1) deta = -1; - // if (tmpeta== 1 && ietaho==-1) deta = 1; - - int dphi = tmpphi-iphiho; - if (dphi>nphimx/2) { dphi -=nphimx;} - if (dphi<-nphimx/2) { dphi +=nphimx;} - - // if (phimn >phimx) { - // if (dphi==71) dphi=-1; - // if (dphi==-71) dphi=1; - // } - - if (m_occupancy) { - float signal = (*jk).energy(); - // int tmpeta1 = (tmpeta>0) ? tmpeta -1 : -tmpeta +14; - if (signal >-100 && Noccu == Noccu_old) { - for (int ij=0; ij<5; ij++) { - if (signal >(ij+2)*m_sigma) { - ho_occupency[ij]->Fill(tmpeta, tmpphi); - } - } - } - } - - int ipass2 = (std::abs(deta) <=1 && std::abs(dphi)<=1) ? 1 : 0; //NEED correction in full CMS detector - if ( ipass2 ==0 ) continue; - - float signal = (*jk).energy(); - - if (3*(deta+1)+dphi+1<9) tmpHOCalib.hbhesig[3*(deta+1)+dphi+1] = signal; - } - } - } //m_hbinfo #endif - - edm::Handle hoht; - iEvent.getByToken(tok_ho_,hoht); - - if (!(*hoht).empty()) { - for (HORecHitCollection::const_iterator jk=(*hoht).begin(); jk!=(*hoht).end(); jk++){ - HcalDetId id =(*jk).id(); - int tmpeta= id.ieta(); - int tmpphi= id.iphi(); - - int ipass1 =0; - if (tmpeta >=etamn && tmpeta <=etamx) { - if (phimn < phimx) { - ipass1 = (tmpphi >=phimn && tmpphi <=phimx ) ? 1 : 0; - } else { - ipass1 = (tmpphi==71 || tmpphi ==72 || tmpphi==1) ? 1 : 0; - } - } - - int deta = tmpeta-ietaho; - int dphi = tmpphi -iphiho; - - if (tmpeta<0 && ietaho>0) deta += 1; - if (tmpeta>0 && ietaho<0) deta -= 1; - // if (tmpeta==-1 && ietaho== 1) deta = -1; - // if (tmpeta== 1 && ietaho==-1) deta = 1; - - if (dphi>nphimx/2) { dphi -=nphimx;} - if (dphi<-nphimx/2) { dphi +=nphimx;} - // if (phimn>phimx) { - // if (dphi==71) dphi=-1; - // if (dphi==-71) dphi=1; - // } - - float signal = (*jk).energy(); - - int ipass2 = (std::abs(deta) <=1 && std::abs(dphi)<=1) ? 1 : 0; - - if (ipass1 ==0 && ipass2 ==0 ) continue; - - if (ipass1 ==1) { - int tmpdph = tmpphi-phimn; - if (tmpdph<0) tmpdph = 2; //only case of iphi==1, where phimn=71 - - int ilog = 2*(tmpeta-etamn)+tmpdph; - if (iring !=0) { - if (iring >0) { - ilog = 3*(tmpeta-etamn)+tmpdph; //Again CMS correction - } else { - ilog = 3*(etamx-tmpeta)+tmpdph; //Again CMS correction - } - } - if (ilog>-1 && ilog<18) { - tmpHOCalib.hocorsig[ilog] = signal; - } - } - - if (ipass2 ==1) { - - if (3*(deta+1)+dphi+1<9) { - tmpHOCalib.hosig[3*(deta+1)+dphi+1] = signal; //Again CMS azimuthal near phi 1&72 - } - } - - if (deta==0 && dphi ==0) { - tmpHOCalib.htime = (*jk).time(); - tmpHOCalib.hoflag = (*jk).flags(); - - // Get Channel Quality information for the given detID - unsigned theStatusValue = theHcalChStatus->getValues(id)->getValue(); - // Now get severity of problems for the given detID, based on the rechit flag word and the channel quality status value - int hitSeverity=hcalSevLvlComputer->getSeverityLevel(id, (*jk).flags(),theStatusValue); - tmpHOCalib.hoflag = hitSeverity; - int crphi = tmpphi + 6; - if (crphi >72) crphi -=72; - - for (HORecHitCollection::const_iterator jcr=(*hoht).begin(); jcr!=(*hoht).end(); jcr++){ - const HORecHit reccr = (const HORecHit)(*jcr); - HcalDetId idcr =reccr.id(); - int etacr= idcr.ieta(); - int phicr= idcr.iphi(); - if (tmpeta==etacr && crphi ==phicr) { - - tmpHOCalib.hocro = reccr.energy(); - - } - } - } - } - } + + if (ietaho != 0 && iphiho != 0 && std::abs(iring) <= 2) { //Muon passed through a tower + isect = 100 * std::abs(ietaho + 50) + std::abs(iphiho); + if (std::abs(ietaho) >= netabin || iphiho < 0) + isect *= -1; //Not extrapolated to any tower + if (std::abs(ietaho) >= netabin) + isect -= 1000000; //not matched with eta + if (iphiho < 0) + isect -= 2000000; //not matched with phi + tmpHOCalib.isect = isect; + + tmpHOCalib.hodx = localxhor1; + tmpHOCalib.hody = localyhor1; + + if (iring == 0) { + tmpHOCalib.hocorsig[8] = localxhor0; + tmpHOCalib.hocorsig[9] = localyhor0; + } + + int etamn = -4; + int etamx = 4; + if (iring == 1) { + etamn = 5; + etamx = 10; + } + if (iring == 2) { + etamn = 11; + etamx = 16; + } + if (iring == -1) { + etamn = -10; + etamx = -5; + } + if (iring == -2) { + etamn = -16; + etamx = -11; + } + + int phimn = 1; + int phimx = 2; + if (iring == 0) { + phimx = 2 * int((iphiho + 1) / 2.); + phimn = phimx - 1; + } else { + phimn = 3 * int((iphiho + 1) / 3.) - 1; + phimx = phimn + 2; + } + + if (phimn < 1) + phimn += nphimx; + if (phimx > 72) + phimx -= nphimx; + + if (m_hbinfo) { + for (int ij = 0; ij < 9; ij++) { + tmpHOCalib.hbhesig[ij] = -100.0; + } + + edm::Handle hbheht; // iEvent.getByType(hbheht); + iEvent.getByToken(tok_hbhe_, hbheht); + + if (!(*hbheht).empty()) { + if ((*hbheht).empty()) + throw(int)(*hbheht).size(); + + for (HBHERecHitCollection::const_iterator jk = (*hbheht).begin(); jk != (*hbheht).end(); jk++) { + HcalDetId id = (*jk).id(); + int tmpeta = id.ieta(); + int tmpphi = id.iphi(); + + int deta = tmpeta - ietaho; + if (tmpeta < 0 && ietaho > 0) + deta += 1; + if (tmpeta > 0 && ietaho < 0) + deta -= 1; + + // if (tmpeta==-1 && ietaho== 1) deta = -1; + // if (tmpeta== 1 && ietaho==-1) deta = 1; + + int dphi = tmpphi - iphiho; + if (dphi > nphimx / 2) { + dphi -= nphimx; + } + if (dphi < -nphimx / 2) { + dphi += nphimx; + } + + // if (phimn >phimx) { + // if (dphi==71) dphi=-1; + // if (dphi==-71) dphi=1; + // } + + if (m_occupancy) { + float signal = (*jk).energy(); + // int tmpeta1 = (tmpeta>0) ? tmpeta -1 : -tmpeta +14; + if (signal > -100 && Noccu == Noccu_old) { + for (int ij = 0; ij < 5; ij++) { + if (signal > (ij + 2) * m_sigma) { + ho_occupency[ij]->Fill(tmpeta, tmpphi); + } + } + } + } + + int ipass2 = (std::abs(deta) <= 1 && std::abs(dphi) <= 1) ? 1 : 0; //NEED correction in full CMS detector + if (ipass2 == 0) + continue; + + float signal = (*jk).energy(); + + if (3 * (deta + 1) + dphi + 1 < 9) + tmpHOCalib.hbhesig[3 * (deta + 1) + dphi + 1] = signal; + } + } + } //m_hbinfo #endif + + edm::Handle hoht; + iEvent.getByToken(tok_ho_, hoht); + + if (!(*hoht).empty()) { + for (HORecHitCollection::const_iterator jk = (*hoht).begin(); jk != (*hoht).end(); jk++) { + HcalDetId id = (*jk).id(); + int tmpeta = id.ieta(); + int tmpphi = id.iphi(); + + int ipass1 = 0; + if (tmpeta >= etamn && tmpeta <= etamx) { + if (phimn < phimx) { + ipass1 = (tmpphi >= phimn && tmpphi <= phimx) ? 1 : 0; + } else { + ipass1 = (tmpphi == 71 || tmpphi == 72 || tmpphi == 1) ? 1 : 0; + } + } + + int deta = tmpeta - ietaho; + int dphi = tmpphi - iphiho; + + if (tmpeta < 0 && ietaho > 0) + deta += 1; + if (tmpeta > 0 && ietaho < 0) + deta -= 1; + // if (tmpeta==-1 && ietaho== 1) deta = -1; + // if (tmpeta== 1 && ietaho==-1) deta = 1; + + if (dphi > nphimx / 2) { + dphi -= nphimx; + } + if (dphi < -nphimx / 2) { + dphi += nphimx; + } + // if (phimn>phimx) { + // if (dphi==71) dphi=-1; + // if (dphi==-71) dphi=1; + // } + + float signal = (*jk).energy(); + + int ipass2 = (std::abs(deta) <= 1 && std::abs(dphi) <= 1) ? 1 : 0; + + if (ipass1 == 0 && ipass2 == 0) + continue; + + if (ipass1 == 1) { + int tmpdph = tmpphi - phimn; + if (tmpdph < 0) + tmpdph = 2; //only case of iphi==1, where phimn=71 + + int ilog = 2 * (tmpeta - etamn) + tmpdph; + if (iring != 0) { + if (iring > 0) { + ilog = 3 * (tmpeta - etamn) + tmpdph; //Again CMS correction + } else { + ilog = 3 * (etamx - tmpeta) + tmpdph; //Again CMS correction + } + } + if (ilog > -1 && ilog < 18) { + tmpHOCalib.hocorsig[ilog] = signal; + } + } + + if (ipass2 == 1) { + if (3 * (deta + 1) + dphi + 1 < 9) { + tmpHOCalib.hosig[3 * (deta + 1) + dphi + 1] = signal; //Again CMS azimuthal near phi 1&72 + } + } + + if (deta == 0 && dphi == 0) { + tmpHOCalib.htime = (*jk).time(); + tmpHOCalib.hoflag = (*jk).flags(); + + // Get Channel Quality information for the given detID + unsigned theStatusValue = theHcalChStatus->getValues(id)->getValue(); + // Now get severity of problems for the given detID, based on the rechit flag word and the channel quality status value + int hitSeverity = hcalSevLvlComputer->getSeverityLevel(id, (*jk).flags(), theStatusValue); + tmpHOCalib.hoflag = hitSeverity; + int crphi = tmpphi + 6; + if (crphi > 72) + crphi -= 72; + + for (HORecHitCollection::const_iterator jcr = (*hoht).begin(); jcr != (*hoht).end(); jcr++) { + const HORecHit reccr = (const HORecHit)(*jcr); + HcalDetId idcr = reccr.id(); + int etacr = idcr.ieta(); + int phicr = idcr.iphi(); + if (tmpeta == etacr && crphi == phicr) { + tmpHOCalib.hocro = reccr.energy(); + } + } + } + } + } } - + //GMA Npass++; - if (Noccu == Noccu_old) Noccu++; - hostore->push_back(tmpHOCalib); - } // if (ipath) - } // Cut on calo energy + if (Noccu == Noccu_old) + Noccu++; + hostore->push_back(tmpHOCalib); + } // if (ipath) + } // Cut on calo energy } void AlCaHOCalibProducer::findHOEtaPhi(int iphisect, int& ietaho, int& iphiho) { - //18/12/06 : use only position, not angle phi - const double etalow[16]={ 0.025, 35.195, 70.625, 106.595, 141.565, 180.765, 220.235, 261.385, 304.525, 349.975, 410.025, 452.085, 506.645, 565.025, 627.725, 660.25}; - const double etahgh[16]={ 35.145, 70.575, 106.545, 125.505, 180.715, 220.185, 261.335, 304.475, 349.925, 392.575, 452.035, 506.595, 564.975, 627.675, 661.075, 700.25}; - - const double philow[6]={-76.27, -35.11, 0.35, 35.81, 71.77, 108.93}; //Ring+/-1 & 2 - const double phihgh[6]={-35.81, -0.35, 35.11, 71.07, 108.23, 140.49}; - - const double philow00[6]={-60.27, -32.91, 0.35, 33.61, 67.37, 102.23}; //Ring0 L0 - const double phihgh00[6]={-33.61, -0.35, 32.91, 66.67, 101.53, 129.49}; - - const double philow01[6]={-64.67, -34.91, 0.35, 35.61, 71.37, 108.33}; //Ring0 L1 - const double phihgh01[6]={-35.61, -0.35, 34.91, 70.67, 107.63, 138.19}; + const double etalow[16] = {0.025, + 35.195, + 70.625, + 106.595, + 141.565, + 180.765, + 220.235, + 261.385, + 304.525, + 349.975, + 410.025, + 452.085, + 506.645, + 565.025, + 627.725, + 660.25}; + const double etahgh[16] = {35.145, + 70.575, + 106.545, + 125.505, + 180.715, + 220.185, + 261.335, + 304.475, + 349.925, + 392.575, + 452.035, + 506.595, + 564.975, + 627.675, + 661.075, + 700.25}; + + const double philow[6] = {-76.27, -35.11, 0.35, 35.81, 71.77, 108.93}; //Ring+/-1 & 2 + const double phihgh[6] = {-35.81, -0.35, 35.11, 71.07, 108.23, 140.49}; + + const double philow00[6] = {-60.27, -32.91, 0.35, 33.61, 67.37, 102.23}; //Ring0 L0 + const double phihgh00[6] = {-33.61, -0.35, 32.91, 66.67, 101.53, 129.49}; + + const double philow01[6] = {-64.67, -34.91, 0.35, 35.61, 71.37, 108.33}; //Ring0 L1 + const double phihgh01[6] = {-35.61, -0.35, 34.91, 70.67, 107.63, 138.19}; iring = -10; - double tmpdy = std::abs(yhor1); - for (int ij=0; ijetalow[ij] && tmpdy etalow[ij] && tmpdy < etahgh[ij]) { + ietaho = ij + 1; + float tmp1 = fabs(tmpdy - etalow[ij]); + float tmp2 = fabs(tmpdy - etahgh[ij]); - if (ij<4) iring =0; - if (ij>=4 && ij<10) iring=1; - if (ij>=10 && ij= 4 && ij < 10) + iring = 1; + if (ij >= 10 && ij < netabin) + iring = 2; break; } } @@ -899,94 +992,99 @@ void AlCaHOCalibProducer::findHOEtaPhi(int iphisect, int& ietaho, int& iphiho) { int tmpphi = 0; int tmpphi0 = 0; - if (ietaho >4) { //Ring 1 and 2 - for (int ij=0; ij<6; ij++) { - if (xhor1 >philow[ij] && xhor1 4) { //Ring 1 and 2 + for (int ij = 0; ij < 6; ij++) { + if (xhor1 > philow[ij] && xhor1 < phihgh[ij]) { + tmpphi = ij + 1; + float tmp1 = fabs(xhor1 - philow[ij]); + float tmp2 = fabs(xhor1 - phihgh[ij]); + localxhor1 = (tmp1 < tmp2) ? -tmp1 : tmp2; + break; } } } else { //Ring 0 - for (int ij=0; ij<6; ij++) { - if (xhor1 >philow01[ij] && xhor1 philow01[ij] && xhor1 < phihgh01[ij]) { + tmpphi = ij + 1; + float tmp1 = fabs(xhor1 - philow01[ij]); + float tmp2 = fabs(xhor1 - phihgh01[ij]); + localxhor1 = (tmp1 < tmp2) ? -tmp1 : tmp2; + break; } } - for (int ij=0; ij<6; ij++) { - if (xhor0 >philow00[ij] && xhor0 philow00[ij] && xhor0 < phihgh00[ij]) { + tmpphi0 = ij + 1; + float tmp1 = fabs(xhor0 - philow00[ij]); + float tmp2 = fabs(xhor0 - phihgh00[ij]); + localxhor0 = (tmp1 < tmp2) ? -tmp1 : tmp2; + if (tmpphi != tmpphi0) + localxhor0 += 10000.; + break; } } - double tmpdy = std::abs(yhor0); - for (int ij=0; ij<4; ij++) { - if (tmpdy >etalow[ij] && tmpdy etalow[ij] && tmpdy < etahgh[ij]) { + float tmp1 = fabs(tmpdy - etalow[ij]); + float tmp2 = fabs(tmpdy - etahgh[ij]); + localyhor0 = (tmp1 < tmp2) ? -tmp1 : tmp2; + if (yhor0 < 0) + localyhor0 *= -1.; + if (ij + 1 != ietaho) + localyhor0 += 10000.; + break; } } } - if (tmpphi!=0) { - iphiho = 6*iphisect -2 + tmpphi; - if (iphiho <=0) iphiho +=nphimx; - if (iphiho >nphimx) iphiho -=nphimx; + if (tmpphi != 0) { + iphiho = 6 * iphisect - 2 + tmpphi; + if (iphiho <= 0) + iphiho += nphimx; + if (iphiho > nphimx) + iphiho -= nphimx; } // isect2 = 15*iring+iphisect+1; - if (yhor1 <0) { - if (std::abs(ietaho) >netabin) { //Initialised with 50 - ietaho +=1; + if (yhor1 < 0) { + if (std::abs(ietaho) > netabin) { //Initialised with 50 + ietaho += 1; } else { - ietaho *=-1; + ietaho *= -1; } - // isect2 *=-1; - iring *=-1; - } + // isect2 *=-1; + iring *= -1; + } } -FreeTrajectoryState AlCaHOCalibProducer::getFreeTrajectoryState( const reco::Track& tk, const MagneticField* field, int iiner, bool dir) -{ - - if (iiner ==0) { - GlobalPoint gpos( tk.outerX(), tk.outerY(), tk.outerZ()); - GlobalVector gmom( tk.outerPx(), tk.outerPy(), tk.outerPz()); - if (dir) gmom *=-1.; - GlobalTrajectoryParameters par( gpos, gmom, tk.charge(), field); - CurvilinearTrajectoryError err( tk.extra()->outerStateCovariance()); - return FreeTrajectoryState( par, err); +FreeTrajectoryState AlCaHOCalibProducer::getFreeTrajectoryState(const reco::Track& tk, + const MagneticField* field, + int iiner, + bool dir) { + if (iiner == 0) { + GlobalPoint gpos(tk.outerX(), tk.outerY(), tk.outerZ()); + GlobalVector gmom(tk.outerPx(), tk.outerPy(), tk.outerPz()); + if (dir) + gmom *= -1.; + GlobalTrajectoryParameters par(gpos, gmom, tk.charge(), field); + CurvilinearTrajectoryError err(tk.extra()->outerStateCovariance()); + return FreeTrajectoryState(par, err); } else { - GlobalPoint gpos( tk.innerPosition().X(), tk.innerPosition().Y(), tk.innerPosition().Z()); - GlobalVector gmom( tk.innerMomentum().X(), tk.innerMomentum().Y(), tk.innerMomentum().Z()); - if (dir) gmom *=-1.; - GlobalTrajectoryParameters par( gpos, -gmom, tk.charge(), field); - CurvilinearTrajectoryError err( tk.extra()->innerStateCovariance()); - return FreeTrajectoryState( par, err); + GlobalPoint gpos(tk.innerPosition().X(), tk.innerPosition().Y(), tk.innerPosition().Z()); + GlobalVector gmom(tk.innerMomentum().X(), tk.innerMomentum().Y(), tk.innerMomentum().Z()); + if (dir) + gmom *= -1.; + GlobalTrajectoryParameters par(gpos, -gmom, tk.charge(), field); + CurvilinearTrajectoryError err(tk.extra()->innerStateCovariance()); + return FreeTrajectoryState(par, err); } - } #include "FWCore/Framework/interface/MakerMacros.h" //define this as a plug-in DEFINE_FWK_MODULE(AlCaHOCalibProducer); - - diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaHcalNoiseProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaHcalNoiseProducer.cc index fa5454ae64213..58f3f4999f7a6 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaHcalNoiseProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaHcalNoiseProducer.cc @@ -8,7 +8,6 @@ Calibration/HcalIsolatedTrackReco/src/SubdetFEDSelector.cc */ - #include "Calibration/HcalAlCaRecoProducers/interface/AlCaHcalNoiseProducer.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" @@ -23,110 +22,101 @@ Calibration/HcalIsolatedTrackReco/src/SubdetFEDSelector.cc #include "FWCore/MessageLogger/interface/MessageLogger.h" +AlCaHcalNoiseProducer::AlCaHcalNoiseProducer(const edm::ParameterSet& iConfig) { + tok_jets_ = consumes(iConfig.getParameter("JetSource")); + tok_met_ = consumes(iConfig.getParameter("MetSource")); + tok_tower_ = consumes(iConfig.getParameter("TowerSource")); + useMet_ = iConfig.getParameter("UseMET"); + useJet_ = iConfig.getParameter("UseJet"); + MetCut_ = iConfig.getParameter("MetCut"); + JetMinE_ = iConfig.getParameter("JetMinE"); + JetHCALminEnergyFraction_ = iConfig.getParameter("JetHCALminEnergyFraction"); + + tok_ho_ = consumes(iConfig.getParameter("hoInput")); + tok_hf_ = consumes(iConfig.getParameter("hfInput")); + tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); + ecalLabels_ = iConfig.getParameter >("ecalInputs"); + tok_ps_ = consumes(iConfig.getParameter("ecalPSInput")); + tok_raw_ = consumes(iConfig.getParameter("rawInput")); + + const unsigned nLabels = ecalLabels_.size(); + for (unsigned i = 0; i != nLabels; i++) + toks_ecal_.push_back(consumes(ecalLabels_[i])); + + //register products + produces("HBHERecHitCollectionFHN"); + produces("HORecHitCollectionFHN"); + produces("HFRecHitCollectionFHN"); + + produces("EcalRecHitCollectionFHN"); + produces("PSEcalRecHitCollectionFHN"); + + produces("HcalFEDsFHN"); +} -AlCaHcalNoiseProducer::AlCaHcalNoiseProducer(const edm::ParameterSet& iConfig) -{ - tok_jets_ = consumes(iConfig.getParameter("JetSource")); - tok_met_ = consumes(iConfig.getParameter("MetSource")); - tok_tower_ = consumes(iConfig.getParameter("TowerSource")); - useMet_ = iConfig.getParameter("UseMET"); - useJet_ = iConfig.getParameter("UseJet"); - MetCut_ = iConfig.getParameter("MetCut"); - JetMinE_ = iConfig.getParameter("JetMinE"); - JetHCALminEnergyFraction_ = iConfig.getParameter("JetHCALminEnergyFraction"); - - tok_ho_ = consumes(iConfig.getParameter("hoInput")); - tok_hf_ = consumes(iConfig.getParameter("hfInput")); - tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); - ecalLabels_= iConfig.getParameter >("ecalInputs"); - tok_ps_ = consumes(iConfig.getParameter("ecalPSInput")); - tok_raw_ = consumes(iConfig.getParameter("rawInput")); - - const unsigned nLabels = ecalLabels_.size(); - for( unsigned i=0; i != nLabels; i++ ) - toks_ecal_.push_back( consumes(ecalLabels_[i]) ); - - - //register products - produces("HBHERecHitCollectionFHN"); - produces("HORecHitCollectionFHN"); - produces("HFRecHitCollectionFHN"); - - produces("EcalRecHitCollectionFHN"); - produces("PSEcalRecHitCollectionFHN"); - - produces("HcalFEDsFHN"); +AlCaHcalNoiseProducer::~AlCaHcalNoiseProducer() {} -} +// ------------ method called to produce the data ------------ +void AlCaHcalNoiseProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + bool acceptEvent = false; + // filtering basing on HLTrigger/special/src/HLTHcalNoiseFilter.cc: -AlCaHcalNoiseProducer::~AlCaHcalNoiseProducer() -{ -} + bool isAnomalous_BasedOnMET = false; + bool isAnomalous_BasedOnEnergyFraction = false; + + if (useMet_) { + edm::Handle metHandle; + iEvent.getByToken(tok_met_, metHandle); + const reco::CaloMETCollection* metCol = metHandle.product(); + const reco::CaloMET met = metCol->front(); + + if (met.pt() > MetCut_) + isAnomalous_BasedOnMET = true; + } + + if (useJet_) { + edm::Handle calojetHandle; + iEvent.getByToken(tok_jets_, calojetHandle); + + edm::Handle towerHandle; + iEvent.getByToken(tok_tower_, towerHandle); + + std::vector TowerContainer; + std::vector JetContainer; + TowerContainer.clear(); + JetContainer.clear(); + CaloTower seedTower; + nEvents++; + for (reco::CaloJetCollection::const_iterator calojetIter = calojetHandle->begin(); + calojetIter != calojetHandle->end(); + ++calojetIter) { + if (((calojetIter->et()) * cosh(calojetIter->eta()) > JetMinE_) && + (calojetIter->energyFractionHadronic() > JetHCALminEnergyFraction_)) { + JetContainer.push_back(*calojetIter); + double maxTowerE = 0.0; + for (CaloTowerCollection::const_iterator kal = towerHandle->begin(); kal != towerHandle->end(); kal++) { + double dR = deltaR((*calojetIter).eta(), (*calojetIter).phi(), (*kal).eta(), (*kal).phi()); + if ((dR < 0.50) && (kal->p() > maxTowerE)) { + maxTowerE = kal->p(); + seedTower = *kal; + } + } + TowerContainer.push_back(seedTower); + } + } + if (!JetContainer.empty()) { + nAnomalousEvents++; + isAnomalous_BasedOnEnergyFraction = true; + } + } + acceptEvent = ((useMet_ && isAnomalous_BasedOnMET) || (useJet_ && isAnomalous_BasedOnEnergyFraction)); -// ------------ method called to produce the data ------------ -void -AlCaHcalNoiseProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - bool acceptEvent=false; + //////////////// - // filtering basing on HLTrigger/special/src/HLTHcalNoiseFilter.cc: + //Create empty output collections - bool isAnomalous_BasedOnMET = false; - bool isAnomalous_BasedOnEnergyFraction=false; - - if (useMet_) - { - edm::Handle metHandle; - iEvent.getByToken(tok_met_, metHandle); - const reco::CaloMETCollection *metCol = metHandle.product(); - const reco::CaloMET met = metCol->front(); - - if(met.pt() > MetCut_) isAnomalous_BasedOnMET=true; - } - - if (useJet_) - { - edm::Handle calojetHandle; - iEvent.getByToken(tok_jets_,calojetHandle); - - edm::Handle towerHandle; - iEvent.getByToken(tok_tower_, towerHandle); - - std::vector TowerContainer; - std::vector JetContainer; - TowerContainer.clear(); - JetContainer.clear(); - CaloTower seedTower; - nEvents++; - for(reco::CaloJetCollection::const_iterator calojetIter = calojetHandle->begin();calojetIter != calojetHandle->end();++calojetIter) { - if( ((calojetIter->et())*cosh(calojetIter->eta()) > JetMinE_) && (calojetIter->energyFractionHadronic() > JetHCALminEnergyFraction_) ) { - JetContainer.push_back(*calojetIter); - double maxTowerE = 0.0; - for(CaloTowerCollection::const_iterator kal = towerHandle->begin(); kal != towerHandle->end(); kal++) { - double dR = deltaR((*calojetIter).eta(),(*calojetIter).phi(),(*kal).eta(),(*kal).phi()); - if( (dR < 0.50) && (kal->p() > maxTowerE) ) { - maxTowerE = kal->p(); - seedTower = *kal; - } - } - TowerContainer.push_back(seedTower); - } - - } - if(!JetContainer.empty()) { - nAnomalousEvents++; - isAnomalous_BasedOnEnergyFraction = true; - } - } - - acceptEvent=((useMet_&&isAnomalous_BasedOnMET)||(useJet_&&isAnomalous_BasedOnEnergyFraction)); - - //////////////// - - //Create empty output collections - auto miniHBHERecHitCollection = std::make_unique(); auto miniHORecHitCollection = std::make_unique(); auto miniHFRecHitCollection = std::make_unique(); @@ -136,129 +126,117 @@ AlCaHcalNoiseProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup auto outputFEDs = std::make_unique(); - // if good event get and save all colletions - if (acceptEvent) - { - edm::Handle hbhe; - edm::Handle ho; - edm::Handle hf; - - iEvent.getByToken(tok_hbhe_,hbhe); - iEvent.getByToken(tok_ho_,ho); - iEvent.getByToken(tok_hf_,hf); - - edm::Handle pRecHits; - iEvent.getByToken(tok_ps_,pRecHits); - - // temporary collection of EB+EE recHits - - auto tmpEcalRecHitCollection = std::make_unique(); - - std::vector >::const_iterator i; - for (i=toks_ecal_.begin(); i!=toks_ecal_.end(); i++) - { - edm::Handle ec; - iEvent.getByToken(*i,ec); - for(EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit) - { - tmpEcalRecHitCollection->push_back(*recHit); - } - } - - ////////// - - //////// write HCAL collections: - const HBHERecHitCollection Hithbhe = *(hbhe.product()); - for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++) - { - miniHBHERecHitCollection->push_back(*hbheItr); - } - const HORecHitCollection Hitho = *(ho.product()); - for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++) - { - miniHORecHitCollection->push_back(*hoItr); - } - - const HFRecHitCollection Hithf = *(hf.product()); - for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++) - { - miniHFRecHitCollection->push_back(*hfItr); - } - ///// - - ///// write ECAL - for (std::vector::const_iterator ehit=tmpEcalRecHitCollection->begin(); ehit!=tmpEcalRecHitCollection->end(); ehit++) - { - outputEColl->push_back(*ehit); - } - ///////// - - // write PS - const EcalRecHitCollection& psrechits = *(pRecHits.product()); - - for(EcalRecHitCollection::const_iterator i=psrechits.begin(); i!=psrechits.end(); i++) - { - outputESColl->push_back( *i ); - } - - - // get HCAL FEDs - edm::Handle rawIn; - iEvent.getByToken(tok_raw_,rawIn); - - std::vector selFEDs; - for (int i=FEDNumbering::MINHCALFEDID; i<=FEDNumbering::MAXHCALFEDID; i++) - { - selFEDs.push_back(i); - } - //////////// - - // Copying FEDs : - const FEDRawDataCollection *rdc=rawIn.product(); - - // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) ) - // continue ; // skip all raw collections not produced by the current process - - for ( int j=0; j< FEDNumbering::MAXFEDID; ++j ) - { - bool rightFED=false; - for (uint32_t k=0; kFEDData(j); - size_t size=fedData.size(); - - if ( size > 0 ) - { - // this fed has data -- lets copy it - FEDRawData & fedDataProd = outputFEDs->FEDData(j); - if ( fedDataProd.size() != 0 ) { - // std::cout << " More than one FEDRawDataCollection with data in FED "; - // std::cout << j << " Skipping the 2nd\n"; - continue; - } - fedDataProd.resize(size); - unsigned char *dataProd=fedDataProd.data(); - const unsigned char *data=fedData.data(); - for ( unsigned int k=0; k hbhe; + edm::Handle ho; + edm::Handle hf; + + iEvent.getByToken(tok_hbhe_, hbhe); + iEvent.getByToken(tok_ho_, ho); + iEvent.getByToken(tok_hf_, hf); + + edm::Handle pRecHits; + iEvent.getByToken(tok_ps_, pRecHits); + + // temporary collection of EB+EE recHits + + auto tmpEcalRecHitCollection = std::make_unique(); + + std::vector >::const_iterator i; + for (i = toks_ecal_.begin(); i != toks_ecal_.end(); i++) { + edm::Handle ec; + iEvent.getByToken(*i, ec); + for (EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit) { + tmpEcalRecHitCollection->push_back(*recHit); + } + } + + ////////// + + //////// write HCAL collections: + const HBHERecHitCollection Hithbhe = *(hbhe.product()); + for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) { + miniHBHERecHitCollection->push_back(*hbheItr); + } + const HORecHitCollection Hitho = *(ho.product()); + for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) { + miniHORecHitCollection->push_back(*hoItr); + } + + const HFRecHitCollection Hithf = *(hf.product()); + for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) { + miniHFRecHitCollection->push_back(*hfItr); + } + ///// + + ///// write ECAL + for (std::vector::const_iterator ehit = tmpEcalRecHitCollection->begin(); + ehit != tmpEcalRecHitCollection->end(); + ehit++) { + outputEColl->push_back(*ehit); + } + ///////// + + // write PS + const EcalRecHitCollection& psrechits = *(pRecHits.product()); + + for (EcalRecHitCollection::const_iterator i = psrechits.begin(); i != psrechits.end(); i++) { + outputESColl->push_back(*i); + } + + // get HCAL FEDs + edm::Handle rawIn; + iEvent.getByToken(tok_raw_, rawIn); + + std::vector selFEDs; + for (int i = FEDNumbering::MINHCALFEDID; i <= FEDNumbering::MAXHCALFEDID; i++) { + selFEDs.push_back(i); + } + //////////// + + // Copying FEDs : + const FEDRawDataCollection* rdc = rawIn.product(); + + // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) ) + // continue ; // skip all raw collections not produced by the current process + + for (int j = 0; j < FEDNumbering::MAXFEDID; ++j) { + bool rightFED = false; + for (uint32_t k = 0; k < selFEDs.size(); k++) { + if (j == selFEDs[k]) { + rightFED = true; + } + } + if (!rightFED) + continue; + const FEDRawData& fedData = rdc->FEDData(j); + size_t size = fedData.size(); + + if (size > 0) { + // this fed has data -- lets copy it + FEDRawData& fedDataProd = outputFEDs->FEDData(j); + if (fedDataProd.size() != 0) { + // std::cout << " More than one FEDRawDataCollection with data in FED "; + // std::cout << j << " Skipping the 2nd\n"; + continue; + } + fedDataProd.resize(size); + unsigned char* dataProd = fedDataProd.data(); + const unsigned char* data = fedData.data(); + for (unsigned int k = 0; k < size; ++k) { + dataProd[k] = data[k]; + } + } } + ////////////////////// + } //Put selected information in the event iEvent.put(std::move(miniHBHERecHitCollection), "HBHERecHitCollectionFHN"); iEvent.put(std::move(miniHORecHitCollection), "HORecHitCollectionFHN"); iEvent.put(std::move(miniHFRecHitCollection), "HFRecHitCollectionFHN"); - iEvent.put(std::move(outputEColl), "EcalRecHitCollectionFHN"); + iEvent.put(std::move(outputEColl), "EcalRecHitCollectionFHN"); iEvent.put(std::move(outputESColl), "PSEcalRecHitCollectionFHN"); - iEvent.put(std::move(outputFEDs), "HcalFEDsFHN"); + iEvent.put(std::move(outputFEDs), "HcalFEDsFHN"); } diff --git a/Calibration/HcalAlCaRecoProducers/src/AlCaIsoTracksProducer.cc b/Calibration/HcalAlCaRecoProducers/src/AlCaIsoTracksProducer.cc index 9e060127355c5..3705529357c77 100644 --- a/Calibration/HcalAlCaRecoProducers/src/AlCaIsoTracksProducer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/AlCaIsoTracksProducer.cc @@ -11,7 +11,7 @@ #include #include #include -#include +#include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -32,8 +32,8 @@ #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDetId/interface/EEDetId.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" -#include "DataFormats/HcalDetId/interface/HcalDetId.h" +#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" +#include "DataFormats/HcalDetId/interface/HcalDetId.h" #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" #include "DataFormats/HcalIsolatedTrack/interface/HcalIsolatedTrackCandidate.h" #include "DataFormats/HLTReco/interface/TriggerEvent.h" @@ -73,7 +73,6 @@ #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" - // // class declaration // @@ -83,85 +82,98 @@ namespace AlCaIsoTracks { Counters() : nAll_(0), nGood_(0), nRange_(0) {} mutable std::atomic nAll_, nGood_, nRange_; }; -} +} // namespace AlCaIsoTracks class AlCaIsoTracksProducer : public edm::stream::EDProducer > { public: explicit AlCaIsoTracksProducer(edm::ParameterSet const&, const AlCaIsoTracks::Counters* count); ~AlCaIsoTracksProducer() override; - - static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& ) { + + static std::unique_ptr initializeGlobalCache(edm::ParameterSet const&) { return std::make_unique(); } - void produce(edm::Event &, edm::EventSetup const&) override; + void produce(edm::Event&, edm::EventSetup const&) override; void endStream() override; - static void globalEndJob(const AlCaIsoTracks::Counters* counters); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: + static void globalEndJob(const AlCaIsoTracks::Counters* counters); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); +private: void beginRun(edm::Run const&, edm::EventSetup const&) override; void endRun(edm::Run const&, edm::EventSetup const&) override; - reco::HcalIsolatedTrackCandidateCollection* select(edm::Handle& triggerResults, const std::vector & triggerNames_, edm::Handle& trkCollection, math::XYZPoint& leadPV,edm::Handle& barrelRecHitsHandle, edm::Handle& endcapRecHitsHandle, edm::Handle& hbhe, double ptL1, double etaL1, double phiL1); - void setPtEtaPhi(std::vector< edm::Ref >& objref, double &ptL1, double &etaL1, double &phiL1); + reco::HcalIsolatedTrackCandidateCollection* select(edm::Handle& triggerResults, + const std::vector& triggerNames_, + edm::Handle& trkCollection, + math::XYZPoint& leadPV, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + double ptL1, + double etaL1, + double phiL1); + void setPtEtaPhi(std::vector >& objref, + double& ptL1, + double& etaL1, + double& phiL1); // ----------member data --------------------------- - HLTConfigProvider hltConfig_; - unsigned int nRun_, nAll_, nGood_, nRange_; - spr::trackSelectionParameters selectionParameter_; - const std::vector trigNames_; - const std::string theTrackQuality_, processName_; - const double a_coneR_, a_mipR_; - const double maxRestrictionP_, slopeRestrictionP_; - const double pTrackMin_, eEcalMax_, eIsolate_; - const double pTrackLow_, pTrackHigh_; - const int preScale_; - const edm::InputTag labelGenTrack_, labelRecVtx_, labelBS_; - const edm::InputTag labelEB_, labelEE_, labelHBHE_, labelHltGT_; - const edm::InputTag labelTriggerEvent_, labelTriggerResults_; - const std::string labelIsoTk_; - double a_charIsoR_; - const MagneticField *bField; - const CaloGeometry *geo; - - edm::EDGetTokenT tok_hltGT_; - edm::EDGetTokenT tok_trigEvt_; - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_genTrack_; - edm::EDGetTokenT tok_recVtx_; - edm::EDGetTokenT tok_bs_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_hbhe_; + HLTConfigProvider hltConfig_; + unsigned int nRun_, nAll_, nGood_, nRange_; + spr::trackSelectionParameters selectionParameter_; + const std::vector trigNames_; + const std::string theTrackQuality_, processName_; + const double a_coneR_, a_mipR_; + const double maxRestrictionP_, slopeRestrictionP_; + const double pTrackMin_, eEcalMax_, eIsolate_; + const double pTrackLow_, pTrackHigh_; + const int preScale_; + const edm::InputTag labelGenTrack_, labelRecVtx_, labelBS_; + const edm::InputTag labelEB_, labelEE_, labelHBHE_, labelHltGT_; + const edm::InputTag labelTriggerEvent_, labelTriggerResults_; + const std::string labelIsoTk_; + double a_charIsoR_; + const MagneticField* bField; + const CaloGeometry* geo; + + edm::EDGetTokenT tok_hltGT_; + edm::EDGetTokenT tok_trigEvt_; + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_genTrack_; + edm::EDGetTokenT tok_recVtx_; + edm::EDGetTokenT tok_bs_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_hbhe_; }; - -AlCaIsoTracksProducer::AlCaIsoTracksProducer(edm::ParameterSet const& iConfig, const AlCaIsoTracks::Counters* counters) : - nRun_(0), nAll_(0), nGood_(0), nRange_(0), - trigNames_(iConfig.getParameter >("triggers")), - theTrackQuality_(iConfig.getParameter("trackQuality")), - processName_(iConfig.getParameter("processName")), - a_coneR_(iConfig.getParameter("coneRadius")), - a_mipR_(iConfig.getParameter("coneRadiusMIP")), - maxRestrictionP_(iConfig.getParameter("maxTrackP")), - slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), - pTrackMin_(iConfig.getParameter("minimumTrackP")), - eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), - eIsolate_(iConfig.getParameter("isolationEnergy")), - pTrackLow_(iConfig.getParameter("momentumRangeLow")), - pTrackHigh_(iConfig.getParameter("momentumRangeHigh")), - preScale_(iConfig.getParameter("preScaleFactor")), - labelGenTrack_(iConfig.getParameter("TrackLabel")), - labelRecVtx_(iConfig.getParameter("VertexLabel")), - labelBS_(iConfig.getParameter("BeamSpotLabel")), - labelEB_(iConfig.getParameter("EBRecHitLabel")), - labelEE_(iConfig.getParameter("EERecHitLabel")), - labelHBHE_(iConfig.getParameter("HBHERecHitLabel")), - labelHltGT_(iConfig.getParameter("L1GTSeedLabel")), - labelTriggerEvent_(iConfig.getParameter("TriggerEventLabel")), - labelTriggerResults_(iConfig.getParameter("TriggerResultLabel")), - labelIsoTk_(iConfig.getParameter("IsoTrackLabel")) { +AlCaIsoTracksProducer::AlCaIsoTracksProducer(edm::ParameterSet const& iConfig, const AlCaIsoTracks::Counters* counters) + : nRun_(0), + nAll_(0), + nGood_(0), + nRange_(0), + trigNames_(iConfig.getParameter >("triggers")), + theTrackQuality_(iConfig.getParameter("trackQuality")), + processName_(iConfig.getParameter("processName")), + a_coneR_(iConfig.getParameter("coneRadius")), + a_mipR_(iConfig.getParameter("coneRadiusMIP")), + maxRestrictionP_(iConfig.getParameter("maxTrackP")), + slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), + pTrackMin_(iConfig.getParameter("minimumTrackP")), + eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), + eIsolate_(iConfig.getParameter("isolationEnergy")), + pTrackLow_(iConfig.getParameter("momentumRangeLow")), + pTrackHigh_(iConfig.getParameter("momentumRangeHigh")), + preScale_(iConfig.getParameter("preScaleFactor")), + labelGenTrack_(iConfig.getParameter("TrackLabel")), + labelRecVtx_(iConfig.getParameter("VertexLabel")), + labelBS_(iConfig.getParameter("BeamSpotLabel")), + labelEB_(iConfig.getParameter("EBRecHitLabel")), + labelEE_(iConfig.getParameter("EERecHitLabel")), + labelHBHE_(iConfig.getParameter("HBHERecHitLabel")), + labelHltGT_(iConfig.getParameter("L1GTSeedLabel")), + labelTriggerEvent_(iConfig.getParameter("TriggerEventLabel")), + labelTriggerResults_(iConfig.getParameter("TriggerResultLabel")), + labelIsoTk_(iConfig.getParameter("IsoTrackLabel")) { // Get the run parameters // Different isolation cuts are described in DN-2016/029 // Tight cut uses 2 GeV; Loose cut uses 10 GeV @@ -169,54 +181,47 @@ AlCaIsoTracksProducer::AlCaIsoTracksProducer(edm::ParameterSet const& iConfig, c // with the factor for exponential slopeRestrictionP_ = log(2.5)/18 // maxRestrictionP_ = 8 GeV as came from a study const double isolationRadius(28.9); - selectionParameter_.minPt = iConfig.getParameter("minTrackPt");; - selectionParameter_.minQuality = reco::TrackBase::qualityByName(theTrackQuality_); - selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); - selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); - selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); - selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); - selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + selectionParameter_.minPt = iConfig.getParameter("minTrackPt"); + ; + selectionParameter_.minQuality = reco::TrackBase::qualityByName(theTrackQuality_); + selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); + selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); - selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); - selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); - a_charIsoR_ = a_coneR_ + isolationRadius; + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); + a_charIsoR_ = a_coneR_ + isolationRadius; // define tokens for access - tok_hltGT_ = consumes(labelHltGT_); - tok_trigEvt_ = consumes(labelTriggerEvent_); - tok_trigRes_ = consumes(labelTriggerResults_); + tok_hltGT_ = consumes(labelHltGT_); + tok_trigEvt_ = consumes(labelTriggerEvent_); + tok_trigRes_ = consumes(labelTriggerResults_); tok_genTrack_ = consumes(labelGenTrack_); - tok_recVtx_ = consumes(labelRecVtx_); - tok_bs_ = consumes(labelBS_); - tok_EB_ = consumes(labelEB_); - tok_EE_ = consumes(labelEE_); - tok_hbhe_ = consumes(labelHBHE_); - - edm::LogInfo("HcalIsoTrack") <<"Parameters read from config file \n" - <<"\t minPt " << selectionParameter_.minPt - <<"\t theTrackQuality " << theTrackQuality_ - <<"\t minQuality " << selectionParameter_.minQuality - <<"\t maxDxyPV " << selectionParameter_.maxDxyPV - <<"\t maxDzPV " << selectionParameter_.maxDzPV - <<"\t maxChi2 " << selectionParameter_.maxChi2 - <<"\t maxDpOverP " << selectionParameter_.maxDpOverP - <<"\t minOuterHit " << selectionParameter_.minOuterHit - <<"\t minLayerCrossed " << selectionParameter_.minLayerCrossed - <<"\t maxInMiss " << selectionParameter_.maxInMiss - <<"\t maxOutMiss " << selectionParameter_.maxOutMiss << "\n" - <<"\t a_coneR " << a_coneR_ - <<"\t a_charIsoR " << a_charIsoR_ - <<"\t a_mipR " << a_mipR_ - <<"\t pTrackMin " << pTrackMin_ - <<"\t eEcalMax " << eEcalMax_ - <<"\t maxRestrictionP_ "<< maxRestrictionP_ - <<"\t slopeRestrictionP_ " << slopeRestrictionP_ - <<"\t eIsolate_ " << eIsolate_ - <<"\t Process " << processName_ << "\n" - <<"\t Precale factor " << preScale_ - <<"\t in momentum range " << pTrackLow_ - <<":" << pTrackHigh_; - for (unsigned int k=0; k(labelRecVtx_); + tok_bs_ = consumes(labelBS_); + tok_EB_ = consumes(labelEB_); + tok_EE_ = consumes(labelEE_); + tok_hbhe_ = consumes(labelHBHE_); + + edm::LogInfo("HcalIsoTrack") << "Parameters read from config file \n" + << "\t minPt " << selectionParameter_.minPt << "\t theTrackQuality " << theTrackQuality_ + << "\t minQuality " << selectionParameter_.minQuality << "\t maxDxyPV " + << selectionParameter_.maxDxyPV << "\t maxDzPV " << selectionParameter_.maxDzPV + << "\t maxChi2 " << selectionParameter_.maxChi2 << "\t maxDpOverP " + << selectionParameter_.maxDpOverP << "\t minOuterHit " << selectionParameter_.minOuterHit + << "\t minLayerCrossed " << selectionParameter_.minLayerCrossed << "\t maxInMiss " + << selectionParameter_.maxInMiss << "\t maxOutMiss " << selectionParameter_.maxOutMiss + << "\n" + << "\t a_coneR " << a_coneR_ << "\t a_charIsoR " << a_charIsoR_ << "\t a_mipR " + << a_mipR_ << "\t pTrackMin " << pTrackMin_ << "\t eEcalMax " << eEcalMax_ + << "\t maxRestrictionP_ " << maxRestrictionP_ << "\t slopeRestrictionP_ " + << slopeRestrictionP_ << "\t eIsolate_ " << eIsolate_ << "\t Process " << processName_ + << "\n" + << "\t Precale factor " << preScale_ << "\t in momentum range " << pTrackLow_ << ":" + << pTrackHigh_; + for (unsigned int k = 0; k < trigNames_.size(); ++k) edm::LogInfo("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k]; //create also IsolatedPixelTrackCandidateCollection which contains isolation info and reference to primary track @@ -227,69 +232,65 @@ AlCaIsoTracksProducer::AlCaIsoTracksProducer(edm::ParameterSet const& iConfig, c produces(labelHBHE_.label()); edm::LogInfo("HcalIsoTrack") << " Expected to produce the collections:\n" - << "reco::HcalIsolatedTrackCandidateCollection " - << " with label HcalIsolatedTrackCollection\n" - << "reco::VertexCollection with label " << labelRecVtx_.label() << "\n" - << "EcalRecHitCollection with label EcalRecHitsEB\n" - << "EcalRecHitCollection with label EcalRecHitsEE\n" - << "HBHERecHitCollection with label " << labelHBHE_.label(); + << "reco::HcalIsolatedTrackCandidateCollection " + << " with label HcalIsolatedTrackCollection\n" + << "reco::VertexCollection with label " << labelRecVtx_.label() << "\n" + << "EcalRecHitCollection with label EcalRecHitsEB\n" + << "EcalRecHitCollection with label EcalRecHitsEE\n" + << "HBHERecHitCollection with label " << labelHBHE_.label(); } - -AlCaIsoTracksProducer::~AlCaIsoTracksProducer() { } +AlCaIsoTracksProducer::~AlCaIsoTracksProducer() {} void AlCaIsoTracksProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; // producer for (HCAL isolated tracks) - desc.add("TrackLabel", edm::InputTag("generalTracks")); - desc.add("VertexLabel", edm::InputTag("offlinePrimaryVertices")); - desc.add("BeamSpotLabel",edm::InputTag("offlineBeamSpot")); - desc.add("EBRecHitLabel",edm::InputTag("ecalRecHit","EcalRecHitsEB")); - desc.add("EERecHitLabel",edm::InputTag("ecalRecHit","EcalRecHitsEE")); - desc.add("HBHERecHitLabel",edm::InputTag("hbhereco")); - desc.add("L1GTSeedLabel",edm::InputTag("hltL1sV0SingleJet60")); - desc.add("TriggerEventLabel",edm::InputTag("hltTriggerSummaryAOD","","HLT")); - desc.add("TriggerResultLabel",edm::InputTag("TriggerResults","","HLT")); - desc.add("IsoTrackLabel","HcalIsolatedTrackCollection"); - std::vector triggers = {"HLT_IsoTrackHB","HLT_IsoTrackHE"}; + desc.add("TrackLabel", edm::InputTag("generalTracks")); + desc.add("VertexLabel", edm::InputTag("offlinePrimaryVertices")); + desc.add("BeamSpotLabel", edm::InputTag("offlineBeamSpot")); + desc.add("EBRecHitLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEB")); + desc.add("EERecHitLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEE")); + desc.add("HBHERecHitLabel", edm::InputTag("hbhereco")); + desc.add("L1GTSeedLabel", edm::InputTag("hltL1sV0SingleJet60")); + desc.add("TriggerEventLabel", edm::InputTag("hltTriggerSummaryAOD", "", "HLT")); + desc.add("TriggerResultLabel", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("IsoTrackLabel", "HcalIsolatedTrackCollection"); + std::vector triggers = {"HLT_IsoTrackHB", "HLT_IsoTrackHE"}; desc.add >("triggers", triggers); desc.add("processName", "HLT"); // following 10 parameters are parameters to select good tracks - desc.add("trackQuality","highPurity"); - desc.add("minTrackPt", 1.0); - desc.add("maxDxyPV", 10.0); - desc.add("maxDzPV", 100.0); - desc.add("maxChi2", 5.0); - desc.add("maxDpOverP", 0.1); - desc.add("minOuterHit", 4); - desc.add("minLayerCrossed", 8); - desc.add("maxInMiss", 2); - desc.add("maxOutMiss", 2); + desc.add("trackQuality", "highPurity"); + desc.add("minTrackPt", 1.0); + desc.add("maxDxyPV", 10.0); + desc.add("maxDzPV", 100.0); + desc.add("maxChi2", 5.0); + desc.add("maxDpOverP", 0.1); + desc.add("minOuterHit", 4); + desc.add("minLayerCrossed", 8); + desc.add("maxInMiss", 2); + desc.add("maxOutMiss", 2); // Minimum momentum of selected isolated track and signal zone - desc.add("coneRadius", 34.98); - desc.add("minimumTrackP", 20.0); + desc.add("coneRadius", 34.98); + desc.add("minimumTrackP", 20.0); // signal zone in ECAL and MIP energy cutoff - desc.add("coneRadiusMIP", 14.0); - desc.add("maximumEcalEnergy",2.0); + desc.add("coneRadiusMIP", 14.0); + desc.add("maximumEcalEnergy", 2.0); // following 3 parameters are for isolation cuts and described in the code - desc.add("maxTrackP", 8.0); - desc.add("slopeTrackP", 0.05090504066); - desc.add("isolationEnergy", 10.0); + desc.add("maxTrackP", 8.0); + desc.add("slopeTrackP", 0.05090504066); + desc.add("isolationEnergy", 10.0); // Prescale events only containing isolated tracks in the range desc.add("momentumRangeLow", 20.0); - desc.add("momentumRangeHigh",40.0); - desc.add("preScaleFactor", 10); - descriptions.add("alcaisotrk",desc); + desc.add("momentumRangeHigh", 40.0); + desc.add("preScaleFactor", 10); + descriptions.add("alcaisotrk", desc); } void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& iSetup) { - nAll_++; #ifdef DebugLog - edm::LogInfo("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); + edm::LogInfo("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); #endif bool valid(true); //Step1: Get all the relevant containers @@ -315,7 +316,7 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i } edm::Handle recVtxs; - iEvent.getByToken(tok_recVtx_, recVtxs); + iEvent.getByToken(tok_recVtx_, recVtxs); if (!recVtxs.isValid()) { edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_; valid = false; @@ -323,11 +324,10 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i edm::Handle beamSpotH; iEvent.getByToken(tok_bs_, beamSpotH); - math::XYZPoint leadPV(0,0,0); + math::XYZPoint leadPV(0, 0, 0); if (valid) { if (!recVtxs->empty() && !((*recVtxs)[0].isFake())) { - leadPV = math::XYZPoint((*recVtxs)[0].x(),(*recVtxs)[0].y(), - (*recVtxs)[0].z()); + leadPV = math::XYZPoint((*recVtxs)[0].x(), (*recVtxs)[0].y(), (*recVtxs)[0].z()); } else if (beamSpotH.isValid()) { leadPV = beamSpotH->position(); } @@ -361,17 +361,17 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i iEvent.getByToken(tok_hltGT_, l1trigobj); if (l1trigobj.isValid()) { - std::vector< edm::Ref > l1tauobjref; + std::vector > l1tauobjref; l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref); - setPtEtaPhi(l1tauobjref,ptL1,etaL1,phiL1); + setPtEtaPhi(l1tauobjref, ptL1, etaL1, phiL1); - std::vector< edm::Ref > l1jetobjref; + std::vector > l1jetobjref; l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref); - setPtEtaPhi(l1jetobjref,ptL1,etaL1,phiL1); + setPtEtaPhi(l1jetobjref, ptL1, etaL1, phiL1); - std::vector< edm::Ref > l1forjetobjref; + std::vector > l1forjetobjref; l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref); - setPtEtaPhi(l1forjetobjref,ptL1,etaL1,phiL1); + setPtEtaPhi(l1forjetobjref, ptL1, etaL1, phiL1); } else { valid = false; } @@ -388,76 +388,93 @@ void AlCaIsoTracksProducer::produce(edm::Event& iEvent, edm::EventSetup const& i } else { trigger::TriggerEvent triggerEvent = *(triggerEventHandle.product()); if (triggerResults.isValid()) { - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & triggerNames_ = triggerNames.triggerNames(); - reco::HcalIsolatedTrackCandidateCollection* isotk = select(triggerResults, triggerNames_, trkCollection, leadPV, barrelRecHitsHandle, endcapRecHitsHandle, hbhe, ptL1, etaL1, phiL1); + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& triggerNames_ = triggerNames.triggerNames(); + reco::HcalIsolatedTrackCandidateCollection* isotk = select(triggerResults, + triggerNames_, + trkCollection, + leadPV, + barrelRecHitsHandle, + endcapRecHitsHandle, + hbhe, + ptL1, + etaL1, + phiL1); #ifdef DebugLog - edm::LogInfo("HcalIsoTrack") << "AlCaIsoTracksProducer::select returns " - << isotk->size() << " isolated tracks"; + edm::LogInfo("HcalIsoTrack") << "AlCaIsoTracksProducer::select returns " << isotk->size() << " isolated tracks"; #endif - + if (!isotk->empty()) { - int ntrin(0), ntrout(0); - for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr=isotk->begin(); itr!=isotk->end(); ++itr) { - if (itr->p() > pTrackLow_ && itr->p() < pTrackHigh_) ntrin++; - else ntrout++; - } - bool selectEvent = ntrout > 0; - if (!selectEvent && ntrin > 0) { - ++nRange_; - if (preScale_ <= 1) selectEvent = true; - else if (nRange_%preScale_ == 1) selectEvent = true; - } - if (selectEvent) { - for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr=isotk->begin(); itr!=isotk->end(); ++itr) - outputHcalIsoTrackColl->push_back(*itr); - - for (reco::VertexCollection::const_iterator vtx=recVtxs->begin(); vtx!=recVtxs->end(); ++vtx) - outputVColl->push_back(*vtx); - - for (edm::SortedCollection::const_iterator ehit=barrelRecHitsHandle->begin(); ehit!=barrelRecHitsHandle->end(); ++ehit) - outputEBColl->push_back(*ehit); - - for (edm::SortedCollection::const_iterator ehit=endcapRecHitsHandle->begin(); ehit!=endcapRecHitsHandle->end(); ++ehit) - outputEEColl->push_back(*ehit); - - for (std::vector::const_iterator hhit=hbhe->begin(); hhit!=hbhe->end(); ++hhit) - outputHBHEColl->push_back(*hhit); - ++nGood_; - } + int ntrin(0), ntrout(0); + for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr = isotk->begin(); itr != isotk->end(); + ++itr) { + if (itr->p() > pTrackLow_ && itr->p() < pTrackHigh_) + ntrin++; + else + ntrout++; + } + bool selectEvent = ntrout > 0; + if (!selectEvent && ntrin > 0) { + ++nRange_; + if (preScale_ <= 1) + selectEvent = true; + else if (nRange_ % preScale_ == 1) + selectEvent = true; + } + if (selectEvent) { + for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr = isotk->begin(); itr != isotk->end(); + ++itr) + outputHcalIsoTrackColl->push_back(*itr); + + for (reco::VertexCollection::const_iterator vtx = recVtxs->begin(); vtx != recVtxs->end(); ++vtx) + outputVColl->push_back(*vtx); + + for (edm::SortedCollection::const_iterator ehit = barrelRecHitsHandle->begin(); + ehit != barrelRecHitsHandle->end(); + ++ehit) + outputEBColl->push_back(*ehit); + + for (edm::SortedCollection::const_iterator ehit = endcapRecHitsHandle->begin(); + ehit != endcapRecHitsHandle->end(); + ++ehit) + outputEEColl->push_back(*ehit); + + for (std::vector::const_iterator hhit = hbhe->begin(); hhit != hbhe->end(); ++hhit) + outputHBHEColl->push_back(*hhit); + ++nGood_; + } } } } iEvent.put(std::move(outputHcalIsoTrackColl), labelIsoTk_); - iEvent.put(std::move(outputVColl), labelRecVtx_.label()); - iEvent.put(std::move(outputEBColl), labelEB_.instance()); - iEvent.put(std::move(outputEEColl), labelEE_.instance()); - iEvent.put(std::move(outputHBHEColl), labelHBHE_.label()); + iEvent.put(std::move(outputVColl), labelRecVtx_.label()); + iEvent.put(std::move(outputEBColl), labelEB_.instance()); + iEvent.put(std::move(outputEEColl), labelEE_.instance()); + iEvent.put(std::move(outputHBHEColl), labelHBHE_.label()); } void AlCaIsoTracksProducer::endStream() { - globalCache()->nAll_ += nAll_; - globalCache()->nGood_ += nGood_; + globalCache()->nAll_ += nAll_; + globalCache()->nGood_ += nGood_; globalCache()->nRange_ += nRange_; } void AlCaIsoTracksProducer::globalEndJob(const AlCaIsoTracks::Counters* count) { - edm::LogInfo("HcalIsoTrack") << "Finds " << count->nGood_ <<" good tracks in " - << count->nAll_ << " events and " << count->nRange_ - << " events in the momentum raange"; + edm::LogInfo("HcalIsoTrack") << "Finds " << count->nGood_ << " good tracks in " << count->nAll_ << " events and " + << count->nRange_ << " events in the momentum raange"; } void AlCaIsoTracksProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bool changed(false); - edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() - << " hltconfig.init " << hltConfig_.init(iRun,iSetup,processName_,changed); + edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init " + << hltConfig_.init(iRun, iSetup, processName_, changed); edm::ESHandle bFieldH; iSetup.get().get(bFieldH); bField = bFieldH.product(); edm::ESHandle pG; iSetup.get().get(pG); - geo = pG.product(); + geo = pG.product(); } void AlCaIsoTracksProducer::endRun(edm::Run const& iRun, edm::EventSetup const&) { @@ -465,118 +482,110 @@ void AlCaIsoTracksProducer::endRun(edm::Run const& iRun, edm::EventSetup const&) ++nRun_; } -reco::HcalIsolatedTrackCandidateCollection* -AlCaIsoTracksProducer::select(edm::Handle& triggerResults, - const std::vector & triggerNames_, - edm::Handle& trkCollection, - math::XYZPoint& leadPV,edm::Handle& barrelRecHitsHandle, - edm::Handle& endcapRecHitsHandle, - edm::Handle& hbhe, - double ptL1, double etaL1, double phiL1) { - - reco::HcalIsolatedTrackCandidateCollection* trackCollection=new reco::HcalIsolatedTrackCandidateCollection; +reco::HcalIsolatedTrackCandidateCollection* AlCaIsoTracksProducer::select( + edm::Handle& triggerResults, + const std::vector& triggerNames_, + edm::Handle& trkCollection, + math::XYZPoint& leadPV, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + double ptL1, + double etaL1, + double phiL1) { + reco::HcalIsolatedTrackCandidateCollection* trackCollection = new reco::HcalIsolatedTrackCandidateCollection; bool ok(false); // Find a good HLT trigger - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; i 0) { - ok = true; - } - edm::LogInfo("HcalIsoTrack") << "The trigger we are looking for " - << triggerNames_[iHLT] << " Flag " - << hlt << ":" << ok; + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (triggerNames_[iHLT].find(trigNames_[i]) != std::string::npos) { + if (hlt > 0) { + ok = true; + } + edm::LogInfo("HcalIsoTrack") << "The trigger we are looking for " << triggerNames_[iHLT] << " Flag " << hlt + << ":" << ok; } } } //Propagate tracks to calorimeter surface) std::vector trkCaloDirections; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDirections, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false); std::vector::const_iterator trkDetItr; unsigned int nTracks(0), nselTracks(0); - for (trkDetItr = trkCaloDirections.begin(),nTracks=0; - trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) { + for (trkDetItr = trkCaloDirections.begin(), nTracks = 0; trkDetItr != trkCaloDirections.end(); + trkDetItr++, nTracks++) { const reco::Track* pTrack = &(*(trkDetItr->trkItr)); - math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), - pTrack->pz(), pTrack->p()); + math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p()); #ifdef DebugLog - edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << pTrack->pt() - << "|" << pTrack->eta() << "|" - << pTrack->phi() << "|" << pTrack->p(); -#endif + edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << pTrack->p(); +#endif //Selection of good track - bool qltyFlag = spr::goodTrack(pTrack,leadPV,selectionParameter_,false); + bool qltyFlag = spr::goodTrack(pTrack, leadPV, selectionParameter_, false); #ifdef DebugLog - edm::LogInfo("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag - << "|" << trkDetItr->okECAL << "|" - << trkDetItr->okHCAL; + edm::LogInfo("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr->okECAL << "|" + << trkDetItr->okHCAL; #endif if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) { - double t_p = pTrack->p(); + double t_p = pTrack->p(); nselTracks++; - int nRH_eMipDR(0), nNearTRKs(0); - double eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, - trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR_, - trkDetItr->directionECAL, - nRH_eMipDR); - double hmaxNearP = spr::chargeIsolationCone(nTracks, - trkCaloDirections, - a_charIsoR_, - nNearTRKs, false); + int nRH_eMipDR(0), nNearTRKs(0); + double eMipDR = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR_, + trkDetItr->directionECAL, + nRH_eMipDR); + double hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false); HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); - int ieta = detId.ietaAbs(); - double eIsolation = (maxRestrictionP_*exp(slopeRestrictionP_*((double)(ieta)))); - if (eIsolation < eIsolate_) eIsolation = eIsolate_; + int ieta = detId.ietaAbs(); + double eIsolation = (maxRestrictionP_ * exp(slopeRestrictionP_ * ((double)(ieta)))); + if (eIsolation < eIsolate_) + eIsolation = eIsolate_; #ifdef DebugLog - edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << pTrack->pt() - << "|" << pTrack->eta() << "|" - << pTrack->phi() << "|" << t_p - << " e_MIP " << eMipDR - << " Chg Isolation " << hmaxNearP - << ":" << eIsolation; + edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << t_p << " e_MIP " << eMipDR + << " Chg Isolation " << hmaxNearP << ":" << eIsolation; #endif - if (t_p>pTrackMin_ && eMipDRpointECAL).eta(), - (trkDetItr->pointECAL).phi()); - HcalDetId detId = HcalDetId(trkDetItr->detIdHCAL); - newCandidate.SetEtaPhiHcal((trkDetItr->pointHCAL).eta(), - (trkDetItr->pointHCAL).phi(), - detId.ieta(), detId.iphi()); - int indx(0); - for (reco::TrackCollection::const_iterator trkItr1=trkCollection->begin(); - trkItr1 != trkCollection->end(); ++trkItr1,++indx) { - const reco::Track* pTrack1 = &(*trkItr1); - if (pTrack1 == pTrack) { - reco::TrackRef tRef = reco::TrackRef(trkCollection,indx); - newCandidate.setTrack(tRef); - break; - } - } - trackCollection->push_back(newCandidate); + if (t_p > pTrackMin_ && eMipDR < eEcalMax_ && hmaxNearP < eIsolation) { + reco::HcalIsolatedTrackCandidate newCandidate(v4); + newCandidate.SetMaxP(hmaxNearP); + newCandidate.SetEnergyEcal(eMipDR); + newCandidate.setL1(ptL1, etaL1, phiL1); + newCandidate.SetEtaPhiEcal((trkDetItr->pointECAL).eta(), (trkDetItr->pointECAL).phi()); + HcalDetId detId = HcalDetId(trkDetItr->detIdHCAL); + newCandidate.SetEtaPhiHcal( + (trkDetItr->pointHCAL).eta(), (trkDetItr->pointHCAL).phi(), detId.ieta(), detId.iphi()); + int indx(0); + for (reco::TrackCollection::const_iterator trkItr1 = trkCollection->begin(); trkItr1 != trkCollection->end(); + ++trkItr1, ++indx) { + const reco::Track* pTrack1 = &(*trkItr1); + if (pTrack1 == pTrack) { + reco::TrackRef tRef = reco::TrackRef(trkCollection, indx); + newCandidate.setTrack(tRef); + break; + } + } + trackCollection->push_back(newCandidate); } } } return trackCollection; } -void AlCaIsoTracksProducer::setPtEtaPhi(std::vector< edm::Ref >& objref, double &ptL1, double &etaL1, double &phiL1) { - - for (unsigned int p=0; ppt()>ptL1) { - ptL1 = objref[p]->pt(); +void AlCaIsoTracksProducer::setPtEtaPhi(std::vector >& objref, + double& ptL1, + double& etaL1, + double& phiL1) { + for (unsigned int p = 0; p < objref.size(); p++) { + if (objref[p]->pt() > ptL1) { + ptL1 = objref[p]->pt(); phiL1 = objref[p]->phi(); etaL1 = objref[p]->eta(); } diff --git a/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc b/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc index 02279fa3e0ae9..b4ecdba9c4949 100644 --- a/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc @@ -7,10 +7,10 @@ #include "DataFormats/MuonReco/interface/Muon.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/HcalCalibObjects/interface/HOCalibVariables.h" #include "DataFormats/TrackReco/interface/TrackExtra.h" #include "DataFormats/TrackReco/interface/TrackExtraFwd.h" @@ -18,216 +18,181 @@ using namespace reco; -namespace cms -{ - -// -// constructors and destructor -// -ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig) -{ - // get name of output file with histogramms - - nameProd_ = iConfig.getUntrackedParameter("nameProd"); - jetCalo_ = iConfig.getUntrackedParameter("jetCalo","GammaJetJetBackToBackCollection"); - gammaClus_ = iConfig.getUntrackedParameter("gammaClus","GammaJetGammaBackToBackCollection"); - ecalInput_=iConfig.getUntrackedParameter("ecalInput","GammaJetEcalRecHitCollection"); - hbheInput_ = iConfig.getUntrackedParameter("hbheInput"); - hoInput_ = iConfig.getUntrackedParameter("hoInput"); - hfInput_ = iConfig.getUntrackedParameter("hfInput"); - Tracks_ = iConfig.getUntrackedParameter("Tracks","GammaJetTracksCollection"); - - tok_hovar_ = consumes( edm::InputTag(nameProd_,hoInput_) ); - tok_horeco_ = consumes( edm::InputTag("horeco") ); - tok_ho_ = consumes( edm::InputTag(hoInput_) ); - tok_hoProd_ = consumes( edm::InputTag(nameProd_,hoInput_) ); - - tok_hf_ = consumes( edm::InputTag(hfInput_) ); - - tok_jets_ = consumes( edm::InputTag(nameProd_,jetCalo_) ); - tok_gamma_ = consumes( edm::InputTag(nameProd_,gammaClus_) ); - tok_muons_ = consumes(edm::InputTag(nameProd_,"SelectedMuons")); - tok_ecal_ = consumes( edm::InputTag(nameProd_,ecalInput_) ); - tok_tracks_ = consumes( edm::InputTag(nameProd_,Tracks_) ); - - tok_hbheProd_ = consumes( edm::InputTag(nameProd_,hbheInput_) ); - tok_hbhe_ = consumes( edm::InputTag(hbheInput_) ); - -} - -ProducerAnalyzer::~ProducerAnalyzer() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - -} - -void ProducerAnalyzer::beginJob() -{ -} - -void ProducerAnalyzer::endJob() -{ -} - - -// -// member functions -// - -// ------------ method called to produce the data ------------ -void -ProducerAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - - using namespace edm; - - edm::ESHandle pG; - iSetup.get().get(pG); - const CaloGeometry* geo = pG.product(); - - - std::vector theProvenance; - iEvent.getAllStableProvenance(theProvenance); - for(auto const& provenance : theProvenance) { - edm::LogVerbatim("HcalAlCa")<<" Print all module/label names " - <moduleName() - <<" "<moduleLabel() - <<" "<productInstanceName(); +namespace cms { + + // + // constructors and destructor + // + ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig) { + // get name of output file with histogramms + + nameProd_ = iConfig.getUntrackedParameter("nameProd"); + jetCalo_ = iConfig.getUntrackedParameter("jetCalo", "GammaJetJetBackToBackCollection"); + gammaClus_ = iConfig.getUntrackedParameter("gammaClus", "GammaJetGammaBackToBackCollection"); + ecalInput_ = iConfig.getUntrackedParameter("ecalInput", "GammaJetEcalRecHitCollection"); + hbheInput_ = iConfig.getUntrackedParameter("hbheInput"); + hoInput_ = iConfig.getUntrackedParameter("hoInput"); + hfInput_ = iConfig.getUntrackedParameter("hfInput"); + Tracks_ = iConfig.getUntrackedParameter("Tracks", "GammaJetTracksCollection"); + + tok_hovar_ = consumes(edm::InputTag(nameProd_, hoInput_)); + tok_horeco_ = consumes(edm::InputTag("horeco")); + tok_ho_ = consumes(edm::InputTag(hoInput_)); + tok_hoProd_ = consumes(edm::InputTag(nameProd_, hoInput_)); + + tok_hf_ = consumes(edm::InputTag(hfInput_)); + + tok_jets_ = consumes(edm::InputTag(nameProd_, jetCalo_)); + tok_gamma_ = consumes(edm::InputTag(nameProd_, gammaClus_)); + tok_muons_ = consumes(edm::InputTag(nameProd_, "SelectedMuons")); + tok_ecal_ = consumes(edm::InputTag(nameProd_, ecalInput_)); + tok_tracks_ = consumes(edm::InputTag(nameProd_, Tracks_)); + + tok_hbheProd_ = consumes(edm::InputTag(nameProd_, hbheInput_)); + tok_hbhe_ = consumes(edm::InputTag(hbheInput_)); } - - - if(nameProd_ == "hoCalibProducer") { - edm::Handle ho; - iEvent.getByToken(tok_hovar_, ho); - const HOCalibVariableCollection Hitho = *(ho.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size(); + + ProducerAnalyzer::~ProducerAnalyzer() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + } + + void ProducerAnalyzer::beginJob() {} + + void ProducerAnalyzer::endJob() {} + + // + // member functions + // + + // ------------ method called to produce the data ------------ + void ProducerAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + + edm::ESHandle pG; + iSetup.get().get(pG); + const CaloGeometry* geo = pG.product(); + + std::vector theProvenance; + iEvent.getAllStableProvenance(theProvenance); + for (auto const& provenance : theProvenance) { + edm::LogVerbatim("HcalAlCa") << " Print all module/label names " << provenance->moduleName() << " " + << provenance->moduleLabel() << " " << provenance->productInstanceName(); + } + + if (nameProd_ == "hoCalibProducer") { + edm::Handle ho; + iEvent.getByToken(tok_hovar_, ho); + const HOCalibVariableCollection Hitho = *(ho.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size(); + } + + if (nameProd_ == "ALCARECOMuAlZMuMu") { + edm::Handle ho; + iEvent.getByToken(tok_horeco_, ho); + const HORecHitCollection Hitho = *(ho.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size(); + edm::Handle mucand; + iEvent.getByToken(tok_muons_, mucand); + edm::LogVerbatim("HcalAlCa") << " Size of muon collection " << mucand->size(); + for (const auto& it : *(mucand.product())) { + TrackRef mu = it.combinedMuon(); + edm::LogVerbatim("HcalAlCa") << " Pt muon " << mu->innerMomentum(); + } + } + + if (nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") { + edm::Handle hbhe; + iEvent.getByToken(tok_hbhe_, hbhe); + const HBHERecHitCollection Hithbhe = *(hbhe.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size(); + + edm::Handle ho; + iEvent.getByToken(tok_ho_, ho); + const HORecHitCollection Hitho = *(ho.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size(); + + edm::Handle hf; + iEvent.getByToken(tok_hf_, hf); + const HFRecHitCollection Hithf = *(hf.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HF " << (Hithf).size(); + } + if (nameProd_ == "IsoProd") { + edm::LogVerbatim("HcalAlCa") << " We are here "; + edm::Handle tracks; + iEvent.getByToken(tok_tracks_, tracks); + + edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size(); + for (const auto& track : *(tracks.product())) { + edm::LogVerbatim("HcalAlCa") << " P track " << track.p() << " eta " << track.eta() << " phi " << track.phi() + << " Outer " << track.outerMomentum() << " " << track.outerPosition(); + TrackExtraRef myextra = track.extra(); + edm::LogVerbatim("HcalAlCa") << " Track extra " << myextra->outerMomentum() << " " << myextra->outerPosition(); + } + + edm::Handle ecal; + iEvent.getByToken(tok_ecal_, ecal); + const EcalRecHitCollection Hitecal = *(ecal.product()); + edm::LogVerbatim("HcalAlCa") << " Size of Ecal " << (Hitecal).size(); + + double energyECAL = 0.; + double energyHCAL = 0.; + + for (const auto& hite : *(ecal.product())) { + const GlobalPoint& posE = geo->getPosition(hite.detid()); + + edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << hite.energy() << " eta " << posE.eta() << " phi " + << posE.phi(); + + energyECAL = energyECAL + hite.energy(); + } + + edm::Handle hbhe; + iEvent.getByToken(tok_hbheProd_, hbhe); + const HBHERecHitCollection Hithbhe = *(hbhe.product()); + edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size(); + + for (const auto& hith : *(hbhe.product())) { + GlobalPoint posH = + (static_cast(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid()); + + edm::LogVerbatim("HcalAlCa") << " Energy HCAL " << hith.energy() << " eta " << posH.eta() << " phi " + << posH.phi(); + + energyHCAL = energyHCAL + hith.energy(); + } + + edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << energyECAL << " Energy HCAL " << energyHCAL; + } + + if (nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd") { + edm::LogVerbatim("HcalAlCa") << " we are in GammaJetProd area "; + edm::Handle ecal; + iEvent.getByToken(tok_ecal_, ecal); + edm::LogVerbatim("HcalAlCa") << " Size of ECAL " << (*ecal).size(); + + edm::Handle jets; + iEvent.getByToken(tok_jets_, jets); + edm::LogVerbatim("HcalAlCa") << " Jet size " << (*jets).size(); + + for (const auto& jet : *(jets.product())) { + edm::LogVerbatim("HcalAlCa") << " Et jet " << jet.et() << " eta " << jet.eta() << " phi " << jet.phi(); + } + + edm::Handle tracks; + iEvent.getByToken(tok_tracks_, tracks); + edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size(); + } + if (nameProd_ == "GammaJetProd") { + edm::Handle eclus; + iEvent.getByToken(tok_gamma_, eclus); + edm::LogVerbatim("HcalAlCa") << " GammaClus size " << (*eclus).size(); + for (const auto& iclus : *(eclus.product())) { + edm::LogVerbatim("HcalAlCa") << " Et gamma " << iclus.energy() / cosh(iclus.eta()) << " eta " << iclus.eta() + << " phi " << iclus.phi(); + } + } } - - if(nameProd_ == "ALCARECOMuAlZMuMu" ) { - - edm::Handle ho; - iEvent.getByToken(tok_horeco_, ho); - const HORecHitCollection Hitho = *(ho.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size(); - edm::Handle mucand; - iEvent.getByToken(tok_muons_, mucand); - edm::LogVerbatim("HcalAlCa")<<" Size of muon collection "<size(); - for(const auto & it : *(mucand.product())) { - TrackRef mu = it.combinedMuon(); - edm::LogVerbatim("HcalAlCa")<<" Pt muon "<innerMomentum(); - } - - } - - if(nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") { - edm::Handle hbhe; - iEvent.getByToken(tok_hbhe_, hbhe); - const HBHERecHitCollection Hithbhe = *(hbhe.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HBHE "<<(Hithbhe).size(); - - - edm::Handle ho; - iEvent.getByToken(tok_ho_, ho); - const HORecHitCollection Hitho = *(ho.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size(); - - - edm::Handle hf; - iEvent.getByToken(tok_hf_, hf); - const HFRecHitCollection Hithf = *(hf.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HF "<<(Hithf).size(); - } - if(nameProd_ == "IsoProd") { - edm::LogVerbatim("HcalAlCa")<<" We are here "; - edm::Handle tracks; - iEvent.getByToken(tok_tracks_,tracks); - - - edm::LogVerbatim("HcalAlCa")<<" Tracks size "<<(*tracks).size(); - for (const auto & track : *(tracks.product())) { - edm::LogVerbatim("HcalAlCa")<<" P track "<outerMomentum()<<" " - <outerPosition(); - } - - edm::Handle ecal; - iEvent.getByToken(tok_ecal_,ecal); - const EcalRecHitCollection Hitecal = *(ecal.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of Ecal "<<(Hitecal).size(); - - double energyECAL = 0.; - double energyHCAL = 0.; - - for (const auto & hite : *(ecal.product())) { - - const GlobalPoint& posE = geo->getPosition(hite.detid()); - - edm::LogVerbatim("HcalAlCa")<<" Energy ECAL "< hbhe; - iEvent.getByToken(tok_hbheProd_,hbhe); - const HBHERecHitCollection Hithbhe = *(hbhe.product()); - edm::LogVerbatim("HcalAlCa")<<" Size of HBHE "<<(Hithbhe).size(); - - for (const auto & hith : *(hbhe.product())) { - - GlobalPoint posH = (static_cast(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid()); - - edm::LogVerbatim("HcalAlCa")<<" Energy HCAL "< ecal; - iEvent.getByToken(tok_ecal_, ecal); - edm::LogVerbatim("HcalAlCa")<<" Size of ECAL "<<(*ecal).size(); - - edm::Handle jets; - iEvent.getByToken(tok_jets_, jets); - edm::LogVerbatim("HcalAlCa")<<" Jet size "<<(*jets).size(); - - for (const auto & jet : *(jets.product())) { - edm::LogVerbatim("HcalAlCa")<<" Et jet "< tracks; - iEvent.getByToken(tok_tracks_, tracks); - edm::LogVerbatim("HcalAlCa")<<" Tracks size "<<(*tracks).size(); - } - if( nameProd_ == "GammaJetProd") { - edm::Handle eclus; - iEvent.getByToken(tok_gamma_, eclus); - edm::LogVerbatim("HcalAlCa")<<" GammaClus size "<<(*eclus).size(); - for (const auto & iclus : *(eclus.product())) { - edm::LogVerbatim("HcalAlCa")<<" Et gamma " - < tok_hovar_; - edm::EDGetTokenT tok_horeco_; - edm::EDGetTokenT tok_ho_; - edm::EDGetTokenT tok_hoProd_; + private: + // ----------member data --------------------------- + std::string nameProd_; + std::string jetCalo_; + std::string gammaClus_; + std::string ecalInput_; + std::string hbheInput_; + std::string hoInput_; + std::string hfInput_; + std::string Tracks_; - edm::EDGetTokenT tok_hf_; + edm::EDGetTokenT tok_hovar_; + edm::EDGetTokenT tok_horeco_; + edm::EDGetTokenT tok_ho_; + edm::EDGetTokenT tok_hoProd_; - edm::EDGetTokenT tok_jets_; - edm::EDGetTokenT tok_gamma_; - edm::EDGetTokenT tok_muons_; - edm::EDGetTokenT tok_ecal_; - edm::EDGetTokenT tok_tracks_; + edm::EDGetTokenT tok_hf_; - edm::EDGetTokenT tok_hbhe_; - edm::EDGetTokenT tok_hbheProd_; + edm::EDGetTokenT tok_jets_; + edm::EDGetTokenT tok_gamma_; + edm::EDGetTokenT tok_muons_; + edm::EDGetTokenT tok_ecal_; + edm::EDGetTokenT tok_tracks_; -}; -}// end namespace cms + edm::EDGetTokenT tok_hbhe_; + edm::EDGetTokenT tok_hbheProd_; + }; +} // end namespace cms #endif From 0aa3753feff458836e9b69f2f6122b9254e8275f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 04:09:30 +0200 Subject: [PATCH 618/686] Fix clang warnings in Calibration/HcalCalibAlgos --- .../interface/CommonUsefulStuff.h | 261 +- .../interface/HcalConstantsXMLWriter.h | 28 +- .../HcalCalibAlgos/interface/hcalCalib.h | 436 +- .../HcalCalibAlgos/interface/hcalCalibUtils.h | 25 +- .../HcalCalibAlgos/plugins/AnalyzerMinbias.cc | 561 ++- .../plugins/Analyzer_minbias.cc | 978 ++-- .../HcalCalibAlgos/plugins/Analyzer_minbias.h | 96 +- .../HcalCalibAlgos/plugins/HOCalibAnalyzer.cc | 4260 +++++++++-------- .../HcalCalibAlgos/plugins/HcalCalibrator.cc | 160 +- .../HcalCalibAlgos/plugins/HcalCalibrator.h | 38 +- .../plugins/HcalHBHEMuonAnalyzer.cc | 1369 +++--- .../plugins/HcalIsoTrkAnalyzer.cc | 1762 +++---- .../HcalCalibAlgos/plugins/HitReCalibrator.cc | 201 +- .../HcalCalibAlgos/plugins/HitReCalibrator.h | 31 +- .../HcalCalibAlgos/plugins/RecAnalyzerHF.cc | 349 +- .../plugins/RecAnalyzerMinbias.cc | 860 ++-- .../plugins/SimAnalyzerMinbias.cc | 164 +- .../plugins/ValidIsoTrkCalib.cc | 1051 ++-- .../src/HcalConstantsXMLWriter.cc | 214 +- Calibration/HcalCalibAlgos/src/TCell.h | 41 +- Calibration/HcalCalibAlgos/src/classes.h | 5 +- Calibration/HcalCalibAlgos/src/hcalCalib.cc | 758 ++- .../HcalCalibAlgos/src/hcalCalibUtils.cc | 309 +- .../HcalCalibAlgos/test/DiJetAnalyzer.cc | 2101 ++++---- .../HcalCalibAlgos/test/DiJetAnalyzer.h | 98 +- .../HcalCalibAlgos/test/GammaJetAnalysis.cc | 2540 +++++----- .../HcalCalibAlgos/test/GammaJetAnalysis.h | 247 +- .../test/HcalConstantsASCIIWriter.cc | 211 +- .../test/HcalConstantsASCIIWriter.h | 32 +- .../test/HcalCorrPFCalculation.cc | 1077 ++--- .../HcalCalibAlgos/test/HcalIsoTrackStudy.cc | 1847 +++---- .../HcalCalibAlgos/test/HcalLaserTest.cc | 233 +- .../test/ValidationHcalIsoTrackAlCaReco.cc | 615 ++- .../test/ValidationHcalIsoTrackAlCaReco.h | 30 +- 34 files changed, 11581 insertions(+), 11407 deletions(-) mode change 100755 => 100644 Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc diff --git a/Calibration/HcalCalibAlgos/interface/CommonUsefulStuff.h b/Calibration/HcalCalibAlgos/interface/CommonUsefulStuff.h index 10dbc2baf9168..d073da89161b9 100644 --- a/Calibration/HcalCalibAlgos/interface/CommonUsefulStuff.h +++ b/Calibration/HcalCalibAlgos/interface/CommonUsefulStuff.h @@ -1,7 +1,6 @@ #ifndef CommonUsefulStuff_h #define CommonUsefulStuff_h - #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -41,106 +40,73 @@ /uscms/home/jhirsch/IsoTracks_314/CMSSW_3_1_4/src/JetMETCorrections/IsolatedParticles/interface/FindCaloHit.icc */ - -struct MaxHit_struct -{ +struct MaxHit_struct { int iphihitm; int ietahitm; int depthhit; float hitenergy; float dr; GlobalPoint posMax; - MaxHit_struct():iphihitm(0),ietahitm(0), - depthhit(0),hitenergy(-100),dr(0){} + MaxHit_struct() : iphihitm(0), ietahitm(0), depthhit(0), hitenergy(-100), dr(0) {} }; - -inline double getDistInPlaneSimple(const GlobalPoint caloPoint, - const GlobalPoint rechitPoint) -{ - +inline double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint) { // Simplified version of getDistInPlane // Assume track direction is origin -> point of hcal intersection - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z()); const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit(); - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitUnitVector = rechitVector.unit(); double dotprod = caloIntersectUnitVector.dot(rechitUnitVector); - double rechitdist = caloIntersectVector.mag()/dotprod; - + double rechitdist = caloIntersectVector.mag() / dotprod; - const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); + const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); + GlobalVector distance_vector = effectiveRechitPoint - caloPoint; - GlobalVector distance_vector = effectiveRechitPoint-caloPoint; - - if (dotprod > 0.) - { + if (dotprod > 0.) { return distance_vector.mag(); - } - else - { + } else { return 999999.; - } - } -inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint, - const GlobalVector caloVector, - const GlobalPoint rechitPoint) -{ - +inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint, + const GlobalVector caloVector, + const GlobalPoint rechitPoint) { // Simplified version of getDistInPlane : no cone "within" Hcal, but // don't assume track direction is origin -> point of hcal // intersection. - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); //p + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), + caloPoint.z()); //p const GlobalVector caloUnitVector = caloVector.unit(); - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitUnitVector = rechitVector.unit(); double dotprod_denominator = caloUnitVector.dot(rechitUnitVector); - double dotprod_numerator = caloUnitVector.dot(caloIntersectVector); - double rechitdist = dotprod_numerator/dotprod_denominator; - const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); - GlobalVector distance_vector = effectiveRechitPoint-caloPoint; - if (dotprod_denominator > 0. && dotprod_numerator > 0.) - { - + double dotprod_numerator = caloUnitVector.dot(caloIntersectVector); + double rechitdist = dotprod_numerator / dotprod_denominator; + const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); + GlobalVector distance_vector = effectiveRechitPoint - caloPoint; + if (dotprod_denominator > 0. && dotprod_numerator > 0.) { return distance_vector.mag(); - } - else - { + } else { return 999999.; } } - - inline double getDistInPlane(const GlobalVector trackDirection, - const GlobalPoint caloPoint, - const GlobalPoint rechitPoint, - double coneHeight) -{ - + const GlobalPoint caloPoint, + const GlobalPoint rechitPoint, + double coneHeight) { // The iso track candidate hits the Calo (Ecal or Hcal) at "caloPoint" // with direction "trackDirection". @@ -154,34 +120,27 @@ inline double getDistInPlane(const GlobalVector trackDirection, // the Hcal. Our approach is to see whether/where this line // intersects a cone of height "coneHeight" with vertex at caloPoint // aligned with trackDirection. - // To that end, this function returns the distance between the + // To that end, this function returns the distance between the // center of the base of the cone and the intersection of the rechit // line and the plane that contains the base of the cone. This // distance is compared with the radius of the cone outside this // function. - // Make vector of length cone height along track direction - const GlobalVector heightVector = trackDirection*coneHeight; + const GlobalVector heightVector = trackDirection * coneHeight; // Make vector from origin to point where iso track intersects the // calorimeter. - const GlobalVector caloIntersectVector(caloPoint.x(), - caloPoint.y(), - caloPoint.z()); + const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z()); // Make vector from origin to point in center of base of cone - const GlobalVector coneBaseVector = heightVector+caloIntersectVector; + const GlobalVector coneBaseVector = heightVector + caloIntersectVector; -// Make point in center of base of cone - const GlobalPoint coneBasePoint(coneBaseVector.x(), - coneBaseVector.y(), - coneBaseVector.z()); + // Make point in center of base of cone + const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z()); // Make unit vector pointing at rechit. - const GlobalVector rechitVector(rechitPoint.x(), - rechitPoint.y(), - rechitPoint.z()); + const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z()); const GlobalVector rechitDirection = rechitVector.unit(); // Find distance "r" along "rechit line" (with angles theta2 and @@ -200,103 +159,95 @@ inline double getDistInPlane(const GlobalVector trackDirection, // Substitute P_{rh} into equation for plane and solve for rechitdist. // rechitDist turns out to be the ratio of dot products: - double rechitdist = trackDirection.dot(coneBaseVector)/trackDirection.dot(rechitDirection); + double rechitdist = trackDirection.dot(coneBaseVector) / trackDirection.dot(rechitDirection); // Now find distance between point at center of cone base and point // where the "rechit line" intersects the plane defined by the base // of the cone; i.e. the effectiveRecHitPoint. - const GlobalVector effectiveRechitVector = rechitdist*rechitDirection; - const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(), - effectiveRechitVector.y(), - effectiveRechitVector.z()); + const GlobalVector effectiveRechitVector = rechitdist * rechitDirection; + const GlobalPoint effectiveRechitPoint( + effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z()); - - GlobalVector distance_vector = effectiveRechitPoint-coneBasePoint; + GlobalVector distance_vector = effectiveRechitPoint - coneBasePoint; return distance_vector.mag(); } - /* Function to calculate Ecal Energy in Cone (given in cm) */ -inline double ecalEnergyInCone(const GlobalPoint center, double radius, const EcalRecHitCollection ecalCol, const CaloGeometry *geo) -{ +inline double ecalEnergyInCone(const GlobalPoint center, + double radius, + const EcalRecHitCollection ecalCol, + const CaloGeometry* geo) { double eECALcone = 0; - std::vector usedHitsEcal; + std::vector usedHitsEcal; usedHitsEcal.clear(); - - for (std::vector::const_iterator ehit=ecalCol.begin(); ehit!=ecalCol.end(); ehit++) - { - //This is a precaution for the case when hitCollection contains duplicats. - bool hitIsUsed=false; - int hitHashedIndex=-10000; - if (ehit->id().subdetId()==EcalBarrel) - { - EBDetId did(ehit->id()); - hitHashedIndex=did.hashedIndex(); - } - if (ehit->id().subdetId()==EcalEndcap) - { - EEDetId did(ehit->id()); - hitHashedIndex=did.hashedIndex(); - } - for (uint32_t i=0; igetPosition((*ehit).detid()); - - if (getDistInPlaneSimple(center,pos) < radius) - { - eECALcone += ehit->energy(); - } + + for (std::vector::const_iterator ehit = ecalCol.begin(); ehit != ecalCol.end(); ehit++) { + //This is a precaution for the case when hitCollection contains duplicats. + bool hitIsUsed = false; + int hitHashedIndex = -10000; + if (ehit->id().subdetId() == EcalBarrel) { + EBDetId did(ehit->id()); + hitHashedIndex = did.hashedIndex(); + } + if (ehit->id().subdetId() == EcalEndcap) { + EEDetId did(ehit->id()); + hitHashedIndex = did.hashedIndex(); + } + for (uint32_t i = 0; i < usedHitsEcal.size(); i++) { + if (usedHitsEcal[i] == hitHashedIndex) + hitIsUsed = true; } + if (hitIsUsed) + continue; + usedHitsEcal.push_back(hitHashedIndex); + // ----------------------------------------------- + + const GlobalPoint& pos = geo->getPosition((*ehit).detid()); + + if (getDistInPlaneSimple(center, pos) < radius) { + eECALcone += ehit->energy(); + } + } return eECALcone; } /* This is another version of ecalEnergy calculation using the getDistInPlaneTrackDir() */ -inline double ecalEnergyInCone(const GlobalVector trackMom, const GlobalPoint center, double radius, const EcalRecHitCollection ecalCol, const CaloGeometry *geo) -{ - +inline double ecalEnergyInCone(const GlobalVector trackMom, + const GlobalPoint center, + double radius, + const EcalRecHitCollection ecalCol, + const CaloGeometry* geo) { double eECALcone = 0; - std::vector usedHitsEcal; + std::vector usedHitsEcal; usedHitsEcal.clear(); - for (std::vector::const_iterator ehit=ecalCol.begin(); ehit!=ecalCol.end(); ehit++) - { - //This is a precaution for the case when hitCollection contains duplicats. - bool hitIsUsed=false; - int hitHashedIndex=-10000; - if (ehit->id().subdetId()==EcalBarrel) - { - EBDetId did(ehit->id()); - hitHashedIndex=did.hashedIndex(); - } - if (ehit->id().subdetId()==EcalEndcap) - { - EEDetId did(ehit->id()); - hitHashedIndex=did.hashedIndex(); - } - for (uint32_t i=0; igetPosition((*ehit).detid()); - - if (getDistInPlaneTrackDir(center, trackMom ,pos) < radius) - { - eECALcone += ehit->energy(); - } - } - return eECALcone; -} + for (std::vector::const_iterator ehit = ecalCol.begin(); ehit != ecalCol.end(); ehit++) { + //This is a precaution for the case when hitCollection contains duplicats. + bool hitIsUsed = false; + int hitHashedIndex = -10000; + if (ehit->id().subdetId() == EcalBarrel) { + EBDetId did(ehit->id()); + hitHashedIndex = did.hashedIndex(); + } + if (ehit->id().subdetId() == EcalEndcap) { + EEDetId did(ehit->id()); + hitHashedIndex = did.hashedIndex(); + } + for (uint32_t i = 0; i < usedHitsEcal.size(); i++) { + if (usedHitsEcal[i] == hitHashedIndex) + hitIsUsed = true; + } + if (hitIsUsed) + continue; + usedHitsEcal.push_back(hitHashedIndex); + // ----------------------------------------------- + const GlobalPoint& pos = geo->getPosition((*ehit).detid()); + if (getDistInPlaneTrackDir(center, trackMom, pos) < radius) { + eECALcone += ehit->energy(); + } + } + return eECALcone; +} #endif - diff --git a/Calibration/HcalCalibAlgos/interface/HcalConstantsXMLWriter.h b/Calibration/HcalCalibAlgos/interface/HcalConstantsXMLWriter.h index 749d6528acb93..029b8e02b0015 100644 --- a/Calibration/HcalCalibAlgos/interface/HcalConstantsXMLWriter.h +++ b/Calibration/HcalCalibAlgos/interface/HcalConstantsXMLWriter.h @@ -15,20 +15,22 @@ #include #include -class HcalConstantsXMLWriter -{ - public: - HcalConstantsXMLWriter(); - virtual ~HcalConstantsXMLWriter(); - void writeXML(std::string&, const std::vector&, const std::vector&, const std::vector&, const std::vector&,const std::vector&); - - void newCellLine(xercesc::DOMElement*, int,int,int,int,float); +class HcalConstantsXMLWriter { +public: + HcalConstantsXMLWriter(); + virtual ~HcalConstantsXMLWriter(); + void writeXML(std::string&, + const std::vector&, + const std::vector&, + const std::vector&, + const std::vector&, + const std::vector&); - private: - std::string hcalfileOut_; - xercesc::DOMDocument* mDoc; -}; + void newCellLine(xercesc::DOMElement*, int, int, int, int, float); +private: + std::string hcalfileOut_; + xercesc::DOMDocument* mDoc; +}; #endif - diff --git a/Calibration/HcalCalibAlgos/interface/hcalCalib.h b/Calibration/HcalCalibAlgos/interface/hcalCalib.h index 24e7bc582d663..27da8ebd35585 100644 --- a/Calibration/HcalCalibAlgos/interface/hcalCalib.h +++ b/Calibration/HcalCalibAlgos/interface/hcalCalib.h @@ -35,235 +35,229 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" - class hcalCalib : public TSelector { -public : - TTree *fChain; //!pointer to the analyzed TTree or TChain - - UInt_t eventNumber; - UInt_t runNumber; - Int_t iEtaHit; - UInt_t iPhiHit; - TClonesArray *cells; - Float_t emEnergy; - Float_t targetE; - Float_t etVetoJet; - - Float_t xTrkHcal; - Float_t yTrkHcal; - Float_t zTrkHcal; - Float_t xTrkEcal; - Float_t yTrkEcal; - Float_t zTrkEcal; - - TLorentzVector *tagJetP4; - TLorentzVector *probeJetP4; - - Float_t tagJetEmFrac; - Float_t probeJetEmFrac; - - // List of branches - TBranch *b_eventNumber; //! - TBranch *b_runNumber; //! - TBranch *b_iEtaHit; //! - TBranch *b_iPhiHit; //! - TBranch *b_cells; //! - TBranch *b_emEnergy; //! - TBranch *b_targetE; //! - TBranch *b_etVetoJet; //! - - TBranch *b_xTrkHcal; - TBranch *b_yTrkHcal; - TBranch *b_zTrkHcal; - TBranch *b_xTrkEcal; - TBranch *b_yTrkEcal; - TBranch *b_zTrkEcal; - - TBranch *b_tagJetEmFrac; //! - TBranch *b_probeJetEmFrac; //! - - TBranch *b_tagJetP4; //! - TBranch *b_probeJetP4; //! - - - hcalCalib(TTree * /*tree*/ =nullptr) { } - ~hcalCalib() override { } - Int_t Version() const override { return 2; } - void Begin(TTree *tree) override; - // virtual void SlaveBegin(TTree *tree); - void Init(TTree *tree) override; - Bool_t Notify() override; - Bool_t Process(Long64_t entry) override; - Int_t GetEntry(Long64_t entry, Int_t getall = 0) override { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; } - void SetOption(const char *option) override { fOption = option; } - void SetObject(TObject *obj) override { fObject = obj; } - void SetInputList(TList *input) override { fInput = input; } - TList *GetOutputList() const override { return fOutput; } - // virtual void SlaveTerminate(); - void Terminate() override; - - //------------ CUTS --------------- - Float_t MIN_TARGET_E; - Float_t MAX_TARGET_E; - - Float_t MIN_CELL_E; - Float_t MIN_EOVERP; - Float_t MAX_EOVERP; - Float_t MAX_TRK_EME; - - Float_t MAX_ET_THIRD_JET; - Float_t MIN_DPHI_DIJETS; - - Bool_t SUM_DEPTHS; - Bool_t SUM_SMALL_DEPTHS; - Bool_t COMBINE_PHI; - - Int_t HB_CLUSTER_SIZE; - Int_t HE_CLUSTER_SIZE; - - Bool_t USE_CONE_CLUSTERING; - Float_t MAX_CONE_DIST; - - Int_t CALIB_ABS_IETA_MAX; - Int_t CALIB_ABS_IETA_MIN; - - Float_t MAX_PROBEJET_EMFRAC; - Float_t MAX_TAGJET_EMFRAC; - Float_t MAX_TAGJET_ABSETA; - Float_t MIN_TAGJET_ET; - - Float_t MIN_PROBEJET_ABSETA; - - TString CALIB_TYPE; // "ISO_TRACK" or "DI_JET" - TString CALIB_METHOD; // L3, matrix inversion, everage then matrix inversion,... - - TString PHI_SYM_COR_FILENAME; - Bool_t APPLY_PHI_SYM_COR_FLAG; - - TString OUTPUT_COR_COEF_FILENAME; - TString HISTO_FILENAME; - - - const CaloGeometry* theCaloGeometry; - const HcalTopology* topo_; - - - void SetMinTargetE(Float_t e) { MIN_TARGET_E = e; } - void SetMaxTargetE(Float_t e) { MAX_TARGET_E = e; } - void SetSumDepthsFlag(Bool_t b) { SUM_DEPTHS = b; } - void SetSumSmallDepthsFlag(Bool_t b) { SUM_SMALL_DEPTHS = b; } - void SetCombinePhiFlag(Bool_t b) { COMBINE_PHI = b; } - void SetMinCellE(Float_t e) { MIN_CELL_E = e; } - void SetMinEOverP(Float_t e) { MIN_EOVERP = e; } - void SetMaxEOverP(Float_t e) { MAX_EOVERP = e; } - void SetMaxTrkEmE(Float_t e) { MAX_TRK_EME = e; } - void SetCalibType(const TString& s) { CALIB_TYPE = s; } - void SetCalibMethod(const TString& s) { CALIB_METHOD = s; } - void SetHbClusterSize(Int_t i) { HB_CLUSTER_SIZE = i; } - void SetHeClusterSize(Int_t i) { HE_CLUSTER_SIZE = i; } - - void SetUseConeClustering (Bool_t b) { USE_CONE_CLUSTERING = b; } - void SetConeMaxDist(Float_t d) { MAX_CONE_DIST = d; } - - void SetCalibAbsIEtaMax(Int_t i) { CALIB_ABS_IETA_MAX = i; } - void SetCalibAbsIEtaMin(Int_t i) { CALIB_ABS_IETA_MIN = i; } - void SetMaxEtThirdJet(Float_t et) { MAX_ET_THIRD_JET = et; } - void SetMinDPhiDiJets(Float_t dphi) { MIN_DPHI_DIJETS = dphi; } - void SetApplyPhiSymCorFlag(Bool_t b) { APPLY_PHI_SYM_COR_FLAG = b; } - void SetPhiSymCorFileName(const TString& filename) { PHI_SYM_COR_FILENAME = filename; } - void SetMaxProbeJetEmFrac(Float_t f) { MAX_PROBEJET_EMFRAC = f; } - void SetMaxTagJetEmFrac(Float_t f) { MAX_TAGJET_EMFRAC = f; } - void SetMaxTagJetAbsEta(Float_t e) { MAX_TAGJET_ABSETA = e; } - void SetMinTagJetEt(Float_t e) { MIN_TAGJET_ET = e; } - void SetMinProbeJetAbsEta(Float_t e) { MIN_PROBEJET_ABSETA = e; } - void SetOutputCorCoefFileName(const TString& filename) { OUTPUT_COR_COEF_FILENAME = filename; } - void SetHistoFileName(const TString& filename) { HISTO_FILENAME = filename; } - - - void SetCaloGeometry (const CaloGeometry* g, const HcalTopology* topo) { theCaloGeometry = g; topo_=topo; } - - void GetCoefFromMtrxInvOfAve(); - - Bool_t ReadPhiSymCor(); - - void makeTextFile(); - - - // --------- containers passed to minimizers ---------------- - std::vector< std::vector > cellEnergies; - std::vector< std::vector > cellIds; - std::vector< std::pair > refIEtaIPhi; // centroid of jet or hottest tower iEta, iPhi - std::vector< Float_t> targetEnergies; - - std::map phiSymCor; // holds the phi symmetry corrections read from the file - - std::map solution; // correction coef: solution from L3, holds final coef for hybrid methods as well - std::map iEtaCoefMap; // correction coef: from matrix inversion AFTER averaging, also intermediate results for hybrid methods - - - - // ClassDef(hcalCalib,0); +public: + TTree *fChain; //!pointer to the analyzed TTree or TChain + + UInt_t eventNumber; + UInt_t runNumber; + Int_t iEtaHit; + UInt_t iPhiHit; + TClonesArray *cells; + Float_t emEnergy; + Float_t targetE; + Float_t etVetoJet; + + Float_t xTrkHcal; + Float_t yTrkHcal; + Float_t zTrkHcal; + Float_t xTrkEcal; + Float_t yTrkEcal; + Float_t zTrkEcal; + + TLorentzVector *tagJetP4; + TLorentzVector *probeJetP4; + + Float_t tagJetEmFrac; + Float_t probeJetEmFrac; + + // List of branches + TBranch *b_eventNumber; //! + TBranch *b_runNumber; //! + TBranch *b_iEtaHit; //! + TBranch *b_iPhiHit; //! + TBranch *b_cells; //! + TBranch *b_emEnergy; //! + TBranch *b_targetE; //! + TBranch *b_etVetoJet; //! + + TBranch *b_xTrkHcal; + TBranch *b_yTrkHcal; + TBranch *b_zTrkHcal; + TBranch *b_xTrkEcal; + TBranch *b_yTrkEcal; + TBranch *b_zTrkEcal; + + TBranch *b_tagJetEmFrac; //! + TBranch *b_probeJetEmFrac; //! + + TBranch *b_tagJetP4; //! + TBranch *b_probeJetP4; //! + + hcalCalib(TTree * /*tree*/ = nullptr) {} + ~hcalCalib() override {} + Int_t Version() const override { return 2; } + void Begin(TTree *tree) override; + // virtual void SlaveBegin(TTree *tree); + void Init(TTree *tree) override; + Bool_t Notify() override; + Bool_t Process(Long64_t entry) override; + Int_t GetEntry(Long64_t entry, Int_t getall = 0) override { + return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; + } + void SetOption(const char *option) override { fOption = option; } + void SetObject(TObject *obj) override { fObject = obj; } + void SetInputList(TList *input) override { fInput = input; } + TList *GetOutputList() const override { return fOutput; } + // virtual void SlaveTerminate(); + void Terminate() override; + + //------------ CUTS --------------- + Float_t MIN_TARGET_E; + Float_t MAX_TARGET_E; + + Float_t MIN_CELL_E; + Float_t MIN_EOVERP; + Float_t MAX_EOVERP; + Float_t MAX_TRK_EME; + + Float_t MAX_ET_THIRD_JET; + Float_t MIN_DPHI_DIJETS; + + Bool_t SUM_DEPTHS; + Bool_t SUM_SMALL_DEPTHS; + Bool_t COMBINE_PHI; + + Int_t HB_CLUSTER_SIZE; + Int_t HE_CLUSTER_SIZE; + + Bool_t USE_CONE_CLUSTERING; + Float_t MAX_CONE_DIST; + + Int_t CALIB_ABS_IETA_MAX; + Int_t CALIB_ABS_IETA_MIN; + + Float_t MAX_PROBEJET_EMFRAC; + Float_t MAX_TAGJET_EMFRAC; + Float_t MAX_TAGJET_ABSETA; + Float_t MIN_TAGJET_ET; + + Float_t MIN_PROBEJET_ABSETA; + + TString CALIB_TYPE; // "ISO_TRACK" or "DI_JET" + TString CALIB_METHOD; // L3, matrix inversion, everage then matrix inversion,... + + TString PHI_SYM_COR_FILENAME; + Bool_t APPLY_PHI_SYM_COR_FLAG; + + TString OUTPUT_COR_COEF_FILENAME; + TString HISTO_FILENAME; + + const CaloGeometry *theCaloGeometry; + const HcalTopology *topo_; + + void SetMinTargetE(Float_t e) { MIN_TARGET_E = e; } + void SetMaxTargetE(Float_t e) { MAX_TARGET_E = e; } + void SetSumDepthsFlag(Bool_t b) { SUM_DEPTHS = b; } + void SetSumSmallDepthsFlag(Bool_t b) { SUM_SMALL_DEPTHS = b; } + void SetCombinePhiFlag(Bool_t b) { COMBINE_PHI = b; } + void SetMinCellE(Float_t e) { MIN_CELL_E = e; } + void SetMinEOverP(Float_t e) { MIN_EOVERP = e; } + void SetMaxEOverP(Float_t e) { MAX_EOVERP = e; } + void SetMaxTrkEmE(Float_t e) { MAX_TRK_EME = e; } + void SetCalibType(const TString &s) { CALIB_TYPE = s; } + void SetCalibMethod(const TString &s) { CALIB_METHOD = s; } + void SetHbClusterSize(Int_t i) { HB_CLUSTER_SIZE = i; } + void SetHeClusterSize(Int_t i) { HE_CLUSTER_SIZE = i; } + + void SetUseConeClustering(Bool_t b) { USE_CONE_CLUSTERING = b; } + void SetConeMaxDist(Float_t d) { MAX_CONE_DIST = d; } + + void SetCalibAbsIEtaMax(Int_t i) { CALIB_ABS_IETA_MAX = i; } + void SetCalibAbsIEtaMin(Int_t i) { CALIB_ABS_IETA_MIN = i; } + void SetMaxEtThirdJet(Float_t et) { MAX_ET_THIRD_JET = et; } + void SetMinDPhiDiJets(Float_t dphi) { MIN_DPHI_DIJETS = dphi; } + void SetApplyPhiSymCorFlag(Bool_t b) { APPLY_PHI_SYM_COR_FLAG = b; } + void SetPhiSymCorFileName(const TString &filename) { PHI_SYM_COR_FILENAME = filename; } + void SetMaxProbeJetEmFrac(Float_t f) { MAX_PROBEJET_EMFRAC = f; } + void SetMaxTagJetEmFrac(Float_t f) { MAX_TAGJET_EMFRAC = f; } + void SetMaxTagJetAbsEta(Float_t e) { MAX_TAGJET_ABSETA = e; } + void SetMinTagJetEt(Float_t e) { MIN_TAGJET_ET = e; } + void SetMinProbeJetAbsEta(Float_t e) { MIN_PROBEJET_ABSETA = e; } + void SetOutputCorCoefFileName(const TString &filename) { OUTPUT_COR_COEF_FILENAME = filename; } + void SetHistoFileName(const TString &filename) { HISTO_FILENAME = filename; } + + void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo) { + theCaloGeometry = g; + topo_ = topo; + } + + void GetCoefFromMtrxInvOfAve(); + + Bool_t ReadPhiSymCor(); + + void makeTextFile(); + + // --------- containers passed to minimizers ---------------- + std::vector > cellEnergies; + std::vector > cellIds; + std::vector > refIEtaIPhi; // centroid of jet or hottest tower iEta, iPhi + std::vector targetEnergies; + + std::map phiSymCor; // holds the phi symmetry corrections read from the file + + std::map solution; // correction coef: solution from L3, holds final coef for hybrid methods as well + std::map + iEtaCoefMap; // correction coef: from matrix inversion AFTER averaging, also intermediate results for hybrid methods + + // ClassDef(hcalCalib,0); }; #endif #ifdef hcalCalib_cxx -void hcalCalib::Init(TTree *tree) -{ - // The Init() function is called when the selector needs to initialize - // a new tree or chain. Typically here the branch addresses and branch - // pointers of the tree will be set. - // It is normaly not necessary to make changes to the generated - // code, but the routine can be extended by the user if needed. - // Init() will be called many times when running on PROOF - // (once per file to be processed). - - // Set object pointer - cells = nullptr; - tagJetP4 = nullptr; - probeJetP4 = nullptr; - - // Set branch addresses and branch pointers - if (!tree) return; - fChain = tree; - - // fChain->SetMakeClass(1); - - fChain->SetBranchAddress("eventNumber", &eventNumber, &b_eventNumber); - fChain->SetBranchAddress("runNumber", &runNumber, &b_runNumber); - fChain->SetBranchAddress("iEtaHit", &iEtaHit, &b_iEtaHit); - fChain->SetBranchAddress("iPhiHit", &iPhiHit, &b_iPhiHit); - fChain->SetBranchAddress("cells", &cells, &b_cells); - fChain->SetBranchAddress("emEnergy", &emEnergy, &b_emEnergy); - fChain->SetBranchAddress("targetE", &targetE, &b_targetE); - fChain->SetBranchAddress("etVetoJet", &etVetoJet, &b_etVetoJet); - - fChain->SetBranchAddress("xTrkHcal", &xTrkHcal, &b_xTrkHcal); - fChain->SetBranchAddress("yTrkHcal", &yTrkHcal, &b_yTrkHcal); - fChain->SetBranchAddress("zTrkHcal", &zTrkHcal, &b_zTrkHcal); - fChain->SetBranchAddress("xTrkEcal", &xTrkEcal, &b_xTrkEcal); - fChain->SetBranchAddress("yTrkEcal", &yTrkEcal, &b_yTrkEcal); - fChain->SetBranchAddress("zTrkEcal", &zTrkEcal, &b_zTrkEcal); - - fChain->SetBranchAddress("tagJetEmFrac", &tagJetEmFrac, &b_tagJetEmFrac); - fChain->SetBranchAddress("probeJetEmFrac", &probeJetEmFrac, &b_probeJetEmFrac); - - fChain->SetBranchAddress("tagJetP4", &tagJetP4, &b_tagJetP4); - fChain->SetBranchAddress("probeJetP4", &probeJetP4, &b_probeJetP4); - - - +void hcalCalib::Init(TTree *tree) { + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normaly not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set object pointer + cells = nullptr; + tagJetP4 = nullptr; + probeJetP4 = nullptr; + + // Set branch addresses and branch pointers + if (!tree) + return; + fChain = tree; + + // fChain->SetMakeClass(1); + + fChain->SetBranchAddress("eventNumber", &eventNumber, &b_eventNumber); + fChain->SetBranchAddress("runNumber", &runNumber, &b_runNumber); + fChain->SetBranchAddress("iEtaHit", &iEtaHit, &b_iEtaHit); + fChain->SetBranchAddress("iPhiHit", &iPhiHit, &b_iPhiHit); + fChain->SetBranchAddress("cells", &cells, &b_cells); + fChain->SetBranchAddress("emEnergy", &emEnergy, &b_emEnergy); + fChain->SetBranchAddress("targetE", &targetE, &b_targetE); + fChain->SetBranchAddress("etVetoJet", &etVetoJet, &b_etVetoJet); + + fChain->SetBranchAddress("xTrkHcal", &xTrkHcal, &b_xTrkHcal); + fChain->SetBranchAddress("yTrkHcal", &yTrkHcal, &b_yTrkHcal); + fChain->SetBranchAddress("zTrkHcal", &zTrkHcal, &b_zTrkHcal); + fChain->SetBranchAddress("xTrkEcal", &xTrkEcal, &b_xTrkEcal); + fChain->SetBranchAddress("yTrkEcal", &yTrkEcal, &b_yTrkEcal); + fChain->SetBranchAddress("zTrkEcal", &zTrkEcal, &b_zTrkEcal); + + fChain->SetBranchAddress("tagJetEmFrac", &tagJetEmFrac, &b_tagJetEmFrac); + fChain->SetBranchAddress("probeJetEmFrac", &probeJetEmFrac, &b_probeJetEmFrac); + + fChain->SetBranchAddress("tagJetP4", &tagJetP4, &b_tagJetP4); + fChain->SetBranchAddress("probeJetP4", &probeJetP4, &b_probeJetP4); } -Bool_t hcalCalib::Notify() -{ - // The Notify() function is called when a new file is opened. This - // can be either for a new TTree in a TChain or when when a new TTree - // is started when using PROOF. It is normaly not necessary to make changes - // to the generated code, but the routine can be extended by the - // user if needed. The return value is currently not used. +Bool_t hcalCalib::Notify() { + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normaly not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. - return kTRUE; + return kTRUE; } -#endif // #ifdef hcalCalib_cxx +#endif // #ifdef hcalCalib_cxx diff --git a/Calibration/HcalCalibAlgos/interface/hcalCalibUtils.h b/Calibration/HcalCalibAlgos/interface/hcalCalibUtils.h index d2087ada4bd50..668b4b518baa6 100644 --- a/Calibration/HcalCalibAlgos/interface/hcalCalibUtils.h +++ b/Calibration/HcalCalibAlgos/interface/hcalCalibUtils.h @@ -9,37 +9,32 @@ #include "Calibration/HcalCalibAlgos/src/TCell.h" - #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" - -void sumDepths(std::vector &selectCells); // replaces original collection +void sumDepths(std::vector& selectCells); // replaces original collection // sum "small" depths in towers 16,17: depths 1,2 in HB -void sumSmallDepths(std::vector &selectCells); // replaces original collection - -void combinePhi(std::vector &selectCells); // replaces original collection - -void combinePhi(std::vector &selectCells, std::vector &combinedCells); +void sumSmallDepths(std::vector& selectCells); // replaces original collection +void combinePhi(std::vector& selectCells); // replaces original collection +void combinePhi(std::vector& selectCells, std::vector& combinedCells); void getIEtaIPhiForHighestE(std::vector& selectCells, Int_t& iEta, UInt_t& iPhi); -void filterCells3x3 (std::vector& selectCells, Int_t iEta, UInt_t iPhi); -void filterCells5x5 (std::vector& selectCells, Int_t iEta, UInt_t iPhi); +void filterCells3x3(std::vector& selectCells, Int_t iEta, UInt_t iPhi); +void filterCells5x5(std::vector& selectCells, Int_t iEta, UInt_t iPhi); - -void filterCellsInCone (std::vector& selectCells, const GlobalPoint hitPositionHcal, - Float_t maxConeDist, const CaloGeometry* theCaloGeometry); +void filterCellsInCone(std::vector& selectCells, + const GlobalPoint hitPositionHcal, + Float_t maxConeDist, + const CaloGeometry* theCaloGeometry); // Jim's implementation fo the cone //double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint); - - //void makeTextFile(std::map &coef); #endif diff --git a/Calibration/HcalCalibAlgos/plugins/AnalyzerMinbias.cc b/Calibration/HcalCalibAlgos/plugins/AnalyzerMinbias.cc index aec8fd2545aaa..9e5fc8103f3d3 100644 --- a/Calibration/HcalCalibAlgos/plugins/AnalyzerMinbias.cc +++ b/Calibration/HcalCalibAlgos/plugins/AnalyzerMinbias.cc @@ -59,12 +59,10 @@ #include "TH2.h" #include "TTree.h" -namespace HcalMinbias { -} +namespace HcalMinbias {} // constructors and destructor class AnalyzerMinbias : public edm::EDAnalyzer { - public: explicit AnalyzerMinbias(const edm::ParameterSet&); ~AnalyzerMinbias() override; @@ -72,16 +70,17 @@ class AnalyzerMinbias : public edm::EDAnalyzer { void analyze(const edm::Event&, const edm::EventSetup&) override; void beginJob() override; void endJob() override; - + private: - - void analyzeHcal(const HcalRespCorrs* myRecalib, - const HBHERecHitCollection& HithbheNS, - const HBHERecHitCollection& HithbheMB, - const HFRecHitCollection& HithfNS, - const HFRecHitCollection& HithfMB, int algoBit, bool fill); - - struct myInfo{ + void analyzeHcal(const HcalRespCorrs* myRecalib, + const HBHERecHitCollection& HithbheNS, + const HBHERecHitCollection& HithbheMB, + const HFRecHitCollection& HithfNS, + const HFRecHitCollection& HithfMB, + int algoBit, + bool fill); + + struct myInfo { double theMB0, theMB1, theMB2, theMB3, theMB4; double theNS0, theNS1, theNS2, theNS3, theNS4; double theDif0, theDif1, theDif2, runcheck; @@ -93,445 +92,435 @@ class AnalyzerMinbias : public edm::EDAnalyzer { }; // ----------member data --------------------------- - std::string fOutputFileName, hcalfile_; - std::ofstream *myout_hcal; - TFile* hOutputFile ; - TTree* myTree; - TH1D *h_Noise[4], *h_Signal[4]; - bool runNZS_, theRecalib_, ignoreL1_; - double rnnum; - + std::string fOutputFileName, hcalfile_; + std::ofstream* myout_hcal; + TFile* hOutputFile; + TTree* myTree; + TH1D *h_Noise[4], *h_Signal[4]; + bool runNZS_, theRecalib_, ignoreL1_; + double rnnum; + // Root tree members - double rnnumber; - int mydet, mysubd, depth, iphi, ieta, cells, trigbit; - float phi, eta; - float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, occup; - float mom0_Noise, mom1_Noise, mom2_Noise, mom3_Noise, mom4_Noise; - float mom0_Diff, mom1_Diff, mom2_Diff, mom3_Diff, mom4_Diff; - - std::map,myInfo> myMap_; - edm::EDGetTokenT tok_hbherecoMB_, tok_hbherecoNoise_; - edm::EDGetTokenT tok_hfrecoMB_, tok_hfrecoNoise_; - edm::EDGetTokenT tok_horecoMB_, tok_horecoNoise_; - edm::EDGetTokenT tok_hbheNormal_; + double rnnumber; + int mydet, mysubd, depth, iphi, ieta, cells, trigbit; + float phi, eta; + float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, occup; + float mom0_Noise, mom1_Noise, mom2_Noise, mom3_Noise, mom4_Noise; + float mom0_Diff, mom1_Diff, mom2_Diff, mom3_Diff, mom4_Diff; + + std::map, myInfo> myMap_; + edm::EDGetTokenT tok_hbherecoMB_, tok_hbherecoNoise_; + edm::EDGetTokenT tok_hfrecoMB_, tok_hfrecoNoise_; + edm::EDGetTokenT tok_horecoMB_, tok_horecoNoise_; + edm::EDGetTokenT tok_hbheNormal_; edm::EDGetTokenT tok_hltL1GtMap_; }; AnalyzerMinbias::AnalyzerMinbias(const edm::ParameterSet& iConfig) { - // get name of output file with histogramms fOutputFileName = iConfig.getUntrackedParameter("HistOutFile"); - - // get token names of modules, producing object collections - tok_hbherecoMB_ = consumes(iConfig.getParameter("hbheInputMB")); - tok_horecoMB_ = consumes(iConfig.getParameter("hoInputMB")); - tok_hfrecoMB_ = consumes(iConfig.getParameter("hfInputMB")); - tok_hbherecoNoise_= consumes(iConfig.getParameter("hbheInputNoise")); - tok_horecoNoise_ = consumes(iConfig.getParameter("hoInputNoise")); - tok_hfrecoNoise_ = consumes(iConfig.getParameter("hfInputNoise")); + // get token names of modules, producing object collections + tok_hbherecoMB_ = consumes(iConfig.getParameter("hbheInputMB")); + tok_horecoMB_ = consumes(iConfig.getParameter("hoInputMB")); + tok_hfrecoMB_ = consumes(iConfig.getParameter("hfInputMB")); - theRecalib_ = iConfig.getParameter("Recalib"); - ignoreL1_ = iConfig.getUntrackedParameter("IgnoreL1", true); - runNZS_ = iConfig.getUntrackedParameter("RunNZS", true); + tok_hbherecoNoise_ = consumes(iConfig.getParameter("hbheInputNoise")); + tok_horecoNoise_ = consumes(iConfig.getParameter("hoInputNoise")); + tok_hfrecoNoise_ = consumes(iConfig.getParameter("hfInputNoise")); + theRecalib_ = iConfig.getParameter("Recalib"); + ignoreL1_ = iConfig.getUntrackedParameter("IgnoreL1", true); + runNZS_ = iConfig.getUntrackedParameter("RunNZS", true); - tok_hbheNormal_ = consumes(edm::InputTag("hbhereco")); - tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); + tok_hbheNormal_ = consumes(edm::InputTag("hbhereco")); + tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); } - -AnalyzerMinbias::~AnalyzerMinbias() { } -void AnalyzerMinbias::beginJob() { +AnalyzerMinbias::~AnalyzerMinbias() {} +void AnalyzerMinbias::beginJob() { std::string det[4] = {"HB", "HE", "HO", "HF"}; - char name[80], title[80]; - for (int subd=0; subd<4; ++subd) { - sprintf(name,"Noise_%s",det[subd].c_str()); - sprintf(title,"Energy Distribution for Noise in %s",det[subd].c_str()); - h_Noise[subd] = new TH1D(name,title,100,-10.,10.); - sprintf(name,"Signal_%s",det[subd].c_str()); - sprintf(title,"Energy Distribution for Signal in %s",det[subd].c_str()); - h_Signal[subd] = new TH1D(name,title,100,-10.,10.); + char name[80], title[80]; + for (int subd = 0; subd < 4; ++subd) { + sprintf(name, "Noise_%s", det[subd].c_str()); + sprintf(title, "Energy Distribution for Noise in %s", det[subd].c_str()); + h_Noise[subd] = new TH1D(name, title, 100, -10., 10.); + sprintf(name, "Signal_%s", det[subd].c_str()); + sprintf(title, "Energy Distribution for Signal in %s", det[subd].c_str()); + h_Signal[subd] = new TH1D(name, title, 100, -10., 10.); } - hOutputFile = new TFile(fOutputFileName.c_str(), "RECREATE") ; - myTree = new TTree("RecJet","RecJet Tree"); - myTree->Branch("mydet", &mydet, "mydet/I"); - myTree->Branch("mysubd", &mysubd, "mysubd/I"); - myTree->Branch("cells", &cells, "cells"); - myTree->Branch("depth", &depth, "depth/I"); - myTree->Branch("ieta", &ieta, "ieta/I"); - myTree->Branch("iphi", &iphi, "iphi/I"); - myTree->Branch("eta", &eta, "eta/F"); - myTree->Branch("phi", &phi, "phi/F"); - myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); - myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); - myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); - myTree->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); - myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); - myTree->Branch("mom0_Noise", &mom0_Noise, "mom0_Noise/F"); - myTree->Branch("mom1_Noise", &mom1_Noise, "mom1_Noise/F"); - myTree->Branch("mom2_Noise", &mom2_Noise, "mom2_Noise/F"); - myTree->Branch("mom3_Noise", &mom3_Noise, "mom3_Noise/F"); - myTree->Branch("mom4_Noise", &mom4_Noise, "mom4_Noise/F"); - myTree->Branch("mom0_Diff", &mom0_Diff, "mom0_Diff/F"); - myTree->Branch("mom1_Diff", &mom1_Diff, "mom1_Diff/F"); - myTree->Branch("mom2_Diff", &mom2_Diff, "mom2_Diff/F"); - myTree->Branch("occup", &occup, "occup/F"); - myTree->Branch("trigbit", &trigbit, "trigbit/I"); - myTree->Branch("rnnumber", &rnnumber, "rnnumber/D"); + hOutputFile = new TFile(fOutputFileName.c_str(), "RECREATE"); + myTree = new TTree("RecJet", "RecJet Tree"); + myTree->Branch("mydet", &mydet, "mydet/I"); + myTree->Branch("mysubd", &mysubd, "mysubd/I"); + myTree->Branch("cells", &cells, "cells"); + myTree->Branch("depth", &depth, "depth/I"); + myTree->Branch("ieta", &ieta, "ieta/I"); + myTree->Branch("iphi", &iphi, "iphi/I"); + myTree->Branch("eta", &eta, "eta/F"); + myTree->Branch("phi", &phi, "phi/F"); + myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); + myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); + myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); + myTree->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); + myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); + myTree->Branch("mom0_Noise", &mom0_Noise, "mom0_Noise/F"); + myTree->Branch("mom1_Noise", &mom1_Noise, "mom1_Noise/F"); + myTree->Branch("mom2_Noise", &mom2_Noise, "mom2_Noise/F"); + myTree->Branch("mom3_Noise", &mom3_Noise, "mom3_Noise/F"); + myTree->Branch("mom4_Noise", &mom4_Noise, "mom4_Noise/F"); + myTree->Branch("mom0_Diff", &mom0_Diff, "mom0_Diff/F"); + myTree->Branch("mom1_Diff", &mom1_Diff, "mom1_Diff/F"); + myTree->Branch("mom2_Diff", &mom2_Diff, "mom2_Diff/F"); + myTree->Branch("occup", &occup, "occup/F"); + myTree->Branch("trigbit", &trigbit, "trigbit/I"); + myTree->Branch("rnnumber", &rnnumber, "rnnumber/D"); myMap_.clear(); } - + // EndJob // void AnalyzerMinbias::endJob() { - - int ii=0; - for (std::map,myInfo>::const_iterator itr=myMap_.begin(); itr != myMap_.end(); ++itr) { - LogDebug("AnalyzerMB") << "Fired trigger bit number " << itr->first.first; + int ii = 0; + for (std::map, myInfo>::const_iterator itr = myMap_.begin(); itr != myMap_.end(); ++itr) { + LogDebug("AnalyzerMB") << "Fired trigger bit number " << itr->first.first; myInfo info = itr->second; - if (info.theMB0 > 0) { - mom0_MB = info.theMB0; - mom1_MB = info.theMB1; - mom2_MB = info.theMB2; - mom3_MB = info.theMB3; - mom4_MB = info.theMB4; + if (info.theMB0 > 0) { + mom0_MB = info.theMB0; + mom1_MB = info.theMB1; + mom2_MB = info.theMB2; + mom3_MB = info.theMB3; + mom4_MB = info.theMB4; mom0_Noise = info.theNS0; mom1_Noise = info.theNS1; mom2_Noise = info.theNS2; mom3_Noise = info.theNS3; mom4_Noise = info.theNS4; - mom0_Diff = info.theDif0; - mom1_Diff = info.theDif1; - mom2_Diff = info.theDif2; - rnnumber = info.runcheck; - trigbit = itr->first.first; - mysubd = itr->first.second.subdet(); - depth = itr->first.second.depth(); - ieta = itr->first.second.ieta(); - iphi = itr->first.second.iphi(); - - LogDebug("AnalyzerMB") << " Result= " << trigbit << " " << mysubd - << " " << ieta << " " << iphi << " mom0 " - << mom0_MB << " mom1 " << mom1_MB << " mom2 " - << mom2_MB << " mom3 " << mom3_MB << " mom4 " - << mom4_MB << " mom0_Noise " << mom0_Noise - << " mom1_Noise " << mom1_Noise << " mom2_Noise " - << mom2_Noise << " mom3_Noise " << mom3_Noise - << " mom4_Noise " << mom4_Noise << " mom0_Diff " - << mom0_Diff << " mom1_Diff " << mom1_Diff - << " mom2_Diff " << mom2_Diff; + mom0_Diff = info.theDif0; + mom1_Diff = info.theDif1; + mom2_Diff = info.theDif2; + rnnumber = info.runcheck; + trigbit = itr->first.first; + mysubd = itr->first.second.subdet(); + depth = itr->first.second.depth(); + ieta = itr->first.second.ieta(); + iphi = itr->first.second.iphi(); + + LogDebug("AnalyzerMB") << " Result= " << trigbit << " " << mysubd << " " << ieta << " " << iphi << " mom0 " + << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB << " mom3 " << mom3_MB << " mom4 " + << mom4_MB << " mom0_Noise " << mom0_Noise << " mom1_Noise " << mom1_Noise + << " mom2_Noise " << mom2_Noise << " mom3_Noise " << mom3_Noise << " mom4_Noise " + << mom4_Noise << " mom0_Diff " << mom0_Diff << " mom1_Diff " << mom1_Diff << " mom2_Diff " + << mom2_Diff; myTree->Fill(); ii++; } } - cells = ii; - LogDebug("AnalyzerMB") << "cells" << " " << cells; - hOutputFile->Write(); + cells = ii; + LogDebug("AnalyzerMB") << "cells" + << " " << cells; + hOutputFile->Write(); hOutputFile->cd(); myTree->Write(); - for(int i=0; i<4; i++){ + for (int i = 0; i < 4; i++) { h_Noise[i]->Write(); h_Signal[i]->Write(); } - hOutputFile->Close() ; + hOutputFile->Close(); } - // // member functions // - + // ------------ method called to produce the data ------------ - + void AnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - - rnnum = (float)iEvent.run(); - const HcalRespCorrs* myRecalib=nullptr; + rnnum = (float)iEvent.run(); + const HcalRespCorrs* myRecalib = nullptr; if (theRecalib_) { - edm::ESHandle recalibCorrs; - iSetup.get().get("recalibrate",recalibCorrs); + edm::ESHandle recalibCorrs; + iSetup.get().get("recalibrate", recalibCorrs); myRecalib = recalibCorrs.product(); - } // theRecalib - + } // theRecalib + edm::Handle hbheNormal; iEvent.getByToken(tok_hbheNormal_, hbheNormal); - if (!hbheNormal.isValid()) { + if (!hbheNormal.isValid()) { edm::LogInfo("AnalyzerMB") << " hbheNormal failed"; } else { - edm::LogInfo("AnalyzerMB") << " The size of the normal collection " - << hbheNormal->size(); + edm::LogInfo("AnalyzerMB") << " The size of the normal collection " << hbheNormal->size(); } edm::Handle hbheNS; iEvent.getByToken(tok_hbherecoNoise_, hbheNS); if (!hbheNS.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbheNoise product!"; - return ; + return; } const HBHERecHitCollection HithbheNS = *(hbheNS.product()); edm::LogInfo("AnalyzerMB") << "HBHE NS size of collection " << HithbheNS.size(); - if (runNZS_ && HithbheNS.size() != 5184) { - edm::LogWarning("AnalyzerMB") << "HBHE NS problem " << rnnum << " size " - << HithbheNS.size(); + if (runNZS_ && HithbheNS.size() != 5184) { + edm::LogWarning("AnalyzerMB") << "HBHE NS problem " << rnnum << " size " << HithbheNS.size(); return; } - + edm::Handle hbheMB; iEvent.getByToken(tok_hbherecoMB_, hbheMB); if (!hbheMB.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbhe product!"; - return ; + return; } const HBHERecHitCollection HithbheMB = *(hbheMB.product()); edm::LogInfo("AnalyzerMB") << "HBHE MB size of collection " << HithbheMB.size(); - if (runNZS_ && HithbheMB.size() != 5184) { - edm::LogWarning("AnalyzerMB") << "HBHE problem " << rnnum << " size " - << HithbheMB.size(); + if (runNZS_ && HithbheMB.size() != 5184) { + edm::LogWarning("AnalyzerMB") << "HBHE problem " << rnnum << " size " << HithbheMB.size(); return; } - + edm::Handle hfNS; iEvent.getByToken(tok_hfrecoNoise_, hfNS); if (!hfNS.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hfNoise product!"; - return ; + return; } const HFRecHitCollection HithfNS = *(hfNS.product()); - edm::LogInfo("AnalyzerMB") << "HF NS size of collection "<< HithfNS.size(); - if (runNZS_ && HithfNS.size() != 1728) { - edm::LogWarning("AnalyzerMB") << "HF NS problem " << rnnum << " size " - << HithfNS.size(); + edm::LogInfo("AnalyzerMB") << "HF NS size of collection " << HithfNS.size(); + if (runNZS_ && HithfNS.size() != 1728) { + edm::LogWarning("AnalyzerMB") << "HF NS problem " << rnnum << " size " << HithfNS.size(); return; } - + edm::Handle hfMB; iEvent.getByToken(tok_hfrecoMB_, hfMB); if (!hfMB.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hf product!"; - return ; + return; } const HFRecHitCollection HithfMB = *(hfMB.product()); edm::LogInfo("AnalyzerMB") << "HF MB size of collection " << HithfMB.size(); - if(runNZS_ && HithfMB.size() != 1728) { - edm::LogWarning("AnalyzerMB") << "HF problem " << rnnum << " size " - << HithfMB.size(); + if (runNZS_ && HithfMB.size() != 1728) { + edm::LogWarning("AnalyzerMB") << "HF problem " << rnnum << " size " << HithfMB.size(); return; } - + if (ignoreL1_) { - analyzeHcal(myRecalib,HithbheNS,HithbheMB,HithfNS,HithfMB,1,true); + analyzeHcal(myRecalib, HithbheNS, HithbheMB, HithfNS, HithfMB, 1, true); } else { edm::Handle gtObjectMapRecord; iEvent.getByToken(tok_hltL1GtMap_, gtObjectMapRecord); if (gtObjectMapRecord.isValid()) { const std::vector& objMapVec = gtObjectMapRecord->gtObjectMap(); - int ii(0); + int ii(0); bool ok(false), fill(true); - for (std::vector::const_iterator itMap = objMapVec.begin(); - itMap != objMapVec.end(); ++itMap, ++ii) { - bool resultGt = (*itMap).algoGtlResult(); - if (resultGt == 1) { - ok = true; - int algoBit = (*itMap).algoBitNumber(); - analyzeHcal(myRecalib,HithbheNS,HithbheMB,HithfNS,HithfMB,algoBit,fill); - fill = false; - std::string algoNameStr = (*itMap).algoName(); - LogDebug("AnalyzerMB") << "Trigger[" << ii << "] " << algoNameStr - << " bit " << algoBit << " entered"; - } + for (std::vector::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end(); + ++itMap, ++ii) { + bool resultGt = (*itMap).algoGtlResult(); + if (resultGt == 1) { + ok = true; + int algoBit = (*itMap).algoBitNumber(); + analyzeHcal(myRecalib, HithbheNS, HithbheMB, HithfNS, HithfMB, algoBit, fill); + fill = false; + std::string algoNameStr = (*itMap).algoName(); + LogDebug("AnalyzerMB") << "Trigger[" << ii << "] " << algoNameStr << " bit " << algoBit << " entered"; + } } - if (!ok) edm::LogInfo("AnalyzerMB") << "No passed L1 Triggers"; + if (!ok) + edm::LogInfo("AnalyzerMB") << "No passed L1 Triggers"; } } } -void AnalyzerMinbias::analyzeHcal(const HcalRespCorrs* myRecalib, - const HBHERecHitCollection& HithbheNS, - const HBHERecHitCollection& HithbheMB, - const HFRecHitCollection& HithfNS, - const HFRecHitCollection& HithfMB, - int algoBit, bool fill) { - +void AnalyzerMinbias::analyzeHcal(const HcalRespCorrs* myRecalib, + const HBHERecHitCollection& HithbheNS, + const HBHERecHitCollection& HithbheMB, + const HFRecHitCollection& HithfNS, + const HFRecHitCollection& HithfMB, + int algoBit, + bool fill) { // Noise part for HB HE - std::map,myInfo> tmpMap; + std::map, myInfo> tmpMap; tmpMap.clear(); - - for (HBHERecHitCollection::const_iterator hbheItr=HithbheNS.begin(); - hbheItr!=HithbheNS.end(); hbheItr++) { - + + for (HBHERecHitCollection::const_iterator hbheItr = HithbheNS.begin(); hbheItr != HithbheNS.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if (theRecalib_) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); + if (theRecalib_) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); double energyhit = aHit.energy(); - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); + + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + std::map, myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit, hid)); if (itr1 == myMap_.end()) { myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); } itr1->second.theNS0++; itr1->second.theNS1 += energyhit; - itr1->second.theNS2 += (energyhit*energyhit); - itr1->second.theNS3 += (energyhit*energyhit*energyhit); - itr1->second.theNS4 += (energyhit*energyhit*energyhit*energyhit); + itr1->second.theNS2 += (energyhit * energyhit); + itr1->second.theNS3 += (energyhit * energyhit * energyhit); + itr1->second.theNS4 += (energyhit * energyhit * energyhit * energyhit); itr1->second.runcheck = rnnum; - if (fill) h_Noise[hid.subdet()-1]->Fill(energyhit); + if (fill) + h_Noise[hid.subdet() - 1]->Fill(energyhit); - std::map,myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit,hid)); + std::map, myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit, hid)); if (itr2 == tmpMap.end()) { myInfo info; - tmpMap[std::pair(algoBit,hid)] = info; - itr2 = tmpMap.find(std::pair(algoBit,hid)); + tmpMap[std::pair(algoBit, hid)] = info; + itr2 = tmpMap.find(std::pair(algoBit, hid)); } itr2->second.theNS0++; itr2->second.theNS1 += energyhit; - itr2->second.theNS2 += (energyhit*energyhit); - itr2->second.theNS3 += (energyhit*energyhit*energyhit); - itr2->second.theNS4 += (energyhit*energyhit*energyhit*energyhit); + itr2->second.theNS2 += (energyhit * energyhit); + itr2->second.theNS3 += (energyhit * energyhit * energyhit); + itr2->second.theNS4 += (energyhit * energyhit * energyhit * energyhit); itr2->second.runcheck = rnnum; - - } // HBHE_NS - - // Signal part for HB HE - - for (HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); - hbheItr!=HithbheMB.end(); hbheItr++) { + + } // HBHE_NS + + // Signal part for HB HE + + for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if (theRecalib_) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); + if (theRecalib_) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); double energyhit = aHit.energy(); - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); - std::map,myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit,hid)); - + + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + std::map, myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit, hid)); + std::map, myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit, hid)); + if (itr1 == myMap_.end()) { myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); - } + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); + } itr1->second.theMB0++; itr1->second.theDif0 = 0; itr1->second.theMB1 += energyhit; - itr1->second.theMB2 += (energyhit*energyhit); - itr1->second.theMB3 += (energyhit*energyhit*energyhit); - itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit); + itr1->second.theMB2 += (energyhit * energyhit); + itr1->second.theMB3 += (energyhit * energyhit * energyhit); + itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit); itr1->second.runcheck = rnnum; float mydiff = 0.0; - if (itr2 !=tmpMap.end()) { + if (itr2 != tmpMap.end()) { mydiff = energyhit - (itr2->second.theNS1); itr1->second.theDif0++; itr1->second.theDif1 += mydiff; - itr1->second.theDif2 += (mydiff*mydiff); - if (fill) h_Signal[hid.subdet()-1]->Fill(mydiff); + itr1->second.theDif2 += (mydiff * mydiff); + if (fill) + h_Signal[hid.subdet() - 1]->Fill(mydiff); } - } // HBHE_MB - - // HF - - for (HFRecHitCollection::const_iterator hbheItr=HithfNS.begin(); - hbheItr!=HithfNS.end(); hbheItr++) { + } // HBHE_MB + + // HF + + for (HFRecHitCollection::const_iterator hbheItr = HithfNS.begin(); hbheItr != HithfNS.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if (theRecalib_) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); + if (theRecalib_) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); double energyhit = aHit.energy(); // Remove PMT hits - if(fabs(energyhit) > 40. ) continue; - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); - + if (fabs(energyhit) > 40.) + continue; + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + std::map, myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit, hid)); + if (itr1 == myMap_.end()) { myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); - } + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); + } itr1->second.theNS0++; itr1->second.theNS1 += energyhit; - itr1->second.theNS2 += (energyhit*energyhit); - itr1->second.theNS3 += (energyhit*energyhit*energyhit); - itr1->second.theNS4 += (energyhit*energyhit*energyhit*energyhit); + itr1->second.theNS2 += (energyhit * energyhit); + itr1->second.theNS3 += (energyhit * energyhit * energyhit); + itr1->second.theNS4 += (energyhit * energyhit * energyhit * energyhit); itr1->second.runcheck = rnnum; - if (fill) h_Noise[hid.subdet()-1]->Fill(energyhit); - - std::map,myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit,hid)); + if (fill) + h_Noise[hid.subdet() - 1]->Fill(energyhit); + + std::map, myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit, hid)); if (itr2 == tmpMap.end()) { myInfo info; - tmpMap[std::pair(algoBit,hid)] = info; - itr2 = tmpMap.find(std::pair(algoBit,hid)); + tmpMap[std::pair(algoBit, hid)] = info; + itr2 = tmpMap.find(std::pair(algoBit, hid)); } itr2->second.theNS0++; itr2->second.theNS1 += energyhit; - itr2->second.theNS2 += (energyhit*energyhit); - itr2->second.theNS3 += (energyhit*energyhit*energyhit); - itr2->second.theNS4 += (energyhit*energyhit*energyhit*energyhit); + itr2->second.theNS2 += (energyhit * energyhit); + itr2->second.theNS3 += (energyhit * energyhit * energyhit); + itr2->second.theNS4 += (energyhit * energyhit * energyhit * energyhit); itr2->second.runcheck = rnnum; - - } // HF_NS - - - // Signal part for HF - - for (HFRecHitCollection::const_iterator hbheItr=HithfMB.begin(); - hbheItr!=HithfMB.end(); hbheItr++) { + + } // HF_NS + + // Signal part for HF + + for (HFRecHitCollection::const_iterator hbheItr = HithfMB.begin(); hbheItr != HithfMB.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if (theRecalib_) icalconst=myRecalib->getValues(mydetid)->getValue(); - HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); - + if (theRecalib_) + icalconst = myRecalib->getValues(mydetid)->getValue(); + HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); + double energyhit = aHit.energy(); // Remove PMT hits - if(fabs(energyhit) > 40. ) continue; - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); - std::map,myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit,hid)); - + if (fabs(energyhit) > 40.) + continue; + + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + std::map, myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit, hid)); + std::map, myInfo>::iterator itr2 = tmpMap.find(std::pair(algoBit, hid)); + if (itr1 == myMap_.end()) { myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); } itr1->second.theMB0++; itr1->second.theDif0 = 0; itr1->second.theMB1 += energyhit; - itr1->second.theMB2 += (energyhit*energyhit); - itr1->second.theMB3 += (energyhit*energyhit*energyhit); - itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit); + itr1->second.theMB2 += (energyhit * energyhit); + itr1->second.theMB3 += (energyhit * energyhit * energyhit); + itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit); itr1->second.runcheck = rnnum; float mydiff = 0.0; - if (itr2 !=tmpMap.end()) { + if (itr2 != tmpMap.end()) { mydiff = energyhit - (itr2->second.theNS1); itr1->second.theDif0++; itr1->second.theDif1 += mydiff; - itr1->second.theDif2 += (mydiff*mydiff); - if (fill) h_Signal[hid.subdet()-1]->Fill(mydiff); + itr1->second.theDif2 += (mydiff * mydiff); + if (fill) + h_Signal[hid.subdet() - 1]->Fill(mydiff); } } } -//define this as a plug-in +//define this as a plug-in #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(AnalyzerMinbias); diff --git a/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.cc b/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.cc index 8e9c6b286ffa8..034cf4c2b4f1a 100644 --- a/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.cc +++ b/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.cc @@ -39,290 +39,277 @@ // // constructors and destructor // -namespace cms{ +namespace cms { Analyzer_minbias::Analyzer_minbias(const edm::ParameterSet& iConfig) { - usesResource(TFileService::kSharedResource); // get name of output file with histogramms - fOutputFileName = iConfig.getUntrackedParameter("HistOutFile"); + fOutputFileName = iConfig.getUntrackedParameter("HistOutFile"); // get names of modules, producing object collections - + tok_hbhe_ = consumes(iConfig.getParameter("hbheInputMB")); - tok_ho_ = consumes(iConfig.getParameter("hoInputMB")); - tok_hf_ = consumes(iConfig.getParameter("hfInputMB")); - tok_data_ = consumes(edm::InputTag(iConfig.getParameter("InputLabel") )); - + tok_ho_ = consumes(iConfig.getParameter("hoInputMB")); + tok_hf_ = consumes(iConfig.getParameter("hfInputMB")); + tok_data_ = consumes(edm::InputTag(iConfig.getParameter("InputLabel"))); + tok_hbheNoise_ = consumes(iConfig.getParameter("hbheInputNoise")); - tok_hoNoise_ = consumes(iConfig.getParameter("hoInputNoise")); - tok_hfNoise_ = consumes(iConfig.getParameter("hfInputNoise")); + tok_hoNoise_ = consumes(iConfig.getParameter("hoInputNoise")); + tok_hfNoise_ = consumes(iConfig.getParameter("hfInputNoise")); // this was hardcodded.. tok_gtRec_ = consumes(edm::InputTag("gtDigisAlCaMB")); tok_hbheNorm_ = consumes(edm::InputTag("hbhereco")); - - theRecalib = iConfig.getParameter("Recalib"); - + + theRecalib = iConfig.getParameter("Recalib"); + // // - for(int i=0; i<73; i++) { - for(int j=0; j<43; j++) { + for (int i = 0; i < 73; i++) { + for (int j = 0; j < 43; j++) { noise_min[i][j] = 0.; - noise_pl[i][j] = 0.; - } + noise_pl[i][j] = 0.; + } } // // - } Analyzer_minbias::~Analyzer_minbias() { - // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) - } - void Analyzer_minbias::beginRun( const edm::Run& r, const edm::EventSetup& iSetup) { - nevent_run = 0; - } - void Analyzer_minbias::endRun( const edm::Run& r, const edm::EventSetup& iSetup) { - edm::LogInfo("AnalyzerMB")<<" Runnumber "<make("RecJet","RecJet Tree"); - myTree->Branch("mydet", &mydet, "mydet/I"); - myTree->Branch("mysubd", &mysubd, "mysubd/I"); - myTree->Branch("depth", &depth, "depth/I"); - myTree->Branch("ieta", &ieta, "ieta/I"); - myTree->Branch("iphi", &iphi, "iphi/I"); - myTree->Branch("eta", &eta, "eta/F"); - myTree->Branch("phi", &phi, "phi/F"); - - myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); - myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); - myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); - myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); - - myTree->Branch("mom0_Noise", &mom0_Noise, "mom0_Noise/F"); - myTree->Branch("mom1_Noise", &mom1_Noise, "mom1_Noise/F"); - myTree->Branch("mom2_Noise", &mom2_Noise, "mom2_Noise/F"); - myTree->Branch("mom4_Noise", &mom4_Noise, "mom4_Noise/F"); - - myTree->Branch("mom0_Diff", &mom0_Diff, "mom0_Diff/F"); - myTree->Branch("mom1_Diff", &mom1_Diff, "mom1_Diff/F"); - myTree->Branch("mom2_Diff", &mom2_Diff, "mom2_Diff/F"); + // hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ; + myTree = fs->make("RecJet", "RecJet Tree"); + myTree->Branch("mydet", &mydet, "mydet/I"); + myTree->Branch("mysubd", &mysubd, "mysubd/I"); + myTree->Branch("depth", &depth, "depth/I"); + myTree->Branch("ieta", &ieta, "ieta/I"); + myTree->Branch("iphi", &iphi, "iphi/I"); + myTree->Branch("eta", &eta, "eta/F"); + myTree->Branch("phi", &phi, "phi/F"); + + myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); + myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); + myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); + myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); + + myTree->Branch("mom0_Noise", &mom0_Noise, "mom0_Noise/F"); + myTree->Branch("mom1_Noise", &mom1_Noise, "mom1_Noise/F"); + myTree->Branch("mom2_Noise", &mom2_Noise, "mom2_Noise/F"); + myTree->Branch("mom4_Noise", &mom4_Noise, "mom4_Noise/F"); + + myTree->Branch("mom0_Diff", &mom0_Diff, "mom0_Diff/F"); + myTree->Branch("mom1_Diff", &mom1_Diff, "mom1_Diff/F"); + myTree->Branch("mom2_Diff", &mom2_Diff, "mom2_Diff/F"); + + myTree->Branch("occup", &occup, "occup/F"); + + edm::LogInfo("AnalyzerMB") << " Before ordering Histos "; - myTree->Branch("occup", &occup, "occup/F"); - - edm::LogInfo("AnalyzerMB")<<" Before ordering Histos "; - char str0[15]; char str1[15]; - + char str10[15]; char str11[15]; - int k=0; + int k = 0; nevent = 0; // Size of collections - hHBHEsize_vs_run = fs->make("hHBHEsize_vs_run","hHBHEsize_vs_run",500,111500.,112000.,6101,-100.5,6000.5); - hHFsize_vs_run = fs->make("hHFsize_vs_run","hHFsize_vs_run",500,111500.,112000.,6101,-100.5,6000.5); - - for(int i=1;i<73;i++){ - for(int j=1;j<43;j++){ - - meannoise_pl[i][j] = 0.; - meannoise_min[i][j] = 0.; - - // for(int l=1;l<5;l++){ - k = i*1000+j; - sprintf(str0,"mpl%d",k); - sprintf(str1,"mmin%d",k); - - sprintf(str10,"vpl%d",k); - sprintf(str11,"vmin%d",k); - // edm::LogInfo("AnalyzerMB")<<" "<make(str0, "h0", 320, -10., 10.); - hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); - - // second order moment - hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 20.); - hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 20.); - } else { - // HF - // first order moment - // edm::LogInfo("AnalyzerMB")<<" "<make(str0, "h0", 320, -10., 10.); - hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); - // - // second order moment - hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 40.); - hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 40.); - } else { - hCalo1[i][j] = fs->make(str0,"h0" , 320, -10., 10.); - hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); - - // second order moment - hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 120.); - hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 120.); - - } - } // HE/HF boundary - // } // l - } // j - } // i - - - hbheNoiseE = fs->make("hbheNoiseE","hbheNoiseE", 320, -10., 10.); - hfNoiseE = fs->make("hfNoiseE","hfNoiseE", 320, -10., 10.); - hbheSignalE = fs->make("hbheSignalE","hbheSignalE", 320, -10., 10.); - hfSignalE = fs->make("hfSignalE","hfSignalE", 320, -10., 10.); - - - edm::LogInfo("AnalyzerMB")<<" After ordering Histos "; + hHBHEsize_vs_run = + fs->make("hHBHEsize_vs_run", "hHBHEsize_vs_run", 500, 111500., 112000., 6101, -100.5, 6000.5); + hHFsize_vs_run = fs->make("hHFsize_vs_run", "hHFsize_vs_run", 500, 111500., 112000., 6101, -100.5, 6000.5); + + for (int i = 1; i < 73; i++) { + for (int j = 1; j < 43; j++) { + meannoise_pl[i][j] = 0.; + meannoise_min[i][j] = 0.; + + // for(int l=1;l<5;l++){ + k = i * 1000 + j; + sprintf(str0, "mpl%d", k); + sprintf(str1, "mmin%d", k); + + sprintf(str10, "vpl%d", k); + sprintf(str11, "vmin%d", k); + // edm::LogInfo("AnalyzerMB")<<" "<make(str0, "h0", 320, -10., 10.); + hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); + + // second order moment + hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 20.); + hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 20.); + } else { + // HF + // first order moment + // edm::LogInfo("AnalyzerMB")<<" "<make(str0, "h0", 320, -10., 10.); + hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); + // + // second order moment + hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 40.); + hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 40.); + } else { + hCalo1[i][j] = fs->make(str0, "h0", 320, -10., 10.); + hCalo2[i][j] = fs->make(str1, "h1", 320, -10., 10.); + + // second order moment + hCalo1mom2[i][j] = fs->make(str10, "h10", 320, 0., 120.); + hCalo2mom2[i][j] = fs->make(str11, "h11", 320, 0., 120.); + } + } // HE/HF boundary + // } // l + } // j + } // i + + hbheNoiseE = fs->make("hbheNoiseE", "hbheNoiseE", 320, -10., 10.); + hfNoiseE = fs->make("hfNoiseE", "hfNoiseE", 320, -10., 10.); + hbheSignalE = fs->make("hbheSignalE", "hbheSignalE", 320, -10., 10.); + hfSignalE = fs->make("hfSignalE", "hfSignalE", 320, -10., 10.); + + edm::LogInfo("AnalyzerMB") << " After ordering Histos "; std::string ccc = "noise_0.dat"; myout_hcal = new std::ofstream(ccc.c_str()); - if(!myout_hcal) edm::LogInfo("AnalyzerMB") << " Output file not open!!! "; + if (!myout_hcal) + edm::LogInfo("AnalyzerMB") << " Output file not open!!! "; // - for (int i=0; i<5;i++) { - for (int j=0; j<5;j++) { - for (int k=0; k<73;k++) { - for (int l=0; l<43;l++) { - theMBFillDetMapPl0[i][j][k][l] = 0.; - theMBFillDetMapPl1[i][j][k][l] = 0.; - theMBFillDetMapPl2[i][j][k][l] = 0.; - theMBFillDetMapPl4[i][j][k][l] = 0.; - - theMBFillDetMapMin0[i][j][k][l] = 0.; - theMBFillDetMapMin1[i][j][k][l] = 0.; - theMBFillDetMapMin2[i][j][k][l] = 0.; - theMBFillDetMapMin4[i][j][k][l] = 0.; - - - theNSFillDetMapPl0[i][j][k][l] = 0.; - theNSFillDetMapPl1[i][j][k][l] = 0.; - theNSFillDetMapPl2[i][j][k][l] = 0.; - theNSFillDetMapPl4[i][j][k][l] = 0.; - - theNSFillDetMapMin0[i][j][k][l] = 0.; - theNSFillDetMapMin1[i][j][k][l] = 0.; - theNSFillDetMapMin2[i][j][k][l] = 0.; - theNSFillDetMapMin4[i][j][k][l] = 0.; - - theDFFillDetMapPl0[i][j][k][l] = 0.; - theDFFillDetMapPl1[i][j][k][l] = 0.; - theDFFillDetMapPl2[i][j][k][l] = 0.; - theDFFillDetMapMin0[i][j][k][l] = 0.; - theDFFillDetMapMin1[i][j][k][l] = 0.; - theDFFillDetMapMin2[i][j][k][l] = 0.; - } - } + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 73; k++) { + for (int l = 0; l < 43; l++) { + theMBFillDetMapPl0[i][j][k][l] = 0.; + theMBFillDetMapPl1[i][j][k][l] = 0.; + theMBFillDetMapPl2[i][j][k][l] = 0.; + theMBFillDetMapPl4[i][j][k][l] = 0.; + + theMBFillDetMapMin0[i][j][k][l] = 0.; + theMBFillDetMapMin1[i][j][k][l] = 0.; + theMBFillDetMapMin2[i][j][k][l] = 0.; + theMBFillDetMapMin4[i][j][k][l] = 0.; + + theNSFillDetMapPl0[i][j][k][l] = 0.; + theNSFillDetMapPl1[i][j][k][l] = 0.; + theNSFillDetMapPl2[i][j][k][l] = 0.; + theNSFillDetMapPl4[i][j][k][l] = 0.; + + theNSFillDetMapMin0[i][j][k][l] = 0.; + theNSFillDetMapMin1[i][j][k][l] = 0.; + theNSFillDetMapMin2[i][j][k][l] = 0.; + theNSFillDetMapMin4[i][j][k][l] = 0.; + + theDFFillDetMapPl0[i][j][k][l] = 0.; + theDFFillDetMapPl1[i][j][k][l] = 0.; + theDFFillDetMapPl2[i][j][k][l] = 0.; + theDFFillDetMapMin0[i][j][k][l] = 0.; + theDFFillDetMapMin1[i][j][k][l] = 0.; + theDFFillDetMapMin2[i][j][k][l] = 0.; + } + } } - } - - return ; + } + + return; } // // EndJob // void Analyzer_minbias::endJob() { - int ii=0; - - for (int i=1; i<5;i++) { - for (int j=1; j<5;j++) { - for (int k=1; k<73;k++) { - for (int l=1; l<43;l++) { - if(theMBFillDetMapPl0[i][j][k][l] > 0) { - mom0_MB = theMBFillDetMapPl0[i][j][k][l]; - mom1_MB = theMBFillDetMapPl1[i][j][k][l]; - mom2_MB = theMBFillDetMapPl2[i][j][k][l]; - mom4_MB = theMBFillDetMapPl4[i][j][k][l]; - mom0_Noise = theNSFillDetMapPl0[i][j][k][l]; - mom1_Noise = theNSFillDetMapPl1[i][j][k][l]; - mom2_Noise = theNSFillDetMapPl2[i][j][k][l]; - mom4_Noise = theNSFillDetMapPl4[i][j][k][l]; - mom0_Diff = theDFFillDetMapPl0[i][j][k][l]; - mom1_Diff = theDFFillDetMapPl1[i][j][k][l]; - mom2_Diff = theDFFillDetMapPl2[i][j][k][l]; - - mysubd = i; - depth = j; - ieta = l; - iphi = k; - edm::LogInfo("AnalyzerMB")<<" Result Plus= "<Fill(); - ii++; - } // Pl > 0 - - - if(theMBFillDetMapMin0[i][j][k][l] > 0) { - mom0_MB = theMBFillDetMapMin0[i][j][k][l]; - mom1_MB = theMBFillDetMapMin1[i][j][k][l]; - mom2_MB = theMBFillDetMapMin2[i][j][k][l]; - mom4_MB = theMBFillDetMapMin4[i][j][k][l]; - mom0_Noise = theNSFillDetMapMin0[i][j][k][l]; - mom1_Noise = theNSFillDetMapMin1[i][j][k][l]; - mom2_Noise = theNSFillDetMapMin2[i][j][k][l]; - mom4_Noise = theNSFillDetMapMin4[i][j][k][l]; - mom0_Diff = theDFFillDetMapMin0[i][j][k][l]; - mom1_Diff = theDFFillDetMapMin1[i][j][k][l]; - mom2_Diff = theDFFillDetMapMin2[i][j][k][l]; - - - mysubd = i; - depth = j; - ieta = -1*l; - iphi = k; - edm::LogInfo("AnalyzerMB")<<" Result Minus= "<Fill(); - ii++; - - } // Min>0 - } // ieta - } // iphi - } // depth - } //subd - - - - edm::LogInfo("AnalyzerMB")<<" Number of cells "<Write(); -// hOutputFile->cd(); -// myTree->Write(); -// hHBHEsize_vs_run->Write() ; -// hHFsize_vs_run->Write() ; - - for(int i=1;i<73;i++){ - for(int j=1;j<43;j++){ - hCalo1[i][j]->Write(); - hCalo2[i][j]->Write(); - hCalo1mom2[i][j]->Write(); - hCalo2mom2[i][j]->Write(); + int ii = 0; + + for (int i = 1; i < 5; i++) { + for (int j = 1; j < 5; j++) { + for (int k = 1; k < 73; k++) { + for (int l = 1; l < 43; l++) { + if (theMBFillDetMapPl0[i][j][k][l] > 0) { + mom0_MB = theMBFillDetMapPl0[i][j][k][l]; + mom1_MB = theMBFillDetMapPl1[i][j][k][l]; + mom2_MB = theMBFillDetMapPl2[i][j][k][l]; + mom4_MB = theMBFillDetMapPl4[i][j][k][l]; + mom0_Noise = theNSFillDetMapPl0[i][j][k][l]; + mom1_Noise = theNSFillDetMapPl1[i][j][k][l]; + mom2_Noise = theNSFillDetMapPl2[i][j][k][l]; + mom4_Noise = theNSFillDetMapPl4[i][j][k][l]; + mom0_Diff = theDFFillDetMapPl0[i][j][k][l]; + mom1_Diff = theDFFillDetMapPl1[i][j][k][l]; + mom2_Diff = theDFFillDetMapPl2[i][j][k][l]; + + mysubd = i; + depth = j; + ieta = l; + iphi = k; + edm::LogInfo("AnalyzerMB") << " Result Plus= " << mysubd << " " << ieta << " " << iphi << " mom0 " + << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB; + myTree->Fill(); + ii++; + } // Pl > 0 + + if (theMBFillDetMapMin0[i][j][k][l] > 0) { + mom0_MB = theMBFillDetMapMin0[i][j][k][l]; + mom1_MB = theMBFillDetMapMin1[i][j][k][l]; + mom2_MB = theMBFillDetMapMin2[i][j][k][l]; + mom4_MB = theMBFillDetMapMin4[i][j][k][l]; + mom0_Noise = theNSFillDetMapMin0[i][j][k][l]; + mom1_Noise = theNSFillDetMapMin1[i][j][k][l]; + mom2_Noise = theNSFillDetMapMin2[i][j][k][l]; + mom4_Noise = theNSFillDetMapMin4[i][j][k][l]; + mom0_Diff = theDFFillDetMapMin0[i][j][k][l]; + mom1_Diff = theDFFillDetMapMin1[i][j][k][l]; + mom2_Diff = theDFFillDetMapMin2[i][j][k][l]; + + mysubd = i; + depth = j; + ieta = -1 * l; + iphi = k; + edm::LogInfo("AnalyzerMB") << " Result Minus= " << mysubd << " " << ieta << " " << iphi << " mom0 " + << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB; + myTree->Fill(); + ii++; + + } // Min>0 + } // ieta + } // iphi + } // depth + } //subd + + edm::LogInfo("AnalyzerMB") << " Number of cells " << ii; + + // hOutputFile->Write(); + // hOutputFile->cd(); + // myTree->Write(); + // hHBHEsize_vs_run->Write() ; + // hHFsize_vs_run->Write() ; + + for (int i = 1; i < 73; i++) { + for (int j = 1; j < 43; j++) { + hCalo1[i][j]->Write(); + hCalo2[i][j]->Write(); + hCalo1mom2[i][j]->Write(); + hCalo2mom2[i][j]->Write(); } } -// hbheNoiseE->Write() ; -// hfNoiseE->Write() ; -// hbheSignalE->Write() ; -// hfSignalE->Write() ; -// hOutputFile->Close() ; - - edm::LogInfo("AnalyzerMB")<<" File is closed "; - - return ; - } + // hbheNoiseE->Write() ; + // hfNoiseE->Write() ; + // hbheSignalE->Write() ; + // hfSignalE->Write() ; + // hOutputFile->Close() ; + edm::LogInfo("AnalyzerMB") << " File is closed "; + + return; + } // // member functions @@ -330,21 +317,19 @@ namespace cms{ // ------------ method called to produce the data ------------ void Analyzer_minbias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - - edm::LogInfo("AnalyzerMB")<<" Start Analyzer_minbias::analyze "< theProvenance; iEvent.getAllStableProvenance(theProvenance); - for(auto const& provenance : theProvenance) { - edm::LogInfo("AnalyzerMB")<<" Print all process/modulelabel/product names " - <processName()<<" , "<moduleLabel()<<" , " - <productInstanceName(); + for (auto const& provenance : theProvenance) { + edm::LogInfo("AnalyzerMB") << " Print all process/modulelabel/product names " << provenance->processName() + << " , " << provenance->moduleLabel() << " , " << provenance->productInstanceName(); } /* edm::Handle rawdata; @@ -395,7 +380,6 @@ namespace cms{ */ - // Geometry // edm::ESHandle pG; // iSetup.get().get(pG); @@ -429,338 +413,360 @@ namespace cms{ } */ - const HcalRespCorrs* myRecalib=nullptr; - if( theRecalib ) { - // Radek: - edm::ESHandle recalibCorrs; - iSetup.get().get("recalibrate",recalibCorrs); + const HcalRespCorrs* myRecalib = nullptr; + if (theRecalib) { + // Radek: + edm::ESHandle recalibCorrs; + iSetup.get().get("recalibrate", recalibCorrs); myRecalib = recalibCorrs.product(); // end - } // theRecalib + } // theRecalib // Noise part for HB HE - double tmpNSFillDetMapPl1[5][5][73][43]; - double tmpNSFillDetMapMin1[5][5][73][43]; - - for (int i=0; i<5;i++) { - for (int j=0; j<5;j++) { - for (int k=0; k<73;k++) { - for (int l=0; l<43;l++) { - tmpNSFillDetMapPl1[i][j][k][l] = 0.; - tmpNSFillDetMapMin1[i][j][k][l] = 0.; - } - } + double tmpNSFillDetMapPl1[5][5][73][43]; + double tmpNSFillDetMapMin1[5][5][73][43]; + + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 73; k++) { + for (int l = 0; l < 43; l++) { + tmpNSFillDetMapPl1[i][j][k][l] = 0.; + tmpNSFillDetMapMin1[i][j][k][l] = 0.; + } + } } } - + edm::Handle hbheNormal; iEvent.getByToken(tok_hbheNorm_, hbheNormal); - if(!hbheNormal.isValid()){ - edm::LogWarning("AnalyzerMB")<<" hbheNormal failed "; + if (!hbheNormal.isValid()) { + edm::LogWarning("AnalyzerMB") << " hbheNormal failed "; } else { - edm::LogInfo("AnalyzerMB")<<" The size of the normal collection "<size(); - } - + edm::LogInfo("AnalyzerMB") << " The size of the normal collection " << hbheNormal->size(); + } edm::Handle hbheNS; iEvent.getByToken(tok_hbheNoise_, hbheNS); - - if(!hbheNS.isValid()){ + if (!hbheNS.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbhe" - << " product! No HBHE MS "; - return ; + << " product! No HBHE MS "; + return; } - const HBHERecHitCollection HithbheNS = *(hbheNS.product()); - edm::LogInfo("AnalyzerMB")<<" HBHE NS size of collection "<Fill(rnnum,(float)HithbheNS.size()); + edm::LogInfo("AnalyzerMB") << " HBHE NS size of collection " << HithbheNS.size(); + hHBHEsize_vs_run->Fill(rnnum, (float)HithbheNS.size()); - if(HithbheNS.size()!= 5184) { - edm::LogWarning("AnalyzerMB")<<" HBHE problem "< hbheMB; iEvent.getByToken(tok_hbhe_, hbheMB); - if(!hbheMB.isValid()){ - edm::LogWarning("AnalyzerMB")<< "HcalCalibAlgos: Error! can't get hbhe" - << " product! No HBHE MB"; + if (!hbheMB.isValid()) { + edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hbhe" + << " product! No HBHE MB"; // return ; } const HBHERecHitCollection HithbheMB = *(hbheMB.product()); - edm::LogInfo("AnalyzerMB")<<" HBHE MB size of collection "< hfNS; iEvent.getByToken(tok_hfNoise_, hfNS); - if(!hfNS.isValid()){ + if (!hfNS.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hf" - << " product! No HF NS "; + << " product! No HF NS "; // return ; } const HFRecHitCollection HithfNS = *(hfNS.product()); - edm::LogInfo("AnalyzerMB")<<" HFE NS size of collection "<Fill(rnnum,(float)HithfNS.size()); - if(HithfNS.size()!= 1728) { - edm::LogWarning("AnalyzerMB")<<" HF problem "<Fill(rnnum, (float)HithfNS.size()); + if (HithfNS.size() != 1728) { + edm::LogWarning("AnalyzerMB") << " HF problem " << rnnum << " " << HithfNS.size(); // return; } edm::Handle hfMB; iEvent.getByToken(tok_hf_, hfMB); - if(!hfMB.isValid()){ + if (!hfMB.isValid()) { edm::LogWarning("AnalyzerMB") << "HcalCalibAlgos: Error! can't get hf" - << " product! No HF MB"; + << " product! No HF MB"; // return ; } const HFRecHitCollection HithfMB = *(hfMB.product()); - edm::LogInfo("AnalyzerMB")<<" HF MB size of collection "<id().rawId(); - if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); - + if (theRecalib) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); + double energyhit = aHit.energy(); - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - - - int mysu = ((hid).rawId()>>25)&0x7; - if( hid.ieta() > 0 ) { - theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.; - theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit; - theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2); - theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4); - - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; - - + + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + int mysu = ((hid).rawId() >> 25) & 0x7; + if (hid.ieta() > 0) { + theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.; + theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit; + theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2); + theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4); + + tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; + } else { - theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.; - theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit; - theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2); - theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4); - - - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; - - } - - if(hid.depth() == 1) { - hbheNoiseE->Fill(energyhit); - - if(energyhit<-2.) edm::LogInfo("AnalyzerMB")<<" Run "< 0 ) { - // hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]); - // hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); - // } else { - // hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]); - // hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); - // } // eta><0 - - } // depth=1 - - - } // HBHE_NS + theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.; + theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit; + theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2); + theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4); + + tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; + } + + if (hid.depth() == 1) { + hbheNoiseE->Fill(energyhit); + + if (energyhit < -2.) + edm::LogInfo("AnalyzerMB") << " Run " << rnnum << " ieta,iphi " << hid.ieta() << " " << hid.iphi() + << energyhit; + // if( hid.ieta() > 0 ) { + // hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]); + // hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); + // } else { + // hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]); + // hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); + // } // eta><0 + + } // depth=1 + + } // HBHE_NS // Signal part for HB HE - - for(HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); hbheItr!=HithbheMB.end(); hbheItr++) { + for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); - + if (theRecalib) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); + double energyhit = aHit.energy(); - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - int mysu = ((hid).rawId()>>25)&0x7; - if( hid.ieta() > 0 ) { - theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] += 1.; - theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] += energyhit; - theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit,2); - theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit,4); - float mydiff = energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; - - - theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+mydiff; - theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(mydiff,2); + + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + int mysu = ((hid).rawId() >> 25) & 0x7; + if (hid.ieta() > 0) { + theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] += 1.; + theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] += energyhit; + theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit, 2); + theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] += pow(energyhit, 4); + float mydiff = energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; + + theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + mydiff; + theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(mydiff, 2); } else { - theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.; - theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit; - theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2); - theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4); - - - float mydiff = energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; - theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+mydiff; - theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(mydiff,2); - } - - - if(hid.depth() == 1) { - - hbheSignalE->Fill(energyhit); - - if( hid.ieta() > 0 ) { - hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit); - hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); - } else { - hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit); - hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); - } // eta><0 - - } // depth=1 - - - } // HBHE_MB - + theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.; + theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit; + theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2); + theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4); + + float mydiff = energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; + theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + mydiff; + theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(mydiff, 2); + } + + if (hid.depth() == 1) { + hbheSignalE->Fill(energyhit); + + if (hid.ieta() > 0) { + hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit); + hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit, 2)); + } else { + hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit); + hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit, 2)); + } // eta><0 + + } // depth=1 + + } // HBHE_MB + // HF - - for(HFRecHitCollection::const_iterator hbheItr=HithfNS.begin(); hbheItr!=HithfNS.end(); hbheItr++) { + + for (HFRecHitCollection::const_iterator hbheItr = HithfNS.begin(); hbheItr != HithfNS.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); - + if (theRecalib) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); + double energyhit = aHit.energy(); // // Remove PMT hits - // + // DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - if(fabs(energyhit) > 40. ) continue; - + HcalDetId hid = HcalDetId(id); + + if (fabs(energyhit) > 40.) + continue; + int mysu = hid.subdetId(); - if( hid.ieta() > 0 ) { - theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.; - theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit; - theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2); - theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4); - - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; - - + if (hid.ieta() > 0) { + theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.; + theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit; + theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2); + theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4); + + tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; + } else { - theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.; - theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit; - theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2); - theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4); + theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.; + theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit; + theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2); + theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4); + + tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; + } - - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit; - - } - - if(hid.depth() == 1) { - hfNoiseE->Fill(energyhit); - - //if( hid.ieta() > 0 ) { - // hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]); - // hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); - //} else { - // hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]); - // hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); - //} // eta><0 - - } // depth=1 - - } // HBHE_NS + if (hid.depth() == 1) { + hfNoiseE->Fill(energyhit); + //if( hid.ieta() > 0 ) { + // hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]); + // hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); + //} else { + // hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]); + // hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); + //} // eta><0 + + } // depth=1 + + } // HBHE_NS // Signal part for HB HE - for(HFRecHitCollection::const_iterator hbheItr=HithfMB.begin(); hbheItr!=HithfMB.end(); hbheItr++) { + for (HFRecHitCollection::const_iterator hbheItr = HithfMB.begin(); hbheItr != HithfMB.end(); hbheItr++) { // Recalibration of energy - float icalconst=1.; + float icalconst = 1.; DetId mydetid = hbheItr->id().rawId(); - if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue(); - - HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); - + if (theRecalib) + icalconst = myRecalib->getValues(mydetid)->getValue(); + + HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); + double energyhit = aHit.energy(); // // Remove PMT hits - // - if(fabs(energyhit) > 40. ) continue; - - DetId id = (*hbheItr).detid(); - HcalDetId hid=HcalDetId(id); - - int mysu = ((hid).rawId()>>25)&0x7; - if( hid.ieta() > 0 ) { - theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.; - theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit; - theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2); - theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4); - + // + if (fabs(energyhit) > 40.) + continue; - theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit-tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; - theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = - theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow((energyhit-tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]),2); + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + + int mysu = ((hid).rawId() >> 25) & 0x7; + if (hid.ieta() > 0) { + theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] + 1.; + theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit; + theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 2); + theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] + pow(energyhit, 4); + + theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit - + tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; + theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + + pow((energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]), 2); } else { - theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.; - theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit; - theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2); - theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4); - - theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit-tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; - theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = - theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow((energyhit-tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]),2); - } - - - if(hid.depth() == 1) { - hfSignalE->Fill(energyhit); - - if( hid.ieta() > 0 ) { - hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit); - hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2)); - } else { - hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit); - hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2)); - } // eta><0 - - } // depth=1 - - } // HF_MB + theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + 1.; + theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + energyhit; + theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 2); + theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = + theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] + pow(energyhit, 4); + + theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] + energyhit - + tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]; + theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = + theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] + + pow((energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]), 2); + } + + if (hid.depth() == 1) { + hfSignalE->Fill(energyhit); + + if (hid.ieta() > 0) { + hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit); + hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit, 2)); + } else { + hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit); + hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit, 2)); + } // eta><0 + + } // depth=1 + + } // HF_MB - edm::LogInfo("AnalyzerMB")<<" Event is finished "; + edm::LogInfo("AnalyzerMB") << " Event is finished "; } -} +} // namespace cms #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.h b/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.h index 2f39e224668bc..a7cd4735a16b0 100644 --- a/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.h +++ b/Calibration/HcalCalibAlgos/plugins/Analyzer_minbias.h @@ -55,8 +55,8 @@ // // class declaration // -namespace cms{ - class Analyzer_minbias : public edm::one::EDAnalyzer { +namespace cms { + class Analyzer_minbias : public edm::one::EDAnalyzer { public: explicit Analyzer_minbias(const edm::ParameterSet&); ~Analyzer_minbias() override; @@ -69,86 +69,84 @@ namespace cms{ private: // ----------member data --------------------------- - std::string fOutputFileName ; + std::string fOutputFileName; std::string hcalfile_; - std::ofstream *myout_hcal; + std::ofstream* myout_hcal; edm::EDGetTokenT tok_data_; - + // names of modules, producing object collections - edm::Service fs; - - TFile* hOutputFile ; - TTree* myTree; - TH1F* hCalo1[73][43]; - TH1F* hCalo2[73][43]; - TH1F* hCalo1mom2[73][43]; - TH1F* hCalo2mom2[73][43]; - TH1F* hbheNoiseE; - TH1F* hbheSignalE; - TH1F* hfNoiseE; - TH1F* hfSignalE; - - TH2F* hHBHEsize_vs_run; - TH2F* hHFsize_vs_run; + edm::Service fs; + + TFile* hOutputFile; + TTree* myTree; + TH1F* hCalo1[73][43]; + TH1F* hCalo2[73][43]; + TH1F* hCalo1mom2[73][43]; + TH1F* hCalo2mom2[73][43]; + TH1F* hbheNoiseE; + TH1F* hbheSignalE; + TH1F* hfNoiseE; + TH1F* hfSignalE; + + TH2F* hHBHEsize_vs_run; + TH2F* hHFsize_vs_run; // Root tree members - int nevent_run; + int nevent_run; int mydet, mysubd, depth, iphi, ieta; - float phi,eta; - float mom0_MB,mom1_MB,mom2_MB,mom3_MB,mom4_MB,occup; - float mom0_Noise,mom1_Noise,mom2_Noise,mom3_Noise,mom4_Noise; - float mom0_Diff,mom1_Diff,mom2_Diff,mom3_Diff,mom4_Diff; - + float phi, eta; + float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, occup; + float mom0_Noise, mom1_Noise, mom2_Noise, mom3_Noise, mom4_Noise; + float mom0_Diff, mom1_Diff, mom2_Diff, mom3_Diff, mom4_Diff; + // Noise subtraction - - double meannoise_pl[73][43],meannoise_min[73][43]; - double noise_pl[73][43],noise_min[73][43]; + + double meannoise_pl[73][43], meannoise_min[73][43]; + double noise_pl[73][43], noise_min[73][43]; // counters double nevent; - double theMBFillDetMapPl0[5][5][73][43]; - double theMBFillDetMapPl1[5][5][73][43]; + double theMBFillDetMapPl0[5][5][73][43]; + double theMBFillDetMapPl1[5][5][73][43]; double theMBFillDetMapPl2[5][5][73][43]; double theMBFillDetMapPl4[5][5][73][43]; - - double theMBFillDetMapMin0[5][5][73][43]; - double theMBFillDetMapMin1[5][5][73][43]; + + double theMBFillDetMapMin0[5][5][73][43]; + double theMBFillDetMapMin1[5][5][73][43]; double theMBFillDetMapMin2[5][5][73][43]; double theMBFillDetMapMin4[5][5][73][43]; - double theNSFillDetMapPl0[5][5][73][43]; - double theNSFillDetMapPl1[5][5][73][43]; + double theNSFillDetMapPl0[5][5][73][43]; + double theNSFillDetMapPl1[5][5][73][43]; double theNSFillDetMapPl2[5][5][73][43]; double theNSFillDetMapPl4[5][5][73][43]; - double theNSFillDetMapMin0[5][5][73][43]; - double theNSFillDetMapMin1[5][5][73][43]; + double theNSFillDetMapMin0[5][5][73][43]; + double theNSFillDetMapMin1[5][5][73][43]; double theNSFillDetMapMin2[5][5][73][43]; double theNSFillDetMapMin4[5][5][73][43]; - double theDFFillDetMapPl0[5][5][73][43]; - double theDFFillDetMapPl1[5][5][73][43]; + double theDFFillDetMapPl0[5][5][73][43]; + double theDFFillDetMapPl1[5][5][73][43]; double theDFFillDetMapPl2[5][5][73][43]; - double theDFFillDetMapMin0[5][5][73][43]; - double theDFFillDetMapMin1[5][5][73][43]; + double theDFFillDetMapMin0[5][5][73][43]; + double theDFFillDetMapMin1[5][5][73][43]; double theDFFillDetMapMin2[5][5][73][43]; - edm::EDGetTokenT tok_hbhe_; edm::EDGetTokenT tok_ho_; edm::EDGetTokenT tok_hf_; - - edm::EDGetTokenT tok_hbheNoise_; + + edm::EDGetTokenT tok_hbheNoise_; edm::EDGetTokenT tok_hoNoise_; edm::EDGetTokenT tok_hfNoise_; - // + // edm::EDGetTokenT tok_gtRec_; edm::EDGetTokenT tok_hbheNorm_; - - bool theRecalib; + bool theRecalib; }; -} +} // namespace cms #endif diff --git a/Calibration/HcalCalibAlgos/plugins/HOCalibAnalyzer.cc b/Calibration/HcalCalibAlgos/plugins/HOCalibAnalyzer.cc index c062fccc2ff76..441de65bc1554 100644 --- a/Calibration/HcalCalibAlgos/plugins/HOCalibAnalyzer.cc +++ b/Calibration/HcalCalibAlgos/plugins/HOCalibAnalyzer.cc @@ -3,7 +3,7 @@ // // Package: HOCalibAnalyzer // Class: HOCalibAnalyzer -// +// /**\class HOCalibAnalyzer HOCalibAnalyzer.cc Calibration/HOCalibAnalyzer/src/HOCalibAnalyzer.cc Description: @@ -22,7 +22,6 @@ April 2015 // // - // system include files #include @@ -62,139 +61,130 @@ April 2015 #include //#include +// +// Look for nearby pixel through eta, phi informations for pixel cross-talk +// 1. Look PIXEL code from (eta,phi) +// 2. Go to nearby pixel code +// 3. Come back to (eta,phi) from pixel code +// Though it works, it is a very ugly/crude way to get cross talk, need better algorithms +// - // - // Look for nearby pixel through eta, phi informations for pixel cross-talk - // 1. Look PIXEL code from (eta,phi) - // 2. Go to nearby pixel code - // 3. Come back to (eta,phi) from pixel code - // Though it works, it is a very ugly/crude way to get cross talk, need better algorithms - // - -static const int mapx1[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {19,18,17}}; +static const int mapx1[6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {19, 18, 17}}; -static const int mapx2[6][3]={{1,4,8}, {12,7,3}, {5,9,13}, {11,6,2}, {16,15,14}, {-1,-1,-1}}; +static const int mapx2[6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {-1, -1, -1}}; -static const int mapx0p[9][2]={{3,1}, {7,4}, {6,5}, {12,8}, {0,0}, {11,9}, {16,13}, {15,14}, {19,17}}; -static const int mapx0m[9][2]={{17,19}, {14,15}, {13,16}, {9,11}, {0,0}, {8,12}, {5,6}, {4,7}, {1,3}}; +static const int mapx0p[9][2] = {{3, 1}, {7, 4}, {6, 5}, {12, 8}, {0, 0}, {11, 9}, {16, 13}, {15, 14}, {19, 17}}; +static const int mapx0m[9][2] = {{17, 19}, {14, 15}, {13, 16}, {9, 11}, {0, 0}, {8, 12}, {5, 6}, {4, 7}, {1, 3}}; -static const int etamap[4][21]={{-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, -1,-1,-1, -1}, //etamap2 - {-1, 0,3,1, 0,2,3, 1,0,2, -1, 3,1,2, 4,4,4, 5,5,5, -1}, //etamap1 - {-1, 0,-1,0, 1,2,2, 1,3,5, -1, 5,3,6, 7,7,6, 8,-1,8, -1}, //etamap0p - {-1, 8,-1,8, 7,6,6, 7,5,3, -1, 3,5,2, 1,1,2, 0,-1,0, -1}}; //etamap0m +static const int etamap[4][21] = {{-1, 0, 3, 1, 0, 2, 3, 1, 0, 2, -1, 3, 1, 2, 4, 4, 4, -1, -1, -1, -1}, //etamap2 + {-1, 0, 3, 1, 0, 2, 3, 1, 0, 2, -1, 3, 1, 2, 4, 4, 4, 5, 5, 5, -1}, //etamap1 + {-1, 0, -1, 0, 1, 2, 2, 1, 3, 5, -1, 5, 3, 6, 7, 7, 6, 8, -1, 8, -1}, //etamap0p + {-1, 8, -1, 8, 7, 6, 6, 7, 5, 3, -1, 3, 5, 2, 1, 1, 2, 0, -1, 0, -1}}; //etamap0m -static const int phimap[4][21] ={{-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap2 - {-1, 0,2,2, 1,0,1, 1,2,1, -1, 0,0,2, 2,1,0, 2,1,0, -1}, //phimap1 - {-1, 1,-1,0, 1,1,0, 0,1,1, -1, 0,0,1, 1,0,0, 1,-1,0, -1}, //phimap0p - {-1, 0,-1,1, 0,0,1, 1,0,0, -1, 1,1,0, 0,1,1, 0,-1,1, -1}}; //phimap0m -//swapped phi map for R0+/R0- (15/03/07) +static const int phimap[4][21] = {{-1, 0, 2, 2, 1, 0, 1, 1, 2, 1, -1, 0, 0, 2, 2, 1, 0, 2, 1, 0, -1}, //phimap2 + {-1, 0, 2, 2, 1, 0, 1, 1, 2, 1, -1, 0, 0, 2, 2, 1, 0, 2, 1, 0, -1}, //phimap1 + {-1, 1, -1, 0, 1, 1, 0, 0, 1, 1, -1, 0, 0, 1, 1, 0, 0, 1, -1, 0, -1}, //phimap0p + {-1, 0, -1, 1, 0, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 1, 1, 0, -1, 1, -1}}; //phimap0m +//swapped phi map for R0+/R0- (15/03/07) -static const int npixleft[21]={0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0,11, 0,13,14,15, 0,17,18,0}; -static const int npixrigh[21]={0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0,12, 0,14,15,16, 0,18,19, 0,0}; -static const int npixlebt[21]={0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0,11,13,14,15,0}; -static const int npixribt[21]={0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0,11,12,14,15,16,0}; -static const int npixleup[21]={0, 4, 5, 6, 8, 9, 0,11, 0,13, 0,15,16, 0,17,18,19, 0, 0, 0,0}; -static const int npixriup[21]={0, 5, 6, 7, 9, 0,11,12,13,14, 0,16, 0,17,18,19, 0, 0, 0, 0,0}; +static const int npixleft[21] = {0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0, 11, 0, 13, 14, 15, 0, 17, 18, 0}; +static const int npixrigh[21] = {0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0, 12, 0, 14, 15, 16, 0, 18, 19, 0, 0}; +static const int npixlebt[21] = {0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0, 11, 13, 14, 15, 0}; +static const int npixribt[21] = {0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0, 11, 12, 14, 15, 16, 0}; +static const int npixleup[21] = {0, 4, 5, 6, 8, 9, 0, 11, 0, 13, 0, 15, 16, 0, 17, 18, 19, 0, 0, 0, 0}; +static const int npixriup[21] = {0, 5, 6, 7, 9, 0, 11, 12, 13, 14, 0, 16, 0, 17, 18, 19, 0, 0, 0, 0, 0}; -static const int netamx=30; -static const int nphimx =72; +static const int netamx = 30; +static const int nphimx = 72; static const int nbgpr = 3; static const int nsgpr = 7; int ietafit; int iphifit; -std::vectorsig_reg[netamx][nphimx+1]; -std::vectorcro_ssg[netamx][nphimx+1]; - +std::vector sig_reg[netamx][nphimx + 1]; +std::vector cro_ssg[netamx][nphimx + 1]; //#define CORREL // // class decleration // -Double_t gausX(Double_t* x, Double_t* par){ - return par[0]*(TMath::Gaus(x[0], par[1], par[2], kTRUE)); -} - -Double_t langaufun(Double_t *x, Double_t *par) { +Double_t gausX(Double_t* x, Double_t* par) { return par[0] * (TMath::Gaus(x[0], par[1], par[2], kTRUE)); } +Double_t langaufun(Double_t* x, Double_t* par) { //Fit parameters: //par[0]*par[1]=Width (scale) parameter of Landau density //par[1]=Most Probable (MP, location) parameter of Landau density //par[2]=Total area (integral -inf to inf, normalization constant) //par[3]=Width (sigma) of convoluted Gaussian function // - //In the Landau distribution (represented by the CERNLIB approximation), + //In the Landau distribution (represented by the CERNLIB approximation), //the maximum is located at x=-0.22278298 with the location parameter=0. //This shift is corrected within this function, so that the actual //maximum is identical to the MP parameter. // /* // Numeric constants - Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2) - Double_t mpshift = -0.22278298; // Landau maximum location - + Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2) + Double_t mpshift = -0.22278298; // Landau maximum location + // Control constants - Double_t np = 100.0; // number of convolution steps - Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas - + Double_t np = 100.0; // number of convolution steps + Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas + // Variables Double_t xx; Double_t mpc; Double_t fland; Double_t sum = 0.0; - Double_t xlow,xupp; + Double_t xlow, xupp; Double_t step; - + // MP shift correction - mpc = par[1] - mpshift * par[0]*par[1]; - + mpc = par[1] - mpshift * par[0] * par[1]; + // Range of convolution integral xlow = x[0] - sc * par[3]; xupp = x[0] + sc * par[3]; - - step = (xupp-xlow) / np; - + + step = (xupp - xlow) / np; + // Convolution integral of Landau and Gaussian by sum - for(double ij=1.0; ij<=np/2; ij++) { - xx = xlow + (ij-.5) * step; - fland = TMath::Landau(xx,mpc,par[0]*par[1], kTRUE); // / par[0]; - sum += fland * TMath::Gaus(x[0],xx,par[3]); - xx = xupp - (ij-.5) * step; - fland = TMath::Landau(xx,mpc,par[0]*par[1], kTRUE); // / par[0]; - sum += fland * TMath::Gaus(x[0],xx,par[3]); + for (double ij = 1.0; ij <= np / 2; ij++) { + xx = xlow + (ij - .5) * step; + fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE); // / par[0]; + sum += fland * TMath::Gaus(x[0], xx, par[3]); + xx = xupp - (ij - .5) * step; + fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE); // / par[0]; + sum += fland * TMath::Gaus(x[0], xx, par[3]); } - + return (par[2] * step * sum * invsq2pi / par[3]); } -Double_t totalfunc(Double_t* x, Double_t* par){ - return gausX(x, par) + langaufun(x, &par[3]); -} +Double_t totalfunc(Double_t* x, Double_t* par) { return gausX(x, par) + langaufun(x, &par[3]); } -void fcnbg(Int_t &npar, Double_t* gin, Double_t &f, Double_t* par, Int_t flag) { - +void fcnbg(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag) { double fval = -par[0]; - for (unsigned ij=0; ij tok_ho_; + edm::EDGetTokenT tok_ho_; edm::EDGetTokenT tok_allho_; - // ----------member data --------------------------- - + // ----------member data --------------------------- }; const int HOCalibAnalyzer::ringmx; @@ -454,15 +435,15 @@ const int HOCalibAnalyzer::neffip; // HOCalibAnalyzer::HOCalibAnalyzer(const edm::ParameterSet& iConfig) - // It is very likely you want the following in your configuration - // hoCalibVariableCollectionTag = cms.InputTag('hoCalibProducer', 'HOCalibVariableCollection') +// It is very likely you want the following in your configuration +// hoCalibVariableCollectionTag = cms.InputTag('hoCalibProducer', 'HOCalibVariableCollection') { - tok_ho_ = consumes(iConfig.getParameter("hoCalibVariableCollectionTag")); - tok_allho_ = consumes(iConfig.getParameter("hoInputTag")); - //now do what ever initialization is needed + tok_ho_ = consumes(iConfig.getParameter("hoCalibVariableCollectionTag")); + tok_allho_ = consumes(iConfig.getParameter("hoInputTag")); + //now do what ever initialization is needed ipass = 0; Nevents = 0; - + theRootFileName = iConfig.getUntrackedParameter("RootFileName", "test.root"); theoutputtxtFile = iConfig.getUntrackedParameter("txtFileName", "test.txt"); theoutputpsFile = iConfig.getUntrackedParameter("psFileName", "test.ps"); @@ -480,82 +461,91 @@ HOCalibAnalyzer::HOCalibAnalyzer(const edm::ParameterSet& iConfig) m_pedsuppr = iConfig.getUntrackedParameter("pedSuppr", true); m_cosmic = iConfig.getUntrackedParameter("cosmic", true); m_sigma = iConfig.getUntrackedParameter("sigma", 0.05); - + edm::Service fs; theFile = new TFile(theRootFileName.c_str(), "RECREATE"); theFile->cd(); - + T1 = new TTree("T1", "DT+CSC+HO"); - - T1->Branch("irun",&irun,"irun/I"); - T1->Branch("ievt",&ievt,"ievt/i"); - - // T1->Branch("itrg1",&itrg1,"itrg1/I"); - // T1->Branch("itrg2",&itrg2,"itrg2/I"); - - T1->Branch("isect",&isect,"isect/I"); - T1->Branch("isect2",&isect2,"isect2/I"); - T1->Branch("ndof",&ndof,"ndof/I"); - T1->Branch("nmuon",&nmuon,"nmuon/I"); - + + T1->Branch("irun", &irun, "irun/I"); + T1->Branch("ievt", &ievt, "ievt/i"); + + // T1->Branch("itrg1",&itrg1,"itrg1/I"); + // T1->Branch("itrg2",&itrg2,"itrg2/I"); + + T1->Branch("isect", &isect, "isect/I"); + T1->Branch("isect2", &isect2, "isect2/I"); + T1->Branch("ndof", &ndof, "ndof/I"); + T1->Branch("nmuon", &nmuon, "nmuon/I"); + T1->Branch("ilumi", &ilumi, "ilumi/I"); - if (!m_cosmic) { - T1->Branch("inslumi",&inslumi,"inslumi/F"); - T1->Branch("nprim", &nprim, "nprim/I"); - T1->Branch("tkpt03", &tkpt03," tkpt03/F"); - T1->Branch("ecal03", &ecal03," ecal03/F"); - T1->Branch("hcal03", &hcal03," hcal03/F"); + if (!m_cosmic) { + T1->Branch("inslumi", &inslumi, "inslumi/F"); + T1->Branch("nprim", &nprim, "nprim/I"); + T1->Branch("tkpt03", &tkpt03, " tkpt03/F"); + T1->Branch("ecal03", &ecal03, " ecal03/F"); + T1->Branch("hcal03", &hcal03, " hcal03/F"); } - T1->Branch("trkdr",&trkdr,"trkdr/F"); - T1->Branch("trkdz",&trkdz,"trkdz/F"); - - T1->Branch("trkvx",&trkvx,"trkvx/F"); - T1->Branch("trkvy",&trkvy,"trkvy/F"); - T1->Branch("trkvz",&trkvz,"trkvz/F"); - T1->Branch("trkmm",&trkmm,"trkmm/F"); - T1->Branch("trkth",&trkth,"trkth/F"); - T1->Branch("trkph",&trkph,"trkph/F"); - - T1->Branch("chisq",&chisq,"chisq/F"); - T1->Branch("therr",&therr,"therr/F"); - T1->Branch("pherr",&pherr,"pherr/F"); - T1->Branch("hodx",&hodx,"hodx/F"); - T1->Branch("hody",&hody,"hody/F"); - T1->Branch("hoang",&hoang,"hoang/F"); - - T1->Branch("momatho", &momatho,"momatho/F"); - T1->Branch("hoflag",&hoflag,"hoflag/i"); - T1->Branch("htime",&htime,"htime/F"); - T1->Branch("hosig",hosig,"hosig[9]/F"); - T1->Branch("hocro",&hocro,"hocro/F"); - T1->Branch("hocorsig",hocorsig,"hocorsig[18]/F"); - T1->Branch("caloen",caloen,"caloen[3]/F"); - - - if (m_hbinfo) { // #ifdef HBINFO - T1->Branch("hbhesig",hbhesig,"hbhesig[9]/F"); - } //m_hbinfo #endif + T1->Branch("trkdr", &trkdr, "trkdr/F"); + T1->Branch("trkdz", &trkdz, "trkdz/F"); + + T1->Branch("trkvx", &trkvx, "trkvx/F"); + T1->Branch("trkvy", &trkvy, "trkvy/F"); + T1->Branch("trkvz", &trkvz, "trkvz/F"); + T1->Branch("trkmm", &trkmm, "trkmm/F"); + T1->Branch("trkth", &trkth, "trkth/F"); + T1->Branch("trkph", &trkph, "trkph/F"); + + T1->Branch("chisq", &chisq, "chisq/F"); + T1->Branch("therr", &therr, "therr/F"); + T1->Branch("pherr", &pherr, "pherr/F"); + T1->Branch("hodx", &hodx, "hodx/F"); + T1->Branch("hody", &hody, "hody/F"); + T1->Branch("hoang", &hoang, "hoang/F"); + + T1->Branch("momatho", &momatho, "momatho/F"); + T1->Branch("hoflag", &hoflag, "hoflag/i"); + T1->Branch("htime", &htime, "htime/F"); + T1->Branch("hosig", hosig, "hosig[9]/F"); + T1->Branch("hocro", &hocro, "hocro/F"); + T1->Branch("hocorsig", hocorsig, "hocorsig[18]/F"); + T1->Branch("caloen", caloen, "caloen[3]/F"); + + if (m_hbinfo) { // #ifdef HBINFO + T1->Branch("hbhesig", hbhesig, "hbhesig[9]/F"); + } //m_hbinfo #endif char name[200]; char title[200]; if (m_allHOsignal) { - ho_entry = fs->make("ho_entry", "ho entry", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); - - ho_energy = fs->make("ho_energy", "ho energy (GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); - - ho_energy2 = fs->make("ho_energy2", "ho energy2 (GeV*GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); - - ho_rms = fs->make("ho_rms", "ho rms (GeV)", netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); - - for (int ij=0; ijmake (name, title, 120, -5., 55.); + ho_entry = fs->make( + "ho_entry", "ho entry", netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); + + ho_energy = fs->make( + "ho_energy", "ho energy (GeV)", netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); + + ho_energy2 = fs->make("ho_energy2", + "ho energy2 (GeV*GeV)", + netamx + 1, + -netamx / 2 - 0.5, + netamx / 2 + 0.5, + nphimx, + 0.5, + nphimx + 0.5); + + ho_rms = fs->make( + "ho_rms", "ho rms (GeV)", netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); + + for (int ij = 0; ij < netamx; ij++) { + int ieta = getHOieta(ij); + for (int jk = 0; jk < nphimx; jk++) { + sprintf(name, "ho_indenergy_%i_%i", ij, jk); + sprintf(title, "ho IndEnergy (GeV) i#eta=%i i#phi=%i", ieta, jk + 1); + ho_indenergy[ij][jk] = fs->make(name, title, 120, -5., 55.); } } } @@ -572,261 +562,271 @@ HOCalibAnalyzer::HOCalibAnalyzer(const edm::ParameterSet& iConfig) sel_muonph = fs->make("sel_muonph", "{Phi}_{mu}(sel)", 180, -180., 180.); sel_muonch = fs->make("sel_muonch", "{chi^2}/ndf(sel)", 100, 0., 1000.); + int nbin = 50; //40;// 45; //50; //55; //60; //55; //45; //40; //50; + alow = -2.0; // -1.85; //-1.90; // -1.95; // -2.0; + ahigh = 8.0; // 8.15; // 8.10; // 8.05; // 8.0; + + float tmpwid = (ahigh - alow) / nbin; + nbn = int(-alow / tmpwid) + 1; + if (nbn < 0) + nbn = 0; + if (nbn > nbin) + nbn = nbin; + + edm::LogInfo("HOCalib") << "nbin " << nbin << " " << alow << " " << ahigh << " " << tmpwid << " " << nbn; + + for (int ij = 0; ij < 15; ij++) { + sprintf(title, "sigvsndof_ring%i", ij + 1); + sigvsevt[ij][0] = fs->make(title, title, 50, 0., 50., -9., 20.); + + sprintf(title, "sigvschisq_ring%i", ij + 1); + sigvsevt[ij][1] = fs->make(title, title, 50, 0., 30., -9., 20.); - int nbin = 50; //40;// 45; //50; //55; //60; //55; //45; //40; //50; - alow = -2.0;// -1.85; //-1.90; // -1.95; // -2.0; - ahigh = 8.0;// 8.15; // 8.10; // 8.05; // 8.0; - - float tmpwid = (ahigh-alow)/nbin; - nbn = int(-alow/tmpwid)+1; - if (nbn <0) nbn = 0; - if (nbn>nbin) nbn = nbin; - - - edm::LogInfo("HOCalib") <<"nbin "<< nbin<<" "<make(title, title, 50, 0., 50.,-9., 20.); - - sprintf(title, "sigvschisq_ring%i", ij+1); - sigvsevt[ij][1] = fs->make(title, title, 50, 0., 30.,-9., 20.); - - sprintf(title, "sigvsth_ring%i", ij+1); - sigvsevt[ij][2] = fs->make(title, title, 50, .7, 2.4,-9., 20.); - - sprintf(title, "sigvsph_ring%i", ij+1); - sigvsevt[ij][3] = fs->make(title, title, 50, -2.4, -0.7,-9., 20.); - - sprintf(title, "sigvstherr_ring%i", ij+1); - sigvsevt[ij][4] = fs->make(title, title, 50, 0., 0.2,-9., 20.); - - sprintf(title, "sigvspherr_ring%i", ij+1); - sigvsevt[ij][5] = fs->make(title, title, 50, 0., 0.2,-9., 20.); - - sprintf(title, "sigvsdircos_ring%i", ij+1); - sigvsevt[ij][6] = fs->make(title, title, 50, 0.5, 1.,-9., 20.); - - sprintf(title, "sigvstrkmm_ring%i", ij+1); - sigvsevt[ij][7] = fs->make(title, title, 50, 0., 50.,-9., 20.); - - sprintf(title, "sigvsnmuon_ring%i", ij+1); - sigvsevt[ij][8] = fs->make(title, title, 5, 0.5, 5.5,-9., 20.); - - sprintf(title, "sigvserr_ring%i", ij+1); + sprintf(title, "sigvsth_ring%i", ij + 1); + sigvsevt[ij][2] = fs->make(title, title, 50, .7, 2.4, -9., 20.); + + sprintf(title, "sigvsph_ring%i", ij + 1); + sigvsevt[ij][3] = fs->make(title, title, 50, -2.4, -0.7, -9., 20.); + + sprintf(title, "sigvstherr_ring%i", ij + 1); + sigvsevt[ij][4] = fs->make(title, title, 50, 0., 0.2, -9., 20.); + + sprintf(title, "sigvspherr_ring%i", ij + 1); + sigvsevt[ij][5] = fs->make(title, title, 50, 0., 0.2, -9., 20.); + + sprintf(title, "sigvsdircos_ring%i", ij + 1); + sigvsevt[ij][6] = fs->make(title, title, 50, 0.5, 1., -9., 20.); + + sprintf(title, "sigvstrkmm_ring%i", ij + 1); + sigvsevt[ij][7] = fs->make(title, title, 50, 0., 50., -9., 20.); + + sprintf(title, "sigvsnmuon_ring%i", ij + 1); + sigvsevt[ij][8] = fs->make(title, title, 5, 0.5, 5.5, -9., 20.); + + sprintf(title, "sigvserr_ring%i", ij + 1); sigvsevt[ij][9] = fs->make(title, title, 50, 0., .3, -9., 20.); - - sprintf(title, "sigvsaccx_ring%i", ij+1); - sigvsevt[ij][10] = fs->make(title, title, 100, -25., 25., -9., 20.); - - sprintf(title, "sigvsaccy_ring%i", ij+1); - sigvsevt[ij][11] = fs->make(title, title, 100, -25., 25., -9., 20.); - - sprintf(title, "sigvscalo_ring%i", ij+1); - sigvsevt[ij][12] = fs->make(title, title, 100, 0., 15., -9., 20.); + + sprintf(title, "sigvsaccx_ring%i", ij + 1); + sigvsevt[ij][10] = fs->make(title, title, 100, -25., 25., -9., 20.); + + sprintf(title, "sigvsaccy_ring%i", ij + 1); + sigvsevt[ij][11] = fs->make(title, title, 100, -25., 25., -9., 20.); + + sprintf(title, "sigvscalo_ring%i", ij + 1); + sigvsevt[ij][12] = fs->make(title, title, 100, 0., 15., -9., 20.); } - for (int jk=0; jkmake(title, title, nbin, alow, ahigh); - if (ij==nphimx) { - sprintf(title, "ped_eta%i_allphi", ieta); + sigrsg[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + if (ij == nphimx) { + sprintf(title, "ped_eta%i_allphi", ieta); } else { - sprintf(title, "ped_eta%i_phi%i", ieta,ij+1); + sprintf(title, "ped_eta%i_phi%i", ieta, ij + 1); } - crossg[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + crossg[jk][ij] = fs->make(title, title, nbin, alow, ahigh); } - for (int ij=0; ijmake(title, title, 10, -0.5, 9.5, -1.0, 30.0); - - sprintf(title, "hopedtime_eta%i_phi%i", (jk<=14) ? jk+1 : 14-jk, ij+1); - hopedtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); - - } //m_hotime #endif - if (m_hbtime) { //#ifdef HBTIME - sprintf(title, "hbtime_eta%i_phi%i", (jk<=15) ? jk+1 : 15-jk, ij+1); - hbtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); - } //m_hbtime #endif - - if (m_correl) { //#ifdef CORREL - sprintf(title, "corrsg_eta%i_phi%i_leftbottom", ieta,ij+1); - corrsglb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_rightbottom", ieta,ij+1); - corrsgrb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_leftup", ieta,ij+1); - corrsglu[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_rightup", ieta,ij+1); - corrsgru[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_all", ieta,ij+1); - corrsgall[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_left", ieta,ij+1); - corrsgl[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "corrsg_eta%i_phi%i_right", ieta,ij+1); - corrsgr[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - } //m_correl #endif - if (m_checkmap) {// #ifdef CHECKMAP - sprintf(title, "corrsg_eta%i_phi%i_centrl", ieta,ij+1); - corrsgc[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - } //m_checkmap #endif + for (int ij = 0; ij < nphimx; ij++) { + if (m_hotime) { //#ifdef HOTIME + sprintf(title, "hotime_eta%i_phi%i", (jk <= 14) ? jk + 1 : 14 - jk, ij + 1); + hotime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + + sprintf(title, "hopedtime_eta%i_phi%i", (jk <= 14) ? jk + 1 : 14 - jk, ij + 1); + hopedtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + + } //m_hotime #endif + if (m_hbtime) { //#ifdef HBTIME + sprintf(title, "hbtime_eta%i_phi%i", (jk <= 15) ? jk + 1 : 15 - jk, ij + 1); + hbtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + } //m_hbtime #endif + + if (m_correl) { //#ifdef CORREL + sprintf(title, "corrsg_eta%i_phi%i_leftbottom", ieta, ij + 1); + corrsglb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_rightbottom", ieta, ij + 1); + corrsgrb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_leftup", ieta, ij + 1); + corrsglu[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_rightup", ieta, ij + 1); + corrsgru[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_all", ieta, ij + 1); + corrsgall[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_left", ieta, ij + 1); + corrsgl[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "corrsg_eta%i_phi%i_right", ieta, ij + 1); + corrsgr[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + } //m_correl #endif + if (m_checkmap) { // #ifdef CHECKMAP + sprintf(title, "corrsg_eta%i_phi%i_centrl", ieta, ij + 1); + corrsgc[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + } //m_checkmap #endif } } - mnsigrsg = fs->make("mnsigrsg","mnsigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - rmssigrsg = fs->make("rmssigrsg","rmssigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - nevsigrsg = fs->make("nevsigrsg","nevsigrsg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - - mncrossg = fs->make("mncrossg","mncrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - rmscrossg = fs->make("rmscrossg","rmscrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - nevcrossg = fs->make("nevcrossg","nevcrossg", netamx*nphimx+ringmx*routmx, -0.5, netamx*nphimx+ringmx*routmx -0.5); - - - for (int ij=0; ijmake( + "mnsigrsg", "mnsigrsg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + rmssigrsg = fs->make( + "rmssigrsg", "rmssigrsg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + nevsigrsg = fs->make( + "nevsigrsg", "nevsigrsg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + + mncrossg = fs->make( + "mncrossg", "mncrossg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + rmscrossg = fs->make( + "rmscrossg", "rmscrossg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + nevcrossg = fs->make( + "nevcrossg", "nevcrossg", netamx * nphimx + ringmx * routmx, -0.5, netamx * nphimx + ringmx * routmx - 0.5); + + for (int ij = 0; ij < neffip; ij++) { + if (ij == 0) { + sprintf(title, "Total projected muon in tower"); + sprintf(name, "total_evt"); } else { - sprintf(title, "Efficiency with sig >%i #sigma", ij); - sprintf(name, "Effi_with_gt%i_sig", ij); + sprintf(title, "Efficiency with sig >%i #sigma", ij); + sprintf(name, "Effi_with_gt%i_sig", ij); } - sig_effi[ij] = fs->make(name, title, netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); + sig_effi[ij] = + fs->make(name, title, netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); } - sprintf(title, "Mean Energy of all towers"); - sprintf(name, "mean_energy"); - mean_energy = fs->make(name, title, netamx+1, -netamx/2-0.5, netamx/2+0.5, nphimx, 0.5, nphimx+0.5); - - if (m_correl) { //#ifdef CORREL - mncorrsglb = fs->make("mncorrsglb","mncorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsglb = fs->make("rmscorrsglb","rmscorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsglb = fs->make("nevcorrsglb","nevcorrsglb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsgrb = fs->make("mncorrsgrb","mncorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgrb = fs->make("rmscorrsgrb","rmscorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgrb = fs->make("nevcorrsgrb","nevcorrsgrb", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsglu = fs->make("mncorrsglu","mncorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsglu = fs->make("rmscorrsglu","rmscorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsglu = fs->make("nevcorrsglu","nevcorrsglu", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsgru = fs->make("mncorrsgru","mncorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgru = fs->make("rmscorrsgru","rmscorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgru = fs->make("nevcorrsgru","nevcorrsgru", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsgall = fs->make("mncorrsgall","mncorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgall = fs->make("rmscorrsgall","rmscorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgall = fs->make("nevcorrsgall","nevcorrsgall", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsgl = fs->make("mncorrsgl","mncorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgl = fs->make("rmscorrsgl","rmscorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgl = fs->make("nevcorrsgl","nevcorrsgl", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - - mncorrsgr = fs->make("mncorrsgr","mncorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgr = fs->make("rmscorrsgr","rmscorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgr = fs->make("nevcorrsgr","nevcorrsgr", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - } //m_correl #endif - - if (m_checkmap) { //#ifdef CHECKMAP - mncorrsgc = fs->make("mncorrsgc","mncorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - rmscorrsgc = fs->make("rmscorrsgc","rmscorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - nevcorrsgc = fs->make("nevcorrsgc","nevcorrsgc", netamx*nphimx+60, -0.5, netamx*nphimx+59.5); - } //m_checkmap #endif - - if (m_combined) { //#ifdef COMBINED - for (int jk=0; jkrout12mx) continue; - int phmn = 3*ij-1; - int phmx = 3*ij+1; - if (jk==2) {phmn = 2*ij-1; phmx=2*ij;} - if (phmn <=0) phmn = nphimx+phmn; - if (phmx <=0) phmx = nphimx+phmx; - - if ((jk==2 && ij==routmx) || (jk!=2 && ij==rout12mx)) { - sprintf(title, "sig_ring%i_allrm", jk-2); - sprintf(name, "sig_ring%i_allrm", jk-2); - } else { - sprintf(title, "sig_ring%i_phi%i-%i", jk-2,phmn,phmx); - sprintf(name, "sig_ring%i_rout%i", jk-2,ij+1); - } - com_sigrsg[jk][ij] = fs->make(name, title, nbin, alow, ahigh); - if ((jk==2 && ij==routmx) || (jk!=2 && ij==rout12mx)) { - sprintf(title, "ped_ring%i_allrm", jk-2); - sprintf(name, "ped_ring%i_allrm", jk-2); - } else { - sprintf(title, "ped_ring%i_phi%i-%i", jk-2,phmn, phmx); - sprintf(name, "ped_ring%i_rout%i", jk-2,ij+1); - } - com_crossg[jk][ij] = fs->make(name, title, nbin, alow, ahigh); + sprintf(title, "Mean Energy of all towers"); + sprintf(name, "mean_energy"); + mean_energy = fs->make(name, title, netamx + 1, -netamx / 2 - 0.5, netamx / 2 + 0.5, nphimx, 0.5, nphimx + 0.5); + + if (m_correl) { //#ifdef CORREL + mncorrsglb = fs->make("mncorrsglb", "mncorrsglb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsglb = fs->make("rmscorrsglb", "rmscorrsglb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsglb = fs->make("nevcorrsglb", "nevcorrsglb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsgrb = fs->make("mncorrsgrb", "mncorrsgrb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgrb = fs->make("rmscorrsgrb", "rmscorrsgrb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgrb = fs->make("nevcorrsgrb", "nevcorrsgrb", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsglu = fs->make("mncorrsglu", "mncorrsglu", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsglu = fs->make("rmscorrsglu", "rmscorrsglu", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsglu = fs->make("nevcorrsglu", "nevcorrsglu", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsgru = fs->make("mncorrsgru", "mncorrsgru", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgru = fs->make("rmscorrsgru", "rmscorrsgru", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgru = fs->make("nevcorrsgru", "nevcorrsgru", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsgall = fs->make("mncorrsgall", "mncorrsgall", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgall = fs->make("rmscorrsgall", "rmscorrsgall", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgall = fs->make("nevcorrsgall", "nevcorrsgall", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsgl = fs->make("mncorrsgl", "mncorrsgl", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgl = fs->make("rmscorrsgl", "rmscorrsgl", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgl = fs->make("nevcorrsgl", "nevcorrsgl", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + + mncorrsgr = fs->make("mncorrsgr", "mncorrsgr", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgr = fs->make("rmscorrsgr", "rmscorrsgr", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgr = fs->make("nevcorrsgr", "nevcorrsgr", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + } //m_correl #endif + + if (m_checkmap) { //#ifdef CHECKMAP + mncorrsgc = fs->make("mncorrsgc", "mncorrsgc", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + rmscorrsgc = fs->make("rmscorrsgc", "rmscorrsgc", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + nevcorrsgc = fs->make("nevcorrsgc", "nevcorrsgc", netamx * nphimx + 60, -0.5, netamx * nphimx + 59.5); + } //m_checkmap #endif + + if (m_combined) { //#ifdef COMBINED + for (int jk = 0; jk < ringmx; jk++) { + for (int ij = 0; ij < routmx + 1; ij++) { + if (jk != 2 && ij > rout12mx) + continue; + int phmn = 3 * ij - 1; + int phmx = 3 * ij + 1; + if (jk == 2) { + phmn = 2 * ij - 1; + phmx = 2 * ij; + } + if (phmn <= 0) + phmn = nphimx + phmn; + if (phmx <= 0) + phmx = nphimx + phmx; + + if ((jk == 2 && ij == routmx) || (jk != 2 && ij == rout12mx)) { + sprintf(title, "sig_ring%i_allrm", jk - 2); + sprintf(name, "sig_ring%i_allrm", jk - 2); + } else { + sprintf(title, "sig_ring%i_phi%i-%i", jk - 2, phmn, phmx); + sprintf(name, "sig_ring%i_rout%i", jk - 2, ij + 1); + } + com_sigrsg[jk][ij] = fs->make(name, title, nbin, alow, ahigh); + if ((jk == 2 && ij == routmx) || (jk != 2 && ij == rout12mx)) { + sprintf(title, "ped_ring%i_allrm", jk - 2); + sprintf(name, "ped_ring%i_allrm", jk - 2); + } else { + sprintf(title, "ped_ring%i_phi%i-%i", jk - 2, phmn, phmx); + sprintf(name, "ped_ring%i_rout%i", jk - 2, ij + 1); + } + com_crossg[jk][ij] = fs->make(name, title, nbin, alow, ahigh); } - for (int ij=0; ijmake(title, title, 10, -0.5, 9.5, -1.0, 30.0); - - sprintf(title, "com_hopedtime_ring%i_sect%i", jk-2, ij+1); - com_hopedtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); - } //m_hotime #endif - if (m_hbtime){ //#ifdef HBTIME - sprintf(title, "_com_hbtime_ring%i_serrct%i", jk-2, ij+1); - com_hbtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); - } //m_hbtime #endif - - if (m_correl) { //#ifdef CORREL - sprintf(title, "com_corrsg_ring%i_sect%i_leftbottom", jk-2,ij+1); - com_corrsglb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_rightbottom", jk-2,ij+1); - com_corrsgrb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_leftup", jk-2,ij+1); - com_corrsglu[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_rightup", jk-2,ij+1); - com_corrsgru[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_all", jk-2,ij+1); - com_corrsgall[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_left", jk-2,ij+1); - com_corrsgl[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - - sprintf(title, "com_corrsg_ring%i_sect%i_right", jk-2,ij+1); - com_corrsgr[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - } //m_correl #endif - - if (m_checkmap) { // #ifdef CHECKMAP - sprintf(title, "com_corrsg_ring%i_sect%i_centrl", jk-2,ij+1); - com_corrsgc[jk][ij] = fs->make(title, title, nbin, alow, ahigh); - } //m_checkmap #endif + for (int ij = 0; ij < sectmx; ij++) { + if (m_hotime) { //#ifdef HOTIME + sprintf(title, "com_hotime_ring%i_sect%i", jk - 2, ij + 1); + com_hotime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + + sprintf(title, "com_hopedtime_ring%i_sect%i", jk - 2, ij + 1); + com_hopedtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + } //m_hotime #endif + if (m_hbtime) { //#ifdef HBTIME + sprintf(title, "_com_hbtime_ring%i_serrct%i", jk - 2, ij + 1); + com_hbtime[jk][ij] = fs->make(title, title, 10, -0.5, 9.5, -1.0, 30.0); + } //m_hbtime #endif + + if (m_correl) { //#ifdef CORREL + sprintf(title, "com_corrsg_ring%i_sect%i_leftbottom", jk - 2, ij + 1); + com_corrsglb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_rightbottom", jk - 2, ij + 1); + com_corrsgrb[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_leftup", jk - 2, ij + 1); + com_corrsglu[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_rightup", jk - 2, ij + 1); + com_corrsgru[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_all", jk - 2, ij + 1); + com_corrsgall[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_left", jk - 2, ij + 1); + com_corrsgl[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + + sprintf(title, "com_corrsg_ring%i_sect%i_right", jk - 2, ij + 1); + com_corrsgr[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + } //m_correl #endif + + if (m_checkmap) { // #ifdef CHECKMAP + sprintf(title, "com_corrsg_ring%i_sect%i_centrl", jk - 2, ij + 1); + com_corrsgc[jk][ij] = fs->make(title, title, nbin, alow, ahigh); + } //m_checkmap #endif } } - } //m_combined #endif + } //m_combined #endif + + for (int ij = -1; ij <= 1; ij++) { + for (int jk = -1; jk <= 1; jk++) { + int kl = 3 * (ij + 1) + jk + 1; - for (int ij=-1; ij<=1; ij++) { - for (int jk=-1; jk<=1; jk++) { - int kl = 3*(ij+1)+jk+1; - sprintf(title, "hosct2p_eta%i_phi%i", ij, jk); ho_sig2p[kl] = fs->make(title, title, nbin, alow, ahigh); - + sprintf(title, "hosct1p_eta%i_phi%i", ij, jk); ho_sig1p[kl] = fs->make(title, title, nbin, alow, ahigh); @@ -839,124 +839,117 @@ HOCalibAnalyzer::HOCalibAnalyzer(const edm::ParameterSet& iConfig) sprintf(title, "hosct2m_eta%i_phi%i", ij, jk); ho_sig2m[kl] = fs->make(title, title, nbin, alow, ahigh); - if (m_hbinfo) { // #ifdef HBINFO - sprintf(title, "hbhesig_eta%i_phi%i", ij, jk); - hbhe_sig[kl] = fs->make(title, title, 51, -10.5, 40.5); - } //m_hbinfo #endif + if (m_hbinfo) { // #ifdef HBINFO + sprintf(title, "hbhesig_eta%i_phi%i", ij, jk); + hbhe_sig[kl] = fs->make(title, title, 51, -10.5, 40.5); + } //m_hbinfo #endif } } if (m_constant) { - ped_evt = fs->make("ped_evt", "ped_evt", netamx*nphimx, -0.5, netamx*nphimx-0.5); - ped_mean = fs->make("ped_mean", "ped_mean", netamx*nphimx, -0.5, netamx*nphimx-0.5); - ped_width = fs->make("ped_width", "ped_width", netamx*nphimx, -0.5, netamx*nphimx-0.5); - - fit_chi = fs->make("fit_chi", "fit_chi", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_evt = fs->make("sig_evt", "sig_evt", netamx*nphimx, -0.5, netamx*nphimx-0.5); - fit_sigevt = fs->make("fit_sigevt", "fit_sigevt", netamx*nphimx, -0.5, netamx*nphimx-0.5); - fit_bkgevt = fs->make("fit_bkgevt", "fit_bkgevt", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_mean = fs->make("sig_mean", "sig_mean", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_diff = fs->make("sig_diff", "sig_diff", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_width = fs->make("sig_width", "sig_width", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_sigma = fs->make("sig_sigma", "sig_sigma", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_meanerr = fs->make("sig_meanerr", "sig_meanerr", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_meanerrp = fs->make("sig_meanerrp", "sig_meanerrp", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_signf = fs->make("sig_signf", "sig_signf", netamx*nphimx, -0.5, netamx*nphimx-0.5); - - ped_statmean = fs->make("ped_statmean", "ped_statmean", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_statmean = fs->make("sig_statmean", "sig_statmean", netamx*nphimx, -0.5, netamx*nphimx-0.5); - ped_rms = fs->make("ped_rms", "ped_rms", netamx*nphimx, -0.5, netamx*nphimx-0.5); - sig_rms = fs->make("sig_rms", "sig_rms", netamx*nphimx, -0.5, netamx*nphimx-0.5); - - const_eta_phi = fs->make("const_eta_phi", "const_eta_phi", netamx+1, -(netamx+1)/2., (netamx+1)/2., nphimx, 0.5, nphimx+0.5); - - for (int ij=0; ijmake("ped_evt", "ped_evt", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + ped_mean = fs->make("ped_mean", "ped_mean", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + ped_width = fs->make("ped_width", "ped_width", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + + fit_chi = fs->make("fit_chi", "fit_chi", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_evt = fs->make("sig_evt", "sig_evt", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + fit_sigevt = fs->make("fit_sigevt", "fit_sigevt", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + fit_bkgevt = fs->make("fit_bkgevt", "fit_bkgevt", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_mean = fs->make("sig_mean", "sig_mean", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_diff = fs->make("sig_diff", "sig_diff", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_width = fs->make("sig_width", "sig_width", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_sigma = fs->make("sig_sigma", "sig_sigma", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_meanerr = fs->make("sig_meanerr", "sig_meanerr", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_meanerrp = fs->make("sig_meanerrp", "sig_meanerrp", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_signf = fs->make("sig_signf", "sig_signf", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + + ped_statmean = fs->make("ped_statmean", "ped_statmean", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_statmean = fs->make("sig_statmean", "sig_statmean", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + ped_rms = fs->make("ped_rms", "ped_rms", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + sig_rms = fs->make("sig_rms", "sig_rms", netamx * nphimx, -0.5, netamx * nphimx - 0.5); + + const_eta_phi = fs->make( + "const_eta_phi", "const_eta_phi", netamx + 1, -(netamx + 1) / 2., (netamx + 1) / 2., nphimx, 0.5, nphimx + 0.5); + + for (int ij = 0; ij < netamx; ij++) { + int ieta = (ij < 15) ? ij + 1 : 14 - ij; sprintf(title, "Cont_Eta_%i", ieta); - const_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx+0.5); - + const_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx + 0.5); + sprintf(title, "Peak_Eta_%i", ieta); - peak_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx+0.5); + peak_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx + 0.5); } - for (int ij=0; ijmake(title, title, iread, 0.5, iread+0.5); - + const_hpdrm[ij] = fs->make(title, title, iread, 0.5, iread + 0.5); + sprintf(title, "Peak_hpdrm_%i", iring); - peak_hpdrm[ij] = fs->make(title, title, iread, 0.5, iread+0.5); + peak_hpdrm[ij] = fs->make(title, title, iread, 0.5, iread + 0.5); } - mean_phi_hst = fs->make("mean_phi_hst", "mean_phi_hst", netamx+1, -(netamx+1)/2., (netamx+1)/2.); - mean_phi_ave = fs->make("mean_phi_ave", "mean_phi_ave", netamx+1, -(netamx+1)/2., (netamx+1)/2.); + mean_phi_hst = fs->make("mean_phi_hst", "mean_phi_hst", netamx + 1, -(netamx + 1) / 2., (netamx + 1) / 2.); + mean_phi_ave = fs->make("mean_phi_ave", "mean_phi_ave", netamx + 1, -(netamx + 1) / 2., (netamx + 1) / 2.); + + mean_eta_ave = fs->make("mean_eta_ave", "mean_eta_ave", nphimx, 0.5, nphimx + 0.5); + + } //m_constant - mean_eta_ave = fs->make("mean_eta_ave", "mean_eta_ave", nphimx, 0.5, nphimx+0.5); + for (int ij = 0; ij < netamx; ij++) { + int ieta = (ij < 15) ? ij + 1 : 14 - ij; - } //m_constant - - for (int ij=0; ijmake(title, title, nphimx, 0.5, nphimx+0.5); - + stat_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx + 0.5); + sprintf(title, "#mu(stat)_Eta_%i", ieta); - statmn_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx+0.5); + statmn_eta[ij] = fs->make(title, title, nphimx, 0.5, nphimx + 0.5); } - for (int jk=0; jkcd(); theFile->Write(); theFile->Close(); - edm::LogInfo("HOCalib") <<" Ttoal events = "<< Nevents<<" Selected events # is "< hoht; - iEvent.getByToken(tok_allho_,hoht); + iEvent.getByToken(tok_allho_, hoht); if (hoht.isValid() && !(*hoht).empty()) { - ho_entry->Fill(-1., -1.); //Count of total number of entries - for (HORecHitCollection::const_iterator ij=(*hoht).begin(); ij!=(*hoht).end(); ij++){ - HcalDetId id =(*ij).id(); - int tmpeta= id.ieta(); - int tmpphi= id.iphi(); - float signal = (*ij).energy(); - ho_entry->Fill(tmpeta, tmpphi); - ho_energy->Fill(tmpeta, tmpphi, signal); - ho_energy2->Fill(tmpeta, tmpphi, signal*signal); - - int inveta = invert_HOieta(tmpeta); - ho_indenergy[inveta][tmpphi-1]->Fill(signal); + ho_entry->Fill(-1., -1.); //Count of total number of entries + for (HORecHitCollection::const_iterator ij = (*hoht).begin(); ij != (*hoht).end(); ij++) { + HcalDetId id = (*ij).id(); + int tmpeta = id.ieta(); + int tmpphi = id.iphi(); + float signal = (*ij).energy(); + ho_entry->Fill(tmpeta, tmpphi); + ho_energy->Fill(tmpeta, tmpphi, signal); + ho_energy2->Fill(tmpeta, tmpphi, signal * signal); + + int inveta = invert_HOieta(tmpeta); + ho_indenergy[inveta][tmpphi - 1]->Fill(signal); } } } - - - - - edm::HandleHOCalib; + edm::Handle HOCalib; bool isCosMu = true; try { iEvent.getByToken(tok_ho_, HOCalib); - } catch ( cms::Exception &iEvent ) { isCosMu = false; } - if (Nevents%5000==1) edm::LogInfo("HOCalib") <<"nmuon event # "<Fill(); - - int ipsall=0; - int ips0=0; - int ips1=0; - int ips2=0; - int ips3=0; - int ips4=0; - int ips5=0; - int ips6=0; - int ips7=0; - int ips8=0; - int ips9=0; - int ips10 =0; - int ips11 =0; + for (int ij = 0; ij < 3; ij++) { + caloen[ij] = (*hoC).caloen[ij]; + } + + if (m_hbinfo) { + for (int ij = 0; ij < 9; ij++) { + hbhesig[ij] = (*hoC).hbhesig[ij]; + } + } // edm::LogInfo("HOCalib")<<"hbhesig "<Fill(); + + int ipsall = 0; + int ips0 = 0; + int ips1 = 0; + int ips2 = 0; + int ips3 = 0; + int ips4 = 0; + int ips5 = 0; + int ips6 = 0; + int ips7 = 0; + int ips8 = 0; + int ips9 = 0; + int ips10 = 0; + int ips11 = 0; int ips12 = 0; // int iselect3 = 0; // if (ndof >=15 && chisq <30) iselect3 = 1; - - if (isect <0) continue; //FIXGM Is it proper place ? - if (fabs(trkth-pival/2)<0.000001) continue; //22OCT07 - int ieta = int((abs(isect)%10000)/100.)-50; //an offset to acodate -ve eta values - if (abs(ieta)>=16) continue; - int iphi = abs(isect)%100; + if (isect < 0) + continue; //FIXGM Is it proper place ? + if (fabs(trkth - pival / 2) < 0.000001) + continue; //22OCT07 + + int ieta = int((abs(isect) % 10000) / 100.) - 50; //an offset to acodate -ve eta values + if (abs(ieta) >= 16) + continue; + int iphi = abs(isect) % 100; + + int tmpsect = int((iphi + 1) / 6.) + 1; + if (tmpsect > 12) + tmpsect = 1; - int tmpsect = int((iphi + 1)/6.) + 1; - if (tmpsect >12) tmpsect = 1; - int iring = 0; - int tmpeta = ieta + 4; //For pixel mapping - if (ieta >=-15 && ieta <=-11) {iring = -2; tmpeta =-11-ieta; } //abs(ieta)-11;} - if (ieta >=-10 && ieta <=-5) {iring = -1; tmpeta =-5-ieta; } // abs(ieta)-5;} - if (ieta >= 5 && ieta <= 10) {iring = 1; tmpeta =ieta-5; } - if (ieta >= 11 && ieta <= 15) {iring = 2; tmpeta =ieta-11;} - + int tmpeta = ieta + 4; //For pixel mapping + if (ieta >= -15 && ieta <= -11) { + iring = -2; + tmpeta = -11 - ieta; + } //abs(ieta)-11;} + if (ieta >= -10 && ieta <= -5) { + iring = -1; + tmpeta = -5 - ieta; + } // abs(ieta)-5;} + if (ieta >= 5 && ieta <= 10) { + iring = 1; + tmpeta = ieta - 5; + } + if (ieta >= 11 && ieta <= 15) { + iring = 2; + tmpeta = ieta - 11; + } + int iring2 = iring + 2; - - int tmprout = int((iphi + 1)/3.) + 1; - int tmproutmx =routmx; - if (iring==0) { - tmprout = int((iphi + 1)/2.) + 1; - if (tmprout >routmx) tmprout = 1; + + int tmprout = int((iphi + 1) / 3.) + 1; + int tmproutmx = routmx; + if (iring == 0) { + tmprout = int((iphi + 1) / 2.) + 1; + if (tmprout > routmx) + tmprout = 1; } else { - if (tmprout >rout12mx) tmprout = 1; - tmproutmx =rout12mx; + if (tmprout > rout12mx) + tmprout = 1; + tmproutmx = rout12mx; } // CRUZET1 if (m_cosmic) { - /* GMA temoparily change to increase event size at 3 & 9 O'clock position */ - if (abs(ndof) >=20 && abs(ndof) <40) {ips0 = (int)mypow_2_0; ipsall += ips0;} - if (chisq >0 && chisq<15) {ips1 = (int)mypow_2_1; ipsall +=ips1;} //18Jan2008 - if (fabs(trkth-pival/2) <21.5) {ips2 = (int)mypow_2_2; ipsall +=ips2;} //No nead for pp evt - if (fabs(trkph+pival/2) <21.5) {ips3 = (int)mypow_2_3; ipsall +=ips3;} //No nead for pp evt - - if (therr <0.02) {ips4 = (int)mypow_2_4; ipsall +=ips4;} - if (pherr <0.0002) {ips5 = (int)mypow_2_5; ipsall +=ips5;} - if (fabs(hoang) >0.30) {ips6 = (int)mypow_2_6; ipsall +=ips6;} - if (fabs(trkmm) >0.100) {ips7 = (int)mypow_2_7; ipsall +=ips7;} - // if (nmuon ==1) {ips8 = (int)mypow_2_8; ipsall +=ips8;} - if (nmuon >=1 && nmuon <=4) {ips8 = (int)mypow_2_8; ipsall +=ips8;} - - if (iring2==2) { - if (fabs(hodx)<100 && fabs(hodx)>2 && fabs(hocorsig[8]) <40 && fabs(hocorsig[8]) >2 ) - {ips10=(int)mypow_2_10;ipsall +=ips10;} - - if (fabs(hody)<100 && fabs(hody)>2 && fabs(hocorsig[9]) <40 && fabs(hocorsig[9]) >2 ) - {ips11=(int)mypow_2_11;ipsall +=ips11;} - - } else { - if (fabs(hodx)<100 && fabs(hodx)>2 ) - {ips10=(int)mypow_2_10;ipsall +=ips10;} - - if (fabs(hody)<100 && fabs(hody)>2) - {ips11=(int)mypow_2_11;ipsall +=ips11;} - } - if (caloen[0] ==0) { ips12=(int)mypow_2_12;ipsall +=ips12;} + /* GMA temoparily change to increase event size at 3 & 9 O'clock position */ + if (abs(ndof) >= 20 && abs(ndof) < 40) { + ips0 = (int)mypow_2_0; + ipsall += ips0; + } + if (chisq > 0 && chisq < 15) { + ips1 = (int)mypow_2_1; + ipsall += ips1; + } //18Jan2008 + if (fabs(trkth - pival / 2) < 21.5) { + ips2 = (int)mypow_2_2; + ipsall += ips2; + } //No nead for pp evt + if (fabs(trkph + pival / 2) < 21.5) { + ips3 = (int)mypow_2_3; + ipsall += ips3; + } //No nead for pp evt + + if (therr < 0.02) { + ips4 = (int)mypow_2_4; + ipsall += ips4; + } + if (pherr < 0.0002) { + ips5 = (int)mypow_2_5; + ipsall += ips5; + } + if (fabs(hoang) > 0.30) { + ips6 = (int)mypow_2_6; + ipsall += ips6; + } + if (fabs(trkmm) > 0.100) { + ips7 = (int)mypow_2_7; + ipsall += ips7; + } + // if (nmuon ==1) {ips8 = (int)mypow_2_8; ipsall +=ips8;} + if (nmuon >= 1 && nmuon <= 4) { + ips8 = (int)mypow_2_8; + ipsall += ips8; + } + + if (iring2 == 2) { + if (fabs(hodx) < 100 && fabs(hodx) > 2 && fabs(hocorsig[8]) < 40 && fabs(hocorsig[8]) > 2) { + ips10 = (int)mypow_2_10; + ipsall += ips10; + } + + if (fabs(hody) < 100 && fabs(hody) > 2 && fabs(hocorsig[9]) < 40 && fabs(hocorsig[9]) > 2) { + ips11 = (int)mypow_2_11; + ipsall += ips11; + } + + } else { + if (fabs(hodx) < 100 && fabs(hodx) > 2) { + ips10 = (int)mypow_2_10; + ipsall += ips10; + } + + if (fabs(hody) < 100 && fabs(hody) > 2) { + ips11 = (int)mypow_2_11; + ipsall += ips11; + } + } + if (caloen[0] == 0) { + ips12 = (int)mypow_2_12; + ipsall += ips12; + } } else { - //csa08 - if (abs(ndof) >=20 && abs(ndof) <40) {ips0 = (int)mypow_2_0; ipsall += ips0;} - if (chisq >0 && chisq<15) {ips1 = (int)mypow_2_1; ipsall +=ips1;} //18Jan2008 - if (fabs(trkth-pival/2) <21.5) {ips2 = (int)mypow_2_2; ipsall +=ips2;} //No nead for pp evt - if (fabs(trkph+pival/2) <21.5) {ips3 = (int)mypow_2_3; ipsall +=ips3;} //No nead for pp evt - - if (therr <0.02) {ips4 = (int)mypow_2_4; ipsall +=ips4;} - if (pherr <0.0002) {ips5 = (int)mypow_2_5; ipsall +=ips5;} - if (fabs(hoang) >0.30) {ips6 = (int)mypow_2_6; ipsall +=ips6;} - if (fabs(trkmm) >4.0) {ips7 = (int)mypow_2_7; ipsall +=ips7;} - if (nmuon >=1 && nmuon <=2) {ips8 = (int)mypow_2_8; ipsall +=ips8;} - - if (iring2==2) { - if (fabs(hodx)<100 && fabs(hodx)>2 && fabs(hocorsig[8]) <40 && fabs(hocorsig[8]) >2 ) - {ips10=(int)mypow_2_10;ipsall +=ips10;} - - if (fabs(hody)<100 && fabs(hody)>2 && fabs(hocorsig[9]) <40 && fabs(hocorsig[9]) >2 ) - {ips11=(int)mypow_2_11;ipsall +=ips11;} - - } else { - if (fabs(hodx)<100 && fabs(hodx)>2 ) - {ips10=(int)mypow_2_10;ipsall +=ips10;} - - if (fabs(hody)<100 && fabs(hody)>2) - {ips11=(int)mypow_2_11;ipsall +=ips11;} - } - // if (m_cosmic || (caloen[0] >0.5 && caloen[0]<5.0)) {ips12=(int)pow_2_12;ipsall +=ips12;} - if (ndof >0 && caloen[0]<5.0) {ips12=(int)mypow_2_12;ipsall +=ips12;} - /* */ + //csa08 + if (abs(ndof) >= 20 && abs(ndof) < 40) { + ips0 = (int)mypow_2_0; + ipsall += ips0; + } + if (chisq > 0 && chisq < 15) { + ips1 = (int)mypow_2_1; + ipsall += ips1; + } //18Jan2008 + if (fabs(trkth - pival / 2) < 21.5) { + ips2 = (int)mypow_2_2; + ipsall += ips2; + } //No nead for pp evt + if (fabs(trkph + pival / 2) < 21.5) { + ips3 = (int)mypow_2_3; + ipsall += ips3; + } //No nead for pp evt + + if (therr < 0.02) { + ips4 = (int)mypow_2_4; + ipsall += ips4; + } + if (pherr < 0.0002) { + ips5 = (int)mypow_2_5; + ipsall += ips5; + } + if (fabs(hoang) > 0.30) { + ips6 = (int)mypow_2_6; + ipsall += ips6; + } + if (fabs(trkmm) > 4.0) { + ips7 = (int)mypow_2_7; + ipsall += ips7; + } + if (nmuon >= 1 && nmuon <= 2) { + ips8 = (int)mypow_2_8; + ipsall += ips8; + } + + if (iring2 == 2) { + if (fabs(hodx) < 100 && fabs(hodx) > 2 && fabs(hocorsig[8]) < 40 && fabs(hocorsig[8]) > 2) { + ips10 = (int)mypow_2_10; + ipsall += ips10; + } + + if (fabs(hody) < 100 && fabs(hody) > 2 && fabs(hocorsig[9]) < 40 && fabs(hocorsig[9]) > 2) { + ips11 = (int)mypow_2_11; + ipsall += ips11; + } + + } else { + if (fabs(hodx) < 100 && fabs(hodx) > 2) { + ips10 = (int)mypow_2_10; + ipsall += ips10; + } + + if (fabs(hody) < 100 && fabs(hody) > 2) { + ips11 = (int)mypow_2_11; + ipsall += ips11; + } + } + // if (m_cosmic || (caloen[0] >0.5 && caloen[0]<5.0)) {ips12=(int)pow_2_12;ipsall +=ips12;} + if (ndof > 0 && caloen[0] < 5.0) { + ips12 = (int)mypow_2_12; + ipsall += ips12; + } + /* */ } - - if (htime >-40 && htime <60) {ips9=(int)mypow_2_9;ipsall +=ips9;} - - if (ipsall-ips0==mypow_2_ncut-mypow_2_0-1) sigvsevt[iring2][0]->Fill(abs(ndof), hosig[4]); - if (ipsall-ips1==mypow_2_ncut-mypow_2_1-1) sigvsevt[iring2][1]->Fill(chisq, hosig[4]); - if (ipsall-ips2==mypow_2_ncut-mypow_2_2-1) sigvsevt[iring2][2]->Fill(trkth, hosig[4]); - if (ipsall-ips3==mypow_2_ncut-mypow_2_3-1) sigvsevt[iring2][3]->Fill(trkph, hosig[4]); - if (ipsall-ips4==mypow_2_ncut-mypow_2_4-1) sigvsevt[iring2][4]->Fill(therr, hosig[4]); - if (ipsall-ips5==mypow_2_ncut-mypow_2_5-1) sigvsevt[iring2][5]->Fill(pherr, hosig[4]); - if (ipsall-ips6==mypow_2_ncut-mypow_2_6-1) sigvsevt[iring2][6]->Fill(hoang, hosig[4]); - if (ipsall-ips7==mypow_2_ncut-mypow_2_7-1) sigvsevt[iring2][7]->Fill(fabs(trkmm), hosig[4]); - if (ipsall-ips8==mypow_2_ncut-mypow_2_8-1) sigvsevt[iring2][8]->Fill(nmuon, hosig[4]); - if (ipsall-ips9==mypow_2_ncut-mypow_2_9-1) sigvsevt[iring2][9]->Fill(htime, hosig[4]); - if (ipsall-ips10==mypow_2_ncut-mypow_2_10-1) sigvsevt[iring2][10]->Fill(hodx, hosig[4]); - if (ipsall-ips11==mypow_2_ncut-mypow_2_11-1) sigvsevt[iring2][11]->Fill(hody, hosig[4]); + + if (htime > -40 && htime < 60) { + ips9 = (int)mypow_2_9; + ipsall += ips9; + } + + if (ipsall - ips0 == mypow_2_ncut - mypow_2_0 - 1) + sigvsevt[iring2][0]->Fill(abs(ndof), hosig[4]); + if (ipsall - ips1 == mypow_2_ncut - mypow_2_1 - 1) + sigvsevt[iring2][1]->Fill(chisq, hosig[4]); + if (ipsall - ips2 == mypow_2_ncut - mypow_2_2 - 1) + sigvsevt[iring2][2]->Fill(trkth, hosig[4]); + if (ipsall - ips3 == mypow_2_ncut - mypow_2_3 - 1) + sigvsevt[iring2][3]->Fill(trkph, hosig[4]); + if (ipsall - ips4 == mypow_2_ncut - mypow_2_4 - 1) + sigvsevt[iring2][4]->Fill(therr, hosig[4]); + if (ipsall - ips5 == mypow_2_ncut - mypow_2_5 - 1) + sigvsevt[iring2][5]->Fill(pherr, hosig[4]); + if (ipsall - ips6 == mypow_2_ncut - mypow_2_6 - 1) + sigvsevt[iring2][6]->Fill(hoang, hosig[4]); + if (ipsall - ips7 == mypow_2_ncut - mypow_2_7 - 1) + sigvsevt[iring2][7]->Fill(fabs(trkmm), hosig[4]); + if (ipsall - ips8 == mypow_2_ncut - mypow_2_8 - 1) + sigvsevt[iring2][8]->Fill(nmuon, hosig[4]); + if (ipsall - ips9 == mypow_2_ncut - mypow_2_9 - 1) + sigvsevt[iring2][9]->Fill(htime, hosig[4]); + if (ipsall - ips10 == mypow_2_ncut - mypow_2_10 - 1) + sigvsevt[iring2][10]->Fill(hodx, hosig[4]); + if (ipsall - ips11 == mypow_2_ncut - mypow_2_11 - 1) + sigvsevt[iring2][11]->Fill(hody, hosig[4]); if (!m_cosmic) { - if (ipsall-ips12==mypow_2_ncut-mypow_2_12-1) sigvsevt[iring2][12]->Fill(caloen[0], hosig[4]); + if (ipsall - ips12 == mypow_2_ncut - mypow_2_12 - 1) + sigvsevt[iring2][12]->Fill(caloen[0], hosig[4]); } - - sigvsevt[iring2+5][0]->Fill(abs(ndof), hosig[4]); - if (ips0 >0) { - sigvsevt[iring2+5][1]->Fill(chisq, hosig[4]); - if (ips1 >0) { - sigvsevt[iring2+5][2]->Fill(trkth, hosig[4]); - if (ips2 >0) { - sigvsevt[iring2+5][3]->Fill(trkph, hosig[4]); - if (ips3 >0) { - sigvsevt[iring2+5][4]->Fill(therr, hosig[4]); - if (ips4 >0) { - sigvsevt[iring2+5][5]->Fill(pherr, hosig[4]); - if (ips5 >0) { - sigvsevt[iring2+5][6]->Fill(hoang, hosig[4]); - if (ips6 >0) { - sigvsevt[iring2+5][7]->Fill(fabs(trkmm), hosig[4]); - if (ips7 >0) { - sigvsevt[iring2+5][8]->Fill(nmuon, hosig[4]); - if (ips8 >0) { - sigvsevt[iring2+5][9]->Fill(htime, hosig[4]); - if (ips9 >0) { - sigvsevt[iring2+5][10]->Fill(hodx, hosig[4]); - if (ips10>0) { - sigvsevt[iring2+5][11]->Fill(hody, hosig[4]); - if (ips11>0) { - if (!m_cosmic) sigvsevt[iring2+5][12]->Fill(caloen[0], hosig[4]); - } - } - } - } - } - } - } - } - } - } - } + + sigvsevt[iring2 + 5][0]->Fill(abs(ndof), hosig[4]); + if (ips0 > 0) { + sigvsevt[iring2 + 5][1]->Fill(chisq, hosig[4]); + if (ips1 > 0) { + sigvsevt[iring2 + 5][2]->Fill(trkth, hosig[4]); + if (ips2 > 0) { + sigvsevt[iring2 + 5][3]->Fill(trkph, hosig[4]); + if (ips3 > 0) { + sigvsevt[iring2 + 5][4]->Fill(therr, hosig[4]); + if (ips4 > 0) { + sigvsevt[iring2 + 5][5]->Fill(pherr, hosig[4]); + if (ips5 > 0) { + sigvsevt[iring2 + 5][6]->Fill(hoang, hosig[4]); + if (ips6 > 0) { + sigvsevt[iring2 + 5][7]->Fill(fabs(trkmm), hosig[4]); + if (ips7 > 0) { + sigvsevt[iring2 + 5][8]->Fill(nmuon, hosig[4]); + if (ips8 > 0) { + sigvsevt[iring2 + 5][9]->Fill(htime, hosig[4]); + if (ips9 > 0) { + sigvsevt[iring2 + 5][10]->Fill(hodx, hosig[4]); + if (ips10 > 0) { + sigvsevt[iring2 + 5][11]->Fill(hody, hosig[4]); + if (ips11 > 0) { + if (!m_cosmic) + sigvsevt[iring2 + 5][12]->Fill(caloen[0], hosig[4]); + } + } + } + } + } + } + } + } + } + } + } } - sigvsevt[iring2+10][0]->Fill(abs(ndof), hosig[4]); - sigvsevt[iring2+10][1]->Fill(chisq, hosig[4]); - sigvsevt[iring2+10][2]->Fill(trkth, hosig[4]); - sigvsevt[iring2+10][3]->Fill(trkph, hosig[4]); - sigvsevt[iring2+10][4]->Fill(therr, hosig[4]); - sigvsevt[iring2+10][5]->Fill(pherr, hosig[4]); - sigvsevt[iring2+10][6]->Fill(hoang, hosig[4]); - sigvsevt[iring2+10][7]->Fill(fabs(trkmm), hosig[4]); - sigvsevt[iring2+10][8]->Fill(nmuon, hosig[4]); - sigvsevt[iring2+10][9]->Fill(htime, hosig[4]); - sigvsevt[iring2+10][10]->Fill(hodx, hosig[4]); - sigvsevt[iring2+10][11]->Fill(hody, hosig[4]); - if (!m_cosmic) sigvsevt[iring2+10][12]->Fill(caloen[0], hosig[4]); + sigvsevt[iring2 + 10][0]->Fill(abs(ndof), hosig[4]); + sigvsevt[iring2 + 10][1]->Fill(chisq, hosig[4]); + sigvsevt[iring2 + 10][2]->Fill(trkth, hosig[4]); + sigvsevt[iring2 + 10][3]->Fill(trkph, hosig[4]); + sigvsevt[iring2 + 10][4]->Fill(therr, hosig[4]); + sigvsevt[iring2 + 10][5]->Fill(pherr, hosig[4]); + sigvsevt[iring2 + 10][6]->Fill(hoang, hosig[4]); + sigvsevt[iring2 + 10][7]->Fill(fabs(trkmm), hosig[4]); + sigvsevt[iring2 + 10][8]->Fill(nmuon, hosig[4]); + sigvsevt[iring2 + 10][9]->Fill(htime, hosig[4]); + sigvsevt[iring2 + 10][10]->Fill(hodx, hosig[4]); + sigvsevt[iring2 + 10][11]->Fill(hody, hosig[4]); + if (!m_cosmic) + sigvsevt[iring2 + 10][12]->Fill(caloen[0], hosig[4]); int iselect = (ipsall == mypow_2_ncut - 1) ? 1 : 0; - if (hocro !=-100.0 && hocro <-50.0) hocro +=100.; - + if (hocro != -100.0 && hocro < -50.0) + hocro += 100.; + muonnm->Fill(nmuon); muonmm->Fill(trkmm); - muonth->Fill(trkth*180/pival); - muonph->Fill(trkph*180/pival); + muonth->Fill(trkth * 180 / pival); + muonph->Fill(trkph * 180 / pival); muonch->Fill(chisq); - - if (iselect==1) { - ipass++; - sel_muonnm->Fill(nmuon); - sel_muonmm->Fill(trkmm); - sel_muonth->Fill(trkth*180/pival); - sel_muonph->Fill(trkph*180/pival); - sel_muonch->Fill(chisq); + + if (iselect == 1) { + ipass++; + sel_muonnm->Fill(nmuon); + sel_muonmm->Fill(trkmm); + sel_muonth->Fill(trkth * 180 / pival); + sel_muonph->Fill(trkph * 180 / pival); + sel_muonch->Fill(chisq); } // if (iselect3) T1->Fill(); - int tmpphi = (iphi + 1)%3; //pixel mapping + int tmpphi = (iphi + 1) % 3; //pixel mapping int npixel = 0; int itag = -1; int iflip = 0; int fact = 2; - - if (iring ==0) { - tmpphi = (iphi+1)%2; - if (tmpsect==2 || tmpsect==3 || tmpsect==6 || tmpsect==7 || tmpsect==10 || tmpsect==11) { - npixel = mapx0p[tmpeta][tmpphi]; - itag = 2; - } else { - npixel = mapx0m[tmpeta][tmpphi]; - itag = 3; - } - } else { - fact = 3; - if (tmpsect%2==1) iflip =1; - if (abs(iring)==1) { - npixel = mapx1[tmpeta][(iflip==0) ? tmpphi : abs(tmpphi-2)]; - itag = 1; - } else { - npixel = mapx2[tmpeta][(iflip==0) ? tmpphi : abs(tmpphi-2)]; - itag = 0; - } + + if (iring == 0) { + tmpphi = (iphi + 1) % 2; + if (tmpsect == 2 || tmpsect == 3 || tmpsect == 6 || tmpsect == 7 || tmpsect == 10 || tmpsect == 11) { + npixel = mapx0p[tmpeta][tmpphi]; + itag = 2; + } else { + npixel = mapx0m[tmpeta][tmpphi]; + itag = 3; + } + } else { + fact = 3; + if (tmpsect % 2 == 1) + iflip = 1; + if (abs(iring) == 1) { + npixel = mapx1[tmpeta][(iflip == 0) ? tmpphi : abs(tmpphi - 2)]; + itag = 1; + } else { + npixel = mapx2[tmpeta][(iflip == 0) ? tmpphi : abs(tmpphi - 2)]; + itag = 0; + } } - int tmpeta1 = (ieta>0) ? ieta -1 : -ieta +14; + int tmpeta1 = (ieta > 0) ? ieta - 1 : -ieta + 14; //Histogram filling for noise study: phi shift according to DTChamberAnalysis - int tmpphi1 = iphi -1 ; //(iphi+6 <=nphimx) ? iphi+5 : iphi+5-nphimx; - - int iselect2=0; - if (hosig[4]!=-100) { - if (m_cosmic) { - if (caloen[2]<=0.0) iselect2=1; - } else { - if (caloen[2]<=3.0) iselect2=1; - } + int tmpphi1 = iphi - 1; //(iphi+6 <=nphimx) ? iphi+5 : iphi+5-nphimx; + + int iselect2 = 0; + if (hosig[4] != -100) { + if (m_cosmic) { + if (caloen[2] <= 0.0) + iselect2 = 1; + } else { + if (caloen[2] <= 3.0) + iselect2 = 1; + } } // edm::LogInfo("HOCalib") <<"cosmic "<12) tmpsect2 = 1; - - int tmprout2 = int((tmpphi2 + 2)/3.) + 1; - if (iring==0) { - tmprout2 = int((tmpphi2 + 2)/2.) + 1; - if (tmprout2 >routmx) tmprout2 = 1; - } else { - if (tmprout2 >rout12mx) tmprout2 = 1; - } - - if (cro_ssg[tmpeta1][tmpphi2].size()<4000) { - if (hocro>alow && hocroFill(hocro); - } - } - - if (tmpphi2 >=0 && tmpphi2 Fill(hocro); - } - if (m_combined) { - com_crossg[iring2][tmprout2-1]->Fill(hocro); - com_crossg[iring2][tmproutmx]->Fill(hocro); - } + if (iselect2 == 1) { + int tmpphi2 = iphi - 1; + tmpphi2 = (iphi + 6 <= nphimx) ? iphi + 5 : iphi + 5 - nphimx; + + int tmpsect2 = int((tmpphi2 + 2) / 6.) + 1; + if (tmpsect2 > 12) + tmpsect2 = 1; + + int tmprout2 = int((tmpphi2 + 2) / 3.) + 1; + if (iring == 0) { + tmprout2 = int((tmpphi2 + 2) / 2.) + 1; + if (tmprout2 > routmx) + tmprout2 = 1; + } else { + if (tmprout2 > rout12mx) + tmprout2 = 1; + } + + if (cro_ssg[tmpeta1][tmpphi2].size() < 4000) { + if (hocro > alow && hocro < ahigh) { + if (!m_histfit) + cro_ssg[tmpeta1][tmpphi2].push_back(hocro); + crossg[tmpeta1][tmpphi2]->Fill(hocro); + } + } + + if (tmpphi2 >= 0 && tmpphi2 < nphimx) { + crossg[tmpeta1][nphimx]->Fill(hocro); + } + if (m_combined) { + com_crossg[iring2][tmprout2 - 1]->Fill(hocro); + com_crossg[iring2][tmproutmx]->Fill(hocro); + } } - if (iselect==1) { - for (int ij=0; ijFill(ieta, iphi, 1.); - } else { - if (hosig[4] >ij*m_sigma) { - sig_effi[ij]->Fill(ieta, iphi, 1.); - } - } - } - - tmpphi1 = iphi - 1; - - if (sig_reg[tmpeta1][tmpphi1].size()<4000 ) { - if (hosig[4]>-50&& hosig[4] <15) { - sigrsg[tmpeta1][tmpphi1]->Fill(hosig[4]); - if (!m_histfit && hosig[4]<=ahigh/2.) sig_reg[tmpeta1][tmpphi1].push_back(hosig[4]); - invang[tmpeta1][tmpphi1] += 1./fabs(hoang); - } - } - - if (tmpphi1 >=0 && tmpphi1 Fill(hosig[4]); - invang[tmpeta1][nphimx] += 1./fabs(hoang); - } - - if (m_combined) { //#ifdef COMBINED - com_sigrsg[iring2][tmprout-1]->Fill(hosig[4]); - com_invang[iring2][tmprout-1] += 1./fabs(hoang); - - com_sigrsg[iring2][tmproutmx]->Fill(hosig[4]); - com_invang[iring2][tmproutmx] += 1./fabs(hoang); - } //m_combined #endif - - if (m_checkmap || m_correl) { //#ifdef CHECKMAP - tmpeta = etamap[itag][npixel]; - tmpphi = phimap[itag][npixel]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - if (int((hocorsig[fact*tmpeta+tmpphi]-hosig[4])*10000)/10000.!=0) { - iaxxx++; - edm::LogInfo("HOCalib")<<"iring2xxx "<Fill(hocorsig[fact*tmpeta+tmpphi]); - if (m_combined) { //#ifdef COMBINED - com_corrsgc[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - } //m_checkmap #endif - - if (m_correl) { //#ifdef CORREL - float allcorsig = 0.0; - - tmpeta = etamap[itag][npixleft[npixel]]; - tmpphi = phimap[itag][npixleft[npixel]]; - - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsgl[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined) { //#ifdef COMBINED - com_corrsgl[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - - tmpeta = etamap[itag][npixrigh[npixel]]; - tmpphi = phimap[itag][npixrigh[npixel]]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsgr[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined) { // #ifdef COMBINED - com_corrsgr[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - - tmpeta = etamap[itag][npixlebt[npixel]]; - tmpphi = phimap[itag][npixlebt[npixel]]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsglb[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined){ //#ifdef COMBINED - com_corrsglb[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - - tmpeta = etamap[itag][npixribt[npixel]]; - tmpphi = phimap[itag][npixribt[npixel]]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsgrb[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined) { // #ifdef COMBINED - com_corrsgrb[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - - tmpeta = etamap[itag][npixleup[npixel]]; - tmpphi = phimap[itag][npixleup[npixel]]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsglu[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined) {// #ifdef COMBINED - com_corrsglu[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - - tmpeta = etamap[itag][npixriup[npixel]]; - tmpphi = phimap[itag][npixriup[npixel]]; - if (tmpeta>=0 && tmpphi >=0) { - if (iflip !=0) tmpphi = abs(tmpphi-2); - corrsgru[tmpeta1][tmpphi1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - allcorsig +=hocorsig[fact*tmpeta+tmpphi]; - if (m_combined) { // #ifdef COMBINED - com_corrsgru[iring2][tmpsect-1]->Fill(hocorsig[fact*tmpeta+tmpphi]); - } //m_combined #endif - } - corrsgall[tmpeta1][tmpphi1]->Fill(allcorsig); - if (m_combined) { // #ifdef COMBINED - com_corrsgall[iring2][tmpsect-1]->Fill(allcorsig); - } //m_combined #endif - - - } //m_correl #endif - for (int k=0; k<9; k++) { - switch (iring) - { - case 2 : ho_sig2p[k]->Fill(hosig[k]); break; - case 1 : ho_sig1p[k]->Fill(hosig[k]); break; - case 0 : ho_sig00[k]->Fill(hosig[k]); break; - case -1 : ho_sig1m[k]->Fill(hosig[k]); break; - case -2 : ho_sig2m[k]->Fill(hosig[k]); break; - } - if (m_hbinfo) { // #ifdef HBINFO - hbhe_sig[k]->Fill(hbhesig[k]); - // edm::LogInfo("HOCalib") <<"hbhe "<Fill(ieta, iphi, 1.); + } else { + if (hosig[4] > ij * m_sigma) { + sig_effi[ij]->Fill(ieta, iphi, 1.); + } + } + } + + tmpphi1 = iphi - 1; + + if (sig_reg[tmpeta1][tmpphi1].size() < 4000) { + if (hosig[4] > -50 && hosig[4] < 15) { + sigrsg[tmpeta1][tmpphi1]->Fill(hosig[4]); + if (!m_histfit && hosig[4] <= ahigh / 2.) + sig_reg[tmpeta1][tmpphi1].push_back(hosig[4]); + invang[tmpeta1][tmpphi1] += 1. / fabs(hoang); + } + } + + if (tmpphi1 >= 0 && tmpphi1 < nphimx) { //GREN + sigrsg[tmpeta1][nphimx]->Fill(hosig[4]); + invang[tmpeta1][nphimx] += 1. / fabs(hoang); + } + + if (m_combined) { //#ifdef COMBINED + com_sigrsg[iring2][tmprout - 1]->Fill(hosig[4]); + com_invang[iring2][tmprout - 1] += 1. / fabs(hoang); + + com_sigrsg[iring2][tmproutmx]->Fill(hosig[4]); + com_invang[iring2][tmproutmx] += 1. / fabs(hoang); + } //m_combined #endif + + if (m_checkmap || m_correl) { //#ifdef CHECKMAP + tmpeta = etamap[itag][npixel]; + tmpphi = phimap[itag][npixel]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + if (int((hocorsig[fact * tmpeta + tmpphi] - hosig[4]) * 10000) / 10000. != 0) { + iaxxx++; + edm::LogInfo("HOCalib") << "iring2xxx " << irun << " " << ievt << " " << isect << " " << iring << " " + << tmpsect << " " << ieta << " " << iphi << " " << npixel << " " << tmpeta << " " + << tmpphi << " " << tmpeta1 << " " << tmpphi1 << " itag " << itag << " " << iflip + << " " << fact << " " << hocorsig[fact * tmpeta + tmpphi] << " " + << fact * tmpeta + tmpphi << " " << hosig[4] << " " << hodx << " " << hody; + + for (int ij = 0; ij < 18; ij++) { + edm::LogInfo("HOCalib") << " " << ij << " " << hocorsig[ij]; + } + edm::LogInfo("HOCalib") << " ix " << iaxxx << " " << ibxxx; + } else { + ibxxx++; + } + + corrsgc[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + if (m_combined) { //#ifdef COMBINED + com_corrsgc[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + } //m_checkmap #endif + + if (m_correl) { //#ifdef CORREL + float allcorsig = 0.0; + + tmpeta = etamap[itag][npixleft[npixel]]; + tmpphi = phimap[itag][npixleft[npixel]]; + + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsgl[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { //#ifdef COMBINED + com_corrsgl[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + + tmpeta = etamap[itag][npixrigh[npixel]]; + tmpphi = phimap[itag][npixrigh[npixel]]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsgr[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { // #ifdef COMBINED + com_corrsgr[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + + tmpeta = etamap[itag][npixlebt[npixel]]; + tmpphi = phimap[itag][npixlebt[npixel]]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsglb[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { //#ifdef COMBINED + com_corrsglb[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + + tmpeta = etamap[itag][npixribt[npixel]]; + tmpphi = phimap[itag][npixribt[npixel]]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsgrb[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { // #ifdef COMBINED + com_corrsgrb[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + + tmpeta = etamap[itag][npixleup[npixel]]; + tmpphi = phimap[itag][npixleup[npixel]]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsglu[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { // #ifdef COMBINED + com_corrsglu[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + + tmpeta = etamap[itag][npixriup[npixel]]; + tmpphi = phimap[itag][npixriup[npixel]]; + if (tmpeta >= 0 && tmpphi >= 0) { + if (iflip != 0) + tmpphi = abs(tmpphi - 2); + corrsgru[tmpeta1][tmpphi1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + allcorsig += hocorsig[fact * tmpeta + tmpphi]; + if (m_combined) { // #ifdef COMBINED + com_corrsgru[iring2][tmpsect - 1]->Fill(hocorsig[fact * tmpeta + tmpphi]); + } //m_combined #endif + } + corrsgall[tmpeta1][tmpphi1]->Fill(allcorsig); + if (m_combined) { // #ifdef COMBINED + com_corrsgall[iring2][tmpsect - 1]->Fill(allcorsig); + } //m_combined #endif + + } //m_correl #endif + for (int k = 0; k < 9; k++) { + switch (iring) { + case 2: + ho_sig2p[k]->Fill(hosig[k]); + break; + case 1: + ho_sig1p[k]->Fill(hosig[k]); + break; + case 0: + ho_sig00[k]->Fill(hosig[k]); + break; + case -1: + ho_sig1m[k]->Fill(hosig[k]); + break; + case -2: + ho_sig2m[k]->Fill(hosig[k]); + break; + } + if (m_hbinfo) { // #ifdef HBINFO + hbhe_sig[k]->Fill(hbhesig[k]); + // edm::LogInfo("HOCalib") <<"hbhe "<cd(); if (m_allHOsignal) { - for (int jk=0; jkGetNbinsX(); jk++) { - for (int kl=0; klGetNbinsY(); kl++) { - double entry=ho_entry->GetBinContent(jk+1, kl+1); - if (entry <1.) entry=1.; - - double energy = ho_energy->GetBinContent(jk+1, kl+1)/entry; - double energy2 = ho_energy2->GetBinContent(jk+1, kl+1)/entry; - double rms = sqrt(energy2 - energy*energy); - - double xval = ho_energy->GetXaxis()->GetBinCenter(jk+1); - double yval = ho_energy->GetYaxis()->GetBinCenter(kl+1); - - ho_rms->Fill(xval, yval, rms); + for (int jk = 0; jk < ho_energy->GetNbinsX(); jk++) { + for (int kl = 0; kl < ho_energy->GetNbinsY(); kl++) { + double entry = ho_entry->GetBinContent(jk + 1, kl + 1); + if (entry < 1.) + entry = 1.; + + double energy = ho_energy->GetBinContent(jk + 1, kl + 1) / entry; + double energy2 = ho_energy2->GetBinContent(jk + 1, kl + 1) / entry; + double rms = sqrt(energy2 - energy * energy); + + double xval = ho_energy->GetXaxis()->GetBinCenter(jk + 1); + double yval = ho_energy->GetYaxis()->GetBinCenter(kl + 1); + + ho_rms->Fill(xval, yval, rms); } } - } - - for (int ij=0; ijFill(netamx*ij+jk, sigrsg[jk][ij]->GetEntries()); - mnsigrsg->Fill(netamx*ij+jk, sigrsg[jk][ij]->GetMean()); - rmssigrsg->Fill(netamx*ij+jk, sigrsg[jk][ij]->GetRMS()); - - nevcrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetEntries()); - mncrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetMean()); - rmscrossg->Fill(netamx*ij+jk, crossg[jk][ij]->GetRMS()); - - if (m_correl) { //#ifdef CORREL - - nevcorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetEntries()); - mncorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetMean()); - rmscorrsglb->Fill(netamx*ij+jk, corrsglb[jk][ij]->GetRMS()); - - nevcorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetEntries()); - mncorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetMean()); - rmscorrsgrb->Fill(netamx*ij+jk, corrsgrb[jk][ij]->GetRMS()); - - nevcorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetEntries()); - mncorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetMean()); - rmscorrsglu->Fill(netamx*ij+jk, corrsglu[jk][ij]->GetRMS()); - - nevcorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetEntries()); - mncorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetMean()); - rmscorrsgru->Fill(netamx*ij+jk, corrsgru[jk][ij]->GetRMS()); - - nevcorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetEntries()); - mncorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetMean()); - rmscorrsgall->Fill(netamx*ij+jk, corrsgall[jk][ij]->GetRMS()); - - nevcorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetEntries()); - mncorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetMean()); - rmscorrsgl->Fill(netamx*ij+jk, corrsgl[jk][ij]->GetRMS()); - - nevcorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetEntries()); - mncorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetMean()); - rmscorrsgr->Fill(netamx*ij+jk, corrsgr[jk][ij]->GetRMS()); - } //m_correl #endif - if (m_checkmap) { //#ifdef CHECKMAP - nevcorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetEntries()); - mncorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetMean()); - rmscorrsgc->Fill(netamx*ij+jk, corrsgc[jk][ij]->GetRMS()); - } //m_checkmap #endif + } + + for (int ij = 0; ij < nphimx; ij++) { + for (int jk = 0; jk < netamx; jk++) { + nevsigrsg->Fill(netamx * ij + jk, sigrsg[jk][ij]->GetEntries()); + mnsigrsg->Fill(netamx * ij + jk, sigrsg[jk][ij]->GetMean()); + rmssigrsg->Fill(netamx * ij + jk, sigrsg[jk][ij]->GetRMS()); + + nevcrossg->Fill(netamx * ij + jk, crossg[jk][ij]->GetEntries()); + mncrossg->Fill(netamx * ij + jk, crossg[jk][ij]->GetMean()); + rmscrossg->Fill(netamx * ij + jk, crossg[jk][ij]->GetRMS()); + + if (m_correl) { //#ifdef CORREL + + nevcorrsglb->Fill(netamx * ij + jk, corrsglb[jk][ij]->GetEntries()); + mncorrsglb->Fill(netamx * ij + jk, corrsglb[jk][ij]->GetMean()); + rmscorrsglb->Fill(netamx * ij + jk, corrsglb[jk][ij]->GetRMS()); + + nevcorrsgrb->Fill(netamx * ij + jk, corrsgrb[jk][ij]->GetEntries()); + mncorrsgrb->Fill(netamx * ij + jk, corrsgrb[jk][ij]->GetMean()); + rmscorrsgrb->Fill(netamx * ij + jk, corrsgrb[jk][ij]->GetRMS()); + + nevcorrsglu->Fill(netamx * ij + jk, corrsglu[jk][ij]->GetEntries()); + mncorrsglu->Fill(netamx * ij + jk, corrsglu[jk][ij]->GetMean()); + rmscorrsglu->Fill(netamx * ij + jk, corrsglu[jk][ij]->GetRMS()); + + nevcorrsgru->Fill(netamx * ij + jk, corrsgru[jk][ij]->GetEntries()); + mncorrsgru->Fill(netamx * ij + jk, corrsgru[jk][ij]->GetMean()); + rmscorrsgru->Fill(netamx * ij + jk, corrsgru[jk][ij]->GetRMS()); + + nevcorrsgall->Fill(netamx * ij + jk, corrsgall[jk][ij]->GetEntries()); + mncorrsgall->Fill(netamx * ij + jk, corrsgall[jk][ij]->GetMean()); + rmscorrsgall->Fill(netamx * ij + jk, corrsgall[jk][ij]->GetRMS()); + + nevcorrsgl->Fill(netamx * ij + jk, corrsgl[jk][ij]->GetEntries()); + mncorrsgl->Fill(netamx * ij + jk, corrsgl[jk][ij]->GetMean()); + rmscorrsgl->Fill(netamx * ij + jk, corrsgl[jk][ij]->GetRMS()); + + nevcorrsgr->Fill(netamx * ij + jk, corrsgr[jk][ij]->GetEntries()); + mncorrsgr->Fill(netamx * ij + jk, corrsgr[jk][ij]->GetMean()); + rmscorrsgr->Fill(netamx * ij + jk, corrsgr[jk][ij]->GetRMS()); + } //m_correl #endif + if (m_checkmap) { //#ifdef CHECKMAP + nevcorrsgc->Fill(netamx * ij + jk, corrsgc[jk][ij]->GetEntries()); + mncorrsgc->Fill(netamx * ij + jk, corrsgc[jk][ij]->GetMean()); + rmscorrsgc->Fill(netamx * ij + jk, corrsgc[jk][ij]->GetRMS()); + } //m_checkmap #endif } } - if (m_combined) { // #ifdef COMBINED - for (int jk=0; jk=rout12mx) continue; - nevsigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetEntries()); - mnsigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetMean()); - rmssigrsg->Fill(netamx*nphimx+ringmx*ij+jk, com_sigrsg[jk][ij]->GetRMS()); - - nevcrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetEntries()); - mncrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetMean()); - rmscrossg->Fill(netamx*nphimx+ringmx*ij+jk, com_crossg[jk][ij]->GetRMS()); + if (m_combined) { // #ifdef COMBINED + for (int jk = 0; jk < ringmx; jk++) { + for (int ij = 0; ij < routmx; ij++) { + if (jk != 2 && ij >= rout12mx) + continue; + nevsigrsg->Fill(netamx * nphimx + ringmx * ij + jk, com_sigrsg[jk][ij]->GetEntries()); + mnsigrsg->Fill(netamx * nphimx + ringmx * ij + jk, com_sigrsg[jk][ij]->GetMean()); + rmssigrsg->Fill(netamx * nphimx + ringmx * ij + jk, com_sigrsg[jk][ij]->GetRMS()); + + nevcrossg->Fill(netamx * nphimx + ringmx * ij + jk, com_crossg[jk][ij]->GetEntries()); + mncrossg->Fill(netamx * nphimx + ringmx * ij + jk, com_crossg[jk][ij]->GetMean()); + rmscrossg->Fill(netamx * nphimx + ringmx * ij + jk, com_crossg[jk][ij]->GetRMS()); } } - for (int ij=0; ijFill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetEntries()); - mncorrsglb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetMean()); - rmscorrsglb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglb[jk][ij]->GetRMS()); - - nevcorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetEntries()); - mncorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetMean()); - rmscorrsgrb->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgrb[jk][ij]->GetRMS()); - - nevcorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetEntries()); - mncorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetMean()); - rmscorrsglu->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsglu[jk][ij]->GetRMS()); - - nevcorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetEntries()); - mncorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetMean()); - rmscorrsgru->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgru[jk][ij]->GetRMS()); - - nevcorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetEntries()); - mncorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetMean()); - rmscorrsgall->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgall[jk][ij]->GetRMS()); - - nevcorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetEntries()); - mncorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetMean()); - rmscorrsgl->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgl[jk][ij]->GetRMS()); - - nevcorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetEntries()); - mncorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetMean()); - rmscorrsgr->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgr[jk][ij]->GetRMS()); - } //m_correl #endif - if (m_checkmap) { // #ifdef CHECKMAP - nevcorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetEntries()); - mncorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetMean()); - rmscorrsgc->Fill(netamx*nphimx+ringmx*ij+jk, com_corrsgc[jk][ij]->GetRMS()); - } //m_checkmap #endif + for (int ij = 0; ij < sectmx; ij++) { + for (int jk = 0; jk < ringmx; jk++) { + if (m_correl) { // #ifdef CORREL + nevcorrsglb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglb[jk][ij]->GetEntries()); + mncorrsglb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglb[jk][ij]->GetMean()); + rmscorrsglb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglb[jk][ij]->GetRMS()); + + nevcorrsgrb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgrb[jk][ij]->GetEntries()); + mncorrsgrb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgrb[jk][ij]->GetMean()); + rmscorrsgrb->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgrb[jk][ij]->GetRMS()); + + nevcorrsglu->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglu[jk][ij]->GetEntries()); + mncorrsglu->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglu[jk][ij]->GetMean()); + rmscorrsglu->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsglu[jk][ij]->GetRMS()); + + nevcorrsgru->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgru[jk][ij]->GetEntries()); + mncorrsgru->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgru[jk][ij]->GetMean()); + rmscorrsgru->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgru[jk][ij]->GetRMS()); + + nevcorrsgall->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgall[jk][ij]->GetEntries()); + mncorrsgall->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgall[jk][ij]->GetMean()); + rmscorrsgall->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgall[jk][ij]->GetRMS()); + + nevcorrsgl->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgl[jk][ij]->GetEntries()); + mncorrsgl->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgl[jk][ij]->GetMean()); + rmscorrsgl->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgl[jk][ij]->GetRMS()); + + nevcorrsgr->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgr[jk][ij]->GetEntries()); + mncorrsgr->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgr[jk][ij]->GetMean()); + rmscorrsgr->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgr[jk][ij]->GetRMS()); + } //m_correl #endif + if (m_checkmap) { // #ifdef CHECKMAP + nevcorrsgc->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgc[jk][ij]->GetEntries()); + mncorrsgc->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgc[jk][ij]->GetMean()); + rmscorrsgc->Fill(netamx * nphimx + ringmx * ij + jk, com_corrsgc[jk][ij]->GetRMS()); + } //m_checkmap #endif } } - } //m_combined #endif + } //m_combined #endif - - for (int ij=1; ijDivide(sig_effi[0]); } - for (int ij=0; ijGetMean(); mean_energy->Fill(ieta, iphi, signal); } - } - - int irunold = irun; + } + int irunold = irun; gStyle->SetOptLogy(0); gStyle->SetTitleFillColor(10); gStyle->SetStatColor(10); - + gStyle->SetCanvasColor(10); - gStyle->SetOptStat(0); //1110); + gStyle->SetOptStat(0); //1110); gStyle->SetOptTitle(1); gStyle->SetTitleColor(10); @@ -1710,10 +1847,10 @@ HOCalibAnalyzer::endJob() { gStyle->SetStatY(.99); gStyle->SetStatW(.45); gStyle->SetStatH(.16); - gStyle->SetLabelSize(0.075,"XY"); - gStyle->SetLabelOffset(0.21,"XYZ"); - gStyle->SetTitleSize(0.065,"XY"); - gStyle->SetTitleOffset(0.06,"XYZ"); + gStyle->SetLabelSize(0.075, "XY"); + gStyle->SetLabelOffset(0.21, "XYZ"); + gStyle->SetTitleSize(0.065, "XY"); + gStyle->SetTitleOffset(0.06, "XYZ"); gStyle->SetPadTopMargin(.09); gStyle->SetPadBottomMargin(0.11); gStyle->SetPadLeftMargin(0.12); @@ -1721,7 +1858,7 @@ HOCalibAnalyzer::endJob() { gStyle->SetPadGridX(true); gStyle->SetPadGridY(true); gStyle->SetGridStyle(2); - gStyle->SetNdivisions(303,"XY"); + gStyle->SetNdivisions(303, "XY"); gStyle->SetMarkerSize(0.60); gStyle->SetMarkerColor(2); @@ -1732,55 +1869,55 @@ HOCalibAnalyzer::endJob() { int xsiz = 700; int ysiz = 500; -// TCanvas *c2 = new TCanvas("c2", "Statistics and efficiency", xsiz, ysiz); -// c2->Divide(2,1); //(3,2); -// for (int ij=0; ijGetXaxis()->SetTitle("#eta"); -// sig_effi[ij]->GetXaxis()->SetTitleSize(0.075); -// sig_effi[ij]->GetXaxis()->SetTitleOffset(0.65); //0.85 -// sig_effi[ij]->GetXaxis()->CenterTitle(); -// sig_effi[ij]->GetXaxis()->SetLabelSize(0.055); -// sig_effi[ij]->GetXaxis()->SetLabelOffset(0.001); - -// sig_effi[ij]->GetYaxis()->SetTitle("#phi"); -// sig_effi[ij]->GetYaxis()->SetTitleSize(0.075); -// sig_effi[ij]->GetYaxis()->SetTitleOffset(0.9); -// sig_effi[ij]->GetYaxis()->CenterTitle(); -// sig_effi[ij]->GetYaxis()->SetLabelSize(0.055); -// sig_effi[ij]->GetYaxis()->SetLabelOffset(0.01); - -// c2->cd(int(ij/3.)+1); sig_effi[ij]->Draw("colz"); -// } -// sprintf(out_file, "comb_hosig_evt_%i.jpg",irunold); -// c2->SaveAs(out_file); - -// gStyle->SetTitleFontSize(0.045); -// gStyle->SetPadRightMargin(0.1); -// gStyle->SetPadLeftMargin(0.1); -// gStyle->SetPadBottomMargin(0.12); - -// TCanvas *c1 = new TCanvas("c1", "Mean signal in each tower", xsiz, ysiz); - -// mean_energy->GetXaxis()->SetTitle("#eta"); -// mean_energy->GetXaxis()->SetTitleSize(0.075); -// mean_energy->GetXaxis()->SetTitleOffset(0.65); //0.6 -// mean_energy->GetXaxis()->CenterTitle(); -// mean_energy->GetXaxis()->SetLabelSize(0.045); -// mean_energy->GetXaxis()->SetLabelOffset(0.001); - -// mean_energy->GetYaxis()->SetTitle("#phi"); -// mean_energy->GetYaxis()->SetTitleSize(0.075); -// mean_energy->GetYaxis()->SetTitleOffset(0.5); -// mean_energy->GetYaxis()->CenterTitle(); -// mean_energy->GetYaxis()->SetLabelSize(0.045); -// mean_energy->GetYaxis()->SetLabelOffset(0.01); - -// mean_energy->Draw("colz"); -// sprintf(out_file, "homean_energy_%i.jpg",irunold); -// c1->SaveAs(out_file); - -// delete c1; -// delete c2; + // TCanvas *c2 = new TCanvas("c2", "Statistics and efficiency", xsiz, ysiz); + // c2->Divide(2,1); //(3,2); + // for (int ij=0; ijGetXaxis()->SetTitle("#eta"); + // sig_effi[ij]->GetXaxis()->SetTitleSize(0.075); + // sig_effi[ij]->GetXaxis()->SetTitleOffset(0.65); //0.85 + // sig_effi[ij]->GetXaxis()->CenterTitle(); + // sig_effi[ij]->GetXaxis()->SetLabelSize(0.055); + // sig_effi[ij]->GetXaxis()->SetLabelOffset(0.001); + + // sig_effi[ij]->GetYaxis()->SetTitle("#phi"); + // sig_effi[ij]->GetYaxis()->SetTitleSize(0.075); + // sig_effi[ij]->GetYaxis()->SetTitleOffset(0.9); + // sig_effi[ij]->GetYaxis()->CenterTitle(); + // sig_effi[ij]->GetYaxis()->SetLabelSize(0.055); + // sig_effi[ij]->GetYaxis()->SetLabelOffset(0.01); + + // c2->cd(int(ij/3.)+1); sig_effi[ij]->Draw("colz"); + // } + // sprintf(out_file, "comb_hosig_evt_%i.jpg",irunold); + // c2->SaveAs(out_file); + + // gStyle->SetTitleFontSize(0.045); + // gStyle->SetPadRightMargin(0.1); + // gStyle->SetPadLeftMargin(0.1); + // gStyle->SetPadBottomMargin(0.12); + + // TCanvas *c1 = new TCanvas("c1", "Mean signal in each tower", xsiz, ysiz); + + // mean_energy->GetXaxis()->SetTitle("#eta"); + // mean_energy->GetXaxis()->SetTitleSize(0.075); + // mean_energy->GetXaxis()->SetTitleOffset(0.65); //0.6 + // mean_energy->GetXaxis()->CenterTitle(); + // mean_energy->GetXaxis()->SetLabelSize(0.045); + // mean_energy->GetXaxis()->SetLabelOffset(0.001); + + // mean_energy->GetYaxis()->SetTitle("#phi"); + // mean_energy->GetYaxis()->SetTitleSize(0.075); + // mean_energy->GetYaxis()->SetTitleOffset(0.5); + // mean_energy->GetYaxis()->CenterTitle(); + // mean_energy->GetYaxis()->SetLabelSize(0.045); + // mean_energy->GetYaxis()->SetLabelOffset(0.01); + + // mean_energy->Draw("colz"); + // sprintf(out_file, "homean_energy_%i.jpg",irunold); + // c1->SaveAs(out_file); + + // delete c1; + // delete c2; gStyle->SetPadBottomMargin(0.14); gStyle->SetPadLeftMargin(0.17); @@ -1788,19 +1925,18 @@ HOCalibAnalyzer::endJob() { gStyle->SetOptStat(1110); - const int nsample =8; - TF1* gx0[nsample]={nullptr}; - TF1* ped0fun[nsample]={nullptr}; - TF1* signal[nsample]={nullptr}; - TF1* pedfun[nsample]={nullptr}; - TF1* sigfun[nsample]={nullptr}; - TF1* signalx[nsample]={nullptr}; - - TH1F* signall[nsample]={nullptr}; - TH1F* pedstll[nsample]={nullptr}; + const int nsample = 8; + TF1* gx0[nsample] = {nullptr}; + TF1* ped0fun[nsample] = {nullptr}; + TF1* signal[nsample] = {nullptr}; + TF1* pedfun[nsample] = {nullptr}; + TF1* sigfun[nsample] = {nullptr}; + TF1* signalx[nsample] = {nullptr}; - if (m_constant) { + TH1F* signall[nsample] = {nullptr}; + TH1F* pedstll[nsample] = {nullptr}; + if (m_constant) { gStyle->SetOptFit(101); gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); @@ -1810,7 +1946,7 @@ HOCalibAnalyzer::endJob() { gStyle->SetTitleFontSize(0.09); gStyle->SetTitleOffset(-0.05); gStyle->SetTitleBorderSize(1); - + gStyle->SetCanvasColor(10); gStyle->SetPadColor(10); gStyle->SetStatColor(10); @@ -1819,36 +1955,41 @@ HOCalibAnalyzer::endJob() { gStyle->SetStatY(0.99); gStyle->SetStatW(0.30); gStyle->SetStatH(0.10); - gStyle->SetTitleSize(0.065,"XYZ"); - gStyle->SetLabelSize(0.075,"XYZ"); - gStyle->SetLabelOffset(0.012,"XYZ"); + gStyle->SetTitleSize(0.065, "XYZ"); + gStyle->SetLabelSize(0.075, "XYZ"); + gStyle->SetLabelOffset(0.012, "XYZ"); gStyle->SetPadGridX(true); gStyle->SetPadGridY(true); gStyle->SetGridStyle(3); - gStyle->SetNdivisions(101,"XY"); + gStyle->SetNdivisions(101, "XY"); gStyle->SetOptLogy(0); int iiter = 0; - std::ofstream file_out(theoutputtxtFile.c_str()); // TPostScript* ps=0; - int ips=111; - TPostScript ps(theoutputpsFile.c_str(),ips); - ps.Range(20,28); + int ips = 111; + TPostScript ps(theoutputpsFile.c_str(), ips); + ps.Range(20, 28); - xsiz = 900; //900; - ysiz = 1200; //600; - TCanvas *c0 = new TCanvas("c0", " Pedestal vs signal", xsiz, ysiz); + xsiz = 900; //900; + ysiz = 1200; //600; + TCanvas* c0 = new TCanvas("c0", " Pedestal vs signal", xsiz, ysiz); -// Fix is done for eta-phi + // Fix is done for eta-phi float mean_eta[netamx]; float mean_phi[nphimx]; float rms_eta[netamx]; float rms_phi[nphimx]; - for (int ij=0; ij=rout12mx) continue; - int izone = iiter%nsample; - - if (iijj==0) { - int iread = (jk==2) ? routmx : rout12mx; - signall[izone] = (TH1F*)com_sigrsg[jk][iread]->Clone("hnew"); - pedstll[izone] = (TH1F*)com_crossg[jk][iread]->Clone("hnew"); - } else if (iijj==1) { - signall[izone] = (TH1F*)com_sigrsg[jk][ij]->Clone("hnew"); - pedstll[izone] = (TH1F*)com_crossg[jk][ij]->Clone("hnew"); - } else if (iijj==2) { - signall[izone] = (TH1F*)sigrsg[jk][nphimx]->Clone("hnew"); - pedstll[izone] = (TH1F*)crossg[jk][nphimx]->Clone("hnew"); - } else if (iijj==3) { - signall[izone] = (TH1F*)sigrsg[jk][ij]->Clone("hnew"); - pedstll[izone] = (TH1F*)crossg[jk][ij]->Clone("hnew"); - } - pedstll[izone]->SetLineWidth(2); - signall[izone]->SetLineWidth(2); - pedstll[izone]->SetLineColor(2); - signall[izone]->SetLineColor(4); - pedstll[izone]->SetNdivisions(506,"XY"); - signall[izone]->SetNdivisions(506,"XY"); - - signall[izone]->GetXaxis()->SetLabelSize(.065); - signall[izone]->GetYaxis()->SetLabelSize(.06); - signall[izone]->GetXaxis()->SetTitle("Signal (GeV)"); - - signall[izone]->GetXaxis()->SetTitleSize(.065); - signall[izone]->GetXaxis()->CenterTitle(); - - if (izone==0) { //iiter%8 ==0) { - ps.NewPage(); - c0->Divide(4,4); //c0->Divide(2,4); // c0->Divide(1,2); - } - c0->cd(2*izone+1); // (iiter%8)+1); //c0->cd(iiter%8+1); - - /* + for (int jk = mneta; jk < mxeta; jk++) { + for (int ij = mnphi; ij < mxphi; ij++) { + if (iijj == 1) + continue; + if ((iijj == 0 || iijj == 1) && jk != 2 && ij >= rout12mx) + continue; + int izone = iiter % nsample; + + if (iijj == 0) { + int iread = (jk == 2) ? routmx : rout12mx; + signall[izone] = (TH1F*)com_sigrsg[jk][iread]->Clone("hnew"); + pedstll[izone] = (TH1F*)com_crossg[jk][iread]->Clone("hnew"); + } else if (iijj == 1) { + signall[izone] = (TH1F*)com_sigrsg[jk][ij]->Clone("hnew"); + pedstll[izone] = (TH1F*)com_crossg[jk][ij]->Clone("hnew"); + } else if (iijj == 2) { + signall[izone] = (TH1F*)sigrsg[jk][nphimx]->Clone("hnew"); + pedstll[izone] = (TH1F*)crossg[jk][nphimx]->Clone("hnew"); + } else if (iijj == 3) { + signall[izone] = (TH1F*)sigrsg[jk][ij]->Clone("hnew"); + pedstll[izone] = (TH1F*)crossg[jk][ij]->Clone("hnew"); + } + + pedstll[izone]->SetLineWidth(2); + signall[izone]->SetLineWidth(2); + pedstll[izone]->SetLineColor(2); + signall[izone]->SetLineColor(4); + pedstll[izone]->SetNdivisions(506, "XY"); + signall[izone]->SetNdivisions(506, "XY"); + + signall[izone]->GetXaxis()->SetLabelSize(.065); + signall[izone]->GetYaxis()->SetLabelSize(.06); + signall[izone]->GetXaxis()->SetTitle("Signal (GeV)"); + + signall[izone]->GetXaxis()->SetTitleSize(.065); + signall[izone]->GetXaxis()->CenterTitle(); + + if (izone == 0) { //iiter%8 ==0) { + ps.NewPage(); + c0->Divide(4, 4); //c0->Divide(2,4); // c0->Divide(1,2); + } + c0->cd(2 * izone + 1); // (iiter%8)+1); //c0->cd(iiter%8+1); + + /* if (iijj==0 && izone==0) { gStyle->SetOptLogy(1); gStyle->SetOptStat(0); @@ -1944,520 +2097,602 @@ HOCalibAnalyzer::endJob() { if (iijj==0) {c0->cd(izone+1); } else { c0->cd(2*izone+1);} */ - float mean = pedstll[izone]->GetMean(); - float rms = pedstll[izone]->GetRMS(); - - if (rms <0.10) rms = 0.10; - if (rms >0.15) rms=0.15; - if (mean >0.20) mean = 0.20; - if (mean <-0.20) mean = -0.20; - - float xmn = mean-6.*rms; - float xmx = mean+6.*rms; - - binwid = pedstll[izone]->GetBinWidth(1); - if (xmx > pedstll[izone]->GetXaxis()->GetXmax()) xmx = pedstll[izone]->GetXaxis()->GetXmax()-0.5*binwid; - if (xmn < pedstll[izone]->GetXaxis()->GetXmin()) xmn = pedstll[izone]->GetXaxis()->GetXmin()+0.5*binwid; - - float height = pedstll[izone]->GetEntries(); - - double par[nbgpr] ={height, mean, 0.75*rms}; - - double gaupr[nbgpr]; - double parer[nbgpr]; - - ietafit = jk; - iphifit = ij; - pedstll[izone]->GetXaxis()->SetLabelSize(.065); - pedstll[izone]->GetYaxis()->SetLabelSize(.06); - - // if (iijj==0) { - // pedstll[izone]->GetXaxis()->SetRangeUser(alow, ahigh); - // } else { - pedstll[izone]->GetXaxis()->SetRangeUser(xmn, xmx); - // } - - if (iijj==0) { - pedstll[izone]->GetXaxis()->SetTitle("Pedestal/Signal (GeV)"); - } else { - pedstll[izone]->GetXaxis()->SetTitle("Pedestal (GeV)"); - } - pedstll[izone]->GetXaxis()->SetTitleSize(.065); - pedstll[izone]->GetXaxis()->CenterTitle(); - // pedstll[izone]->SetLineWidth(2); - - pedstll[izone]->Draw(); - if (m_pedsuppr) { - gaupr[0] = 0; - gaupr[1] = 0.0; // pedmean[ietafit][iphifit]; - gaupr[2] = 0.15; //GMA need from database - parer[0] = parer[1] = parer[2] = 0; - } else { - - if (pedstll[izone]->GetEntries() >5) { - - if ((iijj!=3) || m_histfit) { - char temp[20]; - sprintf(temp, "gx0_%i",izone); - gx0[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); - gx0[izone]->SetParameters(par); - gx0[izone]->SetLineWidth(1); - pedstll[izone]->Fit(gx0[izone], "R+"); - - for (int k=0; kGetParError(k); - gaupr[k] = gx0[izone]->GetParameter(k); - } - } else { - double strt[nbgpr] = {height, mean, 0.75*rms}; - double step[nbgpr] = {1.0, 0.001, 0.001}; - double alowmn[nbgpr] = {0.5*height, mean-rms, 0.3*rms}; - double ahighmn[nbgpr] ={1.5*height, mean+rms, 1.5*rms}; - - TMinuit *gMinuit = new TMinuit(nbgpr); - gMinuit->SetFCN(fcnbg); - - double arglist[10]; - int ierflg = 0; - arglist[0] =0.5; - gMinuit->mnexcm("SET ERR", arglist, 1, ierflg); - char name[100]; - for (int k=0; kmnparm(k, name, strt[k], step[k], alowmn[k], ahighmn[k],ierflg); - } - - arglist[0] = 0; - gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg); - - arglist[0] = 0; - gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg); - - TString chnam; - double parv,err,xlo,xup, plerr, mierr, eparab, gcc; - int iuit; - - for (int k=0; k-10) { - gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit); - gMinuit->mnerrs(k, plerr, mierr, eparab, gcc); - // edm::LogInfo("HOCalib") <<"k "<< k<<" "<SetParameters(gaupr); - - char temp[20]; - sprintf(temp, "ped0fun_%i",izone); - ped0fun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); - ped0fun[izone]->SetParameters(gaupr); - ped0fun[izone]->SetLineColor(3); - ped0fun[izone]->SetLineWidth(1); - ped0fun[izone]->Draw("same"); - - delete gMinuit; - } - } else { - for (int k=0; kcd(2*izone+2); - if (signall[izone]->GetEntries() >5) { - Double_t parall[nsgpr]; - double parserr[nsgpr]; - double fitres[nsgpr]; - double pedht = 0; - - char temp[20]; - sprintf(temp, "signal_%i",izone); - xmn = signall[izone]->GetXaxis()->GetXmin(); - xmx = 0.5*signall[izone]->GetXaxis()->GetXmax(); - signal[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr); - xmx *=2.0; - if ((iijj!=3) || m_histfit) { - pedht = (signall[izone]->GetBinContent(nbn-1)+ - signall[izone]->GetBinContent(nbn)+ - signall[izone]->GetBinContent(nbn+1))/3.; - - if (m_pedsuppr) { - parall[1] = 0.0; // pedmean[ietafit][iphifit]; - parall[2] = 0.15; - } else { - for (int lm=0; lmGetEntries(); - parall[5]= area; - - if (iijj==3) { - parall[4] = fitprm[4][jk]; - parall[6] = fitprm[6][jk]; - } else { - parall[4] = signall[izone]->GetMean(); - parall[6]=parall[2]; - } - - signal[izone]->SetParameters(parall); - signal[izone]->FixParameter(1, parall[1]); - signal[izone]->FixParameter(2, parall[2]); - signal[izone]->SetParLimits(0, 0.00, 2.0*pedht+0.1); - signal[izone]->FixParameter(3, 0.14); - - signal[izone]->SetParLimits(5, 0.40*area, 1.15*area); - // if (m_histfit) { //GMA - if (iijj==3) { - signal[izone]->SetParLimits(4, 0.2*fitprm[4][jk], 2.0*fitprm[4][jk]); - signal[izone]->SetParLimits(6, 0.2*fitprm[6][jk], 2.0*fitprm[6][jk]); - } else { - signal[izone]->SetParLimits(4, 0.1, 1.0); - signal[izone]->SetParLimits(6, 0.035, 0.3); - } - signal[izone]->SetParNames("const", "mean", "sigma","Width","MP","Area","GSigma"); - signall[izone]->Fit(signal[izone], "0R+"); - - signall[izone]->GetXaxis()->SetRangeUser(xmn,xmx); - for (int k=0; kGetParameter(k); - parserr[k] = signal[izone]->GetParError(k); - } - - } else { - double pedhtx = 0; - for (unsigned i =0; igaupr[1]-3*gaupr[2] && sig_reg[ietafit][iphifit][ij]GetEntries(), fitprm[6][jk]}; - double alowmn[nsgpr] = {0.1*pedhtx-0.1, gaupr[1]-0.1, gaupr[2]-0.1,0.07, 0.2*strt[4], 0.1*strt[5], 0.2*strt[6]}; - double ahighmn[nsgpr] ={1.2*pedhtx+0.1, gaupr[1]+0.1, gaupr[2]+0.1,0.20, 2.5*strt[4], 1.5*strt[5], 2.2*strt[6]}; - double step[nsgpr] = {1.0, 0.0, 0.0, 0.0, 0.001, 1.0, 0.002}; - - TMinuit *gMinuit = new TMinuit(nsgpr); - gMinuit->SetFCN(fcnsg); - - double arglist[10]; - int ierflg = 0; - arglist[0] =0.5; - gMinuit->mnexcm("SET ERR", arglist, 1, ierflg); - - for (int k=0; kmnparm(k, name[k], strt[k], step[k], alowmn[k], ahighmn[k],ierflg); - } - - arglist[0] = 0; - gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg); - - arglist[0] = 0; - gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg); - - TString chnam; - double parv,err,xlo,xup, plerr, mierr, eparab, gcc; - int iuit; - - for (int k=0; k-10) { - gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit); - gMinuit->mnerrs(k, plerr, mierr, eparab, gcc); - if (k==0 || k==5) { - fitres[k] = parv*binwid; - parserr[k]= err*binwid; - } else { - fitres[k] = parv; - parserr[k]= err; - } - - } - } - - delete gMinuit; - } - - // if (iijj==0) { - // signall[izone]->Draw("same"); - // } else { - signall[izone]->Draw(); - // } - - sprintf(temp, "pedfun_%i",izone); - pedfun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); - pedfun[izone]->SetParameters(fitres); - pedfun[izone]->SetLineColor(3); - pedfun[izone]->SetLineWidth(1); - pedfun[izone]->Draw("same"); - - sprintf(temp, "signalfun_%i",izone); - sigfun[izone] = new TF1(temp, langaufun, xmn, xmx, nsgpr-nbgpr); - sigfun[izone]->SetParameters(&fitres[3]); - sigfun[izone]->SetLineWidth(1); - sigfun[izone]->SetLineColor(4); - sigfun[izone]->Draw("same"); - - sprintf(temp, "total_%i",izone); - signalx[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr); - signalx[izone]->SetParameters(fitres); - signalx[izone]->SetLineWidth(1); - signalx[izone]->Draw("same"); - - int kl = (jk<15) ? jk+1 : 14-jk; - - edm::LogInfo("HOCalib")<<"histinfo"<GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <GetChisquare()<<" " - <GetNDF(); - - file_out<<"histinfo"<GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <GetChisquare()<<" " - <GetNDF()<Fill(ifl,pedstll[izone]->GetEntries()); - ped_mean->Fill(ifl,gaupr[1]); - ped_width->Fill(ifl,gaupr[2]); - fit_chi->Fill(ifl,signal[izone]->GetChisquare()); - sig_evt->Fill(ifl, signall[izone]->GetEntries()); - fit_sigevt->Fill(ifl, fitres[5]); - fit_bkgevt->Fill(ifl, fitres[0]*sqrt(2*acos(-1.))*gaupr[2]); - sig_mean->Fill(ifl, fitres[4]); - sig_diff->Fill(ifl, fitres[4]-fitres[1]); - sig_width->Fill(ifl, fitres[3]); - sig_sigma->Fill(ifl, fitres[6]); - sig_meanerr->Fill(ifl, parserr[4]); - if (fitres[4]-fitres[1] !=0) sig_meanerrp->Fill(ifl, 100*parserr[4]/(fitres[4]-fitres[1])); - if (gaupr[2]!=0) sig_signf->Fill(ifl,(fitres[4]-fitres[1])/gaupr[2]); - - ped_statmean->Fill(ifl,pedstll[izone]->GetMean()); - sig_statmean->Fill(ifl,signall[izone]->GetMean()); - ped_rms->Fill(ifl,pedstll[izone]->GetRMS()); - sig_rms->Fill(ifl,signall[izone]->GetRMS()); - } - - if ((iijj==2) || (iijj==3) || (iijj==1)) { - if (signall[izone]->GetEntries() >5 && fitres[4]>0.1) { - //GMA need to put this==1 in future - float fact=0.812; - if (abs(kl)<=4) fact=0.895; - fact *=0.19; //conversion factor for GeV/fC - - float fact2 = 0; - if (iijj==2) fact2 = invang[jk][nphimx]; - if (iijj==3) fact2 = invang[jk][ij]; - if (iijj==1) fact2 = com_invang[jk][ij]; - - float calibc = fact*fact2/(fitres[4]*signall[izone]->GetEntries()); - float caliberr= TMath::Abs(calibc*parserr[4]/std::max(0.001,fitres[4])); - - if (iijj==2) { - int ieta = (jk<15) ? jk+1 : 14-jk; - mean_phi_hst->Fill(ieta, calibc); - mean_phi_hst->SetBinError(mean_phi_hst->FindBin(ieta), caliberr); - file_out<<"intieta "<FindBin(double(ieta))<<" "<Fill(ij+1,calibc); - const_eta[jk]->SetBinError(const_eta[jk]->FindBin(ij+1), caliberr); - - peak_eta[jk]->Fill(ij+1,fitres[4]); - peak_eta[jk]->SetBinError(peak_eta[jk]->FindBin(ij+1),parserr[4]); - - int ieta = (jk<15) ? jk+1 : 14-jk; - const_eta_phi->Fill(ieta, ij+1,calibc); - file_out<<"intietax "<FindBin(ieta, ij+1)<0) { - const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij+1),caliberr); - - mean_eta[ij] +=calibc/(caliberr*caliberr); - mean_phi[jk] +=calibc/(caliberr*caliberr); - - rms_eta[ij] +=1./(caliberr*caliberr); - rms_phi[jk] +=1./(caliberr*caliberr); - - } else { - const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij+1), 0.0); - } - } else if (iijj==1) { - const_hpdrm[jk]->Fill(ij+1,calibc); - const_hpdrm[jk]->SetBinError(const_hpdrm[jk]->FindBin(ij+1), caliberr); - - peak_hpdrm[jk]->Fill(ij+1,fitres[4]); - peak_hpdrm[jk]->SetBinError(peak_hpdrm[jk]->FindBin(ij+1),parserr[4]); - } - - file_out<<"HO 4 "<GetEntries() >10) { - signall[izone]->Draw(); - float varx = 0.000; - int kl = (jk<15) ? jk+1 : 14-jk; - file_out<<"histinfo"<GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <GetEntries()<<" " - <GetMean()<<" " - <GetRMS()<<" " - <Update(); - - for (int kl=0; klGetMean(); + float rms = pedstll[izone]->GetRMS(); + + if (rms < 0.10) + rms = 0.10; + if (rms > 0.15) + rms = 0.15; + if (mean > 0.20) + mean = 0.20; + if (mean < -0.20) + mean = -0.20; + + float xmn = mean - 6. * rms; + float xmx = mean + 6. * rms; + + binwid = pedstll[izone]->GetBinWidth(1); + if (xmx > pedstll[izone]->GetXaxis()->GetXmax()) + xmx = pedstll[izone]->GetXaxis()->GetXmax() - 0.5 * binwid; + if (xmn < pedstll[izone]->GetXaxis()->GetXmin()) + xmn = pedstll[izone]->GetXaxis()->GetXmin() + 0.5 * binwid; + + float height = pedstll[izone]->GetEntries(); + + double par[nbgpr] = {height, mean, 0.75 * rms}; + + double gaupr[nbgpr]; + double parer[nbgpr]; + + ietafit = jk; + iphifit = ij; + pedstll[izone]->GetXaxis()->SetLabelSize(.065); + pedstll[izone]->GetYaxis()->SetLabelSize(.06); + + // if (iijj==0) { + // pedstll[izone]->GetXaxis()->SetRangeUser(alow, ahigh); + // } else { + pedstll[izone]->GetXaxis()->SetRangeUser(xmn, xmx); + // } + + if (iijj == 0) { + pedstll[izone]->GetXaxis()->SetTitle("Pedestal/Signal (GeV)"); + } else { + pedstll[izone]->GetXaxis()->SetTitle("Pedestal (GeV)"); + } + pedstll[izone]->GetXaxis()->SetTitleSize(.065); + pedstll[izone]->GetXaxis()->CenterTitle(); + // pedstll[izone]->SetLineWidth(2); + + pedstll[izone]->Draw(); + if (m_pedsuppr) { + gaupr[0] = 0; + gaupr[1] = 0.0; // pedmean[ietafit][iphifit]; + gaupr[2] = 0.15; //GMA need from database + parer[0] = parer[1] = parer[2] = 0; + } else { + if (pedstll[izone]->GetEntries() > 5) { + if ((iijj != 3) || m_histfit) { + char temp[20]; + sprintf(temp, "gx0_%i", izone); + gx0[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); + gx0[izone]->SetParameters(par); + gx0[izone]->SetLineWidth(1); + pedstll[izone]->Fit(gx0[izone], "R+"); + + for (int k = 0; k < nbgpr; k++) { + parer[k] = gx0[izone]->GetParError(k); + gaupr[k] = gx0[izone]->GetParameter(k); + } + } else { + double strt[nbgpr] = {height, mean, 0.75 * rms}; + double step[nbgpr] = {1.0, 0.001, 0.001}; + double alowmn[nbgpr] = {0.5 * height, mean - rms, 0.3 * rms}; + double ahighmn[nbgpr] = {1.5 * height, mean + rms, 1.5 * rms}; + + TMinuit* gMinuit = new TMinuit(nbgpr); + gMinuit->SetFCN(fcnbg); + + double arglist[10]; + int ierflg = 0; + arglist[0] = 0.5; + gMinuit->mnexcm("SET ERR", arglist, 1, ierflg); + char name[100]; + for (int k = 0; k < nbgpr; k++) { + sprintf(name, "pedpar%i", k); + gMinuit->mnparm(k, name, strt[k], step[k], alowmn[k], ahighmn[k], ierflg); + } + + arglist[0] = 0; + gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg); + + arglist[0] = 0; + gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg); + + TString chnam; + double parv, err, xlo, xup, plerr, mierr, eparab, gcc; + int iuit; + + for (int k = 0; k < nbgpr; k++) { + if (step[k] > -10) { + gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit); + gMinuit->mnerrs(k, plerr, mierr, eparab, gcc); + // edm::LogInfo("HOCalib") <<"k "<< k<<" "<SetParameters(gaupr); + + char temp[20]; + sprintf(temp, "ped0fun_%i", izone); + ped0fun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); + ped0fun[izone]->SetParameters(gaupr); + ped0fun[izone]->SetLineColor(3); + ped0fun[izone]->SetLineWidth(1); + ped0fun[izone]->Draw("same"); + + delete gMinuit; + } + } else { + for (int k = 0; k < nbgpr; k++) { + gaupr[k] = par[k]; + } + gaupr[2] = 0.15; + } + } + // if (iijj!=0) + c0->cd(2 * izone + 2); + if (signall[izone]->GetEntries() > 5) { + Double_t parall[nsgpr]; + double parserr[nsgpr]; + double fitres[nsgpr]; + double pedht = 0; + + char temp[20]; + sprintf(temp, "signal_%i", izone); + xmn = signall[izone]->GetXaxis()->GetXmin(); + xmx = 0.5 * signall[izone]->GetXaxis()->GetXmax(); + signal[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr); + xmx *= 2.0; + if ((iijj != 3) || m_histfit) { + pedht = (signall[izone]->GetBinContent(nbn - 1) + signall[izone]->GetBinContent(nbn) + + signall[izone]->GetBinContent(nbn + 1)) / + 3.; + + if (m_pedsuppr) { + parall[1] = 0.0; // pedmean[ietafit][iphifit]; + parall[2] = 0.15; + } else { + for (int lm = 0; lm < nbgpr; lm++) { + parall[lm] = gaupr[lm]; + } + } + + set_mean(parall[1], false); + set_sigma(parall[2], false); + + parall[0] = 0.9 * pedht; //GM for Z-mumu, there is almost no pedestal + parall[3] = 0.14; + double area = binwid * signall[izone]->GetEntries(); + parall[5] = area; + + if (iijj == 3) { + parall[4] = fitprm[4][jk]; + parall[6] = fitprm[6][jk]; + } else { + parall[4] = signall[izone]->GetMean(); + parall[6] = parall[2]; + } + + signal[izone]->SetParameters(parall); + signal[izone]->FixParameter(1, parall[1]); + signal[izone]->FixParameter(2, parall[2]); + signal[izone]->SetParLimits(0, 0.00, 2.0 * pedht + 0.1); + signal[izone]->FixParameter(3, 0.14); + + signal[izone]->SetParLimits(5, 0.40 * area, 1.15 * area); + // if (m_histfit) { //GMA + if (iijj == 3) { + signal[izone]->SetParLimits(4, 0.2 * fitprm[4][jk], 2.0 * fitprm[4][jk]); + signal[izone]->SetParLimits(6, 0.2 * fitprm[6][jk], 2.0 * fitprm[6][jk]); + } else { + signal[izone]->SetParLimits(4, 0.1, 1.0); + signal[izone]->SetParLimits(6, 0.035, 0.3); + } + signal[izone]->SetParNames("const", "mean", "sigma", "Width", "MP", "Area", "GSigma"); + signall[izone]->Fit(signal[izone], "0R+"); + + signall[izone]->GetXaxis()->SetRangeUser(xmn, xmx); + for (int k = 0; k < nsgpr; k++) { + fitres[k] = fitprm[k][jk] = signal[izone]->GetParameter(k); + parserr[k] = signal[izone]->GetParError(k); + } + + } else { + double pedhtx = 0; + for (unsigned i = 0; i < sig_reg[ietafit][iphifit].size(); i++) { + if (sig_reg[ietafit][iphifit][ij] > gaupr[1] - 3 * gaupr[2] && + sig_reg[ietafit][iphifit][ij] < gaupr[1] + gaupr[2]) + pedhtx++; + } + + set_mean(gaupr[1], false); + set_sigma(gaupr[2], false); + + TString name[nsgpr] = {"const", "mean", "sigma", "Width", "MP", "Area", "GSigma"}; + double strt[nsgpr] = {0.9 * pedhtx, + gaupr[1], + gaupr[2], + fitprm[3][jk], + fitprm[4][jk], + signall[izone]->GetEntries(), + fitprm[6][jk]}; + double alowmn[nsgpr] = { + 0.1 * pedhtx - 0.1, gaupr[1] - 0.1, gaupr[2] - 0.1, 0.07, 0.2 * strt[4], 0.1 * strt[5], 0.2 * strt[6]}; + double ahighmn[nsgpr] = { + 1.2 * pedhtx + 0.1, gaupr[1] + 0.1, gaupr[2] + 0.1, 0.20, 2.5 * strt[4], 1.5 * strt[5], 2.2 * strt[6]}; + double step[nsgpr] = {1.0, 0.0, 0.0, 0.0, 0.001, 1.0, 0.002}; + + TMinuit* gMinuit = new TMinuit(nsgpr); + gMinuit->SetFCN(fcnsg); + + double arglist[10]; + int ierflg = 0; + arglist[0] = 0.5; + gMinuit->mnexcm("SET ERR", arglist, 1, ierflg); + + for (int k = 0; k < nsgpr; k++) { + gMinuit->mnparm(k, name[k], strt[k], step[k], alowmn[k], ahighmn[k], ierflg); + } + + arglist[0] = 0; + gMinuit->mnexcm("SIMPLEX", arglist, 0, ierflg); + + arglist[0] = 0; + gMinuit->mnexcm("IMPROVE", arglist, 0, ierflg); + + TString chnam; + double parv, err, xlo, xup, plerr, mierr, eparab, gcc; + int iuit; + + for (int k = 0; k < nsgpr; k++) { + if (step[k] > -10) { + gMinuit->mnpout(k, chnam, parv, err, xlo, xup, iuit); + gMinuit->mnerrs(k, plerr, mierr, eparab, gcc); + if (k == 0 || k == 5) { + fitres[k] = parv * binwid; + parserr[k] = err * binwid; + } else { + fitres[k] = parv; + parserr[k] = err; + } + } + } + + delete gMinuit; + } + + // if (iijj==0) { + // signall[izone]->Draw("same"); + // } else { + signall[izone]->Draw(); + // } + + sprintf(temp, "pedfun_%i", izone); + pedfun[izone] = new TF1(temp, gausX, xmn, xmx, nbgpr); + pedfun[izone]->SetParameters(fitres); + pedfun[izone]->SetLineColor(3); + pedfun[izone]->SetLineWidth(1); + pedfun[izone]->Draw("same"); + + sprintf(temp, "signalfun_%i", izone); + sigfun[izone] = new TF1(temp, langaufun, xmn, xmx, nsgpr - nbgpr); + sigfun[izone]->SetParameters(&fitres[3]); + sigfun[izone]->SetLineWidth(1); + sigfun[izone]->SetLineColor(4); + sigfun[izone]->Draw("same"); + + sprintf(temp, "total_%i", izone); + signalx[izone] = new TF1(temp, totalfunc, xmn, xmx, nsgpr); + signalx[izone]->SetParameters(fitres); + signalx[izone]->SetLineWidth(1); + signalx[izone]->Draw("same"); + + int kl = (jk < 15) ? jk + 1 : 14 - jk; + + edm::LogInfo("HOCalib") << "histinfo" << iijj << " fit " << std::setw(3) << kl << " " << std::setw(3) + << ij + 1 << " " << std::setw(5) << pedstll[izone]->GetEntries() << " " + << std::setw(6) << pedstll[izone]->GetMean() << " " << std::setw(6) + << pedstll[izone]->GetRMS() << " " << std::setw(5) << signall[izone]->GetEntries() + << " " << std::setw(6) << signall[izone]->GetMean() << " " << std::setw(6) + << signall[izone]->GetRMS() << " " << std::setw(6) << signal[izone]->GetChisquare() + << " " << std::setw(3) << signal[izone]->GetNDF(); + + file_out << "histinfo" << iijj << " fit " << std::setw(3) << kl << " " << std::setw(3) << ij + 1 << " " + << std::setw(5) << pedstll[izone]->GetEntries() << " " << std::setw(6) << pedstll[izone]->GetMean() + << " " << std::setw(6) << pedstll[izone]->GetRMS() << " " << std::setw(5) + << signall[izone]->GetEntries() << " " << std::setw(6) << signall[izone]->GetMean() << " " + << std::setw(6) << signall[izone]->GetRMS() << " " << std::setw(6) << signal[izone]->GetChisquare() + << " " << std::setw(3) << signal[izone]->GetNDF() << std::endl; + + file_out << "fitres x" << iijj << " " << kl << " " << ij + 1 << " " << fitres[0] << " " << fitres[1] << " " + << fitres[2] << " " << fitres[3] << " " << fitres[4] << " " << fitres[5] << " " << fitres[6] + << std::endl; + file_out << "parserr" << iijj << " " << kl << " " << ij + 1 << " " << parserr[0] << " " << parserr[1] << " " + << parserr[2] << " " << parserr[3] << " " << parserr[4] << " " << parserr[5] << " " << parserr[6] + << std::endl; + + double diff = fitres[4] - fitres[1]; + if (diff <= 0) + diff = 0.000001; + double error = parserr[4] * parserr[4] + parer[2] * parer[2]; + error = pow(error, 0.5); + + int ieta = (jk < 15) ? (15 + jk) : (29 - jk); + int ifl = nphimx * ieta + ij; + + if (iijj == 3) { + ped_evt->Fill(ifl, pedstll[izone]->GetEntries()); + ped_mean->Fill(ifl, gaupr[1]); + ped_width->Fill(ifl, gaupr[2]); + fit_chi->Fill(ifl, signal[izone]->GetChisquare()); + sig_evt->Fill(ifl, signall[izone]->GetEntries()); + fit_sigevt->Fill(ifl, fitres[5]); + fit_bkgevt->Fill(ifl, fitres[0] * sqrt(2 * acos(-1.)) * gaupr[2]); + sig_mean->Fill(ifl, fitres[4]); + sig_diff->Fill(ifl, fitres[4] - fitres[1]); + sig_width->Fill(ifl, fitres[3]); + sig_sigma->Fill(ifl, fitres[6]); + sig_meanerr->Fill(ifl, parserr[4]); + if (fitres[4] - fitres[1] != 0) + sig_meanerrp->Fill(ifl, 100 * parserr[4] / (fitres[4] - fitres[1])); + if (gaupr[2] != 0) + sig_signf->Fill(ifl, (fitres[4] - fitres[1]) / gaupr[2]); + + ped_statmean->Fill(ifl, pedstll[izone]->GetMean()); + sig_statmean->Fill(ifl, signall[izone]->GetMean()); + ped_rms->Fill(ifl, pedstll[izone]->GetRMS()); + sig_rms->Fill(ifl, signall[izone]->GetRMS()); + } + + if ((iijj == 2) || (iijj == 3) || (iijj == 1)) { + if (signall[izone]->GetEntries() > 5 && fitres[4] > 0.1) { + //GMA need to put this==1 in future + float fact = 0.812; + if (abs(kl) <= 4) + fact = 0.895; + fact *= 0.19; //conversion factor for GeV/fC + + float fact2 = 0; + if (iijj == 2) + fact2 = invang[jk][nphimx]; + if (iijj == 3) + fact2 = invang[jk][ij]; + if (iijj == 1) + fact2 = com_invang[jk][ij]; + + float calibc = fact * fact2 / (fitres[4] * signall[izone]->GetEntries()); + float caliberr = TMath::Abs(calibc * parserr[4] / std::max(0.001, fitres[4])); + + if (iijj == 2) { + int ieta = (jk < 15) ? jk + 1 : 14 - jk; + mean_phi_hst->Fill(ieta, calibc); + mean_phi_hst->SetBinError(mean_phi_hst->FindBin(ieta), caliberr); + file_out << "intieta " << jk << " " << ij << " " << ieta << " " << mean_phi_hst->FindBin(double(ieta)) + << " " << calibc << " " << caliberr << std::endl; + } else if (iijj == 3) { + const_eta[jk]->Fill(ij + 1, calibc); + const_eta[jk]->SetBinError(const_eta[jk]->FindBin(ij + 1), caliberr); + + peak_eta[jk]->Fill(ij + 1, fitres[4]); + peak_eta[jk]->SetBinError(peak_eta[jk]->FindBin(ij + 1), parserr[4]); + + int ieta = (jk < 15) ? jk + 1 : 14 - jk; + const_eta_phi->Fill(ieta, ij + 1, calibc); + file_out << "intietax " << jk << " " << ij << " " << ieta << " " + << const_eta_phi->FindBin(ieta, ij + 1) << std::endl; + if (caliberr > 0) { + const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij + 1), caliberr); + + mean_eta[ij] += calibc / (caliberr * caliberr); + mean_phi[jk] += calibc / (caliberr * caliberr); + + rms_eta[ij] += 1. / (caliberr * caliberr); + rms_phi[jk] += 1. / (caliberr * caliberr); + + } else { + const_eta_phi->SetBinError(const_eta_phi->FindBin(ieta, ij + 1), 0.0); + } + } else if (iijj == 1) { + const_hpdrm[jk]->Fill(ij + 1, calibc); + const_hpdrm[jk]->SetBinError(const_hpdrm[jk]->FindBin(ij + 1), caliberr); + + peak_hpdrm[jk]->Fill(ij + 1, fitres[4]); + peak_hpdrm[jk]->SetBinError(peak_hpdrm[jk]->FindBin(ij + 1), parserr[4]); + } + + file_out << "HO 4 " << iijj << " " << std::setw(3) << kl << " " << std::setw(3) << ij + 1 << " " + << std::setw(7) << calibc << " " << std::setw(7) << caliberr << std::endl; + } + } + + } else { //if (signall[izone]->GetEntries() >10) { + signall[izone]->Draw(); + float varx = 0.000; + int kl = (jk < 15) ? jk + 1 : 14 - jk; + file_out << "histinfo" << iijj << " nof " << std::setw(3) << kl << " " << std::setw(3) << ij + 1 << " " + << std::setw(5) << pedstll[izone]->GetEntries() << " " << std::setw(6) << pedstll[izone]->GetMean() + << " " << std::setw(6) << pedstll[izone]->GetRMS() << " " << std::setw(5) + << signall[izone]->GetEntries() << " " << std::setw(6) << signall[izone]->GetMean() << " " + << std::setw(6) << signall[izone]->GetRMS() << " " << std::setw(6) << varx << " " << std::setw(3) + << varx << std::endl; + + file_out << "fitres x" << iijj << " " << kl << " " << ij + 1 << " " << varx << " " << varx << " " << varx + << " " << varx << " " << varx << " " << varx << " " << varx << std::endl; + file_out << "parserr" << iijj << " " << kl << " " << ij + 1 << " " << varx << " " << varx << " " << varx + << " " << varx << " " << varx << " " << varx << " " << varx << std::endl; + } + iiter++; + if (iiter % nsample == 0) { + c0->Update(); + + for (int kl = 0; kl < nsample; kl++) { + if (gx0[kl]) { + delete gx0[kl]; + gx0[kl] = nullptr; + } + if (ped0fun[kl]) { + delete ped0fun[kl]; + ped0fun[kl] = nullptr; + } + if (signal[kl]) { + delete signal[kl]; + signal[kl] = nullptr; + } + if (pedfun[kl]) { + delete pedfun[kl]; + pedfun[kl] = nullptr; + } + if (sigfun[kl]) { + delete sigfun[kl]; + sigfun[kl] = nullptr; + } + if (signalx[kl]) { + delete signalx[kl]; + signalx[kl] = nullptr; + } + if (signall[kl]) { + delete signall[kl]; + signall[kl] = nullptr; + } + if (pedstll[kl]) { + delete pedstll[kl]; + pedstll[kl] = nullptr; + } + } + } + } //for (int jk=0; jkSaveAs(out_file); // iiter = 0; // } else { - // // c0->Update(); + // // c0->Update(); // } // iiter = 0; - } //end of iijj - if (iiter%nsample!=0) { - c0->Update(); - for (int kl=0; klUpdate(); + for (int kl = 0; kl < nsample; kl++) { + if (gx0[kl]) { + delete gx0[kl]; + gx0[kl] = nullptr; + } + if (ped0fun[kl]) { + delete ped0fun[kl]; + ped0fun[kl] = nullptr; + } + if (signal[kl]) { + delete signal[kl]; + signal[kl] = nullptr; + } + if (pedfun[kl]) { + delete pedfun[kl]; + pedfun[kl] = nullptr; + } + if (sigfun[kl]) { + delete sigfun[kl]; + sigfun[kl] = nullptr; + } + if (signalx[kl]) { + delete signalx[kl]; + signalx[kl] = nullptr; + } + if (signall[kl]) { + delete signall[kl]; + signall[kl] = nullptr; + } + if (pedstll[kl]) { + delete pedstll[kl]; + pedstll[kl] = nullptr; + } } } delete c0; - xsiz = 600; //int xsiz = 600; - ysiz = 800; //int ysiz = 800; - + xsiz = 600; //int xsiz = 600; + ysiz = 800; //int ysiz = 800; + gStyle->SetTitleFontSize(0.05); - gStyle->SetTitleSize(0.025,"XYZ"); - gStyle->SetLabelSize(0.025,"XYZ"); + gStyle->SetTitleSize(0.025, "XYZ"); + gStyle->SetLabelSize(0.025, "XYZ"); gStyle->SetStatFontSize(.045); - + gStyle->SetOptStat(0); - ps.NewPage(); TCanvas *c1 = new TCanvas("c1", " Pedestal vs signal", xsiz, ysiz); - ped_evt->Draw(); c1->Update(); - ps.NewPage(); - ped_statmean->Draw(); c1->Update(); - + TCanvas* c1 = new TCanvas("c1", " Pedestal vs signal", xsiz, ysiz); + ped_evt->Draw(); + c1->Update(); + ps.NewPage(); - ped_rms->Draw(); c1->Update(); - + ped_statmean->Draw(); + c1->Update(); + + ps.NewPage(); + ped_rms->Draw(); + c1->Update(); + + ps.NewPage(); + ped_mean->Draw(); + c1->Update(); + + ps.NewPage(); + ped_width->Draw(); + c1->Update(); + ps.NewPage(); - ped_mean->Draw(); c1->Update(); - + sig_evt->Draw(); + c1->Update(); + ps.NewPage(); - ped_width->Draw(); c1->Update(); - + sig_statmean->Draw(); + c1->Update(); + ps.NewPage(); - sig_evt->Draw(); c1->Update(); - + sig_rms->Draw(); + c1->Update(); + ps.NewPage(); - sig_statmean->Draw(); c1->Update(); - + fit_chi->Draw(); + c1->Update(); + ps.NewPage(); - sig_rms->Draw(); c1->Update(); - + fit_sigevt->Draw(); + c1->Update(); + ps.NewPage(); - fit_chi->Draw(); c1->Update(); - + fit_bkgevt->Draw(); + c1->Update(); + ps.NewPage(); - fit_sigevt->Draw(); c1->Update(); - + sig_mean->Draw(); + c1->Update(); + ps.NewPage(); - fit_bkgevt->Draw(); c1->Update(); - + sig_width->Draw(); + c1->Update(); + ps.NewPage(); - sig_mean->Draw(); c1->Update(); - + sig_sigma->Draw(); + c1->Update(); + ps.NewPage(); - sig_width->Draw(); c1->Update(); - - ps.NewPage(); - sig_sigma->Draw(); c1->Update(); - - ps.NewPage(); - sig_meanerr->Draw(); c1->Update(); - - ps.NewPage(); - sig_meanerrp->Draw(); c1->Update(); - - ps.NewPage(); - sig_signf->Draw(); c1->Update(); - + sig_meanerr->Draw(); + c1->Update(); + + ps.NewPage(); + sig_meanerrp->Draw(); + c1->Update(); + + ps.NewPage(); + sig_signf->Draw(); + c1->Update(); + ps.Close(); delete c1; - + file_out.close(); if (m_figure) { @@ -2470,85 +2705,83 @@ HOCalibAnalyzer::endJob() { gStyle->SetPadRightMargin(0.01); gStyle->SetOptLogy(0); gStyle->SetOptStat(0); - - TCanvas *c2 = new TCanvas("c2", "runfile", xsiz, ysiz); - c2->Divide(5,3); - - for (int side=0; side <2; side++) { - gStyle->SetNdivisions(303,"XY"); - gStyle->SetPadRightMargin(0.01); - int nmn = 0; - int nmx = netamx/2; - if (side==1) { - nmn = netamx/2; - nmx = netamx; - } - - int nzone = 0; - - for (int ij=nmn; ijcd(nzone+1); - const_eta[ij]->GetXaxis()->SetTitle("#phi index"); - const_eta[ij]->GetXaxis()->SetTitleSize(.08); - const_eta[ij]->GetXaxis()->CenterTitle(); - const_eta[ij]->GetXaxis()->SetTitleOffset(0.9); - const_eta[ij]->GetXaxis()->SetLabelSize(.085); - const_eta[ij]->GetXaxis()->SetLabelOffset(.01); - - const_eta[ij]->GetYaxis()->SetLabelSize(.08); - const_eta[ij]->GetYaxis()->SetLabelOffset(.01); - const_eta[ij]->GetYaxis()->SetTitle("GeV/MIP-GeV!!"); - - const_eta[ij]->GetYaxis()->SetTitleSize(.085); - const_eta[ij]->GetYaxis()->CenterTitle(); - const_eta[ij]->GetYaxis()->SetTitleOffset(1.3); - const_eta[ij]->SetMarkerSize(0.60); - const_eta[ij]->SetMarkerColor(2); - const_eta[ij]->SetMarkerStyle(20); - - - const_eta[ij]->Draw(); - nzone++; - } - - sprintf(out_file, "calibho_%i_side%i.eps", irunold, side); - c2->SaveAs(out_file); - - sprintf(out_file, "calibho_%i_side%i.jpg", irunold, side); - c2->SaveAs(out_file); - - nzone = 0; - for (int ij=nmn; ijcd(nzone+1); - peak_eta[ij]->GetXaxis()->SetTitle("#phi index"); - peak_eta[ij]->GetXaxis()->SetTitleSize(.08); - peak_eta[ij]->GetXaxis()->CenterTitle(); - peak_eta[ij]->GetXaxis()->SetTitleOffset(0.90); - peak_eta[ij]->GetXaxis()->SetLabelSize(.08); - peak_eta[ij]->GetXaxis()->SetLabelOffset(.01); - - peak_eta[ij]->GetYaxis()->SetLabelSize(.08); - peak_eta[ij]->GetYaxis()->SetLabelOffset(.01); - peak_eta[ij]->GetYaxis()->SetTitle("GeV"); - - peak_eta[ij]->GetYaxis()->SetTitleSize(.085); - peak_eta[ij]->GetYaxis()->CenterTitle(); - peak_eta[ij]->GetYaxis()->SetTitleOffset(1.3); - - peak_eta[ij]->SetMarkerSize(0.60); - peak_eta[ij]->SetMarkerColor(2); - peak_eta[ij]->SetMarkerStyle(20); - - peak_eta[ij]->Draw(); - nzone++; - } - - sprintf(out_file, "peakho_%i_side%i.eps", irunold, side); - c2->SaveAs(out_file); - - sprintf(out_file, "peakho_%i_side%i.jpg", irunold, side); - c2->SaveAs(out_file); + + TCanvas* c2 = new TCanvas("c2", "runfile", xsiz, ysiz); + c2->Divide(5, 3); + + for (int side = 0; side < 2; side++) { + gStyle->SetNdivisions(303, "XY"); + gStyle->SetPadRightMargin(0.01); + int nmn = 0; + int nmx = netamx / 2; + if (side == 1) { + nmn = netamx / 2; + nmx = netamx; + } + + int nzone = 0; + + for (int ij = nmn; ij < nmx; ij++) { + c2->cd(nzone + 1); + const_eta[ij]->GetXaxis()->SetTitle("#phi index"); + const_eta[ij]->GetXaxis()->SetTitleSize(.08); + const_eta[ij]->GetXaxis()->CenterTitle(); + const_eta[ij]->GetXaxis()->SetTitleOffset(0.9); + const_eta[ij]->GetXaxis()->SetLabelSize(.085); + const_eta[ij]->GetXaxis()->SetLabelOffset(.01); + + const_eta[ij]->GetYaxis()->SetLabelSize(.08); + const_eta[ij]->GetYaxis()->SetLabelOffset(.01); + const_eta[ij]->GetYaxis()->SetTitle("GeV/MIP-GeV!!"); + + const_eta[ij]->GetYaxis()->SetTitleSize(.085); + const_eta[ij]->GetYaxis()->CenterTitle(); + const_eta[ij]->GetYaxis()->SetTitleOffset(1.3); + const_eta[ij]->SetMarkerSize(0.60); + const_eta[ij]->SetMarkerColor(2); + const_eta[ij]->SetMarkerStyle(20); + + const_eta[ij]->Draw(); + nzone++; + } + + sprintf(out_file, "calibho_%i_side%i.eps", irunold, side); + c2->SaveAs(out_file); + + sprintf(out_file, "calibho_%i_side%i.jpg", irunold, side); + c2->SaveAs(out_file); + + nzone = 0; + for (int ij = nmn; ij < nmx; ij++) { + c2->cd(nzone + 1); + peak_eta[ij]->GetXaxis()->SetTitle("#phi index"); + peak_eta[ij]->GetXaxis()->SetTitleSize(.08); + peak_eta[ij]->GetXaxis()->CenterTitle(); + peak_eta[ij]->GetXaxis()->SetTitleOffset(0.90); + peak_eta[ij]->GetXaxis()->SetLabelSize(.08); + peak_eta[ij]->GetXaxis()->SetLabelOffset(.01); + + peak_eta[ij]->GetYaxis()->SetLabelSize(.08); + peak_eta[ij]->GetYaxis()->SetLabelOffset(.01); + peak_eta[ij]->GetYaxis()->SetTitle("GeV"); + + peak_eta[ij]->GetYaxis()->SetTitleSize(.085); + peak_eta[ij]->GetYaxis()->CenterTitle(); + peak_eta[ij]->GetYaxis()->SetTitleOffset(1.3); + + peak_eta[ij]->SetMarkerSize(0.60); + peak_eta[ij]->SetMarkerColor(2); + peak_eta[ij]->SetMarkerStyle(20); + + peak_eta[ij]->Draw(); + nzone++; + } + + sprintf(out_file, "peakho_%i_side%i.eps", irunold, side); + c2->SaveAs(out_file); + + sprintf(out_file, "peakho_%i_side%i.jpg", irunold, side); + c2->SaveAs(out_file); } delete c2; @@ -2560,156 +2793,156 @@ HOCalibAnalyzer::endJob() { gStyle->SetOptStat(0); xsiz = 700; ysiz = 600; - TCanvas *c1 = new TCanvas("c1", "Fitted const in each tower", xsiz, ysiz); + TCanvas* c1 = new TCanvas("c1", "Fitted const in each tower", xsiz, ysiz); const_eta_phi->GetXaxis()->SetTitle("#eta"); const_eta_phi->GetXaxis()->SetTitleSize(0.065); - const_eta_phi->GetXaxis()->SetTitleOffset(0.85); //6); + const_eta_phi->GetXaxis()->SetTitleOffset(0.85); //6); const_eta_phi->GetXaxis()->CenterTitle(); const_eta_phi->GetXaxis()->SetLabelSize(0.045); - const_eta_phi->GetXaxis()->SetLabelOffset(0.01); - + const_eta_phi->GetXaxis()->SetLabelOffset(0.01); + const_eta_phi->GetYaxis()->SetTitle("#phi"); const_eta_phi->GetYaxis()->SetTitleSize(0.075); - const_eta_phi->GetYaxis()->SetTitleOffset(0.5); + const_eta_phi->GetYaxis()->SetTitleOffset(0.5); const_eta_phi->GetYaxis()->CenterTitle(); const_eta_phi->GetYaxis()->SetLabelSize(0.045); - const_eta_phi->GetYaxis()->SetLabelOffset(0.01); - + const_eta_phi->GetYaxis()->SetLabelOffset(0.01); + const_eta_phi->Draw("colz"); - sprintf(out_file, "high_hoconst_eta_phi_%i.jpg",irunold); - c1->SaveAs(out_file); - - delete c1; - - for (int jk=0; jk0) { - mean_phi_ave->Fill(ieta, mean_phi[jk]/rms_phi[jk]); - mean_phi_ave->SetBinError(mean_phi_ave->FindBin(ieta), pow(double(rms_phi[jk]), -0.5)); - } + sprintf(out_file, "high_hoconst_eta_phi_%i.jpg", irunold); + c1->SaveAs(out_file); + + delete c1; + + for (int jk = 0; jk < netamx; jk++) { + int ieta = (jk < 15) ? jk + 1 : 14 - jk; + if (rms_phi[jk] > 0) { + mean_phi_ave->Fill(ieta, mean_phi[jk] / rms_phi[jk]); + mean_phi_ave->SetBinError(mean_phi_ave->FindBin(ieta), pow(double(rms_phi[jk]), -0.5)); + } } - - for (int ij=0; ij0) { - mean_eta_ave->Fill(ij+1, mean_eta[ij]/rms_eta[ij]); - mean_eta_ave->SetBinError(mean_eta_ave->FindBin(ij+1), pow(double(rms_eta[ij]), -0.5)); - } + + for (int ij = 0; ij < nphimx; ij++) { + if (rms_eta[ij] > 0) { + mean_eta_ave->Fill(ij + 1, mean_eta[ij] / rms_eta[ij]); + mean_eta_ave->SetBinError(mean_eta_ave->FindBin(ij + 1), pow(double(rms_eta[ij]), -0.5)); + } } - - ysiz =450; + + ysiz = 450; gStyle->SetPadLeftMargin(0.13); gStyle->SetPadRightMargin(0.03); - - TCanvas *c2y = new TCanvas("c2", "Avearge signal in eta and phi", xsiz, ysiz); - c2y->Divide(2,1); + TCanvas* c2y = new TCanvas("c2", "Avearge signal in eta and phi", xsiz, ysiz); + c2y->Divide(2, 1); mean_eta_ave->GetXaxis()->SetTitle("#phi"); mean_eta_ave->GetXaxis()->SetTitleSize(0.085); - mean_eta_ave->GetXaxis()->SetTitleOffset(0.65); + mean_eta_ave->GetXaxis()->SetTitleOffset(0.65); mean_eta_ave->GetXaxis()->CenterTitle(); mean_eta_ave->GetXaxis()->SetLabelSize(0.05); - mean_eta_ave->GetXaxis()->SetLabelOffset(0.001); - + mean_eta_ave->GetXaxis()->SetLabelOffset(0.001); + mean_eta_ave->GetYaxis()->SetTitle("Signal (GeV)/MIP"); mean_eta_ave->GetYaxis()->SetTitleSize(0.055); - mean_eta_ave->GetYaxis()->SetTitleOffset(1.3); + mean_eta_ave->GetYaxis()->SetTitleOffset(1.3); mean_eta_ave->GetYaxis()->CenterTitle(); mean_eta_ave->GetYaxis()->SetLabelSize(0.045); - mean_eta_ave->GetYaxis()->SetLabelOffset(0.01); + mean_eta_ave->GetYaxis()->SetLabelOffset(0.01); mean_eta_ave->SetMarkerSize(0.60); mean_eta_ave->SetMarkerColor(2); mean_eta_ave->SetMarkerStyle(20); - c2y->cd(1); mean_eta_ave->Draw(); - + c2y->cd(1); + mean_eta_ave->Draw(); + mean_phi_ave->GetXaxis()->SetTitle("#eta"); mean_phi_ave->GetXaxis()->SetTitleSize(0.085); - mean_phi_ave->GetXaxis()->SetTitleOffset(0.65); //55); + mean_phi_ave->GetXaxis()->SetTitleOffset(0.65); //55); mean_phi_ave->GetXaxis()->CenterTitle(); mean_phi_ave->GetXaxis()->SetLabelSize(0.05); - mean_phi_ave->GetXaxis()->SetLabelOffset(0.001); - + mean_phi_ave->GetXaxis()->SetLabelOffset(0.001); + mean_phi_ave->GetYaxis()->SetTitle("Signal (GeV)/MIP"); mean_phi_ave->GetYaxis()->SetTitleSize(0.055); - mean_phi_ave->GetYaxis()->SetTitleOffset(1.3); + mean_phi_ave->GetYaxis()->SetTitleOffset(1.3); mean_phi_ave->GetYaxis()->CenterTitle(); mean_phi_ave->GetYaxis()->SetLabelSize(0.045); - mean_phi_ave->GetYaxis()->SetLabelOffset(0.01); + mean_phi_ave->GetYaxis()->SetLabelOffset(0.01); mean_phi_ave->SetMarkerSize(0.60); mean_phi_ave->SetMarkerColor(2); mean_phi_ave->SetMarkerStyle(20); - - c2y->cd(2); mean_phi_ave->Draw(); - - sprintf(out_file, "high_hoaverage_eta_phi_%i.jpg",irunold); - c2y->SaveAs(out_file); - + + c2y->cd(2); + mean_phi_ave->Draw(); + + sprintf(out_file, "high_hoaverage_eta_phi_%i.jpg", irunold); + c2y->SaveAs(out_file); + delete c2y; // } else { //m_combined xsiz = 800; ysiz = 450; - TCanvas *c3 = new TCanvas("c3", "Avearge signal in eta and phi", xsiz, ysiz); - c3->Divide(2,1); + TCanvas* c3 = new TCanvas("c3", "Avearge signal in eta and phi", xsiz, ysiz); + c3->Divide(2, 1); mean_phi_hst->GetXaxis()->SetTitle("#eta"); mean_phi_hst->GetXaxis()->SetTitleSize(0.065); - mean_phi_hst->GetXaxis()->SetTitleOffset(0.9); + mean_phi_hst->GetXaxis()->SetTitleOffset(0.9); mean_phi_hst->GetXaxis()->CenterTitle(); mean_phi_hst->GetXaxis()->SetLabelSize(0.065); - mean_phi_hst->GetXaxis()->SetLabelOffset(0.001); - + mean_phi_hst->GetXaxis()->SetLabelOffset(0.001); + mean_phi_hst->GetYaxis()->SetTitle("GeV/MIP"); mean_phi_hst->GetYaxis()->SetTitleSize(0.055); - mean_phi_hst->GetYaxis()->SetTitleOffset(0.9); + mean_phi_hst->GetYaxis()->SetTitleOffset(0.9); mean_phi_hst->GetYaxis()->CenterTitle(); mean_phi_hst->GetYaxis()->SetLabelSize(0.065); - mean_phi_hst->GetYaxis()->SetLabelOffset(0.01); - + mean_phi_hst->GetYaxis()->SetLabelOffset(0.01); + mean_phi_hst->SetMarkerColor(4); mean_phi_hst->SetMarkerSize(0.8); mean_phi_hst->SetMarkerStyle(20); mean_phi_hst->Draw(); - - sprintf(out_file, "low_mean_phi_hst_%i.jpg",irunold); - c3->SaveAs(out_file); - + + sprintf(out_file, "low_mean_phi_hst_%i.jpg", irunold); + c3->SaveAs(out_file); + delete c3; - - // } //m_combined + // } //m_combined gStyle->SetOptLogy(1); gStyle->SetPadTopMargin(.1); gStyle->SetPadLeftMargin(.15); xsiz = 800; ysiz = 500; - TCanvas *c0x = new TCanvas("c0x", "Signal in each ring", xsiz, ysiz); - - c0x->Divide(3,2); - for (int ij=0; ijGetXaxis()->SetTitle("Signal/ped (GeV)"); - - com_sigrsg[ij][iread]->GetXaxis()->SetTitleSize(0.060); - com_sigrsg[ij][iread]->GetXaxis()->SetTitleOffset(1.05); - com_sigrsg[ij][iread]->GetXaxis()->CenterTitle(); - com_sigrsg[ij][iread]->GetXaxis()->SetLabelSize(0.065); - com_sigrsg[ij][iread]->GetXaxis()->SetLabelOffset(0.01); - - com_sigrsg[ij][iread]->GetYaxis()->SetLabelSize(0.065); - com_sigrsg[ij][iread]->GetYaxis()->SetLabelOffset(0.01); - - - com_sigrsg[ij][iread]->SetLineWidth(3); - com_sigrsg[ij][iread]->SetLineColor(4); - - c0x->cd(ij+1); com_sigrsg[ij][iread]->Draw(); - - com_crossg[ij][iread]->SetLineWidth(2); - com_crossg[ij][iread]->SetLineColor(2); - com_crossg[ij][iread]->Draw("same"); + TCanvas* c0x = new TCanvas("c0x", "Signal in each ring", xsiz, ysiz); + + c0x->Divide(3, 2); + for (int ij = 0; ij < ringmx; ij++) { + int iread = (ij == 2) ? routmx : rout12mx; + com_sigrsg[ij][iread]->GetXaxis()->SetTitle("Signal/ped (GeV)"); + + com_sigrsg[ij][iread]->GetXaxis()->SetTitleSize(0.060); + com_sigrsg[ij][iread]->GetXaxis()->SetTitleOffset(1.05); + com_sigrsg[ij][iread]->GetXaxis()->CenterTitle(); + com_sigrsg[ij][iread]->GetXaxis()->SetLabelSize(0.065); + com_sigrsg[ij][iread]->GetXaxis()->SetLabelOffset(0.01); + + com_sigrsg[ij][iread]->GetYaxis()->SetLabelSize(0.065); + com_sigrsg[ij][iread]->GetYaxis()->SetLabelOffset(0.01); + + com_sigrsg[ij][iread]->SetLineWidth(3); + com_sigrsg[ij][iread]->SetLineColor(4); + + c0x->cd(ij + 1); + com_sigrsg[ij][iread]->Draw(); + + com_crossg[ij][iread]->SetLineWidth(2); + com_crossg[ij][iread]->SetLineColor(2); + com_crossg[ij][iread]->Draw("same"); } - sprintf(out_file, "hosig_ring_%i.jpg",irunold); + sprintf(out_file, "hosig_ring_%i.jpg", irunold); c0x->SaveAs(out_file); delete c0x; @@ -2717,211 +2950,215 @@ HOCalibAnalyzer::endJob() { gStyle->SetOptStat(0); gStyle->SetOptLogy(0); - TCanvas *c0 = new TCanvas("c0", "Signal in each ring", xsiz, ysiz); - - c0->Divide(3,2); - for (int jk=0; jkGetXaxis()->SetTitle("RM #"); - peak_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070); - peak_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.0); - peak_hpdrm[jk]->GetXaxis()->CenterTitle(); - peak_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065); - peak_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01); - - peak_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)/MIP"); - - peak_hpdrm[jk]->GetYaxis()->SetTitleSize(0.07); - peak_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.3); - peak_hpdrm[jk]->GetYaxis()->CenterTitle(); - peak_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065); - peak_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01); - // peak_hpdrm[jk]->SetLineWidth(3); - // peak_hpdrm[jk]->SetLineColor(4); - peak_hpdrm[jk]->SetMarkerSize(0.60); - peak_hpdrm[jk]->SetMarkerColor(2); - peak_hpdrm[jk]->SetMarkerStyle(20); - - - c0->cd(jk+1); peak_hpdrm[jk]->Draw(); + TCanvas* c0 = new TCanvas("c0", "Signal in each ring", xsiz, ysiz); + + c0->Divide(3, 2); + for (int jk = 0; jk < ringmx; jk++) { + peak_hpdrm[jk]->GetXaxis()->SetTitle("RM #"); + peak_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070); + peak_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.0); + peak_hpdrm[jk]->GetXaxis()->CenterTitle(); + peak_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065); + peak_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01); + + peak_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)/MIP"); + + peak_hpdrm[jk]->GetYaxis()->SetTitleSize(0.07); + peak_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.3); + peak_hpdrm[jk]->GetYaxis()->CenterTitle(); + peak_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065); + peak_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01); + // peak_hpdrm[jk]->SetLineWidth(3); + // peak_hpdrm[jk]->SetLineColor(4); + peak_hpdrm[jk]->SetMarkerSize(0.60); + peak_hpdrm[jk]->SetMarkerColor(2); + peak_hpdrm[jk]->SetMarkerStyle(20); + + c0->cd(jk + 1); + peak_hpdrm[jk]->Draw(); } - sprintf(out_file, "comb_peak_hpdrm_%i.jpg",irunold); + sprintf(out_file, "comb_peak_hpdrm_%i.jpg", irunold); c0->SaveAs(out_file); - + delete c0; - TCanvas *c1y = new TCanvas("c1y", "Signal in each ring", xsiz, ysiz); - - c1y->Divide(3,2); - for (int jk=0; jkGetXaxis()->SetTitle("RM #"); - const_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070); - const_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.3); - const_hpdrm[jk]->GetXaxis()->CenterTitle(); - const_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065); - const_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01); - - const_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)"); - const_hpdrm[jk]->GetYaxis()->SetTitleSize(0.065); - const_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.0); - const_hpdrm[jk]->GetYaxis()->CenterTitle(); - const_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065); - const_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01); - // const_hpdrm[jk]->SetLineWidth(3); - // const_hpdrm[jk]->SetLineColor(4); - const_hpdrm[jk]->SetMarkerSize(0.60); - const_hpdrm[jk]->SetMarkerColor(2); - const_hpdrm[jk]->SetMarkerStyle(20); - - c1y->cd(jk+1); const_hpdrm[jk]->Draw(); + TCanvas* c1y = new TCanvas("c1y", "Signal in each ring", xsiz, ysiz); + + c1y->Divide(3, 2); + for (int jk = 0; jk < ringmx; jk++) { + const_hpdrm[jk]->GetXaxis()->SetTitle("RM #"); + const_hpdrm[jk]->GetXaxis()->SetTitleSize(0.070); + const_hpdrm[jk]->GetXaxis()->SetTitleOffset(1.3); + const_hpdrm[jk]->GetXaxis()->CenterTitle(); + const_hpdrm[jk]->GetXaxis()->SetLabelSize(0.065); + const_hpdrm[jk]->GetXaxis()->SetLabelOffset(0.01); + + const_hpdrm[jk]->GetYaxis()->SetTitle("Peak(GeV)"); + const_hpdrm[jk]->GetYaxis()->SetTitleSize(0.065); + const_hpdrm[jk]->GetYaxis()->SetTitleOffset(1.0); + const_hpdrm[jk]->GetYaxis()->CenterTitle(); + const_hpdrm[jk]->GetYaxis()->SetLabelSize(0.065); + const_hpdrm[jk]->GetYaxis()->SetLabelOffset(0.01); + // const_hpdrm[jk]->SetLineWidth(3); + // const_hpdrm[jk]->SetLineColor(4); + const_hpdrm[jk]->SetMarkerSize(0.60); + const_hpdrm[jk]->SetMarkerColor(2); + const_hpdrm[jk]->SetMarkerStyle(20); + + c1y->cd(jk + 1); + const_hpdrm[jk]->Draw(); } - sprintf(out_file, "comb_const_hpdrm_%i.jpg",irunold); + sprintf(out_file, "comb_const_hpdrm_%i.jpg", irunold); c1y->SaveAs(out_file); - + delete c1y; - } //if (m_figure) { + } //if (m_figure) { // ps.Close(); // file_out.close(); - }// if (m_constant){ - + } // if (m_constant){ if (m_figure) { - for (int ij=0; ijFill(ij+1,sigrsg[jk][ij]->GetEntries()); - statmn_eta[jk]->Fill(ij+1,sigrsg[jk][ij]->GetMean()); + for (int ij = 0; ij < nphimx; ij++) { + for (int jk = 0; jk < netamx; jk++) { + stat_eta[jk]->Fill(ij + 1, sigrsg[jk][ij]->GetEntries()); + statmn_eta[jk]->Fill(ij + 1, sigrsg[jk][ij]->GetMean()); } } - + xsiz = 700; ysiz = 450; gStyle->SetTitleFontSize(0.09); gStyle->SetPadBottomMargin(0.14); gStyle->SetPadLeftMargin(0.17); gStyle->SetPadRightMargin(0.01); - gStyle->SetNdivisions(303,"XY"); + gStyle->SetNdivisions(303, "XY"); gStyle->SetOptLogy(1); - - TCanvas *c2x = new TCanvas("c2x", "runfile", xsiz, ysiz); - c2x->Divide(5,3); - for (int side=0; side <2; side++) { + + TCanvas* c2x = new TCanvas("c2x", "runfile", xsiz, ysiz); + c2x->Divide(5, 3); + for (int side = 0; side < 2; side++) { int nmn = 0; - int nmx = netamx/2; - if (side==1) { - nmn = netamx/2; - nmx = netamx; + int nmx = netamx / 2; + if (side == 1) { + nmn = netamx / 2; + nmx = netamx; } int nzone = 0; char name[200]; - for (int ij=nmn; ijcd(nzone+1); - sprintf(name,"GeV(#eta=%i)",ieta); - sigrsg[ij][nphimx]->GetXaxis()->SetTitle(name); - sigrsg[ij][nphimx]->GetXaxis()->SetTitleSize(.08); - sigrsg[ij][nphimx]->GetXaxis()->CenterTitle(); - sigrsg[ij][nphimx]->GetXaxis()->SetTitleOffset(0.90); - sigrsg[ij][nphimx]->GetXaxis()->SetLabelSize(.08); - sigrsg[ij][nphimx]->GetXaxis()->SetLabelOffset(.01); - - sigrsg[ij][nphimx]->GetYaxis()->SetLabelSize(.08); - sigrsg[ij][nphimx]->GetYaxis()->SetLabelOffset(.01); - sigrsg[ij][nphimx]->SetLineWidth(2); - sigrsg[ij][nphimx]->SetLineColor(4); - sigrsg[ij][nphimx]->Draw(); - crossg[ij][nphimx]->SetLineWidth(2); - crossg[ij][nphimx]->SetLineColor(2); - crossg[ij][nphimx]->Draw("same"); - nzone++; - } - + for (int ij = nmn; ij < nmx; ij++) { + int ieta = (ij < 15) ? ij + 1 : 14 - ij; + c2x->cd(nzone + 1); + sprintf(name, "GeV(#eta=%i)", ieta); + sigrsg[ij][nphimx]->GetXaxis()->SetTitle(name); + sigrsg[ij][nphimx]->GetXaxis()->SetTitleSize(.08); + sigrsg[ij][nphimx]->GetXaxis()->CenterTitle(); + sigrsg[ij][nphimx]->GetXaxis()->SetTitleOffset(0.90); + sigrsg[ij][nphimx]->GetXaxis()->SetLabelSize(.08); + sigrsg[ij][nphimx]->GetXaxis()->SetLabelOffset(.01); + + sigrsg[ij][nphimx]->GetYaxis()->SetLabelSize(.08); + sigrsg[ij][nphimx]->GetYaxis()->SetLabelOffset(.01); + sigrsg[ij][nphimx]->SetLineWidth(2); + sigrsg[ij][nphimx]->SetLineColor(4); + sigrsg[ij][nphimx]->Draw(); + crossg[ij][nphimx]->SetLineWidth(2); + crossg[ij][nphimx]->SetLineColor(2); + crossg[ij][nphimx]->Draw("same"); + nzone++; + } + sprintf(out_file, "sig_ho_%i_side%i.eps", irunold, side); c2x->SaveAs(out_file); - + sprintf(out_file, "sig_ho_%i_side%i.jpg", irunold, side); c2x->SaveAs(out_file); } gStyle->SetOptLogy(0); - c2x = new TCanvas("c2x", "runfile", xsiz, ysiz); - c2x->Divide(5,3); - for (int side=0; side <2; side++) { + c2x = new TCanvas("c2x", "runfile", xsiz, ysiz); + c2x->Divide(5, 3); + for (int side = 0; side < 2; side++) { int nmn = 0; - int nmx = netamx/2; - if (side==1) { - nmn = netamx/2; - nmx = netamx; + int nmx = netamx / 2; + if (side == 1) { + nmn = netamx / 2; + nmx = netamx; } int nzone = 0; nzone = 0; - for (int ij=nmn; ijcd(nzone+1); - statmn_eta[ij]->SetLineWidth(2); - statmn_eta[ij]->SetLineColor(4); - statmn_eta[ij]->GetXaxis()->SetTitle("#phi index"); - statmn_eta[ij]->GetXaxis()->SetTitleSize(.08); - statmn_eta[ij]->GetXaxis()->CenterTitle(); - statmn_eta[ij]->GetXaxis()->SetTitleOffset(0.9); - statmn_eta[ij]->GetYaxis()->SetLabelSize(.08); - statmn_eta[ij]->GetYaxis()->SetLabelOffset(.01); - statmn_eta[ij]->GetXaxis()->SetLabelSize(.08); - statmn_eta[ij]->GetXaxis()->SetLabelOffset(.01); - statmn_eta[ij]->GetYaxis()->SetTitle("GeV"); - statmn_eta[ij]->GetYaxis()->SetTitleSize(.075); - statmn_eta[ij]->GetYaxis()->CenterTitle(); - statmn_eta[ij]->GetYaxis()->SetTitleOffset(1.30); - - statmn_eta[ij]->Draw(); - nzone++; - } - + for (int ij = nmn; ij < nmx; ij++) { + c2x->cd(nzone + 1); + statmn_eta[ij]->SetLineWidth(2); + statmn_eta[ij]->SetLineColor(4); + statmn_eta[ij]->GetXaxis()->SetTitle("#phi index"); + statmn_eta[ij]->GetXaxis()->SetTitleSize(.08); + statmn_eta[ij]->GetXaxis()->CenterTitle(); + statmn_eta[ij]->GetXaxis()->SetTitleOffset(0.9); + statmn_eta[ij]->GetYaxis()->SetLabelSize(.08); + statmn_eta[ij]->GetYaxis()->SetLabelOffset(.01); + statmn_eta[ij]->GetXaxis()->SetLabelSize(.08); + statmn_eta[ij]->GetXaxis()->SetLabelOffset(.01); + statmn_eta[ij]->GetYaxis()->SetTitle("GeV"); + statmn_eta[ij]->GetYaxis()->SetTitleSize(.075); + statmn_eta[ij]->GetYaxis()->CenterTitle(); + statmn_eta[ij]->GetYaxis()->SetTitleOffset(1.30); + + statmn_eta[ij]->Draw(); + nzone++; + } + sprintf(out_file, "statmnho_%i_side%i.eps", irunold, side); c2x->SaveAs(out_file); - + sprintf(out_file, "statmnho_%i_side%i.jpg", irunold, side); c2x->SaveAs(out_file); - + gStyle->SetOptLogy(1); - gStyle->SetNdivisions(203,"XY"); - + gStyle->SetNdivisions(203, "XY"); + nzone = 0; - for (int ij=nmn; ijcd(nzone+1); - stat_eta[ij]->SetLineWidth(2); - stat_eta[ij]->SetLineColor(4); - stat_eta[ij]->GetXaxis()->SetTitle("#phi index"); - stat_eta[ij]->GetXaxis()->SetTitleSize(.08); - stat_eta[ij]->GetXaxis()->CenterTitle(); - stat_eta[ij]->GetXaxis()->SetTitleOffset(0.80); - stat_eta[ij]->GetXaxis()->SetLabelSize(.08); - stat_eta[ij]->GetXaxis()->SetLabelOffset(.01); - stat_eta[ij]->GetYaxis()->SetLabelSize(.08); - stat_eta[ij]->GetYaxis()->SetLabelOffset(.01); - - stat_eta[ij]->Draw(); - nzone++; - } - + for (int ij = nmn; ij < nmx; ij++) { + c2x->cd(nzone + 1); + stat_eta[ij]->SetLineWidth(2); + stat_eta[ij]->SetLineColor(4); + stat_eta[ij]->GetXaxis()->SetTitle("#phi index"); + stat_eta[ij]->GetXaxis()->SetTitleSize(.08); + stat_eta[ij]->GetXaxis()->CenterTitle(); + stat_eta[ij]->GetXaxis()->SetTitleOffset(0.80); + stat_eta[ij]->GetXaxis()->SetLabelSize(.08); + stat_eta[ij]->GetXaxis()->SetLabelOffset(.01); + stat_eta[ij]->GetYaxis()->SetLabelSize(.08); + stat_eta[ij]->GetYaxis()->SetLabelOffset(.01); + + stat_eta[ij]->Draw(); + nzone++; + } + sprintf(out_file, "statho_%i_side%i.eps", irunold, side); c2x->SaveAs(out_file); - + sprintf(out_file, "statho_%i_side%i.jpg", irunold, side); c2x->SaveAs(out_file); } delete c2x; - } //if (m_figure) { - - if (!m_constant) { //m_constant - for (int jk=0; jk @@ -23,8 +23,6 @@ to the actual calibration code in "endJob()". // //_________________________________________________________________________________ - - // system include files #include #include @@ -38,7 +36,6 @@ to the actual calibration code in "endJob()". #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" - #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -56,100 +53,84 @@ to the actual calibration code in "endJob()". #include "TFile.h" - - #include "Geometry/Records/interface/CaloGeometryRecord.h" - - - using namespace edm; //using namespace reco; using namespace std; - // constructor -HcalCalibrator::HcalCalibrator(const edm::ParameterSet& conf) : - - mInputFileList(conf.getUntrackedParameter("inputFileList")), - // mOutputFile(conf.getUntrackedParameter("outputFile")), - - mCalibType(conf.getUntrackedParameter("calibType")), - mCalibMethod(conf.getUntrackedParameter("calibMethod")), - mMinTargetE(conf.getUntrackedParameter("minTargetE")), - mMaxTargetE(conf.getUntrackedParameter("maxTargetE")), - mMinCellE(conf.getUntrackedParameter("minCellE")), - mMinEOverP(conf.getUntrackedParameter("minEOverP")), - mMaxEOverP(conf.getUntrackedParameter("maxEOverP")), - mMaxTrkEmE(conf.getUntrackedParameter("maxTrkEmE")), - mMaxEtThirdJet(conf.getUntrackedParameter("maxEtThirdJet")), - mMinDPhiDiJets(conf.getUntrackedParameter("minDPhiDiJets")), - mSumDepths(conf.getUntrackedParameter("sumDepths")), - mSumSmallDepths(conf.getUntrackedParameter("sumSmallDepths")), - mCombinePhi (conf.getUntrackedParameter("combinePhi")), - mHbClusterSize(conf.getUntrackedParameter("hbClusterSize")), - mHeClusterSize(conf.getUntrackedParameter("heClusterSize")), - - mUseConeClustering(conf.getUntrackedParameter("useConeClustering")), - mMaxConeDist(conf.getUntrackedParameter("maxConeDist")), - - mCalibAbsIEtaMax(conf.getUntrackedParameter("calibAbsIEtaMax")), - mCalibAbsIEtaMin(conf.getUntrackedParameter("calibAbsIEtaMin")), - mMaxProbeJetEmFrac(conf.getUntrackedParameter("maxProbeJetEmFrac")), - mMaxTagJetEmFrac(conf.getUntrackedParameter("maxTagJetEmFrac")), - mMaxTagJetAbsEta(conf.getUntrackedParameter("maxTagJetAbsEta")), - mMinTagJetEt(conf.getUntrackedParameter("minTagJetEt")), - mMinProbeJetAbsEta(conf.getUntrackedParameter("minProbeJetAbsEta")), - mPhiSymCorFileName(conf.getUntrackedParameter("phiSymCorFileName")), - mApplyPhiSymCorFlag(conf.getUntrackedParameter("applyPhiSymCorFlag")), - mOutputCorCoefFileName(conf.getUntrackedParameter("outputCorCoefFileName")), - mHistoFileName(conf.getUntrackedParameter("histoFileName")) - -{ -} - +HcalCalibrator::HcalCalibrator(const edm::ParameterSet& conf) + : + + mInputFileList(conf.getUntrackedParameter("inputFileList")), + // mOutputFile(conf.getUntrackedParameter("outputFile")), + + mCalibType(conf.getUntrackedParameter("calibType")), + mCalibMethod(conf.getUntrackedParameter("calibMethod")), + mMinTargetE(conf.getUntrackedParameter("minTargetE")), + mMaxTargetE(conf.getUntrackedParameter("maxTargetE")), + mMinCellE(conf.getUntrackedParameter("minCellE")), + mMinEOverP(conf.getUntrackedParameter("minEOverP")), + mMaxEOverP(conf.getUntrackedParameter("maxEOverP")), + mMaxTrkEmE(conf.getUntrackedParameter("maxTrkEmE")), + mMaxEtThirdJet(conf.getUntrackedParameter("maxEtThirdJet")), + mMinDPhiDiJets(conf.getUntrackedParameter("minDPhiDiJets")), + mSumDepths(conf.getUntrackedParameter("sumDepths")), + mSumSmallDepths(conf.getUntrackedParameter("sumSmallDepths")), + mCombinePhi(conf.getUntrackedParameter("combinePhi")), + mHbClusterSize(conf.getUntrackedParameter("hbClusterSize")), + mHeClusterSize(conf.getUntrackedParameter("heClusterSize")), + + mUseConeClustering(conf.getUntrackedParameter("useConeClustering")), + mMaxConeDist(conf.getUntrackedParameter("maxConeDist")), + + mCalibAbsIEtaMax(conf.getUntrackedParameter("calibAbsIEtaMax")), + mCalibAbsIEtaMin(conf.getUntrackedParameter("calibAbsIEtaMin")), + mMaxProbeJetEmFrac(conf.getUntrackedParameter("maxProbeJetEmFrac")), + mMaxTagJetEmFrac(conf.getUntrackedParameter("maxTagJetEmFrac")), + mMaxTagJetAbsEta(conf.getUntrackedParameter("maxTagJetAbsEta")), + mMinTagJetEt(conf.getUntrackedParameter("minTagJetEt")), + mMinProbeJetAbsEta(conf.getUntrackedParameter("minProbeJetAbsEta")), + mPhiSymCorFileName(conf.getUntrackedParameter("phiSymCorFileName")), + mApplyPhiSymCorFlag(conf.getUntrackedParameter("applyPhiSymCorFlag")), + mOutputCorCoefFileName(conf.getUntrackedParameter("outputCorCoefFileName")), + mHistoFileName(conf.getUntrackedParameter("histoFileName")) + +{} // destructor -HcalCalibrator::~HcalCalibrator() { -} +HcalCalibrator::~HcalCalibrator() {} // ------------ method called to for each event ------------ -void -HcalCalibrator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - edm::ESHandle pG; - iSetup.get().get(pG); - mTheCaloGeometry = pG.product(); - edm::ESHandle pT; - iSetup.get().get(pT); - mTheHcalTopology = pT.product(); +void HcalCalibrator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + edm::ESHandle pG; + iSetup.get().get(pG); + mTheCaloGeometry = pG.product(); + edm::ESHandle pT; + iSetup.get().get(pT); + mTheHcalTopology = pT.product(); } // ------------ method called once each job just before starting event loop ------------ -void -HcalCalibrator::beginJob() { - +void HcalCalibrator::beginJob() { // ESHandle theGeometry; // ESHandle theEndcapGeometry_handle, theBarrelGeometry_handle; // evtSetup.get().get( theGeometry ); - // edm::ESHandle pG; - // evtSetup.get().get(pG); + // evtSetup.get().get(pG); // mTheCaloGeometry = pG.product(); - } // ------------ method called once each job just after ending the event loop ------------ -void -HcalCalibrator::endJob() { - - - if (mCalibType!="DI_JET" && mCalibType!="ISO_TRACK") { +void HcalCalibrator::endJob() { + if (mCalibType != "DI_JET" && mCalibType != "ISO_TRACK") { std::cout << "\n\nUnknown calibration type " << mCalibType << std::endl; std::cout << "Please select ISO_TRACK or DI_JET in the python file." << std::endl; return; @@ -157,28 +138,29 @@ HcalCalibrator::endJob() { if (mCalibMethod != "L3" && mCalibMethod != "MATRIX_INV_OF_ETA_AVE" && mCalibMethod != "L3_AND_MTRX_INV") { std::cout << "\n\nUnknown calibration method " << mCalibMethod << std::endl; - std::cout << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV" << std::endl; + std::cout << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV" + << std::endl; std::cout << "For DiJets the supported method is L3" << std::endl; return; } - if (mCalibType=="DI_JET" && mCalibMethod!="L3") { + if (mCalibType == "DI_JET" && mCalibMethod != "L3") { std::cout << "\n\nDiJet calibration can use only the L3 method. Please change the python file." << std::endl; return; } - if (mCalibAbsIEtaMin<1 || mCalibAbsIEtaMax>41 || mCalibAbsIEtaMin>mCalibAbsIEtaMax) { - std::cout << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file." << std::endl; + if (mCalibAbsIEtaMin < 1 || mCalibAbsIEtaMax > 41 || mCalibAbsIEtaMin > mCalibAbsIEtaMax) { + std::cout + << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file." + << std::endl; return; } - - hcalCalib* calibrator = new hcalCalib(); // set the parameters controlling the calibratoration - calibrator->SetCalibType(mCalibType); + calibrator->SetCalibType(mCalibType); calibrator->SetCalibMethod(mCalibMethod); calibrator->SetMinTargetE(mMinTargetE); calibrator->SetMaxTargetE(mMaxTargetE); @@ -195,7 +177,7 @@ HcalCalibrator::endJob() { calibrator->SetHeClusterSize(mHeClusterSize); calibrator->SetUseConeClustering(mUseConeClustering); - calibrator->SetConeMaxDist(mMaxConeDist); + calibrator->SetConeMaxDist(mMaxConeDist); calibrator->SetCalibAbsIEtaMax(mCalibAbsIEtaMax); calibrator->SetCalibAbsIEtaMin(mCalibAbsIEtaMin); @@ -210,11 +192,10 @@ HcalCalibrator::endJob() { calibrator->SetPhiSymCorFileName(mPhiSymCorFileName); calibrator->SetOutputCorCoefFileName(mOutputCorCoefFileName); - calibrator->SetHistoFileName(mHistoFileName); + calibrator->SetHistoFileName(mHistoFileName); - calibrator->SetCaloGeometry(mTheCaloGeometry,mTheHcalTopology); + calibrator->SetCaloGeometry(mTheCaloGeometry, mTheHcalTopology); - std::ifstream inputFileList; // contains list of input root files TString files = mInputFileList; @@ -224,36 +205,31 @@ HcalCalibrator::endJob() { while (!inputFileList.eof()) { TString fileName; inputFileList >> fileName; - if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName!="") + if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName != "") inputFiles.push_back(fileName); } inputFileList.close(); std::cout << "\nInput files for processing:" << std::endl; - for (std::vector::iterator it=inputFiles.begin(); it!=inputFiles.end(); ++it) { - std::cout << "file: " << it->Data() << std::endl; + for (std::vector::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it) { + std::cout << "file: " << it->Data() << std::endl; } std::cout << std::endl; - TChain* fChain = new TChain("hcalCalibTree"); - for (std::vector::iterator f_it=inputFiles.begin();f_it!=inputFiles.end(); ++f_it) { + for (std::vector::iterator f_it = inputFiles.begin(); f_it != inputFiles.end(); ++f_it) { fChain->Add(f_it->Data()); } - fChain->Process(calibrator); - if (fChain) delete fChain; + if (fChain) + delete fChain; delete calibrator; return; } - //define this as a plug-in DEFINE_FWK_MODULE(HcalCalibrator); - - - diff --git a/Calibration/HcalCalibAlgos/plugins/HcalCalibrator.h b/Calibration/HcalCalibAlgos/plugins/HcalCalibrator.h index e859945cfc41b..8fe04f03546ca 100644 --- a/Calibration/HcalCalibAlgos/plugins/HcalCalibrator.h +++ b/Calibration/HcalCalibAlgos/plugins/HcalCalibrator.h @@ -6,7 +6,6 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" - //------------------- #include "TString.h" #include "TFile.h" @@ -18,10 +17,8 @@ #include "TLorentzVector.h" //--------------------- - #include "Geometry/CaloGeometry/interface/CaloGeometry.h" - class HcalCalibrator : public edm::EDAnalyzer { public: explicit HcalCalibrator(const edm::ParameterSet&); @@ -29,38 +26,36 @@ class HcalCalibrator : public edm::EDAnalyzer { // Added for running the CaloTower creation algorithm - private: - void beginJob() override ; + void beginJob() override; void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override ; - + void endJob() override; std::string mOutputFile; std::string mInputFileList; std::string mCalibType; - std::string mCalibMethod; + std::string mCalibMethod; double mMinTargetE; double mMaxTargetE; double mMinCellE; double mMinEOverP; double mMaxEOverP; - double mMaxTrkEmE; - + double mMaxTrkEmE; + double mMaxEtThirdJet; double mMinDPhiDiJets; - bool mSumDepths; - bool mSumSmallDepths; - bool mCombinePhi; - int mHbClusterSize; - int mHeClusterSize; + bool mSumDepths; + bool mSumSmallDepths; + bool mCombinePhi; + int mHbClusterSize; + int mHeClusterSize; - bool mUseConeClustering; + bool mUseConeClustering; double mMaxConeDist; - int mCalibAbsIEtaMax; - int mCalibAbsIEtaMin; + int mCalibAbsIEtaMax; + int mCalibAbsIEtaMin; double mMaxProbeJetEmFrac; double mMaxTagJetEmFrac; @@ -68,21 +63,16 @@ class HcalCalibrator : public edm::EDAnalyzer { double mMinTagJetEt; double mMinProbeJetAbsEta; - std::string mPhiSymCorFileName; bool mApplyPhiSymCorFlag; - + std::string mOutputCorCoefFileName; std::string mHistoFileName; - const CaloGeometry* mTheCaloGeometry; const HcalTopology* mTheHcalTopology; - bool allowMissingInputs_; - - }; #endif diff --git a/Calibration/HcalCalibAlgos/plugins/HcalHBHEMuonAnalyzer.cc b/Calibration/HcalCalibAlgos/plugins/HcalHBHEMuonAnalyzer.cc index 549c200ee2ba6..0d0e591e41e36 100644 --- a/Calibration/HcalCalibAlgos/plugins/HcalHBHEMuonAnalyzer.cc +++ b/Calibration/HcalCalibAlgos/plugins/HcalHBHEMuonAnalyzer.cc @@ -43,8 +43,8 @@ #include "CondFormats/HcalObjects/interface/HcalRespCorrs.h" #include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h" -#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" -#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" +#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" +#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h" @@ -52,8 +52,8 @@ #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h" #include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h" -#include "Calibration/IsolatedParticles/interface/eECALMatrix.h" -#include "Calibration/IsolatedParticles/interface/eHCALMatrix.h" +#include "Calibration/IsolatedParticles/interface/eECALMatrix.h" +#include "Calibration/IsolatedParticles/interface/eHCALMatrix.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" @@ -69,8 +69,7 @@ //#define EDM_ML_DEBUG -class HcalHBHEMuonAnalyzer : public edm::one::EDAnalyzer { - +class HcalHBHEMuonAnalyzer : public edm::one::EDAnalyzer { public: explicit HcalHBHEMuonAnalyzer(const edm::ParameterSet&); @@ -81,161 +80,155 @@ class HcalHBHEMuonAnalyzer : public edm::one::EDAnalyzer&, const HcalDetId& id); - int depth16HE(int ieta, int iphi); - bool goodCell(const HcalDetId& hcid, const reco::Track* pTrack, - const CaloGeometry* geo, const MagneticField* bField); + int depth16HE(int ieta, int iphi); + bool goodCell(const HcalDetId& hcid, const reco::Track* pTrack, const CaloGeometry* geo, const MagneticField* bField); // ----------member data --------------------------- - HLTConfigProvider hltConfig_; + HLTConfigProvider hltConfig_; edm::Service fs; - const edm::InputTag hlTriggerResults_; - const edm::InputTag labelEBRecHit_, labelEERecHit_, labelHBHERecHit_; - const std::string labelVtx_, labelMuon_, fileInCorr_; + const edm::InputTag hlTriggerResults_; + const edm::InputTag labelEBRecHit_, labelEERecHit_, labelHBHERecHit_; + const std::string labelVtx_, labelMuon_, fileInCorr_; const std::vector triggers_; - const int verbosity_, useRaw_; - const bool unCorrect_, collapseDepth_, isItPlan1_; - const bool ignoreHECorr_, isItPreRecHit_; - const bool getCharge_, writeRespCorr_; - bool mergedDepth_, useMyCorr_; - int maxDepth_, kount_; - - const HcalDDDRecConstants *hdc_; - const HcalTopology *theHBHETopology_; - HcalRespCorrs *respCorrs_; - - edm::EDGetTokenT tok_trigRes_; - edm::EDGetTokenT tok_Vtx_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_HBHE_; - edm::EDGetTokenT tok_Muon_; - + const int verbosity_, useRaw_; + const bool unCorrect_, collapseDepth_, isItPlan1_; + const bool ignoreHECorr_, isItPreRecHit_; + const bool getCharge_, writeRespCorr_; + bool mergedDepth_, useMyCorr_; + int maxDepth_, kount_; + + const HcalDDDRecConstants* hdc_; + const HcalTopology* theHBHETopology_; + HcalRespCorrs* respCorrs_; + + edm::EDGetTokenT tok_trigRes_; + edm::EDGetTokenT tok_Vtx_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_HBHE_; + edm::EDGetTokenT tok_Muon_; + ////////////////////////////////////////////////////// - static const int depthMax_ = 7; - TTree *tree_; - unsigned int runNumber_, eventNumber_ , lumiNumber_, bxNumber_; - unsigned int goodVertex_; - std::vector muon_is_good_, muon_global_, muon_tracker_; - std::vector muon_is_tight_, muon_is_medium_; - std::vector ptGlob_, etaGlob_, phiGlob_, energyMuon_, pMuon_; - std::vector muon_trkKink, muon_chi2LocalPosition, muon_segComp; - std::vector trackerLayer_, numPixelLayers_, tight_PixelHits_; - std::vector innerTrack_, outerTrack_, globalTrack_; - std::vector chiTracker_, dxyTracker_, dzTracker_; - std::vector innerTrackpt_, innerTracketa_, innerTrackphi_; - std::vector tight_validFraction_, outerTrackChi_; - std::vector outerTrackPt_, outerTrackEta_, outerTrackPhi_; - std::vector outerTrackHits_, outerTrackRHits_; - std::vector globalTrckPt_, globalTrckEta_, globalTrckPhi_; - std::vector globalMuonHits_, matchedStat_; - std::vector chiGlobal_, tight_LongPara_, tight_TransImpara_; - std::vector isolationR04_, isolationR03_; - std::vector ecalEnergy_, hcalEnergy_, hoEnergy_; - std::vector matchedId_, hcalHot_; - std::vector ecal3x3Energy_, hcal1x1Energy_; + static const int depthMax_ = 7; + TTree* tree_; + unsigned int runNumber_, eventNumber_, lumiNumber_, bxNumber_; + unsigned int goodVertex_; + std::vector muon_is_good_, muon_global_, muon_tracker_; + std::vector muon_is_tight_, muon_is_medium_; + std::vector ptGlob_, etaGlob_, phiGlob_, energyMuon_, pMuon_; + std::vector muon_trkKink, muon_chi2LocalPosition, muon_segComp; + std::vector trackerLayer_, numPixelLayers_, tight_PixelHits_; + std::vector innerTrack_, outerTrack_, globalTrack_; + std::vector chiTracker_, dxyTracker_, dzTracker_; + std::vector innerTrackpt_, innerTracketa_, innerTrackphi_; + std::vector tight_validFraction_, outerTrackChi_; + std::vector outerTrackPt_, outerTrackEta_, outerTrackPhi_; + std::vector outerTrackHits_, outerTrackRHits_; + std::vector globalTrckPt_, globalTrckEta_, globalTrckPhi_; + std::vector globalMuonHits_, matchedStat_; + std::vector chiGlobal_, tight_LongPara_, tight_TransImpara_; + std::vector isolationR04_, isolationR03_; + std::vector ecalEnergy_, hcalEnergy_, hoEnergy_; + std::vector matchedId_, hcalHot_; + std::vector ecal3x3Energy_, hcal1x1Energy_; std::vector ecalDetId_, hcalDetId_, ehcalDetId_; - std::vector hcal_ieta_, hcal_iphi_; - std::vector hcalDepthEnergy_[depthMax_]; - std::vector hcalDepthActiveLength_[depthMax_]; - std::vector hcalDepthEnergyHot_[depthMax_]; - std::vector hcalDepthActiveLengthHot_[depthMax_]; - std::vector hcalDepthChargeHot_[depthMax_]; - std::vector hcalDepthChargeHotBG_[depthMax_]; - std::vector hcalDepthEnergyCorr_[depthMax_]; - std::vector hcalDepthEnergyHotCorr_[depthMax_]; - std::vector hcalDepthMatch_[depthMax_]; - std::vector hcalDepthMatchHot_[depthMax_]; - std::vector hcalActiveLength_, hcalActiveLengthHot_; - std::vector all_triggers_; - std::vector hltresults_; + std::vector hcal_ieta_, hcal_iphi_; + std::vector hcalDepthEnergy_[depthMax_]; + std::vector hcalDepthActiveLength_[depthMax_]; + std::vector hcalDepthEnergyHot_[depthMax_]; + std::vector hcalDepthActiveLengthHot_[depthMax_]; + std::vector hcalDepthChargeHot_[depthMax_]; + std::vector hcalDepthChargeHotBG_[depthMax_]; + std::vector hcalDepthEnergyCorr_[depthMax_]; + std::vector hcalDepthEnergyHotCorr_[depthMax_]; + std::vector hcalDepthMatch_[depthMax_]; + std::vector hcalDepthMatchHot_[depthMax_]; + std::vector hcalActiveLength_, hcalActiveLengthHot_; + std::vector all_triggers_; + std::vector hltresults_; std::vector actHB, actHE; - std::map corrValue_; + std::map corrValue_; //////////////////////////////////////////////////////////// - }; -HcalHBHEMuonAnalyzer::HcalHBHEMuonAnalyzer(const edm::ParameterSet& iConfig) : - hlTriggerResults_(iConfig.getParameter("hlTriggerResults")), - labelEBRecHit_(iConfig.getParameter("labelEBRecHit")), - labelEERecHit_(iConfig.getParameter("labelEERecHit")), - labelHBHERecHit_(iConfig.getParameter("labelHBHERecHit")), - labelVtx_(iConfig.getParameter("labelVertex")), - labelMuon_(iConfig.getParameter("labelMuon")), - fileInCorr_(iConfig.getUntrackedParameter("fileInCorr","")), - triggers_(iConfig.getParameter>("triggers")), - verbosity_(iConfig.getUntrackedParameter("verbosity",0)), - useRaw_(iConfig.getParameter("useRaw")), - unCorrect_(iConfig.getParameter("unCorrect")), - collapseDepth_(iConfig.getParameter("collapseDepth")), - isItPlan1_(iConfig.getParameter("isItPlan1")), - ignoreHECorr_(iConfig.getUntrackedParameter("ignoreHECorr",false)), - isItPreRecHit_(iConfig.getUntrackedParameter("isItPreRecHit",false)), - getCharge_(iConfig.getParameter("getCharge")), - writeRespCorr_(iConfig.getUntrackedParameter("writeRespCorr",false)), - hdc_(nullptr), theHBHETopology_(nullptr), respCorrs_(nullptr) { - +HcalHBHEMuonAnalyzer::HcalHBHEMuonAnalyzer(const edm::ParameterSet& iConfig) + : hlTriggerResults_(iConfig.getParameter("hlTriggerResults")), + labelEBRecHit_(iConfig.getParameter("labelEBRecHit")), + labelEERecHit_(iConfig.getParameter("labelEERecHit")), + labelHBHERecHit_(iConfig.getParameter("labelHBHERecHit")), + labelVtx_(iConfig.getParameter("labelVertex")), + labelMuon_(iConfig.getParameter("labelMuon")), + fileInCorr_(iConfig.getUntrackedParameter("fileInCorr", "")), + triggers_(iConfig.getParameter>("triggers")), + verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + useRaw_(iConfig.getParameter("useRaw")), + unCorrect_(iConfig.getParameter("unCorrect")), + collapseDepth_(iConfig.getParameter("collapseDepth")), + isItPlan1_(iConfig.getParameter("isItPlan1")), + ignoreHECorr_(iConfig.getUntrackedParameter("ignoreHECorr", false)), + isItPreRecHit_(iConfig.getUntrackedParameter("isItPreRecHit", false)), + getCharge_(iConfig.getParameter("getCharge")), + writeRespCorr_(iConfig.getUntrackedParameter("writeRespCorr", false)), + hdc_(nullptr), + theHBHETopology_(nullptr), + respCorrs_(nullptr) { usesResource(TFileService::kSharedResource); //now do what ever initialization is needed - kount_ = 0; - maxDepth_ = iConfig.getUntrackedParameter("maxDepth",4); - if (maxDepth_ > depthMax_) maxDepth_ = depthMax_; - else if (maxDepth_ < 1) maxDepth_ = 4; - std::string modnam = iConfig.getUntrackedParameter("moduleName",""); - std::string procnm = iConfig.getUntrackedParameter("processName",""); - - mergedDepth_ = (!isItPreRecHit_) || (collapseDepth_); - tok_trigRes_ = consumes(hlTriggerResults_); - tok_EB_ = consumes(labelEBRecHit_); - tok_EE_ = consumes(labelEERecHit_); - tok_HBHE_ = consumes(labelHBHERecHit_); + kount_ = 0; + maxDepth_ = iConfig.getUntrackedParameter("maxDepth", 4); + if (maxDepth_ > depthMax_) + maxDepth_ = depthMax_; + else if (maxDepth_ < 1) + maxDepth_ = 4; + std::string modnam = iConfig.getUntrackedParameter("moduleName", ""); + std::string procnm = iConfig.getUntrackedParameter("processName", ""); + + mergedDepth_ = (!isItPreRecHit_) || (collapseDepth_); + tok_trigRes_ = consumes(hlTriggerResults_); + tok_EB_ = consumes(labelEBRecHit_); + tok_EE_ = consumes(labelEERecHit_); + tok_HBHE_ = consumes(labelHBHERecHit_); if (modnam.empty()) { - tok_Vtx_ = consumes(labelVtx_); - tok_Muon_ = consumes(labelMuon_); - edm::LogVerbatim("HBHEMuon") << "Labels used: Trig " << hlTriggerResults_ - << " Vtx " << labelVtx_ << " EB " - << labelEBRecHit_ << " EE " - << labelEERecHit_ << " HBHE " - << labelHBHERecHit_ << " MU " << labelMuon_; + tok_Vtx_ = consumes(labelVtx_); + tok_Muon_ = consumes(labelMuon_); + edm::LogVerbatim("HBHEMuon") << "Labels used: Trig " << hlTriggerResults_ << " Vtx " << labelVtx_ << " EB " + << labelEBRecHit_ << " EE " << labelEERecHit_ << " HBHE " << labelHBHERecHit_ << " MU " + << labelMuon_; } else { - tok_Vtx_ = consumes(edm::InputTag(modnam,labelVtx_,procnm)); - tok_Muon_ = consumes(edm::InputTag(modnam,labelMuon_,procnm)); - edm::LogVerbatim("HBHEMuon") << "Labels used Trig " << hlTriggerResults_ - << "\n Vtx " << edm::InputTag(modnam,labelVtx_,procnm) - << "\n EB " << labelEBRecHit_ - << "\n EE " << labelEERecHit_ - << "\n HBHE " << labelHBHERecHit_ - << "\n MU " << edm::InputTag(modnam,labelMuon_,procnm); + tok_Vtx_ = consumes(edm::InputTag(modnam, labelVtx_, procnm)); + tok_Muon_ = consumes(edm::InputTag(modnam, labelMuon_, procnm)); + edm::LogVerbatim("HBHEMuon") << "Labels used Trig " << hlTriggerResults_ << "\n Vtx " + << edm::InputTag(modnam, labelVtx_, procnm) << "\n EB " << labelEBRecHit_ + << "\n EE " << labelEERecHit_ << "\n HBHE " << labelHBHERecHit_ << "\n MU " + << edm::InputTag(modnam, labelMuon_, procnm); } if (!fileInCorr_.empty()) { std::ifstream infile(fileInCorr_.c_str()); if (infile.is_open()) { while (true) { - unsigned int id; - double cfac; - infile >> id >> cfac; - if (!infile.good()) break; - corrValue_[DetId(id)] = cfac; + unsigned int id; + double cfac; + infile >> id >> cfac; + if (!infile.good()) + break; + corrValue_[DetId(id)] = cfac; } infile.close(); } } useMyCorr_ = (!corrValue_.empty()); - edm::LogVerbatim("HBHEMuon") << "Flags used: UseRaw " << useRaw_ - << " GetCharge " << getCharge_ << " UnCorrect " - << unCorrect_ << " IgnoreHECorr " - << ignoreHECorr_ << " CollapseDepth " - << collapseDepth_ << ":" << mergedDepth_ - << " IsItPlan1 " << isItPlan1_ - << " IsItPreRecHit " << isItPreRecHit_ - << " UseMyCorr " << useMyCorr_; + edm::LogVerbatim("HBHEMuon") << "Flags used: UseRaw " << useRaw_ << " GetCharge " << getCharge_ << " UnCorrect " + << unCorrect_ << " IgnoreHECorr " << ignoreHECorr_ << " CollapseDepth " << collapseDepth_ + << ":" << mergedDepth_ << " IsItPlan1 " << isItPlan1_ << " IsItPreRecHit " + << isItPreRecHit_ << " UseMyCorr " << useMyCorr_; } // @@ -246,53 +239,46 @@ HcalHBHEMuonAnalyzer::HcalHBHEMuonAnalyzer(const edm::ParameterSet& iConfig) : void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { ++kount_; clearVectors(); - runNumber_ = iEvent.id().run(); + runNumber_ = iEvent.id().run(); eventNumber_ = iEvent.id().event(); - lumiNumber_ = iEvent.id().luminosityBlock(); - bxNumber_ = iEvent.bunchCrossing(); + lumiNumber_ = iEvent.id().luminosityBlock(); + bxNumber_ = iEvent.bunchCrossing(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "Run " << runNumber_ << " Event " - << eventNumber_ << " Lumi " << lumiNumber_ - << " BX " << bxNumber_ << std::endl; -#endif + edm::LogVerbatim("HBHEMuon") << "Run " << runNumber_ << " Event " << eventNumber_ << " Lumi " << lumiNumber_ << " BX " + << bxNumber_ << std::endl; +#endif edm::Handle _Triggers; - iEvent.getByToken(tok_trigRes_, _Triggers); + iEvent.getByToken(tok_trigRes_, _Triggers); #ifdef EDM_ML_DEBUG - if ((verbosity_/10000)%10>0) - edm::LogVerbatim("HBHEMuon") << "Size of all triggers " - << all_triggers_.size() << std::endl; + if ((verbosity_ / 10000) % 10 > 0) + edm::LogVerbatim("HBHEMuon") << "Size of all triggers " << all_triggers_.size() << std::endl; #endif int Ntriggers = all_triggers_.size(); #ifdef EDM_ML_DEBUG - if ((verbosity_/10000)%10>0) - edm::LogVerbatim("HBHEMuon") << "Size of HLT MENU: " << _Triggers->size() - << std::endl; + if ((verbosity_ / 10000) % 10 > 0) + edm::LogVerbatim("HBHEMuon") << "Size of HLT MENU: " << _Triggers->size() << std::endl; #endif if (_Triggers.isValid()) { - const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers); + const edm::TriggerNames& triggerNames_ = iEvent.triggerNames(*_Triggers); std::vector index; - for (int i=0; isize()); + int triggerSize = int(_Triggers->size()); #ifdef EDM_ML_DEBUG - if ((verbosity_/10000)%10>0) - edm::LogVerbatim("HBHEMuon") << "outside loop " << index[i] - << "\ntriggerSize " << triggerSize - << std::endl; + if ((verbosity_ / 10000) % 10 > 0) + edm::LogVerbatim("HBHEMuon") << "outside loop " << index[i] << "\ntriggerSize " << triggerSize << std::endl; #endif if (index[i] < triggerSize) { - hltresults_.push_back(_Triggers->accept(index[i])); + hltresults_.push_back(_Triggers->accept(index[i])); #ifdef EDM_ML_DEBUG - if ((verbosity_/10000)%10>0) - edm::LogVerbatim("HBHEMuon") << "Trigger_info " << triggerSize - << " triggerSize " << index[i] - << " trigger_index " << hltresults_.at(i) - << " hltresult" << std::endl; + if ((verbosity_ / 10000) % 10 > 0) + edm::LogVerbatim("HBHEMuon") << "Trigger_info " << triggerSize << " triggerSize " << index[i] + << " trigger_index " << hltresults_.at(i) << " hltresult" << std::endl; #endif } else { - if ((verbosity_/10000)%10>0) - edm::LogVerbatim("HBHEMuon") << "Requested HLT path \"" - << "\" does not exist\n"; + if ((verbosity_ / 10000) % 10 > 0) + edm::LogVerbatim("HBHEMuon") << "Requested HLT path \"" + << "\" does not exist\n"; } } } @@ -301,11 +287,11 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + edm::ESHandle bFieldH; iSetup.get().get(bFieldH); const MagneticField* bField = bFieldH.product(); - + edm::ESHandle ecalChStatus; iSetup.get().get(ecalChStatus); const EcalChannelStatus* theEcalChStatus = ecalChStatus.product(); @@ -315,7 +301,7 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet edm::ESHandle theCaloTopology; iSetup.get().get(theCaloTopology); - const CaloTopology *caloTopology = theCaloTopology.product(); + const CaloTopology* caloTopology = theCaloTopology.product(); edm::ESHandle conditions; iSetup.get().get(conditions); @@ -345,112 +331,120 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet return; } reco::VertexCollection::const_iterator firstGoodVertex = vtx->end(); - for (reco::VertexCollection::const_iterator it = vtx->begin(); - it != vtx->end(); it++) { + for (reco::VertexCollection::const_iterator it = vtx->begin(); it != vtx->end(); it++) { if (isGoodVertex(*it)) { - if (firstGoodVertex == vtx->end()) firstGoodVertex = it; + if (firstGoodVertex == vtx->end()) + firstGoodVertex = it; ++goodVertex_; } } - if (firstGoodVertex != vtx->end()) pvx = firstGoodVertex->position(); - + if (firstGoodVertex != vtx->end()) + pvx = firstGoodVertex->position(); + bool accept(false); - if (_Muon.isValid() && barrelRecHitsHandle.isValid() && - endcapRecHitsHandle.isValid() && hbhe.isValid()) { - for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) { - + if (_Muon.isValid() && barrelRecHitsHandle.isValid() && endcapRecHitsHandle.isValid() && hbhe.isValid()) { + for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon != _Muon->end(); ++RecMuon) { muon_is_good_.push_back(RecMuon->isPFMuon()); muon_global_.push_back(RecMuon->isGlobalMuon()); muon_tracker_.push_back(RecMuon->isTrackerMuon()); ptGlob_.push_back((RecMuon)->pt()); etaGlob_.push_back(RecMuon->eta()); phiGlob_.push_back(RecMuon->phi()); - energyMuon_.push_back(RecMuon->energy()); + energyMuon_.push_back(RecMuon->energy()); pMuon_.push_back(RecMuon->p()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "Energy:" << RecMuon->energy() << " P:" - << RecMuon->p() << std::endl; + edm::LogVerbatim("HBHEMuon") << "Energy:" << RecMuon->energy() << " P:" << RecMuon->p() << std::endl; #endif - muon_is_tight_.push_back(muon::isTightMuon(*RecMuon,*firstGoodVertex)); + muon_is_tight_.push_back(muon::isTightMuon(*RecMuon, *firstGoodVertex)); muon_is_medium_.push_back(muon::isMediumMuon(*RecMuon)); muon_trkKink.push_back(RecMuon->combinedQuality().trkKink); muon_chi2LocalPosition.push_back(RecMuon->combinedQuality().chi2LocalPosition); muon_segComp.push_back(muon::segmentCompatibility(*RecMuon)); // acessing tracker hits info if (RecMuon->track().isNonnull()) { - trackerLayer_.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement()); + trackerLayer_.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement()); } else { - trackerLayer_.push_back(-1); + trackerLayer_.push_back(-1); } if (RecMuon->innerTrack().isNonnull()) { - innerTrack_.push_back(true); - numPixelLayers_.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement()); - chiTracker_.push_back(RecMuon->innerTrack()->normalizedChi2()); - dxyTracker_.push_back(fabs(RecMuon->innerTrack()->dxy(pvx))); - dzTracker_.push_back(fabs(RecMuon->innerTrack()->dz(pvx))); - innerTrackpt_.push_back(RecMuon->innerTrack()->pt()); - innerTracketa_.push_back(RecMuon->innerTrack()->eta()); - innerTrackphi_.push_back(RecMuon->innerTrack()->phi()); - tight_PixelHits_.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits()); - tight_validFraction_.push_back(RecMuon->innerTrack()->validFraction()); + innerTrack_.push_back(true); + numPixelLayers_.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement()); + chiTracker_.push_back(RecMuon->innerTrack()->normalizedChi2()); + dxyTracker_.push_back(fabs(RecMuon->innerTrack()->dxy(pvx))); + dzTracker_.push_back(fabs(RecMuon->innerTrack()->dz(pvx))); + innerTrackpt_.push_back(RecMuon->innerTrack()->pt()); + innerTracketa_.push_back(RecMuon->innerTrack()->eta()); + innerTrackphi_.push_back(RecMuon->innerTrack()->phi()); + tight_PixelHits_.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits()); + tight_validFraction_.push_back(RecMuon->innerTrack()->validFraction()); } else { - innerTrack_.push_back(false); - numPixelLayers_.push_back(0); - chiTracker_.push_back(0); - dxyTracker_.push_back(0); - dzTracker_.push_back(0); - innerTrackpt_.push_back(0); - innerTracketa_.push_back(0); - innerTrackphi_.push_back(0); - tight_PixelHits_.push_back(0); - tight_validFraction_.push_back(-99); + innerTrack_.push_back(false); + numPixelLayers_.push_back(0); + chiTracker_.push_back(0); + dxyTracker_.push_back(0); + dzTracker_.push_back(0); + innerTrackpt_.push_back(0); + innerTracketa_.push_back(0); + innerTrackphi_.push_back(0); + tight_PixelHits_.push_back(0); + tight_validFraction_.push_back(-99); } // outer track info if (RecMuon->outerTrack().isNonnull()) { - outerTrack_.push_back(true); - outerTrackPt_.push_back(RecMuon->outerTrack()->pt()); - outerTrackEta_.push_back(RecMuon->outerTrack()->eta()); - outerTrackPhi_.push_back(RecMuon->outerTrack()->phi()); - outerTrackChi_.push_back(RecMuon->outerTrack()->normalizedChi2()); - outerTrackHits_.push_back(RecMuon->outerTrack()->numberOfValidHits()); - outerTrackRHits_.push_back(RecMuon->outerTrack()->recHitsSize()); + outerTrack_.push_back(true); + outerTrackPt_.push_back(RecMuon->outerTrack()->pt()); + outerTrackEta_.push_back(RecMuon->outerTrack()->eta()); + outerTrackPhi_.push_back(RecMuon->outerTrack()->phi()); + outerTrackChi_.push_back(RecMuon->outerTrack()->normalizedChi2()); + outerTrackHits_.push_back(RecMuon->outerTrack()->numberOfValidHits()); + outerTrackRHits_.push_back(RecMuon->outerTrack()->recHitsSize()); } else { - outerTrack_.push_back(false); - outerTrackPt_.push_back(0); - outerTrackEta_.push_back(0); - outerTrackPhi_.push_back(0); - outerTrackChi_.push_back(0); - outerTrackHits_.push_back(0); - outerTrackRHits_.push_back(0); + outerTrack_.push_back(false); + outerTrackPt_.push_back(0); + outerTrackEta_.push_back(0); + outerTrackPhi_.push_back(0); + outerTrackChi_.push_back(0); + outerTrackHits_.push_back(0); + outerTrackRHits_.push_back(0); } // Tight Muon cuts - if (RecMuon->globalTrack().isNonnull()) { - globalTrack_.push_back(true); - chiGlobal_.push_back(RecMuon->globalTrack()->normalizedChi2()); - globalMuonHits_.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits()); - matchedStat_.push_back(RecMuon->numberOfMatchedStations()); - globalTrckPt_.push_back(RecMuon->globalTrack()->pt()); - globalTrckEta_.push_back(RecMuon->globalTrack()->eta()); - globalTrckPhi_.push_back(RecMuon->globalTrack()->phi()); - tight_TransImpara_.push_back(fabs(RecMuon->muonBestTrack()->dxy(pvx))); - tight_LongPara_.push_back(fabs(RecMuon->muonBestTrack()->dz(pvx))); + if (RecMuon->globalTrack().isNonnull()) { + globalTrack_.push_back(true); + chiGlobal_.push_back(RecMuon->globalTrack()->normalizedChi2()); + globalMuonHits_.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits()); + matchedStat_.push_back(RecMuon->numberOfMatchedStations()); + globalTrckPt_.push_back(RecMuon->globalTrack()->pt()); + globalTrckEta_.push_back(RecMuon->globalTrack()->eta()); + globalTrckPhi_.push_back(RecMuon->globalTrack()->phi()); + tight_TransImpara_.push_back(fabs(RecMuon->muonBestTrack()->dxy(pvx))); + tight_LongPara_.push_back(fabs(RecMuon->muonBestTrack()->dz(pvx))); } else { - globalTrack_.push_back(false); - chiGlobal_.push_back(0); - globalMuonHits_.push_back(0); - matchedStat_.push_back(0); - globalTrckPt_.push_back(0); - globalTrckEta_.push_back(0); - globalTrckPhi_.push_back(0); - tight_TransImpara_.push_back(0); - tight_LongPara_.push_back(0); + globalTrack_.push_back(false); + chiGlobal_.push_back(0); + globalMuonHits_.push_back(0); + matchedStat_.push_back(0); + globalTrckPt_.push_back(0); + globalTrckEta_.push_back(0); + globalTrckPhi_.push_back(0); + tight_TransImpara_.push_back(0); + tight_LongPara_.push_back(0); } - - isolationR04_.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) ); - - isolationR03_.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt())); - ecalEnergy_.push_back(RecMuon->calEnergy().emS9); + isolationR04_.push_back( + ((RecMuon->pfIsolationR04().sumChargedHadronPt + + std::max(0., + RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - + (0.5 * RecMuon->pfIsolationR04().sumPUPt))) / + RecMuon->pt())); + + isolationR03_.push_back( + ((RecMuon->pfIsolationR03().sumChargedHadronPt + + std::max(0., + RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - + (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / + RecMuon->pt())); + + ecalEnergy_.push_back(RecMuon->calEnergy().emS9); hcalEnergy_.push_back(RecMuon->calEnergy().hadS9); hoEnergy_.push_back(RecMuon->calEnergy().hoS9); @@ -459,275 +453,319 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet double eHcalDepthC[depthMax_], eHcalDepthHotC[depthMax_]; double cHcalDepthHot[depthMax_], cHcalDepthHotBG[depthMax_]; double activeL[depthMax_], activeHotL[depthMax_]; - bool matchDepth[depthMax_], matchDepthHot[depthMax_]; + bool matchDepth[depthMax_], matchDepthHot[depthMax_]; HcalDetId eHcalDetId[depthMax_]; unsigned int isHot(0); - bool tmpmatch(false); + bool tmpmatch(false); int ieta(-1000), iphi(-1000); - for (int i=0; iinnerTrack().isNonnull()) { - const reco::Track* pTrack = (RecMuon->innerTrack()).get(); - spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0))); - if ((RecMuon->p()>10.0) && (trackID.okHCAL)) accept = true; - - ecalDetId_.push_back((trackID.detIdECAL)()); - hcalDetId_.push_back((trackID.detIdHCAL)()); - ehcalDetId_.push_back((trackID.detIdEHCAL)()); - - HcalDetId check; - std::pair info = spr::propagateHCALBack(pTrack, geo, bField, (((verbosity_/100)%10>0))); - if (info.first) { - check = info.second; - } - - bool okE = trackID.okECAL; - if (okE) { - const DetId isoCell(trackID.detIdECAL); - std::pair e3x3 = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle,*theEcalChStatus,geo,caloTopology,sevlv.product(),1,1,-100.0,-100.0,-500.0,500.0,false); - eEcal = e3x3.first; - okE = e3x3.second; - } + const reco::Track* pTrack = (RecMuon->innerTrack()).get(); + spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_ / 100) % 10 > 0))); + if ((RecMuon->p() > 10.0) && (trackID.okHCAL)) + accept = true; + + ecalDetId_.push_back((trackID.detIdECAL)()); + hcalDetId_.push_back((trackID.detIdHCAL)()); + ehcalDetId_.push_back((trackID.detIdEHCAL)()); + + HcalDetId check; + std::pair info = spr::propagateHCALBack(pTrack, geo, bField, (((verbosity_ / 100) % 10 > 0))); + if (info.first) { + check = info.second; + } + + bool okE = trackID.okECAL; + if (okE) { + const DetId isoCell(trackID.detIdECAL); + std::pair e3x3 = spr::eECALmatrix(isoCell, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + sevlv.product(), + 1, + 1, + -100.0, + -100.0, + -500.0, + 500.0, + false); + eEcal = e3x3.first; + okE = e3x3.second; + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "Propagate Track to ECAL: " << okE - << ":" << trackID.okECAL << " E " < > ehdepth; - spr::energyHCALCell((HcalDetId)closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(ieta,iphi), (((verbosity_/1000)%10)>0)); - for (int i=0; i= depth16HE(ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet; - HcalDetId hcid0(subdet0,ieta,iphi,ehdepth[i].second); - double actL = activeLength(DetId(hcid0)); - double ene = ehdepth[i].first; - bool tmpC(false); - if (ene > 0.0) { - if (!(theHBHETopology_->validHcal(hcid0))) { - edm::LogWarning("HBHEMuon") << "(1) Invalid ID " << hcid0 - << " with E = " << ene; - edm::LogWarning("HBHEMuon") << HcalDetId(closestCell) - << " with " << ehdepth.size() - << " depths:"; - for (const auto& ehd : ehdepth) - edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" - << ehd.first; - } else { - tmpC = goodCell(hcid0, pTrack, geo, bField); - double enec(ene); - if (unCorrect_) { - double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); - if (corr != 0) ene /= corr; + + HcalSubdetector subdet = hcidt.subdet(); + ieta = hcidt.ieta(); + iphi = hcidt.iphi(); + bool hborhe = (std::abs(ieta) == 16); + + eHcal = spr::eHCALmatrix(theHBHETopology_, + closestCell, + hbhe, + 0, + 0, + false, + true, + -100.0, + -100.0, + -100.0, + -100.0, + -500., + 500., + useRaw_); + std::vector> ehdepth; + spr::energyHCALCell((HcalDetId)closestCell, + hbhe, + ehdepth, + maxDepth_, + -100.0, + -100.0, + -100.0, + -100.0, + -500.0, + 500.0, + useRaw_, + depth16HE(ieta, iphi), + (((verbosity_ / 1000) % 10) > 0)); + for (int i = 0; i < depthMax_; ++i) + eHcalDetId[i] = HcalDetId(); + for (unsigned int i = 0; i < ehdepth.size(); ++i) { + HcalSubdetector subdet0 = + (hborhe) ? ((ehdepth[i].second >= depth16HE(ieta, iphi)) ? HcalEndcap : HcalBarrel) : subdet; + HcalDetId hcid0(subdet0, ieta, iphi, ehdepth[i].second); + double actL = activeLength(DetId(hcid0)); + double ene = ehdepth[i].first; + bool tmpC(false); + if (ene > 0.0) { + if (!(theHBHETopology_->validHcal(hcid0))) { + edm::LogWarning("HBHEMuon") << "(1) Invalid ID " << hcid0 << " with E = " << ene; + edm::LogWarning("HBHEMuon") << HcalDetId(closestCell) << " with " << ehdepth.size() << " depths:"; + for (const auto& ehd : ehdepth) + edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" << ehd.first; + } else { + tmpC = goodCell(hcid0, pTrack, geo, bField); + double enec(ene); + if (unCorrect_) { + double corr = (ignoreHECorr_ && (subdet0 == HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); + if (corr != 0) + ene /= corr; #ifdef EDM_ML_DEBUG - HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; - edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id << " Corr " - << corr; + HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; + edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id << " Corr " << corr; #endif - } - int depth = ehdepth[i].second - 1; - if (collapseDepth_) { - HcalDetId id = hdc_->mergedDepthDetId(hcid0); - depth = id.depth() - 1; - } - eHcalDepth[depth] += ene; - eHcalDepthC[depth]+= enec; - activeL[depth] += actL; - activeLengthTot += actL; - matchDepth[depth] = (matchDepth[depth] && tmpC); + } + int depth = ehdepth[i].second - 1; + if (collapseDepth_) { + HcalDetId id = hdc_->mergedDepthDetId(hcid0); + depth = id.depth() - 1; + } + eHcalDepth[depth] += ene; + eHcalDepthC[depth] += enec; + activeL[depth] += actL; + activeLengthTot += actL; + matchDepth[depth] = (matchDepth[depth] && tmpC); #ifdef EDM_ML_DEBUG - if ((verbosity_%10) > 0) - edm::LogVerbatim("HBHEMuon") << hcid0 << " E " << ene << ":" - << enec << " L " << actL - << " Match " << tmpC; + if ((verbosity_ % 10) > 0) + edm::LogVerbatim("HBHEMuon") + << hcid0 << " E " << ene << ":" << enec << " L " << actL << " Match " << tmpC; #endif - } - } - } + } + } + } #ifdef EDM_ML_DEBUG - if ((verbosity_%10) > 0) { - edm::LogVerbatim("HBHEMuon") << hcidt << " Match " << tmpmatch - << " Depths " << ehdepth.size(); - for (unsigned int k=0; k 0) { + edm::LogVerbatim("HBHEMuon") << hcidt << " Match " << tmpmatch << " Depths " << ehdepth.size(); + for (unsigned int k = 0; k < ehdepth.size(); ++k) + edm::LogVerbatim("HBHEMuon") << " [" << k << ":" << ehdepth[k].second << "] " << matchDepth[k]; + } #endif - HcalDetId hotCell; - spr::eHCALmatrix(geo, theHBHETopology_, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false); - isHot = matchId(closestCell,hotCell); - if (hotCell != HcalDetId()) { - subdet = HcalDetId(hotCell).subdet(); - ieta = HcalDetId(hotCell).ieta(); - iphi = HcalDetId(hotCell).iphi(); - hborhe = (std::abs(ieta) == 16); - std::vector > ehdepth; - spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(ieta,iphi), false);//(((verbosity_/1000)%10)>0 )); - for (int i=0; i= depth16HE(ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet; - HcalDetId hcid0(subdet0,ieta,iphi,ehdepth[i].second); - double actL = activeLength(DetId(hcid0)); - double ene = ehdepth[i].first; - bool tmpC(false); - if (ene > 0.0) { - if (!(theHBHETopology_->validHcal(hcid0))) { - edm::LogWarning("HBHEMuon") << "(2) Invalid ID " << hcid0 - << " with E = " << ene; - edm::LogWarning("HBHEMuon") << HcalDetId(hotCell) - << " with " << ehdepth.size() - << " depths:"; - for (const auto& ehd : ehdepth) - edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" - << ehd.first; - } else { - tmpC = goodCell(hcid0, pTrack, geo, bField); - double chg(ene), enec(ene); - if (unCorrect_) { - double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); - if (corr != 0) ene /= corr; + HcalDetId hotCell; + spr::eHCALmatrix(geo, theHBHETopology_, closestCell, hbhe, 1, 1, hotCell, false, useRaw_, false); + isHot = matchId(closestCell, hotCell); + if (hotCell != HcalDetId()) { + subdet = HcalDetId(hotCell).subdet(); + ieta = HcalDetId(hotCell).ieta(); + iphi = HcalDetId(hotCell).iphi(); + hborhe = (std::abs(ieta) == 16); + std::vector> ehdepth; + spr::energyHCALCell(hotCell, + hbhe, + ehdepth, + maxDepth_, + -100.0, + -100.0, + -100.0, + -100.0, + -500.0, + 500.0, + useRaw_, + depth16HE(ieta, iphi), + false); //(((verbosity_/1000)%10)>0 )); + for (int i = 0; i < depthMax_; ++i) + eHcalDetId[i] = HcalDetId(); + for (unsigned int i = 0; i < ehdepth.size(); ++i) { + HcalSubdetector subdet0 = + (hborhe) ? ((ehdepth[i].second >= depth16HE(ieta, iphi)) ? HcalEndcap : HcalBarrel) : subdet; + HcalDetId hcid0(subdet0, ieta, iphi, ehdepth[i].second); + double actL = activeLength(DetId(hcid0)); + double ene = ehdepth[i].first; + bool tmpC(false); + if (ene > 0.0) { + if (!(theHBHETopology_->validHcal(hcid0))) { + edm::LogWarning("HBHEMuon") << "(2) Invalid ID " << hcid0 << " with E = " << ene; + edm::LogWarning("HBHEMuon") << HcalDetId(hotCell) << " with " << ehdepth.size() << " depths:"; + for (const auto& ehd : ehdepth) + edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" << ehd.first; + } else { + tmpC = goodCell(hcid0, pTrack, geo, bField); + double chg(ene), enec(ene); + if (unCorrect_) { + double corr = (ignoreHECorr_ && (subdet0 == HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); + if (corr != 0) + ene /= corr; #ifdef EDM_ML_DEBUG - HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; - edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id - << " Corr " << corr << " E " - << ene << ":" << enec; + HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; + edm::LogVerbatim("HBHEMuon") + << hcid0 << ":" << id << " Corr " << corr << " E " << ene << ":" << enec; #endif - } - if (getCharge_) { - double gain = gainFactor(conditions,hcid0); - if (gain != 0) chg /= gain; + } + if (getCharge_) { + double gain = gainFactor(conditions, hcid0); + if (gain != 0) + chg /= gain; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain - << " C " << chg; + edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain << " C " << chg; #endif - } - int depth = ehdepth[i].second - 1; - if (collapseDepth_) { - HcalDetId id = hdc_->mergedDepthDetId(hcid0); - depth = id.depth() - 1; - } - eHcalDepthHot[depth] += ene; - eHcalDepthHotC[depth] += enec; - cHcalDepthHot[depth] += chg; - activeHotL[depth] += actL; - activeLengthHotTot += actL; - matchDepthHot[depth] = (matchDepthHot[depth] && tmpC); + } + int depth = ehdepth[i].second - 1; + if (collapseDepth_) { + HcalDetId id = hdc_->mergedDepthDetId(hcid0); + depth = id.depth() - 1; + } + eHcalDepthHot[depth] += ene; + eHcalDepthHotC[depth] += enec; + cHcalDepthHot[depth] += chg; + activeHotL[depth] += actL; + activeLengthHotTot += actL; + matchDepthHot[depth] = (matchDepthHot[depth] && tmpC); #ifdef EDM_ML_DEBUG - if ((verbosity_%10) > 0) - edm::LogVerbatim("HBHEMuon") << hcid0 << " depth " << depth - << " E " << ene << ":" << enec - << " C " << chg << " L " - << actL << " Match " << tmpC; + if ((verbosity_ % 10) > 0) + edm::LogVerbatim("HBHEMuon") << hcid0 << " depth " << depth << " E " << ene << ":" << enec << " C " + << chg << " L " << actL << " Match " << tmpC; #endif - } - } - } - - HcalDetId oppCell(subdet,-ieta,iphi,HcalDetId(hotCell).depth()); - std::vector > ehdeptho; - spr::energyHCALCell(oppCell, hbhe, ehdeptho, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(-ieta,iphi), false); //(((verbosity_/1000)%10)>0)); - for (unsigned int i=0; i= depth16HE(-ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet; - HcalDetId hcid0(subdet0,-ieta,iphi,ehdeptho[i].second); - double ene = ehdeptho[i].first; - if (ene > 0.0) { - if (!(theHBHETopology_->validHcal(hcid0))) { - edm::LogWarning("HBHEMuon") << "(3) Invalid ID " << hcid0 - << " with E = " << ene; - edm::LogWarning("HBHEMuon") << oppCell << " with " - << ehdeptho.size() << " depths:"; - for (const auto& ehd : ehdeptho) - edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" - << ehd.first; - } else { - double chg(ene); - if (unCorrect_) { - double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); - if (corr != 0) ene /= corr; + } + } + } + + HcalDetId oppCell(subdet, -ieta, iphi, HcalDetId(hotCell).depth()); + std::vector> ehdeptho; + spr::energyHCALCell(oppCell, + hbhe, + ehdeptho, + maxDepth_, + -100.0, + -100.0, + -100.0, + -100.0, + -500.0, + 500.0, + useRaw_, + depth16HE(-ieta, iphi), + false); //(((verbosity_/1000)%10)>0)); + for (unsigned int i = 0; i < ehdeptho.size(); ++i) { + HcalSubdetector subdet0 = + (hborhe) ? ((ehdeptho[i].second >= depth16HE(-ieta, iphi)) ? HcalEndcap : HcalBarrel) : subdet; + HcalDetId hcid0(subdet0, -ieta, iphi, ehdeptho[i].second); + double ene = ehdeptho[i].first; + if (ene > 0.0) { + if (!(theHBHETopology_->validHcal(hcid0))) { + edm::LogWarning("HBHEMuon") << "(3) Invalid ID " << hcid0 << " with E = " << ene; + edm::LogWarning("HBHEMuon") << oppCell << " with " << ehdeptho.size() << " depths:"; + for (const auto& ehd : ehdeptho) + edm::LogWarning("HBHEMuon") << " " << ehd.second << ":" << ehd.first; + } else { + double chg(ene); + if (unCorrect_) { + double corr = (ignoreHECorr_ && (subdet0 == HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0)); + if (corr != 0) + ene /= corr; #ifdef EDM_ML_DEBUG - HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; - edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id - << " Corr " << corr << " E " - << ene << ":" - << ehdeptho[i].first; + HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0; + edm::LogVerbatim("HBHEMuon") + << hcid0 << ":" << id << " Corr " << corr << " E " << ene << ":" << ehdeptho[i].first; #endif - } - if (getCharge_) { - double gain = gainFactor(conditions,hcid0); - if (gain != 0) chg /= gain; + } + if (getCharge_) { + double gain = gainFactor(conditions, hcid0); + if (gain != 0) + chg /= gain; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain - << " C " << chg; + edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain << " C " << chg; #endif - } - int depth = ehdeptho[i].second - 1; - if (collapseDepth_) { - HcalDetId id = hdc_->mergedDepthDetId(hcid0); - depth = id.depth() - 1; - } - cHcalDepthHotBG[depth] += chg; + } + int depth = ehdeptho[i].second - 1; + if (collapseDepth_) { + HcalDetId id = hdc_->mergedDepthDetId(hcid0); + depth = id.depth() - 1; + } + cHcalDepthHotBG[depth] += chg; #ifdef EDM_ML_DEBUG - if ((verbosity_%10) > 0) - edm::LogVerbatim("HBHEMuon") << hcid0 << " Depth " << depth - << " E " << ene << " C " - << chg; + if ((verbosity_ % 10) > 0) + edm::LogVerbatim("HBHEMuon") << hcid0 << " Depth " << depth << " E " << ene << " C " << chg; #endif - } - } - } - } - } + } + } + } + } + } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "Propagate Track to HCAL: " - << trackID.okHCAL << " Match " << tmpmatch - << " Hot " << isHot << " Energy " - << eHcal << std::endl; + edm::LogVerbatim("HBHEMuon") << "Propagate Track to HCAL: " << trackID.okHCAL << " Match " << tmpmatch + << " Hot " << isHot << " Energy " << eHcal << std::endl; #endif } else { - ecalDetId_.push_back(0); - hcalDetId_.push_back(0); - ehcalDetId_.push_back(0); + ecalDetId_.push_back(0); + hcalDetId_.push_back(0); + ehcalDetId_.push_back(0); } - matchedId_.push_back(tmpmatch); + matchedId_.push_back(tmpmatch); ecal3x3Energy_.push_back(eEcal); hcal1x1Energy_.push_back(eHcal); hcal_ieta_.push_back(ieta); hcal_iphi_.push_back(iphi); - for (int i=0; iFill(); } @@ -747,108 +784,106 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet // ------------ method called once each job just before starting event loop ------------ void HcalHBHEMuonAnalyzer::beginJob() { - tree_ = fs->make("TREE", "TREE"); - tree_->Branch("Event_No", &eventNumber_); - tree_->Branch("Run_No", &runNumber_); - tree_->Branch("LumiNumber", &lumiNumber_); - tree_->Branch("BXNumber", &bxNumber_); - tree_->Branch("GoodVertex", &goodVertex_); - tree_->Branch("PF_Muon", &muon_is_good_); - tree_->Branch("Global_Muon", &muon_global_); - tree_->Branch("Tracker_muon", &muon_tracker_); - tree_->Branch("MuonIsTight", &muon_is_tight_); - tree_->Branch("MuonIsMedium", &muon_is_medium_); - tree_->Branch("pt_of_muon", &ptGlob_); - tree_->Branch("eta_of_muon", &etaGlob_); - tree_->Branch("phi_of_muon", &phiGlob_); - tree_->Branch("energy_of_muon", &energyMuon_); - tree_->Branch("p_of_muon", &pMuon_); - tree_->Branch("muon_trkKink", &muon_trkKink); - tree_->Branch("muon_chi2LocalPosition", &muon_chi2LocalPosition); - tree_->Branch("muon_segComp", &muon_segComp); - - tree_->Branch("TrackerLayer", &trackerLayer_); - tree_->Branch("NumPixelLayers", &numPixelLayers_); - tree_->Branch("InnerTrackPixelHits", &tight_PixelHits_); - tree_->Branch("innerTrack", &innerTrack_); - tree_->Branch("chiTracker", &chiTracker_); - tree_->Branch("DxyTracker", &dxyTracker_); - tree_->Branch("DzTracker", &dzTracker_); - tree_->Branch("innerTrackpt", &innerTrackpt_); - tree_->Branch("innerTracketa", &innerTracketa_); - tree_->Branch("innerTrackphi", &innerTrackphi_); - tree_->Branch("tight_validFraction", &tight_validFraction_); - - tree_->Branch("OuterTrack", &outerTrack_); - tree_->Branch("OuterTrackChi", &outerTrackChi_); - tree_->Branch("OuterTrackPt", &outerTrackPt_); - tree_->Branch("OuterTrackEta", &outerTrackEta_); - tree_->Branch("OuterTrackPhi", &outerTrackPhi_); - tree_->Branch("OuterTrackHits", &outerTrackHits_); - tree_->Branch("OuterTrackRHits", &outerTrackRHits_); - - tree_->Branch("GlobalTrack", &globalTrack_); - tree_->Branch("GlobalTrckPt", &globalTrckPt_); - tree_->Branch("GlobalTrckEta", &globalTrckEta_); - tree_->Branch("GlobalTrckPhi", &globalTrckPhi_); - tree_->Branch("Global_Muon_Hits", &globalMuonHits_); - tree_->Branch("MatchedStations", &matchedStat_); - tree_->Branch("GlobTrack_Chi", &chiGlobal_); - tree_->Branch("Tight_LongitudinalImpactparameter",&tight_LongPara_); - tree_->Branch("Tight_TransImpactparameter", &tight_TransImpara_); - - tree_->Branch("IsolationR04", &isolationR04_); - tree_->Branch("IsolationR03", &isolationR03_); - tree_->Branch("ecal_3into3", &ecalEnergy_); - tree_->Branch("hcal_3into3", &hcalEnergy_); - tree_->Branch("tracker_3into3", &hoEnergy_); - - tree_->Branch("matchedId", &matchedId_); - tree_->Branch("hcal_cellHot", &hcalHot_); - - tree_->Branch("ecal_3x3", &ecal3x3Energy_); - tree_->Branch("hcal_1x1", &hcal1x1Energy_); - tree_->Branch("ecal_detID", &ecalDetId_); - tree_->Branch("hcal_detID", &hcalDetId_); - tree_->Branch("ehcal_detID", &ehcalDetId_); - tree_->Branch("hcal_ieta", &hcal_ieta_); - tree_->Branch("hcal_iphi", &hcal_iphi_); + tree_->Branch("Event_No", &eventNumber_); + tree_->Branch("Run_No", &runNumber_); + tree_->Branch("LumiNumber", &lumiNumber_); + tree_->Branch("BXNumber", &bxNumber_); + tree_->Branch("GoodVertex", &goodVertex_); + tree_->Branch("PF_Muon", &muon_is_good_); + tree_->Branch("Global_Muon", &muon_global_); + tree_->Branch("Tracker_muon", &muon_tracker_); + tree_->Branch("MuonIsTight", &muon_is_tight_); + tree_->Branch("MuonIsMedium", &muon_is_medium_); + tree_->Branch("pt_of_muon", &ptGlob_); + tree_->Branch("eta_of_muon", &etaGlob_); + tree_->Branch("phi_of_muon", &phiGlob_); + tree_->Branch("energy_of_muon", &energyMuon_); + tree_->Branch("p_of_muon", &pMuon_); + tree_->Branch("muon_trkKink", &muon_trkKink); + tree_->Branch("muon_chi2LocalPosition", &muon_chi2LocalPosition); + tree_->Branch("muon_segComp", &muon_segComp); + + tree_->Branch("TrackerLayer", &trackerLayer_); + tree_->Branch("NumPixelLayers", &numPixelLayers_); + tree_->Branch("InnerTrackPixelHits", &tight_PixelHits_); + tree_->Branch("innerTrack", &innerTrack_); + tree_->Branch("chiTracker", &chiTracker_); + tree_->Branch("DxyTracker", &dxyTracker_); + tree_->Branch("DzTracker", &dzTracker_); + tree_->Branch("innerTrackpt", &innerTrackpt_); + tree_->Branch("innerTracketa", &innerTracketa_); + tree_->Branch("innerTrackphi", &innerTrackphi_); + tree_->Branch("tight_validFraction", &tight_validFraction_); + + tree_->Branch("OuterTrack", &outerTrack_); + tree_->Branch("OuterTrackChi", &outerTrackChi_); + tree_->Branch("OuterTrackPt", &outerTrackPt_); + tree_->Branch("OuterTrackEta", &outerTrackEta_); + tree_->Branch("OuterTrackPhi", &outerTrackPhi_); + tree_->Branch("OuterTrackHits", &outerTrackHits_); + tree_->Branch("OuterTrackRHits", &outerTrackRHits_); + + tree_->Branch("GlobalTrack", &globalTrack_); + tree_->Branch("GlobalTrckPt", &globalTrckPt_); + tree_->Branch("GlobalTrckEta", &globalTrckEta_); + tree_->Branch("GlobalTrckPhi", &globalTrckPhi_); + tree_->Branch("Global_Muon_Hits", &globalMuonHits_); + tree_->Branch("MatchedStations", &matchedStat_); + tree_->Branch("GlobTrack_Chi", &chiGlobal_); + tree_->Branch("Tight_LongitudinalImpactparameter", &tight_LongPara_); + tree_->Branch("Tight_TransImpactparameter", &tight_TransImpara_); + + tree_->Branch("IsolationR04", &isolationR04_); + tree_->Branch("IsolationR03", &isolationR03_); + tree_->Branch("ecal_3into3", &ecalEnergy_); + tree_->Branch("hcal_3into3", &hcalEnergy_); + tree_->Branch("tracker_3into3", &hoEnergy_); + + tree_->Branch("matchedId", &matchedId_); + tree_->Branch("hcal_cellHot", &hcalHot_); + + tree_->Branch("ecal_3x3", &ecal3x3Energy_); + tree_->Branch("hcal_1x1", &hcal1x1Energy_); + tree_->Branch("ecal_detID", &ecalDetId_); + tree_->Branch("hcal_detID", &hcalDetId_); + tree_->Branch("ehcal_detID", &ehcalDetId_); + tree_->Branch("hcal_ieta", &hcal_ieta_); + tree_->Branch("hcal_iphi", &hcal_iphi_); char name[100]; - for (int k=0; kBranch(name, &hcalDepthEnergy_[k]); - sprintf (name, "hcal_activeL%d", (k+1)); - tree_->Branch(name, &hcalDepthActiveLength_[k]); - sprintf (name, "hcal_edepthHot%d", (k+1)); - tree_->Branch(name, &hcalDepthEnergyHot_[k]); - sprintf (name, "hcal_activeHotL%d", (k+1)); + sprintf(name, "hcal_activeL%d", (k + 1)); + tree_->Branch(name, &hcalDepthActiveLength_[k]); + sprintf(name, "hcal_edepthHot%d", (k + 1)); + tree_->Branch(name, &hcalDepthEnergyHot_[k]); + sprintf(name, "hcal_activeHotL%d", (k + 1)); tree_->Branch(name, &hcalDepthActiveLengthHot_[k]); - sprintf (name, "hcal_cdepthHot%d", (k+1)); - tree_->Branch(name, &hcalDepthChargeHot_[k]); - sprintf (name, "hcal_cdepthHotBG%d", (k+1)); - tree_->Branch(name, &hcalDepthChargeHotBG_[k]); - sprintf (name, "hcal_edepthCorrect%d", (k+1)); + sprintf(name, "hcal_cdepthHot%d", (k + 1)); + tree_->Branch(name, &hcalDepthChargeHot_[k]); + sprintf(name, "hcal_cdepthHotBG%d", (k + 1)); + tree_->Branch(name, &hcalDepthChargeHotBG_[k]); + sprintf(name, "hcal_edepthCorrect%d", (k + 1)); tree_->Branch(name, &hcalDepthEnergyCorr_[k]); - sprintf (name, "hcal_edepthHotCorrect%d", (k+1)); - tree_->Branch(name, &hcalDepthEnergyHotCorr_[k]); - sprintf (name, "hcal_depthMatch%d", (k+1)); - tree_->Branch(name, &hcalDepthMatch_[k]); - sprintf (name, "hcal_depthMatchHot%d", (k+1)); - tree_->Branch(name, &hcalDepthMatchHot_[k]); + sprintf(name, "hcal_edepthHotCorrect%d", (k + 1)); + tree_->Branch(name, &hcalDepthEnergyHotCorr_[k]); + sprintf(name, "hcal_depthMatch%d", (k + 1)); + tree_->Branch(name, &hcalDepthMatch_[k]); + sprintf(name, "hcal_depthMatchHot%d", (k + 1)); + tree_->Branch(name, &hcalDepthMatchHot_[k]); } - - tree_->Branch("activeLength", &hcalActiveLength_); - tree_->Branch("activeLengthHot", &hcalActiveLengthHot_); - - tree_->Branch("hltresults", &hltresults_); - tree_->Branch("all_triggers", &all_triggers_); + + tree_->Branch("activeLength", &hcalActiveLength_); + tree_->Branch("activeLengthHot", &hcalActiveLengthHot_); + + tree_->Branch("hltresults", &hltresults_); + tree_->Branch("all_triggers", &all_triggers_); } // ------------ method called when starting to processes a run ------------ void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { - edm::ESHandle pHRNDC; iSetup.get().get(pHRNDC); hdc_ = pHRNDC.product(); @@ -860,56 +895,49 @@ void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& unsigned int k1(0), k2(0); edm::LogVerbatim("HBHEMuon") << actHB.size() << " Active Length for HB"; for (const auto& act : actHB) { - edm::LogVerbatim("HBHEMuon") << "[" << k1 << "] ieta " << act.ieta - << " depth " << act.depth << " zside " - << act.zside << " type " << act.stype - << " phi " << act.iphis.size() << ":" - << act.iphis[0] << " L " << act.thick; - HcalDetId hcid1(HcalBarrel,(act.ieta)*(act.zside),act.iphis[0],act.depth); + edm::LogVerbatim("HBHEMuon") << "[" << k1 << "] ieta " << act.ieta << " depth " << act.depth << " zside " + << act.zside << " type " << act.stype << " phi " << act.iphis.size() << ":" + << act.iphis[0] << " L " << act.thick; + HcalDetId hcid1(HcalBarrel, (act.ieta) * (act.zside), act.iphis[0], act.depth); HcalDetId hcid2 = mergedDepth_ ? hdc_->mergedDepthDetId(hcid1) : hcid1; - edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L " - << activeLength(DetId(hcid2)); + edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L " << activeLength(DetId(hcid2)); ++k1; } edm::LogVerbatim("HBHEMuon") << actHE.size() << " Active Length for HE"; for (const auto& act : actHE) { - edm::LogVerbatim("HBHEMuon") << "[" << k2 << "] ieta " << act.ieta - << " depth " << act.depth << " zside " - << act.zside << " type " << act.stype - << " phi " << act.iphis.size() << ":" - << act.iphis[0] << " L " << act.thick; - HcalDetId hcid1(HcalEndcap,(act.ieta)*(act.zside),act.iphis[0],act.depth); + edm::LogVerbatim("HBHEMuon") << "[" << k2 << "] ieta " << act.ieta << " depth " << act.depth << " zside " + << act.zside << " type " << act.stype << " phi " << act.iphis.size() << ":" + << act.iphis[0] << " L " << act.thick; + HcalDetId hcid1(HcalEndcap, (act.ieta) * (act.zside), act.iphis[0], act.depth); HcalDetId hcid2 = mergedDepth_ ? hdc_->mergedDepthDetId(hcid1) : hcid1; - edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L " - << activeLength(DetId(hcid2)); + edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L " << activeLength(DetId(hcid2)); ++k2; } #endif bool changed = true; all_triggers_.clear(); - if (hltConfig_.init(iRun, iSetup, "HLT" , changed)) { + if (hltConfig_.init(iRun, iSetup, "HLT", changed)) { // if init returns TRUE, initialisation has succeeded! #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "HLT config with process name " - << "HLT" << " successfully extracted" - << std::endl; + edm::LogVerbatim("HBHEMuon") << "HLT config with process name " + << "HLT" + << " successfully extracted" << std::endl; #endif unsigned int ntriggers = hltConfig_.size(); - for (unsigned int t=0;t htopo; @@ -926,15 +954,13 @@ void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - const HcalGeometry* gHcal = (const HcalGeometry*)(geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel)); - const std::vector& ids = gHcal->getValidDetIds(DetId::Hcal,0); - edm::LogVerbatim("HBHEMuon") << "\nTable of Correction Factors for Run " - << iRun.run() << "\n"; - for (auto const& id: ids) { - if ((id.det() == DetId::Hcal) && - ((id.subdetId() == HcalBarrel) || (id.subdetId() == HcalEndcap))) { - edm::LogVerbatim("HBHEMuon") << HcalDetId(id) << " " << id.rawId() <<" " - << (respCorrs_->getValues(id))->getValue(); + const HcalGeometry* gHcal = (const HcalGeometry*)(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel)); + const std::vector& ids = gHcal->getValidDetIds(DetId::Hcal, 0); + edm::LogVerbatim("HBHEMuon") << "\nTable of Correction Factors for Run " << iRun.run() << "\n"; + for (auto const& id : ids) { + if ((id.det() == DetId::Hcal) && ((id.subdetId() == HcalBarrel) || (id.subdetId() == HcalEndcap))) { + edm::LogVerbatim("HBHEMuon") << HcalDetId(id) << " " << id.rawId() << " " + << (respCorrs_->getValues(id))->getValue(); } } } @@ -943,46 +969,44 @@ void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void HcalHBHEMuonAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("hlTriggerResults",edm::InputTag("TriggerResults","","HLT")); - desc.add("labelEBRecHit",edm::InputTag("ecalRecHit","EcalRecHitsEB")); - desc.add("labelEERecHit",edm::InputTag("ecalRecHit","EcalRecHitsEE")); - desc.add("labelHBHERecHit",edm::InputTag("hbhereco")); - desc.add("labelVertex","offlinePrimaryVertices"); - desc.add("labelMuon","muons"); - std::vector trig = {"HLT_IsoMu17","HLT_IsoMu20", - "HLT_IsoMu24","HLT_IsoMu27", - "HLT_Mu45","HLT_Mu50"}; - desc.add>("triggers",trig); - desc.addUntracked("verbosity",0); - desc.add("useRaw",0); - desc.add("unCorrect",false); - desc.add("getCharge",false); - desc.add("collapseDepth",false); - desc.add("isItPlan1",false); - desc.addUntracked("ignoreHECorr",false); - desc.addUntracked("isItPreRecHit",false); - desc.addUntracked("moduleName",""); - desc.addUntracked("processName",""); - desc.addUntracked("maxDepth",4); - desc.addUntracked("fileInCorr",""); - desc.addUntracked("writeRespCorr",false); - descriptions.add("hcalHBHEMuon",desc); + desc.add("hlTriggerResults", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("labelEBRecHit", edm::InputTag("ecalRecHit", "EcalRecHitsEB")); + desc.add("labelEERecHit", edm::InputTag("ecalRecHit", "EcalRecHitsEE")); + desc.add("labelHBHERecHit", edm::InputTag("hbhereco")); + desc.add("labelVertex", "offlinePrimaryVertices"); + desc.add("labelMuon", "muons"); + std::vector trig = {"HLT_IsoMu17", "HLT_IsoMu20", "HLT_IsoMu24", "HLT_IsoMu27", "HLT_Mu45", "HLT_Mu50"}; + desc.add>("triggers", trig); + desc.addUntracked("verbosity", 0); + desc.add("useRaw", 0); + desc.add("unCorrect", false); + desc.add("getCharge", false); + desc.add("collapseDepth", false); + desc.add("isItPlan1", false); + desc.addUntracked("ignoreHECorr", false); + desc.addUntracked("isItPreRecHit", false); + desc.addUntracked("moduleName", ""); + desc.addUntracked("processName", ""); + desc.addUntracked("maxDepth", 4); + desc.addUntracked("fileInCorr", ""); + desc.addUntracked("writeRespCorr", false); + descriptions.add("hcalHBHEMuon", desc); } void HcalHBHEMuonAnalyzer::clearVectors() { ///clearing vectots eventNumber_ = -99999; - runNumber_ = -99999; - lumiNumber_ = -99999; - bxNumber_ = -99999; - goodVertex_ = -99999; + runNumber_ = -99999; + lumiNumber_ = -99999; + bxNumber_ = -99999; + goodVertex_ = -99999; muon_is_good_.clear(); muon_global_.clear(); muon_tracker_.clear(); ptGlob_.clear(); - etaGlob_.clear(); - phiGlob_.clear(); + etaGlob_.clear(); + phiGlob_.clear(); energyMuon_.clear(); pMuon_.clear(); muon_trkKink.clear(); @@ -1035,7 +1059,7 @@ void HcalHBHEMuonAnalyzer::clearVectors() { ehcalDetId_.clear(); hcal_ieta_.clear(); hcal_iphi_.clear(); - for (int i=0; i dpths; if (mergedDepth_) { std::vector ids; - hdc_->unmergeDepthDetId(id,ids); - for (auto idh : ids) + hdc_->unmergeDepthDetId(id, ids); + for (auto idh : ids) dpths.emplace_back(idh.depth()); } else { dpths.emplace_back(id.depth()); } double lx(0); if (id.subdet() == HcalBarrel) { - for (unsigned int i=0; i 2.) return false; - if (fabs(vtx.position().Z()) > 24.) return false; + if (vtx.isFake()) + return false; + if (vtx.ndof() < 4) + return false; + if (vtx.position().Rho() > 2.) + return false; + if (fabs(vtx.position().Z()) > 24.) + return false; return true; } @@ -1109,7 +1134,8 @@ double HcalHBHEMuonAnalyzer::respCorr(const DetId& id) { double cfac(1.0); if (useMyCorr_) { auto itr = corrValue_.find(id); - if (itr != corrValue_.end()) cfac = itr->second; + if (itr != corrValue_.end()) + cfac = itr->second; } else if (respCorrs_ != nullptr) { cfac = (respCorrs_->getValues(id))->getValue(); } @@ -1118,35 +1144,34 @@ double HcalHBHEMuonAnalyzer::respCorr(const DetId& id) { double HcalHBHEMuonAnalyzer::gainFactor(const edm::ESHandle& conditions, const HcalDetId& id) { double gain(0.0); - const HcalCalibrations& calibs=conditions->getHcalCalibrations(id); - for (int capid=0; capid<4; ++capid) - gain += (0.25*calibs.respcorrgain(capid)); + const HcalCalibrations& calibs = conditions->getHcalCalibrations(id); + for (int capid = 0; capid < 4; ++capid) + gain += (0.25 * calibs.respcorrgain(capid)); return gain; } int HcalHBHEMuonAnalyzer::depth16HE(int ieta, int iphi) { - // Transition between HB/HE is special + // Transition between HB/HE is special // For Run 1 or for Plan1 standard reconstruction it is 3 // For runs beyond 2018 or in Plan1 for HEP17 it is 4 int zside = (ieta > 0) ? 1 : -1; - int depth = theHBHETopology_->dddConstants()->getMinDepth(1,16,iphi,zside); - if (isItPlan1_ && (!isItPreRecHit_)) depth = 3; + int depth = theHBHETopology_->dddConstants()->getMinDepth(1, 16, iphi, zside); + if (isItPlan1_ && (!isItPreRecHit_)) + depth = 3; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HBHEMuon") << "Plan1 " << isItPlan1_ << " PreRecHit " - << isItPreRecHit_ << " phi " << iphi - << " depth " << depth; + edm::LogVerbatim("HBHEMuon") << "Plan1 " << isItPlan1_ << " PreRecHit " << isItPreRecHit_ << " phi " << iphi + << " depth " << depth; #endif return depth; } -bool HcalHBHEMuonAnalyzer::goodCell(const HcalDetId& hcid, - const reco::Track* pTrack, - const CaloGeometry* geo, - const MagneticField* bField) { - - std::pair rz = hdc_->getRZ(hcid); +bool HcalHBHEMuonAnalyzer::goodCell(const HcalDetId& hcid, + const reco::Track* pTrack, + const CaloGeometry* geo, + const MagneticField* bField) { + std::pair rz = hdc_->getRZ(hcid); bool typeRZ = (hcid.subdet() == HcalEndcap) ? false : true; - bool match = spr::propagateHCAL(pTrack, geo, bField, typeRZ, rz, (((verbosity_/10000)%10)>0)); + bool match = spr::propagateHCAL(pTrack, geo, bField, typeRZ, rz, (((verbosity_ / 10000) % 10) > 0)); return match; } diff --git a/Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc b/Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc index 27407b35d05c5..fc7fccca06deb 100644 --- a/Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc +++ b/Calibration/HcalCalibAlgos/plugins/HcalIsoTrkAnalyzer.cc @@ -84,8 +84,7 @@ //#define EDM_ML_DEBUG -class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer { - +class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer { public: explicit HcalIsoTrkAnalyzer(edm::ParameterSet const&); ~HcalIsoTrkAnalyzer() override {} @@ -97,305 +96,274 @@ class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer fillTree(std::vector< math::XYZTLorentzVector>& vecL1, - std::vector< math::XYZTLorentzVector>& vecL3, - math::XYZPoint& leadPV, - std::vector& trkCaloDirections, - std::vector& trkCaloDets, - const CaloGeometry* geo, const CaloTopology* topo, - const HcalTopology* theHBHETopology, - const EcalChannelStatus* theEcalChStatus, - const EcalSeverityLevelAlgo* theEcalSevlv, - edm::Handle& barrelRecHitsHandle, - edm::Handle& endcapRecHitsHandle, - edm::Handle& hbhe, - edm::Handle& towerHandle, - edm::Handle& genParticles, - const HcalRespCorrs* respCorrs); + + std::array fillTree(std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* topo, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& towerHandle, + edm::Handle& genParticles, + const HcalRespCorrs* respCorrs); double dR(math::XYZTLorentzVector&, math::XYZTLorentzVector&); - double trackP(const reco::Track* , - const edm::Handle&); + double trackP(const reco::Track*, const edm::Handle&); double rhoh(const edm::Handle&); - void storeEnergy(int indx, const HcalRespCorrs* respCorrs, - const std::vector& ids, - std::vector& edet, double & eHcal, - std::vector *detIds, - std::vector *hitEnergies); + void storeEnergy(int indx, + const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector* detIds, + std::vector* hitEnergies); - l1t::L1TGlobalUtil *l1GtUtils_; - edm::Service fs; - HLTConfigProvider hltConfig_; + l1t::L1TGlobalUtil* l1GtUtils_; + edm::Service fs; + HLTConfigProvider hltConfig_; const std::vector trigNames_; - spr::trackSelectionParameters selectionParameter_; - const std::string theTrackQuality_; - const std::string processName_, l1Filter_; - const std::string l2Filter_, l3Filter_; - const double a_coneR_, a_mipR_, a_mipR2_, a_mipR3_; - const double a_mipR4_, a_mipR5_, pTrackMin_, eEcalMax_; - const double maxRestrictionP_, slopeRestrictionP_; - const double hcalScale_, eIsolate1_, eIsolate2_; - const double pTrackLow_, pTrackHigh_; - const int prescaleLow_, prescaleHigh_; - const int useRaw_, dataType_, mode_; - const bool ignoreTrigger_, useL1Trigger_; - const bool unCorrect_, collapseDepth_; - const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; - const double hitEthrEE2_, hitEthrEE3_; - const double hitEthrEELo_, hitEthrEEHi_; - const edm::InputTag triggerEvent_, theTriggerResultsLabel_; - const std::string labelGenTrack_, labelRecVtx_, labelEB_; - const std::string labelEE_, labelHBHE_, labelTower_,l1TrigName_; - unsigned int nRun_, nLow_, nHigh_; - double a_charIsoR_, a_coneR1_, a_coneR2_; - const HcalDDDRecConstants *hdc_; - std::vector etabins_, phibins_; - double etadist_, phidist_, etahalfdist_,phihalfdist_; - edm::EDGetTokenT tok_trigEvt_; - edm::EDGetTokenT tok_trigRes_; + spr::trackSelectionParameters selectionParameter_; + const std::string theTrackQuality_; + const std::string processName_, l1Filter_; + const std::string l2Filter_, l3Filter_; + const double a_coneR_, a_mipR_, a_mipR2_, a_mipR3_; + const double a_mipR4_, a_mipR5_, pTrackMin_, eEcalMax_; + const double maxRestrictionP_, slopeRestrictionP_; + const double hcalScale_, eIsolate1_, eIsolate2_; + const double pTrackLow_, pTrackHigh_; + const int prescaleLow_, prescaleHigh_; + const int useRaw_, dataType_, mode_; + const bool ignoreTrigger_, useL1Trigger_; + const bool unCorrect_, collapseDepth_; + const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; + const double hitEthrEE2_, hitEthrEE3_; + const double hitEthrEELo_, hitEthrEEHi_; + const edm::InputTag triggerEvent_, theTriggerResultsLabel_; + const std::string labelGenTrack_, labelRecVtx_, labelEB_; + const std::string labelEE_, labelHBHE_, labelTower_, l1TrigName_; + unsigned int nRun_, nLow_, nHigh_; + double a_charIsoR_, a_coneR1_, a_coneR2_; + const HcalDDDRecConstants* hdc_; + std::vector etabins_, phibins_; + double etadist_, phidist_, etahalfdist_, phihalfdist_; + edm::EDGetTokenT tok_trigEvt_; + edm::EDGetTokenT tok_trigRes_; edm::EDGetTokenT tok_parts_; - edm::EDGetTokenT tok_genTrack_; - edm::EDGetTokenT tok_recVtx_; - edm::EDGetTokenT tok_bs_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_hbhe_; - edm::EDGetTokenT tok_cala_; - edm::EDGetTokenT tok_ew_; - edm::EDGetTokenT> tok_alg_; + edm::EDGetTokenT tok_genTrack_; + edm::EDGetTokenT tok_recVtx_; + edm::EDGetTokenT tok_bs_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_hbhe_; + edm::EDGetTokenT tok_cala_; + edm::EDGetTokenT tok_ew_; + edm::EDGetTokenT> tok_alg_; - TTree *tree, *tree2; - unsigned int t_RunNo, t_EventNo; - int t_Run, t_Event, t_DataType, t_ieta, t_iphi; - int t_goodPV, t_nVtx, t_nTrk; - double t_EventWeight, t_p, t_pt, t_phi; - double t_l1pt, t_l1eta, t_l1phi; - double t_l3pt, t_l3eta, t_l3phi; - double t_mindR1, t_mindR2; - double t_eMipDR, t_eMipDR2, t_eMipDR3, t_eMipDR4; - double t_eMipDR5, t_hmaxNearP, t_gentrackP; - double t_emaxNearP, t_eAnnular, t_hAnnular; - double t_eHcal, t_eHcal10, t_eHcal30, t_rhoh; - bool t_selectTk, t_qltyFlag, t_qltyMissFlag; - bool t_qltyPVFlag, t_TrigPass, t_TrigPassSel; - std::vector *t_DetIds, *t_DetIds1, *t_DetIds3; - std::vector *t_HitEnergies, *t_HitEnergies1, *t_HitEnergies3; - std::vector *t_trgbits, *t_hltbits; - bool t_L1Bit; - int t_Tracks, t_TracksProp, t_TracksSaved; - int t_TracksLoose, t_TracksTight, t_allvertex; - std::vector *t_ietaAll, *t_ietaGood, *t_trackType; + TTree *tree, *tree2; + unsigned int t_RunNo, t_EventNo; + int t_Run, t_Event, t_DataType, t_ieta, t_iphi; + int t_goodPV, t_nVtx, t_nTrk; + double t_EventWeight, t_p, t_pt, t_phi; + double t_l1pt, t_l1eta, t_l1phi; + double t_l3pt, t_l3eta, t_l3phi; + double t_mindR1, t_mindR2; + double t_eMipDR, t_eMipDR2, t_eMipDR3, t_eMipDR4; + double t_eMipDR5, t_hmaxNearP, t_gentrackP; + double t_emaxNearP, t_eAnnular, t_hAnnular; + double t_eHcal, t_eHcal10, t_eHcal30, t_rhoh; + bool t_selectTk, t_qltyFlag, t_qltyMissFlag; + bool t_qltyPVFlag, t_TrigPass, t_TrigPassSel; + std::vector*t_DetIds, *t_DetIds1, *t_DetIds3; + std::vector*t_HitEnergies, *t_HitEnergies1, *t_HitEnergies3; + std::vector*t_trgbits, *t_hltbits; + bool t_L1Bit; + int t_Tracks, t_TracksProp, t_TracksSaved; + int t_TracksLoose, t_TracksTight, t_allvertex; + std::vector*t_ietaAll, *t_ietaGood, *t_trackType; }; -HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig) : - trigNames_(iConfig.getParameter >("triggers")), - theTrackQuality_(iConfig.getParameter("trackQuality")), - processName_(iConfig.getParameter("processName")), - l1Filter_(iConfig.getParameter("l1Filter")), - l2Filter_(iConfig.getParameter("l2Filter")), - l3Filter_(iConfig.getParameter("l3Filter")), - a_coneR_(iConfig.getParameter("coneRadius")), - a_mipR_(iConfig.getParameter("coneRadiusMIP")), - a_mipR2_(iConfig.getParameter("coneRadiusMIP2")), - a_mipR3_(iConfig.getParameter("coneRadiusMIP3")), - a_mipR4_(iConfig.getParameter("coneRadiusMIP4")), - a_mipR5_(iConfig.getParameter("coneRadiusMIP5")), - pTrackMin_(iConfig.getParameter("minimumTrackP")), - eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), - maxRestrictionP_(iConfig.getParameter("maxTrackP")), - slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), - hcalScale_(iConfig.getUntrackedParameter("hHcalScale",1.0)), - eIsolate1_(iConfig.getParameter("isolationEnergyTight")), - eIsolate2_(iConfig.getParameter("isolationEnergyLoose")), - pTrackLow_(iConfig.getParameter("momentumLow")), - pTrackHigh_(iConfig.getParameter("momentumHigh")), - prescaleLow_(iConfig.getParameter("prescaleLow")), - prescaleHigh_(iConfig.getParameter("prescaleHigh")), - useRaw_(iConfig.getUntrackedParameter("useRaw",0)), - dataType_(iConfig.getUntrackedParameter("dataType",0)), - mode_(iConfig.getUntrackedParameter("outMode",11)), - ignoreTrigger_(iConfig.getUntrackedParameter("ignoreTriggers",false)), - useL1Trigger_(iConfig.getUntrackedParameter("useL1Trigger",false)), - unCorrect_(iConfig.getUntrackedParameter("unCorrect",false)), - collapseDepth_(iConfig.getUntrackedParameter("collapseDepth",false)), - hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold") ), - hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0") ), - hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1") ), - hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2") ), - hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3") ), - hitEthrEELo_(iConfig.getParameter("EEHitEnergyThresholdLow") ), - hitEthrEEHi_(iConfig.getParameter("EEHitEnergyThresholdHigh") ), - triggerEvent_(iConfig.getParameter("labelTriggerEvent")), - theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), - labelGenTrack_(iConfig.getParameter("labelTrack")), - labelRecVtx_(iConfig.getParameter("labelVertex")), - labelEB_(iConfig.getParameter("labelEBRecHit")), - labelEE_(iConfig.getParameter("labelEERecHit")), - labelHBHE_(iConfig.getParameter("labelHBHERecHit")), - labelTower_(iConfig.getParameter("labelCaloTower")), - l1TrigName_(iConfig.getUntrackedParameter("l1TrigName","L1_SingleJet60")), - nRun_(0), nLow_(0), nHigh_(0), hdc_(nullptr) { - +HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(const edm::ParameterSet& iConfig) + : trigNames_(iConfig.getParameter>("triggers")), + theTrackQuality_(iConfig.getParameter("trackQuality")), + processName_(iConfig.getParameter("processName")), + l1Filter_(iConfig.getParameter("l1Filter")), + l2Filter_(iConfig.getParameter("l2Filter")), + l3Filter_(iConfig.getParameter("l3Filter")), + a_coneR_(iConfig.getParameter("coneRadius")), + a_mipR_(iConfig.getParameter("coneRadiusMIP")), + a_mipR2_(iConfig.getParameter("coneRadiusMIP2")), + a_mipR3_(iConfig.getParameter("coneRadiusMIP3")), + a_mipR4_(iConfig.getParameter("coneRadiusMIP4")), + a_mipR5_(iConfig.getParameter("coneRadiusMIP5")), + pTrackMin_(iConfig.getParameter("minimumTrackP")), + eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), + maxRestrictionP_(iConfig.getParameter("maxTrackP")), + slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), + hcalScale_(iConfig.getUntrackedParameter("hHcalScale", 1.0)), + eIsolate1_(iConfig.getParameter("isolationEnergyTight")), + eIsolate2_(iConfig.getParameter("isolationEnergyLoose")), + pTrackLow_(iConfig.getParameter("momentumLow")), + pTrackHigh_(iConfig.getParameter("momentumHigh")), + prescaleLow_(iConfig.getParameter("prescaleLow")), + prescaleHigh_(iConfig.getParameter("prescaleHigh")), + useRaw_(iConfig.getUntrackedParameter("useRaw", 0)), + dataType_(iConfig.getUntrackedParameter("dataType", 0)), + mode_(iConfig.getUntrackedParameter("outMode", 11)), + ignoreTrigger_(iConfig.getUntrackedParameter("ignoreTriggers", false)), + useL1Trigger_(iConfig.getUntrackedParameter("useL1Trigger", false)), + unCorrect_(iConfig.getUntrackedParameter("unCorrect", false)), + collapseDepth_(iConfig.getUntrackedParameter("collapseDepth", false)), + hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold")), + hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0")), + hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1")), + hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2")), + hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3")), + hitEthrEELo_(iConfig.getParameter("EEHitEnergyThresholdLow")), + hitEthrEEHi_(iConfig.getParameter("EEHitEnergyThresholdHigh")), + triggerEvent_(iConfig.getParameter("labelTriggerEvent")), + theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), + labelGenTrack_(iConfig.getParameter("labelTrack")), + labelRecVtx_(iConfig.getParameter("labelVertex")), + labelEB_(iConfig.getParameter("labelEBRecHit")), + labelEE_(iConfig.getParameter("labelEERecHit")), + labelHBHE_(iConfig.getParameter("labelHBHERecHit")), + labelTower_(iConfig.getParameter("labelCaloTower")), + l1TrigName_(iConfig.getUntrackedParameter("l1TrigName", "L1_SingleJet60")), + nRun_(0), + nLow_(0), + nHigh_(0), + hdc_(nullptr) { usesResource(TFileService::kSharedResource); //now do whatever initialization is needed const double isolationRadius(28.9), innerR(10.0), outerR(30.0); - reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality_); - selectionParameter_.minPt = iConfig.getParameter("minTrackPt");; - selectionParameter_.minQuality = trackQuality_; - selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); - selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); - selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); - selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); - selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality_); + selectionParameter_.minPt = iConfig.getParameter("minTrackPt"); + ; + selectionParameter_.minQuality = trackQuality_; + selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); + selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); - selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); - selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); - a_charIsoR_ = a_coneR_ + isolationRadius; - a_coneR1_ = a_coneR_ + innerR; - a_coneR2_ = a_coneR_ + outerR; + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); + a_charIsoR_ = a_coneR_ + isolationRadius; + a_coneR1_ = a_coneR_ + innerR; + a_coneR2_ = a_coneR_ + outerR; // Different isolation cuts are described in DN-2016/029 // Tight cut uses 2 GeV; Loose cut uses 10 GeV // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18)) // with the factor for exponential slopeRestrictionP_ = log(2.5)/18 // maxRestrictionP_ = 8 GeV as came from a study - std::string labelBS = iConfig.getParameter("labelBeamSpot"); - std::string modnam = iConfig.getUntrackedParameter("moduleName",""); - std::string prdnam = iConfig.getUntrackedParameter("producerName",""); - edm::InputTag algTag = iConfig.getParameter("algInputTag"); - edm::InputTag extTag = iConfig.getParameter("extInputTag"); - l1GtUtils_ = new l1t::L1TGlobalUtil(iConfig, consumesCollector(), *this, algTag, extTag); + std::string labelBS = iConfig.getParameter("labelBeamSpot"); + std::string modnam = iConfig.getUntrackedParameter("moduleName", ""); + std::string prdnam = iConfig.getUntrackedParameter("producerName", ""); + edm::InputTag algTag = iConfig.getParameter("algInputTag"); + edm::InputTag extTag = iConfig.getParameter("extInputTag"); + l1GtUtils_ = new l1t::L1TGlobalUtil(iConfig, consumesCollector(), *this, algTag, extTag); // define tokens for access - tok_trigEvt_ = consumes(triggerEvent_); - tok_trigRes_ = consumes(theTriggerResultsLabel_); - tok_bs_ = consumes(labelBS); + tok_trigEvt_ = consumes(triggerEvent_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_bs_ = consumes(labelBS); tok_genTrack_ = consumes(labelGenTrack_); - tok_ew_ = consumes(edm::InputTag("generator")); - tok_parts_ = consumes(edm::InputTag("genParticles")); - tok_cala_ = consumes(labelTower_); - tok_alg_ = consumes>(algTag); + tok_ew_ = consumes(edm::InputTag("generator")); + tok_parts_ = consumes(edm::InputTag("genParticles")); + tok_cala_ = consumes(labelTower_); + tok_alg_ = consumes>(algTag); if (modnam.empty()) { - tok_recVtx_ = consumes(labelRecVtx_); - tok_EB_ = consumes(edm::InputTag("ecalRecHit",labelEB_)); - tok_EE_ = consumes(edm::InputTag("ecalRecHit",labelEE_)); - tok_hbhe_ = consumes(labelHBHE_); - edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " - << theTriggerResultsLabel_ << " " - << labelBS << " " << labelRecVtx_ << " " - << labelGenTrack_ << " " - << edm::InputTag("ecalRecHit",labelEB_) - << " " - << edm::InputTag("ecalRecHit",labelEE_) - << " " << labelHBHE_ << " " << labelTower_; + tok_recVtx_ = consumes(labelRecVtx_); + tok_EB_ = consumes(edm::InputTag("ecalRecHit", labelEB_)); + tok_EE_ = consumes(edm::InputTag("ecalRecHit", labelEE_)); + tok_hbhe_ = consumes(labelHBHE_); + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " " + << labelBS << " " << labelRecVtx_ << " " << labelGenTrack_ << " " + << edm::InputTag("ecalRecHit", labelEB_) << " " + << edm::InputTag("ecalRecHit", labelEE_) << " " << labelHBHE_ << " " + << labelTower_; } else { - tok_recVtx_ = consumes(edm::InputTag(modnam,labelRecVtx_,prdnam)); - tok_EB_ = consumes(edm::InputTag(modnam,labelEB_,prdnam)); - tok_EE_ = consumes(edm::InputTag(modnam,labelEE_,prdnam)); - tok_hbhe_ = consumes(edm::InputTag(modnam,labelHBHE_,prdnam)); - edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " - << theTriggerResultsLabel_ << " " - << labelBS << " " - << edm::InputTag(modnam,labelRecVtx_,prdnam) - << " " << labelGenTrack_ << " " - << edm::InputTag(modnam,labelEB_,prdnam) - << " " - << edm::InputTag(modnam,labelEE_,prdnam) - << " " - << edm::InputTag(modnam,labelHBHE_,prdnam) - << " " << labelTower_; + tok_recVtx_ = consumes(edm::InputTag(modnam, labelRecVtx_, prdnam)); + tok_EB_ = consumes(edm::InputTag(modnam, labelEB_, prdnam)); + tok_EE_ = consumes(edm::InputTag(modnam, labelEE_, prdnam)); + tok_hbhe_ = consumes(edm::InputTag(modnam, labelHBHE_, prdnam)); + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " " + << labelBS << " " << edm::InputTag(modnam, labelRecVtx_, prdnam) << " " + << labelGenTrack_ << " " << edm::InputTag(modnam, labelEB_, prdnam) << " " + << edm::InputTag(modnam, labelEE_, prdnam) << " " + << edm::InputTag(modnam, labelHBHE_, prdnam) << " " << labelTower_; } - edm::LogVerbatim("HcalIsoTrack") <<"Parameters read from config file \n" - <<"\t minPt " << selectionParameter_.minPt - <<"\t theTrackQuality " << theTrackQuality_ - <<"\t minQuality " << selectionParameter_.minQuality - <<"\t maxDxyPV " << selectionParameter_.maxDxyPV - <<"\t maxDzPV " << selectionParameter_.maxDzPV - <<"\t maxChi2 " << selectionParameter_.maxChi2 - <<"\t maxDpOverP " << selectionParameter_.maxDpOverP - <<"\t minOuterHit " << selectionParameter_.minOuterHit - <<"\t minLayerCrossed " << selectionParameter_.minLayerCrossed - <<"\t maxInMiss " << selectionParameter_.maxInMiss - <<"\t maxOutMiss " << selectionParameter_.maxOutMiss - <<"\t a_coneR " << a_coneR_ - << ":" << a_coneR1_ << ":" << a_coneR2_ - <<"\t a_charIsoR " << a_charIsoR_ - <<"\t a_mipR " << a_mipR_ - <<"\t a_mipR2 " << a_mipR2_ - <<"\t a_mipR3 " << a_mipR3_ - <<"\t a_mipR4 " << a_mipR4_ - <<"\t a_mipR5 " << a_mipR5_ - <<"\n pTrackMin_ " << pTrackMin_ - <<"\t eEcalMax_ " << eEcalMax_ - <<"\t maxRestrictionP_ "<< maxRestrictionP_ - <<"\t slopeRestrictionP_ " << slopeRestrictionP_ - <<"\t eIsolateStrong_ " << eIsolate1_ - <<"\t eIsolateSoft_ " << eIsolate2_ - <<"\t hcalScale_ " << hcalScale_ - <<"\n\t momentumLow_ " << pTrackLow_ - <<"\t prescaleLow_ " << prescaleLow_ - <<"\t momentumHigh_ " << pTrackHigh_ - <<"\t prescaleHigh_ " << prescaleHigh_ - <<"\n\t useRaw_ " << useRaw_ - <<"\t ignoreTrigger_ " << ignoreTrigger_ - <<"\n\t useL1Trigegr_ " << useL1Trigger_ - <<"\t dataType_ " << dataType_ - <<"\t mode_ " << mode_ - <<"\t unCorrect_ " << unCorrect_ - <<"\t collapseDepth_ " << collapseDepth_ - <<"\t L1TrigName_ " << l1TrigName_ - <<"\nThreshold for EB " << hitEthrEB_ - << " EE " << hitEthrEE0_ << ":" - << hitEthrEE1_ << ":" << hitEthrEE2_ << ":" - << hitEthrEE3_ << ":" << hitEthrEELo_ << ":" - << hitEthrEEHi_; - edm::LogVerbatim("HcalIsoTrack") << "Process " << processName_ - << " L1Filter:" << l1Filter_ << " L2Filter:" - << l2Filter_ << " L3Filter:" << l3Filter_; - for (unsigned int k=0; k bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); edm::ESHandle ecalChStatus; iSetup.get().get(ecalChStatus); const EcalChannelStatus* theEcalChStatus = ecalChStatus.product(); - + edm::ESHandle sevlv; iSetup.get().get(sevlv); const EcalSeverityLevelAlgo* theEcalSevlv = sevlv.product(); @@ -404,11 +372,11 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + edm::ESHandle theCaloTopology; - iSetup.get().get(theCaloTopology); - const CaloTopology *caloTopology = theCaloTopology.product(); - + iSetup.get().get(theCaloTopology); + const CaloTopology* caloTopology = theCaloTopology.product(); + edm::ESHandle htopo; iSetup.get().get(htopo); const HcalTopology* theHBHETopology = htopo.product(); @@ -421,105 +389,102 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const //=== genParticle information edm::Handle genParticles; iEvent.getByToken(tok_parts_, genParticles); - + bool okC(true); //Get track collection edm::Handle trkCollection; iEvent.getByToken(tok_genTrack_, trkCollection); if (!trkCollection.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelGenTrack_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_; okC = false; } - + //event weight for FLAT sample t_EventWeight = 1.0; edm::Handle genEventInfo; iEvent.getByToken(tok_ew_, genEventInfo); - if (genEventInfo.isValid()) t_EventWeight = genEventInfo->weight(); + if (genEventInfo.isValid()) + t_EventWeight = genEventInfo->weight(); //Define the best vertex and the beamspot edm::Handle recVtxs; - iEvent.getByToken(tok_recVtx_, recVtxs); + iEvent.getByToken(tok_recVtx_, recVtxs); edm::Handle beamSpotH; iEvent.getByToken(tok_bs_, beamSpotH); - math::XYZPoint leadPV(0,0,0); + math::XYZPoint leadPV(0, 0, 0); t_goodPV = t_nVtx = 0; if (recVtxs.isValid() && !(recVtxs->empty())) { t_nVtx = recVtxs->size(); - for (unsigned int k=0; ksize(); ++k) { + for (unsigned int k = 0; k < recVtxs->size(); ++k) { if (!((*recVtxs)[k].isFake()) && ((*recVtxs)[k].ndof() > 4)) { - if (t_goodPV == 0) leadPV = math::XYZPoint((*recVtxs)[k].x(),(*recVtxs)[k].y(),(*recVtxs)[k].z()); - t_goodPV++; + if (t_goodPV == 0) + leadPV = math::XYZPoint((*recVtxs)[k].x(), (*recVtxs)[k].y(), (*recVtxs)[k].z()); + t_goodPV++; } } - } + } if (t_goodPV == 0 && beamSpotH.isValid()) { leadPV = beamSpotH->position(); } t_allvertex = t_goodPV; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " - << t_goodPV << " vertex"; + edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " << t_goodPV << " vertex"; if (beamSpotH.isValid()) { edm::LogVerbatim("HcalIsoTrack") << " Beam Spot " << beamSpotH->position(); } -#endif +#endif // RecHits edm::Handle barrelRecHitsHandle; iEvent.getByToken(tok_EB_, barrelRecHitsHandle); if (!barrelRecHitsHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelEB_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_; okC = false; } edm::Handle endcapRecHitsHandle; iEvent.getByToken(tok_EE_, endcapRecHitsHandle); if (!endcapRecHitsHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelEE_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_; okC = false; } edm::Handle hbhe; iEvent.getByToken(tok_hbhe_, hbhe); if (!hbhe.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelHBHE_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_; okC = false; } edm::Handle caloTower; iEvent.getByToken(tok_cala_, caloTower); - + //Propagate tracks to calorimeter surface) std::vector trkCaloDirections; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDirections, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false); std::vector trkCaloDets; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDets, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDets, false); std::vector vecL1, vecL3; - t_RunNo = iEvent.id().run(); - t_EventNo = iEvent.id().event(); - t_Tracks = trkCollection->size(); + t_RunNo = iEvent.id().run(); + t_EventNo = iEvent.id().event(); + t_Tracks = trkCollection->size(); t_TracksProp = trkCaloDirections.size(); - t_ietaAll->clear(); t_ietaGood->clear(); t_trackType->clear(); - t_trgbits->clear(); t_hltbits->clear(); + t_ietaAll->clear(); + t_ietaGood->clear(); + t_trackType->clear(); + t_trgbits->clear(); + t_hltbits->clear(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "# of propagated tracks " << t_TracksProp - << " out of " << t_Tracks << " with Trigger " - << ignoreTrigger_; + edm::LogVerbatim("HcalIsoTrack") << "# of propagated tracks " << t_TracksProp << " out of " << t_Tracks + << " with Trigger " << ignoreTrigger_; #endif //Trigger - t_trgbits->assign(trigNames_.size(),false); - t_hltbits->assign(trigNames_.size(),false); + t_trgbits->assign(trigNames_.size(), false); + t_hltbits->assign(trigNames_.size(), false); t_TracksSaved = t_TracksLoose = t_TracksTight = 0; - t_L1Bit = true; - t_TrigPass = false; + t_L1Bit = true; + t_TrigPass = false; //L1 - l1GtUtils_->retrieveL1(iEvent,iSetup,tok_alg_); - const std::vector > & finalDecisions = l1GtUtils_->decisionsFinal(); + l1GtUtils_->retrieveL1(iEvent, iSetup, tok_alg_); + const std::vector>& finalDecisions = l1GtUtils_->decisionsFinal(); for (const auto& decision : finalDecisions) { if (decision.first.find(l1TrigName_) != std::string::npos) { t_L1Bit = decision.second; @@ -527,49 +492,59 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ - << " is " << t_L1Bit << " from a list of " - << finalDecisions.size() << " decisions"; + edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ << " is " << t_L1Bit + << " from a list of " << finalDecisions.size() << " decisions"; #endif - + //HLT edm::Handle triggerResults; iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & names = triggerNames.triggerNames(); + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); if (!trigNames_.empty()) { - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; iat(i) = (hlt>0); - t_hltbits->at(i) = (hlt>0); - if (hlt>0) t_TrigPass = true; + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (names[iHLT].find(trigNames_[i]) != std::string::npos) { + t_trgbits->at(i) = (hlt > 0); + t_hltbits->at(i) = (hlt > 0); + if (hlt > 0) + t_TrigPass = true; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This trigger " - << names[iHLT] << " Flag " - << hlt << ":" << t_trgbits->at(i); + edm::LogVerbatim("HcalIsoTrack") + << "This trigger " << names[iHLT] << " Flag " << hlt << ":" << t_trgbits->at(i); #endif - } - } + } + } } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << t_TrigPass - << ":" << trigNames_.empty() << ":" << okC; + edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << t_TrigPass << ":" << trigNames_.empty() << ":" << okC; #endif - std::array ntksave{ {0,0,0} }; + std::array ntksave{{0, 0, 0}}; if (ignoreTrigger_ || useL1Trigger_) { - t_l1pt = t_l1eta = t_l1phi = 0; - t_l3pt = t_l3eta = t_l3phi = 0; + t_l1pt = t_l1eta = t_l1phi = 0; + t_l3pt = t_l3eta = t_l3phi = 0; if (ignoreTrigger_ || t_L1Bit) - ntksave = fillTree(vecL1, vecL3, leadPV, trkCaloDirections, trkCaloDets, - geo, caloTopology, theHBHETopology, theEcalChStatus, - theEcalSevlv, barrelRecHitsHandle, endcapRecHitsHandle, - hbhe, caloTower, genParticles, respCorrs); + ntksave = fillTree(vecL1, + vecL3, + leadPV, + trkCaloDirections, + trkCaloDets, + geo, + caloTopology, + theHBHETopology, + theEcalChStatus, + theEcalSevlv, + barrelRecHitsHandle, + endcapRecHitsHandle, + hbhe, + caloTower, + genParticles, + respCorrs); t_TracksSaved = ntksave[0]; t_TracksLoose = ntksave[1]; t_TracksTight = ntksave[2]; @@ -578,212 +553,209 @@ void HcalIsoTrkAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const edm::Handle triggerEventHandle; iEvent.getByToken(tok_trigEvt_, triggerEventHandle); if (!triggerEventHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " - << triggerEvent_.label() ; + edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " << triggerEvent_.label(); } else if (okC) { triggerEvent = *(triggerEventHandle.product()); const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects()); bool done(false); if (triggerResults.isValid()) { - std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & names = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - bool ok = (t_TrigPass) || (trigNames_.empty()); - if (ok) { - unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]); - const std::vector& moduleLabels(hltConfig_.moduleLabels(triggerindx)); - std::vector vecL2; - vecL1.clear(); vecL3.clear(); - //loop over all trigger filters in event (i.e. filters passed) - for (unsigned int ifilter=0; ifilter Keys; - std::string label = triggerEvent.filterTag(ifilter).label(); - //loop over keys to objects passing this filter - for (unsigned int imodule=0; imodule modules; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + bool ok = (t_TrigPass) || (trigNames_.empty()); + if (ok) { + unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]); + const std::vector& moduleLabels(hltConfig_.moduleLabels(triggerindx)); + std::vector vecL2; + vecL1.clear(); + vecL3.clear(); + //loop over all trigger filters in event (i.e. filters passed) + for (unsigned int ifilter = 0; ifilter < triggerEvent.sizeFilters(); ++ifilter) { + std::vector Keys; + std::string label = triggerEvent.filterTag(ifilter).label(); + //loop over keys to objects passing this filter + for (unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) { + if (label.find(moduleLabels[imodule]) != std::string::npos) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label; + edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label; #endif - for (unsigned int ifiltrKey=0; - ifiltrKey 0); tree2->Fill(); } void HcalIsoTrkAnalyzer::beginJob() { - tree = fs->make("CalibTree", "CalibTree"); - - tree->Branch("t_Run", &t_Run, "t_Run/I"); - tree->Branch("t_Event", &t_Event, "t_Event/I"); - tree->Branch("t_DataType", &t_DataType, "t_DataType/I"); - tree->Branch("t_ieta", &t_ieta, "t_ieta/I"); - tree->Branch("t_iphi", &t_iphi, "t_iphi/I"); + + tree->Branch("t_Run", &t_Run, "t_Run/I"); + tree->Branch("t_Event", &t_Event, "t_Event/I"); + tree->Branch("t_DataType", &t_DataType, "t_DataType/I"); + tree->Branch("t_ieta", &t_ieta, "t_ieta/I"); + tree->Branch("t_iphi", &t_iphi, "t_iphi/I"); tree->Branch("t_EventWeight", &t_EventWeight, "t_EventWeight/D"); - tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I"); - tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I"); - tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I"); - if (((mode_/10)%10) == 1) { - tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D"); - tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D"); - tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D"); - tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D"); - tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D"); - tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D"); + tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I"); + tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I"); + tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I"); + if (((mode_ / 10) % 10) == 1) { + tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D"); + tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D"); + tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D"); + tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D"); + tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D"); + tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D"); } - tree->Branch("t_p", &t_p, "t_p/D"); - tree->Branch("t_pt", &t_pt, "t_pt/D"); - tree->Branch("t_phi", &t_phi, "t_phi/D"); - tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D"); - tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D"); - tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D"); - tree->Branch("t_eMipDR2", &t_eMipDR2, "t_eMipDR2/D"); - tree->Branch("t_eMipDR3", &t_eMipDR3, "t_eMipDR3/D"); - tree->Branch("t_eMipDR4", &t_eMipDR4, "t_eMipDR4/D"); - tree->Branch("t_eMipDR5", &t_eMipDR5, "t_eMipDR5/D"); - tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D"); - tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D"); - tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D"); - tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D"); - tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D"); - tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D"); - tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D"); - tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D"); - tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O"); - tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O"); - tree->Branch("t_qltyMissFlag",&t_qltyMissFlag,"t_qltyMissFlag/O"); - tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O"); - tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D"); + tree->Branch("t_p", &t_p, "t_p/D"); + tree->Branch("t_pt", &t_pt, "t_pt/D"); + tree->Branch("t_phi", &t_phi, "t_phi/D"); + tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D"); + tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D"); + tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D"); + tree->Branch("t_eMipDR2", &t_eMipDR2, "t_eMipDR2/D"); + tree->Branch("t_eMipDR3", &t_eMipDR3, "t_eMipDR3/D"); + tree->Branch("t_eMipDR4", &t_eMipDR4, "t_eMipDR4/D"); + tree->Branch("t_eMipDR5", &t_eMipDR5, "t_eMipDR5/D"); + tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D"); + tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D"); + tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D"); + tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D"); + tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D"); + tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D"); + tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D"); + tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D"); + tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O"); + tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O"); + tree->Branch("t_qltyMissFlag", &t_qltyMissFlag, "t_qltyMissFlag/O"); + tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O"); + tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D"); - t_DetIds = new std::vector(); - t_DetIds1 = new std::vector(); - t_DetIds3 = new std::vector(); - t_HitEnergies = new std::vector(); + t_DetIds = new std::vector(); + t_DetIds1 = new std::vector(); + t_DetIds3 = new std::vector(); + t_HitEnergies = new std::vector(); t_HitEnergies1 = new std::vector(); t_HitEnergies3 = new std::vector(); - t_trgbits = new std::vector(); - tree->Branch("t_DetIds", "std::vector", &t_DetIds); - tree->Branch("t_HitEnergies", "std::vector", &t_HitEnergies); - if (((mode_/10)%10) == 1) { - tree->Branch("t_trgbits", "std::vector", &t_trgbits); + t_trgbits = new std::vector(); + tree->Branch("t_DetIds", "std::vector", &t_DetIds); + tree->Branch("t_HitEnergies", "std::vector", &t_HitEnergies); + if (((mode_ / 10) % 10) == 1) { + tree->Branch("t_trgbits", "std::vector", &t_trgbits); } - if ((mode_%10) == 1) { - tree->Branch("t_DetIds1", "std::vector", &t_DetIds1); - tree->Branch("t_DetIds3", "std::vector", &t_DetIds3); - tree->Branch("t_HitEnergies1", "std::vector", &t_HitEnergies1); - tree->Branch("t_HitEnergies3", "std::vector", &t_HitEnergies3); + if ((mode_ % 10) == 1) { + tree->Branch("t_DetIds1", "std::vector", &t_DetIds1); + tree->Branch("t_DetIds3", "std::vector", &t_DetIds3); + tree->Branch("t_HitEnergies1", "std::vector", &t_HitEnergies1); + tree->Branch("t_HitEnergies3", "std::vector", &t_HitEnergies3); } tree2 = fs->make("EventInfo", "Event Information"); - - tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i"); - tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i"); - tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I"); - tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I"); + + tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i"); + tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i"); + tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I"); + tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I"); tree2->Branch("t_TracksSaved", &t_TracksSaved, "t_TracksSaved/I"); tree2->Branch("t_TracksLoose", &t_TracksLoose, "t_TracksLoose/I"); tree2->Branch("t_TracksTight", &t_TracksTight, "t_TracksTight/I"); - tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O"); + tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O"); tree2->Branch("t_TrigPassSel", &t_TrigPassSel, "t_TrigPassSel/O"); - tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O"); - tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I"); - t_hltbits = new std::vector(); - t_ietaAll = new std::vector(); - t_ietaGood = new std::vector(); - t_trackType = new std::vector(); - tree2->Branch("t_ietaAll", "std::vector", &t_ietaAll); - tree2->Branch("t_ietaGood", "std::vector", &t_ietaGood); - tree2->Branch("t_trackType", "std::vector", &t_trackType); - tree2->Branch("t_hltbits", "std::vector", &t_hltbits); + tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O"); + tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I"); + t_hltbits = new std::vector(); + t_ietaAll = new std::vector(); + t_ietaGood = new std::vector(); + t_trackType = new std::vector(); + tree2->Branch("t_ietaAll", "std::vector", &t_ietaAll); + tree2->Branch("t_ietaGood", "std::vector", &t_ietaGood); + tree2->Branch("t_trackType", "std::vector", &t_trackType); + tree2->Branch("t_hltbits", "std::vector", &t_hltbits); } - // ------------ method called when starting to processes a run ------------ void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { edm::ESHandle pHRNDC; @@ -791,28 +763,24 @@ void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& i hdc_ = pHRNDC.product(); bool changed_(true); - bool flag = hltConfig_.init(iRun,iSetup,processName_,changed_); - edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() - << " process " << processName_ - << " init flag " << flag << " change flag " - << changed_; - // check if trigger names in (new) config + bool flag = hltConfig_.init(iRun, iSetup, processName_, changed_); + edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " process " << processName_ + << " init flag " << flag << " change flag " << changed_; + // check if trigger names in (new) config if (changed_) { changed_ = false; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalIsoTrack") << "New trigger menu found !!!"; #endif const unsigned int n(hltConfig_.size()); - for (unsigned itrig=0; itrig= n) { - edm::LogWarning("HcalIsoTrack") << trigNames_[itrig] << " " - << triggerindx << " does not exist in " - << "the current menu"; + edm::LogWarning("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " does not exist in " + << "the current menu"; #ifdef EDM_ML_DEBUG } else { - edm::LogVerbatim("HcalIsoTrack") << trigNames_[itrig] << " " - << triggerindx << " exists"; + edm::LogVerbatim("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " exists"; #endif } } @@ -827,443 +795,508 @@ void HcalIsoTrkAnalyzer::endRun(edm::Run const& iRun, edm::EventSetup const&) { void HcalIsoTrkAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - std::vector trig = {"HLT_PFJet40","HLT_PFJet60","HLT_PFJet80", - "HLT_PFJet140","HLT_PFJet200","HLT_PFJet260", - "HLT_PFJet320","HLT_PFJet400","HLT_PFJet450", - "HLT_PFJet500"}; - desc.add>("triggers",trig); - desc.add("processName","HLT"); - desc.add("l1Filter",""); - desc.add("l2Filter","L2Filter"); - desc.add("l3Filter","Filter"); + std::vector trig = {"HLT_PFJet40", + "HLT_PFJet60", + "HLT_PFJet80", + "HLT_PFJet140", + "HLT_PFJet200", + "HLT_PFJet260", + "HLT_PFJet320", + "HLT_PFJet400", + "HLT_PFJet450", + "HLT_PFJet500"}; + desc.add>("triggers", trig); + desc.add("processName", "HLT"); + desc.add("l1Filter", ""); + desc.add("l2Filter", "L2Filter"); + desc.add("l3Filter", "Filter"); // following 10 parameters are parameters to select good tracks - desc.add("trackQuality","highPurity"); - desc.add("minTrackPt",1.0); - desc.add("maxDxyPV",0.02); - desc.add("maxDzPV",0.02); - desc.add("maxChi2",5.0); - desc.add("maxDpOverP",0.1); - desc.add("minOuterHit",4); - desc.add("minLayerCrossed",8); - desc.add("maxInMiss",0); - desc.add("maxOutMiss",0); + desc.add("trackQuality", "highPurity"); + desc.add("minTrackPt", 1.0); + desc.add("maxDxyPV", 0.02); + desc.add("maxDzPV", 0.02); + desc.add("maxChi2", 5.0); + desc.add("maxDpOverP", 0.1); + desc.add("minOuterHit", 4); + desc.add("minLayerCrossed", 8); + desc.add("maxInMiss", 0); + desc.add("maxOutMiss", 0); // Minimum momentum of selected isolated track and signal zone - desc.add("minimumTrackP",20.0); - desc.add("coneRadius",34.98); + desc.add("minimumTrackP", 20.0); + desc.add("coneRadius", 34.98); // signal zone in ECAL and MIP energy cutoff - desc.add("coneRadiusMIP",14.0); - desc.add("coneRadiusMIP2",18.0); - desc.add("coneRadiusMIP3",20.0); - desc.add("coneRadiusMIP4",22.0); - desc.add("coneRadiusMIP5",24.0); - desc.add("maximumEcalEnergy",2.0); + desc.add("coneRadiusMIP", 14.0); + desc.add("coneRadiusMIP2", 18.0); + desc.add("coneRadiusMIP3", 20.0); + desc.add("coneRadiusMIP4", 22.0); + desc.add("coneRadiusMIP5", 24.0); + desc.add("maximumEcalEnergy", 2.0); // following 4 parameters are for isolation cuts and described in the code - desc.add("maxTrackP",8.0); - desc.add("slopeTrackP",0.05090504066); - desc.add("isolationEnergyTight",2.0); - desc.add("isolationEnergyLoose",10.0); + desc.add("maxTrackP", 8.0); + desc.add("slopeTrackP", 0.05090504066); + desc.add("isolationEnergyTight", 2.0); + desc.add("isolationEnergyLoose", 10.0); // energy thershold for ECAL (from Egamma group) - desc.add("EBHitEnergyThreshold",0.08); - desc.add("EEHitEnergyThreshold0",0.30); - desc.add("EEHitEnergyThreshold1",0.00); - desc.add("EEHitEnergyThreshold2",0.00); - desc.add("EEHitEnergyThreshold3",0.00); - desc.add("EEHitEnergyThresholdLow",0.30); - desc.add("EEHitEnergyThresholdHigh",0.30); + desc.add("EBHitEnergyThreshold", 0.08); + desc.add("EEHitEnergyThreshold0", 0.30); + desc.add("EEHitEnergyThreshold1", 0.00); + desc.add("EEHitEnergyThreshold2", 0.00); + desc.add("EEHitEnergyThreshold3", 0.00); + desc.add("EEHitEnergyThresholdLow", 0.30); + desc.add("EEHitEnergyThresholdHigh", 0.30); // prescale factors desc.add("momentumLow", 40.0); - desc.add("momentumHigh",60.0); + desc.add("momentumHigh", 60.0); desc.add("prescaleLow", 1); - desc.add("prescaleHigh",1); + desc.add("prescaleHigh", 1); // various labels for collections used in the code - desc.add("labelTriggerEvent",edm::InputTag("hltTriggerSummaryAOD","","HLT")); - desc.add("labelTriggerResult",edm::InputTag("TriggerResults","","HLT")); - desc.add("labelTrack","generalTracks"); - desc.add("labelVertex","offlinePrimaryVertices"); - desc.add("labelEBRecHit","EcalRecHitsEB"); - desc.add("labelEERecHit","EcalRecHitsEE"); - desc.add("labelHBHERecHit","hbhereco"); - desc.add("labelBeamSpot","offlineBeamSpot"); - desc.add("labelCaloTower","towerMaker"); + desc.add("labelTriggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT")); + desc.add("labelTriggerResult", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("labelTrack", "generalTracks"); + desc.add("labelVertex", "offlinePrimaryVertices"); + desc.add("labelEBRecHit", "EcalRecHitsEB"); + desc.add("labelEERecHit", "EcalRecHitsEE"); + desc.add("labelHBHERecHit", "hbhereco"); + desc.add("labelBeamSpot", "offlineBeamSpot"); + desc.add("labelCaloTower", "towerMaker"); desc.add("algInputTag", edm::InputTag("gtStage2Digis")); desc.add("extInputTag", edm::InputTag("gtStage2Digis")); - desc.addUntracked("moduleName",""); - desc.addUntracked("producerName",""); + desc.addUntracked("moduleName", ""); + desc.addUntracked("producerName", ""); // Various flags used for selecting tracks, choice of energy Method2/0 // Data type 0/1 for single jet trigger or others - desc.addUntracked("useRaw",0); - desc.addUntracked("ignoreTriggers",false); - desc.addUntracked("useL1Trigger",false); - desc.addUntracked("hcalScale",1.0); - desc.addUntracked("dataType",0); - desc.addUntracked("outMode",11); - desc.addUntracked("unCorrect",false); - desc.addUntracked("collapseDepth",false); - desc.addUntracked("l1TrigName","L1_SingleJet60"); - descriptions.add("HcalIsoTrkAnalyzer",desc); + desc.addUntracked("useRaw", 0); + desc.addUntracked("ignoreTriggers", false); + desc.addUntracked("useL1Trigger", false); + desc.addUntracked("hcalScale", 1.0); + desc.addUntracked("dataType", 0); + desc.addUntracked("outMode", 11); + desc.addUntracked("unCorrect", false); + desc.addUntracked("collapseDepth", false); + desc.addUntracked("l1TrigName", "L1_SingleJet60"); + descriptions.add("HcalIsoTrkAnalyzer", desc); } -std::array HcalIsoTrkAnalyzer::fillTree(std::vector< math::XYZTLorentzVector>& vecL1, - std::vector< math::XYZTLorentzVector>& vecL3, - math::XYZPoint& leadPV, - std::vector& trkCaloDirections, - std::vector& trkCaloDets, - const CaloGeometry* geo, - const CaloTopology* caloTopology, - const HcalTopology* theHBHETopology, - const EcalChannelStatus* theEcalChStatus, - const EcalSeverityLevelAlgo* theEcalSevlv, - edm::Handle& barrelRecHitsHandle, - edm::Handle& endcapRecHitsHandle, - edm::Handle& hbhe, - edm::Handle& tower, - edm::Handle& genParticles, - const HcalRespCorrs* respCorrs) { - +std::array HcalIsoTrkAnalyzer::fillTree(std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* caloTopology, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& tower, + edm::Handle& genParticles, + const HcalRespCorrs* respCorrs) { int nSave(0), nLoose(0), nTight(0); //Loop over tracks std::vector::const_iterator trkDetItr; unsigned int nTracks(0), nselTracks(0); t_nTrk = trkCaloDirections.size(); t_rhoh = (tower.isValid()) ? rhoh(tower) : 0; - for (trkDetItr = trkCaloDirections.begin(),nTracks=0; - trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) { + for (trkDetItr = trkCaloDirections.begin(), nTracks = 0; trkDetItr != trkCaloDirections.end(); + trkDetItr++, nTracks++) { const reco::Track* pTrack = &(*(trkDetItr->trkItr)); - math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), - pTrack->pz(), pTrack->p()); + math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << pTrack->pt() - << "|" << pTrack->eta() << "|" - << pTrack->phi() << "|" <p(); + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << pTrack->p(); #endif t_mindR2 = 999; - for (unsigned int k=0; kokHCAL) { HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); t_ieta = detId.ieta(); t_iphi = detId.iphi(); - if (t_p > 40.0 && t_p <= 60.0) t_ietaAll->emplace_back(t_ieta); + if (t_p > 40.0 && t_p <= 60.0) + t_ietaAll->emplace_back(t_ieta); } //Selection of good track - t_selectTk = spr::goodTrack(pTrack,leadPV,selectionParameter_,false); + t_selectTk = spr::goodTrack(pTrack, leadPV, selectionParameter_, false); spr::trackSelectionParameters oneCutParameters = selectionParameter_; - oneCutParameters.maxDxyPV = 10; - oneCutParameters.maxDzPV = 100; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; oneCutParameters.maxInMiss = 2; - oneCutParameters.maxOutMiss= 2; - bool qltyFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - oneCutParameters = selectionParameter_; - oneCutParameters.maxDxyPV = 10; - oneCutParameters.maxDzPV = 100; - t_qltyMissFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - oneCutParameters = selectionParameter_; + oneCutParameters.maxOutMiss = 2; + bool qltyFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; + t_qltyMissFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; oneCutParameters.maxInMiss = 2; - oneCutParameters.maxOutMiss= 2; - t_qltyPVFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - double eIsolation = maxRestrictionP_*exp(slopeRestrictionP_*std::abs((double)t_ieta)); - if (eIsolation < eIsolate1_) eIsolation = eIsolate1_; - if (eIsolation < eIsolate2_) eIsolation = eIsolate2_; + oneCutParameters.maxOutMiss = 2; + t_qltyPVFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + double eIsolation = maxRestrictionP_ * exp(slopeRestrictionP_ * std::abs((double)t_ieta)); + if (eIsolation < eIsolate1_) + eIsolation = eIsolate1_; + if (eIsolation < eIsolate2_) + eIsolation = eIsolate2_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " - << qltyFlag << "|" << trkDetItr->okECAL - << "|" << trkDetItr->okHCAL - << " eIsolation " << eIsolation; + edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr->okECAL << "|" + << trkDetItr->okHCAL << " eIsolation " << eIsolation; #endif t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL); if (t_qltyFlag) { nselTracks++; int nNearTRKs(0); ////////////////////////////////-MIP STUFF-////////////////////////////// - std::vector eIds; + std::vector eIds; std::vector eHit; - t_eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR_, - trkDetItr->directionECAL, eIds, eHit); + t_eMipDR = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR_, + trkDetItr->directionECAL, + eIds, + eHit); double eEcal(0); - for (unsigned int k=0; kgetPosition(eIds[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit[k] > eThr) eEcal += eHit[k]; + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit[k] > eThr) + eEcal += eHit[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR - << ":" << eEcal; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR << ":" << eEcal; #endif t_eMipDR = eEcal; ////////////////////////////////-MIP STUFF-/////////////////////////////// ////////////////////////////////-MIP STUFF-2////////////////////////////// - std::vector eIds2; + std::vector eIds2; std::vector eHit2; - t_eMipDR2 = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR2_, - trkDetItr->directionECAL, eIds2, eHit2); + t_eMipDR2 = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR2_, + trkDetItr->directionECAL, + eIds2, + eHit2); double eEcal2(0); - for (unsigned int k=0; kgetPosition(eIds2[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds2[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit2[k] > eThr) eEcal2 += eHit2[k]; + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds2[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit2[k] > eThr) + eEcal2 += eHit2[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR2 - << ":" << eEcal2; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR2 << ":" << eEcal2; #endif t_eMipDR2 = eEcal2; ////////////////////////////////-MIP STUFF-2///////////////////////////// ////////////////////////////////-MIP STUFF-3///////////////////////////// - std::vector eIds3; + std::vector eIds3; std::vector eHit3; - t_eMipDR3 = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR3_, - trkDetItr->directionECAL, eIds3, eHit3); + t_eMipDR3 = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR3_, + trkDetItr->directionECAL, + eIds3, + eHit3); double eEcal3(0); - for (unsigned int k=0; kgetPosition(eIds3[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds3[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit3[k] > eThr) eEcal3 += eHit3[k]; + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds3[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit3[k] > eThr) + eEcal3 += eHit3[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR3 - << ":" << eEcal3; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR3 << ":" << eEcal3; #endif t_eMipDR3 = eEcal3; ////////////////////////////////-MIP STUFF-3///////////////////////////// ////////////////////////////////-MIP STUFF-4///////////////////////////// - std::vector eIds4; + std::vector eIds4; std::vector eHit4; - t_eMipDR4 = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR4_, - trkDetItr->directionECAL, eIds4, eHit4); + t_eMipDR4 = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR4_, + trkDetItr->directionECAL, + eIds4, + eHit4); double eEcal4(0); - for (unsigned int k=0; kgetPosition(eIds4[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds4[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit4[k] > eThr) eEcal4 += eHit4[k]; + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds4[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit4[k] > eThr) + eEcal4 += eHit4[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR4 - << ":" << eEcal4; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR4 << ":" << eEcal4; #endif t_eMipDR4 = eEcal4; ////////////////////////////////-MIP STUFF-4///////////////////////////// ////////////////////////////////-MIP STUFF-5///////////////////////////// - std::vector eIds5; + std::vector eIds5; std::vector eHit5; - t_eMipDR5 = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR5_, - trkDetItr->directionECAL, eIds5, eHit5); + t_eMipDR5 = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR5_, + trkDetItr->directionECAL, + eIds5, + eHit5); double eEcal5(0); - for (unsigned int k=0; kgetPosition(eIds5[k]); - double eta = std::abs(pos.eta()); - double eThr(hitEthrEB_); - if (eIds5[k].subdetId() != EcalBarrel) { - eThr = (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+ - hitEthrEE0_); - if (eThr < hitEthrEELo_) eThr = hitEthrEELo_; - else if (eThr > hitEthrEEHi_) eThr = hitEthrEEHi_; - } - if (eHit5[k] > eThr) eEcal5 += eHit5[k]; + double eta = std::abs(pos.eta()); + double eThr(hitEthrEB_); + if (eIds5[k].subdetId() != EcalBarrel) { + eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eThr < hitEthrEELo_) + eThr = hitEthrEELo_; + else if (eThr > hitEthrEEHi_) + eThr = hitEthrEEHi_; + } + if (eHit5[k] > eThr) + eEcal5 += eHit5[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR5 - << ":" << eEcal5; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR5 << ":" << eEcal5; #endif t_eMipDR5 = eEcal5; ////////////////////////////////-MIP STUFF-5///////////////////////////// - t_emaxNearP = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, - caloTopology, 15,15); + t_emaxNearP = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 15, 15); const DetId cellE(trkDetItr->detIdECAL); - std::pair e11x11P = - spr::eECALmatrix(cellE,barrelRecHitsHandle,endcapRecHitsHandle, - *theEcalChStatus,geo,caloTopology,theEcalSevlv, - 5,5,-100.0,-100.0,-100.0,100.0); - std::pair e15x15P = - spr::eECALmatrix(cellE,barrelRecHitsHandle,endcapRecHitsHandle, - *theEcalChStatus,geo,caloTopology,theEcalSevlv,7,7, - -100.0,-100.0,-100.0,100.0); + std::pair e11x11P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 5, + 5, + -100.0, + -100.0, + -100.0, + 100.0); + std::pair e15x15P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 7, + 7, + -100.0, + -100.0, + -100.0, + 100.0); if (e11x11P.second && e15x15P.second) { - t_eAnnular = (e15x15P.first - e11x11P.first); + t_eAnnular = (e15x15P.first - e11x11P.first); } else { - t_eAnnular =-(e15x15P.first - e11x11P.first); + t_eAnnular = -(e15x15P.first - e11x11P.first); } - t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, - a_charIsoR_, nNearTRKs, false); + t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false); const DetId cellH(trkDetItr->detIdHCAL); - double h5x5 = spr::eHCALmatrix(theHBHETopology,cellH,hbhe,2,2,false,true, - -100.0,-100.0,-100.0,-100.0,-100.0,100.0); - double h7x7 = spr::eHCALmatrix(theHBHETopology,cellH,hbhe,3,3,false,true, - -100.0,-100.0,-100.0,-100.0,-100.0,100.0); + double h5x5 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); + double h7x7 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); t_hAnnular = h7x7 - h5x5; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << t_emaxNearP - << " (Hcal) " << t_hmaxNearP - << " Annular E (Ecal) " << e11x11P.first - << ":" << e15x15P.first << ":" - << t_eAnnular << " (Hcal) " << h5x5 - << ":" << h7x7 << ":" << t_hAnnular; + edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << t_emaxNearP << " (Hcal) " << t_hmaxNearP + << " Annular E (Ecal) " << e11x11P.first << ":" << e15x15P.first << ":" + << t_eAnnular << " (Hcal) " << h5x5 << ":" << h7x7 << ":" << t_hAnnular; #endif t_gentrackP = trackP(pTrack, genParticles); if (t_eMipDR < eEcalMax_ && t_hmaxNearP < eIsolation) { - t_DetIds->clear(); t_HitEnergies->clear(); - t_DetIds1->clear(); t_HitEnergies1->clear(); - t_DetIds3->clear(); t_HitEnergies3->clear(); - int nRecHits(-999), nRecHits1(-999), nRecHits3(-999); - std::vector ids, ids1, ids3; - std::vector edet0, edet1, edet3; - t_eHcal = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR_, - trkDetItr->directionHCAL,nRecHits, - ids, edet0, useRaw_); - storeEnergy(0,respCorrs,ids, edet0,t_eHcal, t_DetIds, t_HitEnergies); + t_DetIds->clear(); + t_HitEnergies->clear(); + t_DetIds1->clear(); + t_HitEnergies1->clear(); + t_DetIds3->clear(); + t_HitEnergies3->clear(); + int nRecHits(-999), nRecHits1(-999), nRecHits3(-999); + std::vector ids, ids1, ids3; + std::vector edet0, edet1, edet3; + t_eHcal = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR_, + trkDetItr->directionHCAL, + nRecHits, + ids, + edet0, + useRaw_); + storeEnergy(0, respCorrs, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies); + + //----- hcal energy in the extended cone 1 (a_coneR+10) -------------- + t_eHcal10 = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR1_, + trkDetItr->directionHCAL, + nRecHits1, + ids1, + edet1, + useRaw_); + storeEnergy(1, respCorrs, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1); - //----- hcal energy in the extended cone 1 (a_coneR+10) -------------- - t_eHcal10 = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR1_, - trkDetItr->directionHCAL,nRecHits1, - ids1, edet1, useRaw_); - storeEnergy(1,respCorrs,ids1,edet1,t_eHcal10,t_DetIds1,t_HitEnergies1); + //----- hcal energy in the extended cone 3 (a_coneR+30) -------------- + t_eHcal30 = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR2_, + trkDetItr->directionHCAL, + nRecHits3, + ids3, + edet3, + useRaw_); + storeEnergy(3, respCorrs, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3); - //----- hcal energy in the extended cone 3 (a_coneR+30) -------------- - t_eHcal30 = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR2_, - trkDetItr->directionHCAL,nRecHits3, - ids3, edet3, useRaw_); - storeEnergy(3,respCorrs,ids3,edet3,t_eHcal30,t_DetIds3,t_HitEnergies3); + t_p = pTrack->p(); + t_pt = pTrack->pt(); + t_phi = pTrack->phi(); - t_p = pTrack->p(); - t_pt = pTrack->pt(); - t_phi = pTrack->phi(); - #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << t_pt - << "|" << pTrack->eta() << "|" - << t_phi << "|" << t_p - << " Generator Level p " - << t_gentrackP; - edm::LogVerbatim("HcalIsoTrack") << "e_MIP " << t_eMipDR - << " Chg Isolation " << t_hmaxNearP - << " eHcal" << t_eHcal << " ieta " - << t_ieta << " Quality " - << t_qltyMissFlag << ":" - << t_qltyPVFlag << ":" << t_selectTk; - for (unsigned int ll=0; llsize(); ll++) { - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds->at(ll) - << " hit enery is = " - << t_HitEnergies->at(ll); - } - for (unsigned int ll=0; llsize(); ll++) { - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds1->at(ll) - << " hit enery is = " - << t_HitEnergies1->at(ll); - } - for (unsigned int ll=0; llsize(); ll++) { - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds3->at(ll) - << " hit enery is = " - << t_HitEnergies3->at(ll); - } + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << t_pt << "|" + << pTrack->eta() << "|" << t_phi << "|" << t_p << " Generator Level p " + << t_gentrackP; + edm::LogVerbatim("HcalIsoTrack") << "e_MIP " << t_eMipDR << " Chg Isolation " << t_hmaxNearP << " eHcal" + << t_eHcal << " ieta " << t_ieta << " Quality " << t_qltyMissFlag << ":" + << t_qltyPVFlag << ":" << t_selectTk; + for (unsigned int ll = 0; ll < t_DetIds->size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds->at(ll) << " hit enery is = " << t_HitEnergies->at(ll); + } + for (unsigned int ll = 0; ll < t_DetIds1->size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds1->at(ll) << " hit enery is = " << t_HitEnergies1->at(ll); + } + for (unsigned int ll = 0; ll < t_DetIds3->size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds3->at(ll) << " hit enery is = " << t_HitEnergies3->at(ll); + } #endif - bool accept(false); - if (t_p>pTrackMin_) { - if (t_ppTrackHigh_) { - ++nHigh_; - if (prescaleHigh_ <= 1) accept = true; - else if (nHigh_%prescaleHigh_ == 1) accept = true; - } else { - accept = true; - } - } - if (accept) { - tree->Fill(); - nSave++; - int type(0); - if (t_eMipDR < 1.0) { - if (t_hmaxNearP < eIsolate2_) { ++nLoose; type = 1;} - if (t_hmaxNearP < eIsolate1_) { ++nTight; type = 2;} - } - if (t_p > 40.0 && t_p <= 60.0 && t_selectTk) { - t_ietaGood->emplace_back(t_ieta); - t_trackType->emplace_back(type); - } + bool accept(false); + if (t_p > pTrackMin_) { + if (t_p < pTrackLow_) { + ++nLow_; + if (prescaleLow_ <= 1) + accept = true; + else if (nLow_ % prescaleLow_ == 1) + accept = true; + } else if (t_p > pTrackHigh_) { + ++nHigh_; + if (prescaleHigh_ <= 1) + accept = true; + else if (nHigh_ % prescaleHigh_ == 1) + accept = true; + } else { + accept = true; + } + } + if (accept) { + tree->Fill(); + nSave++; + int type(0); + if (t_eMipDR < 1.0) { + if (t_hmaxNearP < eIsolate2_) { + ++nLoose; + type = 1; + } + if (t_hmaxNearP < eIsolate1_) { + ++nTight; + type = 2; + } + } + if (t_p > 40.0 && t_p <= 60.0 && t_selectTk) { + t_ietaGood->emplace_back(t_ieta); + t_trackType->emplace_back(type); + } #ifdef EDM_ML_DEBUG - for (unsigned int k=0; ksize(); k++) { - edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " - << t_trgbits->at(k); - } + for (unsigned int k = 0; k < t_trgbits->size(); k++) { + edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " << t_trgbits->at(k); + } #endif - } + } } } } - std::array i3{ {nSave,nLoose,nTight} }; + std::array i3{{nSave, nLoose, nTight}}; return i3; } double HcalIsoTrkAnalyzer::dR(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) { - return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi()); + return reco::deltaR(vec1.eta(), vec1.phi(), vec2.eta(), vec2.phi()); } double HcalIsoTrkAnalyzer::trackP(const reco::Track* pTrack, - const edm::Handle& genParticles) { - + const edm::Handle& genParticles) { double pmom = -1.0; if (genParticles.isValid()) { double mindR(999.9); - for (const auto &p : (*genParticles)) { - double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), - p.momentum().Eta(), p.momentum().Phi()); + for (const auto& p : (*genParticles)) { + double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), p.momentum().Eta(), p.momentum().Phi()); if (dR < mindR) { - mindR = dR; pmom = p.momentum().R(); + mindR = dR; + pmom = p.momentum().R(); } } } @@ -1271,91 +1304,92 @@ double HcalIsoTrkAnalyzer::trackP(const reco::Track* pTrack, } double HcalIsoTrkAnalyzer::rhoh(const edm::Handle& tower) { - std::vector sumPFNallSMDQH2; - sumPFNallSMDQH2.reserve(phibins_.size()*etabins_.size()); - + sumPFNallSMDQH2.reserve(phibins_.size() * etabins_.size()); + for (auto eta : etabins_) { for (auto phi : phibins_) { double hadder = 0; - for (const auto & pf_it : (*tower)) { - if (fabs(eta-pf_it.eta())>etahalfdist_) continue; - if (fabs(reco::deltaPhi(phi,pf_it.phi()))>phihalfdist_) continue; - hadder += pf_it.hadEt(); + for (const auto& pf_it : (*tower)) { + if (fabs(eta - pf_it.eta()) > etahalfdist_) + continue; + if (fabs(reco::deltaPhi(phi, pf_it.phi())) > phihalfdist_) + continue; + hadder += pf_it.hadEt(); } sumPFNallSMDQH2.emplace_back(hadder); } } double evt_smdq(0); - std::sort(sumPFNallSMDQH2.begin(),sumPFNallSMDQH2.end()); - if (sumPFNallSMDQH2.size()%2) evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-1)/2]; - else evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size()/2]+sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-2)/2])/2.; - double rhoh = evt_smdq/(etadist_*phidist_); + std::sort(sumPFNallSMDQH2.begin(), sumPFNallSMDQH2.end()); + if (sumPFNallSMDQH2.size() % 2) + evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 1) / 2]; + else + evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size() / 2] + sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 2) / 2]) / 2.; + double rhoh = evt_smdq / (etadist_ * phidist_); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalIsoTrack") << "Rho " << evt_smdq << ":" << rhoh; #endif return rhoh; } -void HcalIsoTrkAnalyzer::storeEnergy(int indx, const HcalRespCorrs* respCorrs, - const std::vector& ids, - std::vector& edet, - double & eHcal, - std::vector *detIds, - std::vector *hitEnergies) { +void HcalIsoTrkAnalyzer::storeEnergy(int indx, + const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector* detIds, + std::vector* hitEnergies) { double ehcal(0); if (unCorrect_) { - for (unsigned int k=0; kgetValues(ids[k]))->getValue(); - if (corr != 0) edet[k] /= corr; + if (corr != 0) + edet[k] /= corr; ehcal += edet[k]; } } else { - for (const auto& en : edet) ehcal += en; + for (const auto& en : edet) + ehcal += en; } - if (std::abs(ehcal-eHcal) > 0.001) - edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx - << " " << eHcal << ":" << ehcal - << " from " << ids.size() << " cells"; - eHcal = hcalScale_*ehcal; + if (std::abs(ehcal - eHcal) > 0.001) + edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx << " " << eHcal << ":" << ehcal + << " from " << ids.size() << " cells"; + eHcal = hcalScale_ * ehcal; if (collapseDepth_) { - std::map hitMap; - for (unsigned int k=0; k hitMap; + for (unsigned int k = 0; k < ids.size(); ++k) { HcalDetId id = hdc_->mergedDepthDetId(HcalDetId(ids[k])); auto itr = hitMap.find(id); if (itr == hitMap.end()) { - hitMap[id] = edet[k]; + hitMap[id] = edet[k]; } else { - (itr->second) += edet[k]; + (itr->second) += edet[k]; } } - detIds->reserve(hitMap.size()); hitEnergies->reserve(hitMap.size()); + detIds->reserve(hitMap.size()); + hitEnergies->reserve(hitMap.size()); for (const auto& hit : hitMap) { detIds->emplace_back(hit.first.rawId()); hitEnergies->emplace_back(hit.second); } } else { - detIds->reserve(ids.size()); hitEnergies->reserve(ids.size()); - for (unsigned int k=0; kreserve(ids.size()); + hitEnergies->reserve(ids.size()); + for (unsigned int k = 0; k < ids.size(); ++k) { detIds->emplace_back(ids[k].rawId()); hitEnergies->emplace_back(edet[k]); } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Input to storeEnergy with " - << ids.size() << " cells"; - for (unsigned int k=0; ksize() << " cells and Etot " - << eHcal; - for (unsigned int k=0; ksize(); ++k) - edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " - << HcalDetId((*detIds)[k]) << " E " - << (*hitEnergies)[k]; + edm::LogVerbatim("HcalIsoTrack") << "Input to storeEnergy with " << ids.size() << " cells"; + for (unsigned int k = 0; k < ids.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId(ids[k]) << " E " << edet[k]; + edm::LogVerbatim("HcalIsoTrack") << "Output of storeEnergy with " << detIds->size() << " cells and Etot " << eHcal; + for (unsigned int k = 0; k < detIds->size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId((*detIds)[k]) << " E " << (*hitEnergies)[k]; #endif } diff --git a/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.cc b/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.cc index 02323866dbcd5..1e291f4cc1e32 100644 --- a/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.cc +++ b/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.cc @@ -10,122 +10,113 @@ #include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h" #include "FWCore/Utilities/interface/Exception.h" - using namespace edm; using namespace std; using namespace reco; -namespace cms -{ - -HitReCalibrator::HitReCalibrator(const edm::ParameterSet& iConfig) -{ - tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); - tok_ho_ = consumes(iConfig.getParameter("hoInput")); - tok_hf_ = consumes(iConfig.getParameter("hfInput")); - allowMissingInputs_ = true; -//register your products - - produces("DiJetsHBHEReRecHitCollection"); - produces("DiJetsHOReRecHitCollection"); - produces("DiJetsHFReRecHitCollection"); - -} -void HitReCalibrator::beginJob() -{ -} - -HitReCalibrator::~HitReCalibrator() -{ - -} - - -// ------------ method called to produce the data ------------ -void -HitReCalibrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - - auto miniDiJetsHBHERecHitCollection = std::make_unique(); - auto miniDiJetsHORecHitCollection = std::make_unique(); - auto miniDiJetsHFRecHitCollection = std::make_unique(); - - - edm::ESHandle recalibCorrs; - iSetup.get().get("recalibrate",recalibCorrs); - const HcalRespCorrs* jetRecalib = recalibCorrs.product(); - - - try { - edm::Handle hbhe; - iEvent.getByToken(tok_hbhe_,hbhe); - const HBHERecHitCollection Hithbhe = *(hbhe.product()); - for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++) - { - DetId id = hbheItr->detid(); - float recal; - if (jetRecalib->exists(id)) - recal = jetRecalib->getValues(id)->getValue(); - else recal = 1.; - float energy = hbheItr->energy(); - float time = hbheItr->time(); - HBHERecHit* hbhehit = new HBHERecHit(id,recal*energy,time); - miniDiJetsHBHERecHitCollection->push_back(*hbhehit); - } - } catch (cms::Exception& e) { // can't find it! - if (!allowMissingInputs_) {cout<<"No HBHE collection "< ho; - iEvent.getByToken(tok_ho_,ho); - const HORecHitCollection Hitho = *(ho.product()); - for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++) - { - DetId id = hoItr->detid(); - float recal; - if (jetRecalib->exists(id)) - recal = jetRecalib->getValues(id)->getValue(); - else recal = 1.; - float energy = hoItr->energy(); - float time = hoItr->time(); - HORecHit* hohit = new HORecHit(id,recal*energy,time); - miniDiJetsHORecHitCollection->push_back(*hohit); - } - } catch (cms::Exception& e) { // can't find it! - if (!allowMissingInputs_) {cout<<" No HO collection "<(iConfig.getParameter("hbheInput")); + tok_ho_ = consumes(iConfig.getParameter("hoInput")); + tok_hf_ = consumes(iConfig.getParameter("hfInput")); + allowMissingInputs_ = true; + //register your products - try { - edm::Handle hf; - iEvent.getByToken(tok_hf_,hf); - const HFRecHitCollection Hithf = *(hf.product()); - for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++) - { - DetId id = hfItr->detid(); - float recal; - if (jetRecalib->exists(id)) - recal = jetRecalib->getValues(id)->getValue(); - else recal = 1.; - float energy = hfItr->energy(); - float time = hfItr->time(); - HFRecHit* hfhit = new HFRecHit(id,recal*energy,time); - miniDiJetsHFRecHitCollection->push_back(*hfhit); - } - } catch (cms::Exception& e) { // can't find it! - if (!allowMissingInputs_) throw e; + produces("DiJetsHBHEReRecHitCollection"); + produces("DiJetsHOReRecHitCollection"); + produces("DiJetsHFReRecHitCollection"); } + void HitReCalibrator::beginJob() {} + + HitReCalibrator::~HitReCalibrator() {} + + // ------------ method called to produce the data ------------ + void HitReCalibrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + auto miniDiJetsHBHERecHitCollection = std::make_unique(); + auto miniDiJetsHORecHitCollection = std::make_unique(); + auto miniDiJetsHFRecHitCollection = std::make_unique(); + + edm::ESHandle recalibCorrs; + iSetup.get().get("recalibrate", recalibCorrs); + const HcalRespCorrs* jetRecalib = recalibCorrs.product(); + + try { + edm::Handle hbhe; + iEvent.getByToken(tok_hbhe_, hbhe); + const HBHERecHitCollection Hithbhe = *(hbhe.product()); + for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) { + DetId id = hbheItr->detid(); + float recal; + if (jetRecalib->exists(id)) + recal = jetRecalib->getValues(id)->getValue(); + else + recal = 1.; + float energy = hbheItr->energy(); + float time = hbheItr->time(); + HBHERecHit* hbhehit = new HBHERecHit(id, recal * energy, time); + miniDiJetsHBHERecHitCollection->push_back(*hbhehit); + } + } catch (cms::Exception& e) { // can't find it! + if (!allowMissingInputs_) { + cout << "No HBHE collection " << endl; + throw e; + } + } + + try { + edm::Handle ho; + iEvent.getByToken(tok_ho_, ho); + const HORecHitCollection Hitho = *(ho.product()); + for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) { + DetId id = hoItr->detid(); + float recal; + if (jetRecalib->exists(id)) + recal = jetRecalib->getValues(id)->getValue(); + else + recal = 1.; + float energy = hoItr->energy(); + float time = hoItr->time(); + HORecHit* hohit = new HORecHit(id, recal * energy, time); + miniDiJetsHORecHitCollection->push_back(*hohit); + } + } catch (cms::Exception& e) { // can't find it! + if (!allowMissingInputs_) { + cout << " No HO collection " << endl; + throw e; + } + } + + try { + edm::Handle hf; + iEvent.getByToken(tok_hf_, hf); + const HFRecHitCollection Hithf = *(hf.product()); + for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) { + DetId id = hfItr->detid(); + float recal; + if (jetRecalib->exists(id)) + recal = jetRecalib->getValues(id)->getValue(); + else + recal = 1.; + float energy = hfItr->energy(); + float time = hfItr->time(); + HFRecHit* hfhit = new HFRecHit(id, recal * energy, time); + miniDiJetsHFRecHitCollection->push_back(*hfhit); + } + } catch (cms::Exception& e) { // can't find it! + if (!allowMissingInputs_) + throw e; + } - //Put selected information in the event - - iEvent.put(std::move(miniDiJetsHBHERecHitCollection), "DiJetsHBHEReRecHitCollection"); + //Put selected information in the event - iEvent.put(std::move(miniDiJetsHORecHitCollection), "DiJetsHOReRecHitCollection"); + iEvent.put(std::move(miniDiJetsHBHERecHitCollection), "DiJetsHBHEReRecHitCollection"); - iEvent.put(std::move(miniDiJetsHFRecHitCollection), "DiJetsHFReRecHitCollection"); + iEvent.put(std::move(miniDiJetsHORecHitCollection), "DiJetsHOReRecHitCollection"); -} -} + iEvent.put(std::move(miniDiJetsHFRecHitCollection), "DiJetsHFReRecHitCollection"); + } +} // namespace cms #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.h b/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.h index cf348b7f8a23a..76a0f2df079e9 100644 --- a/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.h +++ b/Calibration/HcalCalibAlgos/plugins/HitReCalibrator.h @@ -1,10 +1,8 @@ #ifndef HitReCalibrator_h #define HitReCalibrator_h - // -*- C++ -*- - // system include files #include #include @@ -32,28 +30,27 @@ namespace edm { class ParameterSet; class Event; class EventSetup; -} +} // namespace edm -namespace cms -{ +namespace cms { -class HitReCalibrator : public edm::EDProducer { - public: - explicit HitReCalibrator(const edm::ParameterSet&); - ~HitReCalibrator() override; + class HitReCalibrator : public edm::EDProducer { + public: + explicit HitReCalibrator(const edm::ParameterSet &); + ~HitReCalibrator() override; - void beginJob() override; + void beginJob() override; - void produce(edm::Event &, const edm::EventSetup&) override; - private: - // ----------member data --------------------------- + void produce(edm::Event &, const edm::EventSetup &) override; - bool allowMissingInputs_; + private: + // ----------member data --------------------------- + + bool allowMissingInputs_; edm::EDGetTokenT tok_hbhe_; edm::EDGetTokenT tok_ho_; edm::EDGetTokenT tok_hf_; - -}; -}// end namespace cms + }; +} // end namespace cms #endif diff --git a/Calibration/HcalCalibAlgos/plugins/RecAnalyzerHF.cc b/Calibration/HcalCalibAlgos/plugins/RecAnalyzerHF.cc index 814f9c7c98670..e0fa8981b3366 100644 --- a/Calibration/HcalCalibAlgos/plugins/RecAnalyzerHF.cc +++ b/Calibration/HcalCalibAlgos/plugins/RecAnalyzerHF.cc @@ -39,7 +39,6 @@ // class declaration class RecAnalyzerHF : public edm::one::EDAnalyzer { - public: explicit RecAnalyzerHF(const edm::ParameterSet&); ~RecAnalyzerHF() override; @@ -50,140 +49,138 @@ class RecAnalyzerHF : public edm::one::EDAnalyzer { void analyze(edm::Event const&, edm::EventSetup const&) override; void beginJob() override; void endJob() override; - + private: void analyzeHcal(const HFPreRecHitCollection&, int, bool); // ----------member data --------------------------- edm::Service fs_; - bool ignoreL1_, nzs_, noise_, ratio_,fillTree_; - double eLowHF_, eHighHF_; - std::vector hcalID_; - TTree *myTree_; - TH1D *hist_[2]; - std::vector> histo_; - std::vector trigbit_; - double rnnum_; - struct myInfo{ + bool ignoreL1_, nzs_, noise_, ratio_, fillTree_; + double eLowHF_, eHighHF_; + std::vector hcalID_; + TTree* myTree_; + TH1D* hist_[2]; + std::vector> histo_; + std::vector trigbit_; + double rnnum_; + struct myInfo { double kount, f11, f12, f13, f14, f21, f22, f23, f24, runcheck; - myInfo() { - kount = f11 = f12 = f13 = f14 = f21 = f22 = f23 = f24 = runcheck = 0; - } + myInfo() { kount = f11 = f12 = f13 = f14 = f21 = f22 = f23 = f24 = runcheck = 0; } }; // Root tree members - double rnnumber; - int mysubd, depth, iphi, ieta, cells, trigbit; - float mom0_F1, mom1_F1, mom2_F1, mom3_F1, mom4_F1; - float mom0_F2, mom1_F2, mom2_F2, mom3_F2, mom4_F2; - std::map,myInfo> myMap_; - edm::EDGetTokenT tok_hfreco_; + double rnnumber; + int mysubd, depth, iphi, ieta, cells, trigbit; + float mom0_F1, mom1_F1, mom2_F1, mom3_F1, mom4_F1; + float mom0_F2, mom1_F2, mom2_F2, mom3_F2, mom4_F2; + std::map, myInfo> myMap_; + edm::EDGetTokenT tok_hfreco_; edm::EDGetTokenT tok_hltL1GtMap_; }; // constructors and destructor - RecAnalyzerHF::RecAnalyzerHF(const edm::ParameterSet& iConfig) { - +RecAnalyzerHF::RecAnalyzerHF(const edm::ParameterSet& iConfig) { usesResource("TFileService"); // get name of output file with histogramms - nzs_ = iConfig.getParameter("RunNZS"); - noise_ = iConfig.getParameter("Noise"); - ratio_ = iConfig.getParameter("Ratio"); - eLowHF_ = iConfig.getParameter("ELowHF"); - eHighHF_ = iConfig.getParameter("EHighHF"); - trigbit_ = iConfig.getUntrackedParameter>("TriggerBits"); - ignoreL1_ = iConfig.getUntrackedParameter("IgnoreL1",false); - fillTree_ = iConfig.getUntrackedParameter("FillTree",true); + nzs_ = iConfig.getParameter("RunNZS"); + noise_ = iConfig.getParameter("Noise"); + ratio_ = iConfig.getParameter("Ratio"); + eLowHF_ = iConfig.getParameter("ELowHF"); + eHighHF_ = iConfig.getParameter("EHighHF"); + trigbit_ = iConfig.getUntrackedParameter>("TriggerBits"); + ignoreL1_ = iConfig.getUntrackedParameter("IgnoreL1", false); + fillTree_ = iConfig.getUntrackedParameter("FillTree", true); std::vector ieta = iConfig.getUntrackedParameter>("HcalIeta"); std::vector iphi = iConfig.getUntrackedParameter>("HcalIphi"); - std::vector depth= iConfig.getUntrackedParameter>("HcalDepth"); + std::vector depth = iConfig.getUntrackedParameter>("HcalDepth"); // get token names of modules, producing object collections - tok_hfreco_ = consumes(iConfig.getParameter("hfInput")); - tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); + tok_hfreco_ = consumes(iConfig.getParameter("hfInput")); + tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); - edm::LogVerbatim("RecAnalyzer") << " Flags (IgnoreL1): " << ignoreL1_ - << " (NZS) " << nzs_ << " (Noise) " << noise_ - << " (Ratio) " << ratio_; - edm::LogVerbatim("RecAnalyzer") << "Thresholds for HF " << eLowHF_ << ":" - << eHighHF_; - for (unsigned int k=0; k= 29) { - unsigned int id = (HcalDetId(HcalForward,ieta[k],iphi[k],depth[k])).rawId(); + unsigned int id = (HcalDetId(HcalForward, ieta[k], iphi[k], depth[k])).rawId(); hcalID_.push_back(id); edm::LogVerbatim("RecAnalyzer") << "DetId[" << k << "] " << HcalDetId(id); } } - edm::LogVerbatim("RecAnalyzer") << "Select on " << trigbit_.size() - << " L1 Trigger selection"; + edm::LogVerbatim("RecAnalyzer") << "Select on " << trigbit_.size() << " L1 Trigger selection"; unsigned int k(0); for (auto trig : trigbit_) { - edm::LogVerbatim("RecAnalyzer") << "Bit[" << k << "] " << trig; ++k;} + edm::LogVerbatim("RecAnalyzer") << "Bit[" << k << "] " << trig; + ++k; + } } - + RecAnalyzerHF::~RecAnalyzerHF() {} // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void RecAnalyzerHF::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("RunNZS",true); - desc.add("Noise",false); - desc.add("Ratio",false); - desc.add("ELowHF",10); - desc.add("EHighHF",150); + desc.add("RunNZS", true); + desc.add("Noise", false); + desc.add("Ratio", false); + desc.add("ELowHF", 10); + desc.add("EHighHF", 150); std::vector idummy; - desc.addUntracked >("TriggerBits",idummy); - desc.addUntracked("IgnoreL1",false); - desc.addUntracked("FillHisto",false); - desc.addUntracked >("HcalIeta",idummy); - desc.addUntracked >("HcalIphi",idummy); - desc.addUntracked >("HcalDepth",idummy); - desc.add("hfInput",edm::InputTag("hfprereco")); - descriptions.add("recAnalyzerHF",desc); + desc.addUntracked>("TriggerBits", idummy); + desc.addUntracked("IgnoreL1", false); + desc.addUntracked("FillHisto", false); + desc.addUntracked>("HcalIeta", idummy); + desc.addUntracked>("HcalIphi", idummy); + desc.addUntracked>("HcalDepth", idummy); + desc.add("hfInput", edm::InputTag("hfprereco")); + descriptions.add("recAnalyzerHF", desc); } - -void RecAnalyzerHF::beginJob() { - char name[700], title[700]; - double xmin(-10.0), xmax(90.0); - if (ratio_) { xmin = -5.0; xmax = 5.0;} - for (int i=0; i<2; ++i) { +void RecAnalyzerHF::beginJob() { + char name[700], title[700]; + double xmin(-10.0), xmax(90.0); + if (ratio_) { + xmin = -5.0; + xmax = 5.0; + } + for (int i = 0; i < 2; ++i) { sprintf(name, "HF%d", i); - sprintf (title, "The metric F%d for HF", i+1); - hist_[i] = fs_->make(name,title,50,xmin,xmax); + sprintf(title, "The metric F%d for HF", i + 1); + hist_[i] = fs_->make(name, title, 50, xmin, xmax); } - for (const auto & id : hcalID_) { + for (const auto& id : hcalID_) { HcalDetId hid = HcalDetId(id); TH1D *h1(nullptr), *h2(nullptr); - for (int i=0; i<2; ++i) { - sprintf (name, "HF%d%d_%d_%d", i, hid.ieta(), hid.iphi(), hid.depth()); - sprintf (title, "The metric F%d for HF i#eta %d i#phi %d depth %d", - i+1, hid.ieta(), hid.iphi(), hid.depth()); - if (i == 0) h1 = fs_->make(name, title, 50, xmin, xmax); - else h2 = fs_->make(name, title, 50, xmin, xmax); + for (int i = 0; i < 2; ++i) { + sprintf(name, "HF%d%d_%d_%d", i, hid.ieta(), hid.iphi(), hid.depth()); + sprintf(title, "The metric F%d for HF i#eta %d i#phi %d depth %d", i + 1, hid.ieta(), hid.iphi(), hid.depth()); + if (i == 0) + h1 = fs_->make(name, title, 50, xmin, xmax); + else + h2 = fs_->make(name, title, 50, xmin, xmax); } - histo_.push_back(std::pair(h1,h2)); + histo_.push_back(std::pair(h1, h2)); }; if (fillTree_) { - myTree_ = fs_->make("RecJet","RecJet Tree"); - myTree_->Branch("cells", &cells, "cells/I"); - myTree_->Branch("mysubd", &mysubd, "mysubd/I"); - myTree_->Branch("depth", &depth, "depth/I"); - myTree_->Branch("ieta", &ieta, "ieta/I"); - myTree_->Branch("iphi", &iphi, "iphi/I"); - myTree_->Branch("mom0_F1", &mom0_F1, "mom0_F1/F"); - myTree_->Branch("mom1_F1", &mom1_F1, "mom1_F1/F"); - myTree_->Branch("mom2_F1", &mom2_F1, "mom2_F1/F"); - myTree_->Branch("mom3_F1", &mom3_F1, "mom3_F1/F"); - myTree_->Branch("mom4_F1", &mom4_F1, "mom4_F1/F"); - myTree_->Branch("mom0_F2", &mom0_F2, "mom0_F2/F"); - myTree_->Branch("mom1_F2", &mom1_F2, "mom1_F2/F"); - myTree_->Branch("mom2_F2", &mom2_F2, "mom2_F2/F"); - myTree_->Branch("mom3_F2", &mom3_F2, "mom3_F2/F"); - myTree_->Branch("mom4_F2", &mom4_F2, "mom4_F2/F"); - myTree_->Branch("trigbit", &trigbit, "trigbit/I"); + myTree_ = fs_->make("RecJet", "RecJet Tree"); + myTree_->Branch("cells", &cells, "cells/I"); + myTree_->Branch("mysubd", &mysubd, "mysubd/I"); + myTree_->Branch("depth", &depth, "depth/I"); + myTree_->Branch("ieta", &ieta, "ieta/I"); + myTree_->Branch("iphi", &iphi, "iphi/I"); + myTree_->Branch("mom0_F1", &mom0_F1, "mom0_F1/F"); + myTree_->Branch("mom1_F1", &mom1_F1, "mom1_F1/F"); + myTree_->Branch("mom2_F1", &mom2_F1, "mom2_F1/F"); + myTree_->Branch("mom3_F1", &mom3_F1, "mom3_F1/F"); + myTree_->Branch("mom4_F1", &mom4_F1, "mom4_F1/F"); + myTree_->Branch("mom0_F2", &mom0_F2, "mom0_F2/F"); + myTree_->Branch("mom1_F2", &mom1_F2, "mom1_F2/F"); + myTree_->Branch("mom2_F2", &mom2_F2, "mom2_F2/F"); + myTree_->Branch("mom3_F2", &mom3_F2, "mom3_F2/F"); + myTree_->Branch("mom4_F2", &mom4_F2, "mom4_F2/F"); + myTree_->Branch("trigbit", &trigbit, "trigbit/I"); myTree_->Branch("rnnumber", &rnnumber, "rnnumber/D"); } @@ -191,44 +188,39 @@ void RecAnalyzerHF::beginJob() { } void RecAnalyzerHF::endJob() { - if (fillTree_) { cells = 0; - for (const auto & itr : myMap_) { - edm::LogVerbatim("RecAnalyzer") << "Fired trigger bit number " - << itr.first.first; + for (const auto& itr : myMap_) { + edm::LogVerbatim("RecAnalyzer") << "Fired trigger bit number " << itr.first.first; myInfo info = itr.second; - if (info.kount > 0) { - mom0_F1 = info.kount; - mom1_F1 = info.f11; - mom2_F1 = info.f12; - mom3_F1 = info.f13; - mom4_F1 = info.f14; - mom0_F2 = info.kount; - mom1_F2 = info.f21; - mom2_F2 = info.f22; - mom3_F2 = info.f23; - mom4_F2 = info.f24; - rnnumber = info.runcheck; - trigbit = itr.first.first; - mysubd = itr.first.second.subdet(); - depth = itr.first.second.depth(); - iphi = itr.first.second.iphi(); - ieta = itr.first.second.ieta(); - edm::LogVerbatim("RecAnalyzer") << " Result= " << trigbit << " " - << mysubd << " " << ieta << " " << iphi - << " F1:mom0 " << mom0_F1 << " mom1 " - << mom1_F1 << " mom2 " << mom2_F1 - << " mom3 " << mom3_F1 << " mom4 " - << mom4_F1 << " F2:mom0 " << mom0_F2 - << " mom1 " << mom1_F2 << " mom2 " - << mom2_F2 << " mom3 " << mom3_F2 - << " mom4 " << mom4_F2; - myTree_->Fill(); - cells++; + if (info.kount > 0) { + mom0_F1 = info.kount; + mom1_F1 = info.f11; + mom2_F1 = info.f12; + mom3_F1 = info.f13; + mom4_F1 = info.f14; + mom0_F2 = info.kount; + mom1_F2 = info.f21; + mom2_F2 = info.f22; + mom3_F2 = info.f23; + mom4_F2 = info.f24; + rnnumber = info.runcheck; + trigbit = itr.first.first; + mysubd = itr.first.second.subdet(); + depth = itr.first.second.depth(); + iphi = itr.first.second.iphi(); + ieta = itr.first.second.ieta(); + edm::LogVerbatim("RecAnalyzer") << " Result= " << trigbit << " " << mysubd << " " << ieta << " " << iphi + << " F1:mom0 " << mom0_F1 << " mom1 " << mom1_F1 << " mom2 " << mom2_F1 + << " mom3 " << mom3_F1 << " mom4 " << mom4_F1 << " F2:mom0 " << mom0_F2 + << " mom1 " << mom1_F2 << " mom2 " << mom2_F2 << " mom3 " << mom3_F2 << " mom4 " + << mom4_F2; + myTree_->Fill(); + cells++; } } - edm::LogVerbatim("RecAnalyzer") << "cells" << " " << cells; + edm::LogVerbatim("RecAnalyzer") << "cells" + << " " << cells; } #ifdef EDM_ML_DEBUG edm::LogVerbatim("RecAnalyzer") << "Exiting from RecAnalyzerHF::endjob"; @@ -239,11 +231,10 @@ void RecAnalyzerHF::endJob() { // member functions // // ------------ method called to produce the data ------------ - + void RecAnalyzerHF::analyze(const edm::Event& iEvent, const edm::EventSetup&) { + rnnum_ = (double)iEvent.run(); - rnnum_ = (double)iEvent.run(); - edm::Handle hf; iEvent.getByToken(tok_hfreco_, hf); if (!hf.isValid()) { @@ -251,11 +242,9 @@ void RecAnalyzerHF::analyze(const edm::Event& iEvent, const edm::EventSetup&) { return; } const HFPreRecHitCollection Hithf = *(hf.product()); - edm::LogVerbatim("RecAnalyzer") << "HF MB size of collection " - << Hithf.size(); + edm::LogVerbatim("RecAnalyzer") << "HF MB size of collection " << Hithf.size(); if (Hithf.size() < 1700 && nzs_) { - edm::LogWarning("RecAnalyzer") << "HF problem " << rnnum_ << " size " - << Hithf.size(); + edm::LogWarning("RecAnalyzer") << "HF problem " << rnnum_ << " size " << Hithf.size(); } bool select(false); @@ -264,13 +253,12 @@ void RecAnalyzerHF::analyze(const edm::Event& iEvent, const edm::EventSetup&) { iEvent.getByToken(tok_hltL1GtMap_, gtObjectMapRecord); if (gtObjectMapRecord.isValid()) { const std::vector& objMapVec = gtObjectMapRecord->gtObjectMap(); - for (std::vector::const_iterator itMap = objMapVec.begin(); - itMap != objMapVec.end(); ++itMap) { + for (std::vector::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end(); + ++itMap) { bool resultGt = (*itMap).algoGtlResult(); if (resultGt) { int algoBit = (*itMap).algoBitNumber(); - if (std::find(trigbit_.begin(),trigbit_.end(),algoBit) != - trigbit_.end()) { + if (std::find(trigbit_.begin(), trigbit_.end(), algoBit) != trigbit_.end()) { select = true; break; } @@ -289,52 +277,50 @@ void RecAnalyzerHF::analyze(const edm::Event& iEvent, const edm::EventSetup&) { if (gtObjectMapRecord.isValid()) { const std::vector& objMapVec = gtObjectMapRecord->gtObjectMap(); bool ok(false); - for (std::vector::const_iterator itMap = objMapVec.begin(); - itMap != objMapVec.end(); ++itMap) { - bool resultGt = (*itMap).algoGtlResult(); - if (resultGt) { - int algoBit = (*itMap).algoBitNumber(); - analyzeHcal(Hithf, algoBit, (!ok)); - ok = true; - } + for (std::vector::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end(); + ++itMap) { + bool resultGt = (*itMap).algoGtlResult(); + if (resultGt) { + int algoBit = (*itMap).algoBitNumber(); + analyzeHcal(Hithf, algoBit, (!ok)); + ok = true; + } } if (!ok) { - edm::LogVerbatim("RecAnalyzer") << "No passed L1 Trigger found"; + edm::LogVerbatim("RecAnalyzer") << "No passed L1 Trigger found"; } } } } -void RecAnalyzerHF::analyzeHcal(const HFPreRecHitCollection & Hithf, - int algoBit, bool fill) { -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("RecAnalyzer") << "Enter analyzeHcal for bit " << algoBit - << " Fill " << fill << " Collection size " - << Hithf.size(); +void RecAnalyzerHF::analyzeHcal(const HFPreRecHitCollection& Hithf, int algoBit, bool fill) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("RecAnalyzer") << "Enter analyzeHcal for bit " << algoBit << " Fill " << fill << " Collection size " + << Hithf.size(); #endif // Signal part for HF - for (const auto & hfItr : Hithf) { - HcalDetId hid = hfItr.id(); - double e0 = (hfItr.getHFQIE10Info(0)==nullptr) ? 0 : hfItr.getHFQIE10Info(0)->energy(); - double e1 = (hfItr.getHFQIE10Info(1)==nullptr) ? 0 : hfItr.getHFQIE10Info(1)->energy(); - double energy = e0+e1; - if (std::abs(energy) < 1e-6) energy = (energy > 0) ? 1e-6 : -1e-6; + for (const auto& hfItr : Hithf) { + HcalDetId hid = hfItr.id(); + double e0 = (hfItr.getHFQIE10Info(0) == nullptr) ? 0 : hfItr.getHFQIE10Info(0)->energy(); + double e1 = (hfItr.getHFQIE10Info(1) == nullptr) ? 0 : hfItr.getHFQIE10Info(1)->energy(); + double energy = e0 + e1; + if (std::abs(energy) < 1e-6) + energy = (energy > 0) ? 1e-6 : -1e-6; double f1(e0), f2(e1); if (ratio_) { - f1 /= energy; - f2 /= energy; + f1 /= energy; + f2 /= energy; } -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("RecAnalyzer") << hid << " E " << e0 << ":" << e1 - << " F " << f1 << ":" << f2; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("RecAnalyzer") << hid << " E " << e0 << ":" << e1 << " F " << f1 << ":" << f2; #endif if (fill) { for (unsigned int i = 0; i < hcalID_.size(); i++) { - if (hcalID_[i] == hid.rawId()) { - histo_[i].first->Fill(f1); - histo_[i].second->Fill(f2); - break; - } + if (hcalID_[i] == hid.rawId()) { + histo_[i].first->Fill(f1); + histo_[i].second->Fill(f2); + break; + } } hist_[0]->Fill(f1); hist_[1]->Fill(f2); @@ -343,28 +329,27 @@ void RecAnalyzerHF::analyzeHcal(const HFPreRecHitCollection & Hithf, // // Remove PMT hits // - if (((noise_ || nzs_) && fabs(energy) <= 40.) || - (energy >= eLowHF_ && energy <= eHighHF_)) { - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); + if (((noise_ || nzs_) && fabs(energy) <= 40.) || (energy >= eLowHF_ && energy <= eHighHF_)) { + std::map, myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit, hid)); if (itr1 == myMap_.end()) { - myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); + myInfo info; + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); } - itr1->second.kount += 1.0; - itr1->second.f11 += (f1); - itr1->second.f12 += (f1*f1); - itr1->second.f13 += (f1*f1*f1); - itr1->second.f14 += (f1*f1*f1*f1); - itr1->second.f21 += (f2); - itr1->second.f22 += (f2*f2); - itr1->second.f23 += (f2*f2*f2); - itr1->second.f24 += (f2*f2*f2*f2); + itr1->second.kount += 1.0; + itr1->second.f11 += (f1); + itr1->second.f12 += (f1 * f1); + itr1->second.f13 += (f1 * f1 * f1); + itr1->second.f14 += (f1 * f1 * f1 * f1); + itr1->second.f21 += (f2); + itr1->second.f22 += (f2 * f2); + itr1->second.f23 += (f2 * f2 * f2); + itr1->second.f24 += (f2 * f2 * f2 * f2); itr1->second.runcheck = rnnum_; } } } -//define this as a plug-in +//define this as a plug-in #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecAnalyzerHF); diff --git a/Calibration/HcalCalibAlgos/plugins/RecAnalyzerMinbias.cc b/Calibration/HcalCalibAlgos/plugins/RecAnalyzerMinbias.cc index 2ad54b7d5b69e..15cc3a52e96fa 100644 --- a/Calibration/HcalCalibAlgos/plugins/RecAnalyzerMinbias.cc +++ b/Calibration/HcalCalibAlgos/plugins/RecAnalyzerMinbias.cc @@ -2,7 +2,7 @@ // // Package: HcalCalibAlgos // Class: RecAnalyzerMinbias -// +// /**\class RecAnalyzerMinbias RecAnalyzerMinbias.cc Calibration/HcalCalibAlgos/test/RecAnalyzerMinbias.cc Description: Performs phi-symmetry studies of HB/HE/HF channels @@ -65,8 +65,7 @@ //#define EDM_ML_DEBUG // class declaration -class RecAnalyzerMinbias : public edm::one::EDAnalyzer { - +class RecAnalyzerMinbias : public edm::one::EDAnalyzer { public: explicit RecAnalyzerMinbias(const edm::ParameterSet&); ~RecAnalyzerMinbias() override; @@ -79,349 +78,338 @@ class RecAnalyzerMinbias : public edm::one::EDAnalyzer fs_; - bool theRecalib_, ignoreL1_, runNZS_, Noise_; - bool fillHist_, extraHist_, init_; - double eLowHB_, eHighHB_, eLowHE_, eHighHE_; - double eLowHF_, eHighHF_, eMin_; - int runMin_, runMax_; - std::map corrFactor_; - std::vector hcalID_; - TTree *myTree_, *myTree1_; - TH1D *h_[4]; - TH2D *hbhe_, *hb_, *he_, *hf_; - TH1D *h_AmplitudeHBtest_, *h_AmplitudeHEtest_; - TH1D *h_AmplitudeHFtest_; - TH1D *h_AmplitudeHB_, *h_AmplitudeHE_, *h_AmplitudeHF_; - TProfile *hbherun_, *hbrun_, *herun_, *hfrun_; - std::vector histo_; - std::map histHC_; - std::vector trigbit_; - double rnnum_; - struct myInfo{ + bool theRecalib_, ignoreL1_, runNZS_, Noise_; + bool fillHist_, extraHist_, init_; + double eLowHB_, eHighHB_, eLowHE_, eHighHE_; + double eLowHF_, eHighHF_, eMin_; + int runMin_, runMax_; + std::map corrFactor_; + std::vector hcalID_; + TTree *myTree_, *myTree1_; + TH1D* h_[4]; + TH2D *hbhe_, *hb_, *he_, *hf_; + TH1D *h_AmplitudeHBtest_, *h_AmplitudeHEtest_; + TH1D* h_AmplitudeHFtest_; + TH1D *h_AmplitudeHB_, *h_AmplitudeHE_, *h_AmplitudeHF_; + TProfile *hbherun_, *hbrun_, *herun_, *hfrun_; + std::vector histo_; + std::map histHC_; + std::vector trigbit_; + double rnnum_; + struct myInfo { double theMB0, theMB1, theMB2, theMB3, theMB4, runcheck; - myInfo() { - theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = runcheck = 0; - } + myInfo() { theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = runcheck = 0; } }; // Root tree members - double rnnumber; - int mysubd, depth, iphi, ieta, cells, trigbit; - float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB; - int HBHEsize, HFsize; - std::map,myInfo> myMap_; - edm::EDGetTokenT tok_hbherecoMB_; - edm::EDGetTokenT tok_hfrecoMB_; + double rnnumber; + int mysubd, depth, iphi, ieta, cells, trigbit; + float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB; + int HBHEsize, HFsize; + std::map, myInfo> myMap_; + edm::EDGetTokenT tok_hbherecoMB_; + edm::EDGetTokenT tok_hfrecoMB_; edm::EDGetTokenT tok_hltL1GtMap_; - edm::EDGetTokenT tok_ew_; - edm::EDGetTokenT tok_hbhedigi_; - edm::EDGetTokenT tok_qie11digi_; - edm::EDGetTokenT tok_hodigi_; - edm::EDGetTokenT tok_hfdigi_; - edm::EDGetTokenT tok_qie10digi_; - edm::EDGetTokenT tok_gtRec_; + edm::EDGetTokenT tok_ew_; + edm::EDGetTokenT tok_hbhedigi_; + edm::EDGetTokenT tok_qie11digi_; + edm::EDGetTokenT tok_hodigi_; + edm::EDGetTokenT tok_hfdigi_; + edm::EDGetTokenT tok_qie10digi_; + edm::EDGetTokenT tok_gtRec_; }; // constructors and destructor -RecAnalyzerMinbias::RecAnalyzerMinbias(const edm::ParameterSet& iConfig) : - init_(false) { - +RecAnalyzerMinbias::RecAnalyzerMinbias(const edm::ParameterSet& iConfig) : init_(false) { usesResource("TFileService"); // get name of output file with histogramms - runNZS_ = iConfig.getParameter("runNZS"); - Noise_ = iConfig.getParameter("noise"); - eLowHB_ = iConfig.getParameter("eLowHB"); - eHighHB_ = iConfig.getParameter("eHighHB"); - eLowHE_ = iConfig.getParameter("eLowHE"); - eHighHE_ = iConfig.getParameter("eHighHE"); - eLowHF_ = iConfig.getParameter("eLowHF"); - eHighHF_ = iConfig.getParameter("eHighHF"); - eMin_ = iConfig.getUntrackedParameter("eMin",2.0); + runNZS_ = iConfig.getParameter("runNZS"); + Noise_ = iConfig.getParameter("noise"); + eLowHB_ = iConfig.getParameter("eLowHB"); + eHighHB_ = iConfig.getParameter("eHighHB"); + eLowHE_ = iConfig.getParameter("eLowHE"); + eHighHE_ = iConfig.getParameter("eHighHE"); + eLowHF_ = iConfig.getParameter("eLowHF"); + eHighHF_ = iConfig.getParameter("eHighHF"); + eMin_ = iConfig.getUntrackedParameter("eMin", 2.0); // The following run range is suited to study 2017 commissioning period - runMin_ = iConfig.getUntrackedParameter("RunMin",308327); - runMax_ = iConfig.getUntrackedParameter("RunMax",315250); - trigbit_ = iConfig.getUntrackedParameter>("triggerBits"); - ignoreL1_ = iConfig.getUntrackedParameter("ignoreL1",false); - std::string cfile= iConfig.getUntrackedParameter("corrFile"); - fillHist_ = iConfig.getUntrackedParameter("fillHisto",false); - extraHist_ = iConfig.getUntrackedParameter("extraHisto",false); + runMin_ = iConfig.getUntrackedParameter("RunMin", 308327); + runMax_ = iConfig.getUntrackedParameter("RunMax", 315250); + trigbit_ = iConfig.getUntrackedParameter>("triggerBits"); + ignoreL1_ = iConfig.getUntrackedParameter("ignoreL1", false); + std::string cfile = iConfig.getUntrackedParameter("corrFile"); + fillHist_ = iConfig.getUntrackedParameter("fillHisto", false); + extraHist_ = iConfig.getUntrackedParameter("extraHisto", false); std::vector ieta = iConfig.getUntrackedParameter>("hcalIeta"); std::vector iphi = iConfig.getUntrackedParameter>("hcalIphi"); - std::vector depth= iConfig.getUntrackedParameter>("hcalDepth"); + std::vector depth = iConfig.getUntrackedParameter>("hcalDepth"); // get token names of modules, producing object collections - tok_hbherecoMB_ = consumes(iConfig.getParameter("hbheInputMB")); - tok_hfrecoMB_ = consumes(iConfig.getParameter("hfInputMB")); - tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); - tok_ew_ = consumes(edm::InputTag("generator")); - tok_hbhedigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); - tok_qie11digi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); - tok_hodigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); - tok_hfdigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); - tok_qie10digi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); - tok_gtRec_ = consumes(edm::InputTag("gtDigisAlCaMB")); + tok_hbherecoMB_ = consumes(iConfig.getParameter("hbheInputMB")); + tok_hfrecoMB_ = consumes(iConfig.getParameter("hfInputMB")); + tok_hltL1GtMap_ = consumes(edm::InputTag("hltL1GtObjectMap")); + tok_ew_ = consumes(edm::InputTag("generator")); + tok_hbhedigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); + tok_qie11digi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); + tok_hodigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); + tok_hfdigi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); + tok_qie10digi_ = consumes(iConfig.getParameter("hcalDigiCollectionTag")); + tok_gtRec_ = consumes(edm::InputTag("gtDigisAlCaMB")); // Read correction factors std::ifstream infile(cfile.c_str()); if (!infile.is_open()) { theRecalib_ = false; - edm::LogWarning("RecAnalyzer") << "Cannot open '" << cfile - << "' for the correction file"; + edm::LogWarning("RecAnalyzer") << "Cannot open '" << cfile << "' for the correction file"; } else { unsigned int ndets(0), nrec(0); while (true) { unsigned int id; - double cfac; + double cfac; infile >> id >> cfac; - if (!infile.good()) break; + if (!infile.good()) + break; HcalDetId detId(id); nrec++; - std::map::iterator itr = corrFactor_.find(detId); + std::map::iterator itr = corrFactor_.find(detId); if (itr == corrFactor_.end()) { - corrFactor_[detId] = cfac; - ndets++; + corrFactor_[detId] = cfac; + ndets++; } } infile.close(); - edm::LogInfo("RecAnalyzer") << "Reads " << nrec - << " correction factors for " << ndets - << " detIds"; - theRecalib_ = (ndets>0); + edm::LogInfo("RecAnalyzer") << "Reads " << nrec << " correction factors for " << ndets << " detIds"; + theRecalib_ = (ndets > 0); } - edm::LogInfo("RecAnalyzer") << " Flags (ReCalib): " << theRecalib_ - << " (IgnoreL1): " << ignoreL1_ << " (NZS) " - << runNZS_ << " and with " << ieta.size() - << " detId for full histogram"; - edm::LogInfo("RecAnalyzer") << "Thresholds for HB " << eLowHB_ << ":" - << eHighHB_ << " for HE " << eLowHE_ << ":" - << eHighHE_ << " for HF " << eLowHF_ << ":" - << eHighHF_; - for (unsigned int k=0; k 29) ? HcalForward : - (std::abs(ieta[k]) > 16) ? HcalEndcap : - ((std::abs(ieta[k]) == 16) && (depth[k] == 3)) ? HcalEndcap : - (depth[k] == 4) ? HcalOuter : HcalBarrel); - unsigned int id = (HcalDetId(subd,ieta[k],iphi[k],depth[k])).rawId(); + edm::LogInfo("RecAnalyzer") << " Flags (ReCalib): " << theRecalib_ << " (IgnoreL1): " << ignoreL1_ << " (NZS) " + << runNZS_ << " and with " << ieta.size() << " detId for full histogram"; + edm::LogInfo("RecAnalyzer") << "Thresholds for HB " << eLowHB_ << ":" << eHighHB_ << " for HE " << eLowHE_ << ":" + << eHighHE_ << " for HF " << eLowHF_ << ":" << eHighHF_; + for (unsigned int k = 0; k < ieta.size(); ++k) { + HcalSubdetector subd = + ((std::abs(ieta[k]) > 29) ? HcalForward + : (std::abs(ieta[k]) > 16) ? HcalEndcap + : ((std::abs(ieta[k]) == 16) && (depth[k] == 3)) + ? HcalEndcap + : (depth[k] == 4) ? HcalOuter : HcalBarrel); + unsigned int id = (HcalDetId(subd, ieta[k], iphi[k], depth[k])).rawId(); hcalID_.push_back(id); edm::LogInfo("RecAnalyzer") << "DetId[" << k << "] " << HcalDetId(id); } - edm::LogInfo("RecAnalyzer") << "Select on " << trigbit_.size() - << " L1 Trigger selection"; - for (unsigned int k=0; k iarray; edm::ParameterSetDescription desc; - desc.add("runNZS", true); - desc.add("noise", false); - desc.add("eLowHB", 4); + desc.add("runNZS", true); + desc.add("noise", false); + desc.add("eLowHB", 4); desc.add("eHighHB", 100); - desc.add("eLowHE", 4); + desc.add("eLowHE", 4); desc.add("eHighHE", 150); - desc.add("eLowHF", 10); + desc.add("eLowHF", 10); desc.add("eHighHF", 150); // Suitable cutoff to remove fluctuation of pedestal - desc.addUntracked("eMin",2.0); + desc.addUntracked("eMin", 2.0); // The following run range is suited to study 2017 commissioning period - desc.addUntracked("runMin",308327); - desc.addUntracked("runMax",308347); - desc.addUntracked >("triggerBits", iarray); - desc.addUntracked("ignoreL1", false); + desc.addUntracked("runMin", 308327); + desc.addUntracked("runMax", 308347); + desc.addUntracked>("triggerBits", iarray); + desc.addUntracked("ignoreL1", false); desc.addUntracked("corrFile", "CorFactor.txt"); desc.addUntracked("fillHisto", false); desc.addUntracked("extraHisto", false); - desc.addUntracked >("hcalIeta", iarray); - desc.addUntracked >("hcalIphi", iarray); - desc.addUntracked >("hcalDepth", iarray); + desc.addUntracked>("hcalIeta", iarray); + desc.addUntracked>("hcalIphi", iarray); + desc.addUntracked>("hcalDepth", iarray); desc.add("hbheInputMB", edm::InputTag("hbherecoMB")); - desc.add("hfInputMB", edm::InputTag("hfrecoMB")); + desc.add("hfInputMB", edm::InputTag("hfrecoMB")); desc.add("gtDigisAlCaMB", edm::InputTag("gtDigisAlCaMB")); desc.add("hcalDigiCollectionTag", edm::InputTag("hcalDigis")); - descriptions.add("recAnalyzerMinbias",desc); + descriptions.add("recAnalyzerMinbias", desc); } - void RecAnalyzerMinbias::beginJob() { - - std::string hc[5] = {"Empty", "HB", "HE", "HO", "HF"}; - char name[700], title[700]; - hbhe_ = fs_->make("hbhe","Noise in HB/HE",61,-30.5,30.5,72,0.5,72.5); - hb_ = fs_->make("hb", "Noise in HB",61,-16.5,16.5,72,0.5,72.5); - he_ = fs_->make("he", "Noise in HE",61,-30.5,30.5,72,0.5,72.5); - hf_ = fs_->make("hf", "Noise in HF",82,-41.5,41.5,72,0.5,72.5); - int nbin = (runMax_-runMin_+1); - sprintf (title, "Fraction of channels in HB/HE with E > %4.1f GeV vs Run number", eMin_); - hbherun_ = fs_->make("hbherun",title,nbin,runMin_-0.5,runMax_+0.5,0.0,1.0); - sprintf (title, "Fraction of channels in HB with E > %4.1f GeV vs Run number", eMin_); - hbrun_ = fs_->make("hbrun",title,nbin,runMin_-0.5,runMax_+0.5,0.0,1.0); - sprintf (title, "Fraction of channels in HE with E > %4.1f GeV vs Run number", eMin_); - herun_ = fs_->make("herun",title,nbin,runMin_-0.5,runMax_+0.5,0.0,1.0); - sprintf (title, "Fraction of channels in HF with E > %4.1f GeV vs Run number", eMin_); - hfrun_ = fs_->make("hfrun",title,nbin,runMin_-0.5,runMax_+0.5,0.0,1.0); - for(int idet=1; idet<=4; idet++){ - sprintf(name, "%s", hc[idet].c_str()); - sprintf (title, "Noise distribution for %s", hc[idet].c_str()); - h_[idet-1] = fs_->make(name,title,48,-6., 6.); - } - - for (const auto & hcalid : hcalID_) { - HcalDetId id = HcalDetId(hcalid); - int subdet = id.subdetId(); - sprintf (name, "%s%d_%d_%d", hc[subdet].c_str(), id.ieta(), id.iphi(), id.depth()); - sprintf (title, "Energy Distribution for %s ieta %d iphi %d depth %d", hc[subdet].c_str(), id.ieta(), id.iphi(), id.depth()); - double xmin = (subdet == 4) ? -10 : -1; - double xmax = (subdet == 4) ? 90 : 9; - TH1D* hh = fs_->make(name, title, 50, xmin, xmax); - histo_.push_back(hh); - }; - - if (extraHist_) { - h_AmplitudeHBtest_ = fs_->make("h_AmplitudeHBtest","",5000,0.,5000.); - h_AmplitudeHEtest_ = fs_->make("h_AmplitudeHEtest","",3000,0.,3000.); - h_AmplitudeHFtest_ = fs_->make("h_AmplitudeHFtest","",10000,0.,10000.); - h_AmplitudeHB_ = fs_->make("h_AmplitudeHB", "", 100000,0.,100000.); - h_AmplitudeHE_ = fs_->make("h_AmplitudeHE", "", 300000,0.,300000.); - h_AmplitudeHF_ = fs_->make("h_AmplitudeHF", "", 100000,0.,1000000.); - } - - if (!fillHist_) { - myTree_ = fs_->make("RecJet","RecJet Tree"); - myTree_->Branch("cells", &cells, "cells/I"); - myTree_->Branch("mysubd", &mysubd, "mysubd/I"); - myTree_->Branch("depth", &depth, "depth/I"); - myTree_->Branch("ieta", &ieta, "ieta/I"); - myTree_->Branch("iphi", &iphi, "iphi/I"); - myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); - myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); - myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); - myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); - myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); - myTree_->Branch("trigbit", &trigbit, "trigbit/I"); - myTree_->Branch("rnnumber", &rnnumber, "rnnumber/D"); - } - myTree1_ = fs_->make("RecJet1","RecJet1 Tree"); - myTree1_->Branch("rnnum_", &rnnum_, "rnnum_/D"); - myTree1_->Branch("HBHEsize", &HBHEsize, "HBHEsize/I"); - myTree1_->Branch("HFsize", &HFsize, "HFsize/I"); - - myMap_.clear(); - } +void RecAnalyzerMinbias::beginJob() { + std::string hc[5] = {"Empty", "HB", "HE", "HO", "HF"}; + char name[700], title[700]; + hbhe_ = fs_->make("hbhe", "Noise in HB/HE", 61, -30.5, 30.5, 72, 0.5, 72.5); + hb_ = fs_->make("hb", "Noise in HB", 61, -16.5, 16.5, 72, 0.5, 72.5); + he_ = fs_->make("he", "Noise in HE", 61, -30.5, 30.5, 72, 0.5, 72.5); + hf_ = fs_->make("hf", "Noise in HF", 82, -41.5, 41.5, 72, 0.5, 72.5); + int nbin = (runMax_ - runMin_ + 1); + sprintf(title, "Fraction of channels in HB/HE with E > %4.1f GeV vs Run number", eMin_); + hbherun_ = fs_->make("hbherun", title, nbin, runMin_ - 0.5, runMax_ + 0.5, 0.0, 1.0); + sprintf(title, "Fraction of channels in HB with E > %4.1f GeV vs Run number", eMin_); + hbrun_ = fs_->make("hbrun", title, nbin, runMin_ - 0.5, runMax_ + 0.5, 0.0, 1.0); + sprintf(title, "Fraction of channels in HE with E > %4.1f GeV vs Run number", eMin_); + herun_ = fs_->make("herun", title, nbin, runMin_ - 0.5, runMax_ + 0.5, 0.0, 1.0); + sprintf(title, "Fraction of channels in HF with E > %4.1f GeV vs Run number", eMin_); + hfrun_ = fs_->make("hfrun", title, nbin, runMin_ - 0.5, runMax_ + 0.5, 0.0, 1.0); + for (int idet = 1; idet <= 4; idet++) { + sprintf(name, "%s", hc[idet].c_str()); + sprintf(title, "Noise distribution for %s", hc[idet].c_str()); + h_[idet - 1] = fs_->make(name, title, 48, -6., 6.); + } + + for (const auto& hcalid : hcalID_) { + HcalDetId id = HcalDetId(hcalid); + int subdet = id.subdetId(); + sprintf(name, "%s%d_%d_%d", hc[subdet].c_str(), id.ieta(), id.iphi(), id.depth()); + sprintf(title, + "Energy Distribution for %s ieta %d iphi %d depth %d", + hc[subdet].c_str(), + id.ieta(), + id.iphi(), + id.depth()); + double xmin = (subdet == 4) ? -10 : -1; + double xmax = (subdet == 4) ? 90 : 9; + TH1D* hh = fs_->make(name, title, 50, xmin, xmax); + histo_.push_back(hh); + }; + + if (extraHist_) { + h_AmplitudeHBtest_ = fs_->make("h_AmplitudeHBtest", "", 5000, 0., 5000.); + h_AmplitudeHEtest_ = fs_->make("h_AmplitudeHEtest", "", 3000, 0., 3000.); + h_AmplitudeHFtest_ = fs_->make("h_AmplitudeHFtest", "", 10000, 0., 10000.); + h_AmplitudeHB_ = fs_->make("h_AmplitudeHB", "", 100000, 0., 100000.); + h_AmplitudeHE_ = fs_->make("h_AmplitudeHE", "", 300000, 0., 300000.); + h_AmplitudeHF_ = fs_->make("h_AmplitudeHF", "", 100000, 0., 1000000.); + } + + if (!fillHist_) { + myTree_ = fs_->make("RecJet", "RecJet Tree"); + myTree_->Branch("cells", &cells, "cells/I"); + myTree_->Branch("mysubd", &mysubd, "mysubd/I"); + myTree_->Branch("depth", &depth, "depth/I"); + myTree_->Branch("ieta", &ieta, "ieta/I"); + myTree_->Branch("iphi", &iphi, "iphi/I"); + myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); + myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); + myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); + myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); + myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); + myTree_->Branch("trigbit", &trigbit, "trigbit/I"); + myTree_->Branch("rnnumber", &rnnumber, "rnnumber/D"); + } + myTree1_ = fs_->make("RecJet1", "RecJet1 Tree"); + myTree1_->Branch("rnnum_", &rnnum_, "rnnum_/D"); + myTree1_->Branch("HBHEsize", &HBHEsize, "HBHEsize/I"); + myTree1_->Branch("HFsize", &HFsize, "HFsize/I"); + + myMap_.clear(); +} // EndJob // void RecAnalyzerMinbias::endJob() { - if (!fillHist_) { cells = 0; for (const auto& itr : myMap_) { - edm::LogVerbatim("RecAnalyzer") << "Fired trigger bit number " - << itr.first.first; + edm::LogVerbatim("RecAnalyzer") << "Fired trigger bit number " << itr.first.first; myInfo info = itr.second; - if (info.theMB0 > 0) { - mom0_MB = info.theMB0; - mom1_MB = info.theMB1; - mom2_MB = info.theMB2; - mom3_MB = info.theMB3; - mom4_MB = info.theMB4; - rnnumber = info.runcheck; - trigbit = itr.first.first; - mysubd = itr.first.second.subdet(); - depth = itr.first.second.depth(); - iphi = itr.first.second.iphi(); - ieta = itr.first.second.ieta(); - edm::LogVerbatim("RecAnalyzer") << " Result= " << trigbit << " " - << mysubd << " " << ieta << " " << iphi - << " mom0 " << mom0_MB << " mom1 " - << mom1_MB << " mom2 " << mom2_MB - << " mom3 " << mom3_MB << " mom4 " - << mom4_MB; - myTree_->Fill(); - cells++; + if (info.theMB0 > 0) { + mom0_MB = info.theMB0; + mom1_MB = info.theMB1; + mom2_MB = info.theMB2; + mom3_MB = info.theMB3; + mom4_MB = info.theMB4; + rnnumber = info.runcheck; + trigbit = itr.first.first; + mysubd = itr.first.second.subdet(); + depth = itr.first.second.depth(); + iphi = itr.first.second.iphi(); + ieta = itr.first.second.ieta(); + edm::LogVerbatim("RecAnalyzer") << " Result= " << trigbit << " " << mysubd << " " << ieta << " " << iphi + << " mom0 " << mom0_MB << " mom1 " << mom1_MB << " mom2 " << mom2_MB + << " mom3 " << mom3_MB << " mom4 " << mom4_MB; + myTree_->Fill(); + cells++; } } - edm::LogVerbatim("RecAnalyzer") << "cells" << " " << cells; + edm::LogVerbatim("RecAnalyzer") << "cells" + << " " << cells; } #ifdef EDM_ML_DEBUG edm::LogVerbatim("RecAnalyzer") << "Exiting from RecAnalyzerMinbias::endjob"; #endif } - + void RecAnalyzerMinbias::beginRun(edm::Run const&, edm::EventSetup const& iS) { - if (!init_) { init_ = true; if (fillHist_) { edm::ESHandle htopo; iS.get().get(htopo); if (htopo.isValid()) { - const HcalTopology* hcaltopology = htopo.product(); - - char name[700], title[700]; - // For HB - int maxDepthHB = hcaltopology->maxDepthHB(); - int nbinHB = (Noise_) ? 18 : int(2000*eHighHB_); - double x_min = (Noise_) ? -3. : 0.; - double x_max = (Noise_) ? 3. : 2.*eHighHB_; - for (int eta = -50; eta < 50; eta++) { - for (int phi = 0; phi < 100; phi++) { - for (int depth = 1; depth <= maxDepthHB; depth++) { - HcalDetId cell (HcalBarrel, eta, phi, depth); - if (hcaltopology->valid(cell)) { - sprintf (name, "HBeta%dphi%ddep%d", eta, phi, depth); - sprintf (title,"HB #eta %d #phi %d depth %d", eta, phi, depth); - TH1D* h = fs_->make(name, title, nbinHB, x_min, x_max); - histHC_[cell] = h; - } - } - } - } - // For HE - int maxDepthHE = hcaltopology->maxDepthHE(); - int nbinHE = (Noise_) ? 18 : int(2000*eHighHE_); - x_min = (Noise_) ? -3. : 0.; - x_max = (Noise_) ? 3. : 2.*eHighHE_; - for (int eta = -50; eta < 50; eta++) { - for (int phi = 0; phi < 100; phi++) { - for (int depth = 1; depth <= maxDepthHE; depth++) { - HcalDetId cell (HcalEndcap, eta, phi, depth); - if (hcaltopology->valid(cell)) { - sprintf (name, "HEeta%dphi%ddep%d", eta, phi, depth); - sprintf (title,"HE #eta %d #phi %d depth %d", eta, phi, depth); - TH1D* h = fs_->make(name, title, nbinHE, x_min, x_max); - histHC_[cell] = h; - } - } - } - } - // For HF - int maxDepthHF = 4; - int nbinHF = (Noise_) ? 200 : int(2000*eHighHF_); - x_min = (Noise_) ? -10. : 0.; - x_max = (Noise_) ? 10. : 2.*eHighHF_; - for (int eta = -50; eta < 50; eta++) { - for (int phi = 0; phi < 100; phi++) { - for (int depth = 1; depth <= maxDepthHF; depth++) { - HcalDetId cell (HcalForward, eta, phi, depth); - if (hcaltopology->valid(cell)) { - sprintf (name, "HFeta%dphi%ddep%d", eta, phi, depth); - sprintf (title,"Energy (HF #eta %d #phi %d depth %d)", eta, phi, depth); - TH1D* h = fs_->make(name, title, nbinHF, x_min, x_max); - histHC_[cell] = h; - } - } - } - } + const HcalTopology* hcaltopology = htopo.product(); + + char name[700], title[700]; + // For HB + int maxDepthHB = hcaltopology->maxDepthHB(); + int nbinHB = (Noise_) ? 18 : int(2000 * eHighHB_); + double x_min = (Noise_) ? -3. : 0.; + double x_max = (Noise_) ? 3. : 2. * eHighHB_; + for (int eta = -50; eta < 50; eta++) { + for (int phi = 0; phi < 100; phi++) { + for (int depth = 1; depth <= maxDepthHB; depth++) { + HcalDetId cell(HcalBarrel, eta, phi, depth); + if (hcaltopology->valid(cell)) { + sprintf(name, "HBeta%dphi%ddep%d", eta, phi, depth); + sprintf(title, "HB #eta %d #phi %d depth %d", eta, phi, depth); + TH1D* h = fs_->make(name, title, nbinHB, x_min, x_max); + histHC_[cell] = h; + } + } + } + } + // For HE + int maxDepthHE = hcaltopology->maxDepthHE(); + int nbinHE = (Noise_) ? 18 : int(2000 * eHighHE_); + x_min = (Noise_) ? -3. : 0.; + x_max = (Noise_) ? 3. : 2. * eHighHE_; + for (int eta = -50; eta < 50; eta++) { + for (int phi = 0; phi < 100; phi++) { + for (int depth = 1; depth <= maxDepthHE; depth++) { + HcalDetId cell(HcalEndcap, eta, phi, depth); + if (hcaltopology->valid(cell)) { + sprintf(name, "HEeta%dphi%ddep%d", eta, phi, depth); + sprintf(title, "HE #eta %d #phi %d depth %d", eta, phi, depth); + TH1D* h = fs_->make(name, title, nbinHE, x_min, x_max); + histHC_[cell] = h; + } + } + } + } + // For HF + int maxDepthHF = 4; + int nbinHF = (Noise_) ? 200 : int(2000 * eHighHF_); + x_min = (Noise_) ? -10. : 0.; + x_max = (Noise_) ? 10. : 2. * eHighHF_; + for (int eta = -50; eta < 50; eta++) { + for (int phi = 0; phi < 100; phi++) { + for (int depth = 1; depth <= maxDepthHF; depth++) { + HcalDetId cell(HcalForward, eta, phi, depth); + if (hcaltopology->valid(cell)) { + sprintf(name, "HFeta%dphi%ddep%d", eta, phi, depth); + sprintf(title, "Energy (HF #eta %d #phi %d depth %d)", eta, phi, depth); + TH1D* h = fs_->make(name, title, nbinHF, x_min, x_max); + histHC_[cell] = h; + } + } + } + } } } } @@ -431,86 +419,85 @@ void RecAnalyzerMinbias::beginRun(edm::Run const&, edm::EventSetup const& iS) { // member functions // // ------------ method called to produce the data ------------ - -void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - rnnum_ = (double)iEvent.run(); +void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + rnnum_ = (double)iEvent.run(); - if (extraHist_) { + if (extraHist_) { double amplitudefullHB(0), amplitudefullHE(0), amplitudefullHF(0); edm::Handle hbhedigi; - iEvent.getByToken(tok_hbhedigi_,hbhedigi); + iEvent.getByToken(tok_hbhedigi_, hbhedigi); if (hbhedigi.isValid()) { for (auto const& digi : *(hbhedigi.product())) { - int nTS = digi.size(); - double amplitudefullTSs = 0.; - if (digi.id().subdet()==HcalBarrel) { - if (nTS <= 10) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHB += amplitudefullTSs; - } - } - if (digi.id().subdet()==HcalEndcap) { - if (nTS<=10) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHE += amplitudefullTSs; - } - } + int nTS = digi.size(); + double amplitudefullTSs = 0.; + if (digi.id().subdet() == HcalBarrel) { + if (nTS <= 10) { + for (int i = 0; i < nTS; i++) + amplitudefullTSs += digi.sample(i).adc(); + h_AmplitudeHBtest_->Fill(amplitudefullTSs); + amplitudefullHB += amplitudefullTSs; + } + } + if (digi.id().subdet() == HcalEndcap) { + if (nTS <= 10) { + for (int i = 0; i < nTS; i++) + amplitudefullTSs += digi.sample(i).adc(); + h_AmplitudeHEtest_->Fill(amplitudefullTSs); + amplitudefullHE += amplitudefullTSs; + } + } } } edm::Handle qie11digi; - iEvent.getByToken(tok_qie11digi_,qie11digi); + iEvent.getByToken(tok_qie11digi_, qie11digi); if (qie11digi.isValid()) { for (QIE11DataFrame const& digi : *(qie11digi.product())) { - double amplitudefullTSs = 0.; - if (HcalDetId(digi.id()).subdet()==HcalBarrel) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHB += amplitudefullTSs; - } - if (HcalDetId(digi.id()).subdet()==HcalEndcap) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHE += amplitudefullTSs; - } + double amplitudefullTSs = 0.; + if (HcalDetId(digi.id()).subdet() == HcalBarrel) { + for (int i = 0; i < digi.samples(); i++) + amplitudefullTSs += digi[i].adc(); + h_AmplitudeHBtest_->Fill(amplitudefullTSs); + amplitudefullHB += amplitudefullTSs; + } + if (HcalDetId(digi.id()).subdet() == HcalEndcap) { + for (int i = 0; i < digi.samples(); i++) + amplitudefullTSs += digi[i].adc(); + h_AmplitudeHEtest_->Fill(amplitudefullTSs); + amplitudefullHE += amplitudefullTSs; + } } } edm::Handle hfdigi; - iEvent.getByToken(tok_hfdigi_,hfdigi); + iEvent.getByToken(tok_hfdigi_, hfdigi); if (hfdigi.isValid()) { for (auto const& digi : *(hfdigi.product())) { - int nTS = digi.size(); - double amplitudefullTSs = 0.; - if (digi.id().subdet()==HcalForward) { - if (nTS <= 10) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHF += amplitudefullTSs; - } - } + int nTS = digi.size(); + double amplitudefullTSs = 0.; + if (digi.id().subdet() == HcalForward) { + if (nTS <= 10) { + for (int i = 0; i < nTS; i++) + amplitudefullTSs += digi.sample(i).adc(); + h_AmplitudeHFtest_->Fill(amplitudefullTSs); + amplitudefullHF += amplitudefullTSs; + } + } } } edm::Handle qie10digi; - iEvent.getByToken(tok_qie10digi_,qie10digi); + iEvent.getByToken(tok_qie10digi_, qie10digi); if (qie10digi.isValid()) { for (QIE10DataFrame const& digi : *(qie10digi.product())) { - double amplitudefullTSs = 0.; - if (HcalDetId(digi.id()).subdet()==HcalForward) { - for (int i=0; iFill(amplitudefullTSs); - amplitudefullHF += amplitudefullTSs; - } + double amplitudefullTSs = 0.; + if (HcalDetId(digi.id()).subdet() == HcalForward) { + for (int i = 0; i < digi.samples(); i++) + amplitudefullTSs += digi[i].adc(); + h_AmplitudeHFtest_->Fill(amplitudefullTSs); + amplitudefullHF += amplitudefullTSs; + } } } @@ -523,17 +510,15 @@ void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup iEvent.getByToken(tok_hbherecoMB_, hbheMB); if (!hbheMB.isValid()) { edm::LogWarning("RecAnalyzer") << "HcalCalibAlgos: Error! can't get hbhe product!"; - return ; + return; } const HBHERecHitCollection HithbheMB = *(hbheMB.product()); HBHEsize = HithbheMB.size(); - edm::LogVerbatim("RecAnalyzer") << "HBHE MB size of collection " - << HithbheMB.size(); + edm::LogVerbatim("RecAnalyzer") << "HBHE MB size of collection " << HithbheMB.size(); if (HithbheMB.size() < 5100 && runNZS_) { - edm::LogWarning("RecAnalyzer") << "HBHE problem " << rnnum_ << " size " - << HBHEsize; + edm::LogWarning("RecAnalyzer") << "HBHE problem " << rnnum_ << " size " << HBHEsize; } - + edm::Handle hfMB; iEvent.getByToken(tok_hfrecoMB_, hfMB); if (!hfMB.isValid()) { @@ -541,12 +526,10 @@ void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup return; } const HFRecHitCollection HithfMB = *(hfMB.product()); - edm::LogVerbatim("RecAnalyzer") << "HF MB size of collection " - << HithfMB.size(); + edm::LogVerbatim("RecAnalyzer") << "HF MB size of collection " << HithfMB.size(); HFsize = HithfMB.size(); if (HithfMB.size() < 1700 && runNZS_) { - edm::LogWarning("RecAnalyzer") << "HF problem " << rnnum_ << " size " - << HFsize; + edm::LogWarning("RecAnalyzer") << "HF problem " << rnnum_ << " size " << HFsize; } bool select(false); @@ -555,13 +538,12 @@ void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup iEvent.getByToken(tok_hltL1GtMap_, gtObjectMapRecord); if (gtObjectMapRecord.isValid()) { const std::vector& objMapVec = gtObjectMapRecord->gtObjectMap(); - for (std::vector::const_iterator itMap = objMapVec.begin(); - itMap != objMapVec.end(); ++itMap) { + for (std::vector::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end(); + ++itMap) { bool resultGt = (*itMap).algoGtlResult(); if (resultGt) { int algoBit = (*itMap).algoBitNumber(); - if (std::find(trigbit_.begin(),trigbit_.end(),algoBit) != - trigbit_.end()) { + if (std::find(trigbit_.begin(), trigbit_.end(), algoBit) != trigbit_.end()) { select = true; break; } @@ -570,18 +552,18 @@ void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup } } - if (!trigbit_.empty() || select) myTree1_->Fill(); + if (!trigbit_.empty() || select) + myTree1_->Fill(); //event weight for FLAT sample and PU information double eventWeight = 1.0; edm::Handle genEventInfo; iEvent.getByToken(tok_ew_, genEventInfo); - if (genEventInfo.isValid()) eventWeight = genEventInfo->weight(); + if (genEventInfo.isValid()) + eventWeight = genEventInfo->weight(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("RecAnalyzer") << "Test HB " << HBHEsize << " HF " - << HFsize << " Trigger " << trigbit_.size() - << ":" << select << ":" << ignoreL1_ - << " Wt " << eventWeight; + edm::LogVerbatim("RecAnalyzer") << "Test HB " << HBHEsize << " HF " << HFsize << " Trigger " << trigbit_.size() << ":" + << select << ":" << ignoreL1_ << " Wt " << eventWeight; #endif if (ignoreL1_ || (!trigbit_.empty() && select)) { analyzeHcal(HithbheMB, HithfMB, 1, true, eventWeight); @@ -591,131 +573,135 @@ void RecAnalyzerMinbias::analyze(const edm::Event& iEvent, const edm::EventSetup if (gtObjectMapRecord.isValid()) { const std::vector& objMapVec = gtObjectMapRecord->gtObjectMap(); bool ok(false); - for (std::vector::const_iterator itMap = objMapVec.begin(); - itMap != objMapVec.end(); ++itMap) { - bool resultGt = (*itMap).algoGtlResult(); - if (resultGt) { - int algoBit = (*itMap).algoBitNumber(); - analyzeHcal(HithbheMB, HithfMB, algoBit, (!ok), eventWeight); - ok = true; - } + for (std::vector::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end(); + ++itMap) { + bool resultGt = (*itMap).algoGtlResult(); + if (resultGt) { + int algoBit = (*itMap).algoBitNumber(); + analyzeHcal(HithbheMB, HithfMB, algoBit, (!ok), eventWeight); + ok = true; + } } if (!ok) { - edm::LogInfo("RecAnalyzer") << "No passed L1 Trigger found"; + edm::LogInfo("RecAnalyzer") << "No passed L1 Trigger found"; } } } } -void RecAnalyzerMinbias::analyzeHcal(const HBHERecHitCollection & HithbheMB, - const HFRecHitCollection & HithfMB, - int algoBit, bool fill, double weight) { +void RecAnalyzerMinbias::analyzeHcal( + const HBHERecHitCollection& HithbheMB, const HFRecHitCollection& HithfMB, int algoBit, bool fill, double weight) { // Signal part for HB HE int count(0), countHB(0), countHE(0), count2(0), count2HB(0), count2HE(0); - for (HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); - hbheItr!=HithbheMB.end(); hbheItr++) { + for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) { // Recalibration of energy DetId mydetid = hbheItr->id().rawId(); - double icalconst(1.); + double icalconst(1.); if (theRecalib_) { - std::map::iterator itr = corrFactor_.find(mydetid); - if (itr != corrFactor_.end()) icalconst = itr->second; + std::map::iterator itr = corrFactor_.find(mydetid); + if (itr != corrFactor_.end()) + icalconst = itr->second; } - HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time()); + HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time()); double energyhit = aHit.energy(); - DetId id = (*hbheItr).detid(); - HcalDetId hid = HcalDetId(id); - double eLow = (hid.subdet() == HcalEndcap) ? eLowHE_ : eLowHB_; - double eHigh = (hid.subdet() == HcalEndcap) ? eHighHE_ : eHighHB_; + DetId id = (*hbheItr).detid(); + HcalDetId hid = HcalDetId(id); + double eLow = (hid.subdet() == HcalEndcap) ? eLowHE_ : eLowHB_; + double eHigh = (hid.subdet() == HcalEndcap) ? eHighHE_ : eHighHB_; ++count; - if (id.subdetId() == HcalBarrel) ++countHB; - else ++countHE; + if (id.subdetId() == HcalBarrel) + ++countHB; + else + ++countHE; if (fill) { for (unsigned int i = 0; i < hcalID_.size(); i++) { - if (hcalID_[i] == id.rawId()) { - histo_[i]->Fill(energyhit); - break; - } + if (hcalID_[i] == id.rawId()) { + histo_[i]->Fill(energyhit); + break; + } } if (fillHist_) { - std::map::iterator itr1 = histHC_.find(hid); - if (itr1 != histHC_.end()) itr1->second->Fill(energyhit); + std::map::iterator itr1 = histHC_.find(hid); + if (itr1 != histHC_.end()) + itr1->second->Fill(energyhit); } - h_[hid.subdet()-1]->Fill(energyhit); + h_[hid.subdet() - 1]->Fill(energyhit); if (energyhit > eMin_) { - hbhe_->Fill(hid.ieta(),hid.iphi()); - ++count2; - if (id.subdetId() == HcalBarrel) { - ++count2HB; - hb_->Fill(hid.ieta(),hid.iphi()); - } else { - ++count2HE; - he_->Fill(hid.ieta(),hid.iphi()); - } + hbhe_->Fill(hid.ieta(), hid.iphi()); + ++count2; + if (id.subdetId() == HcalBarrel) { + ++count2HB; + hb_->Fill(hid.ieta(), hid.iphi()); + } else { + ++count2HE; + he_->Fill(hid.ieta(), hid.iphi()); + } } } if (!fillHist_) { if (Noise_ || runNZS_ || (energyhit >= eLow && energyhit <= eHigh)) { - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); - if (itr1 == myMap_.end()) { - myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); - } - itr1->second.theMB0 += weight; - itr1->second.theMB1 += (weight*energyhit); - itr1->second.theMB2 += (weight*energyhit*energyhit); - itr1->second.theMB3 += (weight*energyhit*energyhit*energyhit); - itr1->second.theMB4 += (weight*energyhit*energyhit*energyhit*energyhit); - itr1->second.runcheck = rnnum_; + std::map, myInfo>::iterator itr1 = + myMap_.find(std::pair(algoBit, hid)); + if (itr1 == myMap_.end()) { + myInfo info; + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); + } + itr1->second.theMB0 += weight; + itr1->second.theMB1 += (weight * energyhit); + itr1->second.theMB2 += (weight * energyhit * energyhit); + itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit); + itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit); + itr1->second.runcheck = rnnum_; } } - } // HBHE_MB + } // HBHE_MB if (fill) { - if (count > 0) hbherun_->Fill(rnnum_ ,(double)(count2)/count); - if (countHB > 0) hbrun_->Fill(rnnum_ ,(double)(count2HB)/countHB); - if (countHE > 0) herun_->Fill(rnnum_ ,(double)(count2HE)/countHE); + if (count > 0) + hbherun_->Fill(rnnum_, (double)(count2) / count); + if (countHB > 0) + hbrun_->Fill(rnnum_, (double)(count2HB) / countHB); + if (countHE > 0) + herun_->Fill(rnnum_, (double)(count2HE) / countHE); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("RecAnalyzer") << "HBHE " << count2 << ":" << count << ":" - << (double)(count2)/count << "\t HB " - << count2HB << ":" << countHB << ":" - << (double)(count2HB)/countHB << "\t HE " - << count2HE << ":" << countHE << ":" - << (double)(count2HE)/countHE; + edm::LogVerbatim("RecAnalyzer") << "HBHE " << count2 << ":" << count << ":" << (double)(count2) / count << "\t HB " + << count2HB << ":" << countHB << ":" << (double)(count2HB) / countHB << "\t HE " + << count2HE << ":" << countHE << ":" << (double)(count2HE) / countHE; #endif int countHF(0), count2HF(0); // Signal part for HF - for (HFRecHitCollection::const_iterator hfItr=HithfMB.begin(); - hfItr!=HithfMB.end(); hfItr++) { + for (HFRecHitCollection::const_iterator hfItr = HithfMB.begin(); hfItr != HithfMB.end(); hfItr++) { // Recalibration of energy DetId mydetid = hfItr->id().rawId(); - double icalconst(1.); + double icalconst(1.); if (theRecalib_) { - std::map::iterator itr = corrFactor_.find(mydetid); - if (itr != corrFactor_.end()) icalconst = itr->second; + std::map::iterator itr = corrFactor_.find(mydetid); + if (itr != corrFactor_.end()) + icalconst = itr->second; } - HFRecHit aHit(hfItr->id(),hfItr->energy()*icalconst,hfItr->time()); - + HFRecHit aHit(hfItr->id(), hfItr->energy() * icalconst, hfItr->time()); + double energyhit = aHit.energy(); - DetId id = (*hfItr).detid(); - HcalDetId hid = HcalDetId(id); + DetId id = (*hfItr).detid(); + HcalDetId hid = HcalDetId(id); ++countHF; if (fill) { for (unsigned int i = 0; i < hcalID_.size(); i++) { - if (hcalID_[i] == id.rawId()) { - histo_[i]->Fill(energyhit); - break; - } + if (hcalID_[i] == id.rawId()) { + histo_[i]->Fill(energyhit); + break; + } } if (fillHist_) { - std::map::iterator itr1 = histHC_.find(hid); - if (itr1 != histHC_.end()) itr1->second->Fill(energyhit); + std::map::iterator itr1 = histHC_.find(hid); + if (itr1 != histHC_.end()) + itr1->second->Fill(energyhit); } - h_[hid.subdet()-1]->Fill(energyhit); + h_[hid.subdet() - 1]->Fill(energyhit); if (energyhit > eMin_) { - hf_->Fill(hid.ieta(),hid.iphi()); - ++count2HF; + hf_->Fill(hid.ieta(), hid.iphi()); + ++count2HF; } } @@ -723,28 +709,28 @@ void RecAnalyzerMinbias::analyzeHcal(const HBHERecHitCollection & HithbheMB, // Remove PMT hits // if (!fillHist_) { - if (((Noise_ || runNZS_) && fabs(energyhit) <= 40.) || - (energyhit >= eLowHF_ && energyhit <= eHighHF_)) { - std::map,myInfo>::iterator itr1 = myMap_.find(std::pair(algoBit,hid)); - if (itr1 == myMap_.end()) { - myInfo info; - myMap_[std::pair(algoBit,hid)] = info; - itr1 = myMap_.find(std::pair(algoBit,hid)); - } - itr1->second.theMB0 += weight; - itr1->second.theMB1 += (weight*energyhit); - itr1->second.theMB2 += (weight*energyhit*energyhit); - itr1->second.theMB3 += (weight*energyhit*energyhit*energyhit); - itr1->second.theMB4 += (weight*energyhit*energyhit*energyhit*energyhit); - itr1->second.runcheck = rnnum_; + if (((Noise_ || runNZS_) && fabs(energyhit) <= 40.) || (energyhit >= eLowHF_ && energyhit <= eHighHF_)) { + std::map, myInfo>::iterator itr1 = + myMap_.find(std::pair(algoBit, hid)); + if (itr1 == myMap_.end()) { + myInfo info; + myMap_[std::pair(algoBit, hid)] = info; + itr1 = myMap_.find(std::pair(algoBit, hid)); + } + itr1->second.theMB0 += weight; + itr1->second.theMB1 += (weight * energyhit); + itr1->second.theMB2 += (weight * energyhit * energyhit); + itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit); + itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit); + itr1->second.runcheck = rnnum_; } } } - if (fill && countHF > 0) hfrun_->Fill(rnnum_ ,(double)(count2HF)/countHF); + if (fill && countHF > 0) + hfrun_->Fill(rnnum_, (double)(count2HF) / countHF); #ifdef EDM_ML_DEBUG - if (count) - edm::LogVerbatim("RecAnalyzer") << "HF " << count2HF << ":" << countHF - << ":" << (double)(count2HF)/countHF; + if (count) + edm::LogVerbatim("RecAnalyzer") << "HF " << count2HF << ":" << countHF << ":" << (double)(count2HF) / countHF; #endif } diff --git a/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc b/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc index e95c650d3f82c..96297ebe51a57 100644 --- a/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc +++ b/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc @@ -36,174 +36,157 @@ // class declaration class SimAnalyzerMinbias : public edm::EDAnalyzer { - public: explicit SimAnalyzerMinbias(const edm::ParameterSet&); ~SimAnalyzerMinbias(); virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() ; - virtual void endJob() ; + virtual void beginJob(); + virtual void endJob(); virtual void beginRun(const edm::Run& r, const edm::EventSetup& iSetup); virtual void endRun(const edm::Run& r, const edm::EventSetup& iSetup); - + private: - // ----------member data --------------------------- edm::Service fs_; - double timeCut_; - TTree* myTree_; - + double timeCut_; + TTree* myTree_; + // Root tree members - int mydet, mysubd, depth, iphi, ieta, cells; + int mydet, mysubd, depth, iphi, ieta, cells; float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB; - struct myInfo{ + struct myInfo { double theMB0, theMB1, theMB2, theMB3, theMB4; - myInfo() { - theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = 0; - } + myInfo() { theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = 0; } }; - std::map myMap_; - edm::EDGetTokenT tok_evt_; + std::map myMap_; + edm::EDGetTokenT tok_evt_; edm::EDGetTokenT tok_hcal_; }; // constructors and destructor SimAnalyzerMinbias::SimAnalyzerMinbias(const edm::ParameterSet& iConfig) { + timeCut_ = iConfig.getUntrackedParameter("TimeCut", 500); - timeCut_ = iConfig.getUntrackedParameter("TimeCut", 500); - // get token names of modules, producing object collections tok_evt_ = consumes(edm::InputTag("generator")); - tok_hcal_ = consumes(edm::InputTag("g4SimHits","HcalHits")); + tok_hcal_ = consumes(edm::InputTag("g4SimHits", "HcalHits")); - edm::LogInfo("AnalyzerMB") << "Use Time cut of " << timeCut_ << " ns"; + edm::LogInfo("AnalyzerMB") << "Use Time cut of " << timeCut_ << " ns"; } - + SimAnalyzerMinbias::~SimAnalyzerMinbias() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } - -void SimAnalyzerMinbias::beginRun(const edm::Run& r, const edm::EventSetup& iSetup) { -} - -void SimAnalyzerMinbias::endRun(const edm::Run& r, const edm::EventSetup& iSetup) { -} - -void SimAnalyzerMinbias::beginJob() { - myTree_ = fs_->make("SimJet","SimJet Tree"); - myTree_->Branch("mydet", &mydet, "mydet/I"); - myTree_->Branch("mysubd", &mysubd, "mysubd/I"); - myTree_->Branch("cells", &cells, "cells"); - myTree_->Branch("depth", &depth, "depth/I"); - myTree_->Branch("ieta", &ieta, "ieta/I"); - myTree_->Branch("iphi", &iphi, "iphi/I"); - myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); - myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); - myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); - myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); - myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); +void SimAnalyzerMinbias::beginRun(const edm::Run& r, const edm::EventSetup& iSetup) {} + +void SimAnalyzerMinbias::endRun(const edm::Run& r, const edm::EventSetup& iSetup) {} + +void SimAnalyzerMinbias::beginJob() { + myTree_ = fs_->make("SimJet", "SimJet Tree"); + myTree_->Branch("mydet", &mydet, "mydet/I"); + myTree_->Branch("mysubd", &mysubd, "mysubd/I"); + myTree_->Branch("cells", &cells, "cells"); + myTree_->Branch("depth", &depth, "depth/I"); + myTree_->Branch("ieta", &ieta, "ieta/I"); + myTree_->Branch("iphi", &iphi, "iphi/I"); + myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F"); + myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F"); + myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F"); + myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F"); + myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F"); myMap_.clear(); } - + // EndJob // void SimAnalyzerMinbias::endJob() { - cells = 0; - for (std::map::const_iterator itr=myMap_.begin(); - itr != myMap_.end(); ++itr) { + for (std::map::const_iterator itr = myMap_.begin(); itr != myMap_.end(); ++itr) { mysubd = itr->first.subdet(); - depth = itr->first.depth(); - iphi = itr->first.iphi(); - ieta = itr->first.ieta(); + depth = itr->first.depth(); + iphi = itr->first.iphi(); + ieta = itr->first.ieta(); myInfo info = itr->second; - if (info.theMB0 > 0) { + if (info.theMB0 > 0) { mom0_MB = info.theMB0; mom1_MB = info.theMB1; mom2_MB = info.theMB2; mom3_MB = info.theMB3; mom4_MB = info.theMB4; cells++; - - edm::LogInfo("AnalyzerMB") << " Result= " << mysubd << " " << ieta << " " - << iphi << " mom0 " << mom0_MB << " mom1 " - << mom1_MB << " mom2 " << mom2_MB << " mom3 " - << mom3_MB << " mom4 " << mom4_MB; + + edm::LogInfo("AnalyzerMB") << " Result= " << mysubd << " " << ieta << " " << iphi << " mom0 " << mom0_MB + << " mom1 " << mom1_MB << " mom2 " << mom2_MB << " mom3 " << mom3_MB << " mom4 " + << mom4_MB; myTree_->Fill(); } } - edm::LogInfo("AnalyzerMB") << "cells " << cells; + edm::LogInfo("AnalyzerMB") << "cells " << cells; } // // member functions // - + // ------------ method called to produce the data ------------ - -void SimAnalyzerMinbias::analyze(const edm::Event& iEvent, - const edm::EventSetup&) { - edm::LogInfo("AnalyzerMB") << " Start SimAnalyzerMinbias::analyze " - << iEvent.id().run() << ":" < evtMC; - iEvent.getByToken(tok_evt_, evtMC); + iEvent.getByToken(tok_evt_, evtMC); if (!evtMC.isValid()) { edm::LogWarning("AnalyzerMB") << "no HepMCProduct found"; } else { - const HepMC::GenEvent * myGenEvent = evtMC->GetEvent(); - edm::LogInfo("AnalyzerMB") << "Event with " << myGenEvent->particles_size() - << " particles + " <vertices_size() - << " vertices"; + const HepMC::GenEvent* myGenEvent = evtMC->GetEvent(); + edm::LogInfo("AnalyzerMB") << "Event with " << myGenEvent->particles_size() << " particles + " + << myGenEvent->vertices_size() << " vertices"; } - edm::Handle hcalHits; - iEvent.getByToken(tok_hcal_,hcalHits); + iEvent.getByToken(tok_hcal_, hcalHits); if (!hcalHits.isValid()) { edm::LogWarning("AnalyzerMB") << "Error! can't get HcalHits product!"; - return ; + return; } - - const edm::PCaloHitContainer * HitHcal = hcalHits.product () ; - std::map hitMap; - for (std::vector::const_iterator hcalItr = HitHcal->begin(); - hcalItr != HitHcal->end(); ++hcalItr) { - double time = hcalItr->time(); + + const edm::PCaloHitContainer* HitHcal = hcalHits.product(); + std::map hitMap; + for (std::vector::const_iterator hcalItr = HitHcal->begin(); hcalItr != HitHcal->end(); ++hcalItr) { + double time = hcalItr->time(); if (time < timeCut_) { double energyhit = hcalItr->energy(); - HcalDetId hid = HcalDetId(hcalItr->id()); - std::map::iterator itr1 = hitMap.find(hid); + HcalDetId hid = HcalDetId(hcalItr->id()); + std::map::iterator itr1 = hitMap.find(hid); if (itr1 == hitMap.end()) { - hitMap[hid] = 0; - itr1 = hitMap.find(hid); + hitMap[hid] = 0; + itr1 = hitMap.find(hid); } - itr1->second += energyhit; + itr1->second += energyhit; } } - edm::LogInfo("AnalyzerMB") << "extract information of " << hitMap.size() - << " towers from " << HitHcal->size() << " hits"; + edm::LogInfo("AnalyzerMB") << "extract information of " << hitMap.size() << " towers from " << HitHcal->size() + << " hits"; - for (std::map::const_iterator hcalItr=hitMap.begin(); - hcalItr != hitMap.end(); ++hcalItr) { - HcalDetId hid = hcalItr->first; + for (std::map::const_iterator hcalItr = hitMap.begin(); hcalItr != hitMap.end(); ++hcalItr) { + HcalDetId hid = hcalItr->first; double energyhit = hcalItr->second; - std::map::iterator itr1 = myMap_.find(hid); + std::map::iterator itr1 = myMap_.find(hid); if (itr1 == myMap_.end()) { myInfo info; myMap_[hid] = info; itr1 = myMap_.find(hid); - } + } itr1->second.theMB0++; itr1->second.theMB1 += energyhit; - itr1->second.theMB2 += (energyhit*energyhit); - itr1->second.theMB3 += (energyhit*energyhit*energyhit); - itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit); + itr1->second.theMB2 += (energyhit * energyhit); + itr1->second.theMB3 += (energyhit * energyhit * energyhit); + itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit); edm::LogInfo("AnalyzerMB") << "ID " << hid << " with energy " << energyhit; } } @@ -211,4 +194,3 @@ void SimAnalyzerMinbias::analyze(const edm::Event& iEvent, //define this as a plug-in #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimAnalyzerMinbias); - diff --git a/Calibration/HcalCalibAlgos/plugins/ValidIsoTrkCalib.cc b/Calibration/HcalCalibAlgos/plugins/ValidIsoTrkCalib.cc index c3dbba367dfae..142693555e3b9 100644 --- a/Calibration/HcalCalibAlgos/plugins/ValidIsoTrkCalib.cc +++ b/Calibration/HcalCalibAlgos/plugins/ValidIsoTrkCalib.cc @@ -1,7 +1,7 @@ // // Package: ValidIsoTrkCalib // Class: ValidIsoTrkCalib -// +// /* Description: Validation for Isolated tracks Calibration @@ -56,7 +56,6 @@ See the twiki page for details: #include "TTree.h" #include "TH1F.h" - #include #include @@ -72,15 +71,12 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { // double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint); private: - - void beginJob() override ; + void beginJob() override; void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override ; + void endJob() override; - - // ----------member data --------------------------- - + //Variables from HcalIsotrackAnalyzer TrackDetectorAssociator trackAssociator_; @@ -90,7 +86,7 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { const CaloGeometry* geo; // nothing is done with these tags, so I leave it - cowden - InputTag genhbheLabel_; + InputTag genhbheLabel_; InputTag genhoLabel_; std::vector genecalLabel_; @@ -99,7 +95,7 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { edm::EDGetTokenT tok_ho_; edm::EDGetTokenT tok_track_; edm::EDGetTokenT tok_track1_; - + //std::string m_inputTrackLabel; //std::string m_hcalLabel; @@ -111,16 +107,15 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { string outputFileName_; //string calibFactorsFileName_; // string corrfile; - + bool takeGenTracks_; //bool takeAllRecHits_, takeGenTracks_; int gen, iso, pix; float genPt[500], genPhi[500], genEta[500]; float isoPt[500], isoPhi[500], isoEta[500]; float pixPt[500], pixPhi[500], pixEta[500]; - //int hbheiEta[5000],hbheiPhi[5000],hbheDepth[5000]; - //float hbheEnergy[5000]; - + //int hbheiEta[5000],hbheiPhi[5000],hbheDepth[5000]; + //float hbheEnergy[5000]; int NisoTrk; float trackPt, trackE, trackEta, trackPhi; @@ -132,7 +127,6 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { double energyECALmip, maxPNear; double energyMinIso, energyMaxIso; - Float_t emEnergy; Float_t targetE; @@ -151,11 +145,11 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { int Nhits; float eClustBefore; //Calo energy before calibration float eClustAfter; //After calibration - float eTrack; //Track energy - float etaTrack; - float phiTrack; - float eECAL; // Energy deposited in ECAL - int numHits; //number of rechits + float eTrack; //Track energy + float etaTrack; + float phiTrack; + float eECAL; // Energy deposited in ECAL + int numHits; //number of rechits //float e3x3; float eBeforeDepth1; @@ -185,27 +179,23 @@ class ValidIsoTrkCalib : public edm::EDAnalyzer { float numVH, numVS, numValidTrkHits, numValidTrkStrips; const HcalRespCorrs* respRecalib; - // map CalibFactors; + // map CalibFactors; // Bool_t ReadCalibFactors(string); - TH1F *nTracks; + TH1F* nTracks; edm::Service fs; // int Lumi_n; - - }; - ValidIsoTrkCalib::ValidIsoTrkCalib(const edm::ParameterSet& iConfig) - -{ +{ //takeAllRecHits_=iConfig.getUntrackedParameter("takeAllRecHits"); - takeGenTracks_=iConfig.getUntrackedParameter("takeGenTracks"); + takeGenTracks_ = iConfig.getUntrackedParameter("takeGenTracks"); tok_genTrack_ = consumes(iConfig.getParameter("genTracksLabel")); - genhbheLabel_= iConfig.getParameter("genHBHE"); + genhbheLabel_ = iConfig.getParameter("genHBHE"); //genhoLabel_=iConfig.getParameter("genHO"); //genecalLabel_=iConfig.getParameter >("genECAL"); @@ -214,20 +204,20 @@ ValidIsoTrkCalib::ValidIsoTrkCalib(const edm::ParameterSet& iConfig) tok_hbhe_ = consumes(iConfig.getParameter("hbheInput")); tok_ho_ = consumes(iConfig.getParameter("hoInput")); //eLabel_=iConfig.getParameter("eInput"); - tok_track_ = consumes(iConfig.getParameter("HcalIsolTrackInput")); + tok_track_ = + consumes(iConfig.getParameter("HcalIsolTrackInput")); tok_track1_ = consumes(iConfig.getParameter("trackInput")); - associationConeSize_=iConfig.getParameter("associationConeSize"); - allowMissingInputs_=iConfig.getUntrackedParameter("allowMissingInputs", true); -// outputFileName_=iConfig.getParameter("outputFileName"); + associationConeSize_ = iConfig.getParameter("associationConeSize"); + allowMissingInputs_ = iConfig.getUntrackedParameter("allowMissingInputs", true); + // outputFileName_=iConfig.getParameter("outputFileName"); // calibFactorsFileName_=iConfig.getParameter("calibFactorsFileName"); + AxB_ = iConfig.getParameter("AxB"); + calibrationConeSize_ = iConfig.getParameter("calibrationConeSize"); - AxB_=iConfig.getParameter("AxB"); - calibrationConeSize_=iConfig.getParameter("calibrationConeSize"); - - MinNTrackHitsBarrel = iConfig.getParameter("MinNTrackHitsBarrel"); - MinNTECHitsEndcap = iConfig.getParameter("MinNTECHitsEndcap"); + MinNTrackHitsBarrel = iConfig.getParameter("MinNTrackHitsBarrel"); + MinNTECHitsEndcap = iConfig.getParameter("MinNTECHitsEndcap"); energyECALmip = iConfig.getParameter("energyECALmip"); energyMinIso = iConfig.getParameter("energyMinIso"); energyMaxIso = iConfig.getParameter("energyMaxIso"); @@ -235,52 +225,43 @@ ValidIsoTrkCalib::ValidIsoTrkCalib(const edm::ParameterSet& iConfig) edm::ParameterSet parameters = iConfig.getParameter("TrackAssociatorParameters"); edm::ConsumesCollector iC = consumesCollector(); - parameters_.loadParameters( parameters, iC ); + parameters_.loadParameters(parameters, iC); trackAssociator_.useDefaultPropagator(); // taECALCone_=iConfig.getUntrackedParameter("TrackAssociatorECALCone",0.5); //taHCALCone_=iConfig.getUntrackedParameter("TrackAssociatorHCALCone",0.6); - } - -ValidIsoTrkCalib::~ValidIsoTrkCalib() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - +ValidIsoTrkCalib::~ValidIsoTrkCalib() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) } - // ------------ method called to for each event ------------ -void -ValidIsoTrkCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - - try{ - edm::ESHandle recalibCorrs; - iSetup.get().get("recalibrate",recalibCorrs); - respRecalib = recalibCorrs.product(); +void ValidIsoTrkCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; - LogInfo("CalibConstants")<<" Loaded: OK "; + try { + edm::ESHandle recalibCorrs; + iSetup.get().get("recalibrate", recalibCorrs); + respRecalib = recalibCorrs.product(); - }catch(const cms::Exception & e) { - LogWarning("CalibConstants")<<" Not Found!! "; - } + LogInfo("CalibConstants") << " Loaded: OK "; - edm::Handle generalTracks; - iEvent.getByToken(tok_genTrack_, generalTracks); + } catch (const cms::Exception& e) { + LogWarning("CalibConstants") << " Not Found!! "; + } - edm::Handle isoProdTracks; - iEvent.getByToken(tok_track1_,isoProdTracks); + edm::Handle generalTracks; + iEvent.getByToken(tok_genTrack_, generalTracks); + edm::Handle isoProdTracks; + iEvent.getByToken(tok_track1_, isoProdTracks); edm::Handle isoPixelTracks; //edm::Handle isoPixelTracks; - iEvent.getByToken(tok_track_,isoPixelTracks); - + iEvent.getByToken(tok_track_, isoPixelTracks); + /* edm::Handle ecal; iEvent.getByLabel(eLabel_,ecal); @@ -288,14 +269,14 @@ ValidIsoTrkCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu */ edm::Handle hbhe; - iEvent.getByToken(tok_hbhe_,hbhe); + iEvent.getByToken(tok_hbhe_, hbhe); const HBHERecHitCollection Hithbhe = *(hbhe.product()); edm::ESHandle pG; iSetup.get().get(pG); geo = pG.product(); - - const HcalGeometry* gHcal = static_cast(geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel)); + + const HcalGeometry* gHcal = static_cast(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel)); //Note: even though it says HcalBarrel, we actually get the whole Hcal detector geometry! // Lumi_n=iEvent.luminosityBlock(); @@ -308,79 +289,84 @@ ValidIsoTrkCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu //cout<<"Hello World. TrackCollectionSize: "<< isoPixelTracks->size()<empty()) return; - + if (isoPixelTracks->empty()) + return; + + for (reco::TrackCollection::const_iterator trit = isoProdTracks->begin(); trit != isoProdTracks->end(); trit++) { + reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched = isoPixelTracks->begin(); + //reco::TrackCollection::const_iterator isoMatched=isoPixelTracks->begin(); + bool matched = false; -for (reco::TrackCollection::const_iterator trit=isoProdTracks->begin(); trit!=isoProdTracks->end(); trit++) + //for (reco::IsolatedPixelTrackCandidateCollection::const_iterator trit = isoPixelTracks->begin(); trit!=isoPixelTracks->end(); trit++) + for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin(); + it != isoPixelTracks->end(); + it++) + //for (reco::TrackCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++) { - - reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched=isoPixelTracks->begin(); - //reco::TrackCollection::const_iterator isoMatched=isoPixelTracks->begin(); - bool matched=false; - - //for (reco::IsolatedPixelTrackCandidateCollection::const_iterator trit = isoPixelTracks->begin(); trit!=isoPixelTracks->end(); trit++) - for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++) - //for (reco::TrackCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++) - { - - if (abs((trit->pt() - it->pt())/it->pt()) < 0.005 && abs(trit->eta() - it->eta()) < 0.01) - { - isoMatched=it; - matched=true; - break; - } - } - // CUT - - if (!matched) continue; - if(isoMatched->maxPtPxl() > maxPNear) continue; - - ptNear = isoMatched->maxPtPxl(); - //cout<<"Point 0.1 isoMatch. ptnear: "<hitPattern().numberOfValidHits()eta())>1.47&&trit->hitPattern().numberOfValidStripTECHits()hitPattern().numberOfValidHits()<hitPattern().numberOfValidStripTECHits()<hitPattern().numberOfValidHits(); - numVS = trit->hitPattern().numberOfValidStripTECHits(); - - - - trackE = sqrt(trit->px()*trit->px()+trit->py()*trit->py()+trit->pz()*trit->pz()+0.14*0.14); - trackPt = trit->pt(); - trackEta = trit->eta(); - trackPhi = trit->phi(); - - emEnergy = isoMatched->energyIn(); - - //cout<<"Point 0.3. Matched :: pt: "<pt()<<" wholeEnergy: "<pt() - it->pt()) / it->pt()) < 0.005 && abs(trit->eta() - it->eta()) < 0.01) { + isoMatched = it; + matched = true; + break; + } + } + // CUT + + if (!matched) + continue; + if (isoMatched->maxPtPxl() > maxPNear) + continue; + + ptNear = isoMatched->maxPtPxl(); + //cout<<"Point 0.1 isoMatch. ptnear: "<hitPattern().numberOfValidHits() < MinNTrackHitsBarrel) + continue; + if (fabs(trit->eta()) > 1.47 && trit->hitPattern().numberOfValidStripTECHits() < MinNTECHitsEndcap) + continue; + + //cout<<"Point 0.2.1 after numofvalidhits HB: "<hitPattern().numberOfValidHits()<hitPattern().numberOfValidStripTECHits()<hitPattern().numberOfValidHits(); + numVS = trit->hitPattern().numberOfValidStripTECHits(); + + trackE = sqrt(trit->px() * trit->px() + trit->py() * trit->py() + trit->pz() * trit->pz() + 0.14 * 0.14); + trackPt = trit->pt(); + trackEta = trit->eta(); + trackPhi = trit->phi(); + + emEnergy = isoMatched->energyIn(); + + //cout<<"Point 0.3. Matched :: pt: "<pt()<<" wholeEnergy: "<begin(); trit!=is PzTrkHcal = trackMomAtHcal.z(); */ - GlobalPoint gPointEcal(xTrkEcal,yTrkEcal,zTrkEcal); - GlobalPoint gPointHcal(xTrkHcal,yTrkHcal,zTrkHcal); - - int iphitrue = -10; - int ietatrue = 100; - const HcalDetId tempId = gHcal->getClosestCell(gPointHcal); - ietatrue = tempId.ieta(); - iphitrue = tempId.iphi(); - - - MaxHit_struct MaxHit; - - MaxHit.hitenergy=-100.; - - //container for used recHits - std::vector usedHits; - // - usedHits.clear(); - //cout <<"Point 1. Entrance to HBHECollection"<id()) hitIsUsed=true; - } - if (hitIsUsed) continue; - usedHits.push_back(hhit->id()); - // - - // rof 16.05.2008 start: include the possibility for recalibration - float recal = 1; - // rof end - - GlobalPoint pos = geo->getPosition(hhit->detid()); - //float phihit = pos.phi(); - //float etahit = pos.eta(); - - int iphihitm = (hhit->id()).iphi(); - int ietahitm = (hhit->id()).ieta(); - int depthhit = (hhit->id()).depth(); - float enehit = hhit->energy() * recal; - - if (depthhit!=1) continue; - - /* + GlobalPoint gPointEcal(xTrkEcal, yTrkEcal, zTrkEcal); + GlobalPoint gPointHcal(xTrkHcal, yTrkHcal, zTrkHcal); + + int iphitrue = -10; + int ietatrue = 100; + const HcalDetId tempId = gHcal->getClosestCell(gPointHcal); + ietatrue = tempId.ieta(); + iphitrue = tempId.iphi(); + + MaxHit_struct MaxHit; + + MaxHit.hitenergy = -100.; + + //container for used recHits + std::vector usedHits; + // + usedHits.clear(); + //cout <<"Point 1. Entrance to HBHECollection"<id()) + hitIsUsed = true; + } + if (hitIsUsed) + continue; + usedHits.push_back(hhit->id()); + // + + // rof 16.05.2008 start: include the possibility for recalibration + float recal = 1; + // rof end + + GlobalPoint pos = geo->getPosition(hhit->detid()); + //float phihit = pos.phi(); + //float etahit = pos.eta(); + + int iphihitm = (hhit->id()).iphi(); + int ietahitm = (hhit->id()).ieta(); + int depthhit = (hhit->id()).depth(); + float enehit = hhit->energy() * recal; + + if (depthhit != 1) + continue; + + /* float dphi = fabs(phihcal - phihit); if(dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi; float deta = fabs(etahcal - etahit); float dr = sqrt(dphi*dphi + deta*deta); */ - - - //double distAtHcal = getDistInPlaneTrackDir(gPointHcal, trackMomAtHcal, pos); - double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); - - if(distAtHcal < associationConeSize_) - { - - for (HBHERecHitCollection::const_iterator hhit2=Hithbhe.begin(); hhit2!=Hithbhe.end(); hhit2++) - { - int iphihitm2 = (hhit2->id()).iphi(); - int ietahitm2 = (hhit2->id()).ieta(); - int depthhit2 = (hhit2->id()).depth(); - float enehit2 = hhit2->energy() * recal; - - if (iphihitm==iphihitm2 && ietahitm==ietahitm2 && depthhit!=depthhit2) enehit = enehit+enehit2; - - } - - - //cout<<"IN CONE ieta: "< MaxHit.hitenergy) - { - MaxHit.hitenergy = enehit; - MaxHit.ietahitm = (hhit->id()).ieta(); - MaxHit.iphihitm = (hhit->id()).iphi(); - MaxHit.dr = distAtHcal; - //MaxHit.depthhit = (hhit->id()).depth(); - MaxHit.depthhit = 1; - - //gPhot = geo->getPosition(hhit->detid()); - } - - } - } //end of all HBHE hits cycle - - usedHits.clear(); - - //cout<<"Hottest ieta: "< energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. && abs(MaxHit.ietahitm)<29) passCuts = kTRUE; - - //cout<<"Pont 0.1.1. trackE:"<id()) hitIsUsed=true; - } - if (hitIsUsed) continue; - usedHits.push_back(hhit->id()); - - int DIETA = 100; - if(MaxHit.ietahitm*(hhit->id()).ieta()>0) - { - DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); - } - if(MaxHit.ietahitm*(hhit->id()).ieta()<0) - { - DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); - DIETA = DIETA>0 ? DIETA-1 : DIETA+1; - } - - int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); - DIPHI = DIPHI>36 ? 72-DIPHI : DIPHI; - - - - int numbercell=100; //always collect Wide clastor! - - //if(AxB_=="5x5" || AxB_=="3x3" || AxB_=="7x7"|| AxB_=="Cone") - - //if(AxB_=="3x3") numbercell = 1; - //if(AxB_=="5x5") numbercell = 2; - //if(AxB_=="Cone") numbercell = 1000; - - if( abs(DIETA)<=numbercell && (abs(DIPHI)<=numbercell || ( abs(MaxHit.ietahitm)>=20 && abs(DIPHI)<=numbercell+1)) ) - { - const GlobalPoint pos2 = geo->getPosition(hhit->detid()); - - if(passCuts && hhit->energy()>0) - { - - - float factor = 0.0; - // factor = CalibFactors[hhit->id()]; - factor = respRecalib -> getValues(hhit->id())->getValue(); - - - - //if(i<5){cout<<" calib factors: "<id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm) CentHitFactor=factor; - - if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm) iTime = hhit->time(); - - if(AxB_!="3x3" && AxB_!="5x5" && AxB_!="Cone") LogWarning(" AxB ")<<" Not supported: "<< AxB_; - - - if (abs(DIETA)<=2 && (abs(DIPHI)<=2 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=4) && !( (abs(MaxHit.ietahitm)==21 || abs(MaxHit.ietahitm)==22) && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>2) )) ) - { - - e5x5Before += hhit->energy(); - e5x5After += hhit->energy()*factor; - } - - - if (abs(DIETA)<=1 && (abs(DIPHI)<=1 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=2) && !(abs(MaxHit.ietahitm)==21 && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>1) )) ) - { - - e3x3Before += hhit->energy(); - e3x3After += hhit->energy()*factor; - } - - - if(AxB_=="5x5") - { - - if (abs(DIETA)<=2 && (abs(DIPHI)<=2 || ( abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=4) ) ) - { - if (abs(MaxHit.ietahitm)==21 && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>3) continue; - - HTime[numHits]= hhit->time(); - numHits++; - - eClustBefore += hhit->energy(); - eClustAfter += hhit->energy()*factor; - - if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth1 += hhit->energy(); - eAfterDepth1 += hhit->energy()*factor; - } - else if((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth2 += hhit->energy(); - eAfterDepth2 += hhit->energy()*factor; - } - } - }//end of 5x5 - - - - if(AxB_=="3x3") - { - if (abs(DIETA)<=1 && (abs(DIPHI)<=1 || ( abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=2) ) ) - { - if (abs(MaxHit.ietahitm)==21 && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>2) continue; - - HTime[numHits]= hhit->time(); - numHits++; - - eClustBefore += hhit->energy(); - eClustAfter += hhit->energy() * factor; - - if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth1 += hhit->energy(); - eAfterDepth1 += hhit->energy() * factor; - } - else if((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth2 += hhit->energy(); - eAfterDepth2 += hhit->energy() * factor; - } - - } - }//end of 3x3 - - - if (AxB_=="Cone" && getDistInPlaneSimple(gPointHcal, pos2) < calibrationConeSize_) { - - HTime[numHits]= hhit->time(); - numHits++; - - eClustBefore += hhit->energy(); - eClustAfter += hhit->energy() * factor; - - if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth1 += hhit->energy(); - eAfterDepth1 += hhit->energy() * factor; - } - else if((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) - { - eBeforeDepth2 += hhit->energy(); - eAfterDepth2 += hhit->energy() * factor; - } - - - }//end of Cone - - }//end of passCuts - - }//end of DIETA DIPHI - - } //end of associatedcone HBHE hits cycle - - - int dieta_M_P = 100; - int diphi_M_P = 100; - if(MaxHit.ietahitm*ietatrue>0) {dieta_M_P = abs (MaxHit.ietahitm-ietatrue);} - if(MaxHit.ietahitm*ietatrue<0) {dieta_M_P = abs(MaxHit.ietahitm-ietatrue)-1;} - diphi_M_P = abs(MaxHit.iphihitm-iphitrue); - diphi_M_P = diphi_M_P>36 ? 72-diphi_M_P : diphi_M_P; - - - if(passCuts) - - { - eventNumber = iEvent.id().event(); - runNumber = iEvent.id().run(); - - eCentHitBefore = MaxHit.hitenergy; - eCentHitAfter = MaxHit.hitenergy*CentHitFactor; - eECAL = emEnergy; - numValidTrkHits = numVH; - numValidTrkStrips = numVS; - PtNearBy = ptNear; - - - eTrack = trackE; - phiTrack = trackPhi; - etaTrack = trackEta; - - iEta = MaxHit.ietahitm; - iPhi = MaxHit.iphihitm; - - iEtaTr = ietatrue; - iPhiTr = iphitrue; - iDr = sqrt(diphi_M_P*diphi_M_P+dieta_M_P*dieta_M_P); - delR = MaxHit.dr; - dietatr = dieta_M_P; - diphitr = diphi_M_P; - - fTree -> Fill(); - } - - } //end of isoProdTracks cycle - - - -/* ------------------ Some stuff for general tracks ---------- ----*/ + + //double distAtHcal = getDistInPlaneTrackDir(gPointHcal, trackMomAtHcal, pos); + double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); + + if (distAtHcal < associationConeSize_) { + for (HBHERecHitCollection::const_iterator hhit2 = Hithbhe.begin(); hhit2 != Hithbhe.end(); hhit2++) { + int iphihitm2 = (hhit2->id()).iphi(); + int ietahitm2 = (hhit2->id()).ieta(); + int depthhit2 = (hhit2->id()).depth(); + float enehit2 = hhit2->energy() * recal; + + if (iphihitm == iphihitm2 && ietahitm == ietahitm2 && depthhit != depthhit2) + enehit = enehit + enehit2; + } + + //cout<<"IN CONE ieta: "< MaxHit.hitenergy) { + MaxHit.hitenergy = enehit; + MaxHit.ietahitm = (hhit->id()).ieta(); + MaxHit.iphihitm = (hhit->id()).iphi(); + MaxHit.dr = distAtHcal; + //MaxHit.depthhit = (hhit->id()).depth(); + MaxHit.depthhit = 1; + + //gPhot = geo->getPosition(hhit->detid()); + } + } + } //end of all HBHE hits cycle + + usedHits.clear(); + + //cout<<"Hottest ieta: "< energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. && + abs(MaxHit.ietahitm) < 29) + passCuts = kTRUE; + + //cout<<"Pont 0.1.1. trackE:"<id()) + hitIsUsed = true; + } + if (hitIsUsed) + continue; + usedHits.push_back(hhit->id()); + + int DIETA = 100; + if (MaxHit.ietahitm * (hhit->id()).ieta() > 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + } + if (MaxHit.ietahitm * (hhit->id()).ieta() < 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1; + } + + int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); + DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI; + + int numbercell = 100; //always collect Wide clastor! + + //if(AxB_=="5x5" || AxB_=="3x3" || AxB_=="7x7"|| AxB_=="Cone") + + //if(AxB_=="3x3") numbercell = 1; + //if(AxB_=="5x5") numbercell = 2; + //if(AxB_=="Cone") numbercell = 1000; + + if (abs(DIETA) <= numbercell && + (abs(DIPHI) <= numbercell || (abs(MaxHit.ietahitm) >= 20 && abs(DIPHI) <= numbercell + 1))) { + const GlobalPoint pos2 = geo->getPosition(hhit->detid()); + + if (passCuts && hhit->energy() > 0) { + float factor = 0.0; + // factor = CalibFactors[hhit->id()]; + factor = respRecalib->getValues(hhit->id())->getValue(); + + //if(i<5){cout<<" calib factors: "<id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm) + CentHitFactor = factor; + + if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm) + iTime = hhit->time(); + + if (AxB_ != "3x3" && AxB_ != "5x5" && AxB_ != "Cone") + LogWarning(" AxB ") << " Not supported: " << AxB_; + + if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4) && + !((abs(MaxHit.ietahitm) == 21 || abs(MaxHit.ietahitm) == 22) && + abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)))) { + e5x5Before += hhit->energy(); + e5x5After += hhit->energy() * factor; + } + + if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2) && + !(abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && + abs(DIPHI) > 1)))) { + e3x3Before += hhit->energy(); + e3x3After += hhit->energy() * factor; + } + + if (AxB_ == "5x5") { + if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4))) { + if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 3) + continue; + + HTime[numHits] = hhit->time(); + numHits++; + + eClustBefore += hhit->energy(); + eClustAfter += hhit->energy() * factor; + + if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth1 += hhit->energy(); + eAfterDepth1 += hhit->energy() * factor; + } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth2 += hhit->energy(); + eAfterDepth2 += hhit->energy() * factor; + } + } + } //end of 5x5 + + if (AxB_ == "3x3") { + if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2))) { + if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2) + continue; + + HTime[numHits] = hhit->time(); + numHits++; + + eClustBefore += hhit->energy(); + eClustAfter += hhit->energy() * factor; + + if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth1 += hhit->energy(); + eAfterDepth1 += hhit->energy() * factor; + } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth2 += hhit->energy(); + eAfterDepth2 += hhit->energy() * factor; + } + } + } //end of 3x3 + + if (AxB_ == "Cone" && getDistInPlaneSimple(gPointHcal, pos2) < calibrationConeSize_) { + HTime[numHits] = hhit->time(); + numHits++; + + eClustBefore += hhit->energy(); + eClustAfter += hhit->energy() * factor; + + if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth1 += hhit->energy(); + eAfterDepth1 += hhit->energy() * factor; + } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) { + eBeforeDepth2 += hhit->energy(); + eAfterDepth2 += hhit->energy() * factor; + } + + } //end of Cone + + } //end of passCuts + + } //end of DIETA DIPHI + + } //end of associatedcone HBHE hits cycle + + int dieta_M_P = 100; + int diphi_M_P = 100; + if (MaxHit.ietahitm * ietatrue > 0) { + dieta_M_P = abs(MaxHit.ietahitm - ietatrue); + } + if (MaxHit.ietahitm * ietatrue < 0) { + dieta_M_P = abs(MaxHit.ietahitm - ietatrue) - 1; + } + diphi_M_P = abs(MaxHit.iphihitm - iphitrue); + diphi_M_P = diphi_M_P > 36 ? 72 - diphi_M_P : diphi_M_P; + + if (passCuts) + + { + eventNumber = iEvent.id().event(); + runNumber = iEvent.id().run(); + + eCentHitBefore = MaxHit.hitenergy; + eCentHitAfter = MaxHit.hitenergy * CentHitFactor; + eECAL = emEnergy; + numValidTrkHits = numVH; + numValidTrkStrips = numVS; + PtNearBy = ptNear; + + eTrack = trackE; + phiTrack = trackPhi; + etaTrack = trackEta; + + iEta = MaxHit.ietahitm; + iPhi = MaxHit.iphihitm; + + iEtaTr = ietatrue; + iPhiTr = iphitrue; + iDr = sqrt(diphi_M_P * diphi_M_P + dieta_M_P * dieta_M_P); + delR = MaxHit.dr; + dietatr = dieta_M_P; + diphitr = diphi_M_P; + + fTree->Fill(); + } + + } //end of isoProdTracks cycle + + /* ------------------ Some stuff for general tracks ---------- ----*/ //cout<<" generalTracks Size: "<< generalTracks->size()<size(); nTracks->Fill(n); - if(takeGenTracks_ && iEvent.id().event()%10==1) - { - gen = generalTracks->size(); - iso = isoProdTracks->size(); - pix = isoPixelTracks->size(); - - genPt[0] = -33; - genPhi[0] = -33; - genEta[0] = -33; - - isoPt[0] = -33; - isoPhi[0] = -33; - isoEta[0] = -33; - - pixPt[0] = -33; - pixPhi[0] = -33; - pixEta[0] = -33; - - Int_t gencount=0, isocount=0, pixcount=0; - for (reco::TrackCollection::const_iterator gentr=generalTracks->begin(); gentr!=generalTracks->end(); gentr++) - { - genPt[gencount] = gentr->pt(); - genPhi[gencount] = gentr->phi(); - genEta[gencount] = gentr->eta(); - gencount++; - } - - for (reco::TrackCollection::const_iterator isotr=isoProdTracks->begin(); isotr!=isoProdTracks->end(); isotr++) - { - isoPt[isocount] = isotr->pt(); - isoPhi[isocount] = isotr->phi(); - isoEta[isocount] = isotr->eta(); - isocount++; - } - - for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr=isoPixelTracks->begin(); pixtr!=isoPixelTracks->end(); pixtr++) - { - pixPt[pixcount] = pixtr->pt(); - pixPhi[pixcount] = pixtr->phi(); - pixEta[pixcount] = pixtr->eta(); - pixcount++; - } + if (takeGenTracks_ && iEvent.id().event() % 10 == 1) { + gen = generalTracks->size(); + iso = isoProdTracks->size(); + pix = isoPixelTracks->size(); + + genPt[0] = -33; + genPhi[0] = -33; + genEta[0] = -33; + + isoPt[0] = -33; + isoPhi[0] = -33; + isoEta[0] = -33; + + pixPt[0] = -33; + pixPhi[0] = -33; + pixEta[0] = -33; + + Int_t gencount = 0, isocount = 0, pixcount = 0; + for (reco::TrackCollection::const_iterator gentr = generalTracks->begin(); gentr != generalTracks->end(); gentr++) { + genPt[gencount] = gentr->pt(); + genPhi[gencount] = gentr->phi(); + genEta[gencount] = gentr->eta(); + gencount++; + } + + for (reco::TrackCollection::const_iterator isotr = isoProdTracks->begin(); isotr != isoProdTracks->end(); isotr++) { + isoPt[isocount] = isotr->pt(); + isoPhi[isocount] = isotr->phi(); + isoEta[isocount] = isotr->eta(); + isocount++; } - tTree -> Fill(); + for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr = isoPixelTracks->begin(); + pixtr != isoPixelTracks->end(); + pixtr++) { + pixPt[pixcount] = pixtr->pt(); + pixPhi[pixcount] = pixtr->phi(); + pixEta[pixcount] = pixtr->eta(); + pixcount++; + } + } + tTree->Fill(); } // ------------ method called once each job just before starting event loop ------------ -void -ValidIsoTrkCalib::beginJob() -{ - +void ValidIsoTrkCalib::beginJob() { // if(!ReadCalibFactors(calibFactorsFileName_.c_str() )) {cout<<"Cant read file with cailib coefficients!! ---"< recalibCorrs; -// iSetup.get().get("recalibrate",recalibCorrs); -// respRecalib = recalibCorrs.product(); -// -// LogInfo("CalibConstants")<<" Loaded: OK "; -// -// }catch(const cms::Exception & e) { -// LogWarning("CalibConstants")<<" Not Found!! "; -// } - - - // rootFile = new TFile(outputFileName_.c_str(),"RECREATE"); - - //@@@@@@@@@@@@@ + // try{ + // edm::ESHandle recalibCorrs; + // iSetup.get().get("recalibrate",recalibCorrs); + // respRecalib = recalibCorrs.product(); + // + // LogInfo("CalibConstants")<<" Loaded: OK "; + // + // }catch(const cms::Exception & e) { + // LogWarning("CalibConstants")<<" Not Found!! "; + // } + + // rootFile = new TFile(outputFileName_.c_str(),"RECREATE"); + + //@@@@@@@@@@@@@ //TFileDirectory ValDir = fs->mkdir("Validation"); - - nTracks = fs->make("nTracks","general;number of general tracks",11,-0.5,10.5); - - tTree = fs->make("tTree", "Tree for gen info"); + nTracks = fs->make("nTracks", "general;number of general tracks", 11, -0.5, 10.5); + + tTree = fs->make("tTree", "Tree for gen info"); + + fTree = fs->make("fTree", "Tree for IsoTrack Calibration"); - fTree = fs->make("fTree", "Tree for IsoTrack Calibration"); - fTree->Branch("eventNumber", &eventNumber, "eventNumber/I"); fTree->Branch("runNumber", &runNumber, "runNumber/I"); - fTree->Branch("eClustBefore", &eClustBefore,"eClustBefore/F"); - fTree->Branch("eClustAfter", &eClustAfter,"eClustAfter/F"); + fTree->Branch("eClustBefore", &eClustBefore, "eClustBefore/F"); + fTree->Branch("eClustAfter", &eClustAfter, "eClustAfter/F"); fTree->Branch("eTrack", &eTrack, "eTrack/F"); fTree->Branch("etaTrack", &etaTrack, "etaTrack/F"); fTree->Branch("phiTrack", &phiTrack, "phiTrack/F"); - + fTree->Branch("numHits", &numHits, "numHits/I"); fTree->Branch("eECAL", &eECAL, "eECAL/F"); fTree->Branch("PtNearBy", &PtNearBy, "PtNearBy/F"); fTree->Branch("numValidTrkHits", &numValidTrkHits, "numValidTrkHits/F"); fTree->Branch("numValidTrkStrips", &numValidTrkStrips, "numValidTrkStrips/F"); - + fTree->Branch("eBeforeDepth1", &eBeforeDepth1, "eBeforeDepth1/F"); fTree->Branch("eBeforeDepth2", &eBeforeDepth2, "eBeforeDepth2/F"); fTree->Branch("eAfterDepth1", &eAfterDepth1, "eAfterDepth1/F"); fTree->Branch("eAfterDepth2", &eAfterDepth2, "eAfterDepth2/F"); - + fTree->Branch("e3x3Before", &e3x3Before, "e3x3Before/F"); fTree->Branch("e3x3After", &e3x3After, "e3x3After/F"); fTree->Branch("e5x5Before", &e5x5Before, "e5x5Before/F"); fTree->Branch("e5x5After", &e5x5After, "e5x5After/F"); - + fTree->Branch("eCentHitAfter", &eCentHitAfter, "eCentHitAfter/F"); fTree->Branch("eCentHitBefore", &eCentHitBefore, "eCentHitBefore/F"); fTree->Branch("iEta", &iEta, "iEta/I"); fTree->Branch("iPhi", &iPhi, "iPhi/I"); - fTree->Branch("iEtaTr", &iEtaTr, "iEtaTr/I"); fTree->Branch("iPhiTr", &iPhiTr, "iPhiTr/I"); fTree->Branch("dietatr", &dietatr, "dietatr/I"); @@ -844,39 +783,33 @@ ValidIsoTrkCalib::beginJob() fTree->Branch("iTime", &iTime, "iTime/F"); fTree->Branch("HTime", HTime, "HTime[numHits]/F"); - fTree->Branch("xTrkEcal", &xTrkEcal, "xTrkEcal/F"); - fTree->Branch("yTrkEcal", &yTrkEcal, "yTrkEcal/F"); - fTree->Branch("zTrkEcal", &zTrkEcal, "zTrkEcal/F"); - fTree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F"); - fTree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F"); - fTree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F"); + fTree->Branch("xTrkEcal", &xTrkEcal, "xTrkEcal/F"); + fTree->Branch("yTrkEcal", &yTrkEcal, "yTrkEcal/F"); + fTree->Branch("zTrkEcal", &zTrkEcal, "zTrkEcal/F"); + fTree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F"); + fTree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F"); + fTree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F"); - if(takeGenTracks_) { + if (takeGenTracks_) { tTree->Branch("gen", &gen, "gen/I"); tTree->Branch("iso", &iso, "iso/I"); tTree->Branch("pix", &pix, "pix/I"); tTree->Branch("genPt", genPt, "genPt[gen]/F"); tTree->Branch("genPhi", genPhi, "genPhi[gen]/F"); tTree->Branch("genEta", genEta, "genEta[gen]/F"); - + tTree->Branch("isoPt", isoPt, "isoPt[iso]/F"); tTree->Branch("isoPhi", isoPhi, "isoPhi[iso]/F"); tTree->Branch("isoEta", isoEta, "isoEta[iso]/F"); - + tTree->Branch("pixPt", pixPt, "pixPt[pix]/F"); tTree->Branch("pixPhi", pixPhi, "pixPhi[pix]/F"); tTree->Branch("pixEta", pixEta, "pixEta[pix]/F"); } - - } - - // ------------ method called once each job just after ending the event loop ------------ -void -ValidIsoTrkCalib::endJob() -{ +void ValidIsoTrkCalib::endJob() { // rootFile->Write(); //rootFile->Close(); } diff --git a/Calibration/HcalCalibAlgos/src/HcalConstantsXMLWriter.cc b/Calibration/HcalCalibAlgos/src/HcalConstantsXMLWriter.cc index 9574f0d109522..566e853e568a8 100644 --- a/Calibration/HcalCalibAlgos/src/HcalConstantsXMLWriter.cc +++ b/Calibration/HcalCalibAlgos/src/HcalConstantsXMLWriter.cc @@ -12,123 +12,115 @@ #include #include - #include "CondTools/Hcal/interface/StreamOutFormatTarget.h" #include #include using namespace std; using namespace xercesc; -HcalConstantsXMLWriter::HcalConstantsXMLWriter() -{ -} -HcalConstantsXMLWriter::~HcalConstantsXMLWriter() -{ -} -void HcalConstantsXMLWriter::writeXML(string& newfile0,const vector& detvec,const vector& etavec,const vector& phivec,const vector& depthvec,const vector& scalevec) -{ - int nn = newfile0.size(); - char newfile[99]; - for (int i = 0; i < nn; i++) - { - newfile[i]=newfile0[i]; - } - char const* fend="\0"; - newfile[nn] = *fend; - - cout<<" New file "< mDom( DOMImplementationRegistry::getDOMImplementation (tempStr)); - - XMLString::transcode("CalibrationConstants", tempStr, 99); - mDoc = mDom->createDocument( - nullptr, // root element namespace URI. - tempStr, // root element name - nullptr); // document type object (DTD). - - StreamOutFormatTarget formTarget (fOut); - DOMLSSerializer* domWriter = mDom->createLSSerializer(); - domWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); - DOMElement* root = mDoc->getDocumentElement(); - - XMLString::transcode("Hcal", tempStr, 99); - DOMElement* rootelem = mDoc->createElement (tempStr); - root->appendChild(rootelem); - - XMLString::transcode("Cell", tempStr, 99); - vector theDOMVec; - - for(unsigned int i=0; icreateElement (tempStr)); - newCellLine(theDOMVec[i],detvec[i],etavec[i],phivec[i],depthvec[i],scalevec[i]); - rootelem->appendChild(theDOMVec[i]); - } - - cout<<" Write Doc "<createLSOutput(); - output->setByteStream(&formTarget); - domWriter->write (mDoc, output); - cout<<" End of Writting "<release (); - output->release(); - domWriter->release(); +HcalConstantsXMLWriter::HcalConstantsXMLWriter() {} +HcalConstantsXMLWriter::~HcalConstantsXMLWriter() {} +void HcalConstantsXMLWriter::writeXML(string& newfile0, + const vector& detvec, + const vector& etavec, + const vector& phivec, + const vector& depthvec, + const vector& scalevec) { + int nn = newfile0.size(); + char newfile[99]; + for (int i = 0; i < nn; i++) { + newfile[i] = newfile0[i]; + } + char const* fend = "\0"; + newfile[nn] = *fend; + + cout << " New file " << newfile << endl; + + filebuf fb; + fb.open(newfile, ios::out); + ostream fOut(&fb); + + XMLCh tempStr[100]; + + XMLString::transcode("Core", tempStr, 99); + unique_ptr mDom(DOMImplementationRegistry::getDOMImplementation(tempStr)); + + XMLString::transcode("CalibrationConstants", tempStr, 99); + mDoc = mDom->createDocument(nullptr, // root element namespace URI. + tempStr, // root element name + nullptr); // document type object (DTD). + + StreamOutFormatTarget formTarget(fOut); + DOMLSSerializer* domWriter = mDom->createLSSerializer(); + domWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); + DOMElement* root = mDoc->getDocumentElement(); + + XMLString::transcode("Hcal", tempStr, 99); + DOMElement* rootelem = mDoc->createElement(tempStr); + root->appendChild(rootelem); + + XMLString::transcode("Cell", tempStr, 99); + vector theDOMVec; + + for (unsigned int i = 0; i < detvec.size(); i++) { + theDOMVec.push_back(mDoc->createElement(tempStr)); + newCellLine(theDOMVec[i], detvec[i], etavec[i], phivec[i], depthvec[i], scalevec[i]); + rootelem->appendChild(theDOMVec[i]); + } + + cout << " Write Doc " << theDOMVec.size() << endl; + DOMLSOutput* output = mDom->createLSOutput(); + output->setByteStream(&formTarget); + domWriter->write(mDoc, output); + cout << " End of Writting " << endl; + mDoc->release(); + output->release(); + domWriter->release(); } -void HcalConstantsXMLWriter::newCellLine(DOMElement* detelem, int det, int eta, int phi, int depth, float scale) -{ - XMLCh tempStr[100]; - XMLString::transcode("det_index", tempStr, 99); - DOMAttr* attrdet = mDoc->createAttribute(tempStr); - - XMLString::transcode("eta_index", tempStr, 99); - DOMAttr* attreta = mDoc->createAttribute(tempStr); - - XMLString::transcode("phi_index", tempStr, 99); - DOMAttr* attrphi = mDoc->createAttribute(tempStr) ; - - XMLString::transcode("depth_index", tempStr, 99); - DOMAttr* attrdepth = mDoc->createAttribute(tempStr) ; - - XMLString::transcode("scale_factor", tempStr, 99); - DOMAttr* attrscale = mDoc->createAttribute(tempStr) ; - - ostringstream ost; - ost <setValue(XMLString::transcode(ost.str().c_str())); - detelem->setAttributeNode(attrdet); - - ostringstream ost1; - ost1 <setValue(XMLString::transcode(ost1.str().c_str())); - //DOMAttr* attr3 = detelem->setAttributeNode(attreta); - detelem->setAttributeNode(attreta); - - ostringstream ost2; - ost2 <setValue(XMLString::transcode(ost2.str().c_str())); - //DOMAttr* attr4 = detelem->setAttributeNode(attrphi); - detelem->setAttributeNode(attrphi); - - ostringstream ost3; - ost3 <setValue(XMLString::transcode(ost3.str().c_str())); - //DOMAttr* attr5 = detelem->setAttributeNode(attrdepth); - detelem->setAttributeNode(attrdepth); - - ostringstream ost4; - ost4 << scale; - attrscale->setValue(XMLString::transcode(ost4.str().c_str())); - //DOMAttr* attr6 = detelem->setAttributeNode(attrscale); - detelem->setAttributeNode(attrscale); - +void HcalConstantsXMLWriter::newCellLine(DOMElement* detelem, int det, int eta, int phi, int depth, float scale) { + XMLCh tempStr[100]; + XMLString::transcode("det_index", tempStr, 99); + DOMAttr* attrdet = mDoc->createAttribute(tempStr); + + XMLString::transcode("eta_index", tempStr, 99); + DOMAttr* attreta = mDoc->createAttribute(tempStr); + + XMLString::transcode("phi_index", tempStr, 99); + DOMAttr* attrphi = mDoc->createAttribute(tempStr); + + XMLString::transcode("depth_index", tempStr, 99); + DOMAttr* attrdepth = mDoc->createAttribute(tempStr); + + XMLString::transcode("scale_factor", tempStr, 99); + DOMAttr* attrscale = mDoc->createAttribute(tempStr); + + ostringstream ost; + ost << det; + attrdet->setValue(XMLString::transcode(ost.str().c_str())); + detelem->setAttributeNode(attrdet); + + ostringstream ost1; + ost1 << eta; + attreta->setValue(XMLString::transcode(ost1.str().c_str())); + //DOMAttr* attr3 = detelem->setAttributeNode(attreta); + detelem->setAttributeNode(attreta); + + ostringstream ost2; + ost2 << phi; + attrphi->setValue(XMLString::transcode(ost2.str().c_str())); + //DOMAttr* attr4 = detelem->setAttributeNode(attrphi); + detelem->setAttributeNode(attrphi); + + ostringstream ost3; + ost3 << depth; + attrdepth->setValue(XMLString::transcode(ost3.str().c_str())); + //DOMAttr* attr5 = detelem->setAttributeNode(attrdepth); + detelem->setAttributeNode(attrdepth); + + ostringstream ost4; + ost4 << scale; + attrscale->setValue(XMLString::transcode(ost4.str().c_str())); + //DOMAttr* attr6 = detelem->setAttributeNode(attrscale); + detelem->setAttributeNode(attrscale); } - - diff --git a/Calibration/HcalCalibAlgos/src/TCell.h b/Calibration/HcalCalibAlgos/src/TCell.h index edde139f47a94..e5420dc221156 100644 --- a/Calibration/HcalCalibAlgos/src/TCell.h +++ b/Calibration/HcalCalibAlgos/src/TCell.h @@ -8,30 +8,33 @@ // cell id and energy for the HCAL calibration ntuples #ifndef _TCELL_H -#define _TCELL_H +#define _TCELL_H #include "TObject.h" class TCell : public TObject { - private: - UInt_t _id; - Float_t _e; - + UInt_t _id; + Float_t _e; + public: - TCell() { _id=0; _e=0.0; } - ~TCell() override {}; - TCell(UInt_t i, Float_t e) { _id=i; _e=e; } - - Float_t e() { return _e; } - UInt_t id() { return _id; } - - void SetE(Float_t e) { _e=e; } - void SetId(UInt_t i) { _id=i; } - - - ClassDefOverride(TCell, 1); -}; + TCell() { + _id = 0; + _e = 0.0; + } + ~TCell() override{}; + TCell(UInt_t i, Float_t e) { + _id = i; + _e = e; + } + + Float_t e() { return _e; } + UInt_t id() { return _id; } -#endif /* _TCELL_H */ + void SetE(Float_t e) { _e = e; } + void SetId(UInt_t i) { _id = i; } + + ClassDefOverride(TCell, 1); +}; +#endif /* _TCELL_H */ diff --git a/Calibration/HcalCalibAlgos/src/classes.h b/Calibration/HcalCalibAlgos/src/classes.h index e73880e7782df..8a8c57566aad9 100644 --- a/Calibration/HcalCalibAlgos/src/classes.h +++ b/Calibration/HcalCalibAlgos/src/classes.h @@ -1,6 +1,5 @@ #include "Calibration/HcalCalibAlgos/src/TCell.h" namespace Calibration_HcalCalibAlgos { - struct dictionary { - }; -} + struct dictionary {}; +} // namespace Calibration_HcalCalibAlgos diff --git a/Calibration/HcalCalibAlgos/src/hcalCalib.cc b/Calibration/HcalCalibAlgos/src/hcalCalib.cc index d83c2aa0e27ba..1f8506b81e35f 100644 --- a/Calibration/HcalCalibAlgos/src/hcalCalib.cc +++ b/Calibration/HcalCalibAlgos/src/hcalCalib.cc @@ -36,7 +36,6 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" - using namespace std; UInt_t nEvents; @@ -65,140 +64,146 @@ TH2F* h2_dHitRefEndcap; // expect range |iEta|<=24 (to do: add flexibility for arbitrary range) TH1F* h1_corRespIEta[48]; - -void hcalCalib::Begin(TTree * /*tree*/) { +void hcalCalib::Begin(TTree* /*tree*/) { TString option = GetOption(); nEvents = 0; if (APPLY_PHI_SYM_COR_FLAG && !ReadPhiSymCor()) { cout << "\nERROR: Failed to read the phi symmetry corrections." << endl; - cout << "Check if the filename is correct. If the corrections are not needed, set the corresponding flag to \"false\"\n" << endl; + cout << "Check if the filename is correct. If the corrections are not needed, set the corresponding flag to " + "\"false\"\n" + << endl; cout << "\nThe program will be terminated\n" << endl; exit(1); - } - // cellEnergies.reserve(1000000); // cellIds.reserve(1000000); // targetEnergies.reserve(1000000); - - histoFile = new TFile(HISTO_FILENAME.Data(), "RECREATE"); + histoFile = new TFile(HISTO_FILENAME.Data(), "RECREATE"); - h1_trkP = new TH1F("h1_trkP", "Track momenta; p_{trk} (GeV); Number of tracks", 100, 0, 200); + h1_trkP = new TH1F("h1_trkP", "Track momenta; p_{trk} (GeV); Number of tracks", 100, 0, 200); h1_allTrkP = new TH1F("h1_allTrkP", "Track momenta - all tracks; p_{trk} (GeV); Number of tracks", 100, 0, 200); - h1_selTrkP_iEta10 = new TH1F("h1_selTrkP_iEta10", "Track momenta - tracks with |iEta|<10; p_{trk} (GeV); Number of tracks", 100, 0, 200); - + h1_selTrkP_iEta10 = new TH1F( + "h1_selTrkP_iEta10", "Track momenta - tracks with |iEta|<10; p_{trk} (GeV); Number of tracks", 100, 0, 200); - - if (CALIB_TYPE=="ISO_TRACK") + if (CALIB_TYPE == "ISO_TRACK") h1_rawSumE = new TH1F("h1_rawSumE", "Cluster Energy; E_{cl} (GeV); Number of tracks", 100, 0, 200); - else - h1_rawSumE = new TH1F("h1_rawSumE", "Cluster Energy; E_{cl} (GeV); Number of tracks", 1000, 0, 2000); - - + else + h1_rawSumE = new TH1F("h1_rawSumE", "Cluster Energy; E_{cl} (GeV); Number of tracks", 1000, 0, 2000); h1_rawResp = new TH1F("h1_rawResp", "Uncorrected response: |iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); h1_corResp = new TH1F("h1_corResp", "Corrected response: |iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); - - h1_rawRespBarrel = new TH1F("h1_rawRespBarrel", "Uncorrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3); - h1_corRespBarrel = new TH1F("h1_corRespBarrel", "Corrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3); - - h1_rawRespEndcap = new TH1F("h1_rawRespEndcap", "Uncorrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); - h1_corRespEndcap = new TH1F("h1_corRespEndcap", "Corrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); - - h1_numEventsTwrIEta = new TH1F("h1_numEventsTwrIEta", "h1_numEventsTwrIEta", 80, -40, 40); - h2_dHitRefBarrel = new TH2F("h2_dHitRefBarrel","{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic tower(|i{#eta}|<16);{#Delta}i{#eta}; {#Delta}i{#phi}", 10, -5, 5, 10, -5, 5); - h2_dHitRefEndcap = new TH2F("h2_dHitRefEndcap","{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic tower (16<|i{#eta}|<25) ;{#Delta}i{#eta}; {#Delta}i{#phi}", 10, -5, 5, 10, -5, 5); - + h1_rawRespBarrel = + new TH1F("h1_rawRespBarrel", "Uncorrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3); + h1_corRespBarrel = + new TH1F("h1_corRespBarrel", "Corrected response: |iEta|<15; E_{had}/p; Number of tracks", 300, 0, 3); + h1_rawRespEndcap = + new TH1F("h1_rawRespEndcap", "Uncorrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); + h1_corRespEndcap = + new TH1F("h1_corRespEndcap", "Corrected response: 17<|iEta|<24; E_{had}/p; Number of tracks", 300, 0, 3); + + h1_numEventsTwrIEta = new TH1F("h1_numEventsTwrIEta", "h1_numEventsTwrIEta", 80, -40, 40); + + h2_dHitRefBarrel = new TH2F("h2_dHitRefBarrel", + "{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic " + "tower(|i{#eta}|<16);{#Delta}i{#eta}; {#Delta}i{#phi}", + 10, + -5, + 5, + 10, + -5, + 5); + h2_dHitRefEndcap = new TH2F("h2_dHitRefEndcap", + "{#Delta}i{#phi} vs {#Delta}i{#eta} of hit and most energetic tower (16<|i{#eta}|<25) " + ";{#Delta}i{#eta}; {#Delta}i{#phi}", + 10, + -5, + 5, + 10, + -5, + 5); TString histoName = "isoTrack_"; - - for (Int_t i=0; i<48; ++i) { - Long_t iEta; - if (i<24) iEta = i-24; - else iEta = i-23; + + for (Int_t i = 0; i < 48; ++i) { + Long_t iEta; + if (i < 24) + iEta = i - 24; + else + iEta = i - 23; TString hn = histoName + iEta; h1_corRespIEta[i] = new TH1F(hn, hn, 300, 0, 3.0); } - } // end of Begin() - - //void hcalCalib::SlaveBegin(TTree * /*tree*/) { // TString option = GetOption(); //} - Bool_t hcalCalib::Process(Long64_t entry) { - // fChain->GetTree()->GetEntry(entry); GetEntry(entry); + set uniqueIds; // for testing: check if there are duplicate cells (AA) - set uniqueIds; // for testing: check if there are duplicate cells (AA) - - Bool_t acceptEvent = kTRUE; - - ++nEvents; - if (!(nEvents%100000)) cout << "event: " << nEvents << endl; + ++nEvents; + if (!(nEvents % 100000)) + cout << "event: " << nEvents << endl; h1_allTrkP->Fill(targetE); - - if (targetE < MIN_TARGET_E || targetE > MAX_TARGET_E) return kFALSE;; - - // make local copy as the cells may be modified due to phi/depth sum, phi corrections etc - vector selectCells; + if (targetE < MIN_TARGET_E || targetE > MAX_TARGET_E) + return kFALSE; + ; + // make local copy as the cells may be modified due to phi/depth sum, phi corrections etc + vector selectCells; - if (cells->GetSize()==0) return kFALSE; + if (cells->GetSize() == 0) + return kFALSE; - if (CALIB_TYPE=="DI_JET" && probeJetEmFrac > 0.999) return kTRUE; - + if (CALIB_TYPE == "DI_JET" && probeJetEmFrac > 0.999) + return kTRUE; - for (Int_t i=0; iGetSize(); ++i) { - TCell* thisCell = (TCell*) cells->At(i); + for (Int_t i = 0; i < cells->GetSize(); ++i) { + TCell* thisCell = (TCell*)cells->At(i); - if (HcalDetId(thisCell->id()).subdet()== HcalOuter) continue; // reject HO, make a switch! + if (HcalDetId(thisCell->id()).subdet() == HcalOuter) + continue; // reject HO, make a switch! - if (HcalDetId(thisCell->id()).subdet() != HcalBarrel && - HcalDetId(thisCell->id()).subdet() != HcalEndcap && - HcalDetId(thisCell->id()).subdet() != HcalForward) { - + if (HcalDetId(thisCell->id()).subdet() != HcalBarrel && HcalDetId(thisCell->id()).subdet() != HcalEndcap && + HcalDetId(thisCell->id()).subdet() != HcalForward) { cout << "Unknown or wrong hcal subdetector: " << HcalDetId(thisCell->id()).subdet() << endl; - } - // Apply phi symmetry corrections if the flag is set - if (APPLY_PHI_SYM_COR_FLAG) thisCell->SetE(phiSymCor[thisCell->id()] * thisCell->e()); + if (APPLY_PHI_SYM_COR_FLAG) + thisCell->SetE(phiSymCor[thisCell->id()] * thisCell->e()); - if (thisCell->e() > MIN_CELL_E) selectCells.push_back(*thisCell); + if (thisCell->e() > MIN_CELL_E) + selectCells.push_back(*thisCell); } - if (selectCells.empty()) { cout << "NO CELLS ABOVE THRESHOLD FOUND FOR TARGET!!!" << endl; } - - if (SUM_DEPTHS) sumDepths(selectCells); - else if (SUM_SMALL_DEPTHS) sumSmallDepths(selectCells); // depth 1,2 in twrs 15,16 - - + if (SUM_DEPTHS) + sumDepths(selectCells); + else if (SUM_SMALL_DEPTHS) + sumSmallDepths(selectCells); // depth 1,2 in twrs 15,16 // most energetic tower (IsoTracks) or centroid of probe jet (DiJets) pair refPos; @@ -206,167 +211,166 @@ Bool_t hcalCalib::Process(Long64_t entry) { Int_t dEtaHitRef = 999; Int_t dPhiHitRef = 999; - if (CALIB_TYPE=="ISO_TRACK") { + if (CALIB_TYPE == "ISO_TRACK") { + Int_t iEtaMaxE; // filled by reference in getIEtaIPhiForHighestE + UInt_t iPhiMaxE; // + + getIEtaIPhiForHighestE(selectCells, iEtaMaxE, iPhiMaxE); - Int_t iEtaMaxE; // filled by reference in getIEtaIPhiForHighestE - UInt_t iPhiMaxE; // - - getIEtaIPhiForHighestE(selectCells, iEtaMaxE, iPhiMaxE); - dEtaHitRef = iEtaMaxE - iEtaHit; dPhiHitRef = iPhiMaxE - iPhiHit; - if (dPhiHitRef < -36) dPhiHitRef += 72; - if (dPhiHitRef > 36) dPhiHitRef -= 72; + if (dPhiHitRef < -36) + dPhiHitRef += 72; + if (dPhiHitRef > 36) + dPhiHitRef -= 72; - if (iEtaHit*iEtaMaxE < 0) { - if (dEtaHitRef<0) dEtaHitRef += 1; - if (dEtaHitRef>0) dEtaHitRef -= 1; + if (iEtaHit * iEtaMaxE < 0) { + if (dEtaHitRef < 0) + dEtaHitRef += 1; + if (dEtaHitRef > 0) + dEtaHitRef -= 1; } - - if (abs(iEtaHit)<16) h2_dHitRefBarrel->Fill(dEtaHitRef, dPhiHitRef); - if (abs(iEtaHit)>16 && abs(iEtaHit)<25) h2_dHitRefEndcap->Fill(dEtaHitRef, dPhiHitRef); + if (abs(iEtaHit) < 16) + h2_dHitRefBarrel->Fill(dEtaHitRef, dPhiHitRef); + if (abs(iEtaHit) > 16 && abs(iEtaHit) < 25) + h2_dHitRefEndcap->Fill(dEtaHitRef, dPhiHitRef); // -------------------------------------------------- - // Choice of cluster definition + // Choice of cluster definition // - // fixed size NxN clusters as specified in to config file + // fixed size NxN clusters as specified in to config file if (!USE_CONE_CLUSTERING) { - if (abs(iEtaMaxE)<16 && HB_CLUSTER_SIZE==3) filterCells3x3(selectCells, iEtaMaxE, iPhiMaxE); - if (abs(iEtaMaxE)>15 && HE_CLUSTER_SIZE==3) filterCells3x3(selectCells, iEtaMaxE, iPhiMaxE); - - if (abs(iEtaMaxE)<16 && HB_CLUSTER_SIZE==5) filterCells5x5(selectCells, iEtaMaxE, iPhiMaxE); - if (abs(iEtaMaxE)>15 && HE_CLUSTER_SIZE==5) filterCells5x5(selectCells, iEtaMaxE, iPhiMaxE); - } - else { + if (abs(iEtaMaxE) < 16 && HB_CLUSTER_SIZE == 3) + filterCells3x3(selectCells, iEtaMaxE, iPhiMaxE); + if (abs(iEtaMaxE) > 15 && HE_CLUSTER_SIZE == 3) + filterCells3x3(selectCells, iEtaMaxE, iPhiMaxE); + + if (abs(iEtaMaxE) < 16 && HB_CLUSTER_SIZE == 5) + filterCells5x5(selectCells, iEtaMaxE, iPhiMaxE); + if (abs(iEtaMaxE) > 15 && HE_CLUSTER_SIZE == 5) + filterCells5x5(selectCells, iEtaMaxE, iPhiMaxE); + } else { // calculate distance at hcal surface - const GlobalPoint hitPositionHcal(xTrkHcal, yTrkHcal, zTrkHcal); + const GlobalPoint hitPositionHcal(xTrkHcal, yTrkHcal, zTrkHcal); filterCellsInCone(selectCells, hitPositionHcal, MAX_CONE_DIST, theCaloGeometry); } - - - refPos.first = iEtaMaxE; + refPos.first = iEtaMaxE; refPos.second = iPhiMaxE; - } - else if (CALIB_TYPE=="DI_JET") { // Apply selection cuts on DiJet events here + } else if (CALIB_TYPE == "DI_JET") { // Apply selection cuts on DiJet events here - if (etVetoJet>MAX_ET_THIRD_JET) acceptEvent = kFALSE; - - Float_t jetsDPhi = probeJetP4->DeltaPhi(*tagJetP4); - if (fabs(jetsDPhi * 180.0/M_PI) < MIN_DPHI_DIJETS) acceptEvent = kFALSE; + if (etVetoJet > MAX_ET_THIRD_JET) + acceptEvent = kFALSE; - if (probeJetEmFrac>MAX_PROBEJET_EMFRAC) acceptEvent = kFALSE; - if (fabs(probeJetP4->Eta())Eta())>MAX_TAGJET_ABSETA) acceptEvent = kFALSE; - if (fabs(tagJetP4->Et())< MIN_TAGJET_ET) acceptEvent = kFALSE; + Float_t jetsDPhi = probeJetP4->DeltaPhi(*tagJetP4); + if (fabs(jetsDPhi * 180.0 / M_PI) < MIN_DPHI_DIJETS) + acceptEvent = kFALSE; + + if (probeJetEmFrac > MAX_PROBEJET_EMFRAC) + acceptEvent = kFALSE; + if (fabs(probeJetP4->Eta()) < MIN_PROBEJET_ABSETA) + acceptEvent = kFALSE; + if (fabs(tagJetP4->Eta()) > MAX_TAGJET_ABSETA) + acceptEvent = kFALSE; + if (fabs(tagJetP4->Et()) < MIN_TAGJET_ET) + acceptEvent = kFALSE; if (acceptEvent) { + Int_t iEtaMaxE; // filled by reference in getIEtaIPhiForHighestE + UInt_t iPhiMaxE; // + + getIEtaIPhiForHighestE(selectCells, iEtaMaxE, iPhiMaxE); - Int_t iEtaMaxE; // filled by reference in getIEtaIPhiForHighestE - UInt_t iPhiMaxE; // - - getIEtaIPhiForHighestE(selectCells, iEtaMaxE, iPhiMaxE); - // The ref position for the jet is not used in the minimization at this time. // It will be needed if we attempt to do matrix inversion: then the question is // which value is better suited: the centroid of the jet or the hottest tower... // refPos.first = iEtaHit; // refPos.second = iPhiHit; - - refPos.first = iEtaMaxE; - refPos.second = iPhiMaxE; - - if (abs(iEtaMaxE)>40) acceptEvent = kFALSE; // for testing : set as parameter (AA) - } + refPos.first = iEtaMaxE; + refPos.second = iPhiMaxE; + if (abs(iEtaMaxE) > 40) + acceptEvent = kFALSE; // for testing : set as parameter (AA) + } } + if (COMBINE_PHI) + combinePhi(selectCells); - if (COMBINE_PHI) combinePhi(selectCells); - // fill the containers for the minimization prcedures vector energies; - vector ids; - - for (vector::iterator i_it = selectCells.begin(); i_it!=selectCells.end(); ++i_it) { + vector ids; + for (vector::iterator i_it = selectCells.begin(); i_it != selectCells.end(); ++i_it) { // for testing : fill only unique id's if (uniqueIds.insert(i_it->id()).second) { energies.push_back(i_it->e()); ids.push_back(i_it->id()); } - } - if (CALIB_TYPE=="ISO_TRACK") { - if (accumulate(energies.begin(), energies.end(), 0.0) / targetE < MIN_EOVERP) acceptEvent=kFALSE; - if (accumulate(energies.begin(), energies.end(), 0.0) / targetE > MAX_EOVERP) acceptEvent=kFALSE; + if (CALIB_TYPE == "ISO_TRACK") { + if (accumulate(energies.begin(), energies.end(), 0.0) / targetE < MIN_EOVERP) + acceptEvent = kFALSE; + if (accumulate(energies.begin(), energies.end(), 0.0) / targetE > MAX_EOVERP) + acceptEvent = kFALSE; - if (emEnergy > MAX_TRK_EME) acceptEvent=kFALSE; + if (emEnergy > MAX_TRK_EME) + acceptEvent = kFALSE; - if (abs(dEtaHitRef)>1 || abs(dPhiHitRef)>1) acceptEvent=kFALSE; + if (abs(dEtaHitRef) > 1 || abs(dPhiHitRef) > 1) + acceptEvent = kFALSE; // Have to check if for |iEta|>20 (and neighboring region) the dPhiHitRef // should be relaxed to 2. The neighboring towers have dPhi=2... - - } - h1_rawSumE->Fill(accumulate(energies.begin(), energies.end(), 0.0)); - - + // here we fill the information for the minimization procedure - if (acceptEvent) { + if (acceptEvent) { cellEnergies.push_back(energies); cellIds.push_back(ids); targetEnergies.push_back(targetE); refIEtaIPhi.push_back(refPos); - if (abs(refPos.first)<=10) + if (abs(refPos.first) <= 10) h1_selTrkP_iEta10->Fill(targetE); - - } - - - // Clean up energies.clear(); ids.clear(); selectCells.clear(); - + return kTRUE; } //void hcalCalib::SlaveTerminate() {} void hcalCalib::Terminate() { - cout << "\n\nFinished reading the events.\n"; - cout << "Number of input objects: " << cellIds.size() << endl; + cout << "Number of input objects: " << cellIds.size() << endl; cout << "Performing minimization: depending on selected method can take some time...\n\n"; - - for (vector >::iterator it_rp=refIEtaIPhi.begin(); it_rp!=refIEtaIPhi.end(); ++it_rp ) { - Float_t weight = (abs(it_rp->first)<21)? 1.0/72.0 : 1.0/36.0; + + for (vector >::iterator it_rp = refIEtaIPhi.begin(); it_rp != refIEtaIPhi.end(); ++it_rp) { + Float_t weight = (abs(it_rp->first) < 21) ? 1.0 / 72.0 : 1.0 / 36.0; h1_numEventsTwrIEta->Fill(it_rp->first, weight); } - - if (CALIB_METHOD=="MATRIX_INV_OF_ETA_AVE") { + + if (CALIB_METHOD == "MATRIX_INV_OF_ETA_AVE") { GetCoefFromMtrxInvOfAve(); - } - else if (CALIB_METHOD=="L3" || CALIB_METHOD=="L3_AND_MTRX_INV") { + } else if (CALIB_METHOD == "L3" || CALIB_METHOD == "L3_AND_MTRX_INV") { int eventWeight = 2; // 2 is the default (try at some point 0,1,2,3) MinL3AlgoUniv* thisL3Algo = new MinL3AlgoUniv(eventWeight); int numIterations = 10; // default 10 - + solution = thisL3Algo->iterate(cellEnergies, cellIds, targetEnergies, numIterations); // in order to handle the case where sumDepths="false", but the flag to sum depths 1,2 in HB towers 15, 16 @@ -377,115 +381,109 @@ void hcalCalib::Terminate() { vector idForSummedCells; for (map::iterator m_it = solution.begin(); m_it != solution.end(); ++m_it) { - if (HcalDetId(m_it->first).ietaAbs()!=15 && HcalDetId(m_it->first).ietaAbs()!=16) continue; - if (HcalDetId(m_it->first).subdet()!=HcalBarrel) continue; - if (HcalDetId(m_it->first).depth()==1) - idForSummedCells.push_back(HcalDetId(m_it->first)); + if (HcalDetId(m_it->first).ietaAbs() != 15 && HcalDetId(m_it->first).ietaAbs() != 16) + continue; + if (HcalDetId(m_it->first).subdet() != HcalBarrel) + continue; + if (HcalDetId(m_it->first).depth() == 1) + idForSummedCells.push_back(HcalDetId(m_it->first)); } - for (vector::iterator v_it=idForSummedCells.begin(); v_it!=idForSummedCells.end(); ++v_it) { - UInt_t addCoefId = HcalDetId(HcalBarrel, HcalDetId(*v_it).ieta(), HcalDetId(*v_it).iphi(), 2); - solution[addCoefId] = solution[*v_it]; + for (vector::iterator v_it = idForSummedCells.begin(); v_it != idForSummedCells.end(); ++v_it) { + UInt_t addCoefId = HcalDetId(HcalBarrel, HcalDetId(*v_it).ieta(), HcalDetId(*v_it).iphi(), 2); + solution[addCoefId] = solution[*v_it]; } - + } // end of special treatment for "sumSmallDepths" mode + if (CALIB_METHOD == "L3_AND_MTRX_INV") { + GetCoefFromMtrxInvOfAve(); - if (CALIB_METHOD=="L3_AND_MTRX_INV") { - GetCoefFromMtrxInvOfAve(); - // loop over the solution from L3 and multiply by the additional factor from - // the matrix inversion. Set coef outside of the valid calibration region =1. - for (map::iterator it_s=solution.begin(); it_s!=solution.end(); ++it_s) { - Int_t iEtaSol = HcalDetId(it_s->first).ieta(); - if (abs(iEtaSol) CALIB_ABS_IETA_MAX) it_s->second = 1.0; - else it_s->second *= iEtaCoefMap[iEtaSol]; - } - - } // if CALIB_METHOD=="L3_AND_MTRX_INV" - + // the matrix inversion. Set coef outside of the valid calibration region =1. + for (map::iterator it_s = solution.begin(); it_s != solution.end(); ++it_s) { + Int_t iEtaSol = HcalDetId(it_s->first).ieta(); + if (abs(iEtaSol) < CALIB_ABS_IETA_MIN || abs(iEtaSol) > CALIB_ABS_IETA_MAX) + it_s->second = 1.0; + else + it_s->second *= iEtaCoefMap[iEtaSol]; + } + + } // if CALIB_METHOD=="L3_AND_MTRX_INV" + } // end of L3 or L3 + mtrx inversion minimization // done getting the constants -> write the formatted file makeTextFile(); - + // fill some histograms Float_t rawResp = 0; Float_t corResp = 0; Int_t maxIEta = 0; Int_t minIEta = 999; - - for (unsigned int i=0; i abs(iEta) ) minIEta = abs(iEta); + + if (maxIEta < abs(iEta)) + maxIEta = abs(iEta); + if (minIEta > abs(iEta)) + minIEta = abs(iEta); } rawResp /= targetEnergies[i]; corResp /= targetEnergies[i]; - - // fill histograms based on iEta on ref point of the cluster (for now: hottest tower) + // fill histograms based on iEta on ref point of the cluster (for now: hottest tower) // expect range |iEta|<=24 (to do: add flexibility for arbitrary range) - - if (CALIB_TYPE=="ISO_TRACK") { - Int_t ind = refIEtaIPhi[i].first; - (ind<0) ? (ind +=24) : (ind +=23); - if (ind>=0 && ind<48) { - h1_corRespIEta[ind]->Fill(corResp); + + if (CALIB_TYPE == "ISO_TRACK") { + Int_t ind = refIEtaIPhi[i].first; + (ind < 0) ? (ind += 24) : (ind += 23); + if (ind >= 0 && ind < 48) { + h1_corRespIEta[ind]->Fill(corResp); } - + // fill histograms for cases where all towers are in the barrel or endcap - if (maxIEta<25) { - h1_rawResp->Fill(rawResp); - h1_corResp->Fill(corResp); + if (maxIEta < 25) { + h1_rawResp->Fill(rawResp); + h1_corResp->Fill(corResp); } - if (maxIEta<15) { - h1_rawRespBarrel->Fill(rawResp); - h1_corRespBarrel->Fill(corResp); - } - else if (maxIEta<25 && minIEta>16) { - h1_rawRespEndcap->Fill(rawResp); - h1_corRespEndcap->Fill(corResp); + if (maxIEta < 15) { + h1_rawRespBarrel->Fill(rawResp); + h1_corRespBarrel->Fill(corResp); + } else if (maxIEta < 25 && minIEta > 16) { + h1_rawRespEndcap->Fill(rawResp); + h1_corRespEndcap->Fill(corResp); } } // histograms for isotrack calibration - else { - // put jet plots here - } - - rawResp = 0; corResp = 0; maxIEta = 0; minIEta = 999; } - - // save the histograms + // save the histograms h1_trkP->Write(); h1_allTrkP->Write(); -h1_selTrkP_iEta10->Write(); + h1_selTrkP_iEta10->Write(); h1_rawSumE->Write(); h1_rawResp->Write(); @@ -497,136 +495,122 @@ h1_selTrkP_iEta10->Write(); h1_numEventsTwrIEta->Write(); h2_dHitRefBarrel->Write(); h2_dHitRefEndcap->Write(); - for (Int_t i=0; i<48; ++i) { + for (Int_t i = 0; i < 48; ++i) { h1_corRespIEta[i]->Write(); } - - - - histoFile->Write(); histoFile->Close(); - cout << "\n Finished calibration.\n " << endl; + cout << "\n Finished calibration.\n " << endl; - } // end of Terminate() - - - //************************************************************************************************************** void hcalCalib::GetCoefFromMtrxInvOfAve() { - - // these maps are keyed by iEta - map aveTargetE; - map nEntries; // count hits - - // iEtaRef iEtaCell, energy - map > aveHitE; // add energies in the loop, normalize after that - - for (unsigned int i=0; i aveTargetE; + map nEntries; // count hits + + // iEtaRef iEtaCell, energy + map > aveHitE; // add energies in the loop, normalize after that + + for (unsigned int i = 0; i < cellEnergies.size(); ++i) { + Int_t iEtaRef = refIEtaIPhi[i].first; + aveTargetE[iEtaRef] += targetEnergies[i]; + nEntries[iEtaRef]++; + + // for hybrid method: matrix inv of averages preceeded by L3 + if (CALIB_METHOD == "L3_AND_MTRX_INV") { + for (unsigned int j = 0; j < (cellEnergies[i]).size(); ++j) { + aveHitE[iEtaRef][HcalDetId(cellIds[i][j]).ieta()] += (solution[cellIds[i][j]] * cellEnergies[i][j]); } - else if (CALIB_METHOD=="MATRIX_INV_OF_ETA_AVE") { - for (unsigned int j=0; j<(cellEnergies[i]).size(); ++j) { - aveHitE[iEtaRef][HcalDetId(cellIds[i][j]).ieta()] += cellEnergies[i][j]; - } + } else if (CALIB_METHOD == "MATRIX_INV_OF_ETA_AVE") { + for (unsigned int j = 0; j < (cellEnergies[i]).size(); ++j) { + aveHitE[iEtaRef][HcalDetId(cellIds[i][j]).ieta()] += cellEnergies[i][j]; } + } - } // end of loop of entries + } // end of loop of entries - - // scale by number of entries to get the averages - Float_t norm = 1.0; - for (map::iterator m_it = aveTargetE.begin(); m_it!=aveTargetE.end(); ++m_it){ - Int_t iEta = m_it->first; - norm = (nEntries[iEta] > 0)? 1.0/(nEntries[iEta]) : 1.0; - aveTargetE[iEta] *= norm; + // scale by number of entries to get the averages + Float_t norm = 1.0; + for (map::iterator m_it = aveTargetE.begin(); m_it != aveTargetE.end(); ++m_it) { + Int_t iEta = m_it->first; + norm = (nEntries[iEta] > 0) ? 1.0 / (nEntries[iEta]) : 1.0; + aveTargetE[iEta] *= norm; - map::iterator n_it = (aveHitE[iEta]).begin(); + map::iterator n_it = (aveHitE[iEta]).begin(); - Float_t sumRawE = 0; - for (; n_it!=(aveHitE[iEta]).end(); ++n_it) { - (n_it->second) *= norm; - sumRawE += (n_it->second); - } - - } // end of scaling by number of entries - - Int_t ONE_SIDE_IETA_RANGE = CALIB_ABS_IETA_MAX - CALIB_ABS_IETA_MIN +1; - - // conversion from iEta to index for the linear system - // contains elements only in the valid range for *matrix inversion* - vector iEtaList; - - for (Int_t i=-CALIB_ABS_IETA_MAX; i<=CALIB_ABS_IETA_MAX; ++i) { - if (abs(i)second) *= norm; + sumRawE += (n_it->second); } - for (UInt_t i=0; i::iterator n_it = aveHitE[iEtaList[i]].begin(); - for (; n_it!=aveHitE[iEtaList[i]].end(); ++n_it){ + Int_t ONE_SIDE_IETA_RANGE = CALIB_ABS_IETA_MAX - CALIB_ABS_IETA_MIN + 1; - if (fabs(n_it->first)>CALIB_ABS_IETA_MAX || fabs(n_it->first)first) - iEtaList.begin()); - A(i, j) = n_it->second; + // conversion from iEta to index for the linear system + // contains elements only in the valid range for *matrix inversion* + vector iEtaList; - } + for (Int_t i = -CALIB_ABS_IETA_MAX; i <= CALIB_ABS_IETA_MAX; ++i) { + if (abs(i) < CALIB_ABS_IETA_MIN) + continue; + iEtaList.push_back(i); + } - } + TMatrixD A(2 * ONE_SIDE_IETA_RANGE, 2 * ONE_SIDE_IETA_RANGE); + TMatrixD b(2 * ONE_SIDE_IETA_RANGE, 1); + TMatrixD x(2 * ONE_SIDE_IETA_RANGE, 1); - TMatrixD coef = b; - TDecompQRH qrh(A); - Bool_t hasSolution = qrh.MultiSolve(coef); - - if (hasSolution && (CALIB_METHOD=="L3_AND_MTRX_INV" || CALIB_METHOD=="MATRIX_INV_OF_ETA_AVE")) { - for (UInt_t i=0; i::iterator n_it = aveHitE[iEtaList[i]].begin(); + for (; n_it != aveHitE[iEtaList[i]].end(); ++n_it) { + if (fabs(n_it->first) > CALIB_ABS_IETA_MAX || fabs(n_it->first) < CALIB_ABS_IETA_MIN) + continue; + Int_t j = Int_t(find(iEtaList.begin(), iEtaList.end(), n_it->first) - iEtaList.begin()); + A(i, j) = n_it->second; + } + } + + TMatrixD coef = b; + TDecompQRH qrh(A); + Bool_t hasSolution = qrh.MultiSolve(coef); + + if (hasSolution && (CALIB_METHOD == "L3_AND_MTRX_INV" || CALIB_METHOD == "MATRIX_INV_OF_ETA_AVE")) { + for (UInt_t i = 0; i < iEtaList.size(); ++i) { + iEtaCoefMap[iEtaList[i]] = coef(i, 0); + } + } +} +Bool_t hcalCalib::ReadPhiSymCor() { std::ifstream phiSymFile(PHI_SYM_COR_FILENAME.Data()); if (!phiSymFile) { - cout << "\nERROR: Can not find file with phi symmetry constants \"" << PHI_SYM_COR_FILENAME.Data() << "\"" << endl; + cout << "\nERROR: Can not find file with phi symmetry constants \"" << PHI_SYM_COR_FILENAME.Data() << "\"" << endl; return kFALSE; } // assumes the format used in CSA08, first line is a comment - Int_t iEta; - UInt_t iPhi; - UInt_t depth; + Int_t iEta; + UInt_t iPhi; + UInt_t depth; TString sdName; - UInt_t detId; + UInt_t detId; Float_t value; HcalSubdetector sd; @@ -634,33 +618,38 @@ Bool_t hcalCalib::ReadPhiSymCor() { std::string line; while (getline(phiSymFile, line)) { - - if(line.empty() || line[0]=='#') continue; + if (line.empty() || line[0] == '#') + continue; std::istringstream linestream(line); linestream >> iEta >> iPhi >> depth >> sdName >> value >> hex >> detId; - if (sdName=="HB") sd = HcalBarrel; - else if (sdName=="HE") sd = HcalEndcap; - else if (sdName=="HO") sd = HcalOuter; - else if (sdName=="HF") sd = HcalForward; + if (sdName == "HB") + sd = HcalBarrel; + else if (sdName == "HE") + sd = HcalEndcap; + else if (sdName == "HO") + sd = HcalOuter; + else if (sdName == "HF") + sd = HcalForward; else { cout << "\nInvalid detector name in phi symmetry constants file: " << sdName.Data() << endl; cout << "Check file and rerun!\n" << endl; return kFALSE; } - // check if the data is consistent - + // check if the data is consistent + if (HcalDetId(sd, iEta, iPhi, depth) != HcalDetId(detId)) { cout << "\nInconsistent info in phi symmetry file: subdet, iEta, iPhi, depth do not match rawId!\n" << endl; - return kFALSE; + return kFALSE; } HcalDetId hId(detId); if (!topo_->valid(hId)) { - cout << "\nInvalid DetId from: iEta=" << iEta << " iPhi=" << iPhi << " depth=" << depth - << " subdet=" << sdName.Data() << " detId=" << detId << endl << endl; - return kFALSE; + cout << "\nInvalid DetId from: iEta=" << iEta << " iPhi=" << iPhi << " depth=" << depth + << " subdet=" << sdName.Data() << " detId=" << detId << endl + << endl; + return kFALSE; } phiSymCor[HcalDetId(sd, iEta, iPhi, depth)] = value; @@ -669,88 +658,77 @@ Bool_t hcalCalib::ReadPhiSymCor() { return kTRUE; } - void hcalCalib::makeTextFile() { - //{ HcalEmpty=0, HcalBarrel=1, HcalEndcap=2, HcalOuter=3, HcalForward=4, HcalTriggerTower=5, HcalOther=7 }; - - TString sdName[8] = {"EMPTY", "HB", "HE", "HO", "HF", "TRITWR", "UNDEF", "OTHER"}; - FILE *constFile = fopen(OUTPUT_COR_COEF_FILENAME.Data(), "w+"); + TString sdName[8] = {"EMPTY", "HB", "HE", "HO", "HF", "TRITWR", "UNDEF", "OTHER"}; + + FILE* constFile = fopen(OUTPUT_COR_COEF_FILENAME.Data(), "w+"); // header of the constants file - fprintf(constFile, "%1s%16s%16s%16s%16s%9s%11s\n", - "#", "eta", "phi", "depth", "det", "value", "DetId"); + fprintf(constFile, "%1s%16s%16s%16s%16s%9s%11s\n", "#", "eta", "phi", "depth", "det", "value", "DetId"); - // Order loops to produce sequence of constants as for phi symmetry - - for(Int_t sd=1; sd<=4; sd++) { + // Order loops to produce sequence of constants as for phi symmetry - for(Int_t e=1; e<=50; e++) { + for (Int_t sd = 1; sd <= 4; sd++) { + for (Int_t e = 1; e <= 50; e++) { Int_t eta; - for(Int_t side=0; side<2; side++) { - eta = (side==0)? -e : e; //ta *= (-1); - - for(Int_t phi=1; phi<=72; phi++) { - - for(Int_t d=1; d<5; d++) { - - if (!topo_->valid(HcalDetId(HcalSubdetector(sd), eta, phi, d))) continue; - HcalDetId id(HcalSubdetector(sd), eta, phi, d); - Float_t corrFactor = 1.0; - - - if (abs(eta)>=CALIB_ABS_IETA_MIN && abs(eta)<=CALIB_ABS_IETA_MAX && HcalSubdetector(sd)!=HcalOuter) { - // if (abs(eta)>=CALIB_ABS_IETA_MIN && abs(eta)<=22 && HcalSubdetector(sd)!=HcalOuter) { - - - // need some care when depths were summed for iEta=16 => - // the coeficients are saved in depth 1 of HB: affects - Int_t subdetInd = sd; - - if (abs(eta)==16 && HcalSubdetector(sd)==HcalEndcap && SUM_DEPTHS) { - subdetInd = 1; - } - - if (CALIB_METHOD=="L3" || CALIB_METHOD=="L3_AND_MTRX_INV") { - - - if (SUM_DEPTHS && COMBINE_PHI) corrFactor = solution[HcalDetId(HcalSubdetector(subdetInd), eta, 1, 1)]; - else if (SUM_DEPTHS) corrFactor = solution[HcalDetId(HcalSubdetector(subdetInd), eta, phi, 1)]; - else if (COMBINE_PHI) corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, 1, d)]; - else corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, phi, d)]; - - - // Remark: a new case was added (sumSmallDepths) where the first two depths in towers 15,16 - // are summed and stored in depth 1. - // For now we create the correction coef for depth 2 (set equal to depth 1) - // after the call to the L3 minimizer so that this case is also handled without modifying the - // logic above. Probably it is better to move it here? - - - }// L3 - - else if (CALIB_METHOD=="MATRIX_INV_OF_ETA_AVE") { - corrFactor = iEtaCoefMap[eta]; - } - - else if (CALIB_METHOD=="ISO_TRK_PHI_SYM") { - corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, phi, d)]; - } - - - } // if within the calibration range - - fprintf(constFile, "%17i%16i%16i%16s%9.5f%11X\n", - eta, phi, d, sdName[sd].Data(), corrFactor, id.rawId()); - - } - } + for (Int_t side = 0; side < 2; side++) { + eta = (side == 0) ? -e : e; //ta *= (-1); + + for (Int_t phi = 1; phi <= 72; phi++) { + for (Int_t d = 1; d < 5; d++) { + if (!topo_->valid(HcalDetId(HcalSubdetector(sd), eta, phi, d))) + continue; + HcalDetId id(HcalSubdetector(sd), eta, phi, d); + Float_t corrFactor = 1.0; + + if (abs(eta) >= CALIB_ABS_IETA_MIN && abs(eta) <= CALIB_ABS_IETA_MAX && HcalSubdetector(sd) != HcalOuter) { + // if (abs(eta)>=CALIB_ABS_IETA_MIN && abs(eta)<=22 && HcalSubdetector(sd)!=HcalOuter) { + + // need some care when depths were summed for iEta=16 => + // the coeficients are saved in depth 1 of HB: affects + Int_t subdetInd = sd; + + if (abs(eta) == 16 && HcalSubdetector(sd) == HcalEndcap && SUM_DEPTHS) { + subdetInd = 1; + } + + if (CALIB_METHOD == "L3" || CALIB_METHOD == "L3_AND_MTRX_INV") { + if (SUM_DEPTHS && COMBINE_PHI) + corrFactor = solution[HcalDetId(HcalSubdetector(subdetInd), eta, 1, 1)]; + else if (SUM_DEPTHS) + corrFactor = solution[HcalDetId(HcalSubdetector(subdetInd), eta, phi, 1)]; + else if (COMBINE_PHI) + corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, 1, d)]; + else + corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, phi, d)]; + + // Remark: a new case was added (sumSmallDepths) where the first two depths in towers 15,16 + // are summed and stored in depth 1. + // For now we create the correction coef for depth 2 (set equal to depth 1) + // after the call to the L3 minimizer so that this case is also handled without modifying the + // logic above. Probably it is better to move it here? + + } // L3 + + else if (CALIB_METHOD == "MATRIX_INV_OF_ETA_AVE") { + corrFactor = iEtaCoefMap[eta]; + } + + else if (CALIB_METHOD == "ISO_TRK_PHI_SYM") { + corrFactor = solution[HcalDetId(HcalSubdetector(sd), eta, phi, d)]; + } + + } // if within the calibration range + + fprintf(constFile, "%17i%16i%16i%16s%9.5f%11X\n", eta, phi, d, sdName[sd].Data(), corrFactor, id.rawId()); + } + } } } } - + return; } - diff --git a/Calibration/HcalCalibAlgos/src/hcalCalibUtils.cc b/Calibration/HcalCalibAlgos/src/hcalCalibUtils.cc index 1ed287693b324..5e865d4ff313b 100644 --- a/Calibration/HcalCalibAlgos/src/hcalCalibUtils.cc +++ b/Calibration/HcalCalibAlgos/src/hcalCalibUtils.cc @@ -13,158 +13,145 @@ using namespace std; -void sumDepths(vector &selectCells) { - +void sumDepths(vector& selectCells) { // Assignes teh sum of the energy in cells with the same iEta, iPhi to the cell with depth=1. // All cells with depth>1 are removed form the container. If - // the cell at depth=1 is not present: create it and follow the procedure. - - if (selectCells.empty()) return; + // the cell at depth=1 is not present: create it and follow the procedure. + + if (selectCells.empty()) + return; vector selectCellsDepth1; vector selectCellsHighDepth; - + // // NB: Here we add depth 3 for iEta==16 in *HE* to the value in the barrel // this approach is reflected in several of the following loops: make sure // to check when making changes. // // In some documents it is described as having depth 1, the mapping in CMSSW uses depth 3. - + for (vector::iterator i_it = selectCells.begin(); i_it != selectCells.end(); ++i_it) { - if (HcalDetId(i_it->id()).depth()==1) { + if (HcalDetId(i_it->id()).depth() == 1) { selectCellsDepth1.push_back(*i_it); - } - else { + } else { selectCellsHighDepth.push_back(*i_it); } } - - - + // case where depth 1 has zero energy, but higher depths with same (iEta, iPhi) have energy. // For iEta<15 there is one depth -> selectCellsHighDepth is empty and we do not get in the loop. for (vector::iterator i_it2 = selectCellsHighDepth.begin(); i_it2 != selectCellsHighDepth.end(); ++i_it2) { - - - // protect against corrupt data - if (HcalDetId(i_it2->id()).ietaAbs()<15 && HcalDetId(i_it2->id()).depth()>1) { + // protect against corrupt data + if (HcalDetId(i_it2->id()).ietaAbs() < 15 && HcalDetId(i_it2->id()).depth() > 1) { cout << "ERROR!!! there are no HB cells with depth>1 for iEta<15!\n" - << "Check the input data..." << endl; - cout << "HCalDetId: " << HcalDetId(i_it2->id()) << endl; + << "Check the input data..." << endl; + cout << "HCalDetId: " << HcalDetId(i_it2->id()) << endl; return; } - bool foundDepthOne = false; for (vector::iterator i_it = selectCellsDepth1.begin(); i_it != selectCellsDepth1.end(); ++i_it) { - if (HcalDetId(i_it->id()).ieta()==HcalDetId(i_it2->id()).ieta() && - HcalDetId(i_it->id()).iphi()==HcalDetId(i_it2->id()).iphi()) - foundDepthOne = true; + if (HcalDetId(i_it->id()).ieta() == HcalDetId(i_it2->id()).ieta() && + HcalDetId(i_it->id()).iphi() == HcalDetId(i_it2->id()).iphi()) + foundDepthOne = true; continue; } - if (!foundDepthOne) { // create entry for depth 1 with 0 energy - + if (!foundDepthOne) { // create entry for depth 1 with 0 energy + UInt_t newId; - if (abs(HcalDetId(i_it2->id()).ieta())==16) - newId = HcalDetId(HcalBarrel, HcalDetId(i_it2->id()).ieta(), HcalDetId(i_it2->id()).iphi(), 1); + if (abs(HcalDetId(i_it2->id()).ieta()) == 16) + newId = HcalDetId(HcalBarrel, HcalDetId(i_it2->id()).ieta(), HcalDetId(i_it2->id()).iphi(), 1); else - newId = HcalDetId(HcalDetId(i_it2->id()).subdet(), HcalDetId(i_it2->id()).ieta(), HcalDetId(i_it2->id()).iphi(), 1); - + newId = + HcalDetId(HcalDetId(i_it2->id()).subdet(), HcalDetId(i_it2->id()).ieta(), HcalDetId(i_it2->id()).iphi(), 1); + selectCellsDepth1.push_back(TCell(newId, 0.0)); ////////// cout << "\nCreated a dummy cell in depth one to recover energy!!!\n" << endl; } } - + for (vector::iterator i_it = selectCellsDepth1.begin(); i_it != selectCellsDepth1.end(); ++i_it) { for (vector::iterator i_it2 = selectCellsHighDepth.begin(); i_it2 != selectCellsHighDepth.end(); ++i_it2) { - if (HcalDetId(i_it->id()).ieta()==HcalDetId(i_it2->id()).ieta() && - HcalDetId(i_it->id()).iphi()==HcalDetId(i_it2->id()).iphi()) { - i_it->SetE(i_it->e()+i_it2->e()); - i_it2->SetE(0.0); // paranoid, aren't we... + if (HcalDetId(i_it->id()).ieta() == HcalDetId(i_it2->id()).ieta() && + HcalDetId(i_it->id()).iphi() == HcalDetId(i_it2->id()).iphi()) { + i_it->SetE(i_it->e() + i_it2->e()); + i_it2->SetE(0.0); // paranoid, aren't we... } } } - + // replace the original vectors with the new ones selectCells = selectCellsDepth1; - + return; } - -void combinePhi(vector &selectCells) { - +void combinePhi(vector& selectCells) { // Map: NxN -> N cluster // Comine the targetE of cells with the same iEta - if (selectCells.empty()) return; - + if (selectCells.empty()) + return; + // new container for the TCells // dummy cell id created with iEta; iPhi=1; depth // if combinePhi() is run after combining depths, depth=1 vector combinedCells; - - map > etaSliceE; // keyed by id of cell with iEta and **iPhi=1** - + + map > etaSliceE; // keyed by id of cell with iEta and **iPhi=1** + // map the cells to the eta ring vector::iterator i_it = selectCells.begin(); for (; i_it != selectCells.end(); ++i_it) { DetId id = HcalDetId(i_it->id()); - UInt_t thisKey = HcalDetId(HcalDetId(id).subdet(), HcalDetId(id).ieta(), 1, HcalDetId(id).depth() ); + UInt_t thisKey = HcalDetId(HcalDetId(id).subdet(), HcalDetId(id).ieta(), 1, HcalDetId(id).depth()); etaSliceE[thisKey].push_back(i_it->e()); } - + map >::iterator m_it = etaSliceE.begin(); for (; m_it != etaSliceE.end(); ++m_it) { - combinedCells.push_back(TCell(m_it->first, accumulate(m_it->second.begin(), m_it->second.end(), 0.0) ) ); + combinedCells.push_back(TCell(m_it->first, accumulate(m_it->second.begin(), m_it->second.end(), 0.0))); } - + // replace the original TCell vector with the new one selectCells = combinedCells; - } - -void combinePhi(vector &selectCells, vector &combinedCells) { - +void combinePhi(vector& selectCells, vector& combinedCells) { // Map: NxN -> N cluster // Comine the targetE of cells with the same iEta - if (selectCells.empty()) return; - - map > etaSliceE; // keyed by id of cell with iEta and **iPhi=1** - + if (selectCells.empty()) + return; + + map > etaSliceE; // keyed by id of cell with iEta and **iPhi=1** + // map the cells to the eta ring vector::iterator i_it = selectCells.begin(); for (; i_it != selectCells.end(); ++i_it) { DetId id = HcalDetId(i_it->id()); - UInt_t thisKey = HcalDetId(HcalDetId(id).subdet(), HcalDetId(id).ieta(), 1, HcalDetId(id).depth() ); + UInt_t thisKey = HcalDetId(HcalDetId(id).subdet(), HcalDetId(id).ieta(), 1, HcalDetId(id).depth()); etaSliceE[thisKey].push_back(i_it->e()); } - + map >::iterator m_it = etaSliceE.begin(); for (; m_it != etaSliceE.end(); ++m_it) { - combinedCells.push_back(TCell(m_it->first, accumulate(m_it->second.begin(), m_it->second.end(), 0.0) ) ); + combinedCells.push_back(TCell(m_it->first, accumulate(m_it->second.begin(), m_it->second.end(), 0.0))); } - } - - void getIEtaIPhiForHighestE(vector& selectCells, Int_t& iEtaMostE, UInt_t& iPhiMostE) { - - vector summedDepthsCells = selectCells; - sumDepths(summedDepthsCells); - vector::iterator highCell = summedDepthsCells.begin(); - + sumDepths(summedDepthsCells); + vector::iterator highCell = summedDepthsCells.begin(); + // sum depths locally to get highest energy tower - + Float_t highE = -999; - - for (vector::iterator it=summedDepthsCells.begin(); it!=summedDepthsCells.end(); ++it) { + + for (vector::iterator it = summedDepthsCells.begin(); it != summedDepthsCells.end(); ++it) { if (highE < it->e()) { highCell = it; highE = it->e(); @@ -177,7 +164,6 @@ void getIEtaIPhiForHighestE(vector& selectCells, Int_t& iEtaMostE, UInt_t return; } - // // Remove RecHits outside the 3x3 cluster and replace the vector that will // be used in the minimization. Acts on "event" level. @@ -185,58 +171,61 @@ void getIEtaIPhiForHighestE(vector& selectCells, Int_t& iEtaMostE, UInt_t // to iEta<20. Attempted to minimize affect at the boundary without a sharp jump. void filterCells3x3(vector& selectCells, Int_t iEtaMaxE, UInt_t iPhiMaxE) { - vector filteredCells; - + Int_t dEta, dPhi; - - for (vector::iterator it=selectCells.begin(); it!=selectCells.end(); ++it) { + for (vector::iterator it = selectCells.begin(); it != selectCells.end(); ++it) { Bool_t passDEta = false; Bool_t passDPhi = false; dEta = HcalDetId(it->id()).ieta() - iEtaMaxE; dPhi = HcalDetId(it->id()).iphi() - iPhiMaxE; - if (dPhi > 36) dPhi -= 72; - if (dPhi < -36) dPhi += 72; - - if (abs(dEta)<=1 || (iEtaMaxE * HcalDetId(it->id()).ieta() == -1)) passDEta = true; + if (dPhi > 36) + dPhi -= 72; + if (dPhi < -36) + dPhi += 72; + + if (abs(dEta) <= 1 || (iEtaMaxE * HcalDetId(it->id()).ieta() == -1)) + passDEta = true; + + if (abs(iEtaMaxE) <= 20) { + if (abs(HcalDetId(it->id()).ieta()) <= 20) { + if (abs(dPhi) <= 1) + passDPhi = true; + } else { + // iPhi is labelled by odd numbers + if (iPhiMaxE % 2 == 0) { + if (abs(dPhi) <= 1) + passDPhi = true; + } else { + if (dPhi == -2 || dPhi == 0) + passDPhi = true; + } + } - if (abs(iEtaMaxE)<=20) { + } // if hottest cell with iEta<=20 - if (abs(HcalDetId(it->id()).ieta())<=20) { - if (abs(dPhi)<=1) passDPhi = true; - } - else { - // iPhi is labelled by odd numbers - if (iPhiMaxE%2==0){ - if (abs(dPhi)<=1) passDPhi = true; - } - else { - if (dPhi== -2 || dPhi==0) passDPhi = true; - } + else { + if (abs(HcalDetId(it->id()).ieta()) <= 20) { + if (abs(dPhi) <= 1 || dPhi == 2) + passDPhi = true; + } else { + if (abs(dPhi) <= 2) + passDPhi = true; } + } // if hottest cell with iEta>20 - } // if hottest cell with iEta<=20 - - else { - if (abs(HcalDetId(it->id()).ieta())<=20) { - if (abs(dPhi)<=1 || dPhi==2) passDPhi = true; - } - else { - if (abs(dPhi)<=2) passDPhi = true; - } - } // if hottest cell with iEta>20 - - if (passDEta && passDPhi) filteredCells.push_back(*it); + if (passDEta && passDPhi) + filteredCells.push_back(*it); } - + selectCells = filteredCells; return; } - + // // Remove RecHits outside the 5x5 cluster and replace the vector that will // be used in the minimization. Acts on "event" level @@ -246,119 +235,110 @@ void filterCells3x3(vector& selectCells, Int_t iEtaMaxE, UInt_t iPhiMaxE) // There is some bias in the selection of towers near the boundary void filterCells5x5(vector& selectCells, Int_t iEtaMaxE, UInt_t iPhiMaxE) { - vector filteredCells; - + Int_t dEta, dPhi; - - for (vector::iterator it=selectCells.begin(); it!=selectCells.end(); ++it) { - + + for (vector::iterator it = selectCells.begin(); it != selectCells.end(); ++it) { dEta = HcalDetId(it->id()).ieta() - iEtaMaxE; dPhi = HcalDetId(it->id()).iphi() - iPhiMaxE; - - if (dPhi > 36) dPhi -= 72; - if (dPhi < -36) dPhi += 72; - bool passDPhi = (abs(dPhi)<3); + if (dPhi > 36) + dPhi -= 72; + if (dPhi < -36) + dPhi += 72; - bool passDEta = (abs(dEta)<3 || (iEtaMaxE * HcalDetId(it->id()).ieta() == -2) ); - // includes +/- eta boundary + bool passDPhi = (abs(dPhi) < 3); - if (passDPhi && passDEta) filteredCells.push_back(*it); + bool passDEta = (abs(dEta) < 3 || (iEtaMaxE * HcalDetId(it->id()).ieta() == -2)); + // includes +/- eta boundary + if (passDPhi && passDEta) + filteredCells.push_back(*it); } - + selectCells = filteredCells; return; } - - - // this is for the problematic layer near the HB/HE boundary // sum depths 1,2 in towers 15,16 -void sumSmallDepths(vector &selectCells) { - - if (selectCells.empty()) return; - - vector newCells; // holds unaffected cells to which the modified ones are added - vector manipulatedCells; // the ones that are combined - - for (vector::iterator i_it = selectCells.begin(); i_it != selectCells.end(); ++i_it) { +void sumSmallDepths(vector& selectCells) { + if (selectCells.empty()) + return; + + vector newCells; // holds unaffected cells to which the modified ones are added + vector manipulatedCells; // the ones that are combined - if ( (HcalDetId(i_it->id()).ietaAbs()==15 && HcalDetId(i_it->id()).depth()<=2) || - (HcalDetId(i_it->id()).ietaAbs()==16 && HcalDetId(i_it->id()).depth()<=2)) { + for (vector::iterator i_it = selectCells.begin(); i_it != selectCells.end(); ++i_it) { + if ((HcalDetId(i_it->id()).ietaAbs() == 15 && HcalDetId(i_it->id()).depth() <= 2) || + (HcalDetId(i_it->id()).ietaAbs() == 16 && HcalDetId(i_it->id()).depth() <= 2)) { manipulatedCells.push_back(*i_it); - } - else { + } else { newCells.push_back(*i_it); } - } // if the list is empty there is nothing to manipulate // leave the original vector unchanged if (manipulatedCells.empty()) { - newCells.clear(); + newCells.clear(); return; } - // See what cells are needed to hold the combined information: - // Make holders for depth=1 for each (iEta,iPhi) - // if a cell with these values is present in "manupulatedCells" - vector dummyIds; // to keep track of kreated cells - vector createdCells; // cells that need to be added or they exists; - - for (vector::iterator i_it = manipulatedCells.begin(); i_it!=manipulatedCells.end(); ++i_it) { - UInt_t dummyId = HcalDetId(HcalDetId(i_it->id()).subdet(), HcalDetId(i_it->id()).ieta(), HcalDetId(i_it->id()).iphi(), 1); - if (find(dummyIds.begin(), dummyIds.end(), dummyId)==dummyIds.end()) { + // Make holders for depth=1 for each (iEta,iPhi) + // if a cell with these values is present in "manupulatedCells" + vector dummyIds; // to keep track of kreated cells + vector createdCells; // cells that need to be added or they exists; + + for (vector::iterator i_it = manipulatedCells.begin(); i_it != manipulatedCells.end(); ++i_it) { + UInt_t dummyId = + HcalDetId(HcalDetId(i_it->id()).subdet(), HcalDetId(i_it->id()).ieta(), HcalDetId(i_it->id()).iphi(), 1); + if (find(dummyIds.begin(), dummyIds.end(), dummyId) == dummyIds.end()) { dummyIds.push_back(dummyId); createdCells.push_back(TCell(dummyId, 0.0)); } } - for (vector::iterator i_it = createdCells.begin(); i_it!=createdCells.end(); ++i_it) { - for (vector::iterator i_it2 = manipulatedCells.begin(); i_it2!=manipulatedCells.end(); ++i_it2) { - if (HcalDetId(i_it->id()).ieta()==HcalDetId(i_it2->id()).ieta() && - HcalDetId(i_it->id()).iphi()==HcalDetId(i_it2->id()).iphi() && - HcalDetId(i_it2->id()).depth()<=2) { - i_it->SetE(i_it->e()+i_it2->e()); - } + for (vector::iterator i_it = createdCells.begin(); i_it != createdCells.end(); ++i_it) { + for (vector::iterator i_it2 = manipulatedCells.begin(); i_it2 != manipulatedCells.end(); ++i_it2) { + if (HcalDetId(i_it->id()).ieta() == HcalDetId(i_it2->id()).ieta() && + HcalDetId(i_it->id()).iphi() == HcalDetId(i_it2->id()).iphi() && HcalDetId(i_it2->id()).depth() <= 2) { + i_it->SetE(i_it->e() + i_it2->e()); + } } } - - for (vector::iterator i_it = createdCells.begin(); i_it!=createdCells.end(); ++i_it) { + + for (vector::iterator i_it = createdCells.begin(); i_it != createdCells.end(); ++i_it) { newCells.push_back(*i_it); } - - + // replace the original vectors with the new ones selectCells = newCells; - + return; } - -void filterCellsInCone(std::vector& selectCells, const GlobalPoint hitPositionHcal, - Float_t maxConeDist, const CaloGeometry* theCaloGeometry) { - +void filterCellsInCone(std::vector& selectCells, + const GlobalPoint hitPositionHcal, + Float_t maxConeDist, + const CaloGeometry* theCaloGeometry) { vector filteredCells; - - for (vector::iterator it=selectCells.begin(); it!=selectCells.end(); ++it) { + for (vector::iterator it = selectCells.begin(); it != selectCells.end(); ++it) { GlobalPoint recHitPoint; - DetId id = it->id(); + DetId id = it->id(); if (id.det() == DetId::Hcal) { recHitPoint = (static_cast(theCaloGeometry->getSubdetectorGeometry(id)))->getPosition(id); } else { recHitPoint = GlobalPoint(theCaloGeometry->getPosition(id)); } - if (getDistInPlaneSimple(hitPositionHcal, recHitPoint)<= maxConeDist) + if (getDistInPlaneSimple(hitPositionHcal, recHitPoint) <= maxConeDist) filteredCells.push_back(*it); } @@ -367,7 +347,6 @@ void filterCellsInCone(std::vector& selectCells, const GlobalPoint hitPos return; } - // From Jim H. => keep till the code is included centrally /* double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint) { diff --git a/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.cc b/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.cc index 6d085222c442c..96120c9163fc1 100644 --- a/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.cc +++ b/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.cc @@ -6,188 +6,198 @@ #include "DiJetAnalyzer.h" -DiJetAnalyzer::DiJetAnalyzer(const edm::ParameterSet& iConfig) -{ +DiJetAnalyzer::DiJetAnalyzer(const edm::ParameterSet& iConfig) { // set parameters - pfJetCollName_ = iConfig.getParameter("pfJetCollName"); - pfJetCorrName_ = iConfig.getParameter("pfJetCorrName"); - hbheRecHitName_ = iConfig.getParameter("hbheRecHitName"); - hfRecHitName_ = iConfig.getParameter("hfRecHitName"); - hoRecHitName_ = iConfig.getParameter("hoRecHitName"); - pvCollName_ = iConfig.getParameter("pvCollName"); - rootHistFilename_ = iConfig.getParameter("rootHistFilename"); - maxDeltaEta_ = iConfig.getParameter("maxDeltaEta"); - minTagJetEta_ = iConfig.getParameter("minTagJetEta"); - maxTagJetEta_ = iConfig.getParameter("maxTagJetEta"); - minSumJetEt_ = iConfig.getParameter("minSumJetEt"); - minJetEt_ = iConfig.getParameter("minJetEt"); - maxThirdJetEt_ = iConfig.getParameter("maxThirdJetEt"); - debug_ = iConfig.getUntrackedParameter("debug", false); - - tok_PFJet_ = consumes(pfJetCollName_); - tok_HBHE_ = consumes > >(hbheRecHitName_); - tok_HF_ = consumes > >(hfRecHitName_); - tok_HO_ = consumes > >(hoRecHitName_); - tok_Vertex_ = consumes(pvCollName_); -} + pfJetCollName_ = iConfig.getParameter("pfJetCollName"); + pfJetCorrName_ = iConfig.getParameter("pfJetCorrName"); + hbheRecHitName_ = iConfig.getParameter("hbheRecHitName"); + hfRecHitName_ = iConfig.getParameter("hfRecHitName"); + hoRecHitName_ = iConfig.getParameter("hoRecHitName"); + pvCollName_ = iConfig.getParameter("pvCollName"); + rootHistFilename_ = iConfig.getParameter("rootHistFilename"); + maxDeltaEta_ = iConfig.getParameter("maxDeltaEta"); + minTagJetEta_ = iConfig.getParameter("minTagJetEta"); + maxTagJetEta_ = iConfig.getParameter("maxTagJetEta"); + minSumJetEt_ = iConfig.getParameter("minSumJetEt"); + minJetEt_ = iConfig.getParameter("minJetEt"); + maxThirdJetEt_ = iConfig.getParameter("maxThirdJetEt"); + debug_ = iConfig.getUntrackedParameter("debug", false); -DiJetAnalyzer::~DiJetAnalyzer() -{ + tok_PFJet_ = consumes(pfJetCollName_); + tok_HBHE_ = consumes>>(hbheRecHitName_); + tok_HF_ = consumes>>(hfRecHitName_); + tok_HO_ = consumes>>(hoRecHitName_); + tok_Vertex_ = consumes(pvCollName_); } - + +DiJetAnalyzer::~DiJetAnalyzer() {} + // // member functions // - + // ------------ method called to for each event ------------ -void -DiJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) -{ +void DiJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) { pf_Run_ = iEvent.id().run(); pf_Lumi_ = iEvent.id().luminosityBlock(); pf_Event_ = iEvent.id().event(); - + // Get PFJets edm::Handle pfjets; - iEvent.getByToken(tok_PFJet_,pfjets); - if(!pfjets.isValid()) { + iEvent.getByToken(tok_PFJet_, pfjets); + if (!pfjets.isValid()) { throw edm::Exception(edm::errors::ProductNotFound) - << " could not find PFJetCollection named " << pfJetCollName_ << ".\n"; + << " could not find PFJetCollection named " << pfJetCollName_ << ".\n"; return; } // Get RecHits in HB and HE - edm::Handle>> hbhereco; - iEvent.getByToken(tok_HBHE_,hbhereco); - if(!hbhereco.isValid()) { + edm::Handle>> hbhereco; + iEvent.getByToken(tok_HBHE_, hbhereco); + if (!hbhereco.isValid()) { throw edm::Exception(edm::errors::ProductNotFound) - << " could not find HBHERecHit named " << hbheRecHitName_ << ".\n"; + << " could not find HBHERecHit named " << hbheRecHitName_ << ".\n"; return; } // Get RecHits in HF - edm::Handle>> hfreco; - iEvent.getByToken(tok_HF_,hfreco); - if(!hfreco.isValid()) { - throw edm::Exception(edm::errors::ProductNotFound) - << " could not find HFRecHit named " << hfRecHitName_ << ".\n"; + edm::Handle>> hfreco; + iEvent.getByToken(tok_HF_, hfreco); + if (!hfreco.isValid()) { + throw edm::Exception(edm::errors::ProductNotFound) << " could not find HFRecHit named " << hfRecHitName_ << ".\n"; return; } // Get RecHits in HO - edm::Handle>> horeco; - iEvent.getByToken(tok_HO_,horeco); - if(!horeco.isValid()) { - throw edm::Exception(edm::errors::ProductNotFound) - << " could not find HORecHit named " << hoRecHitName_ << ".\n"; + edm::Handle>> horeco; + iEvent.getByToken(tok_HO_, horeco); + if (!horeco.isValid()) { + throw edm::Exception(edm::errors::ProductNotFound) << " could not find HORecHit named " << hoRecHitName_ << ".\n"; return; } // Get geometry edm::ESHandle geoHandle; evSetup.get().get(geoHandle); - const HcalGeometry *HBGeom = static_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 1)); - const HcalGeometry *HEGeom = static_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 2)); - const CaloSubdetectorGeometry *HOGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 3); - const CaloSubdetectorGeometry *HFGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 4); - + const HcalGeometry* HBGeom = static_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 1)); + const HcalGeometry* HEGeom = static_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 2)); + const CaloSubdetectorGeometry* HOGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 3); + const CaloSubdetectorGeometry* HFGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 4); + int HBHE_n = 0; - for(edm::SortedCollection>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){ + for (edm::SortedCollection>::const_iterator ith = hbhereco->begin(); + ith != hbhereco->end(); + ++ith) { HBHE_n++; } int HF_n = 0; - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ + for (edm::SortedCollection>::const_iterator ith = hfreco->begin(); + ith != hfreco->end(); + ++ith) { HF_n++; } int HO_n = 0; - for(edm::SortedCollection>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){ + for (edm::SortedCollection>::const_iterator ith = horeco->begin(); + ith != horeco->end(); + ++ith) { HO_n++; } // Get primary vertices edm::Handle> pv; - iEvent.getByToken(tok_Vertex_,pv); - if(!pv.isValid()) { - throw edm::Exception(edm::errors::ProductNotFound) - << " could not find Vertex named " << pvCollName_ << ".\n"; + iEvent.getByToken(tok_Vertex_, pv); + if (!pv.isValid()) { + throw edm::Exception(edm::errors::ProductNotFound) << " could not find Vertex named " << pvCollName_ << ".\n"; return; } pf_NPV_ = 0; - for(std::vector::const_iterator it=pv->begin(); it!=pv->end(); ++it){ - if(!it->isFake() && it->ndof() > 4) ++pf_NPV_; + for (std::vector::const_iterator it = pv->begin(); it != pv->end(); ++it) { + if (!it->isFake() && it->ndof() > 4) + ++pf_NPV_; } - + // Get jet corrections - const JetCorrector* correctorPF = JetCorrector::getJetCorrector(pfJetCorrName_,evSetup); - + const JetCorrector* correctorPF = JetCorrector::getJetCorrector(pfJetCorrName_, evSetup); + ////////////////////////////// // Event Selection ////////////////////////////// - + // determine which cut results in failure - int passSelPF=0; + int passSelPF = 0; // sort jets by corrected et std::set pfjetcorretpairset; - for(reco::PFJetCollection::const_iterator it=pfjets->begin(); it!=pfjets->end(); ++it) { - const reco::PFJet* jet=&(*it); + for (reco::PFJetCollection::const_iterator it = pfjets->begin(); it != pfjets->end(); ++it) { + const reco::PFJet* jet = &(*it); double jec = correctorPF->correction(*it, iEvent, evSetup); pfjetcorretpairset.insert(JetCorretPair(jet, jec)); } JetCorretPair pf_tag, pf_probe; - pf_thirdjet_px_=pf_thirdjet_py_=0.0; - pf_realthirdjet_px_=pf_realthirdjet_py_=0.0; + pf_thirdjet_px_ = pf_thirdjet_py_ = 0.0; + pf_realthirdjet_px_ = pf_realthirdjet_py_ = 0.0; pf_realthirdjet_px_ = 1; - int cntr=0; - for(std::set::const_iterator it=pfjetcorretpairset.begin(); it!=pfjetcorretpairset.end(); ++it) { - JetCorretPair jet=(*it); + int cntr = 0; + for (std::set::const_iterator it = pfjetcorretpairset.begin(); + it != pfjetcorretpairset.end(); + ++it) { + JetCorretPair jet = (*it); ++cntr; - if(cntr==1) pf_tag=jet; - else if(cntr==2) pf_probe=jet; + if (cntr == 1) + pf_tag = jet; + else if (cntr == 2) + pf_probe = jet; else { - pf_thirdjet_px_ += jet.scale()*jet.jet()->px(); - pf_thirdjet_py_ += jet.scale()*jet.jet()->py(); - if(cntr==3){ - pf_realthirdjet_px_ = jet.jet()->px(); - pf_realthirdjet_py_ = jet.jet()->py(); - pf_realthirdjet_scale_ = jet.scale(); + pf_thirdjet_px_ += jet.scale() * jet.jet()->px(); + pf_thirdjet_py_ += jet.scale() * jet.jet()->py(); + if (cntr == 3) { + pf_realthirdjet_px_ = jet.jet()->px(); + pf_realthirdjet_py_ = jet.jet()->py(); + pf_realthirdjet_scale_ = jet.scale(); } } } - - if(pf_tag.jet() && pf_probe.jet()){ + + if (pf_tag.jet() && pf_probe.jet()) { // require that the first two jets are above some minimum, // and the rest are below some maximum - if((pf_tag.jet()->et()+pf_probe.jet()->et())et()et()maxThirdJetEt_) passSelPF |= 0x4; - + if ((pf_tag.jet()->et() + pf_probe.jet()->et()) < minSumJetEt_) + passSelPF |= 0x1; + if (pf_tag.jet()->et() < minJetEt_ || pf_probe.jet()->et() < minJetEt_) + passSelPF |= 0x2; + if (sqrt(pf_thirdjet_px_ * pf_thirdjet_px_ + pf_thirdjet_py_ * pf_thirdjet_py_) > maxThirdJetEt_) + passSelPF |= 0x4; + // force the tag jet to have the smaller |eta| - if(std::fabs(pf_tag.jet()->eta())>std::fabs(pf_probe.jet()->eta())) { - JetCorretPair temp=pf_tag; - pf_tag=pf_probe; - pf_probe=temp; + if (std::fabs(pf_tag.jet()->eta()) > std::fabs(pf_probe.jet()->eta())) { + JetCorretPair temp = pf_tag; + pf_tag = pf_probe; + pf_probe = temp; } - + // eta cuts - double dAbsEta=std::fabs(std::fabs(pf_tag.jet()->eta())-std::fabs(pf_probe.jet()->eta())); - if(dAbsEta>maxDeltaEta_) passSelPF |= 0x8; - if(fabs(pf_tag.jet()->eta())eta())>maxTagJetEta_) passSelPF |= 0x10; - } - else{ + double dAbsEta = std::fabs(std::fabs(pf_tag.jet()->eta()) - std::fabs(pf_probe.jet()->eta())); + if (dAbsEta > maxDeltaEta_) + passSelPF |= 0x8; + if (fabs(pf_tag.jet()->eta()) < minTagJetEta_) + passSelPF |= 0x10; + if (fabs(pf_tag.jet()->eta()) > maxTagJetEta_) + passSelPF |= 0x10; + } else { passSelPF = 0x40; } - + h_PassSelPF_->Fill(passSelPF); - if(passSelPF) return; + if (passSelPF) + return; // dump - if(debug_) { + if (debug_) { std::cout << "Run: " << iEvent.id().run() << "; Event: " << iEvent.id().event() << std::endl; - for(reco::PFJetCollection::const_iterator it=pfjets->begin(); it!=pfjets->end(); ++it) { - const reco::PFJet *jet=&(*it); - std::cout << "istag=" << (jet==pf_tag.jet()) << "; isprobe=" << (jet==pf_probe.jet()) << "; et=" << jet->et() << "; eta=" << jet->eta() << std::endl; + for (reco::PFJetCollection::const_iterator it = pfjets->begin(); it != pfjets->end(); ++it) { + const reco::PFJet* jet = &(*it); + std::cout << "istag=" << (jet == pf_tag.jet()) << "; isprobe=" << (jet == pf_probe.jet()) << "; et=" << jet->et() + << "; eta=" << jet->eta() << std::endl; } } @@ -206,7 +216,7 @@ DiJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) ppfjet_unkown_n_ = ppfjet_electron_n_ = ppfjet_muon_n_ = ppfjet_photon_n_ = 0; ppfjet_had_n_ = 0; ppfjet_cluster_n_ = 0; - + tpfjet_had_E_.clear(); tpfjet_had_px_.clear(); tpfjet_had_py_.clear(); @@ -264,991 +274,1018 @@ DiJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) ppfjet_candtrack_pz_.clear(); ppfjet_candtrack_EcalE_.clear(); - std::map>> tpfjet_rechits; - std::map>> ppfjet_rechits; - std::map tpfjet_clusters; - std::map ppfjet_clusters; - + std::map>> tpfjet_rechits; + std::map>> ppfjet_rechits; + std::map tpfjet_clusters; + std::map ppfjet_clusters; + // fill tag jet variables - tpfjet_pt_ = pf_tag.jet()->pt(); - tpfjet_p_ = pf_tag.jet()->p(); - tpfjet_E_ = pf_tag.jet()->energy(); - tpfjet_eta_ = pf_tag.jet()->eta(); - tpfjet_phi_ = pf_tag.jet()->phi(); + tpfjet_pt_ = pf_tag.jet()->pt(); + tpfjet_p_ = pf_tag.jet()->p(); + tpfjet_E_ = pf_tag.jet()->energy(); + tpfjet_eta_ = pf_tag.jet()->eta(); + tpfjet_phi_ = pf_tag.jet()->phi(); tpfjet_scale_ = pf_tag.scale(); - tpfjet_area_ = pf_tag.jet()->jetArea(); - tpfjet_ntwrs_=0; - tpfjet_ncandtracks_=0; - - tpfjet_jetID_ = 0; // Not a loose, medium, or tight jet - if(fabs(pf_tag.jet()->eta()) < 2.4){ - if(pf_tag.jet()->chargedHadronEnergyFraction() > 0 && - pf_tag.jet()->chargedMultiplicity() > 0 && - pf_tag.jet()->chargedEmEnergyFraction() < 0.99 && - (pf_tag.jet()->chargedMultiplicity() + pf_tag.jet()->neutralMultiplicity()) > 1){ - if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.9 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.9){ - tpfjet_jetID_ = 3; // Tight jet - } - else if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.95 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.95){ - tpfjet_jetID_ = 2; // Medium jet - } - else if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.99 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.99){ - tpfjet_jetID_ = 1; // Loose jet + tpfjet_area_ = pf_tag.jet()->jetArea(); + tpfjet_ntwrs_ = 0; + tpfjet_ncandtracks_ = 0; + + tpfjet_jetID_ = 0; // Not a loose, medium, or tight jet + if (fabs(pf_tag.jet()->eta()) < 2.4) { + if (pf_tag.jet()->chargedHadronEnergyFraction() > 0 && pf_tag.jet()->chargedMultiplicity() > 0 && + pf_tag.jet()->chargedEmEnergyFraction() < 0.99 && + (pf_tag.jet()->chargedMultiplicity() + pf_tag.jet()->neutralMultiplicity()) > 1) { + if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.9 && pf_tag.jet()->neutralEmEnergyFraction() < 0.9) { + tpfjet_jetID_ = 3; // Tight jet + } else if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.95 && pf_tag.jet()->neutralEmEnergyFraction() < 0.95) { + tpfjet_jetID_ = 2; // Medium jet + } else if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.99 && pf_tag.jet()->neutralEmEnergyFraction() < 0.99) { + tpfjet_jetID_ = 1; // Loose jet } } - } - else if((pf_tag.jet()->chargedMultiplicity() + pf_tag.jet()->neutralMultiplicity()) > 1){ - if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.9 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.9){ - tpfjet_jetID_ = 3; // Tight jet - } - else if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.95 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.95){ - tpfjet_jetID_ = 2; // Medium jet - } - else if(pf_tag.jet()->neutralHadronEnergyFraction() < 0.99 && - pf_tag.jet()->neutralEmEnergyFraction() < 0.99){ - tpfjet_jetID_ = 1; // Loose jet + } else if ((pf_tag.jet()->chargedMultiplicity() + pf_tag.jet()->neutralMultiplicity()) > 1) { + if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.9 && pf_tag.jet()->neutralEmEnergyFraction() < 0.9) { + tpfjet_jetID_ = 3; // Tight jet + } else if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.95 && pf_tag.jet()->neutralEmEnergyFraction() < 0.95) { + tpfjet_jetID_ = 2; // Medium jet + } else if (pf_tag.jet()->neutralHadronEnergyFraction() < 0.99 && pf_tag.jet()->neutralEmEnergyFraction() < 0.99) { + tpfjet_jetID_ = 1; // Loose jet } } ///////////////////////////////////////////// // Get PF constituents and fill HCAL towers ///////////////////////////////////////////// - + // Get tag PFCandidates - std::vector tagconst=pf_tag.jet()->getPFConstituents(); - for(std::vector::const_iterator it=tagconst.begin(); it!=tagconst.end(); ++it){ + std::vector tagconst = pf_tag.jet()->getPFConstituents(); + for (std::vector::const_iterator it = tagconst.begin(); it != tagconst.end(); ++it) { bool hasTrack = false; // Test PFCandidate type reco::PFCandidate::ParticleType candidateType = (*it)->particleId(); - switch(candidateType){ - case reco::PFCandidate::X: - tpfjet_unkown_E_ += (*it)->energy(); - tpfjet_unkown_px_ += (*it)->px(); - tpfjet_unkown_py_ += (*it)->py(); - tpfjet_unkown_pz_ += (*it)->pz(); - tpfjet_unkown_EcalE_ += (*it)->ecalEnergy(); - tpfjet_unkown_n_++; - continue; - case reco::PFCandidate::h: - { - tpfjet_had_E_.push_back((*it)->energy()); - tpfjet_had_px_.push_back((*it)->px()); - tpfjet_had_py_.push_back((*it)->py()); - tpfjet_had_pz_.push_back((*it)->pz()); - tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - tpfjet_had_id_.push_back(0); - tpfjet_had_ntwrs_.push_back(0); - tpfjet_had_n_++; - - reco::TrackRef trackRef = (*it)->trackRef(); - if(trackRef.isNonnull()){ - reco::Track track = *trackRef; - tpfjet_candtrack_px_.push_back(track.px()); - tpfjet_candtrack_py_.push_back(track.py()); - tpfjet_candtrack_pz_.push_back(track.pz()); - tpfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); - tpfjet_had_candtrackind_.push_back(tpfjet_ncandtracks_); - hasTrack = true; - tpfjet_ncandtracks_++; - } - else{ - tpfjet_had_candtrackind_.push_back(-2); - } - } - break; - case reco::PFCandidate::e: - tpfjet_electron_E_ += (*it)->energy(); - tpfjet_electron_px_ += (*it)->px(); - tpfjet_electron_py_ += (*it)->py(); - tpfjet_electron_pz_ += (*it)->pz(); - tpfjet_electron_EcalE_ += (*it)->ecalEnergy(); - tpfjet_electron_n_++; - continue; - case reco::PFCandidate::mu: - tpfjet_muon_E_ += (*it)->energy(); - tpfjet_muon_px_ += (*it)->px(); - tpfjet_muon_py_ += (*it)->py(); - tpfjet_muon_pz_ += (*it)->pz(); - tpfjet_muon_EcalE_ += (*it)->ecalEnergy(); - tpfjet_muon_n_++; - continue; - case reco::PFCandidate::gamma: - tpfjet_photon_E_ += (*it)->energy(); - tpfjet_photon_px_ += (*it)->px(); - tpfjet_photon_py_ += (*it)->py(); - tpfjet_photon_pz_ += (*it)->pz(); - tpfjet_photon_EcalE_ += (*it)->ecalEnergy(); - tpfjet_photon_n_++; - continue; - case reco::PFCandidate::h0: - { - tpfjet_had_E_.push_back((*it)->energy()); - tpfjet_had_px_.push_back((*it)->px()); - tpfjet_had_py_.push_back((*it)->py()); - tpfjet_had_pz_.push_back((*it)->pz()); - tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - tpfjet_had_id_.push_back(1); - tpfjet_had_candtrackind_.push_back(-1); - tpfjet_had_ntwrs_.push_back(0); - tpfjet_had_n_++; - break; + switch (candidateType) { + case reco::PFCandidate::X: + tpfjet_unkown_E_ += (*it)->energy(); + tpfjet_unkown_px_ += (*it)->px(); + tpfjet_unkown_py_ += (*it)->py(); + tpfjet_unkown_pz_ += (*it)->pz(); + tpfjet_unkown_EcalE_ += (*it)->ecalEnergy(); + tpfjet_unkown_n_++; + continue; + case reco::PFCandidate::h: { + tpfjet_had_E_.push_back((*it)->energy()); + tpfjet_had_px_.push_back((*it)->px()); + tpfjet_had_py_.push_back((*it)->py()); + tpfjet_had_pz_.push_back((*it)->pz()); + tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + tpfjet_had_id_.push_back(0); + tpfjet_had_ntwrs_.push_back(0); + tpfjet_had_n_++; + + reco::TrackRef trackRef = (*it)->trackRef(); + if (trackRef.isNonnull()) { + reco::Track track = *trackRef; + tpfjet_candtrack_px_.push_back(track.px()); + tpfjet_candtrack_py_.push_back(track.py()); + tpfjet_candtrack_pz_.push_back(track.pz()); + tpfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); + tpfjet_had_candtrackind_.push_back(tpfjet_ncandtracks_); + hasTrack = true; + tpfjet_ncandtracks_++; + } else { + tpfjet_had_candtrackind_.push_back(-2); + } + } break; + case reco::PFCandidate::e: + tpfjet_electron_E_ += (*it)->energy(); + tpfjet_electron_px_ += (*it)->px(); + tpfjet_electron_py_ += (*it)->py(); + tpfjet_electron_pz_ += (*it)->pz(); + tpfjet_electron_EcalE_ += (*it)->ecalEnergy(); + tpfjet_electron_n_++; + continue; + case reco::PFCandidate::mu: + tpfjet_muon_E_ += (*it)->energy(); + tpfjet_muon_px_ += (*it)->px(); + tpfjet_muon_py_ += (*it)->py(); + tpfjet_muon_pz_ += (*it)->pz(); + tpfjet_muon_EcalE_ += (*it)->ecalEnergy(); + tpfjet_muon_n_++; + continue; + case reco::PFCandidate::gamma: + tpfjet_photon_E_ += (*it)->energy(); + tpfjet_photon_px_ += (*it)->px(); + tpfjet_photon_py_ += (*it)->py(); + tpfjet_photon_pz_ += (*it)->pz(); + tpfjet_photon_EcalE_ += (*it)->ecalEnergy(); + tpfjet_photon_n_++; + continue; + case reco::PFCandidate::h0: { + tpfjet_had_E_.push_back((*it)->energy()); + tpfjet_had_px_.push_back((*it)->px()); + tpfjet_had_py_.push_back((*it)->py()); + tpfjet_had_pz_.push_back((*it)->pz()); + tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + tpfjet_had_id_.push_back(1); + tpfjet_had_candtrackind_.push_back(-1); + tpfjet_had_ntwrs_.push_back(0); + tpfjet_had_n_++; + break; } - case reco::PFCandidate::h_HF: - { - tpfjet_had_E_.push_back((*it)->energy()); - tpfjet_had_px_.push_back((*it)->px()); - tpfjet_had_py_.push_back((*it)->py()); - tpfjet_had_pz_.push_back((*it)->pz()); - tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - tpfjet_had_id_.push_back(2); - tpfjet_had_candtrackind_.push_back(-1); - tpfjet_had_ntwrs_.push_back(0); - tpfjet_had_n_++; - break; + case reco::PFCandidate::h_HF: { + tpfjet_had_E_.push_back((*it)->energy()); + tpfjet_had_px_.push_back((*it)->px()); + tpfjet_had_py_.push_back((*it)->py()); + tpfjet_had_pz_.push_back((*it)->pz()); + tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + tpfjet_had_id_.push_back(2); + tpfjet_had_candtrackind_.push_back(-1); + tpfjet_had_ntwrs_.push_back(0); + tpfjet_had_n_++; + break; } - case reco::PFCandidate::egamma_HF: - { - tpfjet_had_E_.push_back((*it)->energy()); - tpfjet_had_px_.push_back((*it)->px()); - tpfjet_had_py_.push_back((*it)->py()); - tpfjet_had_pz_.push_back((*it)->pz()); - tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - tpfjet_had_id_.push_back(3); - tpfjet_had_candtrackind_.push_back(-1); - tpfjet_had_ntwrs_.push_back(0); - tpfjet_had_n_++; - break; + case reco::PFCandidate::egamma_HF: { + tpfjet_had_E_.push_back((*it)->energy()); + tpfjet_had_px_.push_back((*it)->px()); + tpfjet_had_py_.push_back((*it)->py()); + tpfjet_had_pz_.push_back((*it)->pz()); + tpfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + tpfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + tpfjet_had_id_.push_back(3); + tpfjet_had_candtrackind_.push_back(-1); + tpfjet_had_ntwrs_.push_back(0); + tpfjet_had_n_++; + break; } } - std::map twrietas; + std::map twrietas; float HFHAD_E = 0; float HFEM_E = 0; - int maxElement=(*it)->elementsInBlocks().size(); - for(int e=0; eelementsInBlocks().size(); + for (int e = 0; e < maxElement; ++e) { // Get elements from block reco::PFBlockRef blockRef = (*it)->elementsInBlocks()[e].first; const edm::OwnVector& elements = blockRef->elements(); - for(unsigned iEle=0; iEleelementsInBlocks()[e].second){ - if(elements[iEle].type() == reco::PFBlockElement::HCAL){ // Element is HB or HE - // Get cluster and hits - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(tpfjet_eta_,tpfjet_phi_,cluster.eta(),cluster.phi()); - if(tpfjet_clusters.count(cluster_dR) == 0){ - tpfjet_clusters[cluster_dR] = tpfjet_cluster_n_; - tpfjet_cluster_eta_.push_back(cluster.eta()); - tpfjet_cluster_phi_.push_back(cluster.phi()); - tpfjet_cluster_dR_.push_back(cluster_dR); - tpfjet_cluster_n_++; - } - int cluster_ind = tpfjet_clusters[cluster_dR]; - - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - - // Run over hits and match - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; - if(tpfjet_rechits.count((*ith).id()) == 0){ - tpfjet_twr_ieta_.push_back((*ith).id().ieta()); - tpfjet_twr_iphi_.push_back((*ith).id().iphi()); - tpfjet_twr_depth_.push_back((*ith).id().depth()); - tpfjet_twr_subdet_.push_back((*ith).id().subdet()); - if(hitsAndFracs[iHit].second > 0.05 && (*ith).energy() > 0.0) twrietas[(*ith).id().ieta()]++; - tpfjet_twr_hade_.push_back((*ith).energy()); - tpfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); - tpfjet_twr_elmttype_.push_back(0); - tpfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - tpfjet_twr_candtrackind_.push_back(tpfjet_ncandtracks_ - 1); - } - else{ - tpfjet_twr_candtrackind_.push_back(-1); - } - switch((*ith).id().subdet()){ - case HcalSubdetector::HcalBarrel: - { - CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_,tpfjet_phi_,avgeta,avgphi)); - break; - } - case HcalSubdetector::HcalEndcap: - { - CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_,tpfjet_phi_,avgeta,avgphi)); - break; - } - default: - tpfjet_twr_dR_.push_back(-1); - break; - } - tpfjet_rechits[(*ith).id()].first = tpfjet_ntwrs_; - ++tpfjet_ntwrs_; - } - else if(tpfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - tpfjet_twr_frac_.at(tpfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < tpfjet_cluster_dR_.at(tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first))){ - tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first) = cluster_ind; - } - tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi matches - } // Loop over rechits - } // Loop over hits - } // Test if element is from HCAL - else if(elements[iEle].type() == reco::PFBlockElement::HFHAD){ // Element is HF - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 1) continue; // Remove long fibers - auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; - tpfjet_twr_ieta_.push_back((*ith).id().ieta()); - tpfjet_twr_iphi_.push_back((*ith).id().iphi()); - tpfjet_twr_depth_.push_back((*ith).id().depth()); - tpfjet_twr_subdet_.push_back((*ith).id().subdet()); - tpfjet_twr_hade_.push_back((*ith).energy()); - tpfjet_twr_frac_.push_back(1.0); - tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); - tpfjet_twr_elmttype_.push_back(1); - tpfjet_twr_clusterind_.push_back(-1); - tpfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_,tpfjet_phi_,avgeta,avgphi)); - ++tpfjet_ntwrs_; - HFHAD_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HFEM){ // Element is HF - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 2) continue; // Remove short fibers - auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; - tpfjet_twr_ieta_.push_back((*ith).id().ieta()); - tpfjet_twr_iphi_.push_back((*ith).id().iphi()); - tpfjet_twr_depth_.push_back((*ith).id().depth()); - tpfjet_twr_subdet_.push_back((*ith).id().subdet()); - tpfjet_twr_hade_.push_back((*ith).energy()); - tpfjet_twr_frac_.push_back(1.0); - tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); - tpfjet_twr_elmttype_.push_back(2); - tpfjet_twr_clusterind_.push_back(-1); - tpfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_,tpfjet_phi_,avgeta,avgphi)); - ++tpfjet_ntwrs_; - HFEM_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HO){ // Element is HO - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(tpfjet_eta_,tpfjet_phi_,cluster.eta(),cluster.phi()); - if(tpfjet_clusters.count(cluster_dR) == 0){ - tpfjet_clusters[cluster_dR] = tpfjet_cluster_n_; - tpfjet_cluster_eta_.push_back(cluster.eta()); - tpfjet_cluster_phi_.push_back(cluster.phi()); - tpfjet_cluster_dR_.push_back(cluster_dR); - tpfjet_cluster_n_++; - } - int cluster_ind = tpfjet_clusters[cluster_dR]; - - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; - if(tpfjet_rechits.count((*ith).id()) == 0){ - tpfjet_twr_ieta_.push_back((*ith).id().ieta()); - tpfjet_twr_iphi_.push_back((*ith).id().iphi()); - tpfjet_twr_depth_.push_back((*ith).id().depth()); - tpfjet_twr_subdet_.push_back((*ith).id().subdet()); - if(hitsAndFracs[iHit].second > 0.05 && (*ith).energy() > 0.0) twrietas[(*ith).id().ieta()]++; - tpfjet_twr_hade_.push_back((*ith).energy()); - tpfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); - tpfjet_twr_elmttype_.push_back(3); - tpfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - tpfjet_twr_candtrackind_.push_back(tpfjet_ncandtracks_ - 1); - } - else{ - tpfjet_twr_candtrackind_.push_back(-1); - } - auto thisCell = HOGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_,tpfjet_phi_,avgeta,avgphi)); - tpfjet_rechits[(*ith).id()].first = tpfjet_ntwrs_; - ++tpfjet_ntwrs_; - } - else if(tpfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - tpfjet_twr_frac_.at(tpfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < tpfjet_cluster_dR_.at(tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first))){ - tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first) = cluster_ind; - } - tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi match - } // Loop over rechits - } // Loop over hits - } // Test if element is HO - } // Test for right element index - } // Loop over elements - } // Loop over elements in blocks - - switch(candidateType){ - case reco::PFCandidate::h_HF: - tpfjet_had_emf_.push_back(HFEM_E/(HFEM_E + HFHAD_E)); - break; - case reco::PFCandidate::egamma_HF: - tpfjet_had_emf_.push_back(-1); - break; - default: - tpfjet_had_emf_.push_back(-1); - break; + for (unsigned iEle = 0; iEle < elements.size(); iEle++) { + if (elements[iEle].index() == (*it)->elementsInBlocks()[e].second) { + if (elements[iEle].type() == reco::PFBlockElement::HCAL) { // Element is HB or HE + // Get cluster and hits + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(tpfjet_eta_, tpfjet_phi_, cluster.eta(), cluster.phi()); + if (tpfjet_clusters.count(cluster_dR) == 0) { + tpfjet_clusters[cluster_dR] = tpfjet_cluster_n_; + tpfjet_cluster_eta_.push_back(cluster.eta()); + tpfjet_cluster_phi_.push_back(cluster.phi()); + tpfjet_cluster_dR_.push_back(cluster_dR); + tpfjet_cluster_n_++; + } + int cluster_ind = tpfjet_clusters[cluster_dR]; + + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + + // Run over hits and match + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + hbhereco->begin(); + ith != hbhereco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; + if (tpfjet_rechits.count((*ith).id()) == 0) { + tpfjet_twr_ieta_.push_back((*ith).id().ieta()); + tpfjet_twr_iphi_.push_back((*ith).id().iphi()); + tpfjet_twr_depth_.push_back((*ith).id().depth()); + tpfjet_twr_subdet_.push_back((*ith).id().subdet()); + if (hitsAndFracs[iHit].second > 0.05 && (*ith).energy() > 0.0) + twrietas[(*ith).id().ieta()]++; + tpfjet_twr_hade_.push_back((*ith).energy()); + tpfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); + tpfjet_twr_elmttype_.push_back(0); + tpfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + tpfjet_twr_candtrackind_.push_back(tpfjet_ncandtracks_ - 1); + } else { + tpfjet_twr_candtrackind_.push_back(-1); + } + switch ((*ith).id().subdet()) { + case HcalSubdetector::HcalBarrel: { + CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_, tpfjet_phi_, avgeta, avgphi)); + break; + } + case HcalSubdetector::HcalEndcap: { + CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_, tpfjet_phi_, avgeta, avgphi)); + break; + } + default: + tpfjet_twr_dR_.push_back(-1); + break; + } + tpfjet_rechits[(*ith).id()].first = tpfjet_ntwrs_; + ++tpfjet_ntwrs_; + } else if (tpfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + tpfjet_twr_frac_.at(tpfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + tpfjet_cluster_dR_.at(tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first))) { + tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first) = cluster_ind; + } + tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi matches + } // Loop over rechits + } // Loop over hits + } // Test if element is from HCAL + else if (elements[iEle].type() == reco::PFBlockElement::HFHAD) { // Element is HF + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 1) + continue; // Remove long fibers + auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; + tpfjet_twr_ieta_.push_back((*ith).id().ieta()); + tpfjet_twr_iphi_.push_back((*ith).id().iphi()); + tpfjet_twr_depth_.push_back((*ith).id().depth()); + tpfjet_twr_subdet_.push_back((*ith).id().subdet()); + tpfjet_twr_hade_.push_back((*ith).energy()); + tpfjet_twr_frac_.push_back(1.0); + tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); + tpfjet_twr_elmttype_.push_back(1); + tpfjet_twr_clusterind_.push_back(-1); + tpfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_, tpfjet_phi_, avgeta, avgphi)); + ++tpfjet_ntwrs_; + HFHAD_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HFEM) { // Element is HF + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 2) + continue; // Remove short fibers + auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; + tpfjet_twr_ieta_.push_back((*ith).id().ieta()); + tpfjet_twr_iphi_.push_back((*ith).id().iphi()); + tpfjet_twr_depth_.push_back((*ith).id().depth()); + tpfjet_twr_subdet_.push_back((*ith).id().subdet()); + tpfjet_twr_hade_.push_back((*ith).energy()); + tpfjet_twr_frac_.push_back(1.0); + tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); + tpfjet_twr_elmttype_.push_back(2); + tpfjet_twr_clusterind_.push_back(-1); + tpfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_, tpfjet_phi_, avgeta, avgphi)); + ++tpfjet_ntwrs_; + HFEM_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HO) { // Element is HO + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(tpfjet_eta_, tpfjet_phi_, cluster.eta(), cluster.phi()); + if (tpfjet_clusters.count(cluster_dR) == 0) { + tpfjet_clusters[cluster_dR] = tpfjet_cluster_n_; + tpfjet_cluster_eta_.push_back(cluster.eta()); + tpfjet_cluster_phi_.push_back(cluster.phi()); + tpfjet_cluster_dR_.push_back(cluster_dR); + tpfjet_cluster_n_++; + } + int cluster_ind = tpfjet_clusters[cluster_dR]; + + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + horeco->begin(); + ith != horeco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + tpfjet_had_ntwrs_.at(tpfjet_had_n_ - 1)++; + if (tpfjet_rechits.count((*ith).id()) == 0) { + tpfjet_twr_ieta_.push_back((*ith).id().ieta()); + tpfjet_twr_iphi_.push_back((*ith).id().iphi()); + tpfjet_twr_depth_.push_back((*ith).id().depth()); + tpfjet_twr_subdet_.push_back((*ith).id().subdet()); + if (hitsAndFracs[iHit].second > 0.05 && (*ith).energy() > 0.0) + twrietas[(*ith).id().ieta()]++; + tpfjet_twr_hade_.push_back((*ith).energy()); + tpfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + tpfjet_twr_hadind_.push_back(tpfjet_had_n_ - 1); + tpfjet_twr_elmttype_.push_back(3); + tpfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + tpfjet_twr_candtrackind_.push_back(tpfjet_ncandtracks_ - 1); + } else { + tpfjet_twr_candtrackind_.push_back(-1); + } + auto thisCell = HOGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / + 2.0; + tpfjet_twr_dR_.push_back(deltaR(tpfjet_eta_, tpfjet_phi_, avgeta, avgphi)); + tpfjet_rechits[(*ith).id()].first = tpfjet_ntwrs_; + ++tpfjet_ntwrs_; + } else if (tpfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + tpfjet_twr_frac_.at(tpfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + tpfjet_cluster_dR_.at(tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first))) { + tpfjet_twr_clusterind_.at(tpfjet_rechits[(*ith).id()].first) = cluster_ind; + } + tpfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi match + } // Loop over rechits + } // Loop over hits + } // Test if element is HO + } // Test for right element index + } // Loop over elements + } // Loop over elements in blocks + + switch (candidateType) { + case reco::PFCandidate::h_HF: + tpfjet_had_emf_.push_back(HFEM_E / (HFEM_E + HFHAD_E)); + break; + case reco::PFCandidate::egamma_HF: + tpfjet_had_emf_.push_back(-1); + break; + default: + tpfjet_had_emf_.push_back(-1); + break; } - } // Loop over PF constitutents + } // Loop over PF constitutents int tag_had_EcalE = 0; int tag_had_rawHcalE = 0; - for(int i=0; ipt(); - ppfjet_p_ = pf_probe.jet()->p(); - ppfjet_E_ = pf_probe.jet()->energy(); - ppfjet_eta_ = pf_probe.jet()->eta(); - ppfjet_phi_ = pf_probe.jet()->phi(); + ppfjet_pt_ = pf_probe.jet()->pt(); + ppfjet_p_ = pf_probe.jet()->p(); + ppfjet_E_ = pf_probe.jet()->energy(); + ppfjet_eta_ = pf_probe.jet()->eta(); + ppfjet_phi_ = pf_probe.jet()->phi(); ppfjet_scale_ = pf_probe.scale(); - ppfjet_area_ = pf_probe.jet()->jetArea(); - ppfjet_ntwrs_=0; - ppfjet_ncandtracks_=0; - - ppfjet_jetID_ = 0; // Not a loose, medium, or tight jet - if(fabs(pf_probe.jet()->eta()) < 2.4){ - if(pf_probe.jet()->chargedHadronEnergyFraction() > 0 && - pf_probe.jet()->chargedMultiplicity() > 0 && - pf_probe.jet()->chargedEmEnergyFraction() < 0.99 && - (pf_probe.jet()->chargedMultiplicity() + pf_probe.jet()->neutralMultiplicity()) > 1){ - if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.9 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.9){ - ppfjet_jetID_ = 3; // Tight jet - } - else if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.95 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.95){ - ppfjet_jetID_ = 2; // Medium jet - } - else if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.99 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.99){ - ppfjet_jetID_ = 1; // Loose jet + ppfjet_area_ = pf_probe.jet()->jetArea(); + ppfjet_ntwrs_ = 0; + ppfjet_ncandtracks_ = 0; + + ppfjet_jetID_ = 0; // Not a loose, medium, or tight jet + if (fabs(pf_probe.jet()->eta()) < 2.4) { + if (pf_probe.jet()->chargedHadronEnergyFraction() > 0 && pf_probe.jet()->chargedMultiplicity() > 0 && + pf_probe.jet()->chargedEmEnergyFraction() < 0.99 && + (pf_probe.jet()->chargedMultiplicity() + pf_probe.jet()->neutralMultiplicity()) > 1) { + if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.9 && pf_probe.jet()->neutralEmEnergyFraction() < 0.9) { + ppfjet_jetID_ = 3; // Tight jet + } else if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.95 && + pf_probe.jet()->neutralEmEnergyFraction() < 0.95) { + ppfjet_jetID_ = 2; // Medium jet + } else if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.99 && + pf_probe.jet()->neutralEmEnergyFraction() < 0.99) { + ppfjet_jetID_ = 1; // Loose jet } } - } - else if((pf_probe.jet()->chargedMultiplicity() + pf_probe.jet()->neutralMultiplicity()) > 1){ - if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.9 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.9){ - ppfjet_jetID_ = 3; // Tight jet - } - else if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.95 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.95){ - ppfjet_jetID_ = 2; // Medium jet - } - else if(pf_probe.jet()->neutralHadronEnergyFraction() < 0.99 && - pf_probe.jet()->neutralEmEnergyFraction() < 0.99){ - ppfjet_jetID_ = 1; // Loose jet + } else if ((pf_probe.jet()->chargedMultiplicity() + pf_probe.jet()->neutralMultiplicity()) > 1) { + if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.9 && pf_probe.jet()->neutralEmEnergyFraction() < 0.9) { + ppfjet_jetID_ = 3; // Tight jet + } else if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.95 && + pf_probe.jet()->neutralEmEnergyFraction() < 0.95) { + ppfjet_jetID_ = 2; // Medium jet + } else if (pf_probe.jet()->neutralHadronEnergyFraction() < 0.99 && + pf_probe.jet()->neutralEmEnergyFraction() < 0.99) { + ppfjet_jetID_ = 1; // Loose jet } } // Get PF constituents and fill HCAL towers - std::vector probeconst=pf_probe.jet()->getPFConstituents(); - for(std::vector::const_iterator it=probeconst.begin(); it!=probeconst.end(); ++it){ + std::vector probeconst = pf_probe.jet()->getPFConstituents(); + for (std::vector::const_iterator it = probeconst.begin(); it != probeconst.end(); ++it) { bool hasTrack = false; reco::PFCandidate::ParticleType candidateType = (*it)->particleId(); - switch(candidateType){ - case reco::PFCandidate::X: - ppfjet_unkown_E_ += (*it)->energy(); - ppfjet_unkown_px_ += (*it)->px(); - ppfjet_unkown_py_ += (*it)->py(); - ppfjet_unkown_pz_ += (*it)->pz(); - ppfjet_unkown_EcalE_ += (*it)->ecalEnergy(); - ppfjet_unkown_n_++; - continue; - case reco::PFCandidate::h: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(0); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - - reco::TrackRef trackRef = (*it)->trackRef(); - if(trackRef.isNonnull()){ - reco::Track track = *trackRef; - ppfjet_candtrack_px_.push_back(track.px()); - ppfjet_candtrack_py_.push_back(track.py()); - ppfjet_candtrack_pz_.push_back(track.pz()); - ppfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_candtrackind_.push_back(ppfjet_ncandtracks_); - hasTrack = true; - ppfjet_ncandtracks_++; - } - else{ - ppfjet_had_candtrackind_.push_back(-2); - } - } - break; - case reco::PFCandidate::e: - ppfjet_electron_E_ += (*it)->energy(); - ppfjet_electron_px_ += (*it)->px(); - ppfjet_electron_py_ += (*it)->py(); - ppfjet_electron_pz_ += (*it)->pz(); - ppfjet_electron_EcalE_ += (*it)->ecalEnergy(); - ppfjet_electron_n_++; - continue; - case reco::PFCandidate::mu: - ppfjet_muon_E_ += (*it)->energy(); - ppfjet_muon_px_ += (*it)->px(); - ppfjet_muon_py_ += (*it)->py(); - ppfjet_muon_pz_ += (*it)->pz(); - ppfjet_muon_EcalE_ += (*it)->ecalEnergy(); - ppfjet_muon_n_++; - continue; - case reco::PFCandidate::gamma: - ppfjet_photon_E_ += (*it)->energy(); - ppfjet_photon_px_ += (*it)->px(); - ppfjet_photon_py_ += (*it)->py(); - ppfjet_photon_pz_ += (*it)->pz(); - ppfjet_photon_EcalE_ += (*it)->ecalEnergy(); - ppfjet_photon_n_++; - continue; - case reco::PFCandidate::h0: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(1); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - break; + switch (candidateType) { + case reco::PFCandidate::X: + ppfjet_unkown_E_ += (*it)->energy(); + ppfjet_unkown_px_ += (*it)->px(); + ppfjet_unkown_py_ += (*it)->py(); + ppfjet_unkown_pz_ += (*it)->pz(); + ppfjet_unkown_EcalE_ += (*it)->ecalEnergy(); + ppfjet_unkown_n_++; + continue; + case reco::PFCandidate::h: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(0); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + + reco::TrackRef trackRef = (*it)->trackRef(); + if (trackRef.isNonnull()) { + reco::Track track = *trackRef; + ppfjet_candtrack_px_.push_back(track.px()); + ppfjet_candtrack_py_.push_back(track.py()); + ppfjet_candtrack_pz_.push_back(track.pz()); + ppfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_candtrackind_.push_back(ppfjet_ncandtracks_); + hasTrack = true; + ppfjet_ncandtracks_++; + } else { + ppfjet_had_candtrackind_.push_back(-2); + } + } break; + case reco::PFCandidate::e: + ppfjet_electron_E_ += (*it)->energy(); + ppfjet_electron_px_ += (*it)->px(); + ppfjet_electron_py_ += (*it)->py(); + ppfjet_electron_pz_ += (*it)->pz(); + ppfjet_electron_EcalE_ += (*it)->ecalEnergy(); + ppfjet_electron_n_++; + continue; + case reco::PFCandidate::mu: + ppfjet_muon_E_ += (*it)->energy(); + ppfjet_muon_px_ += (*it)->px(); + ppfjet_muon_py_ += (*it)->py(); + ppfjet_muon_pz_ += (*it)->pz(); + ppfjet_muon_EcalE_ += (*it)->ecalEnergy(); + ppfjet_muon_n_++; + continue; + case reco::PFCandidate::gamma: + ppfjet_photon_E_ += (*it)->energy(); + ppfjet_photon_px_ += (*it)->px(); + ppfjet_photon_py_ += (*it)->py(); + ppfjet_photon_pz_ += (*it)->pz(); + ppfjet_photon_EcalE_ += (*it)->ecalEnergy(); + ppfjet_photon_n_++; + continue; + case reco::PFCandidate::h0: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(1); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + break; } - case reco::PFCandidate::h_HF: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(2); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - break; + case reco::PFCandidate::h_HF: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(2); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + break; } - case reco::PFCandidate::egamma_HF: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(3); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - break; + case reco::PFCandidate::egamma_HF: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(3); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + break; } } float HFHAD_E = 0; float HFEM_E = 0; - int maxElement=(*it)->elementsInBlocks().size(); - for(int e=0; eelementsInBlocks().size(); + for (int e = 0; e < maxElement; ++e) { // Get elements from block reco::PFBlockRef blockRef = (*it)->elementsInBlocks()[e].first; const edm::OwnVector& elements = blockRef->elements(); - for(unsigned iEle=0; iEleelementsInBlocks()[e].second){ - if(elements[iEle].type() == reco::PFBlockElement::HCAL){ // Element is HB or HE - // Get cluster and hits - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi()); - if(ppfjet_clusters.count(cluster_dR) == 0){ - ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; - ppfjet_cluster_eta_.push_back(cluster.eta()); - ppfjet_cluster_phi_.push_back(cluster.phi()); - ppfjet_cluster_dR_.push_back(cluster_dR); - ppfjet_cluster_n_++; - } - int cluster_ind = ppfjet_clusters[cluster_dR]; - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - - // Run over hits and match - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - if(ppfjet_rechits.count((*ith).id()) == 0){ - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(0); - ppfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); - } - else{ - ppfjet_twr_candtrackind_.push_back(-1); - } - switch((*ith).id().subdet()){ - case HcalSubdetector::HcalBarrel: - { - CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - break; - } - case HcalSubdetector::HcalEndcap: - { - CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - break; - } - default: - ppfjet_twr_dR_.push_back(-1); - break; - } - ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; - ++ppfjet_ntwrs_; - } - else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){ - ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; - } - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi matches - } // Loop over rechits - } // Loop over hits - } // Test if element is from HCAL - else if(elements[iEle].type() == reco::PFBlockElement::HFHAD){ // Element is HF - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 1) continue; // Remove long fibers - auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(1.0); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(1); - ppfjet_twr_clusterind_.push_back(-1); - ppfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ++ppfjet_ntwrs_; - HFHAD_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HFEM){ // Element is HF - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 2) continue; // Remove short fibers - auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(1.0); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(2); - ppfjet_twr_clusterind_.push_back(-1); - ppfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ++ppfjet_ntwrs_; - HFEM_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HO){ // Element is HO - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi()); - if(ppfjet_clusters.count(cluster_dR) == 0){ - ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; - ppfjet_cluster_eta_.push_back(cluster.eta()); - ppfjet_cluster_phi_.push_back(cluster.phi()); - ppfjet_cluster_dR_.push_back(cluster_dR); - ppfjet_cluster_n_++; - } - int cluster_ind = ppfjet_clusters[cluster_dR]; - - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - if(ppfjet_rechits.count((*ith).id()) == 0){ - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(3); - ppfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); - } - else{ - ppfjet_twr_candtrackind_.push_back(-1); - } - auto thisCell = HOGeom->getGeometry((*ith).id().rawId()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; - ++ppfjet_ntwrs_; - } - else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){ - ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; - } - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi match - } // Loop over rechits - } // Loop over hits - } // Test if element is from HO - } // Test for right element index - } // Loop over elements - } // Loop over elements in blocks - switch(candidateType){ - case reco::PFCandidate::h_HF: - ppfjet_had_emf_.push_back(HFEM_E/(HFEM_E + HFHAD_E)); - break; - case reco::PFCandidate::egamma_HF: - ppfjet_had_emf_.push_back(-1); - break; - default: - ppfjet_had_emf_.push_back(-1); - break; + for (unsigned iEle = 0; iEle < elements.size(); iEle++) { + if (elements[iEle].index() == (*it)->elementsInBlocks()[e].second) { + if (elements[iEle].type() == reco::PFBlockElement::HCAL) { // Element is HB or HE + // Get cluster and hits + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(ppfjet_eta_, ppfjet_phi_, cluster.eta(), cluster.phi()); + if (ppfjet_clusters.count(cluster_dR) == 0) { + ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; + ppfjet_cluster_eta_.push_back(cluster.eta()); + ppfjet_cluster_phi_.push_back(cluster.phi()); + ppfjet_cluster_dR_.push_back(cluster_dR); + ppfjet_cluster_n_++; + } + int cluster_ind = ppfjet_clusters[cluster_dR]; + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + + // Run over hits and match + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + hbhereco->begin(); + ith != hbhereco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + if (ppfjet_rechits.count((*ith).id()) == 0) { + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(0); + ppfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); + } else { + ppfjet_twr_candtrackind_.push_back(-1); + } + switch ((*ith).id().subdet()) { + case HcalSubdetector::HcalBarrel: { + CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + break; + } + case HcalSubdetector::HcalEndcap: { + CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + break; + } + default: + ppfjet_twr_dR_.push_back(-1); + break; + } + ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; + ++ppfjet_ntwrs_; + } else if (ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))) { + ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; + } + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi matches + } // Loop over rechits + } // Loop over hits + } // Test if element is from HCAL + else if (elements[iEle].type() == reco::PFBlockElement::HFHAD) { // Element is HF + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 1) + continue; // Remove long fibers + auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(1.0); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(1); + ppfjet_twr_clusterind_.push_back(-1); + ppfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ++ppfjet_ntwrs_; + HFHAD_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HFEM) { // Element is HF + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 2) + continue; // Remove short fibers + auto thisCell = HFGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(1.0); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(2); + ppfjet_twr_clusterind_.push_back(-1); + ppfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ++ppfjet_ntwrs_; + HFEM_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HO) { // Element is HO + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(ppfjet_eta_, ppfjet_phi_, cluster.eta(), cluster.phi()); + if (ppfjet_clusters.count(cluster_dR) == 0) { + ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; + ppfjet_cluster_eta_.push_back(cluster.eta()); + ppfjet_cluster_phi_.push_back(cluster.phi()); + ppfjet_cluster_dR_.push_back(cluster_dR); + ppfjet_cluster_n_++; + } + int cluster_ind = ppfjet_clusters[cluster_dR]; + + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + horeco->begin(); + ith != horeco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + if (ppfjet_rechits.count((*ith).id()) == 0) { + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(3); + ppfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); + } else { + ppfjet_twr_candtrackind_.push_back(-1); + } + auto thisCell = HOGeom->getGeometry((*ith).id().rawId()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; + ++ppfjet_ntwrs_; + } else if (ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))) { + ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; + } + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi match + } // Loop over rechits + } // Loop over hits + } // Test if element is from HO + } // Test for right element index + } // Loop over elements + } // Loop over elements in blocks + switch (candidateType) { + case reco::PFCandidate::h_HF: + ppfjet_had_emf_.push_back(HFEM_E / (HFEM_E + HFHAD_E)); + break; + case reco::PFCandidate::egamma_HF: + ppfjet_had_emf_.push_back(-1); + break; + default: + ppfjet_had_emf_.push_back(-1); + break; } - } // Loop over PF constitutents + } // Loop over PF constitutents int probe_had_EcalE = 0; int probe_had_rawHcalE = 0; - for(int i=0; ieta())-std::fabs(pf_probe.jet()->eta())); - pf_dijet_dphi_=pf_tag.jet()->phi()-pf_probe.jet()->phi(); - if(pf_dijet_dphi_>3.1415) pf_dijet_dphi_ = 6.2832-pf_dijet_dphi_; - pf_dijet_balance_ = (tpfjet_pt_-ppfjet_pt_)/(tpfjet_pt_+ppfjet_pt_); - + pf_dijet_deta_ = std::fabs(std::fabs(pf_tag.jet()->eta()) - std::fabs(pf_probe.jet()->eta())); + pf_dijet_dphi_ = pf_tag.jet()->phi() - pf_probe.jet()->phi(); + if (pf_dijet_dphi_ > 3.1415) + pf_dijet_dphi_ = 6.2832 - pf_dijet_dphi_; + pf_dijet_balance_ = (tpfjet_pt_ - ppfjet_pt_) / (tpfjet_pt_ + ppfjet_pt_); + tree_->Fill(); - + return; } // ------------ method called once each job just before starting event loop ------------ -void DiJetAnalyzer::beginJob() -{ +void DiJetAnalyzer::beginJob() { // book histograms rootfile_ = new TFile(rootHistFilename_.c_str(), "RECREATE"); - h_PassSelPF_ = new TH1D("h_PassSelectionPF", "Selection Pass Failures PFJets",200,-0.5,199.5); + h_PassSelPF_ = new TH1D("h_PassSelectionPF", "Selection Pass Failures PFJets", 200, -0.5, 199.5); tree_ = new TTree("dijettree", "tree for dijet balancing"); - tree_->Branch("tpfjet_pt",&tpfjet_pt_, "tpfjet_pt/F"); - tree_->Branch("tpfjet_p",&tpfjet_p_, "tpfjet_p/F"); - tree_->Branch("tpfjet_E",&tpfjet_E_, "tpfjet_E/F"); - tree_->Branch("tpfjet_eta",&tpfjet_eta_, "tpfjet_eta/F"); - tree_->Branch("tpfjet_phi",&tpfjet_phi_, "tpfjet_phi/F"); - tree_->Branch("tpfjet_EMfrac",&tpfjet_EMfrac_, "tpfjet_EMfrac/F"); - tree_->Branch("tpfjet_hadEcalEfrac",&tpfjet_hadEcalEfrac_, "tpfjet_hadEcalEfrac/F"); - tree_->Branch("tpfjet_scale",&tpfjet_scale_, "tpfjet_scale/F"); - tree_->Branch("tpfjet_area",&tpfjet_area_, "tpfjet_area/F"); - tree_->Branch("tpfjet_jetID",&tpfjet_jetID_, "tpfjet_jetID/I"); - tree_->Branch("tpfjet_unkown_E",&tpfjet_unkown_E_, "tpfjet_unkown_E/F"); - tree_->Branch("tpfjet_electron_E",&tpfjet_electron_E_, "tpfjet_electron_E/F"); - tree_->Branch("tpfjet_muon_E",&tpfjet_muon_E_, "tpfjet_muon_E/F"); - tree_->Branch("tpfjet_photon_E",&tpfjet_photon_E_, "tpfjet_photon_E/F"); - tree_->Branch("tpfjet_unkown_px",&tpfjet_unkown_px_, "tpfjet_unkown_px/F"); - tree_->Branch("tpfjet_electron_px",&tpfjet_electron_px_, "tpfjet_electron_px/F"); - tree_->Branch("tpfjet_muon_px",&tpfjet_muon_px_, "tpfjet_muon_px/F"); - tree_->Branch("tpfjet_photon_px",&tpfjet_photon_px_, "tpfjet_photon_px/F"); - tree_->Branch("tpfjet_unkown_py",&tpfjet_unkown_py_, "tpfjet_unkown_py/F"); - tree_->Branch("tpfjet_electron_py",&tpfjet_electron_py_, "tpfjet_electron_py/F"); - tree_->Branch("tpfjet_muon_py",&tpfjet_muon_py_, "tpfjet_muon_py/F"); - tree_->Branch("tpfjet_photon_py",&tpfjet_photon_py_, "tpfjet_photon_py/F"); - tree_->Branch("tpfjet_unkown_pz",&tpfjet_unkown_pz_, "tpfjet_unkown_pz/F"); - tree_->Branch("tpfjet_electron_pz",&tpfjet_electron_pz_, "tpfjet_electron_pz/F"); - tree_->Branch("tpfjet_muon_pz",&tpfjet_muon_pz_, "tpfjet_muon_pz/F"); - tree_->Branch("tpfjet_photon_pz",&tpfjet_photon_pz_, "tpfjet_photon_pz/F"); - tree_->Branch("tpfjet_unkown_EcalE",&tpfjet_unkown_EcalE_, "tpfjet_unkown_EcalE/F"); - tree_->Branch("tpfjet_electron_EcalE",&tpfjet_electron_EcalE_, "tpfjet_electron_EcalE/F"); - tree_->Branch("tpfjet_muon_EcalE",&tpfjet_muon_EcalE_, "tpfjet_muon_EcalE/F"); - tree_->Branch("tpfjet_photon_EcalE",&tpfjet_photon_EcalE_, "tpfjet_photon_EcalE/F"); - tree_->Branch("tpfjet_unkown_n",&tpfjet_unkown_n_, "tpfjet_unkown_n/I"); - tree_->Branch("tpfjet_electron_n",&tpfjet_electron_n_, "tpfjet_electron_n/I"); - tree_->Branch("tpfjet_muon_n",&tpfjet_muon_n_, "tpfjet_muon_n/I"); - tree_->Branch("tpfjet_photon_n",&tpfjet_photon_n_, "tpfjet_photon_n/I"); - tree_->Branch("tpfjet_had_n",&tpfjet_had_n_, "tpfjet_had_n/I"); - tree_->Branch("tpfjet_had_E",&tpfjet_had_E_); - tree_->Branch("tpfjet_had_px",&tpfjet_had_px_); - tree_->Branch("tpfjet_had_py",&tpfjet_had_py_); - tree_->Branch("tpfjet_had_pz",&tpfjet_had_pz_); - tree_->Branch("tpfjet_had_EcalE",&tpfjet_had_EcalE_); - tree_->Branch("tpfjet_had_rawHcalE",&tpfjet_had_rawHcalE_); - tree_->Branch("tpfjet_had_emf",&tpfjet_had_emf_); - tree_->Branch("tpfjet_had_id",&tpfjet_had_id_); - tree_->Branch("tpfjet_had_candtrackind",&tpfjet_had_candtrackind_); - tree_->Branch("tpfjet_had_ntwrs",&tpfjet_had_ntwrs_); - tree_->Branch("tpfjet_ntwrs",&tpfjet_ntwrs_, "tpfjet_ntwrs/I"); - tree_->Branch("tpfjet_twr_ieta",&tpfjet_twr_ieta_); - tree_->Branch("tpfjet_twr_iphi",&tpfjet_twr_iphi_); - tree_->Branch("tpfjet_twr_depth",&tpfjet_twr_depth_); - tree_->Branch("tpfjet_twr_subdet",&tpfjet_twr_subdet_); - tree_->Branch("tpfjet_twr_hade",&tpfjet_twr_hade_); - tree_->Branch("tpfjet_twr_frac",&tpfjet_twr_frac_); - tree_->Branch("tpfjet_twr_candtrackind",&tpfjet_twr_candtrackind_); - tree_->Branch("tpfjet_twr_hadind",&tpfjet_twr_hadind_); - tree_->Branch("tpfjet_twr_elmttype",&tpfjet_twr_elmttype_); - tree_->Branch("tpfjet_twr_dR",&tpfjet_twr_dR_); - tree_->Branch("tpfjet_twr_clusterind",&tpfjet_twr_clusterind_); - tree_->Branch("tpfjet_cluster_n",&tpfjet_cluster_n_, "tpfjet_cluster_n/I"); - tree_->Branch("tpfjet_cluster_eta",&tpfjet_cluster_eta_); - tree_->Branch("tpfjet_cluster_phi",&tpfjet_cluster_phi_); - tree_->Branch("tpfjet_cluster_dR",&tpfjet_cluster_dR_); - tree_->Branch("tpfjet_ncandtracks",&tpfjet_ncandtracks_, "tpfjet_ncandtracks/I"); - tree_->Branch("tpfjet_candtrack_px",&tpfjet_candtrack_px_); - tree_->Branch("tpfjet_candtrack_py",&tpfjet_candtrack_py_); - tree_->Branch("tpfjet_candtrack_pz",&tpfjet_candtrack_pz_); - tree_->Branch("tpfjet_candtrack_EcalE",&tpfjet_candtrack_EcalE_); - tree_->Branch("ppfjet_pt",&ppfjet_pt_, "ppfjet_pt/F"); - tree_->Branch("ppfjet_p",&ppfjet_p_, "ppfjet_p/F"); - tree_->Branch("ppfjet_E",&ppfjet_E_, "ppfjet_E/F"); - tree_->Branch("ppfjet_eta",&ppfjet_eta_, "ppfjet_eta/F"); - tree_->Branch("ppfjet_phi",&ppfjet_phi_, "ppfjet_phi/F"); - tree_->Branch("ppfjet_EMfrac",&ppfjet_EMfrac_, "ppfjet_EMfrac/F"); - tree_->Branch("ppfjet_hadEcalEfrac",&ppfjet_hadEcalEfrac_, "ppfjet_hadEcalEfrac/F"); - tree_->Branch("ppfjet_scale",&ppfjet_scale_, "ppfjet_scale/F"); - tree_->Branch("ppfjet_area",&ppfjet_area_, "ppfjet_area/F"); - tree_->Branch("ppfjet_jetID",&ppfjet_jetID_, "ppfjet_jetID/I"); - tree_->Branch("ppfjet_unkown_E",&ppfjet_unkown_E_, "ppfjet_unkown_E/F"); - tree_->Branch("ppfjet_electron_E",&ppfjet_electron_E_, "ppfjet_electron_E/F"); - tree_->Branch("ppfjet_muon_E",&ppfjet_muon_E_, "ppfjet_muon_E/F"); - tree_->Branch("ppfjet_photon_E",&ppfjet_photon_E_, "ppfjet_photon_E/F"); - tree_->Branch("ppfjet_unkown_px",&ppfjet_unkown_px_, "ppfjet_unkown_px/F"); - tree_->Branch("ppfjet_electron_px",&ppfjet_electron_px_, "ppfjet_electron_px/F"); - tree_->Branch("ppfjet_muon_px",&ppfjet_muon_px_, "ppfjet_muon_px/F"); - tree_->Branch("ppfjet_photon_px",&ppfjet_photon_px_, "ppfjet_photon_px/F"); - tree_->Branch("ppfjet_unkown_py",&ppfjet_unkown_py_, "ppfjet_unkown_py/F"); - tree_->Branch("ppfjet_electron_py",&ppfjet_electron_py_, "ppfjet_electron_py/F"); - tree_->Branch("ppfjet_muon_py",&ppfjet_muon_py_, "ppfjet_muon_py/F"); - tree_->Branch("ppfjet_photon_py",&ppfjet_photon_py_, "ppfjet_photon_py/F"); - tree_->Branch("ppfjet_unkown_pz",&ppfjet_unkown_pz_, "ppfjet_unkown_pz/F"); - tree_->Branch("ppfjet_electron_pz",&ppfjet_electron_pz_, "ppfjet_electron_pz/F"); - tree_->Branch("ppfjet_muon_pz",&ppfjet_muon_pz_, "ppfjet_muon_pz/F"); - tree_->Branch("ppfjet_photon_pz",&ppfjet_photon_pz_, "ppfjet_photon_pz/F"); - tree_->Branch("ppfjet_unkown_EcalE",&ppfjet_unkown_EcalE_, "ppfjet_unkown_EcalE/F"); - tree_->Branch("ppfjet_electron_EcalE",&ppfjet_electron_EcalE_, "ppfjet_electron_EcalE/F"); - tree_->Branch("ppfjet_muon_EcalE",&ppfjet_muon_EcalE_, "ppfjet_muon_EcalE/F"); - tree_->Branch("ppfjet_photon_EcalE",&ppfjet_photon_EcalE_, "ppfjet_photon_EcalE/F"); - tree_->Branch("ppfjet_unkown_n",&ppfjet_unkown_n_, "ppfjet_unkown_n/I"); - tree_->Branch("ppfjet_electron_n",&ppfjet_electron_n_, "ppfjet_electron_n/I"); - tree_->Branch("ppfjet_muon_n",&ppfjet_muon_n_, "ppfjet_muon_n/I"); - tree_->Branch("ppfjet_photon_n",&ppfjet_photon_n_, "ppfjet_photon_n/I"); - tree_->Branch("ppfjet_had_n",&ppfjet_had_n_, "ppfjet_had_n/I"); - tree_->Branch("ppfjet_had_E",&ppfjet_had_E_); - tree_->Branch("ppfjet_had_px",&ppfjet_had_px_); - tree_->Branch("ppfjet_had_py",&ppfjet_had_py_); - tree_->Branch("ppfjet_had_pz",&ppfjet_had_pz_); - tree_->Branch("ppfjet_had_EcalE",&ppfjet_had_EcalE_); - tree_->Branch("ppfjet_had_rawHcalE",&ppfjet_had_rawHcalE_); - tree_->Branch("ppfjet_had_emf",&ppfjet_had_emf_); - tree_->Branch("ppfjet_had_id",&ppfjet_had_id_); - tree_->Branch("ppfjet_had_candtrackind",&ppfjet_had_candtrackind_); - tree_->Branch("ppfjet_had_ntwrs",&ppfjet_had_ntwrs_); - tree_->Branch("ppfjet_ntwrs",&ppfjet_ntwrs_, "ppfjet_ntwrs/I"); - tree_->Branch("ppfjet_twr_ieta",&ppfjet_twr_ieta_); - tree_->Branch("ppfjet_twr_iphi",&ppfjet_twr_iphi_); - tree_->Branch("ppfjet_twr_depth",&ppfjet_twr_depth_); - tree_->Branch("ppfjet_twr_subdet",&ppfjet_twr_subdet_); - tree_->Branch("ppfjet_twr_hade",&ppfjet_twr_hade_); - tree_->Branch("ppfjet_twr_frac",&ppfjet_twr_frac_); - tree_->Branch("ppfjet_twr_candtrackind",&ppfjet_twr_candtrackind_); - tree_->Branch("ppfjet_twr_hadind",&ppfjet_twr_hadind_); - tree_->Branch("ppfjet_twr_elmttype",&ppfjet_twr_elmttype_); - tree_->Branch("ppfjet_twr_dR",&ppfjet_twr_dR_); - tree_->Branch("ppfjet_twr_clusterind",&ppfjet_twr_clusterind_); - tree_->Branch("ppfjet_cluster_n",&ppfjet_cluster_n_, "ppfjet_cluster_n/I"); - tree_->Branch("ppfjet_cluster_eta",&ppfjet_cluster_eta_); - tree_->Branch("ppfjet_cluster_phi",&ppfjet_cluster_phi_); - tree_->Branch("ppfjet_cluster_dR",&ppfjet_cluster_dR_); - tree_->Branch("ppfjet_ncandtracks",&ppfjet_ncandtracks_, "ppfjet_ncandtracks/I"); - tree_->Branch("ppfjet_candtrack_px",&ppfjet_candtrack_px_); - tree_->Branch("ppfjet_candtrack_py",&ppfjet_candtrack_py_); - tree_->Branch("ppfjet_candtrack_pz",&ppfjet_candtrack_pz_); - tree_->Branch("ppfjet_candtrack_EcalE",&ppfjet_candtrack_EcalE_); - tree_->Branch("pf_dijet_deta",&pf_dijet_deta_, "pf_dijet_deta/F"); - tree_->Branch("pf_dijet_dphi",&pf_dijet_dphi_, "pf_dijet_dphi/F"); - tree_->Branch("pf_dijet_balance",&pf_dijet_balance_, "pf_dijet_balance/F"); - tree_->Branch("pf_thirdjet_px",&pf_thirdjet_px_, "pf_thirdjet_px/F"); - tree_->Branch("pf_thirdjet_py",&pf_thirdjet_py_, "pf_thirdjet_py/F"); - tree_->Branch("pf_realthirdjet_px",&pf_realthirdjet_px_, "pf_realthirdjet_px/F"); - tree_->Branch("pf_realthirdjet_py",&pf_realthirdjet_py_, "pf_realthirdjet_py/F"); - tree_->Branch("pf_realthirdjet_scale",&pf_realthirdjet_scale_, "pf_realthirdjet_scale/F"); - tree_->Branch("pf_Run",&pf_Run_, "pf_Run/I"); - tree_->Branch("pf_Lumi",&pf_Lumi_, "pf_Lumi/I"); - tree_->Branch("pf_Event",&pf_Event_, "pf_Event/I"); - tree_->Branch("pf_NPV",&pf_NPV_, "pf_NPV/I"); + tree_->Branch("tpfjet_pt", &tpfjet_pt_, "tpfjet_pt/F"); + tree_->Branch("tpfjet_p", &tpfjet_p_, "tpfjet_p/F"); + tree_->Branch("tpfjet_E", &tpfjet_E_, "tpfjet_E/F"); + tree_->Branch("tpfjet_eta", &tpfjet_eta_, "tpfjet_eta/F"); + tree_->Branch("tpfjet_phi", &tpfjet_phi_, "tpfjet_phi/F"); + tree_->Branch("tpfjet_EMfrac", &tpfjet_EMfrac_, "tpfjet_EMfrac/F"); + tree_->Branch("tpfjet_hadEcalEfrac", &tpfjet_hadEcalEfrac_, "tpfjet_hadEcalEfrac/F"); + tree_->Branch("tpfjet_scale", &tpfjet_scale_, "tpfjet_scale/F"); + tree_->Branch("tpfjet_area", &tpfjet_area_, "tpfjet_area/F"); + tree_->Branch("tpfjet_jetID", &tpfjet_jetID_, "tpfjet_jetID/I"); + tree_->Branch("tpfjet_unkown_E", &tpfjet_unkown_E_, "tpfjet_unkown_E/F"); + tree_->Branch("tpfjet_electron_E", &tpfjet_electron_E_, "tpfjet_electron_E/F"); + tree_->Branch("tpfjet_muon_E", &tpfjet_muon_E_, "tpfjet_muon_E/F"); + tree_->Branch("tpfjet_photon_E", &tpfjet_photon_E_, "tpfjet_photon_E/F"); + tree_->Branch("tpfjet_unkown_px", &tpfjet_unkown_px_, "tpfjet_unkown_px/F"); + tree_->Branch("tpfjet_electron_px", &tpfjet_electron_px_, "tpfjet_electron_px/F"); + tree_->Branch("tpfjet_muon_px", &tpfjet_muon_px_, "tpfjet_muon_px/F"); + tree_->Branch("tpfjet_photon_px", &tpfjet_photon_px_, "tpfjet_photon_px/F"); + tree_->Branch("tpfjet_unkown_py", &tpfjet_unkown_py_, "tpfjet_unkown_py/F"); + tree_->Branch("tpfjet_electron_py", &tpfjet_electron_py_, "tpfjet_electron_py/F"); + tree_->Branch("tpfjet_muon_py", &tpfjet_muon_py_, "tpfjet_muon_py/F"); + tree_->Branch("tpfjet_photon_py", &tpfjet_photon_py_, "tpfjet_photon_py/F"); + tree_->Branch("tpfjet_unkown_pz", &tpfjet_unkown_pz_, "tpfjet_unkown_pz/F"); + tree_->Branch("tpfjet_electron_pz", &tpfjet_electron_pz_, "tpfjet_electron_pz/F"); + tree_->Branch("tpfjet_muon_pz", &tpfjet_muon_pz_, "tpfjet_muon_pz/F"); + tree_->Branch("tpfjet_photon_pz", &tpfjet_photon_pz_, "tpfjet_photon_pz/F"); + tree_->Branch("tpfjet_unkown_EcalE", &tpfjet_unkown_EcalE_, "tpfjet_unkown_EcalE/F"); + tree_->Branch("tpfjet_electron_EcalE", &tpfjet_electron_EcalE_, "tpfjet_electron_EcalE/F"); + tree_->Branch("tpfjet_muon_EcalE", &tpfjet_muon_EcalE_, "tpfjet_muon_EcalE/F"); + tree_->Branch("tpfjet_photon_EcalE", &tpfjet_photon_EcalE_, "tpfjet_photon_EcalE/F"); + tree_->Branch("tpfjet_unkown_n", &tpfjet_unkown_n_, "tpfjet_unkown_n/I"); + tree_->Branch("tpfjet_electron_n", &tpfjet_electron_n_, "tpfjet_electron_n/I"); + tree_->Branch("tpfjet_muon_n", &tpfjet_muon_n_, "tpfjet_muon_n/I"); + tree_->Branch("tpfjet_photon_n", &tpfjet_photon_n_, "tpfjet_photon_n/I"); + tree_->Branch("tpfjet_had_n", &tpfjet_had_n_, "tpfjet_had_n/I"); + tree_->Branch("tpfjet_had_E", &tpfjet_had_E_); + tree_->Branch("tpfjet_had_px", &tpfjet_had_px_); + tree_->Branch("tpfjet_had_py", &tpfjet_had_py_); + tree_->Branch("tpfjet_had_pz", &tpfjet_had_pz_); + tree_->Branch("tpfjet_had_EcalE", &tpfjet_had_EcalE_); + tree_->Branch("tpfjet_had_rawHcalE", &tpfjet_had_rawHcalE_); + tree_->Branch("tpfjet_had_emf", &tpfjet_had_emf_); + tree_->Branch("tpfjet_had_id", &tpfjet_had_id_); + tree_->Branch("tpfjet_had_candtrackind", &tpfjet_had_candtrackind_); + tree_->Branch("tpfjet_had_ntwrs", &tpfjet_had_ntwrs_); + tree_->Branch("tpfjet_ntwrs", &tpfjet_ntwrs_, "tpfjet_ntwrs/I"); + tree_->Branch("tpfjet_twr_ieta", &tpfjet_twr_ieta_); + tree_->Branch("tpfjet_twr_iphi", &tpfjet_twr_iphi_); + tree_->Branch("tpfjet_twr_depth", &tpfjet_twr_depth_); + tree_->Branch("tpfjet_twr_subdet", &tpfjet_twr_subdet_); + tree_->Branch("tpfjet_twr_hade", &tpfjet_twr_hade_); + tree_->Branch("tpfjet_twr_frac", &tpfjet_twr_frac_); + tree_->Branch("tpfjet_twr_candtrackind", &tpfjet_twr_candtrackind_); + tree_->Branch("tpfjet_twr_hadind", &tpfjet_twr_hadind_); + tree_->Branch("tpfjet_twr_elmttype", &tpfjet_twr_elmttype_); + tree_->Branch("tpfjet_twr_dR", &tpfjet_twr_dR_); + tree_->Branch("tpfjet_twr_clusterind", &tpfjet_twr_clusterind_); + tree_->Branch("tpfjet_cluster_n", &tpfjet_cluster_n_, "tpfjet_cluster_n/I"); + tree_->Branch("tpfjet_cluster_eta", &tpfjet_cluster_eta_); + tree_->Branch("tpfjet_cluster_phi", &tpfjet_cluster_phi_); + tree_->Branch("tpfjet_cluster_dR", &tpfjet_cluster_dR_); + tree_->Branch("tpfjet_ncandtracks", &tpfjet_ncandtracks_, "tpfjet_ncandtracks/I"); + tree_->Branch("tpfjet_candtrack_px", &tpfjet_candtrack_px_); + tree_->Branch("tpfjet_candtrack_py", &tpfjet_candtrack_py_); + tree_->Branch("tpfjet_candtrack_pz", &tpfjet_candtrack_pz_); + tree_->Branch("tpfjet_candtrack_EcalE", &tpfjet_candtrack_EcalE_); + tree_->Branch("ppfjet_pt", &ppfjet_pt_, "ppfjet_pt/F"); + tree_->Branch("ppfjet_p", &ppfjet_p_, "ppfjet_p/F"); + tree_->Branch("ppfjet_E", &ppfjet_E_, "ppfjet_E/F"); + tree_->Branch("ppfjet_eta", &ppfjet_eta_, "ppfjet_eta/F"); + tree_->Branch("ppfjet_phi", &ppfjet_phi_, "ppfjet_phi/F"); + tree_->Branch("ppfjet_EMfrac", &ppfjet_EMfrac_, "ppfjet_EMfrac/F"); + tree_->Branch("ppfjet_hadEcalEfrac", &ppfjet_hadEcalEfrac_, "ppfjet_hadEcalEfrac/F"); + tree_->Branch("ppfjet_scale", &ppfjet_scale_, "ppfjet_scale/F"); + tree_->Branch("ppfjet_area", &ppfjet_area_, "ppfjet_area/F"); + tree_->Branch("ppfjet_jetID", &ppfjet_jetID_, "ppfjet_jetID/I"); + tree_->Branch("ppfjet_unkown_E", &ppfjet_unkown_E_, "ppfjet_unkown_E/F"); + tree_->Branch("ppfjet_electron_E", &ppfjet_electron_E_, "ppfjet_electron_E/F"); + tree_->Branch("ppfjet_muon_E", &ppfjet_muon_E_, "ppfjet_muon_E/F"); + tree_->Branch("ppfjet_photon_E", &ppfjet_photon_E_, "ppfjet_photon_E/F"); + tree_->Branch("ppfjet_unkown_px", &ppfjet_unkown_px_, "ppfjet_unkown_px/F"); + tree_->Branch("ppfjet_electron_px", &ppfjet_electron_px_, "ppfjet_electron_px/F"); + tree_->Branch("ppfjet_muon_px", &ppfjet_muon_px_, "ppfjet_muon_px/F"); + tree_->Branch("ppfjet_photon_px", &ppfjet_photon_px_, "ppfjet_photon_px/F"); + tree_->Branch("ppfjet_unkown_py", &ppfjet_unkown_py_, "ppfjet_unkown_py/F"); + tree_->Branch("ppfjet_electron_py", &ppfjet_electron_py_, "ppfjet_electron_py/F"); + tree_->Branch("ppfjet_muon_py", &ppfjet_muon_py_, "ppfjet_muon_py/F"); + tree_->Branch("ppfjet_photon_py", &ppfjet_photon_py_, "ppfjet_photon_py/F"); + tree_->Branch("ppfjet_unkown_pz", &ppfjet_unkown_pz_, "ppfjet_unkown_pz/F"); + tree_->Branch("ppfjet_electron_pz", &ppfjet_electron_pz_, "ppfjet_electron_pz/F"); + tree_->Branch("ppfjet_muon_pz", &ppfjet_muon_pz_, "ppfjet_muon_pz/F"); + tree_->Branch("ppfjet_photon_pz", &ppfjet_photon_pz_, "ppfjet_photon_pz/F"); + tree_->Branch("ppfjet_unkown_EcalE", &ppfjet_unkown_EcalE_, "ppfjet_unkown_EcalE/F"); + tree_->Branch("ppfjet_electron_EcalE", &ppfjet_electron_EcalE_, "ppfjet_electron_EcalE/F"); + tree_->Branch("ppfjet_muon_EcalE", &ppfjet_muon_EcalE_, "ppfjet_muon_EcalE/F"); + tree_->Branch("ppfjet_photon_EcalE", &ppfjet_photon_EcalE_, "ppfjet_photon_EcalE/F"); + tree_->Branch("ppfjet_unkown_n", &ppfjet_unkown_n_, "ppfjet_unkown_n/I"); + tree_->Branch("ppfjet_electron_n", &ppfjet_electron_n_, "ppfjet_electron_n/I"); + tree_->Branch("ppfjet_muon_n", &ppfjet_muon_n_, "ppfjet_muon_n/I"); + tree_->Branch("ppfjet_photon_n", &ppfjet_photon_n_, "ppfjet_photon_n/I"); + tree_->Branch("ppfjet_had_n", &ppfjet_had_n_, "ppfjet_had_n/I"); + tree_->Branch("ppfjet_had_E", &ppfjet_had_E_); + tree_->Branch("ppfjet_had_px", &ppfjet_had_px_); + tree_->Branch("ppfjet_had_py", &ppfjet_had_py_); + tree_->Branch("ppfjet_had_pz", &ppfjet_had_pz_); + tree_->Branch("ppfjet_had_EcalE", &ppfjet_had_EcalE_); + tree_->Branch("ppfjet_had_rawHcalE", &ppfjet_had_rawHcalE_); + tree_->Branch("ppfjet_had_emf", &ppfjet_had_emf_); + tree_->Branch("ppfjet_had_id", &ppfjet_had_id_); + tree_->Branch("ppfjet_had_candtrackind", &ppfjet_had_candtrackind_); + tree_->Branch("ppfjet_had_ntwrs", &ppfjet_had_ntwrs_); + tree_->Branch("ppfjet_ntwrs", &ppfjet_ntwrs_, "ppfjet_ntwrs/I"); + tree_->Branch("ppfjet_twr_ieta", &ppfjet_twr_ieta_); + tree_->Branch("ppfjet_twr_iphi", &ppfjet_twr_iphi_); + tree_->Branch("ppfjet_twr_depth", &ppfjet_twr_depth_); + tree_->Branch("ppfjet_twr_subdet", &ppfjet_twr_subdet_); + tree_->Branch("ppfjet_twr_hade", &ppfjet_twr_hade_); + tree_->Branch("ppfjet_twr_frac", &ppfjet_twr_frac_); + tree_->Branch("ppfjet_twr_candtrackind", &ppfjet_twr_candtrackind_); + tree_->Branch("ppfjet_twr_hadind", &ppfjet_twr_hadind_); + tree_->Branch("ppfjet_twr_elmttype", &ppfjet_twr_elmttype_); + tree_->Branch("ppfjet_twr_dR", &ppfjet_twr_dR_); + tree_->Branch("ppfjet_twr_clusterind", &ppfjet_twr_clusterind_); + tree_->Branch("ppfjet_cluster_n", &ppfjet_cluster_n_, "ppfjet_cluster_n/I"); + tree_->Branch("ppfjet_cluster_eta", &ppfjet_cluster_eta_); + tree_->Branch("ppfjet_cluster_phi", &ppfjet_cluster_phi_); + tree_->Branch("ppfjet_cluster_dR", &ppfjet_cluster_dR_); + tree_->Branch("ppfjet_ncandtracks", &ppfjet_ncandtracks_, "ppfjet_ncandtracks/I"); + tree_->Branch("ppfjet_candtrack_px", &ppfjet_candtrack_px_); + tree_->Branch("ppfjet_candtrack_py", &ppfjet_candtrack_py_); + tree_->Branch("ppfjet_candtrack_pz", &ppfjet_candtrack_pz_); + tree_->Branch("ppfjet_candtrack_EcalE", &ppfjet_candtrack_EcalE_); + tree_->Branch("pf_dijet_deta", &pf_dijet_deta_, "pf_dijet_deta/F"); + tree_->Branch("pf_dijet_dphi", &pf_dijet_dphi_, "pf_dijet_dphi/F"); + tree_->Branch("pf_dijet_balance", &pf_dijet_balance_, "pf_dijet_balance/F"); + tree_->Branch("pf_thirdjet_px", &pf_thirdjet_px_, "pf_thirdjet_px/F"); + tree_->Branch("pf_thirdjet_py", &pf_thirdjet_py_, "pf_thirdjet_py/F"); + tree_->Branch("pf_realthirdjet_px", &pf_realthirdjet_px_, "pf_realthirdjet_px/F"); + tree_->Branch("pf_realthirdjet_py", &pf_realthirdjet_py_, "pf_realthirdjet_py/F"); + tree_->Branch("pf_realthirdjet_scale", &pf_realthirdjet_scale_, "pf_realthirdjet_scale/F"); + tree_->Branch("pf_Run", &pf_Run_, "pf_Run/I"); + tree_->Branch("pf_Lumi", &pf_Lumi_, "pf_Lumi/I"); + tree_->Branch("pf_Event", &pf_Event_, "pf_Event/I"); + tree_->Branch("pf_NPV", &pf_NPV_, "pf_NPV/I"); return; -} +} // ------------ method called once each job just after ending the event loop ------------ -void -DiJetAnalyzer::endJob() { +void DiJetAnalyzer::endJob() { // write histograms rootfile_->cd(); @@ -1256,37 +1293,33 @@ DiJetAnalyzer::endJob() { tree_->Write(); rootfile_->Close(); - } // helper function -double DiJetAnalyzer::deltaR(const reco::Jet* j1, const reco::Jet* j2) -{ - double deta = j1->eta()-j2->eta(); - double dphi = std::fabs(j1->phi()-j2->phi()); - if(dphi>3.1415927) dphi = 2*3.1415927 - dphi; - return std::sqrt(deta*deta + dphi*dphi); +double DiJetAnalyzer::deltaR(const reco::Jet* j1, const reco::Jet* j2) { + double deta = j1->eta() - j2->eta(); + double dphi = std::fabs(j1->phi() - j2->phi()); + if (dphi > 3.1415927) + dphi = 2 * 3.1415927 - dphi; + return std::sqrt(deta * deta + dphi * dphi); } -double DiJetAnalyzer::deltaR(const double eta1, const double phi1, const double eta2, const double phi2) -{ +double DiJetAnalyzer::deltaR(const double eta1, const double phi1, const double eta2, const double phi2) { double deta = eta1 - eta2; double dphi = std::fabs(phi1 - phi2); - if(dphi>3.1415927) dphi = 2*3.1415927 - dphi; - return std::sqrt(deta*deta + dphi*dphi); + if (dphi > 3.1415927) + dphi = 2 * 3.1415927 - dphi; + return std::sqrt(deta * deta + dphi * dphi); } -int DiJetAnalyzer::getEtaPhi(const DetId id) -{ - return id.rawId() & 0x3FFF; // Get 14 least-significant digits +int DiJetAnalyzer::getEtaPhi(const DetId id) { + return id.rawId() & 0x3FFF; // Get 14 least-significant digits } -int DiJetAnalyzer::getEtaPhi(const HcalDetId id) -{ - return id.rawId() & 0x3FFF; // Get 14 least-significant digits +int DiJetAnalyzer::getEtaPhi(const HcalDetId id) { + return id.rawId() & 0x3FFF; // Get 14 least-significant digits } - //define this as a plug-in DEFINE_FWK_MODULE(DiJetAnalyzer); diff --git a/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.h b/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.h index 8ce4b8192f374..cbbc39c5d2c5a 100644 --- a/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.h +++ b/Calibration/HcalCalibAlgos/test/DiJetAnalyzer.h @@ -59,60 +59,62 @@ class TTree; // class JetCorretPair : protected std::pair { - public: +public: JetCorretPair() { - first=0; - second=1.0; + first = 0; + second = 1.0; } JetCorretPair(const reco::PFJet* j, double s) { - first=j; - second=s; + first = j; + second = s; } ~JetCorretPair() {} inline const reco::PFJet* jet(void) const { return first; } - inline void jet(const reco::PFJet* j) { first=j; return; } + inline void jet(const reco::PFJet* j) { + first = j; + return; + } inline double scale(void) const { return second; } - inline void scale(double d) { second=d; return; } + inline void scale(double d) { + second = d; + return; + } - private: - +private: }; class DiJetAnalyzer : public edm::EDAnalyzer { - public: +public: explicit DiJetAnalyzer(const edm::ParameterSet&); ~DiJetAnalyzer(); - - - private: - virtual void beginJob();//(const edm::EventSetup&); + +private: + virtual void beginJob(); //(const edm::EventSetup&); virtual void analyze(const edm::Event&, const edm::EventSetup&); virtual void endJob(); - // parameters - bool debug_; // print debug statements - std::string pfJetCollName_; // label for the PF jet collection - std::string pfJetCorrName_; // label for the PF jet correction service - std::string hbheRecHitName_; // label for HBHERecHits collection - std::string hfRecHitName_; // label for HFRecHit collection - std::string hoRecHitName_; // label for HORecHit collection - std::string pvCollName_; // label for primary vertex collection - std::string rootHistFilename_; // name of the histogram file - double maxDeltaEta_; // maximum delta-|Eta| between Jets - double minTagJetEta_; // minimum |eta| of the tag jet - double maxTagJetEta_; // maximum |eta| of the tag jet - double minSumJetEt_; // minimum Sum of the tag and probe jet Et - double minJetEt_; // minimum Jet Et - double maxThirdJetEt_; // maximum 3rd jet Et - - edm::EDGetTokenT tok_PFJet_; - edm::EDGetTokenT > > tok_HBHE_; - edm::EDGetTokenT > > tok_HF_; - edm::EDGetTokenT > > tok_HO_; - edm::EDGetTokenT tok_Vertex_; - + bool debug_; // print debug statements + std::string pfJetCollName_; // label for the PF jet collection + std::string pfJetCorrName_; // label for the PF jet correction service + std::string hbheRecHitName_; // label for HBHERecHits collection + std::string hfRecHitName_; // label for HFRecHit collection + std::string hoRecHitName_; // label for HORecHit collection + std::string pvCollName_; // label for primary vertex collection + std::string rootHistFilename_; // name of the histogram file + double maxDeltaEta_; // maximum delta-|Eta| between Jets + double minTagJetEta_; // minimum |eta| of the tag jet + double maxTagJetEta_; // maximum |eta| of the tag jet + double minSumJetEt_; // minimum Sum of the tag and probe jet Et + double minJetEt_; // minimum Jet Et + double maxThirdJetEt_; // maximum 3rd jet Et + + edm::EDGetTokenT tok_PFJet_; + edm::EDGetTokenT > > tok_HBHE_; + edm::EDGetTokenT > > tok_HF_; + edm::EDGetTokenT > > tok_HO_; + edm::EDGetTokenT tok_Vertex_; // root file/histograms TFile* rootfile_; @@ -120,7 +122,8 @@ class DiJetAnalyzer : public edm::EDAnalyzer { TH1D* h_PassSelPF_; TTree* tree_; - float tpfjet_pt_, tpfjet_p_, tpfjet_E_, tpfjet_eta_, tpfjet_phi_, tpfjet_EMfrac_, tpfjet_hadEcalEfrac_, tpfjet_scale_, tpfjet_area_; + float tpfjet_pt_, tpfjet_p_, tpfjet_E_, tpfjet_eta_, tpfjet_phi_, tpfjet_EMfrac_, tpfjet_hadEcalEfrac_, tpfjet_scale_, + tpfjet_area_; int tpfjet_jetID_; float tpfjet_EBE_, tpfjet_EEE_, tpfjet_HBE_, tpfjet_HEE_, tpfjet_HFE_; float tpfjet_unkown_E_, tpfjet_unkown_px_, tpfjet_unkown_py_, tpfjet_unkown_pz_, tpfjet_unkown_EcalE_; @@ -129,16 +132,19 @@ class DiJetAnalyzer : public edm::EDAnalyzer { float tpfjet_photon_E_, tpfjet_photon_px_, tpfjet_photon_py_, tpfjet_photon_pz_, tpfjet_photon_EcalE_; int tpfjet_unkown_n_, tpfjet_electron_n_, tpfjet_muon_n_, tpfjet_photon_n_; int tpfjet_had_n_; - std::vector tpfjet_had_E_, tpfjet_had_px_, tpfjet_had_py_, tpfjet_had_pz_, tpfjet_had_EcalE_, tpfjet_had_rawHcalE_, tpfjet_had_emf_; + std::vector tpfjet_had_E_, tpfjet_had_px_, tpfjet_had_py_, tpfjet_had_pz_, tpfjet_had_EcalE_, + tpfjet_had_rawHcalE_, tpfjet_had_emf_; std::vector tpfjet_had_id_, tpfjet_had_candtrackind_, tpfjet_had_ntwrs_; int tpfjet_ntwrs_; - std::vector tpfjet_twr_ieta_, tpfjet_twr_iphi_, tpfjet_twr_depth_, tpfjet_twr_subdet_, tpfjet_twr_candtrackind_, tpfjet_twr_hadind_, tpfjet_twr_elmttype_, tpfjet_twr_clusterind_; + std::vector tpfjet_twr_ieta_, tpfjet_twr_iphi_, tpfjet_twr_depth_, tpfjet_twr_subdet_, tpfjet_twr_candtrackind_, + tpfjet_twr_hadind_, tpfjet_twr_elmttype_, tpfjet_twr_clusterind_; std::vector tpfjet_twr_hade_, tpfjet_twr_frac_, tpfjet_twr_dR_; int tpfjet_cluster_n_; std::vector tpfjet_cluster_eta_, tpfjet_cluster_phi_, tpfjet_cluster_dR_; int tpfjet_ncandtracks_; std::vector tpfjet_candtrack_px_, tpfjet_candtrack_py_, tpfjet_candtrack_pz_, tpfjet_candtrack_EcalE_; - float ppfjet_pt_, ppfjet_p_, ppfjet_E_, ppfjet_eta_, ppfjet_phi_, ppfjet_EMfrac_, ppfjet_hadEcalEfrac_, ppfjet_scale_, ppfjet_area_; + float ppfjet_pt_, ppfjet_p_, ppfjet_E_, ppfjet_eta_, ppfjet_phi_, ppfjet_EMfrac_, ppfjet_hadEcalEfrac_, ppfjet_scale_, + ppfjet_area_; int ppfjet_jetID_; float ppfjet_EBE_, ppfjet_EEE_, ppfjet_HBE_, ppfjet_HEE_, ppfjet_HFE_; float ppfjet_unkown_E_, ppfjet_unkown_px_, ppfjet_unkown_py_, ppfjet_unkown_pz_, ppfjet_unkown_EcalE_; @@ -147,10 +153,12 @@ class DiJetAnalyzer : public edm::EDAnalyzer { float ppfjet_photon_E_, ppfjet_photon_px_, ppfjet_photon_py_, ppfjet_photon_pz_, ppfjet_photon_EcalE_; int ppfjet_unkown_n_, ppfjet_electron_n_, ppfjet_muon_n_, ppfjet_photon_n_; int ppfjet_had_n_; - std::vector ppfjet_had_E_, ppfjet_had_px_, ppfjet_had_py_, ppfjet_had_pz_, ppfjet_had_EcalE_, ppfjet_had_rawHcalE_, ppfjet_had_emf_; + std::vector ppfjet_had_E_, ppfjet_had_px_, ppfjet_had_py_, ppfjet_had_pz_, ppfjet_had_EcalE_, + ppfjet_had_rawHcalE_, ppfjet_had_emf_; std::vector ppfjet_had_id_, ppfjet_had_candtrackind_, ppfjet_had_ntwrs_; int ppfjet_ntwrs_; - std::vector ppfjet_twr_ieta_, ppfjet_twr_iphi_, ppfjet_twr_depth_, ppfjet_twr_subdet_, ppfjet_twr_candtrackind_, ppfjet_twr_hadind_, ppfjet_twr_elmttype_, ppfjet_twr_clusterind_; + std::vector ppfjet_twr_ieta_, ppfjet_twr_iphi_, ppfjet_twr_depth_, ppfjet_twr_subdet_, ppfjet_twr_candtrackind_, + ppfjet_twr_hadind_, ppfjet_twr_elmttype_, ppfjet_twr_clusterind_; std::vector ppfjet_twr_hade_, ppfjet_twr_frac_, ppfjet_twr_dR_; int ppfjet_cluster_n_; std::vector ppfjet_cluster_eta_, ppfjet_cluster_phi_, ppfjet_cluster_dR_; @@ -168,12 +176,10 @@ class DiJetAnalyzer : public edm::EDAnalyzer { int getEtaPhi(const HcalDetId id); struct JetCorretPairComp { - inline bool operator() ( const JetCorretPair& a, const JetCorretPair& b) const{ - return (a.jet()->pt()*a.scale()) > (b.jet()->pt()*b.scale()); + inline bool operator()(const JetCorretPair& a, const JetCorretPair& b) const { + return (a.jet()->pt() * a.scale()) > (b.jet()->pt() * b.scale()); } }; - }; - #endif diff --git a/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.cc b/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.cc index b59c28ed1a66c..c93c61b37f0b1 100644 --- a/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.cc +++ b/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.cc @@ -20,91 +20,157 @@ #include #include -inline void HERE(const char *msg) { - if (0 && msg) edm::LogWarning("GammaJetAnalysis") << msg; +inline void HERE(const char* msg) { + if (0 && msg) + edm::LogWarning("GammaJetAnalysis") << msg; } double getNeutralPVCorr(double eta, int intNPV, double area, bool isMC_) { double NPV = static_cast(intNPV); - double etaArray[101] = {-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4, -3.9, -3.8, -3.7, -3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9, -2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5}; + double etaArray[101] = {-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4, -3.9, -3.8, -3.7, -3.6, + -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9, -2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, + -2, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, + -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, + 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, + 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, + 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5}; int ind = -1; - for(int i=0; i<100; ++i){ - if(eta > etaArray[i] && eta < etaArray[i+1]){ + for (int i = 0; i < 100; ++i) { + if (eta > etaArray[i] && eta < etaArray[i + 1]) { ind = i; break; } } - if(ind < 0) return 0; + if (ind < 0) + return 0; double pt_density; - if(isMC_){ - double p0[100] = {0.08187, 0.096718, 0.11565, 0.12115, 0.12511, 0.12554, 0.13858, 0.14282, 0.14302, 0.15054, 0.14136, 0.14992, 0.13812, 0.13771, 0.13165, 0.12609, 0.12446, 0.11311, 0.13771, 0.16401, 0.20454, 0.27899, 0.34242, 0.43096, 0.50742, 0.59683, 0.66877, 0.68664, 0.69541, 0.66873, 0.64175, 0.61097, 0.58524, 0.5712, 0.55752, 0.54869, 0.31073, 0.22667, 0.55614, 0.55962, 0.54348, 0.53206, 0.51594, 0.49928, 0.49139, 0.48766, 0.49157, 0.49587, 0.50109, 0.5058, 0.51279, 0.51515, 0.51849, 0.52607, 0.52362, 0.52169, 0.53579, 0.54821, 0.56262, 0.58355, 0.58809, 0.57525, 0.52539, 0.53505, 0.52307, 0.52616, 0.52678, 0.53536, 0.55141, 0.58107, 0.60556, 0.62601, 0.60897, 0.59018, 0.49593, 0.40462, 0.32052, 0.24436, 0.18867, 0.12591, 0.095421, 0.090578, 0.078767, 0.11797, 0.14057, 0.14614, 0.15232, 0.14742, 0.15647, 0.14947, 0.15805, 0.14467, 0.14526, 0.14081, 0.1262, 0.12429, 0.11951, 0.11146, 0.095677, 0.083126}; - double p1[100] = {0.26831, 0.30901, 0.37017, 0.38747, 0.41547, 0.45237, 0.49963, 0.54074, 0.54949, 0.5937, 0.56904, 0.60766, 0.58042, 0.59823, 0.58535, 0.54594, 0.58403, 0.601, 0.65401, 0.65049, 0.65264, 0.6387, 0.60646, 0.59669, 0.55561, 0.5053, 0.42889, 0.37264, 0.36456, 0.36088, 0.36728, 0.37439, 0.38779, 0.40133, 0.40989, 0.41722, 0.47539, 0.49848, 0.42642, 0.42431, 0.42113, 0.41285, 0.41003, 0.41116, 0.41231, 0.41634, 0.41795, 0.41806, 0.41786, 0.41765, 0.41779, 0.41961, 0.42144, 0.42192, 0.4209, 0.41885, 0.4163, 0.4153, 0.41864, 0.4257, 0.43018, 0.43218, 0.43798, 0.42723, 0.42185, 0.41349, 0.40553, 0.39132, 0.3779, 0.37055, 0.36522, 0.37057, 0.38058, 0.43259, 0.51052, 0.55918, 0.60178, 0.60995, 0.64087, 0.65554, 0.65308, 0.65654, 0.60466, 0.58678, 0.54392, 0.58277, 0.59651, 0.57916, 0.60744, 0.56882, 0.59323, 0.5499, 0.54003, 0.49938, 0.4511, 0.41499, 0.38676, 0.36955, 0.30803, 0.26659}; - double p2[100] = {0.00080918, 0.00083447, 0.0011378, 0.0011221, 0.0013613, 0.0016362, 0.0015854, 0.0019131, 0.0017474, 0.0020078, 0.001856, 0.0020331, 0.0020823, 0.001898, 0.0020096, 0.0016464, 0.0032413, 0.0045615, 0.0054495, 0.0057584, 0.0058982, 0.0058956, 0.0055109, 0.0051433, 0.0042098, 0.0032096, 0.00044089, -0.0003884, -0.0007059, -0.00092769, -0.001116, -0.0010437, -0.00080318, -0.00044142, 6.7232e-05, 0.00055265, -0.0014486, -0.0020432, 0.0015121, 0.0016343, 0.0015638, 0.0015707, 0.0014403, 0.0012886, 0.0011684, 0.00099089, 0.00091497, 0.00087915, 0.00084703, 0.00084542, 0.00087419, 0.00088013, 0.00090493, 0.00095853, 0.0010389, 0.0011191, 0.0012643, 0.0013833, 0.001474, 0.0015401, 0.0015582, 0.0014265, 0.00087453, 0.00086639, 0.00042986, -5.0257e-06, -0.00053124, -0.00086417, -0.0011228, -0.0011749, -0.0010068, -0.00083012, -0.00062906, 0.00021515, 0.0028714, 0.0038835, 0.0047212, 0.0051427, 0.0055762, 0.0055872, 0.0054989, 0.0053033, 0.0044519, 0.0032223, 0.0017641, 0.0021165, 0.0019909, 0.0021061, 0.0020322, 0.0018357, 0.0019829, 0.001683, 0.0018553, 0.0015304, 0.0015822, 0.0013119, 0.0010745, 0.0010808, 0.00080678, 0.00079756}; - pt_density = p0[ind] + p1[ind]*(NPV - 1) + p2[ind]*(NPV - 1)*(NPV - 1); - } - else{ - double p0[100] = {0.12523, 0.14896, 0.17696, 0.19376, 0.20038, 0.21353, 0.25069, 0.27089, 0.29124, 0.31947, 0.31781, 0.35453, 0.35424, 0.38159, 0.39453, 0.4003, 0.34798, 0.26303, 0.24824, 0.22857, 0.22609, 0.26793, 0.30096, 0.37637, 0.44461, 0.55692, 0.70328, 0.72458, 0.75065, 0.73569, 0.72485, 0.69933, 0.69804, 0.70775, 0.70965, 0.71439, 0.72189, 0.73691, 0.74847, 0.74968, 0.73467, 0.70115, 0.6732, 0.65971, 0.65724, 0.67751, 0.69569, 0.70905, 0.71815, 0.72119, 0.72128, 0.71645, 0.70588, 0.68958, 0.66978, 0.65959, 0.66889, 0.68713, 0.71063, 0.74283, 0.75153, 0.74733, 0.73335, 0.71346, 0.70168, 0.69445, 0.68841, 0.67761, 0.67654, 0.6957, 0.70276, 0.71057, 0.68176, 0.64651, 0.49156, 0.38366, 0.31375, 0.24127, 0.21395, 0.17783, 0.19026, 0.21486, 0.24689, 0.3434, 0.40184, 0.39876, 0.3873, 0.36462, 0.36337, 0.32777, 0.328, 0.29868, 0.28087, 0.25713, 0.22466, 0.20784, 0.19798, 0.18054, 0.15022, 0.12811}; - double p1[100] = {0.26829, 0.30825, 0.37034, 0.38736, 0.41645, 0.45985, 0.51433, 0.56215, 0.5805, 0.63926, 0.62007, 0.67895, 0.66015, 0.68817, 0.67975, 0.64161, 0.70887, 0.74454, 0.80197, 0.78873, 0.77892, 0.74943, 0.70034, 0.6735, 0.60774, 0.53312, 0.42132, 0.36279, 0.3547, 0.35014, 0.35655, 0.3646, 0.37809, 0.38922, 0.39599, 0.40116, 0.40468, 0.40645, 0.40569, 0.4036, 0.39874, 0.39326, 0.39352, 0.39761, 0.40232, 0.40729, 0.41091, 0.41247, 0.413, 0.41283, 0.41289, 0.4134, 0.41322, 0.41185, 0.40769, 0.40193, 0.39707, 0.39254, 0.39274, 0.3989, 0.40474, 0.40758, 0.40788, 0.40667, 0.40433, 0.40013, 0.39371, 0.38154, 0.36723, 0.3583, 0.35148, 0.35556, 0.36172, 0.41073, 0.50629, 0.57068, 0.62972, 0.65188, 0.69954, 0.72967, 0.74333, 0.76148, 0.71418, 0.69062, 0.63065, 0.67117, 0.68278, 0.66028, 0.68147, 0.62494, 0.64452, 0.58685, 0.57076, 0.52387, 0.47132, 0.42637, 0.39554, 0.37989, 0.31825, 0.27969}; - double p2[100] = {-0.0014595, -0.0014618, -0.0011988, -0.00095404, -5.3893e-05, 0.00018901, 0.00012553, 0.0004172, 0.00020229, 0.00051942, 0.00052088, 0.00076727, 0.0010407, 0.0010184, 0.0013442, 0.0011271, 0.0032841, 0.0045259, 0.0051803, 0.0054477, 0.0055691, 0.0056668, 0.0053084, 0.0050978, 0.0042061, 0.003321, 0.00045155, 0.00021376, 0.0001178, -2.6836e-05, -0.00017689, -0.00014723, 0.00016887, 0.00067322, 0.0012952, 0.0019229, 0.0024702, 0.0028854, 0.0031576, 0.003284, 0.0032643, 0.0031061, 0.0028377, 0.0025386, 0.0022583, 0.0020448, 0.001888, 0.0017968, 0.0017286, 0.0016989, 0.0017014, 0.0017302, 0.0017958, 0.0018891, 0.0020609, 0.0022876, 0.0025391, 0.0028109, 0.0030294, 0.0031867, 0.0032068, 0.0030755, 0.0028181, 0.0023893, 0.0018359, 0.0012192, 0.00061654, 0.00016088, -0.00015204, -0.00019503, -3.7236e-05, 0.00016663, 0.00033833, 0.00082988, 0.0034005, 0.0042941, 0.0050884, 0.0052612, 0.0055901, 0.0054357, 0.0052671, 0.0049174, 0.0042236, 0.0031138, 0.0011733, 0.0014057, 0.0010843, 0.0010992, 0.0007966, 0.00052196, 0.00053029, 0.00021273, 0.00041664, 0.00010455, 0.00015173, -9.7827e-05, -0.0010859, -0.0013748, -0.0016641, -0.0016887}; - pt_density = p0[ind] + p1[ind]*(NPV - 1) + p2[ind]*(NPV - 1)*(NPV - 1); + if (isMC_) { + double p0[100] = {0.08187, 0.096718, 0.11565, 0.12115, 0.12511, 0.12554, 0.13858, 0.14282, 0.14302, 0.15054, + 0.14136, 0.14992, 0.13812, 0.13771, 0.13165, 0.12609, 0.12446, 0.11311, 0.13771, 0.16401, + 0.20454, 0.27899, 0.34242, 0.43096, 0.50742, 0.59683, 0.66877, 0.68664, 0.69541, 0.66873, + 0.64175, 0.61097, 0.58524, 0.5712, 0.55752, 0.54869, 0.31073, 0.22667, 0.55614, 0.55962, + 0.54348, 0.53206, 0.51594, 0.49928, 0.49139, 0.48766, 0.49157, 0.49587, 0.50109, 0.5058, + 0.51279, 0.51515, 0.51849, 0.52607, 0.52362, 0.52169, 0.53579, 0.54821, 0.56262, 0.58355, + 0.58809, 0.57525, 0.52539, 0.53505, 0.52307, 0.52616, 0.52678, 0.53536, 0.55141, 0.58107, + 0.60556, 0.62601, 0.60897, 0.59018, 0.49593, 0.40462, 0.32052, 0.24436, 0.18867, 0.12591, + 0.095421, 0.090578, 0.078767, 0.11797, 0.14057, 0.14614, 0.15232, 0.14742, 0.15647, 0.14947, + 0.15805, 0.14467, 0.14526, 0.14081, 0.1262, 0.12429, 0.11951, 0.11146, 0.095677, 0.083126}; + double p1[100] = {0.26831, 0.30901, 0.37017, 0.38747, 0.41547, 0.45237, 0.49963, 0.54074, 0.54949, 0.5937, + 0.56904, 0.60766, 0.58042, 0.59823, 0.58535, 0.54594, 0.58403, 0.601, 0.65401, 0.65049, + 0.65264, 0.6387, 0.60646, 0.59669, 0.55561, 0.5053, 0.42889, 0.37264, 0.36456, 0.36088, + 0.36728, 0.37439, 0.38779, 0.40133, 0.40989, 0.41722, 0.47539, 0.49848, 0.42642, 0.42431, + 0.42113, 0.41285, 0.41003, 0.41116, 0.41231, 0.41634, 0.41795, 0.41806, 0.41786, 0.41765, + 0.41779, 0.41961, 0.42144, 0.42192, 0.4209, 0.41885, 0.4163, 0.4153, 0.41864, 0.4257, + 0.43018, 0.43218, 0.43798, 0.42723, 0.42185, 0.41349, 0.40553, 0.39132, 0.3779, 0.37055, + 0.36522, 0.37057, 0.38058, 0.43259, 0.51052, 0.55918, 0.60178, 0.60995, 0.64087, 0.65554, + 0.65308, 0.65654, 0.60466, 0.58678, 0.54392, 0.58277, 0.59651, 0.57916, 0.60744, 0.56882, + 0.59323, 0.5499, 0.54003, 0.49938, 0.4511, 0.41499, 0.38676, 0.36955, 0.30803, 0.26659}; + double p2[100] = { + 0.00080918, 0.00083447, 0.0011378, 0.0011221, 0.0013613, 0.0016362, 0.0015854, 0.0019131, + 0.0017474, 0.0020078, 0.001856, 0.0020331, 0.0020823, 0.001898, 0.0020096, 0.0016464, + 0.0032413, 0.0045615, 0.0054495, 0.0057584, 0.0058982, 0.0058956, 0.0055109, 0.0051433, + 0.0042098, 0.0032096, 0.00044089, -0.0003884, -0.0007059, -0.00092769, -0.001116, -0.0010437, + -0.00080318, -0.00044142, 6.7232e-05, 0.00055265, -0.0014486, -0.0020432, 0.0015121, 0.0016343, + 0.0015638, 0.0015707, 0.0014403, 0.0012886, 0.0011684, 0.00099089, 0.00091497, 0.00087915, + 0.00084703, 0.00084542, 0.00087419, 0.00088013, 0.00090493, 0.00095853, 0.0010389, 0.0011191, + 0.0012643, 0.0013833, 0.001474, 0.0015401, 0.0015582, 0.0014265, 0.00087453, 0.00086639, + 0.00042986, -5.0257e-06, -0.00053124, -0.00086417, -0.0011228, -0.0011749, -0.0010068, -0.00083012, + -0.00062906, 0.00021515, 0.0028714, 0.0038835, 0.0047212, 0.0051427, 0.0055762, 0.0055872, + 0.0054989, 0.0053033, 0.0044519, 0.0032223, 0.0017641, 0.0021165, 0.0019909, 0.0021061, + 0.0020322, 0.0018357, 0.0019829, 0.001683, 0.0018553, 0.0015304, 0.0015822, 0.0013119, + 0.0010745, 0.0010808, 0.00080678, 0.00079756}; + pt_density = p0[ind] + p1[ind] * (NPV - 1) + p2[ind] * (NPV - 1) * (NPV - 1); + } else { + double p0[100] = {0.12523, 0.14896, 0.17696, 0.19376, 0.20038, 0.21353, 0.25069, 0.27089, 0.29124, 0.31947, + 0.31781, 0.35453, 0.35424, 0.38159, 0.39453, 0.4003, 0.34798, 0.26303, 0.24824, 0.22857, + 0.22609, 0.26793, 0.30096, 0.37637, 0.44461, 0.55692, 0.70328, 0.72458, 0.75065, 0.73569, + 0.72485, 0.69933, 0.69804, 0.70775, 0.70965, 0.71439, 0.72189, 0.73691, 0.74847, 0.74968, + 0.73467, 0.70115, 0.6732, 0.65971, 0.65724, 0.67751, 0.69569, 0.70905, 0.71815, 0.72119, + 0.72128, 0.71645, 0.70588, 0.68958, 0.66978, 0.65959, 0.66889, 0.68713, 0.71063, 0.74283, + 0.75153, 0.74733, 0.73335, 0.71346, 0.70168, 0.69445, 0.68841, 0.67761, 0.67654, 0.6957, + 0.70276, 0.71057, 0.68176, 0.64651, 0.49156, 0.38366, 0.31375, 0.24127, 0.21395, 0.17783, + 0.19026, 0.21486, 0.24689, 0.3434, 0.40184, 0.39876, 0.3873, 0.36462, 0.36337, 0.32777, + 0.328, 0.29868, 0.28087, 0.25713, 0.22466, 0.20784, 0.19798, 0.18054, 0.15022, 0.12811}; + double p1[100] = {0.26829, 0.30825, 0.37034, 0.38736, 0.41645, 0.45985, 0.51433, 0.56215, 0.5805, 0.63926, + 0.62007, 0.67895, 0.66015, 0.68817, 0.67975, 0.64161, 0.70887, 0.74454, 0.80197, 0.78873, + 0.77892, 0.74943, 0.70034, 0.6735, 0.60774, 0.53312, 0.42132, 0.36279, 0.3547, 0.35014, + 0.35655, 0.3646, 0.37809, 0.38922, 0.39599, 0.40116, 0.40468, 0.40645, 0.40569, 0.4036, + 0.39874, 0.39326, 0.39352, 0.39761, 0.40232, 0.40729, 0.41091, 0.41247, 0.413, 0.41283, + 0.41289, 0.4134, 0.41322, 0.41185, 0.40769, 0.40193, 0.39707, 0.39254, 0.39274, 0.3989, + 0.40474, 0.40758, 0.40788, 0.40667, 0.40433, 0.40013, 0.39371, 0.38154, 0.36723, 0.3583, + 0.35148, 0.35556, 0.36172, 0.41073, 0.50629, 0.57068, 0.62972, 0.65188, 0.69954, 0.72967, + 0.74333, 0.76148, 0.71418, 0.69062, 0.63065, 0.67117, 0.68278, 0.66028, 0.68147, 0.62494, + 0.64452, 0.58685, 0.57076, 0.52387, 0.47132, 0.42637, 0.39554, 0.37989, 0.31825, 0.27969}; + double p2[100] = { + -0.0014595, -0.0014618, -0.0011988, -0.00095404, -5.3893e-05, 0.00018901, 0.00012553, 0.0004172, + 0.00020229, 0.00051942, 0.00052088, 0.00076727, 0.0010407, 0.0010184, 0.0013442, 0.0011271, + 0.0032841, 0.0045259, 0.0051803, 0.0054477, 0.0055691, 0.0056668, 0.0053084, 0.0050978, + 0.0042061, 0.003321, 0.00045155, 0.00021376, 0.0001178, -2.6836e-05, -0.00017689, -0.00014723, + 0.00016887, 0.00067322, 0.0012952, 0.0019229, 0.0024702, 0.0028854, 0.0031576, 0.003284, + 0.0032643, 0.0031061, 0.0028377, 0.0025386, 0.0022583, 0.0020448, 0.001888, 0.0017968, + 0.0017286, 0.0016989, 0.0017014, 0.0017302, 0.0017958, 0.0018891, 0.0020609, 0.0022876, + 0.0025391, 0.0028109, 0.0030294, 0.0031867, 0.0032068, 0.0030755, 0.0028181, 0.0023893, + 0.0018359, 0.0012192, 0.00061654, 0.00016088, -0.00015204, -0.00019503, -3.7236e-05, 0.00016663, + 0.00033833, 0.00082988, 0.0034005, 0.0042941, 0.0050884, 0.0052612, 0.0055901, 0.0054357, + 0.0052671, 0.0049174, 0.0042236, 0.0031138, 0.0011733, 0.0014057, 0.0010843, 0.0010992, + 0.0007966, 0.00052196, 0.00053029, 0.00021273, 0.00041664, 0.00010455, 0.00015173, -9.7827e-05, + -0.0010859, -0.0013748, -0.0016641, -0.0016887}; + pt_density = p0[ind] + p1[ind] * (NPV - 1) + p2[ind] * (NPV - 1) * (NPV - 1); } - double ECorr = pt_density*area*cosh(eta); + double ECorr = pt_density * area * cosh(eta); return ECorr; } // ------------------------------------------------- -inline -unsigned int helper_findTrigger(const std::vector& list, - const std::string& name) -{ - boost::regex re(std::string("^(")+name+"|"+name+"_v\\d*)$"); - for (unsigned int i = 0,n = list.size() ; i < n ; ++i) { - if(boost::regex_match(list[i],re)) return i; +inline unsigned int helper_findTrigger(const std::vector& list, const std::string& name) { + boost::regex re(std::string("^(") + name + "|" + name + "_v\\d*)$"); + for (unsigned int i = 0, n = list.size(); i < n; ++i) { + if (boost::regex_match(list[i], re)) + return i; } return list.size(); } // ------------------------------------------------- -GammaJetAnalysis::GammaJetAnalysis(const edm::ParameterSet& iConfig) : - hltPrescaleProvider_(iConfig, consumesCollector(), *this) { - +GammaJetAnalysis::GammaJetAnalysis(const edm::ParameterSet& iConfig) + : hltPrescaleProvider_(iConfig, consumesCollector(), *this) { // set parameters - debug_ = iConfig.getUntrackedParameter("debug", 0); - debugHLTTrigNames = iConfig.getUntrackedParameter("debugHLTTrigNames",1); - debugEvent = iConfig.getUntrackedParameter("debugEvent",0); - pfMETColl = iConfig.getParameter("PFMETColl"); - pfType1METColl = iConfig.getParameter("PFMETTYPE1Coll"); - rhoCollection_ = iConfig.getParameter("rhoColl"); - photonCollName_ = iConfig.getParameter("photonCollName"); - pfJetCollName_ = iConfig.getParameter("pfJetCollName"); - pfJetCorrName_ = iConfig.getParameter("pfJetCorrName"); - genJetCollName_ = iConfig.getParameter("genJetCollName"); + debug_ = iConfig.getUntrackedParameter("debug", 0); + debugHLTTrigNames = iConfig.getUntrackedParameter("debugHLTTrigNames", 1); + debugEvent = iConfig.getUntrackedParameter("debugEvent", 0); + pfMETColl = iConfig.getParameter("PFMETColl"); + pfType1METColl = iConfig.getParameter("PFMETTYPE1Coll"); + rhoCollection_ = iConfig.getParameter("rhoColl"); + photonCollName_ = iConfig.getParameter("photonCollName"); + pfJetCollName_ = iConfig.getParameter("pfJetCollName"); + pfJetCorrName_ = iConfig.getParameter("pfJetCorrName"); + genJetCollName_ = iConfig.getParameter("genJetCollName"); genParticleCollName_ = iConfig.getParameter("genParticleCollName"); - genEventInfoName_ = iConfig.getParameter("genEventInfoName"); - hbheRecHitName_ = iConfig.getParameter("hbheRecHitName"); - hfRecHitName_ = iConfig.getParameter("hfRecHitName"); - hoRecHitName_ = iConfig.getParameter("hoRecHitName"); - rootHistFilename_ = iConfig.getParameter("rootHistFilename"); - pvCollName_ = iConfig.getParameter("pvCollName"); - prodProcess_ = "MYGAMMA"; + genEventInfoName_ = iConfig.getParameter("genEventInfoName"); + hbheRecHitName_ = iConfig.getParameter("hbheRecHitName"); + hfRecHitName_ = iConfig.getParameter("hfRecHitName"); + hoRecHitName_ = iConfig.getParameter("hoRecHitName"); + rootHistFilename_ = iConfig.getParameter("rootHistFilename"); + pvCollName_ = iConfig.getParameter("pvCollName"); + prodProcess_ = "MYGAMMA"; if (iConfig.exists("prodProcess")) prodProcess_ = iConfig.getUntrackedParameter("prodProcess"); - allowNoPhoton_ = iConfig.getParameter("allowNoPhoton"); - photonPtMin_ = iConfig.getParameter("photonPtMin"); - photonJetDPhiMin_ = iConfig.getParameter("photonJetDPhiMin"); - jetEtMin_ = iConfig.getParameter("jetEtMin"); - jet2EtMax_ = iConfig.getParameter("jet2EtMax"); - jet3EtMax_ = iConfig.getParameter("jet3EtMax"); - photonTrigNamesV_ = iConfig.getParameter>("photonTriggers"); - jetTrigNamesV_ = iConfig.getParameter>("jetTriggers"); - writeTriggerPrescale_= iConfig.getParameter("writeTriggerPrescale"); - doPFJets_ = iConfig.getParameter("doPFJets"); - doGenJets_ = iConfig.getParameter("doGenJets"); - workOnAOD_ = iConfig.getParameter("workOnAOD"); - ignoreHLT_ = iConfig.getUntrackedParameter("ignoreHLT",false); + allowNoPhoton_ = iConfig.getParameter("allowNoPhoton"); + photonPtMin_ = iConfig.getParameter("photonPtMin"); + photonJetDPhiMin_ = iConfig.getParameter("photonJetDPhiMin"); + jetEtMin_ = iConfig.getParameter("jetEtMin"); + jet2EtMax_ = iConfig.getParameter("jet2EtMax"); + jet3EtMax_ = iConfig.getParameter("jet3EtMax"); + photonTrigNamesV_ = iConfig.getParameter>("photonTriggers"); + jetTrigNamesV_ = iConfig.getParameter>("jetTriggers"); + writeTriggerPrescale_ = iConfig.getParameter("writeTriggerPrescale"); + doPFJets_ = iConfig.getParameter("doPFJets"); + doGenJets_ = iConfig.getParameter("doGenJets"); + workOnAOD_ = iConfig.getParameter("workOnAOD"); + ignoreHLT_ = iConfig.getUntrackedParameter("ignoreHLT", false); eventWeight_ = 1.0; eventPtHat_ = 0.; @@ -112,74 +178,77 @@ GammaJetAnalysis::GammaJetAnalysis(const edm::ParameterSet& iConfig) : //Get the tokens // FAST FIX - if (workOnAOD_ < 2) { // origin data file - tok_Photon_ = consumes(photonCollName_); - tok_PFJet_ = consumes(pfJetCollName_); - tok_GenJet_ = consumes >(genJetCollName_); - tok_GenPart_ = consumes >(genParticleCollName_); - tok_GenEvInfo_ = consumes(genEventInfoName_); - tok_HBHE_ = consumes > >(hbheRecHitName_); - tok_HF_ = consumes > >(hfRecHitName_); - tok_HO_ = consumes > >(hoRecHitName_); - tok_loosePhoton_ = consumes >(edm::InputTag("PhotonIDProdGED","PhotonCutBasedIDLoose")); - tok_tightPhoton_ = consumes >(edm::InputTag("PhotonIDProdGED:PhotonCutBasedIDTight")); - tok_PFCand_ = consumes(edm::InputTag("particleFlow")); - tok_Vertex_ = consumes(edm::InputTag("offlinePrimaryVertices")); - tok_GsfElec_ = consumes(edm::InputTag("gsfElectrons")); - tok_Rho_ = consumes(rhoCollection_); - tok_Conv_ = consumes(edm::InputTag("allConversions")); - tok_BS_ = consumes(edm::InputTag("offlineBeamSpot")); - tok_PV_ = consumes >(pvCollName_); - tok_PFMET_ = consumes(pfMETColl); - tok_PFType1MET_ = consumes(pfType1METColl); - tok_TrigRes_ = consumes(edm::InputTag("TriggerResults::HLT")); + if (workOnAOD_ < 2) { // origin data file + tok_Photon_ = consumes(photonCollName_); + tok_PFJet_ = consumes(pfJetCollName_); + tok_GenJet_ = consumes>(genJetCollName_); + tok_GenPart_ = consumes>(genParticleCollName_); + tok_GenEvInfo_ = consumes(genEventInfoName_); + tok_HBHE_ = consumes>>(hbheRecHitName_); + tok_HF_ = consumes>>(hfRecHitName_); + tok_HO_ = consumes>>(hoRecHitName_); + tok_loosePhoton_ = consumes>(edm::InputTag("PhotonIDProdGED", "PhotonCutBasedIDLoose")); + tok_tightPhoton_ = consumes>(edm::InputTag("PhotonIDProdGED:PhotonCutBasedIDTight")); + tok_PFCand_ = consumes(edm::InputTag("particleFlow")); + tok_Vertex_ = consumes(edm::InputTag("offlinePrimaryVertices")); + tok_GsfElec_ = consumes(edm::InputTag("gsfElectrons")); + tok_Rho_ = consumes(rhoCollection_); + tok_Conv_ = consumes(edm::InputTag("allConversions")); + tok_BS_ = consumes(edm::InputTag("offlineBeamSpot")); + tok_PV_ = consumes>(pvCollName_); + tok_PFMET_ = consumes(pfMETColl); + tok_PFType1MET_ = consumes(pfType1METColl); + tok_TrigRes_ = consumes(edm::InputTag("TriggerResults::HLT")); } else { // FAST FIX - const char* prod= "GammaJetProd"; - if (prodProcess_.size()==0) { + const char* prod = "GammaJetProd"; + if (prodProcess_.size() == 0) { edm::LogError("GammaJetAnalysis") << "prodProcess needs to be defined"; throw edm::Exception(edm::errors::ProductNotFound); } - const char* an= prodProcess_.c_str(); - edm::LogWarning("GammaJetAnalysis") << "FAST FIX: changing " << photonCollName_ - << " to" << edm::InputTag(prod,photonCollName_,an); - tok_Photon_ = consumes(edm::InputTag(prod,photonCollName_,an)); - tok_PFJet_ = consumes(edm::InputTag(prod,pfJetCollName_,an)); - tok_GenJet_ = consumes >(edm::InputTag(prod,genJetCollName_,an)); - tok_GenPart_ = consumes >(edm::InputTag(prod,genParticleCollName_,an)); - tok_GenEvInfo_ = consumes(edm::InputTag(prod,genEventInfoName_,an)); - tok_HBHE_ = consumes > >(edm::InputTag(prod,hbheRecHitName_,an)); - tok_HF_ = consumes > >(edm::InputTag(prod,hfRecHitName_,an)); - tok_HO_ = consumes > >(edm::InputTag(prod,hoRecHitName_,an)); + const char* an = prodProcess_.c_str(); + edm::LogWarning("GammaJetAnalysis") << "FAST FIX: changing " << photonCollName_ << " to" + << edm::InputTag(prod, photonCollName_, an); + tok_Photon_ = consumes(edm::InputTag(prod, photonCollName_, an)); + tok_PFJet_ = consumes(edm::InputTag(prod, pfJetCollName_, an)); + tok_GenJet_ = consumes>(edm::InputTag(prod, genJetCollName_, an)); + tok_GenPart_ = consumes>(edm::InputTag(prod, genParticleCollName_, an)); + tok_GenEvInfo_ = consumes(edm::InputTag(prod, genEventInfoName_, an)); + tok_HBHE_ = consumes>>( + edm::InputTag(prod, hbheRecHitName_, an)); + tok_HF_ = consumes>>( + edm::InputTag(prod, hfRecHitName_, an)); + tok_HO_ = consumes>>( + edm::InputTag(prod, hoRecHitName_, an)); //tok_loosePhoton_ = consumes >(edm::InputTag("PhotonIDProdGED","PhotonCutBasedIDLoose")); //tok_tightPhoton_ = consumes >(edm::InputTag("PhotonIDProdGED:PhotonCutBasedIDTight")); - tok_loosePhotonV_ = consumes >(edm::InputTag(prod,"PhotonIDProdGED:PhotonCutBasedIDLoose",an)); - tok_tightPhotonV_ = consumes >(edm::InputTag(prod,"PhotonIDProdGED:PhotonCutBasedIDTight",an)); - tok_PFCand_ = consumes(edm::InputTag(prod,"particleFlow",an)); - tok_Vertex_ = consumes(edm::InputTag(prod,"offlinePrimaryVertices",an)); - tok_GsfElec_ = consumes(edm::InputTag(prod,"gedGsfElectrons",an)); - tok_Rho_ = consumes(edm::InputTag(prod,rhoCollection_.label(),an)); - tok_Conv_ = consumes(edm::InputTag(prod,"allConversions",an)); - tok_BS_ = consumes(edm::InputTag(prod,"offlineBeamSpot",an)); - tok_PV_ = consumes >(edm::InputTag(prod,pvCollName_,an)); - tok_PFMET_ = consumes(edm::InputTag(prod,pfMETColl.label(),an)); - tok_PFType1MET_ = consumes(edm::InputTag(prod,pfType1METColl.label(),an)); + tok_loosePhotonV_ = consumes>(edm::InputTag(prod, "PhotonIDProdGED:PhotonCutBasedIDLoose", an)); + tok_tightPhotonV_ = consumes>(edm::InputTag(prod, "PhotonIDProdGED:PhotonCutBasedIDTight", an)); + tok_PFCand_ = consumes(edm::InputTag(prod, "particleFlow", an)); + tok_Vertex_ = consumes(edm::InputTag(prod, "offlinePrimaryVertices", an)); + tok_GsfElec_ = consumes(edm::InputTag(prod, "gedGsfElectrons", an)); + tok_Rho_ = consumes(edm::InputTag(prod, rhoCollection_.label(), an)); + tok_Conv_ = consumes(edm::InputTag(prod, "allConversions", an)); + tok_BS_ = consumes(edm::InputTag(prod, "offlineBeamSpot", an)); + tok_PV_ = consumes>(edm::InputTag(prod, pvCollName_, an)); + tok_PFMET_ = consumes(edm::InputTag(prod, pfMETColl.label(), an)); + tok_PFType1MET_ = consumes(edm::InputTag(prod, pfType1METColl.label(), an)); TString HLTlabel = "TriggerResults::HLT"; - if (prodProcess_.find("reRECO")!=std::string::npos) - HLTlabel.ReplaceAll("HLT","reHLT"); - tok_TrigRes_ = consumes(edm::InputTag(prod,HLTlabel.Data(),an)); + if (prodProcess_.find("reRECO") != std::string::npos) + HLTlabel.ReplaceAll("HLT", "reHLT"); + tok_TrigRes_ = consumes(edm::InputTag(prod, HLTlabel.Data(), an)); } } GammaJetAnalysis::~GammaJetAnalysis() {} - + // // member functions // - + // ------------ method called to for each event ------------ -void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) { +void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) { nProcessed_++; edm::LogInfo("GammaJetAnalysis") << "nProcessed=" << nProcessed_ << "\n"; @@ -187,23 +256,23 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // 1st. Get Photons // edm::Handle photons; iEvent.getByToken(tok_Photon_, photons); - if(!photons.isValid()) { - edm::LogWarning("GammaJetAnalysis") << "Could not find PhotonCollection named " - << photonCollName_; + if (!photons.isValid()) { + edm::LogWarning("GammaJetAnalysis") << "Could not find PhotonCollection named " << photonCollName_; return; } - if ((photons->size()==0) && !allowNoPhoton_) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "No photons in the event"; + if ((photons->size() == 0) && !allowNoPhoton_) { + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "No photons in the event"; return; } - nPhotons_= photons->size(); + nPhotons_ = photons->size(); edm::LogInfo("GammaJetAnalysis") << "nPhotons_=" << nPhotons_; // Get photon quality flags - edm::Handle > loosePhotonQual, tightPhotonQual; - edm::Handle > loosePhotonQual_Vec, tightPhotonQual_Vec; + edm::Handle> loosePhotonQual, tightPhotonQual; + edm::Handle> loosePhotonQual_Vec, tightPhotonQual_Vec; if (workOnAOD_ < 2) { iEvent.getByToken(tok_loosePhoton_, loosePhotonQual); iEvent.getByToken(tok_tightPhoton_, tightPhotonQual); @@ -211,8 +280,7 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& edm::LogWarning("GammaJetAnalysis") << "Failed to get photon quality flags"; return; } - } - else { + } else { iEvent.getByToken(tok_loosePhotonV_, loosePhotonQual_Vec); iEvent.getByToken(tok_tightPhotonV_, tightPhotonQual_Vec); if (!loosePhotonQual_Vec.isValid() || !tightPhotonQual_Vec.isValid()) { @@ -224,20 +292,21 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // sort photons by Et // // counter is needed later to get the reference to the ptr std::set photonpairset; - int counter=0; - for(reco::PhotonCollection::const_iterator it=photons->begin(); it!=photons->end(); ++it) { + int counter = 0; + for (reco::PhotonCollection::const_iterator it = photons->begin(); it != photons->end(); ++it) { //HERE(Form("photon counter=%d",counter)); - const reco::Photon* photon=&(*it); + const reco::Photon* photon = &(*it); //if(loosePhotonQual.isValid()){ - photonpairset.insert( PhotonPair(photon, photon->pt(), counter) ); + photonpairset.insert(PhotonPair(photon, photon->pt(), counter)); counter++; //} } - HERE(Form("photonpairset.size=%d",int(photonpairset.size()))); + HERE(Form("photonpairset.size=%d", int(photonpairset.size()))); - if ((photonpairset.size()==0) && !allowNoPhoton_) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "No good quality photons in the event"; + if ((photonpairset.size() == 0) && !allowNoPhoton_) { + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "No good quality photons in the event"; return; } @@ -246,27 +315,32 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& /////////////////////////////// // find highest Et photon // - PhotonPair photon_tag; - PhotonPair photon_2nd; - counter=0; - for(std::set::const_iterator it=photonpairset.begin(); it!=photonpairset.end(); ++it) { - PhotonPair photon=(*it); + PhotonPair photon_tag; + PhotonPair photon_2nd; + counter = 0; + for (std::set::const_iterator it = photonpairset.begin(); it != photonpairset.end(); + ++it) { + PhotonPair photon = (*it); ++counter; - if(counter==1) photon_tag = photon; - else if (counter==2) photon_2nd = photon; - else break; + if (counter == 1) + photon_tag = photon; + else if (counter == 2) + photon_2nd = photon; + else + break; } - if (counter==0) { + if (counter == 0) { edm::LogWarning("GammaJetAnalysis") << "Code bug"; return; } - HERE(Form("counter=%d",counter)); + HERE(Form("counter=%d", counter)); // cut on photon pt - if (photon_tag.isValid() && ( photon_tag.pt() < photonPtMin_ )) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "largest photonPt=" << photon_tag.pt(); + if (photon_tag.isValid() && (photon_tag.pt() < photonPtMin_)) { + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "largest photonPt=" << photon_tag.pt(); return; } @@ -274,31 +348,32 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // 2nd. Get Jets edm::Handle pfjets; - nPFJets_=0; - nGenJets_=0; + nPFJets_ = 0; + nGenJets_ = 0; - unsigned int anyJetCount=0; + unsigned int anyJetCount = 0; if (doPFJets_) { - iEvent.getByToken(tok_PFJet_,pfjets); - if(!pfjets.isValid()) { + iEvent.getByToken(tok_PFJet_, pfjets); + if (!pfjets.isValid()) { edm::LogWarning("GammaJetAnalysis") << "Could not find PFJetCollection named " << pfJetCollName_; return; } - anyJetCount+= pfjets->size(); + anyJetCount += pfjets->size(); nPFJets_ = pfjets->size(); } - HERE(Form("anyJetCount=%d",anyJetCount)); + HERE(Form("anyJetCount=%d", anyJetCount)); - if (anyJetCount==0) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "Event contains no jets"; + if (anyJetCount == 0) { + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "Event contains no jets"; return; } - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "nPhotons=" << nPhotons_ - << ", nPFJets=" << nPFJets_; + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "nPhotons=" << nPhotons_ << ", nPFJets=" << nPFJets_; - HERE(Form("nPhotons_=%d, nPFJets_=%d",nPhotons_,nPFJets_)); + HERE(Form("nPhotons_=%d, nPFJets_=%d", nPhotons_, nPFJets_)); // 3rd. Check the trigger photonTrigFired_.clear(); @@ -310,72 +385,81 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // HLT Trigger // assign "trig fired" if no triggers are specified - bool photonTrigFlag= (photonTrigNamesV_.size()==0) ? true : false; - bool jetTrigFlag= (jetTrigNamesV_.size()==0) ? true : false; - if ((photonTrigNamesV_.size()==1) && - (photonTrigNamesV_[0].length()==0)) photonTrigFlag=true; - if ((jetTrigNamesV_.size()==1) && - (jetTrigNamesV_[0].length()==0)) jetTrigFlag=true; + bool photonTrigFlag = (photonTrigNamesV_.size() == 0) ? true : false; + bool jetTrigFlag = (jetTrigNamesV_.size() == 0) ? true : false; + if ((photonTrigNamesV_.size() == 1) && (photonTrigNamesV_[0].length() == 0)) + photonTrigFlag = true; + if ((jetTrigNamesV_.size() == 1) && (jetTrigNamesV_[0].length() == 0)) + jetTrigFlag = true; // If needed, process trigger information if (!photonTrigFlag || !jetTrigFlag) { // check the triggers edm::Handle triggerResults; - if( !iEvent.getByToken(tok_TrigRes_,triggerResults) ) { + if (!iEvent.getByToken(tok_TrigRes_, triggerResults)) { edm::LogWarning("GammaJetAnalysis") << "Could not find TriggerResults::HLT"; return; } - const edm::TriggerNames &evTrigNames =iEvent.triggerNames(*triggerResults); - - if (debugHLTTrigNames>0) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "debugHLTTrigNames is on"; - const std::vector *trNames= & evTrigNames.triggerNames(); - for (size_t i=0; isize(); ++i) { - if (trNames->at(i).find("_Photon")!=std::string::npos) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << " - " << trNames->at(i); - } + const edm::TriggerNames& evTrigNames = iEvent.triggerNames(*triggerResults); + + if (debugHLTTrigNames > 0) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "debugHLTTrigNames is on"; + const std::vector* trNames = &evTrigNames.triggerNames(); + for (size_t i = 0; i < trNames->size(); ++i) { + if (trNames->at(i).find("_Photon") != std::string::npos) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << " - " << trNames->at(i); + } } - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << " "; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << " "; debugHLTTrigNames--; } size_t id = 0; - for (size_t i=0; iaccept(id); - if (fired) photonTrigFlag=true; + int fired = triggerResults->accept(id); + if (fired) + photonTrigFlag = true; photonTrigFired_.push_back(fired); - if (!writeTriggerPrescale_) photonTrigPrescale_.push_back(-1); + if (!writeTriggerPrescale_) + photonTrigPrescale_.push_back(-1); else { - // for triggers with two L1 seeds this fails - std::pair prescaleVals= hltPrescaleProvider_.prescaleValues(iEvent,evSetup, evTrigNames.triggerName(id)); - photonTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second); + // for triggers with two L1 seeds this fails + std::pair prescaleVals = + hltPrescaleProvider_.prescaleValues(iEvent, evSetup, evTrigNames.triggerName(id)); + photonTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second); } } - for (size_t i=0; iaccept(id); - if (fired) jetTrigFlag=true; + int fired = triggerResults->accept(id); + if (fired) + jetTrigFlag = true; jetTrigFired_.push_back(fired); - std::pair prescaleVals = hltPrescaleProvider_.prescaleValues(iEvent,evSetup,evTrigNames.triggerName(id)); + std::pair prescaleVals = + hltPrescaleProvider_.prescaleValues(iEvent, evSetup, evTrigNames.triggerName(id)); jetTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second); } } if (!photonTrigFlag && !jetTrigFlag) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "no trigger fired"; + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "no trigger fired"; return; } @@ -384,7 +468,7 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& tagPho_pfiso_mycharged03.clear(); edm::Handle> genjets; - edm::Handle > genparticles; + edm::Handle> genparticles; edm::Handle pfHandle; iEvent.getByToken(tok_PFCand_, pfHandle); @@ -405,19 +489,18 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& HERE("doGenJets"); - if(doGenJets_){ + if (doGenJets_) { // Get GenJets - iEvent.getByToken(tok_GenJet_,genjets); - if(!genjets.isValid()) { - edm::LogWarning("GammaJetAnalysis") << "Could not find GenJet vector named " - << genJetCollName_; + iEvent.getByToken(tok_GenJet_, genjets); + if (!genjets.isValid()) { + edm::LogWarning("GammaJetAnalysis") << "Could not find GenJet vector named " << genJetCollName_; return; } - nGenJets_= genjets->size(); + nGenJets_ = genjets->size(); // Get GenParticles - iEvent.getByToken(tok_GenPart_,genparticles); - if(!genparticles.isValid()) { + iEvent.getByToken(tok_GenPart_, genparticles); + if (!genparticles.isValid()) { edm::LogWarning("GammaJetAnalysis") << "Could not find GenParticle vector named " << genParticleCollName_; return; } @@ -425,7 +508,7 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // Get weights edm::Handle genEventInfoProduct; iEvent.getByToken(tok_GenEvInfo_, genEventInfoProduct); - if(!genEventInfoProduct.isValid()){ + if (!genEventInfoProduct.isValid()) { edm::LogWarning("GammaJetAnalysis") << "Could not find GenEventInfoProduct named " << genEventInfoName_; return; } @@ -440,58 +523,61 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& lumiBlock_ = iEvent.id().luminosityBlock(); eventNumber_ = iEvent.id().event(); - HERE(Form("runNumber=%d, eventNumber=%d",runNumber_,eventNumber_)); + HERE(Form("runNumber=%d, eventNumber=%d", runNumber_, eventNumber_)); // fill tag photon variables if (!photon_tag.isValid()) { - tagPho_pt_=-1; - pho_2nd_pt_=-1; - tagPho_energy_=-1; - tagPho_eta_=0; - tagPho_phi_=0; - tagPho_sieie_=0; - tagPho_HoE_=0; - tagPho_r9_=0; - tagPho_EcalIsoDR04_=0; - tagPho_HcalIsoDR04_=0; - tagPho_HcalIsoDR0412_=0; - tagPho_TrkIsoHollowDR04_=0; - tagPho_pfiso_myphoton03_=0; - tagPho_pfiso_myneutral03_=0; + tagPho_pt_ = -1; + pho_2nd_pt_ = -1; + tagPho_energy_ = -1; + tagPho_eta_ = 0; + tagPho_phi_ = 0; + tagPho_sieie_ = 0; + tagPho_HoE_ = 0; + tagPho_r9_ = 0; + tagPho_EcalIsoDR04_ = 0; + tagPho_HcalIsoDR04_ = 0; + tagPho_HcalIsoDR0412_ = 0; + tagPho_TrkIsoHollowDR04_ = 0; + tagPho_pfiso_myphoton03_ = 0; + tagPho_pfiso_myneutral03_ = 0; tagPho_pfiso_mycharged03.clear(); - tagPho_pixelSeed_=0; - tagPho_ConvSafeEleVeto_=0; - tagPho_idTight_=0; - tagPho_idLoose_=0; - tagPho_genPt_=0; - tagPho_genEnergy_=0; - tagPho_genEta_=0; - tagPho_genPhi_=0; - tagPho_genDeltaR_=0; - } - else { + tagPho_pixelSeed_ = 0; + tagPho_ConvSafeEleVeto_ = 0; + tagPho_idTight_ = 0; + tagPho_idLoose_ = 0; + tagPho_genPt_ = 0; + tagPho_genEnergy_ = 0; + tagPho_genEta_ = 0; + tagPho_genPhi_ = 0; + tagPho_genDeltaR_ = 0; + } else { HERE("bb"); - tagPho_pt_ = photon_tag.photon()->pt(); - pho_2nd_pt_ = (photon_2nd.photon()) ? photon_2nd.photon()->pt() : -1.; - tagPho_energy_ = photon_tag.photon()->energy(); - tagPho_eta_ = photon_tag.photon()->eta(); - tagPho_phi_ = photon_tag.photon()->phi(); + tagPho_pt_ = photon_tag.photon()->pt(); + pho_2nd_pt_ = (photon_2nd.photon()) ? photon_2nd.photon()->pt() : -1.; + tagPho_energy_ = photon_tag.photon()->energy(); + tagPho_eta_ = photon_tag.photon()->eta(); + tagPho_phi_ = photon_tag.photon()->phi(); tagPho_sieie_ = photon_tag.photon()->sigmaIetaIeta(); - tagPho_HoE_ = photon_tag.photon()->hadTowOverEm(); - tagPho_r9_ = photon_tag.photon()->r9(); + tagPho_HoE_ = photon_tag.photon()->hadTowOverEm(); + tagPho_r9_ = photon_tag.photon()->r9(); tagPho_pixelSeed_ = photon_tag.photon()->hasPixelSeed(); - tagPho_TrkIsoHollowDR04_ = photon_tag.photon()->trkSumPtHollowConeDR04(); + tagPho_TrkIsoHollowDR04_ = photon_tag.photon()->trkSumPtHollowConeDR04(); tagPho_EcalIsoDR04_ = photon_tag.photon()->ecalRecHitSumEtConeDR04(); tagPho_HcalIsoDR04_ = photon_tag.photon()->hcalTowerSumEtConeDR04(); - tagPho_HcalIsoDR0412_ = photon_tag.photon()->hcalTowerSumEtConeDR04() + (photon_tag.photon()->hadronicOverEm() - photon_tag.photon()->hadTowOverEm())*(photon_tag.photon()->energy()/cosh((photon_tag.photon()->eta()))); + tagPho_HcalIsoDR0412_ = photon_tag.photon()->hcalTowerSumEtConeDR04() + + (photon_tag.photon()->hadronicOverEm() - photon_tag.photon()->hadTowOverEm()) * + (photon_tag.photon()->energy() / cosh((photon_tag.photon()->eta()))); HERE("tt"); - - tagPho_pfiso_myphoton03_ = pfEcalIso(photon_tag.photon(), pfHandle, 0.3, 0.0, 0.070, 0.015, 0.0, 0.0, 0.0, reco::PFCandidate::gamma); + + tagPho_pfiso_myphoton03_ = + pfEcalIso(photon_tag.photon(), pfHandle, 0.3, 0.0, 0.070, 0.015, 0.0, 0.0, 0.0, reco::PFCandidate::gamma); tagPho_pfiso_myneutral03_ = pfHcalIso(photon_tag.photon(), pfHandle, 0.3, 0.0, reco::PFCandidate::h0); HERE("calc charged pfiso"); - tagPho_pfiso_mycharged03.push_back(pfTkIsoWithVertex(photon_tag.photon(), pfHandle, vtxHandle, 0.3, 0.02, 0.02, 0.0, 0.2, 0.1, reco::PFCandidate::h)); + tagPho_pfiso_mycharged03.push_back(pfTkIsoWithVertex( + photon_tag.photon(), pfHandle, vtxHandle, 0.3, 0.02, 0.02, 0.0, 0.2, 0.1, reco::PFCandidate::h)); HERE("got isolation"); @@ -500,83 +586,76 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& HERE("get id"); if (workOnAOD_ < 2) { - HERE(Form("workOnAOD_<2. loose photon qual size=%d",int(loosePhotonQual->size()))); + HERE(Form("workOnAOD_<2. loose photon qual size=%d", int(loosePhotonQual->size()))); edm::Ref photonRef(photons, photon_tag.idx()); - HERE(Form("got photon ref, photon_tag.idx()=%d",photon_tag.idx())); + HERE(Form("got photon ref, photon_tag.idx()=%d", photon_tag.idx())); //std::cout << "loosePhotonQual->at(photon_tag.idx())=" << loosePhotonQual->at(photon_tag.idx()) << std::endl; tagPho_idLoose_ = (loosePhotonQual.isValid()) ? (*loosePhotonQual)[photonRef] : -1; tagPho_idTight_ = (tightPhotonQual.isValid()) ? (*tightPhotonQual)[photonRef] : -1; - } - else { + } else { tagPho_idLoose_ = (loosePhotonQual_Vec.isValid()) ? loosePhotonQual_Vec->at(photon_tag.idx()) : -1; - tagPho_idTight_ = (tightPhotonQual_Vec.isValid()) ? tightPhotonQual_Vec->at(photon_tag.idx()) : -1; + tagPho_idTight_ = (tightPhotonQual_Vec.isValid()) ? tightPhotonQual_Vec->at(photon_tag.idx()) : -1; } - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "photon tag ID = " - << tagPho_idLoose_ << " and " - << tagPho_idTight_; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "photon tag ID = " << tagPho_idLoose_ << " and " << tagPho_idTight_; - HERE(Form("tagPhoID= %d and %d",tagPho_idLoose_,tagPho_idTight_)); + HERE(Form("tagPhoID= %d and %d", tagPho_idLoose_, tagPho_idTight_)); HERE("reset pho gen"); - - tagPho_genPt_=0; - tagPho_genEnergy_=0; - tagPho_genEta_=0; - tagPho_genPhi_=0; - tagPho_genDeltaR_=0; + + tagPho_genPt_ = 0; + tagPho_genEnergy_ = 0; + tagPho_genEta_ = 0; + tagPho_genPhi_ = 0; + tagPho_genDeltaR_ = 0; if (doGenJets_) { - tagPho_genDeltaR_=9999.; - for (std::vector::const_iterator itmc=genparticles->begin(); - itmc!=genparticles->end(); itmc++) { - if (itmc->status() == 1 && itmc->pdgId()==22) { - float dR= deltaR(tagPho_eta_,tagPho_phi_, - itmc->eta(),itmc->phi()); - if (dR < tagPho_genDeltaR_) { - tagPho_genPt_ = itmc->pt(); - tagPho_genEnergy_ = itmc->energy(); - tagPho_genEta_ = itmc->eta(); - tagPho_genPhi_ = itmc->phi(); - tagPho_genDeltaR_ = dR; - } - } + tagPho_genDeltaR_ = 9999.; + for (std::vector::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); + itmc++) { + if (itmc->status() == 1 && itmc->pdgId() == 22) { + float dR = deltaR(tagPho_eta_, tagPho_phi_, itmc->eta(), itmc->phi()); + if (dR < tagPho_genDeltaR_) { + tagPho_genPt_ = itmc->pt(); + tagPho_genEnergy_ = itmc->energy(); + tagPho_genEta_ = itmc->eta(); + tagPho_genPhi_ = itmc->phi(); + tagPho_genDeltaR_ = dR; + } + } } } } - + HERE("run over PFJets"); // Run over PFJets // - - if(doPFJets_ && (nPFJets_>0)){ - + + if (doPFJets_ && (nPFJets_ > 0)) { // Get RecHits in HB and HE - edm::Handle>> hbhereco; - iEvent.getByToken(tok_HBHE_,hbhereco); - if(!hbhereco.isValid() && !workOnAOD_) { - edm::LogWarning("GammaJetAnalysis") << "Could not find HBHERecHit named " - << hbheRecHitName_; + edm::Handle>> hbhereco; + iEvent.getByToken(tok_HBHE_, hbhereco); + if (!hbhereco.isValid() && !workOnAOD_) { + edm::LogWarning("GammaJetAnalysis") << "Could not find HBHERecHit named " << hbheRecHitName_; return; } - + // Get RecHits in HF - edm::Handle>> hfreco; - iEvent.getByToken(tok_HF_,hfreco); - if(!hfreco.isValid() && !workOnAOD_) { - edm::LogWarning("GammaJetAnalysis") << "Could not find HFRecHit named " - << hfRecHitName_; + edm::Handle>> hfreco; + iEvent.getByToken(tok_HF_, hfreco); + if (!hfreco.isValid() && !workOnAOD_) { + edm::LogWarning("GammaJetAnalysis") << "Could not find HFRecHit named " << hfRecHitName_; return; } // Get RecHits in HO - edm::Handle>> horeco; - iEvent.getByToken(tok_HO_,horeco); - if(!horeco.isValid() && !workOnAOD_) { - edm::LogWarning("GammaJetAnalysis") << "Could not find HORecHit named " - << hoRecHitName_; + edm::Handle>> horeco; + iEvent.getByToken(tok_HO_, horeco); + if (!horeco.isValid() && !workOnAOD_) { + edm::LogWarning("GammaJetAnalysis") << "Could not find HORecHit named " << hoRecHitName_; return; } @@ -585,38 +664,44 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // Get geometry edm::ESHandle geoHandle; evSetup.get().get(geoHandle); - const HcalGeometry *HBGeom = dynamic_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 1)); - const HcalGeometry *HEGeom = dynamic_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 2)); - const CaloSubdetectorGeometry *HOGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 3); - const CaloSubdetectorGeometry *HFGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 4); + const HcalGeometry* HBGeom = dynamic_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 1)); + const HcalGeometry* HEGeom = dynamic_cast(geoHandle->getSubdetectorGeometry(DetId::Hcal, 2)); + const CaloSubdetectorGeometry* HOGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 3); + const CaloSubdetectorGeometry* HFGeom = geoHandle->getSubdetectorGeometry(DetId::Hcal, 4); HERE("work"); int HBHE_n = 0; if (hbhereco.isValid()) { - for(edm::SortedCollection>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){ - HBHE_n++; - if(iEvent.id().event() == debugEvent){ - if (debug_>1) - edm::LogInfo("GammaJetAnalysis") << (*ith).id().ieta() << " " - << (*ith).id().iphi(); - } + for (edm::SortedCollection>::const_iterator ith = + hbhereco->begin(); + ith != hbhereco->end(); + ++ith) { + HBHE_n++; + if (iEvent.id().event() == debugEvent) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << (*ith).id().ieta() << " " << (*ith).id().iphi(); + } } } int HF_n = 0; if (hfreco.isValid()) { - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - HF_n++; - if(iEvent.id().event() == debugEvent){ - } + for (edm::SortedCollection>::const_iterator ith = hfreco->begin(); + ith != hfreco->end(); + ++ith) { + HF_n++; + if (iEvent.id().event() == debugEvent) { + } } } int HO_n = 0; if (horeco.isValid()) { - for(edm::SortedCollection>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){ - HO_n++; - if(iEvent.id().event() == debugEvent){ - } + for (edm::SortedCollection>::const_iterator ith = horeco->begin(); + ith != horeco->end(); + ++ith) { + HO_n++; + if (iEvent.id().event() == debugEvent) { + } } } @@ -624,42 +709,48 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // Get primary vertices edm::Handle> pv; - iEvent.getByToken(tok_PV_,pv); - if(!pv.isValid()) { - edm::LogWarning("GammaJetAnalysis") << "Could not find Vertex named " - << pvCollName_; + iEvent.getByToken(tok_PV_, pv); + if (!pv.isValid()) { + edm::LogWarning("GammaJetAnalysis") << "Could not find Vertex named " << pvCollName_; return; } pf_NPV_ = 0; - for(std::vector::const_iterator it=pv->begin(); it!=pv->end(); ++it){ - if(!it->isFake() && it->ndof() > 4) ++pf_NPV_; + for (std::vector::const_iterator it = pv->begin(); it != pv->end(); ++it) { + if (!it->isFake() && it->ndof() > 4) + ++pf_NPV_; } HERE("get corrector"); // Get jet corrections - const JetCorrector* correctorPF = JetCorrector::getJetCorrector(pfJetCorrName_,evSetup); - + const JetCorrector* correctorPF = JetCorrector::getJetCorrector(pfJetCorrName_, evSetup); + // sort jets by corrected et std::set pfjetcorretpairset; - for(reco::PFJetCollection::const_iterator it=pfjets->begin(); it!=pfjets->end(); ++it) { - const reco::PFJet* jet=&(*it); + for (reco::PFJetCollection::const_iterator it = pfjets->begin(); it != pfjets->end(); ++it) { + const reco::PFJet* jet = &(*it); // do not let the jet to be close to the tag photon - if (deltaR(photon_tag,jet)<0.5) continue; + if (deltaR(photon_tag, jet) < 0.5) + continue; double jec = correctorPF->correction(*it, iEvent, evSetup); - pfjetcorretpairset.insert( PFJetCorretPair(jet, jec)); + pfjetcorretpairset.insert(PFJetCorretPair(jet, jec)); } PFJetCorretPair pfjet_probe; PFJetCorretPair pf_2ndjet; PFJetCorretPair pf_3rdjet; - int jet_cntr=0; - for(std::set::const_iterator it=pfjetcorretpairset.begin(); it!=pfjetcorretpairset.end(); ++it) { - PFJetCorretPair jet=(*it); + int jet_cntr = 0; + for (std::set::const_iterator it = pfjetcorretpairset.begin(); + it != pfjetcorretpairset.end(); + ++it) { + PFJetCorretPair jet = (*it); ++jet_cntr; - if(jet_cntr==1) pfjet_probe = jet; - else if(jet_cntr==2) pf_2ndjet = jet; - else if(jet_cntr==3) pf_3rdjet = jet; + if (jet_cntr == 1) + pfjet_probe = jet; + else if (jet_cntr == 2) + pf_2ndjet = jet; + else if (jet_cntr == 3) + pf_3rdjet = jet; //else break; // don't break for the statistics } @@ -668,623 +759,668 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& // Check selection int failSelPF = 0; - if (!pfjet_probe.isValid()) failSelPF |= 1; + if (!pfjet_probe.isValid()) + failSelPF |= 1; else { - if (pfjet_probe.scaledEt() < jetEtMin_) failSelPF |= 2; - if (calc_dPhi(photon_tag,pfjet_probe) < photonJetDPhiMin_) failSelPF |= 3; - if (deltaR(photon_tag,pfjet_probe.jet())<0.5) failSelPF |= 4; + if (pfjet_probe.scaledEt() < jetEtMin_) + failSelPF |= 2; + if (calc_dPhi(photon_tag, pfjet_probe) < photonJetDPhiMin_) + failSelPF |= 3; + if (deltaR(photon_tag, pfjet_probe.jet()) < 0.5) + failSelPF |= 4; if (pf_2ndjet.isValid() && (pf_2ndjet.scaledEt() > jet2EtMax_)) - failSelPF |= 5; + failSelPF |= 5; if (pf_3rdjet.isValid() && (pf_3rdjet.scaledEt() > jet3EtMax_)) - failSelPF |= 6; + failSelPF |= 6; } if (!failSelPF) { // put values into 3rd jet quantities if (pf_3rdjet.isValid()) { - pf_thirdjet_et_ = pf_3rdjet.jet()->et(); - pf_thirdjet_pt_ = pf_3rdjet.jet()->pt(); - pf_thirdjet_p_ = pf_3rdjet.jet()->p(); - pf_thirdjet_px_ = pf_3rdjet.jet()->px(); - pf_thirdjet_py_ = pf_3rdjet.jet()->py(); - pf_thirdjet_E_ = pf_3rdjet.jet()->energy(); - pf_thirdjet_eta_= pf_3rdjet.jet()->eta(); - pf_thirdjet_phi_= pf_3rdjet.jet()->phi(); - pf_thirdjet_scale_= pf_3rdjet.scale(); - } - else { - pf_thirdjet_et_ = 0; - pf_thirdjet_pt_ = pf_thirdjet_p_ = 0; - pf_thirdjet_px_ = pf_thirdjet_py_ = 0; - pf_thirdjet_E_ = pf_thirdjet_eta_ = pf_thirdjet_phi_ = 0; - pf_thirdjet_scale_=0; + pf_thirdjet_et_ = pf_3rdjet.jet()->et(); + pf_thirdjet_pt_ = pf_3rdjet.jet()->pt(); + pf_thirdjet_p_ = pf_3rdjet.jet()->p(); + pf_thirdjet_px_ = pf_3rdjet.jet()->px(); + pf_thirdjet_py_ = pf_3rdjet.jet()->py(); + pf_thirdjet_E_ = pf_3rdjet.jet()->energy(); + pf_thirdjet_eta_ = pf_3rdjet.jet()->eta(); + pf_thirdjet_phi_ = pf_3rdjet.jet()->phi(); + pf_thirdjet_scale_ = pf_3rdjet.scale(); + } else { + pf_thirdjet_et_ = 0; + pf_thirdjet_pt_ = pf_thirdjet_p_ = 0; + pf_thirdjet_px_ = pf_thirdjet_py_ = 0; + pf_thirdjet_E_ = pf_thirdjet_eta_ = pf_thirdjet_phi_ = 0; + pf_thirdjet_scale_ = 0; } HERE("fill PF jet"); - int types = 0; - int ntypes = 0; - - ///////////////////////////////////////////// - // Get PF constituents and fill HCAL towers - ///////////////////////////////////////////// - - // fill jet variables - // First start from a second jet, then fill the first jet - PFJetCorretPair pfjet_probe_store = pfjet_probe; - for (int iJet=2; iJet>0; iJet--) { - // prepare the container - clear_leadingPfJetVars(); - - if (iJet==2) pfjet_probe= pf_2ndjet; - else pfjet_probe = pfjet_probe_store; - - if(!pfjet_probe.jet()) { - if (iJet==2) { - // put zeros into 2nd jet quantities - copy_leadingPfJetVars_to_pfJet2(); - } else { - edm::LogWarning("GammaJetAnalysis") << "error in the code: leading pf jet is null"; - } - continue; - } + int types = 0; + int ntypes = 0; - HERE("work further"); - - // temporary variables - std::map>> ppfjet_rechits; - std::map ppfjet_clusters; - - // fill the values - ppfjet_pt_ = pfjet_probe.jet()->pt(); - ppfjet_p_ = pfjet_probe.jet()->p(); - ppfjet_eta_ = pfjet_probe.jet()->eta(); - ppfjet_area_ = pfjet_probe.jet()->jetArea(); - ppfjet_E_ = pfjet_probe.jet()->energy(); - ppfjet_E_NPVcorr_ = pfjet_probe.jet()->energy() - getNeutralPVCorr(ppfjet_eta_,pf_NPV_,ppfjet_area_,doGenJets_); - ppfjet_phi_ = pfjet_probe.jet()->phi(); - ppfjet_NeutralHadronFrac_ = pfjet_probe.jet()->neutralHadronEnergyFraction(); - ppfjet_NeutralEMFrac_ = pfjet_probe.jet()->neutralEmEnergyFraction(); - ppfjet_nConstituents_ = pfjet_probe.jet()->nConstituents(); - ppfjet_ChargedHadronFrac_ = pfjet_probe.jet()->chargedHadronEnergyFraction(); - ppfjet_ChargedMultiplicity_= pfjet_probe.jet()->chargedMultiplicity(); - ppfjet_ChargedEMFrac_ = pfjet_probe.jet()->chargedEmEnergyFraction(); - ppfjet_scale_ = pfjet_probe.scale(); - ppfjet_ntwrs_=0; - ppfjet_cluster_n_=0; - ppfjet_ncandtracks_=0; - - HERE("Get PF constituents"); - + ///////////////////////////////////////////// // Get PF constituents and fill HCAL towers - std::vector probeconst=pfjet_probe.jet()->getPFConstituents(); - HERE(Form("probeconst.size=%d",int(probeconst.size()))); - int iPF=0; - for(std::vector::const_iterator it=probeconst.begin(); it!=probeconst.end(); ++it){ - bool hasTrack = false; - if (!(*it)) HERE("\tnull probeconst iterator value\n"); - reco::PFCandidate::ParticleType candidateType = (*it)->particleId(); - iPF++; - HERE(Form("iPF=%d",iPF)); - - // store information - switch(candidateType){ - case reco::PFCandidate::X: - ppfjet_unkown_E_ += (*it)->energy(); - ppfjet_unkown_px_ += (*it)->px(); - ppfjet_unkown_py_ += (*it)->py(); - ppfjet_unkown_pz_ += (*it)->pz(); - ppfjet_unkown_EcalE_ += (*it)->ecalEnergy(); - ppfjet_unkown_n_++; - continue; - case reco::PFCandidate::h: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(0); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - - if(doGenJets_){ - float gendr = 99999; - float genE = 0; - int genpdgId = 0; - for(std::vector::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){ - if(itmc->status() == 1 && itmc->pdgId() > 100){ - double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi()); - if(dr < gendr){ - gendr = dr; - genE = itmc->energy(); - genpdgId = itmc->pdgId(); - } - } - } - ppfjet_had_E_mctruth_.push_back(genE); - ppfjet_had_mcpdgId_.push_back(genpdgId); - } - - reco::TrackRef trackRef = (*it)->trackRef(); - if(trackRef.isNonnull()){ - reco::Track track = *trackRef; - ppfjet_candtrack_px_.push_back(track.px()); - ppfjet_candtrack_py_.push_back(track.py()); - ppfjet_candtrack_pz_.push_back(track.pz()); - ppfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_candtrackind_.push_back(ppfjet_ncandtracks_); - hasTrack = true; - ppfjet_ncandtracks_++; - } - else{ - ppfjet_had_candtrackind_.push_back(-2); - } - } - break; - case reco::PFCandidate::e: - ppfjet_electron_E_ += (*it)->energy(); - ppfjet_electron_px_ += (*it)->px(); - ppfjet_electron_py_ += (*it)->py(); - ppfjet_electron_pz_ += (*it)->pz(); - ppfjet_electron_EcalE_ += (*it)->ecalEnergy(); - ppfjet_electron_n_++; - continue; - case reco::PFCandidate::mu: - ppfjet_muon_E_ += (*it)->energy(); - ppfjet_muon_px_ += (*it)->px(); - ppfjet_muon_py_ += (*it)->py(); - ppfjet_muon_pz_ += (*it)->pz(); - ppfjet_muon_EcalE_ += (*it)->ecalEnergy(); - ppfjet_muon_n_++; - continue; - case reco::PFCandidate::gamma: - ppfjet_photon_E_ += (*it)->energy(); - ppfjet_photon_px_ += (*it)->px(); - ppfjet_photon_py_ += (*it)->py(); - ppfjet_photon_pz_ += (*it)->pz(); - ppfjet_photon_EcalE_ += (*it)->ecalEnergy(); - ppfjet_photon_n_++; - continue; - case reco::PFCandidate::h0: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(1); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - - if(doGenJets_){ - float gendr = 99999; - float genE = 0; - int genpdgId = 0; - for(std::vector::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){ - if(itmc->status() == 1 && itmc->pdgId() > 100){ - double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi()); - if(dr < gendr){ - gendr = dr; - genE = itmc->energy(); - genpdgId = itmc->pdgId(); - } - } - } - ppfjet_had_E_mctruth_.push_back(genE); - ppfjet_had_mcpdgId_.push_back(genpdgId); - } - - break; - } - case reco::PFCandidate::h_HF: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(2); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - - if(doGenJets_){ - float gendr = 99999; - float genE = 0; - int genpdgId = 0; - for(std::vector::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){ - if(itmc->status() == 1 && itmc->pdgId() > 100){ - double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi()); - if(dr < gendr){ - gendr = dr; - genE = itmc->energy(); - genpdgId = itmc->pdgId(); - } - } - } - ppfjet_had_E_mctruth_.push_back(genE); - ppfjet_had_mcpdgId_.push_back(genpdgId); - } - - break; - } - case reco::PFCandidate::egamma_HF: - { - ppfjet_had_E_.push_back((*it)->energy()); - ppfjet_had_px_.push_back((*it)->px()); - ppfjet_had_py_.push_back((*it)->py()); - ppfjet_had_pz_.push_back((*it)->pz()); - ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); - ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); - ppfjet_had_id_.push_back(3); - ppfjet_had_candtrackind_.push_back(-1); - ppfjet_had_ntwrs_.push_back(0); - ppfjet_had_n_++; - - if(doGenJets_){ - float gendr = 99999; - float genE = 0; - int genpdgId = 0; - for(std::vector::const_iterator itmc = genparticles->begin(); itmc != genparticles->end(); itmc++){ - if(itmc->status() == 1 && itmc->pdgId() > 100){ - double dr = deltaR((*it)->eta(),(*it)->phi(),itmc->eta(),itmc->phi()); - if(dr < gendr){ - gendr = dr; - genE = itmc->energy(); - genpdgId = itmc->pdgId(); - } - } - } - ppfjet_had_E_mctruth_.push_back(genE); - ppfjet_had_mcpdgId_.push_back(genpdgId); - } - - break; - } - } - - float HFHAD_E = 0; - float HFEM_E = 0; - int HFHAD_n_ = 0; - int HFEM_n_ = 0; - int HF_type_ = 0; - int maxElement=(*it)->elementsInBlocks().size(); - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "maxElement=" << maxElement; - if (workOnAOD_==1) { - maxElement=0; - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "forced 0"; - } - HERE(Form("maxElement=%d",maxElement)); - for(int e=0; eelementsInBlocks()[e].first; - const edm::OwnVector& elements = blockRef->elements(); - for(unsigned iEle=0; iEleelementsInBlocks()[e].second){ - if(elements[iEle].type() == reco::PFBlockElement::HCAL){ // Element is HB or HE - HF_type_ |= 0x1; - // Get cluster and hits - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi()); - if(ppfjet_clusters.count(cluster_dR) == 0){ - ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; - ppfjet_cluster_eta_.push_back(cluster.eta()); - ppfjet_cluster_phi_.push_back(cluster.phi()); - ppfjet_cluster_dR_.push_back(cluster_dR); - ppfjet_cluster_n_++; - } - int cluster_ind = ppfjet_clusters[cluster_dR]; - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - - // Run over hits and match - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=hbhereco->begin(); ith!=hbhereco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - if(ppfjet_rechits.count((*ith).id()) == 0){ - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(0); - ppfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); - } - else{ - ppfjet_twr_candtrackind_.push_back(-1); - } - switch((*ith).id().subdet()){ - case HcalSubdetector::HcalBarrel: - { - CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHB" << cv[0].phi() << " " << cv[2].phi(); - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - break; - } - case HcalSubdetector::HcalEndcap: - { - CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHE" << cv[0].phi() << " " << cv[2].phi(); - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - break; - } - default: - ppfjet_twr_dR_.push_back(-1); - break; - } - ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; - ++ppfjet_ntwrs_; - } - else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){ - ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; - } - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi matches - } // Loop over rechits - } // Loop over hits - } // Test if element is from HCAL - else if(elements[iEle].type() == reco::PFBlockElement::HFHAD){ // Element is HF - types |= 0x2; - ntypes++; - HFHAD_n_++; - HF_type_ |= 0x2; - - //// h_etaHFHAD_->Fill((*it)->eta()); - - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 1) continue; // Remove long fibers - auto thisCell = HFGeom->getGeometry((*ith).id()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(1.0); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(1); - ppfjet_twr_clusterind_.push_back(-1); - ppfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHFhad" << cv[0].phi() << " " << cv[2].phi(); - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ++ppfjet_ntwrs_; - HFHAD_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HFEM){ // Element is HF - types |= 0x4; - ntypes++; - HFEM_n_++; - HF_type_ |= 0x4; - - for(edm::SortedCollection>::const_iterator ith=hfreco->begin(); ith!=hfreco->end(); ++ith){ - if((*ith).id().depth() == 2) continue; // Remove short fibers - auto thisCell = HFGeom->getGeometry((*ith).id()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - - bool passMatch = false; - if((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()){ - if((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) passMatch = true; - else if(cv[0].phi() < cv[2].phi()){ - if((*it)->phi() < cv[0].phi()) passMatch = true; - else if((*it)->phi() > cv[2].phi()) passMatch = true; - } - } - - if(passMatch){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(1.0); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(2); - ppfjet_twr_clusterind_.push_back(-1); - ppfjet_twr_candtrackind_.push_back(-1); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHFem" << cv[0].phi() << " " << cv[2].phi(); - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ++ppfjet_ntwrs_; - HFEM_E += (*ith).energy(); - } - } - } - else if(elements[iEle].type() == reco::PFBlockElement::HO){ // Element is HO - types |= 0x8; - ntypes++; - HF_type_ |= 0x8; - reco::PFClusterRef clusterref = elements[iEle].clusterRef(); - reco::PFCluster cluster = *clusterref; - double cluster_dR = deltaR(ppfjet_eta_,ppfjet_phi_,cluster.eta(),cluster.phi()); - if(ppfjet_clusters.count(cluster_dR) == 0){ - ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; - ppfjet_cluster_eta_.push_back(cluster.eta()); - ppfjet_cluster_phi_.push_back(cluster.phi()); - ppfjet_cluster_dR_.push_back(cluster_dR); - ppfjet_cluster_n_++; - } - int cluster_ind = ppfjet_clusters[cluster_dR]; - - std::vector> hitsAndFracs = cluster.hitsAndFractions(); - int nHits = hitsAndFracs.size(); - for(int iHit=0; iHit>::const_iterator ith=horeco->begin(); ith!=horeco->end(); ++ith){ - int etaPhiRecHit = getEtaPhi((*ith).id()); - if(etaPhiPF == etaPhiRecHit){ - ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; - if(ppfjet_rechits.count((*ith).id()) == 0){ - ppfjet_twr_ieta_.push_back((*ith).id().ieta()); - ppfjet_twr_iphi_.push_back((*ith).id().iphi()); - ppfjet_twr_depth_.push_back((*ith).id().depth()); - ppfjet_twr_subdet_.push_back((*ith).id().subdet()); - ppfjet_twr_hade_.push_back((*ith).energy()); - ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); - ppfjet_twr_elmttype_.push_back(3); - ppfjet_twr_clusterind_.push_back(cluster_ind); - if(hasTrack){ - ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); - } - else{ - ppfjet_twr_candtrackind_.push_back(-1); - } - auto thisCell = HOGeom->getGeometry((*ith).id()); - const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); - float avgeta = (cv[0].eta() + cv[2].eta())/2.0; - float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - if((cv[0].phi() < cv[2].phi()) && (debug_>1)) edm::LogInfo("GammaJetAnalysis") << "pHO" << cv[0].phi() << " " << cv[2].phi(); - if(cv[0].phi() < cv[2].phi()) avgphi = (2.0*3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi()))/2.0; - - ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_,ppfjet_phi_,avgeta,avgphi)); - ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; - ++ppfjet_ntwrs_; - } - else if(ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0){ - ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; - if(cluster_dR < ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))){ - ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; - } - ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); - } - } // Test if ieta,iphi match - } // Loop over rechits - } // Loop over hits - } // Test if element is from HO - } // Test for right element index - } // Loop over elements - } // Loop over elements in blocks - switch(candidateType){ - case reco::PFCandidate::h_HF: - ppfjet_had_emf_.push_back(HFEM_E/(HFEM_E + HFHAD_E)); - break; - case reco::PFCandidate::egamma_HF: - ppfjet_had_emf_.push_back(-1); - break; - default: - ppfjet_had_emf_.push_back(-1); - break; - } - } // Loop over PF constitutents - - if(doGenJets_){ - // fill genjet variables - ppfjet_gendr_ = 99999.; - ppfjet_genpt_ = 0; - ppfjet_genp_ = 0; - for(std::vector::const_iterator it=genjets->begin(); it!=genjets->end(); ++it){ - const reco::GenJet* jet=&(*it); - double dr=deltaR(jet, pfjet_probe.jet()); - if(drpt(); - ppfjet_genp_ = jet->p(); - ppfjet_genE_ = jet->energy(); - } - } - } // doGenJets_ - if (iJet==2) { - copy_leadingPfJetVars_to_pfJet2(); + ///////////////////////////////////////////// + + // fill jet variables + // First start from a second jet, then fill the first jet + PFJetCorretPair pfjet_probe_store = pfjet_probe; + for (int iJet = 2; iJet > 0; iJet--) { + // prepare the container + clear_leadingPfJetVars(); + + if (iJet == 2) + pfjet_probe = pf_2ndjet; + else + pfjet_probe = pfjet_probe_store; + + if (!pfjet_probe.jet()) { + if (iJet == 2) { + // put zeros into 2nd jet quantities + copy_leadingPfJetVars_to_pfJet2(); + } else { + edm::LogWarning("GammaJetAnalysis") << "error in the code: leading pf jet is null"; + } + continue; + } + + HERE("work further"); + + // temporary variables + std::map>> ppfjet_rechits; + std::map ppfjet_clusters; + + // fill the values + ppfjet_pt_ = pfjet_probe.jet()->pt(); + ppfjet_p_ = pfjet_probe.jet()->p(); + ppfjet_eta_ = pfjet_probe.jet()->eta(); + ppfjet_area_ = pfjet_probe.jet()->jetArea(); + ppfjet_E_ = pfjet_probe.jet()->energy(); + ppfjet_E_NPVcorr_ = + pfjet_probe.jet()->energy() - getNeutralPVCorr(ppfjet_eta_, pf_NPV_, ppfjet_area_, doGenJets_); + ppfjet_phi_ = pfjet_probe.jet()->phi(); + ppfjet_NeutralHadronFrac_ = pfjet_probe.jet()->neutralHadronEnergyFraction(); + ppfjet_NeutralEMFrac_ = pfjet_probe.jet()->neutralEmEnergyFraction(); + ppfjet_nConstituents_ = pfjet_probe.jet()->nConstituents(); + ppfjet_ChargedHadronFrac_ = pfjet_probe.jet()->chargedHadronEnergyFraction(); + ppfjet_ChargedMultiplicity_ = pfjet_probe.jet()->chargedMultiplicity(); + ppfjet_ChargedEMFrac_ = pfjet_probe.jet()->chargedEmEnergyFraction(); + ppfjet_scale_ = pfjet_probe.scale(); + ppfjet_ntwrs_ = 0; + ppfjet_cluster_n_ = 0; + ppfjet_ncandtracks_ = 0; + + HERE("Get PF constituents"); + + // Get PF constituents and fill HCAL towers + std::vector probeconst = pfjet_probe.jet()->getPFConstituents(); + HERE(Form("probeconst.size=%d", int(probeconst.size()))); + int iPF = 0; + for (std::vector::const_iterator it = probeconst.begin(); it != probeconst.end(); ++it) { + bool hasTrack = false; + if (!(*it)) + HERE("\tnull probeconst iterator value\n"); + reco::PFCandidate::ParticleType candidateType = (*it)->particleId(); + iPF++; + HERE(Form("iPF=%d", iPF)); + + // store information + switch (candidateType) { + case reco::PFCandidate::X: + ppfjet_unkown_E_ += (*it)->energy(); + ppfjet_unkown_px_ += (*it)->px(); + ppfjet_unkown_py_ += (*it)->py(); + ppfjet_unkown_pz_ += (*it)->pz(); + ppfjet_unkown_EcalE_ += (*it)->ecalEnergy(); + ppfjet_unkown_n_++; + continue; + case reco::PFCandidate::h: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(0); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + + if (doGenJets_) { + float gendr = 99999; + float genE = 0; + int genpdgId = 0; + for (std::vector::const_iterator itmc = genparticles->begin(); + itmc != genparticles->end(); + itmc++) { + if (itmc->status() == 1 && itmc->pdgId() > 100) { + double dr = deltaR((*it)->eta(), (*it)->phi(), itmc->eta(), itmc->phi()); + if (dr < gendr) { + gendr = dr; + genE = itmc->energy(); + genpdgId = itmc->pdgId(); + } + } + } + ppfjet_had_E_mctruth_.push_back(genE); + ppfjet_had_mcpdgId_.push_back(genpdgId); + } + + reco::TrackRef trackRef = (*it)->trackRef(); + if (trackRef.isNonnull()) { + reco::Track track = *trackRef; + ppfjet_candtrack_px_.push_back(track.px()); + ppfjet_candtrack_py_.push_back(track.py()); + ppfjet_candtrack_pz_.push_back(track.pz()); + ppfjet_candtrack_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_candtrackind_.push_back(ppfjet_ncandtracks_); + hasTrack = true; + ppfjet_ncandtracks_++; + } else { + ppfjet_had_candtrackind_.push_back(-2); + } + } break; + case reco::PFCandidate::e: + ppfjet_electron_E_ += (*it)->energy(); + ppfjet_electron_px_ += (*it)->px(); + ppfjet_electron_py_ += (*it)->py(); + ppfjet_electron_pz_ += (*it)->pz(); + ppfjet_electron_EcalE_ += (*it)->ecalEnergy(); + ppfjet_electron_n_++; + continue; + case reco::PFCandidate::mu: + ppfjet_muon_E_ += (*it)->energy(); + ppfjet_muon_px_ += (*it)->px(); + ppfjet_muon_py_ += (*it)->py(); + ppfjet_muon_pz_ += (*it)->pz(); + ppfjet_muon_EcalE_ += (*it)->ecalEnergy(); + ppfjet_muon_n_++; + continue; + case reco::PFCandidate::gamma: + ppfjet_photon_E_ += (*it)->energy(); + ppfjet_photon_px_ += (*it)->px(); + ppfjet_photon_py_ += (*it)->py(); + ppfjet_photon_pz_ += (*it)->pz(); + ppfjet_photon_EcalE_ += (*it)->ecalEnergy(); + ppfjet_photon_n_++; + continue; + case reco::PFCandidate::h0: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(1); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + + if (doGenJets_) { + float gendr = 99999; + float genE = 0; + int genpdgId = 0; + for (std::vector::const_iterator itmc = genparticles->begin(); + itmc != genparticles->end(); + itmc++) { + if (itmc->status() == 1 && itmc->pdgId() > 100) { + double dr = deltaR((*it)->eta(), (*it)->phi(), itmc->eta(), itmc->phi()); + if (dr < gendr) { + gendr = dr; + genE = itmc->energy(); + genpdgId = itmc->pdgId(); + } + } + } + ppfjet_had_E_mctruth_.push_back(genE); + ppfjet_had_mcpdgId_.push_back(genpdgId); + } + + break; + } + case reco::PFCandidate::h_HF: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(2); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + + if (doGenJets_) { + float gendr = 99999; + float genE = 0; + int genpdgId = 0; + for (std::vector::const_iterator itmc = genparticles->begin(); + itmc != genparticles->end(); + itmc++) { + if (itmc->status() == 1 && itmc->pdgId() > 100) { + double dr = deltaR((*it)->eta(), (*it)->phi(), itmc->eta(), itmc->phi()); + if (dr < gendr) { + gendr = dr; + genE = itmc->energy(); + genpdgId = itmc->pdgId(); + } + } + } + ppfjet_had_E_mctruth_.push_back(genE); + ppfjet_had_mcpdgId_.push_back(genpdgId); + } + + break; + } + case reco::PFCandidate::egamma_HF: { + ppfjet_had_E_.push_back((*it)->energy()); + ppfjet_had_px_.push_back((*it)->px()); + ppfjet_had_py_.push_back((*it)->py()); + ppfjet_had_pz_.push_back((*it)->pz()); + ppfjet_had_EcalE_.push_back((*it)->ecalEnergy()); + ppfjet_had_rawHcalE_.push_back((*it)->rawHcalEnergy()); + ppfjet_had_id_.push_back(3); + ppfjet_had_candtrackind_.push_back(-1); + ppfjet_had_ntwrs_.push_back(0); + ppfjet_had_n_++; + + if (doGenJets_) { + float gendr = 99999; + float genE = 0; + int genpdgId = 0; + for (std::vector::const_iterator itmc = genparticles->begin(); + itmc != genparticles->end(); + itmc++) { + if (itmc->status() == 1 && itmc->pdgId() > 100) { + double dr = deltaR((*it)->eta(), (*it)->phi(), itmc->eta(), itmc->phi()); + if (dr < gendr) { + gendr = dr; + genE = itmc->energy(); + genpdgId = itmc->pdgId(); + } + } + } + ppfjet_had_E_mctruth_.push_back(genE); + ppfjet_had_mcpdgId_.push_back(genpdgId); + } + + break; + } + } + + float HFHAD_E = 0; + float HFEM_E = 0; + int HFHAD_n_ = 0; + int HFEM_n_ = 0; + int HF_type_ = 0; + int maxElement = (*it)->elementsInBlocks().size(); + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "maxElement=" << maxElement; + if (workOnAOD_ == 1) { + maxElement = 0; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "forced 0"; + } + HERE(Form("maxElement=%d", maxElement)); + for (int e = 0; e < maxElement; ++e) { + // Get elements from block + reco::PFBlockRef blockRef = (*it)->elementsInBlocks()[e].first; + const edm::OwnVector& elements = blockRef->elements(); + for (unsigned iEle = 0; iEle < elements.size(); iEle++) { + if (elements[iEle].index() == (*it)->elementsInBlocks()[e].second) { + if (elements[iEle].type() == reco::PFBlockElement::HCAL) { // Element is HB or HE + HF_type_ |= 0x1; + // Get cluster and hits + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(ppfjet_eta_, ppfjet_phi_, cluster.eta(), cluster.phi()); + if (ppfjet_clusters.count(cluster_dR) == 0) { + ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; + ppfjet_cluster_eta_.push_back(cluster.eta()); + ppfjet_cluster_phi_.push_back(cluster.phi()); + ppfjet_cluster_dR_.push_back(cluster_dR); + ppfjet_cluster_n_++; + } + int cluster_ind = ppfjet_clusters[cluster_dR]; + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + + // Run over hits and match + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + hbhereco->begin(); + ith != hbhereco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + if (ppfjet_rechits.count((*ith).id()) == 0) { + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(0); + ppfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); + } else { + ppfjet_twr_candtrackind_.push_back(-1); + } + switch ((*ith).id().subdet()) { + case HcalSubdetector::HcalBarrel: { + CaloCellGeometry::CornersVec cv = HBGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = + (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if ((cv[0].phi() < cv[2].phi()) && (debug_ > 1)) + edm::LogInfo("GammaJetAnalysis") << "pHB" << cv[0].phi() << " " << cv[2].phi(); + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + break; + } + case HcalSubdetector::HcalEndcap: { + CaloCellGeometry::CornersVec cv = HEGeom->getCorners((*ith).id()); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = + (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if ((cv[0].phi() < cv[2].phi()) && (debug_ > 1)) + edm::LogInfo("GammaJetAnalysis") << "pHE" << cv[0].phi() << " " << cv[2].phi(); + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + break; + } + default: + ppfjet_twr_dR_.push_back(-1); + break; + } + ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; + ++ppfjet_ntwrs_; + } else if (ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))) { + ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; + } + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi matches + } // Loop over rechits + } // Loop over hits + } // Test if element is from HCAL + else if (elements[iEle].type() == reco::PFBlockElement::HFHAD) { // Element is HF + types |= 0x2; + ntypes++; + HFHAD_n_++; + HF_type_ |= 0x2; + + //// h_etaHFHAD_->Fill((*it)->eta()); + + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 1) + continue; // Remove long fibers + auto thisCell = HFGeom->getGeometry((*ith).id()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(1.0); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(1); + ppfjet_twr_clusterind_.push_back(-1); + ppfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if ((cv[0].phi() < cv[2].phi()) && (debug_ > 1)) + edm::LogInfo("GammaJetAnalysis") << "pHFhad" << cv[0].phi() << " " << cv[2].phi(); + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ++ppfjet_ntwrs_; + HFHAD_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HFEM) { // Element is HF + types |= 0x4; + ntypes++; + HFEM_n_++; + HF_type_ |= 0x4; + + for (edm::SortedCollection>::const_iterator ith = + hfreco->begin(); + ith != hfreco->end(); + ++ith) { + if ((*ith).id().depth() == 2) + continue; // Remove short fibers + auto thisCell = HFGeom->getGeometry((*ith).id()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + + bool passMatch = false; + if ((*it)->eta() < cv[0].eta() && (*it)->eta() > cv[2].eta()) { + if ((*it)->phi() < cv[0].phi() && (*it)->phi() > cv[2].phi()) + passMatch = true; + else if (cv[0].phi() < cv[2].phi()) { + if ((*it)->phi() < cv[0].phi()) + passMatch = true; + else if ((*it)->phi() > cv[2].phi()) + passMatch = true; + } + } + + if (passMatch) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(1.0); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(2); + ppfjet_twr_clusterind_.push_back(-1); + ppfjet_twr_candtrackind_.push_back(-1); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if ((cv[0].phi() < cv[2].phi()) && (debug_ > 1)) + edm::LogInfo("GammaJetAnalysis") << "pHFem" << cv[0].phi() << " " << cv[2].phi(); + if (cv[0].phi() < cv[2].phi()) + avgphi = + (2.0 * 3.141592653 + static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / + 2.0; + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ++ppfjet_ntwrs_; + HFEM_E += (*ith).energy(); + } + } + } else if (elements[iEle].type() == reco::PFBlockElement::HO) { // Element is HO + types |= 0x8; + ntypes++; + HF_type_ |= 0x8; + reco::PFClusterRef clusterref = elements[iEle].clusterRef(); + reco::PFCluster cluster = *clusterref; + double cluster_dR = deltaR(ppfjet_eta_, ppfjet_phi_, cluster.eta(), cluster.phi()); + if (ppfjet_clusters.count(cluster_dR) == 0) { + ppfjet_clusters[cluster_dR] = ppfjet_cluster_n_; + ppfjet_cluster_eta_.push_back(cluster.eta()); + ppfjet_cluster_phi_.push_back(cluster.phi()); + ppfjet_cluster_dR_.push_back(cluster_dR); + ppfjet_cluster_n_++; + } + int cluster_ind = ppfjet_clusters[cluster_dR]; + + std::vector> hitsAndFracs = cluster.hitsAndFractions(); + int nHits = hitsAndFracs.size(); + for (int iHit = 0; iHit < nHits; iHit++) { + int etaPhiPF = getEtaPhi(hitsAndFracs[iHit].first); + + for (edm::SortedCollection>::const_iterator ith = + horeco->begin(); + ith != horeco->end(); + ++ith) { + int etaPhiRecHit = getEtaPhi((*ith).id()); + if (etaPhiPF == etaPhiRecHit) { + ppfjet_had_ntwrs_.at(ppfjet_had_n_ - 1)++; + if (ppfjet_rechits.count((*ith).id()) == 0) { + ppfjet_twr_ieta_.push_back((*ith).id().ieta()); + ppfjet_twr_iphi_.push_back((*ith).id().iphi()); + ppfjet_twr_depth_.push_back((*ith).id().depth()); + ppfjet_twr_subdet_.push_back((*ith).id().subdet()); + ppfjet_twr_hade_.push_back((*ith).energy()); + ppfjet_twr_frac_.push_back(hitsAndFracs[iHit].second); + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + ppfjet_twr_hadind_.push_back(ppfjet_had_n_ - 1); + ppfjet_twr_elmttype_.push_back(3); + ppfjet_twr_clusterind_.push_back(cluster_ind); + if (hasTrack) { + ppfjet_twr_candtrackind_.push_back(ppfjet_ncandtracks_ - 1); + } else { + ppfjet_twr_candtrackind_.push_back(-1); + } + auto thisCell = HOGeom->getGeometry((*ith).id()); + const CaloCellGeometry::CornersVec& cv = thisCell->getCorners(); + float avgeta = (cv[0].eta() + cv[2].eta()) / 2.0; + float avgphi = (static_cast(cv[0].phi()) + static_cast(cv[2].phi())) / 2.0; + if ((cv[0].phi() < cv[2].phi()) && (debug_ > 1)) + edm::LogInfo("GammaJetAnalysis") << "pHO" << cv[0].phi() << " " << cv[2].phi(); + if (cv[0].phi() < cv[2].phi()) + avgphi = (2.0 * 3.141592653 + static_cast(cv[0].phi()) + + static_cast(cv[2].phi())) / + 2.0; + + ppfjet_twr_dR_.push_back(deltaR(ppfjet_eta_, ppfjet_phi_, avgeta, avgphi)); + ppfjet_rechits[(*ith).id()].first = ppfjet_ntwrs_; + ++ppfjet_ntwrs_; + } else if (ppfjet_rechits[(*ith).id()].second.count(hitsAndFracs[iHit].second) == 0) { + ppfjet_twr_frac_.at(ppfjet_rechits[(*ith).id()].first) += hitsAndFracs[iHit].second; + if (cluster_dR < + ppfjet_cluster_dR_.at(ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first))) { + ppfjet_twr_clusterind_.at(ppfjet_rechits[(*ith).id()].first) = cluster_ind; + } + ppfjet_rechits[(*ith).id()].second.insert(hitsAndFracs[iHit].second); + } + } // Test if ieta,iphi match + } // Loop over rechits + } // Loop over hits + } // Test if element is from HO + } // Test for right element index + } // Loop over elements + } // Loop over elements in blocks + switch (candidateType) { + case reco::PFCandidate::h_HF: + ppfjet_had_emf_.push_back(HFEM_E / (HFEM_E + HFHAD_E)); + break; + case reco::PFCandidate::egamma_HF: + ppfjet_had_emf_.push_back(-1); + break; + default: + ppfjet_had_emf_.push_back(-1); + break; + } + } // Loop over PF constitutents + + if (doGenJets_) { + // fill genjet variables + ppfjet_gendr_ = 99999.; + ppfjet_genpt_ = 0; + ppfjet_genp_ = 0; + for (std::vector::const_iterator it = genjets->begin(); it != genjets->end(); ++it) { + const reco::GenJet* jet = &(*it); + double dr = deltaR(jet, pfjet_probe.jet()); + if (dr < ppfjet_gendr_) { + ppfjet_gendr_ = dr; + ppfjet_genpt_ = jet->pt(); + ppfjet_genp_ = jet->p(); + ppfjet_genE_ = jet->energy(); + } + } + } // doGenJets_ + if (iJet == 2) { + copy_leadingPfJetVars_to_pfJet2(); + } + } + // double jer= (ppfjet_genpt_==double(0)) ? + // 0. : pfjet_probe.jet()->et()/ppfjet_genpt_; + ///h_pfrecoOgen_et->Fill(jer, eventWeight_); + + ///// MET ///// + edm::Handle pfmet_h; + iEvent.getByToken(tok_PFMET_, pfmet_h); + if (!pfmet_h.isValid()) { + edm::LogWarning("GammaJetAnalysis") << " could not find " << pfMETColl; + return; + } + met_value_ = pfmet_h->begin()->et(); + met_phi_ = pfmet_h->begin()->phi(); + met_sumEt_ = pfmet_h->begin()->sumEt(); + + edm::Handle pfmetType1_h; + iEvent.getByToken(tok_PFType1MET_, pfmetType1_h); + if (pfmetType1_h.isValid()) { + metType1_value_ = pfmetType1_h->begin()->et(); + metType1_phi_ = pfmetType1_h->begin()->phi(); + metType1_sumEt_ = pfmetType1_h->begin()->sumEt(); + } else { + // do we need an exception here? + metType1_value_ = -999.; + metType1_phi_ = -999.; + metType1_sumEt_ = -999.; } - } - // double jer= (ppfjet_genpt_==double(0)) ? - // 0. : pfjet_probe.jet()->et()/ppfjet_genpt_; - ///h_pfrecoOgen_et->Fill(jer, eventWeight_); - - ///// MET ///// - edm::Handle pfmet_h; - iEvent.getByToken(tok_PFMET_, pfmet_h); - if (!pfmet_h.isValid()) { - edm::LogWarning("GammaJetAnalysis") << " could not find " << pfMETColl; - return; - } - met_value_ = pfmet_h->begin()->et(); - met_phi_ = pfmet_h->begin()->phi(); - met_sumEt_ = pfmet_h->begin()->sumEt(); - - edm::Handle pfmetType1_h; - iEvent.getByToken(tok_PFType1MET_, pfmetType1_h); - if ( pfmetType1_h.isValid()) { - metType1_value_ = pfmetType1_h->begin()->et(); - metType1_phi_ = pfmetType1_h->begin()->phi(); - metType1_sumEt_ = pfmetType1_h->begin()->sumEt(); - } - else { - // do we need an exception here? - metType1_value_ = -999.; - metType1_phi_ = -999.; - metType1_sumEt_ = -999.; - } - - // fill photon+jet variables - pf_tree_->Fill(); + // fill photon+jet variables + pf_tree_->Fill(); } } return; - } // ------------ method called once each job just before starting event loop ------------ -void GammaJetAnalysis::beginJob() -{ +void GammaJetAnalysis::beginJob() { rootfile_ = new TFile(rootHistFilename_.c_str(), "RECREATE"); if (doPFJets_) { pf_tree_ = new TTree("pf_gammajettree", "tree for gamma+jet balancing using PFJets"); assert(pf_tree_); } - for (int iJet=0; iJet<2; iJet++) { - bool doJet=doPFJets_; - if (!doJet) continue; - if (iJet>0) continue; // ! caloJet are no longer there, so store only once - TTree *tree= pf_tree_; + for (int iJet = 0; iJet < 2; iJet++) { + bool doJet = doPFJets_; + if (!doJet) + continue; + if (iJet > 0) + continue; // ! caloJet are no longer there, so store only once + TTree* tree = pf_tree_; // Event triggers tree->Branch("photonTrig_fired", &photonTrigFired_); @@ -1293,215 +1429,214 @@ void GammaJetAnalysis::beginJob() tree->Branch("jetTrig_prescale", &jetTrigPrescale_); // Event info - tree->Branch("RunNumber",&runNumber_, "RunNumber/I"); - tree->Branch("LumiBlock",&lumiBlock_, "LumiBlock/I"); - tree->Branch("EventNumber",&eventNumber_, "EventNumber/I"); - tree->Branch("EventWeight",&eventWeight_, "EventWeight/F"); - tree->Branch("EventPtHat",&eventPtHat_, "EventPtHat/F"); + tree->Branch("RunNumber", &runNumber_, "RunNumber/I"); + tree->Branch("LumiBlock", &lumiBlock_, "LumiBlock/I"); + tree->Branch("EventNumber", &eventNumber_, "EventNumber/I"); + tree->Branch("EventWeight", &eventWeight_, "EventWeight/F"); + tree->Branch("EventPtHat", &eventPtHat_, "EventPtHat/F"); // Photon info tree->Branch("rho2012", &rho2012_, "rho2012/F"); - tree->Branch("tagPho_pt", &tagPho_pt_, "tagPho_pt/F"); - tree->Branch("pho_2nd_pt", &pho_2nd_pt_, "pho_2nd_pt/F"); - tree->Branch("tagPho_energy", &tagPho_energy_, "tagPho_energy/F"); - tree->Branch("tagPho_eta", &tagPho_eta_, "tagPho_eta/F"); - tree->Branch("tagPho_phi", &tagPho_phi_, "tagPho_phi/F"); + tree->Branch("tagPho_pt", &tagPho_pt_, "tagPho_pt/F"); + tree->Branch("pho_2nd_pt", &pho_2nd_pt_, "pho_2nd_pt/F"); + tree->Branch("tagPho_energy", &tagPho_energy_, "tagPho_energy/F"); + tree->Branch("tagPho_eta", &tagPho_eta_, "tagPho_eta/F"); + tree->Branch("tagPho_phi", &tagPho_phi_, "tagPho_phi/F"); tree->Branch("tagPho_sieie", &tagPho_sieie_, "tagPho_sieie/F"); - tree->Branch("tagPho_HoE", &tagPho_HoE_, "tagPho_HoE/F"); - tree->Branch("tagPho_r9", &tagPho_r9_, "tagPho_r9/F"); - tree->Branch("tagPho_EcalIsoDR04",&tagPho_EcalIsoDR04_, "tagPho_EcalIsoDR04/F"); - tree->Branch("tagPho_HcalIsoDR04",&tagPho_HcalIsoDR04_, "tagPho_HcalIsoDR04/F"); - tree->Branch("tagPho_HcalIsoDR0412",&tagPho_HcalIsoDR0412_, "tagPho_HcalIsoDR0412/F"); - tree->Branch("tagPho_TrkIsoHollowDR04",&tagPho_TrkIsoHollowDR04_, "tagPho_TrkIsoHollowDR04/F"); - tree->Branch("tagPho_pfiso_myphoton03",&tagPho_pfiso_myphoton03_, "tagPho_pfiso_myphoton03/F"); - tree->Branch("tagPho_pfiso_myneutral03",&tagPho_pfiso_myneutral03_, "tagPho_pfiso_myneutral03/F"); - tree->Branch("tagPho_pfiso_mycharged03","std::vector >", &tagPho_pfiso_mycharged03); - tree->Branch("tagPho_pixelSeed", &tagPho_pixelSeed_, "tagPho_pixelSeed/I"); + tree->Branch("tagPho_HoE", &tagPho_HoE_, "tagPho_HoE/F"); + tree->Branch("tagPho_r9", &tagPho_r9_, "tagPho_r9/F"); + tree->Branch("tagPho_EcalIsoDR04", &tagPho_EcalIsoDR04_, "tagPho_EcalIsoDR04/F"); + tree->Branch("tagPho_HcalIsoDR04", &tagPho_HcalIsoDR04_, "tagPho_HcalIsoDR04/F"); + tree->Branch("tagPho_HcalIsoDR0412", &tagPho_HcalIsoDR0412_, "tagPho_HcalIsoDR0412/F"); + tree->Branch("tagPho_TrkIsoHollowDR04", &tagPho_TrkIsoHollowDR04_, "tagPho_TrkIsoHollowDR04/F"); + tree->Branch("tagPho_pfiso_myphoton03", &tagPho_pfiso_myphoton03_, "tagPho_pfiso_myphoton03/F"); + tree->Branch("tagPho_pfiso_myneutral03", &tagPho_pfiso_myneutral03_, "tagPho_pfiso_myneutral03/F"); + tree->Branch("tagPho_pfiso_mycharged03", "std::vector >", &tagPho_pfiso_mycharged03); + tree->Branch("tagPho_pixelSeed", &tagPho_pixelSeed_, "tagPho_pixelSeed/I"); tree->Branch("tagPho_ConvSafeEleVeto", &tagPho_ConvSafeEleVeto_, "tagPho_ConvSafeEleVeto/I"); - tree->Branch("tagPho_idTight",&tagPho_idTight_, "tagPho_idTight/I"); - tree->Branch("tagPho_idLoose",&tagPho_idLoose_, "tagPho_idLoose/I"); + tree->Branch("tagPho_idTight", &tagPho_idTight_, "tagPho_idTight/I"); + tree->Branch("tagPho_idLoose", &tagPho_idLoose_, "tagPho_idLoose/I"); // gen.info on photon - if(doGenJets_){ - tree->Branch("tagPho_genPt",&tagPho_genPt_, "tagPho_genPt/F"); - tree->Branch("tagPho_genEnergy",&tagPho_genEnergy_,"tagPho_genEnergy/F"); - tree->Branch("tagPho_genEta",&tagPho_genEta_, "tagPho_genEta/F"); - tree->Branch("tagPho_genPhi",&tagPho_genPhi_, "tagPho_genPhi/F"); - tree->Branch("tagPho_genDeltaR",&tagPho_genDeltaR_,"tagPho_genDeltaR/F"); + if (doGenJets_) { + tree->Branch("tagPho_genPt", &tagPho_genPt_, "tagPho_genPt/F"); + tree->Branch("tagPho_genEnergy", &tagPho_genEnergy_, "tagPho_genEnergy/F"); + tree->Branch("tagPho_genEta", &tagPho_genEta_, "tagPho_genEta/F"); + tree->Branch("tagPho_genPhi", &tagPho_genPhi_, "tagPho_genPhi/F"); + tree->Branch("tagPho_genDeltaR", &tagPho_genDeltaR_, "tagPho_genDeltaR/F"); } - // counters - tree->Branch("nPhotons",&nPhotons_, "nPhotons/I"); - tree->Branch("nGenJets",&nGenJets_, "nGenJets/I"); + // counters + tree->Branch("nPhotons", &nPhotons_, "nPhotons/I"); + tree->Branch("nGenJets", &nGenJets_, "nGenJets/I"); } //////// Particle Flow //////// if (doPFJets_) { - - pf_tree_->Branch("nPFJets",&nPFJets_, "nPFJets/I"); + pf_tree_->Branch("nPFJets", &nPFJets_, "nPFJets/I"); // Leading jet info - pf_tree_->Branch("ppfjet_pt",&ppfjet_pt_, "ppfjet_pt/F"); - pf_tree_->Branch("ppfjet_p",&ppfjet_p_, "ppfjet_p/F"); - pf_tree_->Branch("ppfjet_E",&ppfjet_E_, "ppfjet_E/F"); - pf_tree_->Branch("ppfjet_E_NPVcorr",&ppfjet_E_NPVcorr_, "ppfjet_E_NPVcorr/F"); - pf_tree_->Branch("ppfjet_area",&ppfjet_area_, "ppfjet_area/F"); - pf_tree_->Branch("ppfjet_eta",&ppfjet_eta_, "ppfjet_eta/F"); - pf_tree_->Branch("ppfjet_phi",&ppfjet_phi_, "ppfjet_phi/F"); - pf_tree_->Branch("ppfjet_scale",&ppfjet_scale_, "ppfjet_scale/F"); + pf_tree_->Branch("ppfjet_pt", &ppfjet_pt_, "ppfjet_pt/F"); + pf_tree_->Branch("ppfjet_p", &ppfjet_p_, "ppfjet_p/F"); + pf_tree_->Branch("ppfjet_E", &ppfjet_E_, "ppfjet_E/F"); + pf_tree_->Branch("ppfjet_E_NPVcorr", &ppfjet_E_NPVcorr_, "ppfjet_E_NPVcorr/F"); + pf_tree_->Branch("ppfjet_area", &ppfjet_area_, "ppfjet_area/F"); + pf_tree_->Branch("ppfjet_eta", &ppfjet_eta_, "ppfjet_eta/F"); + pf_tree_->Branch("ppfjet_phi", &ppfjet_phi_, "ppfjet_phi/F"); + pf_tree_->Branch("ppfjet_scale", &ppfjet_scale_, "ppfjet_scale/F"); pf_tree_->Branch("ppfjet_NeutralHadronFrac", &ppfjet_NeutralHadronFrac_, "ppfjet_NeutralHadronFrac/F"); pf_tree_->Branch("ppfjet_NeutralEMFrac", &ppfjet_NeutralEMFrac_, "ppfjet_NeutralEMFrac/F"); pf_tree_->Branch("ppfjet_nConstituents", &ppfjet_nConstituents_, "ppfjet_nConstituents/I"); pf_tree_->Branch("ppfjet_ChargedHadronFrac", &ppfjet_ChargedHadronFrac_, "ppfjet_ChargedHadronFrac/F"); pf_tree_->Branch("ppfjet_ChargedMultiplicity", &ppfjet_ChargedMultiplicity_, "ppfjet_ChargedMultiplicity/F"); pf_tree_->Branch("ppfjet_ChargedEMFrac", &ppfjet_ChargedEMFrac_, "ppfjet_ChargedEMFrac/F"); - if(doGenJets_){ - pf_tree_->Branch("ppfjet_genpt",&ppfjet_genpt_, "ppfjet_genpt/F"); - pf_tree_->Branch("ppfjet_genp",&ppfjet_genp_, "ppfjet_genp/F"); - pf_tree_->Branch("ppfjet_genE",&ppfjet_genE_, "ppfjet_genE/F"); - pf_tree_->Branch("ppfjet_gendr",&ppfjet_gendr_, "ppfjet_gendr/F"); + if (doGenJets_) { + pf_tree_->Branch("ppfjet_genpt", &ppfjet_genpt_, "ppfjet_genpt/F"); + pf_tree_->Branch("ppfjet_genp", &ppfjet_genp_, "ppfjet_genp/F"); + pf_tree_->Branch("ppfjet_genE", &ppfjet_genE_, "ppfjet_genE/F"); + pf_tree_->Branch("ppfjet_gendr", &ppfjet_gendr_, "ppfjet_gendr/F"); } - pf_tree_->Branch("ppfjet_unkown_E",&ppfjet_unkown_E_, "ppfjet_unkown_E/F"); - pf_tree_->Branch("ppfjet_electron_E",&ppfjet_electron_E_, "ppfjet_electron_E/F"); - pf_tree_->Branch("ppfjet_muon_E",&ppfjet_muon_E_, "ppfjet_muon_E/F"); - pf_tree_->Branch("ppfjet_photon_E",&ppfjet_photon_E_, "ppfjet_photon_E/F"); - pf_tree_->Branch("ppfjet_unkown_px",&ppfjet_unkown_px_, "ppfjet_unkown_px/F"); - pf_tree_->Branch("ppfjet_electron_px",&ppfjet_electron_px_, "ppfjet_electron_px/F"); - pf_tree_->Branch("ppfjet_muon_px",&ppfjet_muon_px_, "ppfjet_muon_px/F"); - pf_tree_->Branch("ppfjet_photon_px",&ppfjet_photon_px_, "ppfjet_photon_px/F"); - pf_tree_->Branch("ppfjet_unkown_py",&ppfjet_unkown_py_, "ppfjet_unkown_py/F"); - pf_tree_->Branch("ppfjet_electron_py",&ppfjet_electron_py_, "ppfjet_electron_py/F"); - pf_tree_->Branch("ppfjet_muon_py",&ppfjet_muon_py_, "ppfjet_muon_py/F"); - pf_tree_->Branch("ppfjet_photon_py",&ppfjet_photon_py_, "ppfjet_photon_py/F"); - pf_tree_->Branch("ppfjet_unkown_pz",&ppfjet_unkown_pz_, "ppfjet_unkown_pz/F"); - pf_tree_->Branch("ppfjet_electron_pz",&ppfjet_electron_pz_, "ppfjet_electron_pz/F"); - pf_tree_->Branch("ppfjet_muon_pz",&ppfjet_muon_pz_, "ppfjet_muon_pz/F"); - pf_tree_->Branch("ppfjet_photon_pz",&ppfjet_photon_pz_, "ppfjet_photon_pz/F"); - pf_tree_->Branch("ppfjet_unkown_EcalE",&ppfjet_unkown_EcalE_, "ppfjet_unkown_EcalE/F"); - pf_tree_->Branch("ppfjet_electron_EcalE",&ppfjet_electron_EcalE_, "ppfjet_electron_EcalE/F"); - pf_tree_->Branch("ppfjet_muon_EcalE",&ppfjet_muon_EcalE_, "ppfjet_muon_EcalE/F"); - pf_tree_->Branch("ppfjet_photon_EcalE",&ppfjet_photon_EcalE_, "ppfjet_photon_EcalE/F"); - pf_tree_->Branch("ppfjet_unkown_n",&ppfjet_unkown_n_, "ppfjet_unkown_n/I"); - pf_tree_->Branch("ppfjet_electron_n",&ppfjet_electron_n_, "ppfjet_electron_n/I"); - pf_tree_->Branch("ppfjet_muon_n",&ppfjet_muon_n_, "ppfjet_muon_n/I"); - pf_tree_->Branch("ppfjet_photon_n",&ppfjet_photon_n_, "ppfjet_photon_n/I"); - pf_tree_->Branch("ppfjet_had_n",&ppfjet_had_n_, "ppfjet_had_n/I"); - pf_tree_->Branch("ppfjet_had_E",&ppfjet_had_E_); - pf_tree_->Branch("ppfjet_had_px",&ppfjet_had_px_); - pf_tree_->Branch("ppfjet_had_py",&ppfjet_had_py_); - pf_tree_->Branch("ppfjet_had_pz",&ppfjet_had_pz_); - pf_tree_->Branch("ppfjet_had_EcalE",&ppfjet_had_EcalE_); - pf_tree_->Branch("ppfjet_had_rawHcalE",&ppfjet_had_rawHcalE_); - pf_tree_->Branch("ppfjet_had_emf",&ppfjet_had_emf_); - pf_tree_->Branch("ppfjet_had_id",&ppfjet_had_id_); - pf_tree_->Branch("ppfjet_had_candtrackind",&ppfjet_had_candtrackind_); - if(doGenJets_){ - pf_tree_->Branch("ppfjet_had_E_mctruth",&ppfjet_had_E_mctruth_); - pf_tree_->Branch("ppfjet_had_mcpdgId",&ppfjet_had_mcpdgId_); + pf_tree_->Branch("ppfjet_unkown_E", &ppfjet_unkown_E_, "ppfjet_unkown_E/F"); + pf_tree_->Branch("ppfjet_electron_E", &ppfjet_electron_E_, "ppfjet_electron_E/F"); + pf_tree_->Branch("ppfjet_muon_E", &ppfjet_muon_E_, "ppfjet_muon_E/F"); + pf_tree_->Branch("ppfjet_photon_E", &ppfjet_photon_E_, "ppfjet_photon_E/F"); + pf_tree_->Branch("ppfjet_unkown_px", &ppfjet_unkown_px_, "ppfjet_unkown_px/F"); + pf_tree_->Branch("ppfjet_electron_px", &ppfjet_electron_px_, "ppfjet_electron_px/F"); + pf_tree_->Branch("ppfjet_muon_px", &ppfjet_muon_px_, "ppfjet_muon_px/F"); + pf_tree_->Branch("ppfjet_photon_px", &ppfjet_photon_px_, "ppfjet_photon_px/F"); + pf_tree_->Branch("ppfjet_unkown_py", &ppfjet_unkown_py_, "ppfjet_unkown_py/F"); + pf_tree_->Branch("ppfjet_electron_py", &ppfjet_electron_py_, "ppfjet_electron_py/F"); + pf_tree_->Branch("ppfjet_muon_py", &ppfjet_muon_py_, "ppfjet_muon_py/F"); + pf_tree_->Branch("ppfjet_photon_py", &ppfjet_photon_py_, "ppfjet_photon_py/F"); + pf_tree_->Branch("ppfjet_unkown_pz", &ppfjet_unkown_pz_, "ppfjet_unkown_pz/F"); + pf_tree_->Branch("ppfjet_electron_pz", &ppfjet_electron_pz_, "ppfjet_electron_pz/F"); + pf_tree_->Branch("ppfjet_muon_pz", &ppfjet_muon_pz_, "ppfjet_muon_pz/F"); + pf_tree_->Branch("ppfjet_photon_pz", &ppfjet_photon_pz_, "ppfjet_photon_pz/F"); + pf_tree_->Branch("ppfjet_unkown_EcalE", &ppfjet_unkown_EcalE_, "ppfjet_unkown_EcalE/F"); + pf_tree_->Branch("ppfjet_electron_EcalE", &ppfjet_electron_EcalE_, "ppfjet_electron_EcalE/F"); + pf_tree_->Branch("ppfjet_muon_EcalE", &ppfjet_muon_EcalE_, "ppfjet_muon_EcalE/F"); + pf_tree_->Branch("ppfjet_photon_EcalE", &ppfjet_photon_EcalE_, "ppfjet_photon_EcalE/F"); + pf_tree_->Branch("ppfjet_unkown_n", &ppfjet_unkown_n_, "ppfjet_unkown_n/I"); + pf_tree_->Branch("ppfjet_electron_n", &ppfjet_electron_n_, "ppfjet_electron_n/I"); + pf_tree_->Branch("ppfjet_muon_n", &ppfjet_muon_n_, "ppfjet_muon_n/I"); + pf_tree_->Branch("ppfjet_photon_n", &ppfjet_photon_n_, "ppfjet_photon_n/I"); + pf_tree_->Branch("ppfjet_had_n", &ppfjet_had_n_, "ppfjet_had_n/I"); + pf_tree_->Branch("ppfjet_had_E", &ppfjet_had_E_); + pf_tree_->Branch("ppfjet_had_px", &ppfjet_had_px_); + pf_tree_->Branch("ppfjet_had_py", &ppfjet_had_py_); + pf_tree_->Branch("ppfjet_had_pz", &ppfjet_had_pz_); + pf_tree_->Branch("ppfjet_had_EcalE", &ppfjet_had_EcalE_); + pf_tree_->Branch("ppfjet_had_rawHcalE", &ppfjet_had_rawHcalE_); + pf_tree_->Branch("ppfjet_had_emf", &ppfjet_had_emf_); + pf_tree_->Branch("ppfjet_had_id", &ppfjet_had_id_); + pf_tree_->Branch("ppfjet_had_candtrackind", &ppfjet_had_candtrackind_); + if (doGenJets_) { + pf_tree_->Branch("ppfjet_had_E_mctruth", &ppfjet_had_E_mctruth_); + pf_tree_->Branch("ppfjet_had_mcpdgId", &ppfjet_had_mcpdgId_); } - pf_tree_->Branch("ppfjet_had_ntwrs",&ppfjet_had_ntwrs_); - pf_tree_->Branch("ppfjet_ntwrs",&ppfjet_ntwrs_, "ppfjet_ntwrs/I"); - pf_tree_->Branch("ppfjet_twr_ieta",&ppfjet_twr_ieta_); - pf_tree_->Branch("ppfjet_twr_iphi",&ppfjet_twr_iphi_); - pf_tree_->Branch("ppfjet_twr_depth",&ppfjet_twr_depth_); - pf_tree_->Branch("ppfjet_twr_subdet",&ppfjet_twr_subdet_); - pf_tree_->Branch("ppfjet_twr_hade",&ppfjet_twr_hade_); - pf_tree_->Branch("ppfjet_twr_frac",&ppfjet_twr_frac_); - pf_tree_->Branch("ppfjet_twr_candtrackind",&ppfjet_twr_candtrackind_); - pf_tree_->Branch("ppfjet_twr_hadind",&ppfjet_twr_hadind_); - pf_tree_->Branch("ppfjet_twr_elmttype",&ppfjet_twr_elmttype_); - pf_tree_->Branch("ppfjet_twr_dR",&ppfjet_twr_dR_); - pf_tree_->Branch("ppfjet_twr_clusterind",&ppfjet_twr_clusterind_); - pf_tree_->Branch("ppfjet_cluster_n",&ppfjet_cluster_n_, "ppfjet_cluster_n/I"); - pf_tree_->Branch("ppfjet_cluster_eta",&ppfjet_cluster_eta_); - pf_tree_->Branch("ppfjet_cluster_phi",&ppfjet_cluster_phi_); - pf_tree_->Branch("ppfjet_cluster_dR",&ppfjet_cluster_dR_); - pf_tree_->Branch("ppfjet_ncandtracks",&ppfjet_ncandtracks_, "ppfjet_ncandtracks/I"); - pf_tree_->Branch("ppfjet_candtrack_px",&ppfjet_candtrack_px_); - pf_tree_->Branch("ppfjet_candtrack_py",&ppfjet_candtrack_py_); - pf_tree_->Branch("ppfjet_candtrack_pz",&ppfjet_candtrack_pz_); - pf_tree_->Branch("ppfjet_candtrack_EcalE",&ppfjet_candtrack_EcalE_); + pf_tree_->Branch("ppfjet_had_ntwrs", &ppfjet_had_ntwrs_); + pf_tree_->Branch("ppfjet_ntwrs", &ppfjet_ntwrs_, "ppfjet_ntwrs/I"); + pf_tree_->Branch("ppfjet_twr_ieta", &ppfjet_twr_ieta_); + pf_tree_->Branch("ppfjet_twr_iphi", &ppfjet_twr_iphi_); + pf_tree_->Branch("ppfjet_twr_depth", &ppfjet_twr_depth_); + pf_tree_->Branch("ppfjet_twr_subdet", &ppfjet_twr_subdet_); + pf_tree_->Branch("ppfjet_twr_hade", &ppfjet_twr_hade_); + pf_tree_->Branch("ppfjet_twr_frac", &ppfjet_twr_frac_); + pf_tree_->Branch("ppfjet_twr_candtrackind", &ppfjet_twr_candtrackind_); + pf_tree_->Branch("ppfjet_twr_hadind", &ppfjet_twr_hadind_); + pf_tree_->Branch("ppfjet_twr_elmttype", &ppfjet_twr_elmttype_); + pf_tree_->Branch("ppfjet_twr_dR", &ppfjet_twr_dR_); + pf_tree_->Branch("ppfjet_twr_clusterind", &ppfjet_twr_clusterind_); + pf_tree_->Branch("ppfjet_cluster_n", &ppfjet_cluster_n_, "ppfjet_cluster_n/I"); + pf_tree_->Branch("ppfjet_cluster_eta", &ppfjet_cluster_eta_); + pf_tree_->Branch("ppfjet_cluster_phi", &ppfjet_cluster_phi_); + pf_tree_->Branch("ppfjet_cluster_dR", &ppfjet_cluster_dR_); + pf_tree_->Branch("ppfjet_ncandtracks", &ppfjet_ncandtracks_, "ppfjet_ncandtracks/I"); + pf_tree_->Branch("ppfjet_candtrack_px", &ppfjet_candtrack_px_); + pf_tree_->Branch("ppfjet_candtrack_py", &ppfjet_candtrack_py_); + pf_tree_->Branch("ppfjet_candtrack_pz", &ppfjet_candtrack_pz_); + pf_tree_->Branch("ppfjet_candtrack_EcalE", &ppfjet_candtrack_EcalE_); // Subleading jet info - pf_tree_->Branch("pfjet2_pt",&pfjet2_pt_, "pfjet2_pt/F"); - pf_tree_->Branch("pfjet2_p",&pfjet2_p_, "pfjet2_p/F"); - pf_tree_->Branch("pfjet2_E",&pfjet2_E_, "pfjet2_E/F"); - pf_tree_->Branch("pfjet2_E_NPVcorr",&pfjet2_E_NPVcorr_, "pfjet2_E_NPVcorr/F"); - pf_tree_->Branch("pfjet2_area",&pfjet2_area_, "pfjet2_area/F"); - pf_tree_->Branch("pfjet2_eta",&pfjet2_eta_, "pfjet2_eta/F"); - pf_tree_->Branch("pfjet2_phi",&pfjet2_phi_, "pfjet2_phi/F"); - pf_tree_->Branch("pfjet2_scale",&pfjet2_scale_, "pfjet2_scale/F"); + pf_tree_->Branch("pfjet2_pt", &pfjet2_pt_, "pfjet2_pt/F"); + pf_tree_->Branch("pfjet2_p", &pfjet2_p_, "pfjet2_p/F"); + pf_tree_->Branch("pfjet2_E", &pfjet2_E_, "pfjet2_E/F"); + pf_tree_->Branch("pfjet2_E_NPVcorr", &pfjet2_E_NPVcorr_, "pfjet2_E_NPVcorr/F"); + pf_tree_->Branch("pfjet2_area", &pfjet2_area_, "pfjet2_area/F"); + pf_tree_->Branch("pfjet2_eta", &pfjet2_eta_, "pfjet2_eta/F"); + pf_tree_->Branch("pfjet2_phi", &pfjet2_phi_, "pfjet2_phi/F"); + pf_tree_->Branch("pfjet2_scale", &pfjet2_scale_, "pfjet2_scale/F"); pf_tree_->Branch("pfjet2_NeutralHadronFrac", &pfjet2_NeutralHadronFrac_, "pfjet2_NeutralHadronFrac/F"); pf_tree_->Branch("pfjet2_NeutralEMFrac", &pfjet2_NeutralEMFrac_, "pfjet2_NeutralEMFrac/F"); pf_tree_->Branch("pfjet2_nConstituents", &pfjet2_nConstituents_, "pfjet2_nConstituents/I"); pf_tree_->Branch("pfjet2_ChargedHadronFrac", &pfjet2_ChargedHadronFrac_, "pfjet2_ChargedHadronFrac/F"); pf_tree_->Branch("pfjet2_ChargedMultiplicity", &pfjet2_ChargedMultiplicity_, "pfjet2_ChargedMultiplicity/F"); pf_tree_->Branch("pfjet2_ChargedEMFrac", &pfjet2_ChargedEMFrac_, "pfjet2_ChargedEMFrac/F"); - if(doGenJets_){ - pf_tree_->Branch("pfjet2_genpt",&pfjet2_genpt_, "pfjet2_genpt/F"); - pf_tree_->Branch("pfjet2_genp",&pfjet2_genp_, "pfjet2_genp/F"); - pf_tree_->Branch("pfjet2_genE",&pfjet2_genE_, "pfjet2_genE/F"); - pf_tree_->Branch("pfjet2_gendr",&pfjet2_gendr_, "pfjet2_gendr/F"); + if (doGenJets_) { + pf_tree_->Branch("pfjet2_genpt", &pfjet2_genpt_, "pfjet2_genpt/F"); + pf_tree_->Branch("pfjet2_genp", &pfjet2_genp_, "pfjet2_genp/F"); + pf_tree_->Branch("pfjet2_genE", &pfjet2_genE_, "pfjet2_genE/F"); + pf_tree_->Branch("pfjet2_gendr", &pfjet2_gendr_, "pfjet2_gendr/F"); } - pf_tree_->Branch("pfjet2_unkown_E",&pfjet2_unkown_E_, "pfjet2_unkown_E/F"); - pf_tree_->Branch("pfjet2_electron_E",&pfjet2_electron_E_, "pfjet2_electron_E/F"); - pf_tree_->Branch("pfjet2_muon_E",&pfjet2_muon_E_, "pfjet2_muon_E/F"); - pf_tree_->Branch("pfjet2_photon_E",&pfjet2_photon_E_, "pfjet2_photon_E/F"); - pf_tree_->Branch("pfjet2_unkown_px",&pfjet2_unkown_px_, "pfjet2_unkown_px/F"); - pf_tree_->Branch("pfjet2_electron_px",&pfjet2_electron_px_, "pfjet2_electron_px/F"); - pf_tree_->Branch("pfjet2_muon_px",&pfjet2_muon_px_, "pfjet2_muon_px/F"); - pf_tree_->Branch("pfjet2_photon_px",&pfjet2_photon_px_, "pfjet2_photon_px/F"); - pf_tree_->Branch("pfjet2_unkown_py",&pfjet2_unkown_py_, "pfjet2_unkown_py/F"); - pf_tree_->Branch("pfjet2_electron_py",&pfjet2_electron_py_, "pfjet2_electron_py/F"); - pf_tree_->Branch("pfjet2_muon_py",&pfjet2_muon_py_, "pfjet2_muon_py/F"); - pf_tree_->Branch("pfjet2_photon_py",&pfjet2_photon_py_, "pfjet2_photon_py/F"); - pf_tree_->Branch("pfjet2_unkown_pz",&pfjet2_unkown_pz_, "pfjet2_unkown_pz/F"); - pf_tree_->Branch("pfjet2_electron_pz",&pfjet2_electron_pz_, "pfjet2_electron_pz/F"); - pf_tree_->Branch("pfjet2_muon_pz",&pfjet2_muon_pz_, "pfjet2_muon_pz/F"); - pf_tree_->Branch("pfjet2_photon_pz",&pfjet2_photon_pz_, "pfjet2_photon_pz/F"); - pf_tree_->Branch("pfjet2_unkown_EcalE",&pfjet2_unkown_EcalE_, "pfjet2_unkown_EcalE/F"); - pf_tree_->Branch("pfjet2_electron_EcalE",&pfjet2_electron_EcalE_, "pfjet2_electron_EcalE/F"); - pf_tree_->Branch("pfjet2_muon_EcalE",&pfjet2_muon_EcalE_, "pfjet2_muon_EcalE/F"); - pf_tree_->Branch("pfjet2_photon_EcalE",&pfjet2_photon_EcalE_, "pfjet2_photon_EcalE/F"); - pf_tree_->Branch("pfjet2_unkown_n",&pfjet2_unkown_n_, "pfjet2_unkown_n/I"); - pf_tree_->Branch("pfjet2_electron_n",&pfjet2_electron_n_, "pfjet2_electron_n/I"); - pf_tree_->Branch("pfjet2_muon_n",&pfjet2_muon_n_, "pfjet2_muon_n/I"); - pf_tree_->Branch("pfjet2_photon_n",&pfjet2_photon_n_, "pfjet2_photon_n/I"); - pf_tree_->Branch("pfjet2_had_n",&pfjet2_had_n_, "pfjet2_had_n/I"); - pf_tree_->Branch("pfjet2_had_E",&pfjet2_had_E_); - pf_tree_->Branch("pfjet2_had_px",&pfjet2_had_px_); - pf_tree_->Branch("pfjet2_had_py",&pfjet2_had_py_); - pf_tree_->Branch("pfjet2_had_pz",&pfjet2_had_pz_); - pf_tree_->Branch("pfjet2_had_EcalE",&pfjet2_had_EcalE_); - pf_tree_->Branch("pfjet2_had_rawHcalE",&pfjet2_had_rawHcalE_); - pf_tree_->Branch("pfjet2_had_emf",&pfjet2_had_emf_); - pf_tree_->Branch("pfjet2_had_id",&pfjet2_had_id_); - pf_tree_->Branch("pfjet2_had_candtrackind",&pfjet2_had_candtrackind_); - if(doGenJets_){ - pf_tree_->Branch("pfjet2_had_E_mctruth",&pfjet2_had_E_mctruth_); - pf_tree_->Branch("pfjet2_had_mcpdgId",&pfjet2_had_mcpdgId_); + pf_tree_->Branch("pfjet2_unkown_E", &pfjet2_unkown_E_, "pfjet2_unkown_E/F"); + pf_tree_->Branch("pfjet2_electron_E", &pfjet2_electron_E_, "pfjet2_electron_E/F"); + pf_tree_->Branch("pfjet2_muon_E", &pfjet2_muon_E_, "pfjet2_muon_E/F"); + pf_tree_->Branch("pfjet2_photon_E", &pfjet2_photon_E_, "pfjet2_photon_E/F"); + pf_tree_->Branch("pfjet2_unkown_px", &pfjet2_unkown_px_, "pfjet2_unkown_px/F"); + pf_tree_->Branch("pfjet2_electron_px", &pfjet2_electron_px_, "pfjet2_electron_px/F"); + pf_tree_->Branch("pfjet2_muon_px", &pfjet2_muon_px_, "pfjet2_muon_px/F"); + pf_tree_->Branch("pfjet2_photon_px", &pfjet2_photon_px_, "pfjet2_photon_px/F"); + pf_tree_->Branch("pfjet2_unkown_py", &pfjet2_unkown_py_, "pfjet2_unkown_py/F"); + pf_tree_->Branch("pfjet2_electron_py", &pfjet2_electron_py_, "pfjet2_electron_py/F"); + pf_tree_->Branch("pfjet2_muon_py", &pfjet2_muon_py_, "pfjet2_muon_py/F"); + pf_tree_->Branch("pfjet2_photon_py", &pfjet2_photon_py_, "pfjet2_photon_py/F"); + pf_tree_->Branch("pfjet2_unkown_pz", &pfjet2_unkown_pz_, "pfjet2_unkown_pz/F"); + pf_tree_->Branch("pfjet2_electron_pz", &pfjet2_electron_pz_, "pfjet2_electron_pz/F"); + pf_tree_->Branch("pfjet2_muon_pz", &pfjet2_muon_pz_, "pfjet2_muon_pz/F"); + pf_tree_->Branch("pfjet2_photon_pz", &pfjet2_photon_pz_, "pfjet2_photon_pz/F"); + pf_tree_->Branch("pfjet2_unkown_EcalE", &pfjet2_unkown_EcalE_, "pfjet2_unkown_EcalE/F"); + pf_tree_->Branch("pfjet2_electron_EcalE", &pfjet2_electron_EcalE_, "pfjet2_electron_EcalE/F"); + pf_tree_->Branch("pfjet2_muon_EcalE", &pfjet2_muon_EcalE_, "pfjet2_muon_EcalE/F"); + pf_tree_->Branch("pfjet2_photon_EcalE", &pfjet2_photon_EcalE_, "pfjet2_photon_EcalE/F"); + pf_tree_->Branch("pfjet2_unkown_n", &pfjet2_unkown_n_, "pfjet2_unkown_n/I"); + pf_tree_->Branch("pfjet2_electron_n", &pfjet2_electron_n_, "pfjet2_electron_n/I"); + pf_tree_->Branch("pfjet2_muon_n", &pfjet2_muon_n_, "pfjet2_muon_n/I"); + pf_tree_->Branch("pfjet2_photon_n", &pfjet2_photon_n_, "pfjet2_photon_n/I"); + pf_tree_->Branch("pfjet2_had_n", &pfjet2_had_n_, "pfjet2_had_n/I"); + pf_tree_->Branch("pfjet2_had_E", &pfjet2_had_E_); + pf_tree_->Branch("pfjet2_had_px", &pfjet2_had_px_); + pf_tree_->Branch("pfjet2_had_py", &pfjet2_had_py_); + pf_tree_->Branch("pfjet2_had_pz", &pfjet2_had_pz_); + pf_tree_->Branch("pfjet2_had_EcalE", &pfjet2_had_EcalE_); + pf_tree_->Branch("pfjet2_had_rawHcalE", &pfjet2_had_rawHcalE_); + pf_tree_->Branch("pfjet2_had_emf", &pfjet2_had_emf_); + pf_tree_->Branch("pfjet2_had_id", &pfjet2_had_id_); + pf_tree_->Branch("pfjet2_had_candtrackind", &pfjet2_had_candtrackind_); + if (doGenJets_) { + pf_tree_->Branch("pfjet2_had_E_mctruth", &pfjet2_had_E_mctruth_); + pf_tree_->Branch("pfjet2_had_mcpdgId", &pfjet2_had_mcpdgId_); } - pf_tree_->Branch("pfjet2_had_ntwrs",&pfjet2_had_ntwrs_); - pf_tree_->Branch("pfjet2_ntwrs",&pfjet2_ntwrs_, "pfjet2_ntwrs/I"); - pf_tree_->Branch("pfjet2_twr_ieta",&pfjet2_twr_ieta_); - pf_tree_->Branch("pfjet2_twr_iphi",&pfjet2_twr_iphi_); - pf_tree_->Branch("pfjet2_twr_depth",&pfjet2_twr_depth_); - pf_tree_->Branch("pfjet2_twr_subdet",&pfjet2_twr_subdet_); - pf_tree_->Branch("pfjet2_twr_hade",&pfjet2_twr_hade_); - pf_tree_->Branch("pfjet2_twr_frac",&pfjet2_twr_frac_); - pf_tree_->Branch("pfjet2_twr_candtrackind",&pfjet2_twr_candtrackind_); - pf_tree_->Branch("pfjet2_twr_hadind",&pfjet2_twr_hadind_); - pf_tree_->Branch("pfjet2_twr_elmttype",&pfjet2_twr_elmttype_); - pf_tree_->Branch("pfjet2_twr_dR",&pfjet2_twr_dR_); - pf_tree_->Branch("pfjet2_twr_clusterind",&pfjet2_twr_clusterind_); - pf_tree_->Branch("pfjet2_cluster_n",&pfjet2_cluster_n_, "pfjet2_cluster_n/I"); - pf_tree_->Branch("pfjet2_cluster_eta",&pfjet2_cluster_eta_); - pf_tree_->Branch("pfjet2_cluster_phi",&pfjet2_cluster_phi_); - pf_tree_->Branch("pfjet2_cluster_dR",&pfjet2_cluster_dR_); - pf_tree_->Branch("pfjet2_ncandtracks",&pfjet2_ncandtracks_, "pfjet2_ncandtracks/I"); - pf_tree_->Branch("pfjet2_candtrack_px",&pfjet2_candtrack_px_); - pf_tree_->Branch("pfjet2_candtrack_py",&pfjet2_candtrack_py_); - pf_tree_->Branch("pfjet2_candtrack_pz",&pfjet2_candtrack_pz_); - pf_tree_->Branch("pfjet2_candtrack_EcalE",&pfjet2_candtrack_EcalE_); + pf_tree_->Branch("pfjet2_had_ntwrs", &pfjet2_had_ntwrs_); + pf_tree_->Branch("pfjet2_ntwrs", &pfjet2_ntwrs_, "pfjet2_ntwrs/I"); + pf_tree_->Branch("pfjet2_twr_ieta", &pfjet2_twr_ieta_); + pf_tree_->Branch("pfjet2_twr_iphi", &pfjet2_twr_iphi_); + pf_tree_->Branch("pfjet2_twr_depth", &pfjet2_twr_depth_); + pf_tree_->Branch("pfjet2_twr_subdet", &pfjet2_twr_subdet_); + pf_tree_->Branch("pfjet2_twr_hade", &pfjet2_twr_hade_); + pf_tree_->Branch("pfjet2_twr_frac", &pfjet2_twr_frac_); + pf_tree_->Branch("pfjet2_twr_candtrackind", &pfjet2_twr_candtrackind_); + pf_tree_->Branch("pfjet2_twr_hadind", &pfjet2_twr_hadind_); + pf_tree_->Branch("pfjet2_twr_elmttype", &pfjet2_twr_elmttype_); + pf_tree_->Branch("pfjet2_twr_dR", &pfjet2_twr_dR_); + pf_tree_->Branch("pfjet2_twr_clusterind", &pfjet2_twr_clusterind_); + pf_tree_->Branch("pfjet2_cluster_n", &pfjet2_cluster_n_, "pfjet2_cluster_n/I"); + pf_tree_->Branch("pfjet2_cluster_eta", &pfjet2_cluster_eta_); + pf_tree_->Branch("pfjet2_cluster_phi", &pfjet2_cluster_phi_); + pf_tree_->Branch("pfjet2_cluster_dR", &pfjet2_cluster_dR_); + pf_tree_->Branch("pfjet2_ncandtracks", &pfjet2_ncandtracks_, "pfjet2_ncandtracks/I"); + pf_tree_->Branch("pfjet2_candtrack_px", &pfjet2_candtrack_px_); + pf_tree_->Branch("pfjet2_candtrack_py", &pfjet2_candtrack_py_); + pf_tree_->Branch("pfjet2_candtrack_pz", &pfjet2_candtrack_pz_); + pf_tree_->Branch("pfjet2_candtrack_EcalE", &pfjet2_candtrack_EcalE_); // third pf jet pf_tree_->Branch("pf_thirdjet_et", &pf_thirdjet_et_, "pf_thirdjet_et/F"); @@ -1520,18 +1655,17 @@ void GammaJetAnalysis::beginJob() pf_tree_->Branch("metType1_value", &metType1_value_, "metType1_value/F"); pf_tree_->Branch("metType1_phi", &metType1_phi_, "metType1_phi/F"); pf_tree_->Branch("metType1_sumEt", &metType1_sumEt_, "metType1_sumEt/F"); - pf_tree_->Branch("pf_NPV",&pf_NPV_, "pf_NPV/I"); + pf_tree_->Branch("pf_NPV", &pf_NPV_, "pf_NPV/I"); } return; -} +} // ------------ method called once each job just after ending the event loop ------------ -void -GammaJetAnalysis::endJob() { +void GammaJetAnalysis::endJob() { rootfile_->cd(); - if(doPFJets_){ + if (doPFJets_) { pf_tree_->Write(); } // write miscItems @@ -1540,19 +1674,20 @@ GammaJetAnalysis::endJob() { rootfile_->cd(); rootfile_->mkdir("miscItems"); rootfile_->cd("miscItems"); - misc_tree_= new TTree("misc_tree","tree for misc.info"); - misc_tree_->Branch("ignoreHLT",&ignoreHLT_,"ignoreHLT/O"); - misc_tree_->Branch("doPFJets",&doPFJets_,"doPFJets/O"); - misc_tree_->Branch("doGenJets",&doGenJets_,"doGenJets/O"); - misc_tree_->Branch("workOnAOD",&workOnAOD_,"workOnAOD/O"); - misc_tree_->Branch("photonTriggerNames",&photonTrigNamesV_); - misc_tree_->Branch("jetTriggerNames",&jetTrigNamesV_); - misc_tree_->Branch("nProcessed",&nProcessed_,"nProcessed/l"); + misc_tree_ = new TTree("misc_tree", "tree for misc.info"); + misc_tree_->Branch("ignoreHLT", &ignoreHLT_, "ignoreHLT/O"); + misc_tree_->Branch("doPFJets", &doPFJets_, "doPFJets/O"); + misc_tree_->Branch("doGenJets", &doGenJets_, "doGenJets/O"); + misc_tree_->Branch("workOnAOD", &workOnAOD_, "workOnAOD/O"); + misc_tree_->Branch("photonTriggerNames", &photonTrigNamesV_); + misc_tree_->Branch("jetTriggerNames", &jetTrigNamesV_); + misc_tree_->Branch("nProcessed", &nProcessed_, "nProcessed/l"); // put time stamp time_t ltime; - ltime=time(NULL); + ltime = time(NULL); TString str = TString(asctime(localtime(<ime))); - if (str[str.Length()-1]=='\n') str.Remove(str.Length()-1,1); + if (str[str.Length() - 1] == '\n') + str.Remove(str.Length() - 1, 1); TObjString date(str); date.Write(str.Data()); misc_tree_->Fill(); @@ -1563,25 +1698,23 @@ GammaJetAnalysis::endJob() { rootfile_->Close(); } - // --------------------------------------------------------------------- -void GammaJetAnalysis::beginRun(const edm::Run &iRun, - const edm::EventSetup &setup) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "beginRun()"; +void GammaJetAnalysis::beginRun(const edm::Run& iRun, const edm::EventSetup& setup) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "beginRun()"; if (!ignoreHLT_) { - int noPhotonTrigger= (photonTrigNamesV_.size()==0) ? 1:0; - int noJetTrigger= (jetTrigNamesV_.size()==0) ? 1:0; - if (!noPhotonTrigger && - (photonTrigNamesV_.size()==1) && - (photonTrigNamesV_[0].length()==0)) noPhotonTrigger=1; - if (!noJetTrigger && - (jetTrigNamesV_.size()==1) && - (jetTrigNamesV_[0].length()==0)) noJetTrigger=1; + int noPhotonTrigger = (photonTrigNamesV_.size() == 0) ? 1 : 0; + int noJetTrigger = (jetTrigNamesV_.size() == 0) ? 1 : 0; + if (!noPhotonTrigger && (photonTrigNamesV_.size() == 1) && (photonTrigNamesV_[0].length() == 0)) + noPhotonTrigger = 1; + if (!noJetTrigger && (jetTrigNamesV_.size() == 1) && (jetTrigNamesV_[0].length() == 0)) + noJetTrigger = 1; if (noPhotonTrigger && noJetTrigger) { - ignoreHLT_=true; - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "HLT trigger ignored: no trigger requested"; + ignoreHLT_ = true; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "HLT trigger ignored: no trigger requested"; } } else { // clear trigger names, if needed @@ -1590,21 +1723,21 @@ void GammaJetAnalysis::beginRun(const edm::Run &iRun, } if (!ignoreHLT_) { - if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "Initializing trigger information for individual run"; + if (debug_ > 0) + edm::LogInfo("GammaJetAnalysis") << "Initializing trigger information for individual run"; bool changed(true); - std::string processName="HLT"; - if (hltPrescaleProvider_.init(iRun,setup,processName,changed)) { + std::string processName = "HLT"; + if (hltPrescaleProvider_.init(iRun, setup, processName, changed)) { // if init returns TRUE, initialisation has succeeded! if (changed) { - // The HLT config has actually changed wrt the previous Run, hence rebook your - // histograms or do anything else dependent on the revised HLT config + // The HLT config has actually changed wrt the previous Run, hence rebook your + // histograms or do anything else dependent on the revised HLT config } - } - else { + } else { // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem // with the file and/or code and needs to be investigated! throw edm::Exception(edm::errors::ProductNotFound) - << " HLT config extraction failure with process name " << processName; + << " HLT config extraction failure with process name " << processName; // In this case, all access methods will return empty values! } } @@ -1614,8 +1747,18 @@ void GammaJetAnalysis::beginRun(const edm::Run &iRun, // helper function -float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, edm::Handle pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfEcalIso"; +float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, + edm::Handle pfHandle, + float dRmax, + float dRVetoBarrel, + float dRVetoEndcap, + float etaStripBarrel, + float etaStripEndcap, + float energyBarrel, + float energyEndcap, + reco::PFCandidate::ParticleType pfToUse) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "Inside pfEcalIso"; reco::Photon* localPho = localPho1->clone(); float dRVeto; float etaStrip; @@ -1630,11 +1773,11 @@ float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, edm::Handlesize(); float sum = 0; - for (int i=0; isuperCluster().isNonnull()) { + if (pfc.particleId() == pfToUse) { + // Do not include the PFCandidate associated by SC Ref to the reco::Photon + if (pfc.superClusterRef().isNonnull() && localPho->superCluster().isNonnull()) { if (pfc.superClusterRef() == localPho->superCluster()) continue; } @@ -1646,19 +1789,20 @@ float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, edm::HandlesuperCluster()->x() - pfvtx.x(), localPho->superCluster()->y() - pfvtx.y(), localPho->superCluster()->z() - pfvtx.z()); float dEta = fabs(photon_directionWrtVtx.Eta() - pfc.momentum().Eta()); - float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + float dR = deltaR( + photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); if (dEta < etaStrip) continue; - if(dR > dRmax || dR < dRVeto) + if (dR > dRmax || dR < dRVeto) continue; sum += pfc.pt(); @@ -1669,17 +1813,30 @@ float GammaJetAnalysis::pfEcalIso(const reco::Photon* localPho1, edm::Handle pfHandle,float dRmax, float dRveto,reco::PFCandidate::ParticleType pfToUse) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfHcalIso"; +float GammaJetAnalysis::pfHcalIso(const reco::Photon* localPho, + edm::Handle pfHandle, + float dRmax, + float dRveto, + reco::PFCandidate::ParticleType pfToUse) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "Inside pfHcalIso"; return pfEcalIso(localPho, pfHandle, dRmax, dRveto, dRveto, 0.0, 0.0, 0.0, 0.0, pfToUse); - } // --------------------------------------------------------------------- -std::vector GammaJetAnalysis::pfTkIsoWithVertex(const reco::Photon* localPho1, edm::Handle pfHandle, edm::Handle vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse) { - - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Inside pfTkIsoWithVertex()"; +std::vector GammaJetAnalysis::pfTkIsoWithVertex(const reco::Photon* localPho1, + edm::Handle pfHandle, + edm::Handle vtxHandle, + float dRmax, + float dRvetoBarrel, + float dRvetoEndcap, + float ptMin, + float dzMax, + float dxyMax, + reco::PFCandidate::ParticleType pfToUse) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "Inside pfTkIsoWithVertex()"; reco::Photon* localPho = localPho1->clone(); float dRveto; @@ -1692,50 +1849,61 @@ std::vector GammaJetAnalysis::pfTkIsoWithVertex(const reco::Photon* local const reco::PFCandidateCollection* forIsolation = pfHandle.product(); //Calculate isolation sum separately for each vertex - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "vtxHandle->size() = " << vtxHandle->size(); - for(unsigned int ivtx=0; ivtx<(vtxHandle->size()); ++ivtx) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "Vtx " << ivtx; - // Shift the photon according to the vertex + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "vtxHandle->size() = " << vtxHandle->size(); + for (unsigned int ivtx = 0; ivtx < (vtxHandle->size()); ++ivtx) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "Vtx " << ivtx; + // Shift the photon according to the vertex reco::VertexRef vtx(vtxHandle, ivtx); math::XYZVector photon_directionWrtVtx(localPho->superCluster()->x() - vtx->x(), localPho->superCluster()->y() - vtx->y(), localPho->superCluster()->z() - vtx->z()); - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "pfTkIsoWithVertex :: Will Loop over the PFCandidates"; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "pfTkIsoWithVertex :: Will Loop over the PFCandidates"; float sum = 0; - // Loop over the PFCandidates - for(unsigned i=0; isize(); i++) { - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "inside loop"; + // Loop over the PFCandidates + for (unsigned i = 0; i < forIsolation->size(); i++) { + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "inside loop"; const reco::PFCandidate& pfc = (*forIsolation)[i]; //require that PFCandidate is a charged hadron - if (debug_>1) { - edm::LogInfo("GammaJetAnalysis") << "pfToUse=" << pfToUse; - edm::LogInfo("GammaJetAnalysis") << "pfc.particleId()=" << pfc.particleId(); + if (debug_ > 1) { + edm::LogInfo("GammaJetAnalysis") << "pfToUse=" << pfToUse; + edm::LogInfo("GammaJetAnalysis") << "pfc.particleId()=" << pfc.particleId(); } - + if (pfc.particleId() == pfToUse) { - if (debug_>1) { - edm::LogInfo("GammaJetAnalysis") << "\n ***** HERE pfc.particleId() == pfToUse "; - edm::LogInfo("GammaJetAnalysis") << "pfc.pt()=" << pfc.pt(); - } - if (pfc.pt() < ptMin) continue; - + if (debug_ > 1) { + edm::LogInfo("GammaJetAnalysis") << "\n ***** HERE pfc.particleId() == pfToUse "; + edm::LogInfo("GammaJetAnalysis") << "pfc.pt()=" << pfc.pt(); + } + if (pfc.pt() < ptMin) + continue; + float dz = fabs(pfc.trackRef()->dz(vtx->position())); - if (dz > dzMax) continue; - + if (dz > dzMax) + continue; + float dxy = fabs(pfc.trackRef()->dxy(vtx->position())); - if(fabs(dxy) > dxyMax) continue; - float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); - if(dR > dRmax || dR < dRveto) continue; + if (fabs(dxy) > dxyMax) + continue; + float dR = deltaR( + photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi()); + if (dR > dRmax || dR < dRveto) + continue; sum += pfc.pt(); - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "pt=" << pfc.pt(); + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "pt=" << pfc.pt(); } } - if (debug_>1) edm::LogInfo("GammaJetAnalysis") << "sum=" << sum; - sum = sum*1.0; + if (debug_ > 1) + edm::LogInfo("GammaJetAnalysis") << "sum=" << sum; + sum = sum * 1.0; result.push_back(sum); } - if (debug_>1) { + if (debug_ > 1) { edm::LogInfo("GammaJetAnalysis") << "Will return result"; edm::LogInfo("GammaJetAnalysis") << "result" << &result; edm::LogInfo("GammaJetAnalysis") << "Result returned"; @@ -1795,7 +1963,6 @@ void GammaJetAnalysis::clear_leadingPfJetVars() { ppfjet_candtrack_py_.clear(); ppfjet_candtrack_pz_.clear(); ppfjet_candtrack_EcalE_.clear(); - } // --------------------------------------------------------------------- @@ -1893,22 +2060,22 @@ void GammaJetAnalysis::copy_leadingPfJetVars_to_pfJet2() { // --------------------------------------------------------------------- -double GammaJetAnalysis::deltaR(const reco::Jet* j1, const reco::Jet* j2) -{ - double deta = j1->eta()-j2->eta(); - double dphi = std::fabs(j1->phi()-j2->phi()); - if(dphi>3.1415927) dphi = 2*3.1415927 - dphi; - return std::sqrt(deta*deta + dphi*dphi); +double GammaJetAnalysis::deltaR(const reco::Jet* j1, const reco::Jet* j2) { + double deta = j1->eta() - j2->eta(); + double dphi = std::fabs(j1->phi() - j2->phi()); + if (dphi > 3.1415927) + dphi = 2 * 3.1415927 - dphi; + return std::sqrt(deta * deta + dphi * dphi); } // --------------------------------------------------------------------- -double GammaJetAnalysis::deltaR(const double eta1, const double phi1, const double eta2, const double phi2) -{ +double GammaJetAnalysis::deltaR(const double eta1, const double phi1, const double eta2, const double phi2) { double deta = eta1 - eta2; double dphi = std::fabs(phi1 - phi2); - if(dphi>3.1415927) dphi = 2*3.1415927 - dphi; - return std::sqrt(deta*deta + dphi*dphi); + if (dphi > 3.1415927) + dphi = 2 * 3.1415927 - dphi; + return std::sqrt(deta * deta + dphi * dphi); } // --------------------------------------------------------------------- @@ -1926,21 +2093,18 @@ double GammaJetAnalysis::deltaR(const double eta1, const double phi1, const doub // --------------------------------------------------------------------- -int GammaJetAnalysis::getEtaPhi(const DetId id) -{ - return id.rawId() & 0x3FFF; // Get 14 least-significant digits +int GammaJetAnalysis::getEtaPhi(const DetId id) { + return id.rawId() & 0x3FFF; // Get 14 least-significant digits } // --------------------------------------------------------------------- -int GammaJetAnalysis::getEtaPhi(const HcalDetId id) -{ - return id.rawId() & 0x3FFF; // Get 14 least-significant digits +int GammaJetAnalysis::getEtaPhi(const HcalDetId id) { + return id.rawId() & 0x3FFF; // Get 14 least-significant digits } // --------------------------------------------------------------------- - //define this as a plug-in DEFINE_FWK_MODULE(GammaJetAnalysis); diff --git a/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.h b/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.h index b232d08eadbe8..857be47739b0d 100644 --- a/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.h +++ b/Calibration/HcalCalibAlgos/test/GammaJetAnalysis.h @@ -63,53 +63,63 @@ class TTree; // class PhotonPair : protected std::pair { - public: PhotonPair() { - first=0; - second=0.0; - fIdx=-1; + first = 0; + second = 0.0; + fIdx = -1; } - PhotonPair(const reco::Photon* ph, double pt, int setIdx=-1) { - first=ph; - second=pt; - fIdx=setIdx; + PhotonPair(const reco::Photon* ph, double pt, int setIdx = -1) { + first = ph; + second = pt; + fIdx = setIdx; } ~PhotonPair() {} inline const reco::Photon* photon(void) const { return first; } - inline void photon(const reco::Photon* ph) { first=ph; return; } + inline void photon(const reco::Photon* ph) { + first = ph; + return; + } inline double pt(void) const { return second; } - inline void pt(double d) { second=d; return; } - void idx(int set_idx) { fIdx=set_idx; }; + inline void pt(double d) { + second = d; + return; + } + void idx(int set_idx) { fIdx = set_idx; }; int idx() const { return fIdx; } - bool isValid() const { return (first!=NULL) ? true:false; } + bool isValid() const { return (first != NULL) ? true : false; } private: - int fIdx; // index in the photon collection + int fIdx; // index in the photon collection }; class PFJetCorretPair : protected std::pair { public: PFJetCorretPair() { - first=0; - second=1.0; + first = 0; + second = 1.0; } PFJetCorretPair(const reco::PFJet* j, double s) { - first=j; - second=s; + first = j; + second = s; } ~PFJetCorretPair() {} inline const reco::PFJet* jet(void) const { return first; } - inline void jet(const reco::PFJet* j) { first=j; return; } + inline void jet(const reco::PFJet* j) { + first = j; + return; + } inline double scale(void) const { return second; } - inline void scale(double d) { second=d; return; } + inline void scale(double d) { + second = d; + return; + } double scaledEt() const { return first->et() * second; } - bool isValid() const { return (first!=NULL) ? true:false; } + bool isValid() const { return (first != NULL) ? true : false; } private: - }; // -------------------------------------------- @@ -121,82 +131,103 @@ class GammaJetAnalysis : public edm::EDAnalyzer { explicit GammaJetAnalysis(const edm::ParameterSet&); ~GammaJetAnalysis(); - float pfEcalIso(const reco::Photon* localPho1, edm::Handle pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse); - - float pfHcalIso(const reco::Photon* localPho,edm::Handle pfHandle,float dRmax, float dRveto,reco::PFCandidate::ParticleType pfToUse); - - std::vector pfTkIsoWithVertex(const reco::Photon* localPho1, edm::Handle pfHandle, edm::Handle vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse); + float pfEcalIso(const reco::Photon* localPho1, + edm::Handle pfHandle, + float dRmax, + float dRVetoBarrel, + float dRVetoEndcap, + float etaStripBarrel, + float etaStripEndcap, + float energyBarrel, + float energyEndcap, + reco::PFCandidate::ParticleType pfToUse); + + float pfHcalIso(const reco::Photon* localPho, + edm::Handle pfHandle, + float dRmax, + float dRveto, + reco::PFCandidate::ParticleType pfToUse); + + std::vector pfTkIsoWithVertex(const reco::Photon* localPho1, + edm::Handle pfHandle, + edm::Handle vtxHandle, + float dRmax, + float dRvetoBarrel, + float dRvetoEndcap, + float ptMin, + float dzMax, + float dxyMax, + reco::PFCandidate::ParticleType pfToUse); private: - virtual void beginJob();//(const edm::EventSetup&); + virtual void beginJob(); //(const edm::EventSetup&); virtual void analyze(const edm::Event&, const edm::EventSetup&); virtual void endJob(); void beginRun(const edm::Run&, const edm::EventSetup&); - // parameters - int debug_; // print debug statements + int debug_; // print debug statements unsigned int debugEvent; int debugHLTTrigNames; edm::InputTag rhoCollection_; - edm::InputTag pfType1METColl, pfMETColl ; - - std::string photonCollName_; // label for the photon collection - std::string pfJetCollName_; // label for the PF jet collection - std::string pfJetCorrName_; // label for the PF jet correction service - std::string genJetCollName_; // label for the genjet collection - std::string genParticleCollName_; // label for the genparticle collection - std::string genEventInfoName_; // label for the generator event info collection - std::string hbheRecHitName_; // label for HBHERecHits collection - std::string hfRecHitName_; // label for HFRecHit collection - std::string hoRecHitName_; // label for HORecHit collection - std::string rootHistFilename_; // name of the histogram file - std::string pvCollName_; // label for primary vertex collection - std::string prodProcess_; // the producer process for AOD=2 - - bool allowNoPhoton_; // whether module is used for dijet analysis - double photonPtMin_; // lowest value of the leading photon pT - double photonJetDPhiMin_; // phi angle between the leading photon and the leading jet - double jetEtMin_; // lowest value of the leading jet ET - double jet2EtMax_; // largest value of the subleading jet ET - double jet3EtMax_; // largest value of the third jet ET - std::vector photonTrigNamesV_; // photon trigger names - std::vector jetTrigNamesV_; // jet trigger names - bool writeTriggerPrescale_; // whether attempt to record the prescale + edm::InputTag pfType1METColl, pfMETColl; + + std::string photonCollName_; // label for the photon collection + std::string pfJetCollName_; // label for the PF jet collection + std::string pfJetCorrName_; // label for the PF jet correction service + std::string genJetCollName_; // label for the genjet collection + std::string genParticleCollName_; // label for the genparticle collection + std::string genEventInfoName_; // label for the generator event info collection + std::string hbheRecHitName_; // label for HBHERecHits collection + std::string hfRecHitName_; // label for HFRecHit collection + std::string hoRecHitName_; // label for HORecHit collection + std::string rootHistFilename_; // name of the histogram file + std::string pvCollName_; // label for primary vertex collection + std::string prodProcess_; // the producer process for AOD=2 + + bool allowNoPhoton_; // whether module is used for dijet analysis + double photonPtMin_; // lowest value of the leading photon pT + double photonJetDPhiMin_; // phi angle between the leading photon and the leading jet + double jetEtMin_; // lowest value of the leading jet ET + double jet2EtMax_; // largest value of the subleading jet ET + double jet3EtMax_; // largest value of the third jet ET + std::vector photonTrigNamesV_; // photon trigger names + std::vector jetTrigNamesV_; // jet trigger names + bool writeTriggerPrescale_; // whether attempt to record the prescale //Tokens - edm::EDGetTokenT tok_Photon_; - edm::EDGetTokenT tok_PFJet_; - edm::EDGetTokenT > tok_GenJet_; + edm::EDGetTokenT tok_Photon_; + edm::EDGetTokenT tok_PFJet_; + edm::EDGetTokenT > tok_GenJet_; edm::EDGetTokenT > tok_GenPart_; - edm::EDGetTokenT tok_GenEvInfo_; - edm::EDGetTokenT > > tok_HBHE_; - edm::EDGetTokenT > > tok_HF_; - edm::EDGetTokenT > > tok_HO_; - edm::EDGetTokenT > tok_loosePhoton_; - edm::EDGetTokenT > tok_tightPhoton_; - edm::EDGetTokenT > tok_loosePhotonV_; - edm::EDGetTokenT > tok_tightPhotonV_; - edm::EDGetTokenT tok_PFCand_; - edm::EDGetTokenT tok_Vertex_; - edm::EDGetTokenT tok_GsfElec_; - edm::EDGetTokenT tok_Rho_; - edm::EDGetTokenT tok_Conv_; - edm::EDGetTokenT tok_BS_; - edm::EDGetTokenT > tok_PV_; - edm::EDGetTokenT tok_PFMET_; - edm::EDGetTokenT tok_PFType1MET_; - edm::EDGetTokenT tok_TrigRes_; - bool doPFJets_; // use PFJets - bool doGenJets_; // use GenJets - int workOnAOD_; + edm::EDGetTokenT tok_GenEvInfo_; + edm::EDGetTokenT > > tok_HBHE_; + edm::EDGetTokenT > > tok_HF_; + edm::EDGetTokenT > > tok_HO_; + edm::EDGetTokenT > tok_loosePhoton_; + edm::EDGetTokenT > tok_tightPhoton_; + edm::EDGetTokenT > tok_loosePhotonV_; + edm::EDGetTokenT > tok_tightPhotonV_; + edm::EDGetTokenT tok_PFCand_; + edm::EDGetTokenT tok_Vertex_; + edm::EDGetTokenT tok_GsfElec_; + edm::EDGetTokenT tok_Rho_; + edm::EDGetTokenT tok_Conv_; + edm::EDGetTokenT tok_BS_; + edm::EDGetTokenT > tok_PV_; + edm::EDGetTokenT tok_PFMET_; + edm::EDGetTokenT tok_PFType1MET_; + edm::EDGetTokenT tok_TrigRes_; + bool doPFJets_; // use PFJets + bool doGenJets_; // use GenJets + int workOnAOD_; bool ignoreHLT_; // root file/histograms TFile* rootfile_; - TTree* misc_tree_; // misc.information. Will be filled only once + TTree* misc_tree_; // misc.information. Will be filled only once TTree* calo_tree_; TTree* pf_tree_; @@ -215,16 +246,17 @@ class GammaJetAnalysis : public edm::EDAnalyzer { ULong64_t nProcessed_; int pf_NPV_; - /// MET info - float met_value_, met_phi_, met_sumEt_ ; - float metType1_value_, metType1_phi_, metType1_sumEt_ ; + /// MET info + float met_value_, met_phi_, met_sumEt_; + float metType1_value_, metType1_phi_, metType1_sumEt_; // photon info float rho2012_; float tagPho_pt_, pho_2nd_pt_, tagPho_energy_, tagPho_eta_, tagPho_phi_, tagPho_sieie_; - float tagPho_HoE_, tagPho_r9_, tagPho_EcalIsoDR04_, tagPho_HcalIsoDR04_, tagPho_HcalIsoDR0412_, tagPho_TrkIsoHollowDR04_, tagPho_pfiso_myphoton03_; + float tagPho_HoE_, tagPho_r9_, tagPho_EcalIsoDR04_, tagPho_HcalIsoDR04_, tagPho_HcalIsoDR0412_, + tagPho_TrkIsoHollowDR04_, tagPho_pfiso_myphoton03_; float tagPho_pfiso_myneutral03_; - std::vector > tagPho_pfiso_mycharged03 ; + std::vector > tagPho_pfiso_mycharged03; int tagPho_pixelSeed_; int tagPho_ConvSafeEleVeto_; int tagPho_idTight_, tagPho_idLoose_; @@ -245,10 +277,12 @@ class GammaJetAnalysis : public edm::EDAnalyzer { float ppfjet_photon_E_, ppfjet_photon_px_, ppfjet_photon_py_, ppfjet_photon_pz_, ppfjet_photon_EcalE_; int ppfjet_unkown_n_, ppfjet_electron_n_, ppfjet_muon_n_, ppfjet_photon_n_; int ppfjet_had_n_; - std::vector ppfjet_had_E_, ppfjet_had_px_, ppfjet_had_py_, ppfjet_had_pz_, ppfjet_had_EcalE_, ppfjet_had_rawHcalE_, ppfjet_had_emf_, ppfjet_had_E_mctruth_; + std::vector ppfjet_had_E_, ppfjet_had_px_, ppfjet_had_py_, ppfjet_had_pz_, ppfjet_had_EcalE_, + ppfjet_had_rawHcalE_, ppfjet_had_emf_, ppfjet_had_E_mctruth_; std::vector ppfjet_had_id_, ppfjet_had_candtrackind_, ppfjet_had_mcpdgId_, ppfjet_had_ntwrs_; int ppfjet_ntwrs_; - std::vector ppfjet_twr_ieta_, ppfjet_twr_iphi_, ppfjet_twr_depth_, ppfjet_twr_subdet_, ppfjet_twr_candtrackind_, ppfjet_twr_hadind_, ppfjet_twr_elmttype_, ppfjet_twr_clusterind_; + std::vector ppfjet_twr_ieta_, ppfjet_twr_iphi_, ppfjet_twr_depth_, ppfjet_twr_subdet_, ppfjet_twr_candtrackind_, + ppfjet_twr_hadind_, ppfjet_twr_elmttype_, ppfjet_twr_clusterind_; std::vector ppfjet_twr_hade_, ppfjet_twr_frac_, ppfjet_twr_dR_; int ppfjet_cluster_n_; std::vector ppfjet_cluster_eta_, ppfjet_cluster_phi_, ppfjet_cluster_dR_; @@ -268,10 +302,12 @@ class GammaJetAnalysis : public edm::EDAnalyzer { float pfjet2_photon_E_, pfjet2_photon_px_, pfjet2_photon_py_, pfjet2_photon_pz_, pfjet2_photon_EcalE_; int pfjet2_unkown_n_, pfjet2_electron_n_, pfjet2_muon_n_, pfjet2_photon_n_; int pfjet2_had_n_; - std::vector pfjet2_had_E_, pfjet2_had_px_, pfjet2_had_py_, pfjet2_had_pz_, pfjet2_had_EcalE_, pfjet2_had_rawHcalE_, pfjet2_had_emf_, pfjet2_had_E_mctruth_; + std::vector pfjet2_had_E_, pfjet2_had_px_, pfjet2_had_py_, pfjet2_had_pz_, pfjet2_had_EcalE_, + pfjet2_had_rawHcalE_, pfjet2_had_emf_, pfjet2_had_E_mctruth_; std::vector pfjet2_had_id_, pfjet2_had_candtrackind_, pfjet2_had_mcpdgId_, pfjet2_had_ntwrs_; int pfjet2_ntwrs_; - std::vector pfjet2_twr_ieta_, pfjet2_twr_iphi_, pfjet2_twr_depth_, pfjet2_twr_subdet_, pfjet2_twr_candtrackind_, pfjet2_twr_hadind_, pfjet2_twr_elmttype_, pfjet2_twr_clusterind_; + std::vector pfjet2_twr_ieta_, pfjet2_twr_iphi_, pfjet2_twr_depth_, pfjet2_twr_subdet_, pfjet2_twr_candtrackind_, + pfjet2_twr_hadind_, pfjet2_twr_elmttype_, pfjet2_twr_clusterind_; std::vector pfjet2_twr_hade_, pfjet2_twr_frac_, pfjet2_twr_dR_; int pfjet2_cluster_n_; std::vector pfjet2_cluster_eta_, pfjet2_cluster_phi_, pfjet2_cluster_dR_; @@ -283,14 +319,16 @@ class GammaJetAnalysis : public edm::EDAnalyzer { float pf_thirdjet_E_, pf_thirdjet_eta_, pf_thirdjet_phi_, pf_thirdjet_scale_; // helper functions - template - float calc_dPhi(const PhotonPair &pho, const JetPair_type &jet) { - if (!pho.isValid() || !jet.isValid()) return 9999.; - float phi1=pho.photon()->phi(); - float phi2=jet.jet()->phi(); - float dphi=fabs(phi1-phi2); - const float cPi= 4*atan(1); - while (dphi>cPi) dphi = fabs(2*cPi - dphi); + template + float calc_dPhi(const PhotonPair& pho, const JetPair_type& jet) { + if (!pho.isValid() || !jet.isValid()) + return 9999.; + float phi1 = pho.photon()->phi(); + float phi2 = jet.jet()->phi(); + float dphi = fabs(phi1 - phi2); + const float cPi = 4 * atan(1); + while (dphi > cPi) + dphi = fabs(2 * cPi - dphi); return dphi; } @@ -302,25 +340,24 @@ class GammaJetAnalysis : public edm::EDAnalyzer { void clear_leadingPfJetVars(); void copy_leadingPfJetVars_to_pfJet2(); - template - double deltaR(const PhotonPair &photon, const Jet_type *jet) { - if (!photon.isValid()) return 9999.; - return deltaR(photon.photon()->eta(),photon.photon()->phi(), - jet->eta(), jet->phi()); + template + double deltaR(const PhotonPair& photon, const Jet_type* jet) { + if (!photon.isValid()) + return 9999.; + return deltaR(photon.photon()->eta(), photon.photon()->phi(), jet->eta(), jet->phi()); } struct PFJetCorretPairComp { - inline bool operator() ( const PFJetCorretPair& a, const PFJetCorretPair& b) const{ - return (a.jet()->pt()*a.scale()) > (b.jet()->pt()*b.scale()); + inline bool operator()(const PFJetCorretPair& a, const PFJetCorretPair& b) const { + return (a.jet()->pt() * a.scale()) > (b.jet()->pt() * b.scale()); } }; struct PhotonPairComp { - inline bool operator() ( const PhotonPair& a, const PhotonPair& b) const{ - return ( (a.photon()->pt()) > (b.photon()->pt()) ); + inline bool operator()(const PhotonPair& a, const PhotonPair& b) const { + return ((a.photon()->pt()) > (b.photon()->pt())); } }; - }; #endif diff --git a/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.cc b/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.cc index e5dc4350e519f..14734a609dca5 100644 --- a/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.cc +++ b/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.cc @@ -32,143 +32,132 @@ using namespace reco; // // constructors and destructor // -namespace cms{ -HcalConstantsASCIIWriter::HcalConstantsASCIIWriter(const edm::ParameterSet& iConfig) -{ - // get name of output file with histogramms - file_input="Calibration/HcalCalibAlgos/data/"+iConfig.getParameter ("fileInput")+".txt"; - file_output="Calibration/HcalCalibAlgos/data/"+iConfig.getParameter ("fileOutput")+".txt"; -} - -HcalConstantsASCIIWriter::~HcalConstantsASCIIWriter() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - -} - -void HcalConstantsASCIIWriter::beginJob() -{ +namespace cms { + HcalConstantsASCIIWriter::HcalConstantsASCIIWriter(const edm::ParameterSet& iConfig) { + // get name of output file with histogramms + file_input = "Calibration/HcalCalibAlgos/data/" + iConfig.getParameter("fileInput") + ".txt"; + file_output = "Calibration/HcalCalibAlgos/data/" + iConfig.getParameter("fileOutput") + ".txt"; + } + + HcalConstantsASCIIWriter::~HcalConstantsASCIIWriter() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + } + + void HcalConstantsASCIIWriter::beginJob() { edm::FileInPath f1(file_output); std::string fDataFile = f1.fullPath(); - myout_hcal = new std::ofstream(fDataFile.c_str()); - if(!myout_hcal) std::cout << " Output file not open!!! "< r; iSetup.get().get(r); HcalRespCorrs* oldRespCorrs = new HcalRespCorrs(*r.product()); -// std::vector dd = oldRespCorrs->getAllChannels(); - - edm::ESHandle pG; - iSetup.get().get(pG); - const CaloGeometry* geo = pG.product(); -// iSetup.get().get(conditions); - - std::vector did = geo->getValidDetIds(); - - - std::map corrold; - //map corrnew; - - int mysubd,depth,ieta,iphi; - float coradd,corerr; - - std::vector theVector; - for(std::vector::iterator i = did.begin(); i != did.end(); i++) - { - if( (*i).det() == DetId::Hcal ) { - HcalDetId hid = HcalDetId(*i); - theVector.push_back(hid); - corrold[hid] = (oldRespCorrs->getValues(*i))->getValue(); - std::cout<<" Old calibration "< dd = oldRespCorrs->getAllChannels(); + + edm::ESHandle pG; + iSetup.get().get(pG); + const CaloGeometry* geo = pG.product(); + // iSetup.get().get(conditions); + + std::vector did = geo->getValidDetIds(); + + std::map corrold; + //map corrnew; + + int mysubd, depth, ieta, iphi; + float coradd, corerr; + + std::vector theVector; + for (std::vector::iterator i = did.begin(); i != did.end(); i++) { + if ((*i).det() == DetId::Hcal) { + HcalDetId hid = HcalDetId(*i); + theVector.push_back(hid); + corrold[hid] = (oldRespCorrs->getValues(*i))->getValue(); + std::cout << " Old calibration " << hid.depth() << " " << hid.ieta() << " " << hid.iphi() << std::endl; + } } - std::cout<<" Get old calibration "<>mysubd>>depth>>ieta>>iphi>>coradd>>corerr; -// DetId mydid(DetId::Hcal,HcalSubdetector(mysubd)); -// HcalDetId hid(HcalSubdetector(mysubd),ieta,iphi,depth); -// HcalDetId hid(mydid); -// std::cout<<" Check mysubd "<0) corrnew_p[mysubd][depth][ietak][iphi] = coradd; - if(ieta<0) corrnew_m[mysubd][depth][ietak][iphi] = coradd; - std::cout<<" Try to initialize mysubd "<topo()); - - for(std::vector::iterator it = theVector.begin(); it != theVector.end(); it++) - { - float cc1 = (*corrold.find(*it)).second; - // float cc2 = (*corrnew.find(*it)).second; - float cc2 = 0.; - int ietak = (*it).ieta(); - - if((*it).ieta()<0) ietak=-1*(*it).ieta(); - - if((*it).ieta()>0) cc2 = corrnew_p[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()]; - if((*it).ieta()<0) cc2 = corrnew_m[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()]; - - float cc = cc1*cc2; - std::cout<<" Multiply "<<(*it).subdet()<<" "<<(*it).depth()<<" "<<(*it).ieta()<<" "<> mysubd >> depth >> ieta >> iphi >> coradd >> corerr; + // DetId mydid(DetId::Hcal,HcalSubdetector(mysubd)); + // HcalDetId hid(HcalSubdetector(mysubd),ieta,iphi,depth); + // HcalDetId hid(mydid); + // std::cout<<" Check mysubd "< 0) + corrnew_p[mysubd][depth][ietak][iphi] = coradd; + if (ieta < 0) + corrnew_m[mysubd][depth][ietak][iphi] = coradd; + std::cout << " Try to initialize mysubd " << mysubd << " depth " << depth << " ieta " << ieta << " " << ietak + << " iphi " << iphi << " " << coradd << std::endl; + } + + HcalRespCorrs* mycorrections = new HcalRespCorrs(oldRespCorrs->topo()); + + for (std::vector::iterator it = theVector.begin(); it != theVector.end(); it++) { + float cc1 = (*corrold.find(*it)).second; + // float cc2 = (*corrnew.find(*it)).second; + float cc2 = 0.; + int ietak = (*it).ieta(); + + if ((*it).ieta() < 0) + ietak = -1 * (*it).ieta(); + + if ((*it).ieta() > 0) + cc2 = corrnew_p[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()]; + if ((*it).ieta() < 0) + cc2 = corrnew_m[(*it).subdet()][(*it).depth()][ietak][(*it).iphi()]; + + float cc = cc1 * cc2; + std::cout << " Multiply " << (*it).subdet() << " " << (*it).depth() << " " << (*it).ieta() << " " << ietak << " " + << (*it).iphi() << " " << (*it).rawId() << " " << cc1 << " " << cc2 << std::endl; + + // now make the basic object for one cell with HcalDetId myDetId containing the value myValue + HcalRespCorr item((*it).rawId(), cc); mycorrections->addValues(item); - } + } HcalRespCorrs mycc = *mycorrections; - HcalDbASCIIIO::dumpObject (*myout_hcal, mycc); - -} -} + HcalDbASCIIIO::dumpObject(*myout_hcal, mycc); + } +} // namespace cms //define this as a plug-in #include "FWCore/Framework/interface/MakerMacros.h" using cms::HcalConstantsASCIIWriter; DEFINE_FWK_MODULE(HcalConstantsASCIIWriter); - - diff --git a/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.h b/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.h index d7fa0dc6b48c9..67066ff36f66a 100644 --- a/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.h +++ b/Calibration/HcalCalibAlgos/test/HcalConstantsASCIIWriter.h @@ -45,22 +45,22 @@ // // class decleration // -namespace cms{ -class HcalConstantsASCIIWriter : public edm::EDAnalyzer { - public: - explicit HcalConstantsASCIIWriter(const edm::ParameterSet&); - ~HcalConstantsASCIIWriter(); +namespace cms { + class HcalConstantsASCIIWriter : public edm::EDAnalyzer { + public: + explicit HcalConstantsASCIIWriter(const edm::ParameterSet &); + ~HcalConstantsASCIIWriter(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob() ; - virtual void endJob() ; + virtual void analyze(const edm::Event &, const edm::EventSetup &); + virtual void beginJob(); + virtual void endJob(); - private: - // ----------member data --------------------------- - - std::ofstream *myout_hcal; - std::string file_input; - std::string file_output; -}; -} + private: + // ----------member data --------------------------- + + std::ofstream *myout_hcal; + std::string file_input; + std::string file_output; + }; +} // namespace cms #endif diff --git a/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc b/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc old mode 100755 new mode 100644 index fd6216bfaea99..4830196dab73f --- a/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc +++ b/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc @@ -29,7 +29,6 @@ #include "DataFormats/GeometrySurface/interface/Cylinder.h" #include "DataFormats/GeometrySurface/interface/Plane.h" - #include "Calibration/HcalCalibAlgos/interface/CommonUsefulStuff.h" #include @@ -44,20 +43,20 @@ class HcalCorrPFCalculation : public edm::EDAnalyzer { HcalCorrPFCalculation(edm::ParameterSet const& conf); ~HcalCorrPFCalculation(); virtual void analyze(edm::Event const& ev, edm::EventSetup const& c) override; - virtual void beginJob() override ; - virtual void endJob() override ; + virtual void beginJob() override; + virtual void endJob() override; + private: - double RecalibFactor(HcalDetId id); - bool Respcorr_; - bool PFcorr_; - bool Conecorr_; - double radius_; + bool Respcorr_; + bool PFcorr_; + bool Conecorr_; + double radius_; - double clusterConeSize_,associationConeSize_, ecalCone_, neutralIsolationCone_, trackIsolationCone_; - float eECAL, eECAL09cm, eECAL40cm; -// double energyECALmip; + double clusterConeSize_, associationConeSize_, ecalCone_, neutralIsolationCone_, trackIsolationCone_; + float eECAL, eECAL09cm, eECAL40cm; + // double energyECALmip; float eCentHit, eTrack, eParticle; float CentHitFactor; @@ -76,7 +75,7 @@ class HcalCorrPFCalculation : public edm::EDAnalyzer { const HcalPFCorrs* pfRecalib; SteppingHelixPropagator* stepPropF; - MagneticField *theMagField; + MagneticField* theMagField; TrackDetectorAssociator trackAssociator_; TrackAssociatorParameters parameters_; @@ -84,16 +83,16 @@ class HcalCorrPFCalculation : public edm::EDAnalyzer { const CaloGeometry* geo; const HcalGeometry* gHcal; - Float_t xTrkHcal,yTrkHcal,zTrkHcal; + Float_t xTrkHcal, yTrkHcal, zTrkHcal; Float_t xTrkEcal, yTrkEcal, zTrkEcal; Float_t xAtHcal, yAtHcal, zAtHcal; float eEcalCone, eHcalCone, eHcalConeNoise; int UsedCells, UsedCellsNoise; float phiParticle, etaParticle; - - Int_t numValidTrkHits[50], numValidTrkStrips[50], numLayers[50]; - + + Int_t numValidTrkHits[50], numValidTrkStrips[50], numLayers[50]; + Bool_t trkQual[50]; TProfile *nCells, *nCellsNoise, *enHcal, *enHcalNoise; @@ -102,7 +101,7 @@ class HcalCorrPFCalculation : public edm::EDAnalyzer { // TFile *rootFile; edm::Service fs; Int_t nTracks; - Float_t genEta,genPhi, trackEta[50],trackPhi[50], trackP[50] , delRmc[50]; + Float_t genEta, genPhi, trackEta[50], trackPhi[50], trackP[50], delRmc[50]; edm::EDGetTokenT tok_hbhe_; edm::EDGetTokenT tok_ho_; @@ -114,196 +113,185 @@ class HcalCorrPFCalculation : public edm::EDAnalyzer { edm::EDGetTokenT tok_gen_; }; - HcalCorrPFCalculation::HcalCorrPFCalculation(edm::ParameterSet const& iConfig) { - tok_hbhe_ = consumes(iConfig.getParameter("hbheRecHitCollectionTag")); tok_hf_ = consumes(iConfig.getParameter("hfRecHitCollectionTag")); - tok_ho_ = consumes(iConfig.getParameter("hoRecHitCollectionTag")); + tok_ho_ = consumes(iConfig.getParameter("hoRecHitCollectionTag")); // should maybe add these options to configuration - cowden - tok_EE_ = consumes( edm::InputTag("ecalRecHit","EcalRecHitsEE") ); - tok_EB_ = consumes( edm::InputTag("ecalRecHit","EcalRecHitsEB") ); - tok_tracks_ = consumes( edm::InputTag("generalTracks") ); - tok_gen_ = consumes(edm::InputTag("generatorSmeared")); + tok_EE_ = consumes(edm::InputTag("ecalRecHit", "EcalRecHitsEE")); + tok_EB_ = consumes(edm::InputTag("ecalRecHit", "EcalRecHitsEB")); + tok_tracks_ = consumes(edm::InputTag("generalTracks")); + tok_gen_ = consumes(edm::InputTag("generatorSmeared")); // outputFile_ = iConfig.getUntrackedParameter("outputFile", "myfile.root"); - - Respcorr_ = iConfig.getUntrackedParameter("RespcorrAdd", false); - PFcorr_ = iConfig.getUntrackedParameter("PFcorrAdd", false); - Conecorr_ = iConfig.getUntrackedParameter("ConeCorrAdd", true); + + Respcorr_ = iConfig.getUntrackedParameter("RespcorrAdd", false); + PFcorr_ = iConfig.getUntrackedParameter("PFcorrAdd", false); + Conecorr_ = iConfig.getUntrackedParameter("ConeCorrAdd", true); //radius_ = iConfig.getUntrackedParameter("ConeRadiusCm", 40.); //energyECALmip = iConfig.getParameter("energyECALmip"); edm::ParameterSet parameters = iConfig.getParameter("TrackAssociatorParameters"); edm::ConsumesCollector iC = consumesCollector(); - parameters_.loadParameters( parameters, iC ); + parameters_.loadParameters(parameters, iC); trackAssociator_.useDefaultPropagator(); - associationConeSize_=iConfig.getParameter("associationConeSize"); - clusterConeSize_=iConfig.getParameter("clusterConeSize"); - ecalCone_=iConfig.getParameter("ecalCone"); + associationConeSize_ = iConfig.getParameter("associationConeSize"); + clusterConeSize_ = iConfig.getParameter("clusterConeSize"); + ecalCone_ = iConfig.getParameter("ecalCone"); trackIsolationCone_ = iConfig.getParameter("trackIsolationCone"); neutralIsolationCone_ = iConfig.getParameter("neutralIsolationCone"); // AxB_=iConfig.getParameter("AxB"); - } - -double HcalCorrPFCalculation::RecalibFactor(HcalDetId id) -{ +double HcalCorrPFCalculation::RecalibFactor(HcalDetId id) { Float_t resprecal = 1.; Float_t pfrecal = 1.; - if(AddRecalib) { - if(Respcorr_) resprecal = respRecalib -> getValues(id)->getValue(); - if(PFcorr_) pfrecal = pfRecalib -> getValues(id)->getValue(); + if (AddRecalib) { + if (Respcorr_) + resprecal = respRecalib->getValues(id)->getValue(); + if (PFcorr_) + pfrecal = pfRecalib->getValues(id)->getValue(); } - Float_t factor = resprecal*pfrecal; + Float_t factor = resprecal * pfrecal; return factor; } HcalCorrPFCalculation::~HcalCorrPFCalculation() {} void HcalCorrPFCalculation::analyze(edm::Event const& ev, edm::EventSetup const& c) { + AddRecalib = kFALSE; - AddRecalib=kFALSE; - - try{ - - edm::ESHandle recalibCorrs; - c.get().get("recalibrate",recalibCorrs); + try { + edm::ESHandle recalibCorrs; + c.get().get("recalibrate", recalibCorrs); respRecalib = recalibCorrs.product(); - edm::ESHandle pfCorrs; - c.get().get("recalibrate",pfCorrs); + edm::ESHandle pfCorrs; + c.get().get("recalibrate", pfCorrs); pfRecalib = pfCorrs.product(); AddRecalib = kTRUE; // LogMessage("CalibConstants")<<" OK "; - }catch(const cms::Exception & e) { - LogWarning("CalibConstants")<<" Not Found!! "; + } catch (const cms::Exception& e) { + LogWarning("CalibConstants") << " Not Found!! "; } edm::Handle hbhe; ev.getByToken(tok_hbhe_, hbhe); const HBHERecHitCollection Hithbhe = *(hbhe.product()); - + edm::Handle hfcoll; ev.getByToken(tok_hf_, hfcoll); const HFRecHitCollection Hithf = *(hfcoll.product()); - + edm::Handle hocoll; ev.getByToken(tok_ho_, hocoll); const HORecHitCollection Hitho = *(hocoll.product()); - + edm::Handle ecalEE; - ev.getByToken(tok_EE_,ecalEE); + ev.getByToken(tok_EE_, ecalEE); const EERecHitCollection HitecalEE = *(ecalEE.product()); - + edm::Handle ecalEB; - ev.getByToken(tok_EB_,ecalEB); + ev.getByToken(tok_EB_, ecalEB); const EBRecHitCollection HitecalEB = *(ecalEB.product()); - + // temporary collection of EB+EE recHits auto tmpEcalRecHitCollection = std::make_unique(); - for(EcalRecHitCollection::const_iterator recHit = (*ecalEB).begin(); recHit != (*ecalEB).end(); ++recHit) - {tmpEcalRecHitCollection->push_back(*recHit);} - for(EcalRecHitCollection::const_iterator recHit = (*ecalEE).begin(); recHit != (*ecalEE).end(); ++recHit) - {tmpEcalRecHitCollection->push_back(*recHit);} + for (EcalRecHitCollection::const_iterator recHit = (*ecalEB).begin(); recHit != (*ecalEB).end(); ++recHit) { + tmpEcalRecHitCollection->push_back(*recHit); + } + for (EcalRecHitCollection::const_iterator recHit = (*ecalEE).begin(); recHit != (*ecalEE).end(); ++recHit) { + tmpEcalRecHitCollection->push_back(*recHit); + } const EcalRecHitCollection Hitecal = *tmpEcalRecHitCollection; - edm::Handle generalTracks; ev.getByToken(tok_tracks_, generalTracks); - - edm::ESHandle pG; - c.get().get(pG); - geo = pG.product(); - - gHcal = static_cast(geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel)); - - parameters_.useEcal = true; - parameters_.useHcal = true; - parameters_.useCalo = false; - parameters_.useMuon = false; - parameters_.dREcal = 0.5; - parameters_.dRHcal = 0.6; - - //parameters_.dREcal = taECALCone_; - //parameters_.dRHcal = taHCALCone_; - - + + edm::ESHandle pG; + c.get().get(pG); + geo = pG.product(); + + gHcal = static_cast(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel)); + + parameters_.useEcal = true; + parameters_.useHcal = true; + parameters_.useCalo = false; + parameters_.useMuon = false; + parameters_.dREcal = 0.5; + parameters_.dRHcal = 0.6; + + //parameters_.dREcal = taECALCone_; + //parameters_.dRHcal = taHCALCone_; + edm::ESHandle bField; c.get().get(bField); - stepPropF = new SteppingHelixPropagator(&*bField,alongMomentum); + stepPropF = new SteppingHelixPropagator(&*bField, alongMomentum); stepPropF->setMaterialMode(false); stepPropF->applyRadX0Correction(true); - // double eta_bin[42]={0.,.087,.174,.261,.348,.435,.522,.609,.696,.783, //.870,.957,1.044,1.131,1.218,1.305,1.392,1.479,1.566,1.653,1.740,1.830,1.930,2.043,2.172, //2.322,2.500,2.650,2.853,3.000,3.139,3.314,3.489,3.664,3.839,4.013,4.191,4.363,4.538,4.716,4.889,5.191}; - - // MC info + + // MC info //double phi_MC = -999999.; // phi of initial particle from HepMC //double eta_MC = -999999.; // eta of initial particle from HepMC double mom_MC = 50.; // P of initial particle from HepMC //bool MC = false; - + // MC information - - + edm::Handle evtMC; // ev.getByLabel("generatorSmeared",evtMC); - ev.getByToken(tok_gen_,evtMC); - if (!evtMC.isValid()) - { - std::cout << "no HepMCProduct found" << std::endl; - } - else - { - //MC=true; - // std::cout << "*** source HepMCProduct found"<< std::endl; - } - - // MC particle with highest pt is taken as a direction reference + ev.getByToken(tok_gen_, evtMC); + if (!evtMC.isValid()) { + std::cout << "no HepMCProduct found" << std::endl; + } else { + //MC=true; + // std::cout << "*** source HepMCProduct found"<< std::endl; + } + + // MC particle with highest pt is taken as a direction reference double maxPt = -99999.; - int npart = 0; - - GlobalPoint initpos (0,0,0); - - HepMC::GenEvent * myGenEvent = new HepMC::GenEvent(*(evtMC->GetEvent())); - for ( HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin(); - p != myGenEvent->particles_end(); ++p ) - { - phiParticle = (*p)->momentum().phi(); - etaParticle = (*p)->momentum().eta(); - double pt = (*p)->momentum().perp(); - mom_MC = (*p)->momentum().rho(); - if(pt > maxPt) { npart++; maxPt = pt; /*phi_MC = phiParticle; eta_MC = etaParticle;*/ } - GlobalVector mom ((*p)->momentum().x(),(*p)->momentum().y(),(*p)->momentum().z()); - int charge = -1; - - if(abs((*p)->pdg_id())==211) charge = (*p)->pdg_id()/abs((*p)->pdg_id()); // pions only !!! - else continue; - + int npart = 0; - /* Propogate the partoicle to Hcal */ + GlobalPoint initpos(0, 0, 0); + HepMC::GenEvent* myGenEvent = new HepMC::GenEvent(*(evtMC->GetEvent())); + for (HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p) { + phiParticle = (*p)->momentum().phi(); + etaParticle = (*p)->momentum().eta(); + double pt = (*p)->momentum().perp(); + mom_MC = (*p)->momentum().rho(); + if (pt > maxPt) { + npart++; + maxPt = pt; /*phi_MC = phiParticle; eta_MC = etaParticle;*/ + } + GlobalVector mom((*p)->momentum().x(), (*p)->momentum().y(), (*p)->momentum().z()); + int charge = -1; - const FreeTrajectoryState *freetrajectorystate_ = - new FreeTrajectoryState(initpos, mom ,charge , &(*theMagField)); - + if (abs((*p)->pdg_id()) == 211) + charge = (*p)->pdg_id() / abs((*p)->pdg_id()); // pions only !!! + else + continue; - TrackDetMatchInfo info = trackAssociator_.associate(ev, c, *freetrajectorystate_ , parameters_); + /* Propogate the partoicle to Hcal */ - GlobalPoint barrelMC(0,0,0), endcapMC(0,0,0), forwardMC1(0,0,0), forwardMC2(0,0,0); - - GlobalPoint gPointHcal(0.,0.,0.); - - /* + const FreeTrajectoryState* freetrajectorystate_ = new FreeTrajectoryState(initpos, mom, charge, &(*theMagField)); + + TrackDetMatchInfo info = trackAssociator_.associate(ev, c, *freetrajectorystate_, parameters_); + + GlobalPoint barrelMC(0, 0, 0), endcapMC(0, 0, 0), forwardMC1(0, 0, 0), forwardMC2(0, 0, 0); + + GlobalPoint gPointHcal(0., 0., 0.); + + /* xTrkHcal=info.trkGlobPosAtHcal.x(); yTrkHcal=info.trkGlobPosAtHcal.y(); zTrkHcal=info.trkGlobPosAtHcal.z(); @@ -314,472 +302,442 @@ void HcalCorrPFCalculation::analyze(edm::Event const& ev, edm::EventSetup const& if (xTrkHcal==0 && yTrkHcal==0 && zTrkHcal==0) continue; */ + if (fabs(etaParticle) < 1.392) { + Cylinder* cylinder = new Cylinder(181.1, Surface::PositionType(0, 0, 0), Surface::RotationType()); - if(fabs(etaParticle)<1.392) { - Cylinder *cylinder = new Cylinder(181.1, Surface::PositionType(0,0,0), - Surface::RotationType()); - - TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*cylinder)); - if(steppingHelixstateinfo_.isValid() ) - { barrelMC = steppingHelixstateinfo_.freeState()->position(); } - + TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*cylinder)); + if (steppingHelixstateinfo_.isValid()) { + barrelMC = steppingHelixstateinfo_.freeState()->position(); } - - - doHF = kFALSE; - if(fabs(etaParticle)>=1.392 && fabs(etaParticle)<5.191) { - - Surface::RotationType rot(GlobalVector(1,0,0),GlobalVector(0,1,0)); - - Surface::PositionType pos(0., 0.,400.5*fabs(etaParticle)/etaParticle); - PlaneBuilder::ReturnType aPlane = PlaneBuilder().plane(pos,rot); - - - TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane)); - if(steppingHelixstateinfo_.isValid() && fabs(steppingHelixstateinfo_.freeState()->position().eta())<3.0 ) - endcapMC = steppingHelixstateinfo_.freeState()->position(); - if(steppingHelixstateinfo_.isValid() && fabs(steppingHelixstateinfo_.freeState()->position().eta())>3.0 ) - doHF=kTRUE; - } - if(doHF) { - - if (abs(etaParticle)>5.191) continue; - - if(abs(etaParticle)>2.99) { - Surface::RotationType rot(GlobalVector(1,0,0),GlobalVector(0,1,0)); - - Surface::PositionType pos1(0., 0.,1125*fabs(etaParticle)/etaParticle); - // Surface::PositionType pos1(0., 0.,1115*fabs(etaParticle)/etaParticle); - Surface::PositionType pos2(0., 0.,1137*fabs(etaParticle)/etaParticle); - PlaneBuilder::ReturnType aPlane1 = PlaneBuilder().plane(pos1,rot); - PlaneBuilder::ReturnType aPlane2 = PlaneBuilder().plane(pos2,rot); - - - TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane1)); - if(steppingHelixstateinfo_.isValid() ) - forwardMC1 = steppingHelixstateinfo_.freeState()->position(); - - steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane2)); - if(steppingHelixstateinfo_.isValid() ) - forwardMC2 = steppingHelixstateinfo_.freeState()->position(); - } + } + + doHF = kFALSE; + if (fabs(etaParticle) >= 1.392 && fabs(etaParticle) < 5.191) { + Surface::RotationType rot(GlobalVector(1, 0, 0), GlobalVector(0, 1, 0)); + + Surface::PositionType pos(0., 0., 400.5 * fabs(etaParticle) / etaParticle); + PlaneBuilder::ReturnType aPlane = PlaneBuilder().plane(pos, rot); + + TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane)); + if (steppingHelixstateinfo_.isValid() && fabs(steppingHelixstateinfo_.freeState()->position().eta()) < 3.0) + endcapMC = steppingHelixstateinfo_.freeState()->position(); + if (steppingHelixstateinfo_.isValid() && fabs(steppingHelixstateinfo_.freeState()->position().eta()) > 3.0) + doHF = kTRUE; + } + if (doHF) { + if (abs(etaParticle) > 5.191) + continue; + + if (abs(etaParticle) > 2.99) { + Surface::RotationType rot(GlobalVector(1, 0, 0), GlobalVector(0, 1, 0)); + + Surface::PositionType pos1(0., 0., 1125 * fabs(etaParticle) / etaParticle); + // Surface::PositionType pos1(0., 0.,1115*fabs(etaParticle)/etaParticle); + Surface::PositionType pos2(0., 0., 1137 * fabs(etaParticle) / etaParticle); + PlaneBuilder::ReturnType aPlane1 = PlaneBuilder().plane(pos1, rot); + PlaneBuilder::ReturnType aPlane2 = PlaneBuilder().plane(pos2, rot); + + TrajectoryStateOnSurface steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane1)); + if (steppingHelixstateinfo_.isValid()) + forwardMC1 = steppingHelixstateinfo_.freeState()->position(); + + steppingHelixstateinfo_ = stepPropF->propagate(*freetrajectorystate_, (*aPlane2)); + if (steppingHelixstateinfo_.isValid()) + forwardMC2 = steppingHelixstateinfo_.freeState()->position(); } - /* ------------ ------------ ----------------------------- */ - - + } + /* ------------ ------------ ----------------------------- */ - /* Finding the closest cell at Hcal */ - Int_t iphitrue = -10; - Int_t ietatrue = 100; - HcalDetId tempId; - - if (abs(etaParticle)<1.392) - { - gPointHcal = barrelMC; - tempId = gHcal->getClosestCell(gPointHcal); - } - if (abs(etaParticle)>=1.392 && abs(etaParticle)<3.0) - { - gPointHcal = endcapMC; - tempId = gHcal->getClosestCell(gPointHcal); - } - if (abs(etaParticle)>=3.0 && abs(etaParticle)<5.191) - { - gPointHcal = forwardMC1; - tempId = gHcal->getClosestCell(gPointHcal); - //tempId = gHcal->CaloSubdetectorGeometry::getClosestCell(gPointHcal); - } + /* Finding the closest cell at Hcal */ + Int_t iphitrue = -10; + Int_t ietatrue = 100; + HcalDetId tempId; - - + if (abs(etaParticle) < 1.392) { + gPointHcal = barrelMC; tempId = gHcal->getClosestCell(gPointHcal); - - ietatrue = tempId.ieta(); - iphitrue = tempId.iphi(); - - etaGPoint = gPointHcal.eta(); - phiGPoint = gPointHcal.phi(); + } + if (abs(etaParticle) >= 1.392 && abs(etaParticle) < 3.0) { + gPointHcal = endcapMC; + tempId = gHcal->getClosestCell(gPointHcal); + } + if (abs(etaParticle) >= 3.0 && abs(etaParticle) < 5.191) { + gPointHcal = forwardMC1; + tempId = gHcal->getClosestCell(gPointHcal); + //tempId = gHcal->CaloSubdetectorGeometry::getClosestCell(gPointHcal); + } - //xAtHcal = gPointHcal.x(); - //yAtHcal = gPointHcal.y(); - //zAtHcal = gPointHcal.z(); - /* ----------------- ------------------------ */ + tempId = gHcal->getClosestCell(gPointHcal); - - if (gPointHcal.x()==0 && gPointHcal.y()==0 && gPointHcal.z()==0) - {/*cout <<"gPointHcal is Zero!"<5.192) continue; - //if (abs(etahcal)>3.0 && abs(etahcal)<5.191) - - //cout < Fill(eEcalCone); - //if(abs(etaecal)>1.5 && abs(etaecal)<3.1) enEcalE -> Fill(eEcalCone); + float etahcal = gPointHcal.eta(); + // float phihcal=gPointHcal.phi(); + if (abs(etahcal) > 5.192) + continue; + //if (abs(etahcal)>3.0 && abs(etahcal)<5.191) - /* ------------------------------ -------------------------- ----------------- */ + //cout <detid()); - GlobalPoint pos = gHcal->getPosition(hhit->detid()); - - int iphihit = (hhit->id()).iphi(); - int ietahit = (hhit->id()).ieta(); - int depthhit = (hhit->id()).depth(); - float enehit = hhit->energy()* recal; - - if (depthhit!=1) continue; - - double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); - - if(distAtHcal < clusterConeSize_) - { - for (HBHERecHitCollection::const_iterator hhit2=Hithbhe.begin(); hhit2!=Hithbhe.end(); hhit2++) - //for (HcalRecHitCollection::const_iterator hhit2=Hithcal.begin(); hhit2!=Hithcal.end(); hhit2++) - { - int iphihit2 = (hhit2->id()).iphi(); - int ietahit2 = (hhit2->id()).ieta(); - int depthhit2 = (hhit2->id()).depth(); - float enehit2 = hhit2->energy() * recal; - - if (iphihit==iphihit2 && ietahit==ietahit2 && depthhit!=depthhit2) enehit = enehit+enehit2; - - } - - - if(enehit > MaxHit.hitenergy) - { - MaxHit.hitenergy = enehit; - MaxHit.ietahitm = (hhit->id()).ieta(); - MaxHit.iphihitm = (hhit->id()).iphi(); - MaxHit.dr = distAtHcal; - //MaxHit.depthhit = (hhit->id()).depth(); - MaxHit.depthhit = 1; - } - } - } + /* ------------- Calculate Ecal Energy using TrackAssociator ---------------------- */ - - for (HFRecHitCollection::const_iterator hhit=Hithf.begin(); hhit!=Hithf.end(); hhit++) - { - - recal = RecalibFactor(hhit->detid()); - - GlobalPoint pos = gHcal->getPosition(hhit->detid()); - - int iphihit = (hhit->id()).iphi(); - int ietahit = (hhit->id()).ieta(); - int depthhit = (hhit->id()).depth(); - float enehit = hhit->energy()* recal; - - double distAtHcal = getDistInPlaneSimple(gPointHcal,pos); - - if(distAtHcal < associationConeSize_) - { - for (HFRecHitCollection::const_iterator hhit2=Hithf.begin(); hhit2!=Hithf.end(); hhit2++) - { - int iphihit2 = (hhit2->id()).iphi(); - int ietahit2 = (hhit2->id()).ieta(); - int depthhit2 = (hhit2->id()).depth(); - float enehit2 = hhit2->energy() * recal; - - if (iphihit==iphihit2 && ietahit==ietahit2 && depthhit!=depthhit2) enehit = enehit+enehit2; - - } - - if(enehit > MaxHit.hitenergy) - { - MaxHit.hitenergy = enehit; - MaxHit.ietahitm = (hhit->id()).ieta(); - MaxHit.iphihitm = (hhit->id()).iphi(); - MaxHit.dr = distAtHcal; - MaxHit.depthhit = 1; - } - } - } - - /* ---------------------- ---------------- -------------------------------------------- */ + //float etaecal=info.trkGlobPosAtEcal.eta(); + xTrkEcal = info.trkGlobPosAtEcal.x(); + yTrkEcal = info.trkGlobPosAtEcal.y(); + zTrkEcal = info.trkGlobPosAtEcal.z(); - /* ----------- Collect Hcal Energy in a Cone (and also 3x3 and 5x5 around the hottest cell)*/ - - for (HBHERecHitCollection::const_iterator hhit=Hithbhe.begin(); hhit!=Hithbhe.end(); hhit++) - // for (HcalRecHitCollection::const_iterator hhit=Hithcal.begin(); hhit!=Hithcal.end(); hhit++) - { - - recal = RecalibFactor(hhit->detid()); - //cout<<"recal: "<getPosition(hhit->detid()); - - int iphihit = (hhit->id()).iphi(); - int ietahit = (hhit->id()).ieta(); - int depthhit = (hhit->id()).depth(); - float enehit = hhit->energy()* recal; - - //if (depthhit!=1) continue; - - //Set noise RecHit opposite to track hits - int iphihitNoise = iphihit >36 ? iphihit-36 : iphihit+36; - int ietahitNoise = -ietahit; - int depthhitNoise = depthhit; - - double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); - if(distAtHcal < clusterConeSize_ && MaxHit.hitenergy > 0.) - { - eHcalCone += enehit; - UsedCells++; - - - int DIETA = 100; - if(MaxHit.ietahitm*(hhit->id()).ieta()>0) - { DIETA = MaxHit.ietahitm - (hhit->id()).ieta();} - if(MaxHit.ietahitm*(hhit->id()).ieta()<0) - { DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); DIETA = DIETA>0 ? DIETA-1 : DIETA+1;} - int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); - DIPHI = DIPHI>36 ? 72-DIPHI : DIPHI; - - - if (abs(DIETA)<=2 && (abs(DIPHI)<=2 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=4) && !( (abs(MaxHit.ietahitm)==21 || abs(MaxHit.ietahitm)==22) && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>2) )) ) - {e5x5 += hhit->energy();} - if (abs(DIETA)<=1 && (abs(DIPHI)<=1 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=2) && !(abs(MaxHit.ietahitm)==21 && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>1) )) ) - {e3x3 += hhit->energy();} - - // cout<<"track: ieta "<detid()); - int iphihit2 = (hhit2->id()).iphi(); - int ietahit2 = (hhit2->id()).ieta(); - int depthhit2 = (hhit2->id()).depth(); - float enehit2 = hhit2->energy()* recal; - - if (iphihitNoise == iphihit2 && ietahitNoise == ietahit2 && depthhitNoise == depthhit2 && enehit2>0.) - { - eHcalConeNoise += hhit2->energy()*recal; - UsedCellsNoise++; - //cout<<"Noise: ieta "<detid()); - - GlobalPoint pos = gHcal->getPosition(hhit->detid()); - //float phihit = pos.phi(); - //float etahit = pos.eta(); - - int iphihit = (hhit->id()).iphi(); - int ietahit = (hhit->id()).ieta(); - int depthhit = (hhit->id()).depth(); - float enehit = hhit->energy()* recal; - - //Set noise RecHit opposite to track hits - int iphihitNoise = iphihit >36 ? iphihit-36 : iphihit+36; - int ietahitNoise = -ietahit; - int depthhitNoise = depthhit; - - double distAtHcal = getDistInPlaneSimple(gPointHcal,pos); - - if(distAtHcal < clusterConeSize_ && MaxHit.hitenergy > 0.) - //if(dr0.) - { - - eHcalCone += enehit; - UsedCells++; - - int DIETA = 100; - if(MaxHit.ietahitm*(hhit->id()).ieta()>0) - { DIETA = MaxHit.ietahitm - (hhit->id()).ieta();} - if(MaxHit.ietahitm*(hhit->id()).ieta()<0) - { DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); DIETA = DIETA>0 ? DIETA-1 : DIETA+1;} - int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); - DIPHI = DIPHI>36 ? 72-DIPHI : DIPHI; - - - if (abs(DIETA)<=2 && (abs(DIPHI)<=2 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=4) && !( (abs(MaxHit.ietahitm)==21 || abs(MaxHit.ietahitm)==22) && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>2) )) ) - {e5x5 += hhit->energy();} - if (abs(DIETA)<=1 && (abs(DIPHI)<=1 || ((abs(MaxHit.ietahitm)>20 && abs(DIPHI)<=2) && !(abs(MaxHit.ietahitm)==21 && abs((hhit->id()).ieta())<=20 && abs(DIPHI)>1) )) ) - {e3x3 += hhit->energy();} - - for (HFRecHitCollection::const_iterator hhit2=Hithf.begin(); hhit2!=Hithf.end(); hhit2++) - { - recal = RecalibFactor(hhit2->detid()); - - int iphihit2 = (hhit2->id()).iphi(); - int ietahit2 = (hhit2->id()).ieta(); - int depthhit2 = (hhit2->id()).depth(); - float enehit2 = hhit2->energy()* recal; - - if (iphihitNoise == iphihit2 && ietahitNoise == ietahit2 && depthhitNoise == depthhit2 && enehit2>0.01) - { - eHcalConeNoise += hhit2->energy()*recal; - UsedCellsNoise++; - } - } - - } - } //end of all HF hits loop - - /* ---------------- -------------------- ---------------------------------------------- -------- */ - + GlobalPoint gPointEcal(xTrkEcal, yTrkEcal, zTrkEcal); - /* ------------- - Track-MC matching (if any tracks are in event) ------------ - */ - - nTracks=0; + eECAL = ecalEnergyInCone(gPointEcal, ecalCone_, Hitecal, geo); + eECAL09cm = ecalEnergyInCone(gPointEcal, 9, Hitecal, geo); + eECAL40cm = ecalEnergyInCone(gPointEcal, 40, Hitecal, geo); - delRmc[0] = 5; - - float delR_track_particle = 100; - - for (reco::TrackCollection::const_iterator track1=generalTracks->begin(); track1!=generalTracks->end(); track1++) - { - delR_track_particle = deltaR(etaParticle, phiParticle, track1->eta(), track1->phi()); - - trackEta[nTracks] = track1 -> eta(); - trackPhi[nTracks] = track1 -> phi(); - trackP[nTracks] = sqrt(track1->px()*track1->px() + track1->py()*track1->py() + track1->pz()*track1->pz()); - - delRmc[nTracks] = delR_track_particle; - numValidTrkHits[nTracks] = track1->hitPattern().numberOfValidHits(); - numValidTrkStrips[nTracks] = track1->hitPattern().numberOfValidStripTECHits(); - numLayers[nTracks] = track1->hitPattern().trackerLayersWithMeasurement(); //layers crossed - trkQual[nTracks] = track1->quality(reco::TrackBase::highPurity); - - nTracks++; - } - - - /* ------------------ ------------------------------ ------- */ - - - int dieta_M_P = 100; - int diphi_M_P = 100; - if(MaxHit.ietahitm*ietatrue>0) {dieta_M_P = abs (MaxHit.ietahitm-ietatrue);} - if(MaxHit.ietahitm*ietatrue<0) {dieta_M_P = abs(MaxHit.ietahitm-ietatrue)-1;} - diphi_M_P = abs(MaxHit.iphihitm-iphitrue); - - diphi_M_P = diphi_M_P>36 ? 72-diphi_M_P : diphi_M_P; - iDr = sqrt(diphi_M_P*diphi_M_P+dieta_M_P*dieta_M_P); - - /* if (iDr>15) + eEcalCone = eECAL; + //if(abs(etaecal)<1.5) enEcalB -> Fill(eEcalCone); + //if(abs(etaecal)>1.5 && abs(etaecal)<3.1) enEcalE -> Fill(eEcalCone); + + /* ------------------------------ -------------------------- ----------------- */ + + /* ----------------- Find the Hottest Hcal RecHit --------------------------- */ + MaxHit_struct MaxHit; + + MaxHit.hitenergy = -100.; + Float_t recal = 1.0; + + //Hcal: + eHcalCone = 0.; + eHcalConeNoise = 0.; + UsedCells = 0; + UsedCellsNoise = 0; + e3x3 = 0.; + e5x5 = 0.; + + for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) + //for (HcalRecHitCollection::const_iterator hhit=Hithcal.begin(); hhit!=Hithcal.end(); hhit++) + { + recal = RecalibFactor(hhit->detid()); + GlobalPoint pos = gHcal->getPosition(hhit->detid()); + + int iphihit = (hhit->id()).iphi(); + int ietahit = (hhit->id()).ieta(); + int depthhit = (hhit->id()).depth(); + float enehit = hhit->energy() * recal; + + if (depthhit != 1) + continue; + + double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); + + if (distAtHcal < clusterConeSize_) { + for (HBHERecHitCollection::const_iterator hhit2 = Hithbhe.begin(); hhit2 != Hithbhe.end(); hhit2++) + //for (HcalRecHitCollection::const_iterator hhit2=Hithcal.begin(); hhit2!=Hithcal.end(); hhit2++) + { + int iphihit2 = (hhit2->id()).iphi(); + int ietahit2 = (hhit2->id()).ieta(); + int depthhit2 = (hhit2->id()).depth(); + float enehit2 = hhit2->energy() * recal; + + if (iphihit == iphihit2 && ietahit == ietahit2 && depthhit != depthhit2) + enehit = enehit + enehit2; + } + + if (enehit > MaxHit.hitenergy) { + MaxHit.hitenergy = enehit; + MaxHit.ietahitm = (hhit->id()).ieta(); + MaxHit.iphihitm = (hhit->id()).iphi(); + MaxHit.dr = distAtHcal; + //MaxHit.depthhit = (hhit->id()).depth(); + MaxHit.depthhit = 1; + } + } + } + + for (HFRecHitCollection::const_iterator hhit = Hithf.begin(); hhit != Hithf.end(); hhit++) { + recal = RecalibFactor(hhit->detid()); + + GlobalPoint pos = gHcal->getPosition(hhit->detid()); + + int iphihit = (hhit->id()).iphi(); + int ietahit = (hhit->id()).ieta(); + int depthhit = (hhit->id()).depth(); + float enehit = hhit->energy() * recal; + + double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); + + if (distAtHcal < associationConeSize_) { + for (HFRecHitCollection::const_iterator hhit2 = Hithf.begin(); hhit2 != Hithf.end(); hhit2++) { + int iphihit2 = (hhit2->id()).iphi(); + int ietahit2 = (hhit2->id()).ieta(); + int depthhit2 = (hhit2->id()).depth(); + float enehit2 = hhit2->energy() * recal; + + if (iphihit == iphihit2 && ietahit == ietahit2 && depthhit != depthhit2) + enehit = enehit + enehit2; + } + + if (enehit > MaxHit.hitenergy) { + MaxHit.hitenergy = enehit; + MaxHit.ietahitm = (hhit->id()).ieta(); + MaxHit.iphihitm = (hhit->id()).iphi(); + MaxHit.dr = distAtHcal; + MaxHit.depthhit = 1; + } + } + } + + /* ---------------------- ---------------- -------------------------------------------- */ + + /* ----------- Collect Hcal Energy in a Cone (and also 3x3 and 5x5 around the hottest cell)*/ + + for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) + // for (HcalRecHitCollection::const_iterator hhit=Hithcal.begin(); hhit!=Hithcal.end(); hhit++) + { + recal = RecalibFactor(hhit->detid()); + //cout<<"recal: "<getPosition(hhit->detid()); + + int iphihit = (hhit->id()).iphi(); + int ietahit = (hhit->id()).ieta(); + int depthhit = (hhit->id()).depth(); + float enehit = hhit->energy() * recal; + + //if (depthhit!=1) continue; + + //Set noise RecHit opposite to track hits + int iphihitNoise = iphihit > 36 ? iphihit - 36 : iphihit + 36; + int ietahitNoise = -ietahit; + int depthhitNoise = depthhit; + + double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); + if (distAtHcal < clusterConeSize_ && MaxHit.hitenergy > 0.) { + eHcalCone += enehit; + UsedCells++; + + int DIETA = 100; + if (MaxHit.ietahitm * (hhit->id()).ieta() > 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + } + if (MaxHit.ietahitm * (hhit->id()).ieta() < 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1; + } + int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); + DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI; + + if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4) && + !((abs(MaxHit.ietahitm) == 21 || abs(MaxHit.ietahitm) == 22) && + abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)))) { + e5x5 += hhit->energy(); + } + if (abs(DIETA) <= 1 && + (abs(DIPHI) <= 1 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2) && + !(abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 1)))) { + e3x3 += hhit->energy(); + } + + // cout<<"track: ieta "<detid()); + int iphihit2 = (hhit2->id()).iphi(); + int ietahit2 = (hhit2->id()).ieta(); + int depthhit2 = (hhit2->id()).depth(); + float enehit2 = hhit2->energy() * recal; + + if (iphihitNoise == iphihit2 && ietahitNoise == ietahit2 && depthhitNoise == depthhit2 && enehit2 > 0.) { + eHcalConeNoise += hhit2->energy() * recal; + UsedCellsNoise++; + //cout<<"Noise: ieta "<detid()); + + GlobalPoint pos = gHcal->getPosition(hhit->detid()); + //float phihit = pos.phi(); + //float etahit = pos.eta(); + + int iphihit = (hhit->id()).iphi(); + int ietahit = (hhit->id()).ieta(); + int depthhit = (hhit->id()).depth(); + float enehit = hhit->energy() * recal; + + //Set noise RecHit opposite to track hits + int iphihitNoise = iphihit > 36 ? iphihit - 36 : iphihit + 36; + int ietahitNoise = -ietahit; + int depthhitNoise = depthhit; + + double distAtHcal = getDistInPlaneSimple(gPointHcal, pos); + + if (distAtHcal < clusterConeSize_ && MaxHit.hitenergy > 0.) + //if(dr0.) + { + eHcalCone += enehit; + UsedCells++; + + int DIETA = 100; + if (MaxHit.ietahitm * (hhit->id()).ieta() > 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + } + if (MaxHit.ietahitm * (hhit->id()).ieta() < 0) { + DIETA = MaxHit.ietahitm - (hhit->id()).ieta(); + DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1; + } + int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi()); + DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI; + + if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4) && + !((abs(MaxHit.ietahitm) == 21 || abs(MaxHit.ietahitm) == 22) && + abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)))) { + e5x5 += hhit->energy(); + } + if (abs(DIETA) <= 1 && + (abs(DIPHI) <= 1 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2) && + !(abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 1)))) { + e3x3 += hhit->energy(); + } + + for (HFRecHitCollection::const_iterator hhit2 = Hithf.begin(); hhit2 != Hithf.end(); hhit2++) { + recal = RecalibFactor(hhit2->detid()); + + int iphihit2 = (hhit2->id()).iphi(); + int ietahit2 = (hhit2->id()).ieta(); + int depthhit2 = (hhit2->id()).depth(); + float enehit2 = hhit2->energy() * recal; + + if (iphihitNoise == iphihit2 && ietahitNoise == ietahit2 && depthhitNoise == depthhit2 && enehit2 > 0.01) { + eHcalConeNoise += hhit2->energy() * recal; + UsedCellsNoise++; + } + } + } + } //end of all HF hits loop + + /* ---------------- -------------------- ---------------------------------------------- -------- */ + + /* ------------- - Track-MC matching (if any tracks are in event) ------------ - */ + + nTracks = 0; + + delRmc[0] = 5; + + float delR_track_particle = 100; + + for (reco::TrackCollection::const_iterator track1 = generalTracks->begin(); track1 != generalTracks->end(); + track1++) { + delR_track_particle = deltaR(etaParticle, phiParticle, track1->eta(), track1->phi()); + + trackEta[nTracks] = track1->eta(); + trackPhi[nTracks] = track1->phi(); + trackP[nTracks] = sqrt(track1->px() * track1->px() + track1->py() * track1->py() + track1->pz() * track1->pz()); + + delRmc[nTracks] = delR_track_particle; + numValidTrkHits[nTracks] = track1->hitPattern().numberOfValidHits(); + numValidTrkStrips[nTracks] = track1->hitPattern().numberOfValidStripTECHits(); + numLayers[nTracks] = track1->hitPattern().trackerLayersWithMeasurement(); //layers crossed + trkQual[nTracks] = track1->quality(reco::TrackBase::highPurity); + + nTracks++; + } + + /* ------------------ ------------------------------ ------- */ + + int dieta_M_P = 100; + int diphi_M_P = 100; + if (MaxHit.ietahitm * ietatrue > 0) { + dieta_M_P = abs(MaxHit.ietahitm - ietatrue); + } + if (MaxHit.ietahitm * ietatrue < 0) { + dieta_M_P = abs(MaxHit.ietahitm - ietatrue) - 1; + } + diphi_M_P = abs(MaxHit.iphihitm - iphitrue); + + diphi_M_P = diphi_M_P > 36 ? 72 - diphi_M_P : diphi_M_P; + iDr = sqrt(diphi_M_P * diphi_M_P + dieta_M_P * dieta_M_P); + + /* if (iDr>15) { cout<<"diphi: "<0.) passCuts = kTRUE; - Bool_t passCuts = kFALSE; - passCuts=kTRUE; - //if(eEcalCone < energyECALmip && iDr<2.) passCuts = kTRUE; - //if(MaxHit.hitenergy>0.) passCuts = kTRUE; - - - if(passCuts) - { - /* + if (passCuts) { + /* enHcal -> Fill(ietatrue, eHcalCone); nCells -> Fill(ietatrue, UsedCells); enHcalNoise -> Fill(ietatrue, eHcalConeNoise); nCellsNoise -> Fill(ietatrue, UsedCellsNoise); */ + //e3x3=0; e5x5=0; - //e3x3=0; e5x5=0; + iEta = ietatrue; + iPhi = iphitrue; - iEta = ietatrue; - iPhi = iphitrue; + //iEta = MaxHit.ietahitm; + //iPhi = MaxHit.iphihitm; + delR = MaxHit.dr; + eCentHit = MaxHit.hitenergy; - //iEta = MaxHit.ietahitm; - //iPhi = MaxHit.iphihitm; - delR = MaxHit.dr; - eCentHit = MaxHit.hitenergy; + eParticle = mom_MC; + //eTrack = mom_MC; + //phiTrack = phiParticle; + //etaTrack = etaParticle; - eParticle = mom_MC; - //eTrack = mom_MC; - //phiTrack = phiParticle; - //etaTrack = etaParticle; + pfTree->Fill(); + } - pfTree->Fill(); - } + } //Hep:MC +} - } //Hep:MC +void HcalCorrPFCalculation::beginJob() { + pfTree = fs->make("pfTree", "Tree for pf info"); + pfTree->Branch("nTracks", &nTracks, "nTracks/I"); + pfTree->Branch("trackEta", trackEta, "trackEta[nTracks]/F"); + pfTree->Branch("trackPhi", trackPhi, "trackPhi[nTracks]/F"); + pfTree->Branch("trackP", trackP, "trackP[nTracks]/F"); -} + pfTree->Branch("delRmc", delRmc, "delRmc[nTracks]/F"); + pfTree->Branch("numValidTrkHits", numValidTrkHits, "numValidTrkHits[nTracks]/I"); + pfTree->Branch("numValidTrkStrips", numValidTrkStrips, "numValidTrkStrips[nTracks]/I"); + pfTree->Branch("numLayers", numLayers, "numLayers[nTracks]/I"); + pfTree->Branch("trkQual", trkQual, "trkQual[nTracks]/O"); -void HcalCorrPFCalculation::beginJob(){ - - pfTree = fs -> make("pfTree", "Tree for pf info"); - - - pfTree->Branch("nTracks", &nTracks, "nTracks/I"); - pfTree->Branch("trackEta", trackEta, "trackEta[nTracks]/F"); - pfTree->Branch("trackPhi", trackPhi, "trackPhi[nTracks]/F"); - pfTree->Branch("trackP", trackP, "trackP[nTracks]/F"); - - pfTree->Branch("delRmc", delRmc, "delRmc[nTracks]/F"); - pfTree->Branch("numValidTrkHits", numValidTrkHits, "numValidTrkHits[nTracks]/I"); - pfTree->Branch("numValidTrkStrips", numValidTrkStrips, "numValidTrkStrips[nTracks]/I"); - pfTree->Branch("numLayers", numLayers, "numLayers[nTracks]/I"); - pfTree->Branch("trkQual", trkQual, "trkQual[nTracks]/O"); - - pfTree->Branch("eEcalCone", &eEcalCone, "eEcalCone/F"); pfTree->Branch("eHcalCone", &eHcalCone, "eHcalCone/F"); pfTree->Branch("eHcalConeNoise", &eHcalConeNoise, "eHcalConeNoise/F"); - + pfTree->Branch("UsedCellsNoise", &UsedCellsNoise, "UsedCellsNoise/I"); pfTree->Branch("UsedCells", &UsedCells, "UsedCells/I"); - - pfTree->Branch("eCentHit", &eCentHit , "eCentHit/F"); + + pfTree->Branch("eCentHit", &eCentHit, "eCentHit/F"); pfTree->Branch("eParticle", &eParticle, "eParticle/F"); pfTree->Branch("etaParticle", &etaParticle, "etaParticle/F"); @@ -791,34 +749,29 @@ void HcalCorrPFCalculation::beginJob(){ pfTree->Branch("xAtHcal", &xAtHcal, "xAtHcal/F"); pfTree->Branch("yAtHcal", &yAtHcal, "yAtHcal/F"); pfTree->Branch("zAtHcal", &zAtHcal, "zAtHcal/F"); - + pfTree->Branch("eECAL09cm", &eECAL09cm, "eECAL09cm/F"); pfTree->Branch("eECAL40cm", &eECAL40cm, "eECAL40cm/F"); pfTree->Branch("eECAL", &eECAL, "eECAL/F"); - pfTree->Branch("e3x3 ", &e3x3 , "e3x3/F"); - pfTree->Branch("e5x5", &e5x5 , "e5x5/F"); + pfTree->Branch("e3x3 ", &e3x3, "e3x3/F"); + pfTree->Branch("e5x5", &e5x5, "e5x5/F"); pfTree->Branch("iDr", &iDr, "iDr/F"); pfTree->Branch("delR", &delR, "delR/F"); - pfTree->Branch("iEta", &iEta, "iEta/I"); - pfTree->Branch("iPhi", &iPhi, "iPhi/I"); - - // pfTree->Branch("numValidTrkHits", &numValidTrkHits, "numValidTrkHits/I"); - // pfTree->Branch("numValidTrkStrips", &numValidTrkStrips, "numValidTrkStrips/I"); - // pfTree->Branch("trkQual", &trkQual, "trkQual/"); - // pfTree->Branch("numLayers", &numLayers, "numLayers/I"); + pfTree->Branch("iEta", &iEta, "iEta/I"); + pfTree->Branch("iPhi", &iPhi, "iPhi/I"); + // pfTree->Branch("numValidTrkHits", &numValidTrkHits, "numValidTrkHits/I"); + // pfTree->Branch("numValidTrkStrips", &numValidTrkStrips, "numValidTrkStrips/I"); + // pfTree->Branch("trkQual", &trkQual, "trkQual/"); + // pfTree->Branch("numLayers", &numLayers, "numLayers/I"); } - -void HcalCorrPFCalculation::endJob() -{} - +void HcalCorrPFCalculation::endJob() {} #include "FWCore/Framework/interface/MakerMacros.h" - //define this as a plug-in DEFINE_FWK_MODULE(HcalCorrPFCalculation); diff --git a/Calibration/HcalCalibAlgos/test/HcalIsoTrackStudy.cc b/Calibration/HcalCalibAlgos/test/HcalIsoTrackStudy.cc index 1134e8ab7619d..68b43f20a82e6 100644 --- a/Calibration/HcalCalibAlgos/test/HcalIsoTrackStudy.cc +++ b/Calibration/HcalCalibAlgos/test/HcalIsoTrackStudy.cc @@ -85,8 +85,7 @@ #define EDM_ML_DEBUG -class HcalIsoTrackStudy : public edm::one::EDAnalyzer { - +class HcalIsoTrackStudy : public edm::one::EDAnalyzer { public: explicit HcalIsoTrackStudy(edm::ParameterSet const&); ~HcalIsoTrackStudy() override {} @@ -98,317 +97,295 @@ class HcalIsoTrackStudy : public edm::one::EDAnalyzer fillTree(std::vector< math::XYZTLorentzVector>& vecL1, - std::vector< math::XYZTLorentzVector>& vecL3, - math::XYZPoint& leadPV, - std::vector& trkCaloDirections, - std::vector& trkCaloDets, - const CaloGeometry* geo, const CaloTopology* topo, - const HcalTopology* theHBHETopology, - const EcalChannelStatus* theEcalChStatus, - const EcalSeverityLevelAlgo* theEcalSevlv, - edm::Handle& barrelRecHitsHandle, - edm::Handle& endcapRecHitsHandle, - edm::Handle& hbhe, - edm::Handle& towerHandle, - edm::Handle& genParticles, - const HcalRespCorrs* respCorrs); + + std::array fillTree(std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* topo, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& towerHandle, + edm::Handle& genParticles, + const HcalRespCorrs* respCorrs); double dR(math::XYZTLorentzVector&, math::XYZTLorentzVector&); - double trackP(const reco::Track* , - const edm::Handle&); - double trackE(const reco::Track* , - const edm::Handle&); + double trackP(const reco::Track*, const edm::Handle&); + double trackE(const reco::Track*, const edm::Handle&); double rhoh(const edm::Handle&); - void storeEnergy(int indx, const HcalRespCorrs* respCorrs, - const std::vector& ids, - std::vector& edet, double & eHcal, - std::vector *detIds, - std::vector *hitEnergies); + void storeEnergy(int indx, + const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector* detIds, + std::vector* hitEnergies); void fillECALmatrix(const DetId& detId, - edm::Handle& hitsEB, - edm::Handle& hitsEE, - const CaloGeometry* geo, - const CaloTopology* caloTopology, - const reco::Track* pTrack, - int ieta, int iphi); + edm::Handle& hitsEB, + edm::Handle& hitsEE, + const CaloGeometry* geo, + const CaloTopology* caloTopology, + const reco::Track* pTrack, + int ieta, + int iphi); void fillHCALmatrix(const HcalTopology* topology, - const DetId& detId, - edm::Handle& hbhe, - const CaloGeometry* geo, - const reco::Track* pTrack, - int ieta, int iphi); - void TrackMap(unsigned int trkIndex, - std::vector & trkDirs, - double dR); - - - l1t::L1TGlobalUtil *l1GtUtils_; - edm::Service fs; - HLTConfigProvider hltConfig_; + const DetId& detId, + edm::Handle& hbhe, + const CaloGeometry* geo, + const reco::Track* pTrack, + int ieta, + int iphi); + void TrackMap(unsigned int trkIndex, std::vector& trkDirs, double dR); + + l1t::L1TGlobalUtil* l1GtUtils_; + edm::Service fs; + HLTConfigProvider hltConfig_; const std::vector trigNames_; - spr::trackSelectionParameters selectionParameter_; - const std::string theTrackQuality_; - const std::string processName_, l1Filter_; - const std::string l2Filter_, l3Filter_; - const double a_coneR_, a_mipR_, pTrackMin_, eEcalMax_; - const double maxRestrictionP_, slopeRestrictionP_; - const double hcalScale_, eIsolate1_, eIsolate2_; - const double pTrackLow_, pTrackHigh_; - const int prescaleLow_, prescaleHigh_; - const int useRaw_, dataType_, mode_; - const bool ignoreTrigger_, useL1Trigger_; - const bool unCorrect_, collapseDepth_; - const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; - const double hitEthrEE2_, hitEthrEE3_; - const edm::InputTag triggerEvent_, theTriggerResultsLabel_; - const std::string labelGenTrack_, labelRecVtx_, labelEB_; - const std::string labelEE_, labelHBHE_, labelTower_,l1TrigName_; - const int matrixECAL_, matrixHCAL_; - const double mapR_; - const bool get2Ddist_; - unsigned int nRun_, nLow_, nHigh_; - double a_charIsoR_, a_coneR1_, a_coneR2_; - const HcalDDDRecConstants *hdc_; - std::vector etabins_, phibins_; - double etadist_, phidist_, etahalfdist_,phihalfdist_; - edm::EDGetTokenT tok_trigEvt_; - edm::EDGetTokenT tok_trigRes_; + spr::trackSelectionParameters selectionParameter_; + const std::string theTrackQuality_; + const std::string processName_, l1Filter_; + const std::string l2Filter_, l3Filter_; + const double a_coneR_, a_mipR_, pTrackMin_, eEcalMax_; + const double maxRestrictionP_, slopeRestrictionP_; + const double hcalScale_, eIsolate1_, eIsolate2_; + const double pTrackLow_, pTrackHigh_; + const int prescaleLow_, prescaleHigh_; + const int useRaw_, dataType_, mode_; + const bool ignoreTrigger_, useL1Trigger_; + const bool unCorrect_, collapseDepth_; + const double hitEthrEB_, hitEthrEE0_, hitEthrEE1_; + const double hitEthrEE2_, hitEthrEE3_; + const edm::InputTag triggerEvent_, theTriggerResultsLabel_; + const std::string labelGenTrack_, labelRecVtx_, labelEB_; + const std::string labelEE_, labelHBHE_, labelTower_, l1TrigName_; + const int matrixECAL_, matrixHCAL_; + const double mapR_; + const bool get2Ddist_; + unsigned int nRun_, nLow_, nHigh_; + double a_charIsoR_, a_coneR1_, a_coneR2_; + const HcalDDDRecConstants* hdc_; + std::vector etabins_, phibins_; + double etadist_, phidist_, etahalfdist_, phihalfdist_; + edm::EDGetTokenT tok_trigEvt_; + edm::EDGetTokenT tok_trigRes_; edm::EDGetTokenT tok_parts_; - edm::EDGetTokenT tok_genTrack_; - edm::EDGetTokenT tok_recVtx_; - edm::EDGetTokenT tok_bs_; - edm::EDGetTokenT tok_EB_; - edm::EDGetTokenT tok_EE_; - edm::EDGetTokenT tok_hbhe_; - edm::EDGetTokenT tok_cala_; - edm::EDGetTokenT tok_ew_; - edm::EDGetTokenT> tok_alg_; - - TTree *tree, *tree2; - unsigned int t_RunNo, t_EventNo; - int t_Run, t_Event, t_DataType, t_ieta, t_iphi; - int t_goodPV, t_nVtx, t_nTrk; - double t_EventWeight, t_p, t_pt, t_phi; - std::vector *t_mapP,*t_mapPt,*t_mapEta,*t_mapPhi; - double t_l1pt, t_l1eta, t_l1phi; - double t_l3pt, t_l3eta, t_l3phi; - double t_mindR1, t_mindR2; - double t_eMipDR, t_hmaxNearP, t_gentrackP, t_gentrackE; - double t_emaxNearP, t_eAnnular, t_hAnnular; - double t_eHcal, t_eHcal10, t_eHcal30, t_rhoh; - bool t_selectTk, t_qltyFlag, t_qltyMissFlag; - bool t_qltyPVFlag, t_TrigPass, t_TrigPassSel; - std::vector *t_DetIds, *t_DetIds1, *t_DetIds3; - std::vector *t_HitEnergies, *t_HitEnergies1, *t_HitEnergies3; - std::vector *t_trgbits, *t_hltbits; - bool t_L1Bit; - int t_Tracks, t_TracksProp, t_TracksSaved; - int t_TracksLoose, t_TracksTight, t_allvertex; - std::vector *t_ietaAll, *t_ietaGood, *t_trackType; - std::vector *t_DetIdEC, *t_DetIdHC; - std::vector *t_HitEnergyEC, *t_HitDistEC; - std::vector *t_HitEnergyHC, *t_HitDistHC; + edm::EDGetTokenT tok_genTrack_; + edm::EDGetTokenT tok_recVtx_; + edm::EDGetTokenT tok_bs_; + edm::EDGetTokenT tok_EB_; + edm::EDGetTokenT tok_EE_; + edm::EDGetTokenT tok_hbhe_; + edm::EDGetTokenT tok_cala_; + edm::EDGetTokenT tok_ew_; + edm::EDGetTokenT> tok_alg_; + + TTree *tree, *tree2; + unsigned int t_RunNo, t_EventNo; + int t_Run, t_Event, t_DataType, t_ieta, t_iphi; + int t_goodPV, t_nVtx, t_nTrk; + double t_EventWeight, t_p, t_pt, t_phi; + std::vector*t_mapP, *t_mapPt, *t_mapEta, *t_mapPhi; + double t_l1pt, t_l1eta, t_l1phi; + double t_l3pt, t_l3eta, t_l3phi; + double t_mindR1, t_mindR2; + double t_eMipDR, t_hmaxNearP, t_gentrackP, t_gentrackE; + double t_emaxNearP, t_eAnnular, t_hAnnular; + double t_eHcal, t_eHcal10, t_eHcal30, t_rhoh; + bool t_selectTk, t_qltyFlag, t_qltyMissFlag; + bool t_qltyPVFlag, t_TrigPass, t_TrigPassSel; + std::vector*t_DetIds, *t_DetIds1, *t_DetIds3; + std::vector*t_HitEnergies, *t_HitEnergies1, *t_HitEnergies3; + std::vector*t_trgbits, *t_hltbits; + bool t_L1Bit; + int t_Tracks, t_TracksProp, t_TracksSaved; + int t_TracksLoose, t_TracksTight, t_allvertex; + std::vector*t_ietaAll, *t_ietaGood, *t_trackType; + std::vector*t_DetIdEC, *t_DetIdHC; + std::vector*t_HitEnergyEC, *t_HitDistEC; + std::vector*t_HitEnergyHC, *t_HitDistHC; }; -HcalIsoTrackStudy::HcalIsoTrackStudy(const edm::ParameterSet& iConfig) : - trigNames_(iConfig.getParameter >("triggers")), - theTrackQuality_(iConfig.getParameter("trackQuality")), - processName_(iConfig.getParameter("processName")), - l1Filter_(iConfig.getParameter("l1Filter")), - l2Filter_(iConfig.getParameter("l2Filter")), - l3Filter_(iConfig.getParameter("l3Filter")), - a_coneR_(iConfig.getParameter("coneRadius")), - a_mipR_(iConfig.getParameter("coneRadiusMIP")), - pTrackMin_(iConfig.getParameter("minimumTrackP")), - eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), - maxRestrictionP_(iConfig.getParameter("maxTrackP")), - slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), - hcalScale_(iConfig.getUntrackedParameter("hHcalScale",1.0)), - eIsolate1_(iConfig.getParameter("isolationEnergyTight")), - eIsolate2_(iConfig.getParameter("isolationEnergyLoose")), - pTrackLow_(iConfig.getParameter("momentumLow")), - pTrackHigh_(iConfig.getParameter("momentumHigh")), - prescaleLow_(iConfig.getParameter("prescaleLow")), - prescaleHigh_(iConfig.getParameter("prescaleHigh")), - useRaw_(iConfig.getUntrackedParameter("useRaw",0)), - dataType_(iConfig.getUntrackedParameter("dataType",0)), - mode_(iConfig.getUntrackedParameter("outMode",11)), - ignoreTrigger_(iConfig.getUntrackedParameter("ignoreTriggers",false)), - useL1Trigger_(iConfig.getUntrackedParameter("useL1Trigger",false)), - unCorrect_(iConfig.getUntrackedParameter("unCorrect",false)), - collapseDepth_(iConfig.getUntrackedParameter("collapseDepth",false)), - hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold") ), - hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0") ), - hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1") ), - hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2") ), - hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3") ), - triggerEvent_(iConfig.getParameter("labelTriggerEvent")), - theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), - labelGenTrack_(iConfig.getParameter("labelTrack")), - labelRecVtx_(iConfig.getParameter("labelVertex")), - labelEB_(iConfig.getParameter("labelEBRecHit")), - labelEE_(iConfig.getParameter("labelEERecHit")), - labelHBHE_(iConfig.getParameter("labelHBHERecHit")), - labelTower_(iConfig.getParameter("labelCaloTower")), - l1TrigName_(iConfig.getUntrackedParameter("l1TrigName","L1_SingleJet60")), - matrixECAL_(iConfig.getUntrackedParameter("matrixECAL",5)), - matrixHCAL_(iConfig.getUntrackedParameter("matrixHCAL",3)), - mapR_(iConfig.getUntrackedParameter("mapRadius",34.98)), - get2Ddist_(iConfig.getUntrackedParameter("get2Ddist",false)), - nRun_(0), nLow_(0), nHigh_(0), hdc_(nullptr) { - +HcalIsoTrackStudy::HcalIsoTrackStudy(const edm::ParameterSet& iConfig) + : trigNames_(iConfig.getParameter>("triggers")), + theTrackQuality_(iConfig.getParameter("trackQuality")), + processName_(iConfig.getParameter("processName")), + l1Filter_(iConfig.getParameter("l1Filter")), + l2Filter_(iConfig.getParameter("l2Filter")), + l3Filter_(iConfig.getParameter("l3Filter")), + a_coneR_(iConfig.getParameter("coneRadius")), + a_mipR_(iConfig.getParameter("coneRadiusMIP")), + pTrackMin_(iConfig.getParameter("minimumTrackP")), + eEcalMax_(iConfig.getParameter("maximumEcalEnergy")), + maxRestrictionP_(iConfig.getParameter("maxTrackP")), + slopeRestrictionP_(iConfig.getParameter("slopeTrackP")), + hcalScale_(iConfig.getUntrackedParameter("hHcalScale", 1.0)), + eIsolate1_(iConfig.getParameter("isolationEnergyTight")), + eIsolate2_(iConfig.getParameter("isolationEnergyLoose")), + pTrackLow_(iConfig.getParameter("momentumLow")), + pTrackHigh_(iConfig.getParameter("momentumHigh")), + prescaleLow_(iConfig.getParameter("prescaleLow")), + prescaleHigh_(iConfig.getParameter("prescaleHigh")), + useRaw_(iConfig.getUntrackedParameter("useRaw", 0)), + dataType_(iConfig.getUntrackedParameter("dataType", 0)), + mode_(iConfig.getUntrackedParameter("outMode", 11)), + ignoreTrigger_(iConfig.getUntrackedParameter("ignoreTriggers", false)), + useL1Trigger_(iConfig.getUntrackedParameter("useL1Trigger", false)), + unCorrect_(iConfig.getUntrackedParameter("unCorrect", false)), + collapseDepth_(iConfig.getUntrackedParameter("collapseDepth", false)), + hitEthrEB_(iConfig.getParameter("EBHitEnergyThreshold")), + hitEthrEE0_(iConfig.getParameter("EEHitEnergyThreshold0")), + hitEthrEE1_(iConfig.getParameter("EEHitEnergyThreshold1")), + hitEthrEE2_(iConfig.getParameter("EEHitEnergyThreshold2")), + hitEthrEE3_(iConfig.getParameter("EEHitEnergyThreshold3")), + triggerEvent_(iConfig.getParameter("labelTriggerEvent")), + theTriggerResultsLabel_(iConfig.getParameter("labelTriggerResult")), + labelGenTrack_(iConfig.getParameter("labelTrack")), + labelRecVtx_(iConfig.getParameter("labelVertex")), + labelEB_(iConfig.getParameter("labelEBRecHit")), + labelEE_(iConfig.getParameter("labelEERecHit")), + labelHBHE_(iConfig.getParameter("labelHBHERecHit")), + labelTower_(iConfig.getParameter("labelCaloTower")), + l1TrigName_(iConfig.getUntrackedParameter("l1TrigName", "L1_SingleJet60")), + matrixECAL_(iConfig.getUntrackedParameter("matrixECAL", 5)), + matrixHCAL_(iConfig.getUntrackedParameter("matrixHCAL", 3)), + mapR_(iConfig.getUntrackedParameter("mapRadius", 34.98)), + get2Ddist_(iConfig.getUntrackedParameter("get2Ddist", false)), + nRun_(0), + nLow_(0), + nHigh_(0), + hdc_(nullptr) { usesResource(TFileService::kSharedResource); //now do whatever initialization is needed const double isolationRadius(28.9), innerR(10.0), outerR(30.0); - reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality_); - selectionParameter_.minPt = iConfig.getParameter("minTrackPt");; - selectionParameter_.minQuality = trackQuality_; - selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); - selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); - selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); - selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); - selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); + reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality_); + selectionParameter_.minPt = iConfig.getParameter("minTrackPt"); + ; + selectionParameter_.minQuality = trackQuality_; + selectionParameter_.maxDxyPV = iConfig.getParameter("maxDxyPV"); + selectionParameter_.maxDzPV = iConfig.getParameter("maxDzPV"); + selectionParameter_.maxChi2 = iConfig.getParameter("maxChi2"); + selectionParameter_.maxDpOverP = iConfig.getParameter("maxDpOverP"); + selectionParameter_.minOuterHit = iConfig.getParameter("minOuterHit"); selectionParameter_.minLayerCrossed = iConfig.getParameter("minLayerCrossed"); - selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); - selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); - a_charIsoR_ = a_coneR_ + isolationRadius; - a_coneR1_ = a_coneR_ + innerR; - a_coneR2_ = a_coneR_ + outerR; + selectionParameter_.maxInMiss = iConfig.getParameter("maxInMiss"); + selectionParameter_.maxOutMiss = iConfig.getParameter("maxOutMiss"); + a_charIsoR_ = a_coneR_ + isolationRadius; + a_coneR1_ = a_coneR_ + innerR; + a_coneR2_ = a_coneR_ + outerR; // Different isolation cuts are described in DN-2016/029 // Tight cut uses 2 GeV; Loose cut uses 10 GeV // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18)) // with the factor for exponential slopeRestrictionP_ = log(2.5)/18 // maxRestrictionP_ = 8 GeV as came from a study - std::string labelBS = iConfig.getParameter("labelBeamSpot"); - std::string modnam = iConfig.getUntrackedParameter("moduleName",""); - std::string prdnam = iConfig.getUntrackedParameter("producerName",""); - edm::InputTag algTag = iConfig.getParameter("algInputTag"); - edm::InputTag extTag = iConfig.getParameter("extInputTag"); - l1GtUtils_ = new l1t::L1TGlobalUtil(iConfig, consumesCollector(), *this, algTag, extTag); + std::string labelBS = iConfig.getParameter("labelBeamSpot"); + std::string modnam = iConfig.getUntrackedParameter("moduleName", ""); + std::string prdnam = iConfig.getUntrackedParameter("producerName", ""); + edm::InputTag algTag = iConfig.getParameter("algInputTag"); + edm::InputTag extTag = iConfig.getParameter("extInputTag"); + l1GtUtils_ = new l1t::L1TGlobalUtil(iConfig, consumesCollector(), *this, algTag, extTag); // define tokens for access - tok_trigEvt_ = consumes(triggerEvent_); - tok_trigRes_ = consumes(theTriggerResultsLabel_); - tok_bs_ = consumes(labelBS); + tok_trigEvt_ = consumes(triggerEvent_); + tok_trigRes_ = consumes(theTriggerResultsLabel_); + tok_bs_ = consumes(labelBS); tok_genTrack_ = consumes(labelGenTrack_); - tok_ew_ = consumes(edm::InputTag("generator")); - tok_parts_ = consumes(edm::InputTag("genParticles")); - tok_cala_ = consumes(labelTower_); - tok_alg_ = consumes>(algTag); + tok_ew_ = consumes(edm::InputTag("generator")); + tok_parts_ = consumes(edm::InputTag("genParticles")); + tok_cala_ = consumes(labelTower_); + tok_alg_ = consumes>(algTag); if (modnam.empty()) { - tok_recVtx_ = consumes(labelRecVtx_); - tok_EB_ = consumes(edm::InputTag("ecalRecHit",labelEB_)); - tok_EE_ = consumes(edm::InputTag("ecalRecHit",labelEE_)); - tok_hbhe_ = consumes(labelHBHE_); - edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " - << theTriggerResultsLabel_ << " " - << labelBS << " " << labelRecVtx_ << " " - << labelGenTrack_ << " " - << edm::InputTag("ecalRecHit",labelEB_) - << " " - << edm::InputTag("ecalRecHit",labelEE_) - << " " << labelHBHE_ << " " << labelTower_; + tok_recVtx_ = consumes(labelRecVtx_); + tok_EB_ = consumes(edm::InputTag("ecalRecHit", labelEB_)); + tok_EE_ = consumes(edm::InputTag("ecalRecHit", labelEE_)); + tok_hbhe_ = consumes(labelHBHE_); + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " " + << labelBS << " " << labelRecVtx_ << " " << labelGenTrack_ << " " + << edm::InputTag("ecalRecHit", labelEB_) << " " + << edm::InputTag("ecalRecHit", labelEE_) << " " << labelHBHE_ << " " + << labelTower_; } else { - tok_recVtx_ = consumes(edm::InputTag(modnam,labelRecVtx_,prdnam)); - tok_EB_ = consumes(edm::InputTag(modnam,labelEB_,prdnam)); - tok_EE_ = consumes(edm::InputTag(modnam,labelEE_,prdnam)); - tok_hbhe_ = consumes(edm::InputTag(modnam,labelHBHE_,prdnam)); - edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " - << theTriggerResultsLabel_ << " " - << labelBS << " " - << edm::InputTag(modnam,labelRecVtx_,prdnam) - << " " << labelGenTrack_ << " " - << edm::InputTag(modnam,labelEB_,prdnam) - << " " - << edm::InputTag(modnam,labelEE_,prdnam) - << " " - << edm::InputTag(modnam,labelHBHE_,prdnam) - << " " << labelTower_; + tok_recVtx_ = consumes(edm::InputTag(modnam, labelRecVtx_, prdnam)); + tok_EB_ = consumes(edm::InputTag(modnam, labelEB_, prdnam)); + tok_EE_ = consumes(edm::InputTag(modnam, labelEE_, prdnam)); + tok_hbhe_ = consumes(edm::InputTag(modnam, labelHBHE_, prdnam)); + edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " " + << labelBS << " " << edm::InputTag(modnam, labelRecVtx_, prdnam) << " " + << labelGenTrack_ << " " << edm::InputTag(modnam, labelEB_, prdnam) << " " + << edm::InputTag(modnam, labelEE_, prdnam) << " " + << edm::InputTag(modnam, labelHBHE_, prdnam) << " " << labelTower_; } - edm::LogVerbatim("HcalIsoTrack") <<"Parameters read from config file \n" - <<"\t minPt " << selectionParameter_.minPt - <<"\t theTrackQuality " << theTrackQuality_ - <<"\t minQuality " << selectionParameter_.minQuality - <<"\t maxDxyPV " << selectionParameter_.maxDxyPV - <<"\t maxDzPV " << selectionParameter_.maxDzPV - <<"\t maxChi2 " << selectionParameter_.maxChi2 - <<"\t maxDpOverP " << selectionParameter_.maxDpOverP - <<"\t minOuterHit " << selectionParameter_.minOuterHit - <<"\t minLayerCrossed " << selectionParameter_.minLayerCrossed - <<"\t maxInMiss " << selectionParameter_.maxInMiss - <<"\t maxOutMiss " << selectionParameter_.maxOutMiss - <<"\t a_coneR " << a_coneR_ - << ":" << a_coneR1_ << ":" << a_coneR2_ - <<"\t a_charIsoR " << a_charIsoR_ - <<"\t a_mipR " << a_mipR_ - <<"\n pTrackMin_ " << pTrackMin_ - <<"\t eEcalMax_ " << eEcalMax_ - <<"\t maxRestrictionP_ "<< maxRestrictionP_ - <<"\t slopeRestrictionP_ " << slopeRestrictionP_ - <<"\t eIsolateStrong_ " << eIsolate1_ - <<"\t eIsolateSoft_ " << eIsolate2_ - <<"\t hcalScale_ " << hcalScale_ - <<"\n\t momentumLow_ " << pTrackLow_ - <<"\t prescaleLow_ " << prescaleLow_ - <<"\t momentumHigh_ " << pTrackHigh_ - <<"\t prescaleHigh_ " << prescaleHigh_ - <<"\n\t useRaw_ " << useRaw_ - <<"\t ignoreTrigger_ " << ignoreTrigger_ - <<"\n\t useL1Trigegr_ " << useL1Trigger_ - <<"\t dataType_ " << dataType_ - <<"\t mode_ " << mode_ - <<"\t unCorrect_ " << unCorrect_ - <<"\t collapseDepth_ " << collapseDepth_ - <<"\t L1TrigName_ " << l1TrigName_; - edm::LogVerbatim("HcalIsoTrack") << "Process " << processName_ - << " L1Filter:" << l1Filter_ << " L2Filter:" - << l2Filter_ << " L3Filter:" << l3Filter_; - for (unsigned int k=0; k bFieldH; iSetup.get().get(bFieldH); - const MagneticField *bField = bFieldH.product(); + const MagneticField* bField = bFieldH.product(); edm::ESHandle ecalChStatus; iSetup.get().get(ecalChStatus); const EcalChannelStatus* theEcalChStatus = ecalChStatus.product(); - + edm::ESHandle sevlv; iSetup.get().get(sevlv); const EcalSeverityLevelAlgo* theEcalSevlv = sevlv.product(); @@ -417,11 +394,11 @@ void HcalIsoTrackStudy::analyze(edm::Event const& iEvent, edm::EventSetup const& edm::ESHandle pG; iSetup.get().get(pG); const CaloGeometry* geo = pG.product(); - + edm::ESHandle theCaloTopology; - iSetup.get().get(theCaloTopology); - const CaloTopology *caloTopology = theCaloTopology.product(); - + iSetup.get().get(theCaloTopology); + const CaloTopology* caloTopology = theCaloTopology.product(); + edm::ESHandle htopo; iSetup.get().get(htopo); const HcalTopology* theHBHETopology = htopo.product(); @@ -434,105 +411,102 @@ void HcalIsoTrackStudy::analyze(edm::Event const& iEvent, edm::EventSetup const& //=== genParticle information edm::Handle genParticles; iEvent.getByToken(tok_parts_, genParticles); - + bool okC(true); //Get track collection edm::Handle trkCollection; iEvent.getByToken(tok_genTrack_, trkCollection); if (!trkCollection.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelGenTrack_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_; okC = false; } - + //event weight for FLAT sample t_EventWeight = 1.0; edm::Handle genEventInfo; iEvent.getByToken(tok_ew_, genEventInfo); - if (genEventInfo.isValid()) t_EventWeight = genEventInfo->weight(); + if (genEventInfo.isValid()) + t_EventWeight = genEventInfo->weight(); //Define the best vertex and the beamspot edm::Handle recVtxs; - iEvent.getByToken(tok_recVtx_, recVtxs); + iEvent.getByToken(tok_recVtx_, recVtxs); edm::Handle beamSpotH; iEvent.getByToken(tok_bs_, beamSpotH); - math::XYZPoint leadPV(0,0,0); + math::XYZPoint leadPV(0, 0, 0); t_goodPV = t_nVtx = 0; if (recVtxs.isValid() && !(recVtxs->empty())) { t_nVtx = recVtxs->size(); - for (unsigned int k=0; ksize(); ++k) { + for (unsigned int k = 0; k < recVtxs->size(); ++k) { if (!((*recVtxs)[k].isFake()) && ((*recVtxs)[k].ndof() > 4)) { - if (t_goodPV == 0) leadPV = math::XYZPoint((*recVtxs)[k].x(),(*recVtxs)[k].y(),(*recVtxs)[k].z()); - t_goodPV++; + if (t_goodPV == 0) + leadPV = math::XYZPoint((*recVtxs)[k].x(), (*recVtxs)[k].y(), (*recVtxs)[k].z()); + t_goodPV++; } } - } + } if (t_goodPV == 0 && beamSpotH.isValid()) { leadPV = beamSpotH->position(); } t_allvertex = t_goodPV; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " - << t_goodPV << " vertex"; + edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " << t_goodPV << " vertex"; if (beamSpotH.isValid()) { edm::LogVerbatim("HcalIsoTrack") << " Beam Spot " << beamSpotH->position(); } -#endif +#endif // RecHits edm::Handle barrelRecHitsHandle; iEvent.getByToken(tok_EB_, barrelRecHitsHandle); if (!barrelRecHitsHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelEB_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_; okC = false; } edm::Handle endcapRecHitsHandle; iEvent.getByToken(tok_EE_, endcapRecHitsHandle); if (!endcapRecHitsHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelEE_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_; okC = false; } edm::Handle hbhe; iEvent.getByToken(tok_hbhe_, hbhe); if (!hbhe.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " - << labelHBHE_; + edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_; okC = false; } edm::Handle caloTower; iEvent.getByToken(tok_cala_, caloTower); - + //Propagate tracks to calorimeter surface) std::vector trkCaloDirections; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDirections, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false); std::vector trkCaloDets; - spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, - trkCaloDets, false); + spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDets, false); std::vector vecL1, vecL3; - t_RunNo = iEvent.id().run(); - t_EventNo = iEvent.id().event(); - t_Tracks = trkCollection->size(); + t_RunNo = iEvent.id().run(); + t_EventNo = iEvent.id().event(); + t_Tracks = trkCollection->size(); t_TracksProp = trkCaloDirections.size(); - t_ietaAll->clear(); t_ietaGood->clear(); t_trackType->clear(); - t_trgbits->clear(); t_hltbits->clear(); + t_ietaAll->clear(); + t_ietaGood->clear(); + t_trackType->clear(); + t_trgbits->clear(); + t_hltbits->clear(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "# of propagated tracks " << t_TracksProp - << " out of " << t_Tracks << " with Trigger " - << ignoreTrigger_; + edm::LogVerbatim("HcalIsoTrack") << "# of propagated tracks " << t_TracksProp << " out of " << t_Tracks + << " with Trigger " << ignoreTrigger_; #endif //Trigger - t_trgbits->assign(trigNames_.size(),false); - t_hltbits->assign(trigNames_.size(),false); + t_trgbits->assign(trigNames_.size(), false); + t_hltbits->assign(trigNames_.size(), false); t_TracksSaved = t_TracksLoose = t_TracksTight = 0; - t_L1Bit = true; - t_TrigPass = false; + t_L1Bit = true; + t_TrigPass = false; //L1 - l1GtUtils_->retrieveL1(iEvent,iSetup,tok_alg_); - const std::vector > & finalDecisions = l1GtUtils_->decisionsFinal(); + l1GtUtils_->retrieveL1(iEvent, iSetup, tok_alg_); + const std::vector>& finalDecisions = l1GtUtils_->decisionsFinal(); for (const auto& decision : finalDecisions) { if (decision.first.find(l1TrigName_) != std::string::npos) { t_L1Bit = decision.second; @@ -540,49 +514,59 @@ void HcalIsoTrackStudy::analyze(edm::Event const& iEvent, edm::EventSetup const& } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ - << " is " << t_L1Bit << " from a list of " - << finalDecisions.size() << " decisions"; + edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ << " is " << t_L1Bit + << " from a list of " << finalDecisions.size() << " decisions"; #endif - + //HLT edm::Handle triggerResults; iEvent.getByToken(tok_trigRes_, triggerResults); if (triggerResults.isValid()) { - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & names = triggerNames.triggerNames(); + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); if (!trigNames_.empty()) { - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - int hlt = triggerResults->accept(iHLT); - for (unsigned int i=0; iat(i) = (hlt>0); - t_hltbits->at(i) = (hlt>0); - if (hlt>0) t_TrigPass = true; + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + int hlt = triggerResults->accept(iHLT); + for (unsigned int i = 0; i < trigNames_.size(); ++i) { + if (names[iHLT].find(trigNames_[i]) != std::string::npos) { + t_trgbits->at(i) = (hlt > 0); + t_hltbits->at(i) = (hlt > 0); + if (hlt > 0) + t_TrigPass = true; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This trigger " - << names[iHLT] << " Flag " - << hlt << ":" << t_trgbits->at(i); + edm::LogVerbatim("HcalIsoTrack") + << "This trigger " << names[iHLT] << " Flag " << hlt << ":" << t_trgbits->at(i); #endif - } - } + } + } } } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << t_TrigPass - << ":" << trigNames_.empty() << ":" << okC; + edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << t_TrigPass << ":" << trigNames_.empty() << ":" << okC; #endif - std::array ntksave{ {0,0,0} }; + std::array ntksave{{0, 0, 0}}; if (ignoreTrigger_ || useL1Trigger_) { - t_l1pt = t_l1eta = t_l1phi = 0; - t_l3pt = t_l3eta = t_l3phi = 0; + t_l1pt = t_l1eta = t_l1phi = 0; + t_l3pt = t_l3eta = t_l3phi = 0; if (ignoreTrigger_ || t_L1Bit) - ntksave = fillTree(vecL1, vecL3, leadPV, trkCaloDirections, trkCaloDets, - geo, caloTopology, theHBHETopology, theEcalChStatus, - theEcalSevlv, barrelRecHitsHandle, endcapRecHitsHandle, - hbhe, caloTower, genParticles, respCorrs); + ntksave = fillTree(vecL1, + vecL3, + leadPV, + trkCaloDirections, + trkCaloDets, + geo, + caloTopology, + theHBHETopology, + theEcalChStatus, + theEcalSevlv, + barrelRecHitsHandle, + endcapRecHitsHandle, + hbhe, + caloTower, + genParticles, + respCorrs); t_TracksSaved = ntksave[0]; t_TracksLoose = ntksave[1]; t_TracksTight = ntksave[2]; @@ -591,258 +575,253 @@ void HcalIsoTrackStudy::analyze(edm::Event const& iEvent, edm::EventSetup const& edm::Handle triggerEventHandle; iEvent.getByToken(tok_trigEvt_, triggerEventHandle); if (!triggerEventHandle.isValid()) { - edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " - << triggerEvent_.label() ; + edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " << triggerEvent_.label(); } else if (okC) { triggerEvent = *(triggerEventHandle.product()); const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects()); bool done(false); if (triggerResults.isValid()) { - std::vector modules; - const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults); - const std::vector & names = triggerNames.triggerNames(); - for (unsigned int iHLT=0; iHLTsize(); iHLT++) { - bool ok = (t_TrigPass) || (trigNames_.empty()); - if (ok) { - unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]); - const std::vector& moduleLabels(hltConfig_.moduleLabels(triggerindx)); - std::vector vecL2; - vecL1.clear(); vecL3.clear(); - //loop over all trigger filters in event (i.e. filters passed) - for (unsigned int ifilter=0; ifilter Keys; - std::string label = triggerEvent.filterTag(ifilter).label(); - //loop over keys to objects passing this filter - for (unsigned int imodule=0; imodule modules; + const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults); + const std::vector& names = triggerNames.triggerNames(); + for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) { + bool ok = (t_TrigPass) || (trigNames_.empty()); + if (ok) { + unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]); + const std::vector& moduleLabels(hltConfig_.moduleLabels(triggerindx)); + std::vector vecL2; + vecL1.clear(); + vecL3.clear(); + //loop over all trigger filters in event (i.e. filters passed) + for (unsigned int ifilter = 0; ifilter < triggerEvent.sizeFilters(); ++ifilter) { + std::vector Keys; + std::string label = triggerEvent.filterTag(ifilter).label(); + //loop over keys to objects passing this filter + for (unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) { + if (label.find(moduleLabels[imodule]) != std::string::npos) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label; + edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label; #endif - for (unsigned int ifiltrKey=0; ifiltrKey 0); tree2->Fill(); } void HcalIsoTrackStudy::beginJob() { - tree = fs->make("CalibTree", "CalibTree"); - - tree->Branch("t_Run", &t_Run, "t_Run/I"); - tree->Branch("t_Event", &t_Event, "t_Event/I"); - tree->Branch("t_DataType", &t_DataType, "t_DataType/I"); - tree->Branch("t_ieta", &t_ieta, "t_ieta/I"); - tree->Branch("t_iphi", &t_iphi, "t_iphi/I"); + + tree->Branch("t_Run", &t_Run, "t_Run/I"); + tree->Branch("t_Event", &t_Event, "t_Event/I"); + tree->Branch("t_DataType", &t_DataType, "t_DataType/I"); + tree->Branch("t_ieta", &t_ieta, "t_ieta/I"); + tree->Branch("t_iphi", &t_iphi, "t_iphi/I"); tree->Branch("t_EventWeight", &t_EventWeight, "t_EventWeight/D"); - tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I"); - tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I"); - tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I"); - if (((mode_/10)%10) == 1) { - tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D"); - tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D"); - tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D"); - tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D"); - tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D"); - tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D"); + tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I"); + tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I"); + tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I"); + if (((mode_ / 10) % 10) == 1) { + tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D"); + tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D"); + tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D"); + tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D"); + tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D"); + tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D"); } - tree->Branch("t_p", &t_p, "t_p/D"); - tree->Branch("t_pt", &t_pt, "t_pt/D"); - tree->Branch("t_phi", &t_phi, "t_phi/D"); - - t_mapP = new std::vector(); - t_mapPt = new std::vector(); - t_mapEta = new std::vector(); - t_mapPhi = new std::vector(); - tree->Branch("t_mapP", "std::vector", &t_mapP); - tree->Branch("t_mapPt", "std::vector", &t_mapPt); - tree->Branch("t_mapEta", "std::vector", &t_mapEta); - tree->Branch("t_mapPhi", "std::vector", &t_mapPhi); - - tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D"); - tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D"); - tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D"); - tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D"); - tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D"); - tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D"); - tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D"); - tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D"); - tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D"); - tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D"); - tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D"); - tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O"); - tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O"); - tree->Branch("t_qltyMissFlag",&t_qltyMissFlag,"t_qltyMissFlag/O"); - tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O"); - tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D"); - tree->Branch("t_gentrackE", &t_gentrackE, "t_gentrackE/D"); - - t_DetIds = new std::vector(); - t_DetIds1 = new std::vector(); - t_DetIds3 = new std::vector(); - t_DetIdEC = new std::vector(); - t_DetIdHC = new std::vector(); - t_HitEnergies = new std::vector(); + tree->Branch("t_p", &t_p, "t_p/D"); + tree->Branch("t_pt", &t_pt, "t_pt/D"); + tree->Branch("t_phi", &t_phi, "t_phi/D"); + + t_mapP = new std::vector(); + t_mapPt = new std::vector(); + t_mapEta = new std::vector(); + t_mapPhi = new std::vector(); + tree->Branch("t_mapP", "std::vector", &t_mapP); + tree->Branch("t_mapPt", "std::vector", &t_mapPt); + tree->Branch("t_mapEta", "std::vector", &t_mapEta); + tree->Branch("t_mapPhi", "std::vector", &t_mapPhi); + + tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D"); + tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D"); + tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D"); + tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D"); + tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D"); + tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D"); + tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D"); + tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D"); + tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D"); + tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D"); + tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D"); + tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O"); + tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O"); + tree->Branch("t_qltyMissFlag", &t_qltyMissFlag, "t_qltyMissFlag/O"); + tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O"); + tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D"); + tree->Branch("t_gentrackE", &t_gentrackE, "t_gentrackE/D"); + + t_DetIds = new std::vector(); + t_DetIds1 = new std::vector(); + t_DetIds3 = new std::vector(); + t_DetIdEC = new std::vector(); + t_DetIdHC = new std::vector(); + t_HitEnergies = new std::vector(); t_HitEnergies1 = new std::vector(); t_HitEnergies3 = new std::vector(); - t_HitEnergyEC = new std::vector(); - t_HitDistEC = new std::vector(); - t_HitEnergyHC = new std::vector(); - t_HitDistHC = new std::vector(); - t_trgbits = new std::vector(); - tree->Branch("t_DetIds", "std::vector", &t_DetIds); - tree->Branch("t_HitEnergies", "std::vector", &t_HitEnergies); - if (((mode_/10)%10) == 1) { - tree->Branch("t_trgbits", "std::vector", &t_trgbits); + t_HitEnergyEC = new std::vector(); + t_HitDistEC = new std::vector(); + t_HitEnergyHC = new std::vector(); + t_HitDistHC = new std::vector(); + t_trgbits = new std::vector(); + tree->Branch("t_DetIds", "std::vector", &t_DetIds); + tree->Branch("t_HitEnergies", "std::vector", &t_HitEnergies); + if (((mode_ / 10) % 10) == 1) { + tree->Branch("t_trgbits", "std::vector", &t_trgbits); } - if ((mode_%10) == 1) { - tree->Branch("t_DetIds1", "std::vector", &t_DetIds1); - tree->Branch("t_HitEnergies1", "std::vector", &t_HitEnergies1); - tree->Branch("t_DetIds3", "std::vector", &t_DetIds3); - tree->Branch("t_HitEnergies3", "std::vector", &t_HitEnergies3); - tree->Branch("t_DetIdEC", "std::vector", &t_DetIdEC); - tree->Branch("t_HitEnergyEC", "std::vector", &t_HitEnergyEC); - tree->Branch("t_HitDistEC", "std::vector", &t_HitDistEC); - tree->Branch("t_DetIdHC", "std::vector", &t_DetIdHC); - tree->Branch("t_HitEnergyHC", "std::vector", &t_HitEnergyHC); - tree->Branch("t_HitDistHC", "std::vector", &t_HitDistHC); + if ((mode_ % 10) == 1) { + tree->Branch("t_DetIds1", "std::vector", &t_DetIds1); + tree->Branch("t_HitEnergies1", "std::vector", &t_HitEnergies1); + tree->Branch("t_DetIds3", "std::vector", &t_DetIds3); + tree->Branch("t_HitEnergies3", "std::vector", &t_HitEnergies3); + tree->Branch("t_DetIdEC", "std::vector", &t_DetIdEC); + tree->Branch("t_HitEnergyEC", "std::vector", &t_HitEnergyEC); + tree->Branch("t_HitDistEC", "std::vector", &t_HitDistEC); + tree->Branch("t_DetIdHC", "std::vector", &t_DetIdHC); + tree->Branch("t_HitEnergyHC", "std::vector", &t_HitEnergyHC); + tree->Branch("t_HitDistHC", "std::vector", &t_HitDistHC); } tree2 = fs->make("EventInfo", "Event Information"); - - tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i"); - tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i"); - tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I"); - tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I"); + + tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i"); + tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i"); + tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I"); + tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I"); tree2->Branch("t_TracksSaved", &t_TracksSaved, "t_TracksSaved/I"); tree2->Branch("t_TracksLoose", &t_TracksLoose, "t_TracksLoose/I"); tree2->Branch("t_TracksTight", &t_TracksTight, "t_TracksTight/I"); - tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O"); + tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O"); tree2->Branch("t_TrigPassSel", &t_TrigPassSel, "t_TrigPassSel/O"); - tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O"); - tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I"); - t_hltbits = new std::vector(); - t_ietaAll = new std::vector(); - t_ietaGood = new std::vector(); - t_trackType = new std::vector(); - tree2->Branch("t_ietaAll", "std::vector", &t_ietaAll); - tree2->Branch("t_ietaGood", "std::vector", &t_ietaGood); - tree2->Branch("t_trackType", "std::vector", &t_trackType); - tree2->Branch("t_hltbits", "std::vector", &t_hltbits); + tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O"); + tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I"); + t_hltbits = new std::vector(); + t_ietaAll = new std::vector(); + t_ietaGood = new std::vector(); + t_trackType = new std::vector(); + tree2->Branch("t_ietaAll", "std::vector", &t_ietaAll); + tree2->Branch("t_ietaGood", "std::vector", &t_ietaGood); + tree2->Branch("t_trackType", "std::vector", &t_trackType); + tree2->Branch("t_hltbits", "std::vector", &t_hltbits); } - // ------------ method called when starting to processes a run ------------ -void HcalIsoTrackStudy::beginRun(edm::Run const& iRun, - edm::EventSetup const& iSetup) { +void HcalIsoTrackStudy::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { edm::ESHandle pHRNDC; iSetup.get().get(pHRNDC); hdc_ = pHRNDC.product(); bool changed_(true); - bool flag = hltConfig_.init(iRun,iSetup,processName_,changed_); - edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() - << " process " << processName_ - << " init flag " << flag << " change flag " - << changed_; - // check if trigger names in (new) config + bool flag = hltConfig_.init(iRun, iSetup, processName_, changed_); + edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " process " << processName_ + << " init flag " << flag << " change flag " << changed_; + // check if trigger names in (new) config if (changed_) { changed_ = false; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalIsoTrack") << "New trigger menu found !!!"; #endif const unsigned int n(hltConfig_.size()); - for (unsigned itrig=0; itrig= n) { - edm::LogWarning("HcalIsoTrack") << trigNames_[itrig] << " " - << triggerindx << " does not exist in " - << "the current menu"; + edm::LogWarning("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " does not exist in " + << "the current menu"; #ifdef EDM_ML_DEBUG } else { - edm::LogVerbatim("HcalIsoTrack") << trigNames_[itrig] << " " - << triggerindx << " exists"; + edm::LogVerbatim("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " exists"; #endif } } @@ -857,355 +836,396 @@ void HcalIsoTrackStudy::endRun(edm::Run const& iRun, edm::EventSetup const&) { void HcalIsoTrackStudy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - std::vector trig = {"HLT_PFJet40","HLT_PFJet60","HLT_PFJet80", - "HLT_PFJet140","HLT_PFJet200","HLT_PFJet260", - "HLT_PFJet320","HLT_PFJet400","HLT_PFJet450", - "HLT_PFJet500"}; - desc.add>("triggers",trig); - desc.add("processName","HLT"); - desc.add("l1Filter",""); - desc.add("l2Filter","L2Filter"); - desc.add("l3Filter","Filter"); + std::vector trig = {"HLT_PFJet40", + "HLT_PFJet60", + "HLT_PFJet80", + "HLT_PFJet140", + "HLT_PFJet200", + "HLT_PFJet260", + "HLT_PFJet320", + "HLT_PFJet400", + "HLT_PFJet450", + "HLT_PFJet500"}; + desc.add>("triggers", trig); + desc.add("processName", "HLT"); + desc.add("l1Filter", ""); + desc.add("l2Filter", "L2Filter"); + desc.add("l3Filter", "Filter"); // following 10 parameters are parameters to select good tracks - desc.add("trackQuality","highPurity"); - desc.add("minTrackPt",1.0); - desc.add("maxDxyPV",0.02); - desc.add("maxDzPV",0.02); - desc.add("maxChi2",5.0); - desc.add("maxDpOverP",0.1); - desc.add("minOuterHit",4); - desc.add("minLayerCrossed",8); - desc.add("maxInMiss",0); - desc.add("maxOutMiss",0); + desc.add("trackQuality", "highPurity"); + desc.add("minTrackPt", 1.0); + desc.add("maxDxyPV", 0.02); + desc.add("maxDzPV", 0.02); + desc.add("maxChi2", 5.0); + desc.add("maxDpOverP", 0.1); + desc.add("minOuterHit", 4); + desc.add("minLayerCrossed", 8); + desc.add("maxInMiss", 0); + desc.add("maxOutMiss", 0); // Minimum momentum of selected isolated track and signal zone - desc.add("minimumTrackP",20.0); - desc.add("coneRadius",34.98); + desc.add("minimumTrackP", 20.0); + desc.add("coneRadius", 34.98); // signal zone in ECAL and MIP energy cutoff - desc.add("coneRadiusMIP",14.0); - desc.add("maximumEcalEnergy",2.0); + desc.add("coneRadiusMIP", 14.0); + desc.add("maximumEcalEnergy", 2.0); // following 4 parameters are for isolation cuts and described in the code - desc.add("maxTrackP",8.0); - desc.add("slopeTrackP",0.05090504066); - desc.add("isolationEnergyTight",2.0); - desc.add("isolationEnergyLoose",10.0); + desc.add("maxTrackP", 8.0); + desc.add("slopeTrackP", 0.05090504066); + desc.add("isolationEnergyTight", 2.0); + desc.add("isolationEnergyLoose", 10.0); // energy thershold for ECAL (from Egamma group) - desc.add("EBHitEnergyThreshold",0.10); - desc.add("EEHitEnergyThreshold0",-41.0664); - desc.add("EEHitEnergyThreshold1",68.7950); - desc.add("EEHitEnergyThreshold2",-38.1483); - desc.add("EEHitEnergyThreshold3",7.04303); + desc.add("EBHitEnergyThreshold", 0.10); + desc.add("EEHitEnergyThreshold0", -41.0664); + desc.add("EEHitEnergyThreshold1", 68.7950); + desc.add("EEHitEnergyThreshold2", -38.1483); + desc.add("EEHitEnergyThreshold3", 7.04303); // prescale factors desc.add("momentumLow", 40.0); - desc.add("momentumHigh",60.0); + desc.add("momentumHigh", 60.0); desc.add("prescaleLow", 1); - desc.add("prescaleHigh",1); + desc.add("prescaleHigh", 1); // various labels for collections used in the code - desc.add("labelTriggerEvent",edm::InputTag("hltTriggerSummaryAOD","","HLT")); - desc.add("labelTriggerResult",edm::InputTag("TriggerResults","","HLT")); - desc.add("labelTrack","generalTracks"); - desc.add("labelVertex","offlinePrimaryVertices"); - desc.add("labelEBRecHit","EcalRecHitsEB"); - desc.add("labelEERecHit","EcalRecHitsEE"); - desc.add("labelHBHERecHit","hbhereco"); - desc.add("labelBeamSpot","offlineBeamSpot"); - desc.add("labelCaloTower","towerMaker"); + desc.add("labelTriggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT")); + desc.add("labelTriggerResult", edm::InputTag("TriggerResults", "", "HLT")); + desc.add("labelTrack", "generalTracks"); + desc.add("labelVertex", "offlinePrimaryVertices"); + desc.add("labelEBRecHit", "EcalRecHitsEB"); + desc.add("labelEERecHit", "EcalRecHitsEE"); + desc.add("labelHBHERecHit", "hbhereco"); + desc.add("labelBeamSpot", "offlineBeamSpot"); + desc.add("labelCaloTower", "towerMaker"); desc.add("algInputTag", edm::InputTag("gtStage2Digis")); desc.add("extInputTag", edm::InputTag("gtStage2Digis")); - desc.addUntracked("moduleName",""); - desc.addUntracked("producerName",""); + desc.addUntracked("moduleName", ""); + desc.addUntracked("producerName", ""); // Various flags used for selecting tracks, choice of energy Method2/0 // Data type 0/1 for single jet trigger or others - desc.addUntracked("useRaw",0); - desc.addUntracked("ignoreTriggers",false); - desc.addUntracked("useL1Trigger",false); - desc.addUntracked("hcalScale",1.0); - desc.addUntracked("dataType",0); - desc.addUntracked("outMode",11); - desc.addUntracked("unCorrect",false); - desc.addUntracked("collapseDepth",false); - desc.addUntracked("l1TrigName","L1_SingleJet60"); - desc.addUntracked("matrixECAL",5); - desc.addUntracked("matrixHCAL",3); - desc.addUntracked("mapRadius",34.98); - desc.addUntracked("get2Ddist",false); - descriptions.add("hcalIsoTrackStudy",desc); + desc.addUntracked("useRaw", 0); + desc.addUntracked("ignoreTriggers", false); + desc.addUntracked("useL1Trigger", false); + desc.addUntracked("hcalScale", 1.0); + desc.addUntracked("dataType", 0); + desc.addUntracked("outMode", 11); + desc.addUntracked("unCorrect", false); + desc.addUntracked("collapseDepth", false); + desc.addUntracked("l1TrigName", "L1_SingleJet60"); + desc.addUntracked("matrixECAL", 5); + desc.addUntracked("matrixHCAL", 3); + desc.addUntracked("mapRadius", 34.98); + desc.addUntracked("get2Ddist", false); + descriptions.add("hcalIsoTrackStudy", desc); } -std::array HcalIsoTrackStudy::fillTree(std::vector< math::XYZTLorentzVector>& vecL1, - std::vector< math::XYZTLorentzVector>& vecL3, - math::XYZPoint& leadPV, - std::vector& trkCaloDirections, - std::vector& trkCaloDets, - const CaloGeometry* geo, - const CaloTopology* caloTopology, - const HcalTopology* theHBHETopology, - const EcalChannelStatus* theEcalChStatus, - const EcalSeverityLevelAlgo* theEcalSevlv, - edm::Handle& barrelRecHitsHandle, - edm::Handle& endcapRecHitsHandle, - edm::Handle& hbhe, - edm::Handle& tower, - edm::Handle& genParticles, - const HcalRespCorrs* respCorrs) { - +std::array HcalIsoTrackStudy::fillTree(std::vector& vecL1, + std::vector& vecL3, + math::XYZPoint& leadPV, + std::vector& trkCaloDirections, + std::vector& trkCaloDets, + const CaloGeometry* geo, + const CaloTopology* caloTopology, + const HcalTopology* theHBHETopology, + const EcalChannelStatus* theEcalChStatus, + const EcalSeverityLevelAlgo* theEcalSevlv, + edm::Handle& barrelRecHitsHandle, + edm::Handle& endcapRecHitsHandle, + edm::Handle& hbhe, + edm::Handle& tower, + edm::Handle& genParticles, + const HcalRespCorrs* respCorrs) { int nSave(0), nLoose(0), nTight(0); //Loop over tracks std::vector::const_iterator trkDetItr; unsigned int nTracks(0), nselTracks(0); t_nTrk = trkCaloDirections.size(); t_rhoh = (tower.isValid()) ? rhoh(tower) : 0; - for (trkDetItr = trkCaloDirections.begin(),nTracks=0; - trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) { + for (trkDetItr = trkCaloDirections.begin(), nTracks = 0; trkDetItr != trkCaloDirections.end(); + trkDetItr++, nTracks++) { const reco::Track* pTrack = &(*(trkDetItr->trkItr)); - math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), - pTrack->pz(), pTrack->p()); + math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p()); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << pTrack->pt() - << "|" << pTrack->eta() << "|" - << pTrack->phi() << "|" <p(); + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << pTrack->pt() << "|" + << pTrack->eta() << "|" << pTrack->phi() << "|" << pTrack->p(); #endif t_mindR2 = 999; - for (unsigned int k=0; kokHCAL) { HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL); t_ieta = detId.ieta(); t_iphi = detId.iphi(); - if (t_p > 40.0 && t_p <= 60.0) t_ietaAll->emplace_back(t_ieta); + if (t_p > 40.0 && t_p <= 60.0) + t_ietaAll->emplace_back(t_ieta); } //Selection of good track - t_selectTk = spr::goodTrack(pTrack,leadPV,selectionParameter_,false); + t_selectTk = spr::goodTrack(pTrack, leadPV, selectionParameter_, false); spr::trackSelectionParameters oneCutParameters = selectionParameter_; - oneCutParameters.maxDxyPV = 10; - oneCutParameters.maxDzPV = 100; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; oneCutParameters.maxInMiss = 2; - oneCutParameters.maxOutMiss= 2; - bool qltyFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - oneCutParameters = selectionParameter_; - oneCutParameters.maxDxyPV = 10; - oneCutParameters.maxDzPV = 100; - t_qltyMissFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - oneCutParameters = selectionParameter_; + oneCutParameters.maxOutMiss = 2; + bool qltyFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; + oneCutParameters.maxDxyPV = 10; + oneCutParameters.maxDzPV = 100; + t_qltyMissFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + oneCutParameters = selectionParameter_; oneCutParameters.maxInMiss = 2; - oneCutParameters.maxOutMiss= 2; - t_qltyPVFlag = spr::goodTrack(pTrack,leadPV,oneCutParameters,false); - double eIsolation = maxRestrictionP_*exp(slopeRestrictionP_*std::abs((double)t_ieta)); - if (eIsolation < eIsolate1_) eIsolation = eIsolate1_; - if (eIsolation < eIsolate2_) eIsolation = eIsolate2_; + oneCutParameters.maxOutMiss = 2; + t_qltyPVFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false); + double eIsolation = maxRestrictionP_ * exp(slopeRestrictionP_ * std::abs((double)t_ieta)); + if (eIsolation < eIsolate1_) + eIsolation = eIsolate1_; + if (eIsolation < eIsolate2_) + eIsolation = eIsolate2_; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " - << qltyFlag << "|" << trkDetItr->okECAL - << "|" << trkDetItr->okHCAL - << " eIsolation " << eIsolation; + edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr->okECAL << "|" + << trkDetItr->okHCAL << " eIsolation " << eIsolation; #endif t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL); if (t_qltyFlag) { nselTracks++; int nNearTRKs(0); - std::vector eIds; + std::vector eIds; std::vector eHit; - t_eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle, - endcapRecHitsHandle, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_mipR_, - trkDetItr->directionECAL, eIds, eHit); + t_eMipDR = spr::eCone_ecal(geo, + barrelRecHitsHandle, + endcapRecHitsHandle, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_mipR_, + trkDetItr->directionECAL, + eIds, + eHit); double eEcal(0); - for (unsigned int k=0; kgetPosition(eIds[k]); - double eta = std::abs(pos.eta()); - double eThr = (eIds[k].subdetId() == EcalBarrel) ? hitEthrEB_ : - (((eta*hitEthrEE3_+hitEthrEE2_)*eta+hitEthrEE1_)*eta+hitEthrEE0_); - if (eHit[k] > eThr) eEcal += eHit[k]; + double eta = std::abs(pos.eta()); + double eThr = (eIds[k].subdetId() == EcalBarrel) + ? hitEthrEB_ + : (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_); + if (eHit[k] > eThr) + eEcal += eHit[k]; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR - << ":" << eEcal; + edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR << ":" << eEcal; #endif t_eMipDR = eEcal; - t_emaxNearP = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, - caloTopology, 15,15); + t_emaxNearP = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 15, 15); const DetId cellE(trkDetItr->detIdECAL); - std::pair e11x11P = - spr::eECALmatrix(cellE,barrelRecHitsHandle,endcapRecHitsHandle, - *theEcalChStatus,geo,caloTopology,theEcalSevlv, - 5,5,-100.0,-100.0,-100.0,100.0); - std::pair e15x15P = - spr::eECALmatrix(cellE,barrelRecHitsHandle,endcapRecHitsHandle, - *theEcalChStatus,geo,caloTopology,theEcalSevlv,7,7, - -100.0,-100.0,-100.0,100.0); + std::pair e11x11P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 5, + 5, + -100.0, + -100.0, + -100.0, + 100.0); + std::pair e15x15P = spr::eECALmatrix(cellE, + barrelRecHitsHandle, + endcapRecHitsHandle, + *theEcalChStatus, + geo, + caloTopology, + theEcalSevlv, + 7, + 7, + -100.0, + -100.0, + -100.0, + 100.0); if (e11x11P.second && e15x15P.second) { - t_eAnnular = (e15x15P.first - e11x11P.first); + t_eAnnular = (e15x15P.first - e11x11P.first); } else { - t_eAnnular =-(e15x15P.first - e11x11P.first); + t_eAnnular = -(e15x15P.first - e11x11P.first); } - t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, - a_charIsoR_, nNearTRKs, false); + t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false); const DetId cellH(trkDetItr->detIdHCAL); - double h5x5 = spr::eHCALmatrix(theHBHETopology,cellH,hbhe,2,2,false,true, - -100.0,-100.0,-100.0,-100.0,-100.0,100.0); - double h7x7 = spr::eHCALmatrix(theHBHETopology,cellH,hbhe,3,3,false,true, - -100.0,-100.0,-100.0,-100.0,-100.0,100.0); + double h5x5 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); + double h7x7 = spr::eHCALmatrix( + theHBHETopology, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0); t_hAnnular = h7x7 - h5x5; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << t_emaxNearP - << " (Hcal) " << t_hmaxNearP - << " Annular E (Ecal) " << e11x11P.first - << ":" << e15x15P.first << ":" - << t_eAnnular << " (Hcal) " << h5x5 - << ":" << h7x7 << ":" << t_hAnnular; + edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << t_emaxNearP << " (Hcal) " << t_hmaxNearP + << " Annular E (Ecal) " << e11x11P.first << ":" << e15x15P.first << ":" + << t_eAnnular << " (Hcal) " << h5x5 << ":" << h7x7 << ":" << t_hAnnular; #endif t_gentrackP = trackP(pTrack, genParticles); t_gentrackE = trackE(pTrack, genParticles); if (t_eMipDR < eEcalMax_ && t_hmaxNearP < eIsolation) { - t_DetIds->clear(); t_HitEnergies->clear(); - t_DetIds1->clear(); t_HitEnergies1->clear(); - t_DetIds3->clear(); t_HitEnergies3->clear(); - t_DetIdEC->clear(); t_HitEnergyEC->clear(); t_HitDistEC->clear(); - t_DetIdHC->clear(); t_HitEnergyHC->clear(); t_HitDistHC->clear(); - t_mapP->clear();t_mapPt->clear();t_mapEta->clear();t_mapPhi->clear(); - - int nRecHits(-999), nRecHits1(-999), nRecHits3(-999); - std::vector ids, ids1, ids3; - std::vector edet0, edet1, edet3; - t_eHcal = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR_, - trkDetItr->directionHCAL,nRecHits, - ids, edet0, useRaw_); - storeEnergy(0,respCorrs,ids, edet0,t_eHcal, t_DetIds, t_HitEnergies); - - //----- hcal energy in the extended cone 1 (a_coneR+10) -------------- - t_eHcal10 = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR1_, - trkDetItr->directionHCAL,nRecHits1, - ids1, edet1, useRaw_); - storeEnergy(1,respCorrs,ids1,edet1,t_eHcal10,t_DetIds1,t_HitEnergies1); - - //----- hcal energy in the extended cone 3 (a_coneR+30) -------------- - t_eHcal30 = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL, - trkDetItr->pointECAL, a_coneR2_, - trkDetItr->directionHCAL,nRecHits3, - ids3, edet3, useRaw_); - storeEnergy(3,respCorrs,ids3,edet3,t_eHcal30,t_DetIds3,t_HitEnergies3); - - fillECALmatrix(cellE,barrelRecHitsHandle,endcapRecHitsHandle, - geo,caloTopology,pTrack,matrixECAL_,matrixECAL_); - fillHCALmatrix(theHBHETopology,cellH,hbhe,geo,pTrack, - matrixHCAL_,matrixHCAL_); - - TrackMap(nTracks, trkCaloDirections,mapR_); - - - t_p = pTrack->p(); - t_pt = pTrack->pt(); - t_phi = pTrack->phi(); - + t_DetIds->clear(); + t_HitEnergies->clear(); + t_DetIds1->clear(); + t_HitEnergies1->clear(); + t_DetIds3->clear(); + t_HitEnergies3->clear(); + t_DetIdEC->clear(); + t_HitEnergyEC->clear(); + t_HitDistEC->clear(); + t_DetIdHC->clear(); + t_HitEnergyHC->clear(); + t_HitDistHC->clear(); + t_mapP->clear(); + t_mapPt->clear(); + t_mapEta->clear(); + t_mapPhi->clear(); + + int nRecHits(-999), nRecHits1(-999), nRecHits3(-999); + std::vector ids, ids1, ids3; + std::vector edet0, edet1, edet3; + t_eHcal = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR_, + trkDetItr->directionHCAL, + nRecHits, + ids, + edet0, + useRaw_); + storeEnergy(0, respCorrs, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies); + + //----- hcal energy in the extended cone 1 (a_coneR+10) -------------- + t_eHcal10 = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR1_, + trkDetItr->directionHCAL, + nRecHits1, + ids1, + edet1, + useRaw_); + storeEnergy(1, respCorrs, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1); + + //----- hcal energy in the extended cone 3 (a_coneR+30) -------------- + t_eHcal30 = spr::eCone_hcal(geo, + hbhe, + trkDetItr->pointHCAL, + trkDetItr->pointECAL, + a_coneR2_, + trkDetItr->directionHCAL, + nRecHits3, + ids3, + edet3, + useRaw_); + storeEnergy(3, respCorrs, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3); + + fillECALmatrix( + cellE, barrelRecHitsHandle, endcapRecHitsHandle, geo, caloTopology, pTrack, matrixECAL_, matrixECAL_); + fillHCALmatrix(theHBHETopology, cellH, hbhe, geo, pTrack, matrixHCAL_, matrixHCAL_); + + TrackMap(nTracks, trkCaloDirections, mapR_); + + t_p = pTrack->p(); + t_pt = pTrack->pt(); + t_phi = pTrack->phi(); + #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks - << " (pt|eta|phi|p) :" << t_pt - << "|" << pTrack->eta() << "|" - << t_phi << "|" << t_p - << " Generator Level p " - << t_gentrackP; - edm::LogVerbatim("HcalIsoTrack") << "e_MIP " << t_eMipDR - << " Chg Isolation " << t_hmaxNearP - << " eHcal" << t_eHcal << " ieta " - << t_ieta << " Quality " - << t_qltyMissFlag << ":" - << t_qltyPVFlag << ":" << t_selectTk; - for (unsigned int ll=0; llsize(); ll++) { - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds->at(ll) - << " hit enery is = " - << t_HitEnergies->at(ll); - } - for (unsigned int ll=0; llsize(); ll++) { - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds1->at(ll) - << " hit enery is = " - << t_HitEnergies1->at(ll); - } - for (unsigned int ll=0; llsize(); ll++) - edm::LogVerbatim("HcalIsoTrack") << "det id is = " << t_DetIds3->at(ll) - << " hit enery is = " - << t_HitEnergies3->at(ll); - edm::LogVerbatim("HcalIsoTrack") << t_DetIdEC->size() << ":" - << t_DetIdHC->size() << " hits from " - << "ECAL and HCAL"; - for (unsigned int ll=0; llsize(); ++ll) - edm::LogVerbatim("HcalIsoTrack") << "EC[" << ll << "] ID " << std::hex - << t_DetIdEC->at(ll) << std::dec - << " D " << t_HitDistEC->at(ll) - << " E " << t_HitEnergyEC->at(ll); - for (unsigned int ll=0; llsize(); ++ll) - edm::LogVerbatim("HcalIsoTrack") << "HC[" << ll << "] ID " << std::hex - << t_DetIdHC->at(ll) << std::dec - << " D " << t_HitDistHC->at(ll) - << " E " << t_HitEnergyHC->at(ll); + edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) :" << t_pt << "|" + << pTrack->eta() << "|" << t_phi << "|" << t_p << " Generator Level p " + << t_gentrackP; + edm::LogVerbatim("HcalIsoTrack") << "e_MIP " << t_eMipDR << " Chg Isolation " << t_hmaxNearP << " eHcal" + << t_eHcal << " ieta " << t_ieta << " Quality " << t_qltyMissFlag << ":" + << t_qltyPVFlag << ":" << t_selectTk; + for (unsigned int ll = 0; ll < t_DetIds->size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds->at(ll) << " hit enery is = " << t_HitEnergies->at(ll); + } + for (unsigned int ll = 0; ll < t_DetIds1->size(); ll++) { + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds1->at(ll) << " hit enery is = " << t_HitEnergies1->at(ll); + } + for (unsigned int ll = 0; ll < t_DetIds3->size(); ll++) + edm::LogVerbatim("HcalIsoTrack") + << "det id is = " << t_DetIds3->at(ll) << " hit enery is = " << t_HitEnergies3->at(ll); + edm::LogVerbatim("HcalIsoTrack") << t_DetIdEC->size() << ":" << t_DetIdHC->size() << " hits from " + << "ECAL and HCAL"; + for (unsigned int ll = 0; ll < t_DetIdEC->size(); ++ll) + edm::LogVerbatim("HcalIsoTrack") << "EC[" << ll << "] ID " << std::hex << t_DetIdEC->at(ll) << std::dec + << " D " << t_HitDistEC->at(ll) << " E " << t_HitEnergyEC->at(ll); + for (unsigned int ll = 0; ll < t_DetIdHC->size(); ++ll) + edm::LogVerbatim("HcalIsoTrack") << "HC[" << ll << "] ID " << std::hex << t_DetIdHC->at(ll) << std::dec + << " D " << t_HitDistHC->at(ll) << " E " << t_HitEnergyHC->at(ll); #endif - bool accept(false); - if (t_p>pTrackMin_) { - if (t_ppTrackHigh_) { - ++nHigh_; - if (prescaleHigh_ <= 1) accept = true; - else if (nHigh_%prescaleHigh_ == 1) accept = true; - } else { - accept = true; - } - } - if (accept) { - tree->Fill(); - nSave++; - int type(0); - if (t_eMipDR < 1.0) { - if (t_hmaxNearP < eIsolate2_) { ++nLoose; type = 1;} - if (t_hmaxNearP < eIsolate1_) { ++nTight; type = 2;} - } - if (t_p > 40.0 && t_p <= 60.0 && t_selectTk) { - t_ietaGood->emplace_back(t_ieta); - t_trackType->emplace_back(type); - } + bool accept(false); + if (t_p > pTrackMin_) { + if (t_p < pTrackLow_) { + ++nLow_; + if (prescaleLow_ <= 1) + accept = true; + else if (nLow_ % prescaleLow_ == 1) + accept = true; + } else if (t_p > pTrackHigh_) { + ++nHigh_; + if (prescaleHigh_ <= 1) + accept = true; + else if (nHigh_ % prescaleHigh_ == 1) + accept = true; + } else { + accept = true; + } + } + if (accept) { + tree->Fill(); + nSave++; + int type(0); + if (t_eMipDR < 1.0) { + if (t_hmaxNearP < eIsolate2_) { + ++nLoose; + type = 1; + } + if (t_hmaxNearP < eIsolate1_) { + ++nTight; + type = 2; + } + } + if (t_p > 40.0 && t_p <= 60.0 && t_selectTk) { + t_ietaGood->emplace_back(t_ieta); + t_trackType->emplace_back(type); + } #ifdef EDM_ML_DEBUG - for (unsigned int k=0; ksize(); k++) { - edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " - << t_trgbits->at(k); - } + for (unsigned int k = 0; k < t_trgbits->size(); k++) { + edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " << t_trgbits->at(k); + } #endif - } + } } } } - std::array i3{ {nSave,nLoose,nTight} }; + std::array i3{{nSave, nLoose, nTight}}; return i3; } double HcalIsoTrackStudy::dR(math::XYZTLorentzVector& vec1, math::XYZTLorentzVector& vec2) { - return reco::deltaR(vec1.eta(),vec1.phi(),vec2.eta(),vec2.phi()); + return reco::deltaR(vec1.eta(), vec1.phi(), vec2.eta(), vec2.phi()); } double HcalIsoTrackStudy::trackP(const reco::Track* pTrack, - const edm::Handle& genParticles) { - + const edm::Handle& genParticles) { double pmom = -1.0; if (genParticles.isValid()) { double mindR(999.9); - for (const auto &p : (*genParticles)) { - double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), - p.momentum().Eta(), p.momentum().Phi()); + for (const auto& p : (*genParticles)) { + double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), p.momentum().Eta(), p.momentum().Phi()); if (dR < mindR) { - mindR = dR; pmom = p.momentum().R(); - // std::cout<<"p.E() :"<& genParticles) { - + const edm::Handle& genParticles) { double pE = -1.0; if (genParticles.isValid()) { double mindR(999.9); - for (const auto &p : (*genParticles)) { - double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), - p.momentum().Eta(), p.momentum().Phi()); + for (const auto& p : (*genParticles)) { + double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), p.momentum().Eta(), p.momentum().Phi()); if (dR < mindR) { - mindR = dR; pE = p.energy(); - // std::cout<<"p.E() :"<& tower) { - std::vector sumPFNallSMDQH2; - sumPFNallSMDQH2.reserve(phibins_.size()*etabins_.size()); - + sumPFNallSMDQH2.reserve(phibins_.size() * etabins_.size()); + for (auto eta : etabins_) { for (auto phi : phibins_) { double hadder = 0; - for (const auto & pf_it : (*tower)) { - if (fabs(eta-pf_it.eta())>etahalfdist_) continue; - if (fabs(reco::deltaPhi(phi,pf_it.phi()))>phihalfdist_) continue; - hadder += pf_it.hadEt(); + for (const auto& pf_it : (*tower)) { + if (fabs(eta - pf_it.eta()) > etahalfdist_) + continue; + if (fabs(reco::deltaPhi(phi, pf_it.phi())) > phihalfdist_) + continue; + hadder += pf_it.hadEt(); } sumPFNallSMDQH2.emplace_back(hadder); } } double evt_smdq(0); - std::sort(sumPFNallSMDQH2.begin(),sumPFNallSMDQH2.end()); - if (sumPFNallSMDQH2.size()%2) evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-1)/2]; - else evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size()/2]+sumPFNallSMDQH2[(sumPFNallSMDQH2.size()-2)/2])/2.; - double rhoh = evt_smdq/(etadist_*phidist_); + std::sort(sumPFNallSMDQH2.begin(), sumPFNallSMDQH2.end()); + if (sumPFNallSMDQH2.size() % 2) + evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 1) / 2]; + else + evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size() / 2] + sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 2) / 2]) / 2.; + double rhoh = evt_smdq / (etadist_ * phidist_); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalIsoTrack") << "Rho " << evt_smdq << ":" << rhoh; #endif return rhoh; } -void HcalIsoTrackStudy::storeEnergy(int indx, const HcalRespCorrs* respCorrs, - const std::vector& ids, - std::vector& edet, - double & eHcal, - std::vector *detIds, - std::vector *hitEnergies) { +void HcalIsoTrackStudy::storeEnergy(int indx, + const HcalRespCorrs* respCorrs, + const std::vector& ids, + std::vector& edet, + double& eHcal, + std::vector* detIds, + std::vector* hitEnergies) { double ehcal(0); if (unCorrect_) { - for (unsigned int k=0; kgetValues(ids[k]))->getValue(); - if (corr != 0) edet[k] /= corr; + if (corr != 0) + edet[k] /= corr; ehcal += edet[k]; } } else { - for (const auto& en : edet) ehcal += en; + for (const auto& en : edet) + ehcal += en; } - if (std::abs(ehcal-eHcal) > 0.001) - edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx - << " " << eHcal << ":" << ehcal - << " from " << ids.size() << " cells"; - eHcal = hcalScale_*ehcal; + if (std::abs(ehcal - eHcal) > 0.001) + edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx << " " << eHcal << ":" << ehcal + << " from " << ids.size() << " cells"; + eHcal = hcalScale_ * ehcal; if (collapseDepth_) { - std::map hitMap; - for (unsigned int k=0; k hitMap; + for (unsigned int k = 0; k < ids.size(); ++k) { HcalDetId id = hdc_->mergedDepthDetId(HcalDetId(ids[k])); auto itr = hitMap.find(id); if (itr == hitMap.end()) { - hitMap[id] = edet[k]; + hitMap[id] = edet[k]; } else { - (itr->second) += edet[k]; + (itr->second) += edet[k]; } } - detIds->reserve(hitMap.size()); hitEnergies->reserve(hitMap.size()); + detIds->reserve(hitMap.size()); + hitEnergies->reserve(hitMap.size()); for (const auto& hit : hitMap) { detIds->emplace_back(hit.first.rawId()); hitEnergies->emplace_back(hit.second); } } else { - detIds->reserve(ids.size()); hitEnergies->reserve(ids.size()); - for (unsigned int k=0; kreserve(ids.size()); + hitEnergies->reserve(ids.size()); + for (unsigned int k = 0; k < ids.size(); ++k) { detIds->emplace_back(ids[k].rawId()); hitEnergies->emplace_back(edet[k]); } } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalIsoTrack") << "Input to storeEnergy with " - << ids.size() << " cells"; - for (unsigned int k=0; ksize() << " cells and Etot " - << eHcal; - for (unsigned int k=0; ksize(); ++k) - edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " - << HcalDetId((*detIds)[k]) << " E " - << (*hitEnergies)[k]; + edm::LogVerbatim("HcalIsoTrack") << "Input to storeEnergy with " << ids.size() << " cells"; + for (unsigned int k = 0; k < ids.size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId(ids[k]) << " E " << edet[k]; + edm::LogVerbatim("HcalIsoTrack") << "Output of storeEnergy with " << detIds->size() << " cells and Etot " << eHcal; + for (unsigned int k = 0; k < detIds->size(); ++k) + edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId((*detIds)[k]) << " E " << (*hitEnergies)[k]; #endif } void HcalIsoTrackStudy::fillECALmatrix(const DetId& detId, - edm::Handle& hitsEB, - edm::Handle& hitsEE, - const CaloGeometry* geo, - const CaloTopology* caloTopology, - const reco::Track* pTrack, - int ieta, int iphi) { - + edm::Handle& hitsEB, + edm::Handle& hitsEE, + const CaloGeometry* geo, + const CaloTopology* caloTopology, + const reco::Track* pTrack, + int ieta, + int iphi) { //Find the position of the central hit - std::vector< EcalRecHitCollection::const_iterator> hits; - + std::vector hits; + GlobalPoint center; if (detId.subdetId() == EcalEndcap) { EEDetId EEid = EEDetId(detId); @@ -1339,97 +1358,91 @@ void HcalIsoTrackStudy::fillECALmatrix(const DetId& detId, EBDetId EBid = EBDetId(detId); center = geo->getPosition(EBid); } - std::vector vdets; + std::vector vdets; spr::matrixECALIds(detId, ieta, iphi, geo, caloTopology, vdets, false); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalIsoTrack") << "Inside the fill func |||||||||||||||||" - << "center.x(): " << center.x() - << "| center.y(): " << center.y() - << "| center.z(): " << center.z() << "\n" - << "Size of detid vector: " << vdets.size(); + << "center.x(): " << center.x() << "| center.y(): " << center.y() + << "| center.z(): " << center.z() << "\n" + << "Size of detid vector: " << vdets.size(); #endif - int i=0; + int i = 0; for (auto const& id : vdets) { i++; // std::cout<<"counter inside vdet:"<emplace_back(id); t_HitEnergyEC->emplace_back(0.0); t_HitDistEC->emplace_back(0.0); } if (!hits.empty()) { for (auto const& hit : hits) { - GlobalPoint pos = spr::getGpos(geo,hit); - GlobalVector v1(pos.x()-center.x(),pos.y()-center.y(),pos.z()-center.z()); - double dist = v1.mag(); - if (get2Ddist_ && (dist > 0)) { - double cth = ((v1.x()*pTrack->px()+v1.y()*pTrack->py()+ - v1.z()*pTrack->pz())/(dist*pTrack->p())); - dist *= std::sqrt(1.0-cth*cth); - } - double ener = hit->energy(); - t_DetIdEC->emplace_back(hit->id()); - t_HitEnergyEC->emplace_back(ener); - t_HitDistEC->emplace_back(dist); + GlobalPoint pos = spr::getGpos(geo, hit); + GlobalVector v1(pos.x() - center.x(), pos.y() - center.y(), pos.z() - center.z()); + double dist = v1.mag(); + if (get2Ddist_ && (dist > 0)) { + double cth = ((v1.x() * pTrack->px() + v1.y() * pTrack->py() + v1.z() * pTrack->pz()) / (dist * pTrack->p())); + dist *= std::sqrt(1.0 - cth * cth); + } + double ener = hit->energy(); + t_DetIdEC->emplace_back(hit->id()); + t_HitEnergyEC->emplace_back(ener); + t_HitDistEC->emplace_back(dist); } } } - } void HcalIsoTrackStudy::fillHCALmatrix(const HcalTopology* topology, - const DetId& detId, - edm::Handle& hbhe, - const CaloGeometry* geo, - const reco::Track* pTrack, - int ieta, int iphi) { - - + const DetId& detId, + edm::Handle& hbhe, + const CaloGeometry* geo, + const reco::Track* pTrack, + int ieta, + int iphi) { //Find the position of the central hit std::vector hits; spr::hitHCALmatrix(topology, detId, hbhe, ieta, iphi, hits, false, false); GlobalPoint center = (static_cast(geo->getSubdetectorGeometry(detId)))->getPosition(detId); for (auto const& hit : hits) { - GlobalPoint pos = spr::getGpos(geo,hit); - GlobalVector v1(pos.x()-center.x(),pos.y()-center.y(),pos.z()-center.z()); + GlobalPoint pos = spr::getGpos(geo, hit); + GlobalVector v1(pos.x() - center.x(), pos.y() - center.y(), pos.z() - center.z()); double dist = v1.mag(); if (get2Ddist_ && (dist > 0)) { - double cth = ((v1.x()*pTrack->px()+v1.y()*pTrack->py()+ - v1.z()*pTrack->pz())/(dist*pTrack->p())); - dist *= std::sqrt(1.0-cth*cth); + double cth = ((v1.x() * pTrack->px() + v1.y() * pTrack->py() + v1.z() * pTrack->pz()) / (dist * pTrack->p())); + dist *= std::sqrt(1.0 - cth * cth); } double ener = spr::getEnergy(hit, useRaw_); t_DetIdHC->emplace_back(hit->id()); t_HitEnergyHC->emplace_back(ener); t_HitDistHC->emplace_back(dist); } - } -void HcalIsoTrackStudy::TrackMap(unsigned int trkIndex, - std::vector& trkDirs, - double dR) { - +void HcalIsoTrackStudy::TrackMap(unsigned int trkIndex, + std::vector& trkDirs, + double dR) { if (trkDirs[trkIndex].okHCAL) { - for (unsigned int indx=0; indxemplace_back(pTrack->p()); - t_mapPt ->emplace_back(pTrack->pt()); - t_mapEta->emplace_back(point.Eta()); - t_mapPhi->emplace_back(point.Phi()); - } + int isConeChargedIso = spr::coneChargeIsolation( + trkDirs[trkIndex].pointHCAL, trkDirs[indx].pointHCAL, trkDirs[trkIndex].directionHCAL, dR); + if (isConeChargedIso == 0) { + const reco::Track* pTrack = &(*(trkDirs[indx].trkItr)); + TVector3 point(trkDirs[indx].pointHCAL.x(), trkDirs[indx].pointHCAL.y(), trkDirs[indx].pointHCAL.z()); + + t_mapP->emplace_back(pTrack->p()); + t_mapPt->emplace_back(pTrack->pt()); + t_mapEta->emplace_back(point.Eta()); + t_mapPhi->emplace_back(point.Phi()); + } } } } diff --git a/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc b/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc index 845449ea57ae3..7ce3916504184 100644 --- a/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc +++ b/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc @@ -24,83 +24,78 @@ #include #include -class HcalLaserTest : public edm::one::EDAnalyzer { - +class HcalLaserTest : public edm::one::EDAnalyzer { public: explicit HcalLaserTest(const edm::ParameterSet&); virtual ~HcalLaserTest(); - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: virtual void analyze(edm::Event const&, edm::EventSetup const&) override; virtual void beginJob() override; - virtual void beginRun(edm::Run const&, edm::EventSetup const&) override { } - virtual void endRun(edm::Run const&, edm::EventSetup const&) override { } + virtual void beginRun(edm::Run const&, edm::EventSetup const&) override {} + virtual void endRun(edm::Run const&, edm::EventSetup const&) override {} virtual void endJob(void) override; - + // ----------member data --------------------------- - edm::EDGetTokenT inputTokenHBHE_; - edm::EDGetTokenT inputTokenHF_; - edm::EDGetTokenT ioTokenUMN_; - double minFracDiffHBHELaser_, minFracHFLaser_; - int minADCHBHE_, minADCHF_; + edm::EDGetTokenT inputTokenHBHE_; + edm::EDGetTokenT inputTokenHF_; + edm::EDGetTokenT ioTokenUMN_; + double minFracDiffHBHELaser_, minFracHFLaser_; + int minADCHBHE_, minADCHF_; - bool testMode_; + bool testMode_; mutable std::array, 16> eventsByType_; mutable std::array, 16> passedEventsByType_; - TH1F *h_hb1_, *h_hb2_, *h_hb3_, *h_hb4_; - TH1F *h_hb5_, *h_hf1_, *h_hf2_; + TH1F *h_hb1_, *h_hb2_, *h_hb3_, *h_hb4_; + TH1F *h_hb5_, *h_hf1_, *h_hf2_; }; - -HcalLaserTest::HcalLaserTest(const edm::ParameterSet& config) : - inputTokenHBHE_( consumes( config.getParameter("InputHBHE") ) ), - inputTokenHF_( consumes( config.getParameter("InputHF") ) ), - ioTokenUMN_( consumes( config.getParameter("UMNioDigis") )), - minFracDiffHBHELaser_(config.getParameter("minFracDiffHBHELaser")), - minFracHFLaser_(config.getParameter("minFracHFLaser")), - minADCHBHE_(config.getParameter("minADCHBHE")), - minADCHF_(config.getParameter("minADCHF")), - testMode_(config.getUntrackedParameter("testMode", false)), - eventsByType_(), - passedEventsByType_() { - +HcalLaserTest::HcalLaserTest(const edm::ParameterSet& config) + : inputTokenHBHE_(consumes(config.getParameter("InputHBHE"))), + inputTokenHF_(consumes(config.getParameter("InputHF"))), + ioTokenUMN_(consumes(config.getParameter("UMNioDigis"))), + minFracDiffHBHELaser_(config.getParameter("minFracDiffHBHELaser")), + minFracHFLaser_(config.getParameter("minFracHFLaser")), + minADCHBHE_(config.getParameter("minADCHBHE")), + minADCHF_(config.getParameter("minADCHF")), + testMode_(config.getUntrackedParameter("testMode", false)), + eventsByType_(), + passedEventsByType_() { usesResource(TFileService::kSharedResource); } -HcalLaserTest::~HcalLaserTest() { } - +HcalLaserTest::~HcalLaserTest() {} + void HcalLaserTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("InputHBHE",edm::InputTag("source")); - desc.add("InputHF",edm::InputTag("source")); - desc.add("UMNioDigis",edm::InputTag("UMNioDigis")); - desc.add("minADCHBHE",10); - desc.add("minADCHF",10); - desc.add("minFracDiffHBHELaser",0.3); - desc.add("minFracHFLaser",0.3); - desc.addUntracked("testMode",false); - descriptions.add("hcalLaserTest",desc); + desc.add("InputHBHE", edm::InputTag("source")); + desc.add("InputHF", edm::InputTag("source")); + desc.add("UMNioDigis", edm::InputTag("UMNioDigis")); + desc.add("minADCHBHE", 10); + desc.add("minADCHF", 10); + desc.add("minFracDiffHBHELaser", 0.3); + desc.add("minFracHFLaser", 0.3); + desc.addUntracked("testMode", false); + descriptions.add("hcalLaserTest", desc); } -void HcalLaserTest::analyze(edm::Event const& iEvent, - edm::EventSetup const& iSetup) { - - edm::Handle hbhe_digi; - iEvent.getByToken(inputTokenHBHE_, hbhe_digi); +void HcalLaserTest::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) { + edm::Handle hbhe_digi; + iEvent.getByToken(inputTokenHBHE_, hbhe_digi); - edm::Handle hf_digi; - iEvent.getByToken(inputTokenHF_, hf_digi); + edm::Handle hf_digi; + iEvent.getByToken(inputTokenHF_, hf_digi); // Count digis in good, bad RBXes. ('bad' RBXes see no laser signal) double badrbxfracHBHE(0), goodrbxfracHBHE(0), rbxfracHF(0); - int NbadHBHE = HcalBadLaserChannels::badChannelsHBHE(); - int NgoodHBHE = 2592*2-NbadHBHE; // remaining HBHE channels are 'good' - int NallHF = 864*4; + int NbadHBHE = HcalBadLaserChannels::badChannelsHBHE(); + int NgoodHBHE = 2592 * 2 - NbadHBHE; // remaining HBHE channels are 'good' + int NallHF = 864 * 4; int eventType = 0; int laserType = 0; - // Verify proper functioning on calibration stream events, + // Verify proper functioning on calibration stream events, // where the laser firing location "laserType" // is tagged by the UMNio board for eventType==14 @@ -110,106 +105,114 @@ void HcalLaserTest::analyze(edm::Event const& iEvent, eventType = static_cast(cumn->eventType()); laserType = static_cast(cumn->valueUserWord(0)); - if (eventType == 14) eventsByType_.at(laserType)++; + if (eventType == 14) + eventsByType_.at(laserType)++; if (testMode_) - edm::LogVerbatim("HcalLaserTest") - << "hbhe digi collection size: " << hbhe_digi->size() << "\n" - << "hf digi collection size: " << hf_digi->size() << "\n" - << "Event type: " << eventType - << " Laser type: " << laserType << std::endl; + edm::LogVerbatim("HcalLaserTest") << "hbhe digi collection size: " << hbhe_digi->size() << "\n" + << "hf digi collection size: " << hf_digi->size() << "\n" + << "Event type: " << eventType << " Laser type: " << laserType << std::endl; - for (auto & hbhe : *hbhe_digi) { + for (auto& hbhe : *hbhe_digi) { const HBHEDataFrame digi = (const HBHEDataFrame)(hbhe); - int maxdigiHB(0); - for (int i=0; i maxdigiHB) maxdigiHB = digi.sample(i).adc(); + int maxdigiHB(0); + for (int i = 0; i < digi.size(); i++) + if (digi.sample(i).adc() > maxdigiHB) + maxdigiHB = digi.sample(i).adc(); bool passCut = (maxdigiHB > minADCHBHE_); - HcalDetId myid = (HcalDetId)digi.id(); - bool isbad = HcalBadLaserChannels::badChannelHBHE(myid); + HcalDetId myid = (HcalDetId)digi.id(); + bool isbad = HcalBadLaserChannels::badChannelHBHE(myid); - if (isbad) h_hb2_->Fill(maxdigiHB); - else h_hb1_->Fill(maxdigiHB); + if (isbad) + h_hb2_->Fill(maxdigiHB); + else + h_hb1_->Fill(maxdigiHB); if (passCut) { - if (isbad) badrbxfracHBHE += 1.; - else goodrbxfracHBHE += 1.; + if (isbad) + badrbxfracHBHE += 1.; + else + goodrbxfracHBHE += 1.; } } goodrbxfracHBHE /= NgoodHBHE; - badrbxfracHBHE /= NbadHBHE; + badrbxfracHBHE /= NbadHBHE; h_hb3_->Fill(goodrbxfracHBHE); h_hb4_->Fill(badrbxfracHBHE); - h_hb5_->Fill(goodrbxfracHBHE-badrbxfracHBHE); - - for (auto & hf : *(hf_digi)) { + h_hb5_->Fill(goodrbxfracHBHE - badrbxfracHBHE); + + for (auto& hf : *(hf_digi)) { const QIE10DataFrame digi = (const QIE10DataFrame)(hf); bool passCut(false); - int maxdigiHF(0); - for (int i=0; i maxdigiHF) maxdigiHF = digi[i].adc(); - if (maxdigiHF > minADCHF_) passCut = true; + int maxdigiHF(0); + for (int i = 0; i < digi.samples(); i++) + if (digi[i].adc() > maxdigiHF) + maxdigiHF = digi[i].adc(); + if (maxdigiHF > minADCHF_) + passCut = true; h_hf1_->Fill(maxdigiHF); - if (passCut) rbxfracHF += 1.; + if (passCut) + rbxfracHF += 1.; } rbxfracHF /= NallHF; h_hf2_->Fill(rbxfracHF); - if (testMode_) - edm::LogWarning("HcalLaserTest") - << "******************************************************************\n" - << "goodrbxfracHBHE: " << goodrbxfracHBHE << " badrbxfracHBHE: " - << badrbxfracHBHE << " Size " << hbhe_digi->size() << "\n" - << "rbxfracHF: " << rbxfracHF << " Size " << hf_digi->size() - << "\n******************************************************************"; - - if (((goodrbxfracHBHE-badrbxfracHBHE) < minFracDiffHBHELaser_) || - (rbxfracHF < minFracHFLaser_)) { + if (testMode_) + edm::LogWarning("HcalLaserTest") << "******************************************************************\n" + << "goodrbxfracHBHE: " << goodrbxfracHBHE << " badrbxfracHBHE: " << badrbxfracHBHE + << " Size " << hbhe_digi->size() << "\n" + << "rbxfracHF: " << rbxfracHF << " Size " << hf_digi->size() + << "\n******************************************************************"; + + if (((goodrbxfracHBHE - badrbxfracHBHE) < minFracDiffHBHELaser_) || (rbxfracHF < minFracHFLaser_)) { } else { passedEventsByType_.at(laserType)++; } } void HcalLaserTest::beginJob() { - - for (auto & i : eventsByType_) i = 0; - for (auto & i : passedEventsByType_) i = 0; + for (auto& i : eventsByType_) + i = 0; + for (auto& i : passedEventsByType_) + i = 0; edm::Service tfile; - if ( !tfile.isAvailable() ) + if (!tfile.isAvailable()) throw cms::Exception("HcalLaserTest") << "TFileService unavailable: " - << "please add it to config file"; - h_hb1_ = tfile->make("hb1","Maximum ADC in HB (Good)",5000,0,100); - h_hb2_ = tfile->make("hb2","Maximum ADC in HB (Bad)", 5000,0,100); - h_hb3_ = tfile->make("hb3","Signal Channel fraction (Good)", 1000,0,1); - h_hb4_ = tfile->make("hb4","Signal Channel fraction (Bad)", 1000,0,1); - h_hb5_ = tfile->make("hb5","Signal Channel fraction (Diff)",1000,-1,1); - h_hf1_ = tfile->make("hf1","Maximum ADC in HF", 5000,0,100); - h_hf2_ = tfile->make("hf2","Signal Channel fraction (HF)", 1000,0,1); + << "please add it to config file"; + h_hb1_ = tfile->make("hb1", "Maximum ADC in HB (Good)", 5000, 0, 100); + h_hb2_ = tfile->make("hb2", "Maximum ADC in HB (Bad)", 5000, 0, 100); + h_hb3_ = tfile->make("hb3", "Signal Channel fraction (Good)", 1000, 0, 1); + h_hb4_ = tfile->make("hb4", "Signal Channel fraction (Bad)", 1000, 0, 1); + h_hb5_ = tfile->make("hb5", "Signal Channel fraction (Diff)", 1000, -1, 1); + h_hf1_ = tfile->make("hf1", "Maximum ADC in HF", 5000, 0, 100); + h_hf2_ = tfile->make("hf2", "Signal Channel fraction (HF)", 1000, 0, 1); } void HcalLaserTest::endJob() { - edm::LogVerbatim("HcalLaserTest") - << "Summary of filter decisions (passed/total): \n" - << passedEventsByType_.at(hc_Null) << "/" << eventsByType_.at(hc_Null) << "(No Calib), " - << passedEventsByType_.at(hc_Pedestal) << "/" << eventsByType_.at(hc_Pedestal) << "(Pedestal), " - << passedEventsByType_.at(hc_RADDAM) << "/" << eventsByType_.at(hc_RADDAM) << "(RADDAM), " - << passedEventsByType_.at(hc_HBHEHPD) << "/" << eventsByType_.at(hc_HBHEHPD) << "(HBHE/HPD), " - << passedEventsByType_.at(hc_HOHPD) << "/" << eventsByType_.at(hc_HOHPD) << "(HO/HPD), " - << passedEventsByType_.at(hc_HFPMT) << "/" << eventsByType_.at(hc_HFPMT) << "(HF/PMT), " - << passedEventsByType_.at(6) << "/" << eventsByType_.at(6) << "(ZDC), " - << passedEventsByType_.at(7) << "/" << eventsByType_.at(7) << "(HEPMega)\n" - << passedEventsByType_.at(8) << "/" << eventsByType_.at(8) << "(HEMMega), " - << passedEventsByType_.at(9) << "/" << eventsByType_.at(9) << "(HBPMega), " - << passedEventsByType_.at(10) << "/" << eventsByType_.at(10) << "(HBMMega), " - << passedEventsByType_.at(11) << "/" << eventsByType_.at(11) << "(Undefined), " - << passedEventsByType_.at(12) << "/" << eventsByType_.at(12) << "(CRF), " - << passedEventsByType_.at(13) << "/" << eventsByType_.at(13) << "(Calib), " - << passedEventsByType_.at(14) << "/" << eventsByType_.at(14) << "(Safe), " - << passedEventsByType_.at(15) << "/" << eventsByType_.at(15) << "(Undefined)"; + edm::LogVerbatim("HcalLaserTest") << "Summary of filter decisions (passed/total): \n" + << passedEventsByType_.at(hc_Null) << "/" << eventsByType_.at(hc_Null) + << "(No Calib), " << passedEventsByType_.at(hc_Pedestal) << "/" + << eventsByType_.at(hc_Pedestal) << "(Pedestal), " + << passedEventsByType_.at(hc_RADDAM) << "/" << eventsByType_.at(hc_RADDAM) + << "(RADDAM), " << passedEventsByType_.at(hc_HBHEHPD) << "/" + << eventsByType_.at(hc_HBHEHPD) << "(HBHE/HPD), " + << passedEventsByType_.at(hc_HOHPD) << "/" << eventsByType_.at(hc_HOHPD) + << "(HO/HPD), " << passedEventsByType_.at(hc_HFPMT) << "/" + << eventsByType_.at(hc_HFPMT) << "(HF/PMT), " << passedEventsByType_.at(6) << "/" + << eventsByType_.at(6) << "(ZDC), " << passedEventsByType_.at(7) << "/" + << eventsByType_.at(7) << "(HEPMega)\n" + << passedEventsByType_.at(8) << "/" << eventsByType_.at(8) << "(HEMMega), " + << passedEventsByType_.at(9) << "/" << eventsByType_.at(9) << "(HBPMega), " + << passedEventsByType_.at(10) << "/" << eventsByType_.at(10) << "(HBMMega), " + << passedEventsByType_.at(11) << "/" << eventsByType_.at(11) << "(Undefined), " + << passedEventsByType_.at(12) << "/" << eventsByType_.at(12) << "(CRF), " + << passedEventsByType_.at(13) << "/" << eventsByType_.at(13) << "(Calib), " + << passedEventsByType_.at(14) << "/" << eventsByType_.at(14) << "(Safe), " + << passedEventsByType_.at(15) << "/" << eventsByType_.at(15) << "(Undefined)"; } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.cc b/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.cc index 22c2fe811dfbf..ec05bd87794fb 100644 --- a/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.cc +++ b/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.cc @@ -2,7 +2,7 @@ // // Package: Calibration/HcalCalibAlgos/plugins // Class: ValidationHcalIsoTrackAlCaReco -// +// /**\class ValidationHcalIsoTrackAlCaReco ValidationHcalIsoTrackAlCaReco.cc Calibration/HcalCalibAlgos/plugins/ValidationHcalIsoTrackAlCaReco.cc Description: @@ -16,7 +16,6 @@ // // - // system include files #include @@ -56,7 +55,6 @@ #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h" #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h" - // Sergey + #include "SimDataFormats/Track/interface/SimTrack.h" @@ -69,195 +67,196 @@ #include "TH1F.h" - -double ValidationHcalIsoTrackAlCaReco::getDist(double eta1, double phi1, double eta2, double phi2) -{ - double dphi = fabs(phi1 - phi2); - if(dphi>acos(-1)) dphi = 2*acos(-1)-dphi; - double dr = sqrt(dphi*dphi + pow(eta1-eta2,2)); +double ValidationHcalIsoTrackAlCaReco::getDist(double eta1, double phi1, double eta2, double phi2) { + double dphi = fabs(phi1 - phi2); + if (dphi > acos(-1)) + dphi = 2 * acos(-1) - dphi; + double dr = sqrt(dphi * dphi + pow(eta1 - eta2, 2)); return dr; } // Sergey + -double ValidationHcalIsoTrackAlCaReco::getDistInCM(double eta1, double phi1, double eta2, double phi2) -{ +double ValidationHcalIsoTrackAlCaReco::getDistInCM(double eta1, double phi1, double eta2, double phi2) { double dR, Rec; - double theta1=2*atan(exp(-eta1)); - double theta2=2*atan(exp(-eta2)); - if (fabs(eta1)<1.479) Rec=129; - else Rec=275; + double theta1 = 2 * atan(exp(-eta1)); + double theta2 = 2 * atan(exp(-eta2)); + if (fabs(eta1) < 1.479) + Rec = 129; + else + Rec = 275; //|vect| times tg of acos(scalar product) - dR=fabs((Rec/sin(theta1))*tan(acos(sin(theta1)*sin(theta2)*(sin(phi1)*sin(phi2)+cos(phi1)*cos(phi2))+cos(theta1)*cos(theta2)))); + dR = fabs((Rec / sin(theta1)) * tan(acos(sin(theta1) * sin(theta2) * (sin(phi1) * sin(phi2) + cos(phi1) * cos(phi2)) + + cos(theta1) * cos(theta2)))); return dR; } // Sergey - -std::pair ValidationHcalIsoTrackAlCaReco::towerIndex(double eta, double phi) -{ - int ieta=0; - int iphi=0; - for (int i=1; i<21; i++) - { - if (fabs(eta)<(i*0.087)&&fabs(eta)>(i-1)*0.087) ieta=int(fabs(eta)/eta)*i; - } - if (fabs(eta)>1.740&&fabs(eta)<1.830) ieta=int(fabs(eta)/eta)*21; - if (fabs(eta)>1.830&&fabs(eta)<1.930) ieta=int(fabs(eta)/eta)*22; - if (fabs(eta)>1.930&&fabs(eta)<2.043) ieta=int(fabs(eta)/eta)*23; - - double delta=phi+0.174532925; - if (delta<0) delta=delta+2*acos(-1); - if (fabs(eta)<1.740) - { - for (int i=0; i<72; i++) - { - if (delta<(i+1)*0.087266462&&delta>i*0.087266462) iphi=i; - } +std::pair ValidationHcalIsoTrackAlCaReco::towerIndex(double eta, double phi) { + int ieta = 0; + int iphi = 0; + for (int i = 1; i < 21; i++) { + if (fabs(eta) < (i * 0.087) && fabs(eta) > (i - 1) * 0.087) + ieta = int(fabs(eta) / eta) * i; + } + if (fabs(eta) > 1.740 && fabs(eta) < 1.830) + ieta = int(fabs(eta) / eta) * 21; + if (fabs(eta) > 1.830 && fabs(eta) < 1.930) + ieta = int(fabs(eta) / eta) * 22; + if (fabs(eta) > 1.930 && fabs(eta) < 2.043) + ieta = int(fabs(eta) / eta) * 23; + + double delta = phi + 0.174532925; + if (delta < 0) + delta = delta + 2 * acos(-1); + if (fabs(eta) < 1.740) { + for (int i = 0; i < 72; i++) { + if (delta < (i + 1) * 0.087266462 && delta > i * 0.087266462) + iphi = i; } - else - { - for (int i=0; i<36; i++) - { - if (delta<2*(i+1)*0.087266462&&delta>2*i*0.087266462) iphi=2*i; - } + } else { + for (int i = 0; i < 36; i++) { + if (delta < 2 * (i + 1) * 0.087266462 && delta > 2 * i * 0.087266462) + iphi = 2 * i; } + } - return std::pair(ieta,iphi); + return std::pair(ieta, iphi); } - ValidationHcalIsoTrackAlCaReco::ValidationHcalIsoTrackAlCaReco(const edm::ParameterSet& iConfig) { - tok_simTrack_ = consumes(iConfig.getParameter("simTracksTag")); folderName_ = iConfig.getParameter("folderName"); - saveToFile_=iConfig.getParameter("saveToFile"); - outRootFileName_=iConfig.getParameter("outputRootFileName"); + saveToFile_ = iConfig.getParameter("saveToFile"); + outRootFileName_ = iConfig.getParameter("outputRootFileName"); tok_hlt_ = consumes(iConfig.getParameter("hltTriggerEventLabel")); - hltFilterTag_=iConfig.getParameter("hltL3FilterLabel"); - tok_arITr_ = consumes(iConfig.getParameter("alcarecoIsoTracksLabel")); - recoTrLabel_=iConfig.getParameter("recoTracksLabel"); - pThr_=iConfig.getUntrackedParameter("pThrL3",0); - heLow_=iConfig.getUntrackedParameter("lowerHighEnergyCut",40); - heLow_=iConfig.getUntrackedParameter("upperHighEnergyCut",60); - - nTotal=0; - nHLTL3accepts=0; + hltFilterTag_ = iConfig.getParameter("hltL3FilterLabel"); + tok_arITr_ = consumes( + iConfig.getParameter("alcarecoIsoTracksLabel")); + recoTrLabel_ = iConfig.getParameter("recoTracksLabel"); + pThr_ = iConfig.getUntrackedParameter("pThrL3", 0); + heLow_ = iConfig.getUntrackedParameter("lowerHighEnergyCut", 40); + heLow_ = iConfig.getUntrackedParameter("upperHighEnergyCut", 60); + + nTotal = 0; + nHLTL3accepts = 0; } -ValidationHcalIsoTrackAlCaReco::~ValidationHcalIsoTrackAlCaReco() -{} +ValidationHcalIsoTrackAlCaReco::~ValidationHcalIsoTrackAlCaReco() {} -void ValidationHcalIsoTrackAlCaReco::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ +void ValidationHcalIsoTrackAlCaReco::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { nTotal++; edm::Handle trEv; - iEvent.getByToken(tok_hlt_,trEv); - + iEvent.getByToken(tok_hlt_, trEv); + edm::Handle recoIsoTracks; - iEvent.getByToken(tok_arITr_,recoIsoTracks); + iEvent.getByToken(tok_arITr_, recoIsoTracks); const trigger::TriggerObjectCollection& TOCol(trEv->getObjects()); - + trigger::Keys KEYS; const trigger::size_type nFilt(trEv->sizeFilters()); - for (trigger::size_type iFilt=0; iFilt!=nFilt; iFilt++) - { - if (trEv->filterTag(iFilt)==hltFilterTag_) - { - KEYS=trEv->filterKeys(iFilt); - } + for (trigger::size_type iFilt = 0; iFilt != nFilt; iFilt++) { + if (trEv->filterTag(iFilt) == hltFilterTag_) { + KEYS = trEv->filterKeys(iFilt); } - - trigger::size_type nReg=KEYS.size(); - + } + + trigger::size_type nReg = KEYS.size(); + std::vector trigEta; std::vector trigPhi; - bool trig=false; + bool trig = false; //checks with IsoTrack trigger results - for (trigger::size_type iReg=0; iRegFill(TObj.eta(),1); - hl3AbsEta->Fill(fabs(TObj.eta()),1); - hl3phi->Fill(TObj.phi(),1); - - if (recoIsoTracks->size()>0) - { - double minRecoL3dist=1000; - reco::IsolatedPixelTrackCandidateCollection::const_iterator mrtr; - for (reco::IsolatedPixelTrackCandidateCollection::const_iterator rtrit=recoIsoTracks->begin(); rtrit!=recoIsoTracks->end(); rtrit++) - { - double R=getDist(rtrit->eta(),rtrit->phi(),TObj.eta(),TObj.phi()); - if (RFill(minRecoL3dist,1); - hOffL3TrackPtRat->Fill(TObj.pt()/mrtr->pt(),1); - } - - hl3Pt->Fill(TObj.pt(),1); - trig=true; - trigEta.push_back(TObj.eta()); - trigPhi.push_back(TObj.phi()); + for (trigger::size_type iReg = 0; iReg < nReg; iReg++) { + const trigger::TriggerObject& TObj(TOCol[KEYS[iReg]]); + if (TObj.p() < pThr_) + continue; + hl3eta->Fill(TObj.eta(), 1); + hl3AbsEta->Fill(fabs(TObj.eta()), 1); + hl3phi->Fill(TObj.phi(), 1); + + if (recoIsoTracks->size() > 0) { + double minRecoL3dist = 1000; + reco::IsolatedPixelTrackCandidateCollection::const_iterator mrtr; + for (reco::IsolatedPixelTrackCandidateCollection::const_iterator rtrit = recoIsoTracks->begin(); + rtrit != recoIsoTracks->end(); + rtrit++) { + double R = getDist(rtrit->eta(), rtrit->phi(), TObj.eta(), TObj.phi()); + if (R < minRecoL3dist) { + mrtr = rtrit; + minRecoL3dist = R; + } + } + hOffL3TrackMatch->Fill(minRecoL3dist, 1); + hOffL3TrackPtRat->Fill(TObj.pt() / mrtr->pt(), 1); } + hl3Pt->Fill(TObj.pt(), 1); + trig = true; + trigEta.push_back(TObj.eta()); + trigPhi.push_back(TObj.phi()); + } + //general distributions - for (reco::IsolatedPixelTrackCandidateCollection::const_iterator itr=recoIsoTracks->begin(); itr!=recoIsoTracks->end(); itr++) - { - bool match=false; - for (unsigned int l=0; leta(),itr->phi(),trigEta[l],trigPhi[l])<0.2) match=true; - } - if (match&&trig) - { - hOffEtaFP->Fill(itr->eta(),1); - hOffPhiFP->Fill(itr->phi(),1); - } - - hOffEta->Fill(itr->eta(),1); - hOffPhi->Fill(itr->phi(),1); - - hOffAbsEta->Fill(fabs(itr->eta()),1); - - hDeposEcalInner->Fill(itr->energyIn(),1); - hDeposEcalOuter->Fill(itr->energyOut(),1); - - hTracksSumP->Fill(itr->sumPtPxl(),1); - hTracksMaxP->Fill(itr->maxPtPxl(),1); - - if (fabs(itr->eta())<0.5) hOffP_0005->Fill(itr->p(),1); - if (fabs(itr->eta())>0.5&&fabs(itr->eta())<1.0) hOffP_0510->Fill(itr->p(),1); - if (fabs(itr->eta())>1.0&&fabs(itr->eta())<1.5) hOffP_1015->Fill(itr->p(),1); - if (fabs(itr->eta())<1.5&&fabs(itr->eta())<2.0) hOffP_1520->Fill(itr->p(),1); - - hOffP->Fill(itr->p(),1); - - std::pair TI=towerIndex(itr->eta(),itr->phi()); - hOccupancyFull->Fill(TI.first,TI.second,1); - if (itr->p()>heLow_&&itr->p()Fill(TI.first,TI.second,1); + for (reco::IsolatedPixelTrackCandidateCollection::const_iterator itr = recoIsoTracks->begin(); + itr != recoIsoTracks->end(); + itr++) { + bool match = false; + for (unsigned int l = 0; l < trigEta.size(); l++) { + if (getDist(itr->eta(), itr->phi(), trigEta[l], trigPhi[l]) < 0.2) + match = true; } - -// Sergey + + if (match && trig) { + hOffEtaFP->Fill(itr->eta(), 1); + hOffPhiFP->Fill(itr->phi(), 1); + } + + hOffEta->Fill(itr->eta(), 1); + hOffPhi->Fill(itr->phi(), 1); - std::cout << std::endl << " End / Start " << std::endl; + hOffAbsEta->Fill(fabs(itr->eta()), 1); - edm::Handle simTracks; - iEvent.getByToken(tok_simTrack_, simTracks); + hDeposEcalInner->Fill(itr->energyIn(), 1); + hDeposEcalOuter->Fill(itr->energyOut(), 1); - for (reco::IsolatedPixelTrackCandidateCollection::const_iterator bll=recoIsoTracks->begin(); bll!=recoIsoTracks->end(); bll++) - { + hTracksSumP->Fill(itr->sumPtPxl(), 1); + hTracksMaxP->Fill(itr->maxPtPxl(), 1); + + if (fabs(itr->eta()) < 0.5) + hOffP_0005->Fill(itr->p(), 1); + if (fabs(itr->eta()) > 0.5 && fabs(itr->eta()) < 1.0) + hOffP_0510->Fill(itr->p(), 1); + if (fabs(itr->eta()) > 1.0 && fabs(itr->eta()) < 1.5) + hOffP_1015->Fill(itr->p(), 1); + if (fabs(itr->eta()) < 1.5 && fabs(itr->eta()) < 2.0) + hOffP_1520->Fill(itr->p(), 1); + + hOffP->Fill(itr->p(), 1); + + std::pair TI = towerIndex(itr->eta(), itr->phi()); + hOccupancyFull->Fill(TI.first, TI.second, 1); + if (itr->p() > heLow_ && itr->p() < heUp_) + hOccupancyHighEn->Fill(TI.first, TI.second, 1); + } + + // Sergey + + + std::cout << std::endl << " End / Start " << std::endl; + + edm::Handle simTracks; + iEvent.getByToken(tok_simTrack_, simTracks); + + for (reco::IsolatedPixelTrackCandidateCollection::const_iterator bll = recoIsoTracks->begin(); + bll != recoIsoTracks->end(); + bll++) { + std::cout << "ISO Pt " << bll->pt() << " P " << bll->p() << " Eta " << bll->eta() << " Phi " << bll->phi() + << std::endl; - std::cout<<"ISO Pt " << bll->pt() << " P " << bll->p() << " Eta "<< bll->eta() << " Phi "<< bll->phi()<< std::endl; - double distanceMin = 1.; double SimPtMatched = 1.; double SimPhiMatched = 1.; @@ -268,222 +267,184 @@ void ValidationHcalIsoTrackAlCaReco::analyze(const edm::Event& iEvent, const edm double neuenm = 0.; int neun = 0; - for(edm::SimTrackContainer::const_iterator tracksCI = simTracks->begin(); - tracksCI != simTracks->end(); tracksCI++){ - - int partIndex = tracksCI->genpartIndex(); - if (tracksCI->momentum().eta() > (bll->eta()-0.1) - && tracksCI->momentum().eta() < (bll->eta()+0.1) - && tracksCI->momentum().phi() > (bll->phi()-0.1) - && tracksCI->momentum().phi() < (bll->phi()+0.1) -// && tracksCI->momentum().e() > (0.5*bll->p()) -// && tracksCI->momentum().e() < (2.*bll->p()) - && tracksCI->momentum().e() > 2. - && fabs(tracksCI->charge()) == 1 && partIndex >0) - { - - double distance=getDist(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi()); - double distanceCM=getDistInCM(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi()); - - if (distanceMin > distance) { - distanceMin = distance; - SimPtMatched = tracksCI->momentum().pt(); - SimPhiMatched = tracksCI->momentum().phi(); - SimEtaMatched = tracksCI->momentum().eta(); - SimDistMatched = distance; - SimPMatched = sqrt(tracksCI->momentum().pt()*tracksCI->momentum().pt() + tracksCI->momentum().pz()*tracksCI->momentum().pz()); - } - - std::cout<<" Pt "<momentum().pt() - << " Energy " << tracksCI->momentum().e() - << " Eta "<< tracksCI->momentum().eta() - << " Phi "<< tracksCI->momentum().phi() - << " Ind " << partIndex - << " Cha " << tracksCI->charge() - << " Dis " << distance - << " DCM " << distanceCM - << std::endl; - - } - - - if ( - tracksCI->momentum().eta() > (bll->eta()-0.5) - && tracksCI->momentum().eta() < (bll->eta()+0.5) - && tracksCI->momentum().phi() > (bll->phi()-0.5) - && tracksCI->momentum().phi() < (bll->phi()+0.5) -// && tracksCI->momentum().e() > 2. - && tracksCI->charge() == 0 && partIndex >0) - { - - double distance=getDist(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi()); - double distanceCM=getDistInCM(tracksCI->momentum().eta(),tracksCI->momentum().phi(),bll->eta(),bll->phi()); - - std::cout<<"NEU Pt "<momentum().pt() - << " Energy " << tracksCI->momentum().e() - << " Eta "<< tracksCI->momentum().eta() - << " Phi "<< tracksCI->momentum().phi() - << " Ind " << partIndex - << " Cha " << tracksCI->charge() - << " Dis " << distance - << " DCM " << distanceCM - << std::endl; - - if (distanceCM < 40.){ - - neuen = neuen + tracksCI->momentum().e(); - neun = neun + 1; - if (neuenm < tracksCI->momentum().e()) neuenm = tracksCI->momentum().e(); - - } - - } - - } - - hSimNN->Fill(neun,1); - hSimNE->Fill(neuen,1); - hSimNM->Fill(neuenm,1); - - if (distanceMin < 0.1) { - - hSimPt->Fill(SimPtMatched,1); - hSimPhi->Fill(SimPhiMatched,1); - hSimEta->Fill(SimEtaMatched,1); - hSimAbsEta->Fill(fabs(SimEtaMatched),1); - hSimDist->Fill(SimDistMatched,1); - hSimPtRatOff->Fill(SimPtMatched/bll->pt(),1); - hSimP->Fill(SimPMatched,1); - hSimN->Fill(1,1); - - std::cout<<"S Pt "<< SimPtMatched - << std::endl; - } - - if (distanceMin > 0.1) { - hSimN->Fill(0,1); - } - - - - + for (edm::SimTrackContainer::const_iterator tracksCI = simTracks->begin(); tracksCI != simTracks->end(); + tracksCI++) { + int partIndex = tracksCI->genpartIndex(); + if (tracksCI->momentum().eta() > (bll->eta() - 0.1) && tracksCI->momentum().eta() < (bll->eta() + 0.1) && + tracksCI->momentum().phi() > (bll->phi() - 0.1) && + tracksCI->momentum().phi() < (bll->phi() + 0.1) + // && tracksCI->momentum().e() > (0.5*bll->p()) + // && tracksCI->momentum().e() < (2.*bll->p()) + && tracksCI->momentum().e() > 2. && fabs(tracksCI->charge()) == 1 && partIndex > 0) { + double distance = getDist(tracksCI->momentum().eta(), tracksCI->momentum().phi(), bll->eta(), bll->phi()); + double distanceCM = getDistInCM(tracksCI->momentum().eta(), tracksCI->momentum().phi(), bll->eta(), bll->phi()); + + if (distanceMin > distance) { + distanceMin = distance; + SimPtMatched = tracksCI->momentum().pt(); + SimPhiMatched = tracksCI->momentum().phi(); + SimEtaMatched = tracksCI->momentum().eta(); + SimDistMatched = distance; + SimPMatched = sqrt(tracksCI->momentum().pt() * tracksCI->momentum().pt() + + tracksCI->momentum().pz() * tracksCI->momentum().pz()); + } + + std::cout << " Pt " << tracksCI->momentum().pt() << " Energy " << tracksCI->momentum().e() << " Eta " + << tracksCI->momentum().eta() << " Phi " << tracksCI->momentum().phi() << " Ind " << partIndex + << " Cha " << tracksCI->charge() << " Dis " << distance << " DCM " << distanceCM << std::endl; + } + + if (tracksCI->momentum().eta() > (bll->eta() - 0.5) && tracksCI->momentum().eta() < (bll->eta() + 0.5) && + tracksCI->momentum().phi() > (bll->phi() - 0.5) && + tracksCI->momentum().phi() < (bll->phi() + 0.5) + // && tracksCI->momentum().e() > 2. + && tracksCI->charge() == 0 && partIndex > 0) { + double distance = getDist(tracksCI->momentum().eta(), tracksCI->momentum().phi(), bll->eta(), bll->phi()); + double distanceCM = getDistInCM(tracksCI->momentum().eta(), tracksCI->momentum().phi(), bll->eta(), bll->phi()); + + std::cout << "NEU Pt " << tracksCI->momentum().pt() << " Energy " << tracksCI->momentum().e() << " Eta " + << tracksCI->momentum().eta() << " Phi " << tracksCI->momentum().phi() << " Ind " << partIndex + << " Cha " << tracksCI->charge() << " Dis " << distance << " DCM " << distanceCM << std::endl; + + if (distanceCM < 40.) { + neuen = neuen + tracksCI->momentum().e(); + neun = neun + 1; + if (neuenm < tracksCI->momentum().e()) + neuenm = tracksCI->momentum().e(); + } + } + } + + hSimNN->Fill(neun, 1); + hSimNE->Fill(neuen, 1); + hSimNM->Fill(neuenm, 1); + + if (distanceMin < 0.1) { + hSimPt->Fill(SimPtMatched, 1); + hSimPhi->Fill(SimPhiMatched, 1); + hSimEta->Fill(SimEtaMatched, 1); + hSimAbsEta->Fill(fabs(SimEtaMatched), 1); + hSimDist->Fill(SimDistMatched, 1); + hSimPtRatOff->Fill(SimPtMatched / bll->pt(), 1); + hSimP->Fill(SimPMatched, 1); + hSimN->Fill(1, 1); + + std::cout << "S Pt " << SimPtMatched << std::endl; + } + + if (distanceMin > 0.1) { + hSimN->Fill(0, 1); + } } -// Sergey - - - - + // Sergey - } -void ValidationHcalIsoTrackAlCaReco::beginJob() -{ +void ValidationHcalIsoTrackAlCaReco::beginJob() { dbe_ = edm::Service().operator->(); dbe_->setCurrentFolder(folderName_); - hl3Pt=dbe_->book1D("hl3Pt","pT of hlt L3 objects",1000,0,1000); - hl3Pt->setAxisTitle("pT(GeV)",1); - hl3eta=dbe_->book1D("hl3eta","eta of hlt L3 objects",16,-2,2); - hl3eta->setAxisTitle("eta",1); - hl3AbsEta=dbe_->book1D("hl3AbsEta","|eta| of hlt L3 objects",8,0,2); - hl3AbsEta->setAxisTitle("eta",1); - hl3phi=dbe_->book1D("hl3phi","phi of hlt L3 objects",16,-3.2,3.2); - hl3phi->setAxisTitle("phi",1); - - hOffEta=dbe_->book1D("hOffEta","eta of alcareco objects",100,-2,2); - hOffEta->setAxisTitle("eta",1); - hOffPhi=dbe_->book1D("hOffPhi","phi of alcareco objects",100,-3.2,3.2); - hOffPhi->setAxisTitle("phi",1); - hOffP=dbe_->book1D("hOffP","p of alcareco objects",1000,0,1000); - hOffP->setAxisTitle("E(GeV)",1); - hOffP_0005=dbe_->book1D("hOffP_0005","p of alcareco objects, |eta|<0.5",1000,0,1000); - hOffP_0005->setAxisTitle("E(GeV)",1); - hOffP_0510=dbe_->book1D("hOffP_0510","p of alcareco objects, 0.5<|eta|<1.0",1000,0,1000); - hOffP_0510->setAxisTitle("E(GeV)",1); - hOffP_1015=dbe_->book1D("hOffP_1015","p of alcareco objects, 1.0<|eta|<1.5",1000,0,1000); - hOffP_1015->setAxisTitle("E(GeV)",1); - hOffP_1520=dbe_->book1D("hOffP_1520","p of alcareco objects, 1.5<|eta|<2.0",1000,0,1000); - hOffP_1520->setAxisTitle("E(GeV)",1); - hOffEtaFP=dbe_->book1D("hOffEtaFP","eta of alcareco objects, FP",16,-2,2); - hOffEtaFP->setAxisTitle("eta",1); - hOffAbsEta=dbe_->book1D("hOffAbsEta","|eta| of alcareco objects",8,0,2); - hOffAbsEta->setAxisTitle("|eta|",1); - hOffPhiFP=dbe_->book1D("hOffPhiFP","phi of alcareco objects, FP",16,-3.2,3.2); - hOffPhiFP->setAxisTitle("phi",1); - hTracksSumP=dbe_->book1D("hTracksSumP","summary p of tracks in the isolation cone",100,0,20); + hl3Pt = dbe_->book1D("hl3Pt", "pT of hlt L3 objects", 1000, 0, 1000); + hl3Pt->setAxisTitle("pT(GeV)", 1); + hl3eta = dbe_->book1D("hl3eta", "eta of hlt L3 objects", 16, -2, 2); + hl3eta->setAxisTitle("eta", 1); + hl3AbsEta = dbe_->book1D("hl3AbsEta", "|eta| of hlt L3 objects", 8, 0, 2); + hl3AbsEta->setAxisTitle("eta", 1); + hl3phi = dbe_->book1D("hl3phi", "phi of hlt L3 objects", 16, -3.2, 3.2); + hl3phi->setAxisTitle("phi", 1); + + hOffEta = dbe_->book1D("hOffEta", "eta of alcareco objects", 100, -2, 2); + hOffEta->setAxisTitle("eta", 1); + hOffPhi = dbe_->book1D("hOffPhi", "phi of alcareco objects", 100, -3.2, 3.2); + hOffPhi->setAxisTitle("phi", 1); + hOffP = dbe_->book1D("hOffP", "p of alcareco objects", 1000, 0, 1000); + hOffP->setAxisTitle("E(GeV)", 1); + hOffP_0005 = dbe_->book1D("hOffP_0005", "p of alcareco objects, |eta|<0.5", 1000, 0, 1000); + hOffP_0005->setAxisTitle("E(GeV)", 1); + hOffP_0510 = dbe_->book1D("hOffP_0510", "p of alcareco objects, 0.5<|eta|<1.0", 1000, 0, 1000); + hOffP_0510->setAxisTitle("E(GeV)", 1); + hOffP_1015 = dbe_->book1D("hOffP_1015", "p of alcareco objects, 1.0<|eta|<1.5", 1000, 0, 1000); + hOffP_1015->setAxisTitle("E(GeV)", 1); + hOffP_1520 = dbe_->book1D("hOffP_1520", "p of alcareco objects, 1.5<|eta|<2.0", 1000, 0, 1000); + hOffP_1520->setAxisTitle("E(GeV)", 1); + hOffEtaFP = dbe_->book1D("hOffEtaFP", "eta of alcareco objects, FP", 16, -2, 2); + hOffEtaFP->setAxisTitle("eta", 1); + hOffAbsEta = dbe_->book1D("hOffAbsEta", "|eta| of alcareco objects", 8, 0, 2); + hOffAbsEta->setAxisTitle("|eta|", 1); + hOffPhiFP = dbe_->book1D("hOffPhiFP", "phi of alcareco objects, FP", 16, -3.2, 3.2); + hOffPhiFP->setAxisTitle("phi", 1); + hTracksSumP = dbe_->book1D("hTracksSumP", "summary p of tracks in the isolation cone", 100, 0, 20); hTracksSumP->setAxisTitle("E(GeV)"); - hTracksMaxP=dbe_->book1D("hTracksMaxP","maximum p among tracks in the isolation cone",100,0,20); + hTracksMaxP = dbe_->book1D("hTracksMaxP", "maximum p among tracks in the isolation cone", 100, 0, 20); hTracksMaxP->setAxisTitle("E(GeV)"); - hDeposEcalInner=dbe_->book1D("hDeposEcalInner","ecal energy deposition in inner cone around track",1000,0,1000); + hDeposEcalInner = dbe_->book1D("hDeposEcalInner", "ecal energy deposition in inner cone around track", 1000, 0, 1000); hDeposEcalInner->setAxisTitle("E(GeV)"); - hDeposEcalOuter=dbe_->book1D("hDeposEcalOuter","ecal energy deposition in outer cone around track",1000,0,1000); + hDeposEcalOuter = dbe_->book1D("hDeposEcalOuter", "ecal energy deposition in outer cone around track", 1000, 0, 1000); hDeposEcalOuter->setAxisTitle("E(GeV)"); - hOccupancyFull=dbe_->book2D("hOccupancyFull","number of tracks per tower, full energy range",48,-25,25,73,0,73); - hOccupancyFull->setAxisTitle("ieta",1); - hOccupancyFull->setAxisTitle("iphi",2); + hOccupancyFull = + dbe_->book2D("hOccupancyFull", "number of tracks per tower, full energy range", 48, -25, 25, 73, 0, 73); + hOccupancyFull->setAxisTitle("ieta", 1); + hOccupancyFull->setAxisTitle("iphi", 2); hOccupancyFull->getTH2F()->SetOption("colz"); hOccupancyFull->getTH2F()->SetStats(kFALSE); - hOccupancyHighEn=dbe_->book2D("hOccupancyHighEn","number of tracks per tower, high energy tracks",48,-25,25,73,0,73); - hOccupancyHighEn->setAxisTitle("ieta",1); - hOccupancyHighEn->setAxisTitle("iphi",2); + hOccupancyHighEn = + dbe_->book2D("hOccupancyHighEn", "number of tracks per tower, high energy tracks", 48, -25, 25, 73, 0, 73); + hOccupancyHighEn->setAxisTitle("ieta", 1); + hOccupancyHighEn->setAxisTitle("iphi", 2); hOccupancyHighEn->getTH2F()->SetOption("colz"); hOccupancyHighEn->getTH2F()->SetStats(kFALSE); - hOffL3TrackMatch=dbe_->book1D("hOffL3TrackMatch","Distance from L3 object to offline track",200,0,0.5); - hOffL3TrackMatch->setAxisTitle("R(eta,phi)",1); - hOffL3TrackPtRat=dbe_->book1D("hOffL3TrackPtRat","Ratio of pT: L3/offline",100,0,10); - hOffL3TrackPtRat->setAxisTitle("ratio L3/offline",1); + hOffL3TrackMatch = dbe_->book1D("hOffL3TrackMatch", "Distance from L3 object to offline track", 200, 0, 0.5); + hOffL3TrackMatch->setAxisTitle("R(eta,phi)", 1); + hOffL3TrackPtRat = dbe_->book1D("hOffL3TrackPtRat", "Ratio of pT: L3/offline", 100, 0, 10); + hOffL3TrackPtRat->setAxisTitle("ratio L3/offline", 1); + // Sergey + -// Sergey + + hSimPt = dbe_->book1D("hSimPt", "pT of matched SimTrack", 1000, 0, 1000); + hSimPt->setAxisTitle("pT(GeV)", 1); - hSimPt=dbe_->book1D("hSimPt","pT of matched SimTrack",1000,0,1000); - hSimPt->setAxisTitle("pT(GeV)",1); + hSimPhi = dbe_->book1D("hSimPhi", "Phi of matched SimTrack", 100, -3.2, 3.2); + hSimPhi->setAxisTitle("phi", 1); - hSimPhi=dbe_->book1D("hSimPhi","Phi of matched SimTrack",100,-3.2,3.2); - hSimPhi->setAxisTitle("phi",1); - - hSimEta=dbe_->book1D("hSimEta","Eta of matched SimTrack",100,-2.,2.); - hSimEta->setAxisTitle("eta",1); - - hSimAbsEta=dbe_->book1D("hSimAbsEta","|eta| of matched SimTrack",8,0.,2.); - hSimAbsEta->setAxisTitle("|eta|",1); + hSimEta = dbe_->book1D("hSimEta", "Eta of matched SimTrack", 100, -2., 2.); + hSimEta->setAxisTitle("eta", 1); - hSimDist=dbe_->book1D("hSimDist","Distance from matched SimTrack to Offline Track",200,0,0.1); - hSimDist->setAxisTitle("R(eta,phi)",1); + hSimAbsEta = dbe_->book1D("hSimAbsEta", "|eta| of matched SimTrack", 8, 0., 2.); + hSimAbsEta->setAxisTitle("|eta|", 1); - hSimPtRatOff=dbe_->book1D("hSimPtRatOff","pT Sim / pT Offline",100,0,10); - hSimPtRatOff->setAxisTitle("pT Sim / pT Offline",1); + hSimDist = dbe_->book1D("hSimDist", "Distance from matched SimTrack to Offline Track", 200, 0, 0.1); + hSimDist->setAxisTitle("R(eta,phi)", 1); - hSimP=dbe_->book1D("hSimP","p of matched SimTrack",1000,0,1000); - hSimP->setAxisTitle("p(GeV)",1); - - hSimN=dbe_->book1D("hSimN","Number matched",2,0,2); - hSimN->setAxisTitle("Offline/SimTRack - Matched or Not",1); + hSimPtRatOff = dbe_->book1D("hSimPtRatOff", "pT Sim / pT Offline", 100, 0, 10); + hSimPtRatOff->setAxisTitle("pT Sim / pT Offline", 1); - hSimNN=dbe_->book1D("hSimNN","Number of the neutral particles in cone on ECAL",100,0,100); - hSimNN->setAxisTitle("Number",1); + hSimP = dbe_->book1D("hSimP", "p of matched SimTrack", 1000, 0, 1000); + hSimP->setAxisTitle("p(GeV)", 1); - hSimNE=dbe_->book1D("hSimNE","Total energy of the neutral particles in cone on ECAL",100,0,100); - hSimNE->setAxisTitle("Energy",1); + hSimN = dbe_->book1D("hSimN", "Number matched", 2, 0, 2); + hSimN->setAxisTitle("Offline/SimTRack - Matched or Not", 1); - hSimNM=dbe_->book1D("hSimNM","Maximum energy of the neutral particles in cone on ECAL",100,0,100); - hSimNM->setAxisTitle("Energy",1); - -// Sergey - + hSimNN = dbe_->book1D("hSimNN", "Number of the neutral particles in cone on ECAL", 100, 0, 100); + hSimNN->setAxisTitle("Number", 1); + + hSimNE = dbe_->book1D("hSimNE", "Total energy of the neutral particles in cone on ECAL", 100, 0, 100); + hSimNE->setAxisTitle("Energy", 1); + hSimNM = dbe_->book1D("hSimNM", "Maximum energy of the neutral particles in cone on ECAL", 100, 0, 100); + hSimNM->setAxisTitle("Energy", 1); + // Sergey - } void ValidationHcalIsoTrackAlCaReco::endJob() { - -if(dbe_) - { - if (saveToFile_) dbe_->save(outRootFileName_); + if (dbe_) { + if (saveToFile_) + dbe_->save(outRootFileName_); } } #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(ValidationHcalIsoTrackAlCaReco); - diff --git a/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.h b/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.h index b015eacd97441..6d6654f7c4b28 100644 --- a/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.h +++ b/Calibration/HcalCalibAlgos/test/ValidationHcalIsoTrackAlCaReco.h @@ -2,7 +2,7 @@ // // Package: Calibration/HcalCalibAlgos/plugins // Class: ValidationHcalIsoTrackAlCaReco -// +// /**\class ValidationHcalIsoTrackAlCaReco ValidationHcalIsoTrackAlCaReco.cc Calibration/HcalCalibAlgos/plugins/ValidationHcalIsoTrackAlCaReco.cc Description: @@ -16,7 +16,6 @@ // // - // system include files #include @@ -57,7 +56,6 @@ #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h" #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h" - // Sergey + #include "SimDataFormats/Track/interface/SimTrack.h" @@ -65,7 +63,6 @@ // Sergey - - #include #include "TH1F.h" @@ -74,15 +71,13 @@ class ValidationHcalIsoTrackAlCaReco : public edm::EDAnalyzer { public: explicit ValidationHcalIsoTrackAlCaReco(const edm::ParameterSet&); ~ValidationHcalIsoTrackAlCaReco(); - - -private: - DQMStore* dbe_; +private: + DQMStore* dbe_; - virtual void beginJob() ; + virtual void beginJob(); virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob() ; + virtual void endJob(); std::string folderName_; bool saveToFile_; @@ -97,7 +92,7 @@ class ValidationHcalIsoTrackAlCaReco : public edm::EDAnalyzer { double pThr_; double heLow_; double heUp_; - + MonitorElement* hl3Pt; MonitorElement* hl3eta; MonitorElement* hl3AbsEta; @@ -124,14 +119,14 @@ class ValidationHcalIsoTrackAlCaReco : public edm::EDAnalyzer { MonitorElement* hOffEta; MonitorElement* hOffPhi; - + MonitorElement* hOccupancyFull; MonitorElement* hOccupancyHighEn; MonitorElement* hPurityEta; MonitorElement* hPurityPhi; -// Sergey + + // Sergey + MonitorElement* hSimPt; MonitorElement* hSimPhi; @@ -145,19 +140,18 @@ class ValidationHcalIsoTrackAlCaReco : public edm::EDAnalyzer { MonitorElement* hSimNE; MonitorElement* hSimNM; -// Sergey - + // Sergey - int nTotal; int nHLTL3accepts; - + double getDist(double, double, double, double); -// Sergey + + // Sergey + double getDistInCM(double eta1, double phi1, double eta2, double phi2); -// Sergey - + // Sergey - std::pair towerIndex(double eta, double phi); - }; From e930fcb7c312cf6259ed33436b318dc748883bbc Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Sun, 24 Mar 2019 17:10:02 +0100 Subject: [PATCH 619/686] Dyt v2 code copied in 10_6_X --- .../interface/DynamicTruncation.h | 8 +++- .../src/DynamicTruncation.cc | 41 +++++++++++++++---- .../src/GlobalMuonRefitter.cc | 4 +- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 45800deffa945..9075b7665caf0 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -45,6 +45,10 @@ class DynamicTruncation { public: + /* Variables for v2 */ + double p_reco; + double eta_reco; + typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer; typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer; @@ -63,7 +67,7 @@ class DynamicTruncation { void setUseAPE(bool); // Return the vector with the tracker plus the selected muon hits - TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory&); + TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory&, double globalMomentum, double globalEta); // Return the DYTInfo object reco::DYTInfo getDYTInfo() { @@ -77,7 +81,7 @@ class DynamicTruncation { private: void compatibleDets(TrajectoryStateOnSurface&, std::map >&); - void filteringAlgo(); + void filteringAlgo(double momentum,double eta); void fillSegmentMaps(std::map >&, std::map >&, std::map >&); void preliminaryFit(std::map >, std::map >, std::map >); bool chooseLayers(int&, double const &, DTRecSegment4D const &, TrajectoryStateOnSurface const &, double const &, CSCSegment const &, TrajectoryStateOnSurface const &); diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index cc3b98190b4f2..e261a3de571f7 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -135,7 +135,7 @@ void DynamicTruncation::setThr(const vector& thr) { //===> filter -TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Trajectory& traj) { +TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Trajectory& traj, double globalMomentum, double globalEta) { result.clear(); prelFitMeas.clear(); @@ -143,6 +143,9 @@ TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Tr dtApeMap = thrManager->GetDTApeMap(); cscApeMap = thrManager->GetCSCApeMap(); + double momentum = globalMomentum; + double eta = globalEta; + // Get Last tracker TSOS (updated) vector muonMeasurements = traj.measurements(); TrajectoryMeasurement lastTKm = muonMeasurements.front(); @@ -164,20 +167,23 @@ TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Tr prelFitMeas = result; // Run the DYT - filteringAlgo(); + filteringAlgo(momentum,eta); //filteringAlgo(); return result; } //===> filteringAlgo -void DynamicTruncation::filteringAlgo() { +void DynamicTruncation::filteringAlgo(double momentum,double eta) { map > compatibleIds; map > dtSegMap; map > cscSegMap; int incompConLay = 0; nStationsUsed = 0; + p_reco = momentum; + eta_reco = eta; + // Get list of compatible layers compatibleDets(currentState, compatibleIds); @@ -460,10 +466,31 @@ void DynamicTruncation::getThresholdFromDB(double& thr, DetId const& id) { //===> correctThrByPtAndEta void DynamicTruncation::correctThrByPtAndEta(double& thr) { - ////////////////////////////////////// - // This section will be implemented // - // after the release of APEs // - ////////////////////////////////////// + //double p = p_reco; + //double p08[2] = { -0.919853, 0.990742}; + //double p12[4] = { -0.897354, 0.987738}; + //double p20[3] = { -0.986855, 0.998516}; + //double p22[2] = { -0.940342, 0.992955}; + //double p24[2] = { -0.947633, 0.993762}; + //double thr50[5] = { 1, 1, 4, 1, 1}; + + if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ){ + thr = 24; //3000-> 26; //400-> 11; //1000-> 19; //2000-> 25; + //thr = thr50[0] * ( 1 + p08[0]*p + TMath::Power( p, p08[1])); + } else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ){ + thr = 38; //3000-> 29; //400-> 14; //1000-> 22; //2000-> 27; + //thr = thr50[1] * ( 1 + p12[0]*p + TMath::Power( p, p12[1])); + } else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ){ + thr = 19; //3000-> 20; //400-> 10; //1000-> 16; //2000-> 19; + //thr = thr50[2] * ( 1 + p20[0]*p + TMath::Power( p, p20[1])); + } else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ){ + thr = 16; //3000-> 16; //400-> 8; //1000-> 13; //2000-> 15; + //thr = thr50[3] * ( 1 + p22[0]*p + TMath::Power( p, p22[1])); + } else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ){ + thr = 14; //3000-> 12; //400-> 8; //1000-> 11; //2000-> 13; + //thr = thr50[4] * ( 1 + p24[0]*p + TMath::Power( p, p24[1])); + } + //thr = 10; } diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index e2c663a43d5a9..83e1bb9cde472 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -271,13 +271,15 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, // // DYT 2.0 // + double momentum = globalTrack.p(); + double eta = globalTrack.eta(); DynamicTruncation dytRefit(*theEvent,*theService); dytRefit.setProd(all4DSegments, CSCSegments); dytRefit.setSelector(theDYTselector); dytRefit.setThr(theDYTthrs); dytRefit.setUpdateState(theDYTupdator); dytRefit.setUseAPE(theDYTuseAPE); - DYTRecHits = dytRefit.filter(globalTraj.front()); + DYTRecHits = dytRefit.filter(globalTraj.front() ,momentum, eta); dytInfo->CopyFrom(dytRefit.getDYTInfo()); if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag())) stable_sort(DYTRecHits.begin(),DYTRecHits.end(),RecHitLessByDet(alongMomentum)); From e933af233619460bf00c64ea1d888fe53edd8941 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Sat, 30 Mar 2019 01:54:44 +0100 Subject: [PATCH 620/686] Add analytic function for threshold plus parameters modified: RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h modified: RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc - new namespace 'dyt_utils' that contains EtaRegion enum - p_reco and eta_reco private variables - function to obtain the EtaRegion - lambda expr for threshold analytic parametrization modified: RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py modified: RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py - add bool for selectig dyt version to use - add PSet for threshold functions parameters modified: RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc - add few lines in dyt block --- .../GlobalMuonProducer/python/tevMuons_cfi.py | 9 +- .../interface/DynamicTruncation.h | 47 +++-- .../interface/GlobalMuonRefitter.h | 37 ++-- .../python/GlobalMuonRefitter_cff.py | 13 +- .../GlobalTrajectoryBuilderCommon_cff.py | 18 +- .../src/DynamicTruncation.cc | 120 +++++++++---- .../src/GlobalMuonRefitter.cc | 160 +++++++++--------- 7 files changed, 245 insertions(+), 159 deletions(-) diff --git a/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py b/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py index 789ae86e4127a..ab56a296aa931 100644 --- a/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py +++ b/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py @@ -9,9 +9,9 @@ # InputTag MuonCollectionLabel = standAloneMuons:UpdatedAtVtx MuonServiceProxy, RefitIndex = cms.vint32(1, 2, 3, 4), - Refits = cms.vstring('default', - 'firstHit', - 'picky', + Refits = cms.vstring('default', + 'firstHit', + 'picky', 'dyt'), MuonCollectionLabel = cms.InputTag("globalMuons"), RefitterParameters = cms.PSet( @@ -26,6 +26,3 @@ RefitterParameters = dict(TrackerRecHitBuilder = 'WithoutRefit', Propagator = "SmartPropagatorAny") ) - - - diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 9075b7665caf0..4d820ea9acb14 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -13,6 +13,7 @@ * Authors : * D. Pagano & G. Bruno - UCL Louvain * + * \modified by C. Caputo, UCLouvain **/ #include @@ -40,23 +41,22 @@ #include "RecoMuon/GlobalTrackingTools/interface/ThrParameters.h" #include "RecoMuon/GlobalTrackingTools/interface/ChamberSegmentUtility.h" +namespace dyt_utils{ + enum class etaRegion {eta0p8, eta1p2, eta2p0, eta2p2, eta2p4}; +}; class DynamicTruncation { - - public: - /* Variables for v2 */ - double p_reco; - double eta_reco; + public: typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer; typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer; - DynamicTruncation(const edm::Event&, const MuonServiceProxy&); + DynamicTruncation(const edm::Event&, const MuonServiceProxy&, const edm::ParameterSet&); ~DynamicTruncation(); - void setProd(const edm::Handle& DTSegProd, + void setProd(const edm::Handle& DTSegProd, const edm::Handle& CSCSegProd) { getSegs->initCSU(DTSegProd, CSCSegProd); } @@ -65,11 +65,21 @@ class DynamicTruncation { void setThr(const std::vector&); void setUpdateState(bool); void setUseAPE(bool); - + /*---- DyT v2-----*/ + void setRecoP(double p) { + p_reco = p; + useParametrizedThr = true; + } + void setRecoEta(double eta) { + eta_reco = eta; + useParametrizedThr = true; + setEtaRegion(); + } + // Return the vector with the tracker plus the selected muon hits - TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory&, double globalMomentum, double globalEta); + TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory&); - // Return the DYTInfo object + // Return the DYTInfo object reco::DYTInfo getDYTInfo() { dytInfo.setNStUsed(nStationsUsed); dytInfo.setDYTEstimators(estimatorMap); @@ -78,10 +88,12 @@ class DynamicTruncation { return dytInfo; } + void correctThrByPtAndEta(); + private: void compatibleDets(TrajectoryStateOnSurface&, std::map >&); - void filteringAlgo(double momentum,double eta); + void filteringAlgo(); void fillSegmentMaps(std::map >&, std::map >&, std::map >&); void preliminaryFit(std::map >, std::map >, std::map >); bool chooseLayers(int&, double const &, DTRecSegment4D const &, TrajectoryStateOnSurface const &, double const &, CSCSegment const &, TrajectoryStateOnSurface const &); @@ -98,7 +110,8 @@ class DynamicTruncation { void useSegment(DTRecSegment4D const &, TrajectoryStateOnSurface const &); void useSegment(CSCSegment const &, TrajectoryStateOnSurface const &); void sort(ConstRecHitContainer&); - + void setEtaRegion(); + ConstRecHitContainer result, prelFitMeas; bool useAPE; std::vector Thrs; @@ -121,15 +134,19 @@ class DynamicTruncation { TrajectoryStateOnSurface prelFitState; reco::DYTInfo dytInfo; std::map dtApeMap; - std::map cscApeMap; + std::map cscApeMap; double muonPTest, muonETAest; const DYTThrObject* dytThresholds; ChamberSegmentUtility* getSegs; ThrParameters* thrManager; bool useDBforThr; bool doUpdateOfKFStates; + /* Variables for v2 */ + double p_reco; + double eta_reco; + bool useParametrizedThr; + dyt_utils::etaRegion region; + std::map> parameters; }; #endif - - diff --git a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h index 3bb2eb47873c8..6aa14dc911ce6 100644 --- a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h +++ b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h @@ -9,7 +9,7 @@ * \author C. Liu Purdue University * \author A. Everett Purdue University * - * \modified by C. Calabria INFN & Universita  Bari + * \modified by C. Calabria INFN & Universita� Bari * \modified by D. Nash Northeastern University */ @@ -67,7 +67,7 @@ class GlobalMuonRefitter { /// constructor with Parameter Set and MuonServiceProxy GlobalMuonRefitter(const edm::ParameterSet&, const MuonServiceProxy*, edm::ConsumesCollector&); - + /// destructor virtual ~GlobalMuonRefitter(); @@ -78,7 +78,7 @@ class GlobalMuonRefitter { void setServices(const edm::EventSetup&); /// build combined trajectory from sta Track and tracker RecHits - std::vector refit(const reco::Track& globalTrack, const int theMuonHitsOption, + std::vector refit(const reco::Track& globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const; /// build combined trajectory from subset of sta Track and tracker RecHits @@ -92,30 +92,30 @@ class GlobalMuonRefitter { std::vector transform(const reco::Track& newTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer& recHitsForReFit) const; - + // get rid of selected station RecHits ConstRecHitContainer getRidOfSelectStationHits(const ConstRecHitContainer& hits, const TrackerTopology *tTopo) const; - // return DYT-related informations + // return DYT-related informations const reco::DYTInfo* getDYTInfo() {return dytInfo;} - + protected: enum RefitDirection{insideOut,outsideIn,undetermined}; - + /// check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit - void checkMuonHits(const reco::Track&, ConstRecHitContainer&, + void checkMuonHits(const reco::Track&, ConstRecHitContainer&, std::map &) const; - /// get the RecHits in the tracker and the first muon chamber with hits - void getFirstHits(const reco::Track&, ConstRecHitContainer&, + /// get the RecHits in the tracker and the first muon chamber with hits + void getFirstHits(const reco::Track&, ConstRecHitContainer&, ConstRecHitContainer&) const; - + /// select muon hits compatible with trajectory; check hits in chambers with showers - ConstRecHitContainer selectMuonHits(const Trajectory&, + ConstRecHitContainer selectMuonHits(const Trajectory&, const std::map &) const; - + /// print all RecHits of a trajectory void printHits(const ConstRecHitContainer&) const; @@ -129,7 +129,7 @@ class GlobalMuonRefitter { float thePtCut; private: - + int theMuonHitsOption; float theProbCut; int theHitThreshold; @@ -157,10 +157,10 @@ class GlobalMuonRefitter { int theTrackerSkipSystem; int theTrackerSkipSection; - unsigned long long theCacheId_TRH; + unsigned long long theCacheId_TRH; std::string thePropagatorName; - + bool theRPCInTheFit; double theRescaleErrorFactor; @@ -172,14 +172,15 @@ class GlobalMuonRefitter { bool theDYTupdator; bool theDYTuseAPE; reco::DYTInfo *dytInfo; + edm::ParameterSet theDYTthrsParameters; std::string theFitterName; std::unique_ptr theFitter; - + std::string theTrackerRecHitBuilderName; edm::ESHandle theTrackerRecHitBuilder; TkClonerImpl hitCloner; - + std::string theMuonRecHitBuilderName; edm::ESHandle theMuonRecHitBuilder; diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py index 8c08ec7afa041..87c7cd9a8cdc3 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py @@ -26,13 +26,22 @@ RefitDirection = cms.string('insideOut'), PropDirForCosmics = cms.bool(False), RefitRPCHits = cms.bool(True), - + # DYT stuff DYTthrs = cms.vint32(10, 10), DYTselector = cms.int32(1), DYTupdator = cms.bool(True), DYTuseAPE = cms.bool(False), - + ## Parameters for DYT threshold parametrization + DYTuseThrsParametrization = cms.bool(True), + DYTthrsParameters = cms.PSet( + eta0p8 = cms.vdouble(-0.919853, 0.990742), + eta1p2 = cms.vdouble(-0.897354, 0.987738), + eta2p0 = cms.vdouble(-0.986855, 0.998516), + eta2p2 = cms.vdouble(-0.940342, 0.992955), + eta2p4 = cms.vdouble(-0.947633, 0.993762), + thr50 = cms.vdouble(1, 1, 4, 1, 1), + ), # muon station to be skipped SkipStation = cms.int32(-1), diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py index f3db179246ef4..37dc256495e9d 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py @@ -41,7 +41,7 @@ Chi2CutME0 = cms.double(1.0), Chi2CutRPC = cms.double(1.0), HitThreshold = cms.int32(1), - + Fitter = cms.string('GlbMuKFFitter'), Propagator = cms.string('SmartPropagatorAnyRK'), TrackerRecHitBuilder = cms.string('WithAngleAndTemplate'), @@ -50,19 +50,29 @@ RefitDirection = cms.string('insideOut'), PropDirForCosmics = cms.bool(False), RefitRPCHits = cms.bool(True), - + # DYT stuff DYTthrs = cms.vint32(20, 30), DYTselector = cms.int32(1), DYTupdator = cms.bool(False), DYTuseAPE = cms.bool(False), + ## Parameters for DYT threshold parametrization + DYTuseThrsParametrization = cms.bool(True), + DYTthrsParameters = cms.PSet( + eta0p8 = cms.vdouble(-0.919853, 0.990742), + eta1p2 = cms.vdouble(-0.897354, 0.987738), + eta2p0 = cms.vdouble(-0.986855, 0.998516), + eta2p2 = cms.vdouble(-0.940342, 0.992955), + eta2p4 = cms.vdouble(-0.947633, 0.993762), + thr50 = cms.vdouble(1, 1, 4, 1, 1), + ), # muon station to be skipped SkipStation = cms.int32(-1), - + # PXB = 1, PXF = 2, TIB = 3, TID = 4, TOB = 5, TEC = 6 TrackerSkipSystem = cms.int32(-1), - + # layer, wheel, or disk depending on the system TrackerSkipSection = cms.int32(-1), diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index e261a3de571f7..b8c52209e96cf 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -9,6 +9,7 @@ * Authors : * D. Pagano & G. Bruno - UCL Louvain * + * \modified by C. Caputo, UCLouvain **/ #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -33,9 +34,17 @@ using namespace edm; using namespace std; using namespace reco; +namespace dyt_utils{ + std::map etaRegionStr { {etaRegion::eta0p8, "eta0p8"}, + {etaRegion::eta1p2, "eta1p2"}, + {etaRegion::eta2p0, "eta2p0"}, + {etaRegion::eta2p2, "eta2p2"}, + {etaRegion::eta2p4, "eta2p4"}}; +}; -DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceProxy& theService) { + +DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceProxy& theService, const edm::ParameterSet& par) { propagator = theService.propagator("SmartPropagatorAny"); propagatorPF = theService.propagator("SmartPropagatorAny"); propagatorCompatibleDet = theService.propagator("SmartPropagatorAny"); @@ -50,7 +59,12 @@ DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceP thrManager = new ThrParameters(&theService.eventSetup()); useDBforThr = thrManager->isValidThdDB(); if (useDBforThr) dytThresholds = thrManager->getInitialThresholds(); + doUpdateOfKFStates = true; + useParametrizedThr = false; + for (auto const& region : dyt_utils::etaRegionStr ){ + parameters[region.first] = par.getParameter< std::vector >(region.second); + } } DynamicTruncation::~DynamicTruncation() { @@ -68,7 +82,7 @@ void DynamicTruncation::updateWithDThits(TrajectoryStateOnSurface& tsos, DTRecSe ConstRecHitContainer tmprecHits; vector DTrh = bestDTSeg.recHits(); for (vector::iterator it = DTrh.begin(); it != DTrh.end(); it++) { - tmprecHits.push_back(theMuonRecHitBuilder->build(*it)); + tmprecHits.push_back(theMuonRecHitBuilder->build(*it)); } sort(tmprecHits); for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) { @@ -90,7 +104,7 @@ void DynamicTruncation::updateWithCSChits(TrajectoryStateOnSurface& tsos, CSCSeg sort(tmprecHits); for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) { const CSCLayer* cscLayer = cscGeom->layer((*it)->det()->geographicalId()); - TrajectoryStateOnSurface temp = propagator->propagate(tsos, cscLayer->surface()); + TrajectoryStateOnSurface temp = propagator->propagate(tsos, cscLayer->surface()); if (temp.isValid()) { TrajectoryStateOnSurface tempTsos = updatorHandle->update(temp, **it); if (tempTsos.isValid() ) tsos = tempTsos; @@ -135,17 +149,14 @@ void DynamicTruncation::setThr(const vector& thr) { //===> filter -TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Trajectory& traj, double globalMomentum, double globalEta) { +TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Trajectory& traj) { result.clear(); prelFitMeas.clear(); - - // Get APE maps + + // Get APE maps dtApeMap = thrManager->GetDTApeMap(); cscApeMap = thrManager->GetCSCApeMap(); - double momentum = globalMomentum; - double eta = globalEta; - // Get Last tracker TSOS (updated) vector muonMeasurements = traj.measurements(); TrajectoryMeasurement lastTKm = muonMeasurements.front(); @@ -167,28 +178,25 @@ TransientTrackingRecHit::ConstRecHitContainer DynamicTruncation::filter(const Tr prelFitMeas = result; // Run the DYT - filteringAlgo(momentum,eta); //filteringAlgo(); - + filteringAlgo(); + return result; } //===> filteringAlgo -void DynamicTruncation::filteringAlgo(double momentum,double eta) { +void DynamicTruncation::filteringAlgo() { map > compatibleIds; map > dtSegMap; map > cscSegMap; int incompConLay = 0; nStationsUsed = 0; - p_reco = momentum; - eta_reco = eta; - // Get list of compatible layers compatibleDets(currentState, compatibleIds); // Fill segment maps - fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap); + fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap); // Do a preliminary fit if (useDBforThr) preliminaryFit(compatibleIds, dtSegMap, cscSegMap); @@ -203,7 +211,7 @@ void DynamicTruncation::filteringAlgo(double momentum,double eta) { vector dtSegs = dtSegMap[it->first]; vector cscSegs = cscSegMap[it->first]; - // DT case: find the most compatible segment + // DT case: find the most compatible segment TrajectoryStateOnSurface tsosDTlayer; testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer); @@ -213,7 +221,7 @@ void DynamicTruncation::filteringAlgo(double momentum,double eta) { // Decide whether to keep the layer or not bool chosenLayer = chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer); - fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg); + fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg); } //cout << "Number of used stations = " << nStationsUsed << endl; } @@ -234,7 +242,7 @@ int DynamicTruncation::stationfromDet(DetId const& det) { //===> fillDYTInfos -void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int &incompConLay, +void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int &incompConLay, double const &bestDTEstimator, double const &bestCSCEstimator, DTRecSegment4D const &bestDTSeg, CSCSegment const &bestCSCSeg) { if (chosenLayer) { @@ -242,7 +250,7 @@ void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int incompConLay = 0; if (bestDTEstimator <= bestCSCEstimator) { estimatorMap[st] = bestDTEstimator; - DetId id(bestDTSeg.chamberId()); + DetId id(bestDTSeg.chamberId()); idChamberMap[st] = id; } else { DetId id(bestCSCSeg.cscDetId()); @@ -271,7 +279,7 @@ void DynamicTruncation::compatibleDets(TrajectoryStateOnSurface &tsos, mapsubDetector() != GeomDetEnumerators::CSC) continue; ilayerCorrected++; vector comps = navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator); - //cout << comps.size() << " compatible Dets with " << navLayers[ilayer]->subDetector() << " Layer " << ilayer << " " + //cout << comps.size() << " compatible Dets with " << navLayers[ilayer]->subDetector() << " Layer " << ilayer << " " //<< dumper.dumpLayer(navLayers[ilayer]); if (!comps.empty()) { for ( unsigned int icomp=0; icomp > &compatibleIds //===> testDTstation -void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, vector const &segments, +void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, vector const &segments, double &bestEstimator, DTRecSegment4D &bestSeg, TrajectoryStateOnSurface &tsosdt) { if (segments.empty()) return; for (unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) { @@ -318,9 +326,9 @@ void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, v LocalError apeLoc; if (useAPE) apeLoc = ErrorFrameTransformer().transform(dtApeMap.find(chamber)->second, theG->idToDet(chamber)->surface()); StateSegmentMatcher estim(tsosdt, segments[iSeg], apeLoc); - double estimator = estim.value(); + double estimator = estim.value(); //cout << "estimator DT = " << estimator << endl; - if (estimator >= bestEstimator) continue; + if (estimator >= bestEstimator) continue; bestEstimator = estimator; bestSeg = segments[iSeg]; } @@ -328,7 +336,7 @@ void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, v //===> testCSCstation -void DynamicTruncation::testCSCstation(TrajectoryStateOnSurface &startingState, vector const &segments, +void DynamicTruncation::testCSCstation(TrajectoryStateOnSurface &startingState, vector const &segments, double &bestEstimator, CSCSegment &bestSeg, TrajectoryStateOnSurface &tsoscsc) { if (segments.empty()) return; for (unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) { @@ -343,7 +351,7 @@ void DynamicTruncation::testCSCstation(TrajectoryStateOnSurface &startingState, //cout << "estimator CSC = " << estimator << endl; if (estimator >= bestEstimator) continue; bestEstimator = estimator; - bestSeg = segments[iSeg]; + bestSeg = segments[iSeg]; } } @@ -356,7 +364,7 @@ void DynamicTruncation::useSegment(DTRecSegment4D const &bestDTSeg, TrajectorySt } -//===> useSegment +//===> useSegment void DynamicTruncation::useSegment(CSCSegment const &bestCSCSeg, TrajectoryStateOnSurface const &tsosCSC) { result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg)); if (doUpdateOfKFStates) updateWithCSChits(currentState, bestCSCSeg); @@ -412,9 +420,9 @@ void DynamicTruncation::preliminaryFit(map > compatibleIds, m } if (!prelFitMeas.empty()) prelFitMeas.pop_back(); for (auto imrh = prelFitMeas.rbegin(); imrh != prelFitMeas.rend(); ++imrh) { - DetId id = (*imrh)->geographicalId(); + DetId id = (*imrh)->geographicalId(); TrajectoryStateOnSurface tmp = propagatorPF->propagate(prelFitState, theG->idToDet(id)->surface()); - if (tmp.isValid()) prelFitState = tmp; + if (tmp.isValid()) prelFitState = tmp; } muonPTest = prelFitState.globalMomentum().perp(); muonETAest = prelFitState.globalMomentum().eta(); @@ -422,17 +430,17 @@ void DynamicTruncation::preliminaryFit(map > compatibleIds, m //===> chooseLayers -bool DynamicTruncation::chooseLayers(int &incompLayers, double const &bestDTEstimator, DTRecSegment4D const &bestDTSeg, TrajectoryStateOnSurface const &tsosDT, +bool DynamicTruncation::chooseLayers(int &incompLayers, double const &bestDTEstimator, DTRecSegment4D const &bestDTSeg, TrajectoryStateOnSurface const &tsosDT, double const &bestCSCEstimator, CSCSegment const &bestCSCSeg, TrajectoryStateOnSurface const &tsosCSC) { double initThr = MAX_THR; if (bestDTEstimator == MAX_THR && bestCSCEstimator == MAX_THR) return false; if (bestDTEstimator <= bestCSCEstimator) { // Get threshold for the chamber if (useDBforThr) getThresholdFromDB(initThr, DetId(bestDTSeg.chamberId())); - else getThresholdFromCFG(initThr, DetId(bestDTSeg.chamberId())); + else getThresholdFromCFG(initThr, DetId(bestDTSeg.chamberId())); if (DYTselector == 0 || (DYTselector == 1 && bestDTEstimator < initThr) || (DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) { - useSegment(bestDTSeg, tsosDT); + useSegment(bestDTSeg, tsosDT); return true; } } else { @@ -459,7 +467,7 @@ void DynamicTruncation::getThresholdFromDB(double& thr, DetId const& id) { break; } } - correctThrByPtAndEta(thr); + if (useParametrizedThr) correctThrByPtAndEta(thr); } @@ -474,15 +482,21 @@ void DynamicTruncation::correctThrByPtAndEta(double& thr) { //double p24[2] = { -0.947633, 0.993762}; //double thr50[5] = { 1, 1, 4, 1, 1}; + // auto parametricThreshold = [this](float thr50, float p0, float p1){ + // return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); + // }; + + // printf("parametricThreshold(1,-0.919853, 0.990742) = %f", parametricThreshold(1,-0.919853, 0.990742)); + if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ){ thr = 24; //3000-> 26; //400-> 11; //1000-> 19; //2000-> 25; - //thr = thr50[0] * ( 1 + p08[0]*p + TMath::Power( p, p08[1])); + //thr = thr50[0] * ( 1 + p08[0]*p + TMath::Power( p, p08[1])); } else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ){ thr = 38; //3000-> 29; //400-> 14; //1000-> 22; //2000-> 27; - //thr = thr50[1] * ( 1 + p12[0]*p + TMath::Power( p, p12[1])); + //thr = thr50[1] * ( 1 + p12[0]*p + TMath::Power( p, p12[1])); } else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ){ thr = 19; //3000-> 20; //400-> 10; //1000-> 16; //2000-> 19; - //thr = thr50[2] * ( 1 + p20[0]*p + TMath::Power( p, p20[1])); + //thr = thr50[2] * ( 1 + p20[0]*p + TMath::Power( p, p20[1])); } else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ){ thr = 16; //3000-> 16; //400-> 8; //1000-> 13; //2000-> 15; //thr = thr50[3] * ( 1 + p22[0]*p + TMath::Power( p, p22[1])); @@ -494,6 +508,38 @@ void DynamicTruncation::correctThrByPtAndEta(double& thr) { } +void DynamicTruncation::setEtaRegion(){ + + if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ) region = dyt_utils::etaRegion::eta0p8; + else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ) region = dyt_utils::etaRegion::eta1p2; + else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ) region = dyt_utils::etaRegion::eta2p0; + else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ) region = dyt_utils::etaRegion::eta2p2; + else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ) region = dyt_utils::etaRegion::eta2p4; + +} + +//===> correctThrByPtAndEta +void DynamicTruncation::correctThrByPtAndEta() { + + //double p = p_reco; + //double p08[2] = { -0.919853, 0.990742}; + //double p12[4] = { -0.897354, 0.987738}; + //double p20[3] = { -0.986855, 0.998516}; + //double p22[2] = { -0.940342, 0.992955}; + //double p24[2] = { -0.947633, 0.993762}; + //double thr50[5] = { 1, 1, 4, 1, 1}; + + + auto parametricThreshold = [this](float thr50){ + double p0 = this->parameters[this->region].at(0); + double p1 = this->parameters[this->region].at(1); + return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); + }; + + printf("Muon with pt equal to = %f -- eta = %f\n", p_reco, eta_reco ); + printf("parametricThreshold(1,%f, %f) = %f \n", this->parameters[this->region].at(0), this->parameters[this->region].at(1), parametricThreshold(1)); +} + //===> getThresholdFromCFG void DynamicTruncation::getThresholdFromCFG(double& thr, DetId const& id) { @@ -503,6 +549,8 @@ void DynamicTruncation::getThresholdFromCFG(double& thr, DetId const& id) { if (id.subdetId() == MuonSubdetId::CSC) { thr = Thrs[1]; } + + if (useParametrizedThr) correctThrByPtAndEta(thr); } diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 83e1bb9cde472..8f0be6f71dca3 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -8,7 +8,7 @@ * Authors : * P. Traczyk, SINS Warsaw * - * \modified by C. Calabria, INFN & Universita  Bari + * \modified by C. Calabria, INFN & Universita� Bari * \modified by D. Nash, Northeastern University * **/ @@ -74,7 +74,7 @@ using namespace edm; GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, const MuonServiceProxy* service, - edm::ConsumesCollector& iC) : + edm::ConsumesCollector& iC) : theCosmicFlag(par.getParameter("PropDirForCosmics")), theDTRecHitLabel(par.getParameter("DTRecSegmentLabel")), theCSCRecHitLabel(par.getParameter("CSCRecSegmentLabel")), @@ -96,15 +96,15 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, if (refitDirectionName == "insideOut" ) theRefitDirection = insideOut; else if (refitDirectionName == "outsideIn" ) theRefitDirection = outsideIn; - else - throw cms::Exception("TrackTransformer constructor") + else + throw cms::Exception("TrackTransformer constructor") <<"Wrong refit direction chosen in TrackTransformer ParameterSet" << "\n" << "Possible choices are:" << "\n" << "RefitDirection = insideOut or RefitDirection = outsideIn"; - - theFitterName = par.getParameter("Fitter"); + + theFitterName = par.getParameter("Fitter"); thePropagatorName = par.getParameter("Propagator"); theSkipStation = par.getParameter("SkipStation"); @@ -121,6 +121,7 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theDYTupdator = par.existsAs("DYTupdator")?par.getParameter("DYTupdator"):false; theDYTuseAPE = par.existsAs("DYTuseAPE")?par.getParameter("DYTuseAPE"):false; dytInfo = new reco::DYTInfo(); + theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); if (par.existsAs("RescaleErrorFactor")) { theRescaleErrorFactor = par.getParameter("RescaleErrorFactor"); @@ -133,7 +134,7 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theDTRecHitToken=iC.consumes(theDTRecHitLabel); theCSCRecHitToken=iC.consumes(theCSCRecHitLabel); theGEMRecHitToken=iC.consumes(theGEMRecHitLabel); - theME0RecHitToken=iC.consumes(theME0RecHitLabel); + theME0RecHitToken=iC.consumes(theME0RecHitLabel); CSCSegmentsToken = iC.consumes(InputTag("cscSegments")); all4DSegmentsToken=iC.consumes(InputTag("dt4DSegments")); } @@ -155,8 +156,8 @@ void GlobalMuonRefitter::setEvent(const edm::Event& event) { theEvent = &event; event.getByToken(theDTRecHitToken, theDTRecHits); event.getByToken(theCSCRecHitToken, theCSCRecHits); - event.getByToken(theGEMRecHitToken, theGEMRecHits); - event.getByToken(theME0RecHitToken, theME0RecHits); + event.getByToken(theGEMRecHitToken, theGEMRecHits); + event.getByToken(theME0RecHitToken, theME0RecHits); event.getByToken(CSCSegmentsToken, CSCSegments); event.getByToken(all4DSegmentsToken, all4DSegments); } @@ -167,7 +168,7 @@ void GlobalMuonRefitter::setServices(const EventSetup& setup) { edm::ESHandle aFitter; theService->eventSetup().get().get(theFitterName,aFitter); theFitter = aFitter->clone(); - + // Transient Rechit Builders unsigned long long newCacheId_TRH = setup.get().cacheIdentifier(); @@ -185,15 +186,15 @@ void GlobalMuonRefitter::setServices(const EventSetup& setup) { // // build a combined tracker-muon trajectory // -vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, +vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const { LogTrace(theCategory) << " *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl; - + ConstRecHitContainer allRecHitsTemp; // all muon rechits temp reco::TransientTrack track(globalTrack,&*(theService->magneticField()),theService->trackingGeometry()); - + auto tkbuilder = static_cast(theTrackerRecHitBuilder.product()); for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) @@ -202,12 +203,12 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, allRecHitsTemp.push_back((**hit).cloneForFit(*tkbuilder->geometry()->idToDet( (**hit).geographicalId() ) ) ); else if ((*hit)->geographicalId().det() == DetId::Muon) { if ((*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) { - LogTrace(theCategory) << "RPC Rec Hit discarged"; + LogTrace(theCategory) << "RPC Rec Hit discarged"; continue; } allRecHitsTemp.push_back(theMuonRecHitBuilder->build(&**hit)); } - } + } vector refitted = refit(globalTrack,track,allRecHitsTemp,theMuonHitsOption, tTopo); return refitted; } @@ -239,7 +240,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, LogTrace(theCategory) << " Track momentum before refit: " << globalTrack.pt() << endl; LogTrace(theCategory) << " Hits size before : " << allRecHitsTemp.size() << endl; - allRecHits = getRidOfSelectStationHits(allRecHitsTemp, tTopo); + allRecHits = getRidOfSelectStationHits(allRecHitsTemp, tTopo); // printHits(allRecHits); LogTrace(theCategory) << " Hits size: " << allRecHits.size() << endl; @@ -254,32 +255,36 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, return vector(); } - LogTrace(theCategory) << " Initial trajectory state: " + LogTrace(theCategory) << " Initial trajectory state: " << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl; - + if (theMuonHitsOption == 1 ) outputTraj.push_back(globalTraj.front()); - + if (theMuonHitsOption == 3 ) { checkMuonHits(globalTrack, allRecHits, hitMap); selectedRecHits = selectMuonHits(globalTraj.front(),hitMap); - LogTrace(theCategory) << " Selected hits size: " << selectedRecHits.size() << endl; + LogTrace(theCategory) << " Selected hits size: " << selectedRecHits.size() << endl; outputTraj = transform(globalTrack, track, selectedRecHits); - } + } if (theMuonHitsOption == 4 ) { // - // DYT 2.0 + // DYT 2.0 // + cout << " New DyT Version !!!!!!!! ---- " << endl; double momentum = globalTrack.p(); double eta = globalTrack.eta(); - DynamicTruncation dytRefit(*theEvent,*theService); + DynamicTruncation dytRefit(*theEvent,*theService,theDYTthrsParameters); dytRefit.setProd(all4DSegments, CSCSegments); dytRefit.setSelector(theDYTselector); dytRefit.setThr(theDYTthrs); dytRefit.setUpdateState(theDYTupdator); dytRefit.setUseAPE(theDYTuseAPE); - DYTRecHits = dytRefit.filter(globalTraj.front() ,momentum, eta); + dytRefit.setRecoP(momentum); + dytRefit.setRecoEta(eta); + dytRefit.correctThrByPtAndEta(); + DYTRecHits = dytRefit.filter(globalTraj.front()); dytInfo->CopyFrom(dytRefit.getDYTInfo()); if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag())) stable_sort(DYTRecHits.begin(),DYTRecHits.end(),RecHitLessByDet(alongMomentum)); @@ -289,7 +294,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, } else if (theMuonHitsOption == 2 ) { getFirstHits(globalTrack, allRecHits, fmsRecHits); outputTraj = transform(globalTrack, track, fmsRecHits); - } + } if (!outputTraj.empty()) { @@ -299,14 +304,14 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, LogTrace(theCategory) << "No refitted Tracks... " << endl; return vector(); } - + } // // // -void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, +void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, ConstRecHitContainer& all, map &hitMap) const { @@ -316,12 +321,12 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, // loop through all muon hits and calculate the maximum # of hits in each chamber for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) { - + if ( (*imrh != nullptr ) && !(*imrh)->isValid() ) continue; - + int detRecHits = 0; MuonRecHitContainer dRecHits; - + DetId id = (*imrh)->geographicalId(); DetId chamberId; @@ -331,7 +336,7 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, if ( id.subdetId() == MuonSubdetId::DT ) { DTChamberId did(id.rawId()); chamberId=did; - + if ((*imrh)->dimension()>1) { std::vector hits2d = (*imrh)->recHits(); for (std::vector ::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) { @@ -344,7 +349,7 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, DTRecHitCollection::range dRecHits = theDTRecHits->get(lid); int layerHits=0; for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) { - double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x()); + double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x()); if ( rhitDistance < coneSize ) layerHits++; LogTrace(theCategory) << " " << (ir)->localPosition() << " " << (**hit1d).localPosition() << " Distance: " << rhitDistance << " recHits: " << layerHits << " SL: " << lid.superLayer() << endl; @@ -363,10 +368,10 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, } } } - + } else { DTLayerId lid(id.rawId()); - + // Get the 1d DT RechHits from this layer DTRecHitCollection::range dRecHits = theDTRecHits->get(lid); @@ -387,9 +392,9 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, for (std::vector ::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) { DetId id1 = (*hit2d)->geographicalId(); CSCDetId lid(id1.rawId()); - + // Get the CSC Rechits from this layer - CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(lid); + CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(lid); int layerHits=0; for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) { @@ -402,7 +407,7 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, } } else { // Get the CSC Rechits from this layer - CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(did); + CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(did); for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) { double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).mag(); @@ -482,9 +487,9 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, } //end of ME0 if else { if ( id.subdetId() != MuonSubdetId::RPC ) LogError(theCategory)<<" Wrong Hit Type "; - continue; + continue; } - + map::iterator imap=hitMap.find(chamberId); if (imap!=hitMap.end()) { if (detRecHits>imap->second) imap->second=detRecHits; @@ -492,8 +497,8 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, } // end of loop over muon rechits - for (map::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ ) - LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second <::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ ) + LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second < stations; for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) { - + int station = 0; bool use_it = true; DetId id = (*ihit)->geographicalId(); @@ -545,7 +550,7 @@ void GlobalMuonRefitter::getFirstHits(const reco::Track& muon, } if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size()) - LogInfo(theCategory) << "failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " + LogInfo(theCategory) << "failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " << station_to_keep << " stations.size " << stations.size() << " all.size " << all.size(); for (unsigned i = 0; i < stations.size(); ++i) @@ -556,19 +561,19 @@ void GlobalMuonRefitter::getFirstHits(const reco::Track& muon, // -// select muon hits compatible with trajectory; +// select muon hits compatible with trajectory; // check hits in chambers with showers // -GlobalMuonRefitter::ConstRecHitContainer -GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, +GlobalMuonRefitter::ConstRecHitContainer +GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, const map &hitMap) const { ConstRecHitContainer muonRecHits; const double globalChi2Cut = 200.0; - vector muonMeasurements = traj.measurements(); + vector muonMeasurements = traj.measurements(); - // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy + // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy for (std::vector::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) { if ( !(*im).recHit()->isValid() ) continue; @@ -576,7 +581,7 @@ GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, // if ( ( chi2ndf < globalChi2Cut ) ) muonRecHits.push_back((*im).recHit()); continue; - } + } const MuonTransientTrackingRecHit* immrh = dynamic_cast((*im).recHit().get()); DetId id = immrh->geographicalId(); @@ -621,23 +626,23 @@ GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, } else continue; - double chi2ndf = (*im).estimate()/(*im).recHit()->dimension(); + double chi2ndf = (*im).estimate()/(*im).recHit()->dimension(); bool keep = true; map::const_iterator imap=hitMap.find(chamberId); - if ( imap!=hitMap.end() ) + if ( imap!=hitMap.end() ) if (imap->second>threshold) keep = false; - + if ( (keep || (chi2ndfsecond << endl; } } - + // check order of rechits reverse(muonRecHits.begin(),muonRecHits.end()); return muonRecHits; @@ -653,12 +658,12 @@ void GlobalMuonRefitter::printHits(const ConstRecHitContainer& hits) const { for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) { if ( !(*ir)->isValid() ) { LogTrace(theCategory) << "invalid RecHit"; - continue; + continue; } - + const GlobalPoint& pos = (*ir)->globalPosition(); - - LogTrace(theCategory) + + LogTrace(theCategory) << "r = " << sqrt(pos.x() * pos.x() + pos.y() * pos.y()) << " z = " << pos.z() << " dimension = " << (*ir)->dimension() @@ -704,7 +709,7 @@ GlobalMuonRefitter::checkRecHitsOrdering(const TransientTrackingRecHit::ConstRec vector GlobalMuonRefitter::transform(const reco::Track& newTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer& urecHitsForReFit) const { - + TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit = urecHitsForReFit; LogTrace(theCategory) << "GlobalMuonRefitter::transform: " << recHitsForReFit.size() << " hits:"; printHits(recHitsForReFit); @@ -745,7 +750,7 @@ vector GlobalMuonRefitter::transform(const reco::Track& newTrack, firstTSOS = track.outermostMeasurementState(); lastTSOS = track.innermostMeasurementState(); inner_is_first = false; - } + } LogTrace(theCategory) << "firstTSOS: inner_is_first? " << inner_is_first << " globalPosition is " << firstTSOS.globalPosition() @@ -784,7 +789,7 @@ vector GlobalMuonRefitter::transform(const reco::Track& newTrack, if ((*it)->globalPosition().y() > 0) ++y_count; else --y_count; } - + PropagationDirection propDir_ycount = alongMomentum; if (y_count > 0) { if (theRefitDirection == insideOut) propDir_ycount = oppositeToMomentum; @@ -794,12 +799,12 @@ vector GlobalMuonRefitter::transform(const reco::Track& newTrack, if (theRefitDirection == insideOut) propDir_ycount = alongMomentum; else if (theRefitDirection == outsideIn) propDir_ycount = oppositeToMomentum; } - + LogTrace(theCategory) << "y_count = " << y_count << "; based on geometrically-outermost TSOS, propDir is " << propDir << ": " << (propDir == propDir_ycount ? "agrees" : "disagrees") << " with ycount determination"; - + if (propDir_first != propDir_last) { LogTrace(theCategory) << "since first/last disagreed, using y_count propDir"; propDir = propDir_ycount; @@ -819,25 +824,25 @@ vector GlobalMuonRefitter::transform(const reco::Track& newTrack, } } -/* +/* cout << " GlobalMuonRefitter : theFitter " << propDir << endl; - cout << " First TSOS: " + cout << " First TSOS: " << firstTSOS.globalPosition() << " p=" << firstTSOS.globalMomentum() << " = " << firstTSOS.globalMomentum().mag() << endl; - + cout << " Starting seed: " << " nHits= " << seed.nHits() << " tsos: " << seed.startingState().parameters().position() << " p=" << seed.startingState().parameters().momentum() << endl; - + cout << " RecHits: " << recHitsForReFit.size() << endl; */ - + vector trajectories = theFitter->fit(seed,recHitsForReFit,firstTSOS); - + if(trajectories.empty()){ LogDebug(theCategory) << "No Track refitted!" << endl; return vector(); @@ -868,28 +873,28 @@ GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::getRidOfSelectStati // continue; //caveat that just removes the whole system from refitting if (theTrackerSkipSystem == PXB) { - + layer = tTopo->pxbLayer(id); } if (theTrackerSkipSystem == TIB) { - + layer = tTopo->tibLayer(id); } if (theTrackerSkipSystem == TOB) { - + layer = tTopo->tobLayer(id); } if (theTrackerSkipSystem == PXF) { - + disk = tTopo->pxfDisk(id); } if (theTrackerSkipSystem == TID) { - + wheel = tTopo->tidWheel(id); } if (theTrackerSkipSystem == TEC) { - + wheel = tTopo->tecWheel(id); } if (theTrackerSkipSection >= 0 && layer == theTrackerSkipSection) continue; @@ -924,4 +929,3 @@ GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::getRidOfSelectStati } return results; } - From 27bd75fbc54d6348de62c743bd4ff18c7b3b8411 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Sun, 31 Mar 2019 23:32:05 +0200 Subject: [PATCH 621/686] Dynamic threshold's parameters selection --- .../interface/DynamicTruncation.h | 7 +- .../interface/GlobalMuonRefitter.h | 3 +- .../python/GlobalMuonRefitter_cff.py | 11 ++-- .../GlobalTrajectoryBuilderCommon_cff.py | 11 ++-- .../src/DynamicTruncation.cc | 65 ++++--------------- .../src/GlobalMuonRefitter.cc | 18 ++--- 6 files changed, 35 insertions(+), 80 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 4d820ea9acb14..5c72dc31bc6c8 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -66,13 +66,10 @@ class DynamicTruncation { void setUpdateState(bool); void setUseAPE(bool); /*---- DyT v2-----*/ - void setRecoP(double p) { - p_reco = p; - useParametrizedThr = true; - } + void setParThrsMode(bool dytParThrsMode) { useParametrizedThr = dytParThrsMode;} + void setRecoP(double p) { p_reco = p; } void setRecoEta(double eta) { eta_reco = eta; - useParametrizedThr = true; setEtaRegion(); } diff --git a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h index 6aa14dc911ce6..e9e6fd7e3c185 100644 --- a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h +++ b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h @@ -171,8 +171,9 @@ class GlobalMuonRefitter { int theDYTselector; bool theDYTupdator; bool theDYTuseAPE; - reco::DYTInfo *dytInfo; + bool dytParThrsMode; edm::ParameterSet theDYTthrsParameters; + reco::DYTInfo *dytInfo; std::string theFitterName; std::unique_ptr theFitter; diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py index 87c7cd9a8cdc3..f9eb3514cbf84 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py @@ -35,12 +35,11 @@ ## Parameters for DYT threshold parametrization DYTuseThrsParametrization = cms.bool(True), DYTthrsParameters = cms.PSet( - eta0p8 = cms.vdouble(-0.919853, 0.990742), - eta1p2 = cms.vdouble(-0.897354, 0.987738), - eta2p0 = cms.vdouble(-0.986855, 0.998516), - eta2p2 = cms.vdouble(-0.940342, 0.992955), - eta2p4 = cms.vdouble(-0.947633, 0.993762), - thr50 = cms.vdouble(1, 1, 4, 1, 1), + eta0p8 = cms.vdouble(1, -0.919853, 0.990742), + eta1p2 = cms.vdouble(1, -0.897354, 0.987738), + eta2p0 = cms.vdouble(4, -0.986855, 0.998516), + eta2p2 = cms.vdouble(1, -0.940342, 0.992955), + eta2p4 = cms.vdouble(1, -0.947633, 0.993762), ), # muon station to be skipped SkipStation = cms.int32(-1), diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py index 37dc256495e9d..d9e95b57a27d9 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py @@ -59,12 +59,11 @@ ## Parameters for DYT threshold parametrization DYTuseThrsParametrization = cms.bool(True), DYTthrsParameters = cms.PSet( - eta0p8 = cms.vdouble(-0.919853, 0.990742), - eta1p2 = cms.vdouble(-0.897354, 0.987738), - eta2p0 = cms.vdouble(-0.986855, 0.998516), - eta2p2 = cms.vdouble(-0.940342, 0.992955), - eta2p4 = cms.vdouble(-0.947633, 0.993762), - thr50 = cms.vdouble(1, 1, 4, 1, 1), + eta0p8 = cms.vdouble(1, -0.919853, 0.990742), + eta1p2 = cms.vdouble(1, -0.897354, 0.987738), + eta2p0 = cms.vdouble(4, -0.986855, 0.998516), + eta2p2 = cms.vdouble(1, -0.940342, 0.992955), + eta2p4 = cms.vdouble(1, -0.947633, 0.993762), ), # muon station to be skipped diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index b8c52209e96cf..a4f416cfc05ed 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -474,38 +474,19 @@ void DynamicTruncation::getThresholdFromDB(double& thr, DetId const& id) { //===> correctThrByPtAndEta void DynamicTruncation::correctThrByPtAndEta(double& thr) { - //double p = p_reco; - //double p08[2] = { -0.919853, 0.990742}; - //double p12[4] = { -0.897354, 0.987738}; - //double p20[3] = { -0.986855, 0.998516}; - //double p22[2] = { -0.940342, 0.992955}; - //double p24[2] = { -0.947633, 0.993762}; - //double thr50[5] = { 1, 1, 4, 1, 1}; - - // auto parametricThreshold = [this](float thr50, float p0, float p1){ - // return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); - // }; - - // printf("parametricThreshold(1,-0.919853, 0.990742) = %f", parametricThreshold(1,-0.919853, 0.990742)); - - if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ){ - thr = 24; //3000-> 26; //400-> 11; //1000-> 19; //2000-> 25; - //thr = thr50[0] * ( 1 + p08[0]*p + TMath::Power( p, p08[1])); - } else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ){ - thr = 38; //3000-> 29; //400-> 14; //1000-> 22; //2000-> 27; - //thr = thr50[1] * ( 1 + p12[0]*p + TMath::Power( p, p12[1])); - } else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ){ - thr = 19; //3000-> 20; //400-> 10; //1000-> 16; //2000-> 19; - //thr = thr50[2] * ( 1 + p20[0]*p + TMath::Power( p, p20[1])); - } else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ){ - thr = 16; //3000-> 16; //400-> 8; //1000-> 13; //2000-> 15; - //thr = thr50[3] * ( 1 + p22[0]*p + TMath::Power( p, p22[1])); - } else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ){ - thr = 14; //3000-> 12; //400-> 8; //1000-> 11; //2000-> 13; - //thr = thr50[4] * ( 1 + p24[0]*p + TMath::Power( p, p24[1])); - } - //thr = 10; + + auto parametricThreshold = [this]{ + double thr50 = this->parameters[this->region].at(0); + double p0 = this->parameters[this->region].at(1); + double p1 = this->parameters[this->region].at(2); + return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); + }; + + // printf("thr before = %f \n", thr); + // printf("Muon with pt equal to = %f -- eta = %f\n", p_reco, eta_reco ); + // printf("parametricThreshold(1,%f, %f) = %f \n", this->parameters[this->region].at(0), this->parameters[this->region].at(1), parametricThreshold()); + thr = parametricThreshold(); } void DynamicTruncation::setEtaRegion(){ @@ -518,28 +499,6 @@ void DynamicTruncation::setEtaRegion(){ } -//===> correctThrByPtAndEta -void DynamicTruncation::correctThrByPtAndEta() { - - //double p = p_reco; - //double p08[2] = { -0.919853, 0.990742}; - //double p12[4] = { -0.897354, 0.987738}; - //double p20[3] = { -0.986855, 0.998516}; - //double p22[2] = { -0.940342, 0.992955}; - //double p24[2] = { -0.947633, 0.993762}; - //double thr50[5] = { 1, 1, 4, 1, 1}; - - - auto parametricThreshold = [this](float thr50){ - double p0 = this->parameters[this->region].at(0); - double p1 = this->parameters[this->region].at(1); - return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); - }; - - printf("Muon with pt equal to = %f -- eta = %f\n", p_reco, eta_reco ); - printf("parametricThreshold(1,%f, %f) = %f \n", this->parameters[this->region].at(0), this->parameters[this->region].at(1), parametricThreshold(1)); -} - //===> getThresholdFromCFG void DynamicTruncation::getThresholdFromCFG(double& thr, DetId const& id) { diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 8f0be6f71dca3..62482e7371885 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -118,10 +118,11 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theDYTthrs = par.getParameter< std::vector >("DYTthrs"); theDYTselector = par.existsAs("DYTselector")?par.getParameter("DYTselector"):1; - theDYTupdator = par.existsAs("DYTupdator")?par.getParameter("DYTupdator"):false; - theDYTuseAPE = par.existsAs("DYTuseAPE")?par.getParameter("DYTuseAPE"):false; + theDYTupdator = par.existsAs("DYTupdator")?par.getParameter("DYTupdator"):false; + theDYTuseAPE = par.existsAs("DYTuseAPE")?par.getParameter("DYTuseAPE"):false; + dytParThrsMode = par.existsAs("DYTuseThrsParametrization")?par.getParameter("DYTuseThrsParametrization"):false; + theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); dytInfo = new reco::DYTInfo(); - theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); if (par.existsAs("RescaleErrorFactor")) { theRescaleErrorFactor = par.getParameter("RescaleErrorFactor"); @@ -272,18 +273,17 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, // // DYT 2.0 // - cout << " New DyT Version !!!!!!!! ---- " << endl; - double momentum = globalTrack.p(); - double eta = globalTrack.eta(); DynamicTruncation dytRefit(*theEvent,*theService,theDYTthrsParameters); dytRefit.setProd(all4DSegments, CSCSegments); dytRefit.setSelector(theDYTselector); dytRefit.setThr(theDYTthrs); dytRefit.setUpdateState(theDYTupdator); dytRefit.setUseAPE(theDYTuseAPE); - dytRefit.setRecoP(momentum); - dytRefit.setRecoEta(eta); - dytRefit.correctThrByPtAndEta(); + if(dytParThrsMode) { + dytRefit.setParThrsMode(dytParThrsMode); + dytRefit.setRecoP(globalTrack.p()); + dytRefit.setRecoEta(globalTrack.eta()); + } DYTRecHits = dytRefit.filter(globalTraj.front()); dytInfo->CopyFrom(dytRefit.getDYTInfo()); if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag())) From bfb3383a7032559e643a894cd78a7f95533d1bad Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Sun, 31 Mar 2019 23:40:53 +0200 Subject: [PATCH 622/686] Rename correctThrByPtAndEta --- .../GlobalTrackingTools/interface/DynamicTruncation.h | 4 +--- RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 5c72dc31bc6c8..0a61dd4199b63 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -85,8 +85,6 @@ class DynamicTruncation { return dytInfo; } - void correctThrByPtAndEta(); - private: void compatibleDets(TrajectoryStateOnSurface&, std::map >&); @@ -100,7 +98,7 @@ class DynamicTruncation { void updateWithDThits(TrajectoryStateOnSurface&, DTRecSegment4D const &); void updateWithCSChits(TrajectoryStateOnSurface&, CSCSegment const &); void getThresholdFromDB(double&, DetId const&); - void correctThrByPtAndEta(double&); + void correctThrByPAndEta(double&); void getThresholdFromCFG(double&, DetId const&); void testDTstation(TrajectoryStateOnSurface&, std::vector const &, double&, DTRecSegment4D&, TrajectoryStateOnSurface&); void testCSCstation(TrajectoryStateOnSurface&, std::vector const &, double&, CSCSegment&, TrajectoryStateOnSurface&); diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index a4f416cfc05ed..e9d835f6e37a6 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -467,12 +467,12 @@ void DynamicTruncation::getThresholdFromDB(double& thr, DetId const& id) { break; } } - if (useParametrizedThr) correctThrByPtAndEta(thr); + if (useParametrizedThr) correctThrByPAndEta(thr); } -//===> correctThrByPtAndEta -void DynamicTruncation::correctThrByPtAndEta(double& thr) { +//===> correctThrByPAndEta +void DynamicTruncation::correctThrByPAndEta(double& thr) { @@ -509,7 +509,7 @@ void DynamicTruncation::getThresholdFromCFG(double& thr, DetId const& id) { thr = Thrs[1]; } - if (useParametrizedThr) correctThrByPtAndEta(thr); + if (useParametrizedThr) correctThrByPAndEta(thr); } From 7b2602992e4a7a499283bdb7830d8cbc022e7d27 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Mon, 1 Apr 2019 19:57:11 +0200 Subject: [PATCH 623/686] DYTthrsParameters passed to DyTRefitter using a function --- .../GlobalTrackingTools/interface/DynamicTruncation.h | 3 ++- RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc | 11 +++++++---- .../GlobalTrackingTools/src/GlobalMuonRefitter.cc | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 0a61dd4199b63..83595e50528e6 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -52,7 +52,7 @@ class DynamicTruncation { typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer; typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer; - DynamicTruncation(const edm::Event&, const MuonServiceProxy&, const edm::ParameterSet&); + DynamicTruncation(const edm::Event&, const MuonServiceProxy&); ~DynamicTruncation(); @@ -66,6 +66,7 @@ class DynamicTruncation { void setUpdateState(bool); void setUseAPE(bool); /*---- DyT v2-----*/ + void setThrsMap(const edm::ParameterSet&); void setParThrsMode(bool dytParThrsMode) { useParametrizedThr = dytParThrsMode;} void setRecoP(double p) { p_reco = p; } void setRecoEta(double eta) { diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index e9d835f6e37a6..9f8eaae17865f 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -44,7 +44,7 @@ namespace dyt_utils{ -DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceProxy& theService, const edm::ParameterSet& par) { +DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceProxy& theService) { propagator = theService.propagator("SmartPropagatorAny"); propagatorPF = theService.propagator("SmartPropagatorAny"); propagatorCompatibleDet = theService.propagator("SmartPropagatorAny"); @@ -62,9 +62,6 @@ DynamicTruncation::DynamicTruncation(const edm::Event& event, const MuonServiceP doUpdateOfKFStates = true; useParametrizedThr = false; - for (auto const& region : dyt_utils::etaRegionStr ){ - parameters[region.first] = par.getParameter< std::vector >(region.second); - } } DynamicTruncation::~DynamicTruncation() { @@ -142,6 +139,12 @@ void DynamicTruncation::setThr(const vector& thr) { } throw cms::Exception("NotAvailable") << "WARNING: wrong size for the threshold vector!\nExpected size: 2\n Found size: " << thr.size(); } + +void DynamicTruncation::setThrsMap(const edm::ParameterSet& par) { + for (auto const& region : dyt_utils::etaRegionStr ){ + parameters[region.first] = par.getParameter< std::vector >(region.second); + } +} ///////////////////////////////// ///////////////////////////////// ///////////////////////////////// diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 62482e7371885..1cdbfccb6d0cd 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -121,7 +121,7 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theDYTupdator = par.existsAs("DYTupdator")?par.getParameter("DYTupdator"):false; theDYTuseAPE = par.existsAs("DYTuseAPE")?par.getParameter("DYTuseAPE"):false; dytParThrsMode = par.existsAs("DYTuseThrsParametrization")?par.getParameter("DYTuseThrsParametrization"):false; - theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); + if (dytParThrsMode) theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); dytInfo = new reco::DYTInfo(); if (par.existsAs("RescaleErrorFactor")) { @@ -273,7 +273,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, // // DYT 2.0 // - DynamicTruncation dytRefit(*theEvent,*theService,theDYTthrsParameters); + DynamicTruncation dytRefit(*theEvent,*theService); dytRefit.setProd(all4DSegments, CSCSegments); dytRefit.setSelector(theDYTselector); dytRefit.setThr(theDYTthrs); @@ -281,6 +281,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, dytRefit.setUseAPE(theDYTuseAPE); if(dytParThrsMode) { dytRefit.setParThrsMode(dytParThrsMode); + dytRefit.setThrsMap(theDYTthrsParameters); dytRefit.setRecoP(globalTrack.p()); dytRefit.setRecoEta(globalTrack.eta()); } From 8d95b9a228004114c66890830eef014ce20ed632 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Wed, 3 Apr 2019 17:21:37 +0200 Subject: [PATCH 624/686] code clean up --- .../GlobalMuonProducer/python/tevMuons_cfi.py | 6 +-- .../interface/DynamicTruncation.h | 6 +-- .../interface/GlobalMuonRefitter.h | 13 ++--- .../src/DynamicTruncation.cc | 34 ++++++------ .../src/GlobalMuonRefitter.cc | 53 ++++++++++--------- 5 files changed, 57 insertions(+), 55 deletions(-) diff --git a/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py b/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py index ab56a296aa931..faf4e3093120d 100644 --- a/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py +++ b/RecoMuon/GlobalMuonProducer/python/tevMuons_cfi.py @@ -9,9 +9,9 @@ # InputTag MuonCollectionLabel = standAloneMuons:UpdatedAtVtx MuonServiceProxy, RefitIndex = cms.vint32(1, 2, 3, 4), - Refits = cms.vstring('default', - 'firstHit', - 'picky', + Refits = cms.vstring('default', + 'firstHit', + 'picky', 'dyt'), MuonCollectionLabel = cms.InputTag("globalMuons"), RefitterParameters = cms.PSet( diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 83595e50528e6..6040cf3c07ac8 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -46,7 +46,7 @@ namespace dyt_utils{ }; class DynamicTruncation { - + public: typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer; @@ -56,7 +56,7 @@ class DynamicTruncation { ~DynamicTruncation(); - void setProd(const edm::Handle& DTSegProd, + void setProd(const edm::Handle& DTSegProd, const edm::Handle& CSCSegProd) { getSegs->initCSU(DTSegProd, CSCSegProd); } @@ -77,7 +77,7 @@ class DynamicTruncation { // Return the vector with the tracker plus the selected muon hits TransientTrackingRecHit::ConstRecHitContainer filter(const Trajectory&); - // Return the DYTInfo object + // Return the DYTInfo object reco::DYTInfo getDYTInfo() { dytInfo.setNStUsed(nStationsUsed); dytInfo.setDYTEstimators(estimatorMap); diff --git a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h index e9e6fd7e3c185..01ae9e2a3d19a 100644 --- a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h +++ b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h @@ -9,8 +9,9 @@ * \author C. Liu Purdue University * \author A. Everett Purdue University * - * \modified by C. Calabria INFN & Universita� Bari + * \modified by C. Calabria INFN & Universita Bari * \modified by D. Nash Northeastern University + * \modified by C. Caputo UCLouvain */ #include "DataFormats/Common/interface/Handle.h" @@ -67,7 +68,7 @@ class GlobalMuonRefitter { /// constructor with Parameter Set and MuonServiceProxy GlobalMuonRefitter(const edm::ParameterSet&, const MuonServiceProxy*, edm::ConsumesCollector&); - + /// destructor virtual ~GlobalMuonRefitter(); @@ -105,15 +106,15 @@ class GlobalMuonRefitter { enum RefitDirection{insideOut,outsideIn,undetermined}; /// check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit - void checkMuonHits(const reco::Track&, ConstRecHitContainer&, + void checkMuonHits(const reco::Track&, ConstRecHitContainer&, std::map &) const; /// get the RecHits in the tracker and the first muon chamber with hits - void getFirstHits(const reco::Track&, ConstRecHitContainer&, + void getFirstHits(const reco::Track&, ConstRecHitContainer&, ConstRecHitContainer&) const; /// select muon hits compatible with trajectory; check hits in chambers with showers - ConstRecHitContainer selectMuonHits(const Trajectory&, + ConstRecHitContainer selectMuonHits(const Trajectory&, const std::map &) const; /// print all RecHits of a trajectory @@ -129,7 +130,7 @@ class GlobalMuonRefitter { float thePtCut; private: - + int theMuonHitsOption; float theProbCut; int theHitThreshold; diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index 9f8eaae17865f..eaf6efb8aa2f3 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -79,7 +79,7 @@ void DynamicTruncation::updateWithDThits(TrajectoryStateOnSurface& tsos, DTRecSe ConstRecHitContainer tmprecHits; vector DTrh = bestDTSeg.recHits(); for (vector::iterator it = DTrh.begin(); it != DTrh.end(); it++) { - tmprecHits.push_back(theMuonRecHitBuilder->build(*it)); + tmprecHits.push_back(theMuonRecHitBuilder->build(*it)); } sort(tmprecHits); for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) { @@ -101,7 +101,7 @@ void DynamicTruncation::updateWithCSChits(TrajectoryStateOnSurface& tsos, CSCSeg sort(tmprecHits); for (ConstRecHitContainer::const_iterator it = tmprecHits.begin(); it != tmprecHits.end(); ++it) { const CSCLayer* cscLayer = cscGeom->layer((*it)->det()->geographicalId()); - TrajectoryStateOnSurface temp = propagator->propagate(tsos, cscLayer->surface()); + TrajectoryStateOnSurface temp = propagator->propagate(tsos, cscLayer->surface()); if (temp.isValid()) { TrajectoryStateOnSurface tempTsos = updatorHandle->update(temp, **it); if (tempTsos.isValid() ) tsos = tempTsos; @@ -199,7 +199,7 @@ void DynamicTruncation::filteringAlgo() { compatibleDets(currentState, compatibleIds); // Fill segment maps - fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap); + fillSegmentMaps(compatibleIds, dtSegMap, cscSegMap); // Do a preliminary fit if (useDBforThr) preliminaryFit(compatibleIds, dtSegMap, cscSegMap); @@ -214,7 +214,7 @@ void DynamicTruncation::filteringAlgo() { vector dtSegs = dtSegMap[it->first]; vector cscSegs = cscSegMap[it->first]; - // DT case: find the most compatible segment + // DT case: find the most compatible segment TrajectoryStateOnSurface tsosDTlayer; testDTstation(currentState, dtSegs, bestDTEstimator, bestDTSeg, tsosDTlayer); @@ -224,7 +224,7 @@ void DynamicTruncation::filteringAlgo() { // Decide whether to keep the layer or not bool chosenLayer = chooseLayers(incompConLay, bestDTEstimator, bestDTSeg, tsosDTlayer, bestCSCEstimator, bestCSCSeg, tsosCSClayer); - fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg); + fillDYTInfos(stLayer, chosenLayer, incompConLay, bestDTEstimator, bestCSCEstimator, bestDTSeg, bestCSCSeg); } //cout << "Number of used stations = " << nStationsUsed << endl; } @@ -245,7 +245,7 @@ int DynamicTruncation::stationfromDet(DetId const& det) { //===> fillDYTInfos -void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int &incompConLay, +void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int &incompConLay, double const &bestDTEstimator, double const &bestCSCEstimator, DTRecSegment4D const &bestDTSeg, CSCSegment const &bestCSCSeg) { if (chosenLayer) { @@ -253,7 +253,7 @@ void DynamicTruncation::fillDYTInfos(int const &st, bool const &chosenLayer, int incompConLay = 0; if (bestDTEstimator <= bestCSCEstimator) { estimatorMap[st] = bestDTEstimator; - DetId id(bestDTSeg.chamberId()); + DetId id(bestDTSeg.chamberId()); idChamberMap[st] = id; } else { DetId id(bestCSCSeg.cscDetId()); @@ -282,7 +282,7 @@ void DynamicTruncation::compatibleDets(TrajectoryStateOnSurface &tsos, mapsubDetector() != GeomDetEnumerators::CSC) continue; ilayerCorrected++; vector comps = navLayers[ilayer]->compatibleDets(currentState, *propagatorCompatibleDet, *theEstimator); - //cout << comps.size() << " compatible Dets with " << navLayers[ilayer]->subDetector() << " Layer " << ilayer << " " + //cout << comps.size() << " compatible Dets with " << navLayers[ilayer]->subDetector() << " Layer " << ilayer << " " //<< dumper.dumpLayer(navLayers[ilayer]); if (!comps.empty()) { for ( unsigned int icomp=0; icomp > &compatibleIds //===> testDTstation -void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, vector const &segments, +void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, vector const &segments, double &bestEstimator, DTRecSegment4D &bestSeg, TrajectoryStateOnSurface &tsosdt) { if (segments.empty()) return; for (unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) { @@ -331,7 +331,7 @@ void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, v StateSegmentMatcher estim(tsosdt, segments[iSeg], apeLoc); double estimator = estim.value(); //cout << "estimator DT = " << estimator << endl; - if (estimator >= bestEstimator) continue; + if (estimator >= bestEstimator) continue; bestEstimator = estimator; bestSeg = segments[iSeg]; } @@ -339,7 +339,7 @@ void DynamicTruncation::testDTstation(TrajectoryStateOnSurface &startingState, v //===> testCSCstation -void DynamicTruncation::testCSCstation(TrajectoryStateOnSurface &startingState, vector const &segments, +void DynamicTruncation::testCSCstation(TrajectoryStateOnSurface &startingState, vector const &segments, double &bestEstimator, CSCSegment &bestSeg, TrajectoryStateOnSurface &tsoscsc) { if (segments.empty()) return; for (unsigned int iSeg = 0; iSeg < segments.size(); iSeg++) { @@ -367,7 +367,7 @@ void DynamicTruncation::useSegment(DTRecSegment4D const &bestDTSeg, TrajectorySt } -//===> useSegment +//===> useSegment void DynamicTruncation::useSegment(CSCSegment const &bestCSCSeg, TrajectoryStateOnSurface const &tsosCSC) { result.push_back(theMuonRecHitBuilder->build(&bestCSCSeg)); if (doUpdateOfKFStates) updateWithCSChits(currentState, bestCSCSeg); @@ -423,9 +423,9 @@ void DynamicTruncation::preliminaryFit(map > compatibleIds, m } if (!prelFitMeas.empty()) prelFitMeas.pop_back(); for (auto imrh = prelFitMeas.rbegin(); imrh != prelFitMeas.rend(); ++imrh) { - DetId id = (*imrh)->geographicalId(); + DetId id = (*imrh)->geographicalId(); TrajectoryStateOnSurface tmp = propagatorPF->propagate(prelFitState, theG->idToDet(id)->surface()); - if (tmp.isValid()) prelFitState = tmp; + if (tmp.isValid()) prelFitState = tmp; } muonPTest = prelFitState.globalMomentum().perp(); muonETAest = prelFitState.globalMomentum().eta(); @@ -433,17 +433,17 @@ void DynamicTruncation::preliminaryFit(map > compatibleIds, m //===> chooseLayers -bool DynamicTruncation::chooseLayers(int &incompLayers, double const &bestDTEstimator, DTRecSegment4D const &bestDTSeg, TrajectoryStateOnSurface const &tsosDT, +bool DynamicTruncation::chooseLayers(int &incompLayers, double const &bestDTEstimator, DTRecSegment4D const &bestDTSeg, TrajectoryStateOnSurface const &tsosDT, double const &bestCSCEstimator, CSCSegment const &bestCSCSeg, TrajectoryStateOnSurface const &tsosCSC) { double initThr = MAX_THR; if (bestDTEstimator == MAX_THR && bestCSCEstimator == MAX_THR) return false; if (bestDTEstimator <= bestCSCEstimator) { // Get threshold for the chamber if (useDBforThr) getThresholdFromDB(initThr, DetId(bestDTSeg.chamberId())); - else getThresholdFromCFG(initThr, DetId(bestDTSeg.chamberId())); + else getThresholdFromCFG(initThr, DetId(bestDTSeg.chamberId())); if (DYTselector == 0 || (DYTselector == 1 && bestDTEstimator < initThr) || (DYTselector == 2 && incompLayers < 2 && bestDTEstimator < initThr)) { - useSegment(bestDTSeg, tsosDT); + useSegment(bestDTSeg, tsosDT); return true; } } else { diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 1cdbfccb6d0cd..d85333c33dbcd 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -8,8 +8,9 @@ * Authors : * P. Traczyk, SINS Warsaw * - * \modified by C. Calabria, INFN & Universita� Bari + * \modified by C. Calabria, INFN & Universita Bari * \modified by D. Nash, Northeastern University + * \modified by C. Caputo, UCLouvain * **/ @@ -74,7 +75,7 @@ using namespace edm; GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, const MuonServiceProxy* service, - edm::ConsumesCollector& iC) : + edm::ConsumesCollector& iC) : theCosmicFlag(par.getParameter("PropDirForCosmics")), theDTRecHitLabel(par.getParameter("DTRecSegmentLabel")), theCSCRecHitLabel(par.getParameter("CSCRecSegmentLabel")), @@ -96,15 +97,15 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, if (refitDirectionName == "insideOut" ) theRefitDirection = insideOut; else if (refitDirectionName == "outsideIn" ) theRefitDirection = outsideIn; - else - throw cms::Exception("TrackTransformer constructor") + else + throw cms::Exception("TrackTransformer constructor") <<"Wrong refit direction chosen in TrackTransformer ParameterSet" << "\n" << "Possible choices are:" << "\n" << "RefitDirection = insideOut or RefitDirection = outsideIn"; - theFitterName = par.getParameter("Fitter"); + theFitterName = par.getParameter("Fitter"); thePropagatorName = par.getParameter("Propagator"); theSkipStation = par.getParameter("SkipStation"); @@ -134,7 +135,7 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theCacheId_TRH = 0; theDTRecHitToken=iC.consumes(theDTRecHitLabel); theCSCRecHitToken=iC.consumes(theCSCRecHitLabel); - theGEMRecHitToken=iC.consumes(theGEMRecHitLabel); + theGEMRecHitToken=iC.consumes(theGEMRecHitLabel); theME0RecHitToken=iC.consumes(theME0RecHitLabel); CSCSegmentsToken = iC.consumes(InputTag("cscSegments")); all4DSegmentsToken=iC.consumes(InputTag("dt4DSegments")); @@ -157,8 +158,8 @@ void GlobalMuonRefitter::setEvent(const edm::Event& event) { theEvent = &event; event.getByToken(theDTRecHitToken, theDTRecHits); event.getByToken(theCSCRecHitToken, theCSCRecHits); - event.getByToken(theGEMRecHitToken, theGEMRecHits); - event.getByToken(theME0RecHitToken, theME0RecHits); + event.getByToken(theGEMRecHitToken, theGEMRecHits); + event.getByToken(theME0RecHitToken, theME0RecHits); event.getByToken(CSCSegmentsToken, CSCSegments); event.getByToken(all4DSegmentsToken, all4DSegments); } @@ -204,7 +205,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, allRecHitsTemp.push_back((**hit).cloneForFit(*tkbuilder->geometry()->idToDet( (**hit).geographicalId() ) ) ); else if ((*hit)->geographicalId().det() == DetId::Muon) { if ((*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) { - LogTrace(theCategory) << "RPC Rec Hit discarged"; + LogTrace(theCategory) << "RPC Rec Hit discarged"; continue; } allRecHitsTemp.push_back(theMuonRecHitBuilder->build(&**hit)); @@ -241,7 +242,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, LogTrace(theCategory) << " Track momentum before refit: " << globalTrack.pt() << endl; LogTrace(theCategory) << " Hits size before : " << allRecHitsTemp.size() << endl; - allRecHits = getRidOfSelectStationHits(allRecHitsTemp, tTopo); + allRecHits = getRidOfSelectStationHits(allRecHitsTemp, tTopo); // printHits(allRecHits); LogTrace(theCategory) << " Hits size: " << allRecHits.size() << endl; @@ -256,7 +257,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, return vector(); } - LogTrace(theCategory) << " Initial trajectory state: " + LogTrace(theCategory) << " Initial trajectory state: " << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl; if (theMuonHitsOption == 1 ) @@ -312,7 +313,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, // // // -void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, +void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, ConstRecHitContainer& all, map &hitMap) const { @@ -498,8 +499,8 @@ void GlobalMuonRefitter::checkMuonHits(const reco::Track& muon, } // end of loop over muon rechits - for (map::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ ) - LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second <::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ ) + LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second < 4 || stations.size() != all.size()) - LogInfo(theCategory) << "failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " + LogInfo(theCategory) << "failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = " << station_to_keep << " stations.size " << stations.size() << " all.size " << all.size(); for (unsigned i = 0; i < stations.size(); ++i) @@ -562,17 +563,17 @@ void GlobalMuonRefitter::getFirstHits(const reco::Track& muon, // -// select muon hits compatible with trajectory; +// select muon hits compatible with trajectory; // check hits in chambers with showers // -GlobalMuonRefitter::ConstRecHitContainer -GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, +GlobalMuonRefitter::ConstRecHitContainer +GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, const map &hitMap) const { ConstRecHitContainer muonRecHits; const double globalChi2Cut = 200.0; - vector muonMeasurements = traj.measurements(); + vector muonMeasurements = traj.measurements(); // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy for (std::vector::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) { @@ -627,19 +628,19 @@ GlobalMuonRefitter::selectMuonHits(const Trajectory& traj, } else continue; - double chi2ndf = (*im).estimate()/(*im).recHit()->dimension(); + double chi2ndf = (*im).estimate()/(*im).recHit()->dimension(); bool keep = true; map::const_iterator imap=hitMap.find(chamberId); - if ( imap!=hitMap.end() ) + if ( imap!=hitMap.end() ) if (imap->second>threshold) keep = false; if ( (keep || (chi2ndfsecond << endl; } } @@ -659,12 +660,12 @@ void GlobalMuonRefitter::printHits(const ConstRecHitContainer& hits) const { for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) { if ( !(*ir)->isValid() ) { LogTrace(theCategory) << "invalid RecHit"; - continue; + continue; } const GlobalPoint& pos = (*ir)->globalPosition(); - LogTrace(theCategory) + LogTrace(theCategory) << "r = " << sqrt(pos.x() * pos.x() + pos.y() * pos.y()) << " z = " << pos.z() << " dimension = " << (*ir)->dimension() From e91e1639cfd884d9f499c640499d04a1d50c7ddc Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Thu, 4 Apr 2019 12:23:48 +0200 Subject: [PATCH 625/686] update DynamicTruncation::setEtaRegion() for muons with abs(eta)>2.4 --- RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index eaf6efb8aa2f3..a783feb2339f0 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -494,11 +494,14 @@ void DynamicTruncation::correctThrByPAndEta(double& thr) { void DynamicTruncation::setEtaRegion(){ + // Defaul value for muons with abs(eta) > 2.4 + region = dyt_utils::etaRegion::eta2p4; + if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ) region = dyt_utils::etaRegion::eta0p8; - else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ) region = dyt_utils::etaRegion::eta1p2; - else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ) region = dyt_utils::etaRegion::eta2p0; - else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ) region = dyt_utils::etaRegion::eta2p2; - else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ) region = dyt_utils::etaRegion::eta2p4; + else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ) region = dyt_utils::etaRegion::eta1p2; + else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ) region = dyt_utils::etaRegion::eta2p0; + else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ) region = dyt_utils::etaRegion::eta2p2; + else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ) region = dyt_utils::etaRegion::eta2p4; } From 13f30c4fb9bb37775ea10529b52617af4cbc9b0a Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Wed, 10 Apr 2019 19:13:21 +0200 Subject: [PATCH 626/686] implement comments --- .../src/DynamicTruncation.cc | 18 +++++++----------- .../src/GlobalMuonRefitter.cc | 13 ++++++------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index a783feb2339f0..5347690f2eae5 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -477,31 +477,27 @@ void DynamicTruncation::getThresholdFromDB(double& thr, DetId const& id) { //===> correctThrByPAndEta void DynamicTruncation::correctThrByPAndEta(double& thr) { - - auto parametricThreshold = [this]{ double thr50 = this->parameters[this->region].at(0); double p0 = this->parameters[this->region].at(1); double p1 = this->parameters[this->region].at(2); - return thr50 * ( 1 + p0*p_reco + TMath::Power( this->p_reco, p1)); + return thr50 * ( 1 + p0*p_reco + std::pow( this->p_reco, p1)); }; - // printf("thr before = %f \n", thr); - // printf("Muon with pt equal to = %f -- eta = %f\n", p_reco, eta_reco ); - // printf("parametricThreshold(1,%f, %f) = %f \n", this->parameters[this->region].at(0), this->parameters[this->region].at(1), parametricThreshold()); thr = parametricThreshold(); } void DynamicTruncation::setEtaRegion(){ + float absEta = std::abs(eta_reco); // Defaul value for muons with abs(eta) > 2.4 region = dyt_utils::etaRegion::eta2p4; - if( TMath::Abs(eta_reco) > 0 && TMath::Abs(eta_reco) <= 0.8 ) region = dyt_utils::etaRegion::eta0p8; - else if( TMath::Abs(eta_reco) > 0.8 && TMath::Abs(eta_reco) <= 1.2 ) region = dyt_utils::etaRegion::eta1p2; - else if( TMath::Abs(eta_reco) > 1.2 && TMath::Abs(eta_reco) <= 2.0 ) region = dyt_utils::etaRegion::eta2p0; - else if( TMath::Abs(eta_reco) > 2.0 && TMath::Abs(eta_reco) <= 2.2 ) region = dyt_utils::etaRegion::eta2p2; - else if( TMath::Abs(eta_reco) > 2.2 && TMath::Abs(eta_reco) <= 2.4 ) region = dyt_utils::etaRegion::eta2p4; + if( absEta <= 0.8 ) region = dyt_utils::etaRegion::eta0p8; + else if( absEta <= 1.2 ) region = dyt_utils::etaRegion::eta1p2; + else if( absEta <= 2.0 ) region = dyt_utils::etaRegion::eta2p0; + else if( absEta <= 2.2 ) region = dyt_utils::etaRegion::eta2p2; + else if( absEta <= 2.4 ) region = dyt_utils::etaRegion::eta2p4; } diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index d85333c33dbcd..3724329461e73 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -282,7 +282,7 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, dytRefit.setUseAPE(theDYTuseAPE); if(dytParThrsMode) { dytRefit.setParThrsMode(dytParThrsMode); - dytRefit.setThrsMap(theDYTthrsParameters); + dytRefit.setThrsMap(theDYTthrsParameters); dytRefit.setRecoP(globalTrack.p()); dytRefit.setRecoEta(globalTrack.eta()); } @@ -826,22 +826,21 @@ vector GlobalMuonRefitter::transform(const reco::Track& newTrack, } } -/* - cout << " GlobalMuonRefitter : theFitter " << propDir << endl; - cout << " First TSOS: " + + LogDebug(theCategory) << " GlobalMuonRefitter : theFitter " << propDir << endl; + LogDebug(theCategory) << " First TSOS: " << firstTSOS.globalPosition() << " p=" << firstTSOS.globalMomentum() << " = " << firstTSOS.globalMomentum().mag() << endl; - cout << " Starting seed: " + LogDebug(theCategory) << " Starting seed: " << " nHits= " << seed.nHits() << " tsos: " << seed.startingState().parameters().position() << " p=" << seed.startingState().parameters().momentum() << endl; - cout << " RecHits: " + LogDebug(theCategory) << " RecHits: " << recHitsForReFit.size() << endl; -*/ vector trajectories = theFitter->fit(seed,recHitsForReFit,firstTSOS); From 8dd858018d03268ae08389ae36e2cb7f99fe66a7 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Fri, 12 Apr 2019 15:10:17 +0200 Subject: [PATCH 627/686] Update fillDescriptions for L3MuonProducer and GlobalTrackQualityProducer --- .../plugins/GlobalTrackQualityProducer.cc | 63 +++++++++++++++++++ .../plugins/GlobalTrackQualityProducer.h | 3 + .../src/GlobalMuonRefitter.cc | 8 +-- RecoMuon/L3MuonProducer/src/L3MuonProducer.cc | 13 ++++ 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc index f167f7ff69615..2490cb4b0318f 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc +++ b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc @@ -311,5 +311,68 @@ GlobalTrackQualityProducer::trackProbability(Trajectory& track) const { } +void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions){ + edm::ParameterSetDescription desc; + desc.add("InputCollection",edm::InputTag("globalMuons")); + desc.add("InputLinksCollection",edm::InputTag("globalMuons")); + desc.add("BaseLabel","GLB"); +// edm::ParameterSetDescription descRefitter; + { + edm::ParameterSetDescription descGlbMuonRefitter; + descGlbMuonRefitter.add("DTRecSegmentLabel" , edm::InputTag("dt1DRecHits")); + descGlbMuonRefitter.add("CSCRecSegmentLabel" , edm::InputTag("csc2DRecHits")); + descGlbMuonRefitter.add("GEMRecHitLabel" , edm::InputTag("gemRecHits")); + descGlbMuonRefitter.add("ME0RecHitLabel" , edm::InputTag("me0Segments")); + descGlbMuonRefitter.add("RPCRecSegmentLabel" , edm::InputTag("rpcRecHits")); + + descGlbMuonRefitter.add("MuonHitsOption", 1); + descGlbMuonRefitter.add("PtCut", 1.0); + descGlbMuonRefitter.add("Chi2ProbabilityCut", 30.0); + descGlbMuonRefitter.add("Chi2CutCSC", 1.0); + descGlbMuonRefitter.add("Chi2CutDT", 30.0); + descGlbMuonRefitter.add("Chi2CutGEM", 1.0); + descGlbMuonRefitter.add("Chi2CutME0", 1.0); + descGlbMuonRefitter.add("Chi2CutRPC", 1.0); + descGlbMuonRefitter.add("HitThreshold", 1); + + descGlbMuonRefitter.add("Fitter", "KFFitterForRefitInsideOut"); + descGlbMuonRefitter.add("Smoother", "KFSmootherForRefitInsideOut"); + descGlbMuonRefitter.add("Propagator", "SmartPropagatorAnyRK"); + descGlbMuonRefitter.add("TrackerRecHitBuilder", "WithAngleAndTemplate"); + descGlbMuonRefitter.add("MuonRecHitBuilder", "MuonRecHitBuilder"); + descGlbMuonRefitter.add("DoPredictionsOnly", false); + descGlbMuonRefitter.add("RefitDirection", "insideOut"); + descGlbMuonRefitter.add("PropDirForCosmics", false); + descGlbMuonRefitter.add("RefitRPCHits", true); + + descGlbMuonRefitter.add>("DYTthrs",{10, 10}); + descGlbMuonRefitter.add("DYTselector",1); + descGlbMuonRefitter.add("DYTupdator", false); + descGlbMuonRefitter.add("DYTuseAPE", false ); + descGlbMuonRefitter.add("DYTuseThrsParametrization", true); + { + edm::ParameterSetDescription descDYTthrs; + descDYTthrs.add>("eta0p8", {1,-0.919853, 0.990742}); + descDYTthrs.add>("eta1p2", {1,-0.897354, 0.987738}); + descDYTthrs.add>("eta2p0", {1,-0.986855, 0.998516}); + descDYTthrs.add>("eta2p2", {1,-0.940342, 0.992955}); + descDYTthrs.add>("eta2p4", {1,-0.947633, 0.993762}); + descGlbMuonRefitter.add("DYTthrsParameters", descDYTthrs); + } + + descGlbMuonRefitter.add("SkipStation", -1); + descGlbMuonRefitter.add("TrackerSkipSystem",-1); + descGlbMuonRefitter.add("TrackerSkipSection", -1); + descGlbMuonRefitter.add("RefitFlag", true ); + + //descRefitter.add("GlobalMuonRefitter", descGlbMuonRefitter); + desc.add("RefitterParameters", descGlbMuonRefitter); + } + //desc.add("RefitterParameters", descRefitter); + desc.add("nSigma", 3.0); + desc.add("MaxChi2", 100000.0); + + descriptions.add("GlobalTrackQualityProducer", desc); +} //#include "FWCore/Framework/interface/MakerMacros.h" //DEFINE_FWK_MODULE(GlobalTrackQualityProducer); diff --git a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.h b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.h index 69cc177aa6a99..f2949240d0d2a 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.h +++ b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.h @@ -5,6 +5,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -30,6 +31,8 @@ class GlobalTrackQualityProducer : public edm::stream::EDProducer<> { ~GlobalTrackQualityProducer() override; // {} + // describe the parameters it allows or requires to be in its configuration + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: void produce(edm::Event&, const edm::EventSetup&) override; virtual std::pair kink(Trajectory& muon) const ; diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 3724329461e73..17f96d97cc7f1 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -118,10 +118,10 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theRPCInTheFit = par.getParameter("RefitRPCHits"); theDYTthrs = par.getParameter< std::vector >("DYTthrs"); - theDYTselector = par.existsAs("DYTselector")?par.getParameter("DYTselector"):1; - theDYTupdator = par.existsAs("DYTupdator")?par.getParameter("DYTupdator"):false; - theDYTuseAPE = par.existsAs("DYTuseAPE")?par.getParameter("DYTuseAPE"):false; - dytParThrsMode = par.existsAs("DYTuseThrsParametrization")?par.getParameter("DYTuseThrsParametrization"):false; + theDYTselector = par.getParameter("DYTselector"); + theDYTupdator = par.getParameter("DYTupdator"); + theDYTuseAPE = par.getParameter("DYTuseAPE"); + dytParThrsMode = par.getParameter("DYTuseThrsParametrization"); if (dytParThrsMode) theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); dytInfo = new reco::DYTInfo(); diff --git a/RecoMuon/L3MuonProducer/src/L3MuonProducer.cc b/RecoMuon/L3MuonProducer/src/L3MuonProducer.cc index 6940cf9649e28..6962bc7980a7c 100644 --- a/RecoMuon/L3MuonProducer/src/L3MuonProducer.cc +++ b/RecoMuon/L3MuonProducer/src/L3MuonProducer.cc @@ -217,6 +217,19 @@ void L3MuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptio 30, 15, }); + psd1.add("DYTselector",1); + psd1.add("DYTupdator", false); + psd1.add("DYTuseAPE", false ); + psd1.add("DYTuseThrsParametrization", false); + { + edm::ParameterSetDescription psd2; + psd2.add>("eta0p8", {1,-0.919853, 0.990742}); + psd2.add>("eta1p2", {1,-0.897354, 0.987738}); + psd2.add>("eta2p0", {1,-0.986855, 0.998516}); + psd2.add>("eta2p2", {1,-0.940342, 0.992955}); + psd2.add>("eta2p4", {1,-0.947633, 0.993762}); + psd1.add("DYTthrsParameters", psd2); + } psd1.add("Chi2CutCSC", 150.0); psd1.add("Chi2CutDT", 10.0); psd1.add("Chi2CutGEM", 1.0); From bdf5109e6b599d880fd266320a45448a24df74fb Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Sat, 13 Apr 2019 01:09:47 +0200 Subject: [PATCH 628/686] Add additional parameters in GlobalTrackQualityProducer::fillDescriptions --- .../plugins/GlobalTrackQualityProducer.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc index 2490cb4b0318f..0e2704f0523f7 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc +++ b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc @@ -313,10 +313,19 @@ GlobalTrackQualityProducer::trackProbability(Trajectory& track) const { void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions){ edm::ParameterSetDescription desc; + { + edm::ParameterSetDescription psd1; + psd1.setAllowAnything(); + desc.add("ServiceParameters", psd1); + } + { + edm::ParameterSetDescription psd1; + psd1.setAllowAnything(); + desc.add("GlobalMuonTrackMatcher", psd1); + } desc.add("InputCollection",edm::InputTag("globalMuons")); desc.add("InputLinksCollection",edm::InputTag("globalMuons")); desc.add("BaseLabel","GLB"); -// edm::ParameterSetDescription descRefitter; { edm::ParameterSetDescription descGlbMuonRefitter; descGlbMuonRefitter.add("DTRecSegmentLabel" , edm::InputTag("dt1DRecHits")); From 59771c6b85f4c53c5fb0c42e105f15550489bf8f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 14:58:20 +0200 Subject: [PATCH 629/686] Take care of code checks --- .../HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc | 12 ++++++------ .../HcalCalibAlgos/test/HcalCorrPFCalculation.cc | 8 ++++---- Calibration/HcalCalibAlgos/test/HcalLaserTest.cc | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc b/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc index 96297ebe51a57..b66ed3e2426d0 100644 --- a/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc +++ b/Calibration/HcalCalibAlgos/plugins/SimAnalyzerMinbias.cc @@ -38,12 +38,12 @@ class SimAnalyzerMinbias : public edm::EDAnalyzer { public: explicit SimAnalyzerMinbias(const edm::ParameterSet&); - ~SimAnalyzerMinbias(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void beginJob(); - virtual void endJob(); - virtual void beginRun(const edm::Run& r, const edm::EventSetup& iSetup); - virtual void endRun(const edm::Run& r, const edm::EventSetup& iSetup); + ~SimAnalyzerMinbias() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void beginJob() override; + void endJob() override; + void beginRun(const edm::Run& r, const edm::EventSetup& iSetup) override; + void endRun(const edm::Run& r, const edm::EventSetup& iSetup) override; private: // ----------member data --------------------------- diff --git a/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc b/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc index 4830196dab73f..4de366bfccffb 100644 --- a/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc +++ b/Calibration/HcalCalibAlgos/test/HcalCorrPFCalculation.cc @@ -41,10 +41,10 @@ using namespace reco; class HcalCorrPFCalculation : public edm::EDAnalyzer { public: HcalCorrPFCalculation(edm::ParameterSet const& conf); - ~HcalCorrPFCalculation(); - virtual void analyze(edm::Event const& ev, edm::EventSetup const& c) override; - virtual void beginJob() override; - virtual void endJob() override; + ~HcalCorrPFCalculation() override; + void analyze(edm::Event const& ev, edm::EventSetup const& c) override; + void beginJob() override; + void endJob() override; private: double RecalibFactor(HcalDetId id); diff --git a/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc b/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc index 7ce3916504184..e8b9a9ab2e4f7 100644 --- a/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc +++ b/Calibration/HcalCalibAlgos/test/HcalLaserTest.cc @@ -27,15 +27,15 @@ class HcalLaserTest : public edm::one::EDAnalyzer { public: explicit HcalLaserTest(const edm::ParameterSet&); - virtual ~HcalLaserTest(); + ~HcalLaserTest() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - virtual void analyze(edm::Event const&, edm::EventSetup const&) override; - virtual void beginJob() override; - virtual void beginRun(edm::Run const&, edm::EventSetup const&) override {} - virtual void endRun(edm::Run const&, edm::EventSetup const&) override {} - virtual void endJob(void) override; + void analyze(edm::Event const&, edm::EventSetup const&) override; + void beginJob() override; + void beginRun(edm::Run const&, edm::EventSetup const&) override {} + void endRun(edm::Run const&, edm::EventSetup const&) override {} + void endJob(void) override; // ----------member data --------------------------- edm::EDGetTokenT inputTokenHBHE_; From 59a9c8d7a4b6116d3cb8f89f8bf08fb77af81aa7 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 15:03:08 +0200 Subject: [PATCH 630/686] Take care of code checks --- Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc b/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc index b4ecdba9c4949..81d4eec977fcd 100644 --- a/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc +++ b/Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc @@ -126,7 +126,7 @@ namespace cms { for (const auto& track : *(tracks.product())) { edm::LogVerbatim("HcalAlCa") << " P track " << track.p() << " eta " << track.eta() << " phi " << track.phi() << " Outer " << track.outerMomentum() << " " << track.outerPosition(); - TrackExtraRef myextra = track.extra(); + const TrackExtraRef & myextra = track.extra(); edm::LogVerbatim("HcalAlCa") << " Track extra " << myextra->outerMomentum() << " " << myextra->outerPosition(); } From b521eb806a29f3bda14707642ab93963f0e957de Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 27 Mar 2019 19:05:52 +0100 Subject: [PATCH 631/686] Changes to DDHCalBarrelAlgo by removing explicit reference to CLHEP --- Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc | 828 ++++++++++-------- 1 file changed, 443 insertions(+), 385 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc index 8950fa83b88f9..5d630692db4cb 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc @@ -7,9 +7,8 @@ #include #include -namespace std{} using namespace std; - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDSolid.h" @@ -17,8 +16,10 @@ namespace std{} using namespace std; #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units; +using namespace geant_units::operators; DDHCalBarrelAlgo::DDHCalBarrelAlgo(): theta(0),rmax(0),zoff(0),ttheta(0),layerId(0),layerLabel(0),layerMat(0), @@ -28,12 +29,13 @@ DDHCalBarrelAlgo::DDHCalBarrelAlgo(): sideAbsName(0),sideAbsMat(0),sideAbsW(0),detType(0),detdP1(0),detdP2(0), detT11(0),detT12(0),detTsc(0),detT21(0),detT22(0),detWidth1(0),detWidth2(0), detPosY(0) { - LogDebug("HCalGeom") << "DDHCalBarrelAlgo info: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Creating an instance"; +#endif } DDHCalBarrelAlgo::~DDHCalBarrelAlgo() {} - void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs, const DDVectorArguments & vArgs, const DDMapArguments & , @@ -53,27 +55,30 @@ void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs, theta = vArgs["Theta"]; rmax = vArgs["RMax"]; zoff = vArgs["ZOff"]; - int i = 0; - for (i = 0; i < rzones; i++) { + for (int i = 0; i < rzones; i++) { ttheta.emplace_back(tan(theta[i])); //*deg already done in XML } if (rzones > 3) rmax[2] = (zoff[3] - zoff[2]) / ttheta[2]; - LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: General material " - << genMaterial << "\tSectors " << nsectors << ", " - << nsectortot <<"\tHalves " << nhalf - << "\tRotation matrix " << rotns << ":" << rotHalf - << "\n\t\t" << rin << "\t" << rout << "\t" << rzones; - for (i = 0; i < rzones; i++) { - LogDebug("HCalGeom") << "\tTheta[" << i << "] = " << theta[i] << "\trmax[" - << i << "] = " << rmax[i] << "\tzoff[" << i << "] = " - << zoff[i]; - } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: General material " + << genMaterial << "\tSectors " << nsectors + << ", " << nsectortot <<"\tHalves " + << nhalf << "\tRotation matrix " << rotns + << ":" << rotHalf << "\n\t\t" << rin << "\t" + << rout << "\t" << rzones; + for (int i = 0; i < rzones; i++) + edm::LogVerbatim("HCalGeom") << "\tTheta[" << i << "] = " << theta[i] + << "\trmax[" << i << "] = " << rmax[i] + << "\tzoff[" << i << "] = " << zoff[i]; +#endif /////////////////////////////////////////////////////////////// //Layers nLayers = int(nArgs["NLayers"]); - LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Layer\t" << nLayers; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Layer\t" << nLayers; +#endif layerId = dbl_to_int (vArgs["Id"]); layerLabel = vsArgs["LayerLabel"]; layerMat = vsArgs["LayerMat"]; @@ -85,14 +90,15 @@ void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs, layerT2 = vArgs["T2"]; layerAbsorb = dbl_to_int(vArgs["AbsL"]); layerGap = vArgs["Gap"]; - for (i = 0; i < nLayers; i++) { - LogDebug("HCalGeom") << layerLabel[i] << "\t" << layerId[i] << "\t" - << layerMat[i] << "\t" << layerWidth[i] << "\t" - << layerD1[i] << "\t" << layerD2[i] << "\t" - << layerAlpha[i] << "\t" << layerT1[i] << "\t" - << layerT2[i] << "\t" << layerAbsorb[i] << "\t" - << layerGap[i]; - } +#ifdef EDM_ML_DEBUG + for (int i = 0; i < nLayers; i++) + edm::LogVerbatim("HCalGeom") << layerLabel[i] << "\t" << layerId[i] << "\t" + << layerMat[i] << "\t" << layerWidth[i] + << "\t" << layerD1[i] << "\t" << layerD2[i] + << "\t" << layerAlpha[i] << "\t" << layerT1[i] + << "\t" << layerT2[i] << "\t" + << layerAbsorb[i] << "\t" << layerGap[i]; +#endif /////////////////////////////////////////////////////////////// //Absorber Layers and middle part @@ -101,46 +107,52 @@ void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs, absorbD = vArgs["AbsorbD"]; absorbT = vArgs["AbsorbT"]; nAbsorber = absorbName.size(); - for (i = 0; i < nAbsorber; i++) { - LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: " << absorbName[i] - <<" Material " << absorbMat[i] << " d " << absorbD[i] - << " t " <> Constructing DDHCalBarrelAlgo..."; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalBarrelAlgo..."; +#endif constructGeneralVolume(cpv); - LogDebug("HCalGeom") << "<<== End of DDHCalBarrelAlgo construction ..."; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalBarrelAlgo construction"; +#endif } //----------------------start here for DDD work!!! --------------- void DDHCalBarrelAlgo::constructGeneralVolume(DDCompactView& cpv) { - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: General volume..."; - unsigned int i=0; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: General volume..."; +#endif DDRotation rot = DDRotation(); - double alpha = CLHEP::pi/getNsectors(); - double dphi = getNsectortot()*CLHEP::twopi/getNsectors(); + double alpha = piRadians/getNsectors(); + double dphi = getNsectortot()*(2._pi)/getNsectors(); int nsec, ntot=15; if (getNhalf() == 1) nsec = 8; @@ -230,117 +251,63 @@ void DDHCalBarrelAlgo::constructGeneralVolume(DDCompactView& cpv) { double rmid3 =(getZoff(4) - getZoff(2))/getTanTheta(2); double rmid4 = getRmax(2); - vector pgonZ; - pgonZ.emplace_back( -zmax); - pgonZ.emplace_back( -zstep5); - pgonZ.emplace_back( -zstep5); - pgonZ.emplace_back( -zstep4); - pgonZ.emplace_back( -zstep3); - pgonZ.emplace_back( -zstep2); - pgonZ.emplace_back( -zstep1); - pgonZ.emplace_back( 0); - pgonZ.emplace_back( zstep1); - pgonZ.emplace_back( zstep2); - pgonZ.emplace_back( zstep3); - pgonZ.emplace_back( zstep4); - pgonZ.emplace_back( zstep5); - pgonZ.emplace_back( zstep5); - pgonZ.emplace_back( zmax); - - vector pgonRmin; - pgonRmin.emplace_back( rmid4); - pgonRmin.emplace_back( rmid3); - pgonRmin.emplace_back( rmid3); - pgonRmin.emplace_back( rmid2); - pgonRmin.emplace_back( rmid1); - pgonRmin.emplace_back( rmid1); - pgonRmin.emplace_back( rin); - pgonRmin.emplace_back( rin); - pgonRmin.emplace_back( rin); - pgonRmin.emplace_back( rmid1); - pgonRmin.emplace_back( rmid1); - pgonRmin.emplace_back( rmid2); - pgonRmin.emplace_back( rmid3); - pgonRmin.emplace_back( rmid3); - pgonRmin.emplace_back( rmid4); - - vector pgonRmax; - pgonRmax.emplace_back( rout1); - pgonRmax.emplace_back( rout1); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout); - pgonRmax.emplace_back( rout1); - pgonRmax.emplace_back( rout1); - - vector pgonZHalf; - pgonZHalf.emplace_back( 0); - pgonZHalf.emplace_back( zstep1); - pgonZHalf.emplace_back( zstep2); - pgonZHalf.emplace_back( zstep3); - pgonZHalf.emplace_back( zstep4); - pgonZHalf.emplace_back( zstep5); - pgonZHalf.emplace_back( zstep5); - pgonZHalf.emplace_back( zmax); - - vector pgonRminHalf; - pgonRminHalf.emplace_back( rin); - pgonRminHalf.emplace_back( rin); - pgonRminHalf.emplace_back( rmid1); - pgonRminHalf.emplace_back( rmid1); - pgonRminHalf.emplace_back( rmid2); - pgonRminHalf.emplace_back( rmid3); - pgonRminHalf.emplace_back( rmid3); - pgonRminHalf.emplace_back( rmid4); - - vector pgonRmaxHalf; - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout); - pgonRmaxHalf.emplace_back( rout1); - pgonRmaxHalf.emplace_back( rout1); - - string name("Null"); + std::vector pgonZ = {-zmax, -zstep5,-zstep5,-zstep4,-zstep3, + -zstep2,-zstep1, 0, zstep1, zstep2, + zstep3, zstep4, zstep5, zstep5, zmax}; + + std::vector pgonRmin = {rmid4,rmid3,rmid3,rmid2,rmid1, + rmid1, rin, rin, rin,rmid1, + rmid1,rmid2,rmid3,rmid3,rmid4}; + + std::vector pgonRmax = {rout1,rout1,rout, rout, rout, rout, + rout, rout, rout, rout, rout, rout, + rout, rout1,rout1}; + + std::vector pgonZHalf = {0, zstep1,zstep2,zstep3,zstep4,zstep5, + zstep5,zmax}; + + std::vector pgonRminHalf = {rin, rin,rmid1,rmid1,rmid2,rmid3, + rmid3,rmid4}; + + std::vector pgonRmaxHalf = {rout, rout, rout, rout, rout, rout, + rout1,rout1}; + + std::string name("Null"); DDSolid solid; if (nf == 0) { solid = DDSolidFactory::polyhedra(DDName(idName, idNameSpace), getNsectortot(), -alpha, dphi, pgonZ, pgonRmin, pgonRmax); - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " - << DDName(idName, idNameSpace) <<" Polyhedra made of " - << getGenMaterial() << " with " << getNsectortot() - << " sectors from " << -alpha/CLHEP::deg <<" to " - << (-alpha+dphi)/CLHEP::deg << " and with " << nsec - << " sections "; - for (i = 0; i pgonZ, pgonRmin, pgonRmax; + std::vector pgonZ, pgonRmin, pgonRmax; // index 0 pgonZ.emplace_back(0); pgonRmin.emplace_back(rin); @@ -519,30 +506,39 @@ void DDHCalBarrelAlgo::constructInsideSector(const DDLogicalPart& sector, DDComp double rmid = 0.5*(rin+rout); double width = rmid*tan(alpha) - getLayerGap(i); alpha1 = atan(width/rmid); - LogDebug("HCalGeom") << "\t" << "Alpha_1 modified from " - << alpha/CLHEP::deg << " to " << alpha1/CLHEP::deg - << " Rmid " << rmid << " Reduced width " << width; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "\t" << "Alpha_1 modified from " + << convertRadToDeg(alpha) << " to " + << convertRadToDeg(alpha1) + << " Rmid " << rmid << " Reduced width " + << width; +#endif } - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << name << " (Layer " - << i << ") Polyhedra made of " << getLayerMaterial(i) - << " with 1 sector from " << -alpha1/CLHEP::deg - << " to " << alpha1/CLHEP::deg << " and with " - << nsec << " sections"; - for (unsigned int k=0; k= getRmax(i)) in = i+1; } - vector pgonZ, pgonRmin, pgonRmax; + std::vector pgonZ, pgonRmin, pgonRmax; // index 0 pgonZ.emplace_back(0.0); pgonRmin.emplace_back(rsi); @@ -681,44 +689,51 @@ DDLogicalPart DDHCalBarrelAlgo::constructSideLayer(const DDLogicalPart& laylog, DDSolid solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1, -alpha, 2*alpha, pgonZ, pgonRmin, pgonRmax); - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name() - << " Polyhedra made of " << getSideMat(k) - << " with 1 sector from " << -alpha/CLHEP::deg - << " to " << alpha/CLHEP::deg << " and with " - << pgonZ.size() << " sections"; - for (unsigned int ii=0; ii 0) { - string name = namek + getSideAbsName(i); + std::string name = namek + getSideAbsName(i); solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), 1, -alpha1, 2*alpha1, pgonZ, pgonRmin, pgonRmax); - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name() - << " Polyhedra made of " << getSideAbsMat(i) - << " with 1 sector from " << -alpha1/CLHEP::deg - << " to " << alpha1/CLHEP::deg << " and with " - << pgonZ.size() << " sections"; - for (unsigned int ii=0; ii= getRmax(i)) in = i+1; } - vector pgonZ, pgonRmin, pgonRmax; + std::vector pgonZ, pgonRmin, pgonRmax; // index 0 pgonZ.emplace_back(0.0); pgonRmin.emplace_back(rsi); @@ -765,44 +784,51 @@ DDLogicalPart DDHCalBarrelAlgo::constructMidLayer(const DDLogicalPart& laylog, pgonRmax.emplace_back(pgonRmax[1]); solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1, -alpha, 2*alpha, pgonZ, pgonRmin, pgonRmax); - LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name() - << " Polyhedra made of " << getAbsorbMat(k) - << " with 1 sector from " << -alpha/CLHEP::deg - << " to " << alpha/CLHEP::deg << " and with " - << pgonZ.size() << " sections"; - for (unsigned int ii=0; ii Date: Thu, 4 Apr 2019 16:16:28 +0200 Subject: [PATCH 632/686] Minor changes --- Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc index 5d630692db4cb..8a3b69fb8e3f9 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc @@ -322,7 +322,7 @@ void DDHCalBarrelAlgo::constructGeneralVolume(DDCompactView& cpv) { edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: " << DDName(idName, idNameSpace) << " number 1 positioned in " << parentName - << " at " << r0 <<" with "< Date: Thu, 4 Apr 2019 01:25:43 +0200 Subject: [PATCH 633/686] Changes to some of the algorithms used for TB application by removing explicit reference to CLHEP --- Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc | 61 +++++++++------- .../HcalAlgo/plugins/DDHCalTestBeamAlgo.cc | 69 +++++++++++------- Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc | 72 +++++++++++-------- 3 files changed, 122 insertions(+), 80 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc index fcae533fca374..fe739f5385834 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc @@ -6,17 +6,20 @@ #include #include -namespace std{} using namespace std; - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHCalTBZposAlgo::DDHCalTBZposAlgo() { - LogDebug("HCalGeom") << "DDHCalTBZposAlgo test: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Creating an instance"; +#endif } DDHCalTBZposAlgo::~DDHCalTBZposAlgo() {} @@ -35,19 +38,22 @@ void DDHCalTBZposAlgo::initialize(const DDNumericArguments & nArgs, dist = nArgs["Distance"]; tilt = nArgs["TiltAngle"]; copyNumber = int (nArgs["Number"]); - LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parameters for position" - << "ing--" << " Eta " << eta << "\tTheta " - << theta/CLHEP::deg << "\tShifts " << shiftX << ", " - << shiftY << " along x, y axes; \tZoffest " << zoffset - << "\tRadial Distance " << dist << "\tTilt angle " - << tilt/CLHEP::deg << "\tcopyNumber " << copyNumber; + edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for position" + << "ing--" << " Eta " << eta << "\tTheta " + << convertRadToDeg(theta) << "\tShifts " + << shiftX << ", " << shiftY << " along x, y " + << "axes; \tZoffest " << zoffset + << "\tRadial Distance " << dist + << "\tTilt angle " << convertRadToDeg(tilt) + << "\tcopyNumber " << copyNumber; idNameSpace = DDCurrentNamespace::ns(); childName = sArgs["ChildName"]; - DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parent " << parentName - << "\tChild " << childName << " NameSpace " - << idNameSpace; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " < #include -namespace std{} using namespace std; #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHCalTestBeamAlgo::DDHCalTestBeamAlgo() { - LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating an instance"; +#endif } DDHCalTestBeamAlgo::~DDHCalTestBeamAlgo() {} @@ -33,39 +37,47 @@ void DDHCalTestBeamAlgo::initialize(const DDNumericArguments & nArgs, dz = nArgs["Dz"]; copyNumber = int (nArgs["Number"]); dist = (distance+distanceZ/sin(theta)); - LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parameters for position" - << "ing--" << " Eta " << eta << "\tPhi " - << phi/CLHEP::deg << "\tTheta " << theta/CLHEP::deg - << "\tDistance " << distance << "/" << distanceZ << "/" - << dist <<"\tDz " << dz <<"\tcopyNumber " << copyNumber; - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for position" + << "ing--" << " Eta " << eta << "\tPhi " + << convertRadToDeg(phi) << "\tTheta " + << convertRadToDeg(theta) << "\tDistance " + << distance << "/" << distanceZ << "/" + << dist <<"\tDz " << dz <<"\tcopyNumber " + << copyNumber; +#endif idNameSpace = DDCurrentNamespace::ns(); childName = sArgs["ChildName"]; - DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parent " << parentName - << "\tChild " << childName << " NameSpace " - << idNameSpace; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo:Parent " + << parent().name() << "\tChild " << childName + << " NameSpace " << idNameSpace; +#endif } void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) { - double thetax = 90.*CLHEP::deg + theta; + double thetax = 90._deg + theta; double sthx = sin(thetax); if (abs(sthx)>1.e-12) sthx = 1./sthx; else sthx = 1.; double phix = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi)); - double thetay = 90.*CLHEP::deg; - double phiy = 90.*CLHEP::deg + phi; + double thetay = 90._deg; + double phiy = 90._deg + phi; double thetaz = theta; double phiz = phi; DDRotation rotation; - string rotstr = childName; - LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating a new rotation " - << rotstr << "\t" << thetax/CLHEP::deg << "," - << phix/CLHEP::deg << "," << thetay/CLHEP::deg << "," - << phiy/CLHEP::deg << "," << thetaz/CLHEP::deg <<"," - << phiz/CLHEP::deg; + std::string rotstr = childName; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating a rotation " + << rotstr << "\t" << convertRadToDeg(thetax) + << "," << convertRadToDeg(phix) << "," + << convertRadToDeg(thetay) << "," + << convertRadToDeg(phiy) << "," + << convertRadToDeg(thetaz) <<"," + << convertRadToDeg(phiz); +#endif rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy, thetaz, phiz); @@ -76,11 +88,13 @@ void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) { DDTranslation tran(xpos, ypos, zpos); DDName parentName = parent().name(); - cpv.position(DDName(childName,idNameSpace), parentName,copyNumber, tran,rotation); - LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: " - << DDName(childName, idNameSpace) << " number " - << copyNumber << " positioned in " << parentName - << " at " << tran << " with " << rotation; + cpv.position(DDName(childName,idNameSpace), parentName, copyNumber, tran, + rotation); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: " + << DDName(childName, idNameSpace) << " number " + << copyNumber << " positioned in " << parentName + << " at " << tran << " with " << rotation; xpos = (dist-dz)*sin(theta)*cos(phi); ypos = (dist-dz)*sin(theta)*sin(phi); @@ -90,4 +104,5 @@ void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) { << "(" << xpos << ", " << ypos << ", " << zpos << ") and (dist, eta, phi) = (" << (dist-dz) << ", " << eta << ", " << phi << ")"; +#endif } diff --git a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc index 4e96e7f2bed3a..2eae358618b7b 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc @@ -6,15 +6,20 @@ #include #include -namespace std{} using namespace std; #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" +//#define EDM_ML_DEBUG +using namespace geant_units::operators; + DDHCalXtalAlgo::DDHCalXtalAlgo() { - LogDebug("HCalGeom") << "DDHCalXtalAlgo info: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo info: Creating an instance"; +#endif } DDHCalXtalAlgo::~DDHCalXtalAlgo() {} @@ -33,60 +38,71 @@ void DDHCalXtalAlgo::initialize(const DDNumericArguments & nArgs, iaxis = int (nArgs["Axis"]); names = vsArgs["Names"]; - LogDebug("HCalGeom") << "DDHCalXtalAlgo debug: Parameters for positioning:: " - << "Axis " << iaxis << "\tRadius " << radius - << "\tOffset " << offset << "\tDx " << dx << "\tDz " - << dz << "\tAngWidth " << angwidth/CLHEP::deg - << "\tNumbers " << names.size(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo::Parameters for positioning:" + << " Axis " << iaxis << "\tRadius " << radius + << "\tOffset " << offset << "\tDx " << dx + << "\tDz " << dz << "\tAngWidth " + << convertRadToDeg(angwidth) << "\tNumbers " + << names.size(); for (unsigned int i = 0; i < names.size(); i++) - LogDebug("HCalGeom") << "\tnames[" << i << "] = " << names[i]; - + edm::LogVerbatim("HCalGeom") << "\tnames[" << i << "] = " << names[i]; +#endif idNameSpace = DDCurrentNamespace::ns(); idName = sArgs["ChildName"]; - DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalXtalAlgo debug: Parent " << parentName - << "\tChild " << idName << " NameSpace " << idNameSpace; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Parent " << parent().name() + << "\tChild " << idName << " NameSpace " + << idNameSpace; +#endif } void DDHCalXtalAlgo::execute(DDCompactView& cpv) { double theta[3], phi[3], pos[3]; phi[0] = 0; - phi[1] = 90*CLHEP::deg; - theta[1-iaxis] = 90*CLHEP::deg; + phi[1] = 90._deg; + theta[1-iaxis] = 90._deg; pos[1-iaxis] = 0; int number = (int)(names.size()); for (int i=0; i0) { theta[2] = angle; - phi[2] = 90*iaxis*CLHEP::deg; + phi[2] = iaxis*90._deg; } else { theta[2] =-angle; - phi[2] = 90*(2-3*iaxis)*CLHEP::deg; + phi[2] = (2-3*iaxis)*90._deg; } pos[iaxis] = angle*(dz+radius); pos[2] = dx*abs(sin(angle)) + offset; DDRotation rotation; - string rotstr = names[i]; + std::string rotstr = names[i]; DDTranslation tran(pos[0], pos[1], pos[2]); DDName parentName = parent().name(); - if (abs(angle) > 0.01*CLHEP::deg) { - LogDebug("HCalGeom") << "DDHCalXtalAlgo test: Creating a new rotation " - << rotstr << "\t" << theta[0]/CLHEP::deg << "," - << phi[0]/CLHEP::deg << "," << theta[1]/CLHEP::deg - << "," << phi[1]/CLHEP::deg << "," - << theta[2]/CLHEP::deg << "," << phi[2]/CLHEP::deg; + if (std::lround(100.0*convertRadToDeg(angle)) != 0) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Creating a rotation " + << rotstr << "\t" + << convertRadToDeg(theta[0]) << "," + << convertRadToDeg(phi[0]) << "," + << convertRadToDeg(theta[1]) << "," + << convertRadToDeg(phi[1]) << "," + << convertRadToDeg(theta[2]) << "," + << convertRadToDeg(phi[2]); +#endif rotation = DDrot(DDName(rotstr, idNameSpace), theta[0], phi[0], theta[1], phi[1], theta[2], phi[2]); } cpv.position(DDName(idName, idNameSpace), parentName, i+1, tran, rotation); - LogDebug("HCalGeom") << "DDHCalXtalAlgo test: " - << DDName(idName,idNameSpace) << " number " << i+1 - << " positioned in " << parentName << " at " << tran - << " with " << rotation; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: " + << DDName(idName,idNameSpace) << " number " + << i+1 << " positioned in " << parentName + << " at " << tran << " with " << rotation; +#endif } } From e2e22c27424de1b48dcd44e24e5c2b7add5b3e5a Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 03:52:38 +0200 Subject: [PATCH 634/686] Make the scripts uptodate --- .../python/TB2007GeometryNoESXML_cfi.py | 2 + .../python/TB2007GeometryNoEcalXML_cfi.py | 2 + .../python/TB2007GeometryXML_cfi.py | 2 + .../test/python/run2006_33_cfg.py | 49 ++---- .../test/python/run2006_37_cfg.py | 49 ++---- .../test/python/run2006_77_cfg.py | 49 ++---- .../HcalTestBeam/test/python/run2006_cfg.py | 67 ++----- .../HcalTestBeam/test/python/run2007_cfg.py | 163 ++++++++---------- .../HcalTestBeam/test/python/run2010_cfg.py | 157 +++++++++-------- 9 files changed, 200 insertions(+), 340 deletions(-) diff --git a/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoESXML_cfi.py b/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoESXML_cfi.py index ed9f2ba81a934..e62b91167e694 100644 --- a/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoESXML_cfi.py +++ b/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoESXML_cfi.py @@ -18,6 +18,8 @@ 'Geometry/HcalTestBeamData/data/TBHcal07HcalOuter.xml', 'Geometry/HcalTestBeamData/data/TBHcal07Sens.xml', 'Geometry/HcalTestBeamData/data/TBHcal07eeSens.xml', + 'Geometry/HcalTestBeamData/data/TBHcal06SimNumbering.xml', + 'Geometry/HcalCommonData/data/hcalRecNumbering.xml', 'Geometry/HcalTestBeamData/data/TBHcal06ProdCuts.xml', 'Geometry/HcalTestBeamData/data/TBHcal06Util.xml'), rootNodeName = cms.string('TBHcal:OTBHCal') diff --git a/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoEcalXML_cfi.py b/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoEcalXML_cfi.py index bde0e9d50e3f9..1d9e6a854d5ef 100644 --- a/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoEcalXML_cfi.py +++ b/SimG4CMS/HcalTestBeam/python/TB2007GeometryNoEcalXML_cfi.py @@ -11,6 +11,8 @@ 'Geometry/HcalTestBeamData/data/TBHcalEndcap.xml', 'Geometry/HcalTestBeamData/data/TBHcal07HcalOuter.xml', 'Geometry/HcalTestBeamData/data/TBHcal07Sens.xml', + 'Geometry/HcalTestBeamData/data/TBHcal06SimNumbering.xml', + 'Geometry/HcalCommonData/data/hcalRecNumbering.xml', 'Geometry/HcalTestBeamData/data/TBHcal06ProdCuts.xml', 'Geometry/HcalTestBeamData/data/TBHcal06Util.xml'), rootNodeName = cms.string('TBHcal:OTBHCal') diff --git a/SimG4CMS/HcalTestBeam/python/TB2007GeometryXML_cfi.py b/SimG4CMS/HcalTestBeam/python/TB2007GeometryXML_cfi.py index b5656072f5ed8..5bfa072650afc 100644 --- a/SimG4CMS/HcalTestBeam/python/TB2007GeometryXML_cfi.py +++ b/SimG4CMS/HcalTestBeam/python/TB2007GeometryXML_cfi.py @@ -20,6 +20,8 @@ 'Geometry/HcalTestBeamData/data/TBHcal07Sens.xml', 'Geometry/HcalTestBeamData/data/TBHcal07eeSens.xml', 'Geometry/HcalTestBeamData/data/TBHcal07esSens.xml', + 'Geometry/HcalTestBeamData/data/TBHcal06SimNumbering.xml', + 'Geometry/HcalCommonData/data/hcalRecNumbering.xml', 'Geometry/HcalTestBeamData/data/TBHcal06ProdCuts.xml', 'Geometry/HcalTestBeamData/data/TBHcal06Util.xml'), rootNodeName = cms.string('TBHcal:OTBHCal') diff --git a/SimG4CMS/HcalTestBeam/test/python/run2006_33_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2006_33_cfg.py index 3f7a5029d7cd2..24c26e3feda05 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2006_33_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2006_33_cfg.py @@ -2,54 +2,26 @@ process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") +process.load('SimG4CMS.HcalTestBeam.TB2006Geometry33XML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') process.load('Configuration.StandardSequences.Services_cff') -process.load("SimG4CMS.HcalTestBeam.TB2006Geometry33XML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') process.load('GeneratorInterface.Core.generatorSmeared_cfi') process.load('SimG4Core.Application.g4SimHits_cfi') process.load('IOMC.RandomEngine.IOMC_cff') +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') + process.TFileService = cms.Service("TFileService", fileName = cms.string('hcaltb06_33.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - categories = cms.untracked.vstring('CaloSim', - 'HCalGeom', - 'HcalSim', - 'HcalTBSim', - 'SimHCalData'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HCalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimHCalData = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ) - ) - ) - process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 @@ -118,6 +90,7 @@ HcalWidth = cms.double(0.640), EcalFactor = cms.double(1.0), HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), Verbose = cms.untracked.bool(True), MakeTree = cms.untracked.bool(True) ) diff --git a/SimG4CMS/HcalTestBeam/test/python/run2006_37_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2006_37_cfg.py index 1c804cf39ab18..73a2c9c0f3b0e 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2006_37_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2006_37_cfg.py @@ -2,54 +2,26 @@ process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") +process.load('SimG4CMS.HcalTestBeam.TB2006Geometry37XML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') process.load('Configuration.StandardSequences.Services_cff') -process.load("SimG4CMS.HcalTestBeam.TB2006Geometry37XML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') process.load('GeneratorInterface.Core.generatorSmeared_cfi') process.load('SimG4Core.Application.g4SimHits_cfi') process.load('IOMC.RandomEngine.IOMC_cff') +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') + process.TFileService = cms.Service("TFileService", fileName = cms.string('hcaltb06_37.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - categories = cms.untracked.vstring('CaloSim', - 'HCalGeom', - 'HcalSim', - 'HcalTBSim', - 'SimHCalData'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HCalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimHCalData = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ) - ) - ) - process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 @@ -118,6 +90,7 @@ HcalWidth = cms.double(0.640), EcalFactor = cms.double(1.0), HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), Verbose = cms.untracked.bool(True), MakeTree = cms.untracked.bool(True) ) diff --git a/SimG4CMS/HcalTestBeam/test/python/run2006_77_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2006_77_cfg.py index 036c47aa15316..f6d4e9b17f37b 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2006_77_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2006_77_cfg.py @@ -2,54 +2,26 @@ process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") +process.load('SimG4CMS.HcalTestBeam.TB2006Geometry77XML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') process.load('Configuration.StandardSequences.Services_cff') -process.load("SimG4CMS.HcalTestBeam.TB2006Geometry77XML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') process.load('GeneratorInterface.Core.generatorSmeared_cfi') process.load('SimG4Core.Application.g4SimHits_cfi') process.load('IOMC.RandomEngine.IOMC_cff') +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') + process.TFileService = cms.Service("TFileService", fileName = cms.string('hcaltb06_77.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - categories = cms.untracked.vstring('CaloSim', - 'HCalGeom', - 'HcalSim', - 'HcalTBSim', - 'SimHCalData'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HCalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimHCalData = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ) - ) - ) - process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 @@ -118,6 +90,7 @@ HcalWidth = cms.double(0.640), EcalFactor = cms.double(1.0), HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), Verbose = cms.untracked.bool(True), MakeTree = cms.untracked.bool(True) ) diff --git a/SimG4CMS/HcalTestBeam/test/python/run2006_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2006_cfg.py index 023c6d30ae064..777319e6f2f2b 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2006_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2006_cfg.py @@ -2,72 +2,26 @@ process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") +process.load('SimG4CMS.HcalTestBeam.TB2006GeometryXML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') process.load('Configuration.StandardSequences.Services_cff') -process.load("SimG4CMS.HcalTestBeam.TB2006GeometryXML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') process.load('GeneratorInterface.Core.generatorSmeared_cfi') process.load('SimG4Core.Application.g4SimHits_cfi') process.load('IOMC.RandomEngine.IOMC_cff') +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') + process.TFileService = cms.Service("TFileService", fileName = cms.string('hcaltb06.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - debugModules = cms.untracked.vstring('*'), - categories = cms.untracked.vstring('CaloSim', - 'EcalGeom', - 'EcalSim', - 'HCalGeom', - 'HcalSim', - 'HcalTBSim', - 'SimHCalData', - 'SimG4CoreGeometry', - 'SimG4CoreApplication', - 'VertexGenerator'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - VertexGenerator = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - SimG4CoreApplication = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimG4CoreGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - EcalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HCalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimHCalData = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ) - ) - ) - process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 @@ -142,6 +96,7 @@ HcalWidth = cms.double(0.640), EcalFactor = cms.double(1.0), HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), Verbose = cms.untracked.bool(True), MakeTree = cms.untracked.bool(True) ) diff --git a/SimG4CMS/HcalTestBeam/test/python/run2007_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2007_cfg.py index 58758a2b4f023..a1aac02c6260a 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2007_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2007_cfg.py @@ -1,77 +1,36 @@ import FWCore.ParameterSet.Config as cms process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") -process.load("SimG4CMS.HcalTestBeam.TB2007GeometryNoESXML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") -process.load("SimG4Core.Application.g4SimHits_cfi") + +process.load('SimG4CMS.HcalTestBeam.TB2007GeometryNoESXML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') +process.load('GeneratorInterface.Core.generatorSmeared_cfi') +process.load('SimG4Core.Application.g4SimHits_cfi') +process.load('IOMC.RandomEngine.IOMC_cff') + +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') process.TFileService = cms.Service("TFileService", fileName = cms.string('hcaltb07.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - categories = cms.untracked.vstring('CaloSim', - 'EcalGeom', - 'EcalSim', - 'HCalGeom', - 'HcalSim', - 'HcalTBSim', - 'SimHCalData', - 'SimG4CoreGeometry', - 'SimG4CoreApplication', - 'VertexGenerator'), - debugModules = cms.untracked.vstring('*'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('DEBUG'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - VertexGenerator = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimG4CoreApplication = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimG4CoreGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - EcalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HCalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - EcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - SimHCalData = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ) - ) -) - process.load("IOMC.RandomEngine.IOMC_cff") process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 process.common_beam_direction_parameters = cms.PSet( + MinE = cms.double(50.0), + MaxE = cms.double(50.0), + PartID = cms.vint32(-211), MinEta = cms.double(1.562), MaxEta = cms.double(1.562), MinPhi = cms.double(0.0436), @@ -88,9 +47,6 @@ process.generator = cms.EDProducer("FlatRandomEGunProducer", PGunParameters = cms.PSet( process.common_beam_direction_parameters, - MinE = cms.double(50.0), - MaxE = cms.double(50.0), - PartID = cms.vint32(-211) ), Verbosity = cms.untracked.int32(0), AddAntiParticle = cms.bool(False) @@ -129,13 +85,34 @@ ) process.Timing = cms.Service("Timing") -process.p1 = cms.Path(process.generator*process.VtxSmeared*process.g4SimHits) +process.testbeam = cms.EDAnalyzer("HcalTB06Analysis", + process.common_beam_direction_parameters, + ECAL = cms.bool(False), + TestBeamAnalysis = cms.PSet( + EHCalMax = cms.untracked.double(50.0), + ETtotMax = cms.untracked.double(400.0), + beamEnergy = cms.untracked.double(50.), + TimeLimit = cms.double(180.0), + EcalWidth = cms.double(0.362), + HcalWidth = cms.double(0.640), + EcalFactor = cms.double(1.0), + HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), + Verbose = cms.untracked.bool(True), + MakeTree = cms.untracked.bool(True) + ) + ) + +process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.testbeam) process.outpath = cms.EndPath(process.o1) process.common_maximum_timex = cms.PSet( MaxTrackTime = cms.double(1000.0), MaxTimeNames = cms.vstring(), - MaxTrackTimes = cms.vdouble() + MaxTrackTimes = cms.vdouble(), + DeadRegions = cms.vstring(), + CriticalEnergyForVacuum = cms.double(2.0), + CriticalDensity = cms.double(1e-15) ) process.g4SimHits.NonBeamEvent = True process.g4SimHits.UseMagneticField = False @@ -161,32 +138,45 @@ process.g4SimHits.StackingAction = cms.PSet( process.common_heavy_suppression1, process.common_maximum_timex, - TrackNeutrino = cms.bool(False), KillDeltaRay = cms.bool(False), + TrackNeutrino = cms.bool(False), KillHeavy = cms.bool(False), + KillGamma = cms.bool(True), + GammaThreshold = cms.double(0.0001), ## (MeV) SaveFirstLevelSecondary = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInTracker = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInCalo = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInMuon = cms.untracked.bool(False), - RusRoEcalNeutron = cms.double(1.0), - RusRoEcalNeutronLimit = cms.double(0.0), - RusRoHcalNeutron = cms.double(1.0), - RusRoHcalNeutronLimit = cms.double(0.0), - RusRoEcalProton = cms.double(1.0), - RusRoEcalProtonLimit = cms.double(0.0), - RusRoHcalProton = cms.double(1.0), - RusRoHcalProtonLimit = cms.double(0.0) -) + SaveAllPrimaryDecayProductsAndConversions = cms.untracked.bool(True), + RusRoGammaEnergyLimit = cms.double(5.0), ## (MeV) + RusRoEcalGamma = cms.double(0.3), + RusRoHcalGamma = cms.double(0.3), + RusRoMuonIronGamma = cms.double(0.3), + RusRoPreShowerGamma = cms.double(0.3), + RusRoCastorGamma = cms.double(0.3), + RusRoWorldGamma = cms.double(0.3), + RusRoNeutronEnergyLimit = cms.double(10.0), ## (MeV) + RusRoEcalNeutron = cms.double(0.1), + RusRoHcalNeutron = cms.double(0.1), + RusRoMuonIronNeutron = cms.double(0.1), + RusRoPreShowerNeutron = cms.double(0.1), + RusRoCastorNeutron = cms.double(0.1), + RusRoWorldNeutron = cms.double(0.1), + RusRoProtonEnergyLimit = cms.double(0.0), + RusRoEcalProton = cms.double(1.0), + RusRoHcalProton = cms.double(1.0), + RusRoMuonIronProton = cms.double(1.0), + RusRoPreShowerProton = cms.double(1.0), + RusRoCastorProton = cms.double(1.0), + RusRoWorldProton = cms.double(1.0) + ) + process.g4SimHits.SteppingAction = cms.PSet( process.common_maximum_timex, - KillBeamPipe = cms.bool(True), - CriticalEnergyForVacuum = cms.double(2.0), - CriticalDensity = cms.double(1e-15), EkinNames = cms.vstring(), EkinThresholds = cms.vdouble(), - EkinParticles = cms.vstring(), - Verbosity = cms.untracked.int32(0) -) + EkinParticles = cms.vstring() + ) process.g4SimHits.CaloSD = cms.PSet( process.common_beam_direction_parameters, process.common_heavy_suppression1, @@ -204,15 +194,6 @@ DetailedTiming = cms.untracked.bool(False), CorrectTOFBeam = cms.bool(False) ) + process.g4SimHits.CaloTrkProcessing.TestBeam = True -process.g4SimHits.Watchers = cms.VPSet(cms.PSet( - HcalTB06Analysis = cms.PSet( - process.common_beam_direction_parameters, - Names = cms.vstring('HcalHits', 'EcalHitsEB'), - EHCalMax = cms.untracked.double(10.0), - ETtotMax = cms.untracked.double(500.0), - Verbose = cms.untracked.bool(True) - ), - type = cms.string('HcalTB06Analysis') -)) diff --git a/SimG4CMS/HcalTestBeam/test/python/run2010_cfg.py b/SimG4CMS/HcalTestBeam/test/python/run2010_cfg.py index a0cd40d2f6ce7..47cc6bef01181 100644 --- a/SimG4CMS/HcalTestBeam/test/python/run2010_cfg.py +++ b/SimG4CMS/HcalTestBeam/test/python/run2010_cfg.py @@ -2,57 +2,35 @@ process = cms.Process("PROD") -process.load("SimGeneral.HepPDTESSource.pdt_cfi") -process.load("SimG4CMS.HcalTestBeam.TB2010GeometryXML_cfi") -process.load("Geometry.HcalCommonData.hcalParameters_cfi") -process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cfi") -process.load("Configuration.EventContent.EventContent_cff") -process.load("SimG4Core.Application.g4SimHits_cfi") +process.load('SimG4CMS.HcalTestBeam.TB2010GeometryXML_cfi') +process.load('SimGeneral.HepPDTESSource.pdt_cfi') +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Geometry.HcalCommonData.hcalParameters_cfi') +process.load('Geometry.HcalCommonData.hcalDDDSimConstants_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') +process.load('GeneratorInterface.Core.generatorSmeared_cfi') +process.load('SimG4Core.Application.g4SimHits_cfi') +process.load('IOMC.RandomEngine.IOMC_cff') + +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HCalGeom') + process.MessageLogger.categories.append('HcalSim') process.TFileService = cms.Service("TFileService", fileName = cms.string('ehcaltb10.root') ) -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('cout'), - debugModules = cms.untracked.vstring('*'), - categories = cms.untracked.vstring('CaloSim', - 'EcalSim', - 'HcalSim', - 'HcalTBSim', - 'EcalGeom'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('DEBUG'), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - CaloSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - EcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HcalTBSim = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - EcalGeom = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ) - ) -) - process.load("IOMC.RandomEngine.IOMC_cff") process.RandomNumberGeneratorService.generator.initialSeed = 456789 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 process.common_beam_direction_parameters = cms.PSet( + MinE = cms.double(50.0), + MaxE = cms.double(50.0), + PartID = cms.vint32(-211), MinEta = cms.double(0.2175), MaxEta = cms.double(0.2175), MinPhi = cms.double(-0.1309), @@ -66,15 +44,12 @@ ) process.generator = cms.EDProducer("FlatRandomEGunProducer", - PGunParameters = cms.PSet( - process.common_beam_direction_parameters, - MinE = cms.double(50.0), - MaxE = cms.double(50.0), - PartID = cms.vint32(-211) - ), - Verbosity = cms.untracked.int32(0), - AddAntiParticle = cms.bool(False) -) + PGunParameters = cms.PSet( + process.common_beam_direction_parameters, + ), + Verbosity = cms.untracked.int32(0), + AddAntiParticle = cms.bool(False) + ) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) @@ -110,13 +85,34 @@ TimeOffset = cms.double(0.) ) -process.p1 = cms.Path(process.generator*process.VtxSmeared*process.g4SimHits) +process.testbeam = cms.EDAnalyzer("HcalTB06Analysis", + process.common_beam_direction_parameters, + ECAL = cms.bool(True), + TestBeamAnalysis = cms.PSet( + EHCalMax = cms.untracked.double(50.0), + ETtotMax = cms.untracked.double(400.0), + beamEnergy = cms.untracked.double(50.), + TimeLimit = cms.double(180.0), + EcalWidth = cms.double(0.362), + HcalWidth = cms.double(0.640), + EcalFactor = cms.double(1.0), + HcalFactor = cms.double(100.0), + MIP = cms.double(0.8), + Verbose = cms.untracked.bool(True), + MakeTree = cms.untracked.bool(True) + ) + ) + +process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.testbeam) process.outpath = cms.EndPath(process.o1) process.common_maximum_timex = cms.PSet( MaxTrackTime = cms.double(1000.0), MaxTimeNames = cms.vstring(), - MaxTrackTimes = cms.vdouble() + MaxTrackTimes = cms.vdouble(), + DeadRegions = cms.vstring(), + CriticalEnergyForVacuum = cms.double(2.0), + CriticalDensity = cms.double(1e-15) ) process.g4SimHits.NonBeamEvent = True process.g4SimHits.UseMagneticField = False @@ -142,32 +138,46 @@ process.g4SimHits.StackingAction = cms.PSet( process.common_heavy_suppression1, process.common_maximum_timex, - TrackNeutrino = cms.bool(False), KillDeltaRay = cms.bool(False), + TrackNeutrino = cms.bool(False), KillHeavy = cms.bool(False), + KillGamma = cms.bool(True), + GammaThreshold = cms.double(0.0001), ## (MeV) SaveFirstLevelSecondary = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInTracker = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInCalo = cms.untracked.bool(False), SavePrimaryDecayProductsAndConversionsInMuon = cms.untracked.bool(False), - RusRoEcalNeutron = cms.double(1.0), - RusRoEcalNeutronLimit = cms.double(0.0), - RusRoHcalNeutron = cms.double(1.0), - RusRoHcalNeutronLimit = cms.double(0.0), - RusRoEcalProton = cms.double(1.0), - RusRoEcalProtonLimit = cms.double(0.0), - RusRoHcalProton = cms.double(1.0), - RusRoHcalProtonLimit = cms.double(0.0) -) + SaveAllPrimaryDecayProductsAndConversions = cms.untracked.bool(True), + RusRoGammaEnergyLimit = cms.double(5.0), ## (MeV) + RusRoEcalGamma = cms.double(0.3), + RusRoHcalGamma = cms.double(0.3), + RusRoMuonIronGamma = cms.double(0.3), + RusRoPreShowerGamma = cms.double(0.3), + RusRoCastorGamma = cms.double(0.3), + RusRoWorldGamma = cms.double(0.3), + RusRoNeutronEnergyLimit = cms.double(10.0), ## (MeV) + RusRoEcalNeutron = cms.double(0.1), + RusRoHcalNeutron = cms.double(0.1), + RusRoMuonIronNeutron = cms.double(0.1), + RusRoPreShowerNeutron = cms.double(0.1), + RusRoCastorNeutron = cms.double(0.1), + RusRoWorldNeutron = cms.double(0.1), + RusRoProtonEnergyLimit = cms.double(0.0), + RusRoEcalProton = cms.double(1.0), + RusRoHcalProton = cms.double(1.0), + RusRoMuonIronProton = cms.double(1.0), + RusRoPreShowerProton = cms.double(1.0), + RusRoCastorProton = cms.double(1.0), + RusRoWorldProton = cms.double(1.0) + ) + process.g4SimHits.SteppingAction = cms.PSet( process.common_maximum_timex, - KillBeamPipe = cms.bool(True), - CriticalEnergyForVacuum = cms.double(2.0), - CriticalDensity = cms.double(1e-15), EkinNames = cms.vstring(), EkinThresholds = cms.vdouble(), - EkinParticles = cms.vstring(), - Verbosity = cms.untracked.int32(0) -) + EkinParticles = cms.vstring() + ) + process.g4SimHits.CaloSD = cms.PSet( process.common_beam_direction_parameters, process.common_heavy_suppression1, @@ -185,16 +195,5 @@ DetailedTiming = cms.untracked.bool(False), CorrectTOFBeam = cms.bool(False) ) -process.g4SimHits.CaloTrkProcessing.TestBeam = True -process.g4SimHits.Watchers = cms.VPSet(cms.PSet( - HcalTB06Analysis = cms.PSet( - process.common_beam_direction_parameters, - Names = cms.vstring('HcalHits', 'EcalHitsEB'), - EHCalMax = cms.untracked.double(10.0), - ETtotMax = cms.untracked.double(500.0), - Verbose = cms.untracked.bool(True) - ), - type = cms.string('HcalTB06Analysis') -)) - +process.g4SimHits.CaloTrkProcessing.TestBeam = True From b53784c67dc4c70c8b67cedfdeaf4252e5d04e2e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 16:43:45 +0200 Subject: [PATCH 635/686] Convert to degree only to get rotation matrix name --- Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc | 5 ++--- Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc | 4 ++-- Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc index fe739f5385834..bf6f153da742e 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc @@ -67,9 +67,8 @@ void DDHCalTBZposAlgo::execute(DDCompactView& cpv) { double y = shiftY*cos(tilt); DDTranslation tran(x,y,z); DDRotation rot; - double tiltdeg = convertRadToDeg(tilt); - int itilt = int(tiltdeg+0.1); - if (itilt != 0) { + if (tilt != 0) { + int tiltdeg = std::lround(convertRadToDeg(tilt)); std::string rotstr = "R"; if (tiltdeg < 100) rotstr = "R0"; rotstr = rotstr + std::to_string(tiltdeg); diff --git a/Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc index 1c4a45b2729ff..f87bbd78e0cae 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.cc @@ -59,8 +59,8 @@ void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) { double thetax = 90._deg + theta; double sthx = sin(thetax); - if (abs(sthx)>1.e-12) sthx = 1./sthx; - else sthx = 1.; + if (std::abs(sthx)>1.e-12) sthx = 1./sthx; + else sthx = 1.; double phix = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi)); double thetay = 90._deg; double phiy = 90._deg + phi; diff --git a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc index 2eae358618b7b..0a2735cccffaa 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc @@ -76,14 +76,15 @@ void DDHCalXtalAlgo::execute(DDCompactView& cpv) { phi[2] = (2-3*iaxis)*90._deg; } pos[iaxis] = angle*(dz+radius); - pos[2] = dx*abs(sin(angle)) + offset; + pos[2] = dx*std::abs(sin(angle)) + offset; DDRotation rotation; std::string rotstr = names[i]; DDTranslation tran(pos[0], pos[1], pos[2]); DDName parentName = parent().name(); - if (std::lround(100.0*convertRadToDeg(angle)) != 0) { + static const int tol = 0.000174523292; // 0.01 degree + if (std::abs(angle) > tol) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Creating a rotation " << rotstr << "\t" From dadf96368bb7da45643cf6610c4aa12cc212078a Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 4 Apr 2019 17:03:07 +0200 Subject: [PATCH 636/686] Correct a typing error --- Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc index 0a2735cccffaa..418307e443504 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalXtalAlgo.cc @@ -83,7 +83,7 @@ void DDHCalXtalAlgo::execute(DDCompactView& cpv) { DDTranslation tran(pos[0], pos[1], pos[2]); DDName parentName = parent().name(); - static const int tol = 0.000174523292; // 0.01 degree + static const double tol = 0.000174523292; // 0.01 degree if (std::abs(angle) > tol) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Creating a rotation " From 0881518da82a14ade108ee14e55b195a37e5ad9c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 22:04:11 +0200 Subject: [PATCH 637/686] Make use of formatAsDegreesInInteger --- DetectorDescription/Core/src/DDTypes.cc | 3 ++- Geometry/HcalAlgo/plugins/DDHCalAngular.cc | 4 ++-- Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc | 9 +++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/DetectorDescription/Core/src/DDTypes.cc b/DetectorDescription/Core/src/DDTypes.cc index 51c9a4706fc95..75254eea2d8c8 100644 --- a/DetectorDescription/Core/src/DDTypes.cc +++ b/DetectorDescription/Core/src/DDTypes.cc @@ -88,7 +88,8 @@ std::string formatAsDegreesInInteger(double radianVal) { const unsigned short numlen = 4; char degstr[numlen]; int degVal = std::lround(convertRadToDeg( radianVal )); - if (degVal < 0) degVal += 360; + if (degVal < 0) degVal += 360; + else if (degVal >= 360) degVal -= 360; int retval = snprintf(degstr, numlen, "%0*d", numlen-1, degVal); if (retval == numlen - 1) return degstr; diff --git a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc index 79beca3c6acce..7ce1cb9ebc7e6 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalAngular.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalAngular.cc @@ -80,8 +80,8 @@ void DDHCalAngular::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, " - << convertRadToDeg(phi) << ", 90, " - << (90+convertRadToDeg(phi)) << ", 0, 0"; + << convertRadToDeg(phix) << ", 90, " + << (90+convertRadToDeg(phix)) << ", 0, 0"; #endif rotation = DDrot(DDName(rotstr, rotns), theta, phix, theta, phiy, 0,0); } diff --git a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc index 8a3b69fb8e3f9..45c86ec83581b 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc @@ -392,17 +392,14 @@ void DDHCalBarrelAlgo::constructGeneralVolume(DDCompactView& cpv) { DDRotation rotation; std::string rotstr("NULL"); if (phi != 0) { - double phideg = convertRadToDeg(phi); - rotstr = "R"; - if (phideg < 100) rotstr = "R0"; - rotstr = rotstr + std::to_string(std::lround(phideg)); + rotstr = "R" + formatAsDegreesInInteger(phi); rotation = DDRotation(DDName(rotstr, rotns)); if (!rotation) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("HCalGeom") << "DDHCalBarrelAlgo: Creating a new " << "rotation " << rotstr << "\t 90," - << phideg << ",90," << (phideg+90) - << ", 0, 0"; + << convertRadToDeg(phi) << ",90," + << (90+convertRadToDeg(phi)) << ", 0, 0"; #endif rotation = DDrot(DDName(rotstr, rotns), theta, phi, theta, phiy, 0, 0); } //if !rotation From cb3619686fa498a62120384ac2145e259d433f69 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 13 Apr 2019 22:19:21 +0200 Subject: [PATCH 638/686] Make use of formatAsDegreesInInteger --- Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.cc | 12 ++++-------- Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc | 9 +++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.cc index 28da8d9643739..af0965f9875fc 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.cc @@ -160,21 +160,17 @@ void DDHCalTBCableAlgo::execute(DDCompactView& cpv) { for (int ii=0; ii Date: Sun, 14 Apr 2019 20:05:01 +0200 Subject: [PATCH 639/686] Take Kevin's comments --- .../interface/HGCalDDDConstants.h | 2 +- .../HGCalCommonData/plugins/DDHGCalModule.cc | 153 +++++++++--------- .../plugins/DDHGCalModuleAlgo.cc | 128 ++++++++------- .../plugins/DDHGCalTBModule.cc | 132 ++++++++------- .../src/FastTimeDDDConstants.cc | 59 ++++--- 5 files changed, 252 insertions(+), 222 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h index 27c7452e7ef11..e847a5aee5a64 100644 --- a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h @@ -106,7 +106,7 @@ class HGCalDDDConstants { int maxCells(bool reco) const; int maxCells(int lay, bool reco) const; int maxModules() const { return modHalf_; } - int maxMoudlesPerLayer() const { return maxWafersPerLayer_; } + int maxModulesPerLayer() const { return maxWafersPerLayer_; } int maxRows(int lay, bool reco) const; double minSlope() const { return hgpar_->slopeMin_[0]; } int modifyUV(int uv, int type1, int type2) const; diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc b/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc index 35f83575f066a..7d45e9e86c475 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModule.cc @@ -6,8 +6,7 @@ #include #include -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" @@ -20,10 +19,11 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalModule.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalModule::DDHGCalModule() { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule info: Creating an instance" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Creating an instance"; #endif } @@ -36,9 +36,9 @@ void DDHGCalModule::initialize(const DDNumericArguments& nArgs, const DDStringVectorArguments& vsArgs) { wafer = vsArgs["WaferName"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << wafer.size() << " wafers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << wafer.size() << " wafers"; for (unsigned int i = 0; i < wafer.size(); ++i) - std::cout << "Wafer[" << i << "] " << wafer[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer[i]; #endif materials = vsArgs["MaterialNames"]; names = vsArgs["VolumeNames"]; @@ -47,52 +47,58 @@ void DDHGCalModule::initialize(const DDNumericArguments& nArgs, copyNumber.emplace_back(1); } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << materials.size() << " types of volumes" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << materials.size() + << " types of volumes"; for (unsigned int i = 0; i < names.size(); ++i) - std::cout << "Volume [" << i << "] " << names[i] << " of thickness " - << thick[i] << " filled with " << materials[i] - << " first copy number " << copyNumber[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names[i] + << " of thickness " << thick[i] + << " filled with " << materials[i] + << " first copy number " << copyNumber[i]; #endif layers = dbl_to_int(vArgs["Layers"]); layerThick = vArgs["LayerThick"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << layers.size() << " blocks" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << layers.size() <<" blocks"; for (unsigned int i = 0; i < layers.size(); ++i) - std::cout << "Block [" << i << "] of thickness " << layerThick[i] - << " with " << layers[i] << " layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " + << layerThick[i] << " with " << layers[i] + << " layers"; #endif layerType = dbl_to_int(vArgs["LayerType"]); layerSense = dbl_to_int(vArgs["LayerSense"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << layerType.size() << " layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << layerType.size() + << " layers"; for (unsigned int i = 0; i < layerType.size(); ++i) - std::cout << "Layer [" << i << "] with material type " << layerType[i] - << " sensitive class " << layerSense[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " + << layerType[i] << " sensitive class " + << layerSense[i]; #endif zMinBlock = nArgs["zMinBlock"]; rMaxFine = nArgs["rMaxFine"]; waferW = nArgs["waferW"]; sectors = (int)(nArgs["Sectors"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: zStart " << zMinBlock << " rFineCoarse " - << rMaxFine << " wafer width " << waferW << " sectors " << sectors - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: zStart " << zMinBlock + << " rFineCoarse " << rMaxFine << " wafer width " + << waferW << " sectors " << sectors; #endif slopeB = vArgs["SlopeBottom"]; slopeT = vArgs["SlopeTop"]; zFront = vArgs["ZFront"]; rMaxFront = vArgs["RMaxFront"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: Bottom slopes " << slopeB[0] << ":" << slopeB[1] - << " and " << slopeT.size() << " slopes for top" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Bottom slopes " << slopeB[0] + << ":" << slopeB[1] << " and " << slopeT.size() + << " slopes for top"; for (unsigned int i = 0; i < slopeT.size(); ++i) - std::cout << "Block [" << i << "] Zmin " << zFront[i] << " Rmax " - << rMaxFront[i] << " Slope " << slopeT[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFront[i] + << " Rmax " << rMaxFront[i] << " Slope " + << slopeT[i]; #endif idNameSpace = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: NameSpace " << idNameSpace << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: NameSpace " << idNameSpace; #endif } @@ -102,34 +108,27 @@ void DDHGCalModule::initialize(const DDNumericArguments& nArgs, void DDHGCalModule::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "==>> Constructing DDHGCalModule..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalModule..."; #endif copies.clear(); constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - std::cout << copies.size() << " different wafer copy numbers" << std::endl; - int nk(0), k(0); + edm::LogVerbatim("HGCalGeom") << copies.size() << " different wafer copy numbers"; + int k(0); for (std::unordered_set::const_iterator itr = copies.begin(); - itr != copies.end(); ++itr, ++k) { - std::cout << "[" << k << "] : " << (*itr) << " "; - ++nk; - if (nk == 8) { - std::cout << std::endl; - nk = 0; - } - } - if (nk > 0) std::cout << std::endl; + itr != copies.end(); ++itr, ++k) + edm::LogVerbatim("HGCalGeom") << "Copy[" << k << "] : " << (*itr); #endif copies.clear(); #ifdef EDM_ML_DEBUG - std::cout << "<<== End of DDHGCalModule construction ..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalModule construction ..."; #endif } void DDHGCalModule::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: \t\tInside Layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: \t\tInside Layers"; #endif double zi(zMinBlock); int laymin(0); @@ -149,16 +148,17 @@ void DDHGCalModule::constructLayers(const DDLogicalPart& module, std::string name = "HGCal" + names[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: Layer " << ly << ":" << ii << " Front " - << zi << ", " << routF << " Back " << zo << ", " << rinB - << " superlayer thickness " << layerThick[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Layer " << ly << ":" << ii + << " Front " << zi << ", " << routF + << " Back " << zo << ", " << rinB + << " superlayer thickness " << layerThick[i]; #endif DDName matName(DDSplit(materials[ii]).first, DDSplit(materials[ii]).second); DDMaterial matter(matName); DDLogicalPart glog; if (layerSense[ly] == 0) { - double alpha = CLHEP::pi / sectors; + double alpha = geant_units::piRadians / sectors; double rmax = routF * cos(alpha) - tol; std::vector pgonZ, pgonRin, pgonRout; pgonZ.emplace_back(-0.5 * thick[ii]); @@ -168,30 +168,35 @@ void DDHGCalModule::constructLayers(const DDLogicalPart& module, pgonRout.emplace_back(rmax); pgonRout.emplace_back(rmax); DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), - sectors, -alpha, CLHEP::twopi, + sectors, -alpha, + 2*geant_units::piRadians, pgonZ, pgonRin, pgonRout); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: " << solid.name() << " polyhedra of " - << sectors << " sectors covering " << -alpha / CLHEP::deg - << ":" << (-alpha + CLHEP::twopi) / CLHEP::deg << " with " - << pgonZ.size() << " sections" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << solid.name() + << " polyhedra of " << sectors + << " sectors covering " + << convertRadToDeg(-alpha) + << ":" << (360.0+convertRadToDeg(-alpha)) + << " with " << pgonZ.size() << " sections"; for (unsigned int k = 0; k < pgonZ.size(); ++k) - std::cout << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] - << ":" << pgonRout[k] << std::endl; + edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] + << " R " << pgonRin[k] + << ":" << pgonRout[k]; #endif } else { DDSolid solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * thick[ii], - rinB, routF, 0.0, CLHEP::twopi); + rinB, routF, 0.0, 2*geant_units::piRadians); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: " << solid.name() << " Tubs made of " - << matName << " of dimensions " << rinB << ", " << routF - << ", " << 0.5 * thick[ii] << ", 0.0, " - << CLHEP::twopi / CLHEP::deg << std::endl; - std::cout << "DDHGCalModule test position in: " << glog.name() - << " number " << copy << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << solid.name() + << " Tubs made of " << matName + << " of dimensions " << rinB << ", " + << routF << ", " << 0.5 * thick[ii] + << ", 0.0, 360.0"; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule test position in: " + << glog.name() << " number " << copy; #endif positionSensitive(glog, rinB, routF, cpv); } @@ -200,9 +205,10 @@ void DDHGCalModule::constructLayers(const DDLogicalPart& module, cpv.position(glog, module, copy, r1, rot); ++copyNumber[ii]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule test: " << glog.name() << " number " << copy - << " positioned in " << module.name() << " at " << r1 - << " with " << rot << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << glog.name() + << " number " << copy << " positioned in " + << module.name() << " at " << r1 + << " with " << rot; #endif zz += (0.5 * thick[ii]); } // End of loop over layers in a block @@ -235,7 +241,7 @@ double DDHGCalModule::rMax(double z) { #endif } #ifdef EDM_ML_DEBUG - std::cout << "rMax : " << z << ":" << ik << ":" << r << std::endl; + edm::LogVerbatim("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r; #endif return r; } @@ -243,14 +249,14 @@ double DDHGCalModule::rMax(double z) { void DDHGCalModule::positionSensitive(DDLogicalPart& glog, double rin, double rout, DDCompactView& cpv) { double dx = 0.5 * waferW; - double dy = 3.0 * dx * tan(30.0 * CLHEP::deg); - double rr = 2.0 * dx * tan(30.0 * CLHEP::deg); + double dy = 3.0 * dx * tan(30._deg); + double rr = 2.0 * dx * tan(30._deg); int ncol = (int)(2.0 * rout / waferW) + 1; - int nrow = (int)(rout / (waferW * tan(30.0 * CLHEP::deg))) + 1; + int nrow = (int)(rout / (waferW * tan(30._deg))) + 1; int incm(0), inrm(0), kount(0), ntot(0), nin(0), nfine(0), ncoarse(0); #ifdef EDM_ML_DEBUG - std::cout << glog.ddname() << " rout " << rout << " Row " << nrow - << " Column " << ncol << std::endl; + edm::LogVerbatim("HGCalGeom") << glog.ddname() << " rout " << rout << " Row " + << nrow << " Column " << ncol; #endif for (int nr = -nrow; nr <= nrow; ++nr) { int inr = (nr >= 0) ? nr : -nr; @@ -285,9 +291,11 @@ void DDHGCalModule::positionSensitive(DDLogicalPart& glog, double rin, else ++ncoarse; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << name + << " number " << copy + << " positioned in " << glog.ddname() + << " at " << tran << " with " + << rotation; #endif } } @@ -295,9 +303,10 @@ void DDHGCalModule::positionSensitive(DDLogicalPart& glog, double rin, } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModule: # of columns " << incm << " # of rows " << inrm - << " and " << nin << ":" << kount << ":" << ntot << " wafers (" - << nfine << ":" << ncoarse << ") for " << glog.ddname() << " R " - << rin << ":" << rout << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: # of columns " << incm + << " # of rows " << inrm << " and " << nin << ":" + << kount << ":" << ntot << " wafers (" + << nfine << ":" << ncoarse << ") for " + << glog.ddname() << " R " << rin << ":" << rout; #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc index 604d8c8a9782d..3d87d65a1065d 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc @@ -6,8 +6,7 @@ #include #include -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" @@ -20,10 +19,11 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalModuleAlgo::DDHGCalModuleAlgo() { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo info: Creating an instance" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: Creating an instance"; #endif } @@ -36,9 +36,10 @@ void DDHGCalModuleAlgo::initialize(const DDNumericArguments& nArgs, const DDStringVectorArguments& vsArgs) { wafer = vsArgs["WaferName"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << wafer.size() << " wafers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << wafer.size() + << " wafers"; for (unsigned int i = 0; i < wafer.size(); ++i) - std::cout << "Wafer[" << i << "] " << wafer[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer[i]; #endif materials = vsArgs["MaterialNames"]; names = vsArgs["VolumeNames"]; @@ -47,29 +48,33 @@ void DDHGCalModuleAlgo::initialize(const DDNumericArguments& nArgs, copyNumber.emplace_back(1); } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << materials.size() << " types of volumes" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << materials.size() + << " types of volumes"; for (unsigned int i = 0; i < names.size(); ++i) - std::cout << "Volume [" << i << "] " << names[i] << " of thickness " - << thick[i] << " filled with " << materials[i] - << " first copy number " << copyNumber[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names[i] + << " of thickness " << thick[i] + << " filled with " << materials[i] + << " first copy number " << copyNumber[i]; #endif layers = dbl_to_int(vArgs["Layers"]); layerThick = vArgs["LayerThick"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << layers.size() << " blocks" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << layers.size() + << " blocks"; for (unsigned int i = 0; i < layers.size(); ++i) - std::cout << "Block [" << i << "] of thickness " << layerThick[i] - << " with " << layers[i] << " layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " + << layerThick[i] << " with " << layers[i] + << " layers"; #endif layerType = dbl_to_int(vArgs["LayerType"]); layerSense = dbl_to_int(vArgs["LayerSense"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << layerType.size() << " layers" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << layerType.size() + << " layers"; for (unsigned int i = 0; i < layerType.size(); ++i) - std::cout << "Layer [" << i << "] with material type " << layerType[i] - << " sensitive class " << layerSense[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " + << layerType[i] << " sensitive class " + << layerSense[i]; #endif zMinBlock = nArgs["zMinBlock"]; rMaxFine = nArgs["rMaxFine"]; @@ -77,25 +82,27 @@ void DDHGCalModuleAlgo::initialize(const DDNumericArguments& nArgs, waferGap = nArgs["waferGap"]; sectors = (int)(nArgs["Sectors"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: zStart " << zMinBlock << " rFineCoarse " - << rMaxFine << " wafer width " << waferW << " gap among wafers " - << waferGap << " sectors " << sectors << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: zStart " << zMinBlock + << " rFineCoarse " << rMaxFine << " wafer width " + << waferW << " gap among wafers " << waferGap + << " sectors " << sectors; #endif slopeB = vArgs["SlopeBottom"]; slopeT = vArgs["SlopeTop"]; zFront = vArgs["ZFront"]; rMaxFront = vArgs["RMaxFront"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: Bottom slopes " << slopeB[0] << ":" - << slopeB[1] << " and " << slopeT.size() << " slopes for top" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: Bottom slopes " + << slopeB[0] << ":" << slopeB[1] << " and " + << slopeT.size() << " slopes for top"; for (unsigned int i = 0; i < slopeT.size(); ++i) - std::cout << "Block [" << i << "] Zmin " << zFront[i] << " Rmax " - << rMaxFront[i] << " Slope " << slopeT[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFront[i] + << " Rmax " << rMaxFront[i] << " Slope " + << slopeT[i]; #endif idNameSpace = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: NameSpace " << idNameSpace << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: NameSpace " << idNameSpace; #endif } @@ -105,23 +112,23 @@ void DDHGCalModuleAlgo::initialize(const DDNumericArguments& nArgs, void DDHGCalModuleAlgo::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "==>> Constructing DDHGCalModuleAlgo..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalModuleAlgo..."; #endif copies.clear(); constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - std::cout << copies.size() << " different wafer copy numbers" << std::endl; + edm::LogVerbatim("HGCalGeom") << copies.size()<<" different wafer copy numbers"; #endif copies.clear(); #ifdef EDM_ML_DEBUG - std::cout << "<<== End of DDHGCalModuleAlgo construction ..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalModuleAlgo construction"; #endif } void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: \t\tInside Layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo test: \t\tInside Layers"; #endif double zi(zMinBlock); int laymin(0); @@ -141,17 +148,17 @@ void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, std::string name = "HGCal" + names[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: Layer " << ly << ":" << ii - << " Front " << zi << ", " << routF << " Back " << zo << ", " - << rinB << " superlayer thickness " << layerThick[i] - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo test: Layer " << ly + << ":" << ii << " Front " << zi << ", " + << routF << " Back " << zo << ", " << rinB + << " superlayer thickness " << layerThick[i]; #endif DDName matName(DDSplit(materials[ii]).first, DDSplit(materials[ii]).second); DDMaterial matter(matName); DDLogicalPart glog; if (layerSense[ly] == 0) { - double alpha = CLHEP::pi / sectors; + double alpha = geant_units::piRadians / sectors; double rmax = routF * cos(alpha) - tol; std::vector pgonZ, pgonRin, pgonRout; pgonZ.emplace_back(-0.5 * thick[ii]); @@ -161,29 +168,32 @@ void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, pgonRout.emplace_back(rmax); pgonRout.emplace_back(rmax); DDSolid solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), - sectors, -alpha, CLHEP::twopi, + sectors, -alpha, + 2*geant_units::piRadians, pgonZ, pgonRin, pgonRout); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: " << solid.name() - << " polyhedra of " << sectors << " sectors covering " - << -alpha / CLHEP::deg << ":" - << (-alpha + CLHEP::twopi) / CLHEP::deg << " with " - << pgonZ.size() << " sections" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << solid.name() + << " polyhedra of " << sectors + << " sectors covering " + << convertRadToDeg(-alpha) << ":" + << (360.0+convertRadToDeg(-alpha)) + << " with " << pgonZ.size() << " sections"; for (unsigned int k = 0; k < pgonZ.size(); ++k) - std::cout << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] - << ":" << pgonRout[k] << std::endl; + edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " + << pgonRin[k] << ":" << pgonRout[k]; #endif } else { DDSolid solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * thick[ii], - rinB, routF, 0.0, CLHEP::twopi); + rinB, routF, 0.0, 2*geant_units::piRadians); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: " << solid.name() - << " Tubs made of " << matName << " of dimensions " << rinB - << ", " << routF << ", " << 0.5 * thick[ii] << ", 0.0, " - << CLHEP::twopi / CLHEP::deg << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << solid.name() + << " Tubs made of " << matName + << " of dimensions " << rinB << ", " + << routF << ", " << 0.5 * thick[ii] + << ", 0.0, 360.0"; #endif positionSensitive(glog, rinB, routF, cpv); } @@ -192,7 +202,7 @@ void DDHGCalModuleAlgo::constructLayers(const DDLogicalPart& module, cpv.position(glog, module, copy, r1, rot); ++copyNumber[ii]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo test: " << glog.name() << " number " + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo test: " << glog.name() << " number " << copy << " positioned in " << module.name() << " at " << r1 << " with " << rot << std::endl; #endif @@ -227,7 +237,7 @@ double DDHGCalModuleAlgo::rMax(double z) { #endif } #ifdef EDM_ML_DEBUG - std::cout << "rMax : " << z << ":" << ik << ":" << r << std::endl; + edm::LogVerbatim("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r << std::endl; #endif return r; } @@ -236,14 +246,14 @@ void DDHGCalModuleAlgo::positionSensitive(DDLogicalPart& glog, double rin, double rout, DDCompactView& cpv) { double ww = (waferW + waferGap); double dx = 0.5 * ww; - double dy = 3.0 * dx * tan(30.0 * CLHEP::deg); - double rr = 2.0 * dx * tan(30.0 * CLHEP::deg); + double dy = 3.0 * dx * tan(30._deg); + double rr = 2.0 * dx * tan(30._deg); int ncol = (int)(2.0 * rout / ww) + 1; - int nrow = (int)(rout / (ww * tan(30.0 * CLHEP::deg))) + 1; + int nrow = (int)(rout / (ww * tan(30._deg))) + 1; int incm(0), inrm(0), kount(0); #ifdef EDM_ML_DEBUG - std::cout << glog.ddname() << " rout " << rout << " Row " << nrow - << " Column " << ncol << std::endl; + edm::LogVerbatim("HGCalGeom") << glog.ddname() << " rout " << rout << " Row " + << nrow << " Column " << ncol; #endif for (int nr = -nrow; nr <= nrow; ++nr) { int inr = (nr >= 0) ? nr : -nr; @@ -271,7 +281,7 @@ void DDHGCalModuleAlgo::positionSensitive(DDLogicalPart& glog, double rin, kount++; if (copies.count(copy) == 0) copies.insert(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: " << name << " number " << copy + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: " << name << " number " << copy << " positioned in " << glog.ddname() << " at " << tran << " with " << rotation << std::endl; #endif @@ -280,8 +290,8 @@ void DDHGCalModuleAlgo::positionSensitive(DDLogicalPart& glog, double rin, } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalModuleAlgo: # of columns " << incm << " # of rows " - << inrm << " and " << kount << " wafers for " << glog.ddname() - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalModuleAlgo: # of columns " << incm + << " # of rows " << inrm << " and " << kount + << " wafers for " << glog.ddname(); #endif } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc index 260c69f602f54..3fb1d3b347f56 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc @@ -1,8 +1,7 @@ #include #include -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" @@ -13,10 +12,11 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalTBModule::DDHGCalTBModule() { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule info: Creating an instance" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule info: Creating an instance"; #endif } @@ -30,16 +30,18 @@ void DDHGCalTBModule::initialize(const DDNumericArguments& nArgs, wafer_ = vsArgs["WaferName"]; covers_ = vsArgs["CoverName"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << wafer_.size() << " wafers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << wafer_.size() + << " wafers"; unsigned int i(0); for (auto wafer : wafer_) { - std::cout << "Wafer[" << i << "] " << wafer << std::endl; + edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer; ++i; } - std::cout << "DDHGCalTBModule: " << covers_.size() << " covers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << covers_.size() + << " covers"; i = 0; for (auto cover : covers_) { - std::cout << "Cover[" << i << "] " << cover << std::endl; + edm::LogVerbatim("HGCalGeom") << "Cover[" << i << "] " << cover; ++i; } #endif @@ -50,29 +52,33 @@ void DDHGCalTBModule::initialize(const DDNumericArguments& nArgs, copyNumber_.emplace_back(1); } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << materials_.size() << " types of volumes" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << materials_.size() + << " types of volumes"; for (unsigned int i = 0; i < names_.size(); ++i) - std::cout << "Volume [" << i << "] " << names_[i] << " of thickness " - << thick_[i] << " filled with " << materials_[i] - << " first copy number " << copyNumber_[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] + << " of thickness " << thick_[i] + << " filled with " << materials_[i] + << " first copy number " << copyNumber_[i]; #endif layers_ = dbl_to_int(vArgs["Layers"]); layerThick_ = vArgs["LayerThick"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << layers_.size() << " blocks" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << layers_.size() + << " blocks"; for (unsigned int i = 0; i < layers_.size(); ++i) - std::cout << "Block [" << i << "] of thickness " << layerThick_[i] - << " with " << layers_[i] << " layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " + << layerThick_[i] << " with " << layers_[i] + << " layers"; #endif layerType_ = dbl_to_int(vArgs["LayerType"]); layerSense_ = dbl_to_int(vArgs["LayerSense"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << layerType_.size() << " layers" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << layerType_.size() + << " layers"; for (unsigned int i = 0; i < layerType_.size(); ++i) - std::cout << "Layer [" << i << "] with material type " << layerType_[i] - << " sensitive class " << layerSense_[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " + << layerType_[i] << " sensitive class " + << layerSense_[i]; #endif zMinBlock_ = nArgs["zMinBlock"]; rMaxFine_ = nArgs["rMaxFine"]; @@ -82,27 +88,29 @@ void DDHGCalTBModule::initialize(const DDNumericArguments& nArgs, absorbH_ = nArgs["absorberH"]; sectors_ = (int)(nArgs["Sectors"]); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: zStart " << zMinBlock_ << " rFineCoarse " - << rMaxFine_ << " wafer width " << waferW_ << " gap among wafers " - << waferGap_ << " absorber width " << absorbW_ - << " absorber height " << absorbH_ << " sectors " << sectors_ - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: zStart " << zMinBlock_ + << " rFineCoarse " << rMaxFine_ << " wafer width " + << waferW_ << " gap among wafers " + << waferGap_ << " absorber width " << absorbW_ + << " absorber height " << absorbH_ << " sectors " + << sectors_; #endif slopeB_ = vArgs["SlopeBottom"]; slopeT_ = vArgs["SlopeTop"]; zFront_ = vArgs["ZFront"]; rMaxFront_ = vArgs["RMaxFront"]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: Bottom slopes " << slopeB_[0] << ":" - << slopeB_[1] << " and " << slopeT_.size() << " slopes for top" - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: Bottom slopes " << slopeB_[0] + << ":" << slopeB_[1] << " and " << slopeT_.size() + << " slopes for top"; for (unsigned int i = 0; i < slopeT_.size(); ++i) - std::cout << "Block [" << i << "] Zmin " << zFront_[i] << " Rmax " - << rMaxFront_[i] << " Slope " << slopeT_[i] << std::endl; + edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFront_[i] + << " Rmax " << rMaxFront_[i] << " Slope " + << slopeT_[i]; #endif idNameSpace_ = DDCurrentNamespace::ns(); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: NameSpace " << idNameSpace_ << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: NameSpace " << idNameSpace_; #endif } @@ -112,23 +120,23 @@ void DDHGCalTBModule::initialize(const DDNumericArguments& nArgs, void DDHGCalTBModule::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "==>> Constructing DDHGCalTBModule..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalTBModule..."; #endif copies_.clear(); constructLayers(parent(), cpv); #ifdef EDM_ML_DEBUG - std::cout << copies_.size() << " different wafer copy numbers" << std::endl; + edm::LogVerbatim("HGCalGeom") << copies_.size() << " different wafer copy numbers"; #endif copies_.clear(); #ifdef EDM_ML_DEBUG - std::cout << "<<== End of DDHGCalTBModule construction ..." << std::endl; + edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalTBModule construction ..."; #endif } void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule test: \t\tInside Layers" << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule test: \t\tInside Layers"; #endif double zi(zMinBlock_); int laymin(0); @@ -148,10 +156,10 @@ void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, std::string name = "HGCal" + names_[ii] + std::to_string(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule test: Layer " << ly << ":" << ii - << " Front " << zi << ", " << routF << " Back " << zo << ", " - << rinB << " superlayer thickness " << layerThick_[i] - << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: Layer " << ly << ":" + << ii << " Front " << zi << ", " << routF + << " Back " << zo << ", " << rinB + << " superlayer thickness " << layerThick_[i]; #endif DDName matName(DDSplit(materials_[ii]).first, DDSplit(materials_[ii]).second); @@ -162,20 +170,21 @@ void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, DDName(name, idNameSpace_), absorbW_, absorbH_, 0.5 * thick_[ii]); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule test: " << solid.name() - << " box of dimension " << absorbW_ << ":" << absorbH_ << ":" - << 0.5 * thick_[ii] << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule test: " << solid.name() + << " box of dimension " << absorbW_ << ":" + << absorbH_ << ":" << 0.5 * thick_[ii]; #endif } else { DDSolid solid = DDSolidFactory::tubs(DDName(name, idNameSpace_), 0.5 * thick_[ii], - rinB, routF, 0.0, CLHEP::twopi); + rinB, routF, 0.0, 2*geant_units::piRadians); glog = DDLogicalPart(solid.ddname(), matter, solid); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule test: " << solid.name() - << " Tubs made of " << matName << " of dimensions " << rinB - << ", " << routF << ", " << 0.5 * thick_[ii] << ", 0.0, " - << CLHEP::twopi / CLHEP::deg << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << solid.name() + << " Tubs made of " << matName + << " of dimensions " << rinB << ", " + << routF << ", " << 0.5 * thick_[ii] + << ", 0.0, 360.0"; #endif positionSensitive(glog, layerSense_[ly], rinB, routF, cpv); } @@ -184,9 +193,10 @@ void DDHGCalTBModule::constructLayers(const DDLogicalPart& module, cpv.position(glog, module, copy, r1, rot); ++copyNumber_[ii]; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule test: " << glog.name() << " number " << copy - << " positioned in " << module.name() << " at " << r1 - << " with " << rot << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule test: " << glog.name() + << " number " << copy << " positioned in " + << module.name() << " at " << r1 + << " with " << rot; #endif zz += (0.5 * thick_[ii]); } // End of loop over layers in a block @@ -219,7 +229,7 @@ double DDHGCalTBModule::rMax(double z) { #endif } #ifdef EDM_ML_DEBUG - std::cout << "rMax : " << z << ":" << ik << ":" << r << std::endl; + edm::LogVerbatim("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r; #endif return r; } @@ -229,15 +239,15 @@ void DDHGCalTBModule::positionSensitive(DDLogicalPart& glog, int type, DDCompactView& cpv) { double ww = (waferW_ + waferGap_); double dx = 0.5 * ww; - double dy = 3.0 * dx * tan(30.0 * CLHEP::deg); - double rr = 2.0 * dx * tan(30.0 * CLHEP::deg); + double dy = 3.0 * dx * tan(30._deg); + double rr = 2.0 * dx * tan(30._deg); int ncol = (int)(2.0 * rout / ww) + 1; - int nrow = (int)(rout / (ww * tan(30.0 * CLHEP::deg))) + 1; + int nrow = (int)(rout / (ww * tan(30._deg))) + 1; int incm(0), inrm(0), kount(0); double xc[6], yc[6]; #ifdef EDM_ML_DEBUG - std::cout << glog.ddname() << " rout " << rout << " Row " << nrow - << " Column " << ncol << std::endl; + edm::LogVerbatim("HGCalGeom") << glog.ddname() << " rout " << rout << " Row " + << nrow << " Column " << ncol; #endif for (int nr = -nrow; nr <= nrow; ++nr) { int inr = (nr >= 0) ? nr : -nr; @@ -286,16 +296,18 @@ void DDHGCalTBModule::positionSensitive(DDLogicalPart& glog, int type, kount++; if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: " << name << " number " << copy - << " positioned in " << glog.ddname() << " at " << tran - << " with " << rotation << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: " << name + << " number " << copy << " positioned in " + << glog.ddname() << " at " << tran + << " with " << rotation; #endif } } } } #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalTBModule: # of columns " << incm << " # of rows " << inrm - << " and " << kount << " wafers for " << glog.ddname() << std::endl; + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModule: # of columns " << incm + << " # of rows " << inrm << " and " << kount + << " wafers for " << glog.ddname(); #endif } diff --git a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc index ca07354420245..5814aeb8e62e8 100644 --- a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc @@ -1,45 +1,44 @@ #include "Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" - //#define EDM_ML_DEBUG +using namespace geant_units::operators; FastTimeDDDConstants::FastTimeDDDConstants(const FastTimeParameters* ft) : ftpar_(ft) { #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants::FastTimeDDDConstants ( const " - "FastTimeParameters* ft ) constructor\n"; + edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants " + << "( const FastTimeParameters* ft ) constructor"; #endif initialize(); } FastTimeDDDConstants::~FastTimeDDDConstants() { #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants:destructed!!!" << std::endl; + edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:destructed!!!"; #endif } std::pair FastTimeDDDConstants::getZPhi(double z, double phi) const { - if (phi < 0) phi += CLHEP::twopi; + if (phi < 0) phi += (2*geant_units::piRadians); int iz = (int)(z / dZBarrel_) + 1; if (iz > ftpar_->nZBarrel_) iz = ftpar_->nZBarrel_; int iphi = (int)(phi / dPhiBarrel_) + 1; if (iphi > ftpar_->nPhiBarrel_) iphi = 1; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants:Barrel z|phi " << z << " " - << phi / CLHEP::deg << " iz|iphi " << iz << " " << iphi - << std::endl; + edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:Barrel z|phi " << z + << " " << convertRadToDeg(phi) << " iz|iphi " + << iz << " " << iphi; #endif return std::pair(iz, iphi); } std::pair FastTimeDDDConstants::getEtaPhi(double r, double phi) const { - if (phi < 0) phi += CLHEP::twopi; + if (phi < 0) phi += (2*geant_units::piRadians); int ir(ftpar_->nEtaEndcap_); for (unsigned int k = 1; k < rLimits_.size(); ++k) { if (r > rLimits_[k]) { @@ -50,9 +49,9 @@ std::pair FastTimeDDDConstants::getEtaPhi(double r, int iphi = (int)(phi / dPhiEndcap_) + 1; if (iphi > ftpar_->nPhiEndcap_) iphi = 1; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants:Endcap r|phi " << r << " " - << phi / CLHEP::deg << " ir|iphi " << ir << " " << iphi - << std::endl; + edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:Endcap r|phi " << r + << " " << convertRadToDeg(phi) << " ir|iphi " + << ir << " " << iphi; #endif return std::pair(ir, iphi); } @@ -206,9 +205,9 @@ void FastTimeDDDConstants::initialize() { etaMin_ = -log(0.5 * thmax); dEta_ = (etaMax_ - etaMin_) / ftpar_->nEtaEndcap_; #ifdef EDM_ML_DEBUG - std::cout << "Theta range " << thmin / CLHEP::deg << ":" << thmax / CLHEP::deg - << " Eta range " << etaMin_ << ":" << etaMax_ << ":" << dEta_ - << std::endl; + edm::LogVerbatim("HGCalGeom") << "Theta range " << convertRadToDeg(thmin) + << ":" << convertRadToDeg(thmax) << " Eta range " + << etaMin_ << ":" << etaMax_ << ":" << dEta_; #endif for (int k = 0; k <= ftpar_->nEtaEndcap_; ++k) { double eta = etaMin_ + k * dEta_; @@ -217,20 +216,20 @@ void FastTimeDDDConstants::initialize() { rLimits_.emplace_back(rval); } dZBarrel_ = ftpar_->geomParBarrel_[1] / ftpar_->nZBarrel_; - dPhiBarrel_ = CLHEP::twopi / ftpar_->nPhiBarrel_; - dPhiEndcap_ = CLHEP::twopi / ftpar_->nPhiEndcap_; + dPhiBarrel_ = (2*geant_units::piRadians) / ftpar_->nPhiBarrel_; + dPhiEndcap_ = (2*geant_units::piRadians) / ftpar_->nPhiEndcap_; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeDDDConstants initialized with " << ftpar_->nZBarrel_ - << ":" << ftpar_->nPhiBarrel_ << ":" << getCells(1) - << " cells for barrel; dz|dphi " << dZBarrel_ << "|" << dPhiBarrel_ - << " and " << ftpar_->nEtaEndcap_ << ":" << ftpar_->nPhiEndcap_ - << ":" << getCells(2) << " cells for endcap; dphi " << dPhiEndcap_ - << " The Limits in R are" << std::endl; - for (unsigned int k = 0; k < rLimits_.size(); ++k) { - std::cout << "[" << k << "] " << rLimits_[k] << " "; - if (k % 8 == 7) std::cout << std::endl; - } - if ((rLimits_.size() - 1) % 8 != 7) std::cout << std::endl; + edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants initialized with " + << ftpar_->nZBarrel_ << ":" << ftpar_->nPhiBarrel_ + << ":" << getCells(1) + << " cells for barrel; dz|dphi " << dZBarrel_ + << "|" << dPhiBarrel_ << " and " + << ftpar_->nEtaEndcap_ << ":" + << ftpar_->nPhiEndcap_ << ":" << getCells(2) + << " cells for endcap; dphi " << dPhiEndcap_ + << " The Limits in R are"; + for (unsigned int k = 0; k < rLimits_.size(); ++k) + edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << rLimits_[k] << " "; #endif } From 3aececc288009ab2e18437cf43de9e4b68f619ed Mon Sep 17 00:00:00 2001 From: tocheng Date: Mon, 15 Apr 2019 04:07:30 +0200 Subject: [PATCH 640/686] Update LHC optical function --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index eca796b48b005..cab253b1b16c0 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v7', + 'run1_data' : '106X_dataRun2_v8', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v7', + 'run2_data' : '106X_dataRun2_v8', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v5', + 'run2_data_relval' : '106X_dataRun2_relval_v6', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v3', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v4', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v3', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v3', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v4', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v4', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT From 9a83c09236c8672c6c9e78ebc09072ede419b214 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Mon, 15 Apr 2019 10:01:49 +0200 Subject: [PATCH 641/686] Apply code-format L1THGCal --- .../L1THGCal/interface/ClusterShapes.h | 121 +- .../L1THGCal/interface/HGCFETriggerDigi.h | 67 +- .../L1THGCal/interface/HGCFETriggerDigiDefs.h | 2 +- DataFormats/L1THGCal/interface/HGCalCluster.h | 39 +- .../L1THGCal/interface/HGCalClusterT.h | 437 ++-- .../L1THGCal/interface/HGCalMulticluster.h | 65 +- DataFormats/L1THGCal/interface/HGCalTower.h | 36 +- DataFormats/L1THGCal/interface/HGCalTowerID.h | 26 +- .../L1THGCal/interface/HGCalTowerMap.h | 11 +- .../L1THGCal/interface/HGCalTriggerCell.h | 72 +- .../L1THGCal/interface/HGCalTriggerSums.h | 53 +- DataFormats/L1THGCal/src/ClusterShapes.cc | 211 +- DataFormats/L1THGCal/src/HGCFETriggerDigi.cc | 4 +- DataFormats/L1THGCal/src/HGCalCluster.cc | 25 +- DataFormats/L1THGCal/src/HGCalMulticluster.cc | 27 +- DataFormats/L1THGCal/src/HGCalTower.cc | 41 +- DataFormats/L1THGCal/src/HGCalTowerMap.cc | 25 +- DataFormats/L1THGCal/src/HGCalTriggerCell.cc | 26 +- DataFormats/L1THGCal/src/HGCalTriggerSums.cc | 18 +- DataFormats/L1THGCal/src/classes.h | 34 +- .../L1THGCal/interface/HGCalProcessorBase.h | 27 +- .../L1THGCal/interface/HGCalProcessorBaseT.h | 34 +- .../HGCalTriggerBackendAlgorithmBase.h | 45 +- .../interface/HGCalTriggerBackendProcessor.h | 11 +- .../interface/HGCalTriggerFECodecBase.h | 121 +- .../interface/HGCalTriggerGeometryBase.h | 178 +- .../HGCalTriggerGeometryGenericMapping.h | 111 +- .../L1THGCal/interface/HGCalTriggerTools.h | 122 +- .../HGCalTriggerTowerGeometryHelper.h | 47 +- .../backend/HGCalClusteringDummyImpl.h | 32 +- .../interface/backend/HGCalClusteringImpl.h | 114 +- .../backend/HGCalHistoClusteringImpl.h | 80 +- .../interface/backend/HGCalHistoSeedingImpl.h | 68 +- .../backend/HGCalMulticlusteringImpl.h | 70 +- .../interface/backend/HGCalShowerShape.h | 137 +- .../interface/backend/HGCalTowerMap2DImpl.h | 24 +- .../interface/backend/HGCalTowerMap3DImpl.h | 16 +- .../HGCalTriggerClusterIdentificationBase.h | 23 +- .../HGCalConcentratorProcessorSelection.h | 39 +- .../HGCalConcentratorSelectionImpl.h | 77 +- .../HGCalConcentratorSuperTriggerCellImpl.h | 96 +- .../HGCalTriggerCellCalibration.h | 30 +- .../veryfrontend/HGCalVFECompressionImpl.h | 21 +- .../veryfrontend/HGCalVFELinearizationImpl.h | 43 +- .../veryfrontend/HGCalVFEProcessorSums.h | 33 +- .../veryfrontend/HGCalVFESummationImpl.h | 22 +- .../plugins/HGCalBackendLayer1Producer.cc | 31 +- .../plugins/HGCalBackendLayer2Producer.cc | 36 +- .../plugins/HGCalConcentratorProducer.cc | 38 +- .../L1THGCal/plugins/HGCalTowerMapProducer.cc | 38 +- .../L1THGCal/plugins/HGCalTowerProducer.cc | 40 +- .../plugins/HGCalTriggerDigiFEReproducer.cc | 130 +- .../plugins/HGCalTriggerGeometryESProducer.cc | 94 +- .../L1THGCal/plugins/HGCalVFEProducer.cc | 58 +- ...HGCalBackendLayer1Processor2DClustering.cc | 144 +- ...HGCalBackendLayer2Processor3DClustering.cc | 138 +- .../plugins/backend/HGCalTowerMapProcessor.cc | 64 +- .../plugins/backend/HGCalTowerProcessor.cc | 58 +- .../HGCalTriggerClusterIdentificationBDT.cc | 303 ++- .../HGCalConcentratorProcessorSelection.cc | 45 +- .../geometries/HGCalTriggerGeometryHexImp1.cc | 453 ++-- .../geometries/HGCalTriggerGeometryHexImp2.cc | 1483 ++++++------ .../HGCalTriggerGeometryHexLayerBasedImp1.cc | 1406 ++++++------ .../geometries/HGCalTriggerGeometryImp1.cc | 250 +-- .../geometries/HGCalTriggerGeometryV9Imp1.cc | 1911 ++++++++-------- .../geometries/HGCalTriggerGeometryV9Imp2.cc | 1024 ++++----- .../plugins/geometries/NullGeometry.cc | 14 +- .../plugins/geometries/TrivialGeometry.cc | 30 +- .../veryfrontend/HGCalVFEProcessorSums.cc | 65 +- L1Trigger/L1THGCal/src/HGCalProcessorBase.cc | 24 +- .../src/HGCalTriggerBackendAlgorithmBase.cc | 3 +- .../src/HGCalTriggerBackendProcessor.cc | 34 +- .../L1THGCal/src/HGCalTriggerFECodecBase.cc | 3 +- .../L1THGCal/src/HGCalTriggerGeometryBase.cc | 16 +- .../src/HGCalTriggerGeometryGenericMapping.cc | 107 +- L1Trigger/L1THGCal/src/HGCalTriggerTools.cc | 203 +- .../src/HGCalTriggerTowerGeometryHelper.cc | 99 +- .../src/backend/HGCalClusteringDummyImpl.cc | 70 +- .../src/backend/HGCalClusteringImpl.cc | 741 +++--- .../src/backend/HGCalHistoClusteringImpl.cc | 246 +- .../src/backend/HGCalHistoSeedingImpl.cc | 748 +++--- .../src/backend/HGCalMulticlusteringImpl.cc | 347 ++- .../L1THGCal/src/backend/HGCalShowerShape.cc | 449 ++-- .../src/backend/HGCalTowerMap2DImpl.cc | 45 +- .../src/backend/HGCalTowerMap3DImpl.cc | 27 +- .../HGCalTriggerClusterIdentificationBase.cc | 5 +- .../HGCalConcentratorSelectionImpl.cc | 74 +- .../HGCalConcentratorSuperTriggerCellImpl.cc | 144 +- .../HGCalTriggerCellCalibration.cc | 149 +- .../veryfrontend/HGCalVFECompressionImpl.cc | 56 +- .../veryfrontend/HGCalVFELinearizationImpl.cc | 74 +- .../src/veryfrontend/HGCalVFESummationImpl.cc | 31 +- .../test/HGCalTriggerBestChoiceTester.cc | 921 ++++---- ...HGCalTriggerBestChoiceTriggerCellTester.cc | 969 ++++---- .../L1THGCal/test/HGCalTriggerGeomTester.cc | 1798 ++++++++------- .../L1THGCal/test/HGCalTriggerGeomTesterV9.cc | 1824 ++++++++------- .../test/HGCalTriggerGeomTesterV9Imp2.cc | 1995 ++++++++--------- .../HGCalTriggerThresholdTriggerCellTester.cc | 919 ++++---- .../L1THGCal/test/calib/testCalibration.cc | 176 +- .../interface/HGCalTriggerNtupleBase.h | 23 +- .../ntuples/HGCalTriggerNtupleEvent.cc | 69 +- .../plugins/ntuples/HGCalTriggerNtupleGen.cc | 756 +++---- .../ntuples/HGCalTriggerNtupleGenJet.cc | 121 +- .../ntuples/HGCalTriggerNtupleGenTau.cc | 599 +++-- .../ntuples/HGCalTriggerNtupleHGCClusters.cc | 125 +- .../ntuples/HGCalTriggerNtupleHGCDigis.cc | 691 +++--- .../HGCalTriggerNtupleHGCMulticlusters.cc | 137 +- .../ntuples/HGCalTriggerNtupleHGCPanels.cc | 152 +- .../HGCalTriggerNtupleHGCTriggerCells.cc | 277 ++- .../ntuples/HGCalTriggerNtupleManager.cc | 66 +- .../ntuples/HGCalTriggerNtupleTowers.cc | 83 +- .../selectors/HGC3DClusterSimpleSelector.cc | 50 +- .../selectors/HGC3DClusterTMVASelector.cc | 121 +- .../src/HGCalTriggerNtupleBase.cc | 5 +- 114 files changed, 12290 insertions(+), 14096 deletions(-) diff --git a/DataFormats/L1THGCal/interface/ClusterShapes.h b/DataFormats/L1THGCal/interface/ClusterShapes.h index 270a6e61e6b3b..cfd4c15585b95 100644 --- a/DataFormats/L1THGCal/interface/ClusterShapes.h +++ b/DataFormats/L1THGCal/interface/ClusterShapes.h @@ -2,76 +2,73 @@ #define DataFormats_L1HGCal_ClusterShapes_H #include -namespace l1t{ - // this class is design to contain and compute - // efficiently the cluster shapes - // running only once on the cluster members. - class ClusterShapes{ - private: - float sum_e_ = 0.0; - float sum_e2_ = 0.0; - float sum_logE_ = 0.0; - int n_=0.0; +namespace l1t { + // this class is design to contain and compute + // efficiently the cluster shapes + // running only once on the cluster members. + class ClusterShapes { + private: + float sum_e_ = 0.0; + float sum_e2_ = 0.0; + float sum_logE_ = 0.0; + int n_ = 0.0; - float emax_ = 0.0; + float emax_ = 0.0; - float sum_w_ =0.0; // just here for clarity - float sum_eta_ = 0.0; - float sum_r_ = 0.0; - // i will discriminate using the rms in -pi,pi or in 0,pi - float sum_phi_0_ = 0.0; // computed in -pi,pi - float sum_phi_1_ = 0.0; // computed in 0, 2pi + float sum_w_ = 0.0; // just here for clarity + float sum_eta_ = 0.0; + float sum_r_ = 0.0; + // i will discriminate using the rms in -pi,pi or in 0,pi + float sum_phi_0_ = 0.0; // computed in -pi,pi + float sum_phi_1_ = 0.0; // computed in 0, 2pi - float sum_eta2_=0.0; - float sum_r2_ = 0.0; - float sum_phi2_0_=0.0; //computed in -pi,pi - float sum_phi2_1_=0.0; //computed in 0,2pi + float sum_eta2_ = 0.0; + float sum_r2_ = 0.0; + float sum_phi2_0_ = 0.0; //computed in -pi,pi + float sum_phi2_1_ = 0.0; //computed in 0,2pi - // off diagonal element of the tensor - float sum_eta_r_ =0.0; - float sum_r_phi_0_ = 0.0; - float sum_r_phi_1_ = 0.0; - float sum_eta_phi_0_ = 0.0; - float sum_eta_phi_1_ = 0.0; + // off diagonal element of the tensor + float sum_eta_r_ = 0.0; + float sum_r_phi_0_ = 0.0; + float sum_r_phi_1_ = 0.0; + float sum_eta_phi_0_ = 0.0; + float sum_eta_phi_1_ = 0.0; - // caching of informations - mutable bool isPhi0_ = true; - mutable bool modified_ = false; // check wheneever i need + // caching of informations + mutable bool isPhi0_ = true; + mutable bool modified_ = false; // check wheneever i need - public: - ClusterShapes(){} - ClusterShapes(float e, float eta, float phi, float r) { Init(e,eta,phi,r);} - ~ClusterShapes(){} - ClusterShapes(const ClusterShapes&x)= default; - //init an empty cluster - void Init(float e, float eta, float phi, float r=0.); - inline void Add(float e, float eta, float phi, float r=0.0) - { (*this) += ClusterShapes(e,eta,phi,r);} - + public: + ClusterShapes() {} + ClusterShapes(float e, float eta, float phi, float r) { Init(e, eta, phi, r); } + ~ClusterShapes() {} + ClusterShapes(const ClusterShapes &x) = default; + //init an empty cluster + void Init(float e, float eta, float phi, float r = 0.); + inline void Add(float e, float eta, float phi, float r = 0.0) { (*this) += ClusterShapes(e, eta, phi, r); } - // --- - float SigmaEtaEta() const ; - float SigmaPhiPhi() const ; - float SigmaRR() const ; - // ---- - float Phi() const ; - float R() const ; - float Eta() const ; - inline int N()const {return n_;} - // -- - float SigmaEtaR()const ; - float SigmaEtaPhi() const ; - float SigmaRPhi() const ; - // -- - float LogEoverE() const { return sum_logE_/sum_e_;} - float eD() const { return std::sqrt(sum_e2_)/sum_e_;} + // --- + float SigmaEtaEta() const; + float SigmaPhiPhi() const; + float SigmaRR() const; + // ---- + float Phi() const; + float R() const; + float Eta() const; + inline int N() const { return n_; } + // -- + float SigmaEtaR() const; + float SigmaEtaPhi() const; + float SigmaRPhi() const; + // -- + float LogEoverE() const { return sum_logE_ / sum_e_; } + float eD() const { return std::sqrt(sum_e2_) / sum_e_; } - ClusterShapes operator+(const ClusterShapes &); - void operator+=(const ClusterShapes &); - ClusterShapes& operator=(const ClusterShapes &) = default; - }; + ClusterShapes operator+(const ClusterShapes &); + void operator+=(const ClusterShapes &); + ClusterShapes &operator=(const ClusterShapes &) = default; + }; -}; // end namespace +}; // namespace l1t #endif - diff --git a/DataFormats/L1THGCal/interface/HGCFETriggerDigi.h b/DataFormats/L1THGCal/interface/HGCFETriggerDigi.h index d209a5f360ea7..d7de930aea7a6 100644 --- a/DataFormats/L1THGCal/interface/HGCFETriggerDigi.h +++ b/DataFormats/L1THGCal/interface/HGCFETriggerDigi.h @@ -35,73 +35,70 @@ #include "DataFormats/DetId/interface/DetId.h" -namespace l1t { +namespace l1t { constexpr unsigned char hgcal_bad_codec(0xff); class HGCFETriggerDigi { public: - typedef std::vector data_payload; - typedef uint32_t key_type; + typedef uint32_t key_type; - HGCFETriggerDigi() : codec_((unsigned char)0xffff) { - detid_ = 0; - } + HGCFETriggerDigi() : codec_((unsigned char)0xffff) { detid_ = 0; } ~HGCFETriggerDigi() {} - + //detector id information - uint32_t id() const { return detid_; } // for edm::SortedCollection - template - IDTYPE getDetId() const { return IDTYPE(detid_); } - template - void setDetId(const IDTYPE& id) { detid_ = id.rawId(); } + uint32_t id() const { return detid_; } // for edm::SortedCollection + template + IDTYPE getDetId() const { + return IDTYPE(detid_); + } + template + void setDetId(const IDTYPE& id) { + detid_ = id.rawId(); + } // encoding and decoding unsigned char getWhichCodec() const { return codec_; } - - template + + template void encode(const CODEC& codec, const DATA& data) { - if( codec_ != hgcal_bad_codec ) { - throw cms::Exception("HGCTriggerAlreadyEncoded") - << "HGC Codec and data already set with codec: " - << std::hex << codec_ << std::dec; + if (codec_ != hgcal_bad_codec) { + throw cms::Exception("HGCTriggerAlreadyEncoded") + << "HGC Codec and data already set with codec: " << std::hex << codec_ << std::dec; } codec_ = codec.getCodecType(); data_ = codec.encode(data); } - template + template void decode(const CODEC& codec, DATA& data) const { - if( codec_ != codec.getCodecType() ){ + if (codec_ != codec.getCodecType()) { throw cms::Exception("HGCTriggerWrongCodec") - << "Wrong HGC codec: " << std::hex << codec.getCodecType() - << " given to data encoded with HGC codec type: " - << codec_ << std::dec; + << "Wrong HGC codec: " << std::hex << codec.getCodecType() + << " given to data encoded with HGC codec type: " << codec_ << std::dec; } data = codec.decode(data_, detid_); } - + void print(std::ostream& out) const; - template + template void print(const CODEC& codec, std::ostream& out) const; private: - uint32_t detid_; // save in the abstract form - unsigned char codec_; // 0xff is special and means no encoder - data_payload data_; - }; + uint32_t detid_; // save in the abstract form + unsigned char codec_; // 0xff is special and means no encoder + data_payload data_; + }; - template + template void HGCFETriggerDigi::print(const CODEC& codec, std::ostream& out) const { - if( codec_ != codec.getCodecType() ){ + if (codec_ != codec.getCodecType()) { throw cms::Exception("HGCTriggerWrongCodec") - << "Wrong HGC codec: " << codec.getCodecType() - << " given to data encoded with HGC codec type: " - << codec_; + << "Wrong HGC codec: " << codec.getCodecType() << " given to data encoded with HGC codec type: " << codec_; } out << codec.decode(data_, detid_); out << std::endl << " decoded from: " << std::endl; this->print(out); } -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCFETriggerDigiDefs.h b/DataFormats/L1THGCal/interface/HGCFETriggerDigiDefs.h index c978ebb5386eb..8912abbcbc10d 100644 --- a/DataFormats/L1THGCal/interface/HGCFETriggerDigiDefs.h +++ b/DataFormats/L1THGCal/interface/HGCFETriggerDigiDefs.h @@ -19,6 +19,6 @@ namespace l1t { typedef edm::RefVector HGCFETriggerDigiRefVector; typedef edm::Ptr HGCFETriggerDigiPtr; typedef std::vector HGCFETriggerDigiPtrVector; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalCluster.h b/DataFormats/L1THGCal/interface/HGCalCluster.h index f72cfe9257891..2c132916bf024 100644 --- a/DataFormats/L1THGCal/interface/HGCalCluster.h +++ b/DataFormats/L1THGCal/interface/HGCalCluster.h @@ -6,35 +6,26 @@ #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" #include "DataFormats/L1THGCal/interface/HGCalClusterT.h" - namespace l1t { - + class HGCalCluster : public HGCalClusterT { - - public: - - HGCalCluster(){} - HGCalCluster( const LorentzVector p4, - int pt=0, - int eta=0, - int phi=0 - ); - - HGCalCluster( const edm::Ptr &tc ); - - ~HGCalCluster() override; - - void setModule(uint32_t module) {module_ = module;} - uint32_t module() const {return module_;} - - - private: - uint32_t module_; - + public: + HGCalCluster() {} + HGCalCluster(const LorentzVector p4, int pt = 0, int eta = 0, int phi = 0); + + HGCalCluster(const edm::Ptr &tc); + + ~HGCalCluster() override; + + void setModule(uint32_t module) { module_ = module; } + uint32_t module() const { return module_; } + + private: + uint32_t module_; }; typedef BXVector HGCalClusterBxCollection; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalClusterT.h b/DataFormats/L1THGCal/interface/HGCalClusterT.h index fffdf5d6bfa4e..1399a63c7ad0d 100644 --- a/DataFormats/L1THGCal/interface/HGCalClusterT.h +++ b/DataFormats/L1THGCal/interface/HGCalClusterT.h @@ -16,251 +16,222 @@ #include -namespace l1t -{ - template class HGCalClusterT : public L1Candidate - { - - public: - typedef typename std::unordered_map>::const_iterator const_iterator; - - public: - HGCalClusterT(){} - HGCalClusterT( const LorentzVector p4, - int pt=0, - int eta=0, - int phi=0 - ) +namespace l1t { + template + class HGCalClusterT : public L1Candidate { + public: + typedef typename std::unordered_map>::const_iterator const_iterator; + + public: + HGCalClusterT() {} + HGCalClusterT(const LorentzVector p4, int pt = 0, int eta = 0, int phi = 0) : L1Candidate(p4, pt, eta, phi), - valid_(true), - detId_(0), - centre_(0, 0, 0), - centreProj_(0., 0., 0.), - mipPt_(0), - seedMipPt_(0), - sumPt_(0){} - - - HGCalClusterT( const edm::Ptr& c, float fraction=1. ): - valid_(true), - detId_( c->detId() ), - centre_(0., 0., 0.), - centreProj_(0., 0., 0.), - mipPt_(0.), - seedMipPt_(0.), - sumPt_(0.) - { - addConstituent(c, true, fraction); - } - - ~HGCalClusterT() override {}; - - const std::unordered_map>& constituents() const { return constituents_; } - const_iterator constituents_begin() const { return constituents_.begin(); } - const_iterator constituents_end() const { return constituents_.end(); } - unsigned size() const { return constituents_.size(); } - - - void addConstituent( const edm::Ptr& c, bool updateCentre=true, float fraction=1. ) - { - - double cMipt = c->mipPt()*fraction; - - if( constituents_.empty() ) - { - detId_ = DetId( c->detId() ); - seedMipPt_ = cMipt; - /* if the centre will not be dynamically calculated + valid_(true), + detId_(0), + centre_(0, 0, 0), + centreProj_(0., 0., 0.), + mipPt_(0), + seedMipPt_(0), + sumPt_(0) {} + + HGCalClusterT(const edm::Ptr& c, float fraction = 1.) + : valid_(true), + detId_(c->detId()), + centre_(0., 0., 0.), + centreProj_(0., 0., 0.), + mipPt_(0.), + seedMipPt_(0.), + sumPt_(0.) { + addConstituent(c, true, fraction); + } + + ~HGCalClusterT() override{}; + + const std::unordered_map>& constituents() const { return constituents_; } + const_iterator constituents_begin() const { return constituents_.begin(); } + const_iterator constituents_end() const { return constituents_.end(); } + unsigned size() const { return constituents_.size(); } + + void addConstituent(const edm::Ptr& c, bool updateCentre = true, float fraction = 1.) { + double cMipt = c->mipPt() * fraction; + + if (constituents_.empty()) { + detId_ = DetId(c->detId()); + seedMipPt_ = cMipt; + /* if the centre will not be dynamically calculated the seed centre is considere as cluster centre */ - if( !updateCentre ) - { - centre_ = c->position(); - } + if (!updateCentre) { + centre_ = c->position(); } - updateP4AndPosition(c, updateCentre, fraction); - - - constituents_.emplace( c->detId(), c ); - constituentsFraction_.emplace( c->detId(), fraction ); - } - - void removeConstituent( const edm::Ptr& c, bool updateCentre=true ){ - - /* remove the pointer to c from the std::vector */ - double fraction=0; - const auto& constituent_itr = constituents_.find(c->detId()); - const auto& fraction_itr = constituentsFraction_.find(c->detId()); - if(constituent_itr!=constituents_.end()) - { - // remove constituent and get its fraction in the cluster - fraction = fraction_itr->second; - constituents_.erase(constituent_itr); - constituentsFraction_.erase(fraction_itr); - - updateP4AndPosition(c, updateCentre, -fraction); - } - } - - bool valid() const { return valid_; } - void setValid(bool valid) { valid_ = valid; } - - double mipPt() const { return mipPt_; } - double seedMipPt() const { return seedMipPt_; } - uint32_t detId() const { return detId_.rawId(); } - void setPt(double pt) { - setP4( math::PtEtaPhiMLorentzVector(pt, eta(), phi(), mass() ) ); + updateP4AndPosition(c, updateCentre, fraction); + + constituents_.emplace(c->detId(), c); + constituentsFraction_.emplace(c->detId(), fraction); + } + + void removeConstituent(const edm::Ptr& c, bool updateCentre = true) { + /* remove the pointer to c from the std::vector */ + double fraction = 0; + const auto& constituent_itr = constituents_.find(c->detId()); + const auto& fraction_itr = constituentsFraction_.find(c->detId()); + if (constituent_itr != constituents_.end()) { + // remove constituent and get its fraction in the cluster + fraction = fraction_itr->second; + constituents_.erase(constituent_itr); + constituentsFraction_.erase(fraction_itr); + + updateP4AndPosition(c, updateCentre, -fraction); } - double sumPt() const { return sumPt_; } - /* distance in 'cm' */ - double distance( const l1t::HGCalTriggerCell &tc ) const { return ( tc.position() - centre_ ).mag(); } - - const GlobalPoint& position() const { return centre_; } - const GlobalPoint& centre() const { return centre_; } - const GlobalPoint& centreProj() const { return centreProj_; } - - // FIXME: will need to fix places where the shapes are directly accessed - // Right now keep shapes() getter as non-const - ClusterShapes& shapes() {return shapes_;} - double hOverE() const - { - double pt_em = 0.; - double pt_had = 0.; - double hOe = 0.; - - for(const auto& id_constituent : constituents()) - { - DetId id(id_constituent.first); - auto id_fraction = constituentsFraction_.find(id_constituent.first); - double fraction = (id_fraction!=constituentsFraction_.end() ? id_fraction->second : 1.); - if ((id.det() == DetId::Forward && id.subdetId()==HGCEE) || - (id.det() == DetId::HGCalEE) || - (id.det() == DetId::HGCalTrigger && HGCalTriggerDetId(id).subdet()==HGCalTriggerSubdetector::HGCalEETrigger) - ) { - pt_em += id_constituent.second->pt() * fraction; - } else if((id.det() == DetId::Forward && id.subdetId()==HGCHEF) || - (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) || - (id.det() == DetId::HGCalHSi) || - (id.det() == DetId::HGCalHSc) || - (id.det() == DetId::HGCalTrigger && HGCalTriggerDetId(id).subdet()==HGCalTriggerSubdetector::HGCalHSiTrigger) - ) { - pt_had += id_constituent.second->pt() * fraction; - } + } + + bool valid() const { return valid_; } + void setValid(bool valid) { valid_ = valid; } + + double mipPt() const { return mipPt_; } + double seedMipPt() const { return seedMipPt_; } + uint32_t detId() const { return detId_.rawId(); } + void setPt(double pt) { setP4(math::PtEtaPhiMLorentzVector(pt, eta(), phi(), mass())); } + double sumPt() const { return sumPt_; } + /* distance in 'cm' */ + double distance(const l1t::HGCalTriggerCell& tc) const { return (tc.position() - centre_).mag(); } + + const GlobalPoint& position() const { return centre_; } + const GlobalPoint& centre() const { return centre_; } + const GlobalPoint& centreProj() const { return centreProj_; } + + // FIXME: will need to fix places where the shapes are directly accessed + // Right now keep shapes() getter as non-const + ClusterShapes& shapes() { return shapes_; } + double hOverE() const { + double pt_em = 0.; + double pt_had = 0.; + double hOe = 0.; + + for (const auto& id_constituent : constituents()) { + DetId id(id_constituent.first); + auto id_fraction = constituentsFraction_.find(id_constituent.first); + double fraction = (id_fraction != constituentsFraction_.end() ? id_fraction->second : 1.); + if ((id.det() == DetId::Forward && id.subdetId() == HGCEE) || (id.det() == DetId::HGCalEE) || + (id.det() == DetId::HGCalTrigger && + HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalEETrigger)) { + pt_em += id_constituent.second->pt() * fraction; + } else if ((id.det() == DetId::Forward && id.subdetId() == HGCHEF) || + (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) || (id.det() == DetId::HGCalHSi) || + (id.det() == DetId::HGCalHSc) || + (id.det() == DetId::HGCalTrigger && + HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalHSiTrigger)) { + pt_had += id_constituent.second->pt() * fraction; } - if(pt_em>0) hOe = pt_had / pt_em ; - else hOe = -1.; - return hOe; } - - uint32_t subdetId() const {return detId_.subdetId();} - - - //shower shape - - int showerLength() const { return showerLength_; } - int coreShowerLength() const { return coreShowerLength_; } - int firstLayer() const { return firstLayer_; } - int maxLayer() const { return maxLayer_; } - float eMax() const { return eMax_; } - float sigmaEtaEtaMax() const { return sigmaEtaEtaMax_; } - float sigmaPhiPhiMax() const { return sigmaPhiPhiMax_; } - float sigmaEtaEtaTot() const { return sigmaEtaEtaTot_; } - float sigmaPhiPhiTot() const { return sigmaPhiPhiTot_; } - float sigmaZZ() const { return sigmaZZ_; } - float sigmaRRTot() const { return sigmaRRTot_; } - float sigmaRRMax() const { return sigmaRRMax_; } - float sigmaRRMean() const { return sigmaRRMean_; } - - void showerLength(int showerLength) { showerLength_ = showerLength;} - void coreShowerLength(int coreShowerLength) { coreShowerLength_ = coreShowerLength;} - void firstLayer(int firstLayer) { firstLayer_ = firstLayer;} - void maxLayer(int maxLayer) { maxLayer_ = maxLayer;} - void eMax(float eMax) { eMax_ = eMax;} - void sigmaEtaEtaMax(float sigmaEtaEtaMax) { sigmaEtaEtaMax_ = sigmaEtaEtaMax;} - void sigmaEtaEtaTot(float sigmaEtaEtaTot) { sigmaEtaEtaTot_ = sigmaEtaEtaTot;} - void sigmaPhiPhiMax(float sigmaPhiPhiMax) { sigmaPhiPhiMax_ = sigmaPhiPhiMax;} - void sigmaPhiPhiTot(float sigmaPhiPhiTot) { sigmaPhiPhiTot_ = sigmaPhiPhiTot;} - void sigmaRRMax(float sigmaRRMax) { sigmaRRMax_ = sigmaRRMax;} - void sigmaRRTot(float sigmaRRTot) { sigmaRRTot_ = sigmaRRTot;} - void sigmaRRMean(float sigmaRRMean) { sigmaRRMean_ = sigmaRRMean;} - void sigmaZZ(float sigmaZZ) { sigmaZZ_ = sigmaZZ;} - - /* operators */ - bool operator<(const HGCalClusterT& cl) const {return mipPt() < cl.mipPt();} - bool operator>(const HGCalClusterT& cl) const { return cl<*this; } - bool operator<=(const HGCalClusterT& cl) const { return !(cl>*this); } - bool operator>=(const HGCalClusterT& cl) const { return !(cl<*this); } - - - private: - - bool valid_; - DetId detId_; - - std::unordered_map> constituents_; - std::unordered_map constituentsFraction_; - - GlobalPoint centre_; - GlobalPoint centreProj_; // centre projected onto the first HGCal layer - - double mipPt_; - double seedMipPt_; - double sumPt_; - - //shower shape - - int showerLength_; - int coreShowerLength_; - int firstLayer_; - int maxLayer_; - float eMax_; - float sigmaEtaEtaMax_; - float sigmaPhiPhiMax_; - float sigmaRRMax_; - float sigmaEtaEtaTot_; - float sigmaPhiPhiTot_; - float sigmaRRTot_; - float sigmaRRMean_; - float sigmaZZ_; - - ClusterShapes shapes_; - - - void updateP4AndPosition(const edm::Ptr& c, bool updateCentre=true, float fraction=1.) - { - double cMipt = c->mipPt()*fraction; - double cPt = c->pt()*fraction; - /* update cluster positions (IF requested) */ - if( updateCentre ){ - Basic3DVector constituentCentre( c->position() ); - Basic3DVector clusterCentre( centre_ ); - - clusterCentre = clusterCentre*mipPt_ + constituentCentre*cMipt; - if( (mipPt_ + cMipt ) > 0 ) - { - clusterCentre /= ( mipPt_ + cMipt ); - } - centre_ = GlobalPoint( clusterCentre ); - - if( clusterCentre.z()!=0 ) - { - centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() ); - } + if (pt_em > 0) + hOe = pt_had / pt_em; + else + hOe = -1.; + return hOe; + } + + uint32_t subdetId() const { return detId_.subdetId(); } + + //shower shape + + int showerLength() const { return showerLength_; } + int coreShowerLength() const { return coreShowerLength_; } + int firstLayer() const { return firstLayer_; } + int maxLayer() const { return maxLayer_; } + float eMax() const { return eMax_; } + float sigmaEtaEtaMax() const { return sigmaEtaEtaMax_; } + float sigmaPhiPhiMax() const { return sigmaPhiPhiMax_; } + float sigmaEtaEtaTot() const { return sigmaEtaEtaTot_; } + float sigmaPhiPhiTot() const { return sigmaPhiPhiTot_; } + float sigmaZZ() const { return sigmaZZ_; } + float sigmaRRTot() const { return sigmaRRTot_; } + float sigmaRRMax() const { return sigmaRRMax_; } + float sigmaRRMean() const { return sigmaRRMean_; } + + void showerLength(int showerLength) { showerLength_ = showerLength; } + void coreShowerLength(int coreShowerLength) { coreShowerLength_ = coreShowerLength; } + void firstLayer(int firstLayer) { firstLayer_ = firstLayer; } + void maxLayer(int maxLayer) { maxLayer_ = maxLayer; } + void eMax(float eMax) { eMax_ = eMax; } + void sigmaEtaEtaMax(float sigmaEtaEtaMax) { sigmaEtaEtaMax_ = sigmaEtaEtaMax; } + void sigmaEtaEtaTot(float sigmaEtaEtaTot) { sigmaEtaEtaTot_ = sigmaEtaEtaTot; } + void sigmaPhiPhiMax(float sigmaPhiPhiMax) { sigmaPhiPhiMax_ = sigmaPhiPhiMax; } + void sigmaPhiPhiTot(float sigmaPhiPhiTot) { sigmaPhiPhiTot_ = sigmaPhiPhiTot; } + void sigmaRRMax(float sigmaRRMax) { sigmaRRMax_ = sigmaRRMax; } + void sigmaRRTot(float sigmaRRTot) { sigmaRRTot_ = sigmaRRTot; } + void sigmaRRMean(float sigmaRRMean) { sigmaRRMean_ = sigmaRRMean; } + void sigmaZZ(float sigmaZZ) { sigmaZZ_ = sigmaZZ; } + + /* operators */ + bool operator<(const HGCalClusterT& cl) const { return mipPt() < cl.mipPt(); } + bool operator>(const HGCalClusterT& cl) const { return cl < *this; } + bool operator<=(const HGCalClusterT& cl) const { return !(cl > *this); } + bool operator>=(const HGCalClusterT& cl) const { return !(cl < *this); } + + private: + bool valid_; + DetId detId_; + + std::unordered_map> constituents_; + std::unordered_map constituentsFraction_; + + GlobalPoint centre_; + GlobalPoint centreProj_; // centre projected onto the first HGCal layer + + double mipPt_; + double seedMipPt_; + double sumPt_; + + //shower shape + + int showerLength_; + int coreShowerLength_; + int firstLayer_; + int maxLayer_; + float eMax_; + float sigmaEtaEtaMax_; + float sigmaPhiPhiMax_; + float sigmaRRMax_; + float sigmaEtaEtaTot_; + float sigmaPhiPhiTot_; + float sigmaRRTot_; + float sigmaRRMean_; + float sigmaZZ_; + + ClusterShapes shapes_; + + void updateP4AndPosition(const edm::Ptr& c, bool updateCentre = true, float fraction = 1.) { + double cMipt = c->mipPt() * fraction; + double cPt = c->pt() * fraction; + /* update cluster positions (IF requested) */ + if (updateCentre) { + Basic3DVector constituentCentre(c->position()); + Basic3DVector clusterCentre(centre_); + + clusterCentre = clusterCentre * mipPt_ + constituentCentre * cMipt; + if ((mipPt_ + cMipt) > 0) { + clusterCentre /= (mipPt_ + cMipt); } + centre_ = GlobalPoint(clusterCentre); - /* update cluster energies */ - mipPt_ += cMipt; - sumPt_ += cPt; - int updatedPt = hwPt() + (int)(c->hwPt()*fraction); - setHwPt( updatedPt ); - - math::PtEtaPhiMLorentzVector updatedP4 ( p4() ); - updatedP4 += (c->p4()*fraction); - setP4( updatedP4 ); + if (clusterCentre.z() != 0) { + centreProj_ = GlobalPoint(clusterCentre / clusterCentre.z()); + } } + /* update cluster energies */ + mipPt_ += cMipt; + sumPt_ += cPt; + int updatedPt = hwPt() + (int)(c->hwPt() * fraction); + setHwPt(updatedPt); + + math::PtEtaPhiMLorentzVector updatedP4(p4()); + updatedP4 += (c->p4() * fraction); + setP4(updatedP4); + } }; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalMulticluster.h b/DataFormats/L1THGCal/interface/HGCalMulticluster.h index 5f4c59bfa1ffa..3ef25f157fafa 100644 --- a/DataFormats/L1THGCal/interface/HGCalMulticluster.h +++ b/DataFormats/L1THGCal/interface/HGCalMulticluster.h @@ -7,42 +7,37 @@ #include "DataFormats/L1THGCal/interface/HGCalCluster.h" namespace l1t { - + class HGCalMulticluster : public HGCalClusterT { - - public: - - HGCalMulticluster() : hOverEValid_(false) {} - HGCalMulticluster( const LorentzVector p4, - int pt=0, - int eta=0, - int phi=0 - ); - - HGCalMulticluster( const edm::Ptr &tc, float fraction=1); - - ~HGCalMulticluster() override; - - float hOverE() const { - // --- this below would be faster when reading old objects, as HoE will only be computed once, - // --- but it may not be allowed by CMS rules because of the const_cast - // --- and could potentially cause a data race - // if (!hOverEValid_) (const_cast(this))->saveHOverE(); - // --- this below is safe in any case - return hOverEValid_ ? hOverE_ : l1t::HGCalClusterT::hOverE(); - } - - void saveHOverE() { - hOverE_ = l1t::HGCalClusterT::hOverE(); - hOverEValid_ = true; - } - private: - float hOverE_; - bool hOverEValid_; + public: + HGCalMulticluster() : hOverEValid_(false) {} + HGCalMulticluster(const LorentzVector p4, int pt = 0, int eta = 0, int phi = 0); + + HGCalMulticluster(const edm::Ptr &tc, float fraction = 1); + + ~HGCalMulticluster() override; + + float hOverE() const { + // --- this below would be faster when reading old objects, as HoE will only be computed once, + // --- but it may not be allowed by CMS rules because of the const_cast + // --- and could potentially cause a data race + // if (!hOverEValid_) (const_cast(this))->saveHOverE(); + // --- this below is safe in any case + return hOverEValid_ ? hOverE_ : l1t::HGCalClusterT::hOverE(); + } + + void saveHOverE() { + hOverE_ = l1t::HGCalClusterT::hOverE(); + hOverEValid_ = true; + } + + private: + float hOverE_; + bool hOverEValid_; }; - - typedef BXVector HGCalMulticlusterBxCollection; - -} + + typedef BXVector HGCalMulticlusterBxCollection; + +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalTower.h b/DataFormats/L1THGCal/interface/HGCalTower.h index b2f9453db40a9..3d202721d2e09 100644 --- a/DataFormats/L1THGCal/interface/HGCalTower.h +++ b/DataFormats/L1THGCal/interface/HGCalTower.h @@ -1,7 +1,6 @@ #ifndef DataFormats_L1TCalorimeter_HGCalTower_h #define DataFormats_L1TCalorimeter_HGCalTower_h - #include "DataFormats/L1Trigger/interface/L1Candidate.h" #include "DataFormats/L1Trigger/interface/BXVector.h" #include "DataFormats/L1THGCal/interface/HGCalTowerID.h" @@ -12,42 +11,33 @@ namespace l1t { typedef BXVector HGCalTowerBxCollection; class HGCalTower : public L1Candidate { - public: - - HGCalTower(): etEm_(0.), - etHad_(0.), - id_(0), - hwEtEm_(0), - hwEtHad_(0), - hwEtRatio_(0) {} + HGCalTower() : etEm_(0.), etHad_(0.), id_(0), hwEtEm_(0), hwEtHad_(0), hwEtRatio_(0) {} HGCalTower(double etEm, double etHad, double eta, double phi, unsigned short id, - int hwpt=0, - int hweta=0, - int hwphi=0, - int qual=0, - int hwEtEm=0, - int hwEtHad=0, - int hwEtRatio=0); + int hwpt = 0, + int hweta = 0, + int hwphi = 0, + int qual = 0, + int hwEtEm = 0, + int hwEtHad = 0, + int hwEtRatio = 0); ~HGCalTower() override; - - void addEtEm(double et); void addEtHad(double et); - double etEm()const { return etEm_; }; - double etHad()const { return etHad_; }; + double etEm() const { return etEm_; }; + double etHad() const { return etHad_; }; const HGCalTower& operator+=(const HGCalTower& tower); - HGCalTowerID id() const { return id_;} + HGCalTowerID id() const { return id_; } short zside() const { return id_.zside(); } void setHwEtEm(int et) { hwEtEm_ = et; } @@ -59,7 +49,6 @@ namespace l1t { int hwEtRatio() const { return hwEtRatio_; } private: - void addEt(double et); // additional hardware quantities @@ -70,9 +59,8 @@ namespace l1t { int hwEtEm_; int hwEtHad_; int hwEtRatio_; - }; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalTowerID.h b/DataFormats/L1THGCal/interface/HGCalTowerID.h index 77c957e01c745..85a8f88fb024b 100644 --- a/DataFormats/L1THGCal/interface/HGCalTowerID.h +++ b/DataFormats/L1THGCal/interface/HGCalTowerID.h @@ -7,25 +7,24 @@ namespace l1t { class HGCalTowerID { public: - HGCalTowerID(): HGCalTowerID(0) {} + HGCalTowerID() : HGCalTowerID(0) {} - HGCalTowerID(unsigned short rawId): rawId_(rawId) {} + HGCalTowerID(unsigned short rawId) : rawId_(rawId) {} HGCalTowerID(short zside, unsigned short coord1, unsigned short coord2) { - rawId_ = ((coord1 & coordMask) << coord1Shift) | ((coord2 & coordMask) << coord2Shift) | (((zside > 0) & zsideMask) << zsideShift); + rawId_ = ((coord1 & coordMask) << coord1Shift) | ((coord2 & coordMask) << coord2Shift) | + (((zside > 0) & zsideMask) << zsideShift); } - short zside() const { return ((rawId_ >> zsideShift) & zsideMask) ? 1 : -1;} + short zside() const { return ((rawId_ >> zsideShift) & zsideMask) ? 1 : -1; } unsigned short iEta() const { return (rawId_ >> coord1Shift) & coordMask; } - unsigned short iPhi() const { return (rawId_ >> coord2Shift) & coordMask;} - - unsigned short rawId() const {return rawId_;} + unsigned short iPhi() const { return (rawId_ >> coord2Shift) & coordMask; } + unsigned short rawId() const { return rawId_; } private: - unsigned short rawId_; static const int zsideMask = 0x1; static const int zsideShift = 15; @@ -34,20 +33,13 @@ namespace l1t { static const int coord2Shift = 0; }; - struct HGCalTowerCoord { - HGCalTowerCoord(unsigned short rawId, float eta, float phi): rawId(rawId), - eta(eta), - phi(phi) {} + HGCalTowerCoord(unsigned short rawId, float eta, float phi) : rawId(rawId), eta(eta), phi(phi) {} const unsigned short rawId; const float eta; const float phi; - }; -} - - - +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalTowerMap.h b/DataFormats/L1THGCal/interface/HGCalTowerMap.h index 78c073094195c..7eef06abf40ad 100644 --- a/DataFormats/L1THGCal/interface/HGCalTowerMap.h +++ b/DataFormats/L1THGCal/interface/HGCalTowerMap.h @@ -13,10 +13,8 @@ namespace l1t { typedef BXVector HGCalTowerMapBxCollection; class HGCalTowerMap { - public: - - HGCalTowerMap(): layer_(0) {} + HGCalTowerMap() : layer_(0) {} HGCalTowerMap(const std::vector& tower_ids, const int layer); @@ -29,14 +27,11 @@ namespace l1t { unsigned nTowers() const { return towerMap_.size(); } const std::unordered_map& towers() const { return towerMap_; } - private: - - std::unordered_map towerMap_; + std::unordered_map towerMap_; unsigned layer_; - }; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalTriggerCell.h b/DataFormats/L1THGCal/interface/HGCalTriggerCell.h index 4841e0ad2249e..b65fb11316047 100644 --- a/DataFormats/L1THGCal/interface/HGCalTriggerCell.h +++ b/DataFormats/L1THGCal/interface/HGCalTriggerCell.h @@ -1,67 +1,53 @@ #ifndef DataFormats_L1TCalorimeter_HGCalTriggerCell_h #define DataFormats_L1TCalorimeter_HGCalTriggerCell_h - #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/L1Trigger/interface/L1Candidate.h" #include "DataFormats/L1Trigger/interface/BXVector.h" #include "DataFormats/DetId/interface/DetId.h" -namespace l1t -{ +namespace l1t { + + class HGCalTriggerCell; + typedef BXVector HGCalTriggerCellBxCollection; - class HGCalTriggerCell; - typedef BXVector HGCalTriggerCellBxCollection; + class HGCalTriggerCell : public L1Candidate { + public: + HGCalTriggerCell() {} - class HGCalTriggerCell : public L1Candidate - { + HGCalTriggerCell(const LorentzVector& p4, int pt = 0, int eta = 0, int phi = 0, int qual = 0, uint32_t detid = 0); - public: + ~HGCalTriggerCell() override; - HGCalTriggerCell() {} + void setDetId(uint32_t detid) { detid_ = DetId(detid); } + void setPosition(const GlobalPoint& position) { position_ = position; } - HGCalTriggerCell( const LorentzVector& p4, - int pt=0, - int eta=0, - int phi=0, - int qual=0, - uint32_t detid=0); + uint32_t detId() const { return detid_.rawId(); } + const GlobalPoint& position() const { return position_; } - ~HGCalTriggerCell() override; + int subdetId() const { return detid_.subdetId(); } - void setDetId(uint32_t detid) {detid_ = DetId(detid);} - void setPosition(const GlobalPoint& position) {position_ = position;} + void setMipPt(double value) { mipPt_ = value; } + double mipPt() const { return mipPt_; } - uint32_t detId() const {return detid_.rawId();} - const GlobalPoint& position() const {return position_;} - - int subdetId() const { - return detid_.subdetId(); - } - - void setMipPt( double value ) { mipPt_ = value; } - double mipPt() const { return mipPt_; } + void setUncompressedCharge(uint32_t value) { uncompressedCharge_ = value; } + uint32_t uncompressedCharge() const { return uncompressedCharge_; } - void setUncompressedCharge( uint32_t value ) { uncompressedCharge_ = value; } - uint32_t uncompressedCharge() const { return uncompressedCharge_; } + void setCompressedCharge(uint32_t value) { compressedCharge_ = value; } + uint32_t compressedCharge() const { return compressedCharge_; } - void setCompressedCharge( uint32_t value ) { compressedCharge_ = value; } - uint32_t compressedCharge() const { return compressedCharge_; } + void setPt(double pT); - void setPt( double pT ); - - private: - - DetId detid_; - GlobalPoint position_; - - double mipPt_{0.}; + private: + DetId detid_; + GlobalPoint position_; - uint32_t uncompressedCharge_{0}; - uint32_t compressedCharge_{0}; + double mipPt_{0.}; - }; + uint32_t uncompressedCharge_{0}; + uint32_t compressedCharge_{0}; + }; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/interface/HGCalTriggerSums.h b/DataFormats/L1THGCal/interface/HGCalTriggerSums.h index d6c15c6fee07e..f9b8646e9f419 100644 --- a/DataFormats/L1THGCal/interface/HGCalTriggerSums.h +++ b/DataFormats/L1THGCal/interface/HGCalTriggerSums.h @@ -1,53 +1,40 @@ #ifndef DataFormats_L1TCalorimeter_HGCalTriggerSums_h #define DataFormats_L1TCalorimeter_HGCalTriggerSums_h - #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/L1Trigger/interface/L1Candidate.h" #include "DataFormats/L1Trigger/interface/BXVector.h" #include "DataFormats/DetId/interface/DetId.h" -namespace l1t -{ +namespace l1t { - class HGCalTriggerSums; - typedef BXVector HGCalTriggerSumsBxCollection; + class HGCalTriggerSums; + typedef BXVector HGCalTriggerSumsBxCollection; - class HGCalTriggerSums : public L1Candidate - { + class HGCalTriggerSums : public L1Candidate { + public: + HGCalTriggerSums() {} - public: + HGCalTriggerSums(const LorentzVector& p4, int pt = 0, int eta = 0, int phi = 0, int qual = 0, uint32_t detid = 0); - HGCalTriggerSums() {} + ~HGCalTriggerSums() override; - HGCalTriggerSums( const LorentzVector& p4, - int pt=0, - int eta=0, - int phi=0, - int qual=0, - uint32_t detid=0); + void setDetId(uint32_t detid) { detid_ = DetId(detid); } + void setPosition(const GlobalPoint& position) { position_ = position; } - ~HGCalTriggerSums() override; + uint32_t detId() const { return detid_.rawId(); } + const GlobalPoint& position() const { return position_; } - void setDetId(uint32_t detid) {detid_ = DetId(detid);} - void setPosition(const GlobalPoint& position) {position_ = position;} + void setMipPt(double value) { mipPt_ = value; } + double mipPt() const { return mipPt_; } - uint32_t detId() const {return detid_.rawId();} - const GlobalPoint& position() const {return position_;} - - - void setMipPt( double value ) { mipPt_ = value; } - double mipPt() const { return mipPt_; } - - private: - - DetId detid_; - GlobalPoint position_; - - double mipPt_; + private: + DetId detid_; + GlobalPoint position_; - }; + double mipPt_; + }; -} +} // namespace l1t #endif diff --git a/DataFormats/L1THGCal/src/ClusterShapes.cc b/DataFormats/L1THGCal/src/ClusterShapes.cc index 2784a84d90841..f3a3b485fe1f1 100644 --- a/DataFormats/L1THGCal/src/ClusterShapes.cc +++ b/DataFormats/L1THGCal/src/ClusterShapes.cc @@ -3,130 +3,121 @@ using namespace l1t; -ClusterShapes ClusterShapes::operator+(const ClusterShapes& x) -{ - ClusterShapes cs(*this); // copy constructor - cs += x; - return cs; +ClusterShapes ClusterShapes::operator+(const ClusterShapes& x) { + ClusterShapes cs(*this); // copy constructor + cs += x; + return cs; } - -void ClusterShapes::operator +=(const ClusterShapes &x){ - - sum_e_ += x.sum_e_; - sum_e2_ += x.sum_e2_; - sum_logE_ += x.sum_logE_; - n_ += x.n_; - - sum_w_ += x.sum_w_; - - emax_ = (emax_> x.emax_) ? emax_: x.emax_; - - // mid-point - sum_eta_ += x.sum_eta_; - sum_phi_0_ += x.sum_phi_0_; // - sum_phi_1_ += x.sum_phi_1_; // - sum_r_ += x.sum_r_; - - // square - sum_eta2_ += x.sum_eta2_; - sum_phi2_0_ += x.sum_phi2_0_; - sum_phi2_1_ += x.sum_phi2_1_; - sum_r2_ += x.sum_r2_; - - // off diagonal - sum_eta_r_ += x.sum_eta_r_ ; - sum_r_phi_0_ += x.sum_r_phi_0_ ; - sum_r_phi_1_ += x.sum_r_phi_1_ ; - sum_eta_phi_0_ += x.sum_eta_phi_0_; - sum_eta_phi_1_ += x.sum_eta_phi_1_; - +void ClusterShapes::operator+=(const ClusterShapes& x) { + sum_e_ += x.sum_e_; + sum_e2_ += x.sum_e2_; + sum_logE_ += x.sum_logE_; + n_ += x.n_; + + sum_w_ += x.sum_w_; + + emax_ = (emax_ > x.emax_) ? emax_ : x.emax_; + + // mid-point + sum_eta_ += x.sum_eta_; + sum_phi_0_ += x.sum_phi_0_; // + sum_phi_1_ += x.sum_phi_1_; // + sum_r_ += x.sum_r_; + + // square + sum_eta2_ += x.sum_eta2_; + sum_phi2_0_ += x.sum_phi2_0_; + sum_phi2_1_ += x.sum_phi2_1_; + sum_r2_ += x.sum_r2_; + + // off diagonal + sum_eta_r_ += x.sum_eta_r_; + sum_r_phi_0_ += x.sum_r_phi_0_; + sum_r_phi_1_ += x.sum_r_phi_1_; + sum_eta_phi_0_ += x.sum_eta_phi_0_; + sum_eta_phi_1_ += x.sum_eta_phi_1_; } - // -------------- CLUSTER SHAPES --------------- -void ClusterShapes::Init(float e ,float eta, float phi, float r){ - if (e<=0 ) return; - sum_e_ = e; - sum_e2_ = e*e; - sum_logE_ = std::log(e); - - float w = e; - - n_=1; - - sum_w_ = w; - - sum_phi_0_ = w *( phi ); - sum_phi_1_ = w* (phi + M_PI); - sum_r_ = w * r; - sum_eta_ = w * eta; - - //-- - sum_r2_ += w * (r*r); - sum_eta2_ += w * (eta*eta); - sum_phi2_0_ += w * (phi*phi); - sum_phi2_1_ += w * (phi+M_PI)*(phi+M_PI); - - // -- off diagonal - sum_eta_r_ += w * (r*eta); - sum_r_phi_0_ += w* (r *phi); - sum_r_phi_1_ += w* r *(phi + M_PI); - sum_eta_phi_0_ += w* (eta *phi); - sum_eta_phi_1_ += w* eta * (phi+M_PI); - +void ClusterShapes::Init(float e, float eta, float phi, float r) { + if (e <= 0) + return; + sum_e_ = e; + sum_e2_ = e * e; + sum_logE_ = std::log(e); + + float w = e; + + n_ = 1; + + sum_w_ = w; + + sum_phi_0_ = w * (phi); + sum_phi_1_ = w * (phi + M_PI); + sum_r_ = w * r; + sum_eta_ = w * eta; + + //-- + sum_r2_ += w * (r * r); + sum_eta2_ += w * (eta * eta); + sum_phi2_0_ += w * (phi * phi); + sum_phi2_1_ += w * (phi + M_PI) * (phi + M_PI); + + // -- off diagonal + sum_eta_r_ += w * (r * eta); + sum_r_phi_0_ += w * (r * phi); + sum_r_phi_1_ += w * r * (phi + M_PI); + sum_eta_phi_0_ += w * (eta * phi); + sum_eta_phi_1_ += w * eta * (phi + M_PI); } // ------ -float ClusterShapes::Eta()const { return sum_eta_/sum_w_;} -float ClusterShapes::R() const { return sum_r_/sum_w_;} - -float ClusterShapes::SigmaEtaEta()const {return sum_eta2_/sum_w_ - Eta()*Eta();} - -float ClusterShapes::SigmaRR()const { return sum_r2_/sum_w_ - R() *R();} - - -float ClusterShapes::SigmaPhiPhi()const { - float phi_0 = (sum_phi_0_ / sum_w_); - float phi_1 = (sum_phi_1_ / sum_w_); - float spp_0 = sum_phi2_0_ / sum_w_ - phi_0*phi_0; - float spp_1 = sum_phi2_1_ / sum_w_ - phi_1*phi_1; - - if (spp_0 < spp_1 ) - { - isPhi0_=true; - return spp_0; - } - else - { - isPhi0_=false; - return spp_1; - } +float ClusterShapes::Eta() const { return sum_eta_ / sum_w_; } +float ClusterShapes::R() const { return sum_r_ / sum_w_; } + +float ClusterShapes::SigmaEtaEta() const { return sum_eta2_ / sum_w_ - Eta() * Eta(); } + +float ClusterShapes::SigmaRR() const { return sum_r2_ / sum_w_ - R() * R(); } + +float ClusterShapes::SigmaPhiPhi() const { + float phi_0 = (sum_phi_0_ / sum_w_); + float phi_1 = (sum_phi_1_ / sum_w_); + float spp_0 = sum_phi2_0_ / sum_w_ - phi_0 * phi_0; + float spp_1 = sum_phi2_1_ / sum_w_ - phi_1 * phi_1; + + if (spp_0 < spp_1) { + isPhi0_ = true; + return spp_0; + } else { + isPhi0_ = false; + return spp_1; + } } -float ClusterShapes::Phi()const { - SigmaPhiPhi(); //update phi - if (isPhi0_) return (sum_phi_0_ / sum_w_); - else return (sum_phi_1_ / sum_w_); +float ClusterShapes::Phi() const { + SigmaPhiPhi(); //update phi + if (isPhi0_) + return (sum_phi_0_ / sum_w_); + else + return (sum_phi_1_ / sum_w_); } - // off - diagonal -float ClusterShapes::SigmaEtaR() const { return -(sum_eta_r_ / sum_w_ - Eta() *R()) ;} +float ClusterShapes::SigmaEtaR() const { return -(sum_eta_r_ / sum_w_ - Eta() * R()); } -float ClusterShapes::SigmaEtaPhi()const { - SigmaPhiPhi() ; // decide which phi use, update phi +float ClusterShapes::SigmaEtaPhi() const { + SigmaPhiPhi(); // decide which phi use, update phi - if (isPhi0_) - return -(sum_eta_phi_0_ /sum_w_ - Eta()*(sum_phi_0_ / sum_w_)); - else - return -(sum_eta_phi_1_ / sum_w_ - Eta()*(sum_phi_1_ / sum_w_)); + if (isPhi0_) + return -(sum_eta_phi_0_ / sum_w_ - Eta() * (sum_phi_0_ / sum_w_)); + else + return -(sum_eta_phi_1_ / sum_w_ - Eta() * (sum_phi_1_ / sum_w_)); } -float ClusterShapes::SigmaRPhi()const { - SigmaPhiPhi() ; // decide which phi use, update phi - if (isPhi0_) - return -(sum_r_phi_0_ / sum_w_ - R() *(sum_phi_0_ / sum_w_)); - else - return -(sum_r_phi_1_ / sum_w_ - R() * (sum_phi_1_ / sum_w_)); +float ClusterShapes::SigmaRPhi() const { + SigmaPhiPhi(); // decide which phi use, update phi + if (isPhi0_) + return -(sum_r_phi_0_ / sum_w_ - R() * (sum_phi_0_ / sum_w_)); + else + return -(sum_r_phi_1_ / sum_w_ - R() * (sum_phi_1_ / sum_w_)); } - diff --git a/DataFormats/L1THGCal/src/HGCFETriggerDigi.cc b/DataFormats/L1THGCal/src/HGCFETriggerDigi.cc index 20b2db2de995b..8287816d33378 100644 --- a/DataFormats/L1THGCal/src/HGCFETriggerDigi.cc +++ b/DataFormats/L1THGCal/src/HGCFETriggerDigi.cc @@ -5,8 +5,8 @@ using namespace l1t; void HGCFETriggerDigi::print(std::ostream& out) const { out << "Codec type: " << static_cast(codec_) << std::endl; out << "Raw data payload: "; - for( unsigned i = data_.size(); i > 0; --i ) { - out << (unsigned)data_[i-1]; + for (unsigned i = data_.size(); i > 0; --i) { + out << (unsigned)data_[i - 1]; } out << std::endl; } diff --git a/DataFormats/L1THGCal/src/HGCalCluster.cc b/DataFormats/L1THGCal/src/HGCalCluster.cc index 3716ce3623754..1363503d87eac 100644 --- a/DataFormats/L1THGCal/src/HGCalCluster.cc +++ b/DataFormats/L1THGCal/src/HGCalCluster.cc @@ -2,25 +2,10 @@ using namespace l1t; -HGCalCluster::HGCalCluster( const LorentzVector p4, - int pt, - int eta, - int phi ) - : HGCalClusterT(p4, pt, eta, phi), - module_(0) -{ -} - - -HGCalCluster::HGCalCluster( const edm::Ptr &tcSeed ) - : HGCalClusterT(tcSeed), - module_(0) -{ -} - - -HGCalCluster::~HGCalCluster() -{ -} +HGCalCluster::HGCalCluster(const LorentzVector p4, int pt, int eta, int phi) + : HGCalClusterT(p4, pt, eta, phi), module_(0) {} +HGCalCluster::HGCalCluster(const edm::Ptr &tcSeed) + : HGCalClusterT(tcSeed), module_(0) {} +HGCalCluster::~HGCalCluster() {} diff --git a/DataFormats/L1THGCal/src/HGCalMulticluster.cc b/DataFormats/L1THGCal/src/HGCalMulticluster.cc index 57e4c38a52a51..4fb5b4b5528c2 100644 --- a/DataFormats/L1THGCal/src/HGCalMulticluster.cc +++ b/DataFormats/L1THGCal/src/HGCalMulticluster.cc @@ -2,27 +2,10 @@ using namespace l1t; -HGCalMulticluster::HGCalMulticluster( const LorentzVector p4, - int pt, - int eta, - int phi ) - : HGCalClusterT(p4, pt, eta, phi), - hOverE_(-99), - hOverEValid_(false) -{ -} - - -HGCalMulticluster::HGCalMulticluster( const edm::Ptr &clusterSeed, float fraction ) - : HGCalClusterT(clusterSeed, fraction), - hOverE_(-99), - hOverEValid_(false) -{ -} - - -HGCalMulticluster::~HGCalMulticluster() -{ -} +HGCalMulticluster::HGCalMulticluster(const LorentzVector p4, int pt, int eta, int phi) + : HGCalClusterT(p4, pt, eta, phi), hOverE_(-99), hOverEValid_(false) {} +HGCalMulticluster::HGCalMulticluster(const edm::Ptr &clusterSeed, float fraction) + : HGCalClusterT(clusterSeed, fraction), hOverE_(-99), hOverEValid_(false) {} +HGCalMulticluster::~HGCalMulticluster() {} diff --git a/DataFormats/L1THGCal/src/HGCalTower.cc b/DataFormats/L1THGCal/src/HGCalTower.cc index a10ffb2ad5ed0..59a61e49a962b 100644 --- a/DataFormats/L1THGCal/src/HGCalTower.cc +++ b/DataFormats/L1THGCal/src/HGCalTower.cc @@ -1,8 +1,8 @@ #include "DataFormats/L1THGCal/interface/HGCalTower.h" #include "FWCore/Utilities/interface/EDMException.h" -using l1t::L1Candidate; using l1t::HGCalTower; +using l1t::L1Candidate; HGCalTower::HGCalTower(double etEm, double etHad, @@ -15,44 +15,39 @@ HGCalTower::HGCalTower(double etEm, int qual, int hwEtEm, int hwEtHad, - int hwEtRatio) : L1Candidate(PolarLorentzVector(etEm+etHad, eta, phi, 0.), hwpt, hweta, hwphi, qual), - etEm_(etEm), - etHad_(etHad), - id_(id), - hwEtEm_(hwEtEm), - hwEtHad_(hwEtHad), - hwEtRatio_(hwEtRatio) {} - + int hwEtRatio) + : L1Candidate(PolarLorentzVector(etEm + etHad, eta, phi, 0.), hwpt, hweta, hwphi, qual), + etEm_(etEm), + etHad_(etHad), + id_(id), + hwEtEm_(hwEtEm), + hwEtHad_(hwEtHad), + hwEtRatio_(hwEtRatio) {} HGCalTower::~HGCalTower() {} - void HGCalTower::addEtEm(double et) { - etEm_+=et; + etEm_ += et; addEt(et); } void HGCalTower::addEtHad(double et) { - etHad_+=et; + etHad_ += et; addEt(et); } -void HGCalTower::addEt(double et) { - this->setP4(PolarLorentzVector(this->pt()+et, this->eta(), this->phi(), 0.)); -} - +void HGCalTower::addEt(double et) { this->setP4(PolarLorentzVector(this->pt() + et, this->eta(), this->phi(), 0.)); } -const HGCalTower& HGCalTower::operator+=(const HGCalTower& tower){ +const HGCalTower& HGCalTower::operator+=(const HGCalTower& tower) { // NOTE: assume same eta and phi -> need an explicit check on the ID - if(id().rawId() != tower.id().rawId()) { + if (id().rawId() != tower.id().rawId()) { throw edm::Exception(edm::errors::StdException, "StdException") - << "HGCalTower: adding to this tower with ID: " << id().rawId() - << " one with different ID: " << tower.id().rawId() << std::endl; + << "HGCalTower: adding to this tower with ID: " << id().rawId() + << " one with different ID: " << tower.id().rawId() << std::endl; } addEt(tower.pt()); - etEm_+=tower.etEm(); - etHad_+=tower.etHad(); + etEm_ += tower.etEm(); + etHad_ += tower.etHad(); return *this; - } diff --git a/DataFormats/L1THGCal/src/HGCalTowerMap.cc b/DataFormats/L1THGCal/src/HGCalTowerMap.cc index 9880116396c0b..0437425abd7e8 100644 --- a/DataFormats/L1THGCal/src/HGCalTowerMap.cc +++ b/DataFormats/L1THGCal/src/HGCalTowerMap.cc @@ -5,38 +5,35 @@ using namespace l1t; -HGCalTowerMap::HGCalTowerMap(const std::vector& tower_ids, - const int layer=0) : layer_(layer) { - for(auto tower_id: tower_ids) { +HGCalTowerMap::HGCalTowerMap(const std::vector& tower_ids, const int layer = 0) : layer_(layer) { + for (auto tower_id : tower_ids) { towerMap_[tower_id.rawId] = l1t::HGCalTower(0., 0., tower_id.eta, tower_id.phi, tower_id.rawId); } } - - -const HGCalTowerMap& HGCalTowerMap::operator+=(const HGCalTowerMap& map){ +const HGCalTowerMap& HGCalTowerMap::operator+=(const HGCalTowerMap& map) { if (nTowers() != map.nTowers()) { throw edm::Exception(edm::errors::StdException, "StdException") - << "HGCalTowerMap: Trying to add HGCalTowerMaps with different bins: " << nTowers() << " and " << map.nTowers() <second+=tower.second; + this_tower->second += tower.second; } - } return *this; } - bool HGCalTowerMap::addEt(short bin_id, float etEm, float etHad) { auto this_tower = towerMap_.find(bin_id); - if(this_tower == towerMap_.end()) return false; + if (this_tower == towerMap_.end()) + return false; this_tower->second.addEtEm(etEm); this_tower->second.addEtHad(etHad); diff --git a/DataFormats/L1THGCal/src/HGCalTriggerCell.cc b/DataFormats/L1THGCal/src/HGCalTriggerCell.cc index 74a3d0036703d..2cba79618f463 100644 --- a/DataFormats/L1THGCal/src/HGCalTriggerCell.cc +++ b/DataFormats/L1THGCal/src/HGCalTriggerCell.cc @@ -2,27 +2,11 @@ using namespace l1t; -HGCalTriggerCell:: -HGCalTriggerCell( const LorentzVector& p4, - int pt, - int eta, - int phi, - int qual, - uint32_t detid): - L1Candidate(p4, pt, eta, phi, qual), - detid_(detid), position_(), mipPt_(0) -{ -} +HGCalTriggerCell::HGCalTriggerCell(const LorentzVector& p4, int pt, int eta, int phi, int qual, uint32_t detid) + : L1Candidate(p4, pt, eta, phi, qual), detid_(detid), position_(), mipPt_(0) {} -HGCalTriggerCell:: -~HGCalTriggerCell() -{ -} +HGCalTriggerCell::~HGCalTriggerCell() {} -void HGCalTriggerCell:: -setPt( double pt ) -{ - - this->setP4( math::PtEtaPhiMLorentzVector(pt, this->eta(), this->phi(), this->mass() ) ); - +void HGCalTriggerCell::setPt(double pt) { + this->setP4(math::PtEtaPhiMLorentzVector(pt, this->eta(), this->phi(), this->mass())); } diff --git a/DataFormats/L1THGCal/src/HGCalTriggerSums.cc b/DataFormats/L1THGCal/src/HGCalTriggerSums.cc index d02072149fcfc..afb8fb6d366be 100644 --- a/DataFormats/L1THGCal/src/HGCalTriggerSums.cc +++ b/DataFormats/L1THGCal/src/HGCalTriggerSums.cc @@ -2,19 +2,7 @@ using namespace l1t; -HGCalTriggerSums:: -HGCalTriggerSums( const LorentzVector& p4, - int pt, - int eta, - int phi, - int qual, - uint32_t detid): - L1Candidate(p4, pt, eta, phi, qual), - detid_(detid) -{ -} +HGCalTriggerSums::HGCalTriggerSums(const LorentzVector& p4, int pt, int eta, int phi, int qual, uint32_t detid) + : L1Candidate(p4, pt, eta, phi, qual), detid_(detid) {} -HGCalTriggerSums:: -~HGCalTriggerSums() -{ -} +HGCalTriggerSums::~HGCalTriggerSums() {} diff --git a/DataFormats/L1THGCal/src/classes.h b/DataFormats/L1THGCal/src/classes.h index dcb08296a44d8..cef3007c279c8 100644 --- a/DataFormats/L1THGCal/src/classes.h +++ b/DataFormats/L1THGCal/src/classes.h @@ -27,10 +27,10 @@ namespace DataFormats { edm::Wrapper w_v_r_hgcfetd; edm::Wrapper w_v_p_hgcfetd; - l1t::HGCalTowerBxCollection hgcalTowerBxColl; - l1t::HGCalTowerMapBxCollection hgcalTowerMapBxColl; - l1t::HGCalTriggerCellBxCollection hgcalTriggerCellBxColl; - l1t::HGCalTriggerSumsBxCollection hgcalTriggerSumsBxColl; + l1t::HGCalTowerBxCollection hgcalTowerBxColl; + l1t::HGCalTowerMapBxCollection hgcalTowerMapBxColl; + l1t::HGCalTriggerCellBxCollection hgcalTriggerCellBxColl; + l1t::HGCalTriggerSumsBxCollection hgcalTriggerSumsBxColl; l1t::HGCalClusterBxCollection hgcalClusterBxColl; l1t::HGCalMulticlusterBxCollection hgcalMulticlusterBxColl; l1t::HGCalTowerID towerId; @@ -40,21 +40,21 @@ namespace DataFormats { edm::Ptr hgcalClusterPtr; edm::Ptr hgcalTowerMapPtr; - std::vector> hgcalTriggerCellList; - std::vector> hgcalClusterList; - std::vector> hgcalTriggerSumsList; - std::unordered_map> hgcalTriggerCellMap; - std::unordered_map> hgcalClusterMap; + std::vector> hgcalTriggerCellList; + std::vector> hgcalClusterList; + std::vector> hgcalTriggerSumsList; + std::unordered_map> hgcalTriggerCellMap; + std::unordered_map> hgcalClusterMap; - edm::PtrVector hgcalTowerMapList; - std::unordered_map towermap; + edm::PtrVector hgcalTowerMapList; + std::unordered_map towermap; - edm::Wrapper w_hgcalTowerBxColl; - edm::Wrapper w_hgcalTowerMapBxColl; + edm::Wrapper w_hgcalTowerBxColl; + edm::Wrapper w_hgcalTowerMapBxColl; edm::Wrapper w_hgcalClusterBxColl; edm::Wrapper w_hgcalMulticlusterBxColl; - edm::Wrapper w_hgcalTriggerCellBxColl; - edm::Wrapper w_hgcalTriggerSumsBxColl; + edm::Wrapper w_hgcalTriggerCellBxColl; + edm::Wrapper w_hgcalTriggerSumsBxColl; edm::Wrapper> w_hgcalTriggerCellPtr; edm::Wrapper> w_hgcalTriggerSumsPtr; @@ -64,5 +64,5 @@ namespace DataFormats { edm::Wrapper> w_hgcalClusterList; l1t::ClusterShapes clusterShapes; - } -} + } // namespace L1THGCal +} // namespace DataFormats diff --git a/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h b/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h index 8f344d3f3b6d0..d2928f178bee1 100644 --- a/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h @@ -12,18 +12,23 @@ #include "DataFormats/L1THGCal/interface/HGCalTower.h" typedef HGCalProcessorBaseT HGCalVFEProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalTriggerCellBxCollection> HGCalConcentratorProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalClusterBxCollection> HGCalBackendLayer1ProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalMulticlusterBxCollection> HGCalBackendLayer2ProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalTowerMapBxCollection> HGCalTowerMapProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalTowerBxCollection> HGCalTowerProcessorBase; +typedef HGCalProcessorBaseT, l1t::HGCalTriggerCellBxCollection> + HGCalConcentratorProcessorBase; +typedef HGCalProcessorBaseT, l1t::HGCalClusterBxCollection> + HGCalBackendLayer1ProcessorBase; +typedef HGCalProcessorBaseT, l1t::HGCalMulticlusterBxCollection> + HGCalBackendLayer2ProcessorBase; +typedef HGCalProcessorBaseT, l1t::HGCalTowerMapBxCollection> + HGCalTowerMapProcessorBase; +typedef HGCalProcessorBaseT, l1t::HGCalTowerBxCollection> + HGCalTowerProcessorBase; #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalVFEProcessorBase* (const edm::ParameterSet&) > HGCalVFEProcessorBaseFactory; -typedef edmplugin::PluginFactory< HGCalConcentratorProcessorBase* (const edm::ParameterSet&) > HGCalConcentratorFactory; -typedef edmplugin::PluginFactory< HGCalBackendLayer1ProcessorBase* (const edm::ParameterSet&) > HGCalBackendLayer1Factory; -typedef edmplugin::PluginFactory< HGCalBackendLayer2ProcessorBase* (const edm::ParameterSet&) > HGCalBackendLayer2Factory; -typedef edmplugin::PluginFactory< HGCalTowerMapProcessorBase* (const edm::ParameterSet&) > HGCalTowerMapFactory; -typedef edmplugin::PluginFactory< HGCalTowerProcessorBase* (const edm::ParameterSet&) > HGCalTowerFactory; +typedef edmplugin::PluginFactory HGCalVFEProcessorBaseFactory; +typedef edmplugin::PluginFactory HGCalConcentratorFactory; +typedef edmplugin::PluginFactory HGCalBackendLayer1Factory; +typedef edmplugin::PluginFactory HGCalBackendLayer2Factory; +typedef edmplugin::PluginFactory HGCalTowerMapFactory; +typedef edmplugin::PluginFactory HGCalTowerFactory; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h b/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h index 12c40d02d2673..3a645da207853 100644 --- a/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h +++ b/L1Trigger/L1THGCal/interface/HGCalProcessorBaseT.h @@ -6,31 +6,25 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" +template +class HGCalProcessorBaseT { +public: + HGCalProcessorBaseT(const edm::ParameterSet& conf) + : geometry_(nullptr), name_(conf.getParameter("ProcessorName")) {} -template class HGCalProcessorBaseT { - - public: - HGCalProcessorBaseT(const edm::ParameterSet& conf) : - geometry_(nullptr), - name_(conf.getParameter("ProcessorName")) - {} - virtual ~HGCalProcessorBaseT() {} - const std::string& name() const { return name_; } - - void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom;} - - virtual void run(const InputCollection& inputColl, - OutputCollection& outColl, - const edm::EventSetup& es) = 0; - - protected: + const std::string& name() const { return name_; } + + void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom; } + + virtual void run(const InputCollection& inputColl, OutputCollection& outColl, const edm::EventSetup& es) = 0; + +protected: const HGCalTriggerGeometryBase* geometry_; - - private: - const std::string name_; +private: + const std::string name_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h b/L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h index 51e9ccb13f86d..ede6bc136d832 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h @@ -27,60 +27,55 @@ * *******/ -class HGCalTriggerBackendAlgorithmBase { - public: +class HGCalTriggerBackendAlgorithmBase { +public: // Allow HGCalTriggerBackend to be passed a consume collector - HGCalTriggerBackendAlgorithmBase(const edm::ParameterSet& conf, edm::ConsumesCollector &cc) : - geometry_(nullptr), - name_(conf.getParameter("AlgorithmName")) - {} + HGCalTriggerBackendAlgorithmBase(const edm::ParameterSet& conf, edm::ConsumesCollector& cc) + : geometry_(nullptr), name_(conf.getParameter("AlgorithmName")) {} virtual ~HGCalTriggerBackendAlgorithmBase() {} - const std::string& name() const { return name_; } + const std::string& name() const { return name_; } + + virtual void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom; } - virtual void setGeometry(const HGCalTriggerGeometryBase* const geom) {geometry_ = geom;} - //runs the trigger algorithm, storing internally the results virtual void setProduces(edm::stream::EDProducer<>& prod) const = 0; - virtual void run(const l1t::HGCFETriggerDigiCollection& coll, - const edm::EventSetup& es, - edm::Event &e - ) = 0; + virtual void run(const l1t::HGCFETriggerDigiCollection& coll, const edm::EventSetup& es, edm::Event& e) = 0; virtual void putInEvent(edm::Event& evt) = 0; virtual void reset() = 0; - protected: +protected: const HGCalTriggerGeometryBase* geometry_; - private: +private: const std::string name_; }; // ----> all backend algorithm classes derive from this <---- // inheritance looks like class MyAlgorithm : public HGCalTriggerBackend::Algorithm namespace HGCalTriggerBackend { - template - class Algorithm : public HGCalTriggerBackendAlgorithmBase { + template + class Algorithm : public HGCalTriggerBackendAlgorithmBase { public: - Algorithm(const edm::ParameterSet& conf, edm::ConsumesCollector &cc ) : - HGCalTriggerBackendAlgorithmBase(conf, cc), - codec_(conf.getParameterSet("FECodec")){ } + Algorithm(const edm::ParameterSet& conf, edm::ConsumesCollector& cc) + : HGCalTriggerBackendAlgorithmBase(conf, cc), codec_(conf.getParameterSet("FECodec")) {} void setGeometry(const HGCalTriggerGeometryBase* const geom) final { HGCalTriggerBackendAlgorithmBase::setGeometry(geom); codec_.setGeometry(geom); } - - protected: - FECODEC codec_; + + protected: + FECODEC codec_; }; -} +} // namespace HGCalTriggerBackend #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalTriggerBackendAlgorithmBase* (const edm::ParameterSet&,edm::ConsumesCollector & ) > HGCalTriggerBackendAlgorithmFactory; +typedef edmplugin::PluginFactory + HGCalTriggerBackendAlgorithmFactory; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h b/L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h index 82f52c66d86d1..6003e6c8d6566 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h @@ -28,25 +28,22 @@ *******/ class HGCalTriggerBackendProcessor { - public: +public: typedef std::unique_ptr algo_ptr; - HGCalTriggerBackendProcessor(const edm::ParameterSet& conf, edm::ConsumesCollector&&cc); + HGCalTriggerBackendProcessor(const edm::ParameterSet& conf, edm::ConsumesCollector&& cc); void setGeometry(const HGCalTriggerGeometryBase* const geom); void setProduces(edm::stream::EDProducer<>& prod) const; - void run(const l1t::HGCFETriggerDigiCollection& coll, - const edm::EventSetup& es, - edm::Event&e - ); + void run(const l1t::HGCFETriggerDigiCollection& coll, const edm::EventSetup& es, edm::Event& e); void putInEvent(edm::Event& evt); void reset(); - private: +private: std::vector algorithms_; }; diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h b/L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h index fa2059925d1dc..1fa9109e2b31c 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h @@ -23,25 +23,22 @@ * *******/ -class HGCalTriggerFECodecBase { - public: - HGCalTriggerFECodecBase(const edm::ParameterSet& conf) : - geometry_(nullptr), - name_(conf.getParameter("CodecName")), - codec_idx_(static_cast(conf.getParameter("CodecIndex"))) - {} +class HGCalTriggerFECodecBase { +public: + HGCalTriggerFECodecBase(const edm::ParameterSet& conf) + : geometry_(nullptr), + name_(conf.getParameter("CodecName")), + codec_idx_(static_cast(conf.getParameter("CodecIndex"))) {} virtual ~HGCalTriggerFECodecBase() {} - const std::string& name() const { return name_; } - + const std::string& name() const { return name_; } + const unsigned char getCodecType() const { return codec_idx_; } - void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom;} - + void setGeometry(const HGCalTriggerGeometryBase* const geom) { geometry_ = geom; } + // give the FECodec the input digis and it sets itself // with the approprate data - virtual void setDataPayload(const HGCalDigiCollection&, - const HGCalDigiCollection&, - const HGCalDigiCollection& ) = 0; + virtual void setDataPayload(const HGCalDigiCollection&, const HGCalDigiCollection&, const HGCalDigiCollection&) = 0; virtual void setDataPayload(const l1t::HGCFETriggerDigi&) = 0; virtual void unSetDataPayload() = 0; // get the set data out for your own enjoyment @@ -51,73 +48,65 @@ class HGCalTriggerFECodecBase { // these will yell at you if you haven't set the data in the Codec class virtual void encode(l1t::HGCFETriggerDigi&) = 0; virtual void decode(const l1t::HGCFETriggerDigi&) = 0; - virtual void print(const l1t::HGCFETriggerDigi& digi, - std::ostream& out = std::cout) const = 0; + virtual void print(const l1t::HGCFETriggerDigi& digi, std::ostream& out = std::cout) const = 0; - protected: +protected: const HGCalTriggerGeometryBase* geometry_; - private: +private: const std::string name_; - unsigned char codec_idx_; // I hope we never come to having 256 FE codecs :-) + unsigned char codec_idx_; // I hope we never come to having 256 FE codecs :-) }; // ----> all codec classes derive from this <---- // inheritance looks like class MyCodec : public HGCalTriggerFE::Codec namespace HGCalTriggerFE { - template - class Codec : public HGCalTriggerFECodecBase { + template + class Codec : public HGCalTriggerFECodecBase { public: - Codec(const edm::ParameterSet& conf) : - HGCalTriggerFECodecBase(conf), - dataIsSet_(false) { - } - - // mark these as final since at this level we know + Codec(const edm::ParameterSet& conf) : HGCalTriggerFECodecBase(conf), dataIsSet_(false) {} + + // mark these as final since at this level we know // the implementation of the codec void encode(l1t::HGCFETriggerDigi& digi) final { - if( !dataIsSet_ ) { + if (!dataIsSet_) { edm::LogWarning("HGCalTriggerFECodec|NoDataPayload") - << "No data payload was set for HGCTriggerFECodec: " - << this->name(); + << "No data payload was set for HGCTriggerFECodec: " << this->name(); } - digi.encode(static_cast(*this),data_); + digi.encode(static_cast(*this), data_); } void decode(const l1t::HGCFETriggerDigi& digi) final { - if( dataIsSet_ ) { + if (dataIsSet_) { edm::LogWarning("HGCalTriggerFECodec|OverwritePayload") - << "Data payload was already set for HGCTriggerFECodec: " - << this->name() << " overwriting current data!"; + << "Data payload was already set for HGCTriggerFECodec: " << this->name() << " overwriting current data!"; } - digi.decode(static_cast(*this),data_); + digi.decode(static_cast(*this), data_); dataIsSet_ = true; - } - - void setDataPayload(const HGCalDigiCollection& ee, - const HGCalDigiCollection& fh, - const HGCalDigiCollection& bh ) final { - if( dataIsSet_ ) { + } + + void setDataPayload(const HGCalDigiCollection& ee, + const HGCalDigiCollection& fh, + const HGCalDigiCollection& bh) final { + if (dataIsSet_) { edm::LogWarning("HGCalTriggerFECodec|OverwritePayload") - << "Data payload was already set for HGCTriggerFECodec: " - << this->name() << " overwriting current data!"; + << "Data payload was already set for HGCTriggerFECodec: " << this->name() << " overwriting current data!"; } - if(geometry_==nullptr) { + if (geometry_ == nullptr) { throw cms::Exception("HGCTriggerBadInitialization") - << "The HGC trigger geometry has not been passed to the front-end codec\n"; + << "The HGC trigger geometry has not been passed to the front-end codec\n"; } - static_cast(*this).setDataPayloadImpl(ee,fh,bh); + static_cast(*this).setDataPayloadImpl(ee, fh, bh); dataIsSet_ = true; } void setDataPayload(const l1t::HGCFETriggerDigi& digi) final { - if( dataIsSet_ ) { + if (dataIsSet_) { edm::LogWarning("HGCalTriggerFECodec|OverwritePayload") - << "Data payload was already set for HGCTriggerFECodec: " - << this->name() << " overwriting current data!"; + << "Data payload was already set for HGCTriggerFECodec: " << this->name() << " overwriting current data!"; } - if(geometry_==nullptr) { + if (geometry_ == nullptr) { throw cms::Exception("HGCTriggerBadInitialization") - << "The HGC trigger geometry has not been passed to the front-end codec\n"; + << "The HGC trigger geometry has not been passed to the front-end codec\n"; } static_cast(*this).setDataPayloadImpl(digi); dataIsSet_ = true; @@ -127,39 +116,37 @@ namespace HGCalTriggerFE { data_.reset(); dataIsSet_ = false; } - std::vector getDataPayload() const final { - return this->encode(data_); - } - - void print(const l1t::HGCFETriggerDigi& digi, - std::ostream& out = std::cout) const final { - digi.print(static_cast(*this),out); + std::vector getDataPayload() const final { return this->encode(data_); } + + void print(const l1t::HGCFETriggerDigi& digi, std::ostream& out = std::cout) const final { + digi.print(static_cast(*this), out); } std::vector encode(const DATA& data) const { - if(geometry_==nullptr) { + if (geometry_ == nullptr) { throw cms::Exception("HGCTriggerBadInitialization") - << "The HGC trigger geometry has not been passed to the front-end codec\n"; + << "The HGC trigger geometry has not been passed to the front-end codec\n"; } return static_cast(*this).encodeImpl(data); } - DATA decode(const std::vector& data, const uint32_t module=0) const { - if(geometry_==nullptr) { + DATA decode(const std::vector& data, const uint32_t module = 0) const { + if (geometry_ == nullptr) { throw cms::Exception("HGCTriggerBadInitialization") - << "The HGC trigger geometry has not been passed to the front-end codec\n"; + << "The HGC trigger geometry has not been passed to the front-end codec\n"; } return static_cast(*this).decodeImpl(data, module); - } + } - protected: + protected: DATA data_; + private: bool dataIsSet_; }; -} +} // namespace HGCalTriggerFE #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalTriggerFECodecBase* (const edm::ParameterSet&) > HGCalTriggerFECodecFactory; +typedef edmplugin::PluginFactory HGCalTriggerFECodecFactory; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h b/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h index 88a8911aebc04..49a9573b6a218 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h @@ -15,104 +15,94 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" - - // Pure virtual trigger geometry class // Provides the interface to access trigger cell and module mappings -class HGCalTriggerGeometryBase -{ - public: - typedef std::unordered_map geom_map; - typedef std::unordered_set geom_set; - typedef std::set geom_ordered_set; - - HGCalTriggerGeometryBase(const edm::ParameterSet& conf); - virtual ~HGCalTriggerGeometryBase() {} - - const std::string& name() const { return name_; } - - bool isV9Geometry() const {return !calo_geometry_.isValid();} - const edm::ESHandle& caloGeometry() const {return calo_geometry_;} - const HGCalGeometry* eeGeometry() const - { - return ( hgc_ee_geometry_.isValid() ? hgc_ee_geometry_.product() : (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Forward,HGCEE))) ); - } - const HGCalGeometry* fhGeometry() const - { - return (hgc_hsi_geometry_.isValid() ? hgc_hsi_geometry_.product() : (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Forward,HGCHEF))) ); - } - const HcalGeometry* bhGeometry() const - { - if(hgc_hsc_geometry_.isValid()) - { - throw cms::Exception("HGCalTriggerGeometry") - << "bhGeometry cannot be used with the V9 geometry"; - } - return (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Hcal,HcalEndcap))); - } - const HGCalGeometry* hsiGeometry() const {return fhGeometry();} - const HGCalGeometry* hscGeometry() const - { - if(!hgc_hsc_geometry_.isValid()) - { - throw cms::Exception("HGCalTriggerGeometry") - << "hscGeometry cannot be used with the V7 and V8 geometries"; - } - return hgc_hsc_geometry_.product(); - } - const HGCalTopology& eeTopology() const {return eeGeometry()->topology();} - const HGCalTopology& fhTopology() const {return fhGeometry()->topology();} - const HcalTopology& bhTopology() const {return bhGeometry()->topology();} - const HGCalTopology& hsiTopology() const {return hsiGeometry()->topology();} - const HGCalTopology& hscTopology() const {return hscGeometry()->topology();} - - // non-const access to the geometry class - virtual void initialize(const edm::ESHandle&) = 0; - virtual void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) = 0; - virtual void reset(); - - // const access to the geometry class - virtual unsigned getTriggerCellFromCell( const unsigned cell_det_id ) const = 0; - virtual unsigned getModuleFromCell( const unsigned cell_det_id ) const = 0; - virtual unsigned getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const = 0; - - virtual geom_set getCellsFromTriggerCell( const unsigned cell_det_id ) const = 0; - virtual geom_set getCellsFromModule( const unsigned cell_det_id ) const = 0; - virtual geom_set getTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const = 0; - - virtual geom_ordered_set getOrderedCellsFromModule( const unsigned cell_det_id ) const = 0; - virtual geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const = 0; - - virtual geom_set getNeighborsFromTriggerCell( const unsigned trigger_cell_det_id ) const = 0; - - virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const = 0; - virtual GlobalPoint getModulePosition(const unsigned module_det_id) const = 0; - - virtual bool validTriggerCell( const unsigned trigger_cell_id) const = 0; - virtual bool disconnectedModule(const unsigned module_id) const = 0; - virtual unsigned triggerLayer(const unsigned id) const = 0; - - protected: - void setCaloGeometry(const edm::ESHandle& geom) {calo_geometry_=geom;} - void setEEGeometry(const edm::ESHandle& geom) {hgc_ee_geometry_=geom;} - void setHSiGeometry(const edm::ESHandle& geom) {hgc_hsi_geometry_=geom;} - void setHScGeometry(const edm::ESHandle& geom) {hgc_hsc_geometry_=geom;} - - - private: - const std::string name_; - - edm::ESHandle calo_geometry_; - edm::ESHandle hgc_ee_geometry_; - edm::ESHandle hgc_hsi_geometry_; - edm::ESHandle hgc_hsc_geometry_; - +class HGCalTriggerGeometryBase { +public: + typedef std::unordered_map geom_map; + typedef std::unordered_set geom_set; + typedef std::set geom_ordered_set; + + HGCalTriggerGeometryBase(const edm::ParameterSet& conf); + virtual ~HGCalTriggerGeometryBase() {} + + const std::string& name() const { return name_; } + + bool isV9Geometry() const { return !calo_geometry_.isValid(); } + const edm::ESHandle& caloGeometry() const { return calo_geometry_; } + const HGCalGeometry* eeGeometry() const { + return (hgc_ee_geometry_.isValid() + ? hgc_ee_geometry_.product() + : (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Forward, HGCEE)))); + } + const HGCalGeometry* fhGeometry() const { + return (hgc_hsi_geometry_.isValid() + ? hgc_hsi_geometry_.product() + : (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Forward, HGCHEF)))); + } + const HcalGeometry* bhGeometry() const { + if (hgc_hsc_geometry_.isValid()) { + throw cms::Exception("HGCalTriggerGeometry") << "bhGeometry cannot be used with the V9 geometry"; + } + return (static_cast(calo_geometry_->getSubdetectorGeometry(DetId::Hcal, HcalEndcap))); + } + const HGCalGeometry* hsiGeometry() const { return fhGeometry(); } + const HGCalGeometry* hscGeometry() const { + if (!hgc_hsc_geometry_.isValid()) { + throw cms::Exception("HGCalTriggerGeometry") << "hscGeometry cannot be used with the V7 and V8 geometries"; + } + return hgc_hsc_geometry_.product(); + } + const HGCalTopology& eeTopology() const { return eeGeometry()->topology(); } + const HGCalTopology& fhTopology() const { return fhGeometry()->topology(); } + const HcalTopology& bhTopology() const { return bhGeometry()->topology(); } + const HGCalTopology& hsiTopology() const { return hsiGeometry()->topology(); } + const HGCalTopology& hscTopology() const { return hscGeometry()->topology(); } + + // non-const access to the geometry class + virtual void initialize(const edm::ESHandle&) = 0; + virtual void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) = 0; + virtual void reset(); + + // const access to the geometry class + virtual unsigned getTriggerCellFromCell(const unsigned cell_det_id) const = 0; + virtual unsigned getModuleFromCell(const unsigned cell_det_id) const = 0; + virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const = 0; + + virtual geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const = 0; + virtual geom_set getCellsFromModule(const unsigned cell_det_id) const = 0; + virtual geom_set getTriggerCellsFromModule(const unsigned trigger_cell_det_id) const = 0; + + virtual geom_ordered_set getOrderedCellsFromModule(const unsigned cell_det_id) const = 0; + virtual geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const = 0; + + virtual geom_set getNeighborsFromTriggerCell(const unsigned trigger_cell_det_id) const = 0; + + virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const = 0; + virtual GlobalPoint getModulePosition(const unsigned module_det_id) const = 0; + + virtual bool validTriggerCell(const unsigned trigger_cell_id) const = 0; + virtual bool disconnectedModule(const unsigned module_id) const = 0; + virtual unsigned triggerLayer(const unsigned id) const = 0; + +protected: + void setCaloGeometry(const edm::ESHandle& geom) { calo_geometry_ = geom; } + void setEEGeometry(const edm::ESHandle& geom) { hgc_ee_geometry_ = geom; } + void setHSiGeometry(const edm::ESHandle& geom) { hgc_hsi_geometry_ = geom; } + void setHScGeometry(const edm::ESHandle& geom) { hgc_hsc_geometry_ = geom; } + +private: + const std::string name_; + + edm::ESHandle calo_geometry_; + edm::ESHandle hgc_ee_geometry_; + edm::ESHandle hgc_hsi_geometry_; + edm::ESHandle hgc_hsc_geometry_; }; #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalTriggerGeometryBase* (const edm::ParameterSet&) > HGCalTriggerGeometryFactory; - +typedef edmplugin::PluginFactory HGCalTriggerGeometryFactory; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h b/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h index 5f66d4bfd5653..0a20ca1f10008 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h @@ -33,23 +33,15 @@ namespace HGCalTriggerGeometry { public: typedef std::unordered_set list_type; - TriggerCell(unsigned tc_id, unsigned mod_id, const GlobalPoint& pos, - const list_type& neighbs, const list_type& comps) : - trigger_cell_id_(tc_id), - module_id_(mod_id), - position_(pos), - neighbours_(neighbs), - components_(comps) - {} + TriggerCell( + unsigned tc_id, unsigned mod_id, const GlobalPoint& pos, const list_type& neighbs, const list_type& comps) + : trigger_cell_id_(tc_id), module_id_(mod_id), position_(pos), neighbours_(neighbs), components_(comps) {} ~TriggerCell() {} - - + unsigned triggerCellId() const { return trigger_cell_id_; } - unsigned moduleId() const { return module_id_; } - - bool containsCell(const unsigned cell) const { - return ( components_.find(cell) != components_.end() ); - } + unsigned moduleId() const { return module_id_; } + + bool containsCell(const unsigned cell) const { return (components_.find(cell) != components_.end()); } const GlobalPoint& position() const { return position_; } @@ -57,38 +49,36 @@ namespace HGCalTriggerGeometry { const std::unordered_set& components() const { return components_; } private: - unsigned trigger_cell_id_; // the ID of this trigger cell - unsigned module_id_; // module this TC belongs to + unsigned trigger_cell_id_; // the ID of this trigger cell + unsigned module_id_; // module this TC belongs to GlobalPoint position_; - list_type neighbours_; // neighbouring trigger cells - list_type components_; // contained HGC cells + list_type neighbours_; // neighbouring trigger cells + list_type components_; // contained HGC cells }; - + class Module { public: typedef std::unordered_set list_type; - typedef std::unordered_multimap tc_map_type; - - Module(unsigned mod_id, const GlobalPoint& pos, - const list_type& neighbs, const list_type& comps, - const tc_map_type& tc_comps): - module_id_(mod_id), - position_(pos), - neighbours_(neighbs), - components_(comps), - tc_components_(tc_comps) - {} + typedef std::unordered_multimap tc_map_type; + + Module(unsigned mod_id, + const GlobalPoint& pos, + const list_type& neighbs, + const list_type& comps, + const tc_map_type& tc_comps) + : module_id_(mod_id), position_(pos), neighbours_(neighbs), components_(comps), tc_components_(tc_comps) {} ~Module() {} - - unsigned moduleId() const { return module_id_; } + + unsigned moduleId() const { return module_id_; } bool containsTriggerCell(const unsigned trig_cell) const { - return ( components_.find(trig_cell) != components_.end() ); + return (components_.find(trig_cell) != components_.end()); } bool containsCell(const unsigned cell) const { - for( const auto& value : tc_components_ ) { - if( value.second == cell ) return true; + for (const auto& value : tc_components_) { + if (value.second == cell) + return true; } return false; } @@ -100,55 +90,52 @@ namespace HGCalTriggerGeometry { const tc_map_type& triggerCellComponents() const { return tc_components_; } - private: - unsigned module_id_; // module this TC belongs to + private: + unsigned module_id_; // module this TC belongs to GlobalPoint position_; - list_type neighbours_; // neighbouring Modules - list_type components_; // contained HGC trigger cells - tc_map_type tc_components_; // cells contained by trigger cells + list_type neighbours_; // neighbouring Modules + list_type components_; // contained HGC trigger cells + tc_map_type tc_components_; // cells contained by trigger cells }; -} - -class HGCalTriggerGeometryGenericMapping : public HGCalTriggerGeometryBase { - public: +} // namespace HGCalTriggerGeometry - typedef std::unordered_map > module_map; - typedef std::unordered_map > trigger_cell_map; +class HGCalTriggerGeometryGenericMapping : public HGCalTriggerGeometryBase { +public: + typedef std::unordered_map > module_map; + typedef std::unordered_map > trigger_cell_map; HGCalTriggerGeometryGenericMapping(const edm::ParameterSet& conf); ~HGCalTriggerGeometryGenericMapping() override {} // non-const access to the geometry class void reset() final; - - unsigned getTriggerCellFromCell( const unsigned cell_det_id ) const final; - unsigned getModuleFromCell( const unsigned cell_det_id ) const final; - unsigned getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const final; - geom_set getCellsFromTriggerCell( const unsigned cell_det_id ) const final; - geom_set getCellsFromModule( const unsigned cell_det_id ) const final; - geom_set getTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const final; + unsigned getTriggerCellFromCell(const unsigned cell_det_id) const final; + unsigned getModuleFromCell(const unsigned cell_det_id) const final; + unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const final; + + geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const final; + geom_set getCellsFromModule(const unsigned cell_det_id) const final; + geom_set getTriggerCellsFromModule(const unsigned trigger_cell_det_id) const final; - geom_ordered_set getOrderedCellsFromModule( const unsigned cell_det_id ) const final; - geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const final; + geom_ordered_set getOrderedCellsFromModule(const unsigned cell_det_id) const final; + geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const final; - geom_set getNeighborsFromTriggerCell( const unsigned trigger_cell_det_id ) const final; + geom_set getNeighborsFromTriggerCell(const unsigned trigger_cell_det_id) const final; GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const final; GlobalPoint getModulePosition(const unsigned module_det_id) const final; - bool validTriggerCell( const unsigned trigger_cell_det_id ) const final; + bool validTriggerCell(const unsigned trigger_cell_det_id) const final; bool disconnectedModule(const unsigned module_id) const final; unsigned triggerLayer(const unsigned id) const final; - protected: +protected: geom_map cells_to_trigger_cells_; geom_map trigger_cells_to_modules_; - + module_map modules_; trigger_cell_map trigger_cells_; - }; - #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h b/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h index d24140284194d..6ff8525be4d23 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerTools.h @@ -12,7 +12,6 @@ * \author G. Cerminara (CERN), heavily "inspired" by HGCalRechHitTools ;) */ - #include #include #include @@ -27,73 +26,70 @@ class HGCalTriggerGeometryBase; class DetId; - namespace edm { class Event; class EventSetup; -} +} // namespace edm class HGCalTriggerTools { - public: - HGCalTriggerTools() : geom_(nullptr), - eeLayers_(0), fhLayers_(0), bhLayers_(0), totalLayers_(0){} - ~HGCalTriggerTools() {} - - void eventSetup(const edm::EventSetup&); - GlobalPoint getTCPosition(const DetId& id) const; - unsigned layers(ForwardSubdetector type) const; - unsigned layers(DetId::Detector type) const ; - unsigned layer(const DetId&) const; - unsigned layerWithOffset(const DetId&) const; - bool isEm(const DetId&) const; - bool isHad(const DetId& id) const {return !isEm(id);} - bool isSilicon(const DetId&) const; - bool isScintillator(const DetId& id) const {return !isSilicon(id);} - int zside(const DetId&) const; - // tc argument is needed because of the impossibility - // to know whether the ID is a TC or a sensor cell - // in the v8 geometry detid scheme - int thicknessIndex(const DetId&, bool tc=false) const; - - unsigned lastLayerEE() const {return eeLayers_;} - unsigned lastLayerFH() const {return eeLayers_+fhLayers_;} - unsigned lastLayerBH() const {return totalLayers_;} - - // 4-vector helper functions using GlobalPoint - float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const; - float getPhi(const GlobalPoint& position) const; - float getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z = 0.) const; - - // 4-vector helper functions using DetId - float getTCEta(const DetId& id, const float& vertex_z = 0.) const; - float getTCPhi(const DetId& id) const; - float getTCPt(const DetId& id, const float& hitEnergy, const float& vertex_z = 0.) const; - - inline const HGCalTriggerGeometryBase * getTriggerGeometry() const {return geom_;}; - - float getLayerZ(const unsigned& layerWithOffset) const; - float getLayerZ(const int& subdet, const unsigned& layer) const; - - template - std::vector bxVectorToVector(const BXVector& inputBXVector){ - std::vector outputVector; - //loop over collection for a given bx and put the objects into a std::vector - outputVector.insert(outputVector.end(), inputBXVector.begin(0), inputBXVector.end(0)); - return outputVector; - } - - DetId simToReco(const DetId&, const HGCalTopology&) const ; - DetId simToReco(const DetId&, const HcalTopology&) const ; - - private: - const HGCalTriggerGeometryBase* geom_; - unsigned eeLayers_; - unsigned fhLayers_; - unsigned bhLayers_; - unsigned totalLayers_; - - int sensorCellThicknessV8(const DetId& id) const; +public: + HGCalTriggerTools() : geom_(nullptr), eeLayers_(0), fhLayers_(0), bhLayers_(0), totalLayers_(0) {} + ~HGCalTriggerTools() {} + + void eventSetup(const edm::EventSetup&); + GlobalPoint getTCPosition(const DetId& id) const; + unsigned layers(ForwardSubdetector type) const; + unsigned layers(DetId::Detector type) const; + unsigned layer(const DetId&) const; + unsigned layerWithOffset(const DetId&) const; + bool isEm(const DetId&) const; + bool isHad(const DetId& id) const { return !isEm(id); } + bool isSilicon(const DetId&) const; + bool isScintillator(const DetId& id) const { return !isSilicon(id); } + int zside(const DetId&) const; + // tc argument is needed because of the impossibility + // to know whether the ID is a TC or a sensor cell + // in the v8 geometry detid scheme + int thicknessIndex(const DetId&, bool tc = false) const; + + unsigned lastLayerEE() const { return eeLayers_; } + unsigned lastLayerFH() const { return eeLayers_ + fhLayers_; } + unsigned lastLayerBH() const { return totalLayers_; } + + // 4-vector helper functions using GlobalPoint + float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const; + float getPhi(const GlobalPoint& position) const; + float getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z = 0.) const; + + // 4-vector helper functions using DetId + float getTCEta(const DetId& id, const float& vertex_z = 0.) const; + float getTCPhi(const DetId& id) const; + float getTCPt(const DetId& id, const float& hitEnergy, const float& vertex_z = 0.) const; + + inline const HGCalTriggerGeometryBase* getTriggerGeometry() const { return geom_; }; + + float getLayerZ(const unsigned& layerWithOffset) const; + float getLayerZ(const int& subdet, const unsigned& layer) const; + + template + std::vector bxVectorToVector(const BXVector& inputBXVector) { + std::vector outputVector; + //loop over collection for a given bx and put the objects into a std::vector + outputVector.insert(outputVector.end(), inputBXVector.begin(0), inputBXVector.end(0)); + return outputVector; + } + + DetId simToReco(const DetId&, const HGCalTopology&) const; + DetId simToReco(const DetId&, const HcalTopology&) const; + +private: + const HGCalTriggerGeometryBase* geom_; + unsigned eeLayers_; + unsigned fhLayers_; + unsigned bhLayers_; + unsigned totalLayers_; + + int sensorCellThicknessV8(const DetId& id) const; }; - #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h b/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h index 0ff56926d1d36..90bd5b32fd370 100644 --- a/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h +++ b/L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h @@ -20,42 +20,35 @@ namespace l1t { class HGCalTowerID; struct HGCalTowerCoord; -} - +} // namespace l1t class HGCalTriggerTowerGeometryHelper { - public: - HGCalTriggerTowerGeometryHelper(const edm::ParameterSet& conf); - - ~HGCalTriggerTowerGeometryHelper() {} - - void eventSetup(const edm::EventSetup& es) - { - triggerTools_.eventSetup(es); - } - - const std::vector& getTowerCoordinates() const; +public: + HGCalTriggerTowerGeometryHelper(const edm::ParameterSet& conf); - unsigned short getTriggerTowerFromTriggerCell(const unsigned tcId, const float& eta, const float& phi) const; + ~HGCalTriggerTowerGeometryHelper() {} - private: + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } - std::vector tower_coords_; - std::unordered_map cells_to_trigger_towers_; + const std::vector& getTowerCoordinates() const; - double minEta_; - double maxEta_; - double minPhi_; - double maxPhi_; - unsigned int nBinsEta_; - unsigned int nBinsPhi_; + unsigned short getTriggerTowerFromTriggerCell(const unsigned tcId, const float& eta, const float& phi) const; - std::vector binsEta_; - std::vector binsPhi_; +private: + std::vector tower_coords_; + std::unordered_map cells_to_trigger_towers_; - HGCalTriggerTools triggerTools_; + double minEta_; + double maxEta_; + double minPhi_; + double maxPhi_; + unsigned int nBinsEta_; + unsigned int nBinsPhi_; - }; + std::vector binsEta_; + std::vector binsPhi_; + HGCalTriggerTools triggerTools_; +}; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h index 2b37a3f836c9c..fae1512ef4af8 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h @@ -1,7 +1,7 @@ #ifndef __L1Trigger_L1THGCal_HGCalClusteringDummyImpl_h__ #define __L1Trigger_L1THGCal_HGCalClusteringDummyImpl_h__ -#include +#include #include #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" @@ -10,32 +10,22 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - - -class HGCalClusteringDummyImpl{ - - +class HGCalClusteringDummyImpl { public: - - HGCalClusteringDummyImpl( const edm::ParameterSet & conf); - - void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} + HGCalClusteringDummyImpl(const edm::ParameterSet& conf); - void clusterizeDummy( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters - ); + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } - + void clusterizeDummy(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters); private: - - double calibSF_; - std::vector layerWeights_; - bool applyLayerWeights_; - HGCalTriggerTools triggerTools_; - - void calibratePt( l1t::HGCalCluster & cluster ); + double calibSF_; + std::vector layerWeights_; + bool applyLayerWeights_; + HGCalTriggerTools triggerTools_; + void calibratePt(l1t::HGCalCluster& cluster); }; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h index a41fd8bc24a02..cdf6f48005b75 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h @@ -1,7 +1,7 @@ #ifndef __L1Trigger_L1THGCal_HGCalClusteringImpl_h__ #define __L1Trigger_L1THGCal_HGCalClusteringImpl_h__ -#include +#include #include #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" @@ -10,76 +10,62 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" +bool distanceSorter(pair, float> i, pair, float> j) { + return (i.second < j.second); +} -bool distanceSorter (pair,float> i,pair,float> j) { return (i.second> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters - ); - - /* NN-algorithms */ - void mergeClusters( l1t::HGCalCluster & main_cluster, - const l1t::HGCalCluster & secondary_cluster ) const; - - void NNKernel( const std::vector> &reshuffledTriggerCells, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); - - void clusterizeNN( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); - - /* FW-algorithms */ - void clusterizeDRNN( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); - - + void clusterizeDR(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters); -private: - - double siliconSeedThreshold_; - double siliconTriggerCellThreshold_; - double scintillatorSeedThreshold_; - double scintillatorTriggerCellThreshold_; - double dr_; - std::string clusteringAlgorithmType_; - double calibSF_; - std::vector layerWeights_; - bool applyLayerWeights_; - HGCalTriggerTools triggerTools_; - - void triggerCellReshuffling( const std::vector> & triggerCellsPtrs, - std::array>>, kNSides_> & reshuffledTriggerCells ); - - bool areTCneighbour( uint32_t detIDa, uint32_t detIDb, const HGCalTriggerGeometryBase & triggerGeometry ); - - void removeUnconnectedTCinCluster( l1t::HGCalCluster & cluster, - const HGCalTriggerGeometryBase & triggerGeometry - ); - - void calibratePt( l1t::HGCalCluster & cluster ); + /* NN-algorithms */ + void mergeClusters(l1t::HGCalCluster& main_cluster, const l1t::HGCalCluster& secondary_cluster) const; + void NNKernel(const std::vector>& reshuffledTriggerCells, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry); + + void clusterizeNN(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry); + + /* FW-algorithms */ + void clusterizeDRNN(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry); + +private: + double siliconSeedThreshold_; + double siliconTriggerCellThreshold_; + double scintillatorSeedThreshold_; + double scintillatorTriggerCellThreshold_; + double dr_; + std::string clusteringAlgorithmType_; + double calibSF_; + std::vector layerWeights_; + bool applyLayerWeights_; + HGCalTriggerTools triggerTools_; + + void triggerCellReshuffling( + const std::vector>& triggerCellsPtrs, + std::array>>, kNSides_>& reshuffledTriggerCells); + + bool areTCneighbour(uint32_t detIDa, uint32_t detIDb, const HGCalTriggerGeometryBase& triggerGeometry); + + void removeUnconnectedTCinCluster(l1t::HGCalCluster& cluster, const HGCalTriggerGeometryBase& triggerGeometry); + + void calibratePt(l1t::HGCalCluster& cluster); }; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h index 4481d05661a61..2eda8df5ee4b4 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h @@ -11,63 +11,53 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" - -class HGCalHistoClusteringImpl{ - +class HGCalHistoClusteringImpl { public: - - HGCalHistoClusteringImpl( const edm::ParameterSet &conf); - - void eventSetup(const edm::EventSetup& es) - { - triggerTools_.eventSetup(es); - shape_.eventSetup(es); - if ( (!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size()-1) < triggerTools_.lastLayerBH()) - || (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size()-1) < triggerTools_.lastLayerBH()) - ) { - throw cms::Exception("Configuration") << - "The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size()-1) << - "(A) and " << (dr_byLayer_coefficientB_.size()-1) << "(B), while layers go up to " << triggerTools_.lastLayerBH() << "\n"; - } + HGCalHistoClusteringImpl(const edm::ParameterSet& conf); + + void eventSetup(const edm::EventSetup& es) { + triggerTools_.eventSetup(es); + shape_.eventSetup(es); + if ((!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size() - 1) < triggerTools_.lastLayerBH()) || + (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size() - 1) < triggerTools_.lastLayerBH())) { + throw cms::Exception("Configuration") + << "The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size() - 1) << "(A) and " + << (dr_byLayer_coefficientB_.size() - 1) << "(B), while layers go up to " << triggerTools_.lastLayerBH() + << "\n"; } + } - float dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed ) const; - - void clusterizeHisto( const std::vector> & clustersPtr, - const std::vector > & seedPositionsEnergy, - const HGCalTriggerGeometryBase & triggerGeometry, - l1t::HGCalMulticlusterBxCollection & multiclusters - ) const; + float dR(const l1t::HGCalCluster& clu, const GlobalPoint& seed) const; + void clusterizeHisto(const std::vector>& clustersPtr, + const std::vector>& seedPositionsEnergy, + const HGCalTriggerGeometryBase& triggerGeometry, + l1t::HGCalMulticlusterBxCollection& multiclusters) const; private: - enum ClusterAssociationStrategy{ - NearestNeighbour, - EnergySplit - }; + enum ClusterAssociationStrategy { NearestNeighbour, EnergySplit }; - std::vector clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector > & seeds) const; + std::vector clusterSeedMulticluster( + const std::vector>& clustersPtrs, + const std::vector>& seeds) const; - void finalizeClusters(std::vector&, - l1t::HGCalMulticlusterBxCollection&, - const HGCalTriggerGeometryBase&) const; - - double dr_; - std::vector dr_byLayer_coefficientA_; - std::vector dr_byLayer_coefficientB_; - double ptC3dThreshold_; + void finalizeClusters(std::vector&, + l1t::HGCalMulticlusterBxCollection&, + const HGCalTriggerGeometryBase&) const; - std::string cluster_association_input_; - ClusterAssociationStrategy cluster_association_strategy_; + double dr_; + std::vector dr_byLayer_coefficientA_; + std::vector dr_byLayer_coefficientB_; + double ptC3dThreshold_; - HGCalShowerShape shape_; - HGCalTriggerTools triggerTools_; - std::unique_ptr id_; + std::string cluster_association_input_; + ClusterAssociationStrategy cluster_association_strategy_; - static constexpr double kMidRadius_ = 2.3; + HGCalShowerShape shape_; + HGCalTriggerTools triggerTools_; + std::unique_ptr id_; + static constexpr double kMidRadius_ = 2.3; }; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h index 9fbc0583903d9..580bf689686c3 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h @@ -11,66 +11,50 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" - -class HGCalHistoSeedingImpl{ - +class HGCalHistoSeedingImpl { public: + HGCalHistoSeedingImpl(const edm::ParameterSet& conf); - HGCalHistoSeedingImpl( const edm::ParameterSet &conf); - - void eventSetup(const edm::EventSetup& es) - { - triggerTools_.eventSetup(es); - } - - float dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed ) const; + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } - void findHistoSeeds( const std::vector> & clustersPtr, - std::vector > & seedPositionsEnergy); + float dR(const l1t::HGCalCluster& clu, const GlobalPoint& seed) const; + void findHistoSeeds(const std::vector>& clustersPtr, + std::vector>& seedPositionsEnergy); private: - enum SeedingType{ - HistoMaxC3d, - HistoSecondaryMaxC3d, - HistoThresholdC3d, - HistoInterpolatedMaxC3d - }; + enum SeedingType { HistoMaxC3d, HistoSecondaryMaxC3d, HistoThresholdC3d, HistoInterpolatedMaxC3d }; - typedef std::map,float> Histogram; + typedef std::map, float> Histogram; - Histogram fillHistoClusters( const std::vector> & clustersPtrs ); + Histogram fillHistoClusters(const std::vector>& clustersPtrs); - Histogram fillSmoothPhiHistoClusters( const Histogram & histoClusters, - const vector & binSums ); + Histogram fillSmoothPhiHistoClusters(const Histogram& histoClusters, const vector& binSums); - Histogram fillSmoothRPhiHistoClusters( const Histogram & histoClusters ); + Histogram fillSmoothRPhiHistoClusters(const Histogram& histoClusters); - std::vector > computeMaxSeeds( const Histogram & histoClusters ); + std::vector> computeMaxSeeds(const Histogram& histoClusters); - std::vector > computeSecondaryMaxSeeds( const Histogram & histoClusters ); - - std::vector > computeInterpolatedMaxSeeds( const Histogram & histoClusters ); - - std::vector > computeThresholdSeeds( const Histogram & histoClusters ); + std::vector> computeSecondaryMaxSeeds(const Histogram& histoClusters); + std::vector> computeInterpolatedMaxSeeds(const Histogram& histoClusters); - std::string seedingAlgoType_; - SeedingType seedingType_; + std::vector> computeThresholdSeeds(const Histogram& histoClusters); - unsigned nBinsRHisto_ = 36; - unsigned nBinsPhiHisto_ = 216; - std::vector binsSumsHisto_; - double histoThreshold_ = 20.; - std::vector neighbour_weights_; + std::string seedingAlgoType_; + SeedingType seedingType_; - HGCalTriggerTools triggerTools_; + unsigned nBinsRHisto_ = 36; + unsigned nBinsPhiHisto_ = 216; + std::vector binsSumsHisto_; + double histoThreshold_ = 20.; + std::vector neighbour_weights_; - static constexpr unsigned neighbour_weights_size_ = 9; - static constexpr double kROverZMin_ = 0.09; - static constexpr double kROverZMax_ = 0.52; + HGCalTriggerTools triggerTools_; + static constexpr unsigned neighbour_weights_size_ = 9; + static constexpr double kROverZMin_ = 0.09; + static constexpr double kROverZMax_ = 0.52; }; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h index 5a1487a8fb796..62024a868490c 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h @@ -11,53 +11,43 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" - -class HGCalMulticlusteringImpl{ - +class HGCalMulticlusteringImpl { public: + HGCalMulticlusteringImpl(const edm::ParameterSet& conf); - HGCalMulticlusteringImpl( const edm::ParameterSet &conf); - - void eventSetup(const edm::EventSetup& es) - { - triggerTools_.eventSetup(es); - shape_.eventSetup(es); - } + void eventSetup(const edm::EventSetup& es) { + triggerTools_.eventSetup(es); + shape_.eventSetup(es); + } - bool isPertinent( const l1t::HGCalCluster & clu, - const l1t::HGCalMulticluster & mclu, - double dR ) const; + bool isPertinent(const l1t::HGCalCluster& clu, const l1t::HGCalMulticluster& mclu, double dR) const; - void clusterizeDR( const std::vector> & clustersPtr, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); + void clusterizeDR(const std::vector>& clustersPtr, + l1t::HGCalMulticlusterBxCollection& multiclusters, + const HGCalTriggerGeometryBase& triggerGeometry); - void clusterizeDBSCAN( const std::vector> & clustersPtr, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry - ); + void clusterizeDBSCAN(const std::vector>& clustersPtr, + l1t::HGCalMulticlusterBxCollection& multiclusters, + const HGCalTriggerGeometryBase& triggerGeometry); private: - - void findNeighbor( const std::vector>& rankedList, - unsigned int searchInd, - const std::vector> & clustersPtr, - std::vector& neigbors); - void finalizeClusters(std::vector&, - l1t::HGCalMulticlusterBxCollection&, - const HGCalTriggerGeometryBase&); - - double dr_; - double ptC3dThreshold_; - std::string multiclusterAlgoType_; - double distDbscan_ = 0.005; - unsigned minNDbscan_ = 3; - - HGCalShowerShape shape_; - HGCalTriggerTools triggerTools_; - std::unique_ptr id_; - + void findNeighbor(const std::vector>& rankedList, + unsigned int searchInd, + const std::vector>& clustersPtr, + std::vector& neigbors); + void finalizeClusters(std::vector&, + l1t::HGCalMulticlusterBxCollection&, + const HGCalTriggerGeometryBase&); + + double dr_; + double ptC3dThreshold_; + std::string multiclusterAlgoType_; + double distDbscan_ = 0.005; + unsigned minNDbscan_ = 3; + + HGCalShowerShape shape_; + HGCalTriggerTools triggerTools_; + std::unique_ptr id_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h index ba234be8a11c2..f1722fe34be81 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h @@ -9,78 +9,73 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "DataFormats/Math/interface/deltaPhi.h" -class HGCalShowerShape{ - - public: - typedef math::XYZTLorentzVector LorentzVector; - - HGCalShowerShape(){} - - ~HGCalShowerShape(){} - - void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} - - int firstLayer(const l1t::HGCalMulticluster& c3d) const; - int lastLayer(const l1t::HGCalMulticluster& c3d) const; - int maxLayer(const l1t::HGCalMulticluster& c3d) const; - int showerLength(const l1t::HGCalMulticluster& c3d) const {return lastLayer(c3d)-firstLayer(c3d)+1; }//in number of layers - // Maximum number of consecutive layers in the cluster - int coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const; - - float eMax(const l1t::HGCalMulticluster& c3d) const; - - float sigmaZZ(const l1t::HGCalMulticluster& c3d) const; - - float sigmaEtaEtaTot(const l1t::HGCalMulticluster& c3d) const; - float sigmaEtaEtaTot(const l1t::HGCalCluster& c2d) const; - float sigmaEtaEtaMax(const l1t::HGCalMulticluster& c3d) const; - - float sigmaPhiPhiTot(const l1t::HGCalMulticluster& c3d) const; - float sigmaPhiPhiTot(const l1t::HGCalCluster& c2d) const; - float sigmaPhiPhiMax(const l1t::HGCalMulticluster& c3d) const; - - float sigmaRRTot(const l1t::HGCalMulticluster& c3d) const; - float sigmaRRTot(const l1t::HGCalCluster& c2d) const; - float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const; - float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius=5.) const; - - void fillShapes(l1t::HGCalMulticluster&, const HGCalTriggerGeometryBase&) const; - - private: - - float meanX(const std::vector >& energy_X_tc) const; - // Compute energy-weighted RMS of any variable X in the cluster - // Delta(a,b) functor as template argument. Default is (a-b) - template> float sigmaXX( - const std::vector >& energy_X_tc, - const float X_cluster) const { - - Delta delta; - float Etot = 0; - float deltaX2_sum = 0; - for(const auto& energy_X : energy_X_tc){ - deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster),2); - Etot += energy_X.first; - } - float X_MSE = 0; - if (Etot>0) X_MSE=deltaX2_sum/Etot; - float X_RMS=sqrt(X_MSE); - return X_RMS; +class HGCalShowerShape { +public: + typedef math::XYZTLorentzVector LorentzVector; + + HGCalShowerShape() {} + + ~HGCalShowerShape() {} + + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + + int firstLayer(const l1t::HGCalMulticluster& c3d) const; + int lastLayer(const l1t::HGCalMulticluster& c3d) const; + int maxLayer(const l1t::HGCalMulticluster& c3d) const; + int showerLength(const l1t::HGCalMulticluster& c3d) const { + return lastLayer(c3d) - firstLayer(c3d) + 1; + } //in number of layers + // Maximum number of consecutive layers in the cluster + int coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const; + + float eMax(const l1t::HGCalMulticluster& c3d) const; + + float sigmaZZ(const l1t::HGCalMulticluster& c3d) const; + + float sigmaEtaEtaTot(const l1t::HGCalMulticluster& c3d) const; + float sigmaEtaEtaTot(const l1t::HGCalCluster& c2d) const; + float sigmaEtaEtaMax(const l1t::HGCalMulticluster& c3d) const; + + float sigmaPhiPhiTot(const l1t::HGCalMulticluster& c3d) const; + float sigmaPhiPhiTot(const l1t::HGCalCluster& c2d) const; + float sigmaPhiPhiMax(const l1t::HGCalMulticluster& c3d) const; + + float sigmaRRTot(const l1t::HGCalMulticluster& c3d) const; + float sigmaRRTot(const l1t::HGCalCluster& c2d) const; + float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const; + float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius = 5.) const; + + void fillShapes(l1t::HGCalMulticluster&, const HGCalTriggerGeometryBase&) const; + +private: + float meanX(const std::vector>& energy_X_tc) const; + // Compute energy-weighted RMS of any variable X in the cluster + // Delta(a,b) functor as template argument. Default is (a-b) + template > + float sigmaXX(const std::vector>& energy_X_tc, const float X_cluster) const { + Delta delta; + float Etot = 0; + float deltaX2_sum = 0; + for (const auto& energy_X : energy_X_tc) { + deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster), 2); + Etot += energy_X.first; } - // Special case of delta for phi - template struct DeltaPhi { - T operator() (const T& x, const T& y) const {return deltaPhi(x,y);} - }; - float sigmaPhiPhi( - const std::vector >& energy_phi_tc, - const float phi_cluster) const { - return sigmaXX>(energy_phi_tc,phi_cluster); - } - - HGCalTriggerTools triggerTools_; - + float X_MSE = 0; + if (Etot > 0) + X_MSE = deltaX2_sum / Etot; + float X_RMS = sqrt(X_MSE); + return X_RMS; + } + // Special case of delta for phi + template + struct DeltaPhi { + T operator()(const T& x, const T& y) const { return deltaPhi(x, y); } + }; + float sigmaPhiPhi(const std::vector>& energy_phi_tc, const float phi_cluster) const { + return sigmaXX>(energy_phi_tc, phi_cluster); + } + + HGCalTriggerTools triggerTools_; }; - #endif - diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h index 839ac826e53b8..fb44e11df337f 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h @@ -10,35 +10,27 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTowerGeometryHelper.h" - -class HGCalTowerMap2DImpl{ - - public: - - HGCalTowerMap2DImpl( const edm::ParameterSet &conf); +class HGCalTowerMap2DImpl { +public: + HGCalTowerMap2DImpl(const edm::ParameterSet& conf); void resetTowerMaps(); - void buildTowerMap2D(const std::vector> & triggerCellsPtrs, - l1t::HGCalTowerMapBxCollection & towermaps); - + void buildTowerMap2D(const std::vector>& triggerCellsPtrs, + l1t::HGCalTowerMapBxCollection& towermaps); void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - towerGeometryHelper_.eventSetup(es); + triggerTools_.eventSetup(es); + towerGeometryHelper_.eventSetup(es); } - private: - +private: bool useLayerWeights_; std::vector layerWeights_; HGCalTriggerTools triggerTools_; std::unordered_map newTowerMaps(); HGCalTriggerTowerGeometryHelper towerGeometryHelper_; - }; - - #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h index 14c31224f3770..f1901cb0d54d0 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h @@ -7,18 +7,12 @@ #include "DataFormats/L1THGCal/interface/HGCalTowerMap.h" #include "DataFormats/L1THGCal/interface/HGCalTower.h" +class HGCalTowerMap3DImpl { +public: + HGCalTowerMap3DImpl(); -class HGCalTowerMap3DImpl{ - - public: - - HGCalTowerMap3DImpl( ); - - void buildTowerMap3D(const std::vector> & towerMaps2D, - l1t::HGCalTowerBxCollection & towerMap); - + void buildTowerMap3D(const std::vector>& towerMaps2D, + l1t::HGCalTowerBxCollection& towerMap); }; - - #endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h b/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h index a668252abbe37..ac630527dceea 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h @@ -4,23 +4,18 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" - -class HGCalTriggerClusterIdentificationBase -{ - public: - HGCalTriggerClusterIdentificationBase() {}; - virtual ~HGCalTriggerClusterIdentificationBase(){}; - virtual void initialize(const edm::ParameterSet& conf) = 0; - virtual float value(const l1t::HGCalMulticluster& cluster) const = 0; - virtual bool decision(const l1t::HGCalMulticluster& cluster) const = 0; - +class HGCalTriggerClusterIdentificationBase { +public: + HGCalTriggerClusterIdentificationBase(){}; + virtual ~HGCalTriggerClusterIdentificationBase(){}; + virtual void initialize(const edm::ParameterSet& conf) = 0; + virtual float value(const l1t::HGCalMulticluster& cluster) const = 0; + virtual bool decision(const l1t::HGCalMulticluster& cluster) const = 0; }; #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalTriggerClusterIdentificationBase* () > HGCalTriggerClusterIdentificationFactory; - -#define DEFINE_HGC_TPG_CLUSTER_ID(type,name) \ - DEFINE_EDM_PLUGIN (HGCalTriggerClusterIdentificationFactory,type,name) +typedef edmplugin::PluginFactory HGCalTriggerClusterIdentificationFactory; +#define DEFINE_HGC_TPG_CLUSTER_ID(type, name) DEFINE_EDM_PLUGIN(HGCalTriggerClusterIdentificationFactory, type, name) #endif diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h index e301f559ca1e4..78ac2ac990c38 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorProcessorSelection.h @@ -9,29 +9,24 @@ #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h" -class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBase -{ - - private: - enum SelectionType{ - thresholdSelect, - bestChoiceSelect, - superTriggerCellSelect - }; - - public: - HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf); - - void run(const edm::Handle& triggerCellCollInput, l1t::HGCalTriggerCellBxCollection& triggerCellCollOutput, const edm::EventSetup& es) override; - - private: - SelectionType selectionType_; - - std::unique_ptr concentratorProcImpl_; - std::unique_ptr concentratorSTCImpl_; - - HGCalTriggerTools triggerTools_; +class HGCalConcentratorProcessorSelection : public HGCalConcentratorProcessorBase { +private: + enum SelectionType { thresholdSelect, bestChoiceSelect, superTriggerCellSelect }; +public: + HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf); + + void run(const edm::Handle& triggerCellCollInput, + l1t::HGCalTriggerCellBxCollection& triggerCellCollOutput, + const edm::EventSetup& es) override; + +private: + SelectionType selectionType_; + + std::unique_ptr concentratorProcImpl_; + std::unique_ptr concentratorSTCImpl_; + + HGCalTriggerTools triggerTools_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSelectionImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSelectionImpl.h index 7eed56581be30..9c8a6fc6595e1 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSelectionImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSelectionImpl.h @@ -12,46 +12,43 @@ #include #include -class HGCalConcentratorSelectionImpl -{ - - public: - HGCalConcentratorSelectionImpl(const edm::ParameterSet& conf); - - void bestChoiceSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); - void thresholdSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); - - // Retrieve parameters - size_t nCellsInModule() const {return nCellsInModule_;} - double linLSB() const {return linLSB_;} - size_t nData() const {return nData_;} - double adcsaturationBH() const {return adcsaturationBH_;} - uint32_t adcnBitsBH() const {return adcnBitsBH_;} - int TCThreshold_ADC() const {return TCThreshold_ADC_;} - double TCThreshold_fC() const {return TCThreshold_fC_;} - int TCThresholdBH_ADC() const {return TCThresholdBH_ADC_;} - double TCThresholdBH_MIP() const {return TCThresholdBH_MIP_;} - - void eventSetup(const edm::EventSetup& es) { - triggerTools_.eventSetup(es); - } - - private: - - size_t nData_; - size_t nCellsInModule_; - double linLSB_; - double adcsaturationBH_; - uint32_t adcnBitsBH_; - double adcLSBBH_; - int TCThreshold_ADC_; - double TCThreshold_fC_; - int TCThresholdBH_ADC_; - double TCThresholdBH_MIP_; - double triggercell_threshold_silicon_; - double triggercell_threshold_scintillator_; - - HGCalTriggerTools triggerTools_; +class HGCalConcentratorSelectionImpl { +public: + HGCalConcentratorSelectionImpl(const edm::ParameterSet& conf); + + void bestChoiceSelectImpl(const std::vector& trigCellVecInput, + std::vector& trigCellVecOutput); + void thresholdSelectImpl(const std::vector& trigCellVecInput, + std::vector& trigCellVecOutput); + + // Retrieve parameters + size_t nCellsInModule() const { return nCellsInModule_; } + double linLSB() const { return linLSB_; } + size_t nData() const { return nData_; } + double adcsaturationBH() const { return adcsaturationBH_; } + uint32_t adcnBitsBH() const { return adcnBitsBH_; } + int TCThreshold_ADC() const { return TCThreshold_ADC_; } + double TCThreshold_fC() const { return TCThreshold_fC_; } + int TCThresholdBH_ADC() const { return TCThresholdBH_ADC_; } + double TCThresholdBH_MIP() const { return TCThresholdBH_MIP_; } + + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + +private: + size_t nData_; + size_t nCellsInModule_; + double linLSB_; + double adcsaturationBH_; + uint32_t adcnBitsBH_; + double adcLSBBH_; + int TCThreshold_ADC_; + double TCThreshold_fC_; + int TCThresholdBH_ADC_; + double TCThresholdBH_MIP_; + double triggercell_threshold_silicon_; + double triggercell_threshold_scintillator_; + + HGCalTriggerTools triggerTools_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h index f12504dc447de..72ed657f7dd4e 100644 --- a/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h +++ b/L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSuperTriggerCellImpl.h @@ -10,66 +10,60 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - - #include #include -class HGCalConcentratorSuperTriggerCellImpl -{ - public: - HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf); - - void superTriggerCellSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput); - void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} +class HGCalConcentratorSuperTriggerCellImpl { +public: + HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf); - private: + void superTriggerCellSelectImpl(const std::vector& trigCellVecInput, + std::vector& trigCellVecOutput); + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } - int getSuperTriggerCellId(int detid) const ; - static std::map kSplit_; - static const int kWafer_offset_ = 6; - static const int kSTCsizeCoarse_ = 16; - static const int kSTCsizeFine_ = 4; - static const int kSplit_v8_Coarse_ = 0x30; - static const int kSplit_v8_Fine_ = 0x3a; - static const int kNLayers_ = 3; - static const int kSplit_v9_ = 0x36; +private: + int getSuperTriggerCellId(int detid) const; + static std::map kSplit_; + static const int kWafer_offset_ = 6; + static const int kSTCsizeCoarse_ = 16; + static const int kSTCsizeFine_ = 4; + static const int kSplit_v8_Coarse_ = 0x30; + static const int kSplit_v8_Fine_ = 0x3a; + static const int kNLayers_ = 3; + static const int kSplit_v9_ = 0x36; - static const int kRocShift_ = 6; - static const int kRotate4_ = 4; - static const int kUShift_ = 3; + static const int kRocShift_ = 6; + static const int kRotate4_ = 4; + static const int kUShift_ = 3; + HGCalTriggerTools triggerTools_; + HGCSiliconDetIdToROC detIdToROC_; + std::vector stcSize_; - HGCalTriggerTools triggerTools_; - HGCSiliconDetIdToROC detIdToROC_; - std::vector stcSize_; + class SuperTriggerCell { + private: + float sumPt_, sumMipPt_; + int sumHwPt_, maxHwPt_; + unsigned maxId_; - class SuperTriggerCell { - - private: - float sumPt_, sumMipPt_; - int sumHwPt_, maxHwPt_; - unsigned maxId_; - - public: - SuperTriggerCell(){ sumPt_=0, sumMipPt_=0, sumHwPt_=0, maxHwPt_=0, maxId_=0 ;} - void add(const l1t::HGCalTriggerCell &c) { - sumPt_ += c.pt(); - sumMipPt_ += c.mipPt(); - sumHwPt_ += c.hwPt(); - if (maxId_ == 0 || c.hwPt() > maxHwPt_) { - maxHwPt_ = c.hwPt(); - maxId_ = c.detId(); - } - } - void assignEnergy(l1t::HGCalTriggerCell &c) const { - c.setHwPt(sumHwPt_); - c.setMipPt(sumMipPt_); - c.setPt( sumPt_ ); - } - unsigned GetMaxId()const{return maxId_;} - }; - + public: + SuperTriggerCell() { sumPt_ = 0, sumMipPt_ = 0, sumHwPt_ = 0, maxHwPt_ = 0, maxId_ = 0; } + void add(const l1t::HGCalTriggerCell& c) { + sumPt_ += c.pt(); + sumMipPt_ += c.mipPt(); + sumHwPt_ += c.hwPt(); + if (maxId_ == 0 || c.hwPt() > maxHwPt_) { + maxHwPt_ = c.hwPt(); + maxId_ = c.detId(); + } + } + void assignEnergy(l1t::HGCalTriggerCell& c) const { + c.setHwPt(sumHwPt_); + c.setMipPt(sumMipPt_); + c.setPt(sumPt_); + } + unsigned GetMaxId() const { return maxId_; } + }; }; #endif diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h index c8f866d4bc179..9c5028cfce71d 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h @@ -12,27 +12,23 @@ #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" -class HGCalTriggerCellCalibration{ - +class HGCalTriggerCellCalibration { public: - - HGCalTriggerCellCalibration(const edm::ParameterSet &conf); - void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} - void calibrateInMipT(l1t::HGCalTriggerCell&); - void calibrateMipTinGeV(l1t::HGCalTriggerCell&); - void calibrateInGeV(l1t::HGCalTriggerCell&); - void print(); + HGCalTriggerCellCalibration(const edm::ParameterSet& conf); + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void calibrateInMipT(l1t::HGCalTriggerCell&); + void calibrateMipTinGeV(l1t::HGCalTriggerCell&); + void calibrateInGeV(l1t::HGCalTriggerCell&); + void print(); private: - - double LSB_silicon_fC_; - double LSB_scintillator_MIP_; - double fCperMIP_; - double thickCorr_; - std::vector dEdX_weights_; - - HGCalTriggerTools triggerTools_; + double LSB_silicon_fC_; + double LSB_scintillator_MIP_; + double fCperMIP_; + double thickCorr_; + std::vector dEdX_weights_; + HGCalTriggerTools triggerTools_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFECompressionImpl.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFECompressionImpl.h index 1c4d951c14c9d..e13563186ee2c 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFECompressionImpl.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFECompressionImpl.h @@ -4,27 +4,20 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" - -class HGCalVFECompressionImpl -{ - - public: +class HGCalVFECompressionImpl { +public: HGCalVFECompressionImpl(const edm::ParameterSet& conf); - void compress(const std::unordered_map&, - std::unordered_map >&); + void compress(const std::unordered_map&, std::unordered_map >&); + +private: + void compressSingle(const uint32_t value, uint32_t& compressedCode, uint32_t& compressedValue); - private: - void compressSingle(const uint32_t value, - uint32_t & compressedCode, - uint32_t & compressedValue); - uint32_t exponentBits_; uint32_t mantissaBits_; - bool rounding_; + bool rounding_; uint32_t saturationCode_; uint32_t saturationValue_; - }; #endif diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFELinearizationImpl.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFELinearizationImpl.h index d1520b445224a..770e5467c6dd1 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFELinearizationImpl.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFELinearizationImpl.h @@ -9,29 +9,26 @@ #include #include -class HGCalVFELinearizationImpl -{ - - public: - HGCalVFELinearizationImpl(const edm::ParameterSet& conf); - - void linearize(const std::vector>&, - std::vector >&); - - // Retrieve parameters - uint32_t linnBits() const {return linnBits_;} - - private: - double adcLSB_; - double linLSB_; - double adcsaturation_; - uint32_t tdcnBits_ ; - double tdcOnsetfC_; - uint32_t adcnBits_; - double tdcsaturation_ ; - uint32_t linnBits_; - double tdcLSB_; - uint32_t linMax_; +class HGCalVFELinearizationImpl { +public: + HGCalVFELinearizationImpl(const edm::ParameterSet& conf); + + void linearize(const std::vector>&, std::vector>&); + + // Retrieve parameters + uint32_t linnBits() const { return linnBits_; } + +private: + double adcLSB_; + double linLSB_; + double adcsaturation_; + uint32_t tdcnBits_; + double tdcOnsetfC_; + uint32_t adcnBits_; + double tdcsaturation_; + uint32_t linnBits_; + double tdcLSB_; + uint32_t linMax_; }; #endif diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h index 4859d599166fa..e9a92792e7254 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFEProcessorSums.h @@ -13,26 +13,19 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h" +class HGCalVFEProcessorSums : public HGCalVFEProcessorBase { +public: + HGCalVFEProcessorSums(const edm::ParameterSet& conf); + void run(const HGCalDigiCollection& digiColl, + l1t::HGCalTriggerCellBxCollection& triggerCellColl, + const edm::EventSetup& es) override; + +private: + std::unique_ptr vfeLinearizationImpl_; + std::unique_ptr vfeSummationImpl_; + std::unique_ptr vfeCompressionImpl_; + std::unique_ptr calibration_; +}; -class HGCalVFEProcessorSums : public HGCalVFEProcessorBase -{ - - public: - - HGCalVFEProcessorSums(const edm::ParameterSet& conf); - - void run(const HGCalDigiCollection& digiColl, - l1t::HGCalTriggerCellBxCollection& triggerCellColl, - const edm::EventSetup& es) override; - - private: - - std::unique_ptr vfeLinearizationImpl_; - std::unique_ptr vfeSummationImpl_; - std::unique_ptr vfeCompressionImpl_; - std::unique_ptr calibration_; - -}; - #endif diff --git a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h index fb8e9e9bc410e..cb74c54138ebb 100644 --- a/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h +++ b/L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h @@ -11,20 +11,18 @@ #include #include -class HGCalVFESummationImpl -{ - - public: +class HGCalVFESummationImpl { +public: HGCalVFESummationImpl(const edm::ParameterSet& conf); - - void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);} - void triggerCellSums(const HGCalTriggerGeometryBase& , - const std::vector >&, + + void eventSetup(const edm::EventSetup& es) { triggerTools_.eventSetup(es); } + void triggerCellSums(const HGCalTriggerGeometryBase&, + const std::vector >&, std::unordered_map& payload); - const std::vector& thicknessCorrections() const {return thickness_corrections_;} - - private: - std::vector thickness_corrections_; + const std::vector& thicknessCorrections() const { return thickness_corrections_; } + +private: + std::vector thickness_corrections_; HGCalTriggerTools triggerTools_; }; diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc index 54c07f4ff8e2a..ab26bbba9ab75 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc @@ -16,17 +16,15 @@ #include - -class HGCalBackendLayer1Producer : public edm::stream::EDProducer<> { - public: +class HGCalBackendLayer1Producer : public edm::stream::EDProducer<> { +public: HGCalBackendLayer1Producer(const edm::ParameterSet&); - ~HGCalBackendLayer1Producer() override { } + ~HGCalBackendLayer1Producer() override {} - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - - private: + +private: // inputs edm::EDGetToken input_cell_, input_sums_; edm::ESHandle triggerGeometry_; @@ -36,29 +34,26 @@ class HGCalBackendLayer1Producer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(HGCalBackendLayer1Producer); -HGCalBackendLayer1Producer:: -HGCalBackendLayer1Producer(const edm::ParameterSet& conf): -input_cell_(consumes(conf.getParameter("InputTriggerCells"))) -{ +HGCalBackendLayer1Producer::HGCalBackendLayer1Producer(const edm::ParameterSet& conf) + : input_cell_(consumes(conf.getParameter("InputTriggerCells"))) { //setup Backend parameters const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& beProcessorName = beParamConfig.getParameter("ProcessorName"); - backendProcess_ = std::unique_ptr{HGCalBackendLayer1Factory::get()->create(beProcessorName, beParamConfig)}; + backendProcess_ = std::unique_ptr{ + HGCalBackendLayer1Factory::get()->create(beProcessorName, beParamConfig)}; produces(backendProcess_->name()); } -void HGCalBackendLayer1Producer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) { - es.get().get("",triggerGeometry_); +void HGCalBackendLayer1Producer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get("", triggerGeometry_); backendProcess_->setGeometry(triggerGeometry_.product()); } void HGCalBackendLayer1Producer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections auto be_cluster_output = std::make_unique(); - + // Input collections edm::Handle trigCellBxColl; diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc index 56e371181389e..c025069c8e6f4 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc @@ -16,17 +16,15 @@ #include - -class HGCalBackendLayer2Producer : public edm::stream::EDProducer<> { - public: +class HGCalBackendLayer2Producer : public edm::stream::EDProducer<> { +public: HGCalBackendLayer2Producer(const edm::ParameterSet&); - ~HGCalBackendLayer2Producer() override { } - - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + ~HGCalBackendLayer2Producer() override {} + + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - private: +private: // inputs edm::EDGetToken input_clusters_; edm::ESHandle triggerGeometry_; @@ -36,36 +34,32 @@ class HGCalBackendLayer2Producer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(HGCalBackendLayer2Producer); -HGCalBackendLayer2Producer:: -HGCalBackendLayer2Producer(const edm::ParameterSet& conf): - input_clusters_(consumes(conf.getParameter("InputCluster"))) -{ +HGCalBackendLayer2Producer::HGCalBackendLayer2Producer(const edm::ParameterSet& conf) + : input_clusters_(consumes(conf.getParameter("InputCluster"))) { //setup Backend parameters const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& beProcessorName = beParamConfig.getParameter("ProcessorName"); - backendProcess_ = std::unique_ptr{HGCalBackendLayer2Factory::get()->create(beProcessorName, beParamConfig)}; + backendProcess_ = std::unique_ptr{ + HGCalBackendLayer2Factory::get()->create(beProcessorName, beParamConfig)}; produces(backendProcess_->name()); } -void HGCalBackendLayer2Producer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) -{ - es.get().get("",triggerGeometry_); +void HGCalBackendLayer2Producer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get("", triggerGeometry_); backendProcess_->setGeometry(triggerGeometry_.product()); } -void HGCalBackendLayer2Producer::produce(edm::Event& e, const edm::EventSetup& es) -{ +void HGCalBackendLayer2Producer::produce(edm::Event& e, const edm::EventSetup& es) { // Output collections auto be_multicluster_output = std::make_unique(); - // Input collections + // Input collections edm::Handle trigCluster2DBxColl; e.getByToken(input_clusters_, trigCluster2DBxColl); backendProcess_->run(trigCluster2DBxColl, *be_multicluster_output, es); - e.put(std::move(be_multicluster_output), backendProcess_->name()); + e.put(std::move(be_multicluster_output), backendProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc index 13ed48deedc9c..169934d535216 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc @@ -15,63 +15,55 @@ #include - class HGCalConcentratorProducer : public edm::stream::EDProducer<> { - public: +public: HGCalConcentratorProducer(const edm::ParameterSet&); - ~HGCalConcentratorProducer() override { } + ~HGCalConcentratorProducer() override {} - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - private: +private: // inputs edm::EDGetToken input_cell_, input_sums_; edm::ESHandle triggerGeometry_; - + std::unique_ptr concentratorProcess_; }; DEFINE_FWK_MODULE(HGCalConcentratorProducer); -HGCalConcentratorProducer:: -HGCalConcentratorProducer(const edm::ParameterSet& conf): - input_cell_(consumes(conf.getParameter("InputTriggerCells"))), - input_sums_(consumes(conf.getParameter("InputTriggerSums"))) -{ +HGCalConcentratorProducer::HGCalConcentratorProducer(const edm::ParameterSet& conf) + : input_cell_(consumes(conf.getParameter("InputTriggerCells"))), + input_sums_(consumes(conf.getParameter("InputTriggerSums"))) { //setup Concentrator parameters const edm::ParameterSet& concParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& concProcessorName = concParamConfig.getParameter("ProcessorName"); - concentratorProcess_ = std::unique_ptr{HGCalConcentratorFactory::get()->create(concProcessorName, concParamConfig)}; + concentratorProcess_ = std::unique_ptr{ + HGCalConcentratorFactory::get()->create(concProcessorName, concParamConfig)}; produces(concentratorProcess_->name()); produces(concentratorProcess_->name()); - } -void HGCalConcentratorProducer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) { +void HGCalConcentratorProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { es.get().get(triggerGeometry_); - - concentratorProcess_->setGeometry(triggerGeometry_.product()); + concentratorProcess_->setGeometry(triggerGeometry_.product()); } void HGCalConcentratorProducer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections auto cc_trigcell_output = std::make_unique(); auto cc_trigsums_output = std::make_unique(); - + // Input collections edm::Handle trigCellBxColl; - e.getByToken(input_cell_,trigCellBxColl); + e.getByToken(input_cell_, trigCellBxColl); concentratorProcess_->run(trigCellBxColl, *cc_trigcell_output, es); // Put in the event - // At the moment the HGCalTriggerSumsBxCollection is empty + // At the moment the HGCalTriggerSumsBxCollection is empty e.put(std::move(cc_trigcell_output), concentratorProcess_->name()); e.put(std::move(cc_trigsums_output), concentratorProcess_->name()); - } diff --git a/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc index 7dc253d94f7a6..7046ed6a34fd0 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc @@ -15,16 +15,15 @@ #include -class HGCalTowerMapProducer : public edm::stream::EDProducer<> { - public: +class HGCalTowerMapProducer : public edm::stream::EDProducer<> { +public: HGCalTowerMapProducer(const edm::ParameterSet&); - ~HGCalTowerMapProducer() override { } - - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + ~HGCalTowerMapProducer() override {} + + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - - private: + +private: // inputs edm::EDGetToken input_cell_; edm::ESHandle triggerGeometry_; @@ -34,37 +33,32 @@ class HGCalTowerMapProducer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(HGCalTowerMapProducer); -HGCalTowerMapProducer:: -HGCalTowerMapProducer(const edm::ParameterSet& conf): - input_cell_(consumes(conf.getParameter("InputTriggerCells"))) -{ +HGCalTowerMapProducer::HGCalTowerMapProducer(const edm::ParameterSet& conf) + : input_cell_(consumes(conf.getParameter("InputTriggerCells"))) { //setup TowerMap parameters const edm::ParameterSet& towerMapParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& towerMapProcessorName = towerMapParamConfig.getParameter("ProcessorName"); - towersMapProcess_ = std::unique_ptr{HGCalTowerMapFactory::get()->create(towerMapProcessorName, towerMapParamConfig)}; - + towersMapProcess_ = std::unique_ptr{ + HGCalTowerMapFactory::get()->create(towerMapProcessorName, towerMapParamConfig)}; + produces(towersMapProcess_->name()); } -void HGCalTowerMapProducer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) { - es.get().get("",triggerGeometry_); +void HGCalTowerMapProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get("", triggerGeometry_); towersMapProcess_->setGeometry(triggerGeometry_.product()); - } void HGCalTowerMapProducer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections auto towersMap_output = std::make_unique(); - + // Input collections edm::Handle trigCellBxColl; - + e.getByToken(input_cell_, trigCellBxColl); towersMapProcess_->run(trigCellBxColl, *towersMap_output, es); e.put(std::move(towersMap_output), towersMapProcess_->name()); - } diff --git a/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc index e077abe7a0318..dcae07415242a 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc @@ -15,16 +15,15 @@ #include -class HGCalTowerProducer : public edm::stream::EDProducer<> { - public: +class HGCalTowerProducer : public edm::stream::EDProducer<> { +public: HGCalTowerProducer(const edm::ParameterSet&); - ~HGCalTowerProducer() override { } - - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + ~HGCalTowerProducer() override {} + + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - - private: + +private: // inputs edm::EDGetToken input_towers_map_; edm::ESHandle triggerGeometry_; @@ -34,35 +33,32 @@ class HGCalTowerProducer : public edm::stream::EDProducer<> { DEFINE_FWK_MODULE(HGCalTowerProducer); -HGCalTowerProducer:: -HGCalTowerProducer(const edm::ParameterSet& conf): - input_towers_map_(consumes(conf.getParameter("InputTowerMaps"))) -{ +HGCalTowerProducer::HGCalTowerProducer(const edm::ParameterSet& conf) + : input_towers_map_(consumes(conf.getParameter("InputTowerMaps"))) { //setup TowerMap parameters const edm::ParameterSet& towerParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& towerProcessorName = towerParamConfig.getParameter("ProcessorName"); - towersProcess_ = std::unique_ptr{HGCalTowerFactory::get()->create(towerProcessorName, towerParamConfig)}; - + towersProcess_ = + std::unique_ptr{HGCalTowerFactory::get()->create(towerProcessorName, towerParamConfig)}; + produces(towersProcess_->name()); } -void HGCalTowerProducer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) { - es.get().get("",triggerGeometry_); +void HGCalTowerProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get("", triggerGeometry_); towersProcess_->setGeometry(triggerGeometry_.product()); } void HGCalTowerProducer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections auto towers_output = std::make_unique(); - + // Input collections edm::Handle towersMapBxColl; - + e.getByToken(input_towers_map_, towersMapBxColl); - + towersProcess_->run(towersMapBxColl, *towers_output, es); - + e.put(std::move(towers_output), towersProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalTriggerDigiFEReproducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTriggerDigiFEReproducer.cc index 5e43ac7fa39cc..2b883c61987fd 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTriggerDigiFEReproducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTriggerDigiFEReproducer.cc @@ -18,88 +18,86 @@ #include #include -class HGCalTriggerDigiFEReproducer : public edm::stream::EDProducer<> -{ - public: - HGCalTriggerDigiFEReproducer(const edm::ParameterSet&); - ~HGCalTriggerDigiFEReproducer() override { } - - void beginRun(const edm::Run&, const edm::EventSetup&) override; - void produce(edm::Event&, const edm::EventSetup&) override; - - private: - // inputs - edm::EDGetToken inputdigi_; - edm::ESHandle triggerGeometry_; - // algorithm containers - std::unique_ptr codec_; - std::unique_ptr backEndProcessor_; +class HGCalTriggerDigiFEReproducer : public edm::stream::EDProducer<> { +public: + HGCalTriggerDigiFEReproducer(const edm::ParameterSet&); + ~HGCalTriggerDigiFEReproducer() override {} + + void beginRun(const edm::Run&, const edm::EventSetup&) override; + void produce(edm::Event&, const edm::EventSetup&) override; + +private: + // inputs + edm::EDGetToken inputdigi_; + edm::ESHandle triggerGeometry_; + // algorithm containers + std::unique_ptr codec_; + std::unique_ptr backEndProcessor_; }; DEFINE_FWK_MODULE(HGCalTriggerDigiFEReproducer); - /*****************************************************************/ -HGCalTriggerDigiFEReproducer::HGCalTriggerDigiFEReproducer(const edm::ParameterSet& conf): - inputdigi_(consumes(conf.getParameter("feDigis"))), - backEndProcessor_(std::make_unique(conf.getParameterSet("BEConfiguration"), consumesCollector())) +HGCalTriggerDigiFEReproducer::HGCalTriggerDigiFEReproducer(const edm::ParameterSet& conf) + : inputdigi_(consumes(conf.getParameter("feDigis"))), + backEndProcessor_( + std::make_unique(conf.getParameterSet("BEConfiguration"), consumesCollector())) /*****************************************************************/ { - //setup FE codec - const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); - const std::string& feCodecName = feCodecConfig.getParameter("CodecName"); - codec_ = std::unique_ptr{HGCalTriggerFECodecFactory::get()->create(feCodecName,feCodecConfig)}; - codec_->unSetDataPayload(); - - produces(); - // register backend processor products - backEndProcessor_->setProduces(*this); + //setup FE codec + const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); + const std::string& feCodecName = feCodecConfig.getParameter("CodecName"); + codec_ = + std::unique_ptr{HGCalTriggerFECodecFactory::get()->create(feCodecName, feCodecConfig)}; + codec_->unSetDataPayload(); + + produces(); + // register backend processor products + backEndProcessor_->setProduces(*this); } /*****************************************************************/ -void HGCalTriggerDigiFEReproducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) +void HGCalTriggerDigiFEReproducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) /*****************************************************************/ { - es.get().get(triggerGeometry_); - codec_->setGeometry(triggerGeometry_.product()); - backEndProcessor_->setGeometry(triggerGeometry_.product()); + es.get().get(triggerGeometry_); + codec_->setGeometry(triggerGeometry_.product()); + backEndProcessor_->setGeometry(triggerGeometry_.product()); } /*****************************************************************/ void HGCalTriggerDigiFEReproducer::produce(edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ { - std::unique_ptr fe_output( new l1t::HGCFETriggerDigiCollection ); - - edm::Handle digis_h; - - e.getByToken(inputdigi_,digis_h); - - const l1t::HGCFETriggerDigiCollection& digis = *digis_h; - - fe_output->reserve(digis.size()); - std::stringstream output; - for( const auto& digi_in : digis ) - { - fe_output->push_back(l1t::HGCFETriggerDigi()); - l1t::HGCFETriggerDigi& digi_out = fe_output->back(); - codec_->setDataPayload(digi_in); - codec_->encode(digi_out); - digi_out.setDetId( digi_in.getDetId() ); - codec_->print(digi_out,output); - edm::LogInfo("HGCalTriggerDigiFEReproducer") - << output.str(); - codec_->unSetDataPayload(); - output.str(std::string()); - output.clear(); - } - - // get the orphan handle and fe digi collection - auto fe_digis_handle = e.put(std::move(fe_output)); - auto fe_digis_coll = *fe_digis_handle; - - //now we run the emulation of the back-end processor - backEndProcessor_->run(fe_digis_coll,es,e); - backEndProcessor_->putInEvent(e); - backEndProcessor_->reset(); + std::unique_ptr fe_output(new l1t::HGCFETriggerDigiCollection); + + edm::Handle digis_h; + + e.getByToken(inputdigi_, digis_h); + + const l1t::HGCFETriggerDigiCollection& digis = *digis_h; + + fe_output->reserve(digis.size()); + std::stringstream output; + for (const auto& digi_in : digis) { + fe_output->push_back(l1t::HGCFETriggerDigi()); + l1t::HGCFETriggerDigi& digi_out = fe_output->back(); + codec_->setDataPayload(digi_in); + codec_->encode(digi_out); + digi_out.setDetId(digi_in.getDetId()); + codec_->print(digi_out, output); + edm::LogInfo("HGCalTriggerDigiFEReproducer") << output.str(); + codec_->unSetDataPayload(); + output.str(std::string()); + output.clear(); + } + + // get the orphan handle and fe digi collection + auto fe_digis_handle = e.put(std::move(fe_output)); + auto fe_digis_coll = *fe_digis_handle; + + //now we run the emulation of the back-end processor + backEndProcessor_->run(fe_digis_coll, es, e); + backEndProcessor_->putInEvent(e); + backEndProcessor_->reset(); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalTriggerGeometryESProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalTriggerGeometryESProducer.cc index dc79e00adb468..5fd457d1e7357 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalTriggerGeometryESProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalTriggerGeometryESProducer.cc @@ -10,70 +10,54 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -class HGCalTriggerGeometryESProducer : public edm::ESProducer -{ - public: - HGCalTriggerGeometryESProducer(const edm::ParameterSet&); - ~HGCalTriggerGeometryESProducer() override; +class HGCalTriggerGeometryESProducer : public edm::ESProducer { +public: + HGCalTriggerGeometryESProducer(const edm::ParameterSet&); + ~HGCalTriggerGeometryESProducer() override; - typedef std::unique_ptr ReturnType; + typedef std::unique_ptr ReturnType; - ReturnType produce(const CaloGeometryRecord&); + ReturnType produce(const CaloGeometryRecord&); - private: - edm::ParameterSet geometry_config_; - std::string geometry_name_; +private: + edm::ParameterSet geometry_config_; + std::string geometry_name_; }; -HGCalTriggerGeometryESProducer:: -HGCalTriggerGeometryESProducer(const edm::ParameterSet& iConfig): - geometry_config_(iConfig.getParameterSet("TriggerGeometry")), - geometry_name_(geometry_config_.getParameter("TriggerGeometryName")) -{ - setWhatProduced(this); +HGCalTriggerGeometryESProducer::HGCalTriggerGeometryESProducer(const edm::ParameterSet& iConfig) + : geometry_config_(iConfig.getParameterSet("TriggerGeometry")), + geometry_name_(geometry_config_.getParameter("TriggerGeometryName")) { + setWhatProduced(this); } - -HGCalTriggerGeometryESProducer:: -~HGCalTriggerGeometryESProducer() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - +HGCalTriggerGeometryESProducer::~HGCalTriggerGeometryESProducer() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) } -HGCalTriggerGeometryESProducer::ReturnType -HGCalTriggerGeometryESProducer:: -produce(const CaloGeometryRecord& iRecord) -{ - //using namespace edm::es; - ReturnType geometry(HGCalTriggerGeometryFactory::get()->create(geometry_name_,geometry_config_)); - geometry->reset(); - edm::ESHandle calo_geometry; - iRecord.get(calo_geometry); - // Initialize trigger geometry for V7/V8 HGCAL geometry - if(calo_geometry.isValid() && - calo_geometry->getSubdetectorGeometry(DetId::Forward,HGCEE) && - calo_geometry->getSubdetectorGeometry(DetId::Forward,HGCHEF) && - calo_geometry->getSubdetectorGeometry(DetId::Hcal,HcalEndcap) - ) - { - geometry->initialize(calo_geometry); - } - // Initialize trigger geometry for V9 HGCAL geometry - else - { - edm::ESHandle ee_geometry; - edm::ESHandle hsi_geometry; - edm::ESHandle hsc_geometry; - iRecord.getRecord().get("HGCalEESensitive",ee_geometry); - iRecord.getRecord().get("HGCalHESiliconSensitive",hsi_geometry); - iRecord.getRecord().get("HGCalHEScintillatorSensitive",hsc_geometry); - geometry->initialize(ee_geometry, hsi_geometry, hsc_geometry); - } - return geometry; - +HGCalTriggerGeometryESProducer::ReturnType HGCalTriggerGeometryESProducer::produce(const CaloGeometryRecord& iRecord) { + //using namespace edm::es; + ReturnType geometry(HGCalTriggerGeometryFactory::get()->create(geometry_name_, geometry_config_)); + geometry->reset(); + edm::ESHandle calo_geometry; + iRecord.get(calo_geometry); + // Initialize trigger geometry for V7/V8 HGCAL geometry + if (calo_geometry.isValid() && calo_geometry->getSubdetectorGeometry(DetId::Forward, HGCEE) && + calo_geometry->getSubdetectorGeometry(DetId::Forward, HGCHEF) && + calo_geometry->getSubdetectorGeometry(DetId::Hcal, HcalEndcap)) { + geometry->initialize(calo_geometry); + } + // Initialize trigger geometry for V9 HGCAL geometry + else { + edm::ESHandle ee_geometry; + edm::ESHandle hsi_geometry; + edm::ESHandle hsc_geometry; + iRecord.getRecord().get("HGCalEESensitive", ee_geometry); + iRecord.getRecord().get("HGCalHESiliconSensitive", hsi_geometry); + iRecord.getRecord().get("HGCalHEScintillatorSensitive", hsc_geometry); + geometry->initialize(ee_geometry, hsi_geometry, hsc_geometry); + } + return geometry; } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc b/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc index 4642ded004494..d56649bdb6a6a 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc @@ -16,51 +16,44 @@ #include - -class HGCalVFEProducer : public edm::stream::EDProducer<> { - public: +class HGCalVFEProducer : public edm::stream::EDProducer<> { +public: HGCalVFEProducer(const edm::ParameterSet&); - ~HGCalVFEProducer() override { } - - void beginRun(const edm::Run&, - const edm::EventSetup&) override; + ~HGCalVFEProducer() override {} + + void beginRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event&, const edm::EventSetup&) override; - - private: + +private: // inputs edm::EDGetToken inputee_, inputfh_, inputbh_; edm::ESHandle triggerGeometry_; - - std::unique_ptr vfeProcess_; + std::unique_ptr vfeProcess_; }; DEFINE_FWK_MODULE(HGCalVFEProducer); -HGCalVFEProducer:: -HGCalVFEProducer(const edm::ParameterSet& conf): - inputee_(consumes(conf.getParameter("eeDigis"))), - inputfh_(consumes(conf.getParameter("fhDigis"))), - inputbh_(consumes(conf.getParameter("bhDigis"))) -{ +HGCalVFEProducer::HGCalVFEProducer(const edm::ParameterSet& conf) + : inputee_(consumes(conf.getParameter("eeDigis"))), + inputfh_(consumes(conf.getParameter("fhDigis"))), + inputbh_(consumes(conf.getParameter("bhDigis"))) { //setup VFE parameters const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& vfeProcessorName = vfeParamConfig.getParameter("ProcessorName"); - vfeProcess_ = std::unique_ptr{HGCalVFEProcessorBaseFactory::get()->create(vfeProcessorName, vfeParamConfig)}; - + vfeProcess_ = std::unique_ptr{ + HGCalVFEProcessorBaseFactory::get()->create(vfeProcessorName, vfeParamConfig)}; + produces(vfeProcess_->name()); produces(vfeProcess_->name()); - } -void HGCalVFEProducer::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) { +void HGCalVFEProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { es.get().get(triggerGeometry_); vfeProcess_->setGeometry(triggerGeometry_.product()); } void HGCalVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections auto vfe_trigcell_output = std::make_unique(); auto vfe_trigsums_output = std::make_unique(); @@ -70,22 +63,21 @@ void HGCalVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) { edm::Handle fh_digis_h; edm::Handle bh_digis_h; - e.getByToken(inputee_,ee_digis_h); - e.getByToken(inputfh_,fh_digis_h); - e.getByToken(inputbh_,bh_digis_h); + e.getByToken(inputee_, ee_digis_h); + e.getByToken(inputfh_, fh_digis_h); + e.getByToken(inputbh_, bh_digis_h); const HGCalDigiCollection& ee_digis = *ee_digis_h; const HGCalDigiCollection& fh_digis = *fh_digis_h; const HGCalDigiCollection& bh_digis = *bh_digis_h; - + // Processing DigiCollections and putting the results into the HGCalTriggerCellBxCollection - vfeProcess_->run(ee_digis, *vfe_trigcell_output, es); - vfeProcess_->run(fh_digis, *vfe_trigcell_output, es); - vfeProcess_->run(bh_digis, *vfe_trigcell_output, es); + vfeProcess_->run(ee_digis, *vfe_trigcell_output, es); + vfeProcess_->run(fh_digis, *vfe_trigcell_output, es); + vfeProcess_->run(bh_digis, *vfe_trigcell_output, es); - // Put in the event + // Put in the event e.put(std::move(vfe_trigcell_output), vfeProcess_->name()); - // At the moment the HGCalTriggerSumsBxCollection is empty + // At the moment the HGCalTriggerSumsBxCollection is empty e.put(std::move(vfe_trigsums_output), vfeProcess_->name()); - } diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc index 45d6d3f8f6727..3bfef0b69959d 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc @@ -7,92 +7,82 @@ #include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringImpl.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" -class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1ProcessorBase -{ - public: - HGCalBackendLayer1Processor2DClustering(const edm::ParameterSet& conf) : - HGCalBackendLayer1ProcessorBase(conf) - { - std::string typeCluster(conf.getParameterSet("C2d_parameters").getParameter("clusterType")); - if(typeCluster=="dRC2d"){ - clusteringAlgorithmType_ = dRC2d; - clustering_ = std::make_unique( conf.getParameterSet("C2d_parameters") ); - }else if(typeCluster=="NNC2d"){ - clusteringAlgorithmType_ = NNC2d; - clustering_ = std::make_unique( conf.getParameterSet("C2d_parameters") ); - }else if(typeCluster=="dRNNC2d"){ - clusteringAlgorithmType_ = dRNNC2d; - clustering_ = std::make_unique( conf.getParameterSet("C2d_parameters") ); - }else if(typeCluster=="dummyC2d"){ - clusteringAlgorithmType_ = dummyC2d; - clusteringDummy_ = std::make_unique( conf.getParameterSet("C2d_parameters") ); - }else { - throw cms::Exception("HGCTriggerParameterError") - << "Unknown clustering type '" << typeCluster; - } +class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1ProcessorBase { +public: + HGCalBackendLayer1Processor2DClustering(const edm::ParameterSet& conf) : HGCalBackendLayer1ProcessorBase(conf) { + std::string typeCluster(conf.getParameterSet("C2d_parameters").getParameter("clusterType")); + if (typeCluster == "dRC2d") { + clusteringAlgorithmType_ = dRC2d; + clustering_ = std::make_unique(conf.getParameterSet("C2d_parameters")); + } else if (typeCluster == "NNC2d") { + clusteringAlgorithmType_ = NNC2d; + clustering_ = std::make_unique(conf.getParameterSet("C2d_parameters")); + } else if (typeCluster == "dRNNC2d") { + clusteringAlgorithmType_ = dRNNC2d; + clustering_ = std::make_unique(conf.getParameterSet("C2d_parameters")); + } else if (typeCluster == "dummyC2d") { + clusteringAlgorithmType_ = dummyC2d; + clusteringDummy_ = std::make_unique(conf.getParameterSet("C2d_parameters")); + } else { + throw cms::Exception("HGCTriggerParameterError") << "Unknown clustering type '" << typeCluster; } + } - void run(const edm::Handle& collHandle, - l1t::HGCalClusterBxCollection& collCluster2D, - const edm::EventSetup& es) override - { - es.get().get("", triggerGeometry_); - if(clustering_) clustering_->eventSetup(es); - if(clusteringDummy_) clusteringDummy_->eventSetup(es); + void run(const edm::Handle& collHandle, + l1t::HGCalClusterBxCollection& collCluster2D, + const edm::EventSetup& es) override { + es.get().get("", triggerGeometry_); + if (clustering_) + clustering_->eventSetup(es); + if (clusteringDummy_) + clusteringDummy_->eventSetup(es); - /* create a persistent vector of pointers to the trigger-cells */ - std::vector> triggerCellsPtrs; - for( unsigned i = 0; i < collHandle->size(); ++i ) { - edm::Ptr ptr(collHandle,i); - triggerCellsPtrs.push_back(ptr); - } + /* create a persistent vector of pointers to the trigger-cells */ + std::vector> triggerCellsPtrs; + for (unsigned i = 0; i < collHandle->size(); ++i) { + edm::Ptr ptr(collHandle, i); + triggerCellsPtrs.push_back(ptr); + } + + std::sort(triggerCellsPtrs.begin(), + triggerCellsPtrs.end(), + [](const edm::Ptr& a, const edm::Ptr& b) -> bool { + return a->mipPt() > b->mipPt(); + }); - std::sort(triggerCellsPtrs.begin(), triggerCellsPtrs.end(), - [](const edm::Ptr& a, - const edm::Ptr& b) -> bool - { - return a->mipPt() > b->mipPt(); - } - ); + /* call to C2d clustering */ + switch (clusteringAlgorithmType_) { + case dRC2d: + clustering_->clusterizeDR(triggerCellsPtrs, collCluster2D); + break; + case NNC2d: + clustering_->clusterizeNN(triggerCellsPtrs, collCluster2D, *triggerGeometry_); + break; + case dRNNC2d: + clustering_->clusterizeDRNN(triggerCellsPtrs, collCluster2D, *triggerGeometry_); + break; + case dummyC2d: + clusteringDummy_->clusterizeDummy(triggerCellsPtrs, collCluster2D); + break; + default: + // Should not happen, clustering type checked in constructor + break; + } + } - /* call to C2d clustering */ - switch(clusteringAlgorithmType_){ - case dRC2d : - clustering_->clusterizeDR(triggerCellsPtrs, collCluster2D); - break; - case NNC2d: - clustering_->clusterizeNN( triggerCellsPtrs, collCluster2D, *triggerGeometry_ ); - break; - case dRNNC2d: - clustering_->clusterizeDRNN( triggerCellsPtrs, collCluster2D, *triggerGeometry_ ); - break; - case dummyC2d: - clusteringDummy_->clusterizeDummy( triggerCellsPtrs, collCluster2D ); - break; - default: - // Should not happen, clustering type checked in constructor - break; - } - } - - private: - enum ClusterType{ - dRC2d, - NNC2d, - dRNNC2d, - dummyC2d - }; +private: + enum ClusterType { dRC2d, NNC2d, dRNNC2d, dummyC2d }; - edm::ESHandle triggerGeometry_; + edm::ESHandle triggerGeometry_; - /* algorithms instances */ - std::unique_ptr clustering_; - std::unique_ptr clusteringDummy_; + /* algorithms instances */ + std::unique_ptr clustering_; + std::unique_ptr clusteringDummy_; - /* algorithm type */ - ClusterType clusteringAlgorithmType_; + /* algorithm type */ + ClusterType clusteringAlgorithmType_; }; -DEFINE_EDM_PLUGIN(HGCalBackendLayer1Factory, +DEFINE_EDM_PLUGIN(HGCalBackendLayer1Factory, HGCalBackendLayer1Processor2DClustering, "HGCalBackendLayer1Processor2DClustering"); diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc index c0676d3995f69..bd6f2ad7d6773 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer2Processor3DClustering.cc @@ -5,88 +5,84 @@ #include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalMulticlusteringImpl.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h" -class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2ProcessorBase -{ - public: - HGCalBackendLayer2Processor3DClustering(const edm::ParameterSet& conf) : - HGCalBackendLayer2ProcessorBase(conf) - { - std::string typeMulticluster(conf.getParameterSet("C3d_parameters").getParameter("type_multicluster")); - if(typeMulticluster=="dRC3d"){ - multiclusteringAlgoType_ = dRC3d; - multiclustering_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); - }else if(typeMulticluster=="DBSCANC3d"){ - multiclusteringAlgoType_ = DBSCANC3d; - multiclustering_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); - }else if(typeMulticluster.find("Histo")!=std::string::npos){ - multiclusteringAlgoType_ = HistoC3d; - multiclusteringHistoSeeding_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); - multiclusteringHistoClustering_ = std::make_unique( conf.getParameterSet("C3d_parameters") ); - }else { - throw cms::Exception("HGCTriggerParameterError") - << "Unknown Multiclustering type '" << typeMulticluster << "'"; - } +class HGCalBackendLayer2Processor3DClustering : public HGCalBackendLayer2ProcessorBase { +public: + HGCalBackendLayer2Processor3DClustering(const edm::ParameterSet& conf) : HGCalBackendLayer2ProcessorBase(conf) { + std::string typeMulticluster(conf.getParameterSet("C3d_parameters").getParameter("type_multicluster")); + if (typeMulticluster == "dRC3d") { + multiclusteringAlgoType_ = dRC3d; + multiclustering_ = std::make_unique(conf.getParameterSet("C3d_parameters")); + } else if (typeMulticluster == "DBSCANC3d") { + multiclusteringAlgoType_ = DBSCANC3d; + multiclustering_ = std::make_unique(conf.getParameterSet("C3d_parameters")); + } else if (typeMulticluster.find("Histo") != std::string::npos) { + multiclusteringAlgoType_ = HistoC3d; + multiclusteringHistoSeeding_ = std::make_unique(conf.getParameterSet("C3d_parameters")); + multiclusteringHistoClustering_ = + std::make_unique(conf.getParameterSet("C3d_parameters")); + } else { + throw cms::Exception("HGCTriggerParameterError") << "Unknown Multiclustering type '" << typeMulticluster << "'"; } - - void run(const edm::Handle& collHandle, - l1t::HGCalMulticlusterBxCollection& collCluster3D, - const edm::EventSetup& es) override - { - es.get().get("", triggerGeometry_); - if(multiclustering_) multiclustering_->eventSetup(es); - if(multiclusteringHistoSeeding_) multiclusteringHistoSeeding_->eventSetup(es); - if(multiclusteringHistoClustering_) multiclusteringHistoClustering_->eventSetup(es); + } - /* create a persistent vector of pointers to the trigger-cells */ - std::vector> clustersPtrs; - for( unsigned i = 0; i < collHandle->size(); ++i ) { - edm::Ptr ptr(collHandle,i); - clustersPtrs.push_back(ptr); - } + void run(const edm::Handle& collHandle, + l1t::HGCalMulticlusterBxCollection& collCluster3D, + const edm::EventSetup& es) override { + es.get().get("", triggerGeometry_); + if (multiclustering_) + multiclustering_->eventSetup(es); + if (multiclusteringHistoSeeding_) + multiclusteringHistoSeeding_->eventSetup(es); + if (multiclusteringHistoClustering_) + multiclusteringHistoClustering_->eventSetup(es); - /* create a vector of seed positions and their energy*/ - std::vector > seedPositionsEnergy; + /* create a persistent vector of pointers to the trigger-cells */ + std::vector> clustersPtrs; + for (unsigned i = 0; i < collHandle->size(); ++i) { + edm::Ptr ptr(collHandle, i); + clustersPtrs.push_back(ptr); + } + + /* create a vector of seed positions and their energy*/ + std::vector> seedPositionsEnergy; - /* call to multiclustering and compute shower shape*/ - switch(multiclusteringAlgoType_){ - case dRC3d : - multiclustering_->clusterizeDR( clustersPtrs, collCluster3D, *triggerGeometry_); - break; - case DBSCANC3d: - multiclustering_->clusterizeDBSCAN( clustersPtrs, collCluster3D, *triggerGeometry_); - break; - case HistoC3d : - multiclusteringHistoSeeding_->findHistoSeeds( clustersPtrs, seedPositionsEnergy); - multiclusteringHistoClustering_->clusterizeHisto( clustersPtrs, seedPositionsEnergy, *triggerGeometry_, collCluster3D ); - break; - default: - // Should not happen, clustering type checked in constructor - break; - } + /* call to multiclustering and compute shower shape*/ + switch (multiclusteringAlgoType_) { + case dRC3d: + multiclustering_->clusterizeDR(clustersPtrs, collCluster3D, *triggerGeometry_); + break; + case DBSCANC3d: + multiclustering_->clusterizeDBSCAN(clustersPtrs, collCluster3D, *triggerGeometry_); + break; + case HistoC3d: + multiclusteringHistoSeeding_->findHistoSeeds(clustersPtrs, seedPositionsEnergy); + multiclusteringHistoClustering_->clusterizeHisto( + clustersPtrs, seedPositionsEnergy, *triggerGeometry_, collCluster3D); + break; + default: + // Should not happen, clustering type checked in constructor + break; } - - private: - enum MulticlusterType{ - dRC3d, - DBSCANC3d, - HistoC3d - }; - - edm::ESHandle triggerGeometry_; + } + +private: + enum MulticlusterType { dRC3d, DBSCANC3d, HistoC3d }; + + edm::ESHandle triggerGeometry_; - /* algorithms instances */ - std::unique_ptr multiclustering_; - std::unique_ptr multiclusteringHistoSeeding_; - std::unique_ptr multiclusteringHistoClustering_; + /* algorithms instances */ + std::unique_ptr multiclustering_; + std::unique_ptr multiclusteringHistoSeeding_; + std::unique_ptr multiclusteringHistoClustering_; - /* algorithm type */ - MulticlusterType multiclusteringAlgoType_; + /* algorithm type */ + MulticlusterType multiclusteringAlgoType_; }; -DEFINE_EDM_PLUGIN(HGCalBackendLayer2Factory, +DEFINE_EDM_PLUGIN(HGCalBackendLayer2Factory, HGCalBackendLayer2Processor3DClustering, "HGCalBackendLayer2Processor3DClustering"); diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc index b5ac1d4af47ab..c6aee25146231 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerMapProcessor.cc @@ -9,44 +9,34 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h" +class HGCalTowerMapProcessor : public HGCalTowerMapProcessorBase { +public: + HGCalTowerMapProcessor(const edm::ParameterSet& conf) : HGCalTowerMapProcessorBase(conf) { + towermap2D_ = std::make_unique(conf.getParameterSet("towermap_parameters")); + } + + void run(const edm::Handle& collHandle, + l1t::HGCalTowerMapBxCollection& collTowerMap, + const edm::EventSetup& es) override { + es.get().get("", triggerGeometry_); + towermap2D_->eventSetup(es); + + /* create a persistent vector of pointers to the trigger-cells */ + std::vector> triggerCellsPtrs; + for (unsigned i = 0; i < collHandle->size(); ++i) { + edm::Ptr ptr(collHandle, i); + triggerCellsPtrs.push_back(ptr); + } -class HGCalTowerMapProcessor : public HGCalTowerMapProcessorBase -{ - public: + /* call to towerMap2D clustering */ + towermap2D_->buildTowerMap2D(triggerCellsPtrs, collTowerMap); + } - HGCalTowerMapProcessor(const edm::ParameterSet& conf) : - HGCalTowerMapProcessorBase(conf) - { - towermap2D_ = std::make_unique( conf.getParameterSet("towermap_parameters") ); - } - - void run(const edm::Handle& collHandle, - l1t::HGCalTowerMapBxCollection& collTowerMap, - const edm::EventSetup& es) override - { - es.get().get("", triggerGeometry_); - towermap2D_->eventSetup(es); - - /* create a persistent vector of pointers to the trigger-cells */ - std::vector> triggerCellsPtrs; - for( unsigned i = 0; i < collHandle->size(); ++i ) { - edm::Ptr ptr(collHandle,i); - triggerCellsPtrs.push_back(ptr); - } - - /* call to towerMap2D clustering */ - towermap2D_->buildTowerMap2D( triggerCellsPtrs, collTowerMap); - } - - - private: - - edm::ESHandle triggerGeometry_; - - /* algorithms instances */ - std::unique_ptr towermap2D_; +private: + edm::ESHandle triggerGeometry_; + + /* algorithms instances */ + std::unique_ptr towermap2D_; }; -DEFINE_EDM_PLUGIN(HGCalTowerMapFactory, - HGCalTowerMapProcessor, - "HGCalTowerMapProcessor"); +DEFINE_EDM_PLUGIN(HGCalTowerMapFactory, HGCalTowerMapProcessor, "HGCalTowerMapProcessor"); diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc index bb48894b4e9ae..4ab658073d601 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTowerProcessor.cc @@ -9,43 +9,33 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h" - -class HGCalTowerProcessor : public HGCalTowerProcessorBase -{ - public: - - HGCalTowerProcessor(const edm::ParameterSet& conf) : - HGCalTowerProcessorBase(conf) - { - towermap3D_ = std::make_unique( ); - } - - void run(const edm::Handle& collHandle, - l1t::HGCalTowerBxCollection& collTowers, - const edm::EventSetup& es) override - { - es.get().get("", triggerGeometry_); - - /* create a persistent vector of pointers to the towerMaps */ - std::vector> towerMapsPtrs; - for( unsigned i = 0; i < collHandle->size(); ++i ) { - edm::Ptr ptr(collHandle,i); - towerMapsPtrs.push_back(ptr); - } - - /* call to towerMap3D clustering */ - towermap3D_->buildTowerMap3D( towerMapsPtrs, collTowers); +class HGCalTowerProcessor : public HGCalTowerProcessorBase { +public: + HGCalTowerProcessor(const edm::ParameterSet& conf) : HGCalTowerProcessorBase(conf) { + towermap3D_ = std::make_unique(); + } + + void run(const edm::Handle& collHandle, + l1t::HGCalTowerBxCollection& collTowers, + const edm::EventSetup& es) override { + es.get().get("", triggerGeometry_); + + /* create a persistent vector of pointers to the towerMaps */ + std::vector> towerMapsPtrs; + for (unsigned i = 0; i < collHandle->size(); ++i) { + edm::Ptr ptr(collHandle, i); + towerMapsPtrs.push_back(ptr); } - - private: + /* call to towerMap3D clustering */ + towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers); + } - edm::ESHandle triggerGeometry_; +private: + edm::ESHandle triggerGeometry_; - /* algorithms instances */ - std::unique_ptr towermap3D_; + /* algorithms instances */ + std::unique_ptr towermap3D_; }; -DEFINE_EDM_PLUGIN(HGCalTowerFactory, - HGCalTowerProcessor, - "HGCalTowerProcessor"); +DEFINE_EDM_PLUGIN(HGCalTowerFactory, HGCalTowerProcessor, "HGCalTowerProcessor"); diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterIdentificationBDT.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterIdentificationBDT.cc index 523513a246877..b423341fbdea7 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterIdentificationBDT.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalTriggerClusterIdentificationBDT.cc @@ -5,215 +5,194 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" #include "CommonTools/MVAUtils/interface/TMVAEvaluator.h" - - -class HGCalTriggerClusterIdentificationBDT : public HGCalTriggerClusterIdentificationBase -{ - +class HGCalTriggerClusterIdentificationBDT : public HGCalTriggerClusterIdentificationBase { +public: + class Category { public: - class Category - { - public: - Category(float pt_min, float pt_max, float eta_min, float eta_max): - pt_min_(pt_min), pt_max_(pt_max), - eta_min_(eta_min), eta_max_(eta_max) - { - } - ~Category(){} - bool contains(float pt, float eta) const - { - bool output = true; - if(pt=pt_max_) output = false; - if(std::abs(eta)=eta_max_) output = false; - return output; - } - - float pt_min() const {return pt_min_;} - float pt_max() const {return pt_max_;} - float eta_min() const {return eta_min_;} - float eta_max() const {return eta_max_;} - - private: - float pt_min_ = 0.; - float pt_max_ = std::numeric_limits::max(); - float eta_min_ = 1.5; - float eta_max_ = 3.; - }; - - public: - - HGCalTriggerClusterIdentificationBDT(); - ~HGCalTriggerClusterIdentificationBDT() override{}; - void initialize(const edm::ParameterSet& conf) final; - float value(const l1t::HGCalMulticluster& cluster) const final; - bool decision(const l1t::HGCalMulticluster& cluster) const final; + Category(float pt_min, float pt_max, float eta_min, float eta_max) + : pt_min_(pt_min), pt_max_(pt_max), eta_min_(eta_min), eta_max_(eta_max) {} + ~Category() {} + bool contains(float pt, float eta) const { + bool output = true; + if (pt < pt_min_ || pt >= pt_max_) + output = false; + if (std::abs(eta) < eta_min_ || std::abs(eta) >= eta_max_) + output = false; + return output; + } + + float pt_min() const { return pt_min_; } + float pt_max() const { return pt_max_; } + float eta_min() const { return eta_min_; } + float eta_max() const { return eta_max_; } private: - enum class ClusterVariable - { - cl3d_showerlength, - cl3d_coreshowerlength, - cl3d_firstlayer, - cl3d_maxlayer, - cl3d_seetot, - cl3d_seemax, - cl3d_spptot, - cl3d_sppmax, - cl3d_szz, - cl3d_srrtot, - cl3d_srrmax, - cl3d_srrmean - }; - std::vector categories_; - std::vector> bdts_; - std::vector working_points_; - std::vector input_variables_; - std::vector input_variables_id_; - - float clusterVariable(ClusterVariable, const l1t::HGCalMulticluster&) const; - int category(float pt, float eta) const; - - + float pt_min_ = 0.; + float pt_max_ = std::numeric_limits::max(); + float eta_min_ = 1.5; + float eta_max_ = 3.; + }; + +public: + HGCalTriggerClusterIdentificationBDT(); + ~HGCalTriggerClusterIdentificationBDT() override{}; + void initialize(const edm::ParameterSet& conf) final; + float value(const l1t::HGCalMulticluster& cluster) const final; + bool decision(const l1t::HGCalMulticluster& cluster) const final; + +private: + enum class ClusterVariable { + cl3d_showerlength, + cl3d_coreshowerlength, + cl3d_firstlayer, + cl3d_maxlayer, + cl3d_seetot, + cl3d_seemax, + cl3d_spptot, + cl3d_sppmax, + cl3d_szz, + cl3d_srrtot, + cl3d_srrmax, + cl3d_srrmean + }; + std::vector categories_; + std::vector> bdts_; + std::vector working_points_; + std::vector input_variables_; + std::vector input_variables_id_; + + float clusterVariable(ClusterVariable, const l1t::HGCalMulticluster&) const; + int category(float pt, float eta) const; }; -DEFINE_HGC_TPG_CLUSTER_ID(HGCalTriggerClusterIdentificationBDT,"HGCalTriggerClusterIdentificationBDT" ); +DEFINE_HGC_TPG_CLUSTER_ID(HGCalTriggerClusterIdentificationBDT, "HGCalTriggerClusterIdentificationBDT"); +HGCalTriggerClusterIdentificationBDT::HGCalTriggerClusterIdentificationBDT() + : HGCalTriggerClusterIdentificationBase() {} -HGCalTriggerClusterIdentificationBDT:: -HGCalTriggerClusterIdentificationBDT():HGCalTriggerClusterIdentificationBase() -{ -} - -void -HGCalTriggerClusterIdentificationBDT:: -initialize(const edm::ParameterSet& conf) -{ - if(!bdts_.empty()) - { - edm::LogWarning("HGCalTriggerClusterIdentificationBDT|Initialization") - << "BDTs already initialized."; - return; +void HGCalTriggerClusterIdentificationBDT::initialize(const edm::ParameterSet& conf) { + if (!bdts_.empty()) { + edm::LogWarning("HGCalTriggerClusterIdentificationBDT|Initialization") << "BDTs already initialized."; + return; } - input_variables_ = conf.getParameter< std::vector >("Inputs"); - std::vector bdt_files = conf.getParameter< std::vector >("Weights"); + input_variables_ = conf.getParameter>("Inputs"); + std::vector bdt_files = conf.getParameter>("Weights"); std::vector categories_etamin = conf.getParameter>("CategoriesEtaMin"); std::vector categories_etamax = conf.getParameter>("CategoriesEtaMax"); std::vector categories_ptmin = conf.getParameter>("CategoriesPtMin"); std::vector categories_ptmax = conf.getParameter>("CategoriesPtMax"); working_points_ = conf.getParameter>("WorkingPoints"); - if(bdt_files.size()!=categories_etamin.size() || - categories_etamin.size()!=categories_etamax.size() || - categories_etamax.size()!=categories_ptmin.size() || - categories_ptmin.size()!=categories_ptmax.size() || - categories_ptmax.size()!=working_points_.size() - ) - { + if (bdt_files.size() != categories_etamin.size() || categories_etamin.size() != categories_etamax.size() || + categories_etamax.size() != categories_ptmin.size() || categories_ptmin.size() != categories_ptmax.size() || + categories_ptmax.size() != working_points_.size()) { throw cms::Exception("HGCalTriggerClusterIdentificationBDT|BadInitialization") - << "Inconsistent numbers of categories, BDT weight files and working points"; + << "Inconsistent numbers of categories, BDT weight files and working points"; } categories_.reserve(working_points_.size()); bdts_.reserve(working_points_.size()); - for(unsigned cat=0; cat spectators = {}; - for (const auto& file : bdt_files) - { + for (const auto& file : bdt_files) { bdts_.emplace_back(new TMVAEvaluator()); - bdts_.back()->initialize( - "!Color:Silent:!Error", - "BDT::bdt", - edm::FileInPath(file).fullPath(), - input_variables_, - spectators, - false, false); + bdts_.back()->initialize("!Color:Silent:!Error", + "BDT::bdt", + edm::FileInPath(file).fullPath(), + input_variables_, + spectators, + false, + false); } // Transform input variable strings to enum values for later comparisons input_variables_id_.reserve(input_variables_.size()); - for(const auto& variable : input_variables_) - { - if(variable=="cl3d_showerlength") input_variables_id_.push_back(ClusterVariable::cl3d_showerlength); - else if(variable=="cl3d_coreshowerlength") input_variables_id_.push_back(ClusterVariable::cl3d_coreshowerlength); - else if(variable=="cl3d_firstlayer") input_variables_id_.push_back(ClusterVariable::cl3d_firstlayer); - else if(variable=="cl3d_maxlayer") input_variables_id_.push_back(ClusterVariable::cl3d_maxlayer); - else if(variable=="cl3d_seetot") input_variables_id_.push_back(ClusterVariable::cl3d_seetot); - else if(variable=="cl3d_seemax") input_variables_id_.push_back(ClusterVariable::cl3d_seemax); - else if(variable=="cl3d_spptot") input_variables_id_.push_back(ClusterVariable::cl3d_spptot); - else if(variable=="cl3d_sppmax") input_variables_id_.push_back(ClusterVariable::cl3d_sppmax); - else if(variable=="cl3d_szz") input_variables_id_.push_back(ClusterVariable::cl3d_szz); - else if(variable=="cl3d_srrtot") input_variables_id_.push_back(ClusterVariable::cl3d_srrtot); - else if(variable=="cl3d_srrmax") input_variables_id_.push_back(ClusterVariable::cl3d_srrmax); - else if(variable=="cl3d_srrmean") input_variables_id_.push_back(ClusterVariable::cl3d_srrmean); + for (const auto& variable : input_variables_) { + if (variable == "cl3d_showerlength") + input_variables_id_.push_back(ClusterVariable::cl3d_showerlength); + else if (variable == "cl3d_coreshowerlength") + input_variables_id_.push_back(ClusterVariable::cl3d_coreshowerlength); + else if (variable == "cl3d_firstlayer") + input_variables_id_.push_back(ClusterVariable::cl3d_firstlayer); + else if (variable == "cl3d_maxlayer") + input_variables_id_.push_back(ClusterVariable::cl3d_maxlayer); + else if (variable == "cl3d_seetot") + input_variables_id_.push_back(ClusterVariable::cl3d_seetot); + else if (variable == "cl3d_seemax") + input_variables_id_.push_back(ClusterVariable::cl3d_seemax); + else if (variable == "cl3d_spptot") + input_variables_id_.push_back(ClusterVariable::cl3d_spptot); + else if (variable == "cl3d_sppmax") + input_variables_id_.push_back(ClusterVariable::cl3d_sppmax); + else if (variable == "cl3d_szz") + input_variables_id_.push_back(ClusterVariable::cl3d_szz); + else if (variable == "cl3d_srrtot") + input_variables_id_.push_back(ClusterVariable::cl3d_srrtot); + else if (variable == "cl3d_srrmax") + input_variables_id_.push_back(ClusterVariable::cl3d_srrmax); + else if (variable == "cl3d_srrmean") + input_variables_id_.push_back(ClusterVariable::cl3d_srrmean); } } -float -HGCalTriggerClusterIdentificationBDT:: -value(const l1t::HGCalMulticluster& cluster) const -{ +float HGCalTriggerClusterIdentificationBDT::value(const l1t::HGCalMulticluster& cluster) const { std::map inputs; - for(unsigned i=0; ievaluate(inputs) : -999.); + return (cat != -1 ? bdts_.at(cat)->evaluate(inputs) : -999.); } - -bool -HGCalTriggerClusterIdentificationBDT:: -decision(const l1t::HGCalMulticluster& cluster) const -{ +bool HGCalTriggerClusterIdentificationBDT::decision(const l1t::HGCalMulticluster& cluster) const { float bdt_output = value(cluster); float pt = cluster.pt(); float eta = cluster.eta(); int cat = category(pt, eta); - return (cat!=-1 ? bdt_output>working_points_.at(cat) : true); + return (cat != -1 ? bdt_output > working_points_.at(cat) : true); } -int -HGCalTriggerClusterIdentificationBDT:: -category(float pt, float eta) const -{ - for(unsigned cat=0; cat(cat); +int HGCalTriggerClusterIdentificationBDT::category(float pt, float eta) const { + for (unsigned cat = 0; cat < categories_.size(); cat++) { + if (categories_[cat].contains(pt, eta)) + return static_cast(cat); } return -1; } - - - -float -HGCalTriggerClusterIdentificationBDT:: -clusterVariable(ClusterVariable variable, const l1t::HGCalMulticluster& cluster) const -{ - switch(variable) - { - case ClusterVariable::cl3d_showerlength: return cluster.showerLength(); - case ClusterVariable::cl3d_coreshowerlength: return cluster.coreShowerLength(); - case ClusterVariable::cl3d_firstlayer: return cluster.firstLayer(); - case ClusterVariable::cl3d_maxlayer: return cluster.maxLayer(); - case ClusterVariable::cl3d_seetot: return cluster.sigmaEtaEtaTot(); - case ClusterVariable::cl3d_seemax: return cluster.sigmaEtaEtaMax(); - case ClusterVariable::cl3d_spptot: return cluster.sigmaPhiPhiTot(); - case ClusterVariable::cl3d_sppmax: return cluster.sigmaPhiPhiMax(); - case ClusterVariable::cl3d_szz: return cluster.sigmaZZ(); - case ClusterVariable::cl3d_srrtot: return cluster.sigmaRRTot(); - case ClusterVariable::cl3d_srrmax: return cluster.sigmaRRMax(); - case ClusterVariable::cl3d_srrmean: return cluster.sigmaRRMean(); - default: break; +float HGCalTriggerClusterIdentificationBDT::clusterVariable(ClusterVariable variable, + const l1t::HGCalMulticluster& cluster) const { + switch (variable) { + case ClusterVariable::cl3d_showerlength: + return cluster.showerLength(); + case ClusterVariable::cl3d_coreshowerlength: + return cluster.coreShowerLength(); + case ClusterVariable::cl3d_firstlayer: + return cluster.firstLayer(); + case ClusterVariable::cl3d_maxlayer: + return cluster.maxLayer(); + case ClusterVariable::cl3d_seetot: + return cluster.sigmaEtaEtaTot(); + case ClusterVariable::cl3d_seemax: + return cluster.sigmaEtaEtaMax(); + case ClusterVariable::cl3d_spptot: + return cluster.sigmaPhiPhiTot(); + case ClusterVariable::cl3d_sppmax: + return cluster.sigmaPhiPhiMax(); + case ClusterVariable::cl3d_szz: + return cluster.sigmaZZ(); + case ClusterVariable::cl3d_srrtot: + return cluster.sigmaRRTot(); + case ClusterVariable::cl3d_srrmax: + return cluster.sigmaRRMax(); + case ClusterVariable::cl3d_srrmean: + return cluster.sigmaRRMean(); + default: + break; } return 0.; } diff --git a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc index 32ea6af2667f7..032d998ae165b 100644 --- a/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc +++ b/L1Trigger/L1THGCal/plugins/concentrator/HGCalConcentratorProcessorSelection.cc @@ -3,54 +3,49 @@ #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" -DEFINE_EDM_PLUGIN(HGCalConcentratorFactory, - HGCalConcentratorProcessorSelection, - "HGCalConcentratorProcessorSelection"); +DEFINE_EDM_PLUGIN(HGCalConcentratorFactory, HGCalConcentratorProcessorSelection, "HGCalConcentratorProcessorSelection"); -HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf) : - HGCalConcentratorProcessorBase(conf) -{ +HGCalConcentratorProcessorSelection::HGCalConcentratorProcessorSelection(const edm::ParameterSet& conf) + : HGCalConcentratorProcessorBase(conf) { std::string selectionType(conf.getParameter("Method")); - if (selectionType == "thresholdSelect"){ + if (selectionType == "thresholdSelect") { selectionType_ = thresholdSelect; concentratorProcImpl_ = std::make_unique(conf); - } - else if (selectionType == "bestChoiceSelect"){ + } else if (selectionType == "bestChoiceSelect") { selectionType_ = bestChoiceSelect; concentratorProcImpl_ = std::make_unique(conf); - } - else if (selectionType == "superTriggerCellSelect"){ + } else if (selectionType == "superTriggerCellSelect") { selectionType_ = superTriggerCellSelect; concentratorSTCImpl_ = std::make_unique(conf); - } - else{ + } else { throw cms::Exception("HGCTriggerParameterError") - << "Unknown type of concentrator selection '" << selectionType << "'"; + << "Unknown type of concentrator selection '" << selectionType << "'"; } } -void HGCalConcentratorProcessorSelection::run(const edm::Handle& triggerCellCollInput, +void HGCalConcentratorProcessorSelection::run(const edm::Handle& triggerCellCollInput, l1t::HGCalTriggerCellBxCollection& triggerCellCollOutput, - const edm::EventSetup& es) -{ - if(concentratorProcImpl_) concentratorProcImpl_->eventSetup(es); + const edm::EventSetup& es) { + if (concentratorProcImpl_) + concentratorProcImpl_->eventSetup(es); const l1t::HGCalTriggerCellBxCollection& collInput = *triggerCellCollInput; std::unordered_map> tc_modules; - for(const auto& trigCell : collInput) { + for (const auto& trigCell : collInput) { uint32_t module = geometry_->getModuleFromTriggerCell(trigCell.detId()); tc_modules[module].push_back(trigCell); } - if ( concentratorSTCImpl_) concentratorSTCImpl_->eventSetup(es); + if (concentratorSTCImpl_) + concentratorSTCImpl_->eventSetup(es); - for( const auto& module_trigcell : tc_modules ) { + for (const auto& module_trigcell : tc_modules) { std::vector trigCellVecOutput; - switch(selectionType_){ + switch (selectionType_) { case thresholdSelect: concentratorProcImpl_->thresholdSelectImpl(module_trigcell.second, trigCellVecOutput); break; case bestChoiceSelect: - concentratorProcImpl_->bestChoiceSelectImpl(module_trigcell.second, trigCellVecOutput); + concentratorProcImpl_->bestChoiceSelectImpl(module_trigcell.second, trigCellVecOutput); break; case superTriggerCellSelect: concentratorSTCImpl_->superTriggerCellSelectImpl(module_trigcell.second, trigCellVecOutput); @@ -59,8 +54,8 @@ void HGCalConcentratorProcessorSelection::run(const edm::Handle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; - private: - edm::FileInPath l1tCellsMapping_; - edm::FileInPath l1tModulesMapping_; +private: + edm::FileInPath l1tCellsMapping_; + edm::FileInPath l1tModulesMapping_; - void fillMaps(); - void buildTriggerCellsAndModules(); + void fillMaps(); + void buildTriggerCellsAndModules(); }; - /*****************************************************************/ -HGCalTriggerGeometryHexImp1::HGCalTriggerGeometryHexImp1(const edm::ParameterSet& conf): - HGCalTriggerGeometryGenericMapping(conf), - l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), - l1tModulesMapping_(conf.getParameter("L1TModulesMapping")) +HGCalTriggerGeometryHexImp1::HGCalTriggerGeometryHexImp1(const edm::ParameterSet& conf) + : HGCalTriggerGeometryGenericMapping(conf), + l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), + l1tModulesMapping_(conf.getParameter("L1TModulesMapping")) /*****************************************************************/ -{ -} +{} /*****************************************************************/ void HGCalTriggerGeometryHexImp1::initialize(const edm::ESHandle& calo_geometry) /*****************************************************************/ { - edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n"\ - << "WARNING: There is no neighbor information.\n"; - - setCaloGeometry(calo_geometry); - fillMaps(); - buildTriggerCellsAndModules(); + edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n" + << "WARNING: There is no neighbor information.\n"; + setCaloGeometry(calo_geometry); + fillMaps(); + buildTriggerCellsAndModules(); } /*****************************************************************/ - void HGCalTriggerGeometryHexImp1::initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) +void HGCalTriggerGeometryHexImp1::initialize(const edm::ESHandle& hgc_ee_geometry, + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) /*****************************************************************/ { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry"; + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry"; } - - /*****************************************************************/ void HGCalTriggerGeometryHexImp1::fillMaps() /*****************************************************************/ { - // - // read module mapping file - std::unordered_map wafer_to_module_ee; - std::unordered_map wafer_to_module_fh; - std::unordered_map> module_to_wafers_ee; - std::unordered_map> module_to_wafers_fh; - std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); - if(!l1tModulesMappingStream.is_open()) edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TModulesMapping file\n"; - short subdet = 0; - short wafer = 0; - short module = 0; - for(; l1tModulesMappingStream>>subdet>>wafer>>module; ) - { - if(subdet==3) - { - wafer_to_module_ee.emplace(wafer,module); - auto itr_insert = module_to_wafers_ee.emplace(module, std::map()); - itr_insert.first->second.emplace(wafer, 0); - } - else if(subdet==4) - { - wafer_to_module_fh.emplace(wafer,module); - auto itr_insert = module_to_wafers_fh.emplace(module, std::map()); - itr_insert.first->second.emplace(wafer, 0); - } - else edm::LogWarning("HGCalTriggerGeometry") << "Unsupported subdetector number ("< wafer_to_module_ee; + std::unordered_map wafer_to_module_fh; + std::unordered_map> module_to_wafers_ee; + std::unordered_map> module_to_wafers_fh; + std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); + if (!l1tModulesMappingStream.is_open()) + edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TModulesMapping file\n"; + short subdet = 0; + short wafer = 0; + short module = 0; + for (; l1tModulesMappingStream >> subdet >> wafer >> module;) { + if (subdet == 3) { + wafer_to_module_ee.emplace(wafer, module); + auto itr_insert = module_to_wafers_ee.emplace(module, std::map()); + itr_insert.first->second.emplace(wafer, 0); + } else if (subdet == 4) { + wafer_to_module_fh.emplace(wafer, module); + auto itr_insert = module_to_wafers_fh.emplace(module, std::map()); + itr_insert.first->second.emplace(wafer, 0); + } else + edm::LogWarning("HGCalTriggerGeometry") + << "Unsupported subdetector number (" << subdet << ") in L1TModulesMapping file\n"; + } + if (!l1tModulesMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TModulesMapping '" << wafer << " " << module << "' \n"; + l1tModulesMappingStream.close(); + // read trigger cell mapping file + std::map, short> cells_to_trigger_cells; + std::unordered_map number_trigger_cells_in_wafers; // the map key is the wafer type + std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); + if (!l1tCellsMappingStream.is_open()) + edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n"; + short waferType = 0; + short cell = 0; + short triggerCell = 0; + for (; l1tCellsMappingStream >> waferType >> cell >> triggerCell;) { + cells_to_trigger_cells.emplace(std::make_pair((waferType ? 1 : -1), cell), triggerCell); + auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType ? 1 : -1), 0); + if (triggerCell + 1 > itr_insert.first->second) + itr_insert.first->second = triggerCell + 1; + } + if (!l1tCellsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") + << "Error reading L1TCellsMapping'" << waferType << " " << cell << " " << triggerCell << "' \n"; + l1tCellsMappingStream.close(); + // For each wafer compute the trigger cell offset according to the wafer position inside + // the module. The first wafer will have an offset equal to 0, the second an offset equal to the + // number of trigger cells in the first wafer, etc. + short offset = 0; + for (auto& module_wafers : module_to_wafers_ee) { + offset = 0; + for (auto& wafer_offset : module_wafers.second) { + wafer_offset.second = offset; + int wafer_type = (eeTopology().dddConstants().waferTypeT(wafer_offset.first) == 1 ? 1 : -1); + offset += number_trigger_cells_in_wafers.at(wafer_type); } - if(!l1tModulesMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TModulesMapping '"<, short> cells_to_trigger_cells; - std::unordered_map number_trigger_cells_in_wafers; // the map key is the wafer type - std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); - if(!l1tCellsMappingStream.is_open()) edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n"; - short waferType = 0; - short cell = 0; - short triggerCell = 0; - for(; l1tCellsMappingStream>>waferType>>cell>>triggerCell; ) - { - cells_to_trigger_cells.emplace(std::make_pair((waferType?1:-1),cell), triggerCell); - auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType?1:-1), 0); - if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1; + } + for (auto& module_wafers : module_to_wafers_fh) { + offset = 0; + for (auto& wafer_offset : module_wafers.second) { + wafer_offset.second = offset; + int wafer_type = (fhTopology().dddConstants().waferTypeT(wafer_offset.first) == 1 ? 1 : -1); + offset += number_trigger_cells_in_wafers.at(wafer_type); } - if(!l1tCellsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping'"<getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferDetId(id); + short module = wafer_to_module_ee[waferDetId.wafer()]; + short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.wafer()); + int nCells = eeTopology().dddConstants().numberCellsHexagon(waferDetId.wafer()); + for (int c = 0; c < nCells; c++) { + short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(), c)]; + // Fill cell -> trigger cell mapping + HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + waferDetId.wafer(), + c); + // The module id is used instead of the wafer id for the trigger cells + // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field + if (triggercell_offset + triggerCellId >= HGCalDetId::kHGCalCellMask) + edm::LogError("HGCalTriggerGeometry") + << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" + << triggercell_offset + triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n"; + HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + module, + triggercell_offset + triggerCellId); + cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId); + // Fill trigger cell -> module mapping + HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + module, + HGCalDetId::kHGCalCellMask); + trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId); } - for(auto& module_wafers : module_to_wafers_fh) - { - offset = 0; - for(auto& wafer_offset : module_wafers.second) - { - wafer_offset.second = offset; - int wafer_type = (fhTopology().dddConstants().waferTypeT(wafer_offset.first)==1?1:-1); - offset += number_trigger_cells_in_wafers.at(wafer_type); - } - } - // - // Loop over HGC cells - // EE - for(const auto& id : eeGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferDetId(id); - short module = wafer_to_module_ee[waferDetId.wafer()]; - short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.wafer()); - int nCells = eeTopology().dddConstants().numberCellsHexagon(waferDetId.wafer()); - for(int c=0;c trigger cell mapping - HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), waferDetId.wafer(), c); - // The module id is used instead of the wafer id for the trigger cells - // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field - if(triggercell_offset+triggerCellId >= HGCalDetId::kHGCalCellMask) edm::LogError("HGCalTriggerGeometry") << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" << triggercell_offset+triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n"; - HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, triggercell_offset + triggerCellId); - cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId); - // Fill trigger cell -> module mapping - HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, HGCalDetId::kHGCalCellMask); - trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId); - } - } - // FH - for(const auto& id : fhGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferDetId(id); - short module = wafer_to_module_fh[waferDetId.wafer()]; - short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.wafer()); - int nCells = fhTopology().dddConstants().numberCellsHexagon(waferDetId.wafer()); - for(int c=0;c trigger cell mapping - HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), waferDetId.wafer(), c); - // The module id is used instead of the wafer id for the trigger cells - // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field - if(triggercell_offset+triggerCellId >= HGCalDetId::kHGCalCellMask) edm::LogError("HGCalTriggerGeometry") << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" << triggercell_offset+triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n"; - HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, triggercell_offset + triggerCellId); - cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId); - // Fill trigger cell -> module mapping - HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), waferDetId.zside(), waferDetId.layer(), waferDetId.waferType(), module, HGCalDetId::kHGCalCellMask); - trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId); - } + } + // FH + for (const auto& id : fhGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferDetId(id); + short module = wafer_to_module_fh[waferDetId.wafer()]; + short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.wafer()); + int nCells = fhTopology().dddConstants().numberCellsHexagon(waferDetId.wafer()); + for (int c = 0; c < nCells; c++) { + short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(), c)]; + // Fill cell -> trigger cell mapping + HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + waferDetId.wafer(), + c); + // The module id is used instead of the wafer id for the trigger cells + // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field + if (triggercell_offset + triggerCellId >= HGCalDetId::kHGCalCellMask) + edm::LogError("HGCalTriggerGeometry") + << "Trigger cell id requested with a cell field larger than available in HGCalDetId (" + << triggercell_offset + triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n"; + HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + module, + triggercell_offset + triggerCellId); + cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId); + // Fill trigger cell -> module mapping + HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()), + waferDetId.zside(), + waferDetId.layer(), + waferDetId.waferType(), + module, + HGCalDetId::kHGCalCellMask); + trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId); } + } } - - /*****************************************************************/ void HGCalTriggerGeometryHexImp1::buildTriggerCellsAndModules() /*****************************************************************/ { - // - // Build trigger cells and fill map - typedef HGCalTriggerGeometry::TriggerCell::list_type list_cells; - // make list of cells in trigger cells - std::unordered_map trigger_cells_to_cells; - for(const auto& cell_triggerCell : cells_to_trigger_cells_) - { - unsigned cell = cell_triggerCell.first; - unsigned triggerCell = cell_triggerCell.second; - auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells()); - itr_exist.first->second.emplace(cell); - //trigger_cells_to_cells.at(triggerCell).emplace(cell); + // + // Build trigger cells and fill map + typedef HGCalTriggerGeometry::TriggerCell::list_type list_cells; + // make list of cells in trigger cells + std::unordered_map trigger_cells_to_cells; + for (const auto& cell_triggerCell : cells_to_trigger_cells_) { + unsigned cell = cell_triggerCell.first; + unsigned triggerCell = cell_triggerCell.second; + auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells()); + itr_exist.first->second.emplace(cell); + //trigger_cells_to_cells.at(triggerCell).emplace(cell); + } + for (const auto& triggerCell_cells : trigger_cells_to_cells) { + unsigned triggerCellId = triggerCell_cells.first; + list_cells cellIds = triggerCell_cells.second; + // Position: barycenter of the trigger cell. + Basic3DVector triggerCellVector(0., 0., 0.); + for (const auto& cell : cellIds) { + HGCalDetId cellDetId(cell); + triggerCellVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) + : fhGeometry()->getPosition(cellDetId)) + .basicVector(); } - for(const auto& triggerCell_cells : trigger_cells_to_cells) - { - unsigned triggerCellId = triggerCell_cells.first; - list_cells cellIds = triggerCell_cells.second; - // Position: barycenter of the trigger cell. - Basic3DVector triggerCellVector(0.,0.,0.); - for(const auto& cell : cellIds) - { - HGCalDetId cellDetId(cell); - triggerCellVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) : fhGeometry()->getPosition(cellDetId)).basicVector(); - } - GlobalPoint triggerCellPoint( triggerCellVector/cellIds.size() ); - const auto& triggerCellToModuleItr = trigger_cells_to_modules_.find(triggerCellId); - unsigned moduleId = (triggerCellToModuleItr!=trigger_cells_to_modules_.end() ? triggerCellToModuleItr->second : 0); // 0 if the trigger cell doesn't belong to a module - //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId); - // FIXME: empty neighbours - trigger_cells_.emplace(triggerCellId, std::make_unique(triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds)); - } - // - // Build modules and fill map - typedef HGCalTriggerGeometry::Module::list_type list_triggerCells; - typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells; - // make list of trigger cells in modules - std::unordered_map modules_to_trigger_cells; - for(const auto& triggerCell_module : trigger_cells_to_modules_) - { - unsigned triggerCell = triggerCell_module.first; - unsigned module = triggerCell_module.second; - auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells()); - itr_exist.first->second.emplace(triggerCell); - //modules_to_trigger_cells.at(module).emplace(triggerCell); - } - for(const auto& module_triggerCell : modules_to_trigger_cells) - { - unsigned moduleId = module_triggerCell.first; - list_triggerCells triggerCellIds = module_triggerCell.second; - tc_map_to_cells cellsInTriggerCells; - // Position: barycenter of the module, from trigger cell positions - Basic3DVector moduleVector(0.,0.,0.); - for(const auto& triggerCell : triggerCellIds) - { - const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell); - for( const unsigned cell : cells_in_tc ) - { - cellsInTriggerCells.emplace(triggerCell,cell); - } - moduleVector += trigger_cells_.at(triggerCell)->position().basicVector(); - } - GlobalPoint modulePoint( moduleVector/triggerCellIds.size() ); - // FIXME: empty neighbours - modules_.emplace(moduleId, std::make_unique(moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells)); + GlobalPoint triggerCellPoint(triggerCellVector / cellIds.size()); + const auto& triggerCellToModuleItr = trigger_cells_to_modules_.find(triggerCellId); + unsigned moduleId = (triggerCellToModuleItr != trigger_cells_to_modules_.end() + ? triggerCellToModuleItr->second + : 0); // 0 if the trigger cell doesn't belong to a module + //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId); + // FIXME: empty neighbours + trigger_cells_.emplace(triggerCellId, + std::make_unique( + triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds)); + } + // + // Build modules and fill map + typedef HGCalTriggerGeometry::Module::list_type list_triggerCells; + typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells; + // make list of trigger cells in modules + std::unordered_map modules_to_trigger_cells; + for (const auto& triggerCell_module : trigger_cells_to_modules_) { + unsigned triggerCell = triggerCell_module.first; + unsigned module = triggerCell_module.second; + auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells()); + itr_exist.first->second.emplace(triggerCell); + //modules_to_trigger_cells.at(module).emplace(triggerCell); + } + for (const auto& module_triggerCell : modules_to_trigger_cells) { + unsigned moduleId = module_triggerCell.first; + list_triggerCells triggerCellIds = module_triggerCell.second; + tc_map_to_cells cellsInTriggerCells; + // Position: barycenter of the module, from trigger cell positions + Basic3DVector moduleVector(0., 0., 0.); + for (const auto& triggerCell : triggerCellIds) { + const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell); + for (const unsigned cell : cells_in_tc) { + cellsInTriggerCells.emplace(triggerCell, cell); + } + moduleVector += trigger_cells_.at(triggerCell)->position().basicVector(); } + GlobalPoint modulePoint(moduleVector / triggerCellIds.size()); + // FIXME: empty neighbours + modules_.emplace(moduleId, + std::make_unique( + moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells)); + } } - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryHexImp1, - "HGCalTriggerGeometryHexImp1"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, HGCalTriggerGeometryHexImp1, "HGCalTriggerGeometryHexImp1"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexImp2.cc b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexImp2.cc index 260a9a663d3ec..ccbc6f2656c8e 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexImp2.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexImp2.cc @@ -9,836 +9,773 @@ #include #include - -class HGCalTriggerGeometryHexImp2 : public HGCalTriggerGeometryBase -{ - public: - HGCalTriggerGeometryHexImp2(const edm::ParameterSet& conf); - - void initialize(const edm::ESHandle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; - void reset() final; - - unsigned getTriggerCellFromCell( const unsigned ) const final; - unsigned getModuleFromCell( const unsigned ) const final; - unsigned getModuleFromTriggerCell( const unsigned ) const final; - - geom_set getCellsFromTriggerCell( const unsigned ) const final; - geom_set getCellsFromModule( const unsigned ) const final; - geom_set getTriggerCellsFromModule( const unsigned ) const final; - - geom_ordered_set getOrderedCellsFromModule( const unsigned ) const final; - geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned ) const final; - - geom_set getNeighborsFromTriggerCell( const unsigned ) const final; - - GlobalPoint getTriggerCellPosition(const unsigned ) const final; - GlobalPoint getModulePosition(const unsigned ) const final; - - bool validTriggerCell( const unsigned ) const final; - bool disconnectedModule(const unsigned) const final; - unsigned triggerLayer(const unsigned) const final; - - private: - edm::FileInPath l1tCellsMapping_; - edm::FileInPath l1tCellNeighborsMapping_; - edm::FileInPath l1tWaferNeighborsMapping_; - edm::FileInPath l1tModulesMapping_; - - // module related maps - std::unordered_map wafer_to_module_ee_; - std::unordered_map wafer_to_module_fh_; - std::unordered_multimap module_to_wafers_ee_; - std::unordered_multimap module_to_wafers_fh_; - - // trigger cell related maps - std::map, short> cells_to_trigger_cells_; // FIXME: something else than map? - std::multimap, short> trigger_cells_to_cells_;// FIXME: something else than map? - std::unordered_map number_trigger_cells_in_wafers_; // the map key is the wafer type - std::unordered_map number_cells_in_wafers_; // the map key is the wafer type - std::unordered_set invalid_triggercells_; - - // neighbor related maps - // trigger cell neighbors: - // - The key includes the trigger cell id and the wafer configuration. - // The wafer configuration is a 7 bits word encoding the type - // (small or large cells) of the wafer containing the trigger cell - // (central wafer) as well as the type of the 6 surrounding wafers - // - The value is a set of (wafer_idx, trigger_cell_id) - // wafer_idx is a number between 0 and 7. 0=central wafer, 1..7=surrounding - // wafers - std::unordered_map>> trigger_cell_neighbors_; - // wafer neighbors: - // List of the 6 surrounding neighbors around each wafer - std::unordered_map> wafer_neighbors_ee_; - std::unordered_map> wafer_neighbors_fh_; - - void fillMaps(); - void fillNeighborMaps(); - void fillInvalidTriggerCells(); - unsigned packTriggerCell(unsigned, const std::vector&) const; - // returns transverse wafer type: -1=coarse, 1=fine, 0=undefined - int detIdWaferType(unsigned subdet, short wafer) const; - bool validCellId(unsigned subdet, unsigned cell_id) const; - bool validTriggerCellFromCells( const unsigned ) const; +class HGCalTriggerGeometryHexImp2 : public HGCalTriggerGeometryBase { +public: + HGCalTriggerGeometryHexImp2(const edm::ParameterSet& conf); + + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; + void reset() final; + + unsigned getTriggerCellFromCell(const unsigned) const final; + unsigned getModuleFromCell(const unsigned) const final; + unsigned getModuleFromTriggerCell(const unsigned) const final; + + geom_set getCellsFromTriggerCell(const unsigned) const final; + geom_set getCellsFromModule(const unsigned) const final; + geom_set getTriggerCellsFromModule(const unsigned) const final; + + geom_ordered_set getOrderedCellsFromModule(const unsigned) const final; + geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final; + + geom_set getNeighborsFromTriggerCell(const unsigned) const final; + + GlobalPoint getTriggerCellPosition(const unsigned) const final; + GlobalPoint getModulePosition(const unsigned) const final; + + bool validTriggerCell(const unsigned) const final; + bool disconnectedModule(const unsigned) const final; + unsigned triggerLayer(const unsigned) const final; + +private: + edm::FileInPath l1tCellsMapping_; + edm::FileInPath l1tCellNeighborsMapping_; + edm::FileInPath l1tWaferNeighborsMapping_; + edm::FileInPath l1tModulesMapping_; + + // module related maps + std::unordered_map wafer_to_module_ee_; + std::unordered_map wafer_to_module_fh_; + std::unordered_multimap module_to_wafers_ee_; + std::unordered_multimap module_to_wafers_fh_; + + // trigger cell related maps + std::map, short> cells_to_trigger_cells_; // FIXME: something else than map? + std::multimap, short> trigger_cells_to_cells_; // FIXME: something else than map? + std::unordered_map number_trigger_cells_in_wafers_; // the map key is the wafer type + std::unordered_map number_cells_in_wafers_; // the map key is the wafer type + std::unordered_set invalid_triggercells_; + + // neighbor related maps + // trigger cell neighbors: + // - The key includes the trigger cell id and the wafer configuration. + // The wafer configuration is a 7 bits word encoding the type + // (small or large cells) of the wafer containing the trigger cell + // (central wafer) as well as the type of the 6 surrounding wafers + // - The value is a set of (wafer_idx, trigger_cell_id) + // wafer_idx is a number between 0 and 7. 0=central wafer, 1..7=surrounding + // wafers + std::unordered_map>> trigger_cell_neighbors_; + // wafer neighbors: + // List of the 6 surrounding neighbors around each wafer + std::unordered_map> wafer_neighbors_ee_; + std::unordered_map> wafer_neighbors_fh_; + + void fillMaps(); + void fillNeighborMaps(); + void fillInvalidTriggerCells(); + unsigned packTriggerCell(unsigned, const std::vector&) const; + // returns transverse wafer type: -1=coarse, 1=fine, 0=undefined + int detIdWaferType(unsigned subdet, short wafer) const; + bool validCellId(unsigned subdet, unsigned cell_id) const; + bool validTriggerCellFromCells(const unsigned) const; }; - -HGCalTriggerGeometryHexImp2:: -HGCalTriggerGeometryHexImp2(const edm::ParameterSet& conf): - HGCalTriggerGeometryBase(conf), - l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), - l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), - l1tWaferNeighborsMapping_(conf.getParameter("L1TWaferNeighborsMapping")), - l1tModulesMapping_(conf.getParameter("L1TModulesMapping")) -{ +HGCalTriggerGeometryHexImp2::HGCalTriggerGeometryHexImp2(const edm::ParameterSet& conf) + : HGCalTriggerGeometryBase(conf), + l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), + l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), + l1tWaferNeighborsMapping_(conf.getParameter("L1TWaferNeighborsMapping")), + l1tModulesMapping_(conf.getParameter("L1TModulesMapping")) {} + +void HGCalTriggerGeometryHexImp2::reset() { + wafer_to_module_ee_.clear(); + wafer_to_module_fh_.clear(); + module_to_wafers_ee_.clear(); + module_to_wafers_fh_.clear(); + cells_to_trigger_cells_.clear(); + trigger_cells_to_cells_.clear(); + number_trigger_cells_in_wafers_.clear(); + number_cells_in_wafers_.clear(); } -void -HGCalTriggerGeometryHexImp2:: -reset() -{ - wafer_to_module_ee_.clear(); - wafer_to_module_fh_.clear(); - module_to_wafers_ee_.clear(); - module_to_wafers_fh_.clear(); - cells_to_trigger_cells_.clear(); - trigger_cells_to_cells_.clear(); - number_trigger_cells_in_wafers_.clear(); - number_cells_in_wafers_.clear(); +void HGCalTriggerGeometryHexImp2::initialize(const edm::ESHandle& calo_geometry) { + setCaloGeometry(calo_geometry); + fillMaps(); + fillNeighborMaps(); + fillInvalidTriggerCells(); } -void -HGCalTriggerGeometryHexImp2:: -initialize(const edm::ESHandle& calo_geometry) -{ - setCaloGeometry(calo_geometry); - fillMaps(); - fillNeighborMaps(); - fillInvalidTriggerCells(); - +void HGCalTriggerGeometryHexImp2::initialize(const edm::ESHandle& hgc_ee_geometry, + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryHexImp2 geometry cannot be initialized with the V9 HGCAL geometry"; } -void -HGCalTriggerGeometryHexImp2:: -initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) -{ - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryHexImp2 geometry cannot be initialized with the V9 HGCAL geometry"; +unsigned HGCalTriggerGeometryHexImp2::getTriggerCellFromCell(const unsigned cell_id) const { + if (DetId(cell_id).det() == DetId::Hcal) + return 0; + HGCalDetId cell_det_id(cell_id); + int wafer_type = cell_det_id.waferType(); + unsigned cell = cell_det_id.cell(); + // FIXME: better way to do this cell->TC mapping? + auto trigger_cell_itr = cells_to_trigger_cells_.find(std::make_pair(wafer_type, cell)); + if (trigger_cell_itr == cells_to_trigger_cells_.end()) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: HGCal cell " << cell + << " is not mapped to any trigger cell for the wafer type " << wafer_type + << ". The trigger cell mapping should be modified.\n"; + } + unsigned trigger_cell = trigger_cell_itr->second; + return HGCalDetId((ForwardSubdetector)cell_det_id.subdetId(), + cell_det_id.zside(), + cell_det_id.layer(), + cell_det_id.waferType(), + cell_det_id.wafer(), + trigger_cell) + .rawId(); } -unsigned -HGCalTriggerGeometryHexImp2:: -getTriggerCellFromCell( const unsigned cell_id ) const -{ - if(DetId(cell_id).det() == DetId::Hcal) return 0; - HGCalDetId cell_det_id(cell_id); - int wafer_type = cell_det_id.waferType(); - unsigned cell = cell_det_id.cell(); - // FIXME: better way to do this cell->TC mapping? - auto trigger_cell_itr = cells_to_trigger_cells_.find(std::make_pair(wafer_type,cell)); - if(trigger_cell_itr==cells_to_trigger_cells_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: HGCal cell " << cell << " is not mapped to any trigger cell for the wafer type " << wafer_type - << ". The trigger cell mapping should be modified.\n"; - } - unsigned trigger_cell = trigger_cell_itr->second; - return HGCalDetId((ForwardSubdetector)cell_det_id.subdetId(), cell_det_id.zside(), cell_det_id.layer(), cell_det_id.waferType(), cell_det_id.wafer(), trigger_cell).rawId(); +unsigned HGCalTriggerGeometryHexImp2::getModuleFromCell(const unsigned cell_id) const { + if (DetId(cell_id).det() == DetId::Hcal) + return 0; + HGCalDetId cell_det_id(cell_id); + unsigned wafer = cell_det_id.wafer(); + unsigned subdet = cell_det_id.subdetId(); + std::unordered_map::const_iterator module_itr; + bool out_of_range_error = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + module_itr = wafer_to_module_ee_.find(wafer); + if (module_itr == wafer_to_module_ee_.end()) + out_of_range_error = true; + break; + case ForwardSubdetector::HGCHEF: + module_itr = wafer_to_module_fh_.find(wafer); + if (module_itr == wafer_to_module_fh_.end()) + out_of_range_error = true; + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown wafer->module mapping for subdet " << subdet << "\n"; + return 0; + }; + if (out_of_range_error) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Wafer " << wafer + << " is not mapped to any trigger module for subdetector " << subdet + << ". The module mapping should be modified. See " + "https://twiki.cern.ch/twiki/bin/viewauth/CMS/" + "HGCALTriggerPrimitivesSimulation#Trigger_geometry for details.\n"; + } + unsigned module = module_itr->second; + return HGCalDetId((ForwardSubdetector)cell_det_id.subdetId(), + cell_det_id.zside(), + cell_det_id.layer(), + cell_det_id.waferType(), + module, + HGCalDetId::kHGCalCellMask) + .rawId(); } -unsigned -HGCalTriggerGeometryHexImp2:: -getModuleFromCell( const unsigned cell_id ) const -{ - if(DetId(cell_id).det() == DetId::Hcal) return 0; - HGCalDetId cell_det_id(cell_id); - unsigned wafer = cell_det_id.wafer(); - unsigned subdet = cell_det_id.subdetId(); - std::unordered_map::const_iterator module_itr; - bool out_of_range_error = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - module_itr = wafer_to_module_ee_.find(wafer); - if(module_itr==wafer_to_module_ee_.end()) out_of_range_error = true; - break; - case ForwardSubdetector::HGCHEF: - module_itr = wafer_to_module_fh_.find(wafer); - if(module_itr==wafer_to_module_fh_.end()) out_of_range_error = true; - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown wafer->module mapping for subdet "<second; - return HGCalDetId((ForwardSubdetector)cell_det_id.subdetId(), cell_det_id.zside(), cell_det_id.layer(), cell_det_id.waferType(), module, HGCalDetId::kHGCalCellMask).rawId(); +unsigned HGCalTriggerGeometryHexImp2::getModuleFromTriggerCell(const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned wafer = trigger_cell_det_id.wafer(); + unsigned subdet = trigger_cell_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return 0; + std::unordered_map::const_iterator module_itr; + bool out_of_range_error = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + module_itr = wafer_to_module_ee_.find(wafer); + if (module_itr == wafer_to_module_ee_.end()) + out_of_range_error = true; + break; + case ForwardSubdetector::HGCHEF: + module_itr = wafer_to_module_fh_.find(wafer); + if (module_itr == wafer_to_module_fh_.end()) + out_of_range_error = true; + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown wafer->module mapping for subdet " << subdet << "\n"; + return 0; + }; + if (out_of_range_error) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Wafer " << wafer + << " is not mapped to any trigger module for subdetector " << subdet + << ". The module mapping should be modified. See " + "https://twiki.cern.ch/twiki/bin/viewauth/CMS/" + "HGCALTriggerPrimitivesSimulation#Trigger_geometry for details.\n"; + } + unsigned module = module_itr->second; + return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + trigger_cell_det_id.waferType(), + module, + HGCalDetId::kHGCalCellMask) + .rawId(); } -unsigned -HGCalTriggerGeometryHexImp2:: -getModuleFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned wafer = trigger_cell_det_id.wafer(); - unsigned subdet = trigger_cell_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return 0; - std::unordered_map::const_iterator module_itr; - bool out_of_range_error = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - module_itr = wafer_to_module_ee_.find(wafer); - if(module_itr==wafer_to_module_ee_.end()) out_of_range_error = true; - break; - case ForwardSubdetector::HGCHEF: - module_itr = wafer_to_module_fh_.find(wafer); - if(module_itr==wafer_to_module_fh_.end()) out_of_range_error = true; - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown wafer->module mapping for subdet "<second; - return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), trigger_cell_det_id.waferType(), module, HGCalDetId::kHGCalCellMask).rawId(); -} - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexImp2:: -getCellsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned subdet = trigger_cell_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_set(); - int wafer_type = trigger_cell_det_id.waferType(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - // FIXME: better way to do this TC->cell mapping? - const auto& cell_range = trigger_cells_to_cells_.equal_range(std::make_pair(wafer_type,trigger_cell)); - geom_set cell_det_ids; - for(auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++) - { - cell_det_ids.emplace(HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), trigger_cell_det_id.waferType(), trigger_cell_det_id.wafer(), tc_c_itr->second).rawId()); - } - return cell_det_ids; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexImp2::getCellsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned subdet = trigger_cell_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_set(); + int wafer_type = trigger_cell_det_id.waferType(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + // FIXME: better way to do this TC->cell mapping? + const auto& cell_range = trigger_cells_to_cells_.equal_range(std::make_pair(wafer_type, trigger_cell)); + geom_set cell_det_ids; + for (auto tc_c_itr = cell_range.first; tc_c_itr != cell_range.second; tc_c_itr++) { + cell_det_ids.emplace(HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + trigger_cell_det_id.waferType(), + trigger_cell_det_id.wafer(), + tc_c_itr->second) + .rawId()); + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexImp2:: -getCellsFromModule( const unsigned module_id ) const -{ - - HGCalDetId module_det_id(module_id); - unsigned subdet = module_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_set(); - unsigned module = module_det_id.wafer(); - std::pair::const_iterator, - std::unordered_multimap::const_iterator> wafer_itrs; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - wafer_itrs = module_to_wafers_ee_.equal_range(module); - break; - case ForwardSubdetector::HGCHEF: - wafer_itrs = module_to_wafers_fh_.equal_range(module); - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet "<second); - if(wafer_type==0) wafer_type = module_det_id.waferType(); - // loop on the cells in each wafer and return valid ones - for(int cell=0; cellsecond, cell); - if(validCellId(subdet, cell_id)) cell_det_ids.emplace(cell_id.rawId()); - } +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexImp2::getCellsFromModule(const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + unsigned subdet = module_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_set(); + unsigned module = module_det_id.wafer(); + std::pair::const_iterator, std::unordered_multimap::const_iterator> + wafer_itrs; + switch (subdet) { + case ForwardSubdetector::HGCEE: + wafer_itrs = module_to_wafers_ee_.equal_range(module); + break; + case ForwardSubdetector::HGCHEF: + wafer_itrs = module_to_wafers_fh_.equal_range(module); + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet " << subdet << "\n"; + return geom_set(); + }; + geom_set cell_det_ids; + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int wafer_type = detIdWaferType(subdet, wafer_itr->second); + if (wafer_type == 0) + wafer_type = module_det_id.waferType(); + // loop on the cells in each wafer and return valid ones + for (int cell = 0; cell < number_cells_in_wafers_.at(wafer_type); cell++) { + HGCalDetId cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + wafer_type, + wafer_itr->second, + cell); + if (validCellId(subdet, cell_id)) + cell_det_ids.emplace(cell_id.rawId()); } - return cell_det_ids; + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryHexImp2:: -getOrderedCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - unsigned subdet = module_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_ordered_set(); - unsigned module = module_det_id.wafer(); - std::pair::const_iterator, - std::unordered_multimap::const_iterator> wafer_itrs; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - wafer_itrs = module_to_wafers_ee_.equal_range(module); - break; - case ForwardSubdetector::HGCHEF: - wafer_itrs = module_to_wafers_fh_.equal_range(module); - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet "<second); - if(wafer_type==0) wafer_type = module_det_id.waferType(); - // loop on the cells in each wafer - for(int cell=0; cellsecond, cell); - if(validCellId(subdet, cell_id)) cell_det_ids.emplace(cell_id.rawId()); - } +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryHexImp2::getOrderedCellsFromModule( + const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + unsigned subdet = module_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_ordered_set(); + unsigned module = module_det_id.wafer(); + std::pair::const_iterator, std::unordered_multimap::const_iterator> + wafer_itrs; + switch (subdet) { + case ForwardSubdetector::HGCEE: + wafer_itrs = module_to_wafers_ee_.equal_range(module); + break; + case ForwardSubdetector::HGCHEF: + wafer_itrs = module_to_wafers_fh_.equal_range(module); + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet " << subdet << "\n"; + return geom_ordered_set(); + }; + geom_ordered_set cell_det_ids; + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int wafer_type = detIdWaferType(subdet, wafer_itr->second); + if (wafer_type == 0) + wafer_type = module_det_id.waferType(); + // loop on the cells in each wafer + for (int cell = 0; cell < number_cells_in_wafers_.at(wafer_type); cell++) { + HGCalDetId cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + wafer_type, + wafer_itr->second, + cell); + if (validCellId(subdet, cell_id)) + cell_det_ids.emplace(cell_id.rawId()); } - return cell_det_ids; + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexImp2:: -getTriggerCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - unsigned subdet = module_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_set(); - unsigned module = module_det_id.wafer(); - std::pair::const_iterator, - std::unordered_multimap::const_iterator> wafer_itrs; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - wafer_itrs = module_to_wafers_ee_.equal_range(module); - break; - case ForwardSubdetector::HGCHEF: - wafer_itrs = module_to_wafers_fh_.equal_range(module); - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet "<second); - if(wafer_type==0) wafer_type = module_det_id.waferType(); - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond, trigger_cell); - if(validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); - } +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexImp2::getTriggerCellsFromModule( + const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + unsigned subdet = module_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_set(); + unsigned module = module_det_id.wafer(); + std::pair::const_iterator, std::unordered_multimap::const_iterator> + wafer_itrs; + switch (subdet) { + case ForwardSubdetector::HGCEE: + wafer_itrs = module_to_wafers_ee_.equal_range(module); + break; + case ForwardSubdetector::HGCHEF: + wafer_itrs = module_to_wafers_fh_.equal_range(module); + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet " << subdet << "\n"; + return geom_set(); + }; + geom_set trigger_cell_det_ids; + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int wafer_type = detIdWaferType(subdet, wafer_itr->second); + if (wafer_type == 0) + wafer_type = module_det_id.waferType(); + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer_type); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + wafer_type, + wafer_itr->second, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryHexImp2:: -getOrderedTriggerCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - unsigned subdet = module_det_id.subdetId(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_ordered_set(); - unsigned module = module_det_id.wafer(); - std::pair::const_iterator, - std::unordered_multimap::const_iterator> wafer_itrs; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - wafer_itrs = module_to_wafers_ee_.equal_range(module); - break; - case ForwardSubdetector::HGCHEF: - wafer_itrs = module_to_wafers_fh_.equal_range(module); - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet "<second); - if(wafer_type==0) wafer_type = module_det_id.waferType(); - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond, trigger_cell); - if(validTriggerCell(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); - } +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryHexImp2::getOrderedTriggerCellsFromModule( + const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + unsigned subdet = module_det_id.subdetId(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_ordered_set(); + unsigned module = module_det_id.wafer(); + std::pair::const_iterator, std::unordered_multimap::const_iterator> + wafer_itrs; + switch (subdet) { + case ForwardSubdetector::HGCEE: + wafer_itrs = module_to_wafers_ee_.equal_range(module); + break; + case ForwardSubdetector::HGCHEF: + wafer_itrs = module_to_wafers_fh_.equal_range(module); + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown module->wafers mapping for subdet " << subdet << "\n"; + return geom_ordered_set(); + }; + geom_ordered_set trigger_cell_det_ids; + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int wafer_type = detIdWaferType(subdet, wafer_itr->second); + if (wafer_type == 0) + wafer_type = module_det_id.waferType(); + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer_type); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + wafer_type, + wafer_itr->second, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } - - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexImp2:: -getNeighborsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned wafer = trigger_cell_det_id.wafer(); - int wafer_type = trigger_cell_det_id.waferType(); - unsigned subdet = trigger_cell_det_id.subdetId(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - if(subdet==ForwardSubdetector::HGCHEB) return geom_set(); - // Retrieve surrounding wafers (around the wafer containing - // the trigger cell) - std::unordered_map>::const_iterator surrounding_wafers_itr; - bool out_of_range_error = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - surrounding_wafers_itr = wafer_neighbors_ee_.find(wafer); - if(surrounding_wafers_itr==wafer_neighbors_ee_.end()) out_of_range_error = true; - break; - case ForwardSubdetector::HGCHEF: - surrounding_wafers_itr = wafer_neighbors_fh_.find(wafer); - if(surrounding_wafers_itr==wafer_neighbors_fh_.end()) out_of_range_error = true; - break; - default: - edm::LogError("HGCalTriggerGeometry") << "Unknown wafer neighbours for subdet "<& surrounding_wafers = surrounding_wafers_itr->second; - // Find the types of the surrounding wafers - std::vector types; - types.reserve(surrounding_wafers.size()+1); // includes the central wafer -> +1 - types.emplace_back(wafer_type); - for(const auto w : surrounding_wafers) - { - // if no neighbor, use the same type as the central one - // to create the wafer configuration - int wt = wafer_type; - if(w!=-1) wt = detIdWaferType(subdet, w); - if(wt==0) return geom_set(); // invalid wafer type - types.emplace_back(wt); - } - // retrieve neighbors - unsigned trigger_cell_key = packTriggerCell(trigger_cell, types); - geom_set neighbor_detids; - auto neighbors_itr = trigger_cell_neighbors_.find(trigger_cell_key); - if(neighbors_itr==trigger_cell_neighbors_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: Neighbors are not defined for trigger cell " << trigger_cell << " with wafer configuration " - << std::bitset<7>(trigger_cell_key >> 8) << ". The trigger cell neighbor mapping should be modified. \n"; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexImp2::getNeighborsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned wafer = trigger_cell_det_id.wafer(); + int wafer_type = trigger_cell_det_id.waferType(); + unsigned subdet = trigger_cell_det_id.subdetId(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + if (subdet == ForwardSubdetector::HGCHEB) + return geom_set(); + // Retrieve surrounding wafers (around the wafer containing + // the trigger cell) + std::unordered_map>::const_iterator surrounding_wafers_itr; + bool out_of_range_error = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + surrounding_wafers_itr = wafer_neighbors_ee_.find(wafer); + if (surrounding_wafers_itr == wafer_neighbors_ee_.end()) + out_of_range_error = true; + break; + case ForwardSubdetector::HGCHEF: + surrounding_wafers_itr = wafer_neighbors_fh_.find(wafer); + if (surrounding_wafers_itr == wafer_neighbors_fh_.end()) + out_of_range_error = true; + break; + default: + edm::LogError("HGCalTriggerGeometry") << "Unknown wafer neighbours for subdet " << subdet << "\n"; + return geom_set(); + } + if (out_of_range_error) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Neighbors are not defined for wafer " << wafer + << " in subdetector " << subdet + << ". The wafer neighbor mapping should be modified. \n"; + }; + const std::vector& surrounding_wafers = surrounding_wafers_itr->second; + // Find the types of the surrounding wafers + std::vector types; + types.reserve(surrounding_wafers.size() + 1); // includes the central wafer -> +1 + types.emplace_back(wafer_type); + for (const auto w : surrounding_wafers) { + // if no neighbor, use the same type as the central one + // to create the wafer configuration + int wt = wafer_type; + if (w != -1) + wt = detIdWaferType(subdet, w); + if (wt == 0) + return geom_set(); // invalid wafer type + types.emplace_back(wt); + } + // retrieve neighbors + unsigned trigger_cell_key = packTriggerCell(trigger_cell, types); + geom_set neighbor_detids; + auto neighbors_itr = trigger_cell_neighbors_.find(trigger_cell_key); + if (neighbors_itr == trigger_cell_neighbors_.end()) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Neighbors are not defined for trigger cell " + << trigger_cell << " with wafer configuration " + << std::bitset<7>(trigger_cell_key >> 8) + << ". The trigger cell neighbor mapping should be modified. \n"; + } + const auto& neighbors = neighbors_itr->second; + // create HGCalDetId of neighbors and check their validity + neighbor_detids.reserve(neighbors.size()); + for (const auto& wafer_tc : neighbors) { + if (wafer_tc.first - 1 >= (int)surrounding_wafers.size()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Undefined wafer neighbor number " << wafer_tc.first << " for wafer " << wafer + << " and trigger cell " << trigger_cell << ". The neighbor mapping files should be modified."; } - const auto& neighbors = neighbors_itr->second; - // create HGCalDetId of neighbors and check their validity - neighbor_detids.reserve(neighbors.size()); - for(const auto& wafer_tc : neighbors) - { - if(wafer_tc.first-1>=(int)surrounding_wafers.size()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: Undefined wafer neighbor number "< triggerCellVector(0.,0.,0.); - const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); - if(cell_ids.empty()) return GlobalPoint(0,0,0); - for(const auto& cell : cell_ids) - { - HGCalDetId cellDetId(cell); - triggerCellVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) : fhGeometry()->getPosition(cellDetId)).basicVector(); - } - return GlobalPoint( triggerCellVector/cell_ids.size() ); - +GlobalPoint HGCalTriggerGeometryHexImp2::getTriggerCellPosition(const unsigned trigger_cell_det_id) const { + // Position: barycenter of the trigger cell. + Basic3DVector triggerCellVector(0., 0., 0.); + const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); + if (cell_ids.empty()) + return GlobalPoint(0, 0, 0); + for (const auto& cell : cell_ids) { + HGCalDetId cellDetId(cell); + triggerCellVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) + : fhGeometry()->getPosition(cellDetId)) + .basicVector(); + } + return GlobalPoint(triggerCellVector / cell_ids.size()); } -GlobalPoint -HGCalTriggerGeometryHexImp2:: -getModulePosition(const unsigned module_det_id) const -{ - // Position: barycenter of the module. - Basic3DVector moduleVector(0.,0.,0.); - const auto cell_ids = getCellsFromModule(module_det_id); - if(cell_ids.empty()) return GlobalPoint(0,0,0); - for(const auto& cell : cell_ids) - { - HGCalDetId cellDetId(cell); - moduleVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) : fhGeometry()->getPosition(cellDetId)).basicVector(); - } - return GlobalPoint( moduleVector/cell_ids.size() ); +GlobalPoint HGCalTriggerGeometryHexImp2::getModulePosition(const unsigned module_det_id) const { + // Position: barycenter of the module. + Basic3DVector moduleVector(0., 0., 0.); + const auto cell_ids = getCellsFromModule(module_det_id); + if (cell_ids.empty()) + return GlobalPoint(0, 0, 0); + for (const auto& cell : cell_ids) { + HGCalDetId cellDetId(cell); + moduleVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) + : fhGeometry()->getPosition(cellDetId)) + .basicVector(); + } + return GlobalPoint(moduleVector / cell_ids.size()); } - -void -HGCalTriggerGeometryHexImp2:: -fillMaps() -{ - // - // read module mapping file - std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); - if(!l1tModulesMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; - } - short subdet = 0; - short wafer = 0; - short module = 0; - for(; l1tModulesMappingStream>>subdet>>wafer>>module; ) - { - int wafer_type = detIdWaferType(subdet, wafer); - switch(subdet) - { - case ForwardSubdetector::HGCEE: - { - // fill module <-> wafers mappings - wafer_to_module_ee_.emplace(wafer,module); - module_to_wafers_ee_.emplace(module, wafer); - // fill number of cells for a given wafer type - number_cells_in_wafers_.emplace(wafer_type, eeTopology().dddConstants().numberCellsHexagon(wafer)); - break; - } - case ForwardSubdetector::HGCHEF: - { - // fill module <-> wafers mappings - wafer_to_module_fh_.emplace(wafer,module); - module_to_wafers_fh_.emplace(module, wafer); - // fill number of cells for a given wafer type - number_cells_in_wafers_.emplace(wafer_type, fhTopology().dddConstants().numberCellsHexagon(wafer)); - break; - } - default: - edm::LogWarning("HGCalTriggerGeometry") << "Unsupported subdetector number ("<>waferType>>cell>>triggerCell; ) - { - // fill cell <-> trigger cell mappings - cells_to_trigger_cells_.emplace(std::make_pair((waferType?1:-1),cell), triggerCell); - trigger_cells_to_cells_.emplace(std::make_pair((waferType?1:-1),triggerCell), cell); +void HGCalTriggerGeometryHexImp2::fillMaps() { + // + // read module mapping file + std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); + if (!l1tModulesMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; + } + short subdet = 0; + short wafer = 0; + short module = 0; + for (; l1tModulesMappingStream >> subdet >> wafer >> module;) { + int wafer_type = detIdWaferType(subdet, wafer); + switch (subdet) { + case ForwardSubdetector::HGCEE: { + // fill module <-> wafers mappings + wafer_to_module_ee_.emplace(wafer, module); + module_to_wafers_ee_.emplace(module, wafer); + // fill number of cells for a given wafer type + number_cells_in_wafers_.emplace(wafer_type, eeTopology().dddConstants().numberCellsHexagon(wafer)); + break; + } + case ForwardSubdetector::HGCHEF: { + // fill module <-> wafers mappings + wafer_to_module_fh_.emplace(wafer, module); + module_to_wafers_fh_.emplace(module, wafer); // fill number of cells for a given wafer type - auto itr_insert = number_trigger_cells_in_wafers_.emplace((waferType?1:-1), 0); - if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1; + number_cells_in_wafers_.emplace(wafer_type, fhTopology().dddConstants().numberCellsHexagon(wafer)); + break; + } + default: + edm::LogWarning("HGCalTriggerGeometry") + << "Unsupported subdetector number (" << subdet << ") in L1TModulesMapping file\n"; + break; } - if(!l1tCellsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping'"<> waferType >> cell >> triggerCell;) { + // fill cell <-> trigger cell mappings + cells_to_trigger_cells_.emplace(std::make_pair((waferType ? 1 : -1), cell), triggerCell); + trigger_cells_to_cells_.emplace(std::make_pair((waferType ? 1 : -1), triggerCell), cell); + // fill number of cells for a given wafer type + auto itr_insert = number_trigger_cells_in_wafers_.emplace((waferType ? 1 : -1), 0); + if (triggerCell + 1 > itr_insert.first->second) + itr_insert.first->second = triggerCell + 1; + } + if (!l1tCellsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") + << "Error reading L1TCellsMapping'" << waferType << " " << cell << " " << triggerCell << "' \n"; + l1tCellsMappingStream.close(); } -void -HGCalTriggerGeometryHexImp2:: -fillNeighborMaps() -{ - // Fill trigger neighbor map - std::ifstream l1tCellNeighborsMappingStream(l1tCellNeighborsMapping_.fullPath()); - if(!l1tCellNeighborsMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n"; +void HGCalTriggerGeometryHexImp2::fillNeighborMaps() { + // Fill trigger neighbor map + std::ifstream l1tCellNeighborsMappingStream(l1tCellNeighborsMapping_.fullPath()); + if (!l1tCellNeighborsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n"; + } + for (std::array buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], 512);) { + std::string line(&buffer[0]); + // Extract keys consisting of the wafer configuration + // and of the trigger cell id + // Match patterns (X,Y) + // where X is a set of 7 bits + // and Y is a number with less than 4 digits + std::regex key_regex("\\(\\s*[01]{7}\\s*,\\s*\\d{1,3}\\s*\\)"); + std::vector key_tokens{std::sregex_token_iterator(line.begin(), line.end(), key_regex), {}}; + if (key_tokens.size() != 1) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find the trigger cell key in line:\n" + << " '" << &buffer[0] << "'\n"; } - for(std::array buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], 512); ) - { - std::string line(&buffer[0]); - // Extract keys consisting of the wafer configuration - // and of the trigger cell id - // Match patterns (X,Y) - // where X is a set of 7 bits - // and Y is a number with less than 4 digits - std::regex key_regex("\\(\\s*[01]{7}\\s*,\\s*\\d{1,3}\\s*\\)"); - std::vector key_tokens { - std::sregex_token_iterator(line.begin(), line.end(), key_regex), {} - }; - if(key_tokens.size()!=1) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find the trigger cell key in line:\n" - << " '"<<&buffer[0]<<"'\n"; - } - std::regex digits_regex("([01]{7})|(\\d{1,3})"); - std::vector type_tc { - std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {} - }; - // get cell id and wafer configuration - int trigger_cell = std::stoi(type_tc[1]); - std::vector wafer_types; - wafer_types.reserve(type_tc[0].size()); - // Convert waferType coarse=0, fine=1 to coarse=-1, fine=1 - for(const char c : type_tc[0]) wafer_types.emplace_back( (std::stoi(std::string(&c))?1:-1) ); - unsigned map_key = packTriggerCell(trigger_cell, wafer_types); - // Extract neighbors - // Match patterns (X,Y) - // where X is a number with less than 4 digits - // and Y is one single digit (the neighbor wafer, between 0 and 6) - std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d\\s*\\)"); - std::vector neighbors_tokens { - std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), {} - }; - if(neighbors_tokens.empty()) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find any neighbor in line:\n" - << " '"<<&buffer[0]<<"'\n"; - } - auto itr_insert = trigger_cell_neighbors_.emplace(map_key, std::set>()); - for(const auto& neighbor : neighbors_tokens) - { - std::vector pair_neighbor { - std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), {} - }; - short neighbor_wafer(std::stoi(pair_neighbor[1])); - short neighbor_cell(std::stoi(pair_neighbor[0])); - itr_insert.first->second.emplace(neighbor_wafer, neighbor_cell); - } + std::regex digits_regex("([01]{7})|(\\d{1,3})"); + std::vector type_tc{ + std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {}}; + // get cell id and wafer configuration + int trigger_cell = std::stoi(type_tc[1]); + std::vector wafer_types; + wafer_types.reserve(type_tc[0].size()); + // Convert waferType coarse=0, fine=1 to coarse=-1, fine=1 + for (const char c : type_tc[0]) + wafer_types.emplace_back((std::stoi(std::string(&c)) ? 1 : -1)); + unsigned map_key = packTriggerCell(trigger_cell, wafer_types); + // Extract neighbors + // Match patterns (X,Y) + // where X is a number with less than 4 digits + // and Y is one single digit (the neighbor wafer, between 0 and 6) + std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d\\s*\\)"); + std::vector neighbors_tokens{std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), + {}}; + if (neighbors_tokens.empty()) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find any neighbor in line:\n" + << " '" << &buffer[0] << "'\n"; } - if(!l1tCellNeighborsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellNeighborsMapping'\n"; - l1tCellNeighborsMappingStream.close(); - - // Fill wafer neighbor map - std::ifstream l1tWaferNeighborsMappingStream(l1tWaferNeighborsMapping_.fullPath()); - if(!l1tWaferNeighborsMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TWaferNeighborsMapping file\n"; + auto itr_insert = trigger_cell_neighbors_.emplace(map_key, std::set>()); + for (const auto& neighbor : neighbors_tokens) { + std::vector pair_neighbor{std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), + {}}; + short neighbor_wafer(std::stoi(pair_neighbor[1])); + short neighbor_cell(std::stoi(pair_neighbor[0])); + itr_insert.first->second.emplace(neighbor_wafer, neighbor_cell); } - for(std::array buffer; l1tWaferNeighborsMappingStream.getline(&buffer[0], 512); ) - { - std::string line(&buffer[0]); - // split line using spaces as delimiter - std::regex delimiter("\\s+"); - std::vector tokens { - std::sregex_token_iterator(line.begin(), line.end(), delimiter, -1), {} - }; - if(tokens.size()!=8) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TWaferNeighborsMapping in line:\n" - << " '"<<&buffer[0]<<"'\n" - << " A line should be composed of 8 integers separated by spaces:\n" - << " subdet waferid neighbor1 neighbor2 neighbor3 neighbor4 neighbor5 neighbor6\n"; - } - short subdet(std::stoi(tokens[0])); - short wafer(std::stoi(tokens[1])); - - std::unordered_map>* wafer_neighbors; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - wafer_neighbors = &wafer_neighbors_ee_; - break; - case ForwardSubdetector::HGCHEF: - wafer_neighbors = &wafer_neighbors_fh_; - break; - default: - throw cms::Exception("BadGeometry") - << "Unknown subdet " << subdet << " in L1TWaferNeighborsMapping:\n" - << " '"<<&buffer[0]<<"'\n"; - }; - auto wafer_itr = wafer_neighbors->emplace(wafer, std::vector()); - for(auto neighbor_itr=tokens.cbegin()+2; neighbor_itr!=tokens.cend(); ++neighbor_itr) - { - wafer_itr.first->second.emplace_back(std::stoi(*neighbor_itr)); - } + } + if (!l1tCellNeighborsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellNeighborsMapping'\n"; + l1tCellNeighborsMappingStream.close(); + + // Fill wafer neighbor map + std::ifstream l1tWaferNeighborsMappingStream(l1tWaferNeighborsMapping_.fullPath()); + if (!l1tWaferNeighborsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TWaferNeighborsMapping file\n"; + } + for (std::array buffer; l1tWaferNeighborsMappingStream.getline(&buffer[0], 512);) { + std::string line(&buffer[0]); + // split line using spaces as delimiter + std::regex delimiter("\\s+"); + std::vector tokens{std::sregex_token_iterator(line.begin(), line.end(), delimiter, -1), {}}; + if (tokens.size() != 8) { + throw cms::Exception("BadGeometry") + << "Syntax error in the L1TWaferNeighborsMapping in line:\n" + << " '" << &buffer[0] << "'\n" + << " A line should be composed of 8 integers separated by spaces:\n" + << " subdet waferid neighbor1 neighbor2 neighbor3 neighbor4 neighbor5 neighbor6\n"; } -} - - -void -HGCalTriggerGeometryHexImp2:: -fillInvalidTriggerCells() -{ - unsigned n_layers_ee = eeTopology().dddConstants().layers(true); - for(unsigned layer=1; layer<=n_layers_ee; layer++) - { - for(const auto& wafer_module : wafer_to_module_ee_) - { - unsigned wafer = wafer_module.first; - int wafer_type = detIdWaferType(ForwardSubdetector::HGCEE, wafer); - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cell>* wafer_neighbors; + switch (subdet) { + case ForwardSubdetector::HGCEE: + wafer_neighbors = &wafer_neighbors_ee_; + break; + case ForwardSubdetector::HGCHEF: + wafer_neighbors = &wafer_neighbors_fh_; + break; + default: + throw cms::Exception("BadGeometry") << "Unknown subdet " << subdet << " in L1TWaferNeighborsMapping:\n" + << " '" << &buffer[0] << "'\n"; + }; + auto wafer_itr = wafer_neighbors->emplace(wafer, std::vector()); + for (auto neighbor_itr = tokens.cbegin() + 2; neighbor_itr != tokens.cend(); ++neighbor_itr) { + wafer_itr.first->second.emplace_back(std::stoi(*neighbor_itr)); } + } } -unsigned -HGCalTriggerGeometryHexImp2:: -packTriggerCell(unsigned trigger_cell, const std::vector& wafer_types) const -{ - unsigned packed_value = trigger_cell; - for(unsigned i=0; i& wafer_types) const { + unsigned packed_value = trigger_cell; + for (unsigned i = 0; i < wafer_types.size(); i++) { + // trigger cell id on 8 bits + // wafer configuration bits: 0=coarse, 1=fine + if (wafer_types.at(i) == 1) + packed_value += (0x1 << (8 + i)); + } + return packed_value; } -bool -HGCalTriggerGeometryHexImp2:: -validTriggerCell(const unsigned trigger_cell_id) const -{ - return invalid_triggercells_.find(trigger_cell_id)==invalid_triggercells_.end(); +int HGCalTriggerGeometryHexImp2::detIdWaferType(unsigned subdet, short wafer) const { + int wafer_type = 0; + switch (subdet) { + // HGCalDDDConstants::waferTypeT() returns 2=coarse, 1=fine + // HGCalDetId::waferType() returns -1=coarse, 1=fine + // Convert to HGCalDetId waferType + case ForwardSubdetector::HGCEE: + wafer_type = (eeTopology().dddConstants().waferTypeT(wafer) == 2 ? -1 : 1); + break; + case ForwardSubdetector::HGCHEF: + wafer_type = (fhTopology().dddConstants().waferTypeT(wafer) == 2 ? -1 : 1); + break; + default: + break; + }; + return wafer_type; } - -bool -HGCalTriggerGeometryHexImp2:: -disconnectedModule(const unsigned module_id) const -{ - return false; +bool HGCalTriggerGeometryHexImp2::validTriggerCell(const unsigned trigger_cell_id) const { + return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end(); } - -unsigned -HGCalTriggerGeometryHexImp2:: -triggerLayer(const unsigned id) const -{ - return HGCalDetId(id).layer(); +bool HGCalTriggerGeometryHexImp2::disconnectedModule(const unsigned module_id) const { return false; } + +unsigned HGCalTriggerGeometryHexImp2::triggerLayer(const unsigned id) const { return HGCalDetId(id).layer(); } + +bool HGCalTriggerGeometryHexImp2::validTriggerCellFromCells(const unsigned trigger_cell_id) const { + // Check the validity of a trigger cell with the + // validity of the cells. One valid cell in the + // trigger cell is enough to make the trigger cell + // valid. + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned subdet = trigger_cell_det_id.subdetId(); + const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + bool is_valid = false; + for (const auto cell_id : cells) { + is_valid |= validCellId(subdet, cell_id); + if (is_valid) + break; + } + return is_valid; } -bool -HGCalTriggerGeometryHexImp2:: -validTriggerCellFromCells(const unsigned trigger_cell_id) const -{ - // Check the validity of a trigger cell with the - // validity of the cells. One valid cell in the - // trigger cell is enough to make the trigger cell - // valid. - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned subdet = trigger_cell_det_id.subdetId(); - const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - bool is_valid = false; - for(const auto cell_id : cells) - { - is_valid |= validCellId(subdet, cell_id); - if(is_valid) break; - } - return is_valid; +bool HGCalTriggerGeometryHexImp2::validCellId(unsigned subdet, unsigned cell_id) const { + bool is_valid = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + is_valid = eeTopology().valid(cell_id); + break; + case ForwardSubdetector::HGCHEF: + is_valid = fhTopology().valid(cell_id); + break; + default: + is_valid = false; + break; + } + return is_valid; } -bool -HGCalTriggerGeometryHexImp2:: -validCellId(unsigned subdet, unsigned cell_id) const -{ - bool is_valid = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - is_valid = eeTopology().valid(cell_id); - break; - case ForwardSubdetector::HGCHEF: - is_valid = fhTopology().valid(cell_id); - break; - default: - is_valid = false; - break; - } - return is_valid; -} - - - - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryHexImp2, - "HGCalTriggerGeometryHexImp2"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, HGCalTriggerGeometryHexImp2, "HGCalTriggerGeometryHexImp2"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexLayerBasedImp1.cc b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexLayerBasedImp1.cc index 9aebe80da83ce..46da43440478c 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexLayerBasedImp1.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryHexLayerBasedImp1.cc @@ -10,837 +10,737 @@ #include #include - -class HGCalTriggerGeometryHexLayerBasedImp1 : public HGCalTriggerGeometryBase -{ - public: - HGCalTriggerGeometryHexLayerBasedImp1(const edm::ParameterSet& conf); - - void initialize(const edm::ESHandle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; - void reset() final; - - unsigned getTriggerCellFromCell( const unsigned ) const final; - unsigned getModuleFromCell( const unsigned ) const final; - unsigned getModuleFromTriggerCell( const unsigned ) const final; - - geom_set getCellsFromTriggerCell( const unsigned ) const final; - geom_set getCellsFromModule( const unsigned ) const final; - geom_set getTriggerCellsFromModule( const unsigned ) const final; - - geom_ordered_set getOrderedCellsFromModule( const unsigned ) const final; - geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned ) const final; - - geom_set getNeighborsFromTriggerCell( const unsigned ) const final; - - GlobalPoint getTriggerCellPosition(const unsigned ) const final; - GlobalPoint getModulePosition(const unsigned ) const final; - - bool validTriggerCell( const unsigned ) const final; - bool disconnectedModule(const unsigned) const final; - unsigned triggerLayer(const unsigned) const final; - - private: - edm::FileInPath l1tCellsMapping_; - edm::FileInPath l1tCellsBHMapping_; - edm::FileInPath l1tModulesMapping_; - edm::FileInPath l1tCellNeighborsMapping_; - edm::FileInPath l1tCellNeighborsBHMapping_; - - // module related maps - std::unordered_map wafer_to_module_; - std::unordered_multimap module_to_wafers_; - - // trigger cell related maps - std::unordered_map cells_to_trigger_cells_; - std::unordered_multimap trigger_cells_to_cells_; - std::unordered_map cells_to_trigger_cells_bh_; - std::unordered_multimap trigger_cells_to_cells_bh_; - std::unordered_map number_trigger_cells_in_wafers_; - std::unordered_map number_trigger_cells_in_wafers_bh_; - std::unordered_set invalid_triggercells_; - - // neighbor related maps - // trigger cell neighbors: - // - The key includes the module and trigger cell id - // - The value is a set of (module_id, trigger_cell_id) - std::unordered_map>> trigger_cell_neighbors_; - std::unordered_map>> trigger_cell_neighbors_bh_; - - // Disconnected modules and layers - std::unordered_set disconnected_modules_; - std::unordered_set disconnected_layers_; - std::vector trigger_layers_; - - // layer offsets - unsigned fhOffset_; - unsigned bhOffset_; - unsigned totalLayers_; - - void fillMaps(); - void fillNeighborMaps(const edm::FileInPath&, std::unordered_map>>&); - void fillInvalidTriggerCells(); - unsigned packTriggerCell(unsigned, unsigned) const; - bool validCellId(unsigned subdet, unsigned cell_id) const; - bool validTriggerCellFromCells( const unsigned ) const; - - // returns transverse wafer type: -1=coarse, 1=fine, 0=undefined - int detIdWaferType(unsigned subdet, short wafer) const; - unsigned packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const; - unsigned packIetaIphi(unsigned ieta, unsigned iphi) const; - void unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const; - void unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const; - - unsigned layerWithOffset(unsigned) const; +class HGCalTriggerGeometryHexLayerBasedImp1 : public HGCalTriggerGeometryBase { +public: + HGCalTriggerGeometryHexLayerBasedImp1(const edm::ParameterSet& conf); + + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; + void reset() final; + + unsigned getTriggerCellFromCell(const unsigned) const final; + unsigned getModuleFromCell(const unsigned) const final; + unsigned getModuleFromTriggerCell(const unsigned) const final; + + geom_set getCellsFromTriggerCell(const unsigned) const final; + geom_set getCellsFromModule(const unsigned) const final; + geom_set getTriggerCellsFromModule(const unsigned) const final; + + geom_ordered_set getOrderedCellsFromModule(const unsigned) const final; + geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final; + + geom_set getNeighborsFromTriggerCell(const unsigned) const final; + + GlobalPoint getTriggerCellPosition(const unsigned) const final; + GlobalPoint getModulePosition(const unsigned) const final; + + bool validTriggerCell(const unsigned) const final; + bool disconnectedModule(const unsigned) const final; + unsigned triggerLayer(const unsigned) const final; + +private: + edm::FileInPath l1tCellsMapping_; + edm::FileInPath l1tCellsBHMapping_; + edm::FileInPath l1tModulesMapping_; + edm::FileInPath l1tCellNeighborsMapping_; + edm::FileInPath l1tCellNeighborsBHMapping_; + + // module related maps + std::unordered_map wafer_to_module_; + std::unordered_multimap module_to_wafers_; + + // trigger cell related maps + std::unordered_map cells_to_trigger_cells_; + std::unordered_multimap trigger_cells_to_cells_; + std::unordered_map cells_to_trigger_cells_bh_; + std::unordered_multimap trigger_cells_to_cells_bh_; + std::unordered_map number_trigger_cells_in_wafers_; + std::unordered_map number_trigger_cells_in_wafers_bh_; + std::unordered_set invalid_triggercells_; + + // neighbor related maps + // trigger cell neighbors: + // - The key includes the module and trigger cell id + // - The value is a set of (module_id, trigger_cell_id) + std::unordered_map>> trigger_cell_neighbors_; + std::unordered_map>> trigger_cell_neighbors_bh_; + + // Disconnected modules and layers + std::unordered_set disconnected_modules_; + std::unordered_set disconnected_layers_; + std::vector trigger_layers_; + + // layer offsets + unsigned fhOffset_; + unsigned bhOffset_; + unsigned totalLayers_; + + void fillMaps(); + void fillNeighborMaps(const edm::FileInPath&, std::unordered_map>>&); + void fillInvalidTriggerCells(); + unsigned packTriggerCell(unsigned, unsigned) const; + bool validCellId(unsigned subdet, unsigned cell_id) const; + bool validTriggerCellFromCells(const unsigned) const; + + // returns transverse wafer type: -1=coarse, 1=fine, 0=undefined + int detIdWaferType(unsigned subdet, short wafer) const; + unsigned packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const; + unsigned packIetaIphi(unsigned ieta, unsigned iphi) const; + void unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const; + void unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const; + + unsigned layerWithOffset(unsigned) const; }; - -HGCalTriggerGeometryHexLayerBasedImp1:: -HGCalTriggerGeometryHexLayerBasedImp1(const edm::ParameterSet& conf): - HGCalTriggerGeometryBase(conf), - l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), - l1tCellsBHMapping_(conf.getParameter("L1TCellsBHMapping")), - l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), - l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), - l1tCellNeighborsBHMapping_(conf.getParameter("L1TCellNeighborsBHMapping")) -{ - std::vector tmp_vector = conf.getParameter>("DisconnectedModules"); - std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_modules_, disconnected_modules_.end())); - tmp_vector = conf.getParameter>("DisconnectedLayers"); - std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_layers_, disconnected_layers_.end())); +HGCalTriggerGeometryHexLayerBasedImp1::HGCalTriggerGeometryHexLayerBasedImp1(const edm::ParameterSet& conf) + : HGCalTriggerGeometryBase(conf), + l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), + l1tCellsBHMapping_(conf.getParameter("L1TCellsBHMapping")), + l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), + l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), + l1tCellNeighborsBHMapping_(conf.getParameter("L1TCellNeighborsBHMapping")) { + std::vector tmp_vector = conf.getParameter>("DisconnectedModules"); + std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_modules_, disconnected_modules_.end())); + tmp_vector = conf.getParameter>("DisconnectedLayers"); + std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_layers_, disconnected_layers_.end())); } -void -HGCalTriggerGeometryHexLayerBasedImp1:: -reset() -{ - cells_to_trigger_cells_.clear(); - trigger_cells_to_cells_.clear(); - cells_to_trigger_cells_bh_.clear(); - trigger_cells_to_cells_bh_.clear(); - wafer_to_module_.clear(); - module_to_wafers_.clear(); - number_trigger_cells_in_wafers_.clear(); - number_trigger_cells_in_wafers_bh_.clear(); - trigger_cell_neighbors_.clear(); - trigger_cell_neighbors_bh_.clear(); +void HGCalTriggerGeometryHexLayerBasedImp1::reset() { + cells_to_trigger_cells_.clear(); + trigger_cells_to_cells_.clear(); + cells_to_trigger_cells_bh_.clear(); + trigger_cells_to_cells_bh_.clear(); + wafer_to_module_.clear(); + module_to_wafers_.clear(); + number_trigger_cells_in_wafers_.clear(); + number_trigger_cells_in_wafers_bh_.clear(); + trigger_cell_neighbors_.clear(); + trigger_cell_neighbors_bh_.clear(); } -void -HGCalTriggerGeometryHexLayerBasedImp1:: -initialize(const edm::ESHandle& calo_geometry) -{ - setCaloGeometry(calo_geometry); - fhOffset_ = eeTopology().dddConstants().layers(true); - bhOffset_ = fhOffset_ + fhTopology().dddConstants().layers(true); - totalLayers_ = bhOffset_ + bhTopology().dddConstants()->getMaxDepth(1); - trigger_layers_.resize(totalLayers_+1); - trigger_layers_[0] = 0; // layer number 0 doesn't exist - unsigned trigger_layer = 1; - for(unsigned layer=1; layer& calo_geometry) { + setCaloGeometry(calo_geometry); + fhOffset_ = eeTopology().dddConstants().layers(true); + bhOffset_ = fhOffset_ + fhTopology().dddConstants().layers(true); + totalLayers_ = bhOffset_ + bhTopology().dddConstants()->getMaxDepth(1); + trigger_layers_.resize(totalLayers_ + 1); + trigger_layers_[0] = 0; // layer number 0 doesn't exist + unsigned trigger_layer = 1; + for (unsigned layer = 1; layer < trigger_layers_.size(); layer++) { + if (disconnected_layers_.find(layer) == disconnected_layers_.end()) { + // Increase trigger layer number if the layer is not disconnected + trigger_layers_[layer] = trigger_layer; + trigger_layer++; + } else { + trigger_layers_[layer] = 0; } - fillMaps(); - fillNeighborMaps(l1tCellNeighborsMapping_, trigger_cell_neighbors_); - fillNeighborMaps(l1tCellNeighborsBHMapping_, trigger_cell_neighbors_bh_); - fillInvalidTriggerCells(); - + } + fillMaps(); + fillNeighborMaps(l1tCellNeighborsMapping_, trigger_cell_neighbors_); + fillNeighborMaps(l1tCellNeighborsBHMapping_, trigger_cell_neighbors_bh_); + fillInvalidTriggerCells(); } -void -HGCalTriggerGeometryHexLayerBasedImp1:: -initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) -{ - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryHexLayerBasedImp1 geometry cannot be initialized with the V9 HGCAL geometry"; +void HGCalTriggerGeometryHexLayerBasedImp1::initialize(const edm::ESHandle& hgc_ee_geometry, + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryHexLayerBasedImp1 geometry cannot be initialized with the V9 HGCAL geometry"; } -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -getTriggerCellFromCell( const unsigned cell_id ) const -{ - unsigned subdet = 0; - int zside = 0; - unsigned layer = 0; - unsigned wafer_trigger_cell = 0; - unsigned trigger_cell = 0; - // BH - if(DetId(cell_id).det() == DetId::Hcal) - { - HcalDetId cell_det_id(cell_id); - if(cell_det_id.subdetId()!=HcalEndcap) return 0; - unsigned ieta = cell_det_id.ietaAbs(); - unsigned iphi = cell_det_id.iphi(); - layer = cell_det_id.depth(); - subdet = ForwardSubdetector::HGCHEB; - zside = cell_det_id.zside(); - auto trigger_cell_itr = cells_to_trigger_cells_bh_.find(packIetaIphi(ieta, iphi)); - if(trigger_cell_itr==cells_to_trigger_cells_bh_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: Hcal cell ieta=" << ieta << ", iphi="<second, wafer_trigger_cell, trigger_cell); +unsigned HGCalTriggerGeometryHexLayerBasedImp1::getTriggerCellFromCell(const unsigned cell_id) const { + unsigned subdet = 0; + int zside = 0; + unsigned layer = 0; + unsigned wafer_trigger_cell = 0; + unsigned trigger_cell = 0; + // BH + if (DetId(cell_id).det() == DetId::Hcal) { + HcalDetId cell_det_id(cell_id); + if (cell_det_id.subdetId() != HcalEndcap) + return 0; + unsigned ieta = cell_det_id.ietaAbs(); + unsigned iphi = cell_det_id.iphi(); + layer = cell_det_id.depth(); + subdet = ForwardSubdetector::HGCHEB; + zside = cell_det_id.zside(); + auto trigger_cell_itr = cells_to_trigger_cells_bh_.find(packIetaIphi(ieta, iphi)); + if (trigger_cell_itr == cells_to_trigger_cells_bh_.end()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Hcal cell ieta=" << ieta << ", iphi=" << iphi + << " is not mapped to any trigger cell. The trigger cell mapping should be modified.\n"; } - // EE or FH - else if(DetId(cell_id).det() == DetId::Forward) - { - HGCalDetId cell_det_id(cell_id); - subdet = cell_det_id.subdetId(); - layer = cell_det_id.layer(); - zside = cell_det_id.zside(); - unsigned wafer = cell_det_id.wafer(); - unsigned cell = cell_det_id.cell(); - auto trigger_cell_itr = cells_to_trigger_cells_.find(packWaferCellId(subdet, wafer, cell)); - if(trigger_cell_itr==cells_to_trigger_cells_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: HGCal cell " << cell << " in wafer "<second, wafer_trigger_cell, trigger_cell); + trigger_cell = 0; + wafer_trigger_cell = 0; + unpackWaferCellId(trigger_cell_itr->second, wafer_trigger_cell, trigger_cell); + } + // EE or FH + else if (DetId(cell_id).det() == DetId::Forward) { + HGCalDetId cell_det_id(cell_id); + subdet = cell_det_id.subdetId(); + layer = cell_det_id.layer(); + zside = cell_det_id.zside(); + unsigned wafer = cell_det_id.wafer(); + unsigned cell = cell_det_id.cell(); + auto trigger_cell_itr = cells_to_trigger_cells_.find(packWaferCellId(subdet, wafer, cell)); + if (trigger_cell_itr == cells_to_trigger_cells_.end()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: HGCal cell " << cell << " in wafer " << wafer + << " is not mapped to any trigger cell. The trigger cell mapping should be modified.\n"; } - return HGCalDetId((ForwardSubdetector)subdet, zside, layer, 1, wafer_trigger_cell, trigger_cell).rawId(); - + trigger_cell = 0; + wafer_trigger_cell = 0; + unpackWaferCellId(trigger_cell_itr->second, wafer_trigger_cell, trigger_cell); + } + return HGCalDetId((ForwardSubdetector)subdet, zside, layer, 1, wafer_trigger_cell, trigger_cell).rawId(); } -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -getModuleFromCell( const unsigned cell_id ) const -{ - return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); +unsigned HGCalTriggerGeometryHexLayerBasedImp1::getModuleFromCell(const unsigned cell_id) const { + return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); } -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -getModuleFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned module = 0; - // BH - if(trigger_cell_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - // For BH, the module ID is currently encoded as the wafer in HGCalDetId - module = trigger_cell_det_id.wafer(); - } - // EE or FH - else - { - auto module_itr = wafer_to_module_.find(trigger_cell_det_id.wafer()); - if(module_itr==wafer_to_module_.end()) - { - throw cms::Exception("BadGeometry") - <second; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::getModuleFromTriggerCell(const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned module = 0; + // BH + if (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB) { + // For BH, the module ID is currently encoded as the wafer in HGCalDetId + module = trigger_cell_det_id.wafer(); + } + // EE or FH + else { + auto module_itr = wafer_to_module_.find(trigger_cell_det_id.wafer()); + if (module_itr == wafer_to_module_.end()) { + throw cms::Exception("BadGeometry") + << trigger_cell_det_id << "HGCalTriggerGeometry: Wafer " << trigger_cell_det_id.wafer() + << " is not mapped to any trigger module. The module mapping should be modified. See " + "https://twiki.cern.ch/twiki/bin/viewauth/CMS/HGCALTriggerPrimitivesSimulation#Trigger_geometry for " + "details.\n"; } - return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), (trigger_cell_det_id.waferType()==1 ? 1:0), module, HGCalDetId::kHGCalCellMask).rawId(); + module = module_itr->second; + } + return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + (trigger_cell_det_id.waferType() == 1 ? 1 : 0), + module, + HGCalDetId::kHGCalCellMask) + .rawId(); } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getCellsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - geom_set cell_det_ids; - // BH - if(trigger_cell_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - unsigned subdet = trigger_cell_det_id.subdetId(); - unsigned trigger_wafer = trigger_cell_det_id.wafer(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - const auto& cell_range = trigger_cells_to_cells_bh_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); - for(auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++) - { - unsigned ieta = 0; - unsigned iphi = 0; - unpackIetaIphi(tc_c_itr->second, ieta, iphi); - unsigned cell_det_id = HcalDetId(HcalEndcap, trigger_cell_det_id.zside()*ieta, iphi, trigger_cell_det_id.layer()).rawId(); - if(validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id); - } +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexLayerBasedImp1::getCellsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + geom_set cell_det_ids; + // BH + if (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB) { + unsigned subdet = trigger_cell_det_id.subdetId(); + unsigned trigger_wafer = trigger_cell_det_id.wafer(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + const auto& cell_range = + trigger_cells_to_cells_bh_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); + for (auto tc_c_itr = cell_range.first; tc_c_itr != cell_range.second; tc_c_itr++) { + unsigned ieta = 0; + unsigned iphi = 0; + unpackIetaIphi(tc_c_itr->second, ieta, iphi); + unsigned cell_det_id = + HcalDetId(HcalEndcap, trigger_cell_det_id.zside() * ieta, iphi, trigger_cell_det_id.layer()).rawId(); + if (validCellId(subdet, cell_det_id)) + cell_det_ids.emplace(cell_det_id); } - // EE or FH - else - { - unsigned subdet = trigger_cell_det_id.subdetId(); - unsigned trigger_wafer = trigger_cell_det_id.wafer(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - const auto& cell_range = trigger_cells_to_cells_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); - for(auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++) - { - unsigned wafer = 0; - unsigned cell = 0; - unpackWaferCellId(tc_c_itr->second, wafer, cell); - unsigned wafer_type = (detIdWaferType(subdet, wafer)==1 ? 1 : 0); - unsigned cell_det_id = HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), wafer_type, wafer, cell).rawId(); - if(validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id); - } + } + // EE or FH + else { + unsigned subdet = trigger_cell_det_id.subdetId(); + unsigned trigger_wafer = trigger_cell_det_id.wafer(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + const auto& cell_range = trigger_cells_to_cells_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); + for (auto tc_c_itr = cell_range.first; tc_c_itr != cell_range.second; tc_c_itr++) { + unsigned wafer = 0; + unsigned cell = 0; + unpackWaferCellId(tc_c_itr->second, wafer, cell); + unsigned wafer_type = (detIdWaferType(subdet, wafer) == 1 ? 1 : 0); + unsigned cell_det_id = HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + wafer_type, + wafer, + cell) + .rawId(); + if (validCellId(subdet, cell_det_id)) + cell_det_ids.emplace(cell_det_id); } - return cell_det_ids; + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getCellsFromModule( const unsigned module_id ) const -{ - geom_set cell_det_ids; - geom_set trigger_cells = getTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexLayerBasedImp1::getCellsFromModule( + const unsigned module_id) const { + geom_set cell_det_ids; + geom_set trigger_cells = getTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getOrderedCellsFromModule( const unsigned module_id ) const -{ - geom_ordered_set cell_det_ids; - geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryHexLayerBasedImp1::getOrderedCellsFromModule( + const unsigned module_id) const { + geom_ordered_set cell_det_ids; + geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getTriggerCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - geom_set trigger_cell_det_ids; - // BH - if(module_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - unsigned module = module_det_id.wafer(); - // loop on the trigger cells in each module - for(int trigger_cell=0; trigger_cellsecond; - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond; + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + 1, + wafer, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getOrderedTriggerCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - geom_ordered_set trigger_cell_det_ids; - // BH - if(module_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - unsigned module = module_det_id.wafer(); - // loop on the trigger cells in each module - for(int trigger_cell=0; trigger_cellsecond; - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond; + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + 1, + wafer, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } - - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryHexLayerBasedImp1:: -getNeighborsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - // Choose scintillator or silicon map - const auto& neighbors_map = (trigger_cell_det_id.subdetId()==ForwardSubdetector::HGCHEB ? trigger_cell_neighbors_bh_ : trigger_cell_neighbors_); - unsigned module = trigger_cell_det_id.wafer(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - // retrieve neighbors - unsigned trigger_cell_key = packTriggerCell(module, trigger_cell); - geom_set neighbor_detids; - auto neighbors_itr = neighbors_map.find(trigger_cell_key); - if(neighbors_itr==neighbors_map.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: Neighbors are not defined for trigger cell " << trigger_cell << " in module " - << module << ". The trigger cell neighbor mapping should be modified. \n"; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryHexLayerBasedImp1::getNeighborsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + // Choose scintillator or silicon map + const auto& neighbors_map = (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB ? trigger_cell_neighbors_bh_ + : trigger_cell_neighbors_); + unsigned module = trigger_cell_det_id.wafer(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + // retrieve neighbors + unsigned trigger_cell_key = packTriggerCell(module, trigger_cell); + geom_set neighbor_detids; + auto neighbors_itr = neighbors_map.find(trigger_cell_key); + if (neighbors_itr == neighbors_map.end()) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Neighbors are not defined for trigger cell " + << trigger_cell << " in module " << module + << ". The trigger cell neighbor mapping should be modified. \n"; + } + const auto& neighbors = neighbors_itr->second; + // create HGCalDetId of neighbors and check their validity + neighbor_detids.reserve(neighbors.size()); + for (const auto& module_tc : neighbors) { + HGCalDetId neighbor_det_id((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + 1, + module_tc.first, + module_tc.second); + if (validTriggerCell(neighbor_det_id.rawId())) { + neighbor_detids.emplace(neighbor_det_id.rawId()); } - const auto& neighbors = neighbors_itr->second; - // create HGCalDetId of neighbors and check their validity - neighbor_detids.reserve(neighbors.size()); - for(const auto& module_tc : neighbors) - { - HGCalDetId neighbor_det_id((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), 1, module_tc.first, module_tc.second); - if(validTriggerCell(neighbor_det_id.rawId())) - { - neighbor_detids.emplace(neighbor_det_id.rawId()); - } - } - return neighbor_detids; + } + return neighbor_detids; } - -GlobalPoint -HGCalTriggerGeometryHexLayerBasedImp1:: -getTriggerCellPosition(const unsigned trigger_cell_det_id) const -{ - unsigned subdet = HGCalDetId(trigger_cell_det_id).subdetId(); - // Position: barycenter of the trigger cell. - Basic3DVector triggerCellVector(0.,0.,0.); - const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); - // BH - if(subdet==ForwardSubdetector::HGCHEB) - { - for(const auto& cell : cell_ids) - { - HcalDetId cellDetId(cell); - triggerCellVector += bhGeometry()->getPosition(cellDetId).basicVector(); - } +GlobalPoint HGCalTriggerGeometryHexLayerBasedImp1::getTriggerCellPosition(const unsigned trigger_cell_det_id) const { + unsigned subdet = HGCalDetId(trigger_cell_det_id).subdetId(); + // Position: barycenter of the trigger cell. + Basic3DVector triggerCellVector(0., 0., 0.); + const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); + // BH + if (subdet == ForwardSubdetector::HGCHEB) { + for (const auto& cell : cell_ids) { + HcalDetId cellDetId(cell); + triggerCellVector += bhGeometry()->getPosition(cellDetId).basicVector(); } - // EE or FH - else - { - for(const auto& cell : cell_ids) - { - HGCalDetId cellDetId(cell); - triggerCellVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) : fhGeometry()->getPosition(cellDetId)).basicVector(); - } + } + // EE or FH + else { + for (const auto& cell : cell_ids) { + HGCalDetId cellDetId(cell); + triggerCellVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) + : fhGeometry()->getPosition(cellDetId)) + .basicVector(); } - return GlobalPoint( triggerCellVector/cell_ids.size() ); - + } + return GlobalPoint(triggerCellVector / cell_ids.size()); } -GlobalPoint -HGCalTriggerGeometryHexLayerBasedImp1:: -getModulePosition(const unsigned module_det_id) const -{ - unsigned subdet = HGCalDetId(module_det_id).subdetId(); - // Position: barycenter of the module. - Basic3DVector moduleVector(0.,0.,0.); - const auto cell_ids = getCellsFromModule(module_det_id); - // BH - if(subdet==ForwardSubdetector::HGCHEB) - { - for(const auto& cell : cell_ids) - { - HcalDetId cellDetId(cell); - moduleVector += bhGeometry()->getPosition(cellDetId).basicVector(); - } +GlobalPoint HGCalTriggerGeometryHexLayerBasedImp1::getModulePosition(const unsigned module_det_id) const { + unsigned subdet = HGCalDetId(module_det_id).subdetId(); + // Position: barycenter of the module. + Basic3DVector moduleVector(0., 0., 0.); + const auto cell_ids = getCellsFromModule(module_det_id); + // BH + if (subdet == ForwardSubdetector::HGCHEB) { + for (const auto& cell : cell_ids) { + HcalDetId cellDetId(cell); + moduleVector += bhGeometry()->getPosition(cellDetId).basicVector(); } - // EE or FH - else - { - for(const auto& cell : cell_ids) - { - HGCalDetId cellDetId(cell); - moduleVector += (cellDetId.subdetId()==ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) : fhGeometry()->getPosition(cellDetId)).basicVector(); - } + } + // EE or FH + else { + for (const auto& cell : cell_ids) { + HGCalDetId cellDetId(cell); + moduleVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId) + : fhGeometry()->getPosition(cellDetId)) + .basicVector(); } - return GlobalPoint( moduleVector/cell_ids.size() ); + } + return GlobalPoint(moduleVector / cell_ids.size()); } - -void -HGCalTriggerGeometryHexLayerBasedImp1:: -fillMaps() -{ - // - // read module mapping file - std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); - if(!l1tModulesMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; - } - short trigger_wafer = 0; - short module = 0; - for(; l1tModulesMappingStream>>trigger_wafer>>module; ) - { - wafer_to_module_.emplace(trigger_wafer,module); - module_to_wafers_.emplace(module, trigger_wafer); - // Default number of trigger cell in wafer is 0 - number_trigger_cells_in_wafers_.emplace(trigger_wafer, 0); - } - if(!l1tModulesMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TModulesMapping '"<>subdet>>wafer>>cell>>trigger_wafer>>trigger_cell; ) - { - unsigned cell_key = packWaferCellId(subdet,wafer,cell); - unsigned trigger_cell_key = packWaferCellId(subdet,trigger_wafer,trigger_cell); - // fill cell <-> trigger cell mappings - cells_to_trigger_cells_.emplace(cell_key, trigger_cell_key); - trigger_cells_to_cells_.emplace(trigger_cell_key, cell_key); - // fill number of trigger cells in wafers - auto itr_insert = number_trigger_cells_in_wafers_.emplace(trigger_wafer, 0); - if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1; - } - if(!l1tCellsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping '"<>ieta>>iphi>>trigger_wafer>>trigger_cell; ) - { - unsigned cell_key = packIetaIphi(ieta,iphi); - unsigned trigger_cell_key = packWaferCellId(ForwardSubdetector::HGCHEB,trigger_wafer,trigger_cell); - // fill cell <-> trigger cell mappings - cells_to_trigger_cells_bh_.emplace(cell_key, trigger_cell_key); - trigger_cells_to_cells_bh_.emplace(trigger_cell_key, cell_key); - // fill number of trigger cells in wafers - auto itr_insert = number_trigger_cells_in_wafers_bh_.emplace(trigger_wafer, 0); - if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1; - } - if(!l1tCellsBHMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsBHMapping '"<> trigger_wafer >> module;) { + wafer_to_module_.emplace(trigger_wafer, module); + module_to_wafers_.emplace(module, trigger_wafer); + // Default number of trigger cell in wafer is 0 + number_trigger_cells_in_wafers_.emplace(trigger_wafer, 0); + } + if (!l1tModulesMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") + << "Error reading L1TModulesMapping '" << trigger_wafer << " " << module << "' \n"; + l1tModulesMappingStream.close(); + // read trigger cell mapping file + std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); + if (!l1tCellsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellsMapping file\n"; + } + short subdet = 0; + short wafer = 0; + short cell = 0; + trigger_wafer = 0; + short trigger_cell = 0; + for (; l1tCellsMappingStream >> subdet >> wafer >> cell >> trigger_wafer >> trigger_cell;) { + unsigned cell_key = packWaferCellId(subdet, wafer, cell); + unsigned trigger_cell_key = packWaferCellId(subdet, trigger_wafer, trigger_cell); + // fill cell <-> trigger cell mappings + cells_to_trigger_cells_.emplace(cell_key, trigger_cell_key); + trigger_cells_to_cells_.emplace(trigger_cell_key, cell_key); + // fill number of trigger cells in wafers + auto itr_insert = number_trigger_cells_in_wafers_.emplace(trigger_wafer, 0); + if (trigger_cell + 1 > itr_insert.first->second) + itr_insert.first->second = trigger_cell + 1; + } + if (!l1tCellsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping '" << subdet << " " << wafer << " " + << cell << " " << trigger_wafer << " " << trigger_cell << "' \n"; + l1tCellsMappingStream.close(); + // read BH trigger cell mapping file + std::ifstream l1tCellsBHMappingStream(l1tCellsBHMapping_.fullPath()); + if (!l1tCellsBHMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellsBHMapping file\n"; + } + short ieta = 0; + short iphi = 0; + trigger_wafer = 0; + trigger_cell = 0; + for (; l1tCellsBHMappingStream >> ieta >> iphi >> trigger_wafer >> trigger_cell;) { + unsigned cell_key = packIetaIphi(ieta, iphi); + unsigned trigger_cell_key = packWaferCellId(ForwardSubdetector::HGCHEB, trigger_wafer, trigger_cell); + // fill cell <-> trigger cell mappings + cells_to_trigger_cells_bh_.emplace(cell_key, trigger_cell_key); + trigger_cells_to_cells_bh_.emplace(trigger_cell_key, cell_key); + // fill number of trigger cells in wafers + auto itr_insert = number_trigger_cells_in_wafers_bh_.emplace(trigger_wafer, 0); + if (trigger_cell + 1 > itr_insert.first->second) + itr_insert.first->second = trigger_cell + 1; + } + if (!l1tCellsBHMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsBHMapping '" << ieta << " " << iphi << " " + << trigger_wafer << " " << trigger_cell << "' \n"; + l1tCellsBHMappingStream.close(); } - -void -HGCalTriggerGeometryHexLayerBasedImp1:: -fillNeighborMaps(const edm::FileInPath& file, std::unordered_map>>& neighbors_map) -{ - // Fill trigger neighbor map - std::ifstream l1tCellNeighborsMappingStream(file.fullPath()); - if(!l1tCellNeighborsMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n"; +void HGCalTriggerGeometryHexLayerBasedImp1::fillNeighborMaps( + const edm::FileInPath& file, std::unordered_map>>& neighbors_map) { + // Fill trigger neighbor map + std::ifstream l1tCellNeighborsMappingStream(file.fullPath()); + if (!l1tCellNeighborsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n"; + } + for (std::array buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], 512);) { + std::string line(&buffer[0]); + // Extract keys consisting of the module id + // and of the trigger cell id + // Match patterns (X,Y) + // where X is a number with less than 4 digis + // and Y is a number with less than 4 digits + std::regex key_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); + std::vector key_tokens{std::sregex_token_iterator(line.begin(), line.end(), key_regex), {}}; + if (key_tokens.empty()) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find the trigger cell key in line:\n" + << " '" << &buffer[0] << "'\n"; } - for(std::array buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], 512); ) - { - std::string line(&buffer[0]); - // Extract keys consisting of the module id - // and of the trigger cell id - // Match patterns (X,Y) - // where X is a number with less than 4 digis - // and Y is a number with less than 4 digits - std::regex key_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); - std::vector key_tokens { - std::sregex_token_iterator(line.begin(), line.end(), key_regex), {} - }; - if(key_tokens.empty()) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find the trigger cell key in line:\n" - << " '"<<&buffer[0]<<"'\n"; - } - std::regex digits_regex("\\d{1,3}"); - std::vector module_tc { - std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {} - }; - // get module and cell id - int module = std::stoi(module_tc[0]); - int trigger_cell = std::stoi(module_tc[1]); - unsigned map_key = packTriggerCell(module, trigger_cell); - // Extract neighbors - // Match patterns (X,Y) - // where X is a number with less than 4 digits - // and Y is a number with less than 4 digits - std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); - std::vector neighbors_tokens { - std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), {} - }; - if(neighbors_tokens.size()<2) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find any neighbor in line:\n" - << " '"<<&buffer[0]<<"'\n"; - } - auto itr_insert = neighbors_map.emplace(map_key, std::set>()); - // The first element is the key, so start at index 1 - for(unsigned i=1; i pair_neighbor { - std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), {} - }; - short neighbor_module(std::stoi(pair_neighbor[0])); - short neighbor_cell(std::stoi(pair_neighbor[1])); - itr_insert.first->second.emplace(neighbor_module, neighbor_cell); - } + std::regex digits_regex("\\d{1,3}"); + std::vector module_tc{ + std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {}}; + // get module and cell id + int module = std::stoi(module_tc[0]); + int trigger_cell = std::stoi(module_tc[1]); + unsigned map_key = packTriggerCell(module, trigger_cell); + // Extract neighbors + // Match patterns (X,Y) + // where X is a number with less than 4 digits + // and Y is a number with less than 4 digits + std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); + std::vector neighbors_tokens{std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), + {}}; + if (neighbors_tokens.size() < 2) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find any neighbor in line:\n" + << " '" << &buffer[0] << "'\n"; } - if(!l1tCellNeighborsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellNeighborsMapping'\n"; - l1tCellNeighborsMappingStream.close(); - + auto itr_insert = neighbors_map.emplace(map_key, std::set>()); + // The first element is the key, so start at index 1 + for (unsigned i = 1; i < neighbors_tokens.size(); i++) { + const auto& neighbor = neighbors_tokens[i]; + std::vector pair_neighbor{std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), + {}}; + short neighbor_module(std::stoi(pair_neighbor[0])); + short neighbor_cell(std::stoi(pair_neighbor[1])); + itr_insert.first->second.emplace(neighbor_module, neighbor_cell); + } + } + if (!l1tCellNeighborsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellNeighborsMapping'\n"; + l1tCellNeighborsMappingStream.close(); } - - -void -HGCalTriggerGeometryHexLayerBasedImp1:: -fillInvalidTriggerCells() -{ - unsigned n_layers_ee = eeTopology().dddConstants().layers(true); - for(unsigned layer=1; layer<=n_layers_ee; layer++) - { - for(const auto& wafer_module : wafer_to_module_) - { - unsigned wafer = wafer_module.first; - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cell trigger_cell_ids; - trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCEE, -1, layer, 1, wafer, trigger_cell)); - trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCEE, 1, layer, 1, wafer, trigger_cell)); - trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCHEF, -1, layer, 1, wafer, trigger_cell)); - trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCHEF, 1, layer, 1, wafer, trigger_cell)); - for(unsigned trigger_cell : trigger_cell_ids) - { - if(!validTriggerCellFromCells(trigger_cell)) invalid_triggercells_.emplace(trigger_cell); - for(unsigned neighbor : getNeighborsFromTriggerCell(trigger_cell)) - { - if(!validTriggerCellFromCells(neighbor)) invalid_triggercells_.emplace(neighbor); - } - } - } +void HGCalTriggerGeometryHexLayerBasedImp1::fillInvalidTriggerCells() { + unsigned n_layers_ee = eeTopology().dddConstants().layers(true); + for (unsigned layer = 1; layer <= n_layers_ee; layer++) { + for (const auto& wafer_module : wafer_to_module_) { + unsigned wafer = wafer_module.first; + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer); trigger_cell++) { + std::set trigger_cell_ids; + trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCEE, -1, layer, 1, wafer, trigger_cell)); + trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCEE, 1, layer, 1, wafer, trigger_cell)); + trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCHEF, -1, layer, 1, wafer, trigger_cell)); + trigger_cell_ids.emplace(HGCalDetId(ForwardSubdetector::HGCHEF, 1, layer, 1, wafer, trigger_cell)); + for (unsigned trigger_cell : trigger_cell_ids) { + if (!validTriggerCellFromCells(trigger_cell)) + invalid_triggercells_.emplace(trigger_cell); + for (unsigned neighbor : getNeighborsFromTriggerCell(trigger_cell)) { + if (!validTriggerCellFromCells(neighbor)) + invalid_triggercells_.emplace(neighbor); + } } + } } + } } -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const -{ - unsigned packed_value = 0; - const int kSubdetMask = 0x7; - packed_value |= ((cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); - packed_value |= ((wafer & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); - packed_value |= ((subdet & kSubdetMask) << (HGCalDetId::kHGCalWaferTypeOffset)); - return packed_value; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const { + unsigned packed_value = 0; + const int kSubdetMask = 0x7; + packed_value |= ((cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); + packed_value |= ((wafer & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); + packed_value |= ((subdet & kSubdetMask) << (HGCalDetId::kHGCalWaferTypeOffset)); + return packed_value; } - -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -packIetaIphi(unsigned ieta, unsigned iphi) const -{ - unsigned packed_value = 0; - packed_value |= (iphi & HcalDetId::kHcalPhiMask2); - packed_value |= ((ieta & HcalDetId::kHcalEtaMask2) << HcalDetId::kHcalEtaOffset2); - return packed_value; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::packIetaIphi(unsigned ieta, unsigned iphi) const { + unsigned packed_value = 0; + packed_value |= (iphi & HcalDetId::kHcalPhiMask2); + packed_value |= ((ieta & HcalDetId::kHcalEtaMask2) << HcalDetId::kHcalEtaOffset2); + return packed_value; } -void -HGCalTriggerGeometryHexLayerBasedImp1:: -unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const -{ - cell = wafer_cell & HGCalDetId::kHGCalCellMask; - wafer = (wafer_cell>>HGCalDetId::kHGCalWaferOffset) & HGCalDetId::kHGCalWaferMask; +void HGCalTriggerGeometryHexLayerBasedImp1::unpackWaferCellId(unsigned wafer_cell, + unsigned& wafer, + unsigned& cell) const { + cell = wafer_cell & HGCalDetId::kHGCalCellMask; + wafer = (wafer_cell >> HGCalDetId::kHGCalWaferOffset) & HGCalDetId::kHGCalWaferMask; } - -void -HGCalTriggerGeometryHexLayerBasedImp1:: -unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const -{ - iphi = ieta_iphi & HcalDetId::kHcalPhiMask2; - ieta = (ieta_iphi>>HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2; +void HGCalTriggerGeometryHexLayerBasedImp1::unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const { + iphi = ieta_iphi & HcalDetId::kHcalPhiMask2; + ieta = (ieta_iphi >> HcalDetId::kHcalEtaOffset2) & HcalDetId::kHcalEtaMask2; } -bool -HGCalTriggerGeometryHexLayerBasedImp1:: -validTriggerCell(const unsigned trigger_cell_id) const -{ - return invalid_triggercells_.find(trigger_cell_id)==invalid_triggercells_.end(); +bool HGCalTriggerGeometryHexLayerBasedImp1::validTriggerCell(const unsigned trigger_cell_id) const { + return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end(); } -bool -HGCalTriggerGeometryHexLayerBasedImp1:: -disconnectedModule(const unsigned module_id) const -{ - bool disconnected = false; - if(disconnected_modules_.find(HGCalDetId(module_id).wafer())!=disconnected_modules_.end()) disconnected = true; - if(disconnected_layers_.find(layerWithOffset(module_id))!=disconnected_layers_.end()) disconnected = true; - return disconnected; +bool HGCalTriggerGeometryHexLayerBasedImp1::disconnectedModule(const unsigned module_id) const { + bool disconnected = false; + if (disconnected_modules_.find(HGCalDetId(module_id).wafer()) != disconnected_modules_.end()) + disconnected = true; + if (disconnected_layers_.find(layerWithOffset(module_id)) != disconnected_layers_.end()) + disconnected = true; + return disconnected; } -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -triggerLayer(const unsigned id) const -{ - unsigned layer = layerWithOffset(id); - if(layer>=trigger_layers_.size()) return 0; - return trigger_layers_[layer]; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::triggerLayer(const unsigned id) const { + unsigned layer = layerWithOffset(id); + if (layer >= trigger_layers_.size()) + return 0; + return trigger_layers_[layer]; } -bool -HGCalTriggerGeometryHexLayerBasedImp1:: -validTriggerCellFromCells(const unsigned trigger_cell_id) const -{ - // Check the validity of a trigger cell with the - // validity of the cells. One valid cell in the - // trigger cell is enough to make the trigger cell - // valid. - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned subdet = trigger_cell_det_id.subdetId(); - const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - bool is_valid = false; - for(const auto cell_id : cells) - { - is_valid |= validCellId(subdet, cell_id); - if(is_valid) break; - } - return is_valid; +bool HGCalTriggerGeometryHexLayerBasedImp1::validTriggerCellFromCells(const unsigned trigger_cell_id) const { + // Check the validity of a trigger cell with the + // validity of the cells. One valid cell in the + // trigger cell is enough to make the trigger cell + // valid. + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned subdet = trigger_cell_det_id.subdetId(); + const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + bool is_valid = false; + for (const auto cell_id : cells) { + is_valid |= validCellId(subdet, cell_id); + if (is_valid) + break; + } + return is_valid; } -bool -HGCalTriggerGeometryHexLayerBasedImp1:: -validCellId(unsigned subdet, unsigned cell_id) const -{ - bool is_valid = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - is_valid = eeTopology().valid(cell_id); - break; - case ForwardSubdetector::HGCHEF: - is_valid = fhTopology().valid(cell_id); - break; - case ForwardSubdetector::HGCHEB: - is_valid = bhTopology().valid(cell_id); - break; - default: - is_valid = false; - break; - } - return is_valid; +bool HGCalTriggerGeometryHexLayerBasedImp1::validCellId(unsigned subdet, unsigned cell_id) const { + bool is_valid = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + is_valid = eeTopology().valid(cell_id); + break; + case ForwardSubdetector::HGCHEF: + is_valid = fhTopology().valid(cell_id); + break; + case ForwardSubdetector::HGCHEB: + is_valid = bhTopology().valid(cell_id); + break; + default: + is_valid = false; + break; + } + return is_valid; } - -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -packTriggerCell(unsigned module, unsigned trigger_cell) const -{ - unsigned packed_value = 0; - packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); - packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); - return packed_value; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::packTriggerCell(unsigned module, unsigned trigger_cell) const { + unsigned packed_value = 0; + packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); + packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); + return packed_value; } -int -HGCalTriggerGeometryHexLayerBasedImp1:: -detIdWaferType(unsigned subdet, short wafer) const -{ - int wafer_type = 0; - switch(subdet) - { - // HGCalDDDConstants::waferTypeT() returns 2=coarse, 1=fine - // HGCalDetId::waferType() returns -1=coarse, 1=fine - // Convert to HGCalDetId waferType - case ForwardSubdetector::HGCEE: - wafer_type = (eeTopology().dddConstants().waferTypeT(wafer)==2?-1:1); - break; - case ForwardSubdetector::HGCHEF: - wafer_type = (fhTopology().dddConstants().waferTypeT(wafer)==2?-1:1); - break; - default: - break; - }; - return wafer_type; +int HGCalTriggerGeometryHexLayerBasedImp1::detIdWaferType(unsigned subdet, short wafer) const { + int wafer_type = 0; + switch (subdet) { + // HGCalDDDConstants::waferTypeT() returns 2=coarse, 1=fine + // HGCalDetId::waferType() returns -1=coarse, 1=fine + // Convert to HGCalDetId waferType + case ForwardSubdetector::HGCEE: + wafer_type = (eeTopology().dddConstants().waferTypeT(wafer) == 2 ? -1 : 1); + break; + case ForwardSubdetector::HGCHEF: + wafer_type = (fhTopology().dddConstants().waferTypeT(wafer) == 2 ? -1 : 1); + break; + default: + break; + }; + return wafer_type; } - -unsigned -HGCalTriggerGeometryHexLayerBasedImp1:: -layerWithOffset(unsigned id) const -{ - HGCalDetId detid(id); - unsigned layer = 0; - switch(detid.subdetId()) - { - case ForwardSubdetector::HGCEE: - layer = detid.layer(); - break; - case ForwardSubdetector::HGCHEF: - layer = fhOffset_ + detid.layer(); - break; - case ForwardSubdetector::HGCHEB: - layer = bhOffset_ + detid.layer(); - break; - }; - return layer; +unsigned HGCalTriggerGeometryHexLayerBasedImp1::layerWithOffset(unsigned id) const { + HGCalDetId detid(id); + unsigned layer = 0; + switch (detid.subdetId()) { + case ForwardSubdetector::HGCEE: + layer = detid.layer(); + break; + case ForwardSubdetector::HGCHEF: + layer = fhOffset_ + detid.layer(); + break; + case ForwardSubdetector::HGCHEB: + layer = bhOffset_ + detid.layer(); + break; + }; + return layer; } - - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryHexLayerBasedImp1, - "HGCalTriggerGeometryHexLayerBasedImp1"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, + HGCalTriggerGeometryHexLayerBasedImp1, + "HGCalTriggerGeometryHexLayerBasedImp1"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryImp1.cc b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryImp1.cc index 664948f33a835..8f31350ae2851 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryImp1.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryImp1.cc @@ -8,163 +8,153 @@ #include #include +class HGCalTriggerGeometryImp1 : public HGCalTriggerGeometryGenericMapping { +public: + HGCalTriggerGeometryImp1(const edm::ParameterSet& conf); -class HGCalTriggerGeometryImp1 : public HGCalTriggerGeometryGenericMapping -{ - public: - HGCalTriggerGeometryImp1(const edm::ParameterSet& conf); - - void initialize(const edm::ESHandle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; - private: - edm::FileInPath l1tCellsMapping_; +private: + edm::FileInPath l1tCellsMapping_; - void buildMaps(); + void buildMaps(); }; - /*****************************************************************/ -HGCalTriggerGeometryImp1::HGCalTriggerGeometryImp1(const edm::ParameterSet& conf): - HGCalTriggerGeometryGenericMapping(conf), - l1tCellsMapping_(conf.getParameter("L1TCellsMapping")) +HGCalTriggerGeometryImp1::HGCalTriggerGeometryImp1(const edm::ParameterSet& conf) + : HGCalTriggerGeometryGenericMapping(conf), + l1tCellsMapping_(conf.getParameter("L1TCellsMapping")) /*****************************************************************/ -{ -} +{} /*****************************************************************/ void HGCalTriggerGeometryImp1::initialize(const edm::ESHandle& calo_geometry) /*****************************************************************/ { - // FIXME: !!!Only for HGCEE for the moment!!! - edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n"\ - << "WARNING: Only the EE part is covered.\n"\ - << "WARNING: There is no neighbor information.\n"; - setCaloGeometry(calo_geometry); + // FIXME: !!!Only for HGCEE for the moment!!! + edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n" + << "WARNING: Only the EE part is covered.\n" + << "WARNING: There is no neighbor information.\n"; + setCaloGeometry(calo_geometry); } /*****************************************************************/ void HGCalTriggerGeometryImp1::initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) /*****************************************************************/ { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryImp1 geometry cannot be initialized with the V9 HGCAL geometry"; + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryImp1 geometry cannot be initialized with the V9 HGCAL geometry"; } - /*****************************************************************/ void HGCalTriggerGeometryImp1::buildMaps() /*****************************************************************/ { - // - // read trigger cell mapping file - std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); - if(!l1tCellsMappingStream.is_open()) edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n"; - short layer = 0; - short subsector = 0; - short cell = 0; - short module = 0; - short triggercell = 0; - for(; l1tCellsMappingStream>>layer>>subsector>>cell>>module>>triggercell; ) - { - if(layer>30 || layer<=0) - { - edm::LogWarning("HGCalTriggerGeometry") << "Bad layer index in L1TCellsMapping\n"; - continue; - } - // Loop on all sectors - // FIXME: Number of sectors in each zside should not be hardcoded - for(unsigned z=0; z<=1; z++) - { - int zside = (z==0 ? -1 : 1); - for(unsigned sector=1; sector<=18; sector++) - { - HGCEEDetId detid(HGCEE, zside, layer, sector, subsector, cell); - // - // Fill cell -> trigger cell mapping - HGCTriggerDetId triggerDetid(HGCTrigger, zside, layer, sector, module, triggercell); - const auto& ret = cells_to_trigger_cells_.insert( std::make_pair(detid, triggerDetid) ); - if(!ret.second) edm::LogWarning("HGCalTriggerGeometry") << "Duplicate cell in L1TCellsMapping\n"; - // Fill trigger cell -> module mapping - HGCTriggerDetId moduleDetid(HGCTrigger, zside, layer, sector, module, HGCTriggerDetId::UndefinedCell() ); - trigger_cells_to_modules_.insert( std::make_pair(triggerDetid, moduleDetid) ); // do nothing if trigger cell has already been inserted - } - } + // + // read trigger cell mapping file + std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); + if (!l1tCellsMappingStream.is_open()) + edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n"; + short layer = 0; + short subsector = 0; + short cell = 0; + short module = 0; + short triggercell = 0; + for (; l1tCellsMappingStream >> layer >> subsector >> cell >> module >> triggercell;) { + if (layer > 30 || layer <= 0) { + edm::LogWarning("HGCalTriggerGeometry") << "Bad layer index in L1TCellsMapping\n"; + continue; } - if(!l1tCellsMappingStream.eof()) edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TCellsMapping'"< trigger_cells_to_cells; - for(const auto& cell_triggercell : cells_to_trigger_cells_) - { - unsigned cell = cell_triggercell.first; - unsigned triggercell = cell_triggercell.second; - trigger_cells_to_cells.insert( std::make_pair(triggercell, list_cells()) ); - trigger_cells_to_cells.at(triggercell).insert(cell); + // Loop on all sectors + // FIXME: Number of sectors in each zside should not be hardcoded + for (unsigned z = 0; z <= 1; z++) { + int zside = (z == 0 ? -1 : 1); + for (unsigned sector = 1; sector <= 18; sector++) { + HGCEEDetId detid(HGCEE, zside, layer, sector, subsector, cell); + // + // Fill cell -> trigger cell mapping + HGCTriggerDetId triggerDetid(HGCTrigger, zside, layer, sector, module, triggercell); + const auto& ret = cells_to_trigger_cells_.insert(std::make_pair(detid, triggerDetid)); + if (!ret.second) + edm::LogWarning("HGCalTriggerGeometry") << "Duplicate cell in L1TCellsMapping\n"; + // Fill trigger cell -> module mapping + HGCTriggerDetId moduleDetid(HGCTrigger, zside, layer, sector, module, HGCTriggerDetId::UndefinedCell()); + trigger_cells_to_modules_.insert( + std::make_pair(triggerDetid, moduleDetid)); // do nothing if trigger cell has already been inserted + } } - for(const auto& triggercell_cells : trigger_cells_to_cells) - { - unsigned triggercellId = triggercell_cells.first; - list_cells cellIds = triggercell_cells.second; - // Position: for the moment, barycenter of the trigger cell. - Basic3DVector triggercellVector(0.,0.,0.); - for(const auto& cell : cellIds) - { - HGCTriggerDetId cellId(cell); - triggercellVector += eeGeometry()->getPosition(cellId).basicVector(); - } - GlobalPoint triggercellPoint( triggercellVector/cellIds.size() ); - const auto& tc2mItr = trigger_cells_to_modules_.find(triggercellId); - unsigned moduleId = (tc2mItr!=trigger_cells_to_modules_.end() ? tc2mItr->second : 0); // 0 if the trigger cell doesn't belong to a module - //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId); - // FIXME: empty neighbours - std::unique_ptr triggercellPtr(new HGCalTriggerGeometry::TriggerCell(triggercellId, moduleId, triggercellPoint, list_cells(), cellIds)); - trigger_cells_.insert( std::make_pair(triggercellId, std::move(triggercellPtr)) ); + } + if (!l1tCellsMappingStream.eof()) + edm::LogWarning("HGCalTriggerGeometry") + << "Error reading L1TCellsMapping'" << layer << " " << cell << " " << triggercell << " " << subsector << "' \n"; + l1tCellsMappingStream.close(); + // + // Build trigger cells and fill map + typedef HGCalTriggerGeometry::TriggerCell::list_type list_cells; + // make list of cells in trigger cells + std::map trigger_cells_to_cells; + for (const auto& cell_triggercell : cells_to_trigger_cells_) { + unsigned cell = cell_triggercell.first; + unsigned triggercell = cell_triggercell.second; + trigger_cells_to_cells.insert(std::make_pair(triggercell, list_cells())); + trigger_cells_to_cells.at(triggercell).insert(cell); + } + for (const auto& triggercell_cells : trigger_cells_to_cells) { + unsigned triggercellId = triggercell_cells.first; + list_cells cellIds = triggercell_cells.second; + // Position: for the moment, barycenter of the trigger cell. + Basic3DVector triggercellVector(0., 0., 0.); + for (const auto& cell : cellIds) { + HGCTriggerDetId cellId(cell); + triggercellVector += eeGeometry()->getPosition(cellId).basicVector(); } - // - // Build modules and fill map - typedef HGCalTriggerGeometry::Module::list_type list_triggercells; - typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells; - // make list of trigger cells in modules - std::map modules_to_trigger_cells; - for(const auto& triggercell_module : trigger_cells_to_modules_) - { - unsigned triggercell = triggercell_module.first; - unsigned module = triggercell_module.second; - modules_to_trigger_cells.insert( std::make_pair(module, list_triggercells()) ); - modules_to_trigger_cells.at(module).insert(triggercell); - } - for(const auto& module_triggercell : modules_to_trigger_cells) - { - unsigned moduleId = module_triggercell.first; - list_triggercells triggercellIds = module_triggercell.second; - tc_map_to_cells cellsInTriggerCells; - // Position: for the moment, barycenter of the module, from trigger cell positions - Basic3DVector moduleVector(0.,0.,0.); - for(const auto& triggercell : triggercellIds) - { - const auto& cells_in_tc = trigger_cells_to_cells[triggercell]; - for( const unsigned cell : cells_in_tc ) { - cellsInTriggerCells.emplace(triggercell,cell); - } - moduleVector += trigger_cells_.at(triggercell)->position().basicVector(); - } - GlobalPoint modulePoint( moduleVector/triggercellIds.size() ); - // FIXME: empty neighbours - std::unique_ptr modulePtr(new HGCalTriggerGeometry::Module(moduleId, modulePoint, list_triggercells(), triggercellIds, cellsInTriggerCells)); - modules_.insert( std::make_pair(moduleId, std::move(modulePtr)) ); + GlobalPoint triggercellPoint(triggercellVector / cellIds.size()); + const auto& tc2mItr = trigger_cells_to_modules_.find(triggercellId); + unsigned moduleId = + (tc2mItr != trigger_cells_to_modules_.end() ? tc2mItr->second + : 0); // 0 if the trigger cell doesn't belong to a module + //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId); + // FIXME: empty neighbours + std::unique_ptr triggercellPtr( + new HGCalTriggerGeometry::TriggerCell(triggercellId, moduleId, triggercellPoint, list_cells(), cellIds)); + trigger_cells_.insert(std::make_pair(triggercellId, std::move(triggercellPtr))); + } + // + // Build modules and fill map + typedef HGCalTriggerGeometry::Module::list_type list_triggercells; + typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells; + // make list of trigger cells in modules + std::map modules_to_trigger_cells; + for (const auto& triggercell_module : trigger_cells_to_modules_) { + unsigned triggercell = triggercell_module.first; + unsigned module = triggercell_module.second; + modules_to_trigger_cells.insert(std::make_pair(module, list_triggercells())); + modules_to_trigger_cells.at(module).insert(triggercell); + } + for (const auto& module_triggercell : modules_to_trigger_cells) { + unsigned moduleId = module_triggercell.first; + list_triggercells triggercellIds = module_triggercell.second; + tc_map_to_cells cellsInTriggerCells; + // Position: for the moment, barycenter of the module, from trigger cell positions + Basic3DVector moduleVector(0., 0., 0.); + for (const auto& triggercell : triggercellIds) { + const auto& cells_in_tc = trigger_cells_to_cells[triggercell]; + for (const unsigned cell : cells_in_tc) { + cellsInTriggerCells.emplace(triggercell, cell); + } + moduleVector += trigger_cells_.at(triggercell)->position().basicVector(); } + GlobalPoint modulePoint(moduleVector / triggercellIds.size()); + // FIXME: empty neighbours + std::unique_ptr modulePtr(new HGCalTriggerGeometry::Module( + moduleId, modulePoint, list_triggercells(), triggercellIds, cellsInTriggerCells)); + modules_.insert(std::make_pair(moduleId, std::move(modulePtr))); + } } - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryImp1, - "HGCalTriggerGeometryImp1"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, HGCalTriggerGeometryImp1, "HGCalTriggerGeometryImp1"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp1.cc b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp1.cc index dd64cb74dc6d1..889bc2598dda6 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp1.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp1.cc @@ -10,1040 +10,901 @@ #include #include - -class HGCalTriggerGeometryV9Imp1 : public HGCalTriggerGeometryBase -{ - public: - HGCalTriggerGeometryV9Imp1(const edm::ParameterSet& conf); - - void initialize(const edm::ESHandle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; - void reset() final; - - unsigned getTriggerCellFromCell( const unsigned ) const final; - unsigned getModuleFromCell( const unsigned ) const final; - unsigned getModuleFromTriggerCell( const unsigned ) const final; - - geom_set getCellsFromTriggerCell( const unsigned ) const final; - geom_set getCellsFromModule( const unsigned ) const final; - geom_set getTriggerCellsFromModule( const unsigned ) const final; - - geom_ordered_set getOrderedCellsFromModule( const unsigned ) const final; - geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned ) const final; - - geom_set getNeighborsFromTriggerCell( const unsigned ) const final; - - GlobalPoint getTriggerCellPosition(const unsigned ) const final; - GlobalPoint getModulePosition(const unsigned ) const final; - - bool validTriggerCell( const unsigned ) const final; - bool disconnectedModule(const unsigned) const final; - unsigned triggerLayer(const unsigned) const final; - - private: - edm::FileInPath l1tCellsMapping_; - edm::FileInPath l1tCellsSciMapping_; - edm::FileInPath l1tWafersMapping_; - edm::FileInPath l1tModulesMapping_; - edm::FileInPath l1tCellNeighborsMapping_; - edm::FileInPath l1tCellNeighborsSciMapping_; - - // module related maps - std::unordered_map wafer_to_module_; - std::unordered_multimap module_to_wafers_; - - // trigger cell related maps - std::unordered_map cells_to_trigger_cells_; - std::unordered_multimap trigger_cells_to_cells_; - std::unordered_map cells_to_trigger_cells_sci_; - std::unordered_multimap trigger_cells_to_cells_sci_; - std::unordered_map number_trigger_cells_in_wafers_; - std::unordered_map number_trigger_cells_in_wafers_sci_; - std::unordered_map wafers_to_wafers_old_; - std::unordered_map wafers_old_to_wafers_; - std::unordered_set invalid_triggercells_; - - // neighbor related maps - // trigger cell neighbors: - // - The key includes the module and trigger cell id - // - The value is a set of (module_id, trigger_cell_id) - typedef std::unordered_map>> neighbor_map; - neighbor_map trigger_cell_neighbors_; - neighbor_map trigger_cell_neighbors_sci_; - - // Disconnected modules and layers - std::unordered_set disconnected_modules_; - std::unordered_set disconnected_layers_; - std::vector trigger_layers_; - - // layer offsets - unsigned heOffset_; - unsigned totalLayers_; - - void fillMaps(); - void fillNeighborMap(const edm::FileInPath&, neighbor_map&, bool); - void fillInvalidTriggerCells(); - unsigned packTriggerCell(unsigned, unsigned) const; - unsigned packTriggerCellWithType(unsigned, unsigned, unsigned) const; - bool validCellId(unsigned det, unsigned cell_id) const; - bool validTriggerCellFromCells( const unsigned ) const; - - int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const; - unsigned packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const; - unsigned packWaferId(int waferU, int waferV) const; - unsigned packCellId(unsigned type, unsigned cellU, unsigned cellV) const; - unsigned packCellId(unsigned type, unsigned cell) const; - unsigned packIetaIphi(unsigned ieta, unsigned iphi) const; - void unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const; - void unpackWaferId(unsigned wafer, int& waferU, int& waferV) const; - void unpackCellId(unsigned cell, unsigned& cellU, unsigned& cellV) const; - void unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const; - - unsigned layerWithOffset(unsigned) const; +class HGCalTriggerGeometryV9Imp1 : public HGCalTriggerGeometryBase { +public: + HGCalTriggerGeometryV9Imp1(const edm::ParameterSet& conf); + + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; + void reset() final; + + unsigned getTriggerCellFromCell(const unsigned) const final; + unsigned getModuleFromCell(const unsigned) const final; + unsigned getModuleFromTriggerCell(const unsigned) const final; + + geom_set getCellsFromTriggerCell(const unsigned) const final; + geom_set getCellsFromModule(const unsigned) const final; + geom_set getTriggerCellsFromModule(const unsigned) const final; + + geom_ordered_set getOrderedCellsFromModule(const unsigned) const final; + geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final; + + geom_set getNeighborsFromTriggerCell(const unsigned) const final; + + GlobalPoint getTriggerCellPosition(const unsigned) const final; + GlobalPoint getModulePosition(const unsigned) const final; + + bool validTriggerCell(const unsigned) const final; + bool disconnectedModule(const unsigned) const final; + unsigned triggerLayer(const unsigned) const final; + +private: + edm::FileInPath l1tCellsMapping_; + edm::FileInPath l1tCellsSciMapping_; + edm::FileInPath l1tWafersMapping_; + edm::FileInPath l1tModulesMapping_; + edm::FileInPath l1tCellNeighborsMapping_; + edm::FileInPath l1tCellNeighborsSciMapping_; + + // module related maps + std::unordered_map wafer_to_module_; + std::unordered_multimap module_to_wafers_; + + // trigger cell related maps + std::unordered_map cells_to_trigger_cells_; + std::unordered_multimap trigger_cells_to_cells_; + std::unordered_map cells_to_trigger_cells_sci_; + std::unordered_multimap trigger_cells_to_cells_sci_; + std::unordered_map number_trigger_cells_in_wafers_; + std::unordered_map number_trigger_cells_in_wafers_sci_; + std::unordered_map wafers_to_wafers_old_; + std::unordered_map wafers_old_to_wafers_; + std::unordered_set invalid_triggercells_; + + // neighbor related maps + // trigger cell neighbors: + // - The key includes the module and trigger cell id + // - The value is a set of (module_id, trigger_cell_id) + typedef std::unordered_map>> neighbor_map; + neighbor_map trigger_cell_neighbors_; + neighbor_map trigger_cell_neighbors_sci_; + + // Disconnected modules and layers + std::unordered_set disconnected_modules_; + std::unordered_set disconnected_layers_; + std::vector trigger_layers_; + + // layer offsets + unsigned heOffset_; + unsigned totalLayers_; + + void fillMaps(); + void fillNeighborMap(const edm::FileInPath&, neighbor_map&, bool); + void fillInvalidTriggerCells(); + unsigned packTriggerCell(unsigned, unsigned) const; + unsigned packTriggerCellWithType(unsigned, unsigned, unsigned) const; + bool validCellId(unsigned det, unsigned cell_id) const; + bool validTriggerCellFromCells(const unsigned) const; + + int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const; + unsigned packWaferCellId(unsigned subdet, unsigned wafer, unsigned cell) const; + unsigned packWaferId(int waferU, int waferV) const; + unsigned packCellId(unsigned type, unsigned cellU, unsigned cellV) const; + unsigned packCellId(unsigned type, unsigned cell) const; + unsigned packIetaIphi(unsigned ieta, unsigned iphi) const; + void unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const; + void unpackWaferId(unsigned wafer, int& waferU, int& waferV) const; + void unpackCellId(unsigned cell, unsigned& cellU, unsigned& cellV) const; + void unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const; + + unsigned layerWithOffset(unsigned) const; }; - -HGCalTriggerGeometryV9Imp1:: -HGCalTriggerGeometryV9Imp1(const edm::ParameterSet& conf): - HGCalTriggerGeometryBase(conf), - l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), - l1tCellsSciMapping_(conf.getParameter("L1TCellsSciMapping")), - l1tWafersMapping_(conf.getParameter("L1TWafersMapping")), - l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), - l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), - l1tCellNeighborsSciMapping_(conf.getParameter("L1TCellNeighborsSciMapping")) -{ - std::vector tmp_vector = conf.getParameter>("DisconnectedModules"); - std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_modules_, disconnected_modules_.end())); - tmp_vector = conf.getParameter>("DisconnectedLayers"); - std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_layers_, disconnected_layers_.end())); -} - -void -HGCalTriggerGeometryV9Imp1:: -reset() -{ - cells_to_trigger_cells_.clear(); - trigger_cells_to_cells_.clear(); - cells_to_trigger_cells_sci_.clear(); - trigger_cells_to_cells_sci_.clear(); - wafers_to_wafers_old_.clear(); - wafers_old_to_wafers_.clear(); - wafer_to_module_.clear(); - module_to_wafers_.clear(); - number_trigger_cells_in_wafers_.clear(); - number_trigger_cells_in_wafers_sci_.clear(); - trigger_cell_neighbors_.clear(); - trigger_cell_neighbors_sci_.clear(); -} - -void -HGCalTriggerGeometryV9Imp1:: -initialize(const edm::ESHandle& calo_geometry) -{ - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryV9Imp1 geometry cannot be initialized with the V7/V8 HGCAL geometry"; -} - -void -HGCalTriggerGeometryV9Imp1:: -initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) -{ - setEEGeometry(hgc_ee_geometry); - setHSiGeometry(hgc_hsi_geometry); - setHScGeometry(hgc_hsc_geometry); - heOffset_ = eeTopology().dddConstants().layers(true); - totalLayers_ = heOffset_ + hsiTopology().dddConstants().layers(true); - trigger_layers_.resize(totalLayers_+1); - trigger_layers_[0] = 0; // layer number 0 doesn't exist - unsigned trigger_layer = 1; - for(unsigned layer=1; layersecond, wafer_trigger_cell, trigger_cell); - } - // Silicon - else if(det == DetId::HGCalEE || det == DetId::HGCalHSi) - { - HGCSiliconDetId cell_det_id(cell_id); - subdet = (det==DetId::HGCalEE ? ForwardSubdetector::HGCEE : ForwardSubdetector::HGCHEF); - layer = cell_det_id.layer(); - zside = cell_det_id.zside(); - int type = cell_det_id.type(); - int waferu = cell_det_id.waferU(); - int waferv = cell_det_id.waferV(); - unsigned cellu = cell_det_id.cellU(); - unsigned cellv = cell_det_id.cellV(); - auto trigger_cell_itr = cells_to_trigger_cells_.find(packCellId(type, cellu, cellv)); - if(trigger_cell_itr==cells_to_trigger_cells_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: HGCal cell " << cellu << "," << cellv << " in wafer type "<second; - wafer_trigger_cell = wafer_trigger_cell_itr->second; - } - // Using the old HGCalDetId for trigger cells is temporary - // For easy switch between V8 and V9 geometries - return HGCalDetId((ForwardSubdetector)subdet, zside, layer, tc_type, wafer_trigger_cell, trigger_cell).rawId(); - -} - -unsigned -HGCalTriggerGeometryV9Imp1:: -getModuleFromCell( const unsigned cell_id ) const -{ - return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); -} - -unsigned -HGCalTriggerGeometryV9Imp1:: -getModuleFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned module = 0; - // Scintillator - if(trigger_cell_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - // For scintillator, the module ID is currently encoded as the wafer in HGCalDetId - module = trigger_cell_det_id.wafer(); +HGCalTriggerGeometryV9Imp1::HGCalTriggerGeometryV9Imp1(const edm::ParameterSet& conf) + : HGCalTriggerGeometryBase(conf), + l1tCellsMapping_(conf.getParameter("L1TCellsMapping")), + l1tCellsSciMapping_(conf.getParameter("L1TCellsSciMapping")), + l1tWafersMapping_(conf.getParameter("L1TWafersMapping")), + l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), + l1tCellNeighborsMapping_(conf.getParameter("L1TCellNeighborsMapping")), + l1tCellNeighborsSciMapping_(conf.getParameter("L1TCellNeighborsSciMapping")) { + std::vector tmp_vector = conf.getParameter>("DisconnectedModules"); + std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_modules_, disconnected_modules_.end())); + tmp_vector = conf.getParameter>("DisconnectedLayers"); + std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_layers_, disconnected_layers_.end())); +} + +void HGCalTriggerGeometryV9Imp1::reset() { + cells_to_trigger_cells_.clear(); + trigger_cells_to_cells_.clear(); + cells_to_trigger_cells_sci_.clear(); + trigger_cells_to_cells_sci_.clear(); + wafers_to_wafers_old_.clear(); + wafers_old_to_wafers_.clear(); + wafer_to_module_.clear(); + module_to_wafers_.clear(); + number_trigger_cells_in_wafers_.clear(); + number_trigger_cells_in_wafers_sci_.clear(); + trigger_cell_neighbors_.clear(); + trigger_cell_neighbors_sci_.clear(); +} + +void HGCalTriggerGeometryV9Imp1::initialize(const edm::ESHandle& calo_geometry) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryV9Imp1 geometry cannot be initialized with the V7/V8 HGCAL geometry"; +} + +void HGCalTriggerGeometryV9Imp1::initialize(const edm::ESHandle& hgc_ee_geometry, + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) { + setEEGeometry(hgc_ee_geometry); + setHSiGeometry(hgc_hsi_geometry); + setHScGeometry(hgc_hsc_geometry); + heOffset_ = eeTopology().dddConstants().layers(true); + totalLayers_ = heOffset_ + hsiTopology().dddConstants().layers(true); + trigger_layers_.resize(totalLayers_ + 1); + trigger_layers_[0] = 0; // layer number 0 doesn't exist + unsigned trigger_layer = 1; + for (unsigned layer = 1; layer < trigger_layers_.size(); layer++) { + if (disconnected_layers_.find(layer) == disconnected_layers_.end()) { + // Increase trigger layer number if the layer is not disconnected + trigger_layers_[layer] = trigger_layer; + trigger_layer++; + } else { + trigger_layers_[layer] = 0; + } + } + fillMaps(); + fillNeighborMap(l1tCellNeighborsMapping_, trigger_cell_neighbors_, false); // silicon + fillNeighborMap(l1tCellNeighborsSciMapping_, trigger_cell_neighbors_sci_, true); // scintillator + fillInvalidTriggerCells(); +} + +unsigned HGCalTriggerGeometryV9Imp1::getTriggerCellFromCell(const unsigned cell_id) const { + unsigned det = DetId(cell_id).det(); + unsigned subdet = 0; + int zside = 0; + unsigned tc_type = 1; + unsigned layer = 0; + unsigned wafer_trigger_cell = 0; + unsigned trigger_cell = 0; + // Scintillator + if (det == DetId::HGCalHSc) { + HGCScintillatorDetId cell_det_id(cell_id); + unsigned ieta = cell_det_id.ietaAbs(); + unsigned iphi = cell_det_id.iphi(); + tc_type = cell_det_id.type(); + layer = cell_det_id.layer(); + subdet = ForwardSubdetector::HGCHEB; + zside = cell_det_id.zside(); + auto trigger_cell_itr = cells_to_trigger_cells_sci_.find(packIetaIphi(ieta, iphi)); + if (trigger_cell_itr == cells_to_trigger_cells_sci_.end()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: scintillator cell ieta=" << ieta << ", iphi=" << iphi + << " is not mapped to any trigger cell. The trigger cell mapping should be modified.\n"; } - // Silicon - else - { - auto module_itr = wafer_to_module_.find(trigger_cell_det_id.wafer()); - if(module_itr==wafer_to_module_.end()) - { - throw cms::Exception("BadGeometry") - <second; - } - return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), trigger_cell_det_id.layer(), trigger_cell_det_id.waferType(), module, HGCalDetId::kHGCalCellMask).rawId(); -} - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp1:: -getCellsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - geom_set cell_det_ids; - unsigned subdet = trigger_cell_det_id.subdetId(); - unsigned trigger_wafer = trigger_cell_det_id.wafer(); - unsigned trigger_cell = trigger_cell_det_id.cell(); - unsigned layer = trigger_cell_det_id.layer(); - // Scintillator - if(subdet==ForwardSubdetector::HGCHEB) - { - int type = hscTopology().dddConstants().getTypeTrap(layer); - const auto& cell_range = trigger_cells_to_cells_sci_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); - for(auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++) - { - unsigned ieta = 0; - unsigned iphi = 0; - unpackIetaIphi(tc_c_itr->second, ieta, iphi); - unsigned cell_det_id = HGCScintillatorDetId(type, layer, trigger_cell_det_id.zside()*ieta, iphi).rawId(); - if(validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id); - } - } - // Silicon - else - { - int waferu = 0; - int waferv = 0; - auto wafer_itr = wafers_old_to_wafers_.find(trigger_wafer); - if(wafer_itr==wafers_old_to_wafers_.end()) - { - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometry: Trigger wafer ID "<second, waferu, waferv); - DetId::Detector det = (trigger_cell_det_id.subdetId()==ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); - unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); - const auto& cell_range = trigger_cells_to_cells_.equal_range(packCellId(wafer_type, trigger_cell)); - for(auto tc_c_itr=cell_range.first; tc_c_itr!=cell_range.second; tc_c_itr++) - { - unsigned cellu = 0; - unsigned cellv = 0; - unpackCellId(tc_c_itr->second, cellu, cellv); - unsigned cell_det_id = HGCSiliconDetId(det, trigger_cell_det_id.zside(), wafer_type, layer, waferu, waferv, cellu, cellv).rawId(); - if(validCellId(subdet, cell_det_id)) cell_det_ids.emplace(cell_det_id); - } - } - return cell_det_ids; -} - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp1:: -getCellsFromModule( const unsigned module_id ) const -{ - geom_set cell_det_ids; - geom_set trigger_cells = getTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; -} - -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryV9Imp1:: -getOrderedCellsFromModule( const unsigned module_id ) const -{ - geom_ordered_set cell_det_ids; - geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; -} - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp1:: -getTriggerCellsFromModule( const unsigned module_id ) const -{ - HGCalDetId module_det_id(module_id); - geom_set trigger_cell_det_ids; - unsigned module = module_det_id.wafer(); - // Scintillator - if(module_det_id.subdetId()==ForwardSubdetector::HGCHEB) - { - // loop on the trigger cells in each module - for(int trigger_cell=0; trigger_cellsecond; - auto waferuv_itr = wafers_old_to_wafers_.find(wafer); - if(waferuv_itr==wafers_old_to_wafers_.end()) continue; - int waferu = 0; - int waferv = 0; - unpackWaferId(waferuv_itr->second, waferu, waferv); - DetId::Detector det = (module_det_id.subdetId()==ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); - unsigned layer = module_det_id.layer(); - unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond; - auto waferuv_itr = wafers_old_to_wafers_.find(wafer); - if(waferuv_itr==wafers_old_to_wafers_.end()) continue; - int waferu = 0; - int waferv = 0; - unpackWaferId(waferuv_itr->second, waferu, waferv); - DetId::Detector det = (module_det_id.subdetId()==ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); - unsigned layer = module_det_id.layer(); - unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cellsecond; - // create HGCalDetId of neighbors and check their validity - neighbor_detids.reserve(neighbors.size()); - for(const auto& module_tc : neighbors) - { - HGCalDetId neighbor_det_id((ForwardSubdetector)trigger_cell_det_id.subdetId(), trigger_cell_det_id.zside(), layer, type, module_tc.first, module_tc.second); - if(validTriggerCell(neighbor_det_id.rawId())) - { - neighbor_detids.emplace(neighbor_det_id.rawId()); - } - } - return neighbor_detids; -} - - -GlobalPoint -HGCalTriggerGeometryV9Imp1:: -getTriggerCellPosition(const unsigned trigger_cell_det_id) const -{ - unsigned subdet = HGCalDetId(trigger_cell_det_id).subdetId(); - // Position: barycenter of the trigger cell. - Basic3DVector triggerCellVector(0.,0.,0.); - const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); - // Scintillator - if(subdet==ForwardSubdetector::HGCHEB) - { - for(const auto& cell : cell_ids) - { - HcalDetId cellDetId(cell); - triggerCellVector += hscGeometry()->getPosition(cellDetId).basicVector(); - } - } - // Silicon - else - { - for(const auto& cell : cell_ids) - { - HGCSiliconDetId cellDetId(cell); - triggerCellVector += (cellDetId.det()==DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) : hsiGeometry()->getPosition(cellDetId)).basicVector(); - } - } - return GlobalPoint( triggerCellVector/cell_ids.size() ); - -} - -GlobalPoint -HGCalTriggerGeometryV9Imp1:: -getModulePosition(const unsigned module_det_id) const -{ - unsigned subdet = HGCalDetId(module_det_id).subdetId(); - // Position: barycenter of the module. - Basic3DVector moduleVector(0.,0.,0.); - const auto cell_ids = getCellsFromModule(module_det_id); - // Scintillator - if(subdet==ForwardSubdetector::HGCHEB) - { - for(const auto& cell : cell_ids) - { - HGCScintillatorDetId cellDetId(cell); - moduleVector += hscGeometry()->getPosition(cellDetId).basicVector(); - } - } - // Silicon - else - { - for(const auto& cell : cell_ids) - { - HGCSiliconDetId cellDetId(cell); - moduleVector += (cellDetId.det()==DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) : hsiGeometry()->getPosition(cellDetId)).basicVector(); - } - } - return GlobalPoint( moduleVector/cell_ids.size() ); -} - - -void -HGCalTriggerGeometryV9Imp1:: -fillMaps() -{ - // - // read module mapping file - std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); - if(!l1tModulesMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; - } - short trigger_wafer = 0; - short module = 0; - for(; l1tModulesMappingStream>>trigger_wafer>>module; ) - { - wafer_to_module_.emplace(trigger_wafer,module); - module_to_wafers_.emplace(module, trigger_wafer); - } - if(!l1tModulesMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TModulesMapping '"<>type>>cellu>>cellv>>trigger_cell; ) - { - unsigned cell_key = packCellId(type,cellu,cellv); - unsigned trigger_cell_key = packCellId(type,trigger_cell); - // fill cell <-> trigger cell mappings - cells_to_trigger_cells_.emplace(cell_key, trigger_cell); - trigger_cells_to_cells_.emplace(trigger_cell_key, cell_key); - // fill number of trigger cells in wafers - auto itr_insert = number_trigger_cells_in_wafers_.emplace(type, 0); - if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1; - } - if(!l1tCellsMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TCellsMapping '"<>ieta>>iphi>>trigger_wafer>>trigger_cell; ) - { - unsigned cell_key = packIetaIphi(ieta,iphi); - unsigned trigger_cell_key = packWaferCellId(ForwardSubdetector::HGCHEB,trigger_wafer,trigger_cell); - // fill cell <-> trigger cell mappings - cells_to_trigger_cells_sci_.emplace(cell_key, trigger_cell_key); - trigger_cells_to_cells_sci_.emplace(trigger_cell_key, cell_key); - // fill number of trigger cells in wafers - auto itr_insert = number_trigger_cells_in_wafers_sci_.emplace(trigger_wafer, 0); - if(trigger_cell+1 > itr_insert.first->second) itr_insert.first->second = trigger_cell+1; - } - if(!l1tCellsSciMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TCellsSciMapping '"<>waferu>>waferv>>trigger_wafer; ) - { - unsigned wafer_key = packWaferId(waferu,waferv); - // fill wafer u,v <-> old wafer ID mappings - wafers_to_wafers_old_.emplace(wafer_key, trigger_wafer); - wafers_old_to_wafers_.emplace(trigger_wafer, wafer_key); - } - if(!l1tWafersMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TWafersMapping '"< buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], line_size); ) - { - std::string line(&buffer[0]); - // Extract keys consisting of the module id - // and of the trigger cell id - // Match patterns (X,Y) - // where X is a number with less than 4 digis - // and Y is a number with less than 4 digits - // For the scintillator case, match instead (X,Y,Z) patterns - std::regex key_regex(scintillator ? "\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)" : "\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); - std::vector key_tokens { - std::sregex_token_iterator(line.begin(), line.end(), key_regex), {} - }; - if(key_tokens.empty()) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find the trigger cell key in line:\n" - << " '"<<&buffer[0]<<"'\n"; - } - std::regex digits_regex("\\d{1,3}"); - std::vector module_tc { - std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {} - }; - // get module and cell id - unsigned map_key = 0; - if(scintillator) - { - int type = std::stoi(module_tc[0]); - int module = std::stoi(module_tc[1]); - int trigger_cell = std::stoi(module_tc[2]); - map_key = packTriggerCellWithType(type, module, trigger_cell); - } - else - { - int module = std::stoi(module_tc[0]); - int trigger_cell = std::stoi(module_tc[1]); - map_key = packTriggerCell(module, trigger_cell); - } - // Extract neighbors - // Match patterns (X,Y) - // where X is a number with less than 4 digits - // and Y is a number with less than 4 digits - std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); - std::vector neighbors_tokens { - std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), {} - }; - if( (scintillator && neighbors_tokens.empty()) || - (!scintillator && neighbors_tokens.size()<2) - ) - { - throw cms::Exception("BadGeometry") - << "Syntax error in the L1TCellNeighborsMapping:\n" - << " Cannot find any neighbor in line:\n" - << " '"<<&buffer[0]<<"'\n"; + wafer_trigger_cell = 0; + unpackWaferCellId(trigger_cell_itr->second, wafer_trigger_cell, trigger_cell); + } + // Silicon + else if (det == DetId::HGCalEE || det == DetId::HGCalHSi) { + HGCSiliconDetId cell_det_id(cell_id); + subdet = (det == DetId::HGCalEE ? ForwardSubdetector::HGCEE : ForwardSubdetector::HGCHEF); + layer = cell_det_id.layer(); + zside = cell_det_id.zside(); + int type = cell_det_id.type(); + int waferu = cell_det_id.waferU(); + int waferv = cell_det_id.waferV(); + unsigned cellu = cell_det_id.cellU(); + unsigned cellv = cell_det_id.cellV(); + auto trigger_cell_itr = cells_to_trigger_cells_.find(packCellId(type, cellu, cellv)); + if (trigger_cell_itr == cells_to_trigger_cells_.end()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: HGCal cell " << cellu << "," << cellv << " in wafer type " << type + << " is not mapped to any trigger cell. The trigger cell mapping should be modified.\n"; + } + auto wafer_trigger_cell_itr = wafers_to_wafers_old_.find(packWaferId(waferu, waferv)); + if (wafer_trigger_cell_itr == wafers_to_wafers_old_.end()) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Wafer " << waferu << "," << waferv + << " is not mapped to any trigger wafer ID. The wafer mapping should be modified.\n"; + } + trigger_cell = trigger_cell_itr->second; + wafer_trigger_cell = wafer_trigger_cell_itr->second; + } + // Using the old HGCalDetId for trigger cells is temporary + // For easy switch between V8 and V9 geometries + return HGCalDetId((ForwardSubdetector)subdet, zside, layer, tc_type, wafer_trigger_cell, trigger_cell).rawId(); +} + +unsigned HGCalTriggerGeometryV9Imp1::getModuleFromCell(const unsigned cell_id) const { + return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); +} + +unsigned HGCalTriggerGeometryV9Imp1::getModuleFromTriggerCell(const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned module = 0; + // Scintillator + if (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB) { + // For scintillator, the module ID is currently encoded as the wafer in HGCalDetId + module = trigger_cell_det_id.wafer(); + } + // Silicon + else { + auto module_itr = wafer_to_module_.find(trigger_cell_det_id.wafer()); + if (module_itr == wafer_to_module_.end()) { + throw cms::Exception("BadGeometry") + << trigger_cell_det_id << "HGCalTriggerGeometry: Wafer " << trigger_cell_det_id.wafer() + << " is not mapped to any trigger module. The module mapping should be modified. See " + "https://twiki.cern.ch/twiki/bin/viewauth/CMS/HGCALTriggerPrimitivesSimulation#Trigger_geometry for " + "details.\n"; + } + module = module_itr->second; + } + return HGCalDetId((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + trigger_cell_det_id.layer(), + trigger_cell_det_id.waferType(), + module, + HGCalDetId::kHGCalCellMask) + .rawId(); +} + +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp1::getCellsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + geom_set cell_det_ids; + unsigned subdet = trigger_cell_det_id.subdetId(); + unsigned trigger_wafer = trigger_cell_det_id.wafer(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + unsigned layer = trigger_cell_det_id.layer(); + // Scintillator + if (subdet == ForwardSubdetector::HGCHEB) { + int type = hscTopology().dddConstants().getTypeTrap(layer); + const auto& cell_range = + trigger_cells_to_cells_sci_.equal_range(packWaferCellId(subdet, trigger_wafer, trigger_cell)); + for (auto tc_c_itr = cell_range.first; tc_c_itr != cell_range.second; tc_c_itr++) { + unsigned ieta = 0; + unsigned iphi = 0; + unpackIetaIphi(tc_c_itr->second, ieta, iphi); + unsigned cell_det_id = HGCScintillatorDetId(type, layer, trigger_cell_det_id.zside() * ieta, iphi).rawId(); + if (validCellId(subdet, cell_det_id)) + cell_det_ids.emplace(cell_det_id); + } + } + // Silicon + else { + int waferu = 0; + int waferv = 0; + auto wafer_itr = wafers_old_to_wafers_.find(trigger_wafer); + if (wafer_itr == wafers_old_to_wafers_.end()) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Trigger wafer ID " << trigger_wafer + << " is not mapped to any wafer. The wafer mapping should be modified.\n"; + } + unpackWaferId(wafer_itr->second, waferu, waferv); + DetId::Detector det = + (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); + unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); + const auto& cell_range = trigger_cells_to_cells_.equal_range(packCellId(wafer_type, trigger_cell)); + for (auto tc_c_itr = cell_range.first; tc_c_itr != cell_range.second; tc_c_itr++) { + unsigned cellu = 0; + unsigned cellv = 0; + unpackCellId(tc_c_itr->second, cellu, cellv); + unsigned cell_det_id = + HGCSiliconDetId(det, trigger_cell_det_id.zside(), wafer_type, layer, waferu, waferv, cellu, cellv).rawId(); + if (validCellId(subdet, cell_det_id)) + cell_det_ids.emplace(cell_det_id); + } + } + return cell_det_ids; +} + +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp1::getCellsFromModule(const unsigned module_id) const { + geom_set cell_det_ids; + geom_set trigger_cells = getTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; +} + +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryV9Imp1::getOrderedCellsFromModule( + const unsigned module_id) const { + geom_ordered_set cell_det_ids; + geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; +} + +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp1::getTriggerCellsFromModule( + const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + geom_set trigger_cell_det_ids; + unsigned module = module_det_id.wafer(); + // Scintillator + if (module_det_id.subdetId() == ForwardSubdetector::HGCHEB) { + // loop on the trigger cells in each module + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_sci_.at(module); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + module_det_id.waferType(), + module, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } + } + // Silicon + else { + auto wafer_itrs = module_to_wafers_.equal_range(module); + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + unsigned wafer = wafer_itr->second; + auto waferuv_itr = wafers_old_to_wafers_.find(wafer); + if (waferuv_itr == wafers_old_to_wafers_.end()) + continue; + int waferu = 0; + int waferv = 0; + unpackWaferId(waferuv_itr->second, waferu, waferv); + DetId::Detector det = (module_det_id.subdetId() == ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); + unsigned layer = module_det_id.layer(); + unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer_type); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + module_det_id.waferType(), + wafer, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } + } + } + return trigger_cell_det_ids; +} + +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryV9Imp1::getOrderedTriggerCellsFromModule( + const unsigned module_id) const { + HGCalDetId module_det_id(module_id); + geom_ordered_set trigger_cell_det_ids; + unsigned module = module_det_id.wafer(); + // Scintillator + if (module_det_id.subdetId() == ForwardSubdetector::HGCHEB) { + // loop on the trigger cells in each module + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_sci_.at(module); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + module_det_id.waferType(), + module, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } + } + // EE or FH + else { + auto wafer_itrs = module_to_wafers_.equal_range(module); + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + unsigned wafer = wafer_itr->second; + auto waferuv_itr = wafers_old_to_wafers_.find(wafer); + if (waferuv_itr == wafers_old_to_wafers_.end()) + continue; + int waferu = 0; + int waferv = 0; + unpackWaferId(waferuv_itr->second, waferu, waferv); + DetId::Detector det = (module_det_id.subdetId() == ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); + unsigned layer = module_det_id.layer(); + unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(wafer_type); trigger_cell++) { + HGCalDetId trigger_cell_id((ForwardSubdetector)module_det_id.subdetId(), + module_det_id.zside(), + module_det_id.layer(), + module_det_id.waferType(), + wafer, + trigger_cell); + if (validTriggerCell(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); + } + } + } + return trigger_cell_det_ids; +} + +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp1::getNeighborsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + // Choose scintillator or silicon map + const auto& neighbors_map = + (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB ? trigger_cell_neighbors_sci_ + : trigger_cell_neighbors_); + unsigned layer = trigger_cell_det_id.layer(); + unsigned type = + (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB ? hscTopology().dddConstants().getTypeTrap(layer) + : 1); + unsigned module = trigger_cell_det_id.wafer(); + unsigned trigger_cell = trigger_cell_det_id.cell(); + // retrieve neighbors + unsigned trigger_cell_key = (trigger_cell_det_id.subdetId() == ForwardSubdetector::HGCHEB + ? packTriggerCellWithType(type, module, trigger_cell) + : packTriggerCell(module, trigger_cell)); + geom_set neighbor_detids; + auto neighbors_itr = neighbors_map.find(trigger_cell_key); + if (neighbors_itr == neighbors_map.end()) { + throw cms::Exception("BadGeometry") << "HGCalTriggerGeometry: Neighbors are not defined for trigger cell " + << trigger_cell << " in module " << module + << ". The trigger cell neighbor mapping should be modified. \n"; + } + const auto& neighbors = neighbors_itr->second; + // create HGCalDetId of neighbors and check their validity + neighbor_detids.reserve(neighbors.size()); + for (const auto& module_tc : neighbors) { + HGCalDetId neighbor_det_id((ForwardSubdetector)trigger_cell_det_id.subdetId(), + trigger_cell_det_id.zside(), + layer, + type, + module_tc.first, + module_tc.second); + if (validTriggerCell(neighbor_det_id.rawId())) { + neighbor_detids.emplace(neighbor_det_id.rawId()); + } + } + return neighbor_detids; +} + +GlobalPoint HGCalTriggerGeometryV9Imp1::getTriggerCellPosition(const unsigned trigger_cell_det_id) const { + unsigned subdet = HGCalDetId(trigger_cell_det_id).subdetId(); + // Position: barycenter of the trigger cell. + Basic3DVector triggerCellVector(0., 0., 0.); + const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); + // Scintillator + if (subdet == ForwardSubdetector::HGCHEB) { + for (const auto& cell : cell_ids) { + HcalDetId cellDetId(cell); + triggerCellVector += hscGeometry()->getPosition(cellDetId).basicVector(); + } + } + // Silicon + else { + for (const auto& cell : cell_ids) { + HGCSiliconDetId cellDetId(cell); + triggerCellVector += (cellDetId.det() == DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) + : hsiGeometry()->getPosition(cellDetId)) + .basicVector(); + } + } + return GlobalPoint(triggerCellVector / cell_ids.size()); +} + +GlobalPoint HGCalTriggerGeometryV9Imp1::getModulePosition(const unsigned module_det_id) const { + unsigned subdet = HGCalDetId(module_det_id).subdetId(); + // Position: barycenter of the module. + Basic3DVector moduleVector(0., 0., 0.); + const auto cell_ids = getCellsFromModule(module_det_id); + // Scintillator + if (subdet == ForwardSubdetector::HGCHEB) { + for (const auto& cell : cell_ids) { + HGCScintillatorDetId cellDetId(cell); + moduleVector += hscGeometry()->getPosition(cellDetId).basicVector(); + } + } + // Silicon + else { + for (const auto& cell : cell_ids) { + HGCSiliconDetId cellDetId(cell); + moduleVector += (cellDetId.det() == DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) + : hsiGeometry()->getPosition(cellDetId)) + .basicVector(); + } + } + return GlobalPoint(moduleVector / cell_ids.size()); +} + +void HGCalTriggerGeometryV9Imp1::fillMaps() { + // + // read module mapping file + std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); + if (!l1tModulesMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; + } + short trigger_wafer = 0; + short module = 0; + for (; l1tModulesMappingStream >> trigger_wafer >> module;) { + wafer_to_module_.emplace(trigger_wafer, module); + module_to_wafers_.emplace(module, trigger_wafer); + } + if (!l1tModulesMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") + << "Error reading L1TModulesMapping '" << trigger_wafer << " " << module << "' \n"; + } + l1tModulesMappingStream.close(); + // read trigger cell mapping file + std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath()); + if (!l1tCellsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellsMapping file\n"; + } + short type = 0; + short cellu = 0; + short cellv = 0; + short trigger_cell = 0; + for (; l1tCellsMappingStream >> type >> cellu >> cellv >> trigger_cell;) { + unsigned cell_key = packCellId(type, cellu, cellv); + unsigned trigger_cell_key = packCellId(type, trigger_cell); + // fill cell <-> trigger cell mappings + cells_to_trigger_cells_.emplace(cell_key, trigger_cell); + trigger_cells_to_cells_.emplace(trigger_cell_key, cell_key); + // fill number of trigger cells in wafers + auto itr_insert = number_trigger_cells_in_wafers_.emplace(type, 0); + if (trigger_cell + 1 > itr_insert.first->second) + itr_insert.first->second = trigger_cell + 1; + } + if (!l1tCellsMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") + << "Error reading L1TCellsMapping '" << type << " " << cellu << " " << cellv << " " << trigger_cell << "' \n"; + } + l1tCellsMappingStream.close(); + // read scintillator trigger cell mapping file + std::ifstream l1tCellsSciMappingStream(l1tCellsSciMapping_.fullPath()); + if (!l1tCellsSciMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellsSciMapping file\n"; + } + short ieta = 0; + short iphi = 0; + trigger_wafer = 0; + trigger_cell = 0; + for (; l1tCellsSciMappingStream >> ieta >> iphi >> trigger_wafer >> trigger_cell;) { + unsigned cell_key = packIetaIphi(ieta, iphi); + unsigned trigger_cell_key = packWaferCellId(ForwardSubdetector::HGCHEB, trigger_wafer, trigger_cell); + // fill cell <-> trigger cell mappings + cells_to_trigger_cells_sci_.emplace(cell_key, trigger_cell_key); + trigger_cells_to_cells_sci_.emplace(trigger_cell_key, cell_key); + // fill number of trigger cells in wafers + auto itr_insert = number_trigger_cells_in_wafers_sci_.emplace(trigger_wafer, 0); + if (trigger_cell + 1 > itr_insert.first->second) + itr_insert.first->second = trigger_cell + 1; + } + if (!l1tCellsSciMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") << "Error reading L1TCellsSciMapping '" << ieta << " " << iphi << " " + << trigger_wafer << " " << trigger_cell << "' \n"; + } + l1tCellsSciMappingStream.close(); + // read wafer mapping file + std::ifstream l1tWafersMappingStream(l1tWafersMapping_.fullPath()); + if (!l1tWafersMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TWafersMapping file\n"; + } + short waferu = 0; + short waferv = 0; + trigger_wafer = 0; + for (; l1tWafersMappingStream >> waferu >> waferv >> trigger_wafer;) { + unsigned wafer_key = packWaferId(waferu, waferv); + // fill wafer u,v <-> old wafer ID mappings + wafers_to_wafers_old_.emplace(wafer_key, trigger_wafer); + wafers_old_to_wafers_.emplace(trigger_wafer, wafer_key); + } + if (!l1tWafersMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") + << "Error reading L1TWafersMapping '" << waferu << " " << waferv << " " << trigger_wafer << "' \n"; + } + l1tWafersMappingStream.close(); +} + +void HGCalTriggerGeometryV9Imp1::fillNeighborMap(const edm::FileInPath& file, + neighbor_map& neighbors_map, + bool scintillator) { + // Fill trigger neighbor map + std::ifstream l1tCellNeighborsMappingStream(file.fullPath()); + if (!l1tCellNeighborsMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TCellNeighborsMapping file\n"; + } + const unsigned line_size = 512; + for (std::array buffer; l1tCellNeighborsMappingStream.getline(&buffer[0], line_size);) { + std::string line(&buffer[0]); + // Extract keys consisting of the module id + // and of the trigger cell id + // Match patterns (X,Y) + // where X is a number with less than 4 digis + // and Y is a number with less than 4 digits + // For the scintillator case, match instead (X,Y,Z) patterns + std::regex key_regex(scintillator ? "\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)" + : "\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); + std::vector key_tokens{std::sregex_token_iterator(line.begin(), line.end(), key_regex), {}}; + if (key_tokens.empty()) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find the trigger cell key in line:\n" + << " '" << &buffer[0] << "'\n"; + } + std::regex digits_regex("\\d{1,3}"); + std::vector module_tc{ + std::sregex_token_iterator(key_tokens[0].begin(), key_tokens[0].end(), digits_regex), {}}; + // get module and cell id + unsigned map_key = 0; + if (scintillator) { + int type = std::stoi(module_tc[0]); + int module = std::stoi(module_tc[1]); + int trigger_cell = std::stoi(module_tc[2]); + map_key = packTriggerCellWithType(type, module, trigger_cell); + } else { + int module = std::stoi(module_tc[0]); + int trigger_cell = std::stoi(module_tc[1]); + map_key = packTriggerCell(module, trigger_cell); + } + // Extract neighbors + // Match patterns (X,Y) + // where X is a number with less than 4 digits + // and Y is a number with less than 4 digits + std::regex neighbors_regex("\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*\\)"); + std::vector neighbors_tokens{std::sregex_token_iterator(line.begin(), line.end(), neighbors_regex), + {}}; + if ((scintillator && neighbors_tokens.empty()) || (!scintillator && neighbors_tokens.size() < 2)) { + throw cms::Exception("BadGeometry") << "Syntax error in the L1TCellNeighborsMapping:\n" + << " Cannot find any neighbor in line:\n" + << " '" << &buffer[0] << "'\n"; + } + auto itr_insert = neighbors_map.emplace(map_key, std::set>()); + // The first element for silicon neighbors is the key, so start at index 1 + unsigned first_element = (scintillator ? 0 : 1); + for (unsigned i = first_element; i < neighbors_tokens.size(); i++) { + const auto& neighbor = neighbors_tokens[i]; + std::vector pair_neighbor{std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), + {}}; + short neighbor_module(std::stoi(pair_neighbor[0])); + short neighbor_cell(std::stoi(pair_neighbor[1])); + itr_insert.first->second.emplace(neighbor_module, neighbor_cell); + } + } + if (!l1tCellNeighborsMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") << "Error reading L1TCellNeighborsMapping'\n"; + } + l1tCellNeighborsMappingStream.close(); +} + +void HGCalTriggerGeometryV9Imp1::fillInvalidTriggerCells() { + unsigned n_layers_ee = eeTopology().dddConstants().layers(true); + for (unsigned layer = 1; layer <= n_layers_ee; layer++) { + for (const auto& waferuv_wafer : wafers_to_wafers_old_) { + int waferu = 0; + int waferv = 0; + unpackWaferId(waferuv_wafer.first, waferu, waferv); + unsigned waferee_type = detIdWaferType(DetId::HGCalEE, layer, waferu, waferv); + unsigned waferfh_type = detIdWaferType(DetId::HGCalHSi, layer, waferu, waferv); + unsigned trigger_wafer = waferuv_wafer.second; + // loop on the trigger cells in each wafer + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(waferee_type); trigger_cell++) { + for (int zside : {-1, 1}) { + HGCalDetId trigger_cell_id(ForwardSubdetector::HGCEE, zside, layer, 1, trigger_wafer, trigger_cell); + if (!validTriggerCellFromCells(trigger_cell_id)) + invalid_triggercells_.emplace(trigger_cell_id); + for (unsigned neighbor : getNeighborsFromTriggerCell(trigger_cell_id)) { + auto wafer_itr = wafers_old_to_wafers_.find(HGCalDetId(neighbor).wafer()); + if (wafer_itr == wafers_old_to_wafers_.end()) + invalid_triggercells_.emplace(neighbor); + else if (!validTriggerCellFromCells(neighbor)) + invalid_triggercells_.emplace(neighbor); + } } - auto itr_insert = neighbors_map.emplace(map_key, std::set>()); - // The first element for silicon neighbors is the key, so start at index 1 - unsigned first_element = (scintillator ? 0 : 1); - for(unsigned i=first_element; i pair_neighbor { - std::sregex_token_iterator(neighbor.begin(), neighbor.end(), digits_regex), {} - }; - short neighbor_module(std::stoi(pair_neighbor[0])); - short neighbor_cell(std::stoi(pair_neighbor[1])); - itr_insert.first->second.emplace(neighbor_module, neighbor_cell); + } + for (int trigger_cell = 0; trigger_cell < number_trigger_cells_in_wafers_.at(waferfh_type); trigger_cell++) { + for (int zside : {-1, 1}) { + HGCalDetId trigger_cell_id(ForwardSubdetector::HGCHEF, zside, layer, 1, trigger_wafer, trigger_cell); + if (!validTriggerCellFromCells(trigger_cell_id)) + invalid_triggercells_.emplace(trigger_cell_id); + for (unsigned neighbor : getNeighborsFromTriggerCell(trigger_cell_id)) { + auto wafer_itr = wafers_old_to_wafers_.find(HGCalDetId(neighbor).wafer()); + if (wafer_itr == wafers_old_to_wafers_.end()) + invalid_triggercells_.emplace(neighbor); + else if (!validTriggerCellFromCells(neighbor)) + invalid_triggercells_.emplace(neighbor); + } } - } - if(!l1tCellNeighborsMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TCellNeighborsMapping'\n"; - } - l1tCellNeighborsMappingStream.close(); - -} - - -void -HGCalTriggerGeometryV9Imp1:: -fillInvalidTriggerCells() -{ - unsigned n_layers_ee = eeTopology().dddConstants().layers(true); - for(unsigned layer=1; layer<=n_layers_ee; layer++) - { - for(const auto& waferuv_wafer : wafers_to_wafers_old_) - { - int waferu = 0; - int waferv = 0; - unpackWaferId(waferuv_wafer.first, waferu, waferv); - unsigned waferee_type = detIdWaferType(DetId::HGCalEE, layer, waferu, waferv); - unsigned waferfh_type = detIdWaferType(DetId::HGCalHSi, layer, waferu, waferv); - unsigned trigger_wafer = waferuv_wafer.second; - // loop on the trigger cells in each wafer - for(int trigger_cell=0; trigger_cell= 0) ? 0 : 1; - unsigned waferVsign = (waferV >= 0) ? 0 : 1; - packed_value |= ((waferUabs & HGCSiliconDetId::kHGCalWaferUMask) << HGCSiliconDetId::kHGCalWaferUOffset); - packed_value |= ((waferUsign & HGCSiliconDetId::kHGCalWaferUSignMask) << HGCSiliconDetId::kHGCalWaferUSignOffset); - packed_value |= ((waferVabs & HGCSiliconDetId::kHGCalWaferVMask) << HGCSiliconDetId::kHGCalWaferVOffset); - packed_value |= ((waferVsign & HGCSiliconDetId::kHGCalWaferVSignMask) << HGCSiliconDetId::kHGCalWaferVSignOffset); - return packed_value; -} - -unsigned -HGCalTriggerGeometryV9Imp1:: -packIetaIphi(unsigned ieta, unsigned iphi) const -{ - unsigned packed_value = 0; - packed_value |= ((iphi & HGCScintillatorDetId::kHGCalPhiMask) << HGCScintillatorDetId::kHGCalPhiOffset); - packed_value |= ((ieta & HGCScintillatorDetId::kHGCalRadiusMask) << HGCScintillatorDetId::kHGCalRadiusOffset); - return packed_value; -} - -void -HGCalTriggerGeometryV9Imp1:: -unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const -{ - cell = wafer_cell & HGCalDetId::kHGCalCellMask; - wafer = (wafer_cell>>HGCalDetId::kHGCalWaferOffset) & HGCalDetId::kHGCalWaferMask; -} - -void -HGCalTriggerGeometryV9Imp1:: -unpackCellId(unsigned cell, unsigned& cellU, unsigned& cellV) const -{ - cellU = (cell >> HGCSiliconDetId::kHGCalCellUOffset) & HGCSiliconDetId::kHGCalCellUMask; - cellV = (cell >> HGCSiliconDetId::kHGCalCellVOffset) & HGCSiliconDetId::kHGCalCellVMask; -} - - -void -HGCalTriggerGeometryV9Imp1:: -unpackWaferId(unsigned wafer, int& waferU, int& waferV) const -{ - unsigned waferUAbs = (wafer >> HGCSiliconDetId::kHGCalWaferUOffset) & HGCSiliconDetId::kHGCalWaferUMask; - unsigned waferVAbs = (wafer >> HGCSiliconDetId::kHGCalWaferVOffset) & HGCSiliconDetId::kHGCalWaferVMask; - waferU = ( ((wafer >> HGCSiliconDetId::kHGCalWaferUSignOffset) & HGCSiliconDetId::kHGCalWaferUSignMask) ? -waferUAbs : waferUAbs ); - waferV = ( ((wafer >> HGCSiliconDetId::kHGCalWaferVSignOffset) & HGCSiliconDetId::kHGCalWaferVSignMask) ? -waferVAbs : waferVAbs ); -} - - -void -HGCalTriggerGeometryV9Imp1:: -unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const -{ - iphi = (ieta_iphi>>HGCScintillatorDetId::kHGCalPhiOffset) & HGCScintillatorDetId::kHGCalPhiMask; - ieta = (ieta_iphi>>HGCScintillatorDetId::kHGCalRadiusOffset) & HGCScintillatorDetId::kHGCalRadiusMask; -} - -bool -HGCalTriggerGeometryV9Imp1:: -validTriggerCell(const unsigned trigger_cell_id) const -{ - return invalid_triggercells_.find(trigger_cell_id)==invalid_triggercells_.end(); -} - -bool -HGCalTriggerGeometryV9Imp1:: -disconnectedModule(const unsigned module_id) const -{ - bool disconnected = false; - if(disconnected_modules_.find(HGCalDetId(module_id).wafer())!=disconnected_modules_.end()) disconnected = true; - if(disconnected_layers_.find(layerWithOffset(module_id))!=disconnected_layers_.end()) disconnected = true; - return disconnected; -} - -unsigned -HGCalTriggerGeometryV9Imp1:: -triggerLayer(const unsigned id) const -{ - unsigned layer = layerWithOffset(id); - if(layer>=trigger_layers_.size()) return 0; - return trigger_layers_[layer]; -} - -bool -HGCalTriggerGeometryV9Imp1:: -validTriggerCellFromCells(const unsigned trigger_cell_id) const -{ - // Check the validity of a trigger cell with the - // validity of the cells. One valid cell in the - // trigger cell is enough to make the trigger cell - // valid. - HGCalDetId trigger_cell_det_id(trigger_cell_id); - unsigned subdet = trigger_cell_det_id.subdetId(); - const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - bool is_valid = false; - for(const auto cell_id : cells) - { - is_valid |= validCellId(subdet, cell_id); - if(is_valid) break; - } - return is_valid; -} - -bool -HGCalTriggerGeometryV9Imp1:: -validCellId(unsigned subdet, unsigned cell_id) const -{ - bool is_valid = false; - switch(subdet) - { - case ForwardSubdetector::HGCEE: - is_valid = eeTopology().valid(cell_id); - break; - case ForwardSubdetector::HGCHEF: - is_valid = hsiTopology().valid(cell_id); - break; - case ForwardSubdetector::HGCHEB: - is_valid = hscTopology().valid(cell_id); - break; - default: - is_valid = false; - break; - } - return is_valid; -} - - -unsigned -HGCalTriggerGeometryV9Imp1:: -packTriggerCell(unsigned module, unsigned trigger_cell) const -{ - unsigned packed_value = 0; - packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); - packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); - return packed_value; -} - -unsigned -HGCalTriggerGeometryV9Imp1:: -packTriggerCellWithType(unsigned type, unsigned module, unsigned trigger_cell) const -{ - unsigned packed_value = 0; - packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); - packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); - packed_value |= ((type & HGCalDetId::kHGCalWaferTypeMask) << HGCalDetId::kHGCalWaferTypeOffset); - return packed_value; -} - -int -HGCalTriggerGeometryV9Imp1:: -detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const -{ - int wafer_type = 0; - switch(det) - { - case DetId::HGCalEE: - wafer_type = eeTopology().dddConstants().getTypeHex(layer, waferU, waferV); - break; - case DetId::HGCalHSi: - wafer_type = hsiTopology().dddConstants().getTypeHex(layer, waferU, waferV); - break; - default: - break; - }; - return wafer_type; -} - - -unsigned -HGCalTriggerGeometryV9Imp1:: -layerWithOffset(unsigned id) const -{ - HGCalDetId detid(id); - unsigned layer = 0; - switch(detid.subdetId()) - { - case ForwardSubdetector::HGCEE: - layer = detid.layer(); - break; - case ForwardSubdetector::HGCHEF: - layer = heOffset_ + detid.layer(); - break; - case ForwardSubdetector::HGCHEB: - layer = heOffset_ + detid.layer(); - break; - }; - return layer; -} - - - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryV9Imp1, - "HGCalTriggerGeometryV9Imp1"); +unsigned HGCalTriggerGeometryV9Imp1::packCellId(unsigned type, unsigned cell) const { + unsigned packed_value = 0; + packed_value |= ((cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); + packed_value |= ((type & HGCSiliconDetId::kHGCalTypeMask) << HGCSiliconDetId::kHGCalTypeOffset); + return packed_value; +} + +unsigned HGCalTriggerGeometryV9Imp1::packCellId(unsigned type, unsigned cellU, unsigned cellV) const { + unsigned packed_value = 0; + packed_value |= ((cellU & HGCSiliconDetId::kHGCalCellUMask) << HGCSiliconDetId::kHGCalCellUOffset); + packed_value |= ((cellV & HGCSiliconDetId::kHGCalCellVMask) << HGCSiliconDetId::kHGCalCellVOffset); + packed_value |= ((type & HGCSiliconDetId::kHGCalTypeMask) << HGCSiliconDetId::kHGCalTypeOffset); + return packed_value; +} + +unsigned HGCalTriggerGeometryV9Imp1::packWaferId(int waferU, int waferV) const { + unsigned packed_value = 0; + unsigned waferUabs = std::abs(waferU); + unsigned waferVabs = std::abs(waferV); + unsigned waferUsign = (waferU >= 0) ? 0 : 1; + unsigned waferVsign = (waferV >= 0) ? 0 : 1; + packed_value |= ((waferUabs & HGCSiliconDetId::kHGCalWaferUMask) << HGCSiliconDetId::kHGCalWaferUOffset); + packed_value |= ((waferUsign & HGCSiliconDetId::kHGCalWaferUSignMask) << HGCSiliconDetId::kHGCalWaferUSignOffset); + packed_value |= ((waferVabs & HGCSiliconDetId::kHGCalWaferVMask) << HGCSiliconDetId::kHGCalWaferVOffset); + packed_value |= ((waferVsign & HGCSiliconDetId::kHGCalWaferVSignMask) << HGCSiliconDetId::kHGCalWaferVSignOffset); + return packed_value; +} + +unsigned HGCalTriggerGeometryV9Imp1::packIetaIphi(unsigned ieta, unsigned iphi) const { + unsigned packed_value = 0; + packed_value |= ((iphi & HGCScintillatorDetId::kHGCalPhiMask) << HGCScintillatorDetId::kHGCalPhiOffset); + packed_value |= ((ieta & HGCScintillatorDetId::kHGCalRadiusMask) << HGCScintillatorDetId::kHGCalRadiusOffset); + return packed_value; +} + +void HGCalTriggerGeometryV9Imp1::unpackWaferCellId(unsigned wafer_cell, unsigned& wafer, unsigned& cell) const { + cell = wafer_cell & HGCalDetId::kHGCalCellMask; + wafer = (wafer_cell >> HGCalDetId::kHGCalWaferOffset) & HGCalDetId::kHGCalWaferMask; +} + +void HGCalTriggerGeometryV9Imp1::unpackCellId(unsigned cell, unsigned& cellU, unsigned& cellV) const { + cellU = (cell >> HGCSiliconDetId::kHGCalCellUOffset) & HGCSiliconDetId::kHGCalCellUMask; + cellV = (cell >> HGCSiliconDetId::kHGCalCellVOffset) & HGCSiliconDetId::kHGCalCellVMask; +} + +void HGCalTriggerGeometryV9Imp1::unpackWaferId(unsigned wafer, int& waferU, int& waferV) const { + unsigned waferUAbs = (wafer >> HGCSiliconDetId::kHGCalWaferUOffset) & HGCSiliconDetId::kHGCalWaferUMask; + unsigned waferVAbs = (wafer >> HGCSiliconDetId::kHGCalWaferVOffset) & HGCSiliconDetId::kHGCalWaferVMask; + waferU = (((wafer >> HGCSiliconDetId::kHGCalWaferUSignOffset) & HGCSiliconDetId::kHGCalWaferUSignMask) ? -waferUAbs + : waferUAbs); + waferV = (((wafer >> HGCSiliconDetId::kHGCalWaferVSignOffset) & HGCSiliconDetId::kHGCalWaferVSignMask) ? -waferVAbs + : waferVAbs); +} + +void HGCalTriggerGeometryV9Imp1::unpackIetaIphi(unsigned ieta_iphi, unsigned& ieta, unsigned& iphi) const { + iphi = (ieta_iphi >> HGCScintillatorDetId::kHGCalPhiOffset) & HGCScintillatorDetId::kHGCalPhiMask; + ieta = (ieta_iphi >> HGCScintillatorDetId::kHGCalRadiusOffset) & HGCScintillatorDetId::kHGCalRadiusMask; +} + +bool HGCalTriggerGeometryV9Imp1::validTriggerCell(const unsigned trigger_cell_id) const { + return invalid_triggercells_.find(trigger_cell_id) == invalid_triggercells_.end(); +} + +bool HGCalTriggerGeometryV9Imp1::disconnectedModule(const unsigned module_id) const { + bool disconnected = false; + if (disconnected_modules_.find(HGCalDetId(module_id).wafer()) != disconnected_modules_.end()) + disconnected = true; + if (disconnected_layers_.find(layerWithOffset(module_id)) != disconnected_layers_.end()) + disconnected = true; + return disconnected; +} + +unsigned HGCalTriggerGeometryV9Imp1::triggerLayer(const unsigned id) const { + unsigned layer = layerWithOffset(id); + if (layer >= trigger_layers_.size()) + return 0; + return trigger_layers_[layer]; +} + +bool HGCalTriggerGeometryV9Imp1::validTriggerCellFromCells(const unsigned trigger_cell_id) const { + // Check the validity of a trigger cell with the + // validity of the cells. One valid cell in the + // trigger cell is enough to make the trigger cell + // valid. + HGCalDetId trigger_cell_det_id(trigger_cell_id); + unsigned subdet = trigger_cell_det_id.subdetId(); + const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + bool is_valid = false; + for (const auto cell_id : cells) { + is_valid |= validCellId(subdet, cell_id); + if (is_valid) + break; + } + return is_valid; +} + +bool HGCalTriggerGeometryV9Imp1::validCellId(unsigned subdet, unsigned cell_id) const { + bool is_valid = false; + switch (subdet) { + case ForwardSubdetector::HGCEE: + is_valid = eeTopology().valid(cell_id); + break; + case ForwardSubdetector::HGCHEF: + is_valid = hsiTopology().valid(cell_id); + break; + case ForwardSubdetector::HGCHEB: + is_valid = hscTopology().valid(cell_id); + break; + default: + is_valid = false; + break; + } + return is_valid; +} + +unsigned HGCalTriggerGeometryV9Imp1::packTriggerCell(unsigned module, unsigned trigger_cell) const { + unsigned packed_value = 0; + packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); + packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); + return packed_value; +} + +unsigned HGCalTriggerGeometryV9Imp1::packTriggerCellWithType(unsigned type, + unsigned module, + unsigned trigger_cell) const { + unsigned packed_value = 0; + packed_value |= ((trigger_cell & HGCalDetId::kHGCalCellMask) << HGCalDetId::kHGCalCellOffset); + packed_value |= ((module & HGCalDetId::kHGCalWaferMask) << HGCalDetId::kHGCalWaferOffset); + packed_value |= ((type & HGCalDetId::kHGCalWaferTypeMask) << HGCalDetId::kHGCalWaferTypeOffset); + return packed_value; +} + +int HGCalTriggerGeometryV9Imp1::detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const { + int wafer_type = 0; + switch (det) { + case DetId::HGCalEE: + wafer_type = eeTopology().dddConstants().getTypeHex(layer, waferU, waferV); + break; + case DetId::HGCalHSi: + wafer_type = hsiTopology().dddConstants().getTypeHex(layer, waferU, waferV); + break; + default: + break; + }; + return wafer_type; +} + +unsigned HGCalTriggerGeometryV9Imp1::layerWithOffset(unsigned id) const { + HGCalDetId detid(id); + unsigned layer = 0; + switch (detid.subdetId()) { + case ForwardSubdetector::HGCEE: + layer = detid.layer(); + break; + case ForwardSubdetector::HGCHEF: + layer = heOffset_ + detid.layer(); + break; + case ForwardSubdetector::HGCHEB: + layer = heOffset_ + detid.layer(); + break; + }; + return layer; +} + +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, HGCalTriggerGeometryV9Imp1, "HGCalTriggerGeometryV9Imp1"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp2.cc b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp2.cc index 18ea940c7881a..2709bc9469ab8 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp2.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/HGCalTriggerGeometryV9Imp2.cc @@ -13,659 +13,533 @@ #include #include +class HGCalTriggerGeometryV9Imp2 : public HGCalTriggerGeometryBase { +public: + HGCalTriggerGeometryV9Imp2(const edm::ParameterSet& conf); -class HGCalTriggerGeometryV9Imp2 : public HGCalTriggerGeometryBase -{ - public: - HGCalTriggerGeometryV9Imp2(const edm::ParameterSet& conf); + void initialize(const edm::ESHandle&) final; + void initialize(const edm::ESHandle&, + const edm::ESHandle&, + const edm::ESHandle&) final; + void reset() final; - void initialize(const edm::ESHandle& ) final; - void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final; - void reset() final; + unsigned getTriggerCellFromCell(const unsigned) const final; + unsigned getModuleFromCell(const unsigned) const final; + unsigned getModuleFromTriggerCell(const unsigned) const final; - unsigned getTriggerCellFromCell( const unsigned ) const final; - unsigned getModuleFromCell( const unsigned ) const final; - unsigned getModuleFromTriggerCell( const unsigned ) const final; + geom_set getCellsFromTriggerCell(const unsigned) const final; + geom_set getCellsFromModule(const unsigned) const final; + geom_set getTriggerCellsFromModule(const unsigned) const final; - geom_set getCellsFromTriggerCell( const unsigned ) const final; - geom_set getCellsFromModule( const unsigned ) const final; - geom_set getTriggerCellsFromModule( const unsigned ) const final; + geom_ordered_set getOrderedCellsFromModule(const unsigned) const final; + geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final; - geom_ordered_set getOrderedCellsFromModule( const unsigned ) const final; - geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned ) const final; + geom_set getNeighborsFromTriggerCell(const unsigned) const final; - geom_set getNeighborsFromTriggerCell( const unsigned ) const final; + GlobalPoint getTriggerCellPosition(const unsigned) const final; + GlobalPoint getModulePosition(const unsigned) const final; - GlobalPoint getTriggerCellPosition(const unsigned ) const final; - GlobalPoint getModulePosition(const unsigned ) const final; + bool validTriggerCell(const unsigned) const final; + bool disconnectedModule(const unsigned) const final; + unsigned triggerLayer(const unsigned) const final; - bool validTriggerCell( const unsigned ) const final; - bool disconnectedModule(const unsigned) const final; - unsigned triggerLayer(const unsigned) const final; +private: + // HSc trigger cell grouping + unsigned hSc_triggercell_size_ = 2; + unsigned hSc_module_size_ = 12; // in TC units (144 TC / panel = 36 e-links) - private: - // HSc trigger cell grouping - unsigned hSc_triggercell_size_ = 2; - unsigned hSc_module_size_ = 12; // in TC units (144 TC / panel = 36 e-links) + edm::FileInPath l1tModulesMapping_; - edm::FileInPath l1tModulesMapping_; + // module related maps + std::unordered_map wafer_to_module_; + std::unordered_multimap module_to_wafers_; - // module related maps - std::unordered_map wafer_to_module_; - std::unordered_multimap module_to_wafers_; + // Disconnected modules and layers + std::unordered_set disconnected_layers_; + std::vector trigger_layers_; - // Disconnected modules and layers - std::unordered_set disconnected_layers_; - std::vector trigger_layers_; + // layer offsets + unsigned heOffset_; + unsigned totalLayers_; - // layer offsets - unsigned heOffset_; - unsigned totalLayers_; + void fillMaps(); + bool validCellId(unsigned det, unsigned cell_id) const; + bool validTriggerCellFromCells(const unsigned) const; - void fillMaps(); - bool validCellId(unsigned det, unsigned cell_id) const; - bool validTriggerCellFromCells( const unsigned ) const; + int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const; + unsigned packWaferId(int waferU, int waferV) const; + void unpackWaferId(unsigned wafer, int& waferU, int& waferV) const; - int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const; - unsigned packWaferId(int waferU, int waferV) const; - void unpackWaferId(unsigned wafer, int& waferU, int& waferV) const; - - unsigned layerWithOffset(unsigned) const; + unsigned layerWithOffset(unsigned) const; }; - -HGCalTriggerGeometryV9Imp2:: -HGCalTriggerGeometryV9Imp2(const edm::ParameterSet& conf): - HGCalTriggerGeometryBase(conf), - hSc_triggercell_size_(conf.getParameter("ScintillatorTriggerCellSize")), - hSc_module_size_(conf.getParameter("ScintillatorModuleSize")), - l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), - disconnected_layers_(conf.getParameter>("DisconnectedLayers").begin(),conf.getParameter>("DisconnectedLayers").end()) -{ -} - -void -HGCalTriggerGeometryV9Imp2:: -reset() -{ - wafer_to_module_.clear(); - module_to_wafers_.clear(); +HGCalTriggerGeometryV9Imp2::HGCalTriggerGeometryV9Imp2(const edm::ParameterSet& conf) + : HGCalTriggerGeometryBase(conf), + hSc_triggercell_size_(conf.getParameter("ScintillatorTriggerCellSize")), + hSc_module_size_(conf.getParameter("ScintillatorModuleSize")), + l1tModulesMapping_(conf.getParameter("L1TModulesMapping")), + disconnected_layers_(conf.getParameter>("DisconnectedLayers").begin(), + conf.getParameter>("DisconnectedLayers").end()) {} + +void HGCalTriggerGeometryV9Imp2::reset() { + wafer_to_module_.clear(); + module_to_wafers_.clear(); } -void -HGCalTriggerGeometryV9Imp2:: -initialize(const edm::ESHandle& calo_geometry) -{ - throw cms::Exception("BadGeometry") - << "HGCalTriggerGeometryV9Imp2 geometry cannot be initialized with the V7/V8 HGCAL geometry"; +void HGCalTriggerGeometryV9Imp2::initialize(const edm::ESHandle& calo_geometry) { + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometryV9Imp2 geometry cannot be initialized with the V7/V8 HGCAL geometry"; } -void -HGCalTriggerGeometryV9Imp2:: -initialize(const edm::ESHandle& hgc_ee_geometry, - const edm::ESHandle& hgc_hsi_geometry, - const edm::ESHandle& hgc_hsc_geometry - ) -{ - setEEGeometry(hgc_ee_geometry); - setHSiGeometry(hgc_hsi_geometry); - setHScGeometry(hgc_hsc_geometry); - heOffset_ = eeTopology().dddConstants().layers(true); - totalLayers_ = heOffset_ + hsiTopology().dddConstants().layers(true); - trigger_layers_.resize(totalLayers_+1); - trigger_layers_[0] = 0; // layer number 0 doesn't exist - unsigned trigger_layer = 1; - for(unsigned layer=1; layer& hgc_ee_geometry, + const edm::ESHandle& hgc_hsi_geometry, + const edm::ESHandle& hgc_hsc_geometry) { + setEEGeometry(hgc_ee_geometry); + setHSiGeometry(hgc_hsi_geometry); + setHScGeometry(hgc_hsc_geometry); + heOffset_ = eeTopology().dddConstants().layers(true); + totalLayers_ = heOffset_ + hsiTopology().dddConstants().layers(true); + trigger_layers_.resize(totalLayers_ + 1); + trigger_layers_[0] = 0; // layer number 0 doesn't exist + unsigned trigger_layer = 1; + for (unsigned layer = 1; layer < trigger_layers_.size(); layer++) { + if (disconnected_layers_.find(layer) == disconnected_layers_.end()) { + // Increase trigger layer number if the layer is not disconnected + trigger_layers_[layer] = trigger_layer; + trigger_layer++; + } else { + trigger_layers_[layer] = 0; } - fillMaps(); - + } + fillMaps(); } -unsigned -HGCalTriggerGeometryV9Imp2:: -getTriggerCellFromCell( const unsigned cell_id ) const -{ - unsigned det = DetId(cell_id).det(); - unsigned trigger_cell_id = 0; - // Scintillator - if(det == DetId::HGCalHSc) - { - // Very rough mapping from cells to TC - HGCScintillatorDetId cell_sc_id(cell_id); - int ieta = ( (cell_sc_id.ietaAbs()-1)/hSc_triggercell_size_+1 )*cell_sc_id.zside(); - int iphi = (cell_sc_id.iphi()-1)/hSc_triggercell_size_+1; - trigger_cell_id = HGCScintillatorDetId(cell_sc_id.type(), cell_sc_id.layer(), ieta, iphi); - } - // Silicon - else if(det == DetId::HGCalEE || det == DetId::HGCalHSi) - { - HGCSiliconDetId cell_si_id(cell_id); - trigger_cell_id = HGCalTriggerDetId( - det==DetId::HGCalEE ? HGCalTriggerSubdetector::HGCalEETrigger : HGCalTriggerSubdetector::HGCalHSiTrigger, - cell_si_id.zside(), - cell_si_id.type(), - cell_si_id.layer(), - cell_si_id.waferU(), cell_si_id.waferV(), - cell_si_id.triggerCellU(), cell_si_id.triggerCellV() - ); - } - return trigger_cell_id; - +unsigned HGCalTriggerGeometryV9Imp2::getTriggerCellFromCell(const unsigned cell_id) const { + unsigned det = DetId(cell_id).det(); + unsigned trigger_cell_id = 0; + // Scintillator + if (det == DetId::HGCalHSc) { + // Very rough mapping from cells to TC + HGCScintillatorDetId cell_sc_id(cell_id); + int ieta = ((cell_sc_id.ietaAbs() - 1) / hSc_triggercell_size_ + 1) * cell_sc_id.zside(); + int iphi = (cell_sc_id.iphi() - 1) / hSc_triggercell_size_ + 1; + trigger_cell_id = HGCScintillatorDetId(cell_sc_id.type(), cell_sc_id.layer(), ieta, iphi); + } + // Silicon + else if (det == DetId::HGCalEE || det == DetId::HGCalHSi) { + HGCSiliconDetId cell_si_id(cell_id); + trigger_cell_id = HGCalTriggerDetId( + det == DetId::HGCalEE ? HGCalTriggerSubdetector::HGCalEETrigger : HGCalTriggerSubdetector::HGCalHSiTrigger, + cell_si_id.zside(), + cell_si_id.type(), + cell_si_id.layer(), + cell_si_id.waferU(), + cell_si_id.waferV(), + cell_si_id.triggerCellU(), + cell_si_id.triggerCellV()); + } + return trigger_cell_id; } -unsigned -HGCalTriggerGeometryV9Imp2:: -getModuleFromCell( const unsigned cell_id ) const -{ - return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); +unsigned HGCalTriggerGeometryV9Imp2::getModuleFromCell(const unsigned cell_id) const { + return getModuleFromTriggerCell(getTriggerCellFromCell(cell_id)); } -unsigned -HGCalTriggerGeometryV9Imp2:: -getModuleFromTriggerCell( const unsigned trigger_cell_id ) const -{ - unsigned det = DetId(trigger_cell_id).det(); - unsigned module = 0; - unsigned subdet_old = 0; - int zside = 0; - unsigned tc_type = 1; - unsigned layer = 0; - unsigned module_id = 0; - // Scintillator - if(det == DetId::HGCalHSc) - { - HGCScintillatorDetId trigger_cell_sc_id(trigger_cell_id); - tc_type = trigger_cell_sc_id.type(); - layer = trigger_cell_sc_id.layer(); - zside = trigger_cell_sc_id.zside(); - int ieta = ( (trigger_cell_sc_id.ietaAbs()-1)/hSc_module_size_+1 )*zside; - int iphi = (trigger_cell_sc_id.iphi()-1)/hSc_module_size_+1; - module_id = HGCScintillatorDetId(tc_type, layer, ieta, iphi); +unsigned HGCalTriggerGeometryV9Imp2::getModuleFromTriggerCell(const unsigned trigger_cell_id) const { + unsigned det = DetId(trigger_cell_id).det(); + unsigned module = 0; + unsigned subdet_old = 0; + int zside = 0; + unsigned tc_type = 1; + unsigned layer = 0; + unsigned module_id = 0; + // Scintillator + if (det == DetId::HGCalHSc) { + HGCScintillatorDetId trigger_cell_sc_id(trigger_cell_id); + tc_type = trigger_cell_sc_id.type(); + layer = trigger_cell_sc_id.layer(); + zside = trigger_cell_sc_id.zside(); + int ieta = ((trigger_cell_sc_id.ietaAbs() - 1) / hSc_module_size_ + 1) * zside; + int iphi = (trigger_cell_sc_id.iphi() - 1) / hSc_module_size_ + 1; + module_id = HGCScintillatorDetId(tc_type, layer, ieta, iphi); + } + // Silicon + else { + HGCalTriggerDetId trigger_cell_trig_id(trigger_cell_id); + unsigned subdet = trigger_cell_trig_id.subdet(); + subdet_old = + (subdet == HGCalTriggerSubdetector::HGCalEETrigger ? ForwardSubdetector::HGCEE : ForwardSubdetector::HGCHEF); + layer = trigger_cell_trig_id.layer(); + zside = trigger_cell_trig_id.zside(); + if (subdet == HGCalTriggerSubdetector::HGCalEETrigger || subdet == HGCalTriggerSubdetector::HGCalHSiTrigger) { + int waferu = trigger_cell_trig_id.waferU(); + int waferv = trigger_cell_trig_id.waferV(); + auto module_itr = wafer_to_module_.find(packWaferId(waferu, waferv)); + if (module_itr == wafer_to_module_.end()) { + throw cms::Exception("BadGeometry") + << trigger_cell_trig_id << "HGCalTriggerGeometry: Wafer (" << waferu << "," << waferv + << ") is not mapped to any trigger module. The module mapping should be modified. \n"; + } + module = module_itr->second; } - // Silicon - else - { - HGCalTriggerDetId trigger_cell_trig_id(trigger_cell_id); - unsigned subdet = trigger_cell_trig_id.subdet(); - subdet_old = (subdet==HGCalTriggerSubdetector::HGCalEETrigger ? ForwardSubdetector::HGCEE : ForwardSubdetector::HGCHEF); - layer = trigger_cell_trig_id.layer(); - zside = trigger_cell_trig_id.zside(); - if(subdet == HGCalTriggerSubdetector::HGCalEETrigger || subdet == HGCalTriggerSubdetector::HGCalHSiTrigger) - { - int waferu = trigger_cell_trig_id.waferU(); - int waferv = trigger_cell_trig_id.waferV(); - auto module_itr = wafer_to_module_.find(packWaferId(waferu,waferv)); - if(module_itr==wafer_to_module_.end()) - { - throw cms::Exception("BadGeometry") - <second; - } - module_id = HGCalDetId((ForwardSubdetector)subdet_old, zside, layer, tc_type, module, HGCalDetId::kHGCalCellMask).rawId(); - } - return module_id; + module_id = + HGCalDetId((ForwardSubdetector)subdet_old, zside, layer, tc_type, module, HGCalDetId::kHGCalCellMask).rawId(); + } + return module_id; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp2:: -getCellsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - DetId trigger_cell_det_id(trigger_cell_id); - unsigned det = trigger_cell_det_id.det(); - geom_set cell_det_ids; - // Scintillator - if(det==DetId::HGCalHSc) - { - HGCScintillatorDetId trigger_cell_sc_id(trigger_cell_id); - int ieta0 = (trigger_cell_sc_id.ietaAbs()-1)*hSc_triggercell_size_+1; - int iphi0 = (trigger_cell_sc_id.iphi()-1)*hSc_triggercell_size_+1; - for(int ietaAbs=ieta0; ietaAbs cellus = trigger_cell_trig_id.cellU(); - std::vector cellvs = trigger_cell_trig_id.cellV(); - for(unsigned ic=0; ic cellus = trigger_cell_trig_id.cellU(); + std::vector cellvs = trigger_cell_trig_id.cellV(); + for (unsigned ic = 0; ic < cellus.size(); ic++) { + HGCSiliconDetId cell_det_id(cell_det, zside, type, layer, waferu, waferv, cellus[ic], cellvs[ic]); + cell_det_ids.emplace(cell_det_id.rawId()); + } } - return cell_det_ids; + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp2:: -getCellsFromModule( const unsigned module_id ) const -{ - geom_set cell_det_ids; - geom_set trigger_cells = getTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp2::getCellsFromModule(const unsigned module_id) const { + geom_set cell_det_ids; + geom_set trigger_cells = getTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryV9Imp2:: -getOrderedCellsFromModule( const unsigned module_id ) const -{ - geom_ordered_set cell_det_ids; - geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); - for(auto trigger_cell_id : trigger_cells) - { - geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - cell_det_ids.insert(cells.begin(), cells.end()); - } - return cell_det_ids; +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryV9Imp2::getOrderedCellsFromModule( + const unsigned module_id) const { + geom_ordered_set cell_det_ids; + geom_ordered_set trigger_cells = getOrderedTriggerCellsFromModule(module_id); + for (auto trigger_cell_id : trigger_cells) { + geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + cell_det_ids.insert(cells.begin(), cells.end()); + } + return cell_det_ids; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp2:: -getTriggerCellsFromModule( const unsigned module_id ) const -{ - DetId module_det_id(module_id); - unsigned det = module_det_id.det(); - geom_set trigger_cell_det_ids; - // Scintillator - if(det==DetId::HGCalHSc) - { - HGCScintillatorDetId module_sc_id(module_id); - int ieta0 = (module_sc_id.ietaAbs()-1)*hSc_module_size_+1; - int iphi0 = (module_sc_id.iphi()-1)*hSc_module_size_+1; - for(int ietaAbs=ieta0; ietaAbssecond, waferu, waferv); - DetId::Detector det = (module_si_id.subdetId()==ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); - HGCalTriggerSubdetector subdet = (module_si_id.subdetId()==ForwardSubdetector::HGCEE ? HGCalTriggerSubdetector::HGCalEETrigger : HGCalTriggerSubdetector::HGCalHSiTrigger); - unsigned layer = module_si_id.layer(); - unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); - int nroc = (wafer_type==HGCSiliconDetId::HGCalFine ? 6 : 3); - // Loop on ROCs in wafer - for(int roc=1; roc<=nroc; roc++) - { - // loop on TCs in ROC - auto tc_uvs = tc2roc.getTriggerId(roc, wafer_type); - for(const auto& tc_uv : tc_uvs) - { - HGCalTriggerDetId trigger_cell_id(subdet, module_si_id.zside(), wafer_type, layer, waferu, waferv, tc_uv.first, tc_uv.second); - if(validTriggerCellFromCells(trigger_cell_id)) trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); - } - } + } + // Silicon + else { + HGCalDetId module_si_id(module_id); + unsigned module = module_si_id.wafer(); + HGCSiliconDetIdToROC tc2roc; + auto wafer_itrs = module_to_wafers_.equal_range(module); + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int waferu = 0; + int waferv = 0; + unpackWaferId(wafer_itr->second, waferu, waferv); + DetId::Detector det = (module_si_id.subdetId() == ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); + HGCalTriggerSubdetector subdet = + (module_si_id.subdetId() == ForwardSubdetector::HGCEE ? HGCalTriggerSubdetector::HGCalEETrigger + : HGCalTriggerSubdetector::HGCalHSiTrigger); + unsigned layer = module_si_id.layer(); + unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); + int nroc = (wafer_type == HGCSiliconDetId::HGCalFine ? 6 : 3); + // Loop on ROCs in wafer + for (int roc = 1; roc <= nroc; roc++) { + // loop on TCs in ROC + auto tc_uvs = tc2roc.getTriggerId(roc, wafer_type); + for (const auto& tc_uv : tc_uvs) { + HGCalTriggerDetId trigger_cell_id( + subdet, module_si_id.zside(), wafer_type, layer, waferu, waferv, tc_uv.first, tc_uv.second); + if (validTriggerCellFromCells(trigger_cell_id)) + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); } + } } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryV9Imp2:: -getOrderedTriggerCellsFromModule( const unsigned module_id ) const -{ - DetId module_det_id(module_id); - unsigned det = module_det_id.det(); - geom_ordered_set trigger_cell_det_ids; - // Scintillator - if(det==DetId::HGCalHSc) - { - HGCScintillatorDetId module_sc_id(module_id); - int ieta0 = (module_sc_id.ietaAbs()-1)*hSc_module_size_+1; - int iphi0 = (module_sc_id.iphi()-1)*hSc_module_size_+1; - for(int ietaAbs=ieta0; ietaAbssecond, waferu, waferv); - DetId::Detector det = (module_si_id.subdetId()==ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); - HGCalTriggerSubdetector subdet = (module_si_id.subdetId()==ForwardSubdetector::HGCEE ? HGCalTriggerSubdetector::HGCalEETrigger : HGCalTriggerSubdetector::HGCalHSiTrigger); - unsigned layer = module_si_id.layer(); - unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); - int nroc = (wafer_type==HGCSiliconDetId::HGCalFine ? 6 : 3); - // Loop on ROCs in wafer - for(int roc=1; roc<=nroc; roc++) - { - // loop on TCs in ROC - auto tc_uvs = tc2roc.getTriggerId(roc, wafer_type); - for(const auto& tc_uv : tc_uvs) - { - HGCalTriggerDetId trigger_cell_id(subdet, module_si_id.zside(), wafer_type, layer, waferu, waferv, tc_uv.first, tc_uv.second); - trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); - } - } + } + // EE or FH + else { + HGCalDetId module_si_id(module_id); + unsigned module = module_si_id.wafer(); + HGCSiliconDetIdToROC tc2roc; + auto wafer_itrs = module_to_wafers_.equal_range(module); + // loop on the wafers included in the module + for (auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) { + int waferu = 0; + int waferv = 0; + unpackWaferId(wafer_itr->second, waferu, waferv); + DetId::Detector det = (module_si_id.subdetId() == ForwardSubdetector::HGCEE ? DetId::HGCalEE : DetId::HGCalHSi); + HGCalTriggerSubdetector subdet = + (module_si_id.subdetId() == ForwardSubdetector::HGCEE ? HGCalTriggerSubdetector::HGCalEETrigger + : HGCalTriggerSubdetector::HGCalHSiTrigger); + unsigned layer = module_si_id.layer(); + unsigned wafer_type = detIdWaferType(det, layer, waferu, waferv); + int nroc = (wafer_type == HGCSiliconDetId::HGCalFine ? 6 : 3); + // Loop on ROCs in wafer + for (int roc = 1; roc <= nroc; roc++) { + // loop on TCs in ROC + auto tc_uvs = tc2roc.getTriggerId(roc, wafer_type); + for (const auto& tc_uv : tc_uvs) { + HGCalTriggerDetId trigger_cell_id( + subdet, module_si_id.zside(), wafer_type, layer, waferu, waferv, tc_uv.first, tc_uv.second); + trigger_cell_det_ids.emplace(trigger_cell_id.rawId()); } + } } - return trigger_cell_det_ids; + } + return trigger_cell_det_ids; } - - -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryV9Imp2:: -getNeighborsFromTriggerCell( const unsigned trigger_cell_id ) const -{ - HGCalDetId trigger_cell_det_id(trigger_cell_id); - geom_set neighbor_detids; - return neighbor_detids; +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryV9Imp2::getNeighborsFromTriggerCell( + const unsigned trigger_cell_id) const { + HGCalDetId trigger_cell_det_id(trigger_cell_id); + geom_set neighbor_detids; + return neighbor_detids; } - -GlobalPoint -HGCalTriggerGeometryV9Imp2:: -getTriggerCellPosition(const unsigned trigger_cell_det_id) const -{ - unsigned det = DetId(trigger_cell_det_id).det(); - // Position: barycenter of the trigger cell. - Basic3DVector triggerCellVector(0.,0.,0.); - const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); - // Scintillator - if(det==DetId::HGCalHSc) - { - for(const auto& cell : cell_ids) - { - HGCScintillatorDetId cellDetId(cell); - triggerCellVector += hscGeometry()->getPosition(cellDetId).basicVector(); - } +GlobalPoint HGCalTriggerGeometryV9Imp2::getTriggerCellPosition(const unsigned trigger_cell_det_id) const { + unsigned det = DetId(trigger_cell_det_id).det(); + // Position: barycenter of the trigger cell. + Basic3DVector triggerCellVector(0., 0., 0.); + const auto cell_ids = getCellsFromTriggerCell(trigger_cell_det_id); + // Scintillator + if (det == DetId::HGCalHSc) { + for (const auto& cell : cell_ids) { + HGCScintillatorDetId cellDetId(cell); + triggerCellVector += hscGeometry()->getPosition(cellDetId).basicVector(); } - // Silicon - else - { - for(const auto& cell : cell_ids) - { - HGCSiliconDetId cellDetId(cell); - triggerCellVector += (cellDetId.det()==DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) : hsiGeometry()->getPosition(cellDetId)).basicVector(); - } + } + // Silicon + else { + for (const auto& cell : cell_ids) { + HGCSiliconDetId cellDetId(cell); + triggerCellVector += (cellDetId.det() == DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) + : hsiGeometry()->getPosition(cellDetId)) + .basicVector(); } - return GlobalPoint( triggerCellVector/cell_ids.size() ); - + } + return GlobalPoint(triggerCellVector / cell_ids.size()); } -GlobalPoint -HGCalTriggerGeometryV9Imp2:: -getModulePosition(const unsigned module_det_id) const -{ - unsigned det = DetId(module_det_id).det(); - // Position: barycenter of the module. - Basic3DVector moduleVector(0.,0.,0.); - const auto cell_ids = getCellsFromModule(module_det_id); - // Scintillator - if(det==DetId::HGCalHSc) - { - for(const auto& cell : cell_ids) - { - HGCScintillatorDetId cellDetId(cell); - moduleVector += hscGeometry()->getPosition(cellDetId).basicVector(); - } +GlobalPoint HGCalTriggerGeometryV9Imp2::getModulePosition(const unsigned module_det_id) const { + unsigned det = DetId(module_det_id).det(); + // Position: barycenter of the module. + Basic3DVector moduleVector(0., 0., 0.); + const auto cell_ids = getCellsFromModule(module_det_id); + // Scintillator + if (det == DetId::HGCalHSc) { + for (const auto& cell : cell_ids) { + HGCScintillatorDetId cellDetId(cell); + moduleVector += hscGeometry()->getPosition(cellDetId).basicVector(); } - // Silicon - else - { - for(const auto& cell : cell_ids) - { - HGCSiliconDetId cellDetId(cell); - moduleVector += (cellDetId.det()==DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) : hsiGeometry()->getPosition(cellDetId)).basicVector(); - } + } + // Silicon + else { + for (const auto& cell : cell_ids) { + HGCSiliconDetId cellDetId(cell); + moduleVector += (cellDetId.det() == DetId::HGCalEE ? eeGeometry()->getPosition(cellDetId) + : hsiGeometry()->getPosition(cellDetId)) + .basicVector(); } - return GlobalPoint( moduleVector/cell_ids.size() ); + } + return GlobalPoint(moduleVector / cell_ids.size()); } - -void -HGCalTriggerGeometryV9Imp2:: -fillMaps() -{ - // read module mapping file - std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath()); - if(!l1tModulesMappingStream.is_open()) - { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TModulesMapping file\n"; - } - short waferu = 0; - short waferv = 0; - short module = 0; - for(; l1tModulesMappingStream>>waferu>>waferv>>module; ) - { - unsigned wafer_key = packWaferId(waferu,waferv); - wafer_to_module_.emplace(wafer_key,module); - module_to_wafers_.emplace(module, wafer_key); - } - if(!l1tModulesMappingStream.eof()) - { - throw cms::Exception("BadGeometryFile") - << "Error reading L1TModulesMapping '"<> waferu >> waferv >> module;) { + unsigned wafer_key = packWaferId(waferu, waferv); + wafer_to_module_.emplace(wafer_key, module); + module_to_wafers_.emplace(module, wafer_key); + } + if (!l1tModulesMappingStream.eof()) { + throw cms::Exception("BadGeometryFile") + << "Error reading L1TModulesMapping '" << waferu << " " << waferv << " " << module << "' \n"; + } + l1tModulesMappingStream.close(); } - -unsigned -HGCalTriggerGeometryV9Imp2:: -packWaferId(int waferU, int waferV) const -{ - unsigned packed_value = 0; - unsigned waferUsign = (waferU >= 0) ? 0 : 1; - unsigned waferVsign = (waferV >= 0) ? 0 : 1; - packed_value |= ((std::abs(waferU) & HGCSiliconDetId::kHGCalWaferUMask) << HGCSiliconDetId::kHGCalWaferUOffset); - packed_value |= ((waferUsign & HGCSiliconDetId::kHGCalWaferUSignMask) << HGCSiliconDetId::kHGCalWaferUSignOffset); - packed_value |= ((std::abs(waferV) & HGCSiliconDetId::kHGCalWaferVMask) << HGCSiliconDetId::kHGCalWaferVOffset); - packed_value |= ((waferVsign & HGCSiliconDetId::kHGCalWaferVSignMask) << HGCSiliconDetId::kHGCalWaferVSignOffset); - return packed_value; +unsigned HGCalTriggerGeometryV9Imp2::packWaferId(int waferU, int waferV) const { + unsigned packed_value = 0; + unsigned waferUsign = (waferU >= 0) ? 0 : 1; + unsigned waferVsign = (waferV >= 0) ? 0 : 1; + packed_value |= ((std::abs(waferU) & HGCSiliconDetId::kHGCalWaferUMask) << HGCSiliconDetId::kHGCalWaferUOffset); + packed_value |= ((waferUsign & HGCSiliconDetId::kHGCalWaferUSignMask) << HGCSiliconDetId::kHGCalWaferUSignOffset); + packed_value |= ((std::abs(waferV) & HGCSiliconDetId::kHGCalWaferVMask) << HGCSiliconDetId::kHGCalWaferVOffset); + packed_value |= ((waferVsign & HGCSiliconDetId::kHGCalWaferVSignMask) << HGCSiliconDetId::kHGCalWaferVSignOffset); + return packed_value; } - -void -HGCalTriggerGeometryV9Imp2:: -unpackWaferId(unsigned wafer, int& waferU, int& waferV) const -{ - unsigned waferUAbs = (wafer >> HGCSiliconDetId::kHGCalWaferUOffset) & HGCSiliconDetId::kHGCalWaferUMask; - unsigned waferVAbs = (wafer >> HGCSiliconDetId::kHGCalWaferVOffset) & HGCSiliconDetId::kHGCalWaferVMask; - waferU = ( ((wafer >> HGCSiliconDetId::kHGCalWaferUSignOffset) & HGCSiliconDetId::kHGCalWaferUSignMask) ? -waferUAbs : waferUAbs ); - waferV = ( ((wafer >> HGCSiliconDetId::kHGCalWaferVSignOffset) & HGCSiliconDetId::kHGCalWaferVSignMask) ? -waferVAbs : waferVAbs ); +void HGCalTriggerGeometryV9Imp2::unpackWaferId(unsigned wafer, int& waferU, int& waferV) const { + unsigned waferUAbs = (wafer >> HGCSiliconDetId::kHGCalWaferUOffset) & HGCSiliconDetId::kHGCalWaferUMask; + unsigned waferVAbs = (wafer >> HGCSiliconDetId::kHGCalWaferVOffset) & HGCSiliconDetId::kHGCalWaferVMask; + waferU = (((wafer >> HGCSiliconDetId::kHGCalWaferUSignOffset) & HGCSiliconDetId::kHGCalWaferUSignMask) ? -waferUAbs + : waferUAbs); + waferV = (((wafer >> HGCSiliconDetId::kHGCalWaferVSignOffset) & HGCSiliconDetId::kHGCalWaferVSignMask) ? -waferVAbs + : waferVAbs); } - -bool -HGCalTriggerGeometryV9Imp2:: -validTriggerCell(const unsigned trigger_cell_id) const -{ - return validTriggerCellFromCells(trigger_cell_id); +bool HGCalTriggerGeometryV9Imp2::validTriggerCell(const unsigned trigger_cell_id) const { + return validTriggerCellFromCells(trigger_cell_id); } -bool -HGCalTriggerGeometryV9Imp2:: -disconnectedModule(const unsigned module_id) const -{ - bool disconnected = false; - if(disconnected_layers_.find(layerWithOffset(module_id))!=disconnected_layers_.end()) disconnected = true; - return disconnected; +bool HGCalTriggerGeometryV9Imp2::disconnectedModule(const unsigned module_id) const { + bool disconnected = false; + if (disconnected_layers_.find(layerWithOffset(module_id)) != disconnected_layers_.end()) + disconnected = true; + return disconnected; } -unsigned -HGCalTriggerGeometryV9Imp2:: -triggerLayer(const unsigned id) const -{ - unsigned layer = layerWithOffset(id); - if(layer>=trigger_layers_.size()) return 0; - return trigger_layers_[layer]; +unsigned HGCalTriggerGeometryV9Imp2::triggerLayer(const unsigned id) const { + unsigned layer = layerWithOffset(id); + if (layer >= trigger_layers_.size()) + return 0; + return trigger_layers_[layer]; } -bool -HGCalTriggerGeometryV9Imp2:: -validTriggerCellFromCells(const unsigned trigger_cell_id) const -{ - // Check the validity of a trigger cell with the - // validity of the cells. One valid cell in the - // trigger cell is enough to make the trigger cell - // valid. - const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); - bool is_valid = false; - for(const auto cell_id : cells) - { - unsigned det = DetId(cell_id).det(); - is_valid |= validCellId(det, cell_id); - if(is_valid) break; - } - return is_valid; +bool HGCalTriggerGeometryV9Imp2::validTriggerCellFromCells(const unsigned trigger_cell_id) const { + // Check the validity of a trigger cell with the + // validity of the cells. One valid cell in the + // trigger cell is enough to make the trigger cell + // valid. + const geom_set cells = getCellsFromTriggerCell(trigger_cell_id); + bool is_valid = false; + for (const auto cell_id : cells) { + unsigned det = DetId(cell_id).det(); + is_valid |= validCellId(det, cell_id); + if (is_valid) + break; + } + return is_valid; } -bool -HGCalTriggerGeometryV9Imp2:: -validCellId(unsigned subdet, unsigned cell_id) const -{ - bool is_valid = false; - switch(subdet) - { - case DetId::HGCalEE: - is_valid = eeTopology().valid(cell_id); - break; - case DetId::HGCalHSi: - is_valid = hsiTopology().valid(cell_id); - break; - case DetId::HGCalHSc: - is_valid = hscTopology().valid(cell_id); - break; - default: - is_valid = false; - break; - } - return is_valid; +bool HGCalTriggerGeometryV9Imp2::validCellId(unsigned subdet, unsigned cell_id) const { + bool is_valid = false; + switch (subdet) { + case DetId::HGCalEE: + is_valid = eeTopology().valid(cell_id); + break; + case DetId::HGCalHSi: + is_valid = hsiTopology().valid(cell_id); + break; + case DetId::HGCalHSc: + is_valid = hscTopology().valid(cell_id); + break; + default: + is_valid = false; + break; + } + return is_valid; } - - -int -HGCalTriggerGeometryV9Imp2:: -detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const -{ - int wafer_type = 0; - switch(det) - { - case DetId::HGCalEE: - wafer_type = eeTopology().dddConstants().getTypeHex(layer, waferU, waferV); - break; - case DetId::HGCalHSi: - wafer_type = hsiTopology().dddConstants().getTypeHex(layer, waferU, waferV); - break; - default: - break; - }; - return wafer_type; +int HGCalTriggerGeometryV9Imp2::detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const { + int wafer_type = 0; + switch (det) { + case DetId::HGCalEE: + wafer_type = eeTopology().dddConstants().getTypeHex(layer, waferU, waferV); + break; + case DetId::HGCalHSi: + wafer_type = hsiTopology().dddConstants().getTypeHex(layer, waferU, waferV); + break; + default: + break; + }; + return wafer_type; } - -unsigned -HGCalTriggerGeometryV9Imp2:: -layerWithOffset(unsigned id) const -{ - unsigned det = DetId(id).det(); - unsigned layer = 0; - if(det==DetId::HGCalTrigger) - { - unsigned subdet = HGCalTriggerDetId(id).subdet(); - if(subdet==HGCalTriggerSubdetector::HGCalEETrigger) - { - layer = HGCalTriggerDetId(id).layer(); - } - else if(subdet==HGCalTriggerSubdetector::HGCalHSiTrigger) - { - layer = heOffset_ + HGCalTriggerDetId(id).layer(); - } +unsigned HGCalTriggerGeometryV9Imp2::layerWithOffset(unsigned id) const { + unsigned det = DetId(id).det(); + unsigned layer = 0; + if (det == DetId::HGCalTrigger) { + unsigned subdet = HGCalTriggerDetId(id).subdet(); + if (subdet == HGCalTriggerSubdetector::HGCalEETrigger) { + layer = HGCalTriggerDetId(id).layer(); + } else if (subdet == HGCalTriggerSubdetector::HGCalHSiTrigger) { + layer = heOffset_ + HGCalTriggerDetId(id).layer(); } - else if(det==DetId::HGCalHSc) - { - layer = heOffset_ + HGCScintillatorDetId(id).layer(); + } else if (det == DetId::HGCalHSc) { + layer = heOffset_ + HGCScintillatorDetId(id).layer(); + } else if (det == DetId::Forward) { + unsigned subdet = HGCalDetId(id).subdetId(); + if (subdet == ForwardSubdetector::HGCEE) { + layer = HGCalDetId(id).layer(); + } else if (subdet == ForwardSubdetector::HGCHEF || subdet == ForwardSubdetector::HGCHEB) { + layer = heOffset_ + HGCalTriggerDetId(id).layer(); } - else if(det==DetId::Forward) - { - unsigned subdet = HGCalDetId(id).subdetId(); - if(subdet==ForwardSubdetector::HGCEE) - { - layer = HGCalDetId(id).layer(); - } - else if(subdet==ForwardSubdetector::HGCHEF || subdet==ForwardSubdetector::HGCHEB) - { - layer = heOffset_ + HGCalTriggerDetId(id).layer(); - } - } - return layer; + } + return layer; } - - -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - HGCalTriggerGeometryV9Imp2, - "HGCalTriggerGeometryV9Imp2"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, HGCalTriggerGeometryV9Imp2, "HGCalTriggerGeometryV9Imp2"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/NullGeometry.cc b/L1Trigger/L1THGCal/plugins/geometries/NullGeometry.cc index 026c92cadbf92..b33cfe870fcf4 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/NullGeometry.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/NullGeometry.cc @@ -2,16 +2,12 @@ class NullGeometry : public HGCalTriggerGeometryGenericMapping { public: - NullGeometry(const edm::ParameterSet& conf) : - HGCalTriggerGeometryGenericMapping(conf) { - } + NullGeometry(const edm::ParameterSet& conf) : HGCalTriggerGeometryGenericMapping(conf) {} - void initialize(const edm::ESHandle& ) final {} + void initialize(const edm::ESHandle&) final {} void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final {} + const edm::ESHandle&, + const edm::ESHandle&) final {} }; -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - NullGeometry, - "NullGeometry"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, NullGeometry, "NullGeometry"); diff --git a/L1Trigger/L1THGCal/plugins/geometries/TrivialGeometry.cc b/L1Trigger/L1THGCal/plugins/geometries/TrivialGeometry.cc index 8cfa71f8acb38..5a3c04eb0309e 100644 --- a/L1Trigger/L1THGCal/plugins/geometries/TrivialGeometry.cc +++ b/L1Trigger/L1THGCal/plugins/geometries/TrivialGeometry.cc @@ -2,35 +2,25 @@ class TrivialGeometry : public HGCalTriggerGeometryGenericMapping { public: - TrivialGeometry(const edm::ParameterSet& conf) : - HGCalTriggerGeometryGenericMapping(conf) { - } + TrivialGeometry(const edm::ParameterSet& conf) : HGCalTriggerGeometryGenericMapping(conf) {} - void initialize(const edm::ESHandle& ) final { + void initialize(const edm::ESHandle&) final { constexpr unsigned nmodules = 6; - for( unsigned i = 0; i < nmodules; ++i ) { + for (unsigned i = 0; i < nmodules; ++i) { trigger_cells_to_modules_[i] = i; HGCalTriggerGeometry::TriggerCell::list_type tc_empty; - trigger_cells_[i].reset( new HGCalTriggerGeometry::TriggerCell(i,i, - GlobalPoint(), - tc_empty, - tc_empty) ); - + trigger_cells_[i].reset(new HGCalTriggerGeometry::TriggerCell(i, i, GlobalPoint(), tc_empty, tc_empty)); + HGCalTriggerGeometry::Module::list_type mod_empty; - HGCalTriggerGeometry::Module::list_type mod_comps = { i }; + HGCalTriggerGeometry::Module::list_type mod_comps = {i}; HGCalTriggerGeometry::Module::tc_map_type map_empty; - modules_[i].reset( new HGCalTriggerGeometry::Module(i,GlobalPoint(), - mod_empty, - mod_comps, - map_empty) ); + modules_[i].reset(new HGCalTriggerGeometry::Module(i, GlobalPoint(), mod_empty, mod_comps, map_empty)); } } void initialize(const edm::ESHandle&, - const edm::ESHandle&, - const edm::ESHandle&) final {} + const edm::ESHandle&, + const edm::ESHandle&) final {} }; -DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, - TrivialGeometry, - "TrivialGeometry"); +DEFINE_EDM_PLUGIN(HGCalTriggerGeometryFactory, TrivialGeometry, "TrivialGeometry"); diff --git a/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc b/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc index 7daa84d2c1e5b..d547c7612c649 100644 --- a/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc +++ b/L1Trigger/L1THGCal/plugins/veryfrontend/HGCalVFEProcessorSums.cc @@ -4,70 +4,61 @@ #include "DataFormats/Candidate/interface/LeafCandidate.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" +DEFINE_EDM_PLUGIN(HGCalVFEProcessorBaseFactory, HGCalVFEProcessorSums, "HGCalVFEProcessorSums"); -DEFINE_EDM_PLUGIN(HGCalVFEProcessorBaseFactory, - HGCalVFEProcessorSums, - "HGCalVFEProcessorSums"); - - -HGCalVFEProcessorSums:: -HGCalVFEProcessorSums(const edm::ParameterSet& conf) : HGCalVFEProcessorBase(conf) -{ +HGCalVFEProcessorSums::HGCalVFEProcessorSums(const edm::ParameterSet& conf) : HGCalVFEProcessorBase(conf) { vfeLinearizationImpl_ = std::make_unique(conf); vfeSummationImpl_ = std::make_unique(conf); vfeCompressionImpl_ = std::make_unique(conf); - calibration_ = std::make_unique( conf.getParameterSet("calib_parameters") ); + calibration_ = std::make_unique(conf.getParameterSet("calib_parameters")); } -void -HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl, - l1t::HGCalTriggerCellBxCollection& triggerCellColl, - const edm::EventSetup& es) -{ +void HGCalVFEProcessorSums::run(const HGCalDigiCollection& digiColl, + l1t::HGCalTriggerCellBxCollection& triggerCellColl, + const edm::EventSetup& es) { vfeSummationImpl_->eventSetup(es); calibration_->eventSetup(es); std::vector dataframes; - std::vector> linearized_dataframes; + std::vector> linearized_dataframes; std::unordered_map payload; - std::unordered_map > compressed_payload; + std::unordered_map> compressed_payload; - // convert ee and fh hit collections into the same object - for(const auto& digiData : digiColl) - { - if(DetId(digiData.id()).det()==DetId::Hcal && HcalDetId(digiData.id()).subdetId()!=HcalEndcap) continue; + // convert ee and fh hit collections into the same object + for (const auto& digiData : digiColl) { + if (DetId(digiData.id()).det() == DetId::Hcal && HcalDetId(digiData.id()).subdetId() != HcalEndcap) + continue; uint32_t module = geometry_->getModuleFromCell(digiData.id()); - if(geometry_->disconnectedModule(module)) continue; + if (geometry_->disconnectedModule(module)) + continue; dataframes.emplace_back(digiData.id()); - for(int i=0; ilinearize(dataframes, linearized_dataframes); - vfeSummationImpl_->triggerCellSums(*geometry_, linearized_dataframes, payload); + vfeSummationImpl_->triggerCellSums(*geometry_, linearized_dataframes, payload); vfeCompressionImpl_->compress(payload, compressed_payload); - + // Transform map to trigger cell vector vector - for(const auto& id_value : payload) - { - if (id_value.second>0){ - l1t::HGCalTriggerCell triggerCell(reco::LeafCandidate::LorentzVector(), compressed_payload[id_value.first][1], 0, 0, 0, id_value.first); + for (const auto& id_value : payload) { + if (id_value.second > 0) { + l1t::HGCalTriggerCell triggerCell( + reco::LeafCandidate::LorentzVector(), compressed_payload[id_value.first][1], 0, 0, 0, id_value.first); triggerCell.setCompressedCharge(compressed_payload[id_value.first][0]); triggerCell.setUncompressedCharge(id_value.second); GlobalPoint point = geometry_->getTriggerCellPosition(id_value.first); - + // 'value' is hardware, so p4 is meaningless, except for eta and phi - math::PtEtaPhiMLorentzVector p4((double)id_value.second/cosh(point.eta()), point.eta(), point.phi(), 0.); + math::PtEtaPhiMLorentzVector p4((double)id_value.second / cosh(point.eta()), point.eta(), point.phi(), 0.); triggerCell.setP4(p4); - triggerCell.setPosition(point); - + triggerCell.setPosition(point); + // calibration part --------------------------- - if( triggerCell.hwPt() > 0 ) - { - l1t::HGCalTriggerCell calibratedtriggercell( triggerCell ); - calibration_->calibrateInGeV( calibratedtriggercell); + if (triggerCell.hwPt() > 0) { + l1t::HGCalTriggerCell calibratedtriggercell(triggerCell); + calibration_->calibrateInGeV(calibratedtriggercell); triggerCellColl.push_back(0, calibratedtriggercell); } } diff --git a/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc b/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc index 34b5825f3f1d4..c5ca76a2e0525 100644 --- a/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc @@ -1,19 +1,13 @@ #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" -EDM_REGISTER_PLUGINFACTORY(HGCalVFEProcessorBaseFactory, - "HGCalVFEProcessorBaseFactory"); - -EDM_REGISTER_PLUGINFACTORY(HGCalConcentratorFactory, - "HGCalConcentratorFactory"); - -EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer1Factory, - "HGCalBackendLayer1Factory"); - -EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer2Factory, - "HGCalBackendLayer2Factory"); +EDM_REGISTER_PLUGINFACTORY(HGCalVFEProcessorBaseFactory, "HGCalVFEProcessorBaseFactory"); -EDM_REGISTER_PLUGINFACTORY(HGCalTowerMapFactory, - "HGCalTowerMapFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalConcentratorFactory, "HGCalConcentratorFactory"); -EDM_REGISTER_PLUGINFACTORY(HGCalTowerFactory, - "HGCalTowerFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer1Factory, "HGCalBackendLayer1Factory"); + +EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer2Factory, "HGCalBackendLayer2Factory"); + +EDM_REGISTER_PLUGINFACTORY(HGCalTowerMapFactory, "HGCalTowerMapFactory"); + +EDM_REGISTER_PLUGINFACTORY(HGCalTowerFactory, "HGCalTowerFactory"); diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerBackendAlgorithmBase.cc b/L1Trigger/L1THGCal/src/HGCalTriggerBackendAlgorithmBase.cc index 6cc893b6966de..94b29cfa6dfcd 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerBackendAlgorithmBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerBackendAlgorithmBase.cc @@ -1,4 +1,3 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h" -EDM_REGISTER_PLUGINFACTORY(HGCalTriggerBackendAlgorithmFactory, - "HGCalTriggerBackendAlgorithmFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalTriggerBackendAlgorithmFactory, "HGCalTriggerBackendAlgorithmFactory"); diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerBackendProcessor.cc b/L1Trigger/L1THGCal/src/HGCalTriggerBackendProcessor.cc index aa50a192d0d6e..e22be1ad4fb82 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerBackendProcessor.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerBackendProcessor.cc @@ -1,47 +1,41 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendProcessor.h" -HGCalTriggerBackendProcessor:: -HGCalTriggerBackendProcessor(const edm::ParameterSet& conf, edm::ConsumesCollector&& cc) { - const std::vector& be_confs = - conf.getParameterSetVector("algorithms"); - for( const auto& algo_cfg : be_confs ) { - const std::string& algo_name = - algo_cfg.getParameter("AlgorithmName"); - algorithms_.emplace_back(HGCalTriggerBackendAlgorithmFactory::get()->create(algo_name,algo_cfg,cc)); +HGCalTriggerBackendProcessor::HGCalTriggerBackendProcessor(const edm::ParameterSet& conf, edm::ConsumesCollector&& cc) { + const std::vector& be_confs = conf.getParameterSetVector("algorithms"); + for (const auto& algo_cfg : be_confs) { + const std::string& algo_name = algo_cfg.getParameter("AlgorithmName"); + algorithms_.emplace_back(HGCalTriggerBackendAlgorithmFactory::get()->create(algo_name, algo_cfg, cc)); } } void HGCalTriggerBackendProcessor::setGeometry(const HGCalTriggerGeometryBase* const geom) { - for( const auto& algo : algorithms_ ) { + for (const auto& algo : algorithms_) { algo->setGeometry(geom); } } - void HGCalTriggerBackendProcessor::setProduces(edm::stream::EDProducer<>& prod) const { - for( const auto& algo : algorithms_ ) { + for (const auto& algo : algorithms_) { algo->setProduces(prod); } } -void HGCalTriggerBackendProcessor::run(const l1t::HGCFETriggerDigiCollection& coll, - const edm::EventSetup& es, - edm::Event &e - ) { - for( auto& algo : algorithms_ ) { - algo->run(coll, es,e); +void HGCalTriggerBackendProcessor::run(const l1t::HGCFETriggerDigiCollection& coll, + const edm::EventSetup& es, + edm::Event& e) { + for (auto& algo : algorithms_) { + algo->run(coll, es, e); } } void HGCalTriggerBackendProcessor::putInEvent(edm::Event& evt) { - for( auto& algo : algorithms_ ) { + for (auto& algo : algorithms_) { algo->putInEvent(evt); } } void HGCalTriggerBackendProcessor::reset() { - for( auto& algo : algorithms_ ) { + for (auto& algo : algorithms_) { algo->reset(); } } - diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerFECodecBase.cc b/L1Trigger/L1THGCal/src/HGCalTriggerFECodecBase.cc index 1b510536cacb5..4697e82264bb5 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerFECodecBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerFECodecBase.cc @@ -1,4 +1,3 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h" -EDM_REGISTER_PLUGINFACTORY(HGCalTriggerFECodecFactory, - "HGCalTriggerFECodecFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalTriggerFECodecFactory, "HGCalTriggerFECodecFactory"); diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerGeometryBase.cc b/L1Trigger/L1THGCal/src/HGCalTriggerGeometryBase.cc index 88e397c06d230..7d0689923ed45 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerGeometryBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerGeometryBase.cc @@ -1,19 +1,11 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" +HGCalTriggerGeometryBase::HGCalTriggerGeometryBase(const edm::ParameterSet& conf) + : name_(conf.getParameter("TriggerGeometryName")) {} - -HGCalTriggerGeometryBase:: -HGCalTriggerGeometryBase(const edm::ParameterSet& conf) : - name_(conf.getParameter("TriggerGeometryName")) -{ -} - -void HGCalTriggerGeometryBase::reset() -{ -} +void HGCalTriggerGeometryBase::reset() {} #include "FWCore/Utilities/interface/typelookup.h" TYPELOOKUP_DATA_REG(HGCalTriggerGeometryBase); -EDM_REGISTER_PLUGINFACTORY(HGCalTriggerGeometryFactory, - "HGCalTriggerGeometryFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalTriggerGeometryFactory, "HGCalTriggerGeometryFactory"); diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerGeometryGenericMapping.cc b/L1Trigger/L1THGCal/src/HGCalTriggerGeometryGenericMapping.cc index 138b06f9ddd43..f5d35ab757385 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerGeometryGenericMapping.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerGeometryGenericMapping.cc @@ -1,17 +1,14 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h" - using namespace HGCalTriggerGeometry; namespace { std::unique_ptr null_tc; - std::unique_ptr null_mod; -} + std::unique_ptr null_mod; +} // namespace -HGCalTriggerGeometryGenericMapping:: -HGCalTriggerGeometryGenericMapping(const edm::ParameterSet& conf) : - HGCalTriggerGeometryBase(conf){ -} +HGCalTriggerGeometryGenericMapping::HGCalTriggerGeometryGenericMapping(const edm::ParameterSet& conf) + : HGCalTriggerGeometryBase(conf) {} void HGCalTriggerGeometryGenericMapping::reset() { geom_map().swap(cells_to_trigger_cells_); @@ -20,122 +17,92 @@ void HGCalTriggerGeometryGenericMapping::reset() { trigger_cell_map().swap(trigger_cells_); } -unsigned -HGCalTriggerGeometryGenericMapping:: -getTriggerCellFromCell( const unsigned cell_det_id ) const { +unsigned HGCalTriggerGeometryGenericMapping::getTriggerCellFromCell(const unsigned cell_det_id) const { auto found_tc = cells_to_trigger_cells_.find(cell_det_id); - if( found_tc == cells_to_trigger_cells_.end() ) { + if (found_tc == cells_to_trigger_cells_.end()) { return 0; } return trigger_cells_.find(found_tc->second)->second->triggerCellId(); } -unsigned -HGCalTriggerGeometryGenericMapping:: -getModuleFromCell( const unsigned cell_det_id ) const { +unsigned HGCalTriggerGeometryGenericMapping::getModuleFromCell(const unsigned cell_det_id) const { auto found_tc = cells_to_trigger_cells_.find(cell_det_id); - if( found_tc == cells_to_trigger_cells_.end() ) { + if (found_tc == cells_to_trigger_cells_.end()) { return 0; } auto found_mod = trigger_cells_to_modules_.find(found_tc->second); - if( found_mod == trigger_cells_to_modules_.end() ) { + if (found_mod == trigger_cells_to_modules_.end()) { return 0; } return modules_.find(found_mod->second)->second->moduleId(); } -unsigned -HGCalTriggerGeometryGenericMapping:: -getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const { +unsigned HGCalTriggerGeometryGenericMapping::getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const { auto found_mod = trigger_cells_to_modules_.find(trigger_cell_det_id); - if( found_mod == trigger_cells_to_modules_.end() ) { + if (found_mod == trigger_cells_to_modules_.end()) { return 0; } return modules_.find(found_mod->second)->second->moduleId(); } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryGenericMapping:: -getCellsFromTriggerCell( const unsigned trigger_cell_det_id ) const { +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryGenericMapping::getCellsFromTriggerCell( + const unsigned trigger_cell_det_id) const { return trigger_cells_.find(trigger_cell_det_id)->second->components(); } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryGenericMapping:: -getCellsFromModule( const unsigned module_det_id ) const { +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryGenericMapping::getCellsFromModule( + const unsigned module_det_id) const { const auto& triggercell_cells = modules_.find(module_det_id)->second->triggerCellComponents(); HGCalTriggerGeometryBase::geom_set cells; - for(const auto& tc_c : triggercell_cells) { + for (const auto& tc_c : triggercell_cells) { cells.emplace(tc_c.second); } - return cells; + return cells; } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryGenericMapping:: -getOrderedCellsFromModule( const unsigned module_det_id ) const { +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryGenericMapping::getOrderedCellsFromModule( + const unsigned module_det_id) const { const auto& triggercell_cells = modules_.find(module_det_id)->second->triggerCellComponents(); HGCalTriggerGeometryBase::geom_ordered_set cells; - for(const auto& tc_c : triggercell_cells) { + for (const auto& tc_c : triggercell_cells) { cells.emplace(tc_c.second); } - return cells; + return cells; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryGenericMapping:: -getTriggerCellsFromModule( const unsigned module_det_id ) const { - return modules_.find(module_det_id)->second->components(); +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryGenericMapping::getTriggerCellsFromModule( + const unsigned module_det_id) const { + return modules_.find(module_det_id)->second->components(); } -HGCalTriggerGeometryBase::geom_ordered_set -HGCalTriggerGeometryGenericMapping:: -getOrderedTriggerCellsFromModule( const unsigned module_det_id ) const { +HGCalTriggerGeometryBase::geom_ordered_set HGCalTriggerGeometryGenericMapping::getOrderedTriggerCellsFromModule( + const unsigned module_det_id) const { // Build set from unordered_set. Maybe a more efficient to do it HGCalTriggerGeometryBase::geom_ordered_set trigger_cells; - for(const auto& tc : modules_.find(module_det_id)->second->components()) { + for (const auto& tc : modules_.find(module_det_id)->second->components()) { trigger_cells.emplace(tc); } - return trigger_cells; + return trigger_cells; } -HGCalTriggerGeometryBase::geom_set -HGCalTriggerGeometryGenericMapping:: -getNeighborsFromTriggerCell( const unsigned trigger_cell_id ) const -{ +HGCalTriggerGeometryBase::geom_set HGCalTriggerGeometryGenericMapping::getNeighborsFromTriggerCell( + const unsigned trigger_cell_id) const { // empty neighbors return geom_set(); } -GlobalPoint -HGCalTriggerGeometryGenericMapping:: -getTriggerCellPosition(const unsigned trigger_cell_det_id) const { - return trigger_cells_.find(trigger_cell_det_id)->second->position(); +GlobalPoint HGCalTriggerGeometryGenericMapping::getTriggerCellPosition(const unsigned trigger_cell_det_id) const { + return trigger_cells_.find(trigger_cell_det_id)->second->position(); } -GlobalPoint -HGCalTriggerGeometryGenericMapping:: -getModulePosition(const unsigned module_det_id) const { +GlobalPoint HGCalTriggerGeometryGenericMapping::getModulePosition(const unsigned module_det_id) const { return modules_.find(module_det_id)->second->position(); } - -bool -HGCalTriggerGeometryGenericMapping:: -validTriggerCell(const unsigned trigger_cell_det_id) const { - return (trigger_cells_.find(trigger_cell_det_id)!=trigger_cells_.end()); -} - -bool -HGCalTriggerGeometryGenericMapping:: -disconnectedModule(const unsigned module_id) const { - return false; +bool HGCalTriggerGeometryGenericMapping::validTriggerCell(const unsigned trigger_cell_det_id) const { + return (trigger_cells_.find(trigger_cell_det_id) != trigger_cells_.end()); } +bool HGCalTriggerGeometryGenericMapping::disconnectedModule(const unsigned module_id) const { return false; } -unsigned -HGCalTriggerGeometryGenericMapping:: -triggerLayer(const unsigned id) const { - return HGCalDetId(id).layer(); -} - +unsigned HGCalTriggerGeometryGenericMapping::triggerLayer(const unsigned id) const { return HGCalDetId(id).layer(); } diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc b/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc index 20f76b5a4c5a4..111d9fb6d6d8e 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerTools.cc @@ -1,6 +1,5 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" @@ -15,51 +14,41 @@ #include "FWCore/Framework/interface/EventSetup.h" - namespace { - template + template inline void check_ddd(const DDD* ddd) { - if( nullptr == ddd ) { - throw cms::Exception("hgcal::HGCalTriggerTools") - << "DDDConstants not accessible to hgcal::HGCalTriggerTools!"; + if (nullptr == ddd) { + throw cms::Exception("hgcal::HGCalTriggerTools") << "DDDConstants not accessible to hgcal::HGCalTriggerTools!"; } } - template + template inline void check_geom(const GEOM* geom) { - if( nullptr == geom ) { - throw cms::Exception("hgcal::HGCalTriggerTools") - << "Geometry not provided yet to hgcal::HGCalTriggerTools!"; + if (nullptr == geom) { + throw cms::Exception("hgcal::HGCalTriggerTools") << "Geometry not provided yet to hgcal::HGCalTriggerTools!"; } } -} +} // namespace -void -HGCalTriggerTools:: -eventSetup(const edm::EventSetup& es) -{ +void HGCalTriggerTools::eventSetup(const edm::EventSetup& es) { edm::ESHandle triggerGeometry_; es.get().get(triggerGeometry_); geom_ = triggerGeometry_.product(); eeLayers_ = geom_->eeTopology().dddConstants().layers(true); fhLayers_ = geom_->fhTopology().dddConstants().layers(true); - if(geom_->isV9Geometry()) - { + if (geom_->isV9Geometry()) { bhLayers_ = geom_->hscTopology().dddConstants().layers(true); - totalLayers_ = eeLayers_ + fhLayers_; - } - else - { + totalLayers_ = eeLayers_ + fhLayers_; + } else { bhLayers_ = geom_->bhTopology().dddConstants()->getMaxDepth(1); - totalLayers_ = eeLayers_ + fhLayers_ + bhLayers_; + totalLayers_ = eeLayers_ + fhLayers_ + bhLayers_; } } GlobalPoint HGCalTriggerTools::getTCPosition(const DetId& id) const { - if(id.det() == DetId::Hcal || id.det()==DetId::HGCalEE) { - throw cms::Exception("hgcal::HGCalTriggerTools") - << "method getTCPosition called for DetId not belonging to a TC"; + if (id.det() == DetId::Hcal || id.det() == DetId::HGCalEE) { + throw cms::Exception("hgcal::HGCalTriggerTools") << "method getTCPosition called for DetId not belonging to a TC"; // FIXME: this would actually need a better test...but at the moment I can not think to anything better // to distinguish a TC detId } @@ -68,14 +57,9 @@ GlobalPoint HGCalTriggerTools::getTCPosition(const DetId& id) const { return position; } - -unsigned -HGCalTriggerTools:: -layers(ForwardSubdetector type) const -{ +unsigned HGCalTriggerTools::layers(ForwardSubdetector type) const { unsigned layers = 0; - switch(type) - { + switch (type) { case ForwardSubdetector::HGCEE: layers = eeLayers_; break; @@ -94,13 +78,9 @@ layers(ForwardSubdetector type) const return layers; } -unsigned -HGCalTriggerTools:: -layers(DetId::Detector type) const -{ +unsigned HGCalTriggerTools::layers(DetId::Detector type) const { unsigned layers = 0; - switch (type) - { + switch (type) { case DetId::HGCalEE: layers = eeLayers_; break; @@ -119,10 +99,7 @@ layers(DetId::Detector type) const return layers; } - -unsigned -HGCalTriggerTools:: -layer(const DetId& id) const { +unsigned HGCalTriggerTools::layer(const DetId& id) const { unsigned int layer = std::numeric_limits::max(); if (id.det() == DetId::Forward) { layer = HGCalDetId(id).layer(); @@ -138,54 +115,48 @@ layer(const DetId& id) const { return layer; } -unsigned -HGCalTriggerTools:: -layerWithOffset(const DetId& id) const { +unsigned HGCalTriggerTools::layerWithOffset(const DetId& id) const { unsigned int l = layer(id); - if(isHad(id) && isSilicon(id)) { + if (isHad(id) && isSilicon(id)) { l += eeLayers_; - } else if(isHad(id) && isScintillator(id)) { - if(geom_->isV9Geometry()) l += eeLayers_; // mixed silicon and scintillator layers - else l += eeLayers_ + fhLayers_; + } else if (isHad(id) && isScintillator(id)) { + if (geom_->isV9Geometry()) + l += eeLayers_; // mixed silicon and scintillator layers + else + l += eeLayers_ + fhLayers_; } return l; } -bool -HGCalTriggerTools:: -isEm(const DetId& id) const { +bool HGCalTriggerTools::isEm(const DetId& id) const { bool em = false; if (id.det() == DetId::Forward) { - em = (id.subdetId()==HGCEE); + em = (id.subdetId() == HGCEE); } else if (id.det() == DetId::HGCalEE) { em = true; } else if (id.det() == DetId::HGCalTrigger) { - em = (HGCalTriggerDetId(id).subdet()==HGCalTriggerSubdetector::HGCalEETrigger); + em = (HGCalTriggerDetId(id).subdet() == HGCalTriggerSubdetector::HGCalEETrigger); } return em; } -bool -HGCalTriggerTools:: -isSilicon(const DetId& id) const { +bool HGCalTriggerTools::isSilicon(const DetId& id) const { bool silicon = false; if (id.det() == DetId::Forward) { - silicon = (id.subdetId()!=HGCHEB); + silicon = (id.subdetId() != HGCHEB); } else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) { silicon = true; } else if (id.det() == DetId::HGCalTrigger) { - silicon = (HGCalTriggerDetId(id).subdet()!=HGCalTriggerSubdetector::HGCalHScTrigger); + silicon = (HGCalTriggerDetId(id).subdet() != HGCalTriggerSubdetector::HGCalHScTrigger); } return silicon; } -int -HGCalTriggerTools:: -zside(const DetId& id) const { +int HGCalTriggerTools::zside(const DetId& id) const { int zside = 0; if (id.det() == DetId::Forward) { zside = HGCalDetId(id).zside(); - } else if( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) { + } else if (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) { zside = HcalDetId(id).zside(); } else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) { zside = HGCSiliconDetId(id).zside(); @@ -197,43 +168,36 @@ zside(const DetId& id) const { return zside; } -int -HGCalTriggerTools:: -thicknessIndex(const DetId& id, bool tc) const { +int HGCalTriggerTools::thicknessIndex(const DetId& id, bool tc) const { unsigned det = id.det(); int thickness = 0; // For the v8 geometry - if(det==DetId::Forward) - { - if(!tc) thickness = sensorCellThicknessV8(id); - else - { + if (det == DetId::Forward) { + if (!tc) + thickness = sensorCellThicknessV8(id); + else { // For the old geometry, TCs can contain sensor cells // with different thicknesses. // Use a majority logic to find the TC thickness - std::array occurences = { {0,0,0} }; - for(const auto& c_id : geom_->getCellsFromTriggerCell(id)) - { + std::array occurences = {{0, 0, 0}}; + for (const auto& c_id : geom_->getCellsFromTriggerCell(id)) { int c_thickness = sensorCellThicknessV8(c_id); occurences[c_thickness]++; } - thickness = std::max_element(occurences.begin(),occurences.end()) - occurences.begin(); + thickness = std::max_element(occurences.begin(), occurences.end()) - occurences.begin(); } } // For the v9 geometry - else if(det==DetId::HGCalEE || det==DetId::HGCalHSi) - { + else if (det == DetId::HGCalEE || det == DetId::HGCalHSi) { thickness = HGCSiliconDetId(id).type(); - } - else if(det==DetId::HGCalTrigger) - { + } else if (det == DetId::HGCalTrigger) { thickness = HGCalTriggerDetId(id).type(); } return thickness; } float HGCalTriggerTools::getEta(const GlobalPoint& position, const float& vertex_z) const { - GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z()-vertex_z); + GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z() - vertex_z); return corrected_position.eta(); } @@ -243,7 +207,7 @@ float HGCalTriggerTools::getTCEta(const DetId& id, const float& vertex_z) const } float HGCalTriggerTools::getPhi(const GlobalPoint& position) const { - float phi = atan2(position.y(),position.x()); + float phi = atan2(position.y(), position.x()); return phi; } @@ -266,10 +230,10 @@ float HGCalTriggerTools::getTCPt(const DetId& id, const float& hitEnergy, const float HGCalTriggerTools::getLayerZ(const unsigned& layerWithOffset) const { int subdet = ForwardSubdetector::HGCEE; unsigned offset = 0; - if(layerWithOffset > lastLayerEE() && layerWithOffset <= lastLayerFH()) { + if (layerWithOffset > lastLayerEE() && layerWithOffset <= lastLayerFH()) { subdet = ForwardSubdetector::HGCHEF; offset = lastLayerEE(); - } else if(layerWithOffset > lastLayerFH()) { + } else if (layerWithOffset > lastLayerFH()) { subdet = HcalSubdetector::HcalEndcap; offset = lastLayerFH(); } @@ -278,87 +242,64 @@ float HGCalTriggerTools::getLayerZ(const unsigned& layerWithOffset) const { float HGCalTriggerTools::getLayerZ(const int& subdet, const unsigned& layer) const { float layerGlobalZ = 0.; - if( (subdet == ForwardSubdetector::HGCEE) || - (subdet == DetId::HGCalEE) ) { + if ((subdet == ForwardSubdetector::HGCEE) || (subdet == DetId::HGCalEE)) { layerGlobalZ = geom_->eeTopology().dddConstants().waferZ(layer, true); - } else if( (subdet == ForwardSubdetector::HGCHEF) || - (subdet == DetId::HGCalHSi) ) { + } else if ((subdet == ForwardSubdetector::HGCHEF) || (subdet == DetId::HGCalHSi)) { layerGlobalZ = geom_->fhTopology().dddConstants().waferZ(layer, true); - } else if( (subdet == HcalSubdetector::HcalEndcap) || - (subdet == ForwardSubdetector::HGCHEB) || - (subdet == DetId::HGCalHSc) ) { - if(geom_->isV9Geometry()) - { + } else if ((subdet == HcalSubdetector::HcalEndcap) || (subdet == ForwardSubdetector::HGCHEB) || + (subdet == DetId::HGCalHSc)) { + if (geom_->isV9Geometry()) { layerGlobalZ = geom_->hscTopology().dddConstants().waferZ(layer, true); - } - else - { + } else { layerGlobalZ = geom_->bhTopology().dddConstants()->getRZ( - HcalSubdetector::HcalEndcap, - geom_->bhTopology().dddConstants()->getEtaRange(1).second, - layer); + HcalSubdetector::HcalEndcap, geom_->bhTopology().dddConstants()->getEtaRange(1).second, layer); } } return layerGlobalZ; } - -DetId -HGCalTriggerTools:: -simToReco(const DetId& simid, const HGCalTopology& topo) const -{ +DetId HGCalTriggerTools::simToReco(const DetId& simid, const HGCalTopology& topo) const { DetId recoid(0); const auto& dddConst = topo.dddConstants(); // V9 - if (dddConst.geomMode() == HGCalGeometryMode::Hexagon8 || - dddConst.geomMode() == HGCalGeometryMode::Hexagon8Full || - dddConst.geomMode() == HGCalGeometryMode::Trapezoid) - { + if (dddConst.geomMode() == HGCalGeometryMode::Hexagon8 || dddConst.geomMode() == HGCalGeometryMode::Hexagon8Full || + dddConst.geomMode() == HGCalGeometryMode::Trapezoid) { recoid = simid; } // V8 - else - { + else { int subdet(simid.subdetId()); - int layer=0, cell=0, sec=0, subsec=0, zp=0; + int layer = 0, cell = 0, sec = 0, subsec = 0, zp = 0; HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); //sec is wafer and subsec is celltype //skip this hit if after ganging it is not valid - auto recoLayerCell = dddConst.simToReco(cell,layer,sec,topo.detectorType()); - cell = recoLayerCell.first; + auto recoLayerCell = dddConst.simToReco(cell, layer, sec, topo.detectorType()); + cell = recoLayerCell.first; layer = recoLayerCell.second; - if (layer>=0 && cell>=0) - { - recoid = HGCalDetId((ForwardSubdetector)subdet,zp,layer,subsec,sec,cell); + if (layer >= 0 && cell >= 0) { + recoid = HGCalDetId((ForwardSubdetector)subdet, zp, layer, subsec, sec, cell); } } return recoid; } - -DetId -HGCalTriggerTools:: -simToReco(const DetId& simid, const HcalTopology& topo) const -{ +DetId HGCalTriggerTools::simToReco(const DetId& simid, const HcalTopology& topo) const { DetId recoid(0); const auto& dddConst = topo.dddConstants(); - HcalDetId id = HcalHitRelabeller::relabel(simid,dddConst); - if (id.subdet()==int(HcalEndcap)) recoid = id; + HcalDetId id = HcalHitRelabeller::relabel(simid, dddConst); + if (id.subdet() == int(HcalEndcap)) + recoid = id; return recoid; } - -int -HGCalTriggerTools:: -sensorCellThicknessV8(const DetId& id) const { +int HGCalTriggerTools::sensorCellThicknessV8(const DetId& id) const { int thickness = 0; - switch(id.subdetId()) - { + switch (id.subdetId()) { case ForwardSubdetector::HGCEE: - thickness = geom_->eeTopology().dddConstants().waferTypeL(HGCalDetId(id).wafer())-1; + thickness = geom_->eeTopology().dddConstants().waferTypeL(HGCalDetId(id).wafer()) - 1; break; case ForwardSubdetector::HGCHEF: - thickness = geom_->fhTopology().dddConstants().waferTypeL(HGCalDetId(id).wafer())-1; + thickness = geom_->fhTopology().dddConstants().waferTypeL(HGCalDetId(id).wafer()) - 1; break; default: break; diff --git a/L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc b/L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc index cce742da2553c..52a6ae09d3cf6 100644 --- a/L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc +++ b/L1Trigger/L1THGCal/src/HGCalTriggerTowerGeometryHelper.cc @@ -10,123 +10,120 @@ #include #include - -HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(const edm::ParameterSet& conf) : minEta_(conf.getParameter("minEta")), - maxEta_(conf.getParameter("maxEta")), - minPhi_(conf.getParameter("minPhi")), - maxPhi_(conf.getParameter("maxPhi")), - nBinsEta_(conf.getParameter("nBinsEta")), - nBinsPhi_(conf.getParameter("nBinsPhi")), - binsEta_(conf.getParameter >("binsEta")), - binsPhi_(conf.getParameter >("binsPhi")) { - - - if(!binsEta_.empty() && ((unsigned int)(binsEta_.size()) != nBinsEta_+1)) { +HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(const edm::ParameterSet& conf) + : minEta_(conf.getParameter("minEta")), + maxEta_(conf.getParameter("maxEta")), + minPhi_(conf.getParameter("minPhi")), + maxPhi_(conf.getParameter("maxPhi")), + nBinsEta_(conf.getParameter("nBinsEta")), + nBinsPhi_(conf.getParameter("nBinsPhi")), + binsEta_(conf.getParameter >("binsEta")), + binsPhi_(conf.getParameter >("binsPhi")) { + if (!binsEta_.empty() && ((unsigned int)(binsEta_.size()) != nBinsEta_ + 1)) { throw edm::Exception(edm::errors::Configuration, "Configuration") - << "HGCalTriggerTowerGeometryHelper nBinsEta for the tower map not consistent with binsEta size"<("readMappingFile")) { + if (conf.getParameter("readMappingFile")) { // We read the TC to TT mapping from file, // otherwise we derive the TC to TT mapping on the fly from eta-phi coord. of the TCs std::ifstream l1tTriggerTowerMappingStream(conf.getParameter("L1TTriggerTowerMapping").fullPath()); - if(!l1tTriggerTowerMappingStream.is_open()) { - throw cms::Exception("MissingDataFile") - << "Cannot open HGCalTriggerGeometry L1TTriggerTowerMapping file\n"; + if (!l1tTriggerTowerMappingStream.is_open()) { + throw cms::Exception("MissingDataFile") << "Cannot open HGCalTriggerGeometry L1TTriggerTowerMapping file\n"; } unsigned trigger_cell_id = 0; unsigned short iEta = 0; unsigned short iPhi = 0; - for(; l1tTriggerTowerMappingStream >> trigger_cell_id >> iEta >> iPhi;) { - if(iEta >= nBinsEta_ || iPhi >= nBinsPhi_) { + for (; l1tTriggerTowerMappingStream >> trigger_cell_id >> iEta >> iPhi;) { + if (iEta >= nBinsEta_ || iPhi >= nBinsPhi_) { throw edm::Exception(edm::errors::Configuration, "Configuration") - << "HGCalTriggerTowerGeometryHelper warning inconsistent mapping TC : " << trigger_cell_id - << " to TT iEta: " << iEta << " iPhi: " << iPhi - << " when max #bins eta: " << nBinsEta_ << " phi: " << nBinsPhi_ << std::endl; + << "HGCalTriggerTowerGeometryHelper warning inconsistent mapping TC : " << trigger_cell_id + << " to TT iEta: " << iEta << " iPhi: " << iPhi << " when max #bins eta: " << nBinsEta_ + << " phi: " << nBinsPhi_ << std::endl; } l1t::HGCalTowerID towerId(triggerTools_.zside(DetId(trigger_cell_id)), iEta, iPhi); cells_to_trigger_towers_[trigger_cell_id] = towerId.rawId(); } l1tTriggerTowerMappingStream.close(); - } } - const std::vector& HGCalTriggerTowerGeometryHelper::getTowerCoordinates() const { return tower_coords_; } - -unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTowerFromTriggerCell(const unsigned trigger_cell_id, const float& eta, const float& phi) const { +unsigned short HGCalTriggerTowerGeometryHelper::getTriggerTowerFromTriggerCell(const unsigned trigger_cell_id, + const float& eta, + const float& phi) const { // NOTE: if the TC is not found in the map than it is mapped via eta-phi coords. // this can be considered dangerous (silent failure of the map) but it actually allows to save // memory mapping explicitly only what is actually needed auto tower_id_itr = cells_to_trigger_towers_.find(trigger_cell_id); - if(tower_id_itr != cells_to_trigger_towers_.end()) return tower_id_itr->second; + if (tower_id_itr != cells_to_trigger_towers_.end()) + return tower_id_itr->second; auto bin_eta_l = std::lower_bound(binsEta_.begin(), binsEta_.end(), fabs(eta)); unsigned int bin_eta = 0; // we add a protection for TCs in Hadron part which are outside the boundaries and possible rounding effects - if(bin_eta_l == binsEta_.end()) { - if(fabs(eta) < minEta_) { + if (bin_eta_l == binsEta_.end()) { + if (fabs(eta) < minEta_) { bin_eta = 0; - } else if(fabs(eta) >= maxEta_) { + } else if (fabs(eta) >= maxEta_) { bin_eta = nBinsEta_; } else { - edm::LogError("HGCalTriggerTowerGeometryHelper") << " did not manage to map TC " << trigger_cell_id << " (eta: " << eta << ") to any Trigger Tower\n"; + edm::LogError("HGCalTriggerTowerGeometryHelper") + << " did not manage to map TC " << trigger_cell_id << " (eta: " << eta << ") to any Trigger Tower\n"; } } else { bin_eta = bin_eta_l - binsEta_.begin() - 1; } - auto bin_phi_l = std::lower_bound(binsPhi_.begin(), binsPhi_.end(), phi); unsigned int bin_phi = 0; - if(bin_phi_l == binsPhi_.end()) { - if(phi < minPhi_) { + if (bin_phi_l == binsPhi_.end()) { + if (phi < minPhi_) { bin_phi = nBinsPhi_; - } else if(phi >= maxPhi_) { + } else if (phi >= maxPhi_) { bin_phi = 0; } else { - edm::LogError("HGCalTriggerTowerGeometryHelper") << " did not manage to map TC " << trigger_cell_id << " (phi: " << phi << ") to any Trigger Tower\n"; + edm::LogError("HGCalTriggerTowerGeometryHelper") + << " did not manage to map TC " << trigger_cell_id << " (phi: " << phi << ") to any Trigger Tower\n"; } } else { bin_phi = bin_phi_l - binsPhi_.begin() - 1; } - int zside = eta < 0 ? -1 : 1; + int zside = eta < 0 ? -1 : 1; return l1t::HGCalTowerID(zside, bin_eta, bin_phi).rawId(); } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalClusteringDummyImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalClusteringDummyImpl.cc index 670ec363f406f..2c8f14bd8ad8a 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalClusteringDummyImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalClusteringDummyImpl.cc @@ -5,64 +5,52 @@ #include "DataFormats/Common/interface/OrphanHandle.h" //class constructor -HGCalClusteringDummyImpl::HGCalClusteringDummyImpl(const edm::ParameterSet & conf): - calibSF_(conf.getParameter("calibSF_cluster")), - layerWeights_(conf.getParameter< std::vector >("layerWeights")), - applyLayerWeights_(conf.getParameter< bool >("applyLayerCalibration")) -{ - edm::LogInfo("HGCalClusterParameters") << "C2d global calibration factor: " << calibSF_; +HGCalClusteringDummyImpl::HGCalClusteringDummyImpl(const edm::ParameterSet& conf) + : calibSF_(conf.getParameter("calibSF_cluster")), + layerWeights_(conf.getParameter>("layerWeights")), + applyLayerWeights_(conf.getParameter("applyLayerCalibration")) { + edm::LogInfo("HGCalClusterParameters") << "C2d global calibration factor: " << calibSF_; } - - //Create one cluster per TC for direct TC->3D clustering -void HGCalClusteringDummyImpl::clusterizeDummy( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters - ){ - +void HGCalClusteringDummyImpl::clusterizeDummy(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters) { std::vector clustersTmp; - for( std::vector>::const_iterator tc = triggerCellsPtrs.begin(); tc != triggerCellsPtrs.end(); ++tc ){ - clustersTmp.emplace_back( *tc ); + for (std::vector>::const_iterator tc = triggerCellsPtrs.begin(); + tc != triggerCellsPtrs.end(); + ++tc) { + clustersTmp.emplace_back(*tc); } /* store clusters in the persistent collection */ clusters.resize(0, clustersTmp.size()); - for( unsigned i(0); i("seeding_threshold_silicon")), - siliconTriggerCellThreshold_(conf.getParameter("clustering_threshold_silicon")), - scintillatorSeedThreshold_(conf.getParameter("seeding_threshold_scintillator")), - scintillatorTriggerCellThreshold_(conf.getParameter("clustering_threshold_scintillator")), - dr_(conf.getParameter("dR_cluster")), - clusteringAlgorithmType_(conf.getParameter("clusterType")), - calibSF_(conf.getParameter("calibSF_cluster")), - layerWeights_(conf.getParameter< std::vector >("layerWeights")), - applyLayerWeights_(conf.getParameter< bool >("applyLayerCalibration")) -{ - edm::LogInfo("HGCalClusterParameters") << "C2d Clustering Algorithm selected : " << clusteringAlgorithmType_ ; - edm::LogInfo("HGCalClusterParameters") << "C2d silicon seeding Thr: " << siliconSeedThreshold_ ; - edm::LogInfo("HGCalClusterParameters") << "C2d silicon clustering Thr: " << siliconTriggerCellThreshold_ ; - edm::LogInfo("HGCalClusterParameters") << "C2d scintillator seeding Thr: " << scintillatorSeedThreshold_ ; - edm::LogInfo("HGCalClusterParameters") << "C2d scintillator clustering Thr: " << scintillatorTriggerCellThreshold_ ; - edm::LogInfo("HGCalClusterParameters") << "C2d global calibration factor: " << calibSF_; +HGCalClusteringImpl::HGCalClusteringImpl(const edm::ParameterSet& conf) + : siliconSeedThreshold_(conf.getParameter("seeding_threshold_silicon")), + siliconTriggerCellThreshold_(conf.getParameter("clustering_threshold_silicon")), + scintillatorSeedThreshold_(conf.getParameter("seeding_threshold_scintillator")), + scintillatorTriggerCellThreshold_(conf.getParameter("clustering_threshold_scintillator")), + dr_(conf.getParameter("dR_cluster")), + clusteringAlgorithmType_(conf.getParameter("clusterType")), + calibSF_(conf.getParameter("calibSF_cluster")), + layerWeights_(conf.getParameter>("layerWeights")), + applyLayerWeights_(conf.getParameter("applyLayerCalibration")) { + edm::LogInfo("HGCalClusterParameters") << "C2d Clustering Algorithm selected : " << clusteringAlgorithmType_; + edm::LogInfo("HGCalClusterParameters") << "C2d silicon seeding Thr: " << siliconSeedThreshold_; + edm::LogInfo("HGCalClusterParameters") << "C2d silicon clustering Thr: " << siliconTriggerCellThreshold_; + edm::LogInfo("HGCalClusterParameters") << "C2d scintillator seeding Thr: " << scintillatorSeedThreshold_; + edm::LogInfo("HGCalClusterParameters") << "C2d scintillator clustering Thr: " << scintillatorTriggerCellThreshold_; + edm::LogInfo("HGCalClusterParameters") << "C2d global calibration factor: " << calibSF_; } - /* dR-algorithms */ -bool HGCalClusteringImpl::isPertinent( const l1t::HGCalTriggerCell & tc, - const l1t::HGCalCluster & clu, - double distXY ) const -{ - - DetId tcDetId( tc.detId() ); - DetId cluDetId( clu.detId() ); - if( (triggerTools_.layer(tcDetId) != triggerTools_.layer(cluDetId)) || - (tcDetId.subdetId() != cluDetId.subdetId()) || - (triggerTools_.zside(tcDetId) != triggerTools_.zside(cluDetId) )){ - return false; - } - if ( clu.distance((tc)) < distXY ){ - return true; - } +bool HGCalClusteringImpl::isPertinent(const l1t::HGCalTriggerCell& tc, + const l1t::HGCalCluster& clu, + double distXY) const { + DetId tcDetId(tc.detId()); + DetId cluDetId(clu.detId()); + if ((triggerTools_.layer(tcDetId) != triggerTools_.layer(cluDetId)) || (tcDetId.subdetId() != cluDetId.subdetId()) || + (triggerTools_.zside(tcDetId) != triggerTools_.zside(cluDetId))) { return false; - + } + if (clu.distance((tc)) < distXY) { + return true; + } + return false; } - -void HGCalClusteringImpl::clusterizeDR( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters - ){ - - bool isSeed[triggerCellsPtrs.size()]; - - /* search for cluster seeds */ - int itc(0); - for( std::vector>::const_iterator tc = triggerCellsPtrs.begin(); tc != triggerCellsPtrs.end(); ++tc,++itc ){ - double seedThreshold = ((*tc)->subdetId()==HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); - isSeed[itc] = ( (*tc)->mipPt() > seedThreshold) ? true : false; +void HGCalClusteringImpl::clusterizeDR(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters) { + bool isSeed[triggerCellsPtrs.size()]; + + /* search for cluster seeds */ + int itc(0); + for (std::vector>::const_iterator tc = triggerCellsPtrs.begin(); + tc != triggerCellsPtrs.end(); + ++tc, ++itc) { + double seedThreshold = ((*tc)->subdetId() == HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); + isSeed[itc] = ((*tc)->mipPt() > seedThreshold) ? true : false; + } + + /* clustering the TCs */ + std::vector clustersTmp; + + itc = 0; + for (std::vector>::const_iterator tc = triggerCellsPtrs.begin(); + tc != triggerCellsPtrs.end(); + ++tc, ++itc) { + double threshold = ((*tc)->subdetId() == HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); + if ((*tc)->mipPt() < threshold) { + continue; } - - /* clustering the TCs */ - std::vector clustersTmp; - - itc=0; - for( std::vector>::const_iterator tc = triggerCellsPtrs.begin(); tc != triggerCellsPtrs.end(); ++tc,++itc ){ - double threshold = ((*tc)->subdetId()==HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); - if( (*tc)->mipPt() < threshold ){ - continue; - } - - /* + + /* searching for TC near the center of the cluster ToBeFixed: if a tc is not a seed, but could be potencially be part of a cluster generated by a late seed, the tc will not be clusterized */ - double minDist = dr_; - int targetClu = -1; - - for(unsigned iclu=0; icluisPertinent(**tc, clustersTmp.at(iclu), dr_)) continue; + for (unsigned iclu = 0; iclu < clustersTmp.size(); iclu++) { + if (!this->isPertinent(**tc, clustersTmp.at(iclu), dr_)) + continue; - double d = clustersTmp.at(iclu).distance(**tc); - if(d=0) clustersTmp.at( targetClu ).addConstituent( *tc ); - - } - - /* store clusters in the persistent collection */ - clusters.resize(0, clustersTmp.size()); - for( unsigned i(0); i= 0) + clustersTmp.at(targetClu).addConstituent(*tc); + } + + /* store clusters in the persistent collection */ + clusters.resize(0, clustersTmp.size()); + for (unsigned i(0); i < clustersTmp.size(); ++i) { + calibratePt(clustersTmp.at(i)); + clusters.set(0, i, clustersTmp.at(i)); + } } - - /* NN-algorithms */ /* storing trigger cells into vector per layer and per endcap */ -void HGCalClusteringImpl::triggerCellReshuffling( const std::vector> & triggerCellsPtrs, - std::array< std::vector>>,kNSides_> & reshuffledTriggerCells - ){ - - for( const auto& tc : triggerCellsPtrs ){ - DetId tcDetId( tc->detId() ); - int endcap = triggerTools_.zside(tcDetId) == -1 ? 0 : 1 ; - unsigned layer = triggerTools_.layerWithOffset(tc->detId()); - - reshuffledTriggerCells[endcap][layer-1].emplace_back(tc); - - } - +void HGCalClusteringImpl::triggerCellReshuffling( + const std::vector>& triggerCellsPtrs, + std::array>>, kNSides_>& reshuffledTriggerCells) { + for (const auto& tc : triggerCellsPtrs) { + DetId tcDetId(tc->detId()); + int endcap = triggerTools_.zside(tcDetId) == -1 ? 0 : 1; + unsigned layer = triggerTools_.layerWithOffset(tc->detId()); + + reshuffledTriggerCells[endcap][layer - 1].emplace_back(tc); + } } - /* merge clusters that have common neighbors */ -void HGCalClusteringImpl::mergeClusters( l1t::HGCalCluster & main_cluster, - const l1t::HGCalCluster & secondary_cluster ) const -{ - - const std::unordered_map>& pertinentTC = secondary_cluster.constituents(); - - for(const auto& id_tc : pertinentTC){ - main_cluster.addConstituent(id_tc.second); - } +void HGCalClusteringImpl::mergeClusters(l1t::HGCalCluster& main_cluster, + const l1t::HGCalCluster& secondary_cluster) const { + const std::unordered_map>& pertinentTC = secondary_cluster.constituents(); + for (const auto& id_tc : pertinentTC) { + main_cluster.addConstituent(id_tc.second); + } } +void HGCalClusteringImpl::NNKernel(const std::vector>& reshuffledTriggerCells, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry) { + /* declaring the clusters vector */ + std::vector clustersTmp; + + // map TC id -> cluster index in clustersTmp + std::unordered_map cluNNmap; + + /* loop over the trigger-cells */ + for (const auto& tc_ptr : reshuffledTriggerCells) { + double threshold = + (tc_ptr->subdetId() == HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); + if (tc_ptr->mipPt() < threshold) { + continue; + } -void HGCalClusteringImpl::NNKernel( const std::vector> & reshuffledTriggerCells, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ){ - - /* declaring the clusters vector */ - std::vector clustersTmp; - - // map TC id -> cluster index in clustersTmp - std::unordered_map cluNNmap; - - /* loop over the trigger-cells */ - for( const auto& tc_ptr : reshuffledTriggerCells ){ - double threshold = (tc_ptr->subdetId()==HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); - if( tc_ptr->mipPt() < threshold ){ - continue; - } - - // Check if the neighbors of that TC are already included in a cluster - // If this is the case, add the TC to the first (arbitrary) neighbor cluster - // Otherwise create a new cluster - bool createNewC2d(true); - const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell(tc_ptr->detId()); - for( const auto neighbor : neighbors ){ - auto tc_cluster_itr = cluNNmap.find(neighbor); - if(tc_cluster_itr!=cluNNmap.end()){ - createNewC2d = false; - if( tc_cluster_itr->second < clustersTmp.size()){ - clustersTmp.at(tc_cluster_itr->second).addConstituent(tc_ptr); - // map TC id to the existing cluster - cluNNmap.emplace(tc_ptr->detId(), tc_cluster_itr->second); - } - else{ - throw cms::Exception("HGCTriggerUnexpected") - << "Trying to access a non-existing cluster. But it should exist...\n"; - } - break; - } - } - if(createNewC2d){ - clustersTmp.emplace_back(tc_ptr); - clustersTmp.back().setValid(true); - // map TC id to the cluster index (size - 1) - cluNNmap.emplace(tc_ptr->detId(), clustersTmp.size()-1); + // Check if the neighbors of that TC are already included in a cluster + // If this is the case, add the TC to the first (arbitrary) neighbor cluster + // Otherwise create a new cluster + bool createNewC2d(true); + const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell(tc_ptr->detId()); + for (const auto neighbor : neighbors) { + auto tc_cluster_itr = cluNNmap.find(neighbor); + if (tc_cluster_itr != cluNNmap.end()) { + createNewC2d = false; + if (tc_cluster_itr->second < clustersTmp.size()) { + clustersTmp.at(tc_cluster_itr->second).addConstituent(tc_ptr); + // map TC id to the existing cluster + cluNNmap.emplace(tc_ptr->detId(), tc_cluster_itr->second); + } else { + throw cms::Exception("HGCTriggerUnexpected") + << "Trying to access a non-existing cluster. But it should exist...\n"; } + break; + } } - - /* declaring the vector with possible clusters merged */ - // Merge neighbor clusters together - for( auto& cluster1 : clustersTmp){ - // If the cluster has been merged into another one, skip it - if( !cluster1.valid() ) continue; - // Fill a set containing all TC included in the clusters - // as well as all neighbor TC - std::unordered_set cluTcSet; - for(const auto& tc_clu1 : cluster1.constituents()){ - cluTcSet.insert( tc_clu1.second->detId() ); - const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell( tc_clu1.second->detId() ); - for(const auto neighbor : neighbors){ - cluTcSet.insert( neighbor ); - } - } - - for( auto& cluster2 : clustersTmp ){ - // If the cluster has been merged into another one, skip it - if( cluster1.detId()==cluster2.detId() ) continue; - if( !cluster2.valid() ) continue; - // Check if the TC in clu2 are in clu1 or its neighbors - // If yes, merge the second cluster into the first one - for(const auto& tc_clu2 : cluster2.constituents()){ - if( cluTcSet.find(tc_clu2.second->detId())!=cluTcSet.end() ){ - mergeClusters( cluster1, cluster2 ); - cluTcSet.insert( tc_clu2.second->detId() ); - const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell( tc_clu2.second->detId() ); - for(const auto neighbor : neighbors){ - cluTcSet.insert( neighbor ); - } - cluster2.setValid(false); - break; - } - } - } + if (createNewC2d) { + clustersTmp.emplace_back(tc_ptr); + clustersTmp.back().setValid(true); + // map TC id to the cluster index (size - 1) + cluNNmap.emplace(tc_ptr->detId(), clustersTmp.size() - 1); + } + } + + /* declaring the vector with possible clusters merged */ + // Merge neighbor clusters together + for (auto& cluster1 : clustersTmp) { + // If the cluster has been merged into another one, skip it + if (!cluster1.valid()) + continue; + // Fill a set containing all TC included in the clusters + // as well as all neighbor TC + std::unordered_set cluTcSet; + for (const auto& tc_clu1 : cluster1.constituents()) { + cluTcSet.insert(tc_clu1.second->detId()); + const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell(tc_clu1.second->detId()); + for (const auto neighbor : neighbors) { + cluTcSet.insert(neighbor); + } } - /* store clusters in the persistent collection */ - // only if the cluster contain a TC above the seed threshold - for( auto& cluster : clustersTmp ){ - if( !cluster.valid() ) continue; - bool saveInCollection(false); - for( const auto& id_tc : cluster.constituents() ){ - /* threshold in transverse-mip */ - double seedThreshold = (id_tc.second->subdetId()==HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); - if( id_tc.second->mipPt() > seedThreshold ){ - saveInCollection = true; - break; - } - } - if(saveInCollection){ - calibratePt(cluster); - clusters.push_back( 0, cluster ); + for (auto& cluster2 : clustersTmp) { + // If the cluster has been merged into another one, skip it + if (cluster1.detId() == cluster2.detId()) + continue; + if (!cluster2.valid()) + continue; + // Check if the TC in clu2 are in clu1 or its neighbors + // If yes, merge the second cluster into the first one + for (const auto& tc_clu2 : cluster2.constituents()) { + if (cluTcSet.find(tc_clu2.second->detId()) != cluTcSet.end()) { + mergeClusters(cluster1, cluster2); + cluTcSet.insert(tc_clu2.second->detId()); + const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell(tc_clu2.second->detId()); + for (const auto neighbor : neighbors) { + cluTcSet.insert(neighbor); + } + cluster2.setValid(false); + break; } + } } -} - - -void HGCalClusteringImpl::clusterizeNN( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ){ - - std::array< std::vector< std::vector>>,kNSides_> reshuffledTriggerCells; - unsigned layers = triggerTools_.layers(ForwardSubdetector::ForwardEmpty); - for(unsigned side=0; sidesubdetId() == HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); + if (id_tc.second->mipPt() > seedThreshold) { + saveInCollection = true; + break; + } } - triggerCellReshuffling( triggerCellsPtrs, reshuffledTriggerCells ); - - for(unsigned iec=0; iec>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry) { + std::array>>, kNSides_> reshuffledTriggerCells; + unsigned layers = triggerTools_.layers(ForwardSubdetector::ForwardEmpty); + for (unsigned side = 0; side < kNSides_; side++) { + reshuffledTriggerCells[side].resize(layers); + } + triggerCellReshuffling(triggerCellsPtrs, reshuffledTriggerCells); + + for (unsigned iec = 0; iec < kNSides_; ++iec) { + for (unsigned il = 0; il < layers; ++il) { + NNKernel(reshuffledTriggerCells[iec][il], clusters, triggerGeometry); + } + } +} /*** FW-algorithms ***/ -void HGCalClusteringImpl::clusterizeDRNN( const std::vector> & triggerCellsPtrs, - l1t::HGCalClusterBxCollection & clusters, - const HGCalTriggerGeometryBase & triggerGeometry - ){ - - bool isSeed[triggerCellsPtrs.size()]; - std::vector seedPositions; - seedPositions.reserve( triggerCellsPtrs.size() ); - - /* search for cluster seeds */ - int itc(0); - for( std::vector>::const_iterator tc = triggerCellsPtrs.begin(); tc != triggerCellsPtrs.end(); ++tc,++itc ){ - - double seedThreshold = ((*tc)->subdetId()==HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); - - /* decide if is a seed, if yes store the position into of triggerCellsPtrs */ - isSeed[itc] = ( (*tc)->mipPt() > seedThreshold) ? true : false; - if( isSeed[itc] ) { - - seedPositions.push_back( itc ); - - /* remove tc from the seed vector if is a NN of an other seed*/ - for( auto pos : seedPositions ){ - if( ( (*tc)->position() - triggerCellsPtrs[pos]->position() ).mag() < dr_ ){ - if( this->areTCneighbour( (*tc)->detId(), triggerCellsPtrs[pos]->detId(), triggerGeometry ) ) - { - isSeed[itc] = false; - seedPositions.pop_back(); - } - } - } +void HGCalClusteringImpl::clusterizeDRNN(const std::vector>& triggerCellsPtrs, + l1t::HGCalClusterBxCollection& clusters, + const HGCalTriggerGeometryBase& triggerGeometry) { + bool isSeed[triggerCellsPtrs.size()]; + std::vector seedPositions; + seedPositions.reserve(triggerCellsPtrs.size()); + + /* search for cluster seeds */ + int itc(0); + for (std::vector>::const_iterator tc = triggerCellsPtrs.begin(); + tc != triggerCellsPtrs.end(); + ++tc, ++itc) { + double seedThreshold = ((*tc)->subdetId() == HGCHEB ? scintillatorSeedThreshold_ : siliconSeedThreshold_); + + /* decide if is a seed, if yes store the position into of triggerCellsPtrs */ + isSeed[itc] = ((*tc)->mipPt() > seedThreshold) ? true : false; + if (isSeed[itc]) { + seedPositions.push_back(itc); + + /* remove tc from the seed vector if is a NN of an other seed*/ + for (auto pos : seedPositions) { + if (((*tc)->position() - triggerCellsPtrs[pos]->position()).mag() < dr_) { + if (this->areTCneighbour((*tc)->detId(), triggerCellsPtrs[pos]->detId(), triggerGeometry)) { + isSeed[itc] = false; + seedPositions.pop_back(); + } } - - } - - /* clustering the TCs */ - std::vector clustersTmp; - - // every seed generates a cluster - for( auto pos : seedPositions ) { - clustersTmp.emplace_back( triggerCellsPtrs[pos] ); + } } - - /* add the tc to the clusters */ - itc=0; - for( std::vector>::const_iterator tc = triggerCellsPtrs.begin(); tc != triggerCellsPtrs.end(); ++tc,++itc ){ - - /* get the correct threshold for the different part of the detector */ - double threshold = ((*tc)->subdetId()==HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); - - /* continue if not passing the threshold */ - if( (*tc)->mipPt() < threshold ) continue; - if( isSeed[itc] ) continue; //No sharing of seeds between clusters (TBC) - - /* searching for TC near the centre of the cluster */ - std::vector tcPertinentClusters; - unsigned iclu(0); - - for ( const auto& clu : clustersTmp ) { - if( this->isPertinent(**tc, clu, dr_) ){ - tcPertinentClusters.push_back( iclu ); - } - ++iclu; - } - - if ( tcPertinentClusters.empty() ) { - continue; - } - else if( tcPertinentClusters.size() == 1 ) { - clustersTmp.at( tcPertinentClusters.at(0) ).addConstituent( *tc ); - } - else { - - /* calculate the fractions */ - double totMipt = 0; - for( auto clu : tcPertinentClusters ){ - totMipt += clustersTmp.at( clu ).seedMipPt(); - } - - for( auto clu : tcPertinentClusters ){ - double seedMipt = clustersTmp.at( clu ).seedMipPt(); - clustersTmp.at( clu ).addConstituent( *tc, true, seedMipt/totMipt ); - } - } + } + + /* clustering the TCs */ + std::vector clustersTmp; + + // every seed generates a cluster + for (auto pos : seedPositions) { + clustersTmp.emplace_back(triggerCellsPtrs[pos]); + } + + /* add the tc to the clusters */ + itc = 0; + for (std::vector>::const_iterator tc = triggerCellsPtrs.begin(); + tc != triggerCellsPtrs.end(); + ++tc, ++itc) { + /* get the correct threshold for the different part of the detector */ + double threshold = ((*tc)->subdetId() == HGCHEB ? scintillatorTriggerCellThreshold_ : siliconTriggerCellThreshold_); + + /* continue if not passing the threshold */ + if ((*tc)->mipPt() < threshold) + continue; + if (isSeed[itc]) + continue; //No sharing of seeds between clusters (TBC) + + /* searching for TC near the centre of the cluster */ + std::vector tcPertinentClusters; + unsigned iclu(0); + + for (const auto& clu : clustersTmp) { + if (this->isPertinent(**tc, clu, dr_)) { + tcPertinentClusters.push_back(iclu); + } + ++iclu; } - /* store clusters in the persistent collection */ - clusters.resize(0, clustersTmp.size()); - for( unsigned i(0); iremoveUnconnectedTCinCluster( clustersTmp.at(i), triggerGeometry ); - calibratePt( clustersTmp.at(i) ); - clusters.set( 0, i, clustersTmp.at(i) ); + if (tcPertinentClusters.empty()) { + continue; + } else if (tcPertinentClusters.size() == 1) { + clustersTmp.at(tcPertinentClusters.at(0)).addConstituent(*tc); + } else { + /* calculate the fractions */ + double totMipt = 0; + for (auto clu : tcPertinentClusters) { + totMipt += clustersTmp.at(clu).seedMipPt(); + } + + for (auto clu : tcPertinentClusters) { + double seedMipt = clustersTmp.at(clu).seedMipPt(); + clustersTmp.at(clu).addConstituent(*tc, true, seedMipt / totMipt); + } } - + } + + /* store clusters in the persistent collection */ + clusters.resize(0, clustersTmp.size()); + for (unsigned i(0); i < clustersTmp.size(); ++i) { + this->removeUnconnectedTCinCluster(clustersTmp.at(i), triggerGeometry); + calibratePt(clustersTmp.at(i)); + clusters.set(0, i, clustersTmp.at(i)); + } } +bool HGCalClusteringImpl::areTCneighbour(uint32_t detIDa, + uint32_t detIDb, + const HGCalTriggerGeometryBase& triggerGeometry) { + const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell(detIDa); -bool HGCalClusteringImpl::areTCneighbour(uint32_t detIDa, uint32_t detIDb, const HGCalTriggerGeometryBase & triggerGeometry - ){ + if (neighbors.find(detIDb) != neighbors.end()) + return true; - const auto neighbors = triggerGeometry.getNeighborsFromTriggerCell( detIDa ); - - if( neighbors.find( detIDb ) != neighbors.end() ) return true; - - return false; - + return false; } - -void HGCalClusteringImpl::removeUnconnectedTCinCluster( l1t::HGCalCluster & cluster, const HGCalTriggerGeometryBase & triggerGeometry ) { - - /* get the constituents and the centre of the seed tc (considered as the first of the constituents) */ - const std::unordered_map>& constituents = cluster.constituents(); - Basic3DVector seedCentre( constituents.at(cluster.detId())->position() ); - - /* distances from the seed */ - vector,float>> distances; - for( const auto & id_tc : constituents ) - { - Basic3DVector tcCentre( id_tc.second->position() ); - float distance = ( seedCentre - tcCentre ).mag(); - distances.push_back( pair,float>( id_tc.second, distance ) ); - } - - /* sorting (needed in order to be sure that we are skipping any tc) */ - /* FIXME: better sorting needed!!! */ - std::sort( distances.begin(), distances.end(), distanceSorter ); - - - /* checking if the tc is connected to the seed */ - bool toRemove[constituents.size()]; - toRemove[0] = false; // this is the seed - for( unsigned itc=1; itc& tcToStudy = distances[itc].first; - - /* compare with the tc in the cluster */ - for( unsigned itc_ref=0; itc_refdetId(), distances.at( itc_ref ).first->detId(), triggerGeometry ) ) { - toRemove[itc] = false; - break; - } - } +void HGCalClusteringImpl::removeUnconnectedTCinCluster(l1t::HGCalCluster& cluster, + const HGCalTriggerGeometryBase& triggerGeometry) { + /* get the constituents and the centre of the seed tc (considered as the first of the constituents) */ + const std::unordered_map>& constituents = cluster.constituents(); + Basic3DVector seedCentre(constituents.at(cluster.detId())->position()); + + /* distances from the seed */ + vector, float>> distances; + for (const auto& id_tc : constituents) { + Basic3DVector tcCentre(id_tc.second->position()); + float distance = (seedCentre - tcCentre).mag(); + distances.push_back(pair, float>(id_tc.second, distance)); + } + + /* sorting (needed in order to be sure that we are skipping any tc) */ + /* FIXME: better sorting needed!!! */ + std::sort(distances.begin(), distances.end(), distanceSorter); + + /* checking if the tc is connected to the seed */ + bool toRemove[constituents.size()]; + toRemove[0] = false; // this is the seed + for (unsigned itc = 1; itc < distances.size(); itc++) { + /* get the tc under study */ + toRemove[itc] = true; + const edm::Ptr& tcToStudy = distances[itc].first; + + /* compare with the tc in the cluster */ + for (unsigned itc_ref = 0; itc_ref < itc; itc_ref++) { + if (!toRemove[itc_ref]) { + if (areTCneighbour(tcToStudy->detId(), distances.at(itc_ref).first->detId(), triggerGeometry)) { + toRemove[itc] = false; + break; } - + } } + } - - /* remove the unconnected TCs */ - for( unsigned i=0; i("dR_multicluster")), - dr_byLayer_coefficientA_(conf.existsAs>("dR_multicluster_byLayer_coefficientA") ? conf.getParameter>("dR_multicluster_byLayer_coefficientA") : std::vector()), - dr_byLayer_coefficientB_(conf.existsAs>("dR_multicluster_byLayer_coefficientB") ? conf.getParameter>("dR_multicluster_byLayer_coefficientB") : std::vector()), - ptC3dThreshold_(conf.getParameter("minPt_multicluster")), - cluster_association_input_(conf.getParameter("cluster_association")) -{ - - if(cluster_association_input_=="NearestNeighbour"){ - cluster_association_strategy_ = NearestNeighbour; - }else if(cluster_association_input_=="EnergySplit"){ - cluster_association_strategy_ = EnergySplit; - }else { - throw cms::Exception("HGCTriggerParameterError") +HGCalHistoClusteringImpl::HGCalHistoClusteringImpl(const edm::ParameterSet& conf) + : dr_(conf.getParameter("dR_multicluster")), + dr_byLayer_coefficientA_(conf.existsAs>("dR_multicluster_byLayer_coefficientA") + ? conf.getParameter>("dR_multicluster_byLayer_coefficientA") + : std::vector()), + dr_byLayer_coefficientB_(conf.existsAs>("dR_multicluster_byLayer_coefficientB") + ? conf.getParameter>("dR_multicluster_byLayer_coefficientB") + : std::vector()), + ptC3dThreshold_(conf.getParameter("minPt_multicluster")), + cluster_association_input_(conf.getParameter("cluster_association")) { + if (cluster_association_input_ == "NearestNeighbour") { + cluster_association_strategy_ = NearestNeighbour; + } else if (cluster_association_input_ == "EnergySplit") { + cluster_association_strategy_ = EnergySplit; + } else { + throw cms::Exception("HGCTriggerParameterError") << "Unknown cluster association strategy'" << cluster_association_strategy_; - } + } - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR: " << dr_ - <<"\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_ ; - - id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; - id_->initialize(conf.getParameter("EGIdentification")); + edm::LogInfo("HGCalMulticlusterParameters") + << "Multicluster dR: " << dr_ << "\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_; + id_ = std::unique_ptr{ + HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")}; + id_->initialize(conf.getParameter("EGIdentification")); } - - -float HGCalHistoClusteringImpl::dR( const l1t::HGCalCluster & clu, - const GlobalPoint & seed) const -{ - - Basic3DVector seed_3dv( seed ); - GlobalPoint seed_proj( seed_3dv / seed.z() ); - return (seed_proj - clu.centreProj() ).mag(); - +float HGCalHistoClusteringImpl::dR(const l1t::HGCalCluster& clu, const GlobalPoint& seed) const { + Basic3DVector seed_3dv(seed); + GlobalPoint seed_proj(seed_3dv / seed.z()); + return (seed_proj - clu.centreProj()).mag(); } +std::vector HGCalHistoClusteringImpl::clusterSeedMulticluster( + const std::vector>& clustersPtrs, + const std::vector>& seeds) const { + std::map mapSeedMulticluster; + std::vector multiclustersTmp; + for (const auto& clu : clustersPtrs) { + int z_side = triggerTools_.zside(clu->detId()); -std::vector HGCalHistoClusteringImpl::clusterSeedMulticluster(const std::vector> & clustersPtrs, - const std::vector > & seeds) const -{ - - std::map mapSeedMulticluster; - std::vector multiclustersTmp; - - for(const auto& clu : clustersPtrs){ - - int z_side = triggerTools_.zside(clu->detId()); + double radiusCoefficientA = + dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_[triggerTools_.layerWithOffset(clu->detId())]; + double radiusCoefficientB = + dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_[triggerTools_.layerWithOffset(clu->detId())]; + double minDist = radiusCoefficientA + radiusCoefficientB * (kMidRadius_ - std::abs(clu->eta())); - double radiusCoefficientA = dr_byLayer_coefficientA_.empty() ? dr_ : dr_byLayer_coefficientA_[triggerTools_.layerWithOffset(clu->detId())]; - double radiusCoefficientB = dr_byLayer_coefficientB_.empty() ? 0 : dr_byLayer_coefficientB_[triggerTools_.layerWithOffset(clu->detId())]; + std::vector> targetSeedsEnergy; - double minDist = radiusCoefficientA + radiusCoefficientB*(kMidRadius_ - std::abs(clu->eta()) ) ; + for (unsigned int iseed = 0; iseed < seeds.size(); iseed++) { + GlobalPoint seedPosition = seeds[iseed].first; + double seedEnergy = seeds[iseed].second; - std::vector > targetSeedsEnergy; - - for( unsigned int iseed=0; iseeddR(*clu, seeds[iseed].first); - GlobalPoint seedPosition = seeds[iseed].first; - double seedEnergy = seeds[iseed].second; + if (d < minDist) { + if (cluster_association_strategy_ == EnergySplit) { + targetSeedsEnergy.emplace_back(iseed, seedEnergy); + } else if (cluster_association_strategy_ == NearestNeighbour) { + minDist = d; - if( z_side*seedPosition.z()<0) continue; - double d = this->dR(*clu, seeds[iseed].first); - - if ( d < minDist ){ - if ( cluster_association_strategy_ == EnergySplit ){ - targetSeedsEnergy.emplace_back( iseed, seedEnergy ); - } - else if ( cluster_association_strategy_ == NearestNeighbour ){ - - minDist = d; - - if ( targetSeedsEnergy.empty() ) { - targetSeedsEnergy.emplace_back( iseed, seedEnergy ); - } - else { - targetSeedsEnergy.at(0).first = iseed ; - targetSeedsEnergy.at(0).second = seedEnergy; - } - } - - } - - } - - if(targetSeedsEnergy.empty()) continue; - //Loop over target seeds and divide up the clusters energy - double totalTargetSeedEnergy = 0; - for (const auto& energy: targetSeedsEnergy){ - totalTargetSeedEnergy+=energy.second; + if (targetSeedsEnergy.empty()) { + targetSeedsEnergy.emplace_back(iseed, seedEnergy); + } else { + targetSeedsEnergy.at(0).first = iseed; + targetSeedsEnergy.at(0).second = seedEnergy; + } } - - for (const auto& energy: targetSeedsEnergy){ - - double seedWeight = 1; - if ( cluster_association_strategy_ == EnergySplit) seedWeight = energy.second/totalTargetSeedEnergy; - if( mapSeedMulticluster[energy.first].size()==0) { - mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight) ; - } - else{ - mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); - } - - } - + } } + if (targetSeedsEnergy.empty()) + continue; + //Loop over target seeds and divide up the clusters energy + double totalTargetSeedEnergy = 0; + for (const auto& energy : targetSeedsEnergy) { + totalTargetSeedEnergy += energy.second; + } - for(const auto& mclu : mapSeedMulticluster) multiclustersTmp.emplace_back(mclu.second); + for (const auto& energy : targetSeedsEnergy) { + double seedWeight = 1; + if (cluster_association_strategy_ == EnergySplit) + seedWeight = energy.second / totalTargetSeedEnergy; + if (mapSeedMulticluster[energy.first].size() == 0) { + mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight); + } else { + mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight); + } + } + } - return multiclustersTmp; + for (const auto& mclu : mapSeedMulticluster) + multiclustersTmp.emplace_back(mclu.second); + return multiclustersTmp; } - - - -void HGCalHistoClusteringImpl::clusterizeHisto( const std::vector> & clustersPtrs, - const std::vector > & seedPositionsEnergy, - const HGCalTriggerGeometryBase & triggerGeometry, - l1t::HGCalMulticlusterBxCollection & multiclusters) const -{ - - - /* clusterize clusters around seeds */ - std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs,seedPositionsEnergy); - /* making the collection of multiclusters */ - finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); - +void HGCalHistoClusteringImpl::clusterizeHisto(const std::vector>& clustersPtrs, + const std::vector>& seedPositionsEnergy, + const HGCalTriggerGeometryBase& triggerGeometry, + l1t::HGCalMulticlusterBxCollection& multiclusters) const { + /* clusterize clusters around seeds */ + std::vector multiclustersTmp = clusterSeedMulticluster(clustersPtrs, seedPositionsEnergy); + /* making the collection of multiclusters */ + finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); } - - - - -void -HGCalHistoClusteringImpl:: -finalizeClusters(std::vector& multiclusters_in, - l1t::HGCalMulticlusterBxCollection& multiclusters_out, - const HGCalTriggerGeometryBase& triggerGeometry) const -{ - for(auto& multicluster : multiclusters_in) { - // compute the eta, phi from its barycenter - // + pT as scalar sum of pT of constituents - double sumPt=multicluster.sumPt(); - - math::PtEtaPhiMLorentzVector multiclusterP4( sumPt, - multicluster.centre().eta(), - multicluster.centre().phi(), - 0. ); - multicluster.setP4( multiclusterP4 ); - - if( multicluster.pt() > ptC3dThreshold_ ){ - //compute shower shapes - shape_.fillShapes(multicluster, triggerGeometry); - // fill quality flag - multicluster.setHwQual(id_->decision(multicluster)); - // fill H/E - multicluster.saveHOverE(); - - multiclusters_out.push_back( 0, multicluster); - } +void HGCalHistoClusteringImpl::finalizeClusters(std::vector& multiclusters_in, + l1t::HGCalMulticlusterBxCollection& multiclusters_out, + const HGCalTriggerGeometryBase& triggerGeometry) const { + for (auto& multicluster : multiclusters_in) { + // compute the eta, phi from its barycenter + // + pT as scalar sum of pT of constituents + double sumPt = multicluster.sumPt(); + + math::PtEtaPhiMLorentzVector multiclusterP4(sumPt, multicluster.centre().eta(), multicluster.centre().phi(), 0.); + multicluster.setP4(multiclusterP4); + + if (multicluster.pt() > ptC3dThreshold_) { + //compute shower shapes + shape_.fillShapes(multicluster, triggerGeometry); + // fill quality flag + multicluster.setHwQual(id_->decision(multicluster)); + // fill H/E + multicluster.saveHOverE(); + + multiclusters_out.push_back(0, multicluster); } + } } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index ef36f350fb132..ac79cb7479494 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -3,460 +3,382 @@ #include "DataFormats/Math/interface/deltaR.h" #include "DataFormats/Math/interface/deltaPhi.h" -HGCalHistoSeedingImpl::HGCalHistoSeedingImpl( const edm::ParameterSet& conf ) : - seedingAlgoType_(conf.getParameter("type_multicluster")), - nBinsRHisto_(conf.getParameter("nBins_R_histo_multicluster")), - nBinsPhiHisto_(conf.getParameter("nBins_Phi_histo_multicluster")), - binsSumsHisto_(conf.getParameter< std::vector >("binSumsHisto")), - histoThreshold_(conf.getParameter("threshold_histo_multicluster")), - neighbour_weights_(conf.getParameter< std::vector >("neighbour_weights")) -{ - - if(seedingAlgoType_=="HistoMaxC3d"){ - seedingType_ = HistoMaxC3d; - }else if(seedingAlgoType_=="HistoSecondaryMaxC3d"){ - seedingType_ = HistoSecondaryMaxC3d; - }else if(seedingAlgoType_=="HistoThresholdC3d"){ - seedingType_ = HistoThresholdC3d; - }else if(seedingAlgoType_=="HistoInterpolatedMaxC3d"){ - seedingType_ = HistoInterpolatedMaxC3d; - }else { - throw cms::Exception("HGCTriggerParameterError") - << "Unknown Multiclustering type '" << seedingAlgoType_; - } - - edm::LogInfo("HGCalMulticlusterParameters") <<"\nMulticluster number of R-bins for the histo algorithm: " << nBinsRHisto_ - <<"\nMulticluster number of Phi-bins for the histo algorithm: " << nBinsPhiHisto_ - <<"\nMulticluster MIPT threshold for histo threshold algorithm: " << histoThreshold_ - <<"\nMulticluster type of multiclustering algortihm: " << seedingAlgoType_; - - if(seedingAlgoType_.find("Histo")!=std::string::npos && nBinsRHisto_!=binsSumsHisto_.size()){ - throw cms::Exception("Inconsistent bin size") << "Inconsistent nBins_R_histo_multicluster ( " << nBinsRHisto_ << " ) and binSumsHisto ( " << binsSumsHisto_.size() << " ) size in HGCalMulticlustering\n"; - } - - if(neighbour_weights_.size()!=neighbour_weights_size_) { - throw cms::Exception("Inconsistent vector size" ) << "Inconsistent size of neighbour weights vector in HGCalMulticlustering ( " << neighbour_weights_.size() << " ). Should be " << neighbour_weights_size_ << "\n" ; - } - +HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) + : seedingAlgoType_(conf.getParameter("type_multicluster")), + nBinsRHisto_(conf.getParameter("nBins_R_histo_multicluster")), + nBinsPhiHisto_(conf.getParameter("nBins_Phi_histo_multicluster")), + binsSumsHisto_(conf.getParameter>("binSumsHisto")), + histoThreshold_(conf.getParameter("threshold_histo_multicluster")), + neighbour_weights_(conf.getParameter>("neighbour_weights")) { + if (seedingAlgoType_ == "HistoMaxC3d") { + seedingType_ = HistoMaxC3d; + } else if (seedingAlgoType_ == "HistoSecondaryMaxC3d") { + seedingType_ = HistoSecondaryMaxC3d; + } else if (seedingAlgoType_ == "HistoThresholdC3d") { + seedingType_ = HistoThresholdC3d; + } else if (seedingAlgoType_ == "HistoInterpolatedMaxC3d") { + seedingType_ = HistoInterpolatedMaxC3d; + } else { + throw cms::Exception("HGCTriggerParameterError") << "Unknown Multiclustering type '" << seedingAlgoType_; + } + + edm::LogInfo("HGCalMulticlusterParameters") + << "\nMulticluster number of R-bins for the histo algorithm: " << nBinsRHisto_ + << "\nMulticluster number of Phi-bins for the histo algorithm: " << nBinsPhiHisto_ + << "\nMulticluster MIPT threshold for histo threshold algorithm: " << histoThreshold_ + << "\nMulticluster type of multiclustering algortihm: " << seedingAlgoType_; + + if (seedingAlgoType_.find("Histo") != std::string::npos && nBinsRHisto_ != binsSumsHisto_.size()) { + throw cms::Exception("Inconsistent bin size") + << "Inconsistent nBins_R_histo_multicluster ( " << nBinsRHisto_ << " ) and binSumsHisto ( " + << binsSumsHisto_.size() << " ) size in HGCalMulticlustering\n"; + } + + if (neighbour_weights_.size() != neighbour_weights_size_) { + throw cms::Exception("Inconsistent vector size") + << "Inconsistent size of neighbour weights vector in HGCalMulticlustering ( " << neighbour_weights_.size() + << " ). Should be " << neighbour_weights_size_ << "\n"; + } } +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillHistoClusters( + const std::vector>& clustersPtrs) { + Histogram histoClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi -HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillHistoClusters( const std::vector> & clustersPtrs ){ - - - Histogram histoClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_RcentreProj().x(), 2) + pow(clu->centreProj().y(), 2)); + int bin_R = int((ROverZ - kROverZMin_) * nBinsRHisto_ / (kROverZMax_ - kROverZMin_)); + int bin_phi = int((reco::reduceRange(clu->phi()) + M_PI) * nBinsPhiHisto_ / (2 * M_PI)); - for(auto & clu : clustersPtrs){ - - float ROverZ = sqrt( pow(clu->centreProj().x(),2) + pow(clu->centreProj().y(),2) ); - int bin_R = int( (ROverZ-kROverZMin_) * nBinsRHisto_ / (kROverZMax_-kROverZMin_) ); - int bin_phi = int( (reco::reduceRange(clu->phi())+M_PI) * nBinsPhiHisto_ / (2*M_PI) ); - - histoClusters[{{triggerTools_.zside(clu->detId()), bin_R, bin_phi}}]+=clu->mipPt(); - - } - - return histoClusters; + histoClusters[{{triggerTools_.zside(clu->detId()), bin_R, bin_phi}}] += clu->mipPt(); + } + return histoClusters; } - - - -HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoClusters( const Histogram & histoClusters, - const vector & binSums ){ - - Histogram histoSumPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R=int(nBinsPhiHisto_) ) binToSumRight -= nBinsPhiHisto_; - - content += histoClusters.at({{z_side,bin_R,binToSumLeft}}) / pow(2,bin_phi2); // quadratic kernel - content += histoClusters.at({{z_side,bin_R,binToSumRight}}) / pow(2,bin_phi2); // quadratic kernel - - } - - histoSumPhiClusters[{{z_side,bin_R,bin_phi}}] = content/area; - - } - +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoClusters(const Histogram& histoClusters, + const vector& binSums) { + Histogram histoSumPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi + + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + int nBinsSide = (binSums[bin_R] - 1) / 2; + float R1 = kROverZMin_ + bin_R * (kROverZMax_ - kROverZMin_); + float R2 = R1 + (kROverZMax_ - kROverZMin_); + double area = + 0.5 * (pow(R2, 2) - pow(R1, 2)) * + (1 + + 0.5 * + (1 - + pow(0.5, + nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float content = histoClusters.at({{z_side, bin_R, bin_phi}}); + + for (int bin_phi2 = 1; bin_phi2 <= nBinsSide; bin_phi2++) { + int binToSumLeft = bin_phi - bin_phi2; + if (binToSumLeft < 0) + binToSumLeft += nBinsPhiHisto_; + int binToSumRight = bin_phi + bin_phi2; + if (binToSumRight >= int(nBinsPhiHisto_)) + binToSumRight -= nBinsPhiHisto_; + + content += histoClusters.at({{z_side, bin_R, binToSumLeft}}) / pow(2, bin_phi2); // quadratic kernel + content += histoClusters.at({{z_side, bin_R, binToSumRight}}) / pow(2, bin_phi2); // quadratic kernel } + histoSumPhiClusters[{{z_side, bin_R, bin_phi}}] = content / area; + } } + } - return histoSumPhiClusters; - + return histoSumPhiClusters; } +HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothRPhiHistoClusters(const Histogram& histoClusters) { + Histogram histoSumRPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + float weight = (bin_R == 0 || bin_R == int(nBinsRHisto_) - 1) + ? 1.5 + : 2.; //Take into account edges with only one side up or down + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float content = histoClusters.at({{z_side, bin_R, bin_phi}}); + float contentDown = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, bin_phi}}) : 0; + float contentUp = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, bin_phi}}) : 0; - - -HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothRPhiHistoClusters( const Histogram & histoClusters ){ - - Histogram histoSumRPhiClusters; //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0 ; - float contentUp = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; - - histoSumRPhiClusters[{{z_side,bin_R,bin_phi}}] = (content + 0.5*contentDown + 0.5*contentUp)/weight; - - } - - } - + histoSumRPhiClusters[{{z_side, bin_R, bin_phi}}] = (content + 0.5 * contentDown + 0.5 * contentUp) / weight; + } } + } - return histoSumRPhiClusters; - + return histoSumRPhiClusters; } - - - -std::vector > HGCalHistoSeedingImpl::computeMaxSeeds( const Histogram & histoClusters ){ - - std::vector > seedPositionsEnergy; - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R histoThreshold_; - if (!isMax) continue; - - float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; - float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; - - int binLeft = bin_phi - 1; - if( binLeft<0 ) binLeft += nBinsPhiHisto_; - int binRight = bin_phi + 1; - if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; - - float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); - float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); - float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; - float MIPT_NE = bin_R>0 ?histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; - float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; - float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - - isMax &= MIPT_seed>=MIPT_S - && MIPT_seed>MIPT_N - && MIPT_seed>=MIPT_E - && MIPT_seed>=MIPT_SE - && MIPT_seed>=MIPT_NE - && MIPT_seed>MIPT_W - && MIPT_seed>MIPT_SW - && MIPT_seed>MIPT_NW; - - if(isMax){ - - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed); - - } - } - +std::vector> HGCalHistoSeedingImpl::computeMaxSeeds(const Histogram& histoClusters) { + std::vector> seedPositionsEnergy; + + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float MIPT_seed = histoClusters.at({{z_side, bin_R, bin_phi}}); + bool isMax = MIPT_seed > histoThreshold_; + if (!isMax) + continue; + + float MIPT_S = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, bin_phi}}) : 0; + float MIPT_N = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if (binLeft < 0) + binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if (binRight >= int(nBinsPhiHisto_)) + binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side, bin_R, binLeft}}); + float MIPT_E = histoClusters.at({{z_side, bin_R, binRight}}); + float MIPT_NW = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binLeft}}) : 0; + float MIPT_NE = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binRight}}) : 0; + float MIPT_SW = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binLeft}}) : 0; + float MIPT_SE = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binRight}}) : 0; + + isMax &= MIPT_seed >= MIPT_S && MIPT_seed > MIPT_N && MIPT_seed >= MIPT_E && MIPT_seed >= MIPT_SE && + MIPT_seed >= MIPT_NE && MIPT_seed > MIPT_W && MIPT_seed > MIPT_SW && MIPT_seed > MIPT_NW; + + if (isMax) { + float ROverZ_seed = kROverZMin_ + (bin_R + 0.5) * (kROverZMax_ - kROverZMin_) / nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi + 0.5) * 2 * M_PI / nBinsPhiHisto_; + float x_seed = ROverZ_seed * cos(phi_seed); + float y_seed = ROverZ_seed * sin(phi_seed); + seedPositionsEnergy.emplace_back(GlobalPoint(x_seed, y_seed, z_side), MIPT_seed); } - + } } + } - return seedPositionsEnergy; - + return seedPositionsEnergy; } - -std::vector > HGCalHistoSeedingImpl::computeInterpolatedMaxSeeds( const Histogram & histoClusters ){ - - - std::vector > seedPositionsEnergy; - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; - - int binLeft = bin_phi - 1; - if( binLeft<0 ) binLeft += nBinsPhiHisto_; - int binRight = bin_phi + 1; - if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; - - float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); - float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); - - float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; - float MIPT_NE = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; - float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; - float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - - float MIPT_pred = neighbour_weights_.at(0) * MIPT_NW + neighbour_weights_.at(1) * MIPT_N + neighbour_weights_.at(2) * MIPT_NE - + neighbour_weights_.at(3) * MIPT_W + neighbour_weights_.at(5) * MIPT_E + neighbour_weights_.at(6) * MIPT_SW - + neighbour_weights_.at(7) * MIPT_S + neighbour_weights_.at(8) * MIPT_SE; - - bool isMax = MIPT_seed>=(MIPT_pred+histoThreshold_); - - if(isMax){ - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed); - } - - } - +std::vector> HGCalHistoSeedingImpl::computeInterpolatedMaxSeeds( + const Histogram& histoClusters) { + std::vector> seedPositionsEnergy; + + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float MIPT_seed = histoClusters.at({{z_side, bin_R, bin_phi}}); + float MIPT_S = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, bin_phi}}) : 0; + float MIPT_N = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if (binLeft < 0) + binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if (binRight >= int(nBinsPhiHisto_)) + binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side, bin_R, binLeft}}); + float MIPT_E = histoClusters.at({{z_side, bin_R, binRight}}); + + float MIPT_NW = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binLeft}}) : 0; + float MIPT_NE = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binRight}}) : 0; + float MIPT_SW = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binLeft}}) : 0; + float MIPT_SE = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binRight}}) : 0; + + float MIPT_pred = neighbour_weights_.at(0) * MIPT_NW + neighbour_weights_.at(1) * MIPT_N + + neighbour_weights_.at(2) * MIPT_NE + neighbour_weights_.at(3) * MIPT_W + + neighbour_weights_.at(5) * MIPT_E + neighbour_weights_.at(6) * MIPT_SW + + neighbour_weights_.at(7) * MIPT_S + neighbour_weights_.at(8) * MIPT_SE; + + bool isMax = MIPT_seed >= (MIPT_pred + histoThreshold_); + + if (isMax) { + float ROverZ_seed = kROverZMin_ + (bin_R + 0.5) * (kROverZMax_ - kROverZMin_) / nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi + 0.5) * 2 * M_PI / nBinsPhiHisto_; + float x_seed = ROverZ_seed * cos(phi_seed); + float y_seed = ROverZ_seed * sin(phi_seed); + seedPositionsEnergy.emplace_back(GlobalPoint(x_seed, y_seed, z_side), MIPT_seed); } - + } } - - return seedPositionsEnergy; - -} - - -std::vector > HGCalHistoSeedingImpl::computeThresholdSeeds( const Histogram & histoClusters ){ - - - std::vector > seedPositionsEnergy; - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R histoThreshold_; - - if(isSeed){ - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed) ; - } + } - } + return seedPositionsEnergy; +} +std::vector> HGCalHistoSeedingImpl::computeThresholdSeeds( + const Histogram& histoClusters) { + std::vector> seedPositionsEnergy; + + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float MIPT_seed = histoClusters.at({{z_side, bin_R, bin_phi}}); + bool isSeed = MIPT_seed > histoThreshold_; + + if (isSeed) { + float ROverZ_seed = kROverZMin_ + (bin_R + 0.5) * (kROverZMax_ - kROverZMin_) / nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi + 0.5) * 2 * M_PI / nBinsPhiHisto_; + float x_seed = ROverZ_seed * cos(phi_seed); + float y_seed = ROverZ_seed * sin(phi_seed); + seedPositionsEnergy.emplace_back(GlobalPoint(x_seed, y_seed, z_side), MIPT_seed); } - + } } + } - return seedPositionsEnergy; - + return seedPositionsEnergy; } - - -std::vector > HGCalHistoSeedingImpl::computeSecondaryMaxSeeds( const Histogram & histoClusters ){ - - std::vector > seedPositionsEnergy; - - std::map, bool> primarySeedPositions; - std::map, bool> secondarySeedPositions; - std::map, bool> vetoPositions; - - //Search for primary seeds - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R histoThreshold_; - - if (!isMax) continue; - - float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; - float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; - - int binLeft = bin_phi - 1; - if( binLeft<0 ) binLeft += nBinsPhiHisto_; - int binRight = bin_phi + 1; - if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; - - float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); - float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); - float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; - float MIPT_NE = bin_R>0 ?histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; - float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; - float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - - isMax &= MIPT_seed>=MIPT_S - && MIPT_seed>MIPT_N - && MIPT_seed>=MIPT_E - && MIPT_seed>=MIPT_SE - && MIPT_seed>=MIPT_NE - && MIPT_seed>MIPT_W - && MIPT_seed>MIPT_SW - && MIPT_seed>MIPT_NW; - - if(isMax){ - - - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - - seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed ); - primarySeedPositions[std::make_tuple(bin_R,bin_phi,z_side)] = true; - - vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] = true; - vetoPositions[std::make_tuple(bin_R,binRight,z_side)] = true; - if ( bin_R>0 ) { - vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] = true; - vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] = true; - vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] = true; - } - if ( bin_R<(int(nBinsRHisto_)-1) ) { - vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] = true; - vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] = true; - vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] = true; - } - - } - - } - +std::vector> HGCalHistoSeedingImpl::computeSecondaryMaxSeeds( + const Histogram& histoClusters) { + std::vector> seedPositionsEnergy; + + std::map, bool> primarySeedPositions; + std::map, bool> secondarySeedPositions; + std::map, bool> vetoPositions; + + //Search for primary seeds + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + float MIPT_seed = histoClusters.at({{z_side, bin_R, bin_phi}}); + bool isMax = MIPT_seed > histoThreshold_; + + if (!isMax) + continue; + + float MIPT_S = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, bin_phi}}) : 0; + float MIPT_N = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if (binLeft < 0) + binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if (binRight >= int(nBinsPhiHisto_)) + binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side, bin_R, binLeft}}); + float MIPT_E = histoClusters.at({{z_side, bin_R, binRight}}); + float MIPT_NW = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binLeft}}) : 0; + float MIPT_NE = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binRight}}) : 0; + float MIPT_SW = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binLeft}}) : 0; + float MIPT_SE = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binRight}}) : 0; + + isMax &= MIPT_seed >= MIPT_S && MIPT_seed > MIPT_N && MIPT_seed >= MIPT_E && MIPT_seed >= MIPT_SE && + MIPT_seed >= MIPT_NE && MIPT_seed > MIPT_W && MIPT_seed > MIPT_SW && MIPT_seed > MIPT_NW; + + if (isMax) { + float ROverZ_seed = kROverZMin_ + (bin_R + 0.5) * (kROverZMax_ - kROverZMin_) / nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi + 0.5) * 2 * M_PI / nBinsPhiHisto_; + float x_seed = ROverZ_seed * cos(phi_seed); + float y_seed = ROverZ_seed * sin(phi_seed); + + seedPositionsEnergy.emplace_back(GlobalPoint(x_seed, y_seed, z_side), MIPT_seed); + primarySeedPositions[std::make_tuple(bin_R, bin_phi, z_side)] = true; + + vetoPositions[std::make_tuple(bin_R, binLeft, z_side)] = true; + vetoPositions[std::make_tuple(bin_R, binRight, z_side)] = true; + if (bin_R > 0) { + vetoPositions[std::make_tuple(bin_R - 1, bin_phi, z_side)] = true; + vetoPositions[std::make_tuple(bin_R - 1, binRight, z_side)] = true; + vetoPositions[std::make_tuple(bin_R - 1, binLeft, z_side)] = true; + } + if (bin_R < (int(nBinsRHisto_) - 1)) { + vetoPositions[std::make_tuple(bin_R + 1, bin_phi, z_side)] = true; + vetoPositions[std::make_tuple(bin_R + 1, binRight, z_side)] = true; + vetoPositions[std::make_tuple(bin_R + 1, binLeft, z_side)] = true; + } } - + } } - - - //Search for secondary seeds - - for(int z_side : {-1,1}){ - - for(int bin_R = 0; bin_R histoThreshold_; - - float MIPT_S = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,bin_phi}}) : 0; - float MIPT_N = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,bin_phi}}) : 0; - - int binLeft = bin_phi - 1; - if( binLeft<0 ) binLeft += nBinsPhiHisto_; - int binRight = bin_phi + 1; - if( binRight>=int(nBinsPhiHisto_) ) binRight -= nBinsPhiHisto_; - - float MIPT_W = histoClusters.at({{z_side,bin_R,binLeft}}); - float MIPT_E = histoClusters.at({{z_side,bin_R,binRight}}); - float MIPT_NW = bin_R>0 ? histoClusters.at({{z_side,bin_R-1,binLeft}}) : 0; - float MIPT_NE = bin_R>0 ?histoClusters.at({{z_side,bin_R-1,binRight}}) : 0; - float MIPT_SW = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binLeft}}) : 0; - float MIPT_SE = bin_R<(int(nBinsRHisto_)-1) ? histoClusters.at({{z_side,bin_R+1,binRight}}) : 0; - - - isMax &= ( vetoPositions[std::make_tuple(bin_R+1,bin_phi,z_side)] or MIPT_seed>=MIPT_S ) - && ( vetoPositions[std::make_tuple(bin_R-1,bin_phi,z_side)] or MIPT_seed>MIPT_N ) - && ( vetoPositions[std::make_tuple(bin_R,binRight,z_side)] or MIPT_seed>=MIPT_E ) - && ( vetoPositions[std::make_tuple(bin_R+1,binRight,z_side)] or MIPT_seed>=MIPT_SE ) - && ( vetoPositions[std::make_tuple(bin_R-1,binRight,z_side)] or MIPT_seed>=MIPT_NE ) - && ( vetoPositions[std::make_tuple(bin_R,binLeft,z_side)] or MIPT_seed>MIPT_W ) - && ( vetoPositions[std::make_tuple(bin_R+1,binLeft,z_side)] or MIPT_seed>MIPT_SW ) - && ( vetoPositions[std::make_tuple(bin_R-1,binLeft,z_side)] or MIPT_seed>MIPT_NW ); - - - - if(isMax){ - float ROverZ_seed = kROverZMin_ + (bin_R+0.5) * (kROverZMax_-kROverZMin_)/nBinsRHisto_; - float phi_seed = -M_PI + (bin_phi+0.5) * 2*M_PI/nBinsPhiHisto_; - float x_seed = ROverZ_seed*cos(phi_seed); - float y_seed = ROverZ_seed*sin(phi_seed); - seedPositionsEnergy.emplace_back( GlobalPoint(x_seed,y_seed,z_side), MIPT_seed ); - secondarySeedPositions[std::make_tuple(bin_R,bin_phi,z_side)] = true; - } - - } - + } + + //Search for secondary seeds + + for (int z_side : {-1, 1}) { + for (int bin_R = 0; bin_R < int(nBinsRHisto_); bin_R++) { + for (int bin_phi = 0; bin_phi < int(nBinsPhiHisto_); bin_phi++) { + //Cannot be a secondary seed if already a primary seed, or adjacent to primary seed + if (primarySeedPositions[std::make_tuple(bin_R, bin_phi, z_side)] || + vetoPositions[std::make_tuple(bin_R, bin_phi, z_side)]) + continue; + + float MIPT_seed = histoClusters.at({{z_side, bin_R, bin_phi}}); + bool isMax = MIPT_seed > histoThreshold_; + + float MIPT_S = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, bin_phi}}) : 0; + float MIPT_N = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, bin_phi}}) : 0; + + int binLeft = bin_phi - 1; + if (binLeft < 0) + binLeft += nBinsPhiHisto_; + int binRight = bin_phi + 1; + if (binRight >= int(nBinsPhiHisto_)) + binRight -= nBinsPhiHisto_; + + float MIPT_W = histoClusters.at({{z_side, bin_R, binLeft}}); + float MIPT_E = histoClusters.at({{z_side, bin_R, binRight}}); + float MIPT_NW = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binLeft}}) : 0; + float MIPT_NE = bin_R > 0 ? histoClusters.at({{z_side, bin_R - 1, binRight}}) : 0; + float MIPT_SW = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binLeft}}) : 0; + float MIPT_SE = bin_R < (int(nBinsRHisto_) - 1) ? histoClusters.at({{z_side, bin_R + 1, binRight}}) : 0; + + isMax &= (vetoPositions[std::make_tuple(bin_R + 1, bin_phi, z_side)] or MIPT_seed >= MIPT_S) && + (vetoPositions[std::make_tuple(bin_R - 1, bin_phi, z_side)] or MIPT_seed > MIPT_N) && + (vetoPositions[std::make_tuple(bin_R, binRight, z_side)] or MIPT_seed >= MIPT_E) && + (vetoPositions[std::make_tuple(bin_R + 1, binRight, z_side)] or MIPT_seed >= MIPT_SE) && + (vetoPositions[std::make_tuple(bin_R - 1, binRight, z_side)] or MIPT_seed >= MIPT_NE) && + (vetoPositions[std::make_tuple(bin_R, binLeft, z_side)] or MIPT_seed > MIPT_W) && + (vetoPositions[std::make_tuple(bin_R + 1, binLeft, z_side)] or MIPT_seed > MIPT_SW) && + (vetoPositions[std::make_tuple(bin_R - 1, binLeft, z_side)] or MIPT_seed > MIPT_NW); + + if (isMax) { + float ROverZ_seed = kROverZMin_ + (bin_R + 0.5) * (kROverZMax_ - kROverZMin_) / nBinsRHisto_; + float phi_seed = -M_PI + (bin_phi + 0.5) * 2 * M_PI / nBinsPhiHisto_; + float x_seed = ROverZ_seed * cos(phi_seed); + float y_seed = ROverZ_seed * sin(phi_seed); + seedPositionsEnergy.emplace_back(GlobalPoint(x_seed, y_seed, z_side), MIPT_seed); + secondarySeedPositions[std::make_tuple(bin_R, bin_phi, z_side)] = true; } - + } } + } - return seedPositionsEnergy; - + return seedPositionsEnergy; } - -void HGCalHistoSeedingImpl::findHistoSeeds( const std::vector> & clustersPtrs, - std::vector > & seedPositionsEnergy) -{ - - /* put clusters into an r/z x phi histogram */ - Histogram histoCluster = fillHistoClusters(clustersPtrs); //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi, content = MIPTs summed along depth - - /* smoothen along the phi direction + normalize each bin to same area */ - Histogram smoothPhiHistoCluster = fillSmoothPhiHistoClusters(histoCluster,binsSumsHisto_); - - /* smoothen along the r/z direction */ - Histogram smoothRPhiHistoCluster = fillSmoothRPhiHistoClusters(histoCluster); - - /* seeds determined with local maximum criteria */ - if (seedingType_ == HistoMaxC3d) seedPositionsEnergy = computeMaxSeeds(smoothRPhiHistoCluster); - else if(seedingType_ == HistoThresholdC3d) seedPositionsEnergy = computeThresholdSeeds(smoothRPhiHistoCluster); - else if(seedingType_ == HistoInterpolatedMaxC3d) seedPositionsEnergy = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); - else if(seedingType_ == HistoSecondaryMaxC3d) seedPositionsEnergy = computeSecondaryMaxSeeds(smoothRPhiHistoCluster); - +void HGCalHistoSeedingImpl::findHistoSeeds(const std::vector>& clustersPtrs, + std::vector>& seedPositionsEnergy) { + /* put clusters into an r/z x phi histogram */ + Histogram histoCluster = fillHistoClusters( + clustersPtrs); //key[0] = z.side(), key[1] = bin_R, key[2] = bin_phi, content = MIPTs summed along depth + + /* smoothen along the phi direction + normalize each bin to same area */ + Histogram smoothPhiHistoCluster = fillSmoothPhiHistoClusters(histoCluster, binsSumsHisto_); + + /* smoothen along the r/z direction */ + Histogram smoothRPhiHistoCluster = fillSmoothRPhiHistoClusters(histoCluster); + + /* seeds determined with local maximum criteria */ + if (seedingType_ == HistoMaxC3d) + seedPositionsEnergy = computeMaxSeeds(smoothRPhiHistoCluster); + else if (seedingType_ == HistoThresholdC3d) + seedPositionsEnergy = computeThresholdSeeds(smoothRPhiHistoCluster); + else if (seedingType_ == HistoInterpolatedMaxC3d) + seedPositionsEnergy = computeInterpolatedMaxSeeds(smoothRPhiHistoCluster); + else if (seedingType_ == HistoSecondaryMaxC3d) + seedPositionsEnergy = computeSecondaryMaxSeeds(smoothRPhiHistoCluster); } - diff --git a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc index c32f8c4f91889..f5649fb810038 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalMulticlusteringImpl.cc @@ -2,201 +2,190 @@ #include "L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h" #include "DataFormats/Math/interface/deltaR.h" - -HGCalMulticlusteringImpl::HGCalMulticlusteringImpl( const edm::ParameterSet& conf ) : - dr_(conf.getParameter("dR_multicluster")), - ptC3dThreshold_(conf.getParameter("minPt_multicluster")), - multiclusterAlgoType_(conf.getParameter("type_multicluster")), - distDbscan_(conf.getParameter("dist_dbscan_multicluster")), - minNDbscan_(conf.getParameter("minN_dbscan_multicluster")) -{ - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR for Near Neighbour search: " << dr_; - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster minimum transverse-momentum: " << ptC3dThreshold_; - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster DBSCAN Clustering distance: " << distDbscan_; - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster clustering min number of subclusters: " << minNDbscan_; - edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster type of multiclustering algortihm: " << multiclusterAlgoType_; - id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; - id_->initialize(conf.getParameter("EGIdentification")); +HGCalMulticlusteringImpl::HGCalMulticlusteringImpl(const edm::ParameterSet& conf) + : dr_(conf.getParameter("dR_multicluster")), + ptC3dThreshold_(conf.getParameter("minPt_multicluster")), + multiclusterAlgoType_(conf.getParameter("type_multicluster")), + distDbscan_(conf.getParameter("dist_dbscan_multicluster")), + minNDbscan_(conf.getParameter("minN_dbscan_multicluster")) { + edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR for Near Neighbour search: " << dr_; + edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster minimum transverse-momentum: " << ptC3dThreshold_; + edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster DBSCAN Clustering distance: " << distDbscan_; + edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster clustering min number of subclusters: " << minNDbscan_; + edm::LogInfo("HGCalMulticlusterParameters") + << "Multicluster type of multiclustering algortihm: " << multiclusterAlgoType_; + id_ = std::unique_ptr{ + HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")}; + id_->initialize(conf.getParameter("EGIdentification")); } +bool HGCalMulticlusteringImpl::isPertinent(const l1t::HGCalCluster& clu, + const l1t::HGCalMulticluster& mclu, + double dR) const { + DetId cluDetId(clu.detId()); + DetId firstClusterDetId(mclu.detId()); -bool HGCalMulticlusteringImpl::isPertinent( const l1t::HGCalCluster & clu, - const l1t::HGCalMulticluster & mclu, - double dR ) const -{ - DetId cluDetId( clu.detId() ); - DetId firstClusterDetId( mclu.detId() ); - - if( triggerTools_.zside(cluDetId) != triggerTools_.zside(firstClusterDetId) ){ - return false; - } - if( ( mclu.centreProj() - clu.centreProj() ).mag() < dR ){ - return true; - } + if (triggerTools_.zside(cluDetId) != triggerTools_.zside(firstClusterDetId)) { return false; - + } + if ((mclu.centreProj() - clu.centreProj()).mag() < dR) { + return true; + } + return false; } - -void HGCalMulticlusteringImpl::findNeighbor( const std::vector>& rankedList, - unsigned int searchInd, - const std::vector>& clustersPtrs, - std::vector& neighbors - ){ - - if(clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()){ - throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); +void HGCalMulticlusteringImpl::findNeighbor(const std::vector>& rankedList, + unsigned int searchInd, + const std::vector>& clustersPtrs, + std::vector& neighbors) { + if (clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()) { + throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); + } + + for (unsigned int ind = searchInd + 1; + ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) < distDbscan_; + ind++) { + if (clustersPtrs.size() <= rankedList.at(ind).first) { + throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); + + } else if (((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - + (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()) + .mag() < distDbscan_) { + neighbors.push_back(ind); } - - for(unsigned int ind = searchInd+1; ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) < distDbscan_ ; ind++){ - - if(clustersPtrs.size() <= rankedList.at(ind).first){ - throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); - - } else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).mag() < distDbscan_){ - neighbors.push_back(ind); - } - } - - for(unsigned int ind = 0; ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) < distDbscan_ ; ind++){ - - if(clustersPtrs.size() <= rankedList.at(ind).first){ - throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); - - } else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).mag() < distDbscan_){ - neighbors.push_back(ind); - } + } + + for (unsigned int ind = 0; + ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) < distDbscan_; + ind++) { + if (clustersPtrs.size() <= rankedList.at(ind).first) { + throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'"); + + } else if (((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - + (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()) + .mag() < distDbscan_) { + neighbors.push_back(ind); } + } } - -void HGCalMulticlusteringImpl::clusterizeDR( const std::vector> & clustersPtrs, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry) -{ - - std::vector multiclustersTmp; - - int iclu = 0; - for(std::vector>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){ - - double minDist = dr_; - int targetMulticlu = -1; - - for(unsigned imclu=0; imcluisPertinent(**clu, multiclustersTmp.at(imclu), dr_)) continue; - - double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).mag() ; - if(d>& clustersPtrs, + l1t::HGCalMulticlusterBxCollection& multiclusters, + const HGCalTriggerGeometryBase& triggerGeometry) { + std::vector multiclustersTmp; + + int iclu = 0; + for (std::vector>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); + ++clu, ++iclu) { + double minDist = dr_; + int targetMulticlu = -1; + + for (unsigned imclu = 0; imclu < multiclustersTmp.size(); imclu++) { + if (!this->isPertinent(**clu, multiclustersTmp.at(imclu), dr_)) + continue; + + double d = (multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj()).mag(); + if (d < minDist) { + minDist = d; + targetMulticlu = int(imclu); + } } - /* making the collection of multiclusters */ - finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); - + if (targetMulticlu < 0) + multiclustersTmp.emplace_back(*clu); + else + multiclustersTmp.at(targetMulticlu).addConstituent(*clu); + } + + /* making the collection of multiclusters */ + finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); } -void HGCalMulticlusteringImpl::clusterizeDBSCAN( const std::vector> & clustersPtrs, - l1t::HGCalMulticlusterBxCollection & multiclusters, - const HGCalTriggerGeometryBase & triggerGeometry) -{ - - std::vector multiclustersTmp; - l1t::HGCalMulticluster mcluTmp; - std::vector visited(clustersPtrs.size(),false); - std::vector merged (clustersPtrs.size(),false); - std::vector> rankedList; - rankedList.reserve(clustersPtrs.size()); - std::vector> neighborList; - neighborList.reserve(clustersPtrs.size()); - - int iclu = 0, imclu = 0, neighNo; - double dist = 0.; - - for(std::vector>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){ - dist = (*clu)->centreProj().mag()*triggerTools_.zside((*clu)->detId()); - rankedList.push_back(std::make_pair(iclu,dist)); - } - iclu = 0; - std::sort(rankedList.begin(), rankedList.end(), [](auto &left, auto &right) { - return left.second < right.second; - }); - - for(const auto& cluRanked: rankedList){ - std::vector neighbors; - - if(!visited.at(iclu)){ - visited.at(iclu) = true; - findNeighbor(rankedList, iclu, clustersPtrs, neighbors); - neighborList.push_back(std::move(neighbors)); - - if(neighborList.at(iclu).size() >= minNDbscan_) { - multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] ); - merged.at(iclu) = true; - /* dynamic range loop: range-based loop syntax cannot be employed */ - for(unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){ - neighNo = neighborList.at(iclu).at(neighInd); - /* This condition also ensures merging of clusters visited by other clusters but not merged. */ - if(!merged.at(neighNo) ){ - merged.at(neighNo) = true; - multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] ); - - if(!visited.at(neighNo)){ - visited.at(neighNo) = true; - std::vector secNeighbors; - findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors); - - if(secNeighbors.size() >= minNDbscan_){ - neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end()); - } - } - } - } - imclu++; +void HGCalMulticlusteringImpl::clusterizeDBSCAN(const std::vector>& clustersPtrs, + l1t::HGCalMulticlusterBxCollection& multiclusters, + const HGCalTriggerGeometryBase& triggerGeometry) { + std::vector multiclustersTmp; + l1t::HGCalMulticluster mcluTmp; + std::vector visited(clustersPtrs.size(), false); + std::vector merged(clustersPtrs.size(), false); + std::vector> rankedList; + rankedList.reserve(clustersPtrs.size()); + std::vector> neighborList; + neighborList.reserve(clustersPtrs.size()); + + int iclu = 0, imclu = 0, neighNo; + double dist = 0.; + + for (std::vector>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); + ++clu, ++iclu) { + dist = (*clu)->centreProj().mag() * triggerTools_.zside((*clu)->detId()); + rankedList.push_back(std::make_pair(iclu, dist)); + } + iclu = 0; + std::sort(rankedList.begin(), rankedList.end(), [](auto& left, auto& right) { return left.second < right.second; }); + + for (const auto& cluRanked : rankedList) { + std::vector neighbors; + + if (!visited.at(iclu)) { + visited.at(iclu) = true; + findNeighbor(rankedList, iclu, clustersPtrs, neighbors); + neighborList.push_back(std::move(neighbors)); + + if (neighborList.at(iclu).size() >= minNDbscan_) { + multiclustersTmp.emplace_back(clustersPtrs[cluRanked.first]); + merged.at(iclu) = true; + /* dynamic range loop: range-based loop syntax cannot be employed */ + for (unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++) { + neighNo = neighborList.at(iclu).at(neighInd); + /* This condition also ensures merging of clusters visited by other clusters but not merged. */ + if (!merged.at(neighNo)) { + merged.at(neighNo) = true; + multiclustersTmp.at(imclu).addConstituent(clustersPtrs[rankedList.at(neighNo).first]); + + if (!visited.at(neighNo)) { + visited.at(neighNo) = true; + std::vector secNeighbors; + findNeighbor(rankedList, neighNo, clustersPtrs, secNeighbors); + + if (secNeighbors.size() >= minNDbscan_) { + neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end()); + } } + } } - else neighborList.push_back(std::move(neighbors)); - iclu++; - } - /* making the collection of multiclusters */ - finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); + imclu++; + } + } else + neighborList.push_back(std::move(neighbors)); + iclu++; + } + /* making the collection of multiclusters */ + finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry); } - -void -HGCalMulticlusteringImpl:: -finalizeClusters(std::vector& multiclusters_in, - l1t::HGCalMulticlusterBxCollection& multiclusters_out, - const HGCalTriggerGeometryBase& triggerGeometry) { - for(auto& multicluster : multiclusters_in) { - // compute the eta, phi from its barycenter - // + pT as scalar sum of pT of constituents - double sumPt=0.; - const std::unordered_map>& clusters = multicluster.constituents(); - for(const auto& id_cluster : clusters) sumPt += id_cluster.second->pt(); - - math::PtEtaPhiMLorentzVector multiclusterP4( sumPt, - multicluster.centre().eta(), - multicluster.centre().phi(), - 0. ); - multicluster.setP4( multiclusterP4 ); - - if( multicluster.pt() > ptC3dThreshold_ ){ - //compute shower shapes - shape_.fillShapes(multicluster, triggerGeometry); - // fill quality flag - multicluster.setHwQual(id_->decision(multicluster)); - // fill H/E - multicluster.saveHOverE(); - - multiclusters_out.push_back( 0, multicluster); - } +void HGCalMulticlusteringImpl::finalizeClusters(std::vector& multiclusters_in, + l1t::HGCalMulticlusterBxCollection& multiclusters_out, + const HGCalTriggerGeometryBase& triggerGeometry) { + for (auto& multicluster : multiclusters_in) { + // compute the eta, phi from its barycenter + // + pT as scalar sum of pT of constituents + double sumPt = 0.; + const std::unordered_map>& clusters = multicluster.constituents(); + for (const auto& id_cluster : clusters) + sumPt += id_cluster.second->pt(); + + math::PtEtaPhiMLorentzVector multiclusterP4(sumPt, multicluster.centre().eta(), multicluster.centre().phi(), 0.); + multicluster.setP4(multiclusterP4); + + if (multicluster.pt() > ptC3dThreshold_) { + //compute shower shapes + shape_.fillShapes(multicluster, triggerGeometry); + // fill quality flag + multicluster.setHwQual(id_->decision(multicluster)); + // fill H/E + multicluster.saveHOverE(); + + multiclusters_out.push_back(0, multicluster); } + } } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc b/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc index 2fe43fbdecc16..07a287a678a01 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalShowerShape.cc @@ -5,57 +5,47 @@ #include - //Compute energy-weighted mean of any variable X in the cluster -float HGCalShowerShape::meanX(const std::vector >& energy_X_tc) const { - +float HGCalShowerShape::meanX(const std::vector>& energy_X_tc) const { float Etot = 0; float X_sum = 0; - for(const auto& energy_X : energy_X_tc){ - - X_sum += energy_X.first*energy_X.second; + for (const auto& energy_X : energy_X_tc) { + X_sum += energy_X.first * energy_X.second; Etot += energy_X.first; - } float X_mean = 0; - if(Etot>0) X_mean = X_sum/Etot; + if (Etot > 0) + X_mean = X_sum / Etot; return X_mean; - } - int HGCalShowerShape::firstLayer(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - int firstLayer=999; - - for(const auto& id_clu : clustersPtrs){ - + + int firstLayer = 999; + + for (const auto& id_clu : clustersPtrs) { int layer = triggerTools_.layerWithOffset(id_clu.second->detId()); - if(layer>& clustersPtrs = c3d.constituents(); std::unordered_map layers_pt; float max_pt = 0.; int max_layer = 0; - for(const auto& id_cluster : clustersPtrs){ + for (const auto& id_cluster : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_cluster.second->detId()); auto itr_insert = layers_pt.emplace(layer, 0.); itr_insert.first->second += id_cluster.second->pt(); - if(itr_insert.first->second>max_pt){ + if (itr_insert.first->second > max_pt) { max_pt = itr_insert.first->second; max_layer = layer; } @@ -63,436 +53,336 @@ int HGCalShowerShape::maxLayer(const l1t::HGCalMulticluster& c3d) const { return max_layer; } - int HGCalShowerShape::lastLayer(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - int lastLayer=-999; - - for(const auto& id_clu : clustersPtrs){ - + + int lastLayer = -999; + + for (const auto& id_clu : clustersPtrs) { int layer = triggerTools_.layerWithOffset(id_clu.second->detId()); - if(layer>lastLayer) lastLayer=layer; - + if (layer > lastLayer) + lastLayer = layer; } - + return lastLayer; - } -int HGCalShowerShape::coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const -{ +int HGCalShowerShape::coreShowerLength(const l1t::HGCalMulticluster& c3d, + const HGCalTriggerGeometryBase& triggerGeometry) const { const std::unordered_map>& clustersPtrs = c3d.constituents(); unsigned nlayers = triggerTools_.layers(ForwardSubdetector::ForwardEmpty); std::vector layers(nlayers); - for(const auto& id_cluster : clustersPtrs) - { + for (const auto& id_cluster : clustersPtrs) { unsigned layer = triggerGeometry.triggerLayer(id_cluster.second->detId()); - if(layer==0 || layer>nlayers) continue; - layers[layer-1] = true; //layer 0 doesn't exist, so shift by -1 + if (layer == 0 || layer > nlayers) + continue; + layers[layer - 1] = true; //layer 0 doesn't exist, so shift by -1 } int length = 0; int maxlength = 0; - for(bool layer : layers) - { - if(layer) length++; - else length = 0; - if(length>maxlength) maxlength = length; + for (bool layer : layers) { + if (layer) + length++; + else + length = 0; + if (length > maxlength) + maxlength = length; } return maxlength; } - float HGCalShowerShape::sigmaEtaEtaTot(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - std::vector > tc_energy_eta ; - - for(const auto& id_clu : clustersPtrs){ - + + std::vector> tc_energy_eta; + + for (const auto& id_clu : clustersPtrs) { const std::unordered_map>& triggerCells = id_clu.second->constituents(); - - for(const auto& id_tc : triggerCells){ - - tc_energy_eta.emplace_back( std::make_pair(id_tc.second->energy(),id_tc.second->eta()) ); - + + for (const auto& id_tc : triggerCells) { + tc_energy_eta.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta())); } - } - - float SeeTot = sigmaXX(tc_energy_eta,c3d.eta()); - - return SeeTot; - -} - + float SeeTot = sigmaXX(tc_energy_eta, c3d.eta()); + return SeeTot; +} float HGCalShowerShape::sigmaPhiPhiTot(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - std::vector > tc_energy_phi ; - - for(const auto& id_clu : clustersPtrs){ - + + std::vector> tc_energy_phi; + + for (const auto& id_clu : clustersPtrs) { const std::unordered_map>& triggerCells = id_clu.second->constituents(); - - for(const auto& id_tc : triggerCells){ - - tc_energy_phi.emplace_back( std::make_pair(id_tc.second->energy(),id_tc.second->phi()) ); + for (const auto& id_tc : triggerCells) { + tc_energy_phi.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi())); } - } - - float SppTot = sigmaPhiPhi(tc_energy_phi,c3d.phi()); - - return SppTot; - -} - - + float SppTot = sigmaPhiPhi(tc_energy_phi, c3d.phi()); + return SppTot; +} float HGCalShowerShape::sigmaRRTot(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - std::vector > tc_energy_r ; - - for(const auto& id_clu : clustersPtrs){ - + + std::vector> tc_energy_r; + + for (const auto& id_clu : clustersPtrs) { const std::unordered_map>& triggerCells = id_clu.second->constituents(); - - for(const auto& id_tc : triggerCells){ - - float r = (id_tc.second->position().z()!=0. ? std::sqrt( pow(id_tc.second->position().x(),2) + pow(id_tc.second->position().y(),2) )/std::abs(id_tc.second->position().z()) : 0.); - tc_energy_r.emplace_back( std::make_pair(id_tc.second->energy(),r) ); + for (const auto& id_tc : triggerCells) { + float r = (id_tc.second->position().z() != 0. + ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) / + std::abs(id_tc.second->position().z()) + : 0.); + tc_energy_r.emplace_back(std::make_pair(id_tc.second->energy(), r)); } - } float r_mean = meanX(tc_energy_r); - float Szz = sigmaXX(tc_energy_r,r_mean); - + float Szz = sigmaXX(tc_energy_r, r_mean); + return Szz; - } - - - - float HGCalShowerShape::sigmaEtaEtaMax(const l1t::HGCalMulticluster& c3d) const { - - std::unordered_map > > tc_layer_energy_eta; + std::unordered_map>> tc_layer_energy_eta; std::unordered_map layer_LV; const std::unordered_map>& clustersPtrs = c3d.constituents(); - for(const auto& id_clu : clustersPtrs){ - + for (const auto& id_clu : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId()); - + layer_LV[layer] += id_clu.second->p4(); const std::unordered_map>& triggerCells = id_clu.second->constituents(); - for(const auto& id_tc : triggerCells){ - - tc_layer_energy_eta[layer].emplace_back( std::make_pair(id_tc.second->energy(),id_tc.second->eta()) ); - + for (const auto& id_tc : triggerCells) { + tc_layer_energy_eta[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta())); } - } + float SigmaEtaEtaMax = 0; - float SigmaEtaEtaMax=0; - - for(auto& tc_iter : tc_layer_energy_eta){ - - const std::vector >& energy_eta_layer = tc_iter.second; + for (auto& tc_iter : tc_layer_energy_eta) { + const std::vector>& energy_eta_layer = tc_iter.second; const LorentzVector& LV_layer = layer_LV[tc_iter.first]; - float SigmaEtaEtaLayer = sigmaXX(energy_eta_layer,LV_layer.eta()); //RMS wrt layer eta, not wrt c3d eta - if(SigmaEtaEtaLayer > SigmaEtaEtaMax) SigmaEtaEtaMax = SigmaEtaEtaLayer; - + float SigmaEtaEtaLayer = sigmaXX(energy_eta_layer, LV_layer.eta()); //RMS wrt layer eta, not wrt c3d eta + if (SigmaEtaEtaLayer > SigmaEtaEtaMax) + SigmaEtaEtaMax = SigmaEtaEtaLayer; } - return SigmaEtaEtaMax; - - } - - - float HGCalShowerShape::sigmaPhiPhiMax(const l1t::HGCalMulticluster& c3d) const { - - std::unordered_map > > tc_layer_energy_phi; + std::unordered_map>> tc_layer_energy_phi; std::unordered_map layer_LV; const std::unordered_map>& clustersPtrs = c3d.constituents(); - for(const auto& id_clu : clustersPtrs){ - + for (const auto& id_clu : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId()); - + layer_LV[layer] += id_clu.second->p4(); const std::unordered_map>& triggerCells = id_clu.second->constituents(); - for(const auto& id_tc : triggerCells){ - - tc_layer_energy_phi[layer].emplace_back( std::make_pair(id_tc.second->energy(),id_tc.second->phi()) ); - + for (const auto& id_tc : triggerCells) { + tc_layer_energy_phi[layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi())); } - } + float SigmaPhiPhiMax = 0; - float SigmaPhiPhiMax=0; - - for(auto& tc_iter : tc_layer_energy_phi){ - - const std::vector >& energy_phi_layer = tc_iter.second; + for (auto& tc_iter : tc_layer_energy_phi) { + const std::vector>& energy_phi_layer = tc_iter.second; const LorentzVector& LV_layer = layer_LV[tc_iter.first]; - float SigmaPhiPhiLayer = sigmaPhiPhi(energy_phi_layer,LV_layer.phi()); //RMS wrt layer phi, not wrt c3d phi - if(SigmaPhiPhiLayer > SigmaPhiPhiMax) SigmaPhiPhiMax = SigmaPhiPhiLayer; - + float SigmaPhiPhiLayer = sigmaPhiPhi(energy_phi_layer, LV_layer.phi()); //RMS wrt layer phi, not wrt c3d phi + if (SigmaPhiPhiLayer > SigmaPhiPhiMax) + SigmaPhiPhiMax = SigmaPhiPhiLayer; } - return SigmaPhiPhiMax; - - } - - - float HGCalShowerShape::sigmaRRMax(const l1t::HGCalMulticluster& c3d) const { - - std::unordered_map > > tc_layer_energy_r; + std::unordered_map>> tc_layer_energy_r; const std::unordered_map>& clustersPtrs = c3d.constituents(); - for(const auto& id_clu : clustersPtrs){ - + for (const auto& id_clu : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId()); const std::unordered_map>& triggerCells = id_clu.second->constituents(); - for(const auto& id_tc : triggerCells){ - - float r = (id_tc.second->position().z()!=0. ? std::sqrt( pow(id_tc.second->position().x(),2) + pow(id_tc.second->position().y(),2) )/std::abs(id_tc.second->position().z()) : 0.); - tc_layer_energy_r[layer].emplace_back( std::make_pair(id_tc.second->energy(),r) ); - + for (const auto& id_tc : triggerCells) { + float r = (id_tc.second->position().z() != 0. + ? std::sqrt(pow(id_tc.second->position().x(), 2) + pow(id_tc.second->position().y(), 2)) / + std::abs(id_tc.second->position().z()) + : 0.); + tc_layer_energy_r[layer].emplace_back(std::make_pair(id_tc.second->energy(), r)); } - } + float SigmaRRMax = 0; - float SigmaRRMax=0; - - for(auto& tc_iter : tc_layer_energy_r){ - - const std::vector >& energy_r_layer = tc_iter.second; + for (auto& tc_iter : tc_layer_energy_r) { + const std::vector>& energy_r_layer = tc_iter.second; float r_mean_layer = meanX(energy_r_layer); - float SigmaRRLayer = sigmaXX(energy_r_layer,r_mean_layer); - if(SigmaRRLayer > SigmaRRMax) SigmaRRMax = SigmaRRLayer; - + float SigmaRRLayer = sigmaXX(energy_r_layer, r_mean_layer); + if (SigmaRRLayer > SigmaRRMax) + SigmaRRMax = SigmaRRLayer; } - return SigmaRRMax; - - } - float HGCalShowerShape::sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); // group trigger cells by layer - std::unordered_map> > layers_tcs; - for(const auto& id_clu : clustersPtrs){ + std::unordered_map>> layers_tcs; + for (const auto& id_clu : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId()); const std::unordered_map>& triggerCells = id_clu.second->constituents(); - for(const auto& id_tc : triggerCells){ + for (const auto& id_tc : triggerCells) { layers_tcs[layer].emplace_back(id_tc.second); } } // Select trigger cells within X cm of the max TC in the layer - std::unordered_map > > tc_layers_energy_r; - for(const auto& layer_tcs : layers_tcs){ + std::unordered_map>> tc_layers_energy_r; + for (const auto& layer_tcs : layers_tcs) { int layer = layer_tcs.first; edm::Ptr max_tc = layer_tcs.second.front(); - for(const auto& tc : layer_tcs.second){ - if(tc->energy()>max_tc->energy()) max_tc = tc; + for (const auto& tc : layer_tcs.second) { + if (tc->energy() > max_tc->energy()) + max_tc = tc; } - for(const auto& tc : layer_tcs.second){ + for (const auto& tc : layer_tcs.second) { double dx = tc->position().x() - max_tc->position().x(); double dy = tc->position().y() - max_tc->position().y(); - double distance_to_max = std::sqrt(dx*dx+dy*dy); - if(distance_to_maxposition().z()!=0. ? std::sqrt(tc->position().x()*tc->position().x() + tc->position().y()*tc->position().y())/std::abs(tc->position().z()) : 0.); - tc_layers_energy_r[layer].emplace_back( std::make_pair(tc->energy(), r)); + double distance_to_max = std::sqrt(dx * dx + dy * dy); + if (distance_to_max < radius) { + float r = (tc->position().z() != 0. + ? std::sqrt(tc->position().x() * tc->position().x() + tc->position().y() * tc->position().y()) / + std::abs(tc->position().z()) + : 0.); + tc_layers_energy_r[layer].emplace_back(std::make_pair(tc->energy(), r)); } } } // Compute srr layer by layer - std::vector> layers_energy_srr2; - for(const auto& layer_energy_r : tc_layers_energy_r){ + std::vector> layers_energy_srr2; + for (const auto& layer_energy_r : tc_layers_energy_r) { const auto& energies_r = layer_energy_r.second; float r_mean_layer = meanX(energies_r); - float srr = sigmaXX(energies_r,r_mean_layer); + float srr = sigmaXX(energies_r, r_mean_layer); double energy_sum = 0.; - for(const auto& energy_r : energies_r){ + for (const auto& energy_r : energies_r) { energy_sum += energy_r.first; } - layers_energy_srr2.emplace_back(std::make_pair(energy_sum, srr*srr)); + layers_energy_srr2.emplace_back(std::make_pair(energy_sum, srr * srr)); } // Combine all layer srr float srr2_mean = meanX(layers_energy_srr2); return std::sqrt(srr2_mean); } - - float HGCalShowerShape::eMax(const l1t::HGCalMulticluster& c3d) const { - std::unordered_map layer_energy; - + const std::unordered_map>& clustersPtrs = c3d.constituents(); - - for(const auto& id_clu : clustersPtrs){ - + + for (const auto& id_clu : clustersPtrs) { unsigned layer = triggerTools_.layerWithOffset(id_clu.second->detId()); layer_energy[layer] += id_clu.second->energy(); - } - - float EMax=0; - - for(const auto& layer : layer_energy){ - - if(layer.second>EMax) EMax = layer.second; - + + float EMax = 0; + + for (const auto& layer : layer_energy) { + if (layer.second > EMax) + EMax = layer.second; } return EMax; - } - - - - float HGCalShowerShape::sigmaZZ(const l1t::HGCalMulticluster& c3d) const { - const std::unordered_map>& clustersPtrs = c3d.constituents(); - - std::vector > tc_energy_z ; - - for(const auto& id_clu : clustersPtrs){ - + + std::vector> tc_energy_z; + + for (const auto& id_clu : clustersPtrs) { const std::unordered_map>& triggerCells = id_clu.second->constituents(); - - for(const auto& id_tc : triggerCells){ - - tc_energy_z.emplace_back( std::make_pair(id_tc.second->energy(),id_tc.second->position().z()) ); + for (const auto& id_tc : triggerCells) { + tc_energy_z.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->position().z())); } - } float z_mean = meanX(tc_energy_z); - float Szz = sigmaXX(tc_energy_z,z_mean); - + float Szz = sigmaXX(tc_energy_z, z_mean); + return Szz; - } - - - - float HGCalShowerShape::sigmaEtaEtaTot(const l1t::HGCalCluster& c2d) const { - const std::unordered_map>& cellsPtrs = c2d.constituents(); - - std::vector > tc_energy_eta ; - - for(const auto& id_cell : cellsPtrs){ - - tc_energy_eta.emplace_back( std::make_pair(id_cell.second->energy(),id_cell.second->eta()) ); - + + std::vector> tc_energy_eta; + + for (const auto& id_cell : cellsPtrs) { + tc_energy_eta.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->eta())); } - - float See = sigmaXX(tc_energy_eta,c2d.eta()); - - return See; - -} + float See = sigmaXX(tc_energy_eta, c2d.eta()); + return See; +} float HGCalShowerShape::sigmaPhiPhiTot(const l1t::HGCalCluster& c2d) const { - const std::unordered_map>& cellsPtrs = c2d.constituents(); - - std::vector > tc_energy_phi ; - - for(const auto& id_cell : cellsPtrs){ - - tc_energy_phi.emplace_back( std::make_pair(id_cell.second->energy(),id_cell.second->phi()) ); - - } - - float Spp = sigmaPhiPhi(tc_energy_phi,c2d.phi()); - - return Spp; - -} + std::vector> tc_energy_phi; + for (const auto& id_cell : cellsPtrs) { + tc_energy_phi.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->phi())); + } + float Spp = sigmaPhiPhi(tc_energy_phi, c2d.phi()); -float HGCalShowerShape::sigmaRRTot(const l1t::HGCalCluster& c2d) const { + return Spp; +} +float HGCalShowerShape::sigmaRRTot(const l1t::HGCalCluster& c2d) const { const std::unordered_map>& cellsPtrs = c2d.constituents(); - - std::vector > tc_energy_r ; - - for(const auto& id_cell : cellsPtrs){ - - float r = (id_cell.second->position().z()!=0. ? std::sqrt( pow(id_cell.second->position().x(),2) + pow(id_cell.second->position().y(),2) )/std::abs(id_cell.second->position().z()) : 0.); - tc_energy_r.emplace_back( std::make_pair(id_cell.second->energy(),r) ); - + + std::vector> tc_energy_r; + + for (const auto& id_cell : cellsPtrs) { + float r = (id_cell.second->position().z() != 0. + ? std::sqrt(pow(id_cell.second->position().x(), 2) + pow(id_cell.second->position().y(), 2)) / + std::abs(id_cell.second->position().z()) + : 0.); + tc_energy_r.emplace_back(std::make_pair(id_cell.second->energy(), r)); } - - float r_mean = meanX(tc_energy_r); - float Srr = sigmaXX(tc_energy_r,r_mean); - - return Srr; - -} + float r_mean = meanX(tc_energy_r); + float Srr = sigmaXX(tc_energy_r, r_mean); + return Srr; +} -void -HGCalShowerShape:: -fillShapes(l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const -{ +void HGCalShowerShape::fillShapes(l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const { c3d.showerLength(showerLength(c3d)); c3d.coreShowerLength(coreShowerLength(c3d, triggerGeometry)); c3d.firstLayer(firstLayer(c3d)); @@ -507,4 +397,3 @@ fillShapes(l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerG c3d.sigmaRRMean(sigmaRRMean(c3d)); c3d.eMax(eMax(c3d)); } - diff --git a/L1Trigger/L1THGCal/src/backend/HGCalTowerMap2DImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalTowerMap2DImpl.cc index fd9d1574291f9..1bacdcc8a4eae 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalTowerMap2DImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalTowerMap2DImpl.cc @@ -10,53 +10,46 @@ #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" - -HGCalTowerMap2DImpl::HGCalTowerMap2DImpl(const edm::ParameterSet& conf) : useLayerWeights_(conf.getParameter("useLayerWeights")), - layerWeights_(conf.getParameter< std::vector >("layerWeights")), - towerGeometryHelper_(conf.getParameter("L1TTriggerTowerConfig")) { - -} - +HGCalTowerMap2DImpl::HGCalTowerMap2DImpl(const edm::ParameterSet& conf) + : useLayerWeights_(conf.getParameter("useLayerWeights")), + layerWeights_(conf.getParameter>("layerWeights")), + towerGeometryHelper_(conf.getParameter("L1TTriggerTowerConfig")) {} std::unordered_map HGCalTowerMap2DImpl::newTowerMaps() { std::unordered_map towerMaps; - for(unsigned layer = 1; layer<=triggerTools_.lastLayerBH(); layer++) { + for (unsigned layer = 1; layer <= triggerTools_.lastLayerBH(); layer++) { // FIXME: this is hardcoded...quite ugly - if (layer <= triggerTools_.lastLayerEE() && layer%2 == 0) continue; + if (layer <= triggerTools_.lastLayerEE() && layer % 2 == 0) + continue; towerMaps[layer] = l1t::HGCalTowerMap(towerGeometryHelper_.getTowerCoordinates(), layer); } return towerMaps; - } - - -void HGCalTowerMap2DImpl::buildTowerMap2D(const std::vector> & triggerCellsPtrs, - l1t::HGCalTowerMapBxCollection & towerMaps) { - +void HGCalTowerMap2DImpl::buildTowerMap2D(const std::vector>& triggerCellsPtrs, + l1t::HGCalTowerMapBxCollection& towerMaps) { std::unordered_map towerMapsTmp = newTowerMaps(); - for(auto tc: triggerCellsPtrs) { + for (auto tc : triggerCellsPtrs) { unsigned layer = triggerTools_.layerWithOffset(tc->detId()); // FIXME: should actually sum the energy not the Et... double calibPt = tc->pt(); - if(useLayerWeights_) calibPt = layerWeights_[layer] * tc->mipPt(); - - double etEm = layer<=triggerTools_.lastLayerEE() ? calibPt : 0; - double etHad = layer>triggerTools_.lastLayerEE() ? calibPt : 0; + if (useLayerWeights_) + calibPt = layerWeights_[layer] * tc->mipPt(); - towerMapsTmp[layer].addEt(towerGeometryHelper_.getTriggerTowerFromTriggerCell(tc->detId(), tc->eta(), tc->phi()), etEm, etHad); + double etEm = layer <= triggerTools_.lastLayerEE() ? calibPt : 0; + double etHad = layer > triggerTools_.lastLayerEE() ? calibPt : 0; + towerMapsTmp[layer].addEt( + towerGeometryHelper_.getTriggerTowerFromTriggerCell(tc->detId(), tc->eta(), tc->phi()), etEm, etHad); } /* store towerMaps in the persistent collection */ towerMaps.resize(0, towerMapsTmp.size()); - int i=0; - for(auto towerMap : towerMapsTmp){ - towerMaps.set( 0, i, towerMap.second); + int i = 0; + for (auto towerMap : towerMapsTmp) { + towerMaps.set(0, i, towerMap.second); i++; } - - } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalTowerMap3DImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalTowerMap3DImpl.cc index ba03475fdf83d..5edce0e582294 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalTowerMap3DImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalTowerMap3DImpl.cc @@ -5,29 +5,24 @@ /// /// Description: first iteration of HGCal Tower Maps - #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h" +HGCalTowerMap3DImpl::HGCalTowerMap3DImpl() {} -HGCalTowerMap3DImpl::HGCalTowerMap3DImpl( ) {} - - - - - -void HGCalTowerMap3DImpl::buildTowerMap3D(const std::vector> & towerMapsPtrs, - l1t::HGCalTowerBxCollection & towers) { - +void HGCalTowerMap3DImpl::buildTowerMap3D(const std::vector>& towerMapsPtrs, + l1t::HGCalTowerBxCollection& towers) { l1t::HGCalTowerMap towerMap; - for(auto map: towerMapsPtrs) { - if(towerMap.layer()==0) towerMap = (*map); - else towerMap += (*map); + for (auto map : towerMapsPtrs) { + if (towerMap.layer() == 0) + towerMap = (*map); + else + towerMap += (*map); } - for(auto tower: towerMap.towers()) { + for (auto tower : towerMap.towers()) { // FIXME: make this threshold configurable - if(tower.second.pt()>0) towers.push_back(0, tower.second); + if (tower.second.pt() > 0) + towers.push_back(0, tower.second); } - } diff --git a/L1Trigger/L1THGCal/src/backend/HGCalTriggerClusterIdentificationBase.cc b/L1Trigger/L1THGCal/src/backend/HGCalTriggerClusterIdentificationBase.cc index f9fba45108def..9773eec0be382 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalTriggerClusterIdentificationBase.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalTriggerClusterIdentificationBase.cc @@ -1,6 +1,3 @@ #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" -EDM_REGISTER_PLUGINFACTORY(HGCalTriggerClusterIdentificationFactory, - "HGCalTriggerClusterIdentificationFactory"); - - +EDM_REGISTER_PLUGINFACTORY(HGCalTriggerClusterIdentificationFactory, "HGCalTriggerClusterIdentificationFactory"); diff --git a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSelectionImpl.cc b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSelectionImpl.cc index 87794fbc576f7..dfc3c62579722 100644 --- a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSelectionImpl.cc +++ b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSelectionImpl.cc @@ -1,56 +1,46 @@ #include "L1Trigger/L1THGCal/interface/concentrator/HGCalConcentratorSelectionImpl.h" -HGCalConcentratorSelectionImpl:: -HGCalConcentratorSelectionImpl(const edm::ParameterSet& conf): - nData_(conf.getParameter("NData")), - nCellsInModule_(conf.getParameter("MaxCellsInModule")), - linLSB_(conf.getParameter("linLSB")), - adcsaturationBH_(conf.getParameter("adcsaturationBH")), - adcnBitsBH_(conf.getParameter("adcnBitsBH")), - TCThreshold_fC_(conf.getParameter("TCThreshold_fC")), - TCThresholdBH_MIP_(conf.getParameter("TCThresholdBH_MIP")), - triggercell_threshold_silicon_( conf.getParameter("triggercell_threshold_silicon") ), - triggercell_threshold_scintillator_( conf.getParameter("triggercell_threshold_scintillator")) -{ +HGCalConcentratorSelectionImpl::HGCalConcentratorSelectionImpl(const edm::ParameterSet& conf) + : nData_(conf.getParameter("NData")), + nCellsInModule_(conf.getParameter("MaxCellsInModule")), + linLSB_(conf.getParameter("linLSB")), + adcsaturationBH_(conf.getParameter("adcsaturationBH")), + adcnBitsBH_(conf.getParameter("adcnBitsBH")), + TCThreshold_fC_(conf.getParameter("TCThreshold_fC")), + TCThresholdBH_MIP_(conf.getParameter("TCThresholdBH_MIP")), + triggercell_threshold_silicon_(conf.getParameter("triggercell_threshold_silicon")), + triggercell_threshold_scintillator_(conf.getParameter("triggercell_threshold_scintillator")) { // Cannot have more selected cells than the max number of cells - if(nData_>nCellsInModule_) nData_ = nCellsInModule_; - adcLSBBH_ = adcsaturationBH_/pow(2.,adcnBitsBH_); - TCThreshold_ADC_ = (int) (TCThreshold_fC_ / linLSB_); - TCThresholdBH_ADC_ = (int) (TCThresholdBH_MIP_ / adcLSBBH_); + if (nData_ > nCellsInModule_) + nData_ = nCellsInModule_; + adcLSBBH_ = adcsaturationBH_ / pow(2., adcnBitsBH_); + TCThreshold_ADC_ = (int)(TCThreshold_fC_ / linLSB_); + TCThresholdBH_ADC_ = (int)(TCThresholdBH_MIP_ / adcLSBBH_); } -void -HGCalConcentratorSelectionImpl:: -thresholdSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput) -{ - for (const auto& trigCell: trigCellVecInput){ - +void HGCalConcentratorSelectionImpl::thresholdSelectImpl(const std::vector& trigCellVecInput, + std::vector& trigCellVecOutput) { + for (const auto& trigCell : trigCellVecInput) { bool isScintillator = triggerTools_.isScintillator(trigCell.detId()); int threshold = (isScintillator ? TCThresholdBH_ADC_ : TCThreshold_ADC_); - double triggercell_threshold = (isScintillator ? triggercell_threshold_scintillator_ : triggercell_threshold_silicon_); - - if ((trigCell.hwPt() >= threshold) && (trigCell.mipPt() >= triggercell_threshold)){ - trigCellVecOutput.push_back(trigCell); - } + double triggercell_threshold = + (isScintillator ? triggercell_threshold_scintillator_ : triggercell_threshold_silicon_); + + if ((trigCell.hwPt() >= threshold) && (trigCell.mipPt() >= triggercell_threshold)) { + trigCellVecOutput.push_back(trigCell); + } } } -void -HGCalConcentratorSelectionImpl:: -bestChoiceSelectImpl(const std::vector& trigCellVecInput, std::vector& trigCellVecOutput) -{ - trigCellVecOutput = trigCellVecInput; +void HGCalConcentratorSelectionImpl::bestChoiceSelectImpl(const std::vector& trigCellVecInput, + std::vector& trigCellVecOutput) { + trigCellVecOutput = trigCellVecInput; // sort, reverse order - std::sort(trigCellVecOutput.begin(), trigCellVecOutput.end(), - [](const l1t::HGCalTriggerCell& a, - const l1t::HGCalTriggerCell& b) -> bool - { - return a.hwPt() > b.hwPt(); - } - ); + std::sort(trigCellVecOutput.begin(), + trigCellVecOutput.end(), + [](const l1t::HGCalTriggerCell& a, const l1t::HGCalTriggerCell& b) -> bool { return a.hwPt() > b.hwPt(); }); // keep only the first trigger cells - if(trigCellVecOutput.size()>nData_) trigCellVecOutput.resize(nData_); - + if (trigCellVecOutput.size() > nData_) + trigCellVecOutput.resize(nData_); } - diff --git a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc index c5f7e107f7225..9e77e6ab9ab8d 100644 --- a/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc +++ b/L1Trigger/L1THGCal/src/concentrator/HGCalConcentratorSuperTriggerCellImpl.cc @@ -3,136 +3,108 @@ #include -HGCalConcentratorSuperTriggerCellImpl:: -HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) - : stcSize_(conf.getParameter< std::vector >("stcSize")) -{ - - if ( stcSize_.size() != kNLayers_ ){ - throw cms::Exception("HGCTriggerParameterError") - << "Inconsistent size of super trigger cell size vector" << stcSize_.size() ; - } - for(auto stc : stcSize_) { - if ( stc!=kSTCsizeFine_ && stc!=kSTCsizeCoarse_ ){ - throw cms::Exception("HGCTriggerParameterError") - << "Super Trigger Cell should be of size "<< - kSTCsizeFine_ << " or " << kSTCsizeCoarse_; - } +HGCalConcentratorSuperTriggerCellImpl::HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf) + : stcSize_(conf.getParameter >("stcSize")) { + if (stcSize_.size() != kNLayers_) { + throw cms::Exception("HGCTriggerParameterError") + << "Inconsistent size of super trigger cell size vector" << stcSize_.size(); + } + for (auto stc : stcSize_) { + if (stc != kSTCsizeFine_ && stc != kSTCsizeCoarse_) { + throw cms::Exception("HGCTriggerParameterError") + << "Super Trigger Cell should be of size " << kSTCsizeFine_ << " or " << kSTCsizeCoarse_; } - + } } -std::map -HGCalConcentratorSuperTriggerCellImpl::kSplit_ = { - {kSTCsizeFine_, kSplit_v8_Fine_}, - {kSTCsizeCoarse_, kSplit_v8_Coarse_} -}; - -int -HGCalConcentratorSuperTriggerCellImpl::getSuperTriggerCellId(int detid) const { - +std::map HGCalConcentratorSuperTriggerCellImpl::kSplit_ = {{kSTCsizeFine_, kSplit_v8_Fine_}, + {kSTCsizeCoarse_, kSplit_v8_Coarse_}}; - DetId TC_id( detid ); - if ( TC_id.det() == DetId::Forward ){//V8 +int HGCalConcentratorSuperTriggerCellImpl::getSuperTriggerCellId(int detid) const { + DetId TC_id(detid); + if (TC_id.det() == DetId::Forward) { //V8 HGCalDetId TC_idV8(detid); - if( triggerTools_.isScintillator(detid) ){ - return TC_idV8.cell(); //scintillator - } - else{ + if (triggerTools_.isScintillator(detid)) { + return TC_idV8.cell(); //scintillator + } else { int TC_wafer = TC_idV8.wafer(); - int thickness = triggerTools_.thicknessIndex(detid,true); - int TC_split = ( TC_idV8.cell() & kSplit_.at( stcSize_.at(thickness) ) ); + int thickness = triggerTools_.thicknessIndex(detid, true); + int TC_split = (TC_idV8.cell() & kSplit_.at(stcSize_.at(thickness))); - return TC_wafer<& trigCellVecInput, std::vector& trigCellVecOutput) -{ - - std::unordered_map STCs; +void HGCalConcentratorSuperTriggerCellImpl::superTriggerCellSelectImpl( + const std::vector& trigCellVecInput, std::vector& trigCellVecOutput) { + std::unordered_map STCs; // first pass, fill the super trigger cells - for (const l1t::HGCalTriggerCell & tc : trigCellVecInput) { - if (tc.subdetId() == HGCHEB) continue; + for (const l1t::HGCalTriggerCell& tc : trigCellVecInput) { + if (tc.subdetId() == HGCHEB) + continue; STCs[getSuperTriggerCellId(tc.detId())].add(tc); } - + // second pass, write them out - for (const l1t::HGCalTriggerCell & tc : trigCellVecInput) { - + for (const l1t::HGCalTriggerCell& tc : trigCellVecInput) { //If scintillator use a simple threshold cut if (tc.subdetId() == HGCHEB) { - trigCellVecOutput.push_back( tc ); + trigCellVecOutput.push_back(tc); } else { - const auto & stc = STCs[getSuperTriggerCellId(tc.detId())]; - if (tc.detId() == stc.GetMaxId() ) { - trigCellVecOutput.push_back( tc ); + const auto& stc = STCs[getSuperTriggerCellId(tc.detId())]; + if (tc.detId() == stc.GetMaxId()) { + trigCellVecOutput.push_back(tc); stc.assignEnergy(trigCellVecOutput.back()); } } - - } // end of second loop - + + } // end of second loop } diff --git a/L1Trigger/L1THGCal/src/veryfrontend/HGCalTriggerCellCalibration.cc b/L1Trigger/L1THGCal/src/veryfrontend/HGCalTriggerCellCalibration.cc index 6583ee7ecbaed..19fcc1e79bbab 100644 --- a/L1Trigger/L1THGCal/src/veryfrontend/HGCalTriggerCellCalibration.cc +++ b/L1Trigger/L1THGCal/src/veryfrontend/HGCalTriggerCellCalibration.cc @@ -1,95 +1,80 @@ #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalTriggerCellCalibration.h" //class constructor -HGCalTriggerCellCalibration::HGCalTriggerCellCalibration(const edm::ParameterSet& beCodecConfig){ - - LSB_silicon_fC_ = beCodecConfig.getParameter("siliconCellLSB_fC"); - LSB_scintillator_MIP_ = beCodecConfig.getParameter("scintillatorCellLSB_MIP"); - fCperMIP_ = beCodecConfig.getParameter("fCperMIP"); - dEdX_weights_ = beCodecConfig.getParameter>("dEdXweights"); - thickCorr_ = beCodecConfig.getParameter("thickCorr"); - - - - if(fCperMIP_ <= 0){ - edm::LogWarning("DivisionByZero") << "WARNING: the MIP->fC correction factor is zero or negative. It won't be applied to correct trigger cell energies."; - } - if(thickCorr_ <= 0){ - edm::LogWarning("DivisionByZero") << "WARNING: the cell-thickness correction factor is zero or negative. It won't be applied to correct trigger cell energies."; - } - +HGCalTriggerCellCalibration::HGCalTriggerCellCalibration(const edm::ParameterSet& beCodecConfig) { + LSB_silicon_fC_ = beCodecConfig.getParameter("siliconCellLSB_fC"); + LSB_scintillator_MIP_ = beCodecConfig.getParameter("scintillatorCellLSB_MIP"); + fCperMIP_ = beCodecConfig.getParameter("fCperMIP"); + dEdX_weights_ = beCodecConfig.getParameter>("dEdXweights"); + thickCorr_ = beCodecConfig.getParameter("thickCorr"); + + if (fCperMIP_ <= 0) { + edm::LogWarning("DivisionByZero") << "WARNING: the MIP->fC correction factor is zero or negative. It won't be " + "applied to correct trigger cell energies."; + } + if (thickCorr_ <= 0) { + edm::LogWarning("DivisionByZero") << "WARNING: the cell-thickness correction factor is zero or negative. It won't " + "be applied to correct trigger cell energies."; + } } +void HGCalTriggerCellCalibration::calibrateInMipT(l1t::HGCalTriggerCell& trgCell) { + bool isSilicon = triggerTools_.isSilicon(trgCell.detId()); + + /* get the hardware pT in ADC counts: */ + int hwPt = trgCell.hwPt(); + + // Convert ADC to charge in fC (in EE+FH) or in MIPs (in BH) + double amplitude = hwPt * (!isSilicon ? LSB_scintillator_MIP_ : LSB_silicon_fC_); -void HGCalTriggerCellCalibration::calibrateInMipT(l1t::HGCalTriggerCell& trgCell) -{ - - bool isSilicon = triggerTools_.isSilicon( trgCell.detId() ); - - /* get the hardware pT in ADC counts: */ - int hwPt = trgCell.hwPt(); - - // Convert ADC to charge in fC (in EE+FH) or in MIPs (in BH) - double amplitude = hwPt * (!isSilicon ? LSB_scintillator_MIP_ : LSB_silicon_fC_); - - // The responses of the different cell thicknesses have been equalized - // to the 200um response in the front-end. So there is only one global - // fCperMIP and thickCorr here - /* convert the charge amplitude in MIP: */ - double trgCellMipP = amplitude; - if( isSilicon && fCperMIP_ > 0 ){ - trgCellMipP /= fCperMIP_; - } - - /* compute the transverse-mip */ - double trgCellMipPt = trgCellMipP/cosh( trgCell.eta() ); - - /* setting pT [mip] */ - trgCell.setMipPt( trgCellMipPt ) ; -} - - -void HGCalTriggerCellCalibration::calibrateMipTinGeV(l1t::HGCalTriggerCell& trgCell) -{ - const double MevToGeV(0.001); - - DetId trgdetid( trgCell.detId() ); - unsigned trgCellLayer = triggerTools_.layerWithOffset(trgdetid); - - if(dEdX_weights_.at(trgCellLayer)==0.){ - throw cms::Exception("BadConfiguration") - <<"Trigger cell energy forced to 0 by calibration coefficients.\n" - <<"The configuration should be changed. " - <<"Discarded layers should be defined in hgcalTriggerGeometryESProducer.TriggerGeometry.DisconnectedLayers and not with calibration coefficients = 0\n"; - } - - /* weight the amplitude by the absorber coefficient in MeV/mip + bring it in GeV */ - double trgCellEt = trgCell.mipPt() * dEdX_weights_.at(trgCellLayer) * MevToGeV; - - - /* correct for the cell-thickness */ - if( triggerTools_.isSilicon(trgdetid) && thickCorr_ > 0 ){ - trgCellEt /= thickCorr_; - } - /* assign the new energy to the four-vector of the trigger cell */ - math::PtEtaPhiMLorentzVector calibP4(trgCellEt, - trgCell.eta(), - trgCell.phi(), - 0.); - - /* overwriting the 4p with the calibrated 4p */ - trgCell.setP4( calibP4 ); + // The responses of the different cell thicknesses have been equalized + // to the 200um response in the front-end. So there is only one global + // fCperMIP and thickCorr here + /* convert the charge amplitude in MIP: */ + double trgCellMipP = amplitude; + if (isSilicon && fCperMIP_ > 0) { + trgCellMipP /= fCperMIP_; + } + /* compute the transverse-mip */ + double trgCellMipPt = trgCellMipP / cosh(trgCell.eta()); + + /* setting pT [mip] */ + trgCell.setMipPt(trgCellMipPt); } -void HGCalTriggerCellCalibration::calibrateInGeV(l1t::HGCalTriggerCell& trgCell) -{ +void HGCalTriggerCellCalibration::calibrateMipTinGeV(l1t::HGCalTriggerCell& trgCell) { + const double MevToGeV(0.001); + + DetId trgdetid(trgCell.detId()); + unsigned trgCellLayer = triggerTools_.layerWithOffset(trgdetid); - /* calibrate from ADC count to transverse mip */ - calibrateInMipT(trgCell); + if (dEdX_weights_.at(trgCellLayer) == 0.) { + throw cms::Exception("BadConfiguration") + << "Trigger cell energy forced to 0 by calibration coefficients.\n" + << "The configuration should be changed. " + << "Discarded layers should be defined in hgcalTriggerGeometryESProducer.TriggerGeometry.DisconnectedLayers " + "and not with calibration coefficients = 0\n"; + } + + /* weight the amplitude by the absorber coefficient in MeV/mip + bring it in GeV */ + double trgCellEt = trgCell.mipPt() * dEdX_weights_.at(trgCellLayer) * MevToGeV; + + /* correct for the cell-thickness */ + if (triggerTools_.isSilicon(trgdetid) && thickCorr_ > 0) { + trgCellEt /= thickCorr_; + } + /* assign the new energy to the four-vector of the trigger cell */ + math::PtEtaPhiMLorentzVector calibP4(trgCellEt, trgCell.eta(), trgCell.phi(), 0.); + + /* overwriting the 4p with the calibrated 4p */ + trgCell.setP4(calibP4); +} - /* calibrate from mip count to GeV */ - calibrateMipTinGeV(trgCell); +void HGCalTriggerCellCalibration::calibrateInGeV(l1t::HGCalTriggerCell& trgCell) { + /* calibrate from ADC count to transverse mip */ + calibrateInMipT(trgCell); + /* calibrate from mip count to GeV */ + calibrateMipTinGeV(trgCell); } - diff --git a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFECompressionImpl.cc b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFECompressionImpl.cc index 1d6dc1cc0fd36..32e327d975738 100644 --- a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFECompressionImpl.cc +++ b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFECompressionImpl.cc @@ -1,27 +1,20 @@ #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFECompressionImpl.h" -HGCalVFECompressionImpl:: -HGCalVFECompressionImpl(const edm::ParameterSet& conf): - exponentBits_(conf.getParameter("exponentBits")), - mantissaBits_(conf.getParameter("mantissaBits")), - rounding_(conf.getParameter("rounding")) -{ +HGCalVFECompressionImpl::HGCalVFECompressionImpl(const edm::ParameterSet& conf) + : exponentBits_(conf.getParameter("exponentBits")), + mantissaBits_(conf.getParameter("mantissaBits")), + rounding_(conf.getParameter("rounding")) { if (((1 << exponentBits_) + mantissaBits_ - 1) >= 32) { - throw cms::Exception("CodespaceCannotFit") - << "The code space cannot fit into the unsigned 32-bit space.\n"; + throw cms::Exception("CodespaceCannotFit") << "The code space cannot fit into the unsigned 32-bit space.\n"; } saturationCode_ = (1 << (exponentBits_ + mantissaBits_)) - 1; saturationValue_ = - (exponentBits_ == 0) ? saturationCode_ : - ((1 << (mantissaBits_ + 1)) - 1) << ((1 << exponentBits_) - 2); + (exponentBits_ == 0) ? saturationCode_ : ((1 << (mantissaBits_ + 1)) - 1) << ((1 << exponentBits_) - 2); } -void -HGCalVFECompressionImpl:: -compressSingle(const uint32_t value, - uint32_t & compressedCode, - uint32_t & compressedValue) -{ +void HGCalVFECompressionImpl::compressSingle(const uint32_t value, + uint32_t& compressedCode, + uint32_t& compressedValue) { // check for saturation if (value > saturationValue_) { compressedCode = saturationCode_; @@ -32,7 +25,8 @@ compressSingle(const uint32_t value, // count bit length uint32_t bitlen; uint32_t valcopy = value; - for (bitlen = 0; valcopy != 0; valcopy >>= 1, bitlen++) {} + for (bitlen = 0; valcopy != 0; valcopy >>= 1, bitlen++) { + } if (bitlen <= mantissaBits_) { compressedCode = value; compressedValue = value; @@ -41,7 +35,7 @@ compressSingle(const uint32_t value, // build exponent and mantissa const uint32_t exponent = bitlen - mantissaBits_; - const uint32_t mantissa = (value >> (exponent-1)) & ~(1<> (exponent - 1)) & ~(1 << mantissaBits_); // assemble floating-point const uint32_t floatval = (exponent << mantissaBits_) | mantissa; @@ -49,39 +43,33 @@ compressSingle(const uint32_t value, // we will never want to round up maximum code here if (!rounding_ || floatval == saturationCode_) { compressedCode = floatval; - compressedValue = ((1 << mantissaBits_) | mantissa) << (exponent-1); - } - else { - const bool roundup = ((value >> (exponent-2)) & 1) == 1; + compressedValue = ((1 << mantissaBits_) | mantissa) << (exponent - 1); + } else { + const bool roundup = ((value >> (exponent - 2)) & 1) == 1; if (!roundup) { compressedCode = floatval; - compressedValue = ((1 << mantissaBits_) | mantissa) << (exponent-1); - } - else { - compressedCode = floatval+1; + compressedValue = ((1 << mantissaBits_) | mantissa) << (exponent - 1); + } else { + compressedCode = floatval + 1; uint32_t rmantissa = mantissa + 1; uint32_t rexponent = exponent; if (rmantissa >= (1U << mantissaBits_)) { rexponent++; rmantissa &= ~(1 << mantissaBits_); } - compressedValue = ((1 << mantissaBits_) | rmantissa) << (rexponent-1); + compressedValue = ((1 << mantissaBits_) | rmantissa) << (rexponent - 1); } } } -void -HGCalVFECompressionImpl:: -compress(const std::unordered_map& payload, - std::unordered_map >& compressed_payload) -{ +void HGCalVFECompressionImpl::compress(const std::unordered_map& payload, + std::unordered_map >& compressed_payload) { for (const auto& item : payload) { const uint32_t value = item.second; uint32_t code(0); uint32_t compressed_value(0); compressSingle(value, code, compressed_value); - std::array compressed_item = {{ code, compressed_value }}; + std::array compressed_item = {{code, compressed_value}}; compressed_payload.emplace(item.first, compressed_item); } } - diff --git a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFELinearizationImpl.cc b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFELinearizationImpl.cc index 7fb619157e580..3f685b9161bda 100644 --- a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFELinearizationImpl.cc +++ b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFELinearizationImpl.cc @@ -1,49 +1,41 @@ #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFELinearizationImpl.h" -HGCalVFELinearizationImpl:: -HGCalVFELinearizationImpl(const edm::ParameterSet& conf): - linLSB_(conf.getParameter("linLSB")), - adcsaturation_(conf.getParameter("adcsaturation")), - tdcnBits_(conf.getParameter("tdcnBits")), - tdcOnsetfC_(conf.getParameter("tdcOnsetfC")), - adcnBits_(conf.getParameter("adcnBits")), - tdcsaturation_(conf.getParameter("tdcsaturation")), - linnBits_(conf.getParameter("linnBits")) -{ - adcLSB_ = adcsaturation_/pow(2.,adcnBits_); - tdcLSB_ = tdcsaturation_/pow(2.,tdcnBits_); - linMax_ = (0x1<("linLSB")), + adcsaturation_(conf.getParameter("adcsaturation")), + tdcnBits_(conf.getParameter("tdcnBits")), + tdcOnsetfC_(conf.getParameter("tdcOnsetfC")), + adcnBits_(conf.getParameter("adcnBits")), + tdcsaturation_(conf.getParameter("tdcsaturation")), + linnBits_(conf.getParameter("linnBits")) { + adcLSB_ = adcsaturation_ / pow(2., adcnBits_); + tdcLSB_ = tdcsaturation_ / pow(2., tdcnBits_); + linMax_ = (0x1 << linnBits_) - 1; } -void -HGCalVFELinearizationImpl:: -linearize(const std::vector>& dataframes, - std::vector >& linearized_dataframes) -{ - double amplitude = 0.; - uint32_t amplitude_int = 0; - const int kIntimeSample = 2; +void HGCalVFELinearizationImpl::linearize(const std::vector>& dataframes, + std::vector>& linearized_dataframes) { + double amplitude = 0.; + uint32_t amplitude_int = 0; + const int kIntimeSample = 2; - for(const auto& frame : dataframes) {//loop on DIGI - unsigned det = frame.id().det(); - if(det==DetId::Forward || det==DetId::HGCalEE || det==DetId::HGCalHSi) { - if (frame[kIntimeSample].mode()) {//TOT mode - amplitude =( floor(tdcOnsetfC_/adcLSB_) + 1.0 )* adcLSB_ + double(frame[kIntimeSample].data()) * tdcLSB_; - } - else {//ADC mode - amplitude = double(frame[kIntimeSample].data()) * adcLSB_; - } + for (const auto& frame : dataframes) { //loop on DIGI + unsigned det = frame.id().det(); + if (det == DetId::Forward || det == DetId::HGCalEE || det == DetId::HGCalHSi) { + if (frame[kIntimeSample].mode()) { //TOT mode + amplitude = (floor(tdcOnsetfC_ / adcLSB_) + 1.0) * adcLSB_ + double(frame[kIntimeSample].data()) * tdcLSB_; + } else { //ADC mode + amplitude = double(frame[kIntimeSample].data()) * adcLSB_; + } - amplitude_int = uint32_t (floor(amplitude/linLSB_+0.5)); - } - else if(det==DetId::Hcal || det==DetId::HGCalHSc) { - // no linearization here. Take the raw ADC data - amplitude_int = frame[kIntimeSample].data(); - } - if (amplitude_int>linMax_) amplitude_int = linMax_; - - linearized_dataframes.push_back(std::make_pair (frame.id(), amplitude_int)); + amplitude_int = uint32_t(floor(amplitude / linLSB_ + 0.5)); + } else if (det == DetId::Hcal || det == DetId::HGCalHSc) { + // no linearization here. Take the raw ADC data + amplitude_int = frame[kIntimeSample].data(); } -} - + if (amplitude_int > linMax_) + amplitude_int = linMax_; + linearized_dataframes.push_back(std::make_pair(frame.id(), amplitude_int)); + } +} diff --git a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFESummationImpl.cc b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFESummationImpl.cc index d5044286c95c0..586fafd136b01 100644 --- a/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFESummationImpl.cc +++ b/L1Trigger/L1THGCal/src/veryfrontend/HGCalVFESummationImpl.cc @@ -1,37 +1,30 @@ #include "L1Trigger/L1THGCal/interface/veryfrontend/HGCalVFESummationImpl.h" -HGCalVFESummationImpl:: -HGCalVFESummationImpl(const edm::ParameterSet& conf): - thickness_corrections_(conf.getParameter>("ThicknessCorrections")) -{} +HGCalVFESummationImpl::HGCalVFESummationImpl(const edm::ParameterSet& conf) + : thickness_corrections_(conf.getParameter>("ThicknessCorrections")) {} -void -HGCalVFESummationImpl:: -triggerCellSums(const HGCalTriggerGeometryBase& geometry, - const std::vector >& linearized_dataframes, - std::unordered_map& payload) -{ - if(linearized_dataframes.empty()) return; +void HGCalVFESummationImpl::triggerCellSums(const HGCalTriggerGeometryBase& geometry, + const std::vector>& linearized_dataframes, + std::unordered_map& payload) { + if (linearized_dataframes.empty()) + return; // sum energies in trigger cells - for(const auto& frame : linearized_dataframes) - { + for (const auto& frame : linearized_dataframes) { DetId cellid(frame.first); // find trigger cell associated to cell uint32_t tcid = geometry.getTriggerCellFromCell(cellid); - payload.emplace(tcid, 0); // do nothing if key exists already + payload.emplace(tcid, 0); // do nothing if key exists already uint32_t value = frame.second; unsigned det = cellid.det(); // equalize value among cell thicknesses for Silicon parts - if(det==DetId::Forward || det==DetId::HGCalEE || det==DetId::HGCalHSi) - { + if (det == DetId::Forward || det == DetId::HGCalEE || det == DetId::HGCalHSi) { int thickness = triggerTools_.thicknessIndex(cellid); double thickness_correction = thickness_corrections_.at(thickness); - value = (double)value*thickness_correction; + value = (double)value * thickness_correction; } // sums energy for the same trigger cell id - payload[tcid] += value; // 32 bits integer should be largely enough + payload[tcid] += value; // 32 bits integer should be largely enough } - } diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTester.cc b/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTester.cc index 05f3d85fd00b7..6c75bed60ce39 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTester.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTester.cc @@ -2,7 +2,6 @@ #include #include - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" @@ -33,504 +32,538 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerFECodecBase.h" #include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalBestChoiceCodecImpl.h" -#include -#include +#include +#include #include "TH2.h" - -class HGCalTriggerBestChoiceTester : public edm::EDAnalyzer -{ - public: - explicit HGCalTriggerBestChoiceTester(const edm::ParameterSet& ); - ~HGCalTriggerBestChoiceTester(); - - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - - private: - void checkSelectedCells(const edm::Event&, const edm::EventSetup&); - void rerunBestChoiceFragments(const edm::Event&, const edm::EventSetup&); - void fillModule(const std::vector&, const std::vector >&, const HGCalBestChoiceDataPayload&, const HGCalBestChoiceDataPayload&,const HGCalBestChoiceDataPayload&, const std::map &, const std::unordered_map& ); - - // inputs - edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; - bool is_Simhit_comp_; - edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; - // - edm::ESHandle triggerGeometry_; - std::unique_ptr codec_; - edm::Service fs_; - - // histos - TH1F* hgcCellData_; - TH1F* hgcCellData_SimHitasso_; - TH1F* hgcCellSimHits_; - TH2F* hgcCellData_vsSimHits_; - TH1F* hgcCellsPerModule_; - TH1F* hgcCellModuleSum_; - // - TH1F* hgcCellData_linampl_; - TH2F* hgcCellData_linampl_vsSimHits_; - TH2F* hgcCellData_linampl_vsSimHits_zoom_; - TH1F* triggerCellData_noBestChoice_; - TH2F* triggerCellData_noBestChoice_vsSimHits_; - TH1F* triggerCellSimHits_noBestChoice_; - TH1F* triggerCellData_BestChoice_; - TH2F* triggerCellData_BestChoice_vsSimHits_; - TH1F* triggerCellData_; - TH2F* triggerCellData_vsSimHits_; - TH1F* triggerCellsPerModule_; - TH1F* triggerCellModuleSum_; - // - TH2F* selectedCellsVsAllCells_ee_; - TH2F* energyLossVsNCells_ee_; - TH2F* selectedCellsVsAllCells_fh_; - TH2F* energyLossVsNCells_fh_; - // - +class HGCalTriggerBestChoiceTester : public edm::EDAnalyzer { +public: + explicit HGCalTriggerBestChoiceTester(const edm::ParameterSet&); + ~HGCalTriggerBestChoiceTester(); + + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void checkSelectedCells(const edm::Event&, const edm::EventSetup&); + void rerunBestChoiceFragments(const edm::Event&, const edm::EventSetup&); + void fillModule(const std::vector&, + const std::vector>&, + const HGCalBestChoiceDataPayload&, + const HGCalBestChoiceDataPayload&, + const HGCalBestChoiceDataPayload&, + const std::map&, + const std::unordered_map&); + + // inputs + edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; + bool is_Simhit_comp_; + edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; + // + edm::ESHandle triggerGeometry_; + std::unique_ptr codec_; + edm::Service fs_; + + // histos + TH1F* hgcCellData_; + TH1F* hgcCellData_SimHitasso_; + TH1F* hgcCellSimHits_; + TH2F* hgcCellData_vsSimHits_; + TH1F* hgcCellsPerModule_; + TH1F* hgcCellModuleSum_; + // + TH1F* hgcCellData_linampl_; + TH2F* hgcCellData_linampl_vsSimHits_; + TH2F* hgcCellData_linampl_vsSimHits_zoom_; + TH1F* triggerCellData_noBestChoice_; + TH2F* triggerCellData_noBestChoice_vsSimHits_; + TH1F* triggerCellSimHits_noBestChoice_; + TH1F* triggerCellData_BestChoice_; + TH2F* triggerCellData_BestChoice_vsSimHits_; + TH1F* triggerCellData_; + TH2F* triggerCellData_vsSimHits_; + TH1F* triggerCellsPerModule_; + TH1F* triggerCellModuleSum_; + // + TH2F* selectedCellsVsAllCells_ee_; + TH2F* energyLossVsNCells_ee_; + TH2F* selectedCellsVsAllCells_fh_; + TH2F* energyLossVsNCells_fh_; + // }; - /*****************************************************************/ -HGCalTriggerBestChoiceTester::HGCalTriggerBestChoiceTester(const edm::ParameterSet& conf): - inputee_(consumes(conf.getParameter("eeDigis"))), - inputfh_(consumes(conf.getParameter("fhDigis"))), - //inputbh_(consumes(conf.getParameter("bhDigis"))), - inputbeall_(consumes(conf.getParameter("beClustersAll"))), - inputbeselect_(consumes(conf.getParameter("beClustersSelect"))), - is_Simhit_comp_(conf.getParameter("isSimhitComp")), - SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), - SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) - // SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) +HGCalTriggerBestChoiceTester::HGCalTriggerBestChoiceTester(const edm::ParameterSet& conf) + : inputee_(consumes(conf.getParameter("eeDigis"))), + inputfh_(consumes(conf.getParameter("fhDigis"))), + //inputbh_(consumes(conf.getParameter("bhDigis"))), + inputbeall_(consumes(conf.getParameter("beClustersAll"))), + inputbeselect_(consumes(conf.getParameter("beClustersSelect"))), + is_Simhit_comp_(conf.getParameter("isSimhitComp")), + SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), + SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) +// SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) /*****************************************************************/ { - //setup FE codec - const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); - codec_.reset( new HGCalBestChoiceCodecImpl(feCodecConfig) ); - - // initialize output trees - // HGC Cells - hgcCellData_ = fs_->make("hgcCellData","Cell values", 1000, 0., 2000.); - if (is_Simhit_comp_) { - hgcCellData_SimHitasso_ = fs_->make("hgcCellData_SimHitasso_","Cell values with an associated SimHit", 1000, 0, 2000.); - hgcCellSimHits_ = fs_->make("hgcCellSimHits_","Cell simhit energies", 500, 0, 0.16); - hgcCellData_vsSimHits_ = fs_->make("hgcCellData_vsSimHits_","Cell values vs simhit energies", 500,0,0.16,1000, 0., 2000.); - } - hgcCellsPerModule_ = fs_->make("hgcCellsPerModule","Number of cells per module", 128, 0., 128.); - hgcCellModuleSum_ = fs_->make("hgcCellModuleSum","Cell sum in modules", 1000, 0., 3000.); - // - hgcCellData_linampl_ = fs_->make("hgcCellData_linampl_","Cell linearized amplitudes values All", 1000, 0, 70000); - if (is_Simhit_comp_) { - hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_","Cell linearized amplitudes vs simhit energies",500,0,0.16,1000,0,70000); - hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_","Cell linearized amplitudes vssimhit energies, zoomed",1000,0,0.002,1000,0,1000); - } - - // HGC Trigger cells - triggerCellData_noBestChoice_ = fs_->make("triggerCellData_noBestChoice_","Trigger cell values, no best choice", 1000, 0., 70000.); - if (is_Simhit_comp_){ - triggerCellData_noBestChoice_vsSimHits_ = fs_->make("triggerCellData_noBestChoice_vsSimHits_","Trigger cell values vs simhit energies, no best choice", 500,0,0.16,1000, 0., 70000.); - triggerCellSimHits_noBestChoice_ = fs_->make("triggerCellSimHits_noBestChoice","Trigger cell simhit energies, no best choice", 500, 0, 0.16); - } - triggerCellData_BestChoice_ = fs_->make("triggerCellData_BestChoice_","Trigger cell values, best choice", 1000, 0., 70000.); - if (is_Simhit_comp_) triggerCellData_BestChoice_vsSimHits_ = fs_->make("triggerCellData_BestChoice_vsSimHits_","Trigger cell values vs simhit energies, best choice", 500,0,0.16,1000, 0., 70000.); - triggerCellData_ = fs_->make("triggerCellData","Trigger cell values", 1100, 0., 1100.); - if (is_Simhit_comp_) triggerCellData_vsSimHits_ = fs_->make("triggerCellData_vsSimHits_","Trigger cell values vs simhit energies", 500,0,0.16,1100, 0., 1100.); - triggerCellsPerModule_ = fs_->make("triggerCellsPerModule","Number of trigger cells per module", 64, 0., 64.); - triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum","Trigger cell sum in modules", 1000, 0., 10000.); - // - selectedCellsVsAllCells_ee_ = fs_->make("selectedCellsVsAllCells_ee","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_ee_ = fs_->make("energyLossVsNCells_ee","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - selectedCellsVsAllCells_fh_ = fs_->make("selectedCellsVsAllCells_fh","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_fh_ = fs_->make("energyLossVsNCells_fh","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - + //setup FE codec + const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); + codec_.reset(new HGCalBestChoiceCodecImpl(feCodecConfig)); + + // initialize output trees + // HGC Cells + hgcCellData_ = fs_->make("hgcCellData", "Cell values", 1000, 0., 2000.); + if (is_Simhit_comp_) { + hgcCellData_SimHitasso_ = + fs_->make("hgcCellData_SimHitasso_", "Cell values with an associated SimHit", 1000, 0, 2000.); + hgcCellSimHits_ = fs_->make("hgcCellSimHits_", "Cell simhit energies", 500, 0, 0.16); + hgcCellData_vsSimHits_ = + fs_->make("hgcCellData_vsSimHits_", "Cell values vs simhit energies", 500, 0, 0.16, 1000, 0., 2000.); + } + hgcCellsPerModule_ = fs_->make("hgcCellsPerModule", "Number of cells per module", 128, 0., 128.); + hgcCellModuleSum_ = fs_->make("hgcCellModuleSum", "Cell sum in modules", 1000, 0., 3000.); + // + hgcCellData_linampl_ = + fs_->make("hgcCellData_linampl_", "Cell linearized amplitudes values All", 1000, 0, 70000); + if (is_Simhit_comp_) { + hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_", + "Cell linearized amplitudes vs simhit energies", + 500, + 0, + 0.16, + 1000, + 0, + 70000); + hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_", + "Cell linearized amplitudes vssimhit energies, zoomed", + 1000, + 0, + 0.002, + 1000, + 0, + 1000); + } + + // HGC Trigger cells + triggerCellData_noBestChoice_ = + fs_->make("triggerCellData_noBestChoice_", "Trigger cell values, no best choice", 1000, 0., 70000.); + if (is_Simhit_comp_) { + triggerCellData_noBestChoice_vsSimHits_ = fs_->make("triggerCellData_noBestChoice_vsSimHits_", + "Trigger cell values vs simhit energies, no best choice", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellSimHits_noBestChoice_ = fs_->make( + "triggerCellSimHits_noBestChoice", "Trigger cell simhit energies, no best choice", 500, 0, 0.16); + } + triggerCellData_BestChoice_ = + fs_->make("triggerCellData_BestChoice_", "Trigger cell values, best choice", 1000, 0., 70000.); + if (is_Simhit_comp_) + triggerCellData_BestChoice_vsSimHits_ = fs_->make("triggerCellData_BestChoice_vsSimHits_", + "Trigger cell values vs simhit energies, best choice", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellData_ = fs_->make("triggerCellData", "Trigger cell values", 1100, 0., 1100.); + if (is_Simhit_comp_) + triggerCellData_vsSimHits_ = fs_->make( + "triggerCellData_vsSimHits_", "Trigger cell values vs simhit energies", 500, 0, 0.16, 1100, 0., 1100.); + triggerCellsPerModule_ = fs_->make("triggerCellsPerModule", "Number of trigger cells per module", 64, 0., 64.); + triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum", "Trigger cell sum in modules", 1000, 0., 10000.); + // + selectedCellsVsAllCells_ee_ = fs_->make( + "selectedCellsVsAllCells_ee", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_ee_ = fs_->make( + "energyLossVsNCells_ee", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); + selectedCellsVsAllCells_fh_ = fs_->make( + "selectedCellsVsAllCells_fh", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_fh_ = fs_->make( + "energyLossVsNCells_fh", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); } - - /*****************************************************************/ -HGCalTriggerBestChoiceTester::~HGCalTriggerBestChoiceTester() +HGCalTriggerBestChoiceTester::~HGCalTriggerBestChoiceTester() /*****************************************************************/ -{ -} +{} /*****************************************************************/ -void HGCalTriggerBestChoiceTester::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) +void HGCalTriggerBestChoiceTester::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) /*****************************************************************/ { - es.get().get(triggerGeometry_); + es.get().get(triggerGeometry_); } /*****************************************************************/ -void HGCalTriggerBestChoiceTester::analyze(const edm::Event& e, - const edm::EventSetup& es) +void HGCalTriggerBestChoiceTester::analyze(const edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ { - checkSelectedCells(e, es); - rerunBestChoiceFragments(e, es); - + checkSelectedCells(e, es); + rerunBestChoiceFragments(e, es); } /*****************************************************************/ -void HGCalTriggerBestChoiceTester::checkSelectedCells(const edm::Event& e, - const edm::EventSetup& es) +void HGCalTriggerBestChoiceTester::checkSelectedCells(const edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ { - edm::Handle be_clusters_all_h; - edm::Handle be_clusters_select_h; - e.getByToken(inputbeall_,be_clusters_all_h); - e.getByToken(inputbeselect_,be_clusters_select_h); - - const l1t::HGCalClusterBxCollection& be_clusters_all = *be_clusters_all_h; - const l1t::HGCalClusterBxCollection& be_clusters_select = *be_clusters_select_h; - - // store trigger cells module by module. tuple = zside,subdet,layer,module - std::map, std::vector>> module_triggercells_all; - for(auto cl_itr=be_clusters_all.begin(0); cl_itr!=be_clusters_all.end(0); cl_itr++) - { - const l1t::HGCalCluster& cluster = *cl_itr; - uint32_t zside = cluster.eta()<0. ? 0 : 1; - auto itr_insert = module_triggercells_all.emplace( std::make_tuple(zside, cluster.subdetId(), cluster.layer(), cluster.module()), std::vector>()); - itr_insert.first->second.emplace_back(cluster.hwEta(), cluster.hwPt()); // FIXME: the index within the module has been stored in hwEta - } - std::map, std::vector>> module_triggercells_select; - for(auto cl_itr=be_clusters_select.begin(0); cl_itr!=be_clusters_select.end(0); cl_itr++) - { - const l1t::HGCalCluster& cluster = *cl_itr; - uint32_t zside = cluster.eta()<0. ? 0 : 1; - auto itr_insert = module_triggercells_select.emplace( std::make_tuple(zside, cluster.subdetId(), cluster.layer(), cluster.module()), std::vector>()); - itr_insert.first->second.emplace_back(cluster.hwEta(), cluster.hwPt()); // FIXME: the index within the module has been stored in hwEta + edm::Handle be_clusters_all_h; + edm::Handle be_clusters_select_h; + e.getByToken(inputbeall_, be_clusters_all_h); + e.getByToken(inputbeselect_, be_clusters_select_h); + + const l1t::HGCalClusterBxCollection& be_clusters_all = *be_clusters_all_h; + const l1t::HGCalClusterBxCollection& be_clusters_select = *be_clusters_select_h; + + // store trigger cells module by module. tuple = zside,subdet,layer,module + std::map, std::vector>> + module_triggercells_all; + for (auto cl_itr = be_clusters_all.begin(0); cl_itr != be_clusters_all.end(0); cl_itr++) { + const l1t::HGCalCluster& cluster = *cl_itr; + uint32_t zside = cluster.eta() < 0. ? 0 : 1; + auto itr_insert = + module_triggercells_all.emplace(std::make_tuple(zside, cluster.subdetId(), cluster.layer(), cluster.module()), + std::vector>()); + itr_insert.first->second.emplace_back( + cluster.hwEta(), cluster.hwPt()); // FIXME: the index within the module has been stored in hwEta + } + std::map, std::vector>> + module_triggercells_select; + for (auto cl_itr = be_clusters_select.begin(0); cl_itr != be_clusters_select.end(0); cl_itr++) { + const l1t::HGCalCluster& cluster = *cl_itr; + uint32_t zside = cluster.eta() < 0. ? 0 : 1; + auto itr_insert = module_triggercells_select.emplace( + std::make_tuple(zside, cluster.subdetId(), cluster.layer(), cluster.module()), + std::vector>()); + itr_insert.first->second.emplace_back( + cluster.hwEta(), cluster.hwPt()); // FIXME: the index within the module has been stored in hwEta + } + + // Compare 'all' and 'selected' trigger cells, module by module + for (const auto& module_cells : module_triggercells_all) { + const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); + if (module_cells_select_itr == module_triggercells_select.end()) { + std::cout << "ERROR: Cannot find module for selected cells\n"; } - - // Compare 'all' and 'selected' trigger cells, module by module - for(const auto& module_cells : module_triggercells_all) - { - const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); - if(module_cells_select_itr==module_triggercells_select.end()) - { - std::cout<<"ERROR: Cannot find module for selected cells\n"; - } - size_t ncells_all = module_cells.second.size(); - size_t ncells_select = module_cells_select_itr->second.size(); - uint32_t energy_all = 0; - uint32_t energy_select = 0; - for(const auto& id_energy : module_cells.second) energy_all += id_energy.second; - for(const auto& id_energy : module_cells_select_itr->second) energy_select += id_energy.second; - if(std::get<1>(module_cells.first)==ForwardSubdetector::HGCEE) - { - selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select/(double)energy_all); - } - else if(std::get<1>(module_cells.first)==ForwardSubdetector::HGCHEF) - { - selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select/(double)energy_all); - } + size_t ncells_all = module_cells.second.size(); + size_t ncells_select = module_cells_select_itr->second.size(); + uint32_t energy_all = 0; + uint32_t energy_select = 0; + for (const auto& id_energy : module_cells.second) + energy_all += id_energy.second; + for (const auto& id_energy : module_cells_select_itr->second) + energy_select += id_energy.second; + if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCEE) { + selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select / (double)energy_all); + } else if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCHEF) { + selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select / (double)energy_all); } + } - //std::cout<<"All trigger cells = "< ee_digis_h; - edm::Handle fh_digis_h; - e.getByToken(inputee_,ee_digis_h); - e.getByToken(inputfh_,fh_digis_h); - - const HGCalDigiCollection& ee_digis = *ee_digis_h; - const HGCalDigiCollection& fh_digis = *fh_digis_h; - - HGCalBestChoiceDataPayload data; - - // retrieve simhit collections - std::map simhit_energies; - if (is_Simhit_comp_) { - edm::Handle ee_simhits_h; - e.getByToken(SimHits_inputee_,ee_simhits_h); - const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; - edm::Handle fh_simhits_h; - e.getByToken(SimHits_inputfh_,fh_simhits_h); - const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; - - // simhit/digi association EE - HGCalDetId digiid, simid; - int layer=0,cell=0, sec=0, subsec=0, zp=0,subdet=0; - ForwardSubdetector mysubdet; - HGCalDetId recoDetId ; - int n_hits_asso=0; - - // create a map containing all simhit energies - std::unordered_map simhits; - for( const auto& simhit : ee_simhits ) { - simid = (HGCalDetId)simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->eeTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); + // retrieve digi collections + edm::Handle ee_digis_h; + edm::Handle fh_digis_h; + e.getByToken(inputee_, ee_digis_h); + e.getByToken(inputfh_, fh_digis_h); + + const HGCalDigiCollection& ee_digis = *ee_digis_h; + const HGCalDigiCollection& fh_digis = *fh_digis_h; + + HGCalBestChoiceDataPayload data; + + // retrieve simhit collections + std::map simhit_energies; + if (is_Simhit_comp_) { + edm::Handle ee_simhits_h; + e.getByToken(SimHits_inputee_, ee_simhits_h); + const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; + edm::Handle fh_simhits_h; + e.getByToken(SimHits_inputfh_, fh_simhits_h); + const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; + + // simhit/digi association EE + HGCalDetId digiid, simid; + int layer = 0, cell = 0, sec = 0, subsec = 0, zp = 0, subdet = 0; + ForwardSubdetector mysubdet; + HGCalDetId recoDetId; + int n_hits_asso = 0; + + // create a map containing all simhit energies + std::unordered_map simhits; + for (const auto& simhit : ee_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->eeTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; } - // find simhit energies associated to digis - for(const auto& data : ee_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); + } + // find simhit energies associated to digis + for (const auto& data : ee_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso++; + hit_energy = itr->second; } + simhit_energies[digiid] = hit_energy; + } - // simhit/digi association FH - layer=0; - cell=0; - sec=0; - subsec=0; - zp=0; - subdet=0; - int n_hits_asso_fh=0; - - // create a map containing all simhit energies - simhits.clear(); - for( const auto& simhit : fh_simhits ) { - simid = (HGCalDetId) simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->fhTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); - } - // find simhit energies associated to digis - for(const auto& data : fh_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso_fh++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; + // simhit/digi association FH + layer = 0; + cell = 0; + sec = 0; + subsec = 0; + zp = 0; + subdet = 0; + int n_hits_asso_fh = 0; + + // create a map containing all simhit energies + simhits.clear(); + for (const auto& simhit : fh_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->fhTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; } - + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); } - // Find modules containing hits and prepare list of hits for each module - std::unordered_map> hit_modules_ee; - for(const auto& eedata : ee_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); - auto itr_insert = hit_modules_ee.emplace(module,std::vector()); - itr_insert.first->second.push_back(eedata); + // find simhit energies associated to digis + for (const auto& data : fh_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso_fh++; + hit_energy = itr->second; + } + simhit_energies[digiid] = hit_energy; } - std::unordered_map> hit_modules_fh; - for(const auto& fhdata : fh_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); - auto itr_insert = hit_modules_fh.emplace(module, std::vector()); - itr_insert.first->second.push_back(fhdata); + } + // Find modules containing hits and prepare list of hits for each module + std::unordered_map> hit_modules_ee; + for (const auto& eedata : ee_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); + auto itr_insert = hit_modules_ee.emplace(module, std::vector()); + itr_insert.first->second.push_back(eedata); + } + std::unordered_map> hit_modules_fh; + for (const auto& fhdata : fh_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); + auto itr_insert = hit_modules_fh.emplace(module, std::vector()); + itr_insert.first->second.push_back(fhdata); + } + // loop on modules containing hits and call front-end processing + for (const auto& module_hits : hit_modules_ee) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over EE and fill digis belonging to that module + for (const auto& eedata : module_hits.second) { + dataframes.emplace_back(eedata.id()); + for (int i = 0; i < eedata.size(); i++) { + dataframes.back().setSample(i, eedata.sample(i)); + } } - // loop on modules containing hits and call front-end processing - for( const auto& module_hits : hit_modules_ee ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over EE and fill digis belonging to that module - for(const auto& eedata : module_hits.second) - { - dataframes.emplace_back(eedata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - uint32_t index = 0; // index in module (different from .cell()) - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(index, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(index)+=simenergy; - } - index++; - } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; + if (is_Simhit_comp_) { + uint32_t index = 0; // index in module (different from .cell()) + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(index, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(index) += simenergy; } - // Best choice encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalBestChoiceDataPayload data_TCsums_woBestChoice = data; - codec_->bestChoiceSelect(data); - HGCalBestChoiceDataPayload data_TCsums_BestChoice = data; - std::vector dataword = codec_->encode(data); - HGCalBestChoiceDataPayload datadecoded = codec_->decode(dataword); - fillModule(dataframes, linearized_dataframes, data_TCsums_woBestChoice,data_TCsums_BestChoice, datadecoded, simhit_energies, TC_simhit_energies); - - } //end loop on EE modules - for( const auto& module_hits : hit_modules_fh ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over FH digis and fill digis belonging to that module - for(const auto& fhdata : module_hits.second) - { - dataframes.emplace_back(fhdata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - uint32_t index = 0; // index in module (different from .cell()) - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(index, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(index)+=simenergy; - } - index++; - } + index++; + } + } + // Best choice encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalBestChoiceDataPayload data_TCsums_woBestChoice = data; + codec_->bestChoiceSelect(data); + HGCalBestChoiceDataPayload data_TCsums_BestChoice = data; + std::vector dataword = codec_->encode(data); + HGCalBestChoiceDataPayload datadecoded = codec_->decode(dataword); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woBestChoice, + data_TCsums_BestChoice, + datadecoded, + simhit_energies, + TC_simhit_energies); + + } //end loop on EE modules + for (const auto& module_hits : hit_modules_fh) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over FH digis and fill digis belonging to that module + for (const auto& fhdata : module_hits.second) { + dataframes.emplace_back(fhdata.id()); + for (int i = 0; i < fhdata.size(); i++) { + dataframes.back().setSample(i, fhdata.sample(i)); + } + } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; + if (is_Simhit_comp_) { + uint32_t index = 0; // index in module (different from .cell()) + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(index, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(index) += simenergy; } - // Best choice encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalBestChoiceDataPayload data_TCsums_woBestChoice = data; - codec_->bestChoiceSelect(data); - HGCalBestChoiceDataPayload data_TCsums_BestChoice = data; - std::vector dataword = codec_->encode(data); - HGCalBestChoiceDataPayload datadecoded = codec_->decode(dataword); - fillModule(dataframes, linearized_dataframes, data_TCsums_woBestChoice,data_TCsums_BestChoice, datadecoded, simhit_energies, TC_simhit_energies); - } //end loop on FH modules - - + index++; + } + } + // Best choice encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalBestChoiceDataPayload data_TCsums_woBestChoice = data; + codec_->bestChoiceSelect(data); + HGCalBestChoiceDataPayload data_TCsums_BestChoice = data; + std::vector dataword = codec_->encode(data); + HGCalBestChoiceDataPayload datadecoded = codec_->decode(dataword); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woBestChoice, + data_TCsums_BestChoice, + datadecoded, + simhit_energies, + TC_simhit_energies); + } //end loop on FH modules } - /*****************************************************************/ -void HGCalTriggerBestChoiceTester::fillModule( const std::vector& dataframes, const std::vector >& linearized_dataframes, const HGCalBestChoiceDataPayload& fe_payload_TCsums_woBestChoice, const HGCalBestChoiceDataPayload& fe_payload_TCsums_BestChoice, const HGCalBestChoiceDataPayload& fe_payload, const std::map & simhit_energies, const std::unordered_map& TC_simhit_energies) +void HGCalTriggerBestChoiceTester::fillModule(const std::vector& dataframes, + const std::vector>& linearized_dataframes, + const HGCalBestChoiceDataPayload& fe_payload_TCsums_woBestChoice, + const HGCalBestChoiceDataPayload& fe_payload_TCsums_BestChoice, + const HGCalBestChoiceDataPayload& fe_payload, + const std::map& simhit_energies, + const std::unordered_map& TC_simhit_energies) /*****************************************************************/ { - - // HGC cells part - size_t nHGCDigi = 0; - unsigned hgcCellModuleSum = 0; - // digis, cell based info - for(const auto& frame : dataframes) - { - uint32_t value = frame[2].data(); - nHGCDigi++; - hgcCellModuleSum += value; - hgcCellData_->Fill(value); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.id()); - if (sim_energy >0){ - hgcCellData_SimHitasso_->Fill(value); - hgcCellSimHits_->Fill(sim_energy); - hgcCellData_vsSimHits_->Fill(sim_energy,value); - } - } + // HGC cells part + size_t nHGCDigi = 0; + unsigned hgcCellModuleSum = 0; + // digis, cell based info + for (const auto& frame : dataframes) { + uint32_t value = frame[2].data(); + nHGCDigi++; + hgcCellModuleSum += value; + hgcCellData_->Fill(value); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.id()); + if (sim_energy > 0) { + hgcCellData_SimHitasso_->Fill(value); + hgcCellSimHits_->Fill(sim_energy); + hgcCellData_vsSimHits_->Fill(sim_energy, value); } - hgcCellsPerModule_->Fill(nHGCDigi); - hgcCellModuleSum_->Fill(hgcCellModuleSum); - - // linearized samples, cell based info - for(const auto& frame : linearized_dataframes){ - hgcCellData_linampl_-> Fill(frame.second); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.first); - if (sim_energy >0){ - hgcCellData_linampl_vsSimHits_-> Fill(sim_energy,frame.second); - hgcCellData_linampl_vsSimHits_zoom_-> Fill(sim_energy,frame.second); - } + } + } + hgcCellsPerModule_->Fill(nHGCDigi); + hgcCellModuleSum_->Fill(hgcCellModuleSum); + + // linearized samples, cell based info + for (const auto& frame : linearized_dataframes) { + hgcCellData_linampl_->Fill(frame.second); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.first); + if (sim_energy > 0) { + hgcCellData_linampl_vsSimHits_->Fill(sim_energy, frame.second); + hgcCellData_linampl_vsSimHits_zoom_->Fill(sim_energy, frame.second); } } - - // trigger cells part - // after sum, no best choice, no encode/decode - int icell_noBestChoice = 0; - for(const auto& tc : fe_payload_TCsums_woBestChoice.payload) - { - if(tc>0) - { - triggerCellData_noBestChoice_->Fill(tc); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(icell_noBestChoice) >0){ - triggerCellSimHits_noBestChoice_->Fill(TC_simhit_energies.at(icell_noBestChoice)); - triggerCellData_noBestChoice_vsSimHits_->Fill(TC_simhit_energies.at(icell_noBestChoice),tc); - } - } + } + + // trigger cells part + // after sum, no best choice, no encode/decode + int icell_noBestChoice = 0; + for (const auto& tc : fe_payload_TCsums_woBestChoice.payload) { + if (tc > 0) { + triggerCellData_noBestChoice_->Fill(tc); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(icell_noBestChoice) > 0) { + triggerCellSimHits_noBestChoice_->Fill(TC_simhit_energies.at(icell_noBestChoice)); + triggerCellData_noBestChoice_vsSimHits_->Fill(TC_simhit_energies.at(icell_noBestChoice), tc); } - icell_noBestChoice++; + } } - - // after sum, best choice, no encode/decode - int icell_BestChoice = 0; - for(const auto& tc : fe_payload_TCsums_BestChoice.payload) - { - if(tc>0) - { - triggerCellData_BestChoice_->Fill(tc); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(icell_BestChoice)>0) triggerCellData_BestChoice_vsSimHits_->Fill(TC_simhit_energies.at(icell_BestChoice),tc); - } - } - icell_BestChoice++; + icell_noBestChoice++; + } + + // after sum, best choice, no encode/decode + int icell_BestChoice = 0; + for (const auto& tc : fe_payload_TCsums_BestChoice.payload) { + if (tc > 0) { + triggerCellData_BestChoice_->Fill(tc); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(icell_BestChoice) > 0) + triggerCellData_BestChoice_vsSimHits_->Fill(TC_simhit_energies.at(icell_BestChoice), tc); + } } - - // after sum, best choice, encode/decode - int icell = 0; - size_t nFEDigi = 0; - unsigned triggerCellModuleSum = 0; - for(const auto& tc : fe_payload.payload) - { - uint32_t tcShifted = (tc<triggerCellTruncationBits()); - if(tc>0) - { - nFEDigi++; - triggerCellModuleSum += tcShifted; - triggerCellData_->Fill(tc); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(icell)>0) triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(icell),tc); - } - } - icell++; + icell_BestChoice++; + } + + // after sum, best choice, encode/decode + int icell = 0; + size_t nFEDigi = 0; + unsigned triggerCellModuleSum = 0; + for (const auto& tc : fe_payload.payload) { + uint32_t tcShifted = (tc << codec_->triggerCellTruncationBits()); + if (tc > 0) { + nFEDigi++; + triggerCellModuleSum += tcShifted; + triggerCellData_->Fill(tc); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(icell) > 0) + triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(icell), tc); } - triggerCellsPerModule_->Fill(nFEDigi); - triggerCellModuleSum_->Fill(triggerCellModuleSum); + } + icell++; + } + triggerCellsPerModule_->Fill(nFEDigi); + triggerCellModuleSum_->Fill(triggerCellModuleSum); } - + //define this as a plug-in DEFINE_FWK_MODULE(HGCalTriggerBestChoiceTester); diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTriggerCellTester.cc b/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTriggerCellTester.cc index fdf94dc6a4528..6cf3c0df80a49 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTriggerCellTester.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerBestChoiceTriggerCellTester.cc @@ -2,7 +2,6 @@ #include #include - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" @@ -34,515 +33,529 @@ #include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodecImpl.h" #include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodec.h" -#include -#include +#include +#include #include "TH2.h" - -class HGCalTriggerBestChoiceTriggerCellTester : public edm::EDAnalyzer -{ - public: - explicit HGCalTriggerBestChoiceTriggerCellTester(const edm::ParameterSet& ); - ~HGCalTriggerBestChoiceTriggerCellTester(); - - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - - private: - void checkSelectedCells(const edm::Event&, const edm::EventSetup&); - void rerunBestChoiceFragments(const edm::Event&, const edm::EventSetup&); - void fillModule(const std::vector&, const std::vector >&, const HGCalTriggerCellBestChoiceDataPayload&, const HGCalTriggerCellBestChoiceDataPayload&,const HGCalTriggerCellBestChoiceDataPayload&, const std::map &, const std::unordered_map& ); - - // inputs - edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; - bool is_Simhit_comp_; - edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; - // - edm::ESHandle triggerGeometry_; - std::unique_ptr codec_; - edm::Service fs_; - - // histos - TH1F* hgcCellData_; - TH1F* hgcCellData_SimHitasso_; - TH1F* hgcCellSimHits_; - TH2F* hgcCellData_vsSimHits_; - TH1F* hgcCellsPerModule_; - TH1F* hgcCellModuleSum_; - // - TH1F* hgcCellData_linampl_; - TH2F* hgcCellData_linampl_vsSimHits_; - TH2F* hgcCellData_linampl_vsSimHits_zoom_; - TH1F* triggerCellData_noBestChoice_; - TH2F* triggerCellData_noBestChoice_vsSimHits_; - TH1F* triggerCellSimHits_noBestChoice_; - TH1F* triggerCellData_BestChoice_; - TH2F* triggerCellData_BestChoice_vsSimHits_; - TH1F* triggerCellData_; - TH2F* triggerCellData_vsSimHits_; - TH1F* triggerCellsPerModule_; - TH1F* triggerCellModuleSum_; - // - TH2F* selectedCellsVsAllCells_ee_; - TH2F* energyLossVsNCells_ee_; - TH2F* selectedCellsVsAllCells_fh_; - TH2F* energyLossVsNCells_fh_; - // - +class HGCalTriggerBestChoiceTriggerCellTester : public edm::EDAnalyzer { +public: + explicit HGCalTriggerBestChoiceTriggerCellTester(const edm::ParameterSet&); + ~HGCalTriggerBestChoiceTriggerCellTester(); + + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void checkSelectedCells(const edm::Event&, const edm::EventSetup&); + void rerunBestChoiceFragments(const edm::Event&, const edm::EventSetup&); + void fillModule(const std::vector&, + const std::vector>&, + const HGCalTriggerCellBestChoiceDataPayload&, + const HGCalTriggerCellBestChoiceDataPayload&, + const HGCalTriggerCellBestChoiceDataPayload&, + const std::map&, + const std::unordered_map&); + + // inputs + edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; + bool is_Simhit_comp_; + edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; + // + edm::ESHandle triggerGeometry_; + std::unique_ptr codec_; + edm::Service fs_; + + // histos + TH1F* hgcCellData_; + TH1F* hgcCellData_SimHitasso_; + TH1F* hgcCellSimHits_; + TH2F* hgcCellData_vsSimHits_; + TH1F* hgcCellsPerModule_; + TH1F* hgcCellModuleSum_; + // + TH1F* hgcCellData_linampl_; + TH2F* hgcCellData_linampl_vsSimHits_; + TH2F* hgcCellData_linampl_vsSimHits_zoom_; + TH1F* triggerCellData_noBestChoice_; + TH2F* triggerCellData_noBestChoice_vsSimHits_; + TH1F* triggerCellSimHits_noBestChoice_; + TH1F* triggerCellData_BestChoice_; + TH2F* triggerCellData_BestChoice_vsSimHits_; + TH1F* triggerCellData_; + TH2F* triggerCellData_vsSimHits_; + TH1F* triggerCellsPerModule_; + TH1F* triggerCellModuleSum_; + // + TH2F* selectedCellsVsAllCells_ee_; + TH2F* energyLossVsNCells_ee_; + TH2F* selectedCellsVsAllCells_fh_; + TH2F* energyLossVsNCells_fh_; + // }; - -HGCalTriggerBestChoiceTriggerCellTester::HGCalTriggerBestChoiceTriggerCellTester(const edm::ParameterSet& conf): - inputee_(consumes(conf.getParameter("eeDigis"))), - inputfh_(consumes(conf.getParameter("fhDigis"))), - //inputbh_(consumes(conf.getParameter("bhDigis"))), - inputbeall_(consumes(conf.getParameter("beTriggerCellsAll"))), - inputbeselect_(consumes(conf.getParameter("beTriggerCellsSelect"))), - is_Simhit_comp_(conf.getParameter("isSimhitComp")), - SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), - SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) - // SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) +HGCalTriggerBestChoiceTriggerCellTester::HGCalTriggerBestChoiceTriggerCellTester(const edm::ParameterSet& conf) + : inputee_(consumes(conf.getParameter("eeDigis"))), + inputfh_(consumes(conf.getParameter("fhDigis"))), + //inputbh_(consumes(conf.getParameter("bhDigis"))), + inputbeall_(consumes(conf.getParameter("beTriggerCellsAll"))), + inputbeselect_( + consumes(conf.getParameter("beTriggerCellsSelect"))), + is_Simhit_comp_(conf.getParameter("isSimhitComp")), + SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), + SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) +// SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) { - //setup FE codec - const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); - codec_.reset( new HGCalTriggerCellBestChoiceCodecImpl(feCodecConfig) ); - - // initialize output trees - // HGC Cells - hgcCellData_ = fs_->make("hgcCellData","Cell values", 1000, 0., 2000.); - if (is_Simhit_comp_) - { - hgcCellData_SimHitasso_ = fs_->make("hgcCellData_SimHitasso_","Cell values with an associated SimHit", 1000, 0, 2000.); - hgcCellSimHits_ = fs_->make("hgcCellSimHits_","Cell simhit energies", 500, 0, 0.16); - hgcCellData_vsSimHits_ = fs_->make("hgcCellData_vsSimHits_","Cell values vs simhit energies", 500,0,0.16,1000, 0., 2000.); - } - hgcCellsPerModule_ = fs_->make("hgcCellsPerModule","Number of cells per module", 128, 0., 128.); - hgcCellModuleSum_ = fs_->make("hgcCellModuleSum","Cell sum in modules", 1000, 0., 3000.); - // - hgcCellData_linampl_ = fs_->make("hgcCellData_linampl_","Cell linearized amplitudes values All", 1000, 0, 70000); - if (is_Simhit_comp_) - { - hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_","Cell linearized amplitudes vs simhit energies",500,0,0.16,1000,0,70000); - hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_","Cell linearized amplitudes vssimhit energies, zoomed",1000,0,0.002,1000,0,1000); - } - - // HGC Trigger cells - triggerCellData_noBestChoice_ = fs_->make("triggerCellData_noBestChoice_","Trigger cell values, no best choice", 1000, 0., 70000.); - if (is_Simhit_comp_) - { - triggerCellData_noBestChoice_vsSimHits_ = fs_->make("triggerCellData_noBestChoice_vsSimHits_","Trigger cell values vs simhit energies, no best choice", 500,0,0.16,1000, 0., 70000.); - triggerCellSimHits_noBestChoice_ = fs_->make("triggerCellSimHits_noBestChoice","Trigger cell simhit energies, no best choice", 500, 0, 0.16); - } - triggerCellData_BestChoice_ = fs_->make("triggerCellData_BestChoice_","Trigger cell values, best choice", 1000, 0., 70000.); - if (is_Simhit_comp_) triggerCellData_BestChoice_vsSimHits_ = fs_->make("triggerCellData_BestChoice_vsSimHits_","Trigger cell values vs simhit energies, best choice", 500,0,0.16,1000, 0., 70000.); - triggerCellData_ = fs_->make("triggerCellData","Trigger cell values", 1100, 0., 1100.); - if (is_Simhit_comp_) - { - triggerCellData_vsSimHits_ = fs_->make("triggerCellData_vsSimHits_","Trigger cell values vs simhit energies", 500,0,0.16,1100, 0., 1100.); - } - triggerCellsPerModule_ = fs_->make("triggerCellsPerModule","Number of trigger cells per module", 64, 0., 64.); - triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum","Trigger cell sum in modules", 1000, 0., 10000.); - // - selectedCellsVsAllCells_ee_ = fs_->make("selectedCellsVsAllCells_ee","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_ee_ = fs_->make("energyLossVsNCells_ee","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - selectedCellsVsAllCells_fh_ = fs_->make("selectedCellsVsAllCells_fh","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_fh_ = fs_->make("energyLossVsNCells_fh","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - + //setup FE codec + const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); + codec_.reset(new HGCalTriggerCellBestChoiceCodecImpl(feCodecConfig)); + + // initialize output trees + // HGC Cells + hgcCellData_ = fs_->make("hgcCellData", "Cell values", 1000, 0., 2000.); + if (is_Simhit_comp_) { + hgcCellData_SimHitasso_ = + fs_->make("hgcCellData_SimHitasso_", "Cell values with an associated SimHit", 1000, 0, 2000.); + hgcCellSimHits_ = fs_->make("hgcCellSimHits_", "Cell simhit energies", 500, 0, 0.16); + hgcCellData_vsSimHits_ = + fs_->make("hgcCellData_vsSimHits_", "Cell values vs simhit energies", 500, 0, 0.16, 1000, 0., 2000.); + } + hgcCellsPerModule_ = fs_->make("hgcCellsPerModule", "Number of cells per module", 128, 0., 128.); + hgcCellModuleSum_ = fs_->make("hgcCellModuleSum", "Cell sum in modules", 1000, 0., 3000.); + // + hgcCellData_linampl_ = + fs_->make("hgcCellData_linampl_", "Cell linearized amplitudes values All", 1000, 0, 70000); + if (is_Simhit_comp_) { + hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_", + "Cell linearized amplitudes vs simhit energies", + 500, + 0, + 0.16, + 1000, + 0, + 70000); + hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_", + "Cell linearized amplitudes vssimhit energies, zoomed", + 1000, + 0, + 0.002, + 1000, + 0, + 1000); + } + + // HGC Trigger cells + triggerCellData_noBestChoice_ = + fs_->make("triggerCellData_noBestChoice_", "Trigger cell values, no best choice", 1000, 0., 70000.); + if (is_Simhit_comp_) { + triggerCellData_noBestChoice_vsSimHits_ = fs_->make("triggerCellData_noBestChoice_vsSimHits_", + "Trigger cell values vs simhit energies, no best choice", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellSimHits_noBestChoice_ = fs_->make( + "triggerCellSimHits_noBestChoice", "Trigger cell simhit energies, no best choice", 500, 0, 0.16); + } + triggerCellData_BestChoice_ = + fs_->make("triggerCellData_BestChoice_", "Trigger cell values, best choice", 1000, 0., 70000.); + if (is_Simhit_comp_) + triggerCellData_BestChoice_vsSimHits_ = fs_->make("triggerCellData_BestChoice_vsSimHits_", + "Trigger cell values vs simhit energies, best choice", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellData_ = fs_->make("triggerCellData", "Trigger cell values", 1100, 0., 1100.); + if (is_Simhit_comp_) { + triggerCellData_vsSimHits_ = fs_->make( + "triggerCellData_vsSimHits_", "Trigger cell values vs simhit energies", 500, 0, 0.16, 1100, 0., 1100.); + } + triggerCellsPerModule_ = fs_->make("triggerCellsPerModule", "Number of trigger cells per module", 64, 0., 64.); + triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum", "Trigger cell sum in modules", 1000, 0., 10000.); + // + selectedCellsVsAllCells_ee_ = fs_->make( + "selectedCellsVsAllCells_ee", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_ee_ = fs_->make( + "energyLossVsNCells_ee", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); + selectedCellsVsAllCells_fh_ = fs_->make( + "selectedCellsVsAllCells_fh", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_fh_ = fs_->make( + "energyLossVsNCells_fh", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); } +HGCalTriggerBestChoiceTriggerCellTester::~HGCalTriggerBestChoiceTriggerCellTester() {} - -HGCalTriggerBestChoiceTriggerCellTester::~HGCalTriggerBestChoiceTriggerCellTester() -{ -} - -void HGCalTriggerBestChoiceTriggerCellTester::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) -{ - es.get().get(triggerGeometry_); +void HGCalTriggerBestChoiceTriggerCellTester::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get(triggerGeometry_); } -void HGCalTriggerBestChoiceTriggerCellTester::analyze(const edm::Event& e, - const edm::EventSetup& es) -{ - checkSelectedCells(e, es); - rerunBestChoiceFragments(e, es); - +void HGCalTriggerBestChoiceTriggerCellTester::analyze(const edm::Event& e, const edm::EventSetup& es) { + checkSelectedCells(e, es); + rerunBestChoiceFragments(e, es); } -void HGCalTriggerBestChoiceTriggerCellTester::checkSelectedCells(const edm::Event& e, - const edm::EventSetup& es) -{ - edm::Handle be_triggercells_all_h; - edm::Handle be_triggercells_select_h; - e.getByToken(inputbeall_,be_triggercells_all_h); - e.getByToken(inputbeselect_,be_triggercells_select_h); - - const l1t::HGCalTriggerCellBxCollection& be_triggercells_all = *be_triggercells_all_h; - const l1t::HGCalTriggerCellBxCollection& be_triggercells_select = *be_triggercells_select_h; - - // store trigger cells module by module. tuple = zside,subdet,layer,module - std::map, std::vector> module_triggercells_all; - for(auto cl_itr=be_triggercells_all.begin(0); cl_itr!=be_triggercells_all.end(0); cl_itr++) - { - const l1t::HGCalTriggerCell& triggercell = *cl_itr; - uint32_t zside = triggercell.eta()<0. ? 0 : 1; - uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); - uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); - uint32_t layer = HGCalDetId(triggercell.detId()).layer(); - auto itr_insert = module_triggercells_all.emplace( std::make_tuple(zside, subdet, layer, module), std::vector()); - itr_insert.first->second.emplace_back(triggercell.hwPt()); - } - std::map, std::vector> module_triggercells_select; - for(auto cl_itr=be_triggercells_select.begin(0); cl_itr!=be_triggercells_select.end(0); cl_itr++) - { - const l1t::HGCalTriggerCell& triggercell = *cl_itr; - uint32_t zside = triggercell.eta()<0. ? 0 : 1; - uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); - uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); - uint32_t layer = HGCalDetId(triggercell.detId()).layer(); - auto itr_insert = module_triggercells_select.emplace( std::make_tuple(zside, subdet, layer, module), std::vector()); - itr_insert.first->second.emplace_back(triggercell.hwPt()); +void HGCalTriggerBestChoiceTriggerCellTester::checkSelectedCells(const edm::Event& e, const edm::EventSetup& es) { + edm::Handle be_triggercells_all_h; + edm::Handle be_triggercells_select_h; + e.getByToken(inputbeall_, be_triggercells_all_h); + e.getByToken(inputbeselect_, be_triggercells_select_h); + + const l1t::HGCalTriggerCellBxCollection& be_triggercells_all = *be_triggercells_all_h; + const l1t::HGCalTriggerCellBxCollection& be_triggercells_select = *be_triggercells_select_h; + + // store trigger cells module by module. tuple = zside,subdet,layer,module + std::map, std::vector> module_triggercells_all; + for (auto cl_itr = be_triggercells_all.begin(0); cl_itr != be_triggercells_all.end(0); cl_itr++) { + const l1t::HGCalTriggerCell& triggercell = *cl_itr; + uint32_t zside = triggercell.eta() < 0. ? 0 : 1; + uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); + uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); + uint32_t layer = HGCalDetId(triggercell.detId()).layer(); + auto itr_insert = + module_triggercells_all.emplace(std::make_tuple(zside, subdet, layer, module), std::vector()); + itr_insert.first->second.emplace_back(triggercell.hwPt()); + } + std::map, std::vector> module_triggercells_select; + for (auto cl_itr = be_triggercells_select.begin(0); cl_itr != be_triggercells_select.end(0); cl_itr++) { + const l1t::HGCalTriggerCell& triggercell = *cl_itr; + uint32_t zside = triggercell.eta() < 0. ? 0 : 1; + uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); + uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); + uint32_t layer = HGCalDetId(triggercell.detId()).layer(); + auto itr_insert = + module_triggercells_select.emplace(std::make_tuple(zside, subdet, layer, module), std::vector()); + itr_insert.first->second.emplace_back(triggercell.hwPt()); + } + + // Compare 'all' and 'selected' trigger cells, module by module + for (const auto& module_cells : module_triggercells_all) { + const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); + if (module_cells_select_itr == module_triggercells_select.end()) { + stringstream error; + error << "ERROR: Cannot find module for selected cells\n"; + error << " Trigger cell values contained in module:\n"; + for (const auto& value : module_cells.second) { + error << value << " "; + } + error << "\n"; + edm::LogError("HGCalTriggerBestChoiceTriggerCellTester") << error.str(); + continue; } - - // Compare 'all' and 'selected' trigger cells, module by module - for(const auto& module_cells : module_triggercells_all) - { - const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); - if(module_cells_select_itr==module_triggercells_select.end()) - { - stringstream error; - error << "ERROR: Cannot find module for selected cells\n"; - error <<" Trigger cell values contained in module:\n"; - for(const auto& value : module_cells.second) - { - error<second.size(); + uint32_t energy_all = 0; + uint32_t energy_select = 0; + for (const auto& energy : module_cells.second) + energy_all += energy; + for (const auto& energy : module_cells_select_itr->second) + energy_select += energy; + if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCEE) { + selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select / (double)energy_all); + if (energy_all > 0 && ncells_all < codec_->nData() && energy_select < energy_all) { + stringstream error; + error << "ERROR: N(cells)second.size(); - uint32_t energy_all = 0; - uint32_t energy_select = 0; - for(const auto& energy : module_cells.second) energy_all += energy; - for(const auto& energy : module_cells_select_itr->second) energy_select += energy; - if(std::get<1>(module_cells.first)==ForwardSubdetector::HGCEE) - { - selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select/(double)energy_all); - if(energy_all>0 && ncells_allnData() && energy_selectsecond) - { - error<(module_cells.first)==ForwardSubdetector::HGCHEF) - { - selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select/(double)energy_all); + error << "\n"; + error << " Selected trigger cells values contained in module:\n "; + for (const auto& value : module_cells_select_itr->second) { + error << value << " "; } + error << "\n"; + edm::LogError("HGCalTriggerBestChoiceTriggerCellTester") << error.str(); + } + } else if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCHEF) { + selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select / (double)energy_all); } - + } } -void HGCalTriggerBestChoiceTriggerCellTester::rerunBestChoiceFragments(const edm::Event& e, - const edm::EventSetup& es) -{ - // retrieve digi collections - edm::Handle ee_digis_h; - edm::Handle fh_digis_h; - e.getByToken(inputee_,ee_digis_h); - e.getByToken(inputfh_,fh_digis_h); - - const HGCalDigiCollection& ee_digis = *ee_digis_h; - const HGCalDigiCollection& fh_digis = *fh_digis_h; - - HGCalTriggerCellBestChoiceDataPayload data; - - // retrieve simhit collections - std::map simhit_energies; - if (is_Simhit_comp_) { - edm::Handle ee_simhits_h; - e.getByToken(SimHits_inputee_,ee_simhits_h); - const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; - edm::Handle fh_simhits_h; - e.getByToken(SimHits_inputfh_,fh_simhits_h); - const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; - - // simhit/digi association EE - HGCalDetId digiid, simid; - int layer=0,cell=0, sec=0, subsec=0, zp=0,subdet=0; - ForwardSubdetector mysubdet; - HGCalDetId recoDetId ; - int n_hits_asso=0; - - // create a map containing all simhit energies - std::unordered_map simhits; - for( const auto& simhit : ee_simhits ) { - simid = (HGCalDetId)simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->eeTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); - } - // find simhit energies associated to digis - for(const auto& data : ee_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; - } - - // simhit/digi association FH - layer=0; - cell=0; - sec=0; - subsec=0; - zp=0; - subdet=0; - int n_hits_asso_fh=0; - - // create a map containing all simhit energies - simhits.clear(); - for( const auto& simhit : fh_simhits ) { - simid = (HGCalDetId) simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->fhTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); - } - // find simhit energies associated to digis - for(const auto& data : fh_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso_fh++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; - } +void HGCalTriggerBestChoiceTriggerCellTester::rerunBestChoiceFragments(const edm::Event& e, const edm::EventSetup& es) { + // retrieve digi collections + edm::Handle ee_digis_h; + edm::Handle fh_digis_h; + e.getByToken(inputee_, ee_digis_h); + e.getByToken(inputfh_, fh_digis_h); + + const HGCalDigiCollection& ee_digis = *ee_digis_h; + const HGCalDigiCollection& fh_digis = *fh_digis_h; + + HGCalTriggerCellBestChoiceDataPayload data; + + // retrieve simhit collections + std::map simhit_energies; + if (is_Simhit_comp_) { + edm::Handle ee_simhits_h; + e.getByToken(SimHits_inputee_, ee_simhits_h); + const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; + edm::Handle fh_simhits_h; + e.getByToken(SimHits_inputfh_, fh_simhits_h); + const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; + + // simhit/digi association EE + HGCalDetId digiid, simid; + int layer = 0, cell = 0, sec = 0, subsec = 0, zp = 0, subdet = 0; + ForwardSubdetector mysubdet; + HGCalDetId recoDetId; + int n_hits_asso = 0; + + // create a map containing all simhit energies + std::unordered_map simhits; + for (const auto& simhit : ee_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->eeTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; + } + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); + } + // find simhit energies associated to digis + for (const auto& data : ee_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso++; + hit_energy = itr->second; + } + simhit_energies[digiid] = hit_energy; + } + // simhit/digi association FH + layer = 0; + cell = 0; + sec = 0; + subsec = 0; + zp = 0; + subdet = 0; + int n_hits_asso_fh = 0; + + // create a map containing all simhit energies + simhits.clear(); + for (const auto& simhit : fh_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->fhTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; + } + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); } - // Find modules containing hits and prepare list of hits for each module - std::unordered_map> hit_modules_ee; - for(const auto& eedata : ee_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); - auto itr_insert = hit_modules_ee.emplace(module,std::vector()); - itr_insert.first->second.push_back(eedata); + // find simhit energies associated to digis + for (const auto& data : fh_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso_fh++; + hit_energy = itr->second; + } + simhit_energies[digiid] = hit_energy; } - std::unordered_map> hit_modules_fh; - for(const auto& fhdata : fh_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); - auto itr_insert = hit_modules_fh.emplace(module, std::vector()); - itr_insert.first->second.push_back(fhdata); + } + // Find modules containing hits and prepare list of hits for each module + std::unordered_map> hit_modules_ee; + for (const auto& eedata : ee_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); + auto itr_insert = hit_modules_ee.emplace(module, std::vector()); + itr_insert.first->second.push_back(eedata); + } + std::unordered_map> hit_modules_fh; + for (const auto& fhdata : fh_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); + auto itr_insert = hit_modules_fh.emplace(module, std::vector()); + itr_insert.first->second.push_back(fhdata); + } + // loop on modules containing hits and call front-end processing + for (const auto& module_hits : hit_modules_ee) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over EE and fill digis belonging to that module + for (const auto& eedata : module_hits.second) { + dataframes.emplace_back(eedata.id()); + for (int i = 0; i < eedata.size(); i++) { + dataframes.back().setSample(i, eedata.sample(i)); + } } - // loop on modules containing hits and call front-end processing - for( const auto& module_hits : hit_modules_ee ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over EE and fill digis belonging to that module - for(const auto& eedata : module_hits.second) - { - dataframes.emplace_back(eedata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(tc, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(tc)+=simenergy; - } - } - } - // Best choice encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalTriggerCellBestChoiceDataPayload data_TCsums_woBestChoice = data; - codec_->bestChoiceSelect(data); - HGCalTriggerCellBestChoiceDataPayload data_TCsums_BestChoice = data; - std::vector dataword = codec_->encode(data, *triggerGeometry_); - HGCalTriggerCellBestChoiceDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); - fillModule(dataframes, linearized_dataframes, data_TCsums_woBestChoice,data_TCsums_BestChoice, datadecoded, simhit_energies, TC_simhit_energies); - - } //end loop on EE modules - for( const auto& module_hits : hit_modules_fh ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over FH digis and fill digis belonging to that module - for(const auto& fhdata : module_hits.second) - { - dataframes.emplace_back(fhdata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(tc, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(tc)+=simenergy; - } - } - } - // Best choice encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalTriggerCellBestChoiceDataPayload data_TCsums_woBestChoice = data; - codec_->bestChoiceSelect(data); - HGCalTriggerCellBestChoiceDataPayload data_TCsums_BestChoice = data; - std::vector dataword = codec_->encode(data, *triggerGeometry_); - HGCalTriggerCellBestChoiceDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); - fillModule(dataframes, linearized_dataframes, data_TCsums_woBestChoice,data_TCsums_BestChoice, datadecoded, simhit_energies, TC_simhit_energies); - } //end loop on FH modules - - -} - - -void HGCalTriggerBestChoiceTriggerCellTester::fillModule( const std::vector& dataframes, const std::vector >& linearized_dataframes, const HGCalTriggerCellBestChoiceDataPayload& fe_payload_TCsums_woBestChoice, const HGCalTriggerCellBestChoiceDataPayload& fe_payload_TCsums_BestChoice, const HGCalTriggerCellBestChoiceDataPayload& fe_payload, const std::map & simhit_energies, const std::unordered_map& TC_simhit_energies) -{ - - // HGC cells part - size_t nHGCDigi = 0; - unsigned hgcCellModuleSum = 0; - // digis, cell based info - for(const auto& frame : dataframes) - { - uint32_t value = frame[2].data(); - nHGCDigi++; - hgcCellModuleSum += value; - hgcCellData_->Fill(value); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.id()); - if (sim_energy >0){ - hgcCellData_SimHitasso_->Fill(value); - hgcCellSimHits_->Fill(sim_energy); - hgcCellData_vsSimHits_->Fill(sim_energy,value); - } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; + if (is_Simhit_comp_) { + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(tc, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(tc) += simenergy; } + } } - hgcCellsPerModule_->Fill(nHGCDigi); - hgcCellModuleSum_->Fill(hgcCellModuleSum); - - // linearized samples, cell based info - for(const auto& frame : linearized_dataframes){ - hgcCellData_linampl_-> Fill(frame.second); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.first); - if (sim_energy >0){ - hgcCellData_linampl_vsSimHits_-> Fill(sim_energy,frame.second); - hgcCellData_linampl_vsSimHits_zoom_-> Fill(sim_energy,frame.second); - } - } + // Best choice encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalTriggerCellBestChoiceDataPayload data_TCsums_woBestChoice = data; + codec_->bestChoiceSelect(data); + HGCalTriggerCellBestChoiceDataPayload data_TCsums_BestChoice = data; + std::vector dataword = codec_->encode(data, *triggerGeometry_); + HGCalTriggerCellBestChoiceDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woBestChoice, + data_TCsums_BestChoice, + datadecoded, + simhit_energies, + TC_simhit_energies); + + } //end loop on EE modules + for (const auto& module_hits : hit_modules_fh) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over FH digis and fill digis belonging to that module + for (const auto& fhdata : module_hits.second) { + dataframes.emplace_back(fhdata.id()); + for (int i = 0; i < fhdata.size(); i++) { + dataframes.back().setSample(i, fhdata.sample(i)); + } } - - // trigger cells part - // after sum, no best choice, no encode/decode - for(const auto& tc : fe_payload_TCsums_woBestChoice.payload) - { - if(tc.hwPt()>0) - { - triggerCellData_noBestChoice_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId()) >0){ - triggerCellSimHits_noBestChoice_->Fill(TC_simhit_energies.at(tc.detId())); - triggerCellData_noBestChoice_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } - } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; + if (is_Simhit_comp_) { + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(tc, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(tc) += simenergy; } + } } + // Best choice encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalTriggerCellBestChoiceDataPayload data_TCsums_woBestChoice = data; + codec_->bestChoiceSelect(data); + HGCalTriggerCellBestChoiceDataPayload data_TCsums_BestChoice = data; + std::vector dataword = codec_->encode(data, *triggerGeometry_); + HGCalTriggerCellBestChoiceDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woBestChoice, + data_TCsums_BestChoice, + datadecoded, + simhit_energies, + TC_simhit_energies); + } //end loop on FH modules +} - // after sum, best choice, no encode/decode - for(const auto& tc : fe_payload_TCsums_BestChoice.payload) - { - if(tc.hwPt()>0) - { - triggerCellData_BestChoice_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId())>0) triggerCellData_BestChoice_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } - } +void HGCalTriggerBestChoiceTriggerCellTester::fillModule( + const std::vector& dataframes, + const std::vector>& linearized_dataframes, + const HGCalTriggerCellBestChoiceDataPayload& fe_payload_TCsums_woBestChoice, + const HGCalTriggerCellBestChoiceDataPayload& fe_payload_TCsums_BestChoice, + const HGCalTriggerCellBestChoiceDataPayload& fe_payload, + const std::map& simhit_energies, + const std::unordered_map& TC_simhit_energies) { + // HGC cells part + size_t nHGCDigi = 0; + unsigned hgcCellModuleSum = 0; + // digis, cell based info + for (const auto& frame : dataframes) { + uint32_t value = frame[2].data(); + nHGCDigi++; + hgcCellModuleSum += value; + hgcCellData_->Fill(value); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.id()); + if (sim_energy > 0) { + hgcCellData_SimHitasso_->Fill(value); + hgcCellSimHits_->Fill(sim_energy); + hgcCellData_vsSimHits_->Fill(sim_energy, value); + } } + } + hgcCellsPerModule_->Fill(nHGCDigi); + hgcCellModuleSum_->Fill(hgcCellModuleSum); - // after sum, best choice, encode/decode - size_t nFEDigi = 0; - unsigned triggerCellModuleSum = 0; - for(const auto& tc : fe_payload.payload) - { - uint32_t tcShifted = (tc.hwPt()<triggerCellTruncationBits()); - if(tc.hwPt()>0) - { - nFEDigi++; - triggerCellModuleSum += tcShifted; - triggerCellData_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId())>0) triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } + // linearized samples, cell based info + for (const auto& frame : linearized_dataframes) { + hgcCellData_linampl_->Fill(frame.second); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.first); + if (sim_energy > 0) { + hgcCellData_linampl_vsSimHits_->Fill(sim_energy, frame.second); + hgcCellData_linampl_vsSimHits_zoom_->Fill(sim_energy, frame.second); + } + } + } + + // trigger cells part + // after sum, no best choice, no encode/decode + for (const auto& tc : fe_payload_TCsums_woBestChoice.payload) { + if (tc.hwPt() > 0) { + triggerCellData_noBestChoice_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) { + triggerCellSimHits_noBestChoice_->Fill(TC_simhit_energies.at(tc.detId())); + triggerCellData_noBestChoice_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); } + } + } + } + + // after sum, best choice, no encode/decode + for (const auto& tc : fe_payload_TCsums_BestChoice.payload) { + if (tc.hwPt() > 0) { + triggerCellData_BestChoice_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) + triggerCellData_BestChoice_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); + } + } + } + + // after sum, best choice, encode/decode + size_t nFEDigi = 0; + unsigned triggerCellModuleSum = 0; + for (const auto& tc : fe_payload.payload) { + uint32_t tcShifted = (tc.hwPt() << codec_->triggerCellTruncationBits()); + if (tc.hwPt() > 0) { + nFEDigi++; + triggerCellModuleSum += tcShifted; + triggerCellData_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) + triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); + } } - triggerCellsPerModule_->Fill(nFEDigi); - triggerCellModuleSum_->Fill(triggerCellModuleSum); + } + triggerCellsPerModule_->Fill(nFEDigi); + triggerCellModuleSum_->Fill(triggerCellModuleSum); } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTester.cc b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTester.cc index 4de790ca63cec..d70e8ddac1475 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTester.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTester.cc @@ -4,7 +4,6 @@ #include "TTree.h" - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" @@ -27,995 +26,952 @@ #include -namespace -{ - template - struct array_deleter - { - void operator () (T* arr) { delete [] arr; } - }; -} - - -class HGCalTriggerGeomTester : public edm::EDAnalyzer -{ - public: - explicit HGCalTriggerGeomTester(const edm::ParameterSet& ); - ~HGCalTriggerGeomTester(); - - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - - private: - void fillTriggerGeometry(); - void checkMappingConsistency(); - void checkNeighborConsistency(); - void setTreeModuleSize(const size_t n); - void setTreeModuleCellSize(const size_t n); - void setTreeTriggerCellSize(const size_t n); - void setTreeTriggerCellNeighborSize(const size_t n); - - edm::ESHandle triggerGeometry_; - edm::Service fs_; - bool no_trigger_; - bool no_neighbors_; - TTree* treeModules_; - TTree* treeTriggerCells_; - TTree* treeCells_; - TTree* treeCellsBH_; - // tree variables - int moduleId_ ; - int moduleSide_ ; - int moduleSubdet_ ; - int moduleLayer_ ; - int module_ ; - float moduleX_ ; - float moduleY_ ; - float moduleZ_ ; - int moduleTC_N_ ; - std::shared_ptr moduleTC_id_ ; - std::shared_ptr moduleTC_zside_ ; - std::shared_ptr moduleTC_subdet_; - std::shared_ptr moduleTC_layer_ ; - std::shared_ptr moduleTC_wafer_; - std::shared_ptr moduleTC_waferType_; - std::shared_ptr moduleTC_cell_ ; - std::shared_ptr moduleTC_x_ ; - std::shared_ptr moduleTC_y_ ; - std::shared_ptr moduleTC_z_ ; - int moduleCell_N_ ; - std::shared_ptr moduleCell_id_ ; - std::shared_ptr moduleCell_zside_ ; - std::shared_ptr moduleCell_subdet_; - std::shared_ptr moduleCell_layer_ ; - std::shared_ptr moduleCell_wafer_; - std::shared_ptr moduleCell_cell_ ; - std::shared_ptr moduleCell_x_ ; - std::shared_ptr moduleCell_y_ ; - std::shared_ptr moduleCell_z_ ; - int triggerCellId_ ; - int triggerCellSide_ ; - int triggerCellSubdet_ ; - int triggerCellLayer_ ; - int triggerCellWafer_ ; - int triggerCellWaferType_ ; - int triggerCell_ ; - float triggerCellX_ ; - float triggerCellY_ ; - float triggerCellZ_ ; - int triggerCellNeighbor_N_; - std::shared_ptr triggerCellNeighbor_id_ ; - std::shared_ptr triggerCellNeighbor_zside_ ; - std::shared_ptr triggerCellNeighbor_subdet_; - std::shared_ptr triggerCellNeighbor_layer_ ; - std::shared_ptr triggerCellNeighbor_wafer_; - std::shared_ptr triggerCellNeighbor_cell_ ; - std::shared_ptr triggerCellNeighbor_distance_ ; - int triggerCellCell_N_ ; - std::shared_ptr triggerCellCell_id_ ; - std::shared_ptr triggerCellCell_zside_ ; - std::shared_ptr triggerCellCell_subdet_; - std::shared_ptr triggerCellCell_layer_ ; - std::shared_ptr triggerCellCell_wafer_; - std::shared_ptr triggerCellCell_cell_ ; - std::shared_ptr triggerCellCell_ieta_ ; - std::shared_ptr triggerCellCell_iphi_ ; - std::shared_ptr triggerCellCell_x_ ; - std::shared_ptr triggerCellCell_y_ ; - std::shared_ptr triggerCellCell_z_ ; - int cellId_ ; - int cellSide_ ; - int cellSubdet_ ; - int cellLayer_ ; - int cellWafer_ ; - int cellWaferType_ ; - int cellWaferRow_; - int cellWaferColumn_; - int cell_ ; - float cellX_ ; - float cellY_ ; - float cellZ_ ; - float cellX1_ ; - float cellY1_ ; - float cellX2_ ; - float cellY2_ ; - float cellX3_ ; - float cellY3_ ; - float cellX4_ ; - float cellY4_ ; - int cellBHId_ ; - int cellBHSide_ ; - int cellBHSubdet_ ; - int cellBHLayer_ ; - int cellBHIEta_ ; - int cellBHIPhi_ ; - float cellBHEta_ ; - float cellBHPhi_ ; - float cellBHX_ ; - float cellBHY_ ; - float cellBHZ_ ; - float cellBHX1_ ; - float cellBHY1_ ; - float cellBHX2_ ; - float cellBHY2_ ; - float cellBHX3_ ; - float cellBHY3_ ; - float cellBHX4_ ; - float cellBHY4_ ; - +namespace { + template + struct array_deleter { + void operator()(T* arr) { delete[] arr; } + }; +} // namespace + +class HGCalTriggerGeomTester : public edm::EDAnalyzer { +public: + explicit HGCalTriggerGeomTester(const edm::ParameterSet&); + ~HGCalTriggerGeomTester(); + + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void fillTriggerGeometry(); + void checkMappingConsistency(); + void checkNeighborConsistency(); + void setTreeModuleSize(const size_t n); + void setTreeModuleCellSize(const size_t n); + void setTreeTriggerCellSize(const size_t n); + void setTreeTriggerCellNeighborSize(const size_t n); + + edm::ESHandle triggerGeometry_; + edm::Service fs_; + bool no_trigger_; + bool no_neighbors_; + TTree* treeModules_; + TTree* treeTriggerCells_; + TTree* treeCells_; + TTree* treeCellsBH_; + // tree variables + int moduleId_; + int moduleSide_; + int moduleSubdet_; + int moduleLayer_; + int module_; + float moduleX_; + float moduleY_; + float moduleZ_; + int moduleTC_N_; + std::shared_ptr moduleTC_id_; + std::shared_ptr moduleTC_zside_; + std::shared_ptr moduleTC_subdet_; + std::shared_ptr moduleTC_layer_; + std::shared_ptr moduleTC_wafer_; + std::shared_ptr moduleTC_waferType_; + std::shared_ptr moduleTC_cell_; + std::shared_ptr moduleTC_x_; + std::shared_ptr moduleTC_y_; + std::shared_ptr moduleTC_z_; + int moduleCell_N_; + std::shared_ptr moduleCell_id_; + std::shared_ptr moduleCell_zside_; + std::shared_ptr moduleCell_subdet_; + std::shared_ptr moduleCell_layer_; + std::shared_ptr moduleCell_wafer_; + std::shared_ptr moduleCell_cell_; + std::shared_ptr moduleCell_x_; + std::shared_ptr moduleCell_y_; + std::shared_ptr moduleCell_z_; + int triggerCellId_; + int triggerCellSide_; + int triggerCellSubdet_; + int triggerCellLayer_; + int triggerCellWafer_; + int triggerCellWaferType_; + int triggerCell_; + float triggerCellX_; + float triggerCellY_; + float triggerCellZ_; + int triggerCellNeighbor_N_; + std::shared_ptr triggerCellNeighbor_id_; + std::shared_ptr triggerCellNeighbor_zside_; + std::shared_ptr triggerCellNeighbor_subdet_; + std::shared_ptr triggerCellNeighbor_layer_; + std::shared_ptr triggerCellNeighbor_wafer_; + std::shared_ptr triggerCellNeighbor_cell_; + std::shared_ptr triggerCellNeighbor_distance_; + int triggerCellCell_N_; + std::shared_ptr triggerCellCell_id_; + std::shared_ptr triggerCellCell_zside_; + std::shared_ptr triggerCellCell_subdet_; + std::shared_ptr triggerCellCell_layer_; + std::shared_ptr triggerCellCell_wafer_; + std::shared_ptr triggerCellCell_cell_; + std::shared_ptr triggerCellCell_ieta_; + std::shared_ptr triggerCellCell_iphi_; + std::shared_ptr triggerCellCell_x_; + std::shared_ptr triggerCellCell_y_; + std::shared_ptr triggerCellCell_z_; + int cellId_; + int cellSide_; + int cellSubdet_; + int cellLayer_; + int cellWafer_; + int cellWaferType_; + int cellWaferRow_; + int cellWaferColumn_; + int cell_; + float cellX_; + float cellY_; + float cellZ_; + float cellX1_; + float cellY1_; + float cellX2_; + float cellY2_; + float cellX3_; + float cellY3_; + float cellX4_; + float cellY4_; + int cellBHId_; + int cellBHSide_; + int cellBHSubdet_; + int cellBHLayer_; + int cellBHIEta_; + int cellBHIPhi_; + float cellBHEta_; + float cellBHPhi_; + float cellBHX_; + float cellBHY_; + float cellBHZ_; + float cellBHX1_; + float cellBHY1_; + float cellBHX2_; + float cellBHY2_; + float cellBHX3_; + float cellBHY3_; + float cellBHX4_; + float cellBHY4_; }; - /*****************************************************************/ -HGCalTriggerGeomTester::HGCalTriggerGeomTester(const edm::ParameterSet& conf): - no_trigger_(false), - no_neighbors_(false) +HGCalTriggerGeomTester::HGCalTriggerGeomTester(const edm::ParameterSet& conf) + : no_trigger_(false), + no_neighbors_(false) /*****************************************************************/ { - - // initialize output trees - treeModules_ = fs_->make("TreeModules","Tree of all HGC modules"); - treeModules_->Branch("id" , &moduleId_ , "id/I"); - treeModules_->Branch("zside" , &moduleSide_ , "zside/I"); - treeModules_->Branch("subdet" , &moduleSubdet_ , "subdet/I"); - treeModules_->Branch("layer" , &moduleLayer_ , "layer/I"); - treeModules_->Branch("module" , &module_ , "module/I"); - treeModules_->Branch("x" , &moduleX_ , "x/F"); - treeModules_->Branch("y" , &moduleY_ , "y/F"); - treeModules_->Branch("z" , &moduleZ_ , "z/F"); - treeModules_->Branch("tc_n" , &moduleTC_N_ , "tc_n/I"); - moduleTC_id_ .reset(new int[1], array_deleter()); - moduleTC_zside_ .reset(new int[1], array_deleter()); - moduleTC_subdet_.reset(new int[1], array_deleter()); - moduleTC_layer_ .reset(new int[1], array_deleter()); - moduleTC_wafer_ .reset(new int[1], array_deleter()); - moduleTC_waferType_ .reset(new int[1], array_deleter()); - moduleTC_cell_ .reset(new int[1], array_deleter()); - moduleTC_x_ .reset(new float[1], array_deleter()); - moduleTC_y_ .reset(new float[1], array_deleter()); - moduleTC_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("tc_id" , moduleTC_id_.get() , "tc_id[tc_n]/I"); - treeModules_->Branch("tc_zside" , moduleTC_zside_.get() , "tc_zside[tc_n]/I"); - treeModules_->Branch("tc_subdet" , moduleTC_subdet_.get() , "tc_subdet[tc_n]/I"); - treeModules_->Branch("tc_layer" , moduleTC_layer_.get() , "tc_layer[tc_n]/I"); - treeModules_->Branch("tc_wafer" , moduleTC_wafer_.get() , "tc_wafer[tc_n]/I"); - treeModules_->Branch("tc_waferType" , moduleTC_waferType_.get() , "tc_waferType[tc_n]/I"); - treeModules_->Branch("tc_cell" , moduleTC_cell_.get() , "tc_cell[tc_n]/I"); - treeModules_->Branch("tc_x" , moduleTC_x_.get() , "tc_x[tc_n]/F"); - treeModules_->Branch("tc_y" , moduleTC_y_.get() , "tc_y[tc_n]/F"); - treeModules_->Branch("tc_z" , moduleTC_z_.get() , "tc_z[tc_n]/F"); - treeModules_->Branch("c_n" , &moduleCell_N_ , "c_n/I"); - moduleCell_id_ .reset(new int[1], array_deleter()); - moduleCell_zside_ .reset(new int[1], array_deleter()); - moduleCell_subdet_.reset(new int[1], array_deleter()); - moduleCell_layer_ .reset(new int[1], array_deleter()); - moduleCell_wafer_ .reset(new int[1], array_deleter()); - moduleCell_cell_ .reset(new int[1], array_deleter()); - moduleCell_x_ .reset(new float[1], array_deleter()); - moduleCell_y_ .reset(new float[1], array_deleter()); - moduleCell_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("c_id" , moduleCell_id_.get() , "c_id[c_n]/I"); - treeModules_->Branch("c_zside" , moduleCell_zside_.get() , "c_zside[c_n]/I"); - treeModules_->Branch("c_subdet" , moduleCell_subdet_.get() , "c_subdet[c_n]/I"); - treeModules_->Branch("c_layer" , moduleCell_layer_.get() , "c_layer[c_n]/I"); - treeModules_->Branch("c_wafer" , moduleCell_wafer_.get() , "c_wafer[c_n]/I"); - treeModules_->Branch("c_cell" , moduleCell_cell_.get() , "c_cell[c_n]/I"); - treeModules_->Branch("c_x" , moduleCell_x_.get() , "c_x[c_n]/F"); - treeModules_->Branch("c_y" , moduleCell_y_.get() , "c_y[c_n]/F"); - treeModules_->Branch("c_z" , moduleCell_z_.get() , "c_z[c_n]/F"); - // - treeTriggerCells_ = fs_->make("TreeTriggerCells","Tree of all HGC trigger cells"); - treeTriggerCells_->Branch("id" , &triggerCellId_ , "id/I"); - treeTriggerCells_->Branch("zside" , &triggerCellSide_ , "zside/I"); - treeTriggerCells_->Branch("subdet" , &triggerCellSubdet_ , "subdet/I"); - treeTriggerCells_->Branch("layer" , &triggerCellLayer_ , "layer/I"); - treeTriggerCells_->Branch("wafer" , &triggerCellWafer_ , "wafer/I"); - treeTriggerCells_->Branch("wafertype" , &triggerCellWaferType_ , "wafertype/I"); - - treeTriggerCells_->Branch("triggercell" , &triggerCell_ , "triggercell/I"); - treeTriggerCells_->Branch("x" , &triggerCellX_ , "x/F"); - treeTriggerCells_->Branch("y" , &triggerCellY_ , "y/F"); - treeTriggerCells_->Branch("z" , &triggerCellZ_ , "z/F"); - treeTriggerCells_->Branch("neighbor_n" , &triggerCellNeighbor_N_ , "neighbor_n/I"); - triggerCellNeighbor_id_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_subdet_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_wafer_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_cell_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get() , "neighbor_zside[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get() , "neighbor_subdet[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get() , "neighbor_layer[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_wafer", triggerCellNeighbor_wafer_.get() , "neighbor_wafer[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_cell", triggerCellNeighbor_cell_.get() , "neighbor_cell[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_distance", triggerCellNeighbor_distance_.get() , "neighbor_distance[neighbor_n]/F"); - treeTriggerCells_->Branch("c_n" , &triggerCellCell_N_ , "c_n/I"); - triggerCellCell_id_ .reset(new int[1], array_deleter()); - triggerCellCell_zside_ .reset(new int[1], array_deleter()); - triggerCellCell_subdet_ .reset(new int[1], array_deleter()); - triggerCellCell_layer_ .reset(new int[1], array_deleter()); - triggerCellCell_wafer_ .reset(new int[1], array_deleter()); - triggerCellCell_cell_ .reset(new int[1], array_deleter()); - triggerCellCell_ieta_ .reset(new int[1], array_deleter()); - triggerCellCell_iphi_ .reset(new int[1], array_deleter()); - triggerCellCell_x_ .reset(new float[1], array_deleter()); - triggerCellCell_y_ .reset(new float[1], array_deleter()); - triggerCellCell_z_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("c_id" , triggerCellCell_id_.get() , "c_id[c_n]/I"); - treeTriggerCells_->Branch("c_zside" , triggerCellCell_zside_.get() , "c_zside[c_n]/I"); - treeTriggerCells_->Branch("c_subdet" , triggerCellCell_subdet_.get() , "c_subdet[c_n]/I"); - treeTriggerCells_->Branch("c_layer" , triggerCellCell_layer_.get() , "c_layer[c_n]/I"); - treeTriggerCells_->Branch("c_wafer" , triggerCellCell_wafer_.get() , "c_wafer[c_n]/I"); - treeTriggerCells_->Branch("c_cell" , triggerCellCell_cell_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_ieta" , triggerCellCell_ieta_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_iphi" , triggerCellCell_iphi_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_x" , triggerCellCell_x_.get() , "c_x[c_n]/F"); - treeTriggerCells_->Branch("c_y" , triggerCellCell_y_.get() , "c_y[c_n]/F"); - treeTriggerCells_->Branch("c_z" , triggerCellCell_z_.get() , "c_z[c_n]/F"); - // - treeCells_ = fs_->make("TreeCells","Tree of all HGC cells"); - treeCells_->Branch("id" , &cellId_ , "id/I"); - treeCells_->Branch("zside" , &cellSide_ , "zside/I"); - treeCells_->Branch("subdet" , &cellSubdet_ , "subdet/I"); - treeCells_->Branch("layer" , &cellLayer_ , "layer/I"); - treeCells_->Branch("wafer" , &cellWafer_ , "wafer/I"); - treeCells_->Branch("wafertype" , &cellWaferType_ , "wafertype/I"); - treeCells_->Branch("waferrow" , &cellWaferRow_ , "waferrow/I"); - treeCells_->Branch("wafercolumn" , &cellWaferColumn_ , "wafercolumn/I"); - treeCells_->Branch("cell" , &cell_ , "cell/I"); - treeCells_->Branch("x" , &cellX_ , "x/F"); - treeCells_->Branch("y" , &cellY_ , "y/F"); - treeCells_->Branch("z" , &cellZ_ , "z/F"); - treeCells_->Branch("x1" , &cellX1_ , "x1/F"); - treeCells_->Branch("y1" , &cellY1_ , "y1/F"); - treeCells_->Branch("x2" , &cellX2_ , "x2/F"); - treeCells_->Branch("y2" , &cellY2_ , "y2/F"); - treeCells_->Branch("x3" , &cellX3_ , "x3/F"); - treeCells_->Branch("y3" , &cellY3_ , "y3/F"); - treeCells_->Branch("x4" , &cellX4_ , "x4/F"); - treeCells_->Branch("y4" , &cellY4_ , "y4/F"); - // - treeCellsBH_ = fs_->make("TreeCellsBH","Tree of all BH cells"); - treeCellsBH_->Branch("id", &cellBHId_, "id/I"); - treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); - treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); - treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); - treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); - treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); - treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); - treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); - treeCellsBH_->Branch("x", &cellBHX_, "x/F"); - treeCellsBH_->Branch("y", &cellBHY_, "y/F"); - treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); - treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); - treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); - treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); - treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); - treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); - treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); - treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); - treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); + // initialize output trees + treeModules_ = fs_->make("TreeModules", "Tree of all HGC modules"); + treeModules_->Branch("id", &moduleId_, "id/I"); + treeModules_->Branch("zside", &moduleSide_, "zside/I"); + treeModules_->Branch("subdet", &moduleSubdet_, "subdet/I"); + treeModules_->Branch("layer", &moduleLayer_, "layer/I"); + treeModules_->Branch("module", &module_, "module/I"); + treeModules_->Branch("x", &moduleX_, "x/F"); + treeModules_->Branch("y", &moduleY_, "y/F"); + treeModules_->Branch("z", &moduleZ_, "z/F"); + treeModules_->Branch("tc_n", &moduleTC_N_, "tc_n/I"); + moduleTC_id_.reset(new int[1], array_deleter()); + moduleTC_zside_.reset(new int[1], array_deleter()); + moduleTC_subdet_.reset(new int[1], array_deleter()); + moduleTC_layer_.reset(new int[1], array_deleter()); + moduleTC_wafer_.reset(new int[1], array_deleter()); + moduleTC_waferType_.reset(new int[1], array_deleter()); + moduleTC_cell_.reset(new int[1], array_deleter()); + moduleTC_x_.reset(new float[1], array_deleter()); + moduleTC_y_.reset(new float[1], array_deleter()); + moduleTC_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("tc_id", moduleTC_id_.get(), "tc_id[tc_n]/I"); + treeModules_->Branch("tc_zside", moduleTC_zside_.get(), "tc_zside[tc_n]/I"); + treeModules_->Branch("tc_subdet", moduleTC_subdet_.get(), "tc_subdet[tc_n]/I"); + treeModules_->Branch("tc_layer", moduleTC_layer_.get(), "tc_layer[tc_n]/I"); + treeModules_->Branch("tc_wafer", moduleTC_wafer_.get(), "tc_wafer[tc_n]/I"); + treeModules_->Branch("tc_waferType", moduleTC_waferType_.get(), "tc_waferType[tc_n]/I"); + treeModules_->Branch("tc_cell", moduleTC_cell_.get(), "tc_cell[tc_n]/I"); + treeModules_->Branch("tc_x", moduleTC_x_.get(), "tc_x[tc_n]/F"); + treeModules_->Branch("tc_y", moduleTC_y_.get(), "tc_y[tc_n]/F"); + treeModules_->Branch("tc_z", moduleTC_z_.get(), "tc_z[tc_n]/F"); + treeModules_->Branch("c_n", &moduleCell_N_, "c_n/I"); + moduleCell_id_.reset(new int[1], array_deleter()); + moduleCell_zside_.reset(new int[1], array_deleter()); + moduleCell_subdet_.reset(new int[1], array_deleter()); + moduleCell_layer_.reset(new int[1], array_deleter()); + moduleCell_wafer_.reset(new int[1], array_deleter()); + moduleCell_cell_.reset(new int[1], array_deleter()); + moduleCell_x_.reset(new float[1], array_deleter()); + moduleCell_y_.reset(new float[1], array_deleter()); + moduleCell_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("c_id", moduleCell_id_.get(), "c_id[c_n]/I"); + treeModules_->Branch("c_zside", moduleCell_zside_.get(), "c_zside[c_n]/I"); + treeModules_->Branch("c_subdet", moduleCell_subdet_.get(), "c_subdet[c_n]/I"); + treeModules_->Branch("c_layer", moduleCell_layer_.get(), "c_layer[c_n]/I"); + treeModules_->Branch("c_wafer", moduleCell_wafer_.get(), "c_wafer[c_n]/I"); + treeModules_->Branch("c_cell", moduleCell_cell_.get(), "c_cell[c_n]/I"); + treeModules_->Branch("c_x", moduleCell_x_.get(), "c_x[c_n]/F"); + treeModules_->Branch("c_y", moduleCell_y_.get(), "c_y[c_n]/F"); + treeModules_->Branch("c_z", moduleCell_z_.get(), "c_z[c_n]/F"); + // + treeTriggerCells_ = fs_->make("TreeTriggerCells", "Tree of all HGC trigger cells"); + treeTriggerCells_->Branch("id", &triggerCellId_, "id/I"); + treeTriggerCells_->Branch("zside", &triggerCellSide_, "zside/I"); + treeTriggerCells_->Branch("subdet", &triggerCellSubdet_, "subdet/I"); + treeTriggerCells_->Branch("layer", &triggerCellLayer_, "layer/I"); + treeTriggerCells_->Branch("wafer", &triggerCellWafer_, "wafer/I"); + treeTriggerCells_->Branch("wafertype", &triggerCellWaferType_, "wafertype/I"); + + treeTriggerCells_->Branch("triggercell", &triggerCell_, "triggercell/I"); + treeTriggerCells_->Branch("x", &triggerCellX_, "x/F"); + treeTriggerCells_->Branch("y", &triggerCellY_, "y/F"); + treeTriggerCells_->Branch("z", &triggerCellZ_, "z/F"); + treeTriggerCells_->Branch("neighbor_n", &triggerCellNeighbor_N_, "neighbor_n/I"); + triggerCellNeighbor_id_.reset(new int[1], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[1], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[1], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[1], array_deleter()); + triggerCellNeighbor_wafer_.reset(new int[1], array_deleter()); + triggerCellNeighbor_cell_.reset(new int[1], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get(), "neighbor_zside[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get(), "neighbor_subdet[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get(), "neighbor_layer[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_wafer", triggerCellNeighbor_wafer_.get(), "neighbor_wafer[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_cell", triggerCellNeighbor_cell_.get(), "neighbor_cell[neighbor_n]/I"); + treeTriggerCells_->Branch( + "neighbor_distance", triggerCellNeighbor_distance_.get(), "neighbor_distance[neighbor_n]/F"); + treeTriggerCells_->Branch("c_n", &triggerCellCell_N_, "c_n/I"); + triggerCellCell_id_.reset(new int[1], array_deleter()); + triggerCellCell_zside_.reset(new int[1], array_deleter()); + triggerCellCell_subdet_.reset(new int[1], array_deleter()); + triggerCellCell_layer_.reset(new int[1], array_deleter()); + triggerCellCell_wafer_.reset(new int[1], array_deleter()); + triggerCellCell_cell_.reset(new int[1], array_deleter()); + triggerCellCell_ieta_.reset(new int[1], array_deleter()); + triggerCellCell_iphi_.reset(new int[1], array_deleter()); + triggerCellCell_x_.reset(new float[1], array_deleter()); + triggerCellCell_y_.reset(new float[1], array_deleter()); + triggerCellCell_z_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("c_id", triggerCellCell_id_.get(), "c_id[c_n]/I"); + treeTriggerCells_->Branch("c_zside", triggerCellCell_zside_.get(), "c_zside[c_n]/I"); + treeTriggerCells_->Branch("c_subdet", triggerCellCell_subdet_.get(), "c_subdet[c_n]/I"); + treeTriggerCells_->Branch("c_layer", triggerCellCell_layer_.get(), "c_layer[c_n]/I"); + treeTriggerCells_->Branch("c_wafer", triggerCellCell_wafer_.get(), "c_wafer[c_n]/I"); + treeTriggerCells_->Branch("c_cell", triggerCellCell_cell_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_ieta", triggerCellCell_ieta_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_iphi", triggerCellCell_iphi_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_x", triggerCellCell_x_.get(), "c_x[c_n]/F"); + treeTriggerCells_->Branch("c_y", triggerCellCell_y_.get(), "c_y[c_n]/F"); + treeTriggerCells_->Branch("c_z", triggerCellCell_z_.get(), "c_z[c_n]/F"); + // + treeCells_ = fs_->make("TreeCells", "Tree of all HGC cells"); + treeCells_->Branch("id", &cellId_, "id/I"); + treeCells_->Branch("zside", &cellSide_, "zside/I"); + treeCells_->Branch("subdet", &cellSubdet_, "subdet/I"); + treeCells_->Branch("layer", &cellLayer_, "layer/I"); + treeCells_->Branch("wafer", &cellWafer_, "wafer/I"); + treeCells_->Branch("wafertype", &cellWaferType_, "wafertype/I"); + treeCells_->Branch("waferrow", &cellWaferRow_, "waferrow/I"); + treeCells_->Branch("wafercolumn", &cellWaferColumn_, "wafercolumn/I"); + treeCells_->Branch("cell", &cell_, "cell/I"); + treeCells_->Branch("x", &cellX_, "x/F"); + treeCells_->Branch("y", &cellY_, "y/F"); + treeCells_->Branch("z", &cellZ_, "z/F"); + treeCells_->Branch("x1", &cellX1_, "x1/F"); + treeCells_->Branch("y1", &cellY1_, "y1/F"); + treeCells_->Branch("x2", &cellX2_, "x2/F"); + treeCells_->Branch("y2", &cellY2_, "y2/F"); + treeCells_->Branch("x3", &cellX3_, "x3/F"); + treeCells_->Branch("y3", &cellY3_, "y3/F"); + treeCells_->Branch("x4", &cellX4_, "x4/F"); + treeCells_->Branch("y4", &cellY4_, "y4/F"); + // + treeCellsBH_ = fs_->make("TreeCellsBH", "Tree of all BH cells"); + treeCellsBH_->Branch("id", &cellBHId_, "id/I"); + treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); + treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); + treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); + treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); + treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); + treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); + treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); + treeCellsBH_->Branch("x", &cellBHX_, "x/F"); + treeCellsBH_->Branch("y", &cellBHY_, "y/F"); + treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); + treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); + treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); + treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); + treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); + treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); + treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); + treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); + treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); } - - /*****************************************************************/ HGCalTriggerGeomTester::~HGCalTriggerGeomTester() /*****************************************************************/ -{ -} +{} /*****************************************************************/ -void HGCalTriggerGeomTester::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) +void HGCalTriggerGeomTester::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) /*****************************************************************/ { - es.get().get("", triggerGeometry_); + es.get().get("", triggerGeometry_); + + try { + checkMappingConsistency(); + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + no_trigger_ = true; + } + try { + checkNeighborConsistency(); + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + no_neighbors_ = true; + } + fillTriggerGeometry(); +} - try - { - checkMappingConsistency(); - } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - no_trigger_ = true; - } - try - { - checkNeighborConsistency(); +void HGCalTriggerGeomTester::checkMappingConsistency() { + std::unordered_map> modules_to_triggercells; + std::unordered_map> modules_to_cells; + std::unordered_map> triggercells_to_cells; + + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - no_neighbors_ = true; + } + // FH + for (const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->fhTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); } - fillTriggerGeometry(); -} - - -void HGCalTriggerGeomTester::checkMappingConsistency() -{ - - - - - std::unordered_map> modules_to_triggercells; - std::unordered_map> modules_to_cells; - std::unordered_map> triggercells_to_cells; - - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ieeTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); + } + // BH + for (const auto& id : + triggerGeometry_->caloGeometry()->getSubdetectorGeometry(DetId::Hcal, HcalEndcap)->getValidDetIds()) { + if (id.rawId() == 0 || id.subdetId() != 2) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + + edm::LogPrint("TriggerCellCheck") << "Checking cell -> trigger cell -> cell consistency"; + // Loop over trigger cells + for (const auto& triggercell_cells : triggercells_to_cells) { + HGCalDetId id(triggercell_cells.first); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + // Check consistency of cells included in trigger cell + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); + const auto& cells = triggercell_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + edm::LogProblem("BadTriggerCell") << "Error: \n Cell " << cell << "(" << HcalDetId(cell) + << ")\n has not been found in \n trigger cell " << id; + } else { + edm::LogProblem("BadTriggerCell") << "Error: \n Cell " << cell << "(" << HGCalDetId(cell) + << ")\n has not been found in \n trigger cell " << id; } - } - // FH - for(const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ifhTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) { + output << cell_geom << " "; } + edm::LogProblem("BadTriggerCell") << output.str(); + throw cms::Exception("BadTriggerCell") << "Trigger cell <-> cell inconsistency"; + } } - // BH - for(const auto& id : triggerGeometry_->caloGeometry()->getSubdetectorGeometry(DetId::Hcal,HcalEndcap)->getValidDetIds()) - { - if(id.rawId()==0 || id.subdetId()!=2) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - - - - edm::LogPrint("TriggerCellCheck")<<"Checking cell -> trigger cell -> cell consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - HGCalDetId id(triggercell_cells.first); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - // Check consistency of cells included in trigger cell - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); - const auto& cells = triggercell_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - edm::LogProblem("BadTriggerCell")<<"Error: \n Cell "< cell inconsistency"; - } + } + edm::LogPrint("ModuleCheck") << "Checking trigger cell -> module -> trigger cell consistency"; + // Loop over modules + for (const auto& module_triggercells : modules_to_triggercells) { + HGCalDetId id(module_triggercells.first); + // Check consistency of trigger cells included in module + HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); + const auto& triggercells = module_triggercells.second; + for (auto cell : triggercells) { + if (triggercells_geom.find(cell) == triggercells_geom.end()) { + HGCalDetId cellid(cell); + edm::LogProblem("BadModule") << "Error: \n Trigger cell " << cell << "(" << cellid + << ")\n has not been found in \n module " << id; + std::stringstream output; + output << " Available trigger cells are:\n"; + for (auto cell_geom : triggercells_geom) { + output << cell_geom << " "; } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadModule") << "Trigger cell <-> module inconsistency"; + } } - edm::LogPrint("ModuleCheck")<<"Checking trigger cell -> module -> trigger cell consistency"; - // Loop over modules - for( const auto& module_triggercells : modules_to_triggercells ) - { - HGCalDetId id(module_triggercells.first); - // Check consistency of trigger cells included in module - HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); - const auto& triggercells = module_triggercells.second; - for(auto cell : triggercells) - { - if(triggercells_geom.find(cell)==triggercells_geom.end()) - { - HGCalDetId cellid(cell); - edm::LogProblem("BadModule")<<"Error: \n Trigger cell "< module inconsistency"; - } + } + edm::LogPrint("ModuleCheck") << "Checking cell -> module -> cell consistency"; + for (const auto& module_cells : modules_to_cells) { + HGCalDetId id(module_cells.first); + // Check consistency of cells included in module + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); + const auto& cells = module_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HcalDetId(cell) + << ")\n has not been found in \n module " << id; + } else { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCalDetId(cell) + << ")\n has not been found in \n module " << id; } - } - edm::LogPrint("ModuleCheck")<<"Checking cell -> module -> cell consistency"; - for( const auto& module_cells : modules_to_cells ) - { - HGCalDetId id(module_cells.first); - // Check consistency of cells included in module - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); - const auto& cells = module_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - edm::LogProblem("BadModule")<<"Error: \n Cell "< module inconsistency"; - } + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) { + output << cell_geom << " "; } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadModule") << "Cell <-> module inconsistency"; + } } + } } -void HGCalTriggerGeomTester::checkNeighborConsistency() -{ - std::unordered_map> triggercells_to_cells; - - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ieeTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } +void HGCalTriggerGeomTester::checkNeighborConsistency() { + std::unordered_map> triggercells_to_cells; + + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); } - // FH - for(const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ifhTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - } - - // BH - for(const auto& id : triggerGeometry_->caloGeometry()->getSubdetectorGeometry(DetId::Hcal,HcalEndcap)->getValidDetIds()) - { - if(id.rawId()==0 || id.subdetId()!=2) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); + } + // FH + for (const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->fhTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); } - - edm::LogPrint("NeighborCheck")<<"Checking trigger cell neighbor consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - unsigned triggercell_id(triggercell_cells.first); - const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(triggercell_id); - for(const auto neighbor : neighbors) - { - const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); - // check if the original cell is included in the neigbors of neighbor - if(neighbors_of_neighbor.find(triggercell_id)==neighbors_of_neighbor.end()) - { - edm::LogProblem("BadNeighbor")<<"Error: \n Trigger cell "<< HGCalDetId(neighbor) << "\n is a neighbor of \n" << HGCalDetId(triggercell_id); - edm::LogProblem("BadNeighbor")<<" But the opposite is not true"; - std::stringstream output; - output<<" List of neighbors of neighbor = \n"; - for(const auto neighbor_of_neighbor : neighbors_of_neighbor) - { - output<<" "<< HGCalDetId(neighbor_of_neighbor)<<"\n"; - } - edm::LogProblem("BadNeighbor")<caloGeometry()->getSubdetectorGeometry(DetId::Hcal, HcalEndcap)->getValidDetIds()) { + if (id.rawId() == 0 || id.subdetId() != 2) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + + edm::LogPrint("NeighborCheck") << "Checking trigger cell neighbor consistency"; + // Loop over trigger cells + for (const auto& triggercell_cells : triggercells_to_cells) { + unsigned triggercell_id(triggercell_cells.first); + const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(triggercell_id); + for (const auto neighbor : neighbors) { + const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); + // check if the original cell is included in the neigbors of neighbor + if (neighbors_of_neighbor.find(triggercell_id) == neighbors_of_neighbor.end()) { + edm::LogProblem("BadNeighbor") << "Error: \n Trigger cell " << HGCalDetId(neighbor) << "\n is a neighbor of \n" + << HGCalDetId(triggercell_id); + edm::LogProblem("BadNeighbor") << " But the opposite is not true"; + std::stringstream output; + output << " List of neighbors of neighbor = \n"; + for (const auto neighbor_of_neighbor : neighbors_of_neighbor) { + output << " " << HGCalDetId(neighbor_of_neighbor) << "\n"; } + edm::LogProblem("BadNeighbor") << output.str(); + throw cms::Exception("BadNeighbor") << "Neighbor mapping not consistent"; + } } + } } - /*****************************************************************/ void HGCalTriggerGeomTester::fillTriggerGeometry() /*****************************************************************/ { - std::unordered_map> modules; - std::unordered_map> trigger_cells; - - // Loop over cells - edm::LogPrint("TreeFilling")<<"Filling cells tree"; - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ieeTopology().valid(id)) continue; - cellId_ = id.rawId(); - cellSide_ = id.zside(); - cellSubdet_ = id.subdetId(); - cellLayer_ = id.layer(); - cellWafer_ = id.wafer(); - cellWaferType_ = id.waferType(); - auto row_column = triggerGeometry_->eeTopology().dddConstants().rowColumnWafer(id.wafer()); - cellWaferRow_ = row_column.first; - cellWaferColumn_ = row_column.second; - cell_ = id.cell(); - // - GlobalPoint center = triggerGeometry_->eeGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); - if(corners.size()>=4) - { - cellX1_ = corners.at(0).x(); - cellY1_ = corners.at(0).y(); - cellX2_ = corners.at(1).x(); - cellY2_ = corners.at(1).y(); - cellX3_ = corners.at(2).x(); - cellY3_ = corners.at(2).y(); - cellX4_ = corners.at(3).x(); - cellY4_ = corners.at(3).y(); - } - treeCells_->Fill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - } + std::unordered_map> modules; + std::unordered_map> trigger_cells; + + // Loop over cells + edm::LogPrint("TreeFilling") << "Filling cells tree"; + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->eeTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->eeTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + cellId_ = id.rawId(); + cellSide_ = id.zside(); + cellSubdet_ = id.subdetId(); + cellLayer_ = id.layer(); + cellWafer_ = id.wafer(); + cellWaferType_ = id.waferType(); + auto row_column = triggerGeometry_->eeTopology().dddConstants().rowColumnWafer(id.wafer()); + cellWaferRow_ = row_column.first; + cellWaferColumn_ = row_column.second; + cell_ = id.cell(); + // + GlobalPoint center = triggerGeometry_->eeGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); + if (corners.size() >= 4) { + cellX1_ = corners.at(0).x(); + cellY1_ = corners.at(0).y(); + cellX2_ = corners.at(1).x(); + cellY2_ = corners.at(1).y(); + cellX3_ = corners.at(2).x(); + cellY3_ = corners.at(2).y(); + cellX4_ = corners.at(3).x(); + cellY4_ = corners.at(3).y(); + } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } } - // FH - for(const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) - { - if(id.rawId()==0) continue; - HGCalDetId waferid(id); - unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer())==2?0:1); - int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); - for(int i=0;ifhTopology().valid(id)) continue; - cellId_ = id.rawId(); - cellSide_ = id.zside(); - cellSubdet_ = id.subdetId(); - cellLayer_ = id.layer(); - cellWafer_ = id.wafer(); - cellWaferType_ = id.waferType(); - auto row_column = triggerGeometry_->fhTopology().dddConstants().rowColumnWafer(id.wafer()); - cellWaferRow_ = row_column.first; - cellWaferColumn_ = row_column.second; - cell_ = id.cell(); - // - GlobalPoint center = triggerGeometry_->fhGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->fhGeometry()->getCorners(id); - if(corners.size()>=4) - { - cellX1_ = corners.at(0).x(); - cellY1_ = corners.at(0).y(); - cellX2_ = corners.at(1).x(); - cellY2_ = corners.at(1).y(); - cellX3_ = corners.at(2).x(); - cellY3_ = corners.at(2).y(); - cellX4_ = corners.at(3).x(); - cellY4_ = corners.at(3).y(); - } - treeCells_->Fill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - } + } + // FH + for (const auto& id : triggerGeometry_->fhGeometry()->getValidGeomDetIds()) { + if (id.rawId() == 0) + continue; + HGCalDetId waferid(id); + unsigned wafer_type = (triggerGeometry_->fhTopology().dddConstants().waferTypeT(waferid.wafer()) == 2 ? 0 : 1); + int nCells = triggerGeometry_->fhTopology().dddConstants().numberCellsHexagon(waferid.wafer()); + for (int i = 0; i < nCells; i++) { + HGCalDetId id( + ForwardSubdetector(waferid.subdetId()), waferid.zside(), waferid.layer(), wafer_type, waferid.wafer(), i); + if (!triggerGeometry_->fhTopology().valid(id)) + continue; + cellId_ = id.rawId(); + cellSide_ = id.zside(); + cellSubdet_ = id.subdetId(); + cellLayer_ = id.layer(); + cellWafer_ = id.wafer(); + cellWaferType_ = id.waferType(); + auto row_column = triggerGeometry_->fhTopology().dddConstants().rowColumnWafer(id.wafer()); + cellWaferRow_ = row_column.first; + cellWaferColumn_ = row_column.second; + cell_ = id.cell(); + // + GlobalPoint center = triggerGeometry_->fhGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->fhGeometry()->getCorners(id); + if (corners.size() >= 4) { + cellX1_ = corners.at(0).x(); + cellY1_ = corners.at(0).y(); + cellX2_ = corners.at(1).x(); + cellY2_ = corners.at(1).y(); + cellX3_ = corners.at(2).x(); + cellY3_ = corners.at(2).y(); + cellX4_ = corners.at(3).x(); + cellY4_ = corners.at(3).y(); + } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } } - - // BH - for(const auto& id : triggerGeometry_->caloGeometry()->getSubdetectorGeometry(DetId::Hcal,HcalEndcap)->getValidDetIds()) - { - if(id.rawId()==0 || id.subdetId()!=2) continue; - HcalDetId cellid(id); - cellBHId_ = cellid.rawId(); - cellBHSide_ = cellid.zside(); - cellBHSubdet_ = cellid.subdetId(); - cellBHLayer_ = cellid.depth(); - cellBHIEta_ = cellid.ieta(); - cellBHIPhi_ = cellid.iphi(); - // - GlobalPoint center = triggerGeometry_->bhGeometry()->getGeometry(id)->getPosition(); - cellBHEta_ = center.eta(); - cellBHPhi_ = center.phi(); - cellBHX_ = center.x(); - cellBHY_ = center.y(); - cellBHZ_ = center.z(); - auto corners = triggerGeometry_->bhGeometry()->getGeometry(id)->getCorners(); - if(corners.size()>=4) - { - cellBHX1_ = corners[0].x(); - cellBHY1_ = corners[0].y(); - cellBHX2_ = corners[1].x(); - cellBHY2_ = corners[1].y(); - cellBHX3_ = corners[2].x(); - cellBHY3_ = corners[2].y(); - cellBHX4_ = corners[3].x(); - cellBHY4_ = corners[3].y(); - } - treeCellsBH_->Fill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + } + + // BH + for (const auto& id : + triggerGeometry_->caloGeometry()->getSubdetectorGeometry(DetId::Hcal, HcalEndcap)->getValidDetIds()) { + if (id.rawId() == 0 || id.subdetId() != 2) + continue; + HcalDetId cellid(id); + cellBHId_ = cellid.rawId(); + cellBHSide_ = cellid.zside(); + cellBHSubdet_ = cellid.subdetId(); + cellBHLayer_ = cellid.depth(); + cellBHIEta_ = cellid.ieta(); + cellBHIPhi_ = cellid.iphi(); + // + GlobalPoint center = triggerGeometry_->bhGeometry()->getGeometry(id)->getPosition(); + cellBHEta_ = center.eta(); + cellBHPhi_ = center.phi(); + cellBHX_ = center.x(); + cellBHY_ = center.y(); + cellBHZ_ = center.z(); + auto corners = triggerGeometry_->bhGeometry()->getGeometry(id)->getCorners(); + if (corners.size() >= 4) { + cellBHX1_ = corners[0].x(); + cellBHY1_ = corners[0].y(); + cellBHX2_ = corners[1].x(); + cellBHY2_ = corners[1].y(); + cellBHX3_ = corners[2].x(); + cellBHY3_ = corners[2].y(); + cellBHX4_ = corners[3].x(); + cellBHY4_ = corners[3].y(); } - - // if problem detected in the trigger geometry, don't produce trigger trees - if(no_trigger_) return; - - // Loop over trigger cells - edm::LogPrint("TreeFilling")<<"Filling trigger cells tree"; - for( const auto& triggercell_cells : trigger_cells ) - { - HGCalDetId id(triggercell_cells.first); - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); - triggerCellId_ = id.rawId(); - triggerCellSide_ = id.zside(); - triggerCellSubdet_ = id.subdetId(); - triggerCellLayer_ = id.layer(); - triggerCellWafer_ = id.wafer(); - triggerCellWaferType_ = id.waferType(); - triggerCell_ = id.cell(); - triggerCellX_ = position.x(); - triggerCellY_ = position.y(); - triggerCellZ_ = position.z(); - triggerCellCell_N_ = triggercell_cells.second.size(); - // - setTreeTriggerCellSize(triggerCellCell_N_); - size_t ic = 0; - for(const auto& c : triggercell_cells.second) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - HcalDetId cId(c); - GlobalPoint cell_position = triggerGeometry_->bhGeometry()->getGeometry(cId)->getPosition(); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.depth(); - triggerCellCell_wafer_ .get()[ic] = 0; - triggerCellCell_cell_ .get()[ic] = 0; - triggerCellCell_ieta_ .get()[ic] = cId.ietaAbs(); - triggerCellCell_iphi_ .get()[ic] = cId.iphi(); - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - else - { - HGCalDetId cId(c); - GlobalPoint cell_position = (cId.subdetId()==ForwardSubdetector::HGCEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->fhGeometry()->getPosition(cId)); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_wafer_ .get()[ic] = cId.wafer(); - triggerCellCell_cell_ .get()[ic] = cId.cell(); - triggerCellCell_ieta_ .get()[ic] = 0; - triggerCellCell_iphi_ .get()[ic] = 0; - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - ic++; - } - // Get neighbors - if(!no_neighbors_) - { - const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(id.rawId()); - triggerCellNeighbor_N_ = neighbors.size(); - setTreeTriggerCellNeighborSize(triggerCellNeighbor_N_); - size_t in = 0; - for(const auto neighbor : neighbors) - { - GlobalPoint neighbor_position = triggerGeometry_->getTriggerCellPosition(neighbor); - HGCalDetId nId(neighbor); - triggerCellNeighbor_id_.get()[in] = neighbor; - triggerCellNeighbor_zside_ .get()[in] = nId.zside(); - triggerCellNeighbor_subdet_.get()[in] = nId.subdetId(); - triggerCellNeighbor_layer_ .get()[in] = nId.layer(); - triggerCellNeighbor_wafer_ .get()[in] = nId.wafer(); - triggerCellNeighbor_cell_ .get()[in] = nId.cell(); - triggerCellNeighbor_distance_.get()[in] = (neighbor_position - position).mag(); - in++; - } - } - // - treeTriggerCells_->Fill(); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - auto itr_insert = modules.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); + treeCellsBH_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); } - // Loop over modules - edm::LogPrint("TreeFilling")<<"Filling modules tree"; - for( const auto& module_triggercells : modules ) - { - HGCalDetId id(module_triggercells.first); - GlobalPoint position = triggerGeometry_->getModulePosition(id); - moduleId_ = id.rawId(); - moduleSide_ = id.zside(); - moduleSubdet_ = id.subdetId(); - moduleLayer_ = id.layer(); - module_ = id.wafer(); - moduleX_ = position.x(); - moduleY_ = position.y(); - moduleZ_ = position.z(); - moduleTC_N_ = module_triggercells.second.size(); - // - setTreeModuleSize(moduleTC_N_); - size_t itc = 0; - for(const auto& tc : module_triggercells.second) - { - HGCalDetId tcId(tc); - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tcId); - moduleTC_id_ .get()[itc] = tc; - moduleTC_zside_ .get()[itc] = tcId.zside(); - moduleTC_subdet_.get()[itc] = tcId.subdetId(); - moduleTC_layer_ .get()[itc] = tcId.layer(); - moduleTC_wafer_ .get()[itc] = tcId.wafer(); - moduleTC_waferType_ .get()[itc] = tcId.waferType(); - moduleTC_cell_ .get()[itc] = tcId.cell(); - moduleTC_x_ .get()[itc] = position.x(); - moduleTC_y_ .get()[itc] = position.y(); - moduleTC_z_ .get()[itc] = position.z(); - itc++; - } - auto cells_in_module = triggerGeometry_->getCellsFromModule(id); - moduleCell_N_ = cells_in_module.size(); - // - setTreeModuleCellSize(moduleCell_N_); - size_t ic = 0; - for(const auto& c : cells_in_module) - { - HGCalDetId cId(c); - const GlobalPoint position = (cId.subdetId()==ForwardSubdetector::HGCEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->fhGeometry()->getPosition(cId)); - moduleCell_id_ .get()[ic] = c; - moduleCell_zside_ .get()[ic] = cId.zside(); - moduleCell_subdet_.get()[ic] = cId.subdetId(); - moduleCell_layer_ .get()[ic] = cId.layer(); - moduleCell_wafer_ .get()[ic] = cId.wafer(); - moduleCell_cell_ .get()[ic] = cId.cell(); - moduleCell_x_ .get()[ic] = position.x(); - moduleCell_y_ .get()[ic] = position.y(); - moduleCell_z_ .get()[ic] = position.z(); - ic++; - } - // - treeModules_->Fill(); + } + + // if problem detected in the trigger geometry, don't produce trigger trees + if (no_trigger_) + return; + + // Loop over trigger cells + edm::LogPrint("TreeFilling") << "Filling trigger cells tree"; + for (const auto& triggercell_cells : trigger_cells) { + HGCalDetId id(triggercell_cells.first); + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); + triggerCellId_ = id.rawId(); + triggerCellSide_ = id.zside(); + triggerCellSubdet_ = id.subdetId(); + triggerCellLayer_ = id.layer(); + triggerCellWafer_ = id.wafer(); + triggerCellWaferType_ = id.waferType(); + triggerCell_ = id.cell(); + triggerCellX_ = position.x(); + triggerCellY_ = position.y(); + triggerCellZ_ = position.z(); + triggerCellCell_N_ = triggercell_cells.second.size(); + // + setTreeTriggerCellSize(triggerCellCell_N_); + size_t ic = 0; + for (const auto& c : triggercell_cells.second) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + HcalDetId cId(c); + GlobalPoint cell_position = triggerGeometry_->bhGeometry()->getGeometry(cId)->getPosition(); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.depth(); + triggerCellCell_wafer_.get()[ic] = 0; + triggerCellCell_cell_.get()[ic] = 0; + triggerCellCell_ieta_.get()[ic] = cId.ietaAbs(); + triggerCellCell_iphi_.get()[ic] = cId.iphi(); + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } else { + HGCalDetId cId(c); + GlobalPoint cell_position = + (cId.subdetId() == ForwardSubdetector::HGCEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->fhGeometry()->getPosition(cId)); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_wafer_.get()[ic] = cId.wafer(); + triggerCellCell_cell_.get()[ic] = cId.cell(); + triggerCellCell_ieta_.get()[ic] = 0; + triggerCellCell_iphi_.get()[ic] = 0; + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } + ic++; } - + // Get neighbors + if (!no_neighbors_) { + const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(id.rawId()); + triggerCellNeighbor_N_ = neighbors.size(); + setTreeTriggerCellNeighborSize(triggerCellNeighbor_N_); + size_t in = 0; + for (const auto neighbor : neighbors) { + GlobalPoint neighbor_position = triggerGeometry_->getTriggerCellPosition(neighbor); + HGCalDetId nId(neighbor); + triggerCellNeighbor_id_.get()[in] = neighbor; + triggerCellNeighbor_zside_.get()[in] = nId.zside(); + triggerCellNeighbor_subdet_.get()[in] = nId.subdetId(); + triggerCellNeighbor_layer_.get()[in] = nId.layer(); + triggerCellNeighbor_wafer_.get()[in] = nId.wafer(); + triggerCellNeighbor_cell_.get()[in] = nId.cell(); + triggerCellNeighbor_distance_.get()[in] = (neighbor_position - position).mag(); + in++; + } + } + // + treeTriggerCells_->Fill(); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + auto itr_insert = modules.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // Loop over modules + edm::LogPrint("TreeFilling") << "Filling modules tree"; + for (const auto& module_triggercells : modules) { + HGCalDetId id(module_triggercells.first); + GlobalPoint position = triggerGeometry_->getModulePosition(id); + moduleId_ = id.rawId(); + moduleSide_ = id.zside(); + moduleSubdet_ = id.subdetId(); + moduleLayer_ = id.layer(); + module_ = id.wafer(); + moduleX_ = position.x(); + moduleY_ = position.y(); + moduleZ_ = position.z(); + moduleTC_N_ = module_triggercells.second.size(); + // + setTreeModuleSize(moduleTC_N_); + size_t itc = 0; + for (const auto& tc : module_triggercells.second) { + HGCalDetId tcId(tc); + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tcId); + moduleTC_id_.get()[itc] = tc; + moduleTC_zside_.get()[itc] = tcId.zside(); + moduleTC_subdet_.get()[itc] = tcId.subdetId(); + moduleTC_layer_.get()[itc] = tcId.layer(); + moduleTC_wafer_.get()[itc] = tcId.wafer(); + moduleTC_waferType_.get()[itc] = tcId.waferType(); + moduleTC_cell_.get()[itc] = tcId.cell(); + moduleTC_x_.get()[itc] = position.x(); + moduleTC_y_.get()[itc] = position.y(); + moduleTC_z_.get()[itc] = position.z(); + itc++; + } + auto cells_in_module = triggerGeometry_->getCellsFromModule(id); + moduleCell_N_ = cells_in_module.size(); + // + setTreeModuleCellSize(moduleCell_N_); + size_t ic = 0; + for (const auto& c : cells_in_module) { + HGCalDetId cId(c); + const GlobalPoint position = + (cId.subdetId() == ForwardSubdetector::HGCEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->fhGeometry()->getPosition(cId)); + moduleCell_id_.get()[ic] = c; + moduleCell_zside_.get()[ic] = cId.zside(); + moduleCell_subdet_.get()[ic] = cId.subdetId(); + moduleCell_layer_.get()[ic] = cId.layer(); + moduleCell_wafer_.get()[ic] = cId.wafer(); + moduleCell_cell_.get()[ic] = cId.cell(); + moduleCell_x_.get()[ic] = position.x(); + moduleCell_y_.get()[ic] = position.y(); + moduleCell_z_.get()[ic] = position.z(); + ic++; + } + // + treeModules_->Fill(); + } } - /*****************************************************************/ -void HGCalTriggerGeomTester::analyze(const edm::Event& e, - const edm::EventSetup& es) +void HGCalTriggerGeomTester::analyze(const edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ -{ - -} - +{} /*****************************************************************/ void HGCalTriggerGeomTester::setTreeModuleSize(const size_t n) /*****************************************************************/ { - moduleTC_id_ .reset(new int[n], array_deleter()); - moduleTC_zside_ .reset(new int[n], array_deleter()); - moduleTC_subdet_.reset(new int[n], array_deleter()); - moduleTC_layer_ .reset(new int[n], array_deleter()); - moduleTC_wafer_ .reset(new int[n], array_deleter()); - moduleTC_waferType_ .reset(new int[n], array_deleter()); - moduleTC_cell_ .reset(new int[n], array_deleter()); - moduleTC_x_ .reset(new float[n], array_deleter()); - moduleTC_y_ .reset(new float[n], array_deleter()); - moduleTC_z_ .reset(new float[n], array_deleter()); - - treeModules_->GetBranch("tc_id") ->SetAddress(moduleTC_id_ .get()); - treeModules_->GetBranch("tc_zside") ->SetAddress(moduleTC_zside_ .get()); - treeModules_->GetBranch("tc_subdet") ->SetAddress(moduleTC_subdet_.get()); - treeModules_->GetBranch("tc_layer") ->SetAddress(moduleTC_layer_ .get()); - treeModules_->GetBranch("tc_wafer") ->SetAddress(moduleTC_wafer_ .get()); - treeModules_->GetBranch("tc_waferType") ->SetAddress(moduleTC_waferType_ .get()); - treeModules_->GetBranch("tc_cell") ->SetAddress(moduleTC_cell_ .get()); - treeModules_->GetBranch("tc_x") ->SetAddress(moduleTC_x_ .get()); - treeModules_->GetBranch("tc_y") ->SetAddress(moduleTC_y_ .get()); - treeModules_->GetBranch("tc_z") ->SetAddress(moduleTC_z_ .get()); + moduleTC_id_.reset(new int[n], array_deleter()); + moduleTC_zside_.reset(new int[n], array_deleter()); + moduleTC_subdet_.reset(new int[n], array_deleter()); + moduleTC_layer_.reset(new int[n], array_deleter()); + moduleTC_wafer_.reset(new int[n], array_deleter()); + moduleTC_waferType_.reset(new int[n], array_deleter()); + moduleTC_cell_.reset(new int[n], array_deleter()); + moduleTC_x_.reset(new float[n], array_deleter()); + moduleTC_y_.reset(new float[n], array_deleter()); + moduleTC_z_.reset(new float[n], array_deleter()); + + treeModules_->GetBranch("tc_id")->SetAddress(moduleTC_id_.get()); + treeModules_->GetBranch("tc_zside")->SetAddress(moduleTC_zside_.get()); + treeModules_->GetBranch("tc_subdet")->SetAddress(moduleTC_subdet_.get()); + treeModules_->GetBranch("tc_layer")->SetAddress(moduleTC_layer_.get()); + treeModules_->GetBranch("tc_wafer")->SetAddress(moduleTC_wafer_.get()); + treeModules_->GetBranch("tc_waferType")->SetAddress(moduleTC_waferType_.get()); + treeModules_->GetBranch("tc_cell")->SetAddress(moduleTC_cell_.get()); + treeModules_->GetBranch("tc_x")->SetAddress(moduleTC_x_.get()); + treeModules_->GetBranch("tc_y")->SetAddress(moduleTC_y_.get()); + treeModules_->GetBranch("tc_z")->SetAddress(moduleTC_z_.get()); } /*****************************************************************/ void HGCalTriggerGeomTester::setTreeModuleCellSize(const size_t n) /*****************************************************************/ { - moduleCell_id_ .reset(new int[n], array_deleter()); - moduleCell_zside_ .reset(new int[n], array_deleter()); - moduleCell_subdet_.reset(new int[n], array_deleter()); - moduleCell_layer_ .reset(new int[n], array_deleter()); - moduleCell_wafer_ .reset(new int[n], array_deleter()); - moduleCell_cell_ .reset(new int[n], array_deleter()); - moduleCell_x_ .reset(new float[n], array_deleter()); - moduleCell_y_ .reset(new float[n], array_deleter()); - moduleCell_z_ .reset(new float[n], array_deleter()); - - treeModules_->GetBranch("c_id") ->SetAddress(moduleCell_id_ .get()); - treeModules_->GetBranch("c_zside") ->SetAddress(moduleCell_zside_ .get()); - treeModules_->GetBranch("c_subdet") ->SetAddress(moduleCell_subdet_.get()); - treeModules_->GetBranch("c_layer") ->SetAddress(moduleCell_layer_ .get()); - treeModules_->GetBranch("c_wafer") ->SetAddress(moduleCell_wafer_ .get()); - treeModules_->GetBranch("c_cell") ->SetAddress(moduleCell_cell_ .get()); - treeModules_->GetBranch("c_x") ->SetAddress(moduleCell_x_ .get()); - treeModules_->GetBranch("c_y") ->SetAddress(moduleCell_y_ .get()); - treeModules_->GetBranch("c_z") ->SetAddress(moduleCell_z_ .get()); + moduleCell_id_.reset(new int[n], array_deleter()); + moduleCell_zside_.reset(new int[n], array_deleter()); + moduleCell_subdet_.reset(new int[n], array_deleter()); + moduleCell_layer_.reset(new int[n], array_deleter()); + moduleCell_wafer_.reset(new int[n], array_deleter()); + moduleCell_cell_.reset(new int[n], array_deleter()); + moduleCell_x_.reset(new float[n], array_deleter()); + moduleCell_y_.reset(new float[n], array_deleter()); + moduleCell_z_.reset(new float[n], array_deleter()); + + treeModules_->GetBranch("c_id")->SetAddress(moduleCell_id_.get()); + treeModules_->GetBranch("c_zside")->SetAddress(moduleCell_zside_.get()); + treeModules_->GetBranch("c_subdet")->SetAddress(moduleCell_subdet_.get()); + treeModules_->GetBranch("c_layer")->SetAddress(moduleCell_layer_.get()); + treeModules_->GetBranch("c_wafer")->SetAddress(moduleCell_wafer_.get()); + treeModules_->GetBranch("c_cell")->SetAddress(moduleCell_cell_.get()); + treeModules_->GetBranch("c_x")->SetAddress(moduleCell_x_.get()); + treeModules_->GetBranch("c_y")->SetAddress(moduleCell_y_.get()); + treeModules_->GetBranch("c_z")->SetAddress(moduleCell_z_.get()); } /*****************************************************************/ void HGCalTriggerGeomTester::setTreeTriggerCellSize(const size_t n) /*****************************************************************/ { - triggerCellCell_id_ .reset(new int[n], array_deleter()); - triggerCellCell_zside_ .reset(new int[n], array_deleter()); - triggerCellCell_subdet_.reset(new int[n], array_deleter()); - triggerCellCell_layer_ .reset(new int[n], array_deleter()); - triggerCellCell_wafer_ .reset(new int[n], array_deleter()); - triggerCellCell_cell_ .reset(new int[n], array_deleter()); - triggerCellCell_ieta_ .reset(new int[n], array_deleter()); - triggerCellCell_iphi_ .reset(new int[n], array_deleter()); - triggerCellCell_x_ .reset(new float[n], array_deleter()); - triggerCellCell_y_ .reset(new float[n], array_deleter()); - triggerCellCell_z_ .reset(new float[n], array_deleter()); - - treeTriggerCells_->GetBranch("c_id") ->SetAddress(triggerCellCell_id_ .get()); - treeTriggerCells_->GetBranch("c_zside") ->SetAddress(triggerCellCell_zside_ .get()); - treeTriggerCells_->GetBranch("c_subdet") ->SetAddress(triggerCellCell_subdet_.get()); - treeTriggerCells_->GetBranch("c_layer") ->SetAddress(triggerCellCell_layer_ .get()); - treeTriggerCells_->GetBranch("c_wafer") ->SetAddress(triggerCellCell_wafer_ .get()); - treeTriggerCells_->GetBranch("c_cell") ->SetAddress(triggerCellCell_cell_ .get()); - treeTriggerCells_->GetBranch("c_ieta") ->SetAddress(triggerCellCell_ieta_ .get()); - treeTriggerCells_->GetBranch("c_iphi") ->SetAddress(triggerCellCell_iphi_ .get()); - treeTriggerCells_->GetBranch("c_x") ->SetAddress(triggerCellCell_x_ .get()); - treeTriggerCells_->GetBranch("c_y") ->SetAddress(triggerCellCell_y_ .get()); - treeTriggerCells_->GetBranch("c_z") ->SetAddress(triggerCellCell_z_ .get()); + triggerCellCell_id_.reset(new int[n], array_deleter()); + triggerCellCell_zside_.reset(new int[n], array_deleter()); + triggerCellCell_subdet_.reset(new int[n], array_deleter()); + triggerCellCell_layer_.reset(new int[n], array_deleter()); + triggerCellCell_wafer_.reset(new int[n], array_deleter()); + triggerCellCell_cell_.reset(new int[n], array_deleter()); + triggerCellCell_ieta_.reset(new int[n], array_deleter()); + triggerCellCell_iphi_.reset(new int[n], array_deleter()); + triggerCellCell_x_.reset(new float[n], array_deleter()); + triggerCellCell_y_.reset(new float[n], array_deleter()); + triggerCellCell_z_.reset(new float[n], array_deleter()); + + treeTriggerCells_->GetBranch("c_id")->SetAddress(triggerCellCell_id_.get()); + treeTriggerCells_->GetBranch("c_zside")->SetAddress(triggerCellCell_zside_.get()); + treeTriggerCells_->GetBranch("c_subdet")->SetAddress(triggerCellCell_subdet_.get()); + treeTriggerCells_->GetBranch("c_layer")->SetAddress(triggerCellCell_layer_.get()); + treeTriggerCells_->GetBranch("c_wafer")->SetAddress(triggerCellCell_wafer_.get()); + treeTriggerCells_->GetBranch("c_cell")->SetAddress(triggerCellCell_cell_.get()); + treeTriggerCells_->GetBranch("c_ieta")->SetAddress(triggerCellCell_ieta_.get()); + treeTriggerCells_->GetBranch("c_iphi")->SetAddress(triggerCellCell_iphi_.get()); + treeTriggerCells_->GetBranch("c_x")->SetAddress(triggerCellCell_x_.get()); + treeTriggerCells_->GetBranch("c_y")->SetAddress(triggerCellCell_y_.get()); + treeTriggerCells_->GetBranch("c_z")->SetAddress(triggerCellCell_z_.get()); } - - /*****************************************************************/ void HGCalTriggerGeomTester::setTreeTriggerCellNeighborSize(const size_t n) /*****************************************************************/ { - triggerCellNeighbor_id_.reset(new int[n],array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_wafer_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_cell_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[n], array_deleter()); - treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); - treeTriggerCells_->GetBranch("neighbor_zside") ->SetAddress(triggerCellNeighbor_zside_ .get()); - treeTriggerCells_->GetBranch("neighbor_subdet") ->SetAddress(triggerCellNeighbor_subdet_.get()); - treeTriggerCells_->GetBranch("neighbor_layer") ->SetAddress(triggerCellNeighbor_layer_ .get()); - treeTriggerCells_->GetBranch("neighbor_wafer") ->SetAddress(triggerCellNeighbor_wafer_ .get()); - treeTriggerCells_->GetBranch("neighbor_cell") ->SetAddress(triggerCellNeighbor_cell_ .get()); - treeTriggerCells_->GetBranch("neighbor_distance") ->SetAddress(triggerCellNeighbor_distance_ .get()); + triggerCellNeighbor_id_.reset(new int[n], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[n], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[n], array_deleter()); + triggerCellNeighbor_wafer_.reset(new int[n], array_deleter()); + triggerCellNeighbor_cell_.reset(new int[n], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[n], array_deleter()); + treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); + treeTriggerCells_->GetBranch("neighbor_zside")->SetAddress(triggerCellNeighbor_zside_.get()); + treeTriggerCells_->GetBranch("neighbor_subdet")->SetAddress(triggerCellNeighbor_subdet_.get()); + treeTriggerCells_->GetBranch("neighbor_layer")->SetAddress(triggerCellNeighbor_layer_.get()); + treeTriggerCells_->GetBranch("neighbor_wafer")->SetAddress(triggerCellNeighbor_wafer_.get()); + treeTriggerCells_->GetBranch("neighbor_cell")->SetAddress(triggerCellNeighbor_cell_.get()); + treeTriggerCells_->GetBranch("neighbor_distance")->SetAddress(triggerCellNeighbor_distance_.get()); } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9.cc b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9.cc index 68a4ffb430346..ea50b73220fb2 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9.cc @@ -4,7 +4,6 @@ #include "TTree.h" - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDAnalyzer.h" @@ -31,1016 +30,959 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include - -namespace -{ - template - struct array_deleter - { - void operator () (T* arr) { delete [] arr; } - }; -} - - -class HGCalTriggerGeomTesterV9 : public edm::stream::EDAnalyzer<> -{ - public: - explicit HGCalTriggerGeomTesterV9(const edm::ParameterSet& ); - ~HGCalTriggerGeomTesterV9(); - - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - - private: - void fillTriggerGeometry(); - bool checkMappingConsistency(); - bool checkNeighborConsistency(); - void setTreeModuleSize(const size_t n); - void setTreeModuleCellSize(const size_t n); - void setTreeTriggerCellSize(const size_t n); - void setTreeCellCornerSize(const size_t n); - void setTreeTriggerCellNeighborSize(const size_t n); - - edm::ESHandle triggerGeometry_; - edm::ESHandle eeGeometry_; - edm::ESHandle hsiGeometry_; - edm::ESHandle hscGeometry_; - edm::Service fs_; - bool no_trigger_; - bool no_neighbors_; - TTree* treeModules_; - TTree* treeTriggerCells_; - TTree* treeCells_; - TTree* treeCellsBH_; - // tree variables - int moduleId_ ; - int moduleSide_ ; - int moduleSubdet_ ; - int moduleLayer_ ; - int module_ ; - float moduleX_ ; - float moduleY_ ; - float moduleZ_ ; - int moduleTC_N_ ; - std::shared_ptr moduleTC_id_ ; - std::shared_ptr moduleTC_zside_ ; - std::shared_ptr moduleTC_subdet_; - std::shared_ptr moduleTC_layer_ ; - std::shared_ptr moduleTC_wafer_; - std::shared_ptr moduleTC_cell_ ; - std::shared_ptr moduleTC_x_ ; - std::shared_ptr moduleTC_y_ ; - std::shared_ptr moduleTC_z_ ; - int moduleCell_N_ ; - std::shared_ptr moduleCell_id_ ; - std::shared_ptr moduleCell_zside_ ; - std::shared_ptr moduleCell_subdet_; - std::shared_ptr moduleCell_layer_ ; - std::shared_ptr moduleCell_waferU_; - std::shared_ptr moduleCell_waferV_; - std::shared_ptr moduleCell_cellU_ ; - std::shared_ptr moduleCell_cellV_ ; - std::shared_ptr moduleCell_x_ ; - std::shared_ptr moduleCell_y_ ; - std::shared_ptr moduleCell_z_ ; - int triggerCellId_ ; - int triggerCellSide_ ; - int triggerCellSubdet_ ; - int triggerCellLayer_ ; - int triggerCellWafer_ ; - int triggerCell_ ; - float triggerCellX_ ; - float triggerCellY_ ; - float triggerCellZ_ ; - int triggerCellNeighbor_N_; - std::shared_ptr triggerCellNeighbor_id_ ; - std::shared_ptr triggerCellNeighbor_zside_ ; - std::shared_ptr triggerCellNeighbor_subdet_; - std::shared_ptr triggerCellNeighbor_layer_ ; - std::shared_ptr triggerCellNeighbor_wafer_; - std::shared_ptr triggerCellNeighbor_cell_ ; - std::shared_ptr triggerCellNeighbor_distance_ ; - int triggerCellCell_N_ ; - std::shared_ptr triggerCellCell_id_ ; - std::shared_ptr triggerCellCell_zside_ ; - std::shared_ptr triggerCellCell_subdet_; - std::shared_ptr triggerCellCell_layer_ ; - std::shared_ptr triggerCellCell_waferU_; - std::shared_ptr triggerCellCell_waferV_; - std::shared_ptr triggerCellCell_cellU_ ; - std::shared_ptr triggerCellCell_cellV_ ; - std::shared_ptr triggerCellCell_ieta_ ; - std::shared_ptr triggerCellCell_iphi_ ; - std::shared_ptr triggerCellCell_x_ ; - std::shared_ptr triggerCellCell_y_ ; - std::shared_ptr triggerCellCell_z_ ; - int cellId_ ; - int cellSide_ ; - int cellSubdet_ ; - int cellLayer_ ; - int cellWaferU_ ; - int cellWaferV_ ; - int cellWaferType_ ; - int cellWaferRow_; - int cellWaferColumn_; - int cellU_ ; - int cellV_ ; - float cellX_ ; - float cellY_ ; - float cellZ_ ; - int cellCornersN_; - std::shared_ptr cellCornersX_ ; - std::shared_ptr cellCornersY_ ; - std::shared_ptr cellCornersZ_ ; - int cellBHId_ ; - int cellBHType_ ; - int cellBHSide_ ; - int cellBHSubdet_ ; - int cellBHLayer_ ; - int cellBHIEta_ ; - int cellBHIPhi_ ; - float cellBHEta_ ; - float cellBHPhi_ ; - float cellBHX_ ; - float cellBHY_ ; - float cellBHZ_ ; - float cellBHX1_ ; - float cellBHY1_ ; - float cellBHX2_ ; - float cellBHY2_ ; - float cellBHX3_ ; - float cellBHY3_ ; - float cellBHX4_ ; - float cellBHY4_ ; - - private: - typedef std::unordered_map> trigger_map_set; - +#include + +namespace { + template + struct array_deleter { + void operator()(T* arr) { delete[] arr; } + }; +} // namespace + +class HGCalTriggerGeomTesterV9 : public edm::stream::EDAnalyzer<> { +public: + explicit HGCalTriggerGeomTesterV9(const edm::ParameterSet&); + ~HGCalTriggerGeomTesterV9(); + + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void fillTriggerGeometry(); + bool checkMappingConsistency(); + bool checkNeighborConsistency(); + void setTreeModuleSize(const size_t n); + void setTreeModuleCellSize(const size_t n); + void setTreeTriggerCellSize(const size_t n); + void setTreeCellCornerSize(const size_t n); + void setTreeTriggerCellNeighborSize(const size_t n); + + edm::ESHandle triggerGeometry_; + edm::ESHandle eeGeometry_; + edm::ESHandle hsiGeometry_; + edm::ESHandle hscGeometry_; + edm::Service fs_; + bool no_trigger_; + bool no_neighbors_; + TTree* treeModules_; + TTree* treeTriggerCells_; + TTree* treeCells_; + TTree* treeCellsBH_; + // tree variables + int moduleId_; + int moduleSide_; + int moduleSubdet_; + int moduleLayer_; + int module_; + float moduleX_; + float moduleY_; + float moduleZ_; + int moduleTC_N_; + std::shared_ptr moduleTC_id_; + std::shared_ptr moduleTC_zside_; + std::shared_ptr moduleTC_subdet_; + std::shared_ptr moduleTC_layer_; + std::shared_ptr moduleTC_wafer_; + std::shared_ptr moduleTC_cell_; + std::shared_ptr moduleTC_x_; + std::shared_ptr moduleTC_y_; + std::shared_ptr moduleTC_z_; + int moduleCell_N_; + std::shared_ptr moduleCell_id_; + std::shared_ptr moduleCell_zside_; + std::shared_ptr moduleCell_subdet_; + std::shared_ptr moduleCell_layer_; + std::shared_ptr moduleCell_waferU_; + std::shared_ptr moduleCell_waferV_; + std::shared_ptr moduleCell_cellU_; + std::shared_ptr moduleCell_cellV_; + std::shared_ptr moduleCell_x_; + std::shared_ptr moduleCell_y_; + std::shared_ptr moduleCell_z_; + int triggerCellId_; + int triggerCellSide_; + int triggerCellSubdet_; + int triggerCellLayer_; + int triggerCellWafer_; + int triggerCell_; + float triggerCellX_; + float triggerCellY_; + float triggerCellZ_; + int triggerCellNeighbor_N_; + std::shared_ptr triggerCellNeighbor_id_; + std::shared_ptr triggerCellNeighbor_zside_; + std::shared_ptr triggerCellNeighbor_subdet_; + std::shared_ptr triggerCellNeighbor_layer_; + std::shared_ptr triggerCellNeighbor_wafer_; + std::shared_ptr triggerCellNeighbor_cell_; + std::shared_ptr triggerCellNeighbor_distance_; + int triggerCellCell_N_; + std::shared_ptr triggerCellCell_id_; + std::shared_ptr triggerCellCell_zside_; + std::shared_ptr triggerCellCell_subdet_; + std::shared_ptr triggerCellCell_layer_; + std::shared_ptr triggerCellCell_waferU_; + std::shared_ptr triggerCellCell_waferV_; + std::shared_ptr triggerCellCell_cellU_; + std::shared_ptr triggerCellCell_cellV_; + std::shared_ptr triggerCellCell_ieta_; + std::shared_ptr triggerCellCell_iphi_; + std::shared_ptr triggerCellCell_x_; + std::shared_ptr triggerCellCell_y_; + std::shared_ptr triggerCellCell_z_; + int cellId_; + int cellSide_; + int cellSubdet_; + int cellLayer_; + int cellWaferU_; + int cellWaferV_; + int cellWaferType_; + int cellWaferRow_; + int cellWaferColumn_; + int cellU_; + int cellV_; + float cellX_; + float cellY_; + float cellZ_; + int cellCornersN_; + std::shared_ptr cellCornersX_; + std::shared_ptr cellCornersY_; + std::shared_ptr cellCornersZ_; + int cellBHId_; + int cellBHType_; + int cellBHSide_; + int cellBHSubdet_; + int cellBHLayer_; + int cellBHIEta_; + int cellBHIPhi_; + float cellBHEta_; + float cellBHPhi_; + float cellBHX_; + float cellBHY_; + float cellBHZ_; + float cellBHX1_; + float cellBHY1_; + float cellBHX2_; + float cellBHY2_; + float cellBHX3_; + float cellBHY3_; + float cellBHX4_; + float cellBHY4_; + +private: + typedef std::unordered_map> trigger_map_set; }; - /*****************************************************************/ -HGCalTriggerGeomTesterV9::HGCalTriggerGeomTesterV9(const edm::ParameterSet& conf): - no_trigger_(false), - no_neighbors_(false) +HGCalTriggerGeomTesterV9::HGCalTriggerGeomTesterV9(const edm::ParameterSet& conf) + : no_trigger_(false), + no_neighbors_(false) /*****************************************************************/ { - - // initialize output trees - treeModules_ = fs_->make("TreeModules","Tree of all HGC modules"); - treeModules_->Branch("id" , &moduleId_ , "id/I"); - treeModules_->Branch("zside" , &moduleSide_ , "zside/I"); - treeModules_->Branch("subdet" , &moduleSubdet_ , "subdet/I"); - treeModules_->Branch("layer" , &moduleLayer_ , "layer/I"); - treeModules_->Branch("module" , &module_ , "module/I"); - treeModules_->Branch("x" , &moduleX_ , "x/F"); - treeModules_->Branch("y" , &moduleY_ , "y/F"); - treeModules_->Branch("z" , &moduleZ_ , "z/F"); - treeModules_->Branch("tc_n" , &moduleTC_N_ , "tc_n/I"); - moduleTC_id_ .reset(new int[1], array_deleter()); - moduleTC_zside_ .reset(new int[1], array_deleter()); - moduleTC_subdet_.reset(new int[1], array_deleter()); - moduleTC_layer_ .reset(new int[1], array_deleter()); - moduleTC_wafer_ .reset(new int[1], array_deleter()); - moduleTC_cell_ .reset(new int[1], array_deleter()); - moduleTC_x_ .reset(new float[1], array_deleter()); - moduleTC_y_ .reset(new float[1], array_deleter()); - moduleTC_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("tc_id" , moduleTC_id_.get() , "tc_id[tc_n]/I"); - treeModules_->Branch("tc_zside" , moduleTC_zside_.get() , "tc_zside[tc_n]/I"); - treeModules_->Branch("tc_subdet" , moduleTC_subdet_.get() , "tc_subdet[tc_n]/I"); - treeModules_->Branch("tc_layer" , moduleTC_layer_.get() , "tc_layer[tc_n]/I"); - treeModules_->Branch("tc_wafer" , moduleTC_wafer_.get() , "tc_wafer[tc_n]/I"); - treeModules_->Branch("tc_cell" , moduleTC_cell_.get() , "tc_cell[tc_n]/I"); - treeModules_->Branch("tc_x" , moduleTC_x_.get() , "tc_x[tc_n]/F"); - treeModules_->Branch("tc_y" , moduleTC_y_.get() , "tc_y[tc_n]/F"); - treeModules_->Branch("tc_z" , moduleTC_z_.get() , "tc_z[tc_n]/F"); - treeModules_->Branch("c_n" , &moduleCell_N_ , "c_n/I"); - moduleCell_id_ .reset(new int[1], array_deleter()); - moduleCell_zside_ .reset(new int[1], array_deleter()); - moduleCell_subdet_.reset(new int[1], array_deleter()); - moduleCell_layer_ .reset(new int[1], array_deleter()); - moduleCell_waferU_ .reset(new int[1], array_deleter()); - moduleCell_waferV_ .reset(new int[1], array_deleter()); - moduleCell_cellU_ .reset(new int[1], array_deleter()); - moduleCell_cellV_ .reset(new int[1], array_deleter()); - moduleCell_x_ .reset(new float[1], array_deleter()); - moduleCell_y_ .reset(new float[1], array_deleter()); - moduleCell_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("c_id" , moduleCell_id_.get() , "c_id[c_n]/I"); - treeModules_->Branch("c_zside" , moduleCell_zside_.get() , "c_zside[c_n]/I"); - treeModules_->Branch("c_subdet" , moduleCell_subdet_.get() , "c_subdet[c_n]/I"); - treeModules_->Branch("c_layer" , moduleCell_layer_.get() , "c_layer[c_n]/I"); - treeModules_->Branch("c_waferu" , moduleCell_waferU_.get() , "c_waferu[c_n]/I"); - treeModules_->Branch("c_waferv" , moduleCell_waferV_.get() , "c_waferv[c_n]/I"); - treeModules_->Branch("c_cellu" , moduleCell_cellU_.get() , "c_cellu[c_n]/I"); - treeModules_->Branch("c_cellv" , moduleCell_cellV_.get() , "c_cellv[c_n]/I"); - treeModules_->Branch("c_x" , moduleCell_x_.get() , "c_x[c_n]/F"); - treeModules_->Branch("c_y" , moduleCell_y_.get() , "c_y[c_n]/F"); - treeModules_->Branch("c_z" , moduleCell_z_.get() , "c_z[c_n]/F"); - // - treeTriggerCells_ = fs_->make("TreeTriggerCells","Tree of all HGC trigger cells"); - treeTriggerCells_->Branch("id" , &triggerCellId_ , "id/I"); - treeTriggerCells_->Branch("zside" , &triggerCellSide_ , "zside/I"); - treeTriggerCells_->Branch("subdet" , &triggerCellSubdet_ , "subdet/I"); - treeTriggerCells_->Branch("layer" , &triggerCellLayer_ , "layer/I"); - treeTriggerCells_->Branch("wafer" , &triggerCellWafer_ , "wafer/I"); - treeTriggerCells_->Branch("triggercell" , &triggerCell_ , "triggercell/I"); - treeTriggerCells_->Branch("x" , &triggerCellX_ , "x/F"); - treeTriggerCells_->Branch("y" , &triggerCellY_ , "y/F"); - treeTriggerCells_->Branch("z" , &triggerCellZ_ , "z/F"); - treeTriggerCells_->Branch("neighbor_n" , &triggerCellNeighbor_N_ , "neighbor_n/I"); - triggerCellNeighbor_id_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_subdet_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_wafer_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_cell_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get() , "neighbor_zside[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get() , "neighbor_subdet[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get() , "neighbor_layer[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_wafer", triggerCellNeighbor_wafer_.get() , "neighbor_wafer[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_cell", triggerCellNeighbor_cell_.get() , "neighbor_cell[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_distance", triggerCellNeighbor_distance_.get() , "neighbor_distance[neighbor_n]/F"); - treeTriggerCells_->Branch("c_n" , &triggerCellCell_N_ , "c_n/I"); - triggerCellCell_id_ .reset(new int[1], array_deleter()); - triggerCellCell_zside_ .reset(new int[1], array_deleter()); - triggerCellCell_subdet_ .reset(new int[1], array_deleter()); - triggerCellCell_layer_ .reset(new int[1], array_deleter()); - triggerCellCell_waferU_ .reset(new int[1], array_deleter()); - triggerCellCell_waferV_ .reset(new int[1], array_deleter()); - triggerCellCell_cellU_ .reset(new int[1], array_deleter()); - triggerCellCell_cellV_ .reset(new int[1], array_deleter()); - triggerCellCell_ieta_ .reset(new int[1], array_deleter()); - triggerCellCell_iphi_ .reset(new int[1], array_deleter()); - triggerCellCell_x_ .reset(new float[1], array_deleter()); - triggerCellCell_y_ .reset(new float[1], array_deleter()); - triggerCellCell_z_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("c_id" , triggerCellCell_id_.get() , "c_id[c_n]/I"); - treeTriggerCells_->Branch("c_zside" , triggerCellCell_zside_.get() , "c_zside[c_n]/I"); - treeTriggerCells_->Branch("c_subdet" , triggerCellCell_subdet_.get() , "c_subdet[c_n]/I"); - treeTriggerCells_->Branch("c_layer" , triggerCellCell_layer_.get() , "c_layer[c_n]/I"); - treeTriggerCells_->Branch("c_waferu" , triggerCellCell_waferU_.get() , "c_waferu[c_n]/I"); - treeTriggerCells_->Branch("c_waferv" , triggerCellCell_waferV_.get() , "c_waferv[c_n]/I"); - treeTriggerCells_->Branch("c_cellu" , triggerCellCell_cellU_.get() , "c_cellu[c_n]/I"); - treeTriggerCells_->Branch("c_cellv" , triggerCellCell_cellV_.get() , "c_cellv[c_n]/I"); - treeTriggerCells_->Branch("c_ieta" , triggerCellCell_ieta_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_iphi" , triggerCellCell_iphi_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_x" , triggerCellCell_x_.get() , "c_x[c_n]/F"); - treeTriggerCells_->Branch("c_y" , triggerCellCell_y_.get() , "c_y[c_n]/F"); - treeTriggerCells_->Branch("c_z" , triggerCellCell_z_.get() , "c_z[c_n]/F"); - // - treeCells_ = fs_->make("TreeCells","Tree of all HGC cells"); - treeCells_->Branch("id" , &cellId_ , "id/I"); - treeCells_->Branch("zside" , &cellSide_ , "zside/I"); - treeCells_->Branch("subdet" , &cellSubdet_ , "subdet/I"); - treeCells_->Branch("layer" , &cellLayer_ , "layer/I"); - treeCells_->Branch("waferu" , &cellWaferU_ , "waferu/I"); - treeCells_->Branch("waferv" , &cellWaferV_ , "waferv/I"); - treeCells_->Branch("wafertype" , &cellWaferType_ , "wafertype/I"); - treeCells_->Branch("waferrow" , &cellWaferRow_ , "waferrow/I"); - treeCells_->Branch("wafercolumn" , &cellWaferColumn_ , "wafercolumn/I"); - treeCells_->Branch("cellu" , &cellU_ , "cellu/I"); - treeCells_->Branch("cellv" , &cellV_ , "cellv/I"); - treeCells_->Branch("x" , &cellX_ , "x/F"); - treeCells_->Branch("y" , &cellY_ , "y/F"); - treeCells_->Branch("z" , &cellZ_ , "z/F"); - treeCells_->Branch("corner_n" , &cellCornersN_ , "corner_n/I"); - treeCells_->Branch("corner_x" , cellCornersX_.get() , "corner_x[corner_n]/F"); - treeCells_->Branch("corner_y" , cellCornersY_.get() , "corner_y[corner_n]/F"); - treeCells_->Branch("corner_z" , cellCornersZ_.get() , "corner_z[corner_n]/F"); - // - treeCellsBH_ = fs_->make("TreeCellsBH","Tree of all BH cells"); - treeCellsBH_->Branch("id", &cellBHId_, "id/I"); - treeCellsBH_->Branch("type", &cellBHType_, "type/I"); - treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); - treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); - treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); - treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); - treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); - treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); - treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); - treeCellsBH_->Branch("x", &cellBHX_, "x/F"); - treeCellsBH_->Branch("y", &cellBHY_, "y/F"); - treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); - treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); - treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); - treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); - treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); - treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); - treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); - treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); - treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); + // initialize output trees + treeModules_ = fs_->make("TreeModules", "Tree of all HGC modules"); + treeModules_->Branch("id", &moduleId_, "id/I"); + treeModules_->Branch("zside", &moduleSide_, "zside/I"); + treeModules_->Branch("subdet", &moduleSubdet_, "subdet/I"); + treeModules_->Branch("layer", &moduleLayer_, "layer/I"); + treeModules_->Branch("module", &module_, "module/I"); + treeModules_->Branch("x", &moduleX_, "x/F"); + treeModules_->Branch("y", &moduleY_, "y/F"); + treeModules_->Branch("z", &moduleZ_, "z/F"); + treeModules_->Branch("tc_n", &moduleTC_N_, "tc_n/I"); + moduleTC_id_.reset(new int[1], array_deleter()); + moduleTC_zside_.reset(new int[1], array_deleter()); + moduleTC_subdet_.reset(new int[1], array_deleter()); + moduleTC_layer_.reset(new int[1], array_deleter()); + moduleTC_wafer_.reset(new int[1], array_deleter()); + moduleTC_cell_.reset(new int[1], array_deleter()); + moduleTC_x_.reset(new float[1], array_deleter()); + moduleTC_y_.reset(new float[1], array_deleter()); + moduleTC_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("tc_id", moduleTC_id_.get(), "tc_id[tc_n]/I"); + treeModules_->Branch("tc_zside", moduleTC_zside_.get(), "tc_zside[tc_n]/I"); + treeModules_->Branch("tc_subdet", moduleTC_subdet_.get(), "tc_subdet[tc_n]/I"); + treeModules_->Branch("tc_layer", moduleTC_layer_.get(), "tc_layer[tc_n]/I"); + treeModules_->Branch("tc_wafer", moduleTC_wafer_.get(), "tc_wafer[tc_n]/I"); + treeModules_->Branch("tc_cell", moduleTC_cell_.get(), "tc_cell[tc_n]/I"); + treeModules_->Branch("tc_x", moduleTC_x_.get(), "tc_x[tc_n]/F"); + treeModules_->Branch("tc_y", moduleTC_y_.get(), "tc_y[tc_n]/F"); + treeModules_->Branch("tc_z", moduleTC_z_.get(), "tc_z[tc_n]/F"); + treeModules_->Branch("c_n", &moduleCell_N_, "c_n/I"); + moduleCell_id_.reset(new int[1], array_deleter()); + moduleCell_zside_.reset(new int[1], array_deleter()); + moduleCell_subdet_.reset(new int[1], array_deleter()); + moduleCell_layer_.reset(new int[1], array_deleter()); + moduleCell_waferU_.reset(new int[1], array_deleter()); + moduleCell_waferV_.reset(new int[1], array_deleter()); + moduleCell_cellU_.reset(new int[1], array_deleter()); + moduleCell_cellV_.reset(new int[1], array_deleter()); + moduleCell_x_.reset(new float[1], array_deleter()); + moduleCell_y_.reset(new float[1], array_deleter()); + moduleCell_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("c_id", moduleCell_id_.get(), "c_id[c_n]/I"); + treeModules_->Branch("c_zside", moduleCell_zside_.get(), "c_zside[c_n]/I"); + treeModules_->Branch("c_subdet", moduleCell_subdet_.get(), "c_subdet[c_n]/I"); + treeModules_->Branch("c_layer", moduleCell_layer_.get(), "c_layer[c_n]/I"); + treeModules_->Branch("c_waferu", moduleCell_waferU_.get(), "c_waferu[c_n]/I"); + treeModules_->Branch("c_waferv", moduleCell_waferV_.get(), "c_waferv[c_n]/I"); + treeModules_->Branch("c_cellu", moduleCell_cellU_.get(), "c_cellu[c_n]/I"); + treeModules_->Branch("c_cellv", moduleCell_cellV_.get(), "c_cellv[c_n]/I"); + treeModules_->Branch("c_x", moduleCell_x_.get(), "c_x[c_n]/F"); + treeModules_->Branch("c_y", moduleCell_y_.get(), "c_y[c_n]/F"); + treeModules_->Branch("c_z", moduleCell_z_.get(), "c_z[c_n]/F"); + // + treeTriggerCells_ = fs_->make("TreeTriggerCells", "Tree of all HGC trigger cells"); + treeTriggerCells_->Branch("id", &triggerCellId_, "id/I"); + treeTriggerCells_->Branch("zside", &triggerCellSide_, "zside/I"); + treeTriggerCells_->Branch("subdet", &triggerCellSubdet_, "subdet/I"); + treeTriggerCells_->Branch("layer", &triggerCellLayer_, "layer/I"); + treeTriggerCells_->Branch("wafer", &triggerCellWafer_, "wafer/I"); + treeTriggerCells_->Branch("triggercell", &triggerCell_, "triggercell/I"); + treeTriggerCells_->Branch("x", &triggerCellX_, "x/F"); + treeTriggerCells_->Branch("y", &triggerCellY_, "y/F"); + treeTriggerCells_->Branch("z", &triggerCellZ_, "z/F"); + treeTriggerCells_->Branch("neighbor_n", &triggerCellNeighbor_N_, "neighbor_n/I"); + triggerCellNeighbor_id_.reset(new int[1], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[1], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[1], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[1], array_deleter()); + triggerCellNeighbor_wafer_.reset(new int[1], array_deleter()); + triggerCellNeighbor_cell_.reset(new int[1], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get(), "neighbor_zside[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get(), "neighbor_subdet[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get(), "neighbor_layer[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_wafer", triggerCellNeighbor_wafer_.get(), "neighbor_wafer[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_cell", triggerCellNeighbor_cell_.get(), "neighbor_cell[neighbor_n]/I"); + treeTriggerCells_->Branch( + "neighbor_distance", triggerCellNeighbor_distance_.get(), "neighbor_distance[neighbor_n]/F"); + treeTriggerCells_->Branch("c_n", &triggerCellCell_N_, "c_n/I"); + triggerCellCell_id_.reset(new int[1], array_deleter()); + triggerCellCell_zside_.reset(new int[1], array_deleter()); + triggerCellCell_subdet_.reset(new int[1], array_deleter()); + triggerCellCell_layer_.reset(new int[1], array_deleter()); + triggerCellCell_waferU_.reset(new int[1], array_deleter()); + triggerCellCell_waferV_.reset(new int[1], array_deleter()); + triggerCellCell_cellU_.reset(new int[1], array_deleter()); + triggerCellCell_cellV_.reset(new int[1], array_deleter()); + triggerCellCell_ieta_.reset(new int[1], array_deleter()); + triggerCellCell_iphi_.reset(new int[1], array_deleter()); + triggerCellCell_x_.reset(new float[1], array_deleter()); + triggerCellCell_y_.reset(new float[1], array_deleter()); + triggerCellCell_z_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("c_id", triggerCellCell_id_.get(), "c_id[c_n]/I"); + treeTriggerCells_->Branch("c_zside", triggerCellCell_zside_.get(), "c_zside[c_n]/I"); + treeTriggerCells_->Branch("c_subdet", triggerCellCell_subdet_.get(), "c_subdet[c_n]/I"); + treeTriggerCells_->Branch("c_layer", triggerCellCell_layer_.get(), "c_layer[c_n]/I"); + treeTriggerCells_->Branch("c_waferu", triggerCellCell_waferU_.get(), "c_waferu[c_n]/I"); + treeTriggerCells_->Branch("c_waferv", triggerCellCell_waferV_.get(), "c_waferv[c_n]/I"); + treeTriggerCells_->Branch("c_cellu", triggerCellCell_cellU_.get(), "c_cellu[c_n]/I"); + treeTriggerCells_->Branch("c_cellv", triggerCellCell_cellV_.get(), "c_cellv[c_n]/I"); + treeTriggerCells_->Branch("c_ieta", triggerCellCell_ieta_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_iphi", triggerCellCell_iphi_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_x", triggerCellCell_x_.get(), "c_x[c_n]/F"); + treeTriggerCells_->Branch("c_y", triggerCellCell_y_.get(), "c_y[c_n]/F"); + treeTriggerCells_->Branch("c_z", triggerCellCell_z_.get(), "c_z[c_n]/F"); + // + treeCells_ = fs_->make("TreeCells", "Tree of all HGC cells"); + treeCells_->Branch("id", &cellId_, "id/I"); + treeCells_->Branch("zside", &cellSide_, "zside/I"); + treeCells_->Branch("subdet", &cellSubdet_, "subdet/I"); + treeCells_->Branch("layer", &cellLayer_, "layer/I"); + treeCells_->Branch("waferu", &cellWaferU_, "waferu/I"); + treeCells_->Branch("waferv", &cellWaferV_, "waferv/I"); + treeCells_->Branch("wafertype", &cellWaferType_, "wafertype/I"); + treeCells_->Branch("waferrow", &cellWaferRow_, "waferrow/I"); + treeCells_->Branch("wafercolumn", &cellWaferColumn_, "wafercolumn/I"); + treeCells_->Branch("cellu", &cellU_, "cellu/I"); + treeCells_->Branch("cellv", &cellV_, "cellv/I"); + treeCells_->Branch("x", &cellX_, "x/F"); + treeCells_->Branch("y", &cellY_, "y/F"); + treeCells_->Branch("z", &cellZ_, "z/F"); + treeCells_->Branch("corner_n", &cellCornersN_, "corner_n/I"); + treeCells_->Branch("corner_x", cellCornersX_.get(), "corner_x[corner_n]/F"); + treeCells_->Branch("corner_y", cellCornersY_.get(), "corner_y[corner_n]/F"); + treeCells_->Branch("corner_z", cellCornersZ_.get(), "corner_z[corner_n]/F"); + // + treeCellsBH_ = fs_->make("TreeCellsBH", "Tree of all BH cells"); + treeCellsBH_->Branch("id", &cellBHId_, "id/I"); + treeCellsBH_->Branch("type", &cellBHType_, "type/I"); + treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); + treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); + treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); + treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); + treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); + treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); + treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); + treeCellsBH_->Branch("x", &cellBHX_, "x/F"); + treeCellsBH_->Branch("y", &cellBHY_, "y/F"); + treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); + treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); + treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); + treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); + treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); + treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); + treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); + treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); + treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); } - - /*****************************************************************/ -HGCalTriggerGeomTesterV9::~HGCalTriggerGeomTesterV9() +HGCalTriggerGeomTesterV9::~HGCalTriggerGeomTesterV9() /*****************************************************************/ -{ -} +{} /*****************************************************************/ -void HGCalTriggerGeomTesterV9::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) +void HGCalTriggerGeomTesterV9::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) /*****************************************************************/ { - es.get().get("", triggerGeometry_); + es.get().get("", triggerGeometry_); - no_trigger_ = !checkMappingConsistency(); - no_neighbors_ = !checkNeighborConsistency(); - fillTriggerGeometry(); + no_trigger_ = !checkMappingConsistency(); + no_neighbors_ = !checkNeighborConsistency(); + fillTriggerGeometry(); } +bool HGCalTriggerGeomTesterV9::checkMappingConsistency() { + try { + trigger_map_set modules_to_triggercells; + trigger_map_set modules_to_cells; + trigger_map_set triggercells_to_cells; -bool HGCalTriggerGeomTesterV9::checkMappingConsistency() -{ - try - { - trigger_map_set modules_to_triggercells; - trigger_map_set modules_to_cells; - trigger_map_set triggercells_to_cells; - - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - if(!triggerGeometry_->eeTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - // HSi - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - if(!triggerGeometry_->hsiTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - // HSc - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - // fill trigger cells - unsigned layer = HGCScintillatorDetId(id).layer(); - if(HGCScintillatorDetId(id).type()!=triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer)) - { - std::cout<<"Sci cell type = "<getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - - + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // HSi + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + if (!triggerGeometry_->hsiTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // HSc + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + // fill trigger cells + unsigned layer = HGCScintillatorDetId(id).layer(); + if (HGCScintillatorDetId(id).type() != triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer)) { + std::cout << "Sci cell type = " << HGCScintillatorDetId(id).type() + << " != " << triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer) << "\n"; + } + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } - edm::LogPrint("TriggerCellCheck")<<"Checking cell -> trigger cell -> cell consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - HGCalDetId id(triggercell_cells.first); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - // Check consistency of cells included in trigger cell - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); - const auto& cells = triggercell_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - edm::LogProblem("BadTriggerCell")<<"Error: \n Cell "< trigger cell mapping"; - } - } - } - edm::LogPrint("ModuleCheck")<<"Checking trigger cell -> module -> trigger cell consistency"; - // Loop over modules - for( const auto& module_triggercells : modules_to_triggercells ) - { - HGCalDetId id(module_triggercells.first); - // Check consistency of trigger cells included in module - HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); - const auto& triggercells = module_triggercells.second; - for(auto cell : triggercells) - { - if(triggercells_geom.find(cell)==triggercells_geom.end()) - { - HGCalDetId cellid(cell); - edm::LogProblem("BadModule")<<"Error: \n Trigger cell "< module mapping"; - } - } + edm::LogPrint("TriggerCellCheck") << "Checking cell -> trigger cell -> cell consistency"; + // Loop over trigger cells + for (const auto& triggercell_cells : triggercells_to_cells) { + HGCalDetId id(triggercell_cells.first); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + // Check consistency of cells included in trigger cell + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); + const auto& cells = triggercell_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + edm::LogProblem("BadTriggerCell") << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell) + << ")\n has not been found in \n trigger cell " << id; + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) + output << " " << HGCScintillatorDetId(cell_geom) << "\n"; + edm::LogProblem("BadTriggerCell") << output.str(); + } else { + edm::LogProblem("BadTriggerCell") << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell) + << ")\n has not been found in \n trigger cell " << id; + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) + output << " " << HGCSiliconDetId(cell_geom) << "\n"; + edm::LogProblem("BadTriggerCell") << output.str(); + } + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in cell <-> trigger cell mapping"; } - edm::LogPrint("ModuleCheck")<<"Checking cell -> module -> cell consistency"; - for( const auto& module_cells : modules_to_cells ) - { - HGCalDetId id(module_cells.first); - // Check consistency of cells included in module - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); - const auto& cells = module_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - edm::LogProblem("BadModule")<<"Error: \n Cell "< module mapping"; - } - } + } + } + edm::LogPrint("ModuleCheck") << "Checking trigger cell -> module -> trigger cell consistency"; + // Loop over modules + for (const auto& module_triggercells : modules_to_triggercells) { + HGCalDetId id(module_triggercells.first); + // Check consistency of trigger cells included in module + HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); + const auto& triggercells = module_triggercells.second; + for (auto cell : triggercells) { + if (triggercells_geom.find(cell) == triggercells_geom.end()) { + HGCalDetId cellid(cell); + edm::LogProblem("BadModule") << "Error: \n Trigger cell " << cell << "(" << cellid + << ")\n has not been found in \n module " << id; + std::stringstream output; + output << " Available trigger cells are:\n"; + for (auto cell_geom : triggercells_geom) { + output << " " << HGCalDetId(cell_geom) << "\n"; + } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in trigger cell <-> module mapping"; } + } } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - return false; + edm::LogPrint("ModuleCheck") << "Checking cell -> module -> cell consistency"; + for (const auto& module_cells : modules_to_cells) { + HGCalDetId id(module_cells.first); + // Check consistency of cells included in module + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); + const auto& cells = module_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell) + << ")\n has not been found in \n module " << id; + } else { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell) + << ")\n has not been found in \n module " << id; + } + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) { + output << cell_geom << " "; + } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in cell <-> module mapping"; + } + } } - return true; + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + return false; + } + return true; } +bool HGCalTriggerGeomTesterV9::checkNeighborConsistency() { + try { + trigger_map_set triggercells_to_cells; -bool HGCalTriggerGeomTesterV9::checkNeighborConsistency() -{ - try - { - trigger_map_set triggercells_to_cells; - - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->eeTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - // HSi - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->hsiTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // HSi + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + if (!triggerGeometry_->hsiTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } - // HSc - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->hscTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // HSc + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + if (!triggerGeometry_->hscTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } - edm::LogPrint("NeighborCheck")<<"Checking trigger cell neighbor consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - unsigned triggercell_id(triggercell_cells.first); - const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(triggercell_id); - for(const auto neighbor : neighbors) - { - const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); - // check if the original cell is included in the neigbors of neighbor - if(neighbors_of_neighbor.find(triggercell_id)==neighbors_of_neighbor.end()) - { - edm::LogProblem("BadNeighbor")<<"Error: \n Trigger cell "<< HGCalDetId(neighbor) << "\n is a neighbor of \n" << HGCalDetId(triggercell_id); - edm::LogProblem("BadNeighbor")<<" But the opposite is not true"; - std::stringstream output; - output<<" List of neighbors of neighbor = \n"; - for(const auto neighbor_of_neighbor : neighbors_of_neighbor) - { - output<<" "<< HGCalDetId(neighbor_of_neighbor)<<"\n"; - } - edm::LogProblem("BadNeighbor")<getNeighborsFromTriggerCell(triggercell_id); + for (const auto neighbor : neighbors) { + const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); + // check if the original cell is included in the neigbors of neighbor + if (neighbors_of_neighbor.find(triggercell_id) == neighbors_of_neighbor.end()) { + edm::LogProblem("BadNeighbor") << "Error: \n Trigger cell " << HGCalDetId(neighbor) + << "\n is a neighbor of \n" + << HGCalDetId(triggercell_id); + edm::LogProblem("BadNeighbor") << " But the opposite is not true"; + std::stringstream output; + output << " List of neighbors of neighbor = \n"; + for (const auto neighbor_of_neighbor : neighbors_of_neighbor) { + output << " " << HGCalDetId(neighbor_of_neighbor) << "\n"; + } + edm::LogProblem("BadNeighbor") << output.str(); } + } } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - return false; - } - return true; + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + return false; + } + return true; } - /*****************************************************************/ void HGCalTriggerGeomTesterV9::fillTriggerGeometry() /*****************************************************************/ { - trigger_map_set modules; - trigger_map_set trigger_cells; - - // Loop over cells - edm::LogPrint("TreeFilling")<<"Filling cells tree"; - // EE - std::cout<<"Filling EE geometry\n"; - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - cellId_ = detid.rawId(); - cellSide_ = detid.zside(); - cellSubdet_ = detid.subdet(); - cellLayer_ = detid.layer(); - cellWaferU_ = detid.waferU(); - cellWaferV_ = detid.waferV(); - cellU_ = detid.cellU(); - cellV_ = detid.cellV(); - int type1 = detid.type(); - int type2 = triggerGeometry_->eeTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); - if(type1!=type2) - { - std::cout<<"Found incompatible wafer types:\n "<eeGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); - cellCornersN_ = corners.size(); - setTreeCellCornerSize(cellCornersN_); - for(unsigned i=0; iFill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + trigger_map_set modules; + trigger_map_set trigger_cells; + + // Loop over cells + edm::LogPrint("TreeFilling") << "Filling cells tree"; + // EE + std::cout << "Filling EE geometry\n"; + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + cellId_ = detid.rawId(); + cellSide_ = detid.zside(); + cellSubdet_ = detid.subdet(); + cellLayer_ = detid.layer(); + cellWaferU_ = detid.waferU(); + cellWaferV_ = detid.waferV(); + cellU_ = detid.cellU(); + cellV_ = detid.cellV(); + int type1 = detid.type(); + int type2 = triggerGeometry_->eeTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); + if (type1 != type2) { + std::cout << "Found incompatible wafer types:\n " << detid << "\n"; } - std::cout<<"Filling HSi geometry\n"; - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - cellId_ = detid.rawId(); - cellSide_ = detid.zside(); - cellSubdet_ = detid.subdet(); - cellLayer_ = detid.layer(); - cellWaferU_ = detid.waferU(); - cellWaferV_ = detid.waferV(); - cellU_ = detid.cellU(); - cellV_ = detid.cellV(); - int type1 = detid.type(); - int type2 = triggerGeometry_->hsiTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); - if(type1!=type2) - { - std::cout<<"Found incompatible wafer types:\n "<hsiGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->hsiGeometry()->getCorners(id); - cellCornersN_ = corners.size(); - setTreeCellCornerSize(cellCornersN_); - for(unsigned i=0; iFill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // + GlobalPoint center = triggerGeometry_->eeGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); + cellCornersN_ = corners.size(); + setTreeCellCornerSize(cellCornersN_); + for (unsigned i = 0; i < corners.size(); i++) { + cellCornersX_.get()[i] = corners[i].x(); + cellCornersY_.get()[i] = corners[i].y(); + cellCornersZ_.get()[i] = corners[i].z(); } - std::cout<<"Filling HSc geometry\n"; - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - HGCScintillatorDetId cellid(id); - cellBHId_ = cellid.rawId(); - cellBHType_ = cellid.type(); - cellBHSide_ = cellid.zside(); - cellBHSubdet_ = cellid.subdetId(); - cellBHLayer_ = cellid.layer(); - cellBHIEta_ = cellid.ieta(); - cellBHIPhi_ = cellid.iphi(); - // - GlobalPoint center = triggerGeometry_->hscGeometry()->getPosition(id); - cellBHEta_ = center.eta(); - cellBHPhi_ = center.phi(); - cellBHX_ = center.x(); - cellBHY_ = center.y(); - cellBHZ_ = center.z(); - auto corners = triggerGeometry_->hscGeometry()->getCorners(id); - if(corners.size()>=4) - { - cellBHX1_ = corners[0].x(); - cellBHY1_ = corners[0].y(); - cellBHX2_ = corners[1].x(); - cellBHY2_ = corners[1].y(); - cellBHX3_ = corners[2].x(); - cellBHY3_ = corners[2].y(); - cellBHX4_ = corners[3].x(); - cellBHY4_ = corners[3].y(); - } - treeCellsBH_->Fill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); } - - // if problem detected in the trigger geometry, don't produce trigger trees - if(no_trigger_) return; - - // Loop over trigger cells - edm::LogPrint("TreeFilling")<<"Filling trigger cells tree"; - for( const auto& triggercell_cells : trigger_cells ) - { - HGCalDetId id(triggercell_cells.first); - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); - triggerCellId_ = id.rawId(); - triggerCellSide_ = id.zside(); - triggerCellSubdet_ = id.subdetId(); - triggerCellLayer_ = id.layer(); - triggerCellWafer_ = id.wafer(); - triggerCell_ = id.cell(); - triggerCellX_ = position.x(); - triggerCellY_ = position.y(); - triggerCellZ_ = position.z(); - triggerCellCell_N_ = triggercell_cells.second.size(); - // - setTreeTriggerCellSize(triggerCellCell_N_); - size_t ic = 0; - for(const auto& c : triggercell_cells.second) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - HGCScintillatorDetId cId(c); - GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = 0; - triggerCellCell_waferV_ .get()[ic] = 0; - triggerCellCell_cellU_ .get()[ic] = 0; - triggerCellCell_cellV_ .get()[ic] = 0; - triggerCellCell_ieta_ .get()[ic] = cId.ietaAbs(); - triggerCellCell_iphi_ .get()[ic] = cId.iphi(); - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - else - { - HGCSiliconDetId cId(c); - GlobalPoint cell_position = (cId.det()==DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->hsiGeometry()->getPosition(cId)); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = cId.waferU(); - triggerCellCell_waferV_ .get()[ic] = cId.waferV(); - triggerCellCell_cellU_ .get()[ic] = cId.cellU(); - triggerCellCell_cellV_ .get()[ic] = cId.cellV(); - triggerCellCell_ieta_ .get()[ic] = 0; - triggerCellCell_iphi_ .get()[ic] = 0; - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - ic++; - } - // Get neighbors - if(!no_neighbors_) - { - const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(id.rawId()); - triggerCellNeighbor_N_ = neighbors.size(); - setTreeTriggerCellNeighborSize(triggerCellNeighbor_N_); - size_t in = 0; - for(const auto neighbor : neighbors) - { - HGCalDetId nId(neighbor); - // std::cout<<"Neighbor ID "<getTriggerCellPosition(neighbor); - triggerCellNeighbor_id_.get()[in] = neighbor; - triggerCellNeighbor_zside_ .get()[in] = nId.zside(); - triggerCellNeighbor_subdet_.get()[in] = nId.subdetId(); - triggerCellNeighbor_layer_ .get()[in] = nId.layer(); - triggerCellNeighbor_wafer_ .get()[in] = nId.wafer(); - triggerCellNeighbor_cell_ .get()[in] = nId.cell(); - triggerCellNeighbor_distance_.get()[in] = (neighbor_position - position).mag(); - in++; - } - } - - treeTriggerCells_->Fill(); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - auto itr_insert = modules.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); + } + std::cout << "Filling HSi geometry\n"; + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + cellId_ = detid.rawId(); + cellSide_ = detid.zside(); + cellSubdet_ = detid.subdet(); + cellLayer_ = detid.layer(); + cellWaferU_ = detid.waferU(); + cellWaferV_ = detid.waferV(); + cellU_ = detid.cellU(); + cellV_ = detid.cellV(); + int type1 = detid.type(); + int type2 = triggerGeometry_->hsiTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); + if (type1 != type2) { + std::cout << "Found incompatible wafer types:\n " << detid << "\n"; } - // Loop over modules - edm::LogPrint("TreeFilling")<<"Filling modules tree"; - for( const auto& module_triggercells : modules ) - { - HGCalDetId id(module_triggercells.first); - GlobalPoint position = triggerGeometry_->getModulePosition(id); - moduleId_ = id.rawId(); - moduleSide_ = id.zside(); - moduleSubdet_ = id.subdetId(); - moduleLayer_ = id.layer(); - module_ = id.wafer(); - moduleX_ = position.x(); - moduleY_ = position.y(); - moduleZ_ = position.z(); - moduleTC_N_ = module_triggercells.second.size(); - // - setTreeModuleSize(moduleTC_N_); - size_t itc = 0; - for(const auto& tc : module_triggercells.second) - { - HGCalDetId tcId(tc); - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tcId); - moduleTC_id_ .get()[itc] = tc; - moduleTC_zside_ .get()[itc] = tcId.zside(); - moduleTC_subdet_.get()[itc] = tcId.subdetId(); - moduleTC_layer_ .get()[itc] = tcId.layer(); - moduleTC_wafer_ .get()[itc] = tcId.wafer(); - moduleTC_cell_ .get()[itc] = tcId.cell(); - moduleTC_x_ .get()[itc] = position.x(); - moduleTC_y_ .get()[itc] = position.y(); - moduleTC_z_ .get()[itc] = position.z(); - itc++; - } - auto cells_in_module = triggerGeometry_->getCellsFromModule(id); - moduleCell_N_ = cells_in_module.size(); - // - setTreeModuleCellSize(moduleCell_N_); - size_t ic = 0; - for(const auto& c : cells_in_module) - { - if(id.subdetId()==ForwardSubdetector::HGCHEB) - { - HGCScintillatorDetId cId(c); - GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = 0; - triggerCellCell_waferV_ .get()[ic] = 0; - triggerCellCell_cellU_ .get()[ic] = 0; - triggerCellCell_cellV_ .get()[ic] = 0; - triggerCellCell_ieta_ .get()[ic] = cId.ietaAbs(); - triggerCellCell_iphi_ .get()[ic] = cId.iphi(); - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - else - { - HGCSiliconDetId cId(c); - const GlobalPoint position = (cId.det()==DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->hsiGeometry()->getPosition(cId)); - moduleCell_id_ .get()[ic] = c; - moduleCell_zside_ .get()[ic] = cId.zside(); - moduleCell_subdet_.get()[ic] = cId.subdetId(); - moduleCell_layer_ .get()[ic] = cId.layer(); - moduleCell_waferU_ .get()[ic] = cId.waferU(); - moduleCell_waferV_ .get()[ic] = cId.waferV(); - moduleCell_cellU_ .get()[ic] = cId.cellU(); - moduleCell_cellV_ .get()[ic] = cId.cellV(); - moduleCell_x_ .get()[ic] = position.x(); - moduleCell_y_ .get()[ic] = position.y(); - moduleCell_z_ .get()[ic] = position.z(); - ic++; - } - } - // - treeModules_->Fill(); + // + GlobalPoint center = triggerGeometry_->hsiGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->hsiGeometry()->getCorners(id); + cellCornersN_ = corners.size(); + setTreeCellCornerSize(cellCornersN_); + for (unsigned i = 0; i < corners.size(); i++) { + cellCornersX_.get()[i] = corners[i].x(); + cellCornersY_.get()[i] = corners[i].y(); + cellCornersZ_.get()[i] = corners[i].z(); + } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + std::cout << "Filling HSc geometry\n"; + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + HGCScintillatorDetId cellid(id); + cellBHId_ = cellid.rawId(); + cellBHType_ = cellid.type(); + cellBHSide_ = cellid.zside(); + cellBHSubdet_ = cellid.subdetId(); + cellBHLayer_ = cellid.layer(); + cellBHIEta_ = cellid.ieta(); + cellBHIPhi_ = cellid.iphi(); + // + GlobalPoint center = triggerGeometry_->hscGeometry()->getPosition(id); + cellBHEta_ = center.eta(); + cellBHPhi_ = center.phi(); + cellBHX_ = center.x(); + cellBHY_ = center.y(); + cellBHZ_ = center.z(); + auto corners = triggerGeometry_->hscGeometry()->getCorners(id); + if (corners.size() >= 4) { + cellBHX1_ = corners[0].x(); + cellBHY1_ = corners[0].y(); + cellBHX2_ = corners[1].x(); + cellBHY2_ = corners[1].y(); + cellBHX3_ = corners[2].x(); + cellBHY3_ = corners[2].y(); + cellBHX4_ = corners[3].x(); + cellBHY4_ = corners[3].y(); + } + treeCellsBH_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + + // if problem detected in the trigger geometry, don't produce trigger trees + if (no_trigger_) + return; + + // Loop over trigger cells + edm::LogPrint("TreeFilling") << "Filling trigger cells tree"; + for (const auto& triggercell_cells : trigger_cells) { + HGCalDetId id(triggercell_cells.first); + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); + triggerCellId_ = id.rawId(); + triggerCellSide_ = id.zside(); + triggerCellSubdet_ = id.subdetId(); + triggerCellLayer_ = id.layer(); + triggerCellWafer_ = id.wafer(); + triggerCell_ = id.cell(); + triggerCellX_ = position.x(); + triggerCellY_ = position.y(); + triggerCellZ_ = position.z(); + triggerCellCell_N_ = triggercell_cells.second.size(); + // + setTreeTriggerCellSize(triggerCellCell_N_); + size_t ic = 0; + for (const auto& c : triggercell_cells.second) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + HGCScintillatorDetId cId(c); + GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = 0; + triggerCellCell_waferV_.get()[ic] = 0; + triggerCellCell_cellU_.get()[ic] = 0; + triggerCellCell_cellV_.get()[ic] = 0; + triggerCellCell_ieta_.get()[ic] = cId.ietaAbs(); + triggerCellCell_iphi_.get()[ic] = cId.iphi(); + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } else { + HGCSiliconDetId cId(c); + GlobalPoint cell_position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->hsiGeometry()->getPosition(cId)); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = cId.waferU(); + triggerCellCell_waferV_.get()[ic] = cId.waferV(); + triggerCellCell_cellU_.get()[ic] = cId.cellU(); + triggerCellCell_cellV_.get()[ic] = cId.cellV(); + triggerCellCell_ieta_.get()[ic] = 0; + triggerCellCell_iphi_.get()[ic] = 0; + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } + ic++; + } + // Get neighbors + if (!no_neighbors_) { + const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(id.rawId()); + triggerCellNeighbor_N_ = neighbors.size(); + setTreeTriggerCellNeighborSize(triggerCellNeighbor_N_); + size_t in = 0; + for (const auto neighbor : neighbors) { + HGCalDetId nId(neighbor); + // std::cout<<"Neighbor ID "<getTriggerCellPosition(neighbor); + triggerCellNeighbor_id_.get()[in] = neighbor; + triggerCellNeighbor_zside_.get()[in] = nId.zside(); + triggerCellNeighbor_subdet_.get()[in] = nId.subdetId(); + triggerCellNeighbor_layer_.get()[in] = nId.layer(); + triggerCellNeighbor_wafer_.get()[in] = nId.wafer(); + triggerCellNeighbor_cell_.get()[in] = nId.cell(); + triggerCellNeighbor_distance_.get()[in] = (neighbor_position - position).mag(); + in++; + } } + treeTriggerCells_->Fill(); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + auto itr_insert = modules.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // Loop over modules + edm::LogPrint("TreeFilling") << "Filling modules tree"; + for (const auto& module_triggercells : modules) { + HGCalDetId id(module_triggercells.first); + GlobalPoint position = triggerGeometry_->getModulePosition(id); + moduleId_ = id.rawId(); + moduleSide_ = id.zside(); + moduleSubdet_ = id.subdetId(); + moduleLayer_ = id.layer(); + module_ = id.wafer(); + moduleX_ = position.x(); + moduleY_ = position.y(); + moduleZ_ = position.z(); + moduleTC_N_ = module_triggercells.second.size(); + // + setTreeModuleSize(moduleTC_N_); + size_t itc = 0; + for (const auto& tc : module_triggercells.second) { + HGCalDetId tcId(tc); + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tcId); + moduleTC_id_.get()[itc] = tc; + moduleTC_zside_.get()[itc] = tcId.zside(); + moduleTC_subdet_.get()[itc] = tcId.subdetId(); + moduleTC_layer_.get()[itc] = tcId.layer(); + moduleTC_wafer_.get()[itc] = tcId.wafer(); + moduleTC_cell_.get()[itc] = tcId.cell(); + moduleTC_x_.get()[itc] = position.x(); + moduleTC_y_.get()[itc] = position.y(); + moduleTC_z_.get()[itc] = position.z(); + itc++; + } + auto cells_in_module = triggerGeometry_->getCellsFromModule(id); + moduleCell_N_ = cells_in_module.size(); + // + setTreeModuleCellSize(moduleCell_N_); + size_t ic = 0; + for (const auto& c : cells_in_module) { + if (id.subdetId() == ForwardSubdetector::HGCHEB) { + HGCScintillatorDetId cId(c); + GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = 0; + triggerCellCell_waferV_.get()[ic] = 0; + triggerCellCell_cellU_.get()[ic] = 0; + triggerCellCell_cellV_.get()[ic] = 0; + triggerCellCell_ieta_.get()[ic] = cId.ietaAbs(); + triggerCellCell_iphi_.get()[ic] = cId.iphi(); + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } else { + HGCSiliconDetId cId(c); + const GlobalPoint position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->hsiGeometry()->getPosition(cId)); + moduleCell_id_.get()[ic] = c; + moduleCell_zside_.get()[ic] = cId.zside(); + moduleCell_subdet_.get()[ic] = cId.subdetId(); + moduleCell_layer_.get()[ic] = cId.layer(); + moduleCell_waferU_.get()[ic] = cId.waferU(); + moduleCell_waferV_.get()[ic] = cId.waferV(); + moduleCell_cellU_.get()[ic] = cId.cellU(); + moduleCell_cellV_.get()[ic] = cId.cellV(); + moduleCell_x_.get()[ic] = position.x(); + moduleCell_y_.get()[ic] = position.y(); + moduleCell_z_.get()[ic] = position.z(); + ic++; + } + } + // + treeModules_->Fill(); + } } - /*****************************************************************/ -void HGCalTriggerGeomTesterV9::analyze(const edm::Event& e, - const edm::EventSetup& es) +void HGCalTriggerGeomTesterV9::analyze(const edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ -{ - -} - +{} /*****************************************************************/ -void HGCalTriggerGeomTesterV9::setTreeModuleSize(const size_t n) +void HGCalTriggerGeomTesterV9::setTreeModuleSize(const size_t n) /*****************************************************************/ { - moduleTC_id_ .reset(new int[n], array_deleter()); - moduleTC_zside_ .reset(new int[n], array_deleter()); - moduleTC_subdet_.reset(new int[n], array_deleter()); - moduleTC_layer_ .reset(new int[n], array_deleter()); - moduleTC_wafer_ .reset(new int[n], array_deleter()); - moduleTC_cell_ .reset(new int[n], array_deleter()); - moduleTC_x_ .reset(new float[n], array_deleter()); - moduleTC_y_ .reset(new float[n], array_deleter()); - moduleTC_z_ .reset(new float[n], array_deleter()); - - treeModules_->GetBranch("tc_id") ->SetAddress(moduleTC_id_ .get()); - treeModules_->GetBranch("tc_zside") ->SetAddress(moduleTC_zside_ .get()); - treeModules_->GetBranch("tc_subdet") ->SetAddress(moduleTC_subdet_.get()); - treeModules_->GetBranch("tc_layer") ->SetAddress(moduleTC_layer_ .get()); - treeModules_->GetBranch("tc_wafer") ->SetAddress(moduleTC_wafer_ .get()); - treeModules_->GetBranch("tc_cell") ->SetAddress(moduleTC_cell_ .get()); - treeModules_->GetBranch("tc_x") ->SetAddress(moduleTC_x_ .get()); - treeModules_->GetBranch("tc_y") ->SetAddress(moduleTC_y_ .get()); - treeModules_->GetBranch("tc_z") ->SetAddress(moduleTC_z_ .get()); + moduleTC_id_.reset(new int[n], array_deleter()); + moduleTC_zside_.reset(new int[n], array_deleter()); + moduleTC_subdet_.reset(new int[n], array_deleter()); + moduleTC_layer_.reset(new int[n], array_deleter()); + moduleTC_wafer_.reset(new int[n], array_deleter()); + moduleTC_cell_.reset(new int[n], array_deleter()); + moduleTC_x_.reset(new float[n], array_deleter()); + moduleTC_y_.reset(new float[n], array_deleter()); + moduleTC_z_.reset(new float[n], array_deleter()); + + treeModules_->GetBranch("tc_id")->SetAddress(moduleTC_id_.get()); + treeModules_->GetBranch("tc_zside")->SetAddress(moduleTC_zside_.get()); + treeModules_->GetBranch("tc_subdet")->SetAddress(moduleTC_subdet_.get()); + treeModules_->GetBranch("tc_layer")->SetAddress(moduleTC_layer_.get()); + treeModules_->GetBranch("tc_wafer")->SetAddress(moduleTC_wafer_.get()); + treeModules_->GetBranch("tc_cell")->SetAddress(moduleTC_cell_.get()); + treeModules_->GetBranch("tc_x")->SetAddress(moduleTC_x_.get()); + treeModules_->GetBranch("tc_y")->SetAddress(moduleTC_y_.get()); + treeModules_->GetBranch("tc_z")->SetAddress(moduleTC_z_.get()); } /*****************************************************************/ -void HGCalTriggerGeomTesterV9::setTreeModuleCellSize(const size_t n) +void HGCalTriggerGeomTesterV9::setTreeModuleCellSize(const size_t n) /*****************************************************************/ { - moduleCell_id_ .reset(new int[n], array_deleter()); - moduleCell_zside_ .reset(new int[n], array_deleter()); - moduleCell_subdet_.reset(new int[n], array_deleter()); - moduleCell_layer_ .reset(new int[n], array_deleter()); - moduleCell_waferU_ .reset(new int[n], array_deleter()); - moduleCell_waferV_ .reset(new int[n], array_deleter()); - moduleCell_cellU_ .reset(new int[n], array_deleter()); - moduleCell_cellV_ .reset(new int[n], array_deleter()); - moduleCell_x_ .reset(new float[n], array_deleter()); - moduleCell_y_ .reset(new float[n], array_deleter()); - moduleCell_z_ .reset(new float[n], array_deleter()); - - treeModules_->GetBranch("c_id") ->SetAddress(moduleCell_id_ .get()); - treeModules_->GetBranch("c_zside") ->SetAddress(moduleCell_zside_ .get()); - treeModules_->GetBranch("c_subdet") ->SetAddress(moduleCell_subdet_.get()); - treeModules_->GetBranch("c_layer") ->SetAddress(moduleCell_layer_ .get()); - treeModules_->GetBranch("c_waferu") ->SetAddress(moduleCell_waferU_ .get()); - treeModules_->GetBranch("c_waferv") ->SetAddress(moduleCell_waferV_ .get()); - treeModules_->GetBranch("c_cellu") ->SetAddress(moduleCell_cellU_ .get()); - treeModules_->GetBranch("c_cellv") ->SetAddress(moduleCell_cellV_ .get()); - treeModules_->GetBranch("c_x") ->SetAddress(moduleCell_x_ .get()); - treeModules_->GetBranch("c_y") ->SetAddress(moduleCell_y_ .get()); - treeModules_->GetBranch("c_z") ->SetAddress(moduleCell_z_ .get()); + moduleCell_id_.reset(new int[n], array_deleter()); + moduleCell_zside_.reset(new int[n], array_deleter()); + moduleCell_subdet_.reset(new int[n], array_deleter()); + moduleCell_layer_.reset(new int[n], array_deleter()); + moduleCell_waferU_.reset(new int[n], array_deleter()); + moduleCell_waferV_.reset(new int[n], array_deleter()); + moduleCell_cellU_.reset(new int[n], array_deleter()); + moduleCell_cellV_.reset(new int[n], array_deleter()); + moduleCell_x_.reset(new float[n], array_deleter()); + moduleCell_y_.reset(new float[n], array_deleter()); + moduleCell_z_.reset(new float[n], array_deleter()); + + treeModules_->GetBranch("c_id")->SetAddress(moduleCell_id_.get()); + treeModules_->GetBranch("c_zside")->SetAddress(moduleCell_zside_.get()); + treeModules_->GetBranch("c_subdet")->SetAddress(moduleCell_subdet_.get()); + treeModules_->GetBranch("c_layer")->SetAddress(moduleCell_layer_.get()); + treeModules_->GetBranch("c_waferu")->SetAddress(moduleCell_waferU_.get()); + treeModules_->GetBranch("c_waferv")->SetAddress(moduleCell_waferV_.get()); + treeModules_->GetBranch("c_cellu")->SetAddress(moduleCell_cellU_.get()); + treeModules_->GetBranch("c_cellv")->SetAddress(moduleCell_cellV_.get()); + treeModules_->GetBranch("c_x")->SetAddress(moduleCell_x_.get()); + treeModules_->GetBranch("c_y")->SetAddress(moduleCell_y_.get()); + treeModules_->GetBranch("c_z")->SetAddress(moduleCell_z_.get()); } /*****************************************************************/ -void HGCalTriggerGeomTesterV9::setTreeTriggerCellSize(const size_t n) +void HGCalTriggerGeomTesterV9::setTreeTriggerCellSize(const size_t n) /*****************************************************************/ { - triggerCellCell_id_ .reset(new int[n], array_deleter()); - triggerCellCell_zside_ .reset(new int[n], array_deleter()); - triggerCellCell_subdet_.reset(new int[n], array_deleter()); - triggerCellCell_layer_ .reset(new int[n], array_deleter()); - triggerCellCell_waferU_ .reset(new int[n], array_deleter()); - triggerCellCell_waferV_ .reset(new int[n], array_deleter()); - triggerCellCell_cellU_ .reset(new int[n], array_deleter()); - triggerCellCell_cellV_ .reset(new int[n], array_deleter()); - triggerCellCell_ieta_ .reset(new int[n], array_deleter()); - triggerCellCell_iphi_ .reset(new int[n], array_deleter()); - triggerCellCell_x_ .reset(new float[n], array_deleter()); - triggerCellCell_y_ .reset(new float[n], array_deleter()); - triggerCellCell_z_ .reset(new float[n], array_deleter()); - - treeTriggerCells_->GetBranch("c_id") ->SetAddress(triggerCellCell_id_ .get()); - treeTriggerCells_->GetBranch("c_zside") ->SetAddress(triggerCellCell_zside_ .get()); - treeTriggerCells_->GetBranch("c_subdet") ->SetAddress(triggerCellCell_subdet_.get()); - treeTriggerCells_->GetBranch("c_layer") ->SetAddress(triggerCellCell_layer_ .get()); - treeTriggerCells_->GetBranch("c_waferu") ->SetAddress(triggerCellCell_waferU_ .get()); - treeTriggerCells_->GetBranch("c_waferv") ->SetAddress(triggerCellCell_waferV_ .get()); - treeTriggerCells_->GetBranch("c_cellu") ->SetAddress(triggerCellCell_cellU_ .get()); - treeTriggerCells_->GetBranch("c_cellv") ->SetAddress(triggerCellCell_cellV_ .get()); - treeTriggerCells_->GetBranch("c_ieta") ->SetAddress(triggerCellCell_ieta_ .get()); - treeTriggerCells_->GetBranch("c_iphi") ->SetAddress(triggerCellCell_iphi_ .get()); - treeTriggerCells_->GetBranch("c_x") ->SetAddress(triggerCellCell_x_ .get()); - treeTriggerCells_->GetBranch("c_y") ->SetAddress(triggerCellCell_y_ .get()); - treeTriggerCells_->GetBranch("c_z") ->SetAddress(triggerCellCell_z_ .get()); + triggerCellCell_id_.reset(new int[n], array_deleter()); + triggerCellCell_zside_.reset(new int[n], array_deleter()); + triggerCellCell_subdet_.reset(new int[n], array_deleter()); + triggerCellCell_layer_.reset(new int[n], array_deleter()); + triggerCellCell_waferU_.reset(new int[n], array_deleter()); + triggerCellCell_waferV_.reset(new int[n], array_deleter()); + triggerCellCell_cellU_.reset(new int[n], array_deleter()); + triggerCellCell_cellV_.reset(new int[n], array_deleter()); + triggerCellCell_ieta_.reset(new int[n], array_deleter()); + triggerCellCell_iphi_.reset(new int[n], array_deleter()); + triggerCellCell_x_.reset(new float[n], array_deleter()); + triggerCellCell_y_.reset(new float[n], array_deleter()); + triggerCellCell_z_.reset(new float[n], array_deleter()); + + treeTriggerCells_->GetBranch("c_id")->SetAddress(triggerCellCell_id_.get()); + treeTriggerCells_->GetBranch("c_zside")->SetAddress(triggerCellCell_zside_.get()); + treeTriggerCells_->GetBranch("c_subdet")->SetAddress(triggerCellCell_subdet_.get()); + treeTriggerCells_->GetBranch("c_layer")->SetAddress(triggerCellCell_layer_.get()); + treeTriggerCells_->GetBranch("c_waferu")->SetAddress(triggerCellCell_waferU_.get()); + treeTriggerCells_->GetBranch("c_waferv")->SetAddress(triggerCellCell_waferV_.get()); + treeTriggerCells_->GetBranch("c_cellu")->SetAddress(triggerCellCell_cellU_.get()); + treeTriggerCells_->GetBranch("c_cellv")->SetAddress(triggerCellCell_cellV_.get()); + treeTriggerCells_->GetBranch("c_ieta")->SetAddress(triggerCellCell_ieta_.get()); + treeTriggerCells_->GetBranch("c_iphi")->SetAddress(triggerCellCell_iphi_.get()); + treeTriggerCells_->GetBranch("c_x")->SetAddress(triggerCellCell_x_.get()); + treeTriggerCells_->GetBranch("c_y")->SetAddress(triggerCellCell_y_.get()); + treeTriggerCells_->GetBranch("c_z")->SetAddress(triggerCellCell_z_.get()); } - /*****************************************************************/ -void HGCalTriggerGeomTesterV9::setTreeCellCornerSize(const size_t n) +void HGCalTriggerGeomTesterV9::setTreeCellCornerSize(const size_t n) /*****************************************************************/ { - cellCornersX_.reset(new float[n], array_deleter()); - cellCornersY_.reset(new float[n], array_deleter()); - cellCornersZ_.reset(new float[n], array_deleter()); + cellCornersX_.reset(new float[n], array_deleter()); + cellCornersY_.reset(new float[n], array_deleter()); + cellCornersZ_.reset(new float[n], array_deleter()); - treeCells_->GetBranch("corner_x")->SetAddress(cellCornersX_.get()); - treeCells_->GetBranch("corner_y")->SetAddress(cellCornersY_.get()); - treeCells_->GetBranch("corner_z")->SetAddress(cellCornersZ_.get()); + treeCells_->GetBranch("corner_x")->SetAddress(cellCornersX_.get()); + treeCells_->GetBranch("corner_y")->SetAddress(cellCornersY_.get()); + treeCells_->GetBranch("corner_z")->SetAddress(cellCornersZ_.get()); } - - /*****************************************************************/ -void HGCalTriggerGeomTesterV9::setTreeTriggerCellNeighborSize(const size_t n) +void HGCalTriggerGeomTesterV9::setTreeTriggerCellNeighborSize(const size_t n) /*****************************************************************/ { - triggerCellNeighbor_id_.reset(new int[n],array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_wafer_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_cell_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[n], array_deleter()); - treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); - treeTriggerCells_->GetBranch("neighbor_zside") ->SetAddress(triggerCellNeighbor_zside_ .get()); - treeTriggerCells_->GetBranch("neighbor_subdet") ->SetAddress(triggerCellNeighbor_subdet_.get()); - treeTriggerCells_->GetBranch("neighbor_layer") ->SetAddress(triggerCellNeighbor_layer_ .get()); - treeTriggerCells_->GetBranch("neighbor_wafer") ->SetAddress(triggerCellNeighbor_wafer_ .get()); - treeTriggerCells_->GetBranch("neighbor_cell") ->SetAddress(triggerCellNeighbor_cell_ .get()); - treeTriggerCells_->GetBranch("neighbor_distance") ->SetAddress(triggerCellNeighbor_distance_ .get()); + triggerCellNeighbor_id_.reset(new int[n], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[n], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[n], array_deleter()); + triggerCellNeighbor_wafer_.reset(new int[n], array_deleter()); + triggerCellNeighbor_cell_.reset(new int[n], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[n], array_deleter()); + treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); + treeTriggerCells_->GetBranch("neighbor_zside")->SetAddress(triggerCellNeighbor_zside_.get()); + treeTriggerCells_->GetBranch("neighbor_subdet")->SetAddress(triggerCellNeighbor_subdet_.get()); + treeTriggerCells_->GetBranch("neighbor_layer")->SetAddress(triggerCellNeighbor_layer_.get()); + treeTriggerCells_->GetBranch("neighbor_wafer")->SetAddress(triggerCellNeighbor_wafer_.get()); + treeTriggerCells_->GetBranch("neighbor_cell")->SetAddress(triggerCellNeighbor_cell_.get()); + treeTriggerCells_->GetBranch("neighbor_distance")->SetAddress(triggerCellNeighbor_distance_.get()); } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9Imp2.cc b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9Imp2.cc index da071c2baaffc..6d31ab6527dcb 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9Imp2.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerGeomTesterV9Imp2.cc @@ -4,7 +4,6 @@ #include "TTree.h" - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDAnalyzer.h" @@ -31,1124 +30,1052 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" -#include - -namespace -{ - template - struct array_deleter - { - void operator () (T* arr) { delete [] arr; } - }; -} +#include +namespace { + template + struct array_deleter { + void operator()(T* arr) { delete[] arr; } + }; +} // namespace -class HGCalTriggerGeomTesterV9Imp2 : public edm::stream::EDAnalyzer<> -{ - public: - explicit HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet& ); - ~HGCalTriggerGeomTesterV9Imp2(); +class HGCalTriggerGeomTesterV9Imp2 : public edm::stream::EDAnalyzer<> { +public: + explicit HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet&); + ~HGCalTriggerGeomTesterV9Imp2(); - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); +private: + void fillTriggerGeometry(); + bool checkMappingConsistency(); + bool checkNeighborConsistency(); + void setTreeModuleSize(const size_t n); + void setTreeModuleCellSize(const size_t n); + void setTreeTriggerCellSize(const size_t n); + void setTreeCellCornerSize(const size_t n); + void setTreeTriggerCellNeighborSize(const size_t n); - private: - void fillTriggerGeometry(); - bool checkMappingConsistency(); - bool checkNeighborConsistency(); - void setTreeModuleSize(const size_t n); - void setTreeModuleCellSize(const size_t n); - void setTreeTriggerCellSize(const size_t n); - void setTreeCellCornerSize(const size_t n); - void setTreeTriggerCellNeighborSize(const size_t n); + edm::ESHandle triggerGeometry_; + edm::ESHandle eeGeometry_; + edm::ESHandle hsiGeometry_; + edm::ESHandle hscGeometry_; + edm::Service fs_; + bool no_trigger_; + bool no_neighbors_; + TTree* treeModules_; + TTree* treeTriggerCells_; + TTree* treeCells_; + TTree* treeCellsBH_; + // tree variables + int moduleId_; + int moduleSide_; + int moduleSubdet_; + int moduleLayer_; + int moduleIEta_; + int moduleIPhi_; + int module_; + float moduleX_; + float moduleY_; + float moduleZ_; + int moduleTC_N_; + std::shared_ptr moduleTC_id_; + std::shared_ptr moduleTC_zside_; + std::shared_ptr moduleTC_subdet_; + std::shared_ptr moduleTC_layer_; + std::shared_ptr moduleTC_waferU_; + std::shared_ptr moduleTC_waferV_; + std::shared_ptr moduleTC_cellU_; + std::shared_ptr moduleTC_cellV_; + std::shared_ptr moduleTC_ieta_; + std::shared_ptr moduleTC_iphi_; + std::shared_ptr moduleTC_x_; + std::shared_ptr moduleTC_y_; + std::shared_ptr moduleTC_z_; + int moduleCell_N_; + std::shared_ptr moduleCell_id_; + std::shared_ptr moduleCell_zside_; + std::shared_ptr moduleCell_subdet_; + std::shared_ptr moduleCell_layer_; + std::shared_ptr moduleCell_waferU_; + std::shared_ptr moduleCell_waferV_; + std::shared_ptr moduleCell_cellU_; + std::shared_ptr moduleCell_cellV_; + std::shared_ptr moduleCell_x_; + std::shared_ptr moduleCell_y_; + std::shared_ptr moduleCell_z_; + int triggerCellId_; + int triggerCellSide_; + int triggerCellSubdet_; + int triggerCellLayer_; + int triggerCellWaferU_; + int triggerCellWaferV_; + int triggerCellU_; + int triggerCellV_; + int triggerCellIEta_; + int triggerCellIPhi_; + float triggerCellX_; + float triggerCellY_; + float triggerCellZ_; + int triggerCellNeighbor_N_; + std::shared_ptr triggerCellNeighbor_id_; + std::shared_ptr triggerCellNeighbor_zside_; + std::shared_ptr triggerCellNeighbor_subdet_; + std::shared_ptr triggerCellNeighbor_layer_; + std::shared_ptr triggerCellNeighbor_waferU_; + std::shared_ptr triggerCellNeighbor_waferV_; + std::shared_ptr triggerCellNeighbor_cellU_; + std::shared_ptr triggerCellNeighbor_cellV_; + std::shared_ptr triggerCellNeighbor_cellIEta_; + std::shared_ptr triggerCellNeighbor_cellIPhi_; + std::shared_ptr triggerCellNeighbor_distance_; + int triggerCellCell_N_; + std::shared_ptr triggerCellCell_id_; + std::shared_ptr triggerCellCell_zside_; + std::shared_ptr triggerCellCell_subdet_; + std::shared_ptr triggerCellCell_layer_; + std::shared_ptr triggerCellCell_waferU_; + std::shared_ptr triggerCellCell_waferV_; + std::shared_ptr triggerCellCell_cellU_; + std::shared_ptr triggerCellCell_cellV_; + std::shared_ptr triggerCellCell_ieta_; + std::shared_ptr triggerCellCell_iphi_; + std::shared_ptr triggerCellCell_x_; + std::shared_ptr triggerCellCell_y_; + std::shared_ptr triggerCellCell_z_; + int cellId_; + int cellSide_; + int cellSubdet_; + int cellLayer_; + int cellWaferU_; + int cellWaferV_; + int cellWaferType_; + int cellWaferRow_; + int cellWaferColumn_; + int cellU_; + int cellV_; + float cellX_; + float cellY_; + float cellZ_; + int cellCornersN_; + std::shared_ptr cellCornersX_; + std::shared_ptr cellCornersY_; + std::shared_ptr cellCornersZ_; + int cellBHId_; + int cellBHType_; + int cellBHSide_; + int cellBHSubdet_; + int cellBHLayer_; + int cellBHIEta_; + int cellBHIPhi_; + float cellBHEta_; + float cellBHPhi_; + float cellBHX_; + float cellBHY_; + float cellBHZ_; + float cellBHX1_; + float cellBHY1_; + float cellBHX2_; + float cellBHY2_; + float cellBHX3_; + float cellBHY3_; + float cellBHX4_; + float cellBHY4_; - edm::ESHandle triggerGeometry_; - edm::ESHandle eeGeometry_; - edm::ESHandle hsiGeometry_; - edm::ESHandle hscGeometry_; - edm::Service fs_; - bool no_trigger_; - bool no_neighbors_; - TTree* treeModules_; - TTree* treeTriggerCells_; - TTree* treeCells_; - TTree* treeCellsBH_; - // tree variables - int moduleId_ ; - int moduleSide_ ; - int moduleSubdet_ ; - int moduleLayer_ ; - int moduleIEta_ ; - int moduleIPhi_ ; - int module_ ; - float moduleX_ ; - float moduleY_ ; - float moduleZ_ ; - int moduleTC_N_ ; - std::shared_ptr moduleTC_id_ ; - std::shared_ptr moduleTC_zside_ ; - std::shared_ptr moduleTC_subdet_; - std::shared_ptr moduleTC_layer_ ; - std::shared_ptr moduleTC_waferU_; - std::shared_ptr moduleTC_waferV_; - std::shared_ptr moduleTC_cellU_ ; - std::shared_ptr moduleTC_cellV_ ; - std::shared_ptr moduleTC_ieta_ ; - std::shared_ptr moduleTC_iphi_ ; - std::shared_ptr moduleTC_x_ ; - std::shared_ptr moduleTC_y_ ; - std::shared_ptr moduleTC_z_ ; - int moduleCell_N_ ; - std::shared_ptr moduleCell_id_ ; - std::shared_ptr moduleCell_zside_ ; - std::shared_ptr moduleCell_subdet_; - std::shared_ptr moduleCell_layer_ ; - std::shared_ptr moduleCell_waferU_; - std::shared_ptr moduleCell_waferV_; - std::shared_ptr moduleCell_cellU_ ; - std::shared_ptr moduleCell_cellV_ ; - std::shared_ptr moduleCell_x_ ; - std::shared_ptr moduleCell_y_ ; - std::shared_ptr moduleCell_z_ ; - int triggerCellId_ ; - int triggerCellSide_ ; - int triggerCellSubdet_ ; - int triggerCellLayer_ ; - int triggerCellWaferU_ ; - int triggerCellWaferV_ ; - int triggerCellU_ ; - int triggerCellV_ ; - int triggerCellIEta_ ; - int triggerCellIPhi_ ; - float triggerCellX_ ; - float triggerCellY_ ; - float triggerCellZ_ ; - int triggerCellNeighbor_N_; - std::shared_ptr triggerCellNeighbor_id_ ; - std::shared_ptr triggerCellNeighbor_zside_ ; - std::shared_ptr triggerCellNeighbor_subdet_; - std::shared_ptr triggerCellNeighbor_layer_ ; - std::shared_ptr triggerCellNeighbor_waferU_; - std::shared_ptr triggerCellNeighbor_waferV_; - std::shared_ptr triggerCellNeighbor_cellU_ ; - std::shared_ptr triggerCellNeighbor_cellV_ ; - std::shared_ptr triggerCellNeighbor_cellIEta_ ; - std::shared_ptr triggerCellNeighbor_cellIPhi_ ; - std::shared_ptr triggerCellNeighbor_distance_ ; - int triggerCellCell_N_ ; - std::shared_ptr triggerCellCell_id_ ; - std::shared_ptr triggerCellCell_zside_ ; - std::shared_ptr triggerCellCell_subdet_; - std::shared_ptr triggerCellCell_layer_ ; - std::shared_ptr triggerCellCell_waferU_; - std::shared_ptr triggerCellCell_waferV_; - std::shared_ptr triggerCellCell_cellU_ ; - std::shared_ptr triggerCellCell_cellV_ ; - std::shared_ptr triggerCellCell_ieta_ ; - std::shared_ptr triggerCellCell_iphi_ ; - std::shared_ptr triggerCellCell_x_ ; - std::shared_ptr triggerCellCell_y_ ; - std::shared_ptr triggerCellCell_z_ ; - int cellId_ ; - int cellSide_ ; - int cellSubdet_ ; - int cellLayer_ ; - int cellWaferU_ ; - int cellWaferV_ ; - int cellWaferType_ ; - int cellWaferRow_; - int cellWaferColumn_; - int cellU_ ; - int cellV_ ; - float cellX_ ; - float cellY_ ; - float cellZ_ ; - int cellCornersN_; - std::shared_ptr cellCornersX_ ; - std::shared_ptr cellCornersY_ ; - std::shared_ptr cellCornersZ_ ; - int cellBHId_ ; - int cellBHType_ ; - int cellBHSide_ ; - int cellBHSubdet_ ; - int cellBHLayer_ ; - int cellBHIEta_ ; - int cellBHIPhi_ ; - float cellBHEta_ ; - float cellBHPhi_ ; - float cellBHX_ ; - float cellBHY_ ; - float cellBHZ_ ; - float cellBHX1_ ; - float cellBHY1_ ; - float cellBHX2_ ; - float cellBHY2_ ; - float cellBHX3_ ; - float cellBHY3_ ; - float cellBHX4_ ; - float cellBHY4_ ; - - private: - typedef std::unordered_map> trigger_map_set; - +private: + typedef std::unordered_map> trigger_map_set; }; - /*****************************************************************/ -HGCalTriggerGeomTesterV9Imp2::HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet& conf): - no_trigger_(false), - no_neighbors_(false) +HGCalTriggerGeomTesterV9Imp2::HGCalTriggerGeomTesterV9Imp2(const edm::ParameterSet& conf) + : no_trigger_(false), + no_neighbors_(false) /*****************************************************************/ { - - // initialize output trees - treeModules_ = fs_->make("TreeModules","Tree of all HGC modules"); - treeModules_->Branch("id" , &moduleId_ , "id/I"); - treeModules_->Branch("zside" , &moduleSide_ , "zside/I"); - treeModules_->Branch("subdet" , &moduleSubdet_ , "subdet/I"); - treeModules_->Branch("layer" , &moduleLayer_ , "layer/I"); - treeModules_->Branch("ieta" , &moduleIEta_ , "ieta/I"); - treeModules_->Branch("iphi" , &moduleIPhi_ , "iphi/I"); - treeModules_->Branch("module" , &module_ , "module/I"); - treeModules_->Branch("x" , &moduleX_ , "x/F"); - treeModules_->Branch("y" , &moduleY_ , "y/F"); - treeModules_->Branch("z" , &moduleZ_ , "z/F"); - treeModules_->Branch("tc_n" , &moduleTC_N_ , "tc_n/I"); - moduleTC_id_ .reset(new int[1], array_deleter()); - moduleTC_zside_ .reset(new int[1], array_deleter()); - moduleTC_subdet_.reset(new int[1], array_deleter()); - moduleTC_layer_ .reset(new int[1], array_deleter()); - moduleTC_waferU_ .reset(new int[1], array_deleter()); - moduleTC_waferV_ .reset(new int[1], array_deleter()); - moduleTC_cellU_ .reset(new int[1], array_deleter()); - moduleTC_cellV_ .reset(new int[1], array_deleter()); - moduleTC_x_ .reset(new float[1], array_deleter()); - moduleTC_y_ .reset(new float[1], array_deleter()); - moduleTC_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("tc_id" , moduleTC_id_.get() , "tc_id[tc_n]/I"); - treeModules_->Branch("tc_zside" , moduleTC_zside_.get() , "tc_zside[tc_n]/I"); - treeModules_->Branch("tc_subdet" , moduleTC_subdet_.get() , "tc_subdet[tc_n]/I"); - treeModules_->Branch("tc_layer" , moduleTC_layer_.get() , "tc_layer[tc_n]/I"); - treeModules_->Branch("tc_waferu" , moduleTC_waferU_.get() , "tc_waferu[tc_n]/I"); - treeModules_->Branch("tc_waferv" , moduleTC_waferV_.get() , "tc_waferv[tc_n]/I"); - treeModules_->Branch("tc_cellu" , moduleTC_cellU_.get() , "tc_cellu[tc_n]/I"); - treeModules_->Branch("tc_cellv" , moduleTC_cellV_.get() , "tc_cellv[tc_n]/I"); - treeModules_->Branch("tc_ieta" , moduleTC_ieta_.get() , "tc_ieta[tc_n]/I"); - treeModules_->Branch("tc_iphi" , moduleTC_iphi_.get() , "tc_iphi[tc_n]/I"); - treeModules_->Branch("tc_x" , moduleTC_x_.get() , "tc_x[tc_n]/F"); - treeModules_->Branch("tc_y" , moduleTC_y_.get() , "tc_y[tc_n]/F"); - treeModules_->Branch("tc_z" , moduleTC_z_.get() , "tc_z[tc_n]/F"); - treeModules_->Branch("c_n" , &moduleCell_N_ , "c_n/I"); - moduleCell_id_ .reset(new int[1], array_deleter()); - moduleCell_zside_ .reset(new int[1], array_deleter()); - moduleCell_subdet_.reset(new int[1], array_deleter()); - moduleCell_layer_ .reset(new int[1], array_deleter()); - moduleCell_waferU_ .reset(new int[1], array_deleter()); - moduleCell_waferV_ .reset(new int[1], array_deleter()); - moduleCell_cellU_ .reset(new int[1], array_deleter()); - moduleCell_cellV_ .reset(new int[1], array_deleter()); - moduleCell_x_ .reset(new float[1], array_deleter()); - moduleCell_y_ .reset(new float[1], array_deleter()); - moduleCell_z_ .reset(new float[1], array_deleter()); - treeModules_->Branch("c_id" , moduleCell_id_.get() , "c_id[c_n]/I"); - treeModules_->Branch("c_zside" , moduleCell_zside_.get() , "c_zside[c_n]/I"); - treeModules_->Branch("c_subdet" , moduleCell_subdet_.get() , "c_subdet[c_n]/I"); - treeModules_->Branch("c_layer" , moduleCell_layer_.get() , "c_layer[c_n]/I"); - treeModules_->Branch("c_waferu" , moduleCell_waferU_.get() , "c_waferu[c_n]/I"); - treeModules_->Branch("c_waferv" , moduleCell_waferV_.get() , "c_waferv[c_n]/I"); - treeModules_->Branch("c_cellu" , moduleCell_cellU_.get() , "c_cellu[c_n]/I"); - treeModules_->Branch("c_cellv" , moduleCell_cellV_.get() , "c_cellv[c_n]/I"); - treeModules_->Branch("c_x" , moduleCell_x_.get() , "c_x[c_n]/F"); - treeModules_->Branch("c_y" , moduleCell_y_.get() , "c_y[c_n]/F"); - treeModules_->Branch("c_z" , moduleCell_z_.get() , "c_z[c_n]/F"); - // - treeTriggerCells_ = fs_->make("TreeTriggerCells","Tree of all HGC trigger cells"); - treeTriggerCells_->Branch("id" , &triggerCellId_ , "id/I"); - treeTriggerCells_->Branch("zside" , &triggerCellSide_ , "zside/I"); - treeTriggerCells_->Branch("subdet" , &triggerCellSubdet_ , "subdet/I"); - treeTriggerCells_->Branch("layer" , &triggerCellLayer_ , "layer/I"); - treeTriggerCells_->Branch("waferu" , &triggerCellWaferU_ , "waferu/I"); - treeTriggerCells_->Branch("waferv" , &triggerCellWaferV_ , "waferv/I"); - treeTriggerCells_->Branch("triggercellu" , &triggerCellU_ , "triggercellu/I"); - treeTriggerCells_->Branch("triggercellv" , &triggerCellV_ , "triggercellv/I"); - treeTriggerCells_->Branch("triggercellieta" , &triggerCellIEta_ , "triggercellieta/I"); - treeTriggerCells_->Branch("triggercelliphi" , &triggerCellIPhi_ , "triggercelliphi/I"); - treeTriggerCells_->Branch("x" , &triggerCellX_ , "x/F"); - treeTriggerCells_->Branch("y" , &triggerCellY_ , "y/F"); - treeTriggerCells_->Branch("z" , &triggerCellZ_ , "z/F"); - treeTriggerCells_->Branch("neighbor_n" , &triggerCellNeighbor_N_ , "neighbor_n/I"); - triggerCellNeighbor_id_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_subdet_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_waferU_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_waferV_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_cellU_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_cellV_ .reset(new int[1], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get() , "neighbor_zside[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get() , "neighbor_subdet[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get() , "neighbor_layer[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_waferu", triggerCellNeighbor_waferU_.get() , "neighbor_waferu[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_waferv", triggerCellNeighbor_waferV_.get() , "neighbor_waferv[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_cellu", triggerCellNeighbor_cellU_.get() , "neighbor_cellu[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_cellv", triggerCellNeighbor_cellV_.get() , "neighbor_cellv[neighbor_n]/I"); - treeTriggerCells_->Branch("neighbor_distance", triggerCellNeighbor_distance_.get() , "neighbor_distance[neighbor_n]/F"); - treeTriggerCells_->Branch("c_n" , &triggerCellCell_N_ , "c_n/I"); - triggerCellCell_id_ .reset(new int[1], array_deleter()); - triggerCellCell_zside_ .reset(new int[1], array_deleter()); - triggerCellCell_subdet_ .reset(new int[1], array_deleter()); - triggerCellCell_layer_ .reset(new int[1], array_deleter()); - triggerCellCell_waferU_ .reset(new int[1], array_deleter()); - triggerCellCell_waferV_ .reset(new int[1], array_deleter()); - triggerCellCell_cellU_ .reset(new int[1], array_deleter()); - triggerCellCell_cellV_ .reset(new int[1], array_deleter()); - triggerCellCell_ieta_ .reset(new int[1], array_deleter()); - triggerCellCell_iphi_ .reset(new int[1], array_deleter()); - triggerCellCell_x_ .reset(new float[1], array_deleter()); - triggerCellCell_y_ .reset(new float[1], array_deleter()); - triggerCellCell_z_ .reset(new float[1], array_deleter()); - treeTriggerCells_->Branch("c_id" , triggerCellCell_id_.get() , "c_id[c_n]/I"); - treeTriggerCells_->Branch("c_zside" , triggerCellCell_zside_.get() , "c_zside[c_n]/I"); - treeTriggerCells_->Branch("c_subdet" , triggerCellCell_subdet_.get() , "c_subdet[c_n]/I"); - treeTriggerCells_->Branch("c_layer" , triggerCellCell_layer_.get() , "c_layer[c_n]/I"); - treeTriggerCells_->Branch("c_waferu" , triggerCellCell_waferU_.get() , "c_waferu[c_n]/I"); - treeTriggerCells_->Branch("c_waferv" , triggerCellCell_waferV_.get() , "c_waferv[c_n]/I"); - treeTriggerCells_->Branch("c_cellu" , triggerCellCell_cellU_.get() , "c_cellu[c_n]/I"); - treeTriggerCells_->Branch("c_cellv" , triggerCellCell_cellV_.get() , "c_cellv[c_n]/I"); - treeTriggerCells_->Branch("c_ieta" , triggerCellCell_ieta_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_iphi" , triggerCellCell_iphi_.get() , "c_cell[c_n]/I"); - treeTriggerCells_->Branch("c_x" , triggerCellCell_x_.get() , "c_x[c_n]/F"); - treeTriggerCells_->Branch("c_y" , triggerCellCell_y_.get() , "c_y[c_n]/F"); - treeTriggerCells_->Branch("c_z" , triggerCellCell_z_.get() , "c_z[c_n]/F"); - // - treeCells_ = fs_->make("TreeCells","Tree of all HGC cells"); - treeCells_->Branch("id" , &cellId_ , "id/I"); - treeCells_->Branch("zside" , &cellSide_ , "zside/I"); - treeCells_->Branch("subdet" , &cellSubdet_ , "subdet/I"); - treeCells_->Branch("layer" , &cellLayer_ , "layer/I"); - treeCells_->Branch("waferu" , &cellWaferU_ , "waferu/I"); - treeCells_->Branch("waferv" , &cellWaferV_ , "waferv/I"); - treeCells_->Branch("wafertype" , &cellWaferType_ , "wafertype/I"); - treeCells_->Branch("waferrow" , &cellWaferRow_ , "waferrow/I"); - treeCells_->Branch("wafercolumn" , &cellWaferColumn_ , "wafercolumn/I"); - treeCells_->Branch("cellu" , &cellU_ , "cellu/I"); - treeCells_->Branch("cellv" , &cellV_ , "cellv/I"); - treeCells_->Branch("x" , &cellX_ , "x/F"); - treeCells_->Branch("y" , &cellY_ , "y/F"); - treeCells_->Branch("z" , &cellZ_ , "z/F"); - treeCells_->Branch("corner_n" , &cellCornersN_ , "corner_n/I"); - treeCells_->Branch("corner_x" , cellCornersX_.get() , "corner_x[corner_n]/F"); - treeCells_->Branch("corner_y" , cellCornersY_.get() , "corner_y[corner_n]/F"); - treeCells_->Branch("corner_z" , cellCornersZ_.get() , "corner_z[corner_n]/F"); - // - treeCellsBH_ = fs_->make("TreeCellsBH","Tree of all BH cells"); - treeCellsBH_->Branch("id", &cellBHId_, "id/I"); - treeCellsBH_->Branch("type", &cellBHType_, "type/I"); - treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); - treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); - treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); - treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); - treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); - treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); - treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); - treeCellsBH_->Branch("x", &cellBHX_, "x/F"); - treeCellsBH_->Branch("y", &cellBHY_, "y/F"); - treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); - treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); - treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); - treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); - treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); - treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); - treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); - treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); - treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); + // initialize output trees + treeModules_ = fs_->make("TreeModules", "Tree of all HGC modules"); + treeModules_->Branch("id", &moduleId_, "id/I"); + treeModules_->Branch("zside", &moduleSide_, "zside/I"); + treeModules_->Branch("subdet", &moduleSubdet_, "subdet/I"); + treeModules_->Branch("layer", &moduleLayer_, "layer/I"); + treeModules_->Branch("ieta", &moduleIEta_, "ieta/I"); + treeModules_->Branch("iphi", &moduleIPhi_, "iphi/I"); + treeModules_->Branch("module", &module_, "module/I"); + treeModules_->Branch("x", &moduleX_, "x/F"); + treeModules_->Branch("y", &moduleY_, "y/F"); + treeModules_->Branch("z", &moduleZ_, "z/F"); + treeModules_->Branch("tc_n", &moduleTC_N_, "tc_n/I"); + moduleTC_id_.reset(new int[1], array_deleter()); + moduleTC_zside_.reset(new int[1], array_deleter()); + moduleTC_subdet_.reset(new int[1], array_deleter()); + moduleTC_layer_.reset(new int[1], array_deleter()); + moduleTC_waferU_.reset(new int[1], array_deleter()); + moduleTC_waferV_.reset(new int[1], array_deleter()); + moduleTC_cellU_.reset(new int[1], array_deleter()); + moduleTC_cellV_.reset(new int[1], array_deleter()); + moduleTC_x_.reset(new float[1], array_deleter()); + moduleTC_y_.reset(new float[1], array_deleter()); + moduleTC_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("tc_id", moduleTC_id_.get(), "tc_id[tc_n]/I"); + treeModules_->Branch("tc_zside", moduleTC_zside_.get(), "tc_zside[tc_n]/I"); + treeModules_->Branch("tc_subdet", moduleTC_subdet_.get(), "tc_subdet[tc_n]/I"); + treeModules_->Branch("tc_layer", moduleTC_layer_.get(), "tc_layer[tc_n]/I"); + treeModules_->Branch("tc_waferu", moduleTC_waferU_.get(), "tc_waferu[tc_n]/I"); + treeModules_->Branch("tc_waferv", moduleTC_waferV_.get(), "tc_waferv[tc_n]/I"); + treeModules_->Branch("tc_cellu", moduleTC_cellU_.get(), "tc_cellu[tc_n]/I"); + treeModules_->Branch("tc_cellv", moduleTC_cellV_.get(), "tc_cellv[tc_n]/I"); + treeModules_->Branch("tc_ieta", moduleTC_ieta_.get(), "tc_ieta[tc_n]/I"); + treeModules_->Branch("tc_iphi", moduleTC_iphi_.get(), "tc_iphi[tc_n]/I"); + treeModules_->Branch("tc_x", moduleTC_x_.get(), "tc_x[tc_n]/F"); + treeModules_->Branch("tc_y", moduleTC_y_.get(), "tc_y[tc_n]/F"); + treeModules_->Branch("tc_z", moduleTC_z_.get(), "tc_z[tc_n]/F"); + treeModules_->Branch("c_n", &moduleCell_N_, "c_n/I"); + moduleCell_id_.reset(new int[1], array_deleter()); + moduleCell_zside_.reset(new int[1], array_deleter()); + moduleCell_subdet_.reset(new int[1], array_deleter()); + moduleCell_layer_.reset(new int[1], array_deleter()); + moduleCell_waferU_.reset(new int[1], array_deleter()); + moduleCell_waferV_.reset(new int[1], array_deleter()); + moduleCell_cellU_.reset(new int[1], array_deleter()); + moduleCell_cellV_.reset(new int[1], array_deleter()); + moduleCell_x_.reset(new float[1], array_deleter()); + moduleCell_y_.reset(new float[1], array_deleter()); + moduleCell_z_.reset(new float[1], array_deleter()); + treeModules_->Branch("c_id", moduleCell_id_.get(), "c_id[c_n]/I"); + treeModules_->Branch("c_zside", moduleCell_zside_.get(), "c_zside[c_n]/I"); + treeModules_->Branch("c_subdet", moduleCell_subdet_.get(), "c_subdet[c_n]/I"); + treeModules_->Branch("c_layer", moduleCell_layer_.get(), "c_layer[c_n]/I"); + treeModules_->Branch("c_waferu", moduleCell_waferU_.get(), "c_waferu[c_n]/I"); + treeModules_->Branch("c_waferv", moduleCell_waferV_.get(), "c_waferv[c_n]/I"); + treeModules_->Branch("c_cellu", moduleCell_cellU_.get(), "c_cellu[c_n]/I"); + treeModules_->Branch("c_cellv", moduleCell_cellV_.get(), "c_cellv[c_n]/I"); + treeModules_->Branch("c_x", moduleCell_x_.get(), "c_x[c_n]/F"); + treeModules_->Branch("c_y", moduleCell_y_.get(), "c_y[c_n]/F"); + treeModules_->Branch("c_z", moduleCell_z_.get(), "c_z[c_n]/F"); + // + treeTriggerCells_ = fs_->make("TreeTriggerCells", "Tree of all HGC trigger cells"); + treeTriggerCells_->Branch("id", &triggerCellId_, "id/I"); + treeTriggerCells_->Branch("zside", &triggerCellSide_, "zside/I"); + treeTriggerCells_->Branch("subdet", &triggerCellSubdet_, "subdet/I"); + treeTriggerCells_->Branch("layer", &triggerCellLayer_, "layer/I"); + treeTriggerCells_->Branch("waferu", &triggerCellWaferU_, "waferu/I"); + treeTriggerCells_->Branch("waferv", &triggerCellWaferV_, "waferv/I"); + treeTriggerCells_->Branch("triggercellu", &triggerCellU_, "triggercellu/I"); + treeTriggerCells_->Branch("triggercellv", &triggerCellV_, "triggercellv/I"); + treeTriggerCells_->Branch("triggercellieta", &triggerCellIEta_, "triggercellieta/I"); + treeTriggerCells_->Branch("triggercelliphi", &triggerCellIPhi_, "triggercelliphi/I"); + treeTriggerCells_->Branch("x", &triggerCellX_, "x/F"); + treeTriggerCells_->Branch("y", &triggerCellY_, "y/F"); + treeTriggerCells_->Branch("z", &triggerCellZ_, "z/F"); + treeTriggerCells_->Branch("neighbor_n", &triggerCellNeighbor_N_, "neighbor_n/I"); + triggerCellNeighbor_id_.reset(new int[1], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[1], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[1], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[1], array_deleter()); + triggerCellNeighbor_waferU_.reset(new int[1], array_deleter()); + triggerCellNeighbor_waferV_.reset(new int[1], array_deleter()); + triggerCellNeighbor_cellU_.reset(new int[1], array_deleter()); + triggerCellNeighbor_cellV_.reset(new int[1], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("neighbor_id", triggerCellNeighbor_id_.get(), "neighbor_id[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_zside", triggerCellNeighbor_zside_.get(), "neighbor_zside[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_subdet", triggerCellNeighbor_subdet_.get(), "neighbor_subdet[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_layer", triggerCellNeighbor_layer_.get(), "neighbor_layer[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_waferu", triggerCellNeighbor_waferU_.get(), "neighbor_waferu[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_waferv", triggerCellNeighbor_waferV_.get(), "neighbor_waferv[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_cellu", triggerCellNeighbor_cellU_.get(), "neighbor_cellu[neighbor_n]/I"); + treeTriggerCells_->Branch("neighbor_cellv", triggerCellNeighbor_cellV_.get(), "neighbor_cellv[neighbor_n]/I"); + treeTriggerCells_->Branch( + "neighbor_distance", triggerCellNeighbor_distance_.get(), "neighbor_distance[neighbor_n]/F"); + treeTriggerCells_->Branch("c_n", &triggerCellCell_N_, "c_n/I"); + triggerCellCell_id_.reset(new int[1], array_deleter()); + triggerCellCell_zside_.reset(new int[1], array_deleter()); + triggerCellCell_subdet_.reset(new int[1], array_deleter()); + triggerCellCell_layer_.reset(new int[1], array_deleter()); + triggerCellCell_waferU_.reset(new int[1], array_deleter()); + triggerCellCell_waferV_.reset(new int[1], array_deleter()); + triggerCellCell_cellU_.reset(new int[1], array_deleter()); + triggerCellCell_cellV_.reset(new int[1], array_deleter()); + triggerCellCell_ieta_.reset(new int[1], array_deleter()); + triggerCellCell_iphi_.reset(new int[1], array_deleter()); + triggerCellCell_x_.reset(new float[1], array_deleter()); + triggerCellCell_y_.reset(new float[1], array_deleter()); + triggerCellCell_z_.reset(new float[1], array_deleter()); + treeTriggerCells_->Branch("c_id", triggerCellCell_id_.get(), "c_id[c_n]/I"); + treeTriggerCells_->Branch("c_zside", triggerCellCell_zside_.get(), "c_zside[c_n]/I"); + treeTriggerCells_->Branch("c_subdet", triggerCellCell_subdet_.get(), "c_subdet[c_n]/I"); + treeTriggerCells_->Branch("c_layer", triggerCellCell_layer_.get(), "c_layer[c_n]/I"); + treeTriggerCells_->Branch("c_waferu", triggerCellCell_waferU_.get(), "c_waferu[c_n]/I"); + treeTriggerCells_->Branch("c_waferv", triggerCellCell_waferV_.get(), "c_waferv[c_n]/I"); + treeTriggerCells_->Branch("c_cellu", triggerCellCell_cellU_.get(), "c_cellu[c_n]/I"); + treeTriggerCells_->Branch("c_cellv", triggerCellCell_cellV_.get(), "c_cellv[c_n]/I"); + treeTriggerCells_->Branch("c_ieta", triggerCellCell_ieta_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_iphi", triggerCellCell_iphi_.get(), "c_cell[c_n]/I"); + treeTriggerCells_->Branch("c_x", triggerCellCell_x_.get(), "c_x[c_n]/F"); + treeTriggerCells_->Branch("c_y", triggerCellCell_y_.get(), "c_y[c_n]/F"); + treeTriggerCells_->Branch("c_z", triggerCellCell_z_.get(), "c_z[c_n]/F"); + // + treeCells_ = fs_->make("TreeCells", "Tree of all HGC cells"); + treeCells_->Branch("id", &cellId_, "id/I"); + treeCells_->Branch("zside", &cellSide_, "zside/I"); + treeCells_->Branch("subdet", &cellSubdet_, "subdet/I"); + treeCells_->Branch("layer", &cellLayer_, "layer/I"); + treeCells_->Branch("waferu", &cellWaferU_, "waferu/I"); + treeCells_->Branch("waferv", &cellWaferV_, "waferv/I"); + treeCells_->Branch("wafertype", &cellWaferType_, "wafertype/I"); + treeCells_->Branch("waferrow", &cellWaferRow_, "waferrow/I"); + treeCells_->Branch("wafercolumn", &cellWaferColumn_, "wafercolumn/I"); + treeCells_->Branch("cellu", &cellU_, "cellu/I"); + treeCells_->Branch("cellv", &cellV_, "cellv/I"); + treeCells_->Branch("x", &cellX_, "x/F"); + treeCells_->Branch("y", &cellY_, "y/F"); + treeCells_->Branch("z", &cellZ_, "z/F"); + treeCells_->Branch("corner_n", &cellCornersN_, "corner_n/I"); + treeCells_->Branch("corner_x", cellCornersX_.get(), "corner_x[corner_n]/F"); + treeCells_->Branch("corner_y", cellCornersY_.get(), "corner_y[corner_n]/F"); + treeCells_->Branch("corner_z", cellCornersZ_.get(), "corner_z[corner_n]/F"); + // + treeCellsBH_ = fs_->make("TreeCellsBH", "Tree of all BH cells"); + treeCellsBH_->Branch("id", &cellBHId_, "id/I"); + treeCellsBH_->Branch("type", &cellBHType_, "type/I"); + treeCellsBH_->Branch("zside", &cellBHSide_, "zside/I"); + treeCellsBH_->Branch("subdet", &cellBHSubdet_, "subdet/I"); + treeCellsBH_->Branch("layer", &cellBHLayer_, "layer/I"); + treeCellsBH_->Branch("ieta", &cellBHIEta_, "ieta/I"); + treeCellsBH_->Branch("iphi", &cellBHIPhi_, "iphi/I"); + treeCellsBH_->Branch("eta", &cellBHEta_, "eta/F"); + treeCellsBH_->Branch("phi", &cellBHPhi_, "phi/F"); + treeCellsBH_->Branch("x", &cellBHX_, "x/F"); + treeCellsBH_->Branch("y", &cellBHY_, "y/F"); + treeCellsBH_->Branch("z", &cellBHZ_, "z/F"); + treeCellsBH_->Branch("x1", &cellBHX1_, "x1/F"); + treeCellsBH_->Branch("y1", &cellBHY1_, "y1/F"); + treeCellsBH_->Branch("x2", &cellBHX2_, "x2/F"); + treeCellsBH_->Branch("y2", &cellBHY2_, "y2/F"); + treeCellsBH_->Branch("x3", &cellBHX3_, "x3/F"); + treeCellsBH_->Branch("y3", &cellBHY3_, "y3/F"); + treeCellsBH_->Branch("x4", &cellBHX4_, "x4/F"); + treeCellsBH_->Branch("y4", &cellBHY4_, "y4/F"); } - - /*****************************************************************/ -HGCalTriggerGeomTesterV9Imp2::~HGCalTriggerGeomTesterV9Imp2() +HGCalTriggerGeomTesterV9Imp2::~HGCalTriggerGeomTesterV9Imp2() /*****************************************************************/ -{ -} +{} /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) +void HGCalTriggerGeomTesterV9Imp2::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) /*****************************************************************/ { - es.get().get("", triggerGeometry_); + es.get().get("", triggerGeometry_); - no_trigger_ = !checkMappingConsistency(); - no_neighbors_ = !checkNeighborConsistency(); - fillTriggerGeometry(); + no_trigger_ = !checkMappingConsistency(); + no_neighbors_ = !checkNeighborConsistency(); + fillTriggerGeometry(); } +bool HGCalTriggerGeomTesterV9Imp2::checkMappingConsistency() { + try { + trigger_map_set modules_to_triggercells; + trigger_map_set modules_to_cells; + trigger_map_set triggercells_to_cells; -bool HGCalTriggerGeomTesterV9Imp2::checkMappingConsistency() -{ - try - { - trigger_map_set modules_to_triggercells; - trigger_map_set modules_to_cells; - trigger_map_set triggercells_to_cells; + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + HGCalTriggerDetId tcid(trigger_cell); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + if (module != 0) { + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + // HSi + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + if (!triggerGeometry_->hsiTopology().valid(id)) + continue; + // fill trigger cells + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + HGCalTriggerDetId tcid(trigger_cell); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + if (module != 0) { + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + // HSc + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + // fill trigger cells + unsigned layer = HGCScintillatorDetId(id).layer(); + if (HGCScintillatorDetId(id).type() != triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer)) { + std::cout << "Sci cell type = " << HGCScintillatorDetId(id).type() + << " != " << triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer) << "\n"; + } + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromCell(id); + if (module != 0) { + itr_insert = modules_to_cells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - if(!triggerGeometry_->eeTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - HGCalTriggerDetId tcid(trigger_cell); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - if(module!=0) - { - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - } - // HSi - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - if(!triggerGeometry_->hsiTopology().valid(id)) continue; - // fill trigger cells - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - HGCalTriggerDetId tcid(trigger_cell); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - if(module!=0) - { - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + edm::LogPrint("TriggerCellCheck") << "Checking cell -> trigger cell -> cell consistency"; + // Loop over trigger cells + for (const auto& triggercell_cells : triggercells_to_cells) { + DetId id(triggercell_cells.first); + HGCalTriggerDetId trig_id(triggercell_cells.first); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + if (module != 0) { + if (id.det() != DetId::HGCalHSc) { + auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); } - // HSc - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - // fill trigger cells - unsigned layer = HGCScintillatorDetId(id).layer(); - if(HGCScintillatorDetId(id).type()!=triggerGeometry_->hscTopology().dddConstants().getTypeTrap(layer)) - { - std::cout<<"Sci cell type = "<getTriggerCellFromCell(id); - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromCell(id); - if(module!=0) - { - itr_insert = modules_to_cells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + } + // Check consistency of cells included in trigger cell + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); + const auto& cells = triggercell_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.det() == DetId::HGCalHSc) { + edm::LogProblem("BadTriggerCell") + << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell) + << ")\n has not been found in \n trigger cell " << HGCScintillatorDetId(id); + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) + output << " " << HGCScintillatorDetId(cell_geom) << "\n"; + edm::LogProblem("BadTriggerCell") << output.str(); + } else if (trig_id.subdet() == HGCalTriggerSubdetector::HGCalEETrigger || + trig_id.subdet() == HGCalTriggerSubdetector::HGCalHSiTrigger) { + edm::LogProblem("BadTriggerCell") << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell) + << ")\n has not been found in \n trigger cell " << trig_id; + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) + output << " " << HGCSiliconDetId(cell_geom) << "\n"; + edm::LogProblem("BadTriggerCell") << output.str(); + } else { + edm::LogProblem("BadTriggerCell") + << "Unknown detector type " << id.det() << " " << trig_id.subdet() << "\n"; + edm::LogProblem("BadTriggerCell") << "Cell ID " << HGCSiliconDetId(cell) << "\n"; + } + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in cell <-> trigger cell mapping"; } - - - - edm::LogPrint("TriggerCellCheck")<<"Checking cell -> trigger cell -> cell consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - DetId id(triggercell_cells.first); - HGCalTriggerDetId trig_id(triggercell_cells.first); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - if(module!=0) - { - if(id.det()!=DetId::HGCalHSc) - { - auto itr_insert = modules_to_triggercells.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - } - // Check consistency of cells included in trigger cell - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromTriggerCell(id); - const auto& cells = triggercell_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.det()==DetId::HGCalHSc) - { - edm::LogProblem("BadTriggerCell")<<"Error: \n Cell "< trigger cell mapping"; - } - } - } - edm::LogPrint("ModuleCheck")<<"Checking trigger cell -> module -> trigger cell consistency"; - // Loop over modules - for( const auto& module_triggercells : modules_to_triggercells ) - { - DetId id(module_triggercells.first); - // Check consistency of trigger cells included in module - HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); - const auto& triggercells = module_triggercells.second; - for(auto cell : triggercells) - { - if(triggercells_geom.find(cell)==triggercells_geom.end()) - { - if(id.det()==DetId::HGCalHSc) - { - HGCScintillatorDetId cellid(cell); - edm::LogProblem("BadModule")<<"Error: \n Trigger cell "< module mapping"; - } - else - { - HGCalTriggerDetId cellid(cell); - edm::LogProblem("BadModule")<<"Error: \n Trigger cell "< module mapping"; - } - } + } + } + edm::LogPrint("ModuleCheck") << "Checking trigger cell -> module -> trigger cell consistency"; + // Loop over modules + for (const auto& module_triggercells : modules_to_triggercells) { + DetId id(module_triggercells.first); + // Check consistency of trigger cells included in module + HGCalTriggerGeometryBase::geom_set triggercells_geom = triggerGeometry_->getTriggerCellsFromModule(id); + const auto& triggercells = module_triggercells.second; + for (auto cell : triggercells) { + if (triggercells_geom.find(cell) == triggercells_geom.end()) { + if (id.det() == DetId::HGCalHSc) { + HGCScintillatorDetId cellid(cell); + edm::LogProblem("BadModule") << "Error: \n Trigger cell " << cell << "(" << cellid + << ")\n has not been found in \n module " << HGCScintillatorDetId(id); + std::stringstream output; + output << " Available trigger cells are:\n"; + for (auto cell_geom : triggercells_geom) { + output << " " << HGCScintillatorDetId(cell_geom) << "\n"; } - } - edm::LogPrint("ModuleCheck")<<"Checking cell -> module -> cell consistency"; - for( const auto& module_cells : modules_to_cells ) - { - DetId id(module_cells.first); - // Check consistency of cells included in module - HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); - const auto& cells = module_cells.second; - for(auto cell : cells) - { - if(cells_geom.find(cell)==cells_geom.end()) - { - if(id.det()==DetId::HGCalHSc) - { - edm::LogProblem("BadModule")<<"Error: \n Cell "< module mapping"; - } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in trigger cell <-> module mapping"; + } else { + HGCalTriggerDetId cellid(cell); + edm::LogProblem("BadModule") << "Error: \n Trigger cell " << cell << "(" << cellid + << ")\n has not been found in \n module " << HGCalDetId(id); + std::stringstream output; + output << " Available trigger cells are:\n"; + for (auto cell_geom : triggercells_geom) { + output << " " << HGCalTriggerDetId(cell_geom) << "\n"; } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in trigger cell <-> module mapping"; + } } + } } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - return false; + edm::LogPrint("ModuleCheck") << "Checking cell -> module -> cell consistency"; + for (const auto& module_cells : modules_to_cells) { + DetId id(module_cells.first); + // Check consistency of cells included in module + HGCalTriggerGeometryBase::geom_set cells_geom = triggerGeometry_->getCellsFromModule(id); + const auto& cells = module_cells.second; + for (auto cell : cells) { + if (cells_geom.find(cell) == cells_geom.end()) { + if (id.det() == DetId::HGCalHSc) { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCScintillatorDetId(cell) + << ")\n has not been found in \n module " << HGCScintillatorDetId(id); + } else { + edm::LogProblem("BadModule") << "Error: \n Cell " << cell << "(" << HGCSiliconDetId(cell) + << ")\n has not been found in \n module " << HGCalDetId(id); + } + std::stringstream output; + output << " Available cells are:\n"; + for (auto cell_geom : cells_geom) { + output << cell_geom << " "; + } + edm::LogProblem("BadModule") << output.str(); + throw cms::Exception("BadGeometry") + << "HGCalTriggerGeometry: Found inconsistency in cell <-> module mapping"; + } + } } - return true; + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger geometry detected. Only the basic cells tree will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + return false; + } + return true; } +bool HGCalTriggerGeomTesterV9Imp2::checkNeighborConsistency() { + try { + trigger_map_set triggercells_to_cells; -bool HGCalTriggerGeomTesterV9Imp2::checkNeighborConsistency() -{ - try - { - trigger_map_set triggercells_to_cells; - - // EE - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->eeTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } - // HSi - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->hsiTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // EE + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + if (!triggerGeometry_->eeTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // HSi + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + if (!triggerGeometry_->hsiTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } - // HSc - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - if(!triggerGeometry_->hscTopology().valid(id)) continue; - // fill trigger cells - // Skip trigger cells in module 0 - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // HSc + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + if (!triggerGeometry_->hscTopology().valid(id)) + continue; + // fill trigger cells + // Skip trigger cells in module 0 + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = triggercells_to_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } - edm::LogPrint("NeighborCheck")<<"Checking trigger cell neighbor consistency"; - // Loop over trigger cells - for( const auto& triggercell_cells : triggercells_to_cells ) - { - unsigned triggercell_id(triggercell_cells.first); - const auto neighbors = triggerGeometry_->getNeighborsFromTriggerCell(triggercell_id); - for(const auto neighbor : neighbors) - { - const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); - // check if the original cell is included in the neigbors of neighbor - if(neighbors_of_neighbor.find(triggercell_id)==neighbors_of_neighbor.end()) - { - edm::LogProblem("BadNeighbor")<<"Error: \n Trigger cell "<< HGCalDetId(neighbor) << "\n is a neighbor of \n" << HGCalDetId(triggercell_id); - edm::LogProblem("BadNeighbor")<<" But the opposite is not true"; - std::stringstream output; - output<<" List of neighbors of neighbor = \n"; - for(const auto neighbor_of_neighbor : neighbors_of_neighbor) - { - output<<" "<< HGCalDetId(neighbor_of_neighbor)<<"\n"; - } - edm::LogProblem("BadNeighbor")<getNeighborsFromTriggerCell(triggercell_id); + for (const auto neighbor : neighbors) { + const auto neighbors_of_neighbor = triggerGeometry_->getNeighborsFromTriggerCell(neighbor); + // check if the original cell is included in the neigbors of neighbor + if (neighbors_of_neighbor.find(triggercell_id) == neighbors_of_neighbor.end()) { + edm::LogProblem("BadNeighbor") << "Error: \n Trigger cell " << HGCalDetId(neighbor) + << "\n is a neighbor of \n" + << HGCalDetId(triggercell_id); + edm::LogProblem("BadNeighbor") << " But the opposite is not true"; + std::stringstream output; + output << " List of neighbors of neighbor = \n"; + for (const auto neighbor_of_neighbor : neighbors_of_neighbor) { + output << " " << HGCalDetId(neighbor_of_neighbor) << "\n"; + } + edm::LogProblem("BadNeighbor") << output.str(); } + } } - catch(const cms::Exception& e) { - edm::LogWarning("HGCalTriggerGeometryTester") << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; - edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; - return false; - } - return true; + } catch (const cms::Exception& e) { + edm::LogWarning("HGCalTriggerGeometryTester") + << "Problem with the trigger neighbors detected. No neighbor information will be filled\n"; + edm::LogWarning("HGCalTriggerGeometryTester") << e.message() << "\n"; + return false; + } + return true; } - /*****************************************************************/ void HGCalTriggerGeomTesterV9Imp2::fillTriggerGeometry() /*****************************************************************/ { - trigger_map_set modules; - trigger_map_set trigger_cells; + trigger_map_set modules; + trigger_map_set trigger_cells; - // Loop over cells - edm::LogPrint("TreeFilling")<<"Filling cells tree"; - // EE - std::cout<<"Filling EE geometry\n"; - for(const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - cellId_ = detid.rawId(); - cellSide_ = detid.zside(); - cellSubdet_ = detid.subdet(); - cellLayer_ = detid.layer(); - cellWaferU_ = detid.waferU(); - cellWaferV_ = detid.waferV(); - cellU_ = detid.cellU(); - cellV_ = detid.cellV(); - int type1 = detid.type(); - int type2 = triggerGeometry_->eeTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); - if(type1!=type2) - { - std::cout<<"Found incompatible wafer types:\n "<eeGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); - cellCornersN_ = corners.size(); - setTreeCellCornerSize(cellCornersN_); - for(unsigned i=0; iFill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // Loop over cells + edm::LogPrint("TreeFilling") << "Filling cells tree"; + // EE + std::cout << "Filling EE geometry\n"; + for (const auto& id : triggerGeometry_->eeGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + cellId_ = detid.rawId(); + cellSide_ = detid.zside(); + cellSubdet_ = detid.subdet(); + cellLayer_ = detid.layer(); + cellWaferU_ = detid.waferU(); + cellWaferV_ = detid.waferV(); + cellU_ = detid.cellU(); + cellV_ = detid.cellV(); + int type1 = detid.type(); + int type2 = triggerGeometry_->eeTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); + if (type1 != type2) { + std::cout << "Found incompatible wafer types:\n " << detid << "\n"; } - std::cout<<"Filling HSi geometry\n"; - for(const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) - { - HGCSiliconDetId detid(id); - cellId_ = detid.rawId(); - cellSide_ = detid.zside(); - cellSubdet_ = detid.subdet(); - cellLayer_ = detid.layer(); - cellWaferU_ = detid.waferU(); - cellWaferV_ = detid.waferV(); - cellU_ = detid.cellU(); - cellV_ = detid.cellV(); - int type1 = detid.type(); - int type2 = triggerGeometry_->hsiTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); - if(type1!=type2) - { - std::cout<<"Found incompatible wafer types:\n "<hsiGeometry()->getPosition(id); - cellX_ = center.x(); - cellY_ = center.y(); - cellZ_ = center.z(); - std::vector corners = triggerGeometry_->hsiGeometry()->getCorners(id); - cellCornersN_ = corners.size(); - setTreeCellCornerSize(cellCornersN_); - for(unsigned i=0; iFill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - // Skip trigger cells in module 0 - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); - if(HGCalDetId(module).wafer()==0) continue; - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + // + GlobalPoint center = triggerGeometry_->eeGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->eeGeometry()->getCorners(id); + cellCornersN_ = corners.size(); + setTreeCellCornerSize(cellCornersN_); + for (unsigned i = 0; i < corners.size(); i++) { + cellCornersX_.get()[i] = corners[i].x(); + cellCornersY_.get()[i] = corners[i].y(); + cellCornersZ_.get()[i] = corners[i].z(); } - std::cout<<"Filling HSc geometry\n"; - for(const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) - { - HGCScintillatorDetId cellid(id); - cellBHId_ = cellid.rawId(); - cellBHType_ = cellid.type(); - cellBHSide_ = cellid.zside(); - cellBHSubdet_ = cellid.subdet(); - cellBHLayer_ = cellid.layer(); - cellBHIEta_ = cellid.ieta(); - cellBHIPhi_ = cellid.iphi(); - // - GlobalPoint center = triggerGeometry_->hscGeometry()->getPosition(id); - cellBHEta_ = center.eta(); - cellBHPhi_ = center.phi(); - cellBHX_ = center.x(); - cellBHY_ = center.y(); - cellBHZ_ = center.z(); - auto corners = triggerGeometry_->hscGeometry()->getCorners(id); - if(corners.size()>=4) - { - cellBHX1_ = corners[0].x(); - cellBHY1_ = corners[0].y(); - cellBHX2_ = corners[1].x(); - cellBHY2_ = corners[1].y(); - cellBHX3_ = corners[2].x(); - cellBHY3_ = corners[2].y(); - cellBHX4_ = corners[3].x(); - cellBHY4_ = corners[3].y(); - } - treeCellsBH_->Fill(); - // fill trigger cells - if(!no_trigger_) - { - uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); - auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); - itr_insert.first->second.emplace(id); - } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + std::cout << "Filling HSi geometry\n"; + for (const auto& id : triggerGeometry_->hsiGeometry()->getValidDetIds()) { + HGCSiliconDetId detid(id); + cellId_ = detid.rawId(); + cellSide_ = detid.zside(); + cellSubdet_ = detid.subdet(); + cellLayer_ = detid.layer(); + cellWaferU_ = detid.waferU(); + cellWaferV_ = detid.waferV(); + cellU_ = detid.cellU(); + cellV_ = detid.cellV(); + int type1 = detid.type(); + int type2 = triggerGeometry_->hsiTopology().dddConstants().getTypeHex(cellLayer_, cellWaferU_, cellWaferV_); + if (type1 != type2) { + std::cout << "Found incompatible wafer types:\n " << detid << "\n"; } + // + GlobalPoint center = triggerGeometry_->hsiGeometry()->getPosition(id); + cellX_ = center.x(); + cellY_ = center.y(); + cellZ_ = center.z(); + std::vector corners = triggerGeometry_->hsiGeometry()->getCorners(id); + cellCornersN_ = corners.size(); + setTreeCellCornerSize(cellCornersN_); + for (unsigned i = 0; i < corners.size(); i++) { + cellCornersX_.get()[i] = corners[i].x(); + cellCornersY_.get()[i] = corners[i].y(); + cellCornersZ_.get()[i] = corners[i].z(); + } + treeCells_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + // Skip trigger cells in module 0 + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(trigger_cell); + if (HGCalDetId(module).wafer() == 0) + continue; + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } + std::cout << "Filling HSc geometry\n"; + for (const auto& id : triggerGeometry_->hscGeometry()->getValidDetIds()) { + HGCScintillatorDetId cellid(id); + cellBHId_ = cellid.rawId(); + cellBHType_ = cellid.type(); + cellBHSide_ = cellid.zside(); + cellBHSubdet_ = cellid.subdet(); + cellBHLayer_ = cellid.layer(); + cellBHIEta_ = cellid.ieta(); + cellBHIPhi_ = cellid.iphi(); + // + GlobalPoint center = triggerGeometry_->hscGeometry()->getPosition(id); + cellBHEta_ = center.eta(); + cellBHPhi_ = center.phi(); + cellBHX_ = center.x(); + cellBHY_ = center.y(); + cellBHZ_ = center.z(); + auto corners = triggerGeometry_->hscGeometry()->getCorners(id); + if (corners.size() >= 4) { + cellBHX1_ = corners[0].x(); + cellBHY1_ = corners[0].y(); + cellBHX2_ = corners[1].x(); + cellBHY2_ = corners[1].y(); + cellBHX3_ = corners[2].x(); + cellBHY3_ = corners[2].y(); + cellBHX4_ = corners[3].x(); + cellBHY4_ = corners[3].y(); + } + treeCellsBH_->Fill(); + // fill trigger cells + if (!no_trigger_) { + uint32_t trigger_cell = triggerGeometry_->getTriggerCellFromCell(id); + auto itr_insert = trigger_cells.emplace(trigger_cell, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + } - // if problem detected in the trigger geometry, don't produce trigger trees - if(no_trigger_) return; + // if problem detected in the trigger geometry, don't produce trigger trees + if (no_trigger_) + return; - // Loop over trigger cells - edm::LogPrint("TreeFilling")<<"Filling trigger cells tree"; - for( const auto& triggercell_cells : trigger_cells ) - { - DetId id(triggercell_cells.first); - HGCalTriggerDetId id_trig(triggercell_cells.first); - HGCScintillatorDetId id_sc(triggercell_cells.first); - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); - triggerCellId_ = id.rawId(); - if(id.det()==DetId::HGCalHSc) - { - triggerCellSide_ = id_sc.zside(); - triggerCellSubdet_ = id_sc.subdet(); - triggerCellLayer_ = id_sc.layer(); - triggerCellIEta_ = id_sc.ietaAbs(); - triggerCellIPhi_ = id_sc.iphi(); - } - else - { - triggerCellSide_ = id_trig.zside(); - triggerCellSubdet_ = id_trig.subdet(); - triggerCellLayer_ = id_trig.layer(); - triggerCellWaferU_ = id_trig.waferU(); - triggerCellWaferV_ = id_trig.waferV(); - triggerCellU_ = id_trig.triggerCellU(); - triggerCellV_ = id_trig.triggerCellV(); - } - triggerCellX_ = position.x(); - triggerCellY_ = position.y(); - triggerCellZ_ = position.z(); - triggerCellCell_N_ = triggercell_cells.second.size(); - // - setTreeTriggerCellSize(triggerCellCell_N_); - size_t ic = 0; - for(const auto& c : triggercell_cells.second) - { - if(id.det()==DetId::HGCalHSc) - { - HGCScintillatorDetId cId(c); - GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = 0; - triggerCellCell_waferV_ .get()[ic] = 0; - triggerCellCell_cellU_ .get()[ic] = 0; - triggerCellCell_cellV_ .get()[ic] = 0; - triggerCellCell_ieta_ .get()[ic] = cId.ietaAbs(); - triggerCellCell_iphi_ .get()[ic] = cId.iphi(); - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - else - { - HGCSiliconDetId cId(c); - GlobalPoint cell_position = (cId.det()==DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->hsiGeometry()->getPosition(cId)); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdet(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = cId.waferU(); - triggerCellCell_waferV_ .get()[ic] = cId.waferV(); - triggerCellCell_cellU_ .get()[ic] = cId.cellU(); - triggerCellCell_cellV_ .get()[ic] = cId.cellV(); - triggerCellCell_ieta_ .get()[ic] = 0; - triggerCellCell_iphi_ .get()[ic] = 0; - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - ic++; - } - - treeTriggerCells_->Fill(); - // fill modules - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); - auto itr_insert = modules.emplace(module, std::unordered_set()); - itr_insert.first->second.emplace(id); + // Loop over trigger cells + edm::LogPrint("TreeFilling") << "Filling trigger cells tree"; + for (const auto& triggercell_cells : trigger_cells) { + DetId id(triggercell_cells.first); + HGCalTriggerDetId id_trig(triggercell_cells.first); + HGCScintillatorDetId id_sc(triggercell_cells.first); + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(id); + triggerCellId_ = id.rawId(); + if (id.det() == DetId::HGCalHSc) { + triggerCellSide_ = id_sc.zside(); + triggerCellSubdet_ = id_sc.subdet(); + triggerCellLayer_ = id_sc.layer(); + triggerCellIEta_ = id_sc.ietaAbs(); + triggerCellIPhi_ = id_sc.iphi(); + } else { + triggerCellSide_ = id_trig.zside(); + triggerCellSubdet_ = id_trig.subdet(); + triggerCellLayer_ = id_trig.layer(); + triggerCellWaferU_ = id_trig.waferU(); + triggerCellWaferV_ = id_trig.waferV(); + triggerCellU_ = id_trig.triggerCellU(); + triggerCellV_ = id_trig.triggerCellV(); } - // Loop over modules - edm::LogPrint("TreeFilling")<<"Filling modules tree"; - for( const auto& module_triggercells : modules ) - { - DetId id(module_triggercells.first); - GlobalPoint position = triggerGeometry_->getModulePosition(id); - moduleId_ = id.rawId(); - moduleX_ = position.x(); - moduleY_ = position.y(); - moduleZ_ = position.z(); - if(id.det()==DetId::HGCalHSc) - { - HGCScintillatorDetId sc_id(module_triggercells.first); - moduleSide_ = sc_id.zside(); - moduleSubdet_ = ForwardSubdetector::HGCHEB; - moduleLayer_ = sc_id.layer(); - moduleIEta_ = sc_id.ietaAbs(); - moduleIPhi_ = sc_id.iphi(); - module_ = 0; - } - else - { - HGCalDetId si_id(module_triggercells.first); - moduleSide_ = si_id.zside(); - moduleSubdet_ = si_id.subdetId(); - moduleLayer_ = si_id.layer(); - moduleIEta_ = 0; - moduleIPhi_ = 0; - module_ = si_id.wafer(); - } - moduleTC_N_ = module_triggercells.second.size(); - // - setTreeModuleSize(moduleTC_N_); - size_t itc = 0; - for(const auto& tc : module_triggercells.second) - { - moduleTC_id_ .get()[itc] = tc; - if(id.det()==DetId::HGCalHSc) - { - HGCScintillatorDetId tcId(tc); - moduleTC_zside_ .get()[itc] = tcId.zside(); - moduleTC_subdet_.get()[itc] = tcId.subdet(); - moduleTC_layer_ .get()[itc] = tcId.layer(); - moduleTC_waferU_ .get()[itc] = 0; - moduleTC_waferV_ .get()[itc] = 0; - moduleTC_cellU_ .get()[itc] = 0; - moduleTC_cellV_ .get()[itc] = 0; - moduleTC_ieta_ .get()[itc] = tcId.ietaAbs(); - moduleTC_iphi_ .get()[itc] = tcId.iphi(); - } - else - { - HGCalTriggerDetId tcId(tc); - moduleTC_zside_ .get()[itc] = tcId.zside(); - moduleTC_subdet_.get()[itc] = tcId.subdet(); - moduleTC_layer_ .get()[itc] = tcId.layer(); - moduleTC_waferU_ .get()[itc] = tcId.waferU(); - moduleTC_waferV_ .get()[itc] = tcId.waferV(); - moduleTC_cellU_ .get()[itc] = tcId.triggerCellU(); - moduleTC_cellV_ .get()[itc] = tcId.triggerCellV(); - moduleTC_ieta_ .get()[itc] = 0; - moduleTC_iphi_ .get()[itc] = 0; - } - GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tc); - moduleTC_x_ .get()[itc] = position.x(); - moduleTC_y_ .get()[itc] = position.y(); - moduleTC_z_ .get()[itc] = position.z(); - itc++; - } - auto cells_in_module = triggerGeometry_->getCellsFromModule(id); - moduleCell_N_ = cells_in_module.size(); - // - setTreeModuleCellSize(moduleCell_N_); - size_t ic = 0; - for(const auto& c : cells_in_module) - { - if(id.det()==DetId::HGCalHSc) - { - HGCScintillatorDetId cId(c); - GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); - triggerCellCell_id_ .get()[ic] = c; - triggerCellCell_zside_ .get()[ic] = cId.zside(); - triggerCellCell_subdet_.get()[ic] = cId.subdetId(); - triggerCellCell_layer_ .get()[ic] = cId.layer(); - triggerCellCell_waferU_ .get()[ic] = 0; - triggerCellCell_waferV_ .get()[ic] = 0; - triggerCellCell_cellU_ .get()[ic] = 0; - triggerCellCell_cellV_ .get()[ic] = 0; - triggerCellCell_ieta_ .get()[ic] = cId.ietaAbs(); - triggerCellCell_iphi_ .get()[ic] = cId.iphi(); - triggerCellCell_x_ .get()[ic] = cell_position.x(); - triggerCellCell_y_ .get()[ic] = cell_position.y(); - triggerCellCell_z_ .get()[ic] = cell_position.z(); - } - else - { - HGCSiliconDetId cId(c); - const GlobalPoint position = (cId.det()==DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) : triggerGeometry_->hsiGeometry()->getPosition(cId)); - moduleCell_id_ .get()[ic] = c; - moduleCell_zside_ .get()[ic] = cId.zside(); - moduleCell_subdet_.get()[ic] = cId.subdetId(); - moduleCell_layer_ .get()[ic] = cId.layer(); - moduleCell_waferU_ .get()[ic] = cId.waferU(); - moduleCell_waferV_ .get()[ic] = cId.waferV(); - moduleCell_cellU_ .get()[ic] = cId.cellU(); - moduleCell_cellV_ .get()[ic] = cId.cellV(); - moduleCell_x_ .get()[ic] = position.x(); - moduleCell_y_ .get()[ic] = position.y(); - moduleCell_z_ .get()[ic] = position.z(); - ic++; - } - } - // - treeModules_->Fill(); + triggerCellX_ = position.x(); + triggerCellY_ = position.y(); + triggerCellZ_ = position.z(); + triggerCellCell_N_ = triggercell_cells.second.size(); + // + setTreeTriggerCellSize(triggerCellCell_N_); + size_t ic = 0; + for (const auto& c : triggercell_cells.second) { + if (id.det() == DetId::HGCalHSc) { + HGCScintillatorDetId cId(c); + GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = 0; + triggerCellCell_waferV_.get()[ic] = 0; + triggerCellCell_cellU_.get()[ic] = 0; + triggerCellCell_cellV_.get()[ic] = 0; + triggerCellCell_ieta_.get()[ic] = cId.ietaAbs(); + triggerCellCell_iphi_.get()[ic] = cId.iphi(); + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } else { + HGCSiliconDetId cId(c); + GlobalPoint cell_position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->hsiGeometry()->getPosition(cId)); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdet(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = cId.waferU(); + triggerCellCell_waferV_.get()[ic] = cId.waferV(); + triggerCellCell_cellU_.get()[ic] = cId.cellU(); + triggerCellCell_cellV_.get()[ic] = cId.cellV(); + triggerCellCell_ieta_.get()[ic] = 0; + triggerCellCell_iphi_.get()[ic] = 0; + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } + ic++; } + treeTriggerCells_->Fill(); + // fill modules + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(id); + auto itr_insert = modules.emplace(module, std::unordered_set()); + itr_insert.first->second.emplace(id); + } + // Loop over modules + edm::LogPrint("TreeFilling") << "Filling modules tree"; + for (const auto& module_triggercells : modules) { + DetId id(module_triggercells.first); + GlobalPoint position = triggerGeometry_->getModulePosition(id); + moduleId_ = id.rawId(); + moduleX_ = position.x(); + moduleY_ = position.y(); + moduleZ_ = position.z(); + if (id.det() == DetId::HGCalHSc) { + HGCScintillatorDetId sc_id(module_triggercells.first); + moduleSide_ = sc_id.zside(); + moduleSubdet_ = ForwardSubdetector::HGCHEB; + moduleLayer_ = sc_id.layer(); + moduleIEta_ = sc_id.ietaAbs(); + moduleIPhi_ = sc_id.iphi(); + module_ = 0; + } else { + HGCalDetId si_id(module_triggercells.first); + moduleSide_ = si_id.zside(); + moduleSubdet_ = si_id.subdetId(); + moduleLayer_ = si_id.layer(); + moduleIEta_ = 0; + moduleIPhi_ = 0; + module_ = si_id.wafer(); + } + moduleTC_N_ = module_triggercells.second.size(); + // + setTreeModuleSize(moduleTC_N_); + size_t itc = 0; + for (const auto& tc : module_triggercells.second) { + moduleTC_id_.get()[itc] = tc; + if (id.det() == DetId::HGCalHSc) { + HGCScintillatorDetId tcId(tc); + moduleTC_zside_.get()[itc] = tcId.zside(); + moduleTC_subdet_.get()[itc] = tcId.subdet(); + moduleTC_layer_.get()[itc] = tcId.layer(); + moduleTC_waferU_.get()[itc] = 0; + moduleTC_waferV_.get()[itc] = 0; + moduleTC_cellU_.get()[itc] = 0; + moduleTC_cellV_.get()[itc] = 0; + moduleTC_ieta_.get()[itc] = tcId.ietaAbs(); + moduleTC_iphi_.get()[itc] = tcId.iphi(); + } else { + HGCalTriggerDetId tcId(tc); + moduleTC_zside_.get()[itc] = tcId.zside(); + moduleTC_subdet_.get()[itc] = tcId.subdet(); + moduleTC_layer_.get()[itc] = tcId.layer(); + moduleTC_waferU_.get()[itc] = tcId.waferU(); + moduleTC_waferV_.get()[itc] = tcId.waferV(); + moduleTC_cellU_.get()[itc] = tcId.triggerCellU(); + moduleTC_cellV_.get()[itc] = tcId.triggerCellV(); + moduleTC_ieta_.get()[itc] = 0; + moduleTC_iphi_.get()[itc] = 0; + } + GlobalPoint position = triggerGeometry_->getTriggerCellPosition(tc); + moduleTC_x_.get()[itc] = position.x(); + moduleTC_y_.get()[itc] = position.y(); + moduleTC_z_.get()[itc] = position.z(); + itc++; + } + auto cells_in_module = triggerGeometry_->getCellsFromModule(id); + moduleCell_N_ = cells_in_module.size(); + // + setTreeModuleCellSize(moduleCell_N_); + size_t ic = 0; + for (const auto& c : cells_in_module) { + if (id.det() == DetId::HGCalHSc) { + HGCScintillatorDetId cId(c); + GlobalPoint cell_position = triggerGeometry_->hscGeometry()->getPosition(cId); + triggerCellCell_id_.get()[ic] = c; + triggerCellCell_zside_.get()[ic] = cId.zside(); + triggerCellCell_subdet_.get()[ic] = cId.subdetId(); + triggerCellCell_layer_.get()[ic] = cId.layer(); + triggerCellCell_waferU_.get()[ic] = 0; + triggerCellCell_waferV_.get()[ic] = 0; + triggerCellCell_cellU_.get()[ic] = 0; + triggerCellCell_cellV_.get()[ic] = 0; + triggerCellCell_ieta_.get()[ic] = cId.ietaAbs(); + triggerCellCell_iphi_.get()[ic] = cId.iphi(); + triggerCellCell_x_.get()[ic] = cell_position.x(); + triggerCellCell_y_.get()[ic] = cell_position.y(); + triggerCellCell_z_.get()[ic] = cell_position.z(); + } else { + HGCSiliconDetId cId(c); + const GlobalPoint position = (cId.det() == DetId::HGCalEE ? triggerGeometry_->eeGeometry()->getPosition(cId) + : triggerGeometry_->hsiGeometry()->getPosition(cId)); + moduleCell_id_.get()[ic] = c; + moduleCell_zside_.get()[ic] = cId.zside(); + moduleCell_subdet_.get()[ic] = cId.subdetId(); + moduleCell_layer_.get()[ic] = cId.layer(); + moduleCell_waferU_.get()[ic] = cId.waferU(); + moduleCell_waferV_.get()[ic] = cId.waferV(); + moduleCell_cellU_.get()[ic] = cId.cellU(); + moduleCell_cellV_.get()[ic] = cId.cellV(); + moduleCell_x_.get()[ic] = position.x(); + moduleCell_y_.get()[ic] = position.y(); + moduleCell_z_.get()[ic] = position.z(); + ic++; + } + } + // + treeModules_->Fill(); + } } - /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::analyze(const edm::Event& e, - const edm::EventSetup& es) +void HGCalTriggerGeomTesterV9Imp2::analyze(const edm::Event& e, const edm::EventSetup& es) /*****************************************************************/ -{ - -} - +{} /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::setTreeModuleSize(const size_t n) +void HGCalTriggerGeomTesterV9Imp2::setTreeModuleSize(const size_t n) /*****************************************************************/ { - moduleTC_id_ .reset(new int[n], array_deleter()); - moduleTC_zside_ .reset(new int[n], array_deleter()); - moduleTC_subdet_.reset(new int[n], array_deleter()); - moduleTC_layer_ .reset(new int[n], array_deleter()); - moduleTC_waferU_ .reset(new int[n], array_deleter()); - moduleTC_waferV_ .reset(new int[n], array_deleter()); - moduleTC_cellU_ .reset(new int[n], array_deleter()); - moduleTC_cellV_ .reset(new int[n], array_deleter()); - moduleTC_ieta_ .reset(new int[n], array_deleter()); - moduleTC_iphi_ .reset(new int[n], array_deleter()); - moduleTC_x_ .reset(new float[n], array_deleter()); - moduleTC_y_ .reset(new float[n], array_deleter()); - moduleTC_z_ .reset(new float[n], array_deleter()); + moduleTC_id_.reset(new int[n], array_deleter()); + moduleTC_zside_.reset(new int[n], array_deleter()); + moduleTC_subdet_.reset(new int[n], array_deleter()); + moduleTC_layer_.reset(new int[n], array_deleter()); + moduleTC_waferU_.reset(new int[n], array_deleter()); + moduleTC_waferV_.reset(new int[n], array_deleter()); + moduleTC_cellU_.reset(new int[n], array_deleter()); + moduleTC_cellV_.reset(new int[n], array_deleter()); + moduleTC_ieta_.reset(new int[n], array_deleter()); + moduleTC_iphi_.reset(new int[n], array_deleter()); + moduleTC_x_.reset(new float[n], array_deleter()); + moduleTC_y_.reset(new float[n], array_deleter()); + moduleTC_z_.reset(new float[n], array_deleter()); - treeModules_->GetBranch("tc_id") ->SetAddress(moduleTC_id_ .get()); - treeModules_->GetBranch("tc_zside") ->SetAddress(moduleTC_zside_ .get()); - treeModules_->GetBranch("tc_subdet") ->SetAddress(moduleTC_subdet_.get()); - treeModules_->GetBranch("tc_layer") ->SetAddress(moduleTC_layer_ .get()); - treeModules_->GetBranch("tc_waferu") ->SetAddress(moduleTC_waferU_ .get()); - treeModules_->GetBranch("tc_waferv") ->SetAddress(moduleTC_waferV_ .get()); - treeModules_->GetBranch("tc_cellu") ->SetAddress(moduleTC_cellU_ .get()); - treeModules_->GetBranch("tc_cellv") ->SetAddress(moduleTC_cellV_ .get()); - treeModules_->GetBranch("tc_ieta") ->SetAddress(moduleTC_ieta_ .get()); - treeModules_->GetBranch("tc_iphi") ->SetAddress(moduleTC_iphi_ .get()); - treeModules_->GetBranch("tc_x") ->SetAddress(moduleTC_x_ .get()); - treeModules_->GetBranch("tc_y") ->SetAddress(moduleTC_y_ .get()); - treeModules_->GetBranch("tc_z") ->SetAddress(moduleTC_z_ .get()); + treeModules_->GetBranch("tc_id")->SetAddress(moduleTC_id_.get()); + treeModules_->GetBranch("tc_zside")->SetAddress(moduleTC_zside_.get()); + treeModules_->GetBranch("tc_subdet")->SetAddress(moduleTC_subdet_.get()); + treeModules_->GetBranch("tc_layer")->SetAddress(moduleTC_layer_.get()); + treeModules_->GetBranch("tc_waferu")->SetAddress(moduleTC_waferU_.get()); + treeModules_->GetBranch("tc_waferv")->SetAddress(moduleTC_waferV_.get()); + treeModules_->GetBranch("tc_cellu")->SetAddress(moduleTC_cellU_.get()); + treeModules_->GetBranch("tc_cellv")->SetAddress(moduleTC_cellV_.get()); + treeModules_->GetBranch("tc_ieta")->SetAddress(moduleTC_ieta_.get()); + treeModules_->GetBranch("tc_iphi")->SetAddress(moduleTC_iphi_.get()); + treeModules_->GetBranch("tc_x")->SetAddress(moduleTC_x_.get()); + treeModules_->GetBranch("tc_y")->SetAddress(moduleTC_y_.get()); + treeModules_->GetBranch("tc_z")->SetAddress(moduleTC_z_.get()); } /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::setTreeModuleCellSize(const size_t n) +void HGCalTriggerGeomTesterV9Imp2::setTreeModuleCellSize(const size_t n) /*****************************************************************/ { - moduleCell_id_ .reset(new int[n], array_deleter()); - moduleCell_zside_ .reset(new int[n], array_deleter()); - moduleCell_subdet_.reset(new int[n], array_deleter()); - moduleCell_layer_ .reset(new int[n], array_deleter()); - moduleCell_waferU_ .reset(new int[n], array_deleter()); - moduleCell_waferV_ .reset(new int[n], array_deleter()); - moduleCell_cellU_ .reset(new int[n], array_deleter()); - moduleCell_cellV_ .reset(new int[n], array_deleter()); - moduleCell_x_ .reset(new float[n], array_deleter()); - moduleCell_y_ .reset(new float[n], array_deleter()); - moduleCell_z_ .reset(new float[n], array_deleter()); + moduleCell_id_.reset(new int[n], array_deleter()); + moduleCell_zside_.reset(new int[n], array_deleter()); + moduleCell_subdet_.reset(new int[n], array_deleter()); + moduleCell_layer_.reset(new int[n], array_deleter()); + moduleCell_waferU_.reset(new int[n], array_deleter()); + moduleCell_waferV_.reset(new int[n], array_deleter()); + moduleCell_cellU_.reset(new int[n], array_deleter()); + moduleCell_cellV_.reset(new int[n], array_deleter()); + moduleCell_x_.reset(new float[n], array_deleter()); + moduleCell_y_.reset(new float[n], array_deleter()); + moduleCell_z_.reset(new float[n], array_deleter()); - treeModules_->GetBranch("c_id") ->SetAddress(moduleCell_id_ .get()); - treeModules_->GetBranch("c_zside") ->SetAddress(moduleCell_zside_ .get()); - treeModules_->GetBranch("c_subdet") ->SetAddress(moduleCell_subdet_.get()); - treeModules_->GetBranch("c_layer") ->SetAddress(moduleCell_layer_ .get()); - treeModules_->GetBranch("c_waferu") ->SetAddress(moduleCell_waferU_ .get()); - treeModules_->GetBranch("c_waferv") ->SetAddress(moduleCell_waferV_ .get()); - treeModules_->GetBranch("c_cellu") ->SetAddress(moduleCell_cellU_ .get()); - treeModules_->GetBranch("c_cellv") ->SetAddress(moduleCell_cellV_ .get()); - treeModules_->GetBranch("c_x") ->SetAddress(moduleCell_x_ .get()); - treeModules_->GetBranch("c_y") ->SetAddress(moduleCell_y_ .get()); - treeModules_->GetBranch("c_z") ->SetAddress(moduleCell_z_ .get()); + treeModules_->GetBranch("c_id")->SetAddress(moduleCell_id_.get()); + treeModules_->GetBranch("c_zside")->SetAddress(moduleCell_zside_.get()); + treeModules_->GetBranch("c_subdet")->SetAddress(moduleCell_subdet_.get()); + treeModules_->GetBranch("c_layer")->SetAddress(moduleCell_layer_.get()); + treeModules_->GetBranch("c_waferu")->SetAddress(moduleCell_waferU_.get()); + treeModules_->GetBranch("c_waferv")->SetAddress(moduleCell_waferV_.get()); + treeModules_->GetBranch("c_cellu")->SetAddress(moduleCell_cellU_.get()); + treeModules_->GetBranch("c_cellv")->SetAddress(moduleCell_cellV_.get()); + treeModules_->GetBranch("c_x")->SetAddress(moduleCell_x_.get()); + treeModules_->GetBranch("c_y")->SetAddress(moduleCell_y_.get()); + treeModules_->GetBranch("c_z")->SetAddress(moduleCell_z_.get()); } /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellSize(const size_t n) +void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellSize(const size_t n) /*****************************************************************/ { - triggerCellCell_id_ .reset(new int[n], array_deleter()); - triggerCellCell_zside_ .reset(new int[n], array_deleter()); - triggerCellCell_subdet_.reset(new int[n], array_deleter()); - triggerCellCell_layer_ .reset(new int[n], array_deleter()); - triggerCellCell_waferU_ .reset(new int[n], array_deleter()); - triggerCellCell_waferV_ .reset(new int[n], array_deleter()); - triggerCellCell_cellU_ .reset(new int[n], array_deleter()); - triggerCellCell_cellV_ .reset(new int[n], array_deleter()); - triggerCellCell_ieta_ .reset(new int[n], array_deleter()); - triggerCellCell_iphi_ .reset(new int[n], array_deleter()); - triggerCellCell_x_ .reset(new float[n], array_deleter()); - triggerCellCell_y_ .reset(new float[n], array_deleter()); - triggerCellCell_z_ .reset(new float[n], array_deleter()); + triggerCellCell_id_.reset(new int[n], array_deleter()); + triggerCellCell_zside_.reset(new int[n], array_deleter()); + triggerCellCell_subdet_.reset(new int[n], array_deleter()); + triggerCellCell_layer_.reset(new int[n], array_deleter()); + triggerCellCell_waferU_.reset(new int[n], array_deleter()); + triggerCellCell_waferV_.reset(new int[n], array_deleter()); + triggerCellCell_cellU_.reset(new int[n], array_deleter()); + triggerCellCell_cellV_.reset(new int[n], array_deleter()); + triggerCellCell_ieta_.reset(new int[n], array_deleter()); + triggerCellCell_iphi_.reset(new int[n], array_deleter()); + triggerCellCell_x_.reset(new float[n], array_deleter()); + triggerCellCell_y_.reset(new float[n], array_deleter()); + triggerCellCell_z_.reset(new float[n], array_deleter()); - treeTriggerCells_->GetBranch("c_id") ->SetAddress(triggerCellCell_id_ .get()); - treeTriggerCells_->GetBranch("c_zside") ->SetAddress(triggerCellCell_zside_ .get()); - treeTriggerCells_->GetBranch("c_subdet") ->SetAddress(triggerCellCell_subdet_.get()); - treeTriggerCells_->GetBranch("c_layer") ->SetAddress(triggerCellCell_layer_ .get()); - treeTriggerCells_->GetBranch("c_waferu") ->SetAddress(triggerCellCell_waferU_ .get()); - treeTriggerCells_->GetBranch("c_waferv") ->SetAddress(triggerCellCell_waferV_ .get()); - treeTriggerCells_->GetBranch("c_cellu") ->SetAddress(triggerCellCell_cellU_ .get()); - treeTriggerCells_->GetBranch("c_cellv") ->SetAddress(triggerCellCell_cellV_ .get()); - treeTriggerCells_->GetBranch("c_ieta") ->SetAddress(triggerCellCell_ieta_ .get()); - treeTriggerCells_->GetBranch("c_iphi") ->SetAddress(triggerCellCell_iphi_ .get()); - treeTriggerCells_->GetBranch("c_x") ->SetAddress(triggerCellCell_x_ .get()); - treeTriggerCells_->GetBranch("c_y") ->SetAddress(triggerCellCell_y_ .get()); - treeTriggerCells_->GetBranch("c_z") ->SetAddress(triggerCellCell_z_ .get()); + treeTriggerCells_->GetBranch("c_id")->SetAddress(triggerCellCell_id_.get()); + treeTriggerCells_->GetBranch("c_zside")->SetAddress(triggerCellCell_zside_.get()); + treeTriggerCells_->GetBranch("c_subdet")->SetAddress(triggerCellCell_subdet_.get()); + treeTriggerCells_->GetBranch("c_layer")->SetAddress(triggerCellCell_layer_.get()); + treeTriggerCells_->GetBranch("c_waferu")->SetAddress(triggerCellCell_waferU_.get()); + treeTriggerCells_->GetBranch("c_waferv")->SetAddress(triggerCellCell_waferV_.get()); + treeTriggerCells_->GetBranch("c_cellu")->SetAddress(triggerCellCell_cellU_.get()); + treeTriggerCells_->GetBranch("c_cellv")->SetAddress(triggerCellCell_cellV_.get()); + treeTriggerCells_->GetBranch("c_ieta")->SetAddress(triggerCellCell_ieta_.get()); + treeTriggerCells_->GetBranch("c_iphi")->SetAddress(triggerCellCell_iphi_.get()); + treeTriggerCells_->GetBranch("c_x")->SetAddress(triggerCellCell_x_.get()); + treeTriggerCells_->GetBranch("c_y")->SetAddress(triggerCellCell_y_.get()); + treeTriggerCells_->GetBranch("c_z")->SetAddress(triggerCellCell_z_.get()); } - /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::setTreeCellCornerSize(const size_t n) +void HGCalTriggerGeomTesterV9Imp2::setTreeCellCornerSize(const size_t n) /*****************************************************************/ { - cellCornersX_.reset(new float[n], array_deleter()); - cellCornersY_.reset(new float[n], array_deleter()); - cellCornersZ_.reset(new float[n], array_deleter()); + cellCornersX_.reset(new float[n], array_deleter()); + cellCornersY_.reset(new float[n], array_deleter()); + cellCornersZ_.reset(new float[n], array_deleter()); - treeCells_->GetBranch("corner_x")->SetAddress(cellCornersX_.get()); - treeCells_->GetBranch("corner_y")->SetAddress(cellCornersY_.get()); - treeCells_->GetBranch("corner_z")->SetAddress(cellCornersZ_.get()); + treeCells_->GetBranch("corner_x")->SetAddress(cellCornersX_.get()); + treeCells_->GetBranch("corner_y")->SetAddress(cellCornersY_.get()); + treeCells_->GetBranch("corner_z")->SetAddress(cellCornersZ_.get()); } - - /*****************************************************************/ -void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellNeighborSize(const size_t n) +void HGCalTriggerGeomTesterV9Imp2::setTreeTriggerCellNeighborSize(const size_t n) /*****************************************************************/ { - triggerCellNeighbor_id_.reset(new int[n],array_deleter()); - triggerCellNeighbor_zside_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); - triggerCellNeighbor_layer_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_waferU_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_waferV_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_cellU_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_cellV_ .reset(new int[n], array_deleter()); - triggerCellNeighbor_distance_ .reset(new float[n], array_deleter()); - treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); - treeTriggerCells_->GetBranch("neighbor_zside") ->SetAddress(triggerCellNeighbor_zside_ .get()); - treeTriggerCells_->GetBranch("neighbor_subdet") ->SetAddress(triggerCellNeighbor_subdet_.get()); - treeTriggerCells_->GetBranch("neighbor_layer") ->SetAddress(triggerCellNeighbor_layer_ .get()); - treeTriggerCells_->GetBranch("neighbor_waferu") ->SetAddress(triggerCellNeighbor_waferU_ .get()); - treeTriggerCells_->GetBranch("neighbor_waferv") ->SetAddress(triggerCellNeighbor_waferV_ .get()); - treeTriggerCells_->GetBranch("neighbor_cellu") ->SetAddress(triggerCellNeighbor_cellU_ .get()); - treeTriggerCells_->GetBranch("neighbor_cellv") ->SetAddress(triggerCellNeighbor_cellV_ .get()); - treeTriggerCells_->GetBranch("neighbor_distance") ->SetAddress(triggerCellNeighbor_distance_ .get()); + triggerCellNeighbor_id_.reset(new int[n], array_deleter()); + triggerCellNeighbor_zside_.reset(new int[n], array_deleter()); + triggerCellNeighbor_subdet_.reset(new int[n], array_deleter()); + triggerCellNeighbor_layer_.reset(new int[n], array_deleter()); + triggerCellNeighbor_waferU_.reset(new int[n], array_deleter()); + triggerCellNeighbor_waferV_.reset(new int[n], array_deleter()); + triggerCellNeighbor_cellU_.reset(new int[n], array_deleter()); + triggerCellNeighbor_cellV_.reset(new int[n], array_deleter()); + triggerCellNeighbor_distance_.reset(new float[n], array_deleter()); + treeTriggerCells_->GetBranch("neighbor_id")->SetAddress(triggerCellNeighbor_id_.get()); + treeTriggerCells_->GetBranch("neighbor_zside")->SetAddress(triggerCellNeighbor_zside_.get()); + treeTriggerCells_->GetBranch("neighbor_subdet")->SetAddress(triggerCellNeighbor_subdet_.get()); + treeTriggerCells_->GetBranch("neighbor_layer")->SetAddress(triggerCellNeighbor_layer_.get()); + treeTriggerCells_->GetBranch("neighbor_waferu")->SetAddress(triggerCellNeighbor_waferU_.get()); + treeTriggerCells_->GetBranch("neighbor_waferv")->SetAddress(triggerCellNeighbor_waferV_.get()); + treeTriggerCells_->GetBranch("neighbor_cellu")->SetAddress(triggerCellNeighbor_cellU_.get()); + treeTriggerCells_->GetBranch("neighbor_cellv")->SetAddress(triggerCellNeighbor_cellV_.get()); + treeTriggerCells_->GetBranch("neighbor_distance")->SetAddress(triggerCellNeighbor_distance_.get()); } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/test/HGCalTriggerThresholdTriggerCellTester.cc b/L1Trigger/L1THGCal/test/HGCalTriggerThresholdTriggerCellTester.cc index fddfd252919c4..6ec41a813831b 100644 --- a/L1Trigger/L1THGCal/test/HGCalTriggerThresholdTriggerCellTester.cc +++ b/L1Trigger/L1THGCal/test/HGCalTriggerThresholdTriggerCellTester.cc @@ -2,7 +2,6 @@ #include #include - #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" @@ -34,486 +33,506 @@ #include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellThresholdCodecImpl.h" #include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellThresholdCodec.h" -#include -#include +#include +#include #include "TH2.h" - -class HGCalTriggerThresholdTriggerCellTester : public edm::EDAnalyzer -{ - public: - explicit HGCalTriggerThresholdTriggerCellTester(const edm::ParameterSet& ); - ~HGCalTriggerThresholdTriggerCellTester(); - - virtual void beginRun(const edm::Run&, const edm::EventSetup&); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - - private: - void checkSelectedCells(const edm::Event&, const edm::EventSetup&); - void rerunThresholdFragments(const edm::Event&, const edm::EventSetup&); - void fillModule(const std::vector&, const std::vector >&, const HGCalTriggerCellThresholdDataPayload&, const HGCalTriggerCellThresholdDataPayload&,const HGCalTriggerCellThresholdDataPayload&, const std::map &, const std::unordered_map& ); - - // inputs - edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; - bool is_Simhit_comp_; - edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; - // - edm::ESHandle triggerGeometry_; - std::unique_ptr codec_; - edm::Service fs_; - - // histos - TH1F* hgcCellData_; - TH1F* hgcCellData_SimHitasso_; - TH1F* hgcCellSimHits_; - TH2F* hgcCellData_vsSimHits_; - TH1F* hgcCellsPerModule_; - TH1F* hgcCellModuleSum_; - // - TH1F* hgcCellData_linampl_; - TH2F* hgcCellData_linampl_vsSimHits_; - TH2F* hgcCellData_linampl_vsSimHits_zoom_; - TH1F* triggerCellData_noThreshold_; - TH2F* triggerCellData_noThreshold_vsSimHits_; - TH1F* triggerCellSimHits_noThreshold_; - TH1F* triggerCellData_Threshold_; - TH2F* triggerCellData_Threshold_vsSimHits_; - TH1F* triggerCellData_; - TH2F* triggerCellData_vsSimHits_; - TH1F* triggerCellsPerModule_; - TH1F* triggerCellModuleSum_; - // - TH2F* selectedCellsVsAllCells_ee_; - TH2F* energyLossVsNCells_ee_; - TH2F* selectedCellsVsAllCells_fh_; - TH2F* energyLossVsNCells_fh_; - // - +class HGCalTriggerThresholdTriggerCellTester : public edm::EDAnalyzer { +public: + explicit HGCalTriggerThresholdTriggerCellTester(const edm::ParameterSet&); + ~HGCalTriggerThresholdTriggerCellTester(); + + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + +private: + void checkSelectedCells(const edm::Event&, const edm::EventSetup&); + void rerunThresholdFragments(const edm::Event&, const edm::EventSetup&); + void fillModule(const std::vector&, + const std::vector>&, + const HGCalTriggerCellThresholdDataPayload&, + const HGCalTriggerCellThresholdDataPayload&, + const HGCalTriggerCellThresholdDataPayload&, + const std::map&, + const std::unordered_map&); + + // inputs + edm::EDGetToken inputee_, inputfh_, inputbh_, inputbeall_, inputbeselect_; + bool is_Simhit_comp_; + edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; + // + edm::ESHandle triggerGeometry_; + std::unique_ptr codec_; + edm::Service fs_; + + // histos + TH1F* hgcCellData_; + TH1F* hgcCellData_SimHitasso_; + TH1F* hgcCellSimHits_; + TH2F* hgcCellData_vsSimHits_; + TH1F* hgcCellsPerModule_; + TH1F* hgcCellModuleSum_; + // + TH1F* hgcCellData_linampl_; + TH2F* hgcCellData_linampl_vsSimHits_; + TH2F* hgcCellData_linampl_vsSimHits_zoom_; + TH1F* triggerCellData_noThreshold_; + TH2F* triggerCellData_noThreshold_vsSimHits_; + TH1F* triggerCellSimHits_noThreshold_; + TH1F* triggerCellData_Threshold_; + TH2F* triggerCellData_Threshold_vsSimHits_; + TH1F* triggerCellData_; + TH2F* triggerCellData_vsSimHits_; + TH1F* triggerCellsPerModule_; + TH1F* triggerCellModuleSum_; + // + TH2F* selectedCellsVsAllCells_ee_; + TH2F* energyLossVsNCells_ee_; + TH2F* selectedCellsVsAllCells_fh_; + TH2F* energyLossVsNCells_fh_; + // }; - -HGCalTriggerThresholdTriggerCellTester::HGCalTriggerThresholdTriggerCellTester(const edm::ParameterSet& conf): - inputee_(consumes(conf.getParameter("eeDigis"))), - inputfh_(consumes(conf.getParameter("fhDigis"))), - //inputbh_(consumes(conf.getParameter("bhDigis"))), - inputbeall_(consumes(conf.getParameter("beTriggerCellsAll"))), - inputbeselect_(consumes(conf.getParameter("beTriggerCellsSelect"))), - is_Simhit_comp_(conf.getParameter("isSimhitComp")), - SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), - SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) - // SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) +HGCalTriggerThresholdTriggerCellTester::HGCalTriggerThresholdTriggerCellTester(const edm::ParameterSet& conf) + : inputee_(consumes(conf.getParameter("eeDigis"))), + inputfh_(consumes(conf.getParameter("fhDigis"))), + //inputbh_(consumes(conf.getParameter("bhDigis"))), + inputbeall_(consumes(conf.getParameter("beTriggerCellsAll"))), + inputbeselect_( + consumes(conf.getParameter("beTriggerCellsSelect"))), + is_Simhit_comp_(conf.getParameter("isSimhitComp")), + SimHits_inputee_(consumes(conf.getParameter("eeSimHits"))), + SimHits_inputfh_(consumes(conf.getParameter("fhSimHits"))) +// SimHits_inputbh_(consumes(conf.getParameter("bhSimHits"))) { - //setup FE codec - const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); - codec_.reset( new HGCalTriggerCellThresholdCodecImpl(feCodecConfig) ); - - // initialize output trees - // HGC Cells - hgcCellData_ = fs_->make("hgcCellData","Cell values", 1000, 0., 2000.); - if (is_Simhit_comp_) - { - hgcCellData_SimHitasso_ = fs_->make("hgcCellData_SimHitasso_","Cell values with an associated SimHit", 1000, 0, 2000.); - hgcCellSimHits_ = fs_->make("hgcCellSimHits_","Cell simhit energies", 500, 0, 0.16); - hgcCellData_vsSimHits_ = fs_->make("hgcCellData_vsSimHits_","Cell values vs simhit energies", 500,0,0.16,1000, 0., 2000.); - } - hgcCellsPerModule_ = fs_->make("hgcCellsPerModule","Number of cells per module", 128, 0., 128.); - hgcCellModuleSum_ = fs_->make("hgcCellModuleSum","Cell sum in modules", 1000, 0., 3000.); - // - hgcCellData_linampl_ = fs_->make("hgcCellData_linampl_","Cell linearized amplitudes values All", 1000, 0, 70000); - if (is_Simhit_comp_) - { - hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_","Cell linearized amplitudes vs simhit energies",500,0,0.16,1000,0,70000); - hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_","Cell linearized amplitudes vssimhit energies, zoomed",1000,0,0.002,1000,0,1000); - } - - // HGC Trigger cells - triggerCellData_noThreshold_ = fs_->make("triggerCellData_noThreshold_","Trigger cell values, no threshold", 1000, 0., 70000.); - if (is_Simhit_comp_) - { - triggerCellData_noThreshold_vsSimHits_ = fs_->make("triggerCellData_noThreshold_vsSimHits_","Trigger cell values vs simhit energies, no threshold", 500,0,0.16,1000, 0., 70000.); - triggerCellSimHits_noThreshold_ = fs_->make("triggerCellSimHits_noThreshold","Trigger cell simhit energies, no threshold", 500, 0, 0.16); - } - triggerCellData_Threshold_ = fs_->make("triggerCellData_Threshold_","Trigger cell values, threshold", 1000, 0., 70000.); - if (is_Simhit_comp_) triggerCellData_Threshold_vsSimHits_ = fs_->make("triggerCellData_Threshold_vsSimHits_","Trigger cell values vs simhit energies, threshold", 500,0,0.16,1000, 0., 70000.); - triggerCellData_ = fs_->make("triggerCellData","Trigger cell values", 1100, 0., 1100.); - if (is_Simhit_comp_) - { - triggerCellData_vsSimHits_ = fs_->make("triggerCellData_vsSimHits_","Trigger cell values vs simhit energies", 500,0,0.16,1100, 0., 1100.); - } - triggerCellsPerModule_ = fs_->make("triggerCellsPerModule","Number of trigger cells per module", 64, 0., 64.); - triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum","Trigger cell sum in modules", 1000, 0., 10000.); - // - selectedCellsVsAllCells_ee_ = fs_->make("selectedCellsVsAllCells_ee","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_ee_ = fs_->make("energyLossVsNCells_ee","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - selectedCellsVsAllCells_fh_ = fs_->make("selectedCellsVsAllCells_fh","Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); - energyLossVsNCells_fh_ = fs_->make("energyLossVsNCells_fh","Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); - + //setup FE codec + const edm::ParameterSet& feCodecConfig = conf.getParameterSet("FECodec"); + codec_.reset(new HGCalTriggerCellThresholdCodecImpl(feCodecConfig)); + + // initialize output trees + // HGC Cells + hgcCellData_ = fs_->make("hgcCellData", "Cell values", 1000, 0., 2000.); + if (is_Simhit_comp_) { + hgcCellData_SimHitasso_ = + fs_->make("hgcCellData_SimHitasso_", "Cell values with an associated SimHit", 1000, 0, 2000.); + hgcCellSimHits_ = fs_->make("hgcCellSimHits_", "Cell simhit energies", 500, 0, 0.16); + hgcCellData_vsSimHits_ = + fs_->make("hgcCellData_vsSimHits_", "Cell values vs simhit energies", 500, 0, 0.16, 1000, 0., 2000.); + } + hgcCellsPerModule_ = fs_->make("hgcCellsPerModule", "Number of cells per module", 128, 0., 128.); + hgcCellModuleSum_ = fs_->make("hgcCellModuleSum", "Cell sum in modules", 1000, 0., 3000.); + // + hgcCellData_linampl_ = + fs_->make("hgcCellData_linampl_", "Cell linearized amplitudes values All", 1000, 0, 70000); + if (is_Simhit_comp_) { + hgcCellData_linampl_vsSimHits_ = fs_->make("hgcCellData_linampl_vsSimHits_", + "Cell linearized amplitudes vs simhit energies", + 500, + 0, + 0.16, + 1000, + 0, + 70000); + hgcCellData_linampl_vsSimHits_zoom_ = fs_->make("hgcCellData_linampl_vsSimHits_zoom_", + "Cell linearized amplitudes vssimhit energies, zoomed", + 1000, + 0, + 0.002, + 1000, + 0, + 1000); + } + + // HGC Trigger cells + triggerCellData_noThreshold_ = + fs_->make("triggerCellData_noThreshold_", "Trigger cell values, no threshold", 1000, 0., 70000.); + if (is_Simhit_comp_) { + triggerCellData_noThreshold_vsSimHits_ = fs_->make("triggerCellData_noThreshold_vsSimHits_", + "Trigger cell values vs simhit energies, no threshold", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellSimHits_noThreshold_ = + fs_->make("triggerCellSimHits_noThreshold", "Trigger cell simhit energies, no threshold", 500, 0, 0.16); + } + triggerCellData_Threshold_ = + fs_->make("triggerCellData_Threshold_", "Trigger cell values, threshold", 1000, 0., 70000.); + if (is_Simhit_comp_) + triggerCellData_Threshold_vsSimHits_ = fs_->make("triggerCellData_Threshold_vsSimHits_", + "Trigger cell values vs simhit energies, threshold", + 500, + 0, + 0.16, + 1000, + 0., + 70000.); + triggerCellData_ = fs_->make("triggerCellData", "Trigger cell values", 1100, 0., 1100.); + if (is_Simhit_comp_) { + triggerCellData_vsSimHits_ = fs_->make( + "triggerCellData_vsSimHits_", "Trigger cell values vs simhit energies", 500, 0, 0.16, 1100, 0., 1100.); + } + triggerCellsPerModule_ = fs_->make("triggerCellsPerModule", "Number of trigger cells per module", 64, 0., 64.); + triggerCellModuleSum_ = fs_->make("TriggerCellModuleSum", "Trigger cell sum in modules", 1000, 0., 10000.); + // + selectedCellsVsAllCells_ee_ = fs_->make( + "selectedCellsVsAllCells_ee", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_ee_ = fs_->make( + "energyLossVsNCells_ee", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); + selectedCellsVsAllCells_fh_ = fs_->make( + "selectedCellsVsAllCells_fh", "Number of selected cells vs number of cell", 128, 0, 128, 128, 0., 128.); + energyLossVsNCells_fh_ = fs_->make( + "energyLossVsNCells_fh", "Relative energy loss after selection vs number of cell", 128, 0., 128., 101, 0, 1.01); } +HGCalTriggerThresholdTriggerCellTester::~HGCalTriggerThresholdTriggerCellTester() {} - -HGCalTriggerThresholdTriggerCellTester::~HGCalTriggerThresholdTriggerCellTester() -{ +void HGCalTriggerThresholdTriggerCellTester::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { + es.get().get(triggerGeometry_); } -void HGCalTriggerThresholdTriggerCellTester::beginRun(const edm::Run& /*run*/, - const edm::EventSetup& es) -{ - es.get().get(triggerGeometry_); +void HGCalTriggerThresholdTriggerCellTester::analyze(const edm::Event& e, const edm::EventSetup& es) { + checkSelectedCells(e, es); + rerunThresholdFragments(e, es); } -void HGCalTriggerThresholdTriggerCellTester::analyze(const edm::Event& e, - const edm::EventSetup& es) -{ - checkSelectedCells(e, es); - rerunThresholdFragments(e, es); - +void HGCalTriggerThresholdTriggerCellTester::checkSelectedCells(const edm::Event& e, const edm::EventSetup& es) { + edm::Handle be_triggercells_all_h; + edm::Handle be_triggercells_select_h; + e.getByToken(inputbeall_, be_triggercells_all_h); + e.getByToken(inputbeselect_, be_triggercells_select_h); + + const l1t::HGCalTriggerCellBxCollection& be_triggercells_all = *be_triggercells_all_h; + const l1t::HGCalTriggerCellBxCollection& be_triggercells_select = *be_triggercells_select_h; + + // store trigger cells module by module. tuple = zside,subdet,layer,module + std::map, std::vector> module_triggercells_all; + for (auto cl_itr = be_triggercells_all.begin(0); cl_itr != be_triggercells_all.end(0); cl_itr++) { + const l1t::HGCalTriggerCell& triggercell = *cl_itr; + uint32_t zside = triggercell.eta() < 0. ? 0 : 1; + uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); + uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); + uint32_t layer = HGCalDetId(triggercell.detId()).layer(); + auto itr_insert = + module_triggercells_all.emplace(std::make_tuple(zside, subdet, layer, module), std::vector()); + itr_insert.first->second.emplace_back(triggercell.hwPt()); + } + std::map, std::vector> module_triggercells_select; + for (auto cl_itr = be_triggercells_select.begin(0); cl_itr != be_triggercells_select.end(0); cl_itr++) { + const l1t::HGCalTriggerCell& triggercell = *cl_itr; + uint32_t zside = triggercell.eta() < 0. ? 0 : 1; + uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); + uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); + uint32_t layer = HGCalDetId(triggercell.detId()).layer(); + auto itr_insert = + module_triggercells_select.emplace(std::make_tuple(zside, subdet, layer, module), std::vector()); + itr_insert.first->second.emplace_back(triggercell.hwPt()); + } + + // Compare 'all' and 'selected' trigger cells, module by module + for (const auto& module_cells : module_triggercells_all) { + const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); + if (module_cells_select_itr == module_triggercells_select.end()) + continue; + size_t ncells_all = module_cells.second.size(); + size_t ncells_select = module_cells_select_itr->second.size(); + uint32_t energy_all = 0; + uint32_t energy_select = 0; + for (const auto& energy : module_cells.second) + energy_all += energy; + for (const auto& energy : module_cells_select_itr->second) + energy_select += energy; + if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCEE) { + selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select / (double)energy_all); + + } else if (std::get<1>(module_cells.first) == ForwardSubdetector::HGCHEF) { + selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); + if (energy_all > 0) + energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select / (double)energy_all); + } + } } -void HGCalTriggerThresholdTriggerCellTester::checkSelectedCells(const edm::Event& e, - const edm::EventSetup& es) -{ - edm::Handle be_triggercells_all_h; - edm::Handle be_triggercells_select_h; - e.getByToken(inputbeall_,be_triggercells_all_h); - e.getByToken(inputbeselect_,be_triggercells_select_h); - - const l1t::HGCalTriggerCellBxCollection& be_triggercells_all = *be_triggercells_all_h; - const l1t::HGCalTriggerCellBxCollection& be_triggercells_select = *be_triggercells_select_h; - - // store trigger cells module by module. tuple = zside,subdet,layer,module - std::map, std::vector> module_triggercells_all; - for(auto cl_itr=be_triggercells_all.begin(0); cl_itr!=be_triggercells_all.end(0); cl_itr++) - { - const l1t::HGCalTriggerCell& triggercell = *cl_itr; - uint32_t zside = triggercell.eta()<0. ? 0 : 1; - uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); - uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); - uint32_t layer = HGCalDetId(triggercell.detId()).layer(); - auto itr_insert = module_triggercells_all.emplace( std::make_tuple(zside, subdet, layer, module), std::vector()); - itr_insert.first->second.emplace_back(triggercell.hwPt()); +void HGCalTriggerThresholdTriggerCellTester::rerunThresholdFragments(const edm::Event& e, const edm::EventSetup& es) { + // retrieve digi collections + edm::Handle ee_digis_h; + edm::Handle fh_digis_h; + e.getByToken(inputee_, ee_digis_h); + e.getByToken(inputfh_, fh_digis_h); + + const HGCalDigiCollection& ee_digis = *ee_digis_h; + const HGCalDigiCollection& fh_digis = *fh_digis_h; + + HGCalTriggerCellThresholdDataPayload data; + + // retrieve simhit collections + std::map simhit_energies; + if (is_Simhit_comp_) { + edm::Handle ee_simhits_h; + e.getByToken(SimHits_inputee_, ee_simhits_h); + const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; + edm::Handle fh_simhits_h; + e.getByToken(SimHits_inputfh_, fh_simhits_h); + const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; + + // simhit/digi association EE + HGCalDetId digiid, simid; + int layer = 0, cell = 0, sec = 0, subsec = 0, zp = 0, subdet = 0; + ForwardSubdetector mysubdet; + HGCalDetId recoDetId; + int n_hits_asso = 0; + + // create a map containing all simhit energies + std::unordered_map simhits; + for (const auto& simhit : ee_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->eeTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; + } + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); } - std::map, std::vector> module_triggercells_select; - for(auto cl_itr=be_triggercells_select.begin(0); cl_itr!=be_triggercells_select.end(0); cl_itr++) - { - const l1t::HGCalTriggerCell& triggercell = *cl_itr; - uint32_t zside = triggercell.eta()<0. ? 0 : 1; - uint32_t module = HGCalDetId(triggerGeometry_->getModuleFromTriggerCell(triggercell.detId())).wafer(); - uint32_t subdet = HGCalDetId(triggercell.detId()).subdetId(); - uint32_t layer = HGCalDetId(triggercell.detId()).layer(); - auto itr_insert = module_triggercells_select.emplace( std::make_tuple(zside, subdet, layer, module), std::vector()); - itr_insert.first->second.emplace_back(triggercell.hwPt()); + // find simhit energies associated to digis + for (const auto& data : ee_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso++; + hit_energy = itr->second; + } + simhit_energies[digiid] = hit_energy; } - // Compare 'all' and 'selected' trigger cells, module by module - for(const auto& module_cells : module_triggercells_all) - { - const auto& module_cells_select_itr = module_triggercells_select.find(module_cells.first); - if(module_cells_select_itr==module_triggercells_select.end()) continue; - size_t ncells_all = module_cells.second.size(); - size_t ncells_select = module_cells_select_itr->second.size(); - uint32_t energy_all = 0; - uint32_t energy_select = 0; - for(const auto& energy : module_cells.second) energy_all += energy; - for(const auto& energy : module_cells_select_itr->second) energy_select += energy; - if(std::get<1>(module_cells.first)==ForwardSubdetector::HGCEE) - { - selectedCellsVsAllCells_ee_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_ee_->Fill(ncells_all, (double)energy_select/(double)energy_all); - - } - else if(std::get<1>(module_cells.first)==ForwardSubdetector::HGCHEF) - { - selectedCellsVsAllCells_fh_->Fill(ncells_all, ncells_select); - if(energy_all>0) energyLossVsNCells_fh_->Fill(ncells_all, (double)energy_select/(double)energy_all); - } + // simhit/digi association FH + layer = 0; + cell = 0; + sec = 0; + subsec = 0; + zp = 0; + subdet = 0; + int n_hits_asso_fh = 0; + + // create a map containing all simhit energies + simhits.clear(); + for (const auto& simhit : fh_simhits) { + simid = (HGCalDetId)simhit.id(); + HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); + mysubdet = (ForwardSubdetector)(subdet); + std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco( + cell, layer, sec, triggerGeometry_->fhTopology().detectorType()); + cell = recoLayerCell.first; + layer = recoLayerCell.second; + if (layer < 0 || cell < 0) { + continue; + } + recoDetId = HGCalDetId(mysubdet, zp, layer, subsec, sec, cell); + auto itr_insert = simhits.emplace(recoDetId, 0.); + itr_insert.first->second += simhit.energy(); } - -} - -void HGCalTriggerThresholdTriggerCellTester::rerunThresholdFragments(const edm::Event& e, - const edm::EventSetup& es) -{ - // retrieve digi collections - edm::Handle ee_digis_h; - edm::Handle fh_digis_h; - e.getByToken(inputee_,ee_digis_h); - e.getByToken(inputfh_,fh_digis_h); - - const HGCalDigiCollection& ee_digis = *ee_digis_h; - const HGCalDigiCollection& fh_digis = *fh_digis_h; - - HGCalTriggerCellThresholdDataPayload data; - - // retrieve simhit collections - std::map simhit_energies; + // find simhit energies associated to digis + for (const auto& data : fh_digis) { + digiid = (HGCalDetId)data.id(); + double hit_energy = 0; + auto itr = simhits.find(digiid); + if (itr != simhits.end()) { + n_hits_asso_fh++; + hit_energy = itr->second; + } + simhit_energies[digiid] = hit_energy; + } + } + // Find modules containing hits and prepare list of hits for each module + std::unordered_map> hit_modules_ee; + for (const auto& eedata : ee_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); + auto itr_insert = hit_modules_ee.emplace(module, std::vector()); + itr_insert.first->second.push_back(eedata); + } + std::unordered_map> hit_modules_fh; + for (const auto& fhdata : fh_digis) { + uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); + auto itr_insert = hit_modules_fh.emplace(module, std::vector()); + itr_insert.first->second.push_back(fhdata); + } + // loop on modules containing hits and call front-end processing + for (const auto& module_hits : hit_modules_ee) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over EE and fill digis belonging to that module + for (const auto& eedata : module_hits.second) { + dataframes.emplace_back(eedata.id()); + for (int i = 0; i < eedata.size(); i++) { + dataframes.back().setSample(i, eedata.sample(i)); + } + } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; if (is_Simhit_comp_) { - edm::Handle ee_simhits_h; - e.getByToken(SimHits_inputee_,ee_simhits_h); - const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; - edm::Handle fh_simhits_h; - e.getByToken(SimHits_inputfh_,fh_simhits_h); - const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; - - // simhit/digi association EE - HGCalDetId digiid, simid; - int layer=0,cell=0, sec=0, subsec=0, zp=0,subdet=0; - ForwardSubdetector mysubdet; - HGCalDetId recoDetId ; - int n_hits_asso=0; - - // create a map containing all simhit energies - std::unordered_map simhits; - for( const auto& simhit : ee_simhits ) { - simid = (HGCalDetId)simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->eeTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->eeTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(tc, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(tc) += simenergy; } - // find simhit energies associated to digis - for(const auto& data : ee_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; - } - - // simhit/digi association FH - layer=0; - cell=0; - sec=0; - subsec=0; - zp=0; - subdet=0; - int n_hits_asso_fh=0; - - // create a map containing all simhit energies - simhits.clear(); - for( const auto& simhit : fh_simhits ) { - simid = (HGCalDetId) simhit.id(); - HGCalTestNumbering::unpackHexagonIndex(simid, subdet, zp, layer, sec, subsec, cell); - mysubdet = (ForwardSubdetector)(subdet); - std::pair recoLayerCell = triggerGeometry_->fhTopology().dddConstants().simToReco(cell,layer,sec,triggerGeometry_->fhTopology().detectorType()); - cell = recoLayerCell.first; - layer = recoLayerCell.second; - if (layer<0 || cell<0) { - continue; - } - recoDetId = HGCalDetId(mysubdet,zp,layer,subsec,sec,cell); - auto itr_insert = simhits.emplace(recoDetId, 0.); - itr_insert.first->second += simhit.energy(); - } - // find simhit energies associated to digis - for(const auto& data : fh_digis) { - digiid= (HGCalDetId) data.id(); - double hit_energy=0; - auto itr = simhits.find(digiid); - if(itr!=simhits.end()){ - n_hits_asso_fh++; - hit_energy = itr->second; - } - simhit_energies[digiid] = hit_energy; - } - + } } - // Find modules containing hits and prepare list of hits for each module - std::unordered_map> hit_modules_ee; - for(const auto& eedata : ee_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(eedata.id()); - auto itr_insert = hit_modules_ee.emplace(module,std::vector()); - itr_insert.first->second.push_back(eedata); + // Threshold encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalTriggerCellThresholdDataPayload data_TCsums_woThreshold = data; + codec_->thresholdSelect(data); + HGCalTriggerCellThresholdDataPayload data_TCsums_Threshold = data; + std::vector dataword = codec_->encode(data, *triggerGeometry_); + HGCalTriggerCellThresholdDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woThreshold, + data_TCsums_Threshold, + datadecoded, + simhit_energies, + TC_simhit_energies); + + } //end loop on EE modules + for (const auto& module_hits : hit_modules_fh) { + // prepare input data + std::vector dataframes; + std::vector> linearized_dataframes; + // loop over FH digis and fill digis belonging to that module + for (const auto& fhdata : module_hits.second) { + dataframes.emplace_back(fhdata.id()); + for (int i = 0; i < fhdata.size(); i++) { + dataframes.back().setSample(i, fhdata.sample(i)); + } } - std::unordered_map> hit_modules_fh; - for(const auto& fhdata : fh_digis) - { - uint32_t module = triggerGeometry_->getModuleFromCell(fhdata.id()); - auto itr_insert = hit_modules_fh.emplace(module, std::vector()); - itr_insert.first->second.push_back(fhdata); - } - // loop on modules containing hits and call front-end processing - for( const auto& module_hits : hit_modules_ee ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over EE and fill digis belonging to that module - for(const auto& eedata : module_hits.second) - { - dataframes.emplace_back(eedata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(tc, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(tc)+=simenergy; - } - } - } - // Threshold encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalTriggerCellThresholdDataPayload data_TCsums_woThreshold = data; - codec_->thresholdSelect(data); - HGCalTriggerCellThresholdDataPayload data_TCsums_Threshold = data; - std::vector dataword = codec_->encode(data, *triggerGeometry_); - HGCalTriggerCellThresholdDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); - fillModule(dataframes, linearized_dataframes, data_TCsums_woThreshold,data_TCsums_Threshold, datadecoded, simhit_energies, TC_simhit_energies); - - } //end loop on EE modules - for( const auto& module_hits : hit_modules_fh ) - { - // prepare input data - std::vector dataframes; - std::vector > linearized_dataframes; - // loop over FH digis and fill digis belonging to that module - for(const auto& fhdata : module_hits.second) - { - dataframes.emplace_back(fhdata.id()); - for(int i=0; i TC_simhit_energies; - if (is_Simhit_comp_) - { - // need an ordered set to loop on it in the correct order - for(const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) - { - TC_simhit_energies.emplace(tc, 0); - for(const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) - { - double simenergy = simhit_energies[cell]; - TC_simhit_energies.at(tc)+=simenergy; - } - } + // Association simhit energies with trigger cells + std::unordered_map TC_simhit_energies; + if (is_Simhit_comp_) { + // need an ordered set to loop on it in the correct order + for (const auto& tc : triggerGeometry_->getOrderedTriggerCellsFromModule(module_hits.first)) { + TC_simhit_energies.emplace(tc, 0); + for (const auto& cell : triggerGeometry_->getCellsFromTriggerCell(tc)) { + double simenergy = simhit_energies[cell]; + TC_simhit_energies.at(tc) += simenergy; } - // Threshold encoding - data.reset(); - codec_->linearize(dataframes, linearized_dataframes); - codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); - HGCalTriggerCellThresholdDataPayload data_TCsums_woThreshold = data; - codec_->thresholdSelect(data); - HGCalTriggerCellThresholdDataPayload data_TCsums_Threshold = data; - std::vector dataword = codec_->encode(data, *triggerGeometry_); - HGCalTriggerCellThresholdDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); - fillModule(dataframes, linearized_dataframes, data_TCsums_woThreshold,data_TCsums_Threshold, datadecoded, simhit_energies, TC_simhit_energies); - } //end loop on FH modules - - + } + } + // Threshold encoding + data.reset(); + codec_->linearize(dataframes, linearized_dataframes); + codec_->triggerCellSums(*triggerGeometry_, linearized_dataframes, data); + HGCalTriggerCellThresholdDataPayload data_TCsums_woThreshold = data; + codec_->thresholdSelect(data); + HGCalTriggerCellThresholdDataPayload data_TCsums_Threshold = data; + std::vector dataword = codec_->encode(data, *triggerGeometry_); + HGCalTriggerCellThresholdDataPayload datadecoded = codec_->decode(dataword, module_hits.first, *triggerGeometry_); + fillModule(dataframes, + linearized_dataframes, + data_TCsums_woThreshold, + data_TCsums_Threshold, + datadecoded, + simhit_energies, + TC_simhit_energies); + } //end loop on FH modules } - -void HGCalTriggerThresholdTriggerCellTester::fillModule( const std::vector& dataframes, const std::vector >& linearized_dataframes, const HGCalTriggerCellThresholdDataPayload& fe_payload_TCsums_woThreshold, const HGCalTriggerCellThresholdDataPayload& fe_payload_TCsums_Threshold, const HGCalTriggerCellThresholdDataPayload& fe_payload, const std::map & simhit_energies, const std::unordered_map& TC_simhit_energies) -{ - - // HGC cells part - size_t nHGCDigi = 0; - unsigned hgcCellModuleSum = 0; - // digis, cell based info - for(const auto& frame : dataframes) - { - uint32_t value = frame[2].data(); - nHGCDigi++; - hgcCellModuleSum += value; - hgcCellData_->Fill(value); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.id()); - if (sim_energy >0){ - hgcCellData_SimHitasso_->Fill(value); - hgcCellSimHits_->Fill(sim_energy); - hgcCellData_vsSimHits_->Fill(sim_energy,value); - } - } - } - hgcCellsPerModule_->Fill(nHGCDigi); - hgcCellModuleSum_->Fill(hgcCellModuleSum); - - // linearized samples, cell based info - for(const auto& frame : linearized_dataframes){ - hgcCellData_linampl_-> Fill(frame.second); - if (is_Simhit_comp_){ - double sim_energy= simhit_energies.at(frame.first); - if (sim_energy >0){ - hgcCellData_linampl_vsSimHits_-> Fill(sim_energy,frame.second); - hgcCellData_linampl_vsSimHits_zoom_-> Fill(sim_energy,frame.second); - } - } +void HGCalTriggerThresholdTriggerCellTester::fillModule( + const std::vector& dataframes, + const std::vector>& linearized_dataframes, + const HGCalTriggerCellThresholdDataPayload& fe_payload_TCsums_woThreshold, + const HGCalTriggerCellThresholdDataPayload& fe_payload_TCsums_Threshold, + const HGCalTriggerCellThresholdDataPayload& fe_payload, + const std::map& simhit_energies, + const std::unordered_map& TC_simhit_energies) { + // HGC cells part + size_t nHGCDigi = 0; + unsigned hgcCellModuleSum = 0; + // digis, cell based info + for (const auto& frame : dataframes) { + uint32_t value = frame[2].data(); + nHGCDigi++; + hgcCellModuleSum += value; + hgcCellData_->Fill(value); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.id()); + if (sim_energy > 0) { + hgcCellData_SimHitasso_->Fill(value); + hgcCellSimHits_->Fill(sim_energy); + hgcCellData_vsSimHits_->Fill(sim_energy, value); + } } + } + hgcCellsPerModule_->Fill(nHGCDigi); + hgcCellModuleSum_->Fill(hgcCellModuleSum); - // trigger cells part - // after sum, no threshold, no encode/decode - for(const auto& tc : fe_payload_TCsums_woThreshold.payload) - { - if(tc.hwPt()>0) - { - triggerCellData_noThreshold_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId()) >0){ - triggerCellSimHits_noThreshold_->Fill(TC_simhit_energies.at(tc.detId())); - triggerCellData_noThreshold_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } - } - } + // linearized samples, cell based info + for (const auto& frame : linearized_dataframes) { + hgcCellData_linampl_->Fill(frame.second); + if (is_Simhit_comp_) { + double sim_energy = simhit_energies.at(frame.first); + if (sim_energy > 0) { + hgcCellData_linampl_vsSimHits_->Fill(sim_energy, frame.second); + hgcCellData_linampl_vsSimHits_zoom_->Fill(sim_energy, frame.second); + } } - - // after sum, threshold, no encode/decode - for(const auto& tc : fe_payload_TCsums_Threshold.payload) - { - if(tc.hwPt()>0) - { - triggerCellData_Threshold_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId())>0) triggerCellData_Threshold_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } + } + + // trigger cells part + // after sum, no threshold, no encode/decode + for (const auto& tc : fe_payload_TCsums_woThreshold.payload) { + if (tc.hwPt() > 0) { + triggerCellData_noThreshold_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) { + triggerCellSimHits_noThreshold_->Fill(TC_simhit_energies.at(tc.detId())); + triggerCellData_noThreshold_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); } + } } - - // after sum, threshold, encode/decode - size_t nFEDigi = 0; - unsigned triggerCellModuleSum = 0; - for(const auto& tc : fe_payload.payload) - { - uint32_t tcShifted = (tc.hwPt()<triggerCellTruncationBits()); - if(tc.hwPt()>0) - { - nFEDigi++; - triggerCellModuleSum += tcShifted; - triggerCellData_->Fill(tc.hwPt()); - if (is_Simhit_comp_){ - if (TC_simhit_energies.at(tc.detId())>0) triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()),tc.hwPt()); - } - } + } + + // after sum, threshold, no encode/decode + for (const auto& tc : fe_payload_TCsums_Threshold.payload) { + if (tc.hwPt() > 0) { + triggerCellData_Threshold_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) + triggerCellData_Threshold_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); + } + } + } + + // after sum, threshold, encode/decode + size_t nFEDigi = 0; + unsigned triggerCellModuleSum = 0; + for (const auto& tc : fe_payload.payload) { + uint32_t tcShifted = (tc.hwPt() << codec_->triggerCellTruncationBits()); + if (tc.hwPt() > 0) { + nFEDigi++; + triggerCellModuleSum += tcShifted; + triggerCellData_->Fill(tc.hwPt()); + if (is_Simhit_comp_) { + if (TC_simhit_energies.at(tc.detId()) > 0) + triggerCellData_vsSimHits_->Fill(TC_simhit_energies.at(tc.detId()), tc.hwPt()); + } } - triggerCellsPerModule_->Fill(nFEDigi); - triggerCellModuleSum_->Fill(triggerCellModuleSum); + } + triggerCellsPerModule_->Fill(nFEDigi); + triggerCellModuleSum_->Fill(triggerCellModuleSum); } //define this as a plug-in diff --git a/L1Trigger/L1THGCal/test/calib/testCalibration.cc b/L1Trigger/L1THGCal/test/calib/testCalibration.cc index 7d17982c4fcb6..ea2ce102cfda5 100644 --- a/L1Trigger/L1THGCal/test/calib/testCalibration.cc +++ b/L1Trigger/L1THGCal/test/calib/testCalibration.cc @@ -2,7 +2,7 @@ // // Package: Analyzers // Class: testCalibration -// +// /**\class testCalibration testCalibration.cc HGCPFLab/Analyzers/plugins/testCalibration.cc Description: [one line class summary] @@ -17,7 +17,6 @@ // // - // system include files #include @@ -47,111 +46,96 @@ using namespace HGCalTriggerBackend; using namespace l1t; class testCalibration : public edm::EDAnalyzer { - public: - - explicit testCalibration(const edm::ParameterSet& ); - - ~testCalibration(); - + explicit testCalibration(const edm::ParameterSet &); + + ~testCalibration(); + private: - - edm::Service fs_; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - - // ----------member data --------------------------- - EDGetTokenT tokenTrgCell_; - - bool debug_; - int nEvent_=0; - - TH1D *h_photon_pt_; - TH1D *h_tc_hwPt_; - TH1D *h_tc_E_; - TH1D *h_tc_pt_; - TH1D *h_tc_eta_; - TH1D *h_tc_phi_; - TH1D *h_tc_layer_; - - TTree *mytree_; - - double TC_pt_=0.; -}; + edm::Service fs_; + virtual void analyze(const edm::Event &, const edm::EventSetup &); + // ----------member data --------------------------- + EDGetTokenT tokenTrgCell_; + bool debug_; + int nEvent_ = 0; -// constructors and destructor -testCalibration::testCalibration(const edm::ParameterSet& iConfig) : - tokenTrgCell_( consumes< HGCalTriggerCellBxCollection >( iConfig.getParameter ( "triggerCellInputTag" ) ) ) -{ - -// consumes< BXVector< l1t::HGCalTriggerCell > > (TrgCells_tag_); -// consumes< HGCalTriggerCellBxCollection > (TrgCells_tag_); - - //now do what ever initialization is needed - //edm::Service fs; - h_photon_pt_ = fs_->make("h_photon_pt" , "h_photon_pt" , 250 , 0 , 500 ); - h_tc_hwPt_ = fs_->make("h_tc_hwPt" , "h_tc_hwPt" , 100 , 0 , 2 ); - h_tc_E_ = fs_->make("h_tc_E" , "h_tc_E" , 200 , 0 , 50 ); - h_tc_pt_ = fs_->make("h_tc_pt" , "h_tc_pt" , 200 , 0 , 50 ); - h_tc_eta_ = fs_->make("h_tc_eta" , "h_tc_eta" , 100 , -3.1 , 3.1 ); - h_tc_phi_ = fs_->make("h_tc_phi" , "h_tc_phi" , 100 , -3.14 , 3.14 ); - h_tc_layer_ = fs_->make("h_tc_layer" , "h_tc_layer" , 40 , 0 , 40 ); - - mytree_ = fs_->make ("tree","tree"); - - //TTree branch - mytree_->Branch("event", &nEvent_, "event/I"); - mytree_->Branch("TC_pt", &TC_pt_, "TC_pt/D"); + TH1D *h_photon_pt_; + TH1D *h_tc_hwPt_; + TH1D *h_tc_E_; + TH1D *h_tc_pt_; + TH1D *h_tc_eta_; + TH1D *h_tc_phi_; + TH1D *h_tc_layer_; -} + TTree *mytree_; -testCalibration::~testCalibration() -{ + double TC_pt_ = 0.; +}; + +// constructors and destructor +testCalibration::testCalibration(const edm::ParameterSet &iConfig) + : tokenTrgCell_(consumes(iConfig.getParameter("triggerCellInputTag"))) { + // consumes< BXVector< l1t::HGCalTriggerCell > > (TrgCells_tag_); + // consumes< HGCalTriggerCellBxCollection > (TrgCells_tag_); + + //now do what ever initialization is needed + //edm::Service fs; + h_photon_pt_ = fs_->make("h_photon_pt", "h_photon_pt", 250, 0, 500); + h_tc_hwPt_ = fs_->make("h_tc_hwPt", "h_tc_hwPt", 100, 0, 2); + h_tc_E_ = fs_->make("h_tc_E", "h_tc_E", 200, 0, 50); + h_tc_pt_ = fs_->make("h_tc_pt", "h_tc_pt", 200, 0, 50); + h_tc_eta_ = fs_->make("h_tc_eta", "h_tc_eta", 100, -3.1, 3.1); + h_tc_phi_ = fs_->make("h_tc_phi", "h_tc_phi", 100, -3.14, 3.14); + h_tc_layer_ = fs_->make("h_tc_layer", "h_tc_layer", 40, 0, 40); + + mytree_ = fs_->make("tree", "tree"); + + //TTree branch + mytree_->Branch("event", &nEvent_, "event/I"); + mytree_->Branch("TC_pt", &TC_pt_, "TC_pt/D"); } -// ------------ method called for each event ------------ -void testCalibration::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace std; - using namespace edm; - using namespace reco; - using namespace HGCalTriggerBackend; - using namespace l1t; - - Handle trgCell; - iEvent.getByToken(tokenTrgCell_, trgCell); - - double E_allTC_endcap_PosEta=0.; - double E_allTC_endcap_NegEta=0.; - - for(size_t i=0; isize(); ++i){ - if((*trgCell)[i].pt() < 0.01) continue; - HGCalDetId detid( (*trgCell)[i].detId() ); - int tc_layer = detid.layer(); - - if((*trgCell)[i].eta()<0) - E_allTC_endcap_NegEta += (*trgCell)[i].pt(); - else if((*trgCell)[i].eta()>0) - E_allTC_endcap_PosEta += (*trgCell)[i].pt(); - - h_tc_pt_->Fill((*trgCell)[i].pt()); - h_tc_eta_->Fill((*trgCell)[i].eta()); - h_tc_phi_->Fill((*trgCell)[i].phi()); - h_tc_layer_->Fill(tc_layer); - - } - if(E_allTC_endcap_PosEta>0){ - h_photon_pt_->Fill(E_allTC_endcap_PosEta); - }else if(E_allTC_endcap_NegEta>0){ - h_photon_pt_->Fill(E_allTC_endcap_NegEta); - } - mytree_->Fill(); +testCalibration::~testCalibration() {} +// ------------ method called for each event ------------ +void testCalibration::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { + using namespace std; + using namespace edm; + using namespace reco; + using namespace HGCalTriggerBackend; + using namespace l1t; + + Handle trgCell; + iEvent.getByToken(tokenTrgCell_, trgCell); + + double E_allTC_endcap_PosEta = 0.; + double E_allTC_endcap_NegEta = 0.; + + for (size_t i = 0; i < trgCell->size(); ++i) { + if ((*trgCell)[i].pt() < 0.01) + continue; + HGCalDetId detid((*trgCell)[i].detId()); + int tc_layer = detid.layer(); + + if ((*trgCell)[i].eta() < 0) + E_allTC_endcap_NegEta += (*trgCell)[i].pt(); + else if ((*trgCell)[i].eta() > 0) + E_allTC_endcap_PosEta += (*trgCell)[i].pt(); + + h_tc_pt_->Fill((*trgCell)[i].pt()); + h_tc_eta_->Fill((*trgCell)[i].eta()); + h_tc_phi_->Fill((*trgCell)[i].phi()); + h_tc_layer_->Fill(tc_layer); + } + if (E_allTC_endcap_PosEta > 0) { + h_photon_pt_->Fill(E_allTC_endcap_PosEta); + } else if (E_allTC_endcap_NegEta > 0) { + h_photon_pt_->Fill(E_allTC_endcap_NegEta); + } + mytree_->Fill(); } //define this as a plug-in DEFINE_FWK_MODULE(testCalibration); - - - diff --git a/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h index 0b9d678bbdf1b..44dad5863dd7a 100644 --- a/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h +++ b/L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h @@ -5,23 +5,20 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include"TTree.h" +#include "TTree.h" +class HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleBase(const edm::ParameterSet& conf){}; + virtual ~HGCalTriggerNtupleBase(){}; + virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) = 0; + virtual void fill(const edm::Event&, const edm::EventSetup&) = 0; -class HGCalTriggerNtupleBase -{ - public: - HGCalTriggerNtupleBase(const edm::ParameterSet& conf) {}; - virtual ~HGCalTriggerNtupleBase(){}; - virtual void initialize(TTree& , const edm::ParameterSet&, edm::ConsumesCollector&& ) = 0; - virtual void fill(const edm::Event& , const edm::EventSetup& ) = 0; - - protected: - virtual void clear() = 0; +protected: + virtual void clear() = 0; }; #include "FWCore/PluginManager/interface/PluginFactory.h" -typedef edmplugin::PluginFactory< HGCalTriggerNtupleBase* (const edm::ParameterSet&) > HGCalTriggerNtupleFactory; - +typedef edmplugin::PluginFactory HGCalTriggerNtupleFactory; #endif diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc index a2bcbc042323f..24506ebbabcd1 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleEvent.cc @@ -1,58 +1,39 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" -class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase -{ - public: - HGCalTriggerNtupleEvent(const edm::ParameterSet&); +class HGCalTriggerNtupleEvent : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleEvent(const edm::ParameterSet&); - void initialize(TTree&,const edm::ParameterSet&, edm::ConsumesCollector &&) final; - void fill(const edm::Event&,const edm::EventSetup&) final; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event&, const edm::EventSetup&) final; - private: - void clear() final; +private: + void clear() final; - int run_; - int event_; - int lumi_; + int run_; + int event_; + int lumi_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleEvent, - "HGCalTriggerNtupleEvent" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleEvent, "HGCalTriggerNtupleEvent"); +HGCalTriggerNtupleEvent::HGCalTriggerNtupleEvent(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} -HGCalTriggerNtupleEvent:: -HGCalTriggerNtupleEvent(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ +void HGCalTriggerNtupleEvent::initialize(TTree& tree, const edm::ParameterSet&, edm::ConsumesCollector&&) { + clear(); + tree.Branch("run", &run_, "run/I"); + tree.Branch("event", &event_, "event/I"); + tree.Branch("lumi", &lumi_, "lumi/I"); } -void -HGCalTriggerNtupleEvent:: -initialize(TTree& tree,const edm::ParameterSet&, edm::ConsumesCollector&&) -{ - clear(); - tree.Branch("run", &run_, "run/I" ); - tree.Branch("event", &event_, "event/I"); - tree.Branch("lumi", &lumi_, "lumi/I"); +void HGCalTriggerNtupleEvent::fill(const edm::Event& e, const edm::EventSetup& es) { + run_ = e.id().run(); + lumi_ = e.luminosityBlock(); + event_ = e.id().event(); } -void -HGCalTriggerNtupleEvent:: -fill(const edm::Event& e,const edm::EventSetup& es) -{ - run_ = e.id().run(); - lumi_ = e.luminosityBlock(); - event_ = e.id().event(); +void HGCalTriggerNtupleEvent::clear() { + run_ = 0; + lumi_ = 0; + event_ = 0; } - -void -HGCalTriggerNtupleEvent:: -clear() -{ - run_ = 0; - lumi_ = 0; - event_ = 0; -} - - - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc index 2a2914e64704c..cf815780a859c 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc @@ -3,7 +3,6 @@ #include "DataFormats/GeometrySurface/interface/Plane.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" - #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" @@ -26,17 +25,15 @@ namespace HGCal_helpers { class Coordinates { - public: + public: Coordinates() : x(0), y(0), z(0), eta(0), phi(0) {} float x, y, z, eta, phi; inline math::XYZTLorentzVectorD toVector() { return math::XYZTLorentzVectorD(x, y, z, 0); } }; - class SimpleTrackPropagator { - public: - SimpleTrackPropagator(const MagneticField *f) - : field_(f), prod_(field_, alongMomentum), absz_target_(0) { + public: + SimpleTrackPropagator(const MagneticField *f) : field_(f), prod_(field_, alongMomentum), absz_target_(0) { ROOT::Math::SMatrixIdentity id; AlgebraicSymMatrix55 C(id); const float uncert = 0.001; @@ -45,13 +42,21 @@ namespace HGCal_helpers { } void setPropagationTargetZ(const float &z); - bool propagate(const double px, const double py, const double pz, const double x, const double y, - const double z, const float charge, Coordinates &coords) const; - - bool propagate(const math::XYZTLorentzVectorD &momentum, const math::XYZTLorentzVectorD &position, - const float charge, Coordinates &coords) const; - - private: + bool propagate(const double px, + const double py, + const double pz, + const double x, + const double y, + const double z, + const float charge, + Coordinates &coords) const; + + bool propagate(const math::XYZTLorentzVectorD &momentum, + const math::XYZTLorentzVectorD &position, + const float charge, + Coordinates &coords) const; + + private: SimpleTrackPropagator() : field_(nullptr), prod_(field_, alongMomentum), absz_target_(0) {} const RKPropagatorInS &RKProp() const { return prod_.propagator; } Plane::PlanePointer targetPlaneForward_, targetPlaneBackward_; @@ -63,23 +68,25 @@ namespace HGCal_helpers { void SimpleTrackPropagator::setPropagationTargetZ(const float &z) { targetPlaneForward_ = Plane::build(Plane::PositionType(0, 0, std::abs(z)), Plane::RotationType()); - targetPlaneBackward_ = - Plane::build(Plane::PositionType(0, 0, -std::abs(z)), Plane::RotationType()); + targetPlaneBackward_ = Plane::build(Plane::PositionType(0, 0, -std::abs(z)), Plane::RotationType()); absz_target_ = std::abs(z); } - bool SimpleTrackPropagator::propagate(const double px, const double py, const double pz, - const double x, const double y, const double z, - const float charge, Coordinates &output) const { + bool SimpleTrackPropagator::propagate(const double px, + const double py, + const double pz, + const double x, + const double y, + const double z, + const float charge, + Coordinates &output) const { output = Coordinates(); typedef TrajectoryStateOnSurface TSOS; GlobalPoint startingPosition(x, y, z); GlobalVector startingMomentum(px, py, pz); - Plane::PlanePointer startingPlane = - Plane::build(Plane::PositionType(x, y, z), Plane::RotationType()); + Plane::PlanePointer startingPlane = Plane::build(Plane::PositionType(x, y, z), Plane::RotationType()); TSOS startingStateP( - GlobalTrajectoryParameters(startingPosition, startingMomentum, charge, field_), err_, - *startingPlane); + GlobalTrajectoryParameters(startingPosition, startingMomentum, charge, field_), err_, *startingPlane); TSOS trackStateP; if (pz > 0) { @@ -99,400 +106,363 @@ namespace HGCal_helpers { } bool SimpleTrackPropagator::propagate(const math::XYZTLorentzVectorD &momentum, - const math::XYZTLorentzVectorD &position, const float charge, + const math::XYZTLorentzVectorD &position, + const float charge, Coordinates &output) const { - return propagate(momentum.px(), momentum.py(), momentum.pz(), position.x(), position.y(), - position.z(), charge, output); + return propagate( + momentum.px(), momentum.py(), momentum.pz(), position.x(), position.y(), position.z(), charge, output); } -} // HGCal_helpers - - -class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleGen(const edm::ParameterSet& ); - - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup& ) final; - - enum ReachHGCal { - notReach = 0, - outsideEESurface = 1, - onEESurface = 2 - }; - - private: - void clear() final; - - edm::EDGetToken gen_token_; - edm::EDGetToken gen_PU_token_; - - int gen_n_; - int gen_PUNumInt_; - float gen_TrueNumInt_; - - float vtx_x_; - float vtx_y_; - float vtx_z_; - - - //////////////////// - // GenParticles - // - std::vector genpart_eta_; - std::vector genpart_phi_; - std::vector genpart_pt_; - std::vector genpart_energy_; - std::vector genpart_dvx_; - std::vector genpart_dvy_; - std::vector genpart_dvz_; - std::vector genpart_ovx_; - std::vector genpart_ovy_; - std::vector genpart_ovz_; - std::vector genpart_exx_; - std::vector genpart_exy_; - std::vector genpart_mother_; - std::vector genpart_exphi_; - std::vector genpart_exeta_; - std::vector genpart_fbrem_; - std::vector genpart_pid_; - std::vector genpart_gen_; - std::vector genpart_reachedEE_; - std::vector genpart_fromBeamPipe_; - std::vector> genpart_posx_; - std::vector> genpart_posy_; - std::vector> genpart_posz_; - - //////////////////// - // reco::GenParticles - // - std::vector gen_eta_; - std::vector gen_phi_; - std::vector gen_pt_; - std::vector gen_energy_; - std::vector gen_charge_; - std::vector gen_pdgid_; - std::vector gen_status_; - std::vector> gen_daughters_; - - - // -------convenient tool to deal with simulated tracks - std::unique_ptr mySimEvent_; - - // and also the magnetic field - const MagneticField *aField_; - - HGCalTriggerTools triggerTools_; - - // edm::EDGetTokenT > genParticles_; - edm::EDGetToken simTracks_token_; - edm::EDGetToken simVertices_token_; - edm::EDGetToken hepmcev_token_; - - edm::ESWatcher pdt_watcher_; - edm::ESWatcher magfield_watcher_; - - +} // namespace HGCal_helpers + +class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleGen(const edm::ParameterSet &); + + void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final; + void fill(const edm::Event &, const edm::EventSetup &) final; + + enum ReachHGCal { notReach = 0, outsideEESurface = 1, onEESurface = 2 }; + +private: + void clear() final; + + edm::EDGetToken gen_token_; + edm::EDGetToken gen_PU_token_; + + int gen_n_; + int gen_PUNumInt_; + float gen_TrueNumInt_; + + float vtx_x_; + float vtx_y_; + float vtx_z_; + + //////////////////// + // GenParticles + // + std::vector genpart_eta_; + std::vector genpart_phi_; + std::vector genpart_pt_; + std::vector genpart_energy_; + std::vector genpart_dvx_; + std::vector genpart_dvy_; + std::vector genpart_dvz_; + std::vector genpart_ovx_; + std::vector genpart_ovy_; + std::vector genpart_ovz_; + std::vector genpart_exx_; + std::vector genpart_exy_; + std::vector genpart_mother_; + std::vector genpart_exphi_; + std::vector genpart_exeta_; + std::vector genpart_fbrem_; + std::vector genpart_pid_; + std::vector genpart_gen_; + std::vector genpart_reachedEE_; + std::vector genpart_fromBeamPipe_; + std::vector> genpart_posx_; + std::vector> genpart_posy_; + std::vector> genpart_posz_; + + //////////////////// + // reco::GenParticles + // + std::vector gen_eta_; + std::vector gen_phi_; + std::vector gen_pt_; + std::vector gen_energy_; + std::vector gen_charge_; + std::vector gen_pdgid_; + std::vector gen_status_; + std::vector> gen_daughters_; + + // -------convenient tool to deal with simulated tracks + std::unique_ptr mySimEvent_; + + // and also the magnetic field + const MagneticField *aField_; + + HGCalTriggerTools triggerTools_; + + // edm::EDGetTokenT > genParticles_; + edm::EDGetToken simTracks_token_; + edm::EDGetToken simVertices_token_; + edm::EDGetToken hepmcev_token_; + + edm::ESWatcher pdt_watcher_; + edm::ESWatcher magfield_watcher_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleGen, - "HGCalTriggerNtupleGen" ); - - -HGCalTriggerNtupleGen:: -HGCalTriggerNtupleGen(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGen, "HGCalTriggerNtupleGen"); + +HGCalTriggerNtupleGen::HGCalTriggerNtupleGen(const edm::ParameterSet &conf) : HGCalTriggerNtupleBase(conf) {} + +void HGCalTriggerNtupleGen::initialize(TTree &tree, const edm::ParameterSet &conf, edm::ConsumesCollector &&collector) { + edm::ParameterSet particleFilter_(conf.getParameter("particleFilter")); + mySimEvent_ = std::make_unique(particleFilter_); + + gen_token_ = collector.consumes(conf.getParameter("GenParticles")); + gen_PU_token_ = collector.consumes>(conf.getParameter("GenPU")); + tree.Branch("gen_n", &gen_n_, "gen_n/I"); + tree.Branch("gen_PUNumInt", &gen_PUNumInt_, "gen_PUNumInt/I"); + tree.Branch("gen_TrueNumInt", &gen_TrueNumInt_, "gen_TrueNumInt/F"); + + hepmcev_token_ = collector.consumes(conf.getParameter("MCEvent")); + + simTracks_token_ = collector.consumes>(conf.getParameter("SimTracks")); + simVertices_token_ = collector.consumes>(conf.getParameter("SimVertices")); + + tree.Branch("vtx_x", &vtx_x_); + tree.Branch("vtx_y", &vtx_y_); + tree.Branch("vtx_z", &vtx_z_); + + tree.Branch("gen_eta", &gen_eta_); + tree.Branch("gen_phi", &gen_phi_); + tree.Branch("gen_pt", &gen_pt_); + tree.Branch("gen_energy", &gen_energy_); + tree.Branch("gen_charge", &gen_charge_); + tree.Branch("gen_pdgid", &gen_pdgid_); + tree.Branch("gen_status", &gen_status_); + tree.Branch("gen_daughters", &gen_daughters_); + + tree.Branch("genpart_eta", &genpart_eta_); + tree.Branch("genpart_phi", &genpart_phi_); + tree.Branch("genpart_pt", &genpart_pt_); + tree.Branch("genpart_energy", &genpart_energy_); + tree.Branch("genpart_dvx", &genpart_dvx_); + tree.Branch("genpart_dvy", &genpart_dvy_); + tree.Branch("genpart_dvz", &genpart_dvz_); + tree.Branch("genpart_ovx", &genpart_ovx_); + tree.Branch("genpart_ovy", &genpart_ovy_); + tree.Branch("genpart_ovz", &genpart_ovz_); + tree.Branch("genpart_mother", &genpart_mother_); + tree.Branch("genpart_exphi", &genpart_exphi_); + tree.Branch("genpart_exeta", &genpart_exeta_); + tree.Branch("genpart_exx", &genpart_exx_); + tree.Branch("genpart_exy", &genpart_exy_); + tree.Branch("genpart_fbrem", &genpart_fbrem_); + tree.Branch("genpart_pid", &genpart_pid_); + tree.Branch("genpart_gen", &genpart_gen_); + tree.Branch("genpart_reachedEE", &genpart_reachedEE_); + tree.Branch("genpart_fromBeamPipe", &genpart_fromBeamPipe_); + tree.Branch("genpart_posx", &genpart_posx_); + tree.Branch("genpart_posy", &genpart_posy_); + tree.Branch("genpart_posz", &genpart_posz_); } +void HGCalTriggerNtupleGen::fill(const edm::Event &iEvent, const edm::EventSetup &es) { + clear(); -void -HGCalTriggerNtupleGen:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - - edm::ParameterSet particleFilter_(conf.getParameter("particleFilter")); - mySimEvent_ = std::make_unique(particleFilter_); - - gen_token_ = collector.consumes(conf.getParameter("GenParticles")); - gen_PU_token_ = collector.consumes>(conf.getParameter("GenPU")); - tree.Branch("gen_n", &gen_n_, "gen_n/I"); - tree.Branch("gen_PUNumInt", &gen_PUNumInt_ ,"gen_PUNumInt/I"); - tree.Branch("gen_TrueNumInt", &gen_TrueNumInt_ ,"gen_TrueNumInt/F"); - - hepmcev_token_ = collector.consumes(conf.getParameter("MCEvent")); - - simTracks_token_ = collector.consumes>(conf.getParameter("SimTracks")); - simVertices_token_ = collector.consumes>(conf.getParameter("SimVertices")); - - tree.Branch("vtx_x", &vtx_x_); - tree.Branch("vtx_y", &vtx_y_); - tree.Branch("vtx_z", &vtx_z_); - - - tree.Branch("gen_eta", &gen_eta_); - tree.Branch("gen_phi", &gen_phi_); - tree.Branch("gen_pt", &gen_pt_); - tree.Branch("gen_energy", &gen_energy_); - tree.Branch("gen_charge", &gen_charge_); - tree.Branch("gen_pdgid", &gen_pdgid_); - tree.Branch("gen_status", &gen_status_); - tree.Branch("gen_daughters", &gen_daughters_); - - tree.Branch("genpart_eta", &genpart_eta_); - tree.Branch("genpart_phi", &genpart_phi_); - tree.Branch("genpart_pt", &genpart_pt_); - tree.Branch("genpart_energy", &genpart_energy_); - tree.Branch("genpart_dvx", &genpart_dvx_); - tree.Branch("genpart_dvy", &genpart_dvy_); - tree.Branch("genpart_dvz", &genpart_dvz_); - tree.Branch("genpart_ovx", &genpart_ovx_); - tree.Branch("genpart_ovy", &genpart_ovy_); - tree.Branch("genpart_ovz", &genpart_ovz_); - tree.Branch("genpart_mother", &genpart_mother_); - tree.Branch("genpart_exphi", &genpart_exphi_); - tree.Branch("genpart_exeta", &genpart_exeta_); - tree.Branch("genpart_exx", &genpart_exx_); - tree.Branch("genpart_exy", &genpart_exy_); - tree.Branch("genpart_fbrem", &genpart_fbrem_); - tree.Branch("genpart_pid", &genpart_pid_); - tree.Branch("genpart_gen", &genpart_gen_); - tree.Branch("genpart_reachedEE", &genpart_reachedEE_); - tree.Branch("genpart_fromBeamPipe", &genpart_fromBeamPipe_); - tree.Branch("genpart_posx", &genpart_posx_); - tree.Branch("genpart_posy", &genpart_posy_); - tree.Branch("genpart_posz", &genpart_posz_); - - -} - -void -HGCalTriggerNtupleGen:: -fill(const edm::Event& iEvent, const edm::EventSetup& es) -{ - clear(); + edm::Handle> PupInfo_h; + iEvent.getByToken(gen_PU_token_, PupInfo_h); + const std::vector &PupInfo = *PupInfo_h; - edm::Handle > PupInfo_h; - iEvent.getByToken(gen_PU_token_, PupInfo_h); - const std::vector< PileupSummaryInfo >& PupInfo = *PupInfo_h; + if (pdt_watcher_.check(es)) { + edm::ESHandle pdt; + es.get().get(pdt); + mySimEvent_->initializePdt(&(*pdt)); + } - if(pdt_watcher_.check(es)) - { - edm::ESHandle pdt; - es.get().get(pdt); - mySimEvent_->initializePdt(&(*pdt)); - } + if (magfield_watcher_.check(es)) { + edm::ESHandle magfield; + es.get().get(magfield); + aField_ = &(*magfield); + } - if(magfield_watcher_.check(es)) + triggerTools_.eventSetup(es); + + // This balck magic is needed to use the mySimEvent_ + edm::Handle hevH; + edm::Handle> simTracksHandle; + edm::Handle> simVerticesHandle; + + iEvent.getByToken(hepmcev_token_, hevH); + iEvent.getByToken(simTracks_token_, simTracksHandle); + iEvent.getByToken(simVertices_token_, simVerticesHandle); + mySimEvent_->fill(*simTracksHandle, *simVerticesHandle); + + HepMC::GenVertex *primaryVertex = *(hevH)->GetEvent()->vertices_begin(); + const float mm2cm = 0.1; + vtx_x_ = primaryVertex->position().x() * mm2cm; // to put in official units + vtx_y_ = primaryVertex->position().y() * mm2cm; + vtx_z_ = primaryVertex->position().z() * mm2cm; + + HGCal_helpers::SimpleTrackPropagator toHGCalPropagator(aField_); + toHGCalPropagator.setPropagationTargetZ(triggerTools_.getLayerZ(1)); + std::vector allselectedgentracks; + const float eeInnerRadius = 25.; + const float eeOuterRadius = 160.; + unsigned int npart = mySimEvent_->nTracks(); + for (unsigned int i = 0; i < npart; ++i) { + std::vector xp, yp, zp; + FSimTrack &myTrack(mySimEvent_->track(i)); + math::XYZTLorentzVectorD vtx(0, 0, 0, 0); + + int reachedEE = ReachHGCal::notReach; // compute the extrapolations for the particles reaching EE + // and for the gen particles + double fbrem = -1; + + if (std::abs(myTrack.vertex().position().z()) >= triggerTools_.getLayerZ(1)) + continue; + + const unsigned nlayers = triggerTools_.lastLayerBH(); + if (myTrack.noEndVertex()) // || myTrack.genpartIndex()>=0) { - edm::ESHandle magfield; - es.get().get(magfield); - aField_ = &(*magfield); - } - - triggerTools_.eventSetup(es); - - // This balck magic is needed to use the mySimEvent_ - edm::Handle hevH; - edm::Handle> simTracksHandle; - edm::Handle> simVerticesHandle; - - iEvent.getByToken(hepmcev_token_, hevH); - iEvent.getByToken(simTracks_token_, simTracksHandle); - iEvent.getByToken(simVertices_token_, simVerticesHandle); - mySimEvent_->fill(*simTracksHandle, *simVerticesHandle); - - HepMC::GenVertex *primaryVertex = *(hevH)->GetEvent()->vertices_begin(); - const float mm2cm = 0.1; - vtx_x_ = primaryVertex->position().x() * mm2cm; // to put in official units - vtx_y_ = primaryVertex->position().y() * mm2cm; - vtx_z_ = primaryVertex->position().z() * mm2cm; - - - HGCal_helpers::SimpleTrackPropagator toHGCalPropagator(aField_); - toHGCalPropagator.setPropagationTargetZ(triggerTools_.getLayerZ(1)); - std::vector allselectedgentracks; - const float eeInnerRadius = 25.; - const float eeOuterRadius = 160.; - unsigned int npart = mySimEvent_->nTracks(); - for (unsigned int i = 0; i < npart; ++i) { - std::vector xp, yp, zp; - FSimTrack &myTrack(mySimEvent_->track(i)); - math::XYZTLorentzVectorD vtx(0, 0, 0, 0); - - int reachedEE = ReachHGCal::notReach; // compute the extrapolations for the particles reaching EE - // and for the gen particles - double fbrem = -1; - - if (std::abs(myTrack.vertex().position().z()) >= triggerTools_.getLayerZ(1)) continue; - - const unsigned nlayers = triggerTools_.lastLayerBH(); - if (myTrack.noEndVertex()) // || myTrack.genpartIndex()>=0) - { - HGCal_helpers::Coordinates propcoords; - bool reachesHGCal = toHGCalPropagator.propagate( - myTrack.momentum(), myTrack.vertex().position(), myTrack.charge(), propcoords); - vtx = propcoords.toVector(); - - if (reachesHGCal && vtx.Rho() < eeOuterRadius && vtx.Rho() > eeInnerRadius) { - reachedEE = ReachHGCal::onEESurface; - double dpt = 0; - - for (int i = 0; i < myTrack.nDaughters(); ++i) dpt += myTrack.daughter(i).momentum().pt(); - if (abs(myTrack.type()) == 11) fbrem = dpt / myTrack.momentum().pt(); - } else if (reachesHGCal && vtx.Rho() > eeOuterRadius) - reachedEE = ReachHGCal::outsideEESurface; - - HGCal_helpers::SimpleTrackPropagator indiv_particleProp(aField_); - for (unsigned il = 1; il <= nlayers; ++il) { - const float charge = myTrack.charge(); - indiv_particleProp.setPropagationTargetZ(triggerTools_.getLayerZ(il)); - HGCal_helpers::Coordinates propCoords; - indiv_particleProp.propagate(myTrack.momentum(), myTrack.vertex().position(), charge, - propCoords); - - xp.push_back(propCoords.x); - yp.push_back(propCoords.y); - zp.push_back(propCoords.z); - } - } else { - vtx = myTrack.endVertex().position(); + HGCal_helpers::Coordinates propcoords; + bool reachesHGCal = + toHGCalPropagator.propagate(myTrack.momentum(), myTrack.vertex().position(), myTrack.charge(), propcoords); + vtx = propcoords.toVector(); + + if (reachesHGCal && vtx.Rho() < eeOuterRadius && vtx.Rho() > eeInnerRadius) { + reachedEE = ReachHGCal::onEESurface; + double dpt = 0; + + for (int i = 0; i < myTrack.nDaughters(); ++i) + dpt += myTrack.daughter(i).momentum().pt(); + if (abs(myTrack.type()) == 11) + fbrem = dpt / myTrack.momentum().pt(); + } else if (reachesHGCal && vtx.Rho() > eeOuterRadius) + reachedEE = ReachHGCal::outsideEESurface; + + HGCal_helpers::SimpleTrackPropagator indiv_particleProp(aField_); + for (unsigned il = 1; il <= nlayers; ++il) { + const float charge = myTrack.charge(); + indiv_particleProp.setPropagationTargetZ(triggerTools_.getLayerZ(il)); + HGCal_helpers::Coordinates propCoords; + indiv_particleProp.propagate(myTrack.momentum(), myTrack.vertex().position(), charge, propCoords); + + xp.push_back(propCoords.x); + yp.push_back(propCoords.y); + zp.push_back(propCoords.z); } - auto orig_vtx = myTrack.vertex().position(); - - allselectedgentracks.push_back(&mySimEvent_->track(i)); - // fill branches - genpart_eta_.push_back(myTrack.momentum().eta()); - genpart_phi_.push_back(myTrack.momentum().phi()); - genpart_pt_.push_back(myTrack.momentum().pt()); - genpart_energy_.push_back(myTrack.momentum().energy()); - genpart_dvx_.push_back(vtx.x()); - genpart_dvy_.push_back(vtx.y()); - genpart_dvz_.push_back(vtx.z()); - - genpart_ovx_.push_back(orig_vtx.x()); - genpart_ovy_.push_back(orig_vtx.y()); - genpart_ovz_.push_back(orig_vtx.z()); - - HGCal_helpers::Coordinates hitsHGCal; - toHGCalPropagator.propagate(myTrack.momentum(), orig_vtx, myTrack.charge(), hitsHGCal); - - genpart_exphi_.push_back(hitsHGCal.phi); - genpart_exeta_.push_back(hitsHGCal.eta); - genpart_exx_.push_back(hitsHGCal.x); - genpart_exy_.push_back(hitsHGCal.y); - - genpart_fbrem_.push_back(fbrem); - genpart_pid_.push_back(myTrack.type()); - genpart_gen_.push_back(myTrack.genpartIndex()); - genpart_reachedEE_.push_back(reachedEE); - genpart_fromBeamPipe_.push_back(true); - - genpart_posx_.push_back(xp); - genpart_posy_.push_back(yp); - genpart_posz_.push_back(zp); + } else { + vtx = myTrack.endVertex().position(); } + auto orig_vtx = myTrack.vertex().position(); + + allselectedgentracks.push_back(&mySimEvent_->track(i)); + // fill branches + genpart_eta_.push_back(myTrack.momentum().eta()); + genpart_phi_.push_back(myTrack.momentum().phi()); + genpart_pt_.push_back(myTrack.momentum().pt()); + genpart_energy_.push_back(myTrack.momentum().energy()); + genpart_dvx_.push_back(vtx.x()); + genpart_dvy_.push_back(vtx.y()); + genpart_dvz_.push_back(vtx.z()); + + genpart_ovx_.push_back(orig_vtx.x()); + genpart_ovy_.push_back(orig_vtx.y()); + genpart_ovz_.push_back(orig_vtx.z()); + + HGCal_helpers::Coordinates hitsHGCal; + toHGCalPropagator.propagate(myTrack.momentum(), orig_vtx, myTrack.charge(), hitsHGCal); + + genpart_exphi_.push_back(hitsHGCal.phi); + genpart_exeta_.push_back(hitsHGCal.eta); + genpart_exx_.push_back(hitsHGCal.x); + genpart_exy_.push_back(hitsHGCal.y); + + genpart_fbrem_.push_back(fbrem); + genpart_pid_.push_back(myTrack.type()); + genpart_gen_.push_back(myTrack.genpartIndex()); + genpart_reachedEE_.push_back(reachedEE); + genpart_fromBeamPipe_.push_back(true); + + genpart_posx_.push_back(xp); + genpart_posy_.push_back(yp); + genpart_posz_.push_back(zp); + } - - edm::Handle> genParticlesHandle; - iEvent.getByToken(gen_token_, genParticlesHandle); - gen_n_ = genParticlesHandle->size(); - - for (const auto& particle : *genParticlesHandle) { - gen_eta_.push_back(particle.eta()); - gen_phi_.push_back(particle.phi()); - gen_pt_.push_back(particle.pt()); - gen_energy_.push_back(particle.energy()); - gen_charge_.push_back(particle.charge()); - gen_pdgid_.push_back(particle.pdgId()); - gen_status_.push_back(particle.status()); - std::vector daughters(particle.daughterRefVector().size(), 0); - for (unsigned j = 0; j < particle.daughterRefVector().size(); ++j) { - daughters[j] = static_cast(particle.daughterRefVector().at(j).key()); - } - gen_daughters_.push_back(daughters); + edm::Handle> genParticlesHandle; + iEvent.getByToken(gen_token_, genParticlesHandle); + gen_n_ = genParticlesHandle->size(); + + for (const auto &particle : *genParticlesHandle) { + gen_eta_.push_back(particle.eta()); + gen_phi_.push_back(particle.phi()); + gen_pt_.push_back(particle.pt()); + gen_energy_.push_back(particle.energy()); + gen_charge_.push_back(particle.charge()); + gen_pdgid_.push_back(particle.pdgId()); + gen_status_.push_back(particle.status()); + std::vector daughters(particle.daughterRefVector().size(), 0); + for (unsigned j = 0; j < particle.daughterRefVector().size(); ++j) { + daughters[j] = static_cast(particle.daughterRefVector().at(j).key()); } + gen_daughters_.push_back(daughters); + } + // associate gen particles to mothers + genpart_mother_.resize(genpart_posz_.size(), -1); + for (size_t i = 0; i < allselectedgentracks.size(); i++) { + const auto tracki = allselectedgentracks.at(i); - // associate gen particles to mothers - genpart_mother_.resize(genpart_posz_.size(), -1); - for (size_t i = 0; i < allselectedgentracks.size(); i++) { - const auto tracki = allselectedgentracks.at(i); - - for (size_t j = i + 1; j < allselectedgentracks.size(); j++) { - const auto trackj = allselectedgentracks.at(j); + for (size_t j = i + 1; j < allselectedgentracks.size(); j++) { + const auto trackj = allselectedgentracks.at(j); - if (!tracki->noMother()) { - if (&tracki->mother() == trackj) genpart_mother_.at(i) = j; - } - if (!trackj->noMother()) { - if (&trackj->mother() == tracki) genpart_mother_.at(j) = i; - } + if (!tracki->noMother()) { + if (&tracki->mother() == trackj) + genpart_mother_.at(i) = j; + } + if (!trackj->noMother()) { + if (&trackj->mother() == tracki) + genpart_mother_.at(j) = i; } } + } - for(const auto& PVI : PupInfo) - { - if(PVI.getBunchCrossing() == 0) - { - gen_PUNumInt_ = PVI.getPU_NumInteractions(); - gen_TrueNumInt_ = PVI.getTrueNumInteractions(); - } + for (const auto &PVI : PupInfo) { + if (PVI.getBunchCrossing() == 0) { + gen_PUNumInt_ = PVI.getPU_NumInteractions(); + gen_TrueNumInt_ = PVI.getTrueNumInteractions(); } - + } } - -void -HGCalTriggerNtupleGen:: -clear() -{ - - gen_n_ = 0; - gen_PUNumInt_ = 0; - gen_TrueNumInt_ = 0.; - - vtx_x_ = 0; - vtx_y_ = 0; - vtx_z_ = 0; - - - // - genpart_eta_.clear(); - genpart_phi_.clear(); - genpart_pt_.clear(); - genpart_energy_.clear(); - genpart_dvx_.clear(); - genpart_dvy_.clear(); - genpart_dvz_.clear(); - genpart_ovx_.clear(); - genpart_ovy_.clear(); - genpart_ovz_.clear(); - genpart_exx_.clear(); - genpart_exy_.clear(); - genpart_mother_.clear(); - genpart_exphi_.clear(); - genpart_exeta_.clear(); - genpart_fbrem_.clear(); - genpart_pid_.clear(); - genpart_gen_.clear(); - genpart_reachedEE_.clear(); - genpart_fromBeamPipe_.clear(); - genpart_posx_.clear(); - genpart_posy_.clear(); - genpart_posz_.clear(); - - //////////////////// - // reco::GenParticles - // - gen_eta_.clear(); - gen_phi_.clear(); - gen_pt_.clear(); - gen_energy_.clear(); - gen_charge_.clear(); - gen_pdgid_.clear(); - gen_status_.clear(); - gen_daughters_.clear(); +void HGCalTriggerNtupleGen::clear() { + gen_n_ = 0; + gen_PUNumInt_ = 0; + gen_TrueNumInt_ = 0.; + + vtx_x_ = 0; + vtx_y_ = 0; + vtx_z_ = 0; + + // + genpart_eta_.clear(); + genpart_phi_.clear(); + genpart_pt_.clear(); + genpart_energy_.clear(); + genpart_dvx_.clear(); + genpart_dvy_.clear(); + genpart_dvz_.clear(); + genpart_ovx_.clear(); + genpart_ovy_.clear(); + genpart_ovz_.clear(); + genpart_exx_.clear(); + genpart_exy_.clear(); + genpart_mother_.clear(); + genpart_exphi_.clear(); + genpart_exeta_.clear(); + genpart_fbrem_.clear(); + genpart_pid_.clear(); + genpart_gen_.clear(); + genpart_reachedEE_.clear(); + genpart_fromBeamPipe_.clear(); + genpart_posx_.clear(); + genpart_posy_.clear(); + genpart_posz_.clear(); + + //////////////////// + // reco::GenParticles + // + gen_eta_.clear(); + gen_phi_.clear(); + gen_pt_.clear(); + gen_energy_.clear(); + gen_charge_.clear(); + gen_pdgid_.clear(); + gen_status_.clear(); + gen_daughters_.clear(); } diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc index 3a2915caae244..260a21925f260 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenJet.cc @@ -4,90 +4,63 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" +class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleGenJet(const edm::ParameterSet&); + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event&, const edm::EventSetup&) final; -class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase -{ +private: + void clear() final; - public: - HGCalTriggerNtupleGenJet(const edm::ParameterSet& ); - - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup& ) final; - - private: - void clear() final; - - edm::EDGetToken genjet_token_; - - int genjet_n_; - std::vector genjet_energy_; - std::vector genjet_pt_; - std::vector genjet_eta_; - std::vector genjet_phi_; + edm::EDGetToken genjet_token_; + int genjet_n_; + std::vector genjet_energy_; + std::vector genjet_pt_; + std::vector genjet_eta_; + std::vector genjet_phi_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleGenJet, - "HGCalTriggerNtupleGenJet" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenJet, "HGCalTriggerNtupleGenJet"); +HGCalTriggerNtupleGenJet::HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} -HGCalTriggerNtupleGenJet:: -HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ +void HGCalTriggerNtupleGenJet::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + genjet_token_ = collector.consumes(conf.getParameter("GenJets")); + tree.Branch("genjet_n", &genjet_n_, "genjet_n/I"); + tree.Branch("genjet_energy", &genjet_energy_); + tree.Branch("genjet_pt", &genjet_pt_); + tree.Branch("genjet_eta", &genjet_eta_); + tree.Branch("genjet_phi", &genjet_phi_); } -void -HGCalTriggerNtupleGenJet:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - - genjet_token_ = collector.consumes(conf.getParameter("GenJets")); - tree.Branch("genjet_n", &genjet_n_, "genjet_n/I"); - tree.Branch("genjet_energy", &genjet_energy_); - tree.Branch("genjet_pt", &genjet_pt_); - tree.Branch("genjet_eta", &genjet_eta_); - tree.Branch("genjet_phi", &genjet_phi_); - +void HGCalTriggerNtupleGenJet::fill(const edm::Event& e, const edm::EventSetup& es) { + edm::Handle genjets_h; + e.getByToken(genjet_token_, genjets_h); + const reco::GenJetCollection& genjets = *genjets_h; + + clear(); + genjet_n_ = genjets.size(); + genjet_energy_.reserve(genjet_n_); + genjet_pt_.reserve(genjet_n_); + genjet_eta_.reserve(genjet_n_); + genjet_phi_.reserve(genjet_n_); + for (const auto& jet : genjets) { + genjet_energy_.emplace_back(jet.energy()); + genjet_pt_.emplace_back(jet.pt()); + genjet_eta_.emplace_back(jet.eta()); + genjet_phi_.emplace_back(jet.phi()); + } } -void -HGCalTriggerNtupleGenJet:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - edm::Handle< reco::GenJetCollection > genjets_h; - e.getByToken(genjet_token_, genjets_h); - const reco::GenJetCollection& genjets = *genjets_h; - - clear(); - genjet_n_ = genjets.size(); - genjet_energy_.reserve(genjet_n_); - genjet_pt_.reserve(genjet_n_); - genjet_eta_.reserve(genjet_n_); - genjet_phi_.reserve(genjet_n_); - for(const auto& jet : genjets) - { - genjet_energy_.emplace_back(jet.energy()); - genjet_pt_.emplace_back(jet.pt()); - genjet_eta_.emplace_back(jet.eta()); - genjet_phi_.emplace_back(jet.phi()); - } - +void HGCalTriggerNtupleGenJet::clear() { + genjet_n_ = 0; + genjet_energy_.clear(); + genjet_pt_.clear(); + genjet_eta_.clear(); + genjet_phi_.clear(); } - - -void -HGCalTriggerNtupleGenJet:: -clear() -{ - genjet_n_ = 0; - genjet_energy_.clear(); - genjet_pt_.clear(); - genjet_eta_.clear(); - genjet_phi_.clear(); -} - - - - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc index 927f0019f4d23..18c3ce09ab380 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGenTau.cc @@ -6,358 +6,325 @@ typedef math::XYZTLorentzVector LorentzVector; -class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleGenTau(const edm::ParameterSet& ); - - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event&, const edm::EventSetup& ) final; - - private: - void clear() final; - - bool isGoodTau( const reco::GenParticle& candidate ) const; - bool isStableLepton( const reco::GenParticle & daughter ) const; - bool isElectron( const reco::GenParticle & daughter ) const; - bool isMuon( const reco::GenParticle & daughter ) const; - bool isChargedHadron( const reco::GenParticle & daughter ) const; - bool isChargedHadronFromResonance( const reco::GenParticle & daughter ) const; - bool isNeutralPion( const reco::GenParticle & daughter ) const; - bool isNeutralPionFromResonance( const reco::GenParticle & daughter ) const; - bool isIntermediateResonance( const reco::GenParticle & daughter ) const; - bool isGamma( const reco::GenParticle & daughter ) const; - bool isStableNeutralHadron( const reco::GenParticle & daughter ) const; - - edm::EDGetToken gen_token_; - bool isPythia8generator_; - - std::vector gentau_pt_; - std::vector gentau_eta_; - std::vector gentau_phi_; - std::vector gentau_energy_; - std::vector gentau_mass_; - - std::vector gentau_vis_pt_; - std::vector gentau_vis_eta_; - std::vector gentau_vis_phi_; - std::vector gentau_vis_energy_; - std::vector gentau_vis_mass_; - std::vector gentau_decayMode_; - std::vector gentau_totNproducts_; - std::vector gentau_totNgamma_; - std::vector gentau_totNpiZero_; - std::vector gentau_totNcharged_; - - std::vector > gentau_products_pt_; - std::vector > gentau_products_eta_; - std::vector > gentau_products_phi_; - std::vector > gentau_products_energy_; - std::vector > gentau_products_mass_; - std::vector > gentau_products_id_; - +class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleGenTau(const edm::ParameterSet&); + + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event&, const edm::EventSetup&) final; + +private: + void clear() final; + + bool isGoodTau(const reco::GenParticle& candidate) const; + bool isStableLepton(const reco::GenParticle& daughter) const; + bool isElectron(const reco::GenParticle& daughter) const; + bool isMuon(const reco::GenParticle& daughter) const; + bool isChargedHadron(const reco::GenParticle& daughter) const; + bool isChargedHadronFromResonance(const reco::GenParticle& daughter) const; + bool isNeutralPion(const reco::GenParticle& daughter) const; + bool isNeutralPionFromResonance(const reco::GenParticle& daughter) const; + bool isIntermediateResonance(const reco::GenParticle& daughter) const; + bool isGamma(const reco::GenParticle& daughter) const; + bool isStableNeutralHadron(const reco::GenParticle& daughter) const; + + edm::EDGetToken gen_token_; + bool isPythia8generator_; + + std::vector gentau_pt_; + std::vector gentau_eta_; + std::vector gentau_phi_; + std::vector gentau_energy_; + std::vector gentau_mass_; + + std::vector gentau_vis_pt_; + std::vector gentau_vis_eta_; + std::vector gentau_vis_phi_; + std::vector gentau_vis_energy_; + std::vector gentau_vis_mass_; + std::vector gentau_decayMode_; + std::vector gentau_totNproducts_; + std::vector gentau_totNgamma_; + std::vector gentau_totNpiZero_; + std::vector gentau_totNcharged_; + + std::vector > gentau_products_pt_; + std::vector > gentau_products_eta_; + std::vector > gentau_products_phi_; + std::vector > gentau_products_energy_; + std::vector > gentau_products_mass_; + std::vector > gentau_products_id_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleGenTau, - "HGCalTriggerNtupleGenTau" ); - - -HGCalTriggerNtupleGenTau:: -HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleGenTau, "HGCalTriggerNtupleGenTau"); + +HGCalTriggerNtupleGenTau::HGCalTriggerNtupleGenTau(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {} + +void HGCalTriggerNtupleGenTau::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + gen_token_ = collector.consumes(conf.getParameter("GenParticles")); + isPythia8generator_ = conf.getParameter("isPythia8"); + + tree.Branch("gentau_pt", &gentau_pt_); + tree.Branch("gentau_eta", &gentau_eta_); + tree.Branch("gentau_phi", &gentau_phi_); + tree.Branch("gentau_energy", &gentau_energy_); + tree.Branch("gentau_mass", &gentau_mass_); + tree.Branch("gentau_vis_pt", &gentau_vis_pt_); + tree.Branch("gentau_vis_eta", &gentau_vis_eta_); + tree.Branch("gentau_vis_phi", &gentau_vis_phi_); + tree.Branch("gentau_vis_energy", &gentau_vis_energy_); + tree.Branch("gentau_vis_mass", &gentau_vis_mass_); + tree.Branch("gentau_products_pt", &gentau_products_pt_); + tree.Branch("gentau_products_eta", &gentau_products_eta_); + tree.Branch("gentau_products_phi", &gentau_products_phi_); + tree.Branch("gentau_products_energy", &gentau_products_energy_); + tree.Branch("gentau_products_mass", &gentau_products_mass_); + tree.Branch("gentau_products_id", &gentau_products_id_); + tree.Branch("gentau_decayMode", &gentau_decayMode_); + tree.Branch("gentau_totNproducts", &gentau_totNproducts_); + tree.Branch("gentau_totNgamma", &gentau_totNgamma_); + tree.Branch("gentau_totNpiZero", &gentau_totNpiZero_); + tree.Branch("gentau_totNcharged", &gentau_totNcharged_); } -void -HGCalTriggerNtupleGenTau:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - - gen_token_ = collector.consumes(conf.getParameter("GenParticles")); - isPythia8generator_ = conf.getParameter("isPythia8"); - - tree.Branch("gentau_pt", &gentau_pt_); - tree.Branch("gentau_eta", &gentau_eta_); - tree.Branch("gentau_phi", &gentau_phi_); - tree.Branch("gentau_energy", &gentau_energy_); - tree.Branch("gentau_mass", &gentau_mass_); - tree.Branch("gentau_vis_pt", &gentau_vis_pt_); - tree.Branch("gentau_vis_eta", &gentau_vis_eta_); - tree.Branch("gentau_vis_phi", &gentau_vis_phi_); - tree.Branch("gentau_vis_energy", &gentau_vis_energy_); - tree.Branch("gentau_vis_mass", &gentau_vis_mass_); - tree.Branch("gentau_products_pt", &gentau_products_pt_); - tree.Branch("gentau_products_eta", &gentau_products_eta_); - tree.Branch("gentau_products_phi", &gentau_products_phi_); - tree.Branch("gentau_products_energy", &gentau_products_energy_); - tree.Branch("gentau_products_mass", &gentau_products_mass_); - tree.Branch("gentau_products_id", &gentau_products_id_); - tree.Branch("gentau_decayMode", &gentau_decayMode_); - tree.Branch("gentau_totNproducts", &gentau_totNproducts_); - tree.Branch("gentau_totNgamma", &gentau_totNgamma_); - tree.Branch("gentau_totNpiZero", &gentau_totNpiZero_); - tree.Branch("gentau_totNcharged", &gentau_totNcharged_); - +bool HGCalTriggerNtupleGenTau::isGoodTau(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 15 && candidate.status() == 2); } -bool HGCalTriggerNtupleGenTau::isGoodTau( const reco::GenParticle& candidate ) const { - return ( std::abs( candidate.pdgId() ) == 15 && candidate.status() == 2 ); +bool HGCalTriggerNtupleGenTau::isChargedHadron(const reco::GenParticle& candidate) const { + return ((std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321) && candidate.status() == 1 && + candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy()); } - -bool HGCalTriggerNtupleGenTau::isChargedHadron( const reco::GenParticle& candidate ) const { - return ( (std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321 ) && candidate.status()==1 - && candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isChargedHadronFromResonance(const reco::GenParticle& candidate) const { + return ((std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321) && candidate.status() == 1 && + candidate.isLastCopy()); } -bool HGCalTriggerNtupleGenTau::isChargedHadronFromResonance( const reco::GenParticle& candidate ) const { - return ( (std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321 ) && candidate.status()==1 - && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isStableLepton(const reco::GenParticle& candidate) const { + return ((std::abs(candidate.pdgId()) == 11 || std::abs(candidate.pdgId()) == 13) && candidate.status() == 1 && + candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy()); } - -bool HGCalTriggerNtupleGenTau::isStableLepton( const reco::GenParticle& candidate ) const -{ - return ( (std::abs(candidate.pdgId()) == 11 || std::abs(candidate.pdgId()) == 13) && candidate.status()==1 - && candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isElectron(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 11 && candidate.isDirectPromptTauDecayProductFinalState() && + candidate.isLastCopy()); } - -bool HGCalTriggerNtupleGenTau::isElectron( const reco::GenParticle& candidate ) const -{ - return ( std::abs(candidate.pdgId()) == 11 && candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isMuon(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 13 && candidate.isDirectPromptTauDecayProductFinalState() && + candidate.isLastCopy()); } - -bool HGCalTriggerNtupleGenTau::isMuon( const reco::GenParticle& candidate ) const -{ - return ( std::abs(candidate.pdgId()) == 13 && candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isNeutralPion(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 111 && candidate.status() == 2 && + candidate.statusFlags().isTauDecayProduct() && !candidate.isDirectPromptTauDecayProductFinalState()); } - -bool HGCalTriggerNtupleGenTau::isNeutralPion( const reco::GenParticle& candidate ) const -{ - return ( std::abs(candidate.pdgId()) == 111 && candidate.status()==2 && candidate.statusFlags().isTauDecayProduct() - && !candidate.isDirectPromptTauDecayProductFinalState() ); +bool HGCalTriggerNtupleGenTau::isNeutralPionFromResonance(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 111 && candidate.status() == 2 && candidate.statusFlags().isTauDecayProduct()); } - -bool HGCalTriggerNtupleGenTau::isNeutralPionFromResonance( const reco::GenParticle& candidate ) const -{ - return ( std::abs(candidate.pdgId()) == 111 && candidate.status()==2 && candidate.statusFlags().isTauDecayProduct() ); +bool HGCalTriggerNtupleGenTau::isGamma(const reco::GenParticle& candidate) const { + return (std::abs(candidate.pdgId()) == 22 && candidate.status() == 1 && candidate.statusFlags().isTauDecayProduct() && + !candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy()); } - -bool HGCalTriggerNtupleGenTau::isGamma( const reco::GenParticle& candidate ) const -{ - return ( std::abs(candidate.pdgId()) == 22 && candidate.status()==1 && candidate.statusFlags().isTauDecayProduct() - && !candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() ); +bool HGCalTriggerNtupleGenTau::isIntermediateResonance(const reco::GenParticle& candidate) const { + return ((std::abs(candidate.pdgId()) == 213 || std::abs(candidate.pdgId()) == 20213 || + std::abs(candidate.pdgId()) == 24) && + candidate.status() == 2); } -bool HGCalTriggerNtupleGenTau::isIntermediateResonance( const reco::GenParticle& candidate ) const -{ - return ( ( std::abs(candidate.pdgId()) == 213 || std::abs(candidate.pdgId()) == 20213 || std::abs(candidate.pdgId()) == 24 ) - && candidate.status() == 2 ); +bool HGCalTriggerNtupleGenTau::isStableNeutralHadron(const reco::GenParticle& candidate) const { + return (!(std::abs(candidate.pdgId()) > 10 && std::abs(candidate.pdgId()) < 17) && !isChargedHadron(candidate) && + candidate.status() == 1); } +void HGCalTriggerNtupleGenTau::fill(const edm::Event& e, const edm::EventSetup& es) { + edm::Handle gen_particles_h; + e.getByToken(gen_token_, gen_particles_h); + const reco::GenParticleCollection& gen_particles = *gen_particles_h; + + clear(); + + for (const auto& particle : gen_particles) { + /* select good taus */ + if (isGoodTau(particle)) { + LorentzVector tau_p4vis(0., 0., 0., 0.); + gentau_pt_.emplace_back(particle.pt()); + gentau_eta_.emplace_back(particle.eta()); + gentau_phi_.emplace_back(particle.phi()); + gentau_energy_.emplace_back(particle.energy()); + gentau_mass_.emplace_back(particle.mass()); + + int n_pi = 0; + int n_piZero = 0; + int n_gamma = 0; + int n_ele = 0; + int n_mu = 0; + + std::vector tau_products_pt; + std::vector tau_products_eta; + std::vector tau_products_phi; + std::vector tau_products_energy; + std::vector tau_products_mass; + std::vector tau_products_id; + + /* loop over tau daughters */ + const reco::GenParticleRefVector& daughters = particle.daughterRefVector(); + + for (const auto& daughter : daughters) { + reco::GenParticleRefVector finalProds; + + if (isStableLepton(*daughter)) { + if (isElectron(*daughter)) { + n_ele++; + } else if (isMuon(*daughter)) { + n_mu++; + } + tau_p4vis += (daughter->p4()); + finalProds.push_back(daughter); + } -bool HGCalTriggerNtupleGenTau::isStableNeutralHadron( const reco::GenParticle& candidate ) const -{ - return ( !( std::abs(candidate.pdgId())>10 && std::abs(candidate.pdgId())<17) && !isChargedHadron(candidate) - && candidate.status() == 1 ); -} - - -void -HGCalTriggerNtupleGenTau:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - edm::Handle gen_particles_h; - e.getByToken(gen_token_, gen_particles_h); - const reco::GenParticleCollection& gen_particles = *gen_particles_h; - - clear(); - - for(const auto& particle : gen_particles) - { - /* select good taus */ - if( isGoodTau( particle ) ){ - LorentzVector tau_p4vis(0.,0.,0.,0.); - gentau_pt_.emplace_back( particle.pt() ); - gentau_eta_.emplace_back( particle.eta() ); - gentau_phi_.emplace_back( particle.phi() ); - gentau_energy_.emplace_back( particle.energy() ); - gentau_mass_.emplace_back( particle.mass() ); - - int n_pi=0; - int n_piZero=0; - int n_gamma=0; - int n_ele=0; - int n_mu=0; - - std::vector tau_products_pt; - std::vector tau_products_eta; - std::vector tau_products_phi; - std::vector tau_products_energy; - std::vector tau_products_mass; - std::vector< int > tau_products_id; - - /* loop over tau daughters */ - const reco::GenParticleRefVector& daughters = particle.daughterRefVector(); - - for( const auto& daughter : daughters ){ - - reco::GenParticleRefVector finalProds; - - if( isStableLepton( *daughter ) ){ - if( isElectron( *daughter ) ){ - n_ele++; - } - else if( isMuon( *daughter ) ){ - n_mu++; - } - tau_p4vis+=(daughter->p4()); - finalProds.push_back( daughter ); - } - - else if( isChargedHadron( *daughter ) ){ - n_pi++; - tau_p4vis+=(daughter->p4()); - finalProds.push_back( daughter ); - } - - else if( isNeutralPion( *daughter ) ){ - n_piZero++; - const reco::GenParticleRefVector& granddaughters = daughter->daughterRefVector(); - for( const auto& granddaughter : granddaughters ){ - if( isGamma( *granddaughter ) ){ - n_gamma++; - tau_p4vis+=(granddaughter->p4()); - finalProds.push_back( granddaughter ); - } - } - } - - else if( isStableNeutralHadron( *daughter ) ){ - tau_p4vis+=(daughter->p4()); - finalProds.push_back( daughter ); - } - - else{ + else if (isChargedHadron(*daughter)) { + n_pi++; + tau_p4vis += (daughter->p4()); + finalProds.push_back(daughter); + } - const reco::GenParticleRefVector& granddaughters = daughter->daughterRefVector(); + else if (isNeutralPion(*daughter)) { + n_piZero++; + const reco::GenParticleRefVector& granddaughters = daughter->daughterRefVector(); + for (const auto& granddaughter : granddaughters) { + if (isGamma(*granddaughter)) { + n_gamma++; + tau_p4vis += (granddaughter->p4()); + finalProds.push_back(granddaughter); + } + } + } - for( const auto& granddaughter : granddaughters ){ - if( isStableNeutralHadron( *granddaughter ) ){ - tau_p4vis+=(granddaughter->p4()); - finalProds.push_back( granddaughter ); - } - } + else if (isStableNeutralHadron(*daughter)) { + tau_p4vis += (daughter->p4()); + finalProds.push_back(daughter); + } - } + else { + const reco::GenParticleRefVector& granddaughters = daughter->daughterRefVector(); - /* Here the selection of the decay product according to the Pythia6 decayTree */ - if( !isPythia8generator_ ){ - if( isIntermediateResonance( *daughter ) ){ - const reco::GenParticleRefVector& grandaughters = daughter->daughterRefVector(); - for( const auto& grandaughter : grandaughters ){ - if( isChargedHadron( *grandaughter ) || isChargedHadronFromResonance( *grandaughter ) ){ - n_pi++; - tau_p4vis+=(grandaughter->p4()); - finalProds.push_back( daughter ); - } - else if( isNeutralPion( *grandaughter ) || isNeutralPionFromResonance( *grandaughter ) ){ - n_piZero++; - const reco::GenParticleRefVector& descendants = grandaughter->daughterRefVector(); - for( const auto& descendant : descendants ){ - if( isGamma( *descendant ) ){ - n_gamma++; - tau_p4vis+=(descendant->p4()); - finalProds.push_back( daughter ); - } - } - } - } - } - } + for (const auto& granddaughter : granddaughters) { + if (isStableNeutralHadron(*granddaughter)) { + tau_p4vis += (granddaughter->p4()); + finalProds.push_back(granddaughter); + } + } + } - /* Fill daughter informations */ - for( const auto& prod : finalProds ){ - tau_products_pt.emplace_back( prod->pt() ); - tau_products_eta.emplace_back( prod->eta() ); - tau_products_phi.emplace_back( prod->phi() ); - tau_products_energy.emplace_back( prod->energy() ); - tau_products_mass.emplace_back( prod->mass() ); - tau_products_id.emplace_back( prod->pdgId() ); + /* Here the selection of the decay product according to the Pythia6 decayTree */ + if (!isPythia8generator_) { + if (isIntermediateResonance(*daughter)) { + const reco::GenParticleRefVector& grandaughters = daughter->daughterRefVector(); + for (const auto& grandaughter : grandaughters) { + if (isChargedHadron(*grandaughter) || isChargedHadronFromResonance(*grandaughter)) { + n_pi++; + tau_p4vis += (grandaughter->p4()); + finalProds.push_back(daughter); + } else if (isNeutralPion(*grandaughter) || isNeutralPionFromResonance(*grandaughter)) { + n_piZero++; + const reco::GenParticleRefVector& descendants = grandaughter->daughterRefVector(); + for (const auto& descendant : descendants) { + if (isGamma(*descendant)) { + n_gamma++; + tau_p4vis += (descendant->p4()); + finalProds.push_back(daughter); + } } - - } - - /* assign the tau-variables */ - gentau_vis_pt_.emplace_back(tau_p4vis.Pt()); - gentau_vis_eta_.emplace_back(tau_p4vis.Eta()); - gentau_vis_phi_.emplace_back(tau_p4vis.Phi()); - gentau_vis_energy_.emplace_back(tau_p4vis.E()); - gentau_vis_mass_.emplace_back(tau_p4vis.M()); - gentau_totNproducts_.emplace_back(n_pi + n_gamma); - gentau_totNgamma_.emplace_back(n_gamma); - gentau_totNpiZero_.emplace_back(n_piZero); - gentau_totNcharged_.emplace_back(n_pi); - - gentau_products_pt_.emplace_back(tau_products_pt); - gentau_products_eta_.emplace_back(tau_products_eta); - gentau_products_phi_.emplace_back(tau_products_phi); - gentau_products_energy_.emplace_back(tau_products_energy); - gentau_products_mass_.emplace_back(tau_products_mass); - gentau_products_id_.emplace_back(tau_products_id); - - /* leptonic tau decays */ - if( n_pi == 0 && n_piZero == 0 && n_ele==1 ){ gentau_decayMode_.emplace_back(11); } - else if( n_pi == 0 && n_piZero == 0 && n_mu==1 ){ gentau_decayMode_.emplace_back(13); } - /* 1-prong */ - else if( n_pi == 1 && n_piZero == 0 ){ gentau_decayMode_.emplace_back(0); } - /* 1-prong + pi0s */ - else if( n_pi == 1 && n_piZero >= 1 ){ gentau_decayMode_.emplace_back(1); } - /* 3-prongs */ - else if( n_pi == 3 && n_piZero == 0 ){ gentau_decayMode_.emplace_back(4); } - /* 3-prongs + pi0s */ - else if( n_pi == 3 && n_piZero >= 1 ){ gentau_decayMode_.emplace_back(5); } - /* other decays */ - else{ gentau_decayMode_.emplace_back(-1); } + } + } + } + } + /* Fill daughter informations */ + for (const auto& prod : finalProds) { + tau_products_pt.emplace_back(prod->pt()); + tau_products_eta.emplace_back(prod->eta()); + tau_products_phi.emplace_back(prod->phi()); + tau_products_energy.emplace_back(prod->energy()); + tau_products_mass.emplace_back(prod->mass()); + tau_products_id.emplace_back(prod->pdgId()); } + } + + /* assign the tau-variables */ + gentau_vis_pt_.emplace_back(tau_p4vis.Pt()); + gentau_vis_eta_.emplace_back(tau_p4vis.Eta()); + gentau_vis_phi_.emplace_back(tau_p4vis.Phi()); + gentau_vis_energy_.emplace_back(tau_p4vis.E()); + gentau_vis_mass_.emplace_back(tau_p4vis.M()); + gentau_totNproducts_.emplace_back(n_pi + n_gamma); + gentau_totNgamma_.emplace_back(n_gamma); + gentau_totNpiZero_.emplace_back(n_piZero); + gentau_totNcharged_.emplace_back(n_pi); + + gentau_products_pt_.emplace_back(tau_products_pt); + gentau_products_eta_.emplace_back(tau_products_eta); + gentau_products_phi_.emplace_back(tau_products_phi); + gentau_products_energy_.emplace_back(tau_products_energy); + gentau_products_mass_.emplace_back(tau_products_mass); + gentau_products_id_.emplace_back(tau_products_id); + + /* leptonic tau decays */ + if (n_pi == 0 && n_piZero == 0 && n_ele == 1) { + gentau_decayMode_.emplace_back(11); + } else if (n_pi == 0 && n_piZero == 0 && n_mu == 1) { + gentau_decayMode_.emplace_back(13); + } + /* 1-prong */ + else if (n_pi == 1 && n_piZero == 0) { + gentau_decayMode_.emplace_back(0); + } + /* 1-prong + pi0s */ + else if (n_pi == 1 && n_piZero >= 1) { + gentau_decayMode_.emplace_back(1); + } + /* 3-prongs */ + else if (n_pi == 3 && n_piZero == 0) { + gentau_decayMode_.emplace_back(4); + } + /* 3-prongs + pi0s */ + else if (n_pi == 3 && n_piZero >= 1) { + gentau_decayMode_.emplace_back(5); + } + /* other decays */ + else { + gentau_decayMode_.emplace_back(-1); + } } - + } } - -void -HGCalTriggerNtupleGenTau:: -clear() -{ - gentau_pt_.clear(); - gentau_eta_.clear(); - gentau_phi_.clear(); - gentau_energy_.clear(); - gentau_mass_.clear(); - gentau_decayMode_.clear(); - gentau_vis_pt_.clear(); - gentau_vis_eta_.clear(); - gentau_vis_phi_.clear(); - gentau_vis_energy_.clear(); - gentau_vis_mass_.clear(); - gentau_totNproducts_.clear(); - gentau_totNgamma_.clear(); - gentau_totNcharged_.clear(); - gentau_products_pt_.clear(); - gentau_products_eta_.clear(); - gentau_products_phi_.clear(); - gentau_products_energy_.clear(); - gentau_products_mass_.clear(); - gentau_products_id_.clear(); +void HGCalTriggerNtupleGenTau::clear() { + gentau_pt_.clear(); + gentau_eta_.clear(); + gentau_phi_.clear(); + gentau_energy_.clear(); + gentau_mass_.clear(); + gentau_decayMode_.clear(); + gentau_vis_pt_.clear(); + gentau_vis_eta_.clear(); + gentau_vis_phi_.clear(); + gentau_vis_energy_.clear(); + gentau_vis_mass_.clear(); + gentau_totNproducts_.clear(); + gentau_totNgamma_.clear(); + gentau_totNcharged_.clear(); + gentau_products_pt_.clear(); + gentau_products_eta_.clear(); + gentau_products_phi_.clear(); + gentau_products_energy_.clear(); + gentau_products_mass_.clear(); + gentau_products_id_.clear(); } - - - - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc index ddfc840807b1a..dba436caaf5ee 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc @@ -7,60 +7,47 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - - -class HGCalTriggerNtupleHGCClusters : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCClusters() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - void clear() final; - - - bool filter_clusters_in_multiclusters_; - edm::EDGetToken clusters_token_, multiclusters_token_; - HGCalTriggerTools triggerTools_; - - - int cl_n_ ; - std::vector cl_id_; - std::vector cl_mipPt_; - std::vector cl_pt_; - std::vector cl_energy_; - std::vector cl_eta_; - std::vector cl_phi_; - std::vector cl_layer_; - std::vector cl_subdet_; - std::vector cl_cells_n_; - std::vector> cl_cells_id_; - std::vector cl_multicluster_id_; - std::vector cl_multicluster_pt_; - - +class HGCalTriggerNtupleHGCClusters : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCClusters() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + void clear() final; + + bool filter_clusters_in_multiclusters_; + edm::EDGetToken clusters_token_, multiclusters_token_; + HGCalTriggerTools triggerTools_; + + int cl_n_; + std::vector cl_id_; + std::vector cl_mipPt_; + std::vector cl_pt_; + std::vector cl_energy_; + std::vector cl_eta_; + std::vector cl_phi_; + std::vector cl_layer_; + std::vector cl_subdet_; + std::vector cl_cells_n_; + std::vector> cl_cells_id_; + std::vector cl_multicluster_id_; + std::vector cl_multicluster_pt_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCClusters, - "HGCalTriggerNtupleHGCClusters" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCClusters, "HGCalTriggerNtupleHGCClusters"); +HGCalTriggerNtupleHGCClusters::HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf) + : HGCalTriggerNtupleBase(conf), + filter_clusters_in_multiclusters_(conf.getParameter("FilterClustersInMulticlusters")) {} -HGCalTriggerNtupleHGCClusters:: -HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf), - filter_clusters_in_multiclusters_(conf.getParameter("FilterClustersInMulticlusters")) -{ -} - -void -HGCalTriggerNtupleHGCClusters:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ +void HGCalTriggerNtupleHGCClusters::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { clusters_token_ = collector.consumes(conf.getParameter("Clusters")); - multiclusters_token_ = collector.consumes(conf.getParameter("Multiclusters")); + multiclusters_token_ = + collector.consumes(conf.getParameter("Multiclusters")); tree.Branch("cl_n", &cl_n_, "cl_n/I"); tree.Branch("cl_id", &cl_id_); @@ -77,11 +64,7 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& tree.Branch("cl_multicluster_pt", &cl_multicluster_pt_); } -void -HGCalTriggerNtupleHGCClusters:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - +void HGCalTriggerNtupleHGCClusters::fill(const edm::Event& e, const edm::EventSetup& es) { // retrieve clusters edm::Handle clusters_h; e.getByToken(clusters_token_, clusters_h); @@ -98,27 +81,23 @@ fill(const edm::Event& e, const edm::EventSetup& es) // Associate cells to clusters std::unordered_map cluster2multicluster; - for(auto mcl_itr=multiclusters.begin(0); mcl_itr!=multiclusters.end(0); mcl_itr++) - { + for (auto mcl_itr = multiclusters.begin(0); mcl_itr != multiclusters.end(0); mcl_itr++) { // loop on 2D clusters inside 3D clusters - for(const auto& cl_ptr : mcl_itr->constituents()) - { + for (const auto& cl_ptr : mcl_itr->constituents()) { cluster2multicluster.emplace(cl_ptr.second->detId(), mcl_itr); } } - - clear(); - for(auto cl_itr=clusters.begin(0); cl_itr!=clusters.end(0); cl_itr++) - { + for (auto cl_itr = clusters.begin(0); cl_itr != clusters.end(0); cl_itr++) { auto mcl_itr = cluster2multicluster.find(cl_itr->detId()); - uint32_t mcl_id = (mcl_itr!=cluster2multicluster.end() ? mcl_itr->second->detId() : 0); - float mcl_pt = (mcl_itr!=cluster2multicluster.end() ? mcl_itr->second->pt() : 0.); - if(filter_clusters_in_multiclusters_ && mcl_id==0) continue; + uint32_t mcl_id = (mcl_itr != cluster2multicluster.end() ? mcl_itr->second->detId() : 0); + float mcl_pt = (mcl_itr != cluster2multicluster.end() ? mcl_itr->second->pt() : 0.); + if (filter_clusters_in_multiclusters_ && mcl_id == 0) + continue; cl_n_++; cl_mipPt_.emplace_back(cl_itr->mipPt()); - // physical values + // physical values cl_pt_.emplace_back(cl_itr->pt()); cl_energy_.emplace_back(cl_itr->energy()); cl_eta_.emplace_back(cl_itr->eta()); @@ -130,19 +109,17 @@ fill(const edm::Event& e, const edm::EventSetup& es) cl_cells_n_.emplace_back(cl_itr->constituents().size()); // Retrieve indices of trigger cells inside cluster cl_cells_id_.emplace_back(cl_itr->constituents().size()); - std::transform(cl_itr->constituents_begin(), cl_itr->constituents_end(), - cl_cells_id_.back().begin(), [](const std::pair>& id_tc){return id_tc.second->detId();} - ); + std::transform( + cl_itr->constituents_begin(), + cl_itr->constituents_end(), + cl_cells_id_.back().begin(), + [](const std::pair>& id_tc) { return id_tc.second->detId(); }); cl_multicluster_id_.emplace_back(mcl_id); cl_multicluster_pt_.emplace_back(mcl_pt); } } - -void -HGCalTriggerNtupleHGCClusters:: -clear() -{ +void HGCalTriggerNtupleHGCClusters::clear() { cl_n_ = 0; cl_id_.clear(); cl_mipPt_.clear(); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc index 7300a61f42bee..33b138cf03409 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCDigis.cc @@ -13,373 +13,356 @@ #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - -class HGCalTriggerNtupleHGCDigis : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCDigis() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - void simhits(const edm::Event& e, std::unordered_map& simhits_ee, std::unordered_map& simhits_fh, std::unordered_map& simhits_bh); - void clear() final; - - edm::EDGetToken ee_token_, fh_token_, bh_token_; - bool is_Simhit_comp_; - edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; - - HGCalTriggerTools triggerTools_; - - int hgcdigi_n_ ; - std::vector hgcdigi_id_; - std::vector hgcdigi_subdet_; - std::vector hgcdigi_side_; - std::vector hgcdigi_layer_; - std::vector hgcdigi_wafertype_ ; - std::vector hgcdigi_eta_; - std::vector hgcdigi_phi_; - std::vector hgcdigi_z_; - std::vector hgcdigi_data_; - std::vector hgcdigi_isadc_; - std::vector hgcdigi_simenergy_; - // V8 detid scheme - std::vector hgcdigi_wafer_; - std::vector hgcdigi_cell_; - // V9 detid scheme - std::vector hgcdigi_waferu_; - std::vector hgcdigi_waferv_; - std::vector hgcdigi_cellu_; - std::vector hgcdigi_cellv_; - - int bhdigi_n_ ; - std::vector bhdigi_id_; - std::vector bhdigi_subdet_; - std::vector bhdigi_side_; - std::vector bhdigi_layer_; - std::vector bhdigi_ieta_; - std::vector bhdigi_iphi_; - std::vector bhdigi_eta_; - std::vector bhdigi_phi_; - std::vector bhdigi_z_; - std::vector bhdigi_data_; - std::vector bhdigi_simenergy_; - - edm::ESHandle triggerGeometry_; - +class HGCalTriggerNtupleHGCDigis : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCDigis() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + void simhits(const edm::Event& e, + std::unordered_map& simhits_ee, + std::unordered_map& simhits_fh, + std::unordered_map& simhits_bh); + void clear() final; + + edm::EDGetToken ee_token_, fh_token_, bh_token_; + bool is_Simhit_comp_; + edm::EDGetToken SimHits_inputee_, SimHits_inputfh_, SimHits_inputbh_; + + HGCalTriggerTools triggerTools_; + + int hgcdigi_n_; + std::vector hgcdigi_id_; + std::vector hgcdigi_subdet_; + std::vector hgcdigi_side_; + std::vector hgcdigi_layer_; + std::vector hgcdigi_wafertype_; + std::vector hgcdigi_eta_; + std::vector hgcdigi_phi_; + std::vector hgcdigi_z_; + std::vector hgcdigi_data_; + std::vector hgcdigi_isadc_; + std::vector hgcdigi_simenergy_; + // V8 detid scheme + std::vector hgcdigi_wafer_; + std::vector hgcdigi_cell_; + // V9 detid scheme + std::vector hgcdigi_waferu_; + std::vector hgcdigi_waferv_; + std::vector hgcdigi_cellu_; + std::vector hgcdigi_cellv_; + + int bhdigi_n_; + std::vector bhdigi_id_; + std::vector bhdigi_subdet_; + std::vector bhdigi_side_; + std::vector bhdigi_layer_; + std::vector bhdigi_ieta_; + std::vector bhdigi_iphi_; + std::vector bhdigi_eta_; + std::vector bhdigi_phi_; + std::vector bhdigi_z_; + std::vector bhdigi_data_; + std::vector bhdigi_simenergy_; + + edm::ESHandle triggerGeometry_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCDigis, - "HGCalTriggerNtupleHGCDigis" ); - - -HGCalTriggerNtupleHGCDigis:: -HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ - is_Simhit_comp_ = conf.getParameter("isSimhitComp"); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCDigis, "HGCalTriggerNtupleHGCDigis"); +HGCalTriggerNtupleHGCDigis::HGCalTriggerNtupleHGCDigis(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) { + is_Simhit_comp_ = conf.getParameter("isSimhitComp"); } -void -HGCalTriggerNtupleHGCDigis:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - ee_token_ = collector.consumes(conf.getParameter("HGCDigisEE")); - fh_token_ = collector.consumes(conf.getParameter("HGCDigisFH")); - bh_token_ = collector.consumes(conf.getParameter("HGCDigisBH")); - if (is_Simhit_comp_) { - SimHits_inputee_ = collector.consumes(conf.getParameter("eeSimHits")); - SimHits_inputfh_ = collector.consumes(conf.getParameter("fhSimHits")); - SimHits_inputbh_ = collector.consumes(conf.getParameter("bhSimHits")); - } - tree.Branch("hgcdigi_n", &hgcdigi_n_, "hgcdigi_n/I"); - tree.Branch("hgcdigi_id", &hgcdigi_id_); - tree.Branch("hgcdigi_subdet", &hgcdigi_subdet_); - tree.Branch("hgcdigi_zside", &hgcdigi_side_); - tree.Branch("hgcdigi_layer", &hgcdigi_layer_); - tree.Branch("hgcdigi_wafertype", &hgcdigi_wafertype_); - tree.Branch("hgcdigi_eta", &hgcdigi_eta_); - tree.Branch("hgcdigi_phi", &hgcdigi_phi_); - tree.Branch("hgcdigi_z", &hgcdigi_z_); - tree.Branch("hgcdigi_data", &hgcdigi_data_); - tree.Branch("hgcdigi_isadc", &hgcdigi_isadc_); - // V9 detid scheme - tree.Branch("hgcdigi_waferu", &hgcdigi_waferu_); - tree.Branch("hgcdigi_waferv", &hgcdigi_waferv_); - tree.Branch("hgcdigi_cellu", &hgcdigi_cellu_); - tree.Branch("hgcdigi_cellv", &hgcdigi_cellv_); - // V8 detid scheme - tree.Branch("hgcdigi_wafer", &hgcdigi_wafer_); - tree.Branch("hgcdigi_cell", &hgcdigi_cell_); - if (is_Simhit_comp_) tree.Branch("hgcdigi_simenergy", &hgcdigi_simenergy_); - - tree.Branch("bhdigi_n", &bhdigi_n_, "bhdigi_n/I"); - tree.Branch("bhdigi_id", &bhdigi_id_); - tree.Branch("bhdigi_subdet", &bhdigi_subdet_); - tree.Branch("bhdigi_zside", &bhdigi_side_); - tree.Branch("bhdigi_layer", &bhdigi_layer_); - tree.Branch("bhdigi_ieta", &bhdigi_ieta_); - tree.Branch("bhdigi_iphi", &bhdigi_iphi_); - tree.Branch("bhdigi_eta", &bhdigi_eta_); - tree.Branch("bhdigi_phi", &bhdigi_phi_); - tree.Branch("bhdigi_z", &bhdigi_z_); - tree.Branch("bhdigi_data", &bhdigi_data_); - if (is_Simhit_comp_) tree.Branch("bhdigi_simenergy", &bhdigi_simenergy_); +void HGCalTriggerNtupleHGCDigis::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + ee_token_ = collector.consumes(conf.getParameter("HGCDigisEE")); + fh_token_ = collector.consumes(conf.getParameter("HGCDigisFH")); + bh_token_ = collector.consumes(conf.getParameter("HGCDigisBH")); + if (is_Simhit_comp_) { + SimHits_inputee_ = collector.consumes(conf.getParameter("eeSimHits")); + SimHits_inputfh_ = collector.consumes(conf.getParameter("fhSimHits")); + SimHits_inputbh_ = collector.consumes(conf.getParameter("bhSimHits")); + } + tree.Branch("hgcdigi_n", &hgcdigi_n_, "hgcdigi_n/I"); + tree.Branch("hgcdigi_id", &hgcdigi_id_); + tree.Branch("hgcdigi_subdet", &hgcdigi_subdet_); + tree.Branch("hgcdigi_zside", &hgcdigi_side_); + tree.Branch("hgcdigi_layer", &hgcdigi_layer_); + tree.Branch("hgcdigi_wafertype", &hgcdigi_wafertype_); + tree.Branch("hgcdigi_eta", &hgcdigi_eta_); + tree.Branch("hgcdigi_phi", &hgcdigi_phi_); + tree.Branch("hgcdigi_z", &hgcdigi_z_); + tree.Branch("hgcdigi_data", &hgcdigi_data_); + tree.Branch("hgcdigi_isadc", &hgcdigi_isadc_); + // V9 detid scheme + tree.Branch("hgcdigi_waferu", &hgcdigi_waferu_); + tree.Branch("hgcdigi_waferv", &hgcdigi_waferv_); + tree.Branch("hgcdigi_cellu", &hgcdigi_cellu_); + tree.Branch("hgcdigi_cellv", &hgcdigi_cellv_); + // V8 detid scheme + tree.Branch("hgcdigi_wafer", &hgcdigi_wafer_); + tree.Branch("hgcdigi_cell", &hgcdigi_cell_); + if (is_Simhit_comp_) + tree.Branch("hgcdigi_simenergy", &hgcdigi_simenergy_); + + tree.Branch("bhdigi_n", &bhdigi_n_, "bhdigi_n/I"); + tree.Branch("bhdigi_id", &bhdigi_id_); + tree.Branch("bhdigi_subdet", &bhdigi_subdet_); + tree.Branch("bhdigi_zside", &bhdigi_side_); + tree.Branch("bhdigi_layer", &bhdigi_layer_); + tree.Branch("bhdigi_ieta", &bhdigi_ieta_); + tree.Branch("bhdigi_iphi", &bhdigi_iphi_); + tree.Branch("bhdigi_eta", &bhdigi_eta_); + tree.Branch("bhdigi_phi", &bhdigi_phi_); + tree.Branch("bhdigi_z", &bhdigi_z_); + tree.Branch("bhdigi_data", &bhdigi_data_); + if (is_Simhit_comp_) + tree.Branch("bhdigi_simenergy", &bhdigi_simenergy_); } -void -HGCalTriggerNtupleHGCDigis:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - es.get().get(triggerGeometry_); - - edm::Handle ee_digis_h; - e.getByToken(ee_token_, ee_digis_h); - const HGCalDigiCollection& ee_digis = *ee_digis_h; - edm::Handle fh_digis_h; - e.getByToken(fh_token_, fh_digis_h); - const HGCalDigiCollection& fh_digis = *fh_digis_h; - edm::Handle bh_digis_h; - e.getByToken(bh_token_, bh_digis_h); - const HGCalDigiCollection& bh_digis = *bh_digis_h; - - triggerTools_.eventSetup(es); - - // sim hit association - std::unordered_map simhits_ee; - std::unordered_map simhits_fh; - std::unordered_map simhits_bh; - if (is_Simhit_comp_) simhits(e, simhits_ee, simhits_fh, simhits_bh); - - clear(); - hgcdigi_n_ = ee_digis.size() + fh_digis.size(); - hgcdigi_id_.reserve(hgcdigi_n_); - hgcdigi_subdet_.reserve(hgcdigi_n_); - hgcdigi_side_.reserve(hgcdigi_n_); - hgcdigi_layer_.reserve(hgcdigi_n_); - hgcdigi_wafertype_.reserve(hgcdigi_n_); - hgcdigi_eta_.reserve(hgcdigi_n_); - hgcdigi_phi_.reserve(hgcdigi_n_); - hgcdigi_z_.reserve(hgcdigi_n_); - hgcdigi_data_.reserve(hgcdigi_n_); - hgcdigi_isadc_.reserve(hgcdigi_n_); - if(triggerGeometry_->isV9Geometry()) - { - hgcdigi_waferu_.reserve(hgcdigi_n_); - hgcdigi_waferv_.reserve(hgcdigi_n_); - hgcdigi_cellu_.reserve(hgcdigi_n_); - hgcdigi_cellv_.reserve(hgcdigi_n_); +void HGCalTriggerNtupleHGCDigis::fill(const edm::Event& e, const edm::EventSetup& es) { + es.get().get(triggerGeometry_); + + edm::Handle ee_digis_h; + e.getByToken(ee_token_, ee_digis_h); + const HGCalDigiCollection& ee_digis = *ee_digis_h; + edm::Handle fh_digis_h; + e.getByToken(fh_token_, fh_digis_h); + const HGCalDigiCollection& fh_digis = *fh_digis_h; + edm::Handle bh_digis_h; + e.getByToken(bh_token_, bh_digis_h); + const HGCalDigiCollection& bh_digis = *bh_digis_h; + + triggerTools_.eventSetup(es); + + // sim hit association + std::unordered_map simhits_ee; + std::unordered_map simhits_fh; + std::unordered_map simhits_bh; + if (is_Simhit_comp_) + simhits(e, simhits_ee, simhits_fh, simhits_bh); + + clear(); + hgcdigi_n_ = ee_digis.size() + fh_digis.size(); + hgcdigi_id_.reserve(hgcdigi_n_); + hgcdigi_subdet_.reserve(hgcdigi_n_); + hgcdigi_side_.reserve(hgcdigi_n_); + hgcdigi_layer_.reserve(hgcdigi_n_); + hgcdigi_wafertype_.reserve(hgcdigi_n_); + hgcdigi_eta_.reserve(hgcdigi_n_); + hgcdigi_phi_.reserve(hgcdigi_n_); + hgcdigi_z_.reserve(hgcdigi_n_); + hgcdigi_data_.reserve(hgcdigi_n_); + hgcdigi_isadc_.reserve(hgcdigi_n_); + if (triggerGeometry_->isV9Geometry()) { + hgcdigi_waferu_.reserve(hgcdigi_n_); + hgcdigi_waferv_.reserve(hgcdigi_n_); + hgcdigi_cellu_.reserve(hgcdigi_n_); + hgcdigi_cellv_.reserve(hgcdigi_n_); + } else { + hgcdigi_wafer_.reserve(hgcdigi_n_); + hgcdigi_cell_.reserve(hgcdigi_n_); + } + if (is_Simhit_comp_) + hgcdigi_simenergy_.reserve(hgcdigi_n_); + + bhdigi_n_ = bh_digis.size(); + bhdigi_id_.reserve(bhdigi_n_); + bhdigi_subdet_.reserve(bhdigi_n_); + bhdigi_side_.reserve(bhdigi_n_); + bhdigi_layer_.reserve(bhdigi_n_); + bhdigi_ieta_.reserve(bhdigi_n_); + bhdigi_iphi_.reserve(bhdigi_n_); + bhdigi_eta_.reserve(bhdigi_n_); + bhdigi_phi_.reserve(bhdigi_n_); + bhdigi_z_.reserve(bhdigi_n_); + if (is_Simhit_comp_) + bhdigi_simenergy_.reserve(bhdigi_n_); + + const int kIntimeSample = 2; + for (const auto& digi : ee_digis) { + const DetId id(digi.id()); + hgcdigi_id_.emplace_back(id.rawId()); + hgcdigi_subdet_.emplace_back(id.subdetId()); + hgcdigi_side_.emplace_back(triggerTools_.zside(id)); + hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); + GlobalPoint cellpos = triggerGeometry_->eeGeometry()->getPosition(id.rawId()); + hgcdigi_eta_.emplace_back(cellpos.eta()); + hgcdigi_phi_.emplace_back(cellpos.phi()); + hgcdigi_z_.emplace_back(cellpos.z()); + hgcdigi_data_.emplace_back(digi[kIntimeSample].data()); + if (triggerGeometry_->isV9Geometry()) { + const HGCSiliconDetId idv9(digi.id()); + hgcdigi_waferu_.emplace_back(idv9.waferU()); + hgcdigi_waferv_.emplace_back(idv9.waferV()); + hgcdigi_wafertype_.emplace_back(idv9.type()); + hgcdigi_cellu_.emplace_back(idv9.cellU()); + hgcdigi_cellv_.emplace_back(idv9.cellV()); + } else { + const HGCalDetId idv8(digi.id()); + hgcdigi_wafer_.emplace_back(idv8.wafer()); + hgcdigi_wafertype_.emplace_back(idv8.waferType()); + hgcdigi_cell_.emplace_back(idv8.cell()); } - else - { - hgcdigi_wafer_.reserve(hgcdigi_n_); - hgcdigi_cell_.reserve(hgcdigi_n_); + int is_adc = 0; + if (!(digi[kIntimeSample].mode())) + is_adc = 1; + hgcdigi_isadc_.emplace_back(is_adc); + if (is_Simhit_comp_) { + double hit_energy = 0; + auto itr = simhits_ee.find(id); + if (itr != simhits_ee.end()) + hit_energy = itr->second; + hgcdigi_simenergy_.emplace_back(hit_energy); } - if (is_Simhit_comp_) hgcdigi_simenergy_.reserve(hgcdigi_n_); - - bhdigi_n_ = bh_digis.size(); - bhdigi_id_.reserve(bhdigi_n_); - bhdigi_subdet_.reserve(bhdigi_n_); - bhdigi_side_.reserve(bhdigi_n_); - bhdigi_layer_.reserve(bhdigi_n_); - bhdigi_ieta_.reserve(bhdigi_n_); - bhdigi_iphi_.reserve(bhdigi_n_); - bhdigi_eta_.reserve(bhdigi_n_); - bhdigi_phi_.reserve(bhdigi_n_); - bhdigi_z_.reserve(bhdigi_n_); - if (is_Simhit_comp_) bhdigi_simenergy_.reserve(bhdigi_n_); - - const int kIntimeSample = 2; - for(const auto& digi : ee_digis) - { - const DetId id(digi.id()); - hgcdigi_id_.emplace_back(id.rawId()); - hgcdigi_subdet_.emplace_back(id.subdetId()); - hgcdigi_side_.emplace_back(triggerTools_.zside(id)); - hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = triggerGeometry_->eeGeometry()->getPosition(id.rawId()); - hgcdigi_eta_.emplace_back(cellpos.eta()); - hgcdigi_phi_.emplace_back(cellpos.phi()); - hgcdigi_z_.emplace_back(cellpos.z()); - hgcdigi_data_.emplace_back(digi[kIntimeSample].data()); - if(triggerGeometry_->isV9Geometry()) - { - const HGCSiliconDetId idv9(digi.id()); - hgcdigi_waferu_.emplace_back(idv9.waferU()); - hgcdigi_waferv_.emplace_back(idv9.waferV()); - hgcdigi_wafertype_.emplace_back(idv9.type()); - hgcdigi_cellu_.emplace_back(idv9.cellU()); - hgcdigi_cellv_.emplace_back(idv9.cellV()); - } - else - { - const HGCalDetId idv8(digi.id()); - hgcdigi_wafer_.emplace_back(idv8.wafer()); - hgcdigi_wafertype_.emplace_back(idv8.waferType()); - hgcdigi_cell_.emplace_back(idv8.cell()); - } - int is_adc=0; - if (!(digi[kIntimeSample].mode())) is_adc =1; - hgcdigi_isadc_.emplace_back(is_adc); - if (is_Simhit_comp_) { - double hit_energy=0; - auto itr = simhits_ee.find(id); - if(itr!=simhits_ee.end())hit_energy = itr->second; - hgcdigi_simenergy_.emplace_back(hit_energy); - } - } - - for(const auto& digi : fh_digis) - { - const DetId id(digi.id()); - hgcdigi_id_.emplace_back(id.rawId()); - hgcdigi_subdet_.emplace_back(id.subdetId()); - hgcdigi_side_.emplace_back(triggerTools_.zside(id)); - hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = triggerGeometry_->hsiGeometry()->getPosition(id.rawId()); - hgcdigi_eta_.emplace_back(cellpos.eta()); - hgcdigi_phi_.emplace_back(cellpos.phi()); - hgcdigi_z_.emplace_back(cellpos.z()); - hgcdigi_data_.emplace_back(digi[kIntimeSample].data()); - if(triggerGeometry_->isV9Geometry()) - { - const HGCSiliconDetId idv9(digi.id()); - hgcdigi_waferu_.emplace_back(idv9.waferU()); - hgcdigi_waferv_.emplace_back(idv9.waferV()); - hgcdigi_wafertype_.emplace_back(idv9.type()); - hgcdigi_cellu_.emplace_back(idv9.cellU()); - hgcdigi_cellv_.emplace_back(idv9.cellV()); - } - else - { - const HGCalDetId idv8(digi.id()); - hgcdigi_wafer_.emplace_back(idv8.wafer()); - hgcdigi_wafertype_.emplace_back(idv8.waferType()); - hgcdigi_cell_.emplace_back(idv8.cell()); - } - int is_adc=0; - if (!(digi[kIntimeSample].mode())) is_adc =1; - hgcdigi_isadc_.emplace_back(is_adc); - if (is_Simhit_comp_) { - double hit_energy=0; - auto itr = simhits_fh.find(id); - if(itr!=simhits_fh.end())hit_energy = itr->second; - hgcdigi_simenergy_.emplace_back(hit_energy); - } - } - - for(const auto& digi : bh_digis) - { - const DetId id(digi.id()); - bhdigi_id_.emplace_back(id.rawId()); - bhdigi_subdet_.emplace_back(id.subdetId()); - bhdigi_side_.emplace_back(triggerTools_.zside(id)); - bhdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); - GlobalPoint cellpos = (triggerGeometry_->isV9Geometry() ? - triggerGeometry_->hscGeometry()->getPosition(id.rawId()) : - triggerGeometry_->bhGeometry()->getPosition(id.rawId()) ); - bhdigi_eta_.emplace_back(cellpos.eta()); - bhdigi_phi_.emplace_back(cellpos.phi()); - bhdigi_z_.emplace_back(cellpos.z()); - bhdigi_data_.emplace_back(digi[kIntimeSample].data()); - if(triggerGeometry_->isV9Geometry()) - { - const HGCScintillatorDetId idv9(digi.id()); - bhdigi_ieta_.emplace_back(idv9.ietaAbs()); - bhdigi_iphi_.emplace_back(idv9.iphi()); - } - else - { - const HcalDetId idv8(digi.id()); - bhdigi_ieta_.emplace_back(idv8.ieta()); - bhdigi_iphi_.emplace_back(idv8.iphi()); - } - if (is_Simhit_comp_) { - double hit_energy=0; - auto itr = simhits_bh.find(id); - if(itr!=simhits_bh.end())hit_energy = itr->second; - bhdigi_simenergy_.emplace_back(hit_energy); - } - } -} - -void -HGCalTriggerNtupleHGCDigis:: -simhits(const edm::Event& e, std::unordered_map& simhits_ee, std::unordered_map& simhits_fh, std::unordered_map& simhits_bh) -{ - - edm::Handle ee_simhits_h; - e.getByToken(SimHits_inputee_,ee_simhits_h); - const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; - edm::Handle fh_simhits_h; - e.getByToken(SimHits_inputfh_,fh_simhits_h); - const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; - edm::Handle bh_simhits_h; - e.getByToken(SimHits_inputbh_,bh_simhits_h); - const edm::PCaloHitContainer& bh_simhits = *bh_simhits_h; - - //EE - for( const auto& simhit : ee_simhits ) { - DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->eeTopology()); - if(id.rawId()==0) continue; - auto itr_insert = simhits_ee.emplace(id, 0.); - itr_insert.first->second += simhit.energy(); + } + + for (const auto& digi : fh_digis) { + const DetId id(digi.id()); + hgcdigi_id_.emplace_back(id.rawId()); + hgcdigi_subdet_.emplace_back(id.subdetId()); + hgcdigi_side_.emplace_back(triggerTools_.zside(id)); + hgcdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); + GlobalPoint cellpos = triggerGeometry_->hsiGeometry()->getPosition(id.rawId()); + hgcdigi_eta_.emplace_back(cellpos.eta()); + hgcdigi_phi_.emplace_back(cellpos.phi()); + hgcdigi_z_.emplace_back(cellpos.z()); + hgcdigi_data_.emplace_back(digi[kIntimeSample].data()); + if (triggerGeometry_->isV9Geometry()) { + const HGCSiliconDetId idv9(digi.id()); + hgcdigi_waferu_.emplace_back(idv9.waferU()); + hgcdigi_waferv_.emplace_back(idv9.waferV()); + hgcdigi_wafertype_.emplace_back(idv9.type()); + hgcdigi_cellu_.emplace_back(idv9.cellU()); + hgcdigi_cellv_.emplace_back(idv9.cellV()); + } else { + const HGCalDetId idv8(digi.id()); + hgcdigi_wafer_.emplace_back(idv8.wafer()); + hgcdigi_wafertype_.emplace_back(idv8.waferType()); + hgcdigi_cell_.emplace_back(idv8.cell()); + } + int is_adc = 0; + if (!(digi[kIntimeSample].mode())) + is_adc = 1; + hgcdigi_isadc_.emplace_back(is_adc); + if (is_Simhit_comp_) { + double hit_energy = 0; + auto itr = simhits_fh.find(id); + if (itr != simhits_fh.end()) + hit_energy = itr->second; + hgcdigi_simenergy_.emplace_back(hit_energy); } - // FH - for( const auto& simhit : fh_simhits ) { - DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->fhTopology()); - if(id.rawId()==0) continue; - auto itr_insert = simhits_fh.emplace(id, 0.); - itr_insert.first->second += simhit.energy(); + } + + for (const auto& digi : bh_digis) { + const DetId id(digi.id()); + bhdigi_id_.emplace_back(id.rawId()); + bhdigi_subdet_.emplace_back(id.subdetId()); + bhdigi_side_.emplace_back(triggerTools_.zside(id)); + bhdigi_layer_.emplace_back(triggerTools_.layerWithOffset(id)); + GlobalPoint cellpos = (triggerGeometry_->isV9Geometry() ? triggerGeometry_->hscGeometry()->getPosition(id.rawId()) + : triggerGeometry_->bhGeometry()->getPosition(id.rawId())); + bhdigi_eta_.emplace_back(cellpos.eta()); + bhdigi_phi_.emplace_back(cellpos.phi()); + bhdigi_z_.emplace_back(cellpos.z()); + bhdigi_data_.emplace_back(digi[kIntimeSample].data()); + if (triggerGeometry_->isV9Geometry()) { + const HGCScintillatorDetId idv9(digi.id()); + bhdigi_ieta_.emplace_back(idv9.ietaAbs()); + bhdigi_iphi_.emplace_back(idv9.iphi()); + } else { + const HcalDetId idv8(digi.id()); + bhdigi_ieta_.emplace_back(idv8.ieta()); + bhdigi_iphi_.emplace_back(idv8.iphi()); } - // BH - for( const auto& simhit : bh_simhits ) { - DetId id = (triggerGeometry_->isV9Geometry() ? - triggerTools_.simToReco(simhit.id(), triggerGeometry_->hscTopology()) : - triggerTools_.simToReco(simhit.id(), triggerGeometry_->bhTopology()) ); - if(id.rawId()==0) continue; - auto itr_insert = simhits_bh.emplace(id, 0.); - itr_insert.first->second += simhit.energy(); + if (is_Simhit_comp_) { + double hit_energy = 0; + auto itr = simhits_bh.find(id); + if (itr != simhits_bh.end()) + hit_energy = itr->second; + bhdigi_simenergy_.emplace_back(hit_energy); } + } } +void HGCalTriggerNtupleHGCDigis::simhits(const edm::Event& e, + std::unordered_map& simhits_ee, + std::unordered_map& simhits_fh, + std::unordered_map& simhits_bh) { + edm::Handle ee_simhits_h; + e.getByToken(SimHits_inputee_, ee_simhits_h); + const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; + edm::Handle fh_simhits_h; + e.getByToken(SimHits_inputfh_, fh_simhits_h); + const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; + edm::Handle bh_simhits_h; + e.getByToken(SimHits_inputbh_, bh_simhits_h); + const edm::PCaloHitContainer& bh_simhits = *bh_simhits_h; + + //EE + for (const auto& simhit : ee_simhits) { + DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->eeTopology()); + if (id.rawId() == 0) + continue; + auto itr_insert = simhits_ee.emplace(id, 0.); + itr_insert.first->second += simhit.energy(); + } + // FH + for (const auto& simhit : fh_simhits) { + DetId id = triggerTools_.simToReco(simhit.id(), triggerGeometry_->fhTopology()); + if (id.rawId() == 0) + continue; + auto itr_insert = simhits_fh.emplace(id, 0.); + itr_insert.first->second += simhit.energy(); + } + // BH + for (const auto& simhit : bh_simhits) { + DetId id = + (triggerGeometry_->isV9Geometry() ? triggerTools_.simToReco(simhit.id(), triggerGeometry_->hscTopology()) + : triggerTools_.simToReco(simhit.id(), triggerGeometry_->bhTopology())); + if (id.rawId() == 0) + continue; + auto itr_insert = simhits_bh.emplace(id, 0.); + itr_insert.first->second += simhit.energy(); + } +} -void -HGCalTriggerNtupleHGCDigis:: -clear() -{ - hgcdigi_n_ = 0; - hgcdigi_id_.clear(); - hgcdigi_subdet_.clear(); - hgcdigi_side_.clear(); - hgcdigi_layer_.clear(); - hgcdigi_wafer_.clear(); - hgcdigi_waferu_.clear(); - hgcdigi_waferv_.clear(); - hgcdigi_wafertype_.clear(); - hgcdigi_cell_.clear(); - hgcdigi_cellu_.clear(); - hgcdigi_cellv_.clear(); - hgcdigi_eta_.clear(); - hgcdigi_phi_.clear(); - hgcdigi_z_.clear(); - hgcdigi_data_.clear(); - hgcdigi_isadc_.clear(); - if (is_Simhit_comp_) hgcdigi_simenergy_.clear(); - - bhdigi_n_ = 0; - bhdigi_id_.clear(); - bhdigi_subdet_.clear(); - bhdigi_side_.clear(); - bhdigi_layer_.clear(); - bhdigi_ieta_.clear(); - bhdigi_iphi_.clear(); - bhdigi_eta_.clear(); - bhdigi_phi_.clear(); - bhdigi_z_.clear(); - bhdigi_data_.clear(); - if (is_Simhit_comp_) bhdigi_simenergy_.clear(); +void HGCalTriggerNtupleHGCDigis::clear() { + hgcdigi_n_ = 0; + hgcdigi_id_.clear(); + hgcdigi_subdet_.clear(); + hgcdigi_side_.clear(); + hgcdigi_layer_.clear(); + hgcdigi_wafer_.clear(); + hgcdigi_waferu_.clear(); + hgcdigi_waferv_.clear(); + hgcdigi_wafertype_.clear(); + hgcdigi_cell_.clear(); + hgcdigi_cellu_.clear(); + hgcdigi_cellv_.clear(); + hgcdigi_eta_.clear(); + hgcdigi_phi_.clear(); + hgcdigi_z_.clear(); + hgcdigi_data_.clear(); + hgcdigi_isadc_.clear(); + if (is_Simhit_comp_) + hgcdigi_simenergy_.clear(); + + bhdigi_n_ = 0; + bhdigi_id_.clear(); + bhdigi_subdet_.clear(); + bhdigi_side_.clear(); + bhdigi_layer_.clear(); + bhdigi_ieta_.clear(); + bhdigi_iphi_.clear(); + bhdigi_eta_.clear(); + bhdigi_phi_.clear(); + bhdigi_z_.clear(); + bhdigi_data_.clear(); + if (is_Simhit_comp_) + bhdigi_simenergy_.clear(); } diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc index 8c01b9624c0bf..d8818a702bd60 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCMulticlusters.cc @@ -4,67 +4,59 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h" - - -class HGCalTriggerNtupleHGCMulticlusters : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCMulticlusters() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - void clear() final; - - edm::EDGetToken multiclusters_token_; - - std::unique_ptr id_; - - int cl3d_n_ ; - std::vector cl3d_id_; - std::vector cl3d_pt_; - std::vector cl3d_energy_; - std::vector cl3d_eta_; - std::vector cl3d_phi_; - std::vector cl3d_clusters_n_; - std::vector> cl3d_clusters_id_; - // cluster shower shapes - std::vector cl3d_showerlength_; - std::vector cl3d_coreshowerlength_; - std::vector cl3d_firstlayer_; - std::vector cl3d_maxlayer_; - std::vector cl3d_seetot_; - std::vector cl3d_seemax_; - std::vector cl3d_spptot_; - std::vector cl3d_sppmax_; - std::vector cl3d_szz_; - std::vector cl3d_srrtot_; - std::vector cl3d_srrmax_; - std::vector cl3d_srrmean_; - std::vector cl3d_emaxe_; - std::vector cl3d_bdteg_; - std::vector cl3d_quality_; +class HGCalTriggerNtupleHGCMulticlusters : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCMulticlusters() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + void clear() final; + + edm::EDGetToken multiclusters_token_; + + std::unique_ptr id_; + + int cl3d_n_; + std::vector cl3d_id_; + std::vector cl3d_pt_; + std::vector cl3d_energy_; + std::vector cl3d_eta_; + std::vector cl3d_phi_; + std::vector cl3d_clusters_n_; + std::vector> cl3d_clusters_id_; + // cluster shower shapes + std::vector cl3d_showerlength_; + std::vector cl3d_coreshowerlength_; + std::vector cl3d_firstlayer_; + std::vector cl3d_maxlayer_; + std::vector cl3d_seetot_; + std::vector cl3d_seemax_; + std::vector cl3d_spptot_; + std::vector cl3d_sppmax_; + std::vector cl3d_szz_; + std::vector cl3d_srrtot_; + std::vector cl3d_srrmax_; + std::vector cl3d_srrmean_; + std::vector cl3d_emaxe_; + std::vector cl3d_bdteg_; + std::vector cl3d_quality_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCMulticlusters, - "HGCalTriggerNtupleHGCMulticlusters" ); - +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCMulticlusters, "HGCalTriggerNtupleHGCMulticlusters"); -HGCalTriggerNtupleHGCMulticlusters:: -HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ -} +HGCalTriggerNtupleHGCMulticlusters::HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf) + : HGCalTriggerNtupleBase(conf) {} -void -HGCalTriggerNtupleHGCMulticlusters:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - multiclusters_token_ = collector.consumes(conf.getParameter("Multiclusters")); - id_ = std::unique_ptr{ HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") }; - id_->initialize(conf.getParameter("EGIdentification")); +void HGCalTriggerNtupleHGCMulticlusters::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + multiclusters_token_ = + collector.consumes(conf.getParameter("Multiclusters")); + id_ = std::unique_ptr{ + HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")}; + id_->initialize(conf.getParameter("EGIdentification")); tree.Branch("cl3d_n", &cl3d_n_, "cl3d_n/I"); tree.Branch("cl3d_id", &cl3d_id_); @@ -89,14 +81,9 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& tree.Branch("cl3d_emaxe", &cl3d_emaxe_); tree.Branch("cl3d_bdteg", &cl3d_bdteg_); tree.Branch("cl3d_quality", &cl3d_quality_); - } -void -HGCalTriggerNtupleHGCMulticlusters:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - +void HGCalTriggerNtupleHGCMulticlusters::fill(const edm::Event& e, const edm::EventSetup& es) { // retrieve clusters 3D edm::Handle multiclusters_h; e.getByToken(multiclusters_token_, multiclusters_h); @@ -107,11 +94,10 @@ fill(const edm::Event& e, const edm::EventSetup& es) es.get().get(geometry); clear(); - for(auto cl3d_itr=multiclusters.begin(0); cl3d_itr!=multiclusters.end(0); cl3d_itr++) - { + for (auto cl3d_itr = multiclusters.begin(0); cl3d_itr != multiclusters.end(0); cl3d_itr++) { cl3d_n_++; cl3d_id_.emplace_back(cl3d_itr->detId()); - // physical values + // physical values cl3d_pt_.emplace_back(cl3d_itr->pt()); cl3d_energy_.emplace_back(cl3d_itr->energy()); cl3d_eta_.emplace_back(cl3d_itr->eta()); @@ -129,23 +115,20 @@ fill(const edm::Event& e, const edm::EventSetup& es) cl3d_srrtot_.emplace_back(cl3d_itr->sigmaRRTot()); cl3d_srrmax_.emplace_back(cl3d_itr->sigmaRRMax()); cl3d_srrmean_.emplace_back(cl3d_itr->sigmaRRMean()); - cl3d_emaxe_.emplace_back(cl3d_itr->eMax()/cl3d_itr->energy()); + cl3d_emaxe_.emplace_back(cl3d_itr->eMax() / cl3d_itr->energy()); cl3d_bdteg_.emplace_back(id_->value(*cl3d_itr)); cl3d_quality_.emplace_back(cl3d_itr->hwQual()); // Retrieve indices of trigger cells inside cluster cl3d_clusters_id_.emplace_back(cl3d_itr->constituents().size()); - std::transform(cl3d_itr->constituents_begin(), cl3d_itr->constituents_end(), - cl3d_clusters_id_.back().begin(), [](const std::pair>& id_cl){return id_cl.second->detId();} - ); + std::transform(cl3d_itr->constituents_begin(), + cl3d_itr->constituents_end(), + cl3d_clusters_id_.back().begin(), + [](const std::pair>& id_cl) { return id_cl.second->detId(); }); } } - -void -HGCalTriggerNtupleHGCMulticlusters:: -clear() -{ +void HGCalTriggerNtupleHGCMulticlusters::clear() { cl3d_n_ = 0; cl3d_id_.clear(); cl3d_pt_.clear(); @@ -170,7 +153,3 @@ clear() cl3d_bdteg_.clear(); cl3d_quality_.clear(); } - - - - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc index 92976057f49b9..5392b058ccbe0 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCPanels.cc @@ -5,86 +5,70 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" - - -class HGCalTriggerNtupleHGCPanels : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCPanels(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCPanels() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - void clear() final; - - - edm::EDGetToken trigger_cells_token_; - edm::ESHandle geometry_; - - int panel_n_ ; - std::vector panel_id_; - std::vector panel_zside_; - std::vector panel_layer_; - std::vector panel_sector_; - std::vector panel_number_; - std::vector panel_tc_n_; - std::vector > panel_tc_id_; - std::vector > panel_tc_mod_; - std::vector > panel_tc_third_; - std::vector > panel_tc_cell_; - std::vector > panel_tc_mipPt_; - std::vector > panel_tc_pt_; - - private: - static const unsigned kPanel_offset_ = 0; - static const unsigned kPanel_mask_ = 0x1F; - static const unsigned kSector_offset_ = 5; - static const unsigned kSector_mask_ = 0x7; - static const unsigned kThird_offset_ = 4; - static const unsigned kThird_mask_ = 0x3; - static const unsigned kCell_mask_ = 0xF; - +class HGCalTriggerNtupleHGCPanels : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCPanels(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCPanels() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + void clear() final; + + edm::EDGetToken trigger_cells_token_; + edm::ESHandle geometry_; + + int panel_n_; + std::vector panel_id_; + std::vector panel_zside_; + std::vector panel_layer_; + std::vector panel_sector_; + std::vector panel_number_; + std::vector panel_tc_n_; + std::vector > panel_tc_id_; + std::vector > panel_tc_mod_; + std::vector > panel_tc_third_; + std::vector > panel_tc_cell_; + std::vector > panel_tc_mipPt_; + std::vector > panel_tc_pt_; + +private: + static const unsigned kPanel_offset_ = 0; + static const unsigned kPanel_mask_ = 0x1F; + static const unsigned kSector_offset_ = 5; + static const unsigned kSector_mask_ = 0x7; + static const unsigned kThird_offset_ = 4; + static const unsigned kThird_mask_ = 0x3; + static const unsigned kCell_mask_ = 0xF; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCPanels, - "HGCalTriggerNtupleHGCPanels" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCPanels, "HGCalTriggerNtupleHGCPanels"); +HGCalTriggerNtupleHGCPanels::HGCalTriggerNtupleHGCPanels(const edm::ParameterSet& conf) + : HGCalTriggerNtupleBase(conf) {} -HGCalTriggerNtupleHGCPanels:: -HGCalTriggerNtupleHGCPanels(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ -} - -void -HGCalTriggerNtupleHGCPanels:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - trigger_cells_token_ = collector.consumes(conf.getParameter("TriggerCells")); +void HGCalTriggerNtupleHGCPanels::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + trigger_cells_token_ = + collector.consumes(conf.getParameter("TriggerCells")); - tree.Branch("panel_n", &panel_n_, "panel_n/I"); - tree.Branch("panel_id", &panel_id_); + tree.Branch("panel_n", &panel_n_, "panel_n/I"); + tree.Branch("panel_id", &panel_id_); tree.Branch("panel_zside", &panel_zside_); tree.Branch("panel_layer", &panel_layer_); tree.Branch("panel_sector", &panel_sector_); tree.Branch("panel_number", &panel_number_); - tree.Branch("panel_tc_n", &panel_tc_n_); - tree.Branch("panel_tc_id", &panel_tc_id_); - tree.Branch("panel_tc_mod", &panel_tc_mod_); - tree.Branch("panel_tc_third", &panel_tc_third_); - tree.Branch("panel_tc_cell", &panel_tc_cell_); - tree.Branch("panel_tc_mipPt", &panel_tc_mipPt_); - tree.Branch("panel_tc_pt", &panel_tc_pt_); - + tree.Branch("panel_tc_n", &panel_tc_n_); + tree.Branch("panel_tc_id", &panel_tc_id_); + tree.Branch("panel_tc_mod", &panel_tc_mod_); + tree.Branch("panel_tc_third", &panel_tc_third_); + tree.Branch("panel_tc_cell", &panel_tc_cell_); + tree.Branch("panel_tc_mipPt", &panel_tc_mipPt_); + tree.Branch("panel_tc_pt", &panel_tc_pt_); } -void -HGCalTriggerNtupleHGCPanels:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - +void HGCalTriggerNtupleHGCPanels::fill(const edm::Event& e, const edm::EventSetup& es) { // retrieve trigger cells edm::Handle trigger_cells_h; e.getByToken(trigger_cells_token_, trigger_cells_h); @@ -96,22 +80,19 @@ fill(const edm::Event& e, const edm::EventSetup& es) clear(); // Regroup trigger cells by panel - std::unordered_map< uint32_t,vector > panelids_tcs; - for(auto tc_itr=trigger_cells.begin(0); tc_itr!=trigger_cells.end(0); tc_itr++) - { - if(tc_itr->hwPt()>0 && tc_itr->subdetId()!=ForwardSubdetector::HGCHEB) - { + std::unordered_map > panelids_tcs; + for (auto tc_itr = trigger_cells.begin(0); tc_itr != trigger_cells.end(0); tc_itr++) { + if (tc_itr->hwPt() > 0 && tc_itr->subdetId() != ForwardSubdetector::HGCHEB) { HGCalDetId id(tc_itr->detId()); HGCalDetId panelid(geometry_->getModuleFromTriggerCell(id)); panelids_tcs[panelid].push_back(tc_itr); } } - for (const auto& panelid_tcs : panelids_tcs) - { + for (const auto& panelid_tcs : panelids_tcs) { panel_n_++; HGCalDetId panelid(panelid_tcs.first); - int panel_sector = (panelid.wafer()>>kSector_offset_) & kSector_mask_ ; - int panel_number = (panelid.wafer()>>kPanel_offset_) & kPanel_mask_ ; + int panel_sector = (panelid.wafer() >> kSector_offset_) & kSector_mask_; + int panel_number = (panelid.wafer() >> kPanel_offset_) & kPanel_mask_; const auto& tcs = panelid_tcs.second; panel_id_.emplace_back(panelid); panel_zside_.emplace_back(panelid.zside()); @@ -126,14 +107,13 @@ fill(const edm::Event& e, const edm::EventSetup& es) panel_tc_mipPt_.emplace_back(); panel_tc_pt_.emplace_back(); - for (const auto& tc : tcs) - { + for (const auto& tc : tcs) { panel_tc_id_.back().push_back(tc->detId()); panel_tc_mipPt_.back().push_back(tc->mipPt()); panel_tc_pt_.back().push_back(tc->pt()); HGCalDetId tc_detid(tc->detId()); unsigned module_id = tc_detid.wafer(); - unsigned third_id = (tc_detid.cell()>>kThird_offset_) & kThird_mask_; + unsigned third_id = (tc_detid.cell() >> kThird_offset_) & kThird_mask_; unsigned cell_id = tc_detid.cell() & kCell_mask_; panel_tc_mod_.back().push_back(module_id); panel_tc_third_.back().push_back(third_id); @@ -142,11 +122,7 @@ fill(const edm::Event& e, const edm::EventSetup& es) } } - -void -HGCalTriggerNtupleHGCPanels:: -clear() -{ +void HGCalTriggerNtupleHGCPanels::clear() { panel_n_ = 0; panel_id_.clear(); panel_zside_.clear(); @@ -161,7 +137,3 @@ clear() panel_tc_mipPt_.clear(); panel_tc_pt_.clear(); } - - - - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc index 623726317ac51..f0fcad149c3db 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleHGCTriggerCells.cc @@ -11,71 +11,64 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" - - -class HGCalTriggerNtupleHGCTriggerCells : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCTriggerCells() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - double calibrate(double, int, unsigned); - void simhits(const edm::Event& e, std::unordered_map& simhits_ee, std::unordered_map& simhits_fh, std::unordered_map& simhits_bh); - void clear() final; - - HGCalTriggerTools triggerTools_; - - edm::EDGetToken trigger_cells_token_, multiclusters_token_; - edm::EDGetToken simhits_ee_token_, simhits_fh_token_, simhits_bh_token_; - bool fill_simenergy_; - bool filter_cells_in_multiclusters_; - double keV2fC_; - std::vector fcPerMip_; - std::vector layerWeights_; - std::vector thicknessCorrections_; - edm::ESHandle geometry_; - - - int tc_n_ ; - std::vector tc_id_; - std::vector tc_subdet_; - std::vector tc_side_; - std::vector tc_layer_; - std::vector tc_wafer_; - std::vector tc_wafertype_ ; - std::vector tc_cell_; - std::vector tc_data_; - std::vector tc_uncompressedCharge_; - std::vector tc_compressedCharge_; - std::vector tc_mipPt_; - std::vector tc_pt_; - std::vector tc_energy_; - std::vector tc_simenergy_; - std::vector tc_eta_; - std::vector tc_phi_; - std::vector tc_x_; - std::vector tc_y_; - std::vector tc_z_; - std::vector tc_cluster_id_; - std::vector tc_multicluster_id_; - std::vector tc_multicluster_pt_; - +class HGCalTriggerNtupleHGCTriggerCells : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCTriggerCells() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + double calibrate(double, int, unsigned); + void simhits(const edm::Event& e, + std::unordered_map& simhits_ee, + std::unordered_map& simhits_fh, + std::unordered_map& simhits_bh); + void clear() final; + + HGCalTriggerTools triggerTools_; + + edm::EDGetToken trigger_cells_token_, multiclusters_token_; + edm::EDGetToken simhits_ee_token_, simhits_fh_token_, simhits_bh_token_; + bool fill_simenergy_; + bool filter_cells_in_multiclusters_; + double keV2fC_; + std::vector fcPerMip_; + std::vector layerWeights_; + std::vector thicknessCorrections_; + edm::ESHandle geometry_; + + int tc_n_; + std::vector tc_id_; + std::vector tc_subdet_; + std::vector tc_side_; + std::vector tc_layer_; + std::vector tc_wafer_; + std::vector tc_wafertype_; + std::vector tc_cell_; + std::vector tc_data_; + std::vector tc_uncompressedCharge_; + std::vector tc_compressedCharge_; + std::vector tc_mipPt_; + std::vector tc_pt_; + std::vector tc_energy_; + std::vector tc_simenergy_; + std::vector tc_eta_; + std::vector tc_phi_; + std::vector tc_x_; + std::vector tc_y_; + std::vector tc_z_; + std::vector tc_cluster_id_; + std::vector tc_multicluster_id_; + std::vector tc_multicluster_pt_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCTriggerCells, - "HGCalTriggerNtupleHGCTriggerCells" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTriggerCells, "HGCalTriggerNtupleHGCTriggerCells"); - -HGCalTriggerNtupleHGCTriggerCells:: -HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf), - fill_simenergy_(conf.getParameter("FillSimEnergy")), - filter_cells_in_multiclusters_(conf.getParameter("FilterCellsInMulticlusters")) -{ +HGCalTriggerNtupleHGCTriggerCells::HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf) + : HGCalTriggerNtupleBase(conf), + fill_simenergy_(conf.getParameter("FillSimEnergy")), + filter_cells_in_multiclusters_(conf.getParameter("FilterCellsInMulticlusters")) { fill_simenergy_ = conf.getParameter("FillSimEnergy"); filter_cells_in_multiclusters_ = conf.getParameter("FilterCellsInMulticlusters"); keV2fC_ = conf.getParameter("keV2fC"); @@ -84,15 +77,15 @@ HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet& conf):HGCalTriggerNtu thicknessCorrections_ = conf.getParameter>("thicknessCorrections"); } -void -HGCalTriggerNtupleHGCTriggerCells:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ - trigger_cells_token_ = collector.consumes(conf.getParameter("TriggerCells")); - multiclusters_token_ = collector.consumes(conf.getParameter("Multiclusters")); +void HGCalTriggerNtupleHGCTriggerCells::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { + trigger_cells_token_ = + collector.consumes(conf.getParameter("TriggerCells")); + multiclusters_token_ = + collector.consumes(conf.getParameter("Multiclusters")); - if (fill_simenergy_) - { + if (fill_simenergy_) { simhits_ee_token_ = collector.consumes(conf.getParameter("eeSimHits")); simhits_fh_token_ = collector.consumes(conf.getParameter("fhSimHits")); simhits_bh_token_ = collector.consumes(conf.getParameter("bhSimHits")); @@ -112,7 +105,8 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& tree.Branch("tc_pt", &tc_pt_); tree.Branch("tc_mipPt", &tc_mipPt_); tree.Branch("tc_energy", &tc_energy_); - if(fill_simenergy_) tree.Branch("tc_simenergy", &tc_simenergy_); + if (fill_simenergy_) + tree.Branch("tc_simenergy", &tc_simenergy_); tree.Branch("tc_eta", &tc_eta_); tree.Branch("tc_phi", &tc_phi_); tree.Branch("tc_x", &tc_x_); @@ -121,14 +115,9 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& tree.Branch("tc_cluster_id", &tc_cluster_id_); tree.Branch("tc_multicluster_id", &tc_multicluster_id_); tree.Branch("tc_multicluster_pt", &tc_multicluster_pt_); - } -void -HGCalTriggerNtupleHGCTriggerCells:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - +void HGCalTriggerNtupleHGCTriggerCells::fill(const edm::Event& e, const edm::EventSetup& es) { // retrieve trigger cells edm::Handle trigger_cells_h; e.getByToken(trigger_cells_token_, trigger_cells_h); @@ -144,21 +133,19 @@ fill(const edm::Event& e, const edm::EventSetup& es) // sim hit association std::unordered_map simhits_ee; - std::unordered_map simhits_fh; - std::unordered_map simhits_bh; - if(fill_simenergy_) simhits(e, simhits_ee, simhits_fh, simhits_bh); + std::unordered_map simhits_fh; + std::unordered_map simhits_bh; + if (fill_simenergy_) + simhits(e, simhits_ee, simhits_fh, simhits_bh); // Associate cells to clusters std::unordered_map cell2cluster; std::unordered_map cell2multicluster; - for(auto mcl_itr=multiclusters.begin(0); mcl_itr!=multiclusters.end(0); mcl_itr++) - { + for (auto mcl_itr = multiclusters.begin(0); mcl_itr != multiclusters.end(0); mcl_itr++) { // loop on 2D clusters inside 3D clusters - for(const auto& cl_ptr : mcl_itr->constituents()) - { + for (const auto& cl_ptr : mcl_itr->constituents()) { // loop on TC inside 2D clusters - for(const auto& tc_ptr : cl_ptr.second->constituents()) - { + for (const auto& tc_ptr : cl_ptr.second->constituents()) { cell2cluster.emplace(tc_ptr.second->detId(), cl_ptr.second->detId()); cell2multicluster.emplace(tc_ptr.second->detId(), mcl_itr); } @@ -168,17 +155,16 @@ fill(const edm::Event& e, const edm::EventSetup& es) triggerTools_.eventSetup(es); clear(); - for(auto tc_itr=trigger_cells.begin(0); tc_itr!=trigger_cells.end(0); tc_itr++) - { - if(tc_itr->hwPt()>0) - { + for (auto tc_itr = trigger_cells.begin(0); tc_itr != trigger_cells.end(0); tc_itr++) { + if (tc_itr->hwPt() > 0) { auto cl_itr = cell2cluster.find(tc_itr->detId()); auto mcl_itr = cell2multicluster.find(tc_itr->detId()); - uint32_t cl_id = (cl_itr!=cell2cluster.end() ? cl_itr->second : 0); - uint32_t mcl_id = (mcl_itr!=cell2multicluster.end() ? mcl_itr->second->detId() : 0); - float mcl_pt = (mcl_itr!=cell2multicluster.end() ? mcl_itr->second->pt() : 0.); + uint32_t cl_id = (cl_itr != cell2cluster.end() ? cl_itr->second : 0); + uint32_t mcl_id = (mcl_itr != cell2multicluster.end() ? mcl_itr->second->detId() : 0); + float mcl_pt = (mcl_itr != cell2multicluster.end() ? mcl_itr->second->pt() : 0.); // Filter cells not included in a multicluster, if requested - if(filter_cells_in_multiclusters_ && mcl_id==0) continue; + if (filter_cells_in_multiclusters_ && mcl_id == 0) + continue; tc_n_++; // hardware data HGCalDetId id(tc_itr->detId()); @@ -193,7 +179,7 @@ fill(const edm::Event& e, const edm::EventSetup& es) tc_uncompressedCharge_.emplace_back(tc_itr->uncompressedCharge()); tc_compressedCharge_.emplace_back(tc_itr->compressedCharge()); tc_mipPt_.emplace_back(tc_itr->mipPt()); - // physical values + // physical values tc_pt_.emplace_back(tc_itr->pt()); tc_energy_.emplace_back(tc_itr->energy()); tc_eta_.emplace_back(tc_itr->eta()); @@ -206,103 +192,92 @@ fill(const edm::Event& e, const edm::EventSetup& es) tc_multicluster_id_.emplace_back(mcl_id); tc_multicluster_pt_.emplace_back(mcl_pt); - if(fill_simenergy_) - { + if (fill_simenergy_) { double energy = 0; int subdet = id.subdetId(); unsigned layer = triggerTools_.layerWithOffset(id); // search for simhit for all the cells inside the trigger cell - for(uint32_t c_id : geometry_->getCellsFromTriggerCell(id)) - { + for (uint32_t c_id : geometry_->getCellsFromTriggerCell(id)) { int thickness = triggerTools_.thicknessIndex(c_id); - switch(subdet) - { - case ForwardSubdetector::HGCEE: - { - auto itr = simhits_ee.find(c_id); - if(itr!=simhits_ee.end()) energy += calibrate(itr->second, thickness, layer); - break; - } - case ForwardSubdetector::HGCHEF: - { - auto itr = simhits_fh.find(c_id); - if(itr!=simhits_fh.end()) energy += calibrate(itr->second, thickness, layer); - break; - } - case ForwardSubdetector::HGCHEB: - { - auto itr = simhits_bh.find(c_id); - if(itr!=simhits_bh.end()) energy += itr->second; - break; - } + switch (subdet) { + case ForwardSubdetector::HGCEE: { + auto itr = simhits_ee.find(c_id); + if (itr != simhits_ee.end()) + energy += calibrate(itr->second, thickness, layer); + break; + } + case ForwardSubdetector::HGCHEF: { + auto itr = simhits_fh.find(c_id); + if (itr != simhits_fh.end()) + energy += calibrate(itr->second, thickness, layer); + break; + } + case ForwardSubdetector::HGCHEB: { + auto itr = simhits_bh.find(c_id); + if (itr != simhits_bh.end()) + energy += itr->second; + break; + } default: break; } } - tc_simenergy_.emplace_back(energy); + tc_simenergy_.emplace_back(energy); } } } } -double -HGCalTriggerNtupleHGCTriggerCells:: -calibrate(double energy, int thickness, unsigned layer) -{ +double HGCalTriggerNtupleHGCTriggerCells::calibrate(double energy, int thickness, unsigned layer) { double fcPerMip = fcPerMip_[thickness]; double thicknessCorrection = thicknessCorrections_[thickness]; double layerWeight = layerWeights_[layer]; double TeV2GeV = 1.e3; - return energy*keV2fC_/fcPerMip*layerWeight*TeV2GeV/thicknessCorrection; + return energy * keV2fC_ / fcPerMip * layerWeight * TeV2GeV / thicknessCorrection; } -void -HGCalTriggerNtupleHGCTriggerCells:: -simhits(const edm::Event& e, std::unordered_map& simhits_ee, std::unordered_map& simhits_fh, std::unordered_map& simhits_bh) -{ +void HGCalTriggerNtupleHGCTriggerCells::simhits(const edm::Event& e, + std::unordered_map& simhits_ee, + std::unordered_map& simhits_fh, + std::unordered_map& simhits_bh) { edm::Handle ee_simhits_h; - e.getByToken(simhits_ee_token_,ee_simhits_h); + e.getByToken(simhits_ee_token_, ee_simhits_h); const edm::PCaloHitContainer& ee_simhits = *ee_simhits_h; edm::Handle fh_simhits_h; - e.getByToken(simhits_fh_token_,fh_simhits_h); + e.getByToken(simhits_fh_token_, fh_simhits_h); const edm::PCaloHitContainer& fh_simhits = *fh_simhits_h; edm::Handle bh_simhits_h; - e.getByToken(simhits_bh_token_,bh_simhits_h); + e.getByToken(simhits_bh_token_, bh_simhits_h); const edm::PCaloHitContainer& bh_simhits = *bh_simhits_h; //EE - for( const auto& simhit : ee_simhits ) - { + for (const auto& simhit : ee_simhits) { DetId id = triggerTools_.simToReco(simhit.id(), geometry_->eeTopology()); - if(id.rawId()==0) continue; + if (id.rawId() == 0) + continue; auto itr_insert = simhits_ee.emplace(id, 0.); itr_insert.first->second += simhit.energy(); } // FH - for( const auto& simhit : fh_simhits ) - { + for (const auto& simhit : fh_simhits) { DetId id = triggerTools_.simToReco(simhit.id(), geometry_->fhTopology()); - if(id.rawId()==0) continue; + if (id.rawId() == 0) + continue; auto itr_insert = simhits_fh.emplace(id, 0.); itr_insert.first->second += simhit.energy(); - } + } // BH - for( const auto& simhit : bh_simhits ) - { - DetId id = (geometry_->isV9Geometry() ? - triggerTools_.simToReco(simhit.id(), geometry_->hscTopology()) : - triggerTools_.simToReco(simhit.id(), geometry_->bhTopology()) ); - if(id.rawId()==0) continue; + for (const auto& simhit : bh_simhits) { + DetId id = (geometry_->isV9Geometry() ? triggerTools_.simToReco(simhit.id(), geometry_->hscTopology()) + : triggerTools_.simToReco(simhit.id(), geometry_->bhTopology())); + if (id.rawId() == 0) + continue; auto itr_insert = simhits_bh.emplace(id, 0.); itr_insert.first->second += simhit.energy(); - } + } } - -void -HGCalTriggerNtupleHGCTriggerCells:: -clear() -{ +void HGCalTriggerNtupleHGCTriggerCells::clear() { tc_n_ = 0; tc_id_.clear(); tc_subdet_.clear(); diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc index 9bfc16fa5e265..9e32a4a65c4f2 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleManager.cc @@ -8,49 +8,37 @@ #include "CommonTools/UtilAlgos/interface/TFileService.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" -class HGCalTriggerNtupleManager : public edm::EDAnalyzer -{ - public: - typedef std::unique_ptr ntuple_ptr; - - public: - explicit HGCalTriggerNtupleManager(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleManager() override{}; - void beginRun(const edm::Run&, const edm::EventSetup&) override {}; - void analyze(const edm::Event&, const edm::EventSetup&) override; - - private: - edm::Service file_service_; - std::vector hgc_ntuples_; - TTree* tree_; +class HGCalTriggerNtupleManager : public edm::EDAnalyzer { +public: + typedef std::unique_ptr ntuple_ptr; + +public: + explicit HGCalTriggerNtupleManager(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleManager() override{}; + void beginRun(const edm::Run&, const edm::EventSetup&) override{}; + void analyze(const edm::Event&, const edm::EventSetup&) override; + +private: + edm::Service file_service_; + std::vector hgc_ntuples_; + TTree* tree_; }; - DEFINE_FWK_MODULE(HGCalTriggerNtupleManager); - -HGCalTriggerNtupleManager:: -HGCalTriggerNtupleManager(const edm::ParameterSet& conf) -{ - tree_ = file_service_->make("HGCalTriggerNtuple","HGCalTriggerNtuple"); - const std::vector& ntuple_cfgs = conf.getParameterSetVector("Ntuples"); - for(const auto& ntuple_cfg : ntuple_cfgs) - { - const std::string& ntuple_name = ntuple_cfg.getParameter("NtupleName"); - hgc_ntuples_.emplace_back( HGCalTriggerNtupleFactory::get()->create(ntuple_name, ntuple_cfg) ); - hgc_ntuples_.back()->initialize(*tree_, ntuple_cfg , consumesCollector()); - } +HGCalTriggerNtupleManager::HGCalTriggerNtupleManager(const edm::ParameterSet& conf) { + tree_ = file_service_->make("HGCalTriggerNtuple", "HGCalTriggerNtuple"); + const std::vector& ntuple_cfgs = conf.getParameterSetVector("Ntuples"); + for (const auto& ntuple_cfg : ntuple_cfgs) { + const std::string& ntuple_name = ntuple_cfg.getParameter("NtupleName"); + hgc_ntuples_.emplace_back(HGCalTriggerNtupleFactory::get()->create(ntuple_name, ntuple_cfg)); + hgc_ntuples_.back()->initialize(*tree_, ntuple_cfg, consumesCollector()); + } } - -void -HGCalTriggerNtupleManager:: -analyze(const edm::Event& e, const edm::EventSetup& es) -{ - for(auto& hgc_ntuple : hgc_ntuples_) - { - hgc_ntuple->fill(e,es); - } - tree_->Fill(); +void HGCalTriggerNtupleManager::analyze(const edm::Event& e, const edm::EventSetup& es) { + for (auto& hgc_ntuple : hgc_ntuples_) { + hgc_ntuple->fill(e, es); + } + tree_->Fill(); } - diff --git a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc index 605093aa99da2..6603675d394c8 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleTowers.cc @@ -3,48 +3,37 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" - - -class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase -{ - - public: - HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf); - ~HGCalTriggerNtupleHGCTowers() override{}; - void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; - void fill(const edm::Event& e, const edm::EventSetup& es) final; - - private: - void clear() final; - - edm::EDGetToken towers_token_; - - int tower_n_ ; - std::vector tower_pt_; - std::vector tower_energy_; - std::vector tower_eta_; - std::vector tower_phi_; - std::vector tower_etEm_; - std::vector tower_etHad_; - std::vector tower_iEta_; - std::vector tower_iPhi_; - +class HGCalTriggerNtupleHGCTowers : public HGCalTriggerNtupleBase { +public: + HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf); + ~HGCalTriggerNtupleHGCTowers() override{}; + void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final; + void fill(const edm::Event& e, const edm::EventSetup& es) final; + +private: + void clear() final; + + edm::EDGetToken towers_token_; + + int tower_n_; + std::vector tower_pt_; + std::vector tower_energy_; + std::vector tower_eta_; + std::vector tower_phi_; + std::vector tower_etEm_; + std::vector tower_etHad_; + std::vector tower_iEta_; + std::vector tower_iPhi_; }; -DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, - HGCalTriggerNtupleHGCTowers, - "HGCalTriggerNtupleHGCTowers" ); +DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory, HGCalTriggerNtupleHGCTowers, "HGCalTriggerNtupleHGCTowers"); +HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf) + : HGCalTriggerNtupleBase(conf) {} -HGCalTriggerNtupleHGCTowers:: -HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf) -{ -} - -void -HGCalTriggerNtupleHGCTowers:: -initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector) -{ +void HGCalTriggerNtupleHGCTowers::initialize(TTree& tree, + const edm::ParameterSet& conf, + edm::ConsumesCollector&& collector) { towers_token_ = collector.consumes(conf.getParameter("Towers")); tree.Branch("tower_n", &tower_n_, "tower_n/I"); @@ -56,16 +45,9 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& tree.Branch("tower_etHad", &tower_etHad_); tree.Branch("tower_iEta", &tower_iEta_); tree.Branch("tower_iPhi", &tower_iPhi_); - } - - -void -HGCalTriggerNtupleHGCTowers:: -fill(const edm::Event& e, const edm::EventSetup& es) -{ - +void HGCalTriggerNtupleHGCTowers::fill(const edm::Event& e, const edm::EventSetup& es) { // retrieve towers edm::Handle towers_h; e.getByToken(towers_token_, towers_h); @@ -76,8 +58,7 @@ fill(const edm::Event& e, const edm::EventSetup& es) es.get().get(geometry); clear(); - for(auto tower_itr=towers.begin(0); tower_itr!=towers.end(0); tower_itr++) - { + for (auto tower_itr = towers.begin(0); tower_itr != towers.end(0); tower_itr++) { tower_n_++; // physical values tower_pt_.emplace_back(tower_itr->pt()); @@ -92,11 +73,7 @@ fill(const edm::Event& e, const edm::EventSetup& es) } } - -void -HGCalTriggerNtupleHGCTowers:: -clear() -{ +void HGCalTriggerNtupleHGCTowers::clear() { tower_n_ = 0; tower_pt_.clear(); tower_energy_.clear(); diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc index 7be9149f93775..31e50b046f393 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterSimpleSelector.cc @@ -8,42 +8,38 @@ #include "CommonTools/Utils/interface/StringCutObjectSelector.h" namespace l1t { - class HGC3DClusterSimpleSelector : public edm::global::EDProducer<> { - public: - explicit HGC3DClusterSimpleSelector(const edm::ParameterSet&) ; - ~HGC3DClusterSimpleSelector() override {} - void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; - - private: - const edm::EDGetTokenT src_; - const StringCutObjectSelector cut_; - - }; // class -} // namespace - -l1t::HGC3DClusterSimpleSelector::HGC3DClusterSimpleSelector(const edm::ParameterSet & iConfig) : - src_(consumes(iConfig.getParameter("src"))), - cut_(iConfig.getParameter("cut")) -{ - produces(); + class HGC3DClusterSimpleSelector : public edm::global::EDProducer<> { + public: + explicit HGC3DClusterSimpleSelector(const edm::ParameterSet &); + ~HGC3DClusterSimpleSelector() override {} + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; + + private: + const edm::EDGetTokenT src_; + const StringCutObjectSelector cut_; + + }; // class +} // namespace l1t + +l1t::HGC3DClusterSimpleSelector::HGC3DClusterSimpleSelector(const edm::ParameterSet &iConfig) + : src_(consumes(iConfig.getParameter("src"))), + cut_(iConfig.getParameter("cut")) { + produces(); } - -void -l1t::HGC3DClusterSimpleSelector::produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup &) const -{ +void l1t::HGC3DClusterSimpleSelector::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const { std::unique_ptr out = std::make_unique(); edm::Handle multiclusters; iEvent.getByToken(src_, multiclusters); for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) { - for(auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { - const auto & c = *it; - if (cut_(c)) { - out->push_back(bx, c); - } + for (auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { + const auto &c = *it; + if (cut_(c)) { + out->push_back(bx, c); } + } } iEvent.put(std::move(out)); diff --git a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc index c049c3935e026..5274c865d1af7 100644 --- a/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc +++ b/L1Trigger/L1THGCalUtilities/plugins/selectors/HGC3DClusterTMVASelector.cc @@ -13,65 +13,61 @@ #include "TMVA/Reader.h" namespace l1t { - class HGC3DClusterTMVASelector : public edm::stream::EDProducer<> { - public: - explicit HGC3DClusterTMVASelector(const edm::ParameterSet&) ; - ~HGC3DClusterTMVASelector() override {} + class HGC3DClusterTMVASelector : public edm::stream::EDProducer<> { + public: + explicit HGC3DClusterTMVASelector(const edm::ParameterSet &); + ~HGC3DClusterTMVASelector() override {} - private: - class Var { - public: - Var(const std::string & name, const std::string & expr) : - name_(name), expr_(expr) {} - void declare(TMVA::Reader & r) { r.AddVariable(name_, &val_); } - void fill(const l1t::HGCalMulticluster & c) { val_ = expr_(c); } - private: - std::string name_; - StringObjectFunction expr_; - float val_; - }; + private: + class Var { + public: + Var(const std::string &name, const std::string &expr) : name_(name), expr_(expr) {} + void declare(TMVA::Reader &r) { r.AddVariable(name_, &val_); } + void fill(const l1t::HGCalMulticluster &c) { val_ = expr_(c); } - edm::EDGetTokenT src_; - StringCutObjectSelector preselection_; - std::vector variables_; - std::string method_, weightsFile_; - std::unique_ptr reader_; - StringObjectFunction wp_; + private: + std::string name_; + StringObjectFunction expr_; + float val_; + }; + edm::EDGetTokenT src_; + StringCutObjectSelector preselection_; + std::vector variables_; + std::string method_, weightsFile_; + std::unique_ptr reader_; + StringObjectFunction wp_; - void produce(edm::Event&, const edm::EventSetup&) override; + void produce(edm::Event &, const edm::EventSetup &) override; - }; // class -} // namespace + }; // class +} // namespace l1t -l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector(const edm::ParameterSet & iConfig) : - src_(consumes(iConfig.getParameter("src"))), - preselection_(iConfig.getParameter("preselection")), - method_(iConfig.getParameter("method")), - weightsFile_(iConfig.getParameter("weightsFile")), - reader_(new TMVA::Reader()), - wp_(iConfig.getParameter("wp")) -{ - // first create all the variables - for (const auto & psvar : iConfig.getParameter>("variables")) { - variables_.emplace_back(psvar.getParameter("name"), psvar.getParameter("value")); - } - // then declare them - for (auto & var : variables_) var.declare(*reader_); - // then read the weights - if (weightsFile_[0] != '/' && weightsFile_[0] != '.') { - weightsFile_ = edm::FileInPath(weightsFile_).fullPath(); - } - reco::details::loadTMVAWeights(&*reader_, method_, weightsFile_); - // finally, declare outputs - produces(); - produces("fail"); +l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector(const edm::ParameterSet &iConfig) + : src_(consumes(iConfig.getParameter("src"))), + preselection_(iConfig.getParameter("preselection")), + method_(iConfig.getParameter("method")), + weightsFile_(iConfig.getParameter("weightsFile")), + reader_(new TMVA::Reader()), + wp_(iConfig.getParameter("wp")) { + // first create all the variables + for (const auto &psvar : iConfig.getParameter>("variables")) { + variables_.emplace_back(psvar.getParameter("name"), psvar.getParameter("value")); + } + // then declare them + for (auto &var : variables_) + var.declare(*reader_); + // then read the weights + if (weightsFile_[0] != '/' && weightsFile_[0] != '.') { + weightsFile_ = edm::FileInPath(weightsFile_).fullPath(); + } + reco::details::loadTMVAWeights(&*reader_, method_, weightsFile_); + // finally, declare outputs + produces(); + produces("fail"); } - -void -l1t::HGC3DClusterTMVASelector::produce(edm::Event & iEvent, const edm::EventSetup &) -{ +void l1t::HGC3DClusterTMVASelector::produce(edm::Event &iEvent, const edm::EventSetup &) { std::unique_ptr out = std::make_unique(); std::unique_ptr fail = std::make_unique(); @@ -79,18 +75,19 @@ l1t::HGC3DClusterTMVASelector::produce(edm::Event & iEvent, const edm::EventSetu iEvent.getByToken(src_, multiclusters); for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) { - for(auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { - const auto & c = *it; - if (preselection_(c)) { - for (auto & var : variables_) var.fill(c); - float mvaOut = reader_->EvaluateMVA(method_); - if (mvaOut > wp_(c)) { - out->push_back(bx, c); - } else { - fail->push_back(bx, c); - } - } + for (auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) { + const auto &c = *it; + if (preselection_(c)) { + for (auto &var : variables_) + var.fill(c); + float mvaOut = reader_->EvaluateMVA(method_); + if (mvaOut > wp_(c)) { + out->push_back(bx, c); + } else { + fail->push_back(bx, c); + } } + } } iEvent.put(std::move(out)); diff --git a/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc b/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc index c866ee2bdfe25..0faad8576fd3c 100644 --- a/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc +++ b/L1Trigger/L1THGCalUtilities/src/HGCalTriggerNtupleBase.cc @@ -1,6 +1,3 @@ #include "L1Trigger/L1THGCalUtilities/interface/HGCalTriggerNtupleBase.h" -EDM_REGISTER_PLUGINFACTORY(HGCalTriggerNtupleFactory, - "HGCalTriggerNtupleFactory"); - - +EDM_REGISTER_PLUGINFACTORY(HGCalTriggerNtupleFactory, "HGCalTriggerNtupleFactory"); From d4dd4a41193109c50c820ecaa0085dfbbd7b02e4 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 15 Apr 2019 10:11:56 +0200 Subject: [PATCH 642/686] Adapt the Merge config to use the same option as the unit tests. This change is not tested itself, but the unit tests cover the merging behaviour and pass with the option set. --- Configuration/DataProcessing/python/Merge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/DataProcessing/python/Merge.py b/Configuration/DataProcessing/python/Merge.py index 915886f804535..e3207879d61d8 100644 --- a/Configuration/DataProcessing/python/Merge.py +++ b/Configuration/DataProcessing/python/Merge.py @@ -52,7 +52,7 @@ def mergeProcess(*inputFiles, **options): #// if newDQMIO: process.source = Source("DQMRootSource") - process.add_(Service("DQMStore")) + process.add_(Service("DQMStore", forceResetOnBeginLumi = CfgTypes.untracked.bool(True))) else: process.source = Source("PoolSource") if bypassVersionCheck: From f043ae9e5f4c33210469a23e6e643d3df998ea72 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 15 Apr 2019 10:36:48 +0200 Subject: [PATCH 643/686] python test updates for new sklearn version - droppoing deepdish as it appears to be no longer developed --- .../PythonAnalysis/test/BuildFile.xml | 2 - .../PythonAnalysis/test/testDeepDish.py | 15 ------ .../PythonAnalysis/test/testTheanets.py | 49 ------------------- .../test/testXGBoost_and_sklearn.py | 2 +- 4 files changed, 1 insertion(+), 67 deletions(-) delete mode 100755 PhysicsTools/PythonAnalysis/test/testDeepDish.py delete mode 100755 PhysicsTools/PythonAnalysis/test/testTheanets.py diff --git a/PhysicsTools/PythonAnalysis/test/BuildFile.xml b/PhysicsTools/PythonAnalysis/test/BuildFile.xml index 0bd9f0e90be3f..e8393aba11c14 100644 --- a/PhysicsTools/PythonAnalysis/test/BuildFile.xml +++ b/PhysicsTools/PythonAnalysis/test/BuildFile.xml @@ -11,13 +11,11 @@ - -# diff --git a/PhysicsTools/PythonAnalysis/test/testDeepDish.py b/PhysicsTools/PythonAnalysis/test/testDeepDish.py deleted file mode 100755 index c25236dc2d296..0000000000000 --- a/PhysicsTools/PythonAnalysis/test/testDeepDish.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python -#adapted from http://deepdish.readthedocs.io/en/latest/io.html#dictionaries - -from __future__ import print_function -import numpy as np -import pandas as pd -import deepdish as dd - -df = pd.DataFrame({'int': np.arange(3), 'name': ['zero', 'one', 'two']}) - -dd.io.save('test.h5', df) - -d = dd.io.load('test.h5') - -print(d) diff --git a/PhysicsTools/PythonAnalysis/test/testTheanets.py b/PhysicsTools/PythonAnalysis/test/testTheanets.py deleted file mode 100755 index d24d3e3db1731..0000000000000 --- a/PhysicsTools/PythonAnalysis/test/testTheanets.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -#curl http://www.gutenberg.org/cache/epub/2701/pg2701.txt > corpus.txt - -from __future__ import print_function -import numpy as np, re, theanets - -chars = re.sub(r'\s+', ' ', open('corpus.txt').read().lower()) -txt = theanets.recurrent.Text(chars, min_count=10) -A = 1 + len(txt.alpha) # of letter classes - -# create a model to train: input -> gru -> relu -> softmax. -net = theanets.recurrent.Classifier([ - A, (100, 'gru'), (1000, 'relu'), A]) - -# train the model iteratively; draw a sample after every epoch. -seed = txt.encode(txt.text[300017:300050]) -for tm, _ in net.itertrain(txt.classifier_batches(100, 32), momentum=0.9): - print('{}|{} ({:.1f}%)'.format( - txt.decode(seed), - txt.decode(net.predict_sequence(seed, 40)), - 100 * tm['acc'])) - - -import climate -import theanets -from sklearn.datasets import make_classification -from sklearn.metrics import confusion_matrix - -climate.enable_default_logging() - -# Create a classification dataset. -X, y = make_classification( - n_samples=3000, n_features=100, n_classes=10, n_informative=10) -X = X.astype('f') -y = y.astype('i') -cut = int(len(X) * 0.8) # training / validation split -train = X[:cut], y[:cut] -valid = X[cut:], y[cut:] - -# Build a classifier model with 100 inputs and 10 outputs. -net = theanets.Classifier([100, 10]) - -# Train the model using SGD with momentum. -net.train(train, valid, algo='sgd', learning_rate=1e-4, momentum=0.9) - -# Show confusion matrices on the training/validation splits. -for label, (X, y) in (('training:', train), ('validation:', valid)): - print(label) - print(confusion_matrix(y, net.predict(X))) diff --git a/PhysicsTools/PythonAnalysis/test/testXGBoost_and_sklearn.py b/PhysicsTools/PythonAnalysis/test/testXGBoost_and_sklearn.py index 0e0cf36f5dadb..8d2d73464dcda 100755 --- a/PhysicsTools/PythonAnalysis/test/testXGBoost_and_sklearn.py +++ b/PhysicsTools/PythonAnalysis/test/testXGBoost_and_sklearn.py @@ -5,7 +5,7 @@ import numpy as np import xgboost as xgb from sklearn import datasets -from sklearn.cross_validation import train_test_split +from sklearn.model_selection import train_test_split from sklearn.datasets import dump_svmlight_file from sklearn.externals import joblib from sklearn.metrics import precision_score From 5cae020bc92fac5b96318e1b1b86f083551a23f9 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 9 Apr 2019 08:38:42 +0200 Subject: [PATCH 644/686] Removed hardcoded IOV. --- CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc index b1f98f3842c13..5f94a48bf9cc6 100644 --- a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc +++ b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc @@ -53,14 +53,6 @@ CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) { - // TODO: the IOV specified in config is temporarily replaced with a hardcoded one - edm::IOVSyncValue beg(edm::EventID(270293, 0, 0), edm::Timestamp(1461016800ULL << 32)); - edm::IOVSyncValue end(edm::EventID(290872, 0, 0), edm::Timestamp(1483138800ULL << 32)); - oValidity = edm::ValidityInterval(beg, end); - - m_insideValidityRange = (beg < iosv && iosv < end); - - /* if (edm::contains(m_validityRange, iosv.eventID())) { m_insideValidityRange = true; @@ -83,7 +75,6 @@ void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecor oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); } } - */ } //---------------------------------------------------------------------------------------------------- From 86a7fe53d2b6b6e3f81f4d910dd0c7223a0db9ff Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Tue, 9 Apr 2019 08:42:00 +0200 Subject: [PATCH 645/686] By default, LHCInfo and optical functions loaded from DB. --- .../ESProducers/python/ctppsLHCInfo_cff.py | 18 +++++---- .../python/ctppsOpticalFunctions_cff.py | 40 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py index f7ecf58fd6561..3403647fe8463 100644 --- a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py +++ b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py @@ -1,11 +1,13 @@ import FWCore.ParameterSet.Config as cms -ctppsLHCInfoLabel = cms.string("ctpps_minimal") +# by default, LHCInfo is now loaded from CondDB using a GT +ctppsLHCInfoLabel = cms.string("") -# minimal LHCInfo for 2016 data -ctppsLHCInfoESSource_2016 = cms.ESSource("CTPPSLHCInfoESSource", - label = ctppsLHCInfoLabel, - validityRange = cms.EventRange("270293:min - 290872:max"), - beamEnergy = cms.double(6500), # GeV - xangle = cms.double(185) # murad -) +## minimal LHCInfo for 2016 data +#ctppsLHCInfoLabel = cms.string("ctpps_minimal") +#ctppsLHCInfoESSource_2016 = cms.ESSource("CTPPSLHCInfoESSource", +# label = ctppsLHCInfoLabel, +# validityRange = cms.EventRange("270293:min - 290872:max"), +# beamEnergy = cms.double(6500), # GeV +# xangle = cms.double(185) # murad +#) diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py index 05c2dae04514e..a114bb9ad8249 100644 --- a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -2,26 +2,28 @@ from CalibPPS.ESProducers.ctppsLHCInfo_cff import * -from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import * +# by default, (raw) optical functions are now loaded from CondDB using a GT -# add 2016 pre-TS2 configuration -config_2016_preTS2 = cms.PSet( - validityRange = cms.EventRange("273725:min - 280385:max"), - - opticalFunctions = cms.VPSet( - cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) - ), - - scoringPlanes = cms.VPSet( - # z in cm - cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002, strip - cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003, strip - cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102, strip - cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103, strip - ) -) - -ctppsOpticalFunctionsESSource.configuration.append(config_2016_preTS2) +#from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import * +# +## add 2016 pre-TS2 configuration +#config_2016_preTS2 = cms.PSet( +# validityRange = cms.EventRange("273725:min - 280385:max"), +# +# opticalFunctions = cms.VPSet( +# cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) +# ), +# +# scoringPlanes = cms.VPSet( +# # z in cm +# cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002, strip +# cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003, strip +# cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102, strip +# cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103, strip +# ) +#) +# +#ctppsOpticalFunctionsESSource.configuration.append(config_2016_preTS2) # optics interpolation between crossing angles from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import * From 7ddaaa47dac1d6efef5d77d546c92eb35a16ca0d Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 15 Apr 2019 11:24:58 +0200 Subject: [PATCH 646/686] Change the path prefix to allow reading non-CERN files. --- DQMServices/Components/scripts/dqmiodatasetharvest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DQMServices/Components/scripts/dqmiodatasetharvest.py b/DQMServices/Components/scripts/dqmiodatasetharvest.py index f7a05623df7ef..7226bfb9ff96a 100755 --- a/DQMServices/Components/scripts/dqmiodatasetharvest.py +++ b/DQMServices/Components/scripts/dqmiodatasetharvest.py @@ -8,6 +8,10 @@ import subprocess import multiprocessing + +ROOTPREFIX = "root://cms-xrd-global.cern.ch/" +#ROOTPREFIX = "root://eoscms//eos/cms" # for more local files + parser = argparse.ArgumentParser(description="Collect a MEs from DQMIO data, with maximum possible granularity") parser.add_argument('dataset', help='dataset name, like "/StreamHIExpress/HIRun2018A-Express-v1/DQMIO"') @@ -173,7 +177,7 @@ def dasquery(dataset): db.execute(makeindex) def harvestfile(fname): - f = ROOT.TFile.Open("root://eoscms//eos/cms" + fname) + f = ROOT.TFile.Open(ROOTPREFIX + fname) idxtree = getattr(f, "Indices") #idxtree.GetEntry._threaded = True # now the blocking call should release the GIL... From 11dcb2c124ffe547d58142516423b6dd4519e93d Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Sat, 23 Mar 2019 13:05:58 +0100 Subject: [PATCH 647/686] DataFormat updates to add digi-based shower info --- DataFormats/MuonReco/interface/Muon.h | 11 ++++++- .../MuonReco/interface/MuonChamberMatch.h | 25 +++++++++------- DataFormats/MuonReco/src/Muon.cc | 29 +++++++++++++++++++ DataFormats/MuonReco/src/classes_def.xml | 3 +- 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index 6cd9b15a91469..4877ca34056df 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -185,6 +185,9 @@ namespace reco { enum ArbitrationType { NoArbitration, SegmentArbitration, SegmentAndTrackArbitration, SegmentAndTrackArbitrationCleaned, RPCHitAndTrackArbitration, GEMSegmentAndTrackArbitration, ME0SegmentAndTrackArbitration }; + + /// ranges to be used for digi-based shower counting + enum DigiRange { FullChamber, InRange }; /// /// ====================== STANDARD SELECTORS =========================== @@ -260,7 +263,13 @@ namespace reco { unsigned int stationGapMaskDistance( float distanceCut = 10. ) const; /// same as above for given number of sigmas unsigned int stationGapMaskPull( float sigmaCut = 3. ) const; - + /// # of digis in a given station layer + /// index 0-1-2-3 = DT stations 1-2-3-4 /// index 4-5-6-7 = CSC stations 1-2-3-4 + int nDigisInStation( int index, DigiRange range = InRange ) const; + /// # of digis in a given station layer + /// index 0-1-2-3 = DT stations 1-2-3-4 /// index 4-5-6-7 = CSC stations 1-2-3-4 + bool hasShowerInStation( int index, DigiRange range = InRange, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; + /// muon type - type of the algorithm that reconstructed this muon /// multiple algorithms can reconstruct the same muon static const unsigned int GlobalMuon = 1<<1; diff --git a/DataFormats/MuonReco/interface/MuonChamberMatch.h b/DataFormats/MuonReco/interface/MuonChamberMatch.h index 41ec1a99a039f..e59ce2396e0f5 100644 --- a/DataFormats/MuonReco/interface/MuonChamberMatch.h +++ b/DataFormats/MuonReco/interface/MuonChamberMatch.h @@ -14,17 +14,20 @@ namespace reco { std::vector me0Matches; // segments matching propagated track trajectory std::vector truthMatches; // SimHit projection matching propagated track trajectory std::vector rpcMatches; // rpc hits matching propagated track trajectory - float edgeX; // distance to closest edge in X (negative - inside, positive - outside) - float edgeY; // distance to closest edge in Y (negative - inside, positive - outside) - float x; // X position of the track - float y; // Y position of the track - float xErr; // propagation uncertainty in X - float yErr; // propagation uncertainty in Y - float dXdZ; // dX/dZ of the track - float dYdZ; // dY/dZ of the track - float dXdZErr; // propagation uncertainty in dX/dZ - float dYdZErr; // propagation uncertainty in dY/dZ - DetId id; // chamber ID + float edgeX; // distance to closest edge in X (negative - inside, positive - outside) + float edgeY; // distance to closest edge in Y (negative - inside, positive - outside) + float x; // X position of the track + float y; // Y position of the track + float xErr; // propagation uncertainty in X + float yErr; // propagation uncertainty in Y + float dXdZ; // dX/dZ of the track + float dYdZ; // dY/dZ of the track + float dXdZErr; // propagation uncertainty in dX/dZ + float dYdZErr; // propagation uncertainty in dY/dZ + DetId id; // chamber ID + + int nDigisInChamb; // # of DT/CSC digis in the chamber + int nDigisInRange; // # of DT/CSC digis in the chamber close-by to the propagated track int detector() const { return id.subdetId(); } int station() const; diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index c6103c6b86fb6..6632f22f5d768 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -334,6 +334,35 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const return totMask; } +int Muon::nDigisInStation( int index, DigiRange range ) const +{ + + int nDigis(0); + + for ( auto & match : muMatches_ ) + { + if ( match.detector() != MuonSubdetId::CSC && + match.detector() != MuonSubdetId::DT ) + continue; + + int nDigisInCh = range == InRange ? match.nDigisInRange : match.nDigisInChamb; + int iStation = match.detector() == MuonSubdetId::CSC ? index - 3 : index + 1; + + if( iStation == match.station() && nDigisInCh > nDigis) + nDigis = nDigisInCh; + } + + return nDigis; +} + +bool Muon::hasShowerInStation( int index, DigiRange range, int nDtDigisCut, int nCscDigisCut ) const +{ + bool hasShower = index < 4 ? + nDigisInStation(index, range) >= nDtDigisCut : + nDigisInStation(index, range) >= nCscDigisCut; + return hasShower; +} + int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const { int segments(0); diff --git a/DataFormats/MuonReco/src/classes_def.xml b/DataFormats/MuonReco/src/classes_def.xml index 01472efb81161..2ca313a9147d1 100644 --- a/DataFormats/MuonReco/src/classes_def.xml +++ b/DataFormats/MuonReco/src/classes_def.xml @@ -57,7 +57,8 @@ initial version number of a class which has never been stored before. - + + From 5d065c08c4710b3bd4aea7edfccb9913ba806668 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Sun, 24 Mar 2019 18:33:46 +0100 Subject: [PATCH 648/686] Fix: merge digis from ME1/1a and ME1/1b --- DataFormats/MuonReco/src/Muon.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index 6632f22f5d768..c8f0a0f938f47 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -336,8 +336,8 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const int Muon::nDigisInStation( int index, DigiRange range ) const { - int nDigis(0); + std::map me11DigisPerCh; for ( auto & match : muMatches_ ) { @@ -348,10 +348,36 @@ int Muon::nDigisInStation( int index, DigiRange range ) const int nDigisInCh = range == InRange ? match.nDigisInRange : match.nDigisInChamb; int iStation = match.detector() == MuonSubdetId::CSC ? index - 3 : index + 1; + if( match.detector() == MuonSubdetId::CSC && iStation == 1) + { + CSCDetId id(match.id.rawId()); + + int station = id.station(); + int chamber = id.chamber(); + int ring = id.ring(); + + if ( station == 1 && (ring == 1 || ring == 4) ) // merge ME1/1a and ME1/1b digis + { + if(me11DigisPerCh.find(chamber) == me11DigisPerCh.end()) + me11DigisPerCh[chamber] = 0; + + me11DigisPerCh[chamber] += nDigisInCh; + + continue; + } + } + if( iStation == match.station() && nDigisInCh > nDigis) nDigis = nDigisInCh; } + for (const auto & me11DigisInCh : me11DigisPerCh) + { + int nMe11DigisInCh = me11DigisInCh.second; + if (nMe11DigisInCh > nDigis) + nDigis = nMe11DigisInCh; + } + return nDigis; } From 708b771073f43826f35cb4115b8494d08404b79b Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Sun, 24 Mar 2019 18:36:28 +0100 Subject: [PATCH 649/686] Add filling of digi-based shower information to MuonIdProducer --- .../interface/MuonShowerDigiFiller.h | 75 +++++++++ .../plugins/MuonIdProducer.cc | 27 ++- .../plugins/MuonIdProducer.h | 6 +- .../python/MuonShowerDigiFiller_cfi.py | 11 ++ .../python/muons1stStep_cfi.py | 4 + .../src/MuonShowerDigiFiller.cc | 157 ++++++++++++++++++ 6 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h create mode 100644 RecoMuon/MuonIdentification/python/MuonShowerDigiFiller_cfi.py create mode 100644 RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc diff --git a/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h b/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h new file mode 100644 index 0000000000000..004adc2f8c520 --- /dev/null +++ b/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h @@ -0,0 +1,75 @@ +#ifndef MuonIdentification_MuonShowerDigiFiller_h +#define MuonIdentification_MuonShowerDigiFiller_h + +// -*- C++ -*- +// +// Package: MuonShowerDigiFiller +// Class: MuonShowerDigiFiller +// +/**\class MuonShowerDigiFiller MuonShowerDigiFiller.h RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h + + Description: Class filling shower information using DT and CSC digis + + Implementation: + +*/ +// +// Original Author: Carlo Battilana, INFN BO +// Created: Sat Mar 23 14:36:22 CET 2019 +// +// + +// system include files + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + +#include "DataFormats/DTDigi/interface/DTDigiCollection.h" +#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h" + +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" + +#include "DataFormats/MuonReco/interface/MuonChamberMatch.h" +#include "TrackingTools/TrackAssociator/interface/TAMuonChamberMatch.h" + +// +// class decleration +// + +class MuonShowerDigiFiller +{ + + public: + + MuonShowerDigiFiller(const edm::ParameterSet&, edm::ConsumesCollector&& iC); + ~MuonShowerDigiFiller(); + + void getES( const edm::EventSetup& iSetup ); + void getDigis( edm::Event& iEvent ); + + void fill( reco::MuonChamberMatch & muChMatch ) const; + + private: + + double m_digiMaxDistanceX; + + edm::EDGetTokenT m_dtDigisToken; + edm::EDGetTokenT m_cscDigisToken; + + edm::ESHandle m_dtGeometry; + edm::ESHandle m_cscGeometry; + + edm::Handle m_dtDigis; + edm::Handle m_cscDigis; + +}; + +#endif diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index b8585e2961f4f..9bf87a6ef8423 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -59,6 +59,7 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig) storeCrossedHcalRecHits_ = iConfig.getParameter("storeCrossedHcalRecHits"); fillMatching_ = iConfig.getParameter("fillMatching"); fillIsolation_ = iConfig.getParameter("fillIsolation"); + fillShowerDigis_ = iConfig.getParameter("fillShowerDigis"); writeIsoDeposits_ = iConfig.getParameter("writeIsoDeposits"); fillGlobalTrackQuality_ = iConfig.getParameter("fillGlobalTrackQuality"); fillGlobalTrackRefits_ = iConfig.getParameter("fillGlobalTrackRefits"); @@ -80,7 +81,13 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig) // Load parameters for the TimingFiller edm::ParameterSet timingParameters = iConfig.getParameter("TimingFillerParameters"); theTimingFiller_ = std::make_unique(timingParameters,consumesCollector()); - + + // Load parameters for the ShowerDigiFiller + if (fillShowerDigis_ && fillMatching_) + { + edm::ParameterSet showerDigiParameters = iConfig.getParameter("ShowerDigiFillerParameters"); + theShowerDigiFiller_ = std::make_unique(showerDigiParameters,consumesCollector()); + } if (fillCaloCompatibility_){ // Load MuonCaloCompatibility parameters @@ -426,6 +433,8 @@ void MuonIdProducer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetu meshAlgo_->setCSCGeometry(geomHandle.product()); + if (fillShowerDigis_ && fillMatching_) + theShowerDigiFiller_->getES(iSetup); } bool validateGlobalMuonPair( const reco::MuonTrackLinks& goodMuon, @@ -450,6 +459,9 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) init(iEvent, iSetup); + if (fillShowerDigis_ && fillMatching_) + theShowerDigiFiller_->getDigis(iEvent); + // loop over input collections // muons first - no cleaning, take as is. @@ -876,6 +888,15 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu matchedChamber.edgeY = chamber.localDistanceY; matchedChamber.id = chamber.id; + + if (fillShowerDigis_) { + theShowerDigiFiller_->fill(matchedChamber); + } + else { + matchedChamber.nDigisInChamb = 0; + matchedChamber.nDigisInRange = 0; + } + if ( ! chamber.segments.empty() ) ++nubmerOfMatchesAccordingToTrackAssociator; // fill segments @@ -958,6 +979,9 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu matchedChamber.edgeX = chamber.localDistanceX; matchedChamber.edgeY = chamber.localDistanceY; + matchedChamber.nDigisInChamb = 0; + matchedChamber.nDigisInRange = 0; + matchedChamber.id = chamber.id; for ( const auto& rpcRecHit : *rpcHitHandle_ ) @@ -1324,6 +1348,7 @@ void MuonIdProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptio desc.add("arbitrateTrackerMuons",false); desc.add("storeCrossedHcalRecHits",false); + desc.add("fillShowerDigis",false); edm::ParameterSetDescription descTrkAsoPar; descTrkAsoPar.add("GEMSegmentCollectionLabel",edm::InputTag("gemSegments")); diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h index 9491de85caa8f..3da90a54c8862 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.h @@ -47,8 +47,9 @@ #include "RecoMuon/MuonIdentification/interface/MuonTimingFiller.h" #include "RecoMuon/MuonIdentification/interface/MuonCaloCompatibility.h" #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractor.h" -// RPC-Muon stuffs +#include "RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h" +// RPC-Muon stuffs #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/MuonReco/interface/MuonRPCHitMatch.h" @@ -177,6 +178,8 @@ class MuonIdProducer : public edm::stream::EDProducer<> { std::unique_ptr theTimingFiller_; + std::unique_ptr theShowerDigiFiller_; + // selections double minPt_; double minP_; @@ -196,6 +199,7 @@ class MuonIdProducer : public edm::stream::EDProducer<> { bool fillEnergy_; bool storeCrossedHcalRecHits_; bool fillMatching_; + bool fillShowerDigis_; bool fillIsolation_; bool writeIsoDeposits_; double ptThresholdToFillCandidateP4WithGlobalFit_; diff --git a/RecoMuon/MuonIdentification/python/MuonShowerDigiFiller_cfi.py b/RecoMuon/MuonIdentification/python/MuonShowerDigiFiller_cfi.py new file mode 100644 index 0000000000000..9e3039059a3f6 --- /dev/null +++ b/RecoMuon/MuonIdentification/python/MuonShowerDigiFiller_cfi.py @@ -0,0 +1,11 @@ +import FWCore.ParameterSet.Config as cms + +MuonShowerDigiFillerBlock = cms.PSet( + ShowerDigiFillerParameters = cms.PSet( + digiMaxDistanceX = cms.double(25.0), + dtDigiCollectionLabel = cms.InputTag("muonDTDigis"), + cscDigiCollectionLabel = cms.InputTag("muonCSCDigis","MuonCSCStripDigi") + ) +) + + diff --git a/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py b/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py index 73d78ab22e234..cc4961e9be4c5 100644 --- a/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py +++ b/RecoMuon/MuonIdentification/python/muons1stStep_cfi.py @@ -4,6 +4,7 @@ from RecoMuon.MuonIdentification.isolation_cff import * from RecoMuon.MuonIdentification.caloCompatibility_cff import * from RecoMuon.MuonIdentification.MuonTimingFiller_cfi import * +from RecoMuon.MuonIdentification.MuonShowerDigiFiller_cfi import * from RecoMuon.MuonIdentification.TrackerKinkFinder_cfi import * from TrackingTools.TrackAssociator.default_cfi import * muons1stStep = cms.EDProducer("MuonIdProducer", @@ -15,6 +16,8 @@ MIdIsoExtractorPSetBlock, # MuonTiming TimingFillerBlock, + # MuonShowerDigi + MuonShowerDigiFillerBlock, # Kink finder TrackerKinkFinderParametersBlock, @@ -55,6 +58,7 @@ writeIsoDeposits = cms.bool(True), minNumberOfMatches = cms.int32(1), fillMatching = cms.bool(True), + fillShowerDigis = cms.bool(True), # global fit for candidate p4 requirements ptThresholdToFillCandidateP4WithGlobalFit = cms.double(200.0), diff --git a/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc new file mode 100644 index 0000000000000..6b857a7b77723 --- /dev/null +++ b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc @@ -0,0 +1,157 @@ +// +// Package: MuonShowerDigiFiller +// Class: MuonShowerDigiFiller +// +/**\class MuonShowerDigiFiller MuonShowerDigiFiller.cc RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc + + Description: Class filling shower information using DT and CSC digis + + Implementation: + +*/ +// +// Original Author: Carlo Battilana, INFN BO +// Created: Sat Mar 23 14:36:22 CET 2019 +// +// + + +// system include files + +// user include files +#include "RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h" + +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +// +// constructors and destructor +// + +MuonShowerDigiFiller::MuonShowerDigiFiller(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC) : + m_digiMaxDistanceX(iConfig.getParameter("digiMaxDistanceX")) + +{ + + edm::InputTag label = iConfig.getParameter("dtDigiCollectionLabel"); + m_dtDigisToken=iC.consumes(label); + + label = iConfig.getParameter("cscDigiCollectionLabel"); + m_cscDigisToken=iC.consumes(label); + +} + + +MuonShowerDigiFiller::~MuonShowerDigiFiller() +{ + +} + + +// +// member functions +// + +void +MuonShowerDigiFiller::getES( const edm::EventSetup& iSetup ) +{ + + iSetup.get().get(m_dtGeometry); + iSetup.get().get(m_cscGeometry); + +} + +void +MuonShowerDigiFiller::getDigis( edm::Event& iEvent ) +{ + + iEvent.getByToken(m_dtDigisToken, m_dtDigis); + iEvent.getByToken(m_cscDigisToken, m_cscDigis); + +} + +void +MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const +{ + + int nDigisInChamb = 0; + int nDigisInRange = 0; + + // DT chamber + if( muChMatch.detector() == MuonSubdetId::DT ) + { + double xTrack = muChMatch.x; + + for (int sl = 1; sl < 4; sl += 2) + { + for (int layer = 1; layer < 5; ++layer) + { + const DTLayerId layerId(DTChamberId(muChMatch.id.rawId()),sl,layer); + + auto range = m_dtDigis->get(layerId); + + for (auto digiIt = range.first ;digiIt!=range.second; ++digiIt) + { + const auto topo = m_dtGeometry->layer(layerId)->specificTopology(); + + double xWire = topo.wirePosition((*digiIt).wire()); + double dX = std::abs(xWire - xTrack); + + nDigisInChamb++; + if (dX < m_digiMaxDistanceX) + nDigisInRange++; + } + } + } + } + + else if(muChMatch.detector() == MuonSubdetId::CSC) + { + + double xTrack = muChMatch.x; + double yTrack = muChMatch.y; + + for (int iLayer = 1; iLayer < 7; ++iLayer) + { + const CSCDetId chId(muChMatch.id.rawId()); + const CSCDetId layerId(chId.endcap(), chId.station(), + chId.ring(), chId.chamber(), + iLayer); + + auto range = m_cscDigis->get(layerId); + + for (auto digiIt = range.first ;digiIt!=range.second; ++digiIt) + { + + std::vector adcVals = digiIt->getADCCounts(); + bool hasFired = false; + float pedestal = 0.5*(float)(adcVals[0]+adcVals[1]); + float threshold = 13.3 ; + float diff = 0.; + for (const auto & adcVal : adcVals) + { + diff = (float)adcVal - pedestal; + if (diff > threshold) + { + hasFired = true; + break; + } + } + + if (!hasFired) continue; + + const CSCLayerGeometry* layerGeom = m_cscGeometry->layer(layerId)->geometry(); + + Float_t xStrip = layerGeom->xOfStrip(digiIt->getStrip(), yTrack); + float dX = std::abs(xStrip - xTrack); + + nDigisInChamb++; + if (dX < m_digiMaxDistanceX) + nDigisInRange++; + } + } + } + + muChMatch.nDigisInChamb = nDigisInChamb; + muChMatch.nDigisInRange = nDigisInRange; + +} From 549abd64d98abcd0242100d7518b1cb2455b8006 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Thu, 4 Apr 2019 14:29:30 +0200 Subject: [PATCH 650/686] Remove digi counting in full chamber, leaving only digi counting in |dX| range --- DataFormats/MuonReco/interface/Muon.h | 15 +++++++-------- DataFormats/MuonReco/interface/MuonChamberMatch.h | 1 - DataFormats/MuonReco/src/Muon.cc | 10 +++++----- DataFormats/MuonReco/src/classes_def.xml | 2 +- .../MuonIdentification/plugins/MuonIdProducer.cc | 2 -- .../src/MuonShowerDigiFiller.cc | 4 ---- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index 4877ca34056df..be5edaf74495e 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -186,9 +186,6 @@ namespace reco { enum ArbitrationType { NoArbitration, SegmentArbitration, SegmentAndTrackArbitration, SegmentAndTrackArbitrationCleaned, RPCHitAndTrackArbitration, GEMSegmentAndTrackArbitration, ME0SegmentAndTrackArbitration }; - /// ranges to be used for digi-based shower counting - enum DigiRange { FullChamber, InRange }; - /// /// ====================== STANDARD SELECTORS =========================== /// @@ -264,11 +261,13 @@ namespace reco { /// same as above for given number of sigmas unsigned int stationGapMaskPull( float sigmaCut = 3. ) const; /// # of digis in a given station layer - /// index 0-1-2-3 = DT stations 1-2-3-4 /// index 4-5-6-7 = CSC stations 1-2-3-4 - int nDigisInStation( int index, DigiRange range = InRange ) const; - /// # of digis in a given station layer - /// index 0-1-2-3 = DT stations 1-2-3-4 /// index 4-5-6-7 = CSC stations 1-2-3-4 - bool hasShowerInStation( int index, DigiRange range = InRange, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; + /// index 0-1-2-3 = DT stations 1-2-3-4 + /// index 4-5-6-7 = CSC stations 1-2-3-4 + int nDigisInStation( int index) const; + /// tag a shower in a given station layer + /// index 0-1-2-3 = DT stations 1-2-3-4 + /// index 4-5-6-7 = CSC stations 1-2-3-4 + bool hasShowerInStation( int index, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; /// muon type - type of the algorithm that reconstructed this muon /// multiple algorithms can reconstruct the same muon diff --git a/DataFormats/MuonReco/interface/MuonChamberMatch.h b/DataFormats/MuonReco/interface/MuonChamberMatch.h index e59ce2396e0f5..f68a1aac7c5c0 100644 --- a/DataFormats/MuonReco/interface/MuonChamberMatch.h +++ b/DataFormats/MuonReco/interface/MuonChamberMatch.h @@ -26,7 +26,6 @@ namespace reco { float dYdZErr; // propagation uncertainty in dY/dZ DetId id; // chamber ID - int nDigisInChamb; // # of DT/CSC digis in the chamber int nDigisInRange; // # of DT/CSC digis in the chamber close-by to the propagated track int detector() const { return id.subdetId(); } diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index c8f0a0f938f47..0aca784be36a9 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -334,7 +334,7 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const return totMask; } -int Muon::nDigisInStation( int index, DigiRange range ) const +int Muon::nDigisInStation( int index ) const { int nDigis(0); std::map me11DigisPerCh; @@ -345,7 +345,7 @@ int Muon::nDigisInStation( int index, DigiRange range ) const match.detector() != MuonSubdetId::DT ) continue; - int nDigisInCh = range == InRange ? match.nDigisInRange : match.nDigisInChamb; + int nDigisInCh = match.nDigisInRange; int iStation = match.detector() == MuonSubdetId::CSC ? index - 3 : index + 1; if( match.detector() == MuonSubdetId::CSC && iStation == 1) @@ -381,11 +381,11 @@ int Muon::nDigisInStation( int index, DigiRange range ) const return nDigis; } -bool Muon::hasShowerInStation( int index, DigiRange range, int nDtDigisCut, int nCscDigisCut ) const +bool Muon::hasShowerInStation( int index, int nDtDigisCut, int nCscDigisCut ) const { bool hasShower = index < 4 ? - nDigisInStation(index, range) >= nDtDigisCut : - nDigisInStation(index, range) >= nCscDigisCut; + nDigisInStation(index) >= nDtDigisCut : + nDigisInStation(index) >= nCscDigisCut; return hasShower; } diff --git a/DataFormats/MuonReco/src/classes_def.xml b/DataFormats/MuonReco/src/classes_def.xml index 2ca313a9147d1..03703b0181ab0 100644 --- a/DataFormats/MuonReco/src/classes_def.xml +++ b/DataFormats/MuonReco/src/classes_def.xml @@ -58,7 +58,7 @@ initial version number of a class which has never been stored before. - + diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index 9bf87a6ef8423..6344688bcda64 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -893,7 +893,6 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu theShowerDigiFiller_->fill(matchedChamber); } else { - matchedChamber.nDigisInChamb = 0; matchedChamber.nDigisInRange = 0; } @@ -979,7 +978,6 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu matchedChamber.edgeX = chamber.localDistanceX; matchedChamber.edgeY = chamber.localDistanceY; - matchedChamber.nDigisInChamb = 0; matchedChamber.nDigisInRange = 0; matchedChamber.id = chamber.id; diff --git a/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc index 6b857a7b77723..4dcf890c8b476 100644 --- a/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc +++ b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc @@ -73,7 +73,6 @@ void MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const { - int nDigisInChamb = 0; int nDigisInRange = 0; // DT chamber @@ -96,7 +95,6 @@ MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const double xWire = topo.wirePosition((*digiIt).wire()); double dX = std::abs(xWire - xTrack); - nDigisInChamb++; if (dX < m_digiMaxDistanceX) nDigisInRange++; } @@ -144,14 +142,12 @@ MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const Float_t xStrip = layerGeom->xOfStrip(digiIt->getStrip(), yTrack); float dX = std::abs(xStrip - xTrack); - nDigisInChamb++; if (dX < m_digiMaxDistanceX) nDigisInRange++; } } } - muChMatch.nDigisInChamb = nDigisInChamb; muChMatch.nDigisInRange = nDigisInRange; } From a0b754569efc9dc8e0f6609ed58b16bf9c629f75 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Fri, 5 Apr 2019 13:50:22 +0200 Subject: [PATCH 651/686] Add a function that counts showers per muon + cosmetics --- DataFormats/MuonReco/interface/Muon.h | 2 ++ DataFormats/MuonReco/src/Muon.cc | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index be5edaf74495e..05f9f848239e2 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -268,6 +268,8 @@ namespace reco { /// index 0-1-2-3 = DT stations 1-2-3-4 /// index 4-5-6-7 = CSC stations 1-2-3-4 bool hasShowerInStation( int index, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; + /// count the number of showers along a muon track + int numberOfShowers( int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; /// muon type - type of the algorithm that reconstructed this muon /// multiple algorithms can reconstruct the same muon diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index 0aca784be36a9..9e8a29cabf09b 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -348,7 +348,7 @@ int Muon::nDigisInStation( int index ) const int nDigisInCh = match.nDigisInRange; int iStation = match.detector() == MuonSubdetId::CSC ? index - 3 : index + 1; - if( match.detector() == MuonSubdetId::CSC && iStation == 1) + if( match.detector() == MuonSubdetId::CSC && iStation == 1 ) { CSCDetId id(match.id.rawId()); @@ -358,7 +358,7 @@ int Muon::nDigisInStation( int index ) const if ( station == 1 && (ring == 1 || ring == 4) ) // merge ME1/1a and ME1/1b digis { - if(me11DigisPerCh.find(chamber) == me11DigisPerCh.end()) + if( me11DigisPerCh.find(chamber) == me11DigisPerCh.end() ) me11DigisPerCh[chamber] = 0; me11DigisPerCh[chamber] += nDigisInCh; @@ -367,11 +367,11 @@ int Muon::nDigisInStation( int index ) const } } - if( iStation == match.station() && nDigisInCh > nDigis) + if( iStation == match.station() && nDigisInCh > nDigis ) nDigis = nDigisInCh; } - for (const auto & me11DigisInCh : me11DigisPerCh) + for ( const auto & me11DigisInCh : me11DigisPerCh ) { int nMe11DigisInCh = me11DigisInCh.second; if (nMe11DigisInCh > nDigis) @@ -389,6 +389,18 @@ bool Muon::hasShowerInStation( int index, int nDtDigisCut, int nCscDigisCut ) co return hasShower; } +int Muon::numberOfShowers( int nDtDigisCut, int nCscDigisCut ) const +{ + int nShowers = 0; + for ( int iCh = 0; iCh < 8; ++iCh ) + { + if ( hasShowerInStation(iCh,nDtDigisCut,nCscDigisCut) ) + nShowers++; + } + + return nShowers; +} + int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const { int segments(0); From dd4fb7099e39b2018063bfd26e17e26db8d749c9 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Tue, 9 Apr 2019 19:01:48 +0200 Subject: [PATCH 652/686] Disable muon shower info filling in tau MC embedding merge step --- TauAnalysis/MCEmbeddingTools/python/customisers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index 3c480b7009ecf..1f683b7ee7d11 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -367,6 +367,8 @@ def customiseMerging(process, changeProcessname=True,reselect=False): process.muons.FillShoweringInfo = cms.bool(False) process.muons.FillCosmicsIdMap = cms.bool(False) + process.muonsFromCosmics.fillShowerDigis = cms.bool(False) + process.muonsFromCosmics1Leg.fillShowerDigis = cms.bool(False) process.merge_step += process.highlevelreco From e2640f9f5a88c40d02a2359eb8719e0ad2a62709 Mon Sep 17 00:00:00 2001 From: Dmytro Kovalskyi Date: Mon, 15 Apr 2019 11:55:19 +0200 Subject: [PATCH 653/686] updated multiIso working points; dropped unsupported --- PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc index 6a61e358e5653..a20931dbdc374 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc @@ -695,10 +695,7 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu // multi-isolation if (computeMiniIso_){ - - - muon.setSelector(reco::Muon::MultiIsoLoose, miniIsoValue<0.40 && (muon.jetPtRatio() > 0.80 || muon.jetPtRel() > 7.2) ); - muon.setSelector(reco::Muon::MultiIsoMedium, miniIsoValue<0.16 && (muon.jetPtRatio() > 0.76 || muon.jetPtRel() > 7.2) ); + muon.setSelector(reco::Muon::MultiIsoMedium, miniIsoValue<0.11 && (muon.jetPtRatio() > 0.74 || muon.jetPtRel() > 6.8) ); } // MVA working points From b6a0bf4b9ef8b458b5fba2bd6ba9334c8401fbfe Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 15 Apr 2019 12:04:47 +0200 Subject: [PATCH 654/686] Fix prints in root2sqlite.py --- DQMServices/Components/scripts/root2sqlite.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DQMServices/Components/scripts/root2sqlite.py b/DQMServices/Components/scripts/root2sqlite.py index 318a3e4ce2f05..01fb76843217a 100755 --- a/DQMServices/Components/scripts/root2sqlite.py +++ b/DQMServices/Components/scripts/root2sqlite.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import re import json import ROOT @@ -55,7 +56,7 @@ def treetotable(ttree, name): branches = [b.GetName() for b in ttree.GetListOfBranches()] colnames = ", ".join(columnescape(b) for b in branches) create = "CREATE TABLE %s(%s);" % (name, colnames) - print create + print(create) db.execute(create) data = [] for i in range(ttree.GetEntries()): @@ -63,7 +64,7 @@ def treetotable(ttree, name): vals = tuple([tosqlite(getattr(ttree, b)) for b in branches]) data.append(vals) insert = "INSERT INTO %s(%s) VALUES (%s);" % (name, colnames, ",".join(["?"] * len(branches))) - print insert + print(insert) db.executemany(insert, data) def read_objects_root(rootfile): @@ -99,19 +100,19 @@ def parse_directory(di): def save_keyvalue(dictionary, name): name = name.replace("/", "_") create = "CREATE TABLE %s(key, value);" % name - print create + print(create) db.execute(create) data = [] for k, v in dictionary.iteritems(): vals = (unicode(k), tosqlite(v)) data.append(vals) insert = "INSERT INTO %s(key, value) VALUES (?,?);" % name - print insert + print(insert) db.executemany(insert, data) for name, obj, rtype in read_objects_root(f): - print name, obj, rtype + print(name, obj, rtype) if rtype == "TTree": treetotable(obj, name) else: From dc23701a0229973178bf586bd65b05610b0495f1 Mon Sep 17 00:00:00 2001 From: Leonard Apanasevich Date: Mon, 15 Apr 2019 11:19:51 -0500 Subject: [PATCH 655/686] Add trigger bit to emulated GlobalExtBlk to indicate event cannot be due to prefiring of the trigger --- .../python/SimL1EmulatorRepack_Full_cff.py | 16 +++- .../python/SimL1EmulatorRepack_uGT_cff.py | 10 +++ L1Trigger/L1TGlobal/plugins/BuildFile.xml | 1 + .../L1TGlobal/plugins/L1TExtCondProducer.cc | 80 ++++++++++++++++++- .../L1TGlobal/python/simGtExtFakeProd_cfi.py | 2 + 5 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Configuration/StandardSequences/python/SimL1EmulatorRepack_Full_cff.py b/Configuration/StandardSequences/python/SimL1EmulatorRepack_Full_cff.py index 9cc6eb0490c71..61671c9438141 100644 --- a/Configuration/StandardSequences/python/SimL1EmulatorRepack_Full_cff.py +++ b/Configuration/StandardSequences/python/SimL1EmulatorRepack_Full_cff.py @@ -14,7 +14,11 @@ def _print(ignored): (~stage2L1Trigger).toModify(None, lambda x: print("L1T INFO: L1REPACK:Full (intended for 2016 & 2017 data) will unpack all L1T inputs, re-emulated (Stage-2), and pack uGT, uGMT, and Calo Stage-2 output.")) # First, Unpack all inputs to L1: - + +import EventFilter.Utilities.tcdsRawToDigi_cfi +unpackTcds = EventFilter.Utilities.tcdsRawToDigi_cfi.tcdsRawToDigi.clone( + InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess())) + import EventFilter.L1TRawToDigi.bmtfDigis_cfi unpackBmtf = EventFilter.L1TRawToDigi.bmtfDigis_cfi.bmtfDigis.clone( InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess())) @@ -119,6 +123,15 @@ def _print(ignored): simCaloStage2Layer1Digis.ecalToken = 'unpackEcal:EcalTriggerPrimitives' simCaloStage2Layer1Digis.hcalToken = 'unpackLayer1' + +## GT +stage2L1Trigger_2017.toModify(simGtExtFakeStage2Digis, + tcdsRecordLabel= cms.InputTag("unpackTcds","tcdsRecord") +) +stage2L1Trigger.toModify(simGtExtFakeStage2Digis, + tcdsRecordLabel= cms.InputTag("unpackTcds","tcdsRecord") +) + # Finally, pack the new L1T output back into RAW from EventFilter.L1TRawToDigi.caloStage2Raw_cfi import caloStage2Raw as packCaloStage2 @@ -141,6 +154,7 @@ def _print(ignored): SimL1Emulator = cms.Sequence() stage2L1Trigger.toReplaceWith(SimL1Emulator, cms.Sequence(unpackEcal+unpackHcal+unpackCSC+unpackDT+unpackRPC+unpackRPCTwinMux+unpackTwinMux+unpackOmtf+unpackEmtf+unpackCsctf+unpackBmtf +unpackLayer1 + +unpackTcds +SimL1EmulatorCore+packCaloStage2 +packGmtStage2+packGtStage2+rawDataCollector)) diff --git a/Configuration/StandardSequences/python/SimL1EmulatorRepack_uGT_cff.py b/Configuration/StandardSequences/python/SimL1EmulatorRepack_uGT_cff.py index 69835b4a97a99..88a8bbcdc7a25 100644 --- a/Configuration/StandardSequences/python/SimL1EmulatorRepack_uGT_cff.py +++ b/Configuration/StandardSequences/python/SimL1EmulatorRepack_uGT_cff.py @@ -11,12 +11,20 @@ def _print(ignored): stage2L1Trigger.toModify(None, _print) (~stage2L1Trigger).toModify(None, lambda x: print("L1T INFO: L1REPACK:uGT (intended for 2016 data) will unpack uGMT and CaloLaye2 outputs and re-emulate uGT")) + # First, inputs to uGT: import EventFilter.L1TRawToDigi.gtStage2Digis_cfi unpackGtStage2 = EventFilter.L1TRawToDigi.gtStage2Digis_cfi.gtStage2Digis.clone( InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess())) +import EventFilter.Utilities.tcdsRawToDigi_cfi +unpackTcds = EventFilter.Utilities.tcdsRawToDigi_cfi.tcdsRawToDigi.clone( + InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess())) + from L1Trigger.Configuration.SimL1Emulator_cff import * + +simGtExtFakeStage2Digis.tcdsRecordLabel= cms.InputTag("unpackTcds","tcdsRecord") + simGtStage2Digis.MuonInputTag = "unpackGtStage2:Muon" simGtStage2Digis.EGammaInputTag = "unpackGtStage2:EGamma" simGtStage2Digis.TauInputTag = "unpackGtStage2:Tau" @@ -51,6 +59,8 @@ def _print(ignored): SimL1Emulator = cms.Sequence() stage2L1Trigger.toReplaceWith(SimL1Emulator, cms.Sequence(unpackGtStage2 + +unpackTcds + +SimL1TechnicalTriggers +SimL1TGlobal +packGtStage2 +rawDataCollector)) diff --git a/L1Trigger/L1TGlobal/plugins/BuildFile.xml b/L1Trigger/L1TGlobal/plugins/BuildFile.xml index d4461700ce247..8cd9f247db81e 100644 --- a/L1Trigger/L1TGlobal/plugins/BuildFile.xml +++ b/L1Trigger/L1TGlobal/plugins/BuildFile.xml @@ -3,6 +3,7 @@ + diff --git a/L1Trigger/L1TGlobal/plugins/L1TExtCondProducer.cc b/L1Trigger/L1TGlobal/plugins/L1TExtCondProducer.cc index 082f560c95724..06dc15f216610 100644 --- a/L1Trigger/L1TGlobal/plugins/L1TExtCondProducer.cc +++ b/L1Trigger/L1TGlobal/plugins/L1TExtCondProducer.cc @@ -36,6 +36,8 @@ #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h" +#include "DataFormats/TCDS/interface/TCDSRecord.h" + using namespace std; using namespace edm; using namespace l1t; @@ -71,6 +73,12 @@ using namespace l1t; unsigned long long m_l1GtMenuCacheID; std::map m_extBitMap; + + unsigned int m_triggerRulePrefireVetoBit; + + bool makeTriggerRulePrefireVetoBit_; + edm::EDGetTokenT tcdsRecordToken_; + edm::InputTag tcdsInputTag_; }; // @@ -82,8 +90,26 @@ using namespace l1t; setBptxAND_ (iConfig.getParameter("setBptxAND")), setBptxPlus_ (iConfig.getParameter("setBptxPlus")), setBptxMinus_ (iConfig.getParameter("setBptxMinus")), - setBptxOR_ (iConfig.getParameter("setBptxOR")) + setBptxOR_ (iConfig.getParameter("setBptxOR")), + tcdsInputTag_(iConfig.getParameter("tcdsRecordLabel")) { + + makeTriggerRulePrefireVetoBit_=false; + + m_triggerRulePrefireVetoBit=255; + if (m_triggerRulePrefireVetoBit > GlobalExtBlk::maxExternalConditions-1){ + m_triggerRulePrefireVetoBit = GlobalExtBlk::maxExternalConditions-1; + edm::LogWarning("L1TExtCondProducer") << "Default trigger rule prefire veto bit number too large. Resetting to " + << m_triggerRulePrefireVetoBit; + } + + if(!(tcdsInputTag_ == edm::InputTag(""))) + { + tcdsRecordToken_ = consumes(tcdsInputTag_); + makeTriggerRulePrefireVetoBit_ = true; + + } + // register what you produce produces(); @@ -128,6 +154,52 @@ using namespace l1t; m_extBitMap = extBitMap; } + bool TriggerRulePrefireVetoBit(false); + if (makeTriggerRulePrefireVetoBit_){ + // code taken from Nick Smith's EventFilter/L1TRawToDigi/plugins/TriggerRulePrefireVetoFilter.cc + + edm::Handle tcdsRecordH; + iEvent.getByToken(tcdsRecordToken_, tcdsRecordH); + const auto& tcdsRecord = *tcdsRecordH.product(); + + uint64_t thisEvent = (tcdsRecord.getBXID()-1) + tcdsRecord.getOrbitNr()*3564ull; + + std::vector eventHistory; + for (auto&& l1a : tcdsRecord.getFullL1aHistory()) { + eventHistory.push_back(thisEvent - ((l1a.getBXID()-1) + l1a.getOrbitNr()*3564ull)); + } + + // should be 16 according to TCDSRecord.h, we only care about the last 4 + if ( eventHistory.size() < 4 ) { + edm::LogError("L1TExtCondProducer") << "Unexpectedly small L1A history from TCDSRecord"; + } + + // No more than 1 L1A in 3 BX + if ( eventHistory[0] < 3ull ) { + edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (1 in 3)"; + } + + if ( eventHistory[0] == 3ull ) TriggerRulePrefireVetoBit = true; + + // No more than 2 L1As in 25 BX + if ( eventHistory[0] < 25ull and eventHistory[1] < 25ull ) { + edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (2 in 25)"; + } + if ( eventHistory[0] < 25ull and eventHistory[1] == 25ull ) TriggerRulePrefireVetoBit = true; + + // No more than 3 L1As in 100 BX + if ( eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] < 100ull ) { + edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (3 in 100)"; + } + if ( eventHistory[0] < 100ull and eventHistory[1] < 100ull and eventHistory[2] == 100ull ) TriggerRulePrefireVetoBit = true; + + // No more than 4 L1As in 240 BX + if ( eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and eventHistory[3] < 240ull ) { + edm::LogError("L1TExtCondProducer") << "Found an L1A in an impossible location?! (4 in 240)"; + } + if ( eventHistory[0] < 240ull and eventHistory[1] < 240ull and eventHistory[2] < 240ull and eventHistory[3] == 240ull ) TriggerRulePrefireVetoBit = true; + } + // Setup vectors GlobalExtBlk extCond_bx; @@ -157,6 +229,11 @@ using namespace l1t; if( setBptxMinus_ && foundBptxMinus ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_B2_VME"],true); if( setBptxOR_ && foundBptxOR ) extCond_bx.setExternalDecision(m_extBitMap["BPTX_OR_VME"],true); + // set the bit for the TriggerRulePrefireVeto if true + if (TriggerRulePrefireVetoBit) + extCond_bx.setExternalDecision(m_triggerRulePrefireVetoBit,true); + + // Fill Externals for( int iBx=bxFirst_; iBx<=bxLast_; iBx++ ){ extCond->push_back(iBx, extCond_bx); @@ -178,6 +255,7 @@ using namespace l1t; desc.add("setBptxOR", true); desc.add("bxLast", 2); desc.add("setBptxPlus", true); + desc.add ("tcdsRecordLabel", edm::InputTag("")); descriptions.add("simGtExtFakeProd", desc); } diff --git a/L1Trigger/L1TGlobal/python/simGtExtFakeProd_cfi.py b/L1Trigger/L1TGlobal/python/simGtExtFakeProd_cfi.py index 3043f5aef5cf3..8e8ad3772ff97 100644 --- a/L1Trigger/L1TGlobal/python/simGtExtFakeProd_cfi.py +++ b/L1Trigger/L1TGlobal/python/simGtExtFakeProd_cfi.py @@ -8,5 +8,7 @@ setBptxPlus = cms.bool(True), setBptxMinus = cms.bool(True), setBptxOR = cms.bool(True), + tcdsRecordLabel= cms.InputTag("") + ## tcdsRecordLabel= cms.InputTag("tcdsDigis","tcdsRecord") ## use this tag to trigger fetching the tcds record and set the Prefire veto bit ) From 04678db463e25f2e13d01d45c0b5fe954ed02224 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 15 Apr 2019 18:25:49 +0200 Subject: [PATCH 656/686] Correct one xml file --- Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml index 9066d354ac65a..e89b1262fb870 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml @@ -170,7 +170,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -179,7 +179,7 @@ 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, - 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, From 9aef90e55e58b20338a1da1698e87194f82fd6ab Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Mon, 15 Apr 2019 22:15:13 +0200 Subject: [PATCH 657/686] Suggestions by @fabiocos --- .../MuonHits/interface/CSCSimHitMatcher.h | 3 +-- .../MuonHits/interface/DTSimHitMatcher.h | 3 +-- .../MuonHits/interface/GEMSimHitMatcher.h | 3 +-- .../MuonHits/interface/ME0SimHitMatcher.h | 3 +-- .../MuonHits/interface/RPCSimHitMatcher.h | 3 +-- Validation/MuonHits/src/CSCSimHitMatcher.cc | 22 +++++-------------- Validation/MuonHits/src/DTSimHitMatcher.cc | 10 ++++----- Validation/MuonHits/src/GEMSimHitMatcher.cc | 11 +++++----- Validation/MuonHits/src/ME0SimHitMatcher.cc | 11 +++++----- Validation/MuonHits/src/RPCSimHitMatcher.cc | 10 ++++----- 10 files changed, 30 insertions(+), 49 deletions(-) diff --git a/Validation/MuonHits/interface/CSCSimHitMatcher.h b/Validation/MuonHits/interface/CSCSimHitMatcher.h index 72f654e89cd44..f8d9c59458a61 100644 --- a/Validation/MuonHits/interface/CSCSimHitMatcher.h +++ b/Validation/MuonHits/interface/CSCSimHitMatcher.h @@ -71,8 +71,7 @@ class CSCSimHitMatcher : public MuonSimHitMatcher { void camberIdsToString(const std::set&) const; private: - void matchSimHitsToSimTrack(std::vector track_ids, - const edm::PSimHitContainer& csc_hits); + void matchSimHitsToSimTrack(); edm::ESHandle csc_geom_; }; diff --git a/Validation/MuonHits/interface/DTSimHitMatcher.h b/Validation/MuonHits/interface/DTSimHitMatcher.h index 4881fa98353b2..98895b6b0a515 100644 --- a/Validation/MuonHits/interface/DTSimHitMatcher.h +++ b/Validation/MuonHits/interface/DTSimHitMatcher.h @@ -71,8 +71,7 @@ class DTSimHitMatcher : public MuonSimHitMatcher { void dtChamberIdsToString(const std::set&) const; private: - void matchSimHitsToSimTrack(std::vector track_ids, - const edm::PSimHitContainer& hits); + void matchSimHitsToSimTrack(); std::map layer_to_hits_; std::map superlayer_to_hits_; diff --git a/Validation/MuonHits/interface/GEMSimHitMatcher.h b/Validation/MuonHits/interface/GEMSimHitMatcher.h index ebe1f0272791a..eda6fe813bbbd 100644 --- a/Validation/MuonHits/interface/GEMSimHitMatcher.h +++ b/Validation/MuonHits/interface/GEMSimHitMatcher.h @@ -74,8 +74,7 @@ class GEMSimHitMatcher : public MuonSimHitMatcher { std::set hitPartitions() const; private: - void matchSimHitsToSimTrack(std::vector track_ids, - const edm::PSimHitContainer& hits); + void matchSimHitsToSimTrack(); edm::ESHandle gem_geom_; diff --git a/Validation/MuonHits/interface/ME0SimHitMatcher.h b/Validation/MuonHits/interface/ME0SimHitMatcher.h index 9c81acef33cbb..38b433a65b1e9 100644 --- a/Validation/MuonHits/interface/ME0SimHitMatcher.h +++ b/Validation/MuonHits/interface/ME0SimHitMatcher.h @@ -61,8 +61,7 @@ class ME0SimHitMatcher : public MuonSimHitMatcher { int nPadsWithHits() const; private: - void matchSimHitsToSimTrack(std::vector track_ids, - const edm::PSimHitContainer& me0_hits); + void matchSimHitsToSimTrack(); edm::ESHandle me0_geom_; diff --git a/Validation/MuonHits/interface/RPCSimHitMatcher.h b/Validation/MuonHits/interface/RPCSimHitMatcher.h index cc5f640ff046c..bc078327d3498 100644 --- a/Validation/MuonHits/interface/RPCSimHitMatcher.h +++ b/Validation/MuonHits/interface/RPCSimHitMatcher.h @@ -42,8 +42,7 @@ class RPCSimHitMatcher : public MuonSimHitMatcher { std::set hitStripsInDetId(unsigned int, int margin_n_strips = 0) const; private: - void matchSimHitsToSimTrack(std::vector track_ids, - const edm::PSimHitContainer& rpc_hits); + void matchSimHitsToSimTrack(); edm::ESHandle rpc_geom_; }; diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index dd35bc812e858..df71c3086cfc3 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -30,10 +30,11 @@ void CSCSimHitMatcher::init(const edm::Event& iEvent, /// do the matching void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { + // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); + matchSimHitsToSimTrack(); if (verbose_) { edm::LogInfo("CSCSimHitMatcher") @@ -63,10 +64,9 @@ void CSCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { } } -void CSCSimHitMatcher::matchSimHitsToSimTrack( - std::vector track_ids, const edm::PSimHitContainer& hits) { - for (const auto& track_id : track_ids) { - for (const auto& h : hits) { +void CSCSimHitMatcher::matchSimHitsToSimTrack() { + for (const auto& track_id : track_ids_) { + for (const auto& h : simHits_) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; @@ -182,9 +182,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { phi_layer1 = gp1a.phi(); else if (!hits1b.empty()) phi_layer1 = gp1b.phi(); - else - std::cerr << " no hits in layer1, cant not find global phi of hits " - << std::endl; // phi in layer 6 const CSCDetId cscid6a(cscid.endcap(), cscid.station(), 4, cscid.chamber(), @@ -205,9 +202,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { phi_layer6 = gp6a.phi(); else if (!hits6b.empty()) phi_layer6 = gp6b.phi(); - else - std::cerr << " no hits in layer6, cant not find global phi of hits " - << std::endl; } else { // phi in layer 1 @@ -215,9 +209,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { cscid.chamber(), 1); const edm::PSimHitContainer& hits1 = MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); - if (hits1.empty()) - std::cerr << " no hits in layer1, cant not find global phi of hits " - << std::endl; const GlobalPoint& gp1 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); phi_layer1 = gp1.phi(); @@ -227,9 +218,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { cscid.chamber(), 6); const edm::PSimHitContainer& hits6 = MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); - if (hits6.empty()) - std::cerr << " no hits in layer6, cant not find global phi of hits " - << std::endl; const GlobalPoint& gp6 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); phi_layer6 = gp6.phi(); diff --git a/Validation/MuonHits/src/DTSimHitMatcher.cc b/Validation/MuonHits/src/DTSimHitMatcher.cc index 5b1299d4f0517..b98bff00f48d2 100644 --- a/Validation/MuonHits/src/DTSimHitMatcher.cc +++ b/Validation/MuonHits/src/DTSimHitMatcher.cc @@ -30,10 +30,11 @@ void DTSimHitMatcher::init(const edm::Event& iEvent, /// do the matching void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { + // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); + matchSimHitsToSimTrack(); if (verbose_) { edm::LogInfo("DTSimHitMatcher") @@ -55,10 +56,9 @@ void DTSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { } } -void DTSimHitMatcher::matchSimHitsToSimTrack( - std::vector track_ids, const edm::PSimHitContainer& dt_hits) { - for (const auto& track_id : track_ids) { - for (const auto& h : dt_hits) { +void DTSimHitMatcher::matchSimHitsToSimTrack() { + for (const auto& track_id : track_ids_) { + for (const auto& h : simHits_) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; diff --git a/Validation/MuonHits/src/GEMSimHitMatcher.cc b/Validation/MuonHits/src/GEMSimHitMatcher.cc index f5f61286c1f7b..2f16bb04eac6b 100644 --- a/Validation/MuonHits/src/GEMSimHitMatcher.cc +++ b/Validation/MuonHits/src/GEMSimHitMatcher.cc @@ -30,10 +30,11 @@ void GEMSimHitMatcher::init(const edm::Event& iEvent, /// do the matching void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { + // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); + matchSimHitsToSimTrack(); if (verbose_) { edm::LogInfo("GEMSimHitMatcher") @@ -70,11 +71,9 @@ void GEMSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { } } -void GEMSimHitMatcher::matchSimHitsToSimTrack( - std::vector track_ids, - const edm::PSimHitContainer& gem_hits) { - for (const auto& track_id : track_ids) { - for (const auto& h : gem_hits) { +void GEMSimHitMatcher::matchSimHitsToSimTrack() { + for (const auto& track_id : track_ids_) { + for (const auto& h : simHits_) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; diff --git a/Validation/MuonHits/src/ME0SimHitMatcher.cc b/Validation/MuonHits/src/ME0SimHitMatcher.cc index eb25c3318c06a..645e1bac17895 100644 --- a/Validation/MuonHits/src/ME0SimHitMatcher.cc +++ b/Validation/MuonHits/src/ME0SimHitMatcher.cc @@ -30,10 +30,11 @@ void ME0SimHitMatcher::init(const edm::Event& iEvent, /// do the matching void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { + // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); + matchSimHitsToSimTrack(); if (verbose_) { edm::LogInfo("ME0SimHitMatcher") @@ -61,11 +62,9 @@ void ME0SimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { } } -void ME0SimHitMatcher::matchSimHitsToSimTrack( - std::vector track_ids, - const edm::PSimHitContainer& me0_hits) { - for (const auto& track_id : track_ids) { - for (const auto& h : me0_hits) { +void ME0SimHitMatcher::matchSimHitsToSimTrack() { + for (const auto& track_id : track_ids_) { + for (const auto& h : simHits_) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; diff --git a/Validation/MuonHits/src/RPCSimHitMatcher.cc b/Validation/MuonHits/src/RPCSimHitMatcher.cc index 3887e7a72840b..1da78f99c8c25 100644 --- a/Validation/MuonHits/src/RPCSimHitMatcher.cc +++ b/Validation/MuonHits/src/RPCSimHitMatcher.cc @@ -31,10 +31,11 @@ void RPCSimHitMatcher::init(const edm::Event& iEvent, /// do the matching void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { + // instantiates the track ids and simhits MuonSimHitMatcher::match(track, vertex); if (hasGeometry_) { - matchSimHitsToSimTrack(track_ids_, simHits_); + matchSimHitsToSimTrack(); if (verbose_) { edm::LogInfo("RPCSimHitMatcher") @@ -54,7 +55,7 @@ void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { const auto& strips = hitStripsInDetId(id); edm::LogInfo("RPCSimHitMatcher") << "nStrips " << strips.size() << endl; edm::LogInfo("RPCSimHitMatcher") << "strips : "; - for (const auto& p : strips){ + for (const auto& p : strips) { edm::LogInfo("RPCSimHitMatcher") << p; } } @@ -62,10 +63,9 @@ void RPCSimHitMatcher::match(const SimTrack& track, const SimVertex& vertex) { } } -void RPCSimHitMatcher::matchSimHitsToSimTrack( - std::vector track_ids_, const edm::PSimHitContainer& hits) { +void RPCSimHitMatcher::matchSimHitsToSimTrack() { for (const auto& track_id : track_ids_) { - for (const auto& h : hits) { + for (const auto& h : simHits_) { if (h.trackId() != track_id) continue; int pdgid = h.particleType(); if (simMuOnly_ && std::abs(pdgid) != 13) continue; From d9a44d0d30e747926cbccefd992102f7451dc000 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Mon, 15 Apr 2019 23:20:14 +0200 Subject: [PATCH 658/686] Follow-up from PR request: - Use MuonSubdetId in Muon object member functions - Add fillDefault metshod to MuonShowerDigiFiller - few other technical changes --- DataFormats/MuonReco/interface/Muon.h | 8 +--- DataFormats/MuonReco/src/Muon.cc | 41 +++++++++++-------- .../interface/MuonShowerDigiFiller.h | 2 +- .../plugins/MuonIdProducer.cc | 4 +- .../src/MuonShowerDigiFiller.cc | 31 +++++++------- 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index 05f9f848239e2..dda42aaa900e2 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -261,13 +261,9 @@ namespace reco { /// same as above for given number of sigmas unsigned int stationGapMaskPull( float sigmaCut = 3. ) const; /// # of digis in a given station layer - /// index 0-1-2-3 = DT stations 1-2-3-4 - /// index 4-5-6-7 = CSC stations 1-2-3-4 - int nDigisInStation( int index) const; + int nDigisInStation( int station, int muonSubdetId) const; /// tag a shower in a given station layer - /// index 0-1-2-3 = DT stations 1-2-3-4 - /// index 4-5-6-7 = CSC stations 1-2-3-4 - bool hasShowerInStation( int index, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; + bool hasShowerInStation( int station, int muonSubdetId, int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; /// count the number of showers along a muon track int numberOfShowers( int nDtDigisCut = 20, int nCscDigisCut = 36 ) const; diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index 9e8a29cabf09b..74e5d49285167 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -334,29 +334,31 @@ unsigned int Muon::stationGapMaskPull( float sigmaCut ) const return totMask; } -int Muon::nDigisInStation( int index ) const +int Muon::nDigisInStation( int station, int muonSubdetId ) const { int nDigis(0); std::map me11DigisPerCh; + if ( muonSubdetId != MuonSubdetId::CSC && + muonSubdetId != MuonSubdetId::DT ) + return 0; + for ( auto & match : muMatches_ ) { - if ( match.detector() != MuonSubdetId::CSC && - match.detector() != MuonSubdetId::DT ) + if ( match.detector() != muonSubdetId || + match.station() != station ) continue; int nDigisInCh = match.nDigisInRange; - int iStation = match.detector() == MuonSubdetId::CSC ? index - 3 : index + 1; - - if( match.detector() == MuonSubdetId::CSC && iStation == 1 ) + + if( muonSubdetId == MuonSubdetId::CSC && station == 1 ) { CSCDetId id(match.id.rawId()); - int station = id.station(); int chamber = id.chamber(); int ring = id.ring(); - - if ( station == 1 && (ring == 1 || ring == 4) ) // merge ME1/1a and ME1/1b digis + + if ( ring == 1 || ring == 4 ) // merge ME1/1a and ME1/1b digis { if( me11DigisPerCh.find(chamber) == me11DigisPerCh.end() ) me11DigisPerCh[chamber] = 0; @@ -366,35 +368,38 @@ int Muon::nDigisInStation( int index ) const continue; } } - - if( iStation == match.station() && nDigisInCh > nDigis ) + + if( nDigisInCh > nDigis ) nDigis = nDigisInCh; } for ( const auto & me11DigisInCh : me11DigisPerCh ) { int nMe11DigisInCh = me11DigisInCh.second; - if (nMe11DigisInCh > nDigis) + if ( nMe11DigisInCh > nDigis ) nDigis = nMe11DigisInCh; } return nDigis; } -bool Muon::hasShowerInStation( int index, int nDtDigisCut, int nCscDigisCut ) const +bool Muon::hasShowerInStation( int station, int muonSubdetId, int nDtDigisCut, int nCscDigisCut ) const { - bool hasShower = index < 4 ? - nDigisInStation(index) >= nDtDigisCut : - nDigisInStation(index) >= nCscDigisCut; + bool hasShower = muonSubdetId == MuonSubdetId::DT ? + nDigisInStation(station,muonSubdetId) >= nDtDigisCut : + nDigisInStation(station,muonSubdetId) >= nCscDigisCut; + return hasShower; } int Muon::numberOfShowers( int nDtDigisCut, int nCscDigisCut ) const { int nShowers = 0; - for ( int iCh = 0; iCh < 8; ++iCh ) + for ( int iCh = 1; iCh < 5; ++iCh ) { - if ( hasShowerInStation(iCh,nDtDigisCut,nCscDigisCut) ) + if ( hasShowerInStation(iCh,MuonSubdetId::DT,nDtDigisCut,nCscDigisCut) ) + nShowers++; + if ( hasShowerInStation(iCh,MuonSubdetId::CSC,nDtDigisCut,nCscDigisCut) ) nShowers++; } diff --git a/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h b/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h index 004adc2f8c520..2a731945fccd2 100644 --- a/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h +++ b/RecoMuon/MuonIdentification/interface/MuonShowerDigiFiller.h @@ -50,12 +50,12 @@ class MuonShowerDigiFiller public: MuonShowerDigiFiller(const edm::ParameterSet&, edm::ConsumesCollector&& iC); - ~MuonShowerDigiFiller(); void getES( const edm::EventSetup& iSetup ); void getDigis( edm::Event& iEvent ); void fill( reco::MuonChamberMatch & muChMatch ) const; + void fillDefault( reco::MuonChamberMatch & muChMatch ) const; private: diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index 6344688bcda64..e621e43dbef35 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -893,7 +893,7 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu theShowerDigiFiller_->fill(matchedChamber); } else { - matchedChamber.nDigisInRange = 0; + theShowerDigiFiller_->fillDefault(matchedChamber); } if ( ! chamber.segments.empty() ) ++nubmerOfMatchesAccordingToTrackAssociator; @@ -978,7 +978,7 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu matchedChamber.edgeX = chamber.localDistanceX; matchedChamber.edgeY = chamber.localDistanceY; - matchedChamber.nDigisInRange = 0; + theShowerDigiFiller_->fillDefault(matchedChamber); matchedChamber.id = chamber.id; diff --git a/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc index 4dcf890c8b476..799c169bb882e 100644 --- a/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc +++ b/RecoMuon/MuonIdentification/src/MuonShowerDigiFiller.cc @@ -28,25 +28,14 @@ // MuonShowerDigiFiller::MuonShowerDigiFiller(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC) : - m_digiMaxDistanceX(iConfig.getParameter("digiMaxDistanceX")) - + m_digiMaxDistanceX(iConfig.getParameter("digiMaxDistanceX")), + m_dtDigisToken(iC.consumes(iConfig.getParameter("dtDigiCollectionLabel"))), + m_cscDigisToken(iC.consumes(iConfig.getParameter("cscDigiCollectionLabel"))) { - - edm::InputTag label = iConfig.getParameter("dtDigiCollectionLabel"); - m_dtDigisToken=iC.consumes(label); - - label = iConfig.getParameter("cscDigiCollectionLabel"); - m_cscDigisToken=iC.consumes(label); } -MuonShowerDigiFiller::~MuonShowerDigiFiller() -{ - -} - - // // member functions // @@ -80,9 +69,9 @@ MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const { double xTrack = muChMatch.x; - for (int sl = 1; sl < 4; sl += 2) + for (int sl = 1; sl <= DTChamberId::maxSuperLayerId; sl += 2) { - for (int layer = 1; layer < 5; ++layer) + for (int layer = 1; layer <= DTChamberId::maxLayerId; ++layer) { const DTLayerId layerId(DTChamberId(muChMatch.id.rawId()),sl,layer); @@ -108,7 +97,7 @@ MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const double xTrack = muChMatch.x; double yTrack = muChMatch.y; - for (int iLayer = 1; iLayer < 7; ++iLayer) + for (int iLayer = 1; iLayer <= CSCDetId::maxLayerId(); ++iLayer) { const CSCDetId chId(muChMatch.id.rawId()); const CSCDetId layerId(chId.endcap(), chId.station(), @@ -151,3 +140,11 @@ MuonShowerDigiFiller::fill( reco::MuonChamberMatch & muChMatch ) const muChMatch.nDigisInRange = nDigisInRange; } + +void +MuonShowerDigiFiller::fillDefault( reco::MuonChamberMatch & muChMatch ) const +{ + + muChMatch.nDigisInRange = 0; + +} From 9d56bb7d769d05e3ce11270e35b9f1638de23426 Mon Sep 17 00:00:00 2001 From: tocheng Date: Mon, 15 Apr 2019 04:07:30 +0200 Subject: [PATCH 659/686] Update LHC optical function --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 4a684dcd3bfef..d205b90210576 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '105X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v4', + 'run1_data' : '106X_dataRun2_v8', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v4', + 'run2_data' : '106X_dataRun2_v8', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v2', + 'run2_data_relval' : '106X_dataRun2_relval_v6', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v1', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v4', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v1', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v1', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v4', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v4', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v8', # GlobalTag for Run2 HLT: it points to the online GT From b144e2080f894123b8da06bd7dd50ed35dde7c71 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 16 Apr 2019 16:46:39 +0200 Subject: [PATCH 660/686] Get rid of all cout in Geometry/HGCalCommonData src & plugin code --- .../interface/FastTimeDDDConstants.h | 1 - .../interface/FastTimeParameters.h | 1 - .../interface/HGCalDDDConstants.h | 1 - .../interface/HGCalGeomParameters.h | 1 - .../interface/HGCalParameters.h | 1 - .../interface/HGCalWaferType.h | 1 - .../plugins/DDAHcalModuleAlgo.cc | 2 - .../HGCalCommonData/plugins/DDHGCalCell.cc | 1 - .../plugins/DDHGCalNoTaperEndcap.cc | 42 +++++++------- .../HGCalCommonData/plugins/DDHGCalWafer.cc | 56 +++++++++---------- .../HGCalCommonData/plugins/DDHGCalWafer8.cc | 1 - .../plugins/DDHGCalWaferAlgo.cc | 54 +++++++++--------- .../FastTimeNumberingInitialization.cc | 9 ++- .../plugins/FastTimeParametersESModule.cc | 37 ++++++------ .../plugins/HGCalNumberingInitialization.cc | 9 +-- .../plugins/HGCalParametersESModule.cc | 11 ++-- .../src/FastTimeDDDConstants.cc | 7 ++- .../src/FastTimeParametersFromDD.cc | 27 +++++---- .../HGCalCommonData/src/HGCalDDDConstants.cc | 7 +-- .../src/HGCalGeomParameters.cc | 12 ++-- .../HGCalCommonData/src/HGCalParameters.cc | 1 + .../src/HGCalParametersFromDD.cc | 9 +-- .../HGCalCommonData/src/HGCalWaferType.cc | 8 +-- 23 files changed, 140 insertions(+), 159 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h b/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h index 69468b7bffd2e..ec22f3ff319c0 100644 --- a/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h @@ -10,7 +10,6 @@ * */ -#include #include #include diff --git a/Geometry/HGCalCommonData/interface/FastTimeParameters.h b/Geometry/HGCalCommonData/interface/FastTimeParameters.h index 894408291d5cc..d9bcbe74f092e 100644 --- a/Geometry/HGCalCommonData/interface/FastTimeParameters.h +++ b/Geometry/HGCalCommonData/interface/FastTimeParameters.h @@ -2,7 +2,6 @@ #define Geometry_HGCalCommonData_FastTimeParameters_h #include -#include #include #include #include "CondFormats/Serialization/interface/Serializable.h" diff --git a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h index e847a5aee5a64..c78fbdccf3f1e 100644 --- a/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h +++ b/Geometry/HGCalCommonData/interface/HGCalDDDConstants.h @@ -11,7 +11,6 @@ * */ -#include #include #include #include "DataFormats/DetId/interface/DetId.h" diff --git a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h index 8ec86d72704a3..a8ab9d89f9d10 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeomParameters.h @@ -12,7 +12,6 @@ * */ -#include #include #include #include diff --git a/Geometry/HGCalCommonData/interface/HGCalParameters.h b/Geometry/HGCalCommonData/interface/HGCalParameters.h index d484826f7e2b8..d412722c2c2ad 100644 --- a/Geometry/HGCalCommonData/interface/HGCalParameters.h +++ b/Geometry/HGCalCommonData/interface/HGCalParameters.h @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferType.h b/Geometry/HGCalCommonData/interface/HGCalWaferType.h index b8687bf715116..8dabecf93117d 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferType.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferType.h @@ -14,7 +14,6 @@ */ #include -#include #include class HGCalWaferType { diff --git a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc index d0b1c68b63942..943f52b890de8 100644 --- a/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc @@ -6,8 +6,6 @@ #include #include -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc b/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc index df438a85af084..f3f5ec2e02643 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalCell.cc @@ -1,5 +1,4 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalCell.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc index e5daa2f0ff9cb..8c28900c28368 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc @@ -1,9 +1,7 @@ #include #include -#include -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" @@ -13,9 +11,10 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalNoTaperEndcap::DDHGCalNoTaperEndcap() { - edm::LogInfo("HGCalGeom") + edm::LogVerbatim("HGCalGeom") << "DDHGCalNoTaperEndcap test: Creating an instance"; } @@ -37,8 +36,9 @@ void DDHGCalNoTaperEndcap::initialize(const DDNumericArguments& nArgs, m_incrCopyNo = int(nArgs["incrCopyNo"]); m_childName = sArgs["ChildName"]; m_idNameSpace = DDCurrentNamespace::ns(); - edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap: NameSpace " - << m_idNameSpace << "\tParent " << parent().name(); + edm::LogVerbatim("HGCalGeom") + << "DDHGCalNoTaperEndcap: NameSpace " << m_idNameSpace << "\tParent " + << parent().name(); } void DDHGCalNoTaperEndcap::execute(DDCompactView& cpv) { @@ -55,7 +55,7 @@ int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, double tiltAngle = m_tiltAngle; double xphi = xQuadrant * tiltAngle; double yphi = yQuadrant * tiltAngle; - double theta = 90. * CLHEP::deg; + double theta = 90._deg; double phiX = 0.0; double phiY = theta; double phiZ = 3 * theta; @@ -88,10 +88,11 @@ int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, // Make sure we do not add supermodules in rMin area if (limit2 > m_rMin && limit1 < m_rMax) { #ifdef EDM_ML_DEBUG - std::cout << m_childName << " copyNo = " << copyNo << " (" << column - << "," << row << "): offsetX,Y = " << offsetX << "," - << offsetY << " limit=" << limit1 << ":" << limit2 - << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl; + edm::LogVerbatim("HGCalGeom") + << m_childName << " copyNo = " << copyNo << " (" << column + << "," << row << "): offsetX,Y = " << offsetX << "," + << offsetY << " limit=" << limit1 << ":" << limit2 + << " rMin, rMax = " << m_rMin << "," << m_rMax; #endif DDRotation rotation; std::string rotstr("NULL"); @@ -106,12 +107,12 @@ int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, std::make_unique( *DDcreateRotationMatrix(theta, phiX, theta + yphi, phiY, -yphi, phiZ) * - (*DDcreateRotationMatrix(theta + xphi, phiX, 90. * CLHEP::deg, - 90. * CLHEP::deg, xphi, 0.0)))); + (*DDcreateRotationMatrix(theta + xphi, phiX, 90._deg, + 90._deg, xphi, 0.0)))); } DDTranslation tran(offsetX, offsetY, offsetZ); - edm::LogInfo("HGCalGeom") + edm::LogVerbatim("HGCalGeom") << "Module " << copyNo << ": location = " << tran << " Rotation " << rotation; @@ -121,10 +122,10 @@ int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, copyNo += m_incrCopyNo; } else { #ifdef EDM_ML_DEBUG - std::cout << " (" << column << "," << row - << "): offsetX,Y = " << offsetX << "," << offsetY - << " is out of limit=" << limit1 << ":" << limit2 - << " rMin, rMax = " << m_rMin << "," << m_rMax << std::endl; + edm::LogVerbatim("HGCalGeom") + << " (" << column << "," << row << "): offsetX,Y = " << offsetX + << "," << offsetY << " is out of limit=" << limit1 << ":" << limit2 + << " rMin, rMax = " << m_rMin << "," << m_rMax; #endif } @@ -140,8 +141,9 @@ int DDHGCalNoTaperEndcap::createQuarter(DDCompactView& cpv, int xQuadrant, offsetX += xQuadrant * offsetXY; } #ifdef EDM_ML_DEBUG - std::cout << rowmax << " rows and " << column << " columns in quadrant " - << xQuadrant << ":" << yQuadrant << std::endl; + edm::LogVerbatim("HGCalGeom") + << rowmax << " rows and " << column << " columns in quadrant " + << xQuadrant << ":" << yQuadrant; #endif return copyNo; } diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc index ceb546c9f8e9b..31f3239141022 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc @@ -1,7 +1,7 @@ #include #include -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDSplit.h" @@ -10,10 +10,11 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalWafer.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalWafer::DDHGCalWafer() { #ifdef EDM_ML_DEBUG - edm::LogInfo("HGCalGeom") << "DDHGCalWafer test: Creating an instance"; + edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: Creating an instance"; #endif } @@ -35,26 +36,27 @@ void DDHGCalWafer::initialize(const DDNumericArguments& nArgs, idNameSpace_ = DDCurrentNamespace::ns(); parentName_ = parent().name(); #ifdef EDM_ML_DEBUG - std::cout << childNames_.size() << " children: " << childNames_[0] << "; " - << childNames_[1] << " in namespace " << idNameSpace_ - << " positioned in " << nCellsRow_.size() << " rows and " - << nColumns_ << " columns with lowest column at " << nBottomY_ - << " in mother " << parentName_ << " of size " << waferSize_ - << std::endl; + edm::LogVerbatim("HGCalGeom") + << childNames_.size() << " children: " << childNames_[0] << "; " + << childNames_[1] << " in namespace " << idNameSpace_ + << " positioned in " << nCellsRow_.size() << " rows and " + << nColumns_ << " columns with lowest column at " << nBottomY_ + << " in mother " << parentName_ << " of size " << waferSize_; for (unsigned int k = 0; k < nCellsRow_.size(); ++k) - std::cout << "[" << k << "] Ncells " << nCellsRow_[k] << " Edge rotations " - << angleEdges_[2 * k] << ":" << angleEdges_[2 * k + 1] - << " Type of edge cells " << detectorType_[2 * k] << ":" - << detectorType_[2 * k + 1] << std::endl; + edm::LogVerbatim("HGCalGeom") + << "[" << k << "] Ncells " << nCellsRow_[k] << " Edge rotations " + << angleEdges_[2 * k] << ":" << angleEdges_[2 * k + 1] + << " Type of edge cells " << detectorType_[2 * k] << ":" + << detectorType_[2 * k + 1]; #endif } void DDHGCalWafer::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalWafer..."; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWafer..."; #endif double dx = 0.5 * waferSize_ / nColumns_; - double dy = 0.5 * dx * tan(30.0 * CLHEP::deg); + double dy = 0.5 * dx * tan(30._deg); int ny = nBottomY_; int kount(0); @@ -73,21 +75,18 @@ void DDHGCalWafer::execute(DDCompactView& cpv) { } DDRotation rot; if (irot != 0) { - if (irot >= 0 && irot < 100) - rotstr = "R0"; - else - rotstr = "R"; - rotstr = rotstr + std::to_string(irot); + double phi = convertDegToRad(irot); + rotstr = "R" + formatAsDegrees(phi); rot = DDRotation(DDName(rotstr, idNameSpace_)); if (!rot) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: Creating new rotation " - << DDName(rotstr, idNameSpace_) << "\t90, " << irot - << ", 90, " << (irot + 90) << ", 0, 0" << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalWaferAlgo: Creating new rotation " + << DDName(rotstr, idNameSpace_) << "\t90, " << irot + << ", 90, " << (irot + 90) << ", 0, 0"; #endif - rot = DDrot(DDName(rotstr, idNameSpace_), 90 * CLHEP::deg, - irot * CLHEP::deg, 90 * CLHEP::deg, - (90 + irot) * CLHEP::deg, 0 * CLHEP::deg, 0 * CLHEP::deg); + rot = DDrot(DDName(rotstr, idNameSpace_), 90._deg, phi, 90._deg, + (90._deg+phi), 0, 0); } } double xpos = dx * nx; @@ -97,9 +96,10 @@ void DDHGCalWafer::execute(DDCompactView& cpv) { cpv.position(DDName(name, idNameSpace_), parentName_, copy, tran, rot); ++kount; #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWafer: " << DDName(name, idNameSpace_) << " number " - << copy << " positioned in " << parentName_ << " at " << tran - << " with " << rot << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalWafer: " << DDName(name, idNameSpace_) << " number " + << copy << " positioned in " << parentName_ << " at " << tran + << " with " << rot; #endif } ny += 6; diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc index 84a47eb05ff13..049271700adc1 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc @@ -1,5 +1,4 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalWafer8.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDMaterial.h" diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc index a1e73c0fa8b18..5d734dc7aa720 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc @@ -6,7 +6,7 @@ #include #include -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDutils.h" @@ -14,10 +14,11 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.h" //#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHGCalWaferAlgo::DDHGCalWaferAlgo() { #ifdef EDM_ML_DEBUG - edm::LogInfo("HGCalGeom") << "DDHGCalWaferAlgo test: Creating an instance"; + edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating an instance"; #endif } @@ -36,51 +37,49 @@ void DDHGCalWaferAlgo::initialize(const DDNumericArguments& nArgs, angles = vArgs["Angles"]; detectorType = dbl_to_int(vArgs["DetectorType"]); #ifdef EDM_ML_DEBUG - std::cout << childNames.size() << " children: " << childNames[0] << "; " - << childNames[1] << " positioned " << positionX.size() - << " times with cell size " << cellSize << std::endl; + edm::LogVerbatim("HGCalGeom") + << childNames.size() << " children: " << childNames[0] << "; " + << childNames[1] << " positioned " << positionX.size() + << " times with cell size " << cellSize; for (unsigned int k = 0; k < positionX.size(); ++k) - std::cout << "[" << k << "] x " << positionX[k] << " y " << positionY[k] - << " angle " << angles[k] << " detector " << detectorType[k] - << std::endl; + edm::LogVerbatim("HGCalGeom") + << "[" << k << "] x " << positionX[k] << " y " << positionY[k] + << " angle " << angles[k] << " detector " << detectorType[k]; #endif rotns = sArgs["RotNameSpace"]; idNameSpace = DDCurrentNamespace::ns(); parentName = parent().name(); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace " - << idNameSpace << " for Rotation " << rotns << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace " + << idNameSpace << " for Rotation " << rotns; #endif } void DDHGCalWaferAlgo::execute(DDCompactView& cpv) { #ifdef EDM_ML_DEBUG - edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo..."; + edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo..."; #endif double dx = 0.5 * cellSize; - double dy = 0.5 * dx * tan(30.0 * CLHEP::deg); + double dy = 0.5 * dx * tan(30._deg); for (unsigned int k = 0; k < positionX.size(); ++k) { std::string name(childNames[detectorType[k]]); DDRotation rotation; std::string rotstr("NULL"); if (angles[k] != 0) { - if (angles[k] >= 0 && angles[k] < 100) - rotstr = "R0"; - else - rotstr = "R"; - rotstr = rotstr + std::to_string(angles[k]); + double phi = convertDegToRad(angles[k]); + rotstr = "R" + formatAsDegrees(phi); rotation = DDRotation(DDName(rotstr, rotns)); if (!rotation) { #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: Creating new rotation " - << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, " - << (angles[k] + 90) << ", 0, 0" << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalWaferAlgo: Creating new rotation " + << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, " + << (angles[k] + 90) << ", 0, 0"; #endif - rotation = DDrot(DDName(rotstr, rotns), 90 * CLHEP::deg, - angles[k] * CLHEP::deg, 90 * CLHEP::deg, - (90 + angles[k]) * CLHEP::deg, 0 * CLHEP::deg, - 0 * CLHEP::deg); + rotation = DDrot(DDName(rotstr, rotns), 90._deg, phi, + 90._deg, (90._deg + phi), 0, 0); } } double xpos = dx * positionX[k]; @@ -89,9 +88,10 @@ void DDHGCalWaferAlgo::execute(DDCompactView& cpv) { int copy = cellType * 1000 + k; cpv.position(DDName(name, idNameSpace), parentName, copy, tran, rotation); #ifdef EDM_ML_DEBUG - std::cout << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace) << " number " - << copy << " positioned in " << parentName << " at " << tran - << " with " << rotation << std::endl; + edm::LogVerbatim("HGCalGeom") + << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace) << " number " + << copy << " positioned in " << parentName << " at " << tran + << " with " << rotation; #endif } } diff --git a/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc b/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc index b159d69388059..cae2b31eeaf09 100644 --- a/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc +++ b/Geometry/HGCalCommonData/plugins/FastTimeNumberingInitialization.cc @@ -19,9 +19,6 @@ // // -// system include files -#include - // user include files #include #include @@ -51,7 +48,8 @@ class FastTimeNumberingInitialization : public edm::ESProducer { FastTimeNumberingInitialization::FastTimeNumberingInitialization( const edm::ParameterSet&) { #ifdef EDM_ML_DEBUG - std::cout << "constructing FastTimeNumberingInitialization" << std::endl; + edm::LogVerbatim("HGCalGeom") + << "constructing FastTimeNumberingInitialization"; #endif setWhatProduced(this); } @@ -62,7 +60,8 @@ FastTimeNumberingInitialization::~FastTimeNumberingInitialization() {} FastTimeNumberingInitialization::ReturnType FastTimeNumberingInitialization::produce(const IdealGeometryRecord& iRecord) { #ifdef EDM_ML_DEBUG - std::cout << "in FastTimeNumberingInitialization::produce" << std::endl; + edm::LogVerbatim("HGCalGeom") + << "in FastTimeNumberingInitialization::produce"; #endif edm::ESHandle pFTpar; iRecord.get(pFTpar); diff --git a/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc b/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc index fd6def4ada5d4..fcbf7f0bf516d 100644 --- a/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc +++ b/Geometry/HGCalCommonData/plugins/FastTimeParametersESModule.cc @@ -8,8 +8,6 @@ #include "Geometry/HGCalCommonData/interface/FastTimeParametersFromDD.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include - //#define EDM_ML_DEBUG class FastTimeParametersESModule : public edm::ESProducer { @@ -32,13 +30,12 @@ FastTimeParametersESModule::FastTimeParametersESModule( const edm::ParameterSet& iC) { name_ = iC.getUntrackedParameter >("Names"); type_ = iC.getUntrackedParameter >("Types"); - edm::LogInfo("HGCalGeom") - << "FastTimeParametersESModule for " << name_.size() << " types"; #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersESModule for " << name_.size() << " types:"; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersESModule for " << name_.size() << " types:"; for (unsigned int k = 0; k < name_.size(); ++k) - std::cout << " [" << k << "] " << name_[k] << ":" << type_[k]; - std::cout << std::endl; + edm::LogVerbatim("HGCalGeom") + << " [" << k << "] " << name_[k] << ":" << type_[k]; #endif setWhatProduced(this); } @@ -47,8 +44,8 @@ FastTimeParametersESModule::~FastTimeParametersESModule() {} FastTimeParametersESModule::ReturnType FastTimeParametersESModule::produce( const IdealGeometryRecord& iRecord) { - edm::LogInfo("HGCalGeom") << "FastTimeParametersESModule::produce(const " - "IdealGeometryRecord& iRecord)"; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersESModule::produce(const IdealGeometryRecord& iRecord)"; edm::ESTransientHandle cpv; iRecord.get(cpv); @@ -58,18 +55,20 @@ FastTimeParametersESModule::ReturnType FastTimeParametersESModule::produce( builder.build(&(*cpv), *ptp, name_[k], type_[k]); #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersESModule:: Barrel Parameters: " - << " number of cells along z|phi = " << ptp->nZBarrel_ << "|" - << ptp->nPhiBarrel_ << " Geometry parameters = ( "; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersESModule:: Barrel Parameters: " + << " number of cells along z|phi = " << ptp->nZBarrel_ << "|" + << ptp->nPhiBarrel_ << " Geometry parameters:"; for (unsigned k = 0; k < ptp->geomParBarrel_.size(); ++k) - std::cout << "[" << k << "] " << ptp->geomParBarrel_[k] << " "; - std::cout << ")" << std::endl; - std::cout << "FastTimeParametersESModule:: Endcap Parameters: " - << " number of cells along eta|phi = " << ptp->nEtaEndcap_ << "|" - << ptp->nPhiEndcap_ << " Geometry parameters = ( "; + edm::LogVerbatim("HGCalGeom") + << "[" << k << "] " << ptp->geomParBarrel_[k]; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersESModule:: Endcap Parameters: " + << " number of cells along eta|phi = " << ptp->nEtaEndcap_ << "|" + << ptp->nPhiEndcap_ << " Geometry parameters:"; for (unsigned k = 0; k < ptp->geomParEndcap_.size(); ++k) - std::cout << "[" << k << "] " << ptp->geomParEndcap_[k] << " "; - std::cout << ")" << std::endl; + edm::LogVerbatim("HGCalGeom") + << "[" << k << "] " << ptp->geomParEndcap_[k]; #endif return ptp; } diff --git a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc index adb50e42959eb..d6caf8a96df3f 100644 --- a/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc +++ b/Geometry/HGCalCommonData/plugins/HGCalNumberingInitialization.cc @@ -16,9 +16,6 @@ // Created: Tue Mar 21 16:40:29 PDT 2013 // -// system include files -#include - // user include files #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESProducer.h" @@ -50,9 +47,9 @@ HGCalNumberingInitialization::HGCalNumberingInitialization( const edm::ParameterSet& iConfig) : hgcalDDDConst_(nullptr) { name_ = iConfig.getUntrackedParameter("Name"); - edm::LogInfo("HGCalGeom") << "HGCalNumberingInitialization for " << name_; #ifdef EDM_ML_DEBUG - std::cout << "HGCalNumberingInitialization for " << name_ << std::endl; + edm::LogVerbatim("HGCalGeom") + << "HGCalNumberingInitialization for " << name_; #endif setWhatProduced(this, name_); } @@ -62,7 +59,7 @@ HGCalNumberingInitialization::~HGCalNumberingInitialization() {} // ------------ method called to produce the data ------------ HGCalNumberingInitialization::ReturnType HGCalNumberingInitialization::produce( const IdealGeometryRecord& iRecord) { - edm::LogInfo("HGCalGeom") << "in HGCalNumberingInitialization::produce"; + edm::LogVerbatim("HGCalGeom") << "in HGCalNumberingInitialization::produce"; if (hgcalDDDConst_ == nullptr) { edm::ESHandle pHGpar; iRecord.get(name_, pHGpar); diff --git a/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc b/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc index f4eed9deef8bd..69516b72f5cfb 100644 --- a/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc +++ b/Geometry/HGCalCommonData/plugins/HGCalParametersESModule.cc @@ -8,8 +8,6 @@ #include "Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include - //#define EDM_ML_DEBUG class HGCalParametersESModule : public edm::ESProducer { @@ -30,11 +28,10 @@ HGCalParametersESModule::HGCalParametersESModule(const edm::ParameterSet& iC) { namew_ = iC.getUntrackedParameter("NameW"); namec_ = iC.getUntrackedParameter("NameC"); namet_ = iC.getUntrackedParameter("NameT"); - edm::LogInfo("HGCalGeom") << "HGCalParametersESModule for " << name_ << ":" - << namew_ << ":" << namec_ << ":" << namet_; #ifdef EDM_ML_DEBUG - std::cout << "HGCalParametersESModule for " << name_ << ":" << namew_ << ":" - << namec_ << ":" << namet_ << std::endl; + edm::LogVerbatim("HGCalGeom") + << "HGCalParametersESModule for " << name_ << ":" << namew_ << ":" + << namec_ << ":" << namet_; #endif setWhatProduced(this, name_); } @@ -43,7 +40,7 @@ HGCalParametersESModule::~HGCalParametersESModule() {} HGCalParametersESModule::ReturnType HGCalParametersESModule::produce( const IdealGeometryRecord& iRecord) { - edm::LogInfo("HGCalGeom") + edm::LogVerbatim("HGCalGeom") << "HGCalParametersESModule::produce(const IdealGeometryRecord& iRecord)"; edm::ESTransientHandle cpv; iRecord.get(cpv); diff --git a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc index 5814aeb8e62e8..b0e01f6bee165 100644 --- a/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/FastTimeDDDConstants.cc @@ -4,14 +4,15 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" -//#define EDM_ML_DEBUG +#define EDM_ML_DEBUG using namespace geant_units::operators; FastTimeDDDConstants::FastTimeDDDConstants(const FastTimeParameters* ft) : ftpar_(ft) { #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants " - << "( const FastTimeParameters* ft ) constructor"; + edm::LogVerbatim("HGCalGeom") + << "FastTimeDDDConstants::FastTimeDDDConstants " + << "( const FastTimeParameters* ft ) constructor"; #endif initialize(); } diff --git a/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc b/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc index df8a30ed406be..7fd56c10689b4 100644 --- a/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc +++ b/Geometry/HGCalCommonData/src/FastTimeParametersFromDD.cc @@ -4,9 +4,6 @@ #include "DetectorDescription/Core/interface/DDutils.h" #include "Geometry/HGCalCommonData/interface/FastTimeParameters.h" -#include -#include -#include "CLHEP/Units/GlobalSystemOfUnits.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" //#define EDM_ML_DEBUG @@ -15,8 +12,9 @@ bool FastTimeParametersFromDD::build(const DDCompactView* cpv, FastTimeParameters& php, const std::string& name, const int type) { #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersFromDD::build called with names " << name - << " and type " << type << std::endl; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersFromDD::build called with names " << name + << " and type " << type; #endif // Special parameters at simulation level @@ -37,9 +35,9 @@ bool FastTimeParametersFromDD::build(const DDCompactView* cpv, temp = getDDDArray("numberPhiB", sv); php.nPhiBarrel_ = (int)(temp[0]); #ifdef EDM_ML_DEBUG - std::cout << "Barrel Parameters: " << php.nZBarrel_ << ":" - << php.nPhiBarrel_ << ":" << php.geomParBarrel_[0] << ":" - << php.geomParBarrel_[1] << std::endl; + edm::LogVerbatim("HGCalGeom") + << "Barrel Parameters: " << php.nZBarrel_ << ":" << php.nPhiBarrel_ + << ":" << php.geomParBarrel_[0] << ":" << php.geomParBarrel_[1]; #endif } else if (type == 2) { php.geomParEndcap_ = getDDDArray("geomParsE", sv); @@ -48,10 +46,10 @@ bool FastTimeParametersFromDD::build(const DDCompactView* cpv, temp = getDDDArray("numberPhiE", sv); php.nPhiEndcap_ = (int)(temp[0]); #ifdef EDM_ML_DEBUG - std::cout << "Endcap Parameters: " << php.nEtaEndcap_ << ":" - << php.nPhiEndcap_ << ":" << php.geomParEndcap_[0] << ":" - << php.geomParEndcap_[1] << ":" << php.geomParEndcap_[2] - << std::endl; + edm::LogVerbatim("HGCalGeom") + << "Endcap Parameters: " << php.nEtaEndcap_ << ":" + << php.nPhiEndcap_ << ":" << php.geomParEndcap_[0] << ":" + << php.geomParEndcap_[1] << ":" << php.geomParEndcap_[2]; #endif } else { edm::LogWarning("HGCalGeom") @@ -64,8 +62,9 @@ bool FastTimeParametersFromDD::build(const DDCompactView* cpv, << "Attribute " << val << " not found but needed."; } #ifdef EDM_ML_DEBUG - std::cout << "FastTimeParametersFromDD::Returns with flag " << ok << " for " - << name << " and type " << type << std::endl; + edm::LogVerbatim("HGCalGeom") + << "FastTimeParametersFromDD::Returns with flag " << ok << " for " + << name << " and type " << type; #endif return ok; } diff --git a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc index 9c795f01747b9..8d9ff4cbdded9 100644 --- a/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc +++ b/Geometry/HGCalCommonData/src/HGCalDDDConstants.cc @@ -1,5 +1,6 @@ #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h" #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" @@ -10,14 +11,12 @@ #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" - #include #include #include //#define EDM_ML_DEBUG +using namespace geant_units::operators; static const int maxType = 2; static const int minType = 0; @@ -31,7 +30,7 @@ HGCalDDDConstants::HGCalDDDConstants(const HGCalParameters* hp, (mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) { rmax_ = (HGCalParameters::k_ScaleFromDDD * (hgpar_->waferR_) * - std::cos(30.0 * CLHEP::deg)); + std::cos(30._deg)); hexside_ = 2.0 * rmax_ * tan30deg_; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") diff --git a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc index 06c58dae7e42c..84687c15eb1d4 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc @@ -4,8 +4,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DataFormats/Math/interface/Point3D.h" #include "DetectorDescription/Core/interface/DDConstant.h" #include "DetectorDescription/Core/interface/DDFilter.h" @@ -23,6 +22,7 @@ #include //#define EDM_ML_DEBUG +using namespace geant_units::operators; const double tolerance = 0.001; @@ -173,7 +173,7 @@ void HGCalGeomParameters::loadGeometryHexagon( zv = polygon.zVec(); rv = polygon.xVec(); } - php.waferR_ = rv[0] / std::cos(30.0 * CLHEP::deg); + php.waferR_ = rv[0] / std::cos(30._deg); php.waferSize_ = HGCalParameters::k_ScaleFromDDD * rv[0]; double dz = 0.5 * (zv[1] - zv[0]); #ifdef EDM_ML_DEBUG @@ -843,10 +843,10 @@ void HGCalGeomParameters::loadWaferHexagon(HGCalParameters& php) { php.waferPosX_.clear(); php.waferPosY_.clear(); double dx = 0.5 * waferW; - double dy = 3.0 * dx * tan(30.0 * CLHEP::deg); - double rr = 2.0 * dx * tan(30.0 * CLHEP::deg); + double dy = 3.0 * dx * tan(30._deg); + double rr = 2.0 * dx * tan(30._deg); int ncol = (int)(2.0 * rout / waferW) + 1; - int nrow = (int)(rout / (waferW * tan(30.0 * CLHEP::deg))) + 1; + int nrow = (int)(rout / (waferW * tan(30._deg))) + 1; int ns2 = (2 * ncol + 1) * (2 * nrow + 1) * php.layer_.size(); int incm(0), inrm(0), kount(0), ntot(0); HGCalParameters::layer_map copiesInLayers(php.layer_.size() + 1); diff --git a/Geometry/HGCalCommonData/src/HGCalParameters.cc b/Geometry/HGCalCommonData/src/HGCalParameters.cc index 5f0550ff433b8..b5c5074855ce6 100644 --- a/Geometry/HGCalCommonData/src/HGCalParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalParameters.cc @@ -1,6 +1,7 @@ #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" + //#define EDM_ML_DEBUG HGCalParameters::HGCalParameters(const std::string& nam) : name_(nam) { diff --git a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc index 489b40963727c..36ae98bcd6b95 100644 --- a/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc +++ b/Geometry/HGCalCommonData/src/HGCalParametersFromDD.cc @@ -1,4 +1,5 @@ #include "Geometry/HGCalCommonData/interface/HGCalParametersFromDD.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" #include "DetectorDescription/Core/interface/DDutils.h" @@ -6,12 +7,8 @@ #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include -#include -#include "CLHEP/Units/GlobalSystemOfUnits.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - //#define EDM_ML_DEBUG +using namespace geant_units::operators; namespace { HGCalGeometryMode::GeometryMode getGeometryMode(const char* s, @@ -140,7 +137,7 @@ bool HGCalParametersFromDD::build(const DDCompactView* cpv, php.mouseBite_ = HGCalParameters::k_ScaleFromDDD * getDDDValue("MouseBite", sv2); php.waferR_ = 0.5 * HGCalParameters::k_ScaleToDDD * php.waferSize_ / - std::cos(30.0 * CLHEP::deg); + std::cos(30._deg); php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * php.waferSize_ / php.nCellsFine_); php.cellSize_.emplace_back(HGCalParameters::k_ScaleToDDD * diff --git a/Geometry/HGCalCommonData/src/HGCalWaferType.cc b/Geometry/HGCalCommonData/src/HGCalWaferType.cc index bde086aaeb68d..f070a5dfcaa34 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferType.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferType.cc @@ -19,10 +19,10 @@ HGCalWaferType::HGCalWaferType(const std::vector& rad100, R_ = sqrt3_ * waferSize_; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") - << "HGCalWaferType: initialized with waferR's " << waferSize_ << ":" << r_ - << ":" << R_ << " Choice " << choice_ << " Cuts " << cutValue_ << ":" - << cutFracArea_ << " zMin " << zMin_ << " with " << rad100_.size() << ":" - << rad200_.size() << " parameters for R:"; + << "HGCalWaferType: initialized with waferR's " << waferSize_ << ":" + << r_ << ":" << R_ << " Choice " << choice_ << " Cuts " << cutValue_ + << ":" << cutFracArea_ << " zMin " << zMin_ << " with " << rad100_.size() + << ":" << rad200_.size() << " parameters for R:"; for (unsigned k = 0; k < rad100_.size(); ++k) edm::LogVerbatim("HGCalGeom") << "[" << k << "] 100:200 " << rad100_[k] << " 200:300 " << rad200_[k]; From 34a805efbc3b0edd42295c66dfe12d8522130eef Mon Sep 17 00:00:00 2001 From: tocheng Date: Tue, 16 Apr 2019 16:56:04 +0200 Subject: [PATCH 661/686] Revert "Update LHC optical function" This reverts commit 3aececc288009ab2e18437cf43de9e4b68f619ed. --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index cab253b1b16c0..eca796b48b005 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v8', + 'run1_data' : '106X_dataRun2_v7', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v8', + 'run2_data' : '106X_dataRun2_v7', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v6', + 'run2_data_relval' : '106X_dataRun2_relval_v5', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v4', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v3', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v4', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v4', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v3', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v3', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT From a1f666dded22b9a13782dbb51b2c0ecfeba41e3a Mon Sep 17 00:00:00 2001 From: tocheng Date: Tue, 16 Apr 2019 16:58:00 +0200 Subject: [PATCH 662/686] Revert "Fix PPS Geometry and add LHC optical function" This reverts commit 967250ae9f534874c2b6aa6a4908003c88a8e410. --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index eca796b48b005..57cd8de8df124 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v7', + 'run1_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v7', + 'run2_data' : '106X_dataRun2_v6', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v5', + 'run2_data_relval' : '106X_dataRun2_relval_v4', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v3', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v3', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v3', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v2', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v2', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT From ded34d87b6cb8a83f65182d8df2d23f6939abc61 Mon Sep 17 00:00:00 2001 From: tocheng Date: Tue, 16 Apr 2019 17:49:47 +0200 Subject: [PATCH 663/686] Fix CTPPS geometry in offline GTs --- Configuration/AlCa/python/autoCond.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 57cd8de8df124..4d6b51a14e8fa 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -24,16 +24,16 @@ # GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run2 'run2_mc_pa' : '106X_mcRun2_pA_v2', # GlobalTag for Run1 data reprocessing - 'run1_data' : '106X_dataRun2_v6', + 'run1_data' : '106X_dataRun2_PPSGeo_v6', # GlobalTag for Run2 data reprocessing - 'run2_data' : '106X_dataRun2_v6', + 'run2_data' : '106X_dataRun2_PPSGeo_v6', # GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu - 'run2_data_relval' : '106X_dataRun2_relval_v4', + 'run2_data_relval' : '106X_dataRun2_relval_PPSGeo_v4', # GlobalTag for Run2 data 2018B relvals only: HEM-15-16 fail - 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_v2', + 'run2_data_promptlike_HEfail' : '106X_dataRun2_PromptLike_HEfail_PPSGeo_v2', # GlobalTag for Run2 data 2016H relvals only: Prompt Conditions + fixed L1 menu (to be removed) - 'run2_data_promptlike' : '106X_dataRun2_PromptLike_v2', - 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_v2', + 'run2_data_promptlike' : '106X_dataRun2_PromptLike_PPSGeo_v2', + 'run2_data_promptlike_hi' : '106X_dataRun2_PromptLike_HI_PPSGeo_v2', # GlobalTag for Run1 HLT: it points to the online GT 'run1_hlt' : '101X_dataRun2_HLT_frozen_v9', # GlobalTag for Run2 HLT: it points to the online GT From fb618e536dafe9f3797de537c304d030e37bd1c5 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Tue, 16 Apr 2019 18:09:05 +0200 Subject: [PATCH 664/686] More clear syntax for hasShowerInStation and numberOfShowers --- DataFormats/MuonReco/src/Muon.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index 74e5d49285167..f29b8191869e6 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -385,21 +385,20 @@ int Muon::nDigisInStation( int station, int muonSubdetId ) const bool Muon::hasShowerInStation( int station, int muonSubdetId, int nDtDigisCut, int nCscDigisCut ) const { - bool hasShower = muonSubdetId == MuonSubdetId::DT ? - nDigisInStation(station,muonSubdetId) >= nDtDigisCut : - nDigisInStation(station,muonSubdetId) >= nCscDigisCut; + if (muonSubdetId != MuonSubdetId::DT || muonSubdetId != MuonSubdetId::CSC) return false; + auto nDigisCut = muonSubdetId == MuonSubdetId::DT ? nDtDigisCut : nCscDigisCut; - return hasShower; + return nDigisInStation(station,muonSubdetId) >= nDigisCut ; } int Muon::numberOfShowers( int nDtDigisCut, int nCscDigisCut ) const { int nShowers = 0; - for ( int iCh = 1; iCh < 5; ++iCh ) + for ( int station = 1; station < 5; ++station ) { - if ( hasShowerInStation(iCh,MuonSubdetId::DT,nDtDigisCut,nCscDigisCut) ) + if ( hasShowerInStation(station,MuonSubdetId::DT,nDtDigisCut,nCscDigisCut) ) nShowers++; - if ( hasShowerInStation(iCh,MuonSubdetId::CSC,nDtDigisCut,nCscDigisCut) ) + if ( hasShowerInStation(station,MuonSubdetId::CSC,nDtDigisCut,nCscDigisCut) ) nShowers++; } From d719e62e8541b3e100f5a981de0b42fdf189fb8c Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Tue, 16 Apr 2019 18:21:55 +0200 Subject: [PATCH 665/686] Fix: OR should be AND --- DataFormats/MuonReco/src/Muon.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/MuonReco/src/Muon.cc b/DataFormats/MuonReco/src/Muon.cc index f29b8191869e6..bec25d833ef17 100755 --- a/DataFormats/MuonReco/src/Muon.cc +++ b/DataFormats/MuonReco/src/Muon.cc @@ -385,7 +385,7 @@ int Muon::nDigisInStation( int station, int muonSubdetId ) const bool Muon::hasShowerInStation( int station, int muonSubdetId, int nDtDigisCut, int nCscDigisCut ) const { - if (muonSubdetId != MuonSubdetId::DT || muonSubdetId != MuonSubdetId::CSC) return false; + if (muonSubdetId != MuonSubdetId::DT && muonSubdetId != MuonSubdetId::CSC) return false; auto nDigisCut = muonSubdetId == MuonSubdetId::DT ? nDtDigisCut : nCscDigisCut; return nDigisInStation(station,muonSubdetId) >= nDigisCut ; From 5c7c1b29e1e990dbe7058f57de03fc6819a5f31e Mon Sep 17 00:00:00 2001 From: Felice Date: Tue, 16 Apr 2019 18:58:56 +0200 Subject: [PATCH 666/686] filling density map is not thread safe and is taken out of the parallel for --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index 0cf1f9d011d93..cdd2b33eea3f5 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -95,8 +95,6 @@ void HGCalCLUEAlgo::makeClusters() { double maxdensity = calculateLocalDensity(points_[i], hit_kdtree, actualLayer); // also stores rho (energy // density) for each point (node) - //Now that we have the density per point we can store it - setDensity(points_[i]); // calculate distance to nearest point with higher density storing // distance (delta) and point's index calculateDistanceToHigher(points_[i]); @@ -104,6 +102,8 @@ void HGCalCLUEAlgo::makeClusters() { layerClustersPerLayer_[i]); }); }); + //Now that we have the density per point we can store it + for(unsigned int i=0; i< 2 * maxlayer + 2; ++i) setDensity(points_[i]); } std::vector HGCalCLUEAlgo::getClusters(bool) { From 49a96071e7d6bd06c5554f0500591567bb8ee05d Mon Sep 17 00:00:00 2001 From: Felice Date: Tue, 16 Apr 2019 18:59:09 +0200 Subject: [PATCH 667/686] filling density map is not thread safe and is taken out of the parallel for --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc index c05e2ff678a9d..2221095bbeb0e 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc @@ -100,8 +100,6 @@ void HGCalImagingAlgo::makeClusters() { double maxdensity = calculateLocalDensity( points_[i], hit_kdtree, actualLayer); // also stores rho (energy // density) for each point (node) - //Now that we have the density per point we can store it - setDensity(points_[i]); // calculate distance to nearest point with higher density storing // distance (delta) and point's index calculateDistanceToHigher(points_[i]); @@ -109,6 +107,8 @@ void HGCalImagingAlgo::makeClusters() { actualLayer, layerClustersPerLayer_[i]); }); }); + //Now that we have the density per point we can store it + for(unsigned int i=0; i< 2 * maxlayer + 2; ++i) setDensity(points_[i]); } std::vector HGCalImagingAlgo::getClusters(bool doSharing) { From e741bd754fc35efdb03cb6234ae80c56801bbd9a Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Wed, 17 Apr 2019 04:29:09 +0200 Subject: [PATCH 668/686] Remove unused variables --- Validation/MuonHits/src/CSCSimHitMatcher.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Validation/MuonHits/src/CSCSimHitMatcher.cc b/Validation/MuonHits/src/CSCSimHitMatcher.cc index df71c3086cfc3..4332b42dc8fe8 100644 --- a/Validation/MuonHits/src/CSCSimHitMatcher.cc +++ b/Validation/MuonHits/src/CSCSimHitMatcher.cc @@ -207,8 +207,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { // phi in layer 1 const CSCDetId cscid1(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 1); - const edm::PSimHitContainer& hits1 = - MuonSimHitMatcher::hitsInDetId(cscid1.rawId()); const GlobalPoint& gp1 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid1.rawId())); phi_layer1 = gp1.phi(); @@ -216,8 +214,6 @@ float CSCSimHitMatcher::LocalBendingInChamber(unsigned int detid) const { // phi in layer 6 const CSCDetId cscid6(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 6); - const edm::PSimHitContainer& hits6 = - MuonSimHitMatcher::hitsInDetId(cscid6.rawId()); const GlobalPoint& gp6 = simHitsMeanPosition(MuonSimHitMatcher::hitsInDetId(cscid6.rawId())); phi_layer6 = gp6.phi(); From a591574484985e93ff7a3cae7235e53e24d7ed37 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 17 Apr 2019 09:19:09 +0200 Subject: [PATCH 669/686] remove deepdish --- PhysicsTools/PythonAnalysis/test/imports.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/PhysicsTools/PythonAnalysis/test/imports.txt b/PhysicsTools/PythonAnalysis/test/imports.txt index 2d259f9066d73..3db803a1e8623 100644 --- a/PhysicsTools/PythonAnalysis/test/imports.txt +++ b/PhysicsTools/PythonAnalysis/test/imports.txt @@ -20,7 +20,6 @@ climate cycler cython decorator -deepdish docopt downhill dxr From a00d27f01f6ce8cbc1177d527f58b6abe39cf4a3 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 17 Apr 2019 09:27:10 +0200 Subject: [PATCH 670/686] Update RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc Co-Authored-By: felicepantaleo --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index cdd2b33eea3f5..4b4daddfec686 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -103,7 +103,7 @@ void HGCalCLUEAlgo::makeClusters() { }); }); //Now that we have the density per point we can store it - for(unsigned int i=0; i< 2 * maxlayer + 2; ++i) setDensity(points_[i]); + for(auto const& p: points_) { setDensity(p); } } std::vector HGCalCLUEAlgo::getClusters(bool) { From 75b42c377441083c32521401eb22bae4a6064dd1 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 17 Apr 2019 09:27:21 +0200 Subject: [PATCH 671/686] Update RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc Co-Authored-By: felicepantaleo --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc index 2221095bbeb0e..3320bf181524d 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalImagingAlgo.cc @@ -108,7 +108,7 @@ void HGCalImagingAlgo::makeClusters() { }); }); //Now that we have the density per point we can store it - for(unsigned int i=0; i< 2 * maxlayer + 2; ++i) setDensity(points_[i]); +for(auto const& p: points_) { setDensity(p); } } std::vector HGCalImagingAlgo::getClusters(bool doSharing) { From cf9f22d37e3070369fbf652356d27d25865e1161 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Wed, 17 Apr 2019 10:42:43 +0200 Subject: [PATCH 672/686] Add to short matrix upgrade scenario D41 (baseline for L1T TDR) --- Configuration/PyReleaseValidation/scripts/runTheMatrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py index 76ad9b23862e6..753d3350e1c64 100755 --- a/Configuration/PyReleaseValidation/scripts/runTheMatrix.py +++ b/Configuration/PyReleaseValidation/scripts/runTheMatrix.py @@ -78,6 +78,7 @@ def runSelected(opt): 20034.0, #2023D17 ttbar (TDR baseline Muon/Barrel) 21234.0, #2023D21 ttbar (Inner Tracker with lower radii than in TDR) 27434.0, #2023D35 to exercise new HGCal + new MTD + 29034.0, #2023D41 (baseline for L1T TDR) 25202.0, #2016 ttbar UP15 PU 250202.181, #2018 ttbar stage1 + stage2 premix ], From bfe7a0a77fe862d059c09d963dd44acfd2627bd4 Mon Sep 17 00:00:00 2001 From: Jan Kaspar Date: Wed, 17 Apr 2019 16:49:18 +0200 Subject: [PATCH 673/686] Nothing done when input empty. --- .../plugins/CTPPSProtonProducer.cc | 414 +++++++++--------- 1 file changed, 210 insertions(+), 204 deletions(-) diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 3393ae1194a92..49d6cef0cd929 100644 --- a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -196,271 +196,277 @@ void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descr void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - // get conditions - edm::ESHandle hLHCInfo; - iSetup.get().get(lhcInfoLabel_, hLHCInfo); - - edm::ESHandle hOpticalFunctions; - iSetup.get().get(hOpticalFunctions); - - edm::ESHandle hGeometry; - iSetup.get().get(hGeometry); - - // re-initialise algorithm upon crossing-angle change - if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { - currentCrossingAngle_ = hLHCInfo->crossingAngle(); - - if (hOpticalFunctions->empty()) { - edm::LogInfo("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; - algorithm_.release(); - opticsValid_ = false; - } - else { - algorithm_.init(*hOpticalFunctions); - opticsValid_ = true; - } - } + // get input + edm::Handle hTracks; + iEvent.getByToken(tracksToken_, hTracks); // book output std::unique_ptr pOutSingleRP(new reco::ForwardProtonCollection); std::unique_ptr pOutMultiRP(new reco::ForwardProtonCollection); - // do reconstruction only if optics is valid - if (opticsValid_) + // continue only if there is something to process + // NB: this avoids loading (possibly non-existing) conditions in workflows without proton data + if (!hTracks->empty()) { - // prepare log - std::ostringstream ssLog; - if (verbosity_) - ssLog << "* input tracks:" << std::endl; + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(lhcInfoLabel_, hLHCInfo); - // get input - edm::Handle hTracks; - iEvent.getByToken(tracksToken_, hTracks); + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); - // select tracks with small local angles, split them by LHC sector and tracker/timing RPs - std::map> trackingSelection, timingSelection; + edm::ESHandle hGeometry; + iSetup.get().get(hGeometry); - for (unsigned int idx = 0; idx < hTracks->size(); ++idx) + // re-initialise algorithm upon crossing-angle change + if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { - const auto& tr = hTracks->at(idx); - - if (tr.getTx() < localAngleXMin_ || tr.getTx() > localAngleXMax_ - || tr.getTy() < localAngleYMin_ || tr.getTy() > localAngleYMax_) - continue; + currentCrossingAngle_ = hLHCInfo->crossingAngle(); - const CTPPSDetId rpId(tr.getRPId()); - - if (verbosity_) - ssLog << "\t" - << "[" << idx << "] " - << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " - << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " - << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; - - const bool trackerRP = (rpId.subdetId() == CTPPSDetId::sdTrackingStrip || rpId.subdetId() == CTPPSDetId::sdTrackingPixel); - - if (trackerRP) - trackingSelection[rpId.arm()].push_back(idx); - else - timingSelection[rpId.arm()].push_back(idx); + if (hOpticalFunctions->empty()) { + edm::LogInfo("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; + algorithm_.release(); + opticsValid_ = false; + } + else { + algorithm_.init(*hOpticalFunctions); + opticsValid_ = true; + } } - // process each arm - for (const auto &arm_it : trackingSelection) + // do reconstruction only if optics is valid + if (opticsValid_) { - const auto &indices = arm_it.second; + // prepare log + std::ostringstream ssLog; + if (verbosity_) + ssLog << "* input tracks:" << std::endl; - const auto &ac = association_cuts_[arm_it.first]; + // select tracks with small local angles, split them by LHC sector and tracker/timing RPs + std::map> trackingSelection, timingSelection; - // do single-RP reco if needed - std::map singleRPResultsIndexed; - if (doSingleRPReconstruction_ || ac.xi_cut_apply || ac.th_y_cut_apply) + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { - for (const auto &idx : indices) - { - if (verbosity_) - ssLog << std::endl << "* reconstruction from track " << idx << std::endl; + const auto& tr = hTracks->at(idx); - singleRPResultsIndexed[idx] = algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), *hLHCInfo, ssLog); - } - } - - // do multi-RP reco if chosen - if (doMultiRPReconstruction_) - { - // check that exactly two tracking RPs are involved - // - 1 is insufficient for multi-RP reconstruction - // - PPS did not use more than 2 tracking RPs per arm -> algorithms are tuned to this - std::set rpIds; - for (const auto &idx : indices) - rpIds.insert(hTracks->at(idx).getRPId()); - if (rpIds.size() != 2) + if (tr.getTx() < localAngleXMin_ || tr.getTx() > localAngleXMax_ + || tr.getTy() < localAngleYMin_ || tr.getTy() > localAngleYMax_) continue; - // find matching track pairs from different tracking RPs - std::vector> idx_pairs; - std::map idx_pair_multiplicity; - for (const auto &i : indices) - { - for (const auto &j : indices) - { - if (j <= i) - continue; + const CTPPSDetId rpId(tr.getRPId()); - const auto &tr_i = hTracks->at(i); - const auto &tr_j = hTracks->at(j); + if (verbosity_) + ssLog << "\t" + << "[" << idx << "] " + << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " + << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " + << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm" << std::endl; - const auto &pr_i = singleRPResultsIndexed[i]; - const auto &pr_j = singleRPResultsIndexed[j]; + const bool trackerRP = (rpId.subdetId() == CTPPSDetId::sdTrackingStrip || rpId.subdetId() == CTPPSDetId::sdTrackingPixel); - if (tr_i.getRPId() == tr_j.getRPId()) - continue; + if (trackerRP) + trackingSelection[rpId.arm()].push_back(idx); + else + timingSelection[rpId.arm()].push_back(idx); + } - bool matching = true; + // process each arm + for (const auto &arm_it : trackingSelection) + { + const auto &indices = arm_it.second; - if (ac.x_cut_apply && std::abs(tr_i.getX() - tr_j.getX()) > ac.x_cut_value) - matching = false; - if (ac.y_cut_apply && std::abs(tr_i.getY() - tr_j.getY()) > ac.y_cut_value) - matching = false; - if (ac.xi_cut_apply && std::abs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value) - matching = false; - if (ac.th_y_cut_apply && std::abs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value) - matching = false; + const auto &ac = association_cuts_[arm_it.first]; - if (!matching) - continue; + // do single-RP reco if needed + std::map singleRPResultsIndexed; + if (doSingleRPReconstruction_ || ac.xi_cut_apply || ac.th_y_cut_apply) + { + for (const auto &idx : indices) + { + if (verbosity_) + ssLog << std::endl << "* reconstruction from track " << idx << std::endl; - idx_pairs.emplace_back(i, j); - idx_pair_multiplicity[i]++; - idx_pair_multiplicity[j]++; + singleRPResultsIndexed[idx] = algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), *hLHCInfo, ssLog); } } - // evaluate track multiplicity in each timing RP - std::map timing_RP_track_multiplicity; - for (const auto &ti : timingSelection[arm_it.first]) + // do multi-RP reco if chosen + if (doMultiRPReconstruction_) { - const auto &tr = hTracks->at(ti); - timing_RP_track_multiplicity[tr.getRPId()]++; - } - - // associate tracking-RP pairs with timing-RP tracks - std::map> matched_timing_track_indices; - std::map matched_timing_track_multiplicity; - for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) - { - const auto &i = idx_pairs[pr_idx].first; - const auto &j = idx_pairs[pr_idx].second; - - // skip non-unique associations - if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) + // check that exactly two tracking RPs are involved + // - 1 is insufficient for multi-RP reconstruction + // - PPS did not use more than 2 tracking RPs per arm -> algorithms are tuned to this + std::set rpIds; + for (const auto &idx : indices) + rpIds.insert(hTracks->at(idx).getRPId()); + if (rpIds.size() != 2) continue; - const auto &tr_i = hTracks->at(i); - const auto &tr_j = hTracks->at(j); - - const double z_i = hGeometry->getRPTranslation(tr_i.getRPId()).z(); - const double z_j = hGeometry->getRPTranslation(tr_j.getRPId()).z(); + // find matching track pairs from different tracking RPs + std::vector> idx_pairs; + std::map idx_pair_multiplicity; + for (const auto &i : indices) + { + for (const auto &j : indices) + { + if (j <= i) + continue; + + const auto &tr_i = hTracks->at(i); + const auto &tr_j = hTracks->at(j); + + const auto &pr_i = singleRPResultsIndexed[i]; + const auto &pr_j = singleRPResultsIndexed[j]; + + if (tr_i.getRPId() == tr_j.getRPId()) + continue; + + bool matching = true; + + if (ac.x_cut_apply && std::abs(tr_i.getX() - tr_j.getX()) > ac.x_cut_value) + matching = false; + if (ac.y_cut_apply && std::abs(tr_i.getY() - tr_j.getY()) > ac.y_cut_value) + matching = false; + if (ac.xi_cut_apply && std::abs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value) + matching = false; + if (ac.th_y_cut_apply && std::abs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value) + matching = false; + + if (!matching) + continue; + + idx_pairs.emplace_back(i, j); + idx_pair_multiplicity[i]++; + idx_pair_multiplicity[j]++; + } + } + // evaluate track multiplicity in each timing RP + std::map timing_RP_track_multiplicity; for (const auto &ti : timingSelection[arm_it.first]) { - const auto &tr_ti = hTracks->at(ti); + const auto &tr = hTracks->at(ti); + timing_RP_track_multiplicity[tr.getRPId()]++; + } - // skip if timing RP saturated (high track multiplicity) - if (timing_RP_track_multiplicity[tr_ti.getRPId()] > max_n_timing_tracks_) + // associate tracking-RP pairs with timing-RP tracks + std::map> matched_timing_track_indices; + std::map matched_timing_track_multiplicity; + for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) + { + const auto &i = idx_pairs[pr_idx].first; + const auto &j = idx_pairs[pr_idx].second; + + // skip non-unique associations + if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) continue; - // interpolation from tracking RPs - const double z_ti = - hGeometry->getRPTranslation(tr_ti.getRPId()).z(); // the minus sign fixes a bug in the diamond geometry - const double f_i = (z_ti - z_j) / (z_i - z_j), f_j = (z_i - z_ti) / (z_i - z_j); - const double x_inter = f_i * tr_i.getX() + f_j * tr_j.getX(); - const double x_inter_unc_sq = f_i*f_i * tr_i.getXUnc()*tr_i.getXUnc() + f_j*f_j * tr_j.getXUnc()*tr_j.getXUnc(); + const auto &tr_i = hTracks->at(i); + const auto &tr_j = hTracks->at(j); - const double de_x = tr_ti.getX() - x_inter; - const double de_x_unc = sqrt(tr_ti.getXUnc()*tr_ti.getXUnc() + x_inter_unc_sq); + const double z_i = hGeometry->getRPTranslation(tr_i.getRPId()).z(); + const double z_j = hGeometry->getRPTranslation(tr_j.getRPId()).z(); - const bool matching = (std::abs(de_x) <= de_x_unc); + for (const auto &ti : timingSelection[arm_it.first]) + { + const auto &tr_ti = hTracks->at(ti); - if (verbosity_) - ssLog << "ti=" << ti << ", i=" << i << ", j=" << j - << " | z_ti=" << z_ti << ", z_i=" << z_i << ", z_j=" << z_j - << " | x_ti=" << tr_ti.getX() << ", x_inter=" << x_inter << ", de_x=" << de_x << ", de_x_unc=" << de_x_unc - << ", matching=" << matching << std::endl; + // skip if timing RP saturated (high track multiplicity) + if (timing_RP_track_multiplicity[tr_ti.getRPId()] > max_n_timing_tracks_) + continue; - if (!matching) - continue; + // interpolation from tracking RPs + const double z_ti = - hGeometry->getRPTranslation(tr_ti.getRPId()).z(); // the minus sign fixes a bug in the diamond geometry + const double f_i = (z_ti - z_j) / (z_i - z_j), f_j = (z_i - z_ti) / (z_i - z_j); + const double x_inter = f_i * tr_i.getX() + f_j * tr_j.getX(); + const double x_inter_unc_sq = f_i*f_i * tr_i.getXUnc()*tr_i.getXUnc() + f_j*f_j * tr_j.getXUnc()*tr_j.getXUnc(); - matched_timing_track_indices[pr_idx].push_back(ti); - matched_timing_track_multiplicity[ti]++; - } - } + const double de_x = tr_ti.getX() - x_inter; + const double de_x_unc = sqrt(tr_ti.getXUnc()*tr_ti.getXUnc() + x_inter_unc_sq); - // process associated tracks - for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) - { - const auto &i = idx_pairs[pr_idx].first; - const auto &j = idx_pairs[pr_idx].second; + const bool matching = (std::abs(de_x) <= de_x_unc); - // skip non-unique associations of tracking-RP tracks - if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) - continue; + if (verbosity_) + ssLog << "ti=" << ti << ", i=" << i << ", j=" << j + << " | z_ti=" << z_ti << ", z_i=" << z_i << ", z_j=" << z_j + << " | x_ti=" << tr_ti.getX() << ", x_inter=" << x_inter << ", de_x=" << de_x << ", de_x_unc=" << de_x_unc + << ", matching=" << matching << std::endl; - if (verbosity_) - ssLog << std::endl << "* reconstruction from tracking-RP tracks: " << i << ", " << j << " and timing-RP tracks: "; + if (!matching) + continue; - // process tracking-RP data - CTPPSLocalTrackLiteRefVector sel_tracks; - sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, i)); - sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, j)); - reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_tracks, *hLHCInfo, ssLog); + matched_timing_track_indices[pr_idx].push_back(ti); + matched_timing_track_multiplicity[ti]++; + } + } - // process timing-RP data - double sw=0., swt=0.; - for (const auto &ti : matched_timing_track_indices[pr_idx]) + // process associated tracks + for (unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) { - // skip non-unique associations of timing-RP tracks - if (matched_timing_track_multiplicity[ti] > 1) + const auto &i = idx_pairs[pr_idx].first; + const auto &j = idx_pairs[pr_idx].second; + + // skip non-unique associations of tracking-RP tracks + if (idx_pair_multiplicity[i] > 1 || idx_pair_multiplicity[j] > 1) continue; - sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, ti)); + if (verbosity_) + ssLog << std::endl << "* reconstruction from tracking-RP tracks: " << i << ", " << j << " and timing-RP tracks: "; + + // process tracking-RP data + CTPPSLocalTrackLiteRefVector sel_tracks; + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, i)); + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, j)); + reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_tracks, *hLHCInfo, ssLog); + + // process timing-RP data + double sw=0., swt=0.; + for (const auto &ti : matched_timing_track_indices[pr_idx]) + { + // skip non-unique associations of timing-RP tracks + if (matched_timing_track_multiplicity[ti] > 1) + continue; + + sel_tracks.push_back(CTPPSLocalTrackLiteRef(hTracks, ti)); + + if (verbosity_) + ssLog << ti << ", "; + + const auto &tr = hTracks->at(ti); + const double t_unc = tr.getTimeUnc(); + const double w = (t_unc > 0.) ? 1./t_unc/t_unc : 1.; + sw += w; + swt += w * tr.getTime(); + } + + float time = 0., time_unc = 0.; + if (sw > 0.) + { + time = swt / sw; + time_unc = 1. / sqrt(sw); + } if (verbosity_) - ssLog << ti << ", "; + ssLog << std::endl << " time = " << time << " +- " << time_unc << std::endl; - const auto &tr = hTracks->at(ti); - const double t_unc = tr.getTimeUnc(); - const double w = (t_unc > 0.) ? 1./t_unc/t_unc : 1.; - sw += w; - swt += w * tr.getTime(); - } + // save combined output + proton.setContributingLocalTracks(sel_tracks); + proton.setTime(time); + proton.setTimeError(time_unc); - float time = 0., time_unc = 0.; - if (sw > 0.) - { - time = swt / sw; - time_unc = 1. / sqrt(sw); + pOutMultiRP->emplace_back(proton); } - - if (verbosity_) - ssLog << std::endl << " time = " << time << " +- " << time_unc << std::endl; - - // save combined output - proton.setContributingLocalTracks(sel_tracks); - proton.setTime(time); - proton.setTimeError(time_unc); - - pOutMultiRP->emplace_back(proton); } + + // save single-RP results (un-indexed) + for (const auto &p : singleRPResultsIndexed) + pOutSingleRP->emplace_back(std::move(p.second)); } - // save single-RP results (un-indexed) - for (const auto &p : singleRPResultsIndexed) - pOutSingleRP->emplace_back(std::move(p.second)); + // dump log + if (verbosity_) + edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); } - - // dump log - if (verbosity_) - edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); } // save output From e5982101dcdc3211f2a2cb08339f030c50b5249e Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Mon, 11 Mar 2019 14:46:44 +0100 Subject: [PATCH 674/686] Validation package for MTD's SIM and DIGI hits --- .../plugins/BtlDigiHitsValidation.cc | 211 +++++++++++++++ .../plugins/BtlSimHitsValidation.cc | 246 +++++++++++++++++ .../MtdValidation/plugins/BuildFile.xml | 7 + .../plugins/EtlDigiHitsValidation.cc | 210 +++++++++++++++ .../plugins/EtlSimHitsValidation.cc | 251 ++++++++++++++++++ .../MtdValidation/test/mtdValidation_cfg.py | 47 ++++ 6 files changed, 972 insertions(+) create mode 100644 Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc create mode 100644 Validation/MtdValidation/plugins/BtlSimHitsValidation.cc create mode 100644 Validation/MtdValidation/plugins/BuildFile.xml create mode 100644 Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc create mode 100644 Validation/MtdValidation/plugins/EtlSimHitsValidation.cc create mode 100644 Validation/MtdValidation/test/mtdValidation_cfg.py diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc new file mode 100644 index 0000000000000..a45cf4f6cc8a7 --- /dev/null +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -0,0 +1,211 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: BtlDigiHitsValidation +// +/**\class BtlDigiHitsValidation BtlDigiHitsValidation.cc Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc + + Description: BTL DIGI hits validation + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Massimo Casarsa +// Created: Mon, 11 Mar 2019 14:12:22 GMT +// +// + +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" + +#include "DataFormats/ForwardDetId/interface/BTLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/Records/interface/MTDTopologyRcd.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" + +#include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" +#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" + + +// +// class declaration +// + + +class BtlDigiHitsValidation : public DQMEDAnalyzer { + +public: + explicit BtlDigiHitsValidation(const edm::ParameterSet&); + ~BtlDigiHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + + // ------------ member data ------------ + + const MTDGeometry* geom_; + const MTDTopology* topo_; + + const std::string folder_; + const std::string infoLabel_; + const std::string btlDigisCollection_; + + int eventCount_; + + edm::EDGetTokenT btlDigiHitsToken_; + + MonitorElement* meHitCharge_[2]; + MonitorElement* meHitTime1_[2]; + MonitorElement* meHitTime2_[2]; + + MonitorElement* meOccupancy_[2]; + +}; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + topo_(nullptr), + folder_(iConfig.getParameter("folder")), + infoLabel_(iConfig.getParameter("moduleLabel")), + btlDigisCollection_(iConfig.getParameter("btlDigiHitsCollection")), + eventCount_(0) { + + btlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), + std::string(btlDigisCollection_))); + +} + + +BtlDigiHitsValidation::~BtlDigiHitsValidation() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::ESHandle topologyHandle; + iSetup.get().get(topologyHandle); + topo_ = topologyHandle.product(); + + edm::Handle btlDigiHitsHandle; + iEvent.getByToken(btlDigiHitsToken_, btlDigiHitsHandle); + + if( ! btlDigiHitsHandle.isValid() ) return; + + eventCount_++; + + // --- Loop over the BLT DIGI hits + for (const auto& dataFrame: *btlDigiHitsHandle) { + + //DetId id = dataFrame.id(); + + const auto& sample_L = dataFrame.sample(0); + const auto& sample_R = dataFrame.sample(1); + + uint32_t adcL = sample_L.data(); + uint32_t adcR = sample_R.data(); + uint32_t tdc1L = sample_L.toa(); + uint32_t tdc1R = sample_R.toa(); + uint32_t tdc2L = sample_L.toa2(); + uint32_t tdc2R = sample_R.toa2(); + + meHitCharge_[0]->Fill(adcL); + meHitCharge_[1]->Fill(adcR); + meHitTime1_[0]->Fill(tdc1L); + meHitTime1_[1]->Fill(tdc1R); + meHitTime2_[0]->Fill(tdc2L); + meHitTime2_[1]->Fill(tdc2R); + + } // dataFrame loop + + + +} + +void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);amplitude [ADC counts]", + 1024, 0., 1024.); + meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);amplitude [ADC counts]", + 1024, 0., 1024.); + meHitTime1_[0] = ibook.book1D("BtlHitTime1L", "BTL DIGI hits ToA1 (L);ToA [TDC counts]", + 1024, 0., 1024.); + meHitTime1_[1] = ibook.book1D("BtlHitTime1R", "BTL DIGI hits ToA1 (R);ToA [TDC counts]", + 1024, 0., 1024.); + meHitTime2_[0] = ibook.book1D("BtlHitTime2L", "BTL DIGI hits ToA2 (L);ToA [TDC counts]", + 1024, 0., 1024.); + meHitTime2_[1] = ibook.book1D("BtlHitTime2R", "BTL DIGI hits ToA2 (R);ToA [TDC counts]", + 1024, 0., 1024.); + meOccupancy_[0] = ibook.book2D("BtlOccupancyL","BTL DIGI hits occupancy (L);z [cm]; #phi [rad]", + 65, -260., 260., 315, -3.15, 3.15 ); + meOccupancy_[1] = ibook.book2D("BtlOccupancyR","BTL DIGI hits occupancy (R);z [cm]; #phi [rad]", + 65, -260., 260., 315, -3.15, 3.15 ); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void BtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // The following says we do not know what parameters are allowed so do no + // validation + // Please change this to state exactly what you do use, even if it is no + // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/BTL/DigiHits"); + desc.add("moduleLabel","mix"); + desc.add("btlDigiHitsCollection","FTLBarrel"); + descriptions.add("btlDigiHits", desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(BtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc new file mode 100644 index 0000000000000..5f085a972d029 --- /dev/null +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -0,0 +1,246 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: BtlSimHitsValidation +// +/**\class BtlSimHitsValidation BtlSimHitsValidation.cc Validation/MtdValidation/plugins/BtlSimHitsValidation.cc + + Description: BTL SIM hits validation + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Massimo Casarsa +// Created: Fri, 08 Mar 2019 14:04:22 GMT +// +// + +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +#include "DataFormats/ForwardDetId/interface/BTLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/Records/interface/MTDTopologyRcd.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" + +#include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" +#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" + + +// +// class declaration +// + + +class BtlSimHitsValidation : public DQMEDAnalyzer { + +public: + explicit BtlSimHitsValidation(const edm::ParameterSet&); + ~BtlSimHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + +// ------------ member data ------------ + + const MTDGeometry* geom_; + const MTDTopology* topo_; + + const std::string folder_; + const std::string g4InfoLabel_; + const std::string btlHitsCollection_; + + const float hitMinEnergy_; + + int eventCount_; + + edm::EDGetTokenT btlSimHitsToken_; + + MonitorElement* meHitEnergy_; + MonitorElement* meHitTime_; + + MonitorElement* meOccupancy_; + +}; + +// +// constants, enums and typedefs +// + +struct MTDHit { + float energy; + float time; + float x; + float y; + float z; +}; + +// +// static data member definitions +// + +// +// constructors and destructor +// +BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + topo_(nullptr), + folder_(iConfig.getParameter("folder")), + g4InfoLabel_(iConfig.getParameter("moduleLabelG4")), + btlHitsCollection_(iConfig.getParameter("btlSimHitsCollection")), + hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ), + eventCount_(0) { + + btlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel_), + std::string(btlHitsCollection_))); + +} + + +BtlSimHitsValidation::~BtlSimHitsValidation() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::ESHandle topologyHandle; + iSetup.get().get(topologyHandle); + topo_ = topologyHandle.product(); + + edm::Handle btlSimHitsHandle; + iEvent.getByToken(btlSimHitsToken_, btlSimHitsHandle); + + if( ! btlSimHitsHandle.isValid() ) return; + + eventCount_++; + + std::map m_btlHits; + + // --- Loop over the BLT SIM hits + for (auto const& simHit: *btlSimHitsHandle) { + + // --- Only hits compatible with the in-time bunch-crossing + if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; + + DetId id = simHit.detUnitId(); + + auto simHitIt = m_btlHits.emplace(id.rawId(),MTDHit()).first; + + // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell + (simHitIt->second).energy += 1000.*simHit.energyLoss(); + + // --- Get the time of the first SIM hit in the cell + if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { + + (simHitIt->second).time = simHit.tof(); + + auto hit_pos = simHit.entryPoint(); + (simHitIt->second).x = hit_pos.x(); + (simHitIt->second).y = hit_pos.y(); + (simHitIt->second).z = hit_pos.z(); + + } + + } // simHit loop + + + // ============================================================================== + // Histogram filling + // ============================================================================== + + for (auto const& hit: m_btlHits) { + + if ( (hit.second).energy < hitMinEnergy_ ) continue; + + // --- Get the SIM hit global position + BTLDetId detId(hit.first); + DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("BtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); + const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); + + Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); + local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + const auto& global_point = thedet->toGlobal(local_point); + + // --- Fill the histograms + meHitEnergy_->Fill((hit.second).energy); + meHitTime_->Fill((hit.second).time); + meOccupancy_->Fill(global_point.z(),global_point.phi()); + + } // hit loop + +} + +void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 200, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 250, 0., 25.); + + meOccupancy_ = ibook.book2D("BtlOccupancy","BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", + 520, -260., 260., 315, -3.15, 3.15 ); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void BtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // The following says we do not know what parameters are allowed so do no + // validation + // Please change this to state exactly what you do use, even if it is no + // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/BTL/SimHits"); + desc.add("moduleLabelG4","g4SimHits"); + desc.add("btlSimHitsCollection","FastTimerHitsBarrel"); + desc.add("hitMinimumEnergy",1.); // [MeV] + descriptions.add("btlSimHits", desc); + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(BtlSimHitsValidation); diff --git a/Validation/MtdValidation/plugins/BuildFile.xml b/Validation/MtdValidation/plugins/BuildFile.xml new file mode 100644 index 0000000000000..bb1596d73ba87 --- /dev/null +++ b/Validation/MtdValidation/plugins/BuildFile.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc new file mode 100644 index 0000000000000..fd0dd4fafcfaa --- /dev/null +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -0,0 +1,210 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: EtlDigiHitsValidation +// +/**\class EtlDigiHitsValidation EtlDigiHitsValidation.cc Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc + + Description: ETL DIGI hits validation + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Massimo Casarsa +// Created: Mon, 11 Mar 2019 14:30:22 GMT +// +// + +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" + +#include "DataFormats/ForwardDetId/interface/ETLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" + + +// +// class declaration +// + + +class EtlDigiHitsValidation : public DQMEDAnalyzer { + +public: + explicit EtlDigiHitsValidation(const edm::ParameterSet&); + ~EtlDigiHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + + // ------------ member data ------------ + + const MTDGeometry* geom_; + + const std::string folder_; + const std::string infoLabel_; + const std::string etlDigisCollection_; + + int eventCount_; + + edm::EDGetTokenT etlDigiHitsToken_; + + MonitorElement* meHitCharge_[2]; + MonitorElement* meHitTime_[2]; + + MonitorElement* meOccupancy_[2]; + +}; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + folder_(iConfig.getParameter("folder")), + infoLabel_(iConfig.getParameter("moduleLabel")), + etlDigisCollection_(iConfig.getParameter("etlDigiHitsCollection")), + eventCount_(0) { + + etlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), + std::string(etlDigisCollection_))); + +} + + +EtlDigiHitsValidation::~EtlDigiHitsValidation() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::Handle etlDigiHitsHandle; + iEvent.getByToken(etlDigiHitsToken_, etlDigiHitsHandle); + + if( ! etlDigiHitsHandle.isValid() ) return; + + eventCount_++; + + // --- Loop over the ELT DIGI hits + for (const auto& dataFrame: *etlDigiHitsHandle) { + + // --- Get the on-time sample + int isample = 2; + + const auto& sample = dataFrame.sample(isample); + + ETLDetId detId = dataFrame.id(); + + DetId geoId = detId.geographicalId(); + + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + + Local3DPoint local_point(0.,0.,0.); + const auto& global_point = thedet->toGlobal(local_point); + + // --- Fill the histograms + if ( detId.zside()>0. ){ + + meHitCharge_[0]->Fill(sample.data()); + meHitTime_[0]->Fill(sample.toa()); + meOccupancy_[0]->Fill(global_point.x(),global_point.y()); + + } + else { + + meHitCharge_[1]->Fill(sample.data()); + meHitTime_[1]->Fill(sample.toa()); + meOccupancy_[1]->Fill(global_point.x(),global_point.y()); + + } + + } // dataFrame loop + +} + +void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + meHitCharge_[0] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);amplitude [ADC counts]", + 256, 0., 256.); + meHitCharge_[1] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);amplitude [ADC counts]", + 256, 0., 256.); + + meHitTime_[0] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA [TDC counts]", + 1000, 0., 2000.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA [TDC counts]", + 1000, 0., 2000.); + + meOccupancy_[0] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", + 135, -135., 135., 135, -135., 135.); + meOccupancy_[1] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);x [cm];y [cm]", + 135, -135., 135., 135, -135., 135.); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void EtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // The following says we do not know what parameters are allowed so do no + // validation + // Please change this to state exactly what you do use, even if it is no + // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/ETL/DigiHits"); + desc.add("moduleLabel","mix"); + desc.add("etlDigiHitsCollection","FTLEndcap"); + descriptions.add("etlDigiHits", desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(EtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc new file mode 100644 index 0000000000000..5478c2a424220 --- /dev/null +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -0,0 +1,251 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: EtlSimHitsValidation +// +/**\class EtlSimHitsValidation EtlSimHitsValidation.cc Validation/MtdValidation/plugins/EtlSimHitsValidation.cc + + Description: ETL SIM hits validation + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Massimo Casarsa +// Created: Mon, 11 Mar 2019 13:56:22 GMT +// +// + +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +#include "DataFormats/ForwardDetId/interface/ETLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" + + +// +// class declaration +// + + +class EtlSimHitsValidation : public DQMEDAnalyzer { + +public: + explicit EtlSimHitsValidation(const edm::ParameterSet&); + ~EtlSimHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + +// ------------ member data ------------ + + const MTDGeometry* geom_; + + const std::string folder_; + const std::string g4InfoLabel_; + const std::string etlHitsCollection_; + + const float hitMinEnergy_; + + int eventCount_; + + edm::EDGetTokenT etlSimHitsToken_; + + MonitorElement* meHitEnergyZpos_; + MonitorElement* meHitEnergyZneg_; + MonitorElement* meHitTimeZpos_; + MonitorElement* meHitTimeZneg_; + + MonitorElement* meOccupancyZpos_; + MonitorElement* meOccupancyZneg_; + +}; + +// +// constants, enums and typedefs +// + +struct MTDHit { + float energy; + float time; + float x; + float y; + float z; +}; + +// +// static data member definitions +// + +// +// constructors and destructor +// +EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + folder_(iConfig.getParameter("folder")), + g4InfoLabel_(iConfig.getParameter("moduleLabelG4")), + etlHitsCollection_(iConfig.getParameter("etlSimHitsCollection")), + hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ), + eventCount_(0) { + + etlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel_), + std::string(etlHitsCollection_))); + +} + + +EtlSimHitsValidation::~EtlSimHitsValidation() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::Handle etlSimHitsHandle; + iEvent.getByToken(etlSimHitsToken_, etlSimHitsHandle); + + if( ! etlSimHitsHandle.isValid() ) return; + + eventCount_++; + + std::map m_etlHits; + + // --- Loop over the BLT SIM hits + for (auto const& simHit: *etlSimHitsHandle) { + + // --- Only hits compatible with the in-time bunch-crossing + if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; + + DetId id = simHit.detUnitId(); + + auto simHitIt = m_etlHits.emplace(id.rawId(),MTDHit()).first; + + // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell + (simHitIt->second).energy += 1000.*simHit.energyLoss(); + + // --- Get the time of the first SIM hit in the cell + if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { + + (simHitIt->second).time = simHit.tof(); + + auto hit_pos = simHit.entryPoint(); + (simHitIt->second).x = hit_pos.x(); + (simHitIt->second).y = hit_pos.y(); + (simHitIt->second).z = hit_pos.z(); + + } + + } // simHit loop + + + // ============================================================================== + // Histogram filling + // ============================================================================== + + for (auto const& hit: m_etlHits) { + + if ( (hit.second).energy < hitMinEnergy_ ) continue; + + // --- Get the SIM hit global position + ETLDetId detId(hit.first); + + DetId geoId = detId.geographicalId(); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + + Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); + const auto& global_point = thedet->toGlobal(local_point); + + // --- Fill the histograms + if ( detId.zside()>0. ){ + + meHitEnergyZpos_->Fill((hit.second).energy); + meHitTimeZpos_->Fill((hit.second).time); + meOccupancyZpos_->Fill(global_point.x(),global_point.y()); + + } + else { + + meHitEnergyZneg_->Fill((hit.second).energy); + meHitTimeZneg_->Fill((hit.second).time); + meOccupancyZneg_->Fill(global_point.x(),global_point.y()); + + } + + } // hit loop + +} + +void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + meHitEnergyZpos_ = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 200, 0., 2.); + meHitEnergyZneg_ = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 200, 0., 2.); + meHitTimeZpos_ = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 250, 0., 25.); + meHitTimeZneg_ = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 250, 0., 25.); + + meOccupancyZpos_ = ibook.book2D("EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);x_{SIM} [cm];y_{SIM} [cm]", + 135, -135., 135., 135, -135., 135.); + meOccupancyZneg_ = ibook.book2D("EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);x_{SIM} [cm];y_{SIM} [cm]", + 135, -135., 135., 135, -135., 135.); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void EtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // The following says we do not know what parameters are allowed so do no + // validation + // Please change this to state exactly what you do use, even if it is no + // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/ETL/SimHits"); + desc.add("moduleLabelG4","g4SimHits"); + desc.add("etlSimHitsCollection","FastTimerHitsEndcap"); + desc.add("hitMinimumEnergy",0.1); // [MeV] + descriptions.add("etlSimHits", desc); + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(EtlSimHitsValidation); diff --git a/Validation/MtdValidation/test/mtdValidation_cfg.py b/Validation/MtdValidation/test/mtdValidation_cfg.py new file mode 100644 index 0000000000000..31cd7484a08f2 --- /dev/null +++ b/Validation/MtdValidation/test/mtdValidation_cfg.py @@ -0,0 +1,47 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("mtdSimHitsValidation") + +process.load("FWCore.MessageService.MessageLogger_cfi") + +process.load("Configuration.Geometry.GeometryExtended2023D38_cff") + +process.load("Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi") +process.load("Geometry.MTDNumberingBuilder.mtdTopology_cfi") +process.load("Geometry.MTDGeometryBuilder.mtdGeometry_cfi") +process.load("Geometry.MTDGeometryBuilder.mtdParameters_cfi") + +process.mtdGeometry = cms.ESProducer("MTDDigiGeometryESModule", + alignmentsLabel = cms.string(''), + appendToDataLabel = cms.string(''), + applyAlignment = cms.bool(False), + fromDDD = cms.bool(True) +) + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +process.MessageLogger.cerr.FwkReport = cms.untracked.PSet( + reportEvery = cms.untracked.int32(100), +) + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:step3.root' + ) +) + +# --- BTL Validation +process.load("Validation.MtdValidation.btlSimHits_cfi") +process.load("Validation.MtdValidation.btlDigiHits_cfi") +btlValidation = cms.Sequence(process.btlSimHits + process.btlDigiHits) + +# --- ETL Validation +process.load("Validation.MtdValidation.etlSimHits_cfi") +process.load("Validation.MtdValidation.etlDigiHits_cfi") +etlValidation = cms.Sequence(process.etlSimHits + process.etlDigiHits) + +process.DQMStore = cms.Service("DQMStore") + +process.load("DQMServices.FileIO.DQMFileSaverOnline_cfi") + +process.p = cms.Path( btlValidation + etlValidation + process.dqmSaver ) From 003b7e9cc7821d2b8ba7f4e8385e37725d043cae Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Thu, 14 Mar 2019 11:59:18 +0100 Subject: [PATCH 675/686] Added plugins for RecHits validation and updated configuration files --- .../Configuration/python/autoValidation.py | 3 +- .../python/globalValidation_cff.py | 3 + .../Configuration/python/mtdSimValid_cff.py | 13 ++ .../plugins/BtlDigiHitsValidation.cc | 72 ++++--- .../plugins/BtlRecHitsValidation.cc | 178 ++++++++++++++++++ .../plugins/BtlSimHitsValidation.cc | 66 +++---- .../plugins/EtlDigiHitsValidation.cc | 84 +++------ .../plugins/EtlRecHitsValidation.cc | 172 +++++++++++++++++ .../plugins/EtlSimHitsValidation.cc | 66 +++---- .../MtdValidation/test/mtdValidation_cfg.py | 6 +- 10 files changed, 481 insertions(+), 182 deletions(-) create mode 100644 Validation/Configuration/python/mtdSimValid_cff.py create mode 100644 Validation/MtdValidation/plugins/BtlRecHitsValidation.cc create mode 100644 Validation/MtdValidation/plugins/EtlRecHitsValidation.cc diff --git a/Validation/Configuration/python/autoValidation.py b/Validation/Configuration/python/autoValidation.py index 39ebc1c4b567e..cc4a1e312051a 100644 --- a/Validation/Configuration/python/autoValidation.py +++ b/Validation/Configuration/python/autoValidation.py @@ -11,10 +11,11 @@ 'standardValidation' : ['prevalidation','validation','validationHarvesting'], 'standardValidationNoHLT' : ['prevalidationNoHLT','validationNoHLT','validationHarvestingNoHLT'], 'HGCalValidation' : ['', 'globalValidationHGCal', 'hgcalValidatorPostProcessor'], + 'MTDValidation' : ['', 'globalValidationMTD', ''], 'OuterTrackerValidation' : ['', 'globalValidationOuterTracker', 'postValidationOuterTracker'], } -_phase2_allowed = ['baseValidation','trackingValidation','muonOnlyValidation','JetMETOnlyValidation','bTagOnlyValidation','hcalOnlyValidation', 'HGCalValidation', 'OuterTrackerValidation'] +_phase2_allowed = ['baseValidation','trackingValidation','muonOnlyValidation','JetMETOnlyValidation','bTagOnlyValidation','hcalOnlyValidation', 'HGCalValidation', 'MTDValidation', 'OuterTrackerValidation'] autoValidation['phase2Validation'] = ['','',''] for i in range(0,3): autoValidation['phase2Validation'][i] = '+'.join([_f for _f in [autoValidation[m][i] for m in _phase2_allowed] if _f]) diff --git a/Validation/Configuration/python/globalValidation_cff.py b/Validation/Configuration/python/globalValidation_cff.py index a34d575a56a15..6759165acc127 100644 --- a/Validation/Configuration/python/globalValidation_cff.py +++ b/Validation/Configuration/python/globalValidation_cff.py @@ -41,6 +41,7 @@ from DQMOffline.RecoB.dqmAnalyzer_cff import * from Validation.RecoB.BDHadronTrackValidation_cff import * from Validation.Configuration.hgcalSimValid_cff import * +from Validation.Configuration.mtdSimValid_cff import * from Validation.SiOuterTrackerV.OuterTrackerSourceConfigV_cff import * @@ -160,6 +161,8 @@ globalValidationHGCal = cms.Sequence(hgcalValidation) +globalValidationMTD = cms.Sequence(mtdSimValid+mtdDigiValid+mtdRecoValid) + globalValidationOuterTracker = cms.Sequence(OuterTrackerSourceV) globalPrevalidationMuons = cms.Sequence( diff --git a/Validation/Configuration/python/mtdSimValid_cff.py b/Validation/Configuration/python/mtdSimValid_cff.py new file mode 100644 index 0000000000000..0279b8c25a91a --- /dev/null +++ b/Validation/Configuration/python/mtdSimValid_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +# MTD validation sequences +from Validation.MtdValidation.btlSimHits_cfi import btlSimHits +from Validation.MtdValidation.btlDigiHits_cfi import btlDigiHits +from Validation.MtdValidation.btlRecHits_cfi import btlRecHits +from Validation.MtdValidation.etlSimHits_cfi import etlSimHits +from Validation.MtdValidation.etlDigiHits_cfi import etlDigiHits +from Validation.MtdValidation.etlRecHits_cfi import etlRecHits + +mtdSimValid = cms.Sequence(btlSimHits + etlSimHits ) +mtdDigiValid = cms.Sequence(btlDigiHits + etlDigiHits) +mtdRecoValid = cms.Sequence(btlRecHits + etlRecHits ) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index a45cf4f6cc8a7..451587d64fd64 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -10,15 +10,9 @@ Implementation: [Notes on implementation] */ -// -// Original Author: Massimo Casarsa -// Created: Mon, 11 Mar 2019 14:12:22 GMT -// -// #include -// user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -40,11 +34,6 @@ #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" -// -// class declaration -// - - class BtlDigiHitsValidation : public DQMEDAnalyzer { public: @@ -74,6 +63,8 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { edm::EDGetTokenT btlDigiHitsToken_; + // --- histograms declaration + MonitorElement* meHitCharge_[2]; MonitorElement* meHitTime1_[2]; MonitorElement* meHitTime2_[2]; @@ -82,17 +73,8 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { }; -// -// constants, enums and typedefs -// -// -// static data member definitions -// - -// -// constructors and destructor -// +// ------------ constructor and destructor -------------- BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): geom_(nullptr), topo_(nullptr), @@ -106,17 +88,10 @@ BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): } - BtlDigiHitsValidation::~BtlDigiHitsValidation() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) } -// -// member functions -// - // ------------ method called for each event ------------ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -135,15 +110,30 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe edm::Handle btlDigiHitsHandle; iEvent.getByToken(btlDigiHitsToken_, btlDigiHitsHandle); - if( ! btlDigiHitsHandle.isValid() ) return; + if( ! btlDigiHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No BTL DIGI hits found"; + return; + } eventCount_++; // --- Loop over the BLT DIGI hits for (const auto& dataFrame: *btlDigiHitsHandle) { - //DetId id = dataFrame.id(); - + BTLDetId detId = dataFrame.id(); + DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); + const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); + + Local3DPoint local_point(0.,0.,0.); + local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + const auto& global_point = thedet->toGlobal(local_point); + const auto& sample_L = dataFrame.sample(0); const auto& sample_R = dataFrame.sample(1); @@ -161,18 +151,28 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe meHitTime2_[0]->Fill(tdc2L); meHitTime2_[1]->Fill(tdc2R); + if ( adcL > 0 ) + meOccupancy_[0]->Fill(global_point.z(),global_point.phi()); + + if ( adcR > 0 ) + meOccupancy_[1]->Fill(global_point.z(),global_point.phi()); + } // dataFrame loop } + +// ------------ method for histogram booking ------------ void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, edm::Run const& run, edm::EventSetup const & iSetup) { ibook.setCurrentFolder(folder_); + // --- histograms booking + meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);amplitude [ADC counts]", 1024, 0., 1024.); meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);amplitude [ADC counts]", @@ -193,19 +193,17 @@ void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void BtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // The following says we do not know what parameters are allowed so do no - // validation - // Please change this to state exactly what you do use, even if it is no - // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/BTL/DigiHits"); desc.add("moduleLabel","mix"); desc.add("btlDigiHitsCollection","FTLBarrel"); + descriptions.add("btlDigiHits", desc); + } -//define this as a plug-in DEFINE_FWK_MODULE(BtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc new file mode 100644 index 0000000000000..993295af32878 --- /dev/null +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -0,0 +1,178 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: BtlRecHitsValidation +// +/**\class BtlRecHitsValidation BtlRecHitsValidation.cc Validation/MtdValidation/plugins/BtlRecHitsValidation.cc + + Description: BTL RECO hits validation + + Implementation: + [Notes on implementation] +*/ + +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" + +#include "DataFormats/ForwardDetId/interface/BTLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/Records/interface/MTDTopologyRcd.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" + +#include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" +#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" + + +class BtlRecHitsValidation : public DQMEDAnalyzer { + +public: + explicit BtlRecHitsValidation(const edm::ParameterSet&); + ~BtlRecHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + + // ------------ member data ------------ + + const MTDGeometry* geom_; + const MTDTopology* topo_; + + const std::string folder_; + const std::string infoLabel_; + const std::string btlRecHitsCollection_; + + int eventCount_; + + edm::EDGetTokenT btlRecHitsToken_; + + // --- histograms declaration + + MonitorElement* meHitEnergy_; + MonitorElement* meHitTime_; + + MonitorElement* meOccupancy_; + +}; + + +// ------------ constructor and destructor -------------- +BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + topo_(nullptr), + folder_(iConfig.getParameter("folder")), + infoLabel_(iConfig.getParameter("moduleLabel")), + btlRecHitsCollection_(iConfig.getParameter("btlRecHitsCollection")), + eventCount_(0) { + + btlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), + std::string(btlRecHitsCollection_))); + +} + +BtlRecHitsValidation::~BtlRecHitsValidation() { +} + + +// ------------ method called for each event ------------ +void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::ESHandle topologyHandle; + iSetup.get().get(topologyHandle); + topo_ = topologyHandle.product(); + + edm::Handle btlRecHitsHandle; + iEvent.getByToken(btlRecHitsToken_, btlRecHitsHandle); + + if( ! btlRecHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No BTL RecHits found"; + return; + } + + eventCount_++; + + // --- Loop over the BLT RECO hits + for (const auto& recHit: *btlRecHitsHandle) { + + BTLDetId detId = recHit.id(); + DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("BtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); + const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); + + Local3DPoint local_point(0.,0.,0.); + local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + const auto& global_point = thedet->toGlobal(local_point); + + meHitEnergy_->Fill(recHit.energy()); + meHitTime_->Fill(recHit.time()); + + meOccupancy_->Fill(global_point.z(),global_point.phi()); + + } // recHit loop + +} + + +// ------------ method for histogram booking ------------ +void BtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + // --- histograms booking + + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;energy [MeV]", 200, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA [ns]", 250, 0., 25.); + + meOccupancy_ = ibook.book2D("BtlOccupancy","BTL RECO hits occupancy;z [cm]; #phi [rad]", + 65, -260., 260., 315, -3.15, 3.15 ); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void BtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + + edm::ParameterSetDescription desc; + + desc.add("folder", "MTD/BTL/RecHits"); + desc.add("moduleLabel","mtdRecHits"); + desc.add("btlRecHitsCollection","FTLBarrel"); + + descriptions.add("btlRecHits", desc); + +} + +DEFINE_FWK_MODULE(BtlRecHitsValidation); diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index 5f085a972d029..f779a16ede738 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -10,15 +10,9 @@ Implementation: [Notes on implementation] */ -// -// Original Author: Massimo Casarsa -// Created: Fri, 08 Mar 2019 14:04:22 GMT -// -// #include -// user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -40,9 +34,13 @@ #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" -// -// class declaration -// +struct MTDHit { + float energy; + float time; + float x; + float y; + float z; +}; class BtlSimHitsValidation : public DQMEDAnalyzer { @@ -61,7 +59,7 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { void analyze(const edm::Event&, const edm::EventSetup&) override; -// ------------ member data ------------ + // ------------ member data ------------ const MTDGeometry* geom_; const MTDTopology* topo_; @@ -76,6 +74,8 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { edm::EDGetTokenT btlSimHitsToken_; + // --- histograms declaration + MonitorElement* meHitEnergy_; MonitorElement* meHitTime_; @@ -83,25 +83,8 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { }; -// -// constants, enums and typedefs -// - -struct MTDHit { - float energy; - float time; - float x; - float y; - float z; -}; - -// -// static data member definitions -// -// -// constructors and destructor -// +// ------------ constructor and destructor -------------- BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): geom_(nullptr), topo_(nullptr), @@ -116,17 +99,10 @@ BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): } - BtlSimHitsValidation::~BtlSimHitsValidation() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) } -// -// member functions -// - // ------------ method called for each event ------------ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -145,7 +121,10 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet edm::Handle btlSimHitsHandle; iEvent.getByToken(btlSimHitsToken_, btlSimHitsHandle); - if( ! btlSimHitsHandle.isValid() ) return; + if( ! btlSimHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No BTL SIM hits found"; + return; + } eventCount_++; @@ -154,7 +133,7 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Loop over the BLT SIM hits for (auto const& simHit: *btlSimHitsHandle) { - // --- Only hits compatible with the in-time bunch-crossing + // --- Use only hits compatible with the in-time bunch-crossing if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; DetId id = simHit.detUnitId(); @@ -211,12 +190,16 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet } + +// ------------ method for histogram booking ------------ void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, edm::Run const& run, edm::EventSetup const & iSetup) { ibook.setCurrentFolder(folder_); + // --- histograms booking + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 200, 0., 20.); meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 250, 0., 25.); @@ -226,21 +209,18 @@ void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void BtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // The following says we do not know what parameters are allowed so do no - // validation - // Please change this to state exactly what you do use, even if it is no - // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/BTL/SimHits"); desc.add("moduleLabelG4","g4SimHits"); desc.add("btlSimHitsCollection","FastTimerHitsBarrel"); desc.add("hitMinimumEnergy",1.); // [MeV] + descriptions.add("btlSimHits", desc); } -//define this as a plug-in DEFINE_FWK_MODULE(BtlSimHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index fd0dd4fafcfaa..59f875a32e225 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -10,15 +10,9 @@ Implementation: [Notes on implementation] */ -// -// Original Author: Massimo Casarsa -// Created: Mon, 11 Mar 2019 14:30:22 GMT -// -// #include -// user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -35,11 +29,6 @@ #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" -// -// class declaration -// - - class EtlDigiHitsValidation : public DQMEDAnalyzer { public: @@ -68,6 +57,8 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { edm::EDGetTokenT etlDigiHitsToken_; + // --- histograms declaration + MonitorElement* meHitCharge_[2]; MonitorElement* meHitTime_[2]; @@ -75,17 +66,8 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { }; -// -// constants, enums and typedefs -// -// -// static data member definitions -// - -// -// constructors and destructor -// +// ------------ constructor and destructor -------------- EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): geom_(nullptr), folder_(iConfig.getParameter("folder")), @@ -98,17 +80,10 @@ EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): } - EtlDigiHitsValidation::~EtlDigiHitsValidation() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) } -// -// member functions -// - // ------------ method called for each event ------------ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -123,7 +98,10 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe edm::Handle etlDigiHitsHandle; iEvent.getByToken(etlDigiHitsToken_, etlDigiHitsHandle); - if( ! etlDigiHitsHandle.isValid() ) return; + if( ! etlDigiHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No ETL DIGI hits found"; + return; + } eventCount_++; @@ -141,70 +119,64 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe const MTDGeomDet* thedet = geom_->idToDet(geoId); if( thedet == nullptr ) - throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + throw cms::Exception("EtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; Local3DPoint local_point(0.,0.,0.); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms - if ( detId.zside()>0. ){ - - meHitCharge_[0]->Fill(sample.data()); - meHitTime_[0]->Fill(sample.toa()); - meOccupancy_[0]->Fill(global_point.x(),global_point.y()); - - } - else { - meHitCharge_[1]->Fill(sample.data()); - meHitTime_[1]->Fill(sample.toa()); - meOccupancy_[1]->Fill(global_point.x(),global_point.y()); + int idet = (detId.zside()+1)/2; - } + meHitCharge_[idet]->Fill(sample.data()); + meHitTime_[idet]->Fill(sample.toa()); + meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); } // dataFrame loop } + +// ------------ method for histogram booking ------------ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, edm::Run const& run, edm::EventSetup const & iSetup) { ibook.setCurrentFolder(folder_); - meHitCharge_[0] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);amplitude [ADC counts]", + // --- histograms booking + + meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);amplitude [ADC counts]", 256, 0., 256.); - meHitCharge_[1] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);amplitude [ADC counts]", + meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);amplitude [ADC counts]", 256, 0., 256.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA [TDC counts]", + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA [TDC counts]", 1000, 0., 2000.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA [TDC counts]", + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA [TDC counts]", 1000, 0., 2000.); - meOccupancy_[0] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);x [cm];y [cm]", 135, -135., 135., 135, -135., 135.); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);x [cm];y [cm]", + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", 135, -135., 135., 135, -135., 135.); } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // The following says we do not know what parameters are allowed so do no - // validation - // Please change this to state exactly what you do use, even if it is no - // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/ETL/DigiHits"); desc.add("moduleLabel","mix"); desc.add("etlDigiHitsCollection","FTLEndcap"); + descriptions.add("etlDigiHits", desc); + } -//define this as a plug-in DEFINE_FWK_MODULE(EtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc new file mode 100644 index 0000000000000..58d335f1684e2 --- /dev/null +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -0,0 +1,172 @@ +// -*- C++ -*- +// +// Package: Validation/MtdValidation +// Class: EtlRecHitsValidation +// +/**\class EtlRecHitsValidation EtlRecHitsValidation.cc Validation/MtdValidation/plugins/EtlRecHitsValidation.cc + + Description: ETL RECO hits validation + + Implementation: + [Notes on implementation] +*/ + +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DQMServices/Core/interface/DQMEDAnalyzer.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" + +#include "DataFormats/ForwardDetId/interface/ETLDetId.h" + +#include "Geometry/Records/interface/MTDDigiGeometryRecord.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" + + +class EtlRecHitsValidation : public DQMEDAnalyzer { + +public: + explicit EtlRecHitsValidation(const edm::ParameterSet&); + ~EtlRecHitsValidation() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + void bookHistograms(DQMStore::IBooker &, + edm::Run const&, + edm::EventSetup const&) override; + + void analyze(const edm::Event&, const edm::EventSetup&) override; + + // ------------ member data ------------ + + const MTDGeometry* geom_; + + const std::string folder_; + const std::string infoLabel_; + const std::string etlRecHitsCollection_; + + int eventCount_; + + edm::EDGetTokenT etlRecHitsToken_; + + // --- histograms declaration + + MonitorElement* meHitEnergy_[2]; + MonitorElement* meHitTime_[2]; + + MonitorElement* meOccupancy_[2]; + +}; + + +// ------------ constructor and destructor -------------- +EtlRecHitsValidation::EtlRecHitsValidation(const edm::ParameterSet& iConfig): + geom_(nullptr), + folder_(iConfig.getParameter("folder")), + infoLabel_(iConfig.getParameter("moduleLabel")), + etlRecHitsCollection_(iConfig.getParameter("etlRecHitsCollection")), + eventCount_(0) { + + etlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), + std::string(etlRecHitsCollection_))); + +} + +EtlRecHitsValidation::~EtlRecHitsValidation() { +} + + +// ------------ method called for each event ------------ +void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + + using namespace edm; + + edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); + + edm::ESHandle geometryHandle; + iSetup.get().get(geometryHandle); + geom_ = geometryHandle.product(); + + edm::Handle etlRecHitsHandle; + iEvent.getByToken(etlRecHitsToken_, etlRecHitsHandle); + + if( ! etlRecHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No ETL RecHits found"; + return; + } + + eventCount_++; + + // --- Loop over the ELT RECO hits + for (const auto& recHit: *etlRecHitsHandle) { + + ETLDetId detId = recHit.id(); + + DetId geoId = detId.geographicalId(); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("EtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; + + const auto& global_point = thedet->toGlobal(Local3DPoint(0.,0.,0.)); + + // --- Fill the histograms + + int idet = (detId.zside()+1)/2; + + meHitEnergy_[idet]->Fill(recHit.energy()); + meHitTime_[idet]->Fill(recHit.time()); + + meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + + } // recHit loop + +} + + +// ------------ method for histogram booking ------------ +void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, + edm::Run const& run, + edm::EventSetup const & iSetup) { + + ibook.setCurrentFolder(folder_); + + // --- histograms booking + + meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);energy [MeV]", 150, 0., 3.); + meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);energy [MeV]", 150, 0., 3.); + + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA [ns]", 250, 0., 25.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA [ns]", 250, 0., 25.); + + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL RECO hits occupancy (-Z);x [cm];y [cm]", + 59, -130., 130., 59, -130., 130.); + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", + 59, -130., 130., 59, -130., 130.); + +} + + + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void EtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + + desc.add("folder", "MTD/ETL/RecHits"); + desc.add("moduleLabel","mtdRecHits"); + desc.add("etlRecHitsCollection","FTLEndcap"); + + descriptions.add("etlRecHits", desc); + +} + +DEFINE_FWK_MODULE(EtlRecHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 5478c2a424220..57a1456553137 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -10,15 +10,9 @@ Implementation: [Notes on implementation] */ -// -// Original Author: Massimo Casarsa -// Created: Mon, 11 Mar 2019 13:56:22 GMT -// -// #include -// user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -35,9 +29,13 @@ #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" -// -// class declaration -// +struct MTDHit { + float energy; + float time; + float x; + float y; + float z; +}; class EtlSimHitsValidation : public DQMEDAnalyzer { @@ -56,7 +54,7 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { void analyze(const edm::Event&, const edm::EventSetup&) override; -// ------------ member data ------------ + // ------------ member data ------------ const MTDGeometry* geom_; @@ -70,6 +68,8 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { edm::EDGetTokenT etlSimHitsToken_; + // --- histograms declaration + MonitorElement* meHitEnergyZpos_; MonitorElement* meHitEnergyZneg_; MonitorElement* meHitTimeZpos_; @@ -80,25 +80,8 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { }; -// -// constants, enums and typedefs -// - -struct MTDHit { - float energy; - float time; - float x; - float y; - float z; -}; - -// -// static data member definitions -// -// -// constructors and destructor -// +// ------------ constructor and destructor -------------- EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): geom_(nullptr), folder_(iConfig.getParameter("folder")), @@ -112,17 +95,10 @@ EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): } - EtlSimHitsValidation::~EtlSimHitsValidation() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) } -// -// member functions -// - // ------------ method called for each event ------------ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -137,7 +113,10 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet edm::Handle etlSimHitsHandle; iEvent.getByToken(etlSimHitsToken_, etlSimHitsHandle); - if( ! etlSimHitsHandle.isValid() ) return; + if( ! etlSimHitsHandle.isValid() ) { + edm::LogWarning("DataNotFound") << "No ETL SIM hits found"; + return; + } eventCount_++; @@ -146,7 +125,7 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Loop over the BLT SIM hits for (auto const& simHit: *etlSimHitsHandle) { - // --- Only hits compatible with the in-time bunch-crossing + // --- Use only hits compatible with the in-time bunch-crossing if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; DetId id = simHit.detUnitId(); @@ -212,12 +191,16 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet } + +// ------------ method for histogram booking ------------ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, edm::Run const& run, edm::EventSetup const & iSetup) { ibook.setCurrentFolder(folder_); + // --- histograms booking + meHitEnergyZpos_ = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 200, 0., 2.); meHitEnergyZneg_ = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 200, 0., 2.); meHitTimeZpos_ = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 250, 0., 25.); @@ -231,21 +214,18 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - // The following says we do not know what parameters are allowed so do no - // validation - // Please change this to state exactly what you do use, even if it is no - // parameters + edm::ParameterSetDescription desc; + desc.add("folder", "MTD/ETL/SimHits"); desc.add("moduleLabelG4","g4SimHits"); desc.add("etlSimHitsCollection","FastTimerHitsEndcap"); desc.add("hitMinimumEnergy",0.1); // [MeV] + descriptions.add("etlSimHits", desc); } -//define this as a plug-in DEFINE_FWK_MODULE(EtlSimHitsValidation); diff --git a/Validation/MtdValidation/test/mtdValidation_cfg.py b/Validation/MtdValidation/test/mtdValidation_cfg.py index 31cd7484a08f2..ac9c32a49c63e 100644 --- a/Validation/MtdValidation/test/mtdValidation_cfg.py +++ b/Validation/MtdValidation/test/mtdValidation_cfg.py @@ -33,12 +33,14 @@ # --- BTL Validation process.load("Validation.MtdValidation.btlSimHits_cfi") process.load("Validation.MtdValidation.btlDigiHits_cfi") -btlValidation = cms.Sequence(process.btlSimHits + process.btlDigiHits) +process.load("Validation.MtdValidation.btlRecHits_cfi") +btlValidation = cms.Sequence(process.btlSimHits + process.btlDigiHits + process.btlRecHits) # --- ETL Validation process.load("Validation.MtdValidation.etlSimHits_cfi") process.load("Validation.MtdValidation.etlDigiHits_cfi") -etlValidation = cms.Sequence(process.etlSimHits + process.etlDigiHits) +process.load("Validation.MtdValidation.etlRecHits_cfi") +etlValidation = cms.Sequence(process.etlSimHits + process.etlDigiHits + process.etlRecHits) process.DQMStore = cms.Service("DQMStore") From 55a3b68229e54a3acf7ff6fac868a914f48031eb Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Tue, 2 Apr 2019 17:58:23 +0200 Subject: [PATCH 676/686] Added several monitoring plots --- .../plugins/BtlDigiHitsValidation.cc | 128 ++++++++++---- .../plugins/BtlRecHitsValidation.cc | 67 +++++++- .../plugins/BtlSimHitsValidation.cc | 93 +++++++++- .../plugins/EtlDigiHitsValidation.cc | 85 ++++++++- .../plugins/EtlRecHitsValidation.cc | 82 ++++++++- .../plugins/EtlSimHitsValidation.cc | 162 +++++++++++++----- 6 files changed, 525 insertions(+), 92 deletions(-) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index 451587d64fd64..c5dd97362e7c6 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -65,12 +65,27 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { // --- histograms declaration + MonitorElement* meNhits_[2]; + MonitorElement* meHitCharge_[2]; - MonitorElement* meHitTime1_[2]; - MonitorElement* meHitTime2_[2]; + MonitorElement* meHitTime_[2]; MonitorElement* meOccupancy_[2]; + MonitorElement* meHitX_[2]; + MonitorElement* meHitY_[2]; + MonitorElement* meHitZ_[2]; + MonitorElement* meHitPhi_[2]; + MonitorElement* meHitEta_[2]; + + MonitorElement* meHitTvsQ_[2]; + MonitorElement* meHitQvsPhi_[2]; + MonitorElement* meHitQvsEta_[2]; + MonitorElement* meHitQvsZ_[2]; + MonitorElement* meHitTvsPhi_[2]; + MonitorElement* meHitTvsEta_[2]; + MonitorElement* meHitTvsZ_[2]; + }; @@ -118,6 +133,9 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe eventCount_++; // --- Loop over the BLT DIGI hits + + unsigned int n_digi_btl[2] = {0,0}; + for (const auto& dataFrame: *btlDigiHitsHandle) { BTLDetId detId = dataFrame.id(); @@ -137,29 +155,40 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe const auto& sample_L = dataFrame.sample(0); const auto& sample_R = dataFrame.sample(1); - uint32_t adcL = sample_L.data(); - uint32_t adcR = sample_R.data(); - uint32_t tdc1L = sample_L.toa(); - uint32_t tdc1R = sample_R.toa(); - uint32_t tdc2L = sample_L.toa2(); - uint32_t tdc2R = sample_R.toa2(); + uint32_t adc[2] = {sample_L.data(), sample_R.data()}; + uint32_t tdc[2] = {sample_L.toa(), sample_R.toa() }; - meHitCharge_[0]->Fill(adcL); - meHitCharge_[1]->Fill(adcR); - meHitTime1_[0]->Fill(tdc1L); - meHitTime1_[1]->Fill(tdc1R); - meHitTime2_[0]->Fill(tdc2L); - meHitTime2_[1]->Fill(tdc2R); + for (int iside=0; iside<2; ++iside) { + + if ( adc[iside] == 0 ) continue; - if ( adcL > 0 ) - meOccupancy_[0]->Fill(global_point.z(),global_point.phi()); + meHitCharge_[iside]->Fill(adc[iside]); + meHitTime_[iside]->Fill(tdc[iside]); - if ( adcR > 0 ) - meOccupancy_[1]->Fill(global_point.z(),global_point.phi()); + meOccupancy_[iside]->Fill(global_point.z(),global_point.phi()); - } // dataFrame loop + meHitX_[iside]->Fill(global_point.x()); + meHitY_[iside]->Fill(global_point.y()); + meHitZ_[iside]->Fill(global_point.z()); + meHitPhi_[iside]->Fill(global_point.phi()); + meHitEta_[iside]->Fill(global_point.eta()); + meHitTvsQ_[iside]->Fill(adc[iside],tdc[iside]); + meHitQvsPhi_[iside]->Fill(global_point.phi(),adc[iside]); + meHitQvsEta_[iside]->Fill(global_point.eta(),adc[iside]); + meHitQvsZ_[iside]->Fill(global_point.z(),adc[iside]); + meHitTvsPhi_[iside]->Fill(global_point.phi(),tdc[iside]); + meHitTvsEta_[iside]->Fill(global_point.eta(),tdc[iside]); + meHitTvsZ_[iside]->Fill(global_point.z(),tdc[iside]); + n_digi_btl[iside]++; + + } // iside loop + + } // dataFrame loop + + meNhits_[0]->Fill(n_digi_btl[0]); + meNhits_[1]->Fill(n_digi_btl[1]); } @@ -173,23 +202,64 @@ void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);amplitude [ADC counts]", - 1024, 0., 1024.); - meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);amplitude [ADC counts]", - 1024, 0., 1024.); - meHitTime1_[0] = ibook.book1D("BtlHitTime1L", "BTL DIGI hits ToA1 (L);ToA [TDC counts]", + meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);N_{DIGI}", 250, 0., 5000.); + meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);N_{DIGI}", 250, 0., 5000.); + + meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", 1024, 0., 1024.); - meHitTime1_[1] = ibook.book1D("BtlHitTime1R", "BTL DIGI hits ToA1 (R);ToA [TDC counts]", + meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", 1024, 0., 1024.); - meHitTime2_[0] = ibook.book1D("BtlHitTime2L", "BTL DIGI hits ToA2 (L);ToA [TDC counts]", + meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", 1024, 0., 1024.); - meHitTime2_[1] = ibook.book1D("BtlHitTime2R", "BTL DIGI hits ToA2 (R);ToA [TDC counts]", + meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", 1024, 0., 1024.); - meOccupancy_[0] = ibook.book2D("BtlOccupancyL","BTL DIGI hits occupancy (L);z [cm]; #phi [rad]", + + meOccupancy_[0] = ibook.book2D("BtlOccupancyL","BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", 65, -260., 260., 315, -3.15, 3.15 ); - meOccupancy_[1] = ibook.book2D("BtlOccupancyR","BTL DIGI hits occupancy (R);z [cm]; #phi [rad]", + meOccupancy_[1] = ibook.book2D("BtlOccupancyR","BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", 65, -260., 260., 315, -3.15, 3.15 ); + meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 135, -135., 135.); + meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 135, -135., 135.); + meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 135, -135., 135.); + meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 135, -135., 135.); + meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 520, -260., 260.); + meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 520, -260., 260.); + meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 315, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 315, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 200, -1.6, 1.6); + meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 200, -1.6, 1.6); + + + meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL", "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 1024, 0., 1024., 0., 1024.); + meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR", "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 1024, 0., 1024., 0., 1024.); + meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL", "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR", "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitQvsEta_[0] = ibook.bookProfile("BtlHitQvsEtaL","BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", + 200, -1.6, 1.6, 0., 1024.); + meHitQvsEta_[1] = ibook.bookProfile("BtlHitQvsEtaR","BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", + 200, -1.6, 1.6, 0., 1024.); + meHitQvsZ_[0] = ibook.bookProfile("BtlHitQvsZL","BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", + 520, -260., 260., 0., 1024.); + meHitQvsZ_[1] = ibook.bookProfile("BtlHitQvsZR","BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", + 520, -260., 260., 0., 1024.); + meHitTvsPhi_[0] = ibook.bookProfile("BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitTvsPhi_[1] = ibook.bookProfile("BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitTvsEta_[0] = ibook.bookProfile("BtlHitTvsEtaL","BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", + 200, -1.6, 1.6, 0., 1024.); + meHitTvsEta_[1] = ibook.bookProfile("BtlHitTvsEtaR","BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", + 200, -1.6, 1.6, 0., 1024.); + meHitTvsZ_[0] = ibook.bookProfile("BtlHitTvsZL","BTL SIM ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", + 520, -260., 260., 0., 1024.); + meHitTvsZ_[1] = ibook.bookProfile("BtlHitTvsZR","BTL SIM ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", + 520, -260., 260., 0., 1024.); + } diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index 993295af32878..61d0d73d42281 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -65,11 +65,27 @@ class BtlRecHitsValidation : public DQMEDAnalyzer { // --- histograms declaration + MonitorElement* meNhits_; + MonitorElement* meHitEnergy_; MonitorElement* meHitTime_; MonitorElement* meOccupancy_; + MonitorElement* meHitX_; + MonitorElement* meHitY_; + MonitorElement* meHitZ_; + MonitorElement* meHitPhi_; + MonitorElement* meHitEta_; + + MonitorElement* meHitTvsE_; + MonitorElement* meHitEvsPhi_; + MonitorElement* meHitEvsEta_; + MonitorElement* meHitEvsZ_; + MonitorElement* meHitTvsPhi_; + MonitorElement* meHitTvsEta_; + MonitorElement* meHitTvsZ_; + }; @@ -117,6 +133,9 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet eventCount_++; // --- Loop over the BLT RECO hits + + unsigned int n_reco_btl = 0; + for (const auto& recHit: *btlRecHitsHandle) { BTLDetId detId = recHit.id(); @@ -138,8 +157,26 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meOccupancy_->Fill(global_point.z(),global_point.phi()); + meHitX_->Fill(global_point.x()); + meHitY_->Fill(global_point.y()); + meHitZ_->Fill(global_point.z()); + meHitPhi_->Fill(global_point.phi()); + meHitEta_->Fill(global_point.eta()); + + meHitTvsE_->Fill(recHit.energy(),recHit.time()); + meHitEvsPhi_->Fill(global_point.phi(),recHit.energy()); + meHitEvsEta_->Fill(global_point.eta(),recHit.energy()); + meHitEvsZ_->Fill(global_point.z(),recHit.energy()); + meHitTvsPhi_->Fill(global_point.phi(),recHit.time()); + meHitTvsEta_->Fill(global_point.eta(),recHit.time()); + meHitTvsZ_->Fill(global_point.z(),recHit.time()); + + n_reco_btl++; + } // recHit loop + meNhits_->Fill(n_reco_btl); + } @@ -152,12 +189,36 @@ void BtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;energy [MeV]", 200, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA [ns]", 250, 0., 25.); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;N_{RECO}", 250, 0., 5000.); - meOccupancy_ = ibook.book2D("BtlOccupancy","BTL RECO hits occupancy;z [cm]; #phi [rad]", + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;E_{RECO} [MeV]", 200, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 250, 0., 25.); + + meOccupancy_ = ibook.book2D("BtlOccupancy","BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", 65, -260., 260., 315, -3.15, 3.15 ); + meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 135, -135., 135.); + meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 135, -135., 135.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 520, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 315, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 200, -1.6, 1.6); + + meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", + 100, 0., 20., 0., 100.); + meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", + 200, -1.6, 1.6, 0., 100.); + meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", + 520, -260., 260., 0., 100.); + meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", + 200, -1.6, 1.6, 0., 100.); + meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", + 520, -260., 260., 0., 100.); + + } diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index f779a16ede738..ddcf68334c92e 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -76,11 +76,32 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { // --- histograms declaration + MonitorElement* meNhits_; + MonitorElement* meNtrkPerCell_; + MonitorElement* meHitEnergy_; MonitorElement* meHitTime_; + MonitorElement* meHitXlocal_; + MonitorElement* meHitYlocal_; + MonitorElement* meHitZlocal_; + MonitorElement* meOccupancy_; + MonitorElement* meHitX_; + MonitorElement* meHitY_; + MonitorElement* meHitZ_; + MonitorElement* meHitPhi_; + MonitorElement* meHitEta_; + + MonitorElement* meHitTvsE_; + MonitorElement* meHitEvsPhi_; + MonitorElement* meHitEvsEta_; + MonitorElement* meHitEvsZ_; + MonitorElement* meHitTvsPhi_; + MonitorElement* meHitTvsEta_; + MonitorElement* meHitTvsZ_; + }; @@ -128,7 +149,8 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet eventCount_++; - std::map m_btlHits; + std::unordered_map m_btlHits; + std::unordered_map > m_btlTrkPerCell; // --- Loop over the BLT SIM hits for (auto const& simHit: *btlSimHitsHandle) { @@ -138,6 +160,8 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet DetId id = simHit.detUnitId(); + m_btlTrkPerCell[id.rawId()].insert(simHit.trackId()); + auto simHitIt = m_btlHits.emplace(id.rawId(),MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell @@ -162,6 +186,12 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // Histogram filling // ============================================================================== + meNhits_->Fill(m_btlHits.size()); + + for (auto const& hit: m_btlTrkPerCell) + meNtrkPerCell_->Fill((hit.second).size()); + + for (auto const& hit: m_btlHits) { if ( (hit.second).energy < hitMinEnergy_ ) continue; @@ -184,8 +214,27 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Fill the histograms meHitEnergy_->Fill((hit.second).energy); meHitTime_->Fill((hit.second).time); + + meHitXlocal_->Fill((hit.second).x); + meHitYlocal_->Fill((hit.second).y); + meHitZlocal_->Fill((hit.second).z); + meOccupancy_->Fill(global_point.z(),global_point.phi()); + meHitX_->Fill(global_point.x()); + meHitY_->Fill(global_point.y()); + meHitZ_->Fill(global_point.z()); + meHitPhi_->Fill(global_point.phi()); + meHitEta_->Fill(global_point.eta()); + + meHitTvsE_->Fill((hit.second).energy,(hit.second).time); + meHitEvsPhi_->Fill(global_point.phi(),(hit.second).energy); + meHitEvsEta_->Fill(global_point.eta(),(hit.second).energy); + meHitEvsZ_->Fill(global_point.z(),(hit.second).energy); + meHitTvsPhi_->Fill(global_point.phi(),(hit.second).time); + meHitTvsEta_->Fill(global_point.eta(),(hit.second).time); + meHitTvsZ_->Fill(global_point.z(),(hit.second).time); + } // hit loop } @@ -193,18 +242,46 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // ------------ method for histogram booking ------------ void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { + edm::Run const& run, + edm::EventSetup const & iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 200, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 250, 0., 25.); - - meOccupancy_ = ibook.book2D("BtlOccupancy","BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", - 520, -260., 260., 315, -3.15, 3.15 ); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;N_{BTL cells}", 250, 0., 5000.); + meNtrkPerCell_ = ibook.book1D("BtlNtrkPerCell", "Number of tracks per BTL cell;N_{trk}", 10, 0., 10.); + + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 200, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 250, 0., 25.); + + meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 400, -2., 2.); + meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 600, -30., 30.); + meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 400, -2., 2.); + + meOccupancy_ = ibook.book2D("BtlOccupancy","BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", + 520, -260., 260., 315, -3.15, 3.15 ); + + meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 135, -135., 135.); + meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 135, -135., 135.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 520, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 315, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 200, -1.6, 1.6); + + meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL SIM time vs energy;E_{SIM} [MeV];T_{SIM} [ns]", + 100, 0., 20., 0., 100.); + meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL SIM energy vs #phi;#phi_{SIM} [rad];E_{SIM} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL SIM energy vs #eta;#eta_{SIM};E_{SIM} [MeV]", + 200, -1.6, 1.6, 0., 100.); + meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL SIM energy vs Z;Z_{SIM} [cm];E_{SIM} [MeV]", + 520, -260., 260., 0., 100.); + meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL SIM time vs #phi;#phi_{SIM} [rad];T_{SIM} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL SIM time vs #eta;#eta_{SIM};T_{SIM} [ns]", + 200, -1.6, 1.6, 0., 100.); + meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL SIM time vs Z;Z_{SIM} [cm];T_{SIM} [ns]", + 520, -260., 260., 0., 100.); } diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index 59f875a32e225..acc28a359e2ed 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -59,11 +59,25 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { // --- histograms declaration + MonitorElement* meNhits_[2]; + MonitorElement* meHitCharge_[2]; MonitorElement* meHitTime_[2]; MonitorElement* meOccupancy_[2]; + MonitorElement* meHitX_[2]; + MonitorElement* meHitY_[2]; + MonitorElement* meHitZ_[2]; + MonitorElement* meHitPhi_[2]; + MonitorElement* meHitEta_[2]; + + MonitorElement* meHitTvsQ_[2]; + MonitorElement* meHitQvsPhi_[2]; + MonitorElement* meHitQvsEta_[2]; + MonitorElement* meHitTvsPhi_[2]; + MonitorElement* meHitTvsEta_[2]; + }; @@ -106,6 +120,9 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe eventCount_++; // --- Loop over the ELT DIGI hits + + unsigned int n_digi_etl[2] = {0,0}; + for (const auto& dataFrame: *etlDigiHitsHandle) { // --- Get the on-time sample @@ -134,8 +151,26 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe meHitTime_[idet]->Fill(sample.toa()); meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + + meHitX_[idet]->Fill(global_point.x()); + meHitY_[idet]->Fill(global_point.y()); + meHitZ_[idet]->Fill(global_point.z()); + meHitPhi_[idet]->Fill(global_point.phi()); + meHitEta_[idet]->Fill(global_point.eta()); + + meHitTvsQ_[idet]->Fill(sample.data(),sample.toa()); + meHitQvsPhi_[idet]->Fill(global_point.phi(),sample.data()); + meHitQvsEta_[idet]->Fill(global_point.eta(),sample.data()); + meHitTvsPhi_[idet]->Fill(global_point.phi(),sample.toa()); + meHitTvsEta_[idet]->Fill(global_point.eta(),sample.toa()); + + n_digi_etl[idet]++; + } // dataFrame loop + meNhits_[0]->Fill(n_digi_etl[0]); + meNhits_[1]->Fill(n_digi_etl[1]); + } @@ -148,21 +183,57 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);amplitude [ADC counts]", + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL DIGI hits (-Z);N_{DIGI}", 250, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL DIGI hits (+Z);N_{DIGI}", 250, 0., 5000.); + + meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);Q_{DIGI} [ADC counts]", 256, 0., 256.); - meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);amplitude [ADC counts]", + meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);Q_{DIGI} [ADC counts]", 256, 0., 256.); - - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA [TDC counts]", + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA_{DIGI} [TDC counts]", 1000, 0., 2000.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA [TDC counts]", + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA_{DIGI} [TDC counts]", 1000, 0., 2000.); - meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);x [cm];y [cm]", + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);X_{DIGI} [cm];Y_{DIGI} [cm]", 135, -135., 135., 135, -135., 135.); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{DIGI} [cm];Y_{DIGI} [cm]", 135, -135., 135., 135, -135., 135.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL DIGI hits X (-Z);X_{DIGI} [cm]", 135, -135., 135.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL DIGI hits X (+Z);X_{DIGI} [cm]", 135, -135., 135.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL DIGI hits Y (-Z);Y_{DIGI} [cm]", 135, -135., 135.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL DIGI hits Y (+Z);Y_{DIGI} [cm]", 135, -135., 135.); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL DIGI hits Z (-Z);Z_{DIGI} [cm]", 100, -304.5, -303.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL DIGI hits Z (+Z);Z_{DIGI} [cm]", 100, 303., 304.5); + + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 315, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 315, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 200, 1.55, 3.05); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 200, -3.05, -1.55); + + + meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 256, 0., 256., 0., 1024.); + meHitTvsQ_[1] = ibook.bookProfile("EtlHitTvsQZpos", "ETL DIGI ToA vs charge (+Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 256, 0., 256., 0., 1024.); + meHitQvsPhi_[0] = ibook.bookProfile("EtlHitQvsPhiZneg", "ETL DIGI charge vs #phi (-Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitQvsPhi_[1] = ibook.bookProfile("EtlHitQvsPhiZpos", "ETL DIGI charge vs #phi (+Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitQvsEta_[0] = ibook.bookProfile("EtlHitQvsEtaZneg","ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", + 100, -3.05, -1.55, 0., 1024.); + meHitQvsEta_[1] = ibook.bookProfile("EtlHitQvsEtaZpos","ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", + 100, 1.55, 3.05, 0., 1024.); + meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL DIGI ToA vs #phi (+Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 100, -3.15, 3.15, 0., 1024.); + meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZneg","ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", + 100, -3.05, -1.55, 0., 1024.); + meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", + 100, 1.55, 3.05, 0., 1024.); + } diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 58d335f1684e2..519bb33982759 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -59,11 +59,25 @@ class EtlRecHitsValidation : public DQMEDAnalyzer { // --- histograms declaration + MonitorElement* meNhits_[2]; + MonitorElement* meHitEnergy_[2]; MonitorElement* meHitTime_[2]; MonitorElement* meOccupancy_[2]; + MonitorElement* meHitX_[2]; + MonitorElement* meHitY_[2]; + MonitorElement* meHitZ_[2]; + MonitorElement* meHitPhi_[2]; + MonitorElement* meHitEta_[2]; + + MonitorElement* meHitTvsE_[2]; + MonitorElement* meHitEvsPhi_[2]; + MonitorElement* meHitEvsEta_[2]; + MonitorElement* meHitTvsPhi_[2]; + MonitorElement* meHitTvsEta_[2]; + }; @@ -106,6 +120,9 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet eventCount_++; // --- Loop over the ELT RECO hits + + unsigned int n_reco_etl[2] = {0,0}; + for (const auto& recHit: *etlRecHitsHandle) { ETLDetId detId = recHit.id(); @@ -128,8 +145,25 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + meHitX_[idet]->Fill(global_point.x()); + meHitY_[idet]->Fill(global_point.y()); + meHitZ_[idet]->Fill(global_point.z()); + meHitPhi_[idet]->Fill(global_point.phi()); + meHitEta_[idet]->Fill(global_point.eta()); + + meHitTvsE_[idet]->Fill(recHit.energy(),recHit.time()); + meHitEvsPhi_[idet]->Fill(global_point.phi(),recHit.energy()); + meHitEvsEta_[idet]->Fill(global_point.eta(),recHit.energy()); + meHitTvsPhi_[idet]->Fill(global_point.phi(),recHit.time()); + meHitTvsEta_[idet]->Fill(global_point.eta(),recHit.time()); + + n_reco_etl[idet]++; + } // recHit loop + meNhits_[0]->Fill(n_reco_etl[0]); + meNhits_[1]->Fill(n_reco_etl[1]); + } @@ -142,17 +176,53 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);energy [MeV]", 150, 0., 3.); - meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);energy [MeV]", 150, 0., 3.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL RECO hits (-Z);N_{RECO}", 250, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL RECO hits (+Z);N_{RECO}", 250, 0., 5000.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA [ns]", 250, 0., 25.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA [ns]", 250, 0., 25.); + meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);E_{RECO} [MeV]", 150, 0., 3.); + meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);E_{RECO} [MeV]", 150, 0., 3.); - meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL RECO hits occupancy (-Z);x [cm];y [cm]", + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA_{RECO} [ns]", 250, 0., 25.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA_{RECO} [ns]", 250, 0., 25.); + + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL RECO hits occupancy (-Z);X_{RECO} [cm];Y_{RECO} [cm]", 59, -130., 130., 59, -130., 130.); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);x [cm];y [cm]", + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{RECO} [cm];Y_{RECO} [cm]", 59, -130., 130., 59, -130., 130.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL RECO hits X (+Z);X_{RECO} [cm]", 135, -135., 135.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL RECO hits X (-Z);X_{RECO} [cm]", 135, -135., 135.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL RECO hits Y (+Z);Y_{RECO} [cm]", 135, -135., 135.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL RECO hits Y (-Z);Y_{RECO} [cm]", 135, -135., 135.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL RECO hits Z (+Z);Z_{RECO} [cm]", 100, 303., 304.5); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL RECO hits Z (-Z);Z_{RECO} [cm]", 100, -304.5, -303.); + + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 315, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 315, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 200, 1.55, 3.05); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 200, -3.05, -1.55); + + meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", + 100, 0., 2., 0., 100.); + meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL RECO time vs energy (-Z);E_{RECO} [MeV];ToA_{RECO} [ns]", + 100, 0., 2., 0., 100.); + meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL RECO energy vs #phi (+Z);#phi_{RECO} [rad];E_{RECO} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", + 200, 1.55, 3.05, 0., 100.); + meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", + 200, -3.05, -1.55, 0., 100.); + meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", + 200, 1.55, 3.05, 0., 100.); + meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", + 200, -3.05, -1.55, 0., 100.); + } diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 57a1456553137..1fd5642a725c1 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -70,13 +70,29 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { // --- histograms declaration - MonitorElement* meHitEnergyZpos_; - MonitorElement* meHitEnergyZneg_; - MonitorElement* meHitTimeZpos_; - MonitorElement* meHitTimeZneg_; + MonitorElement* meNhits_[2]; + MonitorElement* meNtrkPerCell_[2]; - MonitorElement* meOccupancyZpos_; - MonitorElement* meOccupancyZneg_; + MonitorElement* meHitEnergy_[2]; + MonitorElement* meHitTime_[2]; + + MonitorElement* meHitXlocal_[2]; + MonitorElement* meHitYlocal_[2]; + MonitorElement* meHitZlocal_[2]; + + MonitorElement* meOccupancy_[2]; + + MonitorElement* meHitX_[2]; + MonitorElement* meHitY_[2]; + MonitorElement* meHitZ_[2]; + MonitorElement* meHitPhi_[2]; + MonitorElement* meHitEta_[2]; + + MonitorElement* meHitTvsE_[2]; + MonitorElement* meHitEvsPhi_[2]; + MonitorElement* meHitEvsEta_[2]; + MonitorElement* meHitTvsPhi_[2]; + MonitorElement* meHitTvsEta_[2]; }; @@ -120,7 +136,8 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet eventCount_++; - std::map m_etlHits; + std::unordered_map m_etlHits[2]; + std::unordered_map > m_etlTrkPerCell[2]; // --- Loop over the BLT SIM hits for (auto const& simHit: *etlSimHitsHandle) { @@ -128,9 +145,13 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Use only hits compatible with the in-time bunch-crossing if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; - DetId id = simHit.detUnitId(); + ETLDetId id = simHit.detUnitId(); + + int idet = (id.zside()+1)/2; - auto simHitIt = m_etlHits.emplace(id.rawId(),MTDHit()).first; + m_etlTrkPerCell[idet][id.rawId()].insert(simHit.trackId()); + + auto simHitIt = m_etlHits[idet].emplace(id.rawId(),MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell (simHitIt->second).energy += 1000.*simHit.energyLoss(); @@ -154,40 +175,58 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // Histogram filling // ============================================================================== - for (auto const& hit: m_etlHits) { + for (int idet=0; idet<2; ++idet){ - if ( (hit.second).energy < hitMinEnergy_ ) continue; + meNhits_[idet]->Fill(m_etlHits[idet].size()); - // --- Get the SIM hit global position - ETLDetId detId(hit.first); + for (auto const& hit: m_etlTrkPerCell[idet]) + meNtrkPerCell_[idet]->Fill((hit.second).size()); - DetId geoId = detId.geographicalId(); - const MTDGeomDet* thedet = geom_->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; - Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); - const auto& global_point = thedet->toGlobal(local_point); + for (auto const& hit: m_etlHits[idet]) { - // --- Fill the histograms - if ( detId.zside()>0. ){ + if ( (hit.second).energy < hitMinEnergy_ ) continue; - meHitEnergyZpos_->Fill((hit.second).energy); - meHitTimeZpos_->Fill((hit.second).time); - meOccupancyZpos_->Fill(global_point.x(),global_point.y()); + // --- Get the SIM hit global position + ETLDetId detId(hit.first); - } - else { + DetId geoId = detId.geographicalId(); + const MTDGeomDet* thedet = geom_->idToDet(geoId); + if( thedet == nullptr ) + throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() + << " (" << detId.rawId()<< ") is invalid!" << std::dec + << std::endl; - meHitEnergyZneg_->Fill((hit.second).energy); - meHitTimeZneg_->Fill((hit.second).time); - meOccupancyZneg_->Fill(global_point.x(),global_point.y()); + Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); + const auto& global_point = thedet->toGlobal(local_point); - } + // --- Fill the histograms + + meHitEnergy_[idet]->Fill((hit.second).energy); + meHitTime_[idet]->Fill((hit.second).time); - } // hit loop + meHitXlocal_[idet]->Fill((hit.second).x); + meHitYlocal_[idet]->Fill((hit.second).y); + meHitZlocal_[idet]->Fill((hit.second).z); + + meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + + meHitX_[idet]->Fill(global_point.x()); + meHitY_[idet]->Fill(global_point.y()); + meHitZ_[idet]->Fill(global_point.z()); + meHitPhi_[idet]->Fill(global_point.phi()); + meHitEta_[idet]->Fill(global_point.eta()); + + meHitTvsE_[idet]->Fill((hit.second).energy,(hit.second).time); + meHitEvsPhi_[idet]->Fill(global_point.phi(),(hit.second).energy); + meHitEvsEta_[idet]->Fill(global_point.eta(),(hit.second).energy); + meHitTvsPhi_[idet]->Fill(global_point.phi(),(hit.second).time); + meHitTvsEta_[idet]->Fill(global_point.eta(),(hit.second).time); + + + } // hit loop + + } // idet loop } @@ -201,16 +240,61 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meHitEnergyZpos_ = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 200, 0., 2.); - meHitEnergyZneg_ = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 200, 0., 2.); - meHitTimeZpos_ = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 250, 0., 25.); - meHitTimeZneg_ = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 250, 0., 25.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 250, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 250, 0., 5000.); + meNtrkPerCell_[1] = ibook.book1D("EtlNtrkPerCellZpos", "Number of tracks per ETL sensor (+Z);N_{trk}", 10, 0., 10.); + meNtrkPerCell_[0] = ibook.book1D("EtlNtrkPerCellZneg", "Number of tracks per ETL sensor (-Z);N_{trk}", 10, 0., 10.); + + meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 200, 0., 2.); + meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 200, 0., 2.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 250, 0., 25.); + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 250, 0., 25.); - meOccupancyZpos_ = ibook.book2D("EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);x_{SIM} [cm];y_{SIM} [cm]", + meHitXlocal_[1] = ibook.book1D("EtlHitXlocalZpos", "ETL SIM local X (+Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); + meHitXlocal_[0] = ibook.book1D("EtlHitXlocalZneg", "ETL SIM local X (-Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); + meHitYlocal_[1] = ibook.book1D("EtlHitYlocalZpos", "ETL SIM local Y (+Z);Y_{SIM}^{LOC} [mm]", 200, -50., 50.); + meHitYlocal_[0] = ibook.book1D("EtlHitYlocalZneg", "ETL SIM local Y (-Z);Y_{SIM}^{LOC} [mm]", 200, -50., 50.); + meHitZlocal_[1] = ibook.book1D("EtlHitZlocalZpos", "ETL SIM local Z (+Z);Z_{SIM}^{LOC} [mm]", 80, -0.2, 0.2); + meHitZlocal_[0] = ibook.book1D("EtlHitZlocalZneg", "ETL SIM local Z (-Z);Z_{SIM}^{LOC} [mm]", 80, -0.2, 0.2); + + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); - meOccupancyZneg_ = ibook.book2D("EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);x_{SIM} [cm];y_{SIM} [cm]", + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 135, -135., 135.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 135, -135., 135.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 135, -135., 135.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 135, -135., 135.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303., 304.5); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.5, -303.); + + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 315, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 315, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 200, 1.55, 3.05); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 200, -3.05, -1.55); + + meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", + 100, 0., 2., 0., 100.); + meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL SIM time vs energy (-Z);E_{SIM} [MeV];T_{SIM} [ns]", + 100, 0., 2., 0., 100.); + meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL SIM energy vs #phi (+Z);#phi_{SIM} [rad];E_{SIM} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", + 100, -3.15, 3.15, 0., 100.); + meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", + 200, 1.55, 3.05, 0., 100.); + meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", + 200, -3.05, -1.55, 0., 100.); + meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", + 100, -3.15, 3.15, 0., 100.); + meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", + 200, 1.55, 3.05, 0., 100.); + meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", + 200, -3.05, -1.55, 0., 100.); + } From afe05707d8c3bfb51b0f1b69cb933867fcf63a37 Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Wed, 3 Apr 2019 17:40:06 +0200 Subject: [PATCH 677/686] Fixed local position of ETL DIGI and RECO hits and adjusted range and binning of monitoring histograms --- .../plugins/BtlDigiHitsValidation.cc | 64 +++++++++---------- .../plugins/BtlRecHitsValidation.cc | 32 +++++----- .../plugins/BtlSimHitsValidation.cc | 38 +++++------ .../plugins/EtlDigiHitsValidation.cc | 62 +++++++++--------- .../plugins/EtlRecHitsValidation.cc | 61 +++++++++--------- .../plugins/EtlSimHitsValidation.cc | 60 ++++++++--------- 6 files changed, 161 insertions(+), 156 deletions(-) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index c5dd97362e7c6..3ab287af671df 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -202,63 +202,63 @@ void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);N_{DIGI}", 250, 0., 5000.); - meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);N_{DIGI}", 250, 0., 5000.); + meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);N_{DIGI}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);N_{DIGI}", 100, 0., 5000.); meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", - 1024, 0., 1024.); + 100, 0., 1024.); meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", - 1024, 0., 1024.); + 100, 0., 1024.); meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", - 1024, 0., 1024.); + 100, 0., 1024.); meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", - 1024, 0., 1024.); + 100, 0., 1024.); meOccupancy_[0] = ibook.book2D("BtlOccupancyL","BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", - 65, -260., 260., 315, -3.15, 3.15 ); + 65, -260., 260., 126, -3.15, 3.15 ); meOccupancy_[1] = ibook.book2D("BtlOccupancyR","BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", - 65, -260., 260., 315, -3.15, 3.15 ); + 65, -260., 260., 126, -3.15, 3.15 ); - meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 135, -135., 135.); - meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 135, -135., 135.); - meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 135, -135., 135.); - meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 135, -135., 135.); - meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 520, -260., 260.); - meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 520, -260., 260.); - meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 315, -3.15, 3.15); - meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 315, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 200, -1.6, 1.6); - meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 200, -1.6, 1.6); + meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 60, -120., 120.); + meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 60, -120., 120.); + meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 60, -120., 120.); + meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 60, -120., 120.); + meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 100, -260., 260.); + meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 100, -260., 260.); + meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 126, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 126, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 100, -1.55, 1.55); + meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 100, -1.55, 1.55); meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL", "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 1024, 0., 1024., 0., 1024.); + 50, 0., 1024., 0., 1024.); meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR", "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 1024, 0., 1024., 0., 1024.); + 50, 0., 1024., 0., 1024.); meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL", "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR", "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitQvsEta_[0] = ibook.bookProfile("BtlHitQvsEtaL","BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 200, -1.6, 1.6, 0., 1024.); + 50, -1.55, 1.55, 0., 1024.); meHitQvsEta_[1] = ibook.bookProfile("BtlHitQvsEtaR","BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 200, -1.6, 1.6, 0., 1024.); + 50, -1.55, 1.55, 0., 1024.); meHitQvsZ_[0] = ibook.bookProfile("BtlHitQvsZL","BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", - 520, -260., 260., 0., 1024.); + 50, -260., 260., 0., 1024.); meHitQvsZ_[1] = ibook.bookProfile("BtlHitQvsZR","BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", - 520, -260., 260., 0., 1024.); + 50, -260., 260., 0., 1024.); meHitTvsPhi_[0] = ibook.bookProfile("BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitTvsPhi_[1] = ibook.bookProfile("BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitTvsEta_[0] = ibook.bookProfile("BtlHitTvsEtaL","BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 200, -1.6, 1.6, 0., 1024.); + 50, -1.55, 1.55, 0., 1024.); meHitTvsEta_[1] = ibook.bookProfile("BtlHitTvsEtaR","BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 200, -1.6, 1.6, 0., 1024.); + 50, -1.55, 1.55, 0., 1024.); meHitTvsZ_[0] = ibook.bookProfile("BtlHitTvsZL","BTL SIM ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", - 520, -260., 260., 0., 1024.); + 50, -260., 260., 0., 1024.); meHitTvsZ_[1] = ibook.bookProfile("BtlHitTvsZR","BTL SIM ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", - 520, -260., 260., 0., 1024.); + 50, -260., 260., 0., 1024.); } diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index 61d0d73d42281..c3b9a33ae7c23 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -189,34 +189,34 @@ void BtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;N_{RECO}", 250, 0., 5000.); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;N_{RECO}", 100, 0., 5000.); - meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;E_{RECO} [MeV]", 200, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 250, 0., 25.); + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;E_{RECO} [MeV]", 100, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 100, 0., 25.); meOccupancy_ = ibook.book2D("BtlOccupancy","BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", - 65, -260., 260., 315, -3.15, 3.15 ); + 65, -260., 260., 126, -3.15, 3.15 ); - meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 135, -135., 135.); - meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 135, -135., 135.); - meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 520, -260., 260.); - meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 315, -3.15, 3.15); - meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 200, -1.6, 1.6); + meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 60, -120., 120.); + meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 60, -120., 120.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 100, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 126, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 100, -1.55, 1.55); meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", - 100, 0., 20., 0., 100.); + 50, 0., 20., 0., 100.); meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", - 200, -1.6, 1.6, 0., 100.); + 50, -1.55, 1.55, 0., 100.); meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", - 520, -260., 260., 0., 100.); + 50, -260., 260., 0., 100.); meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", - 200, -1.6, 1.6, 0., 100.); + 50, -1.6, 1.6, 0., 100.); meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", - 520, -260., 260., 0., 100.); + 50, -260., 260., 0., 100.); } diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index ddcf68334c92e..b60e4887b4f8b 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -249,39 +249,39 @@ void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;N_{BTL cells}", 250, 0., 5000.); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;N_{BTL cells}", 100, 0., 5000.); meNtrkPerCell_ = ibook.book1D("BtlNtrkPerCell", "Number of tracks per BTL cell;N_{trk}", 10, 0., 10.); - meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 200, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 250, 0., 25.); + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 100, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 100, 0., 25.); - meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 400, -2., 2.); - meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 600, -30., 30.); - meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 400, -2., 2.); + meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -1.65, 1.65); + meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -30., 30.); + meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 100, -2., 2.); meOccupancy_ = ibook.book2D("BtlOccupancy","BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", - 520, -260., 260., 315, -3.15, 3.15 ); + 130, -260., 260., 200, -3.15, 3.15 ); - meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 135, -135., 135.); - meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 135, -135., 135.); - meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 520, -260., 260.); - meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 315, -3.15, 3.15); - meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 200, -1.6, 1.6); + meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 100, -120., 120.); + meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 100, -120., 120.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 100, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 200, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 100, -1.55, 1.55); meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL SIM time vs energy;E_{SIM} [MeV];T_{SIM} [ns]", - 100, 0., 20., 0., 100.); + 50, 0., 20., 0., 100.); meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL SIM energy vs #phi;#phi_{SIM} [rad];E_{SIM} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL SIM energy vs #eta;#eta_{SIM};E_{SIM} [MeV]", - 200, -1.6, 1.6, 0., 100.); + 50, -1.55, 1.55, 0., 100.); meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL SIM energy vs Z;Z_{SIM} [cm];E_{SIM} [MeV]", - 520, -260., 260., 0., 100.); + 50, -260., 260., 0., 100.); meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL SIM time vs #phi;#phi_{SIM} [rad];T_{SIM} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL SIM time vs #eta;#eta_{SIM};T_{SIM} [ns]", - 200, -1.6, 1.6, 0., 100.); + 50, -1.55, 1.55, 0., 100.); meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL SIM time vs Z;Z_{SIM} [cm];T_{SIM} [ns]", - 520, -260., 260., 0., 100.); + 50, -260., 260., 0., 100.); } diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index acc28a359e2ed..5bcb15290e8a4 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -27,6 +27,7 @@ #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" class EtlDigiHitsValidation : public DQMEDAnalyzer { @@ -139,8 +140,9 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe throw cms::Exception("EtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec << std::endl; - - Local3DPoint local_point(0.,0.,0.); + const PixelTopology& topo = static_cast(thedet->topology()); + + Local3DPoint local_point(topo.localX(sample.row()),topo.localY(sample.column()),0.); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms @@ -183,56 +185,56 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL DIGI hits (-Z);N_{DIGI}", 250, 0., 5000.); - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL DIGI hits (+Z);N_{DIGI}", 250, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL DIGI hits (-Z);N_{DIGI}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL DIGI hits (+Z);N_{DIGI}", 100, 0., 5000.); meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);Q_{DIGI} [ADC counts]", - 256, 0., 256.); + 100, 0., 256.); meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);Q_{DIGI} [ADC counts]", - 256, 0., 256.); + 100, 0., 256.); meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA_{DIGI} [TDC counts]", - 1000, 0., 2000.); + 100, 0., 2000.); meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA_{DIGI} [TDC counts]", - 1000, 0., 2000.); + 100, 0., 2000.); meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);X_{DIGI} [cm];Y_{DIGI} [cm]", - 135, -135., 135., 135, -135., 135.); + 135, -135., 135., 135, -135., 135.); meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{DIGI} [cm];Y_{DIGI} [cm]", - 135, -135., 135., 135, -135., 135.); + 135, -135., 135., 135, -135., 135.); - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL DIGI hits X (-Z);X_{DIGI} [cm]", 135, -135., 135.); - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL DIGI hits X (+Z);X_{DIGI} [cm]", 135, -135., 135.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL DIGI hits Y (-Z);Y_{DIGI} [cm]", 135, -135., 135.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL DIGI hits Y (+Z);Y_{DIGI} [cm]", 135, -135., 135.); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL DIGI hits Z (-Z);Z_{DIGI} [cm]", 100, -304.5, -303.); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL DIGI hits Z (+Z);Z_{DIGI} [cm]", 100, 303., 304.5); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL DIGI hits X (-Z);X_{DIGI} [cm]", 100, -130., 130.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL DIGI hits X (+Z);X_{DIGI} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL DIGI hits Y (-Z);Y_{DIGI} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL DIGI hits Y (+Z);Y_{DIGI} [cm]", 100, -130., 130.); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL DIGI hits Z (-Z);Z_{DIGI} [cm]", 100, -304.2, -303.4); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL DIGI hits Z (+Z);Z_{DIGI} [cm]", 100, 303.4, 304.2); - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 315, -3.15, 3.15); - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 315, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 200, 1.55, 3.05); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 200, -3.05, -1.55); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -2.96, -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 2.96); meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 256, 0., 256., 0., 1024.); + 50, 0., 256., 0., 1024.); meHitTvsQ_[1] = ibook.bookProfile("EtlHitTvsQZpos", "ETL DIGI ToA vs charge (+Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 256, 0., 256., 0., 1024.); + 50, 0., 256., 0., 1024.); meHitQvsPhi_[0] = ibook.bookProfile("EtlHitQvsPhiZneg", "ETL DIGI charge vs #phi (-Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitQvsPhi_[1] = ibook.bookProfile("EtlHitQvsPhiZpos", "ETL DIGI charge vs #phi (+Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitQvsEta_[0] = ibook.bookProfile("EtlHitQvsEtaZneg","ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 100, -3.05, -1.55, 0., 1024.); + 50, -2.96, -1.56, 0., 1024.); meHitQvsEta_[1] = ibook.bookProfile("EtlHitQvsEtaZpos","ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 100, 1.55, 3.05, 0., 1024.); + 50, 1.56, 2.96, 0., 1024.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL DIGI ToA vs #phi (+Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 100, -3.15, 3.15, 0., 1024.); + 50, -3.15, 3.15, 0., 1024.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZneg","ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 100, -3.05, -1.55, 0., 1024.); + 50, -2.96, -1.56, 0., 1024.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 100, 1.55, 3.05, 0., 1024.); + 50, 1.56, 2.96, 0., 1024.); } diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 519bb33982759..04db170efda90 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -27,6 +27,7 @@ #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" +#include "Geometry/CommonTopologies/interface/PixelTopology.h" class EtlRecHitsValidation : public DQMEDAnalyzer { @@ -133,8 +134,10 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet throw cms::Exception("EtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec << std::endl; + const PixelTopology& topo = static_cast(thedet->topology()); - const auto& global_point = thedet->toGlobal(Local3DPoint(0.,0.,0.)); + Local3DPoint local_point(topo.localX(recHit.row()),topo.localY(recHit.column()),0.); + const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms @@ -176,52 +179,52 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL RECO hits (-Z);N_{RECO}", 250, 0., 5000.); - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL RECO hits (+Z);N_{RECO}", 250, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL RECO hits (-Z);N_{RECO}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL RECO hits (+Z);N_{RECO}", 100, 0., 5000.); - meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);E_{RECO} [MeV]", 150, 0., 3.); - meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);E_{RECO} [MeV]", 150, 0., 3.); + meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);E_{RECO} [MeV]", 100, 0., 3.); + meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);E_{RECO} [MeV]", 100, 0., 3.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA_{RECO} [ns]", 250, 0., 25.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA_{RECO} [ns]", 250, 0., 25.); + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA_{RECO} [ns]", 100, 0., 25.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA_{RECO} [ns]", 100, 0., 25.); meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL RECO hits occupancy (-Z);X_{RECO} [cm];Y_{RECO} [cm]", - 59, -130., 130., 59, -130., 130.); + 135, -135., 135., 135, -135., 135.); meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{RECO} [cm];Y_{RECO} [cm]", - 59, -130., 130., 59, -130., 130.); + 135, -135., 135., 135, -135., 135.); - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL RECO hits X (+Z);X_{RECO} [cm]", 135, -135., 135.); - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL RECO hits X (-Z);X_{RECO} [cm]", 135, -135., 135.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL RECO hits Y (+Z);Y_{RECO} [cm]", 135, -135., 135.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL RECO hits Y (-Z);Y_{RECO} [cm]", 135, -135., 135.); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL RECO hits Z (+Z);Z_{RECO} [cm]", 100, 303., 304.5); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL RECO hits Z (-Z);Z_{RECO} [cm]", 100, -304.5, -303.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL RECO hits X (+Z);X_{RECO} [cm]", 100, -130., 130.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL RECO hits X (-Z);X_{RECO} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL RECO hits Y (+Z);Y_{RECO} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL RECO hits Y (-Z);Y_{RECO} [cm]", 100, -130., 130.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL RECO hits Z (+Z);Z_{RECO} [cm]", 100, 303.4, 304.2); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL RECO hits Z (-Z);Z_{RECO} [cm]", 100, -304.2, -303.4); - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 315, -3.15, 3.15); - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 315, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 200, 1.55, 3.05); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 200, -3.05, -1.55); + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 2.96); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -2.96, -1.56); meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", - 100, 0., 2., 0., 100.); + 50, 0., 2., 0., 100.); meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL RECO time vs energy (-Z);E_{RECO} [MeV];ToA_{RECO} [ns]", - 100, 0., 2., 0., 100.); + 50, 0., 2., 0., 100.); meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL RECO energy vs #phi (+Z);#phi_{RECO} [rad];E_{RECO} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", - 200, 1.55, 3.05, 0., 100.); + 50, 1.56, 2.96, 0., 100.); meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", - 200, -3.05, -1.55, 0., 100.); + 50, -2.96, -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", - 200, 1.55, 3.05, 0., 100.); + 50, 1.56, 2.96, 0., 100.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", - 200, -3.05, -1.55, 0., 100.); + 50, -2.96, -1.56, 0., 100.); } diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 1fd5642a725c1..7a8ed2b4d1b58 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -240,60 +240,60 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, // --- histograms booking - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 250, 0., 5000.); - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 250, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 100, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 100, 0., 5000.); meNtrkPerCell_[1] = ibook.book1D("EtlNtrkPerCellZpos", "Number of tracks per ETL sensor (+Z);N_{trk}", 10, 0., 10.); meNtrkPerCell_[0] = ibook.book1D("EtlNtrkPerCellZneg", "Number of tracks per ETL sensor (-Z);N_{trk}", 10, 0., 10.); - meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 200, 0., 2.); - meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 200, 0., 2.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 250, 0., 25.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 250, 0., 25.); + meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 100, 0., 3.); + meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 100, 0., 3.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 100, 0., 25.); + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 100, 0., 25.); meHitXlocal_[1] = ibook.book1D("EtlHitXlocalZpos", "ETL SIM local X (+Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); meHitXlocal_[0] = ibook.book1D("EtlHitXlocalZneg", "ETL SIM local X (-Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); - meHitYlocal_[1] = ibook.book1D("EtlHitYlocalZpos", "ETL SIM local Y (+Z);Y_{SIM}^{LOC} [mm]", 200, -50., 50.); - meHitYlocal_[0] = ibook.book1D("EtlHitYlocalZneg", "ETL SIM local Y (-Z);Y_{SIM}^{LOC} [mm]", 200, -50., 50.); - meHitZlocal_[1] = ibook.book1D("EtlHitZlocalZpos", "ETL SIM local Z (+Z);Z_{SIM}^{LOC} [mm]", 80, -0.2, 0.2); - meHitZlocal_[0] = ibook.book1D("EtlHitZlocalZneg", "ETL SIM local Z (-Z);Z_{SIM}^{LOC} [mm]", 80, -0.2, 0.2); + meHitYlocal_[1] = ibook.book1D("EtlHitYlocalZpos", "ETL SIM local Y (+Z);Y_{SIM}^{LOC} [mm]", 100, -48., 48.); + meHitYlocal_[0] = ibook.book1D("EtlHitYlocalZneg", "ETL SIM local Y (-Z);Y_{SIM}^{LOC} [mm]", 100, -48., 48.); + meHitZlocal_[1] = ibook.book1D("EtlHitZlocalZpos", "ETL SIM local Z (+Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16); + meHitZlocal_[0] = ibook.book1D("EtlHitZlocalZneg", "ETL SIM local Z (-Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16); meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 135, -135., 135.); - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 135, -135., 135.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 135, -135., 135.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 135, -135., 135.); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303., 304.5); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.5, -303.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 100, -130., 130.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 100, -130., 130.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303.4, 304.2); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.2, -303.4); - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 315, -3.15, 3.15); - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 315, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 200, 1.55, 3.05); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 200, -3.05, -1.55); + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 2.96); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, -2.96, -1.56); meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", - 100, 0., 2., 0., 100.); + 50, 0., 2., 0., 100.); meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL SIM time vs energy (-Z);E_{SIM} [MeV];T_{SIM} [ns]", - 100, 0., 2., 0., 100.); + 50, 0., 2., 0., 100.); meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL SIM energy vs #phi (+Z);#phi_{SIM} [rad];E_{SIM} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", - 200, 1.55, 3.05, 0., 100.); + 50, 1.56, 2.96, 0., 100.); meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", - 200, -3.05, -1.55, 0., 100.); + 50, -2.96, -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", - 100, -3.15, 3.15, 0., 100.); + 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", - 200, 1.55, 3.05, 0., 100.); + 50, 1.56, 2.96, 0., 100.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", - 200, -3.05, -1.55, 0., 100.); + 50, -2.96, -1.56, 0., 100.); } From 982b2779884f6b820e50f3f1d85ceb10060a5507 Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Tue, 9 Apr 2019 16:58:22 +0200 Subject: [PATCH 678/686] Addressed part of the comments in #26347 --- .../python/globalValidation_cff.py | 5 ++- .../plugins/BtlDigiHitsValidation.cc | 35 +++++----------- .../plugins/BtlRecHitsValidation.cc | 32 +++++---------- .../plugins/BtlSimHitsValidation.cc | 33 +++++---------- .../plugins/EtlDigiHitsValidation.cc | 41 +++++++------------ .../plugins/EtlRecHitsValidation.cc | 39 +++++++----------- .../plugins/EtlSimHitsValidation.cc | 39 +++++++----------- .../MtdValidation/python/btlDigiHits_cfi.py | 6 +++ .../MtdValidation/python/etlDigiHits_cfi.py | 6 +++ 9 files changed, 90 insertions(+), 146 deletions(-) create mode 100644 Validation/MtdValidation/python/btlDigiHits_cfi.py create mode 100644 Validation/MtdValidation/python/etlDigiHits_cfi.py diff --git a/Validation/Configuration/python/globalValidation_cff.py b/Validation/Configuration/python/globalValidation_cff.py index 6759165acc127..a849c549a3d7f 100644 --- a/Validation/Configuration/python/globalValidation_cff.py +++ b/Validation/Configuration/python/globalValidation_cff.py @@ -161,7 +161,7 @@ globalValidationHGCal = cms.Sequence(hgcalValidation) -globalValidationMTD = cms.Sequence(mtdSimValid+mtdDigiValid+mtdRecoValid) +globalValidationMTD = cms.Sequence() globalValidationOuterTracker = cms.Sequence(OuterTrackerSourceV) @@ -200,3 +200,6 @@ phase2_muon.toReplaceWith( globalValidation, _phase2_globalValidation ) from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 pp_on_AA_2018.toReplaceWith(globalValidation, globalValidation.copyAndExclude([pfTauRunDQMValidation])) +from Configuration.Eras.Modifier_phase2_timing_layer_bar_cff import phase2_timing_layer_bar +from Configuration.Eras.Modifier_phase2_timing_layer_tile_cff import phase2_timing_layer_tile +(phase2_timing_layer_tile | phase2_timing_layer_bar).toReplaceWith(globalValidationMTD, cms.Sequence(mtdSimValid+mtdDigiValid+mtdRecoValid)) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index 3ab287af671df..f4591a234025d 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -52,14 +52,7 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const MTDTopology* topo_; - const std::string folder_; - const std::string infoLabel_; - const std::string btlDigisCollection_; - - int eventCount_; edm::EDGetTokenT btlDigiHitsToken_; @@ -91,15 +84,13 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), - topo_(nullptr), - folder_(iConfig.getParameter("folder")), - infoLabel_(iConfig.getParameter("moduleLabel")), - btlDigisCollection_(iConfig.getParameter("btlDigiHitsCollection")), - eventCount_(0) { + folder_(iConfig.getParameter("folder")) { + + const std::string infoLabel = iConfig.getParameter("moduleLabel"); + const std::string btlDigisCollection = iConfig.getParameter("btlDigiHitsCollection"); - btlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), - std::string(btlDigisCollection_))); + btlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), + std::string(btlDigisCollection))); } @@ -112,15 +103,13 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::ESHandle topologyHandle; iSetup.get().get(topologyHandle); - topo_ = topologyHandle.product(); + const MTDTopology* topology = topologyHandle.product(); edm::Handle btlDigiHitsHandle; iEvent.getByToken(btlDigiHitsToken_, btlDigiHitsHandle); @@ -130,8 +119,6 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe return; } - eventCount_++; - // --- Loop over the BLT DIGI hits unsigned int n_digi_btl[2] = {0,0}; @@ -139,8 +126,8 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe for (const auto& dataFrame: *btlDigiHitsHandle) { BTLDetId detId = dataFrame.id(); - DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec @@ -272,7 +259,7 @@ void BtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& des desc.add("moduleLabel","mix"); desc.add("btlDigiHitsCollection","FTLBarrel"); - descriptions.add("btlDigiHits", desc); + descriptions.add("btlDigiHitsDefault", desc); } diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index c3b9a33ae7c23..336339bcf4263 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -52,14 +52,7 @@ class BtlRecHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const MTDTopology* topo_; - const std::string folder_; - const std::string infoLabel_; - const std::string btlRecHitsCollection_; - - int eventCount_; edm::EDGetTokenT btlRecHitsToken_; @@ -91,15 +84,13 @@ class BtlRecHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), - topo_(nullptr), - folder_(iConfig.getParameter("folder")), - infoLabel_(iConfig.getParameter("moduleLabel")), - btlRecHitsCollection_(iConfig.getParameter("btlRecHitsCollection")), - eventCount_(0) { + folder_(iConfig.getParameter("folder")) { - btlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), - std::string(btlRecHitsCollection_))); + const std::string infoLabel = iConfig.getParameter("moduleLabel"); + const std::string btlRecHitsCollection = iConfig.getParameter("btlRecHitsCollection"); + + btlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), + std::string(btlRecHitsCollection))); } @@ -112,15 +103,13 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::ESHandle topologyHandle; iSetup.get().get(topologyHandle); - topo_ = topologyHandle.product(); + const MTDTopology* topology = topologyHandle.product(); edm::Handle btlRecHitsHandle; iEvent.getByToken(btlRecHitsToken_, btlRecHitsHandle); @@ -130,7 +119,6 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet return; } - eventCount_++; // --- Loop over the BLT RECO hits @@ -139,8 +127,8 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet for (const auto& recHit: *btlRecHitsHandle) { BTLDetId detId = recHit.id(); - DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("BtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index b60e4887b4f8b..58ebc9f12ede1 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -61,17 +61,10 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const MTDTopology* topo_; - const std::string folder_; - const std::string g4InfoLabel_; - const std::string btlHitsCollection_; const float hitMinEnergy_; - int eventCount_; - edm::EDGetTokenT btlSimHitsToken_; // --- histograms declaration @@ -107,16 +100,14 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), - topo_(nullptr), folder_(iConfig.getParameter("folder")), - g4InfoLabel_(iConfig.getParameter("moduleLabelG4")), - btlHitsCollection_(iConfig.getParameter("btlSimHitsCollection")), - hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ), - eventCount_(0) { + hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - btlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel_), - std::string(btlHitsCollection_))); + const std::string g4InfoLabel = iConfig.getParameter("moduleLabelG4"); + const std::string btlHitsCollection = iConfig.getParameter("btlSimHitsCollection"); + + btlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel), + std::string(btlHitsCollection))); } @@ -129,15 +120,13 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::ESHandle topologyHandle; iSetup.get().get(topologyHandle); - topo_ = topologyHandle.product(); + const MTDTopology* topology = topologyHandle.product(); edm::Handle btlSimHitsHandle; iEvent.getByToken(btlSimHitsToken_, btlSimHitsHandle); @@ -147,8 +136,6 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet return; } - eventCount_++; - std::unordered_map m_btlHits; std::unordered_map > m_btlTrkPerCell; @@ -198,8 +185,8 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Get the SIM hit global position BTLDetId detId(hit.first); - DetId geoId = detId.geographicalId( static_cast(topo_->getMTDTopologyMode()) ); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("BtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index 5bcb15290e8a4..8cf901298e30e 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -48,13 +48,7 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const std::string folder_; - const std::string infoLabel_; - const std::string etlDigisCollection_; - - int eventCount_; edm::EDGetTokenT etlDigiHitsToken_; @@ -84,14 +78,13 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), - folder_(iConfig.getParameter("folder")), - infoLabel_(iConfig.getParameter("moduleLabel")), - etlDigisCollection_(iConfig.getParameter("etlDigiHitsCollection")), - eventCount_(0) { + folder_(iConfig.getParameter("folder")) { - etlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), - std::string(etlDigisCollection_))); + const std::string infoLabel = iConfig.getParameter("moduleLabel"); + const std::string etlDigisCollection = iConfig.getParameter("etlDigiHitsCollection"); + + etlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), + std::string(etlDigisCollection))); } @@ -104,11 +97,9 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::Handle etlDigiHitsHandle; iEvent.getByToken(etlDigiHitsToken_, etlDigiHitsHandle); @@ -118,8 +109,6 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe return; } - eventCount_++; - // --- Loop over the ELT DIGI hits unsigned int n_digi_etl[2] = {0,0}; @@ -135,7 +124,7 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe DetId geoId = detId.geographicalId(); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("EtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec @@ -211,8 +200,8 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -2.96, -1.56); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 2.96); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -3., -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 3.); meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", @@ -224,17 +213,17 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitQvsPhi_[1] = ibook.bookProfile("EtlHitQvsPhiZpos", "ETL DIGI charge vs #phi (+Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", 50, -3.15, 3.15, 0., 1024.); meHitQvsEta_[0] = ibook.bookProfile("EtlHitQvsEtaZneg","ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, -2.96, -1.56, 0., 1024.); + 50, -3., -1.56, 0., 1024.); meHitQvsEta_[1] = ibook.bookProfile("EtlHitQvsEtaZpos","ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, 1.56, 2.96, 0., 1024.); + 50, 1.56, 3., 0., 1024.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL DIGI ToA vs #phi (+Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZneg","ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, -2.96, -1.56, 0., 1024.); + 50, -3., -1.56, 0., 1024.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, 1.56, 2.96, 0., 1024.); + 50, 1.56, 3., 0., 1024.); } @@ -248,7 +237,7 @@ void EtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& des desc.add("moduleLabel","mix"); desc.add("etlDigiHitsCollection","FTLEndcap"); - descriptions.add("etlDigiHits", desc); + descriptions.add("etlDigiHitsDefault", desc); } diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 04db170efda90..73bafc647be85 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -48,13 +48,7 @@ class EtlRecHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const std::string folder_; - const std::string infoLabel_; - const std::string etlRecHitsCollection_; - - int eventCount_; edm::EDGetTokenT etlRecHitsToken_; @@ -84,14 +78,13 @@ class EtlRecHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- EtlRecHitsValidation::EtlRecHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), - folder_(iConfig.getParameter("folder")), - infoLabel_(iConfig.getParameter("moduleLabel")), - etlRecHitsCollection_(iConfig.getParameter("etlRecHitsCollection")), - eventCount_(0) { + folder_(iConfig.getParameter("folder")) { + + const std::string infoLabel = iConfig.getParameter("moduleLabel"); + const std::string etlRecHitsCollection = iConfig.getParameter("etlRecHitsCollection"); - etlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel_), - std::string(etlRecHitsCollection_))); + etlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), + std::string(etlRecHitsCollection))); } @@ -104,11 +97,9 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::Handle etlRecHitsHandle; iEvent.getByToken(etlRecHitsToken_, etlRecHitsHandle); @@ -118,8 +109,6 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet return; } - eventCount_++; - // --- Loop over the ELT RECO hits unsigned int n_reco_etl[2] = {0,0}; @@ -129,7 +118,7 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet ETLDetId detId = recHit.id(); DetId geoId = detId.geographicalId(); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("EtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec @@ -202,8 +191,8 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 2.96); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -2.96, -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 3.); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -3., -1.56); meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 2., 0., 100.); @@ -214,17 +203,17 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", - 50, 1.56, 2.96, 0., 100.); + 50, 1.56, 3., 0., 100.); meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", - 50, -2.96, -1.56, 0., 100.); + 50, -3., -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", - 50, 1.56, 2.96, 0., 100.); + 50, 1.56, 3., 0., 100.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", - 50, -2.96, -1.56, 0., 100.); + 50, -3., -1.56, 0., 100.); } diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 7a8ed2b4d1b58..dbb3f6b61fc90 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -56,16 +56,10 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { // ------------ member data ------------ - const MTDGeometry* geom_; - const std::string folder_; - const std::string g4InfoLabel_; - const std::string etlHitsCollection_; const float hitMinEnergy_; - int eventCount_; - edm::EDGetTokenT etlSimHitsToken_; // --- histograms declaration @@ -99,15 +93,14 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): - geom_(nullptr), folder_(iConfig.getParameter("folder")), - g4InfoLabel_(iConfig.getParameter("moduleLabelG4")), - etlHitsCollection_(iConfig.getParameter("etlSimHitsCollection")), - hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ), - eventCount_(0) { + hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - etlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel_), - std::string(etlHitsCollection_))); + const std::string g4InfoLabel = iConfig.getParameter("moduleLabelG4"); + const std::string etlHitsCollection = iConfig.getParameter("etlSimHitsCollection"); + + etlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel), + std::string(etlHitsCollection))); } @@ -120,11 +113,9 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet using namespace edm; - edm::LogInfo("EventInfo") << " Run = " << iEvent.id().run() << " Event = " << iEvent.id().event(); - edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); - geom_ = geometryHandle.product(); + const MTDGeometry* geom = geometryHandle.product(); edm::Handle etlSimHitsHandle; iEvent.getByToken(etlSimHitsToken_, etlSimHitsHandle); @@ -134,8 +125,6 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet return; } - eventCount_++; - std::unordered_map m_etlHits[2]; std::unordered_map > m_etlTrkPerCell[2]; @@ -191,7 +180,7 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet ETLDetId detId(hit.first); DetId geoId = detId.geographicalId(); - const MTDGeomDet* thedet = geom_->idToDet(geoId); + const MTDGeomDet* thedet = geom->idToDet(geoId); if( thedet == nullptr ) throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" << detId.rawId()<< ") is invalid!" << std::dec @@ -271,8 +260,8 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 2.96); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, -2.96, -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, 3., -1.56); meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.); @@ -283,17 +272,17 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", - 50, 1.56, 2.96, 0., 100.); + 50, 1.56, 3., 0., 100.); meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", - 50, -2.96, -1.56, 0., 100.); + 50, 3., -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", - 50, 1.56, 2.96, 0., 100.); + 50, 1.56, 3., 0., 100.); meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", - 50, -2.96, -1.56, 0., 100.); + 50, 3., -1.56, 0., 100.); } diff --git a/Validation/MtdValidation/python/btlDigiHits_cfi.py b/Validation/MtdValidation/python/btlDigiHits_cfi.py new file mode 100644 index 0000000000000..16e38657a852e --- /dev/null +++ b/Validation/MtdValidation/python/btlDigiHits_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms +from Validation.MtdValidation.btlDigiHitsDefault_cfi import btlDigiHitsDefault as _btlDigiHitsDefault +btlDigiHits = _btlDigiHitsDefault.clone() + +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(btlDigiHits, moduleLabel = "mixData") diff --git a/Validation/MtdValidation/python/etlDigiHits_cfi.py b/Validation/MtdValidation/python/etlDigiHits_cfi.py new file mode 100644 index 0000000000000..1d0fadf48b23d --- /dev/null +++ b/Validation/MtdValidation/python/etlDigiHits_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms +from Validation.MtdValidation.etlDigiHitsDefault_cfi import etlDigiHitsDefault as _etlDigiHitsDefault +etlDigiHits = _etlDigiHitsDefault.clone() + +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(etlDigiHits, moduleLabel = "mixData") From 70f402d1917b9f73a7d8642bc1a8c32987a0fc0f Mon Sep 17 00:00:00 2001 From: Massimo Date: Tue, 16 Apr 2019 14:01:26 +0200 Subject: [PATCH 679/686] - InputTag used directly in the python configuration file; - switched to ValidHandle to access the hit collections; - GeantUnits used to convert units. --- .../plugins/BtlDigiHitsValidation.cc | 21 ++++---------- .../plugins/BtlRecHitsValidation.cc | 18 ++++-------- .../plugins/BtlSimHitsValidation.cc | 29 +++++++------------ .../plugins/EtlDigiHitsValidation.cc | 21 ++++---------- .../plugins/EtlRecHitsValidation.cc | 21 ++++---------- .../plugins/EtlSimHitsValidation.cc | 28 +++++++----------- 6 files changed, 41 insertions(+), 97 deletions(-) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index f4591a234025d..57cdb7dbd3aae 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -21,9 +21,9 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" - +#include "DataFormats/Common/interface/ValidHandle.h" #include "DataFormats/ForwardDetId/interface/BTLDetId.h" +#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/Records/interface/MTDTopologyRcd.h" @@ -86,11 +86,7 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): folder_(iConfig.getParameter("folder")) { - const std::string infoLabel = iConfig.getParameter("moduleLabel"); - const std::string btlDigisCollection = iConfig.getParameter("btlDigiHitsCollection"); - - btlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), - std::string(btlDigisCollection))); + btlDigiHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -111,13 +107,7 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe iSetup.get().get(topologyHandle); const MTDTopology* topology = topologyHandle.product(); - edm::Handle btlDigiHitsHandle; - iEvent.getByToken(btlDigiHitsToken_, btlDigiHitsHandle); - - if( ! btlDigiHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No BTL DIGI hits found"; - return; - } + auto btlDigiHitsHandle = makeValid(iEvent.getHandle(btlDigiHitsToken_)); // --- Loop over the BLT DIGI hits @@ -256,8 +246,7 @@ void BtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& des edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/DigiHits"); - desc.add("moduleLabel","mix"); - desc.add("btlDigiHitsCollection","FTLBarrel"); + desc.add("inputTag", edm::InputTag("mix", "FTLBarrel")); descriptions.add("btlDigiHitsDefault", desc); diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index 336339bcf4263..510e127805d0f 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -21,9 +21,10 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" +#include "DataFormats/Common/interface/ValidHandle.h" +#include "DataFormats/ForwardDetId/interface/BTLDetId.h" #include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" -#include "DataFormats/ForwardDetId/interface/BTLDetId.h" #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/Records/interface/MTDTopologyRcd.h" @@ -89,8 +90,7 @@ BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig): const std::string infoLabel = iConfig.getParameter("moduleLabel"); const std::string btlRecHitsCollection = iConfig.getParameter("btlRecHitsCollection"); - btlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), - std::string(btlRecHitsCollection))); + btlRecHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -111,14 +111,7 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet iSetup.get().get(topologyHandle); const MTDTopology* topology = topologyHandle.product(); - edm::Handle btlRecHitsHandle; - iEvent.getByToken(btlRecHitsToken_, btlRecHitsHandle); - - if( ! btlRecHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No BTL RecHits found"; - return; - } - + auto btlRecHitsHandle = makeValid(iEvent.getHandle(btlRecHitsToken_)); // --- Loop over the BLT RECO hits @@ -217,8 +210,7 @@ void BtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& desc edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/RecHits"); - desc.add("moduleLabel","mtdRecHits"); - desc.add("btlRecHitsCollection","FTLBarrel"); + desc.add("inputTag", edm::InputTag("mtdRecHits", "FTLBarrel")); descriptions.add("btlRecHits", desc); diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index 58ebc9f12ede1..9d8c97c2c93b9 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -21,10 +21,12 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" - +#include "DataFormats/Common/interface/ValidHandle.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DataFormats/ForwardDetId/interface/BTLDetId.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/Records/interface/MTDTopologyRcd.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" @@ -103,11 +105,7 @@ BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): folder_(iConfig.getParameter("folder")), hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - const std::string g4InfoLabel = iConfig.getParameter("moduleLabelG4"); - const std::string btlHitsCollection = iConfig.getParameter("btlSimHitsCollection"); - - btlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel), - std::string(btlHitsCollection))); + btlSimHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -119,6 +117,7 @@ BtlSimHitsValidation::~BtlSimHitsValidation() { void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; + using namespace geant_units::operators; edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); @@ -128,13 +127,7 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet iSetup.get().get(topologyHandle); const MTDTopology* topology = topologyHandle.product(); - edm::Handle btlSimHitsHandle; - iEvent.getByToken(btlSimHitsToken_, btlSimHitsHandle); - - if( ! btlSimHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No BTL SIM hits found"; - return; - } + auto btlSimHitsHandle = makeValid(iEvent.getHandle(btlSimHitsToken_)); std::unordered_map m_btlHits; std::unordered_map > m_btlTrkPerCell; @@ -152,7 +145,7 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet auto simHitIt = m_btlHits.emplace(id.rawId(),MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell - (simHitIt->second).energy += 1000.*simHit.energyLoss(); + (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss()); // --- Get the time of the first SIM hit in the cell if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { @@ -194,7 +187,8 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); - Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); + Local3DPoint local_point(convertMmToCm((hit.second).x),convertMmToCm((hit.second).y),convertMmToCm((hit.second).z)); + local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); const auto& global_point = thedet->toGlobal(local_point); @@ -279,8 +273,7 @@ void BtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& desc edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/SimHits"); - desc.add("moduleLabelG4","g4SimHits"); - desc.add("btlSimHitsCollection","FastTimerHitsBarrel"); + desc.add("inputTag", edm::InputTag("g4SimHits", "FastTimerHitsBarrel")); desc.add("hitMinimumEnergy",1.); // [MeV] descriptions.add("btlSimHits", desc); diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index 8cf901298e30e..f828360c75f79 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -21,9 +21,9 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" - +#include "DataFormats/Common/interface/ValidHandle.h" #include "DataFormats/ForwardDetId/interface/ETLDetId.h" +#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" @@ -80,11 +80,7 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): folder_(iConfig.getParameter("folder")) { - const std::string infoLabel = iConfig.getParameter("moduleLabel"); - const std::string etlDigisCollection = iConfig.getParameter("etlDigiHitsCollection"); - - etlDigiHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), - std::string(etlDigisCollection))); + etlDigiHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -101,13 +97,7 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe iSetup.get().get(geometryHandle); const MTDGeometry* geom = geometryHandle.product(); - edm::Handle etlDigiHitsHandle; - iEvent.getByToken(etlDigiHitsToken_, etlDigiHitsHandle); - - if( ! etlDigiHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No ETL DIGI hits found"; - return; - } + auto etlDigiHitsHandle = makeValid(iEvent.getHandle(etlDigiHitsToken_)); // --- Loop over the ELT DIGI hits @@ -234,8 +224,7 @@ void EtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& des edm::ParameterSetDescription desc; desc.add("folder", "MTD/ETL/DigiHits"); - desc.add("moduleLabel","mix"); - desc.add("etlDigiHitsCollection","FTLEndcap"); + desc.add("inputTag", edm::InputTag("mix", "FTLEndcap")); descriptions.add("etlDigiHitsDefault", desc); diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 73bafc647be85..93212eca00134 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -21,9 +21,9 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" - +#include "DataFormats/Common/interface/ValidHandle.h" #include "DataFormats/ForwardDetId/interface/ETLDetId.h" +#include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" @@ -80,11 +80,7 @@ class EtlRecHitsValidation : public DQMEDAnalyzer { EtlRecHitsValidation::EtlRecHitsValidation(const edm::ParameterSet& iConfig): folder_(iConfig.getParameter("folder")) { - const std::string infoLabel = iConfig.getParameter("moduleLabel"); - const std::string etlRecHitsCollection = iConfig.getParameter("etlRecHitsCollection"); - - etlRecHitsToken_ = consumes (edm::InputTag(std::string(infoLabel), - std::string(etlRecHitsCollection))); + etlRecHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -101,13 +97,7 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet iSetup.get().get(geometryHandle); const MTDGeometry* geom = geometryHandle.product(); - edm::Handle etlRecHitsHandle; - iEvent.getByToken(etlRecHitsToken_, etlRecHitsHandle); - - if( ! etlRecHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No ETL RecHits found"; - return; - } + auto etlRecHitsHandle = makeValid(iEvent.getHandle(etlRecHitsToken_)); // --- Loop over the ELT RECO hits @@ -224,8 +214,7 @@ void EtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& desc edm::ParameterSetDescription desc; desc.add("folder", "MTD/ETL/RecHits"); - desc.add("moduleLabel","mtdRecHits"); - desc.add("etlRecHitsCollection","FTLEndcap"); + desc.add("inputTag", edm::InputTag("mtdRecHits", "FTLEndcap")); descriptions.add("etlRecHits", desc); diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index dbb3f6b61fc90..35a517026cb93 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -21,10 +21,12 @@ #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" - +#include "DataFormats/Common/interface/ValidHandle.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DataFormats/ForwardDetId/interface/ETLDetId.h" +#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" @@ -96,11 +98,7 @@ EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): folder_(iConfig.getParameter("folder")), hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - const std::string g4InfoLabel = iConfig.getParameter("moduleLabelG4"); - const std::string etlHitsCollection = iConfig.getParameter("etlSimHitsCollection"); - - etlSimHitsToken_ = consumes (edm::InputTag(std::string(g4InfoLabel), - std::string(etlHitsCollection))); + etlSimHitsToken_ = consumes(iConfig.getParameter("inputTag")); } @@ -112,18 +110,13 @@ EtlSimHitsValidation::~EtlSimHitsValidation() { void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; + using namespace geant_units::operators; edm::ESHandle geometryHandle; iSetup.get().get(geometryHandle); const MTDGeometry* geom = geometryHandle.product(); - edm::Handle etlSimHitsHandle; - iEvent.getByToken(etlSimHitsToken_, etlSimHitsHandle); - - if( ! etlSimHitsHandle.isValid() ) { - edm::LogWarning("DataNotFound") << "No ETL SIM hits found"; - return; - } + auto etlSimHitsHandle = makeValid(iEvent.getHandle(etlSimHitsToken_)); std::unordered_map m_etlHits[2]; std::unordered_map > m_etlTrkPerCell[2]; @@ -143,7 +136,7 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet auto simHitIt = m_etlHits[idet].emplace(id.rawId(),MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell - (simHitIt->second).energy += 1000.*simHit.energyLoss(); + (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss()); // --- Get the time of the first SIM hit in the cell if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { @@ -186,7 +179,7 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet << " (" << detId.rawId()<< ") is invalid!" << std::dec << std::endl; - Local3DPoint local_point(0.1*(hit.second).x,0.1*(hit.second).y,0.1*(hit.second).z); + Local3DPoint local_point(convertMmToCm((hit.second).x),convertMmToCm((hit.second).y),convertMmToCm((hit.second).z)); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms @@ -293,8 +286,7 @@ void EtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& desc edm::ParameterSetDescription desc; desc.add("folder", "MTD/ETL/SimHits"); - desc.add("moduleLabelG4","g4SimHits"); - desc.add("etlSimHitsCollection","FastTimerHitsEndcap"); + desc.add("inputTag", edm::InputTag("g4SimHits", "FastTimerHitsEndcap")); desc.add("hitMinimumEnergy",0.1); // [MeV] descriptions.add("etlSimHits", desc); From eb61011d79ee8112514a65292e65d938fb0c119a Mon Sep 17 00:00:00 2001 From: Massimo Date: Tue, 16 Apr 2019 16:52:28 +0200 Subject: [PATCH 680/686] clang-formatted --- .../plugins/BtlDigiHitsValidation.cc | 224 +++++++++--------- .../plugins/BtlRecHitsValidation.cc | 122 ++++------ .../plugins/BtlSimHitsValidation.cc | 168 ++++++------- .../plugins/EtlDigiHitsValidation.cc | 201 ++++++++-------- .../plugins/EtlRecHitsValidation.cc | 153 ++++++------ .../plugins/EtlSimHitsValidation.cc | 188 +++++++-------- 6 files changed, 497 insertions(+), 559 deletions(-) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index 57cdb7dbd3aae..214caf5c8cdb2 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -33,20 +33,15 @@ #include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" - class BtlDigiHitsValidation : public DQMEDAnalyzer { - public: explicit BtlDigiHitsValidation(const edm::ParameterSet&); ~BtlDigiHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -78,25 +73,18 @@ class BtlDigiHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitTvsPhi_[2]; MonitorElement* meHitTvsEta_[2]; MonitorElement* meHitTvsZ_[2]; - }; - // ------------ constructor and destructor -------------- -BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")) { - +BtlDigiHitsValidation::BtlDigiHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")) { btlDigiHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -BtlDigiHitsValidation::~BtlDigiHitsValidation() { } +BtlDigiHitsValidation::~BtlDigiHitsValidation() {} // ------------ method called for each event ------------ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; edm::ESHandle geometryHandle; @@ -111,38 +99,36 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe // --- Loop over the BLT DIGI hits - unsigned int n_digi_btl[2] = {0,0}; - - for (const auto& dataFrame: *btlDigiHitsHandle) { + unsigned int n_digi_btl[2] = {0, 0}; + for (const auto& dataFrame : *btlDigiHitsHandle) { BTLDetId detId = dataFrame.id(); - DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + DetId geoId = detId.geographicalId(static_cast(topology->getMTDTopologyMode())); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("BtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); - Local3DPoint local_point(0.,0.,0.); - local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + Local3DPoint local_point(0., 0., 0.); + local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows())); const auto& global_point = thedet->toGlobal(local_point); const auto& sample_L = dataFrame.sample(0); const auto& sample_R = dataFrame.sample(1); uint32_t adc[2] = {sample_L.data(), sample_R.data()}; - uint32_t tdc[2] = {sample_L.toa(), sample_R.toa() }; + uint32_t tdc[2] = {sample_L.toa(), sample_R.toa()}; - for (int iside=0; iside<2; ++iside) { - - if ( adc[iside] == 0 ) continue; + for (int iside = 0; iside < 2; ++iside) { + if (adc[iside] == 0) + continue; - meHitCharge_[iside]->Fill(adc[iside]); + meHitCharge_[iside]->Fill(adc[iside]); meHitTime_[iside]->Fill(tdc[iside]); - meOccupancy_[iside]->Fill(global_point.z(),global_point.phi()); + meOccupancy_[iside]->Fill(global_point.z(), global_point.phi()); meHitX_[iside]->Fill(global_point.x()); meHitY_[iside]->Fill(global_point.y()); @@ -150,106 +136,126 @@ void BtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe meHitPhi_[iside]->Fill(global_point.phi()); meHitEta_[iside]->Fill(global_point.eta()); - meHitTvsQ_[iside]->Fill(adc[iside],tdc[iside]); - meHitQvsPhi_[iside]->Fill(global_point.phi(),adc[iside]); - meHitQvsEta_[iside]->Fill(global_point.eta(),adc[iside]); - meHitQvsZ_[iside]->Fill(global_point.z(),adc[iside]); - meHitTvsPhi_[iside]->Fill(global_point.phi(),tdc[iside]); - meHitTvsEta_[iside]->Fill(global_point.eta(),tdc[iside]); - meHitTvsZ_[iside]->Fill(global_point.z(),tdc[iside]); + meHitTvsQ_[iside]->Fill(adc[iside], tdc[iside]); + meHitQvsPhi_[iside]->Fill(global_point.phi(), adc[iside]); + meHitQvsEta_[iside]->Fill(global_point.eta(), adc[iside]); + meHitQvsZ_[iside]->Fill(global_point.z(), adc[iside]); + meHitTvsPhi_[iside]->Fill(global_point.phi(), tdc[iside]); + meHitTvsEta_[iside]->Fill(global_point.eta(), tdc[iside]); + meHitTvsZ_[iside]->Fill(global_point.z(), tdc[iside]); n_digi_btl[iside]++; - } // iside loop + } // iside loop + + } // dataFrame loop - } // dataFrame loop - meNhits_[0]->Fill(n_digi_btl[0]); meNhits_[1]->Fill(n_digi_btl[1]); - } - // ------------ method for histogram booking ------------ -void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);N_{DIGI}", 100, 0., 5000.); - meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);N_{DIGI}", 100, 0., 5000.); - - meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", - 100, 0., 1024.); - meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", - 100, 0., 1024.); - meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", - 100, 0., 1024.); - meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", - 100, 0., 1024.); - - meOccupancy_[0] = ibook.book2D("BtlOccupancyL","BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", - 65, -260., 260., 126, -3.15, 3.15 ); - meOccupancy_[1] = ibook.book2D("BtlOccupancyR","BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", - 65, -260., 260., 126, -3.15, 3.15 ); - - meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 60, -120., 120.); - meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 60, -120., 120.); - meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 60, -120., 120.); - meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 60, -120., 120.); - meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 100, -260., 260.); - meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 100, -260., 260.); - meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 126, -3.15, 3.15); - meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 126, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 100, -1.55, 1.55); - meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 100, -1.55, 1.55); - - - meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL", "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 50, 0., 1024., 0., 1024.); - meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR", "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 50, 0., 1024., 0., 1024.); - meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL", "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR", "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitQvsEta_[0] = ibook.bookProfile("BtlHitQvsEtaL","BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, -1.55, 1.55, 0., 1024.); - meHitQvsEta_[1] = ibook.bookProfile("BtlHitQvsEtaR","BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, -1.55, 1.55, 0., 1024.); - meHitQvsZ_[0] = ibook.bookProfile("BtlHitQvsZL","BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", - 50, -260., 260., 0., 1024.); - meHitQvsZ_[1] = ibook.bookProfile("BtlHitQvsZR","BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", - 50, -260., 260., 0., 1024.); - meHitTvsPhi_[0] = ibook.bookProfile("BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitTvsPhi_[1] = ibook.bookProfile("BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitTvsEta_[0] = ibook.bookProfile("BtlHitTvsEtaL","BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, -1.55, 1.55, 0., 1024.); - meHitTvsEta_[1] = ibook.bookProfile("BtlHitTvsEtaR","BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, -1.55, 1.55, 0., 1024.); - meHitTvsZ_[0] = ibook.bookProfile("BtlHitTvsZL","BTL SIM ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", - 50, -260., 260., 0., 1024.); - meHitTvsZ_[1] = ibook.bookProfile("BtlHitTvsZR","BTL SIM ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", - 50, -260., 260., 0., 1024.); - + meNhits_[0] = ibook.book1D("BtlNhitsL", "Number of BTL DIGI hits (L);N_{DIGI}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("BtlNhitsR", "Number of BTL DIGI hits (R);N_{DIGI}", 100, 0., 5000.); + + meHitCharge_[0] = ibook.book1D("BtlHitChargeL", "BTL DIGI hits charge (L);Q_{DIGI} [ADC counts]", 100, 0., 1024.); + meHitCharge_[1] = ibook.book1D("BtlHitChargeR", "BTL DIGI hits charge (R);Q_{DIGI} [ADC counts]", 100, 0., 1024.); + meHitTime_[0] = ibook.book1D("BtlHitTimeL", "BTL DIGI hits ToA (L);ToA_{DIGI} [TDC counts]", 100, 0., 1024.); + meHitTime_[1] = ibook.book1D("BtlHitTimeR", "BTL DIGI hits ToA (R);ToA_{DIGI} [TDC counts]", 100, 0., 1024.); + + meOccupancy_[0] = ibook.book2D("BtlOccupancyL", + "BTL DIGI hits occupancy (L);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", + 65, + -260., + 260., + 126, + -3.15, + 3.15); + meOccupancy_[1] = ibook.book2D("BtlOccupancyR", + "BTL DIGI hits occupancy (R);Z_{DIGI} [cm]; #phi_{DIGI} [rad]", + 65, + -260., + 260., + 126, + -3.15, + 3.15); + + meHitX_[0] = ibook.book1D("BtlHitXL", "BTL DIGI hits X (L);X_{DIGI} [cm]", 60, -120., 120.); + meHitX_[1] = ibook.book1D("BtlHitXR", "BTL DIGI hits X (R);X_{DIGI} [cm]", 60, -120., 120.); + meHitY_[0] = ibook.book1D("BtlHitYL", "BTL DIGI hits Y (L);Y_{DIGI} [cm]", 60, -120., 120.); + meHitY_[1] = ibook.book1D("BtlHitYR", "BTL DIGI hits Y (R);Y_{DIGI} [cm]", 60, -120., 120.); + meHitZ_[0] = ibook.book1D("BtlHitZL", "BTL DIGI hits Z (L);Z_{DIGI} [cm]", 100, -260., 260.); + meHitZ_[1] = ibook.book1D("BtlHitZR", "BTL DIGI hits Z (R);Z_{DIGI} [cm]", 100, -260., 260.); + meHitPhi_[0] = ibook.book1D("BtlHitPhiL", "BTL DIGI hits #phi (L);#phi_{DIGI} [rad]", 126, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("BtlHitPhiR", "BTL DIGI hits #phi (R);#phi_{DIGI} [rad]", 126, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("BtlHitEtaL", "BTL DIGI hits #eta (L);#eta_{DIGI}", 100, -1.55, 1.55); + meHitEta_[1] = ibook.book1D("BtlHitEtaR", "BTL DIGI hits #eta (R);#eta_{DIGI}", 100, -1.55, 1.55); + + meHitTvsQ_[0] = ibook.bookProfile("BtlHitTvsQL", + "BTL DIGI ToA vs charge (L);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 50, + 0., + 1024., + 0., + 1024.); + meHitTvsQ_[1] = ibook.bookProfile("BtlHitTvsQR", + "BTL DIGI ToA vs charge (R);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 50, + 0., + 1024., + 0., + 1024.); + meHitQvsPhi_[0] = ibook.bookProfile("BtlHitQvsPhiL", + "BTL DIGI charge vs #phi (L);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitQvsPhi_[1] = ibook.bookProfile("BtlHitQvsPhiR", + "BTL DIGI charge vs #phi (R);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitQvsEta_[0] = ibook.bookProfile( + "BtlHitQvsEtaL", "BTL DIGI charge vs #eta (L);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.); + meHitQvsEta_[1] = ibook.bookProfile( + "BtlHitQvsEtaR", "BTL DIGI charge vs #eta (R);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -1.55, 1.55, 0., 1024.); + meHitQvsZ_[0] = ibook.bookProfile( + "BtlHitQvsZL", "BTL DIGI charge vs Z (L);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.); + meHitQvsZ_[1] = ibook.bookProfile( + "BtlHitQvsZR", "BTL DIGI charge vs Z (R);Z_{DIGI} [cm];Q_{DIGI} [ADC counts]", 50, -260., 260., 0., 1024.); + meHitTvsPhi_[0] = ibook.bookProfile( + "BtlHitTvsPhiL", "BTL DIGI ToA vs #phi (L);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.); + meHitTvsPhi_[1] = ibook.bookProfile( + "BtlHitTvsPhiR", "BTL DIGI ToA vs #phi (R);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, -3.15, 3.15, 0., 1024.); + meHitTvsEta_[0] = ibook.bookProfile( + "BtlHitTvsEtaL", "BTL DIGI ToA vs #eta (L);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.); + meHitTvsEta_[1] = ibook.bookProfile( + "BtlHitTvsEtaR", "BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.); + meHitTvsZ_[0] = ibook.bookProfile( + "BtlHitTvsZL", "BTL SIM ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); + meHitTvsZ_[1] = ibook.bookProfile( + "BtlHitTvsZR", "BTL SIM ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void BtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/DigiHits"); desc.add("inputTag", edm::InputTag("mix", "FTLBarrel")); descriptions.add("btlDigiHitsDefault", desc); - } DEFINE_FWK_MODULE(BtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index 510e127805d0f..acf702261392b 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -25,7 +25,6 @@ #include "DataFormats/ForwardDetId/interface/BTLDetId.h" #include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" - #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/Records/interface/MTDTopologyRcd.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" @@ -34,20 +33,15 @@ #include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" - class BtlRecHitsValidation : public DQMEDAnalyzer { - public: explicit BtlRecHitsValidation(const edm::ParameterSet&); ~BtlRecHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -79,28 +73,21 @@ class BtlRecHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitTvsPhi_; MonitorElement* meHitTvsEta_; MonitorElement* meHitTvsZ_; - }; - // ------------ constructor and destructor -------------- -BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")) { - +BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")) { const std::string infoLabel = iConfig.getParameter("moduleLabel"); const std::string btlRecHitsCollection = iConfig.getParameter("btlRecHitsCollection"); btlRecHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -BtlRecHitsValidation::~BtlRecHitsValidation() { } +BtlRecHitsValidation::~BtlRecHitsValidation() {} // ------------ method called for each event ------------ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; edm::ESHandle geometryHandle; @@ -117,26 +104,24 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet unsigned int n_reco_btl = 0; - for (const auto& recHit: *btlRecHitsHandle) { - + for (const auto& recHit : *btlRecHitsHandle) { BTLDetId detId = recHit.id(); - DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + DetId geoId = detId.geographicalId(static_cast(topology->getMTDTopologyMode())); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("BtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("BtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); - Local3DPoint local_point(0.,0.,0.); - local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + Local3DPoint local_point(0., 0., 0.); + local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows())); const auto& global_point = thedet->toGlobal(local_point); meHitEnergy_->Fill(recHit.energy()); meHitTime_->Fill(recHit.time()); - meOccupancy_->Fill(global_point.z(),global_point.phi()); + meOccupancy_->Fill(global_point.z(), global_point.phi()); meHitX_->Fill(global_point.x()); meHitY_->Fill(global_point.y()); @@ -144,76 +129,67 @@ void BtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meHitPhi_->Fill(global_point.phi()); meHitEta_->Fill(global_point.eta()); - meHitTvsE_->Fill(recHit.energy(),recHit.time()); - meHitEvsPhi_->Fill(global_point.phi(),recHit.energy()); - meHitEvsEta_->Fill(global_point.eta(),recHit.energy()); - meHitEvsZ_->Fill(global_point.z(),recHit.energy()); - meHitTvsPhi_->Fill(global_point.phi(),recHit.time()); - meHitTvsEta_->Fill(global_point.eta(),recHit.time()); - meHitTvsZ_->Fill(global_point.z(),recHit.time()); + meHitTvsE_->Fill(recHit.energy(), recHit.time()); + meHitEvsPhi_->Fill(global_point.phi(), recHit.energy()); + meHitEvsEta_->Fill(global_point.eta(), recHit.energy()); + meHitEvsZ_->Fill(global_point.z(), recHit.energy()); + meHitTvsPhi_->Fill(global_point.phi(), recHit.time()); + meHitTvsEta_->Fill(global_point.eta(), recHit.time()); + meHitTvsZ_->Fill(global_point.z(), recHit.time()); n_reco_btl++; - } // recHit loop + } // recHit loop meNhits_->Fill(n_reco_btl); - } - // ------------ method for histogram booking ------------ -void BtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void BtlRecHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;N_{RECO}", 100, 0., 5000.); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL RECO hits;N_{RECO}", 100, 0., 5000.); meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL RECO hits energy;E_{RECO} [MeV]", 100, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 100, 0., 25.); - - meOccupancy_ = ibook.book2D("BtlOccupancy","BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", - 65, -260., 260., 126, -3.15, 3.15 ); - - meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 60, -120., 120.); - meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 60, -120., 120.); - meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 100, -260., 260.); - meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 126, -3.15, 3.15); - meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 100, -1.55, 1.55); - - meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", - 50, 0., 20., 0., 100.); - meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", - 50, -1.55, 1.55, 0., 100.); - meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", - 50, -260., 260., 0., 100.); - meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", - 50, -1.6, 1.6, 0., 100.); - meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", - 50, -260., 260., 0., 100.); - - + meHitTime_ = ibook.book1D("BtlHitTime", "BTL RECO hits ToA;ToA_{RECO} [ns]", 100, 0., 25.); + + meOccupancy_ = ibook.book2D( + "BtlOccupancy", "BTL RECO hits occupancy;Z_{RECO} [cm]; #phi_{RECO} [rad]", 65, -260., 260., 126, -3.15, 3.15); + + meHitX_ = ibook.book1D("BtlHitX", "BTL RECO hits X;X_{RECO} [cm]", 60, -120., 120.); + meHitY_ = ibook.book1D("BtlHitY", "BTL RECO hits Y;Y_{RECO} [cm]", 60, -120., 120.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL RECO hits Z;Z_{RECO} [cm]", 100, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL RECO hits #phi;#phi_{RECO} [rad]", 126, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL RECO hits #eta;#eta_{RECO}", 100, -1.55, 1.55); + + meHitTvsE_ = + ibook.bookProfile("BtlHitTvsE", "BTL RECO ToA vs energy;E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 20., 0., 100.); + meHitEvsPhi_ = ibook.bookProfile( + "BtlHitEvsPhi", "BTL RECO energy vs #phi;#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsEta_ = ibook.bookProfile( + "BtlHitEvsEta", "BTL RECO energy vs #eta;#eta_{RECO};E_{RECO} [MeV]", 50, -1.55, 1.55, 0., 100.); + meHitEvsZ_ = + ibook.bookProfile("BtlHitEvsZ", "BTL RECO energy vs Z;Z_{RECO} [cm];E_{RECO} [MeV]", 50, -260., 260., 0., 100.); + meHitTvsPhi_ = ibook.bookProfile( + "BtlHitTvsPhi", "BTL RECO ToA vs #phi;#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsEta_ = + ibook.bookProfile("BtlHitTvsEta", "BTL RECO ToA vs #eta;#eta_{RECO};ToA_{RECO} [ns]", 50, -1.6, 1.6, 0., 100.); + meHitTvsZ_ = + ibook.bookProfile("BtlHitTvsZ", "BTL RECO ToA vs Z;Z_{RECO} [cm];ToA_{RECO} [ns]", 50, -260., 260., 0., 100.); } - - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void BtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/RecHits"); desc.add("inputTag", edm::InputTag("mtdRecHits", "FTLBarrel")); descriptions.add("btlRecHits", desc); - } DEFINE_FWK_MODULE(BtlRecHitsValidation); diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index 9d8c97c2c93b9..4a94a1ed63a29 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -35,7 +35,6 @@ #include "Geometry/MTDGeometryBuilder/interface/ProxyMTDTopology.h" #include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" - struct MTDHit { float energy; float time; @@ -44,20 +43,15 @@ struct MTDHit { float z; }; - class BtlSimHitsValidation : public DQMEDAnalyzer { - public: explicit BtlSimHitsValidation(const edm::ParameterSet&); ~BtlSimHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -96,26 +90,19 @@ class BtlSimHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitTvsPhi_; MonitorElement* meHitTvsEta_; MonitorElement* meHitTvsZ_; - }; - // ------------ constructor and destructor -------------- -BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")), - hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - +BtlSimHitsValidation::BtlSimHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")), + hitMinEnergy_(iConfig.getParameter("hitMinimumEnergy")) { btlSimHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -BtlSimHitsValidation::~BtlSimHitsValidation() { } +BtlSimHitsValidation::~BtlSimHitsValidation() {} // ------------ method called for each event ------------ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; using namespace geant_units::operators; @@ -133,34 +120,31 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet std::unordered_map > m_btlTrkPerCell; // --- Loop over the BLT SIM hits - for (auto const& simHit: *btlSimHitsHandle) { - + for (auto const& simHit : *btlSimHitsHandle) { // --- Use only hits compatible with the in-time bunch-crossing - if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; + if (simHit.tof() < 0 || simHit.tof() > 25.) + continue; DetId id = simHit.detUnitId(); m_btlTrkPerCell[id.rawId()].insert(simHit.trackId()); - auto simHitIt = m_btlHits.emplace(id.rawId(),MTDHit()).first; + auto simHitIt = m_btlHits.emplace(id.rawId(), MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss()); // --- Get the time of the first SIM hit in the cell - if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { - + if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) { (simHitIt->second).time = simHit.tof(); auto hit_pos = simHit.entryPoint(); (simHitIt->second).x = hit_pos.x(); (simHitIt->second).y = hit_pos.y(); (simHitIt->second).z = hit_pos.z(); - } - } // simHit loop - + } // simHit loop // ============================================================================== // Histogram filling @@ -168,28 +152,27 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meNhits_->Fill(m_btlHits.size()); - for (auto const& hit: m_btlTrkPerCell) + for (auto const& hit : m_btlTrkPerCell) meNtrkPerCell_->Fill((hit.second).size()); - - for (auto const& hit: m_btlHits) { - - if ( (hit.second).energy < hitMinEnergy_ ) continue; + for (auto const& hit : m_btlHits) { + if ((hit.second).energy < hitMinEnergy_) + continue; // --- Get the SIM hit global position - BTLDetId detId(hit.first); - DetId geoId = detId.geographicalId( static_cast(topology->getMTDTopologyMode()) ); + BTLDetId detId(hit.first); + DetId geoId = detId.geographicalId(static_cast(topology->getMTDTopologyMode())); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("BtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("BtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; const ProxyMTDTopology& topoproxy = static_cast(thedet->topology()); const RectangularMTDTopology& topo = static_cast(topoproxy.specificTopology()); - Local3DPoint local_point(convertMmToCm((hit.second).x),convertMmToCm((hit.second).y),convertMmToCm((hit.second).z)); + Local3DPoint local_point( + convertMmToCm((hit.second).x), convertMmToCm((hit.second).y), convertMmToCm((hit.second).z)); - local_point = topo.pixelToModuleLocalPoint(local_point,detId.row(topo.nrows()),detId.column(topo.nrows())); + local_point = topo.pixelToModuleLocalPoint(local_point, detId.row(topo.nrows()), detId.column(topo.nrows())); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms @@ -200,84 +183,77 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meHitYlocal_->Fill((hit.second).y); meHitZlocal_->Fill((hit.second).z); - meOccupancy_->Fill(global_point.z(),global_point.phi()); - - meHitX_->Fill(global_point.x()); - meHitY_->Fill(global_point.y()); - meHitZ_->Fill(global_point.z()); - meHitPhi_->Fill(global_point.phi()); - meHitEta_->Fill(global_point.eta()); + meOccupancy_->Fill(global_point.z(), global_point.phi()); - meHitTvsE_->Fill((hit.second).energy,(hit.second).time); - meHitEvsPhi_->Fill(global_point.phi(),(hit.second).energy); - meHitEvsEta_->Fill(global_point.eta(),(hit.second).energy); - meHitEvsZ_->Fill(global_point.z(),(hit.second).energy); - meHitTvsPhi_->Fill(global_point.phi(),(hit.second).time); - meHitTvsEta_->Fill(global_point.eta(),(hit.second).time); - meHitTvsZ_->Fill(global_point.z(),(hit.second).time); + meHitX_->Fill(global_point.x()); + meHitY_->Fill(global_point.y()); + meHitZ_->Fill(global_point.z()); + meHitPhi_->Fill(global_point.phi()); + meHitEta_->Fill(global_point.eta()); - } // hit loop + meHitTvsE_->Fill((hit.second).energy, (hit.second).time); + meHitEvsPhi_->Fill(global_point.phi(), (hit.second).energy); + meHitEvsEta_->Fill(global_point.eta(), (hit.second).energy); + meHitEvsZ_->Fill(global_point.z(), (hit.second).energy); + meHitTvsPhi_->Fill(global_point.phi(), (hit.second).time); + meHitTvsEta_->Fill(global_point.eta(), (hit.second).time); + meHitTvsZ_->Fill(global_point.z(), (hit.second).time); + } // hit loop } - // ------------ method for histogram booking ------------ -void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;N_{BTL cells}", 100, 0., 5000.); + meNhits_ = ibook.book1D("BtlNhits", "Number of BTL cells with SIM hits;N_{BTL cells}", 100, 0., 5000.); meNtrkPerCell_ = ibook.book1D("BtlNtrkPerCell", "Number of tracks per BTL cell;N_{trk}", 10, 0., 10.); - meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 100, 0., 20.); - meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 100, 0., 25.); - - meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -1.65, 1.65); - meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -30., 30.); - meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 100, -2., 2.); - - meOccupancy_ = ibook.book2D("BtlOccupancy","BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", - 130, -260., 260., 200, -3.15, 3.15 ); - - meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 100, -120., 120.); - meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 100, -120., 120.); - meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 100, -260., 260.); - meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 200, -3.15, 3.15); - meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 100, -1.55, 1.55); - - meHitTvsE_ = ibook.bookProfile("BtlHitTvsE", "BTL SIM time vs energy;E_{SIM} [MeV];T_{SIM} [ns]", - 50, 0., 20., 0., 100.); - meHitEvsPhi_ = ibook.bookProfile("BtlHitEvsPhi", "BTL SIM energy vs #phi;#phi_{SIM} [rad];E_{SIM} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsEta_ = ibook.bookProfile("BtlHitEvsEta","BTL SIM energy vs #eta;#eta_{SIM};E_{SIM} [MeV]", - 50, -1.55, 1.55, 0., 100.); - meHitEvsZ_ = ibook.bookProfile("BtlHitEvsZ","BTL SIM energy vs Z;Z_{SIM} [cm];E_{SIM} [MeV]", - 50, -260., 260., 0., 100.); - meHitTvsPhi_ = ibook.bookProfile("BtlHitTvsPhi", "BTL SIM time vs #phi;#phi_{SIM} [rad];T_{SIM} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsEta_ = ibook.bookProfile("BtlHitTvsEta","BTL SIM time vs #eta;#eta_{SIM};T_{SIM} [ns]", - 50, -1.55, 1.55, 0., 100.); - meHitTvsZ_ = ibook.bookProfile("BtlHitTvsZ","BTL SIM time vs Z;Z_{SIM} [cm];T_{SIM} [ns]", - 50, -260., 260., 0., 100.); - + meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 100, 0., 20.); + meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 100, 0., 25.); + + meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -1.65, 1.65); + meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -30., 30.); + meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 100, -2., 2.); + + meOccupancy_ = ibook.book2D( + "BtlOccupancy", "BTL SIM hits occupancy;z_{SIM} [cm];#phi_{SIM} [rad]", 130, -260., 260., 200, -3.15, 3.15); + + meHitX_ = ibook.book1D("BtlHitX", "BTL SIM hits X;X_{SIM} [cm]", 100, -120., 120.); + meHitY_ = ibook.book1D("BtlHitY", "BTL SIM hits Y;Y_{SIM} [cm]", 100, -120., 120.); + meHitZ_ = ibook.book1D("BtlHitZ", "BTL SIM hits Z;Z_{SIM} [cm]", 100, -260., 260.); + meHitPhi_ = ibook.book1D("BtlHitPhi", "BTL SIM hits #phi;#phi_{SIM} [rad]", 200, -3.15, 3.15); + meHitEta_ = ibook.book1D("BtlHitEta", "BTL SIM hits #eta;#eta_{SIM}", 100, -1.55, 1.55); + + meHitTvsE_ = + ibook.bookProfile("BtlHitTvsE", "BTL SIM time vs energy;E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 20., 0., 100.); + meHitEvsPhi_ = ibook.bookProfile( + "BtlHitEvsPhi", "BTL SIM energy vs #phi;#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsEta_ = + ibook.bookProfile("BtlHitEvsEta", "BTL SIM energy vs #eta;#eta_{SIM};E_{SIM} [MeV]", 50, -1.55, 1.55, 0., 100.); + meHitEvsZ_ = + ibook.bookProfile("BtlHitEvsZ", "BTL SIM energy vs Z;Z_{SIM} [cm];E_{SIM} [MeV]", 50, -260., 260., 0., 100.); + meHitTvsPhi_ = ibook.bookProfile( + "BtlHitTvsPhi", "BTL SIM time vs #phi;#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsEta_ = + ibook.bookProfile("BtlHitTvsEta", "BTL SIM time vs #eta;#eta_{SIM};T_{SIM} [ns]", 50, -1.55, 1.55, 0., 100.); + meHitTvsZ_ = + ibook.bookProfile("BtlHitTvsZ", "BTL SIM time vs Z;Z_{SIM} [cm];T_{SIM} [ns]", 50, -260., 260., 0., 100.); } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void BtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("folder", "MTD/BTL/SimHits"); desc.add("inputTag", edm::InputTag("g4SimHits", "FastTimerHitsBarrel")); - desc.add("hitMinimumEnergy",1.); // [MeV] + desc.add("hitMinimumEnergy", 1.); // [MeV] descriptions.add("btlSimHits", desc); - } DEFINE_FWK_MODULE(BtlSimHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index f828360c75f79..4674d4dc891f6 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -29,20 +29,15 @@ #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" #include "Geometry/CommonTopologies/interface/PixelTopology.h" - class EtlDigiHitsValidation : public DQMEDAnalyzer { - public: explicit EtlDigiHitsValidation(const edm::ParameterSet&); ~EtlDigiHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -72,25 +67,18 @@ class EtlDigiHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitQvsEta_[2]; MonitorElement* meHitTvsPhi_[2]; MonitorElement* meHitTvsEta_[2]; - }; - // ------------ constructor and destructor -------------- -EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")) { - +EtlDigiHitsValidation::EtlDigiHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")) { etlDigiHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -EtlDigiHitsValidation::~EtlDigiHitsValidation() { } +EtlDigiHitsValidation::~EtlDigiHitsValidation() {} // ------------ method called for each event ------------ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; edm::ESHandle geometryHandle; @@ -101,10 +89,9 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe // --- Loop over the ELT DIGI hits - unsigned int n_digi_etl[2] = {0,0}; - - for (const auto& dataFrame: *etlDigiHitsHandle) { + unsigned int n_digi_etl[2] = {0, 0}; + for (const auto& dataFrame : *etlDigiHitsHandle) { // --- Get the on-time sample int isample = 2; @@ -115,119 +102,147 @@ void EtlDigiHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSe DetId geoId = detId.geographicalId(); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("EtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("EtlDigiHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; const PixelTopology& topo = static_cast(thedet->topology()); - Local3DPoint local_point(topo.localX(sample.row()),topo.localY(sample.column()),0.); + Local3DPoint local_point(topo.localX(sample.row()), topo.localY(sample.column()), 0.); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms - int idet = (detId.zside()+1)/2; + int idet = (detId.zside() + 1) / 2; meHitCharge_[idet]->Fill(sample.data()); meHitTime_[idet]->Fill(sample.toa()); - meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + meOccupancy_[idet]->Fill(global_point.x(), global_point.y()); - meHitX_[idet]->Fill(global_point.x()); meHitY_[idet]->Fill(global_point.y()); meHitZ_[idet]->Fill(global_point.z()); meHitPhi_[idet]->Fill(global_point.phi()); meHitEta_[idet]->Fill(global_point.eta()); - meHitTvsQ_[idet]->Fill(sample.data(),sample.toa()); - meHitQvsPhi_[idet]->Fill(global_point.phi(),sample.data()); - meHitQvsEta_[idet]->Fill(global_point.eta(),sample.data()); - meHitTvsPhi_[idet]->Fill(global_point.phi(),sample.toa()); - meHitTvsEta_[idet]->Fill(global_point.eta(),sample.toa()); + meHitTvsQ_[idet]->Fill(sample.data(), sample.toa()); + meHitQvsPhi_[idet]->Fill(global_point.phi(), sample.data()); + meHitQvsEta_[idet]->Fill(global_point.eta(), sample.data()); + meHitTvsPhi_[idet]->Fill(global_point.phi(), sample.toa()); + meHitTvsEta_[idet]->Fill(global_point.eta(), sample.toa()); n_digi_etl[idet]++; - } // dataFrame loop + } // dataFrame loop meNhits_[0]->Fill(n_digi_etl[0]); meNhits_[1]->Fill(n_digi_etl[1]); - } - // ------------ method for histogram booking ------------ -void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL DIGI hits (-Z);N_{DIGI}", 100, 0., 5000.); - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL DIGI hits (+Z);N_{DIGI}", 100, 0., 5000.); - - meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);Q_{DIGI} [ADC counts]", - 100, 0., 256.); - meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);Q_{DIGI} [ADC counts]", - 100, 0., 256.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA_{DIGI} [TDC counts]", - 100, 0., 2000.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA_{DIGI} [TDC counts]", - 100, 0., 2000.); - - meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL DIGI hits occupancy (-Z);X_{DIGI} [cm];Y_{DIGI} [cm]", - 135, -135., 135., 135, -135., 135.); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{DIGI} [cm];Y_{DIGI} [cm]", - 135, -135., 135., 135, -135., 135.); - - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL DIGI hits X (-Z);X_{DIGI} [cm]", 100, -130., 130.); - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL DIGI hits X (+Z);X_{DIGI} [cm]", 100, -130., 130.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL DIGI hits Y (-Z);Y_{DIGI} [cm]", 100, -130., 130.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL DIGI hits Y (+Z);Y_{DIGI} [cm]", 100, -130., 130.); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL DIGI hits Z (-Z);Z_{DIGI} [cm]", 100, -304.2, -303.4); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL DIGI hits Z (+Z);Z_{DIGI} [cm]", 100, 303.4, 304.2); - - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -3., -1.56); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 3.); - - - meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 50, 0., 256., 0., 1024.); - meHitTvsQ_[1] = ibook.bookProfile("EtlHitTvsQZpos", "ETL DIGI ToA vs charge (+Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", - 50, 0., 256., 0., 1024.); - meHitQvsPhi_[0] = ibook.bookProfile("EtlHitQvsPhiZneg", "ETL DIGI charge vs #phi (-Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitQvsPhi_[1] = ibook.bookProfile("EtlHitQvsPhiZpos", "ETL DIGI charge vs #phi (+Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitQvsEta_[0] = ibook.bookProfile("EtlHitQvsEtaZneg","ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, -3., -1.56, 0., 1024.); - meHitQvsEta_[1] = ibook.bookProfile("EtlHitQvsEtaZpos","ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", - 50, 1.56, 3., 0., 1024.); - meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL DIGI ToA vs #phi (+Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", - 50, -3.15, 3.15, 0., 1024.); - meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZneg","ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, -3., -1.56, 0., 1024.); - meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", - 50, 1.56, 3., 0., 1024.); - + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL DIGI hits (-Z);N_{DIGI}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL DIGI hits (+Z);N_{DIGI}", 100, 0., 5000.); + + meHitCharge_[0] = ibook.book1D("EtlHitChargeZneg", "ETL DIGI hits charge (-Z);Q_{DIGI} [ADC counts]", 100, 0., 256.); + meHitCharge_[1] = ibook.book1D("EtlHitChargeZpos", "ETL DIGI hits charge (+Z);Q_{DIGI} [ADC counts]", 100, 0., 256.); + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL DIGI hits ToA (-Z);ToA_{DIGI} [TDC counts]", 100, 0., 2000.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL DIGI hits ToA (+Z);ToA_{DIGI} [TDC counts]", 100, 0., 2000.); + + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg", + "ETL DIGI hits occupancy (-Z);X_{DIGI} [cm];Y_{DIGI} [cm]", + 135, + -135., + 135., + 135, + -135., + 135.); + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos", + "ETL DIGI hits occupancy (+Z);X_{DIGI} [cm];Y_{DIGI} [cm]", + 135, + -135., + 135., + 135, + -135., + 135.); + + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL DIGI hits X (-Z);X_{DIGI} [cm]", 100, -130., 130.); + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL DIGI hits X (+Z);X_{DIGI} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL DIGI hits Y (-Z);Y_{DIGI} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL DIGI hits Y (+Z);Y_{DIGI} [cm]", 100, -130., 130.); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL DIGI hits Z (-Z);Z_{DIGI} [cm]", 100, -304.2, -303.4); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL DIGI hits Z (+Z);Z_{DIGI} [cm]", 100, 303.4, 304.2); + + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -3., -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 3.); + + meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", + "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 50, + 0., + 256., + 0., + 1024.); + meHitTvsQ_[1] = ibook.bookProfile("EtlHitTvsQZpos", + "ETL DIGI ToA vs charge (+Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", + 50, + 0., + 256., + 0., + 1024.); + meHitQvsPhi_[0] = ibook.bookProfile("EtlHitQvsPhiZneg", + "ETL DIGI charge vs #phi (-Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitQvsPhi_[1] = ibook.bookProfile("EtlHitQvsPhiZpos", + "ETL DIGI charge vs #phi (+Z);#phi_{DIGI} [rad];Q_{DIGI} [ADC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitQvsEta_[0] = ibook.bookProfile( + "EtlHitQvsEtaZneg", "ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -3., -1.56, 0., 1024.); + meHitQvsEta_[1] = ibook.bookProfile( + "EtlHitQvsEtaZpos", "ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, 1.56, 3., 0., 1024.); + meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", + "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", + "ETL DIGI ToA vs #phi (+Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", + 50, + -3.15, + 3.15, + 0., + 1024.); + meHitTvsEta_[0] = ibook.bookProfile( + "EtlHitTvsEtaZneg", "ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -3., -1.56, 0., 1024.); + meHitTvsEta_[1] = ibook.bookProfile( + "EtlHitTvsEtaZpos", "ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, 1.56, 3., 0., 1024.); } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EtlDigiHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("folder", "MTD/ETL/DigiHits"); desc.add("inputTag", edm::InputTag("mix", "FTLEndcap")); descriptions.add("etlDigiHitsDefault", desc); - } DEFINE_FWK_MODULE(EtlDigiHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 93212eca00134..139debdbe5772 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -29,20 +29,15 @@ #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" #include "Geometry/CommonTopologies/interface/PixelTopology.h" - class EtlRecHitsValidation : public DQMEDAnalyzer { - public: explicit EtlRecHitsValidation(const edm::ParameterSet&); ~EtlRecHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -72,25 +67,18 @@ class EtlRecHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitEvsEta_[2]; MonitorElement* meHitTvsPhi_[2]; MonitorElement* meHitTvsEta_[2]; - }; - // ------------ constructor and destructor -------------- -EtlRecHitsValidation::EtlRecHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")) { - +EtlRecHitsValidation::EtlRecHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")) { etlRecHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -EtlRecHitsValidation::~EtlRecHitsValidation() { } +EtlRecHitsValidation::~EtlRecHitsValidation() {} // ------------ method called for each event ------------ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; edm::ESHandle geometryHandle; @@ -101,31 +89,29 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet // --- Loop over the ELT RECO hits - unsigned int n_reco_etl[2] = {0,0}; - - for (const auto& recHit: *etlRecHitsHandle) { + unsigned int n_reco_etl[2] = {0, 0}; + for (const auto& recHit : *etlRecHitsHandle) { ETLDetId detId = recHit.id(); DetId geoId = detId.geographicalId(); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("EtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("EtlRecHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; const PixelTopology& topo = static_cast(thedet->topology()); - Local3DPoint local_point(topo.localX(recHit.row()),topo.localY(recHit.column()),0.); + Local3DPoint local_point(topo.localX(recHit.row()), topo.localY(recHit.column()), 0.); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms - int idet = (detId.zside()+1)/2; + int idet = (detId.zside() + 1) / 2; meHitEnergy_[idet]->Fill(recHit.energy()); meHitTime_[idet]->Fill(recHit.time()); - meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); + meOccupancy_[idet]->Fill(global_point.x(), global_point.y()); meHitX_[idet]->Fill(global_point.x()); meHitY_[idet]->Fill(global_point.y()); @@ -133,33 +119,30 @@ void EtlRecHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meHitPhi_[idet]->Fill(global_point.phi()); meHitEta_[idet]->Fill(global_point.eta()); - meHitTvsE_[idet]->Fill(recHit.energy(),recHit.time()); - meHitEvsPhi_[idet]->Fill(global_point.phi(),recHit.energy()); - meHitEvsEta_[idet]->Fill(global_point.eta(),recHit.energy()); - meHitTvsPhi_[idet]->Fill(global_point.phi(),recHit.time()); - meHitTvsEta_[idet]->Fill(global_point.eta(),recHit.time()); + meHitTvsE_[idet]->Fill(recHit.energy(), recHit.time()); + meHitEvsPhi_[idet]->Fill(global_point.phi(), recHit.energy()); + meHitEvsEta_[idet]->Fill(global_point.eta(), recHit.energy()); + meHitTvsPhi_[idet]->Fill(global_point.phi(), recHit.time()); + meHitTvsEta_[idet]->Fill(global_point.eta(), recHit.time()); n_reco_etl[idet]++; - } // recHit loop + } // recHit loop meNhits_[0]->Fill(n_reco_etl[0]); meNhits_[1]->Fill(n_reco_etl[1]); - } - // ------------ method for histogram booking ------------ -void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL RECO hits (-Z);N_{RECO}", 100, 0., 5000.); - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL RECO hits (+Z);N_{RECO}", 100, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL RECO hits (-Z);N_{RECO}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL RECO hits (+Z);N_{RECO}", 100, 0., 5000.); meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL RECO hits energy (-Z);E_{RECO} [MeV]", 100, 0., 3.); meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL RECO hits energy (+Z);E_{RECO} [MeV]", 100, 0., 3.); @@ -167,48 +150,57 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL RECO hits ToA (-Z);ToA_{RECO} [ns]", 100, 0., 25.); meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL RECO hits ToA (+Z);ToA_{RECO} [ns]", 100, 0., 25.); - meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg","ETL RECO hits occupancy (-Z);X_{RECO} [cm];Y_{RECO} [cm]", - 135, -135., 135., 135, -135., 135.); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos","ETL DIGI hits occupancy (+Z);X_{RECO} [cm];Y_{RECO} [cm]", - 135, -135., 135., 135, -135., 135.); - - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL RECO hits X (+Z);X_{RECO} [cm]", 100, -130., 130.); - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL RECO hits X (-Z);X_{RECO} [cm]", 100, -130., 130.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL RECO hits Y (+Z);Y_{RECO} [cm]", 100, -130., 130.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL RECO hits Y (-Z);Y_{RECO} [cm]", 100, -130., 130.); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL RECO hits Z (+Z);Z_{RECO} [cm]", 100, 303.4, 304.2); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL RECO hits Z (-Z);Z_{RECO} [cm]", 100, -304.2, -303.4); - - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 3.); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -3., -1.56); - - meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", - 50, 0., 2., 0., 100.); - meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL RECO time vs energy (-Z);E_{RECO} [MeV];ToA_{RECO} [ns]", - 50, 0., 2., 0., 100.); - meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL RECO energy vs #phi (+Z);#phi_{RECO} [rad];E_{RECO} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", - 50, 1.56, 3., 0., 100.); - meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", - 50, -3., -1.56, 0., 100.); - meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", - 50, 1.56, 3., 0., 100.); - meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", - 50, -3., -1.56, 0., 100.); - + meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg", + "ETL RECO hits occupancy (-Z);X_{RECO} [cm];Y_{RECO} [cm]", + 135, + -135., + 135., + 135, + -135., + 135.); + meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos", + "ETL DIGI hits occupancy (+Z);X_{RECO} [cm];Y_{RECO} [cm]", + 135, + -135., + 135., + 135, + -135., + 135.); + + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL RECO hits X (+Z);X_{RECO} [cm]", 100, -130., 130.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL RECO hits X (-Z);X_{RECO} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL RECO hits Y (+Z);Y_{RECO} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL RECO hits Y (-Z);Y_{RECO} [cm]", 100, -130., 130.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL RECO hits Z (+Z);Z_{RECO} [cm]", 100, 303.4, 304.2); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL RECO hits Z (-Z);Z_{RECO} [cm]", 100, -304.2, -303.4); + + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 3.); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -3., -1.56); + + meHitTvsE_[1] = ibook.bookProfile( + "EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 2., 0., 100.); + meHitTvsE_[0] = ibook.bookProfile( + "EtlHitTvsEZneg", "ETL RECO time vs energy (-Z);E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 2., 0., 100.); + meHitEvsPhi_[1] = ibook.bookProfile( + "EtlHitEvsPhiZpos", "ETL RECO energy vs #phi (+Z);#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsPhi_[0] = ibook.bookProfile( + "EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsEta_[1] = ibook.bookProfile( + "EtlHitEvsEtaZpos", "ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", 50, 1.56, 3., 0., 100.); + meHitEvsEta_[0] = ibook.bookProfile( + "EtlHitEvsEtaZneg", "ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", 50, -3., -1.56, 0., 100.); + meHitTvsPhi_[1] = ibook.bookProfile( + "EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsPhi_[0] = ibook.bookProfile( + "EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsEta_[1] = ibook.bookProfile( + "EtlHitTvsEtaZpos", "ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", 50, 1.56, 3., 0., 100.); + meHitTvsEta_[0] = ibook.bookProfile( + "EtlHitTvsEtaZpos", "ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", 50, -3., -1.56, 0., 100.); } - - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -217,7 +209,6 @@ void EtlRecHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& desc desc.add("inputTag", edm::InputTag("mtdRecHits", "FTLEndcap")); descriptions.add("etlRecHits", desc); - } DEFINE_FWK_MODULE(EtlRecHitsValidation); diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 35a517026cb93..47703c1780ea0 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -30,7 +30,6 @@ #include "Geometry/Records/interface/MTDDigiGeometryRecord.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h" - struct MTDHit { float energy; float time; @@ -39,20 +38,15 @@ struct MTDHit { float z; }; - class EtlSimHitsValidation : public DQMEDAnalyzer { - public: explicit EtlSimHitsValidation(const edm::ParameterSet&); ~EtlSimHitsValidation() override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - private: - void bookHistograms(DQMStore::IBooker &, - edm::Run const&, - edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; @@ -89,26 +83,19 @@ class EtlSimHitsValidation : public DQMEDAnalyzer { MonitorElement* meHitEvsEta_[2]; MonitorElement* meHitTvsPhi_[2]; MonitorElement* meHitTvsEta_[2]; - }; - // ------------ constructor and destructor -------------- -EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig): - folder_(iConfig.getParameter("folder")), - hitMinEnergy_( iConfig.getParameter("hitMinimumEnergy") ) { - +EtlSimHitsValidation::EtlSimHitsValidation(const edm::ParameterSet& iConfig) + : folder_(iConfig.getParameter("folder")), + hitMinEnergy_(iConfig.getParameter("hitMinimumEnergy")) { etlSimHitsToken_ = consumes(iConfig.getParameter("inputTag")); - -} - -EtlSimHitsValidation::~EtlSimHitsValidation() { } +EtlSimHitsValidation::~EtlSimHitsValidation() {} // ------------ method called for each event ------------ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; using namespace geant_units::operators; @@ -122,64 +109,59 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet std::unordered_map > m_etlTrkPerCell[2]; // --- Loop over the BLT SIM hits - for (auto const& simHit: *etlSimHitsHandle) { - + for (auto const& simHit : *etlSimHitsHandle) { // --- Use only hits compatible with the in-time bunch-crossing - if ( simHit.tof() < 0 || simHit.tof() > 25. ) continue; + if (simHit.tof() < 0 || simHit.tof() > 25.) + continue; ETLDetId id = simHit.detUnitId(); - int idet = (id.zside()+1)/2; + int idet = (id.zside() + 1) / 2; m_etlTrkPerCell[idet][id.rawId()].insert(simHit.trackId()); - auto simHitIt = m_etlHits[idet].emplace(id.rawId(),MTDHit()).first; + auto simHitIt = m_etlHits[idet].emplace(id.rawId(), MTDHit()).first; // --- Accumulate the energy (in MeV) of SIM hits in the same detector cell (simHitIt->second).energy += convertUnitsTo(0.001_MeV, simHit.energyLoss()); // --- Get the time of the first SIM hit in the cell - if( (simHitIt->second).time==0 || simHit.tof()<(simHitIt->second).time ) { - + if ((simHitIt->second).time == 0 || simHit.tof() < (simHitIt->second).time) { (simHitIt->second).time = simHit.tof(); auto hit_pos = simHit.entryPoint(); (simHitIt->second).x = hit_pos.x(); (simHitIt->second).y = hit_pos.y(); (simHitIt->second).z = hit_pos.z(); - } - } // simHit loop - + } // simHit loop // ============================================================================== // Histogram filling // ============================================================================== - for (int idet=0; idet<2; ++idet){ - + for (int idet = 0; idet < 2; ++idet) { meNhits_[idet]->Fill(m_etlHits[idet].size()); - for (auto const& hit: m_etlTrkPerCell[idet]) + for (auto const& hit : m_etlTrkPerCell[idet]) meNtrkPerCell_[idet]->Fill((hit.second).size()); - - for (auto const& hit: m_etlHits[idet]) { - - if ( (hit.second).energy < hitMinEnergy_ ) continue; + for (auto const& hit : m_etlHits[idet]) { + if ((hit.second).energy < hitMinEnergy_) + continue; // --- Get the SIM hit global position - ETLDetId detId(hit.first); + ETLDetId detId(hit.first); DetId geoId = detId.geographicalId(); const MTDGeomDet* thedet = geom->idToDet(geoId); - if( thedet == nullptr ) - throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() - << " (" << detId.rawId()<< ") is invalid!" << std::dec - << std::endl; + if (thedet == nullptr) + throw cms::Exception("EtlSimHitsValidation") << "GeographicalID: " << std::hex << geoId.rawId() << " (" + << detId.rawId() << ") is invalid!" << std::dec << std::endl; - Local3DPoint local_point(convertMmToCm((hit.second).x),convertMmToCm((hit.second).y),convertMmToCm((hit.second).z)); + Local3DPoint local_point( + convertMmToCm((hit.second).x), convertMmToCm((hit.second).y), convertMmToCm((hit.second).z)); const auto& global_point = thedet->toGlobal(local_point); // --- Fill the histograms @@ -191,46 +173,42 @@ void EtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet meHitYlocal_[idet]->Fill((hit.second).y); meHitZlocal_[idet]->Fill((hit.second).z); - meOccupancy_[idet]->Fill(global_point.x(),global_point.y()); - - meHitX_[idet]->Fill(global_point.x()); - meHitY_[idet]->Fill(global_point.y()); - meHitZ_[idet]->Fill(global_point.z()); - meHitPhi_[idet]->Fill(global_point.phi()); - meHitEta_[idet]->Fill(global_point.eta()); - - meHitTvsE_[idet]->Fill((hit.second).energy,(hit.second).time); - meHitEvsPhi_[idet]->Fill(global_point.phi(),(hit.second).energy); - meHitEvsEta_[idet]->Fill(global_point.eta(),(hit.second).energy); - meHitTvsPhi_[idet]->Fill(global_point.phi(),(hit.second).time); - meHitTvsEta_[idet]->Fill(global_point.eta(),(hit.second).time); + meOccupancy_[idet]->Fill(global_point.x(), global_point.y()); + meHitX_[idet]->Fill(global_point.x()); + meHitY_[idet]->Fill(global_point.y()); + meHitZ_[idet]->Fill(global_point.z()); + meHitPhi_[idet]->Fill(global_point.phi()); + meHitEta_[idet]->Fill(global_point.eta()); - } // hit loop + meHitTvsE_[idet]->Fill((hit.second).energy, (hit.second).time); + meHitEvsPhi_[idet]->Fill(global_point.phi(), (hit.second).energy); + meHitEvsEta_[idet]->Fill(global_point.eta(), (hit.second).energy); + meHitTvsPhi_[idet]->Fill(global_point.phi(), (hit.second).time); + meHitTvsEta_[idet]->Fill(global_point.eta(), (hit.second).time); - } // idet loop + } // hit loop + } // idet loop } - // ------------ method for histogram booking ------------ -void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, - edm::Run const& run, - edm::EventSetup const & iSetup) { - +void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker& ibook, + edm::Run const& run, + edm::EventSetup const& iSetup) { ibook.setCurrentFolder(folder_); // --- histograms booking - meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 100, 0., 5000.); - meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 100, 0., 5000.); + meNhits_[1] = ibook.book1D("EtlNhitsZpos", "Number of ETL cells with SIM hits (+Z);N_{ETL cells}", 100, 0., 5000.); + meNhits_[0] = ibook.book1D("EtlNhitsZneg", "Number of ETL cells with SIM hits (-Z);N_{ETL cells}", 100, 0., 5000.); meNtrkPerCell_[1] = ibook.book1D("EtlNtrkPerCellZpos", "Number of tracks per ETL sensor (+Z);N_{trk}", 10, 0., 10.); meNtrkPerCell_[0] = ibook.book1D("EtlNtrkPerCellZneg", "Number of tracks per ETL sensor (-Z);N_{trk}", 10, 0., 10.); meHitEnergy_[1] = ibook.book1D("EtlHitEnergyZpos", "ETL SIM hits energy (+Z);E_{SIM} [MeV]", 100, 0., 3.); meHitEnergy_[0] = ibook.book1D("EtlHitEnergyZneg", "ETL SIM hits energy (-Z);E_{SIM} [MeV]", 100, 0., 3.); - meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 100, 0., 25.); - meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 100, 0., 25.); + meHitTime_[1] = ibook.book1D("EtlHitTimeZpos", "ETL SIM hits ToA (+Z);ToA_{SIM} [ns]", 100, 0., 25.); + meHitTime_[0] = ibook.book1D("EtlHitTimeZneg", "ETL SIM hits ToA (-Z);ToA_{SIM} [ns]", 100, 0., 25.); meHitXlocal_[1] = ibook.book1D("EtlHitXlocalZpos", "ETL SIM local X (+Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); meHitXlocal_[0] = ibook.book1D("EtlHitXlocalZneg", "ETL SIM local X (-Z);X_{SIM}^{LOC} [mm]", 100, -25., 25.); @@ -239,58 +217,54 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker & ibook, meHitZlocal_[1] = ibook.book1D("EtlHitZlocalZpos", "ETL SIM local Z (+Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16); meHitZlocal_[0] = ibook.book1D("EtlHitZlocalZneg", "ETL SIM local Z (-Z);Z_{SIM}^{LOC} [mm]", 80, -0.16, 0.16); - meOccupancy_[1] = ibook.book2D("EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);X_{SIM} [cm];Y_{SIM} [cm]", - 135, -135., 135., 135, -135., 135.); - meOccupancy_[0] = ibook.book2D("EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);X_{SIM} [cm];Y_{SIM} [cm]", - 135, -135., 135., 135, -135., 135.); - - meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 100, -130., 130.); - meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 100, -130., 130.); - meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 100, -130., 130.); - meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 100, -130., 130.); - meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303.4, 304.2); - meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.2, -303.4); - - meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); - meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, 3., -1.56); - - meHitTvsE_[1] = ibook.bookProfile("EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", - 50, 0., 2., 0., 100.); - meHitTvsE_[0] = ibook.bookProfile("EtlHitTvsEZneg", "ETL SIM time vs energy (-Z);E_{SIM} [MeV];T_{SIM} [ns]", - 50, 0., 2., 0., 100.); - meHitEvsPhi_[1] = ibook.bookProfile("EtlHitEvsPhiZpos", "ETL SIM energy vs #phi (+Z);#phi_{SIM} [rad];E_{SIM} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsPhi_[0] = ibook.bookProfile("EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", - 50, -3.15, 3.15, 0., 100.); - meHitEvsEta_[1] = ibook.bookProfile("EtlHitEvsEtaZpos","ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", - 50, 1.56, 3., 0., 100.); - meHitEvsEta_[0] = ibook.bookProfile("EtlHitEvsEtaZneg","ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", - 50, 3., -1.56, 0., 100.); - meHitTvsPhi_[1] = ibook.bookProfile("EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", - 50, -3.15, 3.15, 0., 100.); - meHitTvsEta_[1] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", - 50, 1.56, 3., 0., 100.); - meHitTvsEta_[0] = ibook.bookProfile("EtlHitTvsEtaZpos","ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", - 50, 3., -1.56, 0., 100.); - + meOccupancy_[1] = ibook.book2D( + "EtlOccupancyZpos", "ETL SIM hits occupancy (+Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); + meOccupancy_[0] = ibook.book2D( + "EtlOccupancyZneg", "ETL SIM hits occupancy (-Z);X_{SIM} [cm];Y_{SIM} [cm]", 135, -135., 135., 135, -135., 135.); + + meHitX_[1] = ibook.book1D("EtlHitXZpos", "ETL SIM hits X (+Z);X_{SIM} [cm]", 100, -130., 130.); + meHitX_[0] = ibook.book1D("EtlHitXZneg", "ETL SIM hits X (-Z);X_{SIM} [cm]", 100, -130., 130.); + meHitY_[1] = ibook.book1D("EtlHitYZpos", "ETL SIM hits Y (+Z);Y_{SIM} [cm]", 100, -130., 130.); + meHitY_[0] = ibook.book1D("EtlHitYZneg", "ETL SIM hits Y (-Z);Y_{SIM} [cm]", 100, -130., 130.); + meHitZ_[1] = ibook.book1D("EtlHitZZpos", "ETL SIM hits Z (+Z);Z_{SIM} [cm]", 100, 303.4, 304.2); + meHitZ_[0] = ibook.book1D("EtlHitZZneg", "ETL SIM hits Z (-Z);Z_{SIM} [cm]", 100, -304.2, -303.4); + + meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); + meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, 3., -1.56); + + meHitTvsE_[1] = ibook.bookProfile( + "EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.); + meHitTvsE_[0] = ibook.bookProfile( + "EtlHitTvsEZneg", "ETL SIM time vs energy (-Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.); + meHitEvsPhi_[1] = ibook.bookProfile( + "EtlHitEvsPhiZpos", "ETL SIM energy vs #phi (+Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsPhi_[0] = ibook.bookProfile( + "EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.); + meHitEvsEta_[1] = ibook.bookProfile( + "EtlHitEvsEtaZpos", "ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", 50, 1.56, 3., 0., 100.); + meHitEvsEta_[0] = ibook.bookProfile( + "EtlHitEvsEtaZneg", "ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", 50, 3., -1.56, 0., 100.); + meHitTvsPhi_[1] = ibook.bookProfile( + "EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsPhi_[0] = ibook.bookProfile( + "EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); + meHitTvsEta_[1] = ibook.bookProfile( + "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", 50, 1.56, 3., 0., 100.); + meHitTvsEta_[0] = ibook.bookProfile( + "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", 50, 3., -1.56, 0., 100.); } - // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EtlSimHitsValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; desc.add("folder", "MTD/ETL/SimHits"); desc.add("inputTag", edm::InputTag("g4SimHits", "FastTimerHitsEndcap")); - desc.add("hitMinimumEnergy",0.1); // [MeV] + desc.add("hitMinimumEnergy", 0.1); // [MeV] descriptions.add("etlSimHits", desc); - } DEFINE_FWK_MODULE(EtlSimHitsValidation); From a33dd710079c0af8650652c938c2235dcdeec4b7 Mon Sep 17 00:00:00 2001 From: Massimo Date: Tue, 16 Apr 2019 19:12:37 +0200 Subject: [PATCH 681/686] Fixed two histogram names and adjusted some histogram ranges --- .../MtdValidation/plugins/BtlDigiHitsValidation.cc | 4 ++-- .../MtdValidation/plugins/BtlRecHitsValidation.cc | 3 --- .../MtdValidation/plugins/BtlSimHitsValidation.cc | 5 +++-- .../MtdValidation/plugins/EtlDigiHitsValidation.cc | 12 ++++++------ .../MtdValidation/plugins/EtlRecHitsValidation.cc | 12 ++++++------ .../MtdValidation/plugins/EtlSimHitsValidation.cc | 12 ++++++------ 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc index 214caf5c8cdb2..72aed54d6048f 100644 --- a/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlDigiHitsValidation.cc @@ -243,9 +243,9 @@ void BtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitTvsEta_[1] = ibook.bookProfile( "BtlHitTvsEtaR", "BTL DIGI ToA vs #eta (R);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -1.55, 1.55, 0., 1024.); meHitTvsZ_[0] = ibook.bookProfile( - "BtlHitTvsZL", "BTL SIM ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); + "BtlHitTvsZL", "BTL DIGI ToA vs Z (L);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); meHitTvsZ_[1] = ibook.bookProfile( - "BtlHitTvsZR", "BTL SIM ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); + "BtlHitTvsZR", "BTL DIGI ToA vs Z (R);Z_{DIGI} [cm];ToA_{DIGI} [TDC counts]", 50, -260., 260., 0., 1024.); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ diff --git a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc index acf702261392b..e47f8959f1053 100644 --- a/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlRecHitsValidation.cc @@ -78,9 +78,6 @@ class BtlRecHitsValidation : public DQMEDAnalyzer { // ------------ constructor and destructor -------------- BtlRecHitsValidation::BtlRecHitsValidation(const edm::ParameterSet& iConfig) : folder_(iConfig.getParameter("folder")) { - const std::string infoLabel = iConfig.getParameter("moduleLabel"); - const std::string btlRecHitsCollection = iConfig.getParameter("btlRecHitsCollection"); - btlRecHitsToken_ = consumes(iConfig.getParameter("inputTag")); } diff --git a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc index 4a94a1ed63a29..49cd5124c69dd 100644 --- a/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/BtlSimHitsValidation.cc @@ -1,3 +1,4 @@ + // -*- C++ -*- // // Package: Validation/MtdValidation @@ -216,8 +217,8 @@ void BtlSimHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitEnergy_ = ibook.book1D("BtlHitEnergy", "BTL SIM hits energy;E_{SIM} [MeV]", 100, 0., 20.); meHitTime_ = ibook.book1D("BtlHitTime", "BTL SIM hits ToA;ToA_{SIM} [ns]", 100, 0., 25.); - meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -1.65, 1.65); - meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -30., 30.); + meHitXlocal_ = ibook.book1D("BtlHitXlocal", "BTL SIM local X;X_{SIM}^{LOC} [mm]", 100, -30., 30.); + meHitYlocal_ = ibook.book1D("BtlHitYlocal", "BTL SIM local Y;Y_{SIM}^{LOC} [mm]", 100, -1.65, 1.65); meHitZlocal_ = ibook.book1D("BtlHitZlocal", "BTL SIM local z;z_{SIM}^{LOC} [mm]", 100, -2., 2.); meOccupancy_ = ibook.book2D( diff --git a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc index 4674d4dc891f6..9b224f8498380 100644 --- a/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlDigiHitsValidation.cc @@ -180,8 +180,8 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL DIGI hits #phi (-Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL DIGI hits #phi (+Z);#phi_{DIGI} [rad]", 100, -3.15, 3.15); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -3., -1.56); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 3.); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL DIGI hits #eta (-Z);#eta_{DIGI}", 100, -3.2, -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL DIGI hits #eta (+Z);#eta_{DIGI}", 100, 1.56, 3.2); meHitTvsQ_[0] = ibook.bookProfile("EtlHitTvsQZneg", "ETL DIGI ToA vs charge (-Z);Q_{DIGI} [ADC counts];ToA_{DIGI} [TDC counts]", @@ -212,9 +212,9 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, 0., 1024.); meHitQvsEta_[0] = ibook.bookProfile( - "EtlHitQvsEtaZneg", "ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -3., -1.56, 0., 1024.); + "EtlHitQvsEtaZneg", "ETL DIGI charge vs #eta (-Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, -3.2, -1.56, 0., 1024.); meHitQvsEta_[1] = ibook.bookProfile( - "EtlHitQvsEtaZpos", "ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, 1.56, 3., 0., 1024.); + "EtlHitQvsEtaZpos", "ETL DIGI charge vs #eta (+Z);#eta_{DIGI};Q_{DIGI} [ADC counts]", 50, 1.56, 3.2, 0., 1024.); meHitTvsPhi_[0] = ibook.bookProfile("EtlHitTvsPhiZneg", "ETL DIGI ToA vs #phi (-Z);#phi_{DIGI} [rad];ToA_{DIGI} [TDC counts]", 50, @@ -230,9 +230,9 @@ void EtlDigiHitsValidation::bookHistograms(DQMStore::IBooker& ibook, 0., 1024.); meHitTvsEta_[0] = ibook.bookProfile( - "EtlHitTvsEtaZneg", "ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -3., -1.56, 0., 1024.); + "EtlHitTvsEtaZneg", "ETL DIGI ToA vs #eta (-Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, -3.2, -1.56, 0., 1024.); meHitTvsEta_[1] = ibook.bookProfile( - "EtlHitTvsEtaZpos", "ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, 1.56, 3., 0., 1024.); + "EtlHitTvsEtaZpos", "ETL DIGI ToA vs #eta (+Z);#eta_{DIGI};ToA_{DIGI} [TDC counts]", 50, 1.56, 3.2, 0., 1024.); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ diff --git a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc index 139debdbe5772..79e04fdc52cdc 100644 --- a/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlRecHitsValidation.cc @@ -176,8 +176,8 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL RECO hits #phi (+Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL RECO hits #phi (-Z);#phi_{RECO} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 3.); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -3., -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL RECO hits #eta (+Z);#eta_{RECO}", 100, 1.56, 3.2); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL RECO hits #eta (-Z);#eta_{RECO}", 100, -3.2, -1.56); meHitTvsE_[1] = ibook.bookProfile( "EtlHitTvsEZpos", "ETL RECO time vs energy (+Z);E_{RECO} [MeV];ToA_{RECO} [ns]", 50, 0., 2., 0., 100.); @@ -188,17 +188,17 @@ void EtlRecHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitEvsPhi_[0] = ibook.bookProfile( "EtlHitEvsPhiZneg", "ETL RECO energy vs #phi (-Z);#phi_{RECO} [rad];E_{RECO} [MeV]", 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile( - "EtlHitEvsEtaZpos", "ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", 50, 1.56, 3., 0., 100.); + "EtlHitEvsEtaZpos", "ETL RECO energy vs #eta (+Z);#eta_{RECO};E_{RECO} [MeV]", 50, 1.56, 3.2, 0., 100.); meHitEvsEta_[0] = ibook.bookProfile( - "EtlHitEvsEtaZneg", "ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", 50, -3., -1.56, 0., 100.); + "EtlHitEvsEtaZneg", "ETL RECO energy vs #eta (-Z);#eta_{RECO};E_{RECO} [MeV]", 50, -3.2, -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile( "EtlHitTvsPhiZpos", "ETL RECO time vs #phi (+Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile( "EtlHitTvsPhiZneg", "ETL RECO time vs #phi (-Z);#phi_{RECO} [rad];ToA_{RECO} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile( - "EtlHitTvsEtaZpos", "ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", 50, 1.56, 3., 0., 100.); + "EtlHitTvsEtaZpos", "ETL RECO time vs #eta (+Z);#eta_{RECO};ToA_{RECO} [ns]", 50, 1.56, 3.2, 0., 100.); meHitTvsEta_[0] = ibook.bookProfile( - "EtlHitTvsEtaZpos", "ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", 50, -3., -1.56, 0., 100.); + "EtlHitTvsEtaZneg", "ETL RECO time vs #eta (-Z);#eta_{RECO};ToA_{RECO} [ns]", 50, -3.2, -1.56, 0., 100.); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ diff --git a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc index 47703c1780ea0..d0f284a932c11 100644 --- a/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc +++ b/Validation/MtdValidation/plugins/EtlSimHitsValidation.cc @@ -231,8 +231,8 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitPhi_[1] = ibook.book1D("EtlHitPhiZpos", "ETL SIM hits #phi (+Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); meHitPhi_[0] = ibook.book1D("EtlHitPhiZneg", "ETL SIM hits #phi (-Z);#phi_{SIM} [rad]", 100, -3.15, 3.15); - meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.); - meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, 3., -1.56); + meHitEta_[1] = ibook.book1D("EtlHitEtaZpos", "ETL SIM hits #eta (+Z);#eta_{SIM}", 100, 1.56, 3.2); + meHitEta_[0] = ibook.book1D("EtlHitEtaZneg", "ETL SIM hits #eta (-Z);#eta_{SIM}", 100, -3.2, -1.56); meHitTvsE_[1] = ibook.bookProfile( "EtlHitTvsEZpos", "ETL SIM time vs energy (+Z);E_{SIM} [MeV];T_{SIM} [ns]", 50, 0., 2., 0., 100.); @@ -243,17 +243,17 @@ void EtlSimHitsValidation::bookHistograms(DQMStore::IBooker& ibook, meHitEvsPhi_[0] = ibook.bookProfile( "EtlHitEvsPhiZneg", "ETL SIM energy vs #phi (-Z);#phi_{SIM} [rad];E_{SIM} [MeV]", 50, -3.15, 3.15, 0., 100.); meHitEvsEta_[1] = ibook.bookProfile( - "EtlHitEvsEtaZpos", "ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", 50, 1.56, 3., 0., 100.); + "EtlHitEvsEtaZpos", "ETL SIM energy vs #eta (+Z);#eta_{SIM};E_{SIM} [MeV]", 50, 1.56, 3.2, 0., 100.); meHitEvsEta_[0] = ibook.bookProfile( - "EtlHitEvsEtaZneg", "ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", 50, 3., -1.56, 0., 100.); + "EtlHitEvsEtaZneg", "ETL SIM energy vs #eta (-Z);#eta_{SIM};E_{SIM} [MeV]", 50, -3.2, -1.56, 0., 100.); meHitTvsPhi_[1] = ibook.bookProfile( "EtlHitTvsPhiZpos", "ETL SIM time vs #phi (+Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsPhi_[0] = ibook.bookProfile( "EtlHitTvsPhiZneg", "ETL SIM time vs #phi (-Z);#phi_{SIM} [rad];T_{SIM} [ns]", 50, -3.15, 3.15, 0., 100.); meHitTvsEta_[1] = ibook.bookProfile( - "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", 50, 1.56, 3., 0., 100.); + "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (+Z);#eta_{SIM};T_{SIM} [ns]", 50, 1.56, 3.2, 0., 100.); meHitTvsEta_[0] = ibook.bookProfile( - "EtlHitTvsEtaZpos", "ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", 50, 3., -1.56, 0., 100.); + "EtlHitTvsEtaZneg", "ETL SIM time vs #eta (-Z);#eta_{SIM};T_{SIM} [ns]", 50, -3.2, -1.56, 0., 100.); } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ From 271ec308403b8caf45fbd3e8affbef28e60bc2b1 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Wed, 17 Apr 2019 18:12:53 +0200 Subject: [PATCH 682/686] DYTuseThrsParametrization set to False --- .../GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc | 2 +- RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py | 2 +- .../python/GlobalTrajectoryBuilderCommon_cff.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc index 0e2704f0523f7..ffe4850aa085c 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc +++ b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc @@ -358,7 +358,7 @@ void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions descGlbMuonRefitter.add("DYTselector",1); descGlbMuonRefitter.add("DYTupdator", false); descGlbMuonRefitter.add("DYTuseAPE", false ); - descGlbMuonRefitter.add("DYTuseThrsParametrization", true); + descGlbMuonRefitter.add("DYTuseThrsParametrization", false); { edm::ParameterSetDescription descDYTthrs; descDYTthrs.add>("eta0p8", {1,-0.919853, 0.990742}); diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py index f9eb3514cbf84..131b745e4e7e2 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalMuonRefitter_cff.py @@ -33,7 +33,7 @@ DYTupdator = cms.bool(True), DYTuseAPE = cms.bool(False), ## Parameters for DYT threshold parametrization - DYTuseThrsParametrization = cms.bool(True), + DYTuseThrsParametrization = cms.bool(False), DYTthrsParameters = cms.PSet( eta0p8 = cms.vdouble(1, -0.919853, 0.990742), eta1p2 = cms.vdouble(1, -0.897354, 0.987738), diff --git a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py index d9e95b57a27d9..0213fd81dce9c 100644 --- a/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py +++ b/RecoMuon/GlobalTrackingTools/python/GlobalTrajectoryBuilderCommon_cff.py @@ -57,7 +57,7 @@ DYTupdator = cms.bool(False), DYTuseAPE = cms.bool(False), ## Parameters for DYT threshold parametrization - DYTuseThrsParametrization = cms.bool(True), + DYTuseThrsParametrization = cms.bool(False), DYTthrsParameters = cms.PSet( eta0p8 = cms.vdouble(1, -0.919853, 0.990742), eta1p2 = cms.vdouble(1, -0.897354, 0.987738), From 06a38d690d42d3a6cb896dd49c6ab2fea69e24e3 Mon Sep 17 00:00:00 2001 From: Massimo Casarsa Date: Wed, 17 Apr 2019 18:31:44 +0200 Subject: [PATCH 683/686] Fixed the BTL and ETL config files to run the premixing --- Validation/MtdValidation/python/btlDigiHits_cfi.py | 2 +- Validation/MtdValidation/python/etlDigiHits_cfi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/MtdValidation/python/btlDigiHits_cfi.py b/Validation/MtdValidation/python/btlDigiHits_cfi.py index 16e38657a852e..eb8c2dafd010c 100644 --- a/Validation/MtdValidation/python/btlDigiHits_cfi.py +++ b/Validation/MtdValidation/python/btlDigiHits_cfi.py @@ -3,4 +3,4 @@ btlDigiHits = _btlDigiHitsDefault.clone() from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 -premix_stage2.toModify(btlDigiHits, moduleLabel = "mixData") +premix_stage2.toModify(btlDigiHits, inputTag = cms.InputTag("mixData","FTLBarrel")) diff --git a/Validation/MtdValidation/python/etlDigiHits_cfi.py b/Validation/MtdValidation/python/etlDigiHits_cfi.py index 1d0fadf48b23d..61a5ee009a46c 100644 --- a/Validation/MtdValidation/python/etlDigiHits_cfi.py +++ b/Validation/MtdValidation/python/etlDigiHits_cfi.py @@ -3,4 +3,4 @@ etlDigiHits = _etlDigiHitsDefault.clone() from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 -premix_stage2.toModify(etlDigiHits, moduleLabel = "mixData") +premix_stage2.toModify(etlDigiHits, inputTag = cms.InputTag("mixData","FTLEndcap")) From cffa209dae4bd3048ff7c853c9a5985b418f708b Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2019 18:33:05 +0200 Subject: [PATCH 684/686] fixing getPayloadData.py to be able to compile --- CondCore/Utilities/scripts/getPayloadData.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CondCore/Utilities/scripts/getPayloadData.py b/CondCore/Utilities/scripts/getPayloadData.py index ee7c7792a6a4d..7e998128e1c1d 100755 --- a/CondCore/Utilities/scripts/getPayloadData.py +++ b/CondCore/Utilities/scripts/getPayloadData.py @@ -219,8 +219,8 @@ def discover(): def output(description, param): if args.verbose: - print '' - print description, param + print('') + print(description, param) if __name__ == '__main__': @@ -299,9 +299,9 @@ def output(description, param): try: filename = json.loads( result )['file'] #print 'File name',filename - except ValueError, e: + except ValueError as e: os.write( 2, 'Value error when getting image name: %s\n' % str( e )) - except KeyError, e: + except KeyError as e: os.write( 2, 'Key error when getting image name: %s\n' % str( e )) if not filename or not os.path.isfile( filename ): @@ -310,7 +310,7 @@ def output(description, param): try: with open( filename, 'r' ) as f: shutil.copyfileobj( f, sys.stdout ) - except IOError, e: + except IOError as e: os.write( 2, 'IO error when streaming image: %s' % str( e )) finally: os.remove( filename ) From 84d77d12248aa785b7dcd96ec31cd3e6bb4ac8c0 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Thu, 18 Apr 2019 12:25:32 +0200 Subject: [PATCH 685/686] Add static const to etaRegionStr --- .../interface/DynamicTruncation.h | 1 + .../interface/GlobalMuonRefitter.h | 2 +- .../plugins/GlobalTrackQualityProducer.cc | 17 +++-------------- .../src/DynamicTruncation.cc | 2 +- .../src/GlobalMuonRefitter.cc | 8 ++++---- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 6040cf3c07ac8..41a62a1a4c533 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -107,6 +107,7 @@ class DynamicTruncation { void useSegment(CSCSegment const &, TrajectoryStateOnSurface const &); void sort(ConstRecHitContainer&); void setEtaRegion(); + static edm::ParameterSetDescription fillDefaultThrsParameters(); ConstRecHitContainer result, prelFitMeas; bool useAPE; diff --git a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h index 01ae9e2a3d19a..05a6bb6d3b2d8 100644 --- a/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h +++ b/RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h @@ -172,7 +172,7 @@ class GlobalMuonRefitter { int theDYTselector; bool theDYTupdator; bool theDYTuseAPE; - bool dytParThrsMode; + bool theDYTParThrsMode; edm::ParameterSet theDYTthrsParameters; reco::DYTInfo *dytInfo; diff --git a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc index ffe4850aa085c..49e4ecfbfa60e 100644 --- a/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc +++ b/RecoMuon/GlobalTrackingTools/plugins/GlobalTrackQualityProducer.cc @@ -328,22 +328,13 @@ void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions desc.add("BaseLabel","GLB"); { edm::ParameterSetDescription descGlbMuonRefitter; + descGlbMuonRefitter.setAllowAnything(); descGlbMuonRefitter.add("DTRecSegmentLabel" , edm::InputTag("dt1DRecHits")); descGlbMuonRefitter.add("CSCRecSegmentLabel" , edm::InputTag("csc2DRecHits")); descGlbMuonRefitter.add("GEMRecHitLabel" , edm::InputTag("gemRecHits")); descGlbMuonRefitter.add("ME0RecHitLabel" , edm::InputTag("me0Segments")); descGlbMuonRefitter.add("RPCRecSegmentLabel" , edm::InputTag("rpcRecHits")); - descGlbMuonRefitter.add("MuonHitsOption", 1); - descGlbMuonRefitter.add("PtCut", 1.0); - descGlbMuonRefitter.add("Chi2ProbabilityCut", 30.0); - descGlbMuonRefitter.add("Chi2CutCSC", 1.0); - descGlbMuonRefitter.add("Chi2CutDT", 30.0); - descGlbMuonRefitter.add("Chi2CutGEM", 1.0); - descGlbMuonRefitter.add("Chi2CutME0", 1.0); - descGlbMuonRefitter.add("Chi2CutRPC", 1.0); - descGlbMuonRefitter.add("HitThreshold", 1); - descGlbMuonRefitter.add("Fitter", "KFFitterForRefitInsideOut"); descGlbMuonRefitter.add("Smoother", "KFSmootherForRefitInsideOut"); descGlbMuonRefitter.add("Propagator", "SmartPropagatorAnyRK"); @@ -363,7 +354,7 @@ void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions edm::ParameterSetDescription descDYTthrs; descDYTthrs.add>("eta0p8", {1,-0.919853, 0.990742}); descDYTthrs.add>("eta1p2", {1,-0.897354, 0.987738}); - descDYTthrs.add>("eta2p0", {1,-0.986855, 0.998516}); + descDYTthrs.add>("eta2p0", {4,-0.986855, 0.998516}); descDYTthrs.add>("eta2p2", {1,-0.940342, 0.992955}); descDYTthrs.add>("eta2p4", {1,-0.947633, 0.993762}); descGlbMuonRefitter.add("DYTthrsParameters", descDYTthrs); @@ -374,14 +365,12 @@ void GlobalTrackQualityProducer::fillDescriptions(edm::ConfigurationDescriptions descGlbMuonRefitter.add("TrackerSkipSection", -1); descGlbMuonRefitter.add("RefitFlag", true ); - //descRefitter.add("GlobalMuonRefitter", descGlbMuonRefitter); desc.add("RefitterParameters", descGlbMuonRefitter); } - //desc.add("RefitterParameters", descRefitter); desc.add("nSigma", 3.0); desc.add("MaxChi2", 100000.0); - descriptions.add("GlobalTrackQualityProducer", desc); + descriptions.add("globalTrackQualityProducer", desc); } //#include "FWCore/Framework/interface/MakerMacros.h" //DEFINE_FWK_MODULE(GlobalTrackQualityProducer); diff --git a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc index 5347690f2eae5..7e923365af365 100644 --- a/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc +++ b/RecoMuon/GlobalTrackingTools/src/DynamicTruncation.cc @@ -35,7 +35,7 @@ using namespace std; using namespace reco; namespace dyt_utils{ - std::map etaRegionStr { {etaRegion::eta0p8, "eta0p8"}, + static const std::map etaRegionStr { {etaRegion::eta0p8, "eta0p8"}, {etaRegion::eta1p2, "eta1p2"}, {etaRegion::eta2p0, "eta2p0"}, {etaRegion::eta2p2, "eta2p2"}, diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc index 17f96d97cc7f1..3ffecf9f09860 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc @@ -121,8 +121,8 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par, theDYTselector = par.getParameter("DYTselector"); theDYTupdator = par.getParameter("DYTupdator"); theDYTuseAPE = par.getParameter("DYTuseAPE"); - dytParThrsMode = par.getParameter("DYTuseThrsParametrization"); - if (dytParThrsMode) theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); + theDYTParThrsMode = par.getParameter("DYTuseThrsParametrization"); + if (theDYTParThrsMode) theDYTthrsParameters = par.getParameter< edm::ParameterSet >("DYTthrsParameters"); dytInfo = new reco::DYTInfo(); if (par.existsAs("RescaleErrorFactor")) { @@ -280,8 +280,8 @@ vector GlobalMuonRefitter::refit(const reco::Track& globalTrack, dytRefit.setThr(theDYTthrs); dytRefit.setUpdateState(theDYTupdator); dytRefit.setUseAPE(theDYTuseAPE); - if(dytParThrsMode) { - dytRefit.setParThrsMode(dytParThrsMode); + if(theDYTParThrsMode) { + dytRefit.setParThrsMode(theDYTParThrsMode); dytRefit.setThrsMap(theDYTthrsParameters); dytRefit.setRecoP(globalTrack.p()); dytRefit.setRecoEta(globalTrack.eta()); From a5ba43996aa81beea8b0b56632037f596a50a828 Mon Sep 17 00:00:00 2001 From: Claudio Caputo Date: Thu, 18 Apr 2019 15:21:00 +0200 Subject: [PATCH 686/686] Remove undefined symbols --- RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h | 1 - 1 file changed, 1 deletion(-) diff --git a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h index 41a62a1a4c533..6040cf3c07ac8 100644 --- a/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h +++ b/RecoMuon/GlobalTrackingTools/interface/DynamicTruncation.h @@ -107,7 +107,6 @@ class DynamicTruncation { void useSegment(CSCSegment const &, TrajectoryStateOnSurface const &); void sort(ConstRecHitContainer&); void setEtaRegion(); - static edm::ParameterSetDescription fillDefaultThrsParameters(); ConstRecHitContainer result, prelFitMeas; bool useAPE;